text
stringlengths
1
1.05M
# ORG 8000 MVI A,80 OUT 43 MVI A,01 OUT 40 RLC JMP 8006 HLT
// Copyright 2020-2021 The Ray Authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. #include "abstract_ray_runtime.h" #include <ray/api.h> #include <ray/api/ray_exception.h> #include <ray/util/logging.h> #include <cassert> #include "../config_internal.h" #include "../util/function_helper.h" #include "local_mode_ray_runtime.h" #include "native_ray_runtime.h" namespace ray { namespace internal { msgpack::sbuffer PackError(std::string error_msg) { msgpack::sbuffer sbuffer; msgpack::packer<msgpack::sbuffer> packer(sbuffer); packer.pack(msgpack::type::nil_t()); packer.pack(std::make_tuple((int)ray::rpc::ErrorType::TASK_EXECUTION_EXCEPTION, std::move(error_msg))); return sbuffer; } } // namespace internal namespace internal { using ray::core::CoreWorkerProcess; using ray::core::WorkerType; std::shared_ptr<AbstractRayRuntime> AbstractRayRuntime::abstract_ray_runtime_ = nullptr; std::shared_ptr<AbstractRayRuntime> AbstractRayRuntime::DoInit() { std::shared_ptr<AbstractRayRuntime> runtime; if (ConfigInternal::Instance().run_mode == RunMode::SINGLE_PROCESS) { runtime = std::shared_ptr<AbstractRayRuntime>(new LocalModeRayRuntime()); } else { ProcessHelper::GetInstance().RayStart(TaskExecutor::ExecuteTask); runtime = std::shared_ptr<AbstractRayRuntime>(new NativeRayRuntime()); RAY_LOG(INFO) << "Native ray runtime started."; } RAY_CHECK(runtime); internal::RayRuntimeHolder::Instance().Init(runtime); if (ConfigInternal::Instance().worker_type == WorkerType::WORKER) { // Load functions from code search path. FunctionHelper::GetInstance().LoadFunctionsFromPaths( ConfigInternal::Instance().code_search_path); } abstract_ray_runtime_ = runtime; return runtime; } std::shared_ptr<AbstractRayRuntime> AbstractRayRuntime::GetInstance() { return abstract_ray_runtime_; } void AbstractRayRuntime::DoShutdown() { abstract_ray_runtime_ = nullptr; if (ConfigInternal::Instance().run_mode == RunMode::CLUSTER) { ProcessHelper::GetInstance().RayStop(); } } void AbstractRayRuntime::Put(std::shared_ptr<msgpack::sbuffer> data, ObjectID *object_id) { object_store_->Put(data, object_id); } void AbstractRayRuntime::Put(std::shared_ptr<msgpack::sbuffer> data, const ObjectID &object_id) { object_store_->Put(data, object_id); } std::string AbstractRayRuntime::Put(std::shared_ptr<msgpack::sbuffer> data) { ObjectID object_id{}; object_store_->Put(data, &object_id); return object_id.Binary(); } std::shared_ptr<msgpack::sbuffer> AbstractRayRuntime::Get(const std::string &object_id) { return object_store_->Get(ObjectID::FromBinary(object_id), -1); } inline static std::vector<ObjectID> StringIDsToObjectIDs( const std::vector<std::string> &ids) { std::vector<ObjectID> object_ids; for (std::string id : ids) { object_ids.push_back(ObjectID::FromBinary(id)); } return object_ids; } std::vector<std::shared_ptr<msgpack::sbuffer>> AbstractRayRuntime::Get( const std::vector<std::string> &ids) { return object_store_->Get(StringIDsToObjectIDs(ids), -1); } std::vector<bool> AbstractRayRuntime::Wait(const std::vector<std::string> &ids, int num_objects, int timeout_ms) { return object_store_->Wait(StringIDsToObjectIDs(ids), num_objects, timeout_ms); } std::vector<std::unique_ptr<::ray::TaskArg>> TransformArgs( std::vector<ray::internal::TaskArg> &args, bool cross_lang) { std::vector<std::unique_ptr<::ray::TaskArg>> ray_args; for (auto &arg : args) { std::unique_ptr<::ray::TaskArg> ray_arg = nullptr; if (arg.buf) { auto &buffer = *arg.buf; auto memory_buffer = std::make_shared<ray::LocalMemoryBuffer>( reinterpret_cast<uint8_t *>(buffer.data()), buffer.size(), true); std::shared_ptr<Buffer> metadata = nullptr; if (cross_lang) { auto meta_str = arg.meta_str; metadata = std::make_shared<ray::LocalMemoryBuffer>( reinterpret_cast<uint8_t *>(const_cast<char *>(meta_str.data())), meta_str.size(), true); } ray_arg = absl::make_unique<ray::TaskArgByValue>(std::make_shared<ray::RayObject>( memory_buffer, metadata, std::vector<rpc::ObjectReference>())); } else { RAY_CHECK(arg.id); auto id = ObjectID::FromBinary(*arg.id); auto owner_address = ray::rpc::Address{}; if (ConfigInternal::Instance().run_mode == RunMode::CLUSTER) { auto &core_worker = CoreWorkerProcess::GetCoreWorker(); owner_address = core_worker.GetOwnerAddress(id); } ray_arg = absl::make_unique<ray::TaskArgByReference>(id, owner_address, /*call_site=*/""); } ray_args.push_back(std::move(ray_arg)); } return ray_args; } InvocationSpec BuildInvocationSpec1(TaskType task_type, const RemoteFunctionHolder &remote_function_holder, std::vector<ray::internal::TaskArg> &args, const ActorID &actor) { InvocationSpec invocation_spec; invocation_spec.task_type = task_type; invocation_spec.remote_function_holder = remote_function_holder; invocation_spec.actor_id = actor; invocation_spec.args = TransformArgs(args, remote_function_holder.lang_type != LangType::CPP); return invocation_spec; } std::string AbstractRayRuntime::Call(const RemoteFunctionHolder &remote_function_holder, std::vector<ray::internal::TaskArg> &args, const CallOptions &task_options) { auto invocation_spec = BuildInvocationSpec1( TaskType::NORMAL_TASK, remote_function_holder, args, ActorID::Nil()); return task_submitter_->SubmitTask(invocation_spec, task_options).Binary(); } std::string AbstractRayRuntime::CreateActor( const RemoteFunctionHolder &remote_function_holder, std::vector<ray::internal::TaskArg> &args, const ActorCreationOptions &create_options) { auto invocation_spec = BuildInvocationSpec1( TaskType::ACTOR_CREATION_TASK, remote_function_holder, args, ActorID::Nil()); return task_submitter_->CreateActor(invocation_spec, create_options).Binary(); } std::string AbstractRayRuntime::CallActor( const RemoteFunctionHolder &remote_function_holder, const std::string &actor, std::vector<ray::internal::TaskArg> &args, const CallOptions &call_options) { InvocationSpec invocation_spec{}; if (remote_function_holder.lang_type == LangType::PYTHON) { const auto native_actor_handle = CoreWorkerProcess::GetCoreWorker().GetActorHandle( ray::ActorID::FromBinary(actor)); auto function_descriptor = native_actor_handle->ActorCreationTaskFunctionDescriptor(); auto typed_descriptor = function_descriptor->As<PythonFunctionDescriptor>(); RemoteFunctionHolder func_holder = remote_function_holder; func_holder.module_name = typed_descriptor->ModuleName(); func_holder.class_name = typed_descriptor->ClassName(); invocation_spec = BuildInvocationSpec1(TaskType::ACTOR_TASK, func_holder, args, ActorID::FromBinary(actor)); } else { invocation_spec = BuildInvocationSpec1(TaskType::ACTOR_TASK, remote_function_holder, args, ActorID::FromBinary(actor)); } return task_submitter_->SubmitActorTask(invocation_spec, call_options).Binary(); } const TaskID &AbstractRayRuntime::GetCurrentTaskId() { return GetWorkerContext().GetCurrentTaskID(); } const JobID &AbstractRayRuntime::GetCurrentJobID() { return GetWorkerContext().GetCurrentJobID(); } const WorkerContext &AbstractRayRuntime::GetWorkerContext() { return CoreWorkerProcess::GetCoreWorker().GetWorkerContext(); } void AbstractRayRuntime::AddLocalReference(const std::string &id) { if (CoreWorkerProcess::IsInitialized()) { auto &core_worker = CoreWorkerProcess::GetCoreWorker(); core_worker.AddLocalReference(ObjectID::FromBinary(id)); } } void AbstractRayRuntime::RemoveLocalReference(const std::string &id) { if (CoreWorkerProcess::IsInitialized()) { auto &core_worker = CoreWorkerProcess::GetCoreWorker(); core_worker.RemoveLocalReference(ObjectID::FromBinary(id)); } } std::string AbstractRayRuntime::GetActorId(const std::string &actor_name) { auto actor_id = task_submitter_->GetActor(actor_name); if (actor_id.IsNil()) { return ""; } return actor_id.Binary(); } void AbstractRayRuntime::KillActor(const std::string &str_actor_id, bool no_restart) { auto &core_worker = CoreWorkerProcess::GetCoreWorker(); ray::ActorID actor_id = ray::ActorID::FromBinary(str_actor_id); Status status = core_worker.KillActor(actor_id, true, no_restart); if (!status.ok()) { throw RayException(status.message()); } } void AbstractRayRuntime::ExitActor() { auto &core_worker = CoreWorkerProcess::GetCoreWorker(); if (ConfigInternal::Instance().worker_type != WorkerType::WORKER || core_worker.GetActorId().IsNil()) { throw std::logic_error("This shouldn't be called on a non-actor worker."); } throw RayIntentionalSystemExitException("SystemExit"); } const std::unique_ptr<ray::gcs::GlobalStateAccessor> &AbstractRayRuntime::GetGlobalStateAccessor() { return global_state_accessor_; } bool AbstractRayRuntime::WasCurrentActorRestarted() { if (ConfigInternal::Instance().run_mode == RunMode::SINGLE_PROCESS) { return false; } const auto &actor_id = GetCurrentActorID(); auto byte_ptr = global_state_accessor_->GetActorInfo(actor_id); if (byte_ptr == nullptr) { return false; } rpc::ActorTableData actor_table_data; bool r = actor_table_data.ParseFromString(*byte_ptr); if (!r) { throw RayException("Received invalid protobuf data from GCS."); } return actor_table_data.num_restarts() != 0; } ray::PlacementGroup AbstractRayRuntime::CreatePlacementGroup( const ray::PlacementGroupCreationOptions &create_options) { return task_submitter_->CreatePlacementGroup(create_options); } void AbstractRayRuntime::RemovePlacementGroup(const std::string &group_id) { return task_submitter_->RemovePlacementGroup(group_id); } bool AbstractRayRuntime::WaitPlacementGroupReady(const std::string &group_id, int timeout_seconds) { return task_submitter_->WaitPlacementGroupReady(group_id, timeout_seconds); } PlacementGroup AbstractRayRuntime::GeneratePlacementGroup(const std::string &str) { rpc::PlacementGroupTableData pg_table_data; bool r = pg_table_data.ParseFromString(str); if (!r) { throw RayException("Received invalid protobuf data from GCS."); } PlacementGroupCreationOptions options; options.name = pg_table_data.name(); auto &bundles = options.bundles; for (auto &bundle : bundles) { options.bundles.emplace_back(bundle); } options.strategy = PlacementStrategy(pg_table_data.strategy()); PlacementGroup group(pg_table_data.placement_group_id(), std::move(options), PlacementGroupState(pg_table_data.state())); return group; } std::vector<PlacementGroup> AbstractRayRuntime::GetAllPlacementGroups() { std::vector<std::string> list = global_state_accessor_->GetAllPlacementGroupInfo(); std::vector<PlacementGroup> groups; for (auto &str : list) { PlacementGroup group = GeneratePlacementGroup(str); groups.push_back(std::move(group)); } return groups; } PlacementGroup AbstractRayRuntime::GetPlacementGroupById(const std::string &id) { PlacementGroupID pg_id = PlacementGroupID::FromBinary(id); auto str_ptr = global_state_accessor_->GetPlacementGroupInfo(pg_id); if (str_ptr == nullptr) { return {}; } PlacementGroup group = GeneratePlacementGroup(*str_ptr); return group; } PlacementGroup AbstractRayRuntime::GetPlacementGroup(const std::string &name) { auto str_ptr = global_state_accessor_->GetPlacementGroupByName(name, ""); if (str_ptr == nullptr) { return {}; } PlacementGroup group = GeneratePlacementGroup(*str_ptr); return group; } } // namespace internal } // namespace ray
.size 8000 .text@48 jp lstatint .text@100 jp lbegin .data@143 c0 .text@150 lbegin: ld a, 00 ldff(ff), a ld a, 30 ldff(00), a ld a, 01 ldff(4d), a stop, 00 ld a, ff ldff(45), a ld b, 91 call lwaitly_b ld hl, fe00 ld d, 10 ld a, d ld(hl++), a ld a, 08 ld(hl++), a inc l inc l ld a, d ld(hl++), a ld(hl++), a inc l inc l ld(hl++), a ld a, 18 ld(hl++), a inc l inc l ld a, d ld(hl++), a ld a, 20 ld(hl++), a inc l inc l ld a, d ld(hl++), a ld a, 28 ld(hl++), a inc l inc l ld a, d ld(hl++), a ld a, 30 ld(hl++), a inc l inc l ld a, d ld(hl++), a ld a, 38 ld(hl++), a inc l inc l ld a, d ld(hl++), a ld a, 40 ld(hl++), a inc l inc l ld a, d ld(hl++), a ld a, 48 ld(hl++), a inc l inc l ld a, d ld(hl++), a ld a, 50 ld(hl++), a ld a, 40 ldff(41), a ld a, 02 ldff(ff), a xor a, a ldff(0f), a ei ld a, 01 ldff(45), a ld c, 41 ld a, 93 ldff(40), a .text@1000 lstatint: nop .text@101d ld a, 04 ldff(43), a .text@10a9 ldff a, (c) and a, 03 jp lprint_a .text@7000 lprint_a: push af ld b, 91 call lwaitly_b xor a, a ldff(40), a pop af ld(9800), a ld bc, 7a00 ld hl, 8000 ld d, a0 lprint_copytiles: ld a, (bc) inc bc ld(hl++), a dec d jrnz lprint_copytiles ld a, c0 ldff(47), a ld a, 80 ldff(68), a ld a, ff ldff(69), a ldff(69), a ldff(69), a ldff(69), a ldff(69), a ldff(69), a xor a, a ldff(69), a ldff(69), a ldff(43), a ld a, 91 ldff(40), a lprint_limbo: jr lprint_limbo .text@7400 lwaitly_b: ld c, 44 lwaitly_b_loop: ldff a, (c) cmp a, b jrnz lwaitly_b_loop ret .data@7a00 00 00 7f 7f 41 41 41 41 41 41 41 41 41 41 7f 7f 00 00 08 08 08 08 08 08 08 08 08 08 08 08 08 08 00 00 7f 7f 01 01 01 01 7f 7f 40 40 40 40 7f 7f 00 00 7f 7f 01 01 01 01 3f 3f 01 01 01 01 7f 7f 00 00 41 41 41 41 41 41 7f 7f 01 01 01 01 01 01 00 00 7f 7f 40 40 40 40 7e 7e 01 01 01 01 7e 7e 00 00 7f 7f 40 40 40 40 7f 7f 41 41 41 41 7f 7f 00 00 7f 7f 01 01 02 02 04 04 08 08 10 10 10 10 00 00 3e 3e 41 41 41 41 3e 3e 41 41 41 41 3e 3e 00 00 7f 7f 41 41 41 41 7f 7f 01 01 01 01 7f 7f
; expected result: 0x100 = 64 mov r0, #6 mov r1, #1 l: add r1, r1, r1 subs r0, #1 bne l mov r6, #0x100 str r1, [r6]
_mv: file format elf32-i386 Disassembly of section .text: 00000000 <main>: int mv(char *, char *); int main(int argc, char *argv[]) { 0: 55 push %ebp int i = 0; int res = -1; char *src = NULL; char *dest = NULL; struct stat st; char dirstr[DIRSTR] = {0}; 1: 31 c0 xor %eax,%eax { 3: 89 e5 mov %esp,%ebp char dirstr[DIRSTR] = {0}; 5: b9 20 00 00 00 mov $0x20,%ecx { a: 57 push %edi b: 56 push %esi c: 53 push %ebx d: 83 e4 f0 and $0xfffffff0,%esp 10: 81 ec c0 00 00 00 sub $0xc0,%esp 16: 8b 75 0c mov 0xc(%ebp),%esi if (argc < 3) { 19: 83 7d 08 02 cmpl $0x2,0x8(%ebp) char dirstr[DIRSTR] = {0}; 1d: 8d 5c 24 40 lea 0x40(%esp),%ebx 21: 89 df mov %ebx,%edi 23: f3 ab rep stos %eax,%es:(%edi) if (argc < 3) { 25: 7f 19 jg 40 <main+0x40> printf(2, "must have at least 2 arguments\n"); 27: c7 44 24 04 a0 0b 00 movl $0xba0,0x4(%esp) 2e: 00 2f: c7 04 24 02 00 00 00 movl $0x2,(%esp) 36: e8 45 05 00 00 call 580 <printf> exit(); 3b: e8 92 03 00 00 call 3d2 <exit> } src = argv[1]; dest = argv[argc - 1]; 40: 8b 45 08 mov 0x8(%ebp),%eax src = argv[1]; 43: 8b 7e 04 mov 0x4(%esi),%edi dest = argv[argc - 1]; 46: 8b 44 86 fc mov -0x4(%esi,%eax,4),%eax 4a: 89 c1 mov %eax,%ecx 4c: 89 44 24 18 mov %eax,0x18(%esp) // mv f1 f2 f3 dest res = stat(dest, &st); 50: 8d 44 24 2c lea 0x2c(%esp),%eax 54: 89 44 24 04 mov %eax,0x4(%esp) 58: 89 0c 24 mov %ecx,(%esp) 5b: e8 c0 02 00 00 call 320 <stat> if (res < 0) { 60: 85 c0 test %eax,%eax 62: 78 44 js a8 <main+0xa8> mv(src, dest); } else { switch (st.type) { 64: 0f b7 44 24 2c movzwl 0x2c(%esp),%eax 69: 66 83 f8 01 cmp $0x1,%ax 6d: 74 4b je ba <main+0xba> 6f: 66 83 f8 02 cmp $0x2,%ax 73: 74 19 je 8e <main+0x8e> strcpy(&(dirstr[strlen(dirstr)]), argv[i]); mv(argv[i], dirstr); } break; default: printf(2, "cannot rename to an existing device\n"); 75: c7 44 24 04 c0 0b 00 movl $0xbc0,0x4(%esp) 7c: 00 7d: c7 04 24 02 00 00 00 movl $0x2,(%esp) 84: e8 f7 04 00 00 call 580 <printf> break; } } exit(); 89: e8 44 03 00 00 call 3d2 <exit> unlink(dest); 8e: 8b 74 24 18 mov 0x18(%esp),%esi 92: 89 34 24 mov %esi,(%esp) 95: e8 88 03 00 00 call 422 <unlink> mv(src, dest); 9a: 89 74 24 04 mov %esi,0x4(%esp) 9e: 89 3c 24 mov %edi,(%esp) a1: e8 aa 00 00 00 call 150 <mv> break; a6: eb e1 jmp 89 <main+0x89> mv(src, dest); a8: 8b 44 24 18 mov 0x18(%esp),%eax ac: 89 3c 24 mov %edi,(%esp) af: 89 44 24 04 mov %eax,0x4(%esp) b3: e8 98 00 00 00 call 150 <mv> b8: eb cf jmp 89 <main+0x89> ba: 8b 45 08 mov 0x8(%ebp),%eax switch (st.type) { bd: bf 01 00 00 00 mov $0x1,%edi c2: 83 e8 01 sub $0x1,%eax c5: 89 44 24 14 mov %eax,0x14(%esp) c9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi memset(dirstr, 0, DIRSTR); d0: c7 44 24 08 80 00 00 movl $0x80,0x8(%esp) d7: 00 d8: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) df: 00 e0: 89 1c 24 mov %ebx,(%esp) e3: e8 78 01 00 00 call 260 <memset> strcpy(dirstr, dest); e8: 8b 44 24 18 mov 0x18(%esp),%eax ec: 89 1c 24 mov %ebx,(%esp) ef: 89 44 24 04 mov %eax,0x4(%esp) f3: e8 b8 00 00 00 call 1b0 <strcpy> dirstr[strlen(dirstr)] = '/'; f8: 89 1c 24 mov %ebx,(%esp) fb: e8 30 01 00 00 call 230 <strlen> strcpy(&(dirstr[strlen(dirstr)]), argv[i]); 100: 8b 14 be mov (%esi,%edi,4),%edx 103: 89 54 24 1c mov %edx,0x1c(%esp) dirstr[strlen(dirstr)] = '/'; 107: c6 44 04 40 2f movb $0x2f,0x40(%esp,%eax,1) strcpy(&(dirstr[strlen(dirstr)]), argv[i]); 10c: 89 1c 24 mov %ebx,(%esp) 10f: e8 1c 01 00 00 call 230 <strlen> 114: 8b 54 24 1c mov 0x1c(%esp),%edx 118: 89 54 24 04 mov %edx,0x4(%esp) 11c: 01 d8 add %ebx,%eax 11e: 89 04 24 mov %eax,(%esp) 121: e8 8a 00 00 00 call 1b0 <strcpy> mv(argv[i], dirstr); 126: 89 5c 24 04 mov %ebx,0x4(%esp) 12a: 8b 04 be mov (%esi,%edi,4),%eax for (i = 1; i < (argc - 1); i++) { 12d: 83 c7 01 add $0x1,%edi mv(argv[i], dirstr); 130: 89 04 24 mov %eax,(%esp) 133: e8 18 00 00 00 call 150 <mv> for (i = 1; i < (argc - 1); i++) { 138: 3b 7c 24 14 cmp 0x14(%esp),%edi 13c: 75 92 jne d0 <main+0xd0> 13e: e9 46 ff ff ff jmp 89 <main+0x89> 143: 66 90 xchg %ax,%ax 145: 66 90 xchg %ax,%ax 147: 66 90 xchg %ax,%ax 149: 66 90 xchg %ax,%ax 14b: 66 90 xchg %ax,%ax 14d: 66 90 xchg %ax,%ax 14f: 90 nop 00000150 <mv>: } int mv(char *src, char *dest) { 150: 55 push %ebp 151: 89 e5 mov %esp,%ebp 153: 56 push %esi 154: 53 push %ebx 155: 83 ec 10 sub $0x10,%esp 158: 8b 5d 08 mov 0x8(%ebp),%ebx 15b: 8b 75 0c mov 0xc(%ebp),%esi int res = -1; if (link(src, dest) < 0) { 15e: 89 1c 24 mov %ebx,(%esp) 161: 89 74 24 04 mov %esi,0x4(%esp) 165: e8 c8 02 00 00 call 432 <link> 16a: 85 c0 test %eax,%eax 16c: 78 1a js 188 <mv+0x38> printf(2, "mv %s %s: failed\n", src, dest); } else { if (unlink(src) < 0) { 16e: 89 1c 24 mov %ebx,(%esp) 171: e8 ac 02 00 00 call 422 <unlink> 176: 85 c0 test %eax,%eax 178: 78 0e js 188 <mv+0x38> printf(2, "mv %s %s: failed\n", src, dest); } else { res = 0; 17a: 31 c0 xor %eax,%eax } } return res; } 17c: 83 c4 10 add $0x10,%esp 17f: 5b pop %ebx 180: 5e pop %esi 181: 5d pop %ebp 182: c3 ret 183: 90 nop 184: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi printf(2, "mv %s %s: failed\n", src, dest); 188: 89 74 24 0c mov %esi,0xc(%esp) 18c: 89 5c 24 08 mov %ebx,0x8(%esp) 190: c7 44 24 04 8c 0b 00 movl $0xb8c,0x4(%esp) 197: 00 198: c7 04 24 02 00 00 00 movl $0x2,(%esp) 19f: e8 dc 03 00 00 call 580 <printf> int res = -1; 1a4: b8 ff ff ff ff mov $0xffffffff,%eax 1a9: eb d1 jmp 17c <mv+0x2c> 1ab: 66 90 xchg %ax,%ax 1ad: 66 90 xchg %ax,%ax 1af: 90 nop 000001b0 <strcpy>: #include "user.h" #include "x86.h" char* strcpy(char *s, const char *t) { 1b0: 55 push %ebp 1b1: 89 e5 mov %esp,%ebp 1b3: 8b 45 08 mov 0x8(%ebp),%eax 1b6: 8b 4d 0c mov 0xc(%ebp),%ecx 1b9: 53 push %ebx char *os; os = s; while((*s++ = *t++) != 0) 1ba: 89 c2 mov %eax,%edx 1bc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 1c0: 83 c1 01 add $0x1,%ecx 1c3: 0f b6 59 ff movzbl -0x1(%ecx),%ebx 1c7: 83 c2 01 add $0x1,%edx 1ca: 84 db test %bl,%bl 1cc: 88 5a ff mov %bl,-0x1(%edx) 1cf: 75 ef jne 1c0 <strcpy+0x10> ; return os; } 1d1: 5b pop %ebx 1d2: 5d pop %ebp 1d3: c3 ret 1d4: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 1da: 8d bf 00 00 00 00 lea 0x0(%edi),%edi 000001e0 <strcmp>: int strcmp(const char *p, const char *q) { 1e0: 55 push %ebp 1e1: 89 e5 mov %esp,%ebp 1e3: 8b 55 08 mov 0x8(%ebp),%edx 1e6: 53 push %ebx 1e7: 8b 4d 0c mov 0xc(%ebp),%ecx while(*p && *p == *q) 1ea: 0f b6 02 movzbl (%edx),%eax 1ed: 84 c0 test %al,%al 1ef: 74 2d je 21e <strcmp+0x3e> 1f1: 0f b6 19 movzbl (%ecx),%ebx 1f4: 38 d8 cmp %bl,%al 1f6: 74 0e je 206 <strcmp+0x26> 1f8: eb 2b jmp 225 <strcmp+0x45> 1fa: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 200: 38 c8 cmp %cl,%al 202: 75 15 jne 219 <strcmp+0x39> p++, q++; 204: 89 d9 mov %ebx,%ecx 206: 83 c2 01 add $0x1,%edx while(*p && *p == *q) 209: 0f b6 02 movzbl (%edx),%eax p++, q++; 20c: 8d 59 01 lea 0x1(%ecx),%ebx while(*p && *p == *q) 20f: 0f b6 49 01 movzbl 0x1(%ecx),%ecx 213: 84 c0 test %al,%al 215: 75 e9 jne 200 <strcmp+0x20> 217: 31 c0 xor %eax,%eax return (uchar)*p - (uchar)*q; 219: 29 c8 sub %ecx,%eax } 21b: 5b pop %ebx 21c: 5d pop %ebp 21d: c3 ret 21e: 0f b6 09 movzbl (%ecx),%ecx while(*p && *p == *q) 221: 31 c0 xor %eax,%eax 223: eb f4 jmp 219 <strcmp+0x39> 225: 0f b6 cb movzbl %bl,%ecx 228: eb ef jmp 219 <strcmp+0x39> 22a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 00000230 <strlen>: uint strlen(const char *s) { 230: 55 push %ebp 231: 89 e5 mov %esp,%ebp 233: 8b 4d 08 mov 0x8(%ebp),%ecx int n; for(n = 0; s[n]; n++) 236: 80 39 00 cmpb $0x0,(%ecx) 239: 74 12 je 24d <strlen+0x1d> 23b: 31 d2 xor %edx,%edx 23d: 8d 76 00 lea 0x0(%esi),%esi 240: 83 c2 01 add $0x1,%edx 243: 80 3c 11 00 cmpb $0x0,(%ecx,%edx,1) 247: 89 d0 mov %edx,%eax 249: 75 f5 jne 240 <strlen+0x10> ; return n; } 24b: 5d pop %ebp 24c: c3 ret for(n = 0; s[n]; n++) 24d: 31 c0 xor %eax,%eax } 24f: 5d pop %ebp 250: c3 ret 251: eb 0d jmp 260 <memset> 253: 90 nop 254: 90 nop 255: 90 nop 256: 90 nop 257: 90 nop 258: 90 nop 259: 90 nop 25a: 90 nop 25b: 90 nop 25c: 90 nop 25d: 90 nop 25e: 90 nop 25f: 90 nop 00000260 <memset>: void* memset(void *dst, int c, uint n) { 260: 55 push %ebp 261: 89 e5 mov %esp,%ebp 263: 8b 55 08 mov 0x8(%ebp),%edx 266: 57 push %edi } static inline void stosb(void *addr, int data, int cnt) { asm volatile("cld; rep stosb" : 267: 8b 4d 10 mov 0x10(%ebp),%ecx 26a: 8b 45 0c mov 0xc(%ebp),%eax 26d: 89 d7 mov %edx,%edi 26f: fc cld 270: f3 aa rep stos %al,%es:(%edi) stosb(dst, c, n); return dst; } 272: 89 d0 mov %edx,%eax 274: 5f pop %edi 275: 5d pop %ebp 276: c3 ret 277: 89 f6 mov %esi,%esi 279: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 00000280 <strchr>: char* strchr(const char *s, char c) { 280: 55 push %ebp 281: 89 e5 mov %esp,%ebp 283: 8b 45 08 mov 0x8(%ebp),%eax 286: 53 push %ebx 287: 8b 55 0c mov 0xc(%ebp),%edx for(; *s; s++) 28a: 0f b6 18 movzbl (%eax),%ebx 28d: 84 db test %bl,%bl 28f: 74 1d je 2ae <strchr+0x2e> if(*s == c) 291: 38 d3 cmp %dl,%bl 293: 89 d1 mov %edx,%ecx 295: 75 0d jne 2a4 <strchr+0x24> 297: eb 17 jmp 2b0 <strchr+0x30> 299: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 2a0: 38 ca cmp %cl,%dl 2a2: 74 0c je 2b0 <strchr+0x30> for(; *s; s++) 2a4: 83 c0 01 add $0x1,%eax 2a7: 0f b6 10 movzbl (%eax),%edx 2aa: 84 d2 test %dl,%dl 2ac: 75 f2 jne 2a0 <strchr+0x20> return (char*)s; return 0; 2ae: 31 c0 xor %eax,%eax } 2b0: 5b pop %ebx 2b1: 5d pop %ebp 2b2: c3 ret 2b3: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 2b9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 000002c0 <gets>: char* gets(char *buf, int max) { 2c0: 55 push %ebp 2c1: 89 e5 mov %esp,%ebp 2c3: 57 push %edi 2c4: 56 push %esi int i, cc; char c; for(i=0; i+1 < max; ){ 2c5: 31 f6 xor %esi,%esi { 2c7: 53 push %ebx 2c8: 83 ec 2c sub $0x2c,%esp cc = read(0, &c, 1); 2cb: 8d 7d e7 lea -0x19(%ebp),%edi for(i=0; i+1 < max; ){ 2ce: eb 31 jmp 301 <gets+0x41> cc = read(0, &c, 1); 2d0: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) 2d7: 00 2d8: 89 7c 24 04 mov %edi,0x4(%esp) 2dc: c7 04 24 00 00 00 00 movl $0x0,(%esp) 2e3: e8 02 01 00 00 call 3ea <read> if(cc < 1) 2e8: 85 c0 test %eax,%eax 2ea: 7e 1d jle 309 <gets+0x49> break; buf[i++] = c; 2ec: 0f b6 45 e7 movzbl -0x19(%ebp),%eax for(i=0; i+1 < max; ){ 2f0: 89 de mov %ebx,%esi buf[i++] = c; 2f2: 8b 55 08 mov 0x8(%ebp),%edx if(c == '\n' || c == '\r') 2f5: 3c 0d cmp $0xd,%al buf[i++] = c; 2f7: 88 44 1a ff mov %al,-0x1(%edx,%ebx,1) if(c == '\n' || c == '\r') 2fb: 74 0c je 309 <gets+0x49> 2fd: 3c 0a cmp $0xa,%al 2ff: 74 08 je 309 <gets+0x49> for(i=0; i+1 < max; ){ 301: 8d 5e 01 lea 0x1(%esi),%ebx 304: 3b 5d 0c cmp 0xc(%ebp),%ebx 307: 7c c7 jl 2d0 <gets+0x10> break; } buf[i] = '\0'; 309: 8b 45 08 mov 0x8(%ebp),%eax 30c: c6 04 30 00 movb $0x0,(%eax,%esi,1) return buf; } 310: 83 c4 2c add $0x2c,%esp 313: 5b pop %ebx 314: 5e pop %esi 315: 5f pop %edi 316: 5d pop %ebp 317: c3 ret 318: 90 nop 319: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 00000320 <stat>: int stat(const char *n, struct stat *st) { 320: 55 push %ebp 321: 89 e5 mov %esp,%ebp 323: 56 push %esi 324: 53 push %ebx 325: 83 ec 10 sub $0x10,%esp int fd; int r; fd = open(n, O_RDONLY); 328: 8b 45 08 mov 0x8(%ebp),%eax 32b: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 332: 00 333: 89 04 24 mov %eax,(%esp) 336: e8 d7 00 00 00 call 412 <open> if(fd < 0) 33b: 85 c0 test %eax,%eax fd = open(n, O_RDONLY); 33d: 89 c3 mov %eax,%ebx if(fd < 0) 33f: 78 27 js 368 <stat+0x48> return -1; r = fstat(fd, st); 341: 8b 45 0c mov 0xc(%ebp),%eax 344: 89 1c 24 mov %ebx,(%esp) 347: 89 44 24 04 mov %eax,0x4(%esp) 34b: e8 da 00 00 00 call 42a <fstat> close(fd); 350: 89 1c 24 mov %ebx,(%esp) r = fstat(fd, st); 353: 89 c6 mov %eax,%esi close(fd); 355: e8 a0 00 00 00 call 3fa <close> return r; 35a: 89 f0 mov %esi,%eax } 35c: 83 c4 10 add $0x10,%esp 35f: 5b pop %ebx 360: 5e pop %esi 361: 5d pop %ebp 362: c3 ret 363: 90 nop 364: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi return -1; 368: b8 ff ff ff ff mov $0xffffffff,%eax 36d: eb ed jmp 35c <stat+0x3c> 36f: 90 nop 00000370 <atoi>: int atoi(const char *s) { 370: 55 push %ebp 371: 89 e5 mov %esp,%ebp 373: 8b 4d 08 mov 0x8(%ebp),%ecx 376: 53 push %ebx int n; n = 0; while('0' <= *s && *s <= '9') 377: 0f be 11 movsbl (%ecx),%edx 37a: 8d 42 d0 lea -0x30(%edx),%eax 37d: 3c 09 cmp $0x9,%al n = 0; 37f: b8 00 00 00 00 mov $0x0,%eax while('0' <= *s && *s <= '9') 384: 77 17 ja 39d <atoi+0x2d> 386: 66 90 xchg %ax,%ax n = n*10 + *s++ - '0'; 388: 83 c1 01 add $0x1,%ecx 38b: 8d 04 80 lea (%eax,%eax,4),%eax 38e: 8d 44 42 d0 lea -0x30(%edx,%eax,2),%eax while('0' <= *s && *s <= '9') 392: 0f be 11 movsbl (%ecx),%edx 395: 8d 5a d0 lea -0x30(%edx),%ebx 398: 80 fb 09 cmp $0x9,%bl 39b: 76 eb jbe 388 <atoi+0x18> return n; } 39d: 5b pop %ebx 39e: 5d pop %ebp 39f: c3 ret 000003a0 <memmove>: void* memmove(void *vdst, const void *vsrc, int n) { 3a0: 55 push %ebp char *dst; const char *src; dst = vdst; src = vsrc; while(n-- > 0) 3a1: 31 d2 xor %edx,%edx { 3a3: 89 e5 mov %esp,%ebp 3a5: 56 push %esi 3a6: 8b 45 08 mov 0x8(%ebp),%eax 3a9: 53 push %ebx 3aa: 8b 5d 10 mov 0x10(%ebp),%ebx 3ad: 8b 75 0c mov 0xc(%ebp),%esi while(n-- > 0) 3b0: 85 db test %ebx,%ebx 3b2: 7e 12 jle 3c6 <memmove+0x26> 3b4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi *dst++ = *src++; 3b8: 0f b6 0c 16 movzbl (%esi,%edx,1),%ecx 3bc: 88 0c 10 mov %cl,(%eax,%edx,1) 3bf: 83 c2 01 add $0x1,%edx while(n-- > 0) 3c2: 39 da cmp %ebx,%edx 3c4: 75 f2 jne 3b8 <memmove+0x18> return vdst; } 3c6: 5b pop %ebx 3c7: 5e pop %esi 3c8: 5d pop %ebp 3c9: c3 ret 000003ca <fork>: name: \ movl $SYS_ ## name, %eax; \ int $T_SYSCALL; \ ret SYSCALL(fork) 3ca: b8 01 00 00 00 mov $0x1,%eax 3cf: cd 40 int $0x40 3d1: c3 ret 000003d2 <exit>: SYSCALL(exit) 3d2: b8 02 00 00 00 mov $0x2,%eax 3d7: cd 40 int $0x40 3d9: c3 ret 000003da <wait>: SYSCALL(wait) 3da: b8 03 00 00 00 mov $0x3,%eax 3df: cd 40 int $0x40 3e1: c3 ret 000003e2 <pipe>: SYSCALL(pipe) 3e2: b8 04 00 00 00 mov $0x4,%eax 3e7: cd 40 int $0x40 3e9: c3 ret 000003ea <read>: SYSCALL(read) 3ea: b8 05 00 00 00 mov $0x5,%eax 3ef: cd 40 int $0x40 3f1: c3 ret 000003f2 <write>: SYSCALL(write) 3f2: b8 10 00 00 00 mov $0x10,%eax 3f7: cd 40 int $0x40 3f9: c3 ret 000003fa <close>: SYSCALL(close) 3fa: b8 15 00 00 00 mov $0x15,%eax 3ff: cd 40 int $0x40 401: c3 ret 00000402 <kill>: SYSCALL(kill) 402: b8 06 00 00 00 mov $0x6,%eax 407: cd 40 int $0x40 409: c3 ret 0000040a <exec>: SYSCALL(exec) 40a: b8 07 00 00 00 mov $0x7,%eax 40f: cd 40 int $0x40 411: c3 ret 00000412 <open>: SYSCALL(open) 412: b8 0f 00 00 00 mov $0xf,%eax 417: cd 40 int $0x40 419: c3 ret 0000041a <mknod>: SYSCALL(mknod) 41a: b8 11 00 00 00 mov $0x11,%eax 41f: cd 40 int $0x40 421: c3 ret 00000422 <unlink>: SYSCALL(unlink) 422: b8 12 00 00 00 mov $0x12,%eax 427: cd 40 int $0x40 429: c3 ret 0000042a <fstat>: SYSCALL(fstat) 42a: b8 08 00 00 00 mov $0x8,%eax 42f: cd 40 int $0x40 431: c3 ret 00000432 <link>: SYSCALL(link) 432: b8 13 00 00 00 mov $0x13,%eax 437: cd 40 int $0x40 439: c3 ret 0000043a <mkdir>: SYSCALL(mkdir) 43a: b8 14 00 00 00 mov $0x14,%eax 43f: cd 40 int $0x40 441: c3 ret 00000442 <chdir>: SYSCALL(chdir) 442: b8 09 00 00 00 mov $0x9,%eax 447: cd 40 int $0x40 449: c3 ret 0000044a <dup>: SYSCALL(dup) 44a: b8 0a 00 00 00 mov $0xa,%eax 44f: cd 40 int $0x40 451: c3 ret 00000452 <getpid>: SYSCALL(getpid) 452: b8 0b 00 00 00 mov $0xb,%eax 457: cd 40 int $0x40 459: c3 ret 0000045a <sbrk>: SYSCALL(sbrk) 45a: b8 0c 00 00 00 mov $0xc,%eax 45f: cd 40 int $0x40 461: c3 ret 00000462 <sleep>: SYSCALL(sleep) 462: b8 0d 00 00 00 mov $0xd,%eax 467: cd 40 int $0x40 469: c3 ret 0000046a <uptime>: SYSCALL(uptime) 46a: b8 0e 00 00 00 mov $0xe,%eax 46f: cd 40 int $0x40 471: c3 ret 00000472 <getppid>: #ifdef GETPPID SYSCALL(getppid) 472: b8 16 00 00 00 mov $0x16,%eax 477: cd 40 int $0x40 479: c3 ret 0000047a <cps>: #endif // GETPPID #ifdef CPS SYSCALL(cps) 47a: b8 17 00 00 00 mov $0x17,%eax 47f: cd 40 int $0x40 481: c3 ret 00000482 <halt>: #endif // CPS #ifdef HALT SYSCALL(halt) 482: b8 18 00 00 00 mov $0x18,%eax 487: cd 40 int $0x40 489: c3 ret 0000048a <kdebug>: #endif // HALT #ifdef KDEBUG SYSCALL(kdebug) 48a: b8 19 00 00 00 mov $0x19,%eax 48f: cd 40 int $0x40 491: c3 ret 00000492 <va2pa>: #endif // KDEBUG #ifdef VA2PA SYSCALL(va2pa) 492: b8 1a 00 00 00 mov $0x1a,%eax 497: cd 40 int $0x40 499: c3 ret 0000049a <kthread_create>: #endif // VA2PA #ifdef KTHREADS SYSCALL(kthread_create) 49a: b8 1b 00 00 00 mov $0x1b,%eax 49f: cd 40 int $0x40 4a1: c3 ret 000004a2 <kthread_join>: SYSCALL(kthread_join) 4a2: b8 1c 00 00 00 mov $0x1c,%eax 4a7: cd 40 int $0x40 4a9: c3 ret 000004aa <kthread_exit>: SYSCALL(kthread_exit) 4aa: b8 1d 00 00 00 mov $0x1d,%eax 4af: cd 40 int $0x40 4b1: c3 ret 000004b2 <kthread_self>: #endif // KTHREADS #ifdef BENNY_MOOTEX SYSCALL(kthread_self) 4b2: b8 1e 00 00 00 mov $0x1e,%eax 4b7: cd 40 int $0x40 4b9: c3 ret 000004ba <kthread_yield>: SYSCALL(kthread_yield) 4ba: b8 1f 00 00 00 mov $0x1f,%eax 4bf: cd 40 int $0x40 4c1: c3 ret 000004c2 <kthread_cpu_count>: SYSCALL(kthread_cpu_count) 4c2: b8 20 00 00 00 mov $0x20,%eax 4c7: cd 40 int $0x40 4c9: c3 ret 000004ca <kthread_thread_count>: SYSCALL(kthread_thread_count) 4ca: b8 21 00 00 00 mov $0x21,%eax 4cf: cd 40 int $0x40 4d1: c3 ret 4d2: 66 90 xchg %ax,%ax 4d4: 66 90 xchg %ax,%ax 4d6: 66 90 xchg %ax,%ax 4d8: 66 90 xchg %ax,%ax 4da: 66 90 xchg %ax,%ax 4dc: 66 90 xchg %ax,%ax 4de: 66 90 xchg %ax,%ax 000004e0 <printint>: write(fd, &c, 1); } static void printint(int fd, int xx, int base, int sgn) { 4e0: 55 push %ebp 4e1: 89 e5 mov %esp,%ebp 4e3: 57 push %edi 4e4: 56 push %esi 4e5: 89 c6 mov %eax,%esi 4e7: 53 push %ebx 4e8: 83 ec 4c sub $0x4c,%esp char buf[16]; int i, neg; uint x; neg = 0; if(sgn && xx < 0){ 4eb: 8b 5d 08 mov 0x8(%ebp),%ebx 4ee: 85 db test %ebx,%ebx 4f0: 74 09 je 4fb <printint+0x1b> 4f2: 89 d0 mov %edx,%eax 4f4: c1 e8 1f shr $0x1f,%eax 4f7: 84 c0 test %al,%al 4f9: 75 75 jne 570 <printint+0x90> neg = 1; x = -xx; } else { x = xx; 4fb: 89 d0 mov %edx,%eax neg = 0; 4fd: c7 45 c4 00 00 00 00 movl $0x0,-0x3c(%ebp) 504: 89 75 c0 mov %esi,-0x40(%ebp) } i = 0; 507: 31 ff xor %edi,%edi 509: 89 ce mov %ecx,%esi 50b: 8d 5d d7 lea -0x29(%ebp),%ebx 50e: eb 02 jmp 512 <printint+0x32> do{ buf[i++] = digits[x % base]; 510: 89 cf mov %ecx,%edi 512: 31 d2 xor %edx,%edx 514: f7 f6 div %esi 516: 8d 4f 01 lea 0x1(%edi),%ecx 519: 0f b6 92 ef 0b 00 00 movzbl 0xbef(%edx),%edx }while((x /= base) != 0); 520: 85 c0 test %eax,%eax buf[i++] = digits[x % base]; 522: 88 14 0b mov %dl,(%ebx,%ecx,1) }while((x /= base) != 0); 525: 75 e9 jne 510 <printint+0x30> if(neg) 527: 8b 55 c4 mov -0x3c(%ebp),%edx buf[i++] = digits[x % base]; 52a: 89 c8 mov %ecx,%eax 52c: 8b 75 c0 mov -0x40(%ebp),%esi if(neg) 52f: 85 d2 test %edx,%edx 531: 74 08 je 53b <printint+0x5b> buf[i++] = '-'; 533: 8d 4f 02 lea 0x2(%edi),%ecx 536: c6 44 05 d8 2d movb $0x2d,-0x28(%ebp,%eax,1) while(--i >= 0) 53b: 8d 79 ff lea -0x1(%ecx),%edi 53e: 66 90 xchg %ax,%ax 540: 0f b6 44 3d d8 movzbl -0x28(%ebp,%edi,1),%eax 545: 83 ef 01 sub $0x1,%edi write(fd, &c, 1); 548: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) 54f: 00 550: 89 5c 24 04 mov %ebx,0x4(%esp) 554: 89 34 24 mov %esi,(%esp) 557: 88 45 d7 mov %al,-0x29(%ebp) 55a: e8 93 fe ff ff call 3f2 <write> while(--i >= 0) 55f: 83 ff ff cmp $0xffffffff,%edi 562: 75 dc jne 540 <printint+0x60> putc(fd, buf[i]); } 564: 83 c4 4c add $0x4c,%esp 567: 5b pop %ebx 568: 5e pop %esi 569: 5f pop %edi 56a: 5d pop %ebp 56b: c3 ret 56c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi x = -xx; 570: 89 d0 mov %edx,%eax 572: f7 d8 neg %eax neg = 1; 574: c7 45 c4 01 00 00 00 movl $0x1,-0x3c(%ebp) 57b: eb 87 jmp 504 <printint+0x24> 57d: 8d 76 00 lea 0x0(%esi),%esi 00000580 <printf>: // Print to the given fd. Only understands %d, %x, %p, %s. void printf(int fd, const char *fmt, ...) { 580: 55 push %ebp 581: 89 e5 mov %esp,%ebp 583: 57 push %edi char *s; int c, i, state; uint *ap; state = 0; 584: 31 ff xor %edi,%edi { 586: 56 push %esi 587: 53 push %ebx 588: 83 ec 3c sub $0x3c,%esp ap = (uint*)(void*)&fmt + 1; for(i = 0; fmt[i]; i++){ 58b: 8b 5d 0c mov 0xc(%ebp),%ebx ap = (uint*)(void*)&fmt + 1; 58e: 8d 45 10 lea 0x10(%ebp),%eax { 591: 8b 75 08 mov 0x8(%ebp),%esi ap = (uint*)(void*)&fmt + 1; 594: 89 45 d4 mov %eax,-0x2c(%ebp) for(i = 0; fmt[i]; i++){ 597: 0f b6 13 movzbl (%ebx),%edx 59a: 83 c3 01 add $0x1,%ebx 59d: 84 d2 test %dl,%dl 59f: 75 39 jne 5da <printf+0x5a> 5a1: e9 ca 00 00 00 jmp 670 <printf+0xf0> 5a6: 66 90 xchg %ax,%ax c = fmt[i] & 0xff; if(state == 0){ if(c == '%'){ 5a8: 83 fa 25 cmp $0x25,%edx 5ab: 0f 84 c7 00 00 00 je 678 <printf+0xf8> write(fd, &c, 1); 5b1: 8d 45 e0 lea -0x20(%ebp),%eax 5b4: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) 5bb: 00 5bc: 89 44 24 04 mov %eax,0x4(%esp) 5c0: 89 34 24 mov %esi,(%esp) state = '%'; } else { putc(fd, c); 5c3: 88 55 e0 mov %dl,-0x20(%ebp) write(fd, &c, 1); 5c6: e8 27 fe ff ff call 3f2 <write> 5cb: 83 c3 01 add $0x1,%ebx for(i = 0; fmt[i]; i++){ 5ce: 0f b6 53 ff movzbl -0x1(%ebx),%edx 5d2: 84 d2 test %dl,%dl 5d4: 0f 84 96 00 00 00 je 670 <printf+0xf0> if(state == 0){ 5da: 85 ff test %edi,%edi c = fmt[i] & 0xff; 5dc: 0f be c2 movsbl %dl,%eax if(state == 0){ 5df: 74 c7 je 5a8 <printf+0x28> } } else if(state == '%'){ 5e1: 83 ff 25 cmp $0x25,%edi 5e4: 75 e5 jne 5cb <printf+0x4b> if(c == 'd' || c == 'u'){ 5e6: 83 fa 75 cmp $0x75,%edx 5e9: 0f 84 99 00 00 00 je 688 <printf+0x108> 5ef: 83 fa 64 cmp $0x64,%edx 5f2: 0f 84 90 00 00 00 je 688 <printf+0x108> printint(fd, *ap, 10, 1); ap++; } else if(c == 'x' || c == 'p'){ 5f8: 25 f7 00 00 00 and $0xf7,%eax 5fd: 83 f8 70 cmp $0x70,%eax 600: 0f 84 aa 00 00 00 je 6b0 <printf+0x130> putc(fd, '0'); putc(fd, 'x'); printint(fd, *ap, 16, 0); ap++; } else if(c == 's'){ 606: 83 fa 73 cmp $0x73,%edx 609: 0f 84 e9 00 00 00 je 6f8 <printf+0x178> s = "(null)"; while(*s != 0){ putc(fd, *s); s++; } } else if(c == 'c'){ 60f: 83 fa 63 cmp $0x63,%edx 612: 0f 84 2b 01 00 00 je 743 <printf+0x1c3> putc(fd, *ap); ap++; } else if(c == '%'){ 618: 83 fa 25 cmp $0x25,%edx 61b: 0f 84 4f 01 00 00 je 770 <printf+0x1f0> write(fd, &c, 1); 621: 8d 45 e6 lea -0x1a(%ebp),%eax 624: 83 c3 01 add $0x1,%ebx 627: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) 62e: 00 } else { // Unknown % sequence. Print it to draw attention. putc(fd, '%'); putc(fd, c); } state = 0; 62f: 31 ff xor %edi,%edi write(fd, &c, 1); 631: 89 44 24 04 mov %eax,0x4(%esp) 635: 89 34 24 mov %esi,(%esp) 638: 89 55 d0 mov %edx,-0x30(%ebp) 63b: c6 45 e6 25 movb $0x25,-0x1a(%ebp) 63f: e8 ae fd ff ff call 3f2 <write> putc(fd, c); 644: 8b 55 d0 mov -0x30(%ebp),%edx write(fd, &c, 1); 647: 8d 45 e7 lea -0x19(%ebp),%eax 64a: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) 651: 00 652: 89 44 24 04 mov %eax,0x4(%esp) 656: 89 34 24 mov %esi,(%esp) putc(fd, c); 659: 88 55 e7 mov %dl,-0x19(%ebp) write(fd, &c, 1); 65c: e8 91 fd ff ff call 3f2 <write> for(i = 0; fmt[i]; i++){ 661: 0f b6 53 ff movzbl -0x1(%ebx),%edx 665: 84 d2 test %dl,%dl 667: 0f 85 6d ff ff ff jne 5da <printf+0x5a> 66d: 8d 76 00 lea 0x0(%esi),%esi } } } 670: 83 c4 3c add $0x3c,%esp 673: 5b pop %ebx 674: 5e pop %esi 675: 5f pop %edi 676: 5d pop %ebp 677: c3 ret state = '%'; 678: bf 25 00 00 00 mov $0x25,%edi 67d: e9 49 ff ff ff jmp 5cb <printf+0x4b> 682: 8d b6 00 00 00 00 lea 0x0(%esi),%esi printint(fd, *ap, 10, 1); 688: c7 04 24 01 00 00 00 movl $0x1,(%esp) 68f: b9 0a 00 00 00 mov $0xa,%ecx printint(fd, *ap, 16, 0); 694: 8b 45 d4 mov -0x2c(%ebp),%eax state = 0; 697: 31 ff xor %edi,%edi printint(fd, *ap, 16, 0); 699: 8b 10 mov (%eax),%edx 69b: 89 f0 mov %esi,%eax 69d: e8 3e fe ff ff call 4e0 <printint> ap++; 6a2: 83 45 d4 04 addl $0x4,-0x2c(%ebp) 6a6: e9 20 ff ff ff jmp 5cb <printf+0x4b> 6ab: 90 nop 6ac: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi write(fd, &c, 1); 6b0: 8d 45 e1 lea -0x1f(%ebp),%eax 6b3: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) 6ba: 00 6bb: 89 44 24 04 mov %eax,0x4(%esp) 6bf: 89 34 24 mov %esi,(%esp) 6c2: c6 45 e1 30 movb $0x30,-0x1f(%ebp) 6c6: e8 27 fd ff ff call 3f2 <write> 6cb: 8d 45 e2 lea -0x1e(%ebp),%eax 6ce: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) 6d5: 00 6d6: 89 44 24 04 mov %eax,0x4(%esp) 6da: 89 34 24 mov %esi,(%esp) 6dd: c6 45 e2 78 movb $0x78,-0x1e(%ebp) 6e1: e8 0c fd ff ff call 3f2 <write> printint(fd, *ap, 16, 0); 6e6: b9 10 00 00 00 mov $0x10,%ecx 6eb: c7 04 24 00 00 00 00 movl $0x0,(%esp) 6f2: eb a0 jmp 694 <printf+0x114> 6f4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi s = (char*)*ap; 6f8: 8b 45 d4 mov -0x2c(%ebp),%eax ap++; 6fb: 83 45 d4 04 addl $0x4,-0x2c(%ebp) s = (char*)*ap; 6ff: 8b 38 mov (%eax),%edi s = "(null)"; 701: b8 e8 0b 00 00 mov $0xbe8,%eax 706: 85 ff test %edi,%edi 708: 0f 44 f8 cmove %eax,%edi while(*s != 0){ 70b: 0f b6 07 movzbl (%edi),%eax 70e: 84 c0 test %al,%al 710: 74 2a je 73c <printf+0x1bc> 712: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 718: 88 45 e3 mov %al,-0x1d(%ebp) write(fd, &c, 1); 71b: 8d 45 e3 lea -0x1d(%ebp),%eax s++; 71e: 83 c7 01 add $0x1,%edi write(fd, &c, 1); 721: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) 728: 00 729: 89 44 24 04 mov %eax,0x4(%esp) 72d: 89 34 24 mov %esi,(%esp) 730: e8 bd fc ff ff call 3f2 <write> while(*s != 0){ 735: 0f b6 07 movzbl (%edi),%eax 738: 84 c0 test %al,%al 73a: 75 dc jne 718 <printf+0x198> state = 0; 73c: 31 ff xor %edi,%edi 73e: e9 88 fe ff ff jmp 5cb <printf+0x4b> putc(fd, *ap); 743: 8b 45 d4 mov -0x2c(%ebp),%eax state = 0; 746: 31 ff xor %edi,%edi putc(fd, *ap); 748: 8b 00 mov (%eax),%eax write(fd, &c, 1); 74a: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) 751: 00 752: 89 34 24 mov %esi,(%esp) putc(fd, *ap); 755: 88 45 e4 mov %al,-0x1c(%ebp) write(fd, &c, 1); 758: 8d 45 e4 lea -0x1c(%ebp),%eax 75b: 89 44 24 04 mov %eax,0x4(%esp) 75f: e8 8e fc ff ff call 3f2 <write> ap++; 764: 83 45 d4 04 addl $0x4,-0x2c(%ebp) 768: e9 5e fe ff ff jmp 5cb <printf+0x4b> 76d: 8d 76 00 lea 0x0(%esi),%esi write(fd, &c, 1); 770: 8d 45 e5 lea -0x1b(%ebp),%eax state = 0; 773: 31 ff xor %edi,%edi write(fd, &c, 1); 775: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) 77c: 00 77d: 89 44 24 04 mov %eax,0x4(%esp) 781: 89 34 24 mov %esi,(%esp) 784: c6 45 e5 25 movb $0x25,-0x1b(%ebp) 788: e8 65 fc ff ff call 3f2 <write> 78d: e9 39 fe ff ff jmp 5cb <printf+0x4b> 792: 66 90 xchg %ax,%ax 794: 66 90 xchg %ax,%ax 796: 66 90 xchg %ax,%ax 798: 66 90 xchg %ax,%ax 79a: 66 90 xchg %ax,%ax 79c: 66 90 xchg %ax,%ax 79e: 66 90 xchg %ax,%ax 000007a0 <free>: static Header base; static Header *freep; void free(void *ap) { 7a0: 55 push %ebp Header *bp, *p; bp = (Header*)ap - 1; for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 7a1: a1 a4 10 00 00 mov 0x10a4,%eax { 7a6: 89 e5 mov %esp,%ebp 7a8: 57 push %edi 7a9: 56 push %esi 7aa: 53 push %ebx 7ab: 8b 5d 08 mov 0x8(%ebp),%ebx if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) 7ae: 8b 08 mov (%eax),%ecx bp = (Header*)ap - 1; 7b0: 8d 53 f8 lea -0x8(%ebx),%edx for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 7b3: 39 d0 cmp %edx,%eax 7b5: 72 11 jb 7c8 <free+0x28> 7b7: 90 nop if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) 7b8: 39 c8 cmp %ecx,%eax 7ba: 72 04 jb 7c0 <free+0x20> 7bc: 39 ca cmp %ecx,%edx 7be: 72 10 jb 7d0 <free+0x30> 7c0: 89 c8 mov %ecx,%eax for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 7c2: 39 d0 cmp %edx,%eax if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) 7c4: 8b 08 mov (%eax),%ecx for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 7c6: 73 f0 jae 7b8 <free+0x18> 7c8: 39 ca cmp %ecx,%edx 7ca: 72 04 jb 7d0 <free+0x30> if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) 7cc: 39 c8 cmp %ecx,%eax 7ce: 72 f0 jb 7c0 <free+0x20> break; if(bp + bp->s.size == p->s.ptr){ 7d0: 8b 73 fc mov -0x4(%ebx),%esi 7d3: 8d 3c f2 lea (%edx,%esi,8),%edi 7d6: 39 cf cmp %ecx,%edi 7d8: 74 1e je 7f8 <free+0x58> bp->s.size += p->s.ptr->s.size; bp->s.ptr = p->s.ptr->s.ptr; } else bp->s.ptr = p->s.ptr; 7da: 89 4b f8 mov %ecx,-0x8(%ebx) if(p + p->s.size == bp){ 7dd: 8b 48 04 mov 0x4(%eax),%ecx 7e0: 8d 34 c8 lea (%eax,%ecx,8),%esi 7e3: 39 f2 cmp %esi,%edx 7e5: 74 28 je 80f <free+0x6f> p->s.size += bp->s.size; p->s.ptr = bp->s.ptr; } else p->s.ptr = bp; 7e7: 89 10 mov %edx,(%eax) freep = p; 7e9: a3 a4 10 00 00 mov %eax,0x10a4 } 7ee: 5b pop %ebx 7ef: 5e pop %esi 7f0: 5f pop %edi 7f1: 5d pop %ebp 7f2: c3 ret 7f3: 90 nop 7f4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi bp->s.size += p->s.ptr->s.size; 7f8: 03 71 04 add 0x4(%ecx),%esi 7fb: 89 73 fc mov %esi,-0x4(%ebx) bp->s.ptr = p->s.ptr->s.ptr; 7fe: 8b 08 mov (%eax),%ecx 800: 8b 09 mov (%ecx),%ecx 802: 89 4b f8 mov %ecx,-0x8(%ebx) if(p + p->s.size == bp){ 805: 8b 48 04 mov 0x4(%eax),%ecx 808: 8d 34 c8 lea (%eax,%ecx,8),%esi 80b: 39 f2 cmp %esi,%edx 80d: 75 d8 jne 7e7 <free+0x47> p->s.size += bp->s.size; 80f: 03 4b fc add -0x4(%ebx),%ecx freep = p; 812: a3 a4 10 00 00 mov %eax,0x10a4 p->s.size += bp->s.size; 817: 89 48 04 mov %ecx,0x4(%eax) p->s.ptr = bp->s.ptr; 81a: 8b 53 f8 mov -0x8(%ebx),%edx 81d: 89 10 mov %edx,(%eax) } 81f: 5b pop %ebx 820: 5e pop %esi 821: 5f pop %edi 822: 5d pop %ebp 823: c3 ret 824: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 82a: 8d bf 00 00 00 00 lea 0x0(%edi),%edi 00000830 <malloc>: return freep; } void* malloc(uint nbytes) { 830: 55 push %ebp 831: 89 e5 mov %esp,%ebp 833: 57 push %edi 834: 56 push %esi 835: 53 push %ebx 836: 83 ec 1c sub $0x1c,%esp Header *p, *prevp; uint nunits; nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; 839: 8b 45 08 mov 0x8(%ebp),%eax if((prevp = freep) == 0){ 83c: 8b 1d a4 10 00 00 mov 0x10a4,%ebx nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; 842: 8d 48 07 lea 0x7(%eax),%ecx 845: c1 e9 03 shr $0x3,%ecx if((prevp = freep) == 0){ 848: 85 db test %ebx,%ebx nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; 84a: 8d 71 01 lea 0x1(%ecx),%esi if((prevp = freep) == 0){ 84d: 0f 84 9b 00 00 00 je 8ee <malloc+0xbe> 853: 8b 13 mov (%ebx),%edx 855: 8b 7a 04 mov 0x4(%edx),%edi base.s.ptr = freep = prevp = &base; base.s.size = 0; } for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ if(p->s.size >= nunits){ 858: 39 fe cmp %edi,%esi 85a: 76 64 jbe 8c0 <malloc+0x90> 85c: 8d 04 f5 00 00 00 00 lea 0x0(,%esi,8),%eax if(nu < 4096) 863: bb 00 80 00 00 mov $0x8000,%ebx 868: 89 45 e4 mov %eax,-0x1c(%ebp) 86b: eb 0e jmp 87b <malloc+0x4b> 86d: 8d 76 00 lea 0x0(%esi),%esi for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ 870: 8b 02 mov (%edx),%eax if(p->s.size >= nunits){ 872: 8b 78 04 mov 0x4(%eax),%edi 875: 39 fe cmp %edi,%esi 877: 76 4f jbe 8c8 <malloc+0x98> 879: 89 c2 mov %eax,%edx p->s.size = nunits; } freep = prevp; return (void*)(p + 1); } if(p == freep) 87b: 3b 15 a4 10 00 00 cmp 0x10a4,%edx 881: 75 ed jne 870 <malloc+0x40> if(nu < 4096) 883: 8b 45 e4 mov -0x1c(%ebp),%eax 886: 81 fe 00 10 00 00 cmp $0x1000,%esi 88c: bf 00 10 00 00 mov $0x1000,%edi 891: 0f 43 fe cmovae %esi,%edi 894: 0f 42 c3 cmovb %ebx,%eax p = sbrk(nu * sizeof(Header)); 897: 89 04 24 mov %eax,(%esp) 89a: e8 bb fb ff ff call 45a <sbrk> if(p == (char*)-1) 89f: 83 f8 ff cmp $0xffffffff,%eax 8a2: 74 18 je 8bc <malloc+0x8c> hp->s.size = nu; 8a4: 89 78 04 mov %edi,0x4(%eax) free((void*)(hp + 1)); 8a7: 83 c0 08 add $0x8,%eax 8aa: 89 04 24 mov %eax,(%esp) 8ad: e8 ee fe ff ff call 7a0 <free> return freep; 8b2: 8b 15 a4 10 00 00 mov 0x10a4,%edx if((p = morecore(nunits)) == 0) 8b8: 85 d2 test %edx,%edx 8ba: 75 b4 jne 870 <malloc+0x40> return 0; 8bc: 31 c0 xor %eax,%eax 8be: eb 20 jmp 8e0 <malloc+0xb0> if(p->s.size >= nunits){ 8c0: 89 d0 mov %edx,%eax 8c2: 89 da mov %ebx,%edx 8c4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi if(p->s.size == nunits) 8c8: 39 fe cmp %edi,%esi 8ca: 74 1c je 8e8 <malloc+0xb8> p->s.size -= nunits; 8cc: 29 f7 sub %esi,%edi 8ce: 89 78 04 mov %edi,0x4(%eax) p += p->s.size; 8d1: 8d 04 f8 lea (%eax,%edi,8),%eax p->s.size = nunits; 8d4: 89 70 04 mov %esi,0x4(%eax) freep = prevp; 8d7: 89 15 a4 10 00 00 mov %edx,0x10a4 return (void*)(p + 1); 8dd: 83 c0 08 add $0x8,%eax } } 8e0: 83 c4 1c add $0x1c,%esp 8e3: 5b pop %ebx 8e4: 5e pop %esi 8e5: 5f pop %edi 8e6: 5d pop %ebp 8e7: c3 ret prevp->s.ptr = p->s.ptr; 8e8: 8b 08 mov (%eax),%ecx 8ea: 89 0a mov %ecx,(%edx) 8ec: eb e9 jmp 8d7 <malloc+0xa7> base.s.ptr = freep = prevp = &base; 8ee: c7 05 a4 10 00 00 a8 movl $0x10a8,0x10a4 8f5: 10 00 00 base.s.size = 0; 8f8: ba a8 10 00 00 mov $0x10a8,%edx base.s.ptr = freep = prevp = &base; 8fd: c7 05 a8 10 00 00 a8 movl $0x10a8,0x10a8 904: 10 00 00 base.s.size = 0; 907: c7 05 ac 10 00 00 00 movl $0x0,0x10ac 90e: 00 00 00 911: e9 46 ff ff ff jmp 85c <malloc+0x2c> 916: 66 90 xchg %ax,%ax 918: 66 90 xchg %ax,%ax 91a: 66 90 xchg %ax,%ax 91c: 66 90 xchg %ax,%ax 91e: 66 90 xchg %ax,%ax 00000920 <benny_thread_create>: static struct benny_thread_s *bt_new(void); int benny_thread_create(benny_thread_t *abt, void (*func)(void*), void *arg_ptr) { 920: 55 push %ebp 921: 89 e5 mov %esp,%ebp 923: 56 push %esi 924: 53 push %ebx 925: 83 ec 10 sub $0x10,%esp } static struct benny_thread_s * bt_new(void) { struct benny_thread_s *bt = malloc(sizeof(struct benny_thread_s)); 928: c7 04 24 0c 00 00 00 movl $0xc,(%esp) 92f: e8 fc fe ff ff call 830 <malloc> if (bt == NULL) { 934: 85 c0 test %eax,%eax struct benny_thread_s *bt = malloc(sizeof(struct benny_thread_s)); 936: 89 c6 mov %eax,%esi if (bt == NULL) { 938: 74 66 je 9a0 <benny_thread_create+0x80> // allocate 2 pages worth of memory and then make sure the // beginning address used for the stack is page alligned. // we want it page alligned so that we don't generate a // page fault by accessing the stack for a thread. bt->bt_stack = bt->mem_stack = malloc(PGSIZE * 2); 93a: c7 04 24 00 20 00 00 movl $0x2000,(%esp) 941: e8 ea fe ff ff call 830 <malloc> if (bt->bt_stack == NULL) { 946: 85 c0 test %eax,%eax bt->bt_stack = bt->mem_stack = malloc(PGSIZE * 2); 948: 89 c3 mov %eax,%ebx 94a: 89 46 08 mov %eax,0x8(%esi) 94d: 89 46 04 mov %eax,0x4(%esi) if (bt->bt_stack == NULL) { 950: 74 5d je 9af <benny_thread_create+0x8f> free(bt); return NULL; } if (((uint) bt->bt_stack) % PGSIZE != 0) { 952: 25 ff 0f 00 00 and $0xfff,%eax 957: 75 37 jne 990 <benny_thread_create+0x70> // allign the thread stack to a page boundary bt->bt_stack += (PGSIZE - ((uint) bt->bt_stack) % PGSIZE); } bt->bid = -1; 959: c7 06 ff ff ff ff movl $0xffffffff,(%esi) bt->bid = kthread_create(func, arg_ptr, bt->bt_stack); 95f: 8b 45 10 mov 0x10(%ebp),%eax 962: 89 5c 24 08 mov %ebx,0x8(%esp) 966: 89 44 24 04 mov %eax,0x4(%esp) 96a: 8b 45 0c mov 0xc(%ebp),%eax 96d: 89 04 24 mov %eax,(%esp) 970: e8 25 fb ff ff call 49a <kthread_create> if (bt->bid != 0) { 975: 85 c0 test %eax,%eax bt->bid = kthread_create(func, arg_ptr, bt->bt_stack); 977: 89 06 mov %eax,(%esi) if (bt->bid != 0) { 979: 74 2d je 9a8 <benny_thread_create+0x88> *abt = (benny_thread_t) bt; 97b: 8b 45 08 mov 0x8(%ebp),%eax 97e: 89 30 mov %esi,(%eax) result = 0; 980: 31 c0 xor %eax,%eax } 982: 83 c4 10 add $0x10,%esp 985: 5b pop %ebx 986: 5e pop %esi 987: 5d pop %ebp 988: c3 ret 989: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi bt->bt_stack += (PGSIZE - ((uint) bt->bt_stack) % PGSIZE); 990: 29 c3 sub %eax,%ebx 992: 81 c3 00 10 00 00 add $0x1000,%ebx 998: 89 5e 04 mov %ebx,0x4(%esi) 99b: eb bc jmp 959 <benny_thread_create+0x39> 99d: 8d 76 00 lea 0x0(%esi),%esi 9a0: 8b 1d 04 00 00 00 mov 0x4,%ebx 9a6: eb b7 jmp 95f <benny_thread_create+0x3f> int result = -1; 9a8: b8 ff ff ff ff mov $0xffffffff,%eax 9ad: eb d3 jmp 982 <benny_thread_create+0x62> free(bt); 9af: 89 34 24 mov %esi,(%esp) return NULL; 9b2: 31 f6 xor %esi,%esi free(bt); 9b4: e8 e7 fd ff ff call 7a0 <free> 9b9: 8b 5b 04 mov 0x4(%ebx),%ebx 9bc: eb a1 jmp 95f <benny_thread_create+0x3f> 9be: 66 90 xchg %ax,%ax 000009c0 <benny_thread_bid>: { 9c0: 55 push %ebp 9c1: 89 e5 mov %esp,%ebp return bt->bid; 9c3: 8b 45 08 mov 0x8(%ebp),%eax } 9c6: 5d pop %ebp return bt->bid; 9c7: 8b 00 mov (%eax),%eax } 9c9: c3 ret 9ca: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 000009d0 <benny_thread_join>: { 9d0: 55 push %ebp 9d1: 89 e5 mov %esp,%ebp 9d3: 53 push %ebx 9d4: 83 ec 14 sub $0x14,%esp 9d7: 8b 5d 08 mov 0x8(%ebp),%ebx retVal = kthread_join(bt->bid); 9da: 8b 03 mov (%ebx),%eax 9dc: 89 04 24 mov %eax,(%esp) 9df: e8 be fa ff ff call 4a2 <kthread_join> if (retVal == 0) { 9e4: 85 c0 test %eax,%eax 9e6: 75 27 jne a0f <benny_thread_join+0x3f> free(bt->mem_stack); 9e8: 8b 53 08 mov 0x8(%ebx),%edx 9eb: 89 45 f4 mov %eax,-0xc(%ebp) 9ee: 89 14 24 mov %edx,(%esp) 9f1: e8 aa fd ff ff call 7a0 <free> bt->bt_stack = bt->mem_stack = NULL; 9f6: c7 43 08 00 00 00 00 movl $0x0,0x8(%ebx) 9fd: c7 43 04 00 00 00 00 movl $0x0,0x4(%ebx) free(bt); a04: 89 1c 24 mov %ebx,(%esp) a07: e8 94 fd ff ff call 7a0 <free> a0c: 8b 45 f4 mov -0xc(%ebp),%eax } a0f: 83 c4 14 add $0x14,%esp a12: 5b pop %ebx a13: 5d pop %ebp a14: c3 ret a15: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi a19: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 00000a20 <benny_thread_exit>: { a20: 55 push %ebp a21: 89 e5 mov %esp,%ebp } a23: 5d pop %ebp return kthread_exit(exitValue); a24: e9 81 fa ff ff jmp 4aa <kthread_exit> a29: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 00000a30 <benny_mootex_init>: } # ifdef BENNY_MOOTEX int benny_mootex_init(benny_mootex_t *benny_mootex) { a30: 55 push %ebp a31: 89 e5 mov %esp,%ebp a33: 8b 45 08 mov 0x8(%ebp),%eax benny_mootex->locked = 0; a36: c7 00 00 00 00 00 movl $0x0,(%eax) benny_mootex->bid = -1; a3c: c7 40 04 ff ff ff ff movl $0xffffffff,0x4(%eax) return 0; } a43: 31 c0 xor %eax,%eax a45: 5d pop %ebp a46: c3 ret a47: 89 f6 mov %esi,%esi a49: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 00000a50 <benny_mootex_yieldlock>: int benny_mootex_yieldlock(benny_mootex_t *benny_mootex) { a50: 55 push %ebp xchg(volatile uint *addr, uint newval) { uint result; // The + in "+m" denotes a read-modify-write operand. asm volatile("lock; xchgl %0, %1" : a51: b8 01 00 00 00 mov $0x1,%eax a56: 89 e5 mov %esp,%ebp a58: 56 push %esi a59: 53 push %ebx a5a: 8b 5d 08 mov 0x8(%ebp),%ebx a5d: f0 87 03 lock xchg %eax,(%ebx) // #error this is the call to lock the mootex that will yield in a // #error loop until the lock is acquired. while(xchg(&benny_mootex->locked, 1) != 0){ a60: 85 c0 test %eax,%eax a62: be 01 00 00 00 mov $0x1,%esi a67: 74 15 je a7e <benny_mootex_yieldlock+0x2e> a69: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi benny_yield(void) { // # error This just gives up the rest of this scheduled time slice to // # error another process/thread. return kthread_yield(); a70: e8 45 fa ff ff call 4ba <kthread_yield> a75: 89 f0 mov %esi,%eax a77: f0 87 03 lock xchg %eax,(%ebx) while(xchg(&benny_mootex->locked, 1) != 0){ a7a: 85 c0 test %eax,%eax a7c: 75 f2 jne a70 <benny_mootex_yieldlock+0x20> return kthread_self(); a7e: e8 2f fa ff ff call 4b2 <kthread_self> benny_mootex->bid = benny_self(); a83: 89 43 04 mov %eax,0x4(%ebx) } a86: 31 c0 xor %eax,%eax a88: 5b pop %ebx a89: 5e pop %esi a8a: 5d pop %ebp a8b: c3 ret a8c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 00000a90 <benny_mootex_spinlock>: { a90: 55 push %ebp a91: ba 01 00 00 00 mov $0x1,%edx a96: 89 e5 mov %esp,%ebp a98: 53 push %ebx a99: 83 ec 04 sub $0x4,%esp a9c: 8b 5d 08 mov 0x8(%ebp),%ebx a9f: 90 nop aa0: 89 d0 mov %edx,%eax aa2: f0 87 03 lock xchg %eax,(%ebx) while(xchg(&benny_mootex->locked, 1) != 0){ aa5: 85 c0 test %eax,%eax aa7: 75 f7 jne aa0 <benny_mootex_spinlock+0x10> return kthread_self(); aa9: e8 04 fa ff ff call 4b2 <kthread_self> benny_mootex->bid = benny_self(); aae: 89 43 04 mov %eax,0x4(%ebx) } ab1: 83 c4 04 add $0x4,%esp ab4: 31 c0 xor %eax,%eax ab6: 5b pop %ebx ab7: 5d pop %ebp ab8: c3 ret ab9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 00000ac0 <benny_mootex_unlock>: { ac0: 55 push %ebp ac1: 89 e5 mov %esp,%ebp ac3: 53 push %ebx ac4: 83 ec 04 sub $0x4,%esp ac7: 8b 5d 08 mov 0x8(%ebp),%ebx return kthread_self(); aca: e8 e3 f9 ff ff call 4b2 <kthread_self> if(tid == benny_mootex->bid){ acf: 39 43 04 cmp %eax,0x4(%ebx) ad2: 75 1c jne af0 <benny_mootex_unlock+0x30> __sync_synchronize(); ad4: 0f ae f0 mfence return 0; ad7: 31 c0 xor %eax,%eax benny_mootex->bid = -1; ad9: c7 43 04 ff ff ff ff movl $0xffffffff,0x4(%ebx) __sync_lock_release(&benny_mootex->locked); ae0: c7 03 00 00 00 00 movl $0x0,(%ebx) } ae6: 83 c4 04 add $0x4,%esp ae9: 5b pop %ebx aea: 5d pop %ebp aeb: c3 ret aec: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi af0: 83 c4 04 add $0x4,%esp return -1; af3: b8 ff ff ff ff mov $0xffffffff,%eax } af8: 5b pop %ebx af9: 5d pop %ebp afa: c3 ret afb: 90 nop afc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 00000b00 <benny_mootex_trylock>: { b00: 55 push %ebp b01: b8 01 00 00 00 mov $0x1,%eax b06: 89 e5 mov %esp,%ebp b08: 53 push %ebx b09: 83 ec 04 sub $0x4,%esp b0c: 8b 5d 08 mov 0x8(%ebp),%ebx b0f: f0 87 03 lock xchg %eax,(%ebx) if(xchg(&benny_mootex->locked, 1) != 0){ b12: 85 c0 test %eax,%eax b14: 75 08 jne b1e <benny_mootex_trylock+0x1e> int tid = kthread_self(); b16: e8 97 f9 ff ff call 4b2 <kthread_self> benny_mootex->bid = tid; b1b: 89 43 04 mov %eax,0x4(%ebx) } b1e: 83 c4 04 add $0x4,%esp b21: b8 ff ff ff ff mov $0xffffffff,%eax b26: 5b pop %ebx b27: 5d pop %ebp b28: c3 ret b29: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 00000b30 <benny_mootex_wholock>: { b30: 55 push %ebp b31: 89 e5 mov %esp,%ebp return benny_mootex->bid; b33: 8b 45 08 mov 0x8(%ebp),%eax } b36: 5d pop %ebp return benny_mootex->bid; b37: 8b 40 04 mov 0x4(%eax),%eax } b3a: c3 ret b3b: 90 nop b3c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 00000b40 <benny_mootex_islocked>: { b40: 55 push %ebp b41: 89 e5 mov %esp,%ebp return benny_mootex->locked; b43: 8b 45 08 mov 0x8(%ebp),%eax } b46: 5d pop %ebp return benny_mootex->locked; b47: 8b 00 mov (%eax),%eax } b49: c3 ret b4a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 00000b50 <benny_self>: { b50: 55 push %ebp b51: 89 e5 mov %esp,%ebp } b53: 5d pop %ebp return kthread_self(); b54: e9 59 f9 ff ff jmp 4b2 <kthread_self> b59: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 00000b60 <benny_yield>: { b60: 55 push %ebp b61: 89 e5 mov %esp,%ebp } b63: 5d pop %ebp return kthread_yield(); b64: e9 51 f9 ff ff jmp 4ba <kthread_yield> b69: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 00000b70 <benny_cpu_count>: int benny_cpu_count(void) { b70: 55 push %ebp b71: 89 e5 mov %esp,%ebp // # error call the kthread_cpu_count() function. // kthread_cpu_count(); return kthread_cpu_count(); } b73: 5d pop %ebp return kthread_cpu_count(); b74: e9 49 f9 ff ff jmp 4c2 <kthread_cpu_count> b79: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 00000b80 <benny_thread_count>: int benny_thread_count(void) { b80: 55 push %ebp b81: 89 e5 mov %esp,%ebp // # error call the kthread_thread_count() function. // kthread_thread_count() return kthread_thread_count(); } b83: 5d pop %ebp return kthread_thread_count(); b84: e9 41 f9 ff ff jmp 4ca <kthread_thread_count>
!to "build/timer.bin" ;;;;;;;;;;;;;;;; ;;;; Offset ;;;; ;;;;;;;;;;;;;;;; *=$8000 ;;;;;;;;;;;;;; ;;;; Data ;;;; ;;;;;;;;;;;;;; year_1: !word 1955 year_2: !word 1956 year_3: !word 1982 player_1_label: !text "P1:" !byte $00 player_2_label: !text "P2:" !byte $00 ;;;;;;;;;;;;;;;;;;; ;;;; Variables ;;;; ;;;;;;;;;;;;;;;;;;; PORTB = $6000 PORTA = $6001 DDRB = $6002 DDRA = $6003 T1_LC = $6004 T1_HC = $6005 ACR = $600b PCR = $600c IFR = $600d IER = $600e E = %10000000 RW = %01000000 RS = %00100000 string_ptr = $86 counter = $0200 number = counter + 2 mod_10 = number + 2 string = mod_10 + 2 mem_cmp = string + 6 mem_start = mem_cmp + 1 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;; Instructions (main) ;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;; main: ; Set stack pointer to address 01ff ldx #$ff txs jsr lcd_init ; Enable interrupts for timer 1 lda #%11000000 sta IER ; Countinuous timer interrupts (intervals) with output on PB7 lda #%11000000 sta ACR ; Load timer 1 with $ffff to initiate countdown lda #$ff sta T1_LC sta T1_HC ; Set counter to zero lda #0 sta counter sta counter + 1 ; Enable interrupts cli main_loop: lda counter sta number lda counter + 1 sta number + 1 jsr number_to_string jsr print_string jsr lcd_return jmp main_loop nmi: irq: bit T1_LC ; Clear the interrupt by reading low order timer count inc counter bne irq_break inc counter + 1 irq_break: rti ;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;; Memory Utilities ;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;; fill_memory_from_x_to_y: sta mem_start,x stx mem_cmp cpy mem_cmp beq fill_memory_from_x_to_y_complete inx jmp fill_memory_from_x_to_y fill_memory_from_x_to_y_complete: rts ;;;;;;;;;;;;;;;;;;;;;;;;; ;;;; Print Utilities ;;;; ;;;;;;;;;;;;;;;;;;;;;;;;; print: jsr lcd_wait sta PORTB lda #(RS | E) ; Toggle RS and E bits to write data sta PORTA lda #0 sta PORTA rts print_memory_from_x_to_y: pha print_memory_from_x_to_y_start: lda mem_start,x jsr print stx mem_cmp cpy mem_cmp beq print_memory_from_x_to_y_complete inx jmp print_memory_from_x_to_y_start print_memory_from_x_to_y_complete: pla rts print_ascii_table_forever: txa jsr print inx jmp print_ascii_table_forever print_random_chars_forever: lda $00,x jsr print inx jmp print_random_chars_forever print_string: pha phx ldx #0 print_string_loop: lda string,x beq print_string_break jsr print inx jmp print_string_loop print_string_break: plx pla rts print_string_ptr: pha phy ldy #0 print_string_ptr_loop: lda (string_ptr),y beq print_string_ptr_break jsr print iny jmp print_string_ptr_loop print_string_ptr_break: ply pla rts ;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;; String Utilities ;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;; ; Add the character in the A register to the beginning ; of the null-terminated variable `string` push_char: ldy #0 ; Set character index to zero push_char_loop: pha ; Push new character onto the stack lda string,y ; Get character at index and push it into X register tax pla ; Pop new character off the stack sta string,y ; Store new character at the current index beq push_char_break iny ; Increment index txa ; Move previous character into A register jmp push_char_loop push_char_break: rts ; Convert the `number` variable to a sequence of ; characters and store them in the `string` variable number_to_string: pha phx phy ; Initialize string lda #0 sta string number_to_string_divide: ; Initialize the remainder to zero lda #0 sta mod_10 sta mod_10 + 1 ; Initialize X register to 16 as a counter (for processing 2-byte numbers) ldx #16 clc number_to_string_division_loop: ; Rotate dividend and remainder rol number rol number + 1 rol mod_10 rol mod_10 + 1 ; a,y = dividend - divisor sec lda mod_10 sbc #10 tay ; Save low byte to Y register lda mod_10 + 1 sbc #0 bcc number_to_string_ignore_result sty mod_10 sta mod_10 + 1 number_to_string_ignore_result: dex bne number_to_string_division_loop ; Shift carry bit into number rol number rol number + 1 number_to_string_save_remainder: clc lda mod_10 adc #"0" jsr push_char ; If number is not zero, continue dividing (via shift and subtraction) lda number ora number + 1 bne number_to_string_divide ply plx pla rts ;;;;;;;;;;;;;;;;;;;;;; ;;;; LCD Uitities ;;;; ;;;;;;;;;;;;;;;;;;;;;; lcd_init: pha ; Set all pins on port B to output lda #%11111111 sta DDRB ; Set top 3 pins on port A to output lda #%11100000 sta DDRA ; Set 8-bit mode; 2-line display; 5x8 font lda #%00111000 jsr lcd_instruction ; Display on; cursor off; blink off lda #%00001100 jsr lcd_instruction ; Increment cursor; no display shift lda #%00000110 jsr lcd_instruction jsr lcd_clear jsr lcd_return pla rts lcd_clear: pha lda #%00000001 jsr lcd_instruction pla rts lcd_return: pha lda #%00000010 jsr lcd_instruction pla rts lcd_instruction: pha jsr lcd_wait sta PORTB lda #E ; Toggle E bit to send instruction sta PORTA lda #0 sta PORTA pla rts lcd_wait: pha lda #%00000000 ; Set all pins on port B to input sta DDRB lcd_wait_busy: lda #RW sta PORTA lda #(RW | E) ; Toggle RW and E bits to read data sta PORTA lda PORTB and #%10000000 bne lcd_wait_busy lda #%11111111 ; Set all pins on port B to output sta DDRB pla rts ;;;;;;;;;;;;;;;;;;;;;;; ;;;; CPU Utilities ;;;; ;;;;;;;;;;;;;;;;;;;;;;; delay: phx phy ldx #255 ldy #40 delay_loop: dex bne delay_loop dey bne delay_loop ply plx rts idle: jmp idle ;;;;;;;;;;;;;;;; ;;;; Offset ;;;; ;;;;;;;;;;;;;;;; *=$fffa ;;;;;;;;;;;;;; ;;;; Data ;;;; ;;;;;;;;;;;;;; !word nmi ; NMI interrupt handler !word main ; Set the program counter to the address of the main label !word irq ; IRQ interrupt handler
.byte MAPOBJ_HELP, MAPOBJ_EMPTY, MAPOBJ_W7PLANT, MAPOBJ_W7PLANT, MAPOBJ_EMPTY, MAPOBJ_EMPTY, MAPOBJ_EMPTY, MAPOBJ_EMPTY, MAPOBJ_EMPTY
<% import collections import pwnlib.abi import pwnlib.constants import pwnlib.shellcraft %> <%docstring>ipc(call, first, second, third, ptr, fifth) -> str Invokes the syscall ipc. See 'man 2 ipc' for more information. Arguments: call(unsigned): call first(int): first second(int): second third(int): third ptr(void*): ptr fifth(long): fifth Returns: int </%docstring> <%page args="call=0, first=0, second=0, third=0, ptr=0, fifth=0"/> <% abi = pwnlib.abi.ABI.syscall() stack = abi.stack regs = abi.register_arguments[1:] allregs = pwnlib.shellcraft.registers.current() can_pushstr = ['ptr'] can_pushstr_array = [] argument_names = ['call', 'first', 'second', 'third', 'ptr', 'fifth'] argument_values = [call, first, second, third, ptr, fifth] # Load all of the arguments into their destination registers / stack slots. register_arguments = dict() stack_arguments = collections.OrderedDict() string_arguments = dict() dict_arguments = dict() array_arguments = dict() syscall_repr = [] for name, arg in zip(argument_names, argument_values): if arg is not None: syscall_repr.append('%s=%r' % (name, arg)) # If the argument itself (input) is a register... if arg in allregs: index = argument_names.index(name) if index < len(regs): target = regs[index] register_arguments[target] = arg elif arg is not None: stack_arguments[index] = arg # The argument is not a register. It is a string value, and we # are expecting a string value elif name in can_pushstr and isinstance(arg, str): string_arguments[name] = arg # The argument is not a register. It is a dictionary, and we are # expecting K:V paris. elif name in can_pushstr_array and isinstance(arg, dict): array_arguments[name] = ['%s=%s' % (k,v) for (k,v) in arg.items()] # The arguent is not a register. It is a list, and we are expecting # a list of arguments. elif name in can_pushstr_array and isinstance(arg, (list, tuple)): array_arguments[name] = arg # The argument is not a register, string, dict, or list. # It could be a constant string ('O_RDONLY') for an integer argument, # an actual integer value, or a constant. else: index = argument_names.index(name) if index < len(regs): target = regs[index] register_arguments[target] = arg elif arg is not None: stack_arguments[target] = arg # Some syscalls have different names on various architectures. # Determine which syscall number to use for the current architecture. for syscall in ['SYS_ipc']: if hasattr(pwnlib.constants, syscall): break else: raise Exception("Could not locate any syscalls: %r" % syscalls) %> /* ipc(${', '.join(syscall_repr)}) */ %for name, arg in string_arguments.items(): ${pwnlib.shellcraft.pushstr(arg, append_null=('\x00' not in arg))} ${pwnlib.shellcraft.mov(regs[argument_names.index(name)], abi.stack)} %endfor %for name, arg in array_arguments.items(): ${pwnlib.shellcraft.pushstr_array(regs[argument_names.index(name)], arg)} %endfor %for name, arg in stack_arguments.items(): ${pwnlib.shellcraft.push(arg)} %endfor ${pwnlib.shellcraft.setregs(register_arguments)} ${pwnlib.shellcraft.syscall(syscall)}
; Small C+ Math Library ; ceil(x) SECTION code_fp PUBLIC ceil EXTERN floor EXTERN odd ; return -(floor(-x)) .ceil CALL odd jp floor
; A134834: Let {b_n(m)} be a sequence defined by b_n(0)=1, b_n(m) = the largest prime dividing (b_n(m-1) +n). Then a(n) is the smallest positive integer such that b_n(m+a(n)) = b_n(m), for all integers m that are greater than some positive integer M. ; 2,3,2,4,3,8,2,3,4,6 mul $0,2 mov $2,$0 lpb $2 lpb $0,8 mul $0,$2 sub $2,3 lpb $0 mov $0,$2 add $3,1 div $0,$3 sub $0,$3 lpe lpe lpe lpb $3 add $2,7 mod $3,4 lpe mov $26,$2 cmp $26,0 add $2,$26 mov $1,$2 add $1,1 mod $1,10 mov $0,$1
section .text global syscall syscall: push ebp mov ebp, esp push ebx push esi push edi mov eax, [ebp + 8] mov ebx, [ebp + 12] mov ecx, [ebp + 16] mov edx, [ebp + 20] mov esi, [ebp + 24] mov edi, [ebp + 28] cmp eax, 2 jne .call_int .call_int: int 0x80 pop edi pop esi pop ebx pop ebp ret
<% from pwnlib.shellcraft.mips.linux import syscall %> <%page args="fd, file, owner, group, flag"/> <%docstring> Invokes the syscall fchownat. See 'man 2 fchownat' for more information. Arguments: fd(int): fd file(char): file owner(uid_t): owner group(gid_t): group flag(int): flag </%docstring> ${syscall('SYS_fchownat', fd, file, owner, group, flag)}
// Copyright (c) 2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin Core developers // Copyright (c) 2014-2017 The Rapid Core developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include "chainparams.h" #include "consensus/merkle.h" #include "tinyformat.h" #include "util.h" #include "utilstrencodings.h" #include <assert.h> #include <boost/assign/list_of.hpp> #include "chainparamsseeds.h" #include "arith_uint256.h" static CBlock CreateGenesisBlock(const char* pszTimestamp, const CScript& genesisOutputScript, uint32_t nTime, uint32_t nNonce, uint32_t nBits, int32_t nVersion, const CAmount& genesisReward) { CMutableTransaction txNew; txNew.nVersion = 1; txNew.vin.resize(1); txNew.vout.resize(1); txNew.vin[0].scriptSig = CScript() << 486604799 << CScriptNum(4) << std::vector<unsigned char>((const unsigned char*)pszTimestamp, (const unsigned char*)pszTimestamp + strlen(pszTimestamp)); txNew.vout[0].nValue = genesisReward; txNew.vout[0].scriptPubKey = genesisOutputScript; CBlock genesis; genesis.nTime = nTime; genesis.nBits = nBits; genesis.nNonce = nNonce; genesis.nVersion = nVersion; genesis.vtx.push_back(txNew); genesis.hashPrevBlock.SetNull(); genesis.hashMerkleRoot = BlockMerkleRoot(genesis); return genesis; } /** * Build the genesis block. Note that the output of its generation * transaction cannot be spent since it did not originally exist in the * database. * * CBlock(hash=00000ffd590b14, ver=1, hashPrevBlock=00000000000000, hashMerkleRoot=e0028e, nTime=1390095618, nBits=1e0ffff0, nNonce=28917698, vtx=1) * CTransaction(hash=e0028e, ver=1, vin.size=1, vout.size=1, nLockTime=0) * CTxIn(COutPoint(000000, -1), coinbase 04ffff001d01044c5957697265642030392f4a616e2f3230313420546865204772616e64204578706572696d656e7420476f6573204c6976653a204f76657273746f636b2e636f6d204973204e6f7720416363657074696e6720426974636f696e73) * CTxOut(nValue=50.00000000, scriptPubKey=0xA9037BAC7050C479B121CF) * vMerkleTree: e0028e */ static CBlock CreateGenesisBlock(uint32_t nTime, uint32_t nNonce, uint32_t nBits, int32_t nVersion, const CAmount& genesisReward) { const char* pszTimestamp = "RapidCoin! 06/06/2018"; const CScript genesisOutputScript = CScript() << ParseHex("042b7b295a54dd7ef2bda1169b50ed4213de33e74d92853f6ac7080603db3fba249958620a856df8a92e9182f1bc77d0947af0476090ec59a3bd028ded903df38f") << OP_CHECKSIG; return CreateGenesisBlock(pszTimestamp, genesisOutputScript, nTime, nNonce, nBits, nVersion, genesisReward); } /** * Main network */ /** * What makes a good checkpoint block? * + Is surrounded by blocks with reasonable timestamps * (no blocks before with a timestamp after, none after with * timestamp before) * + Contains no strange transactions */ class CMainParams : public CChainParams { public: CMainParams() { strNetworkID = "main"; consensus.nSubsidyHalvingInterval = 210240; // Note: actual number of blocks per calendar year with DGW v3 is ~200700 (for example 449750 - 249050) consensus.nMasternodePaymentsStartBlock = 100; // not true, but it's ok as long as it's less then nMasternodePaymentsIncreaseBlock consensus.nMasternodePaymentsIncreaseBlock = 158000; // actual historical value consensus.nMasternodePaymentsIncreasePeriod = 576*30; // 17280 - actual historical value consensus.nInstantSendKeepLock = 24; consensus.nBudgetPaymentsStartBlock = 6000; // actual historical value consensus.nBudgetPaymentsCycleBlocks = 16616; // ~(60*24*30)/2.6, actual number of blocks per month is 200700 / 12 = 16725 consensus.nBudgetPaymentsWindowBlocks = 100; consensus.nBudgetProposalEstablishingTime = 60*60*24; consensus.nSuperblockStartBlock = 6500; // The block at which 12.1 goes live (end of final 12.0 budget cycle) consensus.nSuperblockCycle = 25000; // ~(60*24*30)/2.6, actual number of blocks per month is 200700 / 12 = 16725 consensus.nGovernanceMinQuorum = 10; consensus.nGovernanceFilterElements = 20000; consensus.nMasternodeMinimumConfirmations = 15; consensus.nMajorityEnforceBlockUpgrade = 750; consensus.nMajorityRejectBlockOutdated = 950; consensus.nMajorityWindow = 1000; consensus.BIP34Height = 1; consensus.BIP34Hash = uint256S("0x000007d91d1254d60e2dd1ae580383070a4ddffa4c64c2eeb4a2f9ecc0414343"); consensus.powLimit = uint256S("00000fffff000000000000000000000000000000000000000000000000000000"); consensus.nPowTargetTimespan = 10 * 60; consensus.nPowTargetSpacing = 2.5 * 60; // Rapid: 2.5 minutes consensus.fPowAllowMinDifficultyBlocks = false; consensus.fPowNoRetargeting = false; consensus.nPowKGWHeight = 6200; consensus.nPowDGWHeight = 9000; consensus.nRuleChangeActivationThreshold = 1916; // 95% of 2016 consensus.nMinerConfirmationWindow = 2016; // nPowTargetTimespan / nPowTargetSpacing consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].bit = 28; consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nStartTime = 1199145601; // January 1, 2008 consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nTimeout = 1230767999; // December 31, 2008 // Deployment of BIP68, BIP112, and BIP113. consensus.vDeployments[Consensus::DEPLOYMENT_CSV].bit = 0; consensus.vDeployments[Consensus::DEPLOYMENT_CSV].nStartTime = 9999999999;// 1486252800; // Feb 5th, 2017 consensus.vDeployments[Consensus::DEPLOYMENT_CSV].nTimeout = 1517788800; // Feb 5th, 2018 // Deployment of DIP0001 consensus.vDeployments[Consensus::DEPLOYMENT_DIP0001].bit = 1; consensus.vDeployments[Consensus::DEPLOYMENT_DIP0001].nStartTime = 1600000000;//1508025600; // Oct 15th, 2017 consensus.vDeployments[Consensus::DEPLOYMENT_DIP0001].nTimeout = 1539561600; // Oct 15th, 2018 consensus.vDeployments[Consensus::DEPLOYMENT_DIP0001].nWindowSize = 4032; consensus.vDeployments[Consensus::DEPLOYMENT_DIP0001].nThreshold = 3226; // 80% of 4032 // The best chain should have at least this much work. consensus.nMinimumChainWork = uint256S("0x00"); // By default assume that the signatures in ancestors of this block are valid. consensus.defaultAssumeValid = uint256S("0x00"); /** * The message start string is designed to be unlikely to occur in normal data. * The characters are rarely used upper ASCII, not valid as UTF-8, and produce * a large 32-bit integer with any alignment. */ pchMessageStart[0] = 0x5e; pchMessageStart[1] = 0xc6; pchMessageStart[2] = 0xa6; pchMessageStart[3] = 0x7c; vAlertPubKey = ParseHex("047064403c7a5d212bd824a785e856d9af3b30672e30c75786f6ba2540b8591a105c0e7e7bf06d45e66c2a651bb183b2f0d86356ecfe5aab2157f8d02ffcb94733"); nDefaultPort = 50451; nMaxTipAge = 6 * 60 * 60; // ~144 blocks behind -> 2 x fork detection time, was 24 * 60 * 60 in bitcoin nDelayGetHeadersTime = 24 * 60 * 60; nPruneAfterHeight = 100000; genesis = CreateGenesisBlock(1528193965, 1657955, 0x1e0ffff0, 1, 50 * COIN); consensus.hashGenesisBlock = genesis.GetHash(); assert(consensus.hashGenesisBlock == uint256S("0x000003dc71373b2cb90c9bbd0e4bde5a6cc6013a4214eaea2cc8b71f9c68808d")); assert(genesis.hashMerkleRoot == uint256S("0x66f38c6f43aed9f6d3ad6d833dc8bc3c7bbc2f0d3571559d0158271e48d3f122")); vSeeds.clear(); // Rapid addresses start with 'R' : 60 'X' : 76 base58Prefixes[PUBKEY_ADDRESS] = std::vector<unsigned char>(1,76); // Rapid script addresses start with '7' base58Prefixes[SCRIPT_ADDRESS] = std::vector<unsigned char>(1,16); // Rapid private keys start with '7' or 'X' base58Prefixes[SECRET_KEY] = std::vector<unsigned char>(1,204); // Rapid BIP32 pubkeys start with 'xpub' (Bitcoin defaults) base58Prefixes[EXT_PUBLIC_KEY] = boost::assign::list_of(0x04)(0x88)(0xB2)(0x1E).convert_to_container<std::vector<unsigned char> >(); // Rapid BIP32 prvkeys start with 'xprv' (Bitcoin defaults) base58Prefixes[EXT_SECRET_KEY] = boost::assign::list_of(0x04)(0x88)(0xAD)(0xE4).convert_to_container<std::vector<unsigned char> >(); // Rapid BIP44 coin type is '5' nExtCoinType = 5; vFixedSeeds = std::vector<SeedSpec6>(pnSeed6_main, pnSeed6_main + ARRAYLEN(pnSeed6_main)); fMiningRequiresPeers = true; fDefaultConsistencyChecks = false; fRequireStandard = true; fMineBlocksOnDemand = false; fTestnetToBeDeprecatedFieldRPC = false; nPoolMaxTransactions = 3; nFulfilledRequestExpireTime = 60*60; // fulfilled requests expire in 1 hour strSporkPubKey = "04549ac134f694c0243f503e8c8a9a986f5de6610049c40b07816809b0d1d06a21b07be27b9bb555931773f62ba6cf35a25fd52f694d4e1106ccd237a7bb899fdd"; checkpointData = (CCheckpointData) { boost::assign::map_list_of ( 0, uint256S("0x000003dc71373b2cb90c9bbd0e4bde5a6cc6013a4214eaea2cc8b71f9c68808d")), 1528193965, // * UNIX timestamp of last checkpoint block 0, // * total number of transactions between genesis and last checkpoint // (the tx=... number in the SetBestChain debug.log lines) 5000 // * estimated number of transactions per day after checkpoint }; } }; static CMainParams mainParams; /** * Testnet (v3) */ class CTestNetParams : public CChainParams { public: CTestNetParams() { strNetworkID = "test"; consensus.nSubsidyHalvingInterval = 210240; consensus.nMasternodePaymentsStartBlock = 4010; // not true, but it's ok as long as it's less then nMasternodePaymentsIncreaseBlock consensus.nMasternodePaymentsIncreaseBlock = 4030; consensus.nMasternodePaymentsIncreasePeriod = 10; consensus.nInstantSendKeepLock = 6; consensus.nBudgetPaymentsStartBlock = 4100; consensus.nBudgetPaymentsCycleBlocks = 50; consensus.nBudgetPaymentsWindowBlocks = 10; consensus.nBudgetProposalEstablishingTime = 60*20; consensus.nSuperblockStartBlock = 4200; // NOTE: Should satisfy nSuperblockStartBlock > nBudgetPeymentsStartBlock consensus.nSuperblockCycle = 24; // Superblocks can be issued hourly on testnet consensus.nGovernanceMinQuorum = 1; consensus.nGovernanceFilterElements = 500; consensus.nMasternodeMinimumConfirmations = 1; consensus.nMajorityEnforceBlockUpgrade = 51; consensus.nMajorityRejectBlockOutdated = 75; consensus.nMajorityWindow = 100; consensus.BIP34Height = 1; consensus.BIP34Hash = uint256S("0x0000047d24635e347be3aaaeb66c26be94901a2f962feccd4f95090191f208c1"); consensus.powLimit = uint256S("00000fffff000000000000000000000000000000000000000000000000000000"); consensus.nPowTargetTimespan = 24 * 60 * 60; // Rapid: 1 day consensus.nPowTargetSpacing = 2.5 * 60; // Rapid: 2.5 minutes consensus.fPowAllowMinDifficultyBlocks = true; consensus.fPowNoRetargeting = false; consensus.nPowKGWHeight = 4001; // nPowKGWHeight >= nPowDGWHeight means "no KGW" consensus.nPowDGWHeight = 4001; consensus.nRuleChangeActivationThreshold = 1512; // 75% for testchains consensus.nMinerConfirmationWindow = 2016; // nPowTargetTimespan / nPowTargetSpacing consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].bit = 28; consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nStartTime = 1199145601; // January 1, 2008 consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nTimeout = 1230767999; // December 31, 2008 // Deployment of BIP68, BIP112, and BIP113. consensus.vDeployments[Consensus::DEPLOYMENT_CSV].bit = 0; consensus.vDeployments[Consensus::DEPLOYMENT_CSV].nStartTime = 1506556800; // September 28th, 2017 consensus.vDeployments[Consensus::DEPLOYMENT_CSV].nTimeout = 1538092800; // September 28th, 2018 // Deployment of DIP0001 consensus.vDeployments[Consensus::DEPLOYMENT_DIP0001].bit = 1; consensus.vDeployments[Consensus::DEPLOYMENT_DIP0001].nStartTime = 1505692800; // Sep 18th, 2017 consensus.vDeployments[Consensus::DEPLOYMENT_DIP0001].nTimeout = 1537228800; // Sep 18th, 2018 consensus.vDeployments[Consensus::DEPLOYMENT_DIP0001].nWindowSize = 100; consensus.vDeployments[Consensus::DEPLOYMENT_DIP0001].nThreshold = 50; // 50% of 100 // The best chain should have at least this much work. consensus.nMinimumChainWork = uint256S("0x000000000000000000000000000000000000000000000000000924e924a21715"); // 37900 // By default assume that the signatures in ancestors of this block are valid. consensus.defaultAssumeValid = uint256S("0x0000000004f5aef732d572ff514af99a995702c92e4452c7af10858231668b1f"); // 37900 pchMessageStart[0] = 0xce; pchMessageStart[1] = 0xe2; pchMessageStart[2] = 0xca; pchMessageStart[3] = 0xff; vAlertPubKey = ParseHex("04517d8a699cb43d3938d7b24faaff7cda448ca4ea267723ba614784de661949bf632d6304316b244646dea079735b9a6fc4af804efb4752075b9fe2245e14e412"); nDefaultPort = 19999; nMaxTipAge = 0x7fffffff; // allow mining on top of old blocks for testnet nDelayGetHeadersTime = 24 * 60 * 60; nPruneAfterHeight = 1000; genesis = CreateGenesisBlock(1390666206UL, 3861367235UL, 0x1e0ffff0, 1, 50 * COIN); consensus.hashGenesisBlock = genesis.GetHash(); //assert(consensus.hashGenesisBlock == uint256S("0x")); //assert(genesis.hashMerkleRoot == uint256S("0x06d94c445d3bffb689885df373ca33d5c51ecdb2b352243aa61c06cddecbb97b")); vFixedSeeds.clear(); vSeeds.clear(); //vSeeds.push_back(CDNSSeedData("rapiddot.io", "testnet-seed.rapiddot.io")); //vSeeds.push_back(CDNSSeedData("masternode.io", "test.dnsseed.masternode.io")); // Testnet Rapid addresses start with 'y' base58Prefixes[PUBKEY_ADDRESS] = std::vector<unsigned char>(1,140); // Testnet Rapid script addresses start with '8' or '9' base58Prefixes[SCRIPT_ADDRESS] = std::vector<unsigned char>(1,19); // Testnet private keys start with '9' or 'c' (Bitcoin defaults) base58Prefixes[SECRET_KEY] = std::vector<unsigned char>(1,239); // Testnet Rapid BIP32 pubkeys start with 'tpub' (Bitcoin defaults) base58Prefixes[EXT_PUBLIC_KEY] = boost::assign::list_of(0x04)(0x35)(0x87)(0xCF).convert_to_container<std::vector<unsigned char> >(); // Testnet Rapid BIP32 prvkeys start with 'tprv' (Bitcoin defaults) base58Prefixes[EXT_SECRET_KEY] = boost::assign::list_of(0x04)(0x35)(0x83)(0x94).convert_to_container<std::vector<unsigned char> >(); // Testnet Rapid BIP44 coin type is '1' (All coin's testnet default) nExtCoinType = 1; vFixedSeeds = std::vector<SeedSpec6>(pnSeed6_test, pnSeed6_test + ARRAYLEN(pnSeed6_test)); fMiningRequiresPeers = true; fDefaultConsistencyChecks = false; fRequireStandard = false; fMineBlocksOnDemand = false; fTestnetToBeDeprecatedFieldRPC = true; nPoolMaxTransactions = 3; nFulfilledRequestExpireTime = 5*60; // fulfilled requests expire in 5 minutes strSporkPubKey = "046f78dcf911fbd61910136f7f0f8d90578f68d0b3ac973b5040fb7afb501b5939f39b108b0569dca71488f5bbf498d92e4d1194f6f941307ffd95f75e76869f0e"; checkpointData = (CCheckpointData) { boost::assign::map_list_of ( 0, uint256S("0x")), 1462856598, // * UNIX timestamp of last checkpoint block 3094, // * total number of transactions between genesis and last checkpoint // (the tx=... number in the SetBestChain debug.log lines) 500 // * estimated number of transactions per day after checkpoint }; } }; static CTestNetParams testNetParams; /** * Regression test */ class CRegTestParams : public CChainParams { public: CRegTestParams() { strNetworkID = "regtest"; consensus.nSubsidyHalvingInterval = 150; consensus.nMasternodePaymentsStartBlock = 240; consensus.nMasternodePaymentsIncreaseBlock = 350; consensus.nMasternodePaymentsIncreasePeriod = 10; consensus.nInstantSendKeepLock = 6; consensus.nBudgetPaymentsStartBlock = 1000; consensus.nBudgetPaymentsCycleBlocks = 50; consensus.nBudgetPaymentsWindowBlocks = 10; consensus.nBudgetProposalEstablishingTime = 60*20; consensus.nSuperblockStartBlock = 1500; consensus.nSuperblockCycle = 10; consensus.nGovernanceMinQuorum = 1; consensus.nGovernanceFilterElements = 100; consensus.nMasternodeMinimumConfirmations = 1; consensus.nMajorityEnforceBlockUpgrade = 750; consensus.nMajorityRejectBlockOutdated = 950; consensus.nMajorityWindow = 1000; consensus.BIP34Height = -1; // BIP34 has not necessarily activated on regtest consensus.BIP34Hash = uint256(); consensus.powLimit = uint256S("7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"); consensus.nPowTargetTimespan = 24 * 60 * 60; // Rapid: 1 day consensus.nPowTargetSpacing = 2.5 * 60; // Rapid: 2.5 minutes consensus.fPowAllowMinDifficultyBlocks = true; consensus.fPowNoRetargeting = true; consensus.nPowKGWHeight = 15200; // same as mainnet consensus.nPowDGWHeight = 34140; // same as mainnet consensus.nRuleChangeActivationThreshold = 108; // 75% for testchains consensus.nMinerConfirmationWindow = 144; // Faster than normal for regtest (144 instead of 2016) consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].bit = 28; consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nStartTime = 0; consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nTimeout = 999999999999ULL; consensus.vDeployments[Consensus::DEPLOYMENT_CSV].bit = 0; consensus.vDeployments[Consensus::DEPLOYMENT_CSV].nStartTime = 0; consensus.vDeployments[Consensus::DEPLOYMENT_CSV].nTimeout = 999999999999ULL; consensus.vDeployments[Consensus::DEPLOYMENT_DIP0001].bit = 1; consensus.vDeployments[Consensus::DEPLOYMENT_DIP0001].nStartTime = 0; consensus.vDeployments[Consensus::DEPLOYMENT_DIP0001].nTimeout = 999999999999ULL; // The best chain should have at least this much work. consensus.nMinimumChainWork = uint256S("0x00"); // By default assume that the signatures in ancestors of this block are valid. consensus.defaultAssumeValid = uint256S("0x00"); pchMessageStart[0] = 0xfc; pchMessageStart[1] = 0xc1; pchMessageStart[2] = 0xb7; pchMessageStart[3] = 0xdc; nMaxTipAge = 6 * 60 * 60; // ~144 blocks behind -> 2 x fork detection time, was 24 * 60 * 60 in bitcoin nDelayGetHeadersTime = 0; // never delay GETHEADERS in regtests nDefaultPort = 19994; nPruneAfterHeight = 1000; genesis = CreateGenesisBlock(1417713337, 1096447, 0x207fffff, 1, 50 * COIN); consensus.hashGenesisBlock = genesis.GetHash(); //assert(consensus.hashGenesisBlock == uint256S("0x")); //assert(genesis.hashMerkleRoot == uint256S("0x")); vFixedSeeds.clear(); //! Regtest mode doesn't have any fixed seeds. vSeeds.clear(); //! Regtest mode doesn't have any DNS seeds. fMiningRequiresPeers = false; fDefaultConsistencyChecks = true; fRequireStandard = false; fMineBlocksOnDemand = true; fTestnetToBeDeprecatedFieldRPC = false; nFulfilledRequestExpireTime = 5*60; // fulfilled requests expire in 5 minutes checkpointData = (CCheckpointData){ boost::assign::map_list_of ( 0, uint256S("0x000008ca1832a4baf228eb1553c03d3a2c8e02399550dd6ea8d65cec3ef23d2e")), 0, 0, 0 }; // Regtest Rapid addresses start with 'y' base58Prefixes[PUBKEY_ADDRESS] = std::vector<unsigned char>(1,140); // Regtest Rapid script addresses start with '8' or '9' base58Prefixes[SCRIPT_ADDRESS] = std::vector<unsigned char>(1,19); // Regtest private keys start with '9' or 'c' (Bitcoin defaults) base58Prefixes[SECRET_KEY] = std::vector<unsigned char>(1,239); // Regtest Rapid BIP32 pubkeys start with 'tpub' (Bitcoin defaults) base58Prefixes[EXT_PUBLIC_KEY] = boost::assign::list_of(0x04)(0x35)(0x87)(0xCF).convert_to_container<std::vector<unsigned char> >(); // Regtest Rapid BIP32 prvkeys start with 'tprv' (Bitcoin defaults) base58Prefixes[EXT_SECRET_KEY] = boost::assign::list_of(0x04)(0x35)(0x83)(0x94).convert_to_container<std::vector<unsigned char> >(); // Regtest Rapid BIP44 coin type is '1' (All coin's testnet default) nExtCoinType = 1; } }; static CRegTestParams regTestParams; static CChainParams *pCurrentParams = 0; const CChainParams &Params() { assert(pCurrentParams); return *pCurrentParams; } CChainParams& Params(const std::string& chain) { if (chain == CBaseChainParams::MAIN) return mainParams; else if (chain == CBaseChainParams::TESTNET) return testNetParams; else if (chain == CBaseChainParams::REGTEST) return regTestParams; else throw std::runtime_error(strprintf("%s: Unknown chain %s.", __func__, chain)); } void SelectParams(const std::string& network) { SelectBaseParams(network); pCurrentParams = &Params(network); }
; A182409: Prime-generating polynomial: 4n^2 + 12n - 1583. ; -1583,-1567,-1543,-1511,-1471,-1423,-1367,-1303,-1231,-1151,-1063,-967,-863,-751,-631,-503,-367,-223,-71,89,257,433,617,809,1009,1217,1433,1657,1889,2129,2377,2633,2897,3169,3449,3737,4033,4337,4649,4969,5297,5633,5977,6329,6689,7057,7433,7817,8209,8609,9017,9433,9857,10289,10729,11177,11633,12097,12569,13049,13537,14033,14537,15049,15569,16097,16633,17177,17729,18289,18857,19433,20017,20609,21209,21817,22433,23057,23689,24329,24977,25633,26297,26969,27649,28337,29033,29737,30449,31169,31897,32633,33377,34129,34889,35657,36433,37217,38009,38809 add $0,2 bin $0,2 sub $0,210 mul $0,8 add $0,89
/** * @file * @copyright This code is licensed under the 3-clause BSD license.\n * Copyright ETH Zurich, Laboratory for Physical Chemistry, Reiher Group.\n * See LICENSE.txt for details. */ #include "Repulsion.h" #include "PairwiseRepulsion.h" #include <Utils/Geometry/ElementInfo.h> #include <Utils/Math/AutomaticDifferentiation/MethodsHelpers.h> #include <Utils/Typenames.h> namespace Scine { namespace Sparrow { using namespace Utils::AutomaticDifferentiation; namespace dftb { Repulsion::Repulsion(const Utils::ElementTypeCollection& elements, const Utils::PositionCollection& positions, const DFTBCommon::DiatomicParameterContainer& diatomicParameters) : RepulsionCalculator(elements, positions), nAtoms_(0), diatomicParameters_(diatomicParameters) { } Repulsion::~Repulsion() = default; void Repulsion::initialize() { nAtoms_ = elements_.size(); // Create 2D-vector of empty unique_ptr's pairRepulsions_ = Container(nAtoms_); for (int i = 0; i < nAtoms_; ++i) pairRepulsions_[i] = std::vector<PairRepulsion>(nAtoms_); for (int i = 0; i < nAtoms_; i++) { for (int j = i + 1; j < nAtoms_; j++) { initializePair(i, j); } } } void Repulsion::initializePair(int i, int j) { Utils::ElementType e1 = elements_[i]; Utils::ElementType e2 = elements_[j]; SKPair* parameters = diatomicParameters_[Utils::ElementInfo::Z(e1)][Utils::ElementInfo::Z(e2)].get(); pairRepulsions_[i][j] = std::make_unique<dftb::PairwiseRepulsion>(parameters->getRepulsionParameters()); } void Repulsion::calculateRepulsion(Utils::derivOrder order) { for (int i = 0; i < nAtoms_; i++) { for (int j = i + 1; j < nAtoms_; j++) { calculatePairRepulsion(i, j, order); } } } void Repulsion::calculatePairRepulsion(int i, int j, Utils::derivOrder order) { const auto& pA = positions_.row(i); const auto& pB = positions_.row(j); Eigen::Vector3d Rab = pB - pA; pairRepulsions_[i][j]->calculate(Rab, order); } double Repulsion::getRepulsionEnergy() const { double repulsion = 0; #pragma omp parallel for reduction(+ : repulsion) for (int a = 0; a < nAtoms_; ++a) { for (int b = a + 1; b < nAtoms_; ++b) { auto p = pairRepulsions_[a][b]->getRepulsionEnergy(); repulsion += p; } } return repulsion; } void Repulsion::addRepulsionDerivatives( Utils::AutomaticDifferentiation::DerivativeContainerType<Utils::derivativeType::first>& derivatives) const { addRepulsionDerivativesImpl<Utils::derivativeType::first>(derivatives); } void Repulsion::addRepulsionDerivatives( Utils::AutomaticDifferentiation::DerivativeContainerType<Utils::derivativeType::second_atomic>& derivatives) const { addRepulsionDerivativesImpl<Utils::derivativeType::second_atomic>(derivatives); } void Repulsion::addRepulsionDerivatives( Utils::AutomaticDifferentiation::DerivativeContainerType<Utils::derivativeType::second_full>& derivatives) const { addRepulsionDerivativesImpl<Utils::derivativeType::second_full>(derivatives); } template<Utils::derivativeType O> void Repulsion::addRepulsionDerivativesImpl(Utils::AutomaticDifferentiation::DerivativeContainerType<O>& derivatives) const { #pragma omp parallel for for (int a = 0; a < nAtoms_; ++a) { for (int b = a + 1; b < nAtoms_; b++) { auto dRep = pairRepulsions_[a][b]->getDerivative<O>(); #pragma omp critical { addDerivativeToContainer<O>(derivatives, a, b, dRep); } } } } } // namespace dftb } // namespace Sparrow } // namespace Scine
//===--- SerializeSIL.cpp - Read and write SIL ----------------------------===// // // This source file is part of the Swift.org open source project // // Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information // See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors // //===----------------------------------------------------------------------===// #define DEBUG_TYPE "sil-serialize" #include "SILFormat.h" #include "Serialization.h" #include "swift/Strings.h" #include "swift/AST/Module.h" #include "swift/AST/ProtocolConformance.h" #include "swift/SIL/CFG.h" #include "swift/SIL/SILArgument.h" #include "swift/SIL/SILModule.h" #include "swift/SIL/SILUndef.h" #include "swift/SILOptimizer/Utils/Generics.h" #include "llvm/ADT/MapVector.h" #include "llvm/ADT/PostOrderIterator.h" #include "llvm/ADT/SmallString.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringExtras.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/Debug.h" #include "llvm/Support/EndianStream.h" #include "llvm/Support/OnDiskHashTable.h" #include <type_traits> using namespace swift; using namespace swift::serialization; using namespace swift::serialization::sil_block; using namespace llvm::support; using llvm::BCBlockRAII; static unsigned toStableStringEncoding(StringLiteralInst::Encoding encoding) { switch (encoding) { case StringLiteralInst::Encoding::UTF8: return SIL_UTF8; case StringLiteralInst::Encoding::UTF16: return SIL_UTF16; case StringLiteralInst::Encoding::ObjCSelector: return SIL_OBJC_SELECTOR; } llvm_unreachable("bad string encoding"); } static unsigned toStableConstStringEncoding(ConstStringLiteralInst::Encoding encoding) { switch (encoding) { case ConstStringLiteralInst::Encoding::UTF8: return SIL_UTF8; case ConstStringLiteralInst::Encoding::UTF16: return SIL_UTF16; } llvm_unreachable("bad string encoding"); } static unsigned toStableSILLinkage(SILLinkage linkage) { switch (linkage) { case SILLinkage::Public: return SIL_LINKAGE_PUBLIC; case SILLinkage::Hidden: return SIL_LINKAGE_HIDDEN; case SILLinkage::Shared: return SIL_LINKAGE_SHARED; case SILLinkage::Private: return SIL_LINKAGE_PRIVATE; case SILLinkage::PublicExternal: return SIL_LINKAGE_PUBLIC_EXTERNAL; case SILLinkage::HiddenExternal: return SIL_LINKAGE_HIDDEN_EXTERNAL; case SILLinkage::SharedExternal: return SIL_LINKAGE_SHARED_EXTERNAL; case SILLinkage::PrivateExternal: return SIL_LINKAGE_PRIVATE_EXTERNAL; } llvm_unreachable("bad linkage"); } static unsigned toStableVTableEntryKind(SILVTable::Entry::Kind kind) { switch (kind) { case SILVTable::Entry::Kind::Normal: return SIL_VTABLE_ENTRY_NORMAL; case SILVTable::Entry::Kind::Inherited: return SIL_VTABLE_ENTRY_INHERITED; case SILVTable::Entry::Kind::Override: return SIL_VTABLE_ENTRY_OVERRIDE; } llvm_unreachable("bad vtable entry kind"); } static unsigned toStableCastConsumptionKind(CastConsumptionKind kind) { switch (kind) { case CastConsumptionKind::TakeAlways: return SIL_CAST_CONSUMPTION_TAKE_ALWAYS; case CastConsumptionKind::TakeOnSuccess: return SIL_CAST_CONSUMPTION_TAKE_ON_SUCCESS; case CastConsumptionKind::CopyOnSuccess: return SIL_CAST_CONSUMPTION_COPY_ON_SUCCESS; } llvm_unreachable("bad cast consumption kind"); } namespace { /// Used to serialize the on-disk func hash table. class FuncTableInfo { public: using key_type = Identifier; using key_type_ref = key_type; using data_type = DeclID; using data_type_ref = const data_type &; using hash_value_type = uint32_t; using offset_type = unsigned; hash_value_type ComputeHash(key_type_ref key) { assert(!key.empty()); return llvm::HashString(key.str()); } std::pair<unsigned, unsigned> EmitKeyDataLength(raw_ostream &out, key_type_ref key, data_type_ref data) { uint32_t keyLength = key.str().size(); uint32_t dataLength = sizeof(uint32_t); endian::Writer<little> writer(out); writer.write<uint16_t>(keyLength); writer.write<uint16_t>(dataLength); return { keyLength, dataLength }; } void EmitKey(raw_ostream &out, key_type_ref key, unsigned len) { out << key.str(); } void EmitData(raw_ostream &out, key_type_ref key, data_type_ref data, unsigned len) { endian::Writer<little>(out).write<uint32_t>(data); } }; class SILSerializer { Serializer &S; ASTContext &Ctx; llvm::BitstreamWriter &Out; /// A reusable buffer for emitting records. SmallVector<uint64_t, 64> ScratchRecord; /// In case we want to encode the relative of InstID vs ValueID. uint32_t /*ValueID*/ InstID = 0; llvm::DenseMap<const ValueBase*, ValueID> ValueIDs; ValueID addValueRef(const ValueBase *Val); public: using TableData = FuncTableInfo::data_type; using Table = llvm::MapVector<FuncTableInfo::key_type, TableData>; private: /// FuncTable maps function name to an ID. Table FuncTable; std::vector<BitOffset> Funcs; /// The current function ID. uint32_t /*DeclID*/ NextFuncID = 1; /// Maps class name to a VTable ID. Table VTableList; /// Holds the list of VTables. std::vector<BitOffset> VTableOffset; uint32_t /*DeclID*/ NextVTableID = 1; /// Maps global variable name to an ID. Table GlobalVarList; /// Holds the list of SIL global variables. std::vector<BitOffset> GlobalVarOffset; uint32_t /*DeclID*/ NextGlobalVarID = 1; /// Maps witness table identifier to an ID. Table WitnessTableList; /// Holds the list of WitnessTables. std::vector<BitOffset> WitnessTableOffset; uint32_t /*DeclID*/ NextWitnessTableID = 1; /// Maps default witness table identifier to an ID. Table DefaultWitnessTableList; /// Holds the list of DefaultWitnessTables. std::vector<BitOffset> DefaultWitnessTableOffset; uint32_t /*DeclID*/ NextDefaultWitnessTableID = 1; /// Give each SILBasicBlock a unique ID. llvm::DenseMap<const SILBasicBlock *, unsigned> BasicBlockMap; /// Functions that we've emitted a reference to. If the key maps /// to true, we want to emit a declaration only. llvm::DenseMap<const SILFunction *, bool> FuncsToEmit; /// Additional functions we might need to serialize. llvm::SmallVector<const SILFunction *, 16> Worklist; std::array<unsigned, 256> SILAbbrCodes; template <typename Layout> void registerSILAbbr() { using AbbrArrayTy = decltype(SILAbbrCodes); static_assert(Layout::Code <= std::tuple_size<AbbrArrayTy>::value, "layout has invalid record code"); SILAbbrCodes[Layout::Code] = Layout::emitAbbrev(Out); DEBUG(llvm::dbgs() << "SIL abbre code " << SILAbbrCodes[Layout::Code] << " for layout " << Layout::Code << "\n"); } bool ShouldSerializeAll; void addMandatorySILFunction(const SILFunction *F, bool emitDeclarationsForOnoneSupport); void addReferencedSILFunction(const SILFunction *F, bool DeclOnly = false); void processSILFunctionWorklist(); /// Helper function to update ListOfValues for MethodInst. Format: /// Attr, SILDeclRef (DeclID, Kind, uncurryLevel, IsObjC), and an operand. void handleMethodInst(const MethodInst *MI, SILValue operand, SmallVectorImpl<ValueID> &ListOfValues); void writeSILFunction(const SILFunction &F, bool DeclOnly = false); void writeSILBasicBlock(const SILBasicBlock &BB); void writeSILInstruction(const SILInstruction &SI); void writeSILVTable(const SILVTable &vt); void writeSILGlobalVar(const SILGlobalVariable &g); void writeSILWitnessTable(const SILWitnessTable &wt); void writeSILDefaultWitnessTable(const SILDefaultWitnessTable &wt); void writeSILBlock(const SILModule *SILMod); void writeIndexTables(); void writeConversionLikeInstruction(const SILInstruction *I); void writeOneTypeLayout(ValueKind valueKind, SILType type); void writeOneTypeOneOperandLayout(ValueKind valueKind, unsigned attrs, SILType type, SILValue operand); void writeOneTypeOneOperandLayout(ValueKind valueKind, unsigned attrs, CanType type, SILValue operand); void writeOneOperandLayout(ValueKind valueKind, unsigned attrs, SILValue operand); /// Helper function to determine if given the current state of the /// deserialization if the function body for F should be deserialized. bool shouldEmitFunctionBody(const SILFunction *F, bool isReference = true); IdentifierID addSILFunctionRef(SILFunction *F); public: SILSerializer(Serializer &S, ASTContext &Ctx, llvm::BitstreamWriter &Out, bool serializeAll) : S(S), Ctx(Ctx), Out(Out), ShouldSerializeAll(serializeAll) {} void writeSILModule(const SILModule *SILMod); }; } // end anonymous namespace void SILSerializer::addMandatorySILFunction(const SILFunction *F, bool emitDeclarationsForOnoneSupport) { // If this function is not fragile, don't do anything. if (!shouldEmitFunctionBody(F, /* isReference */ false)) return; auto iter = FuncsToEmit.find(F); if (iter != FuncsToEmit.end()) { // We've already visited this function. Make sure that we decided // to emit its body the first time around. assert(iter->second == emitDeclarationsForOnoneSupport && "Already emitting declaration"); return; } // We haven't seen this function before. Record that we want to // emit its body, and add it to the worklist. FuncsToEmit[F] = emitDeclarationsForOnoneSupport; if (!emitDeclarationsForOnoneSupport) Worklist.push_back(F); } void SILSerializer::addReferencedSILFunction(const SILFunction *F, bool DeclOnly) { assert(F != nullptr); if (FuncsToEmit.count(F) > 0) return; // We haven't seen this function before. Let's see if we should // serialize the body or just the declaration. if (shouldEmitFunctionBody(F)) { FuncsToEmit[F] = false; Worklist.push_back(F); return; } if (F->getLinkage() == SILLinkage::Shared && !DeclOnly) { assert(F->isSerialized() == IsSerializable || F->hasForeignBody()); FuncsToEmit[F] = false; Worklist.push_back(F); return; } // Ok, we just need to emit a declaration. FuncsToEmit[F] = true; } void SILSerializer::processSILFunctionWorklist() { while (Worklist.size() > 0) { const SILFunction *F = Worklist.back(); Worklist.pop_back(); assert(F != nullptr); assert(FuncsToEmit.count(F) > 0); writeSILFunction(*F, FuncsToEmit[F]); } } /// We enumerate all values in a SILFunction beforehand to correctly /// handle forward references of values. ValueID SILSerializer::addValueRef(const ValueBase *Val) { if (!Val || isa<SILUndef>(Val)) return 0; ValueID id = ValueIDs[Val]; assert(id != 0 && "We should have assigned a value ID to each value."); return id; } void SILSerializer::writeSILFunction(const SILFunction &F, bool DeclOnly) { ValueIDs.clear(); InstID = 0; FuncTable[Ctx.getIdentifier(F.getName())] = NextFuncID++; Funcs.push_back(Out.GetCurrentBitNo()); unsigned abbrCode = SILAbbrCodes[SILFunctionLayout::Code]; TypeID FnID = S.addTypeRef(F.getLoweredType().getSwiftRValueType()); DEBUG(llvm::dbgs() << "SILFunction " << F.getName() << " @ BitNo " << Out.GetCurrentBitNo() << " abbrCode " << abbrCode << " FnID " << FnID << "\n"); DEBUG(llvm::dbgs() << "Serialized SIL:\n"; F.dump()); SmallVector<IdentifierID, 1> SemanticsIDs; for (auto SemanticAttr : F.getSemanticsAttrs()) { SemanticsIDs.push_back(S.addDeclBaseNameRef(Ctx.getIdentifier(SemanticAttr))); } SILLinkage Linkage = F.getLinkage(); // We serialize shared_external linkage as shared since: // // 1. shared_external linkage is just a hack to tell the optimizer that a // shared function was deserialized. // // 2. We cannot just serialize a declaration to a shared_external function // since shared_external functions still have linkonce_odr linkage at the LLVM // level. This means they must be defined not just declared. // // TODO: When serialization is reworked, this should be removed. if (hasSharedVisibility(Linkage)) Linkage = SILLinkage::Shared; // Check if we need to emit a body for this function. bool NoBody = DeclOnly || isAvailableExternally(Linkage) || F.isExternalDeclaration(); // If we don't emit a function body then make sure to mark the declaration // as available externally. if (NoBody) { Linkage = addExternalToLinkage(Linkage); } // If we have a body, we might have a generic environment. GenericEnvironmentID genericEnvID = 0; if (!NoBody) genericEnvID = S.addGenericEnvironmentRef(F.getGenericEnvironment()); DeclID clangNodeOwnerID; if (F.hasClangNode()) clangNodeOwnerID = S.addDeclRef(F.getClangNodeOwner()); unsigned numSpecAttrs = NoBody ? 0 : F.getSpecializeAttrs().size(); SILFunctionLayout::emitRecord( Out, ScratchRecord, abbrCode, toStableSILLinkage(Linkage), (unsigned)F.isTransparent(), (unsigned)F.isSerialized(), (unsigned)F.isThunk(), (unsigned)F.isGlobalInit(), (unsigned)F.getInlineStrategy(), (unsigned)F.getEffectsKind(), (unsigned)numSpecAttrs, (unsigned)F.hasQualifiedOwnership(), FnID, genericEnvID, clangNodeOwnerID, SemanticsIDs); if (NoBody) return; for (auto *SA : F.getSpecializeAttrs()) { unsigned specAttrAbbrCode = SILAbbrCodes[SILSpecializeAttrLayout::Code]; SILSpecializeAttrLayout::emitRecord(Out, ScratchRecord, specAttrAbbrCode, (unsigned)SA->isExported(), (unsigned)SA->getSpecializationKind()); S.writeGenericRequirements(SA->getRequirements(), SILAbbrCodes); } // Assign a unique ID to each basic block of the SILFunction. unsigned BasicID = 0; BasicBlockMap.clear(); // Assign a value ID to each SILInstruction that has value and to each basic // block argument. unsigned ValueID = 0; llvm::ReversePostOrderTraversal<SILFunction *> RPOT( const_cast<SILFunction *>(&F)); for (auto Iter = RPOT.begin(), E = RPOT.end(); Iter != E; ++Iter) { auto &BB = **Iter; BasicBlockMap.insert(std::make_pair(&BB, BasicID++)); for (auto I = BB.args_begin(), E = BB.args_end(); I != E; ++I) ValueIDs[static_cast<const ValueBase*>(*I)] = ++ValueID; for (const SILInstruction &SI : BB) if (SI.hasValue()) ValueIDs[&SI] = ++ValueID; } // Write SIL basic blocks in the RPOT order // to make sure that instructions defining open archetypes // are serialized before instructions using those opened // archetypes. unsigned SerializedBBNum = 0; for (auto Iter = RPOT.begin(), E = RPOT.end(); Iter != E; ++Iter) { auto *BB = *Iter; writeSILBasicBlock(*BB); SerializedBBNum++; } assert(BasicID == SerializedBBNum && "Wrong number of BBs was serialized"); } void SILSerializer::writeSILBasicBlock(const SILBasicBlock &BB) { SmallVector<DeclID, 4> Args; for (auto I = BB.args_begin(), E = BB.args_end(); I != E; ++I) { SILArgument *SA = *I; DeclID tId = S.addTypeRef(SA->getType().getSwiftRValueType()); DeclID vId = addValueRef(static_cast<const ValueBase*>(SA)); Args.push_back(tId); // We put these static asserts here to formalize our assumption that both // SILValueCategory and ValueOwnershipKind have uint8_t as their underlying // pointer values. static_assert( std::is_same< std::underlying_type<decltype(SA->getType().getCategory())>::type, uint8_t>::value, "Expected an underlying uint8_t type"); // We put these static asserts here to formalize our assumption that both // SILValueCategory and ValueOwnershipKind have uint8_t as their underlying // pointer values. static_assert(std::is_same<std::underlying_type<decltype( SA->getOwnershipKind())::innerty>::type, uint8_t>::value, "Expected an underlying uint8_t type"); unsigned packedMetadata = 0; packedMetadata |= unsigned(SA->getType().getCategory()); packedMetadata |= unsigned(SA->getOwnershipKind()) << 8; Args.push_back(packedMetadata); Args.push_back(vId); } unsigned abbrCode = SILAbbrCodes[SILBasicBlockLayout::Code]; SILBasicBlockLayout::emitRecord(Out, ScratchRecord, abbrCode, Args); for (const SILInstruction &SI : BB) writeSILInstruction(SI); } /// Add SILDeclRef to ListOfValues, so we can reconstruct it at /// deserialization. static void handleSILDeclRef(Serializer &S, const SILDeclRef &Ref, SmallVectorImpl<ValueID> &ListOfValues) { ListOfValues.push_back(S.addDeclRef(Ref.getDecl())); ListOfValues.push_back((unsigned)Ref.kind); ListOfValues.push_back((unsigned)Ref.getResilienceExpansion()); ListOfValues.push_back(Ref.getUncurryLevel()); ListOfValues.push_back(Ref.isForeign); } /// Get an identifier ref for a SILFunction and add it to the list of referenced /// functions. IdentifierID SILSerializer::addSILFunctionRef(SILFunction *F) { addReferencedSILFunction(F); return S.addDeclBaseNameRef(Ctx.getIdentifier(F->getName())); } /// Helper function to update ListOfValues for MethodInst. Format: /// Attr, SILDeclRef (DeclID, Kind, uncurryLevel, IsObjC), and an operand. void SILSerializer::handleMethodInst(const MethodInst *MI, SILValue operand, SmallVectorImpl<ValueID> &ListOfValues) { ListOfValues.push_back(MI->isVolatile()); handleSILDeclRef(S, MI->getMember(), ListOfValues); ListOfValues.push_back( S.addTypeRef(operand->getType().getSwiftRValueType())); ListOfValues.push_back((unsigned)operand->getType().getCategory()); ListOfValues.push_back(addValueRef(operand)); } void SILSerializer::writeOneTypeLayout(ValueKind valueKind, SILType type) { unsigned abbrCode = SILAbbrCodes[SILOneTypeLayout::Code]; SILOneTypeLayout::emitRecord(Out, ScratchRecord, abbrCode, (unsigned) valueKind, S.addTypeRef(type.getSwiftRValueType()), (unsigned)type.getCategory()); } void SILSerializer::writeOneOperandLayout(ValueKind valueKind, unsigned attrs, SILValue operand) { auto operandType = operand->getType(); auto operandTypeRef = S.addTypeRef(operandType.getSwiftRValueType()); auto operandRef = addValueRef(operand); SILOneOperandLayout::emitRecord(Out, ScratchRecord, SILAbbrCodes[SILOneOperandLayout::Code], unsigned(valueKind), attrs, operandTypeRef, unsigned(operandType.getCategory()), operandRef); } void SILSerializer::writeOneTypeOneOperandLayout(ValueKind valueKind, unsigned attrs, SILType type, SILValue operand) { auto typeRef = S.addTypeRef(type.getSwiftRValueType()); auto operandType = operand->getType(); auto operandTypeRef = S.addTypeRef(operandType.getSwiftRValueType()); auto operandRef = addValueRef(operand); SILOneTypeOneOperandLayout::emitRecord(Out, ScratchRecord, SILAbbrCodes[SILOneTypeOneOperandLayout::Code], unsigned(valueKind), attrs, typeRef, unsigned(type.getCategory()), operandTypeRef, unsigned(operandType.getCategory()), operandRef); } void SILSerializer::writeOneTypeOneOperandLayout(ValueKind valueKind, unsigned attrs, CanType type, SILValue operand) { auto typeRef = S.addTypeRef(type); auto operandType = operand->getType(); auto operandTypeRef = S.addTypeRef(operandType.getSwiftRValueType()); auto operandRef = addValueRef(operand); SILOneTypeOneOperandLayout::emitRecord(Out, ScratchRecord, SILAbbrCodes[SILOneTypeOneOperandLayout::Code], unsigned(valueKind), attrs, typeRef, 0, operandTypeRef, unsigned(operandType.getCategory()), operandRef); } /// Write an instruction that looks exactly like a conversion: all /// important information is encoded in the operand and the result type. void SILSerializer::writeConversionLikeInstruction(const SILInstruction *I) { assert(I->getNumOperands() - I->getTypeDependentOperands().size() == 1); writeOneTypeOneOperandLayout(I->getKind(), 0, I->getType(), I->getOperand(0)); } void SILSerializer::writeSILInstruction(const SILInstruction &SI) { switch (SI.getKind()) { case ValueKind::SILPHIArgument: case ValueKind::SILFunctionArgument: case ValueKind::SILUndef: llvm_unreachable("not an instruction"); case ValueKind::DebugValueInst: case ValueKind::DebugValueAddrInst: // Currently we don't serialize debug variable infos, so it doesn't make // sense to write the instruction at all. // TODO: decide if we want to serialize those instructions. return; case ValueKind::UnreachableInst: { unsigned abbrCode = SILAbbrCodes[SILInstNoOperandLayout::Code]; SILInstNoOperandLayout::emitRecord(Out, ScratchRecord, abbrCode, (unsigned)SI.getKind()); break; } case ValueKind::AllocExistentialBoxInst: case ValueKind::InitExistentialAddrInst: case ValueKind::InitExistentialValueInst: case ValueKind::InitExistentialMetatypeInst: case ValueKind::InitExistentialRefInst: { SILValue operand; SILType Ty; CanType FormalConcreteType; ArrayRef<ProtocolConformanceRef> conformances; switch (SI.getKind()) { default: llvm_unreachable("out of sync with parent"); case ValueKind::InitExistentialAddrInst: { auto &IEI = cast<InitExistentialAddrInst>(SI); operand = IEI.getOperand(); Ty = IEI.getLoweredConcreteType(); FormalConcreteType = IEI.getFormalConcreteType(); conformances = IEI.getConformances(); break; } case ValueKind::InitExistentialValueInst: { auto &IEOI = cast<InitExistentialValueInst>(SI); operand = IEOI.getOperand(); Ty = IEOI.getType(); FormalConcreteType = IEOI.getFormalConcreteType(); conformances = IEOI.getConformances(); break; } case ValueKind::InitExistentialRefInst: { auto &IERI = cast<InitExistentialRefInst>(SI); operand = IERI.getOperand(); Ty = IERI.getType(); FormalConcreteType = IERI.getFormalConcreteType(); conformances = IERI.getConformances(); break; } case ValueKind::InitExistentialMetatypeInst: { auto &IEMI = cast<InitExistentialMetatypeInst>(SI); operand = IEMI.getOperand(); Ty = IEMI.getType(); conformances = IEMI.getConformances(); break; } case ValueKind::AllocExistentialBoxInst: { auto &AEBI = cast<AllocExistentialBoxInst>(SI); Ty = AEBI.getExistentialType(); FormalConcreteType = AEBI.getFormalConcreteType(); conformances = AEBI.getConformances(); break; } } TypeID operandType = 0; SILValueCategory operandCategory = SILValueCategory::Object; ValueID operandID = 0; if (operand) { operandType = S.addTypeRef(operand->getType().getSwiftRValueType()); operandCategory = operand->getType().getCategory(); operandID = addValueRef(operand); } unsigned abbrCode = SILAbbrCodes[SILInitExistentialLayout::Code]; SILInitExistentialLayout::emitRecord(Out, ScratchRecord, abbrCode, (unsigned)SI.getKind(), S.addTypeRef(Ty.getSwiftRValueType()), (unsigned)Ty.getCategory(), operandType, (unsigned)operandCategory, operandID, S.addTypeRef(FormalConcreteType), conformances.size()); for (auto conformance : conformances) { S.writeConformance(conformance, SILAbbrCodes); } break; } case ValueKind::DeallocValueBufferInst: { auto DVBI = cast<DeallocValueBufferInst>(&SI); writeOneTypeOneOperandLayout(DVBI->getKind(), 0, DVBI->getValueType(), DVBI->getOperand()); break; } case ValueKind::DeallocBoxInst: { auto DBI = cast<DeallocBoxInst>(&SI); writeOneTypeOneOperandLayout(DBI->getKind(), 0, DBI->getOperand()->getType(), DBI->getOperand()); break; } case ValueKind::DeallocExistentialBoxInst: { auto DBI = cast<DeallocExistentialBoxInst>(&SI); writeOneTypeOneOperandLayout(DBI->getKind(), 0, DBI->getConcreteType(), DBI->getOperand()); break; } case ValueKind::ValueMetatypeInst: { auto VMI = cast<ValueMetatypeInst>(&SI); writeOneTypeOneOperandLayout(VMI->getKind(), 0, VMI->getType(), VMI->getOperand()); break; } case ValueKind::ExistentialMetatypeInst: { auto EMI = cast<ExistentialMetatypeInst>(&SI); writeOneTypeOneOperandLayout(EMI->getKind(), 0, EMI->getType(), EMI->getOperand()); break; } case ValueKind::AllocValueBufferInst: { auto AVBI = cast<AllocValueBufferInst>(&SI); writeOneTypeOneOperandLayout(AVBI->getKind(), 0, AVBI->getValueType(), AVBI->getOperand()); break; } case ValueKind::AllocBoxInst: { const AllocBoxInst *ABI = cast<AllocBoxInst>(&SI); writeOneTypeLayout(ABI->getKind(), ABI->getType()); break; } case ValueKind::AllocRefInst: case ValueKind::AllocRefDynamicInst: { const AllocRefInstBase *ARI = cast<AllocRefInstBase>(&SI); unsigned abbrCode = SILAbbrCodes[SILOneTypeValuesLayout::Code]; SmallVector<ValueID, 4> Args; Args.push_back((unsigned)ARI->isObjC() | ((unsigned)ARI->canAllocOnStack() << 1)); ArrayRef<SILType> TailTypes = ARI->getTailAllocatedTypes(); ArrayRef<Operand> AllOps = ARI->getAllOperands(); unsigned NumTailAllocs = TailTypes.size(); unsigned NumOpsToWrite = NumTailAllocs; if (SI.getKind() == ValueKind::AllocRefDynamicInst) ++NumOpsToWrite; for (unsigned Idx = 0; Idx < NumOpsToWrite; ++Idx) { if (Idx < NumTailAllocs) { assert(TailTypes[Idx].isObject()); Args.push_back(S.addTypeRef(TailTypes[Idx].getSwiftRValueType())); } SILValue OpVal = AllOps[Idx].get(); Args.push_back(addValueRef(OpVal)); SILType OpType = OpVal->getType(); assert(OpType.isObject()); Args.push_back(S.addTypeRef(OpType.getSwiftRValueType())); } SILOneTypeValuesLayout::emitRecord(Out, ScratchRecord, abbrCode, (unsigned)SI.getKind(), S.addTypeRef( ARI->getType().getSwiftRValueType()), (unsigned)ARI->getType().getCategory(), Args); break; } case ValueKind::AllocStackInst: { const AllocStackInst *ASI = cast<AllocStackInst>(&SI); writeOneTypeLayout(ASI->getKind(), ASI->getElementType()); break; } case ValueKind::ProjectValueBufferInst: { auto PVBI = cast<ProjectValueBufferInst>(&SI); writeOneTypeOneOperandLayout(PVBI->getKind(), 0, PVBI->getType(), PVBI->getOperand()); break; } case ValueKind::ProjectBoxInst: { auto PBI = cast<ProjectBoxInst>(&SI); // Use SILOneTypeOneOperandLayout with the field index crammed in the TypeID auto boxOperand = PBI->getOperand(); auto boxRef = addValueRef(boxOperand); auto boxType = boxOperand->getType(); auto boxTypeRef = S.addTypeRef(boxType.getSwiftRValueType()); SILOneTypeOneOperandLayout::emitRecord(Out, ScratchRecord, SILAbbrCodes[SILOneTypeOneOperandLayout::Code], unsigned(PBI->getKind()), 0, PBI->getFieldIndex(), 0, boxTypeRef, unsigned(boxType.getCategory()), boxRef); break; } case ValueKind::ProjectExistentialBoxInst: { auto PEBI = cast<ProjectExistentialBoxInst>(&SI); writeOneTypeOneOperandLayout(PEBI->getKind(), 0, PEBI->getType(), PEBI->getOperand()); break; } case ValueKind::BuiltinInst: { // Format: number of substitutions, the builtin name, result type, and // a list of values for the arguments. Each value in the list // is represented with 4 IDs: // ValueID, ValueResultNumber, TypeID, TypeCategory. // The record is followed by the substitution list. const BuiltinInst *BI = cast<BuiltinInst>(&SI); SmallVector<ValueID, 4> Args; for (auto Arg : BI->getArguments()) { Args.push_back(addValueRef(Arg)); Args.push_back(S.addTypeRef(Arg->getType().getSwiftRValueType())); Args.push_back((unsigned)Arg->getType().getCategory()); } SILInstApplyLayout::emitRecord(Out, ScratchRecord, SILAbbrCodes[SILInstApplyLayout::Code], SIL_BUILTIN, BI->getSubstitutions().size(), S.addTypeRef(BI->getType().getSwiftRValueType()), (unsigned)BI->getType().getCategory(), S.addDeclBaseNameRef(BI->getName()), Args); S.writeSubstitutions(BI->getSubstitutions(), SILAbbrCodes); break; } case ValueKind::ApplyInst: { // Format: attributes such as transparent and number of substitutions, // the callee's substituted and unsubstituted types, a value for // the callee and a list of values for the arguments. Each value in the list // is represented with 2 IDs: ValueID and ValueResultNumber. The record // is followed by the substitution list. const ApplyInst *AI = cast<ApplyInst>(&SI); SmallVector<ValueID, 4> Args; for (auto Arg: AI->getArguments()) { Args.push_back(addValueRef(Arg)); } SILInstApplyLayout::emitRecord(Out, ScratchRecord, SILAbbrCodes[SILInstApplyLayout::Code], AI->isNonThrowing() ? SIL_NON_THROWING_APPLY : SIL_APPLY, AI->getSubstitutions().size(), S.addTypeRef(AI->getCallee()->getType().getSwiftRValueType()), S.addTypeRef(AI->getSubstCalleeType()), addValueRef(AI->getCallee()), Args); S.writeSubstitutions(AI->getSubstitutions(), SILAbbrCodes); break; } case ValueKind::TryApplyInst: { // Format: attributes such as transparent and number of substitutions, // the callee's substituted and unsubstituted types, a value for // the callee and a list of values for the arguments. Each value in the list // is represented with 2 IDs: ValueID and ValueResultNumber. The final two // entries in the list are the basic block destinations. The record // is followed by the substitution list. const TryApplyInst *AI = cast<TryApplyInst>(&SI); SmallVector<ValueID, 4> Args; for (auto Arg: AI->getArguments()) { Args.push_back(addValueRef(Arg)); } Args.push_back(BasicBlockMap[AI->getNormalBB()]); Args.push_back(BasicBlockMap[AI->getErrorBB()]); SILInstApplyLayout::emitRecord(Out, ScratchRecord, SILAbbrCodes[SILInstApplyLayout::Code], SIL_TRY_APPLY, AI->getSubstitutions().size(), S.addTypeRef(AI->getCallee()->getType().getSwiftRValueType()), S.addTypeRef(AI->getSubstCalleeType()), addValueRef(AI->getCallee()), Args); S.writeSubstitutions(AI->getSubstitutions(), SILAbbrCodes); break; } case ValueKind::PartialApplyInst: { const PartialApplyInst *PAI = cast<PartialApplyInst>(&SI); SmallVector<ValueID, 4> Args; for (auto Arg: PAI->getArguments()) { Args.push_back(addValueRef(Arg)); } SILInstApplyLayout::emitRecord(Out, ScratchRecord, SILAbbrCodes[SILInstApplyLayout::Code], SIL_PARTIAL_APPLY, PAI->getSubstitutions().size(), S.addTypeRef(PAI->getCallee()->getType().getSwiftRValueType()), S.addTypeRef(PAI->getType().getSwiftRValueType()), addValueRef(PAI->getCallee()), Args); S.writeSubstitutions(PAI->getSubstitutions(), SILAbbrCodes); break; } case ValueKind::AllocGlobalInst: { // Format: Name and type. Use SILOneOperandLayout. const AllocGlobalInst *AGI = cast<AllocGlobalInst>(&SI); SILOneOperandLayout::emitRecord(Out, ScratchRecord, SILAbbrCodes[SILOneOperandLayout::Code], (unsigned)SI.getKind(), 0, 0, 0, S.addDeclBaseNameRef( Ctx.getIdentifier(AGI->getReferencedGlobal()->getName()))); break; } case ValueKind::GlobalAddrInst: { // Format: Name and type. Use SILOneOperandLayout. const GlobalAddrInst *GAI = cast<GlobalAddrInst>(&SI); SILOneOperandLayout::emitRecord(Out, ScratchRecord, SILAbbrCodes[SILOneOperandLayout::Code], (unsigned)SI.getKind(), 0, S.addTypeRef(GAI->getType().getSwiftRValueType()), (unsigned)GAI->getType().getCategory(), S.addDeclBaseNameRef( Ctx.getIdentifier(GAI->getReferencedGlobal()->getName()))); break; } case ValueKind::BranchInst: { // Format: destination basic block ID, a list of arguments. Use // SILOneTypeValuesLayout. const BranchInst *BrI = cast<BranchInst>(&SI); SmallVector<ValueID, 4> ListOfValues; for (auto Elt : BrI->getArgs()) { ListOfValues.push_back(S.addTypeRef(Elt->getType().getSwiftRValueType())); ListOfValues.push_back((unsigned)Elt->getType().getCategory()); ListOfValues.push_back(addValueRef(Elt)); } SILOneTypeValuesLayout::emitRecord(Out, ScratchRecord, SILAbbrCodes[SILOneTypeValuesLayout::Code], (unsigned)SI.getKind(), BasicBlockMap[BrI->getDestBB()], 0, ListOfValues); break; } case ValueKind::CondBranchInst: { // Format: condition, true basic block ID, a list of arguments, false basic // block ID, a list of arguments. Use SILOneTypeValuesLayout: the type is // for condition, the list has value for condition, true basic block ID, // false basic block ID, number of true arguments, and a list of true|false // arguments. const CondBranchInst *CBI = cast<CondBranchInst>(&SI); SmallVector<ValueID, 4> ListOfValues; ListOfValues.push_back(addValueRef(CBI->getCondition())); ListOfValues.push_back(BasicBlockMap[CBI->getTrueBB()]); ListOfValues.push_back(BasicBlockMap[CBI->getFalseBB()]); ListOfValues.push_back(CBI->getTrueArgs().size()); for (auto Elt : CBI->getTrueArgs()) { ListOfValues.push_back(S.addTypeRef(Elt->getType().getSwiftRValueType())); ListOfValues.push_back((unsigned)Elt->getType().getCategory()); ListOfValues.push_back(addValueRef(Elt)); } for (auto Elt : CBI->getFalseArgs()) { ListOfValues.push_back(S.addTypeRef(Elt->getType().getSwiftRValueType())); ListOfValues.push_back((unsigned)Elt->getType().getCategory()); ListOfValues.push_back(addValueRef(Elt)); } SILOneTypeValuesLayout::emitRecord(Out, ScratchRecord, SILAbbrCodes[SILOneTypeValuesLayout::Code], (unsigned)SI.getKind(), S.addTypeRef(CBI->getCondition()->getType().getSwiftRValueType()), (unsigned)CBI->getCondition()->getType().getCategory(), ListOfValues); break; } case ValueKind::SwitchEnumInst: case ValueKind::SwitchEnumAddrInst: { // Format: condition, a list of cases (EnumElementDecl + Basic Block ID), // default basic block ID. Use SILOneTypeValuesLayout: the type is // for condition, the list has value for condition, hasDefault, default // basic block ID, a list of (DeclID, BasicBlock ID). const SwitchEnumInstBase *SOI = cast<SwitchEnumInstBase>(&SI); SmallVector<ValueID, 4> ListOfValues; ListOfValues.push_back(addValueRef(SOI->getOperand())); ListOfValues.push_back((unsigned)SOI->hasDefault()); if (SOI->hasDefault()) ListOfValues.push_back(BasicBlockMap[SOI->getDefaultBB()]); else ListOfValues.push_back(0); for (unsigned i = 0, e = SOI->getNumCases(); i < e; ++i) { EnumElementDecl *elt; SILBasicBlock *dest; std::tie(elt, dest) = SOI->getCase(i); ListOfValues.push_back(S.addDeclRef(elt)); ListOfValues.push_back(BasicBlockMap[dest]); } SILOneTypeValuesLayout::emitRecord(Out, ScratchRecord, SILAbbrCodes[SILOneTypeValuesLayout::Code], (unsigned)SI.getKind(), S.addTypeRef(SOI->getOperand()->getType().getSwiftRValueType()), (unsigned)SOI->getOperand()->getType().getCategory(), ListOfValues); break; } case ValueKind::SelectEnumInst: case ValueKind::SelectEnumAddrInst: { // Format: condition, a list of cases (EnumElementDecl + Value ID), // default value ID. Use SILOneTypeValuesLayout: the type is // for condition, the list has value for condition, result type, // hasDefault, default // basic block ID, a list of (DeclID, BasicBlock ID). const SelectEnumInstBase *SOI = cast<SelectEnumInstBase>(&SI); SmallVector<ValueID, 4> ListOfValues; ListOfValues.push_back(addValueRef(SOI->getEnumOperand())); ListOfValues.push_back(S.addTypeRef(SOI->getType().getSwiftRValueType())); ListOfValues.push_back((unsigned)SOI->getType().getCategory()); ListOfValues.push_back((unsigned)SOI->hasDefault()); if (SOI->hasDefault()) { ListOfValues.push_back(addValueRef(SOI->getDefaultResult())); } else { ListOfValues.push_back(0); } for (unsigned i = 0, e = SOI->getNumCases(); i < e; ++i) { EnumElementDecl *elt; SILValue result; std::tie(elt, result) = SOI->getCase(i); ListOfValues.push_back(S.addDeclRef(elt)); ListOfValues.push_back(addValueRef(result)); } SILOneTypeValuesLayout::emitRecord(Out, ScratchRecord, SILAbbrCodes[SILOneTypeValuesLayout::Code], (unsigned)SI.getKind(), S.addTypeRef(SOI->getEnumOperand()->getType().getSwiftRValueType()), (unsigned)SOI->getEnumOperand()->getType().getCategory(), ListOfValues); break; } case ValueKind::SwitchValueInst: { // Format: condition, a list of cases (Value ID + Basic Block ID), // default basic block ID. Use SILOneTypeValuesLayout: the type is // for condition, the list contains value for condition, hasDefault, default // basic block ID, a list of (Value ID, BasicBlock ID). const SwitchValueInst *SII = cast<SwitchValueInst>(&SI); SmallVector<ValueID, 4> ListOfValues; ListOfValues.push_back(addValueRef(SII->getOperand())); ListOfValues.push_back((unsigned)SII->hasDefault()); if (SII->hasDefault()) ListOfValues.push_back(BasicBlockMap[SII->getDefaultBB()]); else ListOfValues.push_back(0); for (unsigned i = 0, e = SII->getNumCases(); i < e; ++i) { SILValue value; SILBasicBlock *dest; std::tie(value, dest) = SII->getCase(i); ListOfValues.push_back(addValueRef(value)); ListOfValues.push_back(BasicBlockMap[dest]); } SILOneTypeValuesLayout::emitRecord(Out, ScratchRecord, SILAbbrCodes[SILOneTypeValuesLayout::Code], (unsigned)SI.getKind(), S.addTypeRef(SII->getOperand()->getType().getSwiftRValueType()), (unsigned)SII->getOperand()->getType().getCategory(), ListOfValues); break; } case ValueKind::SelectValueInst: { // Format: condition, a list of cases (Value ID + Value ID), // default value ID. Use SILOneTypeValuesLayout: the type is // for condition, the list has value for condition, result type, // hasDefault, default // basic block ID, a list of (Value ID, Value ID). const SelectValueInst *SVI = cast<SelectValueInst>(&SI); SmallVector<ValueID, 4> ListOfValues; ListOfValues.push_back(addValueRef(SVI->getOperand())); ListOfValues.push_back(S.addTypeRef(SVI->getType().getSwiftRValueType())); ListOfValues.push_back((unsigned)SVI->getType().getCategory()); ListOfValues.push_back((unsigned)SVI->hasDefault()); if (SVI->hasDefault()) { ListOfValues.push_back(addValueRef(SVI->getDefaultResult())); } else { ListOfValues.push_back(0); } for (unsigned i = 0, e = SVI->getNumCases(); i < e; ++i) { SILValue casevalue; SILValue result; std::tie(casevalue, result) = SVI->getCase(i); ListOfValues.push_back(addValueRef(casevalue)); ListOfValues.push_back(addValueRef(result)); } SILOneTypeValuesLayout::emitRecord(Out, ScratchRecord, SILAbbrCodes[SILOneTypeValuesLayout::Code], (unsigned)SI.getKind(), S.addTypeRef(SVI->getOperand()->getType().getSwiftRValueType()), (unsigned)SVI->getOperand()->getType().getCategory(), ListOfValues); break; } case ValueKind::CondFailInst: case ValueKind::RetainValueInst: case ValueKind::RetainValueAddrInst: case ValueKind::UnmanagedRetainValueInst: case ValueKind::EndBorrowArgumentInst: case ValueKind::CopyValueInst: case ValueKind::CopyUnownedValueInst: case ValueKind::DestroyValueInst: case ValueKind::ReleaseValueInst: case ValueKind::ReleaseValueAddrInst: case ValueKind::UnmanagedReleaseValueInst: case ValueKind::AutoreleaseValueInst: case ValueKind::UnmanagedAutoreleaseValueInst: case ValueKind::SetDeallocatingInst: case ValueKind::DeallocStackInst: case ValueKind::DeallocRefInst: case ValueKind::DeinitExistentialAddrInst: case ValueKind::DeinitExistentialValueInst: case ValueKind::DestroyAddrInst: case ValueKind::IsNonnullInst: case ValueKind::LoadInst: case ValueKind::LoadBorrowInst: case ValueKind::BeginBorrowInst: case ValueKind::LoadUnownedInst: case ValueKind::LoadWeakInst: case ValueKind::MarkUninitializedInst: case ValueKind::FixLifetimeInst: case ValueKind::EndLifetimeInst: case ValueKind::CopyBlockInst: case ValueKind::StrongPinInst: case ValueKind::StrongReleaseInst: case ValueKind::StrongRetainInst: case ValueKind::StrongUnpinInst: case ValueKind::StrongRetainUnownedInst: case ValueKind::UnownedRetainInst: case ValueKind::UnownedReleaseInst: case ValueKind::IsUniqueInst: case ValueKind::IsUniqueOrPinnedInst: case ValueKind::ReturnInst: case ValueKind::UncheckedOwnershipConversionInst: case ValueKind::ThrowInst: { unsigned Attr = 0; if (auto *LI = dyn_cast<LoadInst>(&SI)) Attr = unsigned(LI->getOwnershipQualifier()); else if (auto *LWI = dyn_cast<LoadWeakInst>(&SI)) Attr = LWI->isTake(); else if (auto *LUI = dyn_cast<LoadUnownedInst>(&SI)) Attr = LUI->isTake(); else if (auto *MUI = dyn_cast<MarkUninitializedInst>(&SI)) Attr = (unsigned)MUI->getKind(); else if (auto *DRI = dyn_cast<DeallocRefInst>(&SI)) Attr = (unsigned)DRI->canAllocOnStack(); else if (auto *RCI = dyn_cast<RefCountingInst>(&SI)) Attr = RCI->isNonAtomic(); else if (auto *UOCI = dyn_cast<UncheckedOwnershipConversionInst>(&SI)) { Attr = unsigned(SILValue(UOCI).getOwnershipKind()); } writeOneOperandLayout(SI.getKind(), Attr, SI.getOperand(0)); break; } case ValueKind::FunctionRefInst: { // Use SILOneOperandLayout to specify the function type and the function // name (IdentifierID). const FunctionRefInst *FRI = cast<FunctionRefInst>(&SI); SILFunction *ReferencedFunction = FRI->getReferencedFunction(); unsigned abbrCode = SILAbbrCodes[SILOneOperandLayout::Code]; SILOneOperandLayout::emitRecord(Out, ScratchRecord, abbrCode, (unsigned)SI.getKind(), 0, S.addTypeRef(FRI->getType().getSwiftRValueType()), (unsigned)FRI->getType().getCategory(), addSILFunctionRef(ReferencedFunction)); break; } case ValueKind::DeallocPartialRefInst: case ValueKind::MarkDependenceInst: case ValueKind::IndexAddrInst: case ValueKind::IndexRawPointerInst: { SILValue operand, operand2; unsigned Attr = 0; if (SI.getKind() == ValueKind::DeallocPartialRefInst) { const DeallocPartialRefInst *DPRI = cast<DeallocPartialRefInst>(&SI); operand = DPRI->getInstance(); operand2 = DPRI->getMetatype(); } else if (SI.getKind() == ValueKind::IndexRawPointerInst) { const IndexRawPointerInst *IRP = cast<IndexRawPointerInst>(&SI); operand = IRP->getBase(); operand2 = IRP->getIndex(); } else if (SI.getKind() == ValueKind::MarkDependenceInst) { const MarkDependenceInst *MDI = cast<MarkDependenceInst>(&SI); operand = MDI->getValue(); operand2 = MDI->getBase(); } else { const IndexAddrInst *IAI = cast<IndexAddrInst>(&SI); operand = IAI->getBase(); operand2 = IAI->getIndex(); } SILTwoOperandsLayout::emitRecord(Out, ScratchRecord, SILAbbrCodes[SILTwoOperandsLayout::Code], (unsigned)SI.getKind(), Attr, S.addTypeRef(operand->getType().getSwiftRValueType()), (unsigned)operand->getType().getCategory(), addValueRef(operand), S.addTypeRef(operand2->getType().getSwiftRValueType()), (unsigned)operand2->getType().getCategory(), addValueRef(operand2)); break; } case ValueKind::TailAddrInst: { const TailAddrInst *TAI = cast<TailAddrInst>(&SI); SILTailAddrLayout::emitRecord(Out, ScratchRecord, SILAbbrCodes[SILTailAddrLayout::Code], (unsigned)SI.getKind(), S.addTypeRef(TAI->getBase()->getType().getSwiftRValueType()), addValueRef(TAI->getBase()), S.addTypeRef(TAI->getIndex()->getType().getSwiftRValueType()), addValueRef(TAI->getIndex()), S.addTypeRef(TAI->getTailType().getSwiftRValueType())); break; } case ValueKind::StringLiteralInst: { auto SLI = cast<StringLiteralInst>(&SI); StringRef Str = SLI->getValue(); unsigned abbrCode = SILAbbrCodes[SILOneOperandLayout::Code]; unsigned encoding = toStableStringEncoding(SLI->getEncoding()); SILOneOperandLayout::emitRecord(Out, ScratchRecord, abbrCode, (unsigned)SI.getKind(), encoding, 0, 0, S.addDeclBaseNameRef(Ctx.getIdentifier(Str))); break; } case ValueKind::ConstStringLiteralInst: { auto SLI = cast<ConstStringLiteralInst>(&SI); StringRef Str = SLI->getValue(); unsigned abbrCode = SILAbbrCodes[SILOneOperandLayout::Code]; unsigned encoding = toStableConstStringEncoding(SLI->getEncoding()); SILOneOperandLayout::emitRecord(Out, ScratchRecord, abbrCode, (unsigned)SI.getKind(), encoding, 0, 0, S.addDeclBaseNameRef(Ctx.getIdentifier(Str))); break; } case ValueKind::FloatLiteralInst: case ValueKind::IntegerLiteralInst: { // Use SILOneOperandLayout to specify the type and the literal. std::string Str; SILType Ty; switch (SI.getKind()) { default: llvm_unreachable("Out of sync with parent switch"); case ValueKind::IntegerLiteralInst: Str = cast<IntegerLiteralInst>(&SI)->getValue().toString(10, true); Ty = cast<IntegerLiteralInst>(&SI)->getType(); break; case ValueKind::FloatLiteralInst: Str = cast<FloatLiteralInst>(&SI)->getBits().toString(16, /*Signed*/false); Ty = cast<FloatLiteralInst>(&SI)->getType(); break; } unsigned abbrCode = SILAbbrCodes[SILOneOperandLayout::Code]; SILOneOperandLayout::emitRecord(Out, ScratchRecord, abbrCode, (unsigned)SI.getKind(), 0, S.addTypeRef(Ty.getSwiftRValueType()), (unsigned)Ty.getCategory(), S.addDeclBaseNameRef(Ctx.getIdentifier(Str))); break; } case ValueKind::MarkFunctionEscapeInst: { // Format: a list of typed values. A typed value is expressed by 4 IDs: // TypeID, TypeCategory, ValueID, ValueResultNumber. const MarkFunctionEscapeInst *MFE = cast<MarkFunctionEscapeInst>(&SI); SmallVector<ValueID, 4> ListOfValues; for (auto Elt : MFE->getElements()) { ListOfValues.push_back(S.addTypeRef(Elt->getType().getSwiftRValueType())); ListOfValues.push_back((unsigned)Elt->getType().getCategory()); ListOfValues.push_back(addValueRef(Elt)); } SILOneTypeValuesLayout::emitRecord(Out, ScratchRecord, SILAbbrCodes[SILOneTypeValuesLayout::Code], (unsigned)SI.getKind(), 0, 0, ListOfValues); break; } case ValueKind::MetatypeInst: writeOneTypeLayout(SI.getKind(), SI.getType()); break; case ValueKind::ObjCProtocolInst: { const ObjCProtocolInst *PI = cast<ObjCProtocolInst>(&SI); unsigned abbrCode = SILAbbrCodes[SILOneOperandLayout::Code]; SILOneOperandLayout::emitRecord(Out, ScratchRecord, abbrCode, (unsigned)SI.getKind(), 0, S.addTypeRef(PI->getType().getSwiftRValueType()), (unsigned)PI->getType().getCategory(), S.addDeclRef(PI->getProtocol())); break; } case ValueKind::OpenExistentialAddrInst: { assert(SI.getNumOperands() - SI.getTypeDependentOperands().size() == 1); unsigned attrs = cast<OpenExistentialAddrInst>(SI).getAccessKind() == OpenedExistentialAccess::Immutable ? 0 : 1; writeOneTypeOneOperandLayout(SI.getKind(), attrs, SI.getType(), SI.getOperand(0)); break; } // Conversion instructions (and others of similar form). case ValueKind::OpenExistentialRefInst: case ValueKind::OpenExistentialMetatypeInst: case ValueKind::OpenExistentialBoxInst: case ValueKind::OpenExistentialValueInst: case ValueKind::OpenExistentialBoxValueInst: case ValueKind::UncheckedRefCastInst: case ValueKind::UncheckedAddrCastInst: case ValueKind::UncheckedTrivialBitCastInst: case ValueKind::UncheckedBitwiseCastInst: case ValueKind::BridgeObjectToRefInst: case ValueKind::BridgeObjectToWordInst: case ValueKind::UpcastInst: case ValueKind::AddressToPointerInst: case ValueKind::RefToRawPointerInst: case ValueKind::RawPointerToRefInst: case ValueKind::RefToUnownedInst: case ValueKind::UnownedToRefInst: case ValueKind::RefToUnmanagedInst: case ValueKind::UnmanagedToRefInst: case ValueKind::ThinToThickFunctionInst: case ValueKind::ThickToObjCMetatypeInst: case ValueKind::ObjCToThickMetatypeInst: case ValueKind::ConvertFunctionInst: case ValueKind::ThinFunctionToPointerInst: case ValueKind::PointerToThinFunctionInst: case ValueKind::ObjCMetatypeToObjectInst: case ValueKind::ObjCExistentialMetatypeToObjectInst: case ValueKind::ProjectBlockStorageInst: { writeConversionLikeInstruction(&SI); break; } case ValueKind::PointerToAddressInst: { assert(SI.getNumOperands() - SI.getTypeDependentOperands().size() == 1); auto &PAI = cast<PointerToAddressInst>(SI); unsigned attrs = (PAI.isStrict() ? 1 : 0) | (PAI.isInvariant() ? 2 : 0); writeOneTypeOneOperandLayout(SI.getKind(), attrs, SI.getType(), SI.getOperand(0)); break; } case ValueKind::RefToBridgeObjectInst: { auto RI = cast<RefToBridgeObjectInst>(&SI); SILTwoOperandsLayout::emitRecord(Out, ScratchRecord, SILAbbrCodes[SILTwoOperandsLayout::Code], (unsigned)SI.getKind(), /*attr*/ 0, S.addTypeRef(RI->getConverted()->getType().getSwiftRValueType()), (unsigned)RI->getConverted()->getType().getCategory(), addValueRef(RI->getConverted()), S.addTypeRef(RI->getBitsOperand()->getType().getSwiftRValueType()), (unsigned)RI->getBitsOperand()->getType().getCategory(), addValueRef(RI->getBitsOperand())); break; } // Checked Conversion instructions. case ValueKind::UnconditionalCheckedCastInst: { auto CI = cast<UnconditionalCheckedCastInst>(&SI); SILInstCastLayout::emitRecord(Out, ScratchRecord, SILAbbrCodes[SILInstCastLayout::Code], (unsigned)SI.getKind(), /*attr*/ 0, S.addTypeRef(CI->getType().getSwiftRValueType()), (unsigned)CI->getType().getCategory(), S.addTypeRef(CI->getOperand()->getType().getSwiftRValueType()), (unsigned)CI->getOperand()->getType().getCategory(), addValueRef(CI->getOperand())); break; } case ValueKind::UnconditionalCheckedCastAddrInst: { auto CI = cast<UnconditionalCheckedCastAddrInst>(&SI); ValueID listOfValues[] = { toStableCastConsumptionKind(CI->getConsumptionKind()), S.addTypeRef(CI->getSourceType()), addValueRef(CI->getSrc()), S.addTypeRef(CI->getSrc()->getType().getSwiftRValueType()), (unsigned)CI->getSrc()->getType().getCategory(), S.addTypeRef(CI->getTargetType()), addValueRef(CI->getDest()) }; SILOneTypeValuesLayout::emitRecord(Out, ScratchRecord, SILAbbrCodes[SILOneTypeValuesLayout::Code], (unsigned)SI.getKind(), S.addTypeRef(CI->getDest()->getType().getSwiftRValueType()), (unsigned)CI->getDest()->getType().getCategory(), llvm::makeArrayRef(listOfValues)); break; } case ValueKind::UnconditionalCheckedCastValueInst: { auto CI = cast<UnconditionalCheckedCastValueInst>(&SI); SILInstCastLayout::emitRecord( Out, ScratchRecord, SILAbbrCodes[SILInstCastLayout::Code], (unsigned)SI.getKind(), toStableCastConsumptionKind(CI->getConsumptionKind()), S.addTypeRef(CI->getType().getSwiftRValueType()), (unsigned)CI->getType().getCategory(), S.addTypeRef(CI->getOperand()->getType().getSwiftRValueType()), (unsigned)CI->getOperand()->getType().getCategory(), addValueRef(CI->getOperand())); break; } case ValueKind::UncheckedRefCastAddrInst: { auto CI = cast<UncheckedRefCastAddrInst>(&SI); ValueID listOfValues[] = { S.addTypeRef(CI->getSourceType()), addValueRef(CI->getSrc()), S.addTypeRef(CI->getSrc()->getType().getSwiftRValueType()), (unsigned)CI->getSrc()->getType().getCategory(), S.addTypeRef(CI->getTargetType()), addValueRef(CI->getDest()) }; SILOneTypeValuesLayout::emitRecord(Out, ScratchRecord, SILAbbrCodes[SILOneTypeValuesLayout::Code], (unsigned)SI.getKind(), S.addTypeRef(CI->getDest()->getType().getSwiftRValueType()), (unsigned)CI->getDest()->getType().getCategory(), llvm::makeArrayRef(listOfValues)); break; } case ValueKind::EndBorrowInst: { unsigned abbrCode = SILAbbrCodes[SILTwoOperandsLayout::Code]; unsigned Attr = 0; auto *EBI = cast<EndBorrowInst>(&SI); SILValue BorrowedValue = EBI->getBorrowedValue(); SILValue OriginalValue = EBI->getOriginalValue(); SILTwoOperandsLayout::emitRecord( Out, ScratchRecord, abbrCode, (unsigned)SI.getKind(), Attr, S.addTypeRef(BorrowedValue->getType().getSwiftRValueType()), (unsigned)BorrowedValue->getType().getCategory(), addValueRef(BorrowedValue), S.addTypeRef(OriginalValue->getType().getSwiftRValueType()), (unsigned)OriginalValue->getType().getCategory(), addValueRef(OriginalValue)); break; } case ValueKind::BeginAccessInst: { unsigned abbrCode = SILAbbrCodes[SILOneOperandLayout::Code]; auto *BAI = cast<BeginAccessInst>(&SI); unsigned attr = unsigned(BAI->getAccessKind()) + (unsigned(BAI->getEnforcement()) << 2); SILValue operand = BAI->getOperand(); SILOneOperandLayout::emitRecord( Out, ScratchRecord, abbrCode, (unsigned)SI.getKind(), attr, S.addTypeRef(operand->getType().getSwiftRValueType()), (unsigned)operand->getType().getCategory(), addValueRef(operand)); break; } case ValueKind::EndAccessInst: { unsigned abbrCode = SILAbbrCodes[SILOneOperandLayout::Code]; auto *EAI = cast<EndAccessInst>(&SI); unsigned attr = unsigned(EAI->isAborting()); SILValue operand = EAI->getOperand(); SILOneOperandLayout::emitRecord( Out, ScratchRecord, abbrCode, (unsigned)SI.getKind(), attr, S.addTypeRef(operand->getType().getSwiftRValueType()), (unsigned)operand->getType().getCategory(), addValueRef(operand)); break; } case ValueKind::BeginUnpairedAccessInst: { unsigned abbrCode = SILAbbrCodes[SILTwoOperandsLayout::Code]; auto *BAI = cast<BeginUnpairedAccessInst>(&SI); unsigned attr = unsigned(BAI->getAccessKind()) + (unsigned(BAI->getEnforcement()) << 2); SILValue source = BAI->getSource(); SILValue buffer = BAI->getBuffer(); SILTwoOperandsLayout::emitRecord( Out, ScratchRecord, abbrCode, (unsigned)SI.getKind(), attr, S.addTypeRef(source->getType().getSwiftRValueType()), (unsigned)source->getType().getCategory(), addValueRef(source), S.addTypeRef(buffer->getType().getSwiftRValueType()), (unsigned)buffer->getType().getCategory(), addValueRef(buffer)); break; } case ValueKind::EndUnpairedAccessInst: { unsigned abbrCode = SILAbbrCodes[SILOneOperandLayout::Code]; auto *EAI = cast<EndUnpairedAccessInst>(&SI); unsigned attr = unsigned(EAI->isAborting()) + (unsigned(EAI->getEnforcement()) << 1); SILValue operand = EAI->getOperand(); SILOneOperandLayout::emitRecord( Out, ScratchRecord, abbrCode, (unsigned)SI.getKind(), attr, S.addTypeRef(operand->getType().getSwiftRValueType()), (unsigned)operand->getType().getCategory(), addValueRef(operand)); break; } case ValueKind::AssignInst: case ValueKind::CopyAddrInst: case ValueKind::StoreInst: case ValueKind::StoreBorrowInst: case ValueKind::StoreUnownedInst: case ValueKind::StoreWeakInst: { SILValue operand, value; unsigned Attr = 0; if (SI.getKind() == ValueKind::StoreWeakInst) { Attr = cast<StoreWeakInst>(&SI)->isInitializationOfDest(); operand = cast<StoreWeakInst>(&SI)->getDest(); value = cast<StoreWeakInst>(&SI)->getSrc(); } else if (SI.getKind() == ValueKind::StoreUnownedInst) { Attr = cast<StoreUnownedInst>(&SI)->isInitializationOfDest(); operand = cast<StoreUnownedInst>(&SI)->getDest(); value = cast<StoreUnownedInst>(&SI)->getSrc(); } else if (SI.getKind() == ValueKind::StoreInst) { Attr = unsigned(cast<StoreInst>(&SI)->getOwnershipQualifier()); operand = cast<StoreInst>(&SI)->getDest(); value = cast<StoreInst>(&SI)->getSrc(); } else if (SI.getKind() == ValueKind::AssignInst) { operand = cast<AssignInst>(&SI)->getDest(); value = cast<AssignInst>(&SI)->getSrc(); } else if (SI.getKind() == ValueKind::CopyAddrInst) { const CopyAddrInst *CAI = cast<CopyAddrInst>(&SI); Attr = (CAI->isInitializationOfDest() << 1) | CAI->isTakeOfSrc(); operand = cast<CopyAddrInst>(&SI)->getDest(); value = cast<CopyAddrInst>(&SI)->getSrc(); } else if (auto *SBI = dyn_cast<StoreBorrowInst>(&SI)) { operand = SBI->getDest(); value = SBI->getSrc(); } else { llvm_unreachable("switch out of sync"); } unsigned abbrCode = SILAbbrCodes[SILOneValueOneOperandLayout::Code]; SILOneValueOneOperandLayout::emitRecord(Out, ScratchRecord, abbrCode, (unsigned)SI.getKind(), Attr, addValueRef(value), S.addTypeRef(operand->getType().getSwiftRValueType()), (unsigned)operand->getType().getCategory(), addValueRef(operand)); break; } case ValueKind::BindMemoryInst: { auto *BI = cast<BindMemoryInst>(&SI); SILValue baseOperand = BI->getBase(); SILValue indexOperand = BI->getIndex(); SILType boundType = BI->getBoundType(); SmallVector<ValueID, 6> ListOfValues; ListOfValues.push_back(S.addTypeRef( baseOperand->getType().getSwiftRValueType())); ListOfValues.push_back((unsigned)baseOperand->getType().getCategory()); ListOfValues.push_back(addValueRef(baseOperand)); ListOfValues.push_back(S.addTypeRef( indexOperand->getType().getSwiftRValueType())); ListOfValues.push_back((unsigned)indexOperand->getType().getCategory()); ListOfValues.push_back(addValueRef(indexOperand)); SILOneTypeValuesLayout::emitRecord( Out, ScratchRecord, SILAbbrCodes[SILOneTypeValuesLayout::Code], (unsigned)SI.getKind(), S.addTypeRef(boundType.getSwiftRValueType()), (unsigned)boundType.getCategory(), ListOfValues); break; } case ValueKind::RefElementAddrInst: case ValueKind::StructElementAddrInst: case ValueKind::StructExtractInst: case ValueKind::InitEnumDataAddrInst: case ValueKind::UncheckedEnumDataInst: case ValueKind::UncheckedTakeEnumDataAddrInst: case ValueKind::InjectEnumAddrInst: { // Has a typed valueref and a field decl. We use SILOneValueOneOperandLayout // where the field decl is streamed as a ValueID. SILValue operand; Decl *tDecl; switch (SI.getKind()) { default: llvm_unreachable("Out of sync with parent switch"); case ValueKind::RefElementAddrInst: operand = cast<RefElementAddrInst>(&SI)->getOperand(); tDecl = cast<RefElementAddrInst>(&SI)->getField(); break; case ValueKind::StructElementAddrInst: operand = cast<StructElementAddrInst>(&SI)->getOperand(); tDecl = cast<StructElementAddrInst>(&SI)->getField(); break; case ValueKind::StructExtractInst: operand = cast<StructExtractInst>(&SI)->getOperand(); tDecl = cast<StructExtractInst>(&SI)->getField(); break; case ValueKind::InitEnumDataAddrInst: operand = cast<InitEnumDataAddrInst>(&SI)->getOperand(); tDecl = cast<InitEnumDataAddrInst>(&SI)->getElement(); break; case ValueKind::UncheckedEnumDataInst: operand = cast<UncheckedEnumDataInst>(&SI)->getOperand(); tDecl = cast<UncheckedEnumDataInst>(&SI)->getElement(); break; case ValueKind::UncheckedTakeEnumDataAddrInst: operand = cast<UncheckedTakeEnumDataAddrInst>(&SI)->getOperand(); tDecl = cast<UncheckedTakeEnumDataAddrInst>(&SI)->getElement(); break; case ValueKind::InjectEnumAddrInst: operand = cast<InjectEnumAddrInst>(&SI)->getOperand(); tDecl = cast<InjectEnumAddrInst>(&SI)->getElement(); break; } SILOneValueOneOperandLayout::emitRecord(Out, ScratchRecord, SILAbbrCodes[SILOneValueOneOperandLayout::Code], (unsigned)SI.getKind(), 0, S.addDeclRef(tDecl), S.addTypeRef(operand->getType().getSwiftRValueType()), (unsigned)operand->getType().getCategory(), addValueRef(operand)); break; } case ValueKind::RefTailAddrInst: { auto *RTAI = cast<RefTailAddrInst>(&SI); writeOneTypeOneOperandLayout(RTAI->getKind(), 0, RTAI->getType(), RTAI->getOperand()); break; } case ValueKind::StructInst: { // Format: a type followed by a list of typed values. A typed value is // expressed by 4 IDs: TypeID, TypeCategory, ValueID, ValueResultNumber. const StructInst *StrI = cast<StructInst>(&SI); SmallVector<ValueID, 4> ListOfValues; for (auto Elt : StrI->getElements()) { ListOfValues.push_back(S.addTypeRef(Elt->getType().getSwiftRValueType())); ListOfValues.push_back((unsigned)Elt->getType().getCategory()); ListOfValues.push_back(addValueRef(Elt)); } SILOneTypeValuesLayout::emitRecord(Out, ScratchRecord, SILAbbrCodes[SILOneTypeValuesLayout::Code], (unsigned)SI.getKind(), S.addTypeRef(StrI->getType().getSwiftRValueType()), (unsigned)StrI->getType().getCategory(), ListOfValues); break; } case ValueKind::TupleElementAddrInst: case ValueKind::TupleExtractInst: { SILValue operand; unsigned FieldNo; switch (SI.getKind()) { default: llvm_unreachable("Out of sync with parent switch"); case ValueKind::TupleElementAddrInst: operand = cast<TupleElementAddrInst>(&SI)->getOperand(); FieldNo = cast<TupleElementAddrInst>(&SI)->getFieldNo(); break; case ValueKind::TupleExtractInst: operand = cast<TupleExtractInst>(&SI)->getOperand(); FieldNo = cast<TupleExtractInst>(&SI)->getFieldNo(); break; } // Use OneTypeOneOperand layout where the field number is stored in TypeID. SILOneTypeOneOperandLayout::emitRecord(Out, ScratchRecord, SILAbbrCodes[SILOneTypeOneOperandLayout::Code], (unsigned)SI.getKind(), 0, FieldNo, 0, S.addTypeRef(operand->getType().getSwiftRValueType()), (unsigned)operand->getType().getCategory(), addValueRef(operand)); break; } case ValueKind::TupleInst: { // Format: a type followed by a list of values. A value is expressed by // 2 IDs: ValueID, ValueResultNumber. const TupleInst *TI = cast<TupleInst>(&SI); SmallVector<ValueID, 4> ListOfValues; for (auto Elt : TI->getElements()) { ListOfValues.push_back(addValueRef(Elt)); } unsigned abbrCode = SILAbbrCodes[SILOneTypeValuesLayout::Code]; SILOneTypeValuesLayout::emitRecord(Out, ScratchRecord, abbrCode, (unsigned)SI.getKind(), S.addTypeRef(TI->getType().getSwiftRValueType()), (unsigned)TI->getType().getCategory(), ListOfValues); break; } case ValueKind::EnumInst: { // Format: a type, an operand and a decl ID. Use SILTwoOperandsLayout: type, // (DeclID + hasOperand), and an operand. const EnumInst *UI = cast<EnumInst>(&SI); TypeID OperandTy = UI->hasOperand() ? S.addTypeRef(UI->getOperand()->getType().getSwiftRValueType()) : TypeID(); unsigned OperandTyCategory = UI->hasOperand() ? (unsigned)UI->getOperand()->getType().getCategory() : 0; SILTwoOperandsLayout::emitRecord(Out, ScratchRecord, SILAbbrCodes[SILTwoOperandsLayout::Code], (unsigned)SI.getKind(), UI->hasOperand(), S.addTypeRef(UI->getType().getSwiftRValueType()), (unsigned)UI->getType().getCategory(), S.addDeclRef(UI->getElement()), OperandTy, OperandTyCategory, UI->hasOperand() ? addValueRef(UI->getOperand()) : ValueID()); break; } case ValueKind::WitnessMethodInst: { // Format: a type, an operand and a SILDeclRef. Use SILOneTypeValuesLayout: // type, Attr, SILDeclRef (DeclID, Kind, uncurryLevel, IsObjC), and a type. const WitnessMethodInst *AMI = cast<WitnessMethodInst>(&SI); CanType Ty = AMI->getLookupType(); SILType Ty2 = AMI->getType(); SmallVector<ValueID, 8> ListOfValues; handleSILDeclRef(S, AMI->getMember(), ListOfValues); // Add an optional operand. TypeID OperandTy = TypeID(); unsigned OperandTyCategory = 0; SILValue OptionalOpenedExistential = SILValue(); auto OperandValueId = addValueRef(OptionalOpenedExistential); SILInstWitnessMethodLayout::emitRecord( Out, ScratchRecord, SILAbbrCodes[SILInstWitnessMethodLayout::Code], S.addTypeRef(Ty), 0, AMI->isVolatile(), S.addTypeRef(Ty2.getSwiftRValueType()), (unsigned)Ty2.getCategory(), OperandTy, OperandTyCategory, OperandValueId, ListOfValues); S.writeConformance(AMI->getConformance(), SILAbbrCodes); break; } case ValueKind::ClassMethodInst: { // Format: a type, an operand and a SILDeclRef. Use SILOneTypeValuesLayout: // type, Attr, SILDeclRef (DeclID, Kind, uncurryLevel, IsObjC), // and an operand. const ClassMethodInst *CMI = cast<ClassMethodInst>(&SI); SILType Ty = CMI->getType(); SmallVector<ValueID, 9> ListOfValues; handleMethodInst(CMI, CMI->getOperand(), ListOfValues); SILOneTypeValuesLayout::emitRecord(Out, ScratchRecord, SILAbbrCodes[SILOneTypeValuesLayout::Code], (unsigned)SI.getKind(), S.addTypeRef(Ty.getSwiftRValueType()), (unsigned)Ty.getCategory(), ListOfValues); break; } case ValueKind::SuperMethodInst: { // Format: a type, an operand and a SILDeclRef. Use SILOneTypeValuesLayout: // type, Attr, SILDeclRef (DeclID, Kind, uncurryLevel, IsObjC), // and an operand. const SuperMethodInst *SMI = cast<SuperMethodInst>(&SI); SILType Ty = SMI->getType(); SmallVector<ValueID, 9> ListOfValues; handleMethodInst(SMI, SMI->getOperand(), ListOfValues); SILOneTypeValuesLayout::emitRecord(Out, ScratchRecord, SILAbbrCodes[SILOneTypeValuesLayout::Code], (unsigned)SI.getKind(), S.addTypeRef(Ty.getSwiftRValueType()), (unsigned)Ty.getCategory(), ListOfValues); break; } case ValueKind::DynamicMethodInst: { // Format: a type, an operand and a SILDeclRef. Use SILOneTypeValuesLayout: // type, Attr, SILDeclRef (DeclID, Kind, uncurryLevel, IsObjC), // and an operand. const DynamicMethodInst *DMI = cast<DynamicMethodInst>(&SI); SILType Ty = DMI->getType(); SmallVector<ValueID, 9> ListOfValues; handleMethodInst(DMI, DMI->getOperand(), ListOfValues); SILOneTypeValuesLayout::emitRecord(Out, ScratchRecord, SILAbbrCodes[SILOneTypeValuesLayout::Code], (unsigned)SI.getKind(), S.addTypeRef(Ty.getSwiftRValueType()), (unsigned)Ty.getCategory(), ListOfValues); break; } case ValueKind::DynamicMethodBranchInst: { // Format: a typed value, a SILDeclRef, a BasicBlock ID for method, // a BasicBlock ID for no method. Use SILOneTypeValuesLayout. const DynamicMethodBranchInst *DMB = cast<DynamicMethodBranchInst>(&SI); SmallVector<ValueID, 8> ListOfValues; ListOfValues.push_back(addValueRef(DMB->getOperand())); handleSILDeclRef(S, DMB->getMember(), ListOfValues); ListOfValues.push_back(BasicBlockMap[DMB->getHasMethodBB()]); ListOfValues.push_back(BasicBlockMap[DMB->getNoMethodBB()]); SILOneTypeValuesLayout::emitRecord(Out, ScratchRecord, SILAbbrCodes[SILOneTypeValuesLayout::Code], (unsigned)SI.getKind(), S.addTypeRef(DMB->getOperand()->getType().getSwiftRValueType()), (unsigned)DMB->getOperand()->getType().getCategory(), ListOfValues); break; } case ValueKind::CheckedCastBranchInst: { // Format: the cast kind, a typed value, a BasicBlock ID for success, // a BasicBlock ID for failure. Uses SILOneTypeValuesLayout. const CheckedCastBranchInst *CBI = cast<CheckedCastBranchInst>(&SI); SmallVector<ValueID, 8> ListOfValues; ListOfValues.push_back(CBI->isExact()), ListOfValues.push_back(addValueRef(CBI->getOperand())); ListOfValues.push_back( S.addTypeRef(CBI->getOperand()->getType().getSwiftRValueType())); ListOfValues.push_back((unsigned)CBI->getOperand()->getType().getCategory()); ListOfValues.push_back(BasicBlockMap[CBI->getSuccessBB()]); ListOfValues.push_back(BasicBlockMap[CBI->getFailureBB()]); SILOneTypeValuesLayout::emitRecord(Out, ScratchRecord, SILAbbrCodes[SILOneTypeValuesLayout::Code], (unsigned)SI.getKind(), S.addTypeRef(CBI->getCastType().getSwiftRValueType()), (unsigned)CBI->getCastType().getCategory(), ListOfValues); break; } case ValueKind::CheckedCastValueBranchInst: { // Format: the cast kind, a typed value, a BasicBlock ID for success, // a BasicBlock ID for failure. Uses SILOneTypeValuesLayout. const CheckedCastValueBranchInst *CBI = cast<CheckedCastValueBranchInst>(&SI); SmallVector<ValueID, 8> ListOfValues; ListOfValues.push_back(addValueRef(CBI->getOperand())); ListOfValues.push_back( S.addTypeRef(CBI->getOperand()->getType().getSwiftRValueType())); ListOfValues.push_back( (unsigned)CBI->getOperand()->getType().getCategory()); ListOfValues.push_back(BasicBlockMap[CBI->getSuccessBB()]); ListOfValues.push_back(BasicBlockMap[CBI->getFailureBB()]); SILOneTypeValuesLayout::emitRecord( Out, ScratchRecord, SILAbbrCodes[SILOneTypeValuesLayout::Code], (unsigned)SI.getKind(), S.addTypeRef(CBI->getCastType().getSwiftRValueType()), (unsigned)CBI->getCastType().getCategory(), ListOfValues); break; } case ValueKind::CheckedCastAddrBranchInst: { // Format: the cast kind, two typed values, a BasicBlock ID for // success, a BasicBlock ID for failure. Uses SILOneTypeValuesLayout; // the type is the type of the second (dest) operand. auto CBI = cast<CheckedCastAddrBranchInst>(&SI); ValueID listOfValues[] = { toStableCastConsumptionKind(CBI->getConsumptionKind()), S.addTypeRef(CBI->getSourceType()), addValueRef(CBI->getSrc()), S.addTypeRef(CBI->getSrc()->getType().getSwiftRValueType()), (unsigned)CBI->getSrc()->getType().getCategory(), S.addTypeRef(CBI->getTargetType()), addValueRef(CBI->getDest()), BasicBlockMap[CBI->getSuccessBB()], BasicBlockMap[CBI->getFailureBB()] }; SILOneTypeValuesLayout::emitRecord(Out, ScratchRecord, SILAbbrCodes[SILOneTypeValuesLayout::Code], (unsigned)SI.getKind(), S.addTypeRef(CBI->getDest()->getType().getSwiftRValueType()), (unsigned)CBI->getDest()->getType().getCategory(), llvm::makeArrayRef(listOfValues)); break; } case ValueKind::InitBlockStorageHeaderInst: { auto IBSHI = cast<InitBlockStorageHeaderInst>(&SI); SmallVector<ValueID, 6> ListOfValues; ListOfValues.push_back(addValueRef(IBSHI->getBlockStorage())); ListOfValues.push_back( S.addTypeRef(IBSHI->getBlockStorage()->getType().getSwiftRValueType())); // Always an address, don't need to save category ListOfValues.push_back(addValueRef(IBSHI->getInvokeFunction())); ListOfValues.push_back( S.addTypeRef(IBSHI->getInvokeFunction()->getType().getSwiftRValueType())); // Always a value, don't need to save category ListOfValues.push_back(IBSHI->getSubstitutions().size()); SILOneTypeValuesLayout::emitRecord(Out, ScratchRecord, SILAbbrCodes[SILOneTypeValuesLayout::Code], (unsigned)SI.getKind(), S.addTypeRef(IBSHI->getType().getSwiftRValueType()), (unsigned)IBSHI->getType().getCategory(), ListOfValues); S.writeSubstitutions(IBSHI->getSubstitutions(), SILAbbrCodes); break; } case ValueKind::KeyPathInst: { auto KPI = cast<KeyPathInst>(&SI); SmallVector<ValueID, 6> ListOfValues; auto pattern = KPI->getPattern(); ListOfValues.push_back(S.addTypeRef(pattern->getRootType())); ListOfValues.push_back(S.addTypeRef(pattern->getValueType())); ListOfValues.push_back(pattern->getComponents().size()); ListOfValues.push_back(pattern->getNumOperands()); ListOfValues.push_back(KPI->getSubstitutions().size()); ListOfValues.push_back( S.addDeclBaseNameRef(Ctx.getIdentifier(pattern->getObjCString()))); ArrayRef<Requirement> reqts; if (auto sig = pattern->getGenericSignature()) { ListOfValues.push_back(sig->getGenericParams().size()); for (auto param : sig->getGenericParams()) ListOfValues.push_back(S.addTypeRef(param)); reqts = sig->getRequirements(); } else { ListOfValues.push_back(0); } for (auto &component : pattern->getComponents()) { auto handleComponentCommon = [&](KeyPathComponentKindEncoding kind) { ListOfValues.push_back((unsigned)kind); ListOfValues.push_back(S.addTypeRef(component.getComponentType())); }; auto handleComputedId = [&](KeyPathPatternComponent::ComputedPropertyId id) { switch (id.getKind()) { case KeyPathPatternComponent::ComputedPropertyId::Property: ListOfValues.push_back( (unsigned)KeyPathComputedComponentIdKindEncoding::Property); ListOfValues.push_back(S.addDeclRef(id.getProperty())); break; case KeyPathPatternComponent::ComputedPropertyId::Function: ListOfValues.push_back( (unsigned)KeyPathComputedComponentIdKindEncoding::Function); ListOfValues.push_back(addSILFunctionRef(id.getFunction())); break; case KeyPathPatternComponent::ComputedPropertyId::DeclRef: ListOfValues.push_back( (unsigned)KeyPathComputedComponentIdKindEncoding::DeclRef); handleSILDeclRef(S, id.getDeclRef(), ListOfValues); break; } }; switch (component.getKind()) { case KeyPathPatternComponent::Kind::StoredProperty: handleComponentCommon(KeyPathComponentKindEncoding::StoredProperty); ListOfValues.push_back(S.addDeclRef(component.getStoredPropertyDecl())); break; case KeyPathPatternComponent::Kind::GettableProperty: handleComponentCommon(KeyPathComponentKindEncoding::GettableProperty); handleComputedId(component.getComputedPropertyId()); ListOfValues.push_back( addSILFunctionRef(component.getComputedPropertyGetter())); assert(component.getComputedPropertyIndices().empty() && "indices not implemented"); break; case KeyPathPatternComponent::Kind::SettableProperty: handleComponentCommon(KeyPathComponentKindEncoding::SettableProperty); handleComputedId(component.getComputedPropertyId()); ListOfValues.push_back( addSILFunctionRef(component.getComputedPropertyGetter())); ListOfValues.push_back( addSILFunctionRef(component.getComputedPropertySetter())); assert(component.getComputedPropertyIndices().empty() && "indices not implemented"); break; case KeyPathPatternComponent::Kind::OptionalChain: handleComponentCommon(KeyPathComponentKindEncoding::OptionalChain); break; case KeyPathPatternComponent::Kind::OptionalForce: handleComponentCommon(KeyPathComponentKindEncoding::OptionalForce); break; case KeyPathPatternComponent::Kind::OptionalWrap: handleComponentCommon(KeyPathComponentKindEncoding::OptionalWrap); break; } } assert(KPI->getAllOperands().empty() && "operands not implemented yet"); SILOneTypeValuesLayout::emitRecord(Out, ScratchRecord, SILAbbrCodes[SILOneTypeValuesLayout::Code], (unsigned)SI.getKind(), S.addTypeRef(KPI->getType().getSwiftRValueType()), (unsigned)KPI->getType().getCategory(), ListOfValues); S.writeGenericRequirements(reqts, SILAbbrCodes); S.writeSubstitutions(KPI->getSubstitutions(), SILAbbrCodes); break; } case ValueKind::MarkUninitializedBehaviorInst: llvm_unreachable("todo"); } // Non-void values get registered in the value table. if (SI.hasValue()) { addValueRef(&SI); ++InstID; } } /// Depending on the RecordKind, we write the SILFunction table, the global /// variable table, the table for SILVTable, or the table for SILWitnessTable. static void writeIndexTable(const sil_index_block::ListLayout &List, sil_index_block::RecordKind kind, const SILSerializer::Table &table) { assert((kind == sil_index_block::SIL_FUNC_NAMES || kind == sil_index_block::SIL_VTABLE_NAMES || kind == sil_index_block::SIL_GLOBALVAR_NAMES || kind == sil_index_block::SIL_WITNESS_TABLE_NAMES || kind == sil_index_block::SIL_DEFAULT_WITNESS_TABLE_NAMES) && "SIL function table, global, vtable and (default) witness table " "are supported"); llvm::SmallString<4096> hashTableBlob; uint32_t tableOffset; { llvm::OnDiskChainedHashTableGenerator<FuncTableInfo> generator; for (auto &entry : table) generator.insert(entry.first, entry.second); llvm::raw_svector_ostream blobStream(hashTableBlob); // Make sure that no bucket is at offset 0. endian::Writer<little>(blobStream).write<uint32_t>(0); tableOffset = generator.Emit(blobStream); } SmallVector<uint64_t, 8> scratch; List.emit(scratch, kind, tableOffset, hashTableBlob); } void SILSerializer::writeIndexTables() { BCBlockRAII restoreBlock(Out, SIL_INDEX_BLOCK_ID, 4); sil_index_block::ListLayout List(Out); sil_index_block::OffsetLayout Offset(Out); if (!FuncTable.empty()) { writeIndexTable(List, sil_index_block::SIL_FUNC_NAMES, FuncTable); Offset.emit(ScratchRecord, sil_index_block::SIL_FUNC_OFFSETS, Funcs); } if (!VTableList.empty()) { writeIndexTable(List, sil_index_block::SIL_VTABLE_NAMES, VTableList); Offset.emit(ScratchRecord, sil_index_block::SIL_VTABLE_OFFSETS, VTableOffset); } if (!GlobalVarList.empty()) { writeIndexTable(List, sil_index_block::SIL_GLOBALVAR_NAMES, GlobalVarList); Offset.emit(ScratchRecord, sil_index_block::SIL_GLOBALVAR_OFFSETS, GlobalVarOffset); } if (!WitnessTableList.empty()) { writeIndexTable(List, sil_index_block::SIL_WITNESS_TABLE_NAMES, WitnessTableList); Offset.emit(ScratchRecord, sil_index_block::SIL_WITNESS_TABLE_OFFSETS, WitnessTableOffset); } if (!DefaultWitnessTableList.empty()) { writeIndexTable(List, sil_index_block::SIL_DEFAULT_WITNESS_TABLE_NAMES, DefaultWitnessTableList); Offset.emit(ScratchRecord, sil_index_block::SIL_DEFAULT_WITNESS_TABLE_OFFSETS, DefaultWitnessTableOffset); } } void SILSerializer::writeSILGlobalVar(const SILGlobalVariable &g) { GlobalVarList[Ctx.getIdentifier(g.getName())] = NextGlobalVarID++; GlobalVarOffset.push_back(Out.GetCurrentBitNo()); TypeID TyID = S.addTypeRef(g.getLoweredType().getSwiftRValueType()); DeclID dID = S.addDeclRef(g.getDecl()); SILGlobalVarLayout::emitRecord(Out, ScratchRecord, SILAbbrCodes[SILGlobalVarLayout::Code], toStableSILLinkage(g.getLinkage()), g.isSerialized() ? 1 : 0, (unsigned)!g.isDefinition(), (unsigned)g.isLet(), TyID, dID); } void SILSerializer::writeSILVTable(const SILVTable &vt) { VTableList[vt.getClass()->getName()] = NextVTableID++; VTableOffset.push_back(Out.GetCurrentBitNo()); VTableLayout::emitRecord(Out, ScratchRecord, SILAbbrCodes[VTableLayout::Code], S.addDeclRef(vt.getClass())); for (auto &entry : vt.getEntries()) { SmallVector<ValueID, 4> ListOfValues; handleSILDeclRef(S, entry.Method, ListOfValues); addReferencedSILFunction(entry.Implementation, true); // Each entry is a pair of SILDeclRef and SILFunction. VTableEntryLayout::emitRecord(Out, ScratchRecord, SILAbbrCodes[VTableEntryLayout::Code], // SILFunction name S.addDeclBaseNameRef(Ctx.getIdentifier(entry.Implementation->getName())), toStableVTableEntryKind(entry.TheKind), toStableSILLinkage(entry.Linkage), ListOfValues); } } void SILSerializer::writeSILWitnessTable(const SILWitnessTable &wt) { WitnessTableList[wt.getIdentifier()] = NextWitnessTableID++; WitnessTableOffset.push_back(Out.GetCurrentBitNo()); WitnessTableLayout::emitRecord( Out, ScratchRecord, SILAbbrCodes[WitnessTableLayout::Code], toStableSILLinkage(wt.getLinkage()), unsigned(wt.isDeclaration()), wt.isSerialized() == IsSerialized ? 1 : 0); S.writeConformance(wt.getConformance(), SILAbbrCodes); // If we have a declaration, do not attempt to serialize entries. if (wt.isDeclaration()) return; for (auto &entry : wt.getEntries()) { if (entry.getKind() == SILWitnessTable::BaseProtocol) { auto &baseWitness = entry.getBaseProtocolWitness(); WitnessBaseEntryLayout::emitRecord(Out, ScratchRecord, SILAbbrCodes[WitnessBaseEntryLayout::Code], S.addDeclRef(baseWitness.Requirement)); S.writeConformance(baseWitness.Witness, SILAbbrCodes); continue; } if (entry.getKind() == SILWitnessTable::AssociatedTypeProtocol) { auto &assoc = entry.getAssociatedTypeProtocolWitness(); WitnessAssocProtocolLayout::emitRecord( Out, ScratchRecord, SILAbbrCodes[WitnessAssocProtocolLayout::Code], S.addTypeRef(assoc.Requirement), S.addDeclRef(assoc.Protocol)); S.writeConformance(assoc.Witness, SILAbbrCodes); continue; } if (entry.getKind() == SILWitnessTable::AssociatedType) { auto &assoc = entry.getAssociatedTypeWitness(); WitnessAssocEntryLayout::emitRecord(Out, ScratchRecord, SILAbbrCodes[WitnessAssocEntryLayout::Code], S.addDeclRef(assoc.Requirement), S.addTypeRef(assoc.Witness)); continue; } auto &methodWitness = entry.getMethodWitness(); SmallVector<ValueID, 4> ListOfValues; handleSILDeclRef(S, methodWitness.Requirement, ListOfValues); IdentifierID witnessID = 0; if (SILFunction *witness = methodWitness.Witness) { addReferencedSILFunction(witness, true); witnessID = S.addDeclBaseNameRef(Ctx.getIdentifier(witness->getName())); } WitnessMethodEntryLayout::emitRecord(Out, ScratchRecord, SILAbbrCodes[WitnessMethodEntryLayout::Code], // SILFunction name witnessID, ListOfValues); } } void SILSerializer:: writeSILDefaultWitnessTable(const SILDefaultWitnessTable &wt) { if (wt.isDeclaration()) return; DefaultWitnessTableList[wt.getIdentifier()] = NextDefaultWitnessTableID++; DefaultWitnessTableOffset.push_back(Out.GetCurrentBitNo()); DefaultWitnessTableLayout::emitRecord( Out, ScratchRecord, SILAbbrCodes[DefaultWitnessTableLayout::Code], S.addDeclRef(wt.getProtocol()), toStableSILLinkage(wt.getLinkage())); for (auto &entry : wt.getEntries()) { if (!entry.isValid()) { DefaultWitnessTableNoEntryLayout::emitRecord(Out, ScratchRecord, SILAbbrCodes[DefaultWitnessTableNoEntryLayout::Code]); continue; } SmallVector<ValueID, 4> ListOfValues; handleSILDeclRef(S, entry.getRequirement(), ListOfValues); SILFunction *witness = entry.getWitness(); addReferencedSILFunction(witness, true); IdentifierID witnessID = S.addDeclBaseNameRef( Ctx.getIdentifier(witness->getName())); DefaultWitnessTableEntryLayout::emitRecord(Out, ScratchRecord, SILAbbrCodes[DefaultWitnessTableEntryLayout::Code], // SILFunction name witnessID, ListOfValues); } } /// Helper function for whether to emit a function body. bool SILSerializer::shouldEmitFunctionBody(const SILFunction *F, bool isReference) { // If F is a declaration, it has no body to emit... // The declaration will be serialized anyways if it is referenced anywhere. if (F->isExternalDeclaration()) return false; // Never serialize any function definitions available externally, unless // it is a referenced shared function (see the explanation in // SILSerializer::writeSILFunction). // TODO: Special handling for resilient mode. if (F->isAvailableExternally() && !(isReference && hasSharedVisibility(F->getLinkage()))) return false; // If we are asked to serialize everything, go ahead and do it. if (ShouldSerializeAll) return true; // If F is serialized, we should always emit its body. if (F->isSerialized() == IsSerialized) return true; return false; } void SILSerializer::writeSILBlock(const SILModule *SILMod) { BCBlockRAII subBlock(Out, SIL_BLOCK_ID, 6); registerSILAbbr<SILFunctionLayout>(); registerSILAbbr<SILBasicBlockLayout>(); registerSILAbbr<SILOneValueOneOperandLayout>(); registerSILAbbr<SILOneTypeLayout>(); registerSILAbbr<SILOneOperandLayout>(); registerSILAbbr<SILOneTypeOneOperandLayout>(); registerSILAbbr<SILInitExistentialLayout>(); registerSILAbbr<SILOneTypeValuesLayout>(); registerSILAbbr<SILTwoOperandsLayout>(); registerSILAbbr<SILTailAddrLayout>(); registerSILAbbr<SILInstApplyLayout>(); registerSILAbbr<SILInstNoOperandLayout>(); registerSILAbbr<VTableLayout>(); registerSILAbbr<VTableEntryLayout>(); registerSILAbbr<SILGlobalVarLayout>(); registerSILAbbr<WitnessTableLayout>(); registerSILAbbr<WitnessMethodEntryLayout>(); registerSILAbbr<WitnessBaseEntryLayout>(); registerSILAbbr<WitnessAssocProtocolLayout>(); registerSILAbbr<WitnessAssocEntryLayout>(); registerSILAbbr<DefaultWitnessTableLayout>(); registerSILAbbr<DefaultWitnessTableEntryLayout>(); registerSILAbbr<DefaultWitnessTableNoEntryLayout>(); registerSILAbbr<SILInstCastLayout>(); registerSILAbbr<SILInstWitnessMethodLayout>(); registerSILAbbr<SILSpecializeAttrLayout>(); // Register the abbreviation codes so these layouts can exist in both // decl blocks and sil blocks. // We have to make sure BOUND_GENERIC_SUBSTITUTION does not overlap with // SIL-specific records. registerSILAbbr<decls_block::BoundGenericSubstitutionLayout>(); registerSILAbbr<decls_block::AbstractProtocolConformanceLayout>(); registerSILAbbr<decls_block::NormalProtocolConformanceLayout>(); registerSILAbbr<decls_block::SpecializedProtocolConformanceLayout>(); registerSILAbbr<decls_block::InheritedProtocolConformanceLayout>(); registerSILAbbr<decls_block::NormalProtocolConformanceIdLayout>(); registerSILAbbr<decls_block::ProtocolConformanceXrefLayout>(); registerSILAbbr<decls_block::GenericRequirementLayout>(); registerSILAbbr<decls_block::LayoutRequirementLayout>(); for (const SILGlobalVariable &g : SILMod->getSILGlobals()) writeSILGlobalVar(g); // Write out VTables first because it may require serializations of // non-transparent SILFunctions (body is not needed). // Go through all SILVTables in SILMod and write them if we should // serialize everything. // FIXME: Resilience: could write out vtable for fragile classes. const DeclContext *assocDC = SILMod->getAssociatedContext(); assert(assocDC && "cannot serialize SIL without an associated DeclContext"); for (const SILVTable &vt : SILMod->getVTables()) { if (ShouldSerializeAll && vt.getClass()->isChildContextOf(assocDC)) writeSILVTable(vt); } // Write out fragile WitnessTables. for (const SILWitnessTable &wt : SILMod->getWitnessTables()) { if ((ShouldSerializeAll || wt.isSerialized()) && wt.getConformance()->getDeclContext()->isChildContextOf(assocDC)) writeSILWitnessTable(wt); } // Write out DefaultWitnessTables. for (const SILDefaultWitnessTable &wt : SILMod->getDefaultWitnessTables()) { // FIXME: Don't need to serialize private and internal default witness // tables. if (wt.getProtocol()->getDeclContext()->isChildContextOf(assocDC)) writeSILDefaultWitnessTable(wt); } // Emit only declarations if it is a module with pre-specializations. // And only do it in optimized builds. bool emitDeclarationsForOnoneSupport = SILMod->getSwiftModule()->getName().str() == SWIFT_ONONE_SUPPORT && SILMod->getOptions().Optimization > SILOptions::SILOptMode::Debug; // Go through all the SILFunctions in SILMod and write out any // mandatory function bodies. for (const SILFunction &F : *SILMod) { if (emitDeclarationsForOnoneSupport) { // Only declarations of whitelisted pre-specializations from with // public linkage need to be serialized as they will be used // by UsePrespecializations pass during -Onone compilation to // check for availability of concrete pre-specializations. if (!hasPublicVisibility(F.getLinkage()) || !isWhitelistedSpecialization(F.getName())) continue; } addMandatorySILFunction(&F, emitDeclarationsForOnoneSupport); processSILFunctionWorklist(); } // Now write function declarations for every function we've // emitted a reference to without emitting a function body for. for (const SILFunction &F : *SILMod) { auto iter = FuncsToEmit.find(&F); if (iter != FuncsToEmit.end() && iter->second) { assert((emitDeclarationsForOnoneSupport || !shouldEmitFunctionBody(&F)) && "Should have emitted function body earlier"); writeSILFunction(F, true); } } assert(Worklist.empty() && "Did not emit everything in worklist"); } void SILSerializer::writeSILModule(const SILModule *SILMod) { writeSILBlock(SILMod); writeIndexTables(); } void Serializer::writeSIL(const SILModule *SILMod, bool serializeAllSIL) { if (!SILMod) return; SILSerializer SILSer(*this, M->getASTContext(), Out, serializeAllSIL); SILSer.writeSILModule(SILMod); }
; A184032: 1/16 the number of (n+1) X 3 0..3 arrays with all 2 X 2 subblocks having the same four values. ; 28,40,61,103,181,337,637,1237,2413,4765,9421,18733,37261,74317,148237,296077,591373,1181965,2362381,4723213,9443341,18883597,37761037,75515917,151019533,302026765,604028941,1208033293,2416017421,4831985677,9663873037,19327647757,38655098893,77310001165,154619609101,309238824973,618476863501,1236952940557,2473904308237,4947807043597,9895610941453,19791218737165,39582431182861,79164856074253,158329699565581,316659386548237,633318747930637,1266637470695437,2533274891059213,5066549731786765,10133099362910221,20266198625157133,40532397048987661,81064793896648717,162129587390644237,324259174378635277,648518347951964173,1297036695098621965,2594073388586631181,5188146775562649613,10376293547904073741,20752587092586921997,41505174178731393037,83010348351020335117,166020696689155768333,332041393365426634765,664082786705083465741,1328165573384397127693,2656331146717254647821,5312662293382969688077,10625324586662860161037,21250649173222641106957,42501298346239123783693,85002596692272089137165,170005193384131861413901,340010386767851405967373,680020773534878178213901,1360041547068931722706957,2720083094136214177972237,5440166188270779088502797,10880332376538259642122253,21760664753073220749361165,43521329506139844428955661,87042659012273091788144653,174085318024532989436755981,348170636049052784733978637,696341272098079181188890637,1392682544196131974098714637,2785365088392211171639296013,5570730176784369566720458765,11141460353568633580324651021,22282920707137161607533035533,44565841414274112108833538061,89131682828548013111434543117,178263365657095604010404020237,356526731314190785808342974477,713053462628380727191755816973,1426106925256760609958581501965,2852213850513519531067302739981,5704427701027037373284745216013 mov $1,4 mov $2,$0 lpb $0 mul $1,2 add $1,$2 sub $1,$0 sub $0,1 trn $2,2 lpe sub $1,4 mul $1,3 add $1,28 mov $0,$1
#pragma once #include <map> #include <string> #include <vector> #include "cstone/sfc/box.hpp" #include "file_utils.hpp" #include "mpi_file_utils.hpp" #include "sph/particles_data.hpp" namespace sphexa { template<typename Dataset> struct IFileWriter { virtual void dump(Dataset& d, size_t firstIndex, size_t lastIndex, const cstone::Box<typename Dataset::RealType>& box, std::string path) const = 0; virtual void constants(const std::map<std::string, double>& c, std::string path) const = 0; virtual ~IFileWriter() = default; }; template<class Dataset> struct AsciiWriter : public IFileWriter<Dataset> { void dump(Dataset& d, size_t firstIndex, size_t lastIndex, const cstone::Box<typename Dataset::RealType>& box, std::string path) const override { const char separator = ' '; path += std::to_string(d.iteration) + ".txt"; int rank, numRanks; MPI_Comm_rank(d.comm, &rank); MPI_Comm_size(d.comm, &numRanks); for (int turn = 0; turn < numRanks; turn++) { if (turn == rank) { try { auto fieldPointers = getOutputArrays(d); bool append = rank != 0; fileutils::writeAscii(firstIndex, lastIndex, path, append, fieldPointers, separator); } catch (std::runtime_error& ex) { if (rank == 0) fprintf(stderr, "ERROR: %s Terminating\n", ex.what()); MPI_Abort(d.comm, 1); } } MPI_Barrier(MPI_COMM_WORLD); } } void constants(const std::map<std::string, double>& c, std::string path) const override {} }; template<class Dataset> struct H5PartWriter : public IFileWriter<Dataset> { void dump(Dataset& d, size_t firstIndex, size_t lastIndex, const cstone::Box<typename Dataset::RealType>& box, std::string path) const override { #ifdef SPH_EXA_HAVE_H5PART path += ".h5part"; fileutils::writeH5Part(d, firstIndex, lastIndex, box, path); #else throw std::runtime_error("Cannot write to HDF5 file: H5Part not enabled\n"); #endif } /*! @brief write simulation parameters to file * * @param c (name, value) pairs of constants * @param path path to HDF5 file * * Note: file is being opened serially, must be called on one rank only. */ void constants(const std::map<std::string, double>& c, std::string path) const override { #ifdef SPH_EXA_HAVE_H5PART path += ".h5part"; const char* h5_fname = path.c_str(); if (std::filesystem::exists(h5_fname)) { throw std::runtime_error("Cannot write constants: file " + path + " already exists\n"); } H5PartFile* h5_file = nullptr; h5_file = H5PartOpenFile(h5_fname, H5PART_WRITE); for (auto it = c.begin(); it != c.end(); ++it) { H5PartWriteFileAttrib(h5_file, it->first.c_str(), H5PART_FLOAT64, &(it->second), 1); } H5PartCloseFile(h5_file); #else throw std::runtime_error("Cannot write to HDF5 file: H5Part not enabled\n"); #endif } }; template<class Dataset> std::unique_ptr<IFileWriter<Dataset>> fileWriterFactory(bool ascii) { if (ascii) { return std::make_unique<AsciiWriter<Dataset>>(); } else { return std::make_unique<H5PartWriter<Dataset>>(); } } } // namespace sphexa
; void print(int stdout_stderr, char* str, size_t size); global print section .text print: mov eax,4 ; write syscall int 0x80 ret
; A114799: Septuple factorial, 7-factorial, n!7, n!!!!!!!, a(n) = n*a(n-7) if n > 1, else 1. ; 1,1,2,3,4,5,6,7,8,18,30,44,60,78,98,120,288,510,792,1140,1560,2058,2640,6624,12240,19800,29640,42120,57624,76560,198720,379440,633600,978120,1432080,2016840,2756160,7352640,14418720,24710400,39124800,58715280,84707280,118514880,323516160,648842400,1136678400,1838865600,2818333440,4150656720,5925744000,16499324160,33739804800,60243955200,99298742400,155008339200,232436776320,337767408000,956960801280,1990648483200,3614637312000,6057223286400,9610517030400,14643516908160,21617114112000,62202452083200,131382799891200,242180699904000,411891183475200,663125675097600,1025046183571200,1534815101952000,4478576549990400 mov $1,12 lpb $0 mul $1,$0 trn $0,7 lpe div $1,12
; A037625: Base 4 digits are, in order, the first n terms of the periodic sequence with initial period 2,3,0. ; 2,11,44,178,715,2860,11442,45771,183084,732338,2929355,11717420,46869682,187478731,749914924,2999659698,11998638795,47994555180,191978220722,767912882891,3071651531564,12286606126258,49146424505035 mul $0,2 add $0,2 mov $1,40 lpb $0 sub $0,1 sub $1,1 mul $1,2 add $1,6 lpe div $1,63 mov $0,$1
// Copyright (c) 2018, The Beldex Project // // 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. // // 3. Neither the name of the copyright holder nor the names of its contributors may be // used to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL // THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers #include "gtest/gtest.h" #include "cryptonote_core/master_node_list.h" #include "cryptonote_core/master_node_voting.h" #include "cryptonote_core/cryptonote_tx_utils.h" #include "cryptonote_basic/cryptonote_basic.h" #include "cryptonote_basic/verification_context.h" #include "cryptonote_config.h" TEST(master_nodes, staking_requirement) { // NOTE: Thanks for the values @Sonofotis const uint64_t atomic_epsilon = config::DEFAULT_DUST_THRESHOLD; // LHS of Equation // Try underflow { uint64_t height = 100; uint64_t mainnet_requirement = master_nodes::get_staking_requirement(cryptonote::MAINNET, height); ASSERT_EQ(mainnet_requirement, (45000 * COIN)); } // Starting height for mainnet { // NOTE: The maximum staking requirement is 50,000, in atomic units is 50,000,000,000,000 < int64 range (2^63-1) // so casting is safe. uint64_t height = 101250; int64_t mainnet_requirement = (int64_t)master_nodes::get_staking_requirement(cryptonote::MAINNET, height); ASSERT_EQ(mainnet_requirement, (45000 * COIN)); } // Check the requirements are decreasing { uint64_t height = 209250; int64_t mainnet_requirement = (int64_t)master_nodes::get_staking_requirement(cryptonote::MAINNET, height); int64_t mainnet_expected = (int64_t)((29643 * COIN) + 670390000); int64_t mainnet_delta = std::abs(mainnet_requirement - mainnet_expected); ASSERT_LT(mainnet_delta, atomic_epsilon); } // NOTE: Staking Requirement Algorithm Switch 2 // Sliftly after the boundary when the scheme switches over to a smooth emissions curve to 15k { uint64_t height = 230704; int64_t mainnet_requirement = (int64_t)master_nodes::get_staking_requirement(cryptonote::MAINNET, height); int64_t mainnet_expected = (int64_t)((27164 * COIN) + 648610000); int64_t mainnet_delta = std::abs(mainnet_requirement - mainnet_expected); ASSERT_LT(mainnet_delta, atomic_epsilon); } // Check staking requirement on height whose value is different with different floating point rounding modes, we expect FE_TONEAREST. { uint64_t height = 373200; int64_t mainnet_requirement = (int64_t)master_nodes::get_staking_requirement(cryptonote::MAINNET, height); int64_t mainnet_expected = (int64_t)((20839 * COIN) + 644149350); ASSERT_EQ(mainnet_requirement, mainnet_expected); } // NOTE: Staking Requirement Algorithm Switch: Integer Math Variant ^____^ { uint64_t height = 450000; uint64_t mainnet_requirement = master_nodes::get_staking_requirement(cryptonote::MAINNET, height); uint64_t mainnet_expected = (18898 * COIN) + 351896001; ASSERT_EQ(mainnet_requirement, mainnet_expected); } // Just before 15k boundary { uint64_t height = 999999; uint64_t mainnet_requirement = master_nodes::get_staking_requirement(cryptonote::MAINNET, height); uint64_t mainnet_expected = (15000 * COIN) + 3122689; ASSERT_EQ(mainnet_requirement, mainnet_expected); } // 15k requirement boundary { uint64_t height = 1000000; uint64_t mainnet_requirement = master_nodes::get_staking_requirement(cryptonote::MAINNET, height); uint64_t mainnet_expected = 15000 * COIN; ASSERT_EQ(mainnet_requirement, mainnet_expected); } } static bool verify_vote(master_nodes::quorum_vote_t const &vote, uint64_t latest_height, cryptonote::vote_verification_context &vvc, master_nodes::quorum const &quorum) { bool result = master_nodes::verify_vote_age(vote, latest_height,vvc, cryptonote::network_version_17_POS ); result &= master_nodes::verify_vote_signature(cryptonote::network_version_count - 1, vote, vvc, quorum); return result; } TEST(master_nodes, vote_validation) { // Generate a quorum and the voter cryptonote::keypair master_node_voter{hw::get_device("default")}; int voter_index = 0; master_nodes::master_node_keys voter_keys; voter_keys.pub = master_node_voter.pub; voter_keys.key = master_node_voter.sec; master_nodes::quorum state = {}; { state.validators.resize(10); state.workers.resize(state.validators.size()); for (size_t i = 0; i < state.validators.size(); ++i) { state.validators[i] = (i == voter_index) ? master_node_voter.pub : cryptonote::keypair{hw::get_device("default")}.pub; state.workers[i] = cryptonote::keypair{hw::get_device("default")}.pub; } } // Valid vote uint64_t block_height = 70; master_nodes::quorum_vote_t valid_vote = master_nodes::make_state_change_vote(block_height, voter_index, 1 /*worker_index*/, master_nodes::new_state::decommission,0, voter_keys); { cryptonote::vote_verification_context vvc = {}; bool result = verify_vote(valid_vote, block_height, vvc, state); if (!result) std::cout << cryptonote::print_vote_verification_context(vvc, &valid_vote) << std::endl; ASSERT_TRUE(result); } // Voters validator index out of bounds { auto vote = valid_vote; vote.index_in_group = state.validators.size() + 10; vote.signature = master_nodes::make_signature_from_vote(vote, voter_keys); cryptonote::vote_verification_context vvc = {}; bool result = verify_vote(vote, block_height, vvc, state); ASSERT_FALSE(result); } // Voters worker index out of bounds { auto vote = valid_vote; vote.state_change.worker_index = state.workers.size() + 10; vote.signature = master_nodes::make_signature_from_vote(vote, voter_keys); cryptonote::vote_verification_context vvc = {}; bool result = verify_vote(vote, block_height, vvc, state); ASSERT_FALSE(result); } // Signature not valid { auto vote = valid_vote; cryptonote::keypair other_voter{hw::get_device("default")}; vote.signature = {}; cryptonote::vote_verification_context vvc = {}; bool result = verify_vote(vote, block_height, vvc, state); ASSERT_FALSE(result); } // Vote too old { cryptonote::vote_verification_context vvc = {}; bool result = verify_vote(valid_vote, 1 /*latest_height*/, vvc, state); ASSERT_FALSE(result); } // Vote too far in the future { cryptonote::vote_verification_context vvc = {}; bool result = verify_vote(valid_vote, block_height + 10000, vvc, state); ASSERT_FALSE(result); } } TEST(master_nodes, tx_extra_state_change_validation) { // Generate a quorum and the voter std::array<master_nodes::master_node_keys, 10> voters = {}; master_nodes::quorum state = {}; { state.validators.resize(voters.size()); state.workers.resize(voters.size()); for (size_t i = 0; i < state.validators.size(); ++i) { cryptonote::keypair voter{hw::get_device("default")}; voters[i].pub = voter.pub; voters[i].key = voter.sec; state.validators[i] = voters[i].pub; state.workers[i] = cryptonote::keypair{hw::get_device("default")}.pub; } } // Valid state_change cryptonote::tx_extra_master_node_state_change valid_state_change = {}; uint8_t hf_version = cryptonote::network_version_11_infinite_staking; const uint64_t HEIGHT = 100; { valid_state_change.block_height = HEIGHT - 1; valid_state_change.master_node_index = 1; valid_state_change.votes.reserve(voters.size()); for (size_t i = 0; i < voters.size(); ++i) { cryptonote::tx_extra_master_node_state_change::vote vote = {}; vote.validator_index = i; vote.signature = master_nodes::make_signature_from_tx_state_change(valid_state_change, voters[i]); valid_state_change.votes.push_back(vote); } cryptonote::tx_verification_context tvc = {}; bool result = master_nodes::verify_tx_state_change(valid_state_change, HEIGHT, tvc, state, hf_version); if (!result) std::cout << cryptonote::print_tx_verification_context(tvc) << std::endl; ASSERT_TRUE(result); } // State Change has insufficient votes { auto state_change = valid_state_change; while (state_change.votes.size() >= master_nodes::STATE_CHANGE_MIN_VOTES_TO_CHANGE_STATE) state_change.votes.pop_back(); cryptonote::tx_verification_context tvc = {}; bool result = master_nodes::verify_tx_state_change(state_change, HEIGHT, tvc, state, hf_version); ASSERT_FALSE(result); } // State Change has duplicated voter { auto state_change = valid_state_change; state_change.votes[0] = state_change.votes[1]; cryptonote::tx_verification_context tvc = {}; bool result = master_nodes::verify_tx_state_change(state_change, HEIGHT, tvc, state, hf_version); ASSERT_FALSE(result); } // State Change has one voter with invalid signature { auto state_change = valid_state_change; state_change.votes[0].signature = state_change.votes[1].signature; cryptonote::tx_verification_context tvc = {}; bool result = master_nodes::verify_tx_state_change(state_change, HEIGHT, tvc, state, hf_version); ASSERT_FALSE(result); } // State Change has one voter with index out of bounds { auto state_change = valid_state_change; state_change.votes[0].validator_index = state.validators.size() + 10; cryptonote::tx_verification_context tvc = {}; bool result = master_nodes::verify_tx_state_change(state_change, HEIGHT, tvc, state, hf_version); ASSERT_FALSE(result); } // State Change master node index is out of bounds { auto state_change = valid_state_change; state_change.master_node_index = state.workers.size() + 10; cryptonote::tx_verification_context tvc = {}; bool result = master_nodes::verify_tx_state_change(state_change, HEIGHT, tvc, state, hf_version); ASSERT_FALSE(result); } // State Change too old { auto state_change = valid_state_change; cryptonote::tx_verification_context tvc = {}; bool result = master_nodes::verify_tx_state_change(state_change, 0, tvc, state, hf_version); ASSERT_FALSE(result); } // State Change too new { auto state_change = valid_state_change; cryptonote::tx_verification_context tvc = {}; bool result = master_nodes::verify_tx_state_change(state_change, HEIGHT + 1000, tvc, state, hf_version); ASSERT_FALSE(result); } } TEST(master_nodes, min_portions) { uint8_t hf_version = cryptonote::network_version_9_master_nodes; // Test new contributors can *NOT* stake to a registration with under 25% of the total stake if there is more than 25% available. { ASSERT_FALSE(master_nodes::check_master_node_portions(hf_version, {0, STAKING_PORTIONS})); } { const auto small = MIN_PORTIONS - 1; const auto rest = STAKING_PORTIONS - small; ASSERT_FALSE(master_nodes::check_master_node_portions(hf_version, {small, rest})); } { /// TODO: fix this test const auto small = MIN_PORTIONS - 1; const auto rest = STAKING_PORTIONS - small - STAKING_PORTIONS / 2; ASSERT_FALSE(master_nodes::check_master_node_portions(hf_version, {STAKING_PORTIONS / 2, small, rest})); } { const auto small = MIN_PORTIONS - 1; const auto rest = STAKING_PORTIONS - small - 2 * MIN_PORTIONS; ASSERT_FALSE(master_nodes::check_master_node_portions(hf_version, {MIN_PORTIONS, MIN_PORTIONS, small, rest})); } // Test new contributors *CAN* stake as the last person with under 25% if there is less than 25% available. // Two contributers { const auto large = 4 * (STAKING_PORTIONS / 5); const auto rest = STAKING_PORTIONS - large; bool result = master_nodes::check_master_node_portions(hf_version, {large, rest}); ASSERT_TRUE(result); } // Three contributers { const auto half = STAKING_PORTIONS / 2 - 1; const auto rest = STAKING_PORTIONS - 2 * half; bool result = master_nodes::check_master_node_portions(hf_version, {half, half, rest}); ASSERT_TRUE(result); } // Four contributers { const auto third = STAKING_PORTIONS / 3 - 1; const auto rest = STAKING_PORTIONS - 3 * third; bool result = master_nodes::check_master_node_portions(hf_version, {third, third, third, rest}); ASSERT_TRUE(result); } // ===== After hard fork v11 ===== hf_version = cryptonote::network_version_11_infinite_staking; { ASSERT_FALSE(master_nodes::check_master_node_portions(hf_version, {0, STAKING_PORTIONS})); } { const auto small = MIN_PORTIONS - 1; const auto rest = STAKING_PORTIONS - small; ASSERT_FALSE(master_nodes::check_master_node_portions(hf_version, {small, rest})); } { const auto small = STAKING_PORTIONS / 8; const auto rest = STAKING_PORTIONS - small - STAKING_PORTIONS / 2; ASSERT_FALSE(master_nodes::check_master_node_portions(hf_version, {STAKING_PORTIONS / 2, small, rest})); } { const auto small = MIN_PORTIONS - 1; const auto rest = STAKING_PORTIONS - small - 2 * MIN_PORTIONS; ASSERT_FALSE(master_nodes::check_master_node_portions(hf_version, {MIN_PORTIONS, MIN_PORTIONS, small, rest})); } // Test new contributors *CAN* stake as the last person with under 25% if there is less than 25% available. // Two contributers { const auto large = 4 * (STAKING_PORTIONS / 5); const auto rest = STAKING_PORTIONS - large; bool result = master_nodes::check_master_node_portions(hf_version, {large, rest}); ASSERT_TRUE(result); } // Three contributers { const auto half = STAKING_PORTIONS / 2 - 1; const auto rest = STAKING_PORTIONS - 2 * half; bool result = master_nodes::check_master_node_portions(hf_version, {half, half, rest}); ASSERT_TRUE(result); } // Four contributers { const auto third = STAKING_PORTIONS / 3 - 1; const auto rest = STAKING_PORTIONS - 3 * third; bool result = master_nodes::check_master_node_portions(hf_version, {third, third, third, rest}); ASSERT_TRUE(result); } // New test for hf_v11: allow less than 25% stake in the presence of large existing contributions { const auto large = STAKING_PORTIONS / 2; const auto small_1 = STAKING_PORTIONS / 6; const auto small_2 = STAKING_PORTIONS / 6; const auto rest = STAKING_PORTIONS - large - small_1 - small_2; bool result = master_nodes::check_master_node_portions(hf_version, {large, small_1, small_2, rest}); ASSERT_TRUE(result); } } // Test minimum stake contributions (should test pre and post this change) TEST(master_nodes, min_stake_amount) { /// pre v11 uint64_t height = 101250; uint8_t hf_version = cryptonote::network_version_9_master_nodes; uint64_t stake_requirement = master_nodes::get_staking_requirement(cryptonote::MAINNET, height); { const uint64_t reserved = stake_requirement / 2; const uint64_t min_stake = master_nodes::get_min_node_contribution(hf_version, stake_requirement, reserved, 1); ASSERT_EQ(min_stake, stake_requirement / 4); } { const uint64_t reserved = 5 * stake_requirement / 6; const uint64_t min_stake = master_nodes::get_min_node_contribution(hf_version, stake_requirement, reserved, 1); ASSERT_EQ(min_stake, stake_requirement / 6); } /// post v11 hf_version = cryptonote::network_version_11_infinite_staking; stake_requirement = master_nodes::get_staking_requirement(cryptonote::MAINNET, height); { // 50% reserved, with 1 contribution, max of 4- the minimum stake should be (50% / 3) const uint64_t reserved = stake_requirement / 2; const uint64_t remaining = stake_requirement - reserved; uint64_t min_stake = master_nodes::get_min_node_contribution(hf_version, stake_requirement, reserved, 1 /*num_contributions_locked*/); ASSERT_EQ(min_stake, remaining / 3); // As above, but with 2 contributions locked up, minimum stake should be (50% / 2) min_stake = master_nodes::get_min_node_contribution(hf_version, stake_requirement, reserved, 2 /*num_contributions_locked*/); ASSERT_EQ(min_stake, remaining / 2); } { /// Cannot contribute less than 25% under normal circumstances const uint64_t reserved = stake_requirement / 4; const uint64_t min_stake = master_nodes::get_min_node_contribution(hf_version, stake_requirement, reserved, 1); ASSERT_FALSE(min_stake <= stake_requirement / 6); } { // Cannot contribute less than 25% as first contributor const uint64_t min_stake = master_nodes::get_min_node_contribution(hf_version, stake_requirement, 0, 0/*num_contributions_locked*/); ASSERT_TRUE(min_stake >= stake_requirement / 4); } } // Test master node receive rewards proportionate to the amount they contributed. TEST(master_nodes, master_node_rewards_proportional_to_portions) { { const auto reward_a = cryptonote::get_portion_of_reward(MIN_PORTIONS, COIN); const auto reward_b = cryptonote::get_portion_of_reward(3 * MIN_PORTIONS, COIN); ASSERT_TRUE(3 * reward_a == reward_b); } { const auto reward_a = cryptonote::get_portion_of_reward(STAKING_PORTIONS/2, COIN); const auto reward_b = cryptonote::get_portion_of_reward(STAKING_PORTIONS, COIN); ASSERT_TRUE(2 * reward_a == reward_b); } } TEST(master_nodes, master_node_get_locked_key_image_unlock_height) { uint64_t lock_duration = master_nodes::staking_num_lock_blocks(cryptonote::MAINNET, cryptonote::network_version_17_POS) / 2; { uint64_t curr_height = 100; uint64_t expected = curr_height + lock_duration; uint64_t unlock_height = master_nodes::get_locked_key_image_unlock_height(cryptonote::MAINNET, 0, curr_height, cryptonote::network_version_17_POS); ASSERT_EQ(unlock_height, expected); } { uint64_t curr_height = lock_duration - 1; uint64_t expected = curr_height + lock_duration; uint64_t unlock_height = master_nodes::get_locked_key_image_unlock_height(cryptonote::MAINNET, 0, curr_height, cryptonote::network_version_17_POS); ASSERT_EQ(unlock_height, expected); } { uint64_t curr_height = lock_duration + 100; uint64_t expected = curr_height + lock_duration; uint64_t unlock_height = master_nodes::get_locked_key_image_unlock_height(cryptonote::MAINNET, 0, curr_height, cryptonote::network_version_17_POS); ASSERT_EQ(unlock_height, expected); } { uint64_t expected = lock_duration + lock_duration; uint64_t unlock_height = master_nodes::get_locked_key_image_unlock_height(cryptonote::MAINNET, lock_duration, lock_duration, cryptonote::network_version_17_POS); ASSERT_EQ(unlock_height, expected); } { uint64_t register_height = lock_duration + 1; uint64_t curr_height = register_height + 2; uint64_t expected = curr_height + lock_duration; uint64_t unlock_height = master_nodes::get_locked_key_image_unlock_height(cryptonote::MAINNET, register_height, curr_height, cryptonote::network_version_17_POS); ASSERT_EQ(unlock_height, expected); } }
.global s_prepare_buffers s_prepare_buffers: push %r11 push %r13 push %r14 push %r15 push %r9 push %rcx push %rdi push %rdx push %rsi lea addresses_UC_ht+0x4abb, %r13 nop cmp %r11, %r11 mov (%r13), %edx nop nop nop nop nop sub %r14, %r14 lea addresses_D_ht+0x1bb3b, %rdx nop inc %r13 mov (%rdx), %r15 nop nop nop cmp $19828, %r14 lea addresses_UC_ht+0x1cdcb, %r15 nop nop nop add %r14, %r14 movl $0x61626364, (%r15) sub $34480, %r14 lea addresses_normal_ht+0x9d93, %r9 nop nop nop nop sub $16690, %r11 movw $0x6162, (%r9) add %rdx, %rdx lea addresses_normal_ht+0x9abb, %r11 dec %r15 mov (%r11), %r14w nop nop nop nop add %r15, %r15 lea addresses_normal_ht+0x1ddfb, %rsi lea addresses_WT_ht+0x3fbb, %rdi nop nop nop nop and %r13, %r13 mov $105, %rcx rep movsb nop nop nop nop nop and $18226, %rsi lea addresses_normal_ht+0xdd9f, %rsi lea addresses_WT_ht+0x7bb, %rdi clflush (%rsi) sub $63143, %r14 mov $115, %rcx rep movsw nop nop nop nop dec %rdi lea addresses_WC_ht+0x18cb, %rcx clflush (%rcx) nop inc %rdi movb (%rcx), %r15b nop nop lfence lea addresses_WT_ht+0xfefd, %rcx clflush (%rcx) nop nop cmp %rsi, %rsi mov $0x6162636465666768, %r11 movq %r11, %xmm7 vmovups %ymm7, (%rcx) add %rdi, %rdi lea addresses_WC_ht+0x371b, %rsi lea addresses_normal_ht+0xf36f, %rdi nop nop nop nop nop sub $63272, %r14 mov $66, %rcx rep movsq nop nop inc %rsi lea addresses_UC_ht+0x1c9f3, %rcx and %r13, %r13 mov $0x6162636465666768, %r15 movq %r15, %xmm5 and $0xffffffffffffffc0, %rcx vmovaps %ymm5, (%rcx) nop xor $20225, %r9 lea addresses_D_ht+0x1a93b, %r14 nop nop cmp $29250, %r13 movl $0x61626364, (%r14) nop nop nop add %r9, %r9 lea addresses_UC_ht+0x1c743, %rsi nop nop nop nop nop sub %r14, %r14 vmovups (%rsi), %ymm4 vextracti128 $1, %ymm4, %xmm4 vpextrq $1, %xmm4, %rdi nop nop nop nop nop xor $38825, %rdi pop %rsi pop %rdx pop %rdi pop %rcx pop %r9 pop %r15 pop %r14 pop %r13 pop %r11 ret .global s_faulty_load s_faulty_load: push %r10 push %r11 push %r14 push %rax push %rbx push %rdx // Faulty Load lea addresses_D+0x94bb, %r10 nop nop nop nop nop xor %r11, %r11 mov (%r10), %rax lea oracles, %rdx and $0xff, %rax shlq $12, %rax mov (%rdx,%rax,1), %rax pop %rdx pop %rbx pop %rax pop %r14 pop %r11 pop %r10 ret /* <gen_faulty_load> [REF] {'src': {'same': True, 'congruent': 0, 'NT': False, 'type': 'addresses_D', 'size': 32, 'AVXalign': False}, 'OP': 'LOAD'} [Faulty Load] {'src': {'same': True, 'congruent': 0, 'NT': False, 'type': 'addresses_D', 'size': 8, 'AVXalign': False}, 'OP': 'LOAD'} <gen_prepare_buffer> {'src': {'same': False, 'congruent': 5, 'NT': False, 'type': 'addresses_UC_ht', 'size': 4, 'AVXalign': False}, 'OP': 'LOAD'} {'src': {'same': False, 'congruent': 6, 'NT': False, 'type': 'addresses_D_ht', 'size': 8, 'AVXalign': False}, 'OP': 'LOAD'} {'OP': 'STOR', 'dst': {'same': True, 'congruent': 3, 'NT': False, 'type': 'addresses_UC_ht', 'size': 4, 'AVXalign': False}} {'OP': 'STOR', 'dst': {'same': False, 'congruent': 3, 'NT': False, 'type': 'addresses_normal_ht', 'size': 2, 'AVXalign': False}} {'src': {'same': False, 'congruent': 8, 'NT': False, 'type': 'addresses_normal_ht', 'size': 2, 'AVXalign': False}, 'OP': 'LOAD'} {'src': {'type': 'addresses_normal_ht', 'congruent': 6, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_WT_ht', 'congruent': 7, 'same': False}} {'src': {'type': 'addresses_normal_ht', 'congruent': 1, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_WT_ht', 'congruent': 7, 'same': False}} {'src': {'same': False, 'congruent': 2, 'NT': False, 'type': 'addresses_WC_ht', 'size': 1, 'AVXalign': False}, 'OP': 'LOAD'} {'OP': 'STOR', 'dst': {'same': False, 'congruent': 1, 'NT': False, 'type': 'addresses_WT_ht', 'size': 32, 'AVXalign': False}} {'src': {'type': 'addresses_WC_ht', 'congruent': 5, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_normal_ht', 'congruent': 2, 'same': True}} {'OP': 'STOR', 'dst': {'same': False, 'congruent': 3, 'NT': False, 'type': 'addresses_UC_ht', 'size': 32, 'AVXalign': True}} {'OP': 'STOR', 'dst': {'same': False, 'congruent': 6, 'NT': False, 'type': 'addresses_D_ht', 'size': 4, 'AVXalign': False}} {'src': {'same': True, 'congruent': 3, 'NT': False, 'type': 'addresses_UC_ht', 'size': 32, 'AVXalign': False}, 'OP': 'LOAD'} {'36': 21829} 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 */
#include "stdafx.h" #include "BandSteuerung.h" void BandSteuerung::GeschwindigkeitRegeln() { } BandSteuerung::BandSteuerung() { } BandSteuerung::~BandSteuerung() { }
; A022377: Fibonacci sequence beginning 2, 30. ; 2,30,32,62,94,156,250,406,656,1062,1718,2780,4498,7278,11776,19054,30830,49884,80714,130598,211312,341910,553222,895132,1448354,2343486,3791840,6135326,9927166,16062492 mov $1,1 mov $3,15 lpb $0,1 sub $0,1 mov $2,$1 mov $1,$3 add $3,$2 lpe add $1,1 mul $1,2 sub $1,4 div $1,2 mul $1,2 add $1,2
.global s_prepare_buffers s_prepare_buffers: push %r11 push %r12 push %r14 push %rax push %rbx push %rcx push %rdi push %rsi lea addresses_UC_ht+0x158c, %rax nop nop nop nop nop and $7856, %r12 and $0xffffffffffffffc0, %rax vmovaps (%rax), %ymm0 vextracti128 $0, %ymm0, %xmm0 vpextrq $0, %xmm0, %rbx nop nop nop nop and %rdi, %rdi lea addresses_WC_ht+0xa38c, %rsi lea addresses_D_ht+0x19c99, %rdi nop nop nop add %r11, %r11 mov $77, %rcx rep movsb nop nop nop dec %rax lea addresses_UC_ht+0x1e174, %rdi nop nop nop nop add $60354, %r12 mov $0x6162636465666768, %rbx movq %rbx, %xmm3 movups %xmm3, (%rdi) nop nop xor $1794, %rsi lea addresses_normal_ht+0xbf4c, %rsi lea addresses_D_ht+0x8d6c, %rdi nop nop nop nop sub $27029, %r14 mov $91, %rcx rep movsw nop nop dec %r14 lea addresses_normal_ht+0xb2cc, %rbx nop nop nop nop and %rdi, %rdi mov (%rbx), %r12d lfence lea addresses_WC_ht+0x934c, %rsi lea addresses_A_ht+0xfd8c, %rdi clflush (%rsi) nop xor %r14, %r14 mov $1, %rcx rep movsw nop nop cmp $37495, %r11 lea addresses_A_ht+0xc0c, %rax nop nop nop nop add %r14, %r14 mov (%rax), %r11 nop and %rbx, %rbx lea addresses_UC_ht+0x1758c, %rsi lea addresses_normal_ht+0x1a50c, %rdi nop nop nop nop and %rbx, %rbx mov $7, %rcx rep movsl nop nop add %rax, %rax lea addresses_WT_ht+0x1dd8c, %rsi lea addresses_A_ht+0xe088, %rdi nop nop sub $24397, %r11 mov $68, %rcx rep movsl add %rax, %rax lea addresses_normal_ht+0x17aac, %rsi xor %rcx, %rcx mov $0x6162636465666768, %r14 movq %r14, %xmm6 and $0xffffffffffffffc0, %rsi movntdq %xmm6, (%rsi) nop nop nop nop nop xor %r14, %r14 lea addresses_UC_ht+0x1d58c, %rdi nop nop xor %rax, %rax movups (%rdi), %xmm6 vpextrq $0, %xmm6, %rsi add %rbx, %rbx lea addresses_normal_ht+0xd478, %rsi nop and %rbx, %rbx mov (%rsi), %eax inc %r11 lea addresses_normal_ht+0x17e8c, %r11 and $47184, %r14 mov (%r11), %edi nop nop dec %rbx lea addresses_normal_ht+0x16d8c, %r14 nop nop sub %rdi, %rdi movb $0x61, (%r14) nop nop add %r14, %r14 pop %rsi pop %rdi pop %rcx pop %rbx pop %rax pop %r14 pop %r12 pop %r11 ret .global s_faulty_load s_faulty_load: push %r13 push %r15 push %r9 push %rbp push %rcx push %rdx push %rsi // Faulty Load lea addresses_D+0x1858c, %r15 nop nop sub %r13, %r13 mov (%r15), %rsi lea oracles, %rbp and $0xff, %rsi shlq $12, %rsi mov (%rbp,%rsi,1), %rsi pop %rsi pop %rdx pop %rcx pop %rbp pop %r9 pop %r15 pop %r13 ret /* <gen_faulty_load> [REF] {'src': {'same': False, 'congruent': 0, 'NT': False, 'type': 'addresses_D', 'size': 1, 'AVXalign': False}, 'OP': 'LOAD'} [Faulty Load] {'src': {'same': True, 'congruent': 0, 'NT': False, 'type': 'addresses_D', 'size': 8, 'AVXalign': False}, 'OP': 'LOAD'} <gen_prepare_buffer> {'src': {'same': True, 'congruent': 11, 'NT': False, 'type': 'addresses_UC_ht', 'size': 32, 'AVXalign': True}, 'OP': 'LOAD'} {'src': {'type': 'addresses_WC_ht', 'congruent': 8, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_D_ht', 'congruent': 0, 'same': False}} {'OP': 'STOR', 'dst': {'same': False, 'congruent': 2, 'NT': False, 'type': 'addresses_UC_ht', 'size': 16, 'AVXalign': False}} {'src': {'type': 'addresses_normal_ht', 'congruent': 5, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_D_ht', 'congruent': 3, 'same': False}} {'src': {'same': False, 'congruent': 5, 'NT': False, 'type': 'addresses_normal_ht', 'size': 4, 'AVXalign': True}, 'OP': 'LOAD'} {'src': {'type': 'addresses_WC_ht', 'congruent': 4, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_A_ht', 'congruent': 9, 'same': False}} {'src': {'same': False, 'congruent': 7, 'NT': False, 'type': 'addresses_A_ht', 'size': 8, 'AVXalign': False}, 'OP': 'LOAD'} {'src': {'type': 'addresses_UC_ht', 'congruent': 11, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_normal_ht', 'congruent': 5, 'same': False}} {'src': {'type': 'addresses_WT_ht', 'congruent': 9, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_A_ht', 'congruent': 2, 'same': False}} {'OP': 'STOR', 'dst': {'same': False, 'congruent': 5, 'NT': True, 'type': 'addresses_normal_ht', 'size': 16, 'AVXalign': False}} {'src': {'same': False, 'congruent': 11, 'NT': False, 'type': 'addresses_UC_ht', 'size': 16, 'AVXalign': False}, 'OP': 'LOAD'} {'src': {'same': False, 'congruent': 1, 'NT': False, 'type': 'addresses_normal_ht', 'size': 4, 'AVXalign': False}, 'OP': 'LOAD'} {'src': {'same': False, 'congruent': 8, 'NT': False, 'type': 'addresses_normal_ht', 'size': 4, 'AVXalign': False}, 'OP': 'LOAD'} {'OP': 'STOR', 'dst': {'same': False, 'congruent': 11, 'NT': False, 'type': 'addresses_normal_ht', 'size': 1, 'AVXalign': False}} {'36': 21829} 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 */
; A017073: a(n) = (8*n)^9. ; 0,134217728,68719476736,2641807540224,35184372088832,262144000000000,1352605460594688,5416169448144896,18014398509481984,51998697814228992,134217728000000000,316478381828866048,692533995824480256,1423311812421484544,2773078757450186752,5159780352000000000,9223372036854775808,15916595351771938816,26623333280885243904,43310409649448026112,68719476736000000000,106606463247835987968,162036931496379416576,241746618002717016064,354577405862133891072,512000000000000000000,728735647959800086528 pow $0,9 mul $0,134217728
// Assembler: KickAssembler 4.4 // jumping text .var irq_line = $d0 .var scr_clear_char = ' ' .var scr_clear_color = $0f .var screen = $400 .var colram = $d800 .var jump_start_row = 2 .var jump_start_col = 10 .var jump_rows = 14 .var jump_start = screen + jump_start_row * 40 + jump_start_col .var jump_start_colram = colram + jump_start_row * 40 + jump_start_col .var vic = $0 .var font = vic + $2000 .var debug = false BasicUpstart2(start) start: jsr scr_clear lda #$00 sta $d020 sta $d021 jsr text_init jsr irq_init jmp * // FIXME remove copy stuff if scroll is working text_init: ldx #$00 !l: lda jump_text, x sta jump_start, x lda #1 .for (var j = 0; j < jump_rows; j++) { sta jump_start_colram + j * 40, x } inx cpx #19 bne !l- // screen at $400, font bitmap at $2000 lda #%00011000 sta $d018 rts irq: asl $d019 .if (debug) { inc $d020 } jump_ptr: jsr jump .if (debug) { dec $d020 } pla tay pla tax pla rti jump: lda jump_ypos clc adc jump_vspeed and #$07 sta jump_ypos cmp jump_vspeed bmi !l+ !b: lda #%00011000 ora jump_ypos sta $d011 inc jump_vspeed rts !l: jsr move_down jmp !b- jump_up: lda jump_ypos sec sbc jump_vspeed //sbc #1 and #$07 sta jump_ypos cmp jump_vspeed bmi !l+ !b: lda #%00011000 ora jump_ypos sta $d011 dec jump_vspeed rts !l: jsr move_up lda #7 sec sbc jump_ypos sta jump_ypos jmp !b- move_down: .for (var j = jump_rows - 1; j >= 0; j--) { .for (var i = 0; i < 40 - jump_start_col; i++) { lda jump_start + i + 40 * j sta jump_start + i + 40 * j + 40 } } lda #' ' .for (var i = 0; i < 40 - jump_start_col; i++) { sta jump_start + i } inc jump_row lda #jump_rows cmp jump_row bne !l+ // reverse direction lda #0 sta jump_row lda #<jump_up sta jump_ptr + 1 lda #>jump_up sta jump_ptr + 2 lda #jump_rows sta jump_row !l: rts move_up: dec jump_row bne !l+ jmp !rev+ !l: .for (var j = 1; j <= jump_rows; j++) { .for (var i = 0; i < 40 - jump_start_col; i++) { lda jump_start + i + 40 * j sta jump_start + i + 40 * j - 40 } } lda #' ' .for (var i = 0; i < 40 - jump_start_col; i++) { sta jump_start + i + 40 * jump_rows } rts !rev: // reverse direction lda #1 sta jump_row sta jump_ypos lda #1 sta jump_vspeed // revert pointer lda #<jump sta jump_ptr + 1 lda #>jump sta jump_ptr + 2 rts jump_ypos: .byte 0 jump_vspeed: .byte 1 jump_row: .byte 0 #import "screen.asm" irq_init: sei lda #<irq sta $0314 lda #>irq sta $0315 asl $d019 lda #$7b sta $dc0d lda #$81 sta $d01a lda #%00011000 sta $d011 lda #irq_line sta $d012 cli rts .align $100 jump_text: .text "deze tekst springt!" .byte $ff * = font "font" .import binary "chars_02.64c", 2
Name: zel_gsub1_fra.asm Type: file Size: 3376 Last-Modified: '2016-05-13T04:20:48Z' SHA-1: DA0413A8DF0D642D4A281E896EAEA8B8205DD6CE Description: null
; A329827: Beatty sequence for (5+sqrt(37))/6. ; 1,3,5,7,9,11,12,14,16,18,20,22,24,25,27,29,31,33,35,36,38,40,42,44,46,48,49,51,53,55,57,59,60,62,64,66,68,70,72,73,75,77,79,81,83,84,86,88,90,92,94,96,97,99,101,103,105,107,108,110,112,114,116 add $0,1 mov $1,24 mul $1,$0 div $1,13
;实验4 2) 将 0:200~0:23F 传送数据 0~63(3FH),只用 9行代码 ; 分析 因为 内存偏移地址 是 200h 那么就用 寄存器数组的方式来做 assume cs:code code segment mov ax, 0 mov ds, ax mov bx, 0 mov cx, 40h s: mov 200[bx], bl inc bl loop s mov ax, 4c00h int 21h code ends end ;anwser ; assume cs:codesg ; codesg segment ; mov ax,20h mov ds,ax mov bx,0 ; mov cx,64 s:mov [bx],bl inc bx loop s ; mov ax,4c00h int 21h ; codesg ends ; end
; A154254: a(n) = 9n^2 - 8n + 2. ; 2,3,22,59,114,187,278,387,514,659,822,1003,1202,1419,1654,1907,2178,2467,2774,3099,3442,3803,4182,4579,4994,5427,5878,6347,6834,7339,7862,8403,8962,9539,10134,10747,11378,12027,12694,13379,14082,14803,15542,16299,17074,17867,18678,19507,20354,21219,22102,23003,23922,24859,25814,26787,27778,28787,29814,30859,31922,33003,34102,35219,36354,37507,38678,39867,41074,42299,43542,44803,46082,47379,48694,50027,51378,52747,54134,55539,56962,58403,59862,61339,62834,64347,65878,67427,68994,70579,72182 mov $1,9 mul $1,$0 sub $1,8 mul $1,$0 add $1,2 mov $0,$1
#include "Platform.inc" #include "FarCalls.inc" #include "Lcd.inc" #include "../LcdStates.inc" #include "TestFixture.inc" radix decimal udata expectedState res 1 StateAfterEnabledSecondTimeTest code global testArrange testArrange: fcall initialiseLcd fcall enableLcd banksel TMR0 movf TMR0, W banksel expectedState movwf expectedState banksel lcdState movwf lcdState testAct: fcall enableLcd testAssert: .assertStateIsRegister expectedState return end
#pragma once #include <eosio/chain/types.hpp> #include <eosio/chain/contract_types.hpp> namespace eosio { namespace chain { class apply_context; /** * @defgroup native_action_handlers Native Action Handlers */ ///@{ void apply_eosio_newaccount(apply_context&); void apply_eosio_updateauth(apply_context&); void apply_eosio_deleteauth(apply_context&); void apply_eosio_linkauth(apply_context&); void apply_eosio_unlinkauth(apply_context&); /* void apply_eosio_postrecovery(apply_context&); void apply_eosio_passrecovery(apply_context&); void apply_eosio_vetorecovery(apply_context&); */ void apply_eosio_setcode(apply_context&); void apply_eosio_setabi(apply_context&); void apply_eosio_canceldelay(apply_context&); // void apply_eosio_chipcounter(apply_context&); // void apply_eosio_enstandby(apply_context&); ///@} end action handlers } } /// namespace eosio::chain
<% from pwnlib.shellcraft.amd64.linux import syscall %> <%page args="name"/> <%docstring> Invokes the syscall uname. See 'man 2 uname' for more information. Arguments: name(utsname): name </%docstring> ${syscall('SYS_uname', name)}
.global s_prepare_buffers s_prepare_buffers: push %r10 push %r12 push %r15 push %r8 push %rax push %rcx push %rdi push %rsi lea addresses_A_ht+0x7543, %rcx nop nop add %r12, %r12 vmovups (%rcx), %ymm4 vextracti128 $0, %ymm4, %xmm4 vpextrq $1, %xmm4, %rsi nop sub $27186, %rax lea addresses_UC_ht+0x12e4d, %rcx nop nop nop xor $12098, %rax mov $0x6162636465666768, %r15 movq %r15, %xmm7 and $0xffffffffffffffc0, %rcx movaps %xmm7, (%rcx) nop nop nop nop sub %rsi, %rsi lea addresses_UC_ht+0x1097f, %rsi lea addresses_D_ht+0x11def, %rdi clflush (%rsi) cmp %rax, %rax mov $7, %rcx rep movsq nop cmp $10910, %r15 lea addresses_WC_ht+0x10ef, %rsi lea addresses_A_ht+0x1588b, %rdi nop nop dec %r8 mov $65, %rcx rep movsb nop dec %r12 lea addresses_A_ht+0x1d6f, %rsi nop nop nop nop nop cmp $21127, %r12 mov $0x6162636465666768, %r8 movq %r8, %xmm7 movups %xmm7, (%rsi) nop nop nop nop cmp %r8, %r8 lea addresses_WC_ht+0x1aef, %rsi lea addresses_A_ht+0x3daf, %rdi nop nop nop nop nop inc %r10 mov $86, %rcx rep movsb nop nop nop inc %rdi lea addresses_normal_ht+0xa50f, %rsi lea addresses_A_ht+0x1ebef, %rdi nop nop and $41666, %r15 mov $114, %rcx rep movsl nop cmp %rax, %rax pop %rsi pop %rdi pop %rcx pop %rax pop %r8 pop %r15 pop %r12 pop %r10 ret .global s_faulty_load s_faulty_load: push %r11 push %r14 push %r15 push %rbx push %rcx push %rdi push %rsi // Store lea addresses_A+0x176d7, %r15 nop nop nop nop nop cmp $18224, %r14 mov $0x5152535455565758, %rsi movq %rsi, %xmm2 vmovups %ymm2, (%r15) inc %rsi // Load lea addresses_A+0x96e7, %rdi clflush (%rdi) nop nop nop sub %rcx, %rcx vmovups (%rdi), %ymm0 vextracti128 $0, %ymm0, %xmm0 vpextrq $1, %xmm0, %r15 add $39535, %rcx // Faulty Load lea addresses_WT+0x67ef, %r11 nop nop nop xor $48504, %r15 movaps (%r11), %xmm1 vpextrq $0, %xmm1, %rsi lea oracles, %rcx and $0xff, %rsi shlq $12, %rsi mov (%rcx,%rsi,1), %rsi pop %rsi pop %rdi pop %rcx pop %rbx pop %r15 pop %r14 pop %r11 ret /* <gen_faulty_load> [REF] {'src': {'congruent': 0, 'AVXalign': False, 'same': False, 'size': 2, 'NT': False, 'type': 'addresses_WT'}, 'OP': 'LOAD'} {'OP': 'STOR', 'dst': {'congruent': 3, 'AVXalign': False, 'same': False, 'size': 32, 'NT': False, 'type': 'addresses_A'}} {'src': {'congruent': 1, 'AVXalign': False, 'same': False, 'size': 32, 'NT': False, 'type': 'addresses_A'}, 'OP': 'LOAD'} [Faulty Load] {'src': {'congruent': 0, 'AVXalign': True, 'same': True, 'size': 16, 'NT': False, 'type': 'addresses_WT'}, 'OP': 'LOAD'} <gen_prepare_buffer> {'src': {'congruent': 1, 'AVXalign': False, 'same': False, 'size': 32, 'NT': False, 'type': 'addresses_A_ht'}, 'OP': 'LOAD'} {'OP': 'STOR', 'dst': {'congruent': 1, 'AVXalign': True, 'same': False, 'size': 16, 'NT': False, 'type': 'addresses_UC_ht'}} {'src': {'congruent': 3, 'same': True, 'type': 'addresses_UC_ht'}, 'OP': 'REPM', 'dst': {'congruent': 9, 'same': False, 'type': 'addresses_D_ht'}} {'src': {'congruent': 7, 'same': False, 'type': 'addresses_WC_ht'}, 'OP': 'REPM', 'dst': {'congruent': 0, 'same': False, 'type': 'addresses_A_ht'}} {'OP': 'STOR', 'dst': {'congruent': 7, 'AVXalign': False, 'same': False, 'size': 16, 'NT': False, 'type': 'addresses_A_ht'}} {'src': {'congruent': 7, 'same': False, 'type': 'addresses_WC_ht'}, 'OP': 'REPM', 'dst': {'congruent': 2, 'same': False, 'type': 'addresses_A_ht'}} {'src': {'congruent': 4, 'same': False, 'type': 'addresses_normal_ht'}, 'OP': 'REPM', 'dst': {'congruent': 9, 'same': False, 'type': 'addresses_A_ht'}} {'00': 21829} 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 */
/* Copyright 2015 Google Inc. 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. ==============================================================================*/ // See docs in ../ops/array_ops.cc. #include <math.h> #include <algorithm> #include <numeric> #include "tensorflow/core/framework/op_kernel.h" #include "tensorflow/core/framework/tensor.h" #include "tensorflow/core/framework/types.h" #if GOOGLE_CUDA #include "tensorflow/core/platform/stream_executor.h" #endif // GOOGLE_CUDA namespace tensorflow { typedef Eigen::ThreadPoolDevice CPUDevice; typedef Eigen::GpuDevice GPUDevice; #if GOOGLE_CUDA template <typename T> struct CheckNumericsLaunch { void Run(const GPUDevice& d, const T* data, int size, int abnormal_detected[2]); }; #endif namespace { template <typename Device, typename T> class CheckNumericsOp; // Partial specialization for CPU template <typename T> class CheckNumericsOp<CPUDevice, T> : public OpKernel { public: explicit CheckNumericsOp(OpKernelConstruction* context) : OpKernel(context) { // message_ is used as the prefix for the assertion error message. For // instance, this can be the name of the input op that produced the tensor. OP_REQUIRES_OK(context, context->GetAttr("message", &message_)); } void Compute(OpKernelContext* context) override { // pass along the input to the output context->set_output(0, context->input(0)); auto in = context->input(0).flat<T>(); const T* data = in.data(); const int64 size = in.size(); // Check to see if any element of the tensor is NaN or Inf. int fp_props = std::accumulate(data, data + size, 0, [](const int& x, const T& y) { int result = x; if (Eigen::numext::isinf(y)) { result |= kInfBit; } else if (Eigen::numext::isnan(y)) { result |= kNaNBit; } return result; }); string status; if ((fp_props & kInfBit) && (fp_props & kNaNBit)) { status = "Inf and NaN"; } else { if (fp_props & kInfBit) { status = "Inf"; } if (fp_props & kNaNBit) { status = "NaN"; } } if (!status.empty()) { context->SetStatus(errors::InvalidArgument(message_, " : Tensor had ", status, " values")); } } private: string message_; static const int kInfBit = 0x01; static const int kNaNBit = 0x02; }; #if GOOGLE_CUDA // Partial specialization for GPU template <typename T> class CheckNumericsOp<GPUDevice, T> : public OpKernel { public: typedef GPUDevice Device; explicit CheckNumericsOp(OpKernelConstruction* context) : OpKernel(context) { // message_ is used as the prefix for the assertion error message. For // instance, this can be the name of the input op that produced the tensor. OP_REQUIRES_OK(context, context->GetAttr("message", &message_)); } void Compute(OpKernelContext* context) override { // pass along the input to the output context->set_output(0, context->input(0)); auto input = context->input(0).flat<T>(); // Allocate and initialize the elements to hold the check results const int abnormal_detected_size = 2; Tensor abnormal_detected; OP_REQUIRES_OK(context, context->allocate_temp( DT_INT32, TensorShape({abnormal_detected_size}), &abnormal_detected)); auto* stream = context->op_device_context()->stream(); OP_REQUIRES(context, stream, errors::Internal("No GPU stream available.")); perftools::gputools::DeviceMemoryBase abnormal_detected_ptr( abnormal_detected.flat<int>().data(), abnormal_detected.flat<int>().size()); stream->ThenMemset32(&abnormal_detected_ptr, 0, abnormal_detected.flat<int>().size() * sizeof(int)); // Call the Cuda kernels for the numerical checks const Device& d = context->eigen_device<Device>(); CheckNumericsLaunch<T>().Run(d, input.data(), input.size(), abnormal_detected.flat<int>().data()); // Copy the results from device to host AllocatorAttributes attr; attr.set_on_host(true); attr.set_gpu_compatible(true); Tensor abnormal_detected_out; OP_REQUIRES_OK(context, context->allocate_temp( DT_INT32, TensorShape({abnormal_detected_size}), &abnormal_detected_out, attr)); int* abnormal_detected_host = abnormal_detected_out.flat<int>().data(); stream->ThenMemcpy(abnormal_detected_host, abnormal_detected_ptr, abnormal_detected_size * sizeof(int)); stream->BlockHostUntilDone(); OP_REQUIRES(context, stream->ok(), errors::Internal("cudaMemcpy from device to host failed")); int is_nan = abnormal_detected_host[0]; int is_inf = abnormal_detected_host[1]; if (is_nan || is_inf) { string status; LOG(ERROR) << "abnormal_detected_host @" << abnormal_detected_host << " = {" << is_nan << ", " << is_inf << "} " << message_; // Results should always be 1 or 0. If we see anything else then // there has been some GPU memory corruption. CHECK_GE(is_nan, 0); CHECK_GE(is_inf, 0); CHECK_LE(is_nan, 1); CHECK_LE(is_inf, 1); if (is_nan && is_inf) { status = "Inf and NaN"; } else if (is_nan) { status = "NaN"; } else if (is_inf) { status = "Inf"; } context->SetStatus(errors::InvalidArgument(message_, " : Tensor had ", status, " values")); } } private: string message_; }; #endif // GOOGLE_CUDA } // namespace REGISTER_KERNEL_BUILDER(Name("CheckNumerics") .Device(DEVICE_CPU) .TypeConstraint<float>("T"), CheckNumericsOp<CPUDevice, float>); REGISTER_KERNEL_BUILDER(Name("CheckNumerics") .Device(DEVICE_CPU) .TypeConstraint<double>("T"), CheckNumericsOp<CPUDevice, double>); #if GOOGLE_CUDA REGISTER_KERNEL_BUILDER(Name("CheckNumerics") .Device(DEVICE_GPU) .TypeConstraint<float>("T"), CheckNumericsOp<GPUDevice, float>); REGISTER_KERNEL_BUILDER(Name("CheckNumerics") .Device(DEVICE_GPU) .TypeConstraint<double>("T"), CheckNumericsOp<GPUDevice, double>); #endif // GOOGLE_CUDA } // namespace tensorflow
; A288826: Binary representation of the diagonal from the origin to the corner of the n-th stage of growth of the two-dimensional cellular automaton defined by "Rule 515", based on the 5-celled von Neumann neighborhood. ; 1,11,101,1011,11011,110111,1110111,11101111,111101111,1111011111,11111011111,111110111111,1111110111111,11111101111111,111111101111111,1111111011111111,11111111011111111,111111110111111111,1111111110111111111,11111111101111111111,111111111101111111111,1111111111011111111111,11111111111011111111111,111111111110111111111111,1111111111110111111111111,11111111111101111111111111,111111111111101111111111111,1111111111111011111111111111,11111111111111011111111111111,111111111111110111111111111111 seq $0,288828 ; Decimal representation of the diagonal from the origin to the corner of the n-th stage of growth of the two-dimensional cellular automaton defined by "Rule 515", based on the 5-celled von Neumann neighborhood. seq $0,99820 ; Even nonnegative integers in base 2 (bisection of A007088). div $0,10
; A014731: Squares of even Lucas numbers. ; 4,16,324,5776,103684,1860496,33385284,599074576,10749957124,192900153616,3461452808004,62113250390416,1114577054219524,20000273725560976,358890350005878084,6440026026380244496,115561578124838522884,2073668380220713167376,37210469265847998489924,667714778405043259651216,11981655542024930675232004,215002084978043708894524816,3858055874062761829426214724,69230003648151669220777340176,1242282009792667284144565908484,22291846172619859445381409012496,400010949097364802732720796316484 seq $0,100233 ; a(n) = Lucas(3*n) - 1. add $0,1 pow $0,2
; A170797: a(n) = n^10*(n^5+1)/2. ; 0,1,16896,7203978,537395200,15263671875,235122725376,2373921992596,17592722915328,102947309439525,500005000000000,2088637053420126,7703541745975296,25593015436291303,77784192406233600,218947233515625000,576461302059237376,1431212533751858121,3373322093472342528,7590566580470528050,16384005120000000000,34061167631416330251,68440047287667421696,133317638445451229628,252428673179713536000,465661334991455078125,838629741726410789376,1477156456220982896646,2548827825717578825728,4314594584152708870575,7174453795245000000000,11732631405736486455376,18889466494428534276096,29969473515222202903953,46897940308125698982400,72442041020737910156250,110536961688445898981376,166723136380199839753171,248727588396574619324928,367230813355772023472100,536870917242880000000000,777549164207098610520501,1116116076203179423658496,1588535193704718987599278,2242643047963191528652800,3141649371496887333984375,4368551719058959909413376,6031674201709750237272696,8271581756414390465200128,11269670185242262192737625,15258789111328125000000000,20536321139906490114250626,27480217136286886535888896,36568576031958045045000603,48403459489545118951027200,63739748805475263554687500,83519985491878541971685376,108916290134446516946500221,141380628656050757330211328,182704893535866871580472150,235092492590330880000000000,301243392624191657732370751,384454852894033017210487296,488740407478037883356192928,618970020219150889752985600,781034745150840368525390625,982039683837579490639397376,1230529543868464908960680746,1536751675250859191818518528,1912962099523922927741880675,2373780756383876245000000000,2936602981320368452438605876,3622075102576448457142173696,4454643014599563401441661253,5463183656584537190015808000,6681730507894706726074218750,8150305516931178674770149376,9915871316962140603061259271,12033419162837412280972681728,14567209758506934495829568200,17592186049784709120000000000,21195579143686934486675681001,25478730799693758698796868096,30559158435190934765159290578,36572891313928878767171174400,43677109560469571550654296875,52053120884298784509205541376,61909713424787581665583880796,73486926963981347196321660928,87060288921090502858799539725,102945566064758422005000000000,121504087782349590744985321126,143148702056821894265027690496,168350431050006193785502365903,197645899406771668927857164800,231645615109813529991093750000,271043189963696160976851173376,316625594605265899366384390321,369284551363555596855928816128,430029177365863366197417200250 mov $2,$0 pow $2,5 mov $1,$2 pow $1,2 mul $2,$1 add $1,$2 div $1,2 mov $0,$1
;------------------------------------------------------------------------------ ; ; Copyright (c) 2016 - 2020, Intel Corporation. All rights reserved.<BR> ; SPDX-License-Identifier: BSD-2-Clause-Patent ; ; ; Module Name: ; ; SecEntry.nasm ; ; Abstract: ; ; This is the code that goes from real-mode to protected mode. ; It consumes the reset vector. ; ;------------------------------------------------------------------------------ SECTION .text extern ASM_PFX(SecStartup) extern ASM_PFX(TempRamInitParams) extern ASM_PFX(PcdGet32(PcdStage1StackSize)) extern ASM_PFX(PcdGet32(PcdStage1DataSize)) extern ASM_PFX(PcdGet32(PcdStage1StackBaseOffset)) global ASM_PFX(_ModuleEntryPoint) ASM_PFX(_ModuleEntryPoint): movd mm0, eax ; ; RDI: time stamp ; ; ; Add a dummy reference to TempRamInitParams to prevent ; compiler from removing this symbol ; mov rax, ASM_PFX(TempRamInitParams) ; ; Setup stack ; ECX: Bootloader stack base ; EDX: Bootloader stack top ; mov rax, ASM_PFX(PcdGet32(PcdStage1StackBaseOffset)) mov eax, dword [rax] mov rsp, rax add rsp, rcx mov rax, ASM_PFX(PcdGet32(PcdStage1StackSize)) mov eax, dword [rax] add rsp, rax ; ; Check stage1 stack base offset ; xor rbx, rbx ; Use EBX for Status mov rax, ASM_PFX(PcdGet32(PcdStage1DataSize)) mov eax, dword [rax] add rax, rsp cmp rax, rdx jle CheckStackRangeDone ; ; Error in stack range ; bts rbx, 1 ; Set BIT1 in Status mov rsp, rdx ; Set ESP to the end CheckStackRangeDone: ; ; CpuBist error check ; movd eax, mm0 emms ; Exit MMX Instruction cmp eax, 0 jz CheckStatusDone ; ; Error in CpuBist ; bts rbx, 0 ; Set BIT0 in Status CheckStatusDone: ; Setup HOB push rbx ; Status push rdi ; TimeStamp[0] [63:0] shl rdx, 32 ; Move CarTop to high 32bit add rdx, rcx ; Add back CarBase push rdx mov rcx, rsp ; Argument 1 sub rsp, 32 ; 32 bytes shadow store for x64 and esp, 0xfffffff0 ; Align stack to 16 bytes call ASM_PFX(SecStartup) ; Jump to C code jmp $
; A335285: a(n) is the greatest possible greatest part of any partition of n into prime parts. ; Submitted by Jon Maiga ; 2,3,2,5,3,7,5,7,7,11,7,13,11,13,13,17,13,19,17,19,19,23,19,23,23,23,23,29,23,31,29,31,31,31,31,37,31,37,37,41,37,43,41,43,43,47,43,47,47,47,47,53,47,53,53,53,53,59,53,61,59,61,61,61,61,67,61,67,67,71,67,73,71,73,73,73,73,79,73,79,79,83,79,83,83,83,83,89,83,89,89,89,89,89,89,97,89,97,97,101 seq $0,115659 ; Permutation of natural numbers generated by 2-rowed array shown below. trn $0,1 seq $0,151799 ; Version 2 of the "previous prime" function: largest prime < n. mul $0,2 sub $0,4 div $0,2 add $0,2
; multi-segment executable file template. data segment tab db "lol$" msg1 db "yes$" msg2 db "no$" ends stack segment dw 128 dup(0) ends code segment start: mov ax, data mov ds, ax mov es, ax mov si,0 mov ax,0 mov cx,0 for: mov al,tab[si] mov dx,ax push dx inc cx inc si cmp al,36 jne for boucle0 : pop dx dec cx mov si,0 mov bx,0 boucle: pop dx mov bl,tab[si] cmp dx,bx jne fin2 inc si loop boucle jmp fin1 fin2: mov dl,offset msg2 mov ah,09h int 21h jmp fin fin1: mov dl,offset msg1 mov ah,09h int 21h fin: mov ax, 4c00h ; exit to operating system. int 21h ends end start ; set entry point and stop the assembler.
COMMENT @---------------------------------------------------------------------- Copyright (c) GeoWorks 1989 -- All Rights Reserved PROJECT: Preferences MODULE: Link FILE: prefLink.asm AUTHOR: Chris Boyke ROUTINES: Name Description ---- ----------- REVISION HISTORY: Name Date Description ---- ---- ----------- CDB 3/8/92 Initial Version DESCRIPTION: $Id: prefui.asm,v 1.1 97/04/05 01:42:43 newdeal Exp $ -----------------------------------------------------------------------------@ ;------------------------------------------------------------------------------ ; Common GEODE stuff ;------------------------------------------------------------------------------ include geos.def include heap.def include geode.def include resource.def include ec.def include library.def include object.def include graphics.def include gstring.def include win.def include char.def include initfile.def ;----------------------------------------------------------------------------- ; Libraries used ;----------------------------------------------------------------------------- UseLib ui.def UseLib config.def ;----------------------------------------------------------------------------- ; DEF FILES ;----------------------------------------------------------------------------- include prefui.def include prefui.rdef ;----------------------------------------------------------------------------- ; VARIABLES ;----------------------------------------------------------------------------- idata segment PrefUIDialogClass idata ends ;----------------------------------------------------------------------------- ; CODE ;----------------------------------------------------------------------------- PrefUICode segment resource COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% PrefUIGetPrefUITree %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Return the root of the UI tree for "Preferences" CALLED BY: PrefMgr PASS: nothing RETURN: dx:ax - OD of root of tree DESTROYED: nothing PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- CDB 3/27/92 Initial version. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ PrefUIGetPrefUITree proc far mov dx, handle PrefUIRoot mov ax, offset PrefUIRoot ret PrefUIGetPrefUITree endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% PrefUIGetMonikerList %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: CALLED BY: PASS: RETURN: ^ldx:ax - server moniker list DESTROYED: nothing PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- CDB 4/ 8/92 Initial version. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ PrefUIGetMonikerList proc far mov dx, handle PrefUIMonikerList mov ax, offset PrefUIMonikerList ret PrefUIGetMonikerList endp ;------------------------------------------------------------- COMMENT @---------------------------------------------------------------------- MESSAGE: PrefUIDialogApply -- MSG_GEN_APPLY for PrefUIDialogClass DESCRIPTION: Add functionality on APPLY PASS: *ds:si - instance data es - segment of PrefUIDialogClass ax - The message RETURN: DESTROYED: bx, si, di, ds, es (message handler) REGISTER/STACK USAGE: PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Tony 8/16/92 Initial version ------------------------------------------------------------------------------@ PrefUIDialogApply method dynamic PrefUIDialogClass, MSG_GEN_APPLY mov di, offset PrefUIDialogClass call ObjCallSuperNoLock ; delete the "ui options" category segmov ds, cs mov si, offset uiFeaturesCategory call InitFileDeleteCategory ret PrefUIDialogApply endm uiFeaturesCategory char "uiFeatures", 0 PrefUICode ends
; A314220: Coordination sequence Gal.5.306.1 where G.u.t.v denotes the coordination sequence for a vertex of type v in tiling number t in the Galebach list of u-uniform tilings. ; Submitted by Jamie Morken(s2.) ; 1,5,11,17,22,28,34,39,45,51,56,61,67,73,78,84,90,95,101,107,112,117,123,129,134,140,146,151,157,163,168,173,179,185,190,196,202,207,213,219,224,229,235,241,246,252,258,263,269,275 mov $1,1 mov $4,$0 mul $4,3 mov $5,$0 lpb $0 mov $0,2 mul $0,$4 mov $2,$4 mod $2,10 add $0,$2 div $0,10 mov $1,$0 lpe mov $3,$5 mul $3,5 add $1,$3 mov $0,$1
#include <ice/Lexer.hpp> #include <ice/Encoding.hpp> #include <ice/Utility.hpp> #include <algorithm> #include <sstream> #include <utility> #ifdef _MSC_VER # pragma warning(disable: 4100) #endif namespace ice { const std::unordered_map<TokenType, std::string> Token::m_TypeNames = { #define E(x) { TokenType:: x, #x } #include <ice/detail/TokenType.txt> #undef E }; Token::Token(TokenType type, std::string word, std::size_t line, std::size_t column) noexcept : m_Type(type), m_Word(std::move(word)), m_Line(line), m_Column(column) { } Token::Token(const Token& token) : m_Type(token.m_Type), m_Word(token.m_Word), m_Line(token.m_Line), m_Column(token.m_Column) { } Token::Token(Token&& token) noexcept : m_Type(token.m_Type), m_Word(std::move(token.m_Word)), m_Line(token.m_Line), m_Column(token.m_Column) { token.m_Type = TokenType::None; token.m_Line = token.m_Column = 0; } Token& Token::operator=(const Token& token) { m_Type = token.m_Type; m_Word = token.m_Word; m_Line = token.m_Line; m_Column = token.m_Column; return *this; } Token& Token::operator=(Token&& token) noexcept { m_Type = token.m_Type; m_Word = std::move(token.m_Word); m_Line = token.m_Line; m_Column = token.m_Column; token.m_Type = TokenType::None; token.m_Line = token.m_Column = 0; return *this; } TokenType Token::Type() const noexcept { return m_Type; } void Token::Type(TokenType newType) noexcept { m_Type = newType; } std::string Token::Word() const { return m_Word; } void Token::Word(std::string newWord) noexcept { m_Word = std::move(newWord); } std::size_t Token::Line() const noexcept { return m_Line; } void Token::Line(std::size_t newLine) noexcept { m_Line = newLine; } std::size_t Token::Column() const noexcept { return m_Column; } void Token::Column(std::size_t newColumn) noexcept { m_Column = newColumn; } std::string Token::ToString() const { std::ostringstream oss; oss << m_Line << ':' << m_Column + 1 << ": " << m_TypeNames.at(m_Type) << "(\"" << m_Word << "\")"; return oss.str(); } } namespace ice { const std::unordered_map<std::string, TokenType> Lexer::m_Keywords = { #define EOrg(type1, type2, str) { str, TokenType::type1##type2 } #define E(type, str) EOrg(type, Keyword, str) E(Module, "module"), E(Import, "import"), E(Int8, "int8"), E(Int16, "int16"), E(Int32, "int32"), E(Int64, "int64"), E(Int128, "int128"), E(IntPtr, "intptr"), E(UInt8, "uint8"), E(UInt16, "uint16"), E(UInt32, "uint32"), E(UInt64, "uint64"), E(UInt128, "uint128"), E(UIntPtr, "uintptr"), E(Float32, "float32"), E(Float64, "float64"), E(Number, "number"), E(Void, "void"), E(Bool, "bool"), E(True, "true"), E(False, "false"), E(Char, "char"), E(Char8, "char8"), E(String, "string"), E(String8, "string8"), E(Null, "null"), E(Any, "any"), E(Object, "object"), E(Enum, "enum"), E(Struct, "struct"), E(LowerSelf, "self"), E(UpperSelf, "Self"), E(Trait, "trait"), E(Impl, "impl"), E(Pub, "pub"), E(Priv, "priv"), E(Is, "is"), E(As, "as"), E(Function, "function"), E(Return, "return"), E(Operator, "operator"), E(If, "if"), E(Else, "else"), E(Switch, "switch"), E(Case, "case"), E(For, "for"), E(While, "while"), E(Do, "do"), E(Break, "break"), E(Continue, "continue"), E(Var, "var"), E(Let, "let"), E(Mut, "mut"), E(New, "new"), E(Throw, "throw"), E(Try, "try"), E(Catch, "catch"), E(Finally, "finally"), E(SizeOf, "sizeof"), E(TypeOf, "typeof"), #undef EOrg #undef E }; const std::unordered_map<char, const std::array<TokenType, 5>> Lexer::m_Operators = { { '+', { TokenType::Plus, TokenType::Increment, TokenType::PlusAssign } }, { '-', { TokenType::Minus, TokenType::Decrement, TokenType::MinusAssign, TokenType::None, TokenType::RightwardsArrow } }, { '*', { TokenType::Multiply, TokenType::Exponent, TokenType::MultiplyAssign, TokenType::ExponentAssign } }, { '/', { TokenType::Divide, TokenType::None, TokenType::DivideAssign } }, { '%', { TokenType::Modulo, TokenType::None, TokenType::ModuloAssign } }, { '=', { TokenType::Assign, TokenType::Equal, TokenType::Equal, TokenType::None, TokenType::RightwardsDoubleArrow } }, { '!', { TokenType::Not, TokenType::None, TokenType::NotEqual } }, { '>', { TokenType::Greater, TokenType::BitLeftShift, TokenType::GreaterEqual, TokenType::BitLeftShiftAssign } }, { '<', { TokenType::Less, TokenType::BitRightShift, TokenType::LessEqual, TokenType::BitRightShiftAssign } }, { '&', { TokenType::BitAnd, TokenType::And, TokenType::BitAndAssign } }, { '|', { TokenType::BitOr, TokenType::Or, TokenType::BitOrAssign } }, { '^', { TokenType::BitXor, TokenType::None, TokenType::BitXorAssign } }, { '~', { TokenType::BitNot } }, { '{', { TokenType::LeftBrace } }, { '}', { TokenType::RightBrace } }, { '(', { TokenType::LeftParen } }, { ')', { TokenType::RightParen } }, { '[', { TokenType::LeftBigParen } }, { ']', { TokenType::RightBigParen } }, { '.', { TokenType::Dot } }, { ',', { TokenType::Comma } }, { ';', { TokenType::Semicolon } }, { ':', { TokenType::Colon } }, { '?', { TokenType::Question } }, }; const std::unordered_map<TokenType, std::string> Lexer::m_OperatorWords = { #define E(type, str) { TokenType:: type, str } E(Plus, "+"), E(Increment, "++"), E(PlusAssign, "+="), E(Minus, "-"), E(Decrement, "--"), E(MinusAssign, "-="), E(Multiply, "*"), E(MultiplyAssign, "*="), E(Divide, "/"), E(DivideAssign, "/="), E(Modulo, "%"), E(ModuloAssign, "%="), E(Exponent, "**"), E(ExponentAssign, "**="), E(Assign, "="), E(Equal, "=="), E(NotEqual, "!="), E(Greater, ">"), E(GreaterEqual, ">="), E(Less, "<"), E(LessEqual, "<="), E(And, "&&"), E(Or, "||"), E(Not, "!"), E(BitAnd, "&"), E(BitAndAssign, "&="), E(BitOr, "|"), E(BitOrAssign, "|="), E(BitXor, "^"), E(BitXorAssign, "^="), E(BitNot, "~"), E(BitLeftShift, "<<"), E(BitLeftShiftAssign, "<<="), E(BitRightShift, ">>"), E(BitRightShiftAssign, ">>="), E(RightwardsArrow, "->"), E(RightwardsDoubleArrow, "=>"), E(LeftBrace, "{"), E(RightBrace, "}"), E(LeftParen, "("), E(RightParen, ")"), E(LeftBigParen, "["), E(RightBigParen, "]"), E(Dot, "."), E(Comma, ","), E(Semicolon, ";"), E(Colon, ":"), E(Question, "?"), #undef E }; Lexer::Lexer(Lexer&& lexer) noexcept : m_Tokens(std::move(lexer.m_Tokens)) { } Lexer& Lexer::operator=(Lexer&& lexer) noexcept { m_Tokens = std::move(lexer.m_Tokens); return *this; } void Lexer::Clear() noexcept { m_Tokens.clear(); } bool Lexer::IsEmpty() const noexcept { return m_Tokens.empty(); } std::vector<Token> Lexer::Tokens() noexcept { return std::move(m_Tokens); } bool Lexer::Lex(const std::string& sourceName, const std::string& source, Messages& messages) { Clear(); m_SourceName = &sourceName; m_Messages = &messages; std::size_t m_LineBegin = 0; std::size_t nextLineBegin = source.find('\n'); do { m_LineSource = source.substr(m_LineBegin, nextLineBegin - m_LineBegin); if (!m_LineSource.empty() && m_LineSource.back() == '\r') { m_LineSource.erase(m_LineSource.end() - 1); } for (m_Column = 0; m_Column < m_LineSource.size(); m_Column += m_CharLength) { m_Char = m_LineSource[m_Column]; m_CharLength = GetCodepointLength(m_Char); if (!Next()) break; } AddIdentifier(); if (!m_IsNoEOLToken) { m_Tokens.push_back(Token(TokenType::EOL, "", m_Line, m_LineSource.size())); m_IsNoEOLToken = false; } ++m_Line; m_IsComment = false; } while ((m_LineBegin = nextLineBegin + 1, nextLineBegin = source.find('\n', m_LineBegin), m_LineBegin) != 0); const bool result = !m_HasError; m_Line = 1; m_IsIdentifier = false; m_IsNoEOLToken = false; m_HasError = false; return result; } ISINLINE bool Lexer::Next() { if (!m_IsIdentifier && IsDigit(m_Char)) { LexInteger(); } else if (m_Char == '"' || m_Char == '\'') { AddIdentifier(); LexStringOrCharacter(m_Char); } else if (IsWhitespace(m_Char)) { AddIdentifier(); } else if (m_Char == '\\') { AddIdentifier(); m_Messages->AddError("unexpected EOL", *m_SourceName, m_Line, m_Column, CreateMessageNoteLocation(m_LineSource, m_Line, m_Column, 1)); m_HasError = true; } else if (m_Char == '\r') { if (m_Column + 1 != m_LineSource.size()) { AddIdentifier(); m_Messages->AddError("unexpected carriage return token", *m_SourceName, m_Line, m_Column); m_Messages->AddNote("is the EOL in this source file a CR?", *m_SourceName); m_HasError = true; } else { m_IsNoEOLToken = true; } } else { if (LexSpecialCharacters()) { switch (m_Char) { case '`': case '@': case '#': case '$': AddIdentifier(); m_Messages->AddError("unexpected invalid token", *m_SourceName, m_Line, m_Column, CreateMessageNoteLocation(m_LineSource, m_Line, m_Column, 1)); m_HasError = true; return true; } if (m_IsIdentifier) { m_IdentifierEnd += m_CharLength; } else { m_IsIdentifier = true; m_IdentifierBegin = m_Column; m_IdentifierEnd = m_Column + m_CharLength; } } else if (AddIdentifier() && m_Tokens.size() > 1) { std::iter_swap(m_Tokens.end() - 1, m_Tokens.end() - 2); } } return !m_IsComment; } ISINLINE bool Lexer::ReadDigits(std::size_t& end, bool(*digitChecker1)(char), bool(*digitChecker2)(char), const char* base) { bool hasError = false; while (end < m_LineSource.size() && (digitChecker1(m_LineSource[end]) || m_LineSource[end] == '\'')) { if (!digitChecker2(m_LineSource[end])) { m_Messages->AddError(Format("invalid digit '%' in % constant", { std::string(1, m_LineSource[end]), base }), *m_SourceName, m_Line, end, CreateMessageNoteLocation(m_LineSource, m_Line, end, 1)); hasError = true; } else if (m_LineSource[end - 1] == '\'' && m_LineSource[end] == '\'') { m_Messages->AddError("expected digit token after '\''", *m_SourceName, m_Line, end, CreateMessageNoteLocation(m_LineSource, m_Line, end, 1)); hasError = true; } ++end; } if (hasError) { m_Column = end - 1; return m_HasError = true; } else if (m_LineSource[end - 1] == '\'') { m_Messages->AddError("expected digit token after '\''", *m_SourceName, m_Line, end - 1, CreateMessageNoteLocation(m_LineSource, m_Line, end - 1, 1)); m_Column = end - 1; return m_HasError = true; } else return false; } ISINLINE bool Lexer::ReadBinDigits(std::size_t& end) { return ReadDigits(end, IsDigit, [](char c) { return c <= '1'; }, "binary"); } ISINLINE bool Lexer::ReadOctDigits(std::size_t& end) { return ReadDigits(end, IsDigit, [](char c) { return c <= '7'; }, "octal"); } ISINLINE bool Lexer::ReadDecDigits(std::size_t& end) { return ReadDigits(end, IsDigit, [](char) { return true; }, nullptr); } ISINLINE bool Lexer::ReadHexDigits(std::size_t& end) { return ReadDigits(end, [](char c) { return IsDigit(c) || ('a' <= c && c <= 'f') || ('A' <= c && c <= 'F'); }, [](char) { return true; }, nullptr); } ISINLINE bool Lexer::ReadScientificNotation(std::size_t& end) { if (end == m_LineSource.size() || (m_LineSource[end] != 'e' && m_LineSource[end] != 'E')) return false; else if (end + 1 < m_LineSource.size()) { const std::size_t oldEnd = ++end; if (ReadDecDigits(end)) return true; else if (oldEnd == end) { if (m_LineSource[oldEnd] == '+' || m_LineSource[oldEnd] == '-') { return ReadDecDigits(++end); } else { m_Messages->AddError(Format("expected digit token after '%'", { std::string(1, m_LineSource[oldEnd]) }), *m_SourceName, m_Line, oldEnd, CreateMessageNoteLocation(m_LineSource, m_Line, oldEnd, 1)); m_Column = end - 1; return m_HasError = true; } } else return false; } else { m_Messages->AddError(Format("expected digit token after '%'", { std::string(1, m_LineSource[end]) }), *m_SourceName, m_Line, end, CreateMessageNoteLocation(m_LineSource, m_Line, end, 1)); m_Column = end - 1; return m_HasError = true; } } ISINLINE void Lexer::LexInteger() { if (m_LineSource[m_Column] != '0') { LexDecIntegerOrDecimal(); } else { LexOtherIntegers(); } } ISINLINE void Lexer::LexDecIntegerOrDecimal() { std::size_t endColumn = m_Column + 1; if (ReadDecDigits(endColumn)) return; else if (endColumn < m_LineSource.size() && m_LineSource[endColumn] == '.') { const std::size_t oldEndColumn = ++endColumn; if (ReadDecDigits(endColumn)) return; else if (oldEndColumn == endColumn) { m_Messages->AddError("expected digit token after '.'", *m_SourceName, m_Line, endColumn - 1, CreateMessageNoteLocation(m_LineSource, m_Line, endColumn - 1, 1)); m_HasError = true; if (m_LineSource[endColumn] == 'e' || m_LineSource[endColumn] == 'E') { ++endColumn; ReadDecDigits(endColumn); } } else if (!ReadScientificNotation(endColumn)) { m_Tokens.push_back(Token(TokenType::Decimal, m_LineSource.substr(m_Column, endColumn - m_Column), m_Line, m_Column)); } } else { const std::size_t oldEndColumn = endColumn; if (!ReadScientificNotation(endColumn)) { m_Tokens.push_back(Token(endColumn == oldEndColumn ? TokenType::DecInteger : TokenType::Decimal, m_LineSource.substr(m_Column, endColumn - m_Column), m_Line, m_Column)); } } m_Column = endColumn - 1; } ISINLINE void Lexer::LexOtherIntegers() { if (m_Column + 1 == m_LineSource.size()) { m_Tokens.push_back(Token(TokenType::DecInteger, "0", m_Line, m_Column)); return; } std::size_t endColumn = m_Column + 1; bool(Lexer::*digitReader)(std::size_t&) = nullptr; TokenType base; switch (m_LineSource[endColumn]) { case 'b': case 'B': digitReader = &Lexer::ReadBinDigits; base = TokenType::BinInteger; break; case 'x': case 'X': digitReader = &Lexer::ReadHexDigits; base = TokenType::HexInteger; break; default: ReadDecDigits(endColumn); if (endColumn < m_LineSource.size() && (m_LineSource[endColumn] == '.' || m_LineSource[endColumn] == 'e' || m_LineSource[endColumn] == 'E')) { LexDecIntegerOrDecimal(); return; } else { digitReader = &Lexer::ReadOctDigits; base = TokenType::OctInteger; --endColumn; break; } } if ((this->*digitReader)(++endColumn)) return; else if (endColumn < m_LineSource.size()) { const std::size_t oldEndColumn = endColumn; if (m_LineSource[endColumn] == '.') { ReadDecDigits(++endColumn); } else goto done; if (m_LineSource[endColumn] == 'e' || m_LineSource[endColumn] == 'E') { ReadScientificNotation(endColumn); } else if (oldEndColumn == endColumn) goto done; m_Messages->AddError(Format("invalid suffix '%' in integer constant", { m_LineSource.substr(oldEndColumn, endColumn - oldEndColumn) }), *m_SourceName, m_Line, oldEndColumn, CreateMessageNoteLocation(m_LineSource, m_Line, oldEndColumn, endColumn - oldEndColumn)); m_Column = endColumn - 1; m_HasError = true; } else { done: m_Tokens.push_back(Token(base, m_LineSource.substr(m_Column, endColumn - m_Column), m_Line, m_Column)); m_Column = endColumn - 1; } } ISINLINE void Lexer::LexStringOrCharacter(char quotation) { std::size_t endColumn = m_Column + 1; do { while (endColumn < m_LineSource.size() && m_LineSource[endColumn] != quotation) ++endColumn; if (endColumn == m_LineSource.size()) { m_Messages->AddError("unexcpeted EOL", *m_SourceName, m_Line, endColumn - 1, CreateMessageNoteLocation(m_LineSource, m_Line, endColumn - 1, 1)); m_Column = endColumn - 1; m_HasError = true; return; } ++endColumn; } while (m_LineSource[endColumn - 2] == '\\'); m_Tokens.push_back(Token(quotation == '"' ? TokenType::String : TokenType::Character, m_LineSource.substr(m_Column, endColumn - m_Column), m_Line, m_Column)); m_Column = endColumn - 1; } ISINLINE bool Lexer::LexSpecialCharacters() { const auto iter = m_Operators.find(m_Char); if (iter == m_Operators.end()) return true; int index = 0; std::size_t column = m_Column + 1; if (column < m_LineSource.size()) { const char nextChar = m_LineSource[column]; if (m_Char == nextChar) { if (++column < m_LineSource.size() && m_LineSource[column] == '=' && iter->second[3] != TokenType::None) { index = 3; ++column; } else if (iter->second[1] != TokenType::None) { index = 1; } } else if (nextChar == '=' && iter->second[2] != TokenType::None) ++column, index = 2; else if (nextChar == '>' && iter->second[4] != TokenType::None) ++column, index = 4; } m_Tokens.push_back(Token(iter->second[index], m_OperatorWords.at(iter->second[index]), m_Line, m_Column)); m_Column = column - 1; return false; } ISINLINE bool Lexer::AddIdentifier() { if (!m_IsIdentifier) return false; m_IsIdentifier = false; m_Tokens.push_back(Token(TokenType::Identifer, m_LineSource.substr(m_IdentifierBegin, m_IdentifierEnd - m_IdentifierBegin), m_Line, m_IdentifierBegin)); if (auto iter = m_Keywords.find(m_Tokens.back().Word()); iter != m_Keywords.end()) { m_Tokens.back().Type(iter->second); } return true; } }
; A104270: a(n) = 2^(n-2)*(C(n,2)+2). ; 1,3,10,32,96,272,736,1920,4864,12032,29184,69632,163840,380928,876544,1998848,4521984,10158080,22675456,50331648,111149056,244318208,534773760,1166016512,2533359616,5486149632,11844714496,25501368320,54760833024,117306294272,250718715904,534723428352,1138166333440,2418066587648,5128190951424,10857677324288,22952305229824,48447231098880,102117142429696,214954523230208,451899279015936,948878534770688,1990116046274560,4169348092526592,8725724278030336 mov $1,1 mov $2,$0 mov $3,$0 lpb $2,1 mul $1,2 lpb $3,1 add $1,$3 sub $3,1 lpe sub $2,1 lpe
_ln: file format elf32-i386 Disassembly of section .text: 00000000 <main>: #include "stat.h" #include "user.h" int main(int argc, char *argv[]) { 0: f3 0f 1e fb endbr32 4: 8d 4c 24 04 lea 0x4(%esp),%ecx 8: 83 e4 f0 and $0xfffffff0,%esp b: ff 71 fc pushl -0x4(%ecx) if(argc != 3){ e: 83 39 03 cmpl $0x3,(%ecx) { 11: 55 push %ebp 12: 89 e5 mov %esp,%ebp 14: 53 push %ebx 15: 51 push %ecx 16: 8b 59 04 mov 0x4(%ecx),%ebx if(argc != 3){ 19: 74 13 je 2e <main+0x2e> printf(2, "Usage: ln old new\n"); 1b: 52 push %edx 1c: 52 push %edx 1d: 68 88 07 00 00 push $0x788 22: 6a 02 push $0x2 24: e8 f7 03 00 00 call 420 <printf> exit(); 29: e8 95 02 00 00 call 2c3 <exit> } if(link(argv[1], argv[2]) < 0) 2e: 50 push %eax 2f: 50 push %eax 30: ff 73 08 pushl 0x8(%ebx) 33: ff 73 04 pushl 0x4(%ebx) 36: e8 e8 02 00 00 call 323 <link> 3b: 83 c4 10 add $0x10,%esp 3e: 85 c0 test %eax,%eax 40: 78 05 js 47 <main+0x47> printf(2, "link %s %s: failed\n", argv[1], argv[2]); exit(); 42: e8 7c 02 00 00 call 2c3 <exit> printf(2, "link %s %s: failed\n", argv[1], argv[2]); 47: ff 73 08 pushl 0x8(%ebx) 4a: ff 73 04 pushl 0x4(%ebx) 4d: 68 9b 07 00 00 push $0x79b 52: 6a 02 push $0x2 54: e8 c7 03 00 00 call 420 <printf> 59: 83 c4 10 add $0x10,%esp 5c: eb e4 jmp 42 <main+0x42> 5e: 66 90 xchg %ax,%ax 00000060 <strcpy>: #include "user.h" #include "x86.h" char* strcpy(char *s, const char *t) { 60: f3 0f 1e fb endbr32 64: 55 push %ebp char *os; os = s; while((*s++ = *t++) != 0) 65: 31 c0 xor %eax,%eax { 67: 89 e5 mov %esp,%ebp 69: 53 push %ebx 6a: 8b 4d 08 mov 0x8(%ebp),%ecx 6d: 8b 5d 0c mov 0xc(%ebp),%ebx while((*s++ = *t++) != 0) 70: 0f b6 14 03 movzbl (%ebx,%eax,1),%edx 74: 88 14 01 mov %dl,(%ecx,%eax,1) 77: 83 c0 01 add $0x1,%eax 7a: 84 d2 test %dl,%dl 7c: 75 f2 jne 70 <strcpy+0x10> ; return os; } 7e: 89 c8 mov %ecx,%eax 80: 5b pop %ebx 81: 5d pop %ebp 82: c3 ret 83: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 8a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 00000090 <strcmp>: int strcmp(const char *p, const char *q) { 90: f3 0f 1e fb endbr32 94: 55 push %ebp 95: 89 e5 mov %esp,%ebp 97: 53 push %ebx 98: 8b 4d 08 mov 0x8(%ebp),%ecx 9b: 8b 55 0c mov 0xc(%ebp),%edx while(*p && *p == *q) 9e: 0f b6 01 movzbl (%ecx),%eax a1: 0f b6 1a movzbl (%edx),%ebx a4: 84 c0 test %al,%al a6: 75 19 jne c1 <strcmp+0x31> a8: eb 26 jmp d0 <strcmp+0x40> aa: 8d b6 00 00 00 00 lea 0x0(%esi),%esi b0: 0f b6 41 01 movzbl 0x1(%ecx),%eax p++, q++; b4: 83 c1 01 add $0x1,%ecx b7: 83 c2 01 add $0x1,%edx while(*p && *p == *q) ba: 0f b6 1a movzbl (%edx),%ebx bd: 84 c0 test %al,%al bf: 74 0f je d0 <strcmp+0x40> c1: 38 d8 cmp %bl,%al c3: 74 eb je b0 <strcmp+0x20> return (uchar)*p - (uchar)*q; c5: 29 d8 sub %ebx,%eax } c7: 5b pop %ebx c8: 5d pop %ebp c9: c3 ret ca: 8d b6 00 00 00 00 lea 0x0(%esi),%esi d0: 31 c0 xor %eax,%eax return (uchar)*p - (uchar)*q; d2: 29 d8 sub %ebx,%eax } d4: 5b pop %ebx d5: 5d pop %ebp d6: c3 ret d7: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi de: 66 90 xchg %ax,%ax 000000e0 <strlen>: uint strlen(const char *s) { e0: f3 0f 1e fb endbr32 e4: 55 push %ebp e5: 89 e5 mov %esp,%ebp e7: 8b 55 08 mov 0x8(%ebp),%edx int n; for(n = 0; s[n]; n++) ea: 80 3a 00 cmpb $0x0,(%edx) ed: 74 21 je 110 <strlen+0x30> ef: 31 c0 xor %eax,%eax f1: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi f8: 83 c0 01 add $0x1,%eax fb: 80 3c 02 00 cmpb $0x0,(%edx,%eax,1) ff: 89 c1 mov %eax,%ecx 101: 75 f5 jne f8 <strlen+0x18> ; return n; } 103: 89 c8 mov %ecx,%eax 105: 5d pop %ebp 106: c3 ret 107: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 10e: 66 90 xchg %ax,%ax for(n = 0; s[n]; n++) 110: 31 c9 xor %ecx,%ecx } 112: 5d pop %ebp 113: 89 c8 mov %ecx,%eax 115: c3 ret 116: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 11d: 8d 76 00 lea 0x0(%esi),%esi 00000120 <memset>: void* memset(void *dst, int c, uint n) { 120: f3 0f 1e fb endbr32 124: 55 push %ebp 125: 89 e5 mov %esp,%ebp 127: 57 push %edi 128: 8b 55 08 mov 0x8(%ebp),%edx } static inline void stosb(void *addr, int data, int cnt) { asm volatile("cld; rep stosb" : 12b: 8b 4d 10 mov 0x10(%ebp),%ecx 12e: 8b 45 0c mov 0xc(%ebp),%eax 131: 89 d7 mov %edx,%edi 133: fc cld 134: f3 aa rep stos %al,%es:(%edi) stosb(dst, c, n); return dst; } 136: 89 d0 mov %edx,%eax 138: 5f pop %edi 139: 5d pop %ebp 13a: c3 ret 13b: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 13f: 90 nop 00000140 <strchr>: char* strchr(const char *s, char c) { 140: f3 0f 1e fb endbr32 144: 55 push %ebp 145: 89 e5 mov %esp,%ebp 147: 8b 45 08 mov 0x8(%ebp),%eax 14a: 0f b6 4d 0c movzbl 0xc(%ebp),%ecx for(; *s; s++) 14e: 0f b6 10 movzbl (%eax),%edx 151: 84 d2 test %dl,%dl 153: 75 16 jne 16b <strchr+0x2b> 155: eb 21 jmp 178 <strchr+0x38> 157: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 15e: 66 90 xchg %ax,%ax 160: 0f b6 50 01 movzbl 0x1(%eax),%edx 164: 83 c0 01 add $0x1,%eax 167: 84 d2 test %dl,%dl 169: 74 0d je 178 <strchr+0x38> if(*s == c) 16b: 38 d1 cmp %dl,%cl 16d: 75 f1 jne 160 <strchr+0x20> return (char*)s; return 0; } 16f: 5d pop %ebp 170: c3 ret 171: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi return 0; 178: 31 c0 xor %eax,%eax } 17a: 5d pop %ebp 17b: c3 ret 17c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 00000180 <gets>: char* gets(char *buf, int max) { 180: f3 0f 1e fb endbr32 184: 55 push %ebp 185: 89 e5 mov %esp,%ebp 187: 57 push %edi 188: 56 push %esi int i, cc; char c; for(i=0; i+1 < max; ){ 189: 31 f6 xor %esi,%esi { 18b: 53 push %ebx 18c: 89 f3 mov %esi,%ebx 18e: 83 ec 1c sub $0x1c,%esp 191: 8b 7d 08 mov 0x8(%ebp),%edi for(i=0; i+1 < max; ){ 194: eb 33 jmp 1c9 <gets+0x49> 196: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 19d: 8d 76 00 lea 0x0(%esi),%esi cc = read(0, &c, 1); 1a0: 83 ec 04 sub $0x4,%esp 1a3: 8d 45 e7 lea -0x19(%ebp),%eax 1a6: 6a 01 push $0x1 1a8: 50 push %eax 1a9: 6a 00 push $0x0 1ab: e8 2b 01 00 00 call 2db <read> if(cc < 1) 1b0: 83 c4 10 add $0x10,%esp 1b3: 85 c0 test %eax,%eax 1b5: 7e 1c jle 1d3 <gets+0x53> break; buf[i++] = c; 1b7: 0f b6 45 e7 movzbl -0x19(%ebp),%eax 1bb: 83 c7 01 add $0x1,%edi 1be: 88 47 ff mov %al,-0x1(%edi) if(c == '\n' || c == '\r') 1c1: 3c 0a cmp $0xa,%al 1c3: 74 23 je 1e8 <gets+0x68> 1c5: 3c 0d cmp $0xd,%al 1c7: 74 1f je 1e8 <gets+0x68> for(i=0; i+1 < max; ){ 1c9: 83 c3 01 add $0x1,%ebx 1cc: 89 fe mov %edi,%esi 1ce: 3b 5d 0c cmp 0xc(%ebp),%ebx 1d1: 7c cd jl 1a0 <gets+0x20> 1d3: 89 f3 mov %esi,%ebx break; } buf[i] = '\0'; return buf; } 1d5: 8b 45 08 mov 0x8(%ebp),%eax buf[i] = '\0'; 1d8: c6 03 00 movb $0x0,(%ebx) } 1db: 8d 65 f4 lea -0xc(%ebp),%esp 1de: 5b pop %ebx 1df: 5e pop %esi 1e0: 5f pop %edi 1e1: 5d pop %ebp 1e2: c3 ret 1e3: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 1e7: 90 nop 1e8: 8b 75 08 mov 0x8(%ebp),%esi 1eb: 8b 45 08 mov 0x8(%ebp),%eax 1ee: 01 de add %ebx,%esi 1f0: 89 f3 mov %esi,%ebx buf[i] = '\0'; 1f2: c6 03 00 movb $0x0,(%ebx) } 1f5: 8d 65 f4 lea -0xc(%ebp),%esp 1f8: 5b pop %ebx 1f9: 5e pop %esi 1fa: 5f pop %edi 1fb: 5d pop %ebp 1fc: c3 ret 1fd: 8d 76 00 lea 0x0(%esi),%esi 00000200 <stat>: int stat(const char *n, struct stat *st) { 200: f3 0f 1e fb endbr32 204: 55 push %ebp 205: 89 e5 mov %esp,%ebp 207: 56 push %esi 208: 53 push %ebx int fd; int r; fd = open(n, O_RDONLY); 209: 83 ec 08 sub $0x8,%esp 20c: 6a 00 push $0x0 20e: ff 75 08 pushl 0x8(%ebp) 211: e8 ed 00 00 00 call 303 <open> if(fd < 0) 216: 83 c4 10 add $0x10,%esp 219: 85 c0 test %eax,%eax 21b: 78 2b js 248 <stat+0x48> return -1; r = fstat(fd, st); 21d: 83 ec 08 sub $0x8,%esp 220: ff 75 0c pushl 0xc(%ebp) 223: 89 c3 mov %eax,%ebx 225: 50 push %eax 226: e8 f0 00 00 00 call 31b <fstat> close(fd); 22b: 89 1c 24 mov %ebx,(%esp) r = fstat(fd, st); 22e: 89 c6 mov %eax,%esi close(fd); 230: e8 b6 00 00 00 call 2eb <close> return r; 235: 83 c4 10 add $0x10,%esp } 238: 8d 65 f8 lea -0x8(%ebp),%esp 23b: 89 f0 mov %esi,%eax 23d: 5b pop %ebx 23e: 5e pop %esi 23f: 5d pop %ebp 240: c3 ret 241: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi return -1; 248: be ff ff ff ff mov $0xffffffff,%esi 24d: eb e9 jmp 238 <stat+0x38> 24f: 90 nop 00000250 <atoi>: int atoi(const char *s) { 250: f3 0f 1e fb endbr32 254: 55 push %ebp 255: 89 e5 mov %esp,%ebp 257: 53 push %ebx 258: 8b 55 08 mov 0x8(%ebp),%edx int n; n = 0; while('0' <= *s && *s <= '9') 25b: 0f be 02 movsbl (%edx),%eax 25e: 8d 48 d0 lea -0x30(%eax),%ecx 261: 80 f9 09 cmp $0x9,%cl n = 0; 264: b9 00 00 00 00 mov $0x0,%ecx while('0' <= *s && *s <= '9') 269: 77 1a ja 285 <atoi+0x35> 26b: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 26f: 90 nop n = n*10 + *s++ - '0'; 270: 83 c2 01 add $0x1,%edx 273: 8d 0c 89 lea (%ecx,%ecx,4),%ecx 276: 8d 4c 48 d0 lea -0x30(%eax,%ecx,2),%ecx while('0' <= *s && *s <= '9') 27a: 0f be 02 movsbl (%edx),%eax 27d: 8d 58 d0 lea -0x30(%eax),%ebx 280: 80 fb 09 cmp $0x9,%bl 283: 76 eb jbe 270 <atoi+0x20> return n; } 285: 89 c8 mov %ecx,%eax 287: 5b pop %ebx 288: 5d pop %ebp 289: c3 ret 28a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 00000290 <memmove>: void* memmove(void *vdst, const void *vsrc, int n) { 290: f3 0f 1e fb endbr32 294: 55 push %ebp 295: 89 e5 mov %esp,%ebp 297: 57 push %edi 298: 8b 45 10 mov 0x10(%ebp),%eax 29b: 8b 55 08 mov 0x8(%ebp),%edx 29e: 56 push %esi 29f: 8b 75 0c mov 0xc(%ebp),%esi char *dst; const char *src; dst = vdst; src = vsrc; while(n-- > 0) 2a2: 85 c0 test %eax,%eax 2a4: 7e 0f jle 2b5 <memmove+0x25> 2a6: 01 d0 add %edx,%eax dst = vdst; 2a8: 89 d7 mov %edx,%edi 2aa: 8d b6 00 00 00 00 lea 0x0(%esi),%esi *dst++ = *src++; 2b0: a4 movsb %ds:(%esi),%es:(%edi) while(n-- > 0) 2b1: 39 f8 cmp %edi,%eax 2b3: 75 fb jne 2b0 <memmove+0x20> return vdst; } 2b5: 5e pop %esi 2b6: 89 d0 mov %edx,%eax 2b8: 5f pop %edi 2b9: 5d pop %ebp 2ba: c3 ret 000002bb <fork>: name: \ movl $SYS_ ## name, %eax; \ int $T_SYSCALL; \ ret SYSCALL(fork) 2bb: b8 01 00 00 00 mov $0x1,%eax 2c0: cd 40 int $0x40 2c2: c3 ret 000002c3 <exit>: SYSCALL(exit) 2c3: b8 02 00 00 00 mov $0x2,%eax 2c8: cd 40 int $0x40 2ca: c3 ret 000002cb <wait>: SYSCALL(wait) 2cb: b8 03 00 00 00 mov $0x3,%eax 2d0: cd 40 int $0x40 2d2: c3 ret 000002d3 <pipe>: SYSCALL(pipe) 2d3: b8 04 00 00 00 mov $0x4,%eax 2d8: cd 40 int $0x40 2da: c3 ret 000002db <read>: SYSCALL(read) 2db: b8 05 00 00 00 mov $0x5,%eax 2e0: cd 40 int $0x40 2e2: c3 ret 000002e3 <write>: SYSCALL(write) 2e3: b8 10 00 00 00 mov $0x10,%eax 2e8: cd 40 int $0x40 2ea: c3 ret 000002eb <close>: SYSCALL(close) 2eb: b8 15 00 00 00 mov $0x15,%eax 2f0: cd 40 int $0x40 2f2: c3 ret 000002f3 <kill>: SYSCALL(kill) 2f3: b8 06 00 00 00 mov $0x6,%eax 2f8: cd 40 int $0x40 2fa: c3 ret 000002fb <exec>: SYSCALL(exec) 2fb: b8 07 00 00 00 mov $0x7,%eax 300: cd 40 int $0x40 302: c3 ret 00000303 <open>: SYSCALL(open) 303: b8 0f 00 00 00 mov $0xf,%eax 308: cd 40 int $0x40 30a: c3 ret 0000030b <mknod>: SYSCALL(mknod) 30b: b8 11 00 00 00 mov $0x11,%eax 310: cd 40 int $0x40 312: c3 ret 00000313 <unlink>: SYSCALL(unlink) 313: b8 12 00 00 00 mov $0x12,%eax 318: cd 40 int $0x40 31a: c3 ret 0000031b <fstat>: SYSCALL(fstat) 31b: b8 08 00 00 00 mov $0x8,%eax 320: cd 40 int $0x40 322: c3 ret 00000323 <link>: SYSCALL(link) 323: b8 13 00 00 00 mov $0x13,%eax 328: cd 40 int $0x40 32a: c3 ret 0000032b <mkdir>: SYSCALL(mkdir) 32b: b8 14 00 00 00 mov $0x14,%eax 330: cd 40 int $0x40 332: c3 ret 00000333 <chdir>: SYSCALL(chdir) 333: b8 09 00 00 00 mov $0x9,%eax 338: cd 40 int $0x40 33a: c3 ret 0000033b <dup>: SYSCALL(dup) 33b: b8 0a 00 00 00 mov $0xa,%eax 340: cd 40 int $0x40 342: c3 ret 00000343 <getpid>: SYSCALL(getpid) 343: b8 0b 00 00 00 mov $0xb,%eax 348: cd 40 int $0x40 34a: c3 ret 0000034b <sbrk>: SYSCALL(sbrk) 34b: b8 0c 00 00 00 mov $0xc,%eax 350: cd 40 int $0x40 352: c3 ret 00000353 <sleep>: SYSCALL(sleep) 353: b8 0d 00 00 00 mov $0xd,%eax 358: cd 40 int $0x40 35a: c3 ret 0000035b <uptime>: SYSCALL(uptime) 35b: b8 0e 00 00 00 mov $0xe,%eax 360: cd 40 int $0x40 362: c3 ret 00000363 <proc_dump>: SYSCALL(proc_dump) 363: b8 16 00 00 00 mov $0x16,%eax 368: cd 40 int $0x40 36a: c3 ret 36b: 66 90 xchg %ax,%ax 36d: 66 90 xchg %ax,%ax 36f: 90 nop 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: 83 ec 3c sub $0x3c,%esp 379: 89 4d c4 mov %ecx,-0x3c(%ebp) uint x; neg = 0; if(sgn && xx < 0){ neg = 1; x = -xx; 37c: 89 d1 mov %edx,%ecx { 37e: 89 45 b8 mov %eax,-0x48(%ebp) if(sgn && xx < 0){ 381: 85 d2 test %edx,%edx 383: 0f 89 7f 00 00 00 jns 408 <printint+0x98> 389: f6 45 08 01 testb $0x1,0x8(%ebp) 38d: 74 79 je 408 <printint+0x98> neg = 1; 38f: c7 45 bc 01 00 00 00 movl $0x1,-0x44(%ebp) x = -xx; 396: f7 d9 neg %ecx } else { x = xx; } i = 0; 398: 31 db xor %ebx,%ebx 39a: 8d 75 d7 lea -0x29(%ebp),%esi 39d: 8d 76 00 lea 0x0(%esi),%esi do{ buf[i++] = digits[x % base]; 3a0: 89 c8 mov %ecx,%eax 3a2: 31 d2 xor %edx,%edx 3a4: 89 cf mov %ecx,%edi 3a6: f7 75 c4 divl -0x3c(%ebp) 3a9: 0f b6 92 b8 07 00 00 movzbl 0x7b8(%edx),%edx 3b0: 89 45 c0 mov %eax,-0x40(%ebp) 3b3: 89 d8 mov %ebx,%eax 3b5: 8d 5b 01 lea 0x1(%ebx),%ebx }while((x /= base) != 0); 3b8: 8b 4d c0 mov -0x40(%ebp),%ecx buf[i++] = digits[x % base]; 3bb: 88 14 1e mov %dl,(%esi,%ebx,1) }while((x /= base) != 0); 3be: 39 7d c4 cmp %edi,-0x3c(%ebp) 3c1: 76 dd jbe 3a0 <printint+0x30> if(neg) 3c3: 8b 4d bc mov -0x44(%ebp),%ecx 3c6: 85 c9 test %ecx,%ecx 3c8: 74 0c je 3d6 <printint+0x66> buf[i++] = '-'; 3ca: c6 44 1d d8 2d movb $0x2d,-0x28(%ebp,%ebx,1) buf[i++] = digits[x % base]; 3cf: 89 d8 mov %ebx,%eax buf[i++] = '-'; 3d1: ba 2d 00 00 00 mov $0x2d,%edx while(--i >= 0) 3d6: 8b 7d b8 mov -0x48(%ebp),%edi 3d9: 8d 5c 05 d7 lea -0x29(%ebp,%eax,1),%ebx 3dd: eb 07 jmp 3e6 <printint+0x76> 3df: 90 nop 3e0: 0f b6 13 movzbl (%ebx),%edx 3e3: 83 eb 01 sub $0x1,%ebx write(fd, &c, 1); 3e6: 83 ec 04 sub $0x4,%esp 3e9: 88 55 d7 mov %dl,-0x29(%ebp) 3ec: 6a 01 push $0x1 3ee: 56 push %esi 3ef: 57 push %edi 3f0: e8 ee fe ff ff call 2e3 <write> while(--i >= 0) 3f5: 83 c4 10 add $0x10,%esp 3f8: 39 de cmp %ebx,%esi 3fa: 75 e4 jne 3e0 <printint+0x70> putc(fd, buf[i]); } 3fc: 8d 65 f4 lea -0xc(%ebp),%esp 3ff: 5b pop %ebx 400: 5e pop %esi 401: 5f pop %edi 402: 5d pop %ebp 403: c3 ret 404: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi neg = 0; 408: c7 45 bc 00 00 00 00 movl $0x0,-0x44(%ebp) 40f: eb 87 jmp 398 <printint+0x28> 411: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 418: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 41f: 90 nop 00000420 <printf>: // Print to the given fd. Only understands %d, %x, %p, %s. void printf(int fd, const char *fmt, ...) { 420: f3 0f 1e fb endbr32 424: 55 push %ebp 425: 89 e5 mov %esp,%ebp 427: 57 push %edi 428: 56 push %esi 429: 53 push %ebx 42a: 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++){ 42d: 8b 75 0c mov 0xc(%ebp),%esi 430: 0f b6 1e movzbl (%esi),%ebx 433: 84 db test %bl,%bl 435: 0f 84 b4 00 00 00 je 4ef <printf+0xcf> ap = (uint*)(void*)&fmt + 1; 43b: 8d 45 10 lea 0x10(%ebp),%eax 43e: 83 c6 01 add $0x1,%esi write(fd, &c, 1); 441: 8d 7d e7 lea -0x19(%ebp),%edi state = 0; 444: 31 d2 xor %edx,%edx ap = (uint*)(void*)&fmt + 1; 446: 89 45 d0 mov %eax,-0x30(%ebp) 449: eb 33 jmp 47e <printf+0x5e> 44b: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 44f: 90 nop 450: 89 55 d4 mov %edx,-0x2c(%ebp) c = fmt[i] & 0xff; if(state == 0){ if(c == '%'){ state = '%'; 453: ba 25 00 00 00 mov $0x25,%edx if(c == '%'){ 458: 83 f8 25 cmp $0x25,%eax 45b: 74 17 je 474 <printf+0x54> write(fd, &c, 1); 45d: 83 ec 04 sub $0x4,%esp 460: 88 5d e7 mov %bl,-0x19(%ebp) 463: 6a 01 push $0x1 465: 57 push %edi 466: ff 75 08 pushl 0x8(%ebp) 469: e8 75 fe ff ff call 2e3 <write> 46e: 8b 55 d4 mov -0x2c(%ebp),%edx } else { putc(fd, c); 471: 83 c4 10 add $0x10,%esp for(i = 0; fmt[i]; i++){ 474: 0f b6 1e movzbl (%esi),%ebx 477: 83 c6 01 add $0x1,%esi 47a: 84 db test %bl,%bl 47c: 74 71 je 4ef <printf+0xcf> c = fmt[i] & 0xff; 47e: 0f be cb movsbl %bl,%ecx 481: 0f b6 c3 movzbl %bl,%eax if(state == 0){ 484: 85 d2 test %edx,%edx 486: 74 c8 je 450 <printf+0x30> } } else if(state == '%'){ 488: 83 fa 25 cmp $0x25,%edx 48b: 75 e7 jne 474 <printf+0x54> if(c == 'd'){ 48d: 83 f8 64 cmp $0x64,%eax 490: 0f 84 9a 00 00 00 je 530 <printf+0x110> printint(fd, *ap, 10, 1); ap++; } else if(c == 'x' || c == 'p'){ 496: 81 e1 f7 00 00 00 and $0xf7,%ecx 49c: 83 f9 70 cmp $0x70,%ecx 49f: 74 5f je 500 <printf+0xe0> printint(fd, *ap, 16, 0); ap++; } else if(c == 's'){ 4a1: 83 f8 73 cmp $0x73,%eax 4a4: 0f 84 d6 00 00 00 je 580 <printf+0x160> s = "(null)"; while(*s != 0){ putc(fd, *s); s++; } } else if(c == 'c'){ 4aa: 83 f8 63 cmp $0x63,%eax 4ad: 0f 84 8d 00 00 00 je 540 <printf+0x120> putc(fd, *ap); ap++; } else if(c == '%'){ 4b3: 83 f8 25 cmp $0x25,%eax 4b6: 0f 84 b4 00 00 00 je 570 <printf+0x150> write(fd, &c, 1); 4bc: 83 ec 04 sub $0x4,%esp 4bf: c6 45 e7 25 movb $0x25,-0x19(%ebp) 4c3: 6a 01 push $0x1 4c5: 57 push %edi 4c6: ff 75 08 pushl 0x8(%ebp) 4c9: e8 15 fe ff ff call 2e3 <write> putc(fd, c); } else { // Unknown % sequence. Print it to draw attention. putc(fd, '%'); putc(fd, c); 4ce: 88 5d e7 mov %bl,-0x19(%ebp) write(fd, &c, 1); 4d1: 83 c4 0c add $0xc,%esp 4d4: 6a 01 push $0x1 4d6: 83 c6 01 add $0x1,%esi 4d9: 57 push %edi 4da: ff 75 08 pushl 0x8(%ebp) 4dd: e8 01 fe ff ff call 2e3 <write> for(i = 0; fmt[i]; i++){ 4e2: 0f b6 5e ff movzbl -0x1(%esi),%ebx putc(fd, c); 4e6: 83 c4 10 add $0x10,%esp } state = 0; 4e9: 31 d2 xor %edx,%edx for(i = 0; fmt[i]; i++){ 4eb: 84 db test %bl,%bl 4ed: 75 8f jne 47e <printf+0x5e> } } } 4ef: 8d 65 f4 lea -0xc(%ebp),%esp 4f2: 5b pop %ebx 4f3: 5e pop %esi 4f4: 5f pop %edi 4f5: 5d pop %ebp 4f6: c3 ret 4f7: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 4fe: 66 90 xchg %ax,%ax printint(fd, *ap, 16, 0); 500: 83 ec 0c sub $0xc,%esp 503: b9 10 00 00 00 mov $0x10,%ecx 508: 6a 00 push $0x0 50a: 8b 5d d0 mov -0x30(%ebp),%ebx 50d: 8b 45 08 mov 0x8(%ebp),%eax 510: 8b 13 mov (%ebx),%edx 512: e8 59 fe ff ff call 370 <printint> ap++; 517: 89 d8 mov %ebx,%eax 519: 83 c4 10 add $0x10,%esp state = 0; 51c: 31 d2 xor %edx,%edx ap++; 51e: 83 c0 04 add $0x4,%eax 521: 89 45 d0 mov %eax,-0x30(%ebp) 524: e9 4b ff ff ff jmp 474 <printf+0x54> 529: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi printint(fd, *ap, 10, 1); 530: 83 ec 0c sub $0xc,%esp 533: b9 0a 00 00 00 mov $0xa,%ecx 538: 6a 01 push $0x1 53a: eb ce jmp 50a <printf+0xea> 53c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi putc(fd, *ap); 540: 8b 5d d0 mov -0x30(%ebp),%ebx write(fd, &c, 1); 543: 83 ec 04 sub $0x4,%esp putc(fd, *ap); 546: 8b 03 mov (%ebx),%eax write(fd, &c, 1); 548: 6a 01 push $0x1 ap++; 54a: 83 c3 04 add $0x4,%ebx write(fd, &c, 1); 54d: 57 push %edi 54e: ff 75 08 pushl 0x8(%ebp) putc(fd, *ap); 551: 88 45 e7 mov %al,-0x19(%ebp) write(fd, &c, 1); 554: e8 8a fd ff ff call 2e3 <write> ap++; 559: 89 5d d0 mov %ebx,-0x30(%ebp) 55c: 83 c4 10 add $0x10,%esp state = 0; 55f: 31 d2 xor %edx,%edx 561: e9 0e ff ff ff jmp 474 <printf+0x54> 566: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 56d: 8d 76 00 lea 0x0(%esi),%esi putc(fd, c); 570: 88 5d e7 mov %bl,-0x19(%ebp) write(fd, &c, 1); 573: 83 ec 04 sub $0x4,%esp 576: e9 59 ff ff ff jmp 4d4 <printf+0xb4> 57b: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 57f: 90 nop s = (char*)*ap; 580: 8b 45 d0 mov -0x30(%ebp),%eax 583: 8b 18 mov (%eax),%ebx ap++; 585: 83 c0 04 add $0x4,%eax 588: 89 45 d0 mov %eax,-0x30(%ebp) if(s == 0) 58b: 85 db test %ebx,%ebx 58d: 74 17 je 5a6 <printf+0x186> while(*s != 0){ 58f: 0f b6 03 movzbl (%ebx),%eax state = 0; 592: 31 d2 xor %edx,%edx while(*s != 0){ 594: 84 c0 test %al,%al 596: 0f 84 d8 fe ff ff je 474 <printf+0x54> 59c: 89 75 d4 mov %esi,-0x2c(%ebp) 59f: 89 de mov %ebx,%esi 5a1: 8b 5d 08 mov 0x8(%ebp),%ebx 5a4: eb 1a jmp 5c0 <printf+0x1a0> s = "(null)"; 5a6: bb af 07 00 00 mov $0x7af,%ebx while(*s != 0){ 5ab: 89 75 d4 mov %esi,-0x2c(%ebp) 5ae: b8 28 00 00 00 mov $0x28,%eax 5b3: 89 de mov %ebx,%esi 5b5: 8b 5d 08 mov 0x8(%ebp),%ebx 5b8: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 5bf: 90 nop write(fd, &c, 1); 5c0: 83 ec 04 sub $0x4,%esp s++; 5c3: 83 c6 01 add $0x1,%esi 5c6: 88 45 e7 mov %al,-0x19(%ebp) write(fd, &c, 1); 5c9: 6a 01 push $0x1 5cb: 57 push %edi 5cc: 53 push %ebx 5cd: e8 11 fd ff ff call 2e3 <write> while(*s != 0){ 5d2: 0f b6 06 movzbl (%esi),%eax 5d5: 83 c4 10 add $0x10,%esp 5d8: 84 c0 test %al,%al 5da: 75 e4 jne 5c0 <printf+0x1a0> 5dc: 8b 75 d4 mov -0x2c(%ebp),%esi state = 0; 5df: 31 d2 xor %edx,%edx 5e1: e9 8e fe ff ff jmp 474 <printf+0x54> 5e6: 66 90 xchg %ax,%ax 5e8: 66 90 xchg %ax,%ax 5ea: 66 90 xchg %ax,%ax 5ec: 66 90 xchg %ax,%ax 5ee: 66 90 xchg %ax,%ax 000005f0 <free>: static Header base; static Header *freep; void free(void *ap) { 5f0: f3 0f 1e fb endbr32 5f4: 55 push %ebp Header *bp, *p; bp = (Header*)ap - 1; for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 5f5: a1 64 0a 00 00 mov 0xa64,%eax { 5fa: 89 e5 mov %esp,%ebp 5fc: 57 push %edi 5fd: 56 push %esi 5fe: 53 push %ebx 5ff: 8b 5d 08 mov 0x8(%ebp),%ebx 602: 8b 10 mov (%eax),%edx bp = (Header*)ap - 1; 604: 8d 4b f8 lea -0x8(%ebx),%ecx for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 607: 39 c8 cmp %ecx,%eax 609: 73 15 jae 620 <free+0x30> 60b: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 60f: 90 nop 610: 39 d1 cmp %edx,%ecx 612: 72 14 jb 628 <free+0x38> if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) 614: 39 d0 cmp %edx,%eax 616: 73 10 jae 628 <free+0x38> { 618: 89 d0 mov %edx,%eax for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 61a: 8b 10 mov (%eax),%edx 61c: 39 c8 cmp %ecx,%eax 61e: 72 f0 jb 610 <free+0x20> if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) 620: 39 d0 cmp %edx,%eax 622: 72 f4 jb 618 <free+0x28> 624: 39 d1 cmp %edx,%ecx 626: 73 f0 jae 618 <free+0x28> break; if(bp + bp->s.size == p->s.ptr){ 628: 8b 73 fc mov -0x4(%ebx),%esi 62b: 8d 3c f1 lea (%ecx,%esi,8),%edi 62e: 39 fa cmp %edi,%edx 630: 74 1e je 650 <free+0x60> bp->s.size += p->s.ptr->s.size; bp->s.ptr = p->s.ptr->s.ptr; } else bp->s.ptr = p->s.ptr; 632: 89 53 f8 mov %edx,-0x8(%ebx) if(p + p->s.size == bp){ 635: 8b 50 04 mov 0x4(%eax),%edx 638: 8d 34 d0 lea (%eax,%edx,8),%esi 63b: 39 f1 cmp %esi,%ecx 63d: 74 28 je 667 <free+0x77> p->s.size += bp->s.size; p->s.ptr = bp->s.ptr; } else p->s.ptr = bp; 63f: 89 08 mov %ecx,(%eax) freep = p; } 641: 5b pop %ebx freep = p; 642: a3 64 0a 00 00 mov %eax,0xa64 } 647: 5e pop %esi 648: 5f pop %edi 649: 5d pop %ebp 64a: c3 ret 64b: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 64f: 90 nop bp->s.size += p->s.ptr->s.size; 650: 03 72 04 add 0x4(%edx),%esi 653: 89 73 fc mov %esi,-0x4(%ebx) bp->s.ptr = p->s.ptr->s.ptr; 656: 8b 10 mov (%eax),%edx 658: 8b 12 mov (%edx),%edx 65a: 89 53 f8 mov %edx,-0x8(%ebx) if(p + p->s.size == bp){ 65d: 8b 50 04 mov 0x4(%eax),%edx 660: 8d 34 d0 lea (%eax,%edx,8),%esi 663: 39 f1 cmp %esi,%ecx 665: 75 d8 jne 63f <free+0x4f> p->s.size += bp->s.size; 667: 03 53 fc add -0x4(%ebx),%edx freep = p; 66a: a3 64 0a 00 00 mov %eax,0xa64 p->s.size += bp->s.size; 66f: 89 50 04 mov %edx,0x4(%eax) p->s.ptr = bp->s.ptr; 672: 8b 53 f8 mov -0x8(%ebx),%edx 675: 89 10 mov %edx,(%eax) } 677: 5b pop %ebx 678: 5e pop %esi 679: 5f pop %edi 67a: 5d pop %ebp 67b: c3 ret 67c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 00000680 <malloc>: return freep; } void* malloc(uint nbytes) { 680: f3 0f 1e fb endbr32 684: 55 push %ebp 685: 89 e5 mov %esp,%ebp 687: 57 push %edi 688: 56 push %esi 689: 53 push %ebx 68a: 83 ec 1c sub $0x1c,%esp Header *p, *prevp; uint nunits; nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; 68d: 8b 45 08 mov 0x8(%ebp),%eax if((prevp = freep) == 0){ 690: 8b 3d 64 0a 00 00 mov 0xa64,%edi nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; 696: 8d 70 07 lea 0x7(%eax),%esi 699: c1 ee 03 shr $0x3,%esi 69c: 83 c6 01 add $0x1,%esi if((prevp = freep) == 0){ 69f: 85 ff test %edi,%edi 6a1: 0f 84 a9 00 00 00 je 750 <malloc+0xd0> base.s.ptr = freep = prevp = &base; base.s.size = 0; } for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ 6a7: 8b 07 mov (%edi),%eax if(p->s.size >= nunits){ 6a9: 8b 48 04 mov 0x4(%eax),%ecx 6ac: 39 f1 cmp %esi,%ecx 6ae: 73 6d jae 71d <malloc+0x9d> 6b0: 81 fe 00 10 00 00 cmp $0x1000,%esi 6b6: bb 00 10 00 00 mov $0x1000,%ebx 6bb: 0f 43 de cmovae %esi,%ebx p = sbrk(nu * sizeof(Header)); 6be: 8d 0c dd 00 00 00 00 lea 0x0(,%ebx,8),%ecx 6c5: 89 4d e4 mov %ecx,-0x1c(%ebp) 6c8: eb 17 jmp 6e1 <malloc+0x61> 6ca: 8d b6 00 00 00 00 lea 0x0(%esi),%esi for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ 6d0: 8b 10 mov (%eax),%edx if(p->s.size >= nunits){ 6d2: 8b 4a 04 mov 0x4(%edx),%ecx 6d5: 39 f1 cmp %esi,%ecx 6d7: 73 4f jae 728 <malloc+0xa8> 6d9: 8b 3d 64 0a 00 00 mov 0xa64,%edi 6df: 89 d0 mov %edx,%eax p->s.size = nunits; } freep = prevp; return (void*)(p + 1); } if(p == freep) 6e1: 39 c7 cmp %eax,%edi 6e3: 75 eb jne 6d0 <malloc+0x50> p = sbrk(nu * sizeof(Header)); 6e5: 83 ec 0c sub $0xc,%esp 6e8: ff 75 e4 pushl -0x1c(%ebp) 6eb: e8 5b fc ff ff call 34b <sbrk> if(p == (char*)-1) 6f0: 83 c4 10 add $0x10,%esp 6f3: 83 f8 ff cmp $0xffffffff,%eax 6f6: 74 1b je 713 <malloc+0x93> hp->s.size = nu; 6f8: 89 58 04 mov %ebx,0x4(%eax) free((void*)(hp + 1)); 6fb: 83 ec 0c sub $0xc,%esp 6fe: 83 c0 08 add $0x8,%eax 701: 50 push %eax 702: e8 e9 fe ff ff call 5f0 <free> return freep; 707: a1 64 0a 00 00 mov 0xa64,%eax if((p = morecore(nunits)) == 0) 70c: 83 c4 10 add $0x10,%esp 70f: 85 c0 test %eax,%eax 711: 75 bd jne 6d0 <malloc+0x50> return 0; } } 713: 8d 65 f4 lea -0xc(%ebp),%esp return 0; 716: 31 c0 xor %eax,%eax } 718: 5b pop %ebx 719: 5e pop %esi 71a: 5f pop %edi 71b: 5d pop %ebp 71c: c3 ret if(p->s.size >= nunits){ 71d: 89 c2 mov %eax,%edx 71f: 89 f8 mov %edi,%eax 721: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi if(p->s.size == nunits) 728: 39 ce cmp %ecx,%esi 72a: 74 54 je 780 <malloc+0x100> p->s.size -= nunits; 72c: 29 f1 sub %esi,%ecx 72e: 89 4a 04 mov %ecx,0x4(%edx) p += p->s.size; 731: 8d 14 ca lea (%edx,%ecx,8),%edx p->s.size = nunits; 734: 89 72 04 mov %esi,0x4(%edx) freep = prevp; 737: a3 64 0a 00 00 mov %eax,0xa64 } 73c: 8d 65 f4 lea -0xc(%ebp),%esp return (void*)(p + 1); 73f: 8d 42 08 lea 0x8(%edx),%eax } 742: 5b pop %ebx 743: 5e pop %esi 744: 5f pop %edi 745: 5d pop %ebp 746: c3 ret 747: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 74e: 66 90 xchg %ax,%ax base.s.ptr = freep = prevp = &base; 750: c7 05 64 0a 00 00 68 movl $0xa68,0xa64 757: 0a 00 00 base.s.size = 0; 75a: bf 68 0a 00 00 mov $0xa68,%edi base.s.ptr = freep = prevp = &base; 75f: c7 05 68 0a 00 00 68 movl $0xa68,0xa68 766: 0a 00 00 for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ 769: 89 f8 mov %edi,%eax base.s.size = 0; 76b: c7 05 6c 0a 00 00 00 movl $0x0,0xa6c 772: 00 00 00 if(p->s.size >= nunits){ 775: e9 36 ff ff ff jmp 6b0 <malloc+0x30> 77a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi prevp->s.ptr = p->s.ptr; 780: 8b 0a mov (%edx),%ecx 782: 89 08 mov %ecx,(%eax) 784: eb b1 jmp 737 <malloc+0xb7>
// Test that fake stack (introduced by ASan's use-after-return mode) is included // in the root set. // RUN: LSAN_BASE="report_objects=1:use_registers=0" // RUN: %clangxx_lsan %s -O2 -o %t // RUN: ASAN_OPTIONS=$ASAN_OPTIONS:detect_stack_use_after_return=1 LSAN_OPTIONS=$LSAN_BASE:"use_stacks=0" not %t 2>&1 | FileCheck %s // RUN: ASAN_OPTIONS=$ASAN_OPTIONS:detect_stack_use_after_return=1 LSAN_OPTIONS=$LSAN_BASE:"use_stacks=1" %t 2>&1 // RUN: ASAN_OPTIONS=$ASAN_OPTIONS:detect_stack_use_after_return=1 LSAN_OPTIONS="" %t 2>&1 #include <stdio.h> #include <stdlib.h> int main() { void *stack_var = malloc(1337); fprintf(stderr, "Test alloc: %p.\n", stack_var); // Take pointer to variable, to ensure it's not optimized into a register. fprintf(stderr, "Stack var at: %p.\n", &stack_var); // Do not return from main to prevent the pointer from going out of scope. exit(0); } // CHECK: Test alloc: [[ADDR:.*]]. // CHECK: LeakSanitizer: detected memory leaks // CHECK: [[ADDR]] (1337 bytes) // CHECK: SUMMARY: {{(Leak|Address)}}Sanitizer:
//------------------------------------------------------------------------------ // // Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR> // // This program and the accompanying materials // are licensed and made available under the terms and conditions of the BSD License // which accompanies this distribution. The full text of the license may be found at // http://opensource.org/licenses/bsd-license.php // // THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, // WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. // //------------------------------------------------------------------------------ EXPORT __aeabi_memset EXPORT __aeabi_memclr EXPORT __aeabi_memclr4 AREA Memset, CODE, READONLY ; ;VOID ;EFIAPI ;__aeabi_memset ( ; IN VOID *Destination, ; IN UINT32 Character, ; IN UINT32 Size ; ); ; __aeabi_memset ; args = 0, pretend = 0, frame = 0 ; frame_needed = 1, uses_anonymous_args = 0 stmfd sp!, {r7, lr} mov ip, #0 add r7, sp, #0 mov lr, r0 b L9 L10 and r3, r1, #255 add ip, ip, #1 strb r3, [lr], #1 L9 cmp ip, r2 bne L10 ldmfd sp!, {r7, pc} __aeabi_memclr mov r2, r1 mov r1, #0 b __aeabi_memset __aeabi_memclr4 mov r2, r1 mov r1, #0 b __aeabi_memset END
; A160511: Number of weighings needed to find lighter coins among n coins. ; 1,2,3,3,4,4,5,6,6,7,7,8,9,9,10,11,11,12,13,13,14,14,15,16,16,17,18,18,19 mov $2,$0 add $2,7 mov $4,5 mov $5,5 lpb $2 add $3,$5 mul $4,2 lpb $4 trn $4,$3 add $5,1 lpe lpb $5 add $2,3 add $2,$1 mov $5,$2 lpe mov $1,$2 sub $2,1 trn $3,$5 mov $4,$1 lpe sub $1,3
global _gcd global _lcm global _gcd64 global _lcm64 segment .text align=16 _gcd: test edi, edi je .return0 test esi, esi je .return0 cmp esi, edi je .returnEsi jl .bigger sub esi, edi jmp _gcd .bigger: sub edi, esi jmp _gcd .return0: xor eax, eax ret .returnEsi: mov eax, esi ret align 16 _lcm: push rbx mov ebx, esi imul ebx, edi call _gcd mov ecx, eax mov eax, ebx pop rbx cdq idiv ecx ret align 16 _gcd64: test rdi, rdi je .return0 test rsi, rsi je .return0 cmp rsi, rdi je .returnRsi jl .bigger sub rsi, rdi jmp _gcd64 .bigger: sub rdi, rsi jmp _gcd64 .return0: xor eax, eax ret .returnRsi: mov rax, rsi ret align 16 _lcm64: push rbx mov rbx, rsi imul rbx, rdi call _gcd64 mov rcx, rax mov rax, rbx cqo idiv rcx pop rbx ret
.thumb .org 0x0 @r0 has x, r1 has y, r2 has bitfield, r3 has halfword, r12 has ballista flag push {r4-r7,r14} mov r7,r8 push {r7} mov r8,r12 mov r4,r0 mov r5,r1 mov r6,r2 cmp r3,#0x0 beq NoRangeHalfword @this should usually be the case lsr r7,r3,#0x8 @r7 has min lsl r2,r3,#0x18 @get max lsr r2,r2,#0x18 mov r3,#0x1 push {r4} ldr r4,WriteRange @fill in squares with radius [max] bl goto_r4 pop {r4} mov r0,r4 mov r1,r5 sub r2,r7,#0x1 mov r3,#0x1 neg r3,r3 push {r4} ldr r4,WriteRange @remove squares with radius [min - 1] bl goto_r4 pop {r4} NoRangeHalfword: mov r0,#0xF lsl r0,r0,#0x10 add r6,r6,r0 BitfieldMagic: lsr r2,r6,#0x10 lsl r0,r6,#0x10 lsr r0,r2 lsl r0,r0,#0x10 mov r3,#0x1 lsl r3,r3,#0x10 sub r6,r6,r3 cmp r0,#0x0 beq BallistaCheck MaxBit: cmp r0,#0x0 blt BitFound1 sub r2,#0x1 sub r6,r6,r3 lsl r0,r0,#0x1 b MaxBit BitFound1: mov r0,r4 mov r1,r5 lsr r3,r3,#0x10 push {r4} ldr r4,WriteRange bl goto_r4 pop {r4} lsr r2,r6,#0x10 lsl r0,r6,#0x10 lsr r0,r2 lsl r0,r0,#0x10 mov r3,#0x1 lsl r3,r3,#0x10 sub r6,r6,r3 MinBit: cmp r0,#0x0 bge BitFound2 sub r2,#0x1 sub r6,r6,r3 lsl r0,r0,#0x1 b MinBit BitFound2: mov r0,r4 mov r1,r5 lsr r3,r3,#0x10 neg r3,r3 push {r4} ldr r4,WriteRange bl goto_r4 pop {r4} b BitfieldMagic BallistaCheck: mov r0,r12 cmp r0,#0x0 beq EndRangeWrite mov r0,r4 mov r1,r5 ldr r3,IsBallista bl goto_r3 @given coordinates, returns ballista item id/uses halfword cmp r0,#0x0 beq EndRangeWrite mov r7,r0 ldr r3,BallistaMax bl goto_r3 @given item id, returns range max nybble mov r2,r0 mov r0,r4 mov r1,r5 mov r3,#0x1 push {r4} ldr r4,WriteRange bl goto_r4 pop {r4} mov r0,r7 ldr r3,BallistaMin @given item id, returns range max nybble bl goto_r3 sub r2,r0,#0x1 mov r0,r4 mov r1,r5 mov r3,#0x1 neg r3,r3 push {r4} ldr r4,WriteRange bl goto_r4 pop {r4} EndRangeWrite: pop {r7} mov r8,r7 pop {r4-r7} pop {r0} bx r0 goto_r3: bx r3 goto_r4: bx r4 .align BallistaMin: .long 0x0801766C+1 BallistaMax: .long 0x08017684+1 IsBallista: .long 0x0803798C+1 WriteRange: .long 0x0801AABC+1
; ; Fast background save ; ; Colour Genie EG2000 version By Stefano Bodrato ; ; ; $Id: bksave.asm,v 1.1 2015/10/28 07:18:49 stefano Exp $ ; PUBLIC bksave EXTERN pixeladdress .bksave ld hl,2 add hl,sp ld e,(hl) inc hl ld d,(hl) ;sprite address push de pop ix inc hl ld e,(hl) inc hl inc hl ld d,(hl) ; x and y coords ld h,d ld l,e call pixeladdress xor 7 ld h,d ld l,e ld (ix+2),h ; we save the current sprite position ld (ix+3),l ld a,(ix+0) ld b,(ix+1) cp 9 jr nc,bksavew ._sloop push bc push hl ld a,(hl) and @10101010 ld (ix+4),a inc hl ld a,(hl) rra and @01010101 or (ix+4) ld (ix+4),a inc hl ld a,(hl) and @10101010 ld (ix+5),a inc hl ld a,(hl) rra and @01010101 or (ix+5) ld (ix+5),a inc hl inc ix inc ix pop hl ld bc,40 ;Go to next line add hl,bc pop bc djnz _sloop ret .bksavew push bc push hl ld a,(hl) and @10101010 ld (ix+4),a inc hl ld a,(hl) rra and @01010101 or (ix+4) ld (ix+4),a inc hl ld a,(hl) and @10101010 ld (ix+5),a inc hl ld a,(hl) rra and @01010101 or (ix+5) ld (ix+5),a inc hl ld a,(hl) and @10101010 ld (ix+6),a inc hl ld a,(hl) rra and @01010101 or (ix+6) ld (ix+6),a inc ix inc ix inc ix pop hl ld bc,40 ;Go to next line add hl,bc pop bc djnz bksavew ret
/****************************************************************************** * Copyright (c) 2014-2015, The Pennsylvania State University * 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. * 3. Neither the name of the copyright holder nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission of the * respective copyright holder or contributor. * * 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, FITNESS FOR A PARTICULAR PURPOSE, * AND NONINFRINGEMENT OF INTELLECTUAL PROPERTY ARE EXPRESSLY DISCLAIMED. IN * NO EVENT SHALL THE COPYRIGHT HOLDERS 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 "spacecontrol.h" #include "windowgroup.h" #include <iostream> #include <fstream> #include <string> #include "functions.h" namespace stadic { Control::Control() { } //Setters //****************** //Folder Information //****************** void Control::setSpaceName(std::string name){ m_SpaceName=name; } void Control::setSpaceDirectory(std::string directory){ m_SpaceDirectory=directory; } void Control::setGeoDirectory(std::string directory){ m_GeoDirectory=directory; } void Control::setIESDirectory(std::string directory){ m_IESDirectory=directory; } void Control::setResultsDirectory(std::string directory){ m_ResultsDirectory=directory; } void Control::setInputDirectory(std::string directory){ m_InputDirectory=directory; } //****************** //Site Information //****************** bool Control::setGroundReflect(double value){ if (value>1 || value<0){ STADIC_WARNING("The ground reflectance must be between 0 and 1.\n\tA default value of 0.2 will be applied."); //std::cerr<<"WARNING: The ground reflectance must be between 0 and 1.\n\tA default value of 0.2 will be applied."<<std::endl; m_GroundReflect=0.2; }else{ m_GroundReflect=value; } return true; } void Control::setWeaFile(std::string fileName){ m_WeaFile=fileName; } //****************** //Geometry Information //****************** void Control::setMatFile(std::string file){ m_MatFile=file; } void Control::setGeoFile(std::string file){ m_GeoFile=file; } void Control::setBuildingRotation(double value){ m_BuildingRotation=value; } void Control::setPTSFile(std::vector<std::string> files){ m_PTSFile=files; } void Control::setXSpacing(std::string value){ m_XSpacing=value; } void Control::setYSpacing(std::string value){ m_YSpacing=value; } void Control::setOffset(std::string value){ m_Offset=value; } void Control::setZOffset(std::string value){ m_ZOffset=value; } void Control::setIdentifiers(std::vector<std::string> identifiers){ m_Identifiers=identifiers; } void Control::setModifiers(std::vector<std::string> modifiers){ m_Modifiers=modifiers; } void Control::setOccSchedule(std::string file){ m_OccSchedule=file; } void Control::setLightSchedule(std::string file){ m_LightSchedule=file; } bool Control::setTargetIlluminance(double value){ if (value<0){ STADIC_ERROR("The target illuminance must be greater than 0."); return false; }else{ m_TargetIlluminance=value; } return true; } //****************** //Simulation Settings //****************** bool Control::setSunDivisions(int value){ if (value<1 || value>6){ STADIC_WARNING("The sun divisions must be between 1 and 6.\n\tA default value of 3 will be applied."); m_SunDivisions=3; }else{ m_SunDivisions=value; } return true; } bool Control::setSkyDivisions(int value) { if (value<1 || value>6){ STADIC_WARNING("The sky divisions must be between 1 and 6.\n\tA default value of 3 will be applied."); m_SkyDivisions=3; }else{ m_SkyDivisions=value; } return true; } void Control::setFirstDay(boost::optional<int> value){ m_FirstDay=value; } void Control::setImportUnits(std::string units){ m_ImportUnits=units; } void Control::setIllumUnits(std::string units){ m_IllumUnits=units; } void Control::setDisplayUnits(std::string units){ m_displayUnits=units; } void Control::setDaylightSavingsTime(bool DST){ m_DaylightSavingsTime=DST; } //****************** //Metrics //****************** bool Control::setDA(bool run, double illum){ m_DA=run; if (illum>0){ m_DAIllum=illum; }else{ STADIC_ERROR("The DA illuminance must be greater than 0."); return false; } return true; } void Control::setCalcDA(bool run){ m_DA=run; } bool Control::setcDA(bool run, double illum){ m_cDA=run; if (illum>0){ m_cDAIllum=illum; }else{ STADIC_ERROR("The cDA illuminance must be greater than 0."); return false; } return true; } void Control::setCalccDA(bool run){ m_cDA=run; } bool Control::setsDA(bool run, double illum, double DAFrac, double startTime, double endTime){ m_sDA=run; if (illum>0){ m_sDAIllum=illum; }else{ STADIC_ERROR("The sDA illuminance must be greater than 0."); return false; } if (DAFrac>0 && DAFrac<1){ m_sDAFrac=DAFrac; }else{ STADIC_ERROR("The sDA fraction must be between 0 and 1."); return false; } if (startTime>0 && startTime<endTime){ m_sDAStart=startTime; }else{ STADIC_ERROR("The sDA start time has to be greater than 0 and less than the end time."); return false; } if (endTime<24 && endTime>startTime){ m_sDAEnd=endTime; }else{ STADIC_ERROR("The sDA end time has to be greater than the start time and less than 24."); return false; } return true; } void Control::setCalcsDA(bool run){ m_sDA=run; } bool Control::setsDAwgSettings(std::vector<int> settingNumbers){ m_sDAwgSettings=settingNumbers; return true; } bool Control::setOccsDA(bool run, double illum, double DAFrac){ m_OccsDA=run; if (illum>0){ m_OccsDAIllum=illum; }else{ STADIC_ERROR("The occupancy schedule based sDA illuminance must be greater than 0."); return false; } if (DAFrac>0 && DAFrac<1){ m_OccsDAFrac=DAFrac; }else{ STADIC_ERROR("The occupancy schedule based sDA fraction must be between 0 and 1."); return false; } return true; } void Control::setCalcOccsDA(bool run){ m_OccsDA=run; } void Control::setDF(bool run){ m_DF=run; } bool Control::setUDI(bool run, double minIllum, double maxIllum){ m_UDI=run; if (minIllum>=0 && minIllum<maxIllum){ m_UDIMin=minIllum; }else{ STADIC_ERROR("The UDI minimum illuminance must be between 0 and the maximum illuminance."); return false; } m_UDIMax=maxIllum; return true; } void Control::setCalcUDI(bool run){ m_UDI=run; } //Getters //****************** //Folder Information //****************** std::string Control::spaceName(){ return m_SpaceName; } std::string Control::spaceDirectory(){ return m_SpaceDirectory; } std::string Control::geoDirectory(){ return m_GeoDirectory; } std::string Control::iesDirectory(){ return m_IESDirectory; } std::string Control::resultsDirectory(){ return m_ResultsDirectory; } std::string Control::inputDirectory(){ return m_InputDirectory; } std::string Control::intermediateDataDirectory(){ return m_ResultsDirectory +"intermediateData/"; } //****************** //Site Information //****************** double Control::groundReflect(){ return m_GroundReflect; } std::string Control::weaFile(){ return m_WeaFile; } //****************** //Geometry Information //****************** std::string Control::matFile(){ return m_MatFile; } std::string Control::geoFile(){ return m_GeoFile; } double Control::buildingRotation(){ return m_BuildingRotation; } std::vector<std::string> Control::ptsFile(){ return m_PTSFile; } boost::optional<std::string> Control::xSpacing(){ return m_XSpacing; } boost::optional<std::string> Control::ySpacing(){ return m_YSpacing; } boost::optional<std::string> Control::offset(){ return m_Offset; } boost::optional<std::string> Control::zOffset(){ return m_ZOffset; } boost::optional<std::vector<std::string>> Control::identifiers(){ return m_Identifiers; } boost::optional<std::vector<std::string>> Control::modifiers(){ return m_Modifiers; } std::vector<WindowGroup> Control::windowGroups(){ return m_WindowGroups; } std::string Control::occSchedule(){ return m_OccSchedule; } std::string Control::lightSchedule(){ return m_LightSchedule; } double Control::targetIlluminance(){ return m_TargetIlluminance; } //****************** //Simulation Settings //****************** int Control::sunDivisions(){ return m_SunDivisions; } int Control::skyDivisions(){ return m_SkyDivisions; } boost::optional<std::string> Control::getRadParam(std::string parameterSet, std::string parameterName){ std::unordered_map<std::string, std::unordered_map<std::string, std::string>>::const_iterator got=m_RadParams.find(parameterSet); if (got==m_RadParams.end()){ return boost::none; } std::unordered_map<std::string, std::string>::const_iterator got2=m_RadParams[parameterSet].find(parameterName); if (got2==m_RadParams[parameterSet].end()){ return boost::none; } return boost::optional<std::string>(m_RadParams[parameterSet][parameterName]); } boost::optional<std::unordered_map<std::string, std::string>> Control::getParamSet(std::string setName){ std::unordered_map<std::string, std::unordered_map<std::string, std::string>>::const_iterator got=m_RadParams.find(setName); if (got==m_RadParams.end()){ return boost::none; } return boost::optional<std::unordered_map<std::string, std::string>>(m_RadParams[setName]); } boost::optional<int> Control::firstDay(){ return m_FirstDay; } std::string Control::importUnits(){ return m_ImportUnits; } std::string Control::illumUnits(){ return m_IllumUnits; } std::string Control::displayUnits(){ return m_displayUnits; } bool Control::daylightSavingsTime(){ return m_DaylightSavingsTime; } //****************** //Lighting Control //****************** std::vector<ControlZone> Control::controlZones(){ return m_ControlZones; } //****************** //Metrics //****************** bool Control::runDA(){ return m_DA; } double Control::DAIllum(){ return m_DAIllum; } bool Control::runsDA(){ return m_sDA; } double Control::sDAIllum(){ return m_sDAIllum; } double Control::sDAFrac(){ return m_sDAFrac; } double Control::sDAStart(){ return m_sDAStart; } double Control::sDAEnd(){ return m_sDAEnd; } std::vector<int> Control::sDAwgSettings(){ return m_sDAwgSettings; } bool Control::runOccsDA(){ return m_OccsDA; } double Control::occsDAIllum(){ return m_OccsDAIllum; } double Control::occsDAFrac(){ return m_OccsDAFrac; } bool Control::runcDA(){ return m_cDA; } double Control::cDAIllum(){ return m_cDAIllum; } bool Control::runDF(){ return m_DF; } bool Control::runUDI(){ return m_UDI; } double Control::UDIMin(){ return m_UDIMin; } double Control::UDIMax(){ return m_UDIMax; } //****************** //PARSER //****************** bool Control::parseJson(const JsonObject &json, BuildingControl *buildingControl) { if (json.empty()){ STADIC_LOG(Severity::Error, "The space does not contain data."); return false; } //get_value_or(/*default*/); boost::optional<std::string> sVal; boost::optional<double> dVal; boost::optional<int> iVal; boost::optional<bool> bVal; boost::optional<JsonObject> treeVal; setWeaFile(buildingControl->weaDataFile().get()); if (buildingControl->buildingRotation()){ setBuildingRotation(buildingControl->buildingRotation().get()); } setFirstDay(buildingControl->firstDay()); setImportUnits(buildingControl->importUnits().get()); setIllumUnits(buildingControl->illumUnits().get()); setDisplayUnits(buildingControl->displayUnits().get()); if (buildingControl->daylightSavingsTime()){ setDaylightSavingsTime(buildingControl->daylightSavingsTime().get()); }else{ setDaylightSavingsTime(false); } //****************** //Folder Information //****************** sVal=getString(json, "space_name", "The key \"space_name\" does not appear in the STADIC Control File.", "The key \"space_name\" does not contain a string.", Severity::Error); if(!sVal){ return false; }else{ setSpaceName(sVal.get()); sVal.reset(); } sVal=getString(json, "space_directory", "The key \"space_directory\" does not appear in the STADIC Control File.", "The key \"space_directory\" does not contain a string.", Severity::Error); if(!sVal){ return false; }else{ setSpaceDirectory(sVal.get()); sVal.reset(); } sVal=getString(json, "geometry_directory", "The key \"geometry_directory\" does not appear in the STADIC Control File.", "The \"geometry_directory\" is not a string.", Severity::Error); if (!sVal){ return false; }else{ setGeoDirectory(sVal.get()); sVal.reset(); } sVal=getString(json, "ies_directory", "The key \"ies_directory\" does not appear in the STADIC Control File.", "The \"ies_directory\" is not a string.", Severity::Warning); if (sVal){ setIESDirectory(sVal.get()); sVal.reset(); } sVal=getString(json, "results_directory", "The key \"results_directory\" does not appear in the STADIC Control File.", "The \"results_directory\" is not a string.", Severity::Error); if (!sVal){ return false; }else{ setResultsDirectory(sVal.get()); sVal.reset(); } sVal=getString(json, "input_directory", "The key \"input_directory\" does not appear in the STADIC Control File.", "The \"input_directory\" is not a string.", Severity::Error); if (!sVal){ return false; }else{ setInputDirectory(sVal.get()); sVal.reset(); } //****************** //Site Information //****************** dVal=getDouble(json, "ground_reflectance"); if (!dVal){ STADIC_LOG(Severity::Info, "A default value of 0.2 will be applied for the ground reflectance."); setGroundReflect(0.2); }else{ setGroundReflect(dVal.get()); dVal.reset(); } //****************** //Geometry Information //****************** sVal=getString(json, "material_file", "The key \"material_file\" does not appear in the STADIC Control File.", "The \"material_file\" is not a string.", Severity::Error); if (!sVal){ return false; }else{ setMatFile(sVal.get()); sVal.reset(); } sVal=getString(json, "geometry_file", "The key \"geometry_file\" does not appear in the STADIC Control File.", "The \"geometry_file\" is not a string.", Severity::Error); if (!sVal){ return false; }else{ setGeoFile(sVal.get()); sVal.reset(); } //Analysis Points treeVal=getObject(json, "analysis_points", "The key \"analysis_points\" does not appear in the STADIC Control File.", Severity::Fatal); //files boost::optional<JsonObject> list; list=getArray(treeVal.get(), "files", "The key \"files\" does not appear within \"analysis_points\" in the STADIC Control File.", Severity::Warning); std::vector<std::string> tempVec; if (list.get().size()<1){ STADIC_LOG(Severity::Warning, "No analysis points file has been listed for the space named \""+m_SpaceName+"\""); } for (unsigned index=0;index<list.get().size();index++){ tempVec.push_back(list.get()[index].asString()); } setPTSFile(tempVec); list.reset(); //x-spacing dVal=getDouble(treeVal.get(), "x_spacing"); if (dVal){ setXSpacing(toString(dVal.get())); dVal.reset(); } /* sVal=getString(treeVal.get(), "x_spacing"); if (sVal){ setXSpacing(sVal.get()); sVal.reset(); } */ //y-spacing dVal=getDouble(treeVal.get(), "y_spacing"); if (dVal){ setYSpacing(toString(dVal.get())); dVal.reset(); } /* sVal=getString(treeVal.get(), "y_spacing"); if (sVal){ setYSpacing(sVal.get()); sVal.reset(); } */ //offset dVal=getDouble(treeVal.get(), "offset"); if (dVal){ setOffset(toString(dVal.get())); dVal.reset(); } /* sVal=getString(treeVal.get(), "offset"); if (sVal){ setOffset(sVal.get()); sVal.reset(); } */ //z-offset dVal=getDouble(treeVal.get(), "z_offset"); if (dVal){ setZOffset(toString(dVal.get())); dVal.reset(); } /* sVal=getString(treeVal.get(), "z_offset"); if (sVal){ setZOffset(sVal.get()); sVal.reset(); } */ //identifier list=getArray(treeVal.get(),"identifier"); if (list){ tempVec.clear(); for (unsigned index=0;index<list.get().size();index++){ tempVec.push_back(list.get()[index].asString()); } setIdentifiers(tempVec); } list.reset(); //modifier list=getArray(treeVal.get(),"modifier"); if (list){ tempVec.clear(); for (unsigned index=0;index<list.get().size();index++){ tempVec.push_back(list.get()[index].asString()); } setModifiers(tempVec); } list.reset(); //Code works through this point. treeVal=getArray(json, "window_groups", "The key \"window_groups\" does not appear in the STADIC Control Space.", Severity::Error); if (!treeVal){ return false; }else{ for(auto &v : treeVal.get()){ WindowGroup WG; if (WG.parseJson(v)){ m_WindowGroups.push_back(WG); }else{ return false; } } treeVal.reset(); } sVal=getString(json, "occupancy_schedule", "The key \"occupancy_schedule\" does not appear in the STADIC Control File.", "The \"occupancy_schedule\" is not a string.", Severity::Error); if (!sVal){ return false; }else{ setOccSchedule(sVal.get()); sVal.reset(); } sVal=getString(json, "lighting_schedule","The key \"lighting_schedule\" does not appear in the STADIC Control Space.", "The \"lighting_schedule\" is not a string.", Severity::Error); if (!sVal){ return false; }else{ setLightSchedule(sVal.get()); sVal.reset(); } dVal=getDouble(json, "target_illuminance", "The key \"target_illuminance\" does not appear within the STADIC Control Space. The \"general\" value will be attempted.", "The \"target_illuminance\" is not a double. The \"general\" value will be attempted.", Severity::Warning); if (!dVal){ if (buildingControl->targetIlluminance()){ setTargetIlluminance(buildingControl->targetIlluminance().get()); STADIC_LOG(Severity::Info, "The General target illuminance value of " +toString(buildingControl->targetIlluminance().get()) +" will be applied to the space named \"" +m_SpaceName+"\""); }else{ STADIC_LOG(Severity::Fatal, "General does not contain a target illuminance. Please add this to the control file before proceeding."); return false; } }else{ if (!setTargetIlluminance(dVal.get())){ return false; } dVal.reset(); } //****************** //Simulation Settings //****************** iVal=getInt(json, "sun_divisions", "The key \"sun_divisions\" does not appear in the STADIC Control Space. The \"general\" value will be attempted.", "The \"sun_divisions\" is not an integer. The \"general\" value will be attempted.", Severity::Warning); if (!iVal){ if (buildingControl->sunDivisions()){ setSunDivisions(buildingControl->sunDivisions().get()); }else{ STADIC_LOG(Severity::Info, "Sun Divisions will be set to 3."); setSunDivisions(3); } }else{ if (!setSunDivisions(iVal.get())){ STADIC_LOG(Severity::Info, "Sun Divisions will be set to 3."); setSunDivisions(3); } iVal.reset(); } iVal=getInt(json, "sky_divisions", "The key \"sky_divisions\" does not appear in the STADIC Control Space. The \"general\" value will be attempted.", "The \"sky_divisions\" is not an integer. The \"general\" value will be attempted.", Severity::Warning); if (!iVal){ if (buildingControl->skyDivisions()){ setSkyDivisions(buildingControl->skyDivisions().get()); }else{ STADIC_LOG(Severity::Info, "Sky Divisions will be set to 3."); setSkyDivisions(3); } }else{ if (!setSkyDivisions(iVal.get())){ STADIC_LOG(Severity::Info, "Sky Divisions will be set to 3."); setSkyDivisions(3); } iVal.reset(); } //Radiance Parameters boost::optional<JsonObject> radTree; radTree=getObject(json, "radiance_parameters"); if (radTree){ for (std::string setName : radTree.get().getMemberNames()){ boost::optional<JsonObject> tempTree; tempTree=getObject(radTree.get(), setName, "The key \""+setName+ "\"does not appear in the STADIC Control File.", Severity::Fatal); std::pair<std::string, std::unordered_map<std::string, std::string>> tempPair=std::make_pair (setName, std::unordered_map<std::string, std::string> ()); m_RadParams.insert(tempPair); //Added to make radiance_parameters work with jsonCPP for (Json::Value::iterator it =tempTree.get().begin(); it != tempTree.get().end(); it++){ Json::Value key =it.key(); Json::Value value = (*it); std::pair<std::string, std::string> parameters (key.asString(), value.asString()); m_RadParams[setName].insert(parameters); } } /* //Old parameter parsing code for (std::string setName : radTree.get().getMemberNames()){ boost::optional<JsonObject> tempTree; tempTree=getObject(radTree.get(), setName, "The key \""+setName+ "\"does not appear in the STADIC Control File.", Severity::Fatal); std::pair<std::string, std::unordered_map<std::string, std::string>> tempPair=std::make_pair (setName, std::unordered_map<std::string, std::string> ()); m_RadParams.insert(tempPair); for (std::string paramName : tempTree.get().getMemberNames()){ sVal=getString(tempTree.get(), paramName, "The key \""+paramName+ "\" does not appear in the STADIC Control File.", "The key \""+paramName+"\" does not appear in the STADIC Control File.", Severity::Fatal); std::pair<std::string, std::string> parameters (paramName, sVal.get()); m_RadParams[setName].insert(parameters); } } */ }else{ //This gets all of the radiance parameters. m_RadParams=buildingControl->getAllRadParams().get(); /* for ( auto i = buildingControl->getAllRadParams().get().begin(); i != buildingControl->getAllRadParams().get().end(); ++i ){ std::pair<std::string, std::unordered_map<std::string, std::string>> tempPair=std::make_pair (i->first, std::unordered_map<std::string, std::string> ()); m_RadParams.insert(tempPair); for (auto j=i->second.begin();j!= i->second.end();++j){ std::pair<std::string, std::string> parameters (j->first, j->second); m_RadParams[i->first].insert(parameters); } } */ } //Fails to verify parameters. verifyParameters(); //****************** //Lighting Control //****************** treeVal=getObject(json, "control_zones", "The key \"control_zones\" does not appear in the STADIC Control File.", Severity::Warning); if (treeVal){ for(auto &v : treeVal.get()){ ControlZone zone; if (zone.parseJson(v)){ m_ControlZones.push_back(zone); }else{ return false; } } treeVal.reset(); } //****************** //Metrics //****************** treeVal=getObject(json, "sDA", "The key \"sDA\" does not appear in the STADIC Control File.", Severity::Info); if (treeVal){ double illum, frac, startTime, endTime; bool calculate; bVal=getBool(treeVal.get(), "calculate", false, "The key \"calculate\" is not a boolean.", Severity::Info); if (!bVal){ calculate=false; }else{ calculate=bVal.get(); bVal.reset(); } dVal=getDouble(treeVal.get(), "illuminance", "The key \"illuminance\" is missing under sDA.", "The key \"illuminance\" does not contain a number.", Severity::Warning); if (!dVal){ STADIC_LOG(Severity::Info, "An assumed value of 300 will be used for sDA illuminance."); illum=300; }else{ illum=dVal.get(); dVal.reset(); } dVal=getDouble(treeVal.get(), "DA_fraction", "The key \"DA_fraction\" is missing under sDA.", "The key \"DA_fraction\" does not contain a number.", Severity::Warning); if (!dVal){ STADIC_LOG(Severity::Info, "An assumed value of 0.50 will be used for sDA fraction."); frac=0.50; }else{ frac=dVal.get(); dVal.reset(); } dVal=getDouble(treeVal.get(), "start_time", "The key \"start_time\" is missing under sDA.", "The key \"start_time\" does not contain a number.", Severity::Warning); if (!dVal){ STADIC_LOG(Severity::Info, "An assumed value of 8 will be used for sDA start time."); startTime=8; }else{ startTime=dVal.get(); dVal.reset(); } dVal=getDouble(treeVal.get(), "end_time", "The key \"end_time\" is missing under sDA.", "The key \"end_time\" does not contain a number.", Severity::Warning); if (!dVal){ STADIC_LOG(Severity::Info, "An assumed value of 17 will be used for sDA end time."); endTime=17; }else{ endTime=dVal.get(); } if (!setsDA(calculate, illum, frac, startTime, endTime)){ return false; } list = getArray(treeVal.get(), "window_group_settings", "The key \"window_group_settings\" does not appear within \"sDA\" in the STADIC Control File for the space named \"" + m_SpaceName + "\".", Severity::Warning); if (list) { if (list.get().size() > 0) { std::vector<int> tempIntVec; for (unsigned index = 0; index < list.get().size(); index++) { tempIntVec.push_back(list.get()[index].asInt()); } setsDAwgSettings(tempIntVec); } else { STADIC_LOG(Severity::Warning, "No window group settings have been listed for the space named \"" + m_SpaceName + "\""); } } list.reset(); treeVal.reset(); } treeVal=getObject(json, "occupied_sDA", "The key \"occupied_sDA\" does not appear in the STADIC Control File.", Severity::Info); if (treeVal){ double illum, frac; bool calculate; bVal=getBool(treeVal.get(), "calculate", false, "The key \"calculate\" is not a boolean.", Severity::Info); if (!bVal){ calculate=false; }else{ calculate=bVal.get(); bVal.reset(); } dVal=getDouble(treeVal.get(), "illuminance", "The key \"illuminance\" is missing under occupied_sDA.", "The key \"illuminance\" does not contain a number.", Severity::Warning); if (!dVal){ STADIC_LOG(Severity::Info, "An assumed value of 300 will be used for occupied_sDA illuminance."); illum=300; }else{ illum=dVal.get(); dVal.reset(); } dVal=getDouble(treeVal.get(), "DA_fraction", "The key \"DA_fraction\" is missing under occupied_sDA.", "The key \"DA_fraction\" does not contain a number.", Severity::Warning); if (!dVal){ STADIC_LOG(Severity::Info, "An assumed value of 0.50 will be used for occupied_sDA fraction."); frac=0.50; }else{ frac=dVal.get(); dVal.reset(); } if (!setOccsDA(calculate, illum, frac)){ return false; } treeVal.reset(); } treeVal=getObject(json, "DA"); if (treeVal){ double illuminance; bool calculate; bVal=getBool(treeVal.get(), "calculate", false, "The key \"calculate\" is not a boolean.", Severity::Info); if (!bVal){ calculate=false; }else{ calculate=bVal.get(); bVal.reset(); } dVal=getDouble(treeVal.get(), "illuminance", "The key \"illuminance\" does not appear in the STADIC Control File.", "The key \"illuminance\" is not a double.", Severity::Error); if (dVal){ illuminance=dVal.get(); dVal.reset(); } if (!setDA(calculate, illuminance)){ return false; } treeVal.reset(); } treeVal=getObject(json, "cDA"); if (treeVal){ double illuminance; bool calculate; bVal=getBool(treeVal.get(), "calculate", false, "The key \"calculate\" is not a boolean.", Severity::Info); if (!bVal){ calculate=false; }else{ calculate=bVal.get(); bVal.reset(); } dVal=getDouble(treeVal.get(), "illuminance", "The key \"illuminance\" does not appear in the STADIC Control File.", "The key \"illuminance\" is not a double.", Severity::Info); if (dVal){ illuminance=dVal.get(); dVal.reset(); } if (!setcDA(calculate, illuminance)){ return false; } treeVal.reset(); } bVal=getBool(json, "DF", "The key \"DF\" does not appear in the STADIC Control File.", "The key \"DF\" is not a boolean.", Severity::Info); if (bVal){ setDF(bVal.get()); } bVal.reset(); treeVal=getObject(json, "UDI", "The key \"UDI\" does not appear in the STADIC Control File.", Severity::Info); if (treeVal){ double minimum, maximum; bool calculate; bVal=getBool(treeVal.get(), "calculate", false, "The key \"calculate\" is not a boolean.", Severity::Info); if (!bVal){ calculate=false; }else{ calculate=bVal.get(); bVal.reset(); } dVal=getDouble(treeVal.get(), "minimum", "The key \"minimum\" is missing under UDI.", "The key \"minimum\" does not contain a number.", Severity::Warning); if (!dVal){ STADIC_LOG(Severity::Info, "An assumed value of 100 will be used for UDI minimum."); minimum=100; }else{ minimum=dVal.get(); } dVal.reset(); dVal=getDouble(treeVal.get(), "maximum", "The key \"maximum\" is missing under UDI.", "The key \"maximum\" does not contain a number.", Severity::Warning); if (!dVal){ STADIC_LOG(Severity::Info, "An assumed value of 2500 will be used for UDI maximum."); maximum=2500; }else{ maximum=dVal.get(); } dVal.reset(); if (!setUDI(calculate, minimum, maximum)){ return false; } treeVal.reset(); } return true; } bool Control::verifyParameters(){ bool allOk=true; bool bsdfSets=false; for (int i=0;i<m_WindowGroups.size();i++){ if (m_WindowGroups[i].isBSDF()){ bsdfSets=true; } } //ab if (bsdfSets){ if (!checkParameter("dmx", "ab", "int")){ allOk=false; } if (!checkParameter("vmx", "ab", "int")){ allOk=false; } } if (!checkParameter("default", "ab", "int")){ allOk=false; } //ad if (bsdfSets){ if (!checkParameter("dmx", "ad", "int")){ allOk=false; } if (!checkParameter("vmx", "ad", "int")){ allOk=false; } } if (!checkParameter("default", "ad", "int")){ allOk=false; } //as if (bsdfSets){ if (!checkParameter("dmx", "as", "int")){ allOk=false; } if (!checkParameter("vmx", "as", "int")){ allOk=false; } } if (!checkParameter("default", "as", "int")){ allOk=false; } //dt if (bsdfSets){ if (!checkParameter("dmx", "dt", "double")){ allOk=false; } if (!checkParameter("vmx", "dt", "double")){ allOk=false; } } if (!checkParameter("default", "dt", "double")){ allOk=false; } //dc if (bsdfSets){ if (!checkParameter("dmx", "dc", "double")){ allOk=false; } if (!checkParameter("vmx", "dc", "double")){ allOk=false; } } if (!checkParameter("default", "dc", "double")){ allOk=false; } //dj if (bsdfSets){ if (!checkParameter("dmx", "dj", "double")){ allOk=false; } if (!checkParameter("vmx", "dj", "double")){ allOk=false; } } if (!checkParameter("default", "dj", "double")){ allOk=false; } //dp if (bsdfSets){ if (!checkParameter("dmx", "dp", "double")){ allOk=false; } if (!checkParameter("vmx", "dp", "double")){ allOk=false; } } if (!checkParameter("default", "dp", "double")){ allOk=false; } //lw if (bsdfSets){ if (!checkParameter("dmx", "lw", "double")){ allOk=false; } if (!checkParameter("vmx", "lw", "double")){ allOk=false; } } if (!checkParameter("default", "lw", "double")){ allOk=false; } return allOk; // Just guessing here... but VS requires a return } bool Control::checkParameter(std::string setName, std::string parameter, std::string varType){ boost::optional<std::string> check; bool ok; check=getRadParam(setName, parameter); if (check){ if (varType=="int"){ toInteger(check.get(), &ok); if (!ok){ STADIC_LOG(Severity::Fatal, "The parameter "+parameter+" within the "+setName+" set in "+m_SpaceName +" is not an integer."); } }else if (varType=="double"){ toDouble(check.get(), &ok); if (!ok){ STADIC_LOG(Severity::Fatal, "The parameter "+parameter+" within the "+setName+" set in "+m_SpaceName +" is not a double."); } }else{ STADIC_LOG(Severity::Fatal, "The variable type for the verification of the parameters is not a known type. This can be either \"int\" or \"double\"."); } check.reset(); } return false; // Add return for VS } }
; A041478: Numerators of continued fraction convergents to sqrt(255). ; Submitted by Jon Maiga ; 15,16,495,511,15825,16336,505905,522241,16173135,16695376,517034415,533729791,16528928145,17062657936,528408666225,545471324161,16892548391055,17438019715216,540033139847535,557471159562751,17264167926730065,17821639086292816,551913340515514545,569734979601807361,17643962728569735375,18213697708171542736,564054893973716017455,582268591681887560191,18032112644430342823185,18614381236112230383376,576463549727797254324465,595077930963909484707841,18428801478645081795559695 add $0,1 mov $3,1 lpb $0 sub $0,1 add $2,$3 mov $3,$1 mov $1,$2 dif $2,5 dif $2,6 mul $2,30 lpe mul $3,2 add $3,$2 mov $0,$3 div $0,2
// Created on October 26, 2013 by Lu, Wangshan. /// This is the implementation file of nostd::diffusion Shared Memory Writer. /// For Writer and Reader maintainer: /// Writer and Reader communicate with a shared memory file. File length is specified in writer's constructor. /// Since the shared memory region contains a 8 byte header, the shared memory file length should not be less than 5. /// The header contains a 4 byte signed integer in the begining indicates the writer's committed offset, starting immediately after header. /// The reader can read the header as a 4 byte signed integer to know if there is available data. /// For a RawData object, writer will write 4 bytes signed integer size of RawData's payload, followed by the payload of RawData. /// The writer will wrap to the shared memroy region's payload's beginning when it encounters the end of the region. /// That means if user specifies a length of 1000000 bytes in the writer's constructor, the payload region for writing data is 999996 bytes. /// And if RawData contains a length of 28 bytes rawdata, it will take 4 + 28 = 32 bytes in the share memory payload region. #include <atomic> #include <memory> #include <boost/interprocess/shared_memory_object.hpp> #include <boost/interprocess/mapped_region.hpp> #include <diffusion/factory.hpp> namespace diffusion { extern constexpr Size kShmHeaderLength = 8; // Also used by shm_reader.cpp class ShmWriter : public Writer { public: ShmWriter(std::string const &shm_name, Size shm_size); virtual ~ShmWriter(); virtual void write(std::vector<char> const & data); virtual void write(char const *data, std::size_t size); private: std::string shm_name_; boost::interprocess::shared_memory_object shm_object_; std::unique_ptr<boost::interprocess::mapped_region> shm_region_; // const since first asignment. char * shm_header_position_; char * shm_body_position_; Size shm_body_size_; // variable. std::uint32_t writer_shm_body_offset_; void cyclic_write(char const *data, std::size_t size); void commit(); }; Writer * create_shared_memory_writer(std::string const &shm_name, Size shm_size) { return new ShmWriter(shm_name, shm_size); } ShmWriter::ShmWriter(std::string const & shm_name, Size shm_size) : shm_name_(shm_name), shm_object_(boost::interprocess::create_only, shm_name.c_str(), boost::interprocess::read_write), writer_shm_body_offset_(0) { shm_object_.truncate(shm_size); shm_region_ = std::unique_ptr<boost::interprocess::mapped_region>(new boost::interprocess::mapped_region(shm_object_, boost::interprocess::read_write)); shm_header_position_ = reinterpret_cast<char *>(shm_region_->get_address()); shm_body_position_ = shm_header_position_ + kShmHeaderLength; shm_body_size_ = shm_region_->get_size() - kShmHeaderLength; } ShmWriter::~ShmWriter() { boost::interprocess::shared_memory_object::remove(shm_name_.c_str()); } void ShmWriter::write(std::vector<char> const &data) { this->write(data.data(), data.size()); } void ShmWriter::write(char const *data, std::size_t size) { auto size_prefix = static_cast<Size>(size); this->cyclic_write(reinterpret_cast<char const *>(&size_prefix), sizeof(size_prefix)); this->cyclic_write(data, size); this->commit(); } void ShmWriter::cyclic_write(char const *data, std::size_t size) { auto bytes_left = static_cast<Size>(size); while (bytes_left > 0) { auto start_position_unwritten_bytes = data + size - bytes_left; auto space_left = shm_body_size_ - static_cast<Size>(writer_shm_body_offset_); auto bytes_can_be_written_without_wrap = (bytes_left > space_left) ? space_left : bytes_left; std::memcpy(shm_body_position_ + static_cast<Offset>(writer_shm_body_offset_), start_position_unwritten_bytes, bytes_can_be_written_without_wrap); writer_shm_body_offset_ += bytes_can_be_written_without_wrap; bytes_left -= bytes_can_be_written_without_wrap; if (static_cast<Size>(writer_shm_body_offset_) == shm_body_size_) { writer_shm_body_offset_ = 0; } } } void ShmWriter::commit() { auto shm_offset_position = reinterpret_cast<std::atomic<std::uint32_t> *>(shm_header_position_); std::atomic_store_explicit(shm_offset_position, static_cast<std::uint32_t>(writer_shm_body_offset_), std::memory_order_release); } } // namespace diffusion
#pragma once #include <eosio/eosio.hpp> #include <eosio/print.hpp> #include <eosio/asset.hpp> #include <eosio/crypto.hpp> #include <eosio/time.hpp> #include <eosio/singleton.hpp> #include <eosio/transaction.hpp> #include <string> using namespace eosio; inline uint32_t now() { static uint32_t current_time = current_time_point().sec_since_epoch(); return current_time; } class [[eosio::contract("stake")]] stake : public contract { public: using contract::contract; inline static const std::string STAKE_MEMO = "stake"; inline static const std::string CLAIM_MEMO = "claim"; inline static const std::string REFUND_MEMO = "unstake"; static const uint32_t SECONDS_PER_DAY = 86400; static const uint32_t CLAIM_STOP_TIME = 1604188799; // Saturday, 31 October 2020 23:59:59 (GMT) static const uint32_t MAX_STAKE_AGE_DAYS = 1000; inline static const std::set<eosio::name> REFUND_INTERCEPT = {"breekean2222"_n}; inline static const eosio::name REFUND_INTERCEPT_TO = "theeffectdao"_n; [[eosio::action]] void init(name token_contract, const symbol& stake_symbol, const symbol& claim_symbol, uint32_t age_limit, uint64_t scale_factor, uint32_t unstake_delay_sec, uint32_t stake_bonus_age, time_point_sec stake_bonus_deadline); [[eosio::action]] void update(uint32_t unstake_delay_sec, uint32_t stake_bonus_age, time_point_sec stake_bonus_deadline); [[eosio::action]] void create(const symbol& stake_symbol, const symbol& claim_symbol, name token_contract, uint32_t unstake_delay_sec); [[eosio::action]] void unstake(name owner, asset quantity); [[eosio::action]] void refund(name owner, const symbol& symbol); [[eosio::action]] void open(name owner, const symbol& symbol, name ram_payer); [[eosio::action]] void claim(name owner, const symbol& symbol); void transfer_handler(name from, name to, asset quantity, std::string memo); private: struct [[eosio::table]] config { name token_contract; symbol stake_symbol; symbol claim_symbol; uint32_t age_limit; uint64_t scale_factor; uint32_t unstake_delay_sec; uint32_t stake_bonus_age; time_point_sec stake_bonus_deadline; }; struct [[eosio::table]] stakeentry { asset amount; time_point_sec last_claim_time; uint32_t last_claim_age; uint64_t primary_key() const { return amount.symbol.code().raw(); } }; struct [[eosio::table]] unstakeentry { asset amount; time_point_sec time; uint64_t primary_key() const { return amount.symbol.code().raw(); } }; struct [[eosio::table]] stakestats { symbol stake_symbol; symbol claim_symbol; name token_contract; uint32_t unstake_delay_sec; uint64_t primary_key() const { return stake_symbol.code().raw(); } }; typedef singleton<"config"_n, config> config_table; typedef multi_index<"stake"_n, stakeentry> stake_table; typedef multi_index<"unstake"_n, unstakeentry> unstake_table; typedef multi_index<"stat"_n, stakestats> stat_table; };
#include "nine/prg_rom/utils_static.asm"
.global s_prepare_buffers s_prepare_buffers: push %r10 push %r11 push %r14 push %r8 push %rbp push %rcx push %rdi push %rsi lea addresses_WT_ht+0x178f3, %rsi lea addresses_UC_ht+0x30d3, %rdi nop nop nop nop nop inc %r14 mov $72, %rcx rep movsq nop nop nop xor $34993, %rdi lea addresses_A_ht+0x184f3, %r14 nop nop nop nop sub $14249, %r10 mov $0x6162636465666768, %r11 movq %r11, (%r14) cmp $12764, %rcx lea addresses_WT_ht+0xb7e, %rsi lea addresses_UC_ht+0x4833, %rdi nop nop nop mfence mov $25, %rcx rep movsl nop nop nop nop nop inc %r11 lea addresses_WC_ht+0x1ebb9, %rsi nop nop nop nop nop and %r8, %r8 movl $0x61626364, (%rsi) nop nop nop nop sub $1453, %r11 lea addresses_WC_ht+0x17ef3, %r8 nop nop sub %rdi, %rdi movb (%r8), %r11b nop nop nop nop nop sub %r10, %r10 lea addresses_A_ht+0x1a8f3, %rdi nop nop xor %r11, %r11 mov (%rdi), %r10 nop nop nop nop inc %rdi lea addresses_WT_ht+0x16173, %rsi lea addresses_WC_ht+0xea93, %rdi nop nop and $46420, %rbp mov $29, %rcx rep movsq sub $65146, %rsi lea addresses_normal_ht+0x115f, %rbp nop nop nop nop sub $12541, %r8 mov (%rbp), %cx cmp %r10, %r10 lea addresses_WC_ht+0xc073, %r14 nop nop nop nop nop dec %r11 mov (%r14), %r10d nop nop nop add $29640, %r14 lea addresses_WC_ht+0x1b4f3, %rsi nop nop and %r8, %r8 mov $0x6162636465666768, %r14 movq %r14, %xmm7 vmovups %ymm7, (%rsi) nop nop and %r8, %r8 lea addresses_WC_ht+0x82f3, %rsi nop nop nop nop nop dec %rdi mov $0x6162636465666768, %rcx movq %rcx, %xmm4 vmovups %ymm4, (%rsi) xor $41210, %r14 lea addresses_normal_ht+0xaa2, %r14 clflush (%r14) nop dec %r8 mov (%r14), %cx nop nop nop nop xor %r8, %r8 pop %rsi pop %rdi pop %rcx pop %rbp pop %r8 pop %r14 pop %r11 pop %r10 ret .global s_faulty_load s_faulty_load: push %r10 push %r11 push %r13 push %r15 push %rdi push %rsi // Store lea addresses_PSE+0xb8f3, %r13 nop nop nop add %r10, %r10 mov $0x5152535455565758, %rdi movq %rdi, (%r13) nop nop nop nop nop xor %r15, %r15 // Faulty Load lea addresses_D+0x10f3, %rdi sub $21722, %r15 mov (%rdi), %r10 lea oracles, %rdi and $0xff, %r10 shlq $12, %r10 mov (%rdi,%r10,1), %r10 pop %rsi pop %rdi pop %r15 pop %r13 pop %r11 pop %r10 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 16, 'type': 'addresses_D', 'congruent': 0}} {'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 8, 'type': 'addresses_PSE', 'congruent': 9}, 'OP': 'STOR'} [Faulty Load] {'OP': 'LOAD', 'src': {'same': True, 'NT': True, 'AVXalign': True, 'size': 8, 'type': 'addresses_D', 'congruent': 0}} <gen_prepare_buffer> {'dst': {'same': False, 'congruent': 5, 'type': 'addresses_UC_ht'}, 'OP': 'REPM', 'src': {'same': False, 'congruent': 11, 'type': 'addresses_WT_ht'}} {'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 8, 'type': 'addresses_A_ht', 'congruent': 10}, 'OP': 'STOR'} {'dst': {'same': False, 'congruent': 6, 'type': 'addresses_UC_ht'}, 'OP': 'REPM', 'src': {'same': False, 'congruent': 0, 'type': 'addresses_WT_ht'}} {'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 4, 'type': 'addresses_WC_ht', 'congruent': 1}, 'OP': 'STOR'} {'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 1, 'type': 'addresses_WC_ht', 'congruent': 8}} {'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 8, 'type': 'addresses_A_ht', 'congruent': 9}} {'dst': {'same': False, 'congruent': 5, 'type': 'addresses_WC_ht'}, 'OP': 'REPM', 'src': {'same': False, 'congruent': 7, 'type': 'addresses_WT_ht'}} {'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 2, 'type': 'addresses_normal_ht', 'congruent': 2}} {'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 4, 'type': 'addresses_WC_ht', 'congruent': 7}} {'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 32, 'type': 'addresses_WC_ht', 'congruent': 8}, 'OP': 'STOR'} {'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 32, 'type': 'addresses_WC_ht', 'congruent': 8}, 'OP': 'STOR'} {'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 2, 'type': 'addresses_normal_ht', 'congruent': 0}} {'36': 21829} 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 */
; float __fsmul (float a1, float a2) SECTION code_fp_math48 PUBLIC cm48_sdcciyp_dsmul EXTERN cm48_sdcciyp_dread2, am48_dmul, cm48_sdcciyp_m482d cm48_sdcciyp_dsmul: ; multiply two sdcc floats ; ; enter : stack = sdcc_float a2, sdcc_float a1, ret ; ; exit : dehl = sdcc_float(a1*a2) ; ; uses : af, bc, de, hl, af', bc', de', hl' call cm48_sdcciyp_dread2 ; AC = a2 ; AC'= a1 call am48_dmul jp cm48_sdcciyp_m482d
match ,{ include 'win32a.inc' } match -,{ else include 'selfhost.inc' end match _ equ } format PE large console 4.0 entry start include '../version.inc' section '.text' code readable executable start: call system_init call get_arguments jc display_usage_information cmp [no_logo],0 jne arguments_ok mov esi,_logo xor ecx,ecx call display_string arguments_ok: xor al,al mov ecx,[verbosity_level] jecxz init or al,TRACE_ERROR_STACK dec ecx jz init or al,TRACE_DISPLAY init: call assembly_init invoke GetTickCount mov [timer],eax assemble: mov esi,[initial_commands] mov edx,[source_path] call assembly_pass jc assembly_done mov eax,[current_pass] cmp eax,[maximum_number_of_passes] jb assemble call show_display_data mov esi,_error_prefix xor ecx,ecx call display_error_string mov esi,_code_cannot_be_generated xor ecx,ecx call display_error_string mov esi,_message_suffix xor ecx,ecx call display_error_string jmp assembly_failed assembly_done: call show_display_data cmp [first_error],0 jne assembly_failed cmp [no_logo],0 jne summary_done mov eax,[current_pass] xor edx,edx call itoa call display_string mov esi,_passes cmp [current_pass],1 jne display_passes_suffix mov esi,_pass display_passes_suffix: xor ecx,ecx call display_string invoke GetTickCount sub eax,[timer] xor edx,edx add eax,50 mov ecx,1000 div ecx mov ebx,eax mov eax,edx xor edx,edx mov ecx,100 div ecx mov [timer],eax xchg eax,ebx or ebx,eax jz display_output_length xor edx,edx call itoa call display_string mov esi,_message_suffix mov ecx,1 call display_string mov eax,[timer] xor edx,edx call itoa call display_string mov esi,_seconds xor ecx,ecx call display_string display_output_length: call get_output_length push eax edx call itoa call display_string pop edx eax mov esi,_bytes cmp eax,1 jne display_bytes_suffix test edx,edx jnz display_bytes_suffix mov esi,_byte display_bytes_suffix: xor ecx,ecx call display_string mov esi,_new_line xor ecx,ecx call display_string summary_done: mov ebx,[source_path] mov edi,[output_path] call write_output_file jc write_failed call assembly_shutdown call system_shutdown invoke ExitProcess,0 assembly_failed: call show_errors call assembly_shutdown call system_shutdown invoke ExitProcess,2 write_failed: mov ebx,_write_failed jmp fatal_error out_of_memory: mov ebx,_out_of_memory jmp fatal_error fatal_error: mov esi,_error_prefix xor ecx,ecx call display_error_string mov esi,ebx xor ecx,ecx call display_error_string mov esi,_message_suffix xor ecx,ecx call display_error_string call assembly_shutdown call system_shutdown invoke ExitProcess,3 display_usage_information: mov esi,_logo xor ecx,ecx call display_string mov esi,_usage xor ecx,ecx call display_string call system_shutdown invoke ExitProcess,1 get_arguments: xor eax,eax mov [initial_commands],eax mov [output_path],eax mov [maximum_number_of_passes],100 mov [maximum_number_of_errors],1 mov [maximum_depth_of_stack],10000 mov [maximum_depth_of_stack],10000 invoke GetCommandLine mov esi,eax mov edi,eax or ecx,-1 xor al,al repne scasb sub edi,esi mov ecx,edi call malloc mov edi,eax get_argument: xor ah,ah read_character: lodsb test al,al jz no_more_arguments cmp al,22h je switch_quote cmp ax,20h je end_argument stosb jmp read_character end_argument: xor al,al stosb find_next_argument: mov al,[esi] test al,al jz no_more_arguments cmp al,20h jne next_argument_found inc esi jmp find_next_argument switch_quote: xor ah,1 jmp read_character next_argument_found: cmp al,'-' je get_option cmp al,'/' je get_option cmp [source_path],0 je get_source_path cmp [output_path],0 je get_output_path error_in_arguments: stc retn get_source_path: mov [source_path],edi jmp get_argument get_output_path: mov [output_path],edi jmp get_argument no_more_arguments: cmp [source_path],0 je error_in_arguments xor al,al stosb clc retn get_option: inc esi lodsb cmp al,'e' je set_errors_limit cmp al,'E' je set_errors_limit cmp al,'i' je insert_initial_command cmp al,'I' je insert_initial_command cmp al,'p' je set_passes_limit cmp al,'P' je set_passes_limit cmp al,'r' je set_recursion_limit cmp al,'R' je set_recursion_limit cmp al,'v' je set_verbose_mode cmp al,'V' je set_verbose_mode cmp al,'n' je set_no_logo cmp al,'N' jne error_in_arguments set_no_logo: or [no_logo],-1 mov al,[esi] cmp al,20h je find_next_argument test al,al jnz error_in_arguments jmp find_next_argument set_verbose_mode: call get_option_value jc error_in_arguments cmp edx,2 ja error_in_arguments mov [verbosity_level],edx jmp find_next_argument set_errors_limit: call get_option_value jc error_in_arguments test edx,edx jz error_in_arguments mov [maximum_number_of_errors],edx jmp find_next_argument set_recursion_limit: call get_option_value jc error_in_arguments test edx,edx jz error_in_arguments mov [maximum_depth_of_stack],edx jmp find_next_argument set_passes_limit: call get_option_value jc error_in_arguments test edx,edx jz error_in_arguments mov [maximum_number_of_passes],edx jmp find_next_argument get_option_value: xor eax,eax mov edx,eax find_option_value: cmp byte [esi],20h jne get_option_digit inc esi jmp find_option_value get_option_digit: lodsb cmp al,20h je option_value_ok test al,al jz option_value_ok sub al,30h jc invalid_option_value cmp al,9 ja invalid_option_value imul edx,10 jo invalid_option_value add edx,eax jc invalid_option_value jmp get_option_digit option_value_ok: dec esi clc ret invalid_option_value: stc ret insert_initial_command: push edi find_command_segment: cmp byte [esi],20h jne command_segment_found inc esi jmp find_command_segment command_segment_found: xor ah,ah cmp byte [esi],22h jne measure_command_segment inc esi inc ah measure_command_segment: mov ebx,esi scan_command_segment: mov ecx,esi mov al,[esi] test al,al jz command_segment_measured cmp ax,20h je command_segment_measured cmp ax,22h je command_segment_measured inc esi cmp al,22h jne scan_command_segment command_segment_measured: sub ecx,ebx mov edi,[initial_commands] lea eax,[ecx+2] test edi,edi jz allocate_initial_commands_buffer mov edx,[initial_commands_length] add edi,edx add eax,edx cmp eax,[initial_commands_maximum_length] ja grow_initial_commands_buffer copy_initial_command: xchg esi,ebx rep movsb mov esi,ebx sub edi,[initial_commands] mov [initial_commands_length],edi mov al,[esi] test al,al jz initial_command_ready cmp al,20h jne command_segment_found initial_command_ready: mov edi,[initial_commands] add edi,[initial_commands_length] mov ax,0Ah stosw inc [initial_commands_length] pop edi jmp find_next_argument allocate_initial_commands_buffer: push ecx mov ecx,eax call malloc mov [initial_commands],eax mov [initial_commands_maximum_length],ecx mov edi,eax pop ecx jmp copy_initial_command grow_initial_commands_buffer: push ecx mov ecx,eax mov eax,[initial_commands] call realloc mov [initial_commands],eax mov [initial_commands_maximum_length],ecx mov edi,eax add edi,[initial_commands_length] pop ecx jmp copy_initial_command include 'system.inc' include '../assembler.inc' include '../symbols.inc' include '../expressions.inc' include '../conditions.inc' include '../floats.inc' include '../directives.inc' include '../errors.inc' include '../map.inc' include '../reader.inc' include '../output.inc' include '../console.inc' section '.data' data readable writeable _logo db 'flat assembler version g.',VERSION,13,10,0 _usage db 'Usage: fasmg source [output]',13,10 db 'Optional settings:',13,10 db ' -e limit Set the maximum number of displayed errors (default 1)',13,10 db ' -p limit Set the maximum allowed number of passes (default 100)',13,10 db ' -r limit Set the maximum depth of the stack (default 10000)',13,10 db ' -v flag Enable or disable showing all lines from the stack (default 0)',13,10 db ' -i command Insert instruction at the beginning of source',13,10 db ' -n Do not show logo nor summary',13,10 db 0 _pass db ' pass, ',0 _passes db ' passes, ',0 _dot db '.' _seconds db ' seconds, ',0 _byte db ' byte.',0 _bytes db ' bytes.',0 _write_failed db 'failed to write the output file',0 _out_of_memory db 'not enough memory to complete the assembly',0 _code_cannot_be_generated db 'could not generate code within the allowed number of passes',0 include '../tables.inc' include '../messages.inc' section '.bss' readable writeable include '../variables.inc' source_path dd ? output_path dd ? maximum_number_of_passes dd ? initial_commands dd ? initial_commands_length dd ? initial_commands_maximum_length dd ? stdout dd ? stderr dd ? memory dd ? bytes_count dd ? position_high dd ? timestamp dq ? systemtime SYSTEMTIME filetime FILETIME timer dd ? verbosity_level dd ? no_logo db ? section '.idata' import data readable writeable library kernel32,'KERNEL32.DLL' import kernel32,\ CloseHandle,'CloseHandle',\ CreateFile,'CreateFileA',\ ExitProcess,'ExitProcess',\ GetCommandLine,'GetCommandLineA',\ GetEnvironmentVariable,'GetEnvironmentVariableA',\ GetStdHandle,'GetStdHandle',\ GetSystemTime,'GetSystemTime',\ GetTickCount,'GetTickCount',\ HeapAlloc,'HeapAlloc',\ HeapCreate,'HeapCreate',\ HeapDestroy,'HeapDestroy',\ HeapFree,'HeapFree',\ HeapReAlloc,'HeapReAlloc',\ HeapSize,'HeapSize',\ ReadFile,'ReadFile',\ SetFilePointer,'SetFilePointer',\ SystemTimeToFileTime,'SystemTimeToFileTime',\ WriteFile,'WriteFile',\ GetLastError,'GetLastError'
; A088128: Expansion of e.g.f.: cosh(x)/(1-x)^2. ; Submitted by Christian Krause ; 1,2,7,30,157,970,6931,56294,512569,5173074,57330271,692227822,9045871957,127205130650,1915394962027,30748771424310,524265894691441,9461374592096674,180184121539899319,3611206508019111614 add $0,1 lpb $0 mul $1,$2 cmp $3,0 mul $3,$0 sub $0,1 add $1,$3 add $2,1 lpe mov $0,$1
;================================================================================ ; Dialog Pointer Override ;-------------------------------------------------------------------------------- DialogOverride: LDA $7F5035 : BEQ .skip LDA $7F5700, X ; use alternate buffer RTL .skip LDA $7F1200, X RTL ;-------------------------------------------------------------------------------- ; $7F5035 - Alternate Text Pointer Flag ; 0=Disable ; $7F5036 - Padding Byte (Must be Zero) ; $7F5700 - $7F57FF - Dialog Buffer ;-------------------------------------------------------------------------------- ResetDialogPointer: STZ $1CF0 : STZ $1CF1 ; reset decompression buffer LDA.b #$00 : STA $7F5035 ; zero out the alternate flag LDA.b #$1C : STA $1CE9 ; thing we wrote over RTL ;-------------------------------------------------------------------------------- ;macro LoadDialog(index,table) ; PHA : PHX : PHY ; PHB : PHK : PLB ; LDA $00 : PHA ; LDA $01 : PHA ; LDA $02 : PHA ; LDA.b #$01 : STA $7F5035 ; set flag ; ; LDA <index> : ASL : !ADD.l <index> : TAX ; get quote offset *3, move to X ; LDA <table>, X : STA $00 ; write pointer to direct page ; LDA <table>+1, X : STA $01 ; LDA <table>+2, X : STA $02 ; ; LDX.b #$00 : LDY.b #$00 ; - ; LDA [$00], Y ; load the next character from the pointer ; STA $7F5700, X ; write to the buffer ; INX : INY ; CMP.b #$7F : BNE - ; PLA : STA $02 ; PLA : STA $01 ; PLA : STA $00 ; PLB ; PLY : PLX : PLA ;endmacro ;-------------------------------------------------------------------------------- ;macro LoadDialogAddress(address) ; PHA : PHX : PHY ; PHP ; PHB : PHK : PLB ; SEP #$30 ; set 8-bit accumulator and index registers ; LDA $00 : PHA ; LDA $01 : PHA ; LDA $02 : PHA ; LDA.b #$01 : STA $7F5035 ; set flag ; ; LDA.b #<address> : STA $00 ; write pointer to direct page ; LDA.b #<address>>>8 : STA $01 ; LDA.b #<address>>>16 : STA $02 ; ; LDX.b #$00 : LDY.b #$00 ; - ; LDA [$00], Y ; load the next character from the pointer ; STA $7F5700, X ; write to the buffer ; INX : INY ; CMP.b #$7F : BNE - ; PLA : STA $02 ; PLA : STA $01 ; PLA : STA $00 ; PLB ; PLP ; PLY : PLX : PLA ;endmacro ;-------------------------------------------------------------------------------- !OFFSET_POINTER = "$7F5094" !OFFSET_RETURN = "$7F5096" !DIALOG_BUFFER = "$7F5700" macro LoadDialogAddress(address) PHA : PHX : PHY PHP PHB : PHK : PLB SEP #$20 ; set 8-bit accumulator REP #$10 ; set 16-bit index registers LDA $00 : PHA LDA $01 : PHA LDA $02 : PHA STZ $1CF0 : STZ $1CF1 ; reset decompression buffer LDA.b #$01 : STA $7F5035 ; set flag %CopyDialog(<address>) PLA : STA $02 PLA : STA $01 PLA : STA $00 PLB PLP PLY : PLX : PLA endmacro ;-------------------------------------------------------------------------------- macro CopyDialog(address) LDA.b #<address> : STA $00 ; write pointer to direct page LDA.b #<address>>>8 : STA $01 LDA.b #<address>>>16 : STA $02 %CopyDialogIndirect() endmacro ;-------------------------------------------------------------------------------- macro CopyDialogIndirect() REP #$20 : LDA !OFFSET_POINTER : TAX : LDY.w #$0000 : SEP #$20 ; copy 2-byte offset pointer to X and set Y to 0 ?loop: LDA [$00], Y ; load the next character from the pointer STA !DIALOG_BUFFER, X ; write to the buffer INX : INY CMP.b #$7F : BNE ?loop REP #$20 ; set 16-bit accumulator TXA : INC : STA !OFFSET_RETURN ; copy out X into LDA.w #$0000 : STA !OFFSET_POINTER SEP #$20 ; set 8-bit accumulator endmacro ;-------------------------------------------------------------------------------- LoadDialogAddressIndirect: STZ $1CF0 : STZ $1CF1 ; reset decompression buffer LDA.b #$01 : STA $7F5035 ; set flag %CopyDialogIndirect() ;%LoadDialogAddress(UncleText) RTL ;-------------------------------------------------------------------------------- !ITEM_TEMPORARY = "$7F5040" FreeDungeonItemNotice: STA !ITEM_TEMPORARY PHA : PHX : PHY PHP PHB : PHK : PLB SEP #$20 ; set 8-bit accumulator REP #$10 ; set 16-bit index registers LDA $00 : PHA LDA $01 : PHA LDA $02 : PHA ;-------------------------------- LDA.l FreeItemText : BNE + : BRL .skip : + LDA #$00 : STA $7F5010 ; initialize scratch LDA.l FreeItemText : AND.b #$01 : CMP.b #$01 : BNE + ; show message for general small key LDA !ITEM_TEMPORARY : CMP.b #$24 : BNE + ; general small key %CopyDialog(Notice_SmallKeyOf) LDA !OFFSET_RETURN : DEC #2 : STA !OFFSET_POINTER %CopyDialog(Notice_Self) BRL .done + : LDA.l FreeItemText : AND.b #$02 : CMP.b #$02 : BNE + ; show message for general compass LDA !ITEM_TEMPORARY : CMP.b #$25 : BNE + ; general compass %CopyDialog(Notice_CompassOf) LDA !OFFSET_RETURN : DEC #2 : STA !OFFSET_POINTER %CopyDialog(Notice_Self) BRL .done + : LDA.l FreeItemText : AND.b #$04 : CMP.b #$04 : BNE + ; show message for general map LDA !ITEM_TEMPORARY : CMP.b #$33 : BNE + ; general map %CopyDialog(Notice_MapOf) LDA !OFFSET_RETURN : DEC #2 : STA !OFFSET_POINTER %CopyDialog(Notice_Self) BRL .done + : LDA.l FreeItemText : AND.b #$08 : CMP.b #$08 : BNE + ; show message for general big key LDA !ITEM_TEMPORARY : CMP.b #$32 : BNE + ; general big key %CopyDialog(Notice_BigKeyOf) LDA !OFFSET_RETURN : DEC #2 : STA !OFFSET_POINTER %CopyDialog(Notice_Self) BRL .done + LDA !ITEM_TEMPORARY : AND.b #$F0 ; looking at high bits only CMP.b #$70 : BNE + ; map of... %CopyDialog(Notice_MapOf) BRL .dungeon + : CMP.b #$80 : BNE + ; compass of... %CopyDialog(Notice_CompassOf) BRL .dungeon + : CMP.b #$90 : BNE + ; big key of... %CopyDialog(Notice_BigKeyOf) BRA .dungeon + : CMP.b #$A0 : BNE + ; small key of... LDA !ITEM_TEMPORARY : CMP.b #$AF : BNE ++ : BRL .skip : ++ %CopyDialog(Notice_SmallKeyOf) PLA : AND.b #$0F : STA $7F5020 : LDA.b #$0F : !SUB $7F5020 : PHA LDA #$01 : STA $7F5010 ; set up a flip for small keys BRA .dungeon + BRL .skip ; it's not something we are going to give a notice for .dungeon LDA !OFFSET_RETURN : DEC #2 : STA !OFFSET_POINTER LDA !ITEM_TEMPORARY AND.b #$0F ; looking at low bits only STA $7F5011 LDA $7F5010 : BEQ + LDA $7F5010 LDA #$0F : !SUB $7F5011 : STA $7F5011 ; flip the values for small keys + LDA $7F5011 CMP.b #$00 : BNE + ; ...light world %CopyDialog(Notice_LightWorld) : BRL .done + : CMP.b #$01 : BNE + ; ...dark world %CopyDialog(Notice_DarkWorld) : BRL .done + : CMP.b #$02 : BNE + ; ...ganon's tower %CopyDialog(Notice_GTower) : BRL .done + : CMP.b #$03 : BNE + ; ...turtle rock %CopyDialog(Notice_TRock) : BRL .done + : CMP.b #$04 : BNE + ; ...thieves' town %CopyDialog(Notice_Thieves) : BRL .done + : CMP.b #$05 : BNE + ; ...tower of hera %CopyDialog(Notice_Hera) : BRL .done + : CMP.b #$06 : BNE + ; ...ice palace %CopyDialog(Notice_Ice) : BRL .done + : CMP.b #$07 : BNE + ; ...skull woods %CopyDialog(Notice_Skull) : BRL .done + : CMP.b #$08 : BNE + ; ...misery mire %CopyDialog(Notice_Mire) : BRL .done + : CMP.b #$09 : BNE + ; ...dark palace %CopyDialog(Notice_PoD) : BRL .done + : CMP.b #$0A : BNE + ; ...swamp palace %CopyDialog(Notice_Swamp) : BRL .done + : CMP.b #$0B : BNE + ; ...agahnim's tower %CopyDialog(Notice_AgaTower) : BRL .done + : CMP.b #$0C : BNE + ; ...desert palace %CopyDialog(Notice_Desert) : BRL .done + : CMP.b #$0D : BNE + ; ...eastern palace %CopyDialog(Notice_Eastern) : BRA .done + : CMP.b #$0E : BNE + ; ...hyrule castle %CopyDialog(Notice_Castle) : BRA .done + : CMP.b #$0F : BNE + ; ...sewers %CopyDialog(Notice_Sewers) + .done STZ $1CF0 : STZ $1CF1 ; reset decompression buffer LDA.b #$01 : STA $7F5035 ; set alternate dialog flag LDA.b #$01 : STA $7F509F ;-------------------------------- PLA : STA $02 PLA : STA $01 PLA : STA $00 PLB PLP PLY : PLX : PLA ;JSL.l Main_ShowTextMessage_Alt RTL .skip ;-------------------------------- PLA : STA $02 PLA : STA $01 PLA : STA $00 PLB PLP PLY : PLX : PLA RTL ;-------------------------------------------------------------------------------- DialogResetSelectionIndex: JSL.l Attract_DecompressStoryGfx ; what we wrote over STZ $1CE8 RTL ;-------------------------------------------------------------------------------- DialogItemReceive: BCS .noMessage ; if doubling the item value overflowed it must be a rando item CPY #$98 : !BLT + ;if the item is $4C or greater it must be a rando item .noMessage LDA.w #$FFFF BRA .done + LDA Ancilla_ReceiveItem_item_messages, Y .done CMP.w #$FFFF RTL ;-------------------------------------------------------------------------------- DialogFairyThrow: LDA.l Restrict_Ponds : BEQ .normal LDA $7EF35C : ORA $7EF35D : ORA $7EF35E : ORA $7EF35F : BNE .normal .noInventory LDA $0D80, X : !ADD #$08 : STA $0D80, X LDA.b #$51 LDY.b #$01 RTL .normal LDA.b #$88 LDY.b #$00 RTL ;-------------------------------------------------------------------------------- DialogGanon1: JSL.l CheckGanonVulnerability : BCS + REP #$20 : LDA.w #$018C : STA $1CF0 : SEP #$20 BRA ++ + REP #$20 : LDA.w #$016D : STA $1CF0 : SEP #$20 ++ JSL.l Sprite_ShowMessageMinimal_Alt RTL ;-------------------------------------------------------------------------------- ; #$0192 - no bow ; #$0193 - no silvers alternate ; #$0194 - no silvers ; #$0195 - silvers ; $7EF38E - bsp-- --- ; b = bow ; s = silver arrow bow ; p = 2nd progressive bow DialogGanon2: JSL.l CheckGanonVulnerability : BCS + REP #$20 : LDA.w #$018D : STA $1CF0 : SEP #$20 BRA ++ + LDA.l $7EF38E : AND #$80 : BNE + ; branch if bow REP #$20 : LDA.w #$0192 : STA $1CF0 : SEP #$20 ; no bow BRA ++ + LDA.l $7EF38E : AND #$40 : BEQ + ; branch if no silvers REP #$20 : LDA.w #$0195 : STA $1CF0 : SEP #$20 ;has silvers BRA ++ + LDA.l $7EF38E : AND #$20 : BNE + ; branch if p bow REP #$20 : LDA.w #$0194 : STA $1CF0 : SEP #$20 ; bow, no-silvers, no-p-bow BRA ++ + LDA.l $7EF38E : AND #$80 : BEQ + ; branch if no bow REP #$20 : LDA.w #$0193 : STA $1CF0 : SEP #$20 ; bow, no-silvers, p-bow BRA ++ + REP #$20 : LDA.w #$016E : STA $1CF0 : SEP #$20 ; both bow and no bow. impossible. ++ JSL.l Sprite_ShowMessageMinimal_Alt RTL ;-------------------------------------------------------------------------------- DialogEtherTablet: PHA LDA $0202 : CMP.b #$0F : BEQ + ; Show normal text if book is not equipped - PLA : JSL Sprite_ShowMessageUnconditional ; Wacky Hylian Text RTL + BIT $F4 : BVC - ; Show normal text if Y is not pressed LDA.l AllowHammerTablets : BEQ ++ LDA $7EF34B : BEQ .yesText : BRA .noText ++ LDA $7EF359 : CMP.b #$FF : BEQ .yesText : CMP.b #$02 : !BGE .noText ;++ .yesText PLA LDA.b #$0c LDY.b #$01 JSL Sprite_ShowMessageUnconditional ; Text From MSPedestalText (tables.asm) RTL .noText PLA RTL ;-------------------------------------------------------------------------------- DialogBombosTablet: PHA LDA $0202 : CMP.b #$0F : BEQ + ; Show normal text if book is not equipped - PLA : JSL Sprite_ShowMessageUnconditional ; Wacky Hylian Text RTL + BIT $F4 : BVC - ; Show normal text if Y is not pressed LDA.l AllowHammerTablets : BEQ ++ LDA $7EF34B : BEQ .yesText : BRA .noText ++ LDA $7EF359 : CMP.b #$FF : BEQ .yesText : CMP.b #$02 : !BGE .noText ;++ .yesText PLA LDA.b #$0D LDY.b #$01 JSL Sprite_ShowMessageUnconditional ; Text From MSPedestalText (tables.asm) RTL .noText PLA RTL ;-------------------------------------------------------------------------------- DialogSahasrahla: LDA.l $7EF374 : AND #$04 : BEQ + ;Check if player has green pendant LDA.b #$2F LDY.b #$00 JSL.l Sprite_ShowMessageUnconditional + RTL ;-------------------------------------------------------------------------------- DialogBombShopGuy: LDA.l $7EF37A : AND #$05 : CMP #$05 : BEQ + ;Check if player has crystals 5 & 6 LDA.b #$15 LDY.b #$01 JSL.l Sprite_ShowMessageUnconditional RTL + LDA.b #$16 LDY.b #$01 JSL.l Sprite_ShowMessageUnconditional RTL ;-------------------------------------------------------------------------------- Main_ShowTextMessage_Alt: ; Are we in text mode? If so then end the routine. LDA $10 : CMP.b #$0E : BEQ .already_in_text_mode Sprite_ShowMessageMinimal_Alt: STZ $11 PHX : PHY LDA.b $00 : PHA LDA.b $01 : PHA LDA.b $02 : PHA LDA.b #$1C : STA.b $02 REP #$30 LDA.w $1CF0 : ASL : TAX LDA.l $7f71c0, X STA.b $00 SEP #$30 LDY.b #$00 LDA [$00], Y : CMP.b #$fe : BNE + INY : LDA [$00], Y : CMP.b #$6e : BNE + INY : LDA [$00], Y : : BNE + INY : LDA [$00], Y : CMP.b #$fe : BNE + INY : LDA [$00], Y : CMP.b #$6b : BNE + INY : LDA [$00], Y : CMP.b #$04 : BNE + STZ $1CE8 BRL .end + STZ $0223 ; Otherwise set it so we are in text mode. STZ $1CD8 ; Initialize the step in the submodule ; Go to text display mode (as opposed to maps, etc) LDA.b #$02 : STA $11 ; Store the current module in the temporary location. LDA $10 : STA $010C ; Switch the main module ($10) to text mode. LDA.b #$0E : STA $10 .end PLA : STA.b $02 PLA : STA.b $01 PLA : STA.b $00 PLY : PLX Main_ShowTextMessage_Alt_already_in_text_mode: RTL CalculateSignIndex: ; for the big 1024x1024 screens we are calculating link's effective ; screen area, as though the screen was 4 different 512x512 screens. ; And we do this in a way that will likely give the right value even ; with major glitches. LDA $8A : ASL A : TAY ;what we wrote over LDA $0712 : BEQ .done ; If a small map, we can skip these calculations. LDA $21 : AND.w #$0002 : ASL #2 : EOR $8A : AND.w #$0008 : BEQ + TYA : !ADD.w #$0010 : TAY ;add 16 if we are in lower half of big screen. + LDA $23 : AND.w #$0002 : LSR : EOR $8A : AND.w #$0001 : BEQ + TYA : INC #2 : TAY ;add 16 if we are in lower half of big screen. + ; ensure even if things go horribly wrong, we don't read the sign out of bounds and crash: TYA : AND.w #$00FF : TAY .done RTL ;-------------------------------------------------------------------------------- ; A0 - A9 - 0 - 9 ; AA - C3 - A - Z ; C6 - ? ; C7 - ! ; C8 - , ; C9 - - Hyphen ; CD - Japanese period ; CE - ~ ; D8 - ` apostraphe ;;-------------------------------------------------------------------------------- ;DialogUncleData: ;;-------------------------------------------------------------------------------- ; .pointers ; dl #DialogUncleData_weetabix ; dl #DialogUncleData_bootlessUntilBoots ; dl #DialogUncleData_onlyOneBed ; dl #DialogUncleData_onlyTextBox ; dl #DialogUncleData_mothTutorial ; dl #DialogUncleData_seedWorst ; dl #DialogUncleData_chasingTail ; dl #DialogUncleData_doneBefore ; dl #DialogUncleData_capeCanPass ; dl #DialogUncleData_bootsAtRace ; dl #DialogUncleData_kanzeonSeed ; dl #DialogUncleData_notRealUncle ; dl #DialogUncleData_haveAVeryBadTime ; dl #DialogUncleData_todayBadLuck ; dl #DialogUncleData_leavingGoodbye ; dl #DialogUncleData_iGotThis ; dl #DialogUncleData_raceToCastle ; dl #DialogUncleData_69BlazeIt ; dl #DialogUncleData_hi ; dl #DialogUncleData_gettingSmokes ; dl #DialogUncleData_dangerousSeeYa ; dl #DialogUncleData_badEnoughDude ; dl #DialogUncleData_iAmError ; dl #DialogUncleData_sub2Guaranteed ; dl #DialogUncleData_chestSecretEverybody ; dl #DialogUncleData_findWindFish ; dl #DialogUncleData_shortcutToGanon ; dl #DialogUncleData_moonCrashing ; dl #DialogUncleData_fightVoldemort ; dl #DialogUncleData_redMailForCowards ; dl #DialogUncleData_heyListen ; dl #DialogUncleData_excuseMePrincess ;;-------------------------------------------------------------------------------- ; .weetabix ; ; We’re out of / Weetabix. To / the store! ; db $00, $c0, $00, $ae, $00, $d8, $00, $bb, $00, $ae, $00, $ff, $00, $b8, $00, $be, $00, $bd, $00, $ff, $00, $b8, $00, $af ; db $75, $00, $c0, $00, $ae, $00, $ae, $00, $bd, $00, $aa, $00, $ab, $00, $b2, $00, $c1, $00, $cD, $00, $ff, $00, $bd, $00, $b8 ; db $76, $00, $bd, $00, $b1, $00, $ae, $00, $ff, $00, $bc, $00, $bd, $00, $b8, $00, $bb, $00, $ae, $00, $c7 ; db $7f, $7f ;;-------------------------------------------------------------------------------- ; .bootlessUntilBoots ; ; This seed is / bootless / until boots. ; db $00, $bd, $00, $b1, $00, $b2, $00, $bc, $00, $ff, $00, $bc, $00, $ae, $00, $ae, $00, $ad, $00, $ff, $00, $b2, $00, $bc ; db $75, $00, $ab, $00, $b8, $00, $b8, $00, $bd, $00, $b5, $00, $ae, $00, $bc, $00, $bc ; db $76, $00, $be, $00, $b7, $00, $bd, $00, $b2, $00, $b5, $00, $ff, $00, $ab, $00, $b8, $00, $b8, $00, $bd, $00, $bc, $00, $cD ; db $7f, $7f ;;-------------------------------------------------------------------------------- ; .onlyOneBed ; ; Why do we only / have one bed? ; db $00, $c0, $00, $b1, $00, $c2, $00, $ff, $00, $ad, $00, $b8, $00, $ff, $00, $c0, $00, $ae, $00, $ff, $00, $b8, $00, $b7, $00, $b5, $00, $c2 ; db $75, $00, $b1, $00, $aa, $00, $bf, $00, $ae, $00, $ff, $00, $b8, $00, $b7, $00, $ae, $00, $ff, $00, $ab, $00, $ae, $00, $ad, $00, $c6 ; db $7f, $7f ;;-------------------------------------------------------------------------------- ; .onlyTextBox ; ; This is the / only textbox. ; db $00, $bd, $00, $b1, $00, $b2, $00, $bc, $00, $ff, $00, $b2, $00, $bc, $00, $ff, $00, $bd, $00, $b1, $00, $ae ; db $75, $00, $b8, $00, $b7, $00, $b5, $00, $c2, $00, $ff, $00, $bd, $00, $ae, $00, $c1, $00, $bd, $00, $ab, $00, $b8, $00, $c1, $00, $cD ; db $7f, $7f ;;-------------------------------------------------------------------------------- ; .mothTutorial ; ; I'm going to / go watch the / Moth tutorial. ; db $00, $b2, $00, $d8, $00, $b6, $00, $ff, $00, $b0, $00, $b8, $00, $b2, $00, $b7, $00, $b0, $00, $ff, $00, $bd, $00, $b8 ; db $75, $00, $b0, $00, $b8, $00, $ff, $00, $c0, $00, $aa, $00, $bd, $00, $ac, $00, $b1, $00, $ff, $00, $bd, $00, $b1, $00, $ae ; db $76, $00, $b6, $00, $b8, $00, $bd, $00, $b1, $00, $ff, $00, $bd, $00, $be, $00, $bd, $00, $b8, $00, $bb, $00, $b2, $00, $aa, $00, $b5, $00, $cD ; db $7f, $7f ;;-------------------------------------------------------------------------------- ; .seedWorst ; ; This seed is / the worst. ; db $00, $bd, $00, $b1, $00, $b2, $00, $bc, $00, $ff, $00, $bc, $00, $ae, $00, $ae, $00, $ad, $00, $ff, $00, $b2, $00, $bc ; db $75, $00, $bd, $00, $b1, $00, $ae, $00, $ff, $00, $c0, $00, $b8, $00, $bb, $00, $bc, $00, $bd, $00, $cD ; db $7f, $7f ;;-------------------------------------------------------------------------------- ; .chasingTail ; ; Chasing tail. / Fly ladies. / Do not follow. ; db $00, $ac, $00, $b1, $00, $aa, $00, $bc, $00, $b2, $00, $b7, $00, $b0, $00, $ff, $00, $bd, $00, $aa, $00, $b2, $00, $b5, $00, $cD ; db $75, $00, $af, $00, $b5, $00, $c2, $00, $ff, $00, $b5, $00, $aa, $00, $ad, $00, $b2, $00, $ae, $00, $bc, $00, $cD ; db $76, $00, $ad, $00, $b8, $00, $ff, $00, $b7, $00, $b8, $00, $bd, $00, $ff, $00, $af, $00, $b8, $00, $b5, $00, $b5, $00, $b8, $00, $c0, $00, $cD ; db $7f, $7f ;;-------------------------------------------------------------------------------- ; .doneBefore ; ; I feel like / I’ve done this / before… ; db $00, $b2, $00, $ff, $00, $af, $00, $ae, $00, $ae, $00, $b5, $00, $ff, $00, $b5, $00, $b2, $00, $b4, $00, $ae ; db $75, $00, $b2, $00, $d8, $00, $bf, $00, $ae, $00, $ff, $00, $ad, $00, $b8, $00, $b7, $00, $ae, $00, $ff, $00, $bd, $00, $b1, $00, $b2, $00, $bc ; db $76, $00, $ab, $00, $ae, $00, $af, $00, $b8, $00, $bb, $00, $ae, $00, $cD, $00, $cD, $00, $cD ; db $7f, $7f ;;-------------------------------------------------------------------------------- ; .capeCanPass ; ; Magic cape can / pass through / the barrier! ; db $00, $b6, $00, $aa, $00, $b0, $00, $b2, $00, $ac, $00, $ff, $00, $ac, $00, $aa, $00, $b9, $00, $ae, $00, $ff, $00, $ac, $00, $aa, $00, $b7 ; db $75, $00, $b9, $00, $aa, $00, $bc, $00, $bc, $00, $ff, $00, $bd, $00, $b1, $00, $bb, $00, $b8, $00, $be, $00, $b0, $00, $b1 ; db $76, $00, $bd, $00, $b1, $00, $ae, $00, $ff, $00, $ab, $00, $aa, $00, $bb, $00, $bb, $00, $b2, $00, $ae, $00, $bb, $00, $c7 ; db $7f, $7f ;;-------------------------------------------------------------------------------- ; .bootsAtRace ; ; Boots at race? / Seed confirmed / impossible. ; db $00, $ab, $00, $b8, $00, $b8, $00, $bd, $00, $bc, $00, $ff, $00, $aa, $00, $bd, $00, $ff, $00, $bb, $00, $aa, $00, $ac, $00, $ae, $00, $c6 ; db $75, $00, $bc, $00, $ae, $00, $ae, $00, $ad, $00, $ff, $00, $ac, $00, $b8, $00, $b7, $00, $af, $00, $b2, $00, $bb, $00, $b6, $00, $ae, $00, $ad ; db $76, $00, $b2, $00, $b6, $00, $b9, $00, $b8, $00, $bc, $00, $bc, $00, $b2, $00, $ab, $00, $b5, $00, $ae, $00, $cD ; db $7f, $7f ;;-------------------------------------------------------------------------------- ; .kanzeonSeed ; ; If this is a / Kanzeon seed, / I'm quitting. ; db $00, $b2, $00, $af, $00, $ff, $00, $bd, $00, $b1, $00, $b2, $00, $bc, $00, $ff, $00, $b2, $00, $bc, $00, $ff, $00, $aa ; db $75, $00, $b4, $00, $aa, $00, $b7, $00, $c3, $00, $ae, $00, $b8, $00, $b7, $00, $ff, $00, $bc, $00, $ae, $00, $ae, $00, $ad, $00, $c8 ; db $76, $00, $b2, $00, $d8, $00, $b6, $00, $ff, $00, $ba, $00, $be, $00, $b2, $00, $bd, $00, $bd, $00, $b2, $00, $b7, $00, $b0, $00, $cD ; db $7f, $7f ;;-------------------------------------------------------------------------------- ; .notRealUncle ; ; I am not your / real uncle. ; db $00, $b2, $00, $ff, $00, $aa, $00, $b6, $00, $ff, $00, $b7, $00, $b8, $00, $bd, $00, $ff, $00, $c2, $00, $b8, $00, $be, $00, $bb ; db $75, $00, $bb, $00, $ae, $00, $aa, $00, $b5, $00, $ff, $00, $be, $00, $b7, $00, $ac, $00, $b5, $00, $ae, $00, $cD ; db $7f, $7f ;;-------------------------------------------------------------------------------- ; .haveAVeryBadTime ; ; You're going / to have a very / bad time. ; db $00, $c2, $00, $b8, $00, $be, $00, $d8, $00, $bb, $00, $ae, $00, $ff, $00, $b0, $00, $b8, $00, $b2, $00, $b7, $00, $b0 ; db $75, $00, $bd, $00, $b8, $00, $ff, $00, $b1, $00, $aa, $00, $bf, $00, $ae, $00, $ff, $00, $aa, $00, $ff, $00, $bf, $00, $ae, $00, $bb, $00, $c2 ; db $76, $00, $ab, $00, $aa, $00, $ad, $00, $ff, $00, $bd, $00, $b2, $00, $b6, $00, $ae, $00, $cD ; db $7f, $7f ;;-------------------------------------------------------------------------------- ; .todayBadLuck ; ; Today you / will have / bad luck. ; db $00, $bd, $00, $b8, $00, $ad, $00, $aa, $00, $c2, $00, $ff, $00, $c2, $00, $b8, $00, $be, $00, $ff, $00, $c0, $00, $b2, $00, $b5, $00, $b5 ; db $75, $00, $b1, $00, $aa, $00, $bf, $00, $ae, $00, $ff, $00, $ab, $00, $aa, $00, $ad, $00, $ff, $00, $b5, $00, $be, $00, $ac, $00, $b4, $00, $c7 ; db $7f, $7f ;;-------------------------------------------------------------------------------- ; .leavingGoodbye ; ; I am leaving / forever. / Goodbye. ; db $00, $b2, $00, $ff, $00, $aa, $00, $b6, $00, $ff, $00, $b5, $00, $ae, $00, $aa, $00, $bf, $00, $b2, $00, $b7, $00, $b0 ; db $75, $00, $af, $00, $b8, $00, $bb, $00, $ae, $00, $bf, $00, $ae, $00, $bb, $00, $cD ; db $76, $00, $b0, $00, $b8, $00, $b8, $00, $ad, $00, $ab, $00, $c2, $00, $ae, $00, $cD ; db $7f, $7f ;;-------------------------------------------------------------------------------- ; .iGotThis ; ; Don’t worry. / I got this / covered. ; db $00, $ad, $00, $b8, $00, $b7, $00, $d8, $00, $bd, $00, $ff, $00, $c0, $00, $b8, $00, $bb, $00, $bb, $00, $c2, $00, $cD ; db $75, $00, $b2, $00, $ff, $00, $b0, $00, $b8, $00, $bd, $00, $ff, $00, $bd, $00, $b1, $00, $b2, $00, $bc ; db $76, $00, $ac, $00, $b8, $00, $bf, $00, $ae, $00, $bb, $00, $ae, $00, $ad, $00, $cD ; db $7f, $7f ;;-------------------------------------------------------------------------------- ; .raceToCastle ; ; Race you to / the castle! ; db $00, $bb, $00, $aa, $00, $ac, $00, $ae, $00, $ff, $00, $c2, $00, $b8, $00, $be, $00, $ff, $00, $bd, $00, $b8 ; db $75, $00, $bd, $00, $b1, $00, $ae, $00, $ff, $00, $ac, $00, $aa, $00, $bc, $00, $bd, $00, $b5, $00, $ae, $00, $c7 ; db $7f, $7f ;;-------------------------------------------------------------------------------- ; .69BlazeIt ; ; ~69 Blaze It!~ ; db $75, $00, $cE, $00, $a6, $00, $a9, $00, $ff, $00, $ab, $00, $b5, $00, $aa, $00, $c3, $00, $ae, $00, $ff, $00, $b2, $00, $bd, $00, $c7, $00, $cE ; db $7f, $7f ;;-------------------------------------------------------------------------------- ; .hi ; ; hi ; db $75, $00, $ff, $00, $ff, $00, $ff, $00, $ff, $00, $ff, $00, $ff, $00, $b1, $00, $b2 ; db $7f, $7f ;;-------------------------------------------------------------------------------- ; .gettingSmokes ; ; I'M JUST GOING / OUT FOR A / PACK OF SMOKES. ; db $00, $b2, $00, $d8, $00, $b6, $00, $ff, $00, $b3, $00, $be, $00, $bc, $00, $bd, $00, $ff, $00, $b0, $00, $b8, $00, $b2, $00, $b7, $00, $b0 ; db $75, $00, $b8, $00, $be, $00, $bd, $00, $ff, $00, $af, $00, $b8, $00, $bb, $00, $ff, $00, $aa ; db $76, $00, $b9, $00, $aa, $00, $ac, $00, $b4, $00, $ff, $00, $b8, $00, $af, $00, $ff, $00, $bc, $00, $b6, $00, $b8, $00, $b4, $00, $ae, $00, $bc, $00, $cD ; db $7f, $7f ;;-------------------------------------------------------------------------------- ; .dangerousSeeYa ; ; It's dangerous / to go alone. / See ya! ; db $00, $b2, $00, $bd, $00, $d8, $00, $bc, $00, $ff, $00, $ad, $00, $aa, $00, $b7, $00, $b0, $00, $ae, $00, $bb, $00, $b8, $00, $be, $00, $bc ; db $75, $00, $bd, $00, $b8, $00, $ff, $00, $b0, $00, $b8, $00, $ff, $00, $aa, $00, $b5, $00, $b8, $00, $b7, $00, $ae, $00, $cD ; db $76, $00, $bc, $00, $ae, $00, $ae, $00, $ff, $00, $c2, $00, $aa, $00, $c7 ; db $7f, $7f ;;-------------------------------------------------------------------------------- ; .badEnoughDude ; ; ARE YOU A BAD / ENOUGH DUDE TO / RESCUE ZELDA? ; db $00, $aa, $00, $bb, $00, $ae, $00, $ff, $00, $c2, $00, $b8, $00, $be, $00, $ff, $00, $aa, $00, $ff, $00, $ab, $00, $aa, $00, $ad ; db $75, $00, $ae, $00, $b7, $00, $b8, $00, $be, $00, $b0, $00, $b1, $00, $ff, $00, $ad, $00, $be, $00, $ad, $00, $ae, $00, $ff, $00, $bd, $00, $b8 ; db $76, $00, $bb, $00, $ae, $00, $bc, $00, $ac, $00, $be, $00, $ae, $00, $ff, $00, $c3, $00, $ae, $00, $b5, $00, $ad, $00, $aa, $00, $c6 ; db $7f, $7f ;;-------------------------------------------------------------------------------- ; .iAmError ; ; I AM ERROR ; db $76, $00, $ff, $00, $ff, $00, $ff, $00, $ff, $00, $b2, $00, $ff, $00, $aa, $00, $b6, $00, $ff, $00, $ae, $00, $bb, $00, $bb, $00, $b8, $00, $bb ; db $7f, $7f ;;-------------------------------------------------------------------------------- ; .sub2Guaranteed ; ; This seed is / sub 2 hours, / guaranteed. ; db $00, $bd, $00, $b1, $00, $b2, $00, $bc, $00, $ff, $00, $bc, $00, $ae, $00, $ae, $00, $ad, $00, $ff, $00, $b2, $00, $bc ; db $75, $00, $bc, $00, $be, $00, $ab, $00, $ff, $00, $a2, $00, $ff, $00, $b1, $00, $b8, $00, $be, $00, $bb, $00, $bc, $00, $c8 ; db $76, $00, $b0, $00, $be, $00, $aa, $00, $bb, $00, $aa, $00, $b7, $00, $bd, $00, $ae, $00, $ae, $00, $ad, $00, $cD ; db $7f, $7f ;;-------------------------------------------------------------------------------- ; .chestSecretEverybody ; ; The chest is / a secret to / everybody. ; db $00, $bd, $00, $b1, $00, $ae, $00, $ff, $00, $ac, $00, $b1, $00, $ae, $00, $bc, $00, $bd, $00, $ff, $00, $b2, $00, $bc ; db $75, $00, $aa, $00, $ff, $00, $bc, $00, $ae, $00, $ac, $00, $bb, $00, $ae, $00, $bd, $00, $ff, $00, $bd, $00, $b8 ; db $76, $00, $ae, $00, $bf, $00, $ae, $00, $bb, $00, $c2, $00, $ab, $00, $b8, $00, $ad, $00, $c2, $00, $cD ; db $7f, $7f ;;-------------------------------------------------------------------------------- ; .findWindFish ; ; I'm off to / find the / wind fish. ; db $00, $b2, $00, $d8, $00, $b6, $00, $ff, $00, $b8, $00, $af, $00, $af, $00, $ff, $00, $bd, $00, $b8 ; db $75, $00, $af, $00, $b2, $00, $b7, $00, $ad, $00, $ff, $00, $bd, $00, $b1, $00, $ae ; db $76, $00, $c0, $00, $b2, $00, $b7, $00, $ad, $00, $ff, $00, $af, $00, $b2, $00, $bc, $00, $b1, $00, $cD ; db $7f, $7f ;;-------------------------------------------------------------------------------- ; .shortcutToGanon ; ; The shortcut / to Ganon / is this way! ; db $00, $bd, $00, $b1, $00, $ae, $00, $ff, $00, $bc, $00, $b1, $00, $b8, $00, $bb, $00, $bd, $00, $ac, $00, $be, $00, $bd ; db $75, $00, $bd, $00, $b8, $00, $ff, $00, $b0, $00, $aa, $00, $b7, $00, $b8, $00, $b7 ; db $76, $00, $b2, $00, $bc, $00, $ff, $00, $bd, $00, $b1, $00, $b2, $00, $bc, $00, $ff, $00, $c0, $00, $aa, $00, $c2, $00, $c7 ; db $7f, $7f ;;-------------------------------------------------------------------------------- ; .moonCrashing ; ; THE MOON IS / CRASHING! RUN / FOR YOUR LIFE! ; db $00, $bd, $00, $b1, $00, $ae, $00, $ff, $00, $b6, $00, $b8, $00, $b8, $00, $b7, $00, $ff, $00, $b2, $00, $bc ; db $75, $00, $ac, $00, $bb, $00, $aa, $00, $bc, $00, $b1, $00, $b2, $00, $b7, $00, $b0, $00, $c7, $00, $ff, $00, $bb, $00, $be, $00, $b7 ; db $76, $00, $af, $00, $b8, $00, $bb, $00, $ff, $00, $c2, $00, $b8, $00, $be, $00, $bb, $00, $ff, $00, $b5, $00, $b2, $00, $af, $00, $ae, $00, $c7 ; db $7f, $7f ;;-------------------------------------------------------------------------------- ; .fightVoldemort ; ; Time to fight / he who must / not be named. ; db $00, $bd, $00, $b2, $00, $b6, $00, $ae, $00, $ff, $00, $bd, $00, $b8, $00, $ff, $00, $af, $00, $b2, $00, $b0, $00, $b1, $00, $bd ; db $75, $00, $b1, $00, $ae, $00, $ff, $00, $c0, $00, $b1, $00, $b8, $00, $ff, $00, $b6, $00, $be, $00, $bc, $00, $bd ; db $76, $00, $b7, $00, $b8, $00, $bd, $00, $ff, $00, $ab, $00, $ae, $00, $ff, $00, $b7, $00, $aa, $00, $b6, $00, $ae, $00, $ad, $00, $cD ; db $7f, $7f ;;-------------------------------------------------------------------------------- ; .redMailForCowards ; ; RED MAIL / IS FOR / COWARDS. ; db $00, $bb, $00, $ae, $00, $ad, $00, $ff, $00, $b6, $00, $aa, $00, $b2, $00, $b5 ; db $75, $00, $b2, $00, $bc, $00, $ff, $00, $af, $00, $b8, $00, $bb ; db $76, $00, $ac, $00, $b8, $00, $c0, $00, $aa, $00, $bb, $00, $ad, $00, $bc, $00, $cD ; db $7f, $7f ;;-------------------------------------------------------------------------------- ; .heyListen ; ; HEY! / / LISTEN! ; db $00, $b1, $00, $ae, $00, $c2, $00, $c7 ; db $76, $00, $b5, $00, $b2, $00, $bc, $00, $bd, $00, $ae, $00, $b7, $00, $c7 ; db $7f, $7f ;;-------------------------------------------------------------------------------- ; .excuseMePrincess ; ; Well / excuuuuuse me, / princess! ; db $00, $c0, $00, $ae, $00, $b5, $00, $b5 ; db $75, $00, $ae, $00, $c1, $00, $ac, $00, $be, $00, $be, $00, $be, $00, $be, $00, $be, $00, $bc, $00, $ae, $00, $ff, $00, $b6, $00, $ae, $00, $c8 ; db $76, $00, $b9, $00, $bb, $00, $b2, $00, $b7, $00, $ac, $00, $ae, $00, $bc, $00, $bc, $00, $c7 ; db $7f, $7f ;;-------------------------------------------------------------------------------- ^32nd
CGROUP group code code segment dword 'CODE' assume cs:CGROUP,ds:CGROUP ;pj_unss2 decodes a FLI_LS chunk of a flic frame. public pj_unss2 ; pj_unss2(cbuf, screen, bpr, screen_seg) ; UBYTE *cbuf; /* points to a FLI_LC chunk after chunk header. */ ; UBYTE *screen; ; int screen_seg pj_unss2 proc near pubr struc pulc_edx dd ? pulc_ecx dd ? pulc_ebx dd ? pulc_edi dd ? pulc_esi dd ? pulc_es dd ? pulc_ebp dd ? pulc_ret dd ? pulc_cbuf dd ? pulc_screen dd ? pulc_bpr dd ? pulc_seg dd ? pulc_width dd ? pubr ends ;save the world and set the basepage push ebp mov ebp,esp push es push esi push edi push ebx push ecx push edx mov eax,[esp].pulc_seg mov es,ax ;set destination segment mov esi,[esp].pulc_cbuf ;source is compressed stream mov edi,[esp].pulc_screen ;destination is screen in edi mov ebp,[esp].pulc_bpr lodsw ;get the count of lines packets mov edx,eax xor ecx,ecx ;clear out hi bits of count jmp lpack skiplines: ;come here to skip some lines push edx neg ax mul ebp pop edx add edi,eax xor eax,eax ;clear hi bits of eax for later... lpack: ss2d: lodsw ;fetch line op test ax,ax jns do_opcount ; if positive it's an ss2 opcount cmp ah,0C0h ; if bit 0x40 of ah is on (unsigned >= C0h) jae skiplines ; we skip lines ; if not put immediate dot at end of line mov ebx,[esp].pulc_width ; width to ebx mov byte ptr es:[edi+ebx-1],al ; put dot at screen + width - 1 lodsw ; get following opcount for compressed data test ax,ax jz line_is_done ; if no ops line is done do_opcount: mov bx,ax ; number of ops in this line to bx push edi ppack: lodsw ;5 mov cl,al ;2 add edi,ecx ;2 test ah,ah ;2 js prun ;? mov cl,ah ;2 rep movsw dec bx jnz ppack pop edi line_is_done: add edi,ebp ;Go to next line of destination. dec edx ; --lineops jnz lpack ; not done lpack jmp pend prun: neg ah mov cl,ah lodsw rep stosw dec bx jnz ppack pop edi add edi,ebp ;Go to next line of destination. dec edx jnz lpack pend: mov eax,esi ;return position in compression stream pop edx pop ecx pop ebx pop edi pop esi pop es pop ebp ret pj_unss2 endp code ends end
puts: puts.loop: LOD $10, $0 CMP $11, $10, #0 BRA puts.end, !EQ $11 STO #1:#0, $10 ADD $0, $0, #1 BRA puts.loop puts.end: RET
;; last edit date: 2016/11/24 ;; author: Forec ;; LICENSE ;; Copyright (c) 2015-2017, Forec <forec@bupt.edu.cn> ;; Permission to use, copy, modify, and/or distribute this code for any ;; purpose with or without fee is hereby granted, provided that the above ;; copyright notice and this permission notice appear in all copies. ;; THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES ;; WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF ;; MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ;; ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES ;; WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ;; ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF ;; OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. title forec_t45 code segment assume cs:code start: mov cx, 0aaaah ;; 10101010 10101010 -> 11001100 11001100 mov ax, cx mov bx, cx mov cx, 8h loop1: shr ah, 01h jc hzero or bx, 0001h jmp checkL hzero: and bx, 0fffeh checkL: shl bx, 01h shr al, 01h jc lzero or bx, 01h jmp continueLoop lzero: and bx, 0fffeh continueLoop: cmp cx, 01h jz quit shl bx, 01h loop loop1 quit: mov cx, bx mov ah, 4ch int 21h code ends end start
.global s_prepare_buffers s_prepare_buffers: push %r10 push %r14 push %r15 push %r8 push %rcx push %rdi push %rdx push %rsi lea addresses_normal_ht+0xb23d, %rsi nop and $38747, %r10 mov (%rsi), %rdi nop nop nop and $63129, %r14 lea addresses_D_ht+0x8155, %r8 nop nop nop nop add %rdx, %rdx mov (%r8), %esi nop nop nop nop add $50561, %r10 lea addresses_normal_ht+0x1a9f5, %r8 nop nop sub %r15, %r15 mov (%r8), %rsi nop nop cmp $1417, %rsi lea addresses_D_ht+0x95c7, %rdi nop nop nop dec %rsi mov $0x6162636465666768, %r15 movq %r15, %xmm4 vmovups %ymm4, (%rdi) nop nop nop and %rdx, %rdx lea addresses_D_ht+0xd975, %rdx cmp %rdi, %rdi movw $0x6162, (%rdx) nop nop nop nop and $11641, %rdi lea addresses_normal_ht+0x1c9f5, %r10 nop nop nop nop lfence movb $0x61, (%r10) nop nop dec %r15 lea addresses_UC_ht+0xd309, %rsi lea addresses_D_ht+0x14d12, %rdi nop nop xor $23592, %r8 mov $31, %rcx rep movsq nop nop nop nop nop xor %r10, %r10 lea addresses_WC_ht+0xe8f5, %rsi lea addresses_UC_ht+0x79f5, %rdi nop nop nop nop nop dec %r15 mov $60, %rcx rep movsb dec %rdi lea addresses_normal_ht+0x1b9f5, %rsi lea addresses_A_ht+0x8f5, %rdi nop xor $64392, %rdx mov $124, %rcx rep movsb nop nop add $32692, %r14 lea addresses_D_ht+0x1d775, %r14 nop nop nop nop nop inc %rdx and $0xffffffffffffffc0, %r14 vmovntdqa (%r14), %ymm2 vextracti128 $0, %ymm2, %xmm2 vpextrq $0, %xmm2, %rdi nop nop nop nop dec %rsi lea addresses_D_ht+0x1d735, %rdi clflush (%rdi) add %rsi, %rsi mov (%rdi), %r8d nop nop nop dec %rsi lea addresses_normal_ht+0x319d, %r15 nop nop nop nop dec %r10 mov (%r15), %r8w inc %r10 lea addresses_normal_ht+0x12025, %r14 nop nop sub $62835, %rdx movl $0x61626364, (%r14) nop nop nop nop cmp $58777, %r8 lea addresses_WT_ht+0x1b05d, %r10 clflush (%r10) nop nop nop nop sub %rcx, %rcx mov $0x6162636465666768, %r15 movq %r15, %xmm2 and $0xffffffffffffffc0, %r10 vmovaps %ymm2, (%r10) nop nop add %rdx, %rdx lea addresses_A_ht+0xb5f5, %rsi lea addresses_normal_ht+0x185e3, %rdi clflush (%rsi) clflush (%rdi) cmp $4148, %r14 mov $52, %rcx rep movsl nop sub %r10, %r10 pop %rsi pop %rdx pop %rdi pop %rcx pop %r8 pop %r15 pop %r14 pop %r10 ret .global s_faulty_load s_faulty_load: push %r10 push %r12 push %r14 push %r15 push %r9 push %rbx push %rdi // Load lea addresses_RW+0x11055, %r9 nop nop nop cmp $64725, %r12 vmovups (%r9), %ymm2 vextracti128 $0, %ymm2, %xmm2 vpextrq $0, %xmm2, %r15 nop nop nop nop nop cmp %rdi, %rdi // Store lea addresses_RW+0x1af35, %r10 xor %rbx, %rbx movl $0x51525354, (%r10) nop nop nop nop cmp %rdi, %rdi // Store lea addresses_UC+0x3ad5, %r12 nop sub %r14, %r14 movl $0x51525354, (%r12) nop add $51815, %r14 // Faulty Load lea addresses_PSE+0x139f5, %r14 add %r9, %r9 mov (%r14), %r15w lea oracles, %rdi and $0xff, %r15 shlq $12, %r15 mov (%rdi,%r15,1), %r15 pop %rdi pop %rbx pop %r9 pop %r15 pop %r14 pop %r12 pop %r10 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'type': 'addresses_PSE', 'size': 8, 'AVXalign': True, 'NT': False, 'congruent': 0, 'same': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_RW', 'size': 32, 'AVXalign': False, 'NT': False, 'congruent': 5, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_RW', 'size': 4, 'AVXalign': False, 'NT': False, 'congruent': 6, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_UC', 'size': 4, 'AVXalign': False, 'NT': False, 'congruent': 5, 'same': False}} [Faulty Load] {'OP': 'LOAD', 'src': {'type': 'addresses_PSE', 'size': 2, 'AVXalign': False, 'NT': True, 'congruent': 0, 'same': True}} <gen_prepare_buffer> {'OP': 'LOAD', 'src': {'type': 'addresses_normal_ht', 'size': 8, 'AVXalign': False, 'NT': False, 'congruent': 1, 'same': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_D_ht', 'size': 4, 'AVXalign': False, 'NT': False, 'congruent': 4, 'same': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_normal_ht', 'size': 8, 'AVXalign': True, 'NT': False, 'congruent': 11, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_D_ht', 'size': 32, 'AVXalign': False, 'NT': False, 'congruent': 1, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_D_ht', 'size': 2, 'AVXalign': False, 'NT': False, 'congruent': 7, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_normal_ht', 'size': 1, 'AVXalign': False, 'NT': False, 'congruent': 10, 'same': False}} {'OP': 'REPM', 'src': {'type': 'addresses_UC_ht', 'congruent': 2, 'same': False}, 'dst': {'type': 'addresses_D_ht', 'congruent': 0, 'same': False}} {'OP': 'REPM', 'src': {'type': 'addresses_WC_ht', 'congruent': 1, 'same': False}, 'dst': {'type': 'addresses_UC_ht', 'congruent': 11, 'same': False}} {'OP': 'REPM', 'src': {'type': 'addresses_normal_ht', 'congruent': 8, 'same': False}, 'dst': {'type': 'addresses_A_ht', 'congruent': 8, 'same': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_D_ht', 'size': 32, 'AVXalign': False, 'NT': True, 'congruent': 7, 'same': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_D_ht', 'size': 4, 'AVXalign': False, 'NT': False, 'congruent': 6, 'same': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_normal_ht', 'size': 2, 'AVXalign': False, 'NT': False, 'congruent': 2, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_normal_ht', 'size': 4, 'AVXalign': True, 'NT': True, 'congruent': 4, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_WT_ht', 'size': 32, 'AVXalign': True, 'NT': True, 'congruent': 2, 'same': False}} {'OP': 'REPM', 'src': {'type': 'addresses_A_ht', 'congruent': 9, 'same': False}, 'dst': {'type': 'addresses_normal_ht', 'congruent': 1, 'same': False}} {'33': 357} 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 */
; A055658: Number of (3,n)-partitions of a chain of length n^2. ; 0,0,1,35,286,1330,4495,12341,29260,62196,121485,221815,383306,632710,1004731,1543465,2303960,3353896,4775385,6666891,9145270,12347930,16435111,21592285,28032676,35999900,45770725,57657951,72013410,89231086,109750355,134059345,162698416,196263760,235411121,280859635,333395790,393877506,463238335,542491781,632735740,735157060,851036221,981752135,1128787066,1293731670,1478290155,1684285561,1913665160,2168505976,2451020425,2763562075,3108631526,3488882410,3907127511,4366345005,4869684820,5420475116,6022228885,6678650671,7393643410,8171315390,9015987331,9932199585,10924719456,11998548640,13158930785,14411359171,15761584510,17215622866,18779763695,20460578005,22264926636,24199968660,26273169901,28492311575,30865499050,33401170726,36108107035,38995439561,42072660280,45349630920,48836592441,52544174635,56483405846,60665722810,65102980615,69807462781,74791891460,80069437756,85653732165,91558875135,97799447746,104390522510,111347674291,118686991345,126425086480,134579108336,143166752785,152206274451,161716498350,171716831650,182227275551,193268437285,204861542236,217028446180,229791647645,243174300391,257200226010,271893926646,287280597835,303386141465,320237178856,337861063960,356285896681,375540536315,395654615110,416658551946,438583566135,461461691341,485325789620,510209565580,536147580661,563175267535,591328944626,620645830750,651164059875,682922696001,715961748160,750322185536,786045952705,823175984995,861756223966,901831633010,943448213071,986653018485,1031494172940,1078020885556,1126283467085,1176333346231,1228223086090,1282006400710,1337738171771,1395474465385,1455272549016,1517190908520,1581289265305,1647628593611,1716271137910,1787280430426,1860721308775,1936659933725,2015163807076,2096301789660,2180144119461,2266762429855,2356229767970,2448620613166,2544010895635,2642478015121,2744100859760,2848959825040,2957136832881,3068715350835,3183780411406,3302418631490,3424718231935,3550769057221,3680662595260,3814491997316,3952352098045,4094339435655,4240552272186,4391090613910,4546056231851,4705552682425,4869685328200,5038561358776,5212289811785,5390981594011,5574749502630,5763708246570,5957974467991,6157666763885,6362905707796,6573813871660,6790515847765,7013138270831,7241809840210,7476661342206,7717825672515,7965437858785,8219635083296,8480556705760,8748344286241,9023141608195,9305094701630,9594351866386,9891063695535,10195383098901,10507465326700,10827467993300,11155551101101,11491877064535,11836610734186,12189919421030,12551972920795,12922943538441,13303006112760,13692338041096,14091119304185,14499532491115,14917762824406,15345998185210,15784429138631,16233248959165,16692653656260,17162841999996,17644015546885,18136378665791,18640138563970,19155505313230,19682691876211,20221914132785,20773390906576,21337343991600,21913998179025,22503581284051,23106324172910,23722460789986,24352228185055,24995866540645,25653619199516,26325732692260,27012456765021,27714044407335,28430751880090,29162838743606,29910567885835,30674205550681,31454021366440,32250288374360,33063283057321,33893285368635,34740578760966,35605450215370,36488190270455,37389093051661,38308456300660,39246581404876 bin $0,2 mul $0,2 add $0,1 bin $0,3 mov $1,$0
; A025685: Exponent of 10 (value of j) in n-th number of form 3^i*10^j. ; 0,0,0,1,0,1,0,1,2,0,1,2,0,1,2,3,0,1,2,3,0,1,2,3,4,0,1,2,3,4,0,1,2,3,4,5,0,1,2,3,4,5,0,1,2,3,4,5,6,0,1,2,3,4,5,6,0,1,2,3,4,5,6,7,0,1,2,3,4,5,6,7,0,1,2,3,4,5,6,7,8,0,1,2,3,4,5,6,7,8,0,1,2,3,4,5,6,7,8,9 mov $1,$0 lpb $1 sub $1,1 add $3,1 trn $0,$3 mov $2,$1 mov $1,$0 mov $0,$2 lpe
; A167337: Totally multiplicative sequence with a(p) = 2*(5p+1) = 10p+2 for prime p. ; Submitted by Jon Maiga ; 1,22,32,484,52,704,72,10648,1024,1144,112,15488,132,1584,1664,234256,172,22528,192,25168,2304,2464,232,340736,2704,2904,32768,34848,292,36608,312,5153632,3584,3784,3744,495616,372,4224,4224,553696,412,50688,432,54208,53248,5104,472,7496192,5184,59488,5504,63888,532,720896,5824,766656,6144,6424,592,805376,612,6864,73728,113379904,6864,78848,672,83248,7424,82368,712,10903552,732,8184,86528,92928,8064,92928,792,12181312,1048576,9064,832,1115136,8944,9504,9344,1192576,892,1171456,9504,112288,9984 add $0,1 mul $0,2 mov $1,1 mov $2,2 mov $4,2 lpb $0 mul $1,$4 mov $3,$0 sub $3,1 add $5,1 lpb $3 mov $4,$0 mod $4,$2 add $2,1 cmp $4,0 cmp $4,0 sub $3,$4 lpe div $0,$2 mov $4,$2 add $5,$2 lpb $5 mul $4,9 add $4,$5 mov $5,1 lpe lpe mov $0,$1 div $0,42
SECTION code_clib SECTION code_l_sccz80 PUBLIC dpush3 EXTERN fa ;------------------------------------------------------ ; Push FA onto stack under ret address and stacked long ;------------------------------------------------------ dpush3: exx pop hl ;save return address pop de ;save next word pop bc ;and the high word exx ld hl,(fa+4) push hl ld hl,(fa+2) push hl ld hl,(fa) push hl exx push bc push de push hl exx ret
/*========================================================================= Program: Visualization Toolkit Module: vtkOpenGLPolyDataMapper2D.cxx Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen All rights reserved. See Copyright.txt or http://www.kitware.com/Copyright.htm for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notice for more information. =========================================================================*/ #include "vtkOpenGLPolyDataMapper2D.h" #include "vtkOpenGLHelper.h" #include "vtkActor2D.h" #include "vtkCellArray.h" #include "vtkHardwareSelector.h" #include "vtkInformation.h" #include "vtkMath.h" #include "vtkMatrix4x4.h" #include "vtkObjectFactory.h" #include "vtkOpenGLBufferObject.h" #include "vtkOpenGLError.h" #include "vtkOpenGLIndexBufferObject.h" #include "vtkOpenGLPolyDataMapper.h" #include "vtkOpenGLRenderer.h" #include "vtkOpenGLRenderWindow.h" #include "vtkOpenGLResourceFreeCallback.h" #include "vtkOpenGLShaderCache.h" #include "vtkOpenGLState.h" #include "vtkOpenGLTexture.h" #include "vtkOpenGLVertexArrayObject.h" #include "vtkOpenGLVertexBufferObjectCache.h" #include "vtkOpenGLVertexBufferObjectGroup.h" #include "vtkPointData.h" #include "vtkPolyData.h" #include "vtkProperty2D.h" #include "vtkProperty.h" #include "vtkShaderProgram.h" #include "vtkTextureObject.h" #include "vtkTransform.h" #include "vtkUnsignedCharArray.h" #include "vtkViewport.h" // Bring in our shader symbols. #include "vtkPolyData2DVS.h" #include "vtkPolyData2DFS.h" #include "vtkPolyDataWideLineGS.h" //----------------------------------------------------------------------------- vtkStandardNewMacro(vtkOpenGLPolyDataMapper2D); //----------------------------------------------------------------------------- vtkOpenGLPolyDataMapper2D::vtkOpenGLPolyDataMapper2D() { this->TransformedPoints = nullptr; this->CellScalarTexture = nullptr; this->CellScalarBuffer = nullptr; this->AppleBugPrimIDBuffer = nullptr; this->HaveAppleBug = false; this->LastBoundBO = nullptr; this->HaveCellScalars = false; this->PrimitiveIDOffset = 0; this->LastPickState = 0; this->VBOs = vtkOpenGLVertexBufferObjectGroup::New(); this->ResourceCallback = new vtkOpenGLResourceFreeCallback<vtkOpenGLPolyDataMapper2D>(this, &vtkOpenGLPolyDataMapper2D::ReleaseGraphicsResources); } //----------------------------------------------------------------------------- vtkOpenGLPolyDataMapper2D::~vtkOpenGLPolyDataMapper2D() { if (this->ResourceCallback) { this->ResourceCallback->Release(); delete this->ResourceCallback; this->ResourceCallback = nullptr; } if (this->TransformedPoints) { this->TransformedPoints->UnRegister(this); } if (this->CellScalarTexture) { // Resources released previously. this->CellScalarTexture->Delete(); this->CellScalarTexture = nullptr; } if (this->CellScalarBuffer) { // Resources released previously. this->CellScalarBuffer->Delete(); this->CellScalarBuffer = nullptr; } this->HaveCellScalars = false; if (this->AppleBugPrimIDBuffer) { this->AppleBugPrimIDBuffer->Delete(); } this->VBOs->Delete(); this->VBOs = nullptr; } //----------------------------------------------------------------------------- void vtkOpenGLPolyDataMapper2D::ReleaseGraphicsResources(vtkWindow* win) { if (!this->ResourceCallback->IsReleasing()) { this->ResourceCallback->Release(); return; } this->VBOs->ReleaseGraphicsResources(win); this->Points.ReleaseGraphicsResources(win); this->Lines.ReleaseGraphicsResources(win); this->Tris.ReleaseGraphicsResources(win); this->TriStrips.ReleaseGraphicsResources(win); if (this->CellScalarTexture) { this->CellScalarTexture->ReleaseGraphicsResources(win); } if (this->CellScalarBuffer) { this->CellScalarBuffer->ReleaseGraphicsResources(); } if (this->AppleBugPrimIDBuffer) { this->AppleBugPrimIDBuffer->ReleaseGraphicsResources(); } this->Modified(); } //----------------------------------------------------------------------------- bool vtkOpenGLPolyDataMapper2D::GetNeedToRebuildShaders( vtkOpenGLHelper &cellBO, vtkViewport* vtkNotUsed(viewport), vtkActor2D *actor) { // has something changed that would require us to recreate the shader? // candidates are // property modified (representation interpolation and lighting) // input modified // light complexity changed if (cellBO.Program == nullptr || cellBO.ShaderSourceTime < this->GetMTime() || cellBO.ShaderSourceTime < actor->GetMTime() || cellBO.ShaderSourceTime < this->GetInput()->GetMTime() || cellBO.ShaderSourceTime < this->PickStateChanged) { return true; } return false; } //----------------------------------------------------------------------------- void vtkOpenGLPolyDataMapper2D::BuildShaders( std::string &VSSource, std::string &FSSource, std::string &GSSource, vtkViewport* viewport, vtkActor2D *actor) { VSSource = vtkPolyData2DVS; FSSource = vtkPolyData2DFS; if (this->HaveWideLines(viewport, actor)) { GSSource = vtkPolyDataWideLineGS; } else { GSSource.clear(); } // Build our shader if necessary. if (this->HaveCellScalars) { vtkShaderProgram::Substitute(FSSource, "//VTK::Color::Dec", "uniform samplerBuffer textureC;"); vtkShaderProgram::Substitute(FSSource, "//VTK::Color::Impl", "gl_FragData[0] = texelFetchBuffer(textureC, gl_PrimitiveID + PrimitiveIDOffset);"); } else { if (this->Colors && this->Colors->GetNumberOfComponents()) { vtkShaderProgram::Substitute(VSSource, "//VTK::Color::Dec", "in vec4 diffuseColor;\n" "out vec4 fcolorVSOutput;"); vtkShaderProgram::Substitute(VSSource, "//VTK::Color::Impl", "fcolorVSOutput = diffuseColor;"); vtkShaderProgram::Substitute(GSSource, "//VTK::Color::Dec", "in vec4 fcolorVSOutput[];\n" "out vec4 fcolorGSOutput;"); vtkShaderProgram::Substitute(GSSource, "//VTK::Color::Impl", "fcolorGSOutput = fcolorVSOutput[i];"); vtkShaderProgram::Substitute(FSSource, "//VTK::Color::Dec", "in vec4 fcolorVSOutput;"); vtkShaderProgram::Substitute(FSSource, "//VTK::Color::Impl", "gl_FragData[0] = fcolorVSOutput;"); } else { vtkShaderProgram::Substitute(FSSource, "//VTK::Color::Dec", "uniform vec4 diffuseColor;"); vtkShaderProgram::Substitute(FSSource, "//VTK::Color::Impl", "gl_FragData[0] = diffuseColor;"); } } int numTCoordComps = this->VBOs->GetNumberOfComponents("tcoordMC"); if (numTCoordComps == 1 || numTCoordComps == 2) { if (numTCoordComps == 1) { vtkShaderProgram::Substitute(VSSource, "//VTK::TCoord::Dec", "in float tcoordMC; out float tcoordVCVSOutput;"); vtkShaderProgram::Substitute(VSSource, "//VTK::TCoord::Impl", "tcoordVCVSOutput = tcoordMC;"); vtkShaderProgram::Substitute(GSSource, "//VTK::TCoord::Dec", "in float tcoordVCVSOutput[];\n" "out float tcoordVCGSOutput;"); vtkShaderProgram::Substitute(GSSource, "//VTK::TCoord::Impl", "tcoordVCGSOutput = tcoordVCVSOutput[i];"); vtkShaderProgram::Substitute(FSSource, "//VTK::TCoord::Dec", "in float tcoordVCVSOutput; uniform sampler2D texture1;"); vtkShaderProgram::Substitute(FSSource, "//VTK::TCoord::Impl", "gl_FragData[0] = gl_FragData[0]*texture2D(texture1, vec2(tcoordVCVSOutput,0));"); } else { vtkShaderProgram::Substitute(VSSource, "//VTK::TCoord::Dec", "in vec2 tcoordMC; out vec2 tcoordVCVSOutput;"); vtkShaderProgram::Substitute(VSSource, "//VTK::TCoord::Impl", "tcoordVCVSOutput = tcoordMC;"); vtkShaderProgram::Substitute(GSSource, "//VTK::TCoord::Dec", "in vec2 tcoordVCVSOutput[];\n" "out vec2 tcoordVCGSOutput;"); vtkShaderProgram::Substitute(GSSource, "//VTK::TCoord::Impl", "tcoordVCGSOutput = tcoordVCVSOutput[i];"); vtkShaderProgram::Substitute(FSSource, "//VTK::TCoord::Dec", "in vec2 tcoordVCVSOutput; uniform sampler2D texture1;"); vtkShaderProgram::Substitute(FSSource, "//VTK::TCoord::Impl", "gl_FragData[0] = gl_FragData[0]*texture2D(texture1, tcoordVCVSOutput.st);"); } } // are we handling the apple bug? if (!this->AppleBugPrimIDs.empty()) { vtkShaderProgram::Substitute(VSSource,"//VTK::PrimID::Dec", "in vec4 appleBugPrimID;\n" "out vec4 applePrimIDVSOutput;"); vtkShaderProgram::Substitute(VSSource,"//VTK::PrimID::Impl", "applePrimIDVSOutput = appleBugPrimID;"); vtkShaderProgram::Substitute(GSSource, "//VTK::PrimID::Dec", "in vec4 applePrimIDVSOutput[];\n" "out vec4 applePrimIDGSOutput;"); vtkShaderProgram::Substitute(GSSource, "//VTK::PrimID::Impl", "applePrimIDGSOutput = applePrimIDVSOutput[i];"); vtkShaderProgram::Substitute(FSSource,"//VTK::PrimID::Dec", "in vec4 applePrimIDVSOutput;"); vtkShaderProgram::Substitute(FSSource,"//VTK::PrimID::Impl", "int vtkPrimID = int(applePrimIDVSOutput[0]*255.1) + int(applePrimIDVSOutput[1]*255.1)*256 + int(applePrimIDVSOutput[2]*255.1)*65536;"); vtkShaderProgram::Substitute(FSSource,"gl_PrimitiveID","vtkPrimID"); } else { if (this->HaveCellScalars) { vtkShaderProgram::Substitute(GSSource, "//VTK::PrimID::Impl", "gl_PrimitiveID = gl_PrimitiveIDIn;"); } } vtkRenderer* ren = vtkRenderer::SafeDownCast(viewport); if (ren && ren->GetSelector()) { this->ReplaceShaderPicking(FSSource, ren, actor); } } //----------------------------------------------------------------------------- void vtkOpenGLPolyDataMapper2D::UpdateShaders(vtkOpenGLHelper &cellBO, vtkViewport* viewport, vtkActor2D *actor) { vtkOpenGLRenderWindow *renWin = vtkOpenGLRenderWindow::SafeDownCast(viewport->GetVTKWindow()); cellBO.VAO->Bind(); this->LastBoundBO = &cellBO; if (this->GetNeedToRebuildShaders(cellBO, viewport, actor)) { std::string VSSource; std::string FSSource; std::string GSSource; this->BuildShaders(VSSource,FSSource,GSSource,viewport,actor); vtkShaderProgram *newShader = renWin->GetShaderCache()->ReadyShaderProgram( VSSource.c_str(), FSSource.c_str(), GSSource.c_str()); cellBO.ShaderSourceTime.Modified(); // if the shader changed reinitialize the VAO if (newShader != cellBO.Program) { cellBO.Program = newShader; cellBO.VAO->ShaderProgramChanged(); // reset the VAO as the shader has changed } } else { renWin->GetShaderCache()->ReadyShaderProgram(cellBO.Program); } if (cellBO.Program) { this->SetMapperShaderParameters(cellBO, viewport, actor); this->SetPropertyShaderParameters(cellBO, viewport, actor); this->SetCameraShaderParameters(cellBO, viewport, actor); } } //----------------------------------------------------------------------------- void vtkOpenGLPolyDataMapper2D::SetMapperShaderParameters( vtkOpenGLHelper &cellBO, vtkViewport *viewport, vtkActor2D *actor) { // Now to update the VAO too, if necessary. if (this->VBOUpdateTime > cellBO.AttributeUpdateTime || cellBO.ShaderSourceTime > cellBO.AttributeUpdateTime) { cellBO.VAO->Bind(); this->VBOs->AddAllAttributesToVAO(cellBO.Program, cellBO.VAO); if (!this->AppleBugPrimIDs.empty() && cellBO.Program->IsAttributeUsed("appleBugPrimID")) { this->AppleBugPrimIDBuffer->Bind(); if (!cellBO.VAO->AddAttributeArray(cellBO.Program, this->AppleBugPrimIDBuffer, "appleBugPrimID", 0, sizeof(float), VTK_UNSIGNED_CHAR, 4, true)) { vtkErrorMacro(<< "Error setting 'appleBugPrimID' in shader VAO."); } this->AppleBugPrimIDBuffer->Release(); } cellBO.AttributeUpdateTime.Modified(); } if (this->HaveCellScalars) { int tunit = this->CellScalarTexture->GetTextureUnit(); cellBO.Program->SetUniformi("textureC", tunit); } if (this->VBOs->GetNumberOfComponents("tcoordMC")) { vtkInformation *info = actor->GetPropertyKeys(); if (info && info->Has(vtkProp::GeneralTextureUnit())) { int tunit = info->Get(vtkProp::GeneralTextureUnit()); cellBO.Program->SetUniformi("texture1", tunit); } } // handle wide lines if (this->HaveWideLines(viewport,actor)) { int vp[4]; glGetIntegerv(GL_VIEWPORT, vp); float lineWidth[2]; lineWidth[0] = 2.0*actor->GetProperty()->GetLineWidth()/vp[2]; lineWidth[1] = 2.0*actor->GetProperty()->GetLineWidth()/vp[3]; cellBO.Program->SetUniform2f("lineWidthNVC",lineWidth); } vtkRenderer* ren = vtkRenderer::SafeDownCast(viewport); vtkHardwareSelector* selector = ren->GetSelector(); if (selector && cellBO.Program->IsUniformUsed("mapperIndex")) { cellBO.Program->SetUniform3f("mapperIndex", selector->GetPropColorValue()); } } //----------------------------------------------------------------------------- void vtkOpenGLPolyDataMapper2D::SetPropertyShaderParameters( vtkOpenGLHelper &cellBO, vtkViewport*, vtkActor2D *actor) { if (!this->Colors || !this->Colors->GetNumberOfComponents()) { vtkShaderProgram *program = cellBO.Program; // Query the actor for some of the properties that can be applied. float opacity = static_cast<float>(actor->GetProperty()->GetOpacity()); double *dColor = actor->GetProperty()->GetColor(); float diffuseColor[4] = {static_cast<float>(dColor[0]), static_cast<float>(dColor[1]), static_cast<float>(dColor[2]), static_cast<float>(opacity)}; program->SetUniform4f("diffuseColor", diffuseColor); } } //----------------------------------------------------------------------------- void vtkOpenGLPolyDataMapper2D::ReplaceShaderPicking( std::string & fssource, vtkRenderer *, vtkActor2D *) { vtkShaderProgram::Substitute(fssource, "//VTK::Picking::Dec", "uniform vec3 mapperIndex;"); vtkShaderProgram::Substitute(fssource, "//VTK::Picking::Impl", "gl_FragData[0] = vec4(mapperIndex,1.0);\n"); } //----------------------------------------------------------------------------- void vtkOpenGLPolyDataMapper2D::SetCameraShaderParameters( vtkOpenGLHelper &cellBO, vtkViewport* viewport, vtkActor2D *actor) { vtkShaderProgram *program = cellBO.Program; if(!program) { vtkErrorWithObjectMacro(this," got null shader program, cannot set parameters."); return; } // Get the position of the actor int size[2]; size[0] = viewport->GetSize()[0]; size[1] = viewport->GetSize()[1]; double *vport = viewport->GetViewport(); int* actorPos = actor->GetPositionCoordinate()->GetComputedViewportValue(viewport); // get window info double *tileViewPort = viewport->GetVTKWindow()->GetTileViewport(); double visVP[4]; visVP[0] = (vport[0] >= tileViewPort[0]) ? vport[0] : tileViewPort[0]; visVP[1] = (vport[1] >= tileViewPort[1]) ? vport[1] : tileViewPort[1]; visVP[2] = (vport[2] <= tileViewPort[2]) ? vport[2] : tileViewPort[2]; visVP[3] = (vport[3] <= tileViewPort[3]) ? vport[3] : tileViewPort[3]; if (visVP[0] >= visVP[2]) { return; } if (visVP[1] >= visVP[3]) { return; } size[0] = vtkMath::Round(size[0]*(visVP[2] - visVP[0])/(vport[2] - vport[0])); size[1] = vtkMath::Round(size[1]*(visVP[3] - visVP[1])/(vport[3] - vport[1])); int *winSize = viewport->GetVTKWindow()->GetSize(); int xoff = static_cast<int>(actorPos[0] - (visVP[0] - vport[0])* winSize[0]); int yoff = static_cast<int>(actorPos[1] - (visVP[1] - vport[1])* winSize[1]); // set ortho projection float left = -xoff; float right = -xoff + size[0]; float bottom = -yoff; float top = -yoff + size[1]; // it's an error to call glOrtho with // either left==right or top==bottom if (left==right) { right = left + 1.0; } if (bottom==top) { top = bottom + 1.0; } float nearV = 0; float farV = VTK_FLOAT_MAX; if (actor->GetProperty()->GetDisplayLocation() != VTK_FOREGROUND_LOCATION) { nearV = -VTK_FLOAT_MAX; farV = 0; } // compute the combined ModelView matrix and send it down to save time in the shader vtkMatrix4x4 *tmpMat = vtkMatrix4x4::New(); tmpMat->SetElement(0,0,2.0/(right - left)); tmpMat->SetElement(1,1,2.0/(top - bottom)); // XXX(cppcheck): possible division by zero tmpMat->SetElement(2,2,-2.0/(farV - nearV)); tmpMat->SetElement(3,3,1.0); tmpMat->SetElement(0,3,-1.0*(right+left)/(right-left)); tmpMat->SetElement(1,3,-1.0*(top+bottom)/(top-bottom)); // XXX(cppcheck): possible division by zero tmpMat->SetElement(2,3,-1.0*(farV+nearV)/(farV-nearV)); tmpMat->Transpose(); /* if (this->VBO->GetCoordShiftAndScaleEnabled()) { this->VBOTransformInverse->GetTranspose(this->VBOShiftScale); // Pre-multiply the inverse of the VBO's transform: vtkMatrix4x4::Multiply4x4( this->VBOShiftScale, tmpMat, tmpMat); } */ program->SetUniformMatrix("WCVCMatrix", tmpMat); tmpMat->Delete(); } //------------------------------------------------------------------------- void vtkOpenGLPolyDataMapper2D::UpdateVBO(vtkActor2D *act, vtkViewport *viewport) { vtkPolyData *poly = this->GetInput(); if (poly == nullptr) { return; } // check if this system is subject to the apple/amd primID bug this->HaveAppleBug = static_cast<vtkOpenGLRenderer *>(viewport)->HaveApplePrimitiveIdBug(); this->MapScalars(act->GetProperty()->GetOpacity()); this->HaveCellScalars = false; if (this->ScalarVisibility) { // We must figure out how the scalars should be mapped to the polydata. if ( (this->ScalarMode == VTK_SCALAR_MODE_USE_CELL_DATA || this->ScalarMode == VTK_SCALAR_MODE_USE_CELL_FIELD_DATA || this->ScalarMode == VTK_SCALAR_MODE_USE_FIELD_DATA || !poly->GetPointData()->GetScalars() ) && this->ScalarMode != VTK_SCALAR_MODE_USE_POINT_FIELD_DATA && this->Colors) { this->HaveCellScalars = true; } } // on Apple Macs with the AMD PrimID bug <rdar://20747550> // we use a slow painful approach to work around it (pre 10.11). this->AppleBugPrimIDs.resize(0); if (this->HaveAppleBug && this->HaveCellScalars) { if (!this->AppleBugPrimIDBuffer) { this->AppleBugPrimIDBuffer = vtkOpenGLBufferObject::New(); } poly = vtkOpenGLPolyDataMapper::HandleAppleBug(poly, this->AppleBugPrimIDs); this->AppleBugPrimIDBuffer->Bind(); this->AppleBugPrimIDBuffer->Upload( this->AppleBugPrimIDs, vtkOpenGLBufferObject::ArrayBuffer); this->AppleBugPrimIDBuffer->Release(); #ifndef NDEBUG static bool warnAppleBugOnce = true; if (warnAppleBugOnce) { vtkWarningMacro("VTK is working around a bug in Apple-AMD hardware related to gl_PrimitiveID. This may cause significant memory and performance impacts. You should update to macOS 10.11 or later, where the bug is fixed. Your hardware has been identified as vendor " << (const char *)glGetString(GL_VENDOR) << " with renderer of " << (const char *)glGetString(GL_RENDERER)); warnAppleBugOnce = false; } #endif } // if we have cell scalars then we have to // build the texture vtkCellArray *prims[4]; prims[0] = poly->GetVerts(); prims[1] = poly->GetLines(); prims[2] = poly->GetPolys(); prims[3] = poly->GetStrips(); std::vector<vtkIdType> cellCellMap; vtkDataArray *c = this->Colors; if (this->HaveCellScalars) { if (this->HaveAppleBug) { vtkIdType numCells = poly->GetNumberOfCells(); for (vtkIdType i = 0; i < numCells; i++) { cellCellMap.push_back(i); } } else { vtkOpenGLIndexBufferObject::CreateCellSupportArrays( prims, cellCellMap, VTK_SURFACE, poly->GetPoints()); } if (!this->CellScalarTexture) { this->CellScalarTexture = vtkTextureObject::New(); this->CellScalarBuffer = vtkOpenGLBufferObject::New(); this->CellScalarBuffer->SetType(vtkOpenGLBufferObject::TextureBuffer); } this->CellScalarTexture->SetContext( static_cast<vtkOpenGLRenderWindow*>(viewport->GetVTKWindow())); // create the cell scalar array adjusted for ogl Cells std::vector<unsigned char> newColors; unsigned char *colorPtr = this->Colors->GetPointer(0); int numComp = this->Colors->GetNumberOfComponents(); assert(numComp == 4); for (size_t i = 0; i < cellCellMap.size(); i++) { for (int j = 0; j < numComp; j++) { newColors.push_back(colorPtr[cellCellMap[i]*numComp + j]); } } this->CellScalarBuffer->Upload(newColors, vtkOpenGLBufferObject::ArrayBuffer); this->CellScalarTexture->CreateTextureBuffer( static_cast<unsigned int>(cellCellMap.size()), numComp, VTK_UNSIGNED_CHAR, this->CellScalarBuffer); c = nullptr; } // do we have texture maps? bool haveTextures = false; vtkInformation *info = act->GetPropertyKeys(); if (info && info->Has(vtkProp::GeneralTextureUnit())) { haveTextures = true; } // Transform the points, if necessary vtkPoints* p = poly->GetPoints(); if ( this->TransformCoordinate ) { vtkIdType numPts = p->GetNumberOfPoints(); if (!this->TransformedPoints) { this->TransformedPoints = vtkPoints::New(); } this->TransformedPoints->SetNumberOfPoints(numPts); for (vtkIdType j = 0; j < numPts; j++) { this->TransformCoordinate->SetValue(p->GetPoint(j)); if (this->TransformCoordinateUseDouble) { double* dtmp = this->TransformCoordinate->GetComputedDoubleViewportValue(viewport); this->TransformedPoints->SetPoint(j,dtmp[0], dtmp[1], 0.0); } else { int* itmp = this->TransformCoordinate->GetComputedViewportValue(viewport); this->TransformedPoints->SetPoint(j,itmp[0], itmp[1], 0.0); } } p = this->TransformedPoints; } vtkOpenGLRenderWindow *renWin = vtkOpenGLRenderWindow::SafeDownCast(viewport->GetVTKWindow()); vtkOpenGLVertexBufferObjectCache *cache = renWin->GetVBOCache(); this->VBOs->CacheDataArray("vertexWC", p->GetData(), cache, VTK_FLOAT); this->VBOs->CacheDataArray("tcoordMC", (haveTextures ? poly->GetPointData()->GetTCoords() : nullptr), cache, VTK_FLOAT); this->VBOs->CacheDataArray("diffuseColor", c, cache, VTK_UNSIGNED_CHAR); this->VBOs->BuildAllVBOs(cache); this->VBOUpdateTime.Modified(); // need to call all the time or GetNeedToRebuild will always return true; this->Points.IBO->IndexCount = this->Points.IBO->CreatePointIndexBuffer(prims[0]); this->Lines.IBO->IndexCount = this->Lines.IBO->CreateLineIndexBuffer(prims[1]); this->Tris.IBO->IndexCount = this->Tris.IBO->CreateTriangleIndexBuffer(prims[2], poly->GetPoints()); this->TriStrips.IBO->IndexCount = this->TriStrips.IBO->CreateStripIndexBuffer(prims[3], false); // free up polydata if allocated due to apple bug if (poly != this->GetInput()) { poly->Delete(); } } bool vtkOpenGLPolyDataMapper2D::HaveWideLines( vtkViewport *ren, vtkActor2D *actor) { if (this->LastBoundBO == &this->Lines && actor->GetProperty()->GetLineWidth() > 1.0) { // we have wide lines, but the OpenGL implementation may // actually support them, check the range to see if we // really need have to implement our own wide lines vtkOpenGLRenderWindow *renWin = vtkOpenGLRenderWindow::SafeDownCast(ren->GetVTKWindow()); return !(renWin && renWin->GetMaximumHardwareLineWidth() >= actor->GetProperty()->GetLineWidth()); } return false; } void vtkOpenGLPolyDataMapper2D::RenderOverlay(vtkViewport* viewport, vtkActor2D* actor) { vtkOpenGLClearErrorMacro(); vtkPolyData* input = this->GetInput(); vtkDebugMacro (<< "vtkOpenGLPolyDataMapper2D::Render"); if ( input == nullptr ) { vtkErrorMacro(<< "No input!"); return; } this->GetInputAlgorithm()->Update(); vtkIdType numPts = input->GetNumberOfPoints(); if (numPts == 0) { vtkDebugMacro(<< "No points!"); return; } if ( this->LookupTable == nullptr ) { this->CreateDefaultLookupTable(); } vtkRenderWindow *renWin = vtkRenderWindow::SafeDownCast(viewport->GetVTKWindow()); this->ResourceCallback->RegisterGraphicsResources( static_cast<vtkOpenGLRenderWindow *>(renWin)); vtkRenderer* ren = vtkRenderer::SafeDownCast(viewport); vtkHardwareSelector* selector = ren->GetSelector(); if (selector) { selector->BeginRenderProp(); } int picking = (selector ? 1 : 0); if (picking != this->LastPickState) { this->LastPickState = picking; this->PickStateChanged.Modified(); } // Assume we want to do Zbuffering for now. // we may turn this off later static_cast<vtkOpenGLRenderWindow *>(renWin)->GetState()->vtkglDepthMask(GL_TRUE); // Update the VBO if needed. if (this->VBOUpdateTime < this->GetMTime() || this->VBOUpdateTime < actor->GetMTime() || this->VBOUpdateTime < input->GetMTime() || (this->TransformCoordinate && ( this->VBOUpdateTime < viewport->GetMTime() || this->VBOUpdateTime < viewport->GetVTKWindow()->GetMTime())) ) { this->UpdateVBO(actor, viewport); this->VBOUpdateTime.Modified(); } // this->VBOs->Bind(); this->LastBoundBO = nullptr; if (this->HaveCellScalars) { this->CellScalarTexture->Activate(); } // Figure out and build the appropriate shader for the mapped geometry. this->PrimitiveIDOffset = 0; int numVerts = this->VBOs->GetNumberOfTuples("vertexWC"); if (this->Points.IBO->IndexCount) { this->UpdateShaders(this->Points, viewport, actor); if(this->Points.Program) { this->Points.Program->SetUniformi("PrimitiveIDOffset",this->PrimitiveIDOffset); } // Set the PointSize #if GL_ES_VERSION_3_0 != 1 glPointSize(actor->GetProperty()->GetPointSize()); // not on ES2 #endif this->Points.IBO->Bind(); glDrawRangeElements(GL_POINTS, 0, static_cast<GLuint>(numVerts - 1), static_cast<GLsizei>(this->Points.IBO->IndexCount), GL_UNSIGNED_INT, nullptr); this->Points.IBO->Release(); this->PrimitiveIDOffset += (int)this->Points.IBO->IndexCount; } if (this->Lines.IBO->IndexCount) { // Set the LineWidth this->UpdateShaders(this->Lines, viewport, actor); if (this->Lines.Program) { this->Lines.Program->SetUniformi("PrimitiveIDOffset",this->PrimitiveIDOffset); if (!this->HaveWideLines(viewport,actor)) { glLineWidth(actor->GetProperty()->GetLineWidth()); } this->Lines.IBO->Bind(); glDrawRangeElements(GL_LINES, 0, static_cast<GLuint>(numVerts - 1), static_cast<GLsizei>(this->Lines.IBO->IndexCount), GL_UNSIGNED_INT, nullptr); this->Lines.IBO->Release(); } this->PrimitiveIDOffset += (int)this->Lines.IBO->IndexCount/2; } // now handle lit primitives if (this->Tris.IBO->IndexCount) { this->UpdateShaders(this->Tris, viewport, actor); if (this->Tris.Program) { this->Tris.Program->SetUniformi("PrimitiveIDOffset",this->PrimitiveIDOffset); this->Tris.IBO->Bind(); glDrawRangeElements(GL_TRIANGLES, 0, static_cast<GLuint>(numVerts - 1), static_cast<GLsizei>(this->Tris.IBO->IndexCount), GL_UNSIGNED_INT, nullptr); this->Tris.IBO->Release(); this->PrimitiveIDOffset += (int)this->Tris.IBO->IndexCount/3; } } if (this->TriStrips.IBO->IndexCount) { this->UpdateShaders(this->TriStrips, viewport, actor); if(this->TriStrips.Program) { this->TriStrips.Program->SetUniformi("PrimitiveIDOffset",this->PrimitiveIDOffset); this->TriStrips.IBO->Bind(); glDrawRangeElements(GL_TRIANGLES, 0, static_cast<GLuint>(numVerts - 1), static_cast<GLsizei>(this->TriStrips.IBO->IndexCount), GL_UNSIGNED_INT, nullptr); this->TriStrips.IBO->Release(); } } if (this->HaveCellScalars) { this->CellScalarTexture->Deactivate(); } if (this->LastBoundBO) { this->LastBoundBO->VAO->Release(); } if (selector) { selector->EndRenderProp(); } // this->VBOs->Release(); vtkOpenGLCheckErrorMacro("failed after RenderOverlay"); } //---------------------------------------------------------------------------- void vtkOpenGLPolyDataMapper2D::PrintSelf(ostream& os, vtkIndent indent) { this->Superclass::PrintSelf(os,indent); }
; A186680: Total number of positive integers below 10^n requiring 17 positive biquadrates in their representation as sum of biquadrates. ; Submitted by Jon Maiga ; 0,3,33,63,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65,65 mov $3,$0 mov $5,$0 lpb $5 mov $0,$3 sub $5,1 sub $0,$5 mul $0,2 mov $2,$0 mov $0,1 mov $1,6 sub $2,2 bin $0,$2 bin $1,$2 add $0,$1 add $1,$0 add $4,$1 lpe mov $0,$4
; A008673: Expansion of 1/((1-x)*(1-x^3)*(1-x^5)*(1-x^7)). ; 1,1,1,2,2,3,4,5,6,7,9,10,12,14,16,19,21,24,27,30,34,38,42,46,51,56,61,67,73,79,86,93,100,108,116,125,134,143,153,163,174,185,197,209,221,235,248,262,277,292,308,324,341,358,376,395,414,434,454,475,497,519,542,566,590,615,641,667,694,722,751,780,810,841,872,905,938,972,1007,1042,1079,1116,1154,1193,1233,1274,1315,1358,1401,1445,1491,1537,1584,1632,1681,1731,1782,1834,1887,1941 lpb $0 mov $2,$0 sub $0,3 seq $2,25777 ; Expansion of 1/((1-x)*(1-x^5)*(1-x^7)). add $1,$2 lpe add $1,1 mov $0,$1
; ; Z88 Graphics Functions - Small C+ stubs ; ; Written around the Interlogic Standard Library ; ; Stubs Written by D Morris - 15/10/98 ; ; ; Page the graphics bank in/out - used by all gfx functions ; Simply does a swap... ; ; ; Stefano - Sept 2011 ; ; ; $Id: swapgfxbk.asm,v 1.6 2017-01-02 22:57:58 aralbrec Exp $ ; ; INCLUDE "flos.def" INCLUDE "osca.def" SECTION code_clib PUBLIC swapgfxbk PUBLIC _swapgfxbk PUBLIC swapgfxbk1 PUBLIC _swapgfxbk1 .swapgfxbk ._swapgfxbk ;call kjt_wait_vrt ; wait for last line of display ;call kjt_page_in_video ; page video RAM in at $2000-$3fff di ld (asave),a in a,(sys_mem_select) or $40 out (sys_mem_select),a ; page in video RAM ld a,(asave) ret .swapgfxbk1 ._swapgfxbk1 ld (asave),a in a,(sys_mem_select) ; page in video RAM and $bf out (sys_mem_select),a ;call kjt_page_out_video ; page video RAM out of $2000-$3fff ld a,@10000011 ; Enable keyboard and mouse interrupts only out (sys_irq_enable),a ld a,(asave) ei ret SECTION bss_clib .asave defb 0
/** * Copyright (c) 2017, Timothy Stack * * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, this * list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * Neither the name of Timothy Stack nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. */ #ifndef __vtab_module_hh #define __vtab_module_hh #include <sqlite3.h> #include <string> #include <vector> #include <utility> #include "optional.hpp" #include "lnav_log.hh" #include "lnav_util.hh" #include "yajlpp.hh" #include "mapbox/variant.hpp" #include "sqlite-extension-func.hh" struct from_sqlite_conversion_error : std::exception { from_sqlite_conversion_error(const char *type, int argi) : e_type(type), e_argi(argi) { }; const char *e_type; int e_argi; }; struct sqlite_func_error : std::exception { sqlite_func_error(const char *fmt, ...) { char buffer[1024]; va_list args; va_start(args, fmt); vsnprintf(buffer, sizeof(buffer), fmt, args); va_end(args); this->e_what = buffer; }; const char *what() const noexcept { return this->e_what.c_str(); } std::string e_what; }; template<typename T> struct from_sqlite { inline T operator()(int argc, sqlite3_value **val, int argi) { return T(); }; }; template<> struct from_sqlite<int64_t> { inline int64_t operator()(int argc, sqlite3_value **val, int argi) { if (sqlite3_value_numeric_type(val[argi]) != SQLITE_INTEGER) { throw from_sqlite_conversion_error("integer", argi); } return sqlite3_value_int64(val[argi]); } }; template<> struct from_sqlite<int> { inline int operator()(int argc, sqlite3_value **val, int argi) { if (sqlite3_value_numeric_type(val[argi]) != SQLITE_INTEGER) { throw from_sqlite_conversion_error("integer", argi); } return sqlite3_value_int(val[argi]); } }; template<> struct from_sqlite<const char *> { inline const char *operator()(int argc, sqlite3_value **val, int argi) { return (const char *) sqlite3_value_text(val[argi]); } }; template<> struct from_sqlite<double> { inline double operator()(int argc, sqlite3_value **val, int argi) { return sqlite3_value_double(val[argi]); } }; template<typename T> struct from_sqlite<nonstd::optional<T>> { inline nonstd::optional<T> operator()(int argc, sqlite3_value **val, int argi) { if (argi >= argc || sqlite3_value_type(val[argi]) == SQLITE_NULL) { return nonstd::nullopt; } return nonstd::optional<T>(from_sqlite<T>()(argc, val, argi)); } }; template<typename T> struct from_sqlite<std::vector<T>> { inline std::vector<T> operator()(int argc, sqlite3_value **val, int argi) { std::vector<T> retval; for (int lpc = argi; lpc < argc; lpc++) { retval.emplace_back(from_sqlite<T>()(argc, val, lpc)); } return retval; } }; inline void to_sqlite(sqlite3_context *ctx, const char *str) { if (str == nullptr) { sqlite3_result_null(ctx); } else { sqlite3_result_text(ctx, str, -1, SQLITE_STATIC); } } inline void to_sqlite(sqlite3_context *ctx, const std::string &str) { sqlite3_result_text(ctx, str.c_str(), str.length(), SQLITE_TRANSIENT); } inline void to_sqlite(sqlite3_context *ctx, const string_fragment &sf) { if (sf.is_valid()) { sqlite3_result_text(ctx, &sf.sf_string[sf.sf_begin], sf.length(), SQLITE_TRANSIENT); } else { sqlite3_result_null(ctx); } } inline void to_sqlite(sqlite3_context *ctx, bool val) { sqlite3_result_int(ctx, val); } inline void to_sqlite(sqlite3_context *ctx, int64_t val) { sqlite3_result_int64(ctx, val); } inline void to_sqlite(sqlite3_context *ctx, double val) { sqlite3_result_double(ctx, val); } inline void to_sqlite(sqlite3_context *ctx, const json_string &val) { sqlite3_result_text(ctx, (const char *) val.js_content, val.js_len, free); sqlite3_result_subtype(ctx, JSON_SUBTYPE); } template<typename T> inline void to_sqlite(sqlite3_context *ctx, const nonstd::optional<T> &val) { if (val.has_value()) { to_sqlite(ctx, val.value()); } else { sqlite3_result_null(ctx); } } struct ToSqliteVisitor { ToSqliteVisitor(sqlite3_context *vctx) : tsv_context(vctx) { }; template<typename T> void operator()(T t) const { to_sqlite(this->tsv_context, t); } sqlite3_context *tsv_context; }; template<typename ... Types> void to_sqlite(sqlite3_context *ctx, const mapbox::util::variant<Types...> &val) { ToSqliteVisitor visitor(ctx); mapbox::util::apply_visitor(visitor, val); } template<typename ... Args> struct optional_counter { constexpr static int value = 0; }; template<typename T> struct optional_counter<nonstd::optional<T>> { constexpr static int value = 1; }; template<typename T, typename ... Rest> struct optional_counter<nonstd::optional<T>, Rest...> { constexpr static int value = 1 + sizeof...(Rest); }; template<typename Arg> struct optional_counter<Arg> { constexpr static int value = 0; }; template<typename Arg1, typename ... Args> struct optional_counter<Arg1, Args...> : optional_counter<Args...> { }; template<typename ... Args> struct variadic_counter { constexpr static int value = 0; }; template<typename T> struct variadic_counter<std::vector<T>> { constexpr static int value = 1; }; template<typename Arg> struct variadic_counter<Arg> { constexpr static int value = 0; }; template<typename Arg1, typename ... Args> struct variadic_counter<Arg1, Args...> : variadic_counter<Args...> { }; template<typename F, F f> struct sqlite_func_adapter; template<typename Return, typename ... Args, Return (*f)(Args...)> struct sqlite_func_adapter<Return (*)(Args...), f> { constexpr static int OPT_COUNT = optional_counter<Args...>::value; constexpr static int VAR_COUNT = variadic_counter<Args...>::value; constexpr static int REQ_COUNT = sizeof...(Args) - OPT_COUNT - VAR_COUNT; template<size_t ... Idx> static void func2(sqlite3_context *context, int argc, sqlite3_value **argv, std::index_sequence<Idx...>) { try { Return retval = f(from_sqlite<Args>()(argc, argv, Idx)...); to_sqlite(context, retval); } catch (from_sqlite_conversion_error &e) { char buffer[64]; snprintf(buffer, sizeof(buffer), "Expecting an %s for argument number %d", e.e_type, e.e_argi); sqlite3_result_error(context, buffer, -1); } catch (const std::exception &e) { sqlite3_result_error(context, e.what(), -1); } catch (...) { sqlite3_result_error(context, "Function threw an unexpected exception", -1); } }; static void func1(sqlite3_context *context, int argc, sqlite3_value **argv) { if (argc < REQ_COUNT && VAR_COUNT == 0) { const struct FuncDef *fd = (const FuncDef *) sqlite3_user_data(context); char buffer[128]; if (OPT_COUNT == 0) { snprintf(buffer, sizeof(buffer), "%s() expects exactly %d argument%s", fd->fd_help.ht_name, REQ_COUNT, REQ_COUNT == 1 ? "s" : ""); } else { snprintf(buffer, sizeof(buffer), "%s() expects between %d and %d arguments", fd->fd_help.ht_name, REQ_COUNT, REQ_COUNT + OPT_COUNT); } sqlite3_result_error(context, buffer, -1); return; } for (int lpc = 0; lpc < REQ_COUNT; lpc++) { if (sqlite3_value_type(argv[lpc]) == SQLITE_NULL) { sqlite3_result_null(context); return; } } func2(context, argc, argv, std::make_index_sequence<sizeof...(Args)>{}); }; static FuncDef builder(help_text ht) { require(ht.ht_parameters.size() == sizeof...(Args)); return { ht.ht_name, (OPT_COUNT > 0 || VAR_COUNT > 0) ? -1 : REQ_COUNT, SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0, func1, ht, }; }; }; extern std::string vtab_module_schemas; class vtab_index_constraints { public: vtab_index_constraints(const sqlite3_index_info *index_info) : vic_index_info(*index_info) { }; struct const_iterator { const_iterator(vtab_index_constraints *parent, int index = 0) : i_parent(parent), i_index(index) { while (this->i_index < this->i_parent->vic_index_info.nConstraint && !this->i_parent->vic_index_info.aConstraint[this->i_index].usable) { this->i_index += 1; } }; const_iterator& operator++() { do { this->i_index += 1; } while ( this->i_index < this->i_parent->vic_index_info.nConstraint && !this->i_parent->vic_index_info.aConstraint[this->i_index].usable); return *this; }; const sqlite3_index_info::sqlite3_index_constraint &operator*() const { return this->i_parent->vic_index_info.aConstraint[this->i_index]; }; const sqlite3_index_info::sqlite3_index_constraint *operator->() const { return &this->i_parent->vic_index_info.aConstraint[this->i_index]; }; bool operator!=(const const_iterator &rhs) const { return this->i_parent != rhs.i_parent || this->i_index != rhs.i_index; }; const vtab_index_constraints *i_parent; int i_index; }; const_iterator begin() { return const_iterator(this); }; const_iterator end() { return const_iterator(this, this->vic_index_info.nConstraint); }; private: const sqlite3_index_info &vic_index_info; }; class vtab_index_usage { public: vtab_index_usage(sqlite3_index_info *index_info) : viu_index_info(*index_info), viu_used_column_count(0), viu_max_column(0) { }; void column_used(const vtab_index_constraints::const_iterator &iter) { this->viu_max_column = std::max(iter->iColumn, this->viu_max_column); this->viu_index_info.idxNum |= (1L << iter.i_index); this->viu_used_column_count += 1; }; void allocate_args(int expected) { int n_arg = 0; if (this->viu_used_column_count != expected) { this->viu_index_info.estimatedCost = 2147483647; this->viu_index_info.estimatedRows = 2147483647; return; } for (int lpc = 0; lpc <= this->viu_max_column; lpc++) { for (int cons_index = 0; cons_index < this->viu_index_info.nConstraint; cons_index++) { if (this->viu_index_info.aConstraint[cons_index].iColumn != lpc) { continue; } if (!(this->viu_index_info.idxNum & (1L << cons_index))) { continue; } this->viu_index_info.aConstraintUsage[cons_index].argvIndex = ++n_arg; } } this->viu_index_info.estimatedCost = 1.0; this->viu_index_info.estimatedRows = 1; }; private: sqlite3_index_info &viu_index_info; int viu_used_column_count; int viu_max_column; }; template<typename T> struct vtab_module { static int tvt_create(sqlite3 *db, void *pAux, int argc, const char *const *argv, sqlite3_vtab **pp_vt, char **pzErr) { static typename T::vtab vt; *pp_vt = vt; return sqlite3_declare_vtab(db, T::CREATE_STMT); }; template<typename ... Args, size_t... Idx> static int apply_impl(T &obj, int (T::*func)(sqlite3_vtab *, sqlite3_int64 &, Args...), sqlite3_vtab *tab, sqlite3_int64 &rowid, sqlite3_value **argv, std::index_sequence<Idx...>) { return (obj.*func)(tab, rowid, from_sqlite<Args>()(sizeof...(Args), argv, Idx)...); } template<typename ... Args> static int apply(T &obj, int (T::*func)(sqlite3_vtab *, sqlite3_int64 &, Args...), sqlite3_vtab *tab, sqlite3_int64 &rowid, int argc, sqlite3_value **argv) { require(sizeof...(Args) == 0 || argc == sizeof...(Args)); return apply_impl(obj, func, tab, rowid, argv, std::make_index_sequence<sizeof...(Args)>{}); } static int tvt_destructor(sqlite3_vtab *p_svt) { return SQLITE_OK; } static int tvt_open(sqlite3_vtab *p_svt, sqlite3_vtab_cursor **pp_cursor) { p_svt->zErrMsg = NULL; typename T::cursor *p_cur = new (typename T::cursor)(p_svt); if (p_cur == NULL) { return SQLITE_NOMEM; } else { *pp_cursor = (sqlite3_vtab_cursor *) p_cur; } return SQLITE_OK; } static int tvt_next(sqlite3_vtab_cursor *cur) { typename T::cursor *p_cur = (typename T::cursor *) cur; return p_cur->next(); } static int tvt_eof(sqlite3_vtab_cursor *cur) { typename T::cursor *p_cur = (typename T::cursor *) cur; return p_cur->eof(); } static int tvt_close(sqlite3_vtab_cursor *cur) { typename T::cursor *p_cur = (typename T::cursor *) cur; delete p_cur; return SQLITE_OK; } static int tvt_rowid(sqlite3_vtab_cursor *cur, sqlite_int64 *p_rowid) { typename T::cursor *p_cur = (typename T::cursor *) cur; return p_cur->get_rowid(*p_rowid); }; static int tvt_column(sqlite3_vtab_cursor *cur, sqlite3_context *ctx, int col) { typename T::cursor *p_cur = (typename T::cursor *) cur; T handler; return handler.get_column(*p_cur, ctx, col); }; static int vt_best_index(sqlite3_vtab *tab, sqlite3_index_info *p_info) { return SQLITE_OK; }; static int vt_filter(sqlite3_vtab_cursor *p_vtc, int idxNum, const char *idxStr, int argc, sqlite3_value **argv) { return SQLITE_OK; } static int tvt_update(sqlite3_vtab *tab, int argc, sqlite3_value **argv, sqlite_int64 *rowid) { T handler; if (argc <= 1) { sqlite3_int64 rowid = sqlite3_value_int64(argv[0]); return handler.delete_row(tab, rowid); } if (sqlite3_value_type(argv[0]) == SQLITE_NULL) { sqlite3_int64 *rowid2 = rowid; return vtab_module<T>::apply(handler, &T::insert_row, tab, *rowid2, argc - 2, argv + 2); } sqlite3_int64 index = sqlite3_value_int64(argv[0]); if (index != sqlite3_value_int64(argv[1])) { tab->zErrMsg = sqlite3_mprintf( "The rowids in the lnav_views table cannot be changed"); return SQLITE_ERROR; } return vtab_module<T>::apply(handler, &T::update_row, tab, index, argc - 2, argv + 2); }; template<typename U> auto addUpdate(U u) -> decltype(&U::delete_row, void()) { this->vm_module.xUpdate = tvt_update; }; template<typename U> void addUpdate(...) { }; vtab_module() noexcept { memset(&this->vm_module, 0, sizeof(this->vm_module)); this->vm_module.iVersion = 0; this->vm_module.xCreate = tvt_create; this->vm_module.xConnect = tvt_create; this->vm_module.xOpen = tvt_open; this->vm_module.xNext = tvt_next; this->vm_module.xEof = tvt_eof; this->vm_module.xClose = tvt_close; this->vm_module.xDestroy = tvt_destructor; this->vm_module.xRowid = tvt_rowid; this->vm_module.xDisconnect = tvt_destructor; this->vm_module.xBestIndex = vt_best_index; this->vm_module.xFilter = vt_filter; this->vm_module.xColumn = tvt_column; this->addUpdate<T>(T()); }; int create(sqlite3 *db, const char *name) { std::string impl_name = name; vtab_module_schemas += T::CREATE_STMT; // XXX Eponymous tables don't seem to work in older sqlite versions impl_name += "_impl"; int rc = sqlite3_create_module(db, impl_name.c_str(), &this->vm_module, NULL); ensure(rc == SQLITE_OK); std::string create_stmt = std::string("CREATE VIRTUAL TABLE ") + name + " USING " + impl_name + "()"; return sqlite3_exec(db, create_stmt.c_str(), NULL, NULL, NULL); }; sqlite3_module vm_module; }; template<typename T> struct tvt_iterator_cursor { struct cursor { sqlite3_vtab_cursor base; typename T::iterator iter; cursor(sqlite3_vtab *vt) { T handler; this->base.pVtab = vt; this->iter = handler.begin(); }; int next() { T handler; if (this->iter != handler.end()) { ++this->iter; } return SQLITE_OK; }; int eof() { T handler; return this->iter == handler.end(); }; int get_rowid(sqlite_int64 &rowid_out) { T handler; rowid_out = std::distance(handler.begin(), this->iter); return SQLITE_OK; }; }; }; template<typename T> struct tvt_no_update : public T { int delete_row(sqlite3_vtab *vt, sqlite3_int64 rowid) { vt->zErrMsg = sqlite3_mprintf( "Rows cannot be deleted from this table"); return SQLITE_ERROR; }; int insert_row(sqlite3_vtab *tab, sqlite3_int64 &rowid_out) { tab->zErrMsg = sqlite3_mprintf( "Rows cannot be inserted into this table"); return SQLITE_ERROR; }; int update_row(sqlite3_vtab *tab, sqlite3_int64 &rowid_out) { tab->zErrMsg = sqlite3_mprintf( "Rows cannot be update in this table"); return SQLITE_ERROR; }; }; #endif
; Listing generated by Microsoft (R) Optimizing Compiler Version 16.00.30319.01 TITLE C:\JitenderN\REBook\AddNumber\AddNumber\AddNumber.cpp .686P .XMM include listing.inc .model flat INCLUDELIB LIBCMT INCLUDELIB OLDNAMES PUBLIC ?has_denorm@_Num_base@std@@2W4float_denorm_style@2@B ; std::_Num_base::has_denorm PUBLIC ?has_denorm_loss@_Num_base@std@@2_NB ; std::_Num_base::has_denorm_loss PUBLIC ?has_infinity@_Num_base@std@@2_NB ; std::_Num_base::has_infinity PUBLIC ?has_quiet_NaN@_Num_base@std@@2_NB ; std::_Num_base::has_quiet_NaN PUBLIC ?has_signaling_NaN@_Num_base@std@@2_NB ; std::_Num_base::has_signaling_NaN PUBLIC ?is_bounded@_Num_base@std@@2_NB ; std::_Num_base::is_bounded PUBLIC ?is_exact@_Num_base@std@@2_NB ; std::_Num_base::is_exact PUBLIC ?is_iec559@_Num_base@std@@2_NB ; std::_Num_base::is_iec559 PUBLIC ?is_integer@_Num_base@std@@2_NB ; std::_Num_base::is_integer PUBLIC ?is_modulo@_Num_base@std@@2_NB ; std::_Num_base::is_modulo PUBLIC ?is_signed@_Num_base@std@@2_NB ; std::_Num_base::is_signed PUBLIC ?is_specialized@_Num_base@std@@2_NB ; std::_Num_base::is_specialized PUBLIC ?tinyness_before@_Num_base@std@@2_NB ; std::_Num_base::tinyness_before PUBLIC ?traps@_Num_base@std@@2_NB ; std::_Num_base::traps PUBLIC ?round_style@_Num_base@std@@2W4float_round_style@2@B ; std::_Num_base::round_style PUBLIC ?digits@_Num_base@std@@2HB ; std::_Num_base::digits PUBLIC ?digits10@_Num_base@std@@2HB ; std::_Num_base::digits10 PUBLIC ?max_digits10@_Num_base@std@@2HB ; std::_Num_base::max_digits10 PUBLIC ?max_exponent@_Num_base@std@@2HB ; std::_Num_base::max_exponent PUBLIC ?max_exponent10@_Num_base@std@@2HB ; std::_Num_base::max_exponent10 PUBLIC ?min_exponent@_Num_base@std@@2HB ; std::_Num_base::min_exponent PUBLIC ?min_exponent10@_Num_base@std@@2HB ; std::_Num_base::min_exponent10 PUBLIC ?radix@_Num_base@std@@2HB ; std::_Num_base::radix PUBLIC ?is_bounded@_Num_int_base@std@@2_NB ; std::_Num_int_base::is_bounded PUBLIC ?is_exact@_Num_int_base@std@@2_NB ; std::_Num_int_base::is_exact PUBLIC ?is_integer@_Num_int_base@std@@2_NB ; std::_Num_int_base::is_integer PUBLIC ?is_modulo@_Num_int_base@std@@2_NB ; std::_Num_int_base::is_modulo PUBLIC ?is_specialized@_Num_int_base@std@@2_NB ; std::_Num_int_base::is_specialized PUBLIC ?radix@_Num_int_base@std@@2HB ; std::_Num_int_base::radix PUBLIC ?has_denorm@_Num_float_base@std@@2W4float_denorm_style@2@B ; std::_Num_float_base::has_denorm PUBLIC ?has_denorm_loss@_Num_float_base@std@@2_NB ; std::_Num_float_base::has_denorm_loss PUBLIC ?has_infinity@_Num_float_base@std@@2_NB ; std::_Num_float_base::has_infinity PUBLIC ?has_quiet_NaN@_Num_float_base@std@@2_NB ; std::_Num_float_base::has_quiet_NaN PUBLIC ?has_signaling_NaN@_Num_float_base@std@@2_NB ; std::_Num_float_base::has_signaling_NaN PUBLIC ?is_bounded@_Num_float_base@std@@2_NB ; std::_Num_float_base::is_bounded PUBLIC ?is_exact@_Num_float_base@std@@2_NB ; std::_Num_float_base::is_exact PUBLIC ?is_iec559@_Num_float_base@std@@2_NB ; std::_Num_float_base::is_iec559 PUBLIC ?is_integer@_Num_float_base@std@@2_NB ; std::_Num_float_base::is_integer PUBLIC ?is_modulo@_Num_float_base@std@@2_NB ; std::_Num_float_base::is_modulo PUBLIC ?is_signed@_Num_float_base@std@@2_NB ; std::_Num_float_base::is_signed PUBLIC ?is_specialized@_Num_float_base@std@@2_NB ; std::_Num_float_base::is_specialized PUBLIC ?tinyness_before@_Num_float_base@std@@2_NB ; std::_Num_float_base::tinyness_before PUBLIC ?traps@_Num_float_base@std@@2_NB ; std::_Num_float_base::traps PUBLIC ?round_style@_Num_float_base@std@@2W4float_round_style@2@B ; std::_Num_float_base::round_style PUBLIC ?radix@_Num_float_base@std@@2HB ; std::_Num_float_base::radix PUBLIC ?is_signed@?$numeric_limits@D@std@@2_NB ; std::numeric_limits<char>::is_signed PUBLIC ?digits@?$numeric_limits@D@std@@2HB ; std::numeric_limits<char>::digits PUBLIC ?digits10@?$numeric_limits@D@std@@2HB ; std::numeric_limits<char>::digits10 PUBLIC ?max_digits10@?$numeric_limits@D@std@@2HB ; std::numeric_limits<char>::max_digits10 PUBLIC ?is_signed@?$numeric_limits@_W@std@@2_NB ; std::numeric_limits<wchar_t>::is_signed PUBLIC ?digits@?$numeric_limits@_W@std@@2HB ; std::numeric_limits<wchar_t>::digits PUBLIC ?digits10@?$numeric_limits@_W@std@@2HB ; std::numeric_limits<wchar_t>::digits10 PUBLIC ?max_digits10@?$numeric_limits@_W@std@@2HB ; std::numeric_limits<wchar_t>::max_digits10 PUBLIC ?is_modulo@?$numeric_limits@_N@std@@2_NB ; std::numeric_limits<bool>::is_modulo PUBLIC ?is_signed@?$numeric_limits@_N@std@@2_NB ; std::numeric_limits<bool>::is_signed PUBLIC ?digits@?$numeric_limits@_N@std@@2HB ; std::numeric_limits<bool>::digits PUBLIC ?digits10@?$numeric_limits@_N@std@@2HB ; std::numeric_limits<bool>::digits10 PUBLIC ?max_digits10@?$numeric_limits@_N@std@@2HB ; std::numeric_limits<bool>::max_digits10 PUBLIC ?is_signed@?$numeric_limits@C@std@@2_NB ; std::numeric_limits<signed char>::is_signed PUBLIC ?digits@?$numeric_limits@C@std@@2HB ; std::numeric_limits<signed char>::digits PUBLIC ?digits10@?$numeric_limits@C@std@@2HB ; std::numeric_limits<signed char>::digits10 PUBLIC ?max_digits10@?$numeric_limits@C@std@@2HB ; std::numeric_limits<signed char>::max_digits10 PUBLIC ?is_signed@?$numeric_limits@E@std@@2_NB ; std::numeric_limits<unsigned char>::is_signed PUBLIC ?digits@?$numeric_limits@E@std@@2HB ; std::numeric_limits<unsigned char>::digits PUBLIC ?digits10@?$numeric_limits@E@std@@2HB ; std::numeric_limits<unsigned char>::digits10 PUBLIC ?max_digits10@?$numeric_limits@E@std@@2HB ; std::numeric_limits<unsigned char>::max_digits10 PUBLIC ?is_signed@?$numeric_limits@F@std@@2_NB ; std::numeric_limits<short>::is_signed PUBLIC ?digits@?$numeric_limits@F@std@@2HB ; std::numeric_limits<short>::digits PUBLIC ?digits10@?$numeric_limits@F@std@@2HB ; std::numeric_limits<short>::digits10 PUBLIC ?max_digits10@?$numeric_limits@F@std@@2HB ; std::numeric_limits<short>::max_digits10 PUBLIC ?is_signed@?$numeric_limits@G@std@@2_NB ; std::numeric_limits<unsigned short>::is_signed PUBLIC ?digits@?$numeric_limits@G@std@@2HB ; std::numeric_limits<unsigned short>::digits PUBLIC ?digits10@?$numeric_limits@G@std@@2HB ; std::numeric_limits<unsigned short>::digits10 PUBLIC ?max_digits10@?$numeric_limits@G@std@@2HB ; std::numeric_limits<unsigned short>::max_digits10 PUBLIC ?is_signed@?$numeric_limits@H@std@@2_NB ; std::numeric_limits<int>::is_signed PUBLIC ?digits@?$numeric_limits@H@std@@2HB ; std::numeric_limits<int>::digits PUBLIC ?digits10@?$numeric_limits@H@std@@2HB ; std::numeric_limits<int>::digits10 PUBLIC ?max_digits10@?$numeric_limits@H@std@@2HB ; std::numeric_limits<int>::max_digits10 PUBLIC ?is_signed@?$numeric_limits@I@std@@2_NB ; std::numeric_limits<unsigned int>::is_signed PUBLIC ?digits@?$numeric_limits@I@std@@2HB ; std::numeric_limits<unsigned int>::digits PUBLIC ?digits10@?$numeric_limits@I@std@@2HB ; std::numeric_limits<unsigned int>::digits10 PUBLIC ?max_digits10@?$numeric_limits@I@std@@2HB ; std::numeric_limits<unsigned int>::max_digits10 PUBLIC ?is_signed@?$numeric_limits@J@std@@2_NB ; std::numeric_limits<long>::is_signed PUBLIC ?digits@?$numeric_limits@J@std@@2HB ; std::numeric_limits<long>::digits PUBLIC ?digits10@?$numeric_limits@J@std@@2HB ; std::numeric_limits<long>::digits10 PUBLIC ?max_digits10@?$numeric_limits@J@std@@2HB ; std::numeric_limits<long>::max_digits10 PUBLIC ?is_signed@?$numeric_limits@K@std@@2_NB ; std::numeric_limits<unsigned long>::is_signed PUBLIC ?digits@?$numeric_limits@K@std@@2HB ; std::numeric_limits<unsigned long>::digits PUBLIC ?digits10@?$numeric_limits@K@std@@2HB ; std::numeric_limits<unsigned long>::digits10 PUBLIC ?max_digits10@?$numeric_limits@K@std@@2HB ; std::numeric_limits<unsigned long>::max_digits10 PUBLIC ?is_signed@?$numeric_limits@_J@std@@2_NB ; std::numeric_limits<__int64>::is_signed PUBLIC ?digits@?$numeric_limits@_J@std@@2HB ; std::numeric_limits<__int64>::digits PUBLIC ?digits10@?$numeric_limits@_J@std@@2HB ; std::numeric_limits<__int64>::digits10 PUBLIC ?max_digits10@?$numeric_limits@_J@std@@2HB ; std::numeric_limits<__int64>::max_digits10 PUBLIC ?is_signed@?$numeric_limits@_K@std@@2_NB ; std::numeric_limits<unsigned __int64>::is_signed PUBLIC ?digits@?$numeric_limits@_K@std@@2HB ; std::numeric_limits<unsigned __int64>::digits PUBLIC ?digits10@?$numeric_limits@_K@std@@2HB ; std::numeric_limits<unsigned __int64>::digits10 PUBLIC ?max_digits10@?$numeric_limits@_K@std@@2HB ; std::numeric_limits<unsigned __int64>::max_digits10 PUBLIC ?digits@?$numeric_limits@M@std@@2HB ; std::numeric_limits<float>::digits PUBLIC ?digits10@?$numeric_limits@M@std@@2HB ; std::numeric_limits<float>::digits10 PUBLIC ?max_digits10@?$numeric_limits@M@std@@2HB ; std::numeric_limits<float>::max_digits10 PUBLIC ?max_exponent@?$numeric_limits@M@std@@2HB ; std::numeric_limits<float>::max_exponent PUBLIC ?max_exponent10@?$numeric_limits@M@std@@2HB ; std::numeric_limits<float>::max_exponent10 PUBLIC ?min_exponent@?$numeric_limits@M@std@@2HB ; std::numeric_limits<float>::min_exponent PUBLIC ?min_exponent10@?$numeric_limits@M@std@@2HB ; std::numeric_limits<float>::min_exponent10 PUBLIC ?digits@?$numeric_limits@N@std@@2HB ; std::numeric_limits<double>::digits PUBLIC ?digits10@?$numeric_limits@N@std@@2HB ; std::numeric_limits<double>::digits10 PUBLIC ?max_digits10@?$numeric_limits@N@std@@2HB ; std::numeric_limits<double>::max_digits10 PUBLIC ?max_exponent@?$numeric_limits@N@std@@2HB ; std::numeric_limits<double>::max_exponent PUBLIC ?max_exponent10@?$numeric_limits@N@std@@2HB ; std::numeric_limits<double>::max_exponent10 PUBLIC ?min_exponent@?$numeric_limits@N@std@@2HB ; std::numeric_limits<double>::min_exponent PUBLIC ?min_exponent10@?$numeric_limits@N@std@@2HB ; std::numeric_limits<double>::min_exponent10 PUBLIC ?digits@?$numeric_limits@O@std@@2HB ; std::numeric_limits<long double>::digits PUBLIC ?digits10@?$numeric_limits@O@std@@2HB ; std::numeric_limits<long double>::digits10 PUBLIC ?max_digits10@?$numeric_limits@O@std@@2HB ; std::numeric_limits<long double>::max_digits10 PUBLIC ?max_exponent@?$numeric_limits@O@std@@2HB ; std::numeric_limits<long double>::max_exponent PUBLIC ?max_exponent10@?$numeric_limits@O@std@@2HB ; std::numeric_limits<long double>::max_exponent10 PUBLIC ?min_exponent@?$numeric_limits@O@std@@2HB ; std::numeric_limits<long double>::min_exponent PUBLIC ?min_exponent10@?$numeric_limits@O@std@@2HB ; std::numeric_limits<long double>::min_exponent10 PUBLIC ?value@?$integral_constant@_N$0A@@tr1@std@@2_NB ; std::tr1::integral_constant<bool,0>::value PUBLIC ?value@?$integral_constant@_N$00@tr1@std@@2_NB ; std::tr1::integral_constant<bool,1>::value PUBLIC ?value@?$integral_constant@I$0A@@tr1@std@@2IB ; std::tr1::integral_constant<unsigned int,0>::value PUBLIC ?_Rank@?$_Arithmetic_traits@_N@std@@2HB ; std::_Arithmetic_traits<bool>::_Rank PUBLIC ?_Rank@?$_Arithmetic_traits@D@std@@2HB ; std::_Arithmetic_traits<char>::_Rank PUBLIC ?_Rank@?$_Arithmetic_traits@C@std@@2HB ; std::_Arithmetic_traits<signed char>::_Rank PUBLIC ?_Rank@?$_Arithmetic_traits@E@std@@2HB ; std::_Arithmetic_traits<unsigned char>::_Rank PUBLIC ?_Rank@?$_Arithmetic_traits@F@std@@2HB ; std::_Arithmetic_traits<short>::_Rank PUBLIC ?_Rank@?$_Arithmetic_traits@G@std@@2HB ; std::_Arithmetic_traits<unsigned short>::_Rank PUBLIC ?_Rank@?$_Arithmetic_traits@H@std@@2HB ; std::_Arithmetic_traits<int>::_Rank PUBLIC ?_Rank@?$_Arithmetic_traits@I@std@@2HB ; std::_Arithmetic_traits<unsigned int>::_Rank PUBLIC ?_Rank@?$_Arithmetic_traits@J@std@@2HB ; std::_Arithmetic_traits<long>::_Rank PUBLIC ?_Rank@?$_Arithmetic_traits@K@std@@2HB ; std::_Arithmetic_traits<unsigned long>::_Rank PUBLIC ?_Rank@?$_Arithmetic_traits@_J@std@@2HB ; std::_Arithmetic_traits<__int64>::_Rank PUBLIC ?_Rank@?$_Arithmetic_traits@_K@std@@2HB ; std::_Arithmetic_traits<unsigned __int64>::_Rank PUBLIC ?_Rank@?$_Arithmetic_traits@M@std@@2HB ; std::_Arithmetic_traits<float>::_Rank PUBLIC ?_Rank@?$_Arithmetic_traits@N@std@@2HB ; std::_Arithmetic_traits<double>::_Rank PUBLIC ?_Rank@?$_Arithmetic_traits@O@std@@2HB ; std::_Arithmetic_traits<long double>::_Rank PUBLIC ?collate@?$_Locbase@H@std@@2HB ; std::_Locbase<int>::collate PUBLIC ?ctype@?$_Locbase@H@std@@2HB ; std::_Locbase<int>::ctype PUBLIC ?monetary@?$_Locbase@H@std@@2HB ; std::_Locbase<int>::monetary PUBLIC ?numeric@?$_Locbase@H@std@@2HB ; std::_Locbase<int>::numeric PUBLIC ?time@?$_Locbase@H@std@@2HB ; std::_Locbase<int>::time PUBLIC ?messages@?$_Locbase@H@std@@2HB ; std::_Locbase<int>::messages PUBLIC ?all@?$_Locbase@H@std@@2HB ; std::_Locbase<int>::all PUBLIC ?none@?$_Locbase@H@std@@2HB ; std::_Locbase<int>::none PUBLIC ?table_size@?$ctype@D@std@@2IB ; std::ctype<char>::table_size PUBLIC ?skipws@?$_Iosb@H@std@@2W4_Fmtflags@12@B ; std::_Iosb<int>::skipws PUBLIC ?unitbuf@?$_Iosb@H@std@@2W4_Fmtflags@12@B ; std::_Iosb<int>::unitbuf PUBLIC ?uppercase@?$_Iosb@H@std@@2W4_Fmtflags@12@B ; std::_Iosb<int>::uppercase PUBLIC ?showbase@?$_Iosb@H@std@@2W4_Fmtflags@12@B ; std::_Iosb<int>::showbase PUBLIC ?showpoint@?$_Iosb@H@std@@2W4_Fmtflags@12@B ; std::_Iosb<int>::showpoint PUBLIC ?showpos@?$_Iosb@H@std@@2W4_Fmtflags@12@B ; std::_Iosb<int>::showpos PUBLIC ?left@?$_Iosb@H@std@@2W4_Fmtflags@12@B ; std::_Iosb<int>::left PUBLIC ?right@?$_Iosb@H@std@@2W4_Fmtflags@12@B ; std::_Iosb<int>::right PUBLIC ?internal@?$_Iosb@H@std@@2W4_Fmtflags@12@B ; std::_Iosb<int>::internal PUBLIC ?dec@?$_Iosb@H@std@@2W4_Fmtflags@12@B ; std::_Iosb<int>::dec PUBLIC ?oct@?$_Iosb@H@std@@2W4_Fmtflags@12@B ; std::_Iosb<int>::oct PUBLIC ?hex@?$_Iosb@H@std@@2W4_Fmtflags@12@B ; std::_Iosb<int>::hex PUBLIC ?scientific@?$_Iosb@H@std@@2W4_Fmtflags@12@B ; std::_Iosb<int>::scientific PUBLIC ?fixed@?$_Iosb@H@std@@2W4_Fmtflags@12@B ; std::_Iosb<int>::fixed PUBLIC ?hexfloat@?$_Iosb@H@std@@2W4_Fmtflags@12@B ; std::_Iosb<int>::hexfloat PUBLIC ?boolalpha@?$_Iosb@H@std@@2W4_Fmtflags@12@B ; std::_Iosb<int>::boolalpha PUBLIC ?_Stdio@?$_Iosb@H@std@@2W4_Fmtflags@12@B ; std::_Iosb<int>::_Stdio PUBLIC ?adjustfield@?$_Iosb@H@std@@2W4_Fmtflags@12@B ; std::_Iosb<int>::adjustfield PUBLIC ?basefield@?$_Iosb@H@std@@2W4_Fmtflags@12@B ; std::_Iosb<int>::basefield PUBLIC ?floatfield@?$_Iosb@H@std@@2W4_Fmtflags@12@B ; std::_Iosb<int>::floatfield PUBLIC ?goodbit@?$_Iosb@H@std@@2W4_Iostate@12@B ; std::_Iosb<int>::goodbit PUBLIC ?eofbit@?$_Iosb@H@std@@2W4_Iostate@12@B ; std::_Iosb<int>::eofbit PUBLIC ?failbit@?$_Iosb@H@std@@2W4_Iostate@12@B ; std::_Iosb<int>::failbit PUBLIC ?badbit@?$_Iosb@H@std@@2W4_Iostate@12@B ; std::_Iosb<int>::badbit PUBLIC ?_Hardfail@?$_Iosb@H@std@@2W4_Iostate@12@B ; std::_Iosb<int>::_Hardfail PUBLIC ?in@?$_Iosb@H@std@@2W4_Openmode@12@B ; std::_Iosb<int>::in PUBLIC ?out@?$_Iosb@H@std@@2W4_Openmode@12@B ; std::_Iosb<int>::out PUBLIC ?ate@?$_Iosb@H@std@@2W4_Openmode@12@B ; std::_Iosb<int>::ate PUBLIC ?app@?$_Iosb@H@std@@2W4_Openmode@12@B ; std::_Iosb<int>::app PUBLIC ?trunc@?$_Iosb@H@std@@2W4_Openmode@12@B ; std::_Iosb<int>::trunc PUBLIC ?_Nocreate@?$_Iosb@H@std@@2W4_Openmode@12@B ; std::_Iosb<int>::_Nocreate PUBLIC ?_Noreplace@?$_Iosb@H@std@@2W4_Openmode@12@B ; std::_Iosb<int>::_Noreplace PUBLIC ?binary@?$_Iosb@H@std@@2W4_Openmode@12@B ; std::_Iosb<int>::binary PUBLIC ?beg@?$_Iosb@H@std@@2W4_Seekdir@12@B ; std::_Iosb<int>::beg PUBLIC ?cur@?$_Iosb@H@std@@2W4_Seekdir@12@B ; std::_Iosb<int>::cur PUBLIC ?end@?$_Iosb@H@std@@2W4_Seekdir@12@B ; std::_Iosb<int>::end ; COMDAT ?end@?$_Iosb@H@std@@2W4_Seekdir@12@B CONST SEGMENT ?end@?$_Iosb@H@std@@2W4_Seekdir@12@B DD 02H ; std::_Iosb<int>::end CONST ENDS ; COMDAT ?cur@?$_Iosb@H@std@@2W4_Seekdir@12@B CONST SEGMENT ?cur@?$_Iosb@H@std@@2W4_Seekdir@12@B DD 01H ; std::_Iosb<int>::cur CONST ENDS ; COMDAT ?beg@?$_Iosb@H@std@@2W4_Seekdir@12@B CONST SEGMENT ?beg@?$_Iosb@H@std@@2W4_Seekdir@12@B DD 00H ; std::_Iosb<int>::beg CONST ENDS ; COMDAT ?binary@?$_Iosb@H@std@@2W4_Openmode@12@B CONST SEGMENT ?binary@?$_Iosb@H@std@@2W4_Openmode@12@B DD 020H ; std::_Iosb<int>::binary CONST ENDS ; COMDAT ?_Noreplace@?$_Iosb@H@std@@2W4_Openmode@12@B CONST SEGMENT ?_Noreplace@?$_Iosb@H@std@@2W4_Openmode@12@B DD 080H ; std::_Iosb<int>::_Noreplace CONST ENDS ; COMDAT ?_Nocreate@?$_Iosb@H@std@@2W4_Openmode@12@B CONST SEGMENT ?_Nocreate@?$_Iosb@H@std@@2W4_Openmode@12@B DD 040H ; std::_Iosb<int>::_Nocreate CONST ENDS ; COMDAT ?trunc@?$_Iosb@H@std@@2W4_Openmode@12@B CONST SEGMENT ?trunc@?$_Iosb@H@std@@2W4_Openmode@12@B DD 010H ; std::_Iosb<int>::trunc CONST ENDS ; COMDAT ?app@?$_Iosb@H@std@@2W4_Openmode@12@B CONST SEGMENT ?app@?$_Iosb@H@std@@2W4_Openmode@12@B DD 08H ; std::_Iosb<int>::app CONST ENDS ; COMDAT ?ate@?$_Iosb@H@std@@2W4_Openmode@12@B CONST SEGMENT ?ate@?$_Iosb@H@std@@2W4_Openmode@12@B DD 04H ; std::_Iosb<int>::ate CONST ENDS ; COMDAT ?out@?$_Iosb@H@std@@2W4_Openmode@12@B CONST SEGMENT ?out@?$_Iosb@H@std@@2W4_Openmode@12@B DD 02H ; std::_Iosb<int>::out CONST ENDS ; COMDAT ?in@?$_Iosb@H@std@@2W4_Openmode@12@B CONST SEGMENT ?in@?$_Iosb@H@std@@2W4_Openmode@12@B DD 01H ; std::_Iosb<int>::in CONST ENDS ; COMDAT ?_Hardfail@?$_Iosb@H@std@@2W4_Iostate@12@B CONST SEGMENT ?_Hardfail@?$_Iosb@H@std@@2W4_Iostate@12@B DD 010H ; std::_Iosb<int>::_Hardfail CONST ENDS ; COMDAT ?badbit@?$_Iosb@H@std@@2W4_Iostate@12@B CONST SEGMENT ?badbit@?$_Iosb@H@std@@2W4_Iostate@12@B DD 04H ; std::_Iosb<int>::badbit CONST ENDS ; COMDAT ?failbit@?$_Iosb@H@std@@2W4_Iostate@12@B CONST SEGMENT ?failbit@?$_Iosb@H@std@@2W4_Iostate@12@B DD 02H ; std::_Iosb<int>::failbit CONST ENDS ; COMDAT ?eofbit@?$_Iosb@H@std@@2W4_Iostate@12@B CONST SEGMENT ?eofbit@?$_Iosb@H@std@@2W4_Iostate@12@B DD 01H ; std::_Iosb<int>::eofbit CONST ENDS ; COMDAT ?goodbit@?$_Iosb@H@std@@2W4_Iostate@12@B CONST SEGMENT ?goodbit@?$_Iosb@H@std@@2W4_Iostate@12@B DD 00H ; std::_Iosb<int>::goodbit CONST ENDS ; COMDAT ?floatfield@?$_Iosb@H@std@@2W4_Fmtflags@12@B CONST SEGMENT ?floatfield@?$_Iosb@H@std@@2W4_Fmtflags@12@B DD 03000H ; std::_Iosb<int>::floatfield CONST ENDS ; COMDAT ?basefield@?$_Iosb@H@std@@2W4_Fmtflags@12@B CONST SEGMENT ?basefield@?$_Iosb@H@std@@2W4_Fmtflags@12@B DD 0e00H ; std::_Iosb<int>::basefield CONST ENDS ; COMDAT ?adjustfield@?$_Iosb@H@std@@2W4_Fmtflags@12@B CONST SEGMENT ?adjustfield@?$_Iosb@H@std@@2W4_Fmtflags@12@B DD 01c0H ; std::_Iosb<int>::adjustfield CONST ENDS ; COMDAT ?_Stdio@?$_Iosb@H@std@@2W4_Fmtflags@12@B CONST SEGMENT ?_Stdio@?$_Iosb@H@std@@2W4_Fmtflags@12@B DD 08000H ; std::_Iosb<int>::_Stdio CONST ENDS ; COMDAT ?boolalpha@?$_Iosb@H@std@@2W4_Fmtflags@12@B CONST SEGMENT ?boolalpha@?$_Iosb@H@std@@2W4_Fmtflags@12@B DD 04000H ; std::_Iosb<int>::boolalpha CONST ENDS ; COMDAT ?hexfloat@?$_Iosb@H@std@@2W4_Fmtflags@12@B CONST SEGMENT ?hexfloat@?$_Iosb@H@std@@2W4_Fmtflags@12@B DD 03000H ; std::_Iosb<int>::hexfloat CONST ENDS ; COMDAT ?fixed@?$_Iosb@H@std@@2W4_Fmtflags@12@B CONST SEGMENT ?fixed@?$_Iosb@H@std@@2W4_Fmtflags@12@B DD 02000H ; std::_Iosb<int>::fixed CONST ENDS ; COMDAT ?scientific@?$_Iosb@H@std@@2W4_Fmtflags@12@B CONST SEGMENT ?scientific@?$_Iosb@H@std@@2W4_Fmtflags@12@B DD 01000H ; std::_Iosb<int>::scientific CONST ENDS ; COMDAT ?hex@?$_Iosb@H@std@@2W4_Fmtflags@12@B CONST SEGMENT ?hex@?$_Iosb@H@std@@2W4_Fmtflags@12@B DD 0800H ; std::_Iosb<int>::hex CONST ENDS ; COMDAT ?oct@?$_Iosb@H@std@@2W4_Fmtflags@12@B CONST SEGMENT ?oct@?$_Iosb@H@std@@2W4_Fmtflags@12@B DD 0400H ; std::_Iosb<int>::oct CONST ENDS ; COMDAT ?dec@?$_Iosb@H@std@@2W4_Fmtflags@12@B CONST SEGMENT ?dec@?$_Iosb@H@std@@2W4_Fmtflags@12@B DD 0200H ; std::_Iosb<int>::dec CONST ENDS ; COMDAT ?internal@?$_Iosb@H@std@@2W4_Fmtflags@12@B CONST SEGMENT ?internal@?$_Iosb@H@std@@2W4_Fmtflags@12@B DD 0100H ; std::_Iosb<int>::internal CONST ENDS ; COMDAT ?right@?$_Iosb@H@std@@2W4_Fmtflags@12@B CONST SEGMENT ?right@?$_Iosb@H@std@@2W4_Fmtflags@12@B DD 080H ; std::_Iosb<int>::right CONST ENDS ; COMDAT ?left@?$_Iosb@H@std@@2W4_Fmtflags@12@B CONST SEGMENT ?left@?$_Iosb@H@std@@2W4_Fmtflags@12@B DD 040H ; std::_Iosb<int>::left CONST ENDS ; COMDAT ?showpos@?$_Iosb@H@std@@2W4_Fmtflags@12@B CONST SEGMENT ?showpos@?$_Iosb@H@std@@2W4_Fmtflags@12@B DD 020H ; std::_Iosb<int>::showpos CONST ENDS ; COMDAT ?showpoint@?$_Iosb@H@std@@2W4_Fmtflags@12@B CONST SEGMENT ?showpoint@?$_Iosb@H@std@@2W4_Fmtflags@12@B DD 010H ; std::_Iosb<int>::showpoint CONST ENDS ; COMDAT ?showbase@?$_Iosb@H@std@@2W4_Fmtflags@12@B CONST SEGMENT ?showbase@?$_Iosb@H@std@@2W4_Fmtflags@12@B DD 08H ; std::_Iosb<int>::showbase CONST ENDS ; COMDAT ?uppercase@?$_Iosb@H@std@@2W4_Fmtflags@12@B CONST SEGMENT ?uppercase@?$_Iosb@H@std@@2W4_Fmtflags@12@B DD 04H ; std::_Iosb<int>::uppercase CONST ENDS ; COMDAT ?unitbuf@?$_Iosb@H@std@@2W4_Fmtflags@12@B CONST SEGMENT ?unitbuf@?$_Iosb@H@std@@2W4_Fmtflags@12@B DD 02H ; std::_Iosb<int>::unitbuf CONST ENDS ; COMDAT ?skipws@?$_Iosb@H@std@@2W4_Fmtflags@12@B CONST SEGMENT ?skipws@?$_Iosb@H@std@@2W4_Fmtflags@12@B DD 01H ; std::_Iosb<int>::skipws CONST ENDS ; COMDAT ?table_size@?$ctype@D@std@@2IB CONST SEGMENT ?table_size@?$ctype@D@std@@2IB DD 0100H ; std::ctype<char>::table_size CONST ENDS ; COMDAT ?none@?$_Locbase@H@std@@2HB CONST SEGMENT ?none@?$_Locbase@H@std@@2HB DD 00H ; std::_Locbase<int>::none CONST ENDS ; COMDAT ?all@?$_Locbase@H@std@@2HB CONST SEGMENT ?all@?$_Locbase@H@std@@2HB DD 03fH ; std::_Locbase<int>::all CONST ENDS ; COMDAT ?messages@?$_Locbase@H@std@@2HB CONST SEGMENT ?messages@?$_Locbase@H@std@@2HB DD 020H ; std::_Locbase<int>::messages CONST ENDS ; COMDAT ?time@?$_Locbase@H@std@@2HB CONST SEGMENT ?time@?$_Locbase@H@std@@2HB DD 010H ; std::_Locbase<int>::time CONST ENDS ; COMDAT ?numeric@?$_Locbase@H@std@@2HB CONST SEGMENT ?numeric@?$_Locbase@H@std@@2HB DD 08H ; std::_Locbase<int>::numeric CONST ENDS ; COMDAT ?monetary@?$_Locbase@H@std@@2HB CONST SEGMENT ?monetary@?$_Locbase@H@std@@2HB DD 04H ; std::_Locbase<int>::monetary CONST ENDS ; COMDAT ?ctype@?$_Locbase@H@std@@2HB CONST SEGMENT ?ctype@?$_Locbase@H@std@@2HB DD 02H ; std::_Locbase<int>::ctype CONST ENDS ; COMDAT ?collate@?$_Locbase@H@std@@2HB CONST SEGMENT ?collate@?$_Locbase@H@std@@2HB DD 01H ; std::_Locbase<int>::collate CONST ENDS ; COMDAT ?_Rank@?$_Arithmetic_traits@O@std@@2HB CONST SEGMENT ?_Rank@?$_Arithmetic_traits@O@std@@2HB DD 09H ; std::_Arithmetic_traits<long double>::_Rank CONST ENDS ; COMDAT ?_Rank@?$_Arithmetic_traits@N@std@@2HB CONST SEGMENT ?_Rank@?$_Arithmetic_traits@N@std@@2HB DD 08H ; std::_Arithmetic_traits<double>::_Rank CONST ENDS ; COMDAT ?_Rank@?$_Arithmetic_traits@M@std@@2HB CONST SEGMENT ?_Rank@?$_Arithmetic_traits@M@std@@2HB DD 07H ; std::_Arithmetic_traits<float>::_Rank CONST ENDS ; COMDAT ?_Rank@?$_Arithmetic_traits@_K@std@@2HB CONST SEGMENT ?_Rank@?$_Arithmetic_traits@_K@std@@2HB DD 06H ; std::_Arithmetic_traits<unsigned __int64>::_Rank CONST ENDS ; COMDAT ?_Rank@?$_Arithmetic_traits@_J@std@@2HB CONST SEGMENT ?_Rank@?$_Arithmetic_traits@_J@std@@2HB DD 06H ; std::_Arithmetic_traits<__int64>::_Rank CONST ENDS ; COMDAT ?_Rank@?$_Arithmetic_traits@K@std@@2HB CONST SEGMENT ?_Rank@?$_Arithmetic_traits@K@std@@2HB DD 05H ; std::_Arithmetic_traits<unsigned long>::_Rank CONST ENDS ; COMDAT ?_Rank@?$_Arithmetic_traits@J@std@@2HB CONST SEGMENT ?_Rank@?$_Arithmetic_traits@J@std@@2HB DD 05H ; std::_Arithmetic_traits<long>::_Rank CONST ENDS ; COMDAT ?_Rank@?$_Arithmetic_traits@I@std@@2HB CONST SEGMENT ?_Rank@?$_Arithmetic_traits@I@std@@2HB DD 04H ; std::_Arithmetic_traits<unsigned int>::_Rank CONST ENDS ; COMDAT ?_Rank@?$_Arithmetic_traits@H@std@@2HB CONST SEGMENT ?_Rank@?$_Arithmetic_traits@H@std@@2HB DD 04H ; std::_Arithmetic_traits<int>::_Rank CONST ENDS ; COMDAT ?_Rank@?$_Arithmetic_traits@G@std@@2HB CONST SEGMENT ?_Rank@?$_Arithmetic_traits@G@std@@2HB DD 03H ; std::_Arithmetic_traits<unsigned short>::_Rank CONST ENDS ; COMDAT ?_Rank@?$_Arithmetic_traits@F@std@@2HB CONST SEGMENT ?_Rank@?$_Arithmetic_traits@F@std@@2HB DD 03H ; std::_Arithmetic_traits<short>::_Rank CONST ENDS ; COMDAT ?_Rank@?$_Arithmetic_traits@E@std@@2HB CONST SEGMENT ?_Rank@?$_Arithmetic_traits@E@std@@2HB DD 02H ; std::_Arithmetic_traits<unsigned char>::_Rank CONST ENDS ; COMDAT ?_Rank@?$_Arithmetic_traits@C@std@@2HB CONST SEGMENT ?_Rank@?$_Arithmetic_traits@C@std@@2HB DD 02H ; std::_Arithmetic_traits<signed char>::_Rank CONST ENDS ; COMDAT ?_Rank@?$_Arithmetic_traits@D@std@@2HB CONST SEGMENT ?_Rank@?$_Arithmetic_traits@D@std@@2HB DD 02H ; std::_Arithmetic_traits<char>::_Rank CONST ENDS ; COMDAT ?_Rank@?$_Arithmetic_traits@_N@std@@2HB CONST SEGMENT ?_Rank@?$_Arithmetic_traits@_N@std@@2HB DD 01H ; std::_Arithmetic_traits<bool>::_Rank CONST ENDS ; COMDAT ?value@?$integral_constant@I$0A@@tr1@std@@2IB CONST SEGMENT ?value@?$integral_constant@I$0A@@tr1@std@@2IB DD 00H ; std::tr1::integral_constant<unsigned int,0>::value CONST ENDS ; COMDAT ?value@?$integral_constant@_N$00@tr1@std@@2_NB CONST SEGMENT ?value@?$integral_constant@_N$00@tr1@std@@2_NB DB 01H ; std::tr1::integral_constant<bool,1>::value CONST ENDS ; COMDAT ?value@?$integral_constant@_N$0A@@tr1@std@@2_NB CONST SEGMENT ?value@?$integral_constant@_N$0A@@tr1@std@@2_NB DB 00H ; std::tr1::integral_constant<bool,0>::value CONST ENDS ; COMDAT ?min_exponent10@?$numeric_limits@O@std@@2HB CONST SEGMENT ?min_exponent10@?$numeric_limits@O@std@@2HB DD 0fffffecdH ; std::numeric_limits<long double>::min_exponent10 CONST ENDS ; COMDAT ?min_exponent@?$numeric_limits@O@std@@2HB CONST SEGMENT ?min_exponent@?$numeric_limits@O@std@@2HB DD 0fffffc03H ; std::numeric_limits<long double>::min_exponent CONST ENDS ; COMDAT ?max_exponent10@?$numeric_limits@O@std@@2HB CONST SEGMENT ?max_exponent10@?$numeric_limits@O@std@@2HB DD 0134H ; std::numeric_limits<long double>::max_exponent10 CONST ENDS ; COMDAT ?max_exponent@?$numeric_limits@O@std@@2HB CONST SEGMENT ?max_exponent@?$numeric_limits@O@std@@2HB DD 0400H ; std::numeric_limits<long double>::max_exponent CONST ENDS ; COMDAT ?max_digits10@?$numeric_limits@O@std@@2HB CONST SEGMENT ?max_digits10@?$numeric_limits@O@std@@2HB DD 011H ; std::numeric_limits<long double>::max_digits10 CONST ENDS ; COMDAT ?digits10@?$numeric_limits@O@std@@2HB CONST SEGMENT ?digits10@?$numeric_limits@O@std@@2HB DD 0fH ; std::numeric_limits<long double>::digits10 CONST ENDS ; COMDAT ?digits@?$numeric_limits@O@std@@2HB CONST SEGMENT ?digits@?$numeric_limits@O@std@@2HB DD 035H ; std::numeric_limits<long double>::digits CONST ENDS ; COMDAT ?min_exponent10@?$numeric_limits@N@std@@2HB CONST SEGMENT ?min_exponent10@?$numeric_limits@N@std@@2HB DD 0fffffecdH ; std::numeric_limits<double>::min_exponent10 CONST ENDS ; COMDAT ?min_exponent@?$numeric_limits@N@std@@2HB CONST SEGMENT ?min_exponent@?$numeric_limits@N@std@@2HB DD 0fffffc03H ; std::numeric_limits<double>::min_exponent CONST ENDS ; COMDAT ?max_exponent10@?$numeric_limits@N@std@@2HB CONST SEGMENT ?max_exponent10@?$numeric_limits@N@std@@2HB DD 0134H ; std::numeric_limits<double>::max_exponent10 CONST ENDS ; COMDAT ?max_exponent@?$numeric_limits@N@std@@2HB CONST SEGMENT ?max_exponent@?$numeric_limits@N@std@@2HB DD 0400H ; std::numeric_limits<double>::max_exponent CONST ENDS ; COMDAT ?max_digits10@?$numeric_limits@N@std@@2HB CONST SEGMENT ?max_digits10@?$numeric_limits@N@std@@2HB DD 011H ; std::numeric_limits<double>::max_digits10 CONST ENDS ; COMDAT ?digits10@?$numeric_limits@N@std@@2HB CONST SEGMENT ?digits10@?$numeric_limits@N@std@@2HB DD 0fH ; std::numeric_limits<double>::digits10 CONST ENDS ; COMDAT ?digits@?$numeric_limits@N@std@@2HB CONST SEGMENT ?digits@?$numeric_limits@N@std@@2HB DD 035H ; std::numeric_limits<double>::digits CONST ENDS ; COMDAT ?min_exponent10@?$numeric_limits@M@std@@2HB CONST SEGMENT ?min_exponent10@?$numeric_limits@M@std@@2HB DD 0ffffffdbH ; std::numeric_limits<float>::min_exponent10 CONST ENDS ; COMDAT ?min_exponent@?$numeric_limits@M@std@@2HB CONST SEGMENT ?min_exponent@?$numeric_limits@M@std@@2HB DD 0ffffff83H ; std::numeric_limits<float>::min_exponent CONST ENDS ; COMDAT ?max_exponent10@?$numeric_limits@M@std@@2HB CONST SEGMENT ?max_exponent10@?$numeric_limits@M@std@@2HB DD 026H ; std::numeric_limits<float>::max_exponent10 CONST ENDS ; COMDAT ?max_exponent@?$numeric_limits@M@std@@2HB CONST SEGMENT ?max_exponent@?$numeric_limits@M@std@@2HB DD 080H ; std::numeric_limits<float>::max_exponent CONST ENDS ; COMDAT ?max_digits10@?$numeric_limits@M@std@@2HB CONST SEGMENT ?max_digits10@?$numeric_limits@M@std@@2HB DD 08H ; std::numeric_limits<float>::max_digits10 CONST ENDS ; COMDAT ?digits10@?$numeric_limits@M@std@@2HB CONST SEGMENT ?digits10@?$numeric_limits@M@std@@2HB DD 06H ; std::numeric_limits<float>::digits10 CONST ENDS ; COMDAT ?digits@?$numeric_limits@M@std@@2HB CONST SEGMENT ?digits@?$numeric_limits@M@std@@2HB DD 018H ; std::numeric_limits<float>::digits CONST ENDS ; COMDAT ?max_digits10@?$numeric_limits@_K@std@@2HB CONST SEGMENT ?max_digits10@?$numeric_limits@_K@std@@2HB DD 015H ; std::numeric_limits<unsigned __int64>::max_digits10 CONST ENDS ; COMDAT ?digits10@?$numeric_limits@_K@std@@2HB CONST SEGMENT ?digits10@?$numeric_limits@_K@std@@2HB DD 013H ; std::numeric_limits<unsigned __int64>::digits10 CONST ENDS ; COMDAT ?digits@?$numeric_limits@_K@std@@2HB CONST SEGMENT ?digits@?$numeric_limits@_K@std@@2HB DD 040H ; std::numeric_limits<unsigned __int64>::digits CONST ENDS ; COMDAT ?is_signed@?$numeric_limits@_K@std@@2_NB CONST SEGMENT ?is_signed@?$numeric_limits@_K@std@@2_NB DB 00H ; std::numeric_limits<unsigned __int64>::is_signed CONST ENDS ; COMDAT ?max_digits10@?$numeric_limits@_J@std@@2HB CONST SEGMENT ?max_digits10@?$numeric_limits@_J@std@@2HB DD 014H ; std::numeric_limits<__int64>::max_digits10 CONST ENDS ; COMDAT ?digits10@?$numeric_limits@_J@std@@2HB CONST SEGMENT ?digits10@?$numeric_limits@_J@std@@2HB DD 012H ; std::numeric_limits<__int64>::digits10 CONST ENDS ; COMDAT ?digits@?$numeric_limits@_J@std@@2HB CONST SEGMENT ?digits@?$numeric_limits@_J@std@@2HB DD 03fH ; std::numeric_limits<__int64>::digits CONST ENDS ; COMDAT ?is_signed@?$numeric_limits@_J@std@@2_NB CONST SEGMENT ?is_signed@?$numeric_limits@_J@std@@2_NB DB 01H ; std::numeric_limits<__int64>::is_signed CONST ENDS ; COMDAT ?max_digits10@?$numeric_limits@K@std@@2HB CONST SEGMENT ?max_digits10@?$numeric_limits@K@std@@2HB DD 0bH ; std::numeric_limits<unsigned long>::max_digits10 CONST ENDS ; COMDAT ?digits10@?$numeric_limits@K@std@@2HB CONST SEGMENT ?digits10@?$numeric_limits@K@std@@2HB DD 09H ; std::numeric_limits<unsigned long>::digits10 CONST ENDS ; COMDAT ?digits@?$numeric_limits@K@std@@2HB CONST SEGMENT ?digits@?$numeric_limits@K@std@@2HB DD 020H ; std::numeric_limits<unsigned long>::digits CONST ENDS ; COMDAT ?is_signed@?$numeric_limits@K@std@@2_NB CONST SEGMENT ?is_signed@?$numeric_limits@K@std@@2_NB DB 00H ; std::numeric_limits<unsigned long>::is_signed CONST ENDS ; COMDAT ?max_digits10@?$numeric_limits@J@std@@2HB CONST SEGMENT ?max_digits10@?$numeric_limits@J@std@@2HB DD 0bH ; std::numeric_limits<long>::max_digits10 CONST ENDS ; COMDAT ?digits10@?$numeric_limits@J@std@@2HB CONST SEGMENT ?digits10@?$numeric_limits@J@std@@2HB DD 09H ; std::numeric_limits<long>::digits10 CONST ENDS ; COMDAT ?digits@?$numeric_limits@J@std@@2HB CONST SEGMENT ?digits@?$numeric_limits@J@std@@2HB DD 01fH ; std::numeric_limits<long>::digits CONST ENDS ; COMDAT ?is_signed@?$numeric_limits@J@std@@2_NB CONST SEGMENT ?is_signed@?$numeric_limits@J@std@@2_NB DB 01H ; std::numeric_limits<long>::is_signed CONST ENDS ; COMDAT ?max_digits10@?$numeric_limits@I@std@@2HB CONST SEGMENT ?max_digits10@?$numeric_limits@I@std@@2HB DD 0bH ; std::numeric_limits<unsigned int>::max_digits10 CONST ENDS ; COMDAT ?digits10@?$numeric_limits@I@std@@2HB CONST SEGMENT ?digits10@?$numeric_limits@I@std@@2HB DD 09H ; std::numeric_limits<unsigned int>::digits10 CONST ENDS ; COMDAT ?digits@?$numeric_limits@I@std@@2HB CONST SEGMENT ?digits@?$numeric_limits@I@std@@2HB DD 020H ; std::numeric_limits<unsigned int>::digits CONST ENDS ; COMDAT ?is_signed@?$numeric_limits@I@std@@2_NB CONST SEGMENT ?is_signed@?$numeric_limits@I@std@@2_NB DB 00H ; std::numeric_limits<unsigned int>::is_signed CONST ENDS ; COMDAT ?max_digits10@?$numeric_limits@H@std@@2HB CONST SEGMENT ?max_digits10@?$numeric_limits@H@std@@2HB DD 0bH ; std::numeric_limits<int>::max_digits10 CONST ENDS ; COMDAT ?digits10@?$numeric_limits@H@std@@2HB CONST SEGMENT ?digits10@?$numeric_limits@H@std@@2HB DD 09H ; std::numeric_limits<int>::digits10 CONST ENDS ; COMDAT ?digits@?$numeric_limits@H@std@@2HB CONST SEGMENT ?digits@?$numeric_limits@H@std@@2HB DD 01fH ; std::numeric_limits<int>::digits CONST ENDS ; COMDAT ?is_signed@?$numeric_limits@H@std@@2_NB CONST SEGMENT ?is_signed@?$numeric_limits@H@std@@2_NB DB 01H ; std::numeric_limits<int>::is_signed CONST ENDS ; COMDAT ?max_digits10@?$numeric_limits@G@std@@2HB CONST SEGMENT ?max_digits10@?$numeric_limits@G@std@@2HB DD 06H ; std::numeric_limits<unsigned short>::max_digits10 CONST ENDS ; COMDAT ?digits10@?$numeric_limits@G@std@@2HB CONST SEGMENT ?digits10@?$numeric_limits@G@std@@2HB DD 04H ; std::numeric_limits<unsigned short>::digits10 CONST ENDS ; COMDAT ?digits@?$numeric_limits@G@std@@2HB CONST SEGMENT ?digits@?$numeric_limits@G@std@@2HB DD 010H ; std::numeric_limits<unsigned short>::digits CONST ENDS ; COMDAT ?is_signed@?$numeric_limits@G@std@@2_NB CONST SEGMENT ?is_signed@?$numeric_limits@G@std@@2_NB DB 00H ; std::numeric_limits<unsigned short>::is_signed CONST ENDS ; COMDAT ?max_digits10@?$numeric_limits@F@std@@2HB CONST SEGMENT ?max_digits10@?$numeric_limits@F@std@@2HB DD 06H ; std::numeric_limits<short>::max_digits10 CONST ENDS ; COMDAT ?digits10@?$numeric_limits@F@std@@2HB CONST SEGMENT ?digits10@?$numeric_limits@F@std@@2HB DD 04H ; std::numeric_limits<short>::digits10 CONST ENDS ; COMDAT ?digits@?$numeric_limits@F@std@@2HB CONST SEGMENT ?digits@?$numeric_limits@F@std@@2HB DD 0fH ; std::numeric_limits<short>::digits CONST ENDS ; COMDAT ?is_signed@?$numeric_limits@F@std@@2_NB CONST SEGMENT ?is_signed@?$numeric_limits@F@std@@2_NB DB 01H ; std::numeric_limits<short>::is_signed CONST ENDS ; COMDAT ?max_digits10@?$numeric_limits@E@std@@2HB CONST SEGMENT ?max_digits10@?$numeric_limits@E@std@@2HB DD 04H ; std::numeric_limits<unsigned char>::max_digits10 CONST ENDS ; COMDAT ?digits10@?$numeric_limits@E@std@@2HB CONST SEGMENT ?digits10@?$numeric_limits@E@std@@2HB DD 02H ; std::numeric_limits<unsigned char>::digits10 CONST ENDS ; COMDAT ?digits@?$numeric_limits@E@std@@2HB CONST SEGMENT ?digits@?$numeric_limits@E@std@@2HB DD 08H ; std::numeric_limits<unsigned char>::digits CONST ENDS ; COMDAT ?is_signed@?$numeric_limits@E@std@@2_NB CONST SEGMENT ?is_signed@?$numeric_limits@E@std@@2_NB DB 00H ; std::numeric_limits<unsigned char>::is_signed CONST ENDS ; COMDAT ?max_digits10@?$numeric_limits@C@std@@2HB CONST SEGMENT ?max_digits10@?$numeric_limits@C@std@@2HB DD 04H ; std::numeric_limits<signed char>::max_digits10 CONST ENDS ; COMDAT ?digits10@?$numeric_limits@C@std@@2HB CONST SEGMENT ?digits10@?$numeric_limits@C@std@@2HB DD 02H ; std::numeric_limits<signed char>::digits10 CONST ENDS ; COMDAT ?digits@?$numeric_limits@C@std@@2HB CONST SEGMENT ?digits@?$numeric_limits@C@std@@2HB DD 07H ; std::numeric_limits<signed char>::digits CONST ENDS ; COMDAT ?is_signed@?$numeric_limits@C@std@@2_NB CONST SEGMENT ?is_signed@?$numeric_limits@C@std@@2_NB DB 01H ; std::numeric_limits<signed char>::is_signed CONST ENDS ; COMDAT ?max_digits10@?$numeric_limits@_N@std@@2HB CONST SEGMENT ?max_digits10@?$numeric_limits@_N@std@@2HB DD 00H ; std::numeric_limits<bool>::max_digits10 CONST ENDS ; COMDAT ?digits10@?$numeric_limits@_N@std@@2HB CONST SEGMENT ?digits10@?$numeric_limits@_N@std@@2HB DD 00H ; std::numeric_limits<bool>::digits10 CONST ENDS ; COMDAT ?digits@?$numeric_limits@_N@std@@2HB CONST SEGMENT ?digits@?$numeric_limits@_N@std@@2HB DD 01H ; std::numeric_limits<bool>::digits CONST ENDS ; COMDAT ?is_signed@?$numeric_limits@_N@std@@2_NB CONST SEGMENT ?is_signed@?$numeric_limits@_N@std@@2_NB DB 00H ; std::numeric_limits<bool>::is_signed CONST ENDS ; COMDAT ?is_modulo@?$numeric_limits@_N@std@@2_NB CONST SEGMENT ?is_modulo@?$numeric_limits@_N@std@@2_NB DB 00H ; std::numeric_limits<bool>::is_modulo CONST ENDS ; COMDAT ?max_digits10@?$numeric_limits@_W@std@@2HB CONST SEGMENT ?max_digits10@?$numeric_limits@_W@std@@2HB DD 06H ; std::numeric_limits<wchar_t>::max_digits10 CONST ENDS ; COMDAT ?digits10@?$numeric_limits@_W@std@@2HB CONST SEGMENT ?digits10@?$numeric_limits@_W@std@@2HB DD 04H ; std::numeric_limits<wchar_t>::digits10 CONST ENDS ; COMDAT ?digits@?$numeric_limits@_W@std@@2HB CONST SEGMENT ?digits@?$numeric_limits@_W@std@@2HB DD 010H ; std::numeric_limits<wchar_t>::digits CONST ENDS ; COMDAT ?is_signed@?$numeric_limits@_W@std@@2_NB CONST SEGMENT ?is_signed@?$numeric_limits@_W@std@@2_NB DB 00H ; std::numeric_limits<wchar_t>::is_signed CONST ENDS ; COMDAT ?max_digits10@?$numeric_limits@D@std@@2HB CONST SEGMENT ?max_digits10@?$numeric_limits@D@std@@2HB DD 04H ; std::numeric_limits<char>::max_digits10 CONST ENDS ; COMDAT ?digits10@?$numeric_limits@D@std@@2HB CONST SEGMENT ?digits10@?$numeric_limits@D@std@@2HB DD 02H ; std::numeric_limits<char>::digits10 CONST ENDS ; COMDAT ?digits@?$numeric_limits@D@std@@2HB CONST SEGMENT ?digits@?$numeric_limits@D@std@@2HB DD 07H ; std::numeric_limits<char>::digits CONST ENDS ; COMDAT ?is_signed@?$numeric_limits@D@std@@2_NB CONST SEGMENT ?is_signed@?$numeric_limits@D@std@@2_NB DB 01H ; std::numeric_limits<char>::is_signed CONST ENDS ; COMDAT ?radix@_Num_float_base@std@@2HB CONST SEGMENT ?radix@_Num_float_base@std@@2HB DD 02H ; std::_Num_float_base::radix CONST ENDS ; COMDAT ?round_style@_Num_float_base@std@@2W4float_round_style@2@B CONST SEGMENT ?round_style@_Num_float_base@std@@2W4float_round_style@2@B DD 01H ; std::_Num_float_base::round_style CONST ENDS ; COMDAT ?traps@_Num_float_base@std@@2_NB CONST SEGMENT ?traps@_Num_float_base@std@@2_NB DB 01H ; std::_Num_float_base::traps CONST ENDS ; COMDAT ?tinyness_before@_Num_float_base@std@@2_NB CONST SEGMENT ?tinyness_before@_Num_float_base@std@@2_NB DB 01H ; std::_Num_float_base::tinyness_before CONST ENDS ; COMDAT ?is_specialized@_Num_float_base@std@@2_NB CONST SEGMENT ?is_specialized@_Num_float_base@std@@2_NB DB 01H ; std::_Num_float_base::is_specialized CONST ENDS ; COMDAT ?is_signed@_Num_float_base@std@@2_NB CONST SEGMENT ?is_signed@_Num_float_base@std@@2_NB DB 01H ; std::_Num_float_base::is_signed CONST ENDS ; COMDAT ?is_modulo@_Num_float_base@std@@2_NB CONST SEGMENT ?is_modulo@_Num_float_base@std@@2_NB DB 00H ; std::_Num_float_base::is_modulo CONST ENDS ; COMDAT ?is_integer@_Num_float_base@std@@2_NB CONST SEGMENT ?is_integer@_Num_float_base@std@@2_NB DB 00H ; std::_Num_float_base::is_integer CONST ENDS ; COMDAT ?is_iec559@_Num_float_base@std@@2_NB CONST SEGMENT ?is_iec559@_Num_float_base@std@@2_NB DB 01H ; std::_Num_float_base::is_iec559 CONST ENDS ; COMDAT ?is_exact@_Num_float_base@std@@2_NB CONST SEGMENT ?is_exact@_Num_float_base@std@@2_NB DB 00H ; std::_Num_float_base::is_exact CONST ENDS ; COMDAT ?is_bounded@_Num_float_base@std@@2_NB CONST SEGMENT ?is_bounded@_Num_float_base@std@@2_NB DB 01H ; std::_Num_float_base::is_bounded CONST ENDS ; COMDAT ?has_signaling_NaN@_Num_float_base@std@@2_NB CONST SEGMENT ?has_signaling_NaN@_Num_float_base@std@@2_NB DB 01H ; std::_Num_float_base::has_signaling_NaN CONST ENDS ; COMDAT ?has_quiet_NaN@_Num_float_base@std@@2_NB CONST SEGMENT ?has_quiet_NaN@_Num_float_base@std@@2_NB DB 01H ; std::_Num_float_base::has_quiet_NaN CONST ENDS ; COMDAT ?has_infinity@_Num_float_base@std@@2_NB CONST SEGMENT ?has_infinity@_Num_float_base@std@@2_NB DB 01H ; std::_Num_float_base::has_infinity CONST ENDS ; COMDAT ?has_denorm_loss@_Num_float_base@std@@2_NB CONST SEGMENT ?has_denorm_loss@_Num_float_base@std@@2_NB DB 01H ; std::_Num_float_base::has_denorm_loss CONST ENDS ; COMDAT ?has_denorm@_Num_float_base@std@@2W4float_denorm_style@2@B CONST SEGMENT ?has_denorm@_Num_float_base@std@@2W4float_denorm_style@2@B DD 01H ; std::_Num_float_base::has_denorm CONST ENDS ; COMDAT ?radix@_Num_int_base@std@@2HB CONST SEGMENT ?radix@_Num_int_base@std@@2HB DD 02H ; std::_Num_int_base::radix CONST ENDS ; COMDAT ?is_specialized@_Num_int_base@std@@2_NB CONST SEGMENT ?is_specialized@_Num_int_base@std@@2_NB DB 01H ; std::_Num_int_base::is_specialized CONST ENDS ; COMDAT ?is_modulo@_Num_int_base@std@@2_NB CONST SEGMENT ?is_modulo@_Num_int_base@std@@2_NB DB 01H ; std::_Num_int_base::is_modulo CONST ENDS ; COMDAT ?is_integer@_Num_int_base@std@@2_NB CONST SEGMENT ?is_integer@_Num_int_base@std@@2_NB DB 01H ; std::_Num_int_base::is_integer CONST ENDS ; COMDAT ?is_exact@_Num_int_base@std@@2_NB CONST SEGMENT ?is_exact@_Num_int_base@std@@2_NB DB 01H ; std::_Num_int_base::is_exact CONST ENDS ; COMDAT ?is_bounded@_Num_int_base@std@@2_NB CONST SEGMENT ?is_bounded@_Num_int_base@std@@2_NB DB 01H ; std::_Num_int_base::is_bounded CONST ENDS ; COMDAT ?radix@_Num_base@std@@2HB CONST SEGMENT ?radix@_Num_base@std@@2HB DD 00H ; std::_Num_base::radix CONST ENDS ; COMDAT ?min_exponent10@_Num_base@std@@2HB CONST SEGMENT ?min_exponent10@_Num_base@std@@2HB DD 00H ; std::_Num_base::min_exponent10 CONST ENDS ; COMDAT ?min_exponent@_Num_base@std@@2HB CONST SEGMENT ?min_exponent@_Num_base@std@@2HB DD 00H ; std::_Num_base::min_exponent CONST ENDS ; COMDAT ?max_exponent10@_Num_base@std@@2HB CONST SEGMENT ?max_exponent10@_Num_base@std@@2HB DD 00H ; std::_Num_base::max_exponent10 CONST ENDS ; COMDAT ?max_exponent@_Num_base@std@@2HB CONST SEGMENT ?max_exponent@_Num_base@std@@2HB DD 00H ; std::_Num_base::max_exponent CONST ENDS ; COMDAT ?max_digits10@_Num_base@std@@2HB CONST SEGMENT ?max_digits10@_Num_base@std@@2HB DD 00H ; std::_Num_base::max_digits10 CONST ENDS ; COMDAT ?digits10@_Num_base@std@@2HB CONST SEGMENT ?digits10@_Num_base@std@@2HB DD 00H ; std::_Num_base::digits10 CONST ENDS ; COMDAT ?digits@_Num_base@std@@2HB CONST SEGMENT ?digits@_Num_base@std@@2HB DD 00H ; std::_Num_base::digits CONST ENDS ; COMDAT ?round_style@_Num_base@std@@2W4float_round_style@2@B CONST SEGMENT ?round_style@_Num_base@std@@2W4float_round_style@2@B DD 00H ; std::_Num_base::round_style CONST ENDS ; COMDAT ?traps@_Num_base@std@@2_NB CONST SEGMENT ?traps@_Num_base@std@@2_NB DB 00H ; std::_Num_base::traps CONST ENDS ; COMDAT ?tinyness_before@_Num_base@std@@2_NB CONST SEGMENT ?tinyness_before@_Num_base@std@@2_NB DB 00H ; std::_Num_base::tinyness_before CONST ENDS ; COMDAT ?is_specialized@_Num_base@std@@2_NB CONST SEGMENT ?is_specialized@_Num_base@std@@2_NB DB 00H ; std::_Num_base::is_specialized CONST ENDS ; COMDAT ?is_signed@_Num_base@std@@2_NB CONST SEGMENT ?is_signed@_Num_base@std@@2_NB DB 00H ; std::_Num_base::is_signed CONST ENDS ; COMDAT ?is_modulo@_Num_base@std@@2_NB CONST SEGMENT ?is_modulo@_Num_base@std@@2_NB DB 00H ; std::_Num_base::is_modulo CONST ENDS ; COMDAT ?is_integer@_Num_base@std@@2_NB CONST SEGMENT ?is_integer@_Num_base@std@@2_NB DB 00H ; std::_Num_base::is_integer CONST ENDS ; COMDAT ?is_iec559@_Num_base@std@@2_NB CONST SEGMENT ?is_iec559@_Num_base@std@@2_NB DB 00H ; std::_Num_base::is_iec559 CONST ENDS ; COMDAT ?is_exact@_Num_base@std@@2_NB CONST SEGMENT ?is_exact@_Num_base@std@@2_NB DB 00H ; std::_Num_base::is_exact CONST ENDS ; COMDAT ?is_bounded@_Num_base@std@@2_NB CONST SEGMENT ?is_bounded@_Num_base@std@@2_NB DB 00H ; std::_Num_base::is_bounded CONST ENDS ; COMDAT ?has_signaling_NaN@_Num_base@std@@2_NB CONST SEGMENT ?has_signaling_NaN@_Num_base@std@@2_NB DB 00H ; std::_Num_base::has_signaling_NaN CONST ENDS ; COMDAT ?has_quiet_NaN@_Num_base@std@@2_NB CONST SEGMENT ?has_quiet_NaN@_Num_base@std@@2_NB DB 00H ; std::_Num_base::has_quiet_NaN CONST ENDS ; COMDAT ?has_infinity@_Num_base@std@@2_NB CONST SEGMENT ?has_infinity@_Num_base@std@@2_NB DB 00H ; std::_Num_base::has_infinity CONST ENDS ; COMDAT ?has_denorm_loss@_Num_base@std@@2_NB CONST SEGMENT ?has_denorm_loss@_Num_base@std@@2_NB DB 00H ; std::_Num_base::has_denorm_loss CONST ENDS ; COMDAT ?has_denorm@_Num_base@std@@2W4float_denorm_style@2@B CONST SEGMENT ?has_denorm@_Num_base@std@@2W4float_denorm_style@2@B DD 00H ; std::_Num_base::has_denorm CONST ENDS PUBLIC ?addition@@YAHHH@Z ; addition ; Function compile flags: /Ogtpy _TEXT SEGMENT _a$ = 8 ; size = 4 _b$ = 12 ; size = 4 ?addition@@YAHHH@Z PROC ; addition ; File c:\jitendern\rebook\addnumber\addnumber\addnumber.cpp ; Line 20 mov eax, DWORD PTR _b$[esp-4] add eax, DWORD PTR _a$[esp-4] ; Line 21 ret 0 ?addition@@YAHHH@Z ENDP ; addition _TEXT ENDS PUBLIC _main ; Function compile flags: /Ogtpy _TEXT SEGMENT _main PROC ; Line 14 xor eax, eax ; Line 15 ret 0 _main ENDP _TEXT ENDS END
;-------------------------------------------------------- ; File Created by SDCC : free open source ANSI-C Compiler ; Version 4.1.6 #12419 (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 __muluchar EXTERN __muluchar_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 _am9511_exp2 ;-------------------------------------------------------- ; Externals used ;-------------------------------------------------------- GLOBAL _hypot_callee GLOBAL _ldexp_callee GLOBAL _frexp_callee GLOBAL _sqrt_fastcall GLOBAL _sqr_fastcall GLOBAL _div2_fastcall GLOBAL _mul2_fastcall GLOBAL _am9511_modf GLOBAL _am9511_fmod GLOBAL _am9511_round GLOBAL _floor_fastcall GLOBAL _fabs_fastcall GLOBAL _ceil_fastcall GLOBAL _am9511_exp10 GLOBAL _am9511_log2 GLOBAL _pow_callee GLOBAL _exp_fastcall GLOBAL _log10_fastcall GLOBAL _log_fastcall GLOBAL _am9511_atanh GLOBAL _am9511_acosh GLOBAL _am9511_asinh GLOBAL _am9511_tanh GLOBAL _am9511_cosh GLOBAL _am9511_sinh GLOBAL _am9511_atan2 GLOBAL _atan_fastcall GLOBAL _acos_fastcall GLOBAL _asin_fastcall GLOBAL _tan_fastcall GLOBAL _cos_fastcall GLOBAL _sin_fastcall GLOBAL _exp10_fastcall GLOBAL _exp10 GLOBAL _mul10u_fastcall GLOBAL _mul10u GLOBAL _mul2 GLOBAL _div2 GLOBAL _sqr GLOBAL _fam9511_f32_fastcall GLOBAL _fam9511_f32 GLOBAL _f32_fam9511_fastcall GLOBAL _f32_fam9511 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 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 GLOBAL _pow GLOBAL _hypot GLOBAL _fabs GLOBAL _logb_fastcall GLOBAL _logb GLOBAL _log2_fastcall GLOBAL _log2 GLOBAL _log1p_fastcall GLOBAL _log1p GLOBAL _log10 GLOBAL _log GLOBAL _scalbln_callee GLOBAL _scalbln GLOBAL _scalbn_callee GLOBAL _scalbn GLOBAL _ldexp GLOBAL _ilogb_fastcall GLOBAL _ilogb GLOBAL _frexp GLOBAL _expm1_fastcall GLOBAL _expm1 GLOBAL _exp2_fastcall GLOBAL _exp2 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 GLOBAL _sin GLOBAL _cos GLOBAL _atan2_callee GLOBAL _atan2 GLOBAL _atan GLOBAL _asin GLOBAL _acos ;-------------------------------------------------------- ; 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 am9511_exp2 ; --------------------------------- _am9511_exp2: ld a, d and a,0x7f or a, e or a, h or a, l jr NZ,l_am9511_exp2_00102 ld de,0x3f80 ld hl,0x0000 jr l_am9511_exp2_00103 l_am9511_exp2_00102: push de push hl ld hl,0x3f31 push hl ld hl,0x7218 push hl call ___fsmul_callee jp _exp_fastcall l_am9511_exp2_00103: ret SECTION IGNORE
main.elf: file format elf32-littleriscv Disassembly of section .text: 00000000 <_start>: 0: 00000037 lui zero,0x0 00000004 <__crt0_pointer_init>: 4: 80002117 auipc sp,0x80002 8: ff810113 addi sp,sp,-8 # 80001ffc <__ctr0_io_space_begin+0x800021fc> c: 80000197 auipc gp,0x80000 10: 7f418193 addi gp,gp,2036 # 80000800 <__ctr0_io_space_begin+0x80000a00> 00000014 <__crt0_cpu_csr_init>: 14: 00000517 auipc a0,0x0 18: 12050513 addi a0,a0,288 # 134 <__crt0_dummy_trap_handler> 1c: 30551073 csrw mtvec,a0 20: 34151073 csrw mepc,a0 24: 30001073 csrw mstatus,zero 28: 30401073 csrw mie,zero 2c: 30601073 csrw mcounteren,zero 30: ffa00593 li a1,-6 34: 32059073 csrw mcountinhibit,a1 38: b0001073 csrw mcycle,zero 3c: b8001073 csrw mcycleh,zero 40: b0201073 csrw minstret,zero 44: b8201073 csrw minstreth,zero 00000048 <__crt0_reg_file_clear>: 48: 00000093 li ra,0 4c: 00000213 li tp,0 50: 00000293 li t0,0 54: 00000313 li t1,0 58: 00000393 li t2,0 5c: 00000713 li a4,0 60: 00000793 li a5,0 64: 00000813 li a6,0 68: 00000893 li a7,0 6c: 00000913 li s2,0 70: 00000993 li s3,0 74: 00000a13 li s4,0 78: 00000a93 li s5,0 7c: 00000b13 li s6,0 80: 00000b93 li s7,0 84: 00000c13 li s8,0 88: 00000c93 li s9,0 8c: 00000d13 li s10,0 90: 00000d93 li s11,0 94: 00000e13 li t3,0 98: 00000e93 li t4,0 9c: 00000f13 li t5,0 a0: 00000f93 li t6,0 000000a4 <__crt0_reset_io>: a4: 00000417 auipc s0,0x0 a8: d5c40413 addi s0,s0,-676 # fffffe00 <__ctr0_io_space_begin+0x0> ac: 00000497 auipc s1,0x0 b0: f5448493 addi s1,s1,-172 # 0 <_start> 000000b4 <__crt0_reset_io_loop>: b4: 00042023 sw zero,0(s0) b8: 00440413 addi s0,s0,4 bc: fe941ce3 bne s0,s1,b4 <__crt0_reset_io_loop> 000000c0 <__crt0_clear_bss>: c0: 80000597 auipc a1,0x80000 c4: f4058593 addi a1,a1,-192 # 80000000 <__ctr0_io_space_begin+0x80000200> c8: 8f418613 addi a2,gp,-1804 # 800000f4 <__BSS_END__> 000000cc <__crt0_clear_bss_loop>: cc: 00c5d863 bge a1,a2,dc <__crt0_clear_bss_loop_end> d0: 00058023 sb zero,0(a1) d4: 00158593 addi a1,a1,1 d8: ff5ff06f j cc <__crt0_clear_bss_loop> 000000dc <__crt0_clear_bss_loop_end>: dc: 00001597 auipc a1,0x1 e0: 01c58593 addi a1,a1,28 # 10f8 <__crt0_copy_data_src_begin> e4: 80000617 auipc a2,0x80000 e8: f1c60613 addi a2,a2,-228 # 80000000 <__ctr0_io_space_begin+0x80000200> ec: 80000697 auipc a3,0x80000 f0: f1468693 addi a3,a3,-236 # 80000000 <__ctr0_io_space_begin+0x80000200> 000000f4 <__crt0_copy_data_loop>: f4: 00d65c63 bge a2,a3,10c <__crt0_copy_data_loop_end> f8: 00058703 lb a4,0(a1) fc: 00e60023 sb a4,0(a2) 100: 00158593 addi a1,a1,1 104: 00160613 addi a2,a2,1 108: fedff06f j f4 <__crt0_copy_data_loop> 0000010c <__crt0_copy_data_loop_end>: 10c: 00000513 li a0,0 110: 00000593 li a1,0 114: 06c000ef jal ra,180 <main> 00000118 <__crt0_main_aftermath>: 118: 34051073 csrw mscratch,a0 11c: 00000093 li ra,0 120: 00008463 beqz ra,128 <__crt0_main_aftermath_end> 124: 000080e7 jalr ra 00000128 <__crt0_main_aftermath_end>: 128: 30047073 csrci mstatus,8 0000012c <__crt0_main_aftermath_end_loop>: 12c: 10500073 wfi 130: ffdff06f j 12c <__crt0_main_aftermath_end_loop> 00000134 <__crt0_dummy_trap_handler>: 134: ff810113 addi sp,sp,-8 138: 00812023 sw s0,0(sp) 13c: 00912223 sw s1,4(sp) 140: 34202473 csrr s0,mcause 144: 02044663 bltz s0,170 <__crt0_dummy_trap_handler_irq> 148: 34102473 csrr s0,mepc 0000014c <__crt0_dummy_trap_handler_exc_c_check>: 14c: 00041483 lh s1,0(s0) 150: 0034f493 andi s1,s1,3 154: 00240413 addi s0,s0,2 158: 34141073 csrw mepc,s0 15c: 00300413 li s0,3 160: 00941863 bne s0,s1,170 <__crt0_dummy_trap_handler_irq> 00000164 <__crt0_dummy_trap_handler_exc_uncrompressed>: 164: 34102473 csrr s0,mepc 168: 00240413 addi s0,s0,2 16c: 34141073 csrw mepc,s0 00000170 <__crt0_dummy_trap_handler_irq>: 170: 00012403 lw s0,0(sp) 174: 00412483 lw s1,4(sp) 178: 00810113 addi sp,sp,8 17c: 30200073 mret 00000180 <main>: 180: ff010113 addi sp,sp,-16 184: 00112623 sw ra,12(sp) 188: 00812423 sw s0,8(sp) 18c: 2f5000ef jal ra,c80 <neorv32_rte_setup> 190: 00005537 lui a0,0x5 194: 00000613 li a2,0 198: 00000593 li a1,0 19c: b0050513 addi a0,a0,-1280 # 4b00 <__crt0_copy_data_src_begin+0x3a08> 1a0: 330000ef jal ra,4d0 <neorv32_uart0_setup> 1a4: 148000ef jal ra,2ec <neorv32_xirq_available> 1a8: 02051263 bnez a0,1cc <main+0x4c> 1ac: 00001537 lui a0,0x1 1b0: dac50513 addi a0,a0,-596 # dac <__etext+0x20> 1b4: 438000ef jal ra,5ec <neorv32_uart0_printf> 1b8: 00c12083 lw ra,12(sp) 1bc: 00812403 lw s0,8(sp) 1c0: 00100513 li a0,1 1c4: 01010113 addi sp,sp,16 1c8: 00008067 ret 1cc: 00001537 lui a0,0x1 1d0: dc450513 addi a0,a0,-572 # dc4 <__etext+0x38> 1d4: 418000ef jal ra,5ec <neorv32_uart0_printf> 1d8: 124000ef jal ra,2fc <neorv32_xirq_setup> 1dc: 00050863 beqz a0,1ec <main+0x6c> 1e0: 00001537 lui a0,0x1 1e4: df850513 addi a0,a0,-520 # df8 <__etext+0x6c> 1e8: fcdff06f j 1b4 <main+0x34> 1ec: 26400593 li a1,612 1f0: 144000ef jal ra,334 <neorv32_xirq_install> 1f4: 00050413 mv s0,a0 1f8: 27400593 li a1,628 1fc: 00100513 li a0,1 200: 134000ef jal ra,334 <neorv32_xirq_install> 204: 00a40433 add s0,s0,a0 208: 28400593 li a1,644 20c: 00200513 li a0,2 210: 124000ef jal ra,334 <neorv32_xirq_install> 214: 00a40433 add s0,s0,a0 218: 29400593 li a1,660 21c: 00300513 li a0,3 220: 114000ef jal ra,334 <neorv32_xirq_install> 224: 00a40433 add s0,s0,a0 228: 00040863 beqz s0,238 <main+0xb8> 22c: 00001537 lui a0,0x1 230: e1450513 addi a0,a0,-492 # e14 <__etext+0x88> 234: f81ff06f j 1b4 <main+0x34> 238: 0f4000ef jal ra,32c <neorv32_xirq_global_enable> 23c: 30046073 csrsi mstatus,8 240: 00000013 nop 244: 00000013 nop 248: 00f00513 li a0,15 24c: 00000593 li a1,0 250: 279000ef jal ra,cc8 <neorv32_gpio_port_set> 254: 00000513 li a0,0 258: 00000593 li a1,0 25c: 26d000ef jal ra,cc8 <neorv32_gpio_port_set> 260: 0000006f j 260 <main+0xe0> 00000264 <xirq_handler_ch0>: 264: 00001537 lui a0,0x1 268: 00000593 li a1,0 26c: d8c50513 addi a0,a0,-628 # d8c <__etext> 270: 37c0006f j 5ec <neorv32_uart0_printf> 00000274 <xirq_handler_ch1>: 274: 00001537 lui a0,0x1 278: 00100593 li a1,1 27c: d8c50513 addi a0,a0,-628 # d8c <__etext> 280: 36c0006f j 5ec <neorv32_uart0_printf> 00000284 <xirq_handler_ch2>: 284: 00001537 lui a0,0x1 288: 00200593 li a1,2 28c: d8c50513 addi a0,a0,-628 # d8c <__etext> 290: 35c0006f j 5ec <neorv32_uart0_printf> 00000294 <xirq_handler_ch3>: 294: 00001537 lui a0,0x1 298: 00300593 li a1,3 29c: d8c50513 addi a0,a0,-628 # d8c <__etext> 2a0: 34c0006f j 5ec <neorv32_uart0_printf> 2a4: 0000 unimp 2a6: 0000 unimp 2a8: 0000 unimp 2aa: 0000 unimp 2ac: 0000 unimp 2ae: 0000 unimp 000002b0 <__neorv32_xirq_core>: 2b0: f8000693 li a3,-128 2b4: 0086a783 lw a5,8(a3) 2b8: 00100713 li a4,1 2bc: 00f71733 sll a4,a4,a5 2c0: fff74713 not a4,a4 2c4: 00e6a223 sw a4,4(a3) 2c8: 00279713 slli a4,a5,0x2 2cc: 800007b7 lui a5,0x80000 2d0: 00078793 mv a5,a5 2d4: 0006a423 sw zero,8(a3) 2d8: 00e787b3 add a5,a5,a4 2dc: 0007a783 lw a5,0(a5) # 80000000 <__ctr0_io_space_begin+0x80000200> 2e0: 00078067 jr a5 000002e4 <__neorv32_xirq_dummy_handler>: 2e4: 00000013 nop 2e8: 00008067 ret 000002ec <neorv32_xirq_available>: 2ec: fe802503 lw a0,-24(zero) # ffffffe8 <__ctr0_io_space_begin+0x1e8> 2f0: 01c55513 srli a0,a0,0x1c 2f4: 00157513 andi a0,a0,1 2f8: 00008067 ret 000002fc <neorv32_xirq_setup>: 2fc: 800007b7 lui a5,0x80000 300: f8002023 sw zero,-128(zero) # ffffff80 <__ctr0_io_space_begin+0x180> 304: 00078793 mv a5,a5 308: f8002223 sw zero,-124(zero) # ffffff84 <__ctr0_io_space_begin+0x184> 30c: 08078693 addi a3,a5,128 # 80000080 <__ctr0_io_space_begin+0x80000280> 310: 2e400713 li a4,740 314: 00e7a023 sw a4,0(a5) 318: 00478793 addi a5,a5,4 31c: fed79ce3 bne a5,a3,314 <neorv32_xirq_setup+0x18> 320: 2b000593 li a1,688 324: 01500513 li a0,21 328: 1010006f j c28 <neorv32_rte_exception_install> 0000032c <neorv32_xirq_global_enable>: 32c: 01800513 li a0,24 330: 4540006f j 784 <neorv32_cpu_irq_enable> 00000334 <neorv32_xirq_install>: 334: 01f00793 li a5,31 338: 02a7ee63 bltu a5,a0,374 <neorv32_xirq_install+0x40> 33c: 800007b7 lui a5,0x80000 340: 00251713 slli a4,a0,0x2 344: 00078793 mv a5,a5 348: 00e787b3 add a5,a5,a4 34c: 00b7a023 sw a1,0(a5) # 80000000 <__ctr0_io_space_begin+0x80000200> 350: 00100793 li a5,1 354: 00a79533 sll a0,a5,a0 358: fff54793 not a5,a0 35c: f8f02223 sw a5,-124(zero) # ffffff84 <__ctr0_io_space_begin+0x184> 360: f8002783 lw a5,-128(zero) # ffffff80 <__ctr0_io_space_begin+0x180> 364: 00a7e533 or a0,a5,a0 368: f8a02023 sw a0,-128(zero) # ffffff80 <__ctr0_io_space_begin+0x180> 36c: 00000513 li a0,0 370: 00008067 ret 374: 00100513 li a0,1 378: 00008067 ret 0000037c <__neorv32_uart_itoa>: 37c: fd010113 addi sp,sp,-48 380: 02812423 sw s0,40(sp) 384: 02912223 sw s1,36(sp) 388: 03212023 sw s2,32(sp) 38c: 01312e23 sw s3,28(sp) 390: 01412c23 sw s4,24(sp) 394: 02112623 sw ra,44(sp) 398: 01512a23 sw s5,20(sp) 39c: 00001a37 lui s4,0x1 3a0: 00050493 mv s1,a0 3a4: 00058413 mv s0,a1 3a8: 00058523 sb zero,10(a1) 3ac: 00000993 li s3,0 3b0: 00410913 addi s2,sp,4 3b4: e30a0a13 addi s4,s4,-464 # e30 <numbers.1> 3b8: 00a00593 li a1,10 3bc: 00048513 mv a0,s1 3c0: 169000ef jal ra,d28 <__umodsi3> 3c4: 00aa0533 add a0,s4,a0 3c8: 00054783 lbu a5,0(a0) 3cc: 01390ab3 add s5,s2,s3 3d0: 00048513 mv a0,s1 3d4: 00fa8023 sb a5,0(s5) 3d8: 00a00593 li a1,10 3dc: 105000ef jal ra,ce0 <__udivsi3> 3e0: 00198993 addi s3,s3,1 3e4: 00a00793 li a5,10 3e8: 00050493 mv s1,a0 3ec: fcf996e3 bne s3,a5,3b8 <__neorv32_uart_itoa+0x3c> 3f0: 00090693 mv a3,s2 3f4: 00900713 li a4,9 3f8: 03000613 li a2,48 3fc: 0096c583 lbu a1,9(a3) 400: 00070793 mv a5,a4 404: fff70713 addi a4,a4,-1 408: 01071713 slli a4,a4,0x10 40c: 01075713 srli a4,a4,0x10 410: 00c59a63 bne a1,a2,424 <__neorv32_uart_itoa+0xa8> 414: 000684a3 sb zero,9(a3) 418: fff68693 addi a3,a3,-1 41c: fe0710e3 bnez a4,3fc <__neorv32_uart_itoa+0x80> 420: 00000793 li a5,0 424: 00f907b3 add a5,s2,a5 428: 00000593 li a1,0 42c: 0007c703 lbu a4,0(a5) 430: 00070c63 beqz a4,448 <__neorv32_uart_itoa+0xcc> 434: 00158693 addi a3,a1,1 438: 00b405b3 add a1,s0,a1 43c: 00e58023 sb a4,0(a1) 440: 01069593 slli a1,a3,0x10 444: 0105d593 srli a1,a1,0x10 448: fff78713 addi a4,a5,-1 44c: 02f91863 bne s2,a5,47c <__neorv32_uart_itoa+0x100> 450: 00b40433 add s0,s0,a1 454: 00040023 sb zero,0(s0) 458: 02c12083 lw ra,44(sp) 45c: 02812403 lw s0,40(sp) 460: 02412483 lw s1,36(sp) 464: 02012903 lw s2,32(sp) 468: 01c12983 lw s3,28(sp) 46c: 01812a03 lw s4,24(sp) 470: 01412a83 lw s5,20(sp) 474: 03010113 addi sp,sp,48 478: 00008067 ret 47c: 00070793 mv a5,a4 480: fadff06f j 42c <__neorv32_uart_itoa+0xb0> 00000484 <__neorv32_uart_tohex>: 484: 00001637 lui a2,0x1 488: 00758693 addi a3,a1,7 48c: 00000713 li a4,0 490: e3c60613 addi a2,a2,-452 # e3c <symbols.0> 494: 02000813 li a6,32 498: 00e557b3 srl a5,a0,a4 49c: 00f7f793 andi a5,a5,15 4a0: 00f607b3 add a5,a2,a5 4a4: 0007c783 lbu a5,0(a5) 4a8: 00470713 addi a4,a4,4 4ac: fff68693 addi a3,a3,-1 4b0: 00f680a3 sb a5,1(a3) 4b4: ff0712e3 bne a4,a6,498 <__neorv32_uart_tohex+0x14> 4b8: 00058423 sb zero,8(a1) 4bc: 00008067 ret 000004c0 <neorv32_uart0_available>: 4c0: fe802503 lw a0,-24(zero) # ffffffe8 <__ctr0_io_space_begin+0x1e8> 4c4: 01255513 srli a0,a0,0x12 4c8: 00157513 andi a0,a0,1 4cc: 00008067 ret 000004d0 <neorv32_uart0_setup>: 4d0: ff010113 addi sp,sp,-16 4d4: 00812423 sw s0,8(sp) 4d8: 00912223 sw s1,4(sp) 4dc: 00112623 sw ra,12(sp) 4e0: fa002023 sw zero,-96(zero) # ffffffa0 <__ctr0_io_space_begin+0x1a0> 4e4: fe002783 lw a5,-32(zero) # ffffffe0 <__ctr0_io_space_begin+0x1e0> 4e8: 00058413 mv s0,a1 4ec: 00151593 slli a1,a0,0x1 4f0: 00078513 mv a0,a5 4f4: 00060493 mv s1,a2 4f8: 7e8000ef jal ra,ce0 <__udivsi3> 4fc: 01051513 slli a0,a0,0x10 500: 000017b7 lui a5,0x1 504: 01055513 srli a0,a0,0x10 508: 00000713 li a4,0 50c: ffe78793 addi a5,a5,-2 # ffe <symbols.0+0x1c2> 510: 04a7e463 bltu a5,a0,558 <neorv32_uart0_setup+0x88> 514: 0034f793 andi a5,s1,3 518: 00347413 andi s0,s0,3 51c: fff50513 addi a0,a0,-1 520: 01479793 slli a5,a5,0x14 524: 01641413 slli s0,s0,0x16 528: 00f567b3 or a5,a0,a5 52c: 0087e7b3 or a5,a5,s0 530: 01871713 slli a4,a4,0x18 534: 00c12083 lw ra,12(sp) 538: 00812403 lw s0,8(sp) 53c: 00e7e7b3 or a5,a5,a4 540: 10000737 lui a4,0x10000 544: 00e7e7b3 or a5,a5,a4 548: faf02023 sw a5,-96(zero) # ffffffa0 <__ctr0_io_space_begin+0x1a0> 54c: 00412483 lw s1,4(sp) 550: 01010113 addi sp,sp,16 554: 00008067 ret 558: ffe70693 addi a3,a4,-2 # ffffffe <__crt0_copy_data_src_begin+0xfffef06> 55c: 0fd6f693 andi a3,a3,253 560: 00069a63 bnez a3,574 <neorv32_uart0_setup+0xa4> 564: 00355513 srli a0,a0,0x3 568: 00170713 addi a4,a4,1 56c: 0ff77713 andi a4,a4,255 570: fa1ff06f j 510 <neorv32_uart0_setup+0x40> 574: 00155513 srli a0,a0,0x1 578: ff1ff06f j 568 <neorv32_uart0_setup+0x98> 0000057c <neorv32_uart0_putc>: 57c: 00040737 lui a4,0x40 580: fa002783 lw a5,-96(zero) # ffffffa0 <__ctr0_io_space_begin+0x1a0> 584: 00e7f7b3 and a5,a5,a4 588: fe079ce3 bnez a5,580 <neorv32_uart0_putc+0x4> 58c: faa02223 sw a0,-92(zero) # ffffffa4 <__ctr0_io_space_begin+0x1a4> 590: 00008067 ret 00000594 <neorv32_uart0_print>: 594: ff010113 addi sp,sp,-16 598: 00812423 sw s0,8(sp) 59c: 01212023 sw s2,0(sp) 5a0: 00112623 sw ra,12(sp) 5a4: 00912223 sw s1,4(sp) 5a8: 00050413 mv s0,a0 5ac: 00a00913 li s2,10 5b0: 00044483 lbu s1,0(s0) 5b4: 00140413 addi s0,s0,1 5b8: 00049e63 bnez s1,5d4 <neorv32_uart0_print+0x40> 5bc: 00c12083 lw ra,12(sp) 5c0: 00812403 lw s0,8(sp) 5c4: 00412483 lw s1,4(sp) 5c8: 00012903 lw s2,0(sp) 5cc: 01010113 addi sp,sp,16 5d0: 00008067 ret 5d4: 01249663 bne s1,s2,5e0 <neorv32_uart0_print+0x4c> 5d8: 00d00513 li a0,13 5dc: fa1ff0ef jal ra,57c <neorv32_uart0_putc> 5e0: 00048513 mv a0,s1 5e4: f99ff0ef jal ra,57c <neorv32_uart0_putc> 5e8: fc9ff06f j 5b0 <neorv32_uart0_print+0x1c> 000005ec <neorv32_uart0_printf>: 5ec: fa010113 addi sp,sp,-96 5f0: 04f12a23 sw a5,84(sp) 5f4: 04410793 addi a5,sp,68 5f8: 02812c23 sw s0,56(sp) 5fc: 03212823 sw s2,48(sp) 600: 03412423 sw s4,40(sp) 604: 03512223 sw s5,36(sp) 608: 03612023 sw s6,32(sp) 60c: 01712e23 sw s7,28(sp) 610: 01812c23 sw s8,24(sp) 614: 01912a23 sw s9,20(sp) 618: 02112e23 sw ra,60(sp) 61c: 02912a23 sw s1,52(sp) 620: 03312623 sw s3,44(sp) 624: 00050413 mv s0,a0 628: 04b12223 sw a1,68(sp) 62c: 04c12423 sw a2,72(sp) 630: 04d12623 sw a3,76(sp) 634: 04e12823 sw a4,80(sp) 638: 05012c23 sw a6,88(sp) 63c: 05112e23 sw a7,92(sp) 640: 00f12023 sw a5,0(sp) 644: 02500a13 li s4,37 648: 00a00a93 li s5,10 64c: 07300913 li s2,115 650: 07500b13 li s6,117 654: 07800b93 li s7,120 658: 06300c13 li s8,99 65c: 06900c93 li s9,105 660: 00044483 lbu s1,0(s0) 664: 02049c63 bnez s1,69c <neorv32_uart0_printf+0xb0> 668: 03c12083 lw ra,60(sp) 66c: 03812403 lw s0,56(sp) 670: 03412483 lw s1,52(sp) 674: 03012903 lw s2,48(sp) 678: 02c12983 lw s3,44(sp) 67c: 02812a03 lw s4,40(sp) 680: 02412a83 lw s5,36(sp) 684: 02012b03 lw s6,32(sp) 688: 01c12b83 lw s7,28(sp) 68c: 01812c03 lw s8,24(sp) 690: 01412c83 lw s9,20(sp) 694: 06010113 addi sp,sp,96 698: 00008067 ret 69c: 0d449863 bne s1,s4,76c <neorv32_uart0_printf+0x180> 6a0: 00240993 addi s3,s0,2 6a4: 00144403 lbu s0,1(s0) 6a8: 05240263 beq s0,s2,6ec <neorv32_uart0_printf+0x100> 6ac: 00896e63 bltu s2,s0,6c8 <neorv32_uart0_printf+0xdc> 6b0: 05840c63 beq s0,s8,708 <neorv32_uart0_printf+0x11c> 6b4: 07940663 beq s0,s9,720 <neorv32_uart0_printf+0x134> 6b8: 02500513 li a0,37 6bc: ec1ff0ef jal ra,57c <neorv32_uart0_putc> 6c0: 00040513 mv a0,s0 6c4: 0540006f j 718 <neorv32_uart0_printf+0x12c> 6c8: 09640663 beq s0,s6,754 <neorv32_uart0_printf+0x168> 6cc: ff7416e3 bne s0,s7,6b8 <neorv32_uart0_printf+0xcc> 6d0: 00012783 lw a5,0(sp) 6d4: 00410593 addi a1,sp,4 6d8: 0007a503 lw a0,0(a5) 6dc: 00478713 addi a4,a5,4 6e0: 00e12023 sw a4,0(sp) 6e4: da1ff0ef jal ra,484 <__neorv32_uart_tohex> 6e8: 0640006f j 74c <neorv32_uart0_printf+0x160> 6ec: 00012783 lw a5,0(sp) 6f0: 0007a503 lw a0,0(a5) 6f4: 00478713 addi a4,a5,4 6f8: 00e12023 sw a4,0(sp) 6fc: e99ff0ef jal ra,594 <neorv32_uart0_print> 700: 00098413 mv s0,s3 704: f5dff06f j 660 <neorv32_uart0_printf+0x74> 708: 00012783 lw a5,0(sp) 70c: 0007c503 lbu a0,0(a5) 710: 00478713 addi a4,a5,4 714: 00e12023 sw a4,0(sp) 718: e65ff0ef jal ra,57c <neorv32_uart0_putc> 71c: fe5ff06f j 700 <neorv32_uart0_printf+0x114> 720: 00012783 lw a5,0(sp) 724: 0007a403 lw s0,0(a5) 728: 00478713 addi a4,a5,4 72c: 00e12023 sw a4,0(sp) 730: 00045863 bgez s0,740 <neorv32_uart0_printf+0x154> 734: 02d00513 li a0,45 738: 40800433 neg s0,s0 73c: e41ff0ef jal ra,57c <neorv32_uart0_putc> 740: 00410593 addi a1,sp,4 744: 00040513 mv a0,s0 748: c35ff0ef jal ra,37c <__neorv32_uart_itoa> 74c: 00410513 addi a0,sp,4 750: fadff06f j 6fc <neorv32_uart0_printf+0x110> 754: 00012783 lw a5,0(sp) 758: 00410593 addi a1,sp,4 75c: 00478713 addi a4,a5,4 760: 0007a503 lw a0,0(a5) 764: 00e12023 sw a4,0(sp) 768: fe1ff06f j 748 <neorv32_uart0_printf+0x15c> 76c: 01549663 bne s1,s5,778 <neorv32_uart0_printf+0x18c> 770: 00d00513 li a0,13 774: e09ff0ef jal ra,57c <neorv32_uart0_putc> 778: 00140993 addi s3,s0,1 77c: 00048513 mv a0,s1 780: f99ff06f j 718 <neorv32_uart0_printf+0x12c> 00000784 <neorv32_cpu_irq_enable>: 784: 01f00793 li a5,31 788: 00050713 mv a4,a0 78c: 02a7e663 bltu a5,a0,7b8 <neorv32_cpu_irq_enable+0x34> 790: ffff17b7 lui a5,0xffff1 794: 88878793 addi a5,a5,-1912 # ffff0888 <__ctr0_io_space_begin+0xffff0a88> 798: 00a7d7b3 srl a5,a5,a0 79c: 0017f793 andi a5,a5,1 7a0: 00100513 li a0,1 7a4: 00078c63 beqz a5,7bc <neorv32_cpu_irq_enable+0x38> 7a8: 00e51533 sll a0,a0,a4 7ac: 30452073 csrs mie,a0 7b0: 00000513 li a0,0 7b4: 00008067 ret 7b8: 00100513 li a0,1 7bc: 00008067 ret 000007c0 <__neorv32_rte_core>: 7c0: fc010113 addi sp,sp,-64 7c4: 02112e23 sw ra,60(sp) 7c8: 02512c23 sw t0,56(sp) 7cc: 02612a23 sw t1,52(sp) 7d0: 02712823 sw t2,48(sp) 7d4: 02a12623 sw a0,44(sp) 7d8: 02b12423 sw a1,40(sp) 7dc: 02c12223 sw a2,36(sp) 7e0: 02d12023 sw a3,32(sp) 7e4: 00e12e23 sw a4,28(sp) 7e8: 00f12c23 sw a5,24(sp) 7ec: 01012a23 sw a6,20(sp) 7f0: 01112823 sw a7,16(sp) 7f4: 01c12623 sw t3,12(sp) 7f8: 01d12423 sw t4,8(sp) 7fc: 01e12223 sw t5,4(sp) 800: 01f12023 sw t6,0(sp) 804: 34102773 csrr a4,mepc 808: 34071073 csrw mscratch,a4 80c: 342027f3 csrr a5,mcause 810: 0807ca63 bltz a5,8a4 <__neorv32_rte_core+0xe4> 814: 00071683 lh a3,0(a4) # 40000 <__crt0_copy_data_src_begin+0x3ef08> 818: 00300593 li a1,3 81c: 0036f693 andi a3,a3,3 820: 00270613 addi a2,a4,2 824: 00b69463 bne a3,a1,82c <__neorv32_rte_core+0x6c> 828: 00470613 addi a2,a4,4 82c: 34161073 csrw mepc,a2 830: 00b00713 li a4,11 834: 04f77c63 bgeu a4,a5,88c <__neorv32_rte_core+0xcc> 838: 000017b7 lui a5,0x1 83c: a3078793 addi a5,a5,-1488 # a30 <__neorv32_rte_debug_exc_handler> 840: 000780e7 jalr a5 844: 03c12083 lw ra,60(sp) 848: 03812283 lw t0,56(sp) 84c: 03412303 lw t1,52(sp) 850: 03012383 lw t2,48(sp) 854: 02c12503 lw a0,44(sp) 858: 02812583 lw a1,40(sp) 85c: 02412603 lw a2,36(sp) 860: 02012683 lw a3,32(sp) 864: 01c12703 lw a4,28(sp) 868: 01812783 lw a5,24(sp) 86c: 01412803 lw a6,20(sp) 870: 01012883 lw a7,16(sp) 874: 00c12e03 lw t3,12(sp) 878: 00812e83 lw t4,8(sp) 87c: 00412f03 lw t5,4(sp) 880: 00012f83 lw t6,0(sp) 884: 04010113 addi sp,sp,64 888: 30200073 mret 88c: 00001737 lui a4,0x1 890: 00279793 slli a5,a5,0x2 894: e5070713 addi a4,a4,-432 # e50 <symbols.0+0x14> 898: 00e787b3 add a5,a5,a4 89c: 0007a783 lw a5,0(a5) 8a0: 00078067 jr a5 8a4: 80000737 lui a4,0x80000 8a8: ffd74713 xori a4,a4,-3 8ac: 00e787b3 add a5,a5,a4 8b0: 01c00713 li a4,28 8b4: f8f762e3 bltu a4,a5,838 <__neorv32_rte_core+0x78> 8b8: 00001737 lui a4,0x1 8bc: 00279793 slli a5,a5,0x2 8c0: e8070713 addi a4,a4,-384 # e80 <symbols.0+0x44> 8c4: 00e787b3 add a5,a5,a4 8c8: 0007a783 lw a5,0(a5) 8cc: 00078067 jr a5 8d0: 8801a783 lw a5,-1920(gp) # 80000080 <__neorv32_rte_vector_lut> 8d4: f6dff06f j 840 <__neorv32_rte_core+0x80> 8d8: 8841a783 lw a5,-1916(gp) # 80000084 <__neorv32_rte_vector_lut+0x4> 8dc: f65ff06f j 840 <__neorv32_rte_core+0x80> 8e0: 8881a783 lw a5,-1912(gp) # 80000088 <__neorv32_rte_vector_lut+0x8> 8e4: f5dff06f j 840 <__neorv32_rte_core+0x80> 8e8: 88c1a783 lw a5,-1908(gp) # 8000008c <__neorv32_rte_vector_lut+0xc> 8ec: f55ff06f j 840 <__neorv32_rte_core+0x80> 8f0: 8901a783 lw a5,-1904(gp) # 80000090 <__neorv32_rte_vector_lut+0x10> 8f4: f4dff06f j 840 <__neorv32_rte_core+0x80> 8f8: 8941a783 lw a5,-1900(gp) # 80000094 <__neorv32_rte_vector_lut+0x14> 8fc: f45ff06f j 840 <__neorv32_rte_core+0x80> 900: 8981a783 lw a5,-1896(gp) # 80000098 <__neorv32_rte_vector_lut+0x18> 904: f3dff06f j 840 <__neorv32_rte_core+0x80> 908: 89c1a783 lw a5,-1892(gp) # 8000009c <__neorv32_rte_vector_lut+0x1c> 90c: f35ff06f j 840 <__neorv32_rte_core+0x80> 910: 8a01a783 lw a5,-1888(gp) # 800000a0 <__neorv32_rte_vector_lut+0x20> 914: f2dff06f j 840 <__neorv32_rte_core+0x80> 918: 8a41a783 lw a5,-1884(gp) # 800000a4 <__neorv32_rte_vector_lut+0x24> 91c: f25ff06f j 840 <__neorv32_rte_core+0x80> 920: 8a81a783 lw a5,-1880(gp) # 800000a8 <__neorv32_rte_vector_lut+0x28> 924: f1dff06f j 840 <__neorv32_rte_core+0x80> 928: 8ac1a783 lw a5,-1876(gp) # 800000ac <__neorv32_rte_vector_lut+0x2c> 92c: f15ff06f j 840 <__neorv32_rte_core+0x80> 930: 8b01a783 lw a5,-1872(gp) # 800000b0 <__neorv32_rte_vector_lut+0x30> 934: f0dff06f j 840 <__neorv32_rte_core+0x80> 938: 8b41a783 lw a5,-1868(gp) # 800000b4 <__neorv32_rte_vector_lut+0x34> 93c: f05ff06f j 840 <__neorv32_rte_core+0x80> 940: 8b81a783 lw a5,-1864(gp) # 800000b8 <__neorv32_rte_vector_lut+0x38> 944: efdff06f j 840 <__neorv32_rte_core+0x80> 948: 8bc1a783 lw a5,-1860(gp) # 800000bc <__neorv32_rte_vector_lut+0x3c> 94c: ef5ff06f j 840 <__neorv32_rte_core+0x80> 950: 8c01a783 lw a5,-1856(gp) # 800000c0 <__neorv32_rte_vector_lut+0x40> 954: eedff06f j 840 <__neorv32_rte_core+0x80> 958: 8c41a783 lw a5,-1852(gp) # 800000c4 <__neorv32_rte_vector_lut+0x44> 95c: ee5ff06f j 840 <__neorv32_rte_core+0x80> 960: 8c81a783 lw a5,-1848(gp) # 800000c8 <__neorv32_rte_vector_lut+0x48> 964: eddff06f j 840 <__neorv32_rte_core+0x80> 968: 8cc1a783 lw a5,-1844(gp) # 800000cc <__neorv32_rte_vector_lut+0x4c> 96c: ed5ff06f j 840 <__neorv32_rte_core+0x80> 970: 8d01a783 lw a5,-1840(gp) # 800000d0 <__neorv32_rte_vector_lut+0x50> 974: ecdff06f j 840 <__neorv32_rte_core+0x80> 978: 8d41a783 lw a5,-1836(gp) # 800000d4 <__neorv32_rte_vector_lut+0x54> 97c: ec5ff06f j 840 <__neorv32_rte_core+0x80> 980: 8d81a783 lw a5,-1832(gp) # 800000d8 <__neorv32_rte_vector_lut+0x58> 984: ebdff06f j 840 <__neorv32_rte_core+0x80> 988: 8dc1a783 lw a5,-1828(gp) # 800000dc <__neorv32_rte_vector_lut+0x5c> 98c: eb5ff06f j 840 <__neorv32_rte_core+0x80> 990: 8e01a783 lw a5,-1824(gp) # 800000e0 <__neorv32_rte_vector_lut+0x60> 994: eadff06f j 840 <__neorv32_rte_core+0x80> 998: 8e41a783 lw a5,-1820(gp) # 800000e4 <__neorv32_rte_vector_lut+0x64> 99c: ea5ff06f j 840 <__neorv32_rte_core+0x80> 9a0: 8e81a783 lw a5,-1816(gp) # 800000e8 <__neorv32_rte_vector_lut+0x68> 9a4: e9dff06f j 840 <__neorv32_rte_core+0x80> 9a8: 8ec1a783 lw a5,-1812(gp) # 800000ec <__neorv32_rte_vector_lut+0x6c> 9ac: e95ff06f j 840 <__neorv32_rte_core+0x80> 9b0: 8f01a783 lw a5,-1808(gp) # 800000f0 <__neorv32_rte_vector_lut+0x70> 9b4: e8dff06f j 840 <__neorv32_rte_core+0x80> 9b8: 0000 unimp 9ba: 0000 unimp 9bc: 0000 unimp 9be: 0000 unimp 000009c0 <__neorv32_rte_print_hex_word>: 9c0: fe010113 addi sp,sp,-32 9c4: 01212823 sw s2,16(sp) 9c8: 00050913 mv s2,a0 9cc: 00001537 lui a0,0x1 9d0: 00912a23 sw s1,20(sp) 9d4: ef450513 addi a0,a0,-268 # ef4 <symbols.0+0xb8> 9d8: 000014b7 lui s1,0x1 9dc: 00812c23 sw s0,24(sp) 9e0: 01312623 sw s3,12(sp) 9e4: 00112e23 sw ra,28(sp) 9e8: 01c00413 li s0,28 9ec: ba9ff0ef jal ra,594 <neorv32_uart0_print> 9f0: 0e848493 addi s1,s1,232 # 10e8 <hex_symbols.0> 9f4: ffc00993 li s3,-4 9f8: 008957b3 srl a5,s2,s0 9fc: 00f7f793 andi a5,a5,15 a00: 00f487b3 add a5,s1,a5 a04: 0007c503 lbu a0,0(a5) a08: ffc40413 addi s0,s0,-4 a0c: b71ff0ef jal ra,57c <neorv32_uart0_putc> a10: ff3414e3 bne s0,s3,9f8 <__neorv32_rte_print_hex_word+0x38> a14: 01c12083 lw ra,28(sp) a18: 01812403 lw s0,24(sp) a1c: 01412483 lw s1,20(sp) a20: 01012903 lw s2,16(sp) a24: 00c12983 lw s3,12(sp) a28: 02010113 addi sp,sp,32 a2c: 00008067 ret 00000a30 <__neorv32_rte_debug_exc_handler>: a30: ff010113 addi sp,sp,-16 a34: 00112623 sw ra,12(sp) a38: 00812423 sw s0,8(sp) a3c: 00912223 sw s1,4(sp) a40: a81ff0ef jal ra,4c0 <neorv32_uart0_available> a44: 1c050863 beqz a0,c14 <__neorv32_rte_debug_exc_handler+0x1e4> a48: 00001537 lui a0,0x1 a4c: ef850513 addi a0,a0,-264 # ef8 <symbols.0+0xbc> a50: b45ff0ef jal ra,594 <neorv32_uart0_print> a54: 34202473 csrr s0,mcause a58: 00900713 li a4,9 a5c: 00f47793 andi a5,s0,15 a60: 03078493 addi s1,a5,48 a64: 00f77463 bgeu a4,a5,a6c <__neorv32_rte_debug_exc_handler+0x3c> a68: 05778493 addi s1,a5,87 a6c: 00b00793 li a5,11 a70: 0087ee63 bltu a5,s0,a8c <__neorv32_rte_debug_exc_handler+0x5c> a74: 00001737 lui a4,0x1 a78: 00241793 slli a5,s0,0x2 a7c: 0b870713 addi a4,a4,184 # 10b8 <symbols.0+0x27c> a80: 00e787b3 add a5,a5,a4 a84: 0007a783 lw a5,0(a5) a88: 00078067 jr a5 a8c: 800007b7 lui a5,0x80000 a90: 00b78713 addi a4,a5,11 # 8000000b <__ctr0_io_space_begin+0x8000020b> a94: 14e40e63 beq s0,a4,bf0 <__neorv32_rte_debug_exc_handler+0x1c0> a98: 02876a63 bltu a4,s0,acc <__neorv32_rte_debug_exc_handler+0x9c> a9c: 00378713 addi a4,a5,3 aa0: 12e40c63 beq s0,a4,bd8 <__neorv32_rte_debug_exc_handler+0x1a8> aa4: 00778793 addi a5,a5,7 aa8: 12f40e63 beq s0,a5,be4 <__neorv32_rte_debug_exc_handler+0x1b4> aac: 00001537 lui a0,0x1 ab0: 05850513 addi a0,a0,88 # 1058 <symbols.0+0x21c> ab4: ae1ff0ef jal ra,594 <neorv32_uart0_print> ab8: 00040513 mv a0,s0 abc: f05ff0ef jal ra,9c0 <__neorv32_rte_print_hex_word> ac0: 00100793 li a5,1 ac4: 08f40c63 beq s0,a5,b5c <__neorv32_rte_debug_exc_handler+0x12c> ac8: 0280006f j af0 <__neorv32_rte_debug_exc_handler+0xc0> acc: ff07c793 xori a5,a5,-16 ad0: 00f407b3 add a5,s0,a5 ad4: 00f00713 li a4,15 ad8: fcf76ae3 bltu a4,a5,aac <__neorv32_rte_debug_exc_handler+0x7c> adc: 00001537 lui a0,0x1 ae0: 04850513 addi a0,a0,72 # 1048 <symbols.0+0x20c> ae4: ab1ff0ef jal ra,594 <neorv32_uart0_print> ae8: 00048513 mv a0,s1 aec: a91ff0ef jal ra,57c <neorv32_uart0_putc> af0: ffd47413 andi s0,s0,-3 af4: 00500793 li a5,5 af8: 06f40263 beq s0,a5,b5c <__neorv32_rte_debug_exc_handler+0x12c> afc: 00001537 lui a0,0x1 b00: 09c50513 addi a0,a0,156 # 109c <symbols.0+0x260> b04: a91ff0ef jal ra,594 <neorv32_uart0_print> b08: 34002573 csrr a0,mscratch b0c: eb5ff0ef jal ra,9c0 <__neorv32_rte_print_hex_word> b10: 00001537 lui a0,0x1 b14: 0a450513 addi a0,a0,164 # 10a4 <symbols.0+0x268> b18: a7dff0ef jal ra,594 <neorv32_uart0_print> b1c: 34302573 csrr a0,mtval b20: ea1ff0ef jal ra,9c0 <__neorv32_rte_print_hex_word> b24: 00812403 lw s0,8(sp) b28: 00c12083 lw ra,12(sp) b2c: 00412483 lw s1,4(sp) b30: 00001537 lui a0,0x1 b34: 0b050513 addi a0,a0,176 # 10b0 <symbols.0+0x274> b38: 01010113 addi sp,sp,16 b3c: a59ff06f j 594 <neorv32_uart0_print> b40: 00001537 lui a0,0x1 b44: f0050513 addi a0,a0,-256 # f00 <symbols.0+0xc4> b48: a4dff0ef jal ra,594 <neorv32_uart0_print> b4c: fb1ff06f j afc <__neorv32_rte_debug_exc_handler+0xcc> b50: 00001537 lui a0,0x1 b54: f2050513 addi a0,a0,-224 # f20 <symbols.0+0xe4> b58: a3dff0ef jal ra,594 <neorv32_uart0_print> b5c: f7c02783 lw a5,-132(zero) # ffffff7c <__ctr0_io_space_begin+0x17c> b60: 0a07d463 bgez a5,c08 <__neorv32_rte_debug_exc_handler+0x1d8> b64: 0017f793 andi a5,a5,1 b68: 08078a63 beqz a5,bfc <__neorv32_rte_debug_exc_handler+0x1cc> b6c: 00001537 lui a0,0x1 b70: 07050513 addi a0,a0,112 # 1070 <symbols.0+0x234> b74: fd5ff06f j b48 <__neorv32_rte_debug_exc_handler+0x118> b78: 00001537 lui a0,0x1 b7c: f3c50513 addi a0,a0,-196 # f3c <symbols.0+0x100> b80: fc9ff06f j b48 <__neorv32_rte_debug_exc_handler+0x118> b84: 00001537 lui a0,0x1 b88: f5050513 addi a0,a0,-176 # f50 <symbols.0+0x114> b8c: fbdff06f j b48 <__neorv32_rte_debug_exc_handler+0x118> b90: 00001537 lui a0,0x1 b94: f5c50513 addi a0,a0,-164 # f5c <symbols.0+0x120> b98: fb1ff06f j b48 <__neorv32_rte_debug_exc_handler+0x118> b9c: 00001537 lui a0,0x1 ba0: f7450513 addi a0,a0,-140 # f74 <symbols.0+0x138> ba4: fb5ff06f j b58 <__neorv32_rte_debug_exc_handler+0x128> ba8: 00001537 lui a0,0x1 bac: f8850513 addi a0,a0,-120 # f88 <symbols.0+0x14c> bb0: f99ff06f j b48 <__neorv32_rte_debug_exc_handler+0x118> bb4: 00001537 lui a0,0x1 bb8: fa450513 addi a0,a0,-92 # fa4 <symbols.0+0x168> bbc: f9dff06f j b58 <__neorv32_rte_debug_exc_handler+0x128> bc0: 00001537 lui a0,0x1 bc4: fb850513 addi a0,a0,-72 # fb8 <symbols.0+0x17c> bc8: f81ff06f j b48 <__neorv32_rte_debug_exc_handler+0x118> bcc: 00001537 lui a0,0x1 bd0: fd850513 addi a0,a0,-40 # fd8 <symbols.0+0x19c> bd4: f75ff06f j b48 <__neorv32_rte_debug_exc_handler+0x118> bd8: 00001537 lui a0,0x1 bdc: ff850513 addi a0,a0,-8 # ff8 <symbols.0+0x1bc> be0: f69ff06f j b48 <__neorv32_rte_debug_exc_handler+0x118> be4: 00001537 lui a0,0x1 be8: 01450513 addi a0,a0,20 # 1014 <symbols.0+0x1d8> bec: f5dff06f j b48 <__neorv32_rte_debug_exc_handler+0x118> bf0: 00001537 lui a0,0x1 bf4: 02c50513 addi a0,a0,44 # 102c <symbols.0+0x1f0> bf8: f51ff06f j b48 <__neorv32_rte_debug_exc_handler+0x118> bfc: 00001537 lui a0,0x1 c00: 08050513 addi a0,a0,128 # 1080 <symbols.0+0x244> c04: f45ff06f j b48 <__neorv32_rte_debug_exc_handler+0x118> c08: 00001537 lui a0,0x1 c0c: 09050513 addi a0,a0,144 # 1090 <symbols.0+0x254> c10: f39ff06f j b48 <__neorv32_rte_debug_exc_handler+0x118> c14: 00c12083 lw ra,12(sp) c18: 00812403 lw s0,8(sp) c1c: 00412483 lw s1,4(sp) c20: 01010113 addi sp,sp,16 c24: 00008067 ret 00000c28 <neorv32_rte_exception_install>: c28: 01f00793 li a5,31 c2c: 00a7ee63 bltu a5,a0,c48 <neorv32_rte_exception_install+0x20> c30: 88018793 addi a5,gp,-1920 # 80000080 <__neorv32_rte_vector_lut> c34: 00251513 slli a0,a0,0x2 c38: 00a78533 add a0,a5,a0 c3c: 00b52023 sw a1,0(a0) c40: 00000513 li a0,0 c44: 00008067 ret c48: 00100513 li a0,1 c4c: 00008067 ret 00000c50 <neorv32_rte_exception_uninstall>: c50: 01f00793 li a5,31 c54: 02a7e263 bltu a5,a0,c78 <neorv32_rte_exception_uninstall+0x28> c58: 88018793 addi a5,gp,-1920 # 80000080 <__neorv32_rte_vector_lut> c5c: 00251513 slli a0,a0,0x2 c60: 00a78533 add a0,a5,a0 c64: 000017b7 lui a5,0x1 c68: a3078793 addi a5,a5,-1488 # a30 <__neorv32_rte_debug_exc_handler> c6c: 00f52023 sw a5,0(a0) c70: 00000513 li a0,0 c74: 00008067 ret c78: 00100513 li a0,1 c7c: 00008067 ret 00000c80 <neorv32_rte_setup>: c80: ff010113 addi sp,sp,-16 c84: 00112623 sw ra,12(sp) c88: 00812423 sw s0,8(sp) c8c: 00912223 sw s1,4(sp) c90: 7c000793 li a5,1984 c94: 30579073 csrw mtvec,a5 c98: 00000413 li s0,0 c9c: 01d00493 li s1,29 ca0: 00040513 mv a0,s0 ca4: 00140413 addi s0,s0,1 ca8: 0ff47413 andi s0,s0,255 cac: fa5ff0ef jal ra,c50 <neorv32_rte_exception_uninstall> cb0: fe9418e3 bne s0,s1,ca0 <neorv32_rte_setup+0x20> cb4: 00c12083 lw ra,12(sp) cb8: 00812403 lw s0,8(sp) cbc: 00412483 lw s1,4(sp) cc0: 01010113 addi sp,sp,16 cc4: 00008067 ret 00000cc8 <neorv32_gpio_port_set>: cc8: fc000793 li a5,-64 ccc: 00a7a423 sw a0,8(a5) cd0: 00b7a623 sw a1,12(a5) cd4: 00008067 ret 00000cd8 <__divsi3>: cd8: 06054063 bltz a0,d38 <__umodsi3+0x10> cdc: 0605c663 bltz a1,d48 <__umodsi3+0x20> 00000ce0 <__udivsi3>: ce0: 00058613 mv a2,a1 ce4: 00050593 mv a1,a0 ce8: fff00513 li a0,-1 cec: 02060c63 beqz a2,d24 <__udivsi3+0x44> cf0: 00100693 li a3,1 cf4: 00b67a63 bgeu a2,a1,d08 <__udivsi3+0x28> cf8: 00c05863 blez a2,d08 <__udivsi3+0x28> cfc: 00161613 slli a2,a2,0x1 d00: 00169693 slli a3,a3,0x1 d04: feb66ae3 bltu a2,a1,cf8 <__udivsi3+0x18> d08: 00000513 li a0,0 d0c: 00c5e663 bltu a1,a2,d18 <__udivsi3+0x38> d10: 40c585b3 sub a1,a1,a2 d14: 00d56533 or a0,a0,a3 d18: 0016d693 srli a3,a3,0x1 d1c: 00165613 srli a2,a2,0x1 d20: fe0696e3 bnez a3,d0c <__udivsi3+0x2c> d24: 00008067 ret 00000d28 <__umodsi3>: d28: 00008293 mv t0,ra d2c: fb5ff0ef jal ra,ce0 <__udivsi3> d30: 00058513 mv a0,a1 d34: 00028067 jr t0 d38: 40a00533 neg a0,a0 d3c: 00b04863 bgtz a1,d4c <__umodsi3+0x24> d40: 40b005b3 neg a1,a1 d44: f9dff06f j ce0 <__udivsi3> d48: 40b005b3 neg a1,a1 d4c: 00008293 mv t0,ra d50: f91ff0ef jal ra,ce0 <__udivsi3> d54: 40a00533 neg a0,a0 d58: 00028067 jr t0 00000d5c <__modsi3>: d5c: 00008293 mv t0,ra d60: 0005ca63 bltz a1,d74 <__modsi3+0x18> d64: 00054c63 bltz a0,d7c <__modsi3+0x20> d68: f79ff0ef jal ra,ce0 <__udivsi3> d6c: 00058513 mv a0,a1 d70: 00028067 jr t0 d74: 40b005b3 neg a1,a1 d78: fe0558e3 bgez a0,d68 <__modsi3+0xc> d7c: 40a00533 neg a0,a0 d80: f61ff0ef jal ra,ce0 <__udivsi3> d84: 40b00533 neg a0,a1 d88: 00028067 jr t0
; A table that translates key presses on the zx keyboard into ascii ; codes. There are four tables mapping the 8x5 zx matrix to an ; ascii code, each corresponding to the states of the CAPS / SYM ; shift keys. ; ; An effort has been made to emulate the PC keyboard with the CTRL key ; represented by CAPS+SYM shifts simultaneously pressed. PUBLIC kbd_transtbl .kbd_transtbl ; the following keys are unshifted defb 255,'z','x','c','v' ; CAPS SHIFT, Z, X, C, V defb 'a','s','d','f','g' ; A, S, D, F, G defb 'q','w','e','r','t' ; Q, W, E, R, T defb '1','2','3','4','5' ; 1, 2, 3, 4, 5 defb '0','9','8','7','6' ; 0, 9, 8, 7, 6 defb 'p','o','i','u','y' ; P, O, I, U, Y defb 13,'l','k','j','h' ; ENTER, L, K, J, H defb ' ',255,'m','n','b' ; SPACE, SYM SHIFT, M, N, B ; the following keys are CAPS SHIFTed defb 255,'Z','X','C','V' ; CAPS SHIFT, Z, X, C, V defb 'A','S','D','F','G' ; A, S, D, F, G defb 'Q','W','E','R','T' ; Q, W, E, R, T defb 7,0,128,129,8 ; 1, 2, 3, 4, 5 defb 12,8,9,11,10 ; 0, 9, 8, 7, 6 defb 'P','O','I','U','Y' ; P, O, I, U, Y defb 13,'L','K','J','H' ; ENTER, L, K, J, H defb ' ',255,'M','N','B' ; SPACE, SYM SHIFT, M, N, B ; the following keys are SYM SHIFTed defb 255,':',96,'?','/' ; CAPS SHIFT, Z, X, C, V defb '~','|',92,'{','}' ; A, S, D, F, G defb 131,132,133,'<','>' ; Q, W, E, R, T defb '!','@','#','$','%' ; 1, 2, 3, 4, 5 defb '_',')','(',39,'&' ; 0, 9, 8, 7, 6 defb 34,';',130,']','[' ; P, O, I, U, Y defb 13,'=','+','-','^' ; ENTER, L, K, J, H defb ' ',255,'.',',','*' ; SPACE, SYM SHIFT, M, N, B ; the following keys are CAPS SHIFTed and SYM SHIFTed ("CTRL" key) defb 255,26,24,3,22 ; CAPS SHIFT, Z, X, C, V defb 1,19,4,6,7 ; A, S, D, F, G defb 17,23,5,18,20 ; Q, W, E, R, T defb 27,28,29,30,31 ; 1, 2, 3, 4, 5 defb 127,255,134,'`',135 ; 0, 9, 8, 7, 6 defb 16,15,9,21,25 ; P, O, I, U, Y defb 13,12,11,10,8 ; ENTER, L, K, J, H defb ' ',255,13,14,2 ; SPACE, SYM SHIFT, M, N, B
/** * Copyright 2017-2020 Stefan Ascher * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies * of the Software, and to permit persons to whom the Software is furnished to do * so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include "EffectManager.h" #include "Effect.h" #include "DataProvider.h" #include <abscommon/DataClient.h> namespace Game { AB::Entities::EffectCategory EffectCatNameToEffectCat(const std::string& name) { const size_t hash = sa::StringHashRt(name.c_str()); switch (hash) { case EFFECTTCAT_CONDITION: return AB::Entities::EffectCondition; case EFFECTTCAT_ENCHANTMENT: return AB::Entities::EffectEnchantment; case EFFECTTCAT_HEX: return AB::Entities::EffectHex; case EFFECTTCAT_SHOUT: return AB::Entities::EffectShout; case EFFECTTCAT_SPIRIT: return AB::Entities::EffectSpirit; case EFFECTTCAT_WARD: return AB::Entities::EffectWard; case EFFECTTCAT_WELL: return AB::Entities::EffectWell; case EFFECTTCAT_PREPARATION: return AB::Entities::EffectPreparation; case EFFECTTCAT_STANCE: return AB::Entities::EffectStance; case EFFECTTCAT_FORM: return AB::Entities::EffectForm; case EFFECTTCAT_GLYPHE: return AB::Entities::EffectGlyphe; case EFFECTTCAT_PETATTTACK: return AB::Entities::EffectPetAttack; case EFFECTTCAT_WEAPONSPELL: return AB::Entities::EffectWeaponSpell; default: return AB::Entities::EffectNone; } } ea::shared_ptr<Effect> EffectManager::Get(uint32_t index) { ea::shared_ptr<Effect> result; auto it = effects_.find(index); if (it != effects_.end()) { result = ea::make_shared<Effect>((*it).second); } else { IO::DataClient* client = GetSubsystem<IO::DataClient>(); AB::Entities::Effect effect; effect.index = index; if (!client->Read(effect)) { LOG_ERROR << "Error reading effect with index " << index << std::endl; return ea::shared_ptr<Effect>(); } result = ea::make_shared<Effect>(effect); // Move to cache effects_.emplace(index, effect); } if (result) { if (result->LoadScript(result->data_.script)) return result; } return ea::shared_ptr<Effect>(); } }
clc adc {m2} sta {m1} lda #0 adc {m2}+1 sta {m1}+1
TITLE 'SEE IF MEMBER IS IN THE PDS' SPACE 3 CLEQUM04 BASEREG EQU 12 CLASMS04 CSECT ******************************************************************* ** SAVE REGISTERS, ETC. ******************************************************************* STM R14,R12,12(R13) SAVE REGISTERS R14 THRU 12 LR BASEREG,R15 LOAD ENTRY POINT USING CLASMS04,BASEREG ESTABLISH REGISTER LA R4,SAVE GET ADDRESS OF SAVE AREA ST R4,8(R13) CALLERS FORWARD CHAIN ST R13,4(R4) MY BACKWARD CHAIN LR R13,R4 LOAD R13 TO MY SAVE AREA WTO ' Message from ASM Subroutine CLASMS04', * ROUTCDE=(11),DESC=(7) ******************************************************************* ** GO BACK TO CALLING PROGRAM ******************************************************************* GOBACK EQU * L R13,SAVE+4 RESTORE REG 13 LM R14,R12,12(R13) RESTORE REGS 14 THRU 12 SR R15,R15 SET CONDCODE=0 BR R14 RETURN ******************************************************************* * MAIN STORAGE ******************************************************************* LTORG DS 0F SAVE DS 18F END CLASMS04
.global s_prepare_buffers s_prepare_buffers: push %r10 push %r13 push %rbp push %rbx push %rcx push %rdi push %rdx push %rsi lea addresses_normal_ht+0x134e7, %rdi nop nop nop nop nop xor $35422, %rbp mov (%rdi), %esi nop nop nop sub %r10, %r10 lea addresses_WT_ht+0x1b9e7, %rsi lea addresses_normal_ht+0xc08f, %rdi nop nop nop nop nop xor $18822, %r10 mov $69, %rcx rep movsq cmp %rcx, %rcx lea addresses_UC_ht+0x1a2e7, %rbx nop nop nop nop nop cmp %r13, %r13 mov $0x6162636465666768, %rcx movq %rcx, (%rbx) nop nop sub %rsi, %rsi lea addresses_D_ht+0xc217, %rsi lea addresses_normal_ht+0x104e7, %rdi nop nop nop nop sub %rdx, %rdx mov $29, %rcx rep movsl nop nop nop nop and $6871, %rsi lea addresses_A_ht+0x111ed, %rsi nop and $62279, %rdi movl $0x61626364, (%rsi) nop cmp %r13, %r13 lea addresses_WC_ht+0x1cc47, %rdi nop cmp $11520, %rsi mov $0x6162636465666768, %rbp movq %rbp, %xmm2 movups %xmm2, (%rdi) nop nop nop nop cmp $18585, %r10 lea addresses_A_ht+0x1c0e7, %rbx nop nop add %rsi, %rsi movb (%rbx), %cl nop inc %rbp lea addresses_UC_ht+0x1ec5c, %rdx nop nop nop nop nop and $26305, %rsi mov $0x6162636465666768, %rdi movq %rdi, (%rdx) nop cmp %rsi, %rsi lea addresses_WC_ht+0x175e7, %rdi nop add $12181, %rdx movw $0x6162, (%rdi) nop nop nop cmp %rdi, %rdi pop %rsi pop %rdx pop %rdi pop %rcx pop %rbx pop %rbp pop %r13 pop %r10 ret .global s_faulty_load s_faulty_load: push %r11 push %r12 push %r13 push %rbp push %rcx push %rdi push %rsi // REPMOV lea addresses_normal+0x1abff, %rsi lea addresses_D+0xd317, %rdi nop sub %r12, %r12 mov $98, %rcx rep movsw nop nop nop inc %rcx // Store lea addresses_UC+0x9fe7, %rcx nop nop nop nop nop dec %r13 mov $0x5152535455565758, %rdi movq %rdi, (%rcx) nop nop nop nop nop xor %r11, %r11 // Store lea addresses_RW+0x313b, %rbp nop cmp $2354, %r13 mov $0x5152535455565758, %rsi movq %rsi, %xmm2 vmovntdq %ymm2, (%rbp) nop nop nop nop nop xor %r12, %r12 // Store lea addresses_US+0xb467, %rbp nop nop nop inc %rdi movw $0x5152, (%rbp) // Exception!!! nop nop nop nop nop mov (0), %rcx inc %r12 // Store lea addresses_A+0x120e7, %r11 sub $35140, %rbp movw $0x5152, (%r11) nop xor $59516, %r11 // Load lea addresses_PSE+0xcc67, %r13 nop nop nop sub $4746, %rsi movups (%r13), %xmm7 vpextrq $0, %xmm7, %rcx nop inc %rbp // Faulty Load mov $0x442ab10000000ce7, %r12 nop nop nop sub $41432, %rcx movups (%r12), %xmm0 vpextrq $1, %xmm0, %rbp lea oracles, %rcx and $0xff, %rbp shlq $12, %rbp mov (%rcx,%rbp,1), %rbp pop %rsi pop %rdi pop %rcx pop %rbp pop %r13 pop %r12 pop %r11 ret /* <gen_faulty_load> [REF] {'src': {'same': False, 'congruent': 0, 'NT': False, 'type': 'addresses_NC', 'size': 4, 'AVXalign': False}, 'OP': 'LOAD'} {'src': {'type': 'addresses_normal', 'congruent': 3, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_D', 'congruent': 2, 'same': False}} {'OP': 'STOR', 'dst': {'same': False, 'congruent': 7, 'NT': False, 'type': 'addresses_UC', 'size': 8, 'AVXalign': False}} {'OP': 'STOR', 'dst': {'same': False, 'congruent': 2, 'NT': True, 'type': 'addresses_RW', 'size': 32, 'AVXalign': False}} {'OP': 'STOR', 'dst': {'same': False, 'congruent': 7, 'NT': False, 'type': 'addresses_US', 'size': 2, 'AVXalign': False}} {'OP': 'STOR', 'dst': {'same': False, 'congruent': 10, 'NT': False, 'type': 'addresses_A', 'size': 2, 'AVXalign': False}} {'src': {'same': False, 'congruent': 7, 'NT': False, 'type': 'addresses_PSE', 'size': 16, 'AVXalign': False}, 'OP': 'LOAD'} [Faulty Load] {'src': {'same': True, 'congruent': 0, 'NT': False, 'type': 'addresses_NC', 'size': 16, 'AVXalign': False}, 'OP': 'LOAD'} <gen_prepare_buffer> {'src': {'same': False, 'congruent': 7, 'NT': True, 'type': 'addresses_normal_ht', 'size': 4, 'AVXalign': False}, 'OP': 'LOAD'} {'src': {'type': 'addresses_WT_ht', 'congruent': 7, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_normal_ht', 'congruent': 2, 'same': False}} {'OP': 'STOR', 'dst': {'same': False, 'congruent': 7, 'NT': False, 'type': 'addresses_UC_ht', 'size': 8, 'AVXalign': False}} {'src': {'type': 'addresses_D_ht', 'congruent': 3, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_normal_ht', 'congruent': 10, 'same': True}} {'OP': 'STOR', 'dst': {'same': False, 'congruent': 1, 'NT': False, 'type': 'addresses_A_ht', 'size': 4, 'AVXalign': False}} {'OP': 'STOR', 'dst': {'same': False, 'congruent': 5, 'NT': False, 'type': 'addresses_WC_ht', 'size': 16, 'AVXalign': False}} {'src': {'same': False, 'congruent': 10, 'NT': False, 'type': 'addresses_A_ht', 'size': 1, 'AVXalign': False}, 'OP': 'LOAD'} {'OP': 'STOR', 'dst': {'same': False, 'congruent': 0, 'NT': False, 'type': 'addresses_UC_ht', 'size': 8, 'AVXalign': False}} {'OP': 'STOR', 'dst': {'same': False, 'congruent': 8, 'NT': False, 'type': 'addresses_WC_ht', 'size': 2, 'AVXalign': False}} {'34': 58, '00': 173, '49': 20, '46': 16, '44': 1, '73': 1, '68': 15, 'ff': 1} ff 00 00 34 00 00 00 00 00 00 73 00 34 49 34 00 00 44 68 00 00 00 00 00 46 00 46 00 00 34 34 00 68 46 34 00 00 34 49 34 00 00 00 00 49 46 68 00 00 00 46 00 34 00 00 46 00 00 34 00 00 00 00 00 00 00 34 00 00 00 00 00 00 00 34 49 46 34 00 34 00 00 34 49 00 49 00 00 68 49 34 49 49 00 34 00 34 00 00 00 00 00 34 34 00 49 00 34 00 00 00 34 68 00 00 00 34 00 46 00 00 34 00 34 00 00 00 00 00 34 34 34 68 34 34 00 00 00 68 34 68 00 00 34 00 00 00 00 00 00 00 00 34 34 00 00 34 00 00 46 00 00 00 00 00 00 49 00 00 00 49 00 00 00 49 00 00 34 00 00 34 34 46 34 00 34 00 49 34 00 00 34 00 34 49 00 00 68 34 00 34 00 00 68 00 34 00 34 00 34 68 00 00 00 00 34 34 00 46 00 00 00 00 00 00 00 49 00 49 00 68 00 46 00 00 00 34 49 00 00 34 00 00 00 34 46 00 49 68 00 00 00 34 00 00 00 46 00 49 00 34 00 00 00 00 00 00 68 00 00 34 46 00 00 34 00 00 00 00 34 00 46 00 00 68 */
; A130664: a(1)=1. a(n) = a(n-1) + (number of terms from among a(1) through a(n-1) which are factorials). ; 1,2,4,6,9,12,15,18,21,24,28,32,36,40,44,48,52,56,60,64,68,72,76,80,84,88,92,96,100,104,108,112,116,120,125,130,135,140,145,150,155,160,165,170,175,180,185,190,195,200,205,210,215,220,225,230,235,240,245,250,255,260,265,270,275,280,285,290,295,300,305,310,315,320,325,330,335,340,345,350,355,360,365,370,375,380,385,390,395,400,405,410,415,420,425,430,435,440,445,450,455,460,465,470,475,480,485,490,495,500,505,510,515,520,525,530,535,540,545,550,555,560,565,570,575,580,585,590,595,600,605,610,615,620,625,630,635,640,645,650,655,660,665,670,675,680,685,690,695,700,705,710,715,720,726,732,738,744,750,756,762,768,774,780,786,792,798,804,810,816,822,828,834,840,846,852,858,864,870,876,882,888,894,900,906,912,918,924,930,936,942,948,954,960,966,972,978,984,990,996,1002,1008,1014,1020,1026,1032,1038,1044,1050,1056,1062,1068,1074,1080,1086,1092,1098,1104,1110,1116,1122,1128,1134,1140,1146,1152,1158,1164,1170,1176,1182,1188,1194,1200,1206,1212,1218,1224,1230,1236,1242,1248,1254,1260,1266,1272,1278,1284,1290,1296 mov $4,$0 add $4,1 mov $7,$0 lpb $4,1 mov $0,$7 sub $4,1 sub $0,$4 mov $2,$0 mov $3,1 lpb $2,1 add $5,$3 mov $6,$3 lpb $5,1 sub $2,1 sub $5,$5 add $6,$2 mov $8,$5 lpe lpb $6,1 add $8,1 mov $3,$8 sub $6,1 div $6,$8 lpe mov $2,1 lpe add $1,$3 lpe
#include "tabtexteditor.h" #include <QHBoxLayout> #include <QSettings> #include <QTreeWidget> #include <QComboBox> #include <QLabel> #include <QTextEdit> #include <QFontDatabase> #include <QDebug> TabTextEditor::TabTextEditor(QWidget *parent) : QWidget(parent) { QHBoxLayout *mainLayout = new QHBoxLayout; mainLayout->addStretch(mBasicStretch); // getting data from QSettings QSettings s; mFontSizeCurrent = (s.contains("editorFontSize") ? s.value("editorFontSize").toString() : mFontSizeDefault); mFontCurrent = (s.contains("editorFontName") ? s.value("editorFontName").toString() : mFontDefault); mFontSizeNew = mFontSizeCurrent; mFontNew = mFontCurrent; // FONT SIZE QHBoxLayout *fontSizeLayoutHoriz = new QHBoxLayout; fontSizeLayoutHoriz->addStretch(mBasicStretch); // set a label QLabel *fontSizeLabel = new QLabel(tr("Font size")); mpComboFontSize = new QComboBox(this); for (int i = minRange; i <= maxRange; i += 2) { mFontSizeList << QString::number(i); } mpComboFontSize->addItems(mFontSizeList); fontSizeLayoutHoriz->addWidget(fontSizeLabel); fontSizeLayoutHoriz->addWidget(mpComboFontSize); QVBoxLayout *fontSizeLayoutVert = new QVBoxLayout; fontSizeLayoutVert->addStretch(mBasicStretch); fontSizeLayoutVert->addLayout(fontSizeLayoutHoriz); fontSizeLayoutVert->addSpacing(100); fontSizeLayoutVert->addStretch(100); mainLayout->addLayout(fontSizeLayoutVert); mainLayout->addSpacing(mColumnSpacing); // set combobox acording to settings mpComboFontSize->setCurrentIndex(0); for(int i = 0; i < mFontSizeList.size(); ++i) { auto &item = mFontSizeList[i]; if (item == mFontSizeCurrent) { mpComboFontSize->setCurrentIndex(i); break; } } connect(mpComboFontSize, SIGNAL(currentIndexChanged(const QString&)), SLOT(onChangeFontSize(const QString&))); // FONT NAME // handling system fonts setupFontTree(); mainLayout->addWidget(mpFontTree); mainLayout->addSpacing(mColumnSpacing); // preview selected font mpTextEdit = new QTextEdit(this); mainLayout->addWidget(mpTextEdit); showFont(mpFontTree->topLevelItem(mFontNumber - 1)); mainLayout->addStretch(100); setLayout(mainLayout); connect(mpFontTree, SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)), this, SLOT(showFont(QTreeWidgetItem*))); } const QString &TabTextEditor::getFontSizeCurrernt() const { return mFontSizeCurrent; } const QString &TabTextEditor::getFontSizeNew() const { return mFontSizeNew; } void TabTextEditor::setFontSizeCurrernt(const QString & newFontSize) { mFontSizeCurrent = newFontSize; } const QString &TabTextEditor::getFontCurrernt() const { return mFontCurrent; } const QString &TabTextEditor::getFontNew() const { return mFontNew; } void TabTextEditor::setFontCurrernt(const QString & newFont) { mFontCurrent = newFont; } void TabTextEditor::setupFontTree() { QFontDatabase database; mpFontTree = new QTreeWidget; mpFontTree->setColumnCount(1); mpFontTree->setHeaderLabels(QStringList() << tr("Font")); int decentFontNumber = 0; bool foundFont = false; foreach (QString family, database.families()) { QTreeWidgetItem *familyItem = new QTreeWidgetItem(mpFontTree); familyItem->setText(0, family); ++decentFontNumber; if (family == mFontCurrent) { mFontNumber = decentFontNumber; familyItem->setSelected(true); foundFont = true; } } if (!foundFont) // in system not found decent font. choose first in database { mpFontTree->setCurrentItem( mpFontTree->topLevelItem(0), // item 0, // column QItemSelectionModel::Select // command ); mFontNumber = 1; } } void TabTextEditor::showFont(QTreeWidgetItem *item) { if (!item) return; QString family; if (item->parent()) family = item->parent()->text(0); else family = item->text(0); mFontNew = family; QString oldText = mpTextEdit->toPlainText().trimmed(); bool modified = mpTextEdit->document()->isModified(); mpTextEdit->clear(); QFont font(family, mFontSizePreview, QFont::Normal, false); mpTextEdit->document()->setDefaultFont(font); QTextCursor cursor = mpTextEdit->textCursor(); QTextBlockFormat blockFormat; blockFormat.setAlignment(Qt::AlignCenter); cursor.insertBlock(blockFormat); if (modified) cursor.insertText(QString(oldText)); else cursor.insertText(QString("%1").arg(family)); mpTextEdit->document()->setModified(modified); emit onChangeFont(mFontNew); } void TabTextEditor::onChangeFont(const QString & newItem) { mFontNew = newItem; } void TabTextEditor::onChangeFontSize(const QString & newItem) { mFontSizeNew = newItem; }
; A024853: a(n) = s(1)t(n) + s(2)t(n-1) + ... + s(k)t(n-k+1), where k = [ n/2 ], s = (natural numbers), t = (natural numbers >= 2). ; 3,4,13,16,34,40,70,80,125,140,203,224,308,336,444,480,615,660,825,880,1078,1144,1378,1456,1729,1820,2135,2240,2600,2720,3128,3264,3723,3876,4389,4560,5130,5320,5950,6160,6853,7084,7843,8096,8924,9200,10100,10400 add $0,3 lpb $0 add $1,$2 add $2,$0 trn $0,2 lpe mov $0,$1
; int wa_priority_queue_resize(wa_priority_queue_t *q, size_t n) SECTION code_clib SECTION code_adt_wa_priority_queue PUBLIC wa_priority_queue_resize_callee EXTERN asm_wa_priority_queue_resize wa_priority_queue_resize_callee: pop hl pop de ex (sp),hl jp asm_wa_priority_queue_resize
; A318236: a(n) = (3*2^(4*n+3) + 1)/5. ; 5,77,1229,19661,314573,5033165,80530637,1288490189,20615843021,329853488333,5277655813325,84442493013197,1351079888211149,21617278211378381,345876451382054093,5534023222112865485,88544371553805847757,1416709944860893564109,22667359117774297025741,362677745884388752411853,5802843934150220038589645,92845502946403520617434317,1485528047142456329878949069,23768448754279301278063185101,380295180068468820449010961613,6084722881095501127184175385805,97355566097528018034946806172877,1557689057560448288559148898766029,24923024920967172616946382380256461,398768398735474761871142118084103373 mov $1,16 mov $2,$0 add $2,1 pow $1,$2 div $1,15 mul $1,9 add $1,1 div $1,2 mov $0,$1
; A301730: Expansion of (x^8-x^7+x^6+5*x^5+4*x^4+3*x^3+5*x^2+5*x+1)/(x^6-x^5-x+1). ; 1,6,11,14,18,24,30,34,38,42,48,54,58,62,66,72,78,82,86,90,96,102,106,110,114,120,126,130,134,138,144,150,154,158,162,168,174,178,182,186,192,198,202,206,210,216,222,226,230,234,240,246,250,254,258,264 mov $1,$0 seq $0,315187 ; Coordination sequence Gal.3.14.3 where G.u.t.v denotes the coordination sequence for a vertex of type v in tiling number t in the Galebach list of u-uniform tilings. sub $1,2 mov $2,$1 dif $2,$1 sub $0,$2 add $0,1
; A254398: Final digits of A237424 in decimal representation. ; 1,4,7,4,7,7,4,7,7,7,4,7,7,7,7,4,7,7,7,7,7,4,7,7,7,7,7,7,4,7,7,7,7,7,7,7,4,7,7,7,7,7,7,7,7,4,7,7,7,7,7,7,7,7,7,4,7,7,7,7,7,7,7,7,7,7,4,7,7,7,7,7,7,7,7,7,7,7,4,7,7,7,7,7,7,7 mov $3,$0 lpb $3 mov $1,$2 sub $3,$4 mov $5,3 lpb $5 sub $5,$3 lpe add $1,$5 add $1,3 trn $3,1 add $4,1 lpe add $1,1
.global s_prepare_buffers s_prepare_buffers: push %r12 push %r13 push %r15 push %rax push %rcx push %rdi push %rdx push %rsi lea addresses_UC_ht+0x189c5, %r12 nop nop nop nop nop add %rdx, %rdx movb (%r12), %cl add $4530, %rsi lea addresses_D_ht+0x2145, %rax nop nop nop and %r15, %r15 movb $0x61, (%rax) nop nop nop inc %rcx lea addresses_D_ht+0x3b45, %rdx nop nop add $44181, %rax movl $0x61626364, (%rdx) nop xor $62534, %rcx lea addresses_normal_ht+0x2dc5, %r12 clflush (%r12) nop nop and $38231, %r13 movw $0x6162, (%r12) nop nop nop nop nop add %r13, %r13 lea addresses_normal_ht+0x120c5, %r15 nop nop nop nop nop sub $9154, %rax movb (%r15), %r13b nop nop nop nop nop add $46141, %rax lea addresses_WC_ht+0x8545, %rsi lea addresses_WC_ht+0x17aeb, %rdi nop xor $963, %r12 mov $29, %rcx rep movsb nop sub $58848, %rdi lea addresses_UC_ht+0xe945, %rsi lea addresses_UC_ht+0x1bb5c, %rdi nop nop nop nop sub $56128, %r12 mov $47, %rcx rep movsl and %rax, %rax lea addresses_WC_ht+0x2b45, %r13 nop nop inc %rcx movups (%r13), %xmm7 vpextrq $0, %xmm7, %rsi nop sub $3123, %r13 pop %rsi pop %rdx pop %rdi pop %rcx pop %rax pop %r15 pop %r13 pop %r12 ret .global s_faulty_load s_faulty_load: push %r10 push %r12 push %r15 push %r9 push %rsi // Faulty Load lea addresses_WC+0x11145, %r15 inc %r9 mov (%r15), %esi lea oracles, %r12 and $0xff, %rsi shlq $12, %rsi mov (%r12,%rsi,1), %rsi pop %rsi pop %r9 pop %r15 pop %r12 pop %r10 ret /* <gen_faulty_load> [REF] {'src': {'congruent': 0, 'AVXalign': False, 'same': False, 'size': 2, 'NT': False, 'type': 'addresses_WC'}, 'OP': 'LOAD'} [Faulty Load] {'src': {'congruent': 0, 'AVXalign': True, 'same': True, 'size': 4, 'NT': False, 'type': 'addresses_WC'}, 'OP': 'LOAD'} <gen_prepare_buffer> {'src': {'congruent': 6, 'AVXalign': False, 'same': False, 'size': 1, 'NT': False, 'type': 'addresses_UC_ht'}, 'OP': 'LOAD'} {'OP': 'STOR', 'dst': {'congruent': 11, 'AVXalign': False, 'same': False, 'size': 1, 'NT': False, 'type': 'addresses_D_ht'}} {'OP': 'STOR', 'dst': {'congruent': 9, 'AVXalign': False, 'same': False, 'size': 4, 'NT': False, 'type': 'addresses_D_ht'}} {'OP': 'STOR', 'dst': {'congruent': 6, 'AVXalign': False, 'same': False, 'size': 2, 'NT': False, 'type': 'addresses_normal_ht'}} {'src': {'congruent': 5, 'AVXalign': False, 'same': False, 'size': 1, 'NT': False, 'type': 'addresses_normal_ht'}, 'OP': 'LOAD'} {'src': {'congruent': 10, 'same': False, 'type': 'addresses_WC_ht'}, 'OP': 'REPM', 'dst': {'congruent': 0, 'same': False, 'type': 'addresses_WC_ht'}} {'src': {'congruent': 11, 'same': False, 'type': 'addresses_UC_ht'}, 'OP': 'REPM', 'dst': {'congruent': 0, 'same': False, 'type': 'addresses_UC_ht'}} {'src': {'congruent': 5, 'AVXalign': False, 'same': True, 'size': 16, 'NT': False, 'type': 'addresses_WC_ht'}, 'OP': 'LOAD'} {'00': 21829} 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 */
#include <internal/util/windows/wmi.hpp> #include <facter/execution/execution.hpp> #include <leatherman/logging/logging.hpp> #include <boost/algorithm/string/join.hpp> #include <boost/algorithm/string/trim.hpp> #include <boost/range/iterator_range.hpp> #include <boost/nowide/convert.hpp> #define _WIN32_DCOM #include <comdef.h> #include <wbemidl.h> using namespace std; using namespace facter::execution; namespace facter { namespace util { namespace windows { wmi_exception::wmi_exception(string const& message) : runtime_error(message) { } string format_hresult(char const* s, HRESULT hres) { return str(boost::format("%1% (%2%)") % s % boost::io::group(hex, showbase, hres)); } // GUID taken from a Windows installation and unaccepted change to MinGW-w64. The MinGW-w64 library // doesn't define it, but obscures the Windows Platform SDK version of wbemuuid.lib. constexpr static CLSID MyCLSID_WbemLocator = {0x4590f811, 0x1d3a, 0x11d0, 0x89, 0x1f, 0x00, 0xaa, 0x00, 0x4b, 0x2e, 0x24}; wmi::wmi() { LOG_DEBUG("initializing WMI"); auto hres = CoInitializeEx(0, COINIT_MULTITHREADED); if (FAILED(hres)) { if (hres == RPC_E_CHANGED_MODE) { LOG_DEBUG("using prior COM concurrency model"); } else { throw wmi_exception(format_hresult("failed to initialize COM library", hres)); } } else { _coInit = scoped_resource<bool>(true, [](bool b) { CoUninitialize(); }); } IWbemLocator *pLoc; hres = CoCreateInstance(MyCLSID_WbemLocator, 0, CLSCTX_INPROC_SERVER, IID_IWbemLocator, reinterpret_cast<LPVOID *>(&pLoc)); if (FAILED(hres)) { throw wmi_exception(format_hresult("failed to create IWbemLocator object", hres)); } _pLoc = scoped_resource<IWbemLocator *>(pLoc, [](IWbemLocator *loc) { if (loc) loc->Release(); }); IWbemServices *pSvc; hres = (*_pLoc).ConnectServer(_bstr_t(L"ROOT\\CIMV2"), nullptr, nullptr, nullptr, 0, nullptr, nullptr, &pSvc); if (FAILED(hres)) { throw wmi_exception(format_hresult("could not connect to WMI server", hres)); } _pSvc = scoped_resource<IWbemServices *>(pSvc, [](IWbemServices *svc) { if (svc) svc->Release(); }); hres = CoSetProxyBlanket(_pSvc, RPC_C_AUTHN_WINNT, RPC_C_AUTHZ_NONE, NULL, RPC_C_AUTHN_LEVEL_CALL, RPC_C_IMP_LEVEL_IMPERSONATE, NULL, EOAC_NONE); if (FAILED(hres)) { throw wmi_exception(format_hresult("could not set proxy blanket", hres)); } } static void wmi_add_result(wmi::imap &vals, string const& group, string const& s, VARIANT *vtProp) { if (V_VT(vtProp) == (VT_ARRAY | VT_BSTR)) { // It's an array of elements; serialize the array as elements with the same key in the imap. // To keep this simple, ignore multi-dimensional arrays. SAFEARRAY *arr = V_ARRAY(vtProp); if (arr->cDims != 1) { LOG_DEBUG("ignoring %1%-dimensional array in query %2%.%3%", arr->cDims, group, s); return; } BSTR *pbstr; if (FAILED(SafeArrayAccessData(arr, reinterpret_cast<void **>(&pbstr)))) { return; } for (auto i = 0u; i < arr->rgsabound[0].cElements; ++i) { vals.emplace(s, boost::trim_copy(boost::nowide::narrow(pbstr[i]))); } SafeArrayUnaccessData(arr); } else if (FAILED(VariantChangeType(vtProp, vtProp, 0, VT_BSTR)) || V_VT(vtProp) != VT_BSTR) { // Uninitialized (null) values can just be ignored. Any others get reported. if (V_VT(vtProp) != VT_NULL) { LOG_DEBUG("WMI query %1%.%2% result could not be converted from type %3% to a string", group, s, V_VT(vtProp)); } } else { vals.emplace(s, boost::trim_copy(boost::nowide::narrow(V_BSTR(vtProp)))); } } wmi::imaps wmi::query(string const& group, vector<string> const& keys, string const& extended) const { IEnumWbemClassObject *_pEnum = NULL; string qry = "SELECT " + boost::join(keys, ",") + " FROM " + group; if (!extended.empty()) { qry += " " + extended; } auto hres = (*_pSvc).ExecQuery(_bstr_t(L"WQL"), _bstr_t(boost::nowide::widen(qry).c_str()), WBEM_FLAG_FORWARD_ONLY | WBEM_FLAG_RETURN_IMMEDIATELY, NULL, &_pEnum); if (FAILED(hres)) { LOG_DEBUG("query %1% failed", qry); return {}; } scoped_resource<IEnumWbemClassObject *> pEnum(_pEnum, [](IEnumWbemClassObject *rsc) { if (rsc) rsc->Release(); }); imaps array_of_vals; IWbemClassObject *pclsObjs[256]; ULONG uReturn = 0; while (pEnum) { auto hr = (*pEnum).Next(WBEM_INFINITE, 256, pclsObjs, &uReturn); if (FAILED(hr) || 0 == uReturn) { break; } for (auto pclsObj : boost::make_iterator_range(pclsObjs, pclsObjs+uReturn)) { imap vals; for (auto &s : keys) { VARIANT vtProp; CIMTYPE vtType; hr = pclsObj->Get(_bstr_t(boost::nowide::widen(s).c_str()), 0, &vtProp, &vtType, 0); if (FAILED(hr)) { LOG_DEBUG("query %1%.%2% could not be found", group, s); break; } wmi_add_result(vals, group, s, &vtProp); VariantClear(&vtProp); } pclsObj->Release(); array_of_vals.emplace_back(move(vals)); } } return array_of_vals; } string const& wmi::get(wmi::imap const& kvmap, string const& key) { static const string empty = {}; auto valIt = kvmap.find(key); if (valIt == kvmap.end()) { return empty; } else { if (kvmap.count(key) > 1) { LOG_DEBUG("only single value requested from array for key %1%", key); } return valIt->second; } } wmi::kv_range wmi::get_range(wmi::imap const& kvmap, string const& key) { return kv_range(kvmap.equal_range(key)); } string const& wmi::get(wmi::imaps const& kvmaps, string const& key) { if (kvmaps.size() > 0) { if (kvmaps.size() > 1) { LOG_DEBUG("only single entry requested from array of entries for key %1%", key); } return get(kvmaps[0], key); } else { throw wmi_exception("unable to get from empty array of objects"); } } wmi::kv_range wmi::get_range(wmi::imaps const& kvmaps, string const& key) { if (kvmaps.size() > 0) { if (kvmaps.size() > 1) { LOG_DEBUG("only single entry requested from array of entries for key %1%", key); } return get_range(kvmaps[0], key); } else { throw wmi_exception("unable to get_range from empty array of objects"); } } }}} // namespace facter::util::windows
; A163305: Numerators of fractions in the approximation of the square root of 5 satisfying: a(n)= (a(n-1)+ c)/(a(n-1)+1); with c=5 and a(1)=0. Also product of the powers of two and five times the Fibonacci numbers. ; Submitted by Jon Maiga ; 0,5,10,40,120,400,1280,4160,13440,43520,140800,455680,1474560,4771840,15441920,49971200,161710080,523304960,1693450240,5480120320,17734041600,57388564480,185713295360,600980848640,1944814878720,6293553152000,20366365818880,65906944245760,213279351767040,690186480517120,2233490368102400,7227726658273280,23389414788956160,75689736211005440,244937131577835520,792633207999692800,2565014942310727680,8300562716620226560,26861185202483363840,86924621271447633920,281293983352828723200 mov $3,1 lpb $0 sub $0,1 mov $2,$3 mul $2,5 add $3,$1 add $1,$2 lpe mov $0,$1
; A139612: 66n + 12. ; 12,78,144,210,276,342,408,474,540,606,672,738,804,870,936,1002,1068,1134,1200,1266,1332,1398,1464,1530,1596,1662,1728,1794,1860,1926,1992,2058,2124,2190,2256,2322,2388,2454,2520,2586,2652,2718,2784,2850,2916,2982,3048,3114,3180,3246,3312,3378,3444,3510,3576,3642,3708,3774,3840,3906,3972,4038,4104,4170,4236,4302,4368,4434,4500,4566,4632,4698,4764,4830,4896,4962,5028,5094,5160,5226,5292,5358,5424,5490,5556,5622,5688,5754,5820,5886,5952,6018,6084,6150,6216,6282,6348,6414,6480,6546,6612,6678,6744,6810,6876,6942,7008,7074,7140,7206,7272,7338,7404,7470,7536,7602,7668,7734,7800,7866,7932,7998,8064,8130,8196,8262,8328,8394,8460,8526,8592,8658,8724,8790,8856,8922,8988,9054,9120,9186,9252,9318,9384,9450,9516,9582,9648,9714,9780,9846,9912,9978,10044,10110,10176,10242,10308,10374,10440,10506,10572,10638,10704,10770,10836,10902,10968,11034,11100,11166,11232,11298,11364,11430,11496,11562,11628,11694,11760,11826,11892,11958,12024,12090,12156,12222,12288,12354,12420,12486,12552,12618,12684,12750,12816,12882,12948,13014,13080,13146,13212,13278,13344,13410,13476,13542,13608,13674,13740,13806,13872,13938,14004,14070,14136,14202,14268,14334,14400,14466,14532,14598,14664,14730,14796,14862,14928,14994,15060,15126,15192,15258,15324,15390,15456,15522,15588,15654,15720,15786,15852,15918,15984,16050,16116,16182,16248,16314,16380,16446 mov $1,$0 mul $1,66 add $1,12
TITLE "Spin Locks" ;++ ; ; Copyright (c) 1989-1998 Microsoft Corporation ; ; Module Name: ; ; spinlock.asm ; ; Abstract: ; ; This module implements x86 spinlock functions for the PC+MP HAL. ; ; Author: ; ; Bryan Willman (bryanwi) 13 Dec 89 ; ; Environment: ; ; Kernel mode only. ; ; Revision History: ; ; Ron Mosgrove (o-RonMo) Dec 93 - modified for PC+MP HAL. ;-- .486p include callconv.inc ; calling convention macros include i386\kimacro.inc include hal386.inc include mac386.inc include apic.inc include ntapic.inc EXTRNP _KeBugCheckEx,5,IMPORT EXTRNP KfRaiseIrql, 1,,FASTCALL EXTRNP KfLowerIrql, 1,,FASTCALL EXTRNP _KeSetEventBoostPriority, 2, IMPORT EXTRNP _KeWaitForSingleObject,5, IMPORT extrn _HalpVectorToIRQL:byte extrn _HalpIRQLtoTPR:byte ifdef NT_UP LOCK_ADD equ add LOCK_DEC equ dec LOCK_CMPXCHG equ cmpxchg else LOCK_ADD equ lock add LOCK_DEC equ lock dec LOCK_CMPXCHG equ lock cmpxchg endif _TEXT SEGMENT PARA PUBLIC 'CODE' ASSUME DS:FLAT, ES:FLAT, SS:FLAT, FS:NOTHING, GS:NOTHING SUBTTL "Acquire Kernel Spin Lock" ;++ ; ; KIRQL ; FASTCALL ; KfAcquireSpinLock ( ; IN PKSPIN_LOCK SpinLock ; ) ; ; Routine Description: ; ; This function raises to DISPATCH_LEVEL and acquires the specified ; spin lock. ; ; Arguments: ; ; SpinLock (ecx) - Supplies a pointer to a kernel spin lock. ; ; Return Value: ; ; The old IRQL is returned as the function value. ; ;-- align 16 cPublicFastCall KfAcquireSpinLock ,1 cPublicFpo 0,0 mov edx, dword ptr APIC[LU_TPR] ; get old IRQL vector mov dword ptr APIC[LU_TPR], DPC_VECTOR ; raise IRQL jmp short sls10 ; finish in common code fstENDP KfAcquireSpinLock SUBTTL "Acquire Kernel Spin Lock" ;++ ; ; KIRQL ; FASTCALL ; KeAcquireSpinLockRaiseToSynch ( ; IN PKSPIN_LOCK SpinLock ; ) ; ; Routine Description: ; ; This function raises to SYNCH_LEVEL and acquires the specified ; spin lock. ; ; Arguments: ; ; SpinLock (ecx) - Supplies a pointer to a kernel spin lock. ; ; Return Value: ; ; The old IRQL is returned as the function value. ; ;-- align 16 cPublicFastCall KeAcquireSpinLockRaiseToSynch,1 cPublicFpo 0,0 mov edx, dword ptr APIC[LU_TPR] ; get old vector mov dword ptr APIC[LU_TPR], APIC_SYNCH_VECTOR ; raise IRQL sls10: shr edx, 4 ; extract high 4 bits of vector movzx eax, _HalpVectorToIRQL[edx] ; translate TPR to old IRQL ifndef NT_UP ; ; Attempt to acquire the specified spin lock. ; sls20: ACQUIRE_SPINLOCK ecx, <short sls30> ; fstRET KeAcquireSpinLockRaiseToSynch ; ; Lock is owned - spin until it is free, then try again. ; sls30: SPIN_ON_SPINLOCK ecx, sls20 ; else fstRET KeAcquireSpinLockRaiseToSynch endif fstENDP KeAcquireSpinLockRaiseToSynch SUBTTL "KeAcquireSpinLockRaiseToSynchMCE" ;++ ; ; KIRQL ; FASTCALL ; KeAcquireSpinLockRaiseToSynchMCE ( ; IN PKSPIN_LOCK SpinLock ; ) ; ; Routine Description: ; ; This function performs the same function as KeAcquireSpinLockRaiseToSynch ; but provides a work around for an IFU errata for Pentium Pro processors ; prior to stepping 619. ; ; Arguments: ; ; (ecx) = SpinLock - Supplies a pointer to a kernel spin lock. ; ; Return Value: ; ; OldIrql (TOS+8) - pointer to place old irql. ; ;-- ifndef NT_UP align 16 cPublicFastCall KeAcquireSpinLockRaiseToSynchMCE,1 cPublicFpo 0,0 mov edx, dword ptr APIC[LU_TPR] ; (ecx) = Old Priority (Vector) mov eax, edx shr eax, 4 movzx eax, _HalpVectorToIRQL[eax] ; (al) = OldIrql ; ; Test lock ; ; TEST_SPINLOCK ecx,<short slm30> ; NOTE - Macro expanded below: test dword ptr [ecx], 1 nop ; On a P6 prior to stepping B1 (619), we nop ; need these 5 NOPs to ensure that we nop ; do not take a machine check exception. nop ; The cost is just 1.5 clocks as the P6 nop ; just tosses the NOPs. jnz short slm30 ; ; Raise irql. ; slm10: mov dword ptr APIC[LU_TPR], APIC_SYNCH_VECTOR ; ; Attempt to assert the lock ; ACQUIRE_SPINLOCK ecx,<short slm20> fstRET KeAcquireSpinLockRaiseToSynchMCE ; ; Lock is owned, spin till it looks free, then go get it ; align dword slm20: mov dword ptr APIC[LU_TPR], edx align dword slm30: SPIN_ON_SPINLOCK ecx,slm10 fstENDP KeAcquireSpinLockRaiseToSynchMCE endif SUBTTL "Release Kernel Spin Lock" ;++ ; ; VOID ; FASTCALL ; KeReleaseSpinLock ( ; IN PKSPIN_LOCK SpinLock, ; IN KIRQL OldIrql ; ) ; ; Routine Description: ; ; This function releases a spin lock and lowers to the old IRQL. ; ; Arguments: ; ; SpinLock (ecx) - Supplies a pointer to a spin lock. ; OldIrql (dl) - Supplies the old IRQL value. ; ; Return Value: ; ; None. ; ;-- align 16 cPublicFastCall KfReleaseSpinLock ,2 cPublicFpo 0,0 movzx eax, dl ; zero extend old IRQL ifndef NT_UP RELEASE_SPINLOCK ecx ; release spin lock endif ; ; Lower IRQL to its previous level. ; ; N.B. Ensure that the requested priority is set before returning. ; movzx ecx, _HalpIRQLtoTPR[eax] ; translate IRQL to TPR value mov dword ptr APIC[LU_TPR], ecx ; lower to old IRQL mov eax, dword ptr APIC[LU_TPR] ; synchronize fstRET KfReleaseSpinLock fstENDP KfReleaseSpinLock SUBTTL "Acquire Lock With Interrupts Disabled" ;++ ; ; ULONG ; FASTCALL ; HalpAcquireHighLevelLock ( ; IN PKSPIN_LOCK SpinLock ; ) ; ; Routine Description: ; ; This function disables interrupts and acquires a spinlock. ; ; Arguments: ; ; SpinLock (ecx) - Supplies a pointer to a spin lock. ; ; Return Value: ; ; The old EFLAGS are returned as the function value. ; ;-- align 16 cPublicFastCall HalpAcquireHighLevelLock, 1 pushfd ; save EFLAGS pop eax ; ahll10: cli ; disable interrupts ACQUIRE_SPINLOCK ecx, ahll20 ; attempt to acquire spin lock fstRET HalpAcquireHighLevelLock ahll20: push eax ; restore EFLAGS popfd ; SPIN_ON_SPINLOCK ecx, <ahll10> ; wait for lock to be free fstENDP HalpAcquireHighLevelLock SUBTTL "Release Lock And Enable Interrupts" ;++ ; ; VOID ; FASTCALL ; HalpReleaseHighLevelLock ( ; IN PKSPIN_LOCK SpinLock, ; IN ULONG Eflags ; ) ; ; Routine Description: ; ; This function releases a kernel spin lock and restores the old EFLAGS. ; ; Arguments: ; ; SpinLock (ecx) - Supplies a pointer to a spin lock. ; Eflags (edx) - supplies the old EFLAGS value. ; ; Return Value: ; ; None. ; ;-- align 16 cPublicFastCall HalpReleaseHighLevelLock, 2 RELEASE_SPINLOCK ecx ; release spin lock push edx ; restore old EFLAGS popfd ; fstRET HalpReleaseHighLevelLock fstENDP HalpReleaseHighLevelLock SUBTTL "Acquire Fast Mutex" ;++ ; ; VOID ; FASTCALL ; ExAcquireFastMutex ( ; IN PFAST_MUTEX FastMutex ; ) ; ; Routine description: ; ; This function acquires ownership of the specified FastMutex. ; ; Arguments: ; ; (ecx) = FastMutex - Supplies a pointer to the fast mutex. ; ; Return Value: ; ; None. ; ;-- align 16 cPublicFastCall ExAcquireFastMutex,1 cPublicFpo 0,0 mov eax, dword ptr APIC[LU_TPR] ; (eax) = Old Priority (Vector) if DBG ; ; Caller must already be at or below APC_LEVEL. ; cmp eax, APC_VECTOR jg short afm11 ; irql too high ==> fatal. endif mov dword ptr APIC[LU_TPR], APC_VECTOR ; Write New Priority to the TPR LOCK_DEC dword ptr [ecx].FmCount ; Get count jnz short afm10 ; Not the owner so go wait. mov dword ptr [ecx].FmOldIrql, eax ; ; Use esp to track the owning thread for debugging purposes. ; !thread from kd will find the owning thread. Note that the ; owner isn't cleared on release, check if the mutex is owned ; first. ; mov dword ptr [ecx].FmOwner, esp fstRet ExAcquireFastMutex cPublicFpo 0,0 afm10: inc dword ptr [ecx].FmContention cPublicFpo 0,2 push ecx push eax add ecx, FmEvent ; Wait on Event stdCall _KeWaitForSingleObject,<ecx,WrExecutive,0,0,0> pop eax ; (al) = OldTpr pop ecx ; (ecx) = FAST_MUTEX mov dword ptr [ecx].FmOldIrql, eax ; ; Use esp to track the owning thread for debugging purposes. ; !thread from kd will find the owning thread. Note that the ; owner isn't cleared on release, check if the mutex is owned ; first. ; mov dword ptr [ecx].FmOwner, esp fstRet ExAcquireFastMutex if DBG cPublicFpo 0,1 afm11: stdCall _KeBugCheckEx,<IRQL_NOT_GREATER_OR_EQUAL,ecx,eax,033h,0> endif fstENDP ExAcquireFastMutex SUBTTL "Release Fast Mutex" ;++ ; ; VOID ; FASTCALL ; ExReleaseFastMutex ( ; IN PFAST_MUTEX FastMutex ; ) ; ; Routine description: ; ; This function releases ownership of the FastMutex. ; ; Arguments: ; ; (ecx) = FastMutex - Supplies a pointer to the fast mutex. ; ; Return Value: ; ; None. ; ;-- align 16 cPublicFastCall ExReleaseFastMutex,1 cPublicFpo 0,0 if DBG ; ; Caller must already be at APC_LEVEL or have APCs blocked. ; mov eax, dword ptr APIC[LU_TPR] ; (eax) = Old Priority (Vector) cmp eax, APC_VECTOR je short rfm04 ; irql is ok. cPublicFpo 0,1 stdCall _KeBugCheckEx,<IRQL_NOT_GREATER_OR_EQUAL,ecx,eax,034h,0> rfm04: endif mov eax, dword ptr [ecx].FmOldIrql ; (eax) = OldTpr LOCK_ADD dword ptr [ecx].FmCount, 1 ; Remove our count jle short rfm05 ; if <= 0, set event cPublicFpo 0,0 mov dword ptr APIC[LU_TPR], eax mov ecx, dword ptr APIC[LU_TPR] if DBG cmp eax, ecx ; Verify TPR is what was je short @f ; written int 3 @@: endif fstRet ExReleaseFastMutex cPublicFpo 0,1 rfm05: add ecx, FmEvent push eax ; save new tpr stdCall _KeSetEventBoostPriority, <ecx, 0> pop eax ; restore tpr cPublicFpo 0,0 mov dword ptr APIC[LU_TPR], eax mov ecx, dword ptr APIC[LU_TPR] if DBG cmp eax, ecx ; Verify TPR is what was je short @f ; written int 3 @@: endif fstRet ExReleaseFastMutex if DBG endif fstENDP ExReleaseFastMutex SUBTTL "Try To Acquire Fast Mutex" ;++ ; ; BOOLEAN ; FASTCALL ; ExTryToAcquireFastMutex ( ; IN PFAST_MUTEX FastMutex ; ) ; ; Routine description: ; ; This function acquires ownership of the FastMutex. ; ; Arguments: ; ; (ecx) = FastMutex - Supplies a pointer to the fast mutex. ; ; Return Value: ; ; Returns TRUE if the FAST_MUTEX was acquired; otherwise FALSE. ; ;-- align 16 cPublicFastCall ExTryToAcquireFastMutex,1 cPublicFpo 0,0 if DBG ; ; Caller must already be at or below APC_LEVEL. ; mov eax, dword ptr APIC[LU_TPR] ; (eax) = Old Priority (Vector) cmp eax, APC_VECTOR jg short tam11 ; irql too high ==> fatal. endif ; ; Try to acquire. ; push dword ptr APIC[LU_TPR] ; Save Old Priority (Vector) mov dword ptr APIC[LU_TPR], APC_VECTOR ; Write New Priority to the TPR mov edx, 0 ; Value to set mov eax, 1 ; Value to compare against LOCK_CMPXCHG dword ptr [ecx].FmCount, edx ; Attempt to acquire jnz short tam20 ; got it? cPublicFpo 0,0 mov eax, 1 ; return TRUE pop dword ptr [ecx].FmOldIrql ; Store Old TPR ; ; Use esp to track the owning thread for debugging purposes. ; !thread from kd will find the owning thread. Note that the ; owner isn't cleared on release, check if the mutex is owned ; first. ; mov dword ptr [ecx].FmOwner, esp fstRet ExTryToAcquireFastMutex tam20: pop ecx ; (ecx) = Old TPR mov dword ptr APIC[LU_TPR], ecx mov eax, dword ptr APIC[LU_TPR] if DBG cmp ecx, eax ; Verify TPR is what was je short @f ; written int 3 @@: endif xor eax, eax ; return FALSE YIELD fstRet ExTryToAcquireFastMutex ; all done if DBG cPublicFpo 0,1 tam11: stdCall _KeBugCheckEx,<IRQL_NOT_GREATER_OR_EQUAL,ecx,eax,033h,0> endif fstENDP ExTryToAcquireFastMutex SUBTTL "Acquire In Stack Queued SpinLock" ;++ ; ; VOID ; FASTCALL ; KeAcquireInStackQueuedSpinLock ( ; IN PKSPIN_LOCK SpinLock, ; IN PKLOCK_QUEUE_HANDLE LockHandle ; ) ; ; VOID ; FASTCALL ; KeAcquireInStackQueuedSpinLockRaiseToSynch ( ; IN PKSPIN_LOCK SpinLock, ; IN PKLOCK_QUEUE_HANDLE LockHandle ; ) ; ; Routine Description: ; ; These functions raise IRQL and acquire an in-stack queued spin lock. ; ; Arguments: ; ; SpinLock (ecx) - Supplies a pointer to a spin lock. ; LockHandle (edx) - supplies a pointer to a lock context. ; ; Return Value: ; ; None. ; ;-- align 16 cPublicFastCall KeAcquireInStackQueuedSpinLock, 2 cPublicFpo 0,0 mov eax, dword ptr APIC[LU_TPR] ; get old IRQL vector mov dword ptr APIC[LU_TPR], DPC_VECTOR ; raise IRQL jmp short iqsl10 ; finish in common code fstENDP KeAcquireInStackQueuedSpinLock align 16 cPublicFastCall KeAcquireInStackQueuedSpinLockRaiseToSynch, 2 cPublicFpo 0,0 mov eax, dword ptr APIC[LU_TPR] ; get old IRQL vector mov dword ptr APIC[LU_TPR], APIC_SYNCH_VECTOR ; raise IRQL iqsl10: shr eax, 4 ; extract high 4 bits of vector mov al, _HalpVectorToIRQL[eax] ; translate to old IRQL mov [edx].LqhOldIrql, al ; save old IRQL in lock context ; ; Set spin lock address in lock context and clear next queue link. ; ifndef NT_UP mov [edx].LqhLock, ecx ; set spin lock address and dword ptr [edx].LqhNext, 0 ; clear next link ifdef CAPKERN_SYNCH_POINTS push ecx ; lock address push 000010101h ; 1 Dword, Timestamp, Subcode = 1 call _CAP_Log_NInt ; add esp, 8 ; endif ; ; Exchange the value of the lock with the address of the lock context. ; mov eax, edx ; save lock context address xchg [ecx], edx ; exchange lock context address cmp edx, 0 ; check if lock is already held jnz short iqsl30 ; if nz, lock already held ; ; N.B. The spin lock address is dword aligned and the bottom two bits are ; used as indicators. ; ; Bit 0 is LOCK_QUEUE_WAIT. ; Bit 1 is LOCK_QUEUE_OWNER. ; or [eax].LqLock, LOCK_QUEUE_OWNER ; set lock owner endif iqsl20: fstRET KeAcquireInStackQueuedSpinLockRaiseToSynch ; ; The lock is already held by another processor. Set the wait bit in the ; lock context, then set the next field in the lock context of the last ; waiter in the lock queue. ; ifndef NT_UP iqsl30: or [eax].LqLock, LOCK_QUEUE_WAIT ; set lock wait mov [edx].LqNext, eax ; set next entry in previous last ifdef CAPKERN_SYNCH_POINTS xor edx, edx ; clear wait counter iqsl40: inc edx ; count wait time test [eax].LqLock, LOCK_QUEUE_WAIT ; check if lock ownership granted jz short iqsl50 ; if z, lock owner granted YIELD ; yield to other SMT processors jmp short iqsl40 ; iqsl50: push ecx ; lock address push edx ; wait counter push 000020104h ; 2 Dwords, Timestamp, Subcode = 4 call _CAP_Log_NInt ; add esp, 12 ; fstRET KeAcquireInStackQueuedSpinLockRaiseToSynch else iqsl40: test [eax].LqLock, LOCK_QUEUE_WAIT ; check if lock ownership granted jz short iqsl20 ; if z, lock ownership granted YIELD ; yield to other SMT processors jmp short iqsl40 ; endif endif fstENDP KeAcquireInStackQueuedSpinLockRaiseToSynch SUBTTL "Acquire Queued Spin Lock" ;++ ; ; KIRQL ; FASTCALL ; KeAcquireQueuedSpinLock ( ; IN KSPIN_LOCK_QUEUE_NUMBER Number ; ) ; ; KIRQL ; FASTCALL ; KeAcquireQueuedSpinLockRaiseToSynch ( ; IN KSPIN_LOCK_QUEUE_NUMBER Number ; ) ; ; Routine Description: ; ; These function raise IRQL and acquire a processor specific queued spin ; lock. ; ; Arguments: ; ; Number (ecx) - Supplies the queued spinlock number. ; ; Return Value: ; ; The old IRQL is returned as the function value. ; ;-- .errnz (LOCK_QUEUE_HEADER_SIZE - 8) align 16 cPublicFastCall KeAcquireQueuedSpinLock, 1 cPublicFpo 0,0 mov eax, dword ptr APIC[LU_TPR] ; get old IRQL vector mov dword ptr APIC[LU_TPR], DPC_VECTOR ; raise IRQL jmp short aqsl10 ; finish in common code fstENDP KeAcquireQueuedSpinLock align 16 cPublicFastCall KeAcquireQueuedSpinLockRaiseToSynch, 1 cPublicFpo 0,0 mov eax, dword ptr APIC[LU_TPR] ; get old IRQL vector mov dword ptr APIC[LU_TPR], APIC_SYNCH_VECTOR ; raise IRQL aqsl10: shr eax, 4 ; extract high 4 bits of vector movzx eax, byte ptr _HalpVectorToIRQL[eax] ; translate to old IRQL ; ; Get address of per processor lock queue entry. ; ifndef NT_UP mov edx, PCR[PcPrcb] ; get address of PRCB lea edx, [edx+ecx*8].PbLockQueue ; get lock queue address mov ecx, [edx].LqLock ; get spin lock address ifdef CAPKERN_SYNCH_POINTS push ecx ; lock address push 000010101h ; 1 Dword, Timestamp, Subcode = 1 call _CAP_Log_NInt ; add esp, 8 ; endif push eax ; save old IRQL cPublicFpo 0,1 if DBG test ecx, LOCK_QUEUE_OWNER + LOCK_QUEUE_WAIT ; inconsistent state? jnz short aqsl60 ; if nz, inconsistent state endif ; ; Exchange the value of the lock with the address of the lock context. ; mov eax, edx ; save lock queue entry address xchg [ecx], edx ; exchange lock queue address cmp edx, 0 ; check if lock is already held jnz short aqsl30 ; if nz, lock already held ; ; N.B. The spin lock address is dword aligned and the bottom two bits are ; used as indicators. ; ; Bit 0 is LOCK_QUEUE_WAIT. ; Bit 1 is LOCK_QUEUE_OWNER. ; or [eax].LqLock, LOCK_QUEUE_OWNER ; set lock owner aqsl20: pop eax ; restore old IRQL cPublicFpo 0,0 endif fstRET KeAcquireQueuedSpinLockRaiseToSynch ; ; The lock is already held by another processor. Set the wait bit in the ; lock context, then set the next field in the lock context of the last ; waiter in the lock queue. ; ifndef NT_UP cPublicFpo 0,1 aqsl30: or [eax].LqLock, LOCK_QUEUE_WAIT ; set lock wait mov [edx].LqNext, eax ; set next entry in previous last ifdef CAPKERN_SYNCH_POINTS xor edx, edx ; clear wait counter aqsl40: inc edx ; count wait time test [eax].LqLock, LOCK_QUEUE_WAIT ; check if lock ownership granted jz short aqsl50 ; if z, lock owner granted YIELD ; yield to other SMT processors jmp short aqsl40 ; aqsl50: push ecx ; lock address push edx ; wait counter push 000020104h ; 2 Dwords, Timestamp, Subcode = 4 call _CAP_Log_NInt ; add esp, 12 ; jmp short aqsl20 ; else aqsl40: test [eax].LqLock, LOCK_QUEUE_WAIT ; check if lock ownership granted jz short aqsl20 ; if z, lock owner granted YIELD ; yield to other SMT processors jmp short aqsl40 ; endif ; ; Inconsistent state in lock queue entry. ; if DBG cPublicFpo 0,1 aqsl60: stdCall _KeBugCheckEx,<SPIN_LOCK_ALREADY_OWNED, ecx, edx, 0, 0> int 3 ; so stacktrace works endif endif fstENDP KeAcquireQueuedSpinLockRaiseToSynch SUBTTL "Release Queued SpinLock" ;++ ; ; VOID ; FASTCALL ; KeReleaseQueuedSpinLock ( ; IN KSPIN_LOCK_QUEUE_NUMBER Number, ; IN KIRQL OldIrql ; ) ; ; Arguments: ; ; Number (ecx) - Supplies the queued spinlock number. ; ; OldIrql (dl) - Supplies the old IRQL. ; ; VOID ; KeReleaseInStackQueuedSpinLock ( ; IN PKLOCK_QUEUE_HANDLE LockHandle ; ) ; ; Arguments: ; ; LockHandle (ecx) - Address of Lock Queue Handle structure. ; ; Routine Description: ; ; These functions release a queued spinlock and lower IRQL to the old ; value. ; ; Return Value: ; ; None. ; ;-- .errnz (LqhNext) .errnz (LOCK_QUEUE_OWNER - 2) align 16 cPublicFastCall KeReleaseInStackQueuedSpinLock, 1 cPublicFpo 0,0 mov dl, byte ptr [ecx].LqhOldIrql ; set old IRQL mov eax, ecx ; set lock queue entry address jmp short rqsl10 ; finish in common code fstENDP KeReleaseInStackQueuedSpinLock align 16 cPublicFastCall KeReleaseQueuedSpinLock, 2 cPublicFpo 0,0 ifndef NT_UP mov eax, PCR[PcPrcb] ; get address of PRCB lea eax, [eax+ecx*8].PbLockQueue ; set lock queue entry address endif rqsl10: movzx edx, dl ; zero extend old IRQL ifndef NT_UP push ebx ; save nonvolatile register cPublicFpo 0,1 mov ebx, [eax].LqNext ; get next entry address mov ecx, [eax].LqLock ; get spin lock home address ifdef CAPKERN_SYNCH_POINTS push ecx ; lock address push 000010107h ; 1 Dword, Timestamp, Subcode = 7 call _CAP_Log_NInt ; add esp, 8 ; endif ; ; Make sure we own the lock and clear the bit ; if DBG btr ecx, 1 ; clear lock owner bit jnc short rqsl80 ; if nc, owner not set cmp dword ptr [ecx], 0 ; lock must be owned for a release jz short rqsl80 else and ecx, NOT LOCK_QUEUE_OWNER ; Clear out the owner bit endif ; ; Test if lock waiter present. ; test ebx, ebx ; test if lock waiter present mov [eax].LqLock, ecx ; clear lock owner bit jnz short rqsl40 ; if nz, lock waiter present ; ; Attempt to release queued spin lock. ; push eax ; save lock queue entry address lock cmpxchg [ecx], ebx ; release spin lock if no waiter pop eax ; restore lock queue entry address jnz short rqsl50 ; if nz, lock waiter present rqs120: pop ebx ; restore nonvolatile register cPublicFpo 0,0 endif ; ; Lower IRQL to its previous level. ; ; N.B. Ensure that the requested priority is set before returning. ; rqsl30: movzx ecx, byte ptr _HalpIRQLtoTPR[edx] ; translate IRQL to TPR value mov dword ptr APIC[LU_TPR], ecx ; lower to old IRQL mov eax, dword ptr APIC[LU_TPR] ; synchronize fstRET KeReleaseQueuedSpinLock ; ; Lock waiter is present. ; ; Clear wait bit and set owner bit in next owner lock queue entry. ; ifndef NT_UP cPublicFpo 0,1 rqsl40: xor [ebx].LqLock, (LOCK_QUEUE_OWNER+LOCK_QUEUE_WAIT) ; set bits and [eax].LqNext, 0 ; clear next waiter address jmp short rqs120 ; ; ; Another processor is attempting to acquire the spin lock. ; ifdef CAPKERN_SYNCH_POINTS rqsl50: push ecx ; lock address (for CAP_Log) xor ecx, ecx ; clear wait counter rqsl60: inc ecx ; increment wait counter mov ebx, [eax].LqNext ; get address of next entry test ebx, ebx ; check if waiter present jnz short rqsl70 ; if nz, waiter is present YIELD ; yield to other SMT processors jmp short rqsl60 ; rqsl70: push ecx ; wait counter push 000020104h ; 2 Dwords, Timestamp, Subcode = 4 call _CAP_Log_NInt ; add esp, 12 ; jmp short rqsl40 ; else rqsl50: mov ebx, [eax].LqNext ; get address of next entry test ebx, ebx ; check if waiter present jnz short rqsl40 ; if nz, waiter is present YIELD ; yield to other SMT processors jmp short rqsl50 ; endif ; ; Inconsistent state in lock queue entry. ; if DBG cPublicFpo 0,1 rqsl80: stdCall _KeBugCheckEx, <SPIN_LOCK_NOT_OWNED, ecx, eax, 0, 1> int 3 ; so stacktrace works endif endif fstENDP KeReleaseQueuedSpinLock SUBTTL "Try to Acquire Queued SpinLock" ;++ ; ; LOGICAL ; KeTryToAcquireQueuedSpinLock ( ; IN KSPIN_LOCK_QUEUE_NUMBER Number, ; OUT PKIRQL OldIrql ; ) ; ; LOGICAL ; KeTryToAcquireQueuedSpinLockRaiseToSynch ( ; IN KSPIN_LOCK_QUEUE_NUMBER Number, ; OUT PKIRQL OldIrql ; ) ; ; Routine Description: ; ; This function raises the current IRQL to DISPATCH/SYNCH level ; and attempts to acquire the specified queued spinlock. If the ; spinlock is already owned by another thread, IRQL is restored ; to its previous value and FALSE is returned. ; ; Arguments: ; ; Number (ecx) - Supplies the queued spinlock number. ; OldIrql (edx) - A pointer to the variable to receive the old ; IRQL. ; ; Return Value: ; ; TRUE if the lock was acquired, FALSE otherwise. ; N.B. ZF is set if FALSE returned, clear otherwise. ; ;-- align 16 cPublicFastCall KeTryToAcquireQueuedSpinLockRaiseToSynch,2 cPublicFpo 0,0 push APIC_SYNCH_VECTOR ; raise to SYNCH jmp short taqsl10 ; continue in common code fstENDP KeTryToAcquireQueuedSpinLockRaiseToSynch cPublicFastCall KeTryToAcquireQueuedSpinLock,2 cPublicFpo 0,0 push DPC_VECTOR ; raise to DPC level ; Attempt to get the lock with interrupts disabled, raising ; the priority in the interrupt controller only if acquisition ; is successful. taqsl10: ifndef NT_UP push edx ; save address of OldIrql pushfd ; save interrupt state cPublicFpo 0,3 ; Get address of Lock Queue entry cli mov edx, PCR[PcPrcb] ; get address of PRCB lea edx, [edx+ecx*8].PbLockQueue ; get &PRCB->LockQueue[Number] ; Get address of the actual lock. mov ecx, [edx].LqLock ifdef CAPKERN_SYNCH_POINTS push ecx ; lock address push 000010108h ; 1 Dword, Timestamp, Subcode = 8 call _CAP_Log_NInt add esp, 8 endif if DBG test ecx, LOCK_QUEUE_OWNER+LOCK_QUEUE_WAIT jnz short taqsl98 ; jiff lock already held (or ; this proc already waiting). endif ; quick test, get out if already taken cmp dword ptr [ecx], 0 ; check if already taken jnz short taqsl60 ; jif already taken xor eax, eax ; comparison value (not locked) ; Store the Lock Queue entry address in the lock ONLY if the ; current lock value is 0. lock cmpxchg [ecx], edx jnz short taqsl60 ; Lock has been acquired. ; note: the actual lock address will be word aligned, we use ; the bottom two bits as indicators, bit 0 is LOCK_QUEUE_WAIT, ; bit 1 is LOCK_QUEUE_OWNER. or ecx, LOCK_QUEUE_OWNER ; mark self as lock owner mov [edx].LqLock, ecx mov eax, [esp+8] ; get new IRQL mov edx, [esp+4] ; get addr to save OldIrql else mov eax, [esp] ; get new IRQL endif ; Raise IRQL and return success. ; Get old priority (vector) from Local APIC's Task Priority ; Register and set the new priority. mov ecx, dword ptr APIC[LU_TPR] ; (ecx) = Old Priority mov dword ptr APIC[LU_TPR], eax ; Set New Priority ifndef NT_UP popfd ; restore interrupt state add esp, 8 ; free locals else add esp, 4 ; free local endif cPublicFpo 0,0 shr ecx, 4 movzx eax, _HalpVectorToIRQL[ecx] ; (al) = OldIrql mov [edx], al ; save OldIrql xor eax, eax ; return TRUE or eax, 1 fstRET KeTryToAcquireQueuedSpinLock ifndef NT_UP taqsl60: ; The lock is already held by another processor. Indicate ; failure to the caller. popfd ; restore interrupt state add esp, 8 ; free locals xor eax, eax ; return FALSE fstRET KeTryToAcquireQueuedSpinLock if DBG cPublicFpo 0,2 taqsl98: stdCall _KeBugCheckEx,<SPIN_LOCK_ALREADY_OWNED,ecx,edx,0,0> int 3 ; so stacktrace works endif endif fstENDP KeTryToAcquireQueuedSpinLock _TEXT ends end
/** * @author : archit * @GitHub : archit-1997 * @email : architsingh456@gmail.com * @file : sortedArrayToHeightBalancedBST.cpp * @created : Thursday Jul 29, 2021 10:26:02 IST */ #include <bits/stdc++.h> using namespace std; void init(){ freopen("input.txt","r",stdin); freopen("output.txt","w",stdout); } // Definition for a binary tree node. struct TreeNode { int val; TreeNode *left; TreeNode *right; TreeNode() : val(0), left(nullptr), right(nullptr) {} TreeNode(int x) : val(x), left(nullptr), right(nullptr) {} TreeNode(int x, TreeNode *left, TreeNode *right) : val(x), left(left), right(right) {} }; class Solution { public: TreeNode* constructTree(TreeNode* root,vector<int> &nums,int low,int high){ if(low>high) return NULL; int mid=low+(high-low)/2; TreeNode* newNode = new TreeNode(nums[mid]); //populate the left and right part newNode->left=constructTree(root,nums,low,mid-1); newNode->right=constructTree(root,nums,mid+1,high); return newNode; } TreeNode* sortedArrayToBST(vector<int>& nums) { int n=nums.size(); int mid=n/2; TreeNode* root=new TreeNode(nums[mid]); root->left=constructTree(root,nums,0,mid-1); root->right=constructTree(root,nums,mid+1,n-1); return root; } };
/* * full_chain_test.cc * EDMProto * * Created by Chris Jones on 4/3/05. * Changed by Viji Sundararajan on 29-Jun-05. * */ #include <iostream> #include "FWCore/Framework/interface/EventSetup.h" #include "FWCore/Framework/interface/EventSetupProvider.h" #include "FWCore/Framework/interface/IOVSyncValue.h" #include "FWCore/Framework/interface/HCMethods.h" #include "FWCore/Framework/interface/ESHandle.h" #include "FWCore/Framework/test/DummyRecord.h" #include "FWCore/Framework/test/DummyData.h" #include "FWCore/Framework/test/DummyFinder.h" #include "FWCore/Framework/test/DummyProxyProvider.h" #include "FWCore/ServiceRegistry/interface/ActivityRegistry.h" #include "cppunit/extensions/HelperMacros.h" using namespace edm; using namespace edm::eventsetup; using namespace edm::eventsetup::test; namespace { edm::ActivityRegistry activityRegistry; } class testfullChain : public CppUnit::TestFixture { CPPUNIT_TEST_SUITE(testfullChain); CPPUNIT_TEST(getfromDataproxyproviderTest); CPPUNIT_TEST_SUITE_END(); public: void setUp() {} void tearDown() {} void getfromDataproxyproviderTest(); }; ///registration of the test so that the runner can find it CPPUNIT_TEST_SUITE_REGISTRATION(testfullChain); void testfullChain::getfromDataproxyproviderTest() { eventsetup::EventSetupProvider provider(&activityRegistry); std::shared_ptr<DataProxyProvider> pProxyProv = std::make_shared<DummyProxyProvider>(); provider.add(pProxyProv); std::shared_ptr<DummyFinder> pFinder = std::make_shared<DummyFinder>(); provider.add(std::shared_ptr<EventSetupRecordIntervalFinder>(pFinder)); const Timestamp time_1(1); const IOVSyncValue sync_1(time_1); pFinder->setInterval(ValidityInterval(sync_1, IOVSyncValue(Timestamp(5)))); for (unsigned int iTime = 1; iTime != 6; ++iTime) { const Timestamp time(iTime); EventSetup const eventSetup{provider.eventSetupForInstance(IOVSyncValue(time)), 0, nullptr}; ESHandle<DummyData> pDummy; eventSetup.get<DummyRecord>().get(pDummy); CPPUNIT_ASSERT(0 != pDummy.product()); eventSetup.getData(pDummy); CPPUNIT_ASSERT(0 != pDummy.product()); } }
; A079635: Sum of (2 - p mod 4) for all prime factors p of n (with repetition). ; Submitted by Christian Krause ; 0,0,-1,0,1,-1,-1,0,-2,1,-1,-1,1,-1,0,0,1,-2,-1,1,-2,-1,-1,-1,2,1,-3,-1,1,0,-1,0,-2,1,0,-2,1,-1,0,1,1,-2,-1,-1,-1,-1,-1,-1,-2,2,0,1,1,-3,0,-1,-2,1,-1,0,1,-1,-3,0,2,-2,-1,1,-2,0,-1,-2,1,1,1,-1,-2,0,-1,1,-4,1,-1,-2,2,-1,0,-1,1,-1,0,-1,-2,-1,0,-1,1,-2,-3,2 add $0,1 lpb $0 mov $3,$0 lpb $3 mov $4,$0 mov $6,$2 cmp $6,0 add $2,$6 mod $4,$2 cmp $4,0 cmp $4,0 mov $5,$2 add $2,2 cmp $5,1 max $4,$5 sub $3,$4 lpe mov $3,$2 add $3,1 lpb $0 dif $0,$2 sub $2,2 lpe lpb $3 mod $3,4 add $7,$3 sub $7,$4 lpe lpe mov $0,$7