text stringlengths 1 1.05M |
|---|
; A176434: Decimal expansion of (7+3*sqrt(7))/2.
; Submitted by Christian Krause
; 7,4,6,8,6,2,6,9,6,6,5,9,6,8,8,5,8,8,5,7,5,2,4,2,3,6,3,0,4,5,8,8,9,0,6,3,8,5,6,5,3,8,8,7,7,4,6,2,3,6,7,5,2,7,0,5,5,2,5,0,1,6,8,8,8,0,1,6,0,3,2,3,4,8,4,5,4,2,5,4,4,1,6,4,0,5,8,9,3,2,9,7,1,1,8,1,5,4,1,5
mov $2,1
mov $3,$0
mul $3,4
lpb $3
add $5,$2
mul $5,2
add $5,$2
add $1,$5
add $2,$1
mov $1,35
sub $3,1
lpe
sub $5,1
mul $5,3
add $1,$5
mov $4,10
pow $4,$0
div $2,$4
div $1,$2
mov $0,$1
add $0,10
mod $0,10
|
#include "CommBatteryEventOpcUa.hh"
#define SERONET_NO_DEPRECATED
#include <SeRoNetSDK/SeRoNet/CommunicationObjects/Description/ComplexType.hpp>
#include <SeRoNetSDK/SeRoNet/CommunicationObjects/Description/ElementPrimitives.hpp>
#include <SeRoNetSDK/SeRoNet/CommunicationObjects/Description/SelfDescriptionArray.hpp>
#include <SeRoNetSDK/SeRoNet/CommunicationObjects/Description/ElementArray.hpp>
namespace SeRoNet {
namespace CommunicationObjects {
namespace Description {
// serialization for CommBasicObjectsIDL::CommBatteryEvent
template <>
IDescription::shp_t SelfDescription(CommBasicObjectsIDL::CommBatteryEvent *obj, std::string name)
{
auto ret = std::make_shared<SeRoNet::CommunicationObjects::Description::ComplexType>(name);
// add chargeValue
ret->add(
SelfDescription(&(obj->chargeValue), "ChargeValue")
);
// add state
ret->add(
SelfDescription(&(obj->state), "State")
);
return ret;
} // end SelfDescription
} // end namespace Description
} // end namespace CommunicationObjects
} // end namespace SeRoNet
|
/*
* Copyright 2015-2016 Tomas Mikalauskas. All rights reserved.
* GitHub repository - https://github.com/TywyllSoftware/TywRenderer
* This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
*/
#include <RendererPch\stdafx.h>
#include <iomanip>
//Triangle Includes
#include "Main.h"
#include <conio.h>
//Renderer Includes
#include <Renderer\VKRenderer.h>
#include <Renderer\Vulkan\VulkanTools.h>
#include <Renderer\Vulkan\VulkanTextureLoader.h>
//Model Loader Includes
#include <Renderer\MeshLoader\Model_local.h>
#include <Renderer\MeshLoader\ImageManager.h>
#include <Renderer\MeshLoader\Material.h>
//Vulkan Includes
#include <Renderer\Vulkan\VkBufferObject.h>
#include <Renderer\Vulkan\VulkanSwapChain.h>
//Font Rendering
#include <Renderer\ThirdParty\FreeType\VkFont.h>
//math
#include <External\glm\glm\gtc\matrix_inverse.hpp>
//Global variables
//====================================================================================
uint32_t g_iDesktopWidth = 0;
uint32_t g_iDesktopHeight = 0;
bool g_bPrepared = false;
glm::vec3 g_Rotation = glm::vec3();
glm::vec3 g_CameraPos = glm::vec3();
glm::vec2 g_MousePos;
// Use to adjust mouse rotation speed
float g_RotationSpeed = 1.0f;
// Use to adjust mouse zoom speed
float g_ZoomSpeed = 1.0f;
float g_zoom = 1.0f;
VkClearColorValue g_DefaultClearColor = { { 0.5f, 0.5f, 0.5f, 1.0f } };
#define VERTEX_BUFFER_BIND_ID 0
// Set to "true" to enable Vulkan's validation layers
// See vulkandebug.cpp for details
#define ENABLE_VALIDATION false
// Set to "true" to use staging buffers for uploading
// vertex and index data to device local memory
// See "prepareVertices" for details on what's staging
// and on why to use it
#define USE_STAGING true
#define GAMEPAD_BUTTON_A 0x1000
#define GAMEPAD_BUTTON_B 0x1001
#define GAMEPAD_BUTTON_X 0x1002
#define GAMEPAD_BUTTON_Y 0x1003
#define GAMEPAD_BUTTON_L1 0x1004
#define GAMEPAD_BUTTON_R1 0x1005
#define GAMEPAD_BUTTON_START 0x1006
//====================================================================================
//functions
//====================================================================================
bool GenerateEvents(MSG& msg);
void WIN_Sizing(WORD side, RECT *rect);
LRESULT CALLBACK HandleWindowMessages(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
//====================================================================================
class Renderer final: public VKRenderer
{
private:
// The pipeline (state objects) is a static store for the 3D pipeline states (including shaders)
// Other than OpenGL this makes you setup the render states up-front
// If different render states are required you need to setup multiple pipelines
// and switch between them
// Note that there are a few dynamic states (scissor, viewport, line width) that
// can be set from a command buffer and does not have to be part of the pipeline
// This basic example only uses one pipeline
VkPipeline pipeline;
// The pipeline layout defines the resource binding slots to be used with a pipeline
// This includes bindings for buffes (ubos, ssbos), images and sampler
// A pipeline layout can be used for multiple pipeline (state objects) as long as
// their shaders use the same binding layout
VkPipelineLayout pipelineLayout;
// The descriptor set stores the resources bound to the binding points in a shader
// It connects the binding points of the different shaders with the buffers and images
// used for those bindings
VkDescriptorSet descriptorSet;
// The descriptor set layout describes the shader binding points without referencing
// the actual buffers.
// Like the pipeline layout it's pretty much a blueprint and can be used with
// different descriptor sets as long as the binding points (and shaders) match
VkDescriptorSetLayout descriptorSetLayout;
// Synchronization semaphores
// Semaphores are used to synchronize dependencies between command buffers
// We use them to ensure that we e.g. don't present to the swap chain
// until all rendering has completed
struct {
// Swap chain image presentation
VkSemaphore presentComplete;
// Command buffer submission and execution
VkSemaphore renderComplete;
// Text overlay submission and execution
VkSemaphore textOverlayComplete;
} Semaphores;
struct {
VkBuffer buffer;
VkDeviceMemory memory;
VkDescriptorBufferInfo descriptor;
} uniformDataVS;
// For simplicity we use the same uniform block layout as in the shader:
//
// layout(set = 0, binding = 0) uniform UBO
// {
// mat4 projectionMatrix;
// mat4 modelMatrix;
// mat4 viewMatrix;
// } ubo;
//
// This way we can just memcopy the ubo data to the ubo
// Note that you should be using data types that align with the GPU
// in order to avoid manual padding
struct {
glm::mat4 projectionMatrix;
glm::mat4 modelMatrix;
glm::mat4 viewMatrix;
} uboVS;
//model data
RenderModelStatic staticModel;
public:
VkFont* m_VkFont;
private:
struct
{
glm::mat4 projectionMatrix;
glm::mat4 modelMatrix;
glm::mat4 viewMatrix;
glm::mat4 normal;
glm::vec4 viewPos;
float lodBias = 0.0f;
}m_uboVS;
uint32_t numVerts = 0;
uint32_t numUvs = 0;
uint32_t numNormals = 0;
std::vector<VkBufferObject_s> listLocalBuffers;
std::vector<VkDescriptorSet> listDescriptros;
std::vector<uint32_t> meshSize;
public:
Renderer();
~Renderer();
void BuildCommandBuffers() override;
void UpdateUniformBuffers() override;
void PrepareUniformBuffers() override;
void PrepareVertices(bool useStagingBuffers) override;
void VLoadTexture(std::string fileName, VkFormat format, bool forceLinearTiling, bool bUseCubeMap = false) override;
void PreparePipeline() override;
void SetupDescriptorSet() override;
void SetupDescriptorSetLayout() override;
void SetupDescriptorPool() override;
void LoadAssets() override;
void StartFrame() override;
void PrepareSemaphore() override;
void BeginTextUpdate();
};
Renderer::Renderer()
{
}
Renderer::~Renderer()
{
SAFE_DELETE(m_VkFont);
//Delete memory
for (int i = 0; i < listLocalBuffers.size(); i++)
{
VkBufferObject::DeleteBufferMemory(m_pWRenderer->m_SwapChain.device, listLocalBuffers[i], nullptr);
}
//Delete data from static model
staticModel.Clear(m_pWRenderer->m_SwapChain.device);
//Destroy Shader Module
for (int i = 0; i < m_ShaderModules.size(); i++)
{
vkDestroyShaderModule(m_pWRenderer->m_SwapChain.device, m_ShaderModules[i], nullptr);
}
//destroy uniform data
vkDestroyBuffer(m_pWRenderer->m_SwapChain.device, uniformDataVS.buffer, nullptr);
vkFreeMemory(m_pWRenderer->m_SwapChain.device, uniformDataVS.memory, nullptr);
//Release semaphores
vkDestroySemaphore(m_pWRenderer->m_SwapChain.device, Semaphores.presentComplete, nullptr);
vkDestroySemaphore(m_pWRenderer->m_SwapChain.device, Semaphores.renderComplete, nullptr);
vkDestroySemaphore(m_pWRenderer->m_SwapChain.device, Semaphores.textOverlayComplete, nullptr);
//DestroyPipeline
vkDestroyPipeline(m_pWRenderer->m_SwapChain.device, pipeline, nullptr);
vkDestroyPipelineLayout(m_pWRenderer->m_SwapChain.device, pipelineLayout, nullptr);
vkDestroyDescriptorSetLayout(m_pWRenderer->m_SwapChain.device, descriptorSetLayout, nullptr);
}
void Renderer::PrepareSemaphore()
{
VkSemaphoreCreateInfo semaphoreCreateInfo = {};
semaphoreCreateInfo.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO;
semaphoreCreateInfo.pNext = NULL;
// This semaphore ensures that the image is complete
// before starting to submit again
VK_CHECK_RESULT(vkCreateSemaphore(m_pWRenderer->m_SwapChain.device, &semaphoreCreateInfo, nullptr, &Semaphores.presentComplete));
// This semaphore ensures that all commands submitted
// have been finished before submitting the image to the queue
VK_CHECK_RESULT(vkCreateSemaphore(m_pWRenderer->m_SwapChain.device, &semaphoreCreateInfo, nullptr, &Semaphores.renderComplete));
// This semaphore ensures that all commands submitted
// have been finished before submitting the image to the queue
VK_CHECK_RESULT(vkCreateSemaphore(m_pWRenderer->m_SwapChain.device, &semaphoreCreateInfo, nullptr, &Semaphores.textOverlayComplete));
}
void Renderer::BeginTextUpdate()
{
m_VkFont->BeginTextUpdate();
std::stringstream ss;
ss << std::fixed << std::setprecision(2) << "ms-" << (frameTimer * 1000.0f) << "-fps-" << lastFPS;
m_VkFont->AddText(-0.22, -0.25, 0.001, 0.001, ss.str());
m_VkFont->EndTextUpdate();
}
void Renderer::BuildCommandBuffers()
{
VkCommandBufferBeginInfo cmdBufInfo = {};
cmdBufInfo.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO;
cmdBufInfo.pNext = NULL;
// Set clear values for all framebuffer attachments with loadOp set to clear
// We use two attachments (color and depth) that are cleared at the
// start of the subpass and as such we need to set clear values for both
VkClearValue clearValues[2];
clearValues[0].color = g_DefaultClearColor;
clearValues[1].depthStencil = { 1.0f, 0 };
VkRenderPassBeginInfo renderPassBeginInfo = {};
renderPassBeginInfo.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO;
renderPassBeginInfo.pNext = NULL;
renderPassBeginInfo.renderPass = m_pWRenderer->m_RenderPass;
renderPassBeginInfo.renderArea.offset.x = 0;
renderPassBeginInfo.renderArea.offset.y = 0;
renderPassBeginInfo.renderArea.extent.width = g_iDesktopWidth;
renderPassBeginInfo.renderArea.extent.height = g_iDesktopHeight;
renderPassBeginInfo.clearValueCount = 2;
renderPassBeginInfo.pClearValues = clearValues;
for (int32_t i = 0; i < m_pWRenderer->m_DrawCmdBuffers.size(); ++i)
{
// Set target frame buffer
renderPassBeginInfo.framebuffer = m_pWRenderer->m_FrameBuffers[i];
VK_CHECK_RESULT(vkBeginCommandBuffer(m_pWRenderer->m_DrawCmdBuffers[i], &cmdBufInfo));
// Start the first sub pass specified in our default render pass setup by the base class
// This will clear the color and depth attachment
vkCmdBeginRenderPass(m_pWRenderer->m_DrawCmdBuffers[i], &renderPassBeginInfo, VK_SUBPASS_CONTENTS_INLINE);
VkViewport viewport = VkTools::Initializer::Viewport((float)g_iDesktopWidth, (float)g_iDesktopHeight, 0.0f, 1.0f);
vkCmdSetViewport(m_pWRenderer->m_DrawCmdBuffers[i], 0, 1, &viewport);
VkRect2D scissor = VkTools::Initializer::Rect2D(g_iDesktopWidth, g_iDesktopHeight, 0, 0);
vkCmdSetScissor(m_pWRenderer->m_DrawCmdBuffers[i], 0, 1, &scissor);
// Bind the rendering pipeline
// The pipeline (state object) contains all states of the rendering pipeline
// So once we bind a pipeline all states that were set upon creation of that
// pipeline will be set
vkCmdBindPipeline(m_pWRenderer->m_DrawCmdBuffers[i], VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline);
// Bind triangle vertex buffer (contains position and colors)
VkDeviceSize offsets[1] = { 0 };
for (int j = 0; j < listLocalBuffers.size(); j++)
{
// Bind descriptor sets describing shader binding points
vkCmdBindDescriptorSets(m_pWRenderer->m_DrawCmdBuffers[i], VK_PIPELINE_BIND_POINT_GRAPHICS, pipelineLayout, 0, 1, &listDescriptros[j], 0, NULL);
//Bind Buffer
vkCmdBindVertexBuffers(m_pWRenderer->m_DrawCmdBuffers[i], VERTEX_BUFFER_BIND_ID, 1, &listLocalBuffers[j].buffer, offsets);
//Draw
vkCmdDraw(m_pWRenderer->m_DrawCmdBuffers[i], meshSize[j], 1, 0, 0);
}
vkCmdEndRenderPass(m_pWRenderer->m_DrawCmdBuffers[i]);
VK_CHECK_RESULT(vkEndCommandBuffer(m_pWRenderer->m_DrawCmdBuffers[i]));
}
}
void Renderer::UpdateUniformBuffers()
{
// Update matrices
m_uboVS.projectionMatrix = glm::perspective(glm::radians(60.0f), (float)m_WindowWidth / (float)m_WindowHeight, 0.1f, 256.0f);
m_uboVS.viewMatrix = glm::translate(glm::mat4(), glm::vec3(0.0f, 5.0f, g_zoom));
m_uboVS.modelMatrix = m_uboVS.viewMatrix * glm::translate(glm::mat4(), glm::vec3(0.0f, 0.0f, 5.0f));
m_uboVS.modelMatrix = glm::rotate(m_uboVS.modelMatrix, glm::radians(g_Rotation.x), glm::vec3(1.0f, 0.0f, 0.0f));
m_uboVS.modelMatrix = glm::rotate(m_uboVS.modelMatrix, glm::radians(g_Rotation.y), glm::vec3(0.0f, 1.0f, 0.0f));
m_uboVS.modelMatrix = glm::rotate(m_uboVS.modelMatrix, glm::radians(g_Rotation.z), glm::vec3(0.0f, 0.0f, 1.0f));
m_uboVS.normal = glm::inverseTranspose(m_uboVS.modelMatrix);
m_uboVS.viewPos = glm::vec4(0.0f, 0.0f, -15.0f, 0.0f);
// Map uniform buffer and update it
uint8_t *pData;
VK_CHECK_RESULT(vkMapMemory(m_pWRenderer->m_SwapChain.device, uniformDataVS.memory, 0, sizeof(m_uboVS), 0, (void **)&pData));
memcpy(pData, &m_uboVS, sizeof(m_uboVS));
vkUnmapMemory(m_pWRenderer->m_SwapChain.device, uniformDataVS.memory);
}
void Renderer::PrepareUniformBuffers()
{
// Prepare and initialize a uniform buffer block containing shader uniforms
// In Vulkan there are no more single uniforms like in GL
// All shader uniforms are passed as uniform buffer blocks
VkMemoryRequirements memReqs;
// Vertex shader uniform buffer block
VkBufferCreateInfo bufferInfo = {};
VkMemoryAllocateInfo allocInfo = {};
allocInfo.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO;
allocInfo.pNext = NULL;
allocInfo.allocationSize = 0;
allocInfo.memoryTypeIndex = 0;
bufferInfo.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO;
bufferInfo.size = sizeof(m_uboVS);
bufferInfo.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT;
// Create a new buffer
VK_CHECK_RESULT(vkCreateBuffer(m_pWRenderer->m_SwapChain.device, &bufferInfo, nullptr, &uniformDataVS.buffer));
// Get memory requirements including size, alignment and memory type
vkGetBufferMemoryRequirements(m_pWRenderer->m_SwapChain.device, uniformDataVS.buffer, &memReqs);
allocInfo.allocationSize = memReqs.size;
// Get the memory type index that supports host visibile memory access
// Most implementations offer multiple memory tpyes and selecting the
// correct one to allocate memory from is important
// We also want the buffer to be host coherent so we don't have to flush
// after every update.
// Note that this may affect performance so you might not want to do this
// in a real world application that updates buffers on a regular base
allocInfo.memoryTypeIndex = VkTools::GetMemoryType(memReqs.memoryTypeBits, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT, m_pWRenderer->m_DeviceMemoryProperties);
// Allocate memory for the uniform buffer
VK_CHECK_RESULT(vkAllocateMemory(m_pWRenderer->m_SwapChain.device, &allocInfo, nullptr, &(uniformDataVS.memory)));
// Bind memory to buffer
VK_CHECK_RESULT(vkBindBufferMemory(m_pWRenderer->m_SwapChain.device, uniformDataVS.buffer, uniformDataVS.memory, 0));
// Store information in the uniform's descriptor
uniformDataVS.descriptor.buffer = uniformDataVS.buffer;
uniformDataVS.descriptor.offset = 0;
uniformDataVS.descriptor.range = sizeof(m_uboVS);
UpdateUniformBuffers();
}
void Renderer::PrepareVertices(bool useStagingBuffers)
{
//Create font pipeline
m_VkFont->CreateFontVk((GetAssetPath() + "Textures/freetype/AmazDooMLeft.ttf"), 64, 96);
m_VkFont->SetupDescriptorPool();
m_VkFont->SetupDescriptorSetLayout();
m_VkFont->PrepareUniformBuffers();
m_VkFont->InitializeChars("qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM-:.@1234567890", *m_pTextureLoader);
m_VkFont->PrepareResources(g_iDesktopWidth, g_iDesktopHeight);
BeginTextUpdate();
staticModel.InitFromFile("Geometry/nanosuit/nanosuit2.obj", GetAssetPath());
std::vector<VkBufferObject_s> listStagingBuffers;
listLocalBuffers.resize(staticModel.surfaces.size());
listStagingBuffers.resize(staticModel.surfaces.size());
listDescriptros.resize(staticModel.surfaces.size());
m_pWRenderer->m_DescriptorPool = VK_NULL_HANDLE;
SetupDescriptorPool();
VkDescriptorSetAllocateInfo allocInfo = VkTools::Initializer::DescriptorSetAllocateInfo(m_pWRenderer->m_DescriptorPool, &descriptorSetLayout, 1);
for (int i = 0; i < staticModel.surfaces.size(); i++)
{
//Get triangles
srfTriangles_t* tr = staticModel.surfaces[i].geometry;
VK_CHECK_RESULT(vkAllocateDescriptorSets(m_pWRenderer->m_SwapChain.device, &allocInfo, &listDescriptros[i]));
std::vector<VkWriteDescriptorSet> writeDescriptorSets =
{
//uniform descriptor
VkTools::Initializer::WriteDescriptorSet(listDescriptros[i],VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, 0,&uniformDataVS.descriptor)
};
//We need this because descriptorset will take pointer to vkDescriptorImageInfo.
//So if we delete it before update descriptor sets. The data will not be sented to gpu. Will pointing to memory address in which nothing exist anymore
//The program won't break. But you will see problems in fragment shader
std::vector<VkDescriptorImageInfo> descriptors;
descriptors.reserve(staticModel.surfaces[i].numMaterials);
//Get all materials
for (uint32_t j = 0; j < staticModel.surfaces[i].numMaterials; j++)
{
VkTools::VulkanTexture* pTexture = staticModel.surfaces[i].material[j].getTexture();
descriptors.push_back(VkTools::Initializer::DescriptorImageInfo(pTexture->sampler, pTexture->view, VK_IMAGE_LAYOUT_GENERAL));
writeDescriptorSets.push_back(VkTools::Initializer::WriteDescriptorSet(listDescriptros[i], VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, j + 1, &descriptors[j]));
}
//Update descriptor set
vkUpdateDescriptorSets(m_pWRenderer->m_SwapChain.device, writeDescriptorSets.size(), writeDescriptorSets.data(), 0, NULL);
//Create stagging buffer first
VkBufferObject::CreateBuffer(
m_pWRenderer->m_SwapChain,
m_pWRenderer->m_DeviceMemoryProperties,
VK_BUFFER_USAGE_TRANSFER_SRC_BIT,
VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT,
static_cast<uint32_t>(sizeof(drawVert) * tr->numVerts),
listStagingBuffers[i],
tr->verts);
//Create Local Copy
VkBufferObject::CreateBuffer(
m_pWRenderer->m_SwapChain,
m_pWRenderer->m_DeviceMemoryProperties,
VK_BUFFER_USAGE_VERTEX_BUFFER_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT,
VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT,
static_cast<uint32_t>(sizeof(drawVert) * tr->numVerts),
listLocalBuffers[i]);
//Create new command buffer
VkCommandBuffer copyCmd = GetCommandBuffer(true);
//Submit info to the queue
VkBufferObject::SubmitBufferObjects(
copyCmd,
m_pWRenderer->m_Queue,
*m_pWRenderer,
static_cast<uint32_t>(sizeof(drawVert) * tr->numVerts),
listStagingBuffers[i],
listLocalBuffers[i], (drawVertFlags::Vertex | drawVertFlags::Normal | drawVertFlags::Uv | drawVertFlags::Tangent | drawVertFlags::Binormal));
meshSize.push_back(tr->numVerts);
numVerts += tr->numVerts;
numUvs += tr->numVerts;
numNormals += tr->numVerts;
}
}
void Renderer::PreparePipeline()
{
// Create our rendering pipeline used in this example
// Vulkan uses the concept of rendering pipelines to encapsulate
// fixed states
// This replaces OpenGL's huge (and cumbersome) state machine
// A pipeline is then stored and hashed on the GPU making
// pipeline changes much faster than having to set dozens of
// states
// In a real world application you'd have dozens of pipelines
// for every shader set used in a scene
// Note that there are a few states that are not stored with
// the pipeline. These are called dynamic states and the
// pipeline only stores that they are used with this pipeline,
// but not their states
// Assign states
// Assign pipeline state create information
VkGraphicsPipelineCreateInfo pipelineCreateInfo = {};
pipelineCreateInfo.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO;
// The layout used for this pipeline
pipelineCreateInfo.layout = pipelineLayout;
// Renderpass this pipeline is attached to
pipelineCreateInfo.renderPass = m_pWRenderer->m_RenderPass;
// Vertex input state
// Describes the topoloy used with this pipeline
VkPipelineInputAssemblyStateCreateInfo inputAssemblyState = {};
inputAssemblyState.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO;
// This pipeline renders vertex data as triangle lists
inputAssemblyState.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST;
// Rasterization state
VkPipelineRasterizationStateCreateInfo rasterizationState = {};
rasterizationState.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO;
// Solid polygon mode
rasterizationState.polygonMode = VK_POLYGON_MODE_FILL;
// No culling
rasterizationState.cullMode = VK_CULL_MODE_NONE;
rasterizationState.frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE;
rasterizationState.depthClampEnable = VK_FALSE;
rasterizationState.rasterizerDiscardEnable = VK_FALSE;
rasterizationState.depthBiasEnable = VK_FALSE;
rasterizationState.lineWidth = 1.0f;
// Color blend state
// Describes blend modes and color masks
VkPipelineColorBlendStateCreateInfo colorBlendState = {};
colorBlendState.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO;
// One blend attachment state
// Blending is not used in this example
VkPipelineColorBlendAttachmentState blendAttachmentState[1] = {};
blendAttachmentState[0].colorWriteMask = 0xf;
blendAttachmentState[0].blendEnable = VK_FALSE;
colorBlendState.attachmentCount = 1;
colorBlendState.pAttachments = blendAttachmentState;
// Viewport state
VkPipelineViewportStateCreateInfo viewportState = {};
viewportState.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO;
// One viewport
viewportState.viewportCount = 1;
// One scissor rectangle
viewportState.scissorCount = 1;
// Enable dynamic states
// Describes the dynamic states to be used with this pipeline
// Dynamic states can be set even after the pipeline has been created
// So there is no need to create new pipelines just for changing
// a viewport's dimensions or a scissor box
VkPipelineDynamicStateCreateInfo dynamicState = {};
// The dynamic state properties themselves are stored in the command buffer
std::vector<VkDynamicState> dynamicStateEnables;
dynamicStateEnables.push_back(VK_DYNAMIC_STATE_VIEWPORT);
dynamicStateEnables.push_back(VK_DYNAMIC_STATE_SCISSOR);
dynamicState.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO;
dynamicState.pDynamicStates = dynamicStateEnables.data();
dynamicState.dynamicStateCount = static_cast<uint32_t>(dynamicStateEnables.size());
// Depth and stencil state
// Describes depth and stenctil test and compare ops
VkPipelineDepthStencilStateCreateInfo depthStencilState = {};
// Basic depth compare setup with depth writes and depth test enabled
// No stencil used
depthStencilState.sType = VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO;
depthStencilState.depthTestEnable = VK_TRUE;
depthStencilState.depthWriteEnable = VK_TRUE;
depthStencilState.depthCompareOp = VK_COMPARE_OP_LESS_OR_EQUAL;
depthStencilState.depthBoundsTestEnable = VK_FALSE;
depthStencilState.back.failOp = VK_STENCIL_OP_KEEP;
depthStencilState.back.passOp = VK_STENCIL_OP_KEEP;
depthStencilState.back.compareOp = VK_COMPARE_OP_ALWAYS;
depthStencilState.stencilTestEnable = VK_FALSE;
depthStencilState.front = depthStencilState.back;
// Multi sampling state
VkPipelineMultisampleStateCreateInfo multisampleState = {};
multisampleState.sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO;
multisampleState.pSampleMask = NULL;
// No multi sampling used in this example
multisampleState.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT;
// Load shaders
//Shaders are loaded from the SPIR-V format, which can be generated from glsl
std::array<VkPipelineShaderStageCreateInfo, 2> shaderStages;
shaderStages[0] = LoadShader(GetAssetPath() + "Shaders/StaticModel/triangle.vert.spv", VK_SHADER_STAGE_VERTEX_BIT);
shaderStages[1] = LoadShader(GetAssetPath() + "Shaders/StaticModel/triangle.frag.spv", VK_SHADER_STAGE_FRAGMENT_BIT);
// Create Pipeline state VI-IA-VS-VP-RS-FS-CB
pipelineCreateInfo.stageCount = static_cast<uint32_t>(shaderStages.size());
pipelineCreateInfo.pStages = shaderStages.data();
pipelineCreateInfo.pVertexInputState = &listLocalBuffers[0].inputState;
pipelineCreateInfo.pInputAssemblyState = &inputAssemblyState;
pipelineCreateInfo.pRasterizationState = &rasterizationState;
pipelineCreateInfo.pColorBlendState = &colorBlendState;
pipelineCreateInfo.pMultisampleState = &multisampleState;
pipelineCreateInfo.pViewportState = &viewportState;
pipelineCreateInfo.pDepthStencilState = &depthStencilState;
pipelineCreateInfo.renderPass = m_pWRenderer->m_RenderPass;
pipelineCreateInfo.pDynamicState = &dynamicState;
// Create rendering pipeline
VK_CHECK_RESULT(vkCreateGraphicsPipelines(m_pWRenderer->m_SwapChain.device, m_pWRenderer->m_PipelineCache, 1, &pipelineCreateInfo, nullptr, &pipeline));
}
void Renderer::VLoadTexture(std::string fileName, VkFormat format, bool forceLinearTiling, bool bUseCubeMap)
{
}
void Renderer::SetupDescriptorSetLayout()
{
std::vector<VkDescriptorSetLayoutBinding> setLayoutBindings =
{
// Binding 0 : Vertex shader uniform buffer
VkTools::Initializer::DescriptorSetLayoutBinding(VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,VK_SHADER_STAGE_VERTEX_BIT,0),
// Binding 1 : Diffuse
VkTools::Initializer::DescriptorSetLayoutBinding(VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,VK_SHADER_STAGE_FRAGMENT_BIT,1),
// Binding 2 : Normal
VkTools::Initializer::DescriptorSetLayoutBinding(VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,VK_SHADER_STAGE_FRAGMENT_BIT,2),
// Binding 3 : Specular
VkTools::Initializer::DescriptorSetLayoutBinding(VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,VK_SHADER_STAGE_FRAGMENT_BIT,3)
};
VkDescriptorSetLayoutCreateInfo descriptorLayout = VkTools::Initializer::DescriptorSetLayoutCreateInfo(setLayoutBindings.data(), setLayoutBindings.size());
VK_CHECK_RESULT(vkCreateDescriptorSetLayout(m_pWRenderer->m_SwapChain.device, &descriptorLayout, nullptr, &descriptorSetLayout));
VkPipelineLayoutCreateInfo pPipelineLayoutCreateInfo = VkTools::Initializer::PipelineLayoutCreateInfo(&descriptorSetLayout, 1);
VK_CHECK_RESULT(vkCreatePipelineLayout(m_pWRenderer->m_SwapChain.device, &pPipelineLayoutCreateInfo, nullptr, &pipelineLayout));
}
void Renderer::SetupDescriptorPool()
{
// Example uses one ubo and one image sampler
std::vector<VkDescriptorPoolSize> poolSizes =
{
VkTools::Initializer::DescriptorPoolSize(VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, 7),
VkTools::Initializer::DescriptorPoolSize(VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 7*3)
};
VkDescriptorPoolCreateInfo descriptorPoolInfo = VkTools::Initializer::DescriptorPoolCreateInfo(poolSizes.size(),poolSizes.data(),7);
VK_CHECK_RESULT(vkCreateDescriptorPool(m_pWRenderer->m_SwapChain.device, &descriptorPoolInfo, nullptr, &m_pWRenderer->m_DescriptorPool));
}
void Renderer::SetupDescriptorSet()
{
/*
VkDescriptorSetAllocateInfo allocInfo = VkTools::Initializer::DescriptorSetAllocateInfo(m_pWRenderer->m_DescriptorPool,&descriptorSetLayout,1);
VK_CHECK_RESULT(vkAllocateDescriptorSets(m_pWRenderer->m_SwapChain.device, &allocInfo, &descriptorSet));
// Image descriptor for the color map texture
VkDescriptorImageInfo texDescriptor = VkTools::Initializer::DescriptorImageInfo(m_VkTexture.sampler, m_VkTexture.view,VK_IMAGE_LAYOUT_GENERAL);
std::vector<VkWriteDescriptorSet> writeDescriptorSets =
{
// Binding 0 : Vertex shader uniform buffer
VkTools::Initializer::WriteDescriptorSet(descriptorSet,VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, 0,&uniformDataVS.descriptor),
// Binding 1 : Fragment shader texture sampler
VkTools::Initializer::WriteDescriptorSet(descriptorSet,VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 1,&texDescriptor)
};
vkUpdateDescriptorSets(m_pWRenderer->m_SwapChain.device, writeDescriptorSets.size(), writeDescriptorSets.data(), 0, NULL);
*/
}
void Renderer::StartFrame()
{
{
// Get next image in the swap chain (back/front buffer)
VK_CHECK_RESULT(m_pWRenderer->m_SwapChain.GetNextImage(Semaphores.presentComplete, &m_pWRenderer->m_currentBuffer));
// Submit the post present image barrier to transform the image back to a color attachment
// that can be used to write to by our render pass
VkSubmitInfo submitInfo = VkTools::Initializer::SubmitInfo();
submitInfo.commandBufferCount = 1;
submitInfo.pCommandBuffers = &m_pWRenderer->m_PostPresentCmdBuffers[m_pWRenderer->m_currentBuffer];
VK_CHECK_RESULT(vkQueueSubmit(m_pWRenderer->m_Queue, 1, &submitInfo, VK_NULL_HANDLE));
// Make sure that the image barrier command submitted to the queue
// has finished executing
VK_CHECK_RESULT(vkQueueWaitIdle(m_pWRenderer->m_Queue));
}
{
//Submit model
VkPipelineStageFlags submitPipelineStages = VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT;
VkPipelineStageFlags stageFlags = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
VkSubmitInfo submitInfo = VkTools::Initializer::SubmitInfo();
submitInfo.pWaitDstStageMask = &submitPipelineStages;
submitInfo.commandBufferCount = 1;
submitInfo.pCommandBuffers = &m_pWRenderer->m_DrawCmdBuffers[m_pWRenderer->m_currentBuffer];
// Wait for swap chain presentation to finish
submitInfo.waitSemaphoreCount = 1;
submitInfo.pWaitSemaphores = &Semaphores.presentComplete;
//Signal ready for model render to complete
submitInfo.signalSemaphoreCount = 1;
submitInfo.pSignalSemaphores = &Semaphores.renderComplete;
VK_CHECK_RESULT(vkQueueSubmit(m_pWRenderer->m_Queue, 1, &submitInfo, VK_NULL_HANDLE));
//Wait for color output before rendering text
submitInfo.pWaitDstStageMask = &stageFlags;
// Wait model rendering to finnish
submitInfo.pWaitSemaphores = &Semaphores.renderComplete;
//Signal ready for text to completeS
submitInfo.pSignalSemaphores = &Semaphores.textOverlayComplete;
submitInfo.pCommandBuffers = &m_VkFont->cmdBuffers[m_pWRenderer->m_currentBuffer];
VK_CHECK_RESULT(vkQueueSubmit(m_pWRenderer->m_Queue, 1, &submitInfo, VK_NULL_HANDLE));
// Reset stage mask
submitInfo.pWaitDstStageMask = &submitPipelineStages;
// Reset wait and signal semaphores for rendering next frame
// Wait for swap chain presentation to finish
submitInfo.waitSemaphoreCount = 1;
submitInfo.pWaitSemaphores = &Semaphores.presentComplete;
// Signal ready with offscreen semaphore
submitInfo.signalSemaphoreCount = 1;
submitInfo.pSignalSemaphores = &Semaphores.renderComplete;
}
{
// Submit pre present image barrier to transform the image from color attachment to present(khr) for presenting to the swap chain
VkSubmitInfo submitInfo = VkTools::Initializer::SubmitInfo();
submitInfo.commandBufferCount = 1;
submitInfo.pCommandBuffers = &m_pWRenderer->m_PrePresentCmdBuffers[m_pWRenderer->m_currentBuffer];
VK_CHECK_RESULT(vkQueueSubmit(m_pWRenderer->m_Queue, 1, &submitInfo, VK_NULL_HANDLE));
// Present the current buffer to the swap chain
// We pass the signal semaphore from the submit info
// to ensure that the image is not rendered until
// all commands have been submitted
VK_CHECK_RESULT(m_pWRenderer->m_SwapChain.QueuePresent(m_pWRenderer->m_Queue, m_pWRenderer->m_currentBuffer, Semaphores.textOverlayComplete));
}
}
void Renderer::LoadAssets()
{
m_VkFont = TYW_NEW VkFont(m_pWRenderer->m_SwapChain.physicalDevice, m_pWRenderer->m_SwapChain.device, m_pWRenderer->m_Queue, m_pWRenderer->m_FrameBuffers, m_pWRenderer->m_SwapChain.colorFormat, m_pWRenderer->m_SwapChain.depthFormat, &g_iDesktopWidth, &g_iDesktopHeight);
}
//Main global Renderer
Renderer g_Renderer;
int main()
{
g_bPrepared = g_Renderer.VInitRenderer(720, 1280, false, HandleWindowMessages);
#if defined(_WIN32)
MSG msg;
#endif
while (TRUE)
{
if (!GenerateEvents(msg))break;
auto tStart = std::chrono::high_resolution_clock::now();
g_Renderer.StartFrame();
//Do something
g_Renderer.EndFrame(nullptr);
auto tEnd = std::chrono::high_resolution_clock::now();
g_Renderer.frameCounter++;
auto tDiff = std::chrono::duration<double, std::milli>(tEnd - tStart).count();
g_Renderer.frameTimer = (float)tDiff / 1000.0f;
g_Renderer.fpsTimer += (float)tDiff;
if (g_Renderer.fpsTimer > 1000.0f)
{
g_Renderer.BeginTextUpdate();
g_Renderer.lastFPS = g_Renderer.frameCounter;
g_Renderer.fpsTimer = 0.0f;
g_Renderer.frameCounter = 0;
}
}
g_Renderer.VShutdown();
return 0;
}
LRESULT CALLBACK HandleWindowMessages(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch (uMsg)
{
case WM_CLOSE:
//prepared = false;
DestroyWindow(hWnd);
PostQuitMessage(0);
break;
case WM_PAINT:
//ValidateRect(window, NULL);
break;
case WM_KEYDOWN:
switch (wParam)
{
case 0x50:
//paused = !paused;
break;
case VK_F1:
//if (enableTextOverlay)
{
//textOverlay->visible = !textOverlay->visible;
}
break;
case VK_ESCAPE:
PostQuitMessage(0);
break;
}
break;
case WM_KEYUP:
/*
if (camera.firstperson)
{
switch (wParam)
{
case 0x57:
camera.keys.up = false;
break;
case 0x53:
camera.keys.down = false;
break;
case 0x41:
camera.keys.left = false;
break;
case 0x44:
camera.keys.right = false;
break;
}
}
*/
break;
case WM_RBUTTONDOWN:
case WM_LBUTTONDOWN:
case WM_MBUTTONDOWN:
g_MousePos.x = (float)LOWORD(lParam);
g_MousePos.y = (float)HIWORD(lParam);
break;
case WM_MOUSEWHEEL:
{
short wheelDelta = GET_WHEEL_DELTA_WPARAM(wParam);
g_zoom += (float)wheelDelta * 0.005f * g_ZoomSpeed;
//camera.translate(glm::vec3(0.0f, 0.0f, (float)wheelDelta * 0.005f * zoomSpeed));
g_Renderer.UpdateUniformBuffers();
break;
}
case WM_MOUSEMOVE:
if (wParam & MK_RBUTTON)
{
int32_t posx = LOWORD(lParam);
int32_t posy = HIWORD(lParam);
g_zoom += (g_MousePos.y - (float)posy) * .005f * g_ZoomSpeed;
//camera.translate(glm::vec3(-0.0f, 0.0f, (mousePos.y - (float)posy) * .005f * zoomSpeed));
g_MousePos = glm::vec2((float)posx, (float)posy);
g_Renderer.UpdateUniformBuffers();
}
if (wParam & MK_LBUTTON)
{
int32_t posx = LOWORD(lParam);
int32_t posy = HIWORD(lParam);
g_Rotation.x += (g_MousePos.y - (float)posy) * 1.25f * g_RotationSpeed;
g_Rotation.y -= (g_MousePos.x - (float)posx) * 1.25f * g_RotationSpeed;
//camera.rotate(glm::vec3((mousePos.y - (float)posy), -(mousePos.x - (float)posx), 0.0f));
g_MousePos = glm::vec2((float)posx, (float)posy);
g_Renderer.UpdateUniformBuffers();
}
if (wParam & MK_MBUTTON)
{
int32_t posx = LOWORD(lParam);
int32_t posy = HIWORD(lParam);
g_CameraPos.x -= (g_MousePos.x - (float)posx) * 0.01f;
g_CameraPos.y -= (g_MousePos.y - (float)posy) * 0.01f;
//camera.translate(glm::vec3(-(mousePos.x - (float)posx) * 0.01f, -(mousePos.y - (float)posy) * 0.01f, 0.0f));
//viewChanged();
g_MousePos.x = (float)posx;
g_MousePos.y = (float)posy;
}
break;
case WM_SIZE:
RECT rect;
if (GetWindowRect(hWnd, &rect))
{
WIN_Sizing(wParam, &rect);
}
break;
case WM_EXITSIZEMOVE:
if (g_bPrepared)
{
g_Renderer.VWindowResize(g_iDesktopHeight, g_iDesktopWidth);
g_Renderer.UpdateUniformBuffers();
g_Renderer.m_VkFont->UpdateUniformBuffers(g_iDesktopWidth, g_iDesktopHeight, 0.0f);
}
break;
}
return DefWindowProc(hWnd, uMsg, wParam, lParam);
}
bool GenerateEvents(MSG& msg)
{
if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
{
if (msg.message == WM_QUIT)
{
return false;
}
else
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
return true;
}
void WIN_Sizing(WORD side, RECT *rect)
{
// restrict to a standard aspect ratio
g_iDesktopWidth = rect->right - rect->left;
g_iDesktopHeight = rect->bottom - rect->top;
// Adjust width/height for window decoration
RECT decoRect = { 0, 0, 0, 0 };
AdjustWindowRect(&decoRect, WINDOW_STYLE | WS_SYSMENU, FALSE);
uint32_t decoWidth = decoRect.right - decoRect.left;
uint32_t decoHeight = decoRect.bottom - decoRect.top;
g_iDesktopWidth -= decoWidth;
g_iDesktopHeight -= decoHeight;
} |
; A173246: Expansion of (1+x)^50 * (1-x)/(1 - x^51).
; 1,49,1175,18375,210700,1888460,13771940,83993700,436994250,1968555050,7766844470,27081460630,84045912300,233460867500,582985137700,1312983918820,2672860120455,4923689695575,8206149492625,12352414499425
mov $3,$0
mov $6,2
lpb $6
sub $6,1
add $0,$6
sub $0,1
mov $2,$6
mov $4,50
bin $4,$0
mov $5,$4
lpb $2
mov $1,$5
sub $2,1
lpe
lpe
lpb $3
sub $1,$5
mov $3,0
lpe
|
; A037506: Base 5 digits are, in order, the first n terms of the periodic sequence with initial period 1,2,0.
; 1,7,35,176,882,4410,22051,110257,551285,2756426,13782132,68910660,344553301,1722766507,8613832535,43069162676,215345813382,1076729066910,5383645334551,26918226672757,134591133363785,672955666818926
add $0,2
mov $3,2
mov $4,1
lpb $0,1
sub $0,1
mul $4,5
add $4,3
mov $5,5
lpe
mov $1,$4
sub $5,$3
mov $2,$5
mul $2,2
add $2,25
div $1,$2
|
; A050408: a(n) = (117*n^2 - 99*n + 2)/2.
; 1,10,136,379,739,1216,1810,2521,3349,4294,5356,6535,7831,9244,10774,12421,14185,16066,18064,20179,22411,24760,27226,29809,32509,35326,38260,41311,44479,47764,51166,54685,58321,62074,65944,69931,74035,78256,82594,87049,91621,96310,101116,106039,111079,116236,121510,126901,132409,138034,143776,149635,155611,161704,167914,174241,180685,187246,193924,200719,207631,214660,221806,229069,236449,243946,251560,259291,267139,275104,283186,291385,299701,308134,316684,325351,334135,343036,352054,361189,370441,379810,389296,398899,408619,418456,428410,438481,448669,458974,469396,479935,490591,501364,512254,523261,534385,545626,556984,568459,580051,591760,603586,615529,627589,639766,652060,664471,676999,689644,702406,715285,728281,741394,754624,767971,781435,795016,808714,822529,836461,850510,864676,878959,893359,907876,922510,937261,952129,967114,982216,997435,1012771,1028224,1043794,1059481,1075285,1091206,1107244,1123399,1139671,1156060,1172566,1189189,1205929,1222786,1239760,1256851,1274059,1291384,1308826,1326385,1344061,1361854,1379764,1397791,1415935,1434196,1452574,1471069,1489681,1508410,1527256,1546219,1565299,1584496,1603810,1623241,1642789,1662454,1682236,1702135,1722151,1742284,1762534,1782901,1803385,1823986,1844704,1865539,1886491,1907560,1928746,1950049,1971469,1993006,2014660,2036431,2058319,2080324,2102446,2124685,2147041,2169514,2192104,2214811,2237635,2260576,2283634,2306809,2330101,2353510,2377036,2400679,2424439,2448316,2472310,2496421,2520649,2544994,2569456,2594035,2618731,2643544,2668474,2693521,2718685,2743966,2769364,2794879,2820511,2846260,2872126,2898109,2924209,2950426,2976760,3003211,3029779,3056464,3083266,3110185,3137221,3164374,3191644,3219031,3246535,3274156,3301894,3329749,3357721,3385810,3414016,3442339,3470779,3499336,3528010,3556801,3585709,3614734
mov $1,$0
bin $0,2
mul $0,13
add $1,$0
mul $1,9
add $1,1
|
; A052975: Expansion of (1-2*x)*(1-x)/(1-5*x+6*x^2-x^3).
; 1,2,6,19,61,197,638,2069,6714,21794,70755,229725,745889,2421850,7863641,25532994,82904974,269190547,874055885,2838041117,9215060822,29921113293,97153242650,315454594314,1024274628963,3325798821581,10798800928441,35063486341682,113850424959345,369670007675074,1200310974960982,3897385253713811
mul $0,2
cal $0,28495 ; Expansion of (1-x^2)/(1-x-2*x^2+x^3).
mov $1,$0
|
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#include <AzCore/std/smart_ptr/make_shared.h>
#include <AzFramework/Physics/SystemBus.h>
#include <MCore/Source/ReflectionSerializer.h>
#include <EMotionFX/CommandSystem/Source/CommandManager.h>
#include <EMotionFX/CommandSystem/Source/ColliderCommands.h>
#include <EMotionFX/CommandSystem/Source/RagdollCommands.h>
#include <EMotionFX/Source/Actor.h>
#include <EMotionFX/Source/ActorManager.h>
#include <EMotionFX/Source/Allocators.h>
#include <EMotionFX/Source/EMotionFXManager.h>
#include <EMotionFX/Source/Node.h>
#include <EMotionFX/Source/PhysicsSetup.h>
#include <MCore/Source/AzCoreConversions.h>
namespace EMotionFX
{
AZ_CLASS_ALLOCATOR_IMPL(CommandAddRagdollJoint, EMotionFX::CommandAllocator, 0)
AZ_CLASS_ALLOCATOR_IMPL(CommandRemoveRagdollJoint, EMotionFX::CommandAllocator, 0)
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
const Physics::RagdollNodeConfiguration* CommandRagdollHelpers::GetNodeConfig(const Actor * actor, const AZStd::string& jointName,
const Physics::RagdollConfiguration& ragdollConfig, AZStd::string& outResult)
{
const Skeleton* skeleton = actor->GetSkeleton();
const Node* joint = skeleton->FindNodeByName(jointName);
if (!joint)
{
outResult = AZStd::string::format("Cannot get node config. Joint with name '%s' does not exist.", jointName.c_str());
return nullptr;
}
return ragdollConfig.FindNodeConfigByName(jointName);
}
Physics::RagdollNodeConfiguration* CommandRagdollHelpers::GetCreateNodeConfig(const Actor* actor, const AZStd::string& jointName,
Physics::RagdollConfiguration& ragdollConfig, const AZStd::optional<size_t>& index, AZStd::string& outResult)
{
const Skeleton* skeleton = actor->GetSkeleton();
const Node* joint = skeleton->FindNodeByName(jointName);
if (!joint)
{
outResult = AZStd::string::format("Cannot add node config. Joint with name '%s' does not exist.", jointName.c_str());
return nullptr;
}
Physics::RagdollNodeConfiguration* nodeConfig = ragdollConfig.FindNodeConfigByName(jointName);
if (nodeConfig)
{
return nodeConfig;
}
Physics::RagdollNodeConfiguration newNodeConfig;
newNodeConfig.m_debugName = jointName;
// Create joint limit on default.
AZStd::vector<AZ::TypeId> supportedJointLimitTypes;
Physics::SystemRequestBus::BroadcastResult(supportedJointLimitTypes, &Physics::SystemRequests::GetSupportedJointTypes);
if (!supportedJointLimitTypes.empty())
{
newNodeConfig.m_jointLimit = CommandRagdollHelpers::CreateJointLimitByType(supportedJointLimitTypes[0], skeleton, joint);
}
if (index)
{
const auto iterator = ragdollConfig.m_nodes.begin() + index.value();
ragdollConfig.m_nodes.insert(iterator, newNodeConfig);
return iterator;
}
else
{
ragdollConfig.m_nodes.push_back(newNodeConfig);
return &ragdollConfig.m_nodes.back();
}
}
AZStd::unique_ptr<Physics::JointLimitConfiguration> CommandRagdollHelpers::CreateJointLimitByType(
const AZ::TypeId& typeId, const Skeleton* skeleton, const Node* node)
{
const Pose* bindPose = skeleton->GetBindPose();
const Transform& nodeBindTransform = bindPose->GetModelSpaceTransform(node->GetNodeIndex());
const Transform& parentBindTransform = node->GetParentNode()
? bindPose->GetModelSpaceTransform(node->GetParentIndex())
: Transform();
const AZ::Quaternion& nodeBindRotationWorld = MCore::EmfxQuatToAzQuat(nodeBindTransform.mRotation);
const AZ::Quaternion& parentBindRotationWorld = MCore::EmfxQuatToAzQuat(parentBindTransform.mRotation);
AZ::Vector3 boneDirection = AZ::Vector3::CreateAxisX();
// if there are child nodes, point the bone direction to the average of their positions
const uint32 numChildNodes = node->GetNumChildNodes();
if (numChildNodes > 0)
{
AZ::Vector3 meanChildPosition = AZ::Vector3::CreateZero();
// weight by the number of descendants of each child node, so that things like jiggle bones and twist bones
// have little influence on the bone direction.
float totalSubChildren = 0.0f;
for (uint32 childNumber = 0; childNumber < numChildNodes; childNumber++)
{
const uint32 childIndex = node->GetChildIndex(childNumber);
const Node* childNode = skeleton->GetNode(childIndex);
const float numSubChildren = static_cast<float>(1 + childNode->GetNumChildNodesRecursive());
totalSubChildren += numSubChildren;
meanChildPosition += numSubChildren * (bindPose->GetModelSpaceTransform(childIndex).mPosition);
}
boneDirection = meanChildPosition / totalSubChildren - nodeBindTransform.mPosition;
}
// otherwise, point the bone direction away from the parent
else
{
boneDirection = nodeBindTransform.mPosition - parentBindTransform.mPosition;
}
AZStd::vector<AZ::Quaternion> exampleRotationsLocal;
AZStd::unique_ptr<Physics::JointLimitConfiguration> jointLimitConfig;
Physics::SystemRequestBus::BroadcastResult(jointLimitConfig,
&Physics::SystemRequests::ComputeInitialJointLimitConfiguration,
typeId, parentBindRotationWorld, nodeBindRotationWorld, boneDirection, exampleRotationsLocal);
AZ_Assert(jointLimitConfig, "Could not create joint limit configuration with type '%s'.", typeId.ToString<AZStd::string>().c_str());
return jointLimitConfig;
}
void CommandRagdollHelpers::AddJointToRagdoll(AZ::u32 actorId, const AZStd::string& jointName,
MCore::CommandGroup* commandGroup, bool executeInsideCommand, bool addDefaultCollider)
{
AddJointToRagdoll(actorId, jointName, AZStd::nullopt, AZStd::nullopt, commandGroup, executeInsideCommand, addDefaultCollider);
}
void CommandRagdollHelpers::AddJointToRagdoll(AZ::u32 actorId, const AZStd::string& jointName,
const AZStd::optional<AZStd::string>& contents, const AZStd::optional<size_t>& index,
MCore::CommandGroup* commandGroup, bool executeInsideCommand, bool addDefaultCollider)
{
// 1. Add joint to ragdoll.
AZStd::string command = AZStd::string::format("%s -%s %d -%s \"%s\"",
CommandAddRagdollJoint::s_commandName,
CommandAddRagdollJoint::s_actorIdParameterName,
actorId,
CommandAddRagdollJoint::s_jointNameParameterName,
jointName.c_str());
if (contents)
{
command += AZStd::string::format(" -%s {", CommandAddRagdollJoint::s_contentsParameterName);
command += contents.value();
command += "}";
}
if (index)
{
command += AZStd::string::format(" -%s %d", CommandAddRagdollJoint::s_indexParameterName, index.value());
}
CommandSystem::GetCommandManager()->ExecuteCommandOrAddToGroup(command, commandGroup, executeInsideCommand);
// 2. Create default capsule collider.
if (addDefaultCollider)
{
const AZ::TypeId defaultColliderType = azrtti_typeid<Physics::CapsuleShapeConfiguration>();
CommandColliderHelpers::AddCollider(actorId, jointName,
PhysicsSetup::Ragdoll, defaultColliderType,
commandGroup, executeInsideCommand);
}
}
void CommandRagdollHelpers::RemoveJointFromRagdoll(AZ::u32 actorId, const AZStd::string& jointName, MCore::CommandGroup* commandGroup, bool executeInsideCommand)
{
// 1. Clear all ragdoll colliders for this joint.
CommandColliderHelpers::ClearColliders(actorId, jointName,
PhysicsSetup::Ragdoll,
commandGroup);
// 2. Remove joint from ragdoll.
AZStd::string command = AZStd::string::format("%s -%s %d -%s \"%s\"",
CommandRemoveRagdollJoint::s_commandName,
CommandRemoveRagdollJoint::s_actorIdParameterName,
actorId,
CommandRemoveRagdollJoint::s_jointNameParameterName,
jointName.c_str());
CommandSystem::GetCommandManager()->ExecuteCommandOrAddToGroup(command, commandGroup, executeInsideCommand);
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
const char* CommandAddRagdollJoint::s_commandName = "AddRagdollJoint";
const char* CommandAddRagdollJoint::s_contentsParameterName = "contents";
const char* CommandAddRagdollJoint::s_indexParameterName = "index";
CommandAddRagdollJoint::CommandAddRagdollJoint(MCore::Command* orgCommand)
: MCore::Command(s_commandName, orgCommand)
, m_oldIsDirty(false)
{
}
CommandAddRagdollJoint::CommandAddRagdollJoint(AZ::u32 actorId, const AZStd::string& jointName, MCore::Command* orgCommand)
: MCore::Command(s_commandName, orgCommand)
, ParameterMixinActorId(actorId)
, ParameterMixinJointName(jointName)
{
}
void CommandAddRagdollJoint::Reflect(AZ::ReflectContext* context)
{
AZ::SerializeContext* serializeContext = azrtti_cast<AZ::SerializeContext*>(context);
if (!serializeContext)
{
return;
}
serializeContext->Class<CommandAddRagdollJoint, MCore::Command, ParameterMixinActorId, ParameterMixinJointName>()
->Version(1)
;
}
bool CommandAddRagdollJoint::Execute(const MCore::CommandLine& parameters, AZStd::string& outResult)
{
AZ_UNUSED(parameters);
Actor* actor = GetActor(this, outResult);
if (!actor)
{
return false;
}
const AZStd::shared_ptr<PhysicsSetup>& physicsSetup = actor->GetPhysicsSetup();
Physics::RagdollConfiguration& ragdollConfig = physicsSetup->GetRagdollConfig();
Physics::RagdollNodeConfiguration* nodeConfig = CommandRagdollHelpers::GetCreateNodeConfig(actor, m_jointName, ragdollConfig, m_index, outResult);
if (!nodeConfig)
{
return false;
}
// Either in case the contents got specified via a command parameter or in case of redo.
if (m_contents)
{
const AZStd::string contents = m_contents.value();
MCore::ReflectionSerializer::Deserialize(nodeConfig, contents);
}
m_oldIsDirty = actor->GetDirtyFlag();
actor->SetDirtyFlag(true);
return true;
}
bool CommandAddRagdollJoint::Undo(const MCore::CommandLine& parameters, AZStd::string& outResult)
{
AZ_UNUSED(parameters);
Actor* actor = GetActor(this, outResult);
if (!actor)
{
return false;
}
const AZStd::shared_ptr<PhysicsSetup>& physicsSetup = actor->GetPhysicsSetup();
Physics::RagdollConfiguration& ragdollConfig = physicsSetup->GetRagdollConfig();
const Physics::RagdollNodeConfiguration* nodeConfig = CommandRagdollHelpers::GetNodeConfig(actor, m_jointName, ragdollConfig, outResult);
if (!nodeConfig)
{
return false;
}
m_contents = MCore::ReflectionSerializer::Serialize(nodeConfig).GetValue();
CommandRagdollHelpers::RemoveJointFromRagdoll(m_actorId, m_jointName, /*commandGroup*/ nullptr, true);
actor->SetDirtyFlag(m_oldIsDirty);
return true;
}
void CommandAddRagdollJoint::InitSyntax()
{
MCore::CommandSyntax& syntax = GetSyntax();
syntax.ReserveParameters(3);
ParameterMixinActorId::InitSyntax(syntax);
ParameterMixinJointName::InitSyntax(syntax);
syntax.AddParameter(s_contentsParameterName, "The serialized contents (in reflected XML).", MCore::CommandSyntax::PARAMTYPE_STRING, "");
syntax.AddParameter(s_indexParameterName, "The index of the ragdoll node config.", MCore::CommandSyntax::PARAMTYPE_INT, "-1");
}
bool CommandAddRagdollJoint::SetCommandParameters(const MCore::CommandLine& parameters)
{
ParameterMixinActorId::SetCommandParameters(parameters);
ParameterMixinJointName::SetCommandParameters(parameters);
if (parameters.CheckIfHasParameter(s_contentsParameterName))
{
m_contents = parameters.GetValue(s_contentsParameterName, this);
}
if (parameters.CheckIfHasParameter(s_indexParameterName))
{
m_index = parameters.GetValueAsInt(s_indexParameterName, this);
}
return true;
}
const char* CommandAddRagdollJoint::GetDescription() const
{
return "Add node to ragdoll.";
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
const char* CommandRemoveRagdollJoint::s_commandName = "RemoveRagdollJoint";
CommandRemoveRagdollJoint::CommandRemoveRagdollJoint(MCore::Command* orgCommand)
: MCore::Command(s_commandName, orgCommand)
, m_oldIsDirty(false)
{
}
CommandRemoveRagdollJoint::CommandRemoveRagdollJoint(AZ::u32 actorId, const AZStd::string& jointName, MCore::Command* orgCommand)
: MCore::Command(s_commandName, orgCommand)
, ParameterMixinActorId(actorId)
, ParameterMixinJointName(jointName)
{
}
void CommandRemoveRagdollJoint::Reflect(AZ::ReflectContext* context)
{
AZ::SerializeContext* serializeContext = azrtti_cast<AZ::SerializeContext*>(context);
if (!serializeContext)
{
return;
}
serializeContext->Class<CommandRemoveRagdollJoint, MCore::Command, ParameterMixinActorId, ParameterMixinJointName>()
->Version(1)
;
}
bool CommandRemoveRagdollJoint::Execute(const MCore::CommandLine& parameters, AZStd::string& outResult)
{
AZ_UNUSED(parameters);
Actor* actor = GetActor(this, outResult);
if (!actor)
{
return false;
}
const AZStd::shared_ptr<PhysicsSetup>& physicsSetup = actor->GetPhysicsSetup();
Physics::RagdollConfiguration& ragdollConfig = physicsSetup->GetRagdollConfig();
const Physics::RagdollNodeConfiguration* nodeConfig = CommandRagdollHelpers::GetNodeConfig(actor, m_jointName, ragdollConfig, outResult);
if (!nodeConfig)
{
return false;
}
m_oldContents = MCore::ReflectionSerializer::Serialize(nodeConfig).GetValue();
m_oldIndex = ragdollConfig.FindNodeConfigIndexByName(m_jointName).GetValue();
m_oldIsDirty = actor->GetDirtyFlag();
ragdollConfig.RemoveNodeConfigByName(m_jointName);
actor->SetDirtyFlag(true);
return true;
}
bool CommandRemoveRagdollJoint::Undo(const MCore::CommandLine& parameters, AZStd::string& outResult)
{
AZ_UNUSED(parameters);
Actor* actor = GetActor(this, outResult);
if (!actor)
{
return false;
}
CommandRagdollHelpers::AddJointToRagdoll(m_actorId, m_jointName, m_oldContents, m_oldIndex, /*commandGroup*/ nullptr, /*executeInsideCommand*/ true, /*addDefaultCollider*/ false);
actor->SetDirtyFlag(m_oldIsDirty);
return true;
}
void CommandRemoveRagdollJoint::InitSyntax()
{
MCore::CommandSyntax& syntax = GetSyntax();
syntax.ReserveParameters(2);
ParameterMixinActorId::InitSyntax(syntax);
ParameterMixinJointName::InitSyntax(syntax);
}
bool CommandRemoveRagdollJoint::SetCommandParameters(const MCore::CommandLine& parameters)
{
ParameterMixinActorId::SetCommandParameters(parameters);
ParameterMixinJointName::SetCommandParameters(parameters);
return true;
}
const char* CommandRemoveRagdollJoint::GetDescription() const
{
return "Remove the given joint from the ragdoll.";
}
} // namespace EMotionFX
|
// Copyright (c) 2011-2013 The Bitcoin Core developers
// Copyright (c) 2014-2016 The Dash Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "openuridialog.h"
#include "ui_openuridialog.h"
#include "guiutil.h"
#include "walletmodel.h"
#include <QUrl>
OpenURIDialog::OpenURIDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::OpenURIDialog)
{
ui->setupUi(this);
#if QT_VERSION >= 0x040700
ui->uriEdit->setPlaceholderText("dash:");
#endif
}
OpenURIDialog::~OpenURIDialog()
{
delete ui;
}
QString OpenURIDialog::getURI()
{
return ui->uriEdit->text();
}
void OpenURIDialog::accept()
{
SendCoinsRecipient rcp;
if(GUIUtil::parseBitcoinURI(getURI(), &rcp))
{
/* Only accept value URIs */
QDialog::accept();
} else {
ui->uriEdit->setValid(false);
}
}
void OpenURIDialog::on_selectFileButton_clicked()
{
QString filename = GUIUtil::getOpenFileName(this, tr("Select payment request file to open"), "", "", NULL);
if(filename.isEmpty())
return;
QUrl fileUri = QUrl::fromLocalFile(filename);
ui->uriEdit->setText("dash:?r=" + QUrl::toPercentEncoding(fileUri.toString()));
}
|
//===----------------------------------------------------------------------===//
//
// BusTub
//
// clock_replacer.cpp
//
// Identification: src/buffer/clock_replacer.cpp
//
// Copyright (c) 2015-2019, Carnegie Mellon University Database Group
//
//===----------------------------------------------------------------------===//
#include "buffer/clock_replacer.h"
namespace bustub {
ClockReplacer::ClockReplacer(size_t num_pages) {
this->capacity = num_pages;
this->clock_hand = 0;
this->buffer_pool.resize(num_pages, -1);
this->ref_bits.resize(num_pages, 0);
}
ClockReplacer::~ClockReplacer() = default;
bool ClockReplacer::Victim(frame_id_t *frame_id) {
int sweep_num = 0;
int size = replacer.size();
if (size == 0) { return false; }
while (sweep_num < size) {
clock_hand %= capacity;
// If the slot is empty or pinned (the page is not in the replacer)
if (buffer_pool[clock_hand] == -1 || replacer.count(buffer_pool[clock_hand]) == 0) {
clock_hand++;
continue;
}
// If the reference bit is 1, set 0
if (ref_bits[clock_hand] == 1) {
sweep_num++;
ref_bits[clock_hand] = 0;
clock_hand++;
} else { // If the reference bit is 0, evict the page (the victim)
int victim_id = buffer_pool[clock_hand];
*frame_id = victim_id;
replacer.erase(victim_id);
buffer_pool[clock_hand] = -1;
page_table.erase(victim_id);
clock_hand++;
return true;
}
}
// If no victim after sweeping, find the smallest frame_id as victim
int smallest_id = INT8_MAX;
for (int i = 0; i < capacity; i++) {
if (buffer_pool[i] == -1 || replacer.count(buffer_pool[i]) == 0) {
continue;
}
if (buffer_pool[i] < smallest_id) {
smallest_id = buffer_pool[i];
}
*frame_id = smallest_id;
replacer.erase(smallest_id);
buffer_pool[clock_hand] = -1;
page_table.erase(smallest_id);
}
return true;
}
void ClockReplacer::Pin(frame_id_t frame_id) {
if (frame_id > capacity || replacer.count(frame_id) == 0) { return; }
replacer.erase(frame_id);
}
void ClockReplacer::Unpin(frame_id_t frame_id) {
if (frame_id > capacity) {return;}
// If not in the buffer pool, add it to the buffer pool and the replacer
if (page_table.count(frame_id) == 0) {
for (int i = 0; i < capacity; i++) {
// Find the empty slot clockwise from the initial clock hand position
int slot = (i + clock_hand) % capacity;
if (buffer_pool[slot] == -1) {
buffer_pool[slot] = frame_id;
page_table[frame_id] = slot;
replacer.insert(frame_id);
ref_bits[slot] = 1;
break;
}
}
} else { // If in the buffer pool, add it to the replacer
replacer.insert(frame_id);
ref_bits[page_table[frame_id]] = 1;
}
}
size_t ClockReplacer::Size() {
int size = replacer.size();
return size;
}
} // namespace bustub
|
#import "../common.inc"
#import "fld-text.inc"
#import "../zoom-plasma/zoom-plasma.inc"
.const zp_base = $80
.const fld_y_index = zp_base
.const fld_y = zp_base + 1
.const enable_motion = zp_base + 3
.pc = fld_text_code_base "interface"
jmp init_bg
jmp init_int
.pc = * "init bg"
// Enables/disables motion based on value of a
init_bg:
sta enable_motion
// Clear screen
ldx #$00
lda #$20
!: sta $0400, x
sta $0500, x
sta $0600, x
sta $0700, x
dex
bne !-
// Init vars
lda #$30
sta fld_y_index
rts
.pc = * "init int"
init_int:
// Set up frame interrupt
lda #<frame
sta $fffe
lda #>frame
sta $ffff
lda #$ff
sta $d012
// Reset cycle counter
lda #$00
sta cycle_frame_counter
sta cycle_counter
rts
.pc = * "frame"
frame:
pha
txa
pha
tya
pha
lda $01
pha
// Bank in io regs
lda #$35
sta $01
// Reset VIC bank
lda #$c7
sta $dd00
// Set default screen location, lowercase chars
lda #$16
sta $d018
// Disable sprites
lda #$00
sta $d015
// Update music
//inc $d020
jsr music + 3
//dec $d020
// Copy text
ldx #$00
copy_text_read_instr:
!: lda text, x
sta $0400, x
inx
cpx #40
bne !-
// Fld
inc fld_y_index
inc fld_y_index
ldx fld_y_index
lda #144
clc
adc fld_text_fld_y_tab, x
sta fld_y
lda enable_motion
bne fld_wait_1
lda #144
sta fld_y
fld_wait_1:
lda $d012
!: cmp $d012
beq !-
cmp fld_y
beq !+
and #$07
ora #$18
sta $d011
jmp fld_wait_1
// Set background colors for text (after waiting a bit..)
!: ldx #$07
!: dex
bne !-
nop
lda cycle_frame_counter
lsr
tax
lda color_ramp, x
sta $d020
sta $d021
// Wait a few lines, then change colors back
lda fld_y
clc
adc #$12
sta fld_y
fld_wait_2:
lda $d012
!: cmp $d012
beq !-
cmp fld_y
bne fld_wait_2
ldx #$09
!: dex
bne !-
nop
nop
lda #$00
sta $d020
sta $d021
// Update cycle
inc cycle_frame_counter
lda cycle_frame_counter
cmp #cycle_frames
bne cycle_update_done
// Bump cycle counter
inc cycle_counter
// Reset counter
lda #$00
sta cycle_frame_counter
// If we've gone 1 cycle with motion disabled, then we're basically at the end. Shut it down and return to BASIC
lda enable_motion
bne !+
lda cycle_counter
cmp #$01
bne !+
// Turn off screen so we don't glitch or anything
lda #$00
sta $d011
// Bank in KERNAL and BASIC
lda #$37
sta $01
// ACK interrupts
/*lda #$01
sta $dd0d
lda $dd0d*/
asl $d019
// And we're out!
jmp ($fffc)
// If we've gone 7 cycles, disable motion
!: lda cycle_counter
cmp #$07
bne !+
lda #$00
sta enable_motion
// If we've gone 8 cycles, time to fire up the next effect
!: lda cycle_counter
cmp #$08
bne !+
jsr zoom_plasma_init_int
// Increment text read pointer
!: lda copy_text_read_instr + 1
clc
adc #40
sta copy_text_read_instr + 1
bcc !+
inc copy_text_read_instr + 2
// Offset y tab indices (looks a bit nicer)
!: lda fld_y_index
clc
adc #$37
sta fld_y_index
cycle_update_done:
asl $d019
pla
sta $01
pla
tay
pla
tax
pla
rti
.file [name="fld-text-data.prg", segments="Data"]
.segmentdef Data [start=fld_text_data_base]
.segment Data "data"
.pc = * "color ramp"
color_ramp:
.byte $00, $06, $04, $03, $01, $0d, $0e, $04
.for(var i = 0; i < cycle_frames / 2 - 16; i++) {
.byte $04
}
.byte $04, $0e, $0d, $01, $03, $04, $06, $00
.pc = * "text"
text:
// ----------------------------------------
.text " logicoma "
.text " at solskogen 2017 "
.text " presents "
.text " a c64 demo "
.text " in 4kb "
.text " this "
.text " is "
.text " makeshift. "
.text " logicoma 2017 "
|
; A051947: Partial sums of A034263.
; 1,10,49,168,462,1092,2310,4488,8151,14014,23023,36400,55692,82824,120156,170544,237405,324786,437437,580888,761530,986700,1264770,1605240,2018835,2517606,3115035,3826144,4667608,5657872,6817272,8168160,9735033,11544666
mov $2,$0
add $0,4
bin $0,$2
mov $1,$2
mul $2,2
add $2,3
mul $0,$2
add $1,5
mul $1,2
mul $1,$0
sub $1,30
div $1,30
add $1,1
mov $0,$1
|
;===============================================================================
; Copyright 2015-2020 Intel Corporation
;
; Licensed under the Apache License, Version 2.0 (the "License");
; you may not use this file except in compliance with the License.
; You may obtain a copy of the License at
;
; http://www.apache.org/licenses/LICENSE-2.0
;
; 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.
;===============================================================================
;
;
; Purpose: Cryptography Primitive.
; Big Number Operations
;
; Content:
; cpAddSub_BNU_school()
;
;
%include "asmdefs.inc"
%include "ia_32e.inc"
%include "pcpvariant.inc"
%if (_ENABLE_KARATSUBA_)
%if (_IPP32E >= _IPP32E_M7)
segment .text align=IPP_ALIGN_FACTOR
;*************************************************************
; Ipp64u cpAddSub_BNU(Ipp64u* pDst,
; const Ipp64u* pSrcA,
; const Ipp64u* pSrcB,
; const Ipp64u* pSrcC,
; int len );
; returns positive borrow
;*************************************************************
align IPP_ALIGN_FACTOR
IPPASM cpAddSub_BNU,PUBLIC
%assign LOCAL_FRAME 0
USES_GPR rsi,rdi,rbx,rbp,r12,r13,r14
USES_XMM
COMP_ABI 5
; rdi = pDst
; rsi = pSrcA
; rdx = pSrcB
; rcx = pSrcC
; r8 = len
movsxd r8, r8d ; length
xor rax, rax
xor rbx, rbx
cmp r8, 2
jge .ADD_GE2
;********** lenSrcA == 1 *************************************
add rax, rax
mov r8, qword [rsi] ; rsi = a
adc r8, qword [rdx] ; r8 = a+b
sbb rax, rax ;
add rbx, rbx
sbb r8, qword [rcx] ; r8 = a+b-c = s
mov qword [rdi], r8 ;
sbb rbx, rbx ;
jmp .FINAL
;********** lenSrcA == 1 END ********************************
.ADD_GE2:
jg .ADD_GT2
;********** lenSrcA == 2 *************************************
add rax, rax
mov r8, qword [rsi] ; r8 = a0
adc r8, qword [rdx] ; r8 = a0+b0
mov r9, qword [rsi+8] ; r9 = a1
adc r9, qword [rdx+8] ; r9 = a1+b1
sbb rax, rax ; rax = carry
add rbx, rbx
sbb r8, qword [rcx] ; r8 = a0+b0-c0 = s0
mov qword [rdi], r8 ; save s0
sbb r9, qword [rcx+8] ; r9 = a1+b1-c1 = s1
mov qword [rdi+8], r9 ; save s1
sbb rbx, rbx ;
jmp .FINAL
;********** lenSrcA == 2 END *********************************
.ADD_GT2:
cmp r8, 4
jge .ADD_GE4
;********** lenSrcA == 3 *************************************
add rax, rax
mov r8, qword [rsi] ; r8 = a0
adc r8, qword [rdx] ; r8 = a0+b0
mov r9, qword [rsi+8] ; r9 = a1
adc r9, qword [rdx+8] ; r9 = a1+b1
mov r10, qword [rsi+16] ; r10 = a2
adc r10, qword [rdx+16] ; r10 = a2+b2
sbb rax, rax ; rax = carry
add rbx, rbx
sbb r8, qword [rcx] ; r8 = a0+b0-c0 = s0
mov qword [rdi], r8 ; save s0
sbb r9, qword [rcx+8] ; r9 = a1+b1-c1 = s1
mov qword [rdi+8], r9 ; save s1
sbb r10, qword [rcx+16] ; r10 = a2+b2-c2 = s2
mov qword [rdi+16], r10 ; save s2
sbb rbx, rbx ;
jmp .FINAL
;********** lenSrcA == 3 END *********************************
.ADD_GE4:
jg .ADD_GT4
;********** lenSrcA == 4 *************************************
add rax, rax
mov r8, qword [rsi] ; r8 = a0
adc r8, qword [rdx] ; r8 = a0+b0
mov r9, qword [rsi+8] ; r9 = a1
adc r9, qword [rdx+8] ; r9 = a1+b1
mov r10, qword [rsi+16] ; r10 = a2
adc r10, qword [rdx+16] ; r10 = a2+b2
mov r11, qword [rsi+24] ; r11 = a3
adc r11, qword [rdx+24] ; r11 = a3+b3
sbb rax, rax ; rax = carry
add rbx, rbx
sbb r8, qword [rcx] ; r8 = a0+b0-c0 = s0
mov qword [rdi], r8 ; save s0
sbb r9, qword [rcx+8] ; r9 = a1+b1-c1 = s1
mov qword [rdi+8], r9 ; save s1
sbb r10, qword [rcx+16] ; r10 = a2+b2-c2 = s2
mov qword [rdi+16], r10 ; save s2
sbb r11, qword [rcx+24] ; r11 = a3+b3-c3 = s3
mov qword [rdi+24], r11 ; save s2
sbb rbx, rbx ; rax = carry
jmp .FINAL
;********** lenSrcA == 4 END *********************************
.ADD_GT4:
cmp r8, 6
jge .ADD_GE6
;********** lenSrcA == 5 *************************************
add rax, rax
mov r8, qword [rsi] ; r8 = a0
adc r8, qword [rdx] ; r8 = a0+b0
mov r9, qword [rsi+8] ; r9 = a1
adc r9, qword [rdx+8] ; r9 = a1+b1
mov r10, qword [rsi+16] ; r10 = a2
adc r10, qword [rdx+16] ; r10 = a2+b2
mov r11, qword [rsi+24] ; r11 = a3
adc r11, qword [rdx+24] ; r11 = a3+b3
mov rsi, qword [rsi+32] ; rsi = a4
adc rsi, qword [rdx+32] ; rsi = a4+b4
sbb rax, rax ; rax = carry
add rbx, rbx
sbb r8, qword [rcx] ; r8 = a0+b0-c0 = s0
mov qword [rdi], r8 ; save s0
sbb r9, qword [rcx+8] ; r9 = a1+b1-c1 = s1
mov qword [rdi+8], r9 ; save s1
sbb r10, qword [rcx+16] ; r10 = a2+b2-c2 = s2
mov qword [rdi+16], r10 ; save s2
sbb r11, qword [rcx+24] ; r11 = a3+b3-c3 = s3
mov qword [rdi+24], r11 ; save s3
sbb rsi, qword [rcx+32] ; rsi = a4+b4-c4 = s4
mov qword [rdi+32], rsi ; save s4
sbb rbx, rbx ; rax = carry
jmp .FINAL
;********** lenSrcA == 5 END *********************************
.ADD_GE6:
jg .ADD_GT6
;********** lenSrcA == 6 *************************************
add rax, rax
mov r8, qword [rsi] ; r8 = a0
adc r8, qword [rdx] ; r8 = a0+b0
mov r9, qword [rsi+8] ; r9 = a1
adc r9, qword [rdx+8] ; r9 = a1+b1
mov r10, qword [rsi+16] ; r10 = a2
adc r10, qword [rdx+16] ; r10 = a2+b2
mov r11, qword [rsi+24] ; r11 = a3
adc r11, qword [rdx+24] ; r11 = a3+b3
mov r12, qword [rsi+32] ; r12 = a4
adc r12, qword [rdx+32] ; r12 = a4+b4
mov rsi, qword [rsi+40] ; rsi = a5
adc rsi, qword [rdx+40] ; rsi = a5+b5
sbb rax, rax ; rax = carry
add rbx, rbx
sbb r8, qword [rcx] ; r8 = a0+b0-c0 = s0
mov qword [rdi], r8 ; save s0
sbb r9, qword [rcx+8] ; r9 = a1+b1-c1 = s1
mov qword [rdi+8], r9 ; save s1
sbb r10, qword [rcx+16] ; r10 = a2+b2-c2 = s2
mov qword [rdi+16], r10 ; save s2
sbb r11, qword [rcx+24] ; r11 = a3+b3-c3 = s3
mov qword [rdi+24], r11 ; save s3
sbb r12, qword [rcx+32] ; r12 = a4+b4-c4 = s4
mov qword [rdi+32], r12 ; save s4
sbb rsi, qword [rcx+40] ; rsi = a5+b5-c5 = s5
mov qword [rdi+40], rsi ; save s5
sbb rbx, rbx ; rax = carry
jmp .FINAL
;********** lenSrcA == 6 END *********************************
.ADD_GT6:
cmp r8, 8
jge .ADD_GE8
.ADD_EQ7:
;********** lenSrcA == 7 *************************************
add rax, rax
mov r8, qword [rsi] ; r8 = a0
adc r8, qword [rdx] ; r8 = a0+b0 = s0
mov r9, qword [rsi+8] ; r9 = a1
adc r9, qword [rdx+8] ; r9 = a1+b1 = s1
mov r10, qword [rsi+16] ; r10 = a2
adc r10, qword [rdx+16] ; r10 = a2+b2 = s2
mov r11, qword [rsi+24] ; r11 = a3
adc r11, qword [rdx+24] ; r11 = a3+b3 = s3
mov r12, qword [rsi+32] ; r12 = a4
adc r12, qword [rdx+32] ; r12 = a4+b4 = s4
mov r13, qword [rsi+40] ; r13 = a5
adc r13, qword [rdx+40] ; r13 = a5+b5 = s5
mov rsi, qword [rsi+48] ; rsi = a6
adc rsi, qword [rdx+48] ; rsi = a6+b6 = s6
sbb rax, rax ; rax = carry
add rbx, rbx
sbb r8, qword [rcx] ; r8 = a0+b0-c0 = s0
mov qword [rdi], r8 ; save s0
sbb r9, qword [rcx+8] ; r9 = a1+b1-c1 = s1
mov qword [rdi+8], r9 ; save s1
sbb r10, qword [rcx+16] ; r10 = a2+b2-c2 = s2
mov qword [rdi+16], r10 ; save s2
sbb r11, qword [rcx+24] ; r11 = a3+b3-c3 = s3
mov qword [rdi+24], r11 ; save s3
sbb r12, qword [rcx+32] ; r12 = a4+b4-c4 = s4
mov qword [rdi+32], r12 ; save s4
sbb r13, qword [rcx+40] ; r13 = a5+b5-c5 = s5
mov qword [rdi+40], r13 ; save s5
sbb rsi, qword [rcx+48] ; rsi = a6+b6-c6 = s6
mov qword [rdi+48], rsi ; save s6
sbb rbx, rbx ; rax = carry
jmp .FINAL
;********** lenSrcA == 7 END *********************************
.ADD_GE8:
jg .ADD_GT8
;********** lenSrcA == 8 *************************************
add rax, rax
mov r8, qword [rsi] ; r8 = a0
adc r8, qword [rdx] ; r8 = a0+b0 = s0
mov r9, qword [rsi+8] ; r9 = a1
adc r9, qword [rdx+8] ; r9 = a1+b1 = s1
mov r10, qword [rsi+16] ; r10 = a2
adc r10, qword [rdx+16] ; r10 = a2+b2 = s2
mov r11, qword [rsi+24] ; r11 = a3
adc r11, qword [rdx+24] ; r11 = a3+b3 = s3
mov r12, qword [rsi+32] ; r12 = a4
adc r12, qword [rdx+32] ; r12 = a4+b4 = s4
mov r13, qword [rsi+40] ; r13 = a5
adc r13, qword [rdx+40] ; r13 = a5+b5 = s5
mov r14, qword [rsi+48] ; r14 = a6
adc r14, qword [rdx+48] ; r14 = a6+b6 = s6
mov rsi, qword [rsi+56] ; rsi = a7
adc rsi, qword [rdx+56] ; rsi = a7+b7 = s7
sbb rax, rax ; rax = carry
add rbx, rbx
sbb r8, qword [rcx] ; r8 = a0+b0-c0 = s0
mov qword [rdi], r8 ; save s0
sbb r9, qword [rcx+8] ; r9 = a1+b1-c1 = s1
mov qword [rdi+8], r9 ; save s1
sbb r10, qword [rcx+16] ; r10 = a2+b2-c2 = s2
mov qword [rdi+16], r10 ; save s2
sbb r11, qword [rcx+24] ; r11 = a3+b3-c3 = s3
mov qword [rdi+24], r11 ; save s3
sbb r12, qword [rcx+32] ; r12 = a4+b4-c4 = s4
mov qword [rdi+32], r12 ; save s4
sbb r13, qword [rcx+40] ; r13 = a5+b5-c5 = s5
mov qword [rdi+40], r13 ; save s5
sbb r14, qword [rcx+48] ; r14 = a6+b6-c6 = s6
mov qword [rdi+48], r14 ; save s6
sbb rsi, qword [rcx+56] ; rsi = a7+b7-c7 = s7
mov qword [rdi+56], rsi ; save s7
sbb rbx, rbx ; rax = carry
jmp .FINAL
;********** lenSrcA == 8 END *********************************
;********** lenSrcA > 8 *************************************
.ADD_GT8:
mov rbp, rcx ; pC
mov rcx, r8 ; length
and r8, 3 ; length%4
xor rcx, r8 ; length/4
lea rsi, [rsi+rcx*sizeof(qword)]
lea rdx, [rdx+rcx*sizeof(qword)]
lea rbp, [rbp+rcx*sizeof(qword)]
lea rdi, [rdi+rcx*sizeof(qword)]
neg rcx
jmp .SUB_GLOOP
align IPP_ALIGN_FACTOR
.SUB_GLOOP:
add rax, rax
mov r9, qword [rsi+sizeof(qword)*rcx] ; r8 = a0
mov r10, qword [rsi+sizeof(qword)*rcx+sizeof(qword)] ; r9 = a1
mov r11, qword [rsi+sizeof(qword)*rcx+sizeof(qword)*2] ; r10 = a2
mov r12, qword [rsi+sizeof(qword)*rcx+sizeof(qword)*3] ; r11 = a3
adc r9, qword [rdx+sizeof(qword)*rcx] ; r8 = a0+b0
adc r10, qword [rdx+sizeof(qword)*rcx+sizeof(qword)] ; r9 = a1+b1
adc r11, qword [rdx+sizeof(qword)*rcx+sizeof(qword)*2] ; r10 = a2+b2
adc r12, qword [rdx+sizeof(qword)*rcx+sizeof(qword)*3] ; r11 = a3+b3
sbb rax, rax
add rbx, rbx
sbb r9, qword [rbp+sizeof(qword)*rcx] ; r8 = a0+b0+c0
mov qword [rdi+sizeof(qword)*rcx], r9
sbb r10, qword [rbp+sizeof(qword)*rcx+sizeof(qword)] ; r9 = a1+b1+c1
mov qword [rdi+sizeof(qword)*rcx+sizeof(qword)], r10
sbb r11, qword [rbp+sizeof(qword)*rcx+sizeof(qword)*2] ; r10 = a2+b2+c2
mov qword [rdi+sizeof(qword)*rcx+sizeof(qword)*2], r11
sbb r12, qword [rbp+sizeof(qword)*rcx+sizeof(qword)*3] ; r11 = a3+b3+c3
mov qword [rdi+sizeof(qword)*rcx+sizeof(qword)*3], r12
sbb rbx, rbx
lea rcx, [rcx+4]
jrcxz .EXIT_LOOP
jmp .SUB_GLOOP
.EXIT_LOOP:
test r8, r8
jz .FINAL
.SUB_LAST2:
test r8, 2
jz .SUB_LAST1
add rax, rax
mov r9, qword [rsi] ; r8 = a0
mov r10, qword [rsi+sizeof(qword)] ; r9 = a1
lea rsi, [rsi+sizeof(qword)*2]
adc r9, qword [rdx] ; r8 = a0+b0
adc r10, qword [rdx+sizeof(qword)] ; r9 = a1+b1
lea rdx, [rdx+sizeof(qword)*2]
sbb rax, rax
add rbx, rbx
sbb r9, qword [rbp] ; r8 = a0+b0+c0
mov qword [rdi], r9
sbb r10, qword [rbp+sizeof(qword)] ; r9 = a1+b1+c1
mov qword [rdi+sizeof(qword)], r10
lea rbp, [rbp+sizeof(qword)*2]
lea rdi, [rdi+sizeof(qword)*2]
sbb rbx, rbx
test r8, 1
jz .FINAL
.SUB_LAST1:
add rax, rax
mov r9, qword [rsi] ; r8 = a0
adc r9, qword [rdx] ; r8 = a0+b0
sbb rax, rax
add rbx, rbx
sbb r9, qword [rbp] ; r8 = a0+b0+c0 = s0
mov qword [rdi], r9
sbb rbx, rbx
;******************* .FINAL ***********************************************************
.FINAL:
sub rax, rbx
neg rax
REST_XMM
REST_GPR
ret
ENDFUNC cpAddSub_BNU
%endif ;; _IPP32E_M7
%endif ;; _ENABLE_KARATSUBA_
|
; A334940: Partial sums of A230595.
; Submitted by Christian Krause
; 0,0,0,1,1,3,3,3,4,6,6,6,6,8,10,10,10,10,10,10,12,14,14,14,15,17,17,17,17,17,17,17,19,21,23,23,23,25,27,27,27,27,27,27,27,29,29,29,30,30,32,32,32,32,34,34,36,38,38,38,38,40,40,40,42,42,42,42,44,44,44,44,44,46,46,46,48,48,48,48,48,50,50,50,52,54,56,56,56,56,58,58,60,62,64,64,64,64,64,64
mov $2,$0
mov $4,$0
lpb $4
mov $0,$2
sub $4,1
sub $0,$4
mov $1,$0
seq $0,1221 ; Number of distinct primes dividing n (also called omega(n)).
seq $1,86436 ; Maximum number of parts possible in a factorization of n; a(1) = 1, and for n > 1, a(n) = A001222(n) = bigomega(n).
sub $1,1
cmp $1,1
mul $0,$1
add $3,$0
lpe
mov $0,$3
|
; void *p_stack_top(p_stack_t *s)
SECTION code_adt_p_stack
PUBLIC _p_stack_top
EXTERN _p_forward_list_front
defc _p_stack_top = _p_forward_list_front
|
# C1-0--0
ldsi s0, 3 # 0
ldsi s1, 4 # 1
subs s3, s0, s1 # 2
bit s195 # 3
adds s114, s195, s195 # 4
bit s155 # 5
adds s196, s114, s155 # 6
adds s115, s196, s196 # 7
bit s156 # 8
adds s197, s115, s156 # 9
adds s116, s197, s197 # 10
bit s157 # 11
adds s198, s116, s157 # 12
adds s117, s198, s198 # 13
bit s158 # 14
adds s199, s117, s158 # 15
adds s118, s199, s199 # 16
bit s159 # 17
adds s200, s118, s159 # 18
adds s119, s200, s200 # 19
bit s160 # 20
adds s201, s119, s160 # 21
adds s120, s201, s201 # 22
bit s161 # 23
adds s202, s120, s161 # 24
adds s121, s202, s202 # 25
bit s162 # 26
adds s203, s121, s162 # 27
adds s122, s203, s203 # 28
bit s163 # 29
adds s204, s122, s163 # 30
adds s123, s204, s204 # 31
bit s164 # 32
adds s205, s123, s164 # 33
adds s124, s205, s205 # 34
bit s165 # 35
adds s206, s124, s165 # 36
adds s125, s206, s206 # 37
bit s166 # 38
adds s207, s125, s166 # 39
adds s126, s207, s207 # 40
bit s167 # 41
adds s208, s126, s167 # 42
adds s127, s208, s208 # 43
bit s168 # 44
adds s209, s127, s168 # 45
adds s128, s209, s209 # 46
bit s169 # 47
adds s210, s128, s169 # 48
adds s129, s210, s210 # 49
bit s170 # 50
adds s211, s129, s170 # 51
adds s130, s211, s211 # 52
bit s171 # 53
adds s212, s130, s171 # 54
adds s131, s212, s212 # 55
bit s172 # 56
adds s213, s131, s172 # 57
adds s132, s213, s213 # 58
bit s173 # 59
adds s214, s132, s173 # 60
adds s133, s214, s214 # 61
bit s174 # 62
adds s215, s133, s174 # 63
adds s134, s215, s215 # 64
bit s175 # 65
adds s216, s134, s175 # 66
adds s135, s216, s216 # 67
bit s176 # 68
adds s217, s135, s176 # 69
adds s136, s217, s217 # 70
bit s177 # 71
adds s218, s136, s177 # 72
adds s137, s218, s218 # 73
bit s178 # 74
adds s219, s137, s178 # 75
adds s138, s219, s219 # 76
bit s179 # 77
adds s220, s138, s179 # 78
adds s139, s220, s220 # 79
bit s180 # 80
adds s221, s139, s180 # 81
adds s140, s221, s221 # 82
bit s181 # 83
adds s222, s140, s181 # 84
adds s141, s222, s222 # 85
bit s182 # 86
adds s223, s141, s182 # 87
adds s142, s223, s223 # 88
bit s183 # 89
adds s224, s142, s183 # 90
adds s143, s224, s224 # 91
bit s184 # 92
adds s225, s143, s184 # 93
adds s144, s225, s225 # 94
bit s185 # 95
adds s226, s144, s185 # 96
adds s145, s226, s226 # 97
bit s186 # 98
adds s227, s145, s186 # 99
adds s146, s227, s227 # 100
bit s187 # 101
adds s228, s146, s187 # 102
adds s147, s228, s228 # 103
bit s188 # 104
adds s229, s147, s188 # 105
adds s148, s229, s229 # 106
bit s189 # 107
adds s230, s148, s189 # 108
adds s149, s230, s230 # 109
bit s190 # 110
adds s231, s149, s190 # 111
adds s150, s231, s231 # 112
bit s191 # 113
adds s232, s150, s191 # 114
adds s151, s232, s232 # 115
bit s192 # 116
adds s233, s151, s192 # 117
adds s152, s233, s233 # 118
bit s193 # 119
adds s234, s152, s193 # 120
adds s153, s234, s234 # 121
bit s194 # 122
adds s7, s153, s194 # 123
bit s40 # 124
adds s51, s40, s40 # 125
bit s39 # 126
adds s52, s51, s39 # 127
adds s53, s52, s52 # 128
bit s38 # 129
adds s54, s53, s38 # 130
adds s55, s54, s54 # 131
bit s37 # 132
adds s56, s55, s37 # 133
adds s57, s56, s56 # 134
bit s36 # 135
adds s58, s57, s36 # 136
adds s59, s58, s58 # 137
bit s35 # 138
adds s60, s59, s35 # 139
adds s61, s60, s60 # 140
bit s34 # 141
adds s62, s61, s34 # 142
adds s63, s62, s62 # 143
bit s33 # 144
adds s64, s63, s33 # 145
adds s65, s64, s64 # 146
bit s32 # 147
adds s66, s65, s32 # 148
adds s67, s66, s66 # 149
bit s31 # 150
adds s68, s67, s31 # 151
adds s69, s68, s68 # 152
bit s30 # 153
adds s70, s69, s30 # 154
adds s71, s70, s70 # 155
bit s29 # 156
adds s72, s71, s29 # 157
adds s73, s72, s72 # 158
bit s28 # 159
adds s74, s73, s28 # 160
adds s75, s74, s74 # 161
bit s27 # 162
adds s76, s75, s27 # 163
adds s77, s76, s76 # 164
bit s26 # 165
adds s78, s77, s26 # 166
adds s79, s78, s78 # 167
bit s25 # 168
adds s80, s79, s25 # 169
adds s81, s80, s80 # 170
bit s24 # 171
adds s82, s81, s24 # 172
adds s83, s82, s82 # 173
bit s23 # 174
adds s84, s83, s23 # 175
adds s85, s84, s84 # 176
bit s22 # 177
adds s86, s85, s22 # 178
adds s87, s86, s86 # 179
bit s21 # 180
adds s88, s87, s21 # 181
adds s89, s88, s88 # 182
bit s20 # 183
adds s90, s89, s20 # 184
adds s91, s90, s90 # 185
bit s19 # 186
adds s92, s91, s19 # 187
adds s93, s92, s92 # 188
bit s18 # 189
adds s94, s93, s18 # 190
adds s95, s94, s94 # 191
bit s17 # 192
adds s96, s95, s17 # 193
adds s97, s96, s96 # 194
bit s16 # 195
adds s98, s97, s16 # 196
adds s99, s98, s98 # 197
bit s15 # 198
adds s100, s99, s15 # 199
adds s101, s100, s100 # 200
bit s14 # 201
adds s102, s101, s14 # 202
adds s103, s102, s102 # 203
bit s13 # 204
adds s104, s103, s13 # 205
adds s105, s104, s104 # 206
bit s12 # 207
adds s106, s105, s12 # 208
adds s107, s106, s106 # 209
bit s11 # 210
adds s108, s107, s11 # 211
adds s109, s108, s108 # 212
bit s10 # 213
adds s110, s109, s10 # 214
adds s111, s110, s110 # 215
bit s9 # 216
adds s112, s111, s9 # 217
movs s8, s112 # 218
ldi c8, 4 # 219
mulci c9, c8, 1073741824 # 220
movc c6, c9 # 221
mulm s43, s7, c6 # 222
ldi c10, 4 # 223
mulci c11, c10, 1073741824 # 224
movc c7, c11 # 225
addm s44, s3, c7 # 226
adds s45, s43, s44 # 227
adds s46, s45, s8 # 228
startopen 1, s46 # 229
stopopen 1, c4 # 230
modc c5, c4, c6 # 231
modci c12, c5, 2 # 232
subc c45, c5, c12 # 233
ldi c108, 1 # 234
divci c109, c108, 2 # 235
mulc c77, c45, c109 # 236
modci c13, c77, 2 # 237
subc c46, c77, c13 # 238
mulc c78, c46, c109 # 239
modci c14, c78, 2 # 240
subc c47, c78, c14 # 241
mulc c79, c47, c109 # 242
modci c15, c79, 2 # 243
subc c48, c79, c15 # 244
mulc c80, c48, c109 # 245
modci c16, c80, 2 # 246
subc c49, c80, c16 # 247
mulc c81, c49, c109 # 248
modci c17, c81, 2 # 249
subc c50, c81, c17 # 250
mulc c82, c50, c109 # 251
modci c18, c82, 2 # 252
subc c51, c82, c18 # 253
mulc c83, c51, c109 # 254
modci c19, c83, 2 # 255
subc c52, c83, c19 # 256
mulc c84, c52, c109 # 257
modci c20, c84, 2 # 258
subc c53, c84, c20 # 259
mulc c85, c53, c109 # 260
modci c21, c85, 2 # 261
subc c54, c85, c21 # 262
mulc c86, c54, c109 # 263
modci c22, c86, 2 # 264
subc c55, c86, c22 # 265
mulc c87, c55, c109 # 266
modci c23, c87, 2 # 267
subc c56, c87, c23 # 268
mulc c88, c56, c109 # 269
modci c24, c88, 2 # 270
subc c57, c88, c24 # 271
mulc c89, c57, c109 # 272
modci c25, c89, 2 # 273
subc c58, c89, c25 # 274
mulc c90, c58, c109 # 275
modci c26, c90, 2 # 276
subc c59, c90, c26 # 277
mulc c91, c59, c109 # 278
modci c27, c91, 2 # 279
subc c60, c91, c27 # 280
mulc c92, c60, c109 # 281
modci c28, c92, 2 # 282
subc c61, c92, c28 # 283
mulc c93, c61, c109 # 284
modci c29, c93, 2 # 285
subc c62, c93, c29 # 286
mulc c94, c62, c109 # 287
modci c30, c94, 2 # 288
subc c63, c94, c30 # 289
mulc c95, c63, c109 # 290
modci c31, c95, 2 # 291
subc c64, c95, c31 # 292
mulc c96, c64, c109 # 293
modci c32, c96, 2 # 294
subc c65, c96, c32 # 295
mulc c97, c65, c109 # 296
modci c33, c97, 2 # 297
subc c66, c97, c33 # 298
mulc c98, c66, c109 # 299
modci c34, c98, 2 # 300
subc c67, c98, c34 # 301
mulc c99, c67, c109 # 302
modci c35, c99, 2 # 303
subc c68, c99, c35 # 304
mulc c100, c68, c109 # 305
modci c36, c100, 2 # 306
subc c69, c100, c36 # 307
mulc c101, c69, c109 # 308
modci c37, c101, 2 # 309
subc c70, c101, c37 # 310
mulc c102, c70, c109 # 311
modci c38, c102, 2 # 312
subc c71, c102, c38 # 313
mulc c103, c71, c109 # 314
modci c39, c103, 2 # 315
subc c72, c103, c39 # 316
mulc c104, c72, c109 # 317
modci c40, c104, 2 # 318
subc c73, c104, c40 # 319
mulc c105, c73, c109 # 320
modci c41, c105, 2 # 321
subc c74, c105, c41 # 322
mulc c106, c74, c109 # 323
modci c42, c106, 2 # 324
subc c75, c106, c42 # 325
mulc c107, c75, c109 # 326
modci c43, c107, 2 # 327
subsfi s236, s9, 1 # 328
subsfi s237, s10, 1 # 329
subsfi s238, s11, 1 # 330
subsfi s239, s12, 1 # 331
subsfi s240, s13, 1 # 332
subsfi s241, s14, 1 # 333
subsfi s242, s15, 1 # 334
subsfi s243, s16, 1 # 335
subsfi s244, s17, 1 # 336
subsfi s245, s18, 1 # 337
subsfi s246, s19, 1 # 338
subsfi s247, s20, 1 # 339
subsfi s248, s21, 1 # 340
subsfi s249, s22, 1 # 341
subsfi s250, s23, 1 # 342
subsfi s251, s24, 1 # 343
subsfi s252, s25, 1 # 344
subsfi s253, s26, 1 # 345
subsfi s254, s27, 1 # 346
subsfi s255, s28, 1 # 347
subsfi s256, s29, 1 # 348
subsfi s257, s30, 1 # 349
subsfi s258, s31, 1 # 350
subsfi s259, s32, 1 # 351
subsfi s260, s33, 1 # 352
subsfi s261, s34, 1 # 353
subsfi s262, s35, 1 # 354
subsfi s263, s36, 1 # 355
subsfi s264, s37, 1 # 356
subsfi s265, s38, 1 # 357
subsfi s266, s39, 1 # 358
subsfi s267, s40, 1 # 359
mulm s333, s267, c43 # 360
mulsi s365, s333, 2 # 361
addm s397, s267, c43 # 362
subs s429, s397, s365 # 363
mulm s334, s266, c42 # 364
mulsi s366, s334, 2 # 365
addm s398, s266, c42 # 366
subs s430, s398, s366 # 367
mulm s335, s265, c41 # 368
mulsi s367, s335, 2 # 369
addm s399, s265, c41 # 370
subs s431, s399, s367 # 371
mulm s336, s264, c40 # 372
mulsi s368, s336, 2 # 373
addm s400, s264, c40 # 374
subs s432, s400, s368 # 375
mulm s337, s263, c39 # 376
mulsi s369, s337, 2 # 377
addm s401, s263, c39 # 378
subs s433, s401, s369 # 379
mulm s338, s262, c38 # 380
mulsi s370, s338, 2 # 381
addm s402, s262, c38 # 382
subs s434, s402, s370 # 383
mulm s339, s261, c37 # 384
mulsi s371, s339, 2 # 385
addm s403, s261, c37 # 386
subs s435, s403, s371 # 387
mulm s340, s260, c36 # 388
mulsi s372, s340, 2 # 389
addm s404, s260, c36 # 390
subs s436, s404, s372 # 391
mulm s341, s259, c35 # 392
mulsi s373, s341, 2 # 393
addm s405, s259, c35 # 394
subs s437, s405, s373 # 395
mulm s342, s258, c34 # 396
mulsi s374, s342, 2 # 397
addm s406, s258, c34 # 398
subs s438, s406, s374 # 399
mulm s343, s257, c33 # 400
mulsi s375, s343, 2 # 401
addm s407, s257, c33 # 402
subs s439, s407, s375 # 403
mulm s344, s256, c32 # 404
mulsi s376, s344, 2 # 405
addm s408, s256, c32 # 406
subs s440, s408, s376 # 407
mulm s345, s255, c31 # 408
mulsi s377, s345, 2 # 409
addm s409, s255, c31 # 410
subs s441, s409, s377 # 411
mulm s346, s254, c30 # 412
mulsi s378, s346, 2 # 413
addm s410, s254, c30 # 414
subs s442, s410, s378 # 415
mulm s347, s253, c29 # 416
mulsi s379, s347, 2 # 417
addm s411, s253, c29 # 418
subs s443, s411, s379 # 419
mulm s348, s252, c28 # 420
mulsi s380, s348, 2 # 421
addm s412, s252, c28 # 422
subs s444, s412, s380 # 423
mulm s349, s251, c27 # 424
mulsi s381, s349, 2 # 425
addm s413, s251, c27 # 426
subs s445, s413, s381 # 427
mulm s350, s250, c26 # 428
mulsi s382, s350, 2 # 429
addm s414, s250, c26 # 430
subs s446, s414, s382 # 431
mulm s351, s249, c25 # 432
mulsi s383, s351, 2 # 433
addm s415, s249, c25 # 434
subs s447, s415, s383 # 435
mulm s352, s248, c24 # 436
mulsi s384, s352, 2 # 437
addm s416, s248, c24 # 438
subs s448, s416, s384 # 439
mulm s353, s247, c23 # 440
mulsi s385, s353, 2 # 441
addm s417, s247, c23 # 442
subs s449, s417, s385 # 443
mulm s354, s246, c22 # 444
mulsi s386, s354, 2 # 445
addm s418, s246, c22 # 446
subs s450, s418, s386 # 447
mulm s355, s245, c21 # 448
mulsi s387, s355, 2 # 449
addm s419, s245, c21 # 450
subs s451, s419, s387 # 451
mulm s356, s244, c20 # 452
mulsi s388, s356, 2 # 453
addm s420, s244, c20 # 454
subs s452, s420, s388 # 455
mulm s357, s243, c19 # 456
mulsi s389, s357, 2 # 457
addm s421, s243, c19 # 458
subs s453, s421, s389 # 459
mulm s358, s242, c18 # 460
mulsi s390, s358, 2 # 461
addm s422, s242, c18 # 462
subs s454, s422, s390 # 463
mulm s359, s241, c17 # 464
mulsi s391, s359, 2 # 465
addm s423, s241, c17 # 466
subs s455, s423, s391 # 467
mulm s360, s240, c16 # 468
mulsi s392, s360, 2 # 469
addm s424, s240, c16 # 470
subs s456, s424, s392 # 471
mulm s361, s239, c15 # 472
mulsi s393, s361, 2 # 473
addm s425, s239, c15 # 474
subs s457, s425, s393 # 475
mulm s362, s238, c14 # 476
mulsi s394, s362, 2 # 477
addm s426, s238, c14 # 478
subs s458, s426, s394 # 479
mulm s363, s237, c13 # 480
mulsi s395, s363, 2 # 481
addm s427, s237, c13 # 482
subs s459, s427, s395 # 483
mulm s364, s236, c12 # 484
mulsi s396, s364, 2 # 485
addm s428, s236, c12 # 486
subs s460, s428, s396 # 487
mulsi s461, s460, 1 # 488
adds s462, s364, s461 # 489
triple s467, s468, s469 # 490
subs s470, s429, s467 # 491
subs s471, s430, s468 # 492
startopen 2, s470, s471 # 493
stopopen 2, c110, c111 # 494
mulm s472, s468, c110 # 495
mulm s473, s467, c111 # 496
mulc c112, c110, c111 # 497
adds s474, s469, s472 # 498
adds s475, s474, s473 # 499
addm s464, s475, c112 # 500
triple s476, s477, s478 # 501
subs s479, s429, s476 # 502
subs s480, s334, s477 # 503
startopen 2, s479, s480 # 504
stopopen 2, c113, c114 # 505
mulm s481, s477, c113 # 506
mulm s482, s476, c114 # 507
mulc c115, c113, c114 # 508
adds s483, s478, s481 # 509
adds s484, s483, s482 # 510
addm s465, s484, c115 # 511
adds s466, s333, s465 # 512
triple s488, s489, s490 # 513
subs s491, s431, s488 # 514
subs s492, s432, s489 # 515
startopen 2, s491, s492 # 516
stopopen 2, c116, c117 # 517
mulm s493, s489, c116 # 518
mulm s494, s488, c117 # 519
mulc c118, c116, c117 # 520
adds s495, s490, s493 # 521
adds s496, s495, s494 # 522
addm s485, s496, c118 # 523
triple s497, s498, s499 # 524
subs s500, s431, s497 # 525
subs s501, s336, s498 # 526
startopen 2, s500, s501 # 527
stopopen 2, c119, c120 # 528
mulm s502, s498, c119 # 529
mulm s503, s497, c120 # 530
mulc c121, c119, c120 # 531
adds s504, s499, s502 # 532
adds s505, s504, s503 # 533
addm s486, s505, c121 # 534
adds s487, s335, s486 # 535
triple s509, s510, s511 # 536
subs s512, s433, s509 # 537
subs s513, s434, s510 # 538
startopen 2, s512, s513 # 539
stopopen 2, c122, c123 # 540
mulm s514, s510, c122 # 541
mulm s515, s509, c123 # 542
mulc c124, c122, c123 # 543
adds s516, s511, s514 # 544
adds s517, s516, s515 # 545
addm s506, s517, c124 # 546
triple s518, s519, s520 # 547
subs s521, s433, s518 # 548
subs s522, s338, s519 # 549
startopen 2, s521, s522 # 550
stopopen 2, c125, c126 # 551
mulm s523, s519, c125 # 552
mulm s524, s518, c126 # 553
mulc c127, c125, c126 # 554
adds s525, s520, s523 # 555
adds s526, s525, s524 # 556
addm s507, s526, c127 # 557
adds s508, s337, s507 # 558
triple s530, s531, s532 # 559
subs s533, s435, s530 # 560
subs s534, s436, s531 # 561
startopen 2, s533, s534 # 562
stopopen 2, c128, c129 # 563
mulm s535, s531, c128 # 564
mulm s536, s530, c129 # 565
mulc c130, c128, c129 # 566
adds s537, s532, s535 # 567
adds s538, s537, s536 # 568
addm s527, s538, c130 # 569
triple s539, s540, s541 # 570
subs s542, s435, s539 # 571
subs s543, s340, s540 # 572
startopen 2, s542, s543 # 573
stopopen 2, c131, c132 # 574
mulm s544, s540, c131 # 575
mulm s545, s539, c132 # 576
mulc c133, c131, c132 # 577
adds s546, s541, s544 # 578
adds s547, s546, s545 # 579
addm s528, s547, c133 # 580
adds s529, s339, s528 # 581
triple s551, s552, s553 # 582
subs s554, s437, s551 # 583
subs s555, s438, s552 # 584
startopen 2, s554, s555 # 585
stopopen 2, c134, c135 # 586
mulm s556, s552, c134 # 587
mulm s557, s551, c135 # 588
mulc c136, c134, c135 # 589
adds s558, s553, s556 # 590
adds s559, s558, s557 # 591
addm s548, s559, c136 # 592
triple s560, s561, s562 # 593
subs s563, s437, s560 # 594
subs s564, s342, s561 # 595
startopen 2, s563, s564 # 596
stopopen 2, c137, c138 # 597
mulm s565, s561, c137 # 598
mulm s566, s560, c138 # 599
mulc c139, c137, c138 # 600
adds s567, s562, s565 # 601
adds s568, s567, s566 # 602
addm s549, s568, c139 # 603
adds s550, s341, s549 # 604
triple s572, s573, s574 # 605
subs s575, s439, s572 # 606
subs s576, s440, s573 # 607
startopen 2, s575, s576 # 608
stopopen 2, c140, c141 # 609
mulm s577, s573, c140 # 610
mulm s578, s572, c141 # 611
mulc c142, c140, c141 # 612
adds s579, s574, s577 # 613
adds s580, s579, s578 # 614
addm s569, s580, c142 # 615
triple s581, s582, s583 # 616
subs s584, s439, s581 # 617
subs s585, s344, s582 # 618
startopen 2, s584, s585 # 619
stopopen 2, c143, c144 # 620
mulm s586, s582, c143 # 621
mulm s587, s581, c144 # 622
mulc c145, c143, c144 # 623
adds s588, s583, s586 # 624
adds s589, s588, s587 # 625
addm s570, s589, c145 # 626
adds s571, s343, s570 # 627
triple s593, s594, s595 # 628
subs s596, s441, s593 # 629
subs s597, s442, s594 # 630
startopen 2, s596, s597 # 631
stopopen 2, c146, c147 # 632
mulm s598, s594, c146 # 633
mulm s599, s593, c147 # 634
mulc c148, c146, c147 # 635
adds s600, s595, s598 # 636
adds s601, s600, s599 # 637
addm s590, s601, c148 # 638
triple s602, s603, s604 # 639
subs s605, s441, s602 # 640
subs s606, s346, s603 # 641
startopen 2, s605, s606 # 642
stopopen 2, c149, c150 # 643
mulm s607, s603, c149 # 644
mulm s608, s602, c150 # 645
mulc c151, c149, c150 # 646
adds s609, s604, s607 # 647
adds s610, s609, s608 # 648
addm s591, s610, c151 # 649
adds s592, s345, s591 # 650
triple s614, s615, s616 # 651
subs s617, s443, s614 # 652
subs s618, s444, s615 # 653
startopen 2, s617, s618 # 654
stopopen 2, c152, c153 # 655
mulm s619, s615, c152 # 656
mulm s620, s614, c153 # 657
mulc c154, c152, c153 # 658
adds s621, s616, s619 # 659
adds s622, s621, s620 # 660
addm s611, s622, c154 # 661
triple s623, s624, s625 # 662
subs s626, s443, s623 # 663
subs s627, s348, s624 # 664
startopen 2, s626, s627 # 665
stopopen 2, c155, c156 # 666
mulm s628, s624, c155 # 667
mulm s629, s623, c156 # 668
mulc c157, c155, c156 # 669
adds s630, s625, s628 # 670
adds s631, s630, s629 # 671
addm s612, s631, c157 # 672
adds s613, s347, s612 # 673
triple s635, s636, s637 # 674
subs s638, s445, s635 # 675
subs s639, s446, s636 # 676
startopen 2, s638, s639 # 677
stopopen 2, c158, c159 # 678
mulm s640, s636, c158 # 679
mulm s641, s635, c159 # 680
mulc c160, c158, c159 # 681
adds s642, s637, s640 # 682
adds s643, s642, s641 # 683
addm s632, s643, c160 # 684
triple s644, s645, s646 # 685
subs s647, s445, s644 # 686
subs s648, s350, s645 # 687
startopen 2, s647, s648 # 688
stopopen 2, c161, c162 # 689
mulm s649, s645, c161 # 690
mulm s650, s644, c162 # 691
mulc c163, c161, c162 # 692
adds s651, s646, s649 # 693
adds s652, s651, s650 # 694
addm s633, s652, c163 # 695
adds s634, s349, s633 # 696
triple s656, s657, s658 # 697
subs s659, s447, s656 # 698
subs s660, s448, s657 # 699
startopen 2, s659, s660 # 700
stopopen 2, c164, c165 # 701
mulm s661, s657, c164 # 702
mulm s662, s656, c165 # 703
mulc c166, c164, c165 # 704
adds s663, s658, s661 # 705
adds s664, s663, s662 # 706
addm s653, s664, c166 # 707
triple s665, s666, s667 # 708
subs s668, s447, s665 # 709
subs s669, s352, s666 # 710
startopen 2, s668, s669 # 711
stopopen 2, c167, c168 # 712
mulm s670, s666, c167 # 713
mulm s671, s665, c168 # 714
mulc c169, c167, c168 # 715
adds s672, s667, s670 # 716
adds s673, s672, s671 # 717
addm s654, s673, c169 # 718
adds s655, s351, s654 # 719
triple s677, s678, s679 # 720
subs s680, s449, s677 # 721
subs s681, s450, s678 # 722
startopen 2, s680, s681 # 723
stopopen 2, c170, c171 # 724
mulm s682, s678, c170 # 725
mulm s683, s677, c171 # 726
mulc c172, c170, c171 # 727
adds s684, s679, s682 # 728
adds s685, s684, s683 # 729
addm s674, s685, c172 # 730
triple s686, s687, s688 # 731
subs s689, s449, s686 # 732
subs s690, s354, s687 # 733
startopen 2, s689, s690 # 734
stopopen 2, c173, c174 # 735
mulm s691, s687, c173 # 736
mulm s692, s686, c174 # 737
mulc c175, c173, c174 # 738
adds s693, s688, s691 # 739
adds s694, s693, s692 # 740
addm s675, s694, c175 # 741
adds s676, s353, s675 # 742
triple s698, s699, s700 # 743
subs s701, s451, s698 # 744
subs s702, s452, s699 # 745
startopen 2, s701, s702 # 746
stopopen 2, c176, c177 # 747
mulm s703, s699, c176 # 748
mulm s704, s698, c177 # 749
mulc c178, c176, c177 # 750
adds s705, s700, s703 # 751
adds s706, s705, s704 # 752
addm s695, s706, c178 # 753
triple s707, s708, s709 # 754
subs s710, s451, s707 # 755
subs s711, s356, s708 # 756
startopen 2, s710, s711 # 757
stopopen 2, c179, c180 # 758
mulm s712, s708, c179 # 759
mulm s713, s707, c180 # 760
mulc c181, c179, c180 # 761
adds s714, s709, s712 # 762
adds s715, s714, s713 # 763
addm s696, s715, c181 # 764
adds s697, s355, s696 # 765
triple s719, s720, s721 # 766
subs s722, s453, s719 # 767
subs s723, s454, s720 # 768
startopen 2, s722, s723 # 769
stopopen 2, c182, c183 # 770
mulm s724, s720, c182 # 771
mulm s725, s719, c183 # 772
mulc c184, c182, c183 # 773
adds s726, s721, s724 # 774
adds s727, s726, s725 # 775
addm s716, s727, c184 # 776
triple s728, s729, s730 # 777
subs s731, s453, s728 # 778
subs s732, s358, s729 # 779
startopen 2, s731, s732 # 780
stopopen 2, c185, c186 # 781
mulm s733, s729, c185 # 782
mulm s734, s728, c186 # 783
mulc c187, c185, c186 # 784
adds s735, s730, s733 # 785
adds s736, s735, s734 # 786
addm s717, s736, c187 # 787
adds s718, s357, s717 # 788
triple s740, s741, s742 # 789
subs s743, s455, s740 # 790
subs s744, s456, s741 # 791
startopen 2, s743, s744 # 792
stopopen 2, c188, c189 # 793
mulm s745, s741, c188 # 794
mulm s746, s740, c189 # 795
mulc c190, c188, c189 # 796
adds s747, s742, s745 # 797
adds s748, s747, s746 # 798
addm s737, s748, c190 # 799
triple s749, s750, s751 # 800
subs s752, s455, s749 # 801
subs s753, s360, s750 # 802
startopen 2, s752, s753 # 803
stopopen 2, c191, c192 # 804
mulm s754, s750, c191 # 805
mulm s755, s749, c192 # 806
mulc c193, c191, c192 # 807
adds s756, s751, s754 # 808
adds s757, s756, s755 # 809
addm s738, s757, c193 # 810
adds s739, s359, s738 # 811
triple s761, s762, s763 # 812
subs s764, s457, s761 # 813
subs s765, s458, s762 # 814
startopen 2, s764, s765 # 815
stopopen 2, c194, c195 # 816
mulm s766, s762, c194 # 817
mulm s767, s761, c195 # 818
mulc c196, c194, c195 # 819
adds s768, s763, s766 # 820
adds s769, s768, s767 # 821
addm s758, s769, c196 # 822
triple s770, s771, s772 # 823
subs s773, s457, s770 # 824
subs s774, s362, s771 # 825
startopen 2, s773, s774 # 826
stopopen 2, c197, c198 # 827
mulm s775, s771, c197 # 828
mulm s776, s770, c198 # 829
mulc c199, c197, c198 # 830
adds s777, s772, s775 # 831
adds s778, s777, s776 # 832
addm s759, s778, c199 # 833
adds s760, s361, s759 # 834
triple s782, s783, s784 # 835
subs s785, s459, s782 # 836
subs s786, s462, s783 # 837
startopen 2, s785, s786 # 838
stopopen 2, c200, c201 # 839
mulm s787, s783, c200 # 840
mulm s788, s782, c201 # 841
mulc c202, c200, c201 # 842
adds s789, s784, s787 # 843
adds s790, s789, s788 # 844
addm s780, s790, c202 # 845
adds s781, s363, s780 # 846
triple s794, s795, s796 # 847
subs s797, s464, s794 # 848
subs s798, s485, s795 # 849
startopen 2, s797, s798 # 850
stopopen 2, c203, c204 # 851
mulm s799, s795, c203 # 852
mulm s800, s794, c204 # 853
mulc c205, c203, c204 # 854
adds s801, s796, s799 # 855
adds s802, s801, s800 # 856
addm s791, s802, c205 # 857
triple s803, s804, s805 # 858
subs s806, s464, s803 # 859
subs s807, s487, s804 # 860
startopen 2, s806, s807 # 861
stopopen 2, c206, c207 # 862
mulm s808, s804, c206 # 863
mulm s809, s803, c207 # 864
mulc c208, c206, c207 # 865
adds s810, s805, s808 # 866
adds s811, s810, s809 # 867
addm s792, s811, c208 # 868
adds s793, s466, s792 # 869
triple s815, s816, s817 # 870
subs s818, s506, s815 # 871
subs s819, s527, s816 # 872
startopen 2, s818, s819 # 873
stopopen 2, c209, c210 # 874
mulm s820, s816, c209 # 875
mulm s821, s815, c210 # 876
mulc c211, c209, c210 # 877
adds s822, s817, s820 # 878
adds s823, s822, s821 # 879
addm s812, s823, c211 # 880
triple s824, s825, s826 # 881
subs s827, s506, s824 # 882
subs s828, s529, s825 # 883
startopen 2, s827, s828 # 884
stopopen 2, c212, c213 # 885
mulm s829, s825, c212 # 886
mulm s830, s824, c213 # 887
mulc c214, c212, c213 # 888
adds s831, s826, s829 # 889
adds s832, s831, s830 # 890
addm s813, s832, c214 # 891
adds s814, s508, s813 # 892
triple s836, s837, s838 # 893
subs s839, s548, s836 # 894
subs s840, s569, s837 # 895
startopen 2, s839, s840 # 896
stopopen 2, c215, c216 # 897
mulm s841, s837, c215 # 898
mulm s842, s836, c216 # 899
mulc c217, c215, c216 # 900
adds s843, s838, s841 # 901
adds s844, s843, s842 # 902
addm s833, s844, c217 # 903
triple s845, s846, s847 # 904
subs s848, s548, s845 # 905
subs s849, s571, s846 # 906
startopen 2, s848, s849 # 907
stopopen 2, c218, c219 # 908
mulm s850, s846, c218 # 909
mulm s851, s845, c219 # 910
mulc c220, c218, c219 # 911
adds s852, s847, s850 # 912
adds s853, s852, s851 # 913
addm s834, s853, c220 # 914
adds s835, s550, s834 # 915
triple s857, s858, s859 # 916
subs s860, s590, s857 # 917
subs s861, s611, s858 # 918
startopen 2, s860, s861 # 919
stopopen 2, c221, c222 # 920
mulm s862, s858, c221 # 921
mulm s863, s857, c222 # 922
mulc c223, c221, c222 # 923
adds s864, s859, s862 # 924
adds s865, s864, s863 # 925
addm s854, s865, c223 # 926
triple s866, s867, s868 # 927
subs s869, s590, s866 # 928
subs s870, s613, s867 # 929
startopen 2, s869, s870 # 930
stopopen 2, c224, c225 # 931
mulm s871, s867, c224 # 932
mulm s872, s866, c225 # 933
mulc c226, c224, c225 # 934
adds s873, s868, s871 # 935
adds s874, s873, s872 # 936
addm s855, s874, c226 # 937
adds s856, s592, s855 # 938
triple s878, s879, s880 # 939
subs s881, s632, s878 # 940
subs s882, s653, s879 # 941
startopen 2, s881, s882 # 942
stopopen 2, c227, c228 # 943
mulm s883, s879, c227 # 944
mulm s884, s878, c228 # 945
mulc c229, c227, c228 # 946
adds s885, s880, s883 # 947
adds s886, s885, s884 # 948
addm s875, s886, c229 # 949
triple s887, s888, s889 # 950
subs s890, s632, s887 # 951
subs s891, s655, s888 # 952
startopen 2, s890, s891 # 953
stopopen 2, c230, c231 # 954
mulm s892, s888, c230 # 955
mulm s893, s887, c231 # 956
mulc c232, c230, c231 # 957
adds s894, s889, s892 # 958
adds s895, s894, s893 # 959
addm s876, s895, c232 # 960
adds s877, s634, s876 # 961
triple s899, s900, s901 # 962
subs s902, s674, s899 # 963
subs s903, s695, s900 # 964
startopen 2, s902, s903 # 965
stopopen 2, c233, c234 # 966
mulm s904, s900, c233 # 967
mulm s905, s899, c234 # 968
mulc c235, c233, c234 # 969
adds s906, s901, s904 # 970
adds s907, s906, s905 # 971
addm s896, s907, c235 # 972
triple s908, s909, s910 # 973
subs s911, s674, s908 # 974
subs s912, s697, s909 # 975
startopen 2, s911, s912 # 976
stopopen 2, c236, c237 # 977
mulm s913, s909, c236 # 978
mulm s914, s908, c237 # 979
mulc c238, c236, c237 # 980
adds s915, s910, s913 # 981
adds s916, s915, s914 # 982
addm s897, s916, c238 # 983
adds s898, s676, s897 # 984
triple s920, s921, s922 # 985
subs s923, s716, s920 # 986
subs s924, s737, s921 # 987
startopen 2, s923, s924 # 988
stopopen 2, c239, c240 # 989
mulm s925, s921, c239 # 990
mulm s926, s920, c240 # 991
mulc c241, c239, c240 # 992
adds s927, s922, s925 # 993
adds s928, s927, s926 # 994
addm s917, s928, c241 # 995
triple s929, s930, s931 # 996
subs s932, s716, s929 # 997
subs s933, s739, s930 # 998
startopen 2, s932, s933 # 999
stopopen 2, c242, c243 # 1000
mulm s934, s930, c242 # 1001
mulm s935, s929, c243 # 1002
mulc c244, c242, c243 # 1003
adds s936, s931, s934 # 1004
adds s937, s936, s935 # 1005
addm s918, s937, c244 # 1006
adds s919, s718, s918 # 1007
triple s941, s942, s943 # 1008
subs s944, s758, s941 # 1009
subs s945, s781, s942 # 1010
startopen 2, s944, s945 # 1011
stopopen 2, c245, c246 # 1012
mulm s946, s942, c245 # 1013
mulm s947, s941, c246 # 1014
mulc c247, c245, c246 # 1015
adds s948, s943, s946 # 1016
adds s949, s948, s947 # 1017
addm s939, s949, c247 # 1018
adds s940, s760, s939 # 1019
triple s953, s954, s955 # 1020
subs s956, s791, s953 # 1021
subs s957, s812, s954 # 1022
startopen 2, s956, s957 # 1023
stopopen 2, c248, c249 # 1024
mulm s958, s954, c248 # 1025
mulm s959, s953, c249 # 1026
mulc c250, c248, c249 # 1027
adds s960, s955, s958 # 1028
adds s961, s960, s959 # 1029
addm s950, s961, c250 # 1030
triple s962, s963, s964 # 1031
subs s965, s791, s962 # 1032
subs s966, s814, s963 # 1033
startopen 2, s965, s966 # 1034
stopopen 2, c251, c252 # 1035
mulm s967, s963, c251 # 1036
mulm s968, s962, c252 # 1037
mulc c253, c251, c252 # 1038
adds s969, s964, s967 # 1039
adds s970, s969, s968 # 1040
addm s951, s970, c253 # 1041
adds s952, s793, s951 # 1042
triple s974, s975, s976 # 1043
subs s977, s833, s974 # 1044
subs s978, s854, s975 # 1045
startopen 2, s977, s978 # 1046
stopopen 2, c254, c255 # 1047
mulm s979, s975, c254 # 1048
mulm s980, s974, c255 # 1049
mulc c256, c254, c255 # 1050
adds s981, s976, s979 # 1051
adds s982, s981, s980 # 1052
addm s971, s982, c256 # 1053
triple s983, s984, s985 # 1054
subs s986, s833, s983 # 1055
subs s987, s856, s984 # 1056
startopen 2, s986, s987 # 1057
stopopen 2, c257, c258 # 1058
mulm s988, s984, c257 # 1059
mulm s989, s983, c258 # 1060
mulc c259, c257, c258 # 1061
adds s990, s985, s988 # 1062
adds s991, s990, s989 # 1063
addm s972, s991, c259 # 1064
adds s973, s835, s972 # 1065
triple s995, s996, s997 # 1066
subs s998, s875, s995 # 1067
subs s999, s896, s996 # 1068
startopen 2, s998, s999 # 1069
stopopen 2, c260, c261 # 1070
mulm s1000, s996, c260 # 1071
mulm s1001, s995, c261 # 1072
mulc c262, c260, c261 # 1073
adds s1002, s997, s1000 # 1074
adds s1003, s1002, s1001 # 1075
addm s992, s1003, c262 # 1076
triple s1004, s1005, s1006 # 1077
subs s1007, s875, s1004 # 1078
subs s1008, s898, s1005 # 1079
startopen 2, s1007, s1008 # 1080
stopopen 2, c263, c264 # 1081
mulm s1009, s1005, c263 # 1082
mulm s1010, s1004, c264 # 1083
mulc c265, c263, c264 # 1084
adds s1011, s1006, s1009 # 1085
adds s1012, s1011, s1010 # 1086
addm s993, s1012, c265 # 1087
adds s994, s877, s993 # 1088
triple s1016, s1017, s1018 # 1089
subs s1019, s917, s1016 # 1090
subs s1020, s940, s1017 # 1091
startopen 2, s1019, s1020 # 1092
stopopen 2, c266, c267 # 1093
mulm s1021, s1017, c266 # 1094
mulm s1022, s1016, c267 # 1095
mulc c268, c266, c267 # 1096
adds s1023, s1018, s1021 # 1097
adds s1024, s1023, s1022 # 1098
addm s1014, s1024, c268 # 1099
adds s1015, s919, s1014 # 1100
triple s1028, s1029, s1030 # 1101
subs s1031, s950, s1028 # 1102
subs s1032, s971, s1029 # 1103
startopen 2, s1031, s1032 # 1104
stopopen 2, c269, c270 # 1105
mulm s1033, s1029, c269 # 1106
mulm s1034, s1028, c270 # 1107
mulc c271, c269, c270 # 1108
adds s1035, s1030, s1033 # 1109
adds s1036, s1035, s1034 # 1110
addm s1025, s1036, c271 # 1111
triple s1037, s1038, s1039 # 1112
subs s1040, s950, s1037 # 1113
subs s1041, s973, s1038 # 1114
startopen 2, s1040, s1041 # 1115
stopopen 2, c272, c273 # 1116
mulm s1042, s1038, c272 # 1117
mulm s1043, s1037, c273 # 1118
mulc c274, c272, c273 # 1119
adds s1044, s1039, s1042 # 1120
adds s1045, s1044, s1043 # 1121
addm s1026, s1045, c274 # 1122
adds s1027, s952, s1026 # 1123
triple s1049, s1050, s1051 # 1124
subs s1052, s992, s1049 # 1125
subs s1053, s1015, s1050 # 1126
startopen 2, s1052, s1053 # 1127
stopopen 2, c275, c276 # 1128
mulm s1054, s1050, c275 # 1129
mulm s1055, s1049, c276 # 1130
mulc c277, c275, c276 # 1131
adds s1056, s1051, s1054 # 1132
adds s1057, s1056, s1055 # 1133
addm s1047, s1057, c277 # 1134
adds s1048, s994, s1047 # 1135
triple s1061, s1062, s1063 # 1136
subs s1064, s1025, s1061 # 1137
subs s1065, s1048, s1062 # 1138
startopen 2, s1064, s1065 # 1139
stopopen 2, c278, c279 # 1140
mulm s1066, s1062, c278 # 1141
mulm s1067, s1061, c279 # 1142
mulc c280, c278, c279 # 1143
adds s1068, s1063, s1066 # 1144
adds s1069, s1068, s1067 # 1145
addm s1059, s1069, c280 # 1146
adds s1060, s1027, s1059 # 1147
movs s300, s1060 # 1148
subsfi s42, s300, 1 # 1149
mulm s47, s42, c6 # 1150
submr s48, c5, s8 # 1151
adds s5, s48, s47 # 1152
subs s6, s3, s5 # 1153
ldi c1, 1 # 1154
ldi c281, 4 # 1155
mulci c282, c281, 1073741824 # 1156
movc c3, c282 # 1157
divc c2, c1, c3 # 1158
mulm s4, s6, c2 # 1159
subsfi s2, s4, 0 # 1160
reqbl 74 # 1161
reqbl 74 # 1162
|
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
/*=============================================================
**
** Source: test1.c
**
** Purpose: Debugs the helper application. Checks that certain events, in
** particular the OUTPUT_DEBUG_STRING_EVENT, is generated correctly
** and gives the correct values.
**
**
**============================================================*/
#include <palsuite.h>
const int DELAY_MS = 2000;
struct OutputCheck
{
DWORD ExpectedEventCode;
DWORD ExpectedUnicode;
char *ExpectedStr;
};
int __cdecl main(int argc, char *argv[])
{
PROCESS_INFORMATION pi;
STARTUPINFO si;
if(0 != (PAL_Initialize(argc, argv)))
{
return FAIL;
}
ZeroMemory( &si, sizeof(si) );
si.cb = sizeof(si);
ZeroMemory( &pi, sizeof(pi) );
/* Create a new process. This is the process to be Debugged */
if(!CreateProcess( NULL, "helper", NULL, NULL,
FALSE, 0, NULL, NULL, &si, &pi))
{
Fail("ERROR: CreateProcess failed to load executable 'helper'. "
"GetLastError() returned %d.\n",GetLastError());
}
/* This is the main loop. It exits when the process which is being
debugged is finished executing.
*/
while(1)
{
DWORD dwRet = 0;
dwRet = WaitForSingleObject(pi.hProcess,
DELAY_MS /* Wait for 2 seconds max*/
);
if (dwRet != WAIT_OBJECT_0)
{
Trace("WaitForSingleObjectTest:WaitForSingleObject "
"failed (%x) after waiting %d seconds for the helper\n",
GetLastError(), DELAY_MS / 1000);
}
else
{
DWORD dwExitCode;
/* check the exit code from the process */
if( ! GetExitCodeProcess( pi.hProcess, &dwExitCode ) )
{
DWORD dwError;
dwError = GetLastError();
CloseHandle ( pi.hProcess );
CloseHandle ( pi.hThread );
Fail( "GetExitCodeProcess call failed with error code %d\n",
dwError );
}
if(dwExitCode != STILL_ACTIVE) {
CloseHandle(pi.hThread);
CloseHandle(pi.hProcess);
break;
}
Trace("still executing %d..\n", dwExitCode);
}
}
PAL_Terminate();
return PASS;
}
|
global _start
section .text
_start:
jmp short call_abc
abc:
pop rdi ; load own address
sub rdi,46 ; jump over egghunter code to avoid finding tag for searching
mov rax,0x8899AABBCCDDEEFF ; load tag 0xAABBCCDD
xor rcx,rcx
mov cx,0xFFFF ; search for max 2^16 bytes
std ; set direction flag
; -> scasd decrements edi
; -> search towards lower emmory
search:
; search for tag at the stack
scasq ; compares string (dword) in eax and [edi], and increments/decrements
; Compare RAX with quadword at RDI or EDI then set status flags.
jz exec ; jump to shellcode if egg is found
add rdi,7 ; search after every byte instead of every 4 bytes to avoid alignment problems
loop search
exec:
; rdi = position of the start of the tag (88 of 8899AABBCCDDEEFF) - 8 (scasq dec)
add rdi,16 ; +8 (scasq) +8 (tag)
jmp rdi ; jmp to shellcode
call_abc:
call abc
|
; A038234: Triangle whose (i,j)-th entry is binomial(i,j)*4^(i-j)*4^j.
; Submitted by Christian Krause
; 1,4,4,16,32,16,64,192,192,64,256,1024,1536,1024,256,1024,5120,10240,10240,5120,1024,4096,24576,61440,81920,61440,24576,4096,16384,114688,344064,573440,573440,344064,114688,16384,65536,524288
lpb $0
add $1,1
sub $0,$1
mul $2,4
add $2,3
lpe
bin $1,$0
mul $2,$1
add $2,$1
mov $0,$2
|
;--------------------------------------------------------
; File Created by SDCC : free open source ANSI-C Compiler
; Version 4.1.6 #12555 (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 _m32_atanhf
;--------------------------------------------------------
; Externals used
;--------------------------------------------------------
GLOBAL _m32_polyf
GLOBAL _m32_hypotf
GLOBAL _m32_ldexpf
GLOBAL _m32_frexpf
GLOBAL _m32_invsqrtf
GLOBAL _m32_sqrtf
GLOBAL _m32_invf
GLOBAL _m32_sqrf
GLOBAL _m32_div2f
GLOBAL _m32_mul2f
GLOBAL _m32_modff
GLOBAL _m32_fmodf
GLOBAL _m32_roundf
GLOBAL _m32_floorf
GLOBAL _m32_fabsf
GLOBAL _m32_ceilf
GLOBAL _m32_powf
GLOBAL _m32_log10f
GLOBAL _m32_log2f
GLOBAL _m32_logf
GLOBAL _m32_exp10f
GLOBAL _m32_exp2f
GLOBAL _m32_expf
GLOBAL _m32_acoshf
GLOBAL _m32_asinhf
GLOBAL _m32_tanhf
GLOBAL _m32_coshf
GLOBAL _m32_sinhf
GLOBAL _m32_atan2f
GLOBAL _m32_atanf
GLOBAL _m32_acosf
GLOBAL _m32_asinf
GLOBAL _m32_tanf
GLOBAL _m32_cosf
GLOBAL _m32_sinf
GLOBAL _poly_callee
GLOBAL _poly
GLOBAL _exp10_fastcall
GLOBAL _exp10
GLOBAL _mul10u_fastcall
GLOBAL _mul10u
GLOBAL _mul2_fastcall
GLOBAL _mul2
GLOBAL _div2_fastcall
GLOBAL _div2
GLOBAL _invsqrt_fastcall
GLOBAL _invsqrt
GLOBAL _inv_fastcall
GLOBAL _inv
GLOBAL _sqr_fastcall
GLOBAL _sqr
GLOBAL _neg_fastcall
GLOBAL _neg
GLOBAL _isunordered_callee
GLOBAL _isunordered
GLOBAL _islessgreater_callee
GLOBAL _islessgreater
GLOBAL _islessequal_callee
GLOBAL _islessequal
GLOBAL _isless_callee
GLOBAL _isless
GLOBAL _isgreaterequal_callee
GLOBAL _isgreaterequal
GLOBAL _isgreater_callee
GLOBAL _isgreater
GLOBAL _fma_callee
GLOBAL _fma
GLOBAL _fmin_callee
GLOBAL _fmin
GLOBAL _fmax_callee
GLOBAL _fmax
GLOBAL _fdim_callee
GLOBAL _fdim
GLOBAL _nexttoward_callee
GLOBAL _nexttoward
GLOBAL _nextafter_callee
GLOBAL _nextafter
GLOBAL _nan_fastcall
GLOBAL _nan
GLOBAL _copysign_callee
GLOBAL _copysign
GLOBAL _remquo_callee
GLOBAL _remquo
GLOBAL _remainder_callee
GLOBAL _remainder
GLOBAL _fmod_callee
GLOBAL _fmod
GLOBAL _modf_callee
GLOBAL _modf
GLOBAL _trunc_fastcall
GLOBAL _trunc
GLOBAL _lround_fastcall
GLOBAL _lround
GLOBAL _round_fastcall
GLOBAL _round
GLOBAL _lrint_fastcall
GLOBAL _lrint
GLOBAL _rint_fastcall
GLOBAL _rint
GLOBAL _nearbyint_fastcall
GLOBAL _nearbyint
GLOBAL _floor_fastcall
GLOBAL _floor
GLOBAL _ceil_fastcall
GLOBAL _ceil
GLOBAL _tgamma_fastcall
GLOBAL _tgamma
GLOBAL _lgamma_fastcall
GLOBAL _lgamma
GLOBAL _erfc_fastcall
GLOBAL _erfc
GLOBAL _erf_fastcall
GLOBAL _erf
GLOBAL _cbrt_fastcall
GLOBAL _cbrt
GLOBAL _sqrt_fastcall
GLOBAL _sqrt
GLOBAL _pow_callee
GLOBAL _pow
GLOBAL _hypot_callee
GLOBAL _hypot
GLOBAL _fabs_fastcall
GLOBAL _fabs
GLOBAL _logb_fastcall
GLOBAL _logb
GLOBAL _log2_fastcall
GLOBAL _log2
GLOBAL _log1p_fastcall
GLOBAL _log1p
GLOBAL _log10_fastcall
GLOBAL _log10
GLOBAL _log_fastcall
GLOBAL _log
GLOBAL _scalbln_callee
GLOBAL _scalbln
GLOBAL _scalbn_callee
GLOBAL _scalbn
GLOBAL _ldexp_callee
GLOBAL _ldexp
GLOBAL _ilogb_fastcall
GLOBAL _ilogb
GLOBAL _frexp_callee
GLOBAL _frexp
GLOBAL _expm1_fastcall
GLOBAL _expm1
GLOBAL _exp2_fastcall
GLOBAL _exp2
GLOBAL _exp_fastcall
GLOBAL _exp
GLOBAL _tanh_fastcall
GLOBAL _tanh
GLOBAL _sinh_fastcall
GLOBAL _sinh
GLOBAL _cosh_fastcall
GLOBAL _cosh
GLOBAL _atanh_fastcall
GLOBAL _atanh
GLOBAL _asinh_fastcall
GLOBAL _asinh
GLOBAL _acosh_fastcall
GLOBAL _acosh
GLOBAL _tan_fastcall
GLOBAL _tan
GLOBAL _sin_fastcall
GLOBAL _sin
GLOBAL _cos_fastcall
GLOBAL _cos
GLOBAL _atan2_callee
GLOBAL _atan2
GLOBAL _atan_fastcall
GLOBAL _atan
GLOBAL _asin_fastcall
GLOBAL _asin
GLOBAL _acos_fastcall
GLOBAL _acos
;--------------------------------------------------------
; special function registers
;--------------------------------------------------------
;--------------------------------------------------------
; ram data
;--------------------------------------------------------
SECTION bss_compiler
;--------------------------------------------------------
; ram data
;--------------------------------------------------------
IF 0
; .area _INITIALIZED removed by z88dk
ENDIF
;--------------------------------------------------------
; absolute external ram data
;--------------------------------------------------------
SECTION IGNORE
;--------------------------------------------------------
; global & static initialisations
;--------------------------------------------------------
SECTION code_crt_init
;--------------------------------------------------------
; Home
;--------------------------------------------------------
SECTION IGNORE
;--------------------------------------------------------
; code
;--------------------------------------------------------
SECTION code_compiler
; ---------------------------------
; Function m32_atanhf
; ---------------------------------
_m32_atanhf:
push ix
ld ix,0
add ix,sp
push af
push af
push hl
push de
ld bc,0x3f80
push bc
ld bc,0x0000
push bc
push de
push hl
call ___fsadd_callee
ld (ix-4),l
ld (ix-3),h
ld (ix-2),e
ld (ix-1),d
pop de
pop hl
push de
push hl
ld hl,0x3f80
push hl
ld hl,0x0000
push hl
call ___fssub_callee
push de
push hl
ld l,(ix-2)
ld h,(ix-1)
push hl
ld l,(ix-4)
ld h,(ix-3)
push hl
call ___fsdiv_callee
call _m32_div2f
call _m32_logf
ld sp, ix
pop ix
ret
SECTION IGNORE
|
//http://www.cplusplus.com/reference/algorithm/sort/
//http://en.cppreference.com/w/cpp/algorithm/equal
//http://en.cppreference.com/w/cpp/algorithm/mismatch
//http://en.cppreference.com/w/cpp/algorithm/copy
//http://www.cplusplus.com/reference/algorithm/fill/
//http://en.cppreference.com/w/cpp/algorithm/swap
//http://www.cplusplus.com/reference/algorithm/remove/
//http://en.cppreference.com/w/cpp/algorithm/binary_search
//http://www.cplusplus.com/reference/algorithm/merge/
//http://www.cplusplus.com/reference/algorithm/lexicographical_compare/
#include <iostream>
#include <algorithm>
#include <vector>
#include <memory>
#include <string>
#include <iterator>
#include <numeric>
#include <cctype>
using namespace std;
/* --------------- min max ---------------------------*/
void stl_min_max()
{
cout << "max (1,3) = " << max(1,3) << endl;
cout << "max ('a','z') = " << max('a','z') << endl;
cout << "min (1,3) = " << min(1,3) << endl;
cout << "min ('a','z') = " << min('a','z') << endl;
}
/* --------------- lexical compare -------------------*/
// a case-insensitive comparison function:
bool mycomp (char c1, char c2)
{ return std::tolower(c1)<std::tolower(c2); }
void stl_lexicographical_compare()
{
char foo[]="Apple";
char bar[]="apartment";
std::cout << std::boolalpha;
std::cout << "Comparing foo and bar lexicographically (foo<bar):\n";
std::cout << "Using default comparison (operator<): ";
std::cout << std::lexicographical_compare(foo,foo+5,bar,bar+9);
std::cout << '\n';
std::cout << "Using mycomp as comparison object: ";
std::cout << std::lexicographical_compare(foo,foo+5,bar,bar+9,mycomp);
std::cout << '\n';
}
/* --------------- sorting and searching -------------*/
void stl_binary_search()
{
vector<int> haystack{1,3,4,5,9};
vector<int> needles {1,2,3};
for(auto needle: needles){
cout << "search for = " << needle << endl;
if(std::binary_search(haystack.begin(), haystack.end(), needle)){
cout << " Found " << needle << endl;
} else {
cout << "nop " << endl;
}
}
}
void stl_merge()
{
int first [] = {5, 10, 15, 20, 25};
int second [] = {50, 40, 30, 20, 10};
vector<int> v(10);
sort (first, first+5);
sort (second, second+5);
merge(first, first+5, second, second+5, v.begin());
for( auto i: v)
{
cout << i << " - ";
}
cout << endl;
}
// partial sort
/* --------------- permutations --------------*/
void stl_fill()
{
vector<int> vector (8);
for( auto v: vector){
cout << v << " - ";
}
cout << endl;
fill(vector.begin(), vector.begin()+4, 5);
for( auto v: vector){
cout << v << " - ";
}
cout << endl;
fill(vector.begin()+3, vector.end()-2, 8);
for( auto v: vector){
cout << v << " - ";
}
cout << endl;
}
void stl_swap()
{
int a = 10, b=20;
cout << a << " - " << b << endl;
std::swap(a,b);
cout << a << " - " << b << endl;
}
/*---------------- modifying sequence algorithms -------------- */
void stl_copy()
{
vector<int> from_vector(10);
std::iota(from_vector.begin(), from_vector.end(), 0);
vector<int> to_vector;
for( auto v: from_vector){
cout << v << " - ";
}
cout << endl;
for( auto v: to_vector){
cout << v << " <-> ";
}
cout << endl;
std::copy(from_vector.begin(), from_vector.end(),
std::back_inserter(to_vector));
for( auto v: to_vector){
cout << v << " <-> ";
}
cout << endl;
cout << "to_vector contains: ";
std::copy(to_vector.begin(), to_vector.end(),
std::ostream_iterator<int>(std::cout, " "));
cout << endl;
}
void stl_remove()
{
int myints[] = {10,20,30,30,10,22};
int* pbegin = myints;
int* pend = myints+ sizeof(myints)/sizeof(int);
std::remove(pbegin, pend, 30);
for(int* p = pbegin; p != pend; ++p)
cout << ' ' << *p;
cout << endl;
}
//unique
//replace
//rotate
//random_shuffle
//partition
/* --------------- nonmodifying sequence algorithms ------------- */
void myprintfunction(string i) { cout << " -> " << i; }
void stl_for_each()
{
vector <string> v {"three", "four", "one"};
for_each( v.begin(), v.end(), myprintfunction);
cout << endl;
}
void stl_find()
{
vector<int> v {1, 56, 2,7};
vector<int>::iterator it;
it = find(v.begin(), v.end(), 56);
if(it != v.end())
cout << "Found = "<< *it << endl;
else
cout << "Not found = " << *it << endl;
}
bool is_palindrome(const std::string& s)
{
return std::equal(s.begin(), s.begin() + s.size()/2, s.rbegin());
}
void stl_equal(const string& s)
{
std::cout << "\"" << s << "\" "
<< (is_palindrome(s) ? "is" : "is not")
<< " a palindrome\n";
}
string stl_mismatch(const string& in)
{
return std::string(in.begin(),
std::mismatch(in.begin(), in.end(), in.rbegin()).first);
}
/*----------------------- sequences---------------------------------- */
bool myfunction (int i,int j) { return (i<j); }
struct myclass
{
bool operator() (int i,int j) { return (i<j);}
} myobject;
void stl_sort()
{
int myints[] = {32,71,12,45,26,80,53,33};
vector <int> myvector(myints, myints+8);
// using default comparison (operator <):
std::sort (myvector.begin(), myvector.begin()+4); //(12 32 45 71)26 80 53 33
// using function as comp
std::sort (myvector.begin()+4, myvector.end(), myfunction); // 12 32 45 71(26 33 53 80)
// using object as comp
std::sort (myvector.begin(), myvector.end(), myobject); //(12 26 32 33 45 53 71 80)
for( auto v: myvector)
cout << v << " ";
cout << endl;
}
int main()
{
// pair of iterators (inputs) or a single iterator (outputs)
stl_sort();
stl_for_each();
stl_find();
stl_equal("radar");
stl_equal("hello");
cout << stl_mismatch("abXYZba") << endl;
cout << stl_mismatch("abca") << endl;
cout << stl_mismatch("aba") << endl;
stl_copy();
stl_fill();
stl_swap();
stl_remove();
stl_binary_search();
stl_merge();
stl_lexicographical_compare();
stl_min_max();
return 0;
}
|
; ***************************************************************************************
; ***************************************************************************************
;
; Name : bootloader.asm
; Author : Paul Robson (paul@robsons.org.uk)
; Date : 14th December 2018
; Purpose : Boot-Loads code by loading "boot.img" into memory
; from $8000-$BFFF then banks 32-94 (2 per page) into $C000-$FFFF
;
; ***************************************************************************************
; ***************************************************************************************
FirstPage = 32 ; these are the pages for an
LastPage = 95 ; unexpanded ZXNext.
org $4000-27
db $3F
dw 0,0,0,0,0,0,0,0,0,0,0
org $4000-4
dw $5AFE
db 1
db 7
org $5AFE
dw $7F00
org $7F00
Start: ld sp,Start-1 ; set up the stack.
;db $DD,$01
ld ix,ImageName ; read the image into memory
call ReadNextMemory
jp $8000 ; run.
; ***************************************************************************************
;
; Access the default drive
;
; ***************************************************************************************
FindDefaultDrive:
xor a
rst $08 ; set the default drive.
db $89
ld (DefaultDrive),a
ret
; ***************************************************************************************
;
; Read ZXNext memory from $8000-$BFFF then pages from $C000-$FFFF
;
; ***************************************************************************************
ReadNextMemory:
call FindDefaultDrive ; get default drive
call OpenFileRead ; open for reading
ld ix,$8000 ; read in 8000-BFFF
call Read16kBlock
ld b,FirstPage ; current page
__ReadBlockLoop:
call SetPaging ; access the pages
ld ix,$C000 ; read in C000-FFFF
call Read16kBlock ; read it in
inc b ; there are two 8k blocks
inc b ; per page
ld a,b
cp LastPage+1 ; until read in pages 32-95
jr nz,__ReadBlockLoop
call CloseFile ; close file.
ret
; ***************************************************************************************
;
; Map $C000-$FFFF onto blocks b and b+1
;
; ***************************************************************************************
SetPaging:
ld a,b ; set $56
db $ED,$92,$56
inc a ; set $57
db $ED,$92,$57
ret
; ***************************************************************************************
;
; Open file read
;
; ***************************************************************************************
OpenFileRead:
push af
push bc
push ix
ld b,1
__OpenFile:
ld a,(DefaultDrive)
rst $08
db $9A
ld (FileHandle),a
pop ix
pop bc
pop af
ret
; ***************************************************************************************
;
; Read 16k block
;
; ***************************************************************************************
Read16kBlock:
push af
push bc
push ix
ld a,(FileHandle)
ld bc,$4000
rst $08
db $9D
pop ix
pop bc
pop af
ret
; ***************************************************************************************
;
; Close open file
;
; ***************************************************************************************
CloseFile:
push af
ld a,(FileHandle)
rst $08
db $9B
pop af
ret
DefaultDrive:
db 0
FileHandle:
db 0
org $7FF0
ImageName:
db "boot.img",0
org $FFFF
db 0
|
; libKong example program ROM, 16KB
.data
; This header contains our main zero-page requirements.
; Don't allocate before $20.
; 32 bytes on the zero page should be enough for libKong.
.include "../../KongZP.asm"
; Starting here leaves a 16-byte boundary between
; the libKong allocation and our ZP requisites.
; It's not necessary, but it keeps things safe from being overwritten.
.org $30
; $100-$1FF are where the stack is located, so make sure you're not putting
; anything into that area. $200 is a good place for a copy of the Object
; Attribute Memory (OAM) to be written, so you can manipulate sprites before
; and after the VBlank, then DMA them into VRAM during the VBlank cycle.
.org $0200
; (256 bytes / 4 bytes per sprite) = 64 sprites on-screen at once.
.org $0300
; This is where variables should go that don't require the speed of a
; zero-page read or write. You have $0300-$07FF available to you.
; That's roughly 1.25 kilobytes. Should be enough for everyone. :)
; Let's set up a few variables for important things like scrolling.
.space ScrollX 1
.space ScrollY 1
.space ActiveScreen 1
; -------------------- END OF DATA SEGMENT --------------------
; Start of the text segment, this is our program code.
.text
; Addressable ROM space starts at $8000. Everything below this area is wired
; to the NES hardware or a mirror of a hardware space, with the exception of
; $6000-$7FFF in boards with 8KB expansion RAM, such as TLROM and TKROM cart
; configurations.
; Since we're only making a 16KB binary, we can set the origin to $C000,
; rather than starting at $8000. This configuration is called "NROM-128",
; because it makes a 128 kilobit program ROM. These ROMs are compatible with
; 32KB/256 kilobit (NROM-256) boards, though to make them work, you'll need
; to write the PRG data twice to inflate the size to 32KB.
.org $C000
.include "../../KongSetup.asm" ; libKong NES setup
.include "../../KongPPU.asm" ; libKong PPU code
.include "../../KongMacros.asm" ; libKong Macros
.include "../../KongRender.asm" ; Rendering routines
.include "../../KongInput.asm" ; Controller handler
; Add our graphics data.
simplePal: ; Palette data
.incbin "simplegfx.pal"
simpleScreen1: ; Screen 1 Data
.incbin "simple1.nam"
simpleScreen2:
.incbin "simple2.nam" ; Screen 2 Data
RESET:
; Make sure everything gets set up properly.
JSR ResetNES ; Basic boilerplate NES setup code
JSR WaitVBlank ; VBlank #1
JSR ClearRAM ; Clear out RAM
`clearStack ; Clean up the stack.
JSR ClearSprites ; Move sprites off-screen.
JSR WaitVBlank ; VBlank #2
; It generally takes 2 VBlank cycles to ensure the PPU is
; warmed up and ready to start drawing stuff on the screen.
; Now that the necessary time is passed, we can configure
; the PPU and get stuff set up to render the title card.
JSR DisableGFX ; Disable graphics
; Init our scrolling position.
LDA #$00
STA ScrollX
STA ScrollY
LDA #$00|NMIOnVBlank|BGAddr0|PPUInc1
STA ActiveScreen
; Load our palettes.
`loadBGPalette simplePal
`loadSpritePalette simplePal
; Clear the nametables.
JSR ClearNameTables
; Set up the PPU. This is self explanatory, but I'll break it down.
; Set Backgrounds to CHR Page 0
; Increment PPU address by 1 (horizontal rendering)
; Set Nametable to PPU Address $2000 (Top-Left)
; We'll actually be writing to the nametable at $2800 (Bottom-Left), but with
; mirroring set to vertical, writing to $2800 will copy that data to $2000.
`ConfigurePPU BGAddr0|PPUInc1|NameTable20
LDX #<simpleScreen1
LDY #>simpleScreen1
LDA #NT0
JSR RenderNameTable
LDX #<simpleScreen2
LDY #>simpleScreen2
LDA #NT1
JSR RenderNameTable
; Now that we've rendered our background, we can reconfigure the PPU with our
; VBlank Non-Maskable Interrupt enabled.
`ConfigurePPU NMIOnVBlank|BGAddr0|PPUInc1|NameTable20
; Enable graphics.
JSR EnableGFX
MainLoop:
JMP MainLoop ; Jump back, infinite loop. All game logic performed on NMI.
; Non Maskable Interrupt, ran once per frame when VBlank triggers.
NMI:
; Set the scroll register using our stored values.
LDX ScrollX
LDY ScrollY
CPX #$FF
BNE +
LDA ActiveScreen
EOR #$01
STA ActiveScreen
STA PPUControl1
* INX
STX ScrollX
STX BGScroll
STY BGScroll
; PPU updates are done, run the game logic.
;ReadPads:
; Read the controller states.
JSR ReadController1
JSR ReadController2
RTI ; ReTurn from Interrupt
; Set up the 3 main vectors the NES looks for
; at the end of the ROM on power-up.
; Unlike the .org directive, .advance will advance the program
; counter and zero fill the space leading up to it to pad the
; binary up to the designated location. This is necessary in places
; like this, where the hardware expects a lookup table with the
; necessary functions to set up the NES and get things running.
.advance $FFFA ; First of the three vectors starts here
.word NMI ; Non-Maskable Interrupt, runs at VBlank, once per frame.
.word RESET ; This function is performed on power-on and reset.
.word 0 ; external IRQ is not used here |
org #4000
ld a, 0
ld b, 0
ld c, 1
ld hl, var1
add hl, bc
ld (hl), a
loop:
jr loop
org #c000
var1: db 1
|
; WARNING: do not edit!
; Generated from openssl/crypto/modes/asm/aesni-gcm-x86_64.pl
;
; Copyright 2013-2020 The OpenSSL Project Authors. All Rights Reserved.
;
; Licensed under the OpenSSL license (the "License"). You may not use
; this file except in compliance with the License. You can obtain a copy
; in the file LICENSE in the source distribution or at
; https://www.openssl.org/source/license.html
default rel
%define XMMWORD
%define YMMWORD
%define ZMMWORD
section .text code align=64
global aesni_gcm_encrypt
aesni_gcm_encrypt:
xor eax,eax
DB 0F3h,0C3h ;repret
global aesni_gcm_decrypt
aesni_gcm_decrypt:
xor eax,eax
DB 0F3h,0C3h ;repret
|
// 4. Квадратно уравнение
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
// Коефициенти на квадратното уравнение
int a, b, c;
// Въвеждаме коефициентите
cout << "a=?, b=?, c=?" << endl;
cin >> a >> b >> c;
// Извършваме математически сметки
float d = pow(b, 2) - 4 * a * c;
float x1 = ((-b) + sqrt(d)) / (2 * a);
float x2 = ((-b) - sqrt(d)) / (2 * a);
// Отпечатаме получения резултат
cout << "d=" << d << endl;
cout << "x1=" << x1 << endl;
cout << "x2=" << x2 << endl;
return 0;
} |
.model small
.stack 100h
.data
nr dw 0Bh
nl db 10,13,'$'
.code
start:
mov ax, @data
mov ds, ax
mov bx, nr
mov cx, 8
print:
mov ah, 02h
mov dl, '0'
test bx, 10000000b
jz zero
mov dl, '1'
zero:
int 21h
shl bx, 1
loop print
mov ah, 4ch
int 21h
end start
|
; A169459: Number of reduced words of length n in Coxeter group on 14 generators S_i with relations (S_i)^2 = (S_i S_j)^33 = I.
; 1,14,182,2366,30758,399854,5198102,67575326,878479238,11420230094,148462991222,1930018885886,25090245516518,326173191714734,4240251492291542,55123269399790046,716602502197270598
add $0,1
mov $3,1
lpb $0
sub $0,1
add $2,$3
div $3,$2
mul $2,13
lpe
mov $0,$2
div $0,13
|
obj/user/forktree.debug: 文件格式 elf32-i386
Disassembly of section .text:
00800020 <_start>:
// starts us running when we are initially loaded into a new environment.
.text
.globl _start
_start:
// See if we were started with arguments on the stack
cmpl $USTACKTOP, %esp
800020: 81 fc 00 e0 bf ee cmp $0xeebfe000,%esp
jne args_exist
800026: 75 04 jne 80002c <args_exist>
// If not, push dummy argc/argv arguments.
// This happens when we are loaded by the kernel,
// because the kernel does not know about passing arguments.
pushl $0
800028: 6a 00 push $0x0
pushl $0
80002a: 6a 00 push $0x0
0080002c <args_exist>:
args_exist:
call libmain
80002c: e8 b2 00 00 00 call 8000e3 <libmain>
1: jmp 1b
800031: eb fe jmp 800031 <args_exist+0x5>
00800033 <forktree>:
}
}
void
forktree(const char *cur)
{
800033: 55 push %ebp
800034: 89 e5 mov %esp,%ebp
800036: 53 push %ebx
800037: 83 ec 04 sub $0x4,%esp
80003a: 8b 5d 08 mov 0x8(%ebp),%ebx
cprintf("%04x: I am '%s'\n", sys_getenvid(), cur);
80003d: e8 68 0b 00 00 call 800baa <sys_getenvid>
800042: 83 ec 04 sub $0x4,%esp
800045: 53 push %ebx
800046: 50 push %eax
800047: 68 a0 13 80 00 push $0x8013a0
80004c: e8 7f 01 00 00 call 8001d0 <cprintf>
forkchild(cur, '0');
800051: 83 c4 08 add $0x8,%esp
800054: 6a 30 push $0x30
800056: 53 push %ebx
800057: e8 13 00 00 00 call 80006f <forkchild>
forkchild(cur, '1');
80005c: 83 c4 08 add $0x8,%esp
80005f: 6a 31 push $0x31
800061: 53 push %ebx
800062: e8 08 00 00 00 call 80006f <forkchild>
}
800067: 83 c4 10 add $0x10,%esp
80006a: 8b 5d fc mov -0x4(%ebp),%ebx
80006d: c9 leave
80006e: c3 ret
0080006f <forkchild>:
{
80006f: 55 push %ebp
800070: 89 e5 mov %esp,%ebp
800072: 56 push %esi
800073: 53 push %ebx
800074: 83 ec 1c sub $0x1c,%esp
800077: 8b 5d 08 mov 0x8(%ebp),%ebx
80007a: 8b 75 0c mov 0xc(%ebp),%esi
if (strlen(cur) >= DEPTH)
80007d: 53 push %ebx
80007e: e8 35 07 00 00 call 8007b8 <strlen>
800083: 83 c4 10 add $0x10,%esp
800086: 83 f8 02 cmp $0x2,%eax
800089: 7e 07 jle 800092 <forkchild+0x23>
}
80008b: 8d 65 f8 lea -0x8(%ebp),%esp
80008e: 5b pop %ebx
80008f: 5e pop %esi
800090: 5d pop %ebp
800091: c3 ret
snprintf(nxt, DEPTH+1, "%s%c", cur, branch);
800092: 83 ec 0c sub $0xc,%esp
800095: 89 f0 mov %esi,%eax
800097: 0f be f0 movsbl %al,%esi
80009a: 56 push %esi
80009b: 53 push %ebx
80009c: 68 b1 13 80 00 push $0x8013b1
8000a1: 6a 04 push $0x4
8000a3: 8d 45 f4 lea -0xc(%ebp),%eax
8000a6: 50 push %eax
8000a7: e8 f2 06 00 00 call 80079e <snprintf>
if (fork() == 0) {
8000ac: 83 c4 20 add $0x20,%esp
8000af: e8 f5 0d 00 00 call 800ea9 <fork>
8000b4: 85 c0 test %eax,%eax
8000b6: 75 d3 jne 80008b <forkchild+0x1c>
forktree(nxt);
8000b8: 83 ec 0c sub $0xc,%esp
8000bb: 8d 45 f4 lea -0xc(%ebp),%eax
8000be: 50 push %eax
8000bf: e8 6f ff ff ff call 800033 <forktree>
exit();
8000c4: e8 60 00 00 00 call 800129 <exit>
8000c9: 83 c4 10 add $0x10,%esp
8000cc: eb bd jmp 80008b <forkchild+0x1c>
008000ce <umain>:
void
umain(int argc, char **argv)
{
8000ce: 55 push %ebp
8000cf: 89 e5 mov %esp,%ebp
8000d1: 83 ec 14 sub $0x14,%esp
forktree("");
8000d4: 68 b0 13 80 00 push $0x8013b0
8000d9: e8 55 ff ff ff call 800033 <forktree>
}
8000de: 83 c4 10 add $0x10,%esp
8000e1: c9 leave
8000e2: c3 ret
008000e3 <libmain>:
const volatile struct Env *thisenv;
const char *binaryname = "<unknown>";
void
libmain(int argc, char **argv)
{
8000e3: 55 push %ebp
8000e4: 89 e5 mov %esp,%ebp
8000e6: 56 push %esi
8000e7: 53 push %ebx
8000e8: 8b 5d 08 mov 0x8(%ebp),%ebx
8000eb: 8b 75 0c mov 0xc(%ebp),%esi
// set thisenv to point at our Env structure in envs[].
// LAB 3: Your code here.
envid_t envid = sys_getenvid();
8000ee: e8 b7 0a 00 00 call 800baa <sys_getenvid>
thisenv = envs + ENVX(envid);
8000f3: 25 ff 03 00 00 and $0x3ff,%eax
8000f8: 6b c0 7c imul $0x7c,%eax,%eax
8000fb: 05 00 00 c0 ee add $0xeec00000,%eax
800100: a3 04 20 80 00 mov %eax,0x802004
// save the name of the program so that panic() can use it
if (argc > 0)
800105: 85 db test %ebx,%ebx
800107: 7e 07 jle 800110 <libmain+0x2d>
binaryname = argv[0];
800109: 8b 06 mov (%esi),%eax
80010b: a3 00 20 80 00 mov %eax,0x802000
// call user main routine
umain(argc, argv);
800110: 83 ec 08 sub $0x8,%esp
800113: 56 push %esi
800114: 53 push %ebx
800115: e8 b4 ff ff ff call 8000ce <umain>
// exit gracefully
exit();
80011a: e8 0a 00 00 00 call 800129 <exit>
}
80011f: 83 c4 10 add $0x10,%esp
800122: 8d 65 f8 lea -0x8(%ebp),%esp
800125: 5b pop %ebx
800126: 5e pop %esi
800127: 5d pop %ebp
800128: c3 ret
00800129 <exit>:
#include <inc/lib.h>
void
exit(void)
{
800129: 55 push %ebp
80012a: 89 e5 mov %esp,%ebp
80012c: 83 ec 14 sub $0x14,%esp
// close_all();
sys_env_destroy(0);
80012f: 6a 00 push $0x0
800131: e8 33 0a 00 00 call 800b69 <sys_env_destroy>
}
800136: 83 c4 10 add $0x10,%esp
800139: c9 leave
80013a: c3 ret
0080013b <putch>:
};
static void
putch(int ch, struct printbuf *b)
{
80013b: 55 push %ebp
80013c: 89 e5 mov %esp,%ebp
80013e: 53 push %ebx
80013f: 83 ec 04 sub $0x4,%esp
800142: 8b 5d 0c mov 0xc(%ebp),%ebx
b->buf[b->idx++] = ch;
800145: 8b 13 mov (%ebx),%edx
800147: 8d 42 01 lea 0x1(%edx),%eax
80014a: 89 03 mov %eax,(%ebx)
80014c: 8b 4d 08 mov 0x8(%ebp),%ecx
80014f: 88 4c 13 08 mov %cl,0x8(%ebx,%edx,1)
if (b->idx == 256-1) {
800153: 3d ff 00 00 00 cmp $0xff,%eax
800158: 74 09 je 800163 <putch+0x28>
sys_cputs(b->buf, b->idx);
b->idx = 0;
}
b->cnt++;
80015a: 83 43 04 01 addl $0x1,0x4(%ebx)
}
80015e: 8b 5d fc mov -0x4(%ebp),%ebx
800161: c9 leave
800162: c3 ret
sys_cputs(b->buf, b->idx);
800163: 83 ec 08 sub $0x8,%esp
800166: 68 ff 00 00 00 push $0xff
80016b: 8d 43 08 lea 0x8(%ebx),%eax
80016e: 50 push %eax
80016f: e8 b8 09 00 00 call 800b2c <sys_cputs>
b->idx = 0;
800174: c7 03 00 00 00 00 movl $0x0,(%ebx)
80017a: 83 c4 10 add $0x10,%esp
80017d: eb db jmp 80015a <putch+0x1f>
0080017f <vcprintf>:
int
vcprintf(const char *fmt, va_list ap)
{
80017f: 55 push %ebp
800180: 89 e5 mov %esp,%ebp
800182: 81 ec 18 01 00 00 sub $0x118,%esp
struct printbuf b;
b.idx = 0;
800188: c7 85 f0 fe ff ff 00 movl $0x0,-0x110(%ebp)
80018f: 00 00 00
b.cnt = 0;
800192: c7 85 f4 fe ff ff 00 movl $0x0,-0x10c(%ebp)
800199: 00 00 00
vprintfmt((void*)putch, &b, fmt, ap);
80019c: ff 75 0c pushl 0xc(%ebp)
80019f: ff 75 08 pushl 0x8(%ebp)
8001a2: 8d 85 f0 fe ff ff lea -0x110(%ebp),%eax
8001a8: 50 push %eax
8001a9: 68 3b 01 80 00 push $0x80013b
8001ae: e8 1a 01 00 00 call 8002cd <vprintfmt>
sys_cputs(b.buf, b.idx);
8001b3: 83 c4 08 add $0x8,%esp
8001b6: ff b5 f0 fe ff ff pushl -0x110(%ebp)
8001bc: 8d 85 f8 fe ff ff lea -0x108(%ebp),%eax
8001c2: 50 push %eax
8001c3: e8 64 09 00 00 call 800b2c <sys_cputs>
return b.cnt;
}
8001c8: 8b 85 f4 fe ff ff mov -0x10c(%ebp),%eax
8001ce: c9 leave
8001cf: c3 ret
008001d0 <cprintf>:
int
cprintf(const char *fmt, ...)
{
8001d0: 55 push %ebp
8001d1: 89 e5 mov %esp,%ebp
8001d3: 83 ec 10 sub $0x10,%esp
va_list ap;
int cnt;
va_start(ap, fmt);
8001d6: 8d 45 0c lea 0xc(%ebp),%eax
cnt = vcprintf(fmt, ap);
8001d9: 50 push %eax
8001da: ff 75 08 pushl 0x8(%ebp)
8001dd: e8 9d ff ff ff call 80017f <vcprintf>
va_end(ap);
return cnt;
}
8001e2: c9 leave
8001e3: c3 ret
008001e4 <printnum>:
* using specified putch function and associated pointer putdat.
*/
static void
printnum(void (*putch)(int, void*), void *putdat,
unsigned long long num, unsigned base, int width, int padc)
{
8001e4: 55 push %ebp
8001e5: 89 e5 mov %esp,%ebp
8001e7: 57 push %edi
8001e8: 56 push %esi
8001e9: 53 push %ebx
8001ea: 83 ec 1c sub $0x1c,%esp
8001ed: 89 c7 mov %eax,%edi
8001ef: 89 d6 mov %edx,%esi
8001f1: 8b 45 08 mov 0x8(%ebp),%eax
8001f4: 8b 55 0c mov 0xc(%ebp),%edx
8001f7: 89 45 d8 mov %eax,-0x28(%ebp)
8001fa: 89 55 dc mov %edx,-0x24(%ebp)
// first recursively print all preceding (more significant) digits
if (num >= base) {
8001fd: 8b 4d 10 mov 0x10(%ebp),%ecx
800200: bb 00 00 00 00 mov $0x0,%ebx
800205: 89 4d e0 mov %ecx,-0x20(%ebp)
800208: 89 5d e4 mov %ebx,-0x1c(%ebp)
80020b: 39 d3 cmp %edx,%ebx
80020d: 72 05 jb 800214 <printnum+0x30>
80020f: 39 45 10 cmp %eax,0x10(%ebp)
800212: 77 7a ja 80028e <printnum+0xaa>
printnum(putch, putdat, num / base, base, width - 1, padc);
800214: 83 ec 0c sub $0xc,%esp
800217: ff 75 18 pushl 0x18(%ebp)
80021a: 8b 45 14 mov 0x14(%ebp),%eax
80021d: 8d 58 ff lea -0x1(%eax),%ebx
800220: 53 push %ebx
800221: ff 75 10 pushl 0x10(%ebp)
800224: 83 ec 08 sub $0x8,%esp
800227: ff 75 e4 pushl -0x1c(%ebp)
80022a: ff 75 e0 pushl -0x20(%ebp)
80022d: ff 75 dc pushl -0x24(%ebp)
800230: ff 75 d8 pushl -0x28(%ebp)
800233: e8 28 0f 00 00 call 801160 <__udivdi3>
800238: 83 c4 18 add $0x18,%esp
80023b: 52 push %edx
80023c: 50 push %eax
80023d: 89 f2 mov %esi,%edx
80023f: 89 f8 mov %edi,%eax
800241: e8 9e ff ff ff call 8001e4 <printnum>
800246: 83 c4 20 add $0x20,%esp
800249: eb 13 jmp 80025e <printnum+0x7a>
} else {
// print any needed pad characters before first digit
while (--width > 0)
putch(padc, putdat);
80024b: 83 ec 08 sub $0x8,%esp
80024e: 56 push %esi
80024f: ff 75 18 pushl 0x18(%ebp)
800252: ff d7 call *%edi
800254: 83 c4 10 add $0x10,%esp
while (--width > 0)
800257: 83 eb 01 sub $0x1,%ebx
80025a: 85 db test %ebx,%ebx
80025c: 7f ed jg 80024b <printnum+0x67>
}
// then print this (the least significant) digit
putch("0123456789abcdef"[num % base], putdat);
80025e: 83 ec 08 sub $0x8,%esp
800261: 56 push %esi
800262: 83 ec 04 sub $0x4,%esp
800265: ff 75 e4 pushl -0x1c(%ebp)
800268: ff 75 e0 pushl -0x20(%ebp)
80026b: ff 75 dc pushl -0x24(%ebp)
80026e: ff 75 d8 pushl -0x28(%ebp)
800271: e8 0a 10 00 00 call 801280 <__umoddi3>
800276: 83 c4 14 add $0x14,%esp
800279: 0f be 80 c0 13 80 00 movsbl 0x8013c0(%eax),%eax
800280: 50 push %eax
800281: ff d7 call *%edi
}
800283: 83 c4 10 add $0x10,%esp
800286: 8d 65 f4 lea -0xc(%ebp),%esp
800289: 5b pop %ebx
80028a: 5e pop %esi
80028b: 5f pop %edi
80028c: 5d pop %ebp
80028d: c3 ret
80028e: 8b 5d 14 mov 0x14(%ebp),%ebx
800291: eb c4 jmp 800257 <printnum+0x73>
00800293 <sprintputch>:
int cnt;
};
static void
sprintputch(int ch, struct sprintbuf *b)
{
800293: 55 push %ebp
800294: 89 e5 mov %esp,%ebp
800296: 8b 45 0c mov 0xc(%ebp),%eax
b->cnt++;
800299: 83 40 08 01 addl $0x1,0x8(%eax)
if (b->buf < b->ebuf)
80029d: 8b 10 mov (%eax),%edx
80029f: 3b 50 04 cmp 0x4(%eax),%edx
8002a2: 73 0a jae 8002ae <sprintputch+0x1b>
*b->buf++ = ch;
8002a4: 8d 4a 01 lea 0x1(%edx),%ecx
8002a7: 89 08 mov %ecx,(%eax)
8002a9: 8b 45 08 mov 0x8(%ebp),%eax
8002ac: 88 02 mov %al,(%edx)
}
8002ae: 5d pop %ebp
8002af: c3 ret
008002b0 <printfmt>:
{
8002b0: 55 push %ebp
8002b1: 89 e5 mov %esp,%ebp
8002b3: 83 ec 08 sub $0x8,%esp
va_start(ap, fmt);
8002b6: 8d 45 14 lea 0x14(%ebp),%eax
vprintfmt(putch, putdat, fmt, ap);
8002b9: 50 push %eax
8002ba: ff 75 10 pushl 0x10(%ebp)
8002bd: ff 75 0c pushl 0xc(%ebp)
8002c0: ff 75 08 pushl 0x8(%ebp)
8002c3: e8 05 00 00 00 call 8002cd <vprintfmt>
}
8002c8: 83 c4 10 add $0x10,%esp
8002cb: c9 leave
8002cc: c3 ret
008002cd <vprintfmt>:
{
8002cd: 55 push %ebp
8002ce: 89 e5 mov %esp,%ebp
8002d0: 57 push %edi
8002d1: 56 push %esi
8002d2: 53 push %ebx
8002d3: 83 ec 2c sub $0x2c,%esp
8002d6: 8b 75 08 mov 0x8(%ebp),%esi
8002d9: 8b 5d 0c mov 0xc(%ebp),%ebx
8002dc: 8b 7d 10 mov 0x10(%ebp),%edi
8002df: e9 c1 03 00 00 jmp 8006a5 <vprintfmt+0x3d8>
padc = ' ';
8002e4: c6 45 d4 20 movb $0x20,-0x2c(%ebp)
altflag = 0;
8002e8: c7 45 d8 00 00 00 00 movl $0x0,-0x28(%ebp)
precision = -1;
8002ef: c7 45 d0 ff ff ff ff movl $0xffffffff,-0x30(%ebp)
width = -1;
8002f6: c7 45 e0 ff ff ff ff movl $0xffffffff,-0x20(%ebp)
lflag = 0;
8002fd: b9 00 00 00 00 mov $0x0,%ecx
switch (ch = *(unsigned char *) fmt++) {
800302: 8d 47 01 lea 0x1(%edi),%eax
800305: 89 45 e4 mov %eax,-0x1c(%ebp)
800308: 0f b6 17 movzbl (%edi),%edx
80030b: 8d 42 dd lea -0x23(%edx),%eax
80030e: 3c 55 cmp $0x55,%al
800310: 0f 87 12 04 00 00 ja 800728 <vprintfmt+0x45b>
800316: 0f b6 c0 movzbl %al,%eax
800319: ff 24 85 00 15 80 00 jmp *0x801500(,%eax,4)
800320: 8b 7d e4 mov -0x1c(%ebp),%edi
padc = '-';
800323: c6 45 d4 2d movb $0x2d,-0x2c(%ebp)
800327: eb d9 jmp 800302 <vprintfmt+0x35>
switch (ch = *(unsigned char *) fmt++) {
800329: 8b 7d e4 mov -0x1c(%ebp),%edi
padc = '0';
80032c: c6 45 d4 30 movb $0x30,-0x2c(%ebp)
800330: eb d0 jmp 800302 <vprintfmt+0x35>
switch (ch = *(unsigned char *) fmt++) {
800332: 0f b6 d2 movzbl %dl,%edx
800335: 8b 7d e4 mov -0x1c(%ebp),%edi
for (precision = 0; ; ++fmt) {
800338: b8 00 00 00 00 mov $0x0,%eax
80033d: 89 4d e4 mov %ecx,-0x1c(%ebp)
precision = precision * 10 + ch - '0';
800340: 8d 04 80 lea (%eax,%eax,4),%eax
800343: 8d 44 42 d0 lea -0x30(%edx,%eax,2),%eax
ch = *fmt;
800347: 0f be 17 movsbl (%edi),%edx
if (ch < '0' || ch > '9')
80034a: 8d 4a d0 lea -0x30(%edx),%ecx
80034d: 83 f9 09 cmp $0x9,%ecx
800350: 77 55 ja 8003a7 <vprintfmt+0xda>
for (precision = 0; ; ++fmt) {
800352: 83 c7 01 add $0x1,%edi
precision = precision * 10 + ch - '0';
800355: eb e9 jmp 800340 <vprintfmt+0x73>
precision = va_arg(ap, int);
800357: 8b 45 14 mov 0x14(%ebp),%eax
80035a: 8b 00 mov (%eax),%eax
80035c: 89 45 d0 mov %eax,-0x30(%ebp)
80035f: 8b 45 14 mov 0x14(%ebp),%eax
800362: 8d 40 04 lea 0x4(%eax),%eax
800365: 89 45 14 mov %eax,0x14(%ebp)
switch (ch = *(unsigned char *) fmt++) {
800368: 8b 7d e4 mov -0x1c(%ebp),%edi
if (width < 0)
80036b: 83 7d e0 00 cmpl $0x0,-0x20(%ebp)
80036f: 79 91 jns 800302 <vprintfmt+0x35>
width = precision, precision = -1;
800371: 8b 45 d0 mov -0x30(%ebp),%eax
800374: 89 45 e0 mov %eax,-0x20(%ebp)
800377: c7 45 d0 ff ff ff ff movl $0xffffffff,-0x30(%ebp)
80037e: eb 82 jmp 800302 <vprintfmt+0x35>
800380: 8b 45 e0 mov -0x20(%ebp),%eax
800383: 85 c0 test %eax,%eax
800385: ba 00 00 00 00 mov $0x0,%edx
80038a: 0f 49 d0 cmovns %eax,%edx
80038d: 89 55 e0 mov %edx,-0x20(%ebp)
switch (ch = *(unsigned char *) fmt++) {
800390: 8b 7d e4 mov -0x1c(%ebp),%edi
800393: e9 6a ff ff ff jmp 800302 <vprintfmt+0x35>
800398: 8b 7d e4 mov -0x1c(%ebp),%edi
altflag = 1;
80039b: c7 45 d8 01 00 00 00 movl $0x1,-0x28(%ebp)
goto reswitch;
8003a2: e9 5b ff ff ff jmp 800302 <vprintfmt+0x35>
8003a7: 8b 4d e4 mov -0x1c(%ebp),%ecx
8003aa: 89 45 d0 mov %eax,-0x30(%ebp)
8003ad: eb bc jmp 80036b <vprintfmt+0x9e>
lflag++;
8003af: 83 c1 01 add $0x1,%ecx
switch (ch = *(unsigned char *) fmt++) {
8003b2: 8b 7d e4 mov -0x1c(%ebp),%edi
goto reswitch;
8003b5: e9 48 ff ff ff jmp 800302 <vprintfmt+0x35>
putch(va_arg(ap, int), putdat);
8003ba: 8b 45 14 mov 0x14(%ebp),%eax
8003bd: 8d 78 04 lea 0x4(%eax),%edi
8003c0: 83 ec 08 sub $0x8,%esp
8003c3: 53 push %ebx
8003c4: ff 30 pushl (%eax)
8003c6: ff d6 call *%esi
break;
8003c8: 83 c4 10 add $0x10,%esp
putch(va_arg(ap, int), putdat);
8003cb: 89 7d 14 mov %edi,0x14(%ebp)
break;
8003ce: e9 cf 02 00 00 jmp 8006a2 <vprintfmt+0x3d5>
err = va_arg(ap, int);
8003d3: 8b 45 14 mov 0x14(%ebp),%eax
8003d6: 8d 78 04 lea 0x4(%eax),%edi
8003d9: 8b 00 mov (%eax),%eax
8003db: 99 cltd
8003dc: 31 d0 xor %edx,%eax
8003de: 29 d0 sub %edx,%eax
if (err >= MAXERROR || (p = error_string[err]) == NULL)
8003e0: 83 f8 0f cmp $0xf,%eax
8003e3: 7f 23 jg 800408 <vprintfmt+0x13b>
8003e5: 8b 14 85 60 16 80 00 mov 0x801660(,%eax,4),%edx
8003ec: 85 d2 test %edx,%edx
8003ee: 74 18 je 800408 <vprintfmt+0x13b>
printfmt(putch, putdat, "%s", p);
8003f0: 52 push %edx
8003f1: 68 e1 13 80 00 push $0x8013e1
8003f6: 53 push %ebx
8003f7: 56 push %esi
8003f8: e8 b3 fe ff ff call 8002b0 <printfmt>
8003fd: 83 c4 10 add $0x10,%esp
err = va_arg(ap, int);
800400: 89 7d 14 mov %edi,0x14(%ebp)
800403: e9 9a 02 00 00 jmp 8006a2 <vprintfmt+0x3d5>
printfmt(putch, putdat, "error %d", err);
800408: 50 push %eax
800409: 68 d8 13 80 00 push $0x8013d8
80040e: 53 push %ebx
80040f: 56 push %esi
800410: e8 9b fe ff ff call 8002b0 <printfmt>
800415: 83 c4 10 add $0x10,%esp
err = va_arg(ap, int);
800418: 89 7d 14 mov %edi,0x14(%ebp)
printfmt(putch, putdat, "error %d", err);
80041b: e9 82 02 00 00 jmp 8006a2 <vprintfmt+0x3d5>
if ((p = va_arg(ap, char *)) == NULL)
800420: 8b 45 14 mov 0x14(%ebp),%eax
800423: 83 c0 04 add $0x4,%eax
800426: 89 45 cc mov %eax,-0x34(%ebp)
800429: 8b 45 14 mov 0x14(%ebp),%eax
80042c: 8b 38 mov (%eax),%edi
p = "(null)";
80042e: 85 ff test %edi,%edi
800430: b8 d1 13 80 00 mov $0x8013d1,%eax
800435: 0f 44 f8 cmove %eax,%edi
if (width > 0 && padc != '-')
800438: 83 7d e0 00 cmpl $0x0,-0x20(%ebp)
80043c: 0f 8e bd 00 00 00 jle 8004ff <vprintfmt+0x232>
800442: 80 7d d4 2d cmpb $0x2d,-0x2c(%ebp)
800446: 75 0e jne 800456 <vprintfmt+0x189>
800448: 89 75 08 mov %esi,0x8(%ebp)
80044b: 8b 75 d0 mov -0x30(%ebp),%esi
80044e: 89 5d 0c mov %ebx,0xc(%ebp)
800451: 8b 5d e0 mov -0x20(%ebp),%ebx
800454: eb 6d jmp 8004c3 <vprintfmt+0x1f6>
for (width -= strnlen(p, precision); width > 0; width--)
800456: 83 ec 08 sub $0x8,%esp
800459: ff 75 d0 pushl -0x30(%ebp)
80045c: 57 push %edi
80045d: e8 6e 03 00 00 call 8007d0 <strnlen>
800462: 8b 4d e0 mov -0x20(%ebp),%ecx
800465: 29 c1 sub %eax,%ecx
800467: 89 4d c8 mov %ecx,-0x38(%ebp)
80046a: 83 c4 10 add $0x10,%esp
putch(padc, putdat);
80046d: 0f be 45 d4 movsbl -0x2c(%ebp),%eax
800471: 89 45 e0 mov %eax,-0x20(%ebp)
800474: 89 7d d4 mov %edi,-0x2c(%ebp)
800477: 89 cf mov %ecx,%edi
for (width -= strnlen(p, precision); width > 0; width--)
800479: eb 0f jmp 80048a <vprintfmt+0x1bd>
putch(padc, putdat);
80047b: 83 ec 08 sub $0x8,%esp
80047e: 53 push %ebx
80047f: ff 75 e0 pushl -0x20(%ebp)
800482: ff d6 call *%esi
for (width -= strnlen(p, precision); width > 0; width--)
800484: 83 ef 01 sub $0x1,%edi
800487: 83 c4 10 add $0x10,%esp
80048a: 85 ff test %edi,%edi
80048c: 7f ed jg 80047b <vprintfmt+0x1ae>
80048e: 8b 7d d4 mov -0x2c(%ebp),%edi
800491: 8b 4d c8 mov -0x38(%ebp),%ecx
800494: 85 c9 test %ecx,%ecx
800496: b8 00 00 00 00 mov $0x0,%eax
80049b: 0f 49 c1 cmovns %ecx,%eax
80049e: 29 c1 sub %eax,%ecx
8004a0: 89 75 08 mov %esi,0x8(%ebp)
8004a3: 8b 75 d0 mov -0x30(%ebp),%esi
8004a6: 89 5d 0c mov %ebx,0xc(%ebp)
8004a9: 89 cb mov %ecx,%ebx
8004ab: eb 16 jmp 8004c3 <vprintfmt+0x1f6>
if (altflag && (ch < ' ' || ch > '~'))
8004ad: 83 7d d8 00 cmpl $0x0,-0x28(%ebp)
8004b1: 75 31 jne 8004e4 <vprintfmt+0x217>
putch(ch, putdat);
8004b3: 83 ec 08 sub $0x8,%esp
8004b6: ff 75 0c pushl 0xc(%ebp)
8004b9: 50 push %eax
8004ba: ff 55 08 call *0x8(%ebp)
8004bd: 83 c4 10 add $0x10,%esp
for (; (ch = *p++) != '\0' && (precision < 0 || --precision >= 0); width--)
8004c0: 83 eb 01 sub $0x1,%ebx
8004c3: 83 c7 01 add $0x1,%edi
8004c6: 0f b6 57 ff movzbl -0x1(%edi),%edx
8004ca: 0f be c2 movsbl %dl,%eax
8004cd: 85 c0 test %eax,%eax
8004cf: 74 59 je 80052a <vprintfmt+0x25d>
8004d1: 85 f6 test %esi,%esi
8004d3: 78 d8 js 8004ad <vprintfmt+0x1e0>
8004d5: 83 ee 01 sub $0x1,%esi
8004d8: 79 d3 jns 8004ad <vprintfmt+0x1e0>
8004da: 89 df mov %ebx,%edi
8004dc: 8b 75 08 mov 0x8(%ebp),%esi
8004df: 8b 5d 0c mov 0xc(%ebp),%ebx
8004e2: eb 37 jmp 80051b <vprintfmt+0x24e>
if (altflag && (ch < ' ' || ch > '~'))
8004e4: 0f be d2 movsbl %dl,%edx
8004e7: 83 ea 20 sub $0x20,%edx
8004ea: 83 fa 5e cmp $0x5e,%edx
8004ed: 76 c4 jbe 8004b3 <vprintfmt+0x1e6>
putch('?', putdat);
8004ef: 83 ec 08 sub $0x8,%esp
8004f2: ff 75 0c pushl 0xc(%ebp)
8004f5: 6a 3f push $0x3f
8004f7: ff 55 08 call *0x8(%ebp)
8004fa: 83 c4 10 add $0x10,%esp
8004fd: eb c1 jmp 8004c0 <vprintfmt+0x1f3>
8004ff: 89 75 08 mov %esi,0x8(%ebp)
800502: 8b 75 d0 mov -0x30(%ebp),%esi
800505: 89 5d 0c mov %ebx,0xc(%ebp)
800508: 8b 5d e0 mov -0x20(%ebp),%ebx
80050b: eb b6 jmp 8004c3 <vprintfmt+0x1f6>
putch(' ', putdat);
80050d: 83 ec 08 sub $0x8,%esp
800510: 53 push %ebx
800511: 6a 20 push $0x20
800513: ff d6 call *%esi
for (; width > 0; width--)
800515: 83 ef 01 sub $0x1,%edi
800518: 83 c4 10 add $0x10,%esp
80051b: 85 ff test %edi,%edi
80051d: 7f ee jg 80050d <vprintfmt+0x240>
if ((p = va_arg(ap, char *)) == NULL)
80051f: 8b 45 cc mov -0x34(%ebp),%eax
800522: 89 45 14 mov %eax,0x14(%ebp)
800525: e9 78 01 00 00 jmp 8006a2 <vprintfmt+0x3d5>
80052a: 89 df mov %ebx,%edi
80052c: 8b 75 08 mov 0x8(%ebp),%esi
80052f: 8b 5d 0c mov 0xc(%ebp),%ebx
800532: eb e7 jmp 80051b <vprintfmt+0x24e>
if (lflag >= 2)
800534: 83 f9 01 cmp $0x1,%ecx
800537: 7e 3f jle 800578 <vprintfmt+0x2ab>
return va_arg(*ap, long long);
800539: 8b 45 14 mov 0x14(%ebp),%eax
80053c: 8b 50 04 mov 0x4(%eax),%edx
80053f: 8b 00 mov (%eax),%eax
800541: 89 45 d8 mov %eax,-0x28(%ebp)
800544: 89 55 dc mov %edx,-0x24(%ebp)
800547: 8b 45 14 mov 0x14(%ebp),%eax
80054a: 8d 40 08 lea 0x8(%eax),%eax
80054d: 89 45 14 mov %eax,0x14(%ebp)
if ((long long) num < 0) {
800550: 83 7d dc 00 cmpl $0x0,-0x24(%ebp)
800554: 79 5c jns 8005b2 <vprintfmt+0x2e5>
putch('-', putdat);
800556: 83 ec 08 sub $0x8,%esp
800559: 53 push %ebx
80055a: 6a 2d push $0x2d
80055c: ff d6 call *%esi
num = -(long long) num;
80055e: 8b 55 d8 mov -0x28(%ebp),%edx
800561: 8b 4d dc mov -0x24(%ebp),%ecx
800564: f7 da neg %edx
800566: 83 d1 00 adc $0x0,%ecx
800569: f7 d9 neg %ecx
80056b: 83 c4 10 add $0x10,%esp
base = 10;
80056e: b8 0a 00 00 00 mov $0xa,%eax
800573: e9 10 01 00 00 jmp 800688 <vprintfmt+0x3bb>
else if (lflag)
800578: 85 c9 test %ecx,%ecx
80057a: 75 1b jne 800597 <vprintfmt+0x2ca>
return va_arg(*ap, int);
80057c: 8b 45 14 mov 0x14(%ebp),%eax
80057f: 8b 00 mov (%eax),%eax
800581: 89 45 d8 mov %eax,-0x28(%ebp)
800584: 89 c1 mov %eax,%ecx
800586: c1 f9 1f sar $0x1f,%ecx
800589: 89 4d dc mov %ecx,-0x24(%ebp)
80058c: 8b 45 14 mov 0x14(%ebp),%eax
80058f: 8d 40 04 lea 0x4(%eax),%eax
800592: 89 45 14 mov %eax,0x14(%ebp)
800595: eb b9 jmp 800550 <vprintfmt+0x283>
return va_arg(*ap, long);
800597: 8b 45 14 mov 0x14(%ebp),%eax
80059a: 8b 00 mov (%eax),%eax
80059c: 89 45 d8 mov %eax,-0x28(%ebp)
80059f: 89 c1 mov %eax,%ecx
8005a1: c1 f9 1f sar $0x1f,%ecx
8005a4: 89 4d dc mov %ecx,-0x24(%ebp)
8005a7: 8b 45 14 mov 0x14(%ebp),%eax
8005aa: 8d 40 04 lea 0x4(%eax),%eax
8005ad: 89 45 14 mov %eax,0x14(%ebp)
8005b0: eb 9e jmp 800550 <vprintfmt+0x283>
num = getint(&ap, lflag);
8005b2: 8b 55 d8 mov -0x28(%ebp),%edx
8005b5: 8b 4d dc mov -0x24(%ebp),%ecx
base = 10;
8005b8: b8 0a 00 00 00 mov $0xa,%eax
8005bd: e9 c6 00 00 00 jmp 800688 <vprintfmt+0x3bb>
if (lflag >= 2)
8005c2: 83 f9 01 cmp $0x1,%ecx
8005c5: 7e 18 jle 8005df <vprintfmt+0x312>
return va_arg(*ap, unsigned long long);
8005c7: 8b 45 14 mov 0x14(%ebp),%eax
8005ca: 8b 10 mov (%eax),%edx
8005cc: 8b 48 04 mov 0x4(%eax),%ecx
8005cf: 8d 40 08 lea 0x8(%eax),%eax
8005d2: 89 45 14 mov %eax,0x14(%ebp)
base = 10;
8005d5: b8 0a 00 00 00 mov $0xa,%eax
8005da: e9 a9 00 00 00 jmp 800688 <vprintfmt+0x3bb>
else if (lflag)
8005df: 85 c9 test %ecx,%ecx
8005e1: 75 1a jne 8005fd <vprintfmt+0x330>
return va_arg(*ap, unsigned int);
8005e3: 8b 45 14 mov 0x14(%ebp),%eax
8005e6: 8b 10 mov (%eax),%edx
8005e8: b9 00 00 00 00 mov $0x0,%ecx
8005ed: 8d 40 04 lea 0x4(%eax),%eax
8005f0: 89 45 14 mov %eax,0x14(%ebp)
base = 10;
8005f3: b8 0a 00 00 00 mov $0xa,%eax
8005f8: e9 8b 00 00 00 jmp 800688 <vprintfmt+0x3bb>
return va_arg(*ap, unsigned long);
8005fd: 8b 45 14 mov 0x14(%ebp),%eax
800600: 8b 10 mov (%eax),%edx
800602: b9 00 00 00 00 mov $0x0,%ecx
800607: 8d 40 04 lea 0x4(%eax),%eax
80060a: 89 45 14 mov %eax,0x14(%ebp)
base = 10;
80060d: b8 0a 00 00 00 mov $0xa,%eax
800612: eb 74 jmp 800688 <vprintfmt+0x3bb>
if (lflag >= 2)
800614: 83 f9 01 cmp $0x1,%ecx
800617: 7e 15 jle 80062e <vprintfmt+0x361>
return va_arg(*ap, unsigned long long);
800619: 8b 45 14 mov 0x14(%ebp),%eax
80061c: 8b 10 mov (%eax),%edx
80061e: 8b 48 04 mov 0x4(%eax),%ecx
800621: 8d 40 08 lea 0x8(%eax),%eax
800624: 89 45 14 mov %eax,0x14(%ebp)
base = 8;
800627: b8 08 00 00 00 mov $0x8,%eax
80062c: eb 5a jmp 800688 <vprintfmt+0x3bb>
else if (lflag)
80062e: 85 c9 test %ecx,%ecx
800630: 75 17 jne 800649 <vprintfmt+0x37c>
return va_arg(*ap, unsigned int);
800632: 8b 45 14 mov 0x14(%ebp),%eax
800635: 8b 10 mov (%eax),%edx
800637: b9 00 00 00 00 mov $0x0,%ecx
80063c: 8d 40 04 lea 0x4(%eax),%eax
80063f: 89 45 14 mov %eax,0x14(%ebp)
base = 8;
800642: b8 08 00 00 00 mov $0x8,%eax
800647: eb 3f jmp 800688 <vprintfmt+0x3bb>
return va_arg(*ap, unsigned long);
800649: 8b 45 14 mov 0x14(%ebp),%eax
80064c: 8b 10 mov (%eax),%edx
80064e: b9 00 00 00 00 mov $0x0,%ecx
800653: 8d 40 04 lea 0x4(%eax),%eax
800656: 89 45 14 mov %eax,0x14(%ebp)
base = 8;
800659: b8 08 00 00 00 mov $0x8,%eax
80065e: eb 28 jmp 800688 <vprintfmt+0x3bb>
putch('0', putdat);
800660: 83 ec 08 sub $0x8,%esp
800663: 53 push %ebx
800664: 6a 30 push $0x30
800666: ff d6 call *%esi
putch('x', putdat);
800668: 83 c4 08 add $0x8,%esp
80066b: 53 push %ebx
80066c: 6a 78 push $0x78
80066e: ff d6 call *%esi
num = (unsigned long long)
800670: 8b 45 14 mov 0x14(%ebp),%eax
800673: 8b 10 mov (%eax),%edx
800675: b9 00 00 00 00 mov $0x0,%ecx
goto number;
80067a: 83 c4 10 add $0x10,%esp
(uintptr_t) va_arg(ap, void *);
80067d: 8d 40 04 lea 0x4(%eax),%eax
800680: 89 45 14 mov %eax,0x14(%ebp)
base = 16;
800683: b8 10 00 00 00 mov $0x10,%eax
printnum(putch, putdat, num, base, width, padc);
800688: 83 ec 0c sub $0xc,%esp
80068b: 0f be 7d d4 movsbl -0x2c(%ebp),%edi
80068f: 57 push %edi
800690: ff 75 e0 pushl -0x20(%ebp)
800693: 50 push %eax
800694: 51 push %ecx
800695: 52 push %edx
800696: 89 da mov %ebx,%edx
800698: 89 f0 mov %esi,%eax
80069a: e8 45 fb ff ff call 8001e4 <printnum>
break;
80069f: 83 c4 20 add $0x20,%esp
err = va_arg(ap, int);
8006a2: 8b 7d e4 mov -0x1c(%ebp),%edi
while ((ch = *(unsigned char *) fmt++) != '%') { //先将非格式化字符输出到控制台。
8006a5: 83 c7 01 add $0x1,%edi
8006a8: 0f b6 47 ff movzbl -0x1(%edi),%eax
8006ac: 83 f8 25 cmp $0x25,%eax
8006af: 0f 84 2f fc ff ff je 8002e4 <vprintfmt+0x17>
if (ch == '\0') //如果没有格式化字符直接返回
8006b5: 85 c0 test %eax,%eax
8006b7: 0f 84 8b 00 00 00 je 800748 <vprintfmt+0x47b>
putch(ch, putdat);
8006bd: 83 ec 08 sub $0x8,%esp
8006c0: 53 push %ebx
8006c1: 50 push %eax
8006c2: ff d6 call *%esi
8006c4: 83 c4 10 add $0x10,%esp
8006c7: eb dc jmp 8006a5 <vprintfmt+0x3d8>
if (lflag >= 2)
8006c9: 83 f9 01 cmp $0x1,%ecx
8006cc: 7e 15 jle 8006e3 <vprintfmt+0x416>
return va_arg(*ap, unsigned long long);
8006ce: 8b 45 14 mov 0x14(%ebp),%eax
8006d1: 8b 10 mov (%eax),%edx
8006d3: 8b 48 04 mov 0x4(%eax),%ecx
8006d6: 8d 40 08 lea 0x8(%eax),%eax
8006d9: 89 45 14 mov %eax,0x14(%ebp)
base = 16;
8006dc: b8 10 00 00 00 mov $0x10,%eax
8006e1: eb a5 jmp 800688 <vprintfmt+0x3bb>
else if (lflag)
8006e3: 85 c9 test %ecx,%ecx
8006e5: 75 17 jne 8006fe <vprintfmt+0x431>
return va_arg(*ap, unsigned int);
8006e7: 8b 45 14 mov 0x14(%ebp),%eax
8006ea: 8b 10 mov (%eax),%edx
8006ec: b9 00 00 00 00 mov $0x0,%ecx
8006f1: 8d 40 04 lea 0x4(%eax),%eax
8006f4: 89 45 14 mov %eax,0x14(%ebp)
base = 16;
8006f7: b8 10 00 00 00 mov $0x10,%eax
8006fc: eb 8a jmp 800688 <vprintfmt+0x3bb>
return va_arg(*ap, unsigned long);
8006fe: 8b 45 14 mov 0x14(%ebp),%eax
800701: 8b 10 mov (%eax),%edx
800703: b9 00 00 00 00 mov $0x0,%ecx
800708: 8d 40 04 lea 0x4(%eax),%eax
80070b: 89 45 14 mov %eax,0x14(%ebp)
base = 16;
80070e: b8 10 00 00 00 mov $0x10,%eax
800713: e9 70 ff ff ff jmp 800688 <vprintfmt+0x3bb>
putch(ch, putdat);
800718: 83 ec 08 sub $0x8,%esp
80071b: 53 push %ebx
80071c: 6a 25 push $0x25
80071e: ff d6 call *%esi
break;
800720: 83 c4 10 add $0x10,%esp
800723: e9 7a ff ff ff jmp 8006a2 <vprintfmt+0x3d5>
putch('%', putdat);
800728: 83 ec 08 sub $0x8,%esp
80072b: 53 push %ebx
80072c: 6a 25 push $0x25
80072e: ff d6 call *%esi
for (fmt--; fmt[-1] != '%'; fmt--)
800730: 83 c4 10 add $0x10,%esp
800733: 89 f8 mov %edi,%eax
800735: eb 03 jmp 80073a <vprintfmt+0x46d>
800737: 83 e8 01 sub $0x1,%eax
80073a: 80 78 ff 25 cmpb $0x25,-0x1(%eax)
80073e: 75 f7 jne 800737 <vprintfmt+0x46a>
800740: 89 45 e4 mov %eax,-0x1c(%ebp)
800743: e9 5a ff ff ff jmp 8006a2 <vprintfmt+0x3d5>
}
800748: 8d 65 f4 lea -0xc(%ebp),%esp
80074b: 5b pop %ebx
80074c: 5e pop %esi
80074d: 5f pop %edi
80074e: 5d pop %ebp
80074f: c3 ret
00800750 <vsnprintf>:
int
vsnprintf(char *buf, int n, const char *fmt, va_list ap)
{
800750: 55 push %ebp
800751: 89 e5 mov %esp,%ebp
800753: 83 ec 18 sub $0x18,%esp
800756: 8b 45 08 mov 0x8(%ebp),%eax
800759: 8b 55 0c mov 0xc(%ebp),%edx
struct sprintbuf b = {buf, buf+n-1, 0};
80075c: 89 45 ec mov %eax,-0x14(%ebp)
80075f: 8d 4c 10 ff lea -0x1(%eax,%edx,1),%ecx
800763: 89 4d f0 mov %ecx,-0x10(%ebp)
800766: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp)
if (buf == NULL || n < 1)
80076d: 85 c0 test %eax,%eax
80076f: 74 26 je 800797 <vsnprintf+0x47>
800771: 85 d2 test %edx,%edx
800773: 7e 22 jle 800797 <vsnprintf+0x47>
return -E_INVAL;
// print the string to the buffer
vprintfmt((void*)sprintputch, &b, fmt, ap);
800775: ff 75 14 pushl 0x14(%ebp)
800778: ff 75 10 pushl 0x10(%ebp)
80077b: 8d 45 ec lea -0x14(%ebp),%eax
80077e: 50 push %eax
80077f: 68 93 02 80 00 push $0x800293
800784: e8 44 fb ff ff call 8002cd <vprintfmt>
// null terminate the buffer
*b.buf = '\0';
800789: 8b 45 ec mov -0x14(%ebp),%eax
80078c: c6 00 00 movb $0x0,(%eax)
return b.cnt;
80078f: 8b 45 f4 mov -0xc(%ebp),%eax
800792: 83 c4 10 add $0x10,%esp
}
800795: c9 leave
800796: c3 ret
return -E_INVAL;
800797: b8 fd ff ff ff mov $0xfffffffd,%eax
80079c: eb f7 jmp 800795 <vsnprintf+0x45>
0080079e <snprintf>:
int
snprintf(char *buf, int n, const char *fmt, ...)
{
80079e: 55 push %ebp
80079f: 89 e5 mov %esp,%ebp
8007a1: 83 ec 08 sub $0x8,%esp
va_list ap;
int rc;
va_start(ap, fmt);
8007a4: 8d 45 14 lea 0x14(%ebp),%eax
rc = vsnprintf(buf, n, fmt, ap);
8007a7: 50 push %eax
8007a8: ff 75 10 pushl 0x10(%ebp)
8007ab: ff 75 0c pushl 0xc(%ebp)
8007ae: ff 75 08 pushl 0x8(%ebp)
8007b1: e8 9a ff ff ff call 800750 <vsnprintf>
va_end(ap);
return rc;
}
8007b6: c9 leave
8007b7: c3 ret
008007b8 <strlen>:
// Primespipe runs 3x faster this way.
#define ASM 1
int
strlen(const char *s)
{
8007b8: 55 push %ebp
8007b9: 89 e5 mov %esp,%ebp
8007bb: 8b 55 08 mov 0x8(%ebp),%edx
int n;
for (n = 0; *s != '\0'; s++)
8007be: b8 00 00 00 00 mov $0x0,%eax
8007c3: eb 03 jmp 8007c8 <strlen+0x10>
n++;
8007c5: 83 c0 01 add $0x1,%eax
for (n = 0; *s != '\0'; s++)
8007c8: 80 3c 02 00 cmpb $0x0,(%edx,%eax,1)
8007cc: 75 f7 jne 8007c5 <strlen+0xd>
return n;
}
8007ce: 5d pop %ebp
8007cf: c3 ret
008007d0 <strnlen>:
int
strnlen(const char *s, size_t size)
{
8007d0: 55 push %ebp
8007d1: 89 e5 mov %esp,%ebp
8007d3: 8b 4d 08 mov 0x8(%ebp),%ecx
8007d6: 8b 55 0c mov 0xc(%ebp),%edx
int n;
for (n = 0; size > 0 && *s != '\0'; s++, size--)
8007d9: b8 00 00 00 00 mov $0x0,%eax
8007de: eb 03 jmp 8007e3 <strnlen+0x13>
n++;
8007e0: 83 c0 01 add $0x1,%eax
for (n = 0; size > 0 && *s != '\0'; s++, size--)
8007e3: 39 d0 cmp %edx,%eax
8007e5: 74 06 je 8007ed <strnlen+0x1d>
8007e7: 80 3c 01 00 cmpb $0x0,(%ecx,%eax,1)
8007eb: 75 f3 jne 8007e0 <strnlen+0x10>
return n;
}
8007ed: 5d pop %ebp
8007ee: c3 ret
008007ef <strcpy>:
char *
strcpy(char *dst, const char *src)
{
8007ef: 55 push %ebp
8007f0: 89 e5 mov %esp,%ebp
8007f2: 53 push %ebx
8007f3: 8b 45 08 mov 0x8(%ebp),%eax
8007f6: 8b 4d 0c mov 0xc(%ebp),%ecx
char *ret;
ret = dst;
while ((*dst++ = *src++) != '\0')
8007f9: 89 c2 mov %eax,%edx
8007fb: 83 c1 01 add $0x1,%ecx
8007fe: 83 c2 01 add $0x1,%edx
800801: 0f b6 59 ff movzbl -0x1(%ecx),%ebx
800805: 88 5a ff mov %bl,-0x1(%edx)
800808: 84 db test %bl,%bl
80080a: 75 ef jne 8007fb <strcpy+0xc>
/* do nothing */;
return ret;
}
80080c: 5b pop %ebx
80080d: 5d pop %ebp
80080e: c3 ret
0080080f <strcat>:
char *
strcat(char *dst, const char *src)
{
80080f: 55 push %ebp
800810: 89 e5 mov %esp,%ebp
800812: 53 push %ebx
800813: 8b 5d 08 mov 0x8(%ebp),%ebx
int len = strlen(dst);
800816: 53 push %ebx
800817: e8 9c ff ff ff call 8007b8 <strlen>
80081c: 83 c4 04 add $0x4,%esp
strcpy(dst + len, src);
80081f: ff 75 0c pushl 0xc(%ebp)
800822: 01 d8 add %ebx,%eax
800824: 50 push %eax
800825: e8 c5 ff ff ff call 8007ef <strcpy>
return dst;
}
80082a: 89 d8 mov %ebx,%eax
80082c: 8b 5d fc mov -0x4(%ebp),%ebx
80082f: c9 leave
800830: c3 ret
00800831 <strncpy>:
char *
strncpy(char *dst, const char *src, size_t size) {
800831: 55 push %ebp
800832: 89 e5 mov %esp,%ebp
800834: 56 push %esi
800835: 53 push %ebx
800836: 8b 75 08 mov 0x8(%ebp),%esi
800839: 8b 4d 0c mov 0xc(%ebp),%ecx
80083c: 89 f3 mov %esi,%ebx
80083e: 03 5d 10 add 0x10(%ebp),%ebx
size_t i;
char *ret;
ret = dst;
for (i = 0; i < size; i++) {
800841: 89 f2 mov %esi,%edx
800843: eb 0f jmp 800854 <strncpy+0x23>
*dst++ = *src;
800845: 83 c2 01 add $0x1,%edx
800848: 0f b6 01 movzbl (%ecx),%eax
80084b: 88 42 ff mov %al,-0x1(%edx)
// If strlen(src) < size, null-pad 'dst' out to 'size' chars
if (*src != '\0')
src++;
80084e: 80 39 01 cmpb $0x1,(%ecx)
800851: 83 d9 ff sbb $0xffffffff,%ecx
for (i = 0; i < size; i++) {
800854: 39 da cmp %ebx,%edx
800856: 75 ed jne 800845 <strncpy+0x14>
}
return ret;
}
800858: 89 f0 mov %esi,%eax
80085a: 5b pop %ebx
80085b: 5e pop %esi
80085c: 5d pop %ebp
80085d: c3 ret
0080085e <strlcpy>:
size_t
strlcpy(char *dst, const char *src, size_t size)
{
80085e: 55 push %ebp
80085f: 89 e5 mov %esp,%ebp
800861: 56 push %esi
800862: 53 push %ebx
800863: 8b 75 08 mov 0x8(%ebp),%esi
800866: 8b 55 0c mov 0xc(%ebp),%edx
800869: 8b 4d 10 mov 0x10(%ebp),%ecx
80086c: 89 f0 mov %esi,%eax
80086e: 8d 5c 0e ff lea -0x1(%esi,%ecx,1),%ebx
char *dst_in;
dst_in = dst;
if (size > 0) {
800872: 85 c9 test %ecx,%ecx
800874: 75 0b jne 800881 <strlcpy+0x23>
800876: eb 17 jmp 80088f <strlcpy+0x31>
while (--size > 0 && *src != '\0')
*dst++ = *src++;
800878: 83 c2 01 add $0x1,%edx
80087b: 83 c0 01 add $0x1,%eax
80087e: 88 48 ff mov %cl,-0x1(%eax)
while (--size > 0 && *src != '\0')
800881: 39 d8 cmp %ebx,%eax
800883: 74 07 je 80088c <strlcpy+0x2e>
800885: 0f b6 0a movzbl (%edx),%ecx
800888: 84 c9 test %cl,%cl
80088a: 75 ec jne 800878 <strlcpy+0x1a>
*dst = '\0';
80088c: c6 00 00 movb $0x0,(%eax)
}
return dst - dst_in;
80088f: 29 f0 sub %esi,%eax
}
800891: 5b pop %ebx
800892: 5e pop %esi
800893: 5d pop %ebp
800894: c3 ret
00800895 <strcmp>:
int
strcmp(const char *p, const char *q)
{
800895: 55 push %ebp
800896: 89 e5 mov %esp,%ebp
800898: 8b 4d 08 mov 0x8(%ebp),%ecx
80089b: 8b 55 0c mov 0xc(%ebp),%edx
while (*p && *p == *q)
80089e: eb 06 jmp 8008a6 <strcmp+0x11>
p++, q++;
8008a0: 83 c1 01 add $0x1,%ecx
8008a3: 83 c2 01 add $0x1,%edx
while (*p && *p == *q)
8008a6: 0f b6 01 movzbl (%ecx),%eax
8008a9: 84 c0 test %al,%al
8008ab: 74 04 je 8008b1 <strcmp+0x1c>
8008ad: 3a 02 cmp (%edx),%al
8008af: 74 ef je 8008a0 <strcmp+0xb>
return (int) ((unsigned char) *p - (unsigned char) *q);
8008b1: 0f b6 c0 movzbl %al,%eax
8008b4: 0f b6 12 movzbl (%edx),%edx
8008b7: 29 d0 sub %edx,%eax
}
8008b9: 5d pop %ebp
8008ba: c3 ret
008008bb <strncmp>:
int
strncmp(const char *p, const char *q, size_t n)
{
8008bb: 55 push %ebp
8008bc: 89 e5 mov %esp,%ebp
8008be: 53 push %ebx
8008bf: 8b 45 08 mov 0x8(%ebp),%eax
8008c2: 8b 55 0c mov 0xc(%ebp),%edx
8008c5: 89 c3 mov %eax,%ebx
8008c7: 03 5d 10 add 0x10(%ebp),%ebx
while (n > 0 && *p && *p == *q)
8008ca: eb 06 jmp 8008d2 <strncmp+0x17>
n--, p++, q++;
8008cc: 83 c0 01 add $0x1,%eax
8008cf: 83 c2 01 add $0x1,%edx
while (n > 0 && *p && *p == *q)
8008d2: 39 d8 cmp %ebx,%eax
8008d4: 74 16 je 8008ec <strncmp+0x31>
8008d6: 0f b6 08 movzbl (%eax),%ecx
8008d9: 84 c9 test %cl,%cl
8008db: 74 04 je 8008e1 <strncmp+0x26>
8008dd: 3a 0a cmp (%edx),%cl
8008df: 74 eb je 8008cc <strncmp+0x11>
if (n == 0)
return 0;
else
return (int) ((unsigned char) *p - (unsigned char) *q);
8008e1: 0f b6 00 movzbl (%eax),%eax
8008e4: 0f b6 12 movzbl (%edx),%edx
8008e7: 29 d0 sub %edx,%eax
}
8008e9: 5b pop %ebx
8008ea: 5d pop %ebp
8008eb: c3 ret
return 0;
8008ec: b8 00 00 00 00 mov $0x0,%eax
8008f1: eb f6 jmp 8008e9 <strncmp+0x2e>
008008f3 <strchr>:
// Return a pointer to the first occurrence of 'c' in 's',
// or a null pointer if the string has no 'c'.
char *
strchr(const char *s, char c)
{
8008f3: 55 push %ebp
8008f4: 89 e5 mov %esp,%ebp
8008f6: 8b 45 08 mov 0x8(%ebp),%eax
8008f9: 0f b6 4d 0c movzbl 0xc(%ebp),%ecx
for (; *s; s++)
8008fd: 0f b6 10 movzbl (%eax),%edx
800900: 84 d2 test %dl,%dl
800902: 74 09 je 80090d <strchr+0x1a>
if (*s == c)
800904: 38 ca cmp %cl,%dl
800906: 74 0a je 800912 <strchr+0x1f>
for (; *s; s++)
800908: 83 c0 01 add $0x1,%eax
80090b: eb f0 jmp 8008fd <strchr+0xa>
return (char *) s;
return 0;
80090d: b8 00 00 00 00 mov $0x0,%eax
}
800912: 5d pop %ebp
800913: c3 ret
00800914 <strfind>:
// Return a pointer to the first occurrence of 'c' in 's',
// or a pointer to the string-ending null character if the string has no 'c'.
char *
strfind(const char *s, char c)
{
800914: 55 push %ebp
800915: 89 e5 mov %esp,%ebp
800917: 8b 45 08 mov 0x8(%ebp),%eax
80091a: 0f b6 4d 0c movzbl 0xc(%ebp),%ecx
for (; *s; s++)
80091e: eb 03 jmp 800923 <strfind+0xf>
800920: 83 c0 01 add $0x1,%eax
800923: 0f b6 10 movzbl (%eax),%edx
if (*s == c)
800926: 38 ca cmp %cl,%dl
800928: 74 04 je 80092e <strfind+0x1a>
80092a: 84 d2 test %dl,%dl
80092c: 75 f2 jne 800920 <strfind+0xc>
break;
return (char *) s;
}
80092e: 5d pop %ebp
80092f: c3 ret
00800930 <memset>:
#if ASM
void *
memset(void *v, int c, size_t n)
{
800930: 55 push %ebp
800931: 89 e5 mov %esp,%ebp
800933: 57 push %edi
800934: 56 push %esi
800935: 53 push %ebx
800936: 8b 7d 08 mov 0x8(%ebp),%edi
800939: 8b 4d 10 mov 0x10(%ebp),%ecx
char *p;
if (n == 0)
80093c: 85 c9 test %ecx,%ecx
80093e: 74 13 je 800953 <memset+0x23>
return v;
if ((int)v%4 == 0 && n%4 == 0) {
800940: f7 c7 03 00 00 00 test $0x3,%edi
800946: 75 05 jne 80094d <memset+0x1d>
800948: f6 c1 03 test $0x3,%cl
80094b: 74 0d je 80095a <memset+0x2a>
c = (c<<24)|(c<<16)|(c<<8)|c;
asm volatile("cld; rep stosl\n"
:: "D" (v), "a" (c), "c" (n/4)
: "cc", "memory");
} else
asm volatile("cld; rep stosb\n"
80094d: 8b 45 0c mov 0xc(%ebp),%eax
800950: fc cld
800951: f3 aa rep stos %al,%es:(%edi)
:: "D" (v), "a" (c), "c" (n)
: "cc", "memory");
return v;
}
800953: 89 f8 mov %edi,%eax
800955: 5b pop %ebx
800956: 5e pop %esi
800957: 5f pop %edi
800958: 5d pop %ebp
800959: c3 ret
c &= 0xFF;
80095a: 0f b6 55 0c movzbl 0xc(%ebp),%edx
c = (c<<24)|(c<<16)|(c<<8)|c;
80095e: 89 d3 mov %edx,%ebx
800960: c1 e3 08 shl $0x8,%ebx
800963: 89 d0 mov %edx,%eax
800965: c1 e0 18 shl $0x18,%eax
800968: 89 d6 mov %edx,%esi
80096a: c1 e6 10 shl $0x10,%esi
80096d: 09 f0 or %esi,%eax
80096f: 09 c2 or %eax,%edx
800971: 09 da or %ebx,%edx
:: "D" (v), "a" (c), "c" (n/4)
800973: c1 e9 02 shr $0x2,%ecx
asm volatile("cld; rep stosl\n"
800976: 89 d0 mov %edx,%eax
800978: fc cld
800979: f3 ab rep stos %eax,%es:(%edi)
80097b: eb d6 jmp 800953 <memset+0x23>
0080097d <memmove>:
void *
memmove(void *dst, const void *src, size_t n)
{
80097d: 55 push %ebp
80097e: 89 e5 mov %esp,%ebp
800980: 57 push %edi
800981: 56 push %esi
800982: 8b 45 08 mov 0x8(%ebp),%eax
800985: 8b 75 0c mov 0xc(%ebp),%esi
800988: 8b 4d 10 mov 0x10(%ebp),%ecx
const char *s;
char *d;
s = src;
d = dst;
if (s < d && s + n > d) {
80098b: 39 c6 cmp %eax,%esi
80098d: 73 35 jae 8009c4 <memmove+0x47>
80098f: 8d 14 0e lea (%esi,%ecx,1),%edx
800992: 39 c2 cmp %eax,%edx
800994: 76 2e jbe 8009c4 <memmove+0x47>
s += n;
d += n;
800996: 8d 3c 08 lea (%eax,%ecx,1),%edi
if ((int)s%4 == 0 && (int)d%4 == 0 && n%4 == 0)
800999: 89 d6 mov %edx,%esi
80099b: 09 fe or %edi,%esi
80099d: f7 c6 03 00 00 00 test $0x3,%esi
8009a3: 74 0c je 8009b1 <memmove+0x34>
asm volatile("std; rep movsl\n"
:: "D" (d-4), "S" (s-4), "c" (n/4) : "cc", "memory");
else
asm volatile("std; rep movsb\n"
:: "D" (d-1), "S" (s-1), "c" (n) : "cc", "memory");
8009a5: 83 ef 01 sub $0x1,%edi
8009a8: 8d 72 ff lea -0x1(%edx),%esi
asm volatile("std; rep movsb\n"
8009ab: fd std
8009ac: f3 a4 rep movsb %ds:(%esi),%es:(%edi)
// Some versions of GCC rely on DF being clear
asm volatile("cld" ::: "cc");
8009ae: fc cld
8009af: eb 21 jmp 8009d2 <memmove+0x55>
if ((int)s%4 == 0 && (int)d%4 == 0 && n%4 == 0)
8009b1: f6 c1 03 test $0x3,%cl
8009b4: 75 ef jne 8009a5 <memmove+0x28>
:: "D" (d-4), "S" (s-4), "c" (n/4) : "cc", "memory");
8009b6: 83 ef 04 sub $0x4,%edi
8009b9: 8d 72 fc lea -0x4(%edx),%esi
8009bc: c1 e9 02 shr $0x2,%ecx
asm volatile("std; rep movsl\n"
8009bf: fd std
8009c0: f3 a5 rep movsl %ds:(%esi),%es:(%edi)
8009c2: eb ea jmp 8009ae <memmove+0x31>
} else {
if ((int)s%4 == 0 && (int)d%4 == 0 && n%4 == 0)
8009c4: 89 f2 mov %esi,%edx
8009c6: 09 c2 or %eax,%edx
8009c8: f6 c2 03 test $0x3,%dl
8009cb: 74 09 je 8009d6 <memmove+0x59>
asm volatile("cld; rep movsl\n"
:: "D" (d), "S" (s), "c" (n/4) : "cc", "memory");
else
asm volatile("cld; rep movsb\n"
8009cd: 89 c7 mov %eax,%edi
8009cf: fc cld
8009d0: f3 a4 rep movsb %ds:(%esi),%es:(%edi)
:: "D" (d), "S" (s), "c" (n) : "cc", "memory");
}
return dst;
}
8009d2: 5e pop %esi
8009d3: 5f pop %edi
8009d4: 5d pop %ebp
8009d5: c3 ret
if ((int)s%4 == 0 && (int)d%4 == 0 && n%4 == 0)
8009d6: f6 c1 03 test $0x3,%cl
8009d9: 75 f2 jne 8009cd <memmove+0x50>
:: "D" (d), "S" (s), "c" (n/4) : "cc", "memory");
8009db: c1 e9 02 shr $0x2,%ecx
asm volatile("cld; rep movsl\n"
8009de: 89 c7 mov %eax,%edi
8009e0: fc cld
8009e1: f3 a5 rep movsl %ds:(%esi),%es:(%edi)
8009e3: eb ed jmp 8009d2 <memmove+0x55>
008009e5 <memcpy>:
}
#endif
void *
memcpy(void *dst, const void *src, size_t n)
{
8009e5: 55 push %ebp
8009e6: 89 e5 mov %esp,%ebp
return memmove(dst, src, n);
8009e8: ff 75 10 pushl 0x10(%ebp)
8009eb: ff 75 0c pushl 0xc(%ebp)
8009ee: ff 75 08 pushl 0x8(%ebp)
8009f1: e8 87 ff ff ff call 80097d <memmove>
}
8009f6: c9 leave
8009f7: c3 ret
008009f8 <memcmp>:
int
memcmp(const void *v1, const void *v2, size_t n)
{
8009f8: 55 push %ebp
8009f9: 89 e5 mov %esp,%ebp
8009fb: 56 push %esi
8009fc: 53 push %ebx
8009fd: 8b 45 08 mov 0x8(%ebp),%eax
800a00: 8b 55 0c mov 0xc(%ebp),%edx
800a03: 89 c6 mov %eax,%esi
800a05: 03 75 10 add 0x10(%ebp),%esi
const uint8_t *s1 = (const uint8_t *) v1;
const uint8_t *s2 = (const uint8_t *) v2;
while (n-- > 0) {
800a08: 39 f0 cmp %esi,%eax
800a0a: 74 1c je 800a28 <memcmp+0x30>
if (*s1 != *s2)
800a0c: 0f b6 08 movzbl (%eax),%ecx
800a0f: 0f b6 1a movzbl (%edx),%ebx
800a12: 38 d9 cmp %bl,%cl
800a14: 75 08 jne 800a1e <memcmp+0x26>
return (int) *s1 - (int) *s2;
s1++, s2++;
800a16: 83 c0 01 add $0x1,%eax
800a19: 83 c2 01 add $0x1,%edx
800a1c: eb ea jmp 800a08 <memcmp+0x10>
return (int) *s1 - (int) *s2;
800a1e: 0f b6 c1 movzbl %cl,%eax
800a21: 0f b6 db movzbl %bl,%ebx
800a24: 29 d8 sub %ebx,%eax
800a26: eb 05 jmp 800a2d <memcmp+0x35>
}
return 0;
800a28: b8 00 00 00 00 mov $0x0,%eax
}
800a2d: 5b pop %ebx
800a2e: 5e pop %esi
800a2f: 5d pop %ebp
800a30: c3 ret
00800a31 <memfind>:
void *
memfind(const void *s, int c, size_t n)
{
800a31: 55 push %ebp
800a32: 89 e5 mov %esp,%ebp
800a34: 8b 45 08 mov 0x8(%ebp),%eax
800a37: 8b 4d 0c mov 0xc(%ebp),%ecx
const void *ends = (const char *) s + n;
800a3a: 89 c2 mov %eax,%edx
800a3c: 03 55 10 add 0x10(%ebp),%edx
for (; s < ends; s++)
800a3f: 39 d0 cmp %edx,%eax
800a41: 73 09 jae 800a4c <memfind+0x1b>
if (*(const unsigned char *) s == (unsigned char) c)
800a43: 38 08 cmp %cl,(%eax)
800a45: 74 05 je 800a4c <memfind+0x1b>
for (; s < ends; s++)
800a47: 83 c0 01 add $0x1,%eax
800a4a: eb f3 jmp 800a3f <memfind+0xe>
break;
return (void *) s;
}
800a4c: 5d pop %ebp
800a4d: c3 ret
00800a4e <strtol>:
long
strtol(const char *s, char **endptr, int base)
{
800a4e: 55 push %ebp
800a4f: 89 e5 mov %esp,%ebp
800a51: 57 push %edi
800a52: 56 push %esi
800a53: 53 push %ebx
800a54: 8b 4d 08 mov 0x8(%ebp),%ecx
800a57: 8b 5d 10 mov 0x10(%ebp),%ebx
int neg = 0;
long val = 0;
// gobble initial whitespace
while (*s == ' ' || *s == '\t')
800a5a: eb 03 jmp 800a5f <strtol+0x11>
s++;
800a5c: 83 c1 01 add $0x1,%ecx
while (*s == ' ' || *s == '\t')
800a5f: 0f b6 01 movzbl (%ecx),%eax
800a62: 3c 20 cmp $0x20,%al
800a64: 74 f6 je 800a5c <strtol+0xe>
800a66: 3c 09 cmp $0x9,%al
800a68: 74 f2 je 800a5c <strtol+0xe>
// plus/minus sign
if (*s == '+')
800a6a: 3c 2b cmp $0x2b,%al
800a6c: 74 2e je 800a9c <strtol+0x4e>
int neg = 0;
800a6e: bf 00 00 00 00 mov $0x0,%edi
s++;
else if (*s == '-')
800a73: 3c 2d cmp $0x2d,%al
800a75: 74 2f je 800aa6 <strtol+0x58>
s++, neg = 1;
// hex or octal base prefix
if ((base == 0 || base == 16) && (s[0] == '0' && s[1] == 'x'))
800a77: f7 c3 ef ff ff ff test $0xffffffef,%ebx
800a7d: 75 05 jne 800a84 <strtol+0x36>
800a7f: 80 39 30 cmpb $0x30,(%ecx)
800a82: 74 2c je 800ab0 <strtol+0x62>
s += 2, base = 16;
else if (base == 0 && s[0] == '0')
800a84: 85 db test %ebx,%ebx
800a86: 75 0a jne 800a92 <strtol+0x44>
s++, base = 8;
else if (base == 0)
base = 10;
800a88: bb 0a 00 00 00 mov $0xa,%ebx
else if (base == 0 && s[0] == '0')
800a8d: 80 39 30 cmpb $0x30,(%ecx)
800a90: 74 28 je 800aba <strtol+0x6c>
base = 10;
800a92: b8 00 00 00 00 mov $0x0,%eax
800a97: 89 5d 10 mov %ebx,0x10(%ebp)
800a9a: eb 50 jmp 800aec <strtol+0x9e>
s++;
800a9c: 83 c1 01 add $0x1,%ecx
int neg = 0;
800a9f: bf 00 00 00 00 mov $0x0,%edi
800aa4: eb d1 jmp 800a77 <strtol+0x29>
s++, neg = 1;
800aa6: 83 c1 01 add $0x1,%ecx
800aa9: bf 01 00 00 00 mov $0x1,%edi
800aae: eb c7 jmp 800a77 <strtol+0x29>
if ((base == 0 || base == 16) && (s[0] == '0' && s[1] == 'x'))
800ab0: 80 79 01 78 cmpb $0x78,0x1(%ecx)
800ab4: 74 0e je 800ac4 <strtol+0x76>
else if (base == 0 && s[0] == '0')
800ab6: 85 db test %ebx,%ebx
800ab8: 75 d8 jne 800a92 <strtol+0x44>
s++, base = 8;
800aba: 83 c1 01 add $0x1,%ecx
800abd: bb 08 00 00 00 mov $0x8,%ebx
800ac2: eb ce jmp 800a92 <strtol+0x44>
s += 2, base = 16;
800ac4: 83 c1 02 add $0x2,%ecx
800ac7: bb 10 00 00 00 mov $0x10,%ebx
800acc: eb c4 jmp 800a92 <strtol+0x44>
while (1) {
int dig;
if (*s >= '0' && *s <= '9')
dig = *s - '0';
else if (*s >= 'a' && *s <= 'z')
800ace: 8d 72 9f lea -0x61(%edx),%esi
800ad1: 89 f3 mov %esi,%ebx
800ad3: 80 fb 19 cmp $0x19,%bl
800ad6: 77 29 ja 800b01 <strtol+0xb3>
dig = *s - 'a' + 10;
800ad8: 0f be d2 movsbl %dl,%edx
800adb: 83 ea 57 sub $0x57,%edx
else if (*s >= 'A' && *s <= 'Z')
dig = *s - 'A' + 10;
else
break;
if (dig >= base)
800ade: 3b 55 10 cmp 0x10(%ebp),%edx
800ae1: 7d 30 jge 800b13 <strtol+0xc5>
break;
s++, val = (val * base) + dig;
800ae3: 83 c1 01 add $0x1,%ecx
800ae6: 0f af 45 10 imul 0x10(%ebp),%eax
800aea: 01 d0 add %edx,%eax
if (*s >= '0' && *s <= '9')
800aec: 0f b6 11 movzbl (%ecx),%edx
800aef: 8d 72 d0 lea -0x30(%edx),%esi
800af2: 89 f3 mov %esi,%ebx
800af4: 80 fb 09 cmp $0x9,%bl
800af7: 77 d5 ja 800ace <strtol+0x80>
dig = *s - '0';
800af9: 0f be d2 movsbl %dl,%edx
800afc: 83 ea 30 sub $0x30,%edx
800aff: eb dd jmp 800ade <strtol+0x90>
else if (*s >= 'A' && *s <= 'Z')
800b01: 8d 72 bf lea -0x41(%edx),%esi
800b04: 89 f3 mov %esi,%ebx
800b06: 80 fb 19 cmp $0x19,%bl
800b09: 77 08 ja 800b13 <strtol+0xc5>
dig = *s - 'A' + 10;
800b0b: 0f be d2 movsbl %dl,%edx
800b0e: 83 ea 37 sub $0x37,%edx
800b11: eb cb jmp 800ade <strtol+0x90>
// we don't properly detect overflow!
}
if (endptr)
800b13: 83 7d 0c 00 cmpl $0x0,0xc(%ebp)
800b17: 74 05 je 800b1e <strtol+0xd0>
*endptr = (char *) s;
800b19: 8b 75 0c mov 0xc(%ebp),%esi
800b1c: 89 0e mov %ecx,(%esi)
return (neg ? -val : val);
800b1e: 89 c2 mov %eax,%edx
800b20: f7 da neg %edx
800b22: 85 ff test %edi,%edi
800b24: 0f 45 c2 cmovne %edx,%eax
}
800b27: 5b pop %ebx
800b28: 5e pop %esi
800b29: 5f pop %edi
800b2a: 5d pop %ebp
800b2b: c3 ret
00800b2c <sys_cputs>:
return ret;
}
void
sys_cputs(const char *s, size_t len)
{
800b2c: 55 push %ebp
800b2d: 89 e5 mov %esp,%ebp
800b2f: 57 push %edi
800b30: 56 push %esi
800b31: 53 push %ebx
asm volatile("int %1\n" //执行int T_SYSCALL指令
800b32: b8 00 00 00 00 mov $0x0,%eax
800b37: 8b 55 08 mov 0x8(%ebp),%edx
800b3a: 8b 4d 0c mov 0xc(%ebp),%ecx
800b3d: 89 c3 mov %eax,%ebx
800b3f: 89 c7 mov %eax,%edi
800b41: 89 c6 mov %eax,%esi
800b43: cd 30 int $0x30
syscall(SYS_cputs, 0, (uint32_t)s, len, 0, 0, 0);
}
800b45: 5b pop %ebx
800b46: 5e pop %esi
800b47: 5f pop %edi
800b48: 5d pop %ebp
800b49: c3 ret
00800b4a <sys_cgetc>:
int
sys_cgetc(void)
{
800b4a: 55 push %ebp
800b4b: 89 e5 mov %esp,%ebp
800b4d: 57 push %edi
800b4e: 56 push %esi
800b4f: 53 push %ebx
asm volatile("int %1\n" //执行int T_SYSCALL指令
800b50: ba 00 00 00 00 mov $0x0,%edx
800b55: b8 01 00 00 00 mov $0x1,%eax
800b5a: 89 d1 mov %edx,%ecx
800b5c: 89 d3 mov %edx,%ebx
800b5e: 89 d7 mov %edx,%edi
800b60: 89 d6 mov %edx,%esi
800b62: cd 30 int $0x30
return syscall(SYS_cgetc, 0, 0, 0, 0, 0, 0);
}
800b64: 5b pop %ebx
800b65: 5e pop %esi
800b66: 5f pop %edi
800b67: 5d pop %ebp
800b68: c3 ret
00800b69 <sys_env_destroy>:
int
sys_env_destroy(envid_t envid)
{
800b69: 55 push %ebp
800b6a: 89 e5 mov %esp,%ebp
800b6c: 57 push %edi
800b6d: 56 push %esi
800b6e: 53 push %ebx
800b6f: 83 ec 0c sub $0xc,%esp
asm volatile("int %1\n" //执行int T_SYSCALL指令
800b72: b9 00 00 00 00 mov $0x0,%ecx
800b77: 8b 55 08 mov 0x8(%ebp),%edx
800b7a: b8 03 00 00 00 mov $0x3,%eax
800b7f: 89 cb mov %ecx,%ebx
800b81: 89 cf mov %ecx,%edi
800b83: 89 ce mov %ecx,%esi
800b85: cd 30 int $0x30
if(check && ret > 0)
800b87: 85 c0 test %eax,%eax
800b89: 7f 08 jg 800b93 <sys_env_destroy+0x2a>
return syscall(SYS_env_destroy, 1, envid, 0, 0, 0, 0);
}
800b8b: 8d 65 f4 lea -0xc(%ebp),%esp
800b8e: 5b pop %ebx
800b8f: 5e pop %esi
800b90: 5f pop %edi
800b91: 5d pop %ebp
800b92: c3 ret
panic("syscall %d returned %d (> 0)", num, ret);
800b93: 83 ec 0c sub $0xc,%esp
800b96: 50 push %eax
800b97: 6a 03 push $0x3
800b99: 68 bf 16 80 00 push $0x8016bf
800b9e: 6a 23 push $0x23
800ba0: 68 dc 16 80 00 push $0x8016dc
800ba5: e8 eb 04 00 00 call 801095 <_panic>
00800baa <sys_getenvid>:
envid_t
sys_getenvid(void)
{
800baa: 55 push %ebp
800bab: 89 e5 mov %esp,%ebp
800bad: 57 push %edi
800bae: 56 push %esi
800baf: 53 push %ebx
asm volatile("int %1\n" //执行int T_SYSCALL指令
800bb0: ba 00 00 00 00 mov $0x0,%edx
800bb5: b8 02 00 00 00 mov $0x2,%eax
800bba: 89 d1 mov %edx,%ecx
800bbc: 89 d3 mov %edx,%ebx
800bbe: 89 d7 mov %edx,%edi
800bc0: 89 d6 mov %edx,%esi
800bc2: cd 30 int $0x30
return syscall(SYS_getenvid, 0, 0, 0, 0, 0, 0);
}
800bc4: 5b pop %ebx
800bc5: 5e pop %esi
800bc6: 5f pop %edi
800bc7: 5d pop %ebp
800bc8: c3 ret
00800bc9 <sys_yield>:
void
sys_yield(void)
{
800bc9: 55 push %ebp
800bca: 89 e5 mov %esp,%ebp
800bcc: 57 push %edi
800bcd: 56 push %esi
800bce: 53 push %ebx
asm volatile("int %1\n" //执行int T_SYSCALL指令
800bcf: ba 00 00 00 00 mov $0x0,%edx
800bd4: b8 0b 00 00 00 mov $0xb,%eax
800bd9: 89 d1 mov %edx,%ecx
800bdb: 89 d3 mov %edx,%ebx
800bdd: 89 d7 mov %edx,%edi
800bdf: 89 d6 mov %edx,%esi
800be1: cd 30 int $0x30
syscall(SYS_yield, 0, 0, 0, 0, 0, 0);
}
800be3: 5b pop %ebx
800be4: 5e pop %esi
800be5: 5f pop %edi
800be6: 5d pop %ebp
800be7: c3 ret
00800be8 <sys_page_alloc>:
int
sys_page_alloc(envid_t envid, void *va, int perm)
{
800be8: 55 push %ebp
800be9: 89 e5 mov %esp,%ebp
800beb: 57 push %edi
800bec: 56 push %esi
800bed: 53 push %ebx
800bee: 83 ec 0c sub $0xc,%esp
asm volatile("int %1\n" //执行int T_SYSCALL指令
800bf1: be 00 00 00 00 mov $0x0,%esi
800bf6: 8b 55 08 mov 0x8(%ebp),%edx
800bf9: 8b 4d 0c mov 0xc(%ebp),%ecx
800bfc: b8 04 00 00 00 mov $0x4,%eax
800c01: 8b 5d 10 mov 0x10(%ebp),%ebx
800c04: 89 f7 mov %esi,%edi
800c06: cd 30 int $0x30
if(check && ret > 0)
800c08: 85 c0 test %eax,%eax
800c0a: 7f 08 jg 800c14 <sys_page_alloc+0x2c>
return syscall(SYS_page_alloc, 1, envid, (uint32_t) va, perm, 0, 0);
}
800c0c: 8d 65 f4 lea -0xc(%ebp),%esp
800c0f: 5b pop %ebx
800c10: 5e pop %esi
800c11: 5f pop %edi
800c12: 5d pop %ebp
800c13: c3 ret
panic("syscall %d returned %d (> 0)", num, ret);
800c14: 83 ec 0c sub $0xc,%esp
800c17: 50 push %eax
800c18: 6a 04 push $0x4
800c1a: 68 bf 16 80 00 push $0x8016bf
800c1f: 6a 23 push $0x23
800c21: 68 dc 16 80 00 push $0x8016dc
800c26: e8 6a 04 00 00 call 801095 <_panic>
00800c2b <sys_page_map>:
int
sys_page_map(envid_t srcenv, void *srcva, envid_t dstenv, void *dstva, int perm)
{
800c2b: 55 push %ebp
800c2c: 89 e5 mov %esp,%ebp
800c2e: 57 push %edi
800c2f: 56 push %esi
800c30: 53 push %ebx
800c31: 83 ec 0c sub $0xc,%esp
asm volatile("int %1\n" //执行int T_SYSCALL指令
800c34: 8b 55 08 mov 0x8(%ebp),%edx
800c37: 8b 4d 0c mov 0xc(%ebp),%ecx
800c3a: b8 05 00 00 00 mov $0x5,%eax
800c3f: 8b 5d 10 mov 0x10(%ebp),%ebx
800c42: 8b 7d 14 mov 0x14(%ebp),%edi
800c45: 8b 75 18 mov 0x18(%ebp),%esi
800c48: cd 30 int $0x30
if(check && ret > 0)
800c4a: 85 c0 test %eax,%eax
800c4c: 7f 08 jg 800c56 <sys_page_map+0x2b>
return syscall(SYS_page_map, 1, srcenv, (uint32_t) srcva, dstenv, (uint32_t) dstva, perm);
}
800c4e: 8d 65 f4 lea -0xc(%ebp),%esp
800c51: 5b pop %ebx
800c52: 5e pop %esi
800c53: 5f pop %edi
800c54: 5d pop %ebp
800c55: c3 ret
panic("syscall %d returned %d (> 0)", num, ret);
800c56: 83 ec 0c sub $0xc,%esp
800c59: 50 push %eax
800c5a: 6a 05 push $0x5
800c5c: 68 bf 16 80 00 push $0x8016bf
800c61: 6a 23 push $0x23
800c63: 68 dc 16 80 00 push $0x8016dc
800c68: e8 28 04 00 00 call 801095 <_panic>
00800c6d <sys_page_unmap>:
int
sys_page_unmap(envid_t envid, void *va)
{
800c6d: 55 push %ebp
800c6e: 89 e5 mov %esp,%ebp
800c70: 57 push %edi
800c71: 56 push %esi
800c72: 53 push %ebx
800c73: 83 ec 0c sub $0xc,%esp
asm volatile("int %1\n" //执行int T_SYSCALL指令
800c76: bb 00 00 00 00 mov $0x0,%ebx
800c7b: 8b 55 08 mov 0x8(%ebp),%edx
800c7e: 8b 4d 0c mov 0xc(%ebp),%ecx
800c81: b8 06 00 00 00 mov $0x6,%eax
800c86: 89 df mov %ebx,%edi
800c88: 89 de mov %ebx,%esi
800c8a: cd 30 int $0x30
if(check && ret > 0)
800c8c: 85 c0 test %eax,%eax
800c8e: 7f 08 jg 800c98 <sys_page_unmap+0x2b>
return syscall(SYS_page_unmap, 1, envid, (uint32_t) va, 0, 0, 0);
}
800c90: 8d 65 f4 lea -0xc(%ebp),%esp
800c93: 5b pop %ebx
800c94: 5e pop %esi
800c95: 5f pop %edi
800c96: 5d pop %ebp
800c97: c3 ret
panic("syscall %d returned %d (> 0)", num, ret);
800c98: 83 ec 0c sub $0xc,%esp
800c9b: 50 push %eax
800c9c: 6a 06 push $0x6
800c9e: 68 bf 16 80 00 push $0x8016bf
800ca3: 6a 23 push $0x23
800ca5: 68 dc 16 80 00 push $0x8016dc
800caa: e8 e6 03 00 00 call 801095 <_panic>
00800caf <sys_env_set_status>:
// sys_exofork is inlined in lib.h
int
sys_env_set_status(envid_t envid, int status)
{
800caf: 55 push %ebp
800cb0: 89 e5 mov %esp,%ebp
800cb2: 57 push %edi
800cb3: 56 push %esi
800cb4: 53 push %ebx
800cb5: 83 ec 0c sub $0xc,%esp
asm volatile("int %1\n" //执行int T_SYSCALL指令
800cb8: bb 00 00 00 00 mov $0x0,%ebx
800cbd: 8b 55 08 mov 0x8(%ebp),%edx
800cc0: 8b 4d 0c mov 0xc(%ebp),%ecx
800cc3: b8 08 00 00 00 mov $0x8,%eax
800cc8: 89 df mov %ebx,%edi
800cca: 89 de mov %ebx,%esi
800ccc: cd 30 int $0x30
if(check && ret > 0)
800cce: 85 c0 test %eax,%eax
800cd0: 7f 08 jg 800cda <sys_env_set_status+0x2b>
return syscall(SYS_env_set_status, 1, envid, status, 0, 0, 0);
}
800cd2: 8d 65 f4 lea -0xc(%ebp),%esp
800cd5: 5b pop %ebx
800cd6: 5e pop %esi
800cd7: 5f pop %edi
800cd8: 5d pop %ebp
800cd9: c3 ret
panic("syscall %d returned %d (> 0)", num, ret);
800cda: 83 ec 0c sub $0xc,%esp
800cdd: 50 push %eax
800cde: 6a 08 push $0x8
800ce0: 68 bf 16 80 00 push $0x8016bf
800ce5: 6a 23 push $0x23
800ce7: 68 dc 16 80 00 push $0x8016dc
800cec: e8 a4 03 00 00 call 801095 <_panic>
00800cf1 <sys_env_set_trapframe>:
int
sys_env_set_trapframe(envid_t envid, struct Trapframe *tf)
{
800cf1: 55 push %ebp
800cf2: 89 e5 mov %esp,%ebp
800cf4: 57 push %edi
800cf5: 56 push %esi
800cf6: 53 push %ebx
800cf7: 83 ec 0c sub $0xc,%esp
asm volatile("int %1\n" //执行int T_SYSCALL指令
800cfa: bb 00 00 00 00 mov $0x0,%ebx
800cff: 8b 55 08 mov 0x8(%ebp),%edx
800d02: 8b 4d 0c mov 0xc(%ebp),%ecx
800d05: b8 09 00 00 00 mov $0x9,%eax
800d0a: 89 df mov %ebx,%edi
800d0c: 89 de mov %ebx,%esi
800d0e: cd 30 int $0x30
if(check && ret > 0)
800d10: 85 c0 test %eax,%eax
800d12: 7f 08 jg 800d1c <sys_env_set_trapframe+0x2b>
return syscall(SYS_env_set_trapframe, 1, envid, (uint32_t) tf, 0, 0, 0);
}
800d14: 8d 65 f4 lea -0xc(%ebp),%esp
800d17: 5b pop %ebx
800d18: 5e pop %esi
800d19: 5f pop %edi
800d1a: 5d pop %ebp
800d1b: c3 ret
panic("syscall %d returned %d (> 0)", num, ret);
800d1c: 83 ec 0c sub $0xc,%esp
800d1f: 50 push %eax
800d20: 6a 09 push $0x9
800d22: 68 bf 16 80 00 push $0x8016bf
800d27: 6a 23 push $0x23
800d29: 68 dc 16 80 00 push $0x8016dc
800d2e: e8 62 03 00 00 call 801095 <_panic>
00800d33 <sys_env_set_pgfault_upcall>:
int
sys_env_set_pgfault_upcall(envid_t envid, void *upcall)
{
800d33: 55 push %ebp
800d34: 89 e5 mov %esp,%ebp
800d36: 57 push %edi
800d37: 56 push %esi
800d38: 53 push %ebx
800d39: 83 ec 0c sub $0xc,%esp
asm volatile("int %1\n" //执行int T_SYSCALL指令
800d3c: bb 00 00 00 00 mov $0x0,%ebx
800d41: 8b 55 08 mov 0x8(%ebp),%edx
800d44: 8b 4d 0c mov 0xc(%ebp),%ecx
800d47: b8 0a 00 00 00 mov $0xa,%eax
800d4c: 89 df mov %ebx,%edi
800d4e: 89 de mov %ebx,%esi
800d50: cd 30 int $0x30
if(check && ret > 0)
800d52: 85 c0 test %eax,%eax
800d54: 7f 08 jg 800d5e <sys_env_set_pgfault_upcall+0x2b>
return syscall(SYS_env_set_pgfault_upcall, 1, envid, (uint32_t) upcall, 0, 0, 0);
}
800d56: 8d 65 f4 lea -0xc(%ebp),%esp
800d59: 5b pop %ebx
800d5a: 5e pop %esi
800d5b: 5f pop %edi
800d5c: 5d pop %ebp
800d5d: c3 ret
panic("syscall %d returned %d (> 0)", num, ret);
800d5e: 83 ec 0c sub $0xc,%esp
800d61: 50 push %eax
800d62: 6a 0a push $0xa
800d64: 68 bf 16 80 00 push $0x8016bf
800d69: 6a 23 push $0x23
800d6b: 68 dc 16 80 00 push $0x8016dc
800d70: e8 20 03 00 00 call 801095 <_panic>
00800d75 <sys_ipc_try_send>:
int
sys_ipc_try_send(envid_t envid, uint32_t value, void *srcva, int perm)
{
800d75: 55 push %ebp
800d76: 89 e5 mov %esp,%ebp
800d78: 57 push %edi
800d79: 56 push %esi
800d7a: 53 push %ebx
asm volatile("int %1\n" //执行int T_SYSCALL指令
800d7b: 8b 55 08 mov 0x8(%ebp),%edx
800d7e: 8b 4d 0c mov 0xc(%ebp),%ecx
800d81: b8 0c 00 00 00 mov $0xc,%eax
800d86: be 00 00 00 00 mov $0x0,%esi
800d8b: 8b 5d 10 mov 0x10(%ebp),%ebx
800d8e: 8b 7d 14 mov 0x14(%ebp),%edi
800d91: cd 30 int $0x30
return syscall(SYS_ipc_try_send, 0, envid, value, (uint32_t) srcva, perm, 0);
}
800d93: 5b pop %ebx
800d94: 5e pop %esi
800d95: 5f pop %edi
800d96: 5d pop %ebp
800d97: c3 ret
00800d98 <sys_ipc_recv>:
int
sys_ipc_recv(void *dstva)
{
800d98: 55 push %ebp
800d99: 89 e5 mov %esp,%ebp
800d9b: 57 push %edi
800d9c: 56 push %esi
800d9d: 53 push %ebx
800d9e: 83 ec 0c sub $0xc,%esp
asm volatile("int %1\n" //执行int T_SYSCALL指令
800da1: b9 00 00 00 00 mov $0x0,%ecx
800da6: 8b 55 08 mov 0x8(%ebp),%edx
800da9: b8 0d 00 00 00 mov $0xd,%eax
800dae: 89 cb mov %ecx,%ebx
800db0: 89 cf mov %ecx,%edi
800db2: 89 ce mov %ecx,%esi
800db4: cd 30 int $0x30
if(check && ret > 0)
800db6: 85 c0 test %eax,%eax
800db8: 7f 08 jg 800dc2 <sys_ipc_recv+0x2a>
return syscall(SYS_ipc_recv, 1, (uint32_t)dstva, 0, 0, 0, 0);
}
800dba: 8d 65 f4 lea -0xc(%ebp),%esp
800dbd: 5b pop %ebx
800dbe: 5e pop %esi
800dbf: 5f pop %edi
800dc0: 5d pop %ebp
800dc1: c3 ret
panic("syscall %d returned %d (> 0)", num, ret);
800dc2: 83 ec 0c sub $0xc,%esp
800dc5: 50 push %eax
800dc6: 6a 0d push $0xd
800dc8: 68 bf 16 80 00 push $0x8016bf
800dcd: 6a 23 push $0x23
800dcf: 68 dc 16 80 00 push $0x8016dc
800dd4: e8 bc 02 00 00 call 801095 <_panic>
00800dd9 <pgfault>:
// Custom page fault handler - if faulting page is copy-on-write,
// map in our own private writable copy.
//
static void
pgfault(struct UTrapframe *utf)
{
800dd9: 55 push %ebp
800dda: 89 e5 mov %esp,%ebp
800ddc: 53 push %ebx
800ddd: 83 ec 04 sub $0x4,%esp
800de0: 8b 45 08 mov 0x8(%ebp),%eax
void *addr = (void *) utf->utf_fault_va;
800de3: 8b 18 mov (%eax),%ebx
// Hint:
// Use the read-only page table mappings at uvpt
// (see <inc/memlayout.h>).
// LAB 4: Your code here.
if (!((err & FEC_WR) && (uvpt[PGNUM(addr)] & PTE_COW))) { //只有因为写操作写时拷贝的地址这中情况,才可以抢救。否则一律panic
800de5: f6 40 04 02 testb $0x2,0x4(%eax)
800de9: 74 74 je 800e5f <pgfault+0x86>
800deb: 89 d8 mov %ebx,%eax
800ded: c1 e8 0c shr $0xc,%eax
800df0: 8b 04 85 00 00 40 ef mov -0x10c00000(,%eax,4),%eax
800df7: f6 c4 08 test $0x8,%ah
800dfa: 74 63 je 800e5f <pgfault+0x86>
// page to the old page's address.
// Hint:
// You should make three system calls.
// LAB 4: Your code here.
addr = ROUNDDOWN(addr, PGSIZE);
800dfc: 81 e3 00 f0 ff ff and $0xfffff000,%ebx
if ((r = sys_page_map(0, addr, 0, PFTEMP, PTE_U|PTE_P)) < 0) //将当前进程PFTEMP也映射到当前进程addr指向的物理页
800e02: 83 ec 0c sub $0xc,%esp
800e05: 6a 05 push $0x5
800e07: 68 00 f0 7f 00 push $0x7ff000
800e0c: 6a 00 push $0x0
800e0e: 53 push %ebx
800e0f: 6a 00 push $0x0
800e11: e8 15 fe ff ff call 800c2b <sys_page_map>
800e16: 83 c4 20 add $0x20,%esp
800e19: 85 c0 test %eax,%eax
800e1b: 78 56 js 800e73 <pgfault+0x9a>
panic("sys_page_map: %e", r);
if ((r = sys_page_alloc(0, addr, PTE_P|PTE_U|PTE_W)) < 0) //令当前进程addr指向新分配的物理页
800e1d: 83 ec 04 sub $0x4,%esp
800e20: 6a 07 push $0x7
800e22: 53 push %ebx
800e23: 6a 00 push $0x0
800e25: e8 be fd ff ff call 800be8 <sys_page_alloc>
800e2a: 83 c4 10 add $0x10,%esp
800e2d: 85 c0 test %eax,%eax
800e2f: 78 54 js 800e85 <pgfault+0xac>
panic("sys_page_alloc: %e", r);
memmove(addr, PFTEMP, PGSIZE); //将PFTEMP指向的物理页拷贝到addr指向的物理页
800e31: 83 ec 04 sub $0x4,%esp
800e34: 68 00 10 00 00 push $0x1000
800e39: 68 00 f0 7f 00 push $0x7ff000
800e3e: 53 push %ebx
800e3f: e8 39 fb ff ff call 80097d <memmove>
if ((r = sys_page_unmap(0, PFTEMP)) < 0) //解除当前进程PFTEMP映射
800e44: 83 c4 08 add $0x8,%esp
800e47: 68 00 f0 7f 00 push $0x7ff000
800e4c: 6a 00 push $0x0
800e4e: e8 1a fe ff ff call 800c6d <sys_page_unmap>
800e53: 83 c4 10 add $0x10,%esp
800e56: 85 c0 test %eax,%eax
800e58: 78 3d js 800e97 <pgfault+0xbe>
panic("sys_page_unmap: %e", r);
}
800e5a: 8b 5d fc mov -0x4(%ebp),%ebx
800e5d: c9 leave
800e5e: c3 ret
panic("pgfault():not cow");
800e5f: 83 ec 04 sub $0x4,%esp
800e62: 68 ea 16 80 00 push $0x8016ea
800e67: 6a 1d push $0x1d
800e69: 68 fc 16 80 00 push $0x8016fc
800e6e: e8 22 02 00 00 call 801095 <_panic>
panic("sys_page_map: %e", r);
800e73: 50 push %eax
800e74: 68 07 17 80 00 push $0x801707
800e79: 6a 2a push $0x2a
800e7b: 68 fc 16 80 00 push $0x8016fc
800e80: e8 10 02 00 00 call 801095 <_panic>
panic("sys_page_alloc: %e", r);
800e85: 50 push %eax
800e86: 68 18 17 80 00 push $0x801718
800e8b: 6a 2c push $0x2c
800e8d: 68 fc 16 80 00 push $0x8016fc
800e92: e8 fe 01 00 00 call 801095 <_panic>
panic("sys_page_unmap: %e", r);
800e97: 50 push %eax
800e98: 68 2b 17 80 00 push $0x80172b
800e9d: 6a 2f push $0x2f
800e9f: 68 fc 16 80 00 push $0x8016fc
800ea4: e8 ec 01 00 00 call 801095 <_panic>
00800ea9 <fork>:
// Neither user exception stack should ever be marked copy-on-write,
// so you must allocate a new page for the child's user exception stack.
//
envid_t
fork(void)
{
800ea9: 55 push %ebp
800eaa: 89 e5 mov %esp,%ebp
800eac: 57 push %edi
800ead: 56 push %esi
800eae: 53 push %ebx
800eaf: 83 ec 28 sub $0x28,%esp
// LAB 4: Your code here.
extern void _pgfault_upcall(void);
set_pgfault_handler(pgfault); //设置缺页处理函数
800eb2: 68 d9 0d 80 00 push $0x800dd9
800eb7: e8 1f 02 00 00 call 8010db <set_pgfault_handler>
// This must be inlined. Exercise for reader: why?
static inline envid_t __attribute__((always_inline))
sys_exofork(void)
{
envid_t ret;
asm volatile("int %2"
800ebc: b8 07 00 00 00 mov $0x7,%eax
800ec1: cd 30 int $0x30
800ec3: 89 45 e4 mov %eax,-0x1c(%ebp)
envid_t envid = sys_exofork(); //系统调用,只是简单创建一个Env结构,复制当前用户环境寄存器状态,UTOP以下的页目录还没有建立
if (envid == 0) { //子进程将走这个逻辑
800ec6: 83 c4 10 add $0x10,%esp
800ec9: 85 c0 test %eax,%eax
800ecb: 74 12 je 800edf <fork+0x36>
800ecd: 89 c7 mov %eax,%edi
thisenv = &envs[ENVX(sys_getenvid())];
return 0;
}
if (envid < 0) {
800ecf: 83 7d e4 00 cmpl $0x0,-0x1c(%ebp)
800ed3: 78 26 js 800efb <fork+0x52>
panic("sys_exofork: %e", envid);
}
uint32_t addr;
for (addr = 0; addr < USTACKTOP; addr += PGSIZE) {
800ed5: bb 00 00 00 00 mov $0x0,%ebx
800eda: e9 94 00 00 00 jmp 800f73 <fork+0xca>
thisenv = &envs[ENVX(sys_getenvid())];
800edf: e8 c6 fc ff ff call 800baa <sys_getenvid>
800ee4: 25 ff 03 00 00 and $0x3ff,%eax
800ee9: 6b c0 7c imul $0x7c,%eax,%eax
800eec: 05 00 00 c0 ee add $0xeec00000,%eax
800ef1: a3 04 20 80 00 mov %eax,0x802004
return 0;
800ef6: e9 51 01 00 00 jmp 80104c <fork+0x1a3>
panic("sys_exofork: %e", envid);
800efb: ff 75 e4 pushl -0x1c(%ebp)
800efe: 68 3e 17 80 00 push $0x80173e
800f03: 6a 6d push $0x6d
800f05: 68 fc 16 80 00 push $0x8016fc
800f0a: e8 86 01 00 00 call 801095 <_panic>
sys_page_map(0, addr, envid, addr, PTE_SYSCALL); //对于表示为PTE_SHARE的页,拷贝映射关系,并且两个进程都有读写权限
800f0f: 83 ec 0c sub $0xc,%esp
800f12: 68 07 0e 00 00 push $0xe07
800f17: 56 push %esi
800f18: 57 push %edi
800f19: 56 push %esi
800f1a: 6a 00 push $0x0
800f1c: e8 0a fd ff ff call 800c2b <sys_page_map>
800f21: 83 c4 20 add $0x20,%esp
800f24: eb 3b jmp 800f61 <fork+0xb8>
if ((r = sys_page_map(0, addr, envid, addr, PTE_COW|PTE_U|PTE_P)) < 0)
800f26: 83 ec 0c sub $0xc,%esp
800f29: 68 05 08 00 00 push $0x805
800f2e: 56 push %esi
800f2f: 57 push %edi
800f30: 56 push %esi
800f31: 6a 00 push $0x0
800f33: e8 f3 fc ff ff call 800c2b <sys_page_map>
800f38: 83 c4 20 add $0x20,%esp
800f3b: 85 c0 test %eax,%eax
800f3d: 0f 88 a9 00 00 00 js 800fec <fork+0x143>
if ((r = sys_page_map(0, addr, 0, addr, PTE_COW|PTE_U|PTE_P)) < 0)
800f43: 83 ec 0c sub $0xc,%esp
800f46: 68 05 08 00 00 push $0x805
800f4b: 56 push %esi
800f4c: 6a 00 push $0x0
800f4e: 56 push %esi
800f4f: 6a 00 push $0x0
800f51: e8 d5 fc ff ff call 800c2b <sys_page_map>
800f56: 83 c4 20 add $0x20,%esp
800f59: 85 c0 test %eax,%eax
800f5b: 0f 88 9d 00 00 00 js 800ffe <fork+0x155>
for (addr = 0; addr < USTACKTOP; addr += PGSIZE) {
800f61: 81 c3 00 10 00 00 add $0x1000,%ebx
800f67: 81 fb 00 e0 bf ee cmp $0xeebfe000,%ebx
800f6d: 0f 84 9d 00 00 00 je 801010 <fork+0x167>
if ((uvpd[PDX(addr)] & PTE_P) && (uvpt[PGNUM(addr)] & PTE_P) //为什么uvpt[pagenumber]能访问到第pagenumber项页表条目:https://pdos.csail.mit.edu/6.828/2018/labs/lab4/uvpt.html
800f73: 89 d8 mov %ebx,%eax
800f75: c1 e8 16 shr $0x16,%eax
800f78: 8b 04 85 00 d0 7b ef mov -0x10843000(,%eax,4),%eax
800f7f: a8 01 test $0x1,%al
800f81: 74 de je 800f61 <fork+0xb8>
800f83: 89 d8 mov %ebx,%eax
800f85: c1 e8 0c shr $0xc,%eax
800f88: 8b 14 85 00 00 40 ef mov -0x10c00000(,%eax,4),%edx
800f8f: f6 c2 01 test $0x1,%dl
800f92: 74 cd je 800f61 <fork+0xb8>
&& (uvpt[PGNUM(addr)] & PTE_U)) {
800f94: 8b 14 85 00 00 40 ef mov -0x10c00000(,%eax,4),%edx
800f9b: f6 c2 04 test $0x4,%dl
800f9e: 74 c1 je 800f61 <fork+0xb8>
void *addr = (void*) (pn * PGSIZE);
800fa0: 89 c6 mov %eax,%esi
800fa2: c1 e6 0c shl $0xc,%esi
if (uvpt[pn] & PTE_SHARE) {
800fa5: 8b 14 85 00 00 40 ef mov -0x10c00000(,%eax,4),%edx
800fac: f6 c6 04 test $0x4,%dh
800faf: 0f 85 5a ff ff ff jne 800f0f <fork+0x66>
} else if ((uvpt[pn] & PTE_W) || (uvpt[pn] & PTE_COW)) { //对于UTOP以下的可写的或者写时拷贝的页,拷贝映射关系的同时,需要同时标记当前进程和子进程的页表项为PTE_COW
800fb5: 8b 14 85 00 00 40 ef mov -0x10c00000(,%eax,4),%edx
800fbc: f6 c2 02 test $0x2,%dl
800fbf: 0f 85 61 ff ff ff jne 800f26 <fork+0x7d>
800fc5: 8b 04 85 00 00 40 ef mov -0x10c00000(,%eax,4),%eax
800fcc: f6 c4 08 test $0x8,%ah
800fcf: 0f 85 51 ff ff ff jne 800f26 <fork+0x7d>
sys_page_map(0, addr, envid, addr, PTE_U|PTE_P); //对于只读的页,只需要拷贝映射关系即可
800fd5: 83 ec 0c sub $0xc,%esp
800fd8: 6a 05 push $0x5
800fda: 56 push %esi
800fdb: 57 push %edi
800fdc: 56 push %esi
800fdd: 6a 00 push $0x0
800fdf: e8 47 fc ff ff call 800c2b <sys_page_map>
800fe4: 83 c4 20 add $0x20,%esp
800fe7: e9 75 ff ff ff jmp 800f61 <fork+0xb8>
panic("sys_page_map:%e", r);
800fec: 50 push %eax
800fed: 68 4e 17 80 00 push $0x80174e
800ff2: 6a 48 push $0x48
800ff4: 68 fc 16 80 00 push $0x8016fc
800ff9: e8 97 00 00 00 call 801095 <_panic>
panic("sys_page_map:%e", r);
800ffe: 50 push %eax
800fff: 68 4e 17 80 00 push $0x80174e
801004: 6a 4a push $0x4a
801006: 68 fc 16 80 00 push $0x8016fc
80100b: e8 85 00 00 00 call 801095 <_panic>
duppage(envid, PGNUM(addr)); //拷贝当前进程映射关系到子进程
}
}
int r;
if ((r = sys_page_alloc(envid, (void *)(UXSTACKTOP-PGSIZE), PTE_P | PTE_W | PTE_U)) < 0) //为子进程分配异常栈
801010: 83 ec 04 sub $0x4,%esp
801013: 6a 07 push $0x7
801015: 68 00 f0 bf ee push $0xeebff000
80101a: ff 75 e4 pushl -0x1c(%ebp)
80101d: e8 c6 fb ff ff call 800be8 <sys_page_alloc>
801022: 83 c4 10 add $0x10,%esp
801025: 85 c0 test %eax,%eax
801027: 78 2e js 801057 <fork+0x1ae>
panic("sys_page_alloc: %e", r);
sys_env_set_pgfault_upcall(envid, _pgfault_upcall); //为子进程设置_pgfault_upcall
801029: 83 ec 08 sub $0x8,%esp
80102c: 68 34 11 80 00 push $0x801134
801031: 8b 7d e4 mov -0x1c(%ebp),%edi
801034: 57 push %edi
801035: e8 f9 fc ff ff call 800d33 <sys_env_set_pgfault_upcall>
if ((r = sys_env_set_status(envid, ENV_RUNNABLE)) < 0) //设置子进程为ENV_RUNNABLE状态
80103a: 83 c4 08 add $0x8,%esp
80103d: 6a 02 push $0x2
80103f: 57 push %edi
801040: e8 6a fc ff ff call 800caf <sys_env_set_status>
801045: 83 c4 10 add $0x10,%esp
801048: 85 c0 test %eax,%eax
80104a: 78 1d js 801069 <fork+0x1c0>
panic("sys_env_set_status: %e", r);
return envid;
}
80104c: 8b 45 e4 mov -0x1c(%ebp),%eax
80104f: 8d 65 f4 lea -0xc(%ebp),%esp
801052: 5b pop %ebx
801053: 5e pop %esi
801054: 5f pop %edi
801055: 5d pop %ebp
801056: c3 ret
panic("sys_page_alloc: %e", r);
801057: 50 push %eax
801058: 68 18 17 80 00 push $0x801718
80105d: 6a 79 push $0x79
80105f: 68 fc 16 80 00 push $0x8016fc
801064: e8 2c 00 00 00 call 801095 <_panic>
panic("sys_env_set_status: %e", r);
801069: 50 push %eax
80106a: 68 60 17 80 00 push $0x801760
80106f: 6a 7d push $0x7d
801071: 68 fc 16 80 00 push $0x8016fc
801076: e8 1a 00 00 00 call 801095 <_panic>
0080107b <sfork>:
// Challenge!
int
sfork(void)
{
80107b: 55 push %ebp
80107c: 89 e5 mov %esp,%ebp
80107e: 83 ec 0c sub $0xc,%esp
panic("sfork not implemented");
801081: 68 77 17 80 00 push $0x801777
801086: 68 85 00 00 00 push $0x85
80108b: 68 fc 16 80 00 push $0x8016fc
801090: e8 00 00 00 00 call 801095 <_panic>
00801095 <_panic>:
* It prints "panic: <message>", then causes a breakpoint exception,
* which causes JOS to enter the JOS kernel monitor.
*/
void
_panic(const char *file, int line, const char *fmt, ...)
{
801095: 55 push %ebp
801096: 89 e5 mov %esp,%ebp
801098: 56 push %esi
801099: 53 push %ebx
va_list ap;
va_start(ap, fmt);
80109a: 8d 5d 14 lea 0x14(%ebp),%ebx
// Print the panic message
cprintf("[%08x] user panic in %s at %s:%d: ",
80109d: 8b 35 00 20 80 00 mov 0x802000,%esi
8010a3: e8 02 fb ff ff call 800baa <sys_getenvid>
8010a8: 83 ec 0c sub $0xc,%esp
8010ab: ff 75 0c pushl 0xc(%ebp)
8010ae: ff 75 08 pushl 0x8(%ebp)
8010b1: 56 push %esi
8010b2: 50 push %eax
8010b3: 68 90 17 80 00 push $0x801790
8010b8: e8 13 f1 ff ff call 8001d0 <cprintf>
sys_getenvid(), binaryname, file, line);
vcprintf(fmt, ap);
8010bd: 83 c4 18 add $0x18,%esp
8010c0: 53 push %ebx
8010c1: ff 75 10 pushl 0x10(%ebp)
8010c4: e8 b6 f0 ff ff call 80017f <vcprintf>
cprintf("\n");
8010c9: c7 04 24 af 13 80 00 movl $0x8013af,(%esp)
8010d0: e8 fb f0 ff ff call 8001d0 <cprintf>
8010d5: 83 c4 10 add $0x10,%esp
// Cause a breakpoint exception
while (1)
asm volatile("int3");
8010d8: cc int3
8010d9: eb fd jmp 8010d8 <_panic+0x43>
008010db <set_pgfault_handler>:
// at UXSTACKTOP), and tell the kernel to call the assembly-language
// _pgfault_upcall routine when a page fault occurs.
//
void
set_pgfault_handler(void (*handler)(struct UTrapframe *utf))
{
8010db: 55 push %ebp
8010dc: 89 e5 mov %esp,%ebp
8010de: 83 ec 08 sub $0x8,%esp
int r;
if (_pgfault_handler == 0) {
8010e1: 83 3d 08 20 80 00 00 cmpl $0x0,0x802008
8010e8: 74 0a je 8010f4 <set_pgfault_handler+0x19>
}
sys_env_set_pgfault_upcall(0, _pgfault_upcall); //系统调用,设置进程的env_pgfault_upcall属性
}
// Save handler pointer for assembly to call.
_pgfault_handler = handler;
8010ea: 8b 45 08 mov 0x8(%ebp),%eax
8010ed: a3 08 20 80 00 mov %eax,0x802008
}
8010f2: c9 leave
8010f3: c3 ret
int r = sys_page_alloc(0, (void *)(UXSTACKTOP-PGSIZE), PTE_W | PTE_U | PTE_P); //为当前进程分配异常栈
8010f4: 83 ec 04 sub $0x4,%esp
8010f7: 6a 07 push $0x7
8010f9: 68 00 f0 bf ee push $0xeebff000
8010fe: 6a 00 push $0x0
801100: e8 e3 fa ff ff call 800be8 <sys_page_alloc>
if (r < 0) {
801105: 83 c4 10 add $0x10,%esp
801108: 85 c0 test %eax,%eax
80110a: 78 14 js 801120 <set_pgfault_handler+0x45>
sys_env_set_pgfault_upcall(0, _pgfault_upcall); //系统调用,设置进程的env_pgfault_upcall属性
80110c: 83 ec 08 sub $0x8,%esp
80110f: 68 34 11 80 00 push $0x801134
801114: 6a 00 push $0x0
801116: e8 18 fc ff ff call 800d33 <sys_env_set_pgfault_upcall>
80111b: 83 c4 10 add $0x10,%esp
80111e: eb ca jmp 8010ea <set_pgfault_handler+0xf>
panic("set_pgfault_handler:sys_page_alloc failed");;
801120: 83 ec 04 sub $0x4,%esp
801123: 68 b4 17 80 00 push $0x8017b4
801128: 6a 22 push $0x22
80112a: 68 e0 17 80 00 push $0x8017e0
80112f: e8 61 ff ff ff call 801095 <_panic>
00801134 <_pgfault_upcall>:
.text
.globl _pgfault_upcall
_pgfault_upcall:
// Call the C page fault handler.
pushl %esp // function argument: pointer to UTF
801134: 54 push %esp
movl _pgfault_handler, %eax
801135: a1 08 20 80 00 mov 0x802008,%eax
call *%eax //调用页处理函数
80113a: ff d0 call *%eax
addl $4, %esp // pop function argument
80113c: 83 c4 04 add $0x4,%esp
// LAB 4: Your code here.
// Restore the trap-time registers. After you do this, you
// can no longer modify any general-purpose registers.
// LAB 4: Your code here.
addl $8, %esp //跳过utf_fault_va和utf_err
80113f: 83 c4 08 add $0x8,%esp
movl 40(%esp), %eax //保存中断发生时的esp到eax
801142: 8b 44 24 28 mov 0x28(%esp),%eax
movl 32(%esp), %ecx //保存终端发生时的eip到ecx
801146: 8b 4c 24 20 mov 0x20(%esp),%ecx
movl %ecx, -4(%eax) //将中断发生时的esp值亚入到到原来的栈中
80114a: 89 48 fc mov %ecx,-0x4(%eax)
popal
80114d: 61 popa
addl $4, %esp //跳过eip
80114e: 83 c4 04 add $0x4,%esp
// Restore eflags from the stack. After you do this, you can
// no longer use arithmetic operations or anything else that
// modifies eflags.
// LAB 4: Your code here.
popfl
801151: 9d popf
// Switch back to the adjusted trap-time stack.
// LAB 4: Your code here.
popl %esp
801152: 5c pop %esp
// Return to re-execute the instruction that faulted.
// LAB 4: Your code here.
lea -4(%esp), %esp //因为之前压入了eip的值但是没有减esp的值,所以现在需要将esp寄存器中的值减4
801153: 8d 64 24 fc lea -0x4(%esp),%esp
801157: c3 ret
801158: 66 90 xchg %ax,%ax
80115a: 66 90 xchg %ax,%ax
80115c: 66 90 xchg %ax,%ax
80115e: 66 90 xchg %ax,%ax
00801160 <__udivdi3>:
801160: 55 push %ebp
801161: 57 push %edi
801162: 56 push %esi
801163: 53 push %ebx
801164: 83 ec 1c sub $0x1c,%esp
801167: 8b 54 24 3c mov 0x3c(%esp),%edx
80116b: 8b 6c 24 30 mov 0x30(%esp),%ebp
80116f: 8b 74 24 34 mov 0x34(%esp),%esi
801173: 8b 5c 24 38 mov 0x38(%esp),%ebx
801177: 85 d2 test %edx,%edx
801179: 75 35 jne 8011b0 <__udivdi3+0x50>
80117b: 39 f3 cmp %esi,%ebx
80117d: 0f 87 bd 00 00 00 ja 801240 <__udivdi3+0xe0>
801183: 85 db test %ebx,%ebx
801185: 89 d9 mov %ebx,%ecx
801187: 75 0b jne 801194 <__udivdi3+0x34>
801189: b8 01 00 00 00 mov $0x1,%eax
80118e: 31 d2 xor %edx,%edx
801190: f7 f3 div %ebx
801192: 89 c1 mov %eax,%ecx
801194: 31 d2 xor %edx,%edx
801196: 89 f0 mov %esi,%eax
801198: f7 f1 div %ecx
80119a: 89 c6 mov %eax,%esi
80119c: 89 e8 mov %ebp,%eax
80119e: 89 f7 mov %esi,%edi
8011a0: f7 f1 div %ecx
8011a2: 89 fa mov %edi,%edx
8011a4: 83 c4 1c add $0x1c,%esp
8011a7: 5b pop %ebx
8011a8: 5e pop %esi
8011a9: 5f pop %edi
8011aa: 5d pop %ebp
8011ab: c3 ret
8011ac: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
8011b0: 39 f2 cmp %esi,%edx
8011b2: 77 7c ja 801230 <__udivdi3+0xd0>
8011b4: 0f bd fa bsr %edx,%edi
8011b7: 83 f7 1f xor $0x1f,%edi
8011ba: 0f 84 98 00 00 00 je 801258 <__udivdi3+0xf8>
8011c0: 89 f9 mov %edi,%ecx
8011c2: b8 20 00 00 00 mov $0x20,%eax
8011c7: 29 f8 sub %edi,%eax
8011c9: d3 e2 shl %cl,%edx
8011cb: 89 54 24 08 mov %edx,0x8(%esp)
8011cf: 89 c1 mov %eax,%ecx
8011d1: 89 da mov %ebx,%edx
8011d3: d3 ea shr %cl,%edx
8011d5: 8b 4c 24 08 mov 0x8(%esp),%ecx
8011d9: 09 d1 or %edx,%ecx
8011db: 89 f2 mov %esi,%edx
8011dd: 89 4c 24 08 mov %ecx,0x8(%esp)
8011e1: 89 f9 mov %edi,%ecx
8011e3: d3 e3 shl %cl,%ebx
8011e5: 89 c1 mov %eax,%ecx
8011e7: d3 ea shr %cl,%edx
8011e9: 89 f9 mov %edi,%ecx
8011eb: 89 5c 24 0c mov %ebx,0xc(%esp)
8011ef: d3 e6 shl %cl,%esi
8011f1: 89 eb mov %ebp,%ebx
8011f3: 89 c1 mov %eax,%ecx
8011f5: d3 eb shr %cl,%ebx
8011f7: 09 de or %ebx,%esi
8011f9: 89 f0 mov %esi,%eax
8011fb: f7 74 24 08 divl 0x8(%esp)
8011ff: 89 d6 mov %edx,%esi
801201: 89 c3 mov %eax,%ebx
801203: f7 64 24 0c mull 0xc(%esp)
801207: 39 d6 cmp %edx,%esi
801209: 72 0c jb 801217 <__udivdi3+0xb7>
80120b: 89 f9 mov %edi,%ecx
80120d: d3 e5 shl %cl,%ebp
80120f: 39 c5 cmp %eax,%ebp
801211: 73 5d jae 801270 <__udivdi3+0x110>
801213: 39 d6 cmp %edx,%esi
801215: 75 59 jne 801270 <__udivdi3+0x110>
801217: 8d 43 ff lea -0x1(%ebx),%eax
80121a: 31 ff xor %edi,%edi
80121c: 89 fa mov %edi,%edx
80121e: 83 c4 1c add $0x1c,%esp
801221: 5b pop %ebx
801222: 5e pop %esi
801223: 5f pop %edi
801224: 5d pop %ebp
801225: c3 ret
801226: 8d 76 00 lea 0x0(%esi),%esi
801229: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
801230: 31 ff xor %edi,%edi
801232: 31 c0 xor %eax,%eax
801234: 89 fa mov %edi,%edx
801236: 83 c4 1c add $0x1c,%esp
801239: 5b pop %ebx
80123a: 5e pop %esi
80123b: 5f pop %edi
80123c: 5d pop %ebp
80123d: c3 ret
80123e: 66 90 xchg %ax,%ax
801240: 31 ff xor %edi,%edi
801242: 89 e8 mov %ebp,%eax
801244: 89 f2 mov %esi,%edx
801246: f7 f3 div %ebx
801248: 89 fa mov %edi,%edx
80124a: 83 c4 1c add $0x1c,%esp
80124d: 5b pop %ebx
80124e: 5e pop %esi
80124f: 5f pop %edi
801250: 5d pop %ebp
801251: c3 ret
801252: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
801258: 39 f2 cmp %esi,%edx
80125a: 72 06 jb 801262 <__udivdi3+0x102>
80125c: 31 c0 xor %eax,%eax
80125e: 39 eb cmp %ebp,%ebx
801260: 77 d2 ja 801234 <__udivdi3+0xd4>
801262: b8 01 00 00 00 mov $0x1,%eax
801267: eb cb jmp 801234 <__udivdi3+0xd4>
801269: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
801270: 89 d8 mov %ebx,%eax
801272: 31 ff xor %edi,%edi
801274: eb be jmp 801234 <__udivdi3+0xd4>
801276: 66 90 xchg %ax,%ax
801278: 66 90 xchg %ax,%ax
80127a: 66 90 xchg %ax,%ax
80127c: 66 90 xchg %ax,%ax
80127e: 66 90 xchg %ax,%ax
00801280 <__umoddi3>:
801280: 55 push %ebp
801281: 57 push %edi
801282: 56 push %esi
801283: 53 push %ebx
801284: 83 ec 1c sub $0x1c,%esp
801287: 8b 6c 24 3c mov 0x3c(%esp),%ebp
80128b: 8b 74 24 30 mov 0x30(%esp),%esi
80128f: 8b 5c 24 34 mov 0x34(%esp),%ebx
801293: 8b 7c 24 38 mov 0x38(%esp),%edi
801297: 85 ed test %ebp,%ebp
801299: 89 f0 mov %esi,%eax
80129b: 89 da mov %ebx,%edx
80129d: 75 19 jne 8012b8 <__umoddi3+0x38>
80129f: 39 df cmp %ebx,%edi
8012a1: 0f 86 b1 00 00 00 jbe 801358 <__umoddi3+0xd8>
8012a7: f7 f7 div %edi
8012a9: 89 d0 mov %edx,%eax
8012ab: 31 d2 xor %edx,%edx
8012ad: 83 c4 1c add $0x1c,%esp
8012b0: 5b pop %ebx
8012b1: 5e pop %esi
8012b2: 5f pop %edi
8012b3: 5d pop %ebp
8012b4: c3 ret
8012b5: 8d 76 00 lea 0x0(%esi),%esi
8012b8: 39 dd cmp %ebx,%ebp
8012ba: 77 f1 ja 8012ad <__umoddi3+0x2d>
8012bc: 0f bd cd bsr %ebp,%ecx
8012bf: 83 f1 1f xor $0x1f,%ecx
8012c2: 89 4c 24 04 mov %ecx,0x4(%esp)
8012c6: 0f 84 b4 00 00 00 je 801380 <__umoddi3+0x100>
8012cc: b8 20 00 00 00 mov $0x20,%eax
8012d1: 89 c2 mov %eax,%edx
8012d3: 8b 44 24 04 mov 0x4(%esp),%eax
8012d7: 29 c2 sub %eax,%edx
8012d9: 89 c1 mov %eax,%ecx
8012db: 89 f8 mov %edi,%eax
8012dd: d3 e5 shl %cl,%ebp
8012df: 89 d1 mov %edx,%ecx
8012e1: 89 54 24 0c mov %edx,0xc(%esp)
8012e5: d3 e8 shr %cl,%eax
8012e7: 09 c5 or %eax,%ebp
8012e9: 8b 44 24 04 mov 0x4(%esp),%eax
8012ed: 89 c1 mov %eax,%ecx
8012ef: d3 e7 shl %cl,%edi
8012f1: 89 d1 mov %edx,%ecx
8012f3: 89 7c 24 08 mov %edi,0x8(%esp)
8012f7: 89 df mov %ebx,%edi
8012f9: d3 ef shr %cl,%edi
8012fb: 89 c1 mov %eax,%ecx
8012fd: 89 f0 mov %esi,%eax
8012ff: d3 e3 shl %cl,%ebx
801301: 89 d1 mov %edx,%ecx
801303: 89 fa mov %edi,%edx
801305: d3 e8 shr %cl,%eax
801307: 0f b6 4c 24 04 movzbl 0x4(%esp),%ecx
80130c: 09 d8 or %ebx,%eax
80130e: f7 f5 div %ebp
801310: d3 e6 shl %cl,%esi
801312: 89 d1 mov %edx,%ecx
801314: f7 64 24 08 mull 0x8(%esp)
801318: 39 d1 cmp %edx,%ecx
80131a: 89 c3 mov %eax,%ebx
80131c: 89 d7 mov %edx,%edi
80131e: 72 06 jb 801326 <__umoddi3+0xa6>
801320: 75 0e jne 801330 <__umoddi3+0xb0>
801322: 39 c6 cmp %eax,%esi
801324: 73 0a jae 801330 <__umoddi3+0xb0>
801326: 2b 44 24 08 sub 0x8(%esp),%eax
80132a: 19 ea sbb %ebp,%edx
80132c: 89 d7 mov %edx,%edi
80132e: 89 c3 mov %eax,%ebx
801330: 89 ca mov %ecx,%edx
801332: 0f b6 4c 24 0c movzbl 0xc(%esp),%ecx
801337: 29 de sub %ebx,%esi
801339: 19 fa sbb %edi,%edx
80133b: 8b 5c 24 04 mov 0x4(%esp),%ebx
80133f: 89 d0 mov %edx,%eax
801341: d3 e0 shl %cl,%eax
801343: 89 d9 mov %ebx,%ecx
801345: d3 ee shr %cl,%esi
801347: d3 ea shr %cl,%edx
801349: 09 f0 or %esi,%eax
80134b: 83 c4 1c add $0x1c,%esp
80134e: 5b pop %ebx
80134f: 5e pop %esi
801350: 5f pop %edi
801351: 5d pop %ebp
801352: c3 ret
801353: 90 nop
801354: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
801358: 85 ff test %edi,%edi
80135a: 89 f9 mov %edi,%ecx
80135c: 75 0b jne 801369 <__umoddi3+0xe9>
80135e: b8 01 00 00 00 mov $0x1,%eax
801363: 31 d2 xor %edx,%edx
801365: f7 f7 div %edi
801367: 89 c1 mov %eax,%ecx
801369: 89 d8 mov %ebx,%eax
80136b: 31 d2 xor %edx,%edx
80136d: f7 f1 div %ecx
80136f: 89 f0 mov %esi,%eax
801371: f7 f1 div %ecx
801373: e9 31 ff ff ff jmp 8012a9 <__umoddi3+0x29>
801378: 90 nop
801379: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
801380: 39 dd cmp %ebx,%ebp
801382: 72 08 jb 80138c <__umoddi3+0x10c>
801384: 39 f7 cmp %esi,%edi
801386: 0f 87 21 ff ff ff ja 8012ad <__umoddi3+0x2d>
80138c: 89 da mov %ebx,%edx
80138e: 89 f0 mov %esi,%eax
801390: 29 f8 sub %edi,%eax
801392: 19 ea sbb %ebp,%edx
801394: e9 14 ff ff ff jmp 8012ad <__umoddi3+0x2d>
|
; A051062: a(n) = 16*n + 8.
; 8,24,40,56,72,88,104,120,136,152,168,184,200,216,232,248,264,280,296,312,328,344,360,376,392,408,424,440,456,472,488,504,520,536,552,568,584,600,616,632,648,664,680,696,712,728,744,760,776,792,808,824,840
mul $0,16
add $0,8
|
/*
* Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
* Not a Contribution
*/
/*
* Copyright (C) 2016 The Android Open Source Project
*
* 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.
*/
#define LOG_TAG "LocSvc_GnssMeasurementInterface"
#include <log_util.h>
#include <MeasurementAPIClient.h>
#include "GnssMeasurement.h"
namespace android {
namespace hardware {
namespace gnss {
namespace V1_1 {
namespace implementation {
void GnssMeasurement::GnssMeasurementDeathRecipient::serviceDied(
uint64_t cookie, const wp<IBase>& who) {
LOC_LOGE("%s] service died. cookie: %llu, who: %p",
__FUNCTION__, static_cast<unsigned long long>(cookie), &who);
if (mGnssMeasurement != nullptr) {
mGnssMeasurement->close();
}
}
GnssMeasurement::GnssMeasurement() {
mGnssMeasurementDeathRecipient = new GnssMeasurementDeathRecipient(this);
mApi = new MeasurementAPIClient();
}
GnssMeasurement::~GnssMeasurement() {
if (mApi) {
delete mApi;
mApi = nullptr;
}
}
// Methods from ::android::hardware::gnss::V1_0::IGnssMeasurement follow.
Return<IGnssMeasurement::GnssMeasurementStatus> GnssMeasurement::setCallback(
const sp<V1_0::IGnssMeasurementCallback>& callback) {
Return<IGnssMeasurement::GnssMeasurementStatus> ret =
IGnssMeasurement::GnssMeasurementStatus::ERROR_GENERIC;
if (mGnssMeasurementCbIface != nullptr) {
LOC_LOGE("%s]: GnssMeasurementCallback is already set", __FUNCTION__);
return IGnssMeasurement::GnssMeasurementStatus::ERROR_ALREADY_INIT;
}
if (callback == nullptr) {
LOC_LOGE("%s]: callback is nullptr", __FUNCTION__);
return ret;
}
if (mApi == nullptr) {
LOC_LOGE("%s]: mApi is nullptr", __FUNCTION__);
return ret;
}
mGnssMeasurementCbIface = callback;
mGnssMeasurementCbIface->linkToDeath(mGnssMeasurementDeathRecipient, 0);
return mApi->measurementSetCallback(callback);
}
Return<void> GnssMeasurement::close() {
if (mApi == nullptr) {
LOC_LOGE("%s]: mApi is nullptr", __FUNCTION__);
return Void();
}
if (mGnssMeasurementCbIface != nullptr) {
mGnssMeasurementCbIface->unlinkToDeath(mGnssMeasurementDeathRecipient);
mGnssMeasurementCbIface = nullptr;
}
if (mGnssMeasurementCbIface_1_1 != nullptr) {
mGnssMeasurementCbIface_1_1->unlinkToDeath(mGnssMeasurementDeathRecipient);
mGnssMeasurementCbIface_1_1 = nullptr;
}
mApi->measurementClose();
return Void();
}
// Methods from ::android::hardware::gnss::V1_1::IGnssMeasurement follow.
Return<GnssMeasurement::GnssMeasurementStatus> GnssMeasurement::setCallback_1_1(
const sp<IGnssMeasurementCallback>& callback, bool enableFullTracking) {
Return<IGnssMeasurement::GnssMeasurementStatus> ret =
IGnssMeasurement::GnssMeasurementStatus::ERROR_GENERIC;
if (mGnssMeasurementCbIface_1_1 != nullptr) {
LOC_LOGE("%s]: GnssMeasurementCallback is already set", __FUNCTION__);
return IGnssMeasurement::GnssMeasurementStatus::ERROR_ALREADY_INIT;
}
if (callback == nullptr) {
LOC_LOGE("%s]: callback is nullptr", __FUNCTION__);
return ret;
}
if (nullptr == mApi) {
LOC_LOGE("%s]: mApi is nullptr", __FUNCTION__);
return ret;
}
mGnssMeasurementCbIface_1_1 = callback;
mGnssMeasurementCbIface_1_1->linkToDeath(mGnssMeasurementDeathRecipient, 0);
GnssPowerMode powerMode = enableFullTracking?
GNSS_POWER_MODE_M1 : GNSS_POWER_MODE_M2;
return mApi->measurementSetCallback_1_1(callback, powerMode);
}
} // namespace implementation
} // namespace V1_1
} // namespace gnss
} // namespace hardware
} // namespace android
|
.data
MainMessage : .asciiz "Enter a Valid Number of the Menus \n1- Search for Request by Priority \n2- Delete all Requests of same Priority \n3- Process all Requests of same Priority \n4- Empty All lists \n5- Insert Requests \n6- print All \n-1 to end the program\n"
firstMessage : .asciiz "Enter The Request Priority that you wish to search : "
secondMessage : .asciiz ""
thirdMessage : .asciiz "Not Found\n"
fourthMessage : .asciiz "Enter The Request Priority that you wish to Delete \n"
fifthMessage : .asciiz "Enter The Request Priority that you wish to Process \n"
sixthMessage : .asciiz "Please Enter Valid menu\n"
message: .asciiz "Binary Search Value "
equal:.asciiz "Inside Equal "
smaller:.asciiz "Inside smaller "
greater:.asciiz "Inside Greater "
innerBinaryMessage:.asciiz "Paramter passed "
sizeOfListsArray: .word 0
.word 4
.word 4
.word 4
#request size is 20 byte and each row contain 20 request then each row will be 400 byte to cover all requests we need
# 4 rows cause we have 4 lists
array: .space 12
.space 12
.space 12
.space 12
colNumber: .word 4 #number of cols in 2d array
rowNumber: .word 1 #number of rows in 2d array
.eqv requestSize 12 #size of one request
prompt: .asciiz "enter request: " #message that display when user enter request
end: .asciiz "All lists are empty"
message2: .asciiz "enter number :"
newLine: .asciiz "\n" #new line
space: .asciiz " " #space
binarySearchMessage:.asciiz "The Index of Search value is "
.text
main :
la $s2 array #load array addresse in s
lw $s0 , colNumber #load cols number in s0
lw $s1 , rowNumber #load row number in s1
#printing meneu
li $v0,4
la $a0,MainMessage
syscall
#Getting User Input value
li $v0,5
syscall
#Store the result in $t0
move $t0,$v0
addi $t1 , $zero , -1
addi $t2 , $zero , 1
addi $t3 , $zero , 2
addi $t4 , $zero , 3
addi $t5 , $zero , 4
addi $t6 , $zero , 5
addi $t7 , $zero , 6
while :
beq $t0 , $t1 , exit
beq $t0 , $t2 , ifStatement1
beq $t0 , $t3 , ifStatement2
beq $t0 , $t4 , ifStatement3
beq $t0 , $t5 , ifStatement4
beq $t0 , $t6 , ifStatement5
beq $t0 , $t7 , ifStatement6
j Else
j printMainMessage
li $v0,5
syscall
j while
exit :
li $v0,10
syscall
ifStatement1 :
#Call binary Search and return result WIth Message
li $v0 ,4
la $a0, firstMessage
syscall
li $v0 , 5
syscall
move $a0, $v0
jal binarySearch
move $t0, $v0 #get the return value
#print message
li $v0, 4
la $a0, binarySearchMessage
syscall
#print the result
li $v0,1
move $a0, $t0
syscall
#print new line
li $v0, 4
la $a0, newLine
syscall
j main
ifStatement2 :
li $v0,4
la $a0,fourthMessage
syscall
li $v0,5
jal Delete_all
#li $v0,10
#syscall
ifStatement3 :
li $v0,4
la $a0,fifthMessage
syscall
li $v0,5
jal Process_all
#li $v0,10
#syscall
ifStatement4 :
jal Emptyall
#jr $ra
#li $v0 , 10
#syscall
ifStatement5 :
jal inputArray
#j while
#jr $ra
#li $v0,10
#syscall
ifStatement6 :
jal printArray #function call
Else :
li $v0 , 4
la $a0 , sixthMessage
syscall
printMainMessage :
li $v0,4
la $a0,MainMessage
syscall
#put input in array
inputArray:
li $t2 , 0 #index for row
li $t4 , 0 # index for col
loop3:
bge $t2 ,$s1 end3 #counter greater than or equal number of rows
loop4:
bge $t4 ,$s0 end4 #counter greater than or equal number of cols
#formla to loop in 2d array
mul $t3 , $t2 , $s0
add $t3 ,$t3 , $t4
mul $t3 , $t3 , requestSize
add $t3 ,$t3 ,$s2
#print prompt message
li $v0 ,4
la $a0 , prompt
syscall
#take priorty from user
li $v0 , 5
syscall
#move value of priorty from vo to t0
move $t0, $v0
#sw $t0, integer
sb $t0,0($t3)
#add 4 bytes to addresse in t3 to go to index that will hold input data
addi $t3 , $t3 ,4
#input User Data text
li $v0, 8
la $a0, ($t3)
li $a1, 8 #maximum number of character user can input
syscall
addi $t4 , $t4 ,1 #second loop counter ++
j loop4 # go back to loop4 branch
end4: #end of loop4
addi $t2 , $t2 ,1 #first loop counter
li $t4 , 0 #reset second loop to 0
j loop3 # go back to loop3 branch
end3: #end of loop3
j main #return to main program
######################
Process_all:
#print prompt message
li $v0 ,4
la $a0 , message2
syscall
#take priorty from user
li $v0 , 5
syscall
move $t0, $v0
li $t2 , 0 #index for row
li $t4 , 0 # index for col
addi $t3 ,$t3 , 0
loop1: #frist loop
bge $t2 ,$s1 end1 #counter greater than or equal number of rows
loop2: #second loop
# beq $t3,$zero,jump
bge $t4 ,$s0 end2 #counter greater than or equal number of cols
#formla to loop in 2d array
mul $t3 , $t2 , $s0
add $t3 ,$t3 , $t4
mul $t3 , $t3 , requestSize
add $t3 ,$t3 ,$s2
#load $t3 in $a0
lb $a0, ($t3)
# branch to check request
beq $a0,$t0,jump
addi $t4 , $t4 ,1 #second loop counter ++
j loop2 #go to loop2 branch
# print request
jump:
#print prority
lb $a0, ($t3)
li $v0, 1
syscall
#print space
li $v0 , 4
la $a0 , space
syscall
#print data
#addi $t3 ,$t3 ,10 #add 10 to current bit to get data form the index
addi $t3 ,$t3 ,4
#load the data part
la $a0, ($t3)
#print the data part
li $v0, 4
syscall
#print new line
li $v0 , 4
la $a0 , newLine
syscall
addi $t4 , $t4 ,1 #second loop counter ++
j loop2 #go to loop2 branch
end2: #end of loop2
addi $t2 , $t2 ,1
li $t4 , 0
j loop1 #go to loop1 branch
end1:
j main
Emptyall:
li $t2 , 0 #index for row
li $t4 , 0 # index for col
addi $t3 ,$t3 , 0
loop5: #frist loop
bge $t2 ,$s1 end5 #counter greater than or equal number of rows
loop6: #second loop
bge $t4 ,$s0 end6 #counter greater than or equal number of cols
#formla to loop in 2d array
mul $t3 , $t2 , $s0
add $t3 ,$t3 , $t4
mul $t3 , $t3 , requestSize
add $t3 ,$t3 ,$s2
#delete prority
sb $zero, 0($t3)
#lw $a0, ($t3)
# addi $a0,$zero,0
#delete data
#addi $t3 ,$t3 ,4 #add 4 to current bit to get data form the index
addi $t3 ,$t3 ,4
#load the data part
sb $zero, 0($t3)
# la $a0, ($t3)
# addi $a0,$zero,0
addi $t4 , $t4 ,1 #second loop counter ++
j loop6 #go to loop2 branch
end6: #end of loop2
addi $t2 , $t2 ,1
li $t4 , 0
j loop5 #go to loop1 branch
end5:
li $v0 , 4
la $a0, end
syscall
j main
########################################
Delete_all:
#print prompt message
li $v0 ,4
la $a0 , message2
syscall
#take priorty from user
li $v0 , 5
syscall
move $t0, $v0
li $t5, 0
li $t2 , 0 #index for row
li $t4 , 0 # index for col
addi $t3 ,$t3 , 0
loop11: #frist loop
bge $t2 ,$s1 end11 #counter greater than or equal number of rows
loop22: #second loop
bge $t4 ,$s0 end22 #counter greater than or equal number of cols
#formla to loop in 2d array
mul $t3 , $t2 , $s0
add $t3 ,$t3 , $t4
mul $t3 , $t3 , requestSize
add $t3 ,$t3 ,$s2
#load $t3 in $a0
lb $a0, ($t3)
# branch to check request
beq $a0,$t0,jump1
addi $t4 , $t4 ,1 #second loop counter ++
j loop22 #go to loop2 branch
# print request
jump1:
#delete prority
sb $t5, 0($t3)
#lw $a0, ($t3)
# addi $a0,$zero,0
#delete data
#addi $t3 ,$t3 ,4 #add 4 to current bit to get data form the index
addi $t3 ,$t3 ,4
#load the data part
sb $t5, 0($t3)
# la $a0, ($t3)
# addi $a0,$zero,0
addi $t4 , $t4 ,1 #second loop counter ++
j loop22 #go to loop2 branch
end22: #end of loop2
addi $t2 , $t2 ,1
li $t4 , 0
j loop11 #go to loop1 branch
end11:
j main
#########################
printArray:
li $t2 , 0 #index for row
li $t4 , 0 # index for col
addi $t3 ,$t3 , 0
loop10: #frist loop
bge $t2 ,$s1 end10 #counter greater than or equal number of rows
loop20: #second loop
bge $t4 ,$s0 end20 #counter greater than or equal number of cols
#formla to loop in 2d array
mul $t3 , $t2 , $s0
add $t3 ,$t3 , $t4
mul $t3 , $t3 , requestSize
add $t3 ,$t3 ,$s2
#print prority
lb $a0, ($t3)
li $v0, 1
syscall
#print space
li $v0 , 4
la $a0 , space
syscall
#print data
#addi $t3 ,$t3 ,10 #add 10 to current bit to get data form the index
addi $t3 ,$t3 ,4
#load the data part
la $a0, ($t3)
#print the data part
li $v0, 4
syscall
#print new line
li $v0 , 4
la $a0 , newLine
syscall
addi $t4 , $t4 ,1 #second loop counter ++
j loop20 #go to loop2 branch
end20: #end of loop2
addi $t2 , $t2 ,1
li $t4 , 0
j loop10 #go to loop1 branch
end10:
j main
##################
quicksort:
addi $sp, $sp, -16 # Create stack for 4 bytes
sw $a0, 0($sp) #store address in stack
sw $a1, 4($sp) #store low in stack
sw $a2, 8($sp) #store high in stack
sw $ra, 12($sp) #store return address in stack
move $t0, $a2 #saving high in t0
slt $t1, $a1, $t0 # t1=1 if low < high, else 0
beq $t1, $zero, end_check # if low >= high, endcheck
#handling prameters to partion function
la $a0 , 0($sp) #array address
lw $a1 ,4($sp) # get low index from stack
lw $a2 ,8($sp) #get high index from stack
jal partition # call partition
move $s0, $v0 # pivot, s0= v0
la $a0 ,0($sp)
lw $a1, 4($sp) #a1 = low
addi $a2, $s0, -1 #a2 = pi -1
jal quicksort #call quicksort
la $a0 ,0($sp)
addi $a1, $s0, 1 #a1 = pi + 1
lw $a2, 8($sp) #a2 = high
jal quicksort #call quicksort
end_check:
lw $a0, 0($sp) #restore a0
lw $a1, 4($sp) #restore a1
lw $a2, 8($sp) #restore $a2
lw $ra, 12($sp) #load return adress into ra
addi $sp, $sp, 16 #restore stack
jr $ra #return to $ra
##############################
getAddress:
addi $sp, $sp, -16 #Make stack of 3 bytes
sw $a0, 0($sp) #Store $a0 array address
sw $a1, 4($sp) #Store $a1 row number
sw $a2, 8($sp) #Store $a2 col number
sw $ra ,12($sp)
move $s2 , $a0
move $s3 , $a1
move $s4 , $a2
addi $s0 ,$0 ,5 #change it later
mul $t8 , $s3 , $s0
add $t8 ,$t8 , $s4
mul $t8 , $t8 , requestSize
add $t8 ,$t8 ,$s2
move $v1 , $t8
lw $ra , 12($sp)
addi $sp,$sp,16 #restore stack
jr $ra #return to $ra
swap:
addi $sp, $sp, -16 #Make stack of 3 bytes
sw $a0, 0($sp) #Store $a0
sw $a1, 4($sp) #Store $a1
sw $a2, 8($sp) #Store $a2
sw $ra ,12($sp)
lw $s6 , 4($sp)
lw $s5 , 8($sp)
#swap the prioty
lw $t6, 0($s6) #$t6=array[left]
lw $t7, 0($s5) #$t7=array[right]
sw $t6, 0($s5) #array[right]=$t6
sw $t7, 0($s6) #array[left]=$t7
#swap the data
addi $t6 ,$s6 , 4
addi $t7 ,$s5 , 4
add $s0,$zero,$zero # i = 0 + 0
L1:
add $t1,$s0,$t6 # address of y[i] in $t1
lbu $t2, 0($t1) # $t2 = y[i]
add $t9,$s0,$t7 # address of y[i] in $t1
lbu $t4, 0($t9) # $t2 = y[i]
sb $t2, 0($t9) # x[i] = y[i]
sb $t4, 0($t1) # x[i] = y[i]
beq $t2,$zero,check2 # if y[i] == 0, go to L2
check2:
beq $t4,$zero,L2
addi $s0, $s0,1 # i = i + 1
j L1 # go to L1
L2:
lw $ra , 12($sp)
jr $ra # return
addi $sp,$sp,12 #restore stack
jr $ra #return to $ra
#################
partition:
addi $sp, $sp, -16
sw $a0, 0($sp) #address of array
sw $a1, 4($sp) #low
sw $a2, 8($sp) #high
sw $ra, 12($sp) #Return address
#mul $t0, $a1, 4 #$t0 = 4*low to get array indix in mips
#add $t1, $t0, $a0 #$t1 = address of array plus $t0 to get addresse of first index of array
move $s0, $a1 #first insex = low array index in zero based indexing
move $s1, $a2 #last index = high index of last element in array
#functioin to get frist index addresse
la $a0, array
li $a1 ,0
li $a2 ,0
jal getAddress
move $t1 , $v1
lw $s3, 0($t1) #load piroty of first index in s3
lw $t3, 0($sp) #$t3 = address of array
while10:
bge $s0, $s1, endwhile #if s0(low index) greater than s1(high index) exit loop and go to endWhile
while1:
#mul $t2, $s1, 4 #$t2= right *4
#formal to get last index from array and every time index decrease
la $a0, array
li $a1 ,0
move $a2 ,$s1
jal getAddress
move $s6 , $v1 #move adderss to s6
lw $s4, 0($s6) #load index priorty in s4
ble $s4,$s3, endwhile1 #end while1 if index priorty <= pivot(first index priorty)
subi $s1,$s1,1 #decrease s1 by 1 to go next index
j while1
endwhile1:
while2:
#mul $t4, $s0, 4 #$t4 = left*4
#formal to get frist index from array and every time index decrease
la $a0, array
li $a1 ,0
move $a2 ,$s0
jal getAddress
move $s7, $v1 #move adderss to s7
lw $s5, 0($s7) #load index priorty in s5
bge $s0, $s1, endwhile2 #branch if left>=right (j>i)to endwhile2
bgt $s5, $s3, endwhile2 #branch if index prioty >pivot(first index priorty) to endwhile2
addi $s0,$s0,1 #increase s0 by one to go next index
j while2
endwhile2:
if:
bge $s0, $s1, end_if #if left>=right (j>=i)branch to end_if
#handling parameters to swap
move $a0, $t3 #move $t3 to $a0
move $a1, $s7 #move array[left] into $a1
move $a2, $s6 #move array[right] into $a2
jal swap #jump and link swap
end_if:
j while10
endwhile:
move $a0, $t3
move $a1, $s6
move $a2, $t1
jal swap
move $v0, $s1 #set $v0 to new pivot index
lw $ra ,12($sp) #restore $ra
addi $sp, $sp,16 #restore stack
jr $ra
####################################
#Binary Search on one LIST
binarySearch:
move $s4 , $a0 # Get the Target Priority
#Print Passed Value
li $v0, 4
la $a0, innerBinaryMessage
syscall
li $v0, 1
move $a0, $s4
syscall
li $v0, 4
la $a0, newLine
syscall
la $s7, array #load the 2d Array in s7
li $t0, 0 #index for row
li $s1, 3 #index for end Of List
li $s2, 0 #start of list
whileStillExitElements:
bge $s2, $s1, endBinarySearch #Branch if st >= end ie no elements in search RAnge
add $t3, $s2, $s1 #get sum to get middle in next instruction
div $t3, $t3, 2 #calculate middle in t3
move $s5, $t3 # move the indx of middle
mul $t4, $t0, 4 #rowidx * colm size and store in t4 for further calcu
add $t4, $t3, $zero #add the colm indx which is the middle
mul $t4, $t4, requestSize #add the Strutcure size
add $t4, $t4, $s7 #add the bass addresss of array
##print the middle
li $v0, 1
lw $a0, 0($t4)
syscall
#print space
li $v0, 4
la $a0, newLine
syscall
#Load the priority of Middle
lw $s6, 0($t4)
beq $s6, $s4, ifEqual # t7 contain the target priority
blt $s6, $s4, ifSmaller #branch if Target,priorty < middle.priorty
bgt $s6, $s4, ifGreater # branch if target.priorty > middle.priorty
endBinarySearch:
#getting the results in v0
move $v0, $s1 #start or end will stop when they equal each other
jr $ra
ifEqual:
add $s1, $s5, $zero #make Start of list at the current middle
#print element
li $v0, 4
la $a0, equal
syscall
####
li $v0, 1
move $a0, $s2
syscall
#print space
li $v0, 4
la $a0, space
syscall
li $v0, 1
move $a0, $s1
syscall
#print space
li $v0, 4
la $a0, newLine
syscall
j endBinarySearch #return to binarySearch
ifGreater:
sub $s1, $s5, $1 #make end of list equal mid - 1
#print element
li $v0, 4
la $a0, greater
syscall
####
li $v0, 1
move $a0, $s2
syscall
#print space
li $v0, 4
la $a0, space
syscall
li $v0, 1
move $a0, $s1
syscall
#print space
li $v0, 4
la $a0, newLine
syscall
j whileStillExitElements #return to binarySearch
ifSmaller:
add $s2, $s5, 1 #make start of list = mid + 1
#print element
li $v0, 4
la $a0, smaller
syscall
####
li $v0, 1
move $a0, $s2
syscall
#print space
li $v0, 4
la $a0, space
syscall
li $v0, 1
move $a0, $s1
syscall
#print space
li $v0, 4
la $a0, newLine
syscall
j whileStillExitElements #return to binarySearch
######################End Binary Search
#Find First Free List
FFFL:
#try to intialize t2,t4 with the number of list
la $s6, sizeOfListsArray
li $s3, 0
Loop:
sll $t1, $s3, 2 #multipy 4 by left shift 2
add $t1, $t1, $s6 #add index address to base address
lw $s2,0($t1) # load the Address after adding to the base
blt $s2, 4, exit2# branch if less than 20 desired list
addi $s3, $s3, 1#else add idx + 1
j Loop #jump to loop while not found list less than 20 element
#take the arguments and return to caller idx of list and the current size of the first free list
exit2:
move $v0,$s3
move $v1, $s2
#restore all values used in fffl
lw $t1, 0($sp)
lw $s6, 4($sp)
lw $s3, 8($sp)
lw $s2, 12($sp)
#return to caller adderres
jr $ra
################################## #end of function
|
; A266659: Triangle read by rows giving successive states of cellular automaton generated by "Rule 47" initiated with a single ON (black) cell.
; 1,1,1,0,0,0,0,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0
add $0,2
mov $1,1
mov $2,1
mov $3,$0
lpb $0
sub $0,$2
add $2,2
trn $3,$0
cmp $1,$3
lpe
mov $0,$1
|
;=============================================================
;=== FILE: isrutilities.asm
;===
;=== Copyright (c)1998 Metrowerks, Inc. All rights reserved.
;=============================================================
; Recommended tab stop = 8.
;===============================================================================
; SECTION: the floating point code
SECTION fp_engine
OPT CC
GLOBAL ARTADDF32UISR
GLOBAL ARTSUBF32UISR
GLOBAL ARTCMPF32ISR
GLOBAL ARTCMPEF32ISR
GLOBAL ARTMPYF32UISR
GLOBAL ARTDIVF32UZISR
include "Fp568d.h"
;===============================================================================
; FUNCTION: ARTADDF32UISR
; DESCRIPTION: ISR wrapper for ARTADDF32U
; INPUT: none
; OUTPUT: none
;
ARTADDF32UISR:
;
; The result is in A, so do not save/restore A
; b,x0,r0,y0,y1
lea (SP)+
move Y0,X:(SP)+
move X0,X:(SP)+
move R0,X:(SP)+
move Y1,X:(SP)+
move B0,X:(SP)+
move B1,X:(SP)+
move B2,X:(SP)
jsr ARTADDF32U
pop B2
pop B1
pop B0
pop Y1
pop R0
pop X0
pop Y0
rts
;===============================================================================
; FUNCTION: ARTSUBF32UISR
; DESCRIPTION: ISR wrapper for ARTSUBF32U
; INPUT: none
; OUTPUT: none
;
ARTSUBF32UISR:
;
; The result is in A, so do not save/restore A
; b,x0,r0,y0,y1
lea (SP)+
move Y0,X:(SP)+
move X0,X:(SP)+
move R0,X:(SP)+
move Y1,X:(SP)+
move B0,X:(SP)+
move B1,X:(SP)+
move B2,X:(SP)
jsr ARTSUBF32U
pop B2
pop B1
pop B0
pop Y1
pop R0
pop X0
pop Y0
rts
;===============================================================================
; FUNCTION: ARTCMPF32ISR
; DESCRIPTION: ISR wrapper for ARTCMPF32
; INPUT: none
; OUTPUT: none
;
ARTCMPF32ISR:
;
; The result is in CC field, it is okay to save/restore Y0
; b,x0,r0,y0,y1
lea (SP)+
move X0,X:(SP)+
move Y1,X:(SP)+
move Y0,X:(SP)+
move A0,X:(SP)+
move A1,X:(SP)+
move A2,X:(SP)+
move B0,X:(SP)+
move B1,X:(SP)+
move B2,X:(SP)
jsr ARTCMPF32
pop B2
pop B1
pop B0
pop A2
pop A1
pop A0
pop Y0
pop Y1
pop X0
rts
;===============================================================================
; FUNCTION: ARTCMPEF32ISR
; DESCRIPTION: ISR wrapper for ARTCMPEF32
; INPUT: none
; OUTPUT: none
;
ARTCMPEF32ISR:
;
; The result is in CC field, it is okay to save/restore Y0
lea (SP)+
move X0,X:(SP)+
move Y1,X:(SP)+
move Y0,X:(SP)+
move A0,X:(SP)+
move A1,X:(SP)+
move A2,X:(SP)+
move B0,X:(SP)+
move B1,X:(SP)+
move B2,X:(SP)
jsr ARTCMPEF32
pop B2
pop B1
pop B0
pop A2
pop A1
pop A0
pop Y0
pop Y1
pop X0
rts
;===============================================================================
; FUNCTION: ARTMPYF32UISR
; DESCRIPTION: ISR wrapper for ARTMPYF32UISR
; INPUT: none
; OUTPUT: none
;
ARTMPYF32UISR:
;
; The result is in A so do not save/restore A
;
lea (SP)+
move X0,X:(SP)+
move Y1,X:(SP)+
move Y0,X:(SP)+
move R0,X:(SP)+
move R1,X:(SP)+
move B0,X:(SP)+
move B1,X:(SP)+
move B2,X:(SP)
jsr ARTMPYF32U
pop B2
pop B1
pop B0
pop R1
pop R0
pop Y0
pop Y1
pop X0
rts
;===============================================================================
; FUNCTION: ARTDIVF32UZISR
; DESCRIPTION: ISR wrapper for ARTDIVF32UZ
; INPUT: none
; OUTPUT: none
;
ARTDIVF32UZISR:
;
; The result is in A so do not save/restore A
; b,x0,r0,y0,y1
lea (SP)+
move X0,X:(SP)+
move Y1,X:(SP)+
move Y0,X:(SP)+
move R0,X:(SP)+
move B0,X:(SP)+
move B1,X:(SP)+
move B2,X:(SP)
jsr ARTDIVF32UZ
pop B2
pop B1
pop B0
pop R0
pop Y0
pop Y1
pop X0
rts
endsec
end
|
//==-------------- math.hpp - DPC++ Explicit SIMD API --------------------==//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// Implement Explicit SIMD math APIs.
//===----------------------------------------------------------------------===//
#pragma once
#include <sycl/ext/intel/experimental/esimd/common.hpp>
#include <sycl/ext/intel/experimental/esimd/detail/host_util.hpp>
#include <sycl/ext/intel/experimental/esimd/detail/math_intrin.hpp>
#include <sycl/ext/intel/experimental/esimd/detail/types.hpp>
#include <sycl/ext/intel/experimental/esimd/detail/util.hpp>
#include <sycl/ext/intel/experimental/esimd/simd.hpp>
#include <cstdint>
__SYCL_INLINE_NAMESPACE(cl) {
namespace sycl {
namespace ext {
namespace intel {
namespace experimental {
namespace esimd {
template <typename T0, typename T1, int SZ>
ESIMD_NODEBUG ESIMD_INLINE simd<T0, SZ> esimd_sat(simd<T1, SZ> src) {
if constexpr (std::is_floating_point<T0>::value)
return __esimd_satf<T0, T1, SZ>(src.data());
else if constexpr (std::is_floating_point<T1>::value) {
if constexpr (std::is_unsigned<T0>::value)
return __esimd_fptoui_sat<T0, T1, SZ>(src.data());
else
return __esimd_fptosi_sat<T0, T1, SZ>(src.data());
} else if constexpr (std::is_unsigned<T0>::value) {
if constexpr (std::is_unsigned<T1>::value)
return __esimd_uutrunc_sat<T0, T1, SZ>(src.data());
else
return __esimd_ustrunc_sat<T0, T1, SZ>(src.data());
} else {
if constexpr (std::is_signed<T1>::value)
return __esimd_sutrunc_sat<T0, T1, SZ>(src.data());
else
return __esimd_sstrunc_sat<T0, T1, SZ>(src.data());
}
}
// esimd_abs
namespace detail {
template <typename T0, typename T1, int SZ>
ESIMD_NODEBUG ESIMD_INLINE simd<T0, SZ>
__esimd_abs_common_internal(simd<T1, SZ> src0, int flag = saturation_off) {
simd<T1, SZ> Result = __esimd_abs<T1, SZ>(src0.data());
if (flag != saturation_on)
return Result;
return esimd_sat<T0>(Result);
}
template <typename T0, typename T1>
ESIMD_NODEBUG ESIMD_INLINE typename sycl::detail::enable_if_t<
detail::is_esimd_scalar<T0>::value && detail::is_esimd_scalar<T1>::value,
typename sycl::detail::remove_const_t<T0>>
__esimd_abs_common_internal(T1 src0, int flag = saturation_off) {
typedef typename sycl::detail::remove_const_t<T0> TT0;
typedef typename sycl::detail::remove_const_t<T1> TT1;
simd<TT1, 1> Src0 = src0;
simd<TT0, 1> Result = __esimd_abs_common_internal<TT0>(Src0, flag);
return Result[0];
}
} // namespace detail
template <typename T0, typename T1, int SZ>
ESIMD_NODEBUG ESIMD_INLINE typename sycl::detail::enable_if_t<
!std::is_same<typename sycl::detail::remove_const_t<T0>,
typename sycl::detail::remove_const_t<T1>>::value,
simd<T0, SZ>>
esimd_abs(simd<T1, SZ> src0, int flag = saturation_off) {
return detail::__esimd_abs_common_internal<T0, T1, SZ>(src0, flag);
}
template <typename T0, typename T1>
ESIMD_NODEBUG ESIMD_INLINE typename sycl::detail::enable_if_t<
!std::is_same<typename sycl::detail::remove_const_t<T0>,
typename sycl::detail::remove_const_t<T1>>::value &&
detail::is_esimd_scalar<T0>::value &&
detail::is_esimd_scalar<T1>::value,
typename sycl::detail::remove_const_t<T0>>
esimd_abs(T1 src0, int flag = saturation_off) {
return detail::__esimd_abs_common_internal<T0, T1>(src0, flag);
}
template <typename T1, int SZ>
ESIMD_NODEBUG ESIMD_INLINE simd<T1, SZ> esimd_abs(simd<T1, SZ> src0,
int flag = saturation_off) {
return detail::__esimd_abs_common_internal<T1, T1, SZ>(src0, flag);
}
template <typename T1>
ESIMD_NODEBUG ESIMD_INLINE typename sycl::detail::enable_if_t<
detail::is_esimd_scalar<T1>::value,
typename sycl::detail::remove_const_t<T1>>
esimd_abs(T1 src0, int flag = saturation_off) {
return detail::__esimd_abs_common_internal<T1, T1>(src0, flag);
}
// esimd_shl
template <typename T0, typename T1, int SZ, typename U>
ESIMD_NODEBUG ESIMD_INLINE
typename sycl::detail::enable_if_t<std::is_integral<T0>::value &&
std::is_integral<T1>::value &&
std::is_integral<U>::value,
simd<T0, SZ>>
esimd_shl(simd<T1, SZ> src0, U src1, int flag = saturation_off) {
typedef
typename detail::computation_type<decltype(src0), U>::type ComputationTy;
typename detail::simd_type<ComputationTy>::type Src0 = src0;
typename detail::simd_type<ComputationTy>::type Src1 = src1;
if (flag != saturation_on) {
if constexpr (std::is_unsigned<T0>::value) {
if constexpr (std::is_unsigned<T1>::value)
return __esimd_uushl_sat<T0, T1, SZ>(Src0.data(), Src1.data());
else
return __esimd_usshl_sat<T0, T1, SZ>(Src0.data(), Src1.data());
} else {
if constexpr (std::is_signed<T1>::value)
return __esimd_sushl_sat<T0, T1, SZ>(Src0.data(), Src1.data());
else
return __esimd_ssshl_sat<T0, T1, SZ>(Src0.data(), Src1.data());
}
} else {
if constexpr (std::is_unsigned<T0>::value) {
if constexpr (std::is_unsigned<T1>::value)
return __esimd_uushl<T0, T1, SZ>(Src0.data(), Src1.data());
else
return __esimd_usshl<T0, T1, SZ>(Src0.data(), Src1.data());
} else {
if constexpr (std::is_signed<T1>::value)
return __esimd_sushl<T0, T1, SZ>(Src0.data(), Src1.data());
else
return __esimd_ssshl<T0, T1, SZ>(Src0.data(), Src1.data());
}
}
}
template <typename T0, typename T1, typename T2>
ESIMD_NODEBUG ESIMD_INLINE typename sycl::detail::enable_if_t<
detail::is_esimd_scalar<T0>::value && detail::is_esimd_scalar<T1>::value &&
detail::is_esimd_scalar<T2>::value && std::is_integral<T0>::value &&
std::is_integral<T1>::value && std::is_integral<T2>::value,
typename sycl::detail::remove_const_t<T0>>
esimd_shl(T1 src0, T2 src1, int flag = saturation_off) {
typedef typename detail::computation_type<T1, T2>::type ComputationTy;
typename detail::simd_type<ComputationTy>::type Src0 = src0;
typename detail::simd_type<ComputationTy>::type Src1 = src1;
simd<T0, 1> Result = esimd_shl<T0>(Src0, Src1, flag);
return Result[0];
}
// esimd_shr
template <typename T0, typename T1, int SZ, typename U>
ESIMD_NODEBUG ESIMD_INLINE
typename sycl::detail::enable_if_t<std::is_integral<T0>::value &&
std::is_integral<T1>::value &&
std::is_integral<U>::value,
simd<T0, SZ>>
esimd_shr(simd<T1, SZ> src0, U src1, int flag = saturation_off) {
typedef
typename detail::computation_type<decltype(src0), U>::type ComputationTy;
typename detail::simd_type<ComputationTy>::type Src0 = src0;
typename detail::simd_type<ComputationTy>::type Src1 = src1;
typename detail::simd_type<ComputationTy>::type Result =
Src0.data() >> Src1.data();
if (flag != saturation_on)
return Result;
return esimd_sat<T0>(Result);
}
template <typename T0, typename T1, typename T2>
ESIMD_NODEBUG ESIMD_INLINE typename sycl::detail::enable_if_t<
detail::is_esimd_scalar<T0>::value && detail::is_esimd_scalar<T1>::value &&
detail::is_esimd_scalar<T2>::value && std::is_integral<T0>::value &&
std::is_integral<T1>::value && std::is_integral<T2>::value,
typename sycl::detail::remove_const_t<T0>>
esimd_shr(T1 src0, T2 src1, int flag = saturation_off) {
typedef typename detail::computation_type<T1, T2>::type ComputationTy;
typename detail::simd_type<ComputationTy>::type Src0 = src0;
typename detail::simd_type<ComputationTy>::type Src1 = src1;
simd<T0, 1> Result = esimd_shr<T0>(Src0, Src1, flag);
return Result[0];
}
// esimd_rol
template <typename T0, typename T1, int SZ>
ESIMD_NODEBUG ESIMD_INLINE typename sycl::detail::enable_if_t<
std::is_integral<T0>::value && std::is_integral<T1>::value, simd<T0, SZ>>
esimd_rol(simd<T1, SZ> src0, simd<T1, SZ> src1) {
return __esimd_rol<T0, T1, SZ>(src0, src1);
}
template <typename T0, typename T1, int SZ, typename U>
ESIMD_NODEBUG ESIMD_INLINE
typename sycl::detail::enable_if_t<std::is_integral<T0>::value &&
std::is_integral<T1>::value &&
std::is_integral<U>::value,
simd<T0, SZ>>
esimd_rol(simd<T1, SZ> src0, U src1) {
typedef
typename detail::computation_type<decltype(src0), U>::type ComputationTy;
typename detail::simd_type<ComputationTy>::type Src0 = src0;
typename detail::simd_type<ComputationTy>::type Src1 = src1;
return __esimd_rol<T0>(Src0.data(), Src1.data());
}
template <typename T0, typename T1, typename T2>
ESIMD_NODEBUG ESIMD_INLINE typename sycl::detail::enable_if_t<
detail::is_esimd_scalar<T0>::value && detail::is_esimd_scalar<T1>::value &&
detail::is_esimd_scalar<T2>::value && std::is_integral<T0>::value &&
std::is_integral<T1>::value && std::is_integral<T2>::value,
typename sycl::detail::remove_const_t<T0>>
esimd_rol(T1 src0, T2 src1) {
typedef typename detail::computation_type<T1, T2>::type ComputationTy;
typename detail::simd_type<ComputationTy>::type Src0 = src0;
typename detail::simd_type<ComputationTy>::type Src1 = src1;
simd<T0, 1> Result = esimd_rol<T0>(Src0, Src1);
return Result[0];
}
// esimd_ror
template <typename T0, typename T1, int SZ>
ESIMD_NODEBUG ESIMD_INLINE typename sycl::detail::enable_if_t<
std::is_integral<T0>::value && std::is_integral<T1>::value, simd<T0, SZ>>
esimd_ror(simd<T1, SZ> src0, simd<T1, SZ> src1) {
return __esimd_ror<T0, T1, SZ>(src0, src1);
}
template <typename T0, typename T1, int SZ, typename U>
ESIMD_NODEBUG ESIMD_INLINE
typename sycl::detail::enable_if_t<std::is_integral<T0>::value &&
std::is_integral<T1>::value &&
std::is_integral<U>::value,
simd<T0, SZ>>
esimd_ror(simd<T1, SZ> src0, U src1) {
typedef
typename detail::computation_type<decltype(src0), U>::type ComputationTy;
typename detail::simd_type<ComputationTy>::type Src0 = src0;
typename detail::simd_type<ComputationTy>::type Src1 = src1;
return __esimd_ror<T0>(Src0.data(), Src1.data());
}
template <typename T0, typename T1, typename T2>
ESIMD_NODEBUG ESIMD_INLINE typename sycl::detail::enable_if_t<
detail::is_esimd_scalar<T0>::value && detail::is_esimd_scalar<T1>::value &&
detail::is_esimd_scalar<T2>::value && std::is_integral<T0>::value &&
std::is_integral<T1>::value && std::is_integral<T2>::value,
typename sycl::detail::remove_const_t<T0>>
esimd_ror(T1 src0, T2 src1) {
typedef typename detail::computation_type<T1, T2>::type ComputationTy;
typename detail::simd_type<ComputationTy>::type Src0 = src0;
typename detail::simd_type<ComputationTy>::type Src1 = src1;
simd<T0, 1> Result = esimd_ror<T0>(Src0, Src1);
return Result[0];
}
// esimd_lsr
template <typename T0, typename T1, int SZ, typename U>
ESIMD_NODEBUG ESIMD_INLINE
typename sycl::detail::enable_if_t<std::is_integral<T0>::value &&
std::is_integral<T1>::value &&
std::is_integral<U>::value,
simd<T0, SZ>>
esimd_lsr(simd<T1, SZ> src0, U src1, int flag = saturation_off) {
typedef typename detail::computation_type<T1, T1>::type IntermedTy;
typedef typename std::make_unsigned<IntermedTy>::type ComputationTy;
simd<ComputationTy, SZ> Src0 = src0;
simd<ComputationTy, SZ> Result = Src0.data() >> src1.data();
if (flag != saturation_on)
return Result;
return esimd_sat<T0>(Result);
}
template <typename T0, typename T1, typename T2>
ESIMD_NODEBUG ESIMD_INLINE typename sycl::detail::enable_if_t<
detail::is_esimd_scalar<T0>::value && detail::is_esimd_scalar<T1>::value &&
detail::is_esimd_scalar<T2>::value && std::is_integral<T0>::value &&
std::is_integral<T1>::value && std::is_integral<T2>::value,
typename sycl::detail::remove_const_t<T0>>
esimd_lsr(T1 src0, T2 src1, int flag = saturation_off) {
typedef typename detail::computation_type<T1, T2>::type ComputationTy;
typename detail::simd_type<ComputationTy>::type Src0 = src0;
typename detail::simd_type<ComputationTy>::type Src1 = src1;
simd<T0, 1> Result = esimd_lsr<T0>(Src0, Src1, flag);
return Result[0];
}
// esimd_asr
template <typename T0, typename T1, int SZ, typename U>
ESIMD_NODEBUG ESIMD_INLINE
typename sycl::detail::enable_if_t<std::is_integral<T0>::value &&
std::is_integral<T1>::value &&
std::is_integral<U>::value,
simd<T0, SZ>>
esimd_asr(simd<T1, SZ> src0, U src1, int flag = saturation_off) {
typedef typename detail::computation_type<T1, T1>::type IntermedTy;
typedef typename std::make_signed<IntermedTy>::type ComputationTy;
simd<ComputationTy, SZ> Src0 = src0;
simd<ComputationTy, SZ> Result = Src0 >> src1;
if (flag != saturation_on)
return Result;
return esimd_sat<T0>(Result);
}
template <typename T0, typename T1, typename T2>
ESIMD_NODEBUG ESIMD_INLINE typename sycl::detail::enable_if_t<
detail::is_esimd_scalar<T0>::value && detail::is_esimd_scalar<T1>::value &&
detail::is_esimd_scalar<T2>::value && std::is_integral<T0>::value &&
std::is_integral<T1>::value && std::is_integral<T2>::value,
typename sycl::detail::remove_const_t<T0>>
esimd_asr(T1 src0, T2 src1, int flag = saturation_off) {
typedef typename detail::computation_type<T1, T2>::type ComputationTy;
typename detail::simd_type<ComputationTy>::type Src0 = src0;
typename detail::simd_type<ComputationTy>::type Src1 = src1;
simd<T0, 1> Result = esimd_asr<T0>(Src0, Src1, flag);
return Result[0];
}
// esimd_imul
#ifndef ESIMD_HAS_LONG_LONG
// use mulh instruction for high half
template <typename T0, typename T1, typename U, int SZ>
ESIMD_NODEBUG ESIMD_INLINE
typename sycl::detail::enable_if_t<detail::is_dword_type<T0>::value &&
detail::is_dword_type<T1>::value &&
detail::is_dword_type<U>::value,
simd<T0, SZ>>
esimd_imul(simd<T0, SZ> &rmd, simd<T1, SZ> src0, U src1) {
typedef
typename detail::computation_type<decltype(src0), U>::type ComputationTy;
typename detail::simd_type<ComputationTy>::type Src0 = src0;
typename detail::simd_type<ComputationTy>::type Src1 = src1;
rmd = Src0 * Src1;
if constexpr (std::is_unsigned<T0>::value)
return __esimd_umulh(Src0.data(), Src1.data());
else
return __esimd_smulh(Src0.data(), Src1.data());
}
#else
// esimd_imul bdw+ version: use qw=dw*dw multiply.
// We need to special case SZ==1 to avoid "error: when select size is 1, the
// stride must also be 1" on the selects.
template <typename T0, typename T1, typename U, int SZ>
ESIMD_NODEBUG ESIMD_INLINE typename sycl::detail::enable_if_t<
detail::is_dword_type<T0>::value && detail::is_dword_type<T1>::value &&
detail::is_dword_type<U>::value && SZ == 1,
simd<T0, SZ>>
esimd_imul(simd<T0, SZ> &rmd, simd<T1, SZ> src0, U src1) {
typedef typename detail::computation_type<decltype(rmd), long long>::type
ComputationTy;
ComputationTy Product = convert<long long>(src0);
Product *= src1;
rmd = Product.bit_cast_view<T0>().select<1, 1>[0];
return Product.bit_cast_view<T0>().select<1, 1>[1];
}
template <typename T0, typename T1, typename U, int SZ>
ESIMD_NODEBUG ESIMD_INLINE typename sycl::detail::enable_if_t<
detail::is_dword_type<T0>::value && detail::is_dword_type<T1>::value &&
detail::is_dword_type<U>::value && SZ != 1,
simd<T0, SZ>>
esimd_imul(simd<T0, SZ> &rmd, simd<T1, SZ> src0, U src1) {
typedef typename detail::computation_type<decltype(rmd), long long>::type
ComputationTy;
ComputationTy Product = convert<long long>(src0);
Product *= src1;
rmd = Product.bit_cast_view<T0>().select<SZ, 2>(0);
return Product.bit_cast_view<T0>().select<SZ, 2>(1);
}
#endif
// esimd_imul wrappers
template <typename T0, typename T1, typename U, int SZ>
ESIMD_NODEBUG ESIMD_INLINE
typename sycl::detail::enable_if_t<detail::is_esimd_scalar<U>::value,
simd<T0, SZ>>
esimd_imul(simd<T0, SZ> &rmd, U src0, simd<T1, SZ> src1) {
return esimd_imul(rmd, src1, src0);
}
template <typename T0, typename T, typename U>
ESIMD_NODEBUG ESIMD_INLINE
typename sycl::detail::enable_if_t<detail::is_esimd_scalar<T>::value &&
detail::is_esimd_scalar<U>::value &&
detail::is_esimd_scalar<T0>::value,
T0>
esimd_imul(simd<T0, 1> &rmd, T src0, U src1) {
simd<T, 1> src_0 = src0;
simd<U, 1> src_1 = src1;
simd<T0, 1> res = esimd_imul(rmd, src_0.select_all(), src_1.select_all());
return res[0];
}
// esimd_quot
template <typename T, int SZ, typename U>
ESIMD_NODEBUG ESIMD_INLINE typename sycl::detail::enable_if_t<
std::is_integral<T>::value && std::is_integral<U>::value, simd<T, SZ>>
esimd_quot(simd<T, SZ> src0, U src1) {
return src0 / src1;
}
template <typename T0, typename T1>
ESIMD_NODEBUG ESIMD_INLINE typename sycl::detail::enable_if_t<
detail::is_esimd_scalar<T0>::value && detail::is_esimd_scalar<T1>::value &&
std::is_integral<T0>::value && std::is_integral<T1>::value,
typename sycl::detail::remove_const_t<T0>>
esimd_quot(T0 src0, T1 src1) {
return src0 / src1;
}
// esimd_mod
template <typename T, int SZ, typename U>
ESIMD_NODEBUG ESIMD_INLINE typename sycl::detail::enable_if_t<
std::is_integral<T>::value && std::is_integral<U>::value, simd<T, SZ>>
esimd_mod(simd<T, SZ> src0, U src1) {
return src0 % src1;
}
template <typename T0, typename T1>
ESIMD_NODEBUG ESIMD_INLINE typename sycl::detail::enable_if_t<
detail::is_esimd_scalar<T0>::value && detail::is_esimd_scalar<T1>::value &&
std::is_integral<T0>::value && std::is_integral<T1>::value,
typename sycl::detail::remove_const_t<T0>>
esimd_mod(T0 src0, T1 src1) {
return src0 % src1;
}
// esimd_div, compute quotient and remainder of division.
template <typename T, int SZ, typename U>
ESIMD_NODEBUG ESIMD_INLINE typename sycl::detail::enable_if_t<
std::is_integral<T>::value && std::is_integral<U>::value, simd<T, SZ>>
esimd_div(simd<T, SZ> &remainder, simd<T, SZ> src0, U src1) {
remainder = src0 % src1;
return src0 / src1;
}
template <typename T, int SZ, typename U>
ESIMD_NODEBUG ESIMD_INLINE
typename sycl::detail::enable_if_t<std::is_integral<T>::value &&
std::is_integral<U>::value &&
detail::is_esimd_scalar<U>::value,
simd<T, SZ>>
esimd_div(simd<T, SZ> &remainder, U src0, simd<T, SZ> src1) {
remainder = src0 % src1;
return src0 / src1;
}
template <typename RT, typename T0, typename T1>
ESIMD_NODEBUG ESIMD_INLINE typename sycl::detail::enable_if_t<
detail::is_esimd_scalar<RT>::value && detail::is_esimd_scalar<T0>::value &&
detail::is_esimd_scalar<T1>::value,
typename sycl::detail::remove_const_t<RT>>
esimd_div(simd<typename std::remove_const<RT>, 1> &remainder, T0 src0,
T1 src1) {
remainder[0] = src0 % src1;
return src0 / src1;
}
// esimd_min and esimd_max
//
// Restriction:
//
// The source operands must be both of integer or both of floating-point type.
//
template <typename T, int SZ>
ESIMD_NODEBUG ESIMD_INLINE simd<T, SZ>
esimd_max(simd<T, SZ> src0, simd<T, SZ> src1, int flag = saturation_off) {
if constexpr (std::is_floating_point<T>::value) {
auto Result = __esimd_fmax<T, SZ>(src0.data(), src1.data());
return (flag == saturation_off) ? Result : __esimd_satf<T, T, SZ>(Result);
} else if constexpr (std::is_unsigned<T>::value) {
auto Result = __esimd_umax<T, SZ>(src0.data(), src1.data());
return (flag == saturation_off) ? Result
: __esimd_uutrunc_sat<T, T, SZ>(Result);
} else {
auto Result = __esimd_smax<T, SZ>(src0.data(), src1.data());
return (flag == saturation_off) ? Result
: __esimd_sstrunc_sat<T, T, SZ>(Result);
}
}
template <typename T, int SZ>
ESIMD_NODEBUG ESIMD_INLINE
typename sycl::detail::enable_if_t<detail::is_esimd_scalar<T>::value,
simd<T, SZ>>
esimd_max(simd<T, SZ> src0, T src1, int flag = saturation_off) {
simd<T, SZ> Src1 = src1;
simd<T, SZ> Result = esimd_max<T>(src0, Src1, flag);
return Result;
}
template <typename T, int SZ>
ESIMD_NODEBUG ESIMD_INLINE
typename sycl::detail::enable_if_t<detail::is_esimd_scalar<T>::value,
simd<T, SZ>>
esimd_max(T src0, simd<T, SZ> src1, int flag = saturation_off) {
simd<T, SZ> Src0 = src0;
simd<T, SZ> Result = esimd_max<T>(Src0, src1, flag);
return Result;
}
template <typename T>
ESIMD_NODEBUG ESIMD_INLINE
typename sycl::detail::enable_if_t<detail::is_esimd_scalar<T>::value, T>
esimd_max(T src0, T src1, int flag = saturation_off) {
simd<T, 1> Src0 = src0;
simd<T, 1> Src1 = src1;
simd<T, 1> Result = esimd_max<T>(Src0, Src1, flag);
return Result[0];
}
template <typename T, int SZ>
ESIMD_NODEBUG ESIMD_INLINE simd<T, SZ>
esimd_min(simd<T, SZ> src0, simd<T, SZ> src1, int flag = saturation_off) {
if constexpr (std::is_floating_point<T>::value) {
auto Result = __esimd_fmin<T, SZ>(src0.data(), src1.data());
return (flag == saturation_off) ? Result : __esimd_satf<T, T, SZ>(Result);
} else if constexpr (std::is_unsigned<T>::value) {
auto Result = __esimd_umin<T, SZ>(src0.data(), src1.data());
return (flag == saturation_off) ? Result
: __esimd_uutrunc_sat<T, T, SZ>(Result);
} else {
auto Result = __esimd_smin<T, SZ>(src0.data(), src1.data());
return (flag == saturation_off) ? Result
: __esimd_sstrunc_sat<T, T, SZ>(Result);
}
}
template <typename T, int SZ>
ESIMD_NODEBUG ESIMD_INLINE
typename sycl::detail::enable_if_t<detail::is_esimd_scalar<T>::value,
simd<T, SZ>>
esimd_min(simd<T, SZ> src0, T src1, int flag = saturation_off) {
simd<T, SZ> Src1 = src1;
simd<T, SZ> Result = esimd_min<T>(src0, Src1, flag);
return Result;
}
template <typename T, int SZ>
ESIMD_NODEBUG ESIMD_INLINE
typename sycl::detail::enable_if_t<detail::is_esimd_scalar<T>::value,
simd<T, SZ>>
esimd_min(T src0, simd<T, SZ> src1, int flag = saturation_off) {
simd<T, SZ> Src0 = src0;
simd<T, SZ> Result = esimd_min<T>(Src0, src1, flag);
return Result;
}
template <typename T>
ESIMD_NODEBUG ESIMD_INLINE
typename sycl::detail::enable_if_t<detail::is_esimd_scalar<T>::value, T>
esimd_min(T src0, T src1, int flag = saturation_off) {
simd<T, 1> Src0 = src0;
simd<T, 1> Src1 = src1;
simd<T, 1> Result = esimd_min<T>(Src0, Src1, flag);
return Result[0];
}
// Dot product builtins
#if defined(ESIMD_GEN7_5) || defined(ESIMD_GEN8) || defined(ESIMD_GEN8_5) || \
defined(ESIMD_GEN9) || defined(ESIMD_GEN9_5)
template <typename T0, typename T1, int SZ, typename U>
ESIMD_NODEBUG ESIMD_INLINE simd<T0, SZ> esimd_dp2(simd<T1, SZ> src0, U src1,
int flag = saturation_off) {
static_assert(SZ % 4 == 0, "result size is not a multiple of 4");
simd<float, SZ> Src0 = src0;
simd<float, SZ> Src1 = src1;
simd<float, SZ> Result = __esimd_dp2(Src0.data(), Src1.data());
if (flag != saturation_on)
return Result;
return esimd_sat<T0>(Result);
}
template <typename T0, typename T1, int SZ, typename U>
ESIMD_NODEBUG ESIMD_INLINE simd<T0, SZ> esimd_dp3(simd<T1, SZ> src0, U src1,
int flag = saturation_off) {
static_assert(SZ % 4 == 0, "result size is not a multiple of 4");
simd<float, SZ> Src0 = src0;
simd<float, SZ> Src1 = src1;
simd<float, SZ> Result = __esimd_dp3(Src0.data(), Src1.data());
if (flag != saturation_on)
return Result;
return esimd_sat<T0>(Result);
}
template <typename T0, typename T1, int SZ, typename U>
ESIMD_NODEBUG ESIMD_INLINE simd<T0, SZ> esimd_dp4(simd<T1, SZ> src0, U src1,
int flag = saturation_off) {
static_assert(SZ % 4 == 0, "result size is not a multiple of 4");
simd<float, SZ> Src0 = src0;
simd<float, SZ> Src1 = src1;
simd<float, SZ> Result = __esimd_dp4(Src0.data(), Src1.data());
if (flag != saturation_on)
return Result;
return esimd_sat<T0>(Result);
}
template <typename T0, typename T1, typename U, int SZ>
ESIMD_NODEBUG ESIMD_INLINE simd<T0, SZ> esimd_dph(simd<T1, SZ> src0, U src1,
int flag = saturation_off) {
static_assert(SZ % 4 == 0, "result size is not a multiple of 4");
simd<float, SZ> Src0 = src0;
simd<float, SZ> Src1 = src1;
simd<float, SZ> Result = __esimd_dph(Src0.data(), Src1.data());
if (flag != saturation_on)
return Result;
return esimd_sat<T0>(Result);
}
template <typename RT, typename T1, typename T2, int SZ>
ESIMD_NODEBUG ESIMD_INLINE simd<RT, SZ>
esimd_line(simd<T1, 4> src0, simd<T2, SZ> src1, int flag = saturation_off) {
static_assert(SZ % 4 == 0, "result size is not a multiple of 4");
simd<float, 4> Src0 = src0;
simd<float, SZ> Src1 = src1;
simd<float, SZ> Result = __esimd_line(Src0.data(), Src1.data());
simd<RT, SZ> Result;
if (flag == saturation_on)
Result = esimd_sat<RT>(Result);
else
Result = Result;
return Result;
}
template <typename RT, typename T, int SZ>
ESIMD_NODEBUG ESIMD_INLINE simd<RT, SZ>
esimd_line(float P, float Q, simd<T, SZ> src1, int flag = saturation_off) {
simd<float, 4> Src0 = P;
Src0(3) = Q;
return esimd_line<RT>(Src0, src1, flag);
}
#else
// The old implementation is to generate vISA IRs for dp2/dp3/dp4/dph/line.
// Now We change to use direct mul/add, and hope to generate mad instructions
// at the end, to still get the performance as good as HW solution.
// We rely on "pragma unroll" to get better code.
// The only input and return types for these APIs are floats.
// In order to be able to use the old emu code, we keep the template argument
// for the type, although the type "T" can only be float.
// We use enable_if to force the float type only.
// If the gen is not specified we warn the programmer that they are potentially
// using a less efficient implementation if not on GEN10 or above.
template <typename T0, typename T1, int SZ, typename U>
ESIMD_NODEBUG ESIMD_INLINE typename sycl::detail::enable_if_t<
detail::is_fp_or_dword_type<T1>::value &&
std::is_floating_point<T1>::value &&
detail::is_fp_or_dword_type<U>::value &&
std::is_floating_point<U>::value,
simd<T0, SZ>>
esimd_dp2(simd<T1, SZ> src0, U src1, int flag = saturation_off) {
static_assert(SZ % 4 == 0, "result size is not a multiple of 4");
simd<float, SZ> Src1 = src1;
simd<float, SZ> Result;
#pragma unroll
for (int i = 0; i < SZ; i += 4) {
Result.select<4, 1>(i) = src0[i] * Src1[i] + src0[i + 1] * Src1[i + 1];
}
if (flag != saturation_on)
return Result;
return esimd_sat<T1>(Result);
}
template <typename T0, typename T1, int SZ, typename U>
ESIMD_NODEBUG ESIMD_INLINE typename sycl::detail::enable_if_t<
detail::is_fp_or_dword_type<T1>::value &&
std::is_floating_point<T1>::value &&
detail::is_fp_or_dword_type<U>::value &&
std::is_floating_point<U>::value,
simd<T0, SZ>>
esimd_dp3(simd<T1, SZ> src0, U src1, int flag = saturation_off) {
static_assert(SZ % 4 == 0, "result size is not a multiple of 4");
simd<float, SZ> Src1 = src1;
simd<float, SZ> Result;
#pragma unroll
for (int i = 0; i < SZ; i += 4) {
Result.select<4, 1>(i) = src0[i] * Src1[i] + src0[i + 1] * Src1[i + 1] +
src0[i + 2] * Src1[i + 2];
}
if (flag != saturation_on)
return Result;
return esimd_sat<T1>(Result);
}
template <typename T0, typename T1, int SZ, typename U>
ESIMD_NODEBUG ESIMD_INLINE typename sycl::detail::enable_if_t<
detail::is_fp_or_dword_type<T1>::value &&
std::is_floating_point<T1>::value &&
detail::is_fp_or_dword_type<U>::value &&
std::is_floating_point<U>::value,
simd<T0, SZ>>
esimd_dp4(simd<T1, SZ> src0, U src1, int flag = saturation_off) {
static_assert(SZ % 4 == 0, "result size is not a multiple of 4");
simd<T1, SZ> Src1 = src1;
simd<float, SZ> Result;
#pragma unroll
for (int i = 0; i < SZ; i += 4) {
Result.select<4, 1>(i) = src0[i] * Src1[i] + src0[i + 1] * Src1[i + 1] +
src0[i + 2] * Src1[i + 2] +
src0[i + 3] * Src1[i + 3];
}
if (flag != saturation_on)
return Result;
return esimd_sat<T1>(Result);
}
template <typename T, typename U, int SZ>
ESIMD_NODEBUG ESIMD_INLINE typename sycl::detail::enable_if_t<
detail::is_fp_or_dword_type<T>::value && std::is_floating_point<T>::value &&
detail::is_fp_or_dword_type<U>::value &&
std::is_floating_point<U>::value,
simd<T, SZ>>
esimd_dph(simd<T, SZ> src0, U src1, int flag = saturation_off) {
static_assert(SZ % 4 == 0, "result size is not a multiple of 4");
simd<float, SZ> Src1 = src1;
simd<float, SZ> Result;
#pragma unroll
for (int i = 0; i < SZ; i += 4) {
Result.select<4, 1>(i) = src0[i] * Src1[i] + src0[i + 1] * Src1[i + 1] +
src0[i + 2] * Src1[i + 2] + 1.0 * Src1[i + 3];
}
if (flag != saturation_on)
return Result;
return esimd_sat<T>(Result);
}
template <typename T, int SZ>
ESIMD_NODEBUG ESIMD_INLINE
typename sycl::detail::enable_if_t<detail::is_fp_or_dword_type<T>::value &&
std::is_floating_point<T>::value,
simd<T, SZ>>
esimd_line(simd<T, 4> src0, simd<T, SZ> src1, int flag = saturation_off) {
static_assert(SZ % 4 == 0, "result size is not a multiple of 4");
simd<T, SZ> Src1 = src1;
simd<T, SZ> Result;
#pragma unroll
for (int i = 0; i < SZ; i += 4) {
Result.select<4, 1>(i) = src0[0] * src1[i] + src0[3];
}
if (flag == saturation_on)
Result = esimd_sat<T>(Result);
return Result;
}
template <typename T, int SZ>
ESIMD_NODEBUG ESIMD_INLINE
typename sycl::detail::enable_if_t<detail::is_fp_or_dword_type<T>::value &&
std::is_floating_point<T>::value,
simd<T, SZ>>
esimd_line(float P, float Q, simd<T, SZ> src1, int flag = saturation_off) {
simd<T, 4> Src0 = P;
Src0(3) = Q;
return esimd_line<T>(Src0, src1, flag);
}
#endif
template <typename T, int SZ>
ESIMD_NODEBUG ESIMD_INLINE simd<T, SZ> esimd_frc(simd<T, SZ> src0) {
simd<float, SZ> Src0 = src0;
return __esimd_frc(Src0);
}
template <typename T> ESIMD_NODEBUG ESIMD_INLINE T esimd_frc(T src0) {
simd<T, 1> Src0 = src0;
simd<T, 1> Result = esimd_frc<T>(Src0);
return Result[0];
}
// esimd_lzd
template <typename RT, typename T0, int SZ>
ESIMD_NODEBUG ESIMD_INLINE simd<RT, SZ> esimd_lzd(simd<T0, SZ> src0,
int flag = saturation_off) {
// Saturation parameter ignored
simd<uint, SZ> Src0 = src0;
return __esimd_lzd<uint>(Src0);
}
template <typename RT, typename T0>
ESIMD_NODEBUG ESIMD_INLINE typename sycl::detail::enable_if_t<
detail::is_esimd_scalar<RT>::value && detail::is_esimd_scalar<T0>::value,
typename sycl::detail::remove_const_t<RT>>
esimd_lzd(T0 src0, int flag = saturation_off) {
simd<T0, 1> Src0 = src0;
simd<RT, 1> Result = esimd_lzd<RT>(Src0);
return Result[0];
}
// esimd_lrp
#if defined(ESIMD_GEN7_5) || defined(ESIMD_GEN8) || defined(ESIMD_GEN8_5) || \
defined(ESIMD_GEN9) || defined(ESIMD_GEN9_5)
template <int SZ, typename U, typename V>
ESIMD_NODEBUG ESIMD_INLINE simd<float, SZ>
esimd_lrp(simd<float, SZ> src0, U src1, V src2, int flag = saturation_off) {
static_assert(SZ >= 4 && (SZ & 0x3) == 0,
"vector size must be a multiple of 4");
simd<float, SZ> Src1 = src1;
simd<float, SZ> Src2 = src2;
simd<float, SZ> Result = __esimd_lrp<SZ>(src0, Src1, Src2);
if (flag != saturation_on)
return Result;
return esimd_sat<float>(Result);
}
#else
// The old implementation is to generate vISA IRs for lrp.
// Now We change to use direct mul/add, and hope to generate mad instructions
// at the end, to still get the performance as good as HW solution.
// The only input and return types for these APIs are floats.
// In order to be able to use the old emu code, we keep the template argument
// for the type, although the type "T" can only be float.
// We use enable_if to force the float type only.
// If the gen is not specified we warn the programmer that they are potentially
// using less efficient implementation.
template <typename T, int SZ, typename U, typename V>
ESIMD_NODEBUG ESIMD_INLINE typename sycl::detail::enable_if_t<
detail::is_fp_or_dword_type<T>::value && std::is_floating_point<T>::value &&
detail::is_fp_or_dword_type<U>::value &&
std::is_floating_point<U>::value,
simd<T, SZ>>
esimd_lrp(simd<T, SZ> src0, U src1, V src2, int flag = saturation_off) {
simd<float, SZ> Src1 = src1;
simd<float, SZ> Src2 = src2;
simd<float, SZ> Result;
Result = Src1 * src0 + Src2 * (1.0f - src0);
if (flag != saturation_on)
return Result;
return esimd_sat<T>(Result);
}
#endif
// esimd_pln
template <int SZ>
ESIMD_NODEBUG ESIMD_INLINE simd<float, SZ>
esimd_pln(simd<float, 4> src0, simd<float, SZ> src1, simd<float, SZ> src2,
int flag = saturation_off) {
static_assert(SZ >= 8 && (SZ & 0x7) == 0,
"vector size must be a multiple of 8");
// __esimd_intrinsic_impl_pln() requires src1 and src2 to be combined into
// a single matrix, interleaving the values together in blocks of 8
// items (ie, a block of 8 from src1, then a block of 8 from src2, then
// the next block of 8 from src1, then the next block of 8 from src2,
// and so-on.)
simd<float, (SZ >> 3) * 16> Src12v;
auto Src12 = Src12v.template bit_cast_view<float, (SZ >> 3), 16>();
Src12.select<(SZ >> 3), 1, 8, 1>(0, 0) =
src1.template bit_cast_view<float, (SZ >> 3), 8>();
Src12.select<(SZ >> 3), 1, 8, 1>(0, 8) =
src2.template bit_cast_view<float, (SZ >> 3), 8>();
simd<float, SZ> Result = __esimd_pln<SZ>(src0, Src12.read());
if (flag != saturation_on)
return Result;
return esimd_sat<float>(Result);
}
// esimd_bf_reverse
template <typename T0, typename T1, int SZ>
ESIMD_NODEBUG ESIMD_INLINE simd<T0, SZ> esimd_bf_reverse(simd<T1, SZ> src0) {
simd<unsigned, SZ> Src0 = src0;
return __esimd_bfrev<unsigned>(Src0);
}
template <typename T0, typename T1>
ESIMD_NODEBUG ESIMD_INLINE typename sycl::detail::enable_if_t<
detail::is_esimd_scalar<T0>::value && detail::is_esimd_scalar<T1>::value,
typename sycl::detail::remove_const_t<T0>>
esimd_bf_reverse(T1 src0) {
simd<T1, 1> Src0 = src0;
simd<T0, 1> Result = esimd_bf_reverse<T0>(Src0);
return Result[0];
}
// esimd_bf_insert
template <typename T0, typename T1, int SZ, typename U, typename V, typename W>
ESIMD_NODEBUG ESIMD_INLINE
typename sycl::detail::enable_if_t<std::is_integral<T1>::value,
simd<T0, SZ>>
esimd_bf_insert(U src0, V src1, W src2, simd<T1, SZ> src3) {
typedef typename detail::dword_type<T1> DT1;
static_assert(std::is_integral<DT1>::value && sizeof(DT1) == sizeof(int),
"operand conversion failed");
simd<DT1, SZ> Src0 = src0;
simd<DT1, SZ> Src1 = src1;
simd<DT1, SZ> Src2 = src2;
simd<DT1, SZ> Src3 = src3;
return __esimd_bfins<DT1>(Src0, Src1, Src2, Src3);
}
template <typename T0, typename T1, typename T2, typename T3, typename T4>
ESIMD_NODEBUG ESIMD_INLINE typename sycl::detail::enable_if_t<
detail::is_esimd_scalar<T0>::value && detail::is_esimd_scalar<T4>::value,
typename sycl::detail::remove_const_t<T0>>
esimd_bf_insert(T1 src0, T2 src1, T3 src2, T4 src3) {
simd<T4, 1> Src3 = src3;
simd<T0, 1> Result = esimd_bf_insert<T0>(src0, src1, src2, Src3);
return Result[0];
}
// esimd_bf_extract
template <typename T0, typename T1, int SZ, typename U, typename V>
ESIMD_NODEBUG ESIMD_INLINE
typename sycl::detail::enable_if_t<std::is_integral<T1>::value,
simd<T0, SZ>>
esimd_bf_extract(U src0, V src1, simd<T1, SZ> src2) {
typedef typename detail::dword_type<T1> DT1;
static_assert(std::is_integral<DT1>::value && sizeof(DT1) == sizeof(int),
"operand conversion failed");
simd<DT1, SZ> Src0 = src0;
simd<DT1, SZ> Src1 = src1;
simd<DT1, SZ> Src2 = src2;
return __esimd_bfext<DT1>(Src0, Src1, Src2);
}
template <typename T0, typename T1, typename T2, typename T3>
ESIMD_NODEBUG ESIMD_INLINE typename sycl::detail::enable_if_t<
detail::is_esimd_scalar<T0>::value && detail::is_esimd_scalar<T3>::value,
typename sycl::detail::remove_const_t<T0>>
esimd_bf_extract(T1 src0, T2 src1, T3 src2) {
simd<T3, 1> Src2 = src2;
simd<T0, 1> Result = esimd_bf_extract<T0>(src0, src1, Src2);
return Result[0];
}
////////////////////////////////////////////////////////////////////////////////
// ESIMD arithmetic intrinsics:
//
// inv, log, exp, sqrt, rsqrt, sin, cos
//
// share the same requirements.
//
// template <int SZ>
// simd<float, SZ>
// ESIMD_INLINE esimd_inv(simd<float, SZ> src0, int flag = saturation_off) {
// simd<float, SZ> Result = __esimd_inv(src0);
// if (flag != saturation_on)
// return Result;
// return __esimd_sat<float>(Result);
// }
//
// template <int N1, int N2>
// ESIMD_NODEBUG ESIMD_INLINE
// simd<float, N1 * N2>
// esimd_inv(matrix<float, N1, N2> src0, int flag = saturation_off) {
// simd<float, N1 * N2> Src0 = src0;
// return esimd_inv(Src0, flag);
// }
//
// ESIMD_INLINE float esimd_inv(float src0, int flag = saturation_off) {
// simd<float, 1> Src0 = src0;
// simd<float, 1> Result = esimd_inv(Src0, flag);
// return Result[0];
// }
//
// we also make the scalar version template-based by adding
// a "typename T". Since the type can only be float, we hack it
// by defining T=void without instantiating it to be float.
#define ESIMD_INTRINSIC_DEF(type, name) \
template <int SZ> \
ESIMD_NODEBUG ESIMD_INLINE simd<type, SZ> esimd_##name( \
simd<type, SZ> src0, int flag = saturation_off) { \
simd<type, SZ> Result = __esimd_##name<SZ>(src0.data()); \
if (flag != saturation_on) \
return Result; \
return esimd_sat<type>(Result); \
} \
template <typename T = void> \
ESIMD_NODEBUG ESIMD_INLINE type esimd_##name(type src0, \
int flag = saturation_off) { \
simd<type, 1> Src0 = src0; \
simd<type, 1> Result = esimd_##name(Src0, flag); \
return Result[0]; \
}
ESIMD_INTRINSIC_DEF(float, inv)
ESIMD_INTRINSIC_DEF(float, log)
ESIMD_INTRINSIC_DEF(float, exp)
ESIMD_INTRINSIC_DEF(float, sqrt)
ESIMD_INTRINSIC_DEF(float, sqrt_ieee)
ESIMD_INTRINSIC_DEF(float, rsqrt)
ESIMD_INTRINSIC_DEF(float, sin)
ESIMD_INTRINSIC_DEF(float, cos)
ESIMD_INTRINSIC_DEF(double, sqrt_ieee)
#undef ESIMD_INTRINSIC_DEF
#define ESIMD_INTRINSIC_DEF(ftype, name) \
template <int SZ, typename U> \
ESIMD_NODEBUG ESIMD_INLINE simd<ftype, SZ> esimd_##name( \
simd<ftype, SZ> src0, U src1, int flag = saturation_off) { \
simd<ftype, SZ> Src1 = src1; \
simd<ftype, SZ> Result = __esimd_##name<SZ>(src0.data(), Src1.data()); \
if (flag != saturation_on) \
return Result; \
\
return esimd_sat<ftype>(Result); \
} \
template <int SZ, typename U> \
ESIMD_NODEBUG ESIMD_INLINE \
typename sycl::detail::enable_if_t<detail::is_esimd_scalar<U>::value, \
simd<ftype, SZ>> \
esimd_##name(U src0, simd<ftype, SZ> src1, \
int flag = saturation_off) { \
simd<ftype, SZ> Src0 = src0; \
return esimd_##name(Src0, src1, flag); \
} \
ESIMD_NODEBUG ESIMD_INLINE ftype esimd_##name(ftype src0, ftype src1, \
int flag = saturation_off) { \
simd<ftype, 1> Src0 = src0; \
simd<ftype, 1> Src1 = src1; \
simd<ftype, 1> Result = esimd_##name(Src0, Src1, flag); \
return Result[0]; \
}
ESIMD_INTRINSIC_DEF(float, pow)
ESIMD_INTRINSIC_DEF(float, div_ieee)
ESIMD_INTRINSIC_DEF(double, div_ieee)
#undef ESIMD_INTRINSIC_DEF
// esimd_sincos
template <int SZ, typename U>
ESIMD_NODEBUG ESIMD_INLINE simd<float, SZ>
esimd_sincos(simd<float, SZ> &dstcos, U src0, int flag = saturation_off) {
dstcos = esimd_cos(src0, flag);
return esimd_sin(src0, flag);
}
// esimd_atan
#define ESIMD_HDR_CONST_PI 3.1415926535897932384626433832795
template <typename T, int SZ>
ESIMD_NODEBUG ESIMD_INLINE
typename sycl::detail::enable_if_t<std::is_floating_point<T>::value,
simd<T, SZ>>
esimd_atan(simd<T, SZ> src0, int flag = saturation_off) {
simd<T, SZ> Src0 = esimd_abs(src0);
simd<ushort, SZ> Neg = src0 < T(0.0);
simd<ushort, SZ> Gt1 = Src0 > T(1.0);
Src0.merge(esimd_inv(Src0), Gt1);
simd<T, SZ> Src0P2 = Src0 * Src0;
simd<T, SZ> Src0P4 = Src0P2 * Src0P2;
simd<T, SZ> Result = (Src0P4 * T(0.185696) +
((Src0 * T(0.787997) + T(0.63693)) * Src0P2) + Src0) /
(((((Src0 * -T(0.000121387) + T(0.00202308)) * Src0P2) +
(Src0 * -T(0.0149145)) + T(0.182569)) *
Src0P4) +
((Src0 * T(0.395889) + T(1.12158)) * Src0P2) +
(Src0 * T(0.636918)) + T(1.0));
Result.merge(Result - T(ESIMD_HDR_CONST_PI / 2.0), Gt1);
Result.merge(Result, Neg);
if (flag != saturation_on)
return Result;
return esimd_sat<T>(Result);
}
template <typename T>
ESIMD_NODEBUG ESIMD_INLINE
typename sycl::detail::enable_if_t<std::is_floating_point<T>::value, T>
esimd_atan(T src0, int flag = saturation_off) {
simd<T, 1> Src0 = src0;
simd<T, 1> Result = esimd_atan(Src0, flag);
return Result[0];
}
// esimd_acos
template <typename T, int SZ>
ESIMD_NODEBUG ESIMD_INLINE
typename sycl::detail::enable_if_t<std::is_floating_point<T>::value,
simd<T, SZ>>
esimd_acos(simd<T, SZ> src0, int flag = saturation_off) {
simd<T, SZ> Src0 = esimd_abs(src0);
simd<ushort, SZ> Neg = src0 < T(0.0);
simd<ushort, SZ> TooBig = Src0 >= T(0.999998);
// Replace oversized values to ensure no possibility of sqrt of
// a negative value later
Src0.merge(T(0.0), TooBig);
simd<T, SZ> Src01m = T(1.0) - Src0;
simd<T, SZ> Src0P2 = Src01m * Src01m;
simd<T, SZ> Src0P4 = Src0P2 * Src0P2;
simd<T, SZ> Result =
(((Src01m * T(0.015098965761299077) - T(0.005516443930088506)) * Src0P4) +
((Src01m * T(0.047654245891495528) + T(0.163910606547823220)) * Src0P2) +
Src01m * T(2.000291665285952400) - T(0.000007239283986332)) *
esimd_rsqrt(Src01m * T(2.0));
Result.merge(T(0.0), TooBig);
Result.merge(T(ESIMD_HDR_CONST_PI) - Result, Neg);
if (flag != saturation_on)
return Result;
return esimd_sat<T>(Result);
}
template <typename T>
ESIMD_NODEBUG ESIMD_INLINE
typename sycl::detail::enable_if_t<std::is_floating_point<T>::value, T>
esimd_acos(T src0, int flag = saturation_off) {
simd<T, 1> Src0 = src0;
simd<T, 1> Result = esimd_acos(Src0, flag);
return Result[0];
}
// esimd_asin
template <typename T, int SZ>
ESIMD_NODEBUG ESIMD_INLINE
typename sycl::detail::enable_if_t<std::is_floating_point<T>::value,
simd<T, SZ>>
esimd_asin(simd<T, SZ> src0, int flag = saturation_off) {
simd<ushort, SZ> Neg = src0 < T(0.0);
simd<T, SZ> Result =
T(ESIMD_HDR_CONST_PI / 2.0) - esimd_acos(esimd_abs(src0));
Result.merge(-Result, Neg);
if (flag != saturation_on)
return Result;
return esimd_sat<T>(Result);
}
template <typename T>
ESIMD_NODEBUG ESIMD_INLINE
typename sycl::detail::enable_if_t<std::is_floating_point<T>::value, T>
esimd_asin(T src0, int flag = saturation_off) {
simd<T, 1> Src0 = src0;
simd<T, 1> Result = esimd_asin(Src0, flag);
return Result[0];
}
////////////////////////////////////////////////////////////////////////////////
// Rounding intrinsics.
////////////////////////////////////////////////////////////////////////////////
#define ESIMD_INTRINSIC_DEF(name) \
template <typename T, int SZ> \
ESIMD_NODEBUG ESIMD_INLINE simd<T, SZ> esimd_##name( \
simd<float, SZ> src0, int flag = saturation_off) { \
simd<float, SZ> Result = __esimd_##name<SZ>(src0.data()); \
if (flag != saturation_on) \
return Result; \
return esimd_sat<T>(Result); \
} \
template <typename T> \
ESIMD_NODEBUG ESIMD_INLINE T esimd_##name(float src0, \
int flag = saturation_off) { \
simd<float, 1> Src0 = src0; \
simd<T, 1> Result = esimd_##name<T>(Src0, flag); \
return Result[0]; \
}
ESIMD_INTRINSIC_DEF(rndd)
ESIMD_INTRINSIC_DEF(rndu)
ESIMD_INTRINSIC_DEF(rnde)
ESIMD_INTRINSIC_DEF(rndz)
#undef ESIMD_INTRINSIC_DEF
template <int N>
ESIMD_NODEBUG ESIMD_INLINE
typename sycl::detail::enable_if_t<(N == 8 || N == 16 || N == 32), uint>
esimd_pack_mask(simd<ushort, N> src0) {
return __esimd_pack_mask<N>(src0.data());
}
template <int N>
ESIMD_NODEBUG ESIMD_INLINE
typename sycl::detail::enable_if_t<(N == 8 || N == 16 || N == 32),
simd<ushort, N>>
esimd_unpack_mask(uint src0) {
return __esimd_unpack_mask<N>(src0);
}
template <int N>
ESIMD_NODEBUG ESIMD_INLINE
typename sycl::detail::enable_if_t<(N != 8 && N != 16 && N < 32), uint>
esimd_pack_mask(simd<ushort, N> src0) {
simd<ushort, (N < 8 ? 8 : N < 16 ? 16 : 32)> src_0 = 0;
src_0.template select<N, 1>() = src0.template bit_cast_view<ushort>();
return esimd_pack_mask(src_0);
}
/// Count number of bits set in the source operand per element.
/// @param src0 the source operand to count bits in.
/// @return a vector of \c uint32_t, where each element is set to bit count of
/// the corresponding element of the source operand.
template <typename T, int N>
ESIMD_NODEBUG ESIMD_INLINE typename sycl::detail::enable_if_t<
std::is_integral<T>::value && sizeof(T) <= 4, simd<uint32_t, N>>
esimd_cbit(simd<T, N> src) {
return __esimd_cbit<T, N>(src.data());
}
/// Scalar version of \c esimd_cbit - both input and output are scalars rather
/// than vectors.
template <typename T>
ESIMD_NODEBUG ESIMD_INLINE typename sycl::detail::enable_if_t<
std::is_integral<T>::value && sizeof(T) <= 4, uint32_t>
esimd_cbit(T src) {
simd<T, 1> Src = src;
simd<uint32_t, 1> Result = esimd_cbit(Src);
return Result[0];
}
/// Scalar version of \c esimd_cbit, that takes simd_view object as an
/// argument, e.g. `esimd_cbit(v[0])`.
/// @param src0 input simd_view object of size 1.
/// @return scalar number of bits set.
template <typename BaseTy, typename RegionTy>
ESIMD_NODEBUG ESIMD_INLINE typename sycl::detail::enable_if_t<
std::is_integral<
typename simd_view<BaseTy, RegionTy>::element_type>::value &&
(sizeof(typename simd_view<BaseTy, RegionTy>::element_type) <= 4) &&
(simd_view<BaseTy, RegionTy>::length == 1),
uint32_t>
esimd_cbit(simd_view<BaseTy, RegionTy> src) {
using Ty = typename simd_view<BaseTy, RegionTy>::element_type;
simd<Ty, 1> Src = src;
simd<uint32_t, 1> Result = esimd_cbit(Src);
return Result[0];
}
/// Find the per element number of the first bit set in the source operand
/// starting from the least significant bit.
/// @param src0 the source operand to count bits in.
/// @return a vector of the same type as the source operand, where each element
/// is set to the number first bit set in corresponding element of the
/// source operand. \c 0xFFFFffff is returned for an element equal to \c 0.
/// Find component-wise the first bit from LSB side
template <typename T, int N>
ESIMD_NODEBUG ESIMD_INLINE typename sycl::detail::enable_if_t<
std::is_integral<T>::value && (sizeof(T) == 4), simd<T, N>>
esimd_fbl(simd<T, N> src) {
return __esimd_fbl<T, N>(src.data());
}
/// Scalar version of \c esimd_fbl - both input and output are scalars rather
/// than vectors.
template <typename T>
ESIMD_NODEBUG ESIMD_INLINE typename sycl::detail::enable_if_t<
std::is_integral<T>::value && (sizeof(T) == 4), T>
esimd_fbl(T src) {
simd<T, 1> Src = src;
simd<T, 1> Result = esimd_fbl(Src);
return Result[0];
}
/// Scalar version of \c esimd_fbl, that takes simd_view object as an
/// argument, e.g. `esimd_fbl(v[0])`.
/// @param src0 input simd_view object of size 1.
/// @return scalar number of the first bit set starting from the least
/// significant bit.
template <typename BaseTy, typename RegionTy>
ESIMD_NODEBUG ESIMD_INLINE typename sycl::detail::enable_if_t<
std::is_integral<
typename simd_view<BaseTy, RegionTy>::element_type>::value &&
(sizeof(typename simd_view<BaseTy, RegionTy>::element_type) == 4) &&
(simd_view<BaseTy, RegionTy>::length == 1),
typename simd_view<BaseTy, RegionTy>::element_type>
esimd_fbl(simd_view<BaseTy, RegionTy> src) {
using Ty = typename simd_view<BaseTy, RegionTy>::element_type;
simd<Ty, 1> Src = src;
simd<Ty, 1> Result = esimd_fbl(Src);
return Result[0];
}
/// Find the per element number of the first bit set in the source operand
/// starting from the most significant bit (sign bit is skipped).
/// @param src0 the source operand to count bits in.
/// @return a vector of the same type as the source operand, where each element
/// is set to the number first bit set in corresponding element of the
/// source operand. \c 0xFFFFffff is returned for an element equal to \c 0
/// or \c -1.
template <typename T, int N>
ESIMD_NODEBUG ESIMD_INLINE typename sycl::detail::enable_if_t<
std::is_integral<T>::value && std::is_signed<T>::value && (sizeof(T) == 4),
simd<T, N>>
esimd_fbh(simd<T, N> src) {
return __esimd_sfbh<T, N>(src.data());
}
/// Find the per element number of the first bit set in the source operand
/// starting from the most significant bit (sign bit is counted).
/// @param src0 the source operand to count bits in.
/// @return a vector of the same type as the source operand, where each element
/// is set to the number first bit set in corresponding element of the
/// source operand. \c 0xFFFFffff is returned for an element equal to \c 0.
template <typename T, int N>
ESIMD_NODEBUG ESIMD_INLINE typename sycl::detail::enable_if_t<
std::is_integral<T>::value && !std::is_signed<T>::value && (sizeof(T) == 4),
simd<T, N>>
esimd_fbh(simd<T, N> src) {
return __esimd_ufbh<T, N>(src.data());
}
/// Scalar version of \c esimd_fbh - both input and output are scalars rather
/// than vectors.
template <typename T>
ESIMD_NODEBUG ESIMD_INLINE typename sycl::detail::enable_if_t<
std::is_integral<T>::value && (sizeof(T) == 4), T>
esimd_fbh(T src) {
simd<T, 1> Src = src;
simd<T, 1> Result = esimd_fbh(Src);
return Result[0];
}
/// Scalar version of \c esimd_fbh, that takes simd_view object as an
/// argument, e.g. `esimd_fbh(v[0])`.
/// @param src0 input simd_view object of size 1.
/// @return scalar number of the first bit set starting from the most
/// significant bit.
template <typename BaseTy, typename RegionTy>
ESIMD_NODEBUG ESIMD_INLINE typename sycl::detail::enable_if_t<
std::is_integral<
typename simd_view<BaseTy, RegionTy>::element_type>::value &&
(sizeof(typename simd_view<BaseTy, RegionTy>::element_type) == 4) &&
(simd_view<BaseTy, RegionTy>::length == 1),
typename simd_view<BaseTy, RegionTy>::element_type>
esimd_fbh(simd_view<BaseTy, RegionTy> src) {
using Ty = typename simd_view<BaseTy, RegionTy>::element_type;
simd<Ty, 1> Src = src;
simd<Ty, 1> Result = esimd_fbh(Src);
return Result[0];
}
/// \brief DP4A.
///
/// @param src0 the first source operand of dp4a operation.
///
/// @param src1 the second source operand of dp4a operation.
///
/// @param src2 the third source operand of dp4a operation.
///
/// @param flag saturation flag, which has default value of saturation_off.
///
/// Returns simd vector of the dp4a operation result.
///
template <typename T1, typename T2, typename T3, typename T4, int N>
ESIMD_NODEBUG ESIMD_INLINE typename sycl::detail::enable_if_t<
detail::is_dword_type<T1>::value && detail::is_dword_type<T2>::value &&
detail::is_dword_type<T3>::value && detail::is_dword_type<T4>::value,
simd<T1, N>>
esimd_dp4a(simd<T2, N> src0, simd<T3, N> src1, simd<T4, N> src2,
int flag = saturation_off) {
simd<T2, N> Src0 = src0;
simd<T3, N> Src1 = src1;
simd<T4, N> Src2 = src2;
simd<T1, N> Result;
#if defined(__SYCL_DEVICE_ONLY__)
if (flag == saturation_off) {
if constexpr (std::is_unsigned<T1>::value) {
if constexpr (std::is_unsigned<T2>::value) {
Result = __esimd_uudp4a<T1, T2, T3, T4, N>(Src0.data(), Src1.data(),
Src2.data());
} else {
Result = __esimd_usdp4a<T1, T2, T3, T4, N>(Src0.data(), Src1.data(),
Src2.data());
}
} else {
if constexpr (std::is_unsigned<T2>::value) {
Result = __esimd_sudp4a<T1, T2, T3, T4, N>(Src0.data(), Src1.data(),
Src2.data());
} else {
Result = __esimd_ssdp4a<T1, T2, T3, T4, N>(Src0.data(), Src1.data(),
Src2.data());
}
}
} else {
if constexpr (std::is_unsigned<T1>::value) {
if constexpr (std::is_unsigned<T2>::value) {
Result = __esimd_uudp4a_sat<T1, T2, T3, T4, N>(Src0.data(), Src1.data(),
Src2.data());
} else {
Result = __esimd_usdp4a_sat<T1, T2, T3, T4, N>(Src0.data(), Src1.data(),
Src2.data());
}
} else {
if constexpr (std::is_unsigned<T2>::value) {
Result = __esimd_sudp4a_sat<T1, T2, T3, T4, N>(Src0.data(), Src1.data(),
Src2.data());
} else {
Result = __esimd_ssdp4a_sat<T1, T2, T3, T4, N>(Src0.data(), Src1.data(),
Src2.data());
}
}
}
#else
simd<T2, N> tmp =
__esimd_dp4a<T1, T2, T3, T4, N>(Src0.data(), Src1.data(), Src2.data());
if (flag == saturation_on)
Result = esimd_sat<T1>(tmp);
else
Result = convert<T1>(tmp);
#endif // __SYCL_DEVICE_ONLY__
return Result;
}
static auto constexpr ESIMD_CONST_E = 2.71828f;
static auto constexpr ESIMD_CONST_PI = 3.14159f;
static auto constexpr ESIMD_CONST_2PI = 6.28318f;
/* smallest such that 1.0+ESIMD_DBL_EPSILON != 1.0 */
static auto constexpr ESIMD_DBL_EPSILON = 0.00001f;
template <typename RT, int SZ>
ESIMD_INLINE simd<RT, SZ> esimd_floor(const simd<float, SZ> src0,
const uint flags = 0) {
return esimd_rndd<RT, SZ>(src0, flags);
}
template <typename RT>
ESIMD_INLINE RT esimd_floor(const float &src0, const uint flags = 0) {
return esimd_rndd<RT, 1U>(src0, flags)[0];
}
template <typename RT, int SZ>
ESIMD_INLINE simd<RT, SZ> esimd_ceil(const simd<float, SZ> src0,
const uint flags = 0) {
return esimd_rndu<RT, SZ>(src0, flags);
}
template <typename RT>
ESIMD_INLINE RT esimd_ceil(const float &src0, const uint flags = 0) {
return esimd_rndu<RT, 1U>(src0, flags);
}
/* esimd_atan2_fast - a fast atan2 implementation */
/* vector input */
template <int N>
simd<float, N> esimd_atan2_fast(simd<float, N> y, simd<float, N> x,
const uint flags = 0);
/* scalar input */
template <typename T> float esimd_atan2_fast(T y, T x, const uint flags = 0);
/* esimd_atan2 - atan2 implementation */
/* For Vector input */
template <int N>
simd<float, N> esimd_atan2(simd<float, N> y, simd<float, N> x,
const uint flags = 0);
/* scalar Input */
template <typename T> float esimd_atan2(T y, T x, const uint flags = 0);
/* esimd_fmod: */
/* vector input */
template <int N>
simd<float, N> esimd_fmod(simd<float, N> y, simd<float, N> x,
const uint flags = 0);
/* scalar Input */
template <typename T> float esimd_fmod(T y, T x, const uint flags = 0);
/* esimd_sin_emu - EU emulation for sin(x) */
/* For Vector input */
template <int N>
simd<float, N> esimd_sin_emu(simd<float, N> x, const uint flags = 0);
/* scalar Input */
template <typename T> float esimd_sin_emu(T x, const uint flags = 0);
/* esimd_cos_emu - EU emulation for cos(x) */
/* For Vector input */
template <int N>
simd<float, N> esimd_cos_emu(simd<float, N> x, const uint flags = 0);
/* scalar Input */
template <typename T> float esimd_cos_emu(T x, const uint flags = 0);
/* esimd_tanh_cody_waite - Cody-Waite implementation for tanh(x) */
/* float input */
float esimd_tanh_cody_waite(float x);
/* vector input */
template <int N> simd<float, N> esimd_tanh_cody_waite(simd<float, N> x);
/* esimd_tanh - opencl like implementation for tanh(x) */
/* float input */
float esimd_tanh(float x);
/* vector input */
template <int N> simd<float, N> esimd_tanh(simd<float, N> x);
/* ------------------------- Extended Math Routines
* -------------------------------------------------*/
// For vector input
template <int N>
ESIMD_INLINE simd<float, N> esimd_atan2_fast(simd<float, N> y, simd<float, N> x,
const uint flags) {
simd<float, N> a0;
simd<float, N> a1;
simd<float, N> atan2;
simd<unsigned short, N> mask = (y >= 0.0f);
a0.merge(ESIMD_CONST_PI * 0.5f, ESIMD_CONST_PI * 1.5f, mask);
a1.merge(0, ESIMD_CONST_PI * 2.0f, mask);
a1.merge(ESIMD_CONST_PI, x < 0.0f);
simd<float, N> xy = x * y;
simd<float, N> x2 = x * x;
simd<float, N> y2 = y * y;
a0 -= (xy / (y2 + x2 * 0.28f + ESIMD_DBL_EPSILON));
a1 += (xy / (x2 + y2 * 0.28f + ESIMD_DBL_EPSILON));
atan2.merge(a1, a0, y2 <= x2);
if (flags & saturation_on)
atan2 = esimd_sat<float>(atan2);
return atan2;
}
// For Scalar Input
template <>
ESIMD_INLINE float esimd_atan2_fast(float y, float x, const uint flags) {
simd<float, 1> vy = y;
simd<float, 1> vx = x;
simd<float, 1> atan2 = esimd_atan2_fast(vy, vx, flags);
return atan2[0];
}
// esimd_atan2
// For Vector input
template <int N>
ESIMD_INLINE simd<float, N> esimd_atan2(simd<float, N> y, simd<float, N> x,
const uint flags) {
simd<float, N> v_distance;
simd<float, N> v_y0;
simd<float, N> atan2;
simd<unsigned short, N> mask;
mask = (x < 0);
v_y0.merge(ESIMD_CONST_PI, 0, mask);
v_distance = esimd_sqrt(x * x + y * y);
mask = (esimd_abs<float>(y) < 0.000001f);
atan2.merge(v_y0, (2 * esimd_atan((v_distance - x) / y)), mask);
if (flags & saturation_on)
atan2 = esimd_sat<float>(atan2);
return atan2;
}
// For Scalar Input
template <> ESIMD_INLINE float esimd_atan2(float y, float x, const uint flags) {
float v_distance;
float v_y0;
simd<float, 1> atan2;
unsigned short mask;
mask = (x < 0);
v_y0 = mask ? ESIMD_CONST_PI : 0;
v_distance = esimd_sqrt<float>(x * x + y * y);
mask = (esimd_abs<float>(y) < 0.000001f);
atan2.merge(v_y0, (2 * esimd_atan((v_distance - x) / y)), mask);
if (flags & saturation_on)
atan2 = esimd_sat<float>(atan2);
return atan2[0];
}
// esimd_fmod:
// For Vector input
template <int N>
ESIMD_INLINE simd<float, N> esimd_fmod(simd<float, N> y, simd<float, N> x,
const uint flags) {
simd<int, N> v_quot;
simd<float, N> fmod;
v_quot = convert<int>(y / x);
fmod = y - x * convert<float>(v_quot);
if (flags & saturation_on)
fmod = esimd_sat<float>(fmod);
return fmod;
}
// For Scalar Input
template <> ESIMD_INLINE float esimd_fmod(float y, float x, const uint flags) {
int v_quot;
simd<float, 1> fmod;
v_quot = (int)(y / x);
fmod = y - x * v_quot;
if (flags & saturation_on)
fmod = esimd_sat<float>(fmod);
return fmod[0];
}
static auto constexpr CMPI = 3.14159265f;
// esimd_sin_emu - EU emulation for sin(x)
// For Vector input
template <int N>
ESIMD_INLINE simd<float, N> esimd_sin_emu(simd<float, N> x, const uint flags) {
simd<float, N> x1;
simd<float, N> x2;
simd<float, N> t3;
simd<float, N> sign;
simd<float, N> fTrig;
simd<float, N> TwoPI(6.2831853f);
simd<float, N> CmpI(CMPI);
simd<float, N> OneP(1.f);
simd<float, N> OneN(-1.f);
x = esimd_fmod(x, TwoPI);
x1.merge(CmpI - x, x - CmpI, (x <= CMPI));
x1.merge(x, (x <= CMPI * 0.5f));
x1.merge(CmpI * 2 - x, (x > CMPI * 1.5f));
sign.merge(OneN, OneP, (x > CMPI));
x2 = x1 * x1;
t3 = x2 * x1 * 0.1666667f;
fTrig =
x1 + t3 * (OneN + x2 * 0.05f *
(OneP + x2 * 0.0238095f *
(OneN + x2 * 0.0138889f *
(OneP - x2 * 0.0090909f))));
fTrig *= sign;
if (flags & saturation_on)
fTrig = esimd_sat<float>(fTrig);
return fTrig;
}
// scalar Input
template <typename T> ESIMD_INLINE float esimd_sin_emu(T x0, const uint flags) {
simd<float, 1> x1;
simd<float, 1> x2;
simd<float, 1> t3;
simd<float, 1> sign;
simd<float, 1> fTrig;
float TwoPI = CMPI * 2.0f;
simd<float, 1> x = esimd_fmod(x0, TwoPI);
simd<float, 1> CmpI(CMPI);
simd<float, 1> OneP(1.f);
simd<float, 1> OneN(-1.f);
x1.merge(CmpI - x, x - CmpI, (x <= CMPI));
x1.merge(x, (x <= CMPI * 0.5f));
x1.merge(CmpI * 2.0f - x, (x > CMPI * 1.5f));
sign.merge(OneN, OneP, (x > CMPI));
x2 = x1 * x1;
t3 = x2 * x1 * 0.1666667f;
fTrig =
x1 + t3 * (OneN + x2 * 0.05f *
(OneP + x2 * 0.0238095f *
(OneN + x2 * 0.0138889f *
(OneP - x2 * 0.0090909f))));
fTrig *= sign;
if (flags & saturation_on)
fTrig = esimd_sat<float>(fTrig);
return fTrig[0];
}
// esimd_cos_emu - EU emulation for sin(x)
// For Vector input
template <int N>
ESIMD_INLINE simd<float, N> esimd_cos_emu(simd<float, N> x, const uint flags) {
simd<float, N> x1;
simd<float, N> x2;
simd<float, N> t2;
simd<float, N> t3;
simd<float, N> sign;
simd<float, N> fTrig;
simd<float, N> TwoPI(6.2831853f);
simd<float, N> CmpI(CMPI);
simd<float, N> OneP(1.f);
simd<float, N> OneN(-1.f);
x = esimd_fmod(x, TwoPI);
x1.merge(x - CMPI * 0.5f, CmpI * 1.5f - x, (x <= CMPI));
x1.merge(CmpI * 0.5f - x, (x <= CMPI * 0.5f));
x1.merge(x - CMPI * 1.5f, (x > CMPI * 1.5f));
sign.merge(1, -1, ((x < CMPI * 0.5f) | (x >= CMPI * 1.5f)));
x2 = x1 * x1;
t3 = x2 * x1 * 0.1666667f;
fTrig =
x1 + t3 * (OneN + x2 * 0.05f *
(OneP + x2 * 0.0238095f *
(OneN + x2 * 0.0138889f *
(OneP - x2 * 0.0090909f))));
fTrig *= sign;
if (flags & saturation_on)
fTrig = esimd_sat<float>(fTrig);
return fTrig;
}
// scalar Input
template <typename T> ESIMD_INLINE float esimd_cos_emu(T x0, const uint flags) {
simd<float, 1> x1;
simd<float, 1> x2;
simd<float, 1> t3;
simd<float, 1> sign;
simd<float, 1> fTrig;
float TwoPI = CMPI * 2.0f;
simd<float, 1> x = esimd_fmod(x0, TwoPI);
simd<float, 1> CmpI(CMPI);
simd<float, 1> OneP(1.f);
simd<float, 1> OneN(-1.f);
x1.merge(x - CMPI * 0.5f, CmpI * 1.5f - x, (x <= CMPI));
x1.merge(CmpI * 0.5f - x, (x <= CMPI * 0.5f));
x1.merge(x - CMPI * 1.5f, (x > CMPI * 1.5f));
sign.merge(OneP, OneN, ((x < CMPI * 0.5f) | (x >= CMPI * 1.5f)));
x2 = x1 * x1;
t3 = x2 * x1 * 0.1666667f;
fTrig =
x1 + t3 * (OneN + x2 * 0.05f *
(OneP + x2 * 0.0238095f *
(OneN + x2 * 0.0138889f *
(OneP - x2 * 0.0090909f))));
fTrig *= sign;
if (flags & saturation_on)
fTrig = esimd_sat<float>(fTrig);
return fTrig[0];
}
namespace detail {
template <int N>
ESIMD_INLINE simd<float, N> esimd_tanh_cody_waite_impl(simd<float, N> x) {
/*
* 0 x_small x_medium x_large
* | x | rational polynomial | 1 - 2/(1 + exp(2*x)) | 1
*
* rational polynomial for single precision = x + x * (g * (p[1] * g + p[0]) /
* (g + q[0]) g = x^2 p0 = -0.82377 28127 E+00 p1 = -0.38310 10665 E-02 q0 =
* 0.24713 19654 E+01 q1 = 1.00000 00000 E+00
*
*/
constexpr float p0 = -0.8237728127E+00f;
constexpr float p1 = -0.3831010665E-02f;
constexpr float q0 = 0.2471319654E+01f;
constexpr float q1 = 1.0000000000E+00f;
constexpr float xsmall = 4.22863966691620432990E-04f;
constexpr float xmedium = 0.54930614433405484570f;
constexpr float xlarge = 8.66433975699931636772f;
constexpr float log2E = 1.442695f; // same as esimd_log(e)
using RT = simd<float, N>;
RT absX = esimd_abs(x);
RT g = absX * absX;
RT sign;
sign.merge(-1.f, 1.f, x < 0.f);
auto isLarge = absX > xlarge;
auto minor = absX <= xlarge;
auto isGtMed = minor & (absX > xmedium);
auto isGtSmall = (absX > xsmall) & (absX <= xmedium);
RT res;
res.merge(sign, x, isLarge);
auto temp = esimd_exp(absX * 2.0f * log2E) + 1.f;
temp = ((temp - 2.f) / temp) * sign;
res.merge(temp, isGtMed);
res.merge((absX + absX * g * (g * p1 + p0) / (g + q0)) * sign, isGtSmall);
return res;
}
template <int N> ESIMD_INLINE simd<float, N> esimd_tanh_impl(simd<float, N> x) {
/*
* 0 x_small x_large
* | x | ( exp(x) - exp(-x) ) / ( exp(x) + exp(-x) ) | 1
*
*/
constexpr float xsmall = 0.000045f; // same as exp(-10.0f)
constexpr float xlarge = 88.f;
constexpr float log2E = 1.442695f; // same as esimd_log(e)
using RT = simd<float, N>;
RT absX = esimd_abs(x);
RT sign;
sign.merge(-1.f, 1.f, x < 0.f);
auto isLarge = (absX > xlarge);
auto isLessE = (absX <= xlarge);
RT res;
res.merge(sign, x, isLarge);
RT exp;
exp = esimd_exp(absX * 2.f * log2E);
res.merge(((exp - 1.f) / (exp + 1.f)) * sign, (absX > xsmall) & isLessE);
return res;
}
} // namespace detail
/* esimd_tanh_cody_waite - Cody-Waite implementation for tanh(x) */
/* float input */
ESIMD_INLINE float esimd_tanh_cody_waite(float x) {
return detail::esimd_tanh_cody_waite_impl(simd<float, 1>(x))[0];
}
/* vector input */
template <int N>
ESIMD_INLINE simd<float, N> esimd_tanh_cody_waite(simd<float, N> x) {
return detail::esimd_tanh_cody_waite_impl(x);
}
/* esimd_tanh - opencl like implementation for tanh(x) */
/* float input */
ESIMD_INLINE float esimd_tanh(float x) {
return detail::esimd_tanh_impl(simd<float, 1>(x))[0];
}
/* vector input */
template <int N> ESIMD_INLINE simd<float, N> esimd_tanh(simd<float, N> x) {
return detail::esimd_tanh_impl(x);
}
// reduction functions
namespace detail {
template <typename T0, typename T1, int SZ> struct esimd_apply_sum {
template <typename... T>
simd<T0, SZ> operator()(simd<T1, SZ> v1, simd<T1, SZ> v2) {
return v1 + v2;
}
};
template <typename T0, typename T1, int SZ> struct esimd_apply_prod {
template <typename... T>
simd<T0, SZ> operator()(simd<T1, SZ> v1, simd<T1, SZ> v2) {
return v1 * v2;
}
};
template <typename T0, typename T1, int SZ> struct esimd_apply_reduced_max {
template <typename... T>
simd<T0, SZ> operator()(simd<T1, SZ> v1, simd<T1, SZ> v2) {
if constexpr (std::is_floating_point<T1>::value) {
return __esimd_reduced_fmax<T1, SZ>(v1, v2);
} else if constexpr (std::is_unsigned<T1>::value) {
return __esimd_reduced_umax<T1, SZ>(v1, v2);
} else {
return __esimd_reduced_smax<T1, SZ>(v1, v2);
}
}
};
template <typename T0, typename T1, int SZ> struct esimd_apply_reduced_min {
template <typename... T>
simd<T0, SZ> operator()(simd<T1, SZ> v1, simd<T1, SZ> v2) {
if constexpr (std::is_floating_point<T1>::value) {
return __esimd_reduced_fmin<T1, SZ>(v1, v2);
} else if constexpr (std::is_unsigned<T1>::value) {
return __esimd_reduced_umin<T1, SZ>(v1, v2);
} else {
return __esimd_reduced_smin<T1, SZ>(v1, v2);
}
}
};
template <typename T0, typename T1, int SZ,
template <typename RT, typename T, int N> class OpType>
T0 esimd_reduce_single(simd<T1, SZ> v) {
if constexpr (SZ == 1) {
return v[0];
} else {
static_assert(detail::isPowerOf2(SZ),
"Invaid input for esimd_reduce_single - the vector size must "
"be power of two.");
constexpr int N = SZ / 2;
simd<T0, N> tmp = OpType<T0, T1, N>()(v.template select<N, 1>(0),
v.template select<N, 1>(N));
return esimd_reduce_single<T0, T0, N, OpType>(tmp);
}
}
template <typename T0, typename T1, int N1, int N2,
template <typename RT, typename T, int N> class OpType>
T0 esimd_reduce_pair(simd<T1, N1> v1, simd<T1, N2> v2) {
if constexpr (N1 == N2) {
simd<T0, N1> tmp = OpType<T0, T1, N1>()(v1, v2);
return esimd_reduce_single<T0, T0, N1, OpType>(tmp);
} else if constexpr (N1 < N2) {
simd<T0, N1> tmp1 = OpType<T0, T1, N1>()(v1, v2.template select<N1, 1>(0));
constexpr int N = N2 - N1;
using NT = simd<T0, N>;
NT tmp2 = convert<T0>(v2.template select<N, 1>(N1).read());
return esimd_reduce_pair<T0, T0, N1, N, OpType>(tmp1, tmp2);
} else {
static_assert(
detail::isPowerOf2(N1),
"Invaid input for esimd_reduce_pair - N1 must be power of two.");
constexpr int N = N1 / 2;
simd<T0, N> tmp = OpType<T0, T1, N>()(v1.template select<N, 1>(0),
v1.template select<N, 1>(N));
using NT = simd<T0, N2>;
NT tmp2 = convert<T0>(v2);
return esimd_reduce_pair<T0, T0, N, N2, OpType>(tmp, tmp2);
}
}
template <typename T0, typename T1, int SZ,
template <typename RT, typename T, int N> class OpType>
T0 esimd_reduce(simd<T1, SZ> v) {
constexpr bool isPowerOf2 = detail::isPowerOf2(SZ);
if constexpr (isPowerOf2) {
return esimd_reduce_single<T0, T1, SZ, OpType>(v);
} else {
constexpr unsigned N1 = 1u << detail::log2<SZ>();
constexpr unsigned N2 = SZ - N1;
simd<T1, N1> v1 = v.template select<N1, 1>(0);
simd<T1, N2> v2 = v.template select<N2, 1>(N1);
return esimd_reduce_pair<T0, T1, N1, N2, OpType>(v1, v2);
}
};
template <typename T0, typename T1, int SZ>
ESIMD_INLINE ESIMD_NODEBUG T0 esimd_sum(simd<T1, SZ> v) {
using TT = compute_type_t<simd<T1, SZ>>;
using RT = typename TT::element_type;
T0 retv = esimd_reduce<RT, T1, SZ, esimd_apply_sum>(v);
return retv;
}
template <typename T0, typename T1, int SZ>
ESIMD_INLINE ESIMD_NODEBUG T0 esimd_prod(simd<T1, SZ> v) {
using TT = compute_type_t<simd<T1, SZ>>;
using RT = typename TT::element_type;
T0 retv = esimd_reduce<RT, T1, SZ, esimd_apply_prod>(v);
return retv;
}
} // namespace detail
template <typename T0, typename T1, int SZ>
ESIMD_INLINE ESIMD_NODEBUG T0 hmax(simd<T1, SZ> v) {
T0 retv =
detail::esimd_reduce<T1, T1, SZ, detail::esimd_apply_reduced_max>(v);
return retv;
}
template <typename T0, typename T1, int SZ>
ESIMD_INLINE ESIMD_NODEBUG T0 hmin(simd<T1, SZ> v) {
T0 retv =
detail::esimd_reduce<T1, T1, SZ, detail::esimd_apply_reduced_min>(v);
return retv;
}
template <typename T0, typename T1, int SZ, typename BinaryOperation>
ESIMD_INLINE ESIMD_NODEBUG T0 reduce(simd<T1, SZ> v, BinaryOperation op) {
if constexpr (std::is_same<detail::remove_cvref_t<BinaryOperation>,
std::plus<>>::value) {
T0 retv = detail::esimd_sum<T0>(v);
return retv;
} else if constexpr (std::is_same<detail::remove_cvref_t<BinaryOperation>,
std::multiplies<>>::value) {
T0 retv = detail::esimd_prod<T0>(v);
return retv;
}
}
template <typename T, int N>
simd<T, N> esimd_dp4(simd<T, N> v1, simd<T, N> v2) {
auto retv = __esimd_dp4<T, N>(v1, v2);
return retv;
}
} // namespace esimd
} // namespace experimental
} // namespace intel
} // namespace ext
} // namespace sycl
} // __SYCL_INLINE_NAMESPACE(cl)
|
; A083392: Alternating partial sums of A000217.
; 0,-1,2,-4,6,-9,12,-16,20,-25,30,-36,42,-49,56,-64,72,-81,90,-100,110,-121,132,-144,156,-169,182,-196,210,-225,240,-256,272,-289,306,-324,342,-361,380,-400,420,-441,462,-484,506,-529,552,-576,600,-625,650,-676,702,-729,756,-784,812,-841,870,-900,930,-961,992,-1024,1056,-1089,1122,-1156,1190,-1225,1260,-1296,1332,-1369,1406,-1444,1482,-1521,1560,-1600,1640,-1681,1722,-1764,1806,-1849,1892,-1936,1980,-2025,2070,-2116,2162,-2209,2256,-2304,2352,-2401,2450,-2500
seq $0,162395 ; a(n) = -(-1)^n * n^2.
div $0,4
|
/*
* GDevelop Core
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights
* reserved. This project is released under the MIT License.
*/
#include "AllBuiltinExtensions.h"
#include "GDCore/Project/Object.h"
#include "GDCore/Tools/Localization.h"
#include "GDCore/Extensions/Metadata/MultipleInstructionMetadata.h"
using namespace std;
namespace gd {
void GD_CORE_API BuiltinExtensionsImplementer::ImplementsBaseObjectExtension(
gd::PlatformExtension& extension) {
extension
.SetExtensionInformation(
"BuiltinObject",
_("Features for all objects"),
_("Common features that can be used for all objects in GDevelop."),
"Florian Rival",
"Open source (MIT License)")
.SetExtensionHelpPath("/objects/base_object/events");
gd::ObjectMetadata& obj = extension.AddObject<gd::Object>(
"", _("Base object"), _("Base object"), "res/objeticon24.png");
#if defined(GD_IDE_ONLY)
obj.AddCondition("PosX",
_("X position"),
_("Compare the X position of the object."),
_("the X position"),
_("Position"),
"res/conditions/position24.png",
"res/conditions/position.png")
.AddParameter("object", _("Object"))
.UseStandardRelationalOperatorParameters("number")
.MarkAsSimple();
obj.AddAction("MettreX",
_("X position"),
_("Change the X position of an object."),
_("the X position"),
_("Position"),
"res/actions/position24.png",
"res/actions/position.png")
.AddParameter("object", _("Object"))
.UseStandardOperatorParameters("number")
.MarkAsSimple();
obj.AddCondition("PosY",
_("Y position"),
_("Compare the Y position of an object."),
_("the Y position"),
_("Position"),
"res/conditions/position24.png",
"res/conditions/position.png")
.AddParameter("object", _("Object"))
.UseStandardRelationalOperatorParameters("number")
.MarkAsSimple();
obj.AddAction("MettreY",
_("Y position"),
_("Change the Y position of an object."),
_("the Y position"),
_("Position"),
"res/actions/position24.png",
"res/actions/position.png")
.AddParameter("object", _("Object"))
.UseStandardOperatorParameters("number")
.MarkAsSimple();
obj.AddAction("MettreXY",
_("Position"),
_("Change the position of an object."),
_("Change the position of _PARAM0_: _PARAM1_ _PARAM2_ (x "
"axis), _PARAM3_ _PARAM4_ (y axis)"),
_("Position"),
"res/actions/position24.png",
"res/actions/position.png")
.AddParameter("object", _("Object"))
.AddParameter("operator", _("Modification's sign"))
.AddParameter("expression", _("X position"))
.AddParameter("operator", _("Modification's sign"))
.AddParameter("expression", _("Y position"))
.MarkAsSimple();
obj.AddAction("SetCenter",
_("Center position"),
_("Change the position of an object, using its center."),
_("Change the position of the center of _PARAM0_: _PARAM1_ _PARAM2_ (x "
"axis), _PARAM3_ _PARAM4_ (y axis)"),
_("Position/Center"),
"res/actions/position24.png",
"res/actions/position.png")
.AddParameter("object", _("Object"))
.AddParameter("operator", _("Modification's sign"))
.AddParameter("expression", _("X position"))
.AddParameter("operator", _("Modification's sign"))
.AddParameter("expression", _("Y position"))
.MarkAsSimple();
obj.AddExpressionAndConditionAndAction("number", "CenterX",
_("Center X position"),
_("the X position of the center"),
_("the X position of the center"),
_("Position/Center"),
"res/actions/position24.png")
.AddParameter("object", _("Object"))
.UseStandardParameters("number");
obj.AddExpressionAndConditionAndAction("number", "CenterY",
_("Center Y position"),
_("the Y position of the center"),
_("the Y position of the center"),
_("Position/Center"),
"res/actions/position24.png")
.AddParameter("object", _("Object"))
.UseStandardParameters("number");
obj.AddAction("MettreAutourPos",
_("Put around a position"),
_("Position the center of the given object around a position, "
"using the specified angle "
"and distance."),
_("Put _PARAM0_ around _PARAM1_;_PARAM2_, with an angle of "
"_PARAM4_ degrees and _PARAM3_ pixels distance."),
_("Position"),
"res/actions/positionAutour24.png",
"res/actions/positionAutour.png")
.AddParameter("object", _("Object"))
.AddParameter("expression", _("X position"))
.AddParameter("expression", _("Y position"))
.AddParameter("expression", _("Distance"))
.AddParameter("expression", _("Angle, in degrees"))
.MarkAsAdvanced();
obj.AddAction("SetAngle",
_("Angle"),
_("Change the angle of rotation of an object."),
_("the angle"),
_("Angle"),
"res/actions/direction24.png",
"res/actions/direction.png")
.AddParameter("object", _("Object"))
.UseStandardOperatorParameters("number");
obj.AddAction("Rotate",
_("Rotate"),
_("Rotate an object, clockwise if the speed is positive, "
"counterclockwise otherwise."),
_("Rotate _PARAM0_ at speed _PARAM1_deg/second"),
_("Angle"),
"res/actions/direction24.png",
"res/actions/direction.png")
.AddParameter("object", _("Object"))
.AddParameter("expression", _("Angular speed (in degrees per second)"))
.AddCodeOnlyParameter("currentScene", "")
.MarkAsSimple();
obj.AddAction(
"RotateTowardAngle",
_("Rotate toward angle"),
_("Rotate an object towards an angle with the specified speed."),
_("Rotate _PARAM0_ towards _PARAM1_ at speed _PARAM2_deg/second"),
_("Angle"),
"res/actions/direction24.png",
"res/actions/direction.png")
.AddParameter("object", _("Object"))
.AddParameter("expression", _("Angle to rotate towards (in degrees)"))
.AddParameter("expression", _("Angular speed (in degrees per second)"))
.SetParameterLongDescription(_("Enter 0 for an immediate rotation."))
.AddCodeOnlyParameter("currentScene", "");
obj.AddAction(
"RotateTowardPosition",
_("Rotate toward position"),
_("Rotate an object towards a position, with the specified speed."),
_("Rotate _PARAM0_ towards _PARAM1_;_PARAM2_ at speed "
"_PARAM3_deg/second"),
_("Angle"),
"res/actions/direction24.png",
"res/actions/direction.png")
.AddParameter("object", _("Object"))
.AddParameter("expression", _("X position"))
.AddParameter("expression", _("Y position"))
.AddParameter("expression", _("Angular speed (in degrees per second)"))
.SetParameterLongDescription(_("Enter 0 for an immediate rotation."))
.AddCodeOnlyParameter("currentScene", "")
.MarkAsAdvanced();
obj.AddAction(
"AddForceXY",
_("Add a force"),
_("Add a force to an object. The object will move according to "
"all of the forces it has."),
_("Add to _PARAM0_ _PARAM3_ force of _PARAM1_ p/s on X axis and "
"_PARAM2_ p/s on Y axis"),
_("Movement using forces"),
"res/actions/force24.png",
"res/actions/force.png")
.AddParameter("object", _("Object"))
.AddParameter("expression", _("Speed on X axis (in pixels per second)"))
.AddParameter("expression", _("Speed on Y axis (in pixels per second)"))
.AddParameter("forceMultiplier", _("Force multiplier"));
obj.AddAction("AddForceAL",
_("Add a force (angle)"),
_("Add a force to an object. The object will move according to "
"all of the forces it has. This action creates the force "
"using the specified angle and length."),
_("Add to _PARAM0_ _PARAM3_ force, angle: _PARAM1_ degrees and "
"length: _PARAM2_ pixels"),
_("Movement using forces"),
"res/actions/force24.png",
"res/actions/force.png")
.AddParameter("object", _("Object"))
.AddParameter("expression", _("Angle"))
.AddParameter("expression", _("Speed (in pixels per second)"))
.AddParameter("forceMultiplier", _("Force multiplier"))
.MarkAsAdvanced();
obj.AddAction(
"AddForceVersPos",
_("Add a force to move toward a position"),
_("Add a force to an object to make it move toward a position."),
_("Move _PARAM0_ toward _PARAM1_;_PARAM2_ with _PARAM4_ force of _PARAM3_ "
"pixels"),
_("Movement using forces"),
"res/actions/force24.png",
"res/actions/force.png")
.AddParameter("object", _("Object"))
.AddParameter("expression", _("X position"))
.AddParameter("expression", _("Y position"))
.AddParameter("expression", _("Speed (in pixels per second)"))
.AddParameter("forceMultiplier", _("Force multiplier"))
.MarkAsAdvanced();
obj.AddAction(
"AddForceTournePos",
"Add a force to move around a position",
"Add a force to an object to make it rotate around a "
"position.\nNote that the movement is not precise, especially if "
"the speed is high.\nTo position an object around a position more "
"precisely, use the actions in the category \"Position\".",
"Rotate _PARAM0_ around _PARAM1_;_PARAM2_ at _PARAM3_ deg/sec and "
"_PARAM4_ pixels away",
_("Movement using forces"),
"res/actions/forceTourne24.png",
"res/actions/forceTourne.png")
.AddParameter("object", _("Object"))
.AddParameter("expression", "X position of the center")
.AddParameter("expression", "Y position of the center")
.AddParameter("expression", "Speed (in Degrees per seconds)")
.AddParameter("expression", "Distance (in pixels)")
.AddParameter("forceMultiplier", "Force multiplier")
.SetHidden();
obj.AddAction("Arreter",
_("Stop the object"),
_("Stop the object by deleting all of its forces."),
_("Stop _PARAM0_ (remove all forces)"),
_("Movement using forces"),
"res/actions/arreter24.png",
"res/actions/arreter.png")
.AddParameter("object", _("Object"))
.MarkAsAdvanced();
obj.AddAction("Delete",
_("Delete the object"),
_("Delete the specified object."),
_("Delete _PARAM0_"),
_("Objects"),
"res/actions/delete24.png",
"res/actions/delete.png")
.AddParameter("object", _("Object"))
.AddCodeOnlyParameter("currentScene", "")
.MarkAsSimple();
obj.AddAction("ChangePlan",
_("Z order"),
_("Modify the Z-order of an object"),
_("the z-order"),
_("Z order"),
"res/actions/planicon24.png",
"res/actions/planicon.png")
.AddParameter("object", _("Object"))
.UseStandardOperatorParameters("number");
obj.AddAction("ChangeLayer",
_("Layer"),
_("Move the object to a different layer."),
_("Put _PARAM0_ on the layer _PARAM1_"),
_("Layers and cameras"),
"res/actions/layer24.png",
"res/actions/layer.png")
.AddParameter("object", _("Object"))
.AddParameter("layer", _("Move it to this layer (base layer if empty)"))
.SetDefaultValue("\"\"")
.MarkAsAdvanced();
obj.AddAction("ModVarObjet",
_("Value of an object variable"),
_("Change the value of an object variable."),
_("the variable _PARAM1_"),
_("Variables"),
"res/actions/var24.png",
"res/actions/var.png")
.AddParameter("object", _("Object"))
.AddParameter("objectvar", _("Variable"))
.UseStandardOperatorParameters("number");
obj.AddAction("ModVarObjetTxt",
_("Text of an object variable"),
_("Change the text of an object variable."),
_("the text of variable _PARAM1_"),
_("Variables"),
"res/actions/var24.png",
"res/actions/var.png")
.AddParameter("object", _("Object"))
.AddParameter("objectvar", _("Variable"))
.UseStandardOperatorParameters("string");
obj.AddAction("SetObjectVariableAsBoolean",
_("Boolean value of an object variable"),
_("Change the boolean value of an object variable."),
_("Set the boolean value of variable _PARAM1_ of "
"_PARAM0_ to _PARAM2_"),
_("Variables"),
"res/actions/var24.png",
"res/actions/var.png")
.AddParameter("object", _("Object"))
.AddParameter("objectvar", _("Variable"))
.AddParameter("trueorfalse", _("New Value:"));
obj.AddAction(
"ToggleObjectVariableAsBoolean",
_("Toggle the boolean value of an object variable"),
_("Toggles the boolean value of an object variable.") + "\n" +
_("If it was true, it will become false, and if it was false "
"it will become true."),
_("Toggle the boolean value of variable _PARAM1_ of "
"_PARAM0_"),
_("Variables"),
"res/actions/var24.png",
"res/actions/var.png")
.AddParameter("object", _("Object"))
.AddParameter("objectvar", _("Variable"));
obj.AddCondition("ObjectVariableChildExists",
_("Child existence"),
_("Check if the specified child of the variable exists."),
_("Child _PARAM2_ of variable _PARAM1_ of _PARAM0_ exists"),
_("Variables/Collections/Structures"),
"res/conditions/var24.png",
"res/conditions/var.png")
.AddParameter("object", _("Object"))
.AddParameter("objectvar", _("Variable"))
.AddParameter("string", _("Name of the child"))
.MarkAsAdvanced();
obj.AddAction("ObjectVariableRemoveChild",
_("Remove a child"),
_("Remove a child from an object variable."),
_("Remove child _PARAM2_ from variable _PARAM1_ of _PARAM0_"),
_("Variables/Collections/Structures"),
"res/actions/var24.png",
"res/actions/var.png")
.AddParameter("object", _("Object"))
.AddParameter("objectvar", _("Variable"))
.AddParameter("string", _("Child's name"))
.MarkAsAdvanced();
obj.AddAction("ObjectVariableClearChildren",
_("Clear variable"),
_("Remove all the children from the object variable."),
_("Clear children from variable _PARAM1_ of _PARAM0_"),
_("Variables/Collections"),
"res/actions/var24.png",
"res/actions/var.png")
.AddParameter("object", _("Object"))
.AddParameter("objectvar", _("Variable"))
.MarkAsAdvanced();
obj.AddAction("Cache",
_("Hide"),
_("Hide the specified object."),
_("Hide _PARAM0_"),
_("Visibility"),
"res/actions/visibilite24.png",
"res/actions/visibilite.png")
.AddParameter("object", _("Object"))
.MarkAsSimple();
obj.AddAction("Montre",
_("Show"),
_("Show the specified object."),
_("Show _PARAM0_"),
_("Visibility"),
"res/actions/visibilite24.png",
"res/actions/visibilite.png")
.AddParameter("object", _("Object"))
.AddCodeOnlyParameter("inlineCode", "false")
.MarkAsSimple();
obj.AddCondition("Angle",
_("Angle"),
_("Compare the angle of the specified object."),
_("the angle (in degrees)"),
_("Angle"),
"res/conditions/direction24.png",
"res/conditions/direction.png")
.AddParameter("object", _("Object"))
.UseStandardRelationalOperatorParameters("number")
.MarkAsAdvanced();
obj.AddCondition("Plan",
_("Z-order"),
_("Compare the Z-order of the specified object."),
_("the Z-order"),
_("Z-order"),
"res/conditions/planicon24.png",
"res/conditions/planicon.png")
.AddParameter("object", _("Object"))
.UseStandardRelationalOperatorParameters("number")
.MarkAsAdvanced();
obj.AddCondition("Layer",
_("Current layer"),
_("Check if the object is on the specified layer."),
_("_PARAM0_ is on layer _PARAM1_"),
_("Layer"),
"res/conditions/layer24.png",
"res/conditions/layer.png")
.AddParameter("object", _("Object"))
.AddParameter("layer", _("Layer"))
.MarkAsAdvanced();
obj.AddCondition("Visible",
_("Visibility"),
_("Check if an object is visible."),
_("_PARAM0_ is visible (not marked as hidden)"),
_("Visibility"),
"res/conditions/visibilite24.png",
"res/conditions/visibilite.png")
.AddParameter("object", _("Object"))
.MarkAsSimple();
obj.AddCondition("Invisible",
"Invisibility of an object",
"Check if an object is hidden.",
"_PARAM0_ is hidden",
_("Visibility"),
"res/conditions/visibilite24.png",
"res/conditions/visibilite.png")
.AddParameter("object", _("Object"))
.SetHidden(); // Inverted "Visible" condition does the same thing.
obj.AddCondition("Arret",
_("Object is stopped (no forces applied on it)"),
_("Check if an object is not moving"),
_("_PARAM0_ is stopped"),
_("Movement using forces"),
"res/conditions/arret24.png",
"res/conditions/arret.png")
.AddParameter("object", _("Object"))
.MarkAsAdvanced();
obj.AddCondition("Vitesse",
_("Speed (from forces)"),
_("Compare the overall speed of an object"),
_("the overall speed"),
_("Movement using forces"),
"res/conditions/vitesse24.png",
"res/conditions/vitesse.png")
.AddParameter("object", _("Object"))
.UseStandardRelationalOperatorParameters("number")
.MarkAsAdvanced();
obj.AddCondition("AngleOfDisplacement",
_("Angle of movement (using forces)"),
_("Compare the angle of movement of an object according to the forces applied on it."),
_("Angle of movement of _PARAM0_ is _PARAM1_ (tolerance"
": _PARAM2_ degrees)"),
_("Movement using forces"),
"res/conditions/vitesse24.png",
"res/conditions/vitesse.png")
.AddParameter("object", _("Object"))
.AddParameter("expression", _("Angle, in degrees"))
.AddParameter("expression", _("Tolerance, in degrees"))
.MarkAsAdvanced();
obj.AddCondition("VarObjet",
_("Value of an object variable"),
_("Compare the value of an object variable."),
_("the variable _PARAM1_"),
_("Variables"),
"res/conditions/var24.png",
"res/conditions/var.png")
.AddParameter("object", _("Object"))
.AddParameter("objectvar", _("Variable"))
.UseStandardRelationalOperatorParameters("number");
obj.AddCondition("VarObjetTxt",
_("Text of an object variable"),
_("Compare the text of an object variable."),
_("the text of variable _PARAM1_"),
_("Variables"),
"res/conditions/var24.png",
"res/conditions/var.png")
.AddParameter("object", _("Object"))
.AddParameter("objectvar", _("Variable"))
.UseStandardRelationalOperatorParameters("string");
obj.AddCondition("ObjectVariableAsBoolean",
_("Boolean value of an object variable"),
_("Compare the boolean value of an object variable."),
_("The boolean value of variable _PARAM1_ of object "
"_PARAM0_ is _PARAM2_"),
_("Variables"),
"res/conditions/var24.png",
"res/conditions/var.png")
.AddParameter("object", _("Object"))
.AddParameter("objectvar", _("Variable"))
.AddParameter("trueorfalse", _("Check if the value is"))
.SetDefaultValue("true");
obj.AddCondition("VarObjetDef",
"Variable defined",
"Check if the variable is defined.",
"Variable _PARAM1 of _PARAM0_ is defined",
_("Variables"),
"res/conditions/var24.png",
"res/conditions/var.png")
.AddParameter("object", _("Object"))
.AddParameter("string", _("Variable"))
.SetHidden();
obj.AddAction(
"ObjectVariablePush",
_("Append variable to an object array"),
_("Appends a variable to the end of an object array variable."),
_("Append variable _PARAM2_ to array variable _PARAM1_ of _PARAM0_"),
_("Variables/Collections/Arrays"),
"res/actions/var24.png",
"res/actions/var.png")
.AddParameter("object", _("Object"))
.AddParameter("objectvar", _("Array variable"))
.AddParameter("scenevar", _("Scene variable with the content to append"))
.SetParameterLongDescription(
_("The content of the variable will *be copied* and appended at the "
"end of the array."))
.MarkAsAdvanced();
obj.AddAction(
"ObjectVariablePushString",
_("Append a string to an object array"),
_("Appends a string to the end of an object array variable."),
_("Append string _PARAM2_ to array variable _PARAM1_ of _PARAM0_"),
_("Variables/Collections/Arrays"),
"res/actions/var24.png",
"res/actions/var.png")
.AddParameter("object", _("Object"))
.AddParameter("objectvar", _("Array variable"))
.AddParameter("string", _("String to append"))
.MarkAsAdvanced();
obj.AddAction(
"ObjectVariablePushNumber",
_("Append a number to an object array"),
_("Appends a number to the end of an object array variable."),
_("Append number _PARAM2_ to array variable _PARAM1_ of _PARAM0_"),
_("Variables/Collections/Arrays"),
"res/actions/var24.png",
"res/actions/var.png")
.AddParameter("object", _("Object"))
.AddParameter("objectvar", _("Array variable"))
.AddParameter("expression", _("Number to append"))
.MarkAsAdvanced();
obj.AddAction(
"ObjectVariablePushBool",
_("Append a boolean to an object array"),
_("Appends a boolean to the end of an object array variable."),
_("Append boolean _PARAM2_ to array variable _PARAM1_ of _PARAM0_"),
_("Variables/Collections/Arrays"),
"res/actions/var24.png",
"res/actions/var.png")
.AddParameter("object", _("Object"))
.AddParameter("objectvar", _("Array variable"))
.AddParameter("trueorfalse", _("Boolean to append"))
.MarkAsAdvanced();
obj.AddAction(
"ObjectVariableRemoveAt",
_("Remove variable from an object array (by index)"),
_("Removes a variable at the specified index of an object array "
"variable."),
_("Remove variable at index _PARAM2_ from array variable _PARAM1_ of "
"_PARAM0_"),
_("Variables/Collections/Arrays"),
"res/actions/var24.png",
"res/actions/var.png")
.AddParameter("object", _("Object"))
.AddParameter("objectvar", _("Variable"))
.AddParameter("expression", _("Index to remove"))
.MarkAsAdvanced();
obj.AddCondition("BehaviorActivated",
_("Behavior activated"),
_("Check if the behavior is activated for the object."),
_("Behavior _PARAM1_ of _PARAM0_ is activated"),
_("Behaviors"),
"res/behavior24.png",
"res/behavior16.png")
.AddParameter("object", _("Object"))
.AddParameter("behavior", _("Behavior"))
.MarkAsAdvanced();
obj.AddAction("ActivateBehavior",
_("De/activate a behavior"),
_("De/activate the behavior for the object."),
_("Activate behavior _PARAM1_ of _PARAM0_: _PARAM2_"),
_("Behaviors"),
"res/behavior24.png",
"res/behavior16.png")
.AddParameter("object", _("Object"))
.AddParameter("behavior", _("Behavior"))
.AddParameter("yesorno", _("Activate?"))
.MarkAsAdvanced();
obj.AddAction(
"AddForceVers",
_("Add a force to move toward an object"),
_("Add a force to an object to make it move toward another."),
_("Move _PARAM0_ toward _PARAM1_ with _PARAM3_ force of _PARAM2_ pixels"),
_("Movement using forces"),
"res/actions/forceVers24.png",
"res/actions/forceVers.png")
.AddParameter("object", _("Object"))
.AddParameter("objectPtr", _("Target Object"))
.AddParameter("expression", _("Speed (in pixels per second)"))
.AddParameter("forceMultiplier", _("Force multiplier"))
.MarkAsAdvanced();
obj.AddAction(
"AddForceTourne",
_("Add a force to move around an object"),
_("Add a force to an object to make it rotate around another.\nNote "
"that the movement is not precise, especially if the speed is "
"high.\nTo position an object around a position more precisely, use "
"the actions in category \"Position\"."),
_("Rotate _PARAM0_ around _PARAM1_ at _PARAM2_ deg/sec and _PARAM3_ "
"pixels away"),
_("Movement using forces"),
"res/actions/forceTourne24.png",
"res/actions/forceTourne.png")
.AddParameter("object", _("Object"))
.AddParameter("objectPtr", _("Rotate around this object"))
.AddParameter("expression", _("Speed (in degrees per second)"))
.AddParameter("expression", _("Distance (in pixels)"))
.AddParameter("forceMultiplier", _("Force multiplier"))
.MarkAsAdvanced();
obj.AddAction("MettreAutour",
_("Put the object around another"),
_("Position an object around another, with the specified angle "
"and distance. The center of the objects are used for "
"positioning them."),
_("Put _PARAM0_ around _PARAM1_, with an angle of _PARAM3_ "
"degrees and _PARAM2_ pixels distance."),
_("Position"),
"res/actions/positionAutour24.png",
"res/actions/positionAutour.png")
.AddParameter("object", _("Object"))
.AddParameter("objectPtr", _("\"Center\" Object"))
.AddParameter("expression", _("Distance"))
.AddParameter("expression", _("Angle, in degrees"))
.MarkAsAdvanced();
// Deprecated action
obj.AddAction("Rebondir",
"Move an object away from another",
"Move an object away from another, using forces.",
"Move _PARAM0_ away from _PARAM1_ (only _PARAM0_ will move)",
_("Movement using forces"),
"res/actions/ecarter24.png",
"res/actions/ecarter.png")
.SetHidden()
.AddParameter("object", _("Object"))
.AddParameter("objectList", "Object 2 (won't move)");
// Deprecated action
obj.AddAction("Ecarter",
"Move an object away from another",
"Move an object away from another without using forces.",
"Move _PARAM0_ away from _PARAM2_ (only _PARAM0_ will move)",
_("Position"),
"res/actions/ecarter24.png",
"res/actions/ecarter.png")
.SetHidden()
.AddParameter("object", _("Object"))
.AddParameter("objectList", "Object 2 (won't move)");
obj.AddAction("SeparateFromObjects",
_("Separate objects"),
_("Move an object away from another using their collision "
"masks.\nBe sure to call this action on a reasonable number "
"of objects\nto avoid slowing down the game."),
_("Move _PARAM0_ away from _PARAM1_ (only _PARAM0_ will move)"),
_("Position"),
"res/actions/ecarter24.png",
"res/actions/ecarter.png")
.AddParameter("object", _("Object"))
.AddParameter("objectList", _("Objects (won't move)"))
.AddParameter("yesorno",
_("Ignore objects that are touching each other on their "
"edges, but are not overlapping (default: no)"),
"",
true)
.SetDefaultValue("no")
.MarkAsSimple();
obj.AddCondition("CollisionPoint",
_("Point inside object"),
_("Test if a point is inside the object collision masks."),
_("_PARAM1_;_PARAM2_ is inside _PARAM0_"),
_("Collision"),
"res/conditions/collisionPoint24.png",
"res/conditions/collisionPoint.png")
.AddParameter("object", _("Object"))
.AddParameter("expression", _("X position of the point"))
.AddParameter("expression", _("Y position of the point"))
.MarkAsSimple();
extension
.AddCondition("SourisSurObjet",
_("The cursor/touch is on an object"),
_("Test if the cursor is over an object, or if the object "
"is being touched."),
_("The cursor/touch is on _PARAM0_"),
_("Mouse and touch"),
"res/conditions/surObjet24.png",
"res/conditions/surObjet.png")
.AddParameter("objectList", _("Object"))
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("yesorno", _("Accurate test (yes by default)"), "", true)
.SetDefaultValue("yes")
.AddCodeOnlyParameter("conditionInverted", "")
.MarkAsSimple();
obj.AddCondition(
"ObjectTimer",
_("Value of an object timer"),
_("Test the elapsed time of an object timer."),
_("The timer _PARAM1_ of _PARAM0_ is greater than _PARAM2_ seconds"),
_("Timers"),
"res/conditions/timer24.png",
"res/conditions/timer.png")
.AddParameter("object", _("Object"))
.AddParameter("string", _("Timer's name"))
.AddParameter("expression", _("Time in seconds"));
obj.AddCondition("ObjectTimerPaused",
_("Object timer paused"),
_("Test if specified object timer is paused."),
_("The timer _PARAM1_ of _PARAM0_ is paused"),
_("Timers"),
"res/conditions/timerPaused24.png",
"res/conditions/timerPaused.png")
.AddParameter("object", _("Object"))
.AddParameter("string", _("Timer's name"))
.MarkAsAdvanced();
obj.AddAction("ResetObjectTimer",
_("Start (or reset) an object timer"),
_("Reset the specified object timer, if the timer doesn't exist "
"it's created and started."),
_("Reset the timer _PARAM1_ of _PARAM0_"),
_("Timers"),
"res/actions/timer24.png",
"res/actions/timer.png")
.AddParameter("object", _("Object"))
.AddParameter("string", _("Timer's name"));
obj.AddAction("PauseObjectTimer",
_("Pause an object timer"),
_("Pause an object timer."),
_("Pause timer _PARAM1_ of _PARAM0_"),
_("Timers"),
"res/actions/pauseTimer24.png",
"res/actions/pauseTimer.png")
.AddParameter("object", _("Object"))
.AddParameter("string", _("Timer's name"))
.MarkAsAdvanced();
obj.AddAction("UnPauseObjectTimer",
_("Unpause an object timer"),
_("Unpause an object timer."),
_("Unpause timer _PARAM1_ of _PARAM0_"),
_("Timers"),
"res/actions/unPauseTimer24.png",
"res/actions/unPauseTimer.png")
.AddParameter("object", _("Object"))
.AddParameter("string", _("Timer's name"))
.MarkAsAdvanced();
obj.AddAction("RemoveObjectTimer",
_("Delete an object timer"),
_("Delete an object timer from memory."),
_("Delete timer _PARAM1_ of _PARAM0_ from memory"),
_("Timers"),
"res/actions/timer24.png",
"res/actions/timer.png")
.AddParameter("object", _("Object"))
.AddParameter("string", _("Timer's name"))
.MarkAsAdvanced();
obj.AddExpression("X",
_("X position"),
_("X position of the object"),
_("Position"),
"res/actions/position.png")
.AddParameter("object", _("Object"));
obj.AddExpression("Y",
_("Y position"),
_("Y position of the object"),
_("Position"),
"res/actions/position.png")
.AddParameter("object", _("Object"));
obj.AddExpression("Angle",
_("Angle"),
_("Current angle, in degrees, of the object"),
_("Angle"),
"res/actions/direction.png")
.AddParameter("object", _("Object"));
obj.AddExpression("ForceX",
_("X coordinate of the sum of forces"),
_("X coordinate of the sum of forces"),
_("Movement using forces"),
"res/actions/force.png")
.AddParameter("object", _("Object"));
obj.AddExpression("ForceY",
_("Y coordinate of the sum of forces"),
_("Y coordinate of the sum of forces"),
_("Movement using forces"),
"res/actions/force.png")
.AddParameter("object", _("Object"));
obj.AddExpression("ForceAngle",
_("Angle of the sum of forces"),
_("Angle of the sum of forces"),
_("Movement using forces"),
"res/actions/force.png")
.AddParameter("object", _("Object"));
obj.AddExpression("ForceLength",
_("Length of the sum of forces"),
_("Length of the sum of forces"),
_("Movement using forces"),
"res/actions/force.png")
.AddParameter("object", _("Object"));
obj.AddExpression("Longueur",
_("Length of the sum of forces"),
_("Length of the sum of forces"),
_("Movement using forces"),
"res/actions/force.png")
.AddParameter("object", _("Object"))
.SetHidden();
obj.AddExpression("Width",
_("Width"),
_("Width of the object"),
_("Size"),
"res/actions/scaleWidth.png")
.AddParameter("object", _("Object"));
obj.AddExpression("Largeur",
_("Width"),
_("Width of the object"),
_("Size"),
"res/actions/scaleWidth.png")
.AddParameter("object", _("Object"))
.SetHidden();
obj.AddExpression("Height",
_("Height"),
_("Height of the object"),
_("Size"),
"res/actions/scaleHeight.png")
.AddParameter("object", _("Object"));
obj.AddExpression("Hauteur",
_("Height"),
_("Height of the object"),
_("Size"),
"res/actions/scaleHeight.png")
.AddParameter("object", _("Object"))
.SetHidden();
obj.AddExpression("ZOrder",
_("Z-order"),
_("Z-order of an object"),
_("Visibility"),
"res/actions/planicon.png")
.AddParameter("object", _("Object"));
obj.AddExpression("Plan",
_("Z-order"),
_("Z-order of an object"),
_("Visibility"),
"res/actions/planicon.png")
.AddParameter("object", _("Object"))
.SetHidden();
obj.AddExpression("Distance",
_("Distance between two objects"),
_("Distance between two objects"),
_("Position"),
"res/conditions/distance.png")
.AddParameter("object", _("Object"))
.AddParameter("objectPtr", _("Object"));
obj.AddExpression("SqDistance",
_("Square distance between two objects"),
_("Square distance between two objects"),
_("Position"),
"res/conditions/distance.png")
.AddParameter("object", _("Object"))
.AddParameter("objectPtr", _("Object"));
obj.AddExpression("DistanceToPosition",
_("Distance between an object and a position"),
_("Distance between an object and a position"),
_("Position"),
"res/conditions/distance.png")
.AddParameter("object", _("Object"))
.AddParameter("expression", _("Target X position"))
.AddParameter("expression", _("Target Y position"));
obj.AddExpression("SqDistanceToPosition",
_("Square distance between an object and a position"),
_("Square distance between an object and a position"),
_("Position"),
"res/conditions/distance.png")
.AddParameter("object", _("Object"))
.AddParameter("expression", _("Target X position"))
.AddParameter("expression", _("Target Y position"));
obj.AddExpression("Variable",
_("Object variable"),
_("Value of an object variable"),
_("Variables"),
"res/actions/var.png")
.AddParameter("object", _("Object"))
.AddParameter("objectvar", _("Variable"));
obj.AddExpression("VariableChildCount",
_("Number of children of an object variable"),
_("Number of children of an object variable"),
_("Variables"),
"res/actions/var.png")
.AddParameter("object", _("Object"))
.AddParameter("objectvar", _("Variable"));
obj.AddStrExpression("VariableString",
_("Object variable"),
_("Text of an object variable"),
_("Variables"),
"res/actions/var.png")
.AddParameter("object", _("Object"))
.AddParameter("objectvar", _("Variable"));
obj.AddExpression("ObjectTimerElapsedTime",
_("Object timer value"),
_("Value of an object timer"),
_("Object timers"),
"res/actions/time.png")
.AddParameter("object", _("Object"))
.AddParameter("string", _("Timer's name"));
obj.AddExpression("AngleToObject",
_("Angle between two objects"),
_("Compute the angle between two objects. If you need the "
"angle to an arbitrary position, use AngleToPosition."),
_("Angle"),
"res/actions/position.png")
.AddParameter("object", _("Object"))
.AddParameter("objectPtr", _("Object"));
obj.AddExpression("XFromAngleAndDistance",
_("X position from angle and distance"),
_("Compute the X position when given an angle and distance "
"relative to the starting object. This is also known as "
"getting the cartesian coordinates of a 2D vector, using "
"its polar coordinates."),
_("Position"),
"res/actions/position.png")
.AddParameter("object", _("Object"))
.AddParameter("expression", _("Angle, in degrees"))
.AddParameter("expression", _("Distance"));
obj.AddExpression("YFromAngleAndDistance",
_("Y position from angle and distance"),
_("Compute the Y position when given an angle and distance "
"relative to the starting object. This is also known as "
"getting the cartesian coordinates of a 2D vector, using "
"its polar coordinates."),
_("Position"),
"res/actions/position.png")
.AddParameter("object", _("Object"))
.AddParameter("expression", _("Angle, in degrees"))
.AddParameter("expression", _("Distance"));
obj.AddExpression("AngleToPosition",
_("Angle between an object and a position"),
_("Compute the angle between the object center and a "
"\"target\" position. If you need the angle between two "
"objects, use AngleToObject."),
_("Angle"),
"res/actions/position.png")
.AddParameter("object", _("Object"))
.AddParameter("expression", _("Target X position"))
.AddParameter("expression", _("Target Y position"));
obj.AddAction("EnableEffect",
_("Enable an object effect"),
_("Enable an effect on the object"),
_("Enable effect _PARAM1_ on _PARAM0_: _PARAM2_"),
_("Effects"),
"res/actions/effect24.png",
"res/actions/effect.png")
.AddParameter("object", _("Object"))
.AddParameter("objectEffectName", _("Effect name"))
.AddParameter("yesorno", _("Enable?"))
.MarkAsSimple();
obj.AddAction("SetEffectDoubleParameter",
_("Effect parameter (number)"),
_("Change the value of a parameter of an effect.") + "\n" +
_("You can find the parameter names (and change the effect "
"names) in the effects window."),
_("Set _PARAM2_ to _PARAM3_ for effect _PARAM1_ of _PARAM0_"),
_("Effects"),
"res/actions/effect24.png",
"res/actions/effect.png")
.AddParameter("object", _("Object"))
.AddParameter("objectEffectName", _("Effect name"))
.AddParameter("objectEffectParameterName", _("Parameter name"))
.AddParameter("expression", _("New value"))
.MarkAsSimple();
obj.AddAction("SetEffectStringParameter",
_("Effect parameter (string)"),
_("Change the value (string) of a parameter of an effect.") + "\n" +
_("You can find the parameter names (and change the effect "
"names) in the effects window."),
_("Set _PARAM2_ to _PARAM3_ for effect _PARAM1_ of _PARAM0_"),
_("Effects"),
"res/actions/effect24.png",
"res/actions/effect.png")
.AddParameter("object", _("Object"))
.AddParameter("objectEffectName", _("Effect name"))
.AddParameter("objectEffectParameterName", _("Parameter name"))
.AddParameter("string", _("New value"))
.MarkAsSimple();
obj.AddAction("SetEffectBooleanParameter",
_("Effect parameter (enable or disable)"),
_("Enable or disable a parameter of an effect.") + "\n" +
_("You can find the parameter names (and change the effect "
"names) in the effects window."),
_("Enable _PARAM2_ for effect _PARAM1_ of _PARAM0_: _PARAM3_"),
_("Effects"),
"res/actions/effect24.png",
"res/actions/effect.png")
.AddParameter("object", _("Object"))
.AddParameter("objectEffectName", _("Effect name"))
.AddParameter("objectEffectParameterName", _("Parameter name"))
.AddParameter("yesorno", _("Enable?"))
.MarkAsSimple();
obj.AddCondition("IsEffectEnabled",
_("Effect is enabled"),
_("Check if the effect on an object is enabled."),
_("Effect _PARAM1_ of _PARAM0_ is enabled"),
_("Effects"),
"res/actions/effect24.png",
"res/actions/effect.png")
.AddParameter("object", _("Object"))
.AddParameter("objectEffectName", _("Effect name"))
.MarkAsSimple();
extension
.AddAction("Create",
_("Create an object"),
_("Create an object at specified position"),
_("Create object _PARAM1_ at position _PARAM2_;_PARAM3_"),
_("Objects"),
"res/actions/create24.png",
"res/actions/create.png")
.AddCodeOnlyParameter("objectsContext", "")
.AddParameter("objectListWithoutPicking", _("Object to create"))
.AddParameter("expression", _("X position"))
.AddParameter("expression", _("Y position"))
.AddParameter("layer", _("Layer (base layer if empty)"), "", true)
.SetDefaultValue("\"\"")
.MarkAsSimple();
extension
.AddAction("CreateByName",
_("Create an object from its name"),
_("Among the objects of the specified group, this action will "
"create the object with the specified name."),
_("Among objects _PARAM1_, create object named _PARAM2_ at "
"position _PARAM3_;_PARAM4_"),
_("Objects"),
"res/actions/create24.png",
"res/actions/create.png")
.AddCodeOnlyParameter("objectsContext", "")
.AddParameter("objectListWithoutPicking", _("Group of potential objects"))
.SetParameterLongDescription(
_("Group containing objects that can be created by the action."))
.AddParameter("string", _("Name of the object to create"))
.SetParameterLongDescription(_(
"Text representing the name of the object to create. If no objects "
"with this name are found in the group, no object will be created."))
.AddParameter("expression", _("X position"))
.AddParameter("expression", _("Y position"))
.AddParameter("layer", _("Layer (base layer if empty)"), "", true)
.SetDefaultValue("\"\"")
.MarkAsAdvanced();
extension
.AddAction("AjoutObjConcern",
_("Pick all instances"),
_("Pick all instances of the specified object(s). When you "
"pick all instances, "
"the next conditions and actions of this event work on all "
"of them."),
_("Pick all instances of _PARAM1_"),
_("Objects"),
"res/actions/add24.png",
"res/actions/add.png")
.AddCodeOnlyParameter("objectsContext", "")
.AddParameter("objectList", _("Object"))
.MarkAsAdvanced();
extension
.AddAction(
"AjoutHasard",
_("Pick a random object"),
_("Pick one object from all the specified objects. When an object "
"is picked, the next conditions and actions of this event work "
"only on that object."),
_("Pick a random _PARAM1_"),
_("Objects"),
"res/actions/ajouthasard24.png",
"res/actions/ajouthasard.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("objectList", _("Object"))
.MarkAsSimple();
extension
.AddAction(
"MoveObjects",
_("Apply movement to all objects"),
_("Moves all objects according to the forces they have. GDevelop "
"calls this action at the end of the events by default."),
_("Apply movement to all objects"),
_("Movement using forces"),
"res/actions/doMove24.png",
"res/actions/doMove.png")
.AddCodeOnlyParameter("currentScene", "")
.MarkAsAdvanced();
extension
.AddCondition("SeDirige",
_("An object is moving toward another (using forces)"),
_("Check if an object moves toward another.\nThe first "
"object must move."),
_("_PARAM0_ is moving toward _PARAM1_"),
_("Movement using forces"),
"res/conditions/sedirige24.png",
"res/conditions/sedirige.png")
.AddParameter("objectList", _("Object"))
.AddParameter("objectList", _("Object 2"))
.AddParameter("expression", _("Tolerance, in degrees"))
.AddCodeOnlyParameter("conditionInverted", "")
.MarkAsAdvanced();
extension
.AddCondition("Distance",
_("Distance between two objects"),
_("Compare the distance between two objects.\nIf condition "
"is inverted, only objects that have a distance greater "
"than specified to any other object will be picked."),
_("_PARAM0_ distance to _PARAM1_ is below _PARAM2_ pixels"),
_("Position"),
"res/conditions/distance24.png",
"res/conditions/distance.png")
.AddParameter("objectList", _("Object"))
.AddParameter("objectList", _("Object 2"))
.AddParameter("expression", _("Distance"))
.AddCodeOnlyParameter("conditionInverted", "")
.MarkAsSimple();
extension
.AddCondition(
"AjoutObjConcern",
_("Pick all objects"),
_("Pick all the specified objects. When you pick all objects, "
"the next conditions and actions of this event work on all "
"of them."),
_("Pick all _PARAM1_ objects"),
_("Objects"),
"res/conditions/add24.png",
"res/conditions/add.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("objectList", _("Object"))
.MarkAsAdvanced();
extension
.AddCondition(
"AjoutHasard",
_("Pick a random object"),
_("Pick one object from all the specified objects. When an object "
"is picked, the next conditions and actions of this event work "
"only on that object."),
_("Pick a random _PARAM1_"),
_("Objects"),
"res/conditions/ajouthasard24.png",
"res/conditions/ajouthasard.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("objectList", _("Object"))
.MarkAsSimple();
extension
.AddCondition(
"PickNearest",
_("Pick nearest object"),
_("Pick the object of this type that is nearest to the specified "
"position. If the condition is inverted, the object farthest from "
"the specified position is picked instead."),
_("Pick the _PARAM0_ that is nearest to _PARAM1_;_PARAM2_"),
_("Objects"),
"res/conditions/distance24.png",
"res/conditions/distance.png")
.AddParameter("objectList", _("Object"))
.AddParameter("expression", _("X position"))
.AddParameter("expression", _("Y position"))
.AddCodeOnlyParameter("conditionInverted", "")
.MarkAsSimple();
extension
.AddCondition(
"NbObjet",
_("Number of objects"),
_("Count how many of the specified objects are currently picked, and "
"compare that number to a value. If previous conditions on the "
"objects have not been used, this condition counts how many of "
"these objects exist in the current scene."),
_("the number of _PARAM0_ objects"),
_("Objects"),
"res/conditions/nbObjet24.png",
"res/conditions/nbObjet.png")
.AddParameter("objectList", _("Object"))
.UseStandardRelationalOperatorParameters("number")
.MarkAsSimple();
extension
.AddCondition(
"CollisionNP", //"CollisionNP" cames from an old condition to test
// collision between two sprites non precisely.
_("Collision"),
_("Test the collision between two objects using their collision "
"masks.\nNote that some objects may not have collision "
"masks.\nSome others, like Sprite objects, also provide more "
"precise collision conditions."),
_("_PARAM0_ is in collision with _PARAM1_"),
_("Collision"),
"res/conditions/collision24.png",
"res/conditions/collision.png")
.AddParameter("objectList", _("Object"))
.AddParameter("objectList", _("Object"))
.AddCodeOnlyParameter("conditionInverted", "")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("yesorno",
_("Ignore objects that are touching each other on their "
"edges, but are not overlapping (default: no)"),
"",
true)
.SetDefaultValue("no")
.MarkAsSimple();
extension
.AddCondition("EstTourne",
_("An object is turned toward another"),
_("Check if an object is turned toward another"),
_("_PARAM0_ is rotated towards _PARAM1_"),
_("Angle"),
"res/conditions/estTourne24.png",
"res/conditions/estTourne.png")
.AddParameter("objectList", _("Name of the object"))
.AddParameter("objectList", _("Name of the second object"))
.AddParameter("expression",
_("Angle of tolerance, in degrees (0: minimum tolerance)"))
.AddCodeOnlyParameter("conditionInverted", "")
.MarkAsAdvanced();
extension
.AddCondition(
"Raycast",
_("Raycast"),
_("Sends a ray from the given source position and angle, "
"intersecting the closest object.\nThe instersected "
"object will become the only one taken into account.\nIf "
"the condition is inverted, the object to be intersected "
"will be the farthest one within the ray radius."),
_("Cast a ray from _PARAM1_;_PARAM2_, angle: _PARAM3_ and max "
"distance: _PARAM4_px, against _PARAM0_, and save the "
"result in _PARAM5_, _PARAM6_"),
_("Collision"),
"res/conditions/raycast24.png",
"res/conditions/raycast.png")
.AddParameter("objectList", _("Objects to test against the ray"))
.AddParameter("expression", _("Ray source X position"))
.AddParameter("expression", _("Ray source Y position"))
.AddParameter("expression", _("Ray angle (in degrees)"))
.AddParameter("expression", _("Ray maximum distance (in pixels)"))
.AddParameter("scenevar", _("Result X position scene variable"))
.SetParameterLongDescription(
_("Scene variable where to store the X position of the intersection. "
"If no intersection is found, the variable won't be changed."))
.AddParameter("scenevar", _("Result Y position scene variable"))
.SetParameterLongDescription(
_("Scene variable where to store the Y position of the intersection. "
"If no intersection is found, the variable won't be changed."))
.AddCodeOnlyParameter("conditionInverted", "")
.MarkAsAdvanced();
extension
.AddCondition(
"RaycastToPosition",
_("Raycast to position"),
_("Sends a ray from the given source position to the final point, "
"intersecting the closest object.\nThe instersected "
"object will become the only one taken into account.\nIf "
"the condition is inverted, the object to be intersected "
"will be the farthest one within the ray radius."),
_("Cast a ray from from _PARAM1_;_PARAM2_ to _PARAM3_;_PARAM4_ "
"against _PARAM0_, and save the "
"result in _PARAM5_, _PARAM6_"),
_("Collision"),
"res/conditions/raycast24.png",
"res/conditions/raycast.png")
.AddParameter("objectList", _("Objects to test against the ray"))
.AddParameter("expression", _("Ray source X position"))
.AddParameter("expression", _("Ray source Y position"))
.AddParameter("expression", _("Ray target X position"))
.AddParameter("expression", _("Ray target Y position"))
.AddParameter("scenevar", _("Result X position scene variable"))
.SetParameterLongDescription(
_("Scene variable where to store the X position of the intersection. "
"If no intersection is found, the variable won't be changed."))
.AddParameter("scenevar", _("Result Y position scene variable"))
.SetParameterLongDescription(
_("Scene variable where to store the Y position of the intersection. "
"If no intersection is found, the variable won't be changed."))
.AddCodeOnlyParameter("conditionInverted", "")
.MarkAsAdvanced();
extension
.AddExpression("Count",
_("Number of objects"),
_("Count the number of the specified objects being "
"currently picked in the event"),
_("Objects"),
"res/conditions/nbObjet.png")
.AddParameter("objectList", _("Object"));
obj.AddStrExpression("ObjectName",
_("Object name"),
_("Return the name of the object"),
_("Objects"),
"res/conditions/text.png")
.AddParameter("object", _("Object"));
obj.AddStrExpression("Layer",
_("Object layer"),
_("Return the name of the layer the object is on"),
_("Objects"),
"res/actions/layer.png")
.AddParameter("object", _("Object"));
#endif
}
} // namespace gd
|
//////////////////////////////////////////////////////////////////////////////
// astro_blackhole_code.asm
// Copyright(c) 2021 Neal Smith.
// License: MIT. See LICENSE file in root directory.
//////////////////////////////////////////////////////////////////////////////
// The following subroutines should be called from the main engine
// as follows
// HoleInit: Call once before main loop
// HoleStep: Call once every raster frame through the main loop
// HoleStart: Call to start the effect
// HoleForceStop: Call to force effect to stop if it is active
// HoleCleanup: Call at end of program after main loop to clean up
//////////////////////////////////////////////////////////////////////////////
#importonce
#import "../nv_c64_util/nv_c64_util_macs_and_data.asm"
#import "astro_vars_data.asm"
#import "astro_blackhole_data.asm"
#import "astro_ships_code.asm"
#import "../nv_c64_util/nv_rand_macs.asm"
//////////////////////////////////////////////////////////////////////////////
// subroutine to start the initialize effect, call once before main loop
HoleInit:
{
// reduce velocity while count greater than 0
lda #$00
sta hole_count
sta hole_hit
jsr blackhole.Setup
jsr blackhole.SetLocationFromExtraData
rts
}
//////////////////////////////////////////////////////////////////////////////
// subroutine to start the effect
HoleStart:
{
lda hole_count
bne HoleAlreadyStarted
lda #HOLE_FRAMES
sta hole_count
lda #HOLE_FRAMES_BETWEEN_STEPS
sta hole_frame_counter
// start sprite out at first frame of its animation
ldx #<sprite_hole_0
lda #>sprite_hole_0
jsr blackhole.SetDataPtr
nv_store16_immed(blackhole.x_loc, NV_SPRITE_RIGHT_WRAP_DEFAULT)
//lda #NV_SPRITE_TOP_WRAP_DEFAULT
nv_rand_byte_a(true)
//and #$7F
clc
adc #NV_SPRITE_TOP_WRAP_DEFAULT
// set Y velocity. start with positive 1 but
// get random bit to decide to change
sta blackhole.y_loc
lda #1
sta blackhole.y_vel
nv_rand_byte_a(true)
sta hole_change_vel_at_x_loc
and #$01
bne SkipNegVelY
NegVelY:
lda #$FF
sta blackhole.y_vel
SkipNegVelY:
lda #$FF
sta blackhole.x_vel
jsr blackhole.Enable
HoleAlreadyStarted:
rts
}
//////////////////////////////////////////////////////////////////////////////
// Subroutine to determine if hole is active
// Accum: will be set to non zero if active or zero if not active
HoleActive:
{
lda hole_count
rts
}
//
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
// subroutine to call once per raster frame while blackhole is active
// if hole_count is zero then this routine will do nothing.
// continually calling the routine will eventually get to
// the state of hole_count = 0 so its safe
// to call this once every raster frame regardless of if effect is active
// or not.
HoleStep:
{
lda hole_count
bne HoleStillStepping
rts
HoleStillStepping:
// sprite movement, every frame
// change the Y velocity of hole when its left of
// the hole_change_vel_at_x_loc
lda hole_change_vel_at_x_loc
cmp blackhole.x_loc // set carry if accum >= Mem
bcc NoChange // branch if hole x_loc < hole_change_at_x_loc
Change:
nv_rand_byte_a(true) // get random byte in Accum
and #$3F // make sure its not bigger than 63
sta scratch_byte // store this random num betwn 0-63
lda hole_change_vel_at_x_loc // setup to subtract the random from
sec // the last change location
sbc scratch_byte // do subtraction
sta hole_change_vel_at_x_loc // save the next x location to change
nv_rand_byte_a(true) // get new random byte
and #$03 // make sure its between 0 and 3
tax // use the rand between 0-3 as index
lda y_vel_table,x // look up the new y vel in table
sta blackhole.y_vel // store new y vel
NoChange:
jsr blackhole.MoveInExtraData
nv_bgt16_immed(blackhole.x_loc, 20, HoleStillAlive)
// hole is done if we get here
jsr HoleForceStop
rts
HoleStillAlive:
// update in memory location based on velocity
jsr blackhole.SetLocationFromExtraData
// update the hitbox based on updated location
jsr HoleUpdateRect
// check if time to animate the sprite
dec hole_frame_counter
bne HoleStepDone // if not zero then not time yet
// is time to animate sprite
// reset our frame counter between animation steps
lda #HOLE_FRAMES_BETWEEN_STEPS
sta hole_frame_counter
// get zero based frame number into y reg
// then multiply by two to get the index
// into our sprite data ptr address table
lda #HOLE_FRAMES
sec
sbc hole_count
asl
tay // y reg now holds index into table of the
// byte that has the LSB of the sprite data ptr
// LSB of sprite's data ptr to x and
// MSB to Accum so we can call the SetDataPtr
ldx hole_sprite_data_ptr_table, y
iny
lda hole_sprite_data_ptr_table, y
jsr blackhole.SetDataPtr
// decrement the count
dec hole_count
bne HoleStepDone
lda #HOLE_FRAMES-2 // last few frames repeat
//lda #HOLE_FRAMES
sta hole_count
HoleStepDone:
rts
y_vel_table:
.byte $00
.byte $01
.byte $FF
.byte $00
}
// HoleStep End.
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
// subroutine to call to force the effect to stop if it is active. if not
// active then should have no effect
HoleForceStop:
{
lda #$00
sta hole_count
sta hole_hit
jsr blackhole.Disable
rts
}
// HoleForceStop End
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
// subroutine to call at end of program when done with all other effect
// data and routines.
HoleCleanup:
jsr HoleForceStop
rts
// HoleCleanup End
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
// internal subroutine to update the hole_rect. should be called whenever
// the sprites location in memory is updated
HoleUpdateRect:
{
/////////// put hole sprite's rectangle, use the hitbox not full sprite
nv_xfer16_mem_mem(blackhole.x_loc, hole_x_left)
nv_adc16x_mem16x_mem8u(hole_x_left, blackhole.hitbox_right, hole_x_right)
nv_adc16x_mem16x_mem8u(hole_x_left, blackhole.hitbox_left, hole_x_left)
lda blackhole.y_loc // 8 bit value so manually load MSB with $00
sta hole_y_top
lda #$00
sta hole_y_top+1
nv_adc16x_mem16x_mem8u(hole_y_top, blackhole.hitbox_bottom, hole_y_bottom)
nv_adc16x_mem16x_mem8u(hole_y_top, blackhole.hitbox_top, hole_y_top)
rts
}
// HoleUpdateRect - end
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
// Namespace with everything related to asteroid 5
.namespace blackhole
{
.var info = nv_sprite_info_struct("black_hole", 6,
200, 100, -1, 0, // init x, y, VelX, VelY
sprite_hole_0,
sprite_extra,
1, 0, 1, 0, // bounce on top, left, bottom, right
0, 0, 0, 0, // min/max top, left, bottom, right
0, // sprite enabled
0, 0, 24, 21) // hitbox left, top, right, bottom
.label x_loc = info.base_addr + NV_SPRITE_X_OFFSET
.label y_loc = info.base_addr + NV_SPRITE_Y_OFFSET
.label x_vel = info.base_addr + NV_SPRITE_VEL_X_OFFSET
.label y_vel = info.base_addr + NV_SPRITE_VEL_Y_OFFSET
.label data_ptr = info.base_addr + NV_SPRITE_DATA_PTR_OFFSET
.label sprite_num = info.base_addr + NV_SPRITE_NUM_OFFSET
.label hitbox_left = info.base_addr + NV_SPRITE_HITBOX_LEFT_OFFSET
.label hitbox_top = info.base_addr + NV_SPRITE_HITBOX_TOP_OFFSET
.label hitbox_right = info.base_addr + NV_SPRITE_HITBOX_RIGHT_OFFSET
.label hitbox_bottom = info.base_addr + NV_SPRITE_HITBOX_BOTTOM_OFFSET
// sprite extra data
sprite_extra:
nv_sprite_extra_data(info)
LoadExtraPtrToRegs:
lda #>info.base_addr
ldx #<info.base_addr
rts
// subroutine to set sprites location in sprite registers based on the extra data
SetLocationFromExtraData:
lda #>info.base_addr
ldx #<info.base_addr
jsr NvSpriteSetLocationFromExtra
rts
// setup sprite so that it ready to be enabled and displayed
Setup:
lda #>info.base_addr
ldx #<info.base_addr
jsr NvSpriteSetupFromExtra
rts
// move the sprite x and y location in the extra data only, not in the sprite registers
// to move in the sprite registsers (and have screen reflect it) call the
// SetLocationFromExtraData subroutine.
MoveInExtraData:
//lda #>info.base_addr
//ldx #<info.base_addr
//jsr NvSpriteMoveInExtra
//rts
nv_sprite_move_any_direction_sr(info)
Enable:
lda #>info.base_addr
ldx #<info.base_addr
nv_sprite_extra_enable_sr()
Disable:
lda #>info.base_addr
ldx #<info.base_addr
nv_sprite_extra_disable_sr()
LoadEnabledToA:
lda info.base_addr + NV_SPRITE_ENABLED_OFFSET
rts
SetBounceAllOn:
nv_sprite_set_all_actions_sr(info, NV_SPRITE_ACTION_BOUNCE)
SetWrapAllOn:
nv_sprite_set_all_actions_sr(info, NV_SPRITE_ACTION_WRAP)
// Accum must have MSB of new data_ptr
// X Reg must have LSB of new data_ptr
SetDataPtr:
stx data_ptr
sta data_ptr+1
// Accum: MSB of address of nv_sprite_extra_data
// X Reg: LSB of address of the nv_sprite_extra_data
lda #>info.base_addr
ldx #<info.base_addr
jsr NvSpriteSetDataPtrFromExtra
rts
}
|
; Original address was $B908
; 7-6
.word $0000 ; Alternate level layout
.word $0000 ; Alternate object layout
.byte LEVEL1_SIZE_01 | LEVEL1_YSTART_170
.byte LEVEL2_BGPAL_00 | LEVEL2_OBJPAL_08 | LEVEL2_XSTART_18
.byte LEVEL3_TILESET_00 | LEVEL3_VSCROLL_LOCKLOW
.byte LEVEL4_BGBANK_INDEX(0) | LEVEL4_INITACT_NOTHING
.byte LEVEL5_BGM_UNDERWATER | LEVEL5_TIME_300
.byte $FF
|
;
; jidctflt.asm - floating-point IDCT (64-bit SSE & SSE2)
;
; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
; Copyright (C) 2009, 2016, D. R. Commander.
;
; Based on the x86 SIMD extension for IJG JPEG library
; Copyright (C) 1999-2006, MIYASAKA Masaru.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
; This file should be assembled with NASM (Netwide Assembler),
; can *not* be assembled with Microsoft's MASM or any compatible
; assembler (including Borland's Turbo Assembler).
; NASM is available from http://nasm.sourceforge.net/ or
; http://sourceforge.net/project/showfiles.php?group_id=6208
;
; This file contains a floating-point implementation of the inverse DCT
; (Discrete Cosine Transform). The following code is based directly on
; the IJG's original jidctflt.c; see the jidctflt.c for more details.
;
; [TAB8]
%include "jsimdext.inc"
%include "jdct.inc"
; --------------------------------------------------------------------------
%macro unpcklps2 2 ; %1=(0 1 2 3) / %2=(4 5 6 7) => %1=(0 1 4 5)
shufps %1, %2, 0x44
%endmacro
%macro unpckhps2 2 ; %1=(0 1 2 3) / %2=(4 5 6 7) => %1=(2 3 6 7)
shufps %1, %2, 0xEE
%endmacro
; --------------------------------------------------------------------------
SECTION SEG_CONST
alignz 32
GLOBAL_DATA(jconst_idct_float_sse2)
EXTN(jconst_idct_float_sse2):
PD_1_414 times 4 dd 1.414213562373095048801689
PD_1_847 times 4 dd 1.847759065022573512256366
PD_1_082 times 4 dd 1.082392200292393968799446
PD_M2_613 times 4 dd -2.613125929752753055713286
PD_RNDINT_MAGIC times 4 dd 100663296.0 ; (float)(0x00C00000 << 3)
PB_CENTERJSAMP times 16 db CENTERJSAMPLE
alignz 32
; --------------------------------------------------------------------------
SECTION SEG_TEXT
BITS 64
;
; Perform dequantization and inverse DCT on one block of coefficients.
;
; GLOBAL(void)
; jsimd_idct_float_sse2(void *dct_table, JCOEFPTR coef_block,
; JSAMPARRAY output_buf, JDIMENSION output_col)
;
; r10 = void *dct_table
; r11 = JCOEFPTR coef_block
; r12 = JSAMPARRAY output_buf
; r13d = JDIMENSION output_col
%define original_rbp rbp + 0
%define wk(i) rbp - (WK_NUM - (i)) * SIZEOF_XMMWORD
; xmmword wk[WK_NUM]
%define WK_NUM 2
%define workspace wk(0) - DCTSIZE2 * SIZEOF_FAST_FLOAT
; FAST_FLOAT workspace[DCTSIZE2]
align 32
GLOBAL_FUNCTION(jsimd_idct_float_sse2)
EXTN(jsimd_idct_float_sse2):
push rbp
mov rax, rsp ; rax = original rbp
sub rsp, byte 4
and rsp, byte (-SIZEOF_XMMWORD) ; align to 128 bits
mov [rsp], rax
mov rbp, rsp ; rbp = aligned rbp
lea rsp, [workspace]
collect_args 4
push rbx
; ---- Pass 1: process columns from input, store into work array.
mov rdx, r10 ; quantptr
mov rsi, r11 ; inptr
lea rdi, [workspace] ; FAST_FLOAT *wsptr
mov rcx, DCTSIZE/4 ; ctr
.columnloop:
%ifndef NO_ZERO_COLUMN_TEST_FLOAT_SSE
mov eax, DWORD [DWBLOCK(1,0,rsi,SIZEOF_JCOEF)]
or eax, DWORD [DWBLOCK(2,0,rsi,SIZEOF_JCOEF)]
jnz near .columnDCT
movq xmm1, XMM_MMWORD [MMBLOCK(1,0,rsi,SIZEOF_JCOEF)]
movq xmm2, XMM_MMWORD [MMBLOCK(2,0,rsi,SIZEOF_JCOEF)]
movq xmm3, XMM_MMWORD [MMBLOCK(3,0,rsi,SIZEOF_JCOEF)]
movq xmm4, XMM_MMWORD [MMBLOCK(4,0,rsi,SIZEOF_JCOEF)]
movq xmm5, XMM_MMWORD [MMBLOCK(5,0,rsi,SIZEOF_JCOEF)]
movq xmm6, XMM_MMWORD [MMBLOCK(6,0,rsi,SIZEOF_JCOEF)]
movq xmm7, XMM_MMWORD [MMBLOCK(7,0,rsi,SIZEOF_JCOEF)]
por xmm1, xmm2
por xmm3, xmm4
por xmm5, xmm6
por xmm1, xmm3
por xmm5, xmm7
por xmm1, xmm5
packsswb xmm1, xmm1
movd eax, xmm1
test rax, rax
jnz short .columnDCT
; -- AC terms all zero
movq xmm0, XMM_MMWORD [MMBLOCK(0,0,rsi,SIZEOF_JCOEF)]
punpcklwd xmm0, xmm0 ; xmm0=(00 00 01 01 02 02 03 03)
psrad xmm0, (DWORD_BIT-WORD_BIT) ; xmm0=in0=(00 01 02 03)
cvtdq2ps xmm0, xmm0 ; xmm0=in0=(00 01 02 03)
mulps xmm0, XMMWORD [XMMBLOCK(0,0,rdx,SIZEOF_FLOAT_MULT_TYPE)]
movaps xmm1, xmm0
movaps xmm2, xmm0
movaps xmm3, xmm0
shufps xmm0, xmm0, 0x00 ; xmm0=(00 00 00 00)
shufps xmm1, xmm1, 0x55 ; xmm1=(01 01 01 01)
shufps xmm2, xmm2, 0xAA ; xmm2=(02 02 02 02)
shufps xmm3, xmm3, 0xFF ; xmm3=(03 03 03 03)
movaps XMMWORD [XMMBLOCK(0,0,rdi,SIZEOF_FAST_FLOAT)], xmm0
movaps XMMWORD [XMMBLOCK(0,1,rdi,SIZEOF_FAST_FLOAT)], xmm0
movaps XMMWORD [XMMBLOCK(1,0,rdi,SIZEOF_FAST_FLOAT)], xmm1
movaps XMMWORD [XMMBLOCK(1,1,rdi,SIZEOF_FAST_FLOAT)], xmm1
movaps XMMWORD [XMMBLOCK(2,0,rdi,SIZEOF_FAST_FLOAT)], xmm2
movaps XMMWORD [XMMBLOCK(2,1,rdi,SIZEOF_FAST_FLOAT)], xmm2
movaps XMMWORD [XMMBLOCK(3,0,rdi,SIZEOF_FAST_FLOAT)], xmm3
movaps XMMWORD [XMMBLOCK(3,1,rdi,SIZEOF_FAST_FLOAT)], xmm3
jmp near .nextcolumn
%endif
.columnDCT:
; -- Even part
movq xmm0, XMM_MMWORD [MMBLOCK(0,0,rsi,SIZEOF_JCOEF)]
movq xmm1, XMM_MMWORD [MMBLOCK(2,0,rsi,SIZEOF_JCOEF)]
movq xmm2, XMM_MMWORD [MMBLOCK(4,0,rsi,SIZEOF_JCOEF)]
movq xmm3, XMM_MMWORD [MMBLOCK(6,0,rsi,SIZEOF_JCOEF)]
punpcklwd xmm0, xmm0 ; xmm0=(00 00 01 01 02 02 03 03)
punpcklwd xmm1, xmm1 ; xmm1=(20 20 21 21 22 22 23 23)
psrad xmm0, (DWORD_BIT-WORD_BIT) ; xmm0=in0=(00 01 02 03)
psrad xmm1, (DWORD_BIT-WORD_BIT) ; xmm1=in2=(20 21 22 23)
cvtdq2ps xmm0, xmm0 ; xmm0=in0=(00 01 02 03)
cvtdq2ps xmm1, xmm1 ; xmm1=in2=(20 21 22 23)
punpcklwd xmm2, xmm2 ; xmm2=(40 40 41 41 42 42 43 43)
punpcklwd xmm3, xmm3 ; xmm3=(60 60 61 61 62 62 63 63)
psrad xmm2, (DWORD_BIT-WORD_BIT) ; xmm2=in4=(40 41 42 43)
psrad xmm3, (DWORD_BIT-WORD_BIT) ; xmm3=in6=(60 61 62 63)
cvtdq2ps xmm2, xmm2 ; xmm2=in4=(40 41 42 43)
cvtdq2ps xmm3, xmm3 ; xmm3=in6=(60 61 62 63)
mulps xmm0, XMMWORD [XMMBLOCK(0,0,rdx,SIZEOF_FLOAT_MULT_TYPE)]
mulps xmm1, XMMWORD [XMMBLOCK(2,0,rdx,SIZEOF_FLOAT_MULT_TYPE)]
mulps xmm2, XMMWORD [XMMBLOCK(4,0,rdx,SIZEOF_FLOAT_MULT_TYPE)]
mulps xmm3, XMMWORD [XMMBLOCK(6,0,rdx,SIZEOF_FLOAT_MULT_TYPE)]
movaps xmm4, xmm0
movaps xmm5, xmm1
subps xmm0, xmm2 ; xmm0=tmp11
subps xmm1, xmm3
addps xmm4, xmm2 ; xmm4=tmp10
addps xmm5, xmm3 ; xmm5=tmp13
mulps xmm1, [rel PD_1_414]
subps xmm1, xmm5 ; xmm1=tmp12
movaps xmm6, xmm4
movaps xmm7, xmm0
subps xmm4, xmm5 ; xmm4=tmp3
subps xmm0, xmm1 ; xmm0=tmp2
addps xmm6, xmm5 ; xmm6=tmp0
addps xmm7, xmm1 ; xmm7=tmp1
movaps XMMWORD [wk(1)], xmm4 ; tmp3
movaps XMMWORD [wk(0)], xmm0 ; tmp2
; -- Odd part
movq xmm2, XMM_MMWORD [MMBLOCK(1,0,rsi,SIZEOF_JCOEF)]
movq xmm3, XMM_MMWORD [MMBLOCK(3,0,rsi,SIZEOF_JCOEF)]
movq xmm5, XMM_MMWORD [MMBLOCK(5,0,rsi,SIZEOF_JCOEF)]
movq xmm1, XMM_MMWORD [MMBLOCK(7,0,rsi,SIZEOF_JCOEF)]
punpcklwd xmm2, xmm2 ; xmm2=(10 10 11 11 12 12 13 13)
punpcklwd xmm3, xmm3 ; xmm3=(30 30 31 31 32 32 33 33)
psrad xmm2, (DWORD_BIT-WORD_BIT) ; xmm2=in1=(10 11 12 13)
psrad xmm3, (DWORD_BIT-WORD_BIT) ; xmm3=in3=(30 31 32 33)
cvtdq2ps xmm2, xmm2 ; xmm2=in1=(10 11 12 13)
cvtdq2ps xmm3, xmm3 ; xmm3=in3=(30 31 32 33)
punpcklwd xmm5, xmm5 ; xmm5=(50 50 51 51 52 52 53 53)
punpcklwd xmm1, xmm1 ; xmm1=(70 70 71 71 72 72 73 73)
psrad xmm5, (DWORD_BIT-WORD_BIT) ; xmm5=in5=(50 51 52 53)
psrad xmm1, (DWORD_BIT-WORD_BIT) ; xmm1=in7=(70 71 72 73)
cvtdq2ps xmm5, xmm5 ; xmm5=in5=(50 51 52 53)
cvtdq2ps xmm1, xmm1 ; xmm1=in7=(70 71 72 73)
mulps xmm2, XMMWORD [XMMBLOCK(1,0,rdx,SIZEOF_FLOAT_MULT_TYPE)]
mulps xmm3, XMMWORD [XMMBLOCK(3,0,rdx,SIZEOF_FLOAT_MULT_TYPE)]
mulps xmm5, XMMWORD [XMMBLOCK(5,0,rdx,SIZEOF_FLOAT_MULT_TYPE)]
mulps xmm1, XMMWORD [XMMBLOCK(7,0,rdx,SIZEOF_FLOAT_MULT_TYPE)]
movaps xmm4, xmm2
movaps xmm0, xmm5
addps xmm2, xmm1 ; xmm2=z11
addps xmm5, xmm3 ; xmm5=z13
subps xmm4, xmm1 ; xmm4=z12
subps xmm0, xmm3 ; xmm0=z10
movaps xmm1, xmm2
subps xmm2, xmm5
addps xmm1, xmm5 ; xmm1=tmp7
mulps xmm2, [rel PD_1_414] ; xmm2=tmp11
movaps xmm3, xmm0
addps xmm0, xmm4
mulps xmm0, [rel PD_1_847] ; xmm0=z5
mulps xmm3, [rel PD_M2_613] ; xmm3=(z10 * -2.613125930)
mulps xmm4, [rel PD_1_082] ; xmm4=(z12 * 1.082392200)
addps xmm3, xmm0 ; xmm3=tmp12
subps xmm4, xmm0 ; xmm4=tmp10
; -- Final output stage
subps xmm3, xmm1 ; xmm3=tmp6
movaps xmm5, xmm6
movaps xmm0, xmm7
addps xmm6, xmm1 ; xmm6=data0=(00 01 02 03)
addps xmm7, xmm3 ; xmm7=data1=(10 11 12 13)
subps xmm5, xmm1 ; xmm5=data7=(70 71 72 73)
subps xmm0, xmm3 ; xmm0=data6=(60 61 62 63)
subps xmm2, xmm3 ; xmm2=tmp5
movaps xmm1, xmm6 ; transpose coefficients(phase 1)
unpcklps xmm6, xmm7 ; xmm6=(00 10 01 11)
unpckhps xmm1, xmm7 ; xmm1=(02 12 03 13)
movaps xmm3, xmm0 ; transpose coefficients(phase 1)
unpcklps xmm0, xmm5 ; xmm0=(60 70 61 71)
unpckhps xmm3, xmm5 ; xmm3=(62 72 63 73)
movaps xmm7, XMMWORD [wk(0)] ; xmm7=tmp2
movaps xmm5, XMMWORD [wk(1)] ; xmm5=tmp3
movaps XMMWORD [wk(0)], xmm0 ; wk(0)=(60 70 61 71)
movaps XMMWORD [wk(1)], xmm3 ; wk(1)=(62 72 63 73)
addps xmm4, xmm2 ; xmm4=tmp4
movaps xmm0, xmm7
movaps xmm3, xmm5
addps xmm7, xmm2 ; xmm7=data2=(20 21 22 23)
addps xmm5, xmm4 ; xmm5=data4=(40 41 42 43)
subps xmm0, xmm2 ; xmm0=data5=(50 51 52 53)
subps xmm3, xmm4 ; xmm3=data3=(30 31 32 33)
movaps xmm2, xmm7 ; transpose coefficients(phase 1)
unpcklps xmm7, xmm3 ; xmm7=(20 30 21 31)
unpckhps xmm2, xmm3 ; xmm2=(22 32 23 33)
movaps xmm4, xmm5 ; transpose coefficients(phase 1)
unpcklps xmm5, xmm0 ; xmm5=(40 50 41 51)
unpckhps xmm4, xmm0 ; xmm4=(42 52 43 53)
movaps xmm3, xmm6 ; transpose coefficients(phase 2)
unpcklps2 xmm6, xmm7 ; xmm6=(00 10 20 30)
unpckhps2 xmm3, xmm7 ; xmm3=(01 11 21 31)
movaps xmm0, xmm1 ; transpose coefficients(phase 2)
unpcklps2 xmm1, xmm2 ; xmm1=(02 12 22 32)
unpckhps2 xmm0, xmm2 ; xmm0=(03 13 23 33)
movaps xmm7, XMMWORD [wk(0)] ; xmm7=(60 70 61 71)
movaps xmm2, XMMWORD [wk(1)] ; xmm2=(62 72 63 73)
movaps XMMWORD [XMMBLOCK(0,0,rdi,SIZEOF_FAST_FLOAT)], xmm6
movaps XMMWORD [XMMBLOCK(1,0,rdi,SIZEOF_FAST_FLOAT)], xmm3
movaps XMMWORD [XMMBLOCK(2,0,rdi,SIZEOF_FAST_FLOAT)], xmm1
movaps XMMWORD [XMMBLOCK(3,0,rdi,SIZEOF_FAST_FLOAT)], xmm0
movaps xmm6, xmm5 ; transpose coefficients(phase 2)
unpcklps2 xmm5, xmm7 ; xmm5=(40 50 60 70)
unpckhps2 xmm6, xmm7 ; xmm6=(41 51 61 71)
movaps xmm3, xmm4 ; transpose coefficients(phase 2)
unpcklps2 xmm4, xmm2 ; xmm4=(42 52 62 72)
unpckhps2 xmm3, xmm2 ; xmm3=(43 53 63 73)
movaps XMMWORD [XMMBLOCK(0,1,rdi,SIZEOF_FAST_FLOAT)], xmm5
movaps XMMWORD [XMMBLOCK(1,1,rdi,SIZEOF_FAST_FLOAT)], xmm6
movaps XMMWORD [XMMBLOCK(2,1,rdi,SIZEOF_FAST_FLOAT)], xmm4
movaps XMMWORD [XMMBLOCK(3,1,rdi,SIZEOF_FAST_FLOAT)], xmm3
.nextcolumn:
add rsi, byte 4*SIZEOF_JCOEF ; coef_block
add rdx, byte 4*SIZEOF_FLOAT_MULT_TYPE ; quantptr
add rdi, 4*DCTSIZE*SIZEOF_FAST_FLOAT ; wsptr
dec rcx ; ctr
jnz near .columnloop
; -- Prefetch the next coefficient block
prefetchnta [rsi + (DCTSIZE2-8)*SIZEOF_JCOEF + 0*32]
prefetchnta [rsi + (DCTSIZE2-8)*SIZEOF_JCOEF + 1*32]
prefetchnta [rsi + (DCTSIZE2-8)*SIZEOF_JCOEF + 2*32]
prefetchnta [rsi + (DCTSIZE2-8)*SIZEOF_JCOEF + 3*32]
; ---- Pass 2: process rows from work array, store into output array.
mov rax, [original_rbp]
lea rsi, [workspace] ; FAST_FLOAT *wsptr
mov rdi, r12 ; (JSAMPROW *)
mov eax, r13d
mov rcx, DCTSIZE/4 ; ctr
.rowloop:
; -- Even part
movaps xmm0, XMMWORD [XMMBLOCK(0,0,rsi,SIZEOF_FAST_FLOAT)]
movaps xmm1, XMMWORD [XMMBLOCK(2,0,rsi,SIZEOF_FAST_FLOAT)]
movaps xmm2, XMMWORD [XMMBLOCK(4,0,rsi,SIZEOF_FAST_FLOAT)]
movaps xmm3, XMMWORD [XMMBLOCK(6,0,rsi,SIZEOF_FAST_FLOAT)]
movaps xmm4, xmm0
movaps xmm5, xmm1
subps xmm0, xmm2 ; xmm0=tmp11
subps xmm1, xmm3
addps xmm4, xmm2 ; xmm4=tmp10
addps xmm5, xmm3 ; xmm5=tmp13
mulps xmm1, [rel PD_1_414]
subps xmm1, xmm5 ; xmm1=tmp12
movaps xmm6, xmm4
movaps xmm7, xmm0
subps xmm4, xmm5 ; xmm4=tmp3
subps xmm0, xmm1 ; xmm0=tmp2
addps xmm6, xmm5 ; xmm6=tmp0
addps xmm7, xmm1 ; xmm7=tmp1
movaps XMMWORD [wk(1)], xmm4 ; tmp3
movaps XMMWORD [wk(0)], xmm0 ; tmp2
; -- Odd part
movaps xmm2, XMMWORD [XMMBLOCK(1,0,rsi,SIZEOF_FAST_FLOAT)]
movaps xmm3, XMMWORD [XMMBLOCK(3,0,rsi,SIZEOF_FAST_FLOAT)]
movaps xmm5, XMMWORD [XMMBLOCK(5,0,rsi,SIZEOF_FAST_FLOAT)]
movaps xmm1, XMMWORD [XMMBLOCK(7,0,rsi,SIZEOF_FAST_FLOAT)]
movaps xmm4, xmm2
movaps xmm0, xmm5
addps xmm2, xmm1 ; xmm2=z11
addps xmm5, xmm3 ; xmm5=z13
subps xmm4, xmm1 ; xmm4=z12
subps xmm0, xmm3 ; xmm0=z10
movaps xmm1, xmm2
subps xmm2, xmm5
addps xmm1, xmm5 ; xmm1=tmp7
mulps xmm2, [rel PD_1_414] ; xmm2=tmp11
movaps xmm3, xmm0
addps xmm0, xmm4
mulps xmm0, [rel PD_1_847] ; xmm0=z5
mulps xmm3, [rel PD_M2_613] ; xmm3=(z10 * -2.613125930)
mulps xmm4, [rel PD_1_082] ; xmm4=(z12 * 1.082392200)
addps xmm3, xmm0 ; xmm3=tmp12
subps xmm4, xmm0 ; xmm4=tmp10
; -- Final output stage
subps xmm3, xmm1 ; xmm3=tmp6
movaps xmm5, xmm6
movaps xmm0, xmm7
addps xmm6, xmm1 ; xmm6=data0=(00 10 20 30)
addps xmm7, xmm3 ; xmm7=data1=(01 11 21 31)
subps xmm5, xmm1 ; xmm5=data7=(07 17 27 37)
subps xmm0, xmm3 ; xmm0=data6=(06 16 26 36)
subps xmm2, xmm3 ; xmm2=tmp5
movaps xmm1, [rel PD_RNDINT_MAGIC] ; xmm1=[rel PD_RNDINT_MAGIC]
pcmpeqd xmm3, xmm3
psrld xmm3, WORD_BIT ; xmm3={0xFFFF 0x0000 0xFFFF 0x0000 ..}
addps xmm6, xmm1 ; xmm6=roundint(data0/8)=(00 ** 10 ** 20 ** 30 **)
addps xmm7, xmm1 ; xmm7=roundint(data1/8)=(01 ** 11 ** 21 ** 31 **)
addps xmm0, xmm1 ; xmm0=roundint(data6/8)=(06 ** 16 ** 26 ** 36 **)
addps xmm5, xmm1 ; xmm5=roundint(data7/8)=(07 ** 17 ** 27 ** 37 **)
pand xmm6, xmm3 ; xmm6=(00 -- 10 -- 20 -- 30 --)
pslld xmm7, WORD_BIT ; xmm7=(-- 01 -- 11 -- 21 -- 31)
pand xmm0, xmm3 ; xmm0=(06 -- 16 -- 26 -- 36 --)
pslld xmm5, WORD_BIT ; xmm5=(-- 07 -- 17 -- 27 -- 37)
por xmm6, xmm7 ; xmm6=(00 01 10 11 20 21 30 31)
por xmm0, xmm5 ; xmm0=(06 07 16 17 26 27 36 37)
movaps xmm1, XMMWORD [wk(0)] ; xmm1=tmp2
movaps xmm3, XMMWORD [wk(1)] ; xmm3=tmp3
addps xmm4, xmm2 ; xmm4=tmp4
movaps xmm7, xmm1
movaps xmm5, xmm3
addps xmm1, xmm2 ; xmm1=data2=(02 12 22 32)
addps xmm3, xmm4 ; xmm3=data4=(04 14 24 34)
subps xmm7, xmm2 ; xmm7=data5=(05 15 25 35)
subps xmm5, xmm4 ; xmm5=data3=(03 13 23 33)
movaps xmm2, [rel PD_RNDINT_MAGIC] ; xmm2=[rel PD_RNDINT_MAGIC]
pcmpeqd xmm4, xmm4
psrld xmm4, WORD_BIT ; xmm4={0xFFFF 0x0000 0xFFFF 0x0000 ..}
addps xmm3, xmm2 ; xmm3=roundint(data4/8)=(04 ** 14 ** 24 ** 34 **)
addps xmm7, xmm2 ; xmm7=roundint(data5/8)=(05 ** 15 ** 25 ** 35 **)
addps xmm1, xmm2 ; xmm1=roundint(data2/8)=(02 ** 12 ** 22 ** 32 **)
addps xmm5, xmm2 ; xmm5=roundint(data3/8)=(03 ** 13 ** 23 ** 33 **)
pand xmm3, xmm4 ; xmm3=(04 -- 14 -- 24 -- 34 --)
pslld xmm7, WORD_BIT ; xmm7=(-- 05 -- 15 -- 25 -- 35)
pand xmm1, xmm4 ; xmm1=(02 -- 12 -- 22 -- 32 --)
pslld xmm5, WORD_BIT ; xmm5=(-- 03 -- 13 -- 23 -- 33)
por xmm3, xmm7 ; xmm3=(04 05 14 15 24 25 34 35)
por xmm1, xmm5 ; xmm1=(02 03 12 13 22 23 32 33)
movdqa xmm2, [rel PB_CENTERJSAMP] ; xmm2=[rel PB_CENTERJSAMP]
packsswb xmm6, xmm3 ; xmm6=(00 01 10 11 20 21 30 31 04 05 14 15 24 25 34 35)
packsswb xmm1, xmm0 ; xmm1=(02 03 12 13 22 23 32 33 06 07 16 17 26 27 36 37)
paddb xmm6, xmm2
paddb xmm1, xmm2
movdqa xmm4, xmm6 ; transpose coefficients(phase 2)
punpcklwd xmm6, xmm1 ; xmm6=(00 01 02 03 10 11 12 13 20 21 22 23 30 31 32 33)
punpckhwd xmm4, xmm1 ; xmm4=(04 05 06 07 14 15 16 17 24 25 26 27 34 35 36 37)
movdqa xmm7, xmm6 ; transpose coefficients(phase 3)
punpckldq xmm6, xmm4 ; xmm6=(00 01 02 03 04 05 06 07 10 11 12 13 14 15 16 17)
punpckhdq xmm7, xmm4 ; xmm7=(20 21 22 23 24 25 26 27 30 31 32 33 34 35 36 37)
pshufd xmm5, xmm6, 0x4E ; xmm5=(10 11 12 13 14 15 16 17 00 01 02 03 04 05 06 07)
pshufd xmm3, xmm7, 0x4E ; xmm3=(30 31 32 33 34 35 36 37 20 21 22 23 24 25 26 27)
mov rdx, JSAMPROW [rdi+0*SIZEOF_JSAMPROW]
mov rbx, JSAMPROW [rdi+2*SIZEOF_JSAMPROW]
movq XMM_MMWORD [rdx+rax*SIZEOF_JSAMPLE], xmm6
movq XMM_MMWORD [rbx+rax*SIZEOF_JSAMPLE], xmm7
mov rdx, JSAMPROW [rdi+1*SIZEOF_JSAMPROW]
mov rbx, JSAMPROW [rdi+3*SIZEOF_JSAMPROW]
movq XMM_MMWORD [rdx+rax*SIZEOF_JSAMPLE], xmm5
movq XMM_MMWORD [rbx+rax*SIZEOF_JSAMPLE], xmm3
add rsi, byte 4*SIZEOF_FAST_FLOAT ; wsptr
add rdi, byte 4*SIZEOF_JSAMPROW
dec rcx ; ctr
jnz near .rowloop
pop rbx
uncollect_args 4
mov rsp, rbp ; rsp <- aligned rbp
pop rsp ; rsp <- original rbp
pop rbp
ret
; For some reason, the OS X linker does not honor the request to align the
; segment unless we do this.
align 32
|
; A183208: Iterates of f(x)=floor((3x-1)/2) from x=6.
; 6,8,11,16,23,34,50,74,110,164,245,367,550,824,1235,1852,2777,4165,6247,9370,14054,21080,31619,47428,71141,106711,160066,240098,360146,540218,810326,1215488,1823231,2734846,4102268,6153401,9230101,13845151
mov $1,5
mov $2,$0
lpb $2
mul $1,3
div $1,2
sub $2,1
lpe
add $1,1
|
// Copyright 2008-2016 Conrad Sanderson (http://conradsanderson.id.au)
// Copyright 2008-2016 National ICT Australia (NICTA)
//
// 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.
// ------------------------------------------------------------------------
//! \addtogroup MapMat
//! @{
template<typename eT>
inline
MapMat<eT>::~MapMat()
{
arma_extra_debug_sigprint_this(this);
if(map_ptr) { (*map_ptr).clear(); delete map_ptr; }
// try to expose buggy user code that accesses deleted objects
if(arma_config::debug) { map_ptr = nullptr; }
arma_type_check(( is_supported_elem_type<eT>::value == false ));
}
template<typename eT>
inline
MapMat<eT>::MapMat()
: n_rows (0)
, n_cols (0)
, n_elem (0)
, map_ptr(nullptr)
{
arma_extra_debug_sigprint_this(this);
init_cold();
}
template<typename eT>
inline
MapMat<eT>::MapMat(const uword in_n_rows, const uword in_n_cols)
: n_rows (in_n_rows)
, n_cols (in_n_cols)
, n_elem (in_n_rows * in_n_cols)
, map_ptr(nullptr)
{
arma_extra_debug_sigprint_this(this);
init_cold();
}
template<typename eT>
inline
MapMat<eT>::MapMat(const SizeMat& s)
: n_rows (s.n_rows)
, n_cols (s.n_cols)
, n_elem (s.n_rows * s.n_cols)
, map_ptr(nullptr)
{
arma_extra_debug_sigprint_this(this);
init_cold();
}
template<typename eT>
inline
MapMat<eT>::MapMat(const MapMat<eT>& x)
: n_rows (0)
, n_cols (0)
, n_elem (0)
, map_ptr(nullptr)
{
arma_extra_debug_sigprint_this(this);
init_cold();
(*this).operator=(x);
}
template<typename eT>
inline
void
MapMat<eT>::operator=(const MapMat<eT>& x)
{
arma_extra_debug_sigprint();
if(this == &x) { return; }
access::rw(n_rows) = x.n_rows;
access::rw(n_cols) = x.n_cols;
access::rw(n_elem) = x.n_elem;
(*map_ptr) = *(x.map_ptr);
}
template<typename eT>
inline
MapMat<eT>::MapMat(const SpMat<eT>& x)
: n_rows (0)
, n_cols (0)
, n_elem (0)
, map_ptr(nullptr)
{
arma_extra_debug_sigprint_this(this);
init_cold();
(*this).operator=(x);
}
template<typename eT>
inline
void
MapMat<eT>::operator=(const SpMat<eT>& x)
{
arma_extra_debug_sigprint();
const uword x_n_rows = x.n_rows;
const uword x_n_cols = x.n_cols;
(*this).zeros(x_n_rows, x_n_cols);
if(x.n_nonzero == 0) { return; }
const eT* x_values = x.values;
const uword* x_row_indices = x.row_indices;
const uword* x_col_ptrs = x.col_ptrs;
map_type& map_ref = (*map_ptr);
for(uword col = 0; col < x_n_cols; ++col)
{
const uword start = x_col_ptrs[col ];
const uword end = x_col_ptrs[col + 1];
for(uword i = start; i < end; ++i)
{
const uword row = x_row_indices[i];
const eT val = x_values[i];
const uword index = (x_n_rows * col) + row;
map_ref.emplace_hint(map_ref.cend(), index, val);
}
}
}
template<typename eT>
inline
MapMat<eT>::MapMat(MapMat<eT>&& x)
: n_rows (x.n_rows )
, n_cols (x.n_cols )
, n_elem (x.n_elem )
, map_ptr(x.map_ptr)
{
arma_extra_debug_sigprint_this(this);
access::rw(x.n_rows) = 0;
access::rw(x.n_cols) = 0;
access::rw(x.n_elem) = 0;
access::rw(x.map_ptr) = nullptr;
}
template<typename eT>
inline
void
MapMat<eT>::operator=(MapMat<eT>&& x)
{
arma_extra_debug_sigprint();
reset();
if(map_ptr) { delete map_ptr; }
access::rw(n_rows) = x.n_rows;
access::rw(n_cols) = x.n_cols;
access::rw(n_elem) = x.n_elem;
access::rw(map_ptr) = x.map_ptr;
access::rw(x.n_rows) = 0;
access::rw(x.n_cols) = 0;
access::rw(x.n_elem) = 0;
access::rw(x.map_ptr) = nullptr;
}
template<typename eT>
inline
void
MapMat<eT>::reset()
{
arma_extra_debug_sigprint();
access::rw(n_rows) = 0;
access::rw(n_cols) = 0;
access::rw(n_elem) = 0;
if((*map_ptr).empty() == false) { (*map_ptr).clear(); }
}
template<typename eT>
inline
void
MapMat<eT>::set_size(const uword in_n_rows)
{
arma_extra_debug_sigprint();
init_warm(in_n_rows, 1);
}
template<typename eT>
inline
void
MapMat<eT>::set_size(const uword in_n_rows, const uword in_n_cols)
{
arma_extra_debug_sigprint();
init_warm(in_n_rows, in_n_cols);
}
template<typename eT>
inline
void
MapMat<eT>::set_size(const SizeMat& s)
{
arma_extra_debug_sigprint();
init_warm(s.n_rows, s.n_cols);
}
template<typename eT>
inline
void
MapMat<eT>::zeros()
{
arma_extra_debug_sigprint();
(*map_ptr).clear();
}
template<typename eT>
inline
void
MapMat<eT>::zeros(const uword in_n_rows)
{
arma_extra_debug_sigprint();
init_warm(in_n_rows, 1);
(*map_ptr).clear();
}
template<typename eT>
inline
void
MapMat<eT>::zeros(const uword in_n_rows, const uword in_n_cols)
{
arma_extra_debug_sigprint();
init_warm(in_n_rows, in_n_cols);
(*map_ptr).clear();
}
template<typename eT>
inline
void
MapMat<eT>::zeros(const SizeMat& s)
{
arma_extra_debug_sigprint();
init_warm(s.n_rows, s.n_cols);
(*map_ptr).clear();
}
template<typename eT>
inline
void
MapMat<eT>::eye()
{
arma_extra_debug_sigprint();
(*this).eye(n_rows, n_cols);
}
template<typename eT>
inline
void
MapMat<eT>::eye(const uword in_n_rows, const uword in_n_cols)
{
arma_extra_debug_sigprint();
zeros(in_n_rows, in_n_cols);
const uword N = (std::min)(in_n_rows, in_n_cols);
map_type& map_ref = (*map_ptr);
for(uword i=0; i<N; ++i)
{
const uword index = (in_n_rows * i) + i;
map_ref.emplace_hint(map_ref.cend(), index, eT(1));
}
}
template<typename eT>
inline
void
MapMat<eT>::eye(const SizeMat& s)
{
arma_extra_debug_sigprint();
(*this).eye(s.n_rows, s.n_cols);
}
template<typename eT>
inline
void
MapMat<eT>::speye()
{
arma_extra_debug_sigprint();
(*this).eye();
}
template<typename eT>
inline
void
MapMat<eT>::speye(const uword in_n_rows, const uword in_n_cols)
{
arma_extra_debug_sigprint();
(*this).eye(in_n_rows, in_n_cols);
}
template<typename eT>
inline
void
MapMat<eT>::speye(const SizeMat& s)
{
arma_extra_debug_sigprint();
(*this).eye(s);
}
template<typename eT>
arma_inline
arma_warn_unused
MapMat_val<eT>
MapMat<eT>::operator[](const uword index)
{
return MapMat_val<eT>(*this, index);
}
template<typename eT>
inline
arma_warn_unused
eT
MapMat<eT>::operator[](const uword index) const
{
map_type& map_ref = (*map_ptr);
typename map_type::const_iterator it = map_ref.find(index);
typename map_type::const_iterator it_end = map_ref.end();
return (it != it_end) ? eT((*it).second) : eT(0);
}
template<typename eT>
arma_inline
arma_warn_unused
MapMat_val<eT>
MapMat<eT>::operator()(const uword index)
{
arma_debug_check_bounds( (index >= n_elem), "MapMat::operator(): index out of bounds" );
return MapMat_val<eT>(*this, index);
}
template<typename eT>
inline
arma_warn_unused
eT
MapMat<eT>::operator()(const uword index) const
{
arma_debug_check_bounds( (index >= n_elem), "MapMat::operator(): index out of bounds" );
map_type& map_ref = (*map_ptr);
typename map_type::const_iterator it = map_ref.find(index);
typename map_type::const_iterator it_end = map_ref.end();
return (it != it_end) ? eT((*it).second) : eT(0);
}
template<typename eT>
arma_inline
arma_warn_unused
MapMat_val<eT>
MapMat<eT>::at(const uword in_row, const uword in_col)
{
const uword index = (n_rows * in_col) + in_row;
return MapMat_val<eT>(*this, index);
}
template<typename eT>
inline
arma_warn_unused
eT
MapMat<eT>::at(const uword in_row, const uword in_col) const
{
const uword index = (n_rows * in_col) + in_row;
map_type& map_ref = (*map_ptr);
typename map_type::const_iterator it = map_ref.find(index);
typename map_type::const_iterator it_end = map_ref.end();
return (it != it_end) ? eT((*it).second) : eT(0);
}
template<typename eT>
arma_inline
arma_warn_unused
MapMat_val<eT>
MapMat<eT>::operator()(const uword in_row, const uword in_col)
{
arma_debug_check_bounds( ((in_row >= n_rows) || (in_col >= n_cols)), "MapMat::operator(): index out of bounds" );
const uword index = (n_rows * in_col) + in_row;
return MapMat_val<eT>(*this, index);
}
template<typename eT>
inline
arma_warn_unused
eT
MapMat<eT>::operator()(const uword in_row, const uword in_col) const
{
arma_debug_check_bounds( ((in_row >= n_rows) || (in_col >= n_cols)), "MapMat::operator(): index out of bounds" );
const uword index = (n_rows * in_col) + in_row;
map_type& map_ref = (*map_ptr);
typename map_type::const_iterator it = map_ref.find(index);
typename map_type::const_iterator it_end = map_ref.end();
return (it != it_end) ? eT((*it).second) : eT(0);
}
template<typename eT>
inline
arma_warn_unused
bool
MapMat<eT>::is_empty() const
{
return (n_elem == 0);
}
template<typename eT>
inline
arma_warn_unused
bool
MapMat<eT>::is_vec() const
{
return ( (n_rows == 1) || (n_cols == 1) );
}
template<typename eT>
inline
arma_warn_unused
bool
MapMat<eT>::is_rowvec() const
{
return (n_rows == 1);
}
//! returns true if the object can be interpreted as a column vector
template<typename eT>
inline
arma_warn_unused
bool
MapMat<eT>::is_colvec() const
{
return (n_cols == 1);
}
template<typename eT>
inline
arma_warn_unused
bool
MapMat<eT>::is_square() const
{
return (n_rows == n_cols);
}
// this function is for debugging purposes only
template<typename eT>
inline
void
MapMat<eT>::sprandu(const uword in_n_rows, const uword in_n_cols, const double density)
{
arma_extra_debug_sigprint();
zeros(in_n_rows, in_n_cols);
const uword N = uword(density * double(n_elem));
const Col<eT> vals(N, fill::randu);
const Col<uword> indx = linspace< Col<uword> >(0, ((n_elem > 0) ? uword(n_elem-1) : uword(0)) , N);
const eT* vals_mem = vals.memptr();
const uword* indx_mem = indx.memptr();
map_type& map_ref = (*map_ptr);
for(uword i=0; i < N; ++i)
{
const uword index = indx_mem[i];
const eT val = vals_mem[i];
map_ref.emplace_hint(map_ref.cend(), index, val);
}
}
// this function is for debugging purposes only
template<typename eT>
inline
void
MapMat<eT>::print(const std::string& extra_text) const
{
arma_extra_debug_sigprint();
if(extra_text.length() != 0)
{
const std::streamsize orig_width = get_cout_stream().width();
get_cout_stream() << extra_text << '\n';
get_cout_stream().width(orig_width);
}
map_type& map_ref = (*map_ptr);
const uword n_nonzero = uword(map_ref.size());
const double density = (n_elem > 0) ? ((double(n_nonzero) / double(n_elem))*double(100)) : double(0);
get_cout_stream()
<< "[matrix size: " << n_rows << 'x' << n_cols << "; n_nonzero: " << n_nonzero
<< "; density: " << density << "%]\n\n";
if(n_nonzero > 0)
{
typename map_type::const_iterator it = map_ref.begin();
for(uword i=0; i < n_nonzero; ++i)
{
const std::pair<uword, eT>& entry = (*it);
const uword index = entry.first;
const eT val = entry.second;
const uword row = index % n_rows;
const uword col = index / n_rows;
get_cout_stream() << '(' << row << ", " << col << ") ";
get_cout_stream() << val << '\n';
++it;
}
}
get_cout_stream().flush();
}
template<typename eT>
inline
uword
MapMat<eT>::get_n_nonzero() const
{
arma_extra_debug_sigprint();
return uword((*map_ptr).size());
}
template<typename eT>
inline
void
MapMat<eT>::get_locval_format(umat& locs, Col<eT>& vals) const
{
arma_extra_debug_sigprint();
map_type& map_ref = (*map_ptr);
typename map_type::const_iterator it = map_ref.begin();
const uword N = uword(map_ref.size());
locs.set_size(2,N);
vals.set_size(N);
eT* vals_mem = vals.memptr();
for(uword i=0; i<N; ++i)
{
const std::pair<uword, eT>& entry = (*it);
const uword index = entry.first;
const eT val = entry.second;
const uword row = index % n_rows;
const uword col = index / n_rows;
uword* locs_colptr = locs.colptr(i);
locs_colptr[0] = row;
locs_colptr[1] = col;
vals_mem[i] = val;
++it;
}
}
template<typename eT>
inline
void
MapMat<eT>::init_cold()
{
arma_extra_debug_sigprint();
// ensure that n_elem can hold the result of (n_rows * n_cols)
#if defined(ARMA_64BIT_WORD)
const char* error_message = "MapMat(): requested size is too large";
#else
const char* error_message = "MapMat(): requested size is too large; suggest to enable ARMA_64BIT_WORD";
#endif
arma_debug_check
(
(
( (n_rows > ARMA_MAX_UHWORD) || (n_cols > ARMA_MAX_UHWORD) )
? ( (double(n_rows) * double(n_cols)) > double(ARMA_MAX_UWORD) )
: false
),
error_message
);
map_ptr = new (std::nothrow) map_type;
arma_check_bad_alloc( (map_ptr == nullptr), "MapMat(): out of memory" );
}
template<typename eT>
inline
void
MapMat<eT>::init_warm(const uword in_n_rows, const uword in_n_cols)
{
arma_extra_debug_sigprint();
if( (n_rows == in_n_rows) && (n_cols == in_n_cols)) { return; }
// ensure that n_elem can hold the result of (n_rows * n_cols)
#if defined(ARMA_64BIT_WORD)
const char* error_message = "MapMat(): requested size is too large";
#else
const char* error_message = "MapMat(): requested size is too large; suggest to enable ARMA_64BIT_WORD";
#endif
arma_debug_check
(
(
( (in_n_rows > ARMA_MAX_UHWORD) || (in_n_cols > ARMA_MAX_UHWORD) )
? ( (double(in_n_rows) * double(in_n_cols)) > double(ARMA_MAX_UWORD) )
: false
),
error_message
);
const uword new_n_elem = in_n_rows * in_n_cols;
access::rw(n_rows) = in_n_rows;
access::rw(n_cols) = in_n_cols;
access::rw(n_elem) = new_n_elem;
if(new_n_elem == 0) { (*map_ptr).clear(); }
}
template<typename eT>
arma_inline
void
MapMat<eT>::set_val(const uword index, const eT& in_val)
{
arma_extra_debug_sigprint();
if(in_val != eT(0))
{
map_type& map_ref = (*map_ptr);
if( (map_ref.empty() == false) && (index > uword(map_ref.crbegin()->first)) )
{
map_ref.emplace_hint(map_ref.cend(), index, in_val);
}
else
{
map_ref.operator[](index) = in_val;
}
}
else
{
(*this).erase_val(index);
}
}
template<typename eT>
inline
void
MapMat<eT>::erase_val(const uword index)
{
arma_extra_debug_sigprint();
map_type& map_ref = (*map_ptr);
typename map_type::iterator it = map_ref.find(index);
typename map_type::iterator it_end = map_ref.end();
if(it != it_end) { map_ref.erase(it); }
}
// MapMat_val
template<typename eT>
arma_inline
MapMat_val<eT>::MapMat_val(MapMat<eT>& in_parent, const uword in_index)
: parent(in_parent)
, index (in_index )
{
arma_extra_debug_sigprint();
}
template<typename eT>
arma_inline
MapMat_val<eT>::operator eT() const
{
arma_extra_debug_sigprint();
const MapMat<eT>& const_parent = parent;
return const_parent.operator[](index);
}
template<typename eT>
arma_inline
typename get_pod_type<eT>::result
MapMat_val<eT>::real() const
{
arma_extra_debug_sigprint();
typedef typename get_pod_type<eT>::result T;
const MapMat<eT>& const_parent = parent;
return T( access::tmp_real( const_parent.operator[](index) ) );
}
template<typename eT>
arma_inline
typename get_pod_type<eT>::result
MapMat_val<eT>::imag() const
{
arma_extra_debug_sigprint();
typedef typename get_pod_type<eT>::result T;
const MapMat<eT>& const_parent = parent;
return T( access::tmp_imag( const_parent.operator[](index) ) );
}
template<typename eT>
arma_inline
void
MapMat_val<eT>::operator=(const MapMat_val<eT>& x)
{
arma_extra_debug_sigprint();
const eT in_val = eT(x);
parent.set_val(index, in_val);
}
template<typename eT>
arma_inline
void
MapMat_val<eT>::operator=(const eT in_val)
{
arma_extra_debug_sigprint();
parent.set_val(index, in_val);
}
template<typename eT>
arma_inline
void
MapMat_val<eT>::operator+=(const eT in_val)
{
arma_extra_debug_sigprint();
typename MapMat<eT>::map_type& map_ref = *(parent.map_ptr);
if(in_val != eT(0))
{
eT& val = map_ref.operator[](index); // creates the element if it doesn't exist
val += in_val;
if(val == eT(0)) { map_ref.erase(index); }
}
}
template<typename eT>
arma_inline
void
MapMat_val<eT>::operator-=(const eT in_val)
{
arma_extra_debug_sigprint();
typename MapMat<eT>::map_type& map_ref = *(parent.map_ptr);
if(in_val != eT(0))
{
eT& val = map_ref.operator[](index); // creates the element if it doesn't exist
val -= in_val;
if(val == eT(0)) { map_ref.erase(index); }
}
}
template<typename eT>
arma_inline
void
MapMat_val<eT>::operator*=(const eT in_val)
{
arma_extra_debug_sigprint();
typename MapMat<eT>::map_type& map_ref = *(parent.map_ptr);
typename MapMat<eT>::map_type::iterator it = map_ref.find(index);
typename MapMat<eT>::map_type::iterator it_end = map_ref.end();
if(it != it_end)
{
if(in_val != eT(0))
{
eT& val = (*it).second;
val *= in_val;
if(val == eT(0)) { map_ref.erase(it); }
}
else
{
map_ref.erase(it);
}
}
}
template<typename eT>
arma_inline
void
MapMat_val<eT>::operator/=(const eT in_val)
{
arma_extra_debug_sigprint();
typename MapMat<eT>::map_type& map_ref = *(parent.map_ptr);
typename MapMat<eT>::map_type::iterator it = map_ref.find(index);
typename MapMat<eT>::map_type::iterator it_end = map_ref.end();
if(it != it_end)
{
eT& val = (*it).second;
val /= in_val;
if(val == eT(0)) { map_ref.erase(it); }
}
else
{
// silly operation, but included for completness
const eT val = eT(0) / in_val;
if(val != eT(0)) { parent.set_val(index, val); }
}
}
template<typename eT>
arma_inline
void
MapMat_val<eT>::operator++()
{
arma_extra_debug_sigprint();
typename MapMat<eT>::map_type& map_ref = *(parent.map_ptr);
eT& val = map_ref.operator[](index); // creates the element if it doesn't exist
val += eT(1); // can't use ++, as eT can be std::complex
if(val == eT(0)) { map_ref.erase(index); }
}
template<typename eT>
arma_inline
void
MapMat_val<eT>::operator++(int)
{
arma_extra_debug_sigprint();
(*this).operator++();
}
template<typename eT>
arma_inline
void
MapMat_val<eT>::operator--()
{
arma_extra_debug_sigprint();
typename MapMat<eT>::map_type& map_ref = *(parent.map_ptr);
eT& val = map_ref.operator[](index); // creates the element if it doesn't exist
val -= eT(1); // can't use --, as eT can be std::complex
if(val == eT(0)) { map_ref.erase(index); }
}
template<typename eT>
arma_inline
void
MapMat_val<eT>::operator--(int)
{
arma_extra_debug_sigprint();
(*this).operator--();
}
// SpMat_MapMat_val
template<typename eT>
arma_inline
SpMat_MapMat_val<eT>::SpMat_MapMat_val(SpMat<eT>& in_s_parent, MapMat<eT>& in_m_parent, const uword in_row, const uword in_col)
: s_parent(in_s_parent)
, m_parent(in_m_parent)
, row (in_row )
, col (in_col )
{
arma_extra_debug_sigprint();
}
template<typename eT>
inline
SpMat_MapMat_val<eT>::operator eT() const
{
arma_extra_debug_sigprint();
const SpMat<eT>& const_s_parent = s_parent; // declare as const for clarity of intent
return const_s_parent.get_value(row,col);
}
template<typename eT>
inline
typename get_pod_type<eT>::result
SpMat_MapMat_val<eT>::real() const
{
arma_extra_debug_sigprint();
typedef typename get_pod_type<eT>::result T;
const SpMat<eT>& const_s_parent = s_parent; // declare as const for clarity of intent
return T( access::tmp_real( const_s_parent.get_value(row,col) ) );
}
template<typename eT>
inline
typename get_pod_type<eT>::result
SpMat_MapMat_val<eT>::imag() const
{
arma_extra_debug_sigprint();
typedef typename get_pod_type<eT>::result T;
const SpMat<eT>& const_s_parent = s_parent; // declare as const for clarity of intent
return T( access::tmp_imag( const_s_parent.get_value(row,col) ) );
}
template<typename eT>
inline
SpMat_MapMat_val<eT>&
SpMat_MapMat_val<eT>::operator=(const SpMat_MapMat_val<eT>& x)
{
arma_extra_debug_sigprint();
const eT in_val = eT(x);
return (*this).operator=(in_val);
}
template<typename eT>
inline
SpMat_MapMat_val<eT>&
SpMat_MapMat_val<eT>::operator=(const eT in_val)
{
arma_extra_debug_sigprint();
#if defined(ARMA_USE_OPENMP)
{
#pragma omp critical (arma_SpMat_cache)
{
(*this).set(in_val);
}
}
#elif (!defined(ARMA_DONT_USE_STD_MUTEX))
{
s_parent.cache_mutex.lock();
(*this).set(in_val);
s_parent.cache_mutex.unlock();
}
#else
{
(*this).set(in_val);
}
#endif
return *this;
}
template<typename eT>
inline
SpMat_MapMat_val<eT>&
SpMat_MapMat_val<eT>::operator+=(const eT in_val)
{
arma_extra_debug_sigprint();
if(in_val == eT(0)) { return *this; }
#if defined(ARMA_USE_OPENMP)
{
#pragma omp critical (arma_SpMat_cache)
{
(*this).add(in_val);
}
}
#elif (!defined(ARMA_DONT_USE_STD_MUTEX))
{
s_parent.cache_mutex.lock();
(*this).add(in_val);
s_parent.cache_mutex.unlock();
}
#else
{
(*this).add(in_val);
}
#endif
return *this;
}
template<typename eT>
inline
SpMat_MapMat_val<eT>&
SpMat_MapMat_val<eT>::operator-=(const eT in_val)
{
arma_extra_debug_sigprint();
if(in_val == eT(0)) { return *this; }
#if defined(ARMA_USE_OPENMP)
{
#pragma omp critical (arma_SpMat_cache)
{
(*this).sub(in_val);
}
}
#elif (!defined(ARMA_DONT_USE_STD_MUTEX))
{
s_parent.cache_mutex.lock();
(*this).sub(in_val);
s_parent.cache_mutex.unlock();
}
#else
{
(*this).sub(in_val);
}
#endif
return *this;
}
template<typename eT>
inline
SpMat_MapMat_val<eT>&
SpMat_MapMat_val<eT>::operator*=(const eT in_val)
{
arma_extra_debug_sigprint();
#if defined(ARMA_USE_OPENMP)
{
#pragma omp critical (arma_SpMat_cache)
{
(*this).mul(in_val);
}
}
#elif (!defined(ARMA_DONT_USE_STD_MUTEX))
{
s_parent.cache_mutex.lock();
(*this).mul(in_val);
s_parent.cache_mutex.unlock();
}
#else
{
(*this).mul(in_val);
}
#endif
return *this;
}
template<typename eT>
inline
SpMat_MapMat_val<eT>&
SpMat_MapMat_val<eT>::operator/=(const eT in_val)
{
arma_extra_debug_sigprint();
#if defined(ARMA_USE_OPENMP)
{
#pragma omp critical (arma_SpMat_cache)
{
(*this).div(in_val);
}
}
#elif (!defined(ARMA_DONT_USE_STD_MUTEX))
{
s_parent.cache_mutex.lock();
(*this).div(in_val);
s_parent.cache_mutex.unlock();
}
#else
{
(*this).div(in_val);
}
#endif
return *this;
}
template<typename eT>
inline
SpMat_MapMat_val<eT>&
SpMat_MapMat_val<eT>::operator++()
{
arma_extra_debug_sigprint();
return (*this).operator+=( eT(1) );
}
template<typename eT>
inline
arma_warn_unused
eT
SpMat_MapMat_val<eT>::operator++(int)
{
arma_extra_debug_sigprint();
const eT old_val = eT(*this);
(*this).operator+=( eT(1) );
return old_val;
}
template<typename eT>
inline
SpMat_MapMat_val<eT>&
SpMat_MapMat_val<eT>::operator--()
{
arma_extra_debug_sigprint();
return (*this).operator-=( eT(1) );
}
template<typename eT>
inline
arma_warn_unused
eT
SpMat_MapMat_val<eT>::operator--(int)
{
arma_extra_debug_sigprint();
const eT old_val = eT(*this);
(*this).operator-=( eT(1) );
return old_val;
}
template<typename eT>
inline
void
SpMat_MapMat_val<eT>::set(const eT in_val)
{
arma_extra_debug_sigprint();
const bool done = (s_parent.sync_state == 0) ? s_parent.try_set_value_csc(row, col, in_val) : false;
if(done == false)
{
s_parent.sync_cache_simple();
const uword index = (m_parent.n_rows * col) + row;
m_parent.set_val(index, in_val);
s_parent.sync_state = 1;
access::rw(s_parent.n_nonzero) = m_parent.get_n_nonzero();
}
}
template<typename eT>
inline
void
SpMat_MapMat_val<eT>::add(const eT in_val)
{
arma_extra_debug_sigprint();
const bool done = (s_parent.sync_state == 0) ? s_parent.try_add_value_csc(row, col, in_val) : false;
if(done == false)
{
s_parent.sync_cache_simple();
const uword index = (m_parent.n_rows * col) + row;
typename MapMat<eT>::map_type& map_ref = *(m_parent.map_ptr);
eT& val = map_ref.operator[](index); // creates the element if it doesn't exist
val += in_val;
if(val == eT(0)) { map_ref.erase(index); }
s_parent.sync_state = 1;
access::rw(s_parent.n_nonzero) = m_parent.get_n_nonzero();
}
}
template<typename eT>
inline
void
SpMat_MapMat_val<eT>::sub(const eT in_val)
{
arma_extra_debug_sigprint();
const bool done = (s_parent.sync_state == 0) ? s_parent.try_sub_value_csc(row, col, in_val) : false;
if(done == false)
{
s_parent.sync_cache_simple();
const uword index = (m_parent.n_rows * col) + row;
typename MapMat<eT>::map_type& map_ref = *(m_parent.map_ptr);
eT& val = map_ref.operator[](index); // creates the element if it doesn't exist
val -= in_val;
if(val == eT(0)) { map_ref.erase(index); }
s_parent.sync_state = 1;
access::rw(s_parent.n_nonzero) = m_parent.get_n_nonzero();
}
}
template<typename eT>
inline
void
SpMat_MapMat_val<eT>::mul(const eT in_val)
{
arma_extra_debug_sigprint();
const bool done = (s_parent.sync_state == 0) ? s_parent.try_mul_value_csc(row, col, in_val) : false;
if(done == false)
{
s_parent.sync_cache_simple();
const uword index = (m_parent.n_rows * col) + row;
typename MapMat<eT>::map_type& map_ref = *(m_parent.map_ptr);
typename MapMat<eT>::map_type::iterator it = map_ref.find(index);
typename MapMat<eT>::map_type::iterator it_end = map_ref.end();
if(it != it_end)
{
if(in_val != eT(0))
{
eT& val = (*it).second;
val *= in_val;
if(val == eT(0)) { map_ref.erase(it); }
}
else
{
map_ref.erase(it);
}
s_parent.sync_state = 1;
access::rw(s_parent.n_nonzero) = m_parent.get_n_nonzero();
}
else
{
// element not found, ie. it's zero; zero multiplied by anything is zero, except for nan and inf
if(arma_isfinite(in_val) == false)
{
const eT result = eT(0) * in_val;
if(result != eT(0)) // paranoia, in case compiling with -ffast-math
{
m_parent.set_val(index, result);
s_parent.sync_state = 1;
access::rw(s_parent.n_nonzero) = m_parent.get_n_nonzero();
}
}
}
}
}
template<typename eT>
inline
void
SpMat_MapMat_val<eT>::div(const eT in_val)
{
arma_extra_debug_sigprint();
const bool done = (s_parent.sync_state == 0) ? s_parent.try_div_value_csc(row, col, in_val) : false;
if(done == false)
{
s_parent.sync_cache_simple();
const uword index = (m_parent.n_rows * col) + row;
typename MapMat<eT>::map_type& map_ref = *(m_parent.map_ptr);
typename MapMat<eT>::map_type::iterator it = map_ref.find(index);
typename MapMat<eT>::map_type::iterator it_end = map_ref.end();
if(it != it_end)
{
eT& val = (*it).second;
val /= in_val;
if(val == eT(0)) { map_ref.erase(it); }
s_parent.sync_state = 1;
access::rw(s_parent.n_nonzero) = m_parent.get_n_nonzero();
}
else
{
// element not found, ie. it's zero; zero divided by anything is zero, except for zero and nan
if( (in_val == eT(0)) || (arma_isnan(in_val)) )
{
const eT result = eT(0) / in_val;
if(result != eT(0)) // paranoia, in case compiling with -ffast-math
{
m_parent.set_val(index, result);
s_parent.sync_state = 1;
access::rw(s_parent.n_nonzero) = m_parent.get_n_nonzero();
}
}
}
}
}
// SpSubview_MapMat_val
template<typename eT>
arma_inline
SpSubview_MapMat_val<eT>::SpSubview_MapMat_val(SpSubview<eT>& in_sv_parent, MapMat<eT>& in_m_parent, const uword in_row, const uword in_col)
: SpMat_MapMat_val<eT>(access::rw(in_sv_parent.m), in_m_parent, in_row, in_col)
, sv_parent(in_sv_parent)
{
arma_extra_debug_sigprint();
}
template<typename eT>
inline
SpSubview_MapMat_val<eT>&
SpSubview_MapMat_val<eT>::operator=(const SpSubview_MapMat_val<eT>& x)
{
arma_extra_debug_sigprint();
const eT in_val = eT(x);
return (*this).operator=(in_val);
}
template<typename eT>
inline
SpSubview_MapMat_val<eT>&
SpSubview_MapMat_val<eT>::operator=(const eT in_val)
{
arma_extra_debug_sigprint();
const uword old_n_nonzero = sv_parent.m.n_nonzero;
SpMat_MapMat_val<eT>::operator=(in_val);
if(sv_parent.m.n_nonzero > old_n_nonzero) { access::rw(sv_parent.n_nonzero)++; }
if(sv_parent.m.n_nonzero < old_n_nonzero) { access::rw(sv_parent.n_nonzero)--; }
return *this;
}
template<typename eT>
inline
SpSubview_MapMat_val<eT>&
SpSubview_MapMat_val<eT>::operator+=(const eT in_val)
{
arma_extra_debug_sigprint();
const uword old_n_nonzero = sv_parent.m.n_nonzero;
SpMat_MapMat_val<eT>::operator+=(in_val);
if(sv_parent.m.n_nonzero > old_n_nonzero) { access::rw(sv_parent.n_nonzero)++; }
if(sv_parent.m.n_nonzero < old_n_nonzero) { access::rw(sv_parent.n_nonzero)--; }
return *this;
}
template<typename eT>
inline
SpSubview_MapMat_val<eT>&
SpSubview_MapMat_val<eT>::operator-=(const eT in_val)
{
arma_extra_debug_sigprint();
const uword old_n_nonzero = sv_parent.m.n_nonzero;
SpMat_MapMat_val<eT>::operator-=(in_val);
if(sv_parent.m.n_nonzero > old_n_nonzero) { access::rw(sv_parent.n_nonzero)++; }
if(sv_parent.m.n_nonzero < old_n_nonzero) { access::rw(sv_parent.n_nonzero)--; }
return *this;
}
template<typename eT>
inline
SpSubview_MapMat_val<eT>&
SpSubview_MapMat_val<eT>::operator*=(const eT in_val)
{
arma_extra_debug_sigprint();
const uword old_n_nonzero = sv_parent.m.n_nonzero;
SpMat_MapMat_val<eT>::operator*=(in_val);
if(sv_parent.m.n_nonzero > old_n_nonzero) { access::rw(sv_parent.n_nonzero)++; }
if(sv_parent.m.n_nonzero < old_n_nonzero) { access::rw(sv_parent.n_nonzero)--; }
return *this;
}
template<typename eT>
inline
SpSubview_MapMat_val<eT>&
SpSubview_MapMat_val<eT>::operator/=(const eT in_val)
{
arma_extra_debug_sigprint();
const uword old_n_nonzero = sv_parent.m.n_nonzero;
SpMat_MapMat_val<eT>::operator/=(in_val);
if(sv_parent.m.n_nonzero > old_n_nonzero) { access::rw(sv_parent.n_nonzero)++; }
if(sv_parent.m.n_nonzero < old_n_nonzero) { access::rw(sv_parent.n_nonzero)--; }
return *this;
}
template<typename eT>
inline
SpSubview_MapMat_val<eT>&
SpSubview_MapMat_val<eT>::operator++()
{
arma_extra_debug_sigprint();
const uword old_n_nonzero = sv_parent.m.n_nonzero;
SpMat_MapMat_val<eT>::operator++();
if(sv_parent.m.n_nonzero > old_n_nonzero) { access::rw(sv_parent.n_nonzero)++; }
if(sv_parent.m.n_nonzero < old_n_nonzero) { access::rw(sv_parent.n_nonzero)--; }
return *this;
}
template<typename eT>
inline
arma_warn_unused
eT
SpSubview_MapMat_val<eT>::operator++(int)
{
arma_extra_debug_sigprint();
const uword old_n_nonzero = sv_parent.m.n_nonzero;
const eT old_val = SpMat_MapMat_val<eT>::operator++(int(0));
if(sv_parent.m.n_nonzero > old_n_nonzero) { access::rw(sv_parent.n_nonzero)++; }
if(sv_parent.m.n_nonzero < old_n_nonzero) { access::rw(sv_parent.n_nonzero)--; }
return old_val;
}
template<typename eT>
inline
SpSubview_MapMat_val<eT>&
SpSubview_MapMat_val<eT>::operator--()
{
arma_extra_debug_sigprint();
const uword old_n_nonzero = sv_parent.m.n_nonzero;
SpMat_MapMat_val<eT>::operator--();
if(sv_parent.m.n_nonzero > old_n_nonzero) { access::rw(sv_parent.n_nonzero)++; }
if(sv_parent.m.n_nonzero < old_n_nonzero) { access::rw(sv_parent.n_nonzero)--; }
return *this;
}
template<typename eT>
inline
arma_warn_unused
eT
SpSubview_MapMat_val<eT>::operator--(int)
{
arma_extra_debug_sigprint();
const uword old_n_nonzero = sv_parent.m.n_nonzero;
const eT old_val = SpMat_MapMat_val<eT>::operator--(int(0));
if(sv_parent.m.n_nonzero > old_n_nonzero) { access::rw(sv_parent.n_nonzero)++; }
if(sv_parent.m.n_nonzero < old_n_nonzero) { access::rw(sv_parent.n_nonzero)--; }
return old_val;
}
//! @}
|
; Prevent Kokiri Sword from being added to inventory on game load
; Replaces:
; sh t9, 0x009C (v0)
.orga 0xBAED6C ; In memory: 0x803B2B6C
nop
;==================================================================================================
; Time Travel
;==================================================================================================
; Prevents FW from being unset on time travel
; Replaces:
; SW R0, 0x0E80 (V1)
.orga 0xAC91B4 ; In memory: 0x80053254
nop
; Replaces:
; jal 8006FDCC ; Give Item
.orga 0xCB6874 ; Bg_Toki_Swd addr 809190F4 in func_8091902C
jal give_master_sword
; Replaces:
; lui/addiu a1, 0x8011A5D0
.orga 0xAE5764
j before_time_travel
nop
; After time travel
; Replaces:
; jr ra
.orga 0xAE59E0 ; In memory: 0x8006FA80
j after_time_travel
;==================================================================================================
; Door of Time Fix
;==================================================================================================
.orga 0xAC8608; 800526A8
or a0, s0
lh t6, 0x00A4(a0)
li at, 67
nop
nop
;==================================================================================================
; Item Overrides
;==================================================================================================
; Patch NPCs to give override-compatible items
.orga 0xDB13D3 :: .byte 0x76 ; Frog Ocarina Game
.orga 0xDF2647 :: .byte 0x76 ; Ocarina memory game
.orga 0xE2F093 :: .byte 0x34 ; Bombchu Bowling Bomb Bag
.orga 0xEC9CE7 :: .byte 0x7A ; Deku Theater Mask of Truth
; Runs when storing an incoming item to the player instance
; Replaces:
; sb a2, 0x0424 (a3)
; sw a0, 0x0428 (a3)
.orga 0xA98C30 ; In memory: 0x80022CD0
jal get_item_hook
sw a0, 0x0428 (a3)
; Override object ID (NPCs)
; Replaces:
; lw a2, 0x0030 (sp)
; or a0, s0, r0
; jal ...
; lh a1, 0x0004 (a2)
.orga 0xBDA0D8 ; In memory: 0x803950C8
jal override_object_npc
or a0, s0, r0
.skip 4
nop
; Override object ID (Chests)
; Replaces:
; lw t9, 0x002C (sp)
; or a0, s0, r0
; jal ...
; lh a1, 0x0004 (t9)
.orga 0xBDA264 ; In memory: 0x80395254
jal override_object_chest
or a0, s0, r0
.skip 4
nop
; Override graphic ID
; Replaces:
; bltz v1, A
; subu t0, r0, v1
; jr ra
; sb v1, 0x0852 (a0)
; A:
; sb t0, 0x0852 (a0)
; jr ra
.orga 0xBCECBC ; In memory: 0x80389CAC
j override_graphic
nop
nop
nop
nop
nop
; Override chest speed
; Replaces:
; lb t2, 0x0002 (t1)
; bltz t2, @@after_chest_speed_check
; nop
; jal 0x80071420
; nop
.orga 0xBDA2E8 ; In memory: 0x803952D8
jal override_chest_speed
lb t2, 0x0002 (t1)
bltz t3, @@after_chest_speed_check
nop
nop
.skip 4 * 22
@@after_chest_speed_check:
; Override text ID
; Replaces:
; lbu a1, 0x03 (v0)
; sw a3, 0x0028 (sp)
.orga 0xBE9AC0 ; In memory: 0x803A4AB0
jal override_text
sw a3, 0x0028 (sp)
; Override action ID
; Replaces:
; lw v0, 0x0024 (sp)
; lw a0, 0x0028 (sp)
; jal 0x8006FDCC
; lbu a1, 0x0000 (v0)
.orga 0xBE9AD8 ; In memory: 0x803A4AC8
jal override_action
lw v0, 0x0024 (sp)
.skip 4
lw a0, 0x0028 (sp)
; Inventory check
; Replaces:
; jal 0x80071420
; sw a2, 0x0030 (sp)
.orga 0xBDA0A0 ; In memory: 0x80395090
jal inventory_check
sw a2, 0x0030 (sp)
; Prevent Silver Gauntlets warp
; Replaces:
; addiu at, r0, 0x0035
.orga 0xBE9BDC ; In memory: 0x803A4BCC
addiu at, r0, 0x8383 ; Make branch impossible
; Change Skulltula Token to give a different item
; Replaces
; move a0, s1
; jal 0x0006FDCC ; call ex_06fdcc(ctx, 0x0071); VROM: 0xAE5D2C
; li a1, 0x71
; lw t5, 0x2C (sp) ; t5 = what was *(ctx + 0x1c44) at the start of the function
; li t4, 0x0A
; move a0, s1
; li a1, 0xB4 ; a1 = 0x00b4 ("You destoryed a Gold Skulltula...")
; move a2, zero
; jal 0x000DCE14 ; call ex_0dce14(ctx, 0x00b4, 0)
; sh t4, 0x110 (t5) ; *(t5 + 0x110) = 0x000a
.orga 0xEC68BC
.area 0x28, 0
lw t5, 0x2C (sp) ; original code
li t4, 0x0A ; original code
sh t4, 0x110 (t5) ; original code
jal get_skulltula_token ; call override_skulltula_token(actor)
move a0, s0
.endarea
.orga 0xEC69AC
.area 0x28, 0
lw t5, 0x2C (sp) ; original code
li t4, 0x0A ; original code
sh t4, 0x110 (t5) ; original code
jal get_skulltula_token ; call override_skulltula_token(actor)
move a0, s0
.endarea
;==================================================================================================
; Every frame hooks
;==================================================================================================
; Runs before the game state update function
; Replaces:
; lw t6, 0x0018 (sp)
; lui at, 0x8010
.orga 0xB12A34 ; In memory: 0x8009CAD4
jal before_game_state_update_hook
nop
; Runs after the game state update function
; Replaces:
; jr ra
; nop
.orga 0xB12A60 ; In memory: 0x8009CB00
j after_game_state_update
nop
;==================================================================================================
; Scene init hook
;==================================================================================================
; Runs after scene init
; Replaces:
; jr ra
; nop
.orga 0xB12E44 ; In memory: 0x8009CEE4
j after_scene_init
nop
;==================================================================================================
; Freestanding models
;==================================================================================================
; Replaces:
; jal 0x80013498 ; Piece of Heart draw function
.orga 0xA88F78 ; In memory: 0x80013018
jal heart_piece_draw
; Replaces:
; jal 0x80013498 ; Collectable draw function
.orga 0xA89048 ; In memory: 0x800130E8
jal small_key_draw
; Replaces:
; addiu sp, sp, -0x48
; sw ra, 0x1C (sp)
.orga 0xCA6DC0
j heart_container_draw
nop
.orga 0xDE1018
.area 10 * 4, 0
jal item_etcetera_draw
nop
.endarea
; Replaces:
; addiu sp, sp, -0x18
; sw ra, 0x14 (sp)
.orga 0xDE1050
j item_etcetera_draw
nop
; Replaces:
; addiu sp, sp, -0x18
; sw ra, 0x14 (sp)
.orga 0xE59E68
j bowling_bomb_bag_draw
nop
; Replaces:
; addiu sp, sp, -0x18
; sw ra, 0x14 (sp)
.orga 0xE59ECC
j bowling_heart_piece_draw
nop
; Replaces:
; addiu sp, sp, -0x18
; sw ra, 0x14 (sp)
.orga 0xEC6B04
j skull_token_draw
nop
; Replaces:
; addiu sp, sp, -0x18
; sw ra, 0x14 (sp)
.orga 0xDB53E8
j ocarina_of_time_draw
nop
;==================================================================================================
; File select hash
;==================================================================================================
; Runs after the file select menu is rendered
; Replaces: code that draws the fade-out rectangle on file load
.orga 0xBAF738 ; In memory: 0x803B3538
.area 0x60, 0
jal draw_file_select_hash
andi a0, t8, 0xFF ; a0 = alpha channel of fade-out rectangle
lw s0, 0x18 (sp)
lw ra, 0x1C (sp)
jr ra
addiu sp, sp, 0x88
.endarea
;==================================================================================================
; Special item sources
;==================================================================================================
; Override Light Arrow cutscene
; Replaces:
; addiu t8, r0, 0x0053
; ori t9, r0, 0xFFF8
; sw t8, 0x0000 (s0)
; b 0x80056F84
; sw t9, 0x0008 (s0)
.orga 0xACCE88 ; In memory: 0x80056F28
jal push_delayed_item
li a0, DELAYED_LIGHT_ARROWS
nop
nop
nop
; Make all Great Fairies give an item
; Replaces:
; jal 0x8002049C
; addiu a1, r0, 0x0038
.orga 0xC89744 ; In memory: 0x801E3884
jal override_great_fairy_cutscene
addiu a1, r0, 0x0038
; Upgrade fairies check scene chest flags instead of magic/defense
; Mountain Summit Fairy
; Replaces:
; lbu t6, 0x3A (a1)
.orga 0xC89868 ; In memory: 0x801E39A8
lbu t6, 0x1D28 (s0)
; Crater Fairy
; Replaces:
; lbu t9, 0x3C (a1)
.orga 0xC898A4 ; In memory: 0x801E39E4
lbu t9, 0x1D29 (s0)
; Ganon's Castle Fairy
; Replaces:
; lbu t2, 0x3D (a1)
.orga 0xC898C8 ; In memory: 0x801E3A08
lbu t2, 0x1D2A (s0)
; Upgrade fairies never check for magic meter
; Replaces:
; lbu t6, 0xA60A (t6)
.orga 0xC892DC ; In memory: 0x801E341C
li t6, 1
; Item fairies never check for magic meter
; Replaces:
; lbu t2, 0xA60A (t2)
.orga 0xC8931C ; In memory: 0x801E345C
li t2, 1
;==================================================================================================
; Pause menu
;==================================================================================================
; Create a blank texture, overwriting a Japanese item description
.orga 0x89E800
.fill 0x400, 0
; Don't display hover boots in the bullet bag/quiver slot if you haven't gotten a slingshot before becoming adult
; Replaces:
; lbu t4, 0x0000 (t7)
; and t6, v1, t5
.orga 0xBB6CF0
jal equipment_menu_fix
nop
; Use a blank item description texture if the cursor is on an empty slot
; Replaces:
; sll t4, v1, 10
; addu a1, t4, t5
.orga 0xBC088C ; In memory: 0x8039820C
jal menu_use_blank_description
nop
;==================================================================================================
; Equipment menu
;==================================================================================================
; Left movement check
; Replaces:
; beqz t3, 0x8038D9FC
; nop
.orga 0xBB5EAC ; In memory: 0x8038D834
nop
nop
; Right movement check
; Replaces:
; beqz t3, 0x8038D9FC
; nop
.orga 0xBB5FDC ; In memory: 0x8038D95C
nop
nop
; Upward movement check
; Replaces:
; beqz t6, 0x8038DB90
; nop
.orga 0xBB6134 ; In memory: 0x8038DABC
nop
nop
; Downward movement check
; Replaces:
; beqz t9, 0x8038DB90
; nop
.orga 0xBB61E0 ; In memory: 0x8038DB68
nop
nop
; Remove "to Equip" text if the cursor is on an empty slot
; Replaces:
; lbu v1, 0x0000 (t4)
; addiu at, r0, 0x0009
.orga 0xBB6688 ; In memory: 0x8038E008
jal equipment_menu_prevent_empty_equip
nop
; Prevent empty slots from being equipped
; Replaces:
; addu t8, t4, v0
; lbu v1, 0x0000 (t8)
.orga 0xBB67C4 ; In memory: 0x8038E144
jal equipment_menu_prevent_empty_equip
addu t4, t4, v0
;==================================================================================================
; Item menu
;==================================================================================================
; Left movement check
; Replaces:
; beq s4, t5, 0x8038F2B4
; nop
.orga 0xBB77B4 ; In memory: 0x8038F134
nop
nop
; Right movement check
; Replaces:
; beq s4, t4, 0x8038F2B4
; nop
.orga 0xBB7894 ; In memory: 0x8038F214
nop
nop
; Upward movement check
; Replaces:
; beq s4, t4, 0x8038F598
; nop
.orga 0xBB7BA0 ; In memory: 0x8038F520
nop
nop
; Downward movement check
; Replaces:
; beq s4, t4, 0x8038F598
; nop
.orga 0xBB7BFC ; In memory: 0x8038F57C
nop
nop
; Remove "to Equip" text if the cursor is on an empty slot
; Replaces:
; addu s1, t6, t7
; lbu v0, 0x0000 (s1)
.orga 0xBB7C88 ; In memory: 0x8038F608
jal item_menu_prevent_empty_equip
addu s1, t6, t7
; Prevent empty slots from being equipped
; Replaces:
; lbu v0, 0x0000 (s1)
; addiu at, r0, 0x0009
.orga 0xBB7D10 ; In memory: 0x8038F690
jal item_menu_prevent_empty_equip
nop
;==================================================================================================
; Song Fixes
;==================================================================================================
; Replaces:
; lw t5, 0x8AA0(t5)
.orga 0xAE5DF0 ; In memory: 8006FE90
jal suns_song_fix
; Replaces:
; addu at, at, s3
.orga 0xB54E5C ; In memory: 800DEEFC
jal suns_song_fix_event
; Replaces:
; addu at, at, s3
.orga 0xB54B38 ; In memory: 800DEBD8
jal warp_song_fix
;==================================================================================================
; Initial save
;==================================================================================================
; Replaces:
; sb t0, 32(s1)
; sb a1, 33(s1)
.orga 0xB06C2C ; In memory: ???
jal write_initial_save
sb t0, 32(s1)
;==================================================================================================
; Enemy Hacks
;==================================================================================================
; Replaces:
; beq t1, at, 0x801E51E0
.orga 0xD74964 ; In memory: 0x801E51B4
b skip_steal_tunic ; disable like-like stealing tunic
.orga 0xD74990
skip_steal_tunic:
;==================================================================================================
; Ocarina Song Cutscene Overrides
;==================================================================================================
; Replaces:
; jal 0x800288B4
.orga 0xACCDE0 ; In memory: 0x80056E80
jal give_sarias_gift
; a3 = item ID
; Replaces:
; li v0, 0xFF
; ... (2 instructions)
; sw t7, 0xA4 (t0)
.orga 0xAE5DF8 ; In memory: 0x8006FE98
jal override_ocarina_songs
.skip 0x8
nop
; Replaces
; lui at, 0x1
; addu at, at, s0
.orga 0xAC9ABC ; In memory: 0x80053B5C
jal override_requiem_song
nop
;lw $t7, 0xa4($v1)
;lui $v0, 0x200
;addiu $v0, $v0, 0x24a0
;and $t8, $t6, $t7
.orga 0xE09F68
lb t7,0x0EDE(v1) ; check learned song from sun's song
.skip 4
.skip 4
andi t8, t7, 0x04
;addiu $t7, $zero, 1
.orga 0xE09FB0
jal override_suns_song
; lw $t7, 0xa4($s0)
; lui $t3, 0x8010
; addiu $t3, $t3, -0x70cc
; and $t8, $t6, $t7
.orga 0xB06400
lb t7,0x0EDE(s0) ; check learned song from ZL
.skip 4
.skip 4
andi t8, t7, 0x02
; Impa does not despawn from Zelda Escape CS
.orga 0xD12F78
li t7, 0
;li v1, 5
.orga 0xE29388
j override_saria_song_check
;lh v0, 0xa4(t6) ; v0 = scene
.orga 0xE2A044
jal set_saria_song_flag
; li a1, 3
.orga 0xDB532C
jal override_song_of_time
;==================================================================================================
; Fire Arrow location spawn condition
;==================================================================================================
; Replaces a check for whether fire arrows are in the inventory
; The item spawns if t9 == at
.orga 0xE9E1B8
.area 6 * 4, 0
lw t9, (GLOBAL_CONTEXT + 0x1D38) ; Chest flags
andi t9, t9, 0x1
ori at, r0, 0
.endarea
;==================================================================================================
; Epona Check Override
;==================================================================================================
.orga 0xA9E838
j Check_Has_Epona_Song
;==================================================================================================
; Shop Injections
;==================================================================================================
; Check sold out override
.orga 0xC004EC
j Shop_Check_Sold_Out
; Allow Shop Item ID up to 100 instead of 50
; slti at, v1, 0x32
.orga 0xC0067C
slti at, v1, 100
; Set sold out override
; lh t6, 0x1c(a1)
.orga 0xC018A0
jal Shop_Set_Sold_Out
; Only run init function if ID is in normal range
; jr t9
.orga 0xC6C7A8
jal Shop_Keeper_Init_ID
.orga 0xC6C920
jal Shop_Keeper_Init_ID
; Override Deku Salescrub sold out check
; addiu at, zero, 2
; lui v1, 0x8012
; bne v0, at, 0xd8
; addiu v1, v1, -0x5a30
; lhu t9, 0xef0(v1)
.orga 0xEBB85C
jal Deku_Check_Sold_Out
.skip 4
bnez v0, @Deku_Check_True
.skip 4
b @Deku_Check_False
.orga 0xEBB8B0
@Deku_Check_True:
.orga 0xEBB8C0
@Deku_Check_False:
; Ovveride Deku Scrub set sold out
; sh t7, 0xef0(v0)
.orga 0xDF7CB0
jal Deku_Set_Sold_Out
;==================================================================================================
; Dungeon info display
;==================================================================================================
; Talk to Temple of Time Altar injection
; Replaces:
; jal 0xD6218
.orga 0xE2B0B4
jal set_dungeon_knowledge
;==================================================================================================
; V1.0 Scarecrow Song Bug
;==================================================================================================
; Replaces:
; jal 0x80057030 ; copies Scarecrow Song from active space to save context
.orga 0xB55A64 ; In memory 800DFB04
jal save_scarecrow_song
;==================================================================================================
; Override Player Name Text
;==================================================================================================
; Replaces
; lui t2,0x8012
; addu t2,t2,s3
; lbu t2,-23053(t2)
.orga 0xB51694
jal get_name_char_1
;addi a0, s3, -1
;ori t2, v0, 0
; Replaces
; lui s0,0x8012
; addu s0,s0,s2
; lbu s0,-23052(s0)
.orga 0xB516C4
jal get_name_char_2
;ori a0, s2, 0
;ori s0, v0, 0
; Replaces
; lw s6,48(sp)
; lw s7,52(sp)
; lw s8,56(sp)
.orga 0xB52784
jal reset_player_name_id
nop
lw ra, 0x3C (sp)
;==================================================================================================
; Text Fixes
;==================================================================================================
; Skip text overrides for GS Token and Biggoron Sword
; Replaces
; li at, 0x0C
.orga 0xB5293C
b skip_GS_BGS_text
.orga 0xB529A0
skip_GS_BGS_text:
;==================================================================================================
; Empty bomb fix
;==================================================================================================
; Replaces:
; lw a1, 0x0018 (sp) ; bomb ovl+134
; lw a0, 0x001C (sp)
.orga 0xC0E404
jal empty_bomb_fix
lw a1, 0x0018 (sp)
;==================================================================================================
; Damage Multiplier
;==================================================================================================
; Replaces:
; lbu t7, 0x3d(a1)
; beql t7, zero, 0x20
; lh t8, 0x30(a1)
; bgezl s0, 0x20
; lh t8, 0x30(a1)
; sra s0, s0, 1 ; double defense
; sll s0, s0, 0x10
; sra s0, s0, 0x10 ; s0 = damage
.orga 0xAE807C
bgez s0, @@continue ; check if damage is negative
lh t8, 0x30(a1) ; load hp for later
jal Apply_Damage_Multiplier
nop
lh t8, 0x30(a1) ; load hp for later
nop
nop
nop
@@continue:
;==================================================================================================
; Skip Scarecrow Song
;==================================================================================================
; Replaces:
; lhu t0, 0x04C6 (t0)
; li at, 0x0B
.orga 0xEF4F98
jal adapt_scarecrow
nop
;==================================================================================================
; Talon Cutscene Skip
;==================================================================================================
; Replaces: lw a0, 0x0018(sp)
; addiu t1, r0, 0x0041
.orga 0xCC0038
jal talon_break_free
lw a0, 0x0018(sp)
;==================================================================================================
; Patches.py imports
;==================================================================================================
; Remove intro cutscene
.orga 0xB06BB8
li t9, 0
; Change Bombchu Shop to be always open
.orga 0xC6CEDC
li t3, 1
; Fix child shooting gallery reward to be static
.orga 0xD35EFC
nop
; Fix Link the Goron to always work
.orga 0xED2FAC
lb t6, 0x0F18(v1)
.orga 0xED2FEC
li t2, 0
.orga 0xAE74D8
li t6, 0
; Fix King Zora Thawed to always work
.orga 0xE55C4C
li t4, 0
.orga 0xE56290
nop
li t3, 0x401F
nop
; Fix target in woods reward to be static
.orga 0xE59CD4
nop
nop
; Fix adult shooting gallery reward to be static
.orga 0xD35F54
b_a 0xD35F78
; Learning Serenade tied to opening chest in room
.orga 0xC7BCF0
lw t9, 0x1D38(a1) ; Chest Flags
li t0, 0x0004 ; flag mask
lw v0, 0x1C44(a1) ; needed for following code
nop
nop
nop
nop
; Dampe Chest spawn condition looks at chest flag instead of having obtained hookshot
.orga 0xDFEC3C
lw t8, (SAVE_CONTEXT + 0xDC + (0x48 * 0x1C)) ; Scene clear flags
addiu a1, sp, 0x24
andi t9, t8, 0x0010 ; clear flag 4
nop
; Darunia sets an event flag and checks for it
; TODO: Figure out what is this for. Also rewrite to make things cleaner
.orga 0xCF1AB8
nop
lw t1, lo(SAVE_CONTEXT + 0xED8)(t8)
andi t0, t1, 0x0040
ori t9, t1, 0x0040
sw t9, lo(SAVE_CONTEXT + 0xED8)(t8)
li t1, 6
;==================================================================================================
; Easier Fishing
;==================================================================================================
; Make fishing less obnoxious
.orga 0xDBF428
jal easier_fishing
lui at, 0x4282
mtc1 at, f8
mtc1 t8, f18
swc1 f18, 0x019C(s2)
.orga 0xDBF484
nop
.orga 0xDBF4A8
nop
; set adult fish size requirement
.orga 0xDCBEA8
lui at, 0x4248
.orga 0xDCBF24
lui at, 0x4248
; set child fish size requirements
.orga 0xDCBF30
lui at, 0x4230
.orga 0xDCBF9C
lui at, 0x4230
; Fish bite guaranteed when the hook is stable
; Replaces: lwc1 f10, 0x0198(s0)
; mul.s f4, f10, f2
.orga 0xDC7090
jal fishing_bite_when_stable
lwc1 f10, 0x0198(s0)
; Remove most fish loss branches
.orga 0xDC87A0
nop
.orga 0xDC87BC
nop
.orga 0xDC87CC
nop
; Prevent RNG fish loss
; Replaces: addiu at, zero, 0x0002
.orga 0xDC8828
move at, t5
;==================================================================================================
; Bombchus In Logic Hooks
;==================================================================================================
.orga 0xE2D714
jal logic_chus__bowling_lady_1
lui t9, 0x8012
li t1, 0xBF
nop
.orga 0xE2D890
jal logic_chus__bowling_lady_2
nop
.orga 0xC01078
jal logic_chus__shopkeeper
nop
nop
nop
nop
nop
;==================================================================================================
; Rainbow Bridge
;==================================================================================================
.orga 0xE2B434
.area 0x30, 0
jal rainbow_bridge
nop
.endarea
;==================================================================================================
; Gossip Stone Hints
;==================================================================================================
.orga 0xEE7B84
.area 0x24, 0
jal gossip_hints
lw a0, 0x002C(sp) ; global context
.endarea
;==================================================================================================
; Potion Shop Fix
;==================================================================================================
.orga 0xE2C03C
jal potion_shop_fix
addiu v0, v0, 0xA5D0 ; displaced
;==================================================================================================
; Jabu Jabu Elevator
;==================================================================================================
;Replaces: addiu t5, r0, 0x0200
.orga 0xD4BE6C
jal jabu_elevator
;==================================================================================================
; DPAD Display
;==================================================================================================
;
; Replaces lw t6, 0x1C44(s6)
; lui t8, 0xDB06
.orga 0xAEB67C ; In Memory: 0x8007571C
jal dpad_draw
nop
;==================================================================================================
; Stone of Agony indicator
;==================================================================================================
; Replaces:
; c.lt.s f0, f2
.orga 0xBE4A14
jal agony_distance_hook
; Replaces:
; c.lt.s f4, f6
.orga 0xBE4A40
jal agony_vibrate_hook
; Replaces:
; addiu sp, sp, 0x20
; jr ra
.orga 0xBE4A60
j agony_post_hook
nop
;==================================================================================================
; Correct Chest Sizes
;==================================================================================================
; Replaces lbu v0,0x01E9(s0)
.orga 0xC064BC
jal GET_CHEST_OVERRIDE_SIZE_WRAPPER
.orga 0xC06E5C
jal GET_CHEST_OVERRIDE_SIZE_WRAPPER
.orga 0xC07494
jal GET_CHEST_OVERRIDE_SIZE_WRAPPER
; Replaces sw t8,8(t6)
; lbu v0,489(s0)
.orga 0xC0722C
jal GET_CHEST_OVERRIDE_SIZE_WRAPPER
sw t8,8(t6)
; Replaces lbu t9,0x01E9(s0)
.orga 0xC075A8
jal GET_CHEST_OVERRIDE_COLOR_WRAPPER
.orga 0xC07648
jal GET_CHEST_OVERRIDE_COLOR_WRAPPER
;==================================================================================================
; Cast Fishing Rod without B Item
;==================================================================================================
.orga 0xBCF914 ; 8038A904
jal keep_fishing_rod_equipped
nop
.orga 0xBCF73C ; 8038A72C
sw ra, 0x0000(sp)
jal cast_fishing_rod_if_equipped
nop
lw ra, 0x0000(sp)
;==================================================================================================
; Big Goron Fix
;==================================================================================================
;
;Replaces: beq $zero, $zero, lbl_80B5AD64
.orga 0xED645C
jal bgs_fix
nop
;==================================================================================================
; Hot Rodder Goron without Bomb Bag
;==================================================================================================
;
;Replaces: LW T8, 0x00A0 (V0)
.orga 0xED2858
addi t8, r0, 0x0008
;==================================================================================================
; Warp song speedup
;==================================================================================================
;
.orga 0xBEA044
jal warp_speedup
nop
;==================================================================================================
; Dampe Digging Fix
;==================================================================================================
;
; Dig Anywhere
.orga 0xCC3FA8
sb at, 0x1F8(s0)
; Always First Try
.orga 0xCC4024
nop
; Leaving without collecting dampe's prize won't lock you out from that prize
.orga 0xCC4038
jal dampe_fix
addiu t4, r0, 0x0004
.orga 0xCC453C
.word 0x00000806
;==================================================================================================
; Drawbridge change
;==================================================================================================
;
; Replaces: SH T9, 0x00B4 (S0)
.orga 0xC82550
nop
;==================================================================================================
; Never override menu subscreen index
;==================================================================================================
; Replaces: bnezl t7, 0xAD1988 ; 0x8005BA28
.orga 0xAD193C ; 0x8005B9DC
b . + 0x4C
;==================================================================================================
; Extended Objects Table
;==================================================================================================
; extends object table lookup for on chest open
.org 0xBD6958
jal extended_object_lookup_GI
nop
; extends object table lookup for on scene loads
.org 0xAF76B8
sw ra, 0x0C (sp)
jal extended_object_lookup_load
subu t7, r0, a2
lw ra, 0x0C (sp)
; extends object table lookup for shop item load
.org 0xAF74F8
sw ra, 0x44 (sp)
jal extended_object_lookup_shop
nop
lw ra, 0x44 (sp)
; extends object table lookup for shop item load after you unpause
.org 0xAF7650
sw ra, 0x34 (sp)
jal extended_object_lookup_shop_unpause
nop
lw ra, 0x34 (sp)
;==================================================================================================
; Cow Shuffle
;==================================================================================================
.orga 0xEF36E4
jal cow_item_hook
nop
.orga 0xEF32B8
jal cow_after_init
nop
lw ra, 0x003C (sp)
.orga 0xEF373C
jal cow_bottle_check
nop
;==================================================================================================
; Make Bunny Hood like Majora's Mask
;==================================================================================================
; Replaces: mfc1 a1, f12
; mtc1 t7, f4
.orga 0xBD9A04
jal bunny_hood
nop
;==================================================================================================
; Prevent hyrule guards from casuing a softlock if they're culled
;==================================================================================================
.orga 0xE24E7C
jal guard_catch
nop
;==================================================================================================
; Never override Heart Colors
;==================================================================================================
; Replaces:
; SH A2, 0x020E (V0)
; SH T9, 0x0212 (V0)
; SH A0, 0x0216 (V0)
.orga 0xADA8A8
nop
nop
nop
; Replaces:
; SH T5, 0x0202 (V0)
.orga 0xADA97C
nop
.orga 0xADA9A8
nop
.orga 0xADA9BC
nop
.orga 0xADAA64
nop
.orga 0xADAA74
nop
nop
.orga 0xADABA8
nop
.orga 0xADABCC
nop
.orga 0xADABE4
nop
;==================================================================================================
; Magic Meter Colors
;==================================================================================================
; Replaces: sh r0, 0x0794 (t6)
; lw t7, 0x0000 (v0)
; sh r0, 0x0796 (t7)
; lw t7, 0x0000 (v0)
; sh r0, 0x0798 (t8)
.orga 0xB58320
sw ra, 0x0000 (sp)
jal magic_colors
nop
lw ra, 0x0000 (sp)
nop
;==================================================================================================
; Add ability to control Lake Hylia's water level
;==================================================================================================
.orga 0xD5B264
jal Check_Fill_Lake
.orga 0xD5B660
j Fill_Lake_Destroy
nop
.orga 0xEE7E4C
jal Hit_Gossip_Stone
.orga 0x26C10E3
.byte 0xFF ; Set generic grotto text ID to load from grotto ID
;==================================================================================================
; Disable trade quest timers in ER
;==================================================================================================
; Replaces: lui at, 0x800F
; sw r0, 0x753C(at)
.orga 0xAE986C ; in memory 8007390C
j disable_trade_timers
lui at, 0x800F
;==================================================================================================
; Remove Shooting gallery actor when entering the room with the wrong age
;==================================================================================================
.orga 0x00D357D4
jal shooting_gallery_init ; addiu t6, zero, 0x0001
;==================================================================================================
; static context init hook
;==================================================================================================
.orga 0xAC7AD4
jal Static_ctxt_Init
;==================================================================================================
; burning kak from any entrance to kak
;==================================================================================================
; Replaces: lw t9, 0x0000(s0)
; addiu at, 0x01E1
.orga 0xACCD34
jal burning_kak
lw t9, 0x0000(s0)
;==================================================================================================
; Set the Obtained Epona Flag when winning the 2nd Ingo Race in ER
;==================================================================================================
; Replaces: lw t9, 0x0024(s0)
; sw t9, 0x0000(t7)
.orga 0xD52698
jal ingo_race_win
lw t9, 0x0024(s0)
;==================================================================================================
; Magic Bean Salesman Shuffle
;==================================================================================================
; Replaces: addu v0, v0, t7
; lb v0, -0x59A4(v0)
.orga 0xE20410
jal bean_initial_check
nop
; Replaces: addu t0, v0, t9
; lb t1, 0x008C(t0)
.orga 0xE206DC
jal bean_enough_rupees_check
nop
; Replaces: addu t7, t7, t6
; lb t7, -0x59A4(t7)
.orga 0xE20798
jal bean_rupees_taken
nop
; Replaces: sw a0, 0x20(sp)
; sw a1, 0x24(sp)
.orga 0xE2076C
jal bean_buy_item_hook
sw a0, 0x20(sp)
;==================================================================================================
; Load Audioseq using dmadata
;==================================================================================================
; Replaces: lui a1, 0x0003
; addiu a1, a1, -0x6220
.orga 0xB2E82C ; in memory 0x800B88CC
lw a1, 0x8000B188
;==================================================================================================
; Load Audiotable using dmadata
;==================================================================================================
; Replaces: lui a1, 0x0008
; addiu a1, a1, -0x6B90
.orga 0xB2E854
lw a1, 0x8000B198
;==================================================================================================
; Handle grottos shuffled with other entrances
;==================================================================================================
; Replaces: lui at, 1
; addu at, at, a3
.orga 0xCF73C8
jal grotto_entrance
lui at, 1
; Replaces: addu at, at, a3
; sh t6, 0x1E1A(at)
.orga 0xBD4C58
jal scene_exit_hook
addu at, at, a3
;==================================================================================================
; Getting Caught by Gerudo NPCs in ER
;==================================================================================================
; Replaces: lui at, 0x0001
; addu at, at, a1
.orga 0xE11F90 ; White-clothed Gerudo
jal gerudo_caught_entrance
nop
.orga 0xE9F678 ; Patrolling Gerudo
jal gerudo_caught_entrance
nop
.orga 0xE9F7A8 ; Patrolling Gerudo
jal gerudo_caught_entrance
nop
; Replaces: lui at, 0x0001
; addu at, at, v0
.orga 0xEC1120 ; Gerudo Fighter
jal gerudo_caught_entrance
nop
;==================================================================================================
; Song of Storms Effect Trigger Changes
;==================================================================================================
; Allow a storm to be triggered with the song in any environment
; Replaces: lui t5, 0x800F
; lbu t5, 0x1648(t5)
.orga 0xE6BF4C
li t5, 0
nop
; Remove the internal cooldown between storm effects (to open grottos, grow bean plants...)
; Replaces: bnez at, 0x80AECC6C
.orga 0xE6BEFC
nop
;==================================================================================================
; Change the Light Arrow Cutscene trigger condition.
;==================================================================================================
.orga 0xACCE18
jal lacs_condition_check
lw v0, 0x00A4(s0)
beqz_a v1, 0x00ACCE9C
nop
nop
nop
nop
nop
nop
nop
nop
;==================================================================================================
; Fix Lab Diving to always be available
;==================================================================================================
; Replaces: lbu t7, -0x709C(t7)
; lui a1, 0x8012
; addiu a1, a1, 0xA5D0 ; a1 = save context
; addu t8, a1, t7
; lbu t9, 0x0074(t8) ; t9 = owned adult trade item
.orga 0xE2CC1C
lui a1, 0x8012
addiu a1, a1, 0xA5D0 ; a1 = save context
lh t0, 0x0270(s0) ; t0 = recent diving depth (in meters)
bne t0, zero, @skip_eyedrops_dialog
lbu t9, 0x008A(a1) ; t9 = owned adult trade item
.orga 0xE2CC50
@skip_eyedrops_dialog:
;==================================================================================================
; Change Gerudo Guards to respond to the Gerudo's Card, not freeing the carpenters.
;==================================================================================================
; Patrolling Gerudo
.orga 0xE9F598
lui t6, 0x8012
lhu t7, 0xA674(t6)
andi t8, t7, 0x0040
beqzl t8, @@return
move v0, zero
li v0, 1
@@return:
jr ra
nop
nop
nop
nop
; White-clothed Gerudo
.orga 0xE11E94
lui v0, 0x8012
lhu v0, 0xA674(v0)
andi t6, v0, 0x0040
beqzl t6, @@return
move v0, zero
li v0, 1
@@return:
jr ra
nop
nop
nop
nop
nop
nop
nop
nop
;==================================================================================================
; In Dungeon ER, open Deku Tree's mouth as adult if Mido has been shown the sword/shield.
;==================================================================================================
.orga 0xC72C64
jal deku_mouth_condition
move a0, s0
lui a1, 0x808D
bnez_a t7, 0xC72C8C
nop
;==================================================================================================
; Running Man should fill wallet when trading Bunny Hood.
;==================================================================================================
.orga 0xE50888
li a0, 999
;==================================================================================================
; Change relevant checks to Bomb Bag
;==================================================================================================
; Bazaar Shop
; Replaces: lw t6, -0x73C4(t6)
; lw t7, 0x00A4(v0)
.orga 0xC0082C
li t6, 0x18
lw t7, 0x00A0(v0)
; Goron Shop
; Replaces: lhu t7, 0x0ED8(v1)
; andi t8, t7, 0x0020
.orga 0xC6ED84
lhu t7, 0x00A2(v1)
andi t8, t7, 0x0018
; Deku Salesman
; Replaces: lw t6, -0x73C4(t6)
; lw t7, 0x00A4(v0)
.orga 0xDF7A90
li t6, 0x18
lw t7, 0x00A0(v0)
; Bazaar Goron
; Replaces: lw t6, -0x73C4(t6)
; lw t7, 0x00A4(a2)
.orga 0xED5A28
li t6, 0x18
lw t7, 0x00A0(a2)
;==================================================================================================
; HUD Rupee Icon color
;==================================================================================================
; Replaces: lui at, 0xC8FF
; addiu t8, s1, 0x0008
; sw t8, 0x02B0(s4)
; sw t9, 0x0000(s1)
; lhu t4, 0x0252(s7)
; ori at, at, 0x6400 ; at = HUD Rupee Icon Color
.orga 0xAEB764
addiu t8, s1, 0x0008
sw t8, 0x02B0(s4)
jal rupee_hud_color
sw t9, 0x0000(s1)
lhu t4, 0x0252(s7)
move at, v0
;==================================================================================================
; Expand Audio Thread memory
;==================================================================================================
.headersize (0x800110A0 - 0xA87000)
//reserve the audio thread's heap
.org 0x800C7DDC
.area 0x1C
lui at, hi(AUDIO_THREAD_INFO_MEM_START)
lw a0, lo(AUDIO_THREAD_INFO_MEM_START)(at)
jal 0x800B8654
lw a1, lo(AUDIO_THREAD_INFO_MEM_SIZE)(at)
lw ra, 0x0014(sp)
jr ra
addiu sp, sp, 0x0018
.endarea
//allocate memory for fanfares and primary/secondary bgm
.org 0x800B5528
.area 0x18, 0
jal get_audio_pointers
.endarea
.org 0x800B5590
.area (0xE0 - 0x90), 0
li a0, 0x80128A50
li a1, AUDIO_THREAD_INFO
jal 0x80057030 //memcopy
li a2, 0x18
li a0, 0x80128A50
jal 0x800B3D18
nop
li a0, 0x80128A5C
jal 0x800B3DDC
nop
.endarea
.headersize 0
;==================================================================================================
; King Zora Init Moved Check Override
;==================================================================================================
; Replaces: lhu t0, 0x0EDA(v0)
; or a0, s0, zero
; andi t1, t0, 0x0008
.orga 0xE565D0
jal kz_moved_check
nop
or a0, s0, zero
; ==================================================================================================
; HUD Button Colors
; ==================================================================================================
; Fix HUD Start Button to allow a value other than 00 for the blue intensity
; Replaces: andi t6, t7, 0x00FF
.orga 0xAE9ED8
ori t6, t7, 0x0000 ; add blue intensity to the start button color (Value Mutated in Cosmetics.py)
; Handle Dynamic Shop Cursor Colors
.orga 0xC6FF30
.area 0x4C, 0
mul.s f16, f10, f0
mfc1 a1, f8 ; color delta 1 (for extreme colors)
trunc.w.s f18, f16
mfc1 a2, f18 ; color delta 2 (for general colors)
swc1 f0, 0x023C(a0) ; displaced code
addiu sp, sp, -0x18
sw ra, 0x04(sp)
jal shop_cursor_colors
nop
lw ra, 0x04(sp)
addiu sp, sp, 0x18
jr ra
nop
.endarea
|
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Copyright (c) Geoworks 1994 -- All Rights Reserved
PROJECT: Clavin
MODULE: Outbox
FILE: outboxC.asm
AUTHOR: Chung Liu, Nov 22, 1994
ROUTINES:
Name Description
---- -----------
MAILBOXSETCANCELACTION
REVISION HISTORY:
Name Date Description
---- ---- -----------
CL 11/22/94 Initial revision
DESCRIPTION:
C Interface
$Id: outboxC.asm,v 1.1 97/04/05 01:21:22 newdeal Exp $
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
SetGeosConvention
C_Mailbox segment resource
COMMENT @----------------------------------------------------------------------
C FUNCTION: MailboxSetCancelAction
C DECLARATION: void (optr destination, Message messageToSend)
KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
CHL 11/94 Initial version
------------------------------------------------------------------------------@
MAILBOXSETCANCELACTION proc far destination:optr,
messageToSend:word
uses si
.enter
movdw bxsi, destination
mov ax, messageToSend
call MailboxSetCancelAction
.leave
ret
MAILBOXSETCANCELACTION endp
C_Mailbox ends
SetDefaultConvention
|
#include "Platform.inc"
#include "FarCalls.inc"
#include "ArithmeticBcd.inc"
#include "SunriseSunset.inc"
#include "States.inc"
radix decimal
defineSunriseSunsetState SUN_STATE_SUNRISE_STORE
.setBankFor accumulatorLowerLow
movf accumulatorLowerLow, W
.setBankFor sunriseHourBcd
movwf sunriseHourBcd
.setBankFor accumulatorUpperLow
movf accumulatorUpperLow, W
.setBankFor sunriseMinuteBcd
movwf sunriseMinuteBcd
setSunriseSunsetState SUN_STATE_SUNRISE_STOREASBCD
returnFromSunriseSunsetState
defineSunriseSunsetStateInSameSection SUN_STATE_SUNRISE_STOREASBCD
.setBankFor sunriseHourBcd
movf sunriseHourBcd, W
.setBankFor RAA
movwf RAA
fcall binaryToBcd
.setBankFor sunriseHourBcd
movwf sunriseHourBcd
.setBankFor sunriseMinuteBcd
movf sunriseMinuteBcd, W
.setBankFor RAA
movwf RAA
fcall binaryToBcd
.setBankFor sunriseMinuteBcd
movwf sunriseMinuteBcd
setSunriseSunsetState SUN_STATE_CALCULATESUNSET
returnFromSunriseSunsetState
end
|
// Copyright (c) 2011-present, Facebook, Inc. All rights reserved.
// This source code is licensed under the BSD-style license found in the
// LICENSE file in the root directory of this source tree. An additional grant
// of patent rights can be found in the PATENTS file in the same directory.
#ifndef ROCKSDB_LITE
#include "utilities/blob_db/blob_db_options_impl.h"
namespace rocksdb {
namespace blob_db {
BlobDBOptionsImpl::BlobDBOptionsImpl(const BlobDBOptions& in)
: BlobDBOptions(in),
deletion_check_period_millisecs(2 * 1000),
gc_file_pct(20),
gc_check_period_millisecs(60 * 1000),
sanity_check_period_millisecs(20 * 60 * 1000),
open_files_trigger(100),
wa_num_stats_periods(24),
wa_stats_period_millisecs(3600 * 1000),
partial_expiration_gc_range_secs(4 * 3600),
partial_expiration_pct(75),
fsync_files_period_millisecs(10 * 1000),
reclaim_of_period_millisecs(1 * 1000),
delete_obsf_period_millisecs(10 * 1000),
check_seqf_period_millisecs(10 * 1000) {}
BlobDBOptionsImpl::BlobDBOptionsImpl()
: deletion_check_period_millisecs(2 * 1000),
gc_file_pct(20),
gc_check_period_millisecs(60 * 1000),
sanity_check_period_millisecs(20 * 60 * 1000),
open_files_trigger(100),
wa_num_stats_periods(24),
wa_stats_period_millisecs(3600 * 1000),
partial_expiration_gc_range_secs(4 * 3600),
partial_expiration_pct(75),
fsync_files_period_millisecs(10 * 1000),
reclaim_of_period_millisecs(1 * 1000),
delete_obsf_period_millisecs(10 * 1000),
check_seqf_period_millisecs(10 * 1000) {}
BlobDBOptionsImpl& BlobDBOptionsImpl::operator=(const BlobDBOptionsImpl& in) {
BlobDBOptions::operator=(in);
if (this != &in) {
deletion_check_period_millisecs = in.deletion_check_period_millisecs;
gc_file_pct = in.gc_file_pct;
gc_check_period_millisecs = in.gc_check_period_millisecs;
sanity_check_period_millisecs = in.sanity_check_period_millisecs;
open_files_trigger = in.open_files_trigger;
wa_num_stats_periods = in.wa_num_stats_periods;
wa_stats_period_millisecs = in.wa_stats_period_millisecs;
partial_expiration_gc_range_secs = in.partial_expiration_gc_range_secs;
partial_expiration_pct = in.partial_expiration_pct;
fsync_files_period_millisecs = in.fsync_files_period_millisecs;
reclaim_of_period_millisecs = in.reclaim_of_period_millisecs;
delete_obsf_period_millisecs = in.delete_obsf_period_millisecs;
check_seqf_period_millisecs = in.check_seqf_period_millisecs;
}
return *this;
}
} // namespace blob_db
} // namespace rocksdb
#endif // ROCKSDB_LITE
|
; A104582: Triangle read by rows: T(i,j) is the (i,j)-entry (1 <= j <= i) of the product of the lower triangular matrix (Fibonacci(i-j+1)) and of the lower triangular matrix all of whose entries are equal to 1 (for j <= i).
; 1,2,1,4,2,1,7,4,2,1,12,7,4,2,1,20,12,7,4,2,1,33,20,12,7,4,2,1,54,33,20,12,7,4,2,1,88,54,33,20,12,7,4,2,1,143,88,54,33,20,12,7,4,2,1,232,143,88,54,33,20,12,7,4,2,1,376,232,143,88,54,33,20,12,7,4,2,1,609,376,232
seq $0,25676 ; Exponent of 8 (value of i) in n-th number of form 8^i*9^j.
seq $0,166876 ; a(n) = a(n-1) + Fibonacci(n), a(1)=1983.
sub $0,1982
|
; A028116: Expansion of 1 / ((1-4*x)*(1-5*x)*(1-7*x)*(1-9*x)).
; Submitted by Simon Strandgaard
; 1,25,398,5162,59619,640227,6549376,64780804,625573157,5936696909,55620675474,516146265726,4755391291015,43574880995671,397637888433092,3617137005125528,32823750870307593,297304128579802113,2688988551055876630,24293750984286505810,219294209471175557291,1978203406122364021835,17835731151833975140488,160744943166804467552172,1448268325000655017094509,13045363266114318575120437,117484915215354029539319066,1057900794861307792977730214,9524863245189905373610573647,85750062776945748131043843519
mov $1,1
mov $2,$0
mov $3,$0
lpb $2
mov $0,$3
sub $2,1
sub $0,$2
seq $0,18911 ; Expansion of 1/((1-4x)(1-5x)(1-9x)).
sub $0,$1
mul $1,8
add $1,$0
lpe
mov $0,$1
|
SECTION code_driver
PUBLIC _sd_write_byte_fastcall
EXTERN asm_sd_write_byte
;Do a write bus cycle to the SD drive, via the CSIO
;
;input L = byte to write to SD drive
defc _sd_write_byte_fastcall = asm_sd_write_byte
|
; pletter v0.5c msx unpacker
; call unpack with hl pointing to some pletter5 data, and de pointing to the destination.
; changes all registers
; define lengthindata when the original size is written in the pletter data
; define LENGTHINDATA
module pletter
macro GETBIT
add a,a
call z,getbit
endmacro
macro GETBITEXX
add a,a
call z,getbitexx
endmacro
@unpack
ifdef LENGTHINDATA
inc hl
inc hl
endif
ld a,(hl)
inc hl
exx
ld de,0
add a,a
inc a
rl e
add a,a
rl e
add a,a
rl e
rl e
ld hl,modes
add hl,de
ld e,(hl)
ld ixl,e
inc hl
ld e,(hl)
ld ixh,e
ld e,1
exx
ld iy,loop
literal
ldi
loop
GETBIT
jr nc,literal
exx
ld h,d
ld l,e
getlen
GETBITEXX
jr nc,.lenok
.lus
GETBITEXX
adc hl,hl
ret c
GETBITEXX
jr nc,.lenok
GETBITEXX
adc hl,hl
ret c
GETBITEXX
jp c,.lus
.lenok
inc hl
exx
ld c,(hl)
inc hl
ld b,0
bit 7,c
jp z,offsok
jp ix
mode6
GETBIT
rl b
mode5
GETBIT
rl b
mode4
GETBIT
rl b
mode3
GETBIT
rl b
mode2
GETBIT
rl b
GETBIT
jr nc,offsok
or a
inc b
res 7,c
offsok
inc bc
push hl
exx
push hl
exx
ld l,e
ld h,d
sbc hl,bc
pop bc
ldir
pop hl
jp iy
getbit
ld a,(hl)
inc hl
rla
ret
getbitexx
exx
ld a,(hl)
inc hl
exx
rla
ret
modes
word offsok
word mode2
word mode3
word mode4
word mode5
word mode6
endmodule
;eof |
; A290770: a(n) = Product_{k=1..n} k^(2*k).
; Submitted by Jon Maiga
; 1,1,16,11664,764411904,7464960000000000,16249593066946560000000000,11020848942410302096869949440000000000,3102093199396597590886754340698424229232640000000000,465607547420733489126893933985879279492195953053596584509440000000000,46560754742073348912689393398587927949219595305359658450944000000000000000000000000000000,3790173449531107802808659831768378834960013997206481599183489298859469039703425024000000000000000000000000000000
mov $1,1
mov $2,1
lpb $0
mul $2,$0
sub $0,1
mul $1,$2
lpe
pow $1,2
mov $0,$1
|
include multi\mac.inc
.model small
.stack 64
.data
msg db "hello","$"
.code
main proc far
mov ax,@DaTa
mov ds,ax
mov ah,9
mov dx,offset msg
int 21h
hlt
MOV AH,4CH
INT 21H ;BACK TO DOS
main endp
end main |
;
; Old School Computer Architecture - interfacing FLOS
; Stefano Bodrato, 2011
;
; $Id: set_pen.asm,v 1.3 2015/01/19 01:33:00 pauloscustodio Exp $
;
INCLUDE "flos.def"
PUBLIC set_pen
set_pen:
;__FASTCALL__
ld a,l
jp kjt_set_pen
|
; @com.wudsn.ide.asm.hardware=ATARI2600
icl "vcs.asm"
icl "macro.asm"
opt h-f+l+
org $f000
; We're going to use a more clever way to position sprites
; ("players") which relies on additional TIA features.
; Because the CPU timing is 3 times as coarse as the TIA's,
; we can only access 1 out of 3 possible positions using
; CPU delays alone.
; Additional TIA registers let us nudge the final position
; by discrete TIA clocks and thus target all 160 positions.
.proc Cart
counter = $81
start Clean_Start
nextframe
Vertical_Sync
; 37 lines of VBLANK
ldx #35
lvblank sta WSYNC
dex
bne lvblank
; Instead of representing the horizontal position in CPU clocks,
; we're going to use TIA clocks.
lda counter ; load the counter as horizontal position
and #$7f ; force range to (0-127)
; We're going to divide the horizontal position by 15.
; The easy way on the 6502 is to subtract in a loop.
; Note that this also conveniently adds 5 CPU cycles
; (15 TIA clocks) per iteration.
sta WSYNC ; 36th line
sta HMCLR ; reset the old horizontal position
DivideLoop
sbc #15 ; subtract 15
bcs DivideLoop ; branch until negative
; A now contains (the remainder - 15).
; We'll convert that into a fine adjustment, which has
; the range -8 to +7.
eor #7
asl ; HMOVE only uses the top 4 bits, so shift by 4
asl
asl
asl
; The fine offset goes into HMP0
sta HMP0
; Now let's fix the coarse position of the player, which as you
; remember is solely based on timing. If you rearrange any of the
; previous instructions, position 0 won't be exactly on the left side.
sta RESP0
; Finally we'll do a WSYNC followed by HMOVE to apply the fine offset.
sta WSYNC ; 37th line
sta HMOVE ; apply offset
; We'll see this method again, and it can be made into a subroutine
; that works on multiple objects.
; Now draw the 192 scanlines, drawing the sprite.
; We've already set its horizontal position for the entire frame,
; but we'll try to draw something real this time, some digits
; lifted from another game.
ldx #192
lda #0 ; changes every scanline
ldy #0 ; sprite data index
lvscan
sta WSYNC ; wait for next scanline
sty COLUBK ; set the background color
lda NUMBERS,y
sta GRP0 ; set sprite 0 pixels
iny
cpy #60
bcc wrap1
ldy #0
wrap1
dex
bne lvscan
; Clear the background color and sprites before overscan
stx COLUBK
stx GRP0
; 30 lines of overscan
ldx #30
lvover sta WSYNC
dex
bne lvover
; Cycle the sprite colors for the next frame
inc counter
lda counter
sta COLUP0
jmp nextframe
.endp
; Bitmap pattern for digits
NUMBERS ;;{w:8,h:6,count:10,brev:1};;
.byte $Ee,$aa,$AA,$AA,$EE,$00
.byte $22,$22,$22,$22,$22,$00
.byte $EE,$22,$EE,$88,$EE,$00
.byte $EE,$22,$66,$22,$EE,$00
.byte $AA,$AA,$EE,$22,$22,$00
.byte $EE,$88,$EE,$22,$EE,$00
.byte $EE,$88,$EE,$AA,$EE,$00
.byte $EE,$22,$22,$22,$22,$00
.byte $EE,$AA,$EE,$AA,$EE,$00
.byte $EE,$AA,$EE,$22,$EE,$00
; Epilogue
org $fffc
.word Cart.start
.word Cart.start
; QUESTION: What if you don't set the fine offset?
; QUESTION: What if you don't set the coarse offset?
|
/*
* Copyright (C) 2010, Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS 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 APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "config.h"
#if ENABLE(WEB_AUDIO)
#include "AudioDestinationNode.h"
#include "AudioBus.h"
#include "AudioContext.h"
#include "AudioNodeInput.h"
#include "AudioNodeOutput.h"
#include "DenormalDisabler.h"
namespace WebCore {
AudioDestinationNode::AudioDestinationNode(AudioContext* context, float sampleRate)
: AudioNode(context, sampleRate)
, m_currentTime(0.0)
{
addInput(adoptPtr(new AudioNodeInput(this)));
setNodeType(NodeTypeDestination);
}
AudioDestinationNode::~AudioDestinationNode()
{
uninitialize();
}
// The audio hardware calls us back here to gets its input stream.
void AudioDestinationNode::provideInput(AudioBus* destinationBus, size_t numberOfFrames)
{
// We don't want denormals slowing down any of the audio processing
// since they can very seriously hurt performance.
// This will take care of all AudioNodes because they all process within this scope.
DenormalDisabler denormalDisabler;
context()->setAudioThread(currentThread());
if (!context()->isRunnable()) {
destinationBus->zero();
return;
}
// Let the context take care of any business at the start of each render quantum.
context()->handlePreRenderTasks();
// This will cause the node(s) connected to us to process, which in turn will pull on their input(s),
// all the way backwards through the rendering graph.
AudioBus* renderedBus = input(0)->pull(destinationBus, numberOfFrames);
if (!renderedBus)
destinationBus->zero();
else if (renderedBus != destinationBus) {
// in-place processing was not possible - so copy
destinationBus->copyFrom(*renderedBus);
}
// Let the context take care of any business at the end of each render quantum.
context()->handlePostRenderTasks();
// Advance current time.
m_currentTime += numberOfFrames / sampleRate();
}
} // namespace WebCore
#endif // ENABLE(WEB_AUDIO)
|
//
// Generated by Microsoft (R) HLSL Shader Compiler 9.30.9200.16384
//
//
///
// Buffer Definitions:
//
// cbuffer cbMain
// {
//
// float4x4 g_mWorld; // Offset: 0 Size: 64 [unused]
// float4x4 g_mView; // Offset: 64 Size: 64 [unused]
// float4x4 g_mProjection; // Offset: 128 Size: 64 [unused]
// float4x4 g_mWorldViewProjection; // Offset: 192 Size: 64 [unused]
// float4x4 g_mViewProjection; // Offset: 256 Size: 64 [unused]
// float4x4 g_mInvView; // Offset: 320 Size: 64 [unused]
// float4 g_vScreenResolution; // Offset: 384 Size: 16 [unused]
// float4 g_vMeshColor; // Offset: 400 Size: 16 [unused]
// float4 g_vTessellationFactor; // Offset: 416 Size: 16
// float4 g_vDetailTessellationHeightScale;// Offset: 432 Size: 16 [unused]
// float4 g_vGridSize; // Offset: 448 Size: 16 [unused]
// float4 g_vDebugColorMultiply; // Offset: 464 Size: 16 [unused]
// float4 g_vDebugColorAdd; // Offset: 480 Size: 16 [unused]
// float4 g_vFrustumPlaneEquation[4]; // Offset: 496 Size: 64 [unused]
//
// }
//
//
// Resource Bindings:
//
// Name Type Format Dim Slot Elements
// ------------------------------ ---------- ------- ----------- ---- --------
// cbMain cbuffer NA NA 0 1
//
//
//
// Patch Constant signature:
//
// Name Index Mask Register SysValue Format Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_TessFactor 0 x 0 TRIEDGE float x
// SV_TessFactor 1 x 1 TRIEDGE float x
// SV_TessFactor 2 x 2 TRIEDGE float x
// SV_InsideTessFactor 0 x 3 TRIINT float x
//
//
// Input signature:
//
// Name Index Mask Register SysValue Format Used
// -------------------- ----- ------ -------- -------- ------- ------
// WORLDPOS 0 xyz 0 NONE float xyz
// NORMAL 0 xyz 1 NONE float xyz
// TEXCOORD 0 xy 2 NONE float xy
// LIGHTVECTORTS 0 xyz 3 NONE float xyz
//
//
// Output signature:
//
// Name Index Mask Register SysValue Format Used
// -------------------- ----- ------ -------- -------- ------- ------
// WORLDPOS 0 xyz 0 NONE float xyz
// NORMAL 0 xyz 1 NONE float xyz
// TEXCOORD 0 xy 2 NONE float xy
// LIGHTVECTORTS 0 xyz 3 NONE float xyz
//
// Tessellation Domain # of control points
// -------------------- --------------------
// Triangle 3
//
// Tessellation Output Primitive Partitioning Type
// ------------------------------ ------------------
// Clockwise Triangles Odd Fractional
//
hs_5_0
hs_decls
dcl_input_control_point_count 3
dcl_output_control_point_count 3
dcl_tessellator_domain domain_tri
dcl_tessellator_partitioning partitioning_fractional_odd
dcl_tessellator_output_primitive output_triangle_cw
dcl_hs_max_tessfactor l(15.000000)
dcl_globalFlags refactoringAllowed
dcl_constantbuffer cb0[27], immediateIndexed
hs_fork_phase
dcl_hs_fork_phase_instance_count 3
dcl_input vForkInstanceID
dcl_output_siv o0.x, finalTriUeq0EdgeTessFactor
dcl_output_siv o1.x, finalTriVeq0EdgeTessFactor
dcl_output_siv o2.x, finalTriWeq0EdgeTessFactor
dcl_temps 1
dcl_indexrange o0.x 3
min r0.x, cb0[26].x, l(15.000000)
mov r0.y, vForkInstanceID.x
mov o[r0.y + 0].x, r0.x
ret
hs_fork_phase
dcl_output_siv o3.x, finalTriInsideTessFactor
min o3.x, cb0[26].y, l(15.000000)
ret
// Approximately 6 instruction slots used
|
dnl PowerPC-64 mpn_divexact_1 -- mpn by limb exact division.
dnl Copyright 2006 Free Software Foundation, Inc.
dnl This file is part of the GNU MP Library.
dnl The GNU MP Library is free software; you can redistribute it and/or modify
dnl it under the terms of the GNU Lesser General Public License as published
dnl by the Free Software Foundation; either version 3 of the License, or (at
dnl your option) any later version.
dnl The GNU MP Library is distributed in the hope that it will be useful, but
dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
dnl License for more details.
dnl You should have received a copy of the GNU Lesser General Public License
dnl along with the GNU MP Library. If not, see http://www.gnu.org/licenses/.
include(`../config.m4')
C cycles/limb
C POWER3/PPC630: 13-19
C POWER4/PPC970: 16
C POWER5: 16
C TODO
C * Check if n=1 code is really an improvement. It probably isn't.
C * Perhaps remove L(norm) code, it is currently unreachable.
C * Make more similar to mode1o.asm.
C INPUT PARAMETERS
define(`rp', `r3')
define(`up', `r4')
define(`n', `r5')
define(`d', `r6')
ASM_START()
EXTERN(binvert_limb_table)
PROLOGUE(mpn_divexact_1)
addic. n, n, -1
ld r12, 0(up)
bne cr0, L(2)
divdu r0, r12, d
std r0, 0(rp)
blr
L(2):
rldicl. r0, d, 0, 63
li r10, 0
bne cr0, L(7)
neg r0, d
and r0, d, r0
cntlzd r0, r0
subfic r0, r0, 63
rldicl r10, r0, 0, 32
srd d, d, r0
L(7):
mtctr n
LEA( r5, binvert_limb_table)
rldicl r11, d, 63, 57
C cmpdi cr7, r0, 0
lbzx r0, r5, r11
mulld r9, r0, r0
sldi r0, r0, 1
mulld r9, d, r9
subf r0, r9, r0
mulld r5, r0, r0
sldi r0, r0, 1
mulld r5, d, r5
subf r0, r5, r0
mulld r9, r0, r0
sldi r0, r0, 1
mulld r9, d, r9
subf r7, r9, r0 C r7 = 1/d mod 2^64
C beq cr7, L(norm)
subfic r8, r10, 64 C set carry as side effect
li r5, 0
ALIGN(16)
L(loop0):
srd r11, r12, r10
ld r12, 8(up)
addi up, up, 8
sld r0, r12, r8
or r11, r11, r0
subfe r9, r5, r11
mulld r0, r7, r9
std r0, 0(rp)
addi rp, rp, 8
mulhdu r5, r0, d
bdnz L(loop0)
srd r0, r12, r10
subfe r0, r5, r0
mulld r0, r7, r0
std r0, 0(rp)
blr
ALIGN(16)
L(norm):
mulld r11, r12, r7
std r11, 0(rp)
ALIGN(16)
L(loop1):
mulhdu r5, r11, d
ld r9, 8(up)
addi up, up, 8
subfe r5, r5, r9
mulld r11, r7, r5
std r11, 8(rp)
addi rp, rp, 8
bdnz L(loop1)
blr
EPILOGUE()
ASM_END()
|
; int strcmp(const char *s1, const char *s2)
SECTION code_string
PUBLIC strcmp_callee
EXTERN asm_strcmp
strcmp_callee:
pop af
pop hl
pop de
push af
jp asm_strcmp
|
#pragma once
#include <string>
#include "tokentype.hpp"
#include "scanner.hpp"
#include "model.hpp"
namespace lexer {
/**
* Token Class
* representation of Token
*/
class Token
{
public:
const std::string lexeme;
const tokenizer::TokenType type;
Token(const std::string &_lexeme, const tokenizer::TokenType _type) :
lexeme(_lexeme), type(_type) {}
model::sp_Element to_element();
};
/**
* Tokenizer Class
*/
class Tokenizer
{
private:
std::string input;
Scanner *scanner;
public:
Tokenizer(const std::string &_input) : input(_input) {
this->scanner = new Scanner(input);
}
bool read_next();
Token current_token();
};
} // lexer
|
#include <iostream>
#include <vector>
using namespace std;
struct Enviament {
string dni;
string exer;
int temps;
string res;
};
struct exercici {
string nom;
string res;
};
struct alums {
string dni;
vector<exercici> exer;
};
typedef vector<Enviament> Historia;
typedef vector<alums> Alumnes;
void mesenviaverds(const Alumnes& classP1) {
int maxenverd, maxexverd, maxexvermell, pos1, pos2, pos3;
maxenverd = maxexverd = maxexvermell = pos1 = pos2 = pos3 = 0;
for (int i = 0;i<int(classP1.size());i++) {
int cverd = 0; // comptador de verds per cada alumne
int uverd = 0; // comptador de verds unics per cada alumne
int uvermell = 0; // comptador de vermells per cada alumne
vector<string> exverd;
vector<string> exvermell;
for (int j=0;j<int(classP1[i].exer.size());j++) {
if (classP1[i].exer[j].res == "verd") {
cverd++;
// verds unics
bool found = false;
for (int k=0;k<int(exverd.size());k++) {
if (classP1[i].exer[j].nom == exverd[k]) found = true;
}
if (not found) {
exverd.push_back(classP1[i].exer[j].nom);
uverd++;
}
}
if (classP1[i].exer[j].res == "vermell") {
bool found = false;
for (int h=0;h<int(exverd.size());h++) {
if (classP1[i].exer[j].nom == exvermell[h]) found = true;
}
if (not found) {
exvermell.push_back(classP1[i].exer[j].nom);
uvermell++;
}
}
}
// verds totals
if (cverd > maxenverd) {
maxenverd = cverd;
pos1 = i;
}
else if (cverd == maxenverd) {
if (classP1[i].dni < classP1[pos1].dni) pos1 = i;
}
// verds unics
if (uverd > maxexverd) {
maxexverd = uverd;
pos2 = i;
}
else if (uverd == maxexverd) {
if (classP1[i].dni < classP1[pos2].dni) pos2 = i;
}
// vermells unics
if (uvermell > maxexvermell) {
maxexvermell = uvermell;
pos3 = i;
}
else if (uvermell == maxexvermell) {
if (classP1[i].dni < classP1[pos3].dni) pos3 = i;
}
}
if (maxenverd > 0) cout << "alumne amb mes enviaments verds: " << classP1[pos1].dni << " (" << maxenverd << ')' << endl;
else if (maxenverd == 0) cout << "alumne amb mes enviaments verds: -" << endl;
if (maxexverd > 0) cout << "alumne amb mes exercicis verds: " << classP1[pos2].dni << " (" << maxexverd << ')' << endl;
else if (maxexverd == 0) cout << "alumne amb mes exercicis verds: -" << endl;
if (maxexvermell > 0) cout << "alumne amb mes exercicis vermells: " << classP1[pos3].dni << " (" << maxexvermell << ')' << endl;
else if (maxexvermell == 0) cout << "alumne amb mes exercicis vermells: -" << endl;
}
void parse(const Historia& P1, Alumnes& classP1) {
for (int i=0;i<int(P1.size());i++) {
for (int j = 0;j<int(classP1.size());j++) {
if (P1[i].dni == classP1[j].dni) {
exercici ex;
ex.nom = P1[i].exer;
ex.res = P1[i].res;
classP1[j].exer.push_back(ex);
}
}
}
}
int main() {
int n;
cin >> n;
Historia P1(n);
Alumnes classP1;
for (int i = 0;i<n;i++) {
cin >> P1[i].dni >> P1[i].exer >> P1[i].temps >> P1[i].res;
bool found = false;
for (int j=0;j<int(classP1.size());j++) {
if (P1[i].dni == classP1[j].dni) found = true;
}
if (not found) {
alums alumne;
alumne.dni = P1[i].dni;
classP1.push_back(alumne);
}
}
parse(P1,classP1);
mesenviaverds(classP1);
}
|
/*
* W.J. van der Laan 2011-2012
*/
#include "bitcoingui.h"
#include "clientmodel.h"
#include "walletmodel.h"
#include "optionsmodel.h"
#include "guiutil.h"
#include "guiconstants.h"
#include "init.h"
#include "util.h"
#include "ui_interface.h"
#include "paymentserver.h"
#include "splashscreen.h"
#include "intro.h"
#include <QApplication>
#include <QMessageBox>
#if QT_VERSION < 0x050000
#include <QTextCodec>
#endif
#include <QLocale>
#include <QTimer>
#include <QTranslator>
#include <QLibraryInfo>
#include <QSettings>
#if defined(BITCOIN_NEED_QT_PLUGINS) && !defined(_BITCOIN_QT_PLUGINS_INCLUDED)
#define _BITCOIN_QT_PLUGINS_INCLUDED
#define __INSURE__
#include <QtPlugin>
Q_IMPORT_PLUGIN(qcncodecs)
Q_IMPORT_PLUGIN(qjpcodecs)
Q_IMPORT_PLUGIN(qtwcodecs)
Q_IMPORT_PLUGIN(qkrcodecs)
Q_IMPORT_PLUGIN(qtaccessiblewidgets)
#endif
// Declare meta types used for QMetaObject::invokeMethod
Q_DECLARE_METATYPE(bool*)
// Need a global reference for the notifications to find the GUI
static BitcoinGUI *guiref;
static SplashScreen *splashref;
static bool ThreadSafeMessageBox(const std::string& message, const std::string& caption, unsigned int style)
{
// Message from network thread
if(guiref)
{
bool modal = (style & CClientUIInterface::MODAL);
bool ret = false;
// In case of modal message, use blocking connection to wait for user to click a button
QMetaObject::invokeMethod(guiref, "message",
modal ? GUIUtil::blockingGUIThreadConnection() : Qt::QueuedConnection,
Q_ARG(QString, QString::fromStdString(caption)),
Q_ARG(QString, QString::fromStdString(message)),
Q_ARG(unsigned int, style),
Q_ARG(bool*, &ret));
return ret;
}
else
{
printf("%s: %s\n", caption.c_str(), message.c_str());
fprintf(stderr, "%s: %s\n", caption.c_str(), message.c_str());
return false;
}
}
static bool ThreadSafeAskFee(int64 nFeeRequired)
{
if(!guiref)
return false;
if(nFeeRequired < CTransaction::nMinTxFee || nFeeRequired <= nTransactionFee || fDaemon)
return true;
bool payFee = false;
QMetaObject::invokeMethod(guiref, "askFee", GUIUtil::blockingGUIThreadConnection(),
Q_ARG(qint64, nFeeRequired),
Q_ARG(bool*, &payFee));
return payFee;
}
static void InitMessage(const std::string &message)
{
if(splashref)
{
splashref->showMessage(QString::fromStdString(message), Qt::AlignBottom|Qt::AlignHCenter, QColor(55,55,55));
qApp->processEvents();
}
printf("init message: %s\n", message.c_str());
}
/*
Translate string to current locale using Qt.
*/
static std::string Translate(const char* psz)
{
return QCoreApplication::translate("bitcoin-core", psz).toStdString();
}
/* Handle runaway exceptions. Shows a message box with the problem and quits the program.
*/
static void handleRunawayException(std::exception *e)
{
PrintExceptionContinue(e, "Runaway exception");
QMessageBox::critical(0, "Runaway exception", BitcoinGUI::tr("A fatal error occurred. BitcoinGlobalAsset can no longer continue safely and will quit.") + QString("\n\n") + QString::fromStdString(strMiscWarning));
exit(1);
}
/** Set up translations */
static void initTranslations(QTranslator &qtTranslatorBase, QTranslator &qtTranslator, QTranslator &translatorBase, QTranslator &translator)
{
QSettings settings;
// Get desired locale (e.g. "de_DE")
// 1) System default language
QString lang_territory = QLocale::system().name();
// 2) Language from QSettings
QString lang_territory_qsettings = settings.value("language", "").toString();
if(!lang_territory_qsettings.isEmpty())
lang_territory = lang_territory_qsettings;
// 3) -lang command line argument
lang_territory = QString::fromStdString(GetArg("-lang", lang_territory.toStdString()));
// Convert to "de" only by truncating "_DE"
QString lang = lang_territory;
lang.truncate(lang_territory.lastIndexOf('_'));
// Load language files for configured locale:
// - First load the translator for the base language, without territory
// - Then load the more specific locale translator
// Load e.g. qt_de.qm
if (qtTranslatorBase.load("qt_" + lang, QLibraryInfo::location(QLibraryInfo::TranslationsPath)))
QApplication::installTranslator(&qtTranslatorBase);
// Load e.g. qt_de_DE.qm
if (qtTranslator.load("qt_" + lang_territory, QLibraryInfo::location(QLibraryInfo::TranslationsPath)))
QApplication::installTranslator(&qtTranslator);
// Load e.g. bitcoin_de.qm (shortcut "de" needs to be defined in bitcoin.qrc)
if (translatorBase.load(lang, ":/translations/"))
QApplication::installTranslator(&translatorBase);
// Load e.g. bitcoin_de_DE.qm (shortcut "de_DE" needs to be defined in bitcoin.qrc)
if (translator.load(lang_territory, ":/translations/"))
QApplication::installTranslator(&translator);
}
#ifndef BITCOIN_QT_TEST
int main(int argc, char *argv[])
{
fHaveGUI = true;
// Command-line options take precedence:
ParseParameters(argc, argv);
#if QT_VERSION < 0x050000
// Internal string conversion is all UTF-8
QTextCodec::setCodecForTr(QTextCodec::codecForName("UTF-8"));
QTextCodec::setCodecForCStrings(QTextCodec::codecForTr());
#endif
Q_INIT_RESOURCE(bitcoin);
QApplication app(argc, argv);
// Register meta types used for QMetaObject::invokeMethod
qRegisterMetaType< bool* >();
// Application identification (must be set before OptionsModel is initialized,
// as it is used to locate QSettings)
QApplication::setOrganizationName("BitcoinGlobalAsset");
QApplication::setOrganizationDomain("bitcoinglobalasset.org");
if (GetBoolArg("-testnet", false)) // Separate UI settings for testnet
QApplication::setApplicationName("BitcoinGlobalAsset-Qt-testnet");
else
QApplication::setApplicationName("BitcoinGlobalAsset-Qt");
// Now that QSettings are accessible, initialize translations
QTranslator qtTranslatorBase, qtTranslator, translatorBase, translator;
initTranslations(qtTranslatorBase, qtTranslator, translatorBase, translator);
// User language is set up: pick a data directory
Intro::pickDataDirectory();
// Do this early as we don't want to bother initializing if we are just calling IPC
// ... but do it after creating app, so QCoreApplication::arguments is initialized:
if (PaymentServer::ipcSendCommandLine())
exit(0);
PaymentServer* paymentServer = new PaymentServer(&app);
// Install global event filter that makes sure that long tooltips can be word-wrapped
app.installEventFilter(new GUIUtil::ToolTipToRichTextFilter(TOOLTIP_WRAP_THRESHOLD, &app));
// ... then bitcoin.conf:
if (!boost::filesystem::is_directory(GetDataDir(false)))
{
QMessageBox::critical(0, QObject::tr("BitcoinGlobalAsset"),
QObject::tr("Error: Specified data directory \"%1\" does not exist.").arg(QString::fromStdString(mapArgs["-datadir"])));
return 1;
}
ReadConfigFile(mapArgs, mapMultiArgs);
// ... then GUI settings:
OptionsModel optionsModel;
// Subscribe to global signals from core
uiInterface.ThreadSafeMessageBox.connect(ThreadSafeMessageBox);
uiInterface.ThreadSafeAskFee.connect(ThreadSafeAskFee);
uiInterface.InitMessage.connect(InitMessage);
uiInterface.Translate.connect(Translate);
// Show help message immediately after parsing command-line options (for "-lang") and setting locale,
// but before showing splash screen.
if (mapArgs.count("-?") || mapArgs.count("--help"))
{
GUIUtil::HelpMessageBox help;
help.showOrPrint();
return 1;
}
SplashScreen splash(QPixmap(), 0);
if (GetBoolArg("-splash", true) && !GetBoolArg("-min", false))
{
splash.show();
splash.setAutoFillBackground(true);
splashref = &splash;
}
app.processEvents();
app.setQuitOnLastWindowClosed(false);
try
{
#ifndef Q_OS_MAC
// Regenerate startup link, to fix links to old versions
// OSX: makes no sense on mac and might also scan/mount external (and sleeping) volumes (can take up some secs)
if (GUIUtil::GetStartOnSystemStartup())
GUIUtil::SetStartOnSystemStartup(true);
#endif
boost::thread_group threadGroup;
BitcoinGUI window(GetBoolArg("-testnet", false), 0);
guiref = &window;
QTimer* pollShutdownTimer = new QTimer(guiref);
QObject::connect(pollShutdownTimer, SIGNAL(timeout()), guiref, SLOT(detectShutdown()));
pollShutdownTimer->start(200);
if(AppInit2(threadGroup))
{
{
// Put this in a block, so that the Model objects are cleaned up before
// calling Shutdown().
optionsModel.Upgrade(); // Must be done after AppInit2
if (splashref)
splash.finish(&window);
ClientModel clientModel(&optionsModel);
WalletModel walletModel(pwalletMain, &optionsModel);
window.setClientModel(&clientModel);
window.addWallet("~Default", &walletModel);
window.setCurrentWallet("~Default");
// If -min option passed, start window minimized.
if(GetBoolArg("-min", false))
{
window.showMinimized();
}
else
{
window.show();
}
// Now that initialization/startup is done, process any command-line
// bitcoin: URIs
QObject::connect(paymentServer, SIGNAL(receivedURI(QString)), &window, SLOT(handleURI(QString)));
QTimer::singleShot(100, paymentServer, SLOT(uiReady()));
app.exec();
window.hide();
window.setClientModel(0);
window.removeAllWallets();
guiref = 0;
}
// Shutdown the core and its threads, but don't exit BitcoinGlobalAsset-Qt here
threadGroup.interrupt_all();
threadGroup.join_all();
Shutdown();
}
else
{
threadGroup.interrupt_all();
threadGroup.join_all();
Shutdown();
return 1;
}
} catch (std::exception& e) {
handleRunawayException(&e);
} catch (...) {
handleRunawayException(NULL);
}
return 0;
}
#endif // BITCOIN_QT_TEST
|
; int vopen(const char *path, int oflag, void *arg)
SECTION code_clib
SECTION code_fcntl
PUBLIC vopen_callee
EXTERN asm_vopen
vopen_callee:
pop af
pop hl
pop bc
pop de
push af
jp asm_vopen
|
; A053127: Binomial coefficients C(2*n-4,5).
; 6,56,252,792,2002,4368,8568,15504,26334,42504,65780,98280,142506,201376,278256,376992,501942,658008,850668,1086008,1370754,1712304,2118760,2598960,3162510,3819816,4582116,5461512,6471002,7624512,8936928,10424128,12103014,13991544,16108764,18474840,21111090,24040016,27285336,30872016,34826302,39175752,43949268,49177128,54891018,61124064,67910864,75287520,83291670,91962520,101340876,111469176,122391522,134153712,146803272,160389488,174963438,190578024,207288004,225150024,244222650,264566400,286243776,309319296,333859526,359933112,387610812,416965528,448072338,481008528,515853624,552689424,591600030,632671880,675993780,721656936,769754986,820384032,873642672,929632032,988455798,1050220248,1115034284,1183009464,1254260034,1328902960,1407057960,1488847536,1574397006,1663834536,1757291172,1854900872,1956800538,2063130048,2174032288,2289653184,2410141734,2535650040,2666333340,2802350040
mul $0,2
add $0,6
bin $0,5
|
SFX_Heal_Ailment_2_Ch4:
duty 2
pitchenvelope 1, 4
squarenote 4, 15, 2, 1536
squarenote 4, 15, 2, 1536
pitchenvelope 1, 7
squarenote 15, 15, 2, 1536
pitchenvelope 0, 0
endchannel
|
/***********************************************************************************************************************
* *
* ANTIKERNEL v0.1 *
* *
* Copyright (c) 2012-2020 Andrew D. Zonenberg *
* All rights reserved. *
* *
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the *
* following conditions are met: *
* *
* * Redistributions of source code must retain the above copyright notice, this list of conditions, and the *
* following disclaimer. *
* *
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the *
* following disclaimer in the documentation and/or other materials provided with the distribution. *
* *
* * Neither the name of the author nor the names of any contributors may be used to endorse or promote products *
* derived from this software without specific prior written permission. *
* *
* THIS SOFTWARE IS PROVIDED BY THE AUTHORS "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 AUTHORS BE HELD 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 "../scopehal/scopehal.h"
#include "USB2PMADecoder.h"
#include <algorithm>
using namespace std;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Construction / destruction
USB2PMADecoder::USB2PMADecoder(const string& color)
: Filter(OscilloscopeChannel::CHANNEL_TYPE_COMPLEX, color, CAT_SERIAL)
{
//Set up channels
CreateInput("D+");
CreateInput("D-");
//TODO: make this an enum/bool
m_speedname = "Full Speed";
m_parameters[m_speedname] = FilterParameter(FilterParameter::TYPE_INT, Unit(Unit::UNIT_COUNTS));
m_parameters[m_speedname].SetIntVal(1);
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Factory methods
bool USB2PMADecoder::ValidateChannel(size_t i, StreamDescriptor stream)
{
if(stream.m_channel == NULL)
return false;
if( (i < 2) && (stream.m_channel->GetType() == OscilloscopeChannel::CHANNEL_TYPE_ANALOG) )
return true;
return false;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Accessors
void USB2PMADecoder::SetDefaultName()
{
char hwname[256];
snprintf(hwname, sizeof(hwname), "USB2PMA(%s,%s)",
GetInputDisplayName(0).c_str(),
GetInputDisplayName(1).c_str());
m_hwname = hwname;
m_displayname = m_hwname;
}
string USB2PMADecoder::GetProtocolName()
{
return "USB 1.x/2.0 PMA";
}
bool USB2PMADecoder::IsOverlay()
{
return true;
}
bool USB2PMADecoder::NeedsConfig()
{
return true;
}
double USB2PMADecoder::GetVoltageRange()
{
return 1;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Actual decoder logic
void USB2PMADecoder::Refresh()
{
//Make sure we've got valid inputs
if(!VerifyAllInputsOKAndAnalog())
{
SetData(NULL, 0);
return;
}
//Get the input data
auto din_p = GetAnalogInputWaveform(0);
auto din_n = GetAnalogInputWaveform(1);
size_t len = min(din_p->m_samples.size(), din_n->m_samples.size());
//Figure out our speed so we know what's going on
int speed = m_parameters[m_speedname].GetIntVal();
//Figure out the line state for each input (no clock recovery yet)
auto cap = new USB2PMAWaveform;
for(size_t i=0; i<len; i++)
{
bool bp = (din_p->m_samples[i] > 0.4);
bool bn = (din_n->m_samples[i] > 0.4);
USB2PMASymbol::SegmentType type = USB2PMASymbol::TYPE_SE1;
if(bp && bn)
type = USB2PMASymbol::TYPE_SE1;
else if(!bp && !bn)
type = USB2PMASymbol::TYPE_SE0;
else
{
if(speed == 1)
{
if(bp && !bn)
type = USB2PMASymbol::TYPE_J;
else
type = USB2PMASymbol::TYPE_K;
}
else
{
if(bp && !bn)
type = USB2PMASymbol::TYPE_K;
else
type = USB2PMASymbol::TYPE_J;
}
}
//First sample goes as-is
if(cap->m_samples.empty())
{
cap->m_offsets.push_back(din_p->m_offsets[i]);
cap->m_durations.push_back(din_p->m_durations[i]);
cap->m_samples.push_back(type);
continue;
}
//Type match? Extend the existing sample
size_t iold = cap->m_samples.size()-1;
auto oldtype = cap->m_samples[iold];
if(oldtype == type)
{
cap->m_durations[iold] += din_p->m_durations[i];
continue;
}
//Ignore SE0/SE1 states during transitions.
int64_t last_ps = cap->m_durations[iold] * din_p->m_timescale;
if(
( (oldtype == USB2PMASymbol::TYPE_SE0) || (oldtype == USB2PMASymbol::TYPE_SE1) ) &&
(last_ps < 100000))
{
cap->m_samples[iold].m_type = type;
cap->m_durations[iold] += din_p->m_durations[i];
continue;
}
//Not a match. Add a new sample.
cap->m_offsets.push_back(din_p->m_offsets[i]);
cap->m_durations.push_back(din_p->m_durations[i]);
cap->m_samples.push_back(type);
}
SetData(cap, 0);
//Copy our time scales from the input
//Use the first trace's timestamp as our start time if they differ
cap->m_timescale = din_p->m_timescale;
cap->m_startTimestamp = din_p->m_startTimestamp;
cap->m_startPicoseconds = din_p->m_startPicoseconds;
}
Gdk::Color USB2PMADecoder::GetColor(int i)
{
auto data = dynamic_cast<USB2PMAWaveform*>(GetData(0));
if(data == NULL)
return m_standardColors[COLOR_ERROR];
if(i >= (int)data->m_samples.size())
return m_standardColors[COLOR_ERROR];
//TODO: have a set of standard colors we use everywhere?
auto sample = data->m_samples[i];
switch(sample.m_type)
{
case USB2PMASymbol::TYPE_J:
case USB2PMASymbol::TYPE_K:
return m_standardColors[COLOR_DATA];
case USB2PMASymbol::TYPE_SE0:
return m_standardColors[COLOR_PREAMBLE];
//invalid state, should never happen
case USB2PMASymbol::TYPE_SE1:
default:
return m_standardColors[COLOR_ERROR];
}
}
string USB2PMADecoder::GetText(int i)
{
auto data = dynamic_cast<USB2PMAWaveform*>(GetData(0));
if(data == NULL)
return "";
if(i >= (int)data->m_samples.size())
return "";
auto sample = data->m_samples[i];
switch(sample.m_type)
{
case USB2PMASymbol::TYPE_J:
return "J";
case USB2PMASymbol::TYPE_K:
return "K";
case USB2PMASymbol::TYPE_SE0:
return "SE0";
case USB2PMASymbol::TYPE_SE1:
return "SE1";
}
return "";
}
|
SECTION UNION "X", WRAM0
SECTION UNION "X", WRAM0, ALIGN[16]
|
// Copyright (c) 2010 Satoshi Nakamoto
// Copyright (c) 2009-2015 The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "base58.h"
#include "clientversion.h"
#include "init.h"
#include "main.h"
#include "net.h"
#include "netbase.h"
#include "rpcserver.h"
#include "timedata.h"
#include "txmempool.h"
#include "util.h"
#include "utilstrencodings.h"
#ifdef ENABLE_WALLET
#include "wallet/wallet.h"
#include "wallet/walletdb.h"
#endif
#include <stdint.h>
#include <boost/assign/list_of.hpp>
#include <univalue.h>
using namespace std;
/**
* @note Do not add or change anything in the information returned by this
* method. `getinfo` exists for backwards-compatibility only. It combines
* information from wildly different sources in the program, which is a mess,
* and is thus planned to be deprecated eventually.
*
* Based on the source of the information, new information should be added to:
* - `getblockchaininfo`,
* - `getnetworkinfo` or
* - `getwalletinfo`
*
* Or alternatively, create a specific query method for the information.
**/
UniValue getinfo(const UniValue& params, bool fHelp)
{
if (fHelp || params.size() != 0)
throw runtime_error(
"getinfo\n"
"Returns an object containing various state info.\n"
"\nResult:\n"
"{\n"
" \"version\": xxxxx, (numeric) the server version\n"
" \"protocolversion\": xxxxx, (numeric) the protocol version\n"
" \"walletversion\": xxxxx, (numeric) the wallet version\n"
" \"balance\": xxxxxxx, (numeric) the total koobit balance of the wallet\n"
" \"blocks\": xxxxxx, (numeric) the current number of blocks processed in the server\n"
" \"timeoffset\": xxxxx, (numeric) the time offset\n"
" \"connections\": xxxxx, (numeric) the number of connections\n"
" \"proxy\": \"host:port\", (string, optional) the proxy used by the server\n"
" \"difficulty\": xxxxxx, (numeric) the current difficulty\n"
" \"testnet\": true|false, (boolean) if the server is using testnet or not\n"
" \"keypoololdest\": xxxxxx, (numeric) the timestamp (seconds since GMT epoch) of the oldest pre-generated key in the key pool\n"
" \"keypoolsize\": xxxx, (numeric) how many new keys are pre-generated\n"
" \"unlocked_until\": ttt, (numeric) the timestamp in seconds since epoch (midnight Jan 1 1970 GMT) that the wallet is unlocked for transfers, or 0 if the wallet is locked\n"
" \"paytxfee\": x.xxxx, (numeric) the transaction fee set in " + CURRENCY_UNIT + "/kB\n"
" \"relayfee\": x.xxxx, (numeric) minimum relay fee for non-free transactions in " + CURRENCY_UNIT + "/kB\n"
" \"errors\": \"...\" (string) any error messages\n"
"}\n"
"\nExamples:\n"
+ HelpExampleCli("getinfo", "")
+ HelpExampleRpc("getinfo", "")
);
#ifdef ENABLE_WALLET
LOCK2(cs_main, pwalletMain ? &pwalletMain->cs_wallet : NULL);
#else
LOCK(cs_main);
#endif
proxyType proxy;
GetProxy(NET_IPV4, proxy);
UniValue obj(UniValue::VOBJ);
obj.push_back(Pair("version", CLIENT_VERSION));
obj.push_back(Pair("protocolversion", PROTOCOL_VERSION));
#ifdef ENABLE_WALLET
if (pwalletMain) {
obj.push_back(Pair("walletversion", pwalletMain->GetVersion()));
obj.push_back(Pair("balance", ValueFromAmount(pwalletMain->GetBalance())));
}
#endif
obj.push_back(Pair("blocks", (int)chainActive.Height()));
obj.push_back(Pair("timeoffset", GetTimeOffset()));
obj.push_back(Pair("connections", (int)vNodes.size()));
obj.push_back(Pair("proxy", (proxy.IsValid() ? proxy.proxy.ToStringIPPort() : string())));
obj.push_back(Pair("difficulty", (double)GetDifficulty()));
obj.push_back(Pair("testnet", Params().TestnetToBeDeprecatedFieldRPC()));
#ifdef ENABLE_WALLET
if (pwalletMain) {
obj.push_back(Pair("keypoololdest", pwalletMain->GetOldestKeyPoolTime()));
obj.push_back(Pair("keypoolsize", (int)pwalletMain->GetKeyPoolSize()));
}
if (pwalletMain && pwalletMain->IsCrypted())
obj.push_back(Pair("unlocked_until", nWalletUnlockTime));
obj.push_back(Pair("paytxfee", ValueFromAmount(payTxFee.GetFeePerK())));
#endif
obj.push_back(Pair("relayfee", ValueFromAmount(::minRelayTxFee.GetFeePerK())));
obj.push_back(Pair("errors", GetWarnings("statusbar")));
return obj;
}
#ifdef ENABLE_WALLET
class DescribeAddressVisitor : public boost::static_visitor<UniValue>
{
public:
UniValue operator()(const CNoDestination &dest) const { return UniValue(UniValue::VOBJ); }
UniValue operator()(const CKeyID &keyID) const {
UniValue obj(UniValue::VOBJ);
CPubKey vchPubKey;
obj.push_back(Pair("isscript", false));
if (pwalletMain && pwalletMain->GetPubKey(keyID, vchPubKey)) {
obj.push_back(Pair("pubkey", HexStr(vchPubKey)));
obj.push_back(Pair("iscompressed", vchPubKey.IsCompressed()));
}
return obj;
}
UniValue operator()(const CScriptID &scriptID) const {
UniValue obj(UniValue::VOBJ);
CScript subscript;
obj.push_back(Pair("isscript", true));
if (pwalletMain && pwalletMain->GetCScript(scriptID, subscript)) {
std::vector<CTxDestination> addresses;
txnouttype whichType;
int nRequired;
ExtractDestinations(subscript, whichType, addresses, nRequired);
obj.push_back(Pair("script", GetTxnOutputType(whichType)));
obj.push_back(Pair("hex", HexStr(subscript.begin(), subscript.end())));
UniValue a(UniValue::VARR);
BOOST_FOREACH(const CTxDestination& addr, addresses)
a.push_back(CKoobitAddress(addr).ToString());
obj.push_back(Pair("addresses", a));
if (whichType == TX_MULTISIG)
obj.push_back(Pair("sigsrequired", nRequired));
}
return obj;
}
};
#endif
UniValue validateaddress(const UniValue& params, bool fHelp)
{
if (fHelp || params.size() != 1)
throw runtime_error(
"validateaddress \"koobitaddress\"\n"
"\nReturn information about the given koobit address.\n"
"\nArguments:\n"
"1. \"koobitaddress\" (string, required) The koobit address to validate\n"
"\nResult:\n"
"{\n"
" \"isvalid\" : true|false, (boolean) If the address is valid or not. If not, this is the only property returned.\n"
" \"address\" : \"koobitaddress\", (string) The koobit address validated\n"
" \"scriptPubKey\" : \"hex\", (string) The hex encoded scriptPubKey generated by the address\n"
" \"ismine\" : true|false, (boolean) If the address is yours or not\n"
" \"iswatchonly\" : true|false, (boolean) If the address is watchonly\n"
" \"isscript\" : true|false, (boolean) If the key is a script\n"
" \"pubkey\" : \"publickeyhex\", (string) The hex value of the raw public key\n"
" \"iscompressed\" : true|false, (boolean) If the address is compressed\n"
" \"account\" : \"account\" (string) DEPRECATED. The account associated with the address, \"\" is the default account\n"
"}\n"
"\nExamples:\n"
+ HelpExampleCli("validateaddress", "\"1PSSGeFHDnKNxiEyFrD1wcEaHr9hrQDDWc\"")
+ HelpExampleRpc("validateaddress", "\"1PSSGeFHDnKNxiEyFrD1wcEaHr9hrQDDWc\"")
);
#ifdef ENABLE_WALLET
LOCK2(cs_main, pwalletMain ? &pwalletMain->cs_wallet : NULL);
#else
LOCK(cs_main);
#endif
CKoobitAddress address(params[0].get_str());
bool isValid = address.IsValid();
UniValue ret(UniValue::VOBJ);
ret.push_back(Pair("isvalid", isValid));
if (isValid)
{
CTxDestination dest = address.Get();
string currentAddress = address.ToString();
ret.push_back(Pair("address", currentAddress));
CScript scriptPubKey = GetScriptForDestination(dest);
ret.push_back(Pair("scriptPubKey", HexStr(scriptPubKey.begin(), scriptPubKey.end())));
#ifdef ENABLE_WALLET
isminetype mine = pwalletMain ? IsMine(*pwalletMain, dest) : ISMINE_NO;
ret.push_back(Pair("ismine", (mine & ISMINE_SPENDABLE) ? true : false));
ret.push_back(Pair("iswatchonly", (mine & ISMINE_WATCH_ONLY) ? true: false));
UniValue detail = boost::apply_visitor(DescribeAddressVisitor(), dest);
ret.pushKVs(detail);
if (pwalletMain && pwalletMain->mapAddressBook.count(dest))
ret.push_back(Pair("account", pwalletMain->mapAddressBook[dest].name));
#endif
}
return ret;
}
/**
* Used by addmultisigaddress / createmultisig:
*/
CScript _createmultisig_redeemScript(const UniValue& params)
{
int nRequired = params[0].get_int();
const UniValue& keys = params[1].get_array();
// Gather public keys
if (nRequired < 1)
throw runtime_error("a multisignature address must require at least one key to redeem");
if ((int)keys.size() < nRequired)
throw runtime_error(
strprintf("not enough keys supplied "
"(got %u keys, but need at least %d to redeem)", keys.size(), nRequired));
if (keys.size() > 16)
throw runtime_error("Number of addresses involved in the multisignature address creation > 16\nReduce the number");
std::vector<CPubKey> pubkeys;
pubkeys.resize(keys.size());
for (unsigned int i = 0; i < keys.size(); i++)
{
const std::string& ks = keys[i].get_str();
#ifdef ENABLE_WALLET
// Case 1: Koobit address and we have full public key:
CKoobitAddress address(ks);
if (pwalletMain && address.IsValid())
{
CKeyID keyID;
if (!address.GetKeyID(keyID))
throw runtime_error(
strprintf("%s does not refer to a key",ks));
CPubKey vchPubKey;
if (!pwalletMain->GetPubKey(keyID, vchPubKey))
throw runtime_error(
strprintf("no full public key for address %s",ks));
if (!vchPubKey.IsFullyValid())
throw runtime_error(" Invalid public key: "+ks);
pubkeys[i] = vchPubKey;
}
// Case 2: hex public key
else
#endif
if (IsHex(ks))
{
CPubKey vchPubKey(ParseHex(ks));
if (!vchPubKey.IsFullyValid())
throw runtime_error(" Invalid public key: "+ks);
pubkeys[i] = vchPubKey;
}
else
{
throw runtime_error(" Invalid public key: "+ks);
}
}
CScript result = GetScriptForMultisig(nRequired, pubkeys);
if (result.size() > MAX_SCRIPT_ELEMENT_SIZE)
throw runtime_error(
strprintf("redeemScript exceeds size limit: %d > %d", result.size(), MAX_SCRIPT_ELEMENT_SIZE));
return result;
}
UniValue createmultisig(const UniValue& params, bool fHelp)
{
if (fHelp || params.size() < 2 || params.size() > 2)
{
string msg = "createmultisig nrequired [\"key\",...]\n"
"\nCreates a multi-signature address with n signature of m keys required.\n"
"It returns a json object with the address and redeemScript.\n"
"\nArguments:\n"
"1. nrequired (numeric, required) The number of required signatures out of the n keys or addresses.\n"
"2. \"keys\" (string, required) A json array of keys which are koobit addresses or hex-encoded public keys\n"
" [\n"
" \"key\" (string) koobit address or hex-encoded public key\n"
" ,...\n"
" ]\n"
"\nResult:\n"
"{\n"
" \"address\":\"multisigaddress\", (string) The value of the new multisig address.\n"
" \"redeemScript\":\"script\" (string) The string value of the hex-encoded redemption script.\n"
"}\n"
"\nExamples:\n"
"\nCreate a multisig address from 2 addresses\n"
+ HelpExampleCli("createmultisig", "2 \"[\\\"16sSauSf5pF2UkUwvKGq4qjNRzBZYqgEL5\\\",\\\"171sgjn4YtPu27adkKGrdDwzRTxnRkBfKV\\\"]\"") +
"\nAs a json rpc call\n"
+ HelpExampleRpc("createmultisig", "2, \"[\\\"16sSauSf5pF2UkUwvKGq4qjNRzBZYqgEL5\\\",\\\"171sgjn4YtPu27adkKGrdDwzRTxnRkBfKV\\\"]\"")
;
throw runtime_error(msg);
}
// Construct using pay-to-script-hash:
CScript inner = _createmultisig_redeemScript(params);
CScriptID innerID(inner);
CKoobitAddress address(innerID);
UniValue result(UniValue::VOBJ);
result.push_back(Pair("address", address.ToString()));
result.push_back(Pair("redeemScript", HexStr(inner.begin(), inner.end())));
return result;
}
UniValue verifymessage(const UniValue& params, bool fHelp)
{
if (fHelp || params.size() != 3)
throw runtime_error(
"verifymessage \"koobitaddress\" \"signature\" \"message\"\n"
"\nVerify a signed message\n"
"\nArguments:\n"
"1. \"koobitaddress\" (string, required) The koobit address to use for the signature.\n"
"2. \"signature\" (string, required) The signature provided by the signer in base 64 encoding (see signmessage).\n"
"3. \"message\" (string, required) The message that was signed.\n"
"\nResult:\n"
"true|false (boolean) If the signature is verified or not.\n"
"\nExamples:\n"
"\nUnlock the wallet for 30 seconds\n"
+ HelpExampleCli("walletpassphrase", "\"mypassphrase\" 30") +
"\nCreate the signature\n"
+ HelpExampleCli("signmessage", "\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XZ\" \"my message\"") +
"\nVerify the signature\n"
+ HelpExampleCli("verifymessage", "\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XZ\" \"signature\" \"my message\"") +
"\nAs json rpc\n"
+ HelpExampleRpc("verifymessage", "\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XZ\", \"signature\", \"my message\"")
);
LOCK(cs_main);
string strAddress = params[0].get_str();
string strSign = params[1].get_str();
string strMessage = params[2].get_str();
CKoobitAddress addr(strAddress);
if (!addr.IsValid())
throw JSONRPCError(RPC_TYPE_ERROR, "Invalid address");
CKeyID keyID;
if (!addr.GetKeyID(keyID))
throw JSONRPCError(RPC_TYPE_ERROR, "Address does not refer to key");
bool fInvalid = false;
vector<unsigned char> vchSig = DecodeBase64(strSign.c_str(), &fInvalid);
if (fInvalid)
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Malformed base64 encoding");
CHashWriter ss(SER_GETHASH, 0);
ss << strMessageMagic;
ss << strMessage;
CPubKey pubkey;
if (!pubkey.RecoverCompact(ss.GetHash(), vchSig))
return false;
return (pubkey.GetID() == keyID);
}
UniValue setmocktime(const UniValue& params, bool fHelp)
{
if (fHelp || params.size() != 1)
throw runtime_error(
"setmocktime timestamp\n"
"\nSet the local time to given timestamp (-regtest only)\n"
"\nArguments:\n"
"1. timestamp (integer, required) Unix seconds-since-epoch timestamp\n"
" Pass 0 to go back to using the system time."
);
if (!Params().MineBlocksOnDemand())
throw runtime_error("setmocktime for regression testing (-regtest mode) only");
// cs_vNodes is locked and node send/receive times are updated
// atomically with the time change to prevent peers from being
// disconnected because we think we haven't communicated with them
// in a long time.
LOCK2(cs_main, cs_vNodes);
RPCTypeCheck(params, boost::assign::list_of(UniValue::VNUM));
SetMockTime(params[0].get_int64());
uint64_t t = GetTime();
BOOST_FOREACH(CNode* pnode, vNodes) {
pnode->nLastSend = pnode->nLastRecv = t;
}
return NullUniValue;
}
bool getAddressFromIndex(const int &type, const uint160 &hash, std::string &address)
{
if (type == 2) {
address = CKoobitAddress(CScriptID(hash)).ToString();
} else if (type == 1) {
address = CKoobitAddress(CKeyID(hash)).ToString();
} else {
return false;
}
return true;
}
bool getAddressesFromParams(const UniValue& params, std::vector<std::pair<uint160, int> > &addresses)
{
if (params[0].isStr()) {
CKoobitAddress address(params[0].get_str());
uint160 hashBytes;
int type = 0;
if (!address.GetIndexKey(hashBytes, type)) {
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid address");
}
addresses.push_back(std::make_pair(hashBytes, type));
} else if (params[0].isObject()) {
UniValue addressValues = find_value(params[0].get_obj(), "addresses");
if (!addressValues.isArray()) {
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Addresses is expected to be an array");
}
std::vector<UniValue> values = addressValues.getValues();
for (std::vector<UniValue>::iterator it = values.begin(); it != values.end(); ++it) {
CKoobitAddress address(it->get_str());
uint160 hashBytes;
int type = 0;
if (!address.GetIndexKey(hashBytes, type)) {
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid address");
}
addresses.push_back(std::make_pair(hashBytes, type));
}
} else {
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid address");
}
return true;
}
bool heightSort(std::pair<CAddressUnspentKey, CAddressUnspentValue> a,
std::pair<CAddressUnspentKey, CAddressUnspentValue> b) {
return a.second.blockHeight < b.second.blockHeight;
}
bool timestampSort(std::pair<CMempoolAddressDeltaKey, CMempoolAddressDelta> a,
std::pair<CMempoolAddressDeltaKey, CMempoolAddressDelta> b) {
return a.second.time < b.second.time;
}
UniValue getaddressmempool(const UniValue& params, bool fHelp)
{
if (fHelp || params.size() != 1)
throw runtime_error(
"getaddressmempool\n"
"\nReturns all mempool deltas for an address (requires addressindex to be enabled).\n"
"\nArguments:\n"
"{\n"
" \"addresses\"\n"
" [\n"
" \"address\" (string) The base58check encoded address\n"
" ,...\n"
" ]\n"
"}\n"
"\nResult:\n"
"[\n"
" {\n"
" \"address\" (string) The base58check encoded address\n"
" \"txid\" (string) The related txid\n"
" \"index\" (number) The related input or output index\n"
" \"satoshis\" (number) The difference of satoshis\n"
" \"timestamp\" (number) The time the transaction entered the mempool (seconds)\n"
" \"prevtxid\" (string) The previous txid (if spending)\n"
" \"prevout\" (string) The previous transaction output index (if spending)\n"
" }\n"
"]\n"
"\nExamples:\n"
+ HelpExampleCli("getaddressmempool", "'{\"addresses\": [\"12c6DSiU4Rq3P4ZxziKxzrL5LmMBrzjrJX\"]}'")
+ HelpExampleRpc("getaddressmempool", "{\"addresses\": [\"12c6DSiU4Rq3P4ZxziKxzrL5LmMBrzjrJX\"]}")
);
std::vector<std::pair<uint160, int> > addresses;
if (!getAddressesFromParams(params, addresses)) {
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid address");
}
std::vector<std::pair<CMempoolAddressDeltaKey, CMempoolAddressDelta> > indexes;
if (!mempool.getAddressIndex(addresses, indexes)) {
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "No information available for address");
}
std::sort(indexes.begin(), indexes.end(), timestampSort);
UniValue result(UniValue::VARR);
for (std::vector<std::pair<CMempoolAddressDeltaKey, CMempoolAddressDelta> >::iterator it = indexes.begin();
it != indexes.end(); it++) {
std::string address;
if (!getAddressFromIndex(it->first.type, it->first.addressBytes, address)) {
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Unknown address type");
}
UniValue delta(UniValue::VOBJ);
delta.push_back(Pair("address", address));
delta.push_back(Pair("txid", it->first.txhash.GetHex()));
delta.push_back(Pair("index", (int)it->first.index));
delta.push_back(Pair("satoshis", it->second.amount));
delta.push_back(Pair("timestamp", it->second.time));
if (it->second.amount < 0) {
delta.push_back(Pair("prevtxid", it->second.prevhash.GetHex()));
delta.push_back(Pair("prevout", (int)it->second.prevout));
}
result.push_back(delta);
}
return result;
}
UniValue getaddressutxos(const UniValue& params, bool fHelp)
{
if (fHelp || params.size() != 1)
throw runtime_error(
"getaddressutxos\n"
"\nReturns all unspent outputs for an address (requires addressindex to be enabled).\n"
"\nArguments:\n"
"{\n"
" \"addresses\"\n"
" [\n"
" \"address\" (string) The base58check encoded address\n"
" ,...\n"
" ],\n"
" \"chainInfo\" (boolean) Include chain info with results\n"
"}\n"
"\nResult\n"
"[\n"
" {\n"
" \"address\" (string) The address base58check encoded\n"
" \"txid\" (string) The output txid\n"
" \"height\" (number) The block height\n"
" \"outputIndex\" (number) The output index\n"
" \"script\" (strin) The script hex encoded\n"
" \"satoshis\" (number) The number of satoshis of the output\n"
" }\n"
"]\n"
"\nExamples:\n"
+ HelpExampleCli("getaddressutxos", "'{\"addresses\": [\"12c6DSiU4Rq3P4ZxziKxzrL5LmMBrzjrJX\"]}'")
+ HelpExampleRpc("getaddressutxos", "{\"addresses\": [\"12c6DSiU4Rq3P4ZxziKxzrL5LmMBrzjrJX\"]}")
);
bool includeChainInfo = false;
if (params[0].isObject()) {
UniValue chainInfo = find_value(params[0].get_obj(), "chainInfo");
if (chainInfo.isBool()) {
includeChainInfo = chainInfo.get_bool();
}
}
std::vector<std::pair<uint160, int> > addresses;
if (!getAddressesFromParams(params, addresses)) {
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid address");
}
std::vector<std::pair<CAddressUnspentKey, CAddressUnspentValue> > unspentOutputs;
for (std::vector<std::pair<uint160, int> >::iterator it = addresses.begin(); it != addresses.end(); it++) {
if (!GetAddressUnspent((*it).first, (*it).second, unspentOutputs)) {
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "No information available for address");
}
}
std::sort(unspentOutputs.begin(), unspentOutputs.end(), heightSort);
UniValue utxos(UniValue::VARR);
for (std::vector<std::pair<CAddressUnspentKey, CAddressUnspentValue> >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) {
UniValue output(UniValue::VOBJ);
std::string address;
if (!getAddressFromIndex(it->first.type, it->first.hashBytes, address)) {
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Unknown address type");
}
output.push_back(Pair("address", address));
output.push_back(Pair("txid", it->first.txhash.GetHex()));
output.push_back(Pair("outputIndex", (int)it->first.index));
output.push_back(Pair("script", HexStr(it->second.script.begin(), it->second.script.end())));
output.push_back(Pair("satoshis", it->second.satoshis));
output.push_back(Pair("height", it->second.blockHeight));
utxos.push_back(output);
}
if (includeChainInfo) {
UniValue result(UniValue::VOBJ);
result.push_back(Pair("utxos", utxos));
LOCK(cs_main);
result.push_back(Pair("hash", chainActive.Tip()->GetBlockHash().GetHex()));
result.push_back(Pair("height", (int)chainActive.Height()));
return result;
} else {
return utxos;
}
}
UniValue getaddressdeltas(const UniValue& params, bool fHelp)
{
if (fHelp || params.size() != 1 || !params[0].isObject())
throw runtime_error(
"getaddressdeltas\n"
"\nReturns all changes for an address (requires addressindex to be enabled).\n"
"\nArguments:\n"
"{\n"
" \"addresses\"\n"
" [\n"
" \"address\" (string) The base58check encoded address\n"
" ,...\n"
" ]\n"
" \"start\" (number) The start block height\n"
" \"end\" (number) The end block height\n"
" \"chainInfo\" (boolean) Include chain info in results, only applies if start and end specified\n"
"}\n"
"\nResult:\n"
"[\n"
" {\n"
" \"satoshis\" (number) The difference of satoshis\n"
" \"txid\" (string) The related txid\n"
" \"index\" (number) The related input or output index\n"
" \"height\" (number) The block height\n"
" \"address\" (string) The base58check encoded address\n"
" }\n"
"]\n"
"\nExamples:\n"
+ HelpExampleCli("getaddressdeltas", "'{\"addresses\": [\"12c6DSiU4Rq3P4ZxziKxzrL5LmMBrzjrJX\"]}'")
+ HelpExampleRpc("getaddressdeltas", "{\"addresses\": [\"12c6DSiU4Rq3P4ZxziKxzrL5LmMBrzjrJX\"]}")
);
UniValue startValue = find_value(params[0].get_obj(), "start");
UniValue endValue = find_value(params[0].get_obj(), "end");
UniValue chainInfo = find_value(params[0].get_obj(), "chainInfo");
bool includeChainInfo = false;
if (chainInfo.isBool()) {
includeChainInfo = chainInfo.get_bool();
}
int start = 0;
int end = 0;
if (startValue.isNum() && endValue.isNum()) {
start = startValue.get_int();
end = endValue.get_int();
if (start <= 0 || end <= 0) {
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Start and end is expected to be greater than zero");
}
if (end < start) {
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "End value is expected to be greater than start");
}
}
std::vector<std::pair<uint160, int> > addresses;
if (!getAddressesFromParams(params, addresses)) {
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid address");
}
std::vector<std::pair<CAddressIndexKey, CAmount> > addressIndex;
for (std::vector<std::pair<uint160, int> >::iterator it = addresses.begin(); it != addresses.end(); it++) {
if (start > 0 && end > 0) {
if (!GetAddressIndex((*it).first, (*it).second, addressIndex, start, end)) {
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "No information available for address");
}
} else {
if (!GetAddressIndex((*it).first, (*it).second, addressIndex)) {
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "No information available for address");
}
}
}
UniValue deltas(UniValue::VARR);
for (std::vector<std::pair<CAddressIndexKey, CAmount> >::const_iterator it=addressIndex.begin(); it!=addressIndex.end(); it++) {
std::string address;
if (!getAddressFromIndex(it->first.type, it->first.hashBytes, address)) {
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Unknown address type");
}
UniValue delta(UniValue::VOBJ);
delta.push_back(Pair("satoshis", it->second));
delta.push_back(Pair("txid", it->first.txhash.GetHex()));
delta.push_back(Pair("index", (int)it->first.index));
delta.push_back(Pair("blockindex", (int)it->first.txindex));
delta.push_back(Pair("height", it->first.blockHeight));
delta.push_back(Pair("address", address));
deltas.push_back(delta);
}
UniValue result(UniValue::VOBJ);
if (includeChainInfo && start > 0 && end > 0) {
LOCK(cs_main);
if (start > chainActive.Height() || end > chainActive.Height()) {
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Start or end is outside chain range");
}
CBlockIndex* startIndex = chainActive[start];
CBlockIndex* endIndex = chainActive[end];
UniValue startInfo(UniValue::VOBJ);
UniValue endInfo(UniValue::VOBJ);
startInfo.push_back(Pair("hash", startIndex->GetBlockHash().GetHex()));
startInfo.push_back(Pair("height", start));
endInfo.push_back(Pair("hash", endIndex->GetBlockHash().GetHex()));
endInfo.push_back(Pair("height", end));
result.push_back(Pair("deltas", deltas));
result.push_back(Pair("start", startInfo));
result.push_back(Pair("end", endInfo));
return result;
} else {
return deltas;
}
}
UniValue getaddressbalance(const UniValue& params, bool fHelp)
{
if (fHelp || params.size() != 1)
throw runtime_error(
"getaddressbalance\n"
"\nReturns the balance for an address(es) (requires addressindex to be enabled).\n"
"\nArguments:\n"
"{\n"
" \"addresses\"\n"
" [\n"
" \"address\" (string) The base58check encoded address\n"
" ,...\n"
" ]\n"
"}\n"
"\nResult:\n"
"{\n"
" \"balance\" (string) The current balance in satoshis\n"
" \"received\" (string) The total number of satoshis received (including change)\n"
"}\n"
"\nExamples:\n"
+ HelpExampleCli("getaddressbalance", "'{\"addresses\": [\"12c6DSiU4Rq3P4ZxziKxzrL5LmMBrzjrJX\"]}'")
+ HelpExampleRpc("getaddressbalance", "{\"addresses\": [\"12c6DSiU4Rq3P4ZxziKxzrL5LmMBrzjrJX\"]}")
);
std::vector<std::pair<uint160, int> > addresses;
if (!getAddressesFromParams(params, addresses)) {
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid address");
}
std::vector<std::pair<CAddressIndexKey, CAmount> > addressIndex;
for (std::vector<std::pair<uint160, int> >::iterator it = addresses.begin(); it != addresses.end(); it++) {
if (!GetAddressIndex((*it).first, (*it).second, addressIndex)) {
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "No information available for address");
}
}
CAmount balance = 0;
CAmount received = 0;
for (std::vector<std::pair<CAddressIndexKey, CAmount> >::const_iterator it=addressIndex.begin(); it!=addressIndex.end(); it++) {
if (it->second > 0) {
received += it->second;
}
balance += it->second;
}
UniValue result(UniValue::VOBJ);
result.push_back(Pair("balance", balance));
result.push_back(Pair("received", received));
return result;
}
UniValue getaddresstxids(const UniValue& params, bool fHelp)
{
if (fHelp || params.size() != 1)
throw runtime_error(
"getaddresstxids\n"
"\nReturns the txids for an address(es) (requires addressindex to be enabled).\n"
"\nArguments:\n"
"{\n"
" \"addresses\"\n"
" [\n"
" \"address\" (string) The base58check encoded address\n"
" ,...\n"
" ]\n"
" \"start\" (number) The start block height\n"
" \"end\" (number) The end block height\n"
"}\n"
"\nResult:\n"
"[\n"
" \"transactionid\" (string) The transaction id\n"
" ,...\n"
"]\n"
"\nExamples:\n"
+ HelpExampleCli("getaddresstxids", "'{\"addresses\": [\"12c6DSiU4Rq3P4ZxziKxzrL5LmMBrzjrJX\"]}'")
+ HelpExampleRpc("getaddresstxids", "{\"addresses\": [\"12c6DSiU4Rq3P4ZxziKxzrL5LmMBrzjrJX\"]}")
);
std::vector<std::pair<uint160, int> > addresses;
if (!getAddressesFromParams(params, addresses)) {
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid address");
}
int start = 0;
int end = 0;
if (params[0].isObject()) {
UniValue startValue = find_value(params[0].get_obj(), "start");
UniValue endValue = find_value(params[0].get_obj(), "end");
if (startValue.isNum() && endValue.isNum()) {
start = startValue.get_int();
end = endValue.get_int();
}
}
std::vector<std::pair<CAddressIndexKey, CAmount> > addressIndex;
for (std::vector<std::pair<uint160, int> >::iterator it = addresses.begin(); it != addresses.end(); it++) {
if (start > 0 && end > 0) {
if (!GetAddressIndex((*it).first, (*it).second, addressIndex, start, end)) {
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "No information available for address");
}
} else {
if (!GetAddressIndex((*it).first, (*it).second, addressIndex)) {
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "No information available for address");
}
}
}
std::set<std::pair<int, std::string> > txids;
UniValue result(UniValue::VARR);
for (std::vector<std::pair<CAddressIndexKey, CAmount> >::const_iterator it=addressIndex.begin(); it!=addressIndex.end(); it++) {
int height = it->first.blockHeight;
std::string txid = it->first.txhash.GetHex();
if (addresses.size() > 1) {
txids.insert(std::make_pair(height, txid));
} else {
if (txids.insert(std::make_pair(height, txid)).second) {
result.push_back(txid);
}
}
}
if (addresses.size() > 1) {
for (std::set<std::pair<int, std::string> >::const_iterator it=txids.begin(); it!=txids.end(); it++) {
result.push_back(it->second);
}
}
return result;
}
UniValue getspentinfo(const UniValue& params, bool fHelp)
{
if (fHelp || params.size() != 1 || !params[0].isObject())
throw runtime_error(
"getspentinfo\n"
"\nReturns the txid and index where an output is spent.\n"
"\nArguments:\n"
"{\n"
" \"txid\" (string) The hex string of the txid\n"
" \"index\" (number) The start block height\n"
"}\n"
"\nResult:\n"
"{\n"
" \"txid\" (string) The transaction id\n"
" \"index\" (number) The spending input index\n"
" ,...\n"
"}\n"
"\nExamples:\n"
+ HelpExampleCli("getspentinfo", "'{\"txid\": \"0437cd7f8525ceed2324359c2d0ba26006d92d856a9c20fa0241106ee5a597c9\", \"index\": 0}'")
+ HelpExampleRpc("getspentinfo", "{\"txid\": \"0437cd7f8525ceed2324359c2d0ba26006d92d856a9c20fa0241106ee5a597c9\", \"index\": 0}")
);
UniValue txidValue = find_value(params[0].get_obj(), "txid");
UniValue indexValue = find_value(params[0].get_obj(), "index");
if (!txidValue.isStr() || !indexValue.isNum()) {
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid txid or index");
}
uint256 txid = ParseHashV(txidValue, "txid");
int outputIndex = indexValue.get_int();
CSpentIndexKey key(txid, outputIndex);
CSpentIndexValue value;
if (!GetSpentIndex(key, value)) {
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Unable to get spent info");
}
UniValue obj(UniValue::VOBJ);
obj.push_back(Pair("txid", value.txid.GetHex()));
obj.push_back(Pair("index", (int)value.inputIndex));
obj.push_back(Pair("height", value.blockHeight));
return obj;
}
|
#include<bits/stdc++.h>
using namespace std;
int main()
{
vector<int>vect{1,2,3,4,5};
for (int i=0; i < vect.size(); i++)
cout <<vect[i];
cout << "\n";
//for left
// rotate(vect.begin(),vect.begin()+2,vect.end());
// cout << "Old vector :";
// for (int i=0; i < vect.size(); i++)
// cout <<vect[i];
cout << "\n";
//for right
rotate(vect.begin(),vect.begin()+vect.size()-2,vect.end());
for (int i=0; i < vect.size(); i++)
cout <<vect[i];
return 0;
}
|
%include "fuzzy/memmgr/tables/gdt.asm"
[BITS 32]
extern interrupt_handler_0x00_0x1F_exception
global at_stack
global _interrupt_handler_0x00_exception
global _interrupt_handler_0x01_exception
global _interrupt_handler_0x02_exception
global _interrupt_handler_0x03_exception
global _interrupt_handler_0x04_exception
global _interrupt_handler_0x05_exception
global _interrupt_handler_0x06_exception
global _interrupt_handler_0x07_exception
global _interrupt_handler_0x08_exception
global _interrupt_handler_0x09_exception
global _interrupt_handler_0x0A_exception
global _interrupt_handler_0x0B_exception
global _interrupt_handler_0x0C_exception
global _interrupt_handler_0x0D_exception
global _interrupt_handler_0x0E_exception
global _interrupt_handler_0x0F_exception
global _interrupt_handler_0x10_exception
global _interrupt_handler_0x11_exception
global _interrupt_handler_0x12_exception
global _interrupt_handler_0x13_exception
global _interrupt_handler_0x14_exception
global _interrupt_handler_0x15_exception
global _interrupt_handler_0x16_exception
global _interrupt_handler_0x17_exception
global _interrupt_handler_0x18_exception
global _interrupt_handler_0x19_exception
global _interrupt_handler_0x1A_exception
global _interrupt_handler_0x1B_exception
global _interrupt_handler_0x1C_exception
global _interrupt_handler_0x1D_exception
global _interrupt_handler_0x1E_exception
global _interrupt_handler_0x1F_exception
[SECTION .text]
%macro create_low__interrupt_handler_xy_exception 1
_interrupt_handler_%1_exception:
; As we are HLT at end of exception there
; is no need to save context for now.
pushad ; execution all general purpose registers
xor eax, eax
mov eax, gs ; execution gs
push eax
mov eax, fs ; execution fs
push eax
mov eax, es ; execution es
push eax
mov eax, ds ; execution ds
push eax
mov eax, ss ; execution ss
push eax
mov eax, %1 ; exception id
push eax
mov eax, GDT_KERNEL_DS ; kernel ds
mov ds, eax
call interrupt_handler_0x00_0x1F_exception
HLT
%endmacro
%macro create_low__interrupt_handler_xy_exception_nohup 1
_interrupt_handler_%1_exception:
iret
%endmacro
at_stack:
push ebp
mov ebp, esp
push ds
mov eax, ss
mov ds, eax
mov esi, [ebp+8] ; stack pointer
mov eax, [esi]
pop ds
pop ebp
ret
create_low__interrupt_handler_xy_exception_nohup 0x00 ; divide-by-zero
create_low__interrupt_handler_xy_exception 0x01
create_low__interrupt_handler_xy_exception 0x02
create_low__interrupt_handler_xy_exception 0x03
create_low__interrupt_handler_xy_exception 0x04
create_low__interrupt_handler_xy_exception_nohup 0x05 ; bound-range-exceeded
create_low__interrupt_handler_xy_exception 0x06
create_low__interrupt_handler_xy_exception 0x07
create_low__interrupt_handler_xy_exception 0x08
create_low__interrupt_handler_xy_exception 0x09
create_low__interrupt_handler_xy_exception 0x0A
create_low__interrupt_handler_xy_exception 0x0B
create_low__interrupt_handler_xy_exception 0x0C
create_low__interrupt_handler_xy_exception 0x0D
create_low__interrupt_handler_xy_exception 0x0E
create_low__interrupt_handler_xy_exception 0x0F
create_low__interrupt_handler_xy_exception 0x10
create_low__interrupt_handler_xy_exception 0x11
create_low__interrupt_handler_xy_exception 0x12
create_low__interrupt_handler_xy_exception 0x13
create_low__interrupt_handler_xy_exception 0x14
create_low__interrupt_handler_xy_exception 0x15
create_low__interrupt_handler_xy_exception 0x16
create_low__interrupt_handler_xy_exception 0x17
create_low__interrupt_handler_xy_exception 0x18
create_low__interrupt_handler_xy_exception 0x19
create_low__interrupt_handler_xy_exception 0x1A
create_low__interrupt_handler_xy_exception 0x1B
create_low__interrupt_handler_xy_exception 0x1C
create_low__interrupt_handler_xy_exception 0x1D
create_low__interrupt_handler_xy_exception 0x1E
create_low__interrupt_handler_xy_exception 0x1F
|
; A212762: Number of (w,x,y,z) with all terms in {0,...,n}, w and x odd, y even.
; 0,2,6,32,60,162,252,512,720,1250,1650,2592,3276,4802,5880,8192,9792,13122,15390,20000,23100,29282,33396,41472,46800,57122,63882,76832,85260,101250,111600,131072,143616,167042,182070,209952,227772
mov $3,$0
add $0,1
add $3,2
div $3,2
mov $2,$3
mul $2,$0
mov $4,$0
div $4,2
mov $0,$4
mul $2,$4
mul $0,$2
mov $1,$0
|
; A006483: a(n) = Fibonacci(n)*2^n + 1.
; 1,3,5,17,49,161,513,1665,5377,17409,56321,182273,589825,1908737,6176769,19988481,64684033,209321985,677380097,2192048129,7093616641,22955425793,74285318145,240392339457,777925951489,2517421260801,8146546327553,26362777698305,85311740706817,276074592206849,893396147240961,2891090663309313
mov $1,1
mov $2,$0
lpb $2
mov $5,5
lpb $5
add $4,$3
sub $5,1
lpe
mov $3,$1
trn $4,5
add $1,$4
add $1,2
sub $2,1
lpe
|
LevelID = $FE
SRAMCopySrcLo = $DC
SRAMCopySrcHi = $D8
SRAMCopyDstLo = $DE
SRAMCopyDstHi = $DA
SRAMCopySize = $FC
SRAMCopyRt = $DC
ExObjTemps = $D8
ExGFXBG1Base = $E0
ExGFXBG2Base = $E6
ExGFXBG3Base = $EA
ExGFXOBJBase = $EE
ExTMBG2 = $D0
ExTMBG3 = $D2
ExPAL = $D4
ExANIM = $D5
ExMAP16 = $D6
|
#pragma once
#include "token.hpp"
namespace cctt
{
auto pretty_print_token_tree(Token const* first, Token const* last) -> void;
}
|
; A330451: a(n) = a(n-3) + 20*n - 30 for n > 2, with a(0)=0, a(1)=3, a(2)=13.
; 0,3,13,30,53,83,120,163,213,270,333,403,480,563,653,750,853,963,1080,1203,1333,1470,1613,1763,1920,2083,2253,2430,2613,2803,3000,3203,3413,3630,3853,4083,4320,4563,4813,5070,5333,5603,5880,6163,6453,6750,7053,7363,7680,8003,8333,8670,9013,9363,9720,10083,10453,10830,11213,11603,12000,12403,12813,13230,13653,14083,14520,14963,15413,15870,16333,16803,17280,17763,18253,18750,19253,19763,20280,20803,21333,21870,22413,22963,23520,24083,24653,25230,25813,26403,27000,27603,28213,28830,29453,30083
pow $0,2
mov $1,10
mul $1,$0
div $1,3
mov $0,$1
|
COMMENT @----------------------------------------------------------------------
Copyright (c) Berkeley Softworks 1992 -- All Rights Reserved
PROJECT: PC GEOS
MODULE: GeoWrite
FILE: documentPage.asm
REVISION HISTORY:
Name Date Description
---- ---- -----------
Tony 3/92 Initial version
DESCRIPTION:
This file contains the section related code for WriteDocumentClass
$Id: documentPage.asm,v 1.1 97/04/04 15:56:50 newdeal Exp $
------------------------------------------------------------------------------@
DocPageCreDest segment resource
COMMENT @----------------------------------------------------------------------
MESSAGE: WriteDocumentAppendPagesViaPosition --
MSG_WRITE_DOCUMENT_APPEND_PAGES_VIA_POSITION
for WriteDocumentClass
DESCRIPTION: Append pages after the given position
PASS:
*ds:si - instance data
es - segment of WriteDocumentClass
ax - The message
cx - x pos
dxbp - y pos
RETURN:
if _REGION_LIMIT - carry set if error
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 5/27/92 Initial version
------------------------------------------------------------------------------@
WriteDocumentAppendPagesViaPosition method dynamic WriteDocumentClass,
MSG_WRITE_DOCUMENT_APPEND_PAGES_VIA_POSITION
; We know that this happens as a result of an APPEND_SECTION from
; an article. We want to partially suspend the document so that
; the document size is not sent to the view until IS_LAST.
ornf ds:[di].WDI_state, mask WDS_SUSPENDED_FOR_APPENDING_REGIONS
; calculate page number
call LockMapBlockES
call FindPageAndSectionAbs ;cx = section, dx = page
EC < ERROR_C FIND_PAGE_RETURNED_ERROR >
mov_tr ax, dx
call MapPageToSectionPage ;ax = section
;bx = page in section
call VMUnlockES
mov_tr cx, ax ;cx = section #
mov bp, bx ;bp = page # in section
mov dx, MSG_WRITE_DOCUMENT_APPEND_PAGE
mov ax, MSG_WRITE_DOCUMENT_INSERT_APPEND_PAGES_LOW
call ObjCallInstanceNoLock
ret
WriteDocumentAppendPagesViaPosition endm
COMMENT @----------------------------------------------------------------------
MESSAGE: WriteDocumentDeletePagesAfterPosition --
MSG_WRITE_DOCUMENT_DELETE_PAGES_AFTER_POSITION
for WriteDocumentClass
DESCRIPTION: Delete all pages in a section after a given position
PASS:
*ds:si - instance data
es - segment of WriteDocumentClass
ax - The message
cx - x pos
dxbp - y pos
RETURN:
if _REGION_LIMIT - carry clear (always)
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 5/27/92 Initial version
------------------------------------------------------------------------------@
WriteDocumentDeletePagesAfterPosition method dynamic WriteDocumentClass,
MSG_WRITE_DOCUMENT_DELETE_PAGES_AFTER_POSITION
ornf ds:[di].WDI_state, mask WDS_SUSPENDED_FOR_APPENDING_REGIONS
; calculate page number
call LockMapBlockES
call FindPageAndSectionAbs ;cx = section, dx = page
mov_tr ax, dx
call MapPageToSectionPage ;ax = section
;bx = page in section
inc bx ;bx = page # to nuke
; we want to delete all pages *after* this page
call SectionArrayEToP_ES
mov cx, es:[di].SAE_numPages ;cx = # pages in section
sub cx, bx ;cx = # of pages to nuke
jcxz done
; ax = section, bx = page #
nukeLoop:
push cx
mov cx, 1 ;set delete flag
clr dx ;not direct user action
call AddDeletePageToSection
pop cx
loop nukeLoop
mov ax, MSG_VIS_INVALIDATE
call ObjCallInstanceNoLock
; if there is an invalid area (and we are in automatic recalc mode)
; then something unusual happened (like moving wrap around graphics
; from a deleted page)
push es
call WriteGetDGroupES
test es:[miscSettings], mask WMS_AUTOMATIC_LAYOUT_RECALC
pop es
jz noRecalc
tstdw es:MBH_invalidRect.RD_bottom
jz noRecalc
mov ax, MSG_WRITE_DOCUMENT_RECALC_INVAL
mov bx, ds:[LMBH_handle]
mov di, mask MF_FORCE_QUEUE
call ObjMessage
noRecalc:
done:
; We know that this happens as a result of an IS_LAST from
; an article. We want to take care of any pending suspends
EC < call AssertIsWriteDocument >
mov di, ds:[si]
add di, ds:[di].Gen_offset
andnf ds:[di].WDI_state, not mask WDS_SUSPENDED_FOR_APPENDING_REGIONS
test ds:[di].WDI_state, mask WDS_SEND_SIZE_PENDING
jz noSendSize
andnf ds:[di].WDI_state, not mask WDS_SEND_SIZE_PENDING
call ReallySendDocumentSizeToView
noSendSize:
call VMUnlockES
if _REGION_LIMIT
clc
endif
ret
WriteDocumentDeletePagesAfterPosition endm
COMMENT @----------------------------------------------------------------------
MESSAGE: WriteDocumentInsertAppendPagesLow --
MSG_WRITE_DOCUMENT_INSERT_APPEND_PAGES_LOW
for WriteDocumentClass
DESCRIPTION: Low-level insert/append pages
PASS:
*ds:si - instance data
es - segment of WriteDocumentClass
ax - The message
cx - section #
dx - MSG_WRITE_DOCUMENT_INSERT_PAGE to insert or
MSG_WRITE_DOCUMENT_APPEND_PAGE to append
bp - page # in section
RETURN:
if _REGION_LIMIT - carry set if error
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 5/27/92 Initial version
------------------------------------------------------------------------------@
WriteDocumentInsertAppendPagesLow method dynamic WriteDocumentClass,
MSG_WRITE_DOCUMENT_INSERT_APPEND_PAGES_LOW
mov_tr ax, cx ;ax = section #
mov bx, bp ;bx = page # in section
call LockMapBlockES
; get the number of pages to insert/delete and the offset to do so
push dx
call SectionArrayEToP_ES ;es:di = SectionArrayElement
xchg ax, bx ;ax = page in section
;bx = section #
clr dx ;dxax = page #
mov cx, es:[di].SAE_numMasterPages
div cx ;ax = set #, dx = remainder
mul cx ;ax = offset of group
xchg ax, bx ;ax = section number
;bx = page in section
pop dx
cmp dx, MSG_WRITE_DOCUMENT_INSERT_PAGE
jz 10$
add bx, cx ;if append then move one page
cmp bx, es:[di].SAE_numPages ;further
; if we are appending at the end then we need only do one page at a time
jb 10$
mov bx, es:[di].SAE_numPages
mov cx, 1
10$:
createLoop:
push cx
clr cx
clr dx ;not direct user action
call AddDeletePageToSection
if _REGION_LIMIT
jc abort
endif
inc bx
pop cx
loop createLoop
call VMDirtyES
; redraw the document (unless we are in galley or draft mode)
cmp es:MBH_displayMode, VLTDM_GALLEY
call VMUnlockES
jae noInvalidate
mov ax, MSG_VIS_INVALIDATE
call ObjCallInstanceNoLock
noInvalidate:
if _REGION_LIMIT
clc
exit:
endif
ret
if _REGION_LIMIT
abort:
pop cx
call VMUnlockES
stc
jmp exit
endif
WriteDocumentInsertAppendPagesLow endm
COMMENT @----------------------------------------------------------------------
FUNCTION: AddDeletePageToSection
DESCRIPTION: Add or delete a set of pages to a section
CALLED BY: INTERNAL
PASS:
*ds:si - document object
es - locked map block
ax - section to add pages to
bx - page number (in section) to insert before
cl - non-zero for delete
ch - non-zero to create only (no insert)
dx - non-zero if this is a direct user action
RETURN:
carry - set if aborted
DESTROYED:
none
REGISTER/STACK USAGE:
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
Tony 3/10/92 Initial version
------------------------------------------------------------------------------@
AddDeletePageToSection proc far uses ax, bx, cx, dx, di
section local word push ax
pageNum local word push bx
docobj local fptr push ds, si
mapBlock local sptr push es
flags local word push cx
userActionFlag local word push dx
insDelParam local InsertDeleteSpaceTypes
position local dword
vmFile local word
numRegions local word
insertPos local word
invalRect local RectDWord
ForceRef section
ForceRef docobj
ForceRef mapBlock
ForceRef numRegions
createOnlyFlag equ flags.high
deleteFlag equ flags.low
.enter
EC < call AssertIsWriteDocument >
call IgnoreUndoNoFlush
call SuspendFlowRegionNotifications
call GetFileHandle
mov vmFile, bx
; insertPos keeps the region number to insert AFTER. It starts at
; null because we must search the article table to figure out where
; to put the first region, but subsequent regions on the same page go
; in order so that we maintain the order from the master page
mov insertPos, CA_NULL_ELEMENT
; assume we are biffing objects
mov insDelParam, mask \
IDST_MOVE_OBJECTS_BELOW_AND_RIGHT_OF_INSERT_POINT_OR_DELETED_SPACE or\
mask IDST_RESIZE_OBJECTS_INTERSECTING_SPACE or \
mask IDST_DELETE_OBJECTS_SHRUNK_TO_ZERO_SIZE
; add space to the document
push ax
call SectionArrayEToP_ES
mov ax, es:MBH_pageSize.XYS_height
mov cx, ax ;cx = page height
mul pageNum ;dxax = position in this section
movdw position, dxax
pop ax
call FindSectionPosition ;dxax = y position
adddw position, dxax
mov bx, cx
clr cx ;cxbx = page height (space to add)
movdw dxax, position ;dx.ax = position to add space
tst createOnlyFlag
LONG jnz afterSpace
; if deleting then check for graphic objects on the page
tst deleteFlag
LONG jz doIt
negdw cxbx ;we're deleting so make
;space negative
tst userActionFlag
LONG jnz doIt
push ds
call WriteGetDGroupDS
test ds:[miscSettings], mask WMS_DTP_MODE
pop ds
LONG jnz done
call DoesSpaceContainGraphics ;any graphics on the page?
jnc doIt
; if the user has chosen "do not delete pages with graphics"
; then honor that request
push ds
call WriteGetDGroupDS
test ds:[miscSettings], mask WMS_DO_NOT_DELETE_PAGES_WITH_GRAPHICS
pop ds
jz 10$
toDone:
jmp done
10$:
push cx
mov ax, offset DeleteGraphicsOnPageString
mov cx, offset DeleteGraphicsOnPageTable
mov dx, CustomDialogBoxFlags \
<0, CDT_QUESTION, GIT_MULTIPLE_RESPONSE,0>
call ComplexQuery ;ax = InteractionCommand
pop cx
cmp ax, IC_NULL
stc
jz toDone
cmp ax, IC_DISMISS ;DISMISS = Cancel
stc
jz toDone
cmp ax, IC_NO ;NO = Move
jnz doIt ;YES = Delete
; it is a move -- set the correct flags and force some recalculation
mov insDelParam, mask \
IDST_MOVE_OBJECTS_BELOW_AND_RIGHT_OF_INSERT_POINT_OR_DELETED_SPACE or\
mask IDST_MOVE_OBJECTS_INTERSECTING_DELETED_SPACE or \
mask IDST_MOVE_OBJECTS_INSIDE_DELETED_SPACE_BY_AMOUNT_DELETED
push bx, cx, bp, ds
mov ds, mapBlock
movdw dxax, position
movdw invalRect.RD_bottom, dxax
adddw dxax, cxbx
movdw invalRect.RD_top, dxax
clr dx
clrdw invalRect.RD_left, dx
mov ax, ds:MBH_pageSize.XYS_width
movdw invalRect.RD_right, dxax
lea bp, invalRect
call AddRectToInval
pop bx, cx, bp, ds
doIt:
movdw dxax, position
push di
mov di, insDelParam
call InsertOrDeleteSpace
pop di
; increment/decrement number of pages
mov cx, 1 ;cx = 1 for insert
tst deleteFlag
jz noDelete3
neg cx ;cx = -1 for delete
noDelete3:
add es:[di].SAE_numPages, cx
add es:MBH_totalPages, cx
call VMDirtyES
afterSpace:
tst deleteFlag
jnz noCreate
; suspend all articles
call SuspendDocument
; calculate correct master page to use
mov ax, pageNum
clr dx
div es:[di].SAE_numMasterPages ;dx = remainder
mov bx, dx
shl bx ;make bx offset into MP array
push si, ds
; get master page block and lock it
mov ax, es:[di][bx].SAE_masterPages
call WriteVMBlockToMemBlock
mov_tr bx, ax
call ObjLockObjBlock
mov ds, ax
mov si, offset FlowRegionArray
; *ds:si = flow region array
push bx
mov bx, cs
mov di, offset CreateArticleRegionCallback
call ChunkArrayEnum
pop bx
call MemUnlock
pop si, ds
if _REGION_LIMIT
;
; If the regions could not be created, don't unsuspend the
; articles. They will recalculate, which could cause them
; to try to add more regions, yuck.
;
jc done ;error adding region
endif
; unsuspend all articles (causes redraw)
call UnsuspendDocument
noCreate:
; send updates (since a page has been added)
mov ax, mask NF_PAGE or mask NF_TOTAL_PAGES
call SendNotification
clc
done:
call UnsuspendFlowRegionNotifications
call AcceptUndo
.leave
ret
AddDeletePageToSection endp
COMMENT @----------------------------------------------------------------------
FUNCTION: CreateArticleRegionCallback
DESCRIPTION: Create an article region (as page of creating a page)
CALLED BY: INTERNAL
PASS:
*ds:si - flow region array
ds:di - FlowRegionArrayElement (in master page block)
ss:bp - inherited variables
es - map block (locked)
RETURN:
carry - set to finish (always returned clear)
(except when region limit is exceeded)
DESTROYED:
ax, bx, cx, dx, si, di
REGISTER/STACK USAGE:
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
Tony 3/10/92 Initial version
------------------------------------------------------------------------------@
CreateArticleRegionCallback proc far uses es
.enter inherit AddDeletePageToSection
push ds:[LMBH_handle]
; find the article block and lock it into es
push di, ds
mov ax, ds:[di].FRAE_article
segmov ds, es
mov si, offset ArticleArray
call ChunkArrayElementToPtr
mov ax, ds:[di].AAE_articleBlock
movdw dssi, docobj
call WriteVMBlockToMemBlock
mov_tr bx, ax
call ObjLockObjBlock
mov es, ax ;es = article block
pop di, ds
push bx ;save handle to unlock
movdw dxax, position
add ax, ds:[di].FRAE_position.XYO_y
adc dx, 0 ;dx.ax = y position for region
mov bx, ds:[di].FRAE_position.XYO_x
pushdw ds:[di].FRAE_textRegion
pushdw ds:[di].FRAE_size
segxchg ds, es ;ds = article, es = master page
mov si, offset ArticleRegionArray
mov di, ds:[si]
mov cx, ds:[di].CAH_count
mov numRegions, cx
if _REGION_LIMIT
checkLimit::
push cx, es
inc cx ; cx <- # of regions after add
call WriteGetDGroupES
tst es:regionLimit ; is there a limit?
jz noLimit ; no, skip the check
cmp cx, es:regionLimit ; # regions < limit?
LONG jae abort ; No - remember to pop CX, ES!
tst es:regionWarning ; is there a warning limit?
jz noLimit ; no, skip the check
cmp cx, es:regionWarning ; # regions < limit?
LONG jae warning
noLimit:
pop cx, es
endif
cmp insertPos, CA_NULL_ELEMENT
jz searchArray
; this is a subsequent region of the same page
push ax
mov ax, insertPos
sub cx, ax ;cx = regions left
dec cx
inc insertPos
call ChunkArrayElementToPtr
add di, size ArticleRegionArrayElement
pop ax
jmp regionCommon
; search the region array to find the place to insert the region
; easier to traverse ourselves than to use ChunkArrayEnum (faster too)
searchArray:
add di, ds:[di].CAH_offset
jcxz gotRegion
searchLoop:
;
; if we get to the end of our desired section, insert at end of
; our desired section
;
push ax
mov ax, section
cmp ax, ds:[di].ARAE_meta.VLTRAE_section
pop ax
jb gotRegion
cmpdw dxax, ds:[di].ARAE_meta.VLTRAE_spatialPosition.PD_y
jb gotRegion
ja next
cmp bx, ds:[di].ARAE_meta.VLTRAE_spatialPosition.PD_x.low
jbe gotRegion
next:
add di, size ArticleRegionArrayElement
loop searchLoop
gotRegion:
push ax
call ChunkArrayPtrToElement
mov insertPos, ax
pop ax
; We have found the position to insert (before ds:di)
; Rules for setting flags the the new region:
; 1) If this is the first and only region in the section, set IS_LAST
; 2) If inserting after the final region in the section, set EMPTY
; 3) If inserting before an EMPTY region, set EMPTY
; Otherwise set no flags
;
; Luckily the IS_LAST bit isn't used any more :-)
regionCommon:
push ax
mov ax, section ;ax = section we're inserting in
cmp cx, numRegions
jz isFirstRegionOfSection
cmp ax, ds:[di-(size ArticleRegionArrayElement)].VLTRAE_section
jz notFirstRegionOfSection
; This is the first region, is it the only one ?
isFirstRegionOfSection:
jcxz firstAndOnly
cmp ax, ds:[di].VLTRAE_section
jz firstButNotOnly
firstAndOnly:
;;; mov cx, mask VLTRF_IS_LAST
clr cx
jmp gotFlags
firstButNotOnly:
clr cx
jmp gotFlags
; Check for case 2 and 3
notFirstRegionOfSection:
jcxz finalRegionInSection
cmp ax, ds:[di].VLTRAE_section
jz notFinalRegionInSection
finalRegionInSection:
mov cx, mask VLTRF_EMPTY
jmp gotFlags
notFinalRegionInSection:
mov cx, mask VLTRF_EMPTY
test cx, ds:[di].VLTRAE_flags
jnz gotFlags
clr cx
gotFlags:
pop ax
call ChunkArrayInsertAt
call ClearArticleTextCachedRegion
; Now that we've created a new element for this region, store it's
; information.
; We make the text object's region one pixel smaller than the grobj
; object so that things will draw correctly
movdw ds:[di].ARAE_meta.VLTRAE_spatialPosition.PD_y, dxax
mov ds:[di].ARAE_meta.VLTRAE_spatialPosition.PD_x.low, bx
mov ds:[di].ARAE_meta.VLTRAE_flags, cx
popdw cxdx
movdw ds:[di].ARAE_meta.VLTRAE_size, cxdx
mov cx, section
mov ds:[di].ARAE_meta.VLTRAE_section, cx
; if we had deleted any chars/lines/space from this section before
; we need to reclaim them now
push es
mov es, mapBlock
call VMDirtyES
mov_tr ax, cx
push di
call SectionArrayEToP_ES ;es:di = section
mov bx, di ;es:bx = section
pop di
clrdw dxax
xchgdw dxax, es:[bx].SAE_charsDeleted
movdw ds:[di].VLTRAE_charCount, dxax
clrdw dxax
xchgdw dxax, es:[bx].SAE_linesDeleted
movdw ds:[di].VLTRAE_lineCount, dxax
clrdw dxax
xchgwbf dxal, es:[bx].SAE_spaceDeleted
movwbf ds:[di].VLTRAE_calcHeight, dxal
pop es
; copy region (if any)
popdw axdx ;axdx = region
tstdw axdx
jz noRegionToCopy
push di, bp ;save ptr to article reg
mov di, dx ;axdi = source item
mov cx, DB_UNGROUPED ;cx = dest group
mov bx, vmFile ;source file
mov bp, bx ;dest file
call DBCopyDBItem ;axdi = item in dest
mov dx, di ;axdx = item in dest
pop di, bp ;restore ptr to article reg
movdw ds:[di].ARAE_inheritedTextRegion, axdx
noRegionToCopy:
; create a GrObj flow object for the region
push di, ds ;save ptr to article reg
pushdw ds:[di].ARAE_meta.VLTRAE_spatialPosition.PD_y ;y pos
mov es, mapBlock
mov ax, es:MBH_grobjBlock
mov bx, vmFile
call VMVMBlockToMemBlock
pop bx
push ax
mov ax, ds:[di].ARAE_meta.VLTRAE_spatialPosition.PD_x.low
mov cx, ds:[di].ARAE_meta.VLTRAE_size.XYS_width
mov dx, ds:[di].ARAE_meta.VLTRAE_size.XYS_height
mov di, offset MainBody
push di ;push body optr
mov di, segment FlowRegionClass
push di
mov di, offset FlowRegionClass
push di ;push class pointer
mov di, GRAPHIC_STYLE_FLOW_REGION
push di
mov di, CA_NULL_ELEMENT
push di ;textStyle
mov di, DOCUMENT_FLOW_REGION_LOCKS
push di
call CreateGrObj ;cx:dx = new object
pop di, ds ;restore ptr to article reg
; tell the flow region what article block it is associated with
mov bx, ds:[LMBH_handle]
call VMMemBlockToVMBlock ;ax = article VM block
mov_tr bx, ax ;bx = article VM block
clr ax ;ax = master page VM block
call SetFlowRegionAssociation
call MemBlockToVMBlockCX
movdw ds:[di].ARAE_object, cxdx
; calculate the correct text flow region for the flow region, but
; first see if we can optimize by noticing that there are no wrap
; objects
mov es, mapBlock
mov ax, es:MBH_grobjBlock
mov bx, vmFile ;bx = file
call VMVMBlockToMemBlock
push bx
mov_tr bx, ax
mov si, offset MainBody ;bxsi = grobj body
mov ax, MSG_WRITE_GROBJ_BODY_GET_FLAGS
push di, bp
mov di, mask MF_CALL or mask MF_FIXUP_DS
call ObjMessage ;ax = WriteGrObjBodyFlags
pop di, bp
test ax, mask WGOBF_WRAP_AREA_NON_NULL
pop ax ;ax = file
jnz recalcFlow
tstdw ds:[di].ARAE_inheritedTextRegion
jz afterFlow
recalcFlow:
call RecalcOneFlowRegion
afterFlow:
mov si, offset ArticleRegionArray
call ChunkArrayPtrToElement ;ax = region number
; unlock article block
pop bx
call MemUnlock
;
; Recalculate text.
;
; If this region was added because the text object asked for it, then
; we don't need to recalculate (since the text object is in the process
; of doing just that).
;
; If this region was added at the users request, then we have one of
; two situations:
; - This is a new article (we need to create lines/recalculate)
; - This is not a new article (we just need to recalculate)
;
push ax ;save region number
mov si, offset ArticleText
mov ax, MSG_VIS_NOTIFY_GEOMETRY_VALID
call DP_ObjMessageNoFlags
pop cx ;cx = region number
mov si, offset ArticleText
mov ax, MSG_VIS_LARGE_TEXT_REGION_CHANGED
call DP_ObjMessageNoFlags
pop bx
call MemDerefDS
clc
if _REGION_LIMIT
done:
endif
.leave
ret
if _REGION_LIMIT
;
; The region limit would exceeded if another region were added,
; so don't do it - just clean up the stack and exit with error.
;
abort:
pop cx, es
add sp, (2 * size dword) ;clear the stack
pop bx
call MemUnlock ;unlock article block
pop bx
call MemDerefDS ;*ds:si - FlowRegArray
stc ;signal error
jmp done
warning:
push ax, bx, si, di, ds
lds si, ss:docobj
mov bx, ds:[LMBH_handle]
mov ax, MSG_WRITE_DOCUMENT_DO_REGION_LIMIT_WARNING
mov di, mask MF_FORCE_QUEUE or mask MF_CHECK_DUPLICATE or \
mask MF_REPLACE or mask MF_CAN_DISCARD_IF_DESPERATE
call ObjMessage
pop ax, bx, si, di, ds
jmp noLimit
endif
CreateArticleRegionCallback endp
COMMENT @----------------------------------------------------------------------
FUNCTION: ClearArticleTextCachedRegion
DESCRIPTION: Clear the cached region for an ArticleText
CALLED BY: INTERNAL
PASS:
ds - article block
RETURN:
none
DESTROYED:
none
REGISTER/STACK USAGE:
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
Tony 6/ 3/92 Initial version
------------------------------------------------------------------------------@
ClearArticleTextCachedRegion proc far
class WriteArticleClass
; clear out the gstate region that we're translated for
push si
mov si, offset ArticleText
mov si, ds:[si]
add si, ds:[si].Vis_offset
cmp ds:[si].VTI_gstateRegion, -1
pop si
ret
ClearArticleTextCachedRegion endp
COMMENT @----------------------------------------------------------------------
FUNCTION: DoesSpaceContainGraphics
DESCRIPTION: See if a given area contains graphics
CALLED BY: INTERNAL
PASS:
*ds:si - document object
es - locked map block
dx.ax - position to add space
cx.bx - (signed) amount of space to add
RETURN:
carry - set if any graphics in space
DESTROYED:
none
REGISTER/STACK USAGE:
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
Tony 4/ 1/92 Initial version
------------------------------------------------------------------------------@
DoesSpaceContainGraphics proc near uses ax, bx, cx, dx, si, di, bp
.enter
EC < call AssertIsWriteDocument >
sub sp, size WriteGrObjBodyGraphicsInSpaceParams
mov bp, sp
movdw ss:[bp].WGBGISP_position, dxax
negdw cxbx
movdw ss:[bp].WGBGISP_size, cxbx
mov ax, es:MBH_grobjBlock
call WriteVMBlockToMemBlock
mov_tr bx, ax
mov ax, MSG_WRITE_GROBJ_BODY_GRAPHICS_IN_SPACE
mov si, offset MainBody
mov di, mask MF_CALL or mask MF_FIXUP_DS
call ObjMessage
lahf
add sp, size WriteGrObjBodyGraphicsInSpaceParams
sahf
.leave
ret
DoesSpaceContainGraphics endp
COMMENT @----------------------------------------------------------------------
FUNCTION: SetFlowRegionAssociation
DESCRIPTION: Set the data the associates a flow region with something
CALLED BY: INTERNAL
PASS:
cxdx - flow region
ax - master page VM block
bx - article block
RETURN:
none
DESTROYED:
none
REGISTER/STACK USAGE:
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
Tony 9/12/92 Initial version
------------------------------------------------------------------------------@
SetFlowRegionAssociation proc far uses ax, bx, cx, dx, si
.enter
push bx
movdw bxsi, cxdx ;bxsi = flow region
mov_tr cx, ax ;cx = master page
pop dx ;dx = article block
mov ax, MSG_FLOW_REGION_SET_ASSOCIATION
call DP_ObjMessageFixupDS
.leave
ret
SetFlowRegionAssociation endp
COMMENT @----------------------------------------------------------------------
FUNCTION: InsertOrDeleteSpace
DESCRIPTION: Insert vertical space in the document
CALLED BY: INTERNAL
PASS:
*ds:si - document object
es - locked map block
dx.ax - position to add space
cx.bx - (signed) amount of space to add
di - InsertDeleteDeleteTypes
RETURN:
none
DESTROYED:
none
REGISTER/STACK USAGE:
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
Tony 3/10/92 Initial version
------------------------------------------------------------------------------@
InsertOrDeleteSpace proc near uses ax, bx, cx, dx, si, di, bp
insDelParams local InsertDeleteSpaceParams
mapBlockSeg local sptr
fileHandle local word
ForceRef mapBlockSeg
.enter
EC < call AssertIsWriteDocument >
; fill in the Parameter structure
mov insDelParams.IDSP_type, di
movdw insDelParams.IDSP_position.PDF_y.DWF_int, dxax
movdw insDelParams.IDSP_space.PDF_y.DWF_int, cxbx
clr ax
mov insDelParams.IDSP_position.PDF_y.DWF_frac, ax
mov insDelParams.IDSP_space.PDF_y.DWF_frac, ax
clrdw insDelParams.IDSP_position.PDF_x.DWF_int
clrdw insDelParams.IDSP_space.PDF_x.DWF_int
mov insDelParams.IDSP_position.PDF_x.DWF_frac, ax
mov insDelParams.IDSP_space.PDF_x.DWF_frac, ax
; for each article:
; - for each text region:
; - move region down if needed
call GetFileHandle
mov fileHandle, bx
push ds:[LMBH_handle], si, es
segmov ds, es
mov si, offset ArticleArray
mov bx, cs
mov di, offset InsDelSpaceInArticleCallback
call ChunkArrayEnum
pop bx, si, es
call MemDerefDS
mov ax, es:MBH_grobjBlock
call WriteVMBlockToMemBlock
mov_tr bx, ax
mov si, offset MainBody
mov ax, MSG_VIS_LAYER_INSERT_OR_DELETE_SPACE
push bp
lea bp, insDelParams
call DP_ObjMessageFixupDS
pop bp
.leave
call SendDocumentSizeToView
ret
InsertOrDeleteSpace endp
COMMENT @----------------------------------------------------------------------
FUNCTION: InsDelSpaceInArticleCallback
DESCRIPTION: Insert or delete space in an article
CALLED BY: INTERNAL
PASS:
ds:di - ArticleArrayElement
ss:bp - inherited variables
RETURN:
carry - set to end (always returned clear)
DESTROYED:
ax, bx, dx, si, di
REGISTER/STACK USAGE:
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
Tony 3/10/92 Initial version
------------------------------------------------------------------------------@
InsDelSpaceInArticleCallback proc far uses cx, ds
.enter inherit InsertOrDeleteSpace
mov mapBlockSeg, ds
; lock the article block
mov bx, fileHandle
mov ax, ds:[di].AAE_articleBlock
call VMVMBlockToMemBlock
mov_tr bx, ax
push bx
call ObjLockObjBlock
mov ds, ax ;ds = article block
movdw dxax, insDelParams.IDSP_position.PDF_y.DWF_int
mov si, offset ArticleRegionArray
mov di, ds:[si]
mov cx, ds:[di].CAH_count
jcxz done
add di, ds:[di].CAH_offset
; zip through the article block looking for regions that need to
; be moved
; dxax = position to insert/delete space at
sizeLoop:
jgdw dxax, ds:[di].ARAE_meta.VLTRAE_spatialPosition.PD_y, next
; move this object -- move the text region (grobj will move the
; grobj object)
adddw ds:[di].ARAE_meta.VLTRAE_spatialPosition.PD_y, \
insDelParams.IDSP_space.PDF_y.DWF_int, bx
; see if this object needs to be deleted
jldw dxax, ds:[di].ARAE_meta.VLTRAE_spatialPosition.PD_y, next
deleteObj::
mov es, mapBlockSeg
call DeleteArticleRegion
sub di, size ArticleRegionArrayElement
next:
add di, size ArticleRegionArrayElement
loop sizeLoop
done:
pop bx
call MemUnlock
clc
.leave
ret
InsDelSpaceInArticleCallback endp
COMMENT @----------------------------------------------------------------------
FUNCTION: DeleteArticleRegion
DESCRIPTION: Update the region array (and possibly the section array)
for a deleted region
CALLED BY: INTERNAL
PASS:
ds:di - ArticleRegionArrayElement
es - map block
RETURN:
none
DESTROYED:
none
REGISTER/STACK USAGE:
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
Tony 6/ 4/92 Initial version
------------------------------------------------------------------------------@
DeleteArticleRegion proc far uses ax, bx, cx, dx, si, bp
.enter
call ChunkArrayPtrToElement ;ax = region number
mov_tr cx, ax ;cx = region number
push si
movdw bxsi, ds:[di].ARAE_object
call VMBlockToMemBlockRefDS
mov ax, MSG_GO_CLEAR
call DP_ObjMessageNoFlags
push cx
mov si, offset ArticleText
mov ax, MSG_VIS_LARGE_TEXT_REGION_CHANGED
call ObjCallInstanceNoLock
pop ax
pop si
; clear out the gstate region that we're translated for
call ClearArticleTextCachedRegion
call ChunkArrayElementToPtr ;ds:di = region
; we need to update the region array to account for the space lost
; if we are not at the first region in the section then add everything
; to the previous region. If we are at the first region then add
; everything to the next region *unless* we are at the only region for
; the section in which case we store the nuked values in the
; section array
mov ax, ds:[di].VLTRAE_section
mov bx, di ;ds:bx = dest region
mov si, ds:[ArticleRegionArray]
ChunkSizePtr ds, si, cx
add cx, si ;cx = offset past chunk
add si, ds:[si].CAH_offset
;
; ds:si = First region in the region array
; ds:di = Region to nuke
; ax = Section for (ds:di)
; ds:cx = Pointer past end of region array
;
cmp si, di ;first region ?
jz firstRegion
;
; We aren't deleting the very first region. If the preceding region
; is in the same section, then we ripple information from the current
; region backwards into that previous one.
;
lea bx, ds:[di-(size ArticleRegionArrayElement)]
cmp ax, ds:[bx].VLTRAE_section
jz gotRegionToModify
;
; The previous region is not in the same section as (ds:di). We need
; to ripple the information forward to the next region (if possible).
;
firstRegion:
;
; ds:di = Region to delete, it is the first region in its section
; ds:cx = Pointer past the end of the region array
;
; We want to ripple information forward to the next region in the
; array, unless the current region is the last one in the section
; in which case we are suddenly helpless :-)
;
sub cx, size ArticleRegionArrayElement
cmp di, cx ; Check for last in array
je lastInSection ; Branch if it is
lea bx, ds:[di+(size ArticleRegionArrayElement)]
cmp ax, ds:[bx].VLTRAE_section ; Check next not in same section
jne lastInSection ; Branch if it isn't
;
; The next region exists and is in the same section. Check to see if
; it's empty.
;
test ds:[bx].VLTRAE_flags, mask VLTRF_EMPTY
jz gotRegionToModify ; Branch if not empty
lastInSection:
;
; This is the last region in this section. Accumulate the amounts
; into a safe place.
;
push di
call SectionArrayEToP_ES ;es:di = section
mov bx, di ;es:bx = section
pop di
adddw es:[bx].SAE_charsDeleted, ds:[di].VLTRAE_charCount, ax
adddw es:[bx].SAE_linesDeleted, ds:[di].VLTRAE_lineCount, ax
addwbf es:[bx].SAE_spaceDeleted, ds:[di].VLTRAE_calcHeight, ax
call VMDirtyES
jmp afterAdjustment
gotRegionToModify:
adddw ds:[bx].VLTRAE_charCount, ds:[di].VLTRAE_charCount, ax
adddw ds:[bx].VLTRAE_lineCount, ds:[di].VLTRAE_lineCount, ax
addwbf ds:[bx].VLTRAE_calcHeight, ds:[di].VLTRAE_calcHeight, ax
afterAdjustment:
mov si, offset ArticleRegionArray
call ChunkArrayDelete
.leave
ret
DeleteArticleRegion endp
COMMENT @----------------------------------------------------------------------
FUNCTION: SuspendFlowRegionNotifications
DESCRIPTION: Suspend flow region notifications
CALLED BY: INTERNAL
PASS:
none
RETURN:
none
DESTROYED:
none
REGISTER/STACK USAGE:
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
Tony 9/13/92 Initial version
------------------------------------------------------------------------------@
SuspendFlowRegionNotifications proc far
pushf
push ds
call WriteGetDGroupDS
inc ds:[suspendNotification]
pop ds
popf
ret
SuspendFlowRegionNotifications endp
UnsuspendFlowRegionNotifications proc far
pushf
push ds
call WriteGetDGroupDS
dec ds:[suspendNotification]
pop ds
popf
ret
UnsuspendFlowRegionNotifications endp
COMMENT @----------------------------------------------------------------------
MESSAGE: WriteDocumentGetGraphicTokensForStyle --
MSG_WRITE_DOCUMENT_GET_GRAPHIC_TOKENS_FOR_STYLE
for WriteDocumentClass
DESCRIPTION: Get the graphic attribute tokens for a style
PASS:
*ds:si - instance data
es - segment of WriteDocumentClass
ax - The message
cx - style token
RETURN:
cx - line attr token
dx - area attr token
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 11/13/92 Initial version
------------------------------------------------------------------------------@
WriteDocumentGetGraphicTokensForStyle method dynamic WriteDocumentClass,
MSG_WRITE_DOCUMENT_GET_GRAPHIC_TOKENS_FOR_STYLE
call GetFileHandle ;bx = file
call LockMapBlockDS
mov ax, ds:[MBH_graphicStyles]
call VMUnlockDS
call VMLock
mov ds, ax
mov si, VM_ELEMENT_ARRAY_CHUNK ;*ds:si = styles
mov_tr ax, cx
call ChunkArrayElementToPtr
mov cx, ds:[di].GSE_lineAttrToken
mov dx, ds:[di].GSE_areaAttrToken
call VMUnlock
ret
WriteDocumentGetGraphicTokensForStyle endm
COMMENT @----------------------------------------------------------------------
MESSAGE: WriteDocumentGetTextTokensForStyle --
MSG_WRITE_DOCUMENT_GET_TEXT_TOKENS_FOR_STYLE
for WriteDocumentClass
DESCRIPTION: Get the text attribute tokens for a style
PASS:
*ds:si - instance data
es - segment of WriteDocumentClass
ax - The message
cx - style token
RETURN:
cx - char attr token
dx - para attr token
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 11/13/92 Initial version
------------------------------------------------------------------------------@
WriteDocumentGetTextTokensForStyle method dynamic WriteDocumentClass,
MSG_WRITE_DOCUMENT_GET_TEXT_TOKENS_FOR_STYLE
call GetFileHandle ;bx = file
call LockMapBlockDS
mov ax, ds:[MBH_textStyles]
call VMUnlockDS
call VMLock
mov ds, ax
mov si, VM_ELEMENT_ARRAY_CHUNK ;*ds:si = styles
mov_tr ax, cx
call ChunkArrayElementToPtr
mov cx, ds:[di].TSEH_charAttrToken
mov dx, ds:[di].TSEH_paraAttrToken
call VMUnlock
ret
WriteDocumentGetTextTokensForStyle endm
if _REGION_LIMIT
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
WriteDocumentDoRegionLimitWarning
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: If the current number of regions exceeds the region limit
warning threshold, warn the user.
CALLED BY: MSG_WRITE_DOCUMENT_DO_REGION_LIMIT_WARNING
PASS: *ds:si - instance data
ds:di - *ds:si
es - seg addr of WriteDocumentClass
ax - the message
RETURN: nothing
DESTROYED: bx, si, di, ds, es (method handler)
ax, cx, bp
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
cassie 4/28/95 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
WriteDocumentDoRegionLimitWarning method dynamic WriteDocumentClass,
MSG_WRITE_DOCUMENT_DO_REGION_LIMIT_WARNING
;
; If we're in the process of reverting, we don't care how
; many regions the document has now, because it will have
; fewer than the limit after the revert is completed.
;
cmp ds:[di].GDI_operation, GDO_REVERT_TO_AUTO_SAVE
je done
call GetFileHandle
mov bp, bx
;
; Count all the regions in all the articles.
;
clr cx ; initialize count
call LockMapBlockDS
mov si, offset ArticleArray
mov bx, cs
mov di, offset CountArticleRegionsCallback
call ChunkArrayEnum
call VMUnlockDS
;
; If the number of regions is now above the warning threshold,
; tell the user about it.
;
call WriteGetDGroupDS
EC < tst ds:regionWarning >
EC < ERROR_Z WRITE_INTERNAL_LOGIC_ERROR >
cmp cx, ds:regionWarning
jb done
mov ax, offset RegionWarningString
call DisplayWarning
done:
ret
WriteDocumentDoRegionLimitWarning endm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
CountArticleRegionsCallback
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: count the total number of regions in all articles
CALLED BY: WriteDocumentDoRegionLimitWarning
PASS: ds:di - ArticleArrayElement
bp - file handle
cx - cumulative count
RETURN: carry clear
DESTROYED: ax, si, di
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
cassie 4/28/95 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
CountArticleRegionsCallback proc far
uses ds
.enter
mov bx, bp
mov ax, ds:[di].AAE_articleBlock
call VMVMBlockToMemBlock
mov bx, ax
push bx
call ObjLockObjBlock
mov ds, ax ;ds = article block
mov si, offset ArticleRegionArray
mov di, ds:[si]
add cx, ds:[di].CAH_count
pop bx
call MemUnlock
clc
.leave
ret
CountArticleRegionsCallback endp
endif
DocPageCreDest ends
|
;;
;; Copyright (c) 2020, Intel Corporation
;;
;; Redistribution and use in source and binary forms, with or without
;; modification, are permitted provided that the following conditions are met:
;;
;; * Redistributions of source code must retain the above copyright notice,
;; this list of conditions and the following disclaimer.
;; * Redistributions in binary form must reproduce the above copyright
;; notice, this list of conditions and the following disclaimer in the
;; documentation and/or other materials provided with the distribution.
;; * Neither the name of Intel Corporation nor the names of its contributors
;; may be used to endorse or promote products derived from this software
;; without specific prior written permission.
;;
;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
;; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
;; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
;; DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
;; FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
;; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
;; SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
;; CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
;; OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
;; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
;;
%include "include/os.asm"
%include "include/imb_job.asm"
%include "include/memcpy.asm"
%include "include/clear_regs.asm"
%include "include/chacha_poly_defines.asm"
%include "include/cet.inc"
section .data
default rel
align 16
constants0:
dd 0x61707865, 0x61707865, 0x61707865, 0x61707865
align 16
constants1:
dd 0x3320646e, 0x3320646e, 0x3320646e, 0x3320646e
align 16
constants2:
dd 0x79622d32, 0x79622d32, 0x79622d32, 0x79622d32
align 16
constants3:
dd 0x6b206574, 0x6b206574, 0x6b206574, 0x6b206574
align 16
constants:
dd 0x61707865, 0x3320646e, 0x79622d32, 0x6b206574
align 16
dword_1:
dd 0x00000001, 0x00000000, 0x00000000, 0x00000000
align 16
dword_2:
dd 0x00000002, 0x00000000, 0x00000000, 0x00000000
align 16
dword_1_4:
dd 0x00000001, 0x00000002, 0x00000003, 0x00000004
align 16
dword_4:
dd 0x00000004, 0x00000004, 0x00000004, 0x00000004
align 16
shuf_mask_rotl8:
db 3, 0, 1, 2, 7, 4, 5, 6, 11, 8, 9, 10, 15, 12, 13, 14
align 16
shuf_mask_rotl16:
db 2, 3, 0, 1, 6, 7, 4, 5, 10, 11, 8, 9, 14, 15, 12, 13
align 16
poly_clamp_r:
dq 0x0ffffffc0fffffff, 0x0ffffffc0ffffffc
struc STACK
_STATE: reso 16 ; Space to store first 4 states
_XMM_SAVE: reso 2 ; Space to store up to 2 temporary XMM registers
_GP_SAVE: resq 7 ; Space to store up to 7 GP registers
_RSP_SAVE: resq 1 ; Space to store rsp pointer
endstruc
%define STACK_SIZE STACK_size
%ifdef LINUX
%define arg1 rdi
%define arg2 rsi
%define arg3 rdx
%define arg4 rcx
%define arg5 r8
%else
%define arg1 rcx
%define arg2 rdx
%define arg3 r8
%define arg4 r9
%define arg5 [rsp + 40]
%endif
%define job arg1
%define APPEND(a,b) a %+ b
section .text
%macro ENCRYPT_0B_64B 14-15
%define %%SRC %1 ; [in/out] Source pointer
%define %%DST %2 ; [in/out] Destination pointer
%define %%LEN %3 ; [in/clobbered] Length to encrypt
%define %%OFF %4 ; [in] Offset into src/dst
%define %%KS0 %5 ; [in/out] Bytes 0-15 of keystream
%define %%KS1 %6 ; [in/out] Bytes 16-31 of keystream
%define %%KS2 %7 ; [in/out] Bytes 32-47 of keystream
%define %%KS3 %8 ; [in/out] Bytes 48-63 of keystream
%define %%PT0 %9 ; [in/clobbered] Bytes 0-15 of plaintext
%define %%PT1 %10 ; [in/clobbered] Bytes 16-31 of plaintext
%define %%PT2 %11 ; [in/clobbered] Bytes 32-47 of plaintext
%define %%PT3 %12 ; [in/clobbered] Bytes 48-63 of plaintext
%define %%TMP %13 ; [clobbered] Temporary GP register
%define %%TMP2 %14 ; [clobbered] Temporary GP register
%define %%KS_PTR %15 ; [in] Pointer to keystream
or %%LEN, %%LEN
jz %%end_encrypt
cmp %%LEN, 16
jbe %%up_to_16B
cmp %%LEN, 32
jbe %%up_to_32B
cmp %%LEN, 48
jbe %%up_to_48B
%%up_to_64B:
vmovdqu %%PT0, [%%SRC + %%OFF]
vmovdqu %%PT1, [%%SRC + %%OFF + 16]
vmovdqu %%PT2, [%%SRC + %%OFF + 32]
%if %0 == 15
vmovdqu %%KS0, [%%KS_PTR]
vmovdqu %%KS1, [%%KS_PTR + 16]
vmovdqu %%KS2, [%%KS_PTR + 32]
%endif
vpxor %%PT0, %%KS0
vpxor %%PT1, %%KS1
vpxor %%PT2, %%KS2
vmovdqu [%%DST + %%OFF], %%PT0
vmovdqu [%%DST + %%OFF + 16], %%PT1
vmovdqu [%%DST + %%OFF + 32], %%PT2
add %%SRC, %%OFF
add %%DST, %%OFF
add %%SRC, 48
add %%DST, 48
sub %%LEN, 48
simd_load_avx_16_1 %%PT3, %%SRC, %%LEN
; XOR KS with plaintext and store resulting ciphertext
%if %0 == 15
vmovdqu %%KS3, [%%KS_PTR + 48]
%endif
vpxor %%PT3, %%KS3
simd_store_avx %%DST, %%PT3, %%LEN, %%TMP, %%TMP2
jmp %%end_encrypt
%%up_to_48B:
vmovdqu %%PT0, [%%SRC + %%OFF]
vmovdqu %%PT1, [%%SRC + %%OFF + 16]
%if %0 == 15
vmovdqu %%KS0, [%%KS_PTR]
vmovdqu %%KS1, [%%KS_PTR + 16]
%endif
vpxor %%PT0, %%KS0
vpxor %%PT1, %%KS1
vmovdqu [%%DST + %%OFF], %%PT0
vmovdqu [%%DST + %%OFF + 16], %%PT1
add %%SRC, %%OFF
add %%DST, %%OFF
add %%SRC, 32
add %%DST, 32
sub %%LEN, 32
simd_load_avx_16_1 %%PT2, %%SRC, %%LEN
; XOR KS with plaintext and store resulting ciphertext
%if %0 == 15
vmovdqu %%KS2, [%%KS_PTR + 32]
%endif
vpxor %%PT2, %%KS2
simd_store_avx %%DST, %%PT2, %%LEN, %%TMP, %%TMP2
jmp %%end_encrypt
%%up_to_32B:
vmovdqu %%PT0, [%%SRC + %%OFF]
%if %0 == 15
vmovdqu %%KS0, [%%KS_PTR]
%endif
vpxor %%PT0, %%KS0
vmovdqu [%%DST + %%OFF], %%PT0
add %%SRC, %%OFF
add %%DST, %%OFF
add %%SRC, 16
add %%DST, 16
sub %%LEN, 16
simd_load_avx_16_1 %%PT1, %%SRC, %%LEN
; XOR KS with plaintext and store resulting ciphertext
%if %0 == 15
vmovdqu %%KS1, [%%KS_PTR + 16]
%endif
vpxor %%PT1, %%KS1
simd_store_avx %%DST, %%PT1, %%LEN, %%TMP, %%TMP2
jmp %%end_encrypt
%%up_to_16B:
add %%SRC, %%OFF
add %%DST, %%OFF
simd_load_avx_16_1 %%PT0, %%SRC, %%LEN
; XOR KS with plaintext and store resulting ciphertext
%if %0 == 15
vmovdqu %%KS0, [%%KS_PTR]
%endif
vpxor %%PT0, %%KS0
simd_store_avx %%DST, %%PT0, %%LEN, %%TMP, %%TMP2
%%end_encrypt:
add %%SRC, %%LEN
add %%DST, %%LEN
%endmacro
;; 4x4 32-bit transpose function
%macro TRANSPOSE4_U32 6
%define %%r0 %1 ;; [in/out] Input first row / output third column
%define %%r1 %2 ;; [in/out] Input second row / output second column
%define %%r2 %3 ;; [in/clobbered] Input third row
%define %%r3 %4 ;; [in/out] Input fourth row / output fourth column
%define %%t0 %5 ;; [out] Temporary XMM register / output first column
%define %%t1 %6 ;; [clobbered] Temporary XMM register
vshufps %%t0, %%r0, %%r1, 0x44 ; t0 = {b1 b0 a1 a0}
vshufps %%r0, %%r1, 0xEE ; r0 = {b3 b2 a3 a2}
vshufps %%t1, %%r2, %%r3, 0x44 ; t1 = {d1 d0 c1 c0}
vshufps %%r2, %%r3, 0xEE ; r2 = {d3 d2 c3 c2}
vshufps %%r1, %%t0, %%t1, 0xDD ; r1 = {d1 c1 b1 a1}
vshufps %%r3, %%r0, %%r2, 0xDD ; r3 = {d3 c3 b3 a3}
vshufps %%r0, %%r2, 0x88 ; r0 = {d2 c2 b2 a2}
vshufps %%t0, %%t1, 0x88 ; t0 = {d0 c0 b0 a0}
%endmacro
; Rotate dwords on a XMM registers to the left N_BITS
%macro VPROLD 3
%define %%XMM_IN %1 ; [in/out] XMM register to be rotated
%define %%N_BITS %2 ; [immediate] Number of bits to rotate
%define %%XTMP %3 ; [clobbered] XMM temporary register
%if %%N_BITS == 8
vpshufb %%XMM_IN, [rel shuf_mask_rotl8]
%elif %%N_BITS == 16
vpshufb %%XMM_IN, [rel shuf_mask_rotl16]
%else
vpsrld %%XTMP, %%XMM_IN, (32-%%N_BITS)
vpslld %%XMM_IN, %%N_BITS
vpor %%XMM_IN, %%XTMP
%endif
%endmacro
;;
;; Performs a quarter round on all 4 columns,
;; resulting in a full round
;;
%macro quarter_round 5
%define %%A %1 ;; [in/out] XMM register containing value A of all 4 columns
%define %%B %2 ;; [in/out] XMM register containing value B of all 4 columns
%define %%C %3 ;; [in/out] XMM register containing value C of all 4 columns
%define %%D %4 ;; [in/out] XMM register containing value D of all 4 columns
%define %%XTMP %5 ;; [clobbered] Temporary XMM register
vpaddd %%A, %%B
vpxor %%D, %%A
VPROLD %%D, 16, %%XTMP
vpaddd %%C, %%D
vpxor %%B, %%C
VPROLD %%B, 12, %%XTMP
vpaddd %%A, %%B
vpxor %%D, %%A
VPROLD %%D, 8, %%XTMP
vpaddd %%C, %%D
vpxor %%B, %%C
VPROLD %%B, 7, %%XTMP
%endmacro
%macro quarter_round_x2 9
%define %%A_L %1 ;; [in/out] XMM register containing value A of all 4 columns
%define %%B_L %2 ;; [in/out] XMM register containing value B of all 4 columns
%define %%C_L %3 ;; [in/out] XMM register containing value C of all 4 columns
%define %%D_L %4 ;; [in/out] XMM register containing value D of all 4 columns
%define %%A_H %5 ;; [in/out] XMM register containing value A of all 4 columns
%define %%B_H %6 ;; [in/out] XMM register containing value B of all 4 columns
%define %%C_H %7 ;; [in/out] XMM register containing value C of all 4 columns
%define %%D_H %8 ;; [in/out] XMM register containing value D of all 4 columns
%define %%XTMP %9 ;; [clobbered] Temporary XMM register
vpaddd %%A_L, %%B_L
vpaddd %%A_H, %%B_H
vpxor %%D_L, %%A_L
vpxor %%D_H, %%A_H
VPROLD %%D_L, 16, %%XTMP
VPROLD %%D_H, 16, %%XTMP
vpaddd %%C_L, %%D_L
vpaddd %%C_H, %%D_H
vpxor %%B_L, %%C_L
vpxor %%B_H, %%C_H
VPROLD %%B_L, 12, %%XTMP
VPROLD %%B_H, 12, %%XTMP
vpaddd %%A_L, %%B_L
vpaddd %%A_H, %%B_H
vpxor %%D_L, %%A_L
vpxor %%D_H, %%A_H
VPROLD %%D_L, 8, %%XTMP
VPROLD %%D_H, 8, %%XTMP
vpaddd %%C_L, %%D_L
vpaddd %%C_H, %%D_H
vpxor %%B_L, %%C_L
vpxor %%B_H, %%C_H
VPROLD %%B_L, 7, %%XTMP
VPROLD %%B_H, 7, %%XTMP
%endmacro
;;
;; Rotates the registers to prepare the data
;; from column round to diagonal round
;;
%macro column_to_diag 3
%define %%B %1 ;; [in/out] XMM register containing value B of all 4 columns
%define %%C %2 ;; [in/out] XMM register containing value C of all 4 columns
%define %%D %3 ;; [in/out] XMM register containing value D of all 4 columns
vpshufd %%B, %%B, 0x39 ; 0b00111001 ;; 0,3,2,1
vpshufd %%C, %%C, 0x4E ; 0b01001110 ;; 1,0,3,2
vpshufd %%D, %%D, 0x93 ; 0b10010011 ;; 2,1,0,3
%endmacro
;;
;; Rotates the registers to prepare the data
;; from diagonal round to column round
;;
%macro diag_to_column 3
%define %%B %1 ;; [in/out] XMM register containing value B of all 4 columns
%define %%C %2 ;; [in/out] XMM register containing value C of all 4 columns
%define %%D %3 ;; [in/out] XMM register containing value D of all 4 columns
vpshufd %%B, %%B, 0x93 ; 0b10010011 ; 2,1,0,3
vpshufd %%C, %%C, 0x4E ; 0b01001110 ; 1,0,3,2
vpshufd %%D, %%D, 0x39 ; 0b00111001 ; 0,3,2,1
%endmacro
;;
;; Generates 64 or 128 bytes of keystream
;; States IN A-C are the same for first 64 and last 64 bytes
;; State IN D differ because of the different block count
;;
%macro GENERATE_64_128_KS 9-14
%define %%STATE_IN_A %1 ;; [in] XMM containing state A
%define %%STATE_IN_B %2 ;; [in] XMM containing state B
%define %%STATE_IN_C %3 ;; [in] XMM containing state C
%define %%STATE_IN_D_L %4 ;; [in] XMM containing state D (low block count)
%define %%A_L_KS0 %5 ;; [out] XMM to contain keystream 0-15 bytes
%define %%B_L_KS1 %6 ;; [out] XMM to contain keystream 16-31 bytes
%define %%C_L_KS2 %7 ;; [out] XMM to contain keystream 32-47 bytes
%define %%D_L_KS3 %8 ;; [out] XMM to contain keystream 48-63 bytes
%define %%XTMP %9 ;; [clobbered] Temporary XMM register
%define %%STATE_IN_D_H %10 ;; [in] XMM containing state D (high block count)
%define %%A_H_KS4 %11 ;; [out] XMM to contain keystream 64-79 bytes
%define %%B_H_KS5 %12 ;; [out] XMM to contain keystream 80-95 bytes
%define %%C_H_KS6 %13 ;; [out] XMM to contain keystream 96-111 bytes
%define %%D_H_KS7 %14 ;; [out] XMM to contain keystream 112-127 bytes
vmovdqa %%A_L_KS0, %%STATE_IN_A
vmovdqa %%B_L_KS1, %%STATE_IN_B
vmovdqa %%C_L_KS2, %%STATE_IN_C
vmovdqa %%D_L_KS3, %%STATE_IN_D_L
%if %0 == 14
vmovdqa %%A_H_KS4, %%STATE_IN_A
vmovdqa %%B_H_KS5, %%STATE_IN_B
vmovdqa %%C_H_KS6, %%STATE_IN_C
vmovdqa %%D_H_KS7, %%STATE_IN_D_H
%endif
%rep 10
%if %0 == 14
quarter_round_x2 %%A_L_KS0, %%B_L_KS1, %%C_L_KS2, %%D_L_KS3, \
%%A_H_KS4, %%B_H_KS5, %%C_H_KS6, %%D_H_KS7, %%XTMP
column_to_diag %%B_L_KS1, %%C_L_KS2, %%D_L_KS3
column_to_diag %%B_H_KS5, %%C_H_KS6, %%D_H_KS7
quarter_round_x2 %%A_L_KS0, %%B_L_KS1, %%C_L_KS2, %%D_L_KS3, \
%%A_H_KS4, %%B_H_KS5, %%C_H_KS6, %%D_H_KS7, %%XTMP
diag_to_column %%B_L_KS1, %%C_L_KS2, %%D_L_KS3
diag_to_column %%B_H_KS5, %%C_H_KS6, %%D_H_KS7
%else
quarter_round %%A_L_KS0, %%B_L_KS1, %%C_L_KS2, %%D_L_KS3, %%XTMP
column_to_diag %%B_L_KS1, %%C_L_KS2, %%D_L_KS3
quarter_round %%A_L_KS0, %%B_L_KS1, %%C_L_KS2, %%D_L_KS3, %%XTMP
diag_to_column %%B_L_KS1, %%C_L_KS2, %%D_L_KS3
%endif
%endrep
vpaddd %%A_L_KS0, %%STATE_IN_A
vpaddd %%B_L_KS1, %%STATE_IN_B
vpaddd %%C_L_KS2, %%STATE_IN_C
vpaddd %%D_L_KS3, %%STATE_IN_D_L
%if %0 == 14
vpaddd %%A_H_KS4, %%STATE_IN_A
vpaddd %%B_H_KS5, %%STATE_IN_B
vpaddd %%C_H_KS6, %%STATE_IN_C
vpaddd %%D_H_KS7, %%STATE_IN_D_H
%endif
%endmacro
; Perform 4 times the operation in first parameter
%macro XMM_OP_X4 9
%define %%OP %1 ; [immediate] Instruction
%define %%DST_SRC1_1 %2 ; [in/out] First source/Destination 1
%define %%DST_SRC1_2 %3 ; [in/out] First source/Destination 2
%define %%DST_SRC1_3 %4 ; [in/out] First source/Destination 3
%define %%DST_SRC1_4 %5 ; [in/out] First source/Destination 4
%define %%SRC2_1 %6 ; [in] Second source 1
%define %%SRC2_2 %7 ; [in] Second source 2
%define %%SRC2_3 %8 ; [in] Second source 3
%define %%SRC2_4 %9 ; [in] Second source 4
%%OP %%DST_SRC1_1, %%SRC2_1
%%OP %%DST_SRC1_2, %%SRC2_2
%%OP %%DST_SRC1_3, %%SRC2_3
%%OP %%DST_SRC1_4, %%SRC2_4
%endmacro
%macro XMM_ROLS_X4 6
%define %%XMM_OP1_1 %1
%define %%XMM_OP1_2 %2
%define %%XMM_OP1_3 %3
%define %%XMM_OP1_4 %4
%define %%BITS_TO_ROTATE %5
%define %%XTMP %6
; Store temporary register when bits to rotate is not 8 and 16,
; as the register will be clobbered in these cases,
; containing needed information
%if %%BITS_TO_ROTATE != 8 && %%BITS_TO_ROTATE != 16
vmovdqa [rsp + _XMM_SAVE], %%XTMP
%endif
VPROLD %%XMM_OP1_1, %%BITS_TO_ROTATE, %%XTMP
VPROLD %%XMM_OP1_2, %%BITS_TO_ROTATE, %%XTMP
VPROLD %%XMM_OP1_3, %%BITS_TO_ROTATE, %%XTMP
VPROLD %%XMM_OP1_4, %%BITS_TO_ROTATE, %%XTMP
%if %%BITS_TO_ROTATE != 8 && %%BITS_TO_ROTATE != 16
vmovdqa %%XTMP, [rsp + _XMM_SAVE]
%endif
%endmacro
;;
;; Performs a full chacha20 round on 4 states,
;; consisting of 4 quarter rounds, which are done in parallel
;;
%macro CHACHA20_ROUND 16
%define %%XMM_DWORD_A1 %1 ;; [in/out] XMM register containing dword A for first quarter round
%define %%XMM_DWORD_A2 %2 ;; [in/out] XMM register containing dword A for second quarter round
%define %%XMM_DWORD_A3 %3 ;; [in/out] XMM register containing dword A for third quarter round
%define %%XMM_DWORD_A4 %4 ;; [in/out] XMM register containing dword A for fourth quarter round
%define %%XMM_DWORD_B1 %5 ;; [in/out] XMM register containing dword B for first quarter round
%define %%XMM_DWORD_B2 %6 ;; [in/out] XMM register containing dword B for second quarter round
%define %%XMM_DWORD_B3 %7 ;; [in/out] XMM register containing dword B for third quarter round
%define %%XMM_DWORD_B4 %8 ;; [in/out] XMM register containing dword B for fourth quarter round
%define %%XMM_DWORD_C1 %9 ;; [in/out] XMM register containing dword C for first quarter round
%define %%XMM_DWORD_C2 %10 ;; [in/out] XMM register containing dword C for second quarter round
%define %%XMM_DWORD_C3 %11 ;; [in/out] XMM register containing dword C for third quarter round
%define %%XMM_DWORD_C4 %12 ;; [in/out] XMM register containing dword C for fourth quarter round
%define %%XMM_DWORD_D1 %13 ;; [in/out] XMM register containing dword D for first quarter round
%define %%XMM_DWORD_D2 %14 ;; [in/out] XMM register containing dword D for second quarter round
%define %%XMM_DWORD_D3 %15 ;; [in/out] XMM register containing dword D for third quarter round
%define %%XMM_DWORD_D4 %16 ;; [in/out] XMM register containing dword D for fourth quarter round
; A += B
XMM_OP_X4 vpaddd, %%XMM_DWORD_A1, %%XMM_DWORD_A2, %%XMM_DWORD_A3, %%XMM_DWORD_A4, \
%%XMM_DWORD_B1, %%XMM_DWORD_B2, %%XMM_DWORD_B3, %%XMM_DWORD_B4
; D ^= A
XMM_OP_X4 vpxor, %%XMM_DWORD_D1, %%XMM_DWORD_D2, %%XMM_DWORD_D3, %%XMM_DWORD_D4, \
%%XMM_DWORD_A1, %%XMM_DWORD_A2, %%XMM_DWORD_A3, %%XMM_DWORD_A4
; D <<< 16
XMM_ROLS_X4 %%XMM_DWORD_D1, %%XMM_DWORD_D2, %%XMM_DWORD_D3, %%XMM_DWORD_D4, 16, \
%%XMM_DWORD_B1
; C += D
XMM_OP_X4 vpaddd, %%XMM_DWORD_C1, %%XMM_DWORD_C2, %%XMM_DWORD_C3, %%XMM_DWORD_C4, \
%%XMM_DWORD_D1, %%XMM_DWORD_D2, %%XMM_DWORD_D3, %%XMM_DWORD_D4
; B ^= C
XMM_OP_X4 vpxor, %%XMM_DWORD_B1, %%XMM_DWORD_B2, %%XMM_DWORD_B3, %%XMM_DWORD_B4, \
%%XMM_DWORD_C1, %%XMM_DWORD_C2, %%XMM_DWORD_C3, %%XMM_DWORD_C4
; B <<< 12
XMM_ROLS_X4 %%XMM_DWORD_B1, %%XMM_DWORD_B2, %%XMM_DWORD_B3, %%XMM_DWORD_B4, 12, \
%%XMM_DWORD_D1
; A += B
XMM_OP_X4 vpaddd, %%XMM_DWORD_A1, %%XMM_DWORD_A2, %%XMM_DWORD_A3, %%XMM_DWORD_A4, \
%%XMM_DWORD_B1, %%XMM_DWORD_B2, %%XMM_DWORD_B3, %%XMM_DWORD_B4
; D ^= A
XMM_OP_X4 vpxor, %%XMM_DWORD_D1, %%XMM_DWORD_D2, %%XMM_DWORD_D3, %%XMM_DWORD_D4, \
%%XMM_DWORD_A1, %%XMM_DWORD_A2, %%XMM_DWORD_A3, %%XMM_DWORD_A4
; D <<< 8
XMM_ROLS_X4 %%XMM_DWORD_D1, %%XMM_DWORD_D2, %%XMM_DWORD_D3, %%XMM_DWORD_D4, 8, \
%%XMM_DWORD_B1
; C += D
XMM_OP_X4 vpaddd, %%XMM_DWORD_C1, %%XMM_DWORD_C2, %%XMM_DWORD_C3, %%XMM_DWORD_C4, \
%%XMM_DWORD_D1, %%XMM_DWORD_D2, %%XMM_DWORD_D3, %%XMM_DWORD_D4
; B ^= C
XMM_OP_X4 vpxor, %%XMM_DWORD_B1, %%XMM_DWORD_B2, %%XMM_DWORD_B3, %%XMM_DWORD_B4, \
%%XMM_DWORD_C1, %%XMM_DWORD_C2, %%XMM_DWORD_C3, %%XMM_DWORD_C4
; B <<< 7
XMM_ROLS_X4 %%XMM_DWORD_B1, %%XMM_DWORD_B2, %%XMM_DWORD_B3, %%XMM_DWORD_B4, 7, \
%%XMM_DWORD_D1
%endmacro
;;
;; Encodes 4 Chacha20 states, outputting 256 bytes of keystream
;; Data still needs to be transposed to get the keystream in the correct order
;;
%macro GENERATE_256_KS 16
%define %%XMM_DWORD_0 %1 ;; [out] XMM register to contain encoded dword 0 of the 4 Chacha20 states
%define %%XMM_DWORD_1 %2 ;; [out] XMM register to contain encoded dword 1 of the 4 Chacha20 states
%define %%XMM_DWORD_2 %3 ;; [out] XMM register to contain encoded dword 2 of the 4 Chacha20 states
%define %%XMM_DWORD_3 %4 ;; [out] XMM register to contain encoded dword 3 of the 4 Chacha20 states
%define %%XMM_DWORD_4 %5 ;; [out] XMM register to contain encoded dword 4 of the 4 Chacha20 states
%define %%XMM_DWORD_5 %6 ;; [out] XMM register to contain encoded dword 5 of the 4 Chacha20 states
%define %%XMM_DWORD_6 %7 ;; [out] XMM register to contain encoded dword 6 of the 4 Chacha20 states
%define %%XMM_DWORD_7 %8 ;; [out] XMM register to contain encoded dword 7 of the 4 Chacha20 states
%define %%XMM_DWORD_8 %9 ;; [out] XMM register to contain encoded dword 8 of the 4 Chacha20 states
%define %%XMM_DWORD_9 %10 ;; [out] XMM register to contain encoded dword 9 of the 4 Chacha20 states
%define %%XMM_DWORD_10 %11 ;; [out] XMM register to contain encoded dword 10 of the 4 Chacha20 states
%define %%XMM_DWORD_11 %12 ;; [out] XMM register to contain encoded dword 11 of the 4 Chacha20 states
%define %%XMM_DWORD_12 %13 ;; [out] XMM register to contain encoded dword 12 of the 4 Chacha20 states
%define %%XMM_DWORD_13 %14 ;; [out] XMM register to contain encoded dword 13 of the 4 Chacha20 states
%define %%XMM_DWORD_14 %15 ;; [out] XMM register to contain encoded dword 14 of the 4 Chacha20 states
%define %%XMM_DWORD_15 %16 ;; [out] XMM register to contain encoded dword 15 of the 4 Chacha20 states
%assign i 0
%rep 16
vmovdqa APPEND(%%XMM_DWORD_, i), [rsp + _STATE + 16*i]
%assign i (i + 1)
%endrep
%rep 10
CHACHA20_ROUND %%XMM_DWORD_0, %%XMM_DWORD_1, %%XMM_DWORD_2, %%XMM_DWORD_3, \
%%XMM_DWORD_4, %%XMM_DWORD_5, %%XMM_DWORD_6, %%XMM_DWORD_7, \
%%XMM_DWORD_8, %%XMM_DWORD_9, %%XMM_DWORD_10, %%XMM_DWORD_11, \
%%XMM_DWORD_12, %%XMM_DWORD_13, %%XMM_DWORD_14, %%XMM_DWORD_15
CHACHA20_ROUND %%XMM_DWORD_0, %%XMM_DWORD_1, %%XMM_DWORD_2, %%XMM_DWORD_3, \
%%XMM_DWORD_5, %%XMM_DWORD_6, %%XMM_DWORD_7, %%XMM_DWORD_4, \
%%XMM_DWORD_10, %%XMM_DWORD_11, %%XMM_DWORD_8, %%XMM_DWORD_9, \
%%XMM_DWORD_15, %%XMM_DWORD_12, %%XMM_DWORD_13, %%XMM_DWORD_14
%endrep
%assign i 0
%rep 16
vpaddd APPEND(%%XMM_DWORD_, i), [rsp + _STATE + 16*i]
%assign i (i + 1)
%endrep
%endmacro
align 32
MKGLOBAL(submit_job_chacha20_enc_dec_avx,function,internal)
submit_job_chacha20_enc_dec_avx:
endbranch64
%define src r8
%define dst r9
%define len r10
%define iv r11
%define keys rdx
%define off rax
%define tmp iv
%define tmp2 keys
; Read pointers and length
mov len, [job + _msg_len_to_cipher_in_bytes]
; Check if there is nothing to encrypt
or len, len
jz exit
mov keys, [job + _enc_keys]
mov iv, [job + _iv]
mov src, [job + _src]
add src, [job + _cipher_start_src_offset_in_bytes]
mov dst, [job + _dst]
mov rax, rsp
sub rsp, STACK_SIZE
and rsp, -16
mov [rsp + _RSP_SAVE], rax ; save RSP
xor off, off
; If less than or equal to 64*2 bytes, prepare directly states for
; up to 2 blocks
cmp len, 64*2
jbe check_1_or_2_blocks_left
; Prepare first 4 chacha states
vmovdqa xmm0, [rel constants0]
vmovdqa xmm1, [rel constants1]
vmovdqa xmm2, [rel constants2]
vmovdqa xmm3, [rel constants3]
; Broadcast 8 dwords from key into XMM4-11
vmovdqu xmm12, [keys]
vmovdqu xmm15, [keys + 16]
vpshufd xmm4, xmm12, 0x0
vpshufd xmm5, xmm12, 0x55
vpshufd xmm6, xmm12, 0xAA
vpshufd xmm7, xmm12, 0xFF
vpshufd xmm8, xmm15, 0x0
vpshufd xmm9, xmm15, 0x55
vpshufd xmm10, xmm15, 0xAA
vpshufd xmm11, xmm15, 0xFF
; Broadcast 3 dwords from IV into XMM13-15
vmovd xmm13, [iv]
vmovd xmm14, [iv + 4]
vpshufd xmm13, xmm13, 0
vpshufd xmm14, xmm14, 0
vmovd xmm15, [iv + 8]
vpshufd xmm15, xmm15, 0
; Set block counters for first 4 Chacha20 states
vmovdqa xmm12, [rel dword_1_4]
%assign i 0
%rep 16
vmovdqa [rsp + _STATE + 16*i], xmm %+ i
%assign i (i + 1)
%endrep
cmp len, 64*4
jb exit_loop
align 32
start_loop:
; Generate 256 bytes of keystream
GENERATE_256_KS xmm0, xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7, \
xmm8, xmm9, xmm10, xmm11, xmm12, xmm13, xmm14, xmm15
;; Transpose state to get keystream and XOR with plaintext
;; to get ciphertext
; Save registers to be used as temp registers
vmovdqa [rsp + _XMM_SAVE], xmm14
vmovdqa [rsp + _XMM_SAVE + 16], xmm15
; Transpose to get 0-15, 64-79, 128-143, 192-207 bytes of KS
TRANSPOSE4_U32 xmm0, xmm1, xmm2, xmm3, xmm14, xmm15
; xmm14, xmm1, xmm0, xmm3
; xmm2, xmm15 free to use
vmovdqu xmm2, [src + off]
vmovdqu xmm15, [src + off + 16*4]
vpxor xmm14, xmm2
vpxor xmm1, xmm15
vmovdqu [dst + off], xmm14
vmovdqu [dst + off + 16*4], xmm1
vmovdqu xmm2, [src + off + 16*8]
vmovdqu xmm15, [src + off + 16*12]
vpxor xmm0, xmm2
vpxor xmm3, xmm15
vmovdqu [dst + off + 16*8], xmm0
vmovdqu [dst + off + 16*12], xmm3
; Restore registers and use xmm0, xmm1 now that they are free
vmovdqa xmm14, [rsp + _XMM_SAVE]
vmovdqa xmm15, [rsp + _XMM_SAVE + 16]
; Transpose to get 16-31, 80-95, 144-159, 208-223 bytes of KS
TRANSPOSE4_U32 xmm4, xmm5, xmm6, xmm7, xmm0, xmm1
; xmm0, xmm5, xmm4, xmm7
; xmm6, xmm1 free to use
vmovdqu xmm6, [src + off + 16]
vmovdqu xmm1, [src + off + 16*5]
vpxor xmm0, xmm6
vpxor xmm5, xmm1
vmovdqu [dst + off + 16], xmm0
vmovdqu [dst + off + 16*5], xmm5
vmovdqu xmm6, [src + off + 16*9]
vmovdqu xmm1, [src + off + 16*13]
vpxor xmm4, xmm6
vpxor xmm7, xmm1
vmovdqu [dst + off + 16*9], xmm4
vmovdqu [dst + off + 16*13], xmm7
; Transpose to get 32-47, 96-111, 160-175, 224-239 bytes of KS
TRANSPOSE4_U32 xmm8, xmm9, xmm10, xmm11, xmm0, xmm1
; xmm0, xmm9, xmm8, xmm11
; xmm10, xmm1 free to use
vmovdqu xmm10, [src + off + 16*2]
vmovdqu xmm1, [src + off + 16*6]
vpxor xmm0, xmm10
vpxor xmm9, xmm1
vmovdqu [dst + off + 16*2], xmm0
vmovdqu [dst + off + 16*6], xmm9
vmovdqu xmm10, [src + off + 16*10]
vmovdqu xmm1, [src + off + 16*14]
vpxor xmm8, xmm10
vpxor xmm11, xmm1
vmovdqu [dst + off + 16*10], xmm8
vmovdqu [dst + off + 16*14], xmm11
; Transpose to get 48-63, 112-127, 176-191, 240-255 bytes of KS
TRANSPOSE4_U32 xmm12, xmm13, xmm14, xmm15, xmm0, xmm1
; xmm0, xmm13, xmm12, xmm15
; xmm14, xmm1 free to use
vmovdqu xmm14, [src + off + 16*3]
vmovdqu xmm1, [src + off + 16*7]
vpxor xmm0, xmm14
vpxor xmm13, xmm1
vmovdqu [dst + off + 16*3], xmm0
vmovdqu [dst + off + 16*7], xmm13
vmovdqu xmm14, [src + off + 16*11]
vmovdqu xmm1, [src + off + 16*15]
vpxor xmm12, xmm14
vpxor xmm15, xmm1
vmovdqu [dst + off + 16*11], xmm12
vmovdqu [dst + off + 16*15], xmm15
; Update remaining length
sub len, 64*4
add off, 64*4
; Update counter values
vmovdqa xmm12, [rsp + 16*12]
vpaddd xmm12, [rel dword_4]
vmovdqa [rsp + 16*12], xmm12
cmp len, 64*4
jae start_loop
exit_loop:
; Check if there are no more bytes to encrypt
or len, len
jz no_partial_block
cmp len, 64*2
ja more_than_2_blocks_left
check_1_or_2_blocks_left:
cmp len, 64
ja two_blocks_left
;; 1 block left
; Get last block counter dividing offset by 64
shr off, 6
; Prepare next chacha state from IV, key
vmovdqu xmm1, [keys] ; Load key bytes 0-15
vmovdqu xmm2, [keys + 16] ; Load key bytes 16-31
; Read nonce (12 bytes)
vmovq xmm3, [iv]
vpinsrd xmm3, [iv + 8], 2
vpslldq xmm3, 4
vpinsrd xmm3, DWORD(off), 0
vmovdqa xmm0, [rel constants]
; Increase block counter
vpaddd xmm3, [rel dword_1]
shl off, 6 ; Restore offset
; Generate 64 bytes of keystream
GENERATE_64_128_KS xmm0, xmm1, xmm2, xmm3, xmm9, xmm10, xmm11, \
xmm12, xmm13
cmp len, 64
jne less_than_64
;; Exactly 64 bytes left
; Load plaintext, XOR with KS and store ciphertext
vmovdqu xmm14, [src + off]
vmovdqu xmm15, [src + off + 16]
vpxor xmm14, xmm9
vpxor xmm15, xmm10
vmovdqu [dst + off], xmm14
vmovdqu [dst + off + 16], xmm15
vmovdqu xmm14, [src + off + 16*2]
vmovdqu xmm15, [src + off + 16*3]
vpxor xmm14, xmm11
vpxor xmm15, xmm12
vmovdqu [dst + off + 16*2], xmm14
vmovdqu [dst + off + 16*3], xmm15
jmp no_partial_block
less_than_64:
cmp len, 48
jb less_than_48
; Load plaintext and XOR with keystream
vmovdqu xmm13, [src + off]
vmovdqu xmm14, [src + off + 16]
vmovdqu xmm15, [src + off + 32]
vpxor xmm13, xmm9
vpxor xmm14, xmm10
vpxor xmm15, xmm11
; Store resulting ciphertext
vmovdqu [dst + off], xmm13
vmovdqu [dst + off + 16], xmm14
vmovdqu [dst + off + 32], xmm15
; Store last KS in xmm9, for partial block
vmovdqu xmm9, xmm12
sub len, 48
add off, 48
jmp check_partial
less_than_48:
cmp len, 32
jb less_than_32
; Load plaintext and XOR with keystream
vmovdqu xmm13, [src + off]
vmovdqu xmm14, [src + off + 16]
vpxor xmm13, xmm9
vpxor xmm14, xmm10
; Store resulting ciphertext
vmovdqu [dst + off], xmm13
vmovdqu [dst + off + 16], xmm14
; Store last KS in xmm9, for partial block
vmovdqu xmm9, xmm11
sub len, 32
add off, 32
jmp check_partial
less_than_32:
cmp len, 16
jb check_partial
; Load plaintext and XOR with keystream
vmovdqu xmm13, [src + off]
vpxor xmm13, xmm9
; Store resulting ciphertext
vmovdqu [dst + off], xmm13
; Store last KS in xmm9, for partial block
vmovdqu xmm9, xmm10
sub len, 16
add off, 16
check_partial:
endbranch64
or len, len
jz no_partial_block
add src, off
add dst, off
; Load plaintext
simd_load_avx_15_1 xmm8, src, len
; XOR KS with plaintext and store resulting ciphertext
vpxor xmm8, xmm9
simd_store_avx_15 dst, xmm8, len, tmp, tmp2
jmp no_partial_block
two_blocks_left:
; Get last block counter dividing offset by 64
shr off, 6
; Prepare next 2 chacha states from IV, key
vmovdqu xmm1, [keys] ; Load key bytes 0-15
vmovdqu xmm2, [keys + 16] ; Load key bytes 16-31
; Read nonce (12 bytes)
vmovq xmm3, [iv]
vpinsrd xmm3, [iv + 8], 2
vpslldq xmm3, 4
vpinsrd xmm3, DWORD(off), 0
vmovdqa xmm0, [rel constants]
vmovdqa xmm8, xmm3
; Increase block counters
vpaddd xmm3, [rel dword_1]
vpaddd xmm8, [rel dword_2]
shl off, 6 ; Restore offset
; Generate 128 bytes of keystream
GENERATE_64_128_KS xmm0, xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7, \
xmm13, xmm8, xmm9, xmm10, xmm11, xmm12
cmp len, 128
jb between_64_127
; Load plaintext, XOR with KS and store ciphertext
vmovdqu xmm14, [src + off]
vmovdqu xmm15, [src + off + 16]
vpxor xmm14, xmm4
vpxor xmm15, xmm5
vmovdqu [dst + off], xmm14
vmovdqu [dst + off + 16], xmm15
vmovdqu xmm14, [src + off + 16*2]
vmovdqu xmm15, [src + off + 16*3]
vpxor xmm14, xmm6
vpxor xmm15, xmm7
vmovdqu [dst + off + 16*2], xmm14
vmovdqu [dst + off + 16*3], xmm15
vmovdqu xmm14, [src + off + 16*4]
vmovdqu xmm15, [src + off + 16*5]
vpxor xmm14, xmm9
vpxor xmm15, xmm10
vmovdqu [dst + off + 16*4], xmm14
vmovdqu [dst + off + 16*5], xmm15
vmovdqu xmm14, [src + off + 16*6]
vmovdqu xmm15, [src + off + 16*7]
vpxor xmm14, xmm11
vpxor xmm15, xmm12
vmovdqu [dst + off + 16*6], xmm14
vmovdqu [dst + off + 16*7], xmm15
jmp no_partial_block
between_64_127:
; Load plaintext, XOR with KS and store ciphertext for first 64 bytes
vmovdqu xmm14, [src + off]
vmovdqu xmm15, [src + off + 16]
vpxor xmm14, xmm4
vpxor xmm15, xmm5
vmovdqu [dst + off], xmm14
vmovdqu [dst + off + 16], xmm15
vmovdqu xmm14, [src + off + 16*2]
vmovdqu xmm15, [src + off + 16*3]
vpxor xmm14, xmm6
vpxor xmm15, xmm7
vmovdqu [dst + off + 16*2], xmm14
vmovdqu [dst + off + 16*3], xmm15
sub len, 64
add off, 64
; Handle rest up to 63 bytes in "less_than_64"
jmp less_than_64
more_than_2_blocks_left:
; Generate 256 bytes of keystream
GENERATE_256_KS xmm0, xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7, \
xmm8, xmm9, xmm10, xmm11, xmm12, xmm13, xmm14, xmm15
;; Transpose state to get keystream and XOR with plaintext
;; to get ciphertext
; Save registers to be used as temp registers
vmovdqa [rsp + _XMM_SAVE], xmm14
vmovdqa [rsp + _XMM_SAVE + 16], xmm15
; Transpose to get 0-15, 64-79, 128-143, 192-207 bytes of KS
TRANSPOSE4_U32 xmm0, xmm1, xmm2, xmm3, xmm14, xmm15
; xmm14, xmm1, xmm0, xmm3
vmovdqa xmm2, xmm0
vmovdqa xmm0, xmm14
; xmm0-3 containing [64*I : 64*I + 15] (I = 0-3) bytes of KS
; Restore registers and save xmm0,xmm1 and use them instead
vmovdqa xmm14, [rsp + _XMM_SAVE]
vmovdqa xmm15, [rsp + _XMM_SAVE + 16]
vmovdqa [rsp + _XMM_SAVE], xmm2
vmovdqa [rsp + _XMM_SAVE + 16], xmm3
; Transpose to get 16-31, 80-95, 144-159, 208-223 bytes of KS
TRANSPOSE4_U32 xmm4, xmm5, xmm6, xmm7, xmm2, xmm3
; xmm2, xmm5, xmm4, xmm7
vmovdqa xmm6, xmm4
vmovdqa xmm4, xmm2
; xmm4-7 containing [64*I + 16 : 64*I + 31] (I = 0-3) bytes of KS
; Transpose to get 32-47, 96-111, 160-175, 224-239 bytes of KS
TRANSPOSE4_U32 xmm8, xmm9, xmm10, xmm11, xmm2, xmm3
; xmm2, xmm9, xmm8, xmm11
vmovdqa xmm10, xmm8
vmovdqa xmm8, xmm2
; xmm8-11 containing [64*I + 32 : 64*I + 47] (I = 0-3) bytes of KS
; Transpose to get 48-63, 112-127, 176-191, 240-255 bytes of KS
TRANSPOSE4_U32 xmm12, xmm13, xmm14, xmm15, xmm2, xmm3
; xmm2, xmm13, xmm12, xmm15
vmovdqa xmm14, xmm12
vmovdqa xmm12, xmm2
; xmm12-15 containing [64*I + 48 : 64*I + 63] (I = 0-3) bytes of KS
; Encrypt first 128 bytes of plaintext (there are at least two 64 byte blocks to process)
vmovdqu xmm2, [src + off]
vmovdqu xmm3, [src + off + 16]
vpxor xmm0, xmm2
vpxor xmm4, xmm3
vmovdqu [dst + off], xmm0
vmovdqu [dst + off + 16], xmm4
vmovdqu xmm2, [src + off + 16*2]
vmovdqu xmm3, [src + off + 16*3]
vpxor xmm8, xmm2
vpxor xmm12, xmm3
vmovdqu [dst + off + 16*2], xmm8
vmovdqu [dst + off + 16*3], xmm12
vmovdqu xmm2, [src + off + 16*4]
vmovdqu xmm3, [src + off + 16*5]
vpxor xmm1, xmm2
vpxor xmm5, xmm3
vmovdqu [dst + off + 16*4], xmm1
vmovdqu [dst + off + 16*5], xmm5
vmovdqu xmm2, [src + off + 16*6]
vmovdqu xmm3, [src + off + 16*7]
vpxor xmm9, xmm2
vpxor xmm13, xmm3
vmovdqu [dst + off + 16*6], xmm9
vmovdqu [dst + off + 16*7], xmm13
; Restore xmm2,xmm3
vmovdqa xmm2, [rsp + _XMM_SAVE]
vmovdqa xmm3, [rsp + _XMM_SAVE + 16]
sub len, 128
add off, 128
; Use now xmm0,xmm1 as scratch registers
; Check if there is at least 64 bytes more to process
cmp len, 64
jb between_129_191
; Encrypt next 64 bytes (128-191)
vmovdqu xmm0, [src + off]
vmovdqu xmm1, [src + off + 16]
vpxor xmm2, xmm0
vpxor xmm6, xmm1
vmovdqu [dst + off], xmm2
vmovdqu [dst + off + 16], xmm6
vmovdqu xmm0, [src + off + 16*2]
vmovdqu xmm1, [src + off + 16*3]
vpxor xmm10, xmm0
vpxor xmm14, xmm1
vmovdqu [dst + off + 16*2], xmm10
vmovdqu [dst + off + 16*3], xmm14
add off, 64
sub len, 64
; Check if there are remaining bytes to process
or len, len
jz no_partial_block
; move last 64 bytes of KS to xmm9-12 (used in less_than_64)
vmovdqa xmm9, xmm3
vmovdqa xmm10, xmm7
; xmm11 is OK
vmovdqa xmm12, xmm15
jmp less_than_64
between_129_191:
; move bytes 128-191 of KS to xmm9-12 (used in less_than_64)
vmovdqa xmm9, xmm2
vmovdqa xmm11, xmm10
vmovdqa xmm10, xmm6
vmovdqa xmm12, xmm14
jmp less_than_64
no_partial_block:
endbranch64
%ifdef SAFE_DATA
clear_all_xmms_avx_asm
; Clear stack frame
%assign i 0
%rep 16
vmovdqa [rsp + _STATE + 16*i], xmm0
%assign i (i + 1)
%endrep
vmovdqa [rsp + _XMM_SAVE], xmm0
vmovdqa [rsp + _XMM_SAVE + 16], xmm0
%endif
mov rsp, [rsp + _RSP_SAVE]
exit:
mov rax, job
or dword [rax + _status], IMB_STATUS_COMPLETED_CIPHER
ret
align 32
MKGLOBAL(chacha20_enc_dec_ks_avx,function,internal)
chacha20_enc_dec_ks_avx:
endbranch64
%define blk_cnt r10
%define prev_ks r13
%define remain_ks r12
%define ctx r11
%define src arg1
%define dst arg2
%define len arg3
%define keys arg4
%define iv r15
%define off rax
%define tmp iv
%define tmp3 r14
%define tmp4 rbp
%define tmp5 rbx
%ifdef LINUX
%define tmp2 r9
%else
%define tmp2 rdi
%endif
mov ctx, arg5
mov rax, rsp
sub rsp, STACK_SIZE
and rsp, -16
mov [rsp + _GP_SAVE], r12
mov [rsp + _GP_SAVE + 8], r13
mov [rsp + _GP_SAVE + 16], r14
mov [rsp + _GP_SAVE + 24], r15
mov [rsp + _GP_SAVE + 32], rbx
mov [rsp + _GP_SAVE + 40], rbp
%ifndef LINUX
mov [rsp + _GP_SAVE + 48], rdi
%endif
mov [rsp + _RSP_SAVE], rax ; save RSP
; Check if there is nothing to encrypt
or len, len
jz exit_ks
xor off, off
mov blk_cnt, [ctx + LastBlkCount]
lea prev_ks, [ctx + LastKs]
mov remain_ks, [ctx + RemainKsBytes]
; Check if there are any remaining bytes of keystream
mov tmp3, remain_ks
or tmp3, tmp3
jz no_remain_ks_bytes
mov tmp4, 64
sub tmp4, tmp3
; Adjust pointer of previous KS to point at start of unused KS
add prev_ks, tmp4
; Set remaining bytes to length of input segment, if lower
cmp len, tmp3
cmovbe tmp3, len
mov tmp5, tmp3
; Read up to 63 bytes of KS and XOR the first bytes of message
; with the previous unused bytes of keystream
ENCRYPT_0B_64B src, dst, tmp3, off, xmm9, xmm10, xmm11, xmm12, \
xmm0, xmm1, xmm2, xmm3, tmp, tmp2, prev_ks
; Update remain bytes of KS
sub [ctx + RemainKsBytes], tmp5
; Restore pointer to previous KS
sub prev_ks, tmp4
sub len, tmp5
jz no_partial_block_ks
no_remain_ks_bytes:
; Reset remaining number of KS bytes
mov qword [ctx + RemainKsBytes], 0
lea iv, [ctx + IV]
; If less than or equal to 64*2 bytes, prepare directly states for
; up to 2 blocks
cmp len, 64*2
jbe check_1_or_2_blocks_left_ks
; Prepare first 4 chacha states
vmovdqa xmm0, [rel constants0]
vmovdqa xmm1, [rel constants1]
vmovdqa xmm2, [rel constants2]
vmovdqa xmm3, [rel constants3]
; Broadcast 8 dwords from key into XMM4-11
vmovdqu xmm12, [keys]
vmovdqu xmm15, [keys + 16]
vpshufd xmm4, xmm12, 0x0
vpshufd xmm5, xmm12, 0x55
vpshufd xmm6, xmm12, 0xAA
vpshufd xmm7, xmm12, 0xFF
vpshufd xmm8, xmm15, 0x0
vpshufd xmm9, xmm15, 0x55
vpshufd xmm10, xmm15, 0xAA
vpshufd xmm11, xmm15, 0xFF
; Broadcast 3 dwords from IV into XMM13-15
vmovd xmm13, [iv]
vmovd xmm14, [iv + 4]
vpshufd xmm13, xmm13, 0
vpshufd xmm14, xmm14, 0
vmovd xmm15, [iv + 8]
vpshufd xmm15, xmm15, 0
; Set block counters for next 4 Chacha20 states
vmovd xmm12, DWORD(blk_cnt)
vpshufd xmm12, xmm12, 0
vpaddd xmm12, [rel dword_1_4]
%assign i 0
%rep 16
vmovdqa [rsp + _STATE + 16*i], xmm %+ i
%assign i (i + 1)
%endrep
cmp len, 64*4
jb exit_loop_ks
align 32
start_loop_ks:
; Generate 256 bytes of keystream
GENERATE_256_KS xmm0, xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7, \
xmm8, xmm9, xmm10, xmm11, xmm12, xmm13, xmm14, xmm15
;; Transpose state to get keystream and XOR with plaintext
;; to get ciphertext
; Save registers to be used as temp registers
vmovdqa [rsp + _XMM_SAVE], xmm14
vmovdqa [rsp + _XMM_SAVE + 16], xmm15
; Transpose to get 16-31, 80-95, 144-159, 208-223 bytes of KS
TRANSPOSE4_U32 xmm0, xmm1, xmm2, xmm3, xmm14, xmm15
; xmm14, xmm1, xmm0, xmm3
; xmm2, xmm15 free to use
vmovdqu xmm2, [src + off]
vmovdqu xmm15, [src + off + 16*4]
vpxor xmm14, xmm2
vpxor xmm1, xmm15
vmovdqu [dst + off], xmm14
vmovdqu [dst + off + 16*4], xmm1
vmovdqu xmm2, [src + off + 16*8]
vmovdqu xmm15, [src + off + 16*12]
vpxor xmm0, xmm2
vpxor xmm3, xmm15
vmovdqu [dst + off + 16*8], xmm0
vmovdqu [dst + off + 16*12], xmm3
; Restore registers and use xmm0, xmm1 now that they are free
vmovdqa xmm14, [rsp + _XMM_SAVE]
vmovdqa xmm15, [rsp + _XMM_SAVE + 16]
; Transpose to get bytes 64-127 of KS
TRANSPOSE4_U32 xmm4, xmm5, xmm6, xmm7, xmm0, xmm1
; xmm0, xmm5, xmm4, xmm7
; xmm6, xmm1 free to use
vmovdqu xmm6, [src + off + 16]
vmovdqu xmm1, [src + off + 16*5]
vpxor xmm0, xmm6
vpxor xmm5, xmm1
vmovdqu [dst + off + 16], xmm0
vmovdqu [dst + off + 16*5], xmm5
vmovdqu xmm6, [src + off + 16*9]
vmovdqu xmm1, [src + off + 16*13]
vpxor xmm4, xmm6
vpxor xmm7, xmm1
vmovdqu [dst + off + 16*9], xmm4
vmovdqu [dst + off + 16*13], xmm7
; Transpose to get 32-47, 96-111, 160-175, 224-239 bytes of KS
TRANSPOSE4_U32 xmm8, xmm9, xmm10, xmm11, xmm0, xmm1
; xmm0, xmm9, xmm8, xmm11
; xmm10, xmm1 free to use
vmovdqu xmm10, [src + off + 16*2]
vmovdqu xmm1, [src + off + 16*6]
vpxor xmm0, xmm10
vpxor xmm9, xmm1
vmovdqu [dst + off + 16*2], xmm0
vmovdqu [dst + off + 16*6], xmm9
vmovdqu xmm10, [src + off + 16*10]
vmovdqu xmm1, [src + off + 16*14]
vpxor xmm8, xmm10
vpxor xmm11, xmm1
vmovdqu [dst + off + 16*10], xmm8
vmovdqu [dst + off + 16*14], xmm11
; Transpose to get 48-63, 112-127, 176-191, 240-255 bytes of KS
TRANSPOSE4_U32 xmm12, xmm13, xmm14, xmm15, xmm0, xmm1
; xmm0, xmm13, xmm12, xmm15
; xmm14, xmm1 free to use
vmovdqu xmm14, [src + off + 16*3]
vmovdqu xmm1, [src + off + 16*7]
vpxor xmm0, xmm14
vpxor xmm13, xmm1
vmovdqu [dst + off + 16*3], xmm0
vmovdqu [dst + off + 16*7], xmm13
vmovdqu xmm14, [src + off + 16*11]
vmovdqu xmm1, [src + off + 16*15]
vpxor xmm12, xmm14
vpxor xmm15, xmm1
vmovdqu [dst + off + 16*11], xmm12
vmovdqu [dst + off + 16*15], xmm15
; Update remaining length
sub len, 64*4
add off, 64*4
add blk_cnt, 4
; Update counter values
vmovdqa xmm12, [rsp + _STATE + 16*12]
vpaddd xmm12, [rel dword_4]
vmovdqa [rsp + _STATE + 16*12], xmm12
cmp len, 64*4
jae start_loop_ks
exit_loop_ks:
; Check if there are no more bytes to encrypt
or len, len
jz no_partial_block_ks
cmp len, 64*2
ja more_than_2_blocks_left_ks
check_1_or_2_blocks_left_ks:
cmp len, 64
ja two_blocks_left_ks
;; 1 block left
; Prepare next chacha state from IV, key
vmovdqu xmm1, [keys] ; Load key bytes 0-15
vmovdqu xmm2, [keys + 16] ; Load key bytes 16-31
; Read nonce (12 bytes)
vmovq xmm3, [iv]
vpinsrd xmm3, [iv + 8], 2
vpslldq xmm3, 4
vpinsrd xmm3, DWORD(blk_cnt), 0
vmovdqa xmm0, [rel constants]
; Increase block counter
vpaddd xmm3, [rel dword_1]
; Generate 64 bytes of keystream
GENERATE_64_128_KS xmm0, xmm1, xmm2, xmm3, xmm9, xmm10, xmm11, \
xmm12, xmm13
cmp len, 64
jne less_than_64_ks
;; Exactly 64 bytes left
; Load plaintext, XOR with KS and store ciphertext
vmovdqu xmm14, [src + off]
vmovdqu xmm15, [src + off + 16]
vpxor xmm14, xmm9
vpxor xmm15, xmm10
vmovdqu [dst + off], xmm14
vmovdqu [dst + off + 16], xmm15
vmovdqu xmm14, [src + off + 16*2]
vmovdqu xmm15, [src + off + 16*3]
vpxor xmm14, xmm11
vpxor xmm15, xmm12
vmovdqu [dst + off + 16*2], xmm14
vmovdqu [dst + off + 16*3], xmm15
inc blk_cnt
jmp no_partial_block_ks
less_than_64_ks:
endbranch64
; Preserve len
mov tmp5, len
ENCRYPT_0B_64B src, dst, len, off, xmm9, xmm10, xmm11, xmm12, \
xmm0, xmm1, xmm2, xmm3, src, off
inc blk_cnt
; Save last 64-byte block of keystream,
; in case it is needed in next segments
vmovdqu [prev_ks], xmm9
vmovdqu [prev_ks + 16], xmm10
vmovdqu [prev_ks + 32], xmm11
vmovdqu [prev_ks + 48], xmm12
; Update remain number of KS bytes
mov tmp, 64
sub tmp, tmp5
mov [ctx + RemainKsBytes], tmp
jmp no_partial_block_ks
two_blocks_left_ks:
; Prepare next 2 chacha states from IV, key
vmovdqu xmm1, [keys] ; Load key bytes 0-15
vmovdqu xmm2, [keys + 16] ; Load key bytes 16-31
; Read nonce (12 bytes)
vmovq xmm3, [iv]
vpinsrd xmm3, [iv + 8], 2
vpslldq xmm3, 4
vpinsrd xmm3, DWORD(blk_cnt), 0
vmovdqa xmm0, [rel constants]
vmovdqa xmm8, xmm3
; Increase block counters
vpaddd xmm3, [rel dword_1]
vpaddd xmm8, [rel dword_2]
; Generate 128 bytes of keystream
GENERATE_64_128_KS xmm0, xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7, \
xmm13, xmm8, xmm9, xmm10, xmm11, xmm12
cmp len, 128
jb between_64_127_ks
; Load plaintext, XOR with KS and store ciphertext
vmovdqu xmm14, [src + off]
vmovdqu xmm15, [src + off + 16]
vpxor xmm14, xmm4
vpxor xmm15, xmm5
vmovdqu [dst + off], xmm14
vmovdqu [dst + off + 16], xmm15
vmovdqu xmm14, [src + off + 16*2]
vmovdqu xmm15, [src + off + 16*3]
vpxor xmm14, xmm6
vpxor xmm15, xmm7
vmovdqu [dst + off + 16*2], xmm14
vmovdqu [dst + off + 16*3], xmm15
vmovdqu xmm14, [src + off + 16*4]
vmovdqu xmm15, [src + off + 16*5]
vpxor xmm14, xmm9
vpxor xmm15, xmm10
vmovdqu [dst + off + 16*4], xmm14
vmovdqu [dst + off + 16*5], xmm15
vmovdqu xmm14, [src + off + 16*6]
vmovdqu xmm15, [src + off + 16*7]
vpxor xmm14, xmm11
vpxor xmm15, xmm12
vmovdqu [dst + off + 16*6], xmm14
vmovdqu [dst + off + 16*7], xmm15
add blk_cnt, 2
jmp no_partial_block_ks
between_64_127_ks:
; Load plaintext, XOR with KS and store ciphertext for first 64 bytes
vmovdqu xmm14, [src + off]
vmovdqu xmm15, [src + off + 16]
vpxor xmm14, xmm4
vpxor xmm15, xmm5
vmovdqu [dst + off], xmm14
vmovdqu [dst + off + 16], xmm15
vmovdqu xmm14, [src + off + 16*2]
vmovdqu xmm15, [src + off + 16*3]
vpxor xmm14, xmm6
vpxor xmm15, xmm7
vmovdqu [dst + off + 16*2], xmm14
vmovdqu [dst + off + 16*3], xmm15
sub len, 64
add off, 64
add blk_cnt, 1
; Handle rest up to 63 bytes in "less_than_64"
jmp less_than_64_ks
more_than_2_blocks_left_ks:
; Generate 256 bytes of keystream
GENERATE_256_KS xmm0, xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7, \
xmm8, xmm9, xmm10, xmm11, xmm12, xmm13, xmm14, xmm15
;; Transpose state to get keystream and XOR with plaintext
;; to get ciphertext
; Save registers to be used as temp registers
vmovdqa [rsp + _XMM_SAVE], xmm14
vmovdqa [rsp + _XMM_SAVE + 16], xmm15
; Transpose to get 0-15, 64-79, 128-143, 192-207 bytes of KS
TRANSPOSE4_U32 xmm0, xmm1, xmm2, xmm3, xmm14, xmm15
; xmm14, xmm1, xmm0, xmm3
vmovdqa xmm2, xmm0
vmovdqa xmm0, xmm14
; xmm0-3 containing [64*I : 64*I + 15] (I = 0-3) bytes of KS
; Restore registers and save xmm0,xmm1 and use them instead
vmovdqa xmm14, [rsp + _XMM_SAVE]
vmovdqa xmm15, [rsp + _XMM_SAVE + 16]
vmovdqa [rsp + _XMM_SAVE], xmm2
vmovdqa [rsp + _XMM_SAVE + 16], xmm3
; Transpose to get 16-31, 80-95, 144-159, 208-223 bytes of KS
TRANSPOSE4_U32 xmm4, xmm5, xmm6, xmm7, xmm2, xmm3
; xmm2, xmm5, xmm4, xmm7
vmovdqa xmm6, xmm4
vmovdqa xmm4, xmm2
; xmm4-7 containing [64*I + 16 : 64*I + 31] (I = 0-3) bytes of KS
; Transpose to get 32-47, 96-111, 160-175, 224-239 bytes of KS
TRANSPOSE4_U32 xmm8, xmm9, xmm10, xmm11, xmm2, xmm3
; xmm2, xmm9, xmm8, xmm11
vmovdqa xmm10, xmm8
vmovdqa xmm8, xmm2
; xmm8-11 containing [64*I + 32 : 64*I + 47] (I = 0-3) bytes of KS
; Transpose to get 48-63, 112-127, 176-191, 240-255 bytes of KS
TRANSPOSE4_U32 xmm12, xmm13, xmm14, xmm15, xmm2, xmm3
; xmm2, xmm13, xmm12, xmm15
vmovdqa xmm14, xmm12
vmovdqa xmm12, xmm2
; xmm12-15 containing [64*I + 48 : 64*I + 63] (I = 0-3) bytes of KS
; Encrypt first 128 bytes of plaintext (there are at least two 64 byte blocks to process)
vmovdqu xmm2, [src + off]
vmovdqu xmm3, [src + off + 16]
vpxor xmm0, xmm2
vpxor xmm4, xmm3
vmovdqu [dst + off], xmm0
vmovdqu [dst + off + 16], xmm4
vmovdqu xmm2, [src + off + 16*2]
vmovdqu xmm3, [src + off + 16*3]
vpxor xmm8, xmm2
vpxor xmm12, xmm3
vmovdqu [dst + off + 16*2], xmm8
vmovdqu [dst + off + 16*3], xmm12
vmovdqu xmm2, [src + off + 16*4]
vmovdqu xmm3, [src + off + 16*5]
vpxor xmm1, xmm2
vpxor xmm5, xmm3
vmovdqu [dst + off + 16*4], xmm1
vmovdqu [dst + off + 16*5], xmm5
vmovdqu xmm2, [src + off + 16*6]
vmovdqu xmm3, [src + off + 16*7]
vpxor xmm9, xmm2
vpxor xmm13, xmm3
vmovdqu [dst + off + 16*6], xmm9
vmovdqu [dst + off + 16*7], xmm13
; Restore xmm2,xmm3
vmovdqa xmm2, [rsp + _XMM_SAVE]
vmovdqa xmm3, [rsp + _XMM_SAVE + 16]
sub len, 128
add off, 128
add blk_cnt, 2
; Use now xmm0,xmm1 as scratch registers
; Check if there is at least 64 bytes more to process
cmp len, 64
jb between_129_191_ks
; Encrypt next 64 bytes (128-191)
vmovdqu xmm0, [src + off]
vmovdqu xmm1, [src + off + 16]
vpxor xmm2, xmm0
vpxor xmm6, xmm1
vmovdqu [dst + off], xmm2
vmovdqu [dst + off + 16], xmm6
vmovdqu xmm0, [src + off + 16*2]
vmovdqu xmm1, [src + off + 16*3]
vpxor xmm10, xmm0
vpxor xmm14, xmm1
vmovdqu [dst + off + 16*2], xmm10
vmovdqu [dst + off + 16*3], xmm14
add off, 64
sub len, 64
add blk_cnt, 1
; Check if there are remaining bytes to process
or len, len
jz no_partial_block_ks
; move last 64 bytes of KS to xmm9-12 (used in less_than_64)
vmovdqa xmm9, xmm3
vmovdqa xmm10, xmm7
; xmm11 is OK
vmovdqa xmm12, xmm15
jmp less_than_64_ks
between_129_191_ks:
; move bytes 128-191 of KS to xmm9-12 (used in less_than_64)
vmovdqa xmm9, xmm2
vmovdqa xmm11, xmm10
vmovdqa xmm10, xmm6
vmovdqa xmm12, xmm14
jmp less_than_64_ks
no_partial_block_ks:
endbranch64
mov [ctx + LastBlkCount], blk_cnt
%ifdef SAFE_DATA
clear_all_xmms_avx_asm
; Clear stack frame
%assign i 0
%rep 16
vmovdqa [rsp + _STATE + 16*i], xmm0
%assign i (i + 1)
%endrep
vmovdqa [rsp + _XMM_SAVE], xmm0
vmovdqa [rsp + _XMM_SAVE + 16], xmm0
%endif
exit_ks:
mov r12, [rsp + _GP_SAVE]
mov r13, [rsp + _GP_SAVE + 8]
mov r14, [rsp + _GP_SAVE + 16]
mov r15, [rsp + _GP_SAVE + 24]
mov rbx, [rsp + _GP_SAVE + 32]
mov rbp, [rsp + _GP_SAVE + 40]
%ifndef LINUX
mov rdi, [rsp + _GP_SAVE + 48]
%endif
mov rsp, [rsp + _RSP_SAVE]; restore RSP
ret
;;
;; void poly1305_key_gen_avx(const void *key, const void *iv, void *poly_key)
align 32
MKGLOBAL(poly1305_key_gen_avx,function,internal)
poly1305_key_gen_avx:
endbranch64
;; prepare chacha state from IV, key
vmovdqa xmm0, [rel constants]
vmovdqu xmm1, [arg1] ; Load key bytes 0-15
vmovdqu xmm2, [arg1 + 16] ; Load key bytes 16-31
;; copy nonce (12 bytes)
vmovq xmm3, [arg2]
vpinsrd xmm3, [arg2 + 8], 2
vpslldq xmm3, 4
;; run one round of chacha20
GENERATE_64_128_KS xmm0, xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7, xmm8
;; clamp R and store poly1305 key
;; R = KEY[0..15] & 0xffffffc0ffffffc0ffffffc0fffffff
vpand xmm4, [rel poly_clamp_r]
vmovdqu [arg3 + 0 * 16], xmm4
vmovdqu [arg3 + 1 * 16], xmm5
%ifdef SAFE_DATA
clear_all_xmms_avx_asm
%endif
ret
%ifdef LINUX
section .note.GNU-stack noalloc noexec nowrite progbits
%endif
|
; A121925: a(n) = floor(n*(Pi^e + e^Pi)).
; 0,45,91,136,182,227,273,319,364,410,455,501,547,592,638,683,729,775,820,866,911,957,1003,1048,1094,1139,1185,1231,1276,1322,1367,1413,1459,1504,1550,1595,1641,1687,1732,1778,1823,1869,1915,1960,2006,2051,2097,2143,2188,2234,2279,2325,2371,2416,2462,2507,2553,2599,2644,2690,2735,2781,2827,2872,2918,2963,3009,3055,3100,3146,3191,3237,3283,3328,3374,3419,3465,3511,3556,3602,3647,3693,3739,3784,3830,3875,3921,3967,4012,4058,4103,4149,4195,4240,4286,4331,4377,4423,4468,4514
mov $1,$0
mul $0,3
sub $0,1
div $0,5
mov $2,$1
mul $2,45
add $0,$2
|
<%
import collections
import pwnlib.abi
import pwnlib.constants
import pwnlib.shellcraft
import six
%>
<%docstring>unlink(name) -> str
Invokes the syscall unlink.
See 'man 2 unlink' for more information.
Arguments:
name(char*): name
Returns:
int
</%docstring>
<%page args="name=0"/>
<%
abi = pwnlib.abi.ABI.syscall()
stack = abi.stack
regs = abi.register_arguments[1:]
allregs = pwnlib.shellcraft.registers.current()
can_pushstr = ['name']
can_pushstr_array = []
argument_names = ['name']
argument_values = [name]
# 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, (six.binary_type, six.text_type)):
if isinstance(arg, six.text_type):
arg = arg.encode('utf-8')
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_unlink']:
if hasattr(pwnlib.constants, syscall):
break
else:
raise Exception("Could not locate any syscalls: %r" % syscalls)
%>
/* unlink(${', '.join(syscall_repr)}) */
%for name, arg in string_arguments.items():
${pwnlib.shellcraft.pushstr(arg, append_null=(b'\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)} |
#pragma once
#include "Object.hpp"
#include <set>
namespace alisp
{
struct SharedValueObjectBase : Object
{
std::set<SharedValueObjectBase*>* markedForCycleDeletion = nullptr;
void tryDestroySharedData(); // Derived classes must call this from destructor.
virtual const void* sharedDataPointer() const = 0;
virtual size_t sharedDataRefCount() const = 0;
virtual void reset() = 0;
};
template<typename T>
struct SharedValueObject : SharedValueObjectBase,
ConvertibleTo<T>,
ConvertibleTo<T&>,
ConvertibleTo<const T&>
{
std::shared_ptr<T> value;
SharedValueObject(std::shared_ptr<T> value) : value(value) {}
~SharedValueObject() { tryDestroySharedData(); }
const void* sharedDataPointer() const override { return value.get(); }
size_t sharedDataRefCount() const override { return value.use_count(); };
void reset() override { value.reset(); }
bool eq(const Object& o) const override
{
const SharedValueObject* op = dynamic_cast<const SharedValueObject*>(&o);
if (!op) {
return false;
}
return value == op->value;
}
T convertTo(typename ConvertibleTo<T>::Tag) const override { return *value; }
T& convertTo(typename ConvertibleTo<T&>::Tag) const override { return *value; }
const T& convertTo(typename ConvertibleTo<const T&>::Tag) const override { return *value; }
};
}
|
; A037959: (n+2)!*n^2*(n+1)/48.
; Submitted by Jon Maiga
; 6,90,1200,15750,211680,2963520,43545600,673596000,10977120000,188367379200,3399953356800,64457449056000,1281520880640000,26676557107200000,580481882652672000,13183287756807168000
add $0,1
mov $1,$0
seq $0,200978 ; Number of ways to arrange n books on 3 consecutive shelves leaving none of the shelves empty.
add $1,1
mul $1,$0
mov $0,$1
div $0,144
mul $0,6
|
.global s_prepare_buffers
s_prepare_buffers:
push %r11
push %r14
push %r8
push %rbx
push %rcx
push %rdi
push %rdx
push %rsi
lea addresses_normal_ht+0x166bc, %r8
nop
nop
cmp $52234, %r14
and $0xffffffffffffffc0, %r8
vmovaps (%r8), %ymm0
vextracti128 $1, %ymm0, %xmm0
vpextrq $0, %xmm0, %rbx
nop
cmp %r14, %r14
lea addresses_UC_ht+0xebc, %r11
nop
nop
nop
nop
nop
add %rcx, %rcx
movb $0x61, (%r11)
nop
nop
nop
nop
cmp %r14, %r14
lea addresses_UC_ht+0x89bc, %rsi
lea addresses_normal_ht+0x57bc, %rdi
nop
nop
nop
nop
and $39095, %rdx
mov $66, %rcx
rep movsb
nop
nop
nop
nop
nop
sub %rsi, %rsi
lea addresses_UC_ht+0x7fbc, %rcx
nop
nop
xor $4154, %rdx
mov $0x6162636465666768, %r14
movq %r14, %xmm1
movups %xmm1, (%rcx)
dec %r11
lea addresses_WT_ht+0x197cc, %r14
clflush (%r14)
nop
nop
nop
nop
add $765, %rbx
movl $0x61626364, (%r14)
nop
nop
nop
xor %r14, %r14
lea addresses_D_ht+0x1a6bc, %r14
clflush (%r14)
sub $43156, %rcx
mov $0x6162636465666768, %rbx
movq %rbx, %xmm7
movups %xmm7, (%r14)
nop
nop
nop
nop
nop
add %r8, %r8
lea addresses_D_ht+0x1b856, %rdx
nop
nop
nop
nop
and %rdi, %rdi
mov $0x6162636465666768, %rsi
movq %rsi, (%rdx)
nop
nop
and %r11, %r11
lea addresses_A_ht+0x103c, %rsi
lea addresses_normal_ht+0x115ba, %rdi
clflush (%rdi)
nop
xor $12629, %r11
mov $101, %rcx
rep movsl
nop
nop
and %rdi, %rdi
lea addresses_A_ht+0x213c, %rsi
lea addresses_WT_ht+0x943c, %rdi
cmp $27552, %rdx
mov $85, %rcx
rep movsl
nop
nop
nop
nop
dec %r8
lea addresses_WT_ht+0x4abc, %r8
cmp %rdi, %rdi
movb $0x61, (%r8)
nop
nop
nop
sub %r11, %r11
lea addresses_WC_ht+0x53ba, %r11
nop
nop
nop
nop
nop
sub $36968, %r14
movw $0x6162, (%r11)
nop
nop
nop
nop
nop
cmp $27018, %r11
lea addresses_WC_ht+0x636c, %rsi
lea addresses_WT_ht+0x31c, %rdi
nop
nop
nop
and $45981, %r11
mov $57, %rcx
rep movsw
nop
nop
nop
nop
cmp $22026, %r14
pop %rsi
pop %rdx
pop %rdi
pop %rcx
pop %rbx
pop %r8
pop %r14
pop %r11
ret
.global s_faulty_load
s_faulty_load:
push %r12
push %r14
push %r15
push %r8
push %r9
push %rbx
push %rdi
// Store
lea addresses_UC+0x1e43c, %r14
clflush (%r14)
nop
nop
and $22702, %r8
mov $0x5152535455565758, %rdi
movq %rdi, %xmm1
vmovups %ymm1, (%r14)
cmp $50489, %r14
// Store
lea addresses_RW+0xdefc, %rbx
nop
nop
nop
cmp $61517, %r9
movb $0x51, (%rbx)
nop
nop
nop
nop
add %rdi, %rdi
// Store
lea addresses_D+0x192cc, %r8
nop
cmp %r15, %r15
mov $0x5152535455565758, %rdi
movq %rdi, %xmm6
vmovups %ymm6, (%r8)
add %r15, %r15
// Store
lea addresses_RW+0x6bc, %r14
nop
nop
sub %rdi, %rdi
mov $0x5152535455565758, %r15
movq %r15, %xmm2
vmovups %ymm2, (%r14)
nop
cmp %r14, %r14
// Store
lea addresses_PSE+0x6ebc, %rbx
nop
nop
nop
nop
nop
add $31374, %r15
mov $0x5152535455565758, %r8
movq %r8, (%rbx)
nop
nop
nop
nop
nop
sub %rdi, %rdi
// Faulty Load
lea addresses_RW+0x6bc, %rbx
clflush (%rbx)
nop
nop
nop
nop
nop
xor %r12, %r12
movb (%rbx), %r15b
lea oracles, %r8
and $0xff, %r15
shlq $12, %r15
mov (%r8,%r15,1), %r15
pop %rdi
pop %rbx
pop %r9
pop %r8
pop %r15
pop %r14
pop %r12
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'type': 'addresses_RW', 'size': 2, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_UC', 'size': 32, 'AVXalign': False, 'NT': False, 'congruent': 4, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_RW', 'size': 1, 'AVXalign': False, 'NT': False, 'congruent': 4, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_D', 'size': 32, 'AVXalign': False, 'NT': False, 'congruent': 1, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_RW', 'size': 32, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': True}}
{'OP': 'STOR', 'dst': {'type': 'addresses_PSE', 'size': 8, 'AVXalign': False, 'NT': False, 'congruent': 10, 'same': False}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'type': 'addresses_RW', 'size': 1, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': True}}
<gen_prepare_buffer>
{'OP': 'LOAD', 'src': {'type': 'addresses_normal_ht', 'size': 32, 'AVXalign': True, 'NT': False, 'congruent': 11, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_UC_ht', 'size': 1, 'AVXalign': False, 'NT': False, 'congruent': 11, 'same': True}}
{'OP': 'REPM', 'src': {'type': 'addresses_UC_ht', 'congruent': 8, 'same': True}, 'dst': {'type': 'addresses_normal_ht', 'congruent': 4, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_UC_ht', 'size': 16, 'AVXalign': False, 'NT': False, 'congruent': 7, 'same': True}}
{'OP': 'STOR', 'dst': {'type': 'addresses_WT_ht', 'size': 4, 'AVXalign': False, 'NT': False, 'congruent': 3, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_D_ht', 'size': 16, 'AVXalign': False, 'NT': False, 'congruent': 11, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_D_ht', 'size': 8, 'AVXalign': False, 'NT': False, 'congruent': 1, 'same': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_A_ht', 'congruent': 7, 'same': False}, 'dst': {'type': 'addresses_normal_ht', 'congruent': 0, 'same': True}}
{'OP': 'REPM', 'src': {'type': 'addresses_A_ht', 'congruent': 5, 'same': False}, 'dst': {'type': 'addresses_WT_ht', 'congruent': 7, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_WT_ht', 'size': 1, 'AVXalign': False, 'NT': False, 'congruent': 6, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_WC_ht', 'size': 2, 'AVXalign': False, 'NT': False, 'congruent': 1, 'same': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_WC_ht', 'congruent': 4, 'same': False}, 'dst': {'type': 'addresses_WT_ht', 'congruent': 3, 'same': False}}
{'58': 1089}
58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58
*/
|
; A307832: Number of palindromic decagonal (10-gonal) numbers of length n whose index is also palindromic.
; 2,0,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0
mov $1,2
mov $2,$0
mov $4,1
lpb $2,1
add $2,3
sub $2,$4
add $3,4
lpb $4,1
mov $1,0
trn $2,3
trn $4,$3
lpe
mov $3,$1
add $1,$2
trn $2,1
add $4,5
lpe
|
; A231601: Number of permutations of [n] avoiding ascents from odd to even numbers.
; 1,1,1,4,8,54,162,1536,6144,75000,375000,5598720,33592320,592950960,4150656720,84557168640,676457349120,15620794116480,140587147048320,3628800000000000,36288000000000000
mov $2,$0
mov $3,$0
add $3,$0
div $0,2
div $3,4
mov $4,$2
sub $4,$3
mov $1,$4
pow $1,$0
fac $4
mul $1,$4
|
proc InputOnChar, char:WORD
cmp cl, 0 ; NULL (0x00) = Backspace character
je .done
cmp cl, 8 ; BS (0x08) = Backspace character
je .backspace
cmp cl, 10 ; LF (0x0A) = Line feed character
je .linefeed
cmp cl, 13 ; CR (0x0D) = Carriage return
je .linefeed
fastcall InputBufferAddChar, cl
ret
.backspace:
fastcall InputBufferRemoveChar
ret
.linefeed: ; enter key
fastcall ConsoleInputHandle, _gr_input_buffer
ret
.done:
ret
endp |
###############################################################################
# Copyright 2018 Intel Corporation
# All Rights Reserved.
#
# If this software was obtained under the Intel Simplified Software License,
# the following terms apply:
#
# The source code, information and material ("Material") contained herein is
# owned by Intel Corporation or its suppliers or licensors, and title to such
# Material remains with Intel Corporation or its suppliers or licensors. The
# Material contains proprietary information of Intel or its suppliers and
# licensors. The Material is protected by worldwide copyright laws and treaty
# provisions. No part of the Material may be used, copied, reproduced,
# modified, published, uploaded, posted, transmitted, distributed or disclosed
# in any way without Intel's prior express written permission. No license under
# any patent, copyright or other intellectual property rights in the Material
# is granted to or conferred upon you, either expressly, by implication,
# inducement, estoppel or otherwise. Any license under such intellectual
# property rights must be express and approved by Intel in writing.
#
# Unless otherwise agreed by Intel in writing, you may not remove or alter this
# notice or any other notice embedded in Materials by Intel or Intel's
# suppliers or licensors in any way.
#
#
# If this software was obtained under the Apache License, Version 2.0 (the
# "License"), the following terms apply:
#
# 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.
###############################################################################
.text
.p2align 6, 0x90
.globl _cpMontMul1024_avx2
_cpMontMul1024_avx2:
push %rbx
push %rbp
push %r12
push %r13
push %r14
sub $(32), %rsp
mov %rdx, %rbp
movslq %r8d, %r8
vzeroall
vmovdqu %ymm0, (%rsi,%r8,8)
vmovdqu %ymm0, (%rcx,%r8,8)
xor %r10, %r10
vmovdqu %ymm0, (%rsp)
.p2align 6, 0x90
.Lloop4_Bgas_1:
movq (%rbp), %rbx
vpbroadcastq (%rbp), %ymm0
mov %rbx, %r10
imulq (%rsi), %r10
addq (%rsp), %r10
mov %r10, %rdx
imul %r9d, %edx
and $(134217727), %edx
mov %rbx, %r11
imulq (8)(%rsi), %r11
addq (8)(%rsp), %r11
mov %rbx, %r12
imulq (16)(%rsi), %r12
addq (16)(%rsp), %r12
mov %rbx, %r13
imulq (24)(%rsi), %r13
addq (24)(%rsp), %r13
vmovd %edx, %xmm11
vpbroadcastq %xmm11, %ymm11
vpmuludq (32)(%rsi), %ymm0, %ymm12
vpaddq %ymm12, %ymm1, %ymm1
vpmuludq (64)(%rsi), %ymm0, %ymm13
vpaddq %ymm13, %ymm2, %ymm2
vpmuludq (96)(%rsi), %ymm0, %ymm14
vpaddq %ymm14, %ymm3, %ymm3
vpmuludq (128)(%rsi), %ymm0, %ymm12
vpaddq %ymm12, %ymm4, %ymm4
vpmuludq (160)(%rsi), %ymm0, %ymm13
vpaddq %ymm13, %ymm5, %ymm5
vpmuludq (192)(%rsi), %ymm0, %ymm14
vpaddq %ymm14, %ymm6, %ymm6
vpmuludq (224)(%rsi), %ymm0, %ymm12
vpaddq %ymm12, %ymm7, %ymm7
vpmuludq (256)(%rsi), %ymm0, %ymm13
vpaddq %ymm13, %ymm8, %ymm8
vpmuludq (288)(%rsi), %ymm0, %ymm14
vpaddq %ymm14, %ymm9, %ymm9
mov %rdx, %rax
imulq (%rcx), %rax
add %rax, %r10
shr $(27), %r10
mov %rdx, %rax
imulq (8)(%rcx), %rax
add %rax, %r11
add %r10, %r11
mov %rdx, %rax
imulq (16)(%rcx), %rax
add %rax, %r12
mov %rdx, %rax
imulq (24)(%rcx), %rax
add %rax, %r13
vpmuludq (32)(%rcx), %ymm11, %ymm12
vpaddq %ymm12, %ymm1, %ymm1
vpmuludq (64)(%rcx), %ymm11, %ymm13
vpaddq %ymm13, %ymm2, %ymm2
vpmuludq (96)(%rcx), %ymm11, %ymm14
vpaddq %ymm14, %ymm3, %ymm3
vpmuludq (128)(%rcx), %ymm11, %ymm12
vpaddq %ymm12, %ymm4, %ymm4
vpmuludq (160)(%rcx), %ymm11, %ymm13
vpaddq %ymm13, %ymm5, %ymm5
vpmuludq (192)(%rcx), %ymm11, %ymm14
vpaddq %ymm14, %ymm6, %ymm6
vpmuludq (224)(%rcx), %ymm11, %ymm12
vpaddq %ymm12, %ymm7, %ymm7
vpmuludq (256)(%rcx), %ymm11, %ymm13
vpaddq %ymm13, %ymm8, %ymm8
vpmuludq (288)(%rcx), %ymm11, %ymm14
vpaddq %ymm14, %ymm9, %ymm9
movq (8)(%rbp), %rbx
vpbroadcastq (8)(%rbp), %ymm0
mov %rbx, %rax
imulq (%rsi), %rax
add %rax, %r11
mov %r11, %rdx
imul %r9d, %edx
and $(134217727), %edx
mov %rbx, %rax
imulq (8)(%rsi), %rax
add %rax, %r12
mov %rbx, %rax
imulq (16)(%rsi), %rax
add %rax, %r13
vmovd %edx, %xmm11
vpbroadcastq %xmm11, %ymm11
vpmuludq (24)(%rsi), %ymm0, %ymm12
vpaddq %ymm12, %ymm1, %ymm1
vpmuludq (56)(%rsi), %ymm0, %ymm13
vpaddq %ymm13, %ymm2, %ymm2
vpmuludq (88)(%rsi), %ymm0, %ymm14
vpaddq %ymm14, %ymm3, %ymm3
vpmuludq (120)(%rsi), %ymm0, %ymm12
vpaddq %ymm12, %ymm4, %ymm4
vpmuludq (152)(%rsi), %ymm0, %ymm13
vpaddq %ymm13, %ymm5, %ymm5
vpmuludq (184)(%rsi), %ymm0, %ymm14
vpaddq %ymm14, %ymm6, %ymm6
vpmuludq (216)(%rsi), %ymm0, %ymm12
vpaddq %ymm12, %ymm7, %ymm7
vpmuludq (248)(%rsi), %ymm0, %ymm13
vpaddq %ymm13, %ymm8, %ymm8
vpmuludq (280)(%rsi), %ymm0, %ymm14
vpaddq %ymm14, %ymm9, %ymm9
mov %rdx, %rax
imulq (%rcx), %rax
add %rax, %r11
shr $(27), %r11
mov %rdx, %rax
imulq (8)(%rcx), %rax
add %rax, %r12
add %r11, %r12
mov %rdx, %rax
imulq (16)(%rcx), %rax
add %rax, %r13
vpmuludq (24)(%rcx), %ymm11, %ymm12
vpaddq %ymm12, %ymm1, %ymm1
vpmuludq (56)(%rcx), %ymm11, %ymm13
vpaddq %ymm13, %ymm2, %ymm2
vpmuludq (88)(%rcx), %ymm11, %ymm14
vpaddq %ymm14, %ymm3, %ymm3
vpmuludq (120)(%rcx), %ymm11, %ymm12
vpaddq %ymm12, %ymm4, %ymm4
vpmuludq (152)(%rcx), %ymm11, %ymm13
vpaddq %ymm13, %ymm5, %ymm5
vpmuludq (184)(%rcx), %ymm11, %ymm14
vpaddq %ymm14, %ymm6, %ymm6
vpmuludq (216)(%rcx), %ymm11, %ymm12
vpaddq %ymm12, %ymm7, %ymm7
vpmuludq (248)(%rcx), %ymm11, %ymm13
vpaddq %ymm13, %ymm8, %ymm8
vpmuludq (280)(%rcx), %ymm11, %ymm14
vpaddq %ymm14, %ymm9, %ymm9
sub $(2), %r8
jz .Lexit_loop_Bgas_1
movq (16)(%rbp), %rbx
vpbroadcastq (16)(%rbp), %ymm0
mov %rbx, %rax
imulq (%rsi), %rax
add %rax, %r12
mov %r12, %rdx
imul %r9d, %edx
and $(134217727), %edx
mov %rbx, %rax
imulq (8)(%rsi), %rax
add %rax, %r13
vmovd %edx, %xmm11
vpbroadcastq %xmm11, %ymm11
vpmuludq (16)(%rsi), %ymm0, %ymm12
vpaddq %ymm12, %ymm1, %ymm1
vpmuludq (48)(%rsi), %ymm0, %ymm13
vpaddq %ymm13, %ymm2, %ymm2
vpmuludq (80)(%rsi), %ymm0, %ymm14
vpaddq %ymm14, %ymm3, %ymm3
vpmuludq (112)(%rsi), %ymm0, %ymm12
vpaddq %ymm12, %ymm4, %ymm4
vpmuludq (144)(%rsi), %ymm0, %ymm13
vpaddq %ymm13, %ymm5, %ymm5
vpmuludq (176)(%rsi), %ymm0, %ymm14
vpaddq %ymm14, %ymm6, %ymm6
vpmuludq (208)(%rsi), %ymm0, %ymm12
vpaddq %ymm12, %ymm7, %ymm7
vpmuludq (240)(%rsi), %ymm0, %ymm13
vpaddq %ymm13, %ymm8, %ymm8
vpmuludq (272)(%rsi), %ymm0, %ymm14
vpaddq %ymm14, %ymm9, %ymm9
mov %rdx, %rax
imulq (%rcx), %rax
add %rax, %r12
shr $(27), %r12
mov %rdx, %rax
imulq (8)(%rcx), %rax
add %rax, %r13
add %r12, %r13
vpmuludq (16)(%rcx), %ymm11, %ymm12
vpaddq %ymm12, %ymm1, %ymm1
vpmuludq (48)(%rcx), %ymm11, %ymm13
vpaddq %ymm13, %ymm2, %ymm2
vpmuludq (80)(%rcx), %ymm11, %ymm14
vpaddq %ymm14, %ymm3, %ymm3
vpmuludq (112)(%rcx), %ymm11, %ymm12
vpaddq %ymm12, %ymm4, %ymm4
vpmuludq (144)(%rcx), %ymm11, %ymm13
vpaddq %ymm13, %ymm5, %ymm5
vpmuludq (176)(%rcx), %ymm11, %ymm14
vpaddq %ymm14, %ymm6, %ymm6
vpmuludq (208)(%rcx), %ymm11, %ymm12
vpaddq %ymm12, %ymm7, %ymm7
vpmuludq (240)(%rcx), %ymm11, %ymm13
vpaddq %ymm13, %ymm8, %ymm8
vpmuludq (272)(%rcx), %ymm11, %ymm14
vpaddq %ymm14, %ymm9, %ymm9
movq (24)(%rbp), %rbx
vpbroadcastq (24)(%rbp), %ymm0
imulq (%rsi), %rbx
add %rbx, %r13
mov %r13, %rdx
imul %r9d, %edx
and $(134217727), %edx
vmovd %edx, %xmm11
vpbroadcastq %xmm11, %ymm11
vpmuludq (8)(%rsi), %ymm0, %ymm12
vpaddq %ymm12, %ymm1, %ymm1
vpmuludq (40)(%rsi), %ymm0, %ymm13
vpaddq %ymm13, %ymm2, %ymm2
vpmuludq (72)(%rsi), %ymm0, %ymm14
vpaddq %ymm14, %ymm3, %ymm3
vpmuludq (104)(%rsi), %ymm0, %ymm12
vpaddq %ymm12, %ymm4, %ymm4
vpmuludq (136)(%rsi), %ymm0, %ymm13
vpaddq %ymm13, %ymm5, %ymm5
vpmuludq (168)(%rsi), %ymm0, %ymm14
vpaddq %ymm14, %ymm6, %ymm6
vpmuludq (200)(%rsi), %ymm0, %ymm12
vpaddq %ymm12, %ymm7, %ymm7
vpmuludq (232)(%rsi), %ymm0, %ymm13
vpaddq %ymm13, %ymm8, %ymm8
vpmuludq (264)(%rsi), %ymm0, %ymm14
vpaddq %ymm14, %ymm9, %ymm9
vpmuludq (296)(%rsi), %ymm0, %ymm10
imulq (%rcx), %rdx
add %rdx, %r13
shr $(27), %r13
vmovq %r13, %xmm14
vpmuludq (8)(%rcx), %ymm11, %ymm12
vpaddq %ymm12, %ymm1, %ymm1
vpaddq %ymm14, %ymm1, %ymm1
vmovdqu %ymm1, (%rsp)
vpmuludq (40)(%rcx), %ymm11, %ymm13
vpaddq %ymm13, %ymm2, %ymm1
vpmuludq (72)(%rcx), %ymm11, %ymm14
vpaddq %ymm14, %ymm3, %ymm2
vpmuludq (104)(%rcx), %ymm11, %ymm12
vpaddq %ymm12, %ymm4, %ymm3
vpmuludq (136)(%rcx), %ymm11, %ymm13
vpaddq %ymm13, %ymm5, %ymm4
vpmuludq (168)(%rcx), %ymm11, %ymm14
vpaddq %ymm14, %ymm6, %ymm5
vpmuludq (200)(%rcx), %ymm11, %ymm12
vpaddq %ymm12, %ymm7, %ymm6
vpmuludq (232)(%rcx), %ymm11, %ymm13
vpaddq %ymm13, %ymm8, %ymm7
vpmuludq (264)(%rcx), %ymm11, %ymm14
vpaddq %ymm14, %ymm9, %ymm8
vpmuludq (296)(%rcx), %ymm11, %ymm12
vpaddq %ymm12, %ymm10, %ymm9
add $(32), %rbp
sub $(2), %r8
jnz .Lloop4_Bgas_1
.Lexit_loop_Bgas_1:
movq %r12, (%rdi)
movq %r13, (8)(%rdi)
vmovdqu %ymm1, (16)(%rdi)
vmovdqu %ymm2, (48)(%rdi)
vmovdqu %ymm3, (80)(%rdi)
vmovdqu %ymm4, (112)(%rdi)
vmovdqu %ymm5, (144)(%rdi)
vmovdqu %ymm6, (176)(%rdi)
vmovdqu %ymm7, (208)(%rdi)
vmovdqu %ymm8, (240)(%rdi)
vmovdqu %ymm9, (272)(%rdi)
mov $(38), %r8
xor %rax, %rax
.Lnorm_loopgas_1:
addq (%rdi), %rax
add $(8), %rdi
mov $(134217727), %rdx
and %rax, %rdx
shr $(27), %rax
movq %rdx, (-8)(%rdi)
sub $(1), %r8
jg .Lnorm_loopgas_1
movq %rax, (%rdi)
add $(32), %rsp
vzeroupper
pop %r14
pop %r13
pop %r12
pop %rbp
pop %rbx
ret
|
;/*!
; @file
;
; @ingroup fapi
;
; @brief BksFreeFocus DOS wrapper
;
; (c) osFree Project 2018, <http://www.osFree.org>
; for licence see licence.txt in root directory, or project website
;
; This is Family API implementation for DOS, used with BIND tools
; to link required API
;
; @author Yuri Prokushev (yuri.prokushev@gmail.com)
;
;*/
.8086
; Helpers
INCLUDE helpers.inc
_TEXT SEGMENT BYTE PUBLIC 'CODE' USE16
@BKSPROLOG BKSFREEFOCUS
KBDHANDLE DW ? ;KEYBOARD HANDLE
@BKSSTART BKSFREEFOCUS
; code here
@BKSEPILOG BKSFREEFOCUS
_TEXT ENDS
END
|
; void *malloc(size_t size)
INCLUDE "clib_cfg.asm"
SECTION code_alloc_malloc
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
IF __CLIB_OPT_MULTITHREAD & $01
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
PUBLIC _malloc
EXTERN asm_malloc
_malloc:
pop af
pop hl
push hl
push af
jp asm_malloc
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
ELSE
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
PUBLIC _malloc
EXTERN _malloc_unlocked
defc _malloc = _malloc_unlocked
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
ENDIF
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
; A133546: Binomial transform of [1,3,5,6,7,8,9,10,11,...] (i.e., positive integers except 2 and 4).
; 1,4,12,31,74,169,376,823,1782,3829,8180,17395,36850,77809,163824,344047,720878,1507309,3145708,6553579,13631466,28311529,58720232,121634791,251658214,520093669,1073741796,2214592483,4563402722
mov $1,4
mov $2,$0
lpb $0
sub $0,1
add $3,$1
add $1,$3
mov $3,$0
lpe
add $2,3
sub $1,$2
|
BITS 32
;TEST_FILE_META_BEGIN
;TEST_TYPE=TEST_F
;TEST_IGNOREFLAGS=
;TEST_FILE_META_END
; CDQ
;TEST_BEGIN_RECORDING
MOV eax, 0x819EDB32
MOV edx, 0
cdq
;TEST_END_RECORDING
|
#include <iostream> // For `<<`
#include <cstdlib> // For `exit`
#include <vector> // For `vector`
#include <cstring> // For `strcmp`
using namespace std;
int factorial(int);
string permute(int, string);
void swap(string&, int, int);
void remove_duplicates(vector<string>&);
void print_usage();
int main(int argc, char **argv)
{
if (!argv[1]) {
cout << "Error: Please input a string to permute." << endl;
print_usage();
exit(1);
}
bool no_dup_flag = false;
if (argv[2]) {
if (!strcmp(argv[2], "--no-duplicates") or !strcmp(argv[2], "-n")) {
no_dup_flag = true;
}
}
string str = argv[1];
int num_chars = str.length();
// Max length, ignoring repetitions, is simply length!
int num_perms = factorial(num_chars);
vector<string> perms(num_perms);
for (int k = 0; k < num_perms; k++) {
perms[k] = permute(k, str);
}
if (no_dup_flag) {
remove_duplicates(perms);
}
cout << "Possible permutations:" << endl;
for (int i=0; i < perms.size(); i++) {
cout << perms[i] << endl;
}
return 0;
}
int factorial(int num)
{
if (num < 0) {
return -1; // Undefined
}
if (num == 0) {
return 1; // By definition
}
int fact = num * factorial(num - 1);
// Standard recursive definition
return fact;
}
string permute(int k, string str)
{
for (int j = 1; j < str.size(); ++j) {
swap(str, k % (j + 1), j);
k = k / (j + 1);
}
return str;
}
void swap(string &str, int i, int j)
{
char tempchar = str[i];
str[i] = str[j];
str[j] = tempchar;
}
void remove_duplicates(vector<string> &string_vec)
{
// Removes all duplicate strings within vector `string_vec`.
for (int j = 0; j < string_vec.size(); j++) {
for (int k = 0; k < string_vec.size(); k++) {
if (string_vec[j] == string_vec[k] and j != k) {
string_vec.erase(string_vec.begin() + j);
}
}
}
}
void print_usage()
{
string usage = "Usage: string-permute STRING [OPTIONS]"
"\nOptions:\n"
"\t--no-duplicates/-n\tRemove duplicate permutations."
"\nExamples:"
"\n\tstring-permute hee\n"
"\t> Possible permutations:\n"
"\t> ehe\n"
"\t> eeh\n"
"\t> eeh\n"
"\t> hee\n"
"\t> ehe\n"
"\t> hee\n"
"\n\tstring-permute hee --no-duplicates\n"
"\t> Possible permutations:\n"
"\t> eeh\n"
"\t> ehe\n"
"\t> hee";
cout << usage << endl;
}
|
;/*!
; @file
;
; @ingroup fapi
;
; @brief DosSearchPath DOS wrapper
;
; (c) osFree Project 2022, <http://www.osFree.org>
; for licence see licence.txt in root directory, or project website
;
; This is Family API implementation for DOS, used with BIND tools
; to link required API
;
; @author Yuri Prokushev (yuri.prokushev@gmail.com)
;
;
;
;*/
.8086
; Helpers
INCLUDE helpers.inc
_TEXT SEGMENT BYTE PUBLIC 'CODE' USE16
@PROLOG DOSSEARCHPATH
@START DOSSEARCHPATH
XOR AX, AX
EXIT:
@EPILOG DOSSEARCHPATH
_TEXT ENDS
END
|
; A318047: a(n) = sum of values taken by all parking functions of length n.
; Submitted by Christian Krause
; 1,8,81,1028,15780,284652,5903464,138407544,3619892160,104485268960,3299177464704,113120695539612,4185473097734656,166217602768452900,7051983744002135040,318324623296131263408,15232941497754507165696,770291040239888149405944,41042353622873800536064000,2298206207793743728251532020,134928783738163170716713353216,8288019896813998779251701210268,531593204581003016035809545158656,35539608400644945736804527153945000,2472489303529411647038304639149670400,178724263621220811752338665594953950032
mov $1,1
add $1,$0
seq $0,328694 ; a(n) = sum of lead terms of all parking functions of length n.
mul $0,$1
|
; A250791: Number of (n+1) X (2+1) 0..1 arrays with nondecreasing min(x(i,j),x(i,j-1)) in the i direction and nondecreasing absolute value of x(i,j)-x(i-1,j) in the j direction.
; Submitted by Christian Krause
; 24,66,180,490,1336,3646,9956,27194,74288,202950,554460,1514802,4138504,11306590,30890164,84393482,230567264,629921462,1720977420,4701797730,12845550264,35094695950,95880492388,261950376634,715661738000,1955224229222,5341771934396,14593992327186,39871528523112,108931041700542,297605140447252,813072364295530,2221355009485504,6068854747562006,16580419514094956,45298548523313858,123757936074817560,338112969196262766,923741810542160580,2523709559476846618,6894902740038014320,18837224599029721798
add $0,1
mov $4,2
lpb $0
sub $0,1
add $3,6
add $1,$3
add $1,2
mul $3,2
mov $2,$3
sub $3,1
add $3,$4
mov $4,$2
lpe
mov $0,$1
add $0,4
mul $0,2
|
*= $C800
;.D X-XFER128.BIN
; Requires modem on channel 5, file on channel 2
JMP SENDFIL
JMP RECVCHK
JMP SENDFIL
JMP RECVCRC
PRINT2
NOP
;OPEN1,8,15,"S0:X-XFER 1300,ML1300X":CLOSE1:SAVE"ML1300X",8:STOP
;**********
;CRC TABLES
;**********
CRCLSB
BYTE 0,33,66,99,132,165,198,231
BYTE 8,41,74,107,140,173,206,239
BYTE 49,16,115,82,181,148,247,214
BYTE 57,24,123,90,189,156,255,222
BYTE 98,67,32,1,230,199,164,133
BYTE 106,75,40,9,238,207,172,141
BYTE 83,114,17,48,215,246,149,180
BYTE 91,122,25,56,223,254,157,188
BYTE 196,229,134,167,64,97,2,35
BYTE 204,237,142,175,72,105,10,43
BYTE 245,212,183,150,113,80,51,18
BYTE 253,220,191,158,121,88,59,26
BYTE 166,135,228,197,34,3,96,65
BYTE 174,143,236,205,42,11,104,73
BYTE 151,182,213,244,19,50,81,112
BYTE 159,190,221,252,27,58,89,120
BYTE 136,169,202,235,12,45,78,111
BYTE 128,161,194,227,4,37,70,103
BYTE 185,152,251,218,61,28,127,94
BYTE 177,144,243,210,53,20,119,86
BYTE 234,203,168,137,110,79,44,13
BYTE 226,195,160,129,102,71,36,5
BYTE 219,250,153,184,95,126,29,60
BYTE 211,242,145,176,87,118,21,52
BYTE 76,109,14,47,200,233,138,171
BYTE 68,101,6,39,192,225,130,163
BYTE 125,92,63,30,249,216,187,154
BYTE 117,84,55,22,241,208,179,146
BYTE 46,15,108,77,170,139,232,201
BYTE 38,7,100,69,162,131,224,193
BYTE 31,62,93,124,155,186,217,248
BYTE 23,54,85,116,147,178,209,240
;
CRCMSB
BYTE 0,16,32,48,64,80,96,112
BYTE 129,145,161,177,193,209,225,241
BYTE 18,2,50,34,82,66,114,98
BYTE 147,131,179,163,211,195,243,227
BYTE 36,52,4,20,100,116,68,84
BYTE 165,181,133,149,229,245,197,213
BYTE 54,38,22,6,118,102,86,70
BYTE 183,167,151,135,247,231,215,199
BYTE 72,88,104,120,8,24,40,56
BYTE 201,217,233,249,137,153,169,185
BYTE 90,74,122,106,26,10,58,42
BYTE 219,203,251,235,155,139,187,171
BYTE 108,124,76,92,44,60,12,28
BYTE 237,253,205,221,173,189,141,157
BYTE 126,110,94,78,62,46,30,14
BYTE 255,239,223,207,191,175,159,143
BYTE 145,129,177,161,209,193,241,225
BYTE 16,0,48,32,80,64,112,96
BYTE 131,147,163,179,195,211,227,243
BYTE 2,18,34,50,66,82,98,114
BYTE 181,165,149,133,245,229,213,197
BYTE 52,36,20,4,116,100,84,68
BYTE 167,183,135,151,231,247,199,215
BYTE 38,54,6,22,102,118,70,86
BYTE 217,201,249,233,153,137,185,169
BYTE 88,72,120,104,24,8,56,40
BYTE 203,219,235,251,139,155,171,187
BYTE 74,90,106,122,10,26,42,58
BYTE 253,237,221,205,189,173,157,141
BYTE 124,108,92,76,60,44,28,12
BYTE 239,255,207,223,175,191,143,159
BYTE 110,126,78,94,46,62,14,30
;****************
;VARIABLE STORAGE
;****************
BUFFER = $CEFD
BUFFER3 = $CF00
ENDBUF = $CF80
CRCBUF = $CF81
ACK = $06
CAN = $18
EOT = $04
NAK = $15
SOH = $01
CNAK = $43
PAD = $1A
OTH = $02
ABORTFLAG = $FB
UPDN = $FE
XTYPE = $FF
FREEKEY = $FA
; KERNAL JUMPS
JSRFAR = $02CD
LOCJSRFAR = $1BE0
FETCH = $02A2
; C128 Specific Locations
TIMEHB = $A0
TIMEMB = $A1
TIMELB = $A2
SHFLAG = $D3
RIDBS = $0A18 ; index to first char in input buffer
RIDBE = $0A19 ; index to last char in input buffer
RODBS = $0A1A ; index to first char in output buffer
RODBE = $0A1B ; index to last char in output buffer
KEYINDEX = $D0
CASSSYNCCT = $96
STATUS = $90
RIBUF = $C8
;***************
;VARIABLE MEMORY
;***************
BLOCK BYTE 0
GOOD BYTE 0
ERRORS BYTE 0
ABORT BYTE 0
TIMEOUTS BYTE 0
BUFBIT BYTE 0
BUFSIZE BYTE 0
CHECKSM BYTE 0
CRC BYTE 0,0
CLOCK BYTE 0
IOSTAT BYTE 0
;*************
;MISC ROUTINES
;*************
GOGOFAR
LDA #$00
STA $FF00
JSR JSRFAR
LDA #$3F
STA $FF00
RTS
PREFAR
STA $06
STX $07
STY $08
LDA LOCJSRFAR
CMP GOGOFAR
BEQ PREFAR3
LDX #$FF
PREFAR2
INX
LDA GOGOFAR,X
STA LOCJSRFAR,X
CPX #$10
BCC PREFAR2
PREFAR3
LDA #$0F
STA $02
LDA #$FF
STA $03
RTS
GOFAR
STA $04
JSR LOCJSRFAR
LDX $07
LDY $08
LDA $06
RTS
CHKIN
JSR PREFAR
LDA #$C6
JMP GOFAR
CHKOUT
JSR PREFAR
LDA #$C9
JMP GOFAR
CLRCH
JSR PREFAR
LDA #$CC
JMP GOFAR
BSOUT
JSR PREFAR
LDA #$D2
JMP GOFAR
SETTIM
JSR PREFAR
LDA #$DB
JMP GOFAR
GETIN
JSR PREFAR
LDA #$E4
JMP GOFAR
GETDD01
TYA
PHA
TXA
PHA
LDA #$01
STA $03
LDA #$DD
STA $04
LDA #$03
STA $02AA
LDY #$00
LDX #$00
JSR FETCH
STA $06
PLA
TAX
PLA
TAY
LDA $06
CMP #$00
RTS
CLEAR
LDA #$00
STA BLOCK
STA GOOD
STA ERRORS
STA ABORT
STA BUFBIT
STA CHECKSM
STA CRC
STA CRC+1
STA TIMEOUTS
STA IOSTAT
RTS
RETIME
LDA #$00
TAX
TAY
JMP SETTIM
CHECKTIME
LDA #$00
STA CLOCK
LDA TIMEMB
CMP #$03
BCS BADTIME
RTS
BADTIME
INC TIMEOUTS
INC CLOCK
JMP RETIME
CHECKABORT
LDA SHFLAG
CMP #$02
BEQ ABORTED
JSR GETDD01
and #$10
beq ABORTED
RTS
ABORTED
LDA #$01
STA ABORT
JMP CLRCH
ERRFLUSH
INC ERRORS
FLUSHBUF
LDY #$00
TYA
FLUSHLP
STA BUFFER,Y
INY
CPY #$85
BCC FLUSHLP
MINFLUSH
LDA RIDBS
STA RIDBE
LDA RODBS
STA RODBE
LDA #$00
STA KEYINDEX
STA BUFBIT
STA GOOD
JSR RETIME
RTS
PAAS
JSR RETIME
PAS1
LDA TIMELB
CMP #$05
BNE PAS1
RTS
GETKEY
TYA
PHA
LDA RIDBS
CMP RIDBE
BEQ NOKEY
LDY RIDBE
LDA (RIBUF),Y
STA FREEKEY
INC RIDBE
LDA #$01
STA CASSSYNCCT
PLA
TAY
RTS
NOKEY
LDA #$00
STA CASSSYNCCT
STA FREEKEY
PLA
TAY
RTS
;*******************
;CHECK BLOCK ROUTINE
;*******************
CHKBLK
LDA XTYPE
BNE CRCCHK
LDY #$00
STY CHECKSM
CHKCHK
LDA BUFFER3,Y
CLC
ADC CHECKSM
STA CHECKSM
INY
CPY #$80
BCC CHKCHK
RTS
CRCCHK
LDY #$00
STY CRC
STY CRC+1
CRCCLP
LDA BUFFER3,Y
EOR CRC
TAX
LDA CRCMSB,X
EOR CRC+1
STA CRC
LDA CRCLSB,X
STA CRC+1
INY
CPY #$80
BNE CRCCLP
RTS
;*********************
;RECEIVE A XMODEM FILE
;*********************
RECVCHK
LDA #$00
STA XTYPE
LDA #$84
STA BUFSIZE
JMP RCVBEGIN
RECVCRC
LDA #$01
STA XTYPE
LDA #$85
STA BUFSIZE
RCVBEGIN
LDA #$01
STA UPDN
JSR CLEAR
JSR FLUSHBUF
INC BLOCK
LDX #$05
JSR CHKOUT
LDA XTYPE
BNE CXNAK
LDA #NAK
JSR BSOUT
JMP RECVLP
CXNAK
LDA #CNAK
JSR BSOUT
RECVLP
LDA ERRORS
CMP #$0E
BCC R2;**TOO MANY ERRS
CANCEL
LDA #$01
STA ABORT
R2 JSR CHECKABORT
JSR CHECKTIME
LDA ABORT
BEQ ARECVN
JMP ABORTXMODEM
RCVDONE
JMP EXITRCV
ARECVN
LDA BLOCK
CMP #$01
BNE NEXTR
LDA TIMEOUTS
CMP #$02
BNE NEXTR
JMP CANCEL
NEXTR
LDA CLOCK
BEQ NOCLOCK
JMP NORBORT
NOCLOCK
LDX #$05
JSR CHKIN
LDA BUFFER
CMP #CAN
BEQ CANCEL
CMP #EOT
BEQ RCVDONE
JSR GETKEY
LDA CASSSYNCCT
BEQ RECVLP
JSR RETIME
LDY BUFBIT
LDA FREEKEY
STA BUFFER,Y
INC BUFBIT
INY
CPY BUFSIZE
BCC RECVLP
;**** CHECK THE BLOCK ****
JSR PAAS
LDA BUFFER
CMP #EOT
BEQ RCVDONE
CMP #CAN
BEQ CANCEL
CMP #OTH
BEQ CHKREST
CMP #SOH
BEQ CHKREST
JMP CONRCV
CHKREST
LDA BUFFER+1
CMP BLOCK
BNE CONRCV
EOR #$FF
CMP BUFFER+2
BNE CONRCV
JSR CHKBLK
LDA XTYPE
BNE CRCDO
LDA CHECKSM
CMP ENDBUF
BEQ GOODIE
JMP CONRCV
CRCDO
LDA ENDBUF
CMP CRC
BNE CONRCV
LDA CRCBUF
CMP CRC+1
BNE CONRCV
GOODIE
LDA #$01
STA GOOD
;**** WRITE OR NAK BLOCK ****
CONRCV
LDA GOOD
BEQ NORGOOD
JSR CLRCH
LDX #$02
JSR CHKOUT
LDY #$00
WRITELP
LDA BUFFER3,Y
JSR BSOUT
INY
CPY #$80
BCC WRITELP
JSR FLUSHBUF
JSR CLRCH
LDA #$2D
JSR BSOUT
LDX #$05
JSR CHKOUT
LDA #ACK
JSR BSOUT
JSR CLRCH
INC BLOCK
JMP RECVLP
NORGOOD
LDA ABORT
BEQ NORBORT
JMP ABORTXMODEM
NORBORT
JSR FLUSHBUF
JSR CLRCH
LDA #$3A
JSR BSOUT
LDX #$05
JSR CHKOUT
LDA XTYPE
BNE CNKK
NAKK
LDA #NAK
JSR BSOUT
JMP CONAK
CNKK
LDA BLOCK
CMP #$02
BCS NAKK
LDA #CNAK
JSR BSOUT
CONAK
INC ERRORS
JSR CLRCH
JMP RECVLP
;****** ALL DONE ******
EXITRCV
JSR CLRCH
LDX #$05
JSR CHKOUT
LDA #ACK
JSR BSOUT
JMP EXITXMODEM
ABORTXMODEM
LDA #$01
STA ABORT
JSR CLRCH
LDX #$05
JSR CHKOUT
LDA #CAN
JSR BSOUT
JSR BSOUT
JSR BSOUT
EXITXMODEM
LDX ABORT
JSR CLEAR
STX ABORT
JSR FLUSHBUF
LDA #$00
STA XTYPE
STA UPDN
JSR CLRCH
LDA #$2A
JSR BSOUT
LDA ABORT
STA ABORTFLAG
RTS
;******************
;SEND A XMODEM FILE
;******************
SENDFIL
LDA #$00
STA UPDN
JSR CLEAR
JSR FLUSHBUF
JSR SNDSCRC
JMP SNDSTART
SNDSCHK
LDA #$00
STA XTYPE
LDA #$84
STA BUFSIZE
RTS
SNDSCRC
LDA #$01
STA XTYPE
LDA #$85
STA BUFSIZE
RTS
SNDBUILD
LDX #$02
JSR CHKIN
LDY #$00
STY IOSTAT
SREAD
JSR GETIN
STA BUFFER3,Y
LDA STATUS
STA IOSTAT
BNE PADBUF
INY
CPY #$80
BCC SREAD
JMP SND2
PADBUF
INY
INY
CPY #$80
BCC PAD2
PAD2
LDA #PAD
STA BUFFER3,Y
INY
CPY #$80
BCC PAD2
SND2
LDA #SOH
STA BUFFER
LDA BLOCK
STA BUFFER+1
EOR #$FF
STA BUFFER+2
;**** BUILD CHECKSUMS ****
JSR CHKBLK
LDA CHECKSM
STA ENDBUF
LDA XTYPE
BEQ SNDCONT
LDA CRC
STA ENDBUF
LDA CRC+1
STA CRCBUF
;***** SEND THE BLOCK *****
SNDCONT
JSR MINFLUSH
JSR CLRCH
LDX #$05
JSR CHKOUT
LDY #$00
STY BUFBIT
SENDLOOP
LDA BUFFER,Y
JSR BSOUT
LDY BUFBIT
INY
STY BUFBIT
CPY BUFSIZE
BCC SENDLOOP
SNDSTART
JSR CLRCH
LDX #$05
JSR CHKIN
JSR RETIME
SENDWAIT
JSR CHECKABORT
JSR CHECKTIME
JSR GETIN
CMP #NAK
BEQ SNDCHK
CMP #CNAK
BEQ SNDCRC
CMP #CAN
BEQ SNDABORT
CMP #ACK
BEQ NEXTBLOCK
LDA ERRORS
CMP #$0E
BEQ SNDABORT
LDA ABORT
BNE SNDABORT
LDA CLOCK
BNE SENDERR
JMP SENDWAIT
;****** MISC SEND ROUTINES ******
SNDABORT
JMP ABORTXMODEM
SNDCRC
JSR SNDSCRC
JMP SENDRE
SNDCHK
JSR SNDSCHK
SENDRE
LDA BLOCK
BEQ NEXTBLOCK
SENDERR
INC ERRORS
JSR CLRCH
LDA #$3A
JSR BSOUT
JSR PAAS
JMP SNDCONT
NEXTBLOCK
INC BLOCK
JSR CLRCH
LDA #$2D
JSR BSOUT
LDA IOSTAT
BEQ NXTGO
LDX #$05
JSR CHKOUT
LDY #$00
EOPL
LDA #EOT
JSR BSOUT
INY
CPY #$85
BNE EOPL
JMP EXITXMODEM
NXTGO
JSR PAAS
JSR FLUSHBUF
JMP SNDBUILD
|
; A174426: Denominator of fractions in A171676.
; 4,36,36,144,144,144,400,400,400,400,900,900,900,900,900,1764,1764,1764,1764,1764,1764,3136,3136,3136,3136,3136,3136,3136,5184,5184,5184,5184,5184,5184,5184,5184,8100,8100,8100,8100,8100,8100,8100,8100,8100
mov $3,1
lpb $0,1
sub $0,1
mov $2,2
add $3,1
add $4,1
trn $0,$4
mov $1,1
add $3,$4
mov $5,1
lpe
sub $1,$5
pow $3,$2
mov $5,$1
mov $1,1
add $5,$3
sub $5,1
add $1,$5
mul $1,2
sub $1,2
div $1,2
mul $1,4
add $1,4
|
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ppapi/proxy/message_handler.h"
#include "ipc/ipc_message.h"
#include "ppapi/proxy/plugin_dispatcher.h"
#include "ppapi/proxy/ppapi_messages.h"
#include "ppapi/proxy/ppb_message_loop_proxy.h"
#include "ppapi/shared_impl/proxy_lock.h"
#include "ppapi/shared_impl/scoped_pp_var.h"
#include "ppapi/thunk/enter.h"
namespace ppapi {
namespace proxy {
namespace {
typedef void (*HandleMessageFunc)(PP_Instance, void*, PP_Var);
typedef PP_Var (*HandleBlockingMessageFunc)(PP_Instance, void*, PP_Var);
void HandleMessageWrapper(HandleMessageFunc function,
PP_Instance instance,
void* user_data,
ScopedPPVar message_data) {
CallWhileUnlocked(function, instance, user_data, message_data.get());
}
void HandleBlockingMessageWrapper(HandleBlockingMessageFunc function,
PP_Instance instance,
void* user_data,
ScopedPPVar message_data,
scoped_ptr<IPC::Message> reply_msg) {
PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance);
if (!dispatcher)
return;
PP_Var return_value = CallWhileUnlocked(function,
instance,
user_data,
message_data.get());
PpapiMsg_PPPMessageHandler_HandleBlockingMessage::WriteReplyParams(
reply_msg.get(),
SerializedVarReturnValue::Convert(dispatcher, return_value),
true /* was_handled */);
dispatcher->Send(reply_msg.release());
}
} // namespace
// static
scoped_ptr<MessageHandler> MessageHandler::Create(
PP_Instance instance,
const PPP_MessageHandler_0_1* handler_if,
void* user_data,
PP_Resource message_loop,
int32_t* error) {
scoped_ptr<MessageHandler> result;
// The interface and all function pointers must be valid.
if (!handler_if ||
!handler_if->HandleMessage ||
!handler_if->HandleBlockingMessage ||
!handler_if->Destroy) {
*error = PP_ERROR_BADARGUMENT;
return result.Pass();
}
thunk::EnterResourceNoLock<thunk::PPB_MessageLoop_API>
enter_loop(message_loop, true);
if (enter_loop.failed()) {
*error = PP_ERROR_BADRESOURCE;
return result.Pass();
}
scoped_refptr<MessageLoopResource> message_loop_resource(
static_cast<MessageLoopResource*>(enter_loop.object()));
if (message_loop_resource->is_main_thread_loop()) {
*error = PP_ERROR_WRONG_THREAD;
return result.Pass();
}
result.reset(new MessageHandler(
instance, handler_if, user_data, message_loop_resource));
*error = PP_OK;
return result.Pass();
}
MessageHandler::~MessageHandler() {
// It's possible the message_loop_proxy is NULL if that loop has been quit.
// In that case, we unfortunately just can't call Destroy.
if (message_loop_->message_loop_proxy().get()) {
// The posted task won't have the proxy lock, but that's OK, it doesn't
// touch any internal state; it's a direct call on the plugin's function.
message_loop_->message_loop_proxy()->PostTask(FROM_HERE,
base::Bind(handler_if_->Destroy,
instance_,
user_data_));
}
}
bool MessageHandler::LoopIsValid() const {
return !!message_loop_->message_loop_proxy().get();
}
void MessageHandler::HandleMessage(ScopedPPVar var) {
message_loop_->message_loop_proxy()->PostTask(FROM_HERE,
RunWhileLocked(base::Bind(&HandleMessageWrapper,
handler_if_->HandleMessage,
instance_,
user_data_,
var)));
}
void MessageHandler::HandleBlockingMessage(ScopedPPVar var,
scoped_ptr<IPC::Message> reply_msg) {
message_loop_->message_loop_proxy()->PostTask(FROM_HERE,
RunWhileLocked(base::Bind(&HandleBlockingMessageWrapper,
handler_if_->HandleBlockingMessage,
instance_,
user_data_,
var,
base::Passed(reply_msg.Pass()))));
}
MessageHandler::MessageHandler(
PP_Instance instance,
const PPP_MessageHandler_0_1* handler_if,
void* user_data,
scoped_refptr<MessageLoopResource> message_loop)
: instance_(instance),
handler_if_(handler_if),
user_data_(user_data),
message_loop_(message_loop) {
}
} // namespace proxy
} // namespace ppapi
|
; void in_Wait(uint ticks)
; 09.2005 aralbrec
PUBLIC in_Wait
EXTERN t_delay
; Waits a period of time measured in milliseconds.
;
; enter : HL = time to wait in ms
; used : AF,BC,DE,HL
.in_Wait
; wait 1ms in loop controlled by HL
; at 3.5MHz, 1ms = 3500 T states
ld e,l
ld d,h
.loop
ld hl,3500 - 36
call t_delay ; wait exactly HL t-states
dec de
ld a,d
or e
jr nz, loop
ret
|
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
// Hint: --trace_serializer is a useful debugging flag.
#include <fstream>
#include <iostream>
#include "deno.h"
#include "file_util.h"
#include "internal.h"
#include "third_party/v8/include/v8.h"
#include "third_party/v8/src/base/logging.h"
int main(int argc, char** argv) {
const char* snapshot_out_bin = argv[1];
const char* js_fn = argv[2];
deno_set_v8_flags(&argc, argv);
CHECK_NOT_NULL(js_fn);
CHECK_NOT_NULL(snapshot_out_bin);
std::string js_source;
CHECK(deno::ReadFileToString(js_fn, &js_source));
deno_init();
deno_config config = {1, deno::empty_snapshot, deno::empty_buf, nullptr};
Deno* d = deno_new(config);
deno_execute(d, nullptr, js_fn, js_source.c_str());
if (deno_last_exception(d) != nullptr) {
std::cerr << "Snapshot Exception " << std::endl;
std::cerr << deno_last_exception(d) << std::endl;
deno_delete(d);
return 1;
}
auto snapshot = deno_snapshot_new(d);
std::ofstream file_(snapshot_out_bin, std::ios::binary);
file_.write(reinterpret_cast<char*>(snapshot.data_ptr), snapshot.data_len);
file_.close();
deno_snapshot_delete(snapshot);
deno_delete(d);
return file_.bad();
}
|
.macro _str,msg
.stringn msg+"<end>" :: .align 4
.endmacro
;repointing stuff
.org 0x08006E9C
.word @NewEndingScript
.org 0x0802E4B4 ;repointing cutscene script locations
.word @Kappado1start
.word @Kappado1redo
.word @Kappado2start
.word @Kappado2redo
.word @Kappado3start
.word @Kappado3redo
.word @Tenko1start
.word @Tenko1redo
.word @Tenko2start
.word @Tenko2redo
.word @Tenko3start
.word @Tenko3redo
.word @Naporon1start
.word @Naporon1redo
.word @Naporon2start
.word @Naporon2redo
.word @Naporon3start
.word @Naporon3redo
.word @Baron1start
.word @Baron1redo
.word @Baron2start
.word @Baron2redo
.word @Baron3start
.word @Baron3redo
.org 0x0802EA9C
.word @Kappado1lose
.word @Kappado1win
.word @Kappado2lose
.word @Kappado2win
.word @Kappado3lose
.word @Kappado3win
.word @Tenko1lose
.word @Tenko1win
.word @Tenko2lose
.word @Tenko2win
.word @Tenko3lose
.word @Tenko3win
.word @Naporon1lose
.word @Naporon1win
.word @Naporon2lose
.word @Naporon2win
.word @Naporon3lose
.word @Naporon3win
.word @Baron1lose
.word @Baron1win
.word @Baron2lose
.word @Baron2win
.word @Baron3lose
.word @Baron3win
.org 0x080292DC
.word @TeacherHareRankUpWorld1
.word @TeacherHareRankUpWorld2
.word @TeacherHareRankUpWorld3
.word @TeacherHareRankUpWorld4
.word @BaronMagicRankUpWorld1
.word @BaronMagicRankUpWorld2
.word @BaronMagicRankUpWorld3
.word @BaronMagicRankUpWorld4
.word @DadRankUp1
.word @DadRankUp2
.word @DadRankUp3
.word @DadRankUp4
.org 0x08010DC4 ;starting intro cutscene from game boot
.word @NewIntroScript
.org 0x08011DD0 ;starting intro cutscene from mode select
.word script_loc1
.org 0x0801A38C ;beat Baron Magic's 3rd minigame, and it's the last one
.word @Baron3winlast
.org 0x0801324C ;cutscene with Baron Magic before Neo Land
.word @Intermission
.org 0x08010DF0
.word script_loc1
.org 0x080A77C8
.region 0xABC1C-0xA77C8, 00 ;deletes original intro cutscene data
.endregion
;---------------- Intro modifications
.org 0x080A6FE2
.byte 0x0F ;custom command to add variable width
.org 0x080A701C
.word 0x30 ;placeholder on max # of characters per line (intro)
.org 0x080A6F9C
.byte 0x04 ;faster text, 0x04 originally
;---------------- Ending modifications
.org 0x080959DE
.byte 0x0F ;vwf
.org 0x08095A18
.byte 0x30 ;chars per line
.org 0x08095998
.byte 0x03 ;faster text, needed to sync with ending music (need to lose ~40 frames) 0x06 originally
;---------------- Dialogue modifications
.org 0x080960EA ;taken from nextscriptpointer.asm
.byte 0x0F ;vwf code in 1st Kappado encounter (TODO: Repoint every cutscene script and change code that adds width)
.org 0x08096118
.byte 0x30 ;max # characters per line (dialogue), shouldn't need this 'cause I'd just use <line>s.
sndOffset equ 0x78 ;originally 0x40, makes more space for characters
.org 0x08096044
.byte sndOffset + 1 ;hack related to storage sound effects
.org 0x0809583C
.byte 0xC0 ;originally 0x60, gives more space for text/sounds
.org 0x0803A360 ;sounds for lowercase letters
.byte 0x3E,0x39,0x3F,0x3A,0x40,0x3B,0x41,0x3C,0x42,0x3D,0x39,0x3E,0x3A, \
0x3F,0x3B,0x40,0x3C,0x41,0x3D,0x3C,0x39,0x3E,0x3A,0x3F,0x3B,0x40
.org 0x0809608C
.byte 0x03 ;lower = faster dialogue speed (at the cost of audio) 0x06 originally
.org 0x08095CE4
.byte 0x50 ;originally 0x26, deletes all text chars
;----------------- Neo Land Intermission dialogue modifications (can press A to display all text)
.org 0x08095EFC
.byte 0x30 ;max # of chars per line
.org 0x08095E10
.byte sndOffset + 1 ;sound effect storage hack
.org 0x08095E70
.byte 0x03 ;faster dialogue speed (0x06 originally)
.org 0x08095ECE
.byte 0x0F ;custom vwf code
;----------------- Special text box (green/pink) modifications
.org 0x080AC574
.byte 0x50 ;delete all chars
.org 0x080AC6D0
.byte 0x03 ;dialogue speed
.org 0x080AC716
.byte 0x0F ;custom vwf code
.org 0x080AC744
.byte 0x30 ;max chars per line
;----------------- Credits modifications
.org 0x080A6504
.byte 0x5D ;reposition "The end"
.org 0x080A651C
_str " FIN"
;-----------------
.macro S_unlockMinigame,game
_str "\""+game+"\""+" was added<line>to the Challenge menu!"
.endmacro
.macro S_unlockMagic,magic
_str "\""+magic+"\""+" was added<line> to the Magic menu!"
.endmacro
.macro loadChars,msg
.byte 0x0A,0x00,0x14,0x00,0x18,0xFF,0xFF,0x7F
_str msg
.endmacro
.macro loadCharsInstant,msg
.byte 0x0A,0x00,0x1A,0x00,0x18,0xFF,0xFF,0x7F ;0x1A custom code auto-centers instantly displayed text
_str msg
.endmacro
.macro loadCharsAndSfx,msg
loadChars msg
.byte 0x0F,0x00,0x04,0x00,sndOffset,0xFF,0xFF,0x7F
_str msg
.endmacro
.loadtable "text/kp_eng.tbl" ;original table bugs out with capital M's
.include "text/dialogue.asm"
.autoregion
.align 4
@NewIntroScript:
.include "asm/scriptcode/intro_sc.asm"
@Kappado1start:
.include "asm/scriptcode/kappado/kappado1start.asm"
@Kappado1lose:
.include "asm/scriptcode/kappado/kappado1lose.asm"
@Kappado1redo:
.include "asm/scriptcode/kappado/kappado1redo.asm"
@Kappado1win:
.include "asm/scriptcode/kappado/kappado1win.asm"
@Kappado2start:
.include "asm/scriptcode/kappado/kappado2start.asm"
@Kappado2lose:
.include "asm/scriptcode/kappado/kappado2lose.asm"
@Kappado2redo:
.include "asm/scriptcode/kappado/kappado2redo.asm"
@Kappado2win:
.include "asm/scriptcode/kappado/kappado2win.asm"
@Kappado3start:
.include "asm/scriptcode/kappado/kappado3start.asm"
@Kappado3lose:
.include "asm/scriptcode/kappado/kappado3lose.asm"
@Kappado3redo:
.include "asm/scriptcode/kappado/kappado3redo.asm"
@Kappado3win:
.include "asm/scriptcode/kappado/kappado3win.asm"
@Tenko1start:
.include "asm/scriptcode/tenko/tenko1start.asm"
@Tenko1lose:
.include "asm/scriptcode/tenko/tenko1lose.asm"
@Tenko1redo:
.include "asm/scriptcode/tenko/tenko1redo.asm"
@Tenko1win:
.include "asm/scriptcode/tenko/tenko1win.asm"
@Tenko2start:
.include "asm/scriptcode/tenko/tenko2start.asm"
@Tenko2lose:
.include "asm/scriptcode/tenko/tenko2lose.asm"
@Tenko2redo:
.include "asm/scriptcode/tenko/tenko2redo.asm"
@Tenko2win:
.include "asm/scriptcode/tenko/tenko2win.asm"
@Tenko3start:
.include "asm/scriptcode/tenko/tenko3start.asm"
@Tenko3lose:
.include "asm/scriptcode/tenko/tenko3lose.asm"
@Tenko3redo:
.include "asm/scriptcode/tenko/tenko3redo.asm"
@Tenko3win:
.include "asm/scriptcode/tenko/tenko3win.asm"
@Naporon1start:
.include "asm/scriptcode/naporon/naporon1start.asm"
@Naporon1lose:
.include "asm/scriptcode/naporon/naporon1lose.asm"
@Naporon1redo:
.include "asm/scriptcode/naporon/naporon1redo.asm"
@Naporon1win:
.include "asm/scriptcode/naporon/naporon1win.asm"
@Naporon2start:
.include "asm/scriptcode/naporon/naporon2start.asm"
@Naporon2lose:
.include "asm/scriptcode/naporon/naporon2lose.asm"
@Naporon2redo:
.include "asm/scriptcode/naporon/naporon2redo.asm"
@Naporon2win:
.include "asm/scriptcode/naporon/naporon2win.asm"
@Naporon3start:
.include "asm/scriptcode/naporon/naporon3start.asm"
@Naporon3lose:
.include "asm/scriptcode/naporon/naporon3lose.asm"
@Naporon3redo:
.include "asm/scriptcode/naporon/naporon3redo.asm"
@Naporon3win:
.include "asm/scriptcode/naporon/naporon3win.asm"
@Baron1start:
.include "asm/scriptcode/baron/baron1start.asm"
@Baron1lose:
.include "asm/scriptcode/baron/baron1lose.asm"
@Baron1redo:
.include "asm/scriptcode/baron/baron1redo.asm"
@Baron1win:
.include "asm/scriptcode/baron/baron1win.asm"
@Baron2start:
.include "asm/scriptcode/baron/baron2start.asm"
@Baron2lose:
.include "asm/scriptcode/baron/baron2lose.asm"
@Baron2redo:
.include "asm/scriptcode/baron/baron2redo.asm"
@Baron2win:
.include "asm/scriptcode/baron/baron2win.asm"
@Baron3start:
.include "asm/scriptcode/baron/baron3start.asm"
@Baron3lose:
.include "asm/scriptcode/baron/baron3lose.asm"
@Baron3redo:
.include "asm/scriptcode/baron/baron3redo.asm"
@Baron3win:
.include "asm/scriptcode/baron/baron3win.asm"
@Baron3winlast:
.include "asm/scriptcode/baron/baron3winlast.asm"
@Intermission:
.include "asm/scriptcode/intermission.asm"
@NewEndingScript:
.include "asm/scriptcode/ending.asm"
@TeacherHareRankUpWorld1:
.include "asm/scriptcode/rankup/rankup_hare1.asm"
@TeacherHareRankUpWorld2:
.include "asm/scriptcode/rankup/rankup_hare2.asm"
@TeacherHareRankUpWorld3:
.include "asm/scriptcode/rankup/rankup_hare3.asm"
@TeacherHareRankUpWorld4:
.include "asm/scriptcode/rankup/rankup_hare4.asm"
@BaronMagicRankUpWorld1:
.include "asm/scriptcode/rankup/rankup_baron1.asm"
@BaronMagicRankUpWorld2:
.include "asm/scriptcode/rankup/rankup_baron2.asm"
@BaronMagicRankUpWorld3:
.include "asm/scriptcode/rankup/rankup_baron3.asm"
@BaronMagicRankUpWorld4:
.include "asm/scriptcode/rankup/rankup_baron4.asm"
@DadRankUp1:
.include "asm/scriptcode/rankup/rankup_dad1.asm"
@DadRankUp2:
.include "asm/scriptcode/rankup/rankup_dad2.asm"
@DadRankUp3:
.include "asm/scriptcode/rankup/rankup_dad3.asm"
@DadRankUp4:
.include "asm/scriptcode/rankup/rankup_dad4.asm"
MinigameUnlock:
.include "asm/scriptcode/minigameunlock.asm"
MagicUnlock:
.include "asm/scriptcode/magicunlock.asm"
.endautoregion |
; A277499: E.g.f.: -sin(LambertW(-x)).
; Submitted by Christian Krause
; 0,1,2,8,52,476,5646,82368,1426888,28623376,652516090,16660233600,470930272572,14598765522368,492441140292934,17955574113204224,703714660937658128,29500170665998713088,1317136516654501334898,62399954043306802391040,3126350346520523438151620,165157373395858224824114176,9174939407854035904802043902,534691522079675789643764809728,32617052250932117291139310292952,2078536646787659518280895019749376,138116534181881587063729033452970346,9553806281043537193710977157917278208
mov $1,$0
lpb $0
sub $0,1
mov $4,$3
mul $3,$1
add $3,$2
mul $2,$1
sub $2,$4
max $3,2
lpe
mov $0,$3
div $0,2
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.