text stringlengths 1 1.05M |
|---|
/* DHT library
MIT license
written by Adafruit Industries
*/
#include "DHT.h"
#define MIN_INTERVAL 2000
DHT::DHT(uint8_t pin, uint8_t type, uint8_t count) {
_pin = pin;
_type = type;
#ifdef __AVR
_bit = digitalPinToBitMask(pin);
_port = digitalPinToPort(pin);
#endif
_maxcycles = microsecondsToClockCycles(1000); // 1 millisecond timeout for
// reading pulses from DHT sensor.
// Note that count is now ignored as the DHT reading algorithm adjusts itself
// basd on the speed of the processor.
}
void DHT::begin(void) {
// set up the pins!
pinMode(_pin, INPUT_PULLUP);
// Using this value makes sure that millis() - lastreadtime will be
// >= MIN_INTERVAL right away. Note that this assignment wraps around,
// but so will the subtraction.
_lastreadtime = -MIN_INTERVAL;
DEBUG_PRINT("Max clock cycles: "); DEBUG_PRINTLN(_maxcycles, DEC);
}
//boolean S == Scale. True == Fahrenheit; False == Celcius
float DHT::readTemperature(bool S, bool force) {
float f = NAN;
if (read(force)) {
switch (_type) {
case DHT11:
f = data[2] + (data[3] * 0.1); // [CGB]
if(S) {
f = convertCtoF(f);
}
break;
case DHT22:
case DHT21:
f = data[2] & 0x7F;
f *= 256;
f += data[3];
f *= 0.1;
if (data[2] & 0x80) {
f *= -1;
}
if(S) {
f = convertCtoF(f);
}
break;
}
}
return f;
}
float DHT::convertCtoF(float c) {
return c * 1.8 + 32;
}
float DHT::convertFtoC(float f) {
return (f - 32) * 0.55555;
}
float DHT::readHumidity(bool force) {
float f = NAN;
if (read()) {
switch (_type) {
case DHT11:
f = data[0];
break;
case DHT22:
case DHT21:
f = data[0];
f *= 256;
f += data[1];
f *= 0.1;
break;
}
}
return f;
}
//boolean isFahrenheit: True == Fahrenheit; False == Celcius
float DHT::computeHeatIndex(float temperature, float percentHumidity, bool isFahrenheit) {
// Using both Rothfusz and Steadman's equations
// http://www.wpc.ncep.noaa.gov/html/heatindex_equation.shtml
float hi;
if (!isFahrenheit)
temperature = convertCtoF(temperature);
hi = 0.5 * (temperature + 61.0 + ((temperature - 68.0) * 1.2) + (percentHumidity * 0.094));
if (hi > 79) {
hi = -42.379 +
2.04901523 * temperature +
10.14333127 * percentHumidity +
-0.22475541 * temperature*percentHumidity +
-0.00683783 * pow(temperature, 2) +
-0.05481717 * pow(percentHumidity, 2) +
0.00122874 * pow(temperature, 2) * percentHumidity +
0.00085282 * temperature*pow(percentHumidity, 2) +
-0.00000199 * pow(temperature, 2) * pow(percentHumidity, 2);
if((percentHumidity < 13) && (temperature >= 80.0) && (temperature <= 112.0))
hi -= ((13.0 - percentHumidity) * 0.25) * sqrt((17.0 - abs(temperature - 95.0)) * 0.05882);
else if((percentHumidity > 85.0) && (temperature >= 80.0) && (temperature <= 87.0))
hi += ((percentHumidity - 85.0) * 0.1) * ((87.0 - temperature) * 0.2);
}
return isFahrenheit ? hi : convertFtoC(hi);
}
boolean DHT::read(bool force) {
// Check if sensor was read less than two seconds ago and return early
// to use last reading.
uint32_t currenttime = millis();
if (!force && ((currenttime - _lastreadtime) < 2000)) {
return _lastresult; // return last correct measurement
}
_lastreadtime = currenttime;
// Reset 40 bits of received data to zero.
data[0] = data[1] = data[2] = data[3] = data[4] = 0;
// Send start signal. See DHT datasheet for full signal diagram:
// http://www.adafruit.com/datasheets/Digital%20humidity%20and%20temperature%20sensor%20AM2302.pdf
// Go into high impedence state to let pull-up raise data line level and
// start the reading process.
digitalWrite(_pin, HIGH);
delay(250);
// First set data line low for 20 milliseconds.
pinMode(_pin, OUTPUT);
digitalWrite(_pin, LOW);
delay(20);
uint32_t cycles[80];
{
// Turn off interrupts temporarily because the next sections are timing critical
// and we don't want any interruptions.
InterruptLock lock;
// End the start signal by setting data line high for 40 microseconds.
digitalWrite(_pin, HIGH);
delayMicroseconds(40);
// Now start reading the data line to get the value from the DHT sensor.
pinMode(_pin, INPUT_PULLUP);
delayMicroseconds(10); // Delay a bit to let sensor pull data line low.
// First expect a low signal for ~80 microseconds followed by a high signal
// for ~80 microseconds again.
if (expectPulse(LOW) == 0) {
DEBUG_PRINTLN(F("Timeout waiting for start signal low pulse."));
_lastresult = false;
return _lastresult;
}
if (expectPulse(HIGH) == 0) {
DEBUG_PRINTLN(F("Timeout waiting for start signal high pulse."));
_lastresult = false;
return _lastresult;
}
// Now read the 40 bits sent by the sensor. Each bit is sent as a 50
// microsecond low pulse followed by a variable length high pulse. If the
// high pulse is ~28 microseconds then it's a 0 and if it's ~70 microseconds
// then it's a 1. We measure the cycle count of the initial 50us low pulse
// and use that to compare to the cycle count of the high pulse to determine
// if the bit is a 0 (high state cycle count < low state cycle count), or a
// 1 (high state cycle count > low state cycle count). Note that for speed all
// the pulses are read into a array and then examined in a later step.
for (int i=0; i<80; i+=2) {
cycles[i] = expectPulse(LOW);
cycles[i+1] = expectPulse(HIGH);
}
} // Timing critical code is now complete.
// Inspect pulses and determine which ones are 0 (high state cycle count < low
// state cycle count), or 1 (high state cycle count > low state cycle count).
for (int i=0; i<40; ++i) {
uint32_t lowCycles = cycles[2*i];
uint32_t highCycles = cycles[2*i+1];
if ((lowCycles == 0) || (highCycles == 0)) {
DEBUG_PRINTLN(F("Timeout waiting for pulse."));
_lastresult = false;
return _lastresult;
}
data[i/8] <<= 1;
// Now compare the low and high cycle times to see if the bit is a 0 or 1.
if (highCycles > lowCycles) {
// High cycles are greater than 50us low cycle count, must be a 1.
data[i/8] |= 1;
}
// Else high cycles are less than (or equal to, a weird case) the 50us low
// cycle count so this must be a zero. Nothing needs to be changed in the
// stored data.
}
DEBUG_PRINTLN(F("Received:"));
DEBUG_PRINT(data[0], HEX); DEBUG_PRINT(F(", "));
DEBUG_PRINT(data[1], HEX); DEBUG_PRINT(F(", "));
DEBUG_PRINT(data[2], HEX); DEBUG_PRINT(F(", "));
DEBUG_PRINT(data[3], HEX); DEBUG_PRINT(F(", "));
DEBUG_PRINT(data[4], HEX); DEBUG_PRINT(F(" =? "));
DEBUG_PRINTLN((data[0] + data[1] + data[2] + data[3]) & 0xFF, HEX);
// Check we read 40 bits and that the checksum matches.
if (data[4] == ((data[0] + data[1] + data[2] + data[3]) & 0xFF)) {
_lastresult = true;
return _lastresult;
}
else {
DEBUG_PRINTLN(F("Checksum failure!"));
_lastresult = false;
return _lastresult;
}
}
// Expect the signal line to be at the specified level for a period of time and
// return a count of loop cycles spent at that level (this cycle count can be
// used to compare the relative time of two pulses). If more than a millisecond
// ellapses without the level changing then the call fails with a 0 response.
// This is adapted from Arduino's pulseInLong function (which is only available
// in the very latest IDE versions):
// https://github.com/arduino/Arduino/blob/master/hardware/arduino/avr/cores/arduino/wiring_pulse.c
uint32_t DHT::expectPulse(bool level) {
uint32_t count = 0;
// On AVR platforms use direct GPIO port access as it's much faster and better
// for catching pulses that are 10's of microseconds in length:
#ifdef __AVR
uint8_t portState = level ? _bit : 0;
while ((*portInputRegister(_port) & _bit) == portState) {
if (count++ >= _maxcycles) {
return 0; // Exceeded timeout, fail.
}
}
// Otherwise fall back to using digitalRead (this seems to be necessary on ESP8266
// right now, perhaps bugs in direct port access functions?).
#else
while (digitalRead(_pin) == level) {
if (count++ >= _maxcycles) {
return 0; // Exceeded timeout, fail.
}
}
#endif
return count;
}
|
include uXmx86asm.inc
option casemap:none
ifndef __X64__
.686P
.xmm
.model flat, c
else
.X64P
.xmm
option win64:11
option stackbase:rsp
endif
option frame:auto
.code
align 16
uXm_has_POPCNT proto VECCALL (byte)
align 16
uXm_has_POPCNT proc VECCALL (byte)
mov eax, 1
cpuid
and ecx, bit_POPCNT
cmp ecx, bit_POPCNT ; POPCNT support by microprocessor
.if EQUAL?
mov al, true
.else
mov al, false
.endif
ret
uXm_has_POPCNT endp
end ;.code |
; A285543: Decimal representation of the diagonal from the origin to the corner of the n-th stage of growth of the two-dimensional cellular automaton defined by "Rule 35", based on the 5-celled von Neumann neighborhood.
; Submitted by Jon Maiga
; 1,3,6,15,28,63,120,255,496,1023,2016,4095,8128,16383,32640,65535,130816,262143,523776,1048575,2096128,4194303,8386560,16777215,33550336,67108863,134209536,268435455,536854528,1073741823,2147450880,4294967295,8589869056,17179869183,34359607296,68719476735,137438691328,274877906943,549755289600,1099511627775,2199022206976,4398046511103,8796090925056,17592186044415,35184367894528,70368744177663,140737479966720,281474976710655,562949936644096,1125899906842623,2251799780130816,4503599627370495
add $0,1
seq $0,290234 ; Decimal representation of the diagonal from the corner to the origin of the n-th stage of growth of the two-dimensional cellular automaton defined by "Rule 773", based on the 5-celled von Neumann neighborhood.
div $0,2
|
; A220018: Number of cyclotomic cosets of 3 mod 10^n.
; 4,11,29,71,129,203,293,399,521,659,813,983,1169,1371,1589,1823,2073,2339,2621,2919,3233,3563,3909,4271,4649,5043,5453,5879,6321,6779,7253,7743,8249,8771,9309,9863,10433,11019,11621,12239,12873,13523,14189
seq $0,220020 ; Number of cyclotomic cosets of 9 mod 10^n.
add $0,2
div $0,2
|
; A002625: Expansion of 1/((1-x)^3*(1-x^2)^2*(1-x^3)).
; 1,3,8,17,33,58,97,153,233,342,489,681,930,1245,1641,2130,2730,3456,4330,5370,6602,8048,9738,11698,13963,16563,19538,22923,26763,31098,35979,41451,47571,54390,61971,70371,79660,89901,101171,113540,127092,141904,158068,175668,194804,215568,238068,262404,288693,317043,347580,380421,415701,453546,494101,537501,583901,633446,686301,742621,802582,866349,934109,1006038,1082334,1163184,1248798,1339374,1435134,1536288,1643070,1755702,1874431,1999491,2131142,2269631,2415231,2568202,2728831,2897391
mov $2,$0
mov $3,$0
lpb $2
mov $0,$3
sub $2,1
sub $0,$2
seq $0,97701 ; Expansion of 1/((1-x)^2*(1-x^2)^2*(1-x^3)).
add $4,$0
lpe
mov $0,$4
add $0,1
|
; A016999: a(n) = (7*n + 1)^7.
; 1,2097152,170859375,2494357888,17249876309,78364164096,271818611107,781250000000,1954897493193,4398046511104,9095120158391,17565568854912,32057708828125,55784660123648,93206534790699,150363025899136,235260548044817,358318080000000,532875860165503,775771085481344,1107984764452581,1555363874947072,2149422977421875,2928229434235008,3937376385699289,5231047633534976,6873178582377927,8938717390000000,11514990476898413,14703176545910784,18619893262512571,23398900746453632,29192926025390625
mul $0,7
add $0,1
pow $0,7
|
// Copyright 2019 DeepMind Technologies 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.
#include "open_spiel/utils/tensor_view.h"
#include <array>
#include <vector>
#include "open_spiel/spiel_utils.h"
namespace open_spiel {
namespace {
void TestTensorView() {
std::vector<double> values;
SPIEL_CHECK_EQ(values.size(), 0);
TensorView<2> view2(&values, {2, 3}, true);
SPIEL_CHECK_EQ(view2.size(), 6);
SPIEL_CHECK_EQ(values.size(), 6);
SPIEL_CHECK_EQ(view2.rank(), 2);
SPIEL_CHECK_EQ(view2.shape(), (std::array<int, 2>{2, 3}));
SPIEL_CHECK_EQ(view2.shape(0), 2);
SPIEL_CHECK_EQ(view2.shape(1), 3);
// All 0 initialized
for (int i = 0; i < values.size(); ++i) {
SPIEL_CHECK_EQ(values[i], 0);
values[i] = i + 1;
}
// Index correctly
for (int a = 0, i = 0; a < view2.shape(0); ++a) {
for (int b = 0; b < view2.shape(1); ++b, ++i) {
SPIEL_CHECK_EQ(view2.index({a, b}), i);
SPIEL_CHECK_EQ((view2[{a, b}]), i + 1);
view2[{a, b}] = -i;
}
}
// Index correctly
for (int i = 0; i < values.size(); ++i) {
SPIEL_CHECK_EQ(values[i], -i);
}
// Clear works
view2.clear();
for (int i = 0; i < values.size(); ++i) {
SPIEL_CHECK_EQ(values[i], 0);
values[i] = i + 1;
}
// Works for more dimensions
TensorView<3> view3(&values, {4, 2, 3}, true);
SPIEL_CHECK_EQ(view3.size(), 24);
SPIEL_CHECK_EQ(values.size(), 24);
SPIEL_CHECK_EQ(view3.rank(), 3);
SPIEL_CHECK_EQ(view3.shape(), (std::array<int, 3>{4, 2, 3}));
SPIEL_CHECK_EQ(view3.shape(0), 4);
SPIEL_CHECK_EQ(view3.shape(1), 2);
SPIEL_CHECK_EQ(view3.shape(2), 3);
// All 0 initialized
for (int i = 0; i < values.size(); ++i) {
SPIEL_CHECK_EQ(values[i], 0);
values[i] = i + 1;
}
// Index correctly
for (int a = 0, i = 0; a < view3.shape(0); ++a) {
for (int b = 0; b < view3.shape(1); ++b) {
for (int c = 0; c < view3.shape(2); ++c, ++i) {
SPIEL_CHECK_EQ(view3.index({a, b, c}), i);
SPIEL_CHECK_EQ((view3[{a, b, c}]), i + 1);
view3[{a, b, c}] = -i;
}
}
}
// Index correctly
for (int i = 0; i < values.size(); ++i) {
SPIEL_CHECK_EQ(values[i], -i);
}
// Works for a single dimension
TensorView<1> view1(&values, {8}, true);
SPIEL_CHECK_EQ(view1.size(), 8);
SPIEL_CHECK_EQ(values.size(), 8);
SPIEL_CHECK_EQ(view1.rank(), 1);
SPIEL_CHECK_EQ(view1.shape(), (std::array<int, 1>{8}));
SPIEL_CHECK_EQ(view1.shape(0), 8);
// All 0 initialized
for (int i = 0; i < values.size(); ++i) {
SPIEL_CHECK_EQ(values[i], 0);
values[i] = i + 1;
}
// Index correctly
for (int a = 0; a < view1.shape(0); ++a) {
SPIEL_CHECK_EQ(view1.index({a}), a);
SPIEL_CHECK_EQ(view1[{a}], a + 1);
view1[{a}] = -a;
}
// Keeps the previous values.
TensorView<2> view_keep(&values, {2, 4}, false);
SPIEL_CHECK_EQ(view_keep.size(), 8);
SPIEL_CHECK_EQ(values.size(), 8);
SPIEL_CHECK_EQ(view_keep.rank(), 2);
SPIEL_CHECK_EQ(view_keep.shape(), (std::array<int, 2>{2, 4}));
SPIEL_CHECK_EQ(view_keep.shape(0), 2);
SPIEL_CHECK_EQ(view_keep.shape(1), 4);
// Index correctly
for (int a = 0, i = 0; a < view_keep.shape(0); ++a) {
for (int b = 0; b < view_keep.shape(1); ++b, ++i) {
SPIEL_CHECK_EQ(view_keep.index({a, b}), i);
SPIEL_CHECK_EQ((view_keep[{a, b}]), -i);
}
}
}
} // namespace
} // namespace open_spiel
int main(int argc, char** argv) { open_spiel::TestTensorView(); }
|
;;
;;
;; fixslut.asm
;;
;; Copyright 2021 G. Adam Stanislav
;; All rights reserved
;;
;; nasm -fwin32 fixslut.asm
default rel
section .rdata
; We make this public in the hope the Microsoft linker will merge this
; with any identically named constants (the names are produced by MSC).
GLOBAL __real@3df0000000000000
__real@3df0000000000000 dq 03df0000000000000h
section .text
GLOBAL _KOLIBA_FixSlut, _KOLIBA_FixFlut
_KOLIBA_FixFlut:
_KOLIBA_FixSlut:
; On Entry:
;
; [esp+4] = address of KOLIBA_SLUT or KOLIBA_FLUT
;
; On Exit:
;
; eax = same as [esp+4] on entry
mov eax, [esp+4]
sub ecx, ecx
test eax, eax
mov cl, 24
je .done
fld qword [__real@3df0000000000000]
fldz
jmp .loop
align 16, int3
.loop:
fld qword [eax+(ecx-1)*8]
fabs
fcomip st2
jae .next
fst qword [eax+(ecx-1)*8]
.next:
loop .loop
fcompp
.done:
ret
section .drectve info
db '-export:_KOLIBA_FixSlut '
db '-export:_KOLIBA_FixFlut '
|
/*M///////////////////////////////////////////////////////////////////////////////////////
//
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
//
// By downloading, copying, installing or using the software you agree to this license.
// If you do not agree to this license, do not download, install,
// copy or use the software.
//
//
// License Agreement
// For Open Source Computer Vision Library
//
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
// Copyright (C) 2009-2011, Willow Garage Inc., all rights reserved.
// Third party copyrights are property of their respective owners.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// * Redistribution's of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistribution's 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.
//
// * The name of the copyright holders may not 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 Intel Corporation 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.
//
//M*/
#include "precomp.hpp"
#include "opencv2/videostab/wobble_suppression.hpp"
#include "opencv2/videostab/ring_buffer.hpp"
#include BOSS_OPENCV_U_opencv2__core__private_D_cuda_hpp //original-code:"opencv2/core/private.cuda.hpp"
#ifdef HAVE_OPENCV_CUDAWARPING
# include "opencv2/cudawarping.hpp"
#endif
#if defined(HAVE_OPENCV_CUDAWARPING)
#if !defined HAVE_CUDA || defined(CUDA_DISABLER)
namespace cv { namespace cuda {
static void calcWobbleSuppressionMaps(int, int, int, Size, const Mat&, const Mat&, GpuMat&, GpuMat&) { throw_no_cuda(); }
}}
#else
namespace cv { namespace cuda { namespace device { namespace globmotion {
void calcWobbleSuppressionMaps(
int left, int idx, int right, int width, int height,
const float *ml, const float *mr, PtrStepSzf mapx, PtrStepSzf mapy);
}}}}
namespace cv { namespace cuda {
static void calcWobbleSuppressionMaps(
int left, int idx, int right, Size size, const Mat &ml, const Mat &mr,
GpuMat &mapx, GpuMat &mapy)
{
CV_Assert(ml.size() == Size(3, 3) && ml.type() == CV_32F && ml.isContinuous());
CV_Assert(mr.size() == Size(3, 3) && mr.type() == CV_32F && mr.isContinuous());
mapx.create(size, CV_32F);
mapy.create(size, CV_32F);
cv::cuda::device::globmotion::calcWobbleSuppressionMaps(
left, idx, right, size.width, size.height,
ml.ptr<float>(), mr.ptr<float>(), mapx, mapy);
}
}}
#endif
#endif
namespace cv
{
namespace videostab
{
WobbleSuppressorBase::WobbleSuppressorBase() : motions_(0), stabilizationMotions_(0)
{
setMotionEstimator(makePtr<KeypointBasedMotionEstimator>(makePtr<MotionEstimatorRansacL2>(MM_HOMOGRAPHY)));
}
void NullWobbleSuppressor::suppress(int /*idx*/, const Mat &frame, Mat &result)
{
result = frame;
}
void MoreAccurateMotionWobbleSuppressor::suppress(int idx, const Mat &frame, Mat &result)
{
CV_Assert(motions_ && stabilizationMotions_);
if (idx % period_ == 0)
{
result = frame;
return;
}
int k1 = idx / period_ * period_;
int k2 = std::min(k1 + period_, frameCount_ - 1);
Mat S1 = (*stabilizationMotions_)[idx];
Mat_<float> ML = S1 * getMotion(k1, idx, *motions2_) * getMotion(k1, idx, *motions_).inv() * S1.inv();
Mat_<float> MR = S1 * getMotion(idx, k2, *motions2_).inv() * getMotion(idx, k2, *motions_) * S1.inv();
mapx_.create(frame.size());
mapy_.create(frame.size());
float xl, yl, zl, wl;
float xr, yr, zr, wr;
for (int y = 0; y < frame.rows; ++y)
{
for (int x = 0; x < frame.cols; ++x)
{
xl = ML(0,0)*x + ML(0,1)*y + ML(0,2);
yl = ML(1,0)*x + ML(1,1)*y + ML(1,2);
zl = ML(2,0)*x + ML(2,1)*y + ML(2,2);
xl /= zl; yl /= zl;
wl = float(idx - k1);
xr = MR(0,0)*x + MR(0,1)*y + MR(0,2);
yr = MR(1,0)*x + MR(1,1)*y + MR(1,2);
zr = MR(2,0)*x + MR(2,1)*y + MR(2,2);
xr /= zr; yr /= zr;
wr = float(k2 - idx);
mapx_(y,x) = (wr * xl + wl * xr) / (wl + wr);
mapy_(y,x) = (wr * yl + wl * yr) / (wl + wr);
}
}
if (result.data == frame.data)
result = Mat(frame.size(), frame.type());
remap(frame, result, mapx_, mapy_, INTER_LINEAR, BORDER_REPLICATE);
}
#if defined(HAVE_OPENCV_CUDAWARPING)
void MoreAccurateMotionWobbleSuppressorGpu::suppress(int idx, const cuda::GpuMat &frame, cuda::GpuMat &result)
{
CV_Assert(motions_ && stabilizationMotions_);
if (idx % period_ == 0)
{
result = frame;
return;
}
int k1 = idx / period_ * period_;
int k2 = std::min(k1 + period_, frameCount_ - 1);
Mat S1 = (*stabilizationMotions_)[idx];
Mat ML = S1 * getMotion(k1, idx, *motions2_) * getMotion(k1, idx, *motions_).inv() * S1.inv();
Mat MR = S1 * getMotion(idx, k2, *motions2_).inv() * getMotion(idx, k2, *motions_) * S1.inv();
cuda::calcWobbleSuppressionMaps(k1, idx, k2, frame.size(), ML, MR, mapx_, mapy_);
if (result.data == frame.data)
result = cuda::GpuMat(frame.size(), frame.type());
cuda::remap(frame, result, mapx_, mapy_, INTER_LINEAR, BORDER_REPLICATE);
}
void MoreAccurateMotionWobbleSuppressorGpu::suppress(int idx, const Mat &frame, Mat &result)
{
frameDevice_.upload(frame);
suppress(idx, frameDevice_, resultDevice_);
resultDevice_.download(result);
}
#endif
} // namespace videostab
} // namespace cv
|
; A222257: Lexicographically earliest injective sequence of positive integers such that the sum of 6 consecutive terms is always divisible by 6.
; 1,2,3,4,5,9,7,8,15,10,11,21,13,14,27,16,17,33,19,20,39,22,23,45,25,26,51,28,29,57,31,32,63,34,35,69,37,38,75,40,41,81,43,44,87,46,47,93,49,50,99,52,53,105,55,56,111,58,59,117,61,62,123,64,65,129,67,68,135,70,71,141,73
sub $0,2
mov $2,3
gcd $2,$0
mul $2,$0
add $2,5037
add $0,$2
sub $0,5031
div $0,2
|
; A118736: Number of zeros in binary expansion of 3^n.
; Submitted by Christian Krause
; 0,0,2,1,4,2,4,7,7,7,7,5,10,10,9,9,15,13,15,14,15,14,16,15,23,22,18,13,20,21,23,24,25,19,25,24,31,25,25,30,36,26,29,30,36,38,28,37,36,45,39,35,41,50,47,46,50,51,50,46,40,41,50,43,46,53,60,60,53,55,47,45,57,58
seq $0,261547 ; The 3 X 3 X ... X 3 dots problem (3, n times): minimal number of straight lines (connected at their endpoints) required to pass through 3^n dots arranged in a 3 X 3 X ... X 3 grid.
seq $0,23416 ; Number of 0's in binary expansion of n.
|
.global s_prepare_buffers
s_prepare_buffers:
push %r12
push %r13
push %r14
push %rax
push %rcx
push %rdi
push %rdx
push %rsi
lea addresses_UC_ht+0x8891, %rdi
nop
nop
nop
nop
nop
sub %r13, %r13
movups (%rdi), %xmm5
vpextrq $0, %xmm5, %rdx
nop
nop
nop
and %r14, %r14
lea addresses_normal_ht+0x11f9f, %rsi
lea addresses_D_ht+0x6ef, %rdi
nop
nop
and $3865, %r12
mov $67, %rcx
rep movsw
nop
nop
inc %rsi
lea addresses_D_ht+0xa52f, %rsi
lea addresses_D_ht+0x100ef, %rdi
clflush (%rdi)
nop
nop
nop
nop
cmp %rax, %rax
mov $13, %rcx
rep movsw
nop
nop
nop
nop
and %rsi, %rsi
lea addresses_D_ht+0x126ef, %rsi
nop
nop
nop
nop
nop
and $35303, %rdi
mov (%rsi), %rax
cmp $3544, %r12
lea addresses_A_ht+0x132ef, %rdi
nop
nop
cmp $60556, %r14
movw $0x6162, (%rdi)
xor $12611, %r12
pop %rsi
pop %rdx
pop %rdi
pop %rcx
pop %rax
pop %r14
pop %r13
pop %r12
ret
.global s_faulty_load
s_faulty_load:
push %r10
push %r14
push %r15
push %r8
push %rbp
push %rbx
push %rdi
// Store
lea addresses_PSE+0x1ceef, %r10
clflush (%r10)
nop
nop
nop
nop
nop
dec %rdi
movw $0x5152, (%r10)
sub $17775, %rdi
// Store
lea addresses_UC+0x1c1ef, %rbx
dec %r8
mov $0x5152535455565758, %rbp
movq %rbp, (%rbx)
cmp %rbx, %rbx
// Load
lea addresses_PSE+0x116ef, %rbx
nop
sub $38195, %rdi
mov (%rbx), %r14
nop
nop
nop
nop
inc %r14
// Store
lea addresses_A+0x1a5e0, %rbx
nop
nop
cmp %rbp, %rbp
mov $0x5152535455565758, %rdi
movq %rdi, %xmm2
movntdq %xmm2, (%rbx)
nop
nop
inc %rdi
// Load
lea addresses_PSE+0x460f, %rdi
nop
nop
sub $56484, %r8
mov (%rdi), %r15d
nop
and $44569, %rbx
// Faulty Load
lea addresses_PSE+0x116ef, %rbx
clflush (%rbx)
nop
nop
lfence
movb (%rbx), %r15b
lea oracles, %r14
and $0xff, %r15
shlq $12, %r15
mov (%r14,%r15,1), %r15
pop %rdi
pop %rbx
pop %rbp
pop %r8
pop %r15
pop %r14
pop %r10
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 16, 'type': 'addresses_PSE', 'congruent': 0}}
{'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 2, 'type': 'addresses_PSE', 'congruent': 7}, 'OP': 'STOR'}
{'dst': {'same': False, 'NT': False, 'AVXalign': True, 'size': 8, 'type': 'addresses_UC', 'congruent': 8}, 'OP': 'STOR'}
{'OP': 'LOAD', 'src': {'same': True, 'NT': False, 'AVXalign': False, 'size': 8, 'type': 'addresses_PSE', 'congruent': 0}}
{'dst': {'same': False, 'NT': True, 'AVXalign': False, 'size': 16, 'type': 'addresses_A', 'congruent': 0}, 'OP': 'STOR'}
{'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 4, 'type': 'addresses_PSE', 'congruent': 5}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'same': True, 'NT': True, 'AVXalign': True, 'size': 1, 'type': 'addresses_PSE', 'congruent': 0}}
<gen_prepare_buffer>
{'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 16, 'type': 'addresses_UC_ht', 'congruent': 0}}
{'dst': {'same': False, 'congruent': 11, 'type': 'addresses_D_ht'}, 'OP': 'REPM', 'src': {'same': False, 'congruent': 4, 'type': 'addresses_normal_ht'}}
{'dst': {'same': False, 'congruent': 8, 'type': 'addresses_D_ht'}, 'OP': 'REPM', 'src': {'same': False, 'congruent': 5, 'type': 'addresses_D_ht'}}
{'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 8, 'type': 'addresses_D_ht', 'congruent': 11}}
{'dst': {'same': False, 'NT': False, 'AVXalign': True, 'size': 2, 'type': 'addresses_A_ht', 'congruent': 9}, 'OP': 'STOR'}
{'33': 21829}
33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33
*/
|
; AI_SMART prefers these moves during harsh sunlight.
SunnyDayMoves:
dw FIRE_PUNCH
dw EMBER
dw FLAMETHROWER
dw FIRE_SPIN
dw FIRE_BLAST
dw SACRED_FIRE
dw MORNING_SUN
dw SYNTHESIS
dw -1 ; end
|
; /*****************************************************************************
; * ugBASIC - an isomorphic BASIC language compiler for retrocomputers *
; *****************************************************************************
; * Copyright 2021-2022 Marco Spedaletti (asimov@mclink.it)
; *
; * 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.
; *----------------------------------------------------------------------------
; * Concesso in licenza secondo i termini della Licenza Apache, versione 2.0
; * (la "Licenza"); è proibito usare questo file se non in conformità alla
; * Licenza. Una copia della Licenza è disponibile all'indirizzo:
; *
; * http://www.apache.org/licenses/LICENSE-2.0
; *
; * Se non richiesto dalla legislazione vigente o concordato per iscritto,
; * il software distribuito nei termini della Licenza è distribuito
; * "COSì COM'è", SENZA GARANZIE O CONDIZIONI DI ALCUN TIPO, esplicite o
; * implicite. Consultare la Licenza per il testo specifico che regola le
; * autorizzazioni e le limitazioni previste dalla medesima.
; ****************************************************************************/
;* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
;* *
;* IMAGES ROUTINE FOR TED *
;* *
;* by Marco Spedaletti *
;* *
;* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
; ----------------------------------------------------------------------------
; - Put image on bitmap
; ----------------------------------------------------------------------------
GETIMAGE:
LDA CURRENTMODE
; BITMAP_MODE_STANDARD
CMP #2
BNE GETIMAGE2X
JMP GETIMAGE2
GETIMAGE2X:
; BITMAP_MODE_MULTICOLOR
CMP #3
BNE GETIMAGE3X
JMP GETIMAGE3
GETIMAGE3X:
; TILEMAP_MODE_STANDARD
CMP #0
BNE GETIMAGE0X
JMP GETIMAGE0
GETIMAGE0X:
; TILEMAP_MODE_MULTICOLOR
CMP #1
BNE GETIMAGE1X
JMP GETIMAGE1
GETIMAGE1X:
; TILEMAP_MODE_EXTENDED
CMP #4
BNE GETIMAGE4X
JMP GETIMAGE4
GETIMAGE4X:
RTS
GETIMAGE0:
GETIMAGE1:
GETIMAGE4:
RTS
GETIMAGE2:
LDY #0
LDA (TMPPTR),Y
STA IMAGEW
LDY #1
LDA (TMPPTR),Y
LSR
LSR
LSR
STA IMAGEH
STA IMAGEH2
CLC
LDA TMPPTR
ADC #2
STA TMPPTR
LDA TMPPTR+1
ADC #0
STA TMPPTR+1
;-------------------------
;calc Y-cell, divide by 8
;y/8 is y-cell table index
;-------------------------
LDA IMAGEY
LSR ;/ 2
LSR ;/ 4
LSR ;/ 8
TAY ;tbl_8,y index
CLC
;------------------------
;calc X-cell, divide by 8
;divide 2-byte PLOTX / 8
;------------------------
LDA IMAGEX
ROR IMAGEX+1 ;rotate the high byte into carry flag
ROR ;lo byte / 2 (rotate C into low byte)
LSR ;lo byte / 4
LSR ;lo byte / 8
TAX ;tbl_8,x index
;----------------------------------
;add x & y to calc cell point is in
;----------------------------------
CLC
LDA PLOTVBASELO,Y ;table of $A000 row base addresses
ADC PLOT8LO,X ;+ (8 * Xcell)
STA PLOTDEST ;= cell address
LDA PLOTVBASEHI,Y ;do the high byte
ADC PLOT8HI,X
STA PLOTDEST+1
TXA
ADC PLOTCVBASELO,Y ;table of $8400 row base addresses
STA PLOTCDEST ;= cell address
LDA #0
ADC PLOTCVBASEHI,Y ;do the high byte
STA PLOTCDEST+1
TYA
LDA IMAGEW
TAY
DEY
GETIMAGE2L1:
GETIMAGE3L1DEF:
LDA (PLOTDEST),Y
GETIMAGE3L1FINAL:
STA (TMPPTR),Y
DEY
CPY #255
BNE GETIMAGE2L1
CLC
LDA TMPPTR
ADC IMAGEW
STA TMPPTR
LDA TMPPTR+1
ADC #0
STA TMPPTR+1
CLC
LDA PLOTDEST
ADC #$40
STA PLOTDEST
LDA PLOTDEST+1
ADC #$1
STA PLOTDEST+1
DEC IMAGEH
BEQ GETIMAGE2C
LDA IMAGEW
TAY
DEY
JMP GETIMAGE2L1
GETIMAGE2C:
LDA IMAGEH2
STA IMAGEH
LDA IMAGEW
LSR A
LSR A
LSR A
STA IMAGEW
TAY
DEY
GETIMAGE2L2:
LDA (PLOTCDEST),Y
STA (TMPPTR),Y
DEY
CPY #255
BNE GETIMAGE2L2
DEC IMAGEH
BEQ GETIMAGE2E
CLC
LDA TMPPTR
ADC IMAGEW
STA TMPPTR
LDA TMPPTR+1
ADC #0
STA TMPPTR+1
CLC
LDA PLOTCDEST
ADC #40
STA PLOTCDEST
LDA PLOTCDEST+1
ADC #0
STA PLOTCDEST+1
LDA IMAGEW
TAY
DEY
JMP GETIMAGE2L2
GETIMAGE2E:
RTS
;;;;;;;;;;;;;;;;;
GETIMAGE3:
LDY #0
LDA (TMPPTR),Y
STA IMAGEW
LDY #1
LDA (TMPPTR),Y
LSR
LSR
LSR
STA IMAGEH
STA IMAGEH2
CLC
LDA TMPPTR
ADC #2
STA TMPPTR
LDA TMPPTR+1
ADC #0
STA TMPPTR+1
;-------------------------
;calc Y-cell, divide by 8
;y/8 is y-cell table index
;-------------------------
LDA IMAGEY
LSR ;/ 2
LSR ;/ 4
LSR ;/ 8
TAY ;tbl_8,y index
CLC
;------------------------
;calc X-cell, divide by 8
;divide 2-byte PLOTX / 8
;------------------------
LDA IMAGEX
ROR IMAGEX+1 ;rotate the high byte into carry flag
ROR ;lo byte / 2 (rotate C into low byte)
LSR ;lo byte / 4
TAX ;tbl_8,x index
;----------------------------------
;add x & y to calc cell point is in
;----------------------------------
CLC
LDA PLOTVBASELO,Y ;table of $A000 row base addresses
ADC PLOT8LO,X ;+ (8 * Xcell)
STA PLOTDEST ;= cell address
LDA PLOTVBASEHI,Y ;do the high byte
ADC PLOT8HI,X
STA PLOTDEST+1
CLC
TXA
ADC PLOTCVBASELO,Y ;table of $8400 row base addresses
STA PLOTCDEST ;= cell address
LDA #0
ADC PLOTCVBASEHI,Y ;do the high byte
STA PLOTCDEST+1
CLC
TXA
ADC PLOTC2VBASELO,Y ;table of $8400 row base addresses
STA PLOTC2DEST ;= cell address
LDA #0
ADC PLOTC2VBASEHI,Y ;do the high byte
STA PLOTC2DEST+1
LDA IMAGEW
ASL
TAY
DEY
GETIMAGE3L1:
LDA (PLOTDEST),Y
STA (TMPPTR),Y
DEY
CPY #255
BNE GETIMAGE3L1
CLC
LDA TMPPTR
ADC IMAGEW
STA TMPPTR
LDA TMPPTR+1
ADC #0
STA TMPPTR+1
CLC
LDA TMPPTR
ADC IMAGEW
STA TMPPTR
LDA TMPPTR+1
ADC #0
STA TMPPTR+1
CLC
LDA PLOTDEST
ADC #$40
STA PLOTDEST
LDA PLOTDEST+1
ADC #$1
STA PLOTDEST+1
DEC IMAGEH
BEQ GETIMAGE3C
LDA IMAGEW
ASL
TAY
DEY
JMP GETIMAGE3L1
GETIMAGE3C:
LDA IMAGEH2
STA IMAGEH
LDA IMAGEW
LSR A
LSR A
STA IMAGEW
TAY
DEY
GETIMAGE3L2:
LDA (PLOTCDEST),Y
STA (TMPPTR),Y
DEY
CPY #255
BNE GETIMAGE3L2
CLC
LDA TMPPTR
ADC IMAGEW
STA TMPPTR
LDA TMPPTR+1
ADC #0
STA TMPPTR+1
CLC
LDA PLOTCDEST
ADC #40
STA PLOTCDEST
LDA PLOTCDEST+1
ADC #0
STA PLOTCDEST+1
DEC IMAGEH
BEQ GETIMAGE3C2
LDA IMAGEW
TAY
DEY
JMP GETIMAGE3L2
GETIMAGE3C2:
LDA IMAGEH2
STA IMAGEH
LDA IMAGEW
TAY
DEY
GETIMAGE3C2L2:
LDA (PLOTC2DEST),Y
STA (TMPPTR),Y
DEY
CPY #255
BNE GETIMAGE3C2L2
DEC IMAGEH
BEQ GETIMAGE3E
CLC
LDA TMPPTR
ADC IMAGEW
STA TMPPTR
LDA TMPPTR+1
ADC #0
STA TMPPTR+1
CLC
LDA PLOTC2DEST
ADC #40
STA PLOTC2DEST
LDA PLOTC2DEST+1
ADC #0
STA PLOTC2DEST+1
LDA IMAGEW
TAY
DEY
JMP GETIMAGE3C2L2
GETIMAGE3E:
LDY #0
LDA $FF15
STA (TMPPTR),Y
LDA $FF16
LDY #1
STA (TMPPTR),Y
RTS
|
; A055793: Numbers n such that n and floor[n/3] are both squares; i.e., squares which remain squares when written in base 3 and last digit is removed.
; Submitted by Jon Maiga
; 0,1,4,49,676,9409,131044,1825201,25421764,354079489,4931691076,68689595569,956722646884,13325427460801,185599261804324,2585064237799729,36005300067391876,501489136705686529,6984842613812219524,97286307456665386801,1355023461779503195684,18873042157456379352769,262867566742609807743076,3661272892239080929050289,50994952924604523198960964,710268068052224243856403201,9892757999806534890790683844,137788343929239264227213170609,1919144057009543164290193704676,26730228454204365035835498694849
mov $1,1
lpb $0
sub $0,1
add $3,$1
add $2,$3
mov $1,$2
mul $1,2
sub $1,1
lpe
pow $3,2
mov $0,$3
|
; A127932: a(4*n) = 4*n+1, a(4*n+1) = a(4*n+2) = a(4*n+3) = 4*n+4.
; 1,4,4,4,5,8,8,8,9,12,12,12,13,16,16,16,17,20,20,20,21,24,24,24,25,28,28,28,29,32,32,32,33,36,36,36,37,40,40,40,41,44,44,44,45,48,48,48,49,52,52,52,53,56,56,56,57,60,60,60,61,64,64,64,65,68,68,68,69,72,72,72,73,76,76,76,77,80,80,80,81,84,84,84,85,88,88,88,89,92,92,92,93,96,96,96,97,100,100,100,101,104,104,104,105,108,108,108,109,112,112,112,113,116,116,116,117,120,120,120,121,124,124,124,125,128,128,128,129,132,132,132,133,136,136,136,137,140,140,140,141,144,144,144,145,148,148,148,149,152,152,152,153,156,156,156,157,160,160,160,161,164,164,164,165,168,168,168,169,172,172,172,173,176,176,176,177,180,180,180,181,184,184,184,185,188,188,188,189,192,192,192,193,196,196,196,197,200,200,200,201,204,204,204,205,208,208,208,209,212,212,212,213,216,216,216,217,220,220,220,221,224,224,224,225,228,228,228,229,232,232,232,233,236,236,236,237,240,240,240,241,244,244,244,245,248,248,248,249,252
mov $2,$0
lpb $2
mov $1,3
trn $1,$2
trn $2,4
lpe
add $1,1
add $1,$0
|
db "BLIMP@" ; species name
db "It can generate"
next "and release gas"
next "within its body."
page "That's how it can"
next "control the height"
next "of its drift.@"
|
; A247817: Sum(4^k, k=2..n).
; 0,16,80,336,1360,5456,21840,87376,349520,1398096,5592400,22369616,89478480,357913936,1431655760,5726623056,22906492240,91625968976,366503875920,1466015503696,5864062014800,23456248059216,93824992236880,375299968947536,1501199875790160,6004799503160656,24019198012642640,96076792050570576,384307168202282320,1537228672809129296,6148914691236517200,24595658764946068816,98382635059784275280,393530540239137101136,1574122160956548404560,6296488643826193618256,25185954575304774473040
mov $1,4
pow $1,$0
div $1,3
mul $1,16
mov $0,$1
|
;;
;; Copyright (c) 2020-2021, Intel Corporation
;;
;; Redistribution and use in source and binary forms, with or without
;; modification, are permitted provided that the following conditions are met:
;;
;; * Redistributions of source code must retain the above copyright notice,
;; this list of conditions and the following disclaimer.
;; * Redistributions in binary form must reproduce the above copyright
;; notice, this list of conditions and the following disclaimer in the
;; documentation and/or other materials provided with the distribution.
;; * Neither the name of Intel Corporation nor the names of its contributors
;; may be used to endorse or promote products derived from this software
;; without specific prior written permission.
;;
;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
;; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
;; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
;; DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
;; FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
;; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
;; SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
;; CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
;; OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
;; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
;;
;; Authors of original CRC implementation:
;; Erdinc Ozturk
;; Vinodh Gopal
;; James Guilford
;; Greg Tucker
;;
;; Reference paper titled:
;; "Fast CRC Computation for Generic Polynomials Using PCLMULQDQ Instruction"
;; URL: http://download.intel.com/design/intarch/papers/323102.pdf
%include "include/os.asm"
%include "include/memcpy.asm"
%include "include/reg_sizes.asm"
%include "include/crc32.inc"
%ifndef CRC32_FN
%define CRC32_FN crc32_by8_sse
%endif
[bits 64]
default rel
%ifdef LINUX
%define arg1 rdi
%define arg2 rsi
%define arg3 rdx
%define arg4 rcx
%else
%define arg1 rcx
%define arg2 rdx
%define arg3 r8
%define arg4 r9
%endif
mksection .text
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; arg1 - initial CRC value (32 bits)
;; arg2 - buffer pointer
;; arg3 - buffer size
;; arg4 - pointer to CRC constants
;; Returns CRC value through EAX
align 32
MKGLOBAL(CRC32_FN,function,internal)
CRC32_FN:
;; check if smaller than 256B
cmp arg3, 256
jl .less_than_256
;; load the initial crc value
movd xmm10, DWORD(arg1) ; initial crc
;; CRC value does not need to be byte-reflected here.
;; It needs to be moved to the high part of the register.
pslldq xmm10, 12
movdqa xmm11, [rel SHUF_MASK]
;; load initial 128B data, xor the initial crc value
movdqu xmm0, [arg2 + 16 * 0]
movdqu xmm1, [arg2 + 16 * 1]
movdqu xmm2, [arg2 + 16 * 2]
movdqu xmm3, [arg2 + 16 * 3]
movdqu xmm4, [arg2 + 16 * 4]
movdqu xmm5, [arg2 + 16 * 5]
movdqu xmm6, [arg2 + 16 * 6]
movdqu xmm7, [arg2 + 16 * 7]
;; XOR the initial_crc value and shuffle the data
pshufb xmm0, xmm11
pxor xmm0, xmm10
pshufb xmm1, xmm11
pshufb xmm2, xmm11
pshufb xmm3, xmm11
pshufb xmm4, xmm11
pshufb xmm5, xmm11
pshufb xmm6, xmm11
pshufb xmm7, xmm11
movdqa xmm10, [arg4 + crc32_const_fold_8x128b]
;; subtract 256 instead of 128 to save one instruction from the loop
sub arg3, 256
;; In this section of the code, there is ((128 * x) + y) bytes of buffer
;; where, 0 <= y < 128.
;; The fold_128_B_loop loop will fold 128 bytes at a time until
;; there is (128 + y) bytes of buffer left
;; Fold 128 bytes at a time.
;; This section of the code folds 8 xmm registers in parallel
.fold_128_B_loop:
add arg2, 128
movdqu xmm9, [arg2 + 16 * 0]
movdqu xmm12, [arg2 + 16 * 1]
pshufb xmm9, xmm11
pshufb xmm12, xmm11
movdqa xmm8, xmm0
pclmulqdq xmm8, xmm10, 0x11
pclmulqdq xmm0, xmm10 , 0x00
movdqa xmm13, xmm1
pclmulqdq xmm13, xmm10, 0x11
pclmulqdq xmm1, xmm10 , 0x00
pxor xmm0, xmm9
xorps xmm0, xmm8
pxor xmm1, xmm12
xorps xmm1, xmm13
movdqu xmm9, [arg2 + 16 * 2]
movdqu xmm12, [arg2 + 16 * 3]
pshufb xmm9, xmm11
pshufb xmm12, xmm11
movdqa xmm8, xmm2
pclmulqdq xmm8, xmm10, 0x11
pclmulqdq xmm2, xmm10 , 0x00
movdqa xmm13, xmm3
pclmulqdq xmm13, xmm10, 0x11
pclmulqdq xmm3, xmm10 , 0x00
pxor xmm2, xmm9
xorps xmm2, xmm8
pxor xmm3, xmm12
xorps xmm3, xmm13
movdqu xmm9, [arg2 + 16 * 4]
movdqu xmm12, [arg2 + 16 * 5]
pshufb xmm9, xmm11
pshufb xmm12, xmm11
movdqa xmm8, xmm4
pclmulqdq xmm8, xmm10, 0x11
pclmulqdq xmm4, xmm10 , 0x00
movdqa xmm13, xmm5
pclmulqdq xmm13, xmm10, 0x11
pclmulqdq xmm5, xmm10 , 0x00
pxor xmm4, xmm9
xorps xmm4, xmm8
pxor xmm5, xmm12
xorps xmm5, xmm13
movdqu xmm9, [arg2 + 16 * 6]
movdqu xmm12, [arg2 + 16 * 7]
pshufb xmm9, xmm11
pshufb xmm12, xmm11
movdqa xmm8, xmm6
pclmulqdq xmm8, xmm10, 0x11
pclmulqdq xmm6, xmm10 , 0x00
movdqa xmm13, xmm7
pclmulqdq xmm13, xmm10, 0x11
pclmulqdq xmm7, xmm10 , 0x00
pxor xmm6, xmm9
xorps xmm6, xmm8
pxor xmm7, xmm12
xorps xmm7, xmm13
sub arg3, 128
jge .fold_128_B_loop
add arg2, 128
;; At this point, the buffer pointer is pointing at the last
;; y bytes of the buffer, where 0 <= y < 128.
;; The 128B of folded data is in 8 of the xmm registers:
;; xmm0, xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7
;; fold the 8 xmm registers into 1 xmm register with different constants
movdqa xmm10, [arg4 + crc32_const_fold_7x128b]
movdqa xmm8, xmm0
pclmulqdq xmm8, xmm10, 0x11
pclmulqdq xmm0, xmm10, 0x00
pxor xmm7, xmm8
xorps xmm7, xmm0
movdqa xmm10, [arg4 + crc32_const_fold_6x128b]
movdqa xmm8, xmm1
pclmulqdq xmm8, xmm10, 0x11
pclmulqdq xmm1, xmm10, 0x00
pxor xmm7, xmm8
xorps xmm7, xmm1
movdqa xmm10, [arg4 + crc32_const_fold_5x128b]
movdqa xmm8, xmm2
pclmulqdq xmm8, xmm10, 0x11
pclmulqdq xmm2, xmm10, 0x00
pxor xmm7, xmm8
pxor xmm7, xmm2
movdqa xmm10, [arg4 + crc32_const_fold_4x128b]
movdqa xmm8, xmm3
pclmulqdq xmm8, xmm10, 0x11
pclmulqdq xmm3, xmm10, 0x00
pxor xmm7, xmm8
xorps xmm7, xmm3
movdqa xmm10, [arg4 + crc32_const_fold_3x128b]
movdqa xmm8, xmm4
pclmulqdq xmm8, xmm10, 0x11
pclmulqdq xmm4, xmm10, 0x00
pxor xmm7, xmm8
pxor xmm7, xmm4
movdqa xmm10, [arg4 + crc32_const_fold_2x128b]
movdqa xmm8, xmm5
pclmulqdq xmm8, xmm10, 0x11
pclmulqdq xmm5, xmm10, 0x00
pxor xmm7, xmm8
xorps xmm7, xmm5
movdqa xmm10, [arg4 + crc32_const_fold_1x128b]
movdqa xmm8, xmm6
pclmulqdq xmm8, xmm10, 0x11
pclmulqdq xmm6, xmm10, 0x00
pxor xmm7, xmm8
pxor xmm7, xmm6
;; Instead of 128, we add 128-16 to the loop counter to save 1
;; instruction from the loop below.
;; Instead of a cmp instruction, we use the negative flag with the jl instruction
add arg3, 128 - 16
jl .final_reduction_for_128
;; There are 16 + y bytes left to reduce.
;; 16 bytes is in register xmm7 and the rest is in memory
;; we can fold 16 bytes at a time if y>=16
;; continue folding 16B at a time
.16B_reduction_loop:
movdqa xmm8, xmm7
pclmulqdq xmm8, xmm10, 0x11
pclmulqdq xmm7, xmm10, 0x00
pxor xmm7, xmm8
movdqu xmm0, [arg2]
pshufb xmm0, xmm11
pxor xmm7, xmm0
add arg2, 16
sub arg3, 16
;; Instead of a cmp instruction, we utilize the flags with the jge instruction.
;; Equivalent of check if there is any more 16B in the buffer to be folded.
jge .16B_reduction_loop
;; Now we have 16+z bytes left to reduce, where 0<= z < 16.
;; First, we reduce the data in the xmm7 register
.final_reduction_for_128:
add arg3, 16
je .128_done
;; Here we are getting data that is less than 16 bytes.
;; Since we know that there was data before the pointer, we can offset
;; the input pointer before the actual point, to receive exactly 16 bytes.
;; After that the registers need to be adjusted.
.get_last_two_xmms:
movdqa xmm2, xmm7
movdqu xmm1, [arg2 - 16 + arg3]
pshufb xmm1, xmm11
;; Get rid of the extra data that was loaded before.
;; Load the shift constant.
lea rax, [rel pshufb_shf_table + 16]
sub rax, arg3
movdqu xmm0, [rax]
pshufb xmm2, xmm0
;; shift xmm7 to the right by 16-arg3 bytes
pxor xmm0, [rel mask1]
pshufb xmm7, xmm0
pblendvb xmm1, xmm2 ;xmm0 is implicit
;; fold 16 Bytes
movdqa xmm2, xmm1
movdqa xmm8, xmm7
pclmulqdq xmm7, xmm10, 0x11
pclmulqdq xmm8, xmm10, 0x00
pxor xmm7, xmm8
pxor xmm7, xmm2
.128_done:
;; compute crc of a 128-bit value
movdqa xmm10, [arg4 + crc32_const_fold_128b_to_64b]
movdqa xmm0, xmm7
;; 64b fold
pclmulqdq xmm7, xmm10, 0x1
pslldq xmm0, 8
pxor xmm7, xmm0
;; 32b fold
movdqa xmm0, xmm7
pand xmm0, [rel mask2]
psrldq xmm7, 12
pclmulqdq xmm7, xmm10, 0x10
pxor xmm7, xmm0
;; barrett reduction
.barrett:
movdqa xmm10, [arg4 + crc32_const_reduce_64b_to_32b]
movdqa xmm0, xmm7
pclmulqdq xmm7, xmm10, 0x01
pslldq xmm7, 4
pclmulqdq xmm7, xmm10, 0x11
pslldq xmm7, 4
pxor xmm7, xmm0
pextrd eax, xmm7, 1
.cleanup:
ret
align 32
.less_than_256:
movdqa xmm11, [rel SHUF_MASK]
;; check if there is enough buffer to be able to fold 16B at a time
cmp arg3, 32
jl .less_than_32
;; if there is, load the constants
movdqa xmm10, [arg4 + crc32_const_fold_1x128b]
movd xmm0, DWORD(arg1) ; get the initial crc value
pslldq xmm0, 12 ; align it to its correct place
movdqu xmm7, [arg2] ; load the plaintext
pshufb xmm7, xmm11 ; byte reflect
pxor xmm7, xmm0
;; update the buffer pointer
add arg2, 16
;; update the counter
;; - subtract 32 instead of 16 to save one instruction from the loop
sub arg3, 32
jmp .16B_reduction_loop
align 32
.less_than_32:
;; Move initial crc to the return value.
;; This is necessary for zero-length buffers.
mov eax, DWORD(arg1)
test arg3, arg3
je .cleanup
movd xmm0, DWORD(arg1) ; get the initial crc value
pslldq xmm0, 12 ; align it to its correct place
cmp arg3, 16
je .exact_16_left
jl .less_than_16_left
movdqu xmm7, [arg2] ; load the plaintext
pshufb xmm7, xmm11 ; byte reflect
pxor xmm7, xmm0 ; xor the initial crc value
add arg2, 16
sub arg3, 16
movdqa xmm10, [arg4 + crc32_const_fold_1x128b]
jmp .get_last_two_xmms
align 32
.less_than_16_left:
simd_load_sse_15_1 xmm7, arg2, arg3
pshufb xmm7, xmm11 ; byte reflect
pxor xmm7, xmm0 ; xor the initial crc value
cmp arg3, 4
jl .only_less_than_4
lea rax, [rel pshufb_shf_table + 16]
sub rax, arg3
movdqu xmm0, [rax]
pxor xmm0, [rel mask1]
pshufb xmm7, xmm0
jmp .128_done
align 32
.exact_16_left:
movdqu xmm7, [arg2]
pshufb xmm7, xmm11 ; byte reflect
pxor xmm7, xmm0 ; xor the initial crc value
jmp .128_done
.only_less_than_4:
cmp arg3, 3
jl .only_less_than_3
psrldq xmm7, 5
jmp .barrett
.only_less_than_3:
cmp arg3, 2
jl .only_less_than_2
psrldq xmm7, 6
jmp .barrett
.only_less_than_2:
psrldq xmm7, 7
jmp .barrett
mksection .rodata
align 16
mask1:
dq 0x8080808080808080, 0x8080808080808080
align 16
mask2:
dq 0xFFFFFFFFFFFFFFFF, 0x00000000FFFFFFFF
align 16
pshufb_shf_table:
;; use these values for shift constants for the pshufb instruction
dq 0x8786858483828100, 0x8f8e8d8c8b8a8988
dq 0x0706050403020100, 0x000e0d0c0b0a0908
align 16
SHUF_MASK:
dq 0x08090A0B0C0D0E0F, 0x0001020304050607
mksection stack-noexec
|
; A136395: Binomial transform of [1, 3, 4, 3, 2, 0, 0, 0,...].
; 1,4,11,25,51,96,169,281,445,676,991,1409,1951,2640,3501,4561,5849,7396,9235,11401,13931,16864,20241,24105,28501,33476,39079,45361,52375,60176,68821,78369,88881,100420,113051,126841,141859,158176,175865,195001,215661,237924,261871,287585,315151,344656,376189,409841,445705,483876,524451,567529,613211,661600,712801,766921,824069,884356,947895,1014801,1085191,1159184,1236901,1318465,1404001,1493636,1587499,1685721,1788435,1895776,2007881,2124889,2246941,2374180,2506751,2644801,2788479,2937936,3093325,3254801,3422521,3596644,3777331,3964745,4159051,4360416,4569009,4785001,5008565,5239876,5479111,5726449,5982071,6246160,6518901,6800481,7091089,7390916,7700155,8019001,8347651,8686304,9035161,9394425,9764301,10144996,10536719,10939681,11354095,11780176,12218141,12668209,13130601,13605540,14093251,14593961,15107899,15635296,16176385,16731401,17300581,17884164,18482391,19095505,19723751,20367376,21026629,21701761,22393025,23100676,23824971,24566169,25324531,26100320,26893801,27705241,28534909,29383076,30250015,31136001,32041311,32966224,33911021,34875985,35861401,36867556,37894739,38943241,40013355,41105376,42219601,43356329,44515861,45698500,46904551,48134321,49388119,50666256,51969045,53296801,54649841,56028484,57433051,58863865,60321251,61805536,63317049,64856121,66423085,68018276,69642031,71294689,72976591,74688080,76429501,78201201,80003529,81836836,83701475,85597801,87526171,89486944,91480481,93507145,95567301,97661316,99789559,101952401,104150215,106383376,108652261,110957249,113298721,115677060,118092651,120545881,123037139,125566816,128135305,130743001,133390301,136077604,138805311,141573825,144383551,147234896,150128269,153064081,156042745,159064676,162130291,165240009,168394251,171593440,174838001,178128361,181464949,184848196,188278535,191756401,195282231,198856464,202479541,206151905,209874001,213646276,217469179,221343161,225268675,229246176,233276121,237358969,241495181,245685220,249929551,254228641,258582959,262992976,267459165,271982001,276561961,281199524,285895171,290649385,295462651,300335456,305268289,310261641,315316005,320431876
mov $1,$0
bin $0,2
add $1,$0
add $0,9
mul $1,2
mul $1,$0
div $1,6
add $1,1
|
.macosx_version_min 10, 11
.section __TEXT,__text,regular,pure_instructions
.align 4, 0x90
.globl _main
_main:
testl %edx, %ebx
testl 4(%ebp), %edx
testl 4(%ebp), %edx
testb %dh, %dl
testb $32, 1(%edx,%ecx,2)
testl $32896, %eax
xchgl %edx, %ebx
xchgl %edx, 4(%ebp)
xchgl %edx, 4(%ebp)
imull $31, %eax, %eax
imull $31, %eax, %eax
ret
# ----------------------
.subsections_via_symbols
|
//
// Created by noah on 01-02-20.
//
#include <string>
#include <iostream>
#include <sstream>
std::string uint128_str(__uint128_t v) {
uint64_t high = v>>64;
uint64_t low = v&(0xFFFFFFFFFFFFFFFF);
std::ostringstream oss;
oss << high << " " << low;
return oss.str();
}
__uint128_t str_uint128(std::string v) {
std::stringstream ss;
ss << v;
__uint128_t res = 0;
uint64_t high, low;
ss >> high >> low;
res = high;
return (res<<64) | low;
}
|
.data
a:
70
80
40
20
10
30
50
60
n:
8
.text
// your code here
// you may change the numbers in the array, and the size of the array; but allow the name of the array to remain as 'a', and size as 'n'
// remove these comments!
|
; Pic animation arrangement.
Unused_AnimateMon_Slow_Normal:
hlcoord 12, 0
ld a, [wBattleMode]
cp WILD_BATTLE
jr z, .wild
ld e, ANIM_MON_SLOW
ld d, $0
call AnimateFrontpic
ret
.wild
ld e, ANIM_MON_NORMAL
ld d, $0
call AnimateFrontpic
ret
AnimateMon_Menu:
ld e, ANIM_MON_MENU
ld d, $0
call AnimateFrontpic
ret
AnimateMon_Trade:
ld e, ANIM_MON_TRADE
ld d, $0
call AnimateFrontpic
ret
AnimateMon_Evolve:
ld e, ANIM_MON_EVOLVE
ld d, $0
call AnimateFrontpic
ret
AnimateMon_Hatch:
ld e, ANIM_MON_HATCH
ld d, $0
call AnimateFrontpic
ret
AnimateMon_HOF:
ld e, ANIM_MON_HOF
ld d, $0
call AnimateFrontpic
ret
pokeanim: MACRO
rept _NARG
; Workaround for a bug where macro args can't come after the start of a symbol
if !DEF(\1_POKEANIM)
\1_POKEANIM EQUS "PokeAnim_\1_"
endc
db (\1_POKEANIM - PokeAnim_SetupCommands) / 2
shift
endr
db (PokeAnim_Finish_ - PokeAnim_SetupCommands) / 2
ENDM
PokeAnims:
; entries correspond to ANIM_MON_* constants
dw .Slow
dw .Normal
dw .Menu
dw .Trade
dw .Evolve
dw .Hatch
dw .HOF
dw .Egg1
dw .Egg2
.Slow: pokeanim StereoCry, Setup2, Play
.Normal: pokeanim StereoCry, Setup, Play
.Menu: pokeanim CryNoWait, Setup, Play, SetWait, Wait, Idle, Play
.Trade: pokeanim Idle, Play2, Idle, Play, SetWait, Wait, Cry, Setup, Play
.Evolve: pokeanim Idle, Play, SetWait, Wait, CryNoWait, Setup, Play
.Hatch: pokeanim Idle, Play, CryNoWait, Setup, Play, SetWait, Wait, Idle, Play
.HOF: pokeanim CryNoWait, Setup, Play, SetWait, Wait, Idle, Play
.Egg1: pokeanim Setup, Play
.Egg2: pokeanim Idle, Play
AnimateFrontpic:
call AnimateMon_CheckIfPokemon
ret c
call LoadMonAnimation
.loop
call SetUpPokeAnim
push af
farcall HDMATransferTileMapToWRAMBank3
pop af
jr nc, .loop
ret
LoadMonAnimation:
push hl
ld c, e
ld b, 0
ld hl, PokeAnims
add hl, bc
add hl, bc
ld a, [hli]
ld b, [hl]
ld c, a
pop hl
call PokeAnim_InitPicAttributes
ret
SetUpPokeAnim:
ldh a, [rSVBK]
push af
ld a, BANK(wPokeAnimStruct)
ldh [rSVBK], a
ld a, [wPokeAnimSceneIndex]
ld c, a
ld b, 0
ld hl, wPokeAnimPointer
ld a, [hli]
ld h, [hl]
ld l, a
add hl, bc
ld a, [hl]
ld hl, PokeAnim_SetupCommands
rst JumpTable
ld a, [wPokeAnimSceneIndex]
ld c, a
pop af
ldh [rSVBK], a
ld a, c
and $80
ret z
scf
ret
PokeAnim_SetupCommands:
setup_command: MACRO
\1_: dw \1
ENDM
setup_command PokeAnim_Finish
setup_command PokeAnim_BasePic
setup_command PokeAnim_SetWait
setup_command PokeAnim_Wait
setup_command PokeAnim_Setup
setup_command PokeAnim_Setup2
setup_command PokeAnim_Idle
setup_command PokeAnim_Play
setup_command PokeAnim_Play2
setup_command PokeAnim_Cry
setup_command PokeAnim_CryNoWait
setup_command PokeAnim_StereoCry
PokeAnim_SetWait:
ld a, 18
ld [wPokeAnimWaitCounter], a
ld a, [wPokeAnimSceneIndex]
inc a
ld [wPokeAnimSceneIndex], a
PokeAnim_Wait:
ld hl, wPokeAnimWaitCounter
dec [hl]
ret nz
ld a, [wPokeAnimSceneIndex]
inc a
ld [wPokeAnimSceneIndex], a
ret
PokeAnim_Setup:
ld c, FALSE
ld b, 0
call PokeAnim_InitAnim
call PokeAnim_SetVBank1
ld a, [wPokeAnimSceneIndex]
inc a
ld [wPokeAnimSceneIndex], a
ret
PokeAnim_Setup2:
ld c, FALSE
ld b, 4
call PokeAnim_InitAnim
call PokeAnim_SetVBank1
ld a, [wPokeAnimSceneIndex]
inc a
ld [wPokeAnimSceneIndex], a
ret
PokeAnim_Idle:
ld c, TRUE
ld b, 0
call PokeAnim_InitAnim
call PokeAnim_SetVBank1
ld a, [wPokeAnimSceneIndex]
inc a
ld [wPokeAnimSceneIndex], a
ret
PokeAnim_Play:
call PokeAnim_DoAnimScript
ld a, [wPokeAnimJumptableIndex]
bit 7, a
ret z
call PokeAnim_PlaceGraphic
ld a, [wPokeAnimSceneIndex]
inc a
ld [wPokeAnimSceneIndex], a
ret
PokeAnim_Play2:
call PokeAnim_DoAnimScript
ld a, [wPokeAnimJumptableIndex]
bit 7, a
ret z
ld a, [wPokeAnimSceneIndex]
inc a
ld [wPokeAnimSceneIndex], a
ret
PokeAnim_BasePic:
call PokeAnim_DeinitFrames
ld a, [wPokeAnimSceneIndex]
inc a
ld [wPokeAnimSceneIndex], a
ret
PokeAnim_Finish:
call PokeAnim_DeinitFrames
ld hl, wPokeAnimSceneIndex
set 7, [hl]
ret
PokeAnim_Cry:
ld a, [wPokeAnimSpecies]
call _PlayMonCry
ld a, [wPokeAnimSceneIndex]
inc a
ld [wPokeAnimSceneIndex], a
ret
PokeAnim_CryNoWait:
ld a, [wPokeAnimSpecies]
call PlayMonCry2
ld a, [wPokeAnimSceneIndex]
inc a
ld [wPokeAnimSceneIndex], a
ret
PokeAnim_StereoCry:
ld a, $f
ld [wCryTracks], a
ld a, [wPokeAnimSpecies]
call PlayStereoCry2
ld a, [wPokeAnimSceneIndex]
inc a
ld [wPokeAnimSceneIndex], a
ret
PokeAnim_DeinitFrames:
ldh a, [rSVBK]
push af
ld a, BANK(wPokeAnimCoord)
ldh [rSVBK], a
call PokeAnim_PlaceGraphic
farcall HDMATransferTileMapToWRAMBank3
call PokeAnim_SetVBank0
farcall HDMATransferAttrMapToWRAMBank3
pop af
ldh [rSVBK], a
ret
AnimateMon_CheckIfPokemon:
ld a, [wCurPartySpecies]
cp EGG
jr z, .fail
call IsAPokemon
jr c, .fail
and a
ret
.fail
scf
ret
PokeAnim_InitPicAttributes:
ldh a, [rSVBK]
push af
ld a, BANK(wPokeAnimStruct)
ldh [rSVBK], a
push bc
push de
push hl
ld hl, wPokeAnimStruct
ld bc, wPokeAnimStructEnd - wPokeAnimStruct
xor a
call ByteFill
pop hl
pop de
pop bc
; bc contains anim pointer
ld a, c
ld [wPokeAnimPointer], a
ld a, b
ld [wPokeAnimPointer + 1], a
; hl contains tilemap coords
ld a, l
ld [wPokeAnimCoord], a
ld a, h
ld [wPokeAnimCoord + 1], a
; d = start tile
ld a, d
ld [wPokeAnimGraphicStartTile], a
ld a, BANK(wCurPartySpecies)
ld hl, wCurPartySpecies
call GetFarWRAMByte
ld [wPokeAnimSpecies], a
ld a, BANK(wUnownLetter)
ld hl, wUnownLetter
call GetFarWRAMByte
ld [wPokeAnimUnownLetter], a
call PokeAnim_GetSpeciesOrUnown
ld [wPokeAnimSpeciesOrUnown], a
call PokeAnim_GetFrontpicDims
ld a, c
ld [wPokeAnimFrontpicHeight], a
pop af
ldh [rSVBK], a
ret
PokeAnim_InitAnim:
ldh a, [rSVBK]
push af
ld a, BANK(wPokeAnimIdleFlag)
ldh [rSVBK], a
push bc
ld hl, wPokeAnimIdleFlag
ld bc, wPokeAnimStructEnd - wPokeAnimIdleFlag
xor a
call ByteFill
pop bc
ld a, b
ld [wPokeAnimSpeed], a
ld a, c
ld [wPokeAnimIdleFlag], a
call GetMonAnimPointer
call GetMonFramesPointer
call GetMonBitmaskPointer
pop af
ldh [rSVBK], a
ret
PokeAnim_DoAnimScript:
xor a
ldh [hBGMapMode], a
.loop
ld a, [wPokeAnimJumptableIndex]
and $7f
ld hl, .Jumptable
rst JumpTable
ret
.Jumptable:
dw .RunAnim
dw .WaitAnim
.RunAnim:
call PokeAnim_GetPointer
ld a, [wPokeAnimCommand]
cp endanim_command
jr z, PokeAnim_End
cp setrepeat_command
jr z, .SetRepeat
cp dorepeat_command
jr z, .DoRepeat
call PokeAnim_GetFrame
ld a, [wPokeAnimParameter]
call PokeAnim_GetDuration
ld [wPokeAnimWaitCounter], a
call PokeAnim_StartWaitAnim
.WaitAnim:
ld a, [wPokeAnimWaitCounter]
dec a
ld [wPokeAnimWaitCounter], a
ret nz
call PokeAnim_StopWaitAnim
ret
.SetRepeat:
ld a, [wPokeAnimParameter]
ld [wPokeAnimRepeatTimer], a
jr .loop
.DoRepeat:
ld a, [wPokeAnimRepeatTimer]
and a
ret z
dec a
ld [wPokeAnimRepeatTimer], a
ret z
ld a, [wPokeAnimParameter]
ld [wPokeAnimFrame], a
jr .loop
PokeAnim_End:
ld hl, wPokeAnimJumptableIndex
set 7, [hl]
ret
PokeAnim_GetDuration:
; a * (1 + [wPokeAnimSpeed] / 16)
ld c, a
ld b, $0
ld hl, 0
ld a, [wPokeAnimSpeed]
call AddNTimes
ld a, h
swap a
and $f0
ld h, a
ld a, l
swap a
and $f
or h
add c
ret
PokeAnim_GetFrame:
call PokeAnim_PlaceGraphic
ld a, [wPokeAnimCommand]
and a
ret z
call PokeAnim_GetBitmaskIndex
push hl
call PokeAnim_CopyBitmaskToBuffer
pop hl
call PokeAnim_ConvertAndApplyBitmask
ret
PokeAnim_StartWaitAnim:
ld a, [wPokeAnimJumptableIndex]
inc a
ld [wPokeAnimJumptableIndex], a
ret
PokeAnim_StopWaitAnim:
ld a, [wPokeAnimJumptableIndex]
dec a
ld [wPokeAnimJumptableIndex], a
ret
PokeAnim_IsUnown:
ld a, [wPokeAnimSpecies]
push hl
call GetPokemonIndexFromID
ld a, l
cp LOW(UNOWN)
ld a, h
pop hl
ret nz
if HIGH(UNOWN) == 0
and a
elif HIGH(UNOWN) == 1
dec a
else
cp HIGH(UNOWN)
endc
ret
PokeAnim_IsEgg:
ld a, [wPokeAnimSpecies]
cp EGG
ret
PokeAnim_GetPointer:
push hl
ld a, [wPokeAnimFrame]
ld e, a
ld d, $0
ld hl, wPokeAnimPointerAddr
ld a, [hli]
ld h, [hl]
ld l, a
add hl, de
add hl, de
ld a, [wPokeAnimPointerBank]
call GetFarHalfword
ld a, l
ld [wPokeAnimCommand], a
ld a, h
ld [wPokeAnimParameter], a
ld hl, wPokeAnimFrame
inc [hl]
pop hl
ret
PokeAnim_GetBitmaskIndex:
ld a, [wPokeAnimCommand]
dec a
ld c, a
ld b, $0
ld hl, wPokeAnimFramesAddr
ld a, [hli]
ld h, [hl]
ld l, a
add hl, bc
add hl, bc
ld a, [wPokeAnimFramesBank]
call GetFarHalfword
ld a, [wPokeAnimFramesBank]
call GetFarByte
ld [wPokeAnimCurBitmask], a
inc hl
ret
PokeAnim_CopyBitmaskToBuffer:
call .GetSize
push bc
ld hl, wPokeAnimBitmaskAddr
ld a, [hli]
ld h, [hl]
ld l, a
ld a, [wPokeAnimCurBitmask]
call AddNTimes
pop bc
ld de, wPokeAnimBitmaskBuffer
ld a, [wPokeAnimBitmaskBank]
call FarCopyBytes
ret
.GetSize:
push hl
ld a, [wPokeAnimFrontpicHeight]
sub 5 ; to get a number 0, 1, or 2
ld c, a
ld b, 0
ld hl, .Sizes
add hl, bc
ld c, [hl]
ld b, 0
pop hl
ret
.Sizes: db 4, 5, 7
poke_anim_box: MACRO
y = 7
rept \1
x = 7 + -\1
rept \1
db x + y
x = x + 1
endr
y = y + 7
endr
ENDM
PokeAnim_ConvertAndApplyBitmask:
xor a
ld [wPokeAnimBitmaskCurBit], a
ld [wPokeAnimBitmaskCurRow], a
ld [wPokeAnimBitmaskCurCol], a
.loop
push hl
call .IsCurBitSet
pop hl
ld a, b
and a
jr z, .next
ld a, [wPokeAnimFramesBank]
call GetFarByte
inc hl
push hl
call .ApplyFrame
pop hl
.next
push hl
call .NextBit
pop hl
jr nc, .loop
ret
.IsCurBitSet:
; which byte
ld a, [wPokeAnimBitmaskCurBit]
and $f8
rrca
rrca
rrca
ld e, a
ld d, 0
ld hl, wPokeAnimBitmaskBuffer
add hl, de
ld b, [hl]
; which bit
ld a, [wPokeAnimBitmaskCurBit]
and $7
jr z, .skip
ld c, a
ld a, b
.loop2
rrca
dec c
jr nz, .loop2
ld b, a
.skip
xor a
bit 0, b
jr z, .finish
ld a, 1
.finish
ld b, a
ld hl, wPokeAnimBitmaskCurBit
inc [hl]
ret
.ApplyFrame:
push af
call .GetCoord
pop af
push hl
call .GetTilemap
ld hl, wPokeAnimGraphicStartTile
add [hl]
pop hl
cp $7f
sbc -1 ;increment if no carry
ld [hl], a
ret
.GetCoord:
call .GetStartCoord
ld a, [wPokeAnimBitmaskCurRow]
ld bc, SCREEN_WIDTH
call AddNTimes
ld a, [wBoxAlignment]
and a
jr nz, .go
ld a, [wPokeAnimBitmaskCurCol]
ld e, a
ld d, 0
add hl, de
jr .skip2
.go
ld a, [wPokeAnimBitmaskCurCol]
ld e, a
ld a, l
sub e
ld l, a
ld a, h
sbc 0
ld h, a
.skip2
ret
; unused
db 6, 5, 4
.GetTilemap:
push af
ld a, [wPokeAnimFrontpicHeight]
cp 5
jr z, .check_add_24
cp 6
jr z, .check_add_13
pop af
ret
.check_add_24
pop af
cp 5 * 5
jr nc, .add_24
push hl
push de
ld hl, ._5by5
ld e, a
ld d, 0
add hl, de
ld a, [hl]
pop de
pop hl
ret
.add_24
add 24
ret
.check_add_13
pop af
cp 6 * 6
jr nc, .add_13
push hl
push de
ld hl, ._6by6
ld e, a
ld d, 0
add hl, de
ld a, [hl]
pop de
pop hl
ret
.add_13
add 13
ret
._5by5:
poke_anim_box 5
; db 9, 10, 11, 12, 13
; db 16, 17, 18, 19, 20
; db 23, 24, 25, 26, 27
; db 30, 31, 32, 33, 34
; db 37, 38, 39, 40, 41
._6by6:
poke_anim_box 6
; db 8, 9, 10, 11, 12, 13
; db 15, 16, 17, 18, 19, 20
; db 22, 23, 24, 25, 26, 27
; db 29, 30, 31, 32, 33, 34
; db 36, 37, 38, 39, 40, 41
; db 43, 44, 45, 46, 47, 48
.GetStartCoord:
ld hl, wPokeAnimCoord
ld a, [hli]
ld h, [hl]
ld l, a
ld a, [wPokeAnimFrontpicHeight]
ld de, 0
ld bc, 6
cp 7
jr z, .okay
ld de, SCREEN_WIDTH + 1
ld bc, SCREEN_WIDTH + 5
cp 6
jr z, .okay
ld de, 2 * SCREEN_WIDTH + 1
ld bc, 2 * SCREEN_WIDTH + 5
.okay
ld a, [wBoxAlignment]
and a
jr nz, .add_bc
add hl, de
ret
.add_bc
add hl, bc
ret
.NextBit:
ld a, [wPokeAnimBitmaskCurRow]
inc a
ld [wPokeAnimBitmaskCurRow], a
ld c, a
ld a, [wPokeAnimFrontpicHeight]
cp c
jr nz, .no_carry
xor a
ld [wPokeAnimBitmaskCurRow], a
ld a, [wPokeAnimBitmaskCurCol]
inc a
ld [wPokeAnimBitmaskCurCol], a
ld c, a
ld a, [wPokeAnimFrontpicHeight]
cp c
jr nz, .no_carry
scf
ret
.no_carry
xor a
ret
PokeAnim_PlaceGraphic:
call .ClearBox
ld a, [wBoxAlignment]
and a
jr nz, .flipped
ld de, 1
ld bc, 0
jr .okay
.flipped
ld de, -1
ld bc, 6
.okay
ld hl, wPokeAnimCoord
ld a, [hli]
ld h, [hl]
ld l, a
add hl, bc
ld c, 7
ld b, 7
ld a, [wPokeAnimGraphicStartTile]
.loop
push bc
push hl
push de
ld de, SCREEN_WIDTH
.loop2
ld [hl], a
inc a
add hl, de
dec b
jr nz, .loop2
pop de
pop hl
add hl, de
pop bc
dec c
jr nz, .loop
ret
.ClearBox:
ld hl, wPokeAnimCoord
ld a, [hli]
ld h, [hl]
ld l, a
ld b, 7
ld c, 7
call ClearBox
ret
PokeAnim_SetVBank1:
ldh a, [rSVBK]
push af
ld a, BANK(wPokeAnimCoord)
ldh [rSVBK], a
xor a
ldh [hBGMapMode], a
call .SetFlag
farcall HDMATransferAttrMapToWRAMBank3
pop af
ldh [rSVBK], a
ret
.SetFlag:
call PokeAnim_GetAttrMapCoord
ld b, 7
ld c, 7
ld de, SCREEN_WIDTH
.row
push bc
push hl
.col
ld a, [hl]
or 8
ld [hl], a
add hl, de
dec c
jr nz, .col
pop hl
inc hl
pop bc
dec b
jr nz, .row
ret
PokeAnim_SetVBank0:
call PokeAnim_GetAttrMapCoord
ld b, 7
ld c, 7
ld de, SCREEN_WIDTH
.row
push bc
push hl
.col
ld a, [hl]
and $f7
ld [hl], a
add hl, de
dec c
jr nz, .col
pop hl
inc hl
pop bc
dec b
jr nz, .row
ret
PokeAnim_GetAttrMapCoord:
ld hl, wPokeAnimCoord
ld a, [hli]
ld h, [hl]
ld l, a
ld de, wAttrMap - wTileMap
add hl, de
ret
GetMonAnimPointer:
call PokeAnim_IsEgg
jr z, .egg
ld c, BANK(UnownAnimationPointers) ; aka BANK(UnownAnimationIdlePointers)
ld hl, UnownAnimationPointers - 2
ld de, UnownAnimationIdlePointers - 2
call PokeAnim_IsUnown
jr z, .unown
ld c, BANK(AnimationPointers) ; aka BANK(AnimationIdlePointers)
ld hl, AnimationPointers - 2
ld de, AnimationIdlePointers - 2
.unown
ld a, [wPokeAnimIdleFlag]
and a
jr nz, .got_pointer
ld d, h
ld e, l
.got_pointer
call PokeAnim_IsUnown
ld a, [wPokeAnimSpeciesOrUnown]
ld l, a
ld h, 0
call nz, GetPokemonIndexFromID
add hl, hl
add hl, de
ld a, c
ld [wPokeAnimPointerBank], a
call GetFarHalfword
ld a, l
ld [wPokeAnimPointerAddr], a
ld a, h
ld [wPokeAnimPointerAddr + 1], a
ret
.egg
ld hl, EggAnimation
ld c, BANK(EggAnimation)
ld a, [wPokeAnimIdleFlag]
and a
jr z, .idles_egg
ld hl, EggAnimationIdle
ld c, BANK(EggAnimationIdle)
.idles_egg
ld a, c
ld [wPokeAnimPointerBank], a
ld a, l
ld [wPokeAnimPointerAddr], a
ld a, h
ld [wPokeAnimPointerAddr + 1], a
ret
PokeAnim_GetFrontpicDims:
ldh a, [rSVBK]
push af
ld a, BANK(wCurPartySpecies)
ldh [rSVBK], a
ld a, [wCurPartySpecies]
ld [wCurSpecies], a
call GetBaseData
ld a, [wBasePicSize]
and $f
ld c, a
pop af
ldh [rSVBK], a
ret
GetMonFramesPointer:
call PokeAnim_IsEgg
jr z, .egg
call PokeAnim_IsUnown
ld hl, FramesPointers - 3
ld a, BANK(FramesPointers)
ld c, 3
jr nz, .got_frames
ld a, BANK(UnownsFrames)
ld [wPokeAnimFramesBank], a
ld hl, UnownFramesPointers - 2
ld a, BANK(UnownFramesPointers)
ld c, 2
.got_frames
push af
push hl
ld a, [wPokeAnimSpeciesOrUnown]
ld l, a
ld h, 0
call nz, GetPokemonIndexFromID
ld a, c
ld c, l
ld b, h
pop hl
call AddNTimes
pop af
jr z, .no_bank
ld c, a
call GetFarByte
ld [wPokeAnimFramesBank], a
inc hl
ld a, c
.no_bank
call GetFarHalfword
ld a, l
ld [wPokeAnimFramesAddr], a
ld a, h
ld [wPokeAnimFramesAddr + 1], a
ret
.egg
ld a, BANK(EggFrames)
ld [wPokeAnimFramesBank], a
ld a, LOW(EggFrames)
ld [wPokeAnimFramesAddr], a
ld a, HIGH(EggFrames)
ld [wPokeAnimFramesAddr + 1], a
ret
GetMonBitmaskPointer:
call PokeAnim_IsEgg
jr z, .egg
call PokeAnim_IsUnown
ld a, BANK(UnownBitmasksPointers)
ld de, UnownBitmasksPointers - 2
jr z, .unown
ld a, BANK(BitmasksPointers)
ld de, BitmasksPointers - 2
.unown
ld [wPokeAnimBitmaskBank], a
ld a, [wPokeAnimSpeciesOrUnown]
ld l, a
ld h, 0
call nz, GetPokemonIndexFromID
add hl, hl
add hl, de
ld a, [wPokeAnimBitmaskBank]
call GetFarHalfword
ld a, l
ld [wPokeAnimBitmaskAddr], a
ld a, h
ld [wPokeAnimBitmaskAddr + 1], a
ret
.egg
ld c, BANK(EggBitmasks)
ld hl, EggBitmasks
ld a, c
ld [wPokeAnimBitmaskBank], a
ld a, l
ld [wPokeAnimBitmaskAddr], a
ld a, h
ld [wPokeAnimBitmaskAddr + 1], a
ret
PokeAnim_GetSpeciesOrUnown:
call PokeAnim_IsUnown
jr z, .unown
ld a, [wPokeAnimSpecies]
ret
.unown
ld a, [wPokeAnimUnownLetter]
ret
Unused_HOF_AnimateAlignedFrontpic:
ld a, $1
ld [wBoxAlignment], a
HOF_AnimateFrontpic:
call AnimateMon_CheckIfPokemon
jr c, .fail
ld h, d
ld l, e
push bc
push hl
ld de, vTiles2
predef GetAnimatedFrontpic
pop hl
pop bc
ld d, 0
ld e, c
call AnimateFrontpic
xor a
ld [wBoxAlignment], a
ret
.fail
xor a
ld [wBoxAlignment], a
inc a
ld [wCurPartySpecies], a
ret
|
.size 8000
.text@49
inc a
ldff(45), a
jp lstatint
.text@100
jp lbegin
.data@143
80
.text@150
lbegin:
ld a, ff
ldff(45), a
ld b, 03
call lwaitly_b
ld a, 40
ldff(41), a
ld a, 02
ldff(ff), a
ei
ld a, b
inc a
inc a
ldff(45), a
ld c, 41
.text@1000
lstatint:
xor a, a
ldff(c), a
ldff(0f), a
.text@1068
ld a, ff
ldff(c), a
xor a, a
ldff(0f), a
ld a, bf
ldff(c), a
ldff a, (0f)
and a, b
jp lprint_a
.text@7000
lprint_a:
push af
ld b, 91
call lwaitly_b
xor a, a
ldff(40), a
pop af
ld(9800), a
ld bc, 7a00
ld hl, 8000
ld d, a0
lprint_copytiles:
ld a, (bc)
inc bc
ld(hl++), a
dec d
jrnz lprint_copytiles
ld a, c0
ldff(47), a
ld a, 80
ldff(68), a
ld a, ff
ldff(69), a
ldff(69), a
ldff(69), a
ldff(69), a
ldff(69), a
ldff(69), a
xor a, a
ldff(69), a
ldff(69), a
ldff(43), a
ld a, 91
ldff(40), a
lprint_limbo:
jr lprint_limbo
.text@7400
lwaitly_b:
ld c, 44
lwaitly_b_loop:
ldff a, (c)
cmp a, b
jrnz lwaitly_b_loop
ret
.data@7a00
00 00 7f 7f 41 41 41 41
41 41 41 41 41 41 7f 7f
00 00 08 08 08 08 08 08
08 08 08 08 08 08 08 08
00 00 7f 7f 01 01 01 01
7f 7f 40 40 40 40 7f 7f
00 00 7f 7f 01 01 01 01
3f 3f 01 01 01 01 7f 7f
00 00 41 41 41 41 41 41
7f 7f 01 01 01 01 01 01
00 00 7f 7f 40 40 40 40
7e 7e 01 01 01 01 7e 7e
00 00 7f 7f 40 40 40 40
7f 7f 41 41 41 41 7f 7f
00 00 7f 7f 01 01 02 02
04 04 08 08 10 10 10 10
00 00 3e 3e 41 41 41 41
3e 3e 41 41 41 41 3e 3e
00 00 7f 7f 41 41 41 41
7f 7f 01 01 01 01 7f 7f
|
.global s_prepare_buffers
s_prepare_buffers:
push %r10
push %r13
push %r8
push %r9
push %rbx
push %rcx
push %rdi
push %rsi
lea addresses_normal_ht+0x1b17d, %r8
clflush (%r8)
nop
nop
nop
nop
sub $37966, %rbx
movb (%r8), %r9b
nop
nop
nop
add %r9, %r9
lea addresses_UC_ht+0x16a11, %rsi
nop
xor $24111, %r10
mov $0x6162636465666768, %rdi
movq %rdi, %xmm6
movups %xmm6, (%rsi)
nop
add $3589, %rsi
lea addresses_WC_ht+0x1577d, %r10
nop
nop
sub $10021, %r13
mov $0x6162636465666768, %rsi
movq %rsi, %xmm5
and $0xffffffffffffffc0, %r10
vmovaps %ymm5, (%r10)
dec %r9
lea addresses_normal_ht+0x1abf7, %rsi
nop
nop
nop
nop
cmp %r8, %r8
mov $0x6162636465666768, %r9
movq %r9, %xmm7
and $0xffffffffffffffc0, %rsi
vmovntdq %ymm7, (%rsi)
nop
nop
nop
nop
sub %r8, %r8
lea addresses_WC_ht+0x19f7d, %rsi
lea addresses_UC_ht+0xa97d, %rdi
nop
nop
nop
nop
sub $30777, %r10
mov $107, %rcx
rep movsl
nop
nop
xor $34578, %r8
lea addresses_UC_ht+0xb87d, %rcx
nop
nop
nop
add $64469, %rdi
mov (%rcx), %r13d
nop
nop
nop
add %r9, %r9
lea addresses_WC_ht+0xc44e, %rsi
lea addresses_A_ht+0x6f7d, %rdi
clflush (%rsi)
nop
nop
nop
nop
nop
add $28416, %rbx
mov $82, %rcx
rep movsq
nop
sub $30099, %rdi
lea addresses_WC_ht+0x16ec1, %rcx
nop
nop
nop
nop
cmp %rbx, %rbx
mov (%rcx), %r13
nop
nop
nop
add %r9, %r9
lea addresses_D_ht+0xadfd, %rdi
nop
nop
xor $12243, %rsi
movw $0x6162, (%rdi)
nop
nop
xor $63325, %rcx
lea addresses_A_ht+0x1d97d, %r9
nop
nop
nop
nop
nop
cmp %rdi, %rdi
movl $0x61626364, (%r9)
nop
nop
nop
and %r10, %r10
lea addresses_UC_ht+0x1149d, %rdi
nop
add %r9, %r9
mov $0x6162636465666768, %rsi
movq %rsi, %xmm5
movups %xmm5, (%rdi)
nop
nop
nop
nop
nop
and $43705, %r9
lea addresses_WC_ht+0x19d97, %rbx
nop
nop
nop
dec %r8
movw $0x6162, (%rbx)
nop
nop
nop
nop
nop
xor %rsi, %rsi
pop %rsi
pop %rdi
pop %rcx
pop %rbx
pop %r9
pop %r8
pop %r13
pop %r10
ret
.global s_faulty_load
s_faulty_load:
push %r10
push %r14
push %r15
push %rdx
// Faulty Load
lea addresses_D+0xff7d, %r14
nop
xor %rdx, %rdx
movups (%r14), %xmm3
vpextrq $1, %xmm3, %r15
lea oracles, %rdx
and $0xff, %r15
shlq $12, %r15
mov (%rdx,%r15,1), %r15
pop %rdx
pop %r15
pop %r14
pop %r10
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 16, 'type': 'addresses_D', 'congruent': 0}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'same': True, 'NT': False, 'AVXalign': False, 'size': 16, 'type': 'addresses_D', 'congruent': 0}}
<gen_prepare_buffer>
{'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 1, 'type': 'addresses_normal_ht', 'congruent': 9}}
{'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 16, 'type': 'addresses_UC_ht', 'congruent': 0}, 'OP': 'STOR'}
{'dst': {'same': False, 'NT': False, 'AVXalign': True, 'size': 32, 'type': 'addresses_WC_ht', 'congruent': 11}, 'OP': 'STOR'}
{'dst': {'same': False, 'NT': True, 'AVXalign': False, 'size': 32, 'type': 'addresses_normal_ht', 'congruent': 0}, 'OP': 'STOR'}
{'dst': {'same': False, 'congruent': 8, 'type': 'addresses_UC_ht'}, 'OP': 'REPM', 'src': {'same': False, 'congruent': 11, 'type': 'addresses_WC_ht'}}
{'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 4, 'type': 'addresses_UC_ht', 'congruent': 8}}
{'dst': {'same': False, 'congruent': 10, 'type': 'addresses_A_ht'}, 'OP': 'REPM', 'src': {'same': False, 'congruent': 0, 'type': 'addresses_WC_ht'}}
{'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 8, 'type': 'addresses_WC_ht', 'congruent': 2}}
{'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 2, 'type': 'addresses_D_ht', 'congruent': 2}, 'OP': 'STOR'}
{'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 4, 'type': 'addresses_A_ht', 'congruent': 9}, 'OP': 'STOR'}
{'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 16, 'type': 'addresses_UC_ht', 'congruent': 5}, 'OP': 'STOR'}
{'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 2, 'type': 'addresses_WC_ht', 'congruent': 1}, 'OP': 'STOR'}
{'36': 21829}
36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36
*/
|
; A212012: Triangle read by rows in which row n lists the number of states of the subshells of the n-th shell of the nuclear shell model ordered by energy level in increasing order.
; 2,4,2,6,4,2,8,6,4,2,10,8,6,4,2,12,10,8,6,4,2,14,12,10,8,6,4,2,16,14,12,10,8,6,4,2,18,16,14,12,10,8,6,4,2,20,18,16,14,12,10,8,6,4,2,22,20,18,16,14,12,10,8,6,4,2,24,22,20,18,16,14,12
mov $1,1
lpb $0,1
sub $0,1
mov $3,$2
add $2,1
add $3,2
sub $3,$0
trn $0,$2
mov $1,$3
lpe
mul $1,2
|
;
; ZX81 libraries - Stefano 7/8/2009
;
;----------------------------------------------------------------
;
; $Id: filltxt.asm,v 1.4 2012/01/09 16:02:36 stefano Exp $
;
;----------------------------------------------------------------
;
; Fill text memory with specified character code
;
;----------------------------------------------------------------
XLIB filltxt
LIB zx_topleft
XREF base_graphics
filltxt:
; __FASTCALL__ mode
ld a,l
ld hl,(16396)
inc hl
ld b,24
floop:
push bc
ld (hl),a
ld d,h
ld e,l
inc de
ld bc,31
ldir
inc hl
inc hl
pop bc
djnz floop
jp zx_topleft
|
; Nathan Lowe
; EECS 2110 - Computer Architecture and Organization
; Spring 2016 at the University of Toledo
;
; Description: Given one or more input strings, determine whether or not it
; conforms to the following password policy:
; * Minimum of 8 characters
; * Maximum of 20 characters
; * At least one lowercase letter ('a'-'z')
; * At least one uppercase letter ('A'-'Z')
; * At least one number ('0'-'9')
; * At least one special character (any printable non alphanumeric character)
;
; ==============================================================================
; | Include libraries and macros |
; ==============================================================================
include ..\lib\pcmac.inc
include .\utils.inc ; For _AssertOne and _CheckChar
; ==============================================================================
; | Constants used in this file |
; ==============================================================================
TAB EQU 09 ; Horizontal Tab
CR EQU 13 ; Carriage Return
LF EQU 10 ; Line Feed
EOS EQU '$' ; DOS End of string terminator
MIN_LENGTH EQU 8 ; The minimum length of a password
MAX_LENGTH EQU 20 ; The maximum length of a password
ASCII_TO_LOWER_MASK EQU 00100000b ; The bitmask to convert a character to lower
NUMERIC_LOWER EQU '0' ; The lower bound for the numeric characters
NUMERIC_UPPER EQU '9' ; The upper bound for the numeric characters
LOWERCASE_LOWER EQU 'a' ; The lower bound for lower-case characters
LOWERCASE_UPPER EQU 'z' ; The upper bound for lower-case characters
UPPERCASE_LOWER EQU 'A' ; The lower bound for upper-case characters
UPPERCASE_UPPER EQU 'Z' ; The upper bound for upper-case characters
; Special characters accepted are broken into 5 ranges
; This excludes non-printable characters
SPECIAL_1_LOWER EQU ' '
SPECIAL_1_UPPER EQU '/'
SPECIAL_2_LOWER EQU ':'
SPECIAL_2_UPPER EQU '@'
SPECIAL_3_LOWER EQU '['
SPECIAL_3_UPPER EQU '`'
SPECIAL_4_LOWER EQU '{'
SPECIAL_4_UPPER EQU '~'
SPECIAL_EXTRA EQU 80h ; Anything from the extended set
RET_OK EQU 00h ; Return code for OK
; =========================== Start of Setup ============================
.model small ; Small Memory MODEL
.586 ; Pentium Instruction Set
.stack 100h ; Stack area - 256 bytes
; =========================== End of Setup ===========================
; =========================== Start of Data Segment ===========================
.data
; --------------------------- Input Prompt Strings ---------------------------
passwordPrompt DB 'Enter a Password to Check> ', EOS
continuePrompt DB 'Continue? [y/n] ', EOS
continueInvalidPrompt DB 'Project specification dictates you enter either one of (Y,y,N,n), so I will ask again. ', EOS
; ------------------------------------------------------------------------------
; --------------------------- Variables ---------------------------
lowerCount DW 0000h ; The number of lower-case characters
upperCount DW 0000h ; The number of upper-case characters
numberCount DW 0000h ; The number of numerical characters
specialCount DW 0000h ; The number of special characters
totalCount DW 0000h ; The total number of characters so far
validationErrors DW 0000h ; The number of validation errors
; ------------------------------------------------------------------------------
; --------------------------- Output Message ---------------------------
policy_1 DB 'Policy: 8-20 characters, and at least one of:', CR, LF, EOS
policy_2 DB TAB, '* Lower Case (a-z)', CR, LF, EOS
policy_3 DB TAB, '* Upper Case (A-Z)', CR, LF, EOS
policy_4 DB TAB, '* Numbers (0-9)', CR, LF, EOS
policy_5 DB TAB, '* Special Characters', CR, LF, EOS
pw_placeholder DB '*', EOS
pw_ok DB 'Nice password! Everything checks out', CR, LF, EOS
missing_number DB 'At least one number is required', CR, LF, EOS
missing_lower DB 'At least one lower case character is required', CR, LF, EOS
missing_upper DB 'At least one upper case character is required', CR, LF, EOS
missing_special DB 'At least one special character is required', CR, LF, EOS
too_short DB 'Password must be at least 8 characters', CR, LF, EOS
too_long DB 'Corporate dictates your password must be no longer than 20 characters...', CR, LF, EOS
blank DB CR, LF, EOS
; ------------------------------------------------------------------------------
; =========================== End of Data Segment ===========================
.code
start:
main PROC
_LdSeg ds, @data ; Load the data segment
_PutStr policy_1 ; Print the policy
_PutStr policy_2
_PutStr policy_3
_PutStr policy_4
_PutStr policy_5
_PutStr blank
PROMPT:
_PutStr passwordPrompt ; Ask for a password
PW_GET_CHAR:
_GetCh noEcho ; Get a character from stdin
cmp al, CR ; Check if the enter key was pressed
je CHECKPW ; If it was, check the password entered
cmp al, LF
je CHECKPW
; Start checking for character sets
; _CheckChar MACRO lower, upper, counter, nextLower, nextUpper, ok
_CheckChar NUMERIC_LOWER, NUMERIC_UPPER, numberCount, CMP_SPECIAL, CMP_UPPER, CHAR_OK
CMP_UPPER:
_CheckChar UPPERCASE_LOWER, UPPERCASE_UPPER, upperCount, CMP_SPECIAL, CMP_LOWER, CHAR_OK
CMP_LOWER:
_CheckChar LOWERCASE_LOWER, LOWERCASE_UPPER, lowerCount, CMP_SPECIAL, CMP_SPECIAL, CHAR_OK
CMP_SPECIAL:
_CheckChar SPECIAL_1_LOWER, SPECIAL_1_UPPER, specialCount, CMP_SPECIAL_2, CMP_SPECIAL_2, CHAR_OK
CMP_SPECIAL_2:
_CheckChar SPECIAL_2_LOWER, SPECIAL_2_UPPER, specialCount, CMP_SPECIAL_3, CMP_SPECIAL_3, CHAR_OK
CMP_SPECIAL_3:
_CheckChar SPECIAL_3_LOWER, SPECIAL_3_UPPER, specialCount, CMP_SPECIAL_4, CMP_SPECIAL_4, CHAR_OK
CMP_SPECIAL_4:
_CheckChar SPECIAL_4_LOWER, SPECIAL_4_UPPER, specialCount, CMP_SPECIAL_EXT, CMP_SPECIAL_EXT, CHAR_OK
CMP_SPECIAL_EXT:
cmp al, SPECIAL_EXTRA
jnae PW_GET_CHAR
inc specialCount
CHAR_OK:
inc totalCount ; Increment the total character count
_PutStr pw_placeholder ; Print '*' for feedback
jmp PW_GET_CHAR ; Go get the next character
CHECKPW:
_PutStr blank ; We just got an 'enter' key, add a blank line
; Ensure that at least one of each policy group has been seen
; _AssertOne MACRO counter, nextOk, msg, validationCounter
_AssertOne numberCount, CHECKPW_LOWER, missing_number, validationErrors
CHECKPW_LOWER:
_AssertOne lowerCount, CHECKPW_UPPER, missing_lower, validationErrors
CHECKPW_UPPER:
_AssertOne upperCount, CHECKPW_SPECIAL, missing_upper, validationErrors
CHECKPW_SPECIAL:
_AssertOne specialCount, CHECKPW_MIN, missing_special, validationErrors
; Also check the minimum and maximum length requirements
CHECKPW_MIN:
cmp totalCount, MIN_LENGTH
jge CHECKPW_MAX
_PutStr too_short
inc validationErrors
CHECKPW_MAX:
cmp totalCount, MAX_LENGTH
jle STATUS
_PutStr too_long
inc validationErrors
STATUS:
_PutStr blank
cmp validationErrors, 0
jne CONTINUE_PROMPT
_PutStr pw_ok
CONTINUE_PROMPT:
_PutStr continuePrompt ; Prompt the user to continue or exit
_GetCh
_PutStr blank
; Reset all counters
mov totalCount, 0000h
mov numberCount, 0000h
mov lowerCount, 0000h
mov upperCount, 0000h
mov specialCount, 0000h
mov validationErrors, 0000h
or al, ASCII_TO_LOWER_MASK ; Convert the read character to lower case
cmp al, 'y'
je PROMPT ; The user entered 'y', prompt for another PW
cmp al, 'n'
je EXIT ; The user entered 'n', exit
_PutStr continueInvalidPrompt ; /snark
jmp CONTINUE_PROMPT ; ask again...
EXIT:
_Exit RET_OK
main ENDP
END main
|
DEVICE AMSTRADCPC464
ORG $7FFF
DB '1' ; mark page 1 at end
DB '2' ; mark page 2 at beginning
ORG 0x10000-4
endStart:
DB '!end' ; mark end of RAM at $FFFF (to check saving of last byte)
.sz EQU $-endStart
ASSERT $10000 == endStart + endStart.sz
MMU $4000, 0 ; map page 0 to slot 1
MMU $8000, 3, $7FFF ; map page 3 to slot 2
dataStart:
DB '0' ; mark page 0 at end
DB '3' ; mark page 3 at beginning
.sz EQU $-dataStart
; create empty CDT file
SAVECDT EMPTY "savecdt_basic.cdt"
; first block: pages 0+3
SAVECDT BASIC "savecdt_basic.cdt","basic1",dataStart,dataStart.sz
; second block: pages 1+2
MMU $4000 $8000, 1 ; map pages 1,2 to slots 1,2
SAVECDT BASIC "savecdt_basic.cdt","basic2",dataStart,dataStart.sz
; third block, saving last bytes of address space
SAVECDT BASIC "savecdt_basic.cdt","basic3",endStart,endStart.sz
|
<%
from pwnlib.shellcraft.aarch64.linux import syscall
%>
<%page args="pid, stat_loc, options, usage"/>
<%docstring>
Invokes the syscall wait4. See 'man 2 wait4' for more information.
Arguments:
pid(pid_t): pid
stat_loc(WAIT_STATUS): stat_loc
options(int): options
usage(rusage): usage
</%docstring>
${syscall('SYS_wait4', pid, stat_loc, options, usage)}
|
SSEG SEGMENT PARA STACK 'STACK'
DB 64 DUP(0)
SSEG ENDS
DSEG SEGMENT PARA 'DATA'
; DATA
DSEG ENDS
CSEG SEGMENT PARA 'CODE'
ASSUME CS:CSEG, DS:DSEG, SS:SSEG
OUTPUT PROC
CMP DL, 9
JA M1
ADD DL, '0' ; if dec digit
JMP M2
M1: ADD DL, 'A' ; if hex digit
SUB DL, 10 ; minus offset
M2: MOV AH, 2
INT 21H
RET
OUTPUT ENDP
START PROC FAR
MOV AH,7
INT 21H
MOV DL, AL
MOV CL, 4
SHR DL, CL ; shift by 4 bytes to get first digit
MOV BL, AL ; after outputing dl al will change
CALL OUTPUT
MOV DL, BL
AND DL, 00001111B ; last digit
CALL OUTPUT
MOV AH,4CH
INT 21H
START ENDP
CSEG ENDS
END START |
DecrementPP:
; after using a move, decrement pp in battle and (if not transformed?) in party
ld a, [de]
cp STRUGGLE
ret z ; if the pokemon is using "struggle", there's nothing to do
; we don't decrement PP for "struggle"
ld hl, wPlayerBattleStatus1
ld a, [hli] ; load the wPlayerBattleStatus1 pokemon status flags and increment hl to load the
; wPlayerBattleStatus2 status flags later
and (1 << STORING_ENERGY) | (1 << THRASHING_ABOUT) | (1 << ATTACKING_MULTIPLE_TIMES)
ret nz ; if any of these statuses are true, don't decrement PP
bit USING_RAGE, [hl]
ret nz ; don't decrement PP either if Pokemon is using Rage
ld hl, wBattleMonPP ; PP of first move (in battle)
; decrement PP in the battle struct
call .DecrementPP
; decrement PP in the party struct
ld a, [wPlayerBattleStatus3]
bit TRANSFORMED, a
ret nz ; Return if transformed. Pokemon Red stores the "current pokemon's" PP
; separately from the "Pokemon in your party's" PP. This is
; duplication -- in all cases *other* than Pokemon with Transform.
; Normally, this means we have to go on and make the same
; modification to the "party's pokemon" PP that we made to the
; "current pokemon's" PP. But, if we're dealing with a Transformed
; Pokemon, it has separate PP for the move set that it copied from
; its opponent, which is *not* the same as its real PP as part of your
; party. So we return, and don't do that part.
ld hl, wPartyMon1PP ; PP of first move (in party)
ld a, [wPlayerMonNumber] ; which mon in party is active
ld bc, wPartyMon2 - wPartyMon1
call AddNTimes ; calculate address of the mon to modify
.DecrementPP:
ld a, [wPlayerMoveListIndex] ; which move (0, 1, 2, 3) did we use?
ld c, a
ld b, 0
add hl ,bc ; calculate the address in memory of the PP we need to decrement
; based on the move chosen.
dec [hl] ; Decrement PP
ret
|
/*********************************************************************************
* Copyright (C) 2006-2013 by Sebastian Gniazdowski *
* All Rights reserved. *
* *
* Redistribution and use in source and binary forms, with or without *
* modification, are permitted provided that the following conditions *
* are met: *
* 1. Redistributions of source code must retain the above copyright *
* notice, this list of conditions and the following disclaimer. *
* 2. Redistributions in binary form must reproduce the above copyright *
* notice, this list of conditions and the following disclaimer in the *
* documentation and/or other materials provided with the distribution. *
* 3. Neither the name of the Keyfrog nor the names of its contributors *
* may be used to endorse or promote products derived from this software *
* without specific prior written permission. *
* *
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND *
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE *
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE *
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE *
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL *
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS *
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) *
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT *
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY *
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF *
* SUCH DAMAGE. *
*********************************************************************************/
#if HAVE_CONFIG_H
#include <config.h>
#endif
#include "RawEvent.h"
namespace keyfrog
{
RawEvent::RawEvent()
{}
RawEvent::~RawEvent()
{}
}
|
; char __CALLEE__ *strrstrip_callee(char *s, char c)
; remove any occurrences of c at the end of s
; 01.2007 aralbrec
XLIB strrstrip_callee
XDEF ASMDISP_STRRSTRIP_CALLEE
.strrstrip_callee
pop hl
pop bc
ex (sp),hl
; enter : c = char c
; hl = char *s
; exit : hl = char *s
; uses : af, de
.asmentry
push hl
.failloop
ld a,(hl)
or a
jr z, fail
inc hl
cp c
jp nz, failloop
ld e,l
ld d,h
dec de
.passloop
ld a,(hl)
or a
jr z,pass
inc hl
cp c
jr nz, failloop
jp passloop
.pass
xor a
ld (de),a
.fail
pop hl
ret
DEFC ASMDISP_STRRSTRIP_CALLEE = asmentry - strrstrip_callee
|
// sound.cpp: basic positional sound using sdl_mixer
#include "engine.h"
#include "SDL_mixer.h"
#define MAXVOL MIX_MAX_VOLUME
bool nosound = true;
struct soundsample
{
char *name;
Mix_Chunk *chunk;
soundsample() : name(NULL), chunk(NULL) {}
~soundsample() { DELETEA(name); }
void cleanup() { if(chunk) { Mix_FreeChunk(chunk); chunk = NULL; } }
};
struct soundslot
{
soundsample *sample;
int volume;
};
struct soundconfig
{
int slots, numslots;
int maxuses;
bool hasslot(const soundslot *p, const vector<soundslot> &v) const
{
return p >= v.getbuf() + slots && p < v.getbuf() + slots+numslots && slots+numslots < v.length();
}
int chooseslot() const
{
return numslots > 1 ? slots + rnd(numslots) : slots;
}
};
struct soundchannel
{
int id;
bool inuse;
vec loc;
soundslot *slot;
extentity *ent;
int radius, volume, pan, flags;
bool dirty;
soundchannel(int id) : id(id) { reset(); }
bool hasloc() const { return loc.x >= -1e15f; }
void clearloc() { loc = vec(-1e16f, -1e16f, -1e16f); }
void reset()
{
inuse = false;
clearloc();
slot = NULL;
ent = NULL;
radius = 0;
volume = -1;
pan = -1;
flags = 0;
dirty = false;
}
};
vector<soundchannel> channels;
int maxchannels = 0;
soundchannel &newchannel(int n, soundslot *slot, const vec *loc = NULL, extentity *ent = NULL, int flags = 0, int radius = 0)
{
if(ent)
{
loc = &ent->o;
ent->visible = true;
}
while(!channels.inrange(n)) channels.add(channels.length());
soundchannel &chan = channels[n];
chan.reset();
chan.inuse = true;
if(loc) chan.loc = *loc;
chan.slot = slot;
chan.ent = ent;
chan.flags = 0;
chan.radius = radius;
return chan;
}
void freechannel(int n)
{
// Note that this can potentially be called from the SDL_mixer audio thread.
// Be careful of race conditions when checking chan.inuse without locking audio.
// Can't use Mix_Playing() checks due to bug with looping sounds in SDL_mixer.
if(!channels.inrange(n) || !channels[n].inuse) return;
soundchannel &chan = channels[n];
chan.inuse = false;
if(chan.ent) chan.ent->visible = false;
}
void syncchannel(soundchannel &chan)
{
if(!chan.dirty) return;
if(!Mix_FadingChannel(chan.id)) Mix_Volume(chan.id, chan.volume);
Mix_SetPanning(chan.id, 255-chan.pan, chan.pan);
chan.dirty = false;
}
void stopchannels()
{
loopv(channels)
{
soundchannel &chan = channels[i];
if(!chan.inuse) continue;
Mix_HaltChannel(i);
freechannel(i);
}
}
void setmusicvol(int musicvol);
VARFP(soundvol, 0, 255, 255, if(!soundvol) { stopchannels(); setmusicvol(0); });
VARFP(musicvol, 0, 0, 255, setmusicvol(soundvol ? musicvol : 0));
char *musicfile = NULL, *musicdonecmd = NULL;
Mix_Music *music = NULL;
SDL_RWops *musicrw = NULL;
stream *musicstream = NULL;
void setmusicvol(int musicvol)
{
if(nosound) return;
if(music) Mix_VolumeMusic((musicvol*MAXVOL)/255);
}
void stopmusic()
{
if(nosound) return;
DELETEA(musicfile);
DELETEA(musicdonecmd);
if(music)
{
Mix_HaltMusic();
Mix_FreeMusic(music);
music = NULL;
}
if(musicrw) { SDL_FreeRW(musicrw); musicrw = NULL; }
DELETEP(musicstream);
}
VARF(soundchans, 1, 32, 128, initwarning("sound configuration", INIT_RESET, CHANGE_SOUND));
VARF(soundfreq, 0, MIX_DEFAULT_FREQUENCY, 44100, initwarning("sound configuration", INIT_RESET, CHANGE_SOUND));
VARF(soundbufferlen, 128, 1024, 4096, initwarning("sound configuration", INIT_RESET, CHANGE_SOUND));
void initsound()
{
if(Mix_OpenAudio(soundfreq, MIX_DEFAULT_FORMAT, 2, soundbufferlen)<0)
{
nosound = true;
conoutf(CON_ERROR, "sound init failed (SDL_mixer): %s", Mix_GetError());
return;
}
Mix_AllocateChannels(soundchans);
Mix_ChannelFinished(freechannel);
maxchannels = soundchans;
nosound = false;
}
void musicdone()
{
if(music) { Mix_HaltMusic(); Mix_FreeMusic(music); music = NULL; }
if(musicrw) { SDL_FreeRW(musicrw); musicrw = NULL; }
DELETEP(musicstream);
DELETEA(musicfile);
if(!musicdonecmd) return;
char *cmd = musicdonecmd;
musicdonecmd = NULL;
execute(cmd);
delete[] cmd;
}
Mix_Music *loadmusic(const char *name)
{
if(!musicstream) musicstream = openzipfile(name, "rb");
if(musicstream)
{
if(!musicrw) musicrw = musicstream->rwops();
if(!musicrw) DELETEP(musicstream);
}
if(musicrw) music = Mix_LoadMUS_RW(musicrw);
else music = Mix_LoadMUS(findfile(name, "rb"));
if(!music)
{
if(musicrw) { SDL_FreeRW(musicrw); musicrw = NULL; }
DELETEP(musicstream);
}
return music;
}
void startmusic(char *name, char *cmd)
{
if(nosound) return;
stopmusic();
if(soundvol && musicvol && *name)
{
defformatstring(file)("packages/%s", name);
path(file);
if(loadmusic(file))
{
DELETEA(musicfile);
DELETEA(musicdonecmd);
musicfile = newstring(file);
if(cmd[0]) musicdonecmd = newstring(cmd);
Mix_PlayMusic(music, cmd[0] ? 0 : -1);
Mix_VolumeMusic((musicvol*MAXVOL)/255);
intret(1);
}
else
{
conoutf(CON_ERROR, "could not play music: %s", file);
intret(0);
}
}
}
COMMANDN(music, startmusic, "ss");
static hashtable<const char *, soundsample> samples;
static vector<soundslot> gameslots, mapslots;
static vector<soundconfig> gamesounds, mapsounds;
static int findsound(const char *name, int vol, vector<soundconfig> &sounds, vector<soundslot> &slots)
{
loopv(sounds)
{
soundconfig &s = sounds[i];
loopj(s.numslots)
{
soundslot &c = slots[s.slots+j];
if(!strcmp(c.sample->name, name) && (!vol || c.volume==vol)) return i;
}
}
return -1;
}
static int addslot(const char *name, int vol, vector<soundslot> &slots)
{
soundsample *s = samples.access(name);
if(!s)
{
char *n = newstring(name);
s = &samples[n];
s->name = n;
s->chunk = NULL;
}
soundslot *oldslots = slots.getbuf();
int oldlen = slots.length();
soundslot &slot = slots.add();
// soundslots.add() may relocate slot pointers
if(slots.getbuf() != oldslots) loopv(channels)
{
soundchannel &chan = channels[i];
if(chan.inuse && chan.slot >= oldslots && chan.slot < &oldslots[oldlen])
chan.slot = &slots[chan.slot - oldslots];
}
slot.sample = s;
slot.volume = vol ? vol : 100;
return oldlen;
}
static int addsound(const char *name, int vol, int maxuses, vector<soundconfig> &sounds, vector<soundslot> &slots)
{
soundconfig &s = sounds.add();
s.slots = addslot(name, vol, slots);
s.numslots = 1;
s.maxuses = maxuses;
return sounds.length()-1;
}
void registersound(char *name, int *vol) { intret(addsound(name, *vol, 0, gamesounds, gameslots)); }
COMMAND(registersound, "si");
void mapsound(char *name, int *vol, int *maxuses) { intret(addsound(name, *vol, *maxuses < 0 ? 0 : max(1, *maxuses), mapsounds, mapslots)); }
COMMAND(mapsound, "sii");
void altsound(char *name, int *vol)
{
if(gamesounds.empty()) return;
addslot(name, *vol, gameslots);
gamesounds.last().numslots++;
}
COMMAND(altsound, "si");
void altmapsound(char *name, int *vol)
{
if(mapsounds.empty()) return;
addslot(name, *vol, mapslots);
mapsounds.last().numslots++;
}
COMMAND(altmapsound, "si");
void resetchannels()
{
loopv(channels) if(channels[i].inuse) freechannel(i);
channels.shrink(0);
}
void clear_sound()
{
closemumble();
if(nosound) return;
stopmusic();
enumerate(samples, soundsample, s, s.cleanup());
Mix_CloseAudio();
resetchannels();
gameslots.setsize(0);
gamesounds.setsize(0);
mapslots.setsize(0);
mapsounds.setsize(0);
samples.clear();
}
void stopmapsounds()
{
loopv(channels) if(channels[i].inuse && channels[i].ent)
{
Mix_HaltChannel(i);
freechannel(i);
}
}
void clearmapsounds()
{
stopmapsounds();
mapslots.setsize(0);
mapsounds.setsize(0);
}
void stopmapsound(extentity *e)
{
loopv(channels)
{
soundchannel &chan = channels[i];
if(chan.inuse && chan.ent == e)
{
Mix_HaltChannel(i);
freechannel(i);
}
}
}
void checkmapsounds()
{
const vector<extentity *> &ents = entities::getents();
loopv(ents)
{
extentity &e = *ents[i];
if(e.type!=ET_SOUND) continue;
if(camera1->o.dist(e.o) < e.attr2)
{
if(!e.visible) playsound(e.attr1, NULL, &e, SND_MAP, -1);
}
else if(e.visible) stopmapsound(&e);
}
}
VAR(stereo, 0, 1, 1);
VARP(maxsoundradius, 0, 340, 10000);
bool updatechannel(soundchannel &chan)
{
if(!chan.slot) return false;
int vol = soundvol, pan = 255/2;
if(chan.hasloc())
{
vec v;
float dist = chan.loc.dist(camera1->o, v);
int rad = maxsoundradius;
if(chan.ent)
{
rad = chan.ent->attr2;
if(chan.ent->attr3)
{
rad -= chan.ent->attr3;
dist -= chan.ent->attr3;
}
}
else if(chan.radius > 0) rad = maxsoundradius ? min(maxsoundradius, chan.radius) : chan.radius;
if(rad > 0) vol -= int(clamp(dist/rad, 0.0f, 1.0f)*soundvol); // simple mono distance attenuation
if(stereo && (v.x != 0 || v.y != 0) && dist>0)
{
v.rotate_around_z(-camera1->yaw*RAD);
pan = int(255.9f*(0.5f - 0.5f*v.x/v.magnitude2())); // range is from 0 (left) to 255 (right)
}
}
vol = (vol*MAXVOL*chan.slot->volume)/255/255;
vol = min(vol, MAXVOL);
if(vol == chan.volume && pan == chan.pan) return false;
chan.volume = vol;
chan.pan = pan;
chan.dirty = true;
return true;
}
void updatesounds()
{
updatemumble();
if(nosound) return;
if(minimized) stopsounds();
else if(mainmenu) stopmapsounds();
else checkmapsounds();
int dirty = 0;
loopv(channels)
{
soundchannel &chan = channels[i];
if(chan.inuse && chan.hasloc() && updatechannel(chan)) dirty++;
}
if(dirty)
{
SDL_LockAudio(); // workaround for race conditions inside Mix_SetPanning
loopv(channels)
{
soundchannel &chan = channels[i];
if(chan.inuse && chan.dirty) syncchannel(chan);
}
SDL_UnlockAudio();
}
if(music)
{
if(!Mix_PlayingMusic()) musicdone();
else if(Mix_PausedMusic()) Mix_ResumeMusic();
}
}
VARP(maxsoundsatonce, 0, 7, 100);
VAR(dbgsound, 0, 0, 1);
static Mix_Chunk *loadwav(const char *name)
{
Mix_Chunk *c = NULL;
stream *z = openzipfile(name, "rb");
if(z)
{
SDL_RWops *rw = z->rwops();
if(rw)
{
c = Mix_LoadWAV_RW(rw, 0);
SDL_FreeRW(rw);
}
delete z;
}
if(!c) c = Mix_LoadWAV(findfile(name, "rb"));
return c;
}
static bool loadsoundslot(soundslot &slot, bool msg = false)
{
if(slot.sample->chunk) return true;
if(!slot.sample->name[0]) return false;
static const char * const exts[] = { "", ".wav", ".ogg" };
string filename;
loopi(sizeof(exts)/sizeof(exts[0]))
{
formatstring(filename)("packages/sounds/%s%s", slot.sample->name, exts[i]);
if(msg && !i) renderprogress(0, filename);
path(filename);
slot.sample->chunk = loadwav(filename);
if(slot.sample->chunk) return true;
}
conoutf(CON_ERROR, "failed to load sample: packages/sounds/%s", slot.sample->name);
return false;
}
static inline void preloadsound(vector<soundconfig> &sounds, vector<soundslot> &slots, int n)
{
if(nosound || !sounds.inrange(n)) return;
soundconfig &config = sounds[n];
loopk(config.numslots) loadsoundslot(slots[config.slots+k], true);
}
void preloadsound(int n)
{
preloadsound(gamesounds, gameslots, n);
}
void preloadmapsound(int n)
{
preloadsound(mapsounds, mapslots, n);
}
void preloadmapsounds()
{
const vector<extentity *> &ents = entities::getents();
loopv(ents)
{
extentity &e = *ents[i];
if(e.type==ET_SOUND) preloadsound(mapsounds, mapslots, e.attr1);
}
}
int playsound(int n, const vec *loc, extentity *ent, int flags, int loops, int fade, int chanid, int radius, int expire)
{
if(nosound || !soundvol || minimized) return -1;
vector<soundslot> &slots = ent || flags&SND_MAP ? mapslots : gameslots;
vector<soundconfig> &sounds = ent || flags&SND_MAP ? mapsounds : gamesounds;
if(!sounds.inrange(n)) { conoutf(CON_WARN, "unregistered sound: %d", n); return -1; }
soundconfig &config = sounds[n];
if(loc && (maxsoundradius || radius > 0))
{
// cull sounds that are unlikely to be heard
int rad = radius > 0 ? (maxsoundradius ? min(maxsoundradius, radius) : radius) : maxsoundradius;
if(camera1->o.dist(*loc) > 1.5f*rad)
{
if(channels.inrange(chanid) && channels[chanid].inuse && config.hasslot(channels[chanid].slot, slots))
{
Mix_HaltChannel(chanid);
freechannel(chanid);
}
return -1;
}
}
if(chanid < 0)
{
if(config.maxuses)
{
int uses = 0;
loopv(channels) if(channels[i].inuse && config.hasslot(channels[i].slot, slots) && ++uses >= config.maxuses) return -1;
}
// avoid bursts of sounds with heavy packetloss and in sp
static int soundsatonce = 0, lastsoundmillis = 0;
if(totalmillis == lastsoundmillis) soundsatonce++; else soundsatonce = 1;
lastsoundmillis = totalmillis;
if(maxsoundsatonce && soundsatonce > maxsoundsatonce) return -1;
}
if(channels.inrange(chanid))
{
soundchannel &chan = channels[chanid];
if(chan.inuse && config.hasslot(chan.slot, slots))
{
if(loc) chan.loc = *loc;
else if(chan.hasloc()) chan.clearloc();
return chanid;
}
}
if(fade < 0) return -1;
soundslot &slot = slots[config.chooseslot()];
if(!slot.sample->chunk && !loadsoundslot(slot)) return -1;
if(dbgsound) conoutf("sound: %s", slot.sample->name);
chanid = -1;
loopv(channels) if(!channels[i].inuse) { chanid = i; break; }
if(chanid < 0 && channels.length() < maxchannels) chanid = channels.length();
if(chanid < 0) loopv(channels) if(!channels[i].volume) { chanid = i; break; }
if(chanid < 0) return -1;
SDL_LockAudio(); // must lock here to prevent freechannel/Mix_SetPanning race conditions
if(channels.inrange(chanid) && channels[chanid].inuse)
{
Mix_HaltChannel(chanid);
freechannel(chanid);
}
soundchannel &chan = newchannel(chanid, &slot, loc, ent, flags, radius);
updatechannel(chan);
int playing = -1;
if(fade)
{
Mix_Volume(chanid, chan.volume);
playing = expire >= 0 ? Mix_FadeInChannelTimed(chanid, slot.sample->chunk, loops, fade, expire) : Mix_FadeInChannel(chanid, slot.sample->chunk, loops, fade);
}
else playing = expire >= 0 ? Mix_PlayChannelTimed(chanid, slot.sample->chunk, loops, expire) : Mix_PlayChannel(chanid, slot.sample->chunk, loops);
if(playing >= 0) syncchannel(chan);
else freechannel(chanid);
SDL_UnlockAudio();
return playing;
}
void stopsounds()
{
loopv(channels) if(channels[i].inuse)
{
Mix_HaltChannel(i);
freechannel(i);
}
}
bool stopsound(int n, int chanid, int fade)
{
if(!channels.inrange(chanid) || !channels[chanid].inuse || !gamesounds.inrange(n) || !gamesounds[n].hasslot(channels[chanid].slot, gameslots)) return false;
if(dbgsound) conoutf("stopsound: %s", channels[chanid].slot->sample->name);
if(!fade || !Mix_FadeOutChannel(chanid, fade))
{
Mix_HaltChannel(chanid);
freechannel(chanid);
}
return true;
}
int playsoundname(const char *s, const vec *loc, int vol, int flags, int loops, int fade, int chanid, int radius, int expire)
{
if(!vol) vol = 100;
int id = findsound(s, vol, gamesounds, gameslots);
if(id < 0) id = addsound(s, vol, 0, gamesounds, gameslots);
return playsound(id, loc, NULL, flags, loops, fade, chanid, radius, expire);
}
void sound(int *n) { playsound(*n); }
COMMAND(sound, "i");
void resetsound()
{
const SDL_version *v = Mix_Linked_Version();
if(SDL_VERSIONNUM(v->major, v->minor, v->patch) <= SDL_VERSIONNUM(1, 2, 8))
{
conoutf(CON_ERROR, "Sound reset not available in-game due to SDL_mixer-1.2.8 bug. Please restart for changes to take effect.");
return;
}
clearchanges(CHANGE_SOUND);
if(!nosound)
{
enumerate(samples, soundsample, s, s.cleanup());
if(music)
{
Mix_HaltMusic();
Mix_FreeMusic(music);
}
if(musicstream) musicstream->seek(0, SEEK_SET);
Mix_CloseAudio();
}
initsound();
resetchannels();
if(nosound)
{
DELETEA(musicfile);
DELETEA(musicdonecmd);
music = NULL;
gamesounds.setsize(0);
mapsounds.setsize(0);
samples.clear();
return;
}
if(music && loadmusic(musicfile))
{
Mix_PlayMusic(music, musicdonecmd ? 0 : -1);
Mix_VolumeMusic((musicvol*MAXVOL)/255);
}
else
{
DELETEA(musicfile);
DELETEA(musicdonecmd);
}
}
COMMAND(resetsound, "");
#ifdef WIN32
#include <wchar.h>
#else
#include <unistd.h>
#ifdef _POSIX_SHARED_MEMORY_OBJECTS
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/mman.h>
#include <fcntl.h>
#include <wchar.h>
#endif
#endif
#if defined(WIN32) || defined(_POSIX_SHARED_MEMORY_OBJECTS)
struct MumbleInfo
{
int version, timestamp;
vec pos, front, top;
wchar_t name[256];
};
#endif
#ifdef WIN32
static HANDLE mumblelink = NULL;
static MumbleInfo *mumbleinfo = NULL;
#define VALID_MUMBLELINK (mumblelink && mumbleinfo)
#elif defined(_POSIX_SHARED_MEMORY_OBJECTS)
static int mumblelink = -1;
static MumbleInfo *mumbleinfo = (MumbleInfo *)-1;
#define VALID_MUMBLELINK (mumblelink >= 0 && mumbleinfo != (MumbleInfo *)-1)
#endif
#ifdef VALID_MUMBLELINK
VARFP(mumble, 0, 1, 1, { if(mumble) initmumble(); else closemumble(); });
#else
VARFP(mumble, 0, 0, 1, { if(mumble) initmumble(); else closemumble(); });
#endif
void initmumble()
{
if(!mumble) return;
#ifdef VALID_MUMBLELINK
if(VALID_MUMBLELINK) return;
#ifdef WIN32
mumblelink = OpenFileMapping(FILE_MAP_ALL_ACCESS, FALSE, "MumbleLink");
if(mumblelink)
{
mumbleinfo = (MumbleInfo *)MapViewOfFile(mumblelink, FILE_MAP_ALL_ACCESS, 0, 0, sizeof(MumbleInfo));
if(mumbleinfo) wcsncpy(mumbleinfo->name, L"Sauerbraten", 256);
}
#elif defined(_POSIX_SHARED_MEMORY_OBJECTS)
defformatstring(shmname)("/MumbleLink.%d", getuid());
mumblelink = shm_open(shmname, O_RDWR, 0);
if(mumblelink >= 0)
{
mumbleinfo = (MumbleInfo *)mmap(NULL, sizeof(MumbleInfo), PROT_READ|PROT_WRITE, MAP_SHARED, mumblelink, 0);
if(mumbleinfo != (MumbleInfo *)-1) wcsncpy(mumbleinfo->name, L"Sauerbraten", 256);
}
#endif
if(!VALID_MUMBLELINK) closemumble();
#else
conoutf(CON_ERROR, "Mumble positional audio is not available on this platform.");
#endif
}
void closemumble()
{
#ifdef WIN32
if(mumbleinfo) { UnmapViewOfFile(mumbleinfo); mumbleinfo = NULL; }
if(mumblelink) { CloseHandle(mumblelink); mumblelink = NULL; }
#elif defined(_POSIX_SHARED_MEMORY_OBJECTS)
if(mumbleinfo != (MumbleInfo *)-1) { munmap(mumbleinfo, sizeof(MumbleInfo)); mumbleinfo = (MumbleInfo *)-1; }
if(mumblelink >= 0) { close(mumblelink); mumblelink = -1; }
#endif
}
static inline vec mumblevec(const vec &v, bool pos = false)
{
// change from X left, Z up, Y forward to X right, Y up, Z forward
// 8 cube units = 1 meter
vec m(-v.x, v.z, v.y);
if(pos) m.div(8);
return m;
}
void updatemumble()
{
#ifdef VALID_MUMBLELINK
if(!VALID_MUMBLELINK) return;
static int timestamp = 0;
mumbleinfo->version = 1;
mumbleinfo->timestamp = ++timestamp;
mumbleinfo->pos = mumblevec(player->o, true);
mumbleinfo->front = mumblevec(vec(RAD*player->yaw, RAD*player->pitch));
mumbleinfo->top = mumblevec(vec(RAD*player->yaw, RAD*(player->pitch+90)));
#endif
}
|
; A305157: a(n) = 164*2^n - 99.
; 65,229,557,1213,2525,5149,10397,20893,41885,83869,167837,335773,671645,1343389,2686877,5373853,10747805,21495709,42991517,85983133,171966365,343932829,687865757,1375731613,2751463325,5502926749,11005853597,22011707293,44023414685,88046829469,176093659037,352187318173,704374636445,1408749272989,2817498546077,5634997092253,11269994184605,22539988369309,45079976738717,90159953477533,180319906955165,360639813910429,721279627820957,1442559255642013,2885118511284125,5770237022568349,11540474045136797,23080948090273693,46161896180547485,92323792361095069,184647584722190237,369295169444380573,738590338888761245,1477180677777522589,2954361355555045277,5908722711110090653,11817445422220181405,23634890844440362909,47269781688880725917,94539563377761451933,189079126755522903965,378158253511045808029,756316507022091616157,1512633014044183232413,3025266028088366464925,6050532056176732929949,12101064112353465859997,24202128224706931720093,48404256449413863440285,96808512898827726880669,193617025797655453761437,387234051595310907522973,774468103190621815046045,1548936206381243630092189,3097872412762487260184477,6195744825524974520369053,12391489651049949040738205,24782979302099898081476509,49565958604199796162953117,99131917208399592325906333,198263834416799184651812765,396527668833598369303625629,793055337667196738607251357,1586110675334393477214502813,3172221350668786954429005725,6344442701337573908858011549,12688885402675147817716023197,25377770805350295635432046493,50755541610700591270864093085,101511083221401182541728186269,203022166442802365083456372637,406044332885604730166912745373,812088665771209460333825490845,1624177331542418920667650981789,3248354663084837841335301963677,6496709326169675682670603927453,12993418652339351365341207855005,25986837304678702730682415710109,51973674609357405461364831420317,103947349218714810922729662840733
mov $1,2
pow $1,$0
sub $1,1
mul $1,164
add $1,65
mov $0,$1
|
////////////////////////////////////////////////////////////////////////////////////////////////////
//
// Project: Embedded Learning Library (ELL)
// File: DgmlGraph.h
// Authors: Chris Lovett
//
////////////////////////////////////////////////////////////////////////////////////////////////////
#include "Graph.h"
#include "StringUtil.h"
using namespace ell::utilities;
void Graph::AddStyle(GraphStyle style)
{
_styles.push_back(style);
}
void Graph::AddProperty(GraphProperty prop)
{
_properties.push_back(prop);
}
GraphNode& Graph::GetOrCreateGroup(const std::string& id, const std::string& label)
{
if (_nodes.find(id) == _nodes.end())
{
GraphNode node{ id, label, true };
_nodes[id] = node;
}
return _nodes[id];
}
GraphNode* Graph::GetNode(const std::string& id)
{
if (_nodes.find(id) == _nodes.end())
{
return nullptr;
}
return &_nodes[id];
}
GraphNode& Graph::GetOrCreateNode(const std::string& id, const std::string& label)
{
if (_nodes.find(id) == _nodes.end())
{
GraphNode node{ id, label };
_nodes[id] = node;
}
return _nodes[id];
}
GraphLink& Graph::GetOrCreateLink(GraphNode& source, GraphNode& target, const std::string& category)
{
std::string key = source.GetId() + "->" + target.GetId();
if (_links.find(key) == _links.end())
{
GraphLink link{ source, target, category };
_links[key] = link;
}
return _links[key];
}
std::string Graph::EscapeAttribute(const std::string& value)
{
std::string result(value);
ReplaceAll(result, "&", "&");
ReplaceAll(result, "<", "<");
ReplaceAll(result, ">", ">");
ReplaceAll(result, "'", "'");
return result;
}
std::string Graph::ValidDotIdentifier(const std::string& value)
{
std::string result(value);
ReplaceAll(result, "&", "_");
ReplaceAll(result, "<", "_");
ReplaceAll(result, ">", "_");
ReplaceAll(result, "(", "_");
ReplaceAll(result, ")", "_");
ReplaceAll(result, "'", "_");
ReplaceAll(result, ",", "_");
return result;
}
void Graph::SaveDot(std::ostream& fout)
{
fout << "digraph network_graph {";
for (auto ptr = _nodes.begin(), end = _nodes.end(); ptr != end; ptr++)
{
GraphNode& node = ptr->second;
fout << ValidDotIdentifier(node.GetId()) << " [ label=\"" << node.GetLabel() << "\"";
auto node_properties = node.GetProperties();
for (auto iter = node_properties.begin(), lastProperty = node_properties.end(); iter != lastProperty; iter++)
{
auto pair = *iter;
fout << ", " << pair.first << "=\"" << pair.second << "\"";
}
fout << "];\n";
}
for (auto ptr = _links.begin(), end = _links.end(); ptr != end; ptr++)
{
GraphLink link = ptr->second;
fout << ValidDotIdentifier(link.GetSource().GetId()) << " -> " << ValidDotIdentifier(link.GetTarget().GetId()) << ";\n";
}
fout << "}";
}
void Graph::SaveDgml(std::ostream& fout)
{
fout << "<DirectedGraph xmlns='http://schemas.microsoft.com/vs/2009/dgml'>" << std::endl;
fout << " <Nodes>" << std::endl;
for (auto ptr = _nodes.begin(), end = _nodes.end(); ptr != end; ptr++)
{
GraphNode& node = ptr->second;
fout << " <Node Id='" << EscapeAttribute(node.GetId()) << "' Label='" << EscapeAttribute(node.GetLabel()) << "'";
if (node.GetIsGroup())
{
fout << " Group='Expanded'";
}
auto node_properties = node.GetProperties();
for (auto iter = node_properties.begin(), lastProperty = node_properties.end(); iter != lastProperty; iter++)
{
auto pair = *iter;
fout << " " << pair.first << "='" << EscapeAttribute(pair.second) << "'";
}
fout << "/>" << std::endl;
}
fout << " </Nodes>" << std::endl;
fout << " <Links>" << std::endl;
for (auto ptr = _links.begin(), end = _links.end(); ptr != end; ptr++)
{
GraphLink& link = ptr->second;
fout << " <Link Source='" << EscapeAttribute(link.GetSource().GetId()) << "' Target='" << EscapeAttribute(link.GetTarget().GetId()) << "'";
if (link.GetCategory().size() > 0)
{
fout << " Category='" << EscapeAttribute(link.GetCategory()) << "'";
}
fout << "/>" << std::endl;
}
fout << " </Links>" << std::endl;
fout << " <Properties>" << std::endl;
for (auto ptr = _properties.begin(), end = _properties.end(); ptr != end; ptr++)
{
GraphProperty p = *ptr;
fout << " <Property Id='" << EscapeAttribute(p.GetId()) << "' Label='" << EscapeAttribute(p.GetLabel()) << "' Description='" << EscapeAttribute(p.GetDescription()) << "' DataType='" << EscapeAttribute(p.GetDataType()) << "'/>" << std::endl;
}
fout << " </Properties>" << std::endl;
fout << " <Styles>" << std::endl;
for (auto ptr = _styles.begin(), end = _styles.end(); ptr != end; ptr++)
{
GraphStyle style = *ptr;
fout << " <Style TargetType='" << EscapeAttribute(style.GetTargetType()) << "' GroupLabel='" << EscapeAttribute(style.GetGroupLabel()) << "' ValueLabel='" << EscapeAttribute(style.GetValueLabel()) << "'";
fout << ">" << std::endl;
if (style.GetCondition().GetExpression() != "")
{
fout << " <Condition Expression='" << EscapeAttribute(style.GetCondition().GetExpression()) << "'/>" << std::endl;
}
auto setters = style.GetSetters();
for (auto s = setters.begin(), e = setters.end(); s != e; s++)
{
GraphStyleSetter setter = *s;
fout << " <Setter Property='" << EscapeAttribute(setter.GetProperty()) << "'";
if (setter.GetExpression() != "")
{
fout << " Expression='" << EscapeAttribute(setter.GetExpression()) << "'/>" << std::endl;
}
else
{
fout << " Value='" << EscapeAttribute(setter.GetValue()) << "'/>" << std::endl;
}
}
fout << " </Style>" << std::endl;
}
fout << " </Styles>" << std::endl;
fout << "</DirectedGraph>" << std::endl;
}
GraphNode::GraphNode(std::string id, std::string label, bool isGroup)
{
_id = id;
_label = label;
_is_group = isGroup;
}
GraphNode::GraphNode(const GraphNode& other)
: _id(other._id), _label(other._label), _is_group(other._is_group)
{
}
GraphNode& GraphNode::operator=(GraphNode& other)
{
this->_id = other.GetId();
this->_label = other.GetLabel();
this->_is_group = other.GetIsGroup();
return *this;
}
const std::string& GraphNode::GetProperty(const std::string& name)
{
return _properties[name];
}
void GraphNode::SetProperty(const std::string& name, const std::string& value)
{
_properties[name] = value;
}
GraphStyleSetter::GraphStyleSetter(std::string propertyName, std::string value, std::string expression)
{
_property = propertyName;
_value = value;
_expression = expression;
}
GraphStyleCondition::GraphStyleCondition(std::string expression)
{
_expression = expression;
}
GraphStyleCondition::GraphStyleCondition(const GraphStyleCondition& other)
{
_expression = other._expression;
}
GraphStyle::GraphStyle(std::string targetType, std::string groupLabel, std::string valueLabel, GraphStyleCondition condition)
: _condition(condition)
{
_targetType = targetType;
_groupLabel = groupLabel;
_valueLabel = valueLabel;
}
GraphProperty::GraphProperty(std::string id, std::string label, std::string description, std::string dataType)
{
_id = id;
_label = label;
_description = description;
_dataType = dataType;
}
GraphLink::GraphLink(GraphNode& source, GraphNode& target, std::string category)
: _source(source), _target(target), _category(category)
{
}
GraphLink::GraphLink(const GraphLink& other)
: _source(other._source), _target(other._target), _category(other._category)
{
}
GraphLink& GraphLink::operator=(GraphLink& other)
{
this->_source = other.GetSource();
this->_target = other.GetTarget();
this->_category = other.GetCategory();
return *this;
}
GraphLink::GraphLink() = default;
GraphNode::GraphNode() = default;
GraphLink::GraphLink(GraphLink&& other) = default;
GraphNode::GraphNode(GraphNode&& other) = default; |
section .text
org 0x100
mov ah, 0x9
mox dx, hello
int 0x21
mox ax, 0x4c00
int 0x21
section .data
hello: db 'Hello World!', 13, 10, '$'
|
; A005053: Expand (1-2*x)/(1-5*x).
; 1,3,15,75,375,1875,9375,46875,234375,1171875,5859375,29296875,146484375,732421875,3662109375,18310546875,91552734375,457763671875,2288818359375,11444091796875,57220458984375,286102294921875,1430511474609375,7152557373046875
mov $1,5
pow $1,$0
mul $1,30
div $1,100
mul $1,2
add $1,1
|
; A120198: a(1)=5; a(n)=floor((44+sum(a(1) to a(n-1)))/8).
; 5,6,6,7,8,9,10,11,13,14,16,18,20,23,26,29,33,37,41,47,52,59,66,75,84,94,106,119,134,151,170,191,215,242,272,306,344,387,436,490
mov $2,2
mov $7,$0
lpb $2
mov $0,$7
sub $2,1
add $0,$2
mov $5,0
lpb $0
sub $0,1
mov $4,$5
add $5,4
div $5,8
add $5,5
add $5,$4
lpe
mov $3,$2
mov $6,$5
lpb $3
mov $1,$6
sub $3,1
lpe
lpe
lpb $7
sub $1,$6
mov $7,0
lpe
|
mov ax, 0x7c0
mov ds, ax
mov es, ax
mov bp, 0x8000
mov sp, bp
mov bx, 0x8001
mov dh, 2
call disk_load ;bios sets dl to boot drive nr.
mov dx, [0x8001]
call print_hex
call print_nl
mov dx, [0x8201] ;0x9000 + 512
call print_hex
jmp $
%include "boot_sect_print.asm"
%include "boot_sect_print_hex.asm"
%include "boot_sect_disk.asm"
times 510 -($-$$) db 0
dw 0xaa55
;since qemu loads this file into an emulated hdd, add two data sectors
times 256 dw 0xdada
times 256 dw 0xface |
; A185391: a(n) = Sum_{k=0..n} A185390(n,k) * k.
; Submitted by Christian Krause
; 0,1,10,114,1556,25080,468462,9971920,238551336,6339784320,185391061010,5917263922944,204735466350780,7633925334590464,305188474579874550,13023103577435351040,590850477768105474128,28401410966866912051200,1441935117039649859464986,77103971245747601072128000,4331442482780866933991448420,255043548003911856505059803136,15707664942972696868983911448830,1009929598628053714602298128728064,67668611669641410581427657823515000,4717311462820392920156613927396966400,341633590761894323067565547381817506082
mov $2,$0
mov $3,$0
mov $4,-1
lpb $0
sub $0,1
mov $1,$3
add $3,$4
mul $3,$2
add $3,$1
mul $4,$0
lpe
mov $0,$3
|
org 0000h ;
MOV P1,#00h ;
MOV P2,#00h ;
principal:
setb p1.0 ;
lcall tempo ;
setb p1.1 ;
clr p1.0 ;
lcall tempo ;
setb p1.2 ;
clr p1.1 ;
lcall tempo ;
setb p1.3 ;
clr p1.2 ;
lcall tempo ;
setb p1.4 ;
clr p1.3 ;
lcall tempo ;
setb p1.5 ;
clr p1.4 ;
lcall tempo ;
setb p1.6 ;
clr p1.5 ;
lcall tempo ;
setb p1.7 ;
clr p1.6 ;
lcall tempo ;
clr p1.7 ;
lcall tempo ;
lcall volta ;
ljmp principal ;
tempo:
mov r6,#155 ;
mov r5,#150 ;
tempo1:
djnz r6,tempo1 ;
mov r6,#155 ;
djnz r5,tempo1 ;
ret ;
volta:
setb p1.7 ;
lcall tempo ;
setb p1.6 ;
clr p1.7 ;
lcall tempo ;
setb p1.5 ;
clr p1.6 ;
lcall tempo ;
setb p1.4 ;
clr p1.5 ;
lcall tempo ;
setb p1.3 ;
clr p1.4 ;
lcall tempo ;
setb p1.2 ;
clr p1.3 ;
lcall tempo ;
setb p1.1 ;
clr p1.2 ;
lcall tempo ;
setb p1.0 ;
clr p1.1 ;
lcall tempo ;
clr p1.0 ;
lcall tempo ;
lcall volta2 ;
volta1:
setb p1.4 ;
setb p1.3 ;
lcall tempo ;
setb p1.5 ;
setb p1.2 ;
clr p1.4 ;
clr p1.3 ;
lcall tempo ;
setb p1.6 ;
setb p1.1 ;
clr p1.5 ;
clr p1.2 ;
lcall tempo ;
setb p1.7 ;
setb p1.0 ;
clr p1.6 ;
clr p1.1 ;
lcall tempo ;
clr p1.7 ;
clr p1.0 ;
lcall tempo ;
volta2:
setb p1.7 ;
setb p1.0 ;
lcall tempo ;
setb p1.6 ;
setb p1.1 ;
clr p1.7 ;
clr p1.0 ;
lcall tempo ;
setb p1.5 ;
setb p1.2 ;
clr p1.6 ;
clr p1.1 ;
lcall tempo ;
setb p1.4 ;
setb p1.3 ;
clr p1.5 ;
clr p1.2 ;
lcall tempo ;
clr p1.4 ;
clr p1.3 ;
lcall tempo ;
lcall volta3 ;
volta3:
setb p2.0 ;
lcall tempo ;
lcall tempo ;
clr p2.0 ;
setb p2.1 ;
lcall tempo ;
lcall tempo ;
clr p2.1 ;
setb p2.2 ;
lcall tempo ;
lcall tempo ;
clr p2.2 ;
setb p2.3 ;
lcall tempo ;
lcall tempo ;
clr p2.3 ;
lcall tempo ;
lcall principal ; |
// Copyright (c) 2011-2016 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/bitcoin-config.h"
#endif
#include "askpassphrasedialog.h"
#include "ui_askpassphrasedialog.h"
#include "guiconstants.h"
#include "walletmodel.h"
#include "support/allocators/secure.h"
#include <QKeyEvent>
#include <QMessageBox>
#include <QPushButton>
AskPassphraseDialog::AskPassphraseDialog(Mode _mode, QWidget *parent) :
QDialog(parent),
ui(new Ui::AskPassphraseDialog),
mode(_mode),
model(0),
fCapsLock(false)
{
ui->setupUi(this);
ui->passEdit1->setMinimumSize(ui->passEdit1->sizeHint());
ui->passEdit2->setMinimumSize(ui->passEdit2->sizeHint());
ui->passEdit3->setMinimumSize(ui->passEdit3->sizeHint());
ui->passEdit1->setMaxLength(MAX_PASSPHRASE_SIZE);
ui->passEdit2->setMaxLength(MAX_PASSPHRASE_SIZE);
ui->passEdit3->setMaxLength(MAX_PASSPHRASE_SIZE);
// Setup Caps Lock detection.
ui->passEdit1->installEventFilter(this);
ui->passEdit2->installEventFilter(this);
ui->passEdit3->installEventFilter(this);
switch(mode)
{
case Encrypt: // Ask passphrase x2
ui->warningLabel->setText(tr("Enter the new passphrase to the wallet.<br/>Please use a passphrase of <b>ten or more random characters</b>, or <b>eight or more words</b>."));
ui->passLabel1->hide();
ui->passEdit1->hide();
setWindowTitle(tr("Encrypt wallet"));
break;
case Unlock: // Ask passphrase
ui->warningLabel->setText(tr("This operation needs your wallet passphrase to unlock the wallet."));
ui->passLabel2->hide();
ui->passEdit2->hide();
ui->passLabel3->hide();
ui->passEdit3->hide();
setWindowTitle(tr("Unlock wallet"));
break;
case Decrypt: // Ask passphrase
ui->warningLabel->setText(tr("This operation needs your wallet passphrase to decrypt the wallet."));
ui->passLabel2->hide();
ui->passEdit2->hide();
ui->passLabel3->hide();
ui->passEdit3->hide();
setWindowTitle(tr("Decrypt wallet"));
break;
case ChangePass: // Ask old passphrase + new passphrase x2
setWindowTitle(tr("Change passphrase"));
ui->warningLabel->setText(tr("Enter the old passphrase and new passphrase to the wallet."));
break;
}
textChanged();
connect(ui->passEdit1, SIGNAL(textChanged(QString)), this, SLOT(textChanged()));
connect(ui->passEdit2, SIGNAL(textChanged(QString)), this, SLOT(textChanged()));
connect(ui->passEdit3, SIGNAL(textChanged(QString)), this, SLOT(textChanged()));
}
AskPassphraseDialog::~AskPassphraseDialog()
{
secureClearPassFields();
delete ui;
}
void AskPassphraseDialog::setModel(WalletModel *_model)
{
this->model = _model;
}
void AskPassphraseDialog::accept()
{
SecureString oldpass, newpass1, newpass2;
if(!model)
return;
oldpass.reserve(MAX_PASSPHRASE_SIZE);
newpass1.reserve(MAX_PASSPHRASE_SIZE);
newpass2.reserve(MAX_PASSPHRASE_SIZE);
// TODO: get rid of this .c_str() by implementing SecureString::operator=(std::string)
// Alternately, find a way to make this input mlock()'d to begin with.
oldpass.assign(ui->passEdit1->text().toStdString().c_str());
newpass1.assign(ui->passEdit2->text().toStdString().c_str());
newpass2.assign(ui->passEdit3->text().toStdString().c_str());
secureClearPassFields();
switch(mode)
{
case Encrypt: {
if(newpass1.empty() || newpass2.empty())
{
// Cannot encrypt with empty passphrase
break;
}
QMessageBox::StandardButton retval = QMessageBox::question(this, tr("Confirm wallet encryption"),
tr("Warning: If you encrypt your wallet and lose your passphrase, you will <b>LOSE ALL OF YOUR AZZYCOINS</b>!") + "<br><br>" + tr("Are you sure you wish to encrypt your wallet?"),
QMessageBox::Yes|QMessageBox::Cancel,
QMessageBox::Cancel);
if(retval == QMessageBox::Yes)
{
if(newpass1 == newpass2)
{
if(model->setWalletEncrypted(true, newpass1))
{
QMessageBox::warning(this, tr("Wallet encrypted"),
"<qt>" +
tr("%1 will close now to finish the encryption process. "
"Remember that encrypting your wallet cannot fully protect "
"your azzycoins from being stolen by malware infecting your computer.").arg(tr(PACKAGE_NAME)) +
"<br><br><b>" +
tr("IMPORTANT: Any previous backups you have made of your wallet file "
"should be replaced with the newly generated, encrypted wallet file. "
"For security reasons, previous backups of the unencrypted wallet file "
"will become useless as soon as you start using the new, encrypted wallet.") +
"</b></qt>");
QApplication::quit();
}
else
{
QMessageBox::critical(this, tr("Wallet encryption failed"),
tr("Wallet encryption failed due to an internal error. Your wallet was not encrypted."));
}
QDialog::accept(); // Success
}
else
{
QMessageBox::critical(this, tr("Wallet encryption failed"),
tr("The supplied passphrases do not match."));
}
}
else
{
QDialog::reject(); // Cancelled
}
} break;
case Unlock:
if(!model->setWalletLocked(false, oldpass))
{
QMessageBox::critical(this, tr("Wallet unlock failed"),
tr("The passphrase entered for the wallet decryption was incorrect."));
}
else
{
QDialog::accept(); // Success
}
break;
case Decrypt:
if(!model->setWalletEncrypted(false, oldpass))
{
QMessageBox::critical(this, tr("Wallet decryption failed"),
tr("The passphrase entered for the wallet decryption was incorrect."));
}
else
{
QDialog::accept(); // Success
}
break;
case ChangePass:
if(newpass1 == newpass2)
{
if(model->changePassphrase(oldpass, newpass1))
{
QMessageBox::information(this, tr("Wallet encrypted"),
tr("Wallet passphrase was successfully changed."));
QDialog::accept(); // Success
}
else
{
QMessageBox::critical(this, tr("Wallet encryption failed"),
tr("The passphrase entered for the wallet decryption was incorrect."));
}
}
else
{
QMessageBox::critical(this, tr("Wallet encryption failed"),
tr("The supplied passphrases do not match."));
}
break;
}
}
void AskPassphraseDialog::textChanged()
{
// Validate input, set Ok button to enabled when acceptable
bool acceptable = false;
switch(mode)
{
case Encrypt: // New passphrase x2
acceptable = !ui->passEdit2->text().isEmpty() && !ui->passEdit3->text().isEmpty();
break;
case Unlock: // Old passphrase x1
case Decrypt:
acceptable = !ui->passEdit1->text().isEmpty();
break;
case ChangePass: // Old passphrase x1, new passphrase x2
acceptable = !ui->passEdit1->text().isEmpty() && !ui->passEdit2->text().isEmpty() && !ui->passEdit3->text().isEmpty();
break;
}
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(acceptable);
}
bool AskPassphraseDialog::event(QEvent *event)
{
// Detect Caps Lock key press.
if (event->type() == QEvent::KeyPress) {
QKeyEvent *ke = static_cast<QKeyEvent *>(event);
if (ke->key() == Qt::Key_CapsLock) {
fCapsLock = !fCapsLock;
}
if (fCapsLock) {
ui->capsLabel->setText(tr("Warning: The Caps Lock key is on!"));
} else {
ui->capsLabel->clear();
}
}
return QWidget::event(event);
}
bool AskPassphraseDialog::eventFilter(QObject *object, QEvent *event)
{
/* Detect Caps Lock.
* There is no good OS-independent way to check a key state in Qt, but we
* can detect Caps Lock by checking for the following condition:
* Shift key is down and the result is a lower case character, or
* Shift key is not down and the result is an upper case character.
*/
if (event->type() == QEvent::KeyPress) {
QKeyEvent *ke = static_cast<QKeyEvent *>(event);
QString str = ke->text();
if (str.length() != 0) {
const QChar *psz = str.unicode();
bool fShift = (ke->modifiers() & Qt::ShiftModifier) != 0;
if ((fShift && *psz >= 'a' && *psz <= 'z') || (!fShift && *psz >= 'A' && *psz <= 'Z')) {
fCapsLock = true;
ui->capsLabel->setText(tr("Warning: The Caps Lock key is on!"));
} else if (psz->isLetter()) {
fCapsLock = false;
ui->capsLabel->clear();
}
}
}
return QDialog::eventFilter(object, event);
}
static void SecureClearQLineEdit(QLineEdit* edit)
{
// Attempt to overwrite text so that they do not linger around in memory
edit->setText(QString(" ").repeated(edit->text().size()));
edit->clear();
}
void AskPassphraseDialog::secureClearPassFields()
{
SecureClearQLineEdit(ui->passEdit1);
SecureClearQLineEdit(ui->passEdit2);
SecureClearQLineEdit(ui->passEdit3);
}
|
page ,132
title memset - set sections of memory all to one byte
;***
;memset.asm - set a section of memory to all one byte
;
; Copyright (c) 1985-2001, Microsoft Corporation. All rights reserved.
;
;Purpose:
; contains the memset() routine
;
;Revision History:
; 05-07-84 RN initial version
; 06-30-87 SKS faster algorithm
; 05-17-88 SJM Add model-independent (large model) ifdef
; 08-04-88 SJM convert to cruntime/ add 32-bit support
; 08-19-88 JCR Enable word alignment code for all models/CPUs,
; Some code improvement
; 10-25-88 JCR General cleanup for 386-only code
; 10-27-88 JCR More optimization (dword alignment, no ebx usage, etc)
; 03-23-90 GJF Changed to _stdcall. Also, fixed the copyright.
; 05-10-91 GJF Back to _cdecl, sigh...
; 01-23-95 GJF Improved routine from Intel Israel. I fixed up the
; formatting and comments.
; 01-24-95 GJF Added FPO directive.
; 06-12-01 PML inc->add 1, dec->sub 1 for Pentium 4 perf (vs7#267015)
;
;*******************************************************************************
.xlist
include cruntime.inc
.list
page
;***
;char *memset(dst, value, count) - sets "count" bytes at "dst" to "value"
;
;Purpose:
; Sets the first "count" bytes of the memory starting
; at "dst" to the character value "value".
;
; Algorithm:
; char *
; memset (dst, value, count)
; char *dst;
; char value;
; unsigned int count;
; {
; char *start = dst;
;
; while (count--)
; *dst++ = value;
; return(start);
; }
;
;Entry:
; char *dst - pointer to memory to fill with value
; char value - value to put in dst bytes
; int count - number of bytes of dst to fill
;
;Exit:
; returns dst, with filled bytes
;
;Uses:
;
;Exceptions:
;
;*******************************************************************************
CODESEG
public memset
memset proc
.FPO ( 0, 3, 0, 0, 0, 0 )
mov edx,[esp + 0ch] ; edx = "count"
mov ecx,[esp + 4] ; ecx points to "dst"
test edx,edx ; 0?
jz short toend ; if so, nothing to do
xor eax,eax
mov al,[esp + 8] ; the byte "value" to be stored
; Align address on dword boundary
push edi ; preserve edi
mov edi,ecx ; edi = dest pointer
cmp edx,4 ; if it's less then 4 bytes
jb tail ; tail needs edi and edx to be initialized
neg ecx
and ecx,3 ; ecx = # bytes before dword boundary
jz short dwords ; jump if address already aligned
sub edx,ecx ; edx = adjusted count (for later)
adjust_loop:
mov [edi],al
add edi,1
sub ecx,1
jnz adjust_loop
dwords:
; set all 4 bytes of eax to [value]
mov ecx,eax ; ecx=0/0/0/value
shl eax,8 ; eax=0/0/value/0
add eax,ecx ; eax=0/0val/val
mov ecx,eax ; ecx=0/0/val/val
shl eax,10h ; eax=val/val/0/0
add eax,ecx ; eax = all 4 bytes = [value]
; Set dword-sized blocks
mov ecx,edx ; move original count to ecx
and edx,3 ; prepare in edx byte count (for tail loop)
shr ecx,2 ; adjust ecx to be dword count
jz tail ; jump if it was less then 4 bytes
rep stosd
main_loop_tail:
test edx,edx ; if there is no tail bytes,
jz finish ; we finish, and it's time to leave
; Set remaining bytes
tail:
mov [edi],al ; set remaining bytes
add edi,1
sub edx,1 ; if there is some more bytes
jnz tail ; continue to fill them
; Done
finish:
mov eax,[esp + 8] ; return dest pointer
pop edi ; restore edi
ret
toend:
mov eax,[esp + 4] ; return dest pointer
ret
memset endp
end
|
db 0 ; species ID placeholder
db 50, 85, 55, 90, 65, 65
; hp atk def spd sat sdf
db FIRE, FIRE ; type
db 190 ; catch rate
db 152 ; base exp
db NO_ITEM, NO_ITEM ; items
db GENDER_F50 ; gender ratio
db 20 ; step cycles to hatch
INCBIN "gfx/pokemon/ponyta/front.dimensions"
db GROWTH_MEDIUM_FAST ; growth rate
dn EGG_GROUND, EGG_GROUND ; egg groups
db 70 ; happiness
; tm/hm learnset
tmhm TOXIC, HIDDEN_POWER, SUNNY_DAY, PROTECT, FRUSTRATION, SOLARBEAM, IRON_TAIL, RETURN, DOUBLE_TEAM, FLAMETHROWER, FIRE_BLAST, FACADE, SECRET_POWER, REST, ATTRACT, OVERHEAT, ENDURE, WILL_O_WISP, CAPTIVATE, SLEEP_TALK, NATURAL_GIFT, SWAGGER, SUBSTITUTE, STRENGTH, BOUNCE, HEAT_WAVE, SNORE, SWIFT
; end
|
; A120848: 2^n+3^n-n.
; 2,4,11,32,93,270,787,2308,6809,20186,60063,179184,535525,1602502,4799339,14381660,43112241,129271218,387682615,1162785736,3487832957,10462450334,31385253891,94151567412,282446313673,847322163850,2541932937167,7625731702688,22877060890389,68630914235766,205892205836443,617675543767564,1853024483819105,5559069156490082
mov $1,2
pow $1,$0
mov $2,3
pow $2,$0
add $2,7
sub $2,$0
add $1,$2
sub $1,7
|
; A268262: Number of length-(3+1) 0..n arrays with new repeated values introduced in sequential order starting with zero.
; 9,42,143,378,837,1634,2907,4818,7553,11322,16359,22922,31293,41778,54707,70434,89337,111818,138303,169242,205109,246402,293643,347378,408177,476634,553367,639018,734253,839762,956259,1084482,1225193,1379178,1547247,1730234,1928997,2144418,2377403,2628882,2899809,3191162,3503943,3839178,4197917,4581234,4990227,5426018,5889753,6382602,6905759,7460442,8047893,8669378,9326187,10019634,10751057,11521818,12333303,13186922,14084109,15026322,16015043,17051778,18138057,19275434,20465487,21709818,23010053,24367842,25784859,27262802,28803393,30408378,32079527,33818634,35627517,37508018,39462003,41491362,43598009,45783882,48050943,50401178,52836597,55359234,57971147,60674418,63471153,66363482,69353559,72443562,75635693,78932178,82335267,85847234,89470377,93207018,97059503,101030202
mov $1,$0
add $1,1
pow $1,2
add $1,2
add $0,$1
mul $1,$0
mov $0,$1
|
.global s_prepare_buffers
s_prepare_buffers:
push %r12
push %r13
push %r14
push %r15
push %rbp
push %rcx
push %rdi
push %rsi
lea addresses_A_ht+0x19ab, %r15
nop
add %r13, %r13
mov (%r15), %r14
nop
sub $54086, %rbp
lea addresses_A_ht+0x155ab, %rsi
lea addresses_normal_ht+0x2616, %rdi
nop
and $24582, %r13
mov $44, %rcx
rep movsl
nop
nop
inc %r15
lea addresses_normal_ht+0x38a3, %rsi
lea addresses_WT_ht+0x1a5fb, %rdi
nop
nop
nop
nop
add $60686, %r13
mov $49, %rcx
rep movsl
nop
nop
nop
nop
inc %r14
lea addresses_WC_ht+0x165cd, %rsi
lea addresses_A_ht+0xc9ab, %rdi
nop
nop
nop
nop
nop
sub %r12, %r12
mov $58, %rcx
rep movsb
nop
nop
cmp $32219, %rbp
lea addresses_A_ht+0x8ab, %r13
and %r14, %r14
mov $0x6162636465666768, %rsi
movq %rsi, (%r13)
nop
nop
sub $35507, %r14
lea addresses_D_ht+0x1dfab, %rsi
lea addresses_WT_ht+0x1bf6f, %rdi
nop
nop
add $25390, %r13
mov $67, %rcx
rep movsq
nop
nop
add %rdi, %rdi
lea addresses_WT_ht+0x196bd, %rsi
lea addresses_WC_ht+0x89ab, %rdi
nop
nop
nop
nop
nop
dec %r15
mov $21, %rcx
rep movsb
nop
nop
nop
nop
sub $16453, %r13
pop %rsi
pop %rdi
pop %rcx
pop %rbp
pop %r15
pop %r14
pop %r13
pop %r12
ret
.global s_faulty_load
s_faulty_load:
push %r10
push %r12
push %r13
push %r9
push %rax
push %rbx
// Store
lea addresses_D+0x45c3, %r9
nop
nop
nop
nop
add $34707, %r13
mov $0x5152535455565758, %r10
movq %r10, %xmm5
vmovups %ymm5, (%r9)
nop
nop
nop
nop
nop
xor $3866, %r13
// Faulty Load
lea addresses_A+0x159ab, %rax
nop
nop
nop
nop
nop
cmp %r10, %r10
mov (%rax), %bx
lea oracles, %r9
and $0xff, %rbx
shlq $12, %rbx
mov (%r9,%rbx,1), %rbx
pop %rbx
pop %rax
pop %r9
pop %r13
pop %r12
pop %r10
ret
/*
<gen_faulty_load>
[REF]
{'src': {'same': False, 'congruent': 0, 'NT': False, 'type': 'addresses_A', 'size': 32, 'AVXalign': False}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'same': False, 'congruent': 0, 'NT': False, 'type': 'addresses_D', 'size': 32, 'AVXalign': False}}
[Faulty Load]
{'src': {'same': True, 'congruent': 0, 'NT': False, 'type': 'addresses_A', 'size': 2, 'AVXalign': False}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'src': {'same': False, 'congruent': 9, 'NT': False, 'type': 'addresses_A_ht', 'size': 8, 'AVXalign': False}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_A_ht', 'congruent': 10, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_normal_ht', 'congruent': 0, 'same': False}}
{'src': {'type': 'addresses_normal_ht', 'congruent': 3, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_WT_ht', 'congruent': 4, 'same': True}}
{'src': {'type': 'addresses_WC_ht', 'congruent': 1, 'same': True}, 'OP': 'REPM', 'dst': {'type': 'addresses_A_ht', 'congruent': 8, 'same': False}}
{'OP': 'STOR', 'dst': {'same': False, 'congruent': 8, 'NT': True, 'type': 'addresses_A_ht', 'size': 8, 'AVXalign': False}}
{'src': {'type': 'addresses_D_ht', 'congruent': 9, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_WT_ht', 'congruent': 2, 'same': False}}
{'src': {'type': 'addresses_WT_ht', 'congruent': 1, 'same': True}, 'OP': 'REPM', 'dst': {'type': 'addresses_WC_ht', 'congruent': 9, 'same': False}}
{'35': 21829}
35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35
*/
|
Name: mn_hp_smram.asm
Type: file
Size: 60893
Last-Modified: '1993-08-24T11:34:58Z'
SHA-1: 3C856154AE2C5C98CC7D8C08D42D1CAB9D0E2C53
Description: null
|
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#include <EMotionFX/CommandSystem/Source/AnimGraphParameterCommands.h>
#include <EMotionFX/CommandSystem/Source/AnimGraphConnectionCommands.h>
#include <EMotionFX/CommandSystem/Source/CommandManager.h>
#include <AzCore/std/sort.h>
#include <EMotionFX/Source/ActorInstance.h>
#include <EMotionFX/Source/ActorManager.h>
#include <EMotionFX/Source/AnimGraph.h>
#include <EMotionFX/Source/AnimGraphInstance.h>
#include <EMotionFX/Source/AnimGraphManager.h>
#include <EMotionFX/Source/AnimGraphNode.h>
#include <EMotionFX/Source/AnimGraphParameterCondition.h>
#include <EMotionFX/Source/AnimGraphTagCondition.h>
#include <EMotionFX/Source/AnimGraphStateMachine.h>
#include <EMotionFX/Source/BlendTreeParameterNode.h>
#include <EMotionFX/Source/Parameter/Parameter.h>
#include <EMotionFX/Source/Parameter/ParameterFactory.h>
#include <EMotionFX/Source/Parameter/ValueParameter.h>
#include <MCore/Source/AttributeFactory.h>
#include <MCore/Source/LogManager.h>
#include <MCore/Source/ReflectionSerializer.h>
namespace CommandSystem
{
//-------------------------------------------------------------------------------------
// Create a anim graph parameter
//-------------------------------------------------------------------------------------
CommandAnimGraphCreateParameter::CommandAnimGraphCreateParameter(MCore::Command* orgCommand)
: MCore::Command("AnimGraphCreateParameter", orgCommand)
{
}
CommandAnimGraphCreateParameter::~CommandAnimGraphCreateParameter() = default;
bool CommandAnimGraphCreateParameter::Execute(const MCore::CommandLine& parameters, AZStd::string& outResult)
{
// Get the parameter name.
AZStd::string name;
parameters.GetValue("name", this, name);
// Find the anim graph by using the id from command parameter.
const uint32 animGraphID = parameters.GetValueAsInt("animGraphID", this);
EMotionFX::AnimGraph* animGraph = EMotionFX::GetAnimGraphManager().FindAnimGraphByID(animGraphID);
if (!animGraph)
{
outResult = AZStd::string::format("Cannot add parameter '%s' to anim graph. Anim graph id '%i' is not valid.", name.c_str(), animGraphID);
return false;
}
// Check if the parameter name is unique and not used by any other parameter yet.
if (animGraph->FindParameterByName(name))
{
outResult = AZStd::string::format("There is already a parameter with the name '%s', please use a another, unique name.", name.c_str());
return false;
}
// Get the data type and check if it is a valid one.
AZ::Outcome<AZStd::string> valueString = parameters.GetValueIfExists("type", this);
if (!valueString.IsSuccess())
{
outResult = AZStd::string::format("The type was not specified. Please use -help or use the command browser to see a list of valid options.");
return false;
}
const AZ::TypeId parameterType(valueString.GetValue().c_str(), valueString.GetValue().size());
// Create the new parameter based on the dialog settings.
AZStd::unique_ptr<EMotionFX::Parameter> newParam(EMotionFX::ParameterFactory::Create(parameterType));
if (!newParam)
{
outResult = AZStd::string::format("Could not construct parameter '%s'", name.c_str());
return false;
}
newParam->SetName(name);
// Description.
AZStd::string description;
parameters.GetValue("description", this, description);
newParam->SetDescription(description);
valueString = parameters.GetValueIfExists("minValue", this);
if (valueString.IsSuccess())
{
if (!MCore::ReflectionSerializer::DeserializeIntoMember(newParam.get(), "minValue", valueString.GetValue()))
{
outResult = AZStd::string::format("Failed to initialize minimum value from string '%s'", valueString.GetValue().c_str());
return false;
}
}
valueString = parameters.GetValueIfExists("maxValue", this);
if (valueString.IsSuccess())
{
if (!MCore::ReflectionSerializer::DeserializeIntoMember(newParam.get(), "maxValue", valueString.GetValue()))
{
outResult = AZStd::string::format("Failed to initialize maximum value from string '%s'", valueString.GetValue().c_str());
return false;
}
}
valueString = parameters.GetValueIfExists("defaultValue", this);
if (valueString.IsSuccess())
{
if (!MCore::ReflectionSerializer::DeserializeIntoMember(newParam.get(), "defaultValue", valueString.GetValue()))
{
outResult = AZStd::string::format("Failed to initialize default value from string '%s'", valueString.GetValue().c_str());
return false;
}
}
valueString = parameters.GetValueIfExists("contents", this);
if (valueString.IsSuccess())
{
MCore::ReflectionSerializer::Deserialize(newParam.get(), valueString.GetValue());
}
// Check if the group parameter got specified.
const EMotionFX::GroupParameter* parentGroupParameter = nullptr;
valueString = parameters.GetValueIfExists("parent", this);
if (valueString.IsSuccess())
{
// Find the group parameter index and get a pointer to the group parameter.
parentGroupParameter = animGraph->FindGroupParameterByName(valueString.GetValue());
if (!parentGroupParameter)
{
MCore::LogWarning("The group parameter named '%s' could not be found. The parameter cannot be added to the group.", valueString.GetValue().c_str());
}
}
// The position inside the parameter array where the parameter should get added to.
const int insertAtIndex = parameters.GetValueAsInt("index", this);
const size_t parentGroupSize = parentGroupParameter ? parentGroupParameter->GetNumParameters() : animGraph->GetNumParameters();
if (insertAtIndex != -1 && (insertAtIndex < 0 || insertAtIndex > static_cast<int>(parentGroupSize)))
{
outResult = AZStd::string::format("Cannot insert parameter at index '%d'. Index is out of range.", insertAtIndex);
return false;
}
const bool paramResult = insertAtIndex == -1
? animGraph->AddParameter(newParam.get(), parentGroupParameter)
: animGraph->InsertParameter(insertAtIndex, newParam.get(), parentGroupParameter);
if (!paramResult)
{
outResult = AZStd::string::format("Could not add parameter: '%s.'", newParam->GetName().c_str());
return false;
}
const AZ::Outcome<size_t> parameterIndex = animGraph->FindParameterIndex(newParam.get());
AZ_Assert(parameterIndex.IsSuccess(), "Expected valid parameter index.");
newParam.release(); // adding the parameter succeeded, release the memory because it is owned by the AnimGraph
const EMotionFX::Parameter* param = animGraph->FindParameter(parameterIndex.GetValue());
if (azrtti_typeid(param) != azrtti_typeid<EMotionFX::GroupParameter>())
{
const AZ::Outcome<size_t> valueParameterIndex = animGraph->FindValueParameterIndex(static_cast<const EMotionFX::ValueParameter*>(param));
AZ_Assert(valueParameterIndex.IsSuccess(), "Expected valid value parameter index.");
// Update all anim graph instances.
const size_t numInstances = animGraph->GetNumAnimGraphInstances();
for (size_t i = 0; i < numInstances; ++i)
{
EMotionFX::AnimGraphInstance* animGraphInstance = animGraph->GetAnimGraphInstance(i);
animGraphInstance->InsertParameterValue(static_cast<uint32>(valueParameterIndex.GetValue()));
}
AZStd::vector<EMotionFX::AnimGraphObject*> affectedObjects;
animGraph->RecursiveCollectObjectsOfType(azrtti_typeid<EMotionFX::ObjectAffectedByParameterChanges>(), affectedObjects);
EMotionFX::GetAnimGraphManager().RecursiveCollectObjectsAffectedBy(animGraph, affectedObjects);
for (EMotionFX::AnimGraphObject* affectedObject : affectedObjects)
{
EMotionFX::ObjectAffectedByParameterChanges* affectedObjectByParameterChanges = azdynamic_cast<EMotionFX::ObjectAffectedByParameterChanges*>(affectedObject);
affectedObjectByParameterChanges->ParameterAdded(name);
}
}
// Set the parameter name as command result.
outResult = name.c_str();
// Save the current dirty flag and tell the anim graph that something got changed.
mOldDirtyFlag = animGraph->GetDirtyFlag();
animGraph->SetDirtyFlag(true);
return true;
}
bool CommandAnimGraphCreateParameter::Undo(const MCore::CommandLine& parameters, AZStd::string& outResult)
{
// Get the parameter name.
AZStd::string name;
parameters.GetValue("name", this, name);
// Find the anim graph by using the id from command parameter.
const uint32 animGraphID = parameters.GetValueAsInt("animGraphID", this);
EMotionFX::AnimGraph* animGraph = EMotionFX::GetAnimGraphManager().FindAnimGraphByID(animGraphID);
if (!animGraph)
{
outResult = AZStd::string::format("Cannot undo add parameter '%s' to anim graph. Anim graph id '%i' is not valid.", name.c_str(), animGraphID);
return false;
}
const AZStd::string commandString = AZStd::string::format("AnimGraphRemoveParameter -animGraphID %i -name \"%s\"", animGraph->GetID(), name.c_str());
AZStd::string result;
if (!GetCommandManager()->ExecuteCommandInsideCommand(commandString, result))
{
AZ_Error("EMotionFX", false, result.c_str());
}
// Set the dirty flag back to the old value.
animGraph->SetDirtyFlag(mOldDirtyFlag);
return true;
}
void CommandAnimGraphCreateParameter::InitSyntax()
{
GetSyntax().ReserveParameters(9);
GetSyntax().AddRequiredParameter("animGraphID", "The id of the anim graph.", MCore::CommandSyntax::PARAMTYPE_INT);
GetSyntax().AddRequiredParameter("type", "The type of this parameter (UUID).", MCore::CommandSyntax::PARAMTYPE_STRING);
GetSyntax().AddRequiredParameter("name", "The name of the parameter, which has to be unique inside the currently selected anim graph.", MCore::CommandSyntax::PARAMTYPE_STRING);
GetSyntax().AddParameter("description", "The description of the parameter.", MCore::CommandSyntax::PARAMTYPE_STRING, "");
GetSyntax().AddParameter("index", "The position where the parameter should be added. If the parameter is not specified it will get added to the end. This index is relative to the \"parent\" parameter", MCore::CommandSyntax::PARAMTYPE_INT, "-1");
GetSyntax().AddParameter("contents", "The serialized contents of the parameter (in reflected XML).", MCore::CommandSyntax::PARAMTYPE_STRING, "");
GetSyntax().AddParameter("parent", "The parent group name into which the parameter should be added. If not specified it will get added to the root group.", MCore::CommandSyntax::PARAMTYPE_STRING, "");
GetSyntax().AddParameter("updateUI", "Setting this to true will trigger a refresh of the parameter UI.", MCore::CommandSyntax::PARAMTYPE_BOOLEAN, "true");
}
const char* CommandAnimGraphCreateParameter::GetDescription() const
{
return "This command creates a anim graph parameter with given settings. The name of the parameter is returned on success.";
}
//-------------------------------------------------------------------------------------
// Remove a anim graph parameter
//-------------------------------------------------------------------------------------
CommandAnimGraphRemoveParameter::CommandAnimGraphRemoveParameter(MCore::Command* orgCommand)
: MCore::Command("AnimGraphRemoveParameter", orgCommand)
{
}
CommandAnimGraphRemoveParameter::~CommandAnimGraphRemoveParameter() = default;
bool CommandAnimGraphRemoveParameter::Execute(const MCore::CommandLine& parameters, AZStd::string& outResult)
{
// Get the parameter name.
parameters.GetValue("name", this, mName);
// Find the anim graph by using the id from command parameter.
const uint32 animGraphID = parameters.GetValueAsInt("animGraphID", this);
EMotionFX::AnimGraph* animGraph = EMotionFX::GetAnimGraphManager().FindAnimGraphByID(animGraphID);
if (!animGraph)
{
outResult = AZStd::string::format("Cannot remove parameter '%s' from anim graph. Anim graph id '%i' is not valid.", mName.c_str(), animGraphID);
return false;
}
// Check if there is a parameter with the given name.
const EMotionFX::Parameter* parameter = animGraph->FindParameterByName(mName);
if (!parameter)
{
outResult = AZStd::string::format("Cannot remove parameter '%s' from anim graph. There is no parameter with the given name.", mName.c_str());
return false;
}
AZ_Assert(azrtti_typeid(parameter) != azrtti_typeid<EMotionFX::GroupParameter>(), "CommmandAnimGraphRemoveParameter called for a group parameter");
const EMotionFX::GroupParameter* parentGroup = animGraph->FindParentGroupParameter(parameter);
const AZ::Outcome<size_t> parameterIndex = parentGroup ? parentGroup->FindRelativeParameterIndex(parameter) : animGraph->FindRelativeParameterIndex(parameter);
AZ_Assert(parameterIndex.IsSuccess(), "Expected valid parameter index");
// Store undo info before we remove it, so that we can recreate it later.
mType = azrtti_typeid(parameter);
mIndex = parameterIndex.GetValue();
mParent = parentGroup ? parentGroup->GetName() : "";
mContents = MCore::ReflectionSerializer::Serialize(parameter).GetValue();
AZ::Outcome<size_t> valueParameterIndex = AZ::Failure();
if (mType != azrtti_typeid<EMotionFX::GroupParameter>())
{
valueParameterIndex = animGraph->FindValueParameterIndex(static_cast<const EMotionFX::ValueParameter*>(parameter));
}
// Remove the parameter from the anim graph.
if (animGraph->RemoveParameter(const_cast<EMotionFX::Parameter*>(parameter)))
{
// Remove the parameter from all corresponding anim graph instances if it is a value parameter
if (mType != azrtti_typeid<EMotionFX::GroupParameter>())
{
AZStd::vector<EMotionFX::AnimGraphObject*> affectedObjects;
animGraph->RecursiveCollectObjectsOfType(azrtti_typeid<EMotionFX::ObjectAffectedByParameterChanges>(), affectedObjects);
EMotionFX::GetAnimGraphManager().RecursiveCollectObjectsAffectedBy(animGraph, affectedObjects);
for (EMotionFX::AnimGraphObject* affectedObject : affectedObjects)
{
EMotionFX::ObjectAffectedByParameterChanges* parameterDriven = azdynamic_cast<EMotionFX::ObjectAffectedByParameterChanges*>(affectedObject);
parameterDriven->ParameterRemoved(mName);
}
const size_t numInstances = animGraph->GetNumAnimGraphInstances();
for (size_t i = 0; i < numInstances; ++i)
{
EMotionFX::AnimGraphInstance* animGraphInstance = animGraph->GetAnimGraphInstance(i);
// Remove the parameter.
animGraphInstance->RemoveParameterValue(static_cast<uint32>(valueParameterIndex.GetValue()));
}
// Save the current dirty flag and tell the anim graph that something got changed.
mOldDirtyFlag = animGraph->GetDirtyFlag();
animGraph->SetDirtyFlag(true);
}
return true;
}
return false;
}
bool CommandAnimGraphRemoveParameter::Undo(const MCore::CommandLine& parameters, AZStd::string& outResult)
{
// Find the anim graph by using the id from command parameter.
const uint32 animGraphID = parameters.GetValueAsInt("animGraphID", this);
EMotionFX::AnimGraph* animGraph = EMotionFX::GetAnimGraphManager().FindAnimGraphByID(animGraphID);
if (!animGraph)
{
outResult = AZStd::string::format("Cannot undo remove parameter '%s' from anim graph. Anim graph id '%i' is not valid.", mName.c_str(), animGraphID);
return false;
}
const AZStd::string updateUI = parameters.GetValue("updateUI", this);
// Execute the command to create the parameter again.
AZStd::string commandString;
commandString = AZStd::string::format("AnimGraphCreateParameter -animGraphID %i -name \"%s\" -index %zu -type \"%s\" -contents {%s} -parent \"%s\" -updateUI %s",
animGraph->GetID(),
mName.c_str(),
mIndex,
mType.ToString<AZStd::string>().c_str(),
mContents.c_str(),
mParent.c_str(),
updateUI.c_str());
// The parameter will be restored to the right parent group because the index is absolute
// Execute the command.
if (!GetCommandManager()->ExecuteCommandInsideCommand(commandString, outResult))
{
AZ_Error("EMotionFX", false, outResult.c_str());
return false;
}
// Set the dirty flag back to the old value.
animGraph->SetDirtyFlag(mOldDirtyFlag);
return true;
}
void CommandAnimGraphRemoveParameter::InitSyntax()
{
GetSyntax().ReserveParameters(3);
GetSyntax().AddRequiredParameter("animGraphID", "The id of the anim graph.", MCore::CommandSyntax::PARAMTYPE_INT);
GetSyntax().AddRequiredParameter("name", "The name of the parameter inside the currently selected anim graph.", MCore::CommandSyntax::PARAMTYPE_STRING);
GetSyntax().AddParameter("updateUI", "Setting this to true will trigger a refresh of the parameter UI.", MCore::CommandSyntax::PARAMTYPE_BOOLEAN, "true");
}
const char* CommandAnimGraphRemoveParameter::GetDescription() const
{
return "This command removes a anim graph parameter with the specified name.";
}
//-------------------------------------------------------------------------------------
// Adjust a anim graph parameter
//-------------------------------------------------------------------------------------
CommandAnimGraphAdjustParameter::CommandAnimGraphAdjustParameter(MCore::Command* orgCommand)
: MCore::Command("AnimGraphAdjustParameter", orgCommand)
{
}
CommandAnimGraphAdjustParameter::~CommandAnimGraphAdjustParameter() = default;
bool CommandAnimGraphAdjustParameter::Execute(const MCore::CommandLine& parameters, AZStd::string& outResult)
{
// Get the parameter name.
parameters.GetValue("name", this, mOldName);
// Find the anim graph by using the id from command parameter.
const uint32 animGraphID = parameters.GetValueAsInt("animGraphID", this);
EMotionFX::AnimGraph* animGraph = EMotionFX::GetAnimGraphManager().FindAnimGraphByID(animGraphID);
if (!animGraph)
{
outResult = AZStd::string::format("Cannot adjust parameter '%s'. Anim graph with id '%d' not found.", mOldName.c_str(), animGraphID);
return false;
}
const EMotionFX::Parameter* parameter = animGraph->FindParameterByName(mOldName);
if (!parameter)
{
outResult = AZStd::string::format("There is no parameter with the name '%s'.", mOldName.c_str());
return false;
}
AZ::Outcome<size_t> oldValueParameterIndex = AZ::Failure();
if (azrtti_istypeof<EMotionFX::ValueParameter*>(parameter))
{
const EMotionFX::ValueParameter* valueParameter = static_cast<const EMotionFX::ValueParameter*>(parameter);
oldValueParameterIndex = animGraph->FindValueParameterIndex(valueParameter);
}
const EMotionFX::GroupParameter* currentParent = animGraph->FindParentGroupParameter(parameter);
// Store the undo info.
mOldType = azrtti_typeid(parameter);
mOldContents = MCore::ReflectionSerializer::Serialize(parameter).GetValue();
// Get the new name and check if it is valid.
AZStd::string newName;
parameters.GetValue("newName", this, newName);
if (!newName.empty())
{
if (newName == mOldName)
{
newName.clear();
}
else if (animGraph->FindParameterByName(newName))
{
outResult = AZStd::string::format("There is already a parameter with the name '%s', please use a unique name.", newName.c_str());
return false;
}
}
if (!newName.empty())
{
EMotionFX::Parameter* editableParameter = const_cast<EMotionFX::Parameter*>(parameter);
animGraph->RenameParameter(editableParameter, newName);
}
// Get the data type and check if it is a valid one.
bool changedType = false;
AZ::Outcome<AZStd::string> valueString = parameters.GetValueIfExists("type", this);
if (valueString.IsSuccess())
{
const AZ::TypeId type = AZ::TypeId::CreateString(valueString.GetValue().c_str(), valueString.GetValue().size());
if (type.IsNull())
{
outResult = AZStd::string::format("The type is not a valid UUID type. Please use -help or use the command browser to see a list of valid options.");
return false;
}
if (type != mOldType)
{
AZStd::unique_ptr<EMotionFX::Parameter> newParameter(EMotionFX::ParameterFactory::Create(type));
newParameter->SetName(newName.empty() ? mOldName : newName);
newParameter->SetDescription(parameter->GetDescription());
const AZ::Outcome<size_t> paramIndexRelativeToParent = currentParent ? currentParent->FindRelativeParameterIndex(parameter) : animGraph->FindRelativeParameterIndex(parameter);
AZ_Assert(paramIndexRelativeToParent.IsSuccess(), "Expected parameter to be in the parent");
if (!animGraph->RemoveParameter(const_cast<EMotionFX::Parameter*>(parameter)))
{
outResult = AZStd::string::format("Could not remove current parameter '%s' to change its type.", mOldName.c_str());
return false;
}
if (!animGraph->InsertParameter(paramIndexRelativeToParent.GetValue(), newParameter.get(), currentParent))
{
outResult = AZStd::string::format("Could not insert new parameter '%s' to change its type.", newName.c_str());
return false;
}
parameter = newParameter.release();
changedType = true;
}
}
EMotionFX::Parameter* mutableParam = const_cast<EMotionFX::Parameter*>(parameter);
// Get the value strings.
valueString = parameters.GetValueIfExists("minValue", this);
if (valueString.IsSuccess())
{
MCore::ReflectionSerializer::DeserializeIntoMember(mutableParam, "minValue", valueString.GetValue());
}
valueString = parameters.GetValueIfExists("maxValue", this);
if (valueString.IsSuccess())
{
MCore::ReflectionSerializer::DeserializeIntoMember(mutableParam, "maxValue", valueString.GetValue());
}
valueString = parameters.GetValueIfExists("defaultValue", this);
if (valueString.IsSuccess())
{
MCore::ReflectionSerializer::DeserializeIntoMember(mutableParam, "defaultValue", valueString.GetValue());
}
valueString = parameters.GetValueIfExists("description", this);
if (valueString.IsSuccess())
{
MCore::ReflectionSerializer::DeserializeIntoMember(mutableParam, "description", valueString.GetValue());
}
valueString = parameters.GetValueIfExists("contents", this);
if (valueString.IsSuccess())
{
MCore::ReflectionSerializer::Deserialize(mutableParam, valueString.GetValue());
}
if (azrtti_istypeof<EMotionFX::ValueParameter>(parameter))
{
const EMotionFX::ValueParameter* valueParameter = static_cast<const EMotionFX::ValueParameter*>(parameter);
const AZ::Outcome<size_t> valueParameterIndex = animGraph->FindValueParameterIndex(valueParameter);
AZ_Assert(valueParameterIndex.IsSuccess(), "Expect a valid value parameter index");
// Update all corresponding anim graph instances.
const size_t numInstances = animGraph->GetNumAnimGraphInstances();
for (uint32 i = 0; i < numInstances; ++i)
{
EMotionFX::AnimGraphInstance* animGraphInstance = animGraph->GetAnimGraphInstance(i);
// reinit the modified parameters
if (mOldType != azrtti_typeid<EMotionFX::GroupParameter>())
{
animGraphInstance->ReInitParameterValue(static_cast<uint32>(valueParameterIndex.GetValue()));
}
else
{
animGraphInstance->AddMissingParameterValues();
}
}
// Apply the name change., only required to do it if the type didn't change
if (!changedType)
{
if (!newName.empty())
{
AZStd::vector<EMotionFX::AnimGraphObject*> affectedObjects;
animGraph->RecursiveCollectObjectsOfType(azrtti_typeid<EMotionFX::ObjectAffectedByParameterChanges>(), affectedObjects);
EMotionFX::GetAnimGraphManager().RecursiveCollectObjectsAffectedBy(animGraph, affectedObjects);
for (EMotionFX::AnimGraphObject* affectedObject : affectedObjects)
{
EMotionFX::ObjectAffectedByParameterChanges* affectedObjectByParameterChanges = azdynamic_cast<EMotionFX::ObjectAffectedByParameterChanges*>(affectedObject);
affectedObjectByParameterChanges->ParameterRenamed(mOldName, newName);
}
}
}
else
{
// Changed the type, should be treated as remove/add
AZStd::vector<EMotionFX::AnimGraphObject*> affectedObjects;
animGraph->RecursiveCollectObjectsOfType(azrtti_typeid<EMotionFX::ObjectAffectedByParameterChanges>(), affectedObjects);
EMotionFX::GetAnimGraphManager().RecursiveCollectObjectsAffectedBy(animGraph, affectedObjects);
for (EMotionFX::AnimGraphObject* affectedObject : affectedObjects)
{
EMotionFX::ObjectAffectedByParameterChanges* affectedObjectByParameterChanges = azdynamic_cast<EMotionFX::ObjectAffectedByParameterChanges*>(affectedObject);
affectedObjectByParameterChanges->ParameterRemoved(mOldName);
affectedObjectByParameterChanges->ParameterAdded(newName);
}
}
// Save the current dirty flag and tell the anim graph that something got changed.
mOldDirtyFlag = animGraph->GetDirtyFlag();
animGraph->SetDirtyFlag(true);
}
else if (mOldType != azrtti_typeid<EMotionFX::GroupParameter>())
{
AZ_Assert(oldValueParameterIndex.IsSuccess(), "Unable to find parameter index when changing parameter to a group");
// Changed the type, should be treated as remove/add
AZStd::vector<EMotionFX::AnimGraphObject*> affectedObjects;
animGraph->RecursiveCollectObjectsOfType(azrtti_typeid<EMotionFX::ObjectAffectedByParameterChanges>(), affectedObjects);
EMotionFX::GetAnimGraphManager().RecursiveCollectObjectsAffectedBy(animGraph, affectedObjects);
for (EMotionFX::AnimGraphObject* affectedObject : affectedObjects)
{
EMotionFX::ObjectAffectedByParameterChanges* affectedObjectByParameterChanges = azdynamic_cast<EMotionFX::ObjectAffectedByParameterChanges*>(affectedObject);
affectedObjectByParameterChanges->ParameterRemoved(mOldName);
}
// Save the current dirty flag and tell the anim graph that something got changed.
mOldDirtyFlag = animGraph->GetDirtyFlag();
animGraph->SetDirtyFlag(true);
}
return true;
}
bool CommandAnimGraphAdjustParameter::Undo(const MCore::CommandLine& parameters, AZStd::string& outResult)
{
// Find the anim graph by using the id from command parameter.
const uint32 animGraphID = parameters.GetValueAsInt("animGraphID", this);
EMotionFX::AnimGraph* animGraph = EMotionFX::GetAnimGraphManager().FindAnimGraphByID(animGraphID);
if (!animGraph)
{
outResult = AZStd::string::format("Cannot adjust parameter to anim graph. Anim graph id '%d' is not valid.", animGraphID);
return false;
}
// get the name and check if it is unique
AZStd::string name;
AZStd::string newName;
parameters.GetValue("name", this, name);
parameters.GetValue("newName", this, newName);
// Get the parameter index.
AZ::Outcome<size_t> paramIndex = animGraph->FindParameterIndexByName(name.c_str());
if (!paramIndex.IsSuccess())
{
paramIndex = animGraph->FindParameterIndexByName(newName.c_str());
}
// If the neither the former nor the new parameter exist, return.
if (!paramIndex.IsSuccess())
{
if (newName.empty())
{
outResult = AZStd::string::format("There is no parameter with the name '%s'.", name.c_str());
}
else
{
outResult = AZStd::string::format("There is no parameter with the name '%s'.", newName.c_str());
}
return false;
}
// Construct and execute the command.
const AZStd::string commandString = AZStd::string::format("AnimGraphAdjustParameter -animGraphID %i -name \"%s\" -newName \"%s\" -type \"%s\" -contents {%s}",
animGraph->GetID(),
newName.c_str(),
name.c_str(),
mOldType.ToString<AZStd::string>().c_str(),
mOldContents.c_str());
if (!GetCommandManager()->ExecuteCommandInsideCommand(commandString, outResult))
{
AZ_Error("EMotionFX", false, outResult.c_str());
}
animGraph->SetDirtyFlag(mOldDirtyFlag);
return true;
}
void CommandAnimGraphAdjustParameter::InitSyntax()
{
GetSyntax().ReserveParameters(10);
GetSyntax().AddRequiredParameter("animGraphID", "The id of the anim graph.", MCore::CommandSyntax::PARAMTYPE_INT);
GetSyntax().AddRequiredParameter("name", "The name of the parameter inside the currently selected anim graph to modify.", MCore::CommandSyntax::PARAMTYPE_STRING);
GetSyntax().AddParameter("type", "The new type (UUID).", MCore::CommandSyntax::PARAMTYPE_STRING, "");
GetSyntax().AddParameter("newName", "The new name of the parameter.", MCore::CommandSyntax::PARAMTYPE_STRING, "");
GetSyntax().AddParameter("defaultValue", "The new default value of the parameter.", MCore::CommandSyntax::PARAMTYPE_STRING, "");
GetSyntax().AddParameter("minValue", "The new minimum value of the parameter. In case of checkboxes or strings this parameter value will be ignored.", MCore::CommandSyntax::PARAMTYPE_STRING, "");
GetSyntax().AddParameter("maxValue", "The new maximum value of the parameter. In case of checkboxes or strings this parameter value will be ignored.", MCore::CommandSyntax::PARAMTYPE_STRING, "");
GetSyntax().AddParameter("description", "The new description of the parameter.", MCore::CommandSyntax::PARAMTYPE_STRING, "");
GetSyntax().AddParameter("contents", "The contents of the parameter (serialized reflected XML)", MCore::CommandSyntax::PARAMTYPE_STRING, "");
GetSyntax().AddParameter("updateUI", "Setting this to true will trigger a refresh of the parameter UI.", MCore::CommandSyntax::PARAMTYPE_BOOLEAN, "true");
}
const char* CommandAnimGraphAdjustParameter::GetDescription() const
{
return "This command adjusts a anim graph parameter with given settings.";
}
//-------------------------------------------------------------------------------------
// Move a parameter to another position
//-------------------------------------------------------------------------------------
CommandAnimGraphMoveParameter::CommandAnimGraphMoveParameter(MCore::Command* orgCommand)
: MCore::Command("AnimGraphMoveParameter", orgCommand)
{
}
CommandAnimGraphMoveParameter::~CommandAnimGraphMoveParameter() = default;
bool CommandAnimGraphMoveParameter::Execute(const MCore::CommandLine& parameters, AZStd::string& outResult)
{
AZStd::string name;
parameters.GetValue("name", this, name);
// Find the anim graph by using the id from command parameter.
const uint32 animGraphID = parameters.GetValueAsInt("animGraphID", this);
EMotionFX::AnimGraph* animGraph = EMotionFX::GetAnimGraphManager().FindAnimGraphByID(animGraphID);
if (!animGraph)
{
outResult = AZStd::string::format("Cannot swap parameters. Anim graph id '%i' is not valid.", animGraphID);
return false;
}
AZ::Outcome<AZStd::string> parent = parameters.GetValueIfExists("parent", this);
// if parent is empty, the parameter is being moved (or already in) the root group
const EMotionFX::GroupParameter* destinationParent = animGraph->FindGroupParameterByName(parent.IsSuccess() ? parent.GetValue() : "");
if (!destinationParent)
{
outResult = AZStd::string::format("Could not find destination parent \"%s\"", parent.GetValue().c_str());
return false;
}
int32 destinationIndex = parameters.GetValueAsInt("index", this);
const EMotionFX::ParameterVector& siblingDestinationParamenters = destinationParent->GetChildParameters();
if (destinationIndex < 0 || destinationIndex > siblingDestinationParamenters.size())
{
outResult = AZStd::string::format("Index %d is out of bounds for parent \"%s\"", destinationIndex, parent.GetValue().c_str());
return false;
}
const EMotionFX::Parameter* parameter = animGraph->FindParameterByName(name);
if (!parameter)
{
outResult = AZStd::string::format("There is no parameter with the name '%s'.", name.c_str());
return false;
}
// Get the current data for undo
const EMotionFX::GroupParameter* currentParent = animGraph->FindParentGroupParameter(parameter);
if (currentParent)
{
mOldParent = currentParent->GetName();
mOldIndex = currentParent->FindRelativeParameterIndex(parameter).GetValue();
}
else
{
mOldParent.clear(); // means the root
mOldIndex = animGraph->FindRelativeParameterIndex(parameter).GetValue();
}
EMotionFX::ValueParameterVector valueParametersBeforeChange = animGraph->RecursivelyGetValueParameters();
// If the parameter being moved is a value parameter (not a group), we need to update the anim graph instances and
// nodes. To do so, we need to get the absolute index of the parameter before and after the move.
AZ::Outcome<size_t> valueIndexBeforeMove = AZ::Failure();
AZ::Outcome<size_t> valueIndexAfterMove = AZ::Failure();
const bool isValueParameter = azrtti_typeid(parameter) != azrtti_typeid<EMotionFX::GroupParameter>();
if (isValueParameter)
{
valueIndexBeforeMove = animGraph->FindValueParameterIndex(static_cast<const EMotionFX::ValueParameter*>(parameter));
}
if (!animGraph->TakeParameterFromParent(parameter))
{
outResult = AZStd::string::format("Could not remove the parameter \"%s\" from its parent", name.c_str());
return false;
}
animGraph->InsertParameter(destinationIndex, const_cast<EMotionFX::Parameter*>(parameter), destinationParent);
if (isValueParameter)
{
valueIndexAfterMove = animGraph->FindValueParameterIndex(static_cast<const EMotionFX::ValueParameter*>(parameter));
}
if (!isValueParameter || valueIndexAfterMove.GetValue() == valueIndexBeforeMove.GetValue())
{
// Nothing else to do, the anim graph instances and nodes dont require an update
return true;
}
// Remove the parameter from all corresponding anim graph instances if it is a value parameter
const size_t numInstances = animGraph->GetNumAnimGraphInstances();
for (size_t i = 0; i < numInstances; ++i)
{
EMotionFX::AnimGraphInstance* animGraphInstance = animGraph->GetAnimGraphInstance(i);
// Move the parameter from original position to the new position
animGraphInstance->MoveParameterValue(static_cast<uint32>(valueIndexBeforeMove.GetValue()), static_cast<uint32>(valueIndexAfterMove.GetValue()));
}
EMotionFX::ValueParameterVector valueParametersAfterChange = animGraph->RecursivelyGetValueParameters();
AZStd::vector<EMotionFX::AnimGraphObject*> affectedObjects;
animGraph->RecursiveCollectObjectsOfType(azrtti_typeid<EMotionFX::ObjectAffectedByParameterChanges>(), affectedObjects);
EMotionFX::GetAnimGraphManager().RecursiveCollectObjectsAffectedBy(animGraph, affectedObjects);
for (EMotionFX::AnimGraphObject* affectedObject : affectedObjects)
{
EMotionFX::ObjectAffectedByParameterChanges* affectedObjectByParameterChanges = azdynamic_cast<EMotionFX::ObjectAffectedByParameterChanges*>(affectedObject);
affectedObjectByParameterChanges->ParameterOrderChanged(valueParametersBeforeChange, valueParametersAfterChange);
}
// Save the current dirty flag and tell the anim graph that something got changed.
mOldDirtyFlag = animGraph->GetDirtyFlag();
animGraph->SetDirtyFlag(true);
return true;
}
bool CommandAnimGraphMoveParameter::Undo(const MCore::CommandLine& parameters, AZStd::string& outResult)
{
AZStd::string name;
parameters.GetValue("name", this, name);
// Find the anim graph by using the id from command parameter.
const uint32 animGraphID = parameters.GetValueAsInt("animGraphID", this);
EMotionFX::AnimGraph* animGraph = EMotionFX::GetAnimGraphManager().FindAnimGraphByID(animGraphID);
if (!animGraph)
{
outResult = AZStd::string::format("Cannot undo move parameters. Anim graph id '%i' is not valid.", animGraphID);
return false;
}
AZStd::string commandString = AZStd::string::format("AnimGraphMoveParameter -animGraphID %i -name \"%s\" -index %zu",
animGraphID,
name.c_str(),
mOldIndex);
if (!mOldParent.empty())
{
commandString += AZStd::string::format(" -parent \"%s\"", mOldParent.c_str());
}
if (!GetCommandManager()->ExecuteCommandInsideCommand(commandString, outResult))
{
AZ_Error("EMotionFX", false, outResult.c_str());
return false;
}
animGraph->SetDirtyFlag(mOldDirtyFlag);
return true;
}
void CommandAnimGraphMoveParameter::InitSyntax()
{
GetSyntax().ReserveParameters(5);
GetSyntax().AddRequiredParameter("animGraphID", "The id of the anim graph.", MCore::CommandSyntax::PARAMTYPE_INT);
GetSyntax().AddRequiredParameter("name", "The name of the parameter to move.", MCore::CommandSyntax::PARAMTYPE_STRING);
GetSyntax().AddRequiredParameter("index", "The new index of the parameter, relative to the new parent", MCore::CommandSyntax::PARAMTYPE_INT);
GetSyntax().AddParameter("parent", "The new parent of the parameter.", MCore::CommandSyntax::PARAMTYPE_STRING, "");
GetSyntax().AddParameter("updateUI", "Setting this to true will trigger a refresh of the parameter UI.", MCore::CommandSyntax::PARAMTYPE_BOOLEAN, "true");
}
const char* CommandAnimGraphMoveParameter::GetDescription() const
{
return "This command moves a parameter to another place in the parameter hierarchy.";
}
//--------------------------------------------------------------------------------
// Helper functions
//--------------------------------------------------------------------------------
//--------------------------------------------------------------------------------
// Construct create parameter command strings
//--------------------------------------------------------------------------------
void ConstructCreateParameterCommand(AZStd::string& outResult, EMotionFX::AnimGraph* animGraph, const EMotionFX::Parameter* parameter, uint32 insertAtIndex)
{
// Build the command string.
AZStd::string parameterContents;
parameterContents = MCore::ReflectionSerializer::Serialize(parameter).GetValue();
outResult = AZStd::string::format("AnimGraphCreateParameter -animGraphID %i -type \"%s\" -name \"%s\" -contents {%s}",
animGraph->GetID(),
azrtti_typeid(parameter).ToString<AZStd::string>().c_str(),
parameter->GetName().c_str(),
parameterContents.c_str());
if (insertAtIndex != MCORE_INVALIDINDEX32)
{
outResult += AZStd::string::format(" -index \"%i\"", insertAtIndex);
}
}
//--------------------------------------------------------------------------------
// Remove and or clear parameter helper functions
//--------------------------------------------------------------------------------
void ClearParametersCommand(EMotionFX::AnimGraph* animGraph, MCore::CommandGroup* commandGroup)
{
const EMotionFX::ValueParameterVector parameters = animGraph->RecursivelyGetValueParameters();
if (parameters.empty())
{
return;
}
// Iterate through all parameters and fill the parameter name array.
AZStd::vector<AZStd::string> parameterNames;
parameterNames.reserve(static_cast<size_t>(parameters.size()));
for (const EMotionFX::ValueParameter* parameter : parameters)
{
parameterNames.push_back(parameter->GetName());
}
// Is the command group parameter set?
if (!commandGroup)
{
// Create and fill the command group.
AZStd::string outResult;
MCore::CommandGroup internalCommandGroup("Clear parameters");
BuildRemoveParametersCommandGroup(animGraph, parameterNames, &internalCommandGroup);
// Execute the command group.
if (!GetCommandManager()->ExecuteCommandGroup(internalCommandGroup, outResult))
{
AZ_Error("EMotionFX", false, outResult.c_str());
}
}
else
{
// Use the given parameter command group.
BuildRemoveParametersCommandGroup(animGraph, parameterNames, commandGroup);
}
}
void RemoveConnectionsForParameter(EMotionFX::AnimGraph* animGraph, const char* parameterName, MCore::CommandGroup& commandGroup)
{
AZStd::vector<EMotionFX::AnimGraphNode*> parameterNodes;
animGraph->RecursiveCollectNodesOfType(azrtti_typeid<EMotionFX::BlendTreeParameterNode>(), ¶meterNodes);
AZStd::vector<AZStd::pair<EMotionFX::BlendTreeConnection*, EMotionFX::AnimGraphNode*>> outgoingConnectionsFromThisPort;
for (const EMotionFX::AnimGraphNode* parameterNode : parameterNodes)
{
const AZ::u32 sourcePortIndex = parameterNode->FindOutputPortIndex(parameterName);
parameterNode->CollectOutgoingConnections(outgoingConnectionsFromThisPort, sourcePortIndex); // outgoingConnectionsFromThisPort will be cleared inside the function.
const size_t numConnections = outgoingConnectionsFromThisPort.size();
for (uint32 i = 0; i < numConnections; ++i)
{
const EMotionFX::AnimGraphNode* targetNode = outgoingConnectionsFromThisPort[i].second;
const EMotionFX::BlendTreeConnection* connection = outgoingConnectionsFromThisPort[i].first;
const bool updateUniqueData = (i == 0 || i == numConnections - 1);
DeleteNodeConnection(&commandGroup, targetNode, connection, updateUniqueData);
}
}
}
// Remove all connections linked to parameter nodes inside blend trees for the parameters about to be removed back to front.
void RemoveConnectionsForParameters(EMotionFX::AnimGraph* animGraph, const AZStd::vector<AZStd::string>& parameterNames, MCore::CommandGroup& commandGroup)
{
const size_t numValueParameters = animGraph->GetNumValueParameters();
for (size_t i = 0; i < numValueParameters; ++i)
{
const size_t valueParameterIndex = numValueParameters - i - 1;
const EMotionFX::ValueParameter* valueParameter = animGraph->FindValueParameter(valueParameterIndex);
AZ_Assert(valueParameter, "Value parameter with index %d not found.", valueParameterIndex);
if (AZStd::find(parameterNames.begin(), parameterNames.end(), valueParameter->GetName().c_str()) != parameterNames.end())
{
RemoveConnectionsForParameter(animGraph, valueParameter->GetName().c_str(), commandGroup);
}
}
}
bool BuildRemoveParametersCommandGroup(EMotionFX::AnimGraph* animGraph, const AZStd::vector<AZStd::string>& parameterNamesToRemove, MCore::CommandGroup* commandGroup)
{
// Make sure the anim graph is valid and that the parameter names array at least contains a single one.
if (!animGraph || parameterNamesToRemove.empty())
{
return false;
}
// Create the command group.
AZStd::string outResult;
AZStd::string commandString;
MCore::CommandGroup internalCommandGroup(commandString.c_str());
MCore::CommandGroup* usedCommandGroup = commandGroup;
if (!commandGroup)
{
if (parameterNamesToRemove.size() == 1)
{
commandString = AZStd::string::format("Remove parameter '%s'", parameterNamesToRemove[0].c_str());
}
else
{
commandString = AZStd::string::format("Remove %zu parameters", parameterNamesToRemove.size());
}
usedCommandGroup = &internalCommandGroup;
}
// 1. Remove all connections linked to parameter nodes inside blend trees for the parameters about to be removed back to front.
RemoveConnectionsForParameters(animGraph, parameterNamesToRemove, *usedCommandGroup);
// 2. Inform all objects affected that we are going to remove a parameter and let them make sure to add all necessary commands to prepare for it.
AZStd::vector<EMotionFX::AnimGraphObject*> affectedObjects;
animGraph->RecursiveCollectObjectsOfType(azrtti_typeid<EMotionFX::ObjectAffectedByParameterChanges>(), affectedObjects);
EMotionFX::GetAnimGraphManager().RecursiveCollectObjectsAffectedBy(animGraph, affectedObjects);
for (EMotionFX::AnimGraphObject* object : affectedObjects)
{
EMotionFX::ObjectAffectedByParameterChanges* affectedObject = azdynamic_cast<EMotionFX::ObjectAffectedByParameterChanges*>(object);
AZ_Assert(affectedObject != nullptr, "Can't cast object. Object must be inherited from ObjectAffectedByParameterChanges.");
for (const AZStd::string& parameterName : parameterNamesToRemove)
{
affectedObject->BuildParameterRemovedCommands(*usedCommandGroup, parameterName);
}
}
// 3. Remove the actual parameters.
size_t numIterations = parameterNamesToRemove.size();
for (uint32 i = 0; i < numIterations; ++i)
{
commandString = AZStd::string::format("AnimGraphRemoveParameter -animGraphID %i -name \"%s\"", animGraph->GetID(), parameterNamesToRemove[i].c_str());
if (i != 0 && i != numIterations - 1)
{
commandString += " -updateUI false";
}
usedCommandGroup->AddCommandString(commandString);
}
if (!commandGroup)
{
if (!GetCommandManager()->ExecuteCommandGroup(internalCommandGroup, outResult))
{
AZ_Error("EMotionFX", false, outResult.c_str());
return false;
}
}
return true;
}
} // namespace CommandSystem
|
;
; Z88 Graphics Functions - Small C+ stubs
;
; Written around the Interlogic Standard Library
;
; Stubs Written by D Morris - 30/9/98
;
;
; $Id: undrawb.asm,v 1.6 2016-04-13 21:09:09 dom Exp $
;
SECTION code_clib
PUBLIC undrawb
PUBLIC _undrawb
EXTERN drawbox
EXTERN respixel
EXTERN swapgfxbk
EXTERN __graphics_end
.undrawb
._undrawb
push ix
ld ix,2
add ix,sp
ld b,(ix+2)
ld c,(ix+4)
ld l,(ix+6)
ld h,(ix+8)
ld ix,respixel
call swapgfxbk
call drawbox
jp __graphics_end
|
;@DOES set BC bytes of HL to the value A
;@INPUT HL pointer to set
;@INPUT BC amount to set
;@INPUT A byte to set memory to
;@OUTPUT HL HL+BC
;@OUTPUT DE HL+BC+1
;@DESTROYS AF
sys_MemSet:
push hl
pop de
inc de
ld (hl),a
ldir
ret
|
;
; CPC Maths Routines
;
; August 2003 **_|warp6|_** <kbaccam /at/ free.fr>
;
; $Id: sqrt.asm,v 1.4 2016-06-22 19:50:49 dom Exp $
;
SECTION code_fp
INCLUDE "cpcfirm.def"
INCLUDE "cpcfp.def"
PUBLIC sqrt
PUBLIC sqrtc
EXTERN get_para
.sqrt call get_para
call firmware
.sqrtc defw CPCFP_FLO_SQRT
ret
|
#include <bits/stdc++.h>
using namespace std;
vector<int> findOrder(int numCourses, vector<vector<int>>& prerequisites) {
// find courses without constraint requirements
int reqments[numCourses];
bool completed[numCourses];
vector<int> done;
for (int i = 0; i < numCourses; i++) {
reqments[i] = 0;
completed[i] = false;
}
for (int i = 0; i < prerequisites.size(); i++) {
reqments[prerequisites[i][0]]++;
}
for (int i = 0; i < numCourses; i++) {
if (reqments[i]==0){ // no requirements, get these courses done first
done.push_back(i);
completed[i] = true;
cout << i << " No reqs" << endl;
}
}
int prev = prerequisites.size();
// keep finishing courses as per `done` fulfilled
while (!(prerequisites.empty())){
for (int i = 0; i < prerequisites.size(); i++) {
if (reqments[prerequisites[i][0]]>0 && completed[prerequisites[i][1]]){
cout << prerequisites[i][0] << " Reqs left = " << reqments[prerequisites[i][0]] << endl;
if (reqments[prerequisites[i][0]]==1){
done.push_back(prerequisites[i][0]); // requirement fulfilled, so complete that course
completed[prerequisites[i][0]] = true; // completed
}
reqments[prerequisites[i][0]]--;
prerequisites.erase(prerequisites.begin()+i);
i--;
}
}
if(prev==prerequisites.size() && (!(prerequisites.empty()))){ // // not possible, ded end
cout << prerequisites.size() << " & prev=" << prev << endl;
done.clear();
break;
}
prev = prerequisites.size();
}
return done;
}
int main(){
// int numCourses = 7;
// vector<vector<int>> prereq = {{1,0}, {2,0}, {2,1}, {2,3}, {3,4}, {4,3}}; // impssible tc
int numCourses = 3;
vector<vector<int>> prereq = {{2,1}, {1,0}};
// vector<vector<int>> prereq = {{1,0}, {2,0}, {2,1}, {2,3}, {3,4}, {4,1}};
// int numCourses = 4;
// vector<vector<int>> prereq = {{1,0}, {2,0}, {3,1}, {3,2}};
vector<int> res = findOrder(numCourses, prereq);
for (int i = 0; i < res.size(); i++){
cout << res[i] << " ";
}
return 0;
} |
/*
* bsv.cpp
*
* Created on: Jun. 19, 2019
* Author: takis
*/
#include <iostream>
#include <vector>
using std::cout; using std::endl;
using std::vector;
typedef vector<int> vs_t;
void print_out(const vs_t &arr, const vs_t::size_type N)
{
cout << endl;
for (vs_t::size_type i = 0; i != N; ++i)
{
cout << arr[i] << " ";
}
cout << endl;
}
/*
* function swap:
* - takes a pointer to an array
* - swaps elements n and m
*/
void swap(vs_t &arr, vs_t::size_type n, vs_t::size_type m)
{
int store = arr[n];
arr[n] = arr[m];
arr[m] = store;
return;
}
int main()
{
vs_t a = { 10, 15, 31, 6, 2, 7, 1, 5 };
vs_t::size_type N = a.size();
// show original array contents
cout << "The original array is:" << endl;
print_out(a, N);
cout << endl;
bool swaps = 1;
while (swaps)
{
swaps = 0;
for (vs_t::size_type j=0; j != (N-1); ++j)
{
if (a[j] > a[j+1])
{
swap(a, j, j+1);
swaps = 1;
}
}
}
// show updated array contents
cout << "The sorted array is:" << endl;
print_out(a, N);
cout << endl;
// end program successfully
return 0;
}
|
dnl Intel Pentium-4 mpn_add_n -- mpn addition.
dnl Copyright 2001, 2002 Free Software Foundation, Inc.
dnl
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
dnl modify it under the terms of the GNU Lesser General Public License as
dnl published by the Free Software Foundation; either version 3 of the
dnl License, or (at your option) any later version.
dnl
dnl The GNU MP Library is distributed in the hope that it will be useful,
dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
dnl Lesser General Public License for more details.
dnl
dnl You should have received a copy of the GNU Lesser General Public License
dnl along with the GNU MP Library. If not, see http://www.gnu.org/licenses/.
include(`../config.m4')
C P4 Willamette, Northwood: 4.0 cycles/limb if dst!=src1 and dst!=src2
C 6.0 cycles/limb if dst==src1 or dst==src2
C P4 Prescott: >= 5 cycles/limb
C mp_limb_t mpn_add_n (mp_ptr dst, mp_srcptr src1, mp_srcptr src2,
C mp_size_t size);
C mp_limb_t mpn_add_nc (mp_ptr dst, mp_srcptr src1, mp_srcptr src2,
C mp_size_t size, mp_limb_t carry);
C
C The 4 c/l achieved here isn't particularly good, but is better than 9 c/l
C for a basic adc loop.
defframe(PARAM_CARRY,20)
defframe(PARAM_SIZE, 16)
defframe(PARAM_SRC2, 12)
defframe(PARAM_SRC1, 8)
defframe(PARAM_DST, 4)
dnl re-use parameter space
define(SAVE_EBX,`PARAM_SRC1')
TEXT
ALIGN(8)
PROLOGUE(mpn_add_nc)
deflit(`FRAME',0)
movd PARAM_CARRY, %mm0
jmp L(start_nc)
EPILOGUE()
ALIGN(8)
PROLOGUE(mpn_add_n)
deflit(`FRAME',0)
pxor %mm0, %mm0
L(start_nc):
movl PARAM_SRC1, %eax
movl %ebx, SAVE_EBX
movl PARAM_SRC2, %ebx
movl PARAM_DST, %edx
movl PARAM_SIZE, %ecx
leal (%eax,%ecx,4), %eax C src1 end
leal (%ebx,%ecx,4), %ebx C src2 end
leal (%edx,%ecx,4), %edx C dst end
negl %ecx C -size
L(top):
C eax src1 end
C ebx src2 end
C ecx counter, limbs, negative
C edx dst end
C mm0 carry bit
movd (%eax,%ecx,4), %mm1
movd (%ebx,%ecx,4), %mm2
paddq %mm2, %mm1
paddq %mm1, %mm0
movd %mm0, (%edx,%ecx,4)
psrlq $32, %mm0
addl $1, %ecx
jnz L(top)
movd %mm0, %eax
movl SAVE_EBX, %ebx
emms
ret
EPILOGUE()
|
; A045430: Number of dominoes with n spots (in standard set).
; 1,1,2,2,3,3,4,3,3,2,2,1,1
lpb $0
mul $0,11
mod $0,12
lpe
div $0,2
add $0,1
|
#pragma once
#include "common.hpp"
#include "chunk.hpp"
namespace png {
class Iend : public Chunk {
public:
Iend(Chunk c);
virtual ~Iend() {};
};
}
|
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Copyright (c) Palm Computing, Inc. 1993 -- All Rights Reserved
PROJECT: PEN GEOS
MODULE: World Clock
FILE: wcLists.asm
AUTHOR: Roger Flores, Oct 16, 1992
ROUTINES:
Name Description
---- -----------
WorldClockInitSelectionLists
Initialize the city selection lists.
New PENELOPE routines:
WorldClockPopHomeCityUI (MSG_WC_POPUP_HOME_CITY_UI)
Displays the UI for the Home/Dest City Selection
Dialog. This is rewritten from existing code for Penelope.
WorldClockSetSortOption (MSG_WC_SET_SORT_OPTION)
Sorts the city list according to the user selection.
WorldClockSetCityOption (MSG_WC_SET_CITY_OPTION)
Responds to UI to set user or city selection.
WorldClockDisplayMiscellaneousUI
Sets up the home/dest selection dialog title, ok
trigger, and daylight boolean.
WorldClockUpdateListSelections
Displays the City List listbox according to user's
sort and user city selections.
WorldClockChangeUserSelectedCityIndex
Changes the index into the CityList when the sort
option changes.
WorldClockApplySummerTime
Handles any daylight savings UI changes made in
response to the apply on the set home/dest city dialogs.
WorldClockListboxKbdChar
Intercepts alpha chars to implement quick index
feature in the city listbox.
REVISION HISTORY:
Name Date Description
---- ---- -----------
rsf 10/16/92 Initial revision
rsf 4/9/93 Broke from wcUI.asm
pam 10/15/96 Added Penelope specifc code
DESCRIPTION:
Contains code to handle the city selection box.
$Id: wcLists.asm,v 1.1 97/04/04 16:22:00 newdeal Exp $
;if _PENELOPE
All code related to the city listbox and the Set Home/Dest
City dialog boxes.
;else
This handles the seven things a user can do in the selection box:
city, country
country
city
city selection on
city selection off
user city on
user city off
The first three have their own methods. The last four share
MSG_WC_SWITCH_SELECTION which is sent by the boolean group which
they are in.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
CommonCode segment resource
COMMENT @-------------------------------------------------------------------
FUNCTION: WorldClockInitSelectionLists
DESCRIPTION: Initialize the selection lists with the count.
CALLED BY: WorldClockOpenApplication
PASS: es - dgroup
RETURN: nothing
DESTROYED:
PSEUDO CODE/STRATEGY:
Initialize the city list and the country list. This is the
only place which initializes them.
REVISION HISTORY:
Name Date Description
---- ---- -----------
rsf 11/ 2/92 Initial version
----------------------------------------------------------------------------@
WorldClockInitSelectionLists proc far
.enter
EC < call ECCheckDGroupES >
; lock the block to pass to ChunkArrayGetCount
mov bx, es:[cityIndexHandle]
call MemLock
mov ds, ax
; the city selection list
; get the number of cities in the list so we can tell the list object
mov si, es:[cityNamesIndexHandle]
call ChunkArrayGetCount ; count in cx
; pass count in cx
ObjCall MSG_GEN_DYNAMIC_LIST_INITIALIZE, CityList
; the country city selection list
; get the number of cities in the list so we can tell the list object
mov si, es:[countryNamesIndexHandle]
call ChunkArrayGetCount ; count in cx
; pass count in cx
ObjCall MSG_GEN_DYNAMIC_LIST_INITIALIZE, CountryList
; we no longer need the city index block
mov bx, es:[cityIndexHandle]
call MemUnlock
.leave
ret
WorldClockInitSelectionLists endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
WorldClockPopHomeCityUI
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Popup the city selection ui set to the home city
CALLED BY: MSG_WC_POPUP_HOME_CITY_UI
PASS: es - dgroup
cl - HOME_CITY or DEST_CITY
RETURN: none
DESTROYED: ax, cx, dx, si, di
PSEUDO CODE/STRATEGY:
It is assumed that the appropriate lists are visible.
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
rsf 10/16/92 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
WorldClockPopHomeCityUI method WorldClockProcessClass, MSG_WC_POPUP_HOME_CITY_UI
EC < mov ax, es ; check dgroup >
EC < call ECCheckSegment >
push cx ; save city to change
call WorldClockMarkAppBusy
pop cx ; restore city to change
call BlinkerStop
mov es:[changeCity], cl ; save which city to change
; record which city is selected. This variable is only changed
; when the user selects a different city. It is used by
; WorldClockSelectLists for selections.
cmp cl, mask DEST_CITY
je getDestCity
getHomeCity:
mov ax, es:[homeCityPtr]
jmp gotCityPtr
getDestCity:
mov ax, es:[destCityPtr]
cmp ax, CITY_NOT_SELECTED
je getHomeCity
gotCityPtr:
mov es:[userSelectedCity], ax
; We now must set the user city option if on. Note that this must be
; set because it may be set differently if the other city is different.
; By setting it the user city option, those handlers will insure that
; the currently selected city is either shown or not shown as well
; as set program variables. We also set which lists are visible from here.
and cl, es:[userCities] ; non zero if this is a user city
jz userCityBitOk
mov cl, mask USER_CITY_SELECTION
userCityBitOk:
mov ch, es:[citySelection] ; find which city lists to use
andnf ch, mask CITY_SELECTION ; the only info we want
ornf cl, ch ; set the city lists
clr ch ; no high bits
; we must set this new value for citySelection because the boolean
; list's status message handler does not handle multiple bits
; changing. We can avoid adding this capability by set the
; variable here and letting the status message handler set the lists.
; mov es:[citySelection], cl
clr dx ; clear no bits
ObjCall MSG_GEN_BOOLEAN_GROUP_SET_GROUP_STATE, CityCountrySelectionOption
mov cx, mask CITY_SELECTION or mask USER_CITY_SELECTION
ObjSend MSG_GEN_BOOLEAN_GROUP_SEND_STATUS_MSG
; Now we wish the popup's title bar to display either Home or Destination
; depending on which the user is changing.
test es:[changeCity], mask HOME_CITY
jz destCity
mov si, offset homeCityText
jmp gotCityText
destCity:
mov si, offset destCityText
gotCityText:
GetResourceHandleNS homeCityText, bx
call MemLock
mov ds, ax ; text segment
mov si, ds:[si] ; dereference chunk handle
; We do not want the trailing ':' to appear at the top of the dialog
; so we want to strip off the last ':'. To do this we count the
; length of the string and strip off the last character. We will
; write the ':' back in later.
push es ; save dgroup
segmov es, ds
mov di, si
call LocalStringSize
add di, cx
dec di ; position at char before null
DBCS < dec di >
pop es ; restore dgroup
push ds:[di] ; save character value
push di ; save character position
SBCS < clr {byte}ds:[di] >
DBCS < clr {word}ds:[di] >
movdw cxdx, dssi ; bu
mov bp, VUM_MANUAL
ObjCall MSG_GEN_REPLACE_VIS_MONIKER_TEXT, CitySelectionInteraction
mov dx, bx ; save resource handle
; now restore the ':' to the trigger name and unlock the block
pop di ; restore character position
pop ds:[di] ; restore character value
GetResourceHandleNS homeCityText, bx
call MemUnlock
mov bx, dx ; restore resource handle
ObjCall MSG_GEN_INTERACTION_INITIATE
call WorldClockMarkAppNotBusy
ret
WorldClockPopHomeCityUI endm
COMMENT @------------------------------------------------------------------
METHOD: MSG_WC_CITY_LIST_REQUEST_MONIKER for WorldClockProcessClass
DESCRIPTION: Called by ui to set moniker of list entry
PASS: ^lcx:dx - ItemGenDynamicList
bp - entry # of requested moniker(0-N)
RETURN: none
DESTROYED: none
WARNING: This routine MAY resize the LMem block, moving it on the
heap and invalidating stored segment pointers to it.
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
rsf 10/20/92 Initial version
----------------------------------------------------------------------------@
WorldClockCityListRequestMoniker method dynamic WorldClockProcessClass,\
MSG_WC_CITY_LIST_REQUEST_MONIKER
.enter
FXIP < GetResourceSegmentNS dgroup, es >
sub sp, TEMP_STR_SIZE
push cx, dx ; ^lcx:dx of GenDynamicList
mov cx, ss
mov dx, sp ; buffer starts at sp
add dx, 4 ; plus the two pushes
mov ax, bp ; element number
call WorldClockFormCityNameText
; send the GenDynamicList the text in the buffer
mov ax, MSG_GEN_DYNAMIC_LIST_REPLACE_ITEM_TEXT
pop bx, si ; ^lcx:dx of GenDynamicList
mov cx, ss ; buffer segment
mov dx, sp ; buffer offset
mov di, mask MF_CALL
call ObjMessage ; ax, cx, dx, bp destroyed
add sp, TEMP_STR_SIZE ; free stack buffer
.leave
ret
WorldClockCityListRequestMoniker endm
COMMENT @------------------------------------------------------------------
METHOD: MSG_WC_COUNTRY_CITY_LIST_REQUEST_MONIKER for WorldClockProcessClass
DESCRIPTION: Called by ui to set moniker of list entry
PASS: ^lcx:dx - ItemGenDynamicList
bp - entry # of requested moniker(0-N)
RETURN: none
DESTROYED: none
WARNING: This routine MAY resize the LMem block, moving it on the
heap and invalidating stored segment pointers to it.
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
rsf 10/20/92 Initial version
----------------------------------------------------------------------------@
WorldClockCountryCityListRequestMoniker method dynamic WorldClockProcessClass, \
MSG_WC_COUNTRY_CITY_LIST_REQUEST_MONIKER
.enter
sub sp, TEMP_STR_SIZE
push cx, dx ; ^lcx:dx of GenDynamicList
mov cx, ss
mov dx, sp ; buffer starts at sp
add dx, 4 ; plus the two pushes
mov ax, bp ; element number
add ax, es:[firstCityInCountry]
mov si, es:[countryCityNamesIndexHandle]
call CityInfoEntryLock
; get the number of cities in the list so we can tell the list object
mov es, cx ; buffer segment
mov di, dx ; buffer offset
mov si, dx ; move to indexing register
mov si, es:[si] ; get pointer
LocalCopyString
; we no longer need the city index block, text is on the stack
call MemUnlock
; send the GenDynamicList the text in the buffer
mov ax, MSG_GEN_DYNAMIC_LIST_REPLACE_ITEM_TEXT
pop bx, si ; ^lcx:dx of GenDynamicList
mov cx, ss ; buffer segment
mov dx, sp ; buffer offset
mov di, mask MF_CALL
call ObjMessage ; ax, cx, dx, bp destroyed
add sp, TEMP_STR_SIZE ; free stack buffer
.leave
ret
WorldClockCountryCityListRequestMoniker endm
COMMENT @------------------------------------------------------------------
METHOD: MSG_WC_COUNTRY_LIST_REQUEST_MONIKER for WorldClockProcessClass
DESCRIPTION: Called by ui to set moniker of list entry
PASS: ^lcx:dx - ItemGenDynamicList
bp - entry # of requested moniker (0-N)
es - dgroup
RETURN: none
DESTROYED: none
WARNING: This routine MAY resize the LMem block, moving it on the
heap and invalidating stored segment pointers to it.
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
rsf 10/20/92 Initial version
----------------------------------------------------------------------------@
WorldClockCountryListRequestMoniker method dynamic WorldClockProcessClass, \
MSG_WC_COUNTRY_LIST_REQUEST_MONIKER
.enter
EC < mov ax, es ; check dgroup >
EC < call ECCheckSegment >
sub sp, TEMP_STR_SIZE
push cx, dx ; ^lcx:dx of GenDynamicList
mov cx, ss
mov dx, sp ; buffer starts at sp
add dx, 4 ; plus the two pushes
mov ax, bp ; element number
mov si, es:[countryNamesIndexHandle]
call CityInfoEntryLock ; does right thing
mov si, dx
mov es, cx ; buffer segment
mov di, dx ; buffer offset
mov si, es:[si].CIE_name ; use ptr
LocalCopyString
; we no longer need the city index block, text is on the stack
call MemUnlock
; send the GenDynamicList the text in the buffer
mov ax, MSG_GEN_DYNAMIC_LIST_REPLACE_ITEM_TEXT
pop bx, si ; ^lcx:dx of GenDynamicList
mov cx, ss ; buffer segment
mov dx, sp ; buffer offset
mov di, mask MF_CALL
call ObjMessage ; ax, cx, dx, bp destroyed
add sp, TEMP_STR_SIZE ; free stack buffer
.leave
ret
WorldClockCountryListRequestMoniker endm
COMMENT @------------------------------------------------------------------
FUNCTION: WorldClockNotUserCity
DESCRIPTION: A city has been selected so don't use the user city
PASS: es - dgroup
RETURN: nothing
DESTROYED:
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
rsf 4/12/93 Initial version
----------------------------------------------------------------------------@
WorldClockNotUserCity proc near
.enter
EC < call ECCheckDGroupES >
test es:[citySelection], mask USER_CITY_SELECTION
jz done
; Change the UI boolean option and send the status message.
mov cx, mask USER_CITY_SELECTION ; boolean to change
clr dx ; clear the boolean
ObjCall MSG_GEN_BOOLEAN_GROUP_SET_BOOLEAN_STATE, CityCountrySelectionOption
mov cx, mask USER_CITY_SELECTION
ObjSend MSG_GEN_BOOLEAN_GROUP_SEND_STATUS_MSG
done:
.leave
ret
WorldClockNotUserCity endp
COMMENT @------------------------------------------------------------------
METHOD: MSG_WC_USE_CITY for WorldClockProcessClass
DESCRIPTION: Set the city to a new one
PASS: es - dgroup
es:[changeCity] - HOME_CITY or DEST_CITY
cx - city just selected
RETURN: nothing
DESTROYED:
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
rsf 10/21/92 Initial version
----------------------------------------------------------------------------@
WorldClockUseCity method WorldClockProcessClass, MSG_WC_USE_CITY
.enter
EC < mov ax, es ; check dgroup >
EC < call ECCheckSegment >
; set the correct city ptr
cmp es:[changeCity], mask HOME_CITY
jne changeDestCityPtr
; Removed done if identical because it failed to handle exiting user city mode
; when the city is identical!
; cmp es:[homeCityPtr], cx ; do nothing if unchanged
;LONG je done
call SetHomeCity
jmp changedCityPtr
changeDestCityPtr:
; cmp es:[destCityPtr], cx ; do nothing if unchanged
;LONG je done
call SetDestCity
push cx ; save city selected
call EnableDestCityUI
pop cx ; restore city selected
changedCityPtr:
sub sp, DATE_TIME_BUFFER_SIZE ; large enough buffer
mov ax, cx ; element number
mov cx, ss
mov dx, sp ; buffer starts at sp
call WorldClockFormCityNameText
; lock the Time Zone Info block. It's used by
; WorldClockResolvePointToTimeZone.
push ax, bx ; save x, y coords
mov bx, es:[timeZoneInfoHandle]
call MemLock
mov ds, ax
pop ax, bx ; restore x, y coords
; write in the coords and set the correct city text from the buffer
cmp es:[changeCity], mask HOME_CITY
jne changeDestCityName
mov es:[homeCityX], ax
mov es:[homeCityY], bx
mov cx, ax
mov dx, bx
call WorldClockResolvePointToTimeZone
mov es:[homeCityTimeZone], ax ; time zone hour and minute
GetResourceHandleNS HomeCityName, bx
mov si, offset HomeCityName
jmp changedCityName
changeDestCityName:
mov es:[destCityX], ax
mov es:[destCityY], bx
mov cx, ax
mov dx, bx
call BlinkerMove
call WorldClockResolvePointToTimeZone
mov es:[destCityTimeZone], ax ; time zone hour and minute
GetResourceHandleNS DestCityName, bx
mov si, offset DestCityName
changedCityName:
push bx
mov bx, es:[timeZoneInfoHandle] ; done with info
call MemUnlock
pop bx
mov ax, MSG_GEN_REPLACE_VIS_MONIKER_TEXT
mov cx, ss ; buffer segment
mov dx, sp ; buffer offset
cmp es:[uiSetupSoUpdatingUIIsOk], FALSE
jne updateNow
mov bp, VUM_MANUAL ; ui still setting up
jmp vumSet
updateNow:
mov bp, VUM_NOW
vumSet:
mov di, mask MF_CALL
call ObjMessage ; ax, cx, dx, bp destroyed
add sp, DATE_TIME_BUFFER_SIZE ; free stack buffer
call WorldClockUpdateTimeDates
;done:
.leave
ret
WorldClockUseCity endm
COMMENT @-------------------------------------------------------------------
FUNCTION: EnableDestCityUI
DESCRIPTION:
CALLED BY:
PASS:
RETURN: nothing
DESTROYED: nothing
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
rsf 11/18/93 Initial version
----------------------------------------------------------------------------@
EnableDestCityUI proc far
.enter
; These two options are now usable because there is a destination city.
mov dl, VUM_NOW
ObjSend MSG_GEN_SET_ENABLED, SetSystemToDestTime
mov dl, VUM_NOW
ObjSend MSG_GEN_SET_ENABLED, SetDestTimeToSummer
.leave
ret
EnableDestCityUI endp
COMMENT @------------------------------------------------------------------
METHOD: MSG_WC_COUNTRY_CITY_CHANGE for WorldClockProcessClass
DESCRIPTION: Records the city selected and removes the user city selection
PASS: es - dgroup
cx - city just selected
bp - StatTypeMask indicating which items changed. ???
RETURN: nothing
DESTROYED:
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
rsf 4/9/93 Initial version
----------------------------------------------------------------------------@
WorldClockCountryCityChange method dynamic WorldClockProcessClass, MSG_WC_COUNTRY_CITY_CHANGE
push cx ; save city
ObjCall MSG_GEN_ITEM_GROUP_GET_SELECTION, CountryList ; ax = selection
cmp ax, GIGS_NONE
jne gotCountry
; the user has selected a city when they were in user city mode.
; This means that the two lists visible have nothing selected (and
; that is how this condition is detected). What we need to ultimately
; is to determine the city number of the city selected. To do that
; we need to know the number of the country and also select the country
; in the country list. We can then pass the country number along.
; We can use userSelectedCity because the lists shown show it's city.
mov ax, es:[userSelectedCity]
call WorldClockMapCityToCountryAndCity
mov cx, bx ; country number
clr dx ; determinate
ObjSend MSG_GEN_ITEM_GROUP_SET_SINGLE_SELECTION, CountryList
mov ax, cx ; country number
gotCountry:
pop cx ; restore city
call WorldClockMapCountryAndCityToCity
mov es:[userSelectedCity], cx
call WorldClockNotUserCity ; remove user city selection stuff
ret
WorldClockCountryCityChange endm
COMMENT @------------------------------------------------------------------
METHOD: MSG_WC_CITY_CHANGE for WorldClockProcessClass
DESCRIPTION: Records the city selected and removes the user city selection
PASS: es - dgroup
cx - city just selected
bp - StatTypeMask indicating which items changed.
RETURN: nothing
DESTROYED: nothing
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
rsf 4/9/93 Initial version
----------------------------------------------------------------------------@
WorldClockCityChange method dynamic WorldClockProcessClass, MSG_WC_CITY_CHANGE
FXIP < GetResourceSegmentNS dgroup, es >
mov es:[userSelectedCity], cx
call WorldClockNotUserCity ;remove user city selection stuff
ret
WorldClockCityChange endm
COMMENT @------------------------------------------------------------------
METHOD: MSG_WC_COUNTRY_CHANGE for WorldClockProcessClass
DESCRIPTION: This inits a new city list for the country and selects
the first city. Also removes the user city selection.
PASS: es - dgroup
cx - country just selected
bp - StatTypeMask indicating which items changed. ???
RETURN: nothing
DESTROYED: nothing
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
rsf 10/21/92 Initial version
rsf 4/9/93 redone
----------------------------------------------------------------------------@
WorldClockCountryChange method dynamic WorldClockProcessClass, MSG_WC_COUNTRY_CHANGE
.enter
FXIP < GetResourceSegmentNS dgroup, es >
call WorldClockCountryChangeHandleListStuffOnly
; now record the city selected
mov ax, es:[currentCountry]
clr cx ; first city has been selected
call WorldClockMapCountryAndCityToCity
mov es:[userSelectedCity], cx
call WorldClockNotUserCity ; remove user city selection stuff
.leave
ret
WorldClockCountryChange endm
COMMENT @-------------------------------------------------------------------
FUNCTION: WorldClockCountryChangeHandleListStuffOnly
DESCRIPTION: This inits a new city list for the country and selects
the first city.
CALLED BY: WorldClockCountryChange, WorldClockUpdateListSelections
PASS: cx = country just selected
es = dgroup
RETURN: nothing
DESTROYED: nothing
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
rsf 6/ 9/93 Initial version
----------------------------------------------------------------------------@
WorldClockCountryChangeHandleListStuffOnly proc near
.enter
EC < call ECCheckDGroupES >
; check to see if the country is different than that shown
; Calls to this routine sometimes occur when the country is
; the same as that shown. This saves the time of the costly
; initialization and the annoying flicker too.
; we need to run this whole procedure in Dove, so no escape valve...
cmp es:[currentCountry], cx
je done
mov es:[currentCountry], cx
sub sp, size CountryIndexElement
mov ax, cx ; index number
mov cx, ss ; buffer segment
mov dx, sp ; buffer offset
mov si, es:[countryNamesIndexHandle]
call CityInfoEntryLock
call MemUnlock ; unlock city info
mov si, sp
mov ax, ss:[si].CIE_firstCity
mov es:[firstCityInCountry], ax
mov cx, ss:[si].CIE_cityCount
mov es:[cityInCountryCount], cx
add sp, size CountryIndexElement ; sp back to buffer, now free
; pass count in cx
ObjCall MSG_GEN_DYNAMIC_LIST_INITIALIZE, CountryCityList
clr cx, dx ; first item, determinate
ObjCall MSG_GEN_ITEM_GROUP_SET_SINGLE_SELECTION, CountryCityList
done:
.leave
ret
WorldClockCountryChangeHandleListStuffOnly endp
COMMENT @------------------------------------------------------------------
METHOD: MSG_WC_SWITCH_SELECTION for WorldClockProcess
DESCRIPTION: Switch from city selection to country-city selection and back
PASS: es - dgroup
cx - selection mode
bp - value changed
RETURN: nothing
DESTROYED: nothing
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
rsf 11/4/92 Initial version
rsf 7/1/93 Changed to handle multiple bits changing
----------------------------------------------------------------------------@
WorldClockSwitchSelection method dynamic WorldClockProcessClass, MSG_WC_SWITCH_SELECTION
FXIP < GetResourceSegmentNS dgroup, es >
EC < call ECCheckDGroupES >
mov es:[citySelection], cl ; current status of bits
test bp, mask CITY_SELECTION ; did this change?
jz updateLists
; push cx ; save selection state
; call WorldClockMarkAppBusy
; pop cx ; restore selection state
; andnf es:[citySelection], not mask CITY_SELECTION
; ornf es:[citySelection], cl ; record for later
test cl, mask CITY_SELECTION
jnz doCitySelection
; set the country city list
mov dl, VUM_NOW
ObjCall MSG_GEN_SET_NOT_USABLE, CityList
; set the country and country city list
mov dl, VUM_NOW
; GetResourceHandleNS CityCountrySelectionGroup, bx ; same resource
mov si, offset CityCountrySelectionGroup
ObjCall MSG_GEN_SET_USABLE
jmp markNotBusy
doCitySelection:
; set the country and country city list
mov dl, VUM_NOW
ObjCall MSG_GEN_SET_NOT_USABLE, CityCountrySelectionGroup
; set the country city list
mov dl, VUM_NOW
; GetResourceHandleNS CityList, bx ; same resource
mov si, offset CityList
ObjCall MSG_GEN_SET_USABLE
markNotBusy:
; This should ideally be done after the update lists but if this
; routine is entered because the user city changes then the app
; isn't marked busy because the action is a fairly quick one
; and so doesn't deserve a busy cursor.
; call WorldClockMarkAppNotBusy
updateLists:
call WorldClockUpdateListSelections
.leave
ret
WorldClockSwitchSelection endm
COMMENT @-------------------------------------------------------------------
FUNCTION: WorldClockUpdateListSelections
DESCRIPTION: This handles selecting the user city option when selecting cities.
CALLED BY: WorldClockSwitchSelection
PASS: es - dgroup
cx - selection mode
RETURN: nothing
DESTROYED:
PSEUDO CODE/STRATEGY:
NOTE: The user city info isn't stored yet. It is stored at the
apply event.
REVISION HISTORY:
Name Date Description
---- ---- -----------
rsf 4/9/93 Initial version
----------------------------------------------------------------------------@
WorldClockUpdateListSelections proc near
EC < call ECCheckDGroupES >
test es:[citySelection], mask USER_CITY_SELECTION ; is there a user city?
LONG jz noUserCity
; There is now a user city so select nothing in the list being shown
test es:[citySelection], mask CITY_SELECTION
jz deselectCountryCityLists
clr dx ; determinate
ObjCall MSG_GEN_ITEM_GROUP_SET_NONE_SELECTED, CityList
mov cx, es:[userSelectedCity]
mov ax, MSG_GEN_ITEM_GROUP_MAKE_ITEM_VISIBLE
mov di, mask MF_FORCE_QUEUE
call ObjMessage
jmp done
deselectCountryCityLists:
; for both lists we select none but make sure that the last thing
; the user selected is visible so they can select it again if desired.
mov ax, es:[userSelectedCity]
call WorldClockMapCityToCountryAndCity
push bx ; country list item
push ax ; country city list item
; handle the city
mov_tr cx, bx ; country city list item
call WorldClockCountryChangeHandleListStuffOnly
; insure cities for country showing
clr dx ; determinate
ObjCall MSG_GEN_ITEM_GROUP_SET_NONE_SELECTED, CountryCityList
pop cx ; country city list item
mov ax, MSG_GEN_ITEM_GROUP_MAKE_ITEM_VISIBLE
mov di, mask MF_FORCE_QUEUE
call ObjMessage
clr dx ; determinate
ObjCall MSG_GEN_ITEM_GROUP_SET_NONE_SELECTED, CountryList
pop cx ; country list item
mov ax, MSG_GEN_ITEM_GROUP_MAKE_ITEM_VISIBLE
mov di, mask MF_FORCE_QUEUE
call ObjMessage
jmp done
noUserCity:
mov cx, es:[userSelectedCity]
test es:[citySelection], mask CITY_SELECTION
jz selectCountryCityLists
clr dx ; determinate
ObjSend MSG_GEN_ITEM_GROUP_SET_SINGLE_SELECTION, CityList
jmp done
selectCountryCityLists:
; for both lists we select none but make sure that the last thing
; the user selected is visible so they can select it again if desired.
mov ax, es:[userSelectedCity]
call WorldClockMapCityToCountryAndCity
push bx ; country list item
; handle the city
push ax ; save city number
mov_tr cx, bx ; country list item
call WorldClockCountryChangeHandleListStuffOnly
; insure cities for country showing
pop cx ; country city list item
clr dx ; determinate
ObjSend MSG_GEN_ITEM_GROUP_SET_SINGLE_SELECTION, CountryCityList
pop cx ; restore country number
; clr dx ; determinate
ObjSend MSG_GEN_ITEM_GROUP_SET_SINGLE_SELECTION, CountryList
done:
ret
WorldClockUpdateListSelections endp
COMMENT @-------------------------------------------------------------------
FUNCTION: WorldClockMapCityToCountryAndCity
DESCRIPTION: Set the country-city lists from the city list
CALLED BY: WorldClockCountryCityChange, WorldClockUpdateListSelections
PASS: ax - city number
es - dgroup
RETURN: ax - city number
bx - country number
DESTROYED: cx, dx, di, si, bp
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
rsf 6/9/93 Initial version
----------------------------------------------------------------------------@
WorldClockMapCityToCountryAndCity proc near
uses es
countryElementNptr local nptr
.enter
EC < call ECCheckDGroupES >
; lock the block to pass to ChunkArrayGetElement
mov bx, es:[cityIndexHandle]
push bx ; save handle for unlock
; since dgroup won't be available
push ax ; city index number
call MemLock
mov ds, ax
pop ax ; city index number
; get the nptr to the city in city info
mov si, es:[cityNamesIndexHandle]
call ChunkArrayElementToPtr ; pointer at ds:di
EC < ERROR_C WC_ERROR_OUT_OF_ARRAY_BOUNDS >
mov di, ds:[di] ; get nptr to city info entry
push di ; nptr to city name
mov si, es:[countryCityNamesIndexHandle]
push si ; save index handle
mov si, es:[countryNamesIndexHandle]
; lock the block to copy to stack
mov bx, es:[cityInfoHandle]
call MemLock
mov es, ax
; skip to the next field
clr ax
mov cx, -1 ; forever
LocalFindChar
mov dx, di ; nptr to country name
loopFindMatchingCountry:
call ChunkArrayElementToPtr
EC < ERROR_C WC_ERROR_OUT_OF_ARRAY_BOUNDS >
inc ax ; point to next element
mov countryElementNptr, di ; save, used later if match found
mov di, ds:[di].CIE_name
push ds, si
segmov ds, es, si
mov si, dx
clr cx ; null terminated
call LocalCmpStrings
pop ds, si
jne loopFindMatchingCountry
dec ax ; undo the inc
call MemUnlock ; done with city info
; now find the matching city
pop si ; country city names index handle
pop dx ; nptr to city name
push ax ; country element number
mov di, countryElementNptr ; restore element nptr
mov ax, ds:[di].CIE_firstCity
loopFindMatchingCity:
call ChunkArrayElementToPtr
EC < ERROR_C WC_ERROR_OUT_OF_ARRAY_BOUNDS >
inc ax ; point to next element
cmp ds:[di], dx ; same nptr to city names?
jne loopFindMatchingCity
dec ax ; undo inc
mov di, countryElementNptr ; restore element nptr
sub ax, ds:[di].CIE_firstCity
; ax is city element
pop cx ; country number
pop bx ; city index handle
call MemUnlock
mov bx, cx ; return country number
.leave
ret
WorldClockMapCityToCountryAndCity endp
COMMENT @-------------------------------------------------------------------
FUNCTION: WorldClockMapCountryAndCityToCity
DESCRIPTION: Map from the Country and City lists to a city number.
CALLED BY:
PASS: ax - country number
cx - city number
es - dgroup
RETURN: cx - city number
DESTROYED: ax, bx, dx, di, si, bp, ds
PSEUDO CODE/STRATEGY:
Works by get the selection from each list.
REVISION HISTORY:
Name Date Description
---- ---- -----------
rsf 4/9/93 Initial version
----------------------------------------------------------------------------@
WorldClockMapCountryAndCityToCity proc far
.enter
EC < call ECCheckDGroupES >
push cx ; save country city number
; lock the block to pass to ChunkArrayGetElement
push ax ; country index number
mov bx, es:[cityIndexHandle]
call MemLock
mov ds, ax
pop ax ; country index number
; get the first city in the country
mov si, es:[countryNamesIndexHandle]
call ChunkArrayElementToPtr ; pointer at ds:di
EC < ERROR_C WC_ERROR_OUT_OF_ARRAY_BOUNDS >
mov cx, ds:[di].CIE_firstCity ; get nptr to city info entry
; get the nptr to the city in city info
pop ax ; country selection
add ax, cx
mov si, es:[countryCityNamesIndexHandle]
call ChunkArrayElementToPtr ; pointer at ds:di
EC < ERROR_C WC_ERROR_OUT_OF_ARRAY_BOUNDS >
mov cx, ds:[di] ; get nptr to city info entry
; now find the matching city
mov si, es:[cityNamesIndexHandle]
clr ax ; start with first element
loopFindMatchingCity:
call ChunkArrayElementToPtr
EC < ERROR_C WC_ERROR_OUT_OF_ARRAY_BOUNDS >
inc ax ; point to next element
cmp ds:[di], cx ; same nptr to city names?
jne loopFindMatchingCity
dec ax ; undo inc
mov cx, ax ; city number
mov bx, es:[cityIndexHandle]
call MemUnlock
.leave
ret
WorldClockMapCountryAndCityToCity endp
COMMENT @------------------------------------------------------------------
METHOD: MSG_GEN_APPLY for CustomApplyInteractionClass
DESCRIPTION: Apply the changes to the city.
PASS: *ds:si = CustomApplyInteractionClass object
ds:di = CustomApplyInteractionClass instance data
ds:bx = CustomApplyInteractionClass object (same as *ds:si)
es = segment of CustomApplyInteractionClass
ax = message #
RETURN: nothing
DESTROYED: ax, cx, dx, di, bp
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
rsf 4/12/93 Initial version
rsf 6/9/93 recoded
----------------------------------------------------------------------------@
WorldClockUserCityApply method dynamic CustomApplyInteractionClass, MSG_GEN_APPLY
mov di, offset CustomApplyInteractionClass
call ObjCallSuperNoLock
FXIP < GetResourceSegmentNS dgroup, es >
;Did the user pick the user city?
test es:[citySelection], mask USER_CITY_SELECTION
jz notUserCity
;Record the city as using the user city.
mov al, es:[changeCity]
ornf es:[userCities], al
call SetUserCities
call WorldClockUpdateUserCities
jmp done
notUserCity:
;Remove any user city stuff and set the city data.
mov al, es:[changeCity]
not al
andnf es:[userCities], al
call SetUserCities
mov cx, es:[userSelectedCity]
call WorldClockUseCity
done:
ret
WorldClockUserCityApply endm
COMMENT @------------------------------------------------------------------
METHOD: MSG_VIS_CLOSE for CustomApplyInteractionClass
DESCRIPTION: Apply the user city info and then call the super class for rest
PASS: es - dgroup
RETURN: nothing
DESTROYED: nothing
PSEUDO CODE/STRATEGY:
After applying the information in the interaction and letting it
tear itself down, enable the blinking. The blinking will
visually start on the next timer tick to reach 60 ticks.
REVISION HISTORY:
Name Date Description
---- ---- -----------
rsf 5/24/93 Initial version
----------------------------------------------------------------------------@
CustomApplyInteractionClose method dynamic CustomApplyInteractionClass, \
MSG_VIS_CLOSE
.enter
mov di, offset CustomApplyInteractionClass
call ObjCallSuperNoLock
; call BlinkerOn after all the ui stuff has settled down. We force
; it on the queue so it occurs after the ui junk.
mov ax, MSG_WC_BLINKER_ON
call GeodeGetProcessHandle
mov di, mask MF_FORCE_QUEUE
call ObjMessage
.leave
ret
CustomApplyInteractionClose endm
CommonCode ends
|
; A267599: Binary representation of the n-th iteration of the "Rule 177" elementary cellular automaton starting with a single ON (black) cell.
; 1,1,1001,101001,10101001,1010101001,101010101001,10101010101001,1010101010101001,101010101010101001,10101010101010101001,1010101010101010101001,101010101010101010101001,10101010101010101010101001,1010101010101010101010101001,101010101010101010101010101001,10101010101010101010101010101001,1010101010101010101010101010101001,101010101010101010101010101010101001,10101010101010101010101010101010101001,1010101010101010101010101010101010101001,101010101010101010101010101010101010101001
mov $1,100
pow $1,$0
sub $1,11
div $1,99
mul $1,10
add $1,1
mov $0,$1
|
db DEX_SEADRA ; pokedex id
db 55, 65, 95, 85, 95
; hp atk def spd spc
db WATER, WATER ; type
db 75 ; catch rate
db 155 ; base exp
INCBIN "gfx/pokemon/front/seadra.pic", 0, 1 ; sprite dimensions
dw SeadraPicFront, SeadraPicBack
db BUBBLE, SMOKESCREEN, WATER_GUN, NO_MOVE ; level 1 learnset
db GROWTH_MEDIUM_FAST ; growth rate
; tm/hm learnset
tmhm TOXIC, TAKE_DOWN, DOUBLE_EDGE, BUBBLEBEAM, WATER_GUN, \
ICE_BEAM, BLIZZARD, HYPER_BEAM, RAGE, MIMIC, \
DOUBLE_TEAM, BIDE, SWIFT, SKULL_BASH, REST, \
SUBSTITUTE, SURF
; end
db 0 ; padding
|
/*
* Copyright 2011 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include "include/core/SkTraceMemoryDump.h"
#include "include/gpu/GrContext.h"
#include "include/gpu/GrGpuResource.h"
#include "src/gpu/GrContextPriv.h"
#include "src/gpu/GrGpu.h"
#include "src/gpu/GrGpuResourcePriv.h"
#include "src/gpu/GrResourceCache.h"
#include <atomic>
static inline GrResourceCache* get_resource_cache(GrGpu* gpu) {
SkASSERT(gpu);
SkASSERT(gpu->getContext());
SkASSERT(gpu->getContext()->priv().getResourceCache());
return gpu->getContext()->priv().getResourceCache();
}
GrGpuResource::GrGpuResource(GrGpu* gpu) : fGpu(gpu), fUniqueID(CreateUniqueID()) {
SkDEBUGCODE(fCacheArrayIndex = -1);
}
void GrGpuResource::registerWithCache(SkBudgeted budgeted) {
SkASSERT(fBudgetedType == GrBudgetedType::kUnbudgetedUncacheable);
fBudgetedType = budgeted == SkBudgeted::kYes ? GrBudgetedType::kBudgeted
: GrBudgetedType::kUnbudgetedUncacheable;
this->computeScratchKey(&fScratchKey);
get_resource_cache(fGpu)->resourceAccess().insertResource(this);
}
void GrGpuResource::registerWithCacheWrapped(GrWrapCacheable wrapType) {
SkASSERT(fBudgetedType == GrBudgetedType::kUnbudgetedUncacheable);
// Resources referencing wrapped objects are never budgeted. They may be cached or uncached.
fBudgetedType = wrapType == GrWrapCacheable::kNo ? GrBudgetedType::kUnbudgetedUncacheable
: GrBudgetedType::kUnbudgetedCacheable;
fRefsWrappedObjects = true;
get_resource_cache(fGpu)->resourceAccess().insertResource(this);
}
GrGpuResource::~GrGpuResource() {
// The cache should have released or destroyed this resource.
SkASSERT(this->wasDestroyed());
}
void GrGpuResource::release() {
SkASSERT(fGpu);
this->onRelease();
get_resource_cache(fGpu)->resourceAccess().removeResource(this);
fGpu = nullptr;
fGpuMemorySize = 0;
}
void GrGpuResource::abandon() {
if (this->wasDestroyed()) {
return;
}
SkASSERT(fGpu);
this->onAbandon();
get_resource_cache(fGpu)->resourceAccess().removeResource(this);
fGpu = nullptr;
fGpuMemorySize = 0;
}
void GrGpuResource::dumpMemoryStatistics(SkTraceMemoryDump* traceMemoryDump) const {
if (this->fRefsWrappedObjects && !traceMemoryDump->shouldDumpWrappedObjects()) {
return;
}
this->dumpMemoryStatisticsPriv(traceMemoryDump, this->getResourceName(),
this->getResourceType(), this->gpuMemorySize());
}
void GrGpuResource::dumpMemoryStatisticsPriv(SkTraceMemoryDump* traceMemoryDump,
const SkString& resourceName,
const char* type, size_t size) const {
const char* tag = "Scratch";
if (fUniqueKey.isValid()) {
tag = (fUniqueKey.tag() != nullptr) ? fUniqueKey.tag() : "Other";
}
traceMemoryDump->dumpNumericValue(resourceName.c_str(), "size", "bytes", size);
traceMemoryDump->dumpStringValue(resourceName.c_str(), "type", type);
traceMemoryDump->dumpStringValue(resourceName.c_str(), "category", tag);
if (this->isPurgeable()) {
traceMemoryDump->dumpNumericValue(resourceName.c_str(), "purgeable_size", "bytes", size);
}
this->setMemoryBacking(traceMemoryDump, resourceName);
}
bool GrGpuResource::isPurgeable() const {
// Resources in the kUnbudgetedCacheable state are never purgeable when they have a unique
// key. The key must be removed/invalidated to make them purgeable.
return !this->hasRefOrPendingIO() &&
!(fBudgetedType == GrBudgetedType::kUnbudgetedCacheable && fUniqueKey.isValid());
}
bool GrGpuResource::hasRefOrPendingIO() const {
return this->internalHasRef() || this->internalHasPendingIO();
}
bool GrGpuResource::hasRef() const { return this->internalHasRef(); }
SkString GrGpuResource::getResourceName() const {
// Dump resource as "skia/gpu_resources/resource_#".
SkString resourceName("skia/gpu_resources/resource_");
resourceName.appendU32(this->uniqueID().asUInt());
return resourceName;
}
const GrContext* GrGpuResource::getContext() const {
if (fGpu) {
return fGpu->getContext();
} else {
return nullptr;
}
}
GrContext* GrGpuResource::getContext() {
if (fGpu) {
return fGpu->getContext();
} else {
return nullptr;
}
}
void GrGpuResource::removeUniqueKey() {
if (this->wasDestroyed()) {
return;
}
SkASSERT(fUniqueKey.isValid());
get_resource_cache(fGpu)->resourceAccess().removeUniqueKey(this);
}
void GrGpuResource::setUniqueKey(const GrUniqueKey& key) {
SkASSERT(this->internalHasRef());
SkASSERT(key.isValid());
// Uncached resources can never have a unique key, unless they're wrapped resources. Wrapped
// resources are a special case: the unique keys give us a weak ref so that we can reuse the
// same resource (rather than re-wrapping). When a wrapped resource is no longer referenced,
// it will always be released - it is never converted to a scratch resource.
if (this->resourcePriv().budgetedType() != GrBudgetedType::kBudgeted &&
!this->fRefsWrappedObjects) {
return;
}
if (this->wasDestroyed()) {
return;
}
get_resource_cache(fGpu)->resourceAccess().changeUniqueKey(this, key);
}
void GrGpuResource::notifyAllCntsWillBeZero() const {
GrGpuResource* mutableThis = const_cast<GrGpuResource*>(this);
mutableThis->willRemoveLastRefOrPendingIO();
}
void GrGpuResource::notifyAllCntsAreZero(CntType lastCntTypeToReachZero) const {
if (this->wasDestroyed()) {
// We've already been removed from the cache. Goodbye cruel world!
delete this;
return;
}
// We should have already handled this fully in notifyRefCntIsZero().
SkASSERT(kRef_CntType != lastCntTypeToReachZero);
static const uint32_t kFlag =
GrResourceCache::ResourceAccess::kAllCntsReachedZero_RefNotificationFlag;
GrGpuResource* mutableThis = const_cast<GrGpuResource*>(this);
get_resource_cache(fGpu)->resourceAccess().notifyCntReachedZero(mutableThis, kFlag);
}
bool GrGpuResource::notifyRefCountIsZero() const {
if (this->wasDestroyed()) {
// handle this in notifyAllCntsAreZero().
return true;
}
GrGpuResource* mutableThis = const_cast<GrGpuResource*>(this);
uint32_t flags = GrResourceCache::ResourceAccess::kRefCntReachedZero_RefNotificationFlag;
if (!this->internalHasPendingIO()) {
flags |= GrResourceCache::ResourceAccess::kAllCntsReachedZero_RefNotificationFlag;
}
get_resource_cache(fGpu)->resourceAccess().notifyCntReachedZero(mutableThis, flags);
// There is no need to call our notifyAllCntsAreZero function at this point since we already
// told the cache about the state of cnts.
return false;
}
void GrGpuResource::removeScratchKey() {
if (!this->wasDestroyed() && fScratchKey.isValid()) {
get_resource_cache(fGpu)->resourceAccess().willRemoveScratchKey(this);
fScratchKey.reset();
}
}
void GrGpuResource::makeBudgeted() {
// We should never make a wrapped resource budgeted.
SkASSERT(!fRefsWrappedObjects);
// Only wrapped resources can be in the kUnbudgetedCacheable state.
SkASSERT(fBudgetedType != GrBudgetedType::kUnbudgetedCacheable);
if (!this->wasDestroyed() && fBudgetedType == GrBudgetedType::kUnbudgetedUncacheable) {
// Currently resources referencing wrapped objects are not budgeted.
fBudgetedType = GrBudgetedType::kBudgeted;
get_resource_cache(fGpu)->resourceAccess().didChangeBudgetStatus(this);
}
}
void GrGpuResource::makeUnbudgeted() {
if (!this->wasDestroyed() && fBudgetedType == GrBudgetedType::kBudgeted &&
!fUniqueKey.isValid()) {
fBudgetedType = GrBudgetedType::kUnbudgetedUncacheable;
get_resource_cache(fGpu)->resourceAccess().didChangeBudgetStatus(this);
}
}
uint32_t GrGpuResource::CreateUniqueID() {
static std::atomic<uint32_t> nextID{1};
uint32_t id;
do {
id = nextID++;
} while (id == SK_InvalidUniqueID);
return id;
}
//////////////////////////////////////////////////////////////////////////////
void GrGpuResource::ProxyAccess::ref(GrResourceCache* cache) {
SkASSERT(cache == fResource->getContext()->priv().getResourceCache());
cache->resourceAccess().refResource(fResource);
}
|
;===============================================================================
; Copyright 2015-2019 Intel Corporation
; All Rights Reserved.
;
; If this software was obtained under the Intel Simplified Software License,
; the following terms apply:
;
; The source code, information and material ("Material") contained herein is
; owned by Intel Corporation or its suppliers or licensors, and title to such
; Material remains with Intel Corporation or its suppliers or licensors. The
; Material contains proprietary information of Intel or its suppliers and
; licensors. The Material is protected by worldwide copyright laws and treaty
; provisions. No part of the Material may be used, copied, reproduced,
; modified, published, uploaded, posted, transmitted, distributed or disclosed
; in any way without Intel's prior express written permission. No license under
; any patent, copyright or other intellectual property rights in the Material
; is granted to or conferred upon you, either expressly, by implication,
; inducement, estoppel or otherwise. Any license under such intellectual
; property rights must be express and approved by Intel in writing.
;
; Unless otherwise agreed by Intel in writing, you may not remove or alter this
; notice or any other notice embedded in Materials by Intel or Intel's
; suppliers or licensors in any way.
;
;
; If this software was obtained under the Apache License, Version 2.0 (the
; "License"), the following terms apply:
;
; You may not use this file except in compliance with the License. You may
; obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
;
;
; Unless required by applicable law or agreed to in writing, software
; distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
; WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
;
; See the License for the specific language governing permissions and
; limitations under the License.
;===============================================================================
;
;
; Purpose: Cryptography Primitive.
; Rijndael Inverse Cipher function
;
; Content:
; DecryptCBC_RIJ128pipe_AES_NI()
;
;
include asmdefs.inc
include ia_32e.inc
include pcpvariant.inc
IF (_AES_NI_ENABLING_ EQ _FEATURE_ON_) OR (_AES_NI_ENABLING_ EQ _FEATURE_TICKTOCK_)
IF (_IPP32E GE _IPP32E_Y8)
IPPCODE SEGMENT 'CODE' ALIGN (IPP_ALIGN_FACTOR)
;***************************************************************
;* Purpose: pipelined RIJ128 CBC decryption
;*
;* void DecryptCBC_RIJ128pipe_AES_NI(const Ipp32u* inpBlk,
;* Ipp32u* outBlk,
;* int nr,
;* const Ipp32u* pRKey,
;* int len,
;* const Ipp8u* pIV)
;***************************************************************
;;
;; Lib = Y8
;;
;; Caller = ippsAESDecryptCBC
;;
AES_BLOCK = (16)
ALIGN IPP_ALIGN_FACTOR
IPPASM DecryptCBC_RIJ128pipe_AES_NI PROC PUBLIC FRAME
USES_GPR rsi, rdi, rbx
LOCAL_FRAME = ((1+8)*AES_BLOCK)
USES_XMM xmm15
COMP_ABI 6
;; rdi: pInpBlk: PTR DWORD, ; input blocks address
;; rsi: pOutBlk: PTR DWORD, ; output blocks address
;; rdx: nr: DWORD, ; number of rounds
;; rcx pKey: PTR DWORD ; key material address
;; r8d length: DWORD ; length (bytes)
;; r9 pIV PTR BYTE ; pointer to the IV
SC equ (4)
movdqu xmm15, oword ptr [r9] ; IV
movsxd r8, r8d ; processed length
lea rax,[rdx*SC] ; keys offset
cmp r8, (4*AES_BLOCK)
jl short123_input
cmp r8, (16*AES_BLOCK)
jle block4x
;;
;; 8-blocks processing
;;
mov rbx, rsp ; rbx points on cipher's data in stack
sub rsp, sizeof(oword)*4 ; allocate stack and xmm registers
movdqa oword ptr[rsp+0*sizeof(oword)], xmm6
movdqa oword ptr[rsp+1*sizeof(oword)], xmm7
movdqa oword ptr[rsp+2*sizeof(oword)], xmm8
movdqa oword ptr[rsp+3*sizeof(oword)], xmm9
sub r8, (8*AES_BLOCK)
ALIGN IPP_ALIGN_FACTOR
blk8_loop:
lea r9,[rcx+rax*sizeof(dword)-AES_BLOCK]; pointer to the key material
movdqu xmm0, oword ptr[rdi+0*AES_BLOCK] ; get input blocks
movdqu xmm1, oword ptr[rdi+1*AES_BLOCK]
movdqu xmm2, oword ptr[rdi+2*AES_BLOCK]
movdqu xmm3, oword ptr[rdi+3*AES_BLOCK]
movdqu xmm6, oword ptr[rdi+4*AES_BLOCK]
movdqu xmm7, oword ptr[rdi+5*AES_BLOCK]
movdqu xmm8, oword ptr[rdi+6*AES_BLOCK]
movdqu xmm9, oword ptr[rdi+7*AES_BLOCK]
movdqa xmm5, oword ptr [r9+AES_BLOCK] ; whitening keys
movdqa xmm4, oword ptr [r9] ; pre load operation's keys
movdqa oword ptr [rbx+1*AES_BLOCK], xmm0 ; save input into the stack
pxor xmm0, xmm5 ; and do whitening
movdqa oword ptr [rbx+2*AES_BLOCK], xmm1
pxor xmm1, xmm5
movdqa oword ptr [rbx+3*AES_BLOCK], xmm2
pxor xmm2, xmm5
movdqa oword ptr [rbx+4*AES_BLOCK], xmm3
pxor xmm3, xmm5
movdqa oword ptr [rbx+5*AES_BLOCK], xmm6
pxor xmm6, xmm5
movdqa oword ptr [rbx+6*AES_BLOCK], xmm7
pxor xmm7, xmm5
movdqa oword ptr [rbx+7*AES_BLOCK], xmm8
pxor xmm8, xmm5
movdqa oword ptr [rbx+8*AES_BLOCK], xmm9
pxor xmm9, xmm5
movdqa xmm5, oword ptr [r9-AES_BLOCK] ; pre load operation's keys
sub r9, (2*AES_BLOCK)
lea r10, [rdx-2] ; counter = nrounds-2
ALIGN IPP_ALIGN_FACTOR
cipher_loop8:
aesdec xmm0, xmm4 ; regular round
aesdec xmm1, xmm4
aesdec xmm2, xmm4
aesdec xmm3, xmm4
aesdec xmm6, xmm4
aesdec xmm7, xmm4
aesdec xmm8, xmm4
aesdec xmm9, xmm4
movdqa xmm4, oword ptr[r9] ; pre load operation's keys
aesdec xmm0, xmm5 ; regular round
aesdec xmm1, xmm5
aesdec xmm2, xmm5
aesdec xmm3, xmm5
aesdec xmm6, xmm5
aesdec xmm7, xmm5
aesdec xmm8, xmm5
aesdec xmm9, xmm5
movdqa xmm5, oword ptr [r9-AES_BLOCK] ; pre load operation's keys
sub r9, (2*AES_BLOCK)
sub r10, 2
jnz cipher_loop8
aesdec xmm0, xmm4 ; regular round
aesdec xmm1, xmm4
aesdec xmm2, xmm4
aesdec xmm3, xmm4
aesdec xmm6, xmm4
aesdec xmm7, xmm4
aesdec xmm8, xmm4
aesdec xmm9, xmm4
aesdeclast xmm0, xmm5 ; irregular round, ^IV, and store result
pxor xmm0, xmm15
movdqu oword ptr[rsi+0*AES_BLOCK], xmm0
aesdeclast xmm1, xmm5
pxor xmm1, oword ptr[rbx+1*AES_BLOCK]
movdqu oword ptr[rsi+1*AES_BLOCK], xmm1
aesdeclast xmm2, xmm5
pxor xmm2, oword ptr[rbx+2*AES_BLOCK]
movdqu oword ptr[rsi+2*AES_BLOCK], xmm2
aesdeclast xmm3, xmm5
pxor xmm3, oword ptr[rbx+3*AES_BLOCK]
movdqu oword ptr[rsi+3*AES_BLOCK], xmm3
aesdeclast xmm6, xmm5
pxor xmm6, oword ptr[rbx+4*AES_BLOCK]
movdqu oword ptr[rsi+4*AES_BLOCK], xmm6
aesdeclast xmm7, xmm5
pxor xmm7, oword ptr[rbx+5*AES_BLOCK]
movdqu oword ptr[rsi+5*AES_BLOCK], xmm7
aesdeclast xmm8, xmm5
pxor xmm8, oword ptr[rbx+6*AES_BLOCK]
movdqu oword ptr[rsi+6*AES_BLOCK], xmm8
aesdeclast xmm9, xmm5
pxor xmm9, oword ptr[rbx+7*AES_BLOCK]
movdqu oword ptr[rsi+7*AES_BLOCK], xmm9
movdqa xmm15,oword ptr[rbx+8*AES_BLOCK] ; update IV
add rsi, (8*AES_BLOCK)
add rdi, (8*AES_BLOCK)
sub r8, (8*AES_BLOCK)
jge blk8_loop
movdqa xmm6, oword ptr[rsp+0*sizeof(oword)] ; restore xmm registers
movdqa xmm7, oword ptr[rsp+1*sizeof(oword)]
movdqa xmm8, oword ptr[rsp+2*sizeof(oword)]
movdqa xmm9, oword ptr[rsp+3*sizeof(oword)]
add rsp, sizeof(oword)*4 ; and release stack
add r8, (8*AES_BLOCK)
jz quit
;;
;; test if 4-blocks processing alaivalbe
;;
block4x:
cmp r8, (4*AES_BLOCK)
jl short123_input
sub r8, (4*AES_BLOCK)
ALIGN IPP_ALIGN_FACTOR
blk4_loop:
lea r9,[rcx+rax*sizeof(dword)-AES_BLOCK]; pointer to the key material
movdqu xmm0, oword ptr[rdi+0*AES_BLOCK] ; get input blocks
movdqu xmm1, oword ptr[rdi+1*AES_BLOCK]
movdqu xmm2, oword ptr[rdi+2*AES_BLOCK]
movdqu xmm3, oword ptr[rdi+3*AES_BLOCK]
movdqa xmm5, oword ptr [r9+AES_BLOCK] ; whitening keys
movdqa xmm4, oword ptr [r9] ; pre load operation's keys
movdqa oword ptr [rsp+1*AES_BLOCK], xmm0 ; save input into the stack
pxor xmm0, xmm5 ; and do whitening
movdqa oword ptr [rsp+2*AES_BLOCK], xmm1
pxor xmm1, xmm5
movdqa oword ptr [rsp+3*AES_BLOCK], xmm2
pxor xmm2, xmm5
movdqa oword ptr [rsp+4*AES_BLOCK], xmm3
pxor xmm3, xmm5
movdqa xmm5, oword ptr [r9-AES_BLOCK] ; pre load operation's keys
sub r9, (2*AES_BLOCK)
lea r10, [rdx-2] ; counter = nrounds-2
ALIGN IPP_ALIGN_FACTOR
cipher_loop4:
aesdec xmm0, xmm4 ; regular round
aesdec xmm1, xmm4
aesdec xmm2, xmm4
aesdec xmm3, xmm4
movdqa xmm4, oword ptr[r9] ; pre load operation's keys
aesdec xmm0, xmm5 ; regular round
aesdec xmm1, xmm5
aesdec xmm2, xmm5
aesdec xmm3, xmm5
movdqa xmm5, oword ptr [r9-AES_BLOCK] ; pre load operation's keys
sub r9, (2*AES_BLOCK)
sub r10, 2
jnz cipher_loop4
aesdec xmm0, xmm4 ; regular round
aesdec xmm1, xmm4
aesdec xmm2, xmm4
aesdec xmm3, xmm4
aesdeclast xmm0, xmm5 ; irregular round, ^IV, and store result
pxor xmm0, xmm15
movdqu oword ptr[rsi+0*AES_BLOCK], xmm0
aesdeclast xmm1, xmm5
pxor xmm1, oword ptr[rsp+1*AES_BLOCK]
movdqu oword ptr[rsi+1*AES_BLOCK], xmm1
aesdeclast xmm2, xmm5
pxor xmm2, oword ptr[rsp+2*AES_BLOCK]
movdqu oword ptr[rsi+2*AES_BLOCK], xmm2
aesdeclast xmm3, xmm5
pxor xmm3, oword ptr[rsp+3*AES_BLOCK]
movdqu oword ptr[rsi+3*AES_BLOCK], xmm3
movdqa xmm15,oword ptr[rsp+4*AES_BLOCK] ; update IV
add rsi, (4*AES_BLOCK)
add rdi, (4*AES_BLOCK)
sub r8, (4*AES_BLOCK)
jge blk4_loop
add r8, (4*AES_BLOCK)
jz quit
;;
;; block-by-block processing
;;
short123_input:
lea r9,[rcx+rax*sizeof(dword)] ; pointer to the key material (whitening)
ALIGN IPP_ALIGN_FACTOR
single_blk_loop:
movdqu xmm0, oword ptr[rdi] ; get input block
add rdi, AES_BLOCK
movdqa xmm1, xmm0 ; and save as IV for future
pxor xmm0, oword ptr [r9] ; whitening
cmp rdx,12 ; switch according to number of rounds
jl key_128_s
jz key_192_s
key_256_s:
aesdec xmm0, oword ptr[rcx+9*SC*4+4*SC*4]
aesdec xmm0, oword ptr[rcx+9*SC*4+3*SC*4]
key_192_s:
aesdec xmm0, oword ptr[rcx+9*SC*4+2*SC*4]
aesdec xmm0, oword ptr[rcx+9*SC*4+1*SC*4]
key_128_s:
aesdec xmm0, oword ptr[rcx+9*SC*4-0*SC*4]
aesdec xmm0, oword ptr[rcx+9*SC*4-1*SC*4]
aesdec xmm0, oword ptr[rcx+9*SC*4-2*SC*4]
aesdec xmm0, oword ptr[rcx+9*SC*4-3*SC*4]
aesdec xmm0, oword ptr[rcx+9*SC*4-4*SC*4]
aesdec xmm0, oword ptr[rcx+9*SC*4-5*SC*4]
aesdec xmm0, oword ptr[rcx+9*SC*4-6*SC*4]
aesdec xmm0, oword ptr[rcx+9*SC*4-7*SC*4]
aesdec xmm0, oword ptr[rcx+9*SC*4-8*SC*4]
aesdeclast xmm0, oword ptr[rcx+9*SC*4-9*SC*4]
pxor xmm0, xmm15 ; add IV
movdqu oword ptr[rsi], xmm0 ; and save output blocl
add rsi, AES_BLOCK
sub r8, AES_BLOCK
movdqa xmm15, xmm1 ; update IV
jnz single_blk_loop
quit:
pxor xmm4, xmm4
pxor xmm5, xmm5
REST_XMM
REST_GPR
ret
IPPASM DecryptCBC_RIJ128pipe_AES_NI ENDP
ENDIF ;; _IPP32E GE _IPP32E_Y8
ENDIF ;; _AES_NI_ENABLING_
END
|
; void exit(int eax);
exit:
mov ebx, eax ; eax
mov eax, 0x01 ; exit |
int 0x80 ; | (| );
; void putint(int eax);
putint:
push eax ; preserve
push ecx
push edx
push esi
mov ecx, 0 ; count string size
.div_loop: ; do {
inc ecx ; ++ecx;
xor edx, edx ; edx = 0;
mov esi, 10 ; 10 10
idiv esi ; edx = eax % | ; eax /= | ;
add edx, '0' ; edx += '0';
push edx ; build stack string
cmp eax, 0 ; }
jnz .div_loop ; while (eax);
.print_loop: ; do {
dec ecx ; --ecx;
pop eax ; eax
call putchar ; putchar(| );
cmp ecx, 0 ; }
jnz .print_loop ; while (ecx);
mov eax, 0x0a ; '\n'
call putchar ; putchar(| );
pop esi ; preserve
pop edx
pop ecx
pop eax
ret
; void puts(char *const eax);
puts:
push eax ; preserve
call print ; print(eax);
mov eax, 0x0a ; '\n'
call putchar ; putchar(| );
pop eax ; preserve
ret
; void putchar(char eax);
putchar:
push edx ; preserve
push ecx
push ebx
push eax
mov edx, 1 ; 1
mov ecx, esp ; &eax |
mov ebx, 1 ; stdout | |
mov eax, 0x04 ; write | | |
int 0x80 ; | (| , | , |);
pop eax ; preserve
pop ebx
pop ecx
pop edx
ret
; void print(char *const eax);
print:
push edx ; preserve
push ecx
push ebx
push eax
push eax ; save
call strlen ; strlen(eax)
mov edx, eax ; |
pop eax ; restore eax |
mov ecx, eax ; | |
mov ebx, 1 ; stdout | |
mov eax, 0x04 ; write | | |
int 0x80 ; | ( , | , | );
pop eax ; preserve
pop ebx
pop ecx
pop edx
ret
; size_t (*)(char *const eax);
strlen:
push ebx ; preserve
mov ebx, eax ; ebx = eax;
jmp .while
.loop: ; do {
inc eax ; ++eax;
.while:
cmp byte [eax], 0 ; }
jnz .loop ; while (eax);
sub eax, ebx ; return eax - ebx;
pop ebx ; preserve
ret
|
###############################################################################
# Copyright 2018 Intel Corporation
# All Rights Reserved.
#
# If this software was obtained under the Intel Simplified Software License,
# the following terms apply:
#
# The source code, information and material ("Material") contained herein is
# owned by Intel Corporation or its suppliers or licensors, and title to such
# Material remains with Intel Corporation or its suppliers or licensors. The
# Material contains proprietary information of Intel or its suppliers and
# licensors. The Material is protected by worldwide copyright laws and treaty
# provisions. No part of the Material may be used, copied, reproduced,
# modified, published, uploaded, posted, transmitted, distributed or disclosed
# in any way without Intel's prior express written permission. No license under
# any patent, copyright or other intellectual property rights in the Material
# is granted to or conferred upon you, either expressly, by implication,
# inducement, estoppel or otherwise. Any license under such intellectual
# property rights must be express and approved by Intel in writing.
#
# Unless otherwise agreed by Intel in writing, you may not remove or alter this
# notice or any other notice embedded in Materials by Intel or Intel's
# suppliers or licensors in any way.
#
#
# If this software was obtained under the Apache License, Version 2.0 (the
# "License"), the following terms apply:
#
# You may not use this file except in compliance with the License. You may
# obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
#
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#
# See the License for the specific language governing permissions and
# limitations under the License.
###############################################################################
.section .note.GNU-stack,"",%progbits
.text
.p2align 5, 0x90
_CONST_DATA:
_INIT_IDX:
.word 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7
_INCR_IDX:
.word 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8
.p2align 5, 0x90
.globl h9_getAesGcmConst_table_ct
.type h9_getAesGcmConst_table_ct, @function
h9_getAesGcmConst_table_ct:
push %ebx
call .L__0000gas_1
.L__0000gas_1:
pop %ebx
sub $(.L__0000gas_1-_CONST_DATA), %ebx
pxor %xmm2, %xmm2
mov %ecx, %eax
shl $(16), %ecx
or %eax, %ecx
movd %ecx, %xmm3
pshufd $(0), %xmm3, %xmm3
movdqa ((_INIT_IDX-_CONST_DATA))(%ebx), %xmm6
xor %eax, %eax
.p2align 5, 0x90
.Lsearch_loopgas_1:
movdqa %xmm6, %xmm7
paddw ((_INCR_IDX-_CONST_DATA))(%ebx), %xmm6
pcmpeqw %xmm3, %xmm7
pand (%edx,%eax,2), %xmm7
add $(8), %eax
cmp $(256), %eax
por %xmm7, %xmm2
jl .Lsearch_loopgas_1
movdqa %xmm2, %xmm3
psrldq $(8), %xmm2
por %xmm3, %xmm2
movdqa %xmm2, %xmm3
psrldq $(4), %xmm2
por %xmm3, %xmm2
movd %xmm2, %eax
pop %ebx
and $(3), %ecx
shl $(4), %ecx
shr %cl, %eax
ret
.Lfe1:
.size h9_getAesGcmConst_table_ct, .Lfe1-(h9_getAesGcmConst_table_ct)
.p2align 5, 0x90
.globl h9_AesGcmMulGcm_table2K
.type h9_AesGcmMulGcm_table2K, @function
h9_AesGcmMulGcm_table2K:
push %ebp
mov %esp, %ebp
push %ebx
push %esi
push %edi
movl (8)(%ebp), %edi
movdqu (%edi), %xmm0
movl (12)(%ebp), %esi
movl (16)(%ebp), %edx
movd %xmm0, %ebx
mov $(4042322160), %eax
and %ebx, %eax
shl $(4), %ebx
and $(4042322160), %ebx
movzbl %ah, %ecx
movdqa (1024)(%esi,%ecx), %xmm5
movzbl %al, %ecx
movdqa (1024)(%esi,%ecx), %xmm4
shr $(16), %eax
movzbl %ah, %ecx
movdqa (1024)(%esi,%ecx), %xmm3
movzbl %al, %ecx
movdqa (1024)(%esi,%ecx), %xmm2
psrldq $(4), %xmm0
movd %xmm0, %eax
and $(4042322160), %eax
movzbl %bh, %ecx
pxor (%esi,%ecx), %xmm5
movzbl %bl, %ecx
pxor (%esi,%ecx), %xmm4
shr $(16), %ebx
movzbl %bh, %ecx
pxor (%esi,%ecx), %xmm3
movzbl %bl, %ecx
pxor (%esi,%ecx), %xmm2
movd %xmm0, %ebx
shl $(4), %ebx
and $(4042322160), %ebx
movzbl %ah, %ecx
pxor (1280)(%esi,%ecx), %xmm5
movzbl %al, %ecx
pxor (1280)(%esi,%ecx), %xmm4
shr $(16), %eax
movzbl %ah, %ecx
pxor (1280)(%esi,%ecx), %xmm3
movzbl %al, %ecx
pxor (1280)(%esi,%ecx), %xmm2
psrldq $(4), %xmm0
movd %xmm0, %eax
and $(4042322160), %eax
movzbl %bh, %ecx
pxor (256)(%esi,%ecx), %xmm5
movzbl %bl, %ecx
pxor (256)(%esi,%ecx), %xmm4
shr $(16), %ebx
movzbl %bh, %ecx
pxor (256)(%esi,%ecx), %xmm3
movzbl %bl, %ecx
pxor (256)(%esi,%ecx), %xmm2
movd %xmm0, %ebx
shl $(4), %ebx
and $(4042322160), %ebx
movzbl %ah, %ecx
pxor (1536)(%esi,%ecx), %xmm5
movzbl %al, %ecx
pxor (1536)(%esi,%ecx), %xmm4
shr $(16), %eax
movzbl %ah, %ecx
pxor (1536)(%esi,%ecx), %xmm3
movzbl %al, %ecx
pxor (1536)(%esi,%ecx), %xmm2
psrldq $(4), %xmm0
movd %xmm0, %eax
and $(4042322160), %eax
movzbl %bh, %ecx
pxor (512)(%esi,%ecx), %xmm5
movzbl %bl, %ecx
pxor (512)(%esi,%ecx), %xmm4
shr $(16), %ebx
movzbl %bh, %ecx
pxor (512)(%esi,%ecx), %xmm3
movzbl %bl, %ecx
pxor (512)(%esi,%ecx), %xmm2
movd %xmm0, %ebx
shl $(4), %ebx
and $(4042322160), %ebx
movzbl %ah, %ecx
pxor (1792)(%esi,%ecx), %xmm5
movzbl %al, %ecx
pxor (1792)(%esi,%ecx), %xmm4
shr $(16), %eax
movzbl %ah, %ecx
pxor (1792)(%esi,%ecx), %xmm3
movzbl %al, %ecx
pxor (1792)(%esi,%ecx), %xmm2
movzbl %bh, %ecx
pxor (768)(%esi,%ecx), %xmm5
movzbl %bl, %ecx
pxor (768)(%esi,%ecx), %xmm4
shr $(16), %ebx
movzbl %bh, %ecx
pxor (768)(%esi,%ecx), %xmm3
movzbl %bl, %ecx
pxor (768)(%esi,%ecx), %xmm2
movdqa %xmm3, %xmm0
pslldq $(1), %xmm3
pxor %xmm3, %xmm2
movdqa %xmm2, %xmm1
pslldq $(1), %xmm2
pxor %xmm2, %xmm5
psrldq $(15), %xmm0
movd %xmm0, %ecx
call h9_getAesGcmConst_table_ct
shl $(8), %eax
movdqa %xmm5, %xmm0
pslldq $(1), %xmm5
pxor %xmm5, %xmm4
psrldq $(15), %xmm1
movd %xmm1, %ecx
mov %eax, %ebx
call h9_getAesGcmConst_table_ct
xor %ebx, %eax
shl $(8), %eax
psrldq $(15), %xmm0
movd %xmm0, %ecx
mov %eax, %ebx
call h9_getAesGcmConst_table_ct
xor %ebx, %eax
movd %eax, %xmm0
pxor %xmm4, %xmm0
movdqu %xmm0, (%edi)
pop %edi
pop %esi
pop %ebx
pop %ebp
ret
.Lfe2:
.size h9_AesGcmMulGcm_table2K, .Lfe2-(h9_AesGcmMulGcm_table2K)
.p2align 5, 0x90
.globl h9_AesGcmAuth_table2K
.type h9_AesGcmAuth_table2K, @function
h9_AesGcmAuth_table2K:
push %ebp
mov %esp, %ebp
push %ebx
push %esi
push %edi
movl (8)(%ebp), %edi
movdqu (%edi), %xmm0
movl (20)(%ebp), %esi
movl (12)(%ebp), %edi
movl (24)(%ebp), %edx
.p2align 5, 0x90
.Lauth_loopgas_3:
movdqu (%edi), %xmm4
pxor %xmm4, %xmm0
movd %xmm0, %ebx
mov $(4042322160), %eax
and %ebx, %eax
shl $(4), %ebx
and $(4042322160), %ebx
movzbl %ah, %ecx
movdqa (1024)(%esi,%ecx), %xmm5
movzbl %al, %ecx
movdqa (1024)(%esi,%ecx), %xmm4
shr $(16), %eax
movzbl %ah, %ecx
movdqa (1024)(%esi,%ecx), %xmm3
movzbl %al, %ecx
movdqa (1024)(%esi,%ecx), %xmm2
psrldq $(4), %xmm0
movd %xmm0, %eax
and $(4042322160), %eax
movzbl %bh, %ecx
pxor (%esi,%ecx), %xmm5
movzbl %bl, %ecx
pxor (%esi,%ecx), %xmm4
shr $(16), %ebx
movzbl %bh, %ecx
pxor (%esi,%ecx), %xmm3
movzbl %bl, %ecx
pxor (%esi,%ecx), %xmm2
movd %xmm0, %ebx
shl $(4), %ebx
and $(4042322160), %ebx
movzbl %ah, %ecx
pxor (1280)(%esi,%ecx), %xmm5
movzbl %al, %ecx
pxor (1280)(%esi,%ecx), %xmm4
shr $(16), %eax
movzbl %ah, %ecx
pxor (1280)(%esi,%ecx), %xmm3
movzbl %al, %ecx
pxor (1280)(%esi,%ecx), %xmm2
psrldq $(4), %xmm0
movd %xmm0, %eax
and $(4042322160), %eax
movzbl %bh, %ecx
pxor (256)(%esi,%ecx), %xmm5
movzbl %bl, %ecx
pxor (256)(%esi,%ecx), %xmm4
shr $(16), %ebx
movzbl %bh, %ecx
pxor (256)(%esi,%ecx), %xmm3
movzbl %bl, %ecx
pxor (256)(%esi,%ecx), %xmm2
movd %xmm0, %ebx
shl $(4), %ebx
and $(4042322160), %ebx
movzbl %ah, %ecx
pxor (1536)(%esi,%ecx), %xmm5
movzbl %al, %ecx
pxor (1536)(%esi,%ecx), %xmm4
shr $(16), %eax
movzbl %ah, %ecx
pxor (1536)(%esi,%ecx), %xmm3
movzbl %al, %ecx
pxor (1536)(%esi,%ecx), %xmm2
psrldq $(4), %xmm0
movd %xmm0, %eax
and $(4042322160), %eax
movzbl %bh, %ecx
pxor (512)(%esi,%ecx), %xmm5
movzbl %bl, %ecx
pxor (512)(%esi,%ecx), %xmm4
shr $(16), %ebx
movzbl %bh, %ecx
pxor (512)(%esi,%ecx), %xmm3
movzbl %bl, %ecx
pxor (512)(%esi,%ecx), %xmm2
movd %xmm0, %ebx
shl $(4), %ebx
and $(4042322160), %ebx
movzbl %ah, %ecx
pxor (1792)(%esi,%ecx), %xmm5
movzbl %al, %ecx
pxor (1792)(%esi,%ecx), %xmm4
shr $(16), %eax
movzbl %ah, %ecx
pxor (1792)(%esi,%ecx), %xmm3
movzbl %al, %ecx
pxor (1792)(%esi,%ecx), %xmm2
movzbl %bh, %ecx
pxor (768)(%esi,%ecx), %xmm5
movzbl %bl, %ecx
pxor (768)(%esi,%ecx), %xmm4
shr $(16), %ebx
movzbl %bh, %ecx
pxor (768)(%esi,%ecx), %xmm3
movzbl %bl, %ecx
pxor (768)(%esi,%ecx), %xmm2
movdqa %xmm3, %xmm0
pslldq $(1), %xmm3
pxor %xmm3, %xmm2
movdqa %xmm2, %xmm1
pslldq $(1), %xmm2
pxor %xmm2, %xmm5
psrldq $(15), %xmm0
movd %xmm0, %ecx
call h9_getAesGcmConst_table_ct
shl $(8), %eax
movdqa %xmm5, %xmm0
pslldq $(1), %xmm5
pxor %xmm5, %xmm4
psrldq $(15), %xmm1
movd %xmm1, %ecx
mov %eax, %ebx
call h9_getAesGcmConst_table_ct
xor %ebx, %eax
shl $(8), %eax
psrldq $(15), %xmm0
movd %xmm0, %ecx
mov %eax, %ebx
call h9_getAesGcmConst_table_ct
xor %ebx, %eax
movd %eax, %xmm0
pxor %xmm4, %xmm0
add $(16), %edi
subl $(16), (16)(%ebp)
jnz .Lauth_loopgas_3
movl (8)(%ebp), %edi
movdqu %xmm0, (%edi)
pop %edi
pop %esi
pop %ebx
pop %ebp
ret
.Lfe3:
.size h9_AesGcmAuth_table2K, .Lfe3-(h9_AesGcmAuth_table2K)
|
Music_LookYoungster:
musicheader 3, 1, Music_LookYoungster_Ch1
musicheader 1, 2, Music_LookYoungster_Ch2
musicheader 1, 3, Music_LookYoungster_Ch3
Music_LookYoungster_Ch1:
tempo 118
volume $77
stereopanning $f
dutycycle $3
notetype $c, $a3
octave 3
note G_, 1
note G#, 1
note A_, 1
note A#, 1
intensity $3e
note B_, 16
intensity $c3
octave 4
note C_, 1
note __, 3
note C_, 4
note __, 2
note C_, 6
intensity $b3
Music_LookYoungster_branch_f66ea:
note __, 2
octave 3
note G_, 1
note __, 1
note B_, 1
note __, 1
note G_, 1
note __, 1
octave 4
note D_, 1
note __, 1
note C_, 1
note __, 3
note C_, 1
note __, 1
note __, 16
note __, 2
octave 3
note G_, 1
note __, 1
note B_, 1
note __, 1
note G_, 1
note __, 1
octave 4
note D_, 1
note __, 1
note C_, 1
note __, 3
note C_, 1
note __, 1
note __, 16
loopchannel 0, Music_LookYoungster_branch_f66ea
db $ff
Music_LookYoungster_Ch2:
stereopanning $f0
vibrato $12, $26
dutycycle $1
notetype $c, $a3
octave 3
note B_, 1
octave 4
note C_, 1
note C#, 1
note D_, 1
intensity $3e
notetype $c, $2e
note G_, 16
notetype $c, $b3
intensity $c3
note F_, 1
note __, 3
note F_, 4
note __, 2
note F#, 6
Music_LookYoungster_branch_f672f:
dutycycle $3
intensity $b3
note __, 2
octave 3
note B_, 1
note __, 1
octave 4
note D_, 1
note __, 1
octave 3
note B_, 1
note __, 1
octave 4
note G_, 1
note __, 1
note F_, 1
note __, 3
note F_, 1
note __, 1
intensity $97
dutycycle $2
note D#, 1
note F_, 1
note D#, 1
note D_, 1
note C_, 1
note __, 1
octave 3
note G#, 1
note __, 3
note F_, 1
note __, 1
note G_, 1
note __, 1
note G#, 1
note __, 1
dutycycle $3
intensity $b3
note __, 2
note B_, 1
note __, 1
octave 4
note D_, 1
note __, 1
octave 3
note B_, 1
note __, 1
octave 4
note G_, 1
note __, 1
note F_, 1
note __, 3
note F_, 1
note __, 1
dutycycle $2
intensity $97
note G#, 1
note A#, 1
note G#, 1
note G_, 1
note F_, 1
note __, 1
note C_, 1
note __, 3
octave 3
note G#, 1
note __, 1
note A#, 1
note __, 1
octave 4
note C_, 1
note __, 1
loopchannel 0, Music_LookYoungster_branch_f672f
db $ff
Music_LookYoungster_Ch3:
stereopanning $ff
vibrato $2, $24
notetype $c, $25
note __, 4
octave 2
note G_, 1
note __, 1
octave 3
note G_, 1
note __, 1
octave 2
note G_, 1
note __, 1
octave 3
note G_, 1
note __, 1
octave 2
note G_, 1
note __, 1
octave 3
note G_, 1
note __, 1
intensity $15
octave 2
note G_, 1
note __, 1
octave 3
note G_, 1
note __, 1
note D_, 1
note __, 3
note D_, 4
note __, 2
note G#, 6
intensity $25
Music_LookYoungster_branch_f67ae:
octave 2
note G_, 1
note __, 1
octave 3
note G_, 1
note __, 1
octave 2
note G_, 1
note __, 1
octave 3
note G_, 1
note __, 1
octave 2
note G_, 1
note __, 1
octave 3
note G_, 1
note __, 1
octave 2
note G_, 1
note __, 1
octave 3
note G_, 1
note __, 1
octave 2
note F_, 1
note __, 1
octave 3
note D#, 1
note __, 1
octave 2
note F_, 1
note __, 1
octave 3
note D#, 1
note __, 1
octave 2
note F_, 1
note __, 1
octave 3
note D#, 1
note __, 1
octave 2
note F_, 1
note __, 1
octave 3
note D#, 1
note __, 1
octave 2
note G_, 1
note __, 1
octave 3
note G_, 1
note __, 1
octave 2
note G_, 1
note __, 1
octave 3
note G_, 1
note __, 1
octave 2
note G_, 1
note __, 1
octave 3
note G_, 1
note __, 1
octave 2
note G_, 1
note __, 1
octave 3
note G_, 1
note __, 1
octave 2
note G#, 1
note __, 1
octave 3
note D#, 1
note __, 1
octave 2
note G#, 1
note __, 1
octave 3
note D#, 1
note __, 1
octave 2
note G#, 1
note __, 1
octave 3
note D#, 1
note __, 1
note G_, 1
note __, 1
note G#, 1
note __, 1
loopchannel 0, Music_LookYoungster_branch_f67ae
db $ff
|
//=================================================================================================
/*!
// \file src/mathtest/operations/dmatdmatsub/MDaM4x4b.cpp
// \brief Source file for the MDaM4x4b dense matrix/dense matrix subtraction math test
//
// Copyright (C) 2012-2020 Klaus Iglberger - All Rights Reserved
//
// This file is part of the Blaze library. You can redistribute it and/or modify it under
// the terms of the New (Revised) BSD License. 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 names of the Blaze development group 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.
*/
//=================================================================================================
//*************************************************************************************************
// Includes
//*************************************************************************************************
#include <cstdlib>
#include <iostream>
#include <blaze/math/DynamicMatrix.h>
#include <blaze/math/StaticMatrix.h>
#include <blazetest/mathtest/Creator.h>
#include <blazetest/mathtest/operations/dmatdmatsub/OperationTest.h>
#include <blazetest/system/MathTest.h>
#ifdef BLAZE_USE_HPX_THREADS
# include <hpx/hpx_main.hpp>
#endif
//=================================================================================================
//
// MAIN FUNCTION
//
//=================================================================================================
//*************************************************************************************************
int main()
{
std::cout << " Running 'MDaM2b'..." << std::endl;
using blazetest::mathtest::TypeA;
using blazetest::mathtest::TypeB;
try
{
// Matrix type definitions
using MDa = blaze::DynamicMatrix<TypeA>;
using M4x4b = blaze::StaticMatrix<TypeB,4UL,4UL>;
// Creator type definitions
using CMDa = blazetest::Creator<MDa>;
using CM4x4b = blazetest::Creator<M4x4b>;
// Running the tests
RUN_DMATDMATSUB_OPERATION_TEST( CMDa( 4UL, 4UL ), CM4x4b() );
}
catch( std::exception& ex ) {
std::cerr << "\n\n ERROR DETECTED during dense matrix/dense matrix subtraction:\n"
<< ex.what() << "\n";
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}
//*************************************************************************************************
|
; A094056: Number of digits in A002860(n) (number of Latin squares).
; 1,1,2,3,6,9,14,21,28,37,48
pow $0,2
seq $0,6005 ; The odd prime numbers together with 1.
add $0,2
mov $2,2
mul $2,$0
sub $2,2
div $2,23
mov $0,$2
add $0,1
|
;
; Fast background area save
;
; MC-1000 version
;
; $Id: bksave.asm,v 1.6 2016-07-02 09:01:35 dom Exp $
;
SECTION code_clib
PUBLIC bksave
PUBLIC _bksave
PUBLIC bkpixeladdress
EXTERN gfxbyte_get
EXTERN pixelbyte
.bksave
._bksave
push ix ;save callers
ld hl,4
add hl,sp
ld e,(hl)
inc hl
ld d,(hl) ;sprite address
push de
pop ix
inc hl
ld e,(hl)
inc hl
inc hl
ld d,(hl) ; x and y __gfx_coords
ld h,d ; current x coordinate
ld l,e ; current y coordinate
ld (ix+2),h
ld (ix+3),l
ld a,(ix+0)
ld b,(ix+1)
dec a
srl a
srl a
srl a
inc a
inc a ; INT ((Xsize-1)/8+2)
ld (rbytes+1),a
.bksaves
push bc
call bkpixeladdress
.rbytes
ld b,0
.rloop
;-------
push bc
push hl
ex de,hl
call gfxbyte_get
ex de,hl
pop hl
pop bc
ld a,(pixelbyte)
;-------
ld (ix+4),a
inc de
inc ix
djnz rloop
inc l
pop bc
djnz bksaves
pop ix ;restore callers
ret
.bkpixeladdress
push hl
; add y-times the nuber of bytes per line (32)
; or just multiply y by 32 and the add
ld e,l
ld a,h
ld b,a
ld h,0
add hl,hl
add hl,hl
add hl,hl
add hl,hl
add hl,hl
ld de,$8000
add hl,de
; add x divided by 8
;or a
rra
srl a
srl a
ld e,a
ld d,0
add hl,de
ex de,hl
pop hl
ret
|
; A203135: Indices of hexagonal numbers that are also decagonal
; Submitted by Jon Maiga
; 1,28,943,32026,1087933,36957688,1255473451,42649139638,1448815274233,49217070184276,1671931570991143,56796456343514578,1929407584108504501,65543061403345638448,2226534680129643202723,75636636063004523254126,2569419091462024147437553
mov $2,4
mov $3,1
lpb $0
sub $0,1
mov $1,$3
mul $1,32
add $2,$1
add $3,$2
lpe
mov $0,$3
div $0,4
mul $0,3
add $0,1
|
//===================================================================================================================
//
// MmuVars.cc -- Common variables for the MMU
//
// Copyright (c) 2017-2020 -- Adam Clark
// Licensed under "THE BEER-WARE LICENSE"
// See License.md for details.
//
// ------------------------------------------------------------------------------------------------------------------
//
// Date Tracker Version Pgmr Description
// ----------- ------- ------- ---- ---------------------------------------------------------------------------
// 2019-Dec-22 Initial v0.5.0b ADCL Initial Version
//
//===================================================================================================================
#include "types.h"
#include "cpu.h"
#include "spinlock.h"
#include "mmu.h"
//
// -- This spinlock is used to control access to the address space to clear the frame
// -------------------------------------------------------------------------------
EXPORT KERNEL_BSS
Spinlock_t frameClearLock;
//
// -- This is used to control the flushes for the TLB buffer
// ------------------------------------------------------
EXPORT KERNEL_BSS
TlbFlush_t tlbFlush;
|
;--------------------------------------------------------
; File Created by SDCC : free open source ANSI-C Compiler
; Version 3.6.0 #9615 (MINGW64)
;--------------------------------------------------------
; PIC16 port for the Microchip 16-bit core micros
;--------------------------------------------------------
list p=18f4550
radix dec
;--------------------------------------------------------
; public variables in this module
;--------------------------------------------------------
global _eventInit
global _eventRead
;--------------------------------------------------------
; extern variables in this module
;--------------------------------------------------------
extern _kpRead
extern _kpInit
extern _serialInit
extern _serialProtocol
;--------------------------------------------------------
; Equates to used internal registers
;--------------------------------------------------------
STATUS equ 0xfd8
WREG equ 0xfe8
FSR1L equ 0xfe1
FSR2L equ 0xfd9
POSTDEC1 equ 0xfe5
PREINC1 equ 0xfe4
PRODL equ 0xff3
; Internal registers
.registers udata_ovr 0x0000
r0x00 res 1
r0x01 res 1
r0x02 res 1
r0x03 res 1
r0x04 res 1
r0x05 res 1
udata_event_0 udata
_key_ant res 1
;--------------------------------------------------------
; global & static initialisations
;--------------------------------------------------------
; I code from now on!
; ; Starting pCode block
S_event__eventRead code
_eventRead:
; .line 14; event.c unsigned int eventRead(void) {
MOVFF FSR2L, POSTDEC1
MOVFF FSR1L, FSR2L
MOVFF r0x00, POSTDEC1
MOVFF r0x01, POSTDEC1
MOVFF r0x02, POSTDEC1
MOVFF r0x03, POSTDEC1
MOVFF r0x04, POSTDEC1
MOVFF r0x05, POSTDEC1
; .line 16; event.c int ev = EV_NOEVENT;
MOVLW 0x06
MOVWF r0x00
CLRF r0x01
; .line 17; event.c key = kpRead();
CALL _kpRead
MOVWF r0x02
CLRF r0x03
; .line 18; event.c serial = serialProtocol();
CALL _serialProtocol
MOVWF r0x04
CLRF r0x05
; .line 19; event.c if ((key != 0) || (serial !=0)) {
MOVF r0x02, W
IORWF r0x03, W
BNZ _00122_DS_
MOVF r0x04, W
IORWF r0x05, W
BZ _00123_DS_
_00122_DS_:
; .line 20; event.c if ((key == 1)|| (serial == 'A')) {
MOVF r0x02, W
XORLW 0x01
BNZ _00143_DS_
MOVF r0x03, W
BZ _00110_DS_
_00143_DS_:
MOVF r0x04, W
XORLW 0x41
BNZ _00111_DS_
MOVF r0x05, W
BZ _00110_DS_
_00144_DS_:
BRA _00111_DS_
_00110_DS_:
; .line 21; event.c ev = EV_LEFT;
MOVLW 0x02
MOVWF r0x00
CLRF r0x01
_00111_DS_:
; .line 24; event.c if ((key == 2)||(serial== 'S')) {
MOVF r0x02, W
XORLW 0x02
BNZ _00147_DS_
MOVF r0x03, W
BZ _00113_DS_
_00147_DS_:
MOVF r0x04, W
XORLW 0x53
BNZ _00114_DS_
MOVF r0x05, W
BZ _00113_DS_
_00148_DS_:
BRA _00114_DS_
_00113_DS_:
; .line 25; event.c ev = EV_ENTER;
MOVLW 0x04
MOVWF r0x00
CLRF r0x01
_00114_DS_:
; .line 28; event.c if ((key == 3)||(serial=='D')) {
MOVF r0x02, W
XORLW 0x03
BNZ _00151_DS_
MOVF r0x03, W
BZ _00116_DS_
_00151_DS_:
MOVF r0x04, W
XORLW 0x44
BNZ _00117_DS_
MOVF r0x05, W
BZ _00116_DS_
_00152_DS_:
BRA _00117_DS_
_00116_DS_:
; .line 29; event.c ev = EV_RIGHT;
MOVLW 0x03
MOVWF r0x00
CLRF r0x01
_00117_DS_:
; .line 32; event.c if ((key == 4)||(serial=='@')) {
MOVF r0x02, W
XORLW 0x04
BNZ _00155_DS_
MOVF r0x03, W
BZ _00119_DS_
_00155_DS_:
MOVF r0x04, W
XORLW 0x40
BNZ _00123_DS_
MOVF r0x05, W
BZ _00119_DS_
_00156_DS_:
BRA _00123_DS_
_00119_DS_:
; .line 33; event.c ev = EV_RESET;
MOVLW 0x05
MOVWF r0x00
CLRF r0x01
_00123_DS_:
; .line 37; event.c key_ant = key;
MOVF r0x02, W
BANKSEL _key_ant
MOVWF _key_ant, B
; .line 38; event.c return ev;
MOVFF r0x01, PRODL
MOVF r0x00, W
MOVFF PREINC1, r0x05
MOVFF PREINC1, r0x04
MOVFF PREINC1, r0x03
MOVFF PREINC1, r0x02
MOVFF PREINC1, r0x01
MOVFF PREINC1, r0x00
MOVFF PREINC1, FSR2L
RETURN
; ; Starting pCode block
S_event__eventInit code
_eventInit:
; .line 8; event.c void eventInit(void) {
MOVFF FSR2L, POSTDEC1
MOVFF FSR1L, FSR2L
; .line 9; event.c kpInit();
CALL _kpInit
; .line 10; event.c serialInit();
CALL _serialInit
BANKSEL _key_ant
; .line 11; event.c key_ant = 0;
CLRF _key_ant, B
MOVFF PREINC1, FSR2L
RETURN
; Statistics:
; code size: 246 (0x00f6) bytes ( 0.19%)
; 123 (0x007b) words
; udata size: 1 (0x0001) bytes ( 0.06%)
; access size: 6 (0x0006) bytes
end
|
;; Licensed to the .NET Foundation under one or more agreements.
;; The .NET Foundation licenses this file to you under the MIT license.
;; See the LICENSE file in the project root for more information.
.586
.model flat
option casemap:none
.code
include AsmMacros.inc
EXTERN RhExceptionHandling_ThrowClasslibOverflowException : PROC
EXTERN RhExceptionHandling_ThrowClasslibDivideByZeroException : PROC
EXTERN __alldiv : PROC
EXTERN __allrem : PROC
EXTERN __aulldiv : PROC
EXTERN __aullrem : PROC
EXTERN __aulldvrm : PROC
EXTERN __alldvrm : PROC
esp_offsetof_dividend_low equ 4
esp_offsetof_dividend_high equ 8
esp_offsetof_divisor_low equ 12
esp_offsetof_divisor_high equ 16
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; RhpLDiv
;;
;; INPUT: [ESP+4]: dividend low
;; [ESP+8]: dividend high
;; [ESP+12]: divisor low
;; [ESP+16]: divisor high
;;
;; OUTPUT: EAX: result low
;; EDX: result high
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
FASTCALL_FUNC RhpLDiv, 16
;; pretest for the problematic cases of overflow and divide by zero
;; overflow: dividend = 0x80000000`00000000 and divisor = -1l = 0xffffffff`ffffffff
;; divide by zero: divisor = 0x00000000`00000000
;;
;; quick pretest - if the two halves of the divisor are unequal, we cannot
;; have one of the problematic cases
mov eax,[esp+esp_offsetof_divisor_low]
cmp eax,[esp+esp_offsetof_divisor_high]
je LDivDoMoreTests
LDivOkToDivide:
;; tailcall to the actual divide routine
jmp __alldiv
LDivDoMoreTests:
;; we know the high and low halves of the divisor are equal
;;
;; check for the divide by zero case
test eax,eax
je ThrowClasslibDivideByZeroException
;;
;; is the divisor == -1l? I.e., can we have the overflow case?
cmp eax,-1
jne LDivOkToDivide
;;
;; is the dividend == 0x80000000`00000000?
cmp dword ptr [esp+esp_offsetof_dividend_low],0
jne LDivOkToDivide
cmp dword ptr [esp+esp_offsetof_dividend_high],80000000h
jne LDivOkToDivide
FASTCALL_ENDFUNC
;; make it look like the managed code called this directly
;; by popping the parameters and putting the return address in the proper place
ThrowClasslibOverflowException proc
pop ecx
add esp,16
push ecx
;; passing return address in ecx
jmp RhExceptionHandling_ThrowClasslibOverflowException
ThrowClasslibOverflowException endp
ThrowClasslibDivideByZeroException proc
pop ecx
add esp,16
push ecx
;; passing return address in ecx
jmp RhExceptionHandling_ThrowClasslibDivideByZeroException
ThrowClasslibDivideByZeroException endp
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; RhpLMod
;;
;; INPUT: [ESP+4]: dividend low
;; [ESP+8]: dividend high
;; [ESP+12]: divisor low
;; [ESP+16]: divisor high
;;
;; OUTPUT: EAX: result low
;; EDX: result high
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
FASTCALL_FUNC RhpLMod, 16
;; pretest for the problematic cases of overflow and divide by zero
;; overflow: dividend = 0x80000000`00000000 and divisor = -1l = 0xffffffff`ffffffff
;; divide by zero: divisor = 0x00000000`00000000
;;
;; quick pretest - if the two halves of the divisor are unequal, we cannot
;; have one of the problematic cases
mov eax,[esp+esp_offsetof_divisor_low]
cmp eax,[esp+esp_offsetof_divisor_high]
je LModDoMoreTests
LModOkToDivide:
jmp __allrem
LModDoMoreTests:
;; we know the high and low halves of the divisor are equal
;;
;; check for the divide by zero case
test eax,eax
je ThrowClasslibDivideByZeroException
;;
;; is the divisor == -1l? I.e., can we have the overflow case?
cmp eax,-1
jne LModOkToDivide
;;
;; is the dividend == 0x80000000`00000000?
cmp dword ptr [esp+esp_offsetof_dividend_low],0
jne LModOkToDivide
cmp dword ptr [esp+esp_offsetof_dividend_high],80000000h
jne LModOkToDivide
jmp ThrowClasslibOverflowException
FASTCALL_ENDFUNC
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; RhpLDivMod
;;
;; INPUT: [ESP+4]: dividend low
;; [ESP+8]: dividend high
;; [ESP+12]: divisor low
;; [ESP+16]: divisor high
;;
;; OUTPUT: EAX: quotient low
;; EDX: quotient high
;; ECX: remainder high
;; EBX: remainder high
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
FASTCALL_FUNC RhpLDivMod, 16
;; pretest for the problematic cases of overflow and divide by zero
;; overflow: dividend = 0x80000000`00000000 and divisor = -1l = 0xffffffff`ffffffff
;; divide by zero: divisor = 0x00000000`00000000
;;
;; quick pretest - if the two halves of the divisor are unequal, we cannot
;; have one of the problematic cases
mov eax,[esp+esp_offsetof_divisor_low]
cmp eax,[esp+esp_offsetof_divisor_high]
je LDivModDoMoreTests
LDivModOkToDivide:
jmp __alldvrm
LDivModDoMoreTests:
;; we know the high and low halves of the divisor are equal
;;
;; check for the divide by zero case
test eax,eax
je ThrowClasslibDivideByZeroException
;;
;; is the divisor == -1l? I.e., can we have the overflow case?
cmp eax,-1
jne LDivModOkToDivide
;;
;; is the dividend == 0x80000000`00000000?
cmp dword ptr [esp+esp_offsetof_dividend_low],0
jne LDivModOkToDivide
cmp dword ptr [esp+esp_offsetof_dividend_high],80000000h
jne LDivModOkToDivide
jmp ThrowClasslibOverflowException
FASTCALL_ENDFUNC
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; RhpULDiv
;;
;; INPUT: [ESP+4]: dividend low
;; [ESP+8]: dividend high
;; [ESP+12]: divisor low
;; [ESP+16]: divisor high
;;
;; OUTPUT: EAX: result low
;; EDX: result high
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
FASTCALL_FUNC RhpULDiv, 16
;; pretest for divide by zero
mov eax,[esp+esp_offsetof_divisor_low]
or eax,[esp+esp_offsetof_divisor_high]
jne __aulldiv
jmp ThrowClasslibDivideByZeroException
FASTCALL_ENDFUNC
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; RhpULMod
;;
;; INPUT: [ESP+4]: dividend low
;; [ESP+8]: dividend high
;; [ESP+12]: divisor low
;; [ESP+16]: divisor high
;;
;; OUTPUT: EAX: result low
;; EDX: result high
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
FASTCALL_FUNC RhpULMod, 16
;; pretest for divide by zero
mov eax,[esp+esp_offsetof_divisor_low]
or eax,[esp+esp_offsetof_divisor_high]
jne __aullrem
jmp ThrowClasslibDivideByZeroException
FASTCALL_ENDFUNC
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; RhpULDivMod
;;
;; INPUT: [ESP+4]: dividend low
;; [ESP+8]: dividend high
;; [ESP+12]: divisor low
;; [ESP+16]: divisor high
;;
;; OUTPUT: EAX: quotient low
;; EDX: quotient high
;; ECX: remainder high
;; EBX: remainder high
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
FASTCALL_FUNC RhpULDivMod, 16
;; pretest for divide by zero
mov eax,[esp+esp_offsetof_divisor_low]
or eax,[esp+esp_offsetof_divisor_high]
jne __aulldvrm
jmp ThrowClasslibDivideByZeroException
FASTCALL_ENDFUNC
end
|
// This file is part of www.nand2tetris.org
// and the book "The Elements of Computing Systems"
// by Nisan and Schocken, MIT Press.
// File name: projects/04/Fill.asm
// Runs an infinite loop that listens to the keyboard input.
// When a key is pressed (any key), the program blackens the screen,
// i.e. writes "black" in every pixel;
// the screen should remain fully black as long as the key is pressed.
// When no key is pressed, the program clears the screen, i.e. writes
// "white" in every pixel;
// the screen should remain fully clear as long as no key is pressed.
// Put your code here.
// Nand2Tetris part 2, practice review 7/27/19
@R0 // R0 is the control bit for color: 0 = white, -1 = black
M=0 // initialize R0 to 0
(MAIN_LOOP)
@KBD
D=M
@MAKE_SCREEN_BLACK
D;JGT
@MAKE_SCREEN_WHITE
0;JMP
(MAKE_SCREEN_BLACK)
@R0
D=M
@MAIN_LOOP
D;JLT // back to loop if screen already black
@R0
M=-1
@DRAW
0;JMP
(MAKE_SCREEN_WHITE)
@R0
D=M
@MAIN_LOOP
D;JEQ // back to loop if screen already white
@R0
M=0
@DRAW // otherwise make screen white
0;JMP
(DRAW)
@i
M=0 // i = 0
@SCREEN
D = A
@address
M = D // address = 16384 (base address of the Hack screen)
(DRAW_LOOP)
@i
D=M
@8191
D=D-A
@MAIN_LOOP
D;JGT // if i > max words return to main loop
@R0
D=M // color control bit
@address
A=M // writing to memory using a pointer
M=D // RAM[address] = color control bit (16 pixels)
@i
M=M+1 // i += 1
@address
M=M+1 // address += 1
@DRAW_LOOP
0;JMP |
; *****************************************************************************
; *
; * Forth operating system for an IBM Compatible PC
; * Copyright (C) 1993-2011 W Nagel
; * Copyright (C) 2014 MikeOS Developers -- see doc/LICENSE.TXT
; *
; * For the most part it follows the FIG model, Forth-79 standard
; * There are differences, however
; *
; *****************************************************************************
; Some machines use subroutine threading (use SP for R stack) - this is
; considered Forth-like, and not true Forth. Also, the 8086 does not support
; [SP] and there are many more PUSH (1 byte) than RPUSH (4 bytes) instructions.
; This would be a poor choice for this processor.
; CFA = Compilation (or Code) Field Address.
; A Forth header =
; LFA address of previous word in chain, last one = 0
; NFA count(b4-0)/flags(b7=immediate, b5=smudge) + name
; CFA points to executable code for this definition
; PFA may contain parameters or code
; converted to nasm's macro processor
bits 16 ; nasm, 8086
%include "mikedev.inc"
cr equ 13 ; carriage return
lf equ 10 ; line feed
bell equ 7 ; bell (sort of)
spc equ 32 ; space
bs equ 8 ; back space
del equ 127 ; 'delete' character
%macro NEXT 0 ; mov di,[si] + inc si (twice) => couple extra bytes & many cycles
lodsw
xchg ax,di ; less bytes than mov, just as fast
jmp [di] ; 4 bytes
%endmacro
%macro RPUSH 1
dec bp
dec bp
mov word [bp+0],%1
%endmacro
%macro RPOP 1
mov word %1,[bp+0]
inc bp
inc bp
%endmacro
; A vocabulary is specified by a number between 1 and 15. See 'vocabulary' for a short
; discussion. A minimum of (2* highest vocabulary) dictionary threads are needed to
; prevent 'collisions' among the vocabularies. Initial compilation is entirely in the
; 'FORTH' vocabulary.
VOC EQU 1 ; specify FORTH part of Dictionary for this build
%assign IMM 0 ; next word is not IMMEDIATE
%macro IMMEDIATE 0 ; the following word is immediate
%assign IMM 080h
%endmacro
%assign defn 0 ; definition counter to create unique label
%define @def0 0 ; no definitions yet, mark as end of chain
%macro HEADING 1
%assign t1 defn ; unique label for chaining definitions
%assign defn defn+1 ; increment label
%strlen lenstrng %1 ; get length of name
@def %+ defn: dw @def %+ t1 ; temporary LFA -- first startup rearranges into chains
db IMM+lenstrng, %1 ; turn name into counted string with immediate indicator
%assign IMM 0 ; next word is not immediate, by default
%endmacro
org 0x8000 ; Start 1/2 way through segment for MikeOS
size EQU 65536
first EQU size & 0xffff ; 65536 or memory end for single segment 8086
stack0 EQU size - 128 ; R Stack & text input buffer
jmp do_startup ; maximize use-once code that will be "forgotten"
; Nucleus / Core -- ground 0
; Single precision (16-bit) Arithmetic operators
; CODE used extensively for speed
HEADING '*' ; ( n1 n2 -- n )
mult: dw $ + 2
pop di
pop ax
mul di
push ax
NEXT
HEADING '*/' ; ( n1 n2 n3 -- n )
dw $ + 2
pop di
pop dx
pop ax
imul dx
idiv di
push ax
NEXT
HEADING '*/MOD' ; ( u1 u2 u3 -- r q )
dw $ + 2
pop di
pop dx
pop ax
mul dx
div di
push dx
push ax
NEXT
HEADING '+' ; ( n1 n2 -- n )
plus: dw $ + 2
pop dx
pop ax
add ax,dx
push ax
NEXT
HEADING '-' ; ( n1 n2 -- n )
minus: dw $ + 2
pop dx
pop ax
sub ax,dx
push ax
NEXT
HEADING '/' ; ( n1 n2 -- n )
divide: dw $ + 2
pop di
pop ax
CWD
idiv di ; use di register for all divisions
push ax ; so that div_0 interrupt will work
NEXT
HEADING '/MOD' ; ( u1 u2 -- r q )
dw $ + 2
pop di
pop ax
sub dx,dx
div di
push dx
push ax
NEXT
HEADING '1+' ; ( n -- n+1 )
one_plus: dw $ + 2
pop ax
inc ax
push ax
NEXT
HEADING '1+!' ; ( a -- )
one_plus_store: dw $ + 2
pop di
inc word [di]
NEXT
HEADING '1-' ; ( n -- n-1 )
one_minus: dw $ + 2
pop ax
dec ax
push ax
NEXT
HEADING '1-!' ; ( a -- )
dw $ + 2
pop di
dec word [di]
NEXT
HEADING '2*' ; ( n -- 2n )
two_times: dw $ + 2
pop ax
shl ax,1
push ax
NEXT
HEADING '2**' ; ( n -- 2**N )
dw $ + 2
mov ax,1
pop cx
and cx,0Fh
shl ax,cl
push ax
NEXT
HEADING '2+' ; ( n -- n+2 )
two_plus: dw $ + 2
pop ax
inc ax
inc ax
push ax
NEXT
HEADING '2-' ; ( n -- n-2 )
two_minus: dw $ + 2
pop ax
dec ax
dec ax
push ax
NEXT
HEADING '2/' ; ( n -- n/2 )
dw $ + 2
pop ax
sar ax,1
push ax
NEXT
HEADING '4*' ; ( n -- 4n )
dw $ + 2
pop ax
shl ax,1
shl ax,1
push ax
NEXT
HEADING '4/' ; ( n -- n/4 )
dw $ + 2
pop ax
sar ax,1
sar ax,1
push ax
NEXT
HEADING 'MOD' ; ( u1 u2 -- r )
dw $ + 2
pop di
pop ax
sub dx,dx
div di
push dx
NEXT
HEADING 'NEGATE' ; ( n -- -n )
dw $ + 2
pop ax
negate1:
neg ax
push ax
NEXT
HEADING 'ABS' ; ( n -- |n| )
dw $ + 2
pop ax
or ax,ax
jl negate1 ; not alphabetical, allow short jump
push ax
NEXT
; Bit and Logical operators
HEADING 'AND' ; ( n1 n2 -- n )
cfa_and: dw $ + 2
pop dx
pop ax
and ax,dx
push ax
NEXT
HEADING 'COM' ; ( n -- !n >> ones complement )
dw $ + 2
pop ax
not ax
push ax
NEXT
HEADING 'LSHIFT' ; ( n c -- n<<c )
dw $ + 2
pop cx
pop ax
and cx,0Fh ; 16-bit word => max of 15 shifts
shl ax,cl
push ax
NEXT
HEADING 'NOT' ; ( f -- \f )
cfa_not: dw zero_eq + 2 ; similar to an alias
HEADING 'OR' ; ( n1 n2 -- n )
cfa_or: dw $ + 2
pop dx
pop ax
or ax,dx
push ax
NEXT
HEADING 'RSHIFT' ; ( n c -- n>>c )
dw $ + 2
pop cx
pop ax
and cx,0Fh
sar ax,cl
push ax
NEXT
HEADING 'XOR' ; ( n1 n2 -- n )
cfa_xor: dw $ + 2
pop dx
pop ax
xor ax,dx
push ax
NEXT
; Number comparison
HEADING '0<' ; ( n -- f )
zero_less: dw $ + 2
pop cx
or cx,cx
do_less:
mov ax,0
jge dl1
inc ax ; '79 true = 1
; dec ax ; '83 true = -1
dl1:
push ax
NEXT
HEADING '<' ; ( n1 n2 -- f )
less: dw $ + 2
pop dx
pop cx
cmp cx,dx
JMP do_less
HEADING '>' ; ( n1 n2 -- f )
greater: dw $ + 2
pop cx
pop dx
cmp cx,dx
JMP do_less
HEADING '0=' ; ( n -- f )
zero_eq: dw $ + 2
pop cx
test0:
mov ax,1 ; '79 true
jcxz z2
dec ax ; 1-1 = 0 = FALSE
z2:
push ax
NEXT
HEADING '=' ; ( n1 n2 -- f )
cfa_eq: dw $ + 2
pop dx
pop cx
sub cx,dx
JMP test0
HEADING 'MAX' ; ( n1 n2 -- n )
dw $ + 2
pop ax
pop dx
CMP dx,ax
jge max1
xchg ax,dx
max1:
push dx
NEXT
HEADING 'MIN' ; ( n1 n2 -- n )
cfa_min: dw $ + 2
pop ax
pop dx
CMP ax,dx
jge min1
xchg ax,dx
min1:
push dx
NEXT
HEADING 'U<' ; ( u1 u2 -- f )
u_less: dw $ + 2
sub cx,cx
pop dx
pop ax
cmp ax,dx
jnc ul1
inc cx
ul1:
push cx
NEXT
HEADING 'WITHIN' ; ( n nl nh -- f >> true if nl <= n < nh )
WITHIN: dw $ + 2
sub cx,cx ; flag, default is false
pop dx ; high limit
pop di ; low limit
pop ax ; variable
cmp ax,dx ; less than (lt) high, continue
jge w1
cmp ax,di ; ge low
jl w1
inc cx
w1:
push cx
NEXT
; Memory reference, 16 bit
HEADING '!' ; ( n a -- )
store: dw $ + 2
pop di
pop ax
stosw ; less bytes and just as fast as move
NEXT
HEADING '+!' ; ( n a -- )
plus_store: dw $ + 2
pop di
pop ax
add [di],ax
NEXT
HEADING '@' ; ( a -- n )
fetch: dw $ + 2
pop di
push word [di]
NEXT
HEADING 'C!' ; ( c a -- )
c_store: dw $ + 2
pop di
pop ax
stosb ; less bytes and just as fast as move
NEXT
HEADING 'C+!' ; ( c a -- )
dw $ + 2
pop di
pop ax
add [di],al
NEXT
HEADING 'C@' ; ( a -- zxc >> zero extend )
c_fetch: dw $ + 2
pop di
sub ax,ax
mov al,[di]
push ax
NEXT
HEADING 'FALSE!' ; ( a -- >> stores 0 in address )
false_store: dw $ + 2
sub ax,ax
pop di
stosw
NEXT
HEADING 'XFER' ; ( a1 a2 -- >> transfers contents of 1 to 2 )
XFER: dw $ + 2
pop dx
pop di
mov ax,[di]
mov di,dx
stosw
NEXT
; 16-bit Parameter Stack operators
HEADING '-ROT' ; ( n1 n2 n3 -- n3 n1 n2 )
m_ROT: dw $ + 2
pop di
pop dx
pop ax
push di
push ax
push dx
NEXT
HEADING '?DUP' ; ( n -- 0, n n )
q_DUP: dw $ + 2
pop ax
or ax,ax
jz qdu1
push ax
qdu1:
push ax
NEXT
HEADING 'DROP' ; ( n -- )
DROP: dw $ + 2
pop ax
NEXT
HEADING 'DUP' ; ( n -- n n )
cfa_dup: dw $ + 2
pop ax
push ax
push ax
NEXT
HEADING 'OVER' ; ( n1 n2 -- n1 n2 n1 )
OVER: dw $ + 2
mov di,sp
push word [di+2]
NEXT
HEADING 'PICK' ; ( ... n1 c -- ... nc )
PICK: dw $ + 2
pop di
dec di
shl di,1
add di,sp
push word [di]
NEXT
HEADING 'ROT' ; ( n1 n2 n3 -- n2 n3 n1 )
ROT: dw $ + 2
pop di
pop dx
pop ax
push dx
push di
push ax
NEXT
; Note: 'push sp' results vary by processor
HEADING 'SP@' ; ( -- a )
sp_fetch: dw $ + 2
mov ax,sp
push ax
NEXT
HEADING 'SWAP' ; ( n1 n2 -- n2 n1 )
SWAP: dw $ + 2
pop dx
pop ax
push dx
push ax
NEXT
; Return stack manipulation
HEADING 'I' ; ( -- n >> [RP] )
eye: dw $ + 2
mov ax,[bp+0]
push ax
NEXT
HEADING "I'" ; ( -- n >> [RP+2] )
eye_prime: dw $ + 2
mov ax,[bp+2]
push ax
NEXT
HEADING 'J' ; ( -- n >> [RP+4] )
dw $ + 2
mov ax,[bp+4]
push ax
NEXT
HEADING "J'" ; ( -- n >> [RP+6] )
dw $ + 2
mov ax,[bp+6]
push ax
NEXT
HEADING 'K' ; ( -- n >> [RP+8] )
dw $ + 2
mov ax,[bp+8]
push ax
NEXT
HEADING '>R' ; ( n -- >> S stack to R stack )
to_r: dw $ + 2
pop ax
RPUSH ax
NEXT
HEADING 'R>' ; ( -- n >> R stack to S stack )
r_from: dw $ + 2
RPOP ax
push ax
NEXT
; Constant replacements
; CONSTANT takes 66 cycles (8086) to execute
HEADING '0' ; ( -- 0 )
zero: dw $ + 2
xor ax,ax
push ax
NEXT
HEADING '1' ; ( -- 1 )
one: dw $ + 2
mov ax,1
push ax
NEXT
HEADING 'FALSE' ; ( -- 0 )
dw zero + 2
HEADING 'TRUE' ; ( -- t )
truu: dw $ + 2
mov ax,1 ; '79 value
push ax
NEXT
; 32-bit (double cell) - standard option
HEADING '2!' ; ( d a -- )
two_store: dw $ + 2
pop di
pop dx ; TOS = high word
pop ax ; variable low address => low word
stosw
mov ax,dx
stosw
NEXT
HEADING '2>R' ; ( n n -- >> transfer to R stack )
two_to_r: dw $ + 2
pop ax
pop dx
RPUSH dx
RPUSH ax
NEXT
HEADING '2@' ; ( a -- d )
two_fetch: dw $ + 2
pop di
push word [di] ; low variable address => low word
push word [di+2] ; low param stack address (TOS) => high word
NEXT
HEADING '2DROP' ; ( d -- )
two_drop: dw $ + 2
pop ax
pop ax
NEXT
HEADING '2DUP' ; ( d -- d d )
two_dup: dw $ + 2
pop dx
pop ax
push ax
push dx
push ax
push dx
NEXT
HEADING '2OVER' ; ( d1 d2 -- d1 d2 d1 )
two_over: dw $ + 2
mov di,sp
push word [di+6]
push word [di+4]
NEXT
HEADING '2R>' ; ( -- n1 n2 )
two_r_from: dw $ + 2
RPOP ax
RPOP dx
push dx
push ax
NEXT
HEADING '2SWAP' ; ( d1 d2 -- d2 d1 )
two_swap: dw $ + 2
pop dx
pop di
pop ax
pop cx
push di
push dx
push cx
push ax
NEXT
HEADING 'D+' ; ( d1 d2 -- d )
d_plus: dw $ + 2
pop dx
pop ax
dplus:
mov di,sp
add [di+2],ax
adc [di],dx
NEXT
HEADING 'D+!' ; ( d a -- )
dw $ + 2
pop di
pop dx
pop ax
add [di+2],ax
adc [di],dx
NEXT
HEADING 'D-' ; ( d1 d2 -- d )
d_minus: dw $ + 2
pop cx
pop di
pop ax
pop dx
sub dx,di
sbb ax,cx
push dx
push ax
NEXT
HEADING 'D0=' ; ( d -- f )
d_zero_eq: dw $ + 2
pop ax
pop dx
sub cx,cx
or ax,dx
jnz dz1
inc cx ; 1, F79
; dec cx ; -1, F83
dz1:
push cx
NEXT
HEADING 'DNEGATE' ; ( d -- -d )
DNEGATE: dw $ + 2
pop dx
pop ax
neg ax
adc dx,0
neg dx
push ax
push dx
NEXT
HEADING 'S>D' ; ( n -- d )
s_to_d: dw $ + 2
pop ax
CWD
push ax
push dx
NEXT
HEADING 'M*' ; ( n1 n2 -- d )
dw $ + 2
pop ax
pop dx
imul dx
push ax
push dx
NEXT
HEADING 'M+' ; ( d1 n -- d )
dw $ + 2
pop ax
CWD
jmp dplus
HEADING 'M/' ; ( d n1 -- n )
dw $ + 2
pop di
pop dx
pop ax
idiv di
push ax
NEXT
HEADING 'U*' ; ( u1 u2 -- d )
dw $ + 2
pop ax
pop dx
mul dx
push ax
push dx
NEXT
HEADING 'U/MOD' ; ( d u -- r q )
dw $ + 2
pop di
pop dx
pop ax
div di
push dx
push ax
NEXT
; Long Structures - more efficient code, but extra byte
; These use a stored address rather than a byte offset
do_branch: dw $ + 2
branch:
lodsw ; ax = goto address
mov si,ax ; XP = goto
NEXT
; jump on opposite condition, ie NE IF compiles JE
q_branch: dw $ + 2 ; ( f -- )
pop ax
or ax,ax
je branch ; ignore conditional execution if flag false
no_branch:
inc si ; bypass jump address
inc si
NEXT ; and then execute conditional words
do_loop: dw $ + 2
mov cx,1 ; normal increment
lp1:
add cx,[bp+0] ; update counter
mov [bp+0],cx ; save for next round
cmp cx,[bp+2] ; (signed, Forth-79) compare to limit
jl branch ; not at end of loop count, go again
lp2:
add bp,4 ; at end, drop cntr & limit from R stack
inc si ; skip jump/loop address & continue
inc si
NEXT
plus_loop: dw $ + 2 ; ( n -- )
pop cx
JMP lp1
slant_loop: dw $ + 2 ; ( n -- )
pop dx
add [bp+0],dx ; (Forth-83) crossed boundary from below?
mov ax,[bp+0]
sub ax,[bp+2]
xor ax,dx
jge lp2 ; end of loop, exit
jmp branch ; no, branch back to loop beginning
c_switch: dw $ + 2 ; ( xx c.input -- xx | xx c.input )
pop dx
RPUSH si
ADD si,4
sub cx,cx
c_s1: ; BEGIN
lodsw ; inc si, get address of byte
mov di,ax
MOV cl,[di] ; byte to match
lodsw ; inc si, get possible link
CMP dl,cl
je c_s3 ; input match this entry ?
CMP ax,0 ; WHILE not last link = 0
jz c_s2
mov si,ax
JMP c_s1 ; REPEAT, try next entry
c_s2:
push dx ; no matches
c_s3:
NEXT
do_switch: dw $ + 2 ; ( xx n.input -- xx | xx n.input )
pop dx ; switch input
RPUSH si
ADD si,4 ; skip forth branch
sw1:
lodsw
MOV cx,ax ; number to match
lodsw ; increment I; get possible link
CMP dx,cx
je sw3 ; input match this entry
CMP ax,0
je sw2
mov si,ax
JMP sw1 ; try next entry
sw2:
push dx ; no matches
sw3:
NEXT
; Runtime for literals
bite: dw $ + 2
lodsb ; get data byte
cbw ; sign extend to word
push ax
NEXT
cell: dw $ + 2 ; code def with no header/ only cfa.
lodsw ; used by literal
push ax ; push data word on param stack
NEXT
dclit: dw $ + 2 ; ( -- sxc1 sxc2 )
lodsb ; get first byte
cbw
push ax
lodsb ; get second byte
cbw
push ax
NEXT
dblwd: dw $ + 2 ; ( -- d )
lodsw
mov dx,ax ; low address => high word when inline
lodsw
push ax
push dx ; lower stack address (TOS) => high word
NEXT
; Program execution
HEADING 'EXECUTE'
EXECUTE: dw $ + 2
pop di ; ( cfa -- >> runtime )
exec1:
or di,di
jz e001 ; no address was given, cannot be 0
jmp [di]
e001:
NEXT
HEADING '@EXECUTE'
@EXECUTE: dw $ + 2
pop di ; ( a -- >> runtime )
mov di,[di]
JMP exec1
HEADING 'EXIT' ; LFA + NFA
EXIT: dw $ + 2 ; CFA
exit1: ; R = BP, return stack pointer ( PFA )
RPOP si
NEXT
HEADING 'LEAVE-EXIT'
leave_exit: dw $ + 2
add bp,4 ; 2RDROP - count & limit
jmp exit1
HEADING '2LEAVE-EXIT'
dw $ + 2
add bp,8 ; 4RDROP - both counts & limits
jmp exit1
HEADING 'LEAVE'
leave_lp: dw $ + 2
mov ax,[bp+0] ; next test will => done, count = limit
mov [bp+2],ax
NEXT
HEADING 'STAY' ; ( f -- >> exit if false )
STAY: dw $ + 2
pop ax
or ax,ax
jz exit1
NEXT
; Defining words -- define & execution
HEADING ':'
dw colon
dw cfa_create, r_bracket
dw sem_cod ; sets CFA of daughter to 'colon'
colon:
inc di ; cfa -> pfa
inc di
RPUSH si ; rpush si = execute ptr => current pfa
mov si,di ; exec ptr = new pfa
NEXT
; Note - word copies input to here + 2, in case of a new definition
HEADING 'CREATE'
cfa_create dw colon ; ( -- )
dw blnk, cfa_word, cfa_dup ; word adr = string adr = na
dw c_fetch, cfa_dup ; ( na count count )
dw zero_eq, abortq
db ct001 - $ - 1
db 'No name'
ct001:
dw bite ; ( na count )
db 31
dw greater, abortq
db ct002 - $ - 1
db 'Name too long!'
ct002:
dw CURRENT, c_fetch, HASH, FIND_WD ; ( na v -- na lfa,0 )
dw q_DUP, q_branch ; IF name exists in current vocab,
dw ct005 ; print redefinition 'warning'
dw CR, OVER, COUNT, cfa_type
dw dotq
db ct003 - $ - 1
db ' Redefinition of: '
ct003:
dw cfa_dup, id_dot, dotq
db ct004 - $ - 1
db 'at '
ct004:
dw u_dot
ct005: ; THEN
dw CURRENT, c_fetch, HASH ; ( na link )
dw HEADS, plus, HERE ; ( nfa hdx lfa=here )
dw cfa_dup, LAST, store ; ( nfa hdx lfa )
dw OVER, fetch, comma ; set link field
dw SWAP, store ; update heads
dw c_fetch ; ( count )
dw one_plus, ALLOT ; allot name and count/flags
dw SMUDGE
dw zero, comma ; code field = 0, ;code will update
dw sem_cod
create: ; ( -- pfa )
inc di ; cfa -> pfa
inc di
push di ; standard def => leave pfa on stack
NEXT
does:
RPUSH si ; rpush current (word uses parent) execute ptr
pop si ; get new (parent) execute ptr
inc di ; daughter cfa -> pfa
inc di
push di ; leave daughter pfa on stack
NEXT
HEADING 'CONSTANT'
cfa_constant: dw colon ; ( n -- >> compile time )
dw cfa_create, comma
dw UNSMUDGE, sem_cod
constant: ; ( -- n >> run time )
push word [di+2]
NEXT
HEADING '2CONSTANT'
dw colon ; ( d -- )
dw SWAP, cfa_constant
dw comma, sem_cod
two_con: ; ( -- d )
push word [di+2]
push word [di+4]
NEXT
; System-wide constants
HEADING '0.' ; ( -- 0 0 >> code def is alternative )
zero_dot: dw two_con
dw 0, 0
HEADING '1.'
dw two_con
dw 1, 0
HEADING '2'
two: dw constant, 2
HEADING 'BL'
blnk: dw constant, spc ; <space>
B_HDR: dw constant ; bytes in header, ie, hash lists * 2
dw 32 ; see HEADS and FENCE
L_WIDTH: dw constant
dw 80
HEADING 'S0'
SP0: dw constant, stack0
; String, text operators
HEADING '-TEXT' ; ( a1 n a2 -- f,t=different )
dw $ + 2
pop di
pop cx
pop ax
xchg ax,si
REP CMPSB
je txt1
mov cx,1
jnc txt1
neg cx
txt1:
push cx
mov si,ax
NEXT
HEADING '-TRAILING' ; ( a n -- a n' )
m_TRAILING: dw $ + 2
pop cx
pop di
push di
jcxz trl1
mov al,' '
add di,cx
dec di
STD
REP scasb
cld
je trl1
inc cx
trl1:
push cx
NEXT
HEADING '<CMOVE' ; ( s d n -- )
backwards_cmove: dw $ + 2
pop cx
pop di
pop ax
jcxz bmv1
xchg ax,si
add di,cx
dec di
add si,cx
dec si
STD
REP movsb
cld
mov si,ax
bmv1:
NEXT
HEADING 'CMOVE' ; ( s d n -- )
front_cmove: dw $ + 2
pop cx ; count
pop di
pop ax
xchg ax,si
rep movsb
mov si,ax
NEXT
HEADING 'COUNT' ; ( a -- a+1 n )
COUNT: dw $ + 2
pop di
sub ax,ax
mov al,[di]
inc di
push di
push ax
NEXT
; Memory fills
HEADING 'FILL' ; ( a n c -- )
dw $ + 2
pop ax
mem_fill:
pop cx
pop di
REP stosb
NEXT
HEADING 'BLANK' ; ( a n -- )
BLANK: dw $ + 2
mov al,' '
JMP mem_fill
HEADING 'ERASE' ; ( a n -- )
ERASE: dw $ + 2
sub ax,ax
JMP mem_fill
; Intersegment data moves
HEADING 'L!' ; ( n seg off -- )
dw $ + 2
pop di
pop ds
pop ax
mov [di],ax
mov dx,cs
mov ds,dx
NEXT
HEADING 'L@' ; ( seg off -- n )
dw $ + 2
pop di
pop ds
mov ax,[di]
mov dx,cs
mov ds,dx
push ax
NEXT
HEADING 'LC!' ; ( c seg off -- )
dw $ + 2
pop di
pop ds
pop ax
mov [di],al
mov dx,cs
mov ds,dx
NEXT
HEADING 'LC@' ; ( seg off -- c >> zero extended byte )
dw $ + 2
pop di
pop ds
sub ax,ax
mov al,[di]
mov dx,cs
mov ds,dx
push ax
NEXT
HEADING 'FORTHSEG' ; ( -- seg )
FORTHSEG: dw $ + 2 ; not a constant in a PC system
push cs ; changes each time the program is run
NEXT
HEADING 'STACKSEG' ; ( -- seg )
dw $ + 2
mov ax,cs ; 64K (4K segs) above FORTHSEG
add ax,4096
push ax
NEXT
HEADING 'FIRSTSEG' ; ( -- seg )
dw $ + 2
mov ax,cs ; 128K (8K segs) above FORTHSEG, 64k above stack/buffer seg
add ax,8192
push ax
NEXT
HEADING 'SEGMOVE' ; ( fs fa ts ta #byte -- )
dw $ + 2
pop cx
pop di
pop es
pop ax
pop ds
xchg ax,si
shr cx,1
jcxz segmv1
REP MOVSw
segmv1:
jnc segmv2
movsb
segmv2:
mov dx,cs
mov ds,dx
mov es,dx
mov si,ax
NEXT
; Miscellaneous Stuff
HEADING '><' ; ( n -- n' >> bytes interchanged )
dw $ + 2
pop ax
xchg al,ah
push ax
NEXT
HEADING '+@' ; ( a1 a2 -- n )
plus_fetch: dw $ + 2
pop ax
pop di
add di,ax
push word [di]
NEXT
HEADING '@+' ; ( n1 a -- n )
fetch_plus: dw $ + 2
pop di
pop ax
add ax,[di]
push ax
NEXT
HEADING '@-' ; ( n1 a -- n )
fetch_minus: dw $ + 2
pop di
pop ax
sub ax,[di]
push ax
NEXT
HEADING 'CFA' ; ( pfa -- cfa )
CFA: dw two_minus + 2 ; similar to an alias
HEADING '>BODY' ; ( cfa -- pfa )
to_body: dw two_plus + 2 ; similar to an alias
HEADING 'L>CFA' ; ( lfa -- cfa )
l_to_cfa: dw $ + 2
pop di
inc di
inc di
mov al,[di]
AND ax,1Fh ; count only, no flags such as immediate
add di,ax
inc di
push di
NEXT
HEADING 'L>NFA' ; ( lfa -- nfa )
l_to_nfa: dw two_plus + 2
HEADING 'L>PFA' ; ( lfa -- pfa )
dw colon
dw l_to_cfa, to_body, EXIT
; 15-bit Square Root of a 31-bit integer
HEADING 'SQRT' ; ( d -- n )
dw $ + 2
pop dx
pop ax
push si
sub di,di
mov si,di
mov cx,16
lr1:
shl ax,1
rcl dx,1
rcl si,1
shl ax,1
rcl dx,1
rcl si,1
shl di,1
shl di,1
inc di
CMP si,di
jc lr2
sub si,di
inc di
lr2:
shr di,1
LOOP lr1
pop si
push di
NEXT
; Start Colon Definitions -- non-defining words
; Best for FORTH compiler to create defining words first -- minimizes forward references
; Most of these are used in the base dictionary
HEADING 'D<' ; ( d1 d2 -- f )
d_less: dw colon ; CFA
dw d_minus ; PFA
dw zero_less, SWAP, DROP
dw EXIT ; semicolon
HEADING 'D=' ; ( d1 d2 -- f )
dw colon
dw d_minus
dw d_zero_eq
dw EXIT
HEADING 'DABS' ; ( d -- |d| )
DABS: dw colon
dw cfa_dup, zero_less, q_branch ; IF <0 THEN NEGATE
dw dab1
dw DNEGATE
dab1:
dw EXIT
HEADING 'DMAX' ; ( d1 d2 -- d )
dw colon
dw two_over, two_over, d_less
dw q_branch ; IF 1st < THEN SWAP
dw dmax1
dw two_swap
dmax1:
dw two_drop
dw EXIT
HEADING 'DMIN' ; ( d1 d2 -- d )
DMIN: dw colon
dw two_over, two_over, d_less
dw zero_eq, q_branch ; IF 1st >= THEN SWAP
dw dmin1
dw two_swap
dmin1:
dw two_drop
dw EXIT
HEADING '-LEADING' ; ( addr cnt -- addr' cnt' )
m_LEADING: dw colon
dw cfa_dup, zero, two_to_r
mld1:
dw OVER, c_fetch, blnk
dw cfa_eq, q_branch ; IF leading = space
dw mld2
dw SWAP, one_plus
dw SWAP, one_minus, do_branch
dw mld3
mld2:
dw leave_lp
mld3:
dw do_loop
dw mld1
dw EXIT
HEADING '0>' ; ( n -- f )
zero_greater: dw colon
dw zero, greater
dw EXIT
HEADING '3DUP' ; ( n1 n2 n3 -- n1 n2 n3 n1 n2 n3 )
three_dup: dw colon
dw cfa_dup, two_over, ROT
dw EXIT
HEADING 'ROLL' ; ( ... c -- ... )
dw colon
dw two_times, to_r, sp_fetch
dw eye, two_minus, plus_fetch
dw sp_fetch, cfa_dup, two_plus
dw r_from, backwards_cmove, DROP
dw EXIT
HEADING 'T*' ; ( d n -- t )
tr_times: dw $ + 2
mov [bp-2],si ; save thread pointer above 'R'
mov [bp-4],bx ; save user pointer - in case implemented
pop bx ; n
pop si ; d hi
pop di ; d lo
mov ax,di
mul bx ; n * lo
push ax ; bottom (lo) of tripple result
mov cx,dx
mov ax,si
mul bx ; n * hi
add cx,ax ; middle terms
adc dx,0
or si,si
jge tt1 ; correct unsigned mul by n
sub dx,bx
tt1:
or bx,bx
jge tt2 ; correct unsigned mul by d
sub cx,di
sbb dx,si
tt2:
push cx ; result mid
push dx ; result hi
mov bx,[bp-4] ; restore registers
mov si,[bp-2]
NEXT
HEADING 'T/' ; ( t n -- d )
tr_div: dw $ + 2
pop di ; n
pop dx ; hi
pop ax ; med
pop cx ; lo
push si
sub si,si
or di,di
jge td11
neg di ; |n|
inc si
td11:
or dx,dx
jge td12
dec si ; poor man's negate
neg cx ; |t|
adc ax,0
adc dx,0
neg ax
adc dx,0
neg dx
td12:
div di
xchg ax,cx
div di
or si,si ; sign of results
jz td13 ; 0 or 2 negatives => positive
neg ax ; dnegate
adc cx,0
neg cx
td13:
pop si
push ax
push cx
NEXT
HEADING 'M*/' ; ( d1 n1 n2 -- d )
dw colon
dw to_r, tr_times, r_from, tr_div
dw EXIT
; No User variables -- all treated as normal variables for single user system
HEADING 'SPAN' ; actual # chrs rcvd.
SPAN: dw create ; Normal variable
span1: dw 0
HEADING 'TIB' ; Text input starts at top of parameter stack
TIB: dw create
tib1: dw stack0
HEADING '#TIB'
num_tib: dw create
n_tib1: dw 0
HEADING 'T_FLG' ; serial transmit flags
dw create ; cvariable
tflg1: db 0
HEADING 'R_FLG' ; serial receive flags
rcv_flg: dw create ; cvariable
rflg1: db 0
; User / System variables
HEADING 'CONTEXT' ; ( -- a >> 2variable )
CONTEXT: dw create
dw VOC, 0
HEADING 'CURRENT' ; ( -- a >> 2variable )
CURRENT: dw create
dw VOC, 0
; Kept variable storage together to make PROTECT and EMPTY easier
HEADING 'HEADS'
HEADS: dw create ; 'Links to remember'
hds: times 16 dw 0
h1: dw very_end
last1: dw 0 ; LFA of last word defined
HEADING 'FENCE'
FENCE: dw create ; GOLDEN (protected)
links: times 16 dw 0
goldh: dw addr_end
goldl: dw GOLDEN_LAST
; Now setup access to array elements as a variable
HEADING 'H'
H: dw constant
dw h1
HEADING 'LAST'
LAST: dw constant
dw last1
HEADING 'BUF0' ; only disk buffer(s), for now
BUF0: dw create
buf0a: times 1024 db spc ; currently in FORTH seg
HEADING 'BUF1' ; break buffer into 2 pieces for IBM
dw constant
dw BUF0 + 512 + 2
HEADING 'PATH'
PATH: dw create
path1: db 'a:\' ; drive
path2: times 62 db spc ; path
db 0
HEADING 'FNAME'
FNAME: dw create
fname1: times 64 db spc ; name
db 0
HEADING "'ABORT"
dw create
abrt_ptr: dw QUT1
HEADING 'BASE'
BASE: dw create
base1: dw 10 ; decimal
T_BASE: dw create ; headerless variable
t_ba: dw 10
HEADING '>IN'
tin: dw create
tin1: dw 0
hndl1: dw 0 ; temporary store before transfer to handle
; used like BLK in normal systems
; minimum value should be 5, max = FILES - 1
qend1: dw 0 ; at end of file for loading
HEADING 'STATE'
STATE: dw create
state1: dw 0
HEADING 'HLD'
HLD: dw create
hld1 dw 0
HEADING 'RMD'
RMD: dw create
dw 0
HEADING 'ROWS'
dw create
max_rows: dw 0
; Include stored interrupt vector(s) for convenience
HEADING 'LINES'
dw create
max_col: dw 0
_mode: dw 0 ; video setup information
_page: dw 0
d_off: dw 0 ; save divide 0 vector here
d_seg: dw 0
sp_save: dw 0 ; save original SP
ss_save: dw 0
HEADING 'D_VER' ; DOS version for .com generate
D_VER: dw create
dver1: dw 0
HEADING 'ABORT'
ABORT: dw $ + 2 ; ( x ... x -- )
abrt: MOV sp,stack0 ; clear parameter stack
mov ax,[base1] ; reset temporary base to current
mov [t_ba],ax
sub ax,ax ; mark disk file as ended
mov [qend1],ax
push ax ; for parameter stack underflow
MOV si,[abrt_ptr] ; goto 'quit'
NEXT
HEADING 'SYSTEM'
SYSTEM: dw $ + 2
push es
mov cx,[d_seg] ; restore div 0 vector
mov dx,[d_off]
xor ax,ax ; interrupt segment and address of vector 0
mov es,ax
mov di,ax
mov [es:di],dx
mov [es:di+2],cx
mov dx,[sp_save]
mov ax,[ss_save]
pop es
cli ; restore original SP
mov sp,dx
mov ss,ax
sti
ret ; return to MikeOS
HEADING '!CURSOR' ; ( row col -- )
dw $ + 2
pop dx
pop ax
mov dh,al
call os_move_cursor
NEXT
HEADING '@CURSOR' ; ( -- row col )
get_cursor: dw $ + 2
call os_get_cursor_pos
sub ax,ax
mov al,dh
push ax
mov al,dl
push ax
NEXT
HEADING 'CLS' ; ( -- )
CLS: dw $ + 2
call os_clear_screen
NEXT
; Polled 'type'
; Bits 0-3 of T_FLG control transmission; Bit 0 => XON
HEADING 'TYPE' ; ( a n -- )
cfa_type: dw $ + 2
pop cx ; character count
pop di ; ds:di = data pointer
push bx ; some BIOS destroy BX, DX and/or BP
push bp
or cx,cx ; normally 1 to 255 characters, always < 1025
jle short ty2 ; bad data or nothing to print
ty1:
test byte [tflg1],0Fh ; output allowed? XON-XOFF
jne ty1
mov al,[di] ; get character
inc di
mov ah,0x0E ; print to screen, TTY mode
mov bh,[_page] ; ignored on newer BIOSs
mov bl,7 ; foreground, usually ignored
int 10h
loop ty1 ; do for input count
ty2:
pop bp
pop bx
NEXT
HEADING 'EMIT' ; ( c -- )
EMIT: dw $ + 2
pop ax
push bx ; some BIOS destroy BX, DX and/or BP
push bp
mov ah,0x0E
mov bh,[_page]
mov bl,7 ; foreground, usually ignored
int 10h
pop bp
pop bx
NEXT
HEADING '/0' ; heading for generate
dw $ + 2
div_0: ; divide zero interrupt
sub ax,ax
cwd
mov di,1 ; 80286 will repeat division !
iret
; TERMINAL -- NON-VECTORED
; Note: buffer must be able to contain one more than expected characters.
HEADING 'EXPECT' ; ( a n -- )
EXPECT: dw $ + 2
pop cx ; count
pop di ; buffer address
push bx ; some BIOS destroy BX, DX and/or BP
push bp
sub ax,ax
MOV [span1],ax
or cx,cx ; > 0, normally < 1025
jg exp_loop
jmp exp_end
exp_loop:
and byte [rflg1],7Fh ; clear special, b7
xor ax,ax ; BIOS input, no echo
int 16h
cmp al,0 ; extended/special ?
je exp1 ; yes
cmp al,0xE0
jne exp2
exp1:
or byte [rflg1],80h ; set special
mov al,1 ; get extended scan code in al
xchg al,ah
jmp short exp_store ; special cannot be a control
exp2: ; normal input, limited control processing
TEST byte [rflg1],1 ; (b0=raw) skip test specials ?
jnz exp_store
CMP al,bs ; <back space> ?
je exp5
CMP al,del ; <delete> ?
jne exp7
exp5:
TEST word [span1],7FFFh ; any chr in buffer ?
jnz exp6
mov dl,bell ; echo (warning) bell
jmp short exp_echo
exp6:
DEC word [span1]
INC cx
dec di
test byte [rflg1],10h ; b4, echo allowed ?
jnz exp10
mov bh,[_page]
mov bl,7 ; foreground, usually ignored
mov ax,0x0E08 ; BS
int 10h
mov ax,0x0E20 ; space
int 10h
mov ax,0x0E08 ; BS
int 10h
jmp short exp10
exp7:
CMP al,cr ; <cr> ?
jne exp9
sub cx,cx ; no more needed
mov dl,' ' ; echo space
jmp short exp_echo
exp9:
cmp al,lf ; <lf> ?
jne exp_store
mov al,' ' ; echo & store space
exp_store:
mov dl,al ; echo input
stosb
INC word [span1]
DEC cx
exp_echo:
test byte [rflg1],10h ; b4, echo allowed ?
jnz exp10
mov al,dl
mov ah,0x0E ; send to monitor
mov bh,[_page]
mov bl,7 ; foreground, usually ignored
int 10h
exp10:
jcxz exp_end
jmp exp_loop
exp_end:
sub ax,ax ; end input marker
stosb
pop bp
pop bx
NEXT
HEADING 'KEY' ; ( -- c >> high byte = end marker = 0 )
KEY: dw colon
dw rcv_flg, c_fetch, cfa_dup, one, cfa_or, rcv_flg, c_store ; set special
dw zero, sp_fetch, one, EXPECT ; ( rflg c )
dw rcv_flg, c_fetch, bite
db 80h
dw cfa_and, ROT, cfa_or ; extended receive &
dw rcv_flg, c_store ; echo flag maintained
dw EXIT
cfa_msg: dw colon
dw cfa_create, UNSMUDGE, sem_cod
msg:
db 232 ; call pushes execute PFA on parameter stack
dw does - $ - 2
dw COUNT, cfa_type
dw EXIT
; Generic CRT Terminal
HEADING 'BELL'
BELL: dw msg
db 1, bell
HEADING 'CR'
CR: dw msg
db 2, cr, lf
HEADING 'OK'
OK: dw msg
db 2, 'ok'
HEADING 'SPACE'
SPACE: dw msg
db 1, ' '
HEADING 'SPACES' ; ( n -- >> n=0 to 32767 )
SPACES: dw colon
dw cfa_dup, zero_greater, q_branch ; IF number positive
dw sp2
dw cfa_dup, zero, two_to_r
sp1:
dw SPACE, do_loop
dw sp1
sp2:
dw DROP
dw EXIT
HEADING 'HERE' ; ( -- h )
HERE: dw $ + 2
PUSH word [h1]
NEXT
h_p_2: dw colon ; ( -- h+2 )
dw HERE, two_plus
dw EXIT
HEADING 'PAD' ; ( -- a >> a=here+34, assumes full header )
PAD: dw $ + 2
mov ax,[h1]
ADD ax,34 ; max NFA size + LFA
push ax
NEXT
; Pictured Number output
HEADING 'HOLD' ; ( n -- )
HOLD: dw $ + 2
DEC word [hld1]
MOV di,[hld1]
pop ax
stosb
NEXT
dgt1: dw $ + 2 ; ( d -- d' c )
pop ax
pop cx
sub dx,dx
mov di,[base1] ; no overflow should be possible
DIV di ; just in case base cleared
xchg ax,cx
DIV di
push ax
push cx
CMP dl,10 ; dx = Rmd: 0 to Base
jc dgt2 ; U<
add dl,7 ; 'A' - '9'
dgt2:
add dl,'0' ; to ASCII
push dx
NEXT
HEADING '<#' ; ( d -- d )
st_num: dw colon
dw PAD, HLD, store
dw EXIT
HEADING '#' ; ( d -- d' )
add_num: dw colon
dw dgt1, HOLD
dw EXIT
HEADING '#>' ; ( d -- a n )
nd_num: dw colon
dw two_drop, HLD, fetch
dw PAD, OVER, minus
dw EXIT
HEADING 'SIGN' ; ( n d -- d )
SIGN: dw colon
dw ROT, zero_less, q_branch ; IF negative
dw si1
dw bite
db '-'
dw HOLD
si1:
dw EXIT
HEADING '#S' ; ( d -- 0 0 )
nums: dw colon
nums1:
dw add_num, two_dup, d_zero_eq
dw q_branch ; UNTIL nothing left
dw nums1
dw EXIT
HEADING '(D.)' ; ( d -- a n )
paren_d: dw colon
dw SWAP, OVER, DABS
dw st_num, nums
dw SIGN, nd_num
dw EXIT
HEADING 'D.R' ; ( d n -- )
d_dot_r: dw colon
dw to_r, paren_d, r_from, OVER, minus, SPACES, cfa_type
dw EXIT
HEADING 'U.R' ; ( u n -- )
u_dot_r: dw colon
dw zero, SWAP, d_dot_r
dw EXIT
HEADING '.R' ; ( n n -- )
dw colon
dw to_r, s_to_d, r_from, d_dot_r
dw EXIT
HEADING 'D.' ; ( d -- )
d_dot: dw colon
dw paren_d, cfa_type, SPACE
dw EXIT
HEADING 'U.' ; ( u -- )
u_dot: dw colon
dw zero, d_dot
dw EXIT
HEADING '.' ; ( n -- )
dot: dw colon
dw s_to_d, d_dot
dw EXIT
; String output
; ( f -- a n >> return to caller if true )
; ( f -- >> skip caller if false )
q_COUNT: dw $ + 2
MOV di,[bp+0] ; get pointer to forth stream
sub ax,ax
mov al,[di]
inc ax
ADD [bp+0],ax ; bump pointer past string
pop dx
or dx,dx
jnz cnt_1
JMP exit1
cnt_1:
dec ax ; restore count
inc di ; get address
push di
push ax
NEXT
; ( f -- >> return to caller if false )
abortq: dw colon
dw q_COUNT, h_p_2, COUNT, cfa_type
dw SPACE, cfa_type, CR
dw ABORT
dotq: dw colon
dw one, q_COUNT, cfa_type
dw EXIT
; 32-bit Number input
q_DIGIT: dw $ + 2 ; ( d a -- d a' n f )
sub dx,dx
pop di ; get addr
inc di ; next chr
push di ; save
mov al,[di] ; get this chr
cmp al,58 ; chr U< '9'+ 1
jc dgt4
cmp al,65
jc bad_dgt
SUB al,7 ; 'A' - '9'
dgt4:
SUB al,'0'
jc bad_dgt
CMP al,[t_ba]
jnc bad_dgt
cbw
push ax
INC dx
bad_dgt:
push dx
NEXT
D_SUM: dw $ + 2 ; ( d a n -- d' a )
pop di
pop dx
pop ax
pop cx
push dx
MUL word [t_ba]
xchg ax,cx
MUL word [t_ba]
ADD ax,di
ADC cx,dx
pop dx
push ax
push cx
push dx
NEXT
HEADING 'CONVERT' ; ( d a -- d' a' )
CONVERT: dw colon
dgt8:
dw q_DIGIT, q_branch ; IF
dw dgt9
dw D_SUM, HLD, one_plus_store
dw do_branch
dw dgt8
dgt9:
dw EXIT
HEADING 'NUMBER' ; ( a -- n, d )
NUMBER: dw colon
dw cell, -513, HLD, store ; max length * -1
dw cfa_dup, one_plus, c_fetch, bite ; 1st chr '-' ?
db '-'
dw cfa_eq, cfa_dup, to_r, q_branch ; IF, save sign & pass up
dw num1
dw one_plus
num1:
dw zero, cfa_dup, ROT ; ( 0. a' )
num2:
dw CONVERT, cfa_dup, c_fetch, cfa_dup ; ( d end chr[end] )
dw dclit
db 43, 48 ; chr[end] '+' to '/'
dw WITHIN, SWAP, bite
db 58 ; or ':' ?
dw cfa_eq, cfa_or, q_branch
dw num3
dw HLD, false_store, do_branch ; yes = double
dw num2
num3:
dw c_fetch, abortq ; word ends zero
db 1,'?'
dw r_from, q_branch ; IF negative, NEGATE
dw num4
dw DNEGATE
num4:
dw HLD, fetch, zero_less, q_branch
dw num5
dw RMD, store ; single = store high cell
num5:
dw BASE, T_BASE, XFER
dw EXIT
; Floppy variables
; Do NOT support DOS functions: Delete or Rename
; This construct turns a memory location into a "variable" that fits in other definitions
HEADING 'HNDL'
HNDL: dw constant
dw hndl1
HEADING '?END'
q_END: dw constant
dw qend1
HEADING 'FDSTAT'
FDSTAT: dw create
fdst1: dw 0 ; error flag, may be extended later
HEADING 'FDWORK'
FDWORK: dw create
fdwk1: dw 0 ; error, handle, or count low
fdwk2: dw 0 ; high word of count when applicable
HEADING ".AZ" ; ( a -- )
dot_az: dw colon
dw dclit ; print ASCII zero terminated string
db 64, 0
dw two_to_r ; DO
dp1:
dw cfa_dup, c_fetch, q_DUP
dw q_branch, dp2 ; IF
dw EMIT, one_plus
dw do_branch, dp3 ; ELSE
dp2:
dw leave_lp
dp3: ; THEN
dw do_loop, dp1 ; LOOP
dw DROP
dw EXIT
del_lf: dw $ + 2 ; ( a n -- )
pop cx
pop di
mov dx,di
jcxz dlf3
inc cx ; results of last comparison not checked
push cx
mov ax,200Ah ; ah = replacement = space, al = search = LineFeed
dl001:
repne scasb
jcxz dlf1
mov [di-1],ah
jmp dl001
dlf1:
pop cx
mov di,dx
mov al,09 ; remove tab characters
dl002:
repne scasb
jcxz dlf2
mov [di-1],ah
jmp dl002
dlf2:
cmp byte [di-1],26 ; eof marker
jne dlf3
mov [di-1],ah
dlf3:
NEXT
GET_DISK: dw colon ; ( a n -- )
dw BLANK, SPACE, ABORT
; Interpreter
do_wrd01: dw $ + 2 ; ( c a n -- a=here+2 )
pop cx
pop di
do_wrd02: ; Entry with just ( c -- ), DI & CX set
pop ax ; chr
push ax
push si ; execute pointer
ADD di,[tin1]
SUB cx,[tin1] ; number of chrs left
ADD [tin1],cx ; set pointer to end of input
SUB si,si ; set z flag
REP scasb ; del leading chrs
mov si,di ; save beginning
je wrd01 ; cx = 0 = no significant chrs
dec si ; back up to 1st significant chr
REPne scasb
jne wrd01 ; input ended in significant chr
dec di ; back up to last significant chr
wrd01:
SUB [tin1],cx ; back pointer to end this word
cmp byte [di-1],cr ; ends in <cr> ?
jne wrd02 ; yes = do not include in word
dec di
wrd02:
SUB di,si ; number chr in this word
MOV cx,di
MOV di,[h1]
inc di
inc di
mov dx,di ; adr = here + 2
push cx ; save count
MOV ax,cx
stosb ; counted string format
REP movsb ; count = 0 = do not move anything
sub ax,ax ; terminate with bytes 0, 0
stosw
pop cx
pop si ; retrieve Forth execute pointer
or cx,cx ; any chrs ?
jnz wrd03 ; yes = exit WORD
mov cx,[n_tib1] ; may be empty disk line
cmp cx,[tin1] ; any more ?
jg strm2 ; yes = try next word
wrd03:
pop ax ; remove test chr
push dx ; set here+2
JMP exit1
STREAM: dw $ + 2 ; ( c -- c )
MOV cx,[n_tib1]
mov di,[hndl1]
or di,di
jnz strm2 ; disk is active source
MOV di,[tib1] ; text input buffer [TIB]
strm1:
jmp do_wrd02 ; Skip GET DISK buffer & go directly to WORD
strm2:
mov di, buf0a ; disk buffer
mov ax,[tin1] ; still in buf0 ?
cmp ax,512
jl strm1 ; yes = get next word
test byte [qend1],0xff ; at end of file ?
jne strm1
mov dx,512
sub ax,dx ; fix pointers
mov [tin1],ax ; >IN
sub cx,dx
mov [n_tib1],cx ; #TIB
push di ; BUF0 for do_wrd01
push cx ; n=ctr, position
mov ax,di
add ax,512 ; buf1 = buf0 + 512
push ax ; BUF1 for get_disk
push dx ; count = 512
xchg si,ax
mov cx,256
rep movsw ; move 512 bytes from buf1 to buf0
mov si,ax ; restore FORTH exec pointer
NEXT ; ( c a=buf0 n=#tib a=buf1 cnt=512 )
HEADING 'WORD' ; ( c -- a )
cfa_word: dw colon
dw STREAM ; will go directly to do_wrd02
dw GET_DISK ; may abort ( c a0 n )
dw do_wrd01 ; EXIT not needed
; Dictionary search
HASH: ; ( na v -- na offset )
dw $ + 2
pop ax
AND ax,0Fh ; must have a vocabulary (1-15) to search, v <> 0
shl ax,1 ; 2* vocab, different chains for each
pop di
push di ; hash = 2 * vocab + 1st char of word
ADD al,[di+1] ; 1st char (not count)
AND al,1Eh ; (B_HDR - 2) even, mod 32 => 16 chains
push ax
NEXT
; Note - no address can be less than 0100h
FIND_WD: ; ( na offset -- na lfa,0 )
dw $ + 2
mov [bp-2],si ; temporary save XP - below return
pop di ; chain offset
pop ax ; address of counted string to match
push ax
ADD di, hds ; address of beginning of hash chain
push di
fnd1:
pop di ;
mov di,[di] ; get next link
push di ; last link in chain = 0
or di,di
jz fnd2 ; end of chain, not found
inc di ; goto count/flags byte
inc di
MOV cx,[di]
AND cx,3Fh ; count (1F) + smudge (20)
mov si,ax
CMP cl,[si]
jne fnd1 ; wrong count, try next word
inc di ; to beginning of text
inc si
REP CMPSB ; compare the two strings
jne fnd1 ; not matched, try next word
fnd2: ; exit - found or chain exhausted
mov si,[bp-2] ; restore execution pointer
NEXT
; LFA > 0100h (current lowest value is 0103h), can be used as "found" flag
; HEADING 'FIND' ; ( na -- cfa lfa/f if found || na 0 if not )
FIND: dw colon
dw CONTEXT, two_fetch ; ( na v.d )
find1: ; BEGIN
dw two_dup, d_zero_eq, cfa_not, q_branch ; WHILE, still vocab to search
dw find3
dw two_dup, zero, bite
db 16
dw tr_div, two_to_r, DROP, HASH, FIND_WD
dw two_r_from, ROT, q_DUP
dw q_branch, find2 ; IF found
dw m_ROT, two_drop, SWAP, DROP
dw cfa_dup, l_to_cfa, SWAP, EXIT
find2: ; THEN
dw do_branch ; REPEAT, not found yet
dw find1
find3:
dw two_drop, zero, EXIT ; not found anywhere
HEADING 'DEPTH' ; ( -- n )
DEPTH: dw $ + 2
mov ax,stack0
SUB ax,sp
sar ax,1
dec ax ; 0 for underflow protection
push ax
NEXT
q_STACK: dw colon
dw DEPTH, zero_less, abortq
db qsk2 - $ - 1
db 'Stack Empty'
qsk2:
dw EXIT
; Interpreter control - notice that this is not reentrant
; uses variables - #TIB, >IN & HNDL - to manipulate input (text or disk)
HEADING 'INTERPRET'
INTERPRET: dw colon
ntrp1: ; BEGIN
dw blnk, cfa_word
dw cfa_dup, c_fetch, q_branch ; WHILE - text left in input buffer
dw ntrp6
dw FIND, q_DUP, q_branch ; IF found in context vocabulary, process it
dw ntrp3
dw one_plus, fetch, zero_less ; Immediate flag in high byte for test
dw STATE, fetch, cfa_not, cfa_or
dw q_branch, nrtp2 ; IF Immediate or not compiling ( cfa )
dw EXECUTE, q_STACK, do_branch
dw ntrp5 ; ELSE compiling => put into current word
nrtp2:
dw comma, do_branch
dw ntrp5 ; THEN
ntrp3: ; ELSE try a number - may abort ( na )
dw NUMBER
dw STATE, fetch, q_branch ; IF compiling => put into current word
dw ntrp5
dw HLD, fetch, zero_less ; IF single precision (includes byte)
dw q_branch
dw ntrp4
dw LITERAL, do_branch ; ELSE double precision
dw ntrp5
ntrp4:
dw cell, dblwd, comma, comma, comma ; COMPILE dblwd
; THEN ; THEN
ntrp5: ; THEN
dw do_branch, ntrp1 ; REPEAT until stream exhausted
ntrp6:
dw DROP, EXIT ; Exit and get more input
HEADING 'QUERY'
QUERY: dw colon ; get input from keyboard or disk stream
dw TIB, fetch, L_WIDTH, EXPECT
dw SPAN, num_tib, XFER
dw zero_dot, tin, two_store
dw EXIT
R_RESET: dw $ + 2
MOV bp,first
NEXT
HEADING 'QUIT' ; ( -- )
QUIT: dw colon
QUT1: dw STATE, false_store ; start by interpreting user input
qt02: ; BEGIN
dw R_RESET, QUERY, INTERPRET
dw OK, CR
dw do_branch, qt02 ; AGAIN => Endless loop
; Note no Exit needed
; Vocabulary lists
HEADING 'ID.' ; ( lfa -- >> prints name of word at link addr )
id_dot: dw colon
dw l_to_nfa, cfa_dup, c_fetch, bite
db 1Fh
dw cfa_and, zero
dw two_to_r ; DO for len of word (some versions do not store whole word)
id1:
dw one_plus, cfa_dup, c_fetch ; ( adr chr )
dw cfa_dup, blnk, less, q_branch ; IF control character, print caret
dw id2
dw dotq
db 1,'^'
dw bite
db 64
dw plus
id2: ; THEN
dw EMIT
dw do_loop
dw id1 ; LOOP
dw DROP, SPACE, SPACE
dw EXIT
; Compiler
HEADING 'IMMEDIATE'
dw colon
dw LAST, fetch, l_to_nfa
dw cfa_dup, c_fetch, cell, 80h ; set bit 7 of the count-flag byte
dw cfa_or, SWAP, c_store
dw EXIT
HEADING 'ALLOT' ; ( n -- )
ALLOT: dw colon
dw SP0, OVER, HERE, plus, bite
db 178 ; full head(34) + pad(80) + min stack(64)
dw plus, u_less, abortq
db alt3 - $ - 1
db 'Dictionary full'
alt3:
dw H, plus_store, EXIT
HEADING 'C,' ; ( uc -- )
c_comma: dw colon
dw HERE, c_store, one, ALLOT
dw EXIT
HEADING ',' ; ( u -- )
comma: dw colon
dw HERE, store, two, ALLOT
dw EXIT
HEADING '?CELL' ; ( n -- n f,t=word )
q_CELL: dw colon
dw cfa_dup, bite
db -128
dw cell, 128
dw WITHIN, zero_eq
dw EXIT
IMMEDIATE
HEADING 'LITERAL' ; ( n -- )
LITERAL: dw colon
dw q_CELL, q_branch, lit1 ; IF
dw cell, cell, comma, comma ; COMPILE cell
dw do_branch, lit2 ; ELSE
lit1:
dw cell, bite, comma, c_comma ; COMPILE byte
lit2: ; THEN
dw EXIT
IMMEDIATE
HEADING 'COMPILE'
dw colon
dw blnk, cfa_word, FIND ; (cfa t || na 0)
dw cfa_not, abortq
db cmp1 - $ - 1
db '?'
cmp1:
dw LITERAL, sem_cod
COMPILE:
db 232 ; call executes comma (below)
dw does - $ - 2
dw comma ; puts CFA of next word into dictionary
dw EXIT
IMMEDIATE
HEADING "'" ; ( return or compile CFA as literal )
tic: dw colon
dw blnk, cfa_word, FIND ; ( na 0 || cfa lfa )
dw cfa_not, abortq
db 1,'?'
dw STATE, fetch, STAY
dw LITERAL, EXIT ; ( compiling => put in-line )
HEADING ']' ; ( -- >> set STATE for compiling )
r_bracket: dw $ + 2
mov ax,1
mov [state1],ax ; compiling
NEXT
IMMEDIATE
HEADING '[' ; ( -- )
l_bracket: dw $ + 2
sub ax,ax
mov [state1],ax ; interpreting
NEXT
HEADING 'SMUDGE'
SMUDGE: dw colon
dw LAST, fetch, l_to_nfa, cfa_dup
dw c_fetch, blnk ; set bit 5
dw cfa_or, SWAP, c_store
dw EXIT
HEADING 'UNSMUDGE'
UNSMUDGE: dw colon
dw LAST, fetch, l_to_nfa, cfa_dup
dw c_fetch, bite ; clear bit 5
db 0DFh
dw cfa_and, SWAP, c_store
dw EXIT
IMMEDIATE
HEADING ';'
dw colon
dw cell, EXIT, comma ; COMPILE EXIT
dw l_bracket, UNSMUDGE
dw EXIT
; Chains increase speed of compilation and
; allow multiple vocabularies without special code.
; User vocabularies can also have separate chains to keep definitions separate.
; 4 chains would be sufficient for a minimum kernel,
; but vocabularies would be limited to max. of 4
; 8 chains => maximum of 8 vocabularies, good for small systems
; 16 chains best choice for medium to large systems and for cross compiling
; 32 chains are marginally better for larger systems, but more is not always best
; Each vocabulary = nibble size => maximum number of 7 vocabularies,
; 15 (if pre-multiply*2)
; nibble in cell => maximum search path of 4 vocabularies
; dword => 8 nibbles => 8 search vocabularies
; Note: can "seal" portion of dictionary by eliminating FORTH from search string
HEADING 'VOCABULARY' ; ( d -- )
dw colon
dw cfa_create, SWAP, comma, comma, UNSMUDGE, sem_cod
vocabulary:
db 232 ; call
dw does - $ - 2
dw two_fetch, CONTEXT, two_store
dw EXIT
HEADING 'ASSEMBLER'
ASSEMBLER: dw vocabulary, 0012h, 0 ; search order is low adr lsb to high adr msb
HEADING 'EDITOR'
dw vocabulary, 0013h, 0
HEADING 'FORTH'
dw vocabulary, VOC, 0 ; VOC = 00000001
HEADING 'DEFINITIONS'
dw colon
dw CONTEXT, two_fetch, CURRENT, two_store
dw EXIT
HEADING ';code'
sem_cod: dw colon
dw r_from
dw LAST, fetch, l_to_cfa, store
dw EXIT
IMMEDIATE
HEADING ';CODE'
dw colon
dw cell, sem_cod, comma ; COMPILE ;code
dw r_from, DROP, ASSEMBLER
dw l_bracket, UNSMUDGE
dw EXIT
HEADING 'CVARIABLE'
dw colon
dw cfa_create, zero, c_comma, UNSMUDGE
dw EXIT
HEADING 'VARIABLE'
VARIABLE: dw colon
dw cfa_create, zero, comma, UNSMUDGE
dw EXIT
HEADING '2VARIABLE'
dw colon
dw VARIABLE, zero, comma
dw EXIT
IMMEDIATE
HEADING 'DCLIT' ; ( c1 c2 -- )
dw colon
dw cell, dclit, comma ; COMPILE dclit
dw SWAP, c_comma, c_comma ; reverse bytes here instead of
dw EXIT ; execution time!
HEADING 'ARRAY' ; ( #bytes -- )
dw colon
dw cfa_create, HERE, OVER
dw ERASE, ALLOT, UNSMUDGE
dw EXIT
; Compiler directives - conditionals
; Absolute [long] structures
; Short structures did not save that much space, longer execution time
; Note: the code contains 47 Forth ?branch (IF) statements
; 19 do_branch -- other conditionals such as THEN and REPEAT
; 9 normal loops, 3 /loops and 1 +loop
IMMEDIATE
HEADING 'IF' ; ( -- a )
cfa_if: dw colon
dw cell, q_branch, comma ; COMPILE ?branch
dw HERE, zero, comma
dw EXIT
IMMEDIATE
HEADING 'THEN' ; ( a -- )
THEN: dw colon
dw HERE, SWAP, store
dw EXIT
IMMEDIATE
HEADING 'ELSE' ; ( a1 -- a2 )
dw colon
dw cell, do_branch, comma ; COMPILE branch
dw HERE, zero, comma
dw SWAP, THEN, EXIT
IMMEDIATE
HEADING 'BEGIN' ; ( -- a )
dw colon
dw HERE
dw EXIT
IMMEDIATE
HEADING 'UNTIL' ; ( a -- | f -- )
dw colon
dw cell, q_branch, comma ; COMPILE ?branch
dw comma, EXIT
IMMEDIATE
HEADING 'AGAIN' ; ( a -- )
AGAIN: dw colon
dw cell, do_branch, comma ; COMPILE branch
dw comma, EXIT
IMMEDIATE
HEADING 'WHILE'
dw colon
dw cfa_if, SWAP
dw EXIT
IMMEDIATE
HEADING 'REPEAT'
dw colon
dw AGAIN, THEN
dw EXIT
; Switch Support - part 2 (compiling)
IMMEDIATE
HEADING 'SWITCH'
dw colon
dw cell, do_switch, comma ; COMPILE switch
dw cell, do_branch, comma ; COMPILE branch
dw HERE, cfa_dup, zero, comma
dw EXIT
IMMEDIATE
HEADING 'C@SWITCH'
dw colon
dw cell, c_switch, comma ; COMPILE c_switch
dw cell, do_branch, comma ; COMPILE branch
dw HERE, cfa_dup, zero, comma
dw EXIT
IMMEDIATE
HEADING '{' ; ( a1 a2 n -- a1 h[0] )
dw colon
dw comma, HERE, zero
dw comma, cfa_dup, two_minus, ROT
dw store, r_bracket
dw EXIT
IMMEDIATE
HEADING '}'
dw colon
dw cell, EXIT, comma ; COMPILE EXIT
dw EXIT
IMMEDIATE
HEADING 'ENDSWITCH'
dw colon
dw DROP, THEN
dw EXIT
; Compiler directives - looping
IMMEDIATE
HEADING 'DO' ; ( -- a )
dw colon
dw cell, two_to_r, comma ; COMPILE 2>R
dw HERE, EXIT
IMMEDIATE
HEADING 'LOOP' ; ( a -- )
dw colon
dw cell, do_loop, comma ; COMPILE loop
dw comma, EXIT
IMMEDIATE
HEADING '+LOOP' ; ( a -- )
dw colon
dw cell, plus_loop, comma ; COMPILE +loop
dw comma, EXIT
IMMEDIATE
HEADING '/LOOP' ; ( a -- )
dw colon
dw cell, slant_loop, comma ; COMPILE /loop
dw comma, EXIT
; Miscellaneous
IMMEDIATE
HEADING 'DOES>'
dw colon
dw cell, sem_cod, comma ; COMPILE ;code
dw cell, 232, c_comma ; CALL does - leaves PFA on stack
dw cell, does - 2, HERE
dw minus, comma
dw EXIT
HEADING 'EMPTY' ; ( -- )
EMPTY: dw colon
dw FENCE, HEADS, bite
db 36
dw front_cmove
dw EXIT
; Updates HERE and HEADS, but not LAST
HEADING 'FORGET'
dw colon
dw blnk, cfa_word, CURRENT, c_fetch, HASH, FIND_WD ; ( na v -- na lfa,0 )
dw q_DUP, cfa_not, abortq
db 1,'?'
dw SWAP, DROP, cfa_dup ; (lfa lfa)
dw cell, goldh, fetch
dw u_less ; ( protected from deletion )
dw abortq
db 5,"Can't"
dw H, store ; new HERE = LFA
dw H, HEADS, two_to_r ; DO for 16 chains
fgt1:
dw eye, fetch
fgt2: ; BEGIN
dw cfa_dup, HERE, u_less
dw cfa_not, q_branch, fgt3 ; WHILE defined after this word, go down chain
dw fetch, do_branch, fgt2 ; REPEAT
fgt3:
dw eye, store, two, slant_loop, fgt1 ; /LOOP update top of chain, do next
dw EXIT
HEADING 'PROTECT' ; ( -- )
PROTECT: dw colon
dw HEADS, FENCE, bite
db 36
dw front_cmove
dw EXIT
HEADING 'STRING' ; ( -- )
STRING: dw colon
dw bite
db -2
dw ALLOT, bite
db '"'
dw cfa_word, c_fetch, two_plus
dw one_plus, ALLOT
dw EXIT
HEADING 'MSG'
dw colon
dw cfa_msg, STRING
dw EXIT
IMMEDIATE
HEADING 'ABORT"'
dw colon
dw STATE, fetch, q_branch, abtq1 ; IF ( -- ) compiling
dw cell, abortq, comma ; COMPILE abort" and put string into dictionary
dw STRING, do_branch, abtq3
abtq1:
dw bite ; ELSE ( f -- ), interpret must have flag
db '"'
dw cfa_word, SWAP, q_branch, abtq2 ; IF flag is true, print string and abort
dw COUNT, cfa_type, ABORT
dw do_branch, abtq3
abtq2: ; ELSE drop string address
dw DROP
abtq3: ; THEN THEN
dw EXIT
IMMEDIATE
HEADING '."'
dw colon
dw STATE, fetch, q_branch, dq1 ; IF compiling
dw cell, dotq, comma ; COMPILE ." and put string into dictionary
dw STRING, do_branch, dq2
dq1: ; ELSE print following string
dw bite
db '"'
dw cfa_word, COUNT, cfa_type
dq2: ; THEN
dw EXIT
HEADING '?' ; ( a -- )
question: dw colon
dw fetch, dot
dw EXIT
; Set operating bases
HEADING 'BASE!' ; ( n -- )
base_store: dw colon
dw cfa_dup, BASE, store
dw T_BASE, store
dw EXIT
HEADING '.BASE' ; ( -- >> print current base in decimal )
dw colon
dw BASE, fetch, cfa_dup, bite
db 10
dw BASE, store, dot
dw BASE, store
dw EXIT
HEADING 'DECIMAL'
DECIMAL: dw colon
dw bite
db 10
dw base_store
dw EXIT
HEADING 'HEX'
HEX: dw colon
dw bite
db 16
dw base_store
dw EXIT
HEADING 'OCTAL'
dw colon
dw bite
db 8
dw base_store
dw EXIT
HEADING 'BINARY'
dw colon
dw bite
db 2
dw base_store
dw EXIT
IMMEDIATE
HEADING '$'
dw colon
dw bite
db 16
dw T_BASE, store
dw EXIT
IMMEDIATE
HEADING 'Q'
dw colon
dw bite
db 8
dw T_BASE, store
dw EXIT
IMMEDIATE
HEADING '%'
dw colon
dw bite
db 2
dw T_BASE, store
dw EXIT
IMMEDIATE
HEADING '('
dw colon
dw bite
db ')'
dw cfa_word, DROP
dw EXIT
; String operators, help with Screen Editor
HEADING '-MATCH' ; ( a n s n -- a t )
dw $ + 2
pop dx
pop ax
pop cx
pop di
PUSH bx
push si
mov bx,ax
MOV al,[bx]
DEC dx
SUB cx,dx
jle mat3
INC bx
mat1:
REP scasb
jne mat3 ; 1st match
push cx
push di
MOV si,bx
mov cx,dx
REP CMPSB
je mat2
pop di ; No match
pop cx
JMP mat1
mat2:
pop ax ; Match
pop ax
sub ax,ax
mat3:
pop si
pop bx
push di
push ax
NEXT
HEADING '?PRINTABLE' ; ( c -- f,t=printable )
q_PRINTABLE: dw colon
dw dclit
db spc, '~'+1
dw WITHIN
dw EXIT
IMMEDIATE
HEADING '\'
dw colon
dw bite
db cr
dw cfa_word, DROP
dw EXIT
; Vocabulary lists
HEADING 'H-LIST' ; ( n -- )
hlist: dw colon
dw two_times, HEADS, plus_fetch ; ( list head )
dw CR
hlst1: ; BEGIN
dw q_DUP, q_branch, hlst3 ; WHILE
dw cfa_dup, id_dot, fetch
dw get_cursor, bite ; test column
db 64
dw greater, q_branch, hlst2 ; IF
dw CR
hlst2: ; THEN
dw DROP ; drop row/line
dw do_branch, hlst1 ; REPEAT
hlst3:
dw EXIT
; Headerless, only used by WORDS below
; returns highest lfa contained in copy of HEADS at PAD
MAX_HEADER: dw colon ; ( -- index max.lfa )
dw zero_dot
dw B_HDR, zero, two_to_r
mh1:
dw cfa_dup, PAD, eye, plus_fetch
dw u_less, q_branch ; ( new max lfa )
dw mh2
dw two_drop, eye, PAD
dw eye, plus_fetch
mh2:
dw two, slant_loop
dw mh1
dw EXIT
HEADING 'VLIST' ; ( -- >> lists the words in the context vocabulary )
dw colon
dw HEADS, PAD, B_HDR ; copy HEADS to PAD
dw front_cmove, CR
wds1: ; BEGIN
dw MAX_HEADER, cfa_dup, q_branch ; WHILE a valid lfa exists at PAD
dw wds4
dw two_dup, two_plus ; ( index lfa index nfa )
dw CONTEXT, fetch, HASH ; just first vocab
dw SWAP, DROP ; ( index lfa index index' )
dw cfa_eq, q_branch ; IF in this vocab, display name
dw wds2
dw cfa_dup, id_dot
wds2: ; THEN
dw fetch, SWAP, PAD
dw plus, store ; update PAD, working header
dw get_cursor, bite
db 64
dw greater, q_branch ; IF near end of line, send new line
dw wds3
dw CR
wds3: ; THEN
dw DROP, do_branch
dw wds1
wds4: ; REPEAT
dw two_drop
dw EXIT
; Miscellaneous extensions
HEADING '.S'
dot_s: dw colon
dw q_STACK, DEPTH, CR, q_branch ; IF
dw dots2
dw sp_fetch, cell, stack0 - 4, two_to_r
dots1:
dw eye, fetch, u_dot, bite
db -2
dw slant_loop
dw dots1
dots2:
dw dotq
db dots3 - $ - 1
db ' <--Top '
dots3:
dw EXIT
HEADING 'LOWER>UPPER' ; ( k -- k' )
dw colon
dw cfa_dup, dclit
db 'a', 'z'+1
dw WITHIN, q_branch
dw l_u1
dw blnk, minus ; if lower case ASCII clear bit 5
l_u1:
dw EXIT
HEADING 'R-DEPTH'
dw $ + 2
MOV ax,first
SUB ax,bp
SHR ax,1
push ax
NEXT
HEADING 'R>S'
dw $ + 2
MOV cx,first
SUB cx,bp
shr cx,1
MOV ax,cx
rs1:
MOV di,cx
shl di,1
NEG di
ADD di,first
push word [di]
LOOP rs1
push ax
NEXT
HEADING 'DUMP' ; ( a n -- )
DUMP: dw colon
dw zero, two_to_r ; DO
du1:
dw eye, bite
db 15
dw cfa_and, cfa_not, q_branch ; IF, new line
dw du2
dw CR, cfa_dup, eye, plus, bite
db 5
dw u_dot_r, SPACE
du2: ; THEN
dw eye, bite
db 7
dw cfa_and, cfa_not, q_branch ; IF, 3 more spaces
dw du3
dw bite
db 3
dw SPACES
du3: ; THEN
dw cfa_dup, eye
dw plus, c_fetch, bite
db 4
dw u_dot_r, do_loop
dw du1 ; LOOP
dw CR, DROP
dw EXIT
HEADING 'WDUMP' ; ( a n -- )
dw colon
dw zero, two_to_r
wdp1:
dw eye, bite
db 7
dw cfa_and, cfa_not, q_branch
dw wdp2
dw CR, cfa_dup, eye, two_times, plus, bite
db 5
dw u_dot_r, SPACE
wdp2:
dw cfa_dup, eye, two_times
dw plus_fetch, bite
db 7
dw u_dot_r, do_loop
dw wdp1
dw CR, DROP
dw EXIT
HEADING '.LINE' ; ( adr n -- )
dot_line: dw colon
dw to_r, PAD, eye, front_cmove
dw PAD, eye, zero, two_to_r
dln1:
dw cfa_dup, eye, plus, c_fetch, q_PRINTABLE
dw cfa_not, q_branch
dw dln2
dw bite
db 94
dw OVER, eye, plus, c_store
dln2:
dw do_loop
dw dln1
dw r_from, cfa_type
dw EXIT
HEADING 'A-DUMP' ; ( a n -- )
a_dump: dw colon
dw zero, two_to_r
ad1:
dw eye, bite
db 63
dw cfa_and, cfa_not, q_branch
dw ad2
dw CR, cfa_dup, eye, plus, bite
db 5
dw u_dot_r, bite
db 3
dw SPACES
ad2:
dw cfa_dup, eye, plus, bite
db 64
dw eye_prime, cfa_min, dot_line, bite
db 64
dw slant_loop
dw ad1
dw CR, DROP
dw EXIT
IMMEDIATE
HEADING 'ASCII' ; ( -- n )
dw colon
dw blnk, cfa_word, one_plus
dw c_fetch ; ( ASCII value of next word )
dw STATE, fetch
dw STAY, LITERAL
dw EXIT
HEADING '?MEM' ; ( -- left )
dw colon
dw sp_fetch, PAD
dw two_plus, minus
dw EXIT
msec: dw $ + 2
mov al,06 ; latch counter 0
out 43h,al
in al,40h
mov dl,al
in al,40h
mov dh,al
sub dx,2366 ; (1193.2 - 10 setup)*2/msec
ms1:
mov al,06 ; latch counter 0
out 43h,al
in al,40h
mov cl,al
in al,40h
mov ch,al
sub cx,dx
cmp cx,12 ; uncertainty
ja ms1 ; U>
HEADING 'MS' ; ( n -- )
dw colon
dw zero, two_to_r
ms01:
dw msec, do_loop
dw ms01
dw EXIT
NEXT
; End of the dictionary (lfa) that will be retained (PROTECTED)
GOLDEN_LAST: ; dictionary 'protected' below this definition
addr_end: ; Used for EMPTY after startup
; Initial program entry and start up code
; If startup modified, modify the GEN.4th script
do_startup:
mov ax,cs ; init segments
mov ds,ax
mov es,ax
cli
mov dx,sp ; save original SP
mov cx,ss
mov ss,ax ; init stack
mov sp,stack0
sti
mov [ss_save],cx
mov [sp_save],dx
mov ah,0Fh ; get current display mode from BIOS
int 10h
sub dx,dx
mov dl,ah
mov [max_col],dx
mov dl,al
mov [_mode],dx
mov dl,bh
mov [_page],dx
push ds
mov ax,40h ; BIOS data segment, ah = 0
mov ds,ax
mov si,84h ; rows - 1
lodsb
inc ax
mov [es:max_rows],ax
mov si,17h ; caps lock on (most BIOS)
mov al,[si]
or al,40h
mov [si],al
pop ds
call os_get_api_version
mov ah,al
xor al,al
mov [dver1],ax
mov al,'a' ; get/save current disk
mov [path1],al
xor ax,ax ; set current directory
mov [path2],ax
push es
xor ax,ax ; get current, set new div 0 vector
mov es,ax ; interrupt segment and offset = 0
mov di,ax
mov bx,[es:di]
mov dx,[es:di+2]
mov [d_off],bx
mov [d_seg],dx
mov bx,div_0
mov dx,ds
mov [es:di],bx
mov [es:di+2],dx
pop es
mov bp,first ; R at end of mem - see r_reset
sub ax,ax ; Top of parameter stack (for underflow)
push ax
MOV si, start_forth ; forward reference, may be modified when new GEN.4th
NEXT ; goto FORTH start, begin following pointers
; When generating a new file, VERSION may be FORGOTTEN and new created
; Set address of new start_forth in above script
LAST_HERE: ; Last definition that will be 'remembered' (with a header)
HEADING 'VERSION'
VERSION: dw colon
dw dotq
db vr01 - $ - 1
db 'V1.5.1, 2011/01/15 '
vr01:
dw EXIT
; Break a long, single chain of definitions into separate hash lists
; Generate can save modified dictionary for faster startup
N_HASH: dw colon ; create hash lists
dw PAD, B_HDR, ERASE ; temporary buffer for pointers
dw cell, LAST_HERE, cfa_dup ; set last link field to VERSION
dw LAST, store
nh1: ; BEGIN ( lfa )
dw q_DUP, q_branch, nh05 ; WHILE not start of dictionary
dw cfa_dup, fetch, SWAP
dw zero, OVER, store ; set chain end, just in case
dw cfa_dup, l_to_nfa, bite
db VOC ; ( lfa' lfa nfa v )
dw HASH, SWAP, DROP ; ( lfa' lfa lnk )
dw cfa_dup, HEADS, plus_fetch
dw cfa_not, q_branch, nh2 ; set end of normal chain IF not already
dw two_dup, HEADS, plus, store
nh2: ; THEN
dw two_dup, FENCE, plus_fetch, cfa_not
dw SWAP, cell, GOLDEN_LAST + 1
dw u_less, cfa_and
dw q_branch, nh03 ; set end of GOLDEN chain IF not already
dw two_dup, FENCE, plus, store
nh03: ; THEN
dw PAD, plus, cfa_dup, fetch ; update individual chains
dw q_branch, nh04 ; IF not first, update chain
; ( lfa' lfa padx )
dw two_dup, fetch, store
nh04: ; THEN
dw store ; update pad buffer
dw do_branch, nh1 ; REPEAT
nh05:
dw EXIT
; High level Start-up
; Headerless. Will be FORGOTTEN. GEN.4th must create a replacement
start_forth:
dw CR, CR, dotq
db sf01 - $ - 1
db 'Copyright (C) 2014 MikeOS Developers -- see doc/LICENSE.TXT'
sf01:
dw CR, dotq
db sf02 - $ - 1
db 'FORTH version '
sf02:
dw VERSION
dw CR, dotq
db sf03 - $ - 1
db 'DOS version '
sf03:
dw D_VER, one_plus, c_fetch, zero, st_num
dw add_num, add_num, cell, 46, HOLD, two_drop
dw D_VER, c_fetch, zero, nums, nd_num, cfa_type
dw CR, PATH, dot_az
dw CR, OK, CR
dw N_HASH
dw ABORT ; no print on abort
very_end: dw 0, 0
|
; Z88 Small C+ Run time Library
; Moved functions over to proper libdefs
; To make startup code smaller and neater!
;
; 6/9/98 djm
;
; 13/5/99 djm, inverted carry conditions
SECTION code_crt0_sccz80
PUBLIC l_uge
EXTERN l_compare_result
;
; DE >= HL [unsigned]
; set carry if true
.l_uge
ld a,d
cp h
ccf
jp nz, l_compare_result
ld a,e
cp l
ccf
jp l_compare_result
; call l_ucmp
; ccf
; ret
|
; A292936: a(n) = the least k >= 0 such that floor(n/(2^k)) is a nonprime; a(n) is degree of the "safeness" of prime, 0 if n is not a prime, 1 for unsafe primes (A059456), and k >= 2 for primes that are (k-1)-safe but not k-safe.
; 0,1,1,0,2,0,2,0,0,0,3,0,1,0,0,0,1,0,1,0,0,0,4,0,0,0,0,0,1,0,1,0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,5,0,0,0,0,0,1,0,0,0,0,0,2,0,1,0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,0,0,1,0,0,0,2,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0
mov $2,1
lpb $0
mul $0,2
sub $0,1
dif $0,3
lpe
add $1,6
lpb $0
trn $0,1
seq $0,69268 ; Greatest common divisor of n! and n*(n+1)/2.
sub $0,1
add $1,1
lpe
add $1,1
add $1,$2
sub $1,8
mov $0,$1
|
SECTION code_fp_am9511
PUBLIC cos
EXTERN cam32_sccz80_cos
defc cos = cam32_sccz80_cos
; SDCC bridge for Classic
IF __CLASSIC
PUBLIC _cos
EXTERN cam32_sdcc_dcc_cos
defc _cos = cam32_sdcc_dcc_cos
ENDIF
|
_usertests: file format elf32-i386
Disassembly of section .text:
00000000 <main>:
return randstate;
}
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: 51 push %ecx
e: 83 ec 0c sub $0xc,%esp
printf(1, "usertests starting\n");
11: 68 46 4d 00 00 push $0x4d46
16: 6a 01 push $0x1
18: e8 e3 39 00 00 call 3a00 <printf>
if(open("usertests.ran", 0) >= 0){
1d: 59 pop %ecx
1e: 58 pop %eax
1f: 6a 00 push $0x0
21: 68 5a 4d 00 00 push $0x4d5a
26: e8 b7 38 00 00 call 38e2 <open>
2b: 83 c4 10 add $0x10,%esp
2e: 85 c0 test %eax,%eax
30: 78 13 js 45 <main+0x45>
printf(1, "already ran user tests -- rebuild fs.img\n");
32: 52 push %edx
33: 52 push %edx
34: 68 c4 54 00 00 push $0x54c4
39: 6a 01 push $0x1
3b: e8 c0 39 00 00 call 3a00 <printf>
exit();
40: e8 5d 38 00 00 call 38a2 <exit>
}
close(open("usertests.ran", O_CREATE));
45: 50 push %eax
46: 50 push %eax
47: 68 00 02 00 00 push $0x200
4c: 68 5a 4d 00 00 push $0x4d5a
51: e8 8c 38 00 00 call 38e2 <open>
56: 89 04 24 mov %eax,(%esp)
59: e8 6c 38 00 00 call 38ca <close>
argptest();
5e: e8 5d 35 00 00 call 35c0 <argptest>
createdelete();
63: e8 a8 11 00 00 call 1210 <createdelete>
linkunlink();
68: e8 63 1a 00 00 call 1ad0 <linkunlink>
concreate();
6d: e8 5e 17 00 00 call 17d0 <concreate>
fourfiles();
72: e8 99 0f 00 00 call 1010 <fourfiles>
sharedfd();
77: e8 d4 0d 00 00 call e50 <sharedfd>
bigargtest();
7c: e8 ff 31 00 00 call 3280 <bigargtest>
bigwrite();
81: e8 6a 23 00 00 call 23f0 <bigwrite>
bigargtest();
86: e8 f5 31 00 00 call 3280 <bigargtest>
bsstest();
8b: e8 70 31 00 00 call 3200 <bsstest>
sbrktest();
90: e8 9b 2c 00 00 call 2d30 <sbrktest>
validatetest();
95: e8 b6 30 00 00 call 3150 <validatetest>
opentest();
9a: e8 51 03 00 00 call 3f0 <opentest>
writetest();
9f: e8 dc 03 00 00 call 480 <writetest>
writetest1();
a4: e8 b7 05 00 00 call 660 <writetest1>
createtest();
a9: e8 82 07 00 00 call 830 <createtest>
openiputtest();
ae: e8 3d 02 00 00 call 2f0 <openiputtest>
exitiputtest();
b3: e8 48 01 00 00 call 200 <exitiputtest>
iputtest();
b8: e8 63 00 00 00 call 120 <iputtest>
mem();
bd: e8 be 0c 00 00 call d80 <mem>
pipe1();
c2: e8 49 09 00 00 call a10 <pipe1>
preempt();
c7: e8 e4 0a 00 00 call bb0 <preempt>
exitwait();
cc: e8 1f 0c 00 00 call cf0 <exitwait>
rmdot();
d1: e8 0a 27 00 00 call 27e0 <rmdot>
fourteen();
d6: e8 c5 25 00 00 call 26a0 <fourteen>
bigfile();
db: e8 f0 23 00 00 call 24d0 <bigfile>
subdir();
e0: e8 2b 1c 00 00 call 1d10 <subdir>
linktest();
e5: e8 d6 14 00 00 call 15c0 <linktest>
unlinkread();
ea: e8 41 13 00 00 call 1430 <unlinkread>
dirfile();
ef: e8 6c 28 00 00 call 2960 <dirfile>
iref();
f4: e8 67 2a 00 00 call 2b60 <iref>
forktest();
f9: e8 82 2b 00 00 call 2c80 <forktest>
bigdir(); // slow
fe: e8 dd 1a 00 00 call 1be0 <bigdir>
uio();
103: e8 48 34 00 00 call 3550 <uio>
exectest();
108: e8 b3 08 00 00 call 9c0 <exectest>
exit();
10d: e8 90 37 00 00 call 38a2 <exit>
112: 66 90 xchg %ax,%ax
114: 66 90 xchg %ax,%ax
116: 66 90 xchg %ax,%ax
118: 66 90 xchg %ax,%ax
11a: 66 90 xchg %ax,%ax
11c: 66 90 xchg %ax,%ax
11e: 66 90 xchg %ax,%ax
00000120 <iputtest>:
{
120: 55 push %ebp
121: 89 e5 mov %esp,%ebp
123: 83 ec 10 sub $0x10,%esp
printf(stdout, "iput test\n");
126: 68 ec 3d 00 00 push $0x3dec
12b: ff 35 08 5e 00 00 pushl 0x5e08
131: e8 ca 38 00 00 call 3a00 <printf>
if(mkdir("iputdir") < 0){
136: c7 04 24 7f 3d 00 00 movl $0x3d7f,(%esp)
13d: e8 c8 37 00 00 call 390a <mkdir>
142: 83 c4 10 add $0x10,%esp
145: 85 c0 test %eax,%eax
147: 78 58 js 1a1 <iputtest+0x81>
if(chdir("iputdir") < 0){
149: 83 ec 0c sub $0xc,%esp
14c: 68 7f 3d 00 00 push $0x3d7f
151: e8 bc 37 00 00 call 3912 <chdir>
156: 83 c4 10 add $0x10,%esp
159: 85 c0 test %eax,%eax
15b: 0f 88 85 00 00 00 js 1e6 <iputtest+0xc6>
if(unlink("../iputdir") < 0){
161: 83 ec 0c sub $0xc,%esp
164: 68 7c 3d 00 00 push $0x3d7c
169: e8 84 37 00 00 call 38f2 <unlink>
16e: 83 c4 10 add $0x10,%esp
171: 85 c0 test %eax,%eax
173: 78 5a js 1cf <iputtest+0xaf>
if(chdir("/") < 0){
175: 83 ec 0c sub $0xc,%esp
178: 68 a1 3d 00 00 push $0x3da1
17d: e8 90 37 00 00 call 3912 <chdir>
182: 83 c4 10 add $0x10,%esp
185: 85 c0 test %eax,%eax
187: 78 2f js 1b8 <iputtest+0x98>
printf(stdout, "iput test ok\n");
189: 83 ec 08 sub $0x8,%esp
18c: 68 24 3e 00 00 push $0x3e24
191: ff 35 08 5e 00 00 pushl 0x5e08
197: e8 64 38 00 00 call 3a00 <printf>
}
19c: 83 c4 10 add $0x10,%esp
19f: c9 leave
1a0: c3 ret
printf(stdout, "mkdir failed\n");
1a1: 50 push %eax
1a2: 50 push %eax
1a3: 68 58 3d 00 00 push $0x3d58
1a8: ff 35 08 5e 00 00 pushl 0x5e08
1ae: e8 4d 38 00 00 call 3a00 <printf>
exit();
1b3: e8 ea 36 00 00 call 38a2 <exit>
printf(stdout, "chdir / failed\n");
1b8: 50 push %eax
1b9: 50 push %eax
1ba: 68 a3 3d 00 00 push $0x3da3
1bf: ff 35 08 5e 00 00 pushl 0x5e08
1c5: e8 36 38 00 00 call 3a00 <printf>
exit();
1ca: e8 d3 36 00 00 call 38a2 <exit>
printf(stdout, "unlink ../iputdir failed\n");
1cf: 52 push %edx
1d0: 52 push %edx
1d1: 68 87 3d 00 00 push $0x3d87
1d6: ff 35 08 5e 00 00 pushl 0x5e08
1dc: e8 1f 38 00 00 call 3a00 <printf>
exit();
1e1: e8 bc 36 00 00 call 38a2 <exit>
printf(stdout, "chdir iputdir failed\n");
1e6: 51 push %ecx
1e7: 51 push %ecx
1e8: 68 66 3d 00 00 push $0x3d66
1ed: ff 35 08 5e 00 00 pushl 0x5e08
1f3: e8 08 38 00 00 call 3a00 <printf>
exit();
1f8: e8 a5 36 00 00 call 38a2 <exit>
1fd: 8d 76 00 lea 0x0(%esi),%esi
00000200 <exitiputtest>:
{
200: 55 push %ebp
201: 89 e5 mov %esp,%ebp
203: 83 ec 10 sub $0x10,%esp
printf(stdout, "exitiput test\n");
206: 68 b3 3d 00 00 push $0x3db3
20b: ff 35 08 5e 00 00 pushl 0x5e08
211: e8 ea 37 00 00 call 3a00 <printf>
pid = fork();
216: e8 7f 36 00 00 call 389a <fork>
if(pid < 0){
21b: 83 c4 10 add $0x10,%esp
21e: 85 c0 test %eax,%eax
220: 0f 88 82 00 00 00 js 2a8 <exitiputtest+0xa8>
if(pid == 0){
226: 75 48 jne 270 <exitiputtest+0x70>
if(mkdir("iputdir") < 0){
228: 83 ec 0c sub $0xc,%esp
22b: 68 7f 3d 00 00 push $0x3d7f
230: e8 d5 36 00 00 call 390a <mkdir>
235: 83 c4 10 add $0x10,%esp
238: 85 c0 test %eax,%eax
23a: 0f 88 96 00 00 00 js 2d6 <exitiputtest+0xd6>
if(chdir("iputdir") < 0){
240: 83 ec 0c sub $0xc,%esp
243: 68 7f 3d 00 00 push $0x3d7f
248: e8 c5 36 00 00 call 3912 <chdir>
24d: 83 c4 10 add $0x10,%esp
250: 85 c0 test %eax,%eax
252: 78 6b js 2bf <exitiputtest+0xbf>
if(unlink("../iputdir") < 0){
254: 83 ec 0c sub $0xc,%esp
257: 68 7c 3d 00 00 push $0x3d7c
25c: e8 91 36 00 00 call 38f2 <unlink>
261: 83 c4 10 add $0x10,%esp
264: 85 c0 test %eax,%eax
266: 78 28 js 290 <exitiputtest+0x90>
exit();
268: e8 35 36 00 00 call 38a2 <exit>
26d: 8d 76 00 lea 0x0(%esi),%esi
wait();
270: e8 35 36 00 00 call 38aa <wait>
printf(stdout, "exitiput test ok\n");
275: 83 ec 08 sub $0x8,%esp
278: 68 d6 3d 00 00 push $0x3dd6
27d: ff 35 08 5e 00 00 pushl 0x5e08
283: e8 78 37 00 00 call 3a00 <printf>
}
288: 83 c4 10 add $0x10,%esp
28b: c9 leave
28c: c3 ret
28d: 8d 76 00 lea 0x0(%esi),%esi
printf(stdout, "unlink ../iputdir failed\n");
290: 83 ec 08 sub $0x8,%esp
293: 68 87 3d 00 00 push $0x3d87
298: ff 35 08 5e 00 00 pushl 0x5e08
29e: e8 5d 37 00 00 call 3a00 <printf>
exit();
2a3: e8 fa 35 00 00 call 38a2 <exit>
printf(stdout, "fork failed\n");
2a8: 51 push %ecx
2a9: 51 push %ecx
2aa: 68 99 4c 00 00 push $0x4c99
2af: ff 35 08 5e 00 00 pushl 0x5e08
2b5: e8 46 37 00 00 call 3a00 <printf>
exit();
2ba: e8 e3 35 00 00 call 38a2 <exit>
printf(stdout, "child chdir failed\n");
2bf: 50 push %eax
2c0: 50 push %eax
2c1: 68 c2 3d 00 00 push $0x3dc2
2c6: ff 35 08 5e 00 00 pushl 0x5e08
2cc: e8 2f 37 00 00 call 3a00 <printf>
exit();
2d1: e8 cc 35 00 00 call 38a2 <exit>
printf(stdout, "mkdir failed\n");
2d6: 52 push %edx
2d7: 52 push %edx
2d8: 68 58 3d 00 00 push $0x3d58
2dd: ff 35 08 5e 00 00 pushl 0x5e08
2e3: e8 18 37 00 00 call 3a00 <printf>
exit();
2e8: e8 b5 35 00 00 call 38a2 <exit>
2ed: 8d 76 00 lea 0x0(%esi),%esi
000002f0 <openiputtest>:
{
2f0: 55 push %ebp
2f1: 89 e5 mov %esp,%ebp
2f3: 83 ec 10 sub $0x10,%esp
printf(stdout, "openiput test\n");
2f6: 68 e8 3d 00 00 push $0x3de8
2fb: ff 35 08 5e 00 00 pushl 0x5e08
301: e8 fa 36 00 00 call 3a00 <printf>
if(mkdir("oidir") < 0){
306: c7 04 24 f7 3d 00 00 movl $0x3df7,(%esp)
30d: e8 f8 35 00 00 call 390a <mkdir>
312: 83 c4 10 add $0x10,%esp
315: 85 c0 test %eax,%eax
317: 0f 88 88 00 00 00 js 3a5 <openiputtest+0xb5>
pid = fork();
31d: e8 78 35 00 00 call 389a <fork>
if(pid < 0){
322: 85 c0 test %eax,%eax
324: 0f 88 92 00 00 00 js 3bc <openiputtest+0xcc>
if(pid == 0){
32a: 75 34 jne 360 <openiputtest+0x70>
int fd = open("oidir", O_RDWR);
32c: 83 ec 08 sub $0x8,%esp
32f: 6a 02 push $0x2
331: 68 f7 3d 00 00 push $0x3df7
336: e8 a7 35 00 00 call 38e2 <open>
if(fd >= 0){
33b: 83 c4 10 add $0x10,%esp
33e: 85 c0 test %eax,%eax
340: 78 5e js 3a0 <openiputtest+0xb0>
printf(stdout, "open directory for write succeeded\n");
342: 83 ec 08 sub $0x8,%esp
345: 68 7c 4d 00 00 push $0x4d7c
34a: ff 35 08 5e 00 00 pushl 0x5e08
350: e8 ab 36 00 00 call 3a00 <printf>
exit();
355: e8 48 35 00 00 call 38a2 <exit>
35a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
sleep(1);
360: 83 ec 0c sub $0xc,%esp
363: 6a 01 push $0x1
365: e8 c8 35 00 00 call 3932 <sleep>
if(unlink("oidir") != 0){
36a: c7 04 24 f7 3d 00 00 movl $0x3df7,(%esp)
371: e8 7c 35 00 00 call 38f2 <unlink>
376: 83 c4 10 add $0x10,%esp
379: 85 c0 test %eax,%eax
37b: 75 56 jne 3d3 <openiputtest+0xe3>
wait();
37d: e8 28 35 00 00 call 38aa <wait>
printf(stdout, "openiput test ok\n");
382: 83 ec 08 sub $0x8,%esp
385: 68 20 3e 00 00 push $0x3e20
38a: ff 35 08 5e 00 00 pushl 0x5e08
390: e8 6b 36 00 00 call 3a00 <printf>
395: 83 c4 10 add $0x10,%esp
}
398: c9 leave
399: c3 ret
39a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
exit();
3a0: e8 fd 34 00 00 call 38a2 <exit>
printf(stdout, "mkdir oidir failed\n");
3a5: 51 push %ecx
3a6: 51 push %ecx
3a7: 68 fd 3d 00 00 push $0x3dfd
3ac: ff 35 08 5e 00 00 pushl 0x5e08
3b2: e8 49 36 00 00 call 3a00 <printf>
exit();
3b7: e8 e6 34 00 00 call 38a2 <exit>
printf(stdout, "fork failed\n");
3bc: 52 push %edx
3bd: 52 push %edx
3be: 68 99 4c 00 00 push $0x4c99
3c3: ff 35 08 5e 00 00 pushl 0x5e08
3c9: e8 32 36 00 00 call 3a00 <printf>
exit();
3ce: e8 cf 34 00 00 call 38a2 <exit>
printf(stdout, "unlink failed\n");
3d3: 50 push %eax
3d4: 50 push %eax
3d5: 68 11 3e 00 00 push $0x3e11
3da: ff 35 08 5e 00 00 pushl 0x5e08
3e0: e8 1b 36 00 00 call 3a00 <printf>
exit();
3e5: e8 b8 34 00 00 call 38a2 <exit>
3ea: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
000003f0 <opentest>:
{
3f0: 55 push %ebp
3f1: 89 e5 mov %esp,%ebp
3f3: 83 ec 10 sub $0x10,%esp
printf(stdout, "open test\n");
3f6: 68 32 3e 00 00 push $0x3e32
3fb: ff 35 08 5e 00 00 pushl 0x5e08
401: e8 fa 35 00 00 call 3a00 <printf>
fd = open("echo", 0);
406: 58 pop %eax
407: 5a pop %edx
408: 6a 00 push $0x0
40a: 68 3d 3e 00 00 push $0x3e3d
40f: e8 ce 34 00 00 call 38e2 <open>
if(fd < 0){
414: 83 c4 10 add $0x10,%esp
417: 85 c0 test %eax,%eax
419: 78 36 js 451 <opentest+0x61>
close(fd);
41b: 83 ec 0c sub $0xc,%esp
41e: 50 push %eax
41f: e8 a6 34 00 00 call 38ca <close>
fd = open("doesnotexist", 0);
424: 5a pop %edx
425: 59 pop %ecx
426: 6a 00 push $0x0
428: 68 55 3e 00 00 push $0x3e55
42d: e8 b0 34 00 00 call 38e2 <open>
if(fd >= 0){
432: 83 c4 10 add $0x10,%esp
435: 85 c0 test %eax,%eax
437: 79 2f jns 468 <opentest+0x78>
printf(stdout, "open test ok\n");
439: 83 ec 08 sub $0x8,%esp
43c: 68 80 3e 00 00 push $0x3e80
441: ff 35 08 5e 00 00 pushl 0x5e08
447: e8 b4 35 00 00 call 3a00 <printf>
}
44c: 83 c4 10 add $0x10,%esp
44f: c9 leave
450: c3 ret
printf(stdout, "open echo failed!\n");
451: 50 push %eax
452: 50 push %eax
453: 68 42 3e 00 00 push $0x3e42
458: ff 35 08 5e 00 00 pushl 0x5e08
45e: e8 9d 35 00 00 call 3a00 <printf>
exit();
463: e8 3a 34 00 00 call 38a2 <exit>
printf(stdout, "open doesnotexist succeeded!\n");
468: 50 push %eax
469: 50 push %eax
46a: 68 62 3e 00 00 push $0x3e62
46f: ff 35 08 5e 00 00 pushl 0x5e08
475: e8 86 35 00 00 call 3a00 <printf>
exit();
47a: e8 23 34 00 00 call 38a2 <exit>
47f: 90 nop
00000480 <writetest>:
{
480: 55 push %ebp
481: 89 e5 mov %esp,%ebp
483: 56 push %esi
484: 53 push %ebx
printf(stdout, "small file test\n");
485: 83 ec 08 sub $0x8,%esp
488: 68 8e 3e 00 00 push $0x3e8e
48d: ff 35 08 5e 00 00 pushl 0x5e08
493: e8 68 35 00 00 call 3a00 <printf>
fd = open("small", O_CREATE|O_RDWR);
498: 58 pop %eax
499: 5a pop %edx
49a: 68 02 02 00 00 push $0x202
49f: 68 9f 3e 00 00 push $0x3e9f
4a4: e8 39 34 00 00 call 38e2 <open>
if(fd >= 0){
4a9: 83 c4 10 add $0x10,%esp
4ac: 85 c0 test %eax,%eax
4ae: 0f 88 88 01 00 00 js 63c <writetest+0x1bc>
printf(stdout, "creat small succeeded; ok\n");
4b4: 83 ec 08 sub $0x8,%esp
4b7: 89 c6 mov %eax,%esi
for(i = 0; i < 100; i++){
4b9: 31 db xor %ebx,%ebx
printf(stdout, "creat small succeeded; ok\n");
4bb: 68 a5 3e 00 00 push $0x3ea5
4c0: ff 35 08 5e 00 00 pushl 0x5e08
4c6: e8 35 35 00 00 call 3a00 <printf>
4cb: 83 c4 10 add $0x10,%esp
4ce: 66 90 xchg %ax,%ax
if(write(fd, "aaaaaaaaaa", 10) != 10){
4d0: 83 ec 04 sub $0x4,%esp
4d3: 6a 0a push $0xa
4d5: 68 dc 3e 00 00 push $0x3edc
4da: 56 push %esi
4db: e8 e2 33 00 00 call 38c2 <write>
4e0: 83 c4 10 add $0x10,%esp
4e3: 83 f8 0a cmp $0xa,%eax
4e6: 0f 85 d9 00 00 00 jne 5c5 <writetest+0x145>
if(write(fd, "bbbbbbbbbb", 10) != 10){
4ec: 83 ec 04 sub $0x4,%esp
4ef: 6a 0a push $0xa
4f1: 68 e7 3e 00 00 push $0x3ee7
4f6: 56 push %esi
4f7: e8 c6 33 00 00 call 38c2 <write>
4fc: 83 c4 10 add $0x10,%esp
4ff: 83 f8 0a cmp $0xa,%eax
502: 0f 85 d6 00 00 00 jne 5de <writetest+0x15e>
for(i = 0; i < 100; i++){
508: 83 c3 01 add $0x1,%ebx
50b: 83 fb 64 cmp $0x64,%ebx
50e: 75 c0 jne 4d0 <writetest+0x50>
printf(stdout, "writes ok\n");
510: 83 ec 08 sub $0x8,%esp
513: 68 f2 3e 00 00 push $0x3ef2
518: ff 35 08 5e 00 00 pushl 0x5e08
51e: e8 dd 34 00 00 call 3a00 <printf>
close(fd);
523: 89 34 24 mov %esi,(%esp)
526: e8 9f 33 00 00 call 38ca <close>
fd = open("small", O_RDONLY);
52b: 5b pop %ebx
52c: 5e pop %esi
52d: 6a 00 push $0x0
52f: 68 9f 3e 00 00 push $0x3e9f
534: e8 a9 33 00 00 call 38e2 <open>
if(fd >= 0){
539: 83 c4 10 add $0x10,%esp
53c: 85 c0 test %eax,%eax
fd = open("small", O_RDONLY);
53e: 89 c3 mov %eax,%ebx
if(fd >= 0){
540: 0f 88 b1 00 00 00 js 5f7 <writetest+0x177>
printf(stdout, "open small succeeded ok\n");
546: 83 ec 08 sub $0x8,%esp
549: 68 fd 3e 00 00 push $0x3efd
54e: ff 35 08 5e 00 00 pushl 0x5e08
554: e8 a7 34 00 00 call 3a00 <printf>
i = read(fd, buf, 2000);
559: 83 c4 0c add $0xc,%esp
55c: 68 d0 07 00 00 push $0x7d0
561: 68 40 86 00 00 push $0x8640
566: 53 push %ebx
567: e8 4e 33 00 00 call 38ba <read>
if(i == 2000){
56c: 83 c4 10 add $0x10,%esp
56f: 3d d0 07 00 00 cmp $0x7d0,%eax
574: 0f 85 94 00 00 00 jne 60e <writetest+0x18e>
printf(stdout, "read succeeded ok\n");
57a: 83 ec 08 sub $0x8,%esp
57d: 68 31 3f 00 00 push $0x3f31
582: ff 35 08 5e 00 00 pushl 0x5e08
588: e8 73 34 00 00 call 3a00 <printf>
close(fd);
58d: 89 1c 24 mov %ebx,(%esp)
590: e8 35 33 00 00 call 38ca <close>
if(unlink("small") < 0){
595: c7 04 24 9f 3e 00 00 movl $0x3e9f,(%esp)
59c: e8 51 33 00 00 call 38f2 <unlink>
5a1: 83 c4 10 add $0x10,%esp
5a4: 85 c0 test %eax,%eax
5a6: 78 7d js 625 <writetest+0x1a5>
printf(stdout, "small file test ok\n");
5a8: 83 ec 08 sub $0x8,%esp
5ab: 68 59 3f 00 00 push $0x3f59
5b0: ff 35 08 5e 00 00 pushl 0x5e08
5b6: e8 45 34 00 00 call 3a00 <printf>
}
5bb: 83 c4 10 add $0x10,%esp
5be: 8d 65 f8 lea -0x8(%ebp),%esp
5c1: 5b pop %ebx
5c2: 5e pop %esi
5c3: 5d pop %ebp
5c4: c3 ret
printf(stdout, "error: write aa %d new file failed\n", i);
5c5: 83 ec 04 sub $0x4,%esp
5c8: 53 push %ebx
5c9: 68 a0 4d 00 00 push $0x4da0
5ce: ff 35 08 5e 00 00 pushl 0x5e08
5d4: e8 27 34 00 00 call 3a00 <printf>
exit();
5d9: e8 c4 32 00 00 call 38a2 <exit>
printf(stdout, "error: write bb %d new file failed\n", i);
5de: 83 ec 04 sub $0x4,%esp
5e1: 53 push %ebx
5e2: 68 c4 4d 00 00 push $0x4dc4
5e7: ff 35 08 5e 00 00 pushl 0x5e08
5ed: e8 0e 34 00 00 call 3a00 <printf>
exit();
5f2: e8 ab 32 00 00 call 38a2 <exit>
printf(stdout, "error: open small failed!\n");
5f7: 51 push %ecx
5f8: 51 push %ecx
5f9: 68 16 3f 00 00 push $0x3f16
5fe: ff 35 08 5e 00 00 pushl 0x5e08
604: e8 f7 33 00 00 call 3a00 <printf>
exit();
609: e8 94 32 00 00 call 38a2 <exit>
printf(stdout, "read failed\n");
60e: 52 push %edx
60f: 52 push %edx
610: 68 5d 42 00 00 push $0x425d
615: ff 35 08 5e 00 00 pushl 0x5e08
61b: e8 e0 33 00 00 call 3a00 <printf>
exit();
620: e8 7d 32 00 00 call 38a2 <exit>
printf(stdout, "unlink small failed\n");
625: 50 push %eax
626: 50 push %eax
627: 68 44 3f 00 00 push $0x3f44
62c: ff 35 08 5e 00 00 pushl 0x5e08
632: e8 c9 33 00 00 call 3a00 <printf>
exit();
637: e8 66 32 00 00 call 38a2 <exit>
printf(stdout, "error: creat small failed!\n");
63c: 50 push %eax
63d: 50 push %eax
63e: 68 c0 3e 00 00 push $0x3ec0
643: ff 35 08 5e 00 00 pushl 0x5e08
649: e8 b2 33 00 00 call 3a00 <printf>
exit();
64e: e8 4f 32 00 00 call 38a2 <exit>
653: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
659: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
00000660 <writetest1>:
{
660: 55 push %ebp
661: 89 e5 mov %esp,%ebp
663: 56 push %esi
664: 53 push %ebx
printf(stdout, "big files test\n");
665: 83 ec 08 sub $0x8,%esp
668: 68 6d 3f 00 00 push $0x3f6d
66d: ff 35 08 5e 00 00 pushl 0x5e08
673: e8 88 33 00 00 call 3a00 <printf>
fd = open("big", O_CREATE|O_RDWR);
678: 58 pop %eax
679: 5a pop %edx
67a: 68 02 02 00 00 push $0x202
67f: 68 e7 3f 00 00 push $0x3fe7
684: e8 59 32 00 00 call 38e2 <open>
if(fd < 0){
689: 83 c4 10 add $0x10,%esp
68c: 85 c0 test %eax,%eax
68e: 0f 88 61 01 00 00 js 7f5 <writetest1+0x195>
694: 89 c6 mov %eax,%esi
for(i = 0; i < MAXFILE; i++){
696: 31 db xor %ebx,%ebx
698: 90 nop
699: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
if(write(fd, buf, 512) != 512){
6a0: 83 ec 04 sub $0x4,%esp
((int*)buf)[0] = i;
6a3: 89 1d 40 86 00 00 mov %ebx,0x8640
if(write(fd, buf, 512) != 512){
6a9: 68 00 02 00 00 push $0x200
6ae: 68 40 86 00 00 push $0x8640
6b3: 56 push %esi
6b4: e8 09 32 00 00 call 38c2 <write>
6b9: 83 c4 10 add $0x10,%esp
6bc: 3d 00 02 00 00 cmp $0x200,%eax
6c1: 0f 85 b3 00 00 00 jne 77a <writetest1+0x11a>
for(i = 0; i < MAXFILE; i++){
6c7: 83 c3 01 add $0x1,%ebx
6ca: 81 fb 8c 00 00 00 cmp $0x8c,%ebx
6d0: 75 ce jne 6a0 <writetest1+0x40>
close(fd);
6d2: 83 ec 0c sub $0xc,%esp
6d5: 56 push %esi
6d6: e8 ef 31 00 00 call 38ca <close>
fd = open("big", O_RDONLY);
6db: 5b pop %ebx
6dc: 5e pop %esi
6dd: 6a 00 push $0x0
6df: 68 e7 3f 00 00 push $0x3fe7
6e4: e8 f9 31 00 00 call 38e2 <open>
if(fd < 0){
6e9: 83 c4 10 add $0x10,%esp
6ec: 85 c0 test %eax,%eax
fd = open("big", O_RDONLY);
6ee: 89 c6 mov %eax,%esi
if(fd < 0){
6f0: 0f 88 e8 00 00 00 js 7de <writetest1+0x17e>
n = 0;
6f6: 31 db xor %ebx,%ebx
6f8: eb 1d jmp 717 <writetest1+0xb7>
6fa: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
} else if(i != 512){
700: 3d 00 02 00 00 cmp $0x200,%eax
705: 0f 85 9f 00 00 00 jne 7aa <writetest1+0x14a>
if(((int*)buf)[0] != n){
70b: a1 40 86 00 00 mov 0x8640,%eax
710: 39 d8 cmp %ebx,%eax
712: 75 7f jne 793 <writetest1+0x133>
n++;
714: 83 c3 01 add $0x1,%ebx
i = read(fd, buf, 512);
717: 83 ec 04 sub $0x4,%esp
71a: 68 00 02 00 00 push $0x200
71f: 68 40 86 00 00 push $0x8640
724: 56 push %esi
725: e8 90 31 00 00 call 38ba <read>
if(i == 0){
72a: 83 c4 10 add $0x10,%esp
72d: 85 c0 test %eax,%eax
72f: 75 cf jne 700 <writetest1+0xa0>
if(n == MAXFILE - 1){
731: 81 fb 8b 00 00 00 cmp $0x8b,%ebx
737: 0f 84 86 00 00 00 je 7c3 <writetest1+0x163>
close(fd);
73d: 83 ec 0c sub $0xc,%esp
740: 56 push %esi
741: e8 84 31 00 00 call 38ca <close>
if(unlink("big") < 0){
746: c7 04 24 e7 3f 00 00 movl $0x3fe7,(%esp)
74d: e8 a0 31 00 00 call 38f2 <unlink>
752: 83 c4 10 add $0x10,%esp
755: 85 c0 test %eax,%eax
757: 0f 88 af 00 00 00 js 80c <writetest1+0x1ac>
printf(stdout, "big files ok\n");
75d: 83 ec 08 sub $0x8,%esp
760: 68 0e 40 00 00 push $0x400e
765: ff 35 08 5e 00 00 pushl 0x5e08
76b: e8 90 32 00 00 call 3a00 <printf>
}
770: 83 c4 10 add $0x10,%esp
773: 8d 65 f8 lea -0x8(%ebp),%esp
776: 5b pop %ebx
777: 5e pop %esi
778: 5d pop %ebp
779: c3 ret
printf(stdout, "error: write big file failed\n", i);
77a: 83 ec 04 sub $0x4,%esp
77d: 53 push %ebx
77e: 68 97 3f 00 00 push $0x3f97
783: ff 35 08 5e 00 00 pushl 0x5e08
789: e8 72 32 00 00 call 3a00 <printf>
exit();
78e: e8 0f 31 00 00 call 38a2 <exit>
printf(stdout, "read content of block %d is %d\n",
793: 50 push %eax
794: 53 push %ebx
795: 68 e8 4d 00 00 push $0x4de8
79a: ff 35 08 5e 00 00 pushl 0x5e08
7a0: e8 5b 32 00 00 call 3a00 <printf>
exit();
7a5: e8 f8 30 00 00 call 38a2 <exit>
printf(stdout, "read failed %d\n", i);
7aa: 83 ec 04 sub $0x4,%esp
7ad: 50 push %eax
7ae: 68 eb 3f 00 00 push $0x3feb
7b3: ff 35 08 5e 00 00 pushl 0x5e08
7b9: e8 42 32 00 00 call 3a00 <printf>
exit();
7be: e8 df 30 00 00 call 38a2 <exit>
printf(stdout, "read only %d blocks from big", n);
7c3: 52 push %edx
7c4: 68 8b 00 00 00 push $0x8b
7c9: 68 ce 3f 00 00 push $0x3fce
7ce: ff 35 08 5e 00 00 pushl 0x5e08
7d4: e8 27 32 00 00 call 3a00 <printf>
exit();
7d9: e8 c4 30 00 00 call 38a2 <exit>
printf(stdout, "error: open big failed!\n");
7de: 51 push %ecx
7df: 51 push %ecx
7e0: 68 b5 3f 00 00 push $0x3fb5
7e5: ff 35 08 5e 00 00 pushl 0x5e08
7eb: e8 10 32 00 00 call 3a00 <printf>
exit();
7f0: e8 ad 30 00 00 call 38a2 <exit>
printf(stdout, "error: creat big failed!\n");
7f5: 50 push %eax
7f6: 50 push %eax
7f7: 68 7d 3f 00 00 push $0x3f7d
7fc: ff 35 08 5e 00 00 pushl 0x5e08
802: e8 f9 31 00 00 call 3a00 <printf>
exit();
807: e8 96 30 00 00 call 38a2 <exit>
printf(stdout, "unlink big failed\n");
80c: 50 push %eax
80d: 50 push %eax
80e: 68 fb 3f 00 00 push $0x3ffb
813: ff 35 08 5e 00 00 pushl 0x5e08
819: e8 e2 31 00 00 call 3a00 <printf>
exit();
81e: e8 7f 30 00 00 call 38a2 <exit>
823: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
829: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
00000830 <createtest>:
{
830: 55 push %ebp
831: 89 e5 mov %esp,%ebp
833: 53 push %ebx
name[2] = '\0';
834: bb 30 00 00 00 mov $0x30,%ebx
{
839: 83 ec 0c sub $0xc,%esp
printf(stdout, "many creates, followed by unlink test\n");
83c: 68 08 4e 00 00 push $0x4e08
841: ff 35 08 5e 00 00 pushl 0x5e08
847: e8 b4 31 00 00 call 3a00 <printf>
name[0] = 'a';
84c: c6 05 40 a6 00 00 61 movb $0x61,0xa640
name[2] = '\0';
853: c6 05 42 a6 00 00 00 movb $0x0,0xa642
85a: 83 c4 10 add $0x10,%esp
85d: 8d 76 00 lea 0x0(%esi),%esi
fd = open(name, O_CREATE|O_RDWR);
860: 83 ec 08 sub $0x8,%esp
name[1] = '0' + i;
863: 88 1d 41 a6 00 00 mov %bl,0xa641
869: 83 c3 01 add $0x1,%ebx
fd = open(name, O_CREATE|O_RDWR);
86c: 68 02 02 00 00 push $0x202
871: 68 40 a6 00 00 push $0xa640
876: e8 67 30 00 00 call 38e2 <open>
close(fd);
87b: 89 04 24 mov %eax,(%esp)
87e: e8 47 30 00 00 call 38ca <close>
for(i = 0; i < 52; i++){
883: 83 c4 10 add $0x10,%esp
886: 80 fb 64 cmp $0x64,%bl
889: 75 d5 jne 860 <createtest+0x30>
name[0] = 'a';
88b: c6 05 40 a6 00 00 61 movb $0x61,0xa640
name[2] = '\0';
892: c6 05 42 a6 00 00 00 movb $0x0,0xa642
899: bb 30 00 00 00 mov $0x30,%ebx
89e: 66 90 xchg %ax,%ax
unlink(name);
8a0: 83 ec 0c sub $0xc,%esp
name[1] = '0' + i;
8a3: 88 1d 41 a6 00 00 mov %bl,0xa641
8a9: 83 c3 01 add $0x1,%ebx
unlink(name);
8ac: 68 40 a6 00 00 push $0xa640
8b1: e8 3c 30 00 00 call 38f2 <unlink>
for(i = 0; i < 52; i++){
8b6: 83 c4 10 add $0x10,%esp
8b9: 80 fb 64 cmp $0x64,%bl
8bc: 75 e2 jne 8a0 <createtest+0x70>
printf(stdout, "many creates, followed by unlink; ok\n");
8be: 83 ec 08 sub $0x8,%esp
8c1: 68 30 4e 00 00 push $0x4e30
8c6: ff 35 08 5e 00 00 pushl 0x5e08
8cc: e8 2f 31 00 00 call 3a00 <printf>
}
8d1: 83 c4 10 add $0x10,%esp
8d4: 8b 5d fc mov -0x4(%ebp),%ebx
8d7: c9 leave
8d8: c3 ret
8d9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
000008e0 <dirtest>:
{
8e0: 55 push %ebp
8e1: 89 e5 mov %esp,%ebp
8e3: 83 ec 10 sub $0x10,%esp
printf(stdout, "mkdir test\n");
8e6: 68 1c 40 00 00 push $0x401c
8eb: ff 35 08 5e 00 00 pushl 0x5e08
8f1: e8 0a 31 00 00 call 3a00 <printf>
if(mkdir("dir0") < 0){
8f6: c7 04 24 28 40 00 00 movl $0x4028,(%esp)
8fd: e8 08 30 00 00 call 390a <mkdir>
902: 83 c4 10 add $0x10,%esp
905: 85 c0 test %eax,%eax
907: 78 58 js 961 <dirtest+0x81>
if(chdir("dir0") < 0){
909: 83 ec 0c sub $0xc,%esp
90c: 68 28 40 00 00 push $0x4028
911: e8 fc 2f 00 00 call 3912 <chdir>
916: 83 c4 10 add $0x10,%esp
919: 85 c0 test %eax,%eax
91b: 0f 88 85 00 00 00 js 9a6 <dirtest+0xc6>
if(chdir("..") < 0){
921: 83 ec 0c sub $0xc,%esp
924: 68 cd 45 00 00 push $0x45cd
929: e8 e4 2f 00 00 call 3912 <chdir>
92e: 83 c4 10 add $0x10,%esp
931: 85 c0 test %eax,%eax
933: 78 5a js 98f <dirtest+0xaf>
if(unlink("dir0") < 0){
935: 83 ec 0c sub $0xc,%esp
938: 68 28 40 00 00 push $0x4028
93d: e8 b0 2f 00 00 call 38f2 <unlink>
942: 83 c4 10 add $0x10,%esp
945: 85 c0 test %eax,%eax
947: 78 2f js 978 <dirtest+0x98>
printf(stdout, "mkdir test ok\n");
949: 83 ec 08 sub $0x8,%esp
94c: 68 65 40 00 00 push $0x4065
951: ff 35 08 5e 00 00 pushl 0x5e08
957: e8 a4 30 00 00 call 3a00 <printf>
}
95c: 83 c4 10 add $0x10,%esp
95f: c9 leave
960: c3 ret
printf(stdout, "mkdir failed\n");
961: 50 push %eax
962: 50 push %eax
963: 68 58 3d 00 00 push $0x3d58
968: ff 35 08 5e 00 00 pushl 0x5e08
96e: e8 8d 30 00 00 call 3a00 <printf>
exit();
973: e8 2a 2f 00 00 call 38a2 <exit>
printf(stdout, "unlink dir0 failed\n");
978: 50 push %eax
979: 50 push %eax
97a: 68 51 40 00 00 push $0x4051
97f: ff 35 08 5e 00 00 pushl 0x5e08
985: e8 76 30 00 00 call 3a00 <printf>
exit();
98a: e8 13 2f 00 00 call 38a2 <exit>
printf(stdout, "chdir .. failed\n");
98f: 52 push %edx
990: 52 push %edx
991: 68 40 40 00 00 push $0x4040
996: ff 35 08 5e 00 00 pushl 0x5e08
99c: e8 5f 30 00 00 call 3a00 <printf>
exit();
9a1: e8 fc 2e 00 00 call 38a2 <exit>
printf(stdout, "chdir dir0 failed\n");
9a6: 51 push %ecx
9a7: 51 push %ecx
9a8: 68 2d 40 00 00 push $0x402d
9ad: ff 35 08 5e 00 00 pushl 0x5e08
9b3: e8 48 30 00 00 call 3a00 <printf>
exit();
9b8: e8 e5 2e 00 00 call 38a2 <exit>
9bd: 8d 76 00 lea 0x0(%esi),%esi
000009c0 <exectest>:
{
9c0: 55 push %ebp
9c1: 89 e5 mov %esp,%ebp
9c3: 83 ec 10 sub $0x10,%esp
printf(stdout, "exec test\n");
9c6: 68 74 40 00 00 push $0x4074
9cb: ff 35 08 5e 00 00 pushl 0x5e08
9d1: e8 2a 30 00 00 call 3a00 <printf>
if(exec("echo", echoargv) < 0){
9d6: 5a pop %edx
9d7: 59 pop %ecx
9d8: 68 0c 5e 00 00 push $0x5e0c
9dd: 68 3d 3e 00 00 push $0x3e3d
9e2: e8 f3 2e 00 00 call 38da <exec>
9e7: 83 c4 10 add $0x10,%esp
9ea: 85 c0 test %eax,%eax
9ec: 78 02 js 9f0 <exectest+0x30>
}
9ee: c9 leave
9ef: c3 ret
printf(stdout, "exec echo failed\n");
9f0: 50 push %eax
9f1: 50 push %eax
9f2: 68 7f 40 00 00 push $0x407f
9f7: ff 35 08 5e 00 00 pushl 0x5e08
9fd: e8 fe 2f 00 00 call 3a00 <printf>
exit();
a02: e8 9b 2e 00 00 call 38a2 <exit>
a07: 89 f6 mov %esi,%esi
a09: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
00000a10 <pipe1>:
{
a10: 55 push %ebp
a11: 89 e5 mov %esp,%ebp
a13: 57 push %edi
a14: 56 push %esi
a15: 53 push %ebx
if(pipe(fds) != 0){
a16: 8d 45 e0 lea -0x20(%ebp),%eax
{
a19: 83 ec 38 sub $0x38,%esp
if(pipe(fds) != 0){
a1c: 50 push %eax
a1d: e8 90 2e 00 00 call 38b2 <pipe>
a22: 83 c4 10 add $0x10,%esp
a25: 85 c0 test %eax,%eax
a27: 0f 85 3e 01 00 00 jne b6b <pipe1+0x15b>
a2d: 89 c3 mov %eax,%ebx
pid = fork();
a2f: e8 66 2e 00 00 call 389a <fork>
if(pid == 0){
a34: 83 f8 00 cmp $0x0,%eax
a37: 0f 84 84 00 00 00 je ac1 <pipe1+0xb1>
} else if(pid > 0){
a3d: 0f 8e 3b 01 00 00 jle b7e <pipe1+0x16e>
close(fds[1]);
a43: 83 ec 0c sub $0xc,%esp
a46: ff 75 e4 pushl -0x1c(%ebp)
cc = 1;
a49: bf 01 00 00 00 mov $0x1,%edi
close(fds[1]);
a4e: e8 77 2e 00 00 call 38ca <close>
while((n = read(fds[0], buf, cc)) > 0){
a53: 83 c4 10 add $0x10,%esp
total = 0;
a56: c7 45 d4 00 00 00 00 movl $0x0,-0x2c(%ebp)
while((n = read(fds[0], buf, cc)) > 0){
a5d: 83 ec 04 sub $0x4,%esp
a60: 57 push %edi
a61: 68 40 86 00 00 push $0x8640
a66: ff 75 e0 pushl -0x20(%ebp)
a69: e8 4c 2e 00 00 call 38ba <read>
a6e: 83 c4 10 add $0x10,%esp
a71: 85 c0 test %eax,%eax
a73: 0f 8e ab 00 00 00 jle b24 <pipe1+0x114>
if((buf[i] & 0xff) != (seq++ & 0xff)){
a79: 89 d9 mov %ebx,%ecx
a7b: 8d 34 18 lea (%eax,%ebx,1),%esi
a7e: f7 d9 neg %ecx
a80: 38 9c 0b 40 86 00 00 cmp %bl,0x8640(%ebx,%ecx,1)
a87: 8d 53 01 lea 0x1(%ebx),%edx
a8a: 75 1b jne aa7 <pipe1+0x97>
for(i = 0; i < n; i++){
a8c: 39 f2 cmp %esi,%edx
a8e: 89 d3 mov %edx,%ebx
a90: 75 ee jne a80 <pipe1+0x70>
cc = cc * 2;
a92: 01 ff add %edi,%edi
total += n;
a94: 01 45 d4 add %eax,-0x2c(%ebp)
a97: b8 00 20 00 00 mov $0x2000,%eax
a9c: 81 ff 00 20 00 00 cmp $0x2000,%edi
aa2: 0f 4f f8 cmovg %eax,%edi
aa5: eb b6 jmp a5d <pipe1+0x4d>
printf(1, "pipe1 oops 2\n");
aa7: 83 ec 08 sub $0x8,%esp
aaa: 68 ae 40 00 00 push $0x40ae
aaf: 6a 01 push $0x1
ab1: e8 4a 2f 00 00 call 3a00 <printf>
return;
ab6: 83 c4 10 add $0x10,%esp
}
ab9: 8d 65 f4 lea -0xc(%ebp),%esp
abc: 5b pop %ebx
abd: 5e pop %esi
abe: 5f pop %edi
abf: 5d pop %ebp
ac0: c3 ret
close(fds[0]);
ac1: 83 ec 0c sub $0xc,%esp
ac4: ff 75 e0 pushl -0x20(%ebp)
ac7: 31 db xor %ebx,%ebx
ac9: be 09 04 00 00 mov $0x409,%esi
ace: e8 f7 2d 00 00 call 38ca <close>
ad3: 83 c4 10 add $0x10,%esp
ad6: 89 d8 mov %ebx,%eax
ad8: 89 f2 mov %esi,%edx
ada: f7 d8 neg %eax
adc: 29 da sub %ebx,%edx
ade: 66 90 xchg %ax,%ax
buf[i] = seq++;
ae0: 88 84 03 40 86 00 00 mov %al,0x8640(%ebx,%eax,1)
ae7: 83 c0 01 add $0x1,%eax
for(i = 0; i < 1033; i++)
aea: 39 d0 cmp %edx,%eax
aec: 75 f2 jne ae0 <pipe1+0xd0>
if(write(fds[1], buf, 1033) != 1033){
aee: 83 ec 04 sub $0x4,%esp
af1: 68 09 04 00 00 push $0x409
af6: 68 40 86 00 00 push $0x8640
afb: ff 75 e4 pushl -0x1c(%ebp)
afe: e8 bf 2d 00 00 call 38c2 <write>
b03: 83 c4 10 add $0x10,%esp
b06: 3d 09 04 00 00 cmp $0x409,%eax
b0b: 0f 85 80 00 00 00 jne b91 <pipe1+0x181>
b11: 81 eb 09 04 00 00 sub $0x409,%ebx
for(n = 0; n < 5; n++){
b17: 81 fb d3 eb ff ff cmp $0xffffebd3,%ebx
b1d: 75 b7 jne ad6 <pipe1+0xc6>
exit();
b1f: e8 7e 2d 00 00 call 38a2 <exit>
if(total != 5 * 1033){
b24: 81 7d d4 2d 14 00 00 cmpl $0x142d,-0x2c(%ebp)
b2b: 75 29 jne b56 <pipe1+0x146>
close(fds[0]);
b2d: 83 ec 0c sub $0xc,%esp
b30: ff 75 e0 pushl -0x20(%ebp)
b33: e8 92 2d 00 00 call 38ca <close>
wait();
b38: e8 6d 2d 00 00 call 38aa <wait>
printf(1, "pipe1 ok\n");
b3d: 5a pop %edx
b3e: 59 pop %ecx
b3f: 68 d3 40 00 00 push $0x40d3
b44: 6a 01 push $0x1
b46: e8 b5 2e 00 00 call 3a00 <printf>
b4b: 83 c4 10 add $0x10,%esp
}
b4e: 8d 65 f4 lea -0xc(%ebp),%esp
b51: 5b pop %ebx
b52: 5e pop %esi
b53: 5f pop %edi
b54: 5d pop %ebp
b55: c3 ret
printf(1, "pipe1 oops 3 total %d\n", total);
b56: 53 push %ebx
b57: ff 75 d4 pushl -0x2c(%ebp)
b5a: 68 bc 40 00 00 push $0x40bc
b5f: 6a 01 push $0x1
b61: e8 9a 2e 00 00 call 3a00 <printf>
exit();
b66: e8 37 2d 00 00 call 38a2 <exit>
printf(1, "pipe() failed\n");
b6b: 57 push %edi
b6c: 57 push %edi
b6d: 68 91 40 00 00 push $0x4091
b72: 6a 01 push $0x1
b74: e8 87 2e 00 00 call 3a00 <printf>
exit();
b79: e8 24 2d 00 00 call 38a2 <exit>
printf(1, "fork() failed\n");
b7e: 50 push %eax
b7f: 50 push %eax
b80: 68 dd 40 00 00 push $0x40dd
b85: 6a 01 push $0x1
b87: e8 74 2e 00 00 call 3a00 <printf>
exit();
b8c: e8 11 2d 00 00 call 38a2 <exit>
printf(1, "pipe1 oops 1\n");
b91: 56 push %esi
b92: 56 push %esi
b93: 68 a0 40 00 00 push $0x40a0
b98: 6a 01 push $0x1
b9a: e8 61 2e 00 00 call 3a00 <printf>
exit();
b9f: e8 fe 2c 00 00 call 38a2 <exit>
ba4: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
baa: 8d bf 00 00 00 00 lea 0x0(%edi),%edi
00000bb0 <preempt>:
{
bb0: 55 push %ebp
bb1: 89 e5 mov %esp,%ebp
bb3: 57 push %edi
bb4: 56 push %esi
bb5: 53 push %ebx
bb6: 83 ec 24 sub $0x24,%esp
printf(1, "preempt: ");
bb9: 68 ec 40 00 00 push $0x40ec
bbe: 6a 01 push $0x1
bc0: e8 3b 2e 00 00 call 3a00 <printf>
pid1 = fork();
bc5: e8 d0 2c 00 00 call 389a <fork>
if(pid1 == 0)
bca: 83 c4 10 add $0x10,%esp
bcd: 85 c0 test %eax,%eax
bcf: 75 02 jne bd3 <preempt+0x23>
bd1: eb fe jmp bd1 <preempt+0x21>
bd3: 89 c7 mov %eax,%edi
pid2 = fork();
bd5: e8 c0 2c 00 00 call 389a <fork>
if(pid2 == 0)
bda: 85 c0 test %eax,%eax
pid2 = fork();
bdc: 89 c6 mov %eax,%esi
if(pid2 == 0)
bde: 75 02 jne be2 <preempt+0x32>
be0: eb fe jmp be0 <preempt+0x30>
pipe(pfds);
be2: 8d 45 e0 lea -0x20(%ebp),%eax
be5: 83 ec 0c sub $0xc,%esp
be8: 50 push %eax
be9: e8 c4 2c 00 00 call 38b2 <pipe>
pid3 = fork();
bee: e8 a7 2c 00 00 call 389a <fork>
if(pid3 == 0){
bf3: 83 c4 10 add $0x10,%esp
bf6: 85 c0 test %eax,%eax
pid3 = fork();
bf8: 89 c3 mov %eax,%ebx
if(pid3 == 0){
bfa: 75 46 jne c42 <preempt+0x92>
close(pfds[0]);
bfc: 83 ec 0c sub $0xc,%esp
bff: ff 75 e0 pushl -0x20(%ebp)
c02: e8 c3 2c 00 00 call 38ca <close>
if(write(pfds[1], "x", 1) != 1)
c07: 83 c4 0c add $0xc,%esp
c0a: 6a 01 push $0x1
c0c: 68 b1 46 00 00 push $0x46b1
c11: ff 75 e4 pushl -0x1c(%ebp)
c14: e8 a9 2c 00 00 call 38c2 <write>
c19: 83 c4 10 add $0x10,%esp
c1c: 83 e8 01 sub $0x1,%eax
c1f: 74 11 je c32 <preempt+0x82>
printf(1, "preempt write error");
c21: 50 push %eax
c22: 50 push %eax
c23: 68 f6 40 00 00 push $0x40f6
c28: 6a 01 push $0x1
c2a: e8 d1 2d 00 00 call 3a00 <printf>
c2f: 83 c4 10 add $0x10,%esp
close(pfds[1]);
c32: 83 ec 0c sub $0xc,%esp
c35: ff 75 e4 pushl -0x1c(%ebp)
c38: e8 8d 2c 00 00 call 38ca <close>
c3d: 83 c4 10 add $0x10,%esp
c40: eb fe jmp c40 <preempt+0x90>
close(pfds[1]);
c42: 83 ec 0c sub $0xc,%esp
c45: ff 75 e4 pushl -0x1c(%ebp)
c48: e8 7d 2c 00 00 call 38ca <close>
if(read(pfds[0], buf, sizeof(buf)) != 1){
c4d: 83 c4 0c add $0xc,%esp
c50: 68 00 20 00 00 push $0x2000
c55: 68 40 86 00 00 push $0x8640
c5a: ff 75 e0 pushl -0x20(%ebp)
c5d: e8 58 2c 00 00 call 38ba <read>
c62: 83 c4 10 add $0x10,%esp
c65: 83 e8 01 sub $0x1,%eax
c68: 74 19 je c83 <preempt+0xd3>
printf(1, "preempt read error");
c6a: 50 push %eax
c6b: 50 push %eax
c6c: 68 0a 41 00 00 push $0x410a
c71: 6a 01 push $0x1
c73: e8 88 2d 00 00 call 3a00 <printf>
return;
c78: 83 c4 10 add $0x10,%esp
}
c7b: 8d 65 f4 lea -0xc(%ebp),%esp
c7e: 5b pop %ebx
c7f: 5e pop %esi
c80: 5f pop %edi
c81: 5d pop %ebp
c82: c3 ret
close(pfds[0]);
c83: 83 ec 0c sub $0xc,%esp
c86: ff 75 e0 pushl -0x20(%ebp)
c89: e8 3c 2c 00 00 call 38ca <close>
printf(1, "kill... ");
c8e: 58 pop %eax
c8f: 5a pop %edx
c90: 68 1d 41 00 00 push $0x411d
c95: 6a 01 push $0x1
c97: e8 64 2d 00 00 call 3a00 <printf>
kill(pid1);
c9c: 89 3c 24 mov %edi,(%esp)
c9f: e8 2e 2c 00 00 call 38d2 <kill>
kill(pid2);
ca4: 89 34 24 mov %esi,(%esp)
ca7: e8 26 2c 00 00 call 38d2 <kill>
kill(pid3);
cac: 89 1c 24 mov %ebx,(%esp)
caf: e8 1e 2c 00 00 call 38d2 <kill>
printf(1, "wait... ");
cb4: 59 pop %ecx
cb5: 5b pop %ebx
cb6: 68 26 41 00 00 push $0x4126
cbb: 6a 01 push $0x1
cbd: e8 3e 2d 00 00 call 3a00 <printf>
wait();
cc2: e8 e3 2b 00 00 call 38aa <wait>
wait();
cc7: e8 de 2b 00 00 call 38aa <wait>
wait();
ccc: e8 d9 2b 00 00 call 38aa <wait>
printf(1, "preempt ok\n");
cd1: 5e pop %esi
cd2: 5f pop %edi
cd3: 68 2f 41 00 00 push $0x412f
cd8: 6a 01 push $0x1
cda: e8 21 2d 00 00 call 3a00 <printf>
cdf: 83 c4 10 add $0x10,%esp
ce2: eb 97 jmp c7b <preempt+0xcb>
ce4: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
cea: 8d bf 00 00 00 00 lea 0x0(%edi),%edi
00000cf0 <exitwait>:
{
cf0: 55 push %ebp
cf1: 89 e5 mov %esp,%ebp
cf3: 56 push %esi
cf4: be 64 00 00 00 mov $0x64,%esi
cf9: 53 push %ebx
cfa: eb 14 jmp d10 <exitwait+0x20>
cfc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
if(pid){
d00: 74 6f je d71 <exitwait+0x81>
if(wait() != pid){
d02: e8 a3 2b 00 00 call 38aa <wait>
d07: 39 d8 cmp %ebx,%eax
d09: 75 2d jne d38 <exitwait+0x48>
for(i = 0; i < 100; i++){
d0b: 83 ee 01 sub $0x1,%esi
d0e: 74 48 je d58 <exitwait+0x68>
pid = fork();
d10: e8 85 2b 00 00 call 389a <fork>
if(pid < 0){
d15: 85 c0 test %eax,%eax
pid = fork();
d17: 89 c3 mov %eax,%ebx
if(pid < 0){
d19: 79 e5 jns d00 <exitwait+0x10>
printf(1, "fork failed\n");
d1b: 83 ec 08 sub $0x8,%esp
d1e: 68 99 4c 00 00 push $0x4c99
d23: 6a 01 push $0x1
d25: e8 d6 2c 00 00 call 3a00 <printf>
return;
d2a: 83 c4 10 add $0x10,%esp
}
d2d: 8d 65 f8 lea -0x8(%ebp),%esp
d30: 5b pop %ebx
d31: 5e pop %esi
d32: 5d pop %ebp
d33: c3 ret
d34: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
printf(1, "wait wrong pid\n");
d38: 83 ec 08 sub $0x8,%esp
d3b: 68 3b 41 00 00 push $0x413b
d40: 6a 01 push $0x1
d42: e8 b9 2c 00 00 call 3a00 <printf>
return;
d47: 83 c4 10 add $0x10,%esp
}
d4a: 8d 65 f8 lea -0x8(%ebp),%esp
d4d: 5b pop %ebx
d4e: 5e pop %esi
d4f: 5d pop %ebp
d50: c3 ret
d51: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
printf(1, "exitwait ok\n");
d58: 83 ec 08 sub $0x8,%esp
d5b: 68 4b 41 00 00 push $0x414b
d60: 6a 01 push $0x1
d62: e8 99 2c 00 00 call 3a00 <printf>
d67: 83 c4 10 add $0x10,%esp
}
d6a: 8d 65 f8 lea -0x8(%ebp),%esp
d6d: 5b pop %ebx
d6e: 5e pop %esi
d6f: 5d pop %ebp
d70: c3 ret
exit();
d71: e8 2c 2b 00 00 call 38a2 <exit>
d76: 8d 76 00 lea 0x0(%esi),%esi
d79: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
00000d80 <mem>:
{
d80: 55 push %ebp
d81: 89 e5 mov %esp,%ebp
d83: 57 push %edi
d84: 56 push %esi
d85: 53 push %ebx
d86: 31 db xor %ebx,%ebx
d88: 83 ec 14 sub $0x14,%esp
printf(1, "mem test\n");
d8b: 68 58 41 00 00 push $0x4158
d90: 6a 01 push $0x1
d92: e8 69 2c 00 00 call 3a00 <printf>
ppid = getpid();
d97: e8 86 2b 00 00 call 3922 <getpid>
d9c: 89 c6 mov %eax,%esi
if((pid = fork()) == 0){
d9e: e8 f7 2a 00 00 call 389a <fork>
da3: 83 c4 10 add $0x10,%esp
da6: 85 c0 test %eax,%eax
da8: 74 0a je db4 <mem+0x34>
daa: e9 89 00 00 00 jmp e38 <mem+0xb8>
daf: 90 nop
*(char**)m2 = m1;
db0: 89 18 mov %ebx,(%eax)
db2: 89 c3 mov %eax,%ebx
while((m2 = malloc(10001)) != 0){
db4: 83 ec 0c sub $0xc,%esp
db7: 68 11 27 00 00 push $0x2711
dbc: e8 9f 2e 00 00 call 3c60 <malloc>
dc1: 83 c4 10 add $0x10,%esp
dc4: 85 c0 test %eax,%eax
dc6: 75 e8 jne db0 <mem+0x30>
while(m1){
dc8: 85 db test %ebx,%ebx
dca: 74 18 je de4 <mem+0x64>
dcc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
m2 = *(char**)m1;
dd0: 8b 3b mov (%ebx),%edi
free(m1);
dd2: 83 ec 0c sub $0xc,%esp
dd5: 53 push %ebx
dd6: 89 fb mov %edi,%ebx
dd8: e8 f3 2d 00 00 call 3bd0 <free>
while(m1){
ddd: 83 c4 10 add $0x10,%esp
de0: 85 db test %ebx,%ebx
de2: 75 ec jne dd0 <mem+0x50>
m1 = malloc(1024*20);
de4: 83 ec 0c sub $0xc,%esp
de7: 68 00 50 00 00 push $0x5000
dec: e8 6f 2e 00 00 call 3c60 <malloc>
if(m1 == 0){
df1: 83 c4 10 add $0x10,%esp
df4: 85 c0 test %eax,%eax
df6: 74 20 je e18 <mem+0x98>
free(m1);
df8: 83 ec 0c sub $0xc,%esp
dfb: 50 push %eax
dfc: e8 cf 2d 00 00 call 3bd0 <free>
printf(1, "mem ok\n");
e01: 58 pop %eax
e02: 5a pop %edx
e03: 68 7c 41 00 00 push $0x417c
e08: 6a 01 push $0x1
e0a: e8 f1 2b 00 00 call 3a00 <printf>
exit();
e0f: e8 8e 2a 00 00 call 38a2 <exit>
e14: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
printf(1, "couldn't allocate mem?!!\n");
e18: 83 ec 08 sub $0x8,%esp
e1b: 68 62 41 00 00 push $0x4162
e20: 6a 01 push $0x1
e22: e8 d9 2b 00 00 call 3a00 <printf>
kill(ppid);
e27: 89 34 24 mov %esi,(%esp)
e2a: e8 a3 2a 00 00 call 38d2 <kill>
exit();
e2f: e8 6e 2a 00 00 call 38a2 <exit>
e34: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
}
e38: 8d 65 f4 lea -0xc(%ebp),%esp
e3b: 5b pop %ebx
e3c: 5e pop %esi
e3d: 5f pop %edi
e3e: 5d pop %ebp
wait();
e3f: e9 66 2a 00 00 jmp 38aa <wait>
e44: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
e4a: 8d bf 00 00 00 00 lea 0x0(%edi),%edi
00000e50 <sharedfd>:
{
e50: 55 push %ebp
e51: 89 e5 mov %esp,%ebp
e53: 57 push %edi
e54: 56 push %esi
e55: 53 push %ebx
e56: 83 ec 34 sub $0x34,%esp
printf(1, "sharedfd test\n");
e59: 68 84 41 00 00 push $0x4184
e5e: 6a 01 push $0x1
e60: e8 9b 2b 00 00 call 3a00 <printf>
unlink("sharedfd");
e65: c7 04 24 93 41 00 00 movl $0x4193,(%esp)
e6c: e8 81 2a 00 00 call 38f2 <unlink>
fd = open("sharedfd", O_CREATE|O_RDWR);
e71: 59 pop %ecx
e72: 5b pop %ebx
e73: 68 02 02 00 00 push $0x202
e78: 68 93 41 00 00 push $0x4193
e7d: e8 60 2a 00 00 call 38e2 <open>
if(fd < 0){
e82: 83 c4 10 add $0x10,%esp
e85: 85 c0 test %eax,%eax
e87: 0f 88 33 01 00 00 js fc0 <sharedfd+0x170>
e8d: 89 c6 mov %eax,%esi
memset(buf, pid==0?'c':'p', sizeof(buf));
e8f: bb e8 03 00 00 mov $0x3e8,%ebx
pid = fork();
e94: e8 01 2a 00 00 call 389a <fork>
memset(buf, pid==0?'c':'p', sizeof(buf));
e99: 83 f8 01 cmp $0x1,%eax
pid = fork();
e9c: 89 c7 mov %eax,%edi
memset(buf, pid==0?'c':'p', sizeof(buf));
e9e: 19 c0 sbb %eax,%eax
ea0: 83 ec 04 sub $0x4,%esp
ea3: 83 e0 f3 and $0xfffffff3,%eax
ea6: 6a 0a push $0xa
ea8: 83 c0 70 add $0x70,%eax
eab: 50 push %eax
eac: 8d 45 de lea -0x22(%ebp),%eax
eaf: 50 push %eax
eb0: e8 4b 28 00 00 call 3700 <memset>
eb5: 83 c4 10 add $0x10,%esp
eb8: eb 0b jmp ec5 <sharedfd+0x75>
eba: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
for(i = 0; i < 1000; i++){
ec0: 83 eb 01 sub $0x1,%ebx
ec3: 74 29 je eee <sharedfd+0x9e>
if(write(fd, buf, sizeof(buf)) != sizeof(buf)){
ec5: 8d 45 de lea -0x22(%ebp),%eax
ec8: 83 ec 04 sub $0x4,%esp
ecb: 6a 0a push $0xa
ecd: 50 push %eax
ece: 56 push %esi
ecf: e8 ee 29 00 00 call 38c2 <write>
ed4: 83 c4 10 add $0x10,%esp
ed7: 83 f8 0a cmp $0xa,%eax
eda: 74 e4 je ec0 <sharedfd+0x70>
printf(1, "fstests: write sharedfd failed\n");
edc: 83 ec 08 sub $0x8,%esp
edf: 68 84 4e 00 00 push $0x4e84
ee4: 6a 01 push $0x1
ee6: e8 15 2b 00 00 call 3a00 <printf>
break;
eeb: 83 c4 10 add $0x10,%esp
if(pid == 0)
eee: 85 ff test %edi,%edi
ef0: 0f 84 fe 00 00 00 je ff4 <sharedfd+0x1a4>
wait();
ef6: e8 af 29 00 00 call 38aa <wait>
close(fd);
efb: 83 ec 0c sub $0xc,%esp
nc = np = 0;
efe: 31 db xor %ebx,%ebx
f00: 31 ff xor %edi,%edi
close(fd);
f02: 56 push %esi
f03: 8d 75 e8 lea -0x18(%ebp),%esi
f06: e8 bf 29 00 00 call 38ca <close>
fd = open("sharedfd", 0);
f0b: 58 pop %eax
f0c: 5a pop %edx
f0d: 6a 00 push $0x0
f0f: 68 93 41 00 00 push $0x4193
f14: e8 c9 29 00 00 call 38e2 <open>
if(fd < 0){
f19: 83 c4 10 add $0x10,%esp
f1c: 85 c0 test %eax,%eax
fd = open("sharedfd", 0);
f1e: 89 45 d4 mov %eax,-0x2c(%ebp)
if(fd < 0){
f21: 0f 88 b3 00 00 00 js fda <sharedfd+0x18a>
f27: 89 f8 mov %edi,%eax
f29: 89 df mov %ebx,%edi
f2b: 89 c3 mov %eax,%ebx
f2d: 8d 76 00 lea 0x0(%esi),%esi
while((n = read(fd, buf, sizeof(buf))) > 0){
f30: 8d 45 de lea -0x22(%ebp),%eax
f33: 83 ec 04 sub $0x4,%esp
f36: 6a 0a push $0xa
f38: 50 push %eax
f39: ff 75 d4 pushl -0x2c(%ebp)
f3c: e8 79 29 00 00 call 38ba <read>
f41: 83 c4 10 add $0x10,%esp
f44: 85 c0 test %eax,%eax
f46: 7e 28 jle f70 <sharedfd+0x120>
f48: 8d 45 de lea -0x22(%ebp),%eax
f4b: eb 15 jmp f62 <sharedfd+0x112>
f4d: 8d 76 00 lea 0x0(%esi),%esi
np++;
f50: 80 fa 70 cmp $0x70,%dl
f53: 0f 94 c2 sete %dl
f56: 0f b6 d2 movzbl %dl,%edx
f59: 01 d7 add %edx,%edi
f5b: 83 c0 01 add $0x1,%eax
for(i = 0; i < sizeof(buf); i++){
f5e: 39 f0 cmp %esi,%eax
f60: 74 ce je f30 <sharedfd+0xe0>
if(buf[i] == 'c')
f62: 0f b6 10 movzbl (%eax),%edx
f65: 80 fa 63 cmp $0x63,%dl
f68: 75 e6 jne f50 <sharedfd+0x100>
nc++;
f6a: 83 c3 01 add $0x1,%ebx
f6d: eb ec jmp f5b <sharedfd+0x10b>
f6f: 90 nop
close(fd);
f70: 83 ec 0c sub $0xc,%esp
f73: 89 d8 mov %ebx,%eax
f75: ff 75 d4 pushl -0x2c(%ebp)
f78: 89 fb mov %edi,%ebx
f7a: 89 c7 mov %eax,%edi
f7c: e8 49 29 00 00 call 38ca <close>
unlink("sharedfd");
f81: c7 04 24 93 41 00 00 movl $0x4193,(%esp)
f88: e8 65 29 00 00 call 38f2 <unlink>
if(nc == 10000 && np == 10000){
f8d: 83 c4 10 add $0x10,%esp
f90: 81 ff 10 27 00 00 cmp $0x2710,%edi
f96: 75 61 jne ff9 <sharedfd+0x1a9>
f98: 81 fb 10 27 00 00 cmp $0x2710,%ebx
f9e: 75 59 jne ff9 <sharedfd+0x1a9>
printf(1, "sharedfd ok\n");
fa0: 83 ec 08 sub $0x8,%esp
fa3: 68 9c 41 00 00 push $0x419c
fa8: 6a 01 push $0x1
faa: e8 51 2a 00 00 call 3a00 <printf>
faf: 83 c4 10 add $0x10,%esp
}
fb2: 8d 65 f4 lea -0xc(%ebp),%esp
fb5: 5b pop %ebx
fb6: 5e pop %esi
fb7: 5f pop %edi
fb8: 5d pop %ebp
fb9: c3 ret
fba: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
printf(1, "fstests: cannot open sharedfd for writing");
fc0: 83 ec 08 sub $0x8,%esp
fc3: 68 58 4e 00 00 push $0x4e58
fc8: 6a 01 push $0x1
fca: e8 31 2a 00 00 call 3a00 <printf>
return;
fcf: 83 c4 10 add $0x10,%esp
}
fd2: 8d 65 f4 lea -0xc(%ebp),%esp
fd5: 5b pop %ebx
fd6: 5e pop %esi
fd7: 5f pop %edi
fd8: 5d pop %ebp
fd9: c3 ret
printf(1, "fstests: cannot open sharedfd for reading\n");
fda: 83 ec 08 sub $0x8,%esp
fdd: 68 a4 4e 00 00 push $0x4ea4
fe2: 6a 01 push $0x1
fe4: e8 17 2a 00 00 call 3a00 <printf>
return;
fe9: 83 c4 10 add $0x10,%esp
}
fec: 8d 65 f4 lea -0xc(%ebp),%esp
fef: 5b pop %ebx
ff0: 5e pop %esi
ff1: 5f pop %edi
ff2: 5d pop %ebp
ff3: c3 ret
exit();
ff4: e8 a9 28 00 00 call 38a2 <exit>
printf(1, "sharedfd oops %d %d\n", nc, np);
ff9: 53 push %ebx
ffa: 57 push %edi
ffb: 68 a9 41 00 00 push $0x41a9
1000: 6a 01 push $0x1
1002: e8 f9 29 00 00 call 3a00 <printf>
exit();
1007: e8 96 28 00 00 call 38a2 <exit>
100c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
00001010 <fourfiles>:
{
1010: 55 push %ebp
1011: 89 e5 mov %esp,%ebp
1013: 57 push %edi
1014: 56 push %esi
1015: 53 push %ebx
printf(1, "fourfiles test\n");
1016: be be 41 00 00 mov $0x41be,%esi
for(pi = 0; pi < 4; pi++){
101b: 31 db xor %ebx,%ebx
{
101d: 83 ec 34 sub $0x34,%esp
char *names[] = { "f0", "f1", "f2", "f3" };
1020: c7 45 d8 be 41 00 00 movl $0x41be,-0x28(%ebp)
1027: c7 45 dc 07 43 00 00 movl $0x4307,-0x24(%ebp)
printf(1, "fourfiles test\n");
102e: 68 c4 41 00 00 push $0x41c4
1033: 6a 01 push $0x1
char *names[] = { "f0", "f1", "f2", "f3" };
1035: c7 45 e0 0b 43 00 00 movl $0x430b,-0x20(%ebp)
103c: c7 45 e4 c1 41 00 00 movl $0x41c1,-0x1c(%ebp)
printf(1, "fourfiles test\n");
1043: e8 b8 29 00 00 call 3a00 <printf>
1048: 83 c4 10 add $0x10,%esp
unlink(fname);
104b: 83 ec 0c sub $0xc,%esp
104e: 56 push %esi
104f: e8 9e 28 00 00 call 38f2 <unlink>
pid = fork();
1054: e8 41 28 00 00 call 389a <fork>
if(pid < 0){
1059: 83 c4 10 add $0x10,%esp
105c: 85 c0 test %eax,%eax
105e: 0f 88 68 01 00 00 js 11cc <fourfiles+0x1bc>
if(pid == 0){
1064: 0f 84 df 00 00 00 je 1149 <fourfiles+0x139>
for(pi = 0; pi < 4; pi++){
106a: 83 c3 01 add $0x1,%ebx
106d: 83 fb 04 cmp $0x4,%ebx
1070: 74 06 je 1078 <fourfiles+0x68>
1072: 8b 74 9d d8 mov -0x28(%ebp,%ebx,4),%esi
1076: eb d3 jmp 104b <fourfiles+0x3b>
wait();
1078: e8 2d 28 00 00 call 38aa <wait>
for(i = 0; i < 2; i++){
107d: 31 ff xor %edi,%edi
wait();
107f: e8 26 28 00 00 call 38aa <wait>
1084: e8 21 28 00 00 call 38aa <wait>
1089: e8 1c 28 00 00 call 38aa <wait>
108e: c7 45 d0 be 41 00 00 movl $0x41be,-0x30(%ebp)
fd = open(fname, 0);
1095: 83 ec 08 sub $0x8,%esp
total = 0;
1098: 31 db xor %ebx,%ebx
fd = open(fname, 0);
109a: 6a 00 push $0x0
109c: ff 75 d0 pushl -0x30(%ebp)
109f: e8 3e 28 00 00 call 38e2 <open>
while((n = read(fd, buf, sizeof(buf))) > 0){
10a4: 83 c4 10 add $0x10,%esp
fd = open(fname, 0);
10a7: 89 45 d4 mov %eax,-0x2c(%ebp)
10aa: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
while((n = read(fd, buf, sizeof(buf))) > 0){
10b0: 83 ec 04 sub $0x4,%esp
10b3: 68 00 20 00 00 push $0x2000
10b8: 68 40 86 00 00 push $0x8640
10bd: ff 75 d4 pushl -0x2c(%ebp)
10c0: e8 f5 27 00 00 call 38ba <read>
10c5: 83 c4 10 add $0x10,%esp
10c8: 85 c0 test %eax,%eax
10ca: 7e 26 jle 10f2 <fourfiles+0xe2>
for(j = 0; j < n; j++){
10cc: 31 d2 xor %edx,%edx
10ce: 66 90 xchg %ax,%ax
if(buf[j] != '0'+i){
10d0: 0f be b2 40 86 00 00 movsbl 0x8640(%edx),%esi
10d7: 83 ff 01 cmp $0x1,%edi
10da: 19 c9 sbb %ecx,%ecx
10dc: 83 c1 31 add $0x31,%ecx
10df: 39 ce cmp %ecx,%esi
10e1: 0f 85 be 00 00 00 jne 11a5 <fourfiles+0x195>
for(j = 0; j < n; j++){
10e7: 83 c2 01 add $0x1,%edx
10ea: 39 d0 cmp %edx,%eax
10ec: 75 e2 jne 10d0 <fourfiles+0xc0>
total += n;
10ee: 01 c3 add %eax,%ebx
10f0: eb be jmp 10b0 <fourfiles+0xa0>
close(fd);
10f2: 83 ec 0c sub $0xc,%esp
10f5: ff 75 d4 pushl -0x2c(%ebp)
10f8: e8 cd 27 00 00 call 38ca <close>
if(total != 12*500){
10fd: 83 c4 10 add $0x10,%esp
1100: 81 fb 70 17 00 00 cmp $0x1770,%ebx
1106: 0f 85 d3 00 00 00 jne 11df <fourfiles+0x1cf>
unlink(fname);
110c: 83 ec 0c sub $0xc,%esp
110f: ff 75 d0 pushl -0x30(%ebp)
1112: e8 db 27 00 00 call 38f2 <unlink>
for(i = 0; i < 2; i++){
1117: 83 c4 10 add $0x10,%esp
111a: 83 ff 01 cmp $0x1,%edi
111d: 75 1a jne 1139 <fourfiles+0x129>
printf(1, "fourfiles ok\n");
111f: 83 ec 08 sub $0x8,%esp
1122: 68 02 42 00 00 push $0x4202
1127: 6a 01 push $0x1
1129: e8 d2 28 00 00 call 3a00 <printf>
}
112e: 83 c4 10 add $0x10,%esp
1131: 8d 65 f4 lea -0xc(%ebp),%esp
1134: 5b pop %ebx
1135: 5e pop %esi
1136: 5f pop %edi
1137: 5d pop %ebp
1138: c3 ret
1139: 8b 45 dc mov -0x24(%ebp),%eax
113c: bf 01 00 00 00 mov $0x1,%edi
1141: 89 45 d0 mov %eax,-0x30(%ebp)
1144: e9 4c ff ff ff jmp 1095 <fourfiles+0x85>
fd = open(fname, O_CREATE | O_RDWR);
1149: 83 ec 08 sub $0x8,%esp
114c: 68 02 02 00 00 push $0x202
1151: 56 push %esi
1152: e8 8b 27 00 00 call 38e2 <open>
if(fd < 0){
1157: 83 c4 10 add $0x10,%esp
115a: 85 c0 test %eax,%eax
fd = open(fname, O_CREATE | O_RDWR);
115c: 89 c6 mov %eax,%esi
if(fd < 0){
115e: 78 59 js 11b9 <fourfiles+0x1a9>
memset(buf, '0'+pi, 512);
1160: 83 ec 04 sub $0x4,%esp
1163: 83 c3 30 add $0x30,%ebx
1166: 68 00 02 00 00 push $0x200
116b: 53 push %ebx
116c: bb 0c 00 00 00 mov $0xc,%ebx
1171: 68 40 86 00 00 push $0x8640
1176: e8 85 25 00 00 call 3700 <memset>
117b: 83 c4 10 add $0x10,%esp
if((n = write(fd, buf, 500)) != 500){
117e: 83 ec 04 sub $0x4,%esp
1181: 68 f4 01 00 00 push $0x1f4
1186: 68 40 86 00 00 push $0x8640
118b: 56 push %esi
118c: e8 31 27 00 00 call 38c2 <write>
1191: 83 c4 10 add $0x10,%esp
1194: 3d f4 01 00 00 cmp $0x1f4,%eax
1199: 75 57 jne 11f2 <fourfiles+0x1e2>
for(i = 0; i < 12; i++){
119b: 83 eb 01 sub $0x1,%ebx
119e: 75 de jne 117e <fourfiles+0x16e>
exit();
11a0: e8 fd 26 00 00 call 38a2 <exit>
printf(1, "wrong char\n");
11a5: 83 ec 08 sub $0x8,%esp
11a8: 68 e5 41 00 00 push $0x41e5
11ad: 6a 01 push $0x1
11af: e8 4c 28 00 00 call 3a00 <printf>
exit();
11b4: e8 e9 26 00 00 call 38a2 <exit>
printf(1, "create failed\n");
11b9: 51 push %ecx
11ba: 51 push %ecx
11bb: 68 5f 44 00 00 push $0x445f
11c0: 6a 01 push $0x1
11c2: e8 39 28 00 00 call 3a00 <printf>
exit();
11c7: e8 d6 26 00 00 call 38a2 <exit>
printf(1, "fork failed\n");
11cc: 53 push %ebx
11cd: 53 push %ebx
11ce: 68 99 4c 00 00 push $0x4c99
11d3: 6a 01 push $0x1
11d5: e8 26 28 00 00 call 3a00 <printf>
exit();
11da: e8 c3 26 00 00 call 38a2 <exit>
printf(1, "wrong length %d\n", total);
11df: 50 push %eax
11e0: 53 push %ebx
11e1: 68 f1 41 00 00 push $0x41f1
11e6: 6a 01 push $0x1
11e8: e8 13 28 00 00 call 3a00 <printf>
exit();
11ed: e8 b0 26 00 00 call 38a2 <exit>
printf(1, "write failed %d\n", n);
11f2: 52 push %edx
11f3: 50 push %eax
11f4: 68 d4 41 00 00 push $0x41d4
11f9: 6a 01 push $0x1
11fb: e8 00 28 00 00 call 3a00 <printf>
exit();
1200: e8 9d 26 00 00 call 38a2 <exit>
1205: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
1209: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
00001210 <createdelete>:
{
1210: 55 push %ebp
1211: 89 e5 mov %esp,%ebp
1213: 57 push %edi
1214: 56 push %esi
1215: 53 push %ebx
for(pi = 0; pi < 4; pi++){
1216: 31 db xor %ebx,%ebx
{
1218: 83 ec 44 sub $0x44,%esp
printf(1, "createdelete test\n");
121b: 68 10 42 00 00 push $0x4210
1220: 6a 01 push $0x1
1222: e8 d9 27 00 00 call 3a00 <printf>
1227: 83 c4 10 add $0x10,%esp
pid = fork();
122a: e8 6b 26 00 00 call 389a <fork>
if(pid < 0){
122f: 85 c0 test %eax,%eax
1231: 0f 88 be 01 00 00 js 13f5 <createdelete+0x1e5>
if(pid == 0){
1237: 0f 84 0b 01 00 00 je 1348 <createdelete+0x138>
for(pi = 0; pi < 4; pi++){
123d: 83 c3 01 add $0x1,%ebx
1240: 83 fb 04 cmp $0x4,%ebx
1243: 75 e5 jne 122a <createdelete+0x1a>
1245: 8d 7d c8 lea -0x38(%ebp),%edi
name[0] = name[1] = name[2] = 0;
1248: be ff ff ff ff mov $0xffffffff,%esi
wait();
124d: e8 58 26 00 00 call 38aa <wait>
1252: e8 53 26 00 00 call 38aa <wait>
1257: e8 4e 26 00 00 call 38aa <wait>
125c: e8 49 26 00 00 call 38aa <wait>
name[0] = name[1] = name[2] = 0;
1261: c6 45 ca 00 movb $0x0,-0x36(%ebp)
1265: 8d 76 00 lea 0x0(%esi),%esi
1268: 8d 46 31 lea 0x31(%esi),%eax
126b: 88 45 c7 mov %al,-0x39(%ebp)
126e: 8d 46 01 lea 0x1(%esi),%eax
1271: 83 f8 09 cmp $0x9,%eax
1274: 89 45 c0 mov %eax,-0x40(%ebp)
1277: 0f 9f c3 setg %bl
127a: 85 c0 test %eax,%eax
127c: 0f 94 c0 sete %al
127f: 09 c3 or %eax,%ebx
1281: 88 5d c6 mov %bl,-0x3a(%ebp)
name[2] = '\0';
1284: bb 70 00 00 00 mov $0x70,%ebx
name[1] = '0' + i;
1289: 0f b6 45 c7 movzbl -0x39(%ebp),%eax
fd = open(name, 0);
128d: 83 ec 08 sub $0x8,%esp
name[0] = 'p' + pi;
1290: 88 5d c8 mov %bl,-0x38(%ebp)
fd = open(name, 0);
1293: 6a 00 push $0x0
1295: 57 push %edi
name[1] = '0' + i;
1296: 88 45 c9 mov %al,-0x37(%ebp)
fd = open(name, 0);
1299: e8 44 26 00 00 call 38e2 <open>
if((i == 0 || i >= N/2) && fd < 0){
129e: 83 c4 10 add $0x10,%esp
12a1: 80 7d c6 00 cmpb $0x0,-0x3a(%ebp)
12a5: 0f 84 85 00 00 00 je 1330 <createdelete+0x120>
12ab: 85 c0 test %eax,%eax
12ad: 0f 88 1a 01 00 00 js 13cd <createdelete+0x1bd>
} else if((i >= 1 && i < N/2) && fd >= 0){
12b3: 83 fe 08 cmp $0x8,%esi
12b6: 0f 86 54 01 00 00 jbe 1410 <createdelete+0x200>
close(fd);
12bc: 83 ec 0c sub $0xc,%esp
12bf: 50 push %eax
12c0: e8 05 26 00 00 call 38ca <close>
12c5: 83 c4 10 add $0x10,%esp
12c8: 83 c3 01 add $0x1,%ebx
for(pi = 0; pi < 4; pi++){
12cb: 80 fb 74 cmp $0x74,%bl
12ce: 75 b9 jne 1289 <createdelete+0x79>
12d0: 8b 75 c0 mov -0x40(%ebp),%esi
for(i = 0; i < N; i++){
12d3: 83 fe 13 cmp $0x13,%esi
12d6: 75 90 jne 1268 <createdelete+0x58>
12d8: be 70 00 00 00 mov $0x70,%esi
12dd: 8d 76 00 lea 0x0(%esi),%esi
12e0: 8d 46 c0 lea -0x40(%esi),%eax
name[0] = name[1] = name[2] = 0;
12e3: bb 04 00 00 00 mov $0x4,%ebx
12e8: 88 45 c7 mov %al,-0x39(%ebp)
name[0] = 'p' + i;
12eb: 89 f0 mov %esi,%eax
unlink(name);
12ed: 83 ec 0c sub $0xc,%esp
name[0] = 'p' + i;
12f0: 88 45 c8 mov %al,-0x38(%ebp)
name[1] = '0' + i;
12f3: 0f b6 45 c7 movzbl -0x39(%ebp),%eax
unlink(name);
12f7: 57 push %edi
name[1] = '0' + i;
12f8: 88 45 c9 mov %al,-0x37(%ebp)
unlink(name);
12fb: e8 f2 25 00 00 call 38f2 <unlink>
for(pi = 0; pi < 4; pi++){
1300: 83 c4 10 add $0x10,%esp
1303: 83 eb 01 sub $0x1,%ebx
1306: 75 e3 jne 12eb <createdelete+0xdb>
1308: 83 c6 01 add $0x1,%esi
for(i = 0; i < N; i++){
130b: 89 f0 mov %esi,%eax
130d: 3c 84 cmp $0x84,%al
130f: 75 cf jne 12e0 <createdelete+0xd0>
printf(1, "createdelete ok\n");
1311: 83 ec 08 sub $0x8,%esp
1314: 68 23 42 00 00 push $0x4223
1319: 6a 01 push $0x1
131b: e8 e0 26 00 00 call 3a00 <printf>
}
1320: 8d 65 f4 lea -0xc(%ebp),%esp
1323: 5b pop %ebx
1324: 5e pop %esi
1325: 5f pop %edi
1326: 5d pop %ebp
1327: c3 ret
1328: 90 nop
1329: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
} else if((i >= 1 && i < N/2) && fd >= 0){
1330: 83 fe 08 cmp $0x8,%esi
1333: 0f 86 cf 00 00 00 jbe 1408 <createdelete+0x1f8>
if(fd >= 0)
1339: 85 c0 test %eax,%eax
133b: 78 8b js 12c8 <createdelete+0xb8>
133d: e9 7a ff ff ff jmp 12bc <createdelete+0xac>
1342: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
name[0] = 'p' + pi;
1348: 83 c3 70 add $0x70,%ebx
name[2] = '\0';
134b: c6 45 ca 00 movb $0x0,-0x36(%ebp)
134f: 8d 7d c8 lea -0x38(%ebp),%edi
name[0] = 'p' + pi;
1352: 88 5d c8 mov %bl,-0x38(%ebp)
name[2] = '\0';
1355: 31 db xor %ebx,%ebx
1357: eb 0f jmp 1368 <createdelete+0x158>
1359: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
for(i = 0; i < N; i++){
1360: 83 fb 13 cmp $0x13,%ebx
1363: 74 63 je 13c8 <createdelete+0x1b8>
1365: 83 c3 01 add $0x1,%ebx
fd = open(name, O_CREATE | O_RDWR);
1368: 83 ec 08 sub $0x8,%esp
name[1] = '0' + i;
136b: 8d 43 30 lea 0x30(%ebx),%eax
fd = open(name, O_CREATE | O_RDWR);
136e: 68 02 02 00 00 push $0x202
1373: 57 push %edi
name[1] = '0' + i;
1374: 88 45 c9 mov %al,-0x37(%ebp)
fd = open(name, O_CREATE | O_RDWR);
1377: e8 66 25 00 00 call 38e2 <open>
if(fd < 0){
137c: 83 c4 10 add $0x10,%esp
137f: 85 c0 test %eax,%eax
1381: 78 5f js 13e2 <createdelete+0x1d2>
close(fd);
1383: 83 ec 0c sub $0xc,%esp
1386: 50 push %eax
1387: e8 3e 25 00 00 call 38ca <close>
if(i > 0 && (i % 2 ) == 0){
138c: 83 c4 10 add $0x10,%esp
138f: 85 db test %ebx,%ebx
1391: 74 d2 je 1365 <createdelete+0x155>
1393: f6 c3 01 test $0x1,%bl
1396: 75 c8 jne 1360 <createdelete+0x150>
if(unlink(name) < 0){
1398: 83 ec 0c sub $0xc,%esp
name[1] = '0' + (i / 2);
139b: 89 d8 mov %ebx,%eax
139d: d1 f8 sar %eax
if(unlink(name) < 0){
139f: 57 push %edi
name[1] = '0' + (i / 2);
13a0: 83 c0 30 add $0x30,%eax
13a3: 88 45 c9 mov %al,-0x37(%ebp)
if(unlink(name) < 0){
13a6: e8 47 25 00 00 call 38f2 <unlink>
13ab: 83 c4 10 add $0x10,%esp
13ae: 85 c0 test %eax,%eax
13b0: 79 ae jns 1360 <createdelete+0x150>
printf(1, "unlink failed\n");
13b2: 52 push %edx
13b3: 52 push %edx
13b4: 68 11 3e 00 00 push $0x3e11
13b9: 6a 01 push $0x1
13bb: e8 40 26 00 00 call 3a00 <printf>
exit();
13c0: e8 dd 24 00 00 call 38a2 <exit>
13c5: 8d 76 00 lea 0x0(%esi),%esi
exit();
13c8: e8 d5 24 00 00 call 38a2 <exit>
printf(1, "oops createdelete %s didn't exist\n", name);
13cd: 83 ec 04 sub $0x4,%esp
13d0: 57 push %edi
13d1: 68 d0 4e 00 00 push $0x4ed0
13d6: 6a 01 push $0x1
13d8: e8 23 26 00 00 call 3a00 <printf>
exit();
13dd: e8 c0 24 00 00 call 38a2 <exit>
printf(1, "create failed\n");
13e2: 51 push %ecx
13e3: 51 push %ecx
13e4: 68 5f 44 00 00 push $0x445f
13e9: 6a 01 push $0x1
13eb: e8 10 26 00 00 call 3a00 <printf>
exit();
13f0: e8 ad 24 00 00 call 38a2 <exit>
printf(1, "fork failed\n");
13f5: 53 push %ebx
13f6: 53 push %ebx
13f7: 68 99 4c 00 00 push $0x4c99
13fc: 6a 01 push $0x1
13fe: e8 fd 25 00 00 call 3a00 <printf>
exit();
1403: e8 9a 24 00 00 call 38a2 <exit>
} else if((i >= 1 && i < N/2) && fd >= 0){
1408: 85 c0 test %eax,%eax
140a: 0f 88 b8 fe ff ff js 12c8 <createdelete+0xb8>
printf(1, "oops createdelete %s did exist\n", name);
1410: 50 push %eax
1411: 57 push %edi
1412: 68 f4 4e 00 00 push $0x4ef4
1417: 6a 01 push $0x1
1419: e8 e2 25 00 00 call 3a00 <printf>
exit();
141e: e8 7f 24 00 00 call 38a2 <exit>
1423: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
1429: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
00001430 <unlinkread>:
{
1430: 55 push %ebp
1431: 89 e5 mov %esp,%ebp
1433: 56 push %esi
1434: 53 push %ebx
printf(1, "unlinkread test\n");
1435: 83 ec 08 sub $0x8,%esp
1438: 68 34 42 00 00 push $0x4234
143d: 6a 01 push $0x1
143f: e8 bc 25 00 00 call 3a00 <printf>
fd = open("unlinkread", O_CREATE | O_RDWR);
1444: 5b pop %ebx
1445: 5e pop %esi
1446: 68 02 02 00 00 push $0x202
144b: 68 45 42 00 00 push $0x4245
1450: e8 8d 24 00 00 call 38e2 <open>
if(fd < 0){
1455: 83 c4 10 add $0x10,%esp
1458: 85 c0 test %eax,%eax
145a: 0f 88 e6 00 00 00 js 1546 <unlinkread+0x116>
write(fd, "hello", 5);
1460: 83 ec 04 sub $0x4,%esp
1463: 89 c3 mov %eax,%ebx
1465: 6a 05 push $0x5
1467: 68 6a 42 00 00 push $0x426a
146c: 50 push %eax
146d: e8 50 24 00 00 call 38c2 <write>
close(fd);
1472: 89 1c 24 mov %ebx,(%esp)
1475: e8 50 24 00 00 call 38ca <close>
fd = open("unlinkread", O_RDWR);
147a: 58 pop %eax
147b: 5a pop %edx
147c: 6a 02 push $0x2
147e: 68 45 42 00 00 push $0x4245
1483: e8 5a 24 00 00 call 38e2 <open>
if(fd < 0){
1488: 83 c4 10 add $0x10,%esp
148b: 85 c0 test %eax,%eax
fd = open("unlinkread", O_RDWR);
148d: 89 c3 mov %eax,%ebx
if(fd < 0){
148f: 0f 88 10 01 00 00 js 15a5 <unlinkread+0x175>
if(unlink("unlinkread") != 0){
1495: 83 ec 0c sub $0xc,%esp
1498: 68 45 42 00 00 push $0x4245
149d: e8 50 24 00 00 call 38f2 <unlink>
14a2: 83 c4 10 add $0x10,%esp
14a5: 85 c0 test %eax,%eax
14a7: 0f 85 e5 00 00 00 jne 1592 <unlinkread+0x162>
fd1 = open("unlinkread", O_CREATE | O_RDWR);
14ad: 83 ec 08 sub $0x8,%esp
14b0: 68 02 02 00 00 push $0x202
14b5: 68 45 42 00 00 push $0x4245
14ba: e8 23 24 00 00 call 38e2 <open>
write(fd1, "yyy", 3);
14bf: 83 c4 0c add $0xc,%esp
fd1 = open("unlinkread", O_CREATE | O_RDWR);
14c2: 89 c6 mov %eax,%esi
write(fd1, "yyy", 3);
14c4: 6a 03 push $0x3
14c6: 68 a2 42 00 00 push $0x42a2
14cb: 50 push %eax
14cc: e8 f1 23 00 00 call 38c2 <write>
close(fd1);
14d1: 89 34 24 mov %esi,(%esp)
14d4: e8 f1 23 00 00 call 38ca <close>
if(read(fd, buf, sizeof(buf)) != 5){
14d9: 83 c4 0c add $0xc,%esp
14dc: 68 00 20 00 00 push $0x2000
14e1: 68 40 86 00 00 push $0x8640
14e6: 53 push %ebx
14e7: e8 ce 23 00 00 call 38ba <read>
14ec: 83 c4 10 add $0x10,%esp
14ef: 83 f8 05 cmp $0x5,%eax
14f2: 0f 85 87 00 00 00 jne 157f <unlinkread+0x14f>
if(buf[0] != 'h'){
14f8: 80 3d 40 86 00 00 68 cmpb $0x68,0x8640
14ff: 75 6b jne 156c <unlinkread+0x13c>
if(write(fd, buf, 10) != 10){
1501: 83 ec 04 sub $0x4,%esp
1504: 6a 0a push $0xa
1506: 68 40 86 00 00 push $0x8640
150b: 53 push %ebx
150c: e8 b1 23 00 00 call 38c2 <write>
1511: 83 c4 10 add $0x10,%esp
1514: 83 f8 0a cmp $0xa,%eax
1517: 75 40 jne 1559 <unlinkread+0x129>
close(fd);
1519: 83 ec 0c sub $0xc,%esp
151c: 53 push %ebx
151d: e8 a8 23 00 00 call 38ca <close>
unlink("unlinkread");
1522: c7 04 24 45 42 00 00 movl $0x4245,(%esp)
1529: e8 c4 23 00 00 call 38f2 <unlink>
printf(1, "unlinkread ok\n");
152e: 58 pop %eax
152f: 5a pop %edx
1530: 68 ed 42 00 00 push $0x42ed
1535: 6a 01 push $0x1
1537: e8 c4 24 00 00 call 3a00 <printf>
}
153c: 83 c4 10 add $0x10,%esp
153f: 8d 65 f8 lea -0x8(%ebp),%esp
1542: 5b pop %ebx
1543: 5e pop %esi
1544: 5d pop %ebp
1545: c3 ret
printf(1, "create unlinkread failed\n");
1546: 51 push %ecx
1547: 51 push %ecx
1548: 68 50 42 00 00 push $0x4250
154d: 6a 01 push $0x1
154f: e8 ac 24 00 00 call 3a00 <printf>
exit();
1554: e8 49 23 00 00 call 38a2 <exit>
printf(1, "unlinkread write failed\n");
1559: 51 push %ecx
155a: 51 push %ecx
155b: 68 d4 42 00 00 push $0x42d4
1560: 6a 01 push $0x1
1562: e8 99 24 00 00 call 3a00 <printf>
exit();
1567: e8 36 23 00 00 call 38a2 <exit>
printf(1, "unlinkread wrong data\n");
156c: 53 push %ebx
156d: 53 push %ebx
156e: 68 bd 42 00 00 push $0x42bd
1573: 6a 01 push $0x1
1575: e8 86 24 00 00 call 3a00 <printf>
exit();
157a: e8 23 23 00 00 call 38a2 <exit>
printf(1, "unlinkread read failed");
157f: 56 push %esi
1580: 56 push %esi
1581: 68 a6 42 00 00 push $0x42a6
1586: 6a 01 push $0x1
1588: e8 73 24 00 00 call 3a00 <printf>
exit();
158d: e8 10 23 00 00 call 38a2 <exit>
printf(1, "unlink unlinkread failed\n");
1592: 50 push %eax
1593: 50 push %eax
1594: 68 88 42 00 00 push $0x4288
1599: 6a 01 push $0x1
159b: e8 60 24 00 00 call 3a00 <printf>
exit();
15a0: e8 fd 22 00 00 call 38a2 <exit>
printf(1, "open unlinkread failed\n");
15a5: 50 push %eax
15a6: 50 push %eax
15a7: 68 70 42 00 00 push $0x4270
15ac: 6a 01 push $0x1
15ae: e8 4d 24 00 00 call 3a00 <printf>
exit();
15b3: e8 ea 22 00 00 call 38a2 <exit>
15b8: 90 nop
15b9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
000015c0 <linktest>:
{
15c0: 55 push %ebp
15c1: 89 e5 mov %esp,%ebp
15c3: 53 push %ebx
15c4: 83 ec 0c sub $0xc,%esp
printf(1, "linktest\n");
15c7: 68 fc 42 00 00 push $0x42fc
15cc: 6a 01 push $0x1
15ce: e8 2d 24 00 00 call 3a00 <printf>
unlink("lf1");
15d3: c7 04 24 06 43 00 00 movl $0x4306,(%esp)
15da: e8 13 23 00 00 call 38f2 <unlink>
unlink("lf2");
15df: c7 04 24 0a 43 00 00 movl $0x430a,(%esp)
15e6: e8 07 23 00 00 call 38f2 <unlink>
fd = open("lf1", O_CREATE|O_RDWR);
15eb: 58 pop %eax
15ec: 5a pop %edx
15ed: 68 02 02 00 00 push $0x202
15f2: 68 06 43 00 00 push $0x4306
15f7: e8 e6 22 00 00 call 38e2 <open>
if(fd < 0){
15fc: 83 c4 10 add $0x10,%esp
15ff: 85 c0 test %eax,%eax
1601: 0f 88 1e 01 00 00 js 1725 <linktest+0x165>
if(write(fd, "hello", 5) != 5){
1607: 83 ec 04 sub $0x4,%esp
160a: 89 c3 mov %eax,%ebx
160c: 6a 05 push $0x5
160e: 68 6a 42 00 00 push $0x426a
1613: 50 push %eax
1614: e8 a9 22 00 00 call 38c2 <write>
1619: 83 c4 10 add $0x10,%esp
161c: 83 f8 05 cmp $0x5,%eax
161f: 0f 85 98 01 00 00 jne 17bd <linktest+0x1fd>
close(fd);
1625: 83 ec 0c sub $0xc,%esp
1628: 53 push %ebx
1629: e8 9c 22 00 00 call 38ca <close>
if(link("lf1", "lf2") < 0){
162e: 5b pop %ebx
162f: 58 pop %eax
1630: 68 0a 43 00 00 push $0x430a
1635: 68 06 43 00 00 push $0x4306
163a: e8 c3 22 00 00 call 3902 <link>
163f: 83 c4 10 add $0x10,%esp
1642: 85 c0 test %eax,%eax
1644: 0f 88 60 01 00 00 js 17aa <linktest+0x1ea>
unlink("lf1");
164a: 83 ec 0c sub $0xc,%esp
164d: 68 06 43 00 00 push $0x4306
1652: e8 9b 22 00 00 call 38f2 <unlink>
if(open("lf1", 0) >= 0){
1657: 58 pop %eax
1658: 5a pop %edx
1659: 6a 00 push $0x0
165b: 68 06 43 00 00 push $0x4306
1660: e8 7d 22 00 00 call 38e2 <open>
1665: 83 c4 10 add $0x10,%esp
1668: 85 c0 test %eax,%eax
166a: 0f 89 27 01 00 00 jns 1797 <linktest+0x1d7>
fd = open("lf2", 0);
1670: 83 ec 08 sub $0x8,%esp
1673: 6a 00 push $0x0
1675: 68 0a 43 00 00 push $0x430a
167a: e8 63 22 00 00 call 38e2 <open>
if(fd < 0){
167f: 83 c4 10 add $0x10,%esp
1682: 85 c0 test %eax,%eax
fd = open("lf2", 0);
1684: 89 c3 mov %eax,%ebx
if(fd < 0){
1686: 0f 88 f8 00 00 00 js 1784 <linktest+0x1c4>
if(read(fd, buf, sizeof(buf)) != 5){
168c: 83 ec 04 sub $0x4,%esp
168f: 68 00 20 00 00 push $0x2000
1694: 68 40 86 00 00 push $0x8640
1699: 50 push %eax
169a: e8 1b 22 00 00 call 38ba <read>
169f: 83 c4 10 add $0x10,%esp
16a2: 83 f8 05 cmp $0x5,%eax
16a5: 0f 85 c6 00 00 00 jne 1771 <linktest+0x1b1>
close(fd);
16ab: 83 ec 0c sub $0xc,%esp
16ae: 53 push %ebx
16af: e8 16 22 00 00 call 38ca <close>
if(link("lf2", "lf2") >= 0){
16b4: 58 pop %eax
16b5: 5a pop %edx
16b6: 68 0a 43 00 00 push $0x430a
16bb: 68 0a 43 00 00 push $0x430a
16c0: e8 3d 22 00 00 call 3902 <link>
16c5: 83 c4 10 add $0x10,%esp
16c8: 85 c0 test %eax,%eax
16ca: 0f 89 8e 00 00 00 jns 175e <linktest+0x19e>
unlink("lf2");
16d0: 83 ec 0c sub $0xc,%esp
16d3: 68 0a 43 00 00 push $0x430a
16d8: e8 15 22 00 00 call 38f2 <unlink>
if(link("lf2", "lf1") >= 0){
16dd: 59 pop %ecx
16de: 5b pop %ebx
16df: 68 06 43 00 00 push $0x4306
16e4: 68 0a 43 00 00 push $0x430a
16e9: e8 14 22 00 00 call 3902 <link>
16ee: 83 c4 10 add $0x10,%esp
16f1: 85 c0 test %eax,%eax
16f3: 79 56 jns 174b <linktest+0x18b>
if(link(".", "lf1") >= 0){
16f5: 83 ec 08 sub $0x8,%esp
16f8: 68 06 43 00 00 push $0x4306
16fd: 68 ce 45 00 00 push $0x45ce
1702: e8 fb 21 00 00 call 3902 <link>
1707: 83 c4 10 add $0x10,%esp
170a: 85 c0 test %eax,%eax
170c: 79 2a jns 1738 <linktest+0x178>
printf(1, "linktest ok\n");
170e: 83 ec 08 sub $0x8,%esp
1711: 68 a4 43 00 00 push $0x43a4
1716: 6a 01 push $0x1
1718: e8 e3 22 00 00 call 3a00 <printf>
}
171d: 83 c4 10 add $0x10,%esp
1720: 8b 5d fc mov -0x4(%ebp),%ebx
1723: c9 leave
1724: c3 ret
printf(1, "create lf1 failed\n");
1725: 50 push %eax
1726: 50 push %eax
1727: 68 0e 43 00 00 push $0x430e
172c: 6a 01 push $0x1
172e: e8 cd 22 00 00 call 3a00 <printf>
exit();
1733: e8 6a 21 00 00 call 38a2 <exit>
printf(1, "link . lf1 succeeded! oops\n");
1738: 50 push %eax
1739: 50 push %eax
173a: 68 88 43 00 00 push $0x4388
173f: 6a 01 push $0x1
1741: e8 ba 22 00 00 call 3a00 <printf>
exit();
1746: e8 57 21 00 00 call 38a2 <exit>
printf(1, "link non-existant succeeded! oops\n");
174b: 52 push %edx
174c: 52 push %edx
174d: 68 3c 4f 00 00 push $0x4f3c
1752: 6a 01 push $0x1
1754: e8 a7 22 00 00 call 3a00 <printf>
exit();
1759: e8 44 21 00 00 call 38a2 <exit>
printf(1, "link lf2 lf2 succeeded! oops\n");
175e: 50 push %eax
175f: 50 push %eax
1760: 68 6a 43 00 00 push $0x436a
1765: 6a 01 push $0x1
1767: e8 94 22 00 00 call 3a00 <printf>
exit();
176c: e8 31 21 00 00 call 38a2 <exit>
printf(1, "read lf2 failed\n");
1771: 51 push %ecx
1772: 51 push %ecx
1773: 68 59 43 00 00 push $0x4359
1778: 6a 01 push $0x1
177a: e8 81 22 00 00 call 3a00 <printf>
exit();
177f: e8 1e 21 00 00 call 38a2 <exit>
printf(1, "open lf2 failed\n");
1784: 53 push %ebx
1785: 53 push %ebx
1786: 68 48 43 00 00 push $0x4348
178b: 6a 01 push $0x1
178d: e8 6e 22 00 00 call 3a00 <printf>
exit();
1792: e8 0b 21 00 00 call 38a2 <exit>
printf(1, "unlinked lf1 but it is still there!\n");
1797: 50 push %eax
1798: 50 push %eax
1799: 68 14 4f 00 00 push $0x4f14
179e: 6a 01 push $0x1
17a0: e8 5b 22 00 00 call 3a00 <printf>
exit();
17a5: e8 f8 20 00 00 call 38a2 <exit>
printf(1, "link lf1 lf2 failed\n");
17aa: 51 push %ecx
17ab: 51 push %ecx
17ac: 68 33 43 00 00 push $0x4333
17b1: 6a 01 push $0x1
17b3: e8 48 22 00 00 call 3a00 <printf>
exit();
17b8: e8 e5 20 00 00 call 38a2 <exit>
printf(1, "write lf1 failed\n");
17bd: 50 push %eax
17be: 50 push %eax
17bf: 68 21 43 00 00 push $0x4321
17c4: 6a 01 push $0x1
17c6: e8 35 22 00 00 call 3a00 <printf>
exit();
17cb: e8 d2 20 00 00 call 38a2 <exit>
000017d0 <concreate>:
{
17d0: 55 push %ebp
17d1: 89 e5 mov %esp,%ebp
17d3: 57 push %edi
17d4: 56 push %esi
17d5: 53 push %ebx
for(i = 0; i < 40; i++){
17d6: 31 f6 xor %esi,%esi
17d8: 8d 5d ad lea -0x53(%ebp),%ebx
if(pid && (i % 3) == 1){
17db: bf ab aa aa aa mov $0xaaaaaaab,%edi
{
17e0: 83 ec 64 sub $0x64,%esp
printf(1, "concreate test\n");
17e3: 68 b1 43 00 00 push $0x43b1
17e8: 6a 01 push $0x1
17ea: e8 11 22 00 00 call 3a00 <printf>
file[0] = 'C';
17ef: c6 45 ad 43 movb $0x43,-0x53(%ebp)
file[2] = '\0';
17f3: c6 45 af 00 movb $0x0,-0x51(%ebp)
17f7: 83 c4 10 add $0x10,%esp
17fa: eb 4c jmp 1848 <concreate+0x78>
17fc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
if(pid && (i % 3) == 1){
1800: 89 f0 mov %esi,%eax
1802: 89 f1 mov %esi,%ecx
1804: f7 e7 mul %edi
1806: d1 ea shr %edx
1808: 8d 04 52 lea (%edx,%edx,2),%eax
180b: 29 c1 sub %eax,%ecx
180d: 83 f9 01 cmp $0x1,%ecx
1810: 0f 84 ba 00 00 00 je 18d0 <concreate+0x100>
fd = open(file, O_CREATE | O_RDWR);
1816: 83 ec 08 sub $0x8,%esp
1819: 68 02 02 00 00 push $0x202
181e: 53 push %ebx
181f: e8 be 20 00 00 call 38e2 <open>
if(fd < 0){
1824: 83 c4 10 add $0x10,%esp
1827: 85 c0 test %eax,%eax
1829: 78 67 js 1892 <concreate+0xc2>
close(fd);
182b: 83 ec 0c sub $0xc,%esp
for(i = 0; i < 40; i++){
182e: 83 c6 01 add $0x1,%esi
close(fd);
1831: 50 push %eax
1832: e8 93 20 00 00 call 38ca <close>
1837: 83 c4 10 add $0x10,%esp
wait();
183a: e8 6b 20 00 00 call 38aa <wait>
for(i = 0; i < 40; i++){
183f: 83 fe 28 cmp $0x28,%esi
1842: 0f 84 aa 00 00 00 je 18f2 <concreate+0x122>
unlink(file);
1848: 83 ec 0c sub $0xc,%esp
file[1] = '0' + i;
184b: 8d 46 30 lea 0x30(%esi),%eax
unlink(file);
184e: 53 push %ebx
file[1] = '0' + i;
184f: 88 45 ae mov %al,-0x52(%ebp)
unlink(file);
1852: e8 9b 20 00 00 call 38f2 <unlink>
pid = fork();
1857: e8 3e 20 00 00 call 389a <fork>
if(pid && (i % 3) == 1){
185c: 83 c4 10 add $0x10,%esp
185f: 85 c0 test %eax,%eax
1861: 75 9d jne 1800 <concreate+0x30>
} else if(pid == 0 && (i % 5) == 1){
1863: 89 f0 mov %esi,%eax
1865: ba cd cc cc cc mov $0xcccccccd,%edx
186a: f7 e2 mul %edx
186c: c1 ea 02 shr $0x2,%edx
186f: 8d 04 92 lea (%edx,%edx,4),%eax
1872: 29 c6 sub %eax,%esi
1874: 83 fe 01 cmp $0x1,%esi
1877: 74 37 je 18b0 <concreate+0xe0>
fd = open(file, O_CREATE | O_RDWR);
1879: 83 ec 08 sub $0x8,%esp
187c: 68 02 02 00 00 push $0x202
1881: 53 push %ebx
1882: e8 5b 20 00 00 call 38e2 <open>
if(fd < 0){
1887: 83 c4 10 add $0x10,%esp
188a: 85 c0 test %eax,%eax
188c: 0f 89 28 02 00 00 jns 1aba <concreate+0x2ea>
printf(1, "concreate create %s failed\n", file);
1892: 83 ec 04 sub $0x4,%esp
1895: 53 push %ebx
1896: 68 c4 43 00 00 push $0x43c4
189b: 6a 01 push $0x1
189d: e8 5e 21 00 00 call 3a00 <printf>
exit();
18a2: e8 fb 1f 00 00 call 38a2 <exit>
18a7: 89 f6 mov %esi,%esi
18a9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
link("C0", file);
18b0: 83 ec 08 sub $0x8,%esp
18b3: 53 push %ebx
18b4: 68 c1 43 00 00 push $0x43c1
18b9: e8 44 20 00 00 call 3902 <link>
18be: 83 c4 10 add $0x10,%esp
exit();
18c1: e8 dc 1f 00 00 call 38a2 <exit>
18c6: 8d 76 00 lea 0x0(%esi),%esi
18c9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
link("C0", file);
18d0: 83 ec 08 sub $0x8,%esp
for(i = 0; i < 40; i++){
18d3: 83 c6 01 add $0x1,%esi
link("C0", file);
18d6: 53 push %ebx
18d7: 68 c1 43 00 00 push $0x43c1
18dc: e8 21 20 00 00 call 3902 <link>
18e1: 83 c4 10 add $0x10,%esp
wait();
18e4: e8 c1 1f 00 00 call 38aa <wait>
for(i = 0; i < 40; i++){
18e9: 83 fe 28 cmp $0x28,%esi
18ec: 0f 85 56 ff ff ff jne 1848 <concreate+0x78>
memset(fa, 0, sizeof(fa));
18f2: 8d 45 c0 lea -0x40(%ebp),%eax
18f5: 83 ec 04 sub $0x4,%esp
18f8: 6a 28 push $0x28
18fa: 6a 00 push $0x0
18fc: 50 push %eax
18fd: e8 fe 1d 00 00 call 3700 <memset>
fd = open(".", 0);
1902: 5f pop %edi
1903: 58 pop %eax
1904: 6a 00 push $0x0
1906: 68 ce 45 00 00 push $0x45ce
190b: 8d 7d b0 lea -0x50(%ebp),%edi
190e: e8 cf 1f 00 00 call 38e2 <open>
while(read(fd, &de, sizeof(de)) > 0){
1913: 83 c4 10 add $0x10,%esp
fd = open(".", 0);
1916: 89 c6 mov %eax,%esi
n = 0;
1918: c7 45 a4 00 00 00 00 movl $0x0,-0x5c(%ebp)
191f: 90 nop
while(read(fd, &de, sizeof(de)) > 0){
1920: 83 ec 04 sub $0x4,%esp
1923: 6a 10 push $0x10
1925: 57 push %edi
1926: 56 push %esi
1927: e8 8e 1f 00 00 call 38ba <read>
192c: 83 c4 10 add $0x10,%esp
192f: 85 c0 test %eax,%eax
1931: 7e 3d jle 1970 <concreate+0x1a0>
if(de.inum == 0)
1933: 66 83 7d b0 00 cmpw $0x0,-0x50(%ebp)
1938: 74 e6 je 1920 <concreate+0x150>
if(de.name[0] == 'C' && de.name[2] == '\0'){
193a: 80 7d b2 43 cmpb $0x43,-0x4e(%ebp)
193e: 75 e0 jne 1920 <concreate+0x150>
1940: 80 7d b4 00 cmpb $0x0,-0x4c(%ebp)
1944: 75 da jne 1920 <concreate+0x150>
i = de.name[1] - '0';
1946: 0f be 45 b3 movsbl -0x4d(%ebp),%eax
194a: 83 e8 30 sub $0x30,%eax
if(i < 0 || i >= sizeof(fa)){
194d: 83 f8 27 cmp $0x27,%eax
1950: 0f 87 4e 01 00 00 ja 1aa4 <concreate+0x2d4>
if(fa[i]){
1956: 80 7c 05 c0 00 cmpb $0x0,-0x40(%ebp,%eax,1)
195b: 0f 85 2d 01 00 00 jne 1a8e <concreate+0x2be>
fa[i] = 1;
1961: c6 44 05 c0 01 movb $0x1,-0x40(%ebp,%eax,1)
n++;
1966: 83 45 a4 01 addl $0x1,-0x5c(%ebp)
196a: eb b4 jmp 1920 <concreate+0x150>
196c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
close(fd);
1970: 83 ec 0c sub $0xc,%esp
1973: 56 push %esi
1974: e8 51 1f 00 00 call 38ca <close>
if(n != 40){
1979: 83 c4 10 add $0x10,%esp
197c: 83 7d a4 28 cmpl $0x28,-0x5c(%ebp)
1980: 0f 85 f5 00 00 00 jne 1a7b <concreate+0x2ab>
for(i = 0; i < 40; i++){
1986: 31 f6 xor %esi,%esi
1988: eb 48 jmp 19d2 <concreate+0x202>
198a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
((i % 3) == 1 && pid != 0)){
1990: 85 ff test %edi,%edi
1992: 74 05 je 1999 <concreate+0x1c9>
1994: 83 fa 01 cmp $0x1,%edx
1997: 74 64 je 19fd <concreate+0x22d>
unlink(file);
1999: 83 ec 0c sub $0xc,%esp
199c: 53 push %ebx
199d: e8 50 1f 00 00 call 38f2 <unlink>
unlink(file);
19a2: 89 1c 24 mov %ebx,(%esp)
19a5: e8 48 1f 00 00 call 38f2 <unlink>
unlink(file);
19aa: 89 1c 24 mov %ebx,(%esp)
19ad: e8 40 1f 00 00 call 38f2 <unlink>
unlink(file);
19b2: 89 1c 24 mov %ebx,(%esp)
19b5: e8 38 1f 00 00 call 38f2 <unlink>
19ba: 83 c4 10 add $0x10,%esp
if(pid == 0)
19bd: 85 ff test %edi,%edi
19bf: 0f 84 fc fe ff ff je 18c1 <concreate+0xf1>
for(i = 0; i < 40; i++){
19c5: 83 c6 01 add $0x1,%esi
wait();
19c8: e8 dd 1e 00 00 call 38aa <wait>
for(i = 0; i < 40; i++){
19cd: 83 fe 28 cmp $0x28,%esi
19d0: 74 7e je 1a50 <concreate+0x280>
file[1] = '0' + i;
19d2: 8d 46 30 lea 0x30(%esi),%eax
19d5: 88 45 ae mov %al,-0x52(%ebp)
pid = fork();
19d8: e8 bd 1e 00 00 call 389a <fork>
if(pid < 0){
19dd: 85 c0 test %eax,%eax
pid = fork();
19df: 89 c7 mov %eax,%edi
if(pid < 0){
19e1: 0f 88 80 00 00 00 js 1a67 <concreate+0x297>
if(((i % 3) == 0 && pid == 0) ||
19e7: b8 ab aa aa aa mov $0xaaaaaaab,%eax
19ec: f7 e6 mul %esi
19ee: d1 ea shr %edx
19f0: 8d 04 52 lea (%edx,%edx,2),%eax
19f3: 89 f2 mov %esi,%edx
19f5: 29 c2 sub %eax,%edx
19f7: 89 d0 mov %edx,%eax
19f9: 09 f8 or %edi,%eax
19fb: 75 93 jne 1990 <concreate+0x1c0>
close(open(file, 0));
19fd: 83 ec 08 sub $0x8,%esp
1a00: 6a 00 push $0x0
1a02: 53 push %ebx
1a03: e8 da 1e 00 00 call 38e2 <open>
1a08: 89 04 24 mov %eax,(%esp)
1a0b: e8 ba 1e 00 00 call 38ca <close>
close(open(file, 0));
1a10: 58 pop %eax
1a11: 5a pop %edx
1a12: 6a 00 push $0x0
1a14: 53 push %ebx
1a15: e8 c8 1e 00 00 call 38e2 <open>
1a1a: 89 04 24 mov %eax,(%esp)
1a1d: e8 a8 1e 00 00 call 38ca <close>
close(open(file, 0));
1a22: 59 pop %ecx
1a23: 58 pop %eax
1a24: 6a 00 push $0x0
1a26: 53 push %ebx
1a27: e8 b6 1e 00 00 call 38e2 <open>
1a2c: 89 04 24 mov %eax,(%esp)
1a2f: e8 96 1e 00 00 call 38ca <close>
close(open(file, 0));
1a34: 58 pop %eax
1a35: 5a pop %edx
1a36: 6a 00 push $0x0
1a38: 53 push %ebx
1a39: e8 a4 1e 00 00 call 38e2 <open>
1a3e: 89 04 24 mov %eax,(%esp)
1a41: e8 84 1e 00 00 call 38ca <close>
1a46: 83 c4 10 add $0x10,%esp
1a49: e9 6f ff ff ff jmp 19bd <concreate+0x1ed>
1a4e: 66 90 xchg %ax,%ax
printf(1, "concreate ok\n");
1a50: 83 ec 08 sub $0x8,%esp
1a53: 68 16 44 00 00 push $0x4416
1a58: 6a 01 push $0x1
1a5a: e8 a1 1f 00 00 call 3a00 <printf>
}
1a5f: 8d 65 f4 lea -0xc(%ebp),%esp
1a62: 5b pop %ebx
1a63: 5e pop %esi
1a64: 5f pop %edi
1a65: 5d pop %ebp
1a66: c3 ret
printf(1, "fork failed\n");
1a67: 83 ec 08 sub $0x8,%esp
1a6a: 68 99 4c 00 00 push $0x4c99
1a6f: 6a 01 push $0x1
1a71: e8 8a 1f 00 00 call 3a00 <printf>
exit();
1a76: e8 27 1e 00 00 call 38a2 <exit>
printf(1, "concreate not enough files in directory listing\n");
1a7b: 51 push %ecx
1a7c: 51 push %ecx
1a7d: 68 60 4f 00 00 push $0x4f60
1a82: 6a 01 push $0x1
1a84: e8 77 1f 00 00 call 3a00 <printf>
exit();
1a89: e8 14 1e 00 00 call 38a2 <exit>
printf(1, "concreate duplicate file %s\n", de.name);
1a8e: 8d 45 b2 lea -0x4e(%ebp),%eax
1a91: 53 push %ebx
1a92: 50 push %eax
1a93: 68 f9 43 00 00 push $0x43f9
1a98: 6a 01 push $0x1
1a9a: e8 61 1f 00 00 call 3a00 <printf>
exit();
1a9f: e8 fe 1d 00 00 call 38a2 <exit>
printf(1, "concreate weird file %s\n", de.name);
1aa4: 8d 45 b2 lea -0x4e(%ebp),%eax
1aa7: 56 push %esi
1aa8: 50 push %eax
1aa9: 68 e0 43 00 00 push $0x43e0
1aae: 6a 01 push $0x1
1ab0: e8 4b 1f 00 00 call 3a00 <printf>
exit();
1ab5: e8 e8 1d 00 00 call 38a2 <exit>
close(fd);
1aba: 83 ec 0c sub $0xc,%esp
1abd: 50 push %eax
1abe: e8 07 1e 00 00 call 38ca <close>
1ac3: 83 c4 10 add $0x10,%esp
1ac6: e9 f6 fd ff ff jmp 18c1 <concreate+0xf1>
1acb: 90 nop
1acc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
00001ad0 <linkunlink>:
{
1ad0: 55 push %ebp
1ad1: 89 e5 mov %esp,%ebp
1ad3: 57 push %edi
1ad4: 56 push %esi
1ad5: 53 push %ebx
1ad6: 83 ec 24 sub $0x24,%esp
printf(1, "linkunlink test\n");
1ad9: 68 24 44 00 00 push $0x4424
1ade: 6a 01 push $0x1
1ae0: e8 1b 1f 00 00 call 3a00 <printf>
unlink("x");
1ae5: c7 04 24 b1 46 00 00 movl $0x46b1,(%esp)
1aec: e8 01 1e 00 00 call 38f2 <unlink>
pid = fork();
1af1: e8 a4 1d 00 00 call 389a <fork>
if(pid < 0){
1af6: 83 c4 10 add $0x10,%esp
1af9: 85 c0 test %eax,%eax
pid = fork();
1afb: 89 45 e4 mov %eax,-0x1c(%ebp)
if(pid < 0){
1afe: 0f 88 b6 00 00 00 js 1bba <linkunlink+0xea>
unsigned int x = (pid ? 1 : 97);
1b04: 83 7d e4 01 cmpl $0x1,-0x1c(%ebp)
1b08: bb 64 00 00 00 mov $0x64,%ebx
if((x % 3) == 0){
1b0d: be ab aa aa aa mov $0xaaaaaaab,%esi
unsigned int x = (pid ? 1 : 97);
1b12: 19 ff sbb %edi,%edi
1b14: 83 e7 60 and $0x60,%edi
1b17: 83 c7 01 add $0x1,%edi
1b1a: eb 1e jmp 1b3a <linkunlink+0x6a>
1b1c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
} else if((x % 3) == 1){
1b20: 83 fa 01 cmp $0x1,%edx
1b23: 74 7b je 1ba0 <linkunlink+0xd0>
unlink("x");
1b25: 83 ec 0c sub $0xc,%esp
1b28: 68 b1 46 00 00 push $0x46b1
1b2d: e8 c0 1d 00 00 call 38f2 <unlink>
1b32: 83 c4 10 add $0x10,%esp
for(i = 0; i < 100; i++){
1b35: 83 eb 01 sub $0x1,%ebx
1b38: 74 3d je 1b77 <linkunlink+0xa7>
x = x * 1103515245 + 12345;
1b3a: 69 cf 6d 4e c6 41 imul $0x41c64e6d,%edi,%ecx
1b40: 8d b9 39 30 00 00 lea 0x3039(%ecx),%edi
if((x % 3) == 0){
1b46: 89 f8 mov %edi,%eax
1b48: f7 e6 mul %esi
1b4a: d1 ea shr %edx
1b4c: 8d 04 52 lea (%edx,%edx,2),%eax
1b4f: 89 fa mov %edi,%edx
1b51: 29 c2 sub %eax,%edx
1b53: 75 cb jne 1b20 <linkunlink+0x50>
close(open("x", O_RDWR | O_CREATE));
1b55: 83 ec 08 sub $0x8,%esp
1b58: 68 02 02 00 00 push $0x202
1b5d: 68 b1 46 00 00 push $0x46b1
1b62: e8 7b 1d 00 00 call 38e2 <open>
1b67: 89 04 24 mov %eax,(%esp)
1b6a: e8 5b 1d 00 00 call 38ca <close>
1b6f: 83 c4 10 add $0x10,%esp
for(i = 0; i < 100; i++){
1b72: 83 eb 01 sub $0x1,%ebx
1b75: 75 c3 jne 1b3a <linkunlink+0x6a>
if(pid)
1b77: 8b 45 e4 mov -0x1c(%ebp),%eax
1b7a: 85 c0 test %eax,%eax
1b7c: 74 4f je 1bcd <linkunlink+0xfd>
wait();
1b7e: e8 27 1d 00 00 call 38aa <wait>
printf(1, "linkunlink ok\n");
1b83: 83 ec 08 sub $0x8,%esp
1b86: 68 39 44 00 00 push $0x4439
1b8b: 6a 01 push $0x1
1b8d: e8 6e 1e 00 00 call 3a00 <printf>
}
1b92: 8d 65 f4 lea -0xc(%ebp),%esp
1b95: 5b pop %ebx
1b96: 5e pop %esi
1b97: 5f pop %edi
1b98: 5d pop %ebp
1b99: c3 ret
1b9a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
link("cat", "x");
1ba0: 83 ec 08 sub $0x8,%esp
1ba3: 68 b1 46 00 00 push $0x46b1
1ba8: 68 35 44 00 00 push $0x4435
1bad: e8 50 1d 00 00 call 3902 <link>
1bb2: 83 c4 10 add $0x10,%esp
1bb5: e9 7b ff ff ff jmp 1b35 <linkunlink+0x65>
printf(1, "fork failed\n");
1bba: 52 push %edx
1bbb: 52 push %edx
1bbc: 68 99 4c 00 00 push $0x4c99
1bc1: 6a 01 push $0x1
1bc3: e8 38 1e 00 00 call 3a00 <printf>
exit();
1bc8: e8 d5 1c 00 00 call 38a2 <exit>
exit();
1bcd: e8 d0 1c 00 00 call 38a2 <exit>
1bd2: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
1bd9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
00001be0 <bigdir>:
{
1be0: 55 push %ebp
1be1: 89 e5 mov %esp,%ebp
1be3: 57 push %edi
1be4: 56 push %esi
1be5: 53 push %ebx
1be6: 83 ec 24 sub $0x24,%esp
printf(1, "bigdir test\n");
1be9: 68 48 44 00 00 push $0x4448
1bee: 6a 01 push $0x1
1bf0: e8 0b 1e 00 00 call 3a00 <printf>
unlink("bd");
1bf5: c7 04 24 55 44 00 00 movl $0x4455,(%esp)
1bfc: e8 f1 1c 00 00 call 38f2 <unlink>
fd = open("bd", O_CREATE);
1c01: 5a pop %edx
1c02: 59 pop %ecx
1c03: 68 00 02 00 00 push $0x200
1c08: 68 55 44 00 00 push $0x4455
1c0d: e8 d0 1c 00 00 call 38e2 <open>
if(fd < 0){
1c12: 83 c4 10 add $0x10,%esp
1c15: 85 c0 test %eax,%eax
1c17: 0f 88 de 00 00 00 js 1cfb <bigdir+0x11b>
close(fd);
1c1d: 83 ec 0c sub $0xc,%esp
1c20: 8d 7d de lea -0x22(%ebp),%edi
for(i = 0; i < 500; i++){
1c23: 31 f6 xor %esi,%esi
close(fd);
1c25: 50 push %eax
1c26: e8 9f 1c 00 00 call 38ca <close>
1c2b: 83 c4 10 add $0x10,%esp
1c2e: 66 90 xchg %ax,%ax
name[1] = '0' + (i / 64);
1c30: 89 f0 mov %esi,%eax
if(link("bd", name) != 0){
1c32: 83 ec 08 sub $0x8,%esp
name[0] = 'x';
1c35: c6 45 de 78 movb $0x78,-0x22(%ebp)
name[1] = '0' + (i / 64);
1c39: c1 f8 06 sar $0x6,%eax
if(link("bd", name) != 0){
1c3c: 57 push %edi
1c3d: 68 55 44 00 00 push $0x4455
name[1] = '0' + (i / 64);
1c42: 83 c0 30 add $0x30,%eax
name[3] = '\0';
1c45: c6 45 e1 00 movb $0x0,-0x1f(%ebp)
name[1] = '0' + (i / 64);
1c49: 88 45 df mov %al,-0x21(%ebp)
name[2] = '0' + (i % 64);
1c4c: 89 f0 mov %esi,%eax
1c4e: 83 e0 3f and $0x3f,%eax
1c51: 83 c0 30 add $0x30,%eax
1c54: 88 45 e0 mov %al,-0x20(%ebp)
if(link("bd", name) != 0){
1c57: e8 a6 1c 00 00 call 3902 <link>
1c5c: 83 c4 10 add $0x10,%esp
1c5f: 85 c0 test %eax,%eax
1c61: 89 c3 mov %eax,%ebx
1c63: 75 6e jne 1cd3 <bigdir+0xf3>
for(i = 0; i < 500; i++){
1c65: 83 c6 01 add $0x1,%esi
1c68: 81 fe f4 01 00 00 cmp $0x1f4,%esi
1c6e: 75 c0 jne 1c30 <bigdir+0x50>
unlink("bd");
1c70: 83 ec 0c sub $0xc,%esp
1c73: 68 55 44 00 00 push $0x4455
1c78: e8 75 1c 00 00 call 38f2 <unlink>
1c7d: 83 c4 10 add $0x10,%esp
name[1] = '0' + (i / 64);
1c80: 89 d8 mov %ebx,%eax
if(unlink(name) != 0){
1c82: 83 ec 0c sub $0xc,%esp
name[0] = 'x';
1c85: c6 45 de 78 movb $0x78,-0x22(%ebp)
name[1] = '0' + (i / 64);
1c89: c1 f8 06 sar $0x6,%eax
if(unlink(name) != 0){
1c8c: 57 push %edi
name[3] = '\0';
1c8d: c6 45 e1 00 movb $0x0,-0x1f(%ebp)
name[1] = '0' + (i / 64);
1c91: 83 c0 30 add $0x30,%eax
1c94: 88 45 df mov %al,-0x21(%ebp)
name[2] = '0' + (i % 64);
1c97: 89 d8 mov %ebx,%eax
1c99: 83 e0 3f and $0x3f,%eax
1c9c: 83 c0 30 add $0x30,%eax
1c9f: 88 45 e0 mov %al,-0x20(%ebp)
if(unlink(name) != 0){
1ca2: e8 4b 1c 00 00 call 38f2 <unlink>
1ca7: 83 c4 10 add $0x10,%esp
1caa: 85 c0 test %eax,%eax
1cac: 75 39 jne 1ce7 <bigdir+0x107>
for(i = 0; i < 500; i++){
1cae: 83 c3 01 add $0x1,%ebx
1cb1: 81 fb f4 01 00 00 cmp $0x1f4,%ebx
1cb7: 75 c7 jne 1c80 <bigdir+0xa0>
printf(1, "bigdir ok\n");
1cb9: 83 ec 08 sub $0x8,%esp
1cbc: 68 97 44 00 00 push $0x4497
1cc1: 6a 01 push $0x1
1cc3: e8 38 1d 00 00 call 3a00 <printf>
}
1cc8: 83 c4 10 add $0x10,%esp
1ccb: 8d 65 f4 lea -0xc(%ebp),%esp
1cce: 5b pop %ebx
1ccf: 5e pop %esi
1cd0: 5f pop %edi
1cd1: 5d pop %ebp
1cd2: c3 ret
printf(1, "bigdir link failed\n");
1cd3: 83 ec 08 sub $0x8,%esp
1cd6: 68 6e 44 00 00 push $0x446e
1cdb: 6a 01 push $0x1
1cdd: e8 1e 1d 00 00 call 3a00 <printf>
exit();
1ce2: e8 bb 1b 00 00 call 38a2 <exit>
printf(1, "bigdir unlink failed");
1ce7: 83 ec 08 sub $0x8,%esp
1cea: 68 82 44 00 00 push $0x4482
1cef: 6a 01 push $0x1
1cf1: e8 0a 1d 00 00 call 3a00 <printf>
exit();
1cf6: e8 a7 1b 00 00 call 38a2 <exit>
printf(1, "bigdir create failed\n");
1cfb: 50 push %eax
1cfc: 50 push %eax
1cfd: 68 58 44 00 00 push $0x4458
1d02: 6a 01 push $0x1
1d04: e8 f7 1c 00 00 call 3a00 <printf>
exit();
1d09: e8 94 1b 00 00 call 38a2 <exit>
1d0e: 66 90 xchg %ax,%ax
00001d10 <subdir>:
{
1d10: 55 push %ebp
1d11: 89 e5 mov %esp,%ebp
1d13: 53 push %ebx
1d14: 83 ec 0c sub $0xc,%esp
printf(1, "subdir test\n");
1d17: 68 a2 44 00 00 push $0x44a2
1d1c: 6a 01 push $0x1
1d1e: e8 dd 1c 00 00 call 3a00 <printf>
unlink("ff");
1d23: c7 04 24 2b 45 00 00 movl $0x452b,(%esp)
1d2a: e8 c3 1b 00 00 call 38f2 <unlink>
if(mkdir("dd") != 0){
1d2f: c7 04 24 c8 45 00 00 movl $0x45c8,(%esp)
1d36: e8 cf 1b 00 00 call 390a <mkdir>
1d3b: 83 c4 10 add $0x10,%esp
1d3e: 85 c0 test %eax,%eax
1d40: 0f 85 b3 05 00 00 jne 22f9 <subdir+0x5e9>
fd = open("dd/ff", O_CREATE | O_RDWR);
1d46: 83 ec 08 sub $0x8,%esp
1d49: 68 02 02 00 00 push $0x202
1d4e: 68 01 45 00 00 push $0x4501
1d53: e8 8a 1b 00 00 call 38e2 <open>
if(fd < 0){
1d58: 83 c4 10 add $0x10,%esp
1d5b: 85 c0 test %eax,%eax
fd = open("dd/ff", O_CREATE | O_RDWR);
1d5d: 89 c3 mov %eax,%ebx
if(fd < 0){
1d5f: 0f 88 81 05 00 00 js 22e6 <subdir+0x5d6>
write(fd, "ff", 2);
1d65: 83 ec 04 sub $0x4,%esp
1d68: 6a 02 push $0x2
1d6a: 68 2b 45 00 00 push $0x452b
1d6f: 50 push %eax
1d70: e8 4d 1b 00 00 call 38c2 <write>
close(fd);
1d75: 89 1c 24 mov %ebx,(%esp)
1d78: e8 4d 1b 00 00 call 38ca <close>
if(unlink("dd") >= 0){
1d7d: c7 04 24 c8 45 00 00 movl $0x45c8,(%esp)
1d84: e8 69 1b 00 00 call 38f2 <unlink>
1d89: 83 c4 10 add $0x10,%esp
1d8c: 85 c0 test %eax,%eax
1d8e: 0f 89 3f 05 00 00 jns 22d3 <subdir+0x5c3>
if(mkdir("/dd/dd") != 0){
1d94: 83 ec 0c sub $0xc,%esp
1d97: 68 dc 44 00 00 push $0x44dc
1d9c: e8 69 1b 00 00 call 390a <mkdir>
1da1: 83 c4 10 add $0x10,%esp
1da4: 85 c0 test %eax,%eax
1da6: 0f 85 14 05 00 00 jne 22c0 <subdir+0x5b0>
fd = open("dd/dd/ff", O_CREATE | O_RDWR);
1dac: 83 ec 08 sub $0x8,%esp
1daf: 68 02 02 00 00 push $0x202
1db4: 68 fe 44 00 00 push $0x44fe
1db9: e8 24 1b 00 00 call 38e2 <open>
if(fd < 0){
1dbe: 83 c4 10 add $0x10,%esp
1dc1: 85 c0 test %eax,%eax
fd = open("dd/dd/ff", O_CREATE | O_RDWR);
1dc3: 89 c3 mov %eax,%ebx
if(fd < 0){
1dc5: 0f 88 24 04 00 00 js 21ef <subdir+0x4df>
write(fd, "FF", 2);
1dcb: 83 ec 04 sub $0x4,%esp
1dce: 6a 02 push $0x2
1dd0: 68 1f 45 00 00 push $0x451f
1dd5: 50 push %eax
1dd6: e8 e7 1a 00 00 call 38c2 <write>
close(fd);
1ddb: 89 1c 24 mov %ebx,(%esp)
1dde: e8 e7 1a 00 00 call 38ca <close>
fd = open("dd/dd/../ff", 0);
1de3: 58 pop %eax
1de4: 5a pop %edx
1de5: 6a 00 push $0x0
1de7: 68 22 45 00 00 push $0x4522
1dec: e8 f1 1a 00 00 call 38e2 <open>
if(fd < 0){
1df1: 83 c4 10 add $0x10,%esp
1df4: 85 c0 test %eax,%eax
fd = open("dd/dd/../ff", 0);
1df6: 89 c3 mov %eax,%ebx
if(fd < 0){
1df8: 0f 88 de 03 00 00 js 21dc <subdir+0x4cc>
cc = read(fd, buf, sizeof(buf));
1dfe: 83 ec 04 sub $0x4,%esp
1e01: 68 00 20 00 00 push $0x2000
1e06: 68 40 86 00 00 push $0x8640
1e0b: 50 push %eax
1e0c: e8 a9 1a 00 00 call 38ba <read>
if(cc != 2 || buf[0] != 'f'){
1e11: 83 c4 10 add $0x10,%esp
1e14: 83 f8 02 cmp $0x2,%eax
1e17: 0f 85 3a 03 00 00 jne 2157 <subdir+0x447>
1e1d: 80 3d 40 86 00 00 66 cmpb $0x66,0x8640
1e24: 0f 85 2d 03 00 00 jne 2157 <subdir+0x447>
close(fd);
1e2a: 83 ec 0c sub $0xc,%esp
1e2d: 53 push %ebx
1e2e: e8 97 1a 00 00 call 38ca <close>
if(link("dd/dd/ff", "dd/dd/ffff") != 0){
1e33: 5b pop %ebx
1e34: 58 pop %eax
1e35: 68 62 45 00 00 push $0x4562
1e3a: 68 fe 44 00 00 push $0x44fe
1e3f: e8 be 1a 00 00 call 3902 <link>
1e44: 83 c4 10 add $0x10,%esp
1e47: 85 c0 test %eax,%eax
1e49: 0f 85 c6 03 00 00 jne 2215 <subdir+0x505>
if(unlink("dd/dd/ff") != 0){
1e4f: 83 ec 0c sub $0xc,%esp
1e52: 68 fe 44 00 00 push $0x44fe
1e57: e8 96 1a 00 00 call 38f2 <unlink>
1e5c: 83 c4 10 add $0x10,%esp
1e5f: 85 c0 test %eax,%eax
1e61: 0f 85 16 03 00 00 jne 217d <subdir+0x46d>
if(open("dd/dd/ff", O_RDONLY) >= 0){
1e67: 83 ec 08 sub $0x8,%esp
1e6a: 6a 00 push $0x0
1e6c: 68 fe 44 00 00 push $0x44fe
1e71: e8 6c 1a 00 00 call 38e2 <open>
1e76: 83 c4 10 add $0x10,%esp
1e79: 85 c0 test %eax,%eax
1e7b: 0f 89 2c 04 00 00 jns 22ad <subdir+0x59d>
if(chdir("dd") != 0){
1e81: 83 ec 0c sub $0xc,%esp
1e84: 68 c8 45 00 00 push $0x45c8
1e89: e8 84 1a 00 00 call 3912 <chdir>
1e8e: 83 c4 10 add $0x10,%esp
1e91: 85 c0 test %eax,%eax
1e93: 0f 85 01 04 00 00 jne 229a <subdir+0x58a>
if(chdir("dd/../../dd") != 0){
1e99: 83 ec 0c sub $0xc,%esp
1e9c: 68 96 45 00 00 push $0x4596
1ea1: e8 6c 1a 00 00 call 3912 <chdir>
1ea6: 83 c4 10 add $0x10,%esp
1ea9: 85 c0 test %eax,%eax
1eab: 0f 85 b9 02 00 00 jne 216a <subdir+0x45a>
if(chdir("dd/../../../dd") != 0){
1eb1: 83 ec 0c sub $0xc,%esp
1eb4: 68 bc 45 00 00 push $0x45bc
1eb9: e8 54 1a 00 00 call 3912 <chdir>
1ebe: 83 c4 10 add $0x10,%esp
1ec1: 85 c0 test %eax,%eax
1ec3: 0f 85 a1 02 00 00 jne 216a <subdir+0x45a>
if(chdir("./..") != 0){
1ec9: 83 ec 0c sub $0xc,%esp
1ecc: 68 cb 45 00 00 push $0x45cb
1ed1: e8 3c 1a 00 00 call 3912 <chdir>
1ed6: 83 c4 10 add $0x10,%esp
1ed9: 85 c0 test %eax,%eax
1edb: 0f 85 21 03 00 00 jne 2202 <subdir+0x4f2>
fd = open("dd/dd/ffff", 0);
1ee1: 83 ec 08 sub $0x8,%esp
1ee4: 6a 00 push $0x0
1ee6: 68 62 45 00 00 push $0x4562
1eeb: e8 f2 19 00 00 call 38e2 <open>
if(fd < 0){
1ef0: 83 c4 10 add $0x10,%esp
1ef3: 85 c0 test %eax,%eax
fd = open("dd/dd/ffff", 0);
1ef5: 89 c3 mov %eax,%ebx
if(fd < 0){
1ef7: 0f 88 e0 04 00 00 js 23dd <subdir+0x6cd>
if(read(fd, buf, sizeof(buf)) != 2){
1efd: 83 ec 04 sub $0x4,%esp
1f00: 68 00 20 00 00 push $0x2000
1f05: 68 40 86 00 00 push $0x8640
1f0a: 50 push %eax
1f0b: e8 aa 19 00 00 call 38ba <read>
1f10: 83 c4 10 add $0x10,%esp
1f13: 83 f8 02 cmp $0x2,%eax
1f16: 0f 85 ae 04 00 00 jne 23ca <subdir+0x6ba>
close(fd);
1f1c: 83 ec 0c sub $0xc,%esp
1f1f: 53 push %ebx
1f20: e8 a5 19 00 00 call 38ca <close>
if(open("dd/dd/ff", O_RDONLY) >= 0){
1f25: 59 pop %ecx
1f26: 5b pop %ebx
1f27: 6a 00 push $0x0
1f29: 68 fe 44 00 00 push $0x44fe
1f2e: e8 af 19 00 00 call 38e2 <open>
1f33: 83 c4 10 add $0x10,%esp
1f36: 85 c0 test %eax,%eax
1f38: 0f 89 65 02 00 00 jns 21a3 <subdir+0x493>
if(open("dd/ff/ff", O_CREATE|O_RDWR) >= 0){
1f3e: 83 ec 08 sub $0x8,%esp
1f41: 68 02 02 00 00 push $0x202
1f46: 68 16 46 00 00 push $0x4616
1f4b: e8 92 19 00 00 call 38e2 <open>
1f50: 83 c4 10 add $0x10,%esp
1f53: 85 c0 test %eax,%eax
1f55: 0f 89 35 02 00 00 jns 2190 <subdir+0x480>
if(open("dd/xx/ff", O_CREATE|O_RDWR) >= 0){
1f5b: 83 ec 08 sub $0x8,%esp
1f5e: 68 02 02 00 00 push $0x202
1f63: 68 3b 46 00 00 push $0x463b
1f68: e8 75 19 00 00 call 38e2 <open>
1f6d: 83 c4 10 add $0x10,%esp
1f70: 85 c0 test %eax,%eax
1f72: 0f 89 0f 03 00 00 jns 2287 <subdir+0x577>
if(open("dd", O_CREATE) >= 0){
1f78: 83 ec 08 sub $0x8,%esp
1f7b: 68 00 02 00 00 push $0x200
1f80: 68 c8 45 00 00 push $0x45c8
1f85: e8 58 19 00 00 call 38e2 <open>
1f8a: 83 c4 10 add $0x10,%esp
1f8d: 85 c0 test %eax,%eax
1f8f: 0f 89 df 02 00 00 jns 2274 <subdir+0x564>
if(open("dd", O_RDWR) >= 0){
1f95: 83 ec 08 sub $0x8,%esp
1f98: 6a 02 push $0x2
1f9a: 68 c8 45 00 00 push $0x45c8
1f9f: e8 3e 19 00 00 call 38e2 <open>
1fa4: 83 c4 10 add $0x10,%esp
1fa7: 85 c0 test %eax,%eax
1fa9: 0f 89 b2 02 00 00 jns 2261 <subdir+0x551>
if(open("dd", O_WRONLY) >= 0){
1faf: 83 ec 08 sub $0x8,%esp
1fb2: 6a 01 push $0x1
1fb4: 68 c8 45 00 00 push $0x45c8
1fb9: e8 24 19 00 00 call 38e2 <open>
1fbe: 83 c4 10 add $0x10,%esp
1fc1: 85 c0 test %eax,%eax
1fc3: 0f 89 85 02 00 00 jns 224e <subdir+0x53e>
if(link("dd/ff/ff", "dd/dd/xx") == 0){
1fc9: 83 ec 08 sub $0x8,%esp
1fcc: 68 aa 46 00 00 push $0x46aa
1fd1: 68 16 46 00 00 push $0x4616
1fd6: e8 27 19 00 00 call 3902 <link>
1fdb: 83 c4 10 add $0x10,%esp
1fde: 85 c0 test %eax,%eax
1fe0: 0f 84 55 02 00 00 je 223b <subdir+0x52b>
if(link("dd/xx/ff", "dd/dd/xx") == 0){
1fe6: 83 ec 08 sub $0x8,%esp
1fe9: 68 aa 46 00 00 push $0x46aa
1fee: 68 3b 46 00 00 push $0x463b
1ff3: e8 0a 19 00 00 call 3902 <link>
1ff8: 83 c4 10 add $0x10,%esp
1ffb: 85 c0 test %eax,%eax
1ffd: 0f 84 25 02 00 00 je 2228 <subdir+0x518>
if(link("dd/ff", "dd/dd/ffff") == 0){
2003: 83 ec 08 sub $0x8,%esp
2006: 68 62 45 00 00 push $0x4562
200b: 68 01 45 00 00 push $0x4501
2010: e8 ed 18 00 00 call 3902 <link>
2015: 83 c4 10 add $0x10,%esp
2018: 85 c0 test %eax,%eax
201a: 0f 84 a9 01 00 00 je 21c9 <subdir+0x4b9>
if(mkdir("dd/ff/ff") == 0){
2020: 83 ec 0c sub $0xc,%esp
2023: 68 16 46 00 00 push $0x4616
2028: e8 dd 18 00 00 call 390a <mkdir>
202d: 83 c4 10 add $0x10,%esp
2030: 85 c0 test %eax,%eax
2032: 0f 84 7e 01 00 00 je 21b6 <subdir+0x4a6>
if(mkdir("dd/xx/ff") == 0){
2038: 83 ec 0c sub $0xc,%esp
203b: 68 3b 46 00 00 push $0x463b
2040: e8 c5 18 00 00 call 390a <mkdir>
2045: 83 c4 10 add $0x10,%esp
2048: 85 c0 test %eax,%eax
204a: 0f 84 67 03 00 00 je 23b7 <subdir+0x6a7>
if(mkdir("dd/dd/ffff") == 0){
2050: 83 ec 0c sub $0xc,%esp
2053: 68 62 45 00 00 push $0x4562
2058: e8 ad 18 00 00 call 390a <mkdir>
205d: 83 c4 10 add $0x10,%esp
2060: 85 c0 test %eax,%eax
2062: 0f 84 3c 03 00 00 je 23a4 <subdir+0x694>
if(unlink("dd/xx/ff") == 0){
2068: 83 ec 0c sub $0xc,%esp
206b: 68 3b 46 00 00 push $0x463b
2070: e8 7d 18 00 00 call 38f2 <unlink>
2075: 83 c4 10 add $0x10,%esp
2078: 85 c0 test %eax,%eax
207a: 0f 84 11 03 00 00 je 2391 <subdir+0x681>
if(unlink("dd/ff/ff") == 0){
2080: 83 ec 0c sub $0xc,%esp
2083: 68 16 46 00 00 push $0x4616
2088: e8 65 18 00 00 call 38f2 <unlink>
208d: 83 c4 10 add $0x10,%esp
2090: 85 c0 test %eax,%eax
2092: 0f 84 e6 02 00 00 je 237e <subdir+0x66e>
if(chdir("dd/ff") == 0){
2098: 83 ec 0c sub $0xc,%esp
209b: 68 01 45 00 00 push $0x4501
20a0: e8 6d 18 00 00 call 3912 <chdir>
20a5: 83 c4 10 add $0x10,%esp
20a8: 85 c0 test %eax,%eax
20aa: 0f 84 bb 02 00 00 je 236b <subdir+0x65b>
if(chdir("dd/xx") == 0){
20b0: 83 ec 0c sub $0xc,%esp
20b3: 68 ad 46 00 00 push $0x46ad
20b8: e8 55 18 00 00 call 3912 <chdir>
20bd: 83 c4 10 add $0x10,%esp
20c0: 85 c0 test %eax,%eax
20c2: 0f 84 90 02 00 00 je 2358 <subdir+0x648>
if(unlink("dd/dd/ffff") != 0){
20c8: 83 ec 0c sub $0xc,%esp
20cb: 68 62 45 00 00 push $0x4562
20d0: e8 1d 18 00 00 call 38f2 <unlink>
20d5: 83 c4 10 add $0x10,%esp
20d8: 85 c0 test %eax,%eax
20da: 0f 85 9d 00 00 00 jne 217d <subdir+0x46d>
if(unlink("dd/ff") != 0){
20e0: 83 ec 0c sub $0xc,%esp
20e3: 68 01 45 00 00 push $0x4501
20e8: e8 05 18 00 00 call 38f2 <unlink>
20ed: 83 c4 10 add $0x10,%esp
20f0: 85 c0 test %eax,%eax
20f2: 0f 85 4d 02 00 00 jne 2345 <subdir+0x635>
if(unlink("dd") == 0){
20f8: 83 ec 0c sub $0xc,%esp
20fb: 68 c8 45 00 00 push $0x45c8
2100: e8 ed 17 00 00 call 38f2 <unlink>
2105: 83 c4 10 add $0x10,%esp
2108: 85 c0 test %eax,%eax
210a: 0f 84 22 02 00 00 je 2332 <subdir+0x622>
if(unlink("dd/dd") < 0){
2110: 83 ec 0c sub $0xc,%esp
2113: 68 dd 44 00 00 push $0x44dd
2118: e8 d5 17 00 00 call 38f2 <unlink>
211d: 83 c4 10 add $0x10,%esp
2120: 85 c0 test %eax,%eax
2122: 0f 88 f7 01 00 00 js 231f <subdir+0x60f>
if(unlink("dd") < 0){
2128: 83 ec 0c sub $0xc,%esp
212b: 68 c8 45 00 00 push $0x45c8
2130: e8 bd 17 00 00 call 38f2 <unlink>
2135: 83 c4 10 add $0x10,%esp
2138: 85 c0 test %eax,%eax
213a: 0f 88 cc 01 00 00 js 230c <subdir+0x5fc>
printf(1, "subdir ok\n");
2140: 83 ec 08 sub $0x8,%esp
2143: 68 aa 47 00 00 push $0x47aa
2148: 6a 01 push $0x1
214a: e8 b1 18 00 00 call 3a00 <printf>
}
214f: 83 c4 10 add $0x10,%esp
2152: 8b 5d fc mov -0x4(%ebp),%ebx
2155: c9 leave
2156: c3 ret
printf(1, "dd/dd/../ff wrong content\n");
2157: 50 push %eax
2158: 50 push %eax
2159: 68 47 45 00 00 push $0x4547
215e: 6a 01 push $0x1
2160: e8 9b 18 00 00 call 3a00 <printf>
exit();
2165: e8 38 17 00 00 call 38a2 <exit>
printf(1, "chdir dd/../../dd failed\n");
216a: 50 push %eax
216b: 50 push %eax
216c: 68 a2 45 00 00 push $0x45a2
2171: 6a 01 push $0x1
2173: e8 88 18 00 00 call 3a00 <printf>
exit();
2178: e8 25 17 00 00 call 38a2 <exit>
printf(1, "unlink dd/dd/ff failed\n");
217d: 52 push %edx
217e: 52 push %edx
217f: 68 6d 45 00 00 push $0x456d
2184: 6a 01 push $0x1
2186: e8 75 18 00 00 call 3a00 <printf>
exit();
218b: e8 12 17 00 00 call 38a2 <exit>
printf(1, "create dd/ff/ff succeeded!\n");
2190: 50 push %eax
2191: 50 push %eax
2192: 68 1f 46 00 00 push $0x461f
2197: 6a 01 push $0x1
2199: e8 62 18 00 00 call 3a00 <printf>
exit();
219e: e8 ff 16 00 00 call 38a2 <exit>
printf(1, "open (unlinked) dd/dd/ff succeeded!\n");
21a3: 52 push %edx
21a4: 52 push %edx
21a5: 68 04 50 00 00 push $0x5004
21aa: 6a 01 push $0x1
21ac: e8 4f 18 00 00 call 3a00 <printf>
exit();
21b1: e8 ec 16 00 00 call 38a2 <exit>
printf(1, "mkdir dd/ff/ff succeeded!\n");
21b6: 52 push %edx
21b7: 52 push %edx
21b8: 68 b3 46 00 00 push $0x46b3
21bd: 6a 01 push $0x1
21bf: e8 3c 18 00 00 call 3a00 <printf>
exit();
21c4: e8 d9 16 00 00 call 38a2 <exit>
printf(1, "link dd/ff dd/dd/ffff succeeded!\n");
21c9: 51 push %ecx
21ca: 51 push %ecx
21cb: 68 74 50 00 00 push $0x5074
21d0: 6a 01 push $0x1
21d2: e8 29 18 00 00 call 3a00 <printf>
exit();
21d7: e8 c6 16 00 00 call 38a2 <exit>
printf(1, "open dd/dd/../ff failed\n");
21dc: 50 push %eax
21dd: 50 push %eax
21de: 68 2e 45 00 00 push $0x452e
21e3: 6a 01 push $0x1
21e5: e8 16 18 00 00 call 3a00 <printf>
exit();
21ea: e8 b3 16 00 00 call 38a2 <exit>
printf(1, "create dd/dd/ff failed\n");
21ef: 51 push %ecx
21f0: 51 push %ecx
21f1: 68 07 45 00 00 push $0x4507
21f6: 6a 01 push $0x1
21f8: e8 03 18 00 00 call 3a00 <printf>
exit();
21fd: e8 a0 16 00 00 call 38a2 <exit>
printf(1, "chdir ./.. failed\n");
2202: 50 push %eax
2203: 50 push %eax
2204: 68 d0 45 00 00 push $0x45d0
2209: 6a 01 push $0x1
220b: e8 f0 17 00 00 call 3a00 <printf>
exit();
2210: e8 8d 16 00 00 call 38a2 <exit>
printf(1, "link dd/dd/ff dd/dd/ffff failed\n");
2215: 51 push %ecx
2216: 51 push %ecx
2217: 68 bc 4f 00 00 push $0x4fbc
221c: 6a 01 push $0x1
221e: e8 dd 17 00 00 call 3a00 <printf>
exit();
2223: e8 7a 16 00 00 call 38a2 <exit>
printf(1, "link dd/xx/ff dd/dd/xx succeeded!\n");
2228: 53 push %ebx
2229: 53 push %ebx
222a: 68 50 50 00 00 push $0x5050
222f: 6a 01 push $0x1
2231: e8 ca 17 00 00 call 3a00 <printf>
exit();
2236: e8 67 16 00 00 call 38a2 <exit>
printf(1, "link dd/ff/ff dd/dd/xx succeeded!\n");
223b: 50 push %eax
223c: 50 push %eax
223d: 68 2c 50 00 00 push $0x502c
2242: 6a 01 push $0x1
2244: e8 b7 17 00 00 call 3a00 <printf>
exit();
2249: e8 54 16 00 00 call 38a2 <exit>
printf(1, "open dd wronly succeeded!\n");
224e: 50 push %eax
224f: 50 push %eax
2250: 68 8f 46 00 00 push $0x468f
2255: 6a 01 push $0x1
2257: e8 a4 17 00 00 call 3a00 <printf>
exit();
225c: e8 41 16 00 00 call 38a2 <exit>
printf(1, "open dd rdwr succeeded!\n");
2261: 50 push %eax
2262: 50 push %eax
2263: 68 76 46 00 00 push $0x4676
2268: 6a 01 push $0x1
226a: e8 91 17 00 00 call 3a00 <printf>
exit();
226f: e8 2e 16 00 00 call 38a2 <exit>
printf(1, "create dd succeeded!\n");
2274: 50 push %eax
2275: 50 push %eax
2276: 68 60 46 00 00 push $0x4660
227b: 6a 01 push $0x1
227d: e8 7e 17 00 00 call 3a00 <printf>
exit();
2282: e8 1b 16 00 00 call 38a2 <exit>
printf(1, "create dd/xx/ff succeeded!\n");
2287: 50 push %eax
2288: 50 push %eax
2289: 68 44 46 00 00 push $0x4644
228e: 6a 01 push $0x1
2290: e8 6b 17 00 00 call 3a00 <printf>
exit();
2295: e8 08 16 00 00 call 38a2 <exit>
printf(1, "chdir dd failed\n");
229a: 50 push %eax
229b: 50 push %eax
229c: 68 85 45 00 00 push $0x4585
22a1: 6a 01 push $0x1
22a3: e8 58 17 00 00 call 3a00 <printf>
exit();
22a8: e8 f5 15 00 00 call 38a2 <exit>
printf(1, "open (unlinked) dd/dd/ff succeeded\n");
22ad: 50 push %eax
22ae: 50 push %eax
22af: 68 e0 4f 00 00 push $0x4fe0
22b4: 6a 01 push $0x1
22b6: e8 45 17 00 00 call 3a00 <printf>
exit();
22bb: e8 e2 15 00 00 call 38a2 <exit>
printf(1, "subdir mkdir dd/dd failed\n");
22c0: 53 push %ebx
22c1: 53 push %ebx
22c2: 68 e3 44 00 00 push $0x44e3
22c7: 6a 01 push $0x1
22c9: e8 32 17 00 00 call 3a00 <printf>
exit();
22ce: e8 cf 15 00 00 call 38a2 <exit>
printf(1, "unlink dd (non-empty dir) succeeded!\n");
22d3: 50 push %eax
22d4: 50 push %eax
22d5: 68 94 4f 00 00 push $0x4f94
22da: 6a 01 push $0x1
22dc: e8 1f 17 00 00 call 3a00 <printf>
exit();
22e1: e8 bc 15 00 00 call 38a2 <exit>
printf(1, "create dd/ff failed\n");
22e6: 50 push %eax
22e7: 50 push %eax
22e8: 68 c7 44 00 00 push $0x44c7
22ed: 6a 01 push $0x1
22ef: e8 0c 17 00 00 call 3a00 <printf>
exit();
22f4: e8 a9 15 00 00 call 38a2 <exit>
printf(1, "subdir mkdir dd failed\n");
22f9: 50 push %eax
22fa: 50 push %eax
22fb: 68 af 44 00 00 push $0x44af
2300: 6a 01 push $0x1
2302: e8 f9 16 00 00 call 3a00 <printf>
exit();
2307: e8 96 15 00 00 call 38a2 <exit>
printf(1, "unlink dd failed\n");
230c: 50 push %eax
230d: 50 push %eax
230e: 68 98 47 00 00 push $0x4798
2313: 6a 01 push $0x1
2315: e8 e6 16 00 00 call 3a00 <printf>
exit();
231a: e8 83 15 00 00 call 38a2 <exit>
printf(1, "unlink dd/dd failed\n");
231f: 52 push %edx
2320: 52 push %edx
2321: 68 83 47 00 00 push $0x4783
2326: 6a 01 push $0x1
2328: e8 d3 16 00 00 call 3a00 <printf>
exit();
232d: e8 70 15 00 00 call 38a2 <exit>
printf(1, "unlink non-empty dd succeeded!\n");
2332: 51 push %ecx
2333: 51 push %ecx
2334: 68 98 50 00 00 push $0x5098
2339: 6a 01 push $0x1
233b: e8 c0 16 00 00 call 3a00 <printf>
exit();
2340: e8 5d 15 00 00 call 38a2 <exit>
printf(1, "unlink dd/ff failed\n");
2345: 53 push %ebx
2346: 53 push %ebx
2347: 68 6e 47 00 00 push $0x476e
234c: 6a 01 push $0x1
234e: e8 ad 16 00 00 call 3a00 <printf>
exit();
2353: e8 4a 15 00 00 call 38a2 <exit>
printf(1, "chdir dd/xx succeeded!\n");
2358: 50 push %eax
2359: 50 push %eax
235a: 68 56 47 00 00 push $0x4756
235f: 6a 01 push $0x1
2361: e8 9a 16 00 00 call 3a00 <printf>
exit();
2366: e8 37 15 00 00 call 38a2 <exit>
printf(1, "chdir dd/ff succeeded!\n");
236b: 50 push %eax
236c: 50 push %eax
236d: 68 3e 47 00 00 push $0x473e
2372: 6a 01 push $0x1
2374: e8 87 16 00 00 call 3a00 <printf>
exit();
2379: e8 24 15 00 00 call 38a2 <exit>
printf(1, "unlink dd/ff/ff succeeded!\n");
237e: 50 push %eax
237f: 50 push %eax
2380: 68 22 47 00 00 push $0x4722
2385: 6a 01 push $0x1
2387: e8 74 16 00 00 call 3a00 <printf>
exit();
238c: e8 11 15 00 00 call 38a2 <exit>
printf(1, "unlink dd/xx/ff succeeded!\n");
2391: 50 push %eax
2392: 50 push %eax
2393: 68 06 47 00 00 push $0x4706
2398: 6a 01 push $0x1
239a: e8 61 16 00 00 call 3a00 <printf>
exit();
239f: e8 fe 14 00 00 call 38a2 <exit>
printf(1, "mkdir dd/dd/ffff succeeded!\n");
23a4: 50 push %eax
23a5: 50 push %eax
23a6: 68 e9 46 00 00 push $0x46e9
23ab: 6a 01 push $0x1
23ad: e8 4e 16 00 00 call 3a00 <printf>
exit();
23b2: e8 eb 14 00 00 call 38a2 <exit>
printf(1, "mkdir dd/xx/ff succeeded!\n");
23b7: 50 push %eax
23b8: 50 push %eax
23b9: 68 ce 46 00 00 push $0x46ce
23be: 6a 01 push $0x1
23c0: e8 3b 16 00 00 call 3a00 <printf>
exit();
23c5: e8 d8 14 00 00 call 38a2 <exit>
printf(1, "read dd/dd/ffff wrong len\n");
23ca: 50 push %eax
23cb: 50 push %eax
23cc: 68 fb 45 00 00 push $0x45fb
23d1: 6a 01 push $0x1
23d3: e8 28 16 00 00 call 3a00 <printf>
exit();
23d8: e8 c5 14 00 00 call 38a2 <exit>
printf(1, "open dd/dd/ffff failed\n");
23dd: 50 push %eax
23de: 50 push %eax
23df: 68 e3 45 00 00 push $0x45e3
23e4: 6a 01 push $0x1
23e6: e8 15 16 00 00 call 3a00 <printf>
exit();
23eb: e8 b2 14 00 00 call 38a2 <exit>
000023f0 <bigwrite>:
{
23f0: 55 push %ebp
23f1: 89 e5 mov %esp,%ebp
23f3: 56 push %esi
23f4: 53 push %ebx
for(sz = 499; sz < 12*512; sz += 471){
23f5: bb f3 01 00 00 mov $0x1f3,%ebx
printf(1, "bigwrite test\n");
23fa: 83 ec 08 sub $0x8,%esp
23fd: 68 b5 47 00 00 push $0x47b5
2402: 6a 01 push $0x1
2404: e8 f7 15 00 00 call 3a00 <printf>
unlink("bigwrite");
2409: c7 04 24 c4 47 00 00 movl $0x47c4,(%esp)
2410: e8 dd 14 00 00 call 38f2 <unlink>
2415: 83 c4 10 add $0x10,%esp
2418: 90 nop
2419: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
fd = open("bigwrite", O_CREATE | O_RDWR);
2420: 83 ec 08 sub $0x8,%esp
2423: 68 02 02 00 00 push $0x202
2428: 68 c4 47 00 00 push $0x47c4
242d: e8 b0 14 00 00 call 38e2 <open>
if(fd < 0){
2432: 83 c4 10 add $0x10,%esp
2435: 85 c0 test %eax,%eax
fd = open("bigwrite", O_CREATE | O_RDWR);
2437: 89 c6 mov %eax,%esi
if(fd < 0){
2439: 78 7e js 24b9 <bigwrite+0xc9>
int cc = write(fd, buf, sz);
243b: 83 ec 04 sub $0x4,%esp
243e: 53 push %ebx
243f: 68 40 86 00 00 push $0x8640
2444: 50 push %eax
2445: e8 78 14 00 00 call 38c2 <write>
if(cc != sz){
244a: 83 c4 10 add $0x10,%esp
244d: 39 d8 cmp %ebx,%eax
244f: 75 55 jne 24a6 <bigwrite+0xb6>
int cc = write(fd, buf, sz);
2451: 83 ec 04 sub $0x4,%esp
2454: 53 push %ebx
2455: 68 40 86 00 00 push $0x8640
245a: 56 push %esi
245b: e8 62 14 00 00 call 38c2 <write>
if(cc != sz){
2460: 83 c4 10 add $0x10,%esp
2463: 39 d8 cmp %ebx,%eax
2465: 75 3f jne 24a6 <bigwrite+0xb6>
close(fd);
2467: 83 ec 0c sub $0xc,%esp
for(sz = 499; sz < 12*512; sz += 471){
246a: 81 c3 d7 01 00 00 add $0x1d7,%ebx
close(fd);
2470: 56 push %esi
2471: e8 54 14 00 00 call 38ca <close>
unlink("bigwrite");
2476: c7 04 24 c4 47 00 00 movl $0x47c4,(%esp)
247d: e8 70 14 00 00 call 38f2 <unlink>
for(sz = 499; sz < 12*512; sz += 471){
2482: 83 c4 10 add $0x10,%esp
2485: 81 fb 07 18 00 00 cmp $0x1807,%ebx
248b: 75 93 jne 2420 <bigwrite+0x30>
printf(1, "bigwrite ok\n");
248d: 83 ec 08 sub $0x8,%esp
2490: 68 f7 47 00 00 push $0x47f7
2495: 6a 01 push $0x1
2497: e8 64 15 00 00 call 3a00 <printf>
}
249c: 83 c4 10 add $0x10,%esp
249f: 8d 65 f8 lea -0x8(%ebp),%esp
24a2: 5b pop %ebx
24a3: 5e pop %esi
24a4: 5d pop %ebp
24a5: c3 ret
printf(1, "write(%d) ret %d\n", sz, cc);
24a6: 50 push %eax
24a7: 53 push %ebx
24a8: 68 e5 47 00 00 push $0x47e5
24ad: 6a 01 push $0x1
24af: e8 4c 15 00 00 call 3a00 <printf>
exit();
24b4: e8 e9 13 00 00 call 38a2 <exit>
printf(1, "cannot create bigwrite\n");
24b9: 83 ec 08 sub $0x8,%esp
24bc: 68 cd 47 00 00 push $0x47cd
24c1: 6a 01 push $0x1
24c3: e8 38 15 00 00 call 3a00 <printf>
exit();
24c8: e8 d5 13 00 00 call 38a2 <exit>
24cd: 8d 76 00 lea 0x0(%esi),%esi
000024d0 <bigfile>:
{
24d0: 55 push %ebp
24d1: 89 e5 mov %esp,%ebp
24d3: 57 push %edi
24d4: 56 push %esi
24d5: 53 push %ebx
24d6: 83 ec 14 sub $0x14,%esp
printf(1, "bigfile test\n");
24d9: 68 04 48 00 00 push $0x4804
24de: 6a 01 push $0x1
24e0: e8 1b 15 00 00 call 3a00 <printf>
unlink("bigfile");
24e5: c7 04 24 20 48 00 00 movl $0x4820,(%esp)
24ec: e8 01 14 00 00 call 38f2 <unlink>
fd = open("bigfile", O_CREATE | O_RDWR);
24f1: 58 pop %eax
24f2: 5a pop %edx
24f3: 68 02 02 00 00 push $0x202
24f8: 68 20 48 00 00 push $0x4820
24fd: e8 e0 13 00 00 call 38e2 <open>
if(fd < 0){
2502: 83 c4 10 add $0x10,%esp
2505: 85 c0 test %eax,%eax
2507: 0f 88 5e 01 00 00 js 266b <bigfile+0x19b>
250d: 89 c6 mov %eax,%esi
for(i = 0; i < 20; i++){
250f: 31 db xor %ebx,%ebx
2511: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
memset(buf, i, 600);
2518: 83 ec 04 sub $0x4,%esp
251b: 68 58 02 00 00 push $0x258
2520: 53 push %ebx
2521: 68 40 86 00 00 push $0x8640
2526: e8 d5 11 00 00 call 3700 <memset>
if(write(fd, buf, 600) != 600){
252b: 83 c4 0c add $0xc,%esp
252e: 68 58 02 00 00 push $0x258
2533: 68 40 86 00 00 push $0x8640
2538: 56 push %esi
2539: e8 84 13 00 00 call 38c2 <write>
253e: 83 c4 10 add $0x10,%esp
2541: 3d 58 02 00 00 cmp $0x258,%eax
2546: 0f 85 f8 00 00 00 jne 2644 <bigfile+0x174>
for(i = 0; i < 20; i++){
254c: 83 c3 01 add $0x1,%ebx
254f: 83 fb 14 cmp $0x14,%ebx
2552: 75 c4 jne 2518 <bigfile+0x48>
close(fd);
2554: 83 ec 0c sub $0xc,%esp
2557: 56 push %esi
2558: e8 6d 13 00 00 call 38ca <close>
fd = open("bigfile", 0);
255d: 5e pop %esi
255e: 5f pop %edi
255f: 6a 00 push $0x0
2561: 68 20 48 00 00 push $0x4820
2566: e8 77 13 00 00 call 38e2 <open>
if(fd < 0){
256b: 83 c4 10 add $0x10,%esp
256e: 85 c0 test %eax,%eax
fd = open("bigfile", 0);
2570: 89 c6 mov %eax,%esi
if(fd < 0){
2572: 0f 88 e0 00 00 00 js 2658 <bigfile+0x188>
total = 0;
2578: 31 db xor %ebx,%ebx
for(i = 0; ; i++){
257a: 31 ff xor %edi,%edi
257c: eb 30 jmp 25ae <bigfile+0xde>
257e: 66 90 xchg %ax,%ax
if(cc != 300){
2580: 3d 2c 01 00 00 cmp $0x12c,%eax
2585: 0f 85 91 00 00 00 jne 261c <bigfile+0x14c>
if(buf[0] != i/2 || buf[299] != i/2){
258b: 0f be 05 40 86 00 00 movsbl 0x8640,%eax
2592: 89 fa mov %edi,%edx
2594: d1 fa sar %edx
2596: 39 d0 cmp %edx,%eax
2598: 75 6e jne 2608 <bigfile+0x138>
259a: 0f be 15 6b 87 00 00 movsbl 0x876b,%edx
25a1: 39 d0 cmp %edx,%eax
25a3: 75 63 jne 2608 <bigfile+0x138>
total += cc;
25a5: 81 c3 2c 01 00 00 add $0x12c,%ebx
for(i = 0; ; i++){
25ab: 83 c7 01 add $0x1,%edi
cc = read(fd, buf, 300);
25ae: 83 ec 04 sub $0x4,%esp
25b1: 68 2c 01 00 00 push $0x12c
25b6: 68 40 86 00 00 push $0x8640
25bb: 56 push %esi
25bc: e8 f9 12 00 00 call 38ba <read>
if(cc < 0){
25c1: 83 c4 10 add $0x10,%esp
25c4: 85 c0 test %eax,%eax
25c6: 78 68 js 2630 <bigfile+0x160>
if(cc == 0)
25c8: 75 b6 jne 2580 <bigfile+0xb0>
close(fd);
25ca: 83 ec 0c sub $0xc,%esp
25cd: 56 push %esi
25ce: e8 f7 12 00 00 call 38ca <close>
if(total != 20*600){
25d3: 83 c4 10 add $0x10,%esp
25d6: 81 fb e0 2e 00 00 cmp $0x2ee0,%ebx
25dc: 0f 85 9c 00 00 00 jne 267e <bigfile+0x1ae>
unlink("bigfile");
25e2: 83 ec 0c sub $0xc,%esp
25e5: 68 20 48 00 00 push $0x4820
25ea: e8 03 13 00 00 call 38f2 <unlink>
printf(1, "bigfile test ok\n");
25ef: 58 pop %eax
25f0: 5a pop %edx
25f1: 68 af 48 00 00 push $0x48af
25f6: 6a 01 push $0x1
25f8: e8 03 14 00 00 call 3a00 <printf>
}
25fd: 83 c4 10 add $0x10,%esp
2600: 8d 65 f4 lea -0xc(%ebp),%esp
2603: 5b pop %ebx
2604: 5e pop %esi
2605: 5f pop %edi
2606: 5d pop %ebp
2607: c3 ret
printf(1, "read bigfile wrong data\n");
2608: 83 ec 08 sub $0x8,%esp
260b: 68 7c 48 00 00 push $0x487c
2610: 6a 01 push $0x1
2612: e8 e9 13 00 00 call 3a00 <printf>
exit();
2617: e8 86 12 00 00 call 38a2 <exit>
printf(1, "short read bigfile\n");
261c: 83 ec 08 sub $0x8,%esp
261f: 68 68 48 00 00 push $0x4868
2624: 6a 01 push $0x1
2626: e8 d5 13 00 00 call 3a00 <printf>
exit();
262b: e8 72 12 00 00 call 38a2 <exit>
printf(1, "read bigfile failed\n");
2630: 83 ec 08 sub $0x8,%esp
2633: 68 53 48 00 00 push $0x4853
2638: 6a 01 push $0x1
263a: e8 c1 13 00 00 call 3a00 <printf>
exit();
263f: e8 5e 12 00 00 call 38a2 <exit>
printf(1, "write bigfile failed\n");
2644: 83 ec 08 sub $0x8,%esp
2647: 68 28 48 00 00 push $0x4828
264c: 6a 01 push $0x1
264e: e8 ad 13 00 00 call 3a00 <printf>
exit();
2653: e8 4a 12 00 00 call 38a2 <exit>
printf(1, "cannot open bigfile\n");
2658: 53 push %ebx
2659: 53 push %ebx
265a: 68 3e 48 00 00 push $0x483e
265f: 6a 01 push $0x1
2661: e8 9a 13 00 00 call 3a00 <printf>
exit();
2666: e8 37 12 00 00 call 38a2 <exit>
printf(1, "cannot create bigfile");
266b: 50 push %eax
266c: 50 push %eax
266d: 68 12 48 00 00 push $0x4812
2672: 6a 01 push $0x1
2674: e8 87 13 00 00 call 3a00 <printf>
exit();
2679: e8 24 12 00 00 call 38a2 <exit>
printf(1, "read bigfile wrong total\n");
267e: 51 push %ecx
267f: 51 push %ecx
2680: 68 95 48 00 00 push $0x4895
2685: 6a 01 push $0x1
2687: e8 74 13 00 00 call 3a00 <printf>
exit();
268c: e8 11 12 00 00 call 38a2 <exit>
2691: eb 0d jmp 26a0 <fourteen>
2693: 90 nop
2694: 90 nop
2695: 90 nop
2696: 90 nop
2697: 90 nop
2698: 90 nop
2699: 90 nop
269a: 90 nop
269b: 90 nop
269c: 90 nop
269d: 90 nop
269e: 90 nop
269f: 90 nop
000026a0 <fourteen>:
{
26a0: 55 push %ebp
26a1: 89 e5 mov %esp,%ebp
26a3: 83 ec 10 sub $0x10,%esp
printf(1, "fourteen test\n");
26a6: 68 c0 48 00 00 push $0x48c0
26ab: 6a 01 push $0x1
26ad: e8 4e 13 00 00 call 3a00 <printf>
if(mkdir("12345678901234") != 0){
26b2: c7 04 24 fb 48 00 00 movl $0x48fb,(%esp)
26b9: e8 4c 12 00 00 call 390a <mkdir>
26be: 83 c4 10 add $0x10,%esp
26c1: 85 c0 test %eax,%eax
26c3: 0f 85 97 00 00 00 jne 2760 <fourteen+0xc0>
if(mkdir("12345678901234/123456789012345") != 0){
26c9: 83 ec 0c sub $0xc,%esp
26cc: 68 b8 50 00 00 push $0x50b8
26d1: e8 34 12 00 00 call 390a <mkdir>
26d6: 83 c4 10 add $0x10,%esp
26d9: 85 c0 test %eax,%eax
26db: 0f 85 de 00 00 00 jne 27bf <fourteen+0x11f>
fd = open("123456789012345/123456789012345/123456789012345", O_CREATE);
26e1: 83 ec 08 sub $0x8,%esp
26e4: 68 00 02 00 00 push $0x200
26e9: 68 08 51 00 00 push $0x5108
26ee: e8 ef 11 00 00 call 38e2 <open>
if(fd < 0){
26f3: 83 c4 10 add $0x10,%esp
26f6: 85 c0 test %eax,%eax
26f8: 0f 88 ae 00 00 00 js 27ac <fourteen+0x10c>
close(fd);
26fe: 83 ec 0c sub $0xc,%esp
2701: 50 push %eax
2702: e8 c3 11 00 00 call 38ca <close>
fd = open("12345678901234/12345678901234/12345678901234", 0);
2707: 58 pop %eax
2708: 5a pop %edx
2709: 6a 00 push $0x0
270b: 68 78 51 00 00 push $0x5178
2710: e8 cd 11 00 00 call 38e2 <open>
if(fd < 0){
2715: 83 c4 10 add $0x10,%esp
2718: 85 c0 test %eax,%eax
271a: 78 7d js 2799 <fourteen+0xf9>
close(fd);
271c: 83 ec 0c sub $0xc,%esp
271f: 50 push %eax
2720: e8 a5 11 00 00 call 38ca <close>
if(mkdir("12345678901234/12345678901234") == 0){
2725: c7 04 24 ec 48 00 00 movl $0x48ec,(%esp)
272c: e8 d9 11 00 00 call 390a <mkdir>
2731: 83 c4 10 add $0x10,%esp
2734: 85 c0 test %eax,%eax
2736: 74 4e je 2786 <fourteen+0xe6>
if(mkdir("123456789012345/12345678901234") == 0){
2738: 83 ec 0c sub $0xc,%esp
273b: 68 14 52 00 00 push $0x5214
2740: e8 c5 11 00 00 call 390a <mkdir>
2745: 83 c4 10 add $0x10,%esp
2748: 85 c0 test %eax,%eax
274a: 74 27 je 2773 <fourteen+0xd3>
printf(1, "fourteen ok\n");
274c: 83 ec 08 sub $0x8,%esp
274f: 68 0a 49 00 00 push $0x490a
2754: 6a 01 push $0x1
2756: e8 a5 12 00 00 call 3a00 <printf>
}
275b: 83 c4 10 add $0x10,%esp
275e: c9 leave
275f: c3 ret
printf(1, "mkdir 12345678901234 failed\n");
2760: 50 push %eax
2761: 50 push %eax
2762: 68 cf 48 00 00 push $0x48cf
2767: 6a 01 push $0x1
2769: e8 92 12 00 00 call 3a00 <printf>
exit();
276e: e8 2f 11 00 00 call 38a2 <exit>
printf(1, "mkdir 12345678901234/123456789012345 succeeded!\n");
2773: 50 push %eax
2774: 50 push %eax
2775: 68 34 52 00 00 push $0x5234
277a: 6a 01 push $0x1
277c: e8 7f 12 00 00 call 3a00 <printf>
exit();
2781: e8 1c 11 00 00 call 38a2 <exit>
printf(1, "mkdir 12345678901234/12345678901234 succeeded!\n");
2786: 52 push %edx
2787: 52 push %edx
2788: 68 e4 51 00 00 push $0x51e4
278d: 6a 01 push $0x1
278f: e8 6c 12 00 00 call 3a00 <printf>
exit();
2794: e8 09 11 00 00 call 38a2 <exit>
printf(1, "open 12345678901234/12345678901234/12345678901234 failed\n");
2799: 51 push %ecx
279a: 51 push %ecx
279b: 68 a8 51 00 00 push $0x51a8
27a0: 6a 01 push $0x1
27a2: e8 59 12 00 00 call 3a00 <printf>
exit();
27a7: e8 f6 10 00 00 call 38a2 <exit>
printf(1, "create 123456789012345/123456789012345/123456789012345 failed\n");
27ac: 51 push %ecx
27ad: 51 push %ecx
27ae: 68 38 51 00 00 push $0x5138
27b3: 6a 01 push $0x1
27b5: e8 46 12 00 00 call 3a00 <printf>
exit();
27ba: e8 e3 10 00 00 call 38a2 <exit>
printf(1, "mkdir 12345678901234/123456789012345 failed\n");
27bf: 50 push %eax
27c0: 50 push %eax
27c1: 68 d8 50 00 00 push $0x50d8
27c6: 6a 01 push $0x1
27c8: e8 33 12 00 00 call 3a00 <printf>
exit();
27cd: e8 d0 10 00 00 call 38a2 <exit>
27d2: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
27d9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
000027e0 <rmdot>:
{
27e0: 55 push %ebp
27e1: 89 e5 mov %esp,%ebp
27e3: 83 ec 10 sub $0x10,%esp
printf(1, "rmdot test\n");
27e6: 68 17 49 00 00 push $0x4917
27eb: 6a 01 push $0x1
27ed: e8 0e 12 00 00 call 3a00 <printf>
if(mkdir("dots") != 0){
27f2: c7 04 24 23 49 00 00 movl $0x4923,(%esp)
27f9: e8 0c 11 00 00 call 390a <mkdir>
27fe: 83 c4 10 add $0x10,%esp
2801: 85 c0 test %eax,%eax
2803: 0f 85 b0 00 00 00 jne 28b9 <rmdot+0xd9>
if(chdir("dots") != 0){
2809: 83 ec 0c sub $0xc,%esp
280c: 68 23 49 00 00 push $0x4923
2811: e8 fc 10 00 00 call 3912 <chdir>
2816: 83 c4 10 add $0x10,%esp
2819: 85 c0 test %eax,%eax
281b: 0f 85 1d 01 00 00 jne 293e <rmdot+0x15e>
if(unlink(".") == 0){
2821: 83 ec 0c sub $0xc,%esp
2824: 68 ce 45 00 00 push $0x45ce
2829: e8 c4 10 00 00 call 38f2 <unlink>
282e: 83 c4 10 add $0x10,%esp
2831: 85 c0 test %eax,%eax
2833: 0f 84 f2 00 00 00 je 292b <rmdot+0x14b>
if(unlink("..") == 0){
2839: 83 ec 0c sub $0xc,%esp
283c: 68 cd 45 00 00 push $0x45cd
2841: e8 ac 10 00 00 call 38f2 <unlink>
2846: 83 c4 10 add $0x10,%esp
2849: 85 c0 test %eax,%eax
284b: 0f 84 c7 00 00 00 je 2918 <rmdot+0x138>
if(chdir("/") != 0){
2851: 83 ec 0c sub $0xc,%esp
2854: 68 a1 3d 00 00 push $0x3da1
2859: e8 b4 10 00 00 call 3912 <chdir>
285e: 83 c4 10 add $0x10,%esp
2861: 85 c0 test %eax,%eax
2863: 0f 85 9c 00 00 00 jne 2905 <rmdot+0x125>
if(unlink("dots/.") == 0){
2869: 83 ec 0c sub $0xc,%esp
286c: 68 6b 49 00 00 push $0x496b
2871: e8 7c 10 00 00 call 38f2 <unlink>
2876: 83 c4 10 add $0x10,%esp
2879: 85 c0 test %eax,%eax
287b: 74 75 je 28f2 <rmdot+0x112>
if(unlink("dots/..") == 0){
287d: 83 ec 0c sub $0xc,%esp
2880: 68 89 49 00 00 push $0x4989
2885: e8 68 10 00 00 call 38f2 <unlink>
288a: 83 c4 10 add $0x10,%esp
288d: 85 c0 test %eax,%eax
288f: 74 4e je 28df <rmdot+0xff>
if(unlink("dots") != 0){
2891: 83 ec 0c sub $0xc,%esp
2894: 68 23 49 00 00 push $0x4923
2899: e8 54 10 00 00 call 38f2 <unlink>
289e: 83 c4 10 add $0x10,%esp
28a1: 85 c0 test %eax,%eax
28a3: 75 27 jne 28cc <rmdot+0xec>
printf(1, "rmdot ok\n");
28a5: 83 ec 08 sub $0x8,%esp
28a8: 68 be 49 00 00 push $0x49be
28ad: 6a 01 push $0x1
28af: e8 4c 11 00 00 call 3a00 <printf>
}
28b4: 83 c4 10 add $0x10,%esp
28b7: c9 leave
28b8: c3 ret
printf(1, "mkdir dots failed\n");
28b9: 50 push %eax
28ba: 50 push %eax
28bb: 68 28 49 00 00 push $0x4928
28c0: 6a 01 push $0x1
28c2: e8 39 11 00 00 call 3a00 <printf>
exit();
28c7: e8 d6 0f 00 00 call 38a2 <exit>
printf(1, "unlink dots failed!\n");
28cc: 50 push %eax
28cd: 50 push %eax
28ce: 68 a9 49 00 00 push $0x49a9
28d3: 6a 01 push $0x1
28d5: e8 26 11 00 00 call 3a00 <printf>
exit();
28da: e8 c3 0f 00 00 call 38a2 <exit>
printf(1, "unlink dots/.. worked!\n");
28df: 52 push %edx
28e0: 52 push %edx
28e1: 68 91 49 00 00 push $0x4991
28e6: 6a 01 push $0x1
28e8: e8 13 11 00 00 call 3a00 <printf>
exit();
28ed: e8 b0 0f 00 00 call 38a2 <exit>
printf(1, "unlink dots/. worked!\n");
28f2: 51 push %ecx
28f3: 51 push %ecx
28f4: 68 72 49 00 00 push $0x4972
28f9: 6a 01 push $0x1
28fb: e8 00 11 00 00 call 3a00 <printf>
exit();
2900: e8 9d 0f 00 00 call 38a2 <exit>
printf(1, "chdir / failed\n");
2905: 50 push %eax
2906: 50 push %eax
2907: 68 a3 3d 00 00 push $0x3da3
290c: 6a 01 push $0x1
290e: e8 ed 10 00 00 call 3a00 <printf>
exit();
2913: e8 8a 0f 00 00 call 38a2 <exit>
printf(1, "rm .. worked!\n");
2918: 50 push %eax
2919: 50 push %eax
291a: 68 5c 49 00 00 push $0x495c
291f: 6a 01 push $0x1
2921: e8 da 10 00 00 call 3a00 <printf>
exit();
2926: e8 77 0f 00 00 call 38a2 <exit>
printf(1, "rm . worked!\n");
292b: 50 push %eax
292c: 50 push %eax
292d: 68 4e 49 00 00 push $0x494e
2932: 6a 01 push $0x1
2934: e8 c7 10 00 00 call 3a00 <printf>
exit();
2939: e8 64 0f 00 00 call 38a2 <exit>
printf(1, "chdir dots failed\n");
293e: 50 push %eax
293f: 50 push %eax
2940: 68 3b 49 00 00 push $0x493b
2945: 6a 01 push $0x1
2947: e8 b4 10 00 00 call 3a00 <printf>
exit();
294c: e8 51 0f 00 00 call 38a2 <exit>
2951: eb 0d jmp 2960 <dirfile>
2953: 90 nop
2954: 90 nop
2955: 90 nop
2956: 90 nop
2957: 90 nop
2958: 90 nop
2959: 90 nop
295a: 90 nop
295b: 90 nop
295c: 90 nop
295d: 90 nop
295e: 90 nop
295f: 90 nop
00002960 <dirfile>:
{
2960: 55 push %ebp
2961: 89 e5 mov %esp,%ebp
2963: 53 push %ebx
2964: 83 ec 0c sub $0xc,%esp
printf(1, "dir vs file\n");
2967: 68 c8 49 00 00 push $0x49c8
296c: 6a 01 push $0x1
296e: e8 8d 10 00 00 call 3a00 <printf>
fd = open("dirfile", O_CREATE);
2973: 59 pop %ecx
2974: 5b pop %ebx
2975: 68 00 02 00 00 push $0x200
297a: 68 d5 49 00 00 push $0x49d5
297f: e8 5e 0f 00 00 call 38e2 <open>
if(fd < 0){
2984: 83 c4 10 add $0x10,%esp
2987: 85 c0 test %eax,%eax
2989: 0f 88 43 01 00 00 js 2ad2 <dirfile+0x172>
close(fd);
298f: 83 ec 0c sub $0xc,%esp
2992: 50 push %eax
2993: e8 32 0f 00 00 call 38ca <close>
if(chdir("dirfile") == 0){
2998: c7 04 24 d5 49 00 00 movl $0x49d5,(%esp)
299f: e8 6e 0f 00 00 call 3912 <chdir>
29a4: 83 c4 10 add $0x10,%esp
29a7: 85 c0 test %eax,%eax
29a9: 0f 84 10 01 00 00 je 2abf <dirfile+0x15f>
fd = open("dirfile/xx", 0);
29af: 83 ec 08 sub $0x8,%esp
29b2: 6a 00 push $0x0
29b4: 68 0e 4a 00 00 push $0x4a0e
29b9: e8 24 0f 00 00 call 38e2 <open>
if(fd >= 0){
29be: 83 c4 10 add $0x10,%esp
29c1: 85 c0 test %eax,%eax
29c3: 0f 89 e3 00 00 00 jns 2aac <dirfile+0x14c>
fd = open("dirfile/xx", O_CREATE);
29c9: 83 ec 08 sub $0x8,%esp
29cc: 68 00 02 00 00 push $0x200
29d1: 68 0e 4a 00 00 push $0x4a0e
29d6: e8 07 0f 00 00 call 38e2 <open>
if(fd >= 0){
29db: 83 c4 10 add $0x10,%esp
29de: 85 c0 test %eax,%eax
29e0: 0f 89 c6 00 00 00 jns 2aac <dirfile+0x14c>
if(mkdir("dirfile/xx") == 0){
29e6: 83 ec 0c sub $0xc,%esp
29e9: 68 0e 4a 00 00 push $0x4a0e
29ee: e8 17 0f 00 00 call 390a <mkdir>
29f3: 83 c4 10 add $0x10,%esp
29f6: 85 c0 test %eax,%eax
29f8: 0f 84 46 01 00 00 je 2b44 <dirfile+0x1e4>
if(unlink("dirfile/xx") == 0){
29fe: 83 ec 0c sub $0xc,%esp
2a01: 68 0e 4a 00 00 push $0x4a0e
2a06: e8 e7 0e 00 00 call 38f2 <unlink>
2a0b: 83 c4 10 add $0x10,%esp
2a0e: 85 c0 test %eax,%eax
2a10: 0f 84 1b 01 00 00 je 2b31 <dirfile+0x1d1>
if(link("README", "dirfile/xx") == 0){
2a16: 83 ec 08 sub $0x8,%esp
2a19: 68 0e 4a 00 00 push $0x4a0e
2a1e: 68 72 4a 00 00 push $0x4a72
2a23: e8 da 0e 00 00 call 3902 <link>
2a28: 83 c4 10 add $0x10,%esp
2a2b: 85 c0 test %eax,%eax
2a2d: 0f 84 eb 00 00 00 je 2b1e <dirfile+0x1be>
if(unlink("dirfile") != 0){
2a33: 83 ec 0c sub $0xc,%esp
2a36: 68 d5 49 00 00 push $0x49d5
2a3b: e8 b2 0e 00 00 call 38f2 <unlink>
2a40: 83 c4 10 add $0x10,%esp
2a43: 85 c0 test %eax,%eax
2a45: 0f 85 c0 00 00 00 jne 2b0b <dirfile+0x1ab>
fd = open(".", O_RDWR);
2a4b: 83 ec 08 sub $0x8,%esp
2a4e: 6a 02 push $0x2
2a50: 68 ce 45 00 00 push $0x45ce
2a55: e8 88 0e 00 00 call 38e2 <open>
if(fd >= 0){
2a5a: 83 c4 10 add $0x10,%esp
2a5d: 85 c0 test %eax,%eax
2a5f: 0f 89 93 00 00 00 jns 2af8 <dirfile+0x198>
fd = open(".", 0);
2a65: 83 ec 08 sub $0x8,%esp
2a68: 6a 00 push $0x0
2a6a: 68 ce 45 00 00 push $0x45ce
2a6f: e8 6e 0e 00 00 call 38e2 <open>
if(write(fd, "x", 1) > 0){
2a74: 83 c4 0c add $0xc,%esp
fd = open(".", 0);
2a77: 89 c3 mov %eax,%ebx
if(write(fd, "x", 1) > 0){
2a79: 6a 01 push $0x1
2a7b: 68 b1 46 00 00 push $0x46b1
2a80: 50 push %eax
2a81: e8 3c 0e 00 00 call 38c2 <write>
2a86: 83 c4 10 add $0x10,%esp
2a89: 85 c0 test %eax,%eax
2a8b: 7f 58 jg 2ae5 <dirfile+0x185>
close(fd);
2a8d: 83 ec 0c sub $0xc,%esp
2a90: 53 push %ebx
2a91: e8 34 0e 00 00 call 38ca <close>
printf(1, "dir vs file OK\n");
2a96: 58 pop %eax
2a97: 5a pop %edx
2a98: 68 a5 4a 00 00 push $0x4aa5
2a9d: 6a 01 push $0x1
2a9f: e8 5c 0f 00 00 call 3a00 <printf>
}
2aa4: 83 c4 10 add $0x10,%esp
2aa7: 8b 5d fc mov -0x4(%ebp),%ebx
2aaa: c9 leave
2aab: c3 ret
printf(1, "create dirfile/xx succeeded!\n");
2aac: 50 push %eax
2aad: 50 push %eax
2aae: 68 19 4a 00 00 push $0x4a19
2ab3: 6a 01 push $0x1
2ab5: e8 46 0f 00 00 call 3a00 <printf>
exit();
2aba: e8 e3 0d 00 00 call 38a2 <exit>
printf(1, "chdir dirfile succeeded!\n");
2abf: 50 push %eax
2ac0: 50 push %eax
2ac1: 68 f4 49 00 00 push $0x49f4
2ac6: 6a 01 push $0x1
2ac8: e8 33 0f 00 00 call 3a00 <printf>
exit();
2acd: e8 d0 0d 00 00 call 38a2 <exit>
printf(1, "create dirfile failed\n");
2ad2: 52 push %edx
2ad3: 52 push %edx
2ad4: 68 dd 49 00 00 push $0x49dd
2ad9: 6a 01 push $0x1
2adb: e8 20 0f 00 00 call 3a00 <printf>
exit();
2ae0: e8 bd 0d 00 00 call 38a2 <exit>
printf(1, "write . succeeded!\n");
2ae5: 51 push %ecx
2ae6: 51 push %ecx
2ae7: 68 91 4a 00 00 push $0x4a91
2aec: 6a 01 push $0x1
2aee: e8 0d 0f 00 00 call 3a00 <printf>
exit();
2af3: e8 aa 0d 00 00 call 38a2 <exit>
printf(1, "open . for writing succeeded!\n");
2af8: 53 push %ebx
2af9: 53 push %ebx
2afa: 68 88 52 00 00 push $0x5288
2aff: 6a 01 push $0x1
2b01: e8 fa 0e 00 00 call 3a00 <printf>
exit();
2b06: e8 97 0d 00 00 call 38a2 <exit>
printf(1, "unlink dirfile failed!\n");
2b0b: 50 push %eax
2b0c: 50 push %eax
2b0d: 68 79 4a 00 00 push $0x4a79
2b12: 6a 01 push $0x1
2b14: e8 e7 0e 00 00 call 3a00 <printf>
exit();
2b19: e8 84 0d 00 00 call 38a2 <exit>
printf(1, "link to dirfile/xx succeeded!\n");
2b1e: 50 push %eax
2b1f: 50 push %eax
2b20: 68 68 52 00 00 push $0x5268
2b25: 6a 01 push $0x1
2b27: e8 d4 0e 00 00 call 3a00 <printf>
exit();
2b2c: e8 71 0d 00 00 call 38a2 <exit>
printf(1, "unlink dirfile/xx succeeded!\n");
2b31: 50 push %eax
2b32: 50 push %eax
2b33: 68 54 4a 00 00 push $0x4a54
2b38: 6a 01 push $0x1
2b3a: e8 c1 0e 00 00 call 3a00 <printf>
exit();
2b3f: e8 5e 0d 00 00 call 38a2 <exit>
printf(1, "mkdir dirfile/xx succeeded!\n");
2b44: 50 push %eax
2b45: 50 push %eax
2b46: 68 37 4a 00 00 push $0x4a37
2b4b: 6a 01 push $0x1
2b4d: e8 ae 0e 00 00 call 3a00 <printf>
exit();
2b52: e8 4b 0d 00 00 call 38a2 <exit>
2b57: 89 f6 mov %esi,%esi
2b59: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
00002b60 <iref>:
{
2b60: 55 push %ebp
2b61: 89 e5 mov %esp,%ebp
2b63: 53 push %ebx
printf(1, "empty file name\n");
2b64: bb 33 00 00 00 mov $0x33,%ebx
{
2b69: 83 ec 0c sub $0xc,%esp
printf(1, "empty file name\n");
2b6c: 68 b5 4a 00 00 push $0x4ab5
2b71: 6a 01 push $0x1
2b73: e8 88 0e 00 00 call 3a00 <printf>
2b78: 83 c4 10 add $0x10,%esp
2b7b: 90 nop
2b7c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
if(mkdir("irefd") != 0){
2b80: 83 ec 0c sub $0xc,%esp
2b83: 68 c6 4a 00 00 push $0x4ac6
2b88: e8 7d 0d 00 00 call 390a <mkdir>
2b8d: 83 c4 10 add $0x10,%esp
2b90: 85 c0 test %eax,%eax
2b92: 0f 85 bb 00 00 00 jne 2c53 <iref+0xf3>
if(chdir("irefd") != 0){
2b98: 83 ec 0c sub $0xc,%esp
2b9b: 68 c6 4a 00 00 push $0x4ac6
2ba0: e8 6d 0d 00 00 call 3912 <chdir>
2ba5: 83 c4 10 add $0x10,%esp
2ba8: 85 c0 test %eax,%eax
2baa: 0f 85 b7 00 00 00 jne 2c67 <iref+0x107>
mkdir("");
2bb0: 83 ec 0c sub $0xc,%esp
2bb3: 68 7b 41 00 00 push $0x417b
2bb8: e8 4d 0d 00 00 call 390a <mkdir>
link("README", "");
2bbd: 59 pop %ecx
2bbe: 58 pop %eax
2bbf: 68 7b 41 00 00 push $0x417b
2bc4: 68 72 4a 00 00 push $0x4a72
2bc9: e8 34 0d 00 00 call 3902 <link>
fd = open("", O_CREATE);
2bce: 58 pop %eax
2bcf: 5a pop %edx
2bd0: 68 00 02 00 00 push $0x200
2bd5: 68 7b 41 00 00 push $0x417b
2bda: e8 03 0d 00 00 call 38e2 <open>
if(fd >= 0)
2bdf: 83 c4 10 add $0x10,%esp
2be2: 85 c0 test %eax,%eax
2be4: 78 0c js 2bf2 <iref+0x92>
close(fd);
2be6: 83 ec 0c sub $0xc,%esp
2be9: 50 push %eax
2bea: e8 db 0c 00 00 call 38ca <close>
2bef: 83 c4 10 add $0x10,%esp
fd = open("xx", O_CREATE);
2bf2: 83 ec 08 sub $0x8,%esp
2bf5: 68 00 02 00 00 push $0x200
2bfa: 68 b0 46 00 00 push $0x46b0
2bff: e8 de 0c 00 00 call 38e2 <open>
if(fd >= 0)
2c04: 83 c4 10 add $0x10,%esp
2c07: 85 c0 test %eax,%eax
2c09: 78 0c js 2c17 <iref+0xb7>
close(fd);
2c0b: 83 ec 0c sub $0xc,%esp
2c0e: 50 push %eax
2c0f: e8 b6 0c 00 00 call 38ca <close>
2c14: 83 c4 10 add $0x10,%esp
unlink("xx");
2c17: 83 ec 0c sub $0xc,%esp
2c1a: 68 b0 46 00 00 push $0x46b0
2c1f: e8 ce 0c 00 00 call 38f2 <unlink>
for(i = 0; i < 50 + 1; i++){
2c24: 83 c4 10 add $0x10,%esp
2c27: 83 eb 01 sub $0x1,%ebx
2c2a: 0f 85 50 ff ff ff jne 2b80 <iref+0x20>
chdir("/");
2c30: 83 ec 0c sub $0xc,%esp
2c33: 68 a1 3d 00 00 push $0x3da1
2c38: e8 d5 0c 00 00 call 3912 <chdir>
printf(1, "empty file name OK\n");
2c3d: 58 pop %eax
2c3e: 5a pop %edx
2c3f: 68 f4 4a 00 00 push $0x4af4
2c44: 6a 01 push $0x1
2c46: e8 b5 0d 00 00 call 3a00 <printf>
}
2c4b: 83 c4 10 add $0x10,%esp
2c4e: 8b 5d fc mov -0x4(%ebp),%ebx
2c51: c9 leave
2c52: c3 ret
printf(1, "mkdir irefd failed\n");
2c53: 83 ec 08 sub $0x8,%esp
2c56: 68 cc 4a 00 00 push $0x4acc
2c5b: 6a 01 push $0x1
2c5d: e8 9e 0d 00 00 call 3a00 <printf>
exit();
2c62: e8 3b 0c 00 00 call 38a2 <exit>
printf(1, "chdir irefd failed\n");
2c67: 83 ec 08 sub $0x8,%esp
2c6a: 68 e0 4a 00 00 push $0x4ae0
2c6f: 6a 01 push $0x1
2c71: e8 8a 0d 00 00 call 3a00 <printf>
exit();
2c76: e8 27 0c 00 00 call 38a2 <exit>
2c7b: 90 nop
2c7c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
00002c80 <forktest>:
{
2c80: 55 push %ebp
2c81: 89 e5 mov %esp,%ebp
2c83: 53 push %ebx
for(n=0; n<1000; n++){
2c84: 31 db xor %ebx,%ebx
{
2c86: 83 ec 0c sub $0xc,%esp
printf(1, "fork test\n");
2c89: 68 08 4b 00 00 push $0x4b08
2c8e: 6a 01 push $0x1
2c90: e8 6b 0d 00 00 call 3a00 <printf>
2c95: 83 c4 10 add $0x10,%esp
2c98: eb 13 jmp 2cad <forktest+0x2d>
2c9a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
if(pid == 0)
2ca0: 74 62 je 2d04 <forktest+0x84>
for(n=0; n<1000; n++){
2ca2: 83 c3 01 add $0x1,%ebx
2ca5: 81 fb e8 03 00 00 cmp $0x3e8,%ebx
2cab: 74 43 je 2cf0 <forktest+0x70>
pid = fork();
2cad: e8 e8 0b 00 00 call 389a <fork>
if(pid < 0)
2cb2: 85 c0 test %eax,%eax
2cb4: 79 ea jns 2ca0 <forktest+0x20>
for(; n > 0; n--){
2cb6: 85 db test %ebx,%ebx
2cb8: 74 14 je 2cce <forktest+0x4e>
2cba: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
if(wait() < 0){
2cc0: e8 e5 0b 00 00 call 38aa <wait>
2cc5: 85 c0 test %eax,%eax
2cc7: 78 40 js 2d09 <forktest+0x89>
for(; n > 0; n--){
2cc9: 83 eb 01 sub $0x1,%ebx
2ccc: 75 f2 jne 2cc0 <forktest+0x40>
if(wait() != -1){
2cce: e8 d7 0b 00 00 call 38aa <wait>
2cd3: 83 f8 ff cmp $0xffffffff,%eax
2cd6: 75 45 jne 2d1d <forktest+0x9d>
printf(1, "fork test OK\n");
2cd8: 83 ec 08 sub $0x8,%esp
2cdb: 68 3a 4b 00 00 push $0x4b3a
2ce0: 6a 01 push $0x1
2ce2: e8 19 0d 00 00 call 3a00 <printf>
}
2ce7: 8b 5d fc mov -0x4(%ebp),%ebx
2cea: c9 leave
2ceb: c3 ret
2cec: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
printf(1, "fork claimed to work 1000 times!\n");
2cf0: 83 ec 08 sub $0x8,%esp
2cf3: 68 a8 52 00 00 push $0x52a8
2cf8: 6a 01 push $0x1
2cfa: e8 01 0d 00 00 call 3a00 <printf>
exit();
2cff: e8 9e 0b 00 00 call 38a2 <exit>
exit();
2d04: e8 99 0b 00 00 call 38a2 <exit>
printf(1, "wait stopped early\n");
2d09: 83 ec 08 sub $0x8,%esp
2d0c: 68 13 4b 00 00 push $0x4b13
2d11: 6a 01 push $0x1
2d13: e8 e8 0c 00 00 call 3a00 <printf>
exit();
2d18: e8 85 0b 00 00 call 38a2 <exit>
printf(1, "wait got too many\n");
2d1d: 50 push %eax
2d1e: 50 push %eax
2d1f: 68 27 4b 00 00 push $0x4b27
2d24: 6a 01 push $0x1
2d26: e8 d5 0c 00 00 call 3a00 <printf>
exit();
2d2b: e8 72 0b 00 00 call 38a2 <exit>
00002d30 <sbrktest>:
{
2d30: 55 push %ebp
2d31: 89 e5 mov %esp,%ebp
2d33: 57 push %edi
2d34: 56 push %esi
2d35: 53 push %ebx
for(i = 0; i < 5000; i++){
2d36: 31 ff xor %edi,%edi
{
2d38: 83 ec 64 sub $0x64,%esp
printf(stdout, "sbrk test\n");
2d3b: 68 48 4b 00 00 push $0x4b48
2d40: ff 35 08 5e 00 00 pushl 0x5e08
2d46: e8 b5 0c 00 00 call 3a00 <printf>
oldbrk = sbrk(0);
2d4b: c7 04 24 00 00 00 00 movl $0x0,(%esp)
2d52: e8 d3 0b 00 00 call 392a <sbrk>
a = sbrk(0);
2d57: c7 04 24 00 00 00 00 movl $0x0,(%esp)
oldbrk = sbrk(0);
2d5e: 89 c3 mov %eax,%ebx
a = sbrk(0);
2d60: e8 c5 0b 00 00 call 392a <sbrk>
2d65: 83 c4 10 add $0x10,%esp
2d68: 89 c6 mov %eax,%esi
2d6a: eb 06 jmp 2d72 <sbrktest+0x42>
2d6c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
a = b + 1;
2d70: 89 c6 mov %eax,%esi
b = sbrk(1);
2d72: 83 ec 0c sub $0xc,%esp
2d75: 6a 01 push $0x1
2d77: e8 ae 0b 00 00 call 392a <sbrk>
if(b != a){
2d7c: 83 c4 10 add $0x10,%esp
2d7f: 39 f0 cmp %esi,%eax
2d81: 0f 85 62 02 00 00 jne 2fe9 <sbrktest+0x2b9>
for(i = 0; i < 5000; i++){
2d87: 83 c7 01 add $0x1,%edi
*b = 1;
2d8a: c6 06 01 movb $0x1,(%esi)
a = b + 1;
2d8d: 8d 46 01 lea 0x1(%esi),%eax
for(i = 0; i < 5000; i++){
2d90: 81 ff 88 13 00 00 cmp $0x1388,%edi
2d96: 75 d8 jne 2d70 <sbrktest+0x40>
pid = fork();
2d98: e8 fd 0a 00 00 call 389a <fork>
if(pid < 0){
2d9d: 85 c0 test %eax,%eax
pid = fork();
2d9f: 89 c7 mov %eax,%edi
if(pid < 0){
2da1: 0f 88 82 03 00 00 js 3129 <sbrktest+0x3f9>
c = sbrk(1);
2da7: 83 ec 0c sub $0xc,%esp
if(c != a + 1){
2daa: 83 c6 02 add $0x2,%esi
c = sbrk(1);
2dad: 6a 01 push $0x1
2daf: e8 76 0b 00 00 call 392a <sbrk>
c = sbrk(1);
2db4: c7 04 24 01 00 00 00 movl $0x1,(%esp)
2dbb: e8 6a 0b 00 00 call 392a <sbrk>
if(c != a + 1){
2dc0: 83 c4 10 add $0x10,%esp
2dc3: 39 f0 cmp %esi,%eax
2dc5: 0f 85 47 03 00 00 jne 3112 <sbrktest+0x3e2>
if(pid == 0)
2dcb: 85 ff test %edi,%edi
2dcd: 0f 84 3a 03 00 00 je 310d <sbrktest+0x3dd>
wait();
2dd3: e8 d2 0a 00 00 call 38aa <wait>
a = sbrk(0);
2dd8: 83 ec 0c sub $0xc,%esp
2ddb: 6a 00 push $0x0
2ddd: e8 48 0b 00 00 call 392a <sbrk>
2de2: 89 c6 mov %eax,%esi
amt = (BIG) - (uint)a;
2de4: b8 00 00 40 06 mov $0x6400000,%eax
2de9: 29 f0 sub %esi,%eax
p = sbrk(amt);
2deb: 89 04 24 mov %eax,(%esp)
2dee: e8 37 0b 00 00 call 392a <sbrk>
if (p != a) {
2df3: 83 c4 10 add $0x10,%esp
2df6: 39 c6 cmp %eax,%esi
2df8: 0f 85 f8 02 00 00 jne 30f6 <sbrktest+0x3c6>
a = sbrk(0);
2dfe: 83 ec 0c sub $0xc,%esp
*lastaddr = 99;
2e01: c6 05 ff ff 3f 06 63 movb $0x63,0x63fffff
a = sbrk(0);
2e08: 6a 00 push $0x0
2e0a: e8 1b 0b 00 00 call 392a <sbrk>
c = sbrk(-4096);
2e0f: c7 04 24 00 f0 ff ff movl $0xfffff000,(%esp)
a = sbrk(0);
2e16: 89 c6 mov %eax,%esi
c = sbrk(-4096);
2e18: e8 0d 0b 00 00 call 392a <sbrk>
if(c == (char*)0xffffffff){
2e1d: 83 c4 10 add $0x10,%esp
2e20: 83 f8 ff cmp $0xffffffff,%eax
2e23: 0f 84 b6 02 00 00 je 30df <sbrktest+0x3af>
c = sbrk(0);
2e29: 83 ec 0c sub $0xc,%esp
2e2c: 6a 00 push $0x0
2e2e: e8 f7 0a 00 00 call 392a <sbrk>
if(c != a - 4096){
2e33: 8d 96 00 f0 ff ff lea -0x1000(%esi),%edx
2e39: 83 c4 10 add $0x10,%esp
2e3c: 39 d0 cmp %edx,%eax
2e3e: 0f 85 84 02 00 00 jne 30c8 <sbrktest+0x398>
a = sbrk(0);
2e44: 83 ec 0c sub $0xc,%esp
2e47: 6a 00 push $0x0
2e49: e8 dc 0a 00 00 call 392a <sbrk>
2e4e: 89 c6 mov %eax,%esi
c = sbrk(4096);
2e50: c7 04 24 00 10 00 00 movl $0x1000,(%esp)
2e57: e8 ce 0a 00 00 call 392a <sbrk>
if(c != a || sbrk(0) != a + 4096){
2e5c: 83 c4 10 add $0x10,%esp
2e5f: 39 c6 cmp %eax,%esi
c = sbrk(4096);
2e61: 89 c7 mov %eax,%edi
if(c != a || sbrk(0) != a + 4096){
2e63: 0f 85 48 02 00 00 jne 30b1 <sbrktest+0x381>
2e69: 83 ec 0c sub $0xc,%esp
2e6c: 6a 00 push $0x0
2e6e: e8 b7 0a 00 00 call 392a <sbrk>
2e73: 8d 96 00 10 00 00 lea 0x1000(%esi),%edx
2e79: 83 c4 10 add $0x10,%esp
2e7c: 39 d0 cmp %edx,%eax
2e7e: 0f 85 2d 02 00 00 jne 30b1 <sbrktest+0x381>
if(*lastaddr == 99){
2e84: 80 3d ff ff 3f 06 63 cmpb $0x63,0x63fffff
2e8b: 0f 84 09 02 00 00 je 309a <sbrktest+0x36a>
a = sbrk(0);
2e91: 83 ec 0c sub $0xc,%esp
2e94: 6a 00 push $0x0
2e96: e8 8f 0a 00 00 call 392a <sbrk>
c = sbrk(-(sbrk(0) - oldbrk));
2e9b: c7 04 24 00 00 00 00 movl $0x0,(%esp)
a = sbrk(0);
2ea2: 89 c6 mov %eax,%esi
c = sbrk(-(sbrk(0) - oldbrk));
2ea4: e8 81 0a 00 00 call 392a <sbrk>
2ea9: 89 d9 mov %ebx,%ecx
2eab: 29 c1 sub %eax,%ecx
2ead: 89 0c 24 mov %ecx,(%esp)
2eb0: e8 75 0a 00 00 call 392a <sbrk>
if(c != a){
2eb5: 83 c4 10 add $0x10,%esp
2eb8: 39 c6 cmp %eax,%esi
2eba: 0f 85 c3 01 00 00 jne 3083 <sbrktest+0x353>
for(a = (char*)(KERNBASE); a < (char*) (KERNBASE+2000000); a += 50000){
2ec0: be 00 00 00 80 mov $0x80000000,%esi
ppid = getpid();
2ec5: e8 58 0a 00 00 call 3922 <getpid>
2eca: 89 c7 mov %eax,%edi
pid = fork();
2ecc: e8 c9 09 00 00 call 389a <fork>
if(pid < 0){
2ed1: 85 c0 test %eax,%eax
2ed3: 0f 88 93 01 00 00 js 306c <sbrktest+0x33c>
if(pid == 0){
2ed9: 0f 84 6b 01 00 00 je 304a <sbrktest+0x31a>
for(a = (char*)(KERNBASE); a < (char*) (KERNBASE+2000000); a += 50000){
2edf: 81 c6 50 c3 00 00 add $0xc350,%esi
wait();
2ee5: e8 c0 09 00 00 call 38aa <wait>
for(a = (char*)(KERNBASE); a < (char*) (KERNBASE+2000000); a += 50000){
2eea: 81 fe 80 84 1e 80 cmp $0x801e8480,%esi
2ef0: 75 d3 jne 2ec5 <sbrktest+0x195>
if(pipe(fds) != 0){
2ef2: 8d 45 b8 lea -0x48(%ebp),%eax
2ef5: 83 ec 0c sub $0xc,%esp
2ef8: 50 push %eax
2ef9: e8 b4 09 00 00 call 38b2 <pipe>
2efe: 83 c4 10 add $0x10,%esp
2f01: 85 c0 test %eax,%eax
2f03: 0f 85 2e 01 00 00 jne 3037 <sbrktest+0x307>
2f09: 8d 7d c0 lea -0x40(%ebp),%edi
2f0c: 89 fe mov %edi,%esi
2f0e: eb 23 jmp 2f33 <sbrktest+0x203>
if(pids[i] != -1)
2f10: 83 f8 ff cmp $0xffffffff,%eax
2f13: 74 14 je 2f29 <sbrktest+0x1f9>
read(fds[0], &scratch, 1);
2f15: 8d 45 b7 lea -0x49(%ebp),%eax
2f18: 83 ec 04 sub $0x4,%esp
2f1b: 6a 01 push $0x1
2f1d: 50 push %eax
2f1e: ff 75 b8 pushl -0x48(%ebp)
2f21: e8 94 09 00 00 call 38ba <read>
2f26: 83 c4 10 add $0x10,%esp
for(i = 0; i < sizeof(pids)/sizeof(pids[0]); i++){
2f29: 8d 45 e8 lea -0x18(%ebp),%eax
2f2c: 83 c6 04 add $0x4,%esi
2f2f: 39 c6 cmp %eax,%esi
2f31: 74 4f je 2f82 <sbrktest+0x252>
if((pids[i] = fork()) == 0){
2f33: e8 62 09 00 00 call 389a <fork>
2f38: 85 c0 test %eax,%eax
2f3a: 89 06 mov %eax,(%esi)
2f3c: 75 d2 jne 2f10 <sbrktest+0x1e0>
sbrk(BIG - (uint)sbrk(0));
2f3e: 83 ec 0c sub $0xc,%esp
2f41: 6a 00 push $0x0
2f43: e8 e2 09 00 00 call 392a <sbrk>
2f48: ba 00 00 40 06 mov $0x6400000,%edx
2f4d: 29 c2 sub %eax,%edx
2f4f: 89 14 24 mov %edx,(%esp)
2f52: e8 d3 09 00 00 call 392a <sbrk>
write(fds[1], "x", 1);
2f57: 83 c4 0c add $0xc,%esp
2f5a: 6a 01 push $0x1
2f5c: 68 b1 46 00 00 push $0x46b1
2f61: ff 75 bc pushl -0x44(%ebp)
2f64: e8 59 09 00 00 call 38c2 <write>
2f69: 83 c4 10 add $0x10,%esp
2f6c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
for(;;) sleep(1000);
2f70: 83 ec 0c sub $0xc,%esp
2f73: 68 e8 03 00 00 push $0x3e8
2f78: e8 b5 09 00 00 call 3932 <sleep>
2f7d: 83 c4 10 add $0x10,%esp
2f80: eb ee jmp 2f70 <sbrktest+0x240>
c = sbrk(4096);
2f82: 83 ec 0c sub $0xc,%esp
2f85: 68 00 10 00 00 push $0x1000
2f8a: e8 9b 09 00 00 call 392a <sbrk>
2f8f: 83 c4 10 add $0x10,%esp
2f92: 89 45 a4 mov %eax,-0x5c(%ebp)
if(pids[i] == -1)
2f95: 8b 07 mov (%edi),%eax
2f97: 83 f8 ff cmp $0xffffffff,%eax
2f9a: 74 11 je 2fad <sbrktest+0x27d>
kill(pids[i]);
2f9c: 83 ec 0c sub $0xc,%esp
2f9f: 50 push %eax
2fa0: e8 2d 09 00 00 call 38d2 <kill>
wait();
2fa5: e8 00 09 00 00 call 38aa <wait>
2faa: 83 c4 10 add $0x10,%esp
2fad: 83 c7 04 add $0x4,%edi
for(i = 0; i < sizeof(pids)/sizeof(pids[0]); i++){
2fb0: 39 fe cmp %edi,%esi
2fb2: 75 e1 jne 2f95 <sbrktest+0x265>
if(c == (char*)0xffffffff){
2fb4: 83 7d a4 ff cmpl $0xffffffff,-0x5c(%ebp)
2fb8: 74 66 je 3020 <sbrktest+0x2f0>
if(sbrk(0) > oldbrk)
2fba: 83 ec 0c sub $0xc,%esp
2fbd: 6a 00 push $0x0
2fbf: e8 66 09 00 00 call 392a <sbrk>
2fc4: 83 c4 10 add $0x10,%esp
2fc7: 39 d8 cmp %ebx,%eax
2fc9: 77 3c ja 3007 <sbrktest+0x2d7>
printf(stdout, "sbrk test OK\n");
2fcb: 83 ec 08 sub $0x8,%esp
2fce: 68 f0 4b 00 00 push $0x4bf0
2fd3: ff 35 08 5e 00 00 pushl 0x5e08
2fd9: e8 22 0a 00 00 call 3a00 <printf>
}
2fde: 83 c4 10 add $0x10,%esp
2fe1: 8d 65 f4 lea -0xc(%ebp),%esp
2fe4: 5b pop %ebx
2fe5: 5e pop %esi
2fe6: 5f pop %edi
2fe7: 5d pop %ebp
2fe8: c3 ret
printf(stdout, "sbrk test failed %d %x %x\n", i, a, b);
2fe9: 83 ec 0c sub $0xc,%esp
2fec: 50 push %eax
2fed: 56 push %esi
2fee: 57 push %edi
2fef: 68 53 4b 00 00 push $0x4b53
2ff4: ff 35 08 5e 00 00 pushl 0x5e08
2ffa: e8 01 0a 00 00 call 3a00 <printf>
exit();
2fff: 83 c4 20 add $0x20,%esp
3002: e8 9b 08 00 00 call 38a2 <exit>
sbrk(-(sbrk(0) - oldbrk));
3007: 83 ec 0c sub $0xc,%esp
300a: 6a 00 push $0x0
300c: e8 19 09 00 00 call 392a <sbrk>
3011: 29 c3 sub %eax,%ebx
3013: 89 1c 24 mov %ebx,(%esp)
3016: e8 0f 09 00 00 call 392a <sbrk>
301b: 83 c4 10 add $0x10,%esp
301e: eb ab jmp 2fcb <sbrktest+0x29b>
printf(stdout, "failed sbrk leaked memory\n");
3020: 50 push %eax
3021: 50 push %eax
3022: 68 d5 4b 00 00 push $0x4bd5
3027: ff 35 08 5e 00 00 pushl 0x5e08
302d: e8 ce 09 00 00 call 3a00 <printf>
exit();
3032: e8 6b 08 00 00 call 38a2 <exit>
printf(1, "pipe() failed\n");
3037: 52 push %edx
3038: 52 push %edx
3039: 68 91 40 00 00 push $0x4091
303e: 6a 01 push $0x1
3040: e8 bb 09 00 00 call 3a00 <printf>
exit();
3045: e8 58 08 00 00 call 38a2 <exit>
printf(stdout, "oops could read %x = %x\n", a, *a);
304a: 0f be 06 movsbl (%esi),%eax
304d: 50 push %eax
304e: 56 push %esi
304f: 68 bc 4b 00 00 push $0x4bbc
3054: ff 35 08 5e 00 00 pushl 0x5e08
305a: e8 a1 09 00 00 call 3a00 <printf>
kill(ppid);
305f: 89 3c 24 mov %edi,(%esp)
3062: e8 6b 08 00 00 call 38d2 <kill>
exit();
3067: e8 36 08 00 00 call 38a2 <exit>
printf(stdout, "fork failed\n");
306c: 51 push %ecx
306d: 51 push %ecx
306e: 68 99 4c 00 00 push $0x4c99
3073: ff 35 08 5e 00 00 pushl 0x5e08
3079: e8 82 09 00 00 call 3a00 <printf>
exit();
307e: e8 1f 08 00 00 call 38a2 <exit>
printf(stdout, "sbrk downsize failed, a %x c %x\n", a, c);
3083: 50 push %eax
3084: 56 push %esi
3085: 68 9c 53 00 00 push $0x539c
308a: ff 35 08 5e 00 00 pushl 0x5e08
3090: e8 6b 09 00 00 call 3a00 <printf>
exit();
3095: e8 08 08 00 00 call 38a2 <exit>
printf(stdout, "sbrk de-allocation didn't really deallocate\n");
309a: 53 push %ebx
309b: 53 push %ebx
309c: 68 6c 53 00 00 push $0x536c
30a1: ff 35 08 5e 00 00 pushl 0x5e08
30a7: e8 54 09 00 00 call 3a00 <printf>
exit();
30ac: e8 f1 07 00 00 call 38a2 <exit>
printf(stdout, "sbrk re-allocation failed, a %x c %x\n", a, c);
30b1: 57 push %edi
30b2: 56 push %esi
30b3: 68 44 53 00 00 push $0x5344
30b8: ff 35 08 5e 00 00 pushl 0x5e08
30be: e8 3d 09 00 00 call 3a00 <printf>
exit();
30c3: e8 da 07 00 00 call 38a2 <exit>
printf(stdout, "sbrk deallocation produced wrong address, a %x c %x\n", a, c);
30c8: 50 push %eax
30c9: 56 push %esi
30ca: 68 0c 53 00 00 push $0x530c
30cf: ff 35 08 5e 00 00 pushl 0x5e08
30d5: e8 26 09 00 00 call 3a00 <printf>
exit();
30da: e8 c3 07 00 00 call 38a2 <exit>
printf(stdout, "sbrk could not deallocate\n");
30df: 56 push %esi
30e0: 56 push %esi
30e1: 68 a1 4b 00 00 push $0x4ba1
30e6: ff 35 08 5e 00 00 pushl 0x5e08
30ec: e8 0f 09 00 00 call 3a00 <printf>
exit();
30f1: e8 ac 07 00 00 call 38a2 <exit>
printf(stdout, "sbrk test failed to grow big address space; enough phys mem?\n");
30f6: 57 push %edi
30f7: 57 push %edi
30f8: 68 cc 52 00 00 push $0x52cc
30fd: ff 35 08 5e 00 00 pushl 0x5e08
3103: e8 f8 08 00 00 call 3a00 <printf>
exit();
3108: e8 95 07 00 00 call 38a2 <exit>
exit();
310d: e8 90 07 00 00 call 38a2 <exit>
printf(stdout, "sbrk test failed post-fork\n");
3112: 50 push %eax
3113: 50 push %eax
3114: 68 85 4b 00 00 push $0x4b85
3119: ff 35 08 5e 00 00 pushl 0x5e08
311f: e8 dc 08 00 00 call 3a00 <printf>
exit();
3124: e8 79 07 00 00 call 38a2 <exit>
printf(stdout, "sbrk test fork failed\n");
3129: 50 push %eax
312a: 50 push %eax
312b: 68 6e 4b 00 00 push $0x4b6e
3130: ff 35 08 5e 00 00 pushl 0x5e08
3136: e8 c5 08 00 00 call 3a00 <printf>
exit();
313b: e8 62 07 00 00 call 38a2 <exit>
00003140 <validateint>:
{
3140: 55 push %ebp
3141: 89 e5 mov %esp,%ebp
}
3143: 5d pop %ebp
3144: c3 ret
3145: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
3149: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
00003150 <validatetest>:
{
3150: 55 push %ebp
3151: 89 e5 mov %esp,%ebp
3153: 56 push %esi
3154: 53 push %ebx
for(p = 0; p <= (uint)hi; p += 4096){
3155: 31 db xor %ebx,%ebx
printf(stdout, "validate test\n");
3157: 83 ec 08 sub $0x8,%esp
315a: 68 fe 4b 00 00 push $0x4bfe
315f: ff 35 08 5e 00 00 pushl 0x5e08
3165: e8 96 08 00 00 call 3a00 <printf>
316a: 83 c4 10 add $0x10,%esp
316d: 8d 76 00 lea 0x0(%esi),%esi
if((pid = fork()) == 0){
3170: e8 25 07 00 00 call 389a <fork>
3175: 85 c0 test %eax,%eax
3177: 89 c6 mov %eax,%esi
3179: 74 63 je 31de <validatetest+0x8e>
sleep(0);
317b: 83 ec 0c sub $0xc,%esp
317e: 6a 00 push $0x0
3180: e8 ad 07 00 00 call 3932 <sleep>
sleep(0);
3185: c7 04 24 00 00 00 00 movl $0x0,(%esp)
318c: e8 a1 07 00 00 call 3932 <sleep>
kill(pid);
3191: 89 34 24 mov %esi,(%esp)
3194: e8 39 07 00 00 call 38d2 <kill>
wait();
3199: e8 0c 07 00 00 call 38aa <wait>
if(link("nosuchfile", (char*)p) != -1){
319e: 58 pop %eax
319f: 5a pop %edx
31a0: 53 push %ebx
31a1: 68 0d 4c 00 00 push $0x4c0d
31a6: e8 57 07 00 00 call 3902 <link>
31ab: 83 c4 10 add $0x10,%esp
31ae: 83 f8 ff cmp $0xffffffff,%eax
31b1: 75 30 jne 31e3 <validatetest+0x93>
for(p = 0; p <= (uint)hi; p += 4096){
31b3: 81 c3 00 10 00 00 add $0x1000,%ebx
31b9: 81 fb 00 40 11 00 cmp $0x114000,%ebx
31bf: 75 af jne 3170 <validatetest+0x20>
printf(stdout, "validate ok\n");
31c1: 83 ec 08 sub $0x8,%esp
31c4: 68 31 4c 00 00 push $0x4c31
31c9: ff 35 08 5e 00 00 pushl 0x5e08
31cf: e8 2c 08 00 00 call 3a00 <printf>
}
31d4: 83 c4 10 add $0x10,%esp
31d7: 8d 65 f8 lea -0x8(%ebp),%esp
31da: 5b pop %ebx
31db: 5e pop %esi
31dc: 5d pop %ebp
31dd: c3 ret
exit();
31de: e8 bf 06 00 00 call 38a2 <exit>
printf(stdout, "link should not succeed\n");
31e3: 83 ec 08 sub $0x8,%esp
31e6: 68 18 4c 00 00 push $0x4c18
31eb: ff 35 08 5e 00 00 pushl 0x5e08
31f1: e8 0a 08 00 00 call 3a00 <printf>
exit();
31f6: e8 a7 06 00 00 call 38a2 <exit>
31fb: 90 nop
31fc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
00003200 <bsstest>:
{
3200: 55 push %ebp
3201: 89 e5 mov %esp,%ebp
3203: 83 ec 10 sub $0x10,%esp
printf(stdout, "bss test\n");
3206: 68 3e 4c 00 00 push $0x4c3e
320b: ff 35 08 5e 00 00 pushl 0x5e08
3211: e8 ea 07 00 00 call 3a00 <printf>
if(uninit[i] != '\0'){
3216: 83 c4 10 add $0x10,%esp
3219: 80 3d 00 5f 00 00 00 cmpb $0x0,0x5f00
3220: 75 39 jne 325b <bsstest+0x5b>
for(i = 0; i < sizeof(uninit); i++){
3222: b8 01 00 00 00 mov $0x1,%eax
3227: 89 f6 mov %esi,%esi
3229: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
if(uninit[i] != '\0'){
3230: 80 b8 00 5f 00 00 00 cmpb $0x0,0x5f00(%eax)
3237: 75 22 jne 325b <bsstest+0x5b>
for(i = 0; i < sizeof(uninit); i++){
3239: 83 c0 01 add $0x1,%eax
323c: 3d 10 27 00 00 cmp $0x2710,%eax
3241: 75 ed jne 3230 <bsstest+0x30>
printf(stdout, "bss test ok\n");
3243: 83 ec 08 sub $0x8,%esp
3246: 68 59 4c 00 00 push $0x4c59
324b: ff 35 08 5e 00 00 pushl 0x5e08
3251: e8 aa 07 00 00 call 3a00 <printf>
}
3256: 83 c4 10 add $0x10,%esp
3259: c9 leave
325a: c3 ret
printf(stdout, "bss test failed\n");
325b: 83 ec 08 sub $0x8,%esp
325e: 68 48 4c 00 00 push $0x4c48
3263: ff 35 08 5e 00 00 pushl 0x5e08
3269: e8 92 07 00 00 call 3a00 <printf>
exit();
326e: e8 2f 06 00 00 call 38a2 <exit>
3273: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
3279: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
00003280 <bigargtest>:
{
3280: 55 push %ebp
3281: 89 e5 mov %esp,%ebp
3283: 83 ec 14 sub $0x14,%esp
unlink("bigarg-ok");
3286: 68 66 4c 00 00 push $0x4c66
328b: e8 62 06 00 00 call 38f2 <unlink>
pid = fork();
3290: e8 05 06 00 00 call 389a <fork>
if(pid == 0){
3295: 83 c4 10 add $0x10,%esp
3298: 85 c0 test %eax,%eax
329a: 74 3f je 32db <bigargtest+0x5b>
} else if(pid < 0){
329c: 0f 88 c2 00 00 00 js 3364 <bigargtest+0xe4>
wait();
32a2: e8 03 06 00 00 call 38aa <wait>
fd = open("bigarg-ok", 0);
32a7: 83 ec 08 sub $0x8,%esp
32aa: 6a 00 push $0x0
32ac: 68 66 4c 00 00 push $0x4c66
32b1: e8 2c 06 00 00 call 38e2 <open>
if(fd < 0){
32b6: 83 c4 10 add $0x10,%esp
32b9: 85 c0 test %eax,%eax
32bb: 0f 88 8c 00 00 00 js 334d <bigargtest+0xcd>
close(fd);
32c1: 83 ec 0c sub $0xc,%esp
32c4: 50 push %eax
32c5: e8 00 06 00 00 call 38ca <close>
unlink("bigarg-ok");
32ca: c7 04 24 66 4c 00 00 movl $0x4c66,(%esp)
32d1: e8 1c 06 00 00 call 38f2 <unlink>
}
32d6: 83 c4 10 add $0x10,%esp
32d9: c9 leave
32da: c3 ret
32db: b8 20 5e 00 00 mov $0x5e20,%eax
args[i] = "bigargs test: failed\n ";
32e0: c7 00 c0 53 00 00 movl $0x53c0,(%eax)
32e6: 83 c0 04 add $0x4,%eax
for(i = 0; i < MAXARG-1; i++)
32e9: 3d 9c 5e 00 00 cmp $0x5e9c,%eax
32ee: 75 f0 jne 32e0 <bigargtest+0x60>
printf(stdout, "bigarg test\n");
32f0: 51 push %ecx
32f1: 51 push %ecx
32f2: 68 70 4c 00 00 push $0x4c70
32f7: ff 35 08 5e 00 00 pushl 0x5e08
args[MAXARG-1] = 0;
32fd: c7 05 9c 5e 00 00 00 movl $0x0,0x5e9c
3304: 00 00 00
printf(stdout, "bigarg test\n");
3307: e8 f4 06 00 00 call 3a00 <printf>
exec("echo", args);
330c: 58 pop %eax
330d: 5a pop %edx
330e: 68 20 5e 00 00 push $0x5e20
3313: 68 3d 3e 00 00 push $0x3e3d
3318: e8 bd 05 00 00 call 38da <exec>
printf(stdout, "bigarg test ok\n");
331d: 59 pop %ecx
331e: 58 pop %eax
331f: 68 7d 4c 00 00 push $0x4c7d
3324: ff 35 08 5e 00 00 pushl 0x5e08
332a: e8 d1 06 00 00 call 3a00 <printf>
fd = open("bigarg-ok", O_CREATE);
332f: 58 pop %eax
3330: 5a pop %edx
3331: 68 00 02 00 00 push $0x200
3336: 68 66 4c 00 00 push $0x4c66
333b: e8 a2 05 00 00 call 38e2 <open>
close(fd);
3340: 89 04 24 mov %eax,(%esp)
3343: e8 82 05 00 00 call 38ca <close>
exit();
3348: e8 55 05 00 00 call 38a2 <exit>
printf(stdout, "bigarg test failed!\n");
334d: 50 push %eax
334e: 50 push %eax
334f: 68 a6 4c 00 00 push $0x4ca6
3354: ff 35 08 5e 00 00 pushl 0x5e08
335a: e8 a1 06 00 00 call 3a00 <printf>
exit();
335f: e8 3e 05 00 00 call 38a2 <exit>
printf(stdout, "bigargtest: fork failed\n");
3364: 52 push %edx
3365: 52 push %edx
3366: 68 8d 4c 00 00 push $0x4c8d
336b: ff 35 08 5e 00 00 pushl 0x5e08
3371: e8 8a 06 00 00 call 3a00 <printf>
exit();
3376: e8 27 05 00 00 call 38a2 <exit>
337b: 90 nop
337c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
00003380 <fsfull>:
{
3380: 55 push %ebp
3381: 89 e5 mov %esp,%ebp
3383: 57 push %edi
3384: 56 push %esi
3385: 53 push %ebx
for(nfiles = 0; ; nfiles++){
3386: 31 db xor %ebx,%ebx
{
3388: 83 ec 54 sub $0x54,%esp
printf(1, "fsfull test\n");
338b: 68 bb 4c 00 00 push $0x4cbb
3390: 6a 01 push $0x1
3392: e8 69 06 00 00 call 3a00 <printf>
3397: 83 c4 10 add $0x10,%esp
339a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
name[1] = '0' + nfiles / 1000;
33a0: b8 d3 4d 62 10 mov $0x10624dd3,%eax
name[3] = '0' + (nfiles % 100) / 10;
33a5: b9 cd cc cc cc mov $0xcccccccd,%ecx
printf(1, "writing %s\n", name);
33aa: 83 ec 04 sub $0x4,%esp
name[1] = '0' + nfiles / 1000;
33ad: f7 e3 mul %ebx
name[0] = 'f';
33af: c6 45 a8 66 movb $0x66,-0x58(%ebp)
name[5] = '\0';
33b3: c6 45 ad 00 movb $0x0,-0x53(%ebp)
name[1] = '0' + nfiles / 1000;
33b7: c1 ea 06 shr $0x6,%edx
33ba: 8d 42 30 lea 0x30(%edx),%eax
name[2] = '0' + (nfiles % 1000) / 100;
33bd: 69 d2 e8 03 00 00 imul $0x3e8,%edx,%edx
name[1] = '0' + nfiles / 1000;
33c3: 88 45 a9 mov %al,-0x57(%ebp)
name[2] = '0' + (nfiles % 1000) / 100;
33c6: 89 d8 mov %ebx,%eax
33c8: 29 d0 sub %edx,%eax
33ca: 89 c2 mov %eax,%edx
33cc: b8 1f 85 eb 51 mov $0x51eb851f,%eax
33d1: f7 e2 mul %edx
name[3] = '0' + (nfiles % 100) / 10;
33d3: b8 1f 85 eb 51 mov $0x51eb851f,%eax
name[2] = '0' + (nfiles % 1000) / 100;
33d8: c1 ea 05 shr $0x5,%edx
33db: 83 c2 30 add $0x30,%edx
33de: 88 55 aa mov %dl,-0x56(%ebp)
name[3] = '0' + (nfiles % 100) / 10;
33e1: f7 e3 mul %ebx
33e3: 89 d8 mov %ebx,%eax
33e5: c1 ea 05 shr $0x5,%edx
33e8: 6b d2 64 imul $0x64,%edx,%edx
33eb: 29 d0 sub %edx,%eax
33ed: f7 e1 mul %ecx
name[4] = '0' + (nfiles % 10);
33ef: 89 d8 mov %ebx,%eax
name[3] = '0' + (nfiles % 100) / 10;
33f1: c1 ea 03 shr $0x3,%edx
33f4: 83 c2 30 add $0x30,%edx
33f7: 88 55 ab mov %dl,-0x55(%ebp)
name[4] = '0' + (nfiles % 10);
33fa: f7 e1 mul %ecx
33fc: 89 d9 mov %ebx,%ecx
33fe: c1 ea 03 shr $0x3,%edx
3401: 8d 04 92 lea (%edx,%edx,4),%eax
3404: 01 c0 add %eax,%eax
3406: 29 c1 sub %eax,%ecx
3408: 89 c8 mov %ecx,%eax
340a: 83 c0 30 add $0x30,%eax
340d: 88 45 ac mov %al,-0x54(%ebp)
printf(1, "writing %s\n", name);
3410: 8d 45 a8 lea -0x58(%ebp),%eax
3413: 50 push %eax
3414: 68 c8 4c 00 00 push $0x4cc8
3419: 6a 01 push $0x1
341b: e8 e0 05 00 00 call 3a00 <printf>
int fd = open(name, O_CREATE|O_RDWR);
3420: 58 pop %eax
3421: 8d 45 a8 lea -0x58(%ebp),%eax
3424: 5a pop %edx
3425: 68 02 02 00 00 push $0x202
342a: 50 push %eax
342b: e8 b2 04 00 00 call 38e2 <open>
if(fd < 0){
3430: 83 c4 10 add $0x10,%esp
3433: 85 c0 test %eax,%eax
int fd = open(name, O_CREATE|O_RDWR);
3435: 89 c7 mov %eax,%edi
if(fd < 0){
3437: 78 57 js 3490 <fsfull+0x110>
int total = 0;
3439: 31 f6 xor %esi,%esi
343b: eb 05 jmp 3442 <fsfull+0xc2>
343d: 8d 76 00 lea 0x0(%esi),%esi
total += cc;
3440: 01 c6 add %eax,%esi
int cc = write(fd, buf, 512);
3442: 83 ec 04 sub $0x4,%esp
3445: 68 00 02 00 00 push $0x200
344a: 68 40 86 00 00 push $0x8640
344f: 57 push %edi
3450: e8 6d 04 00 00 call 38c2 <write>
if(cc < 512)
3455: 83 c4 10 add $0x10,%esp
3458: 3d ff 01 00 00 cmp $0x1ff,%eax
345d: 7f e1 jg 3440 <fsfull+0xc0>
printf(1, "wrote %d bytes\n", total);
345f: 83 ec 04 sub $0x4,%esp
3462: 56 push %esi
3463: 68 e4 4c 00 00 push $0x4ce4
3468: 6a 01 push $0x1
346a: e8 91 05 00 00 call 3a00 <printf>
close(fd);
346f: 89 3c 24 mov %edi,(%esp)
3472: e8 53 04 00 00 call 38ca <close>
if(total == 0)
3477: 83 c4 10 add $0x10,%esp
347a: 85 f6 test %esi,%esi
347c: 74 28 je 34a6 <fsfull+0x126>
for(nfiles = 0; ; nfiles++){
347e: 83 c3 01 add $0x1,%ebx
3481: e9 1a ff ff ff jmp 33a0 <fsfull+0x20>
3486: 8d 76 00 lea 0x0(%esi),%esi
3489: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
printf(1, "open %s failed\n", name);
3490: 8d 45 a8 lea -0x58(%ebp),%eax
3493: 83 ec 04 sub $0x4,%esp
3496: 50 push %eax
3497: 68 d4 4c 00 00 push $0x4cd4
349c: 6a 01 push $0x1
349e: e8 5d 05 00 00 call 3a00 <printf>
break;
34a3: 83 c4 10 add $0x10,%esp
name[1] = '0' + nfiles / 1000;
34a6: bf d3 4d 62 10 mov $0x10624dd3,%edi
name[2] = '0' + (nfiles % 1000) / 100;
34ab: be 1f 85 eb 51 mov $0x51eb851f,%esi
name[1] = '0' + nfiles / 1000;
34b0: 89 d8 mov %ebx,%eax
name[3] = '0' + (nfiles % 100) / 10;
34b2: b9 cd cc cc cc mov $0xcccccccd,%ecx
unlink(name);
34b7: 83 ec 0c sub $0xc,%esp
name[1] = '0' + nfiles / 1000;
34ba: f7 e7 mul %edi
name[0] = 'f';
34bc: c6 45 a8 66 movb $0x66,-0x58(%ebp)
name[5] = '\0';
34c0: c6 45 ad 00 movb $0x0,-0x53(%ebp)
name[1] = '0' + nfiles / 1000;
34c4: c1 ea 06 shr $0x6,%edx
34c7: 8d 42 30 lea 0x30(%edx),%eax
name[2] = '0' + (nfiles % 1000) / 100;
34ca: 69 d2 e8 03 00 00 imul $0x3e8,%edx,%edx
name[1] = '0' + nfiles / 1000;
34d0: 88 45 a9 mov %al,-0x57(%ebp)
name[2] = '0' + (nfiles % 1000) / 100;
34d3: 89 d8 mov %ebx,%eax
34d5: 29 d0 sub %edx,%eax
34d7: f7 e6 mul %esi
name[3] = '0' + (nfiles % 100) / 10;
34d9: 89 d8 mov %ebx,%eax
name[2] = '0' + (nfiles % 1000) / 100;
34db: c1 ea 05 shr $0x5,%edx
34de: 83 c2 30 add $0x30,%edx
34e1: 88 55 aa mov %dl,-0x56(%ebp)
name[3] = '0' + (nfiles % 100) / 10;
34e4: f7 e6 mul %esi
34e6: 89 d8 mov %ebx,%eax
34e8: c1 ea 05 shr $0x5,%edx
34eb: 6b d2 64 imul $0x64,%edx,%edx
34ee: 29 d0 sub %edx,%eax
34f0: f7 e1 mul %ecx
name[4] = '0' + (nfiles % 10);
34f2: 89 d8 mov %ebx,%eax
name[3] = '0' + (nfiles % 100) / 10;
34f4: c1 ea 03 shr $0x3,%edx
34f7: 83 c2 30 add $0x30,%edx
34fa: 88 55 ab mov %dl,-0x55(%ebp)
name[4] = '0' + (nfiles % 10);
34fd: f7 e1 mul %ecx
34ff: 89 d9 mov %ebx,%ecx
nfiles--;
3501: 83 eb 01 sub $0x1,%ebx
name[4] = '0' + (nfiles % 10);
3504: c1 ea 03 shr $0x3,%edx
3507: 8d 04 92 lea (%edx,%edx,4),%eax
350a: 01 c0 add %eax,%eax
350c: 29 c1 sub %eax,%ecx
350e: 89 c8 mov %ecx,%eax
3510: 83 c0 30 add $0x30,%eax
3513: 88 45 ac mov %al,-0x54(%ebp)
unlink(name);
3516: 8d 45 a8 lea -0x58(%ebp),%eax
3519: 50 push %eax
351a: e8 d3 03 00 00 call 38f2 <unlink>
while(nfiles >= 0){
351f: 83 c4 10 add $0x10,%esp
3522: 83 fb ff cmp $0xffffffff,%ebx
3525: 75 89 jne 34b0 <fsfull+0x130>
printf(1, "fsfull test finished\n");
3527: 83 ec 08 sub $0x8,%esp
352a: 68 f4 4c 00 00 push $0x4cf4
352f: 6a 01 push $0x1
3531: e8 ca 04 00 00 call 3a00 <printf>
}
3536: 83 c4 10 add $0x10,%esp
3539: 8d 65 f4 lea -0xc(%ebp),%esp
353c: 5b pop %ebx
353d: 5e pop %esi
353e: 5f pop %edi
353f: 5d pop %ebp
3540: c3 ret
3541: eb 0d jmp 3550 <uio>
3543: 90 nop
3544: 90 nop
3545: 90 nop
3546: 90 nop
3547: 90 nop
3548: 90 nop
3549: 90 nop
354a: 90 nop
354b: 90 nop
354c: 90 nop
354d: 90 nop
354e: 90 nop
354f: 90 nop
00003550 <uio>:
{
3550: 55 push %ebp
3551: 89 e5 mov %esp,%ebp
3553: 83 ec 10 sub $0x10,%esp
printf(1, "uio test\n");
3556: 68 0a 4d 00 00 push $0x4d0a
355b: 6a 01 push $0x1
355d: e8 9e 04 00 00 call 3a00 <printf>
pid = fork();
3562: e8 33 03 00 00 call 389a <fork>
if(pid == 0){
3567: 83 c4 10 add $0x10,%esp
356a: 85 c0 test %eax,%eax
356c: 74 1b je 3589 <uio+0x39>
} else if(pid < 0){
356e: 78 3d js 35ad <uio+0x5d>
wait();
3570: e8 35 03 00 00 call 38aa <wait>
printf(1, "uio test done\n");
3575: 83 ec 08 sub $0x8,%esp
3578: 68 14 4d 00 00 push $0x4d14
357d: 6a 01 push $0x1
357f: e8 7c 04 00 00 call 3a00 <printf>
}
3584: 83 c4 10 add $0x10,%esp
3587: c9 leave
3588: c3 ret
asm volatile("outb %0,%1"::"a"(val), "d" (port));
3589: b8 09 00 00 00 mov $0x9,%eax
358e: ba 70 00 00 00 mov $0x70,%edx
3593: ee out %al,(%dx)
asm volatile("inb %1,%0" : "=a" (val) : "d" (port));
3594: ba 71 00 00 00 mov $0x71,%edx
3599: ec in (%dx),%al
printf(1, "uio: uio succeeded; test FAILED\n");
359a: 52 push %edx
359b: 52 push %edx
359c: 68 a0 54 00 00 push $0x54a0
35a1: 6a 01 push $0x1
35a3: e8 58 04 00 00 call 3a00 <printf>
exit();
35a8: e8 f5 02 00 00 call 38a2 <exit>
printf (1, "fork failed\n");
35ad: 50 push %eax
35ae: 50 push %eax
35af: 68 99 4c 00 00 push $0x4c99
35b4: 6a 01 push $0x1
35b6: e8 45 04 00 00 call 3a00 <printf>
exit();
35bb: e8 e2 02 00 00 call 38a2 <exit>
000035c0 <argptest>:
{
35c0: 55 push %ebp
35c1: 89 e5 mov %esp,%ebp
35c3: 53 push %ebx
35c4: 83 ec 0c sub $0xc,%esp
fd = open("init", O_RDONLY);
35c7: 6a 00 push $0x0
35c9: 68 23 4d 00 00 push $0x4d23
35ce: e8 0f 03 00 00 call 38e2 <open>
if (fd < 0) {
35d3: 83 c4 10 add $0x10,%esp
35d6: 85 c0 test %eax,%eax
35d8: 78 39 js 3613 <argptest+0x53>
read(fd, sbrk(0) - 1, -1);
35da: 83 ec 0c sub $0xc,%esp
35dd: 89 c3 mov %eax,%ebx
35df: 6a 00 push $0x0
35e1: e8 44 03 00 00 call 392a <sbrk>
35e6: 83 c4 0c add $0xc,%esp
35e9: 83 e8 01 sub $0x1,%eax
35ec: 6a ff push $0xffffffff
35ee: 50 push %eax
35ef: 53 push %ebx
35f0: e8 c5 02 00 00 call 38ba <read>
close(fd);
35f5: 89 1c 24 mov %ebx,(%esp)
35f8: e8 cd 02 00 00 call 38ca <close>
printf(1, "arg test passed\n");
35fd: 58 pop %eax
35fe: 5a pop %edx
35ff: 68 35 4d 00 00 push $0x4d35
3604: 6a 01 push $0x1
3606: e8 f5 03 00 00 call 3a00 <printf>
}
360b: 83 c4 10 add $0x10,%esp
360e: 8b 5d fc mov -0x4(%ebp),%ebx
3611: c9 leave
3612: c3 ret
printf(2, "open failed\n");
3613: 51 push %ecx
3614: 51 push %ecx
3615: 68 28 4d 00 00 push $0x4d28
361a: 6a 02 push $0x2
361c: e8 df 03 00 00 call 3a00 <printf>
exit();
3621: e8 7c 02 00 00 call 38a2 <exit>
3626: 8d 76 00 lea 0x0(%esi),%esi
3629: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
00003630 <rand>:
randstate = randstate * 1664525 + 1013904223;
3630: 69 05 04 5e 00 00 0d imul $0x19660d,0x5e04,%eax
3637: 66 19 00
{
363a: 55 push %ebp
363b: 89 e5 mov %esp,%ebp
}
363d: 5d pop %ebp
randstate = randstate * 1664525 + 1013904223;
363e: 05 5f f3 6e 3c add $0x3c6ef35f,%eax
3643: a3 04 5e 00 00 mov %eax,0x5e04
}
3648: c3 ret
3649: 66 90 xchg %ax,%ax
364b: 66 90 xchg %ax,%ax
364d: 66 90 xchg %ax,%ax
364f: 90 nop
00003650 <strcpy>:
#include "user.h"
#include "x86.h"
char*
strcpy(char *s, const char *t)
{
3650: 55 push %ebp
3651: 89 e5 mov %esp,%ebp
3653: 53 push %ebx
3654: 8b 45 08 mov 0x8(%ebp),%eax
3657: 8b 4d 0c mov 0xc(%ebp),%ecx
char *os;
os = s;
while((*s++ = *t++) != 0)
365a: 89 c2 mov %eax,%edx
365c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
3660: 83 c1 01 add $0x1,%ecx
3663: 0f b6 59 ff movzbl -0x1(%ecx),%ebx
3667: 83 c2 01 add $0x1,%edx
366a: 84 db test %bl,%bl
366c: 88 5a ff mov %bl,-0x1(%edx)
366f: 75 ef jne 3660 <strcpy+0x10>
;
return os;
}
3671: 5b pop %ebx
3672: 5d pop %ebp
3673: c3 ret
3674: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
367a: 8d bf 00 00 00 00 lea 0x0(%edi),%edi
00003680 <strcmp>:
int
strcmp(const char *p, const char *q)
{
3680: 55 push %ebp
3681: 89 e5 mov %esp,%ebp
3683: 53 push %ebx
3684: 8b 55 08 mov 0x8(%ebp),%edx
3687: 8b 4d 0c mov 0xc(%ebp),%ecx
while(*p && *p == *q)
368a: 0f b6 02 movzbl (%edx),%eax
368d: 0f b6 19 movzbl (%ecx),%ebx
3690: 84 c0 test %al,%al
3692: 75 1c jne 36b0 <strcmp+0x30>
3694: eb 2a jmp 36c0 <strcmp+0x40>
3696: 8d 76 00 lea 0x0(%esi),%esi
3699: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
p++, q++;
36a0: 83 c2 01 add $0x1,%edx
while(*p && *p == *q)
36a3: 0f b6 02 movzbl (%edx),%eax
p++, q++;
36a6: 83 c1 01 add $0x1,%ecx
36a9: 0f b6 19 movzbl (%ecx),%ebx
while(*p && *p == *q)
36ac: 84 c0 test %al,%al
36ae: 74 10 je 36c0 <strcmp+0x40>
36b0: 38 d8 cmp %bl,%al
36b2: 74 ec je 36a0 <strcmp+0x20>
return (uchar)*p - (uchar)*q;
36b4: 29 d8 sub %ebx,%eax
}
36b6: 5b pop %ebx
36b7: 5d pop %ebp
36b8: c3 ret
36b9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
36c0: 31 c0 xor %eax,%eax
return (uchar)*p - (uchar)*q;
36c2: 29 d8 sub %ebx,%eax
}
36c4: 5b pop %ebx
36c5: 5d pop %ebp
36c6: c3 ret
36c7: 89 f6 mov %esi,%esi
36c9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
000036d0 <strlen>:
uint
strlen(const char *s)
{
36d0: 55 push %ebp
36d1: 89 e5 mov %esp,%ebp
36d3: 8b 4d 08 mov 0x8(%ebp),%ecx
int n;
for(n = 0; s[n]; n++)
36d6: 80 39 00 cmpb $0x0,(%ecx)
36d9: 74 15 je 36f0 <strlen+0x20>
36db: 31 d2 xor %edx,%edx
36dd: 8d 76 00 lea 0x0(%esi),%esi
36e0: 83 c2 01 add $0x1,%edx
36e3: 80 3c 11 00 cmpb $0x0,(%ecx,%edx,1)
36e7: 89 d0 mov %edx,%eax
36e9: 75 f5 jne 36e0 <strlen+0x10>
;
return n;
}
36eb: 5d pop %ebp
36ec: c3 ret
36ed: 8d 76 00 lea 0x0(%esi),%esi
for(n = 0; s[n]; n++)
36f0: 31 c0 xor %eax,%eax
}
36f2: 5d pop %ebp
36f3: c3 ret
36f4: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
36fa: 8d bf 00 00 00 00 lea 0x0(%edi),%edi
00003700 <memset>:
void*
memset(void *dst, int c, uint n)
{
3700: 55 push %ebp
3701: 89 e5 mov %esp,%ebp
3703: 57 push %edi
3704: 8b 55 08 mov 0x8(%ebp),%edx
}
static inline void
stosb(void *addr, int data, int cnt)
{
asm volatile("cld; rep stosb" :
3707: 8b 4d 10 mov 0x10(%ebp),%ecx
370a: 8b 45 0c mov 0xc(%ebp),%eax
370d: 89 d7 mov %edx,%edi
370f: fc cld
3710: f3 aa rep stos %al,%es:(%edi)
stosb(dst, c, n);
return dst;
}
3712: 89 d0 mov %edx,%eax
3714: 5f pop %edi
3715: 5d pop %ebp
3716: c3 ret
3717: 89 f6 mov %esi,%esi
3719: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
00003720 <strchr>:
char*
strchr(const char *s, char c)
{
3720: 55 push %ebp
3721: 89 e5 mov %esp,%ebp
3723: 53 push %ebx
3724: 8b 45 08 mov 0x8(%ebp),%eax
3727: 8b 5d 0c mov 0xc(%ebp),%ebx
for(; *s; s++)
372a: 0f b6 10 movzbl (%eax),%edx
372d: 84 d2 test %dl,%dl
372f: 74 1d je 374e <strchr+0x2e>
if(*s == c)
3731: 38 d3 cmp %dl,%bl
3733: 89 d9 mov %ebx,%ecx
3735: 75 0d jne 3744 <strchr+0x24>
3737: eb 17 jmp 3750 <strchr+0x30>
3739: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
3740: 38 ca cmp %cl,%dl
3742: 74 0c je 3750 <strchr+0x30>
for(; *s; s++)
3744: 83 c0 01 add $0x1,%eax
3747: 0f b6 10 movzbl (%eax),%edx
374a: 84 d2 test %dl,%dl
374c: 75 f2 jne 3740 <strchr+0x20>
return (char*)s;
return 0;
374e: 31 c0 xor %eax,%eax
}
3750: 5b pop %ebx
3751: 5d pop %ebp
3752: c3 ret
3753: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
3759: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
00003760 <gets>:
char*
gets(char *buf, int max)
{
3760: 55 push %ebp
3761: 89 e5 mov %esp,%ebp
3763: 57 push %edi
3764: 56 push %esi
3765: 53 push %ebx
int i, cc;
char c;
for(i=0; i+1 < max; ){
3766: 31 f6 xor %esi,%esi
3768: 89 f3 mov %esi,%ebx
{
376a: 83 ec 1c sub $0x1c,%esp
376d: 8b 7d 08 mov 0x8(%ebp),%edi
for(i=0; i+1 < max; ){
3770: eb 2f jmp 37a1 <gets+0x41>
3772: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
cc = read(0, &c, 1);
3778: 8d 45 e7 lea -0x19(%ebp),%eax
377b: 83 ec 04 sub $0x4,%esp
377e: 6a 01 push $0x1
3780: 50 push %eax
3781: 6a 00 push $0x0
3783: e8 32 01 00 00 call 38ba <read>
if(cc < 1)
3788: 83 c4 10 add $0x10,%esp
378b: 85 c0 test %eax,%eax
378d: 7e 1c jle 37ab <gets+0x4b>
break;
buf[i++] = c;
378f: 0f b6 45 e7 movzbl -0x19(%ebp),%eax
3793: 83 c7 01 add $0x1,%edi
3796: 88 47 ff mov %al,-0x1(%edi)
if(c == '\n' || c == '\r')
3799: 3c 0a cmp $0xa,%al
379b: 74 23 je 37c0 <gets+0x60>
379d: 3c 0d cmp $0xd,%al
379f: 74 1f je 37c0 <gets+0x60>
for(i=0; i+1 < max; ){
37a1: 83 c3 01 add $0x1,%ebx
37a4: 3b 5d 0c cmp 0xc(%ebp),%ebx
37a7: 89 fe mov %edi,%esi
37a9: 7c cd jl 3778 <gets+0x18>
37ab: 89 f3 mov %esi,%ebx
break;
}
buf[i] = '\0';
return buf;
}
37ad: 8b 45 08 mov 0x8(%ebp),%eax
buf[i] = '\0';
37b0: c6 03 00 movb $0x0,(%ebx)
}
37b3: 8d 65 f4 lea -0xc(%ebp),%esp
37b6: 5b pop %ebx
37b7: 5e pop %esi
37b8: 5f pop %edi
37b9: 5d pop %ebp
37ba: c3 ret
37bb: 90 nop
37bc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
37c0: 8b 75 08 mov 0x8(%ebp),%esi
37c3: 8b 45 08 mov 0x8(%ebp),%eax
37c6: 01 de add %ebx,%esi
37c8: 89 f3 mov %esi,%ebx
buf[i] = '\0';
37ca: c6 03 00 movb $0x0,(%ebx)
}
37cd: 8d 65 f4 lea -0xc(%ebp),%esp
37d0: 5b pop %ebx
37d1: 5e pop %esi
37d2: 5f pop %edi
37d3: 5d pop %ebp
37d4: c3 ret
37d5: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
37d9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
000037e0 <stat>:
int
stat(const char *n, struct stat *st)
{
37e0: 55 push %ebp
37e1: 89 e5 mov %esp,%ebp
37e3: 56 push %esi
37e4: 53 push %ebx
int fd;
int r;
fd = open(n, O_RDONLY);
37e5: 83 ec 08 sub $0x8,%esp
37e8: 6a 00 push $0x0
37ea: ff 75 08 pushl 0x8(%ebp)
37ed: e8 f0 00 00 00 call 38e2 <open>
if(fd < 0)
37f2: 83 c4 10 add $0x10,%esp
37f5: 85 c0 test %eax,%eax
37f7: 78 27 js 3820 <stat+0x40>
return -1;
r = fstat(fd, st);
37f9: 83 ec 08 sub $0x8,%esp
37fc: ff 75 0c pushl 0xc(%ebp)
37ff: 89 c3 mov %eax,%ebx
3801: 50 push %eax
3802: e8 f3 00 00 00 call 38fa <fstat>
close(fd);
3807: 89 1c 24 mov %ebx,(%esp)
r = fstat(fd, st);
380a: 89 c6 mov %eax,%esi
close(fd);
380c: e8 b9 00 00 00 call 38ca <close>
return r;
3811: 83 c4 10 add $0x10,%esp
}
3814: 8d 65 f8 lea -0x8(%ebp),%esp
3817: 89 f0 mov %esi,%eax
3819: 5b pop %ebx
381a: 5e pop %esi
381b: 5d pop %ebp
381c: c3 ret
381d: 8d 76 00 lea 0x0(%esi),%esi
return -1;
3820: be ff ff ff ff mov $0xffffffff,%esi
3825: eb ed jmp 3814 <stat+0x34>
3827: 89 f6 mov %esi,%esi
3829: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
00003830 <atoi>:
int
atoi(const char *s)
{
3830: 55 push %ebp
3831: 89 e5 mov %esp,%ebp
3833: 53 push %ebx
3834: 8b 4d 08 mov 0x8(%ebp),%ecx
int n;
n = 0;
while('0' <= *s && *s <= '9')
3837: 0f be 11 movsbl (%ecx),%edx
383a: 8d 42 d0 lea -0x30(%edx),%eax
383d: 3c 09 cmp $0x9,%al
n = 0;
383f: b8 00 00 00 00 mov $0x0,%eax
while('0' <= *s && *s <= '9')
3844: 77 1f ja 3865 <atoi+0x35>
3846: 8d 76 00 lea 0x0(%esi),%esi
3849: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
n = n*10 + *s++ - '0';
3850: 8d 04 80 lea (%eax,%eax,4),%eax
3853: 83 c1 01 add $0x1,%ecx
3856: 8d 44 42 d0 lea -0x30(%edx,%eax,2),%eax
while('0' <= *s && *s <= '9')
385a: 0f be 11 movsbl (%ecx),%edx
385d: 8d 5a d0 lea -0x30(%edx),%ebx
3860: 80 fb 09 cmp $0x9,%bl
3863: 76 eb jbe 3850 <atoi+0x20>
return n;
}
3865: 5b pop %ebx
3866: 5d pop %ebp
3867: c3 ret
3868: 90 nop
3869: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
00003870 <memmove>:
void*
memmove(void *vdst, const void *vsrc, int n)
{
3870: 55 push %ebp
3871: 89 e5 mov %esp,%ebp
3873: 56 push %esi
3874: 53 push %ebx
3875: 8b 5d 10 mov 0x10(%ebp),%ebx
3878: 8b 45 08 mov 0x8(%ebp),%eax
387b: 8b 75 0c mov 0xc(%ebp),%esi
char *dst;
const char *src;
dst = vdst;
src = vsrc;
while(n-- > 0)
387e: 85 db test %ebx,%ebx
3880: 7e 14 jle 3896 <memmove+0x26>
3882: 31 d2 xor %edx,%edx
3884: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
*dst++ = *src++;
3888: 0f b6 0c 16 movzbl (%esi,%edx,1),%ecx
388c: 88 0c 10 mov %cl,(%eax,%edx,1)
388f: 83 c2 01 add $0x1,%edx
while(n-- > 0)
3892: 39 d3 cmp %edx,%ebx
3894: 75 f2 jne 3888 <memmove+0x18>
return vdst;
}
3896: 5b pop %ebx
3897: 5e pop %esi
3898: 5d pop %ebp
3899: c3 ret
0000389a <fork>:
name: \
movl $SYS_ ## name, %eax; \
int $T_SYSCALL; \
ret
SYSCALL(fork)
389a: b8 01 00 00 00 mov $0x1,%eax
389f: cd 40 int $0x40
38a1: c3 ret
000038a2 <exit>:
SYSCALL(exit)
38a2: b8 02 00 00 00 mov $0x2,%eax
38a7: cd 40 int $0x40
38a9: c3 ret
000038aa <wait>:
SYSCALL(wait)
38aa: b8 03 00 00 00 mov $0x3,%eax
38af: cd 40 int $0x40
38b1: c3 ret
000038b2 <pipe>:
SYSCALL(pipe)
38b2: b8 04 00 00 00 mov $0x4,%eax
38b7: cd 40 int $0x40
38b9: c3 ret
000038ba <read>:
SYSCALL(read)
38ba: b8 05 00 00 00 mov $0x5,%eax
38bf: cd 40 int $0x40
38c1: c3 ret
000038c2 <write>:
SYSCALL(write)
38c2: b8 10 00 00 00 mov $0x10,%eax
38c7: cd 40 int $0x40
38c9: c3 ret
000038ca <close>:
SYSCALL(close)
38ca: b8 15 00 00 00 mov $0x15,%eax
38cf: cd 40 int $0x40
38d1: c3 ret
000038d2 <kill>:
SYSCALL(kill)
38d2: b8 06 00 00 00 mov $0x6,%eax
38d7: cd 40 int $0x40
38d9: c3 ret
000038da <exec>:
SYSCALL(exec)
38da: b8 07 00 00 00 mov $0x7,%eax
38df: cd 40 int $0x40
38e1: c3 ret
000038e2 <open>:
SYSCALL(open)
38e2: b8 0f 00 00 00 mov $0xf,%eax
38e7: cd 40 int $0x40
38e9: c3 ret
000038ea <mknod>:
SYSCALL(mknod)
38ea: b8 11 00 00 00 mov $0x11,%eax
38ef: cd 40 int $0x40
38f1: c3 ret
000038f2 <unlink>:
SYSCALL(unlink)
38f2: b8 12 00 00 00 mov $0x12,%eax
38f7: cd 40 int $0x40
38f9: c3 ret
000038fa <fstat>:
SYSCALL(fstat)
38fa: b8 08 00 00 00 mov $0x8,%eax
38ff: cd 40 int $0x40
3901: c3 ret
00003902 <link>:
SYSCALL(link)
3902: b8 13 00 00 00 mov $0x13,%eax
3907: cd 40 int $0x40
3909: c3 ret
0000390a <mkdir>:
SYSCALL(mkdir)
390a: b8 14 00 00 00 mov $0x14,%eax
390f: cd 40 int $0x40
3911: c3 ret
00003912 <chdir>:
SYSCALL(chdir)
3912: b8 09 00 00 00 mov $0x9,%eax
3917: cd 40 int $0x40
3919: c3 ret
0000391a <dup>:
SYSCALL(dup)
391a: b8 0a 00 00 00 mov $0xa,%eax
391f: cd 40 int $0x40
3921: c3 ret
00003922 <getpid>:
SYSCALL(getpid)
3922: b8 0b 00 00 00 mov $0xb,%eax
3927: cd 40 int $0x40
3929: c3 ret
0000392a <sbrk>:
SYSCALL(sbrk)
392a: b8 0c 00 00 00 mov $0xc,%eax
392f: cd 40 int $0x40
3931: c3 ret
00003932 <sleep>:
SYSCALL(sleep)
3932: b8 0d 00 00 00 mov $0xd,%eax
3937: cd 40 int $0x40
3939: c3 ret
0000393a <uptime>:
SYSCALL(uptime)
393a: b8 0e 00 00 00 mov $0xe,%eax
393f: cd 40 int $0x40
3941: c3 ret
00003942 <waitx>:
SYSCALL(waitx)
3942: b8 16 00 00 00 mov $0x16,%eax
3947: cd 40 int $0x40
3949: c3 ret
0000394a <set_priority>:
SYSCALL(set_priority)
394a: b8 17 00 00 00 mov $0x17,%eax
394f: cd 40 int $0x40
3951: c3 ret
00003952 <getpinfo>:
SYSCALL(getpinfo)
3952: b8 18 00 00 00 mov $0x18,%eax
3957: cd 40 int $0x40
3959: c3 ret
395a: 66 90 xchg %ax,%ax
395c: 66 90 xchg %ax,%ax
395e: 66 90 xchg %ax,%ax
00003960 <printint>:
write(fd, &c, 1);
}
static void
printint(int fd, int xx, int base, int sgn)
{
3960: 55 push %ebp
3961: 89 e5 mov %esp,%ebp
3963: 57 push %edi
3964: 56 push %esi
3965: 53 push %ebx
3966: 83 ec 3c sub $0x3c,%esp
char buf[16];
int i, neg;
uint x;
neg = 0;
if(sgn && xx < 0){
3969: 85 d2 test %edx,%edx
{
396b: 89 45 c0 mov %eax,-0x40(%ebp)
neg = 1;
x = -xx;
396e: 89 d0 mov %edx,%eax
if(sgn && xx < 0){
3970: 79 76 jns 39e8 <printint+0x88>
3972: f6 45 08 01 testb $0x1,0x8(%ebp)
3976: 74 70 je 39e8 <printint+0x88>
x = -xx;
3978: f7 d8 neg %eax
neg = 1;
397a: c7 45 c4 01 00 00 00 movl $0x1,-0x3c(%ebp)
} else {
x = xx;
}
i = 0;
3981: 31 f6 xor %esi,%esi
3983: 8d 5d d7 lea -0x29(%ebp),%ebx
3986: eb 0a jmp 3992 <printint+0x32>
3988: 90 nop
3989: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
do{
buf[i++] = digits[x % base];
3990: 89 fe mov %edi,%esi
3992: 31 d2 xor %edx,%edx
3994: 8d 7e 01 lea 0x1(%esi),%edi
3997: f7 f1 div %ecx
3999: 0f b6 92 f8 54 00 00 movzbl 0x54f8(%edx),%edx
}while((x /= base) != 0);
39a0: 85 c0 test %eax,%eax
buf[i++] = digits[x % base];
39a2: 88 14 3b mov %dl,(%ebx,%edi,1)
}while((x /= base) != 0);
39a5: 75 e9 jne 3990 <printint+0x30>
if(neg)
39a7: 8b 45 c4 mov -0x3c(%ebp),%eax
39aa: 85 c0 test %eax,%eax
39ac: 74 08 je 39b6 <printint+0x56>
buf[i++] = '-';
39ae: c6 44 3d d8 2d movb $0x2d,-0x28(%ebp,%edi,1)
39b3: 8d 7e 02 lea 0x2(%esi),%edi
39b6: 8d 74 3d d7 lea -0x29(%ebp,%edi,1),%esi
39ba: 8b 7d c0 mov -0x40(%ebp),%edi
39bd: 8d 76 00 lea 0x0(%esi),%esi
39c0: 0f b6 06 movzbl (%esi),%eax
write(fd, &c, 1);
39c3: 83 ec 04 sub $0x4,%esp
39c6: 83 ee 01 sub $0x1,%esi
39c9: 6a 01 push $0x1
39cb: 53 push %ebx
39cc: 57 push %edi
39cd: 88 45 d7 mov %al,-0x29(%ebp)
39d0: e8 ed fe ff ff call 38c2 <write>
while(--i >= 0)
39d5: 83 c4 10 add $0x10,%esp
39d8: 39 de cmp %ebx,%esi
39da: 75 e4 jne 39c0 <printint+0x60>
putc(fd, buf[i]);
}
39dc: 8d 65 f4 lea -0xc(%ebp),%esp
39df: 5b pop %ebx
39e0: 5e pop %esi
39e1: 5f pop %edi
39e2: 5d pop %ebp
39e3: c3 ret
39e4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
neg = 0;
39e8: c7 45 c4 00 00 00 00 movl $0x0,-0x3c(%ebp)
39ef: eb 90 jmp 3981 <printint+0x21>
39f1: eb 0d jmp 3a00 <printf>
39f3: 90 nop
39f4: 90 nop
39f5: 90 nop
39f6: 90 nop
39f7: 90 nop
39f8: 90 nop
39f9: 90 nop
39fa: 90 nop
39fb: 90 nop
39fc: 90 nop
39fd: 90 nop
39fe: 90 nop
39ff: 90 nop
00003a00 <printf>:
// Print to the given fd. Only understands %d, %x, %p, %s.
void
printf(int fd, const char *fmt, ...)
{
3a00: 55 push %ebp
3a01: 89 e5 mov %esp,%ebp
3a03: 57 push %edi
3a04: 56 push %esi
3a05: 53 push %ebx
3a06: 83 ec 2c sub $0x2c,%esp
int c, i, state;
uint *ap;
state = 0;
ap = (uint*)(void*)&fmt + 1;
for(i = 0; fmt[i]; i++){
3a09: 8b 75 0c mov 0xc(%ebp),%esi
3a0c: 0f b6 1e movzbl (%esi),%ebx
3a0f: 84 db test %bl,%bl
3a11: 0f 84 b3 00 00 00 je 3aca <printf+0xca>
ap = (uint*)(void*)&fmt + 1;
3a17: 8d 45 10 lea 0x10(%ebp),%eax
3a1a: 83 c6 01 add $0x1,%esi
state = 0;
3a1d: 31 ff xor %edi,%edi
ap = (uint*)(void*)&fmt + 1;
3a1f: 89 45 d4 mov %eax,-0x2c(%ebp)
3a22: eb 2f jmp 3a53 <printf+0x53>
3a24: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
c = fmt[i] & 0xff;
if(state == 0){
if(c == '%'){
3a28: 83 f8 25 cmp $0x25,%eax
3a2b: 0f 84 a7 00 00 00 je 3ad8 <printf+0xd8>
write(fd, &c, 1);
3a31: 8d 45 e2 lea -0x1e(%ebp),%eax
3a34: 83 ec 04 sub $0x4,%esp
3a37: 88 5d e2 mov %bl,-0x1e(%ebp)
3a3a: 6a 01 push $0x1
3a3c: 50 push %eax
3a3d: ff 75 08 pushl 0x8(%ebp)
3a40: e8 7d fe ff ff call 38c2 <write>
3a45: 83 c4 10 add $0x10,%esp
3a48: 83 c6 01 add $0x1,%esi
for(i = 0; fmt[i]; i++){
3a4b: 0f b6 5e ff movzbl -0x1(%esi),%ebx
3a4f: 84 db test %bl,%bl
3a51: 74 77 je 3aca <printf+0xca>
if(state == 0){
3a53: 85 ff test %edi,%edi
c = fmt[i] & 0xff;
3a55: 0f be cb movsbl %bl,%ecx
3a58: 0f b6 c3 movzbl %bl,%eax
if(state == 0){
3a5b: 74 cb je 3a28 <printf+0x28>
state = '%';
} else {
putc(fd, c);
}
} else if(state == '%'){
3a5d: 83 ff 25 cmp $0x25,%edi
3a60: 75 e6 jne 3a48 <printf+0x48>
if(c == 'd'){
3a62: 83 f8 64 cmp $0x64,%eax
3a65: 0f 84 05 01 00 00 je 3b70 <printf+0x170>
printint(fd, *ap, 10, 1);
ap++;
} else if(c == 'x' || c == 'p'){
3a6b: 81 e1 f7 00 00 00 and $0xf7,%ecx
3a71: 83 f9 70 cmp $0x70,%ecx
3a74: 74 72 je 3ae8 <printf+0xe8>
printint(fd, *ap, 16, 0);
ap++;
} else if(c == 's'){
3a76: 83 f8 73 cmp $0x73,%eax
3a79: 0f 84 99 00 00 00 je 3b18 <printf+0x118>
s = "(null)";
while(*s != 0){
putc(fd, *s);
s++;
}
} else if(c == 'c'){
3a7f: 83 f8 63 cmp $0x63,%eax
3a82: 0f 84 08 01 00 00 je 3b90 <printf+0x190>
putc(fd, *ap);
ap++;
} else if(c == '%'){
3a88: 83 f8 25 cmp $0x25,%eax
3a8b: 0f 84 ef 00 00 00 je 3b80 <printf+0x180>
write(fd, &c, 1);
3a91: 8d 45 e7 lea -0x19(%ebp),%eax
3a94: 83 ec 04 sub $0x4,%esp
3a97: c6 45 e7 25 movb $0x25,-0x19(%ebp)
3a9b: 6a 01 push $0x1
3a9d: 50 push %eax
3a9e: ff 75 08 pushl 0x8(%ebp)
3aa1: e8 1c fe ff ff call 38c2 <write>
3aa6: 83 c4 0c add $0xc,%esp
3aa9: 8d 45 e6 lea -0x1a(%ebp),%eax
3aac: 88 5d e6 mov %bl,-0x1a(%ebp)
3aaf: 6a 01 push $0x1
3ab1: 50 push %eax
3ab2: ff 75 08 pushl 0x8(%ebp)
3ab5: 83 c6 01 add $0x1,%esi
} else {
// Unknown % sequence. Print it to draw attention.
putc(fd, '%');
putc(fd, c);
}
state = 0;
3ab8: 31 ff xor %edi,%edi
write(fd, &c, 1);
3aba: e8 03 fe ff ff call 38c2 <write>
for(i = 0; fmt[i]; i++){
3abf: 0f b6 5e ff movzbl -0x1(%esi),%ebx
write(fd, &c, 1);
3ac3: 83 c4 10 add $0x10,%esp
for(i = 0; fmt[i]; i++){
3ac6: 84 db test %bl,%bl
3ac8: 75 89 jne 3a53 <printf+0x53>
}
}
}
3aca: 8d 65 f4 lea -0xc(%ebp),%esp
3acd: 5b pop %ebx
3ace: 5e pop %esi
3acf: 5f pop %edi
3ad0: 5d pop %ebp
3ad1: c3 ret
3ad2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
state = '%';
3ad8: bf 25 00 00 00 mov $0x25,%edi
3add: e9 66 ff ff ff jmp 3a48 <printf+0x48>
3ae2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
printint(fd, *ap, 16, 0);
3ae8: 83 ec 0c sub $0xc,%esp
3aeb: b9 10 00 00 00 mov $0x10,%ecx
3af0: 6a 00 push $0x0
3af2: 8b 7d d4 mov -0x2c(%ebp),%edi
3af5: 8b 45 08 mov 0x8(%ebp),%eax
3af8: 8b 17 mov (%edi),%edx
3afa: e8 61 fe ff ff call 3960 <printint>
ap++;
3aff: 89 f8 mov %edi,%eax
3b01: 83 c4 10 add $0x10,%esp
state = 0;
3b04: 31 ff xor %edi,%edi
ap++;
3b06: 83 c0 04 add $0x4,%eax
3b09: 89 45 d4 mov %eax,-0x2c(%ebp)
3b0c: e9 37 ff ff ff jmp 3a48 <printf+0x48>
3b11: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
s = (char*)*ap;
3b18: 8b 45 d4 mov -0x2c(%ebp),%eax
3b1b: 8b 08 mov (%eax),%ecx
ap++;
3b1d: 83 c0 04 add $0x4,%eax
3b20: 89 45 d4 mov %eax,-0x2c(%ebp)
if(s == 0)
3b23: 85 c9 test %ecx,%ecx
3b25: 0f 84 8e 00 00 00 je 3bb9 <printf+0x1b9>
while(*s != 0){
3b2b: 0f b6 01 movzbl (%ecx),%eax
state = 0;
3b2e: 31 ff xor %edi,%edi
s = (char*)*ap;
3b30: 89 cb mov %ecx,%ebx
while(*s != 0){
3b32: 84 c0 test %al,%al
3b34: 0f 84 0e ff ff ff je 3a48 <printf+0x48>
3b3a: 89 75 d0 mov %esi,-0x30(%ebp)
3b3d: 89 de mov %ebx,%esi
3b3f: 8b 5d 08 mov 0x8(%ebp),%ebx
3b42: 8d 7d e3 lea -0x1d(%ebp),%edi
3b45: 8d 76 00 lea 0x0(%esi),%esi
write(fd, &c, 1);
3b48: 83 ec 04 sub $0x4,%esp
s++;
3b4b: 83 c6 01 add $0x1,%esi
3b4e: 88 45 e3 mov %al,-0x1d(%ebp)
write(fd, &c, 1);
3b51: 6a 01 push $0x1
3b53: 57 push %edi
3b54: 53 push %ebx
3b55: e8 68 fd ff ff call 38c2 <write>
while(*s != 0){
3b5a: 0f b6 06 movzbl (%esi),%eax
3b5d: 83 c4 10 add $0x10,%esp
3b60: 84 c0 test %al,%al
3b62: 75 e4 jne 3b48 <printf+0x148>
3b64: 8b 75 d0 mov -0x30(%ebp),%esi
state = 0;
3b67: 31 ff xor %edi,%edi
3b69: e9 da fe ff ff jmp 3a48 <printf+0x48>
3b6e: 66 90 xchg %ax,%ax
printint(fd, *ap, 10, 1);
3b70: 83 ec 0c sub $0xc,%esp
3b73: b9 0a 00 00 00 mov $0xa,%ecx
3b78: 6a 01 push $0x1
3b7a: e9 73 ff ff ff jmp 3af2 <printf+0xf2>
3b7f: 90 nop
write(fd, &c, 1);
3b80: 83 ec 04 sub $0x4,%esp
3b83: 88 5d e5 mov %bl,-0x1b(%ebp)
3b86: 8d 45 e5 lea -0x1b(%ebp),%eax
3b89: 6a 01 push $0x1
3b8b: e9 21 ff ff ff jmp 3ab1 <printf+0xb1>
putc(fd, *ap);
3b90: 8b 7d d4 mov -0x2c(%ebp),%edi
write(fd, &c, 1);
3b93: 83 ec 04 sub $0x4,%esp
putc(fd, *ap);
3b96: 8b 07 mov (%edi),%eax
write(fd, &c, 1);
3b98: 6a 01 push $0x1
ap++;
3b9a: 83 c7 04 add $0x4,%edi
putc(fd, *ap);
3b9d: 88 45 e4 mov %al,-0x1c(%ebp)
write(fd, &c, 1);
3ba0: 8d 45 e4 lea -0x1c(%ebp),%eax
3ba3: 50 push %eax
3ba4: ff 75 08 pushl 0x8(%ebp)
3ba7: e8 16 fd ff ff call 38c2 <write>
ap++;
3bac: 89 7d d4 mov %edi,-0x2c(%ebp)
3baf: 83 c4 10 add $0x10,%esp
state = 0;
3bb2: 31 ff xor %edi,%edi
3bb4: e9 8f fe ff ff jmp 3a48 <printf+0x48>
s = "(null)";
3bb9: bb f0 54 00 00 mov $0x54f0,%ebx
while(*s != 0){
3bbe: b8 28 00 00 00 mov $0x28,%eax
3bc3: e9 72 ff ff ff jmp 3b3a <printf+0x13a>
3bc8: 66 90 xchg %ax,%ax
3bca: 66 90 xchg %ax,%ax
3bcc: 66 90 xchg %ax,%ax
3bce: 66 90 xchg %ax,%ax
00003bd0 <free>:
static Header base;
static Header *freep;
void
free(void *ap)
{
3bd0: 55 push %ebp
Header *bp, *p;
bp = (Header*)ap - 1;
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
3bd1: a1 a0 5e 00 00 mov 0x5ea0,%eax
{
3bd6: 89 e5 mov %esp,%ebp
3bd8: 57 push %edi
3bd9: 56 push %esi
3bda: 53 push %ebx
3bdb: 8b 5d 08 mov 0x8(%ebp),%ebx
bp = (Header*)ap - 1;
3bde: 8d 4b f8 lea -0x8(%ebx),%ecx
3be1: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
3be8: 39 c8 cmp %ecx,%eax
3bea: 8b 10 mov (%eax),%edx
3bec: 73 32 jae 3c20 <free+0x50>
3bee: 39 d1 cmp %edx,%ecx
3bf0: 72 04 jb 3bf6 <free+0x26>
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
3bf2: 39 d0 cmp %edx,%eax
3bf4: 72 32 jb 3c28 <free+0x58>
break;
if(bp + bp->s.size == p->s.ptr){
3bf6: 8b 73 fc mov -0x4(%ebx),%esi
3bf9: 8d 3c f1 lea (%ecx,%esi,8),%edi
3bfc: 39 fa cmp %edi,%edx
3bfe: 74 30 je 3c30 <free+0x60>
bp->s.size += p->s.ptr->s.size;
bp->s.ptr = p->s.ptr->s.ptr;
} else
bp->s.ptr = p->s.ptr;
3c00: 89 53 f8 mov %edx,-0x8(%ebx)
if(p + p->s.size == bp){
3c03: 8b 50 04 mov 0x4(%eax),%edx
3c06: 8d 34 d0 lea (%eax,%edx,8),%esi
3c09: 39 f1 cmp %esi,%ecx
3c0b: 74 3a je 3c47 <free+0x77>
p->s.size += bp->s.size;
p->s.ptr = bp->s.ptr;
} else
p->s.ptr = bp;
3c0d: 89 08 mov %ecx,(%eax)
freep = p;
3c0f: a3 a0 5e 00 00 mov %eax,0x5ea0
}
3c14: 5b pop %ebx
3c15: 5e pop %esi
3c16: 5f pop %edi
3c17: 5d pop %ebp
3c18: c3 ret
3c19: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
3c20: 39 d0 cmp %edx,%eax
3c22: 72 04 jb 3c28 <free+0x58>
3c24: 39 d1 cmp %edx,%ecx
3c26: 72 ce jb 3bf6 <free+0x26>
{
3c28: 89 d0 mov %edx,%eax
3c2a: eb bc jmp 3be8 <free+0x18>
3c2c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
bp->s.size += p->s.ptr->s.size;
3c30: 03 72 04 add 0x4(%edx),%esi
3c33: 89 73 fc mov %esi,-0x4(%ebx)
bp->s.ptr = p->s.ptr->s.ptr;
3c36: 8b 10 mov (%eax),%edx
3c38: 8b 12 mov (%edx),%edx
3c3a: 89 53 f8 mov %edx,-0x8(%ebx)
if(p + p->s.size == bp){
3c3d: 8b 50 04 mov 0x4(%eax),%edx
3c40: 8d 34 d0 lea (%eax,%edx,8),%esi
3c43: 39 f1 cmp %esi,%ecx
3c45: 75 c6 jne 3c0d <free+0x3d>
p->s.size += bp->s.size;
3c47: 03 53 fc add -0x4(%ebx),%edx
freep = p;
3c4a: a3 a0 5e 00 00 mov %eax,0x5ea0
p->s.size += bp->s.size;
3c4f: 89 50 04 mov %edx,0x4(%eax)
p->s.ptr = bp->s.ptr;
3c52: 8b 53 f8 mov -0x8(%ebx),%edx
3c55: 89 10 mov %edx,(%eax)
}
3c57: 5b pop %ebx
3c58: 5e pop %esi
3c59: 5f pop %edi
3c5a: 5d pop %ebp
3c5b: c3 ret
3c5c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
00003c60 <malloc>:
return freep;
}
void*
malloc(uint nbytes)
{
3c60: 55 push %ebp
3c61: 89 e5 mov %esp,%ebp
3c63: 57 push %edi
3c64: 56 push %esi
3c65: 53 push %ebx
3c66: 83 ec 0c sub $0xc,%esp
Header *p, *prevp;
uint nunits;
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
3c69: 8b 45 08 mov 0x8(%ebp),%eax
if((prevp = freep) == 0){
3c6c: 8b 15 a0 5e 00 00 mov 0x5ea0,%edx
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
3c72: 8d 78 07 lea 0x7(%eax),%edi
3c75: c1 ef 03 shr $0x3,%edi
3c78: 83 c7 01 add $0x1,%edi
if((prevp = freep) == 0){
3c7b: 85 d2 test %edx,%edx
3c7d: 0f 84 9d 00 00 00 je 3d20 <malloc+0xc0>
3c83: 8b 02 mov (%edx),%eax
3c85: 8b 48 04 mov 0x4(%eax),%ecx
base.s.ptr = freep = prevp = &base;
base.s.size = 0;
}
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
if(p->s.size >= nunits){
3c88: 39 cf cmp %ecx,%edi
3c8a: 76 6c jbe 3cf8 <malloc+0x98>
3c8c: 81 ff 00 10 00 00 cmp $0x1000,%edi
3c92: bb 00 10 00 00 mov $0x1000,%ebx
3c97: 0f 43 df cmovae %edi,%ebx
p = sbrk(nu * sizeof(Header));
3c9a: 8d 34 dd 00 00 00 00 lea 0x0(,%ebx,8),%esi
3ca1: eb 0e jmp 3cb1 <malloc+0x51>
3ca3: 90 nop
3ca4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
3ca8: 8b 02 mov (%edx),%eax
if(p->s.size >= nunits){
3caa: 8b 48 04 mov 0x4(%eax),%ecx
3cad: 39 f9 cmp %edi,%ecx
3caf: 73 47 jae 3cf8 <malloc+0x98>
p->s.size = nunits;
}
freep = prevp;
return (void*)(p + 1);
}
if(p == freep)
3cb1: 39 05 a0 5e 00 00 cmp %eax,0x5ea0
3cb7: 89 c2 mov %eax,%edx
3cb9: 75 ed jne 3ca8 <malloc+0x48>
p = sbrk(nu * sizeof(Header));
3cbb: 83 ec 0c sub $0xc,%esp
3cbe: 56 push %esi
3cbf: e8 66 fc ff ff call 392a <sbrk>
if(p == (char*)-1)
3cc4: 83 c4 10 add $0x10,%esp
3cc7: 83 f8 ff cmp $0xffffffff,%eax
3cca: 74 1c je 3ce8 <malloc+0x88>
hp->s.size = nu;
3ccc: 89 58 04 mov %ebx,0x4(%eax)
free((void*)(hp + 1));
3ccf: 83 ec 0c sub $0xc,%esp
3cd2: 83 c0 08 add $0x8,%eax
3cd5: 50 push %eax
3cd6: e8 f5 fe ff ff call 3bd0 <free>
return freep;
3cdb: 8b 15 a0 5e 00 00 mov 0x5ea0,%edx
if((p = morecore(nunits)) == 0)
3ce1: 83 c4 10 add $0x10,%esp
3ce4: 85 d2 test %edx,%edx
3ce6: 75 c0 jne 3ca8 <malloc+0x48>
return 0;
}
}
3ce8: 8d 65 f4 lea -0xc(%ebp),%esp
return 0;
3ceb: 31 c0 xor %eax,%eax
}
3ced: 5b pop %ebx
3cee: 5e pop %esi
3cef: 5f pop %edi
3cf0: 5d pop %ebp
3cf1: c3 ret
3cf2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
if(p->s.size == nunits)
3cf8: 39 cf cmp %ecx,%edi
3cfa: 74 54 je 3d50 <malloc+0xf0>
p->s.size -= nunits;
3cfc: 29 f9 sub %edi,%ecx
3cfe: 89 48 04 mov %ecx,0x4(%eax)
p += p->s.size;
3d01: 8d 04 c8 lea (%eax,%ecx,8),%eax
p->s.size = nunits;
3d04: 89 78 04 mov %edi,0x4(%eax)
freep = prevp;
3d07: 89 15 a0 5e 00 00 mov %edx,0x5ea0
}
3d0d: 8d 65 f4 lea -0xc(%ebp),%esp
return (void*)(p + 1);
3d10: 83 c0 08 add $0x8,%eax
}
3d13: 5b pop %ebx
3d14: 5e pop %esi
3d15: 5f pop %edi
3d16: 5d pop %ebp
3d17: c3 ret
3d18: 90 nop
3d19: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
base.s.ptr = freep = prevp = &base;
3d20: c7 05 a0 5e 00 00 a4 movl $0x5ea4,0x5ea0
3d27: 5e 00 00
3d2a: c7 05 a4 5e 00 00 a4 movl $0x5ea4,0x5ea4
3d31: 5e 00 00
base.s.size = 0;
3d34: b8 a4 5e 00 00 mov $0x5ea4,%eax
3d39: c7 05 a8 5e 00 00 00 movl $0x0,0x5ea8
3d40: 00 00 00
3d43: e9 44 ff ff ff jmp 3c8c <malloc+0x2c>
3d48: 90 nop
3d49: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
prevp->s.ptr = p->s.ptr;
3d50: 8b 08 mov (%eax),%ecx
3d52: 89 0a mov %ecx,(%edx)
3d54: eb b1 jmp 3d07 <malloc+0xa7>
|
.global s_prepare_buffers
s_prepare_buffers:
push %r15
push %r8
push %rax
push %rbx
push %rcx
push %rdi
push %rdx
push %rsi
lea addresses_UC_ht+0x1c19e, %rsi
lea addresses_normal_ht+0x18ade, %rdi
clflush (%rdi)
nop
nop
nop
nop
nop
cmp %r8, %r8
mov $104, %rcx
rep movsb
nop
nop
nop
inc %rcx
lea addresses_WC_ht+0x6ade, %r8
nop
nop
and $13381, %r15
mov (%r8), %ebx
nop
nop
nop
inc %rbx
lea addresses_UC_ht+0xa2de, %rcx
nop
nop
xor $57524, %rdx
movw $0x6162, (%rcx)
nop
nop
nop
cmp $47156, %rdi
lea addresses_A_ht+0x18f7e, %rsi
lea addresses_A_ht+0x15f7e, %rdi
nop
inc %rdx
mov $100, %rcx
rep movsb
nop
nop
and %rbx, %rbx
lea addresses_D_ht+0xfade, %rsi
lea addresses_A_ht+0x13ade, %rdi
nop
nop
nop
inc %rbx
mov $59, %rcx
rep movsw
dec %r15
lea addresses_WC_ht+0x8906, %rsi
nop
nop
nop
nop
dec %rdx
vmovups (%rsi), %ymm3
vextracti128 $1, %ymm3, %xmm3
vpextrq $1, %xmm3, %rcx
nop
nop
nop
nop
nop
and $38448, %rdi
lea addresses_normal_ht+0x119ee, %rbx
nop
xor %rdi, %rdi
mov $0x6162636465666768, %rcx
movq %rcx, %xmm7
vmovups %ymm7, (%rbx)
nop
sub %rdx, %rdx
lea addresses_normal_ht+0x5e9e, %rbx
nop
nop
nop
nop
nop
cmp %rsi, %rsi
vmovups (%rbx), %ymm2
vextracti128 $0, %ymm2, %xmm2
vpextrq $1, %xmm2, %rcx
nop
nop
nop
nop
xor %rdx, %rdx
lea addresses_WT_ht+0x19c46, %r8
nop
nop
nop
add %rdi, %rdi
mov $0x6162636465666768, %rdx
movq %rdx, %xmm0
vmovups %ymm0, (%r8)
and %rsi, %rsi
lea addresses_normal_ht+0x98ce, %rsi
lea addresses_normal_ht+0x153de, %rdi
nop
nop
sub $30199, %rax
mov $19, %rcx
rep movsl
cmp %rdx, %rdx
lea addresses_WT_ht+0x1a59e, %rsi
lea addresses_normal_ht+0x1a5e, %rdi
nop
nop
nop
nop
nop
sub %rax, %rax
mov $15, %rcx
rep movsq
nop
dec %rcx
lea addresses_WT_ht+0x13ede, %r15
nop
nop
nop
nop
nop
cmp %r8, %r8
mov $0x6162636465666768, %rbx
movq %rbx, (%r15)
nop
nop
nop
add $6156, %rsi
pop %rsi
pop %rdx
pop %rdi
pop %rcx
pop %rbx
pop %rax
pop %r8
pop %r15
ret
.global s_faulty_load
s_faulty_load:
push %r10
push %r8
push %rbp
push %rbx
push %rcx
push %rdi
push %rsi
// Store
lea addresses_A+0x172de, %rbx
nop
sub $14041, %r8
mov $0x5152535455565758, %rbp
movq %rbp, (%rbx)
nop
nop
nop
nop
nop
and $23650, %rdi
// REPMOV
lea addresses_UC+0x5fde, %rsi
lea addresses_WC+0x2cf4, %rdi
nop
nop
nop
nop
nop
mfence
mov $127, %rcx
rep movsw
nop
nop
nop
nop
lfence
// Load
lea addresses_WC+0x109d1, %rcx
nop
nop
nop
nop
add %rbp, %rbp
mov (%rcx), %di
nop
nop
nop
nop
dec %rdi
// Store
mov $0x6e1a3100000002c6, %rbx
nop
cmp %rdi, %rdi
mov $0x5152535455565758, %rbp
movq %rbp, %xmm4
movntdq %xmm4, (%rbx)
nop
nop
nop
nop
sub %r8, %r8
// Faulty Load
lea addresses_A+0x172de, %rsi
nop
nop
nop
nop
nop
cmp %rdi, %rdi
movups (%rsi), %xmm7
vpextrq $1, %xmm7, %r10
lea oracles, %rsi
and $0xff, %r10
shlq $12, %r10
mov (%rsi,%r10,1), %r10
pop %rsi
pop %rdi
pop %rcx
pop %rbx
pop %rbp
pop %r8
pop %r10
ret
/*
<gen_faulty_load>
[REF]
{'src': {'type': 'addresses_A', 'same': False, 'size': 32, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
{'dst': {'type': 'addresses_A', 'same': True, 'size': 8, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
{'src': {'type': 'addresses_UC', 'congruent': 4, 'same': False}, 'dst': {'type': 'addresses_WC', 'congruent': 1, 'same': False}, 'OP': 'REPM'}
{'src': {'type': 'addresses_WC', 'same': False, 'size': 2, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
{'dst': {'type': 'addresses_NC', 'same': False, 'size': 16, 'congruent': 3, 'NT': True, 'AVXalign': False}, 'OP': 'STOR'}
[Faulty Load]
{'src': {'type': 'addresses_A', 'same': True, 'size': 16, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'src': {'type': 'addresses_UC_ht', 'congruent': 6, 'same': False}, 'dst': {'type': 'addresses_normal_ht', 'congruent': 9, 'same': False}, 'OP': 'REPM'}
{'src': {'type': 'addresses_WC_ht', 'same': False, 'size': 4, 'congruent': 7, 'NT': False, 'AVXalign': True}, 'OP': 'LOAD'}
{'dst': {'type': 'addresses_UC_ht', 'same': True, 'size': 2, 'congruent': 11, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
{'src': {'type': 'addresses_A_ht', 'congruent': 4, 'same': False}, 'dst': {'type': 'addresses_A_ht', 'congruent': 5, 'same': True}, 'OP': 'REPM'}
{'src': {'type': 'addresses_D_ht', 'congruent': 5, 'same': True}, 'dst': {'type': 'addresses_A_ht', 'congruent': 11, 'same': False}, 'OP': 'REPM'}
{'src': {'type': 'addresses_WC_ht', 'same': False, 'size': 32, 'congruent': 3, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
{'dst': {'type': 'addresses_normal_ht', 'same': False, 'size': 32, 'congruent': 4, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
{'src': {'type': 'addresses_normal_ht', 'same': True, 'size': 32, 'congruent': 5, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
{'dst': {'type': 'addresses_WT_ht', 'same': False, 'size': 32, 'congruent': 3, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
{'src': {'type': 'addresses_normal_ht', 'congruent': 4, 'same': False}, 'dst': {'type': 'addresses_normal_ht', 'congruent': 7, 'same': False}, 'OP': 'REPM'}
{'src': {'type': 'addresses_WT_ht', 'congruent': 6, 'same': False}, 'dst': {'type': 'addresses_normal_ht', 'congruent': 2, 'same': False}, 'OP': 'REPM'}
{'dst': {'type': 'addresses_WT_ht', 'same': True, 'size': 8, 'congruent': 10, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
{'35': 21829}
35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35
*/
|
/*
* Copyright (c) 2017-2019 THL A29 Limited, a Tencent company. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <tencentcloud/vod/v20180717/model/AiRecognitionTaskOcrWordsResult.h>
using TencentCloud::CoreInternalOutcome;
using namespace TencentCloud::Vod::V20180717::Model;
using namespace std;
AiRecognitionTaskOcrWordsResult::AiRecognitionTaskOcrWordsResult() :
m_statusHasBeenSet(false),
m_errCodeExtHasBeenSet(false),
m_errCodeHasBeenSet(false),
m_messageHasBeenSet(false),
m_inputHasBeenSet(false),
m_outputHasBeenSet(false)
{
}
CoreInternalOutcome AiRecognitionTaskOcrWordsResult::Deserialize(const rapidjson::Value &value)
{
string requestId = "";
if (value.HasMember("Status") && !value["Status"].IsNull())
{
if (!value["Status"].IsString())
{
return CoreInternalOutcome(Core::Error("response `AiRecognitionTaskOcrWordsResult.Status` IsString=false incorrectly").SetRequestId(requestId));
}
m_status = string(value["Status"].GetString());
m_statusHasBeenSet = true;
}
if (value.HasMember("ErrCodeExt") && !value["ErrCodeExt"].IsNull())
{
if (!value["ErrCodeExt"].IsString())
{
return CoreInternalOutcome(Core::Error("response `AiRecognitionTaskOcrWordsResult.ErrCodeExt` IsString=false incorrectly").SetRequestId(requestId));
}
m_errCodeExt = string(value["ErrCodeExt"].GetString());
m_errCodeExtHasBeenSet = true;
}
if (value.HasMember("ErrCode") && !value["ErrCode"].IsNull())
{
if (!value["ErrCode"].IsInt64())
{
return CoreInternalOutcome(Core::Error("response `AiRecognitionTaskOcrWordsResult.ErrCode` IsInt64=false incorrectly").SetRequestId(requestId));
}
m_errCode = value["ErrCode"].GetInt64();
m_errCodeHasBeenSet = true;
}
if (value.HasMember("Message") && !value["Message"].IsNull())
{
if (!value["Message"].IsString())
{
return CoreInternalOutcome(Core::Error("response `AiRecognitionTaskOcrWordsResult.Message` IsString=false incorrectly").SetRequestId(requestId));
}
m_message = string(value["Message"].GetString());
m_messageHasBeenSet = true;
}
if (value.HasMember("Input") && !value["Input"].IsNull())
{
if (!value["Input"].IsObject())
{
return CoreInternalOutcome(Core::Error("response `AiRecognitionTaskOcrWordsResult.Input` is not object type").SetRequestId(requestId));
}
CoreInternalOutcome outcome = m_input.Deserialize(value["Input"]);
if (!outcome.IsSuccess())
{
outcome.GetError().SetRequestId(requestId);
return outcome;
}
m_inputHasBeenSet = true;
}
if (value.HasMember("Output") && !value["Output"].IsNull())
{
if (!value["Output"].IsObject())
{
return CoreInternalOutcome(Core::Error("response `AiRecognitionTaskOcrWordsResult.Output` is not object type").SetRequestId(requestId));
}
CoreInternalOutcome outcome = m_output.Deserialize(value["Output"]);
if (!outcome.IsSuccess())
{
outcome.GetError().SetRequestId(requestId);
return outcome;
}
m_outputHasBeenSet = true;
}
return CoreInternalOutcome(true);
}
void AiRecognitionTaskOcrWordsResult::ToJsonObject(rapidjson::Value &value, rapidjson::Document::AllocatorType& allocator) const
{
if (m_statusHasBeenSet)
{
rapidjson::Value iKey(rapidjson::kStringType);
string key = "Status";
iKey.SetString(key.c_str(), allocator);
value.AddMember(iKey, rapidjson::Value(m_status.c_str(), allocator).Move(), allocator);
}
if (m_errCodeExtHasBeenSet)
{
rapidjson::Value iKey(rapidjson::kStringType);
string key = "ErrCodeExt";
iKey.SetString(key.c_str(), allocator);
value.AddMember(iKey, rapidjson::Value(m_errCodeExt.c_str(), allocator).Move(), allocator);
}
if (m_errCodeHasBeenSet)
{
rapidjson::Value iKey(rapidjson::kStringType);
string key = "ErrCode";
iKey.SetString(key.c_str(), allocator);
value.AddMember(iKey, m_errCode, allocator);
}
if (m_messageHasBeenSet)
{
rapidjson::Value iKey(rapidjson::kStringType);
string key = "Message";
iKey.SetString(key.c_str(), allocator);
value.AddMember(iKey, rapidjson::Value(m_message.c_str(), allocator).Move(), allocator);
}
if (m_inputHasBeenSet)
{
rapidjson::Value iKey(rapidjson::kStringType);
string key = "Input";
iKey.SetString(key.c_str(), allocator);
value.AddMember(iKey, rapidjson::Value(rapidjson::kObjectType).Move(), allocator);
m_input.ToJsonObject(value[key.c_str()], allocator);
}
if (m_outputHasBeenSet)
{
rapidjson::Value iKey(rapidjson::kStringType);
string key = "Output";
iKey.SetString(key.c_str(), allocator);
value.AddMember(iKey, rapidjson::Value(rapidjson::kObjectType).Move(), allocator);
m_output.ToJsonObject(value[key.c_str()], allocator);
}
}
string AiRecognitionTaskOcrWordsResult::GetStatus() const
{
return m_status;
}
void AiRecognitionTaskOcrWordsResult::SetStatus(const string& _status)
{
m_status = _status;
m_statusHasBeenSet = true;
}
bool AiRecognitionTaskOcrWordsResult::StatusHasBeenSet() const
{
return m_statusHasBeenSet;
}
string AiRecognitionTaskOcrWordsResult::GetErrCodeExt() const
{
return m_errCodeExt;
}
void AiRecognitionTaskOcrWordsResult::SetErrCodeExt(const string& _errCodeExt)
{
m_errCodeExt = _errCodeExt;
m_errCodeExtHasBeenSet = true;
}
bool AiRecognitionTaskOcrWordsResult::ErrCodeExtHasBeenSet() const
{
return m_errCodeExtHasBeenSet;
}
int64_t AiRecognitionTaskOcrWordsResult::GetErrCode() const
{
return m_errCode;
}
void AiRecognitionTaskOcrWordsResult::SetErrCode(const int64_t& _errCode)
{
m_errCode = _errCode;
m_errCodeHasBeenSet = true;
}
bool AiRecognitionTaskOcrWordsResult::ErrCodeHasBeenSet() const
{
return m_errCodeHasBeenSet;
}
string AiRecognitionTaskOcrWordsResult::GetMessage() const
{
return m_message;
}
void AiRecognitionTaskOcrWordsResult::SetMessage(const string& _message)
{
m_message = _message;
m_messageHasBeenSet = true;
}
bool AiRecognitionTaskOcrWordsResult::MessageHasBeenSet() const
{
return m_messageHasBeenSet;
}
AiRecognitionTaskOcrWordsResultInput AiRecognitionTaskOcrWordsResult::GetInput() const
{
return m_input;
}
void AiRecognitionTaskOcrWordsResult::SetInput(const AiRecognitionTaskOcrWordsResultInput& _input)
{
m_input = _input;
m_inputHasBeenSet = true;
}
bool AiRecognitionTaskOcrWordsResult::InputHasBeenSet() const
{
return m_inputHasBeenSet;
}
AiRecognitionTaskOcrWordsResultOutput AiRecognitionTaskOcrWordsResult::GetOutput() const
{
return m_output;
}
void AiRecognitionTaskOcrWordsResult::SetOutput(const AiRecognitionTaskOcrWordsResultOutput& _output)
{
m_output = _output;
m_outputHasBeenSet = true;
}
bool AiRecognitionTaskOcrWordsResult::OutputHasBeenSet() const
{
return m_outputHasBeenSet;
}
|
; A081592: A self generating sequence: "there are n a(n)'s in the sequence". Start with 1,2 and use the rule : "a(n)=k implies there are n following k's (k is 1 or 2)".
; 1,2,1,2,2,1,1,1,2,2,2,2,2,2,2,2,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2
mov $2,$0
lpb $2
mov $1,9
mov $4,$2
sub $4,1
lpb $4
add $3,1
trn $4,$3
lpe
lpb $3
mov $1,$0
mov $0,1
mov $2,$3
mov $3,0
lpe
sub $2,1
lpe
div $1,9
add $1,1
mov $0,$1
|
; A123950: Expansion of g.f.: x^2*(1-2*x) / (1-3*x-3*x^2+2*x^3).
; Submitted by Jon Maiga
; 0,1,1,6,19,73,264,973,3565,13086,48007,176149,646296,2371321,8700553,31923030,117128107,429752305,1576795176,5785386229,21227039605,77883687150,285761407807,1048481205661,3846960466104,14114802199681,51788325586033,190015462424934,697181759633539,2558015015003353,9385559399060808,34436359722925405,126349727335951933,463587142378510398,1700937889697536183,6240875641556235877,22898266309004295384,84015550072286521417,308259697860759978649,1131029211181130909430,4149835626981099621403
mov $1,1
mov $2,1
lpb $0
sub $0,1
mov $3,$2
add $2,$1
mul $2,2
add $3,$4
mov $4,$1
add $1,$3
sub $1,$4
add $2,$3
lpe
mov $0,$4
|
Name: en-data-1.asm
Type: file
Size: 11385
Last-Modified: '1993-07-20T07:13:22Z'
SHA-1: D629ABDF2531DA2C70CE35E3DCE408049D6E1811
Description: null
|
; A165849: Totally multiplicative sequence with a(p) = 28.
; 1,28,28,784,28,784,28,21952,784,784,28,21952,28,784,784,614656,28,21952,28,21952,784,784,28,614656,784,784,21952,21952,28,21952,28,17210368,784,784,784,614656,28,784,784,614656,28,21952,28,21952,21952,784,28,17210368,784,21952,784,21952,28,614656,784,614656,784,784,28,614656,28,784,21952,481890304,784,21952,28,21952,784,21952,28,17210368,28,784,21952,21952,784,21952,28,17210368,614656,784,28,614656,784,784,784,614656,28,614656,784,21952,784,784,784,481890304,28,21952,21952,614656
seq $0,1222 ; Number of prime divisors of n counted with multiplicity (also called bigomega(n) or Omega(n)).
mov $1,28
pow $1,$0
mov $0,$1
|
;-------------------------------------------------------------------------------
; MSP430F5529 blink in assembly
; This is inefficient as it uses a software delay and the CPU is always on
; (C) 2018 Manolis Kiagias
;-------------------------------------------------------------------------------
.cdecls C,LIST,"msp430.h" ; Include device header file
;-------------------------------------------------------------------------------
.def RESET ; Export program entry-point to
; make it known to linker.
;-------------------------------------------------------------------------------
.text ; Assemble into program memory.
.retain ; Override ELF conditional linking
; and retain current section.
.retainrefs ; And retain any sections that have
; references to current section.
;-------------------------------------------------------------------------------
RESET mov.w #__STACK_END,SP ; Initialize stackpointer
StopWDT mov.w #WDTPW|WDTHOLD,&WDTCTL ; Stop watchdog timer
;-------------------------------------------------------------------------------
; Main loop here
;-------------------------------------------------------------------------------
;-------------------------------------------------------------------------------
; Initialize outputs
;-------------------------------------------------------------------------------
bis.b #BIT0, &P1DIR ; make P1.0 output
bis.b #BIT7, &P4DIR ; make P4.7 output
;-------------------------------------------------------------------------------
; Red led off, green led on
;-------------------------------------------------------------------------------
On bic.b #BIT0, &P1OUT ; clear P1.0 (red led off)
bis.b #BIT7, &P4OUT ; set P4.7 (green red on)
call #d1 ; call delay
;-------------------------------------------------------------------------------
; Red led on, green led off
;-------------------------------------------------------------------------------
Off bis.b #BIT0, &P1OUT ; set P1.0 (red led on)
bic.b #BIT7, &P4OUT ; clear P4.7 (green led off)
call #d1 ; call delay
jmp On
;-------------------------------------------------------------------------------
; Delay subroutine
;-------------------------------------------------------------------------------
d1 mov.w #10,R14 ; load R14 with outer loop value
L1 mov.w #35000,R15 ; load R15 with inner loop value
L2 dec.w R15 ; decrement R15
jnz L2 ; loop till zero
dec.w R14 ; decrement R14
jnz L1 ; loop till zero
ret ; Back to caller
;-------------------------------------------------------------------------------
; Stack Pointer definition
;-------------------------------------------------------------------------------
.global __STACK_END
.sect .stack
;-------------------------------------------------------------------------------
; Interrupt Vectors
;-------------------------------------------------------------------------------
.sect ".reset" ; MSP430 RESET Vector
.short RESET
|
;*******************************************************************************
; MSP430x24x Demo - Basic Clock, MCLK Sourced from HF XTAL
;
; Description: Proper selection of an external HF XTAL for MCLK is shown by
; first polling the OSC fault until XTAL is stable - only then is MCLK
; sourced by LFXT1. MCLK/10 is on P1.1 driven by a software loop taking
; exactly 10 CPU cycles.
; ACLK = MCLK = LFXT1 = HF XTAL, SMCLK = default DCO ~1.025MHz
; //* HF XTAL NOT INSTALLED ON FET *//
; //* Min Vcc required varies with MCLK frequency - refer to datasheet *//
;
; MSP430F249
; -----------------
; /|\| XIN|-
; | | | HF XTAL (3 16MHz crystal or resonator)
; --|RST XOUT|-
; | |
; | P1.1|-->MCLK/10 = HFXTAL/10
; | P5.4/MCLK|-->MCLK = XT2 HFXTAL
;
; JL Bile
; Texas Instruments Inc.
; May 2008
; Built Code Composer Essentials: v3 FET
;*******************************************************************************
.cdecls C,LIST, "msp430x24x.h"
;-------------------------------------------------------------------------------
.text ;Program Start
;-------------------------------------------------------------------------------
RESET mov.w #0500h,SP ; Initialize stackpointer
StopWDT mov.w #WDTPW+WDTHOLD,&WDTCTL ; Stop WDT
SetupBC bic.b #XT2OFF,&BCSCTL1 ; Activate XT2 high freq xtal
bis.b #XT2S_2,&BCSCTL3 ; 3 16MHz crystal or resonator
SetupOsc bic.b #OFIFG,&IFG1 ; Clear OSC fault flag
mov.w #0FFh,R15 ; R15 = Delay
SetupOsc1 dec.w R15 ; Additional delay to ensure start
jnz SetupOsc1 ;
bit.b #OFIFG,&IFG1 ; OSC fault flag set?
jnz SetupOsc ; OSC Fault, clear flag again
bis.b #SELM_2, &BCSCTL2 ; MCLK = XT2 HF XTAL (safe)
bis.b #010h,&P5DIR ; P5.4 = output direction
bis.b #010h,&P5SEL ; P5.4 = ACLK function
bis.b #002h,&P1DIR ; P1.1 = output direction
Mainloop bis.b #002h,&P1OUT ; P1.1 = 1
bic.b #002h,&P1OUT ; P1.1 = 0
jmp Mainloop ; Repeat
;
;-------------------------------------------------------------------------------
; Interrupt Vectors
;-------------------------------------------------------------------------------
.sect ".reset" ; POR, ext. Reset
.short RESET
.end
|
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
*******************************************************************************
*
* Copyright (C) 2004-2014, International Business Machines
* Corporation and others. All Rights Reserved.
*
*******************************************************************************
* file name: ubidi_props.c
* encoding: UTF-8
* tab size: 8 (not used)
* indentation:4
*
* created on: 2004dec30
* created by: Markus W. Scherer
*
* Low-level Unicode bidi/shaping properties access.
*/
#include "unicode/utypes.h"
#include "unicode/uset.h"
#include "unicode/udata.h" /* UDataInfo */
#include "ucmndata.h" /* DataHeader */
#include "udatamem.h"
#include "uassert.h"
#include "cmemory.h"
#include "utrie2.h"
#include "ubidi_props.h"
#include "ucln_cmn.h"
struct UBiDiProps {
UDataMemory *mem;
const int32_t *indexes;
const uint32_t *mirrors;
const uint8_t *jgArray;
const uint8_t *jgArray2;
UTrie2 trie;
uint8_t formatVersion[4];
};
/* ubidi_props_data.h is machine-generated by genbidi --csource */
#define INCLUDED_FROM_UBIDI_PROPS_C
#include "ubidi_props_data.h"
/* set of property starts for UnicodeSet ------------------------------------ */
static UBool U_CALLCONV
ubidi_props_enumPropertyStartsRange(const void *context, UChar32 start, UChar32 end, uint32_t value) {
(void)end;
(void)value;
/* add the start code point to the USet */
const USetAdder *sa=(const USetAdder *)context;
sa->add(sa->set, start);
return TRUE;
}
U_CFUNC void
ubidi_addPropertyStarts(const USetAdder *sa, UErrorCode *pErrorCode) {
int32_t i, length;
UChar32 c, start, limit;
const uint8_t *jgArray;
uint8_t prev, jg;
if(U_FAILURE(*pErrorCode)) {
return;
}
/* add the start code point of each same-value range of the trie */
utrie2_enum(&ubidi_props_singleton.trie, NULL, ubidi_props_enumPropertyStartsRange, sa);
/* add the code points from the bidi mirroring table */
length=ubidi_props_singleton.indexes[UBIDI_IX_MIRROR_LENGTH];
for(i=0; i<length; ++i) {
c=UBIDI_GET_MIRROR_CODE_POINT(ubidi_props_singleton.mirrors[i]);
sa->addRange(sa->set, c, c+1);
}
/* add the code points from the Joining_Group array where the value changes */
start=ubidi_props_singleton.indexes[UBIDI_IX_JG_START];
limit=ubidi_props_singleton.indexes[UBIDI_IX_JG_LIMIT];
jgArray=ubidi_props_singleton.jgArray;
for(;;) {
prev=0;
while(start<limit) {
jg=*jgArray++;
if(jg!=prev) {
sa->add(sa->set, start);
prev=jg;
}
++start;
}
if(prev!=0) {
/* add the limit code point if the last value was not 0 (it is now start==limit) */
sa->add(sa->set, limit);
}
if(limit==ubidi_props_singleton.indexes[UBIDI_IX_JG_LIMIT]) {
/* switch to the second Joining_Group range */
start=ubidi_props_singleton.indexes[UBIDI_IX_JG_START2];
limit=ubidi_props_singleton.indexes[UBIDI_IX_JG_LIMIT2];
jgArray=ubidi_props_singleton.jgArray2;
} else {
break;
}
}
/* add code points with hardcoded properties, plus the ones following them */
/* (none right now) */
}
/* property access functions ------------------------------------------------ */
U_CFUNC int32_t
ubidi_getMaxValue(UProperty which) {
int32_t max=ubidi_props_singleton.indexes[UBIDI_MAX_VALUES_INDEX];
switch(which) {
case UCHAR_BIDI_CLASS:
return (max&UBIDI_CLASS_MASK);
case UCHAR_JOINING_GROUP:
return (max&UBIDI_MAX_JG_MASK)>>UBIDI_MAX_JG_SHIFT;
case UCHAR_JOINING_TYPE:
return (max&UBIDI_JT_MASK)>>UBIDI_JT_SHIFT;
case UCHAR_BIDI_PAIRED_BRACKET_TYPE:
return (max&UBIDI_BPT_MASK)>>UBIDI_BPT_SHIFT;
default:
return -1; /* undefined */
}
}
U_CAPI UCharDirection
ubidi_getClass(UChar32 c) {
uint16_t props=UTRIE2_GET16(&ubidi_props_singleton.trie, c);
return (UCharDirection)UBIDI_GET_CLASS(props);
}
U_CFUNC UBool
ubidi_isMirrored(UChar32 c) {
uint16_t props=UTRIE2_GET16(&ubidi_props_singleton.trie, c);
return (UBool)UBIDI_GET_FLAG(props, UBIDI_IS_MIRRORED_SHIFT);
}
static UChar32
getMirror(UChar32 c, uint16_t props) {
int32_t delta=UBIDI_GET_MIRROR_DELTA(props);
if(delta!=UBIDI_ESC_MIRROR_DELTA) {
return c+delta;
} else {
/* look for mirror code point in the mirrors[] table */
const uint32_t *mirrors;
uint32_t m;
int32_t i, length;
UChar32 c2;
mirrors=ubidi_props_singleton.mirrors;
length=ubidi_props_singleton.indexes[UBIDI_IX_MIRROR_LENGTH];
/* linear search */
for(i=0; i<length; ++i) {
m=mirrors[i];
c2=UBIDI_GET_MIRROR_CODE_POINT(m);
if(c==c2) {
/* found c, return its mirror code point using the index in m */
return UBIDI_GET_MIRROR_CODE_POINT(mirrors[UBIDI_GET_MIRROR_INDEX(m)]);
} else if(c<c2) {
break;
}
}
/* c not found, return it itself */
return c;
}
}
U_CFUNC UChar32
ubidi_getMirror(UChar32 c) {
uint16_t props=UTRIE2_GET16(&ubidi_props_singleton.trie, c);
return getMirror(c, props);
}
U_CFUNC UBool
ubidi_isBidiControl(UChar32 c) {
uint16_t props=UTRIE2_GET16(&ubidi_props_singleton.trie, c);
return (UBool)UBIDI_GET_FLAG(props, UBIDI_BIDI_CONTROL_SHIFT);
}
U_CFUNC UBool
ubidi_isJoinControl(UChar32 c) {
uint16_t props=UTRIE2_GET16(&ubidi_props_singleton.trie, c);
return (UBool)UBIDI_GET_FLAG(props, UBIDI_JOIN_CONTROL_SHIFT);
}
U_CFUNC UJoiningType
ubidi_getJoiningType(UChar32 c) {
uint16_t props=UTRIE2_GET16(&ubidi_props_singleton.trie, c);
return (UJoiningType)((props&UBIDI_JT_MASK)>>UBIDI_JT_SHIFT);
}
U_CFUNC UJoiningGroup
ubidi_getJoiningGroup(UChar32 c) {
UChar32 start, limit;
start=ubidi_props_singleton.indexes[UBIDI_IX_JG_START];
limit=ubidi_props_singleton.indexes[UBIDI_IX_JG_LIMIT];
if(start<=c && c<limit) {
return (UJoiningGroup)ubidi_props_singleton.jgArray[c-start];
}
start=ubidi_props_singleton.indexes[UBIDI_IX_JG_START2];
limit=ubidi_props_singleton.indexes[UBIDI_IX_JG_LIMIT2];
if(start<=c && c<limit) {
return (UJoiningGroup)ubidi_props_singleton.jgArray2[c-start];
}
return U_JG_NO_JOINING_GROUP;
}
U_CFUNC UBidiPairedBracketType
ubidi_getPairedBracketType(UChar32 c) {
uint16_t props=UTRIE2_GET16(&ubidi_props_singleton.trie, c);
return (UBidiPairedBracketType)((props&UBIDI_BPT_MASK)>>UBIDI_BPT_SHIFT);
}
U_CFUNC UChar32
ubidi_getPairedBracket(UChar32 c) {
uint16_t props=UTRIE2_GET16(&ubidi_props_singleton.trie, c);
if((props&UBIDI_BPT_MASK)==0) {
return c;
} else {
return getMirror(c, props);
}
}
/* public API (see uchar.h) ------------------------------------------------- */
U_CFUNC UCharDirection
u_charDirection(UChar32 c) {
return ubidi_getClass(c);
}
U_CFUNC UBool
u_isMirrored(UChar32 c) {
return ubidi_isMirrored(c);
}
U_CFUNC UChar32
u_charMirror(UChar32 c) {
return ubidi_getMirror(c);
}
U_STABLE UChar32 U_EXPORT2
u_getBidiPairedBracket(UChar32 c) {
return ubidi_getPairedBracket(c);
}
|
; A172011: 12*A002605(n).
; 0,12,24,72,192,528,1440,3936,10752,29376,80256,219264,599040,1636608,4471296,12215808,33374208,91180032,249108480,680577024,1859371008,5079896064,13878534144,37916860416,103590789120,283015299072,773212176384,2112454950912
mov $2,6
lpb $0
sub $0,1
add $3,$2
add $1,$3
add $2,$1
mov $1,$3
mul $1,2
sub $3,$3
lpe
|
// Copyright (c) 2018, The Sherkitty Project
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification, are
// permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice, this list of
// conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright notice, this list
// of conditions and the following disclaimer in the documentation and/or other
// materials provided with the distribution.
//
// 3. Neither the name of the copyright holder nor the names of its contributors may be
// used to endorse or promote products derived from this software without specific
// prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
// THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "gtest/gtest.h"
#include "ringct/rctOps.h"
#include "device/device_default.hpp"
TEST(device, name)
{
hw::core::device_default dev;
ASSERT_TRUE(dev.set_name("test"));
ASSERT_EQ(dev.get_name(), "test");
}
/*
TEST(device, locking)
{
hw::core::device_default dev;
ASSERT_TRUE(dev.try_lock());
ASSERT_FALSE(dev.try_lock());
dev.unlock();
ASSERT_TRUE(dev.try_lock());
dev.unlock();
dev.lock();
ASSERT_FALSE(dev.try_lock());
dev.unlock();
ASSERT_TRUE(dev.try_lock());
dev.unlock();
}
*/
TEST(device, open_close)
{
hw::core::device_default dev;
crypto::secret_key key;
ASSERT_TRUE(dev.open_tx(key));
ASSERT_TRUE(dev.close_tx());
}
TEST(device, ops)
{
hw::core::device_default dev;
rct::key resd, res;
crypto::key_derivation derd, der;
rct::key sk, pk;
crypto::secret_key sk0, sk1;
crypto::public_key pk0, pk1;
crypto::ec_scalar ressc0, ressc1;
crypto::key_image ki0, ki1;
rct::skpkGen(sk, pk);
rct::scalarmultBase((rct::key&)pk0, (rct::key&)sk0);
rct::scalarmultBase((rct::key&)pk1, (rct::key&)sk1);
dev.scalarmultKey(resd, pk, sk);
rct::scalarmultKey(res, pk, sk);
ASSERT_EQ(resd, res);
dev.scalarmultBase(resd, sk);
rct::scalarmultBase(res, sk);
ASSERT_EQ(resd, res);
dev.sc_secret_add((crypto::secret_key&)resd, sk0, sk1);
sc_add((unsigned char*)&res, (unsigned char*)&sk0, (unsigned char*)&sk1);
ASSERT_EQ(resd, res);
dev.generate_key_derivation(pk0, sk0, derd);
crypto::generate_key_derivation(pk0, sk0, der);
ASSERT_FALSE(memcmp(&derd, &der, sizeof(der)));
dev.derivation_to_scalar(der, 0, ressc0);
crypto::derivation_to_scalar(der, 0, ressc1);
ASSERT_FALSE(memcmp(&ressc0, &ressc1, sizeof(ressc1)));
dev.derive_secret_key(der, 0, rct::rct2sk(sk), sk0);
crypto::derive_secret_key(der, 0, rct::rct2sk(sk), sk1);
ASSERT_EQ(sk0, sk1);
dev.derive_public_key(der, 0, rct::rct2pk(pk), pk0);
crypto::derive_public_key(der, 0, rct::rct2pk(pk), pk1);
ASSERT_EQ(pk0, pk1);
dev.secret_key_to_public_key(rct::rct2sk(sk), pk0);
crypto::secret_key_to_public_key(rct::rct2sk(sk), pk1);
ASSERT_EQ(pk0, pk1);
dev.generate_key_image(pk0, sk0, ki0);
crypto::generate_key_image(pk0, sk0, ki1);
ASSERT_EQ(ki0, ki1);
}
TEST(device, ecdh32)
{
hw::core::device_default dev;
rct::ecdhTuple tuple, tuple2;
rct::key key = rct::skGen();
tuple.mask = rct::skGen();
tuple.amount = rct::skGen();
tuple2 = tuple;
dev.ecdhEncode(tuple, key, false);
dev.ecdhDecode(tuple, key, false);
ASSERT_EQ(tuple2.mask, tuple.mask);
ASSERT_EQ(tuple2.amount, tuple.amount);
}
|
; A041263: Denominators of continued fraction convergents to sqrt(143).
; Submitted by Christian Krause
; 1,1,23,24,551,575,13201,13776,316273,330049,7577351,7907400,181540151,189447551,4349386273,4538833824,104203730401,108742564225,2496540143351,2605282707576,59812759710023,62418042417599,1433009692897201,1495427735314800,34332419869822801,35827847605137601,822545067182850023,858372914787987624,19706749192518577751,20565122107306565375,472139435553263016001,492704557660569581376,11311639704085793806273,11804344261746363387649,271007213462505788334551,282811557724252151722200
add $0,1
mov $3,1
lpb $0
sub $0,1
div $2,2
add $2,$3
mov $3,$1
mov $1,$2
dif $2,22
mul $2,44
lpe
mov $0,$2
div $0,44
|
pushpc
org $0ef51b
jml RenderCharExtended
org $0ef520
RenderCharExtended_returnOriginal:
org $0ef567
RenderCharExtended_returnUncompressed:
org $0ef356
jsl RenderCharLookupWidth
org $0ef3ba
jsl RenderCharLookupWidth
org $0ef48e
jml RenderCharLookupWidthDraw
org $0ef499
RenderCharLookupWidthDraw_return:
org $0ef6aa
jml RenderCharToMapExtended
org $0ef6c2
RenderCharToMapExtended_return:
org $0efa50
jsl RenderCharSetColorExtended
org $0eee5d
jsl RenderCharSetColorExtended_init
org $0ef285
jsl RenderCharSetColorExtended_close : nop
org $531000
NewFont:
incbin data/newfont.bin
NewFontInverted:
incbin data/newfont_inverted.bin
pullpc
!INVERTED_TEMP = $35
RenderCharSetColorExtended_init:
stz !INVERTED_TEMP
jsl $00d84e
rtl
RenderCharSetColorExtended_close:
stz !INVERTED_TEMP
lda $010c
sta $10
rtl
RenderCharSetColorExtended:
pha
and #$10
cmp #$10
beq .inverted
lda #$00
bra .end
.inverted
lda #$01
.end
sta !INVERTED_TEMP
pla
and #$07 : asl : asl
rtl
RenderCharToMapExtended:
phx : tya : asl #2 : tax
lda.l FontProperties, x
and #$0001
bne .uncompressed
.compressed
plx
lda #$0000
sta $00
lda #$007f
sta $02
lda #$0000
clc : adc #$0020
sta $03
lda #$007f
sta $05
jml RenderCharToMapExtended_return
.uncompressed
lda.l FontProperties+$2, x
plx
clc : adc #(NewFont&$ffff)
sta $00
clc : adc #$0100
pha
lda #(NewFont>>16)
sta $02
pla : sta $03
lda #(NewFont>>16)
sta $05
jml RenderCharToMapExtended_return
RenderCharLookupWidthDraw:
rep #$30
phx : lda $09 : and #$fffe : tax
lda.l FontProperties, x
bmi .thin
.wide
plx : sep #$30
lda $09 : and #$03 : tay
lda $fd7c, y : tay
jml RenderCharLookupWidthDraw_return
.thin
plx : sep #$30
lda $09 : and #$03 : phx : tax
lda.l RenderCharThinTable, x : tay : plx
jml RenderCharLookupWidthDraw_return
RenderCharLookupWidth:
phx : lda $09 : and #$fffe : tax
lda.l FontProperties, x
bmi .thin
.wide
plx : lda $fd7c, x : clc
rtl
.thin
plx : lda.l RenderCharThinTable, x : clc
rtl
RenderCharThinTable:
db $08, $00, $ff
RenderCharExtended:
pha
asl : asl : tax
lda.l FontProperties, x
and #$00ff
bne .renderUncompressed
.renderOriginal
pla : asl : tax : asl : adc $0e
jml RenderCharExtended_returnOriginal
.renderUncompressed
pla : phb : pea $5353 : plb : plb
lda.l FontProperties+$2, x
tay
lda !INVERTED_TEMP
bne .inverted
ldx #$00000
-
lda.w NewFont, y
sta.l $7EBFC0, x
lda.w NewFont+$100, y
sta.l $7EBFC0+$16, x
inx #2
iny #2
cpx #$0010
bne -
bra .end
.inverted
ldx #$00000
-
lda.w NewFontInverted, y
sta.l $7EBFC0, x
lda.w NewFontInverted+$100, y
sta.l $7EBFC0+$16, x
inx #2
iny #2
cpx #$0010
bne -
.end
plb
jml RenderCharExtended_returnUncompressed
; Table of font properties and tilemap offset
; Properties are these for now:
; t---- ----u
; t = thin spacing (0 px instead of 3 px)
; u = uncompressed character loaded from offset
FontProperties:
; props, offset
dw $0000, $0000 ; 00
dw $0000, $0000 ; 01
dw $0000, $0000 ; 02
dw $0000, $0000 ; 03
dw $0000, $0000 ; 04
dw $0000, $0000 ; 05
dw $0000, $0000 ; 06
dw $0000, $0000 ; 07
dw $0000, $0000 ; 08
dw $0000, $0000 ; 09
dw $0000, $0000 ; 0A
dw $0000, $0000 ; 0B
dw $0000, $0000 ; 0C
dw $0000, $0000 ; 0D
dw $0000, $0000 ; 0E
dw $0000, $0000 ; 0F
dw $0000, $0000 ; 10
dw $0000, $0000 ; 11
dw $0000, $0000 ; 12
dw $0000, $0000 ; 13
dw $0000, $0000 ; 14
dw $0000, $0000 ; 15
dw $0000, $0000 ; 16
dw $0000, $0000 ; 17
dw $0000, $0000 ; 18
dw $0000, $0000 ; 19
dw $0000, $0000 ; 1A
dw $0000, $0000 ; 1B
dw $0000, $0000 ; 1C
dw $0000, $0000 ; 1D
dw $0000, $0000 ; 1E
dw $0000, $0000 ; 1F
dw $0000, $0000 ; 20
dw $0000, $0000 ; 21
dw $0000, $0000 ; 22
dw $0000, $0000 ; 23
dw $0000, $0000 ; 24
dw $0000, $0000 ; 25
dw $0000, $0000 ; 26
dw $0000, $0000 ; 27
dw $0000, $0000 ; 28
dw $0000, $0000 ; 29
dw $0000, $0000 ; 2A
dw $0000, $0000 ; 2B
dw $0000, $0000 ; 2C
dw $0000, $0000 ; 2D
dw $0000, $0000 ; 2E
dw $0000, $0000 ; 2F
dw $8001, $0400 ; 30
dw $8001, $0410 ; 31
dw $8001, $0420 ; 32
dw $8001, $0430 ; 33
dw $8001, $0440 ; 34
dw $8001, $0450 ; 35
dw $8001, $0460 ; 36
dw $8001, $0470 ; 37
dw $8001, $0480 ; 38
dw $8001, $0490 ; 39
dw $8001, $04A0 ; 3A
dw $8001, $04B0 ; 3B
dw $8001, $04C0 ; 3C
dw $8001, $04D0 ; 3D
dw $8001, $04E0 ; 3E
dw $8001, $04F0 ; 3F
dw $8001, $0600 ; 40
dw $8001, $0610 ; 41
dw $8001, $0620 ; 42
dw $8001, $0630 ; 43
dw $8001, $0640 ; 44
dw $8001, $0650 ; 45
dw $8001, $0660 ; 46
dw $8001, $0670 ; 47
dw $8001, $0680 ; 48
dw $8001, $0690 ; 49 ; z
dw $8001, $06F0 ; 4A ; :
dw $8001, $0A90 ; 4B ; @ (thin)
dw $8001, $0AA0 ; 4C ; # (thin)
dw $8001, $0AB0 ; 4D ; morphball left
dw $8001, $0AC0 ; 4E ; morphball right
dw $8001, $0EF0 ; 4F
dw $0000, $0000 ; 50
dw $0000, $0000 ; 51
dw $0000, $0000 ; 52
dw $0000, $0000 ; 53
dw $0000, $0000 ; 54
dw $0000, $0000 ; 55
dw $0000, $0000 ; 56
dw $0000, $0000 ; 57
dw $0000, $0000 ; 58
dw $0000, $0000 ; 59
dw $0000, $0000 ; 5A
dw $0000, $0000 ; 5B
dw $0000, $0000 ; 5C
dw $0000, $0000 ; 5D
dw $0000, $0000 ; 5E
dw $0000, $0000 ; 5F
dw $0000, $0000 ; 60
dw $0000, $0000 ; 61
dw $0000, $0000 ; 62
dw $0000, $0000 ; 63
dw $0000, $0000 ; 64
dw $0000, $0000 ; 65
dw $0000, $0000 ; 66
dw $0000, $0000 ; 67
dw $0000, $0000 ; 68
dw $0000, $0000 ; 69
dw $0000, $0000 ; 6A
dw $0000, $0000 ; 6B
dw $0000, $0000 ; 6C
dw $0000, $0000 ; 6D
dw $0000, $0000 ; 6E
dw $0000, $0000 ; 6F
dw $0000, $0000 ; 70
dw $0000, $0000 ; 71
dw $0000, $0000 ; 72
dw $0000, $0000 ; 73
dw $0000, $0000 ; 74
dw $0000, $0000 ; 75
dw $0000, $0000 ; 76
dw $0000, $0000 ; 77
dw $0000, $0000 ; 78
dw $0000, $0000 ; 79
dw $0000, $0000 ; 7A
dw $0000, $0000 ; 7B
dw $0000, $0000 ; 7C
dw $0000, $0000 ; 7D
dw $0000, $0000 ; 7E
dw $0000, $0000 ; 7F
dw $0000, $0000 ; 80
dw $0000, $0000 ; 81
dw $0000, $0000 ; 82
dw $0000, $0000 ; 83
dw $0000, $0000 ; 84
dw $0000, $0000 ; 85
dw $0000, $0000 ; 86
dw $0000, $0000 ; 87
dw $0000, $0000 ; 88
dw $0000, $0000 ; 89
dw $0000, $0000 ; 8A
dw $0000, $0000 ; 8B
dw $0000, $0000 ; 8C
dw $0000, $0000 ; 8D
dw $0000, $0000 ; 8E
dw $0000, $0000 ; 8F
dw $0000, $0000 ; 90
dw $0000, $0000 ; 91
dw $0000, $0000 ; 92
dw $0000, $0000 ; 93
dw $0000, $0000 ; 94
dw $0000, $0000 ; 95
dw $0000, $0000 ; 96
dw $0000, $0000 ; 97
dw $0000, $0000 ; 98
dw $0000, $0000 ; 99
dw $0000, $0000 ; 9A
dw $0000, $0000 ; 9B
dw $0000, $0000 ; 9C
dw $0000, $0000 ; 9D
dw $0000, $0000 ; 9E
dw $0000, $0000 ; 9F
dw $8001, $0800 ; A0
dw $8001, $0810 ; A1
dw $8001, $0820 ; A2
dw $8001, $0830 ; A3
dw $8001, $0840 ; A4
dw $8001, $0850 ; A5
dw $8001, $0860 ; A6
dw $8001, $0870 ; A7
dw $8001, $0880 ; A8
dw $8001, $0890 ; A9
dw $8001, $0000 ; AA
dw $8001, $0010 ; AB
dw $8001, $0020 ; AC
dw $8001, $0030 ; AD
dw $8001, $0040 ; AE
dw $8001, $0050 ; AF
dw $8001, $0060 ; B0
dw $8001, $0070 ; B1
dw $8001, $0080 ; B2
dw $8001, $0090 ; B3
dw $8001, $00A0 ; B4
dw $8001, $00B0 ; B5
dw $8001, $00C0 ; B6
dw $8001, $00D0 ; B7
dw $8001, $00E0 ; B8
dw $8001, $00F0 ; B9
dw $8001, $0200 ; BA
dw $8001, $0210 ; BB
dw $8001, $0220 ; BC
dw $8001, $0230 ; BD
dw $8001, $0240 ; BE
dw $8001, $0250 ; BF
dw $8001, $0260 ; C0
dw $8001, $0270 ; C1
dw $8001, $0280 ; C2
dw $8001, $0290 ; C3 Z
dw $8000, $0000 ; C4
dw $8000, $0000 ; C5
dw $8001, $06D0 ; C6 ?
dw $8001, $06C0 ; C7 !
dw $8001, $02D0 ; C8 ,
dw $8001, $02B0 ; C9 -
dw $8000, $0000 ; CA
dw $8000, $0000 ; CB
dw $8000, $02E0 ; CC ...
dw $8001, $02C0 ; CD .
dw $8001, $02F0 ; CE ~
dw $8000, $0000 ; CF
dw $0000, $0000 ; D0
dw $0000, $0000 ; D1
dw $8001, $06a0 ; D2 Link face left
dw $8001, $06b0 ; D3 Link face right
dw $0000, $0000 ; D4
dw $0000, $0000 ; D5
dw $0000, $0000 ; D6
dw $0000, $0000 ; D7
dw $8001, $06E0 ; D8 '
dw $0000, $0000 ; D9
dw $0000, $0000 ; DA
dw $0000, $0000 ; DB
dw $0000, $0000 ; DC
dw $0000, $0000 ; DD
dw $0000, $0000 ; DE
dw $0000, $0000 ; DF
dw $0000, $0000 ; E0
dw $0000, $0000 ; E1
dw $0000, $0000 ; E2
dw $0000, $0000 ; E3
dw $8001, $02A0 ; E4 Arrow >
dw $0000, $0000 ; E5
dw $0000, $0000 ; E6
dw $0000, $0000 ; E7
dw $0000, $0000 ; E8
dw $0000, $0000 ; E9
dw $0000, $0000 ; EA
dw $0000, $0000 ; EB
dw $0000, $0000 ; EC
dw $0000, $0000 ; ED
dw $0000, $0000 ; EE
dw $0000, $0000 ; EF
dw $0000, $0000 ; F0
dw $0000, $0000 ; F1
dw $0000, $0000 ; F2
dw $0000, $0000 ; F3
dw $0000, $0000 ; F4
dw $0000, $0000 ; F5
dw $0000, $0000 ; F6
dw $0000, $0000 ; F7
dw $0000, $0000 ; F8
dw $0000, $0000 ; F9
dw $0000, $0000 ; FA
dw $0000, $0000 ; FB
dw $0000, $0000 ; FC
dw $0000, $0000 ; FD
dw $0000, $0000 ; FE
dw $8001, $0EF0 ; FF
|
;
; Z88 Graphics Functions - Small C+ stubs
;
; Written around the Interlogic Standard Library
;
; Stubs Written by D Morris - 15/10/98
;
;
; Page the graphics bank in/out - used by all gfx functions
; Simply does a swap...
;
;
; $Id: swapgfxbk.asm,v 1.2 2001/04/18 13:21:38 stefano Exp $
;
XLIB swapgfxbk
XDEF swapgfxbk1
.swapgfxbk
.swapgfxbk1
ret
|
.global s_prepare_buffers
s_prepare_buffers:
push %r12
push %r15
push %r8
push %rax
push %rbx
push %rcx
push %rdi
push %rsi
lea addresses_WC_ht+0x13975, %rbx
nop
nop
nop
sub %rax, %rax
mov (%rbx), %di
nop
nop
nop
nop
nop
and $11995, %r12
lea addresses_UC_ht+0xbc55, %rsi
lea addresses_UC_ht+0x10e55, %rdi
clflush (%rdi)
nop
nop
nop
nop
nop
xor $52936, %r8
mov $3, %rcx
rep movsw
nop
nop
nop
cmp %rcx, %rcx
lea addresses_D_ht+0x1b655, %r8
nop
nop
inc %rbx
movb $0x61, (%r8)
nop
nop
nop
nop
nop
sub $8607, %rcx
lea addresses_D_ht+0x1a55, %r12
nop
and %rdi, %rdi
movw $0x6162, (%r12)
nop
nop
sub $62595, %rdi
lea addresses_UC_ht+0x1efc5, %rsi
lea addresses_WC_ht+0x11c55, %rdi
nop
nop
nop
nop
add %r15, %r15
mov $38, %rcx
rep movsw
nop
nop
nop
inc %r15
lea addresses_D_ht+0xd0d5, %r8
nop
nop
sub %rdi, %rdi
vmovups (%r8), %ymm2
vextracti128 $0, %ymm2, %xmm2
vpextrq $1, %xmm2, %r15
and %rdi, %rdi
lea addresses_WT_ht+0x85b5, %rsi
lea addresses_UC_ht+0x2455, %rdi
nop
nop
nop
and $38393, %rbx
mov $118, %rcx
rep movsl
sub %rcx, %rcx
pop %rsi
pop %rdi
pop %rcx
pop %rbx
pop %rax
pop %r8
pop %r15
pop %r12
ret
.global s_faulty_load
s_faulty_load:
push %r10
push %r11
push %r12
push %r13
push %r14
push %rax
push %rdi
// Store
mov $0x1ca1380000000a69, %rax
dec %r14
movl $0x51525354, (%rax)
nop
nop
nop
cmp $46643, %r10
// Store
lea addresses_US+0x10855, %r11
nop
nop
nop
nop
nop
sub $51645, %rdi
movb $0x51, (%r11)
nop
add $57803, %r12
// Store
lea addresses_A+0x15f55, %rdi
cmp %r13, %r13
mov $0x5152535455565758, %r11
movq %r11, %xmm6
vmovups %ymm6, (%rdi)
nop
nop
nop
nop
xor $13888, %r14
// Store
lea addresses_normal+0x1c5f5, %r14
nop
nop
nop
nop
sub $31652, %rax
movl $0x51525354, (%r14)
nop
nop
sub $4108, %r11
// Faulty Load
lea addresses_US+0x1fc55, %r12
nop
nop
nop
dec %r13
vmovaps (%r12), %ymm4
vextracti128 $0, %ymm4, %xmm4
vpextrq $0, %xmm4, %r11
lea oracles, %r13
and $0xff, %r11
shlq $12, %r11
mov (%r13,%r11,1), %r11
pop %rdi
pop %rax
pop %r14
pop %r13
pop %r12
pop %r11
pop %r10
ret
/*
<gen_faulty_load>
[REF]
{'src': {'NT': False, 'same': True, 'congruent': 0, 'type': 'addresses_US', 'AVXalign': False, 'size': 16}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 2, 'type': 'addresses_NC', 'AVXalign': False, 'size': 4}}
{'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 10, 'type': 'addresses_US', 'AVXalign': True, 'size': 1}}
{'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 6, 'type': 'addresses_A', 'AVXalign': False, 'size': 32}}
{'OP': 'STOR', 'dst': {'NT': False, 'same': True, 'congruent': 5, 'type': 'addresses_normal', 'AVXalign': False, 'size': 4}}
[Faulty Load]
{'src': {'NT': True, 'same': True, 'congruent': 0, 'type': 'addresses_US', 'AVXalign': True, 'size': 32}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'src': {'NT': False, 'same': False, 'congruent': 4, 'type': 'addresses_WC_ht', 'AVXalign': False, 'size': 2}, 'OP': 'LOAD'}
{'src': {'same': False, 'congruent': 10, 'type': 'addresses_UC_ht'}, 'OP': 'REPM', 'dst': {'same': False, 'congruent': 4, 'type': 'addresses_UC_ht'}}
{'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 9, 'type': 'addresses_D_ht', 'AVXalign': True, 'size': 1}}
{'OP': 'STOR', 'dst': {'NT': True, 'same': False, 'congruent': 8, 'type': 'addresses_D_ht', 'AVXalign': False, 'size': 2}}
{'src': {'same': False, 'congruent': 4, 'type': 'addresses_UC_ht'}, 'OP': 'REPM', 'dst': {'same': True, 'congruent': 10, 'type': 'addresses_WC_ht'}}
{'src': {'NT': False, 'same': False, 'congruent': 6, 'type': 'addresses_D_ht', 'AVXalign': False, 'size': 32}, 'OP': 'LOAD'}
{'src': {'same': False, 'congruent': 3, 'type': 'addresses_WT_ht'}, 'OP': 'REPM', 'dst': {'same': False, 'congruent': 11, 'type': 'addresses_UC_ht'}}
{'00': 21829}
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
*/
|
// Copyright (c) 2011-2013 The Bitcoin Core developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#define BOOST_TEST_MODULE Fac Test Suite
#include "main.h"
#include "random.h"
#include "txdb.h"
#include "ui_interface.h"
#include "util.h"
#ifdef ENABLE_WALLET
#include "db.h"
#include "wallet.h"
#endif
#include <boost/filesystem.hpp>
#include <boost/test/unit_test.hpp>
#include <boost/thread.hpp>
CClientUIInterface uiInterface;
CWallet* pwalletMain;
extern bool fPrintToConsole;
extern void noui_connect();
struct TestingSetup {
CCoinsViewDB *pcoinsdbview;
boost::filesystem::path pathTemp;
boost::thread_group threadGroup;
TestingSetup() {
SetupEnvironment();
fPrintToDebugLog = false; // don't want to write to debug.log file
fCheckBlockIndex = true;
SelectParams(CBaseChainParams::UNITTEST);
noui_connect();
#ifdef ENABLE_WALLET
bitdb.MakeMock();
#endif
pathTemp = GetTempPath() / strprintf("test_fac_%lu_%i", (unsigned long)GetTime(), (int)(GetRand(100000)));
boost::filesystem::create_directories(pathTemp);
mapArgs["-datadir"] = pathTemp.string();
pblocktree = new CBlockTreeDB(1 << 20, true);
pcoinsdbview = new CCoinsViewDB(1 << 23, true);
pcoinsTip = new CCoinsViewCache(pcoinsdbview);
InitBlockIndex();
#ifdef ENABLE_WALLET
bool fFirstRun;
pwalletMain = new CWallet("wallet.dat");
pwalletMain->LoadWallet(fFirstRun);
RegisterValidationInterface(pwalletMain);
#endif
nScriptCheckThreads = 3;
for (int i=0; i < nScriptCheckThreads-1; i++)
threadGroup.create_thread(&ThreadScriptCheck);
RegisterNodeSignals(GetNodeSignals());
}
~TestingSetup()
{
threadGroup.interrupt_all();
threadGroup.join_all();
UnregisterNodeSignals(GetNodeSignals());
#ifdef ENABLE_WALLET
delete pwalletMain;
pwalletMain = NULL;
#endif
delete pcoinsTip;
delete pcoinsdbview;
delete pblocktree;
#ifdef ENABLE_WALLET
bitdb.Flush(true);
#endif
boost::filesystem::remove_all(pathTemp);
}
};
BOOST_GLOBAL_FIXTURE(TestingSetup);
void Shutdown(void* parg)
{
exit(0);
}
void StartShutdown()
{
exit(0);
}
bool ShutdownRequested()
{
return false;
}
|
;*****************************************************************************
;* mc-a2.asm: x86 motion compensation
;*****************************************************************************
;* Copyright (C) 2005-2018 x264 project
;*
;* Authors: Loren Merritt <lorenm@u.washington.edu>
;* Fiona Glaser <fiona@x264.com>
;* Holger Lubitz <holger@lubitz.org>
;* Mathieu Monnier <manao@melix.net>
;* Oskar Arvidsson <oskar@irock.se>
;*
;* This program is free software; you can redistribute it and/or modify
;* it under the terms of the GNU General Public License as published by
;* the Free Software Foundation; either version 2 of the License, or
;* (at your option) any later version.
;*
;* This program is distributed in the hope that it will be useful,
;* but WITHOUT ANY WARRANTY; without even the implied warranty of
;* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;* GNU General Public License for more details.
;*
;* You should have received a copy of the GNU General Public License
;* along with this program; if not, write to the Free Software
;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA.
;*
;* This program is also available under a commercial proprietary license.
;* For more information, contact us at licensing@x264.com.
;*****************************************************************************
%include "x86inc.asm"
%include "x86util.asm"
SECTION_RODATA 64
%if HIGH_BIT_DEPTH
v210_shuf_avx512: db 0, 0,34, 1,35,34, 4, 4,38, 5,39,38, 8, 8,42, 9, ; luma, chroma
db 43,42,12,12,46,13,47,46,16,16,50,17,51,50,20,20,
db 54,21,55,54,24,24,58,25,59,58,28,28,62,29,63,62
v210_mask: dd 0x3ff003ff, 0xc00ffc00, 0x3ff003ff, 0xc00ffc00
v210_luma_shuf: db 1, 2, 4, 5, 6, 7, 9,10,12,13,14,15,12,13,14,15
v210_chroma_shuf: db 0, 1, 2, 3, 5, 6, 8, 9,10,11,13,14,10,11,13,14
; vpermd indices {0,1,2,4,5,7,_,_} merged in the 3 lsb of each dword to save a register
v210_mult: dw 0x2000,0x7fff,0x0801,0x2000,0x7ffa,0x0800,0x7ffc,0x0800
dw 0x1ffd,0x7fff,0x07ff,0x2000,0x7fff,0x0800,0x7fff,0x0800
copy_swap_shuf: SHUFFLE_MASK_W 1,0,3,2,5,4,7,6
deinterleave_shuf: SHUFFLE_MASK_W 0,2,4,6,1,3,5,7
deinterleave_shuf32a: SHUFFLE_MASK_W 0,2,4,6,8,10,12,14
deinterleave_shuf32b: SHUFFLE_MASK_W 1,3,5,7,9,11,13,15
%else
deinterleave_rgb_shuf: db 0, 3, 6, 9, 0, 3, 6, 9, 1, 4, 7,10, 2, 5, 8,11
db 0, 4, 8,12, 0, 4, 8,12, 1, 5, 9,13, 2, 6,10,14
copy_swap_shuf: db 1, 0, 3, 2, 5, 4, 7, 6, 9, 8,11,10,13,12,15,14
deinterleave_shuf: db 0, 2, 4, 6, 8,10,12,14, 1, 3, 5, 7, 9,11,13,15
deinterleave_shuf32a: db 0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30
deinterleave_shuf32b: db 1,3,5,7,9,11,13,15,17,19,21,23,25,27,29,31
%endif ; !HIGH_BIT_DEPTH
pw_1024: times 16 dw 1024
filt_mul20: times 32 db 20
filt_mul15: times 16 db 1, -5
filt_mul51: times 16 db -5, 1
hpel_shuf: times 2 db 0,8,1,9,2,10,3,11,4,12,5,13,6,14,7,15
mbtree_prop_list_avx512_shuf: dw 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7
mbtree_fix8_unpack_shuf: db -1,-1, 1, 0,-1,-1, 3, 2,-1,-1, 5, 4,-1,-1, 7, 6
db -1,-1, 9, 8,-1,-1,11,10,-1,-1,13,12,-1,-1,15,14
; bits 0-3: pshufb, bits 4-7: AVX-512 vpermq
mbtree_fix8_pack_shuf: db 0x01,0x20,0x43,0x62,0x15,0x34,0x57,0x76,0x09,0x08,0x0b,0x0a,0x0d,0x0c,0x0f,0x0e
pf_256: times 4 dd 256.0
pf_inv16777216: times 4 dd 0x1p-24
pd_16: times 4 dd 16
pad10: times 8 dw 10*PIXEL_MAX
pad20: times 8 dw 20*PIXEL_MAX
pad30: times 8 dw 30*PIXEL_MAX
depad: times 4 dd 32*20*PIXEL_MAX + 512
tap1: times 4 dw 1, -5
tap2: times 4 dw 20, 20
tap3: times 4 dw -5, 1
pw_0xc000: times 8 dw 0xc000
pw_31: times 8 dw 31
pd_4: times 4 dd 4
SECTION .text
cextern pb_0
cextern pw_1
cextern pw_8
cextern pw_16
cextern pw_32
cextern pw_512
cextern pw_00ff
cextern pw_3fff
cextern pw_pixel_max
cextern pw_0to15
cextern pd_8
cextern pd_0123
cextern pd_ffff
cextern deinterleave_shufd
%macro LOAD_ADD 4
movh %4, %3
movh %1, %2
punpcklbw %4, m0
punpcklbw %1, m0
paddw %1, %4
%endmacro
%macro LOAD_ADD_2 6
mova %5, %3
mova %1, %4
punpckhbw %6, %5, m0
punpcklbw %5, m0
punpckhbw %2, %1, m0
punpcklbw %1, m0
paddw %1, %5
paddw %2, %6
%endmacro
%macro FILT_V2 6
psubw %1, %2 ; a-b
psubw %4, %5
psubw %2, %3 ; b-c
psubw %5, %6
psllw %2, 2
psllw %5, 2
psubw %1, %2 ; a-5*b+4*c
psllw %3, 4
psubw %4, %5
psllw %6, 4
paddw %1, %3 ; a-5*b+20*c
paddw %4, %6
%endmacro
%macro FILT_H 3
psubw %1, %2 ; a-b
psraw %1, 2 ; (a-b)/4
psubw %1, %2 ; (a-b)/4-b
paddw %1, %3 ; (a-b)/4-b+c
psraw %1, 2 ; ((a-b)/4-b+c)/4
paddw %1, %3 ; ((a-b)/4-b+c)/4+c = (a-5*b+20*c)/16
%endmacro
%macro FILT_H2 6
psubw %1, %2
psubw %4, %5
psraw %1, 2
psraw %4, 2
psubw %1, %2
psubw %4, %5
paddw %1, %3
paddw %4, %6
psraw %1, 2
psraw %4, 2
paddw %1, %3
paddw %4, %6
%endmacro
%macro FILT_PACK 3-5
%if cpuflag(ssse3)
pmulhrsw %1, %3
pmulhrsw %2, %3
%else
paddw %1, %3
paddw %2, %3
%if %0 == 5
psubusw %1, %5
psubusw %2, %5
psrlw %1, %4
psrlw %2, %4
%else
psraw %1, %4
psraw %2, %4
%endif
%endif
%if HIGH_BIT_DEPTH == 0
packuswb %1, %2
%endif
%endmacro
;The hpel_filter routines use non-temporal writes for output.
;The following defines may be uncommented for testing.
;Doing the hpel_filter temporal may be a win if the last level cache
;is big enough (preliminary benching suggests on the order of 4* framesize).
;%define movntq movq
;%define movntps movaps
;%define sfence
%if HIGH_BIT_DEPTH
;-----------------------------------------------------------------------------
; void hpel_filter_v( uint16_t *dst, uint16_t *src, int16_t *buf, intptr_t stride, intptr_t width );
;-----------------------------------------------------------------------------
%macro HPEL_FILTER 0
cglobal hpel_filter_v, 5,6,11
FIX_STRIDES r3, r4
lea r5, [r1+r3]
sub r1, r3
sub r1, r3
%if num_mmregs > 8
mova m8, [pad10]
mova m9, [pad20]
mova m10, [pad30]
%define s10 m8
%define s20 m9
%define s30 m10
%else
%define s10 [pad10]
%define s20 [pad20]
%define s30 [pad30]
%endif
add r0, r4
add r2, r4
neg r4
mova m7, [pw_pixel_max]
pxor m0, m0
.loop:
mova m1, [r1]
mova m2, [r1+r3]
mova m3, [r1+r3*2]
mova m4, [r1+mmsize]
mova m5, [r1+r3+mmsize]
mova m6, [r1+r3*2+mmsize]
paddw m1, [r5+r3*2]
paddw m2, [r5+r3]
paddw m3, [r5]
paddw m4, [r5+r3*2+mmsize]
paddw m5, [r5+r3+mmsize]
paddw m6, [r5+mmsize]
add r1, 2*mmsize
add r5, 2*mmsize
FILT_V2 m1, m2, m3, m4, m5, m6
mova m6, [pw_16]
psubw m1, s20
psubw m4, s20
mova [r2+r4], m1
mova [r2+r4+mmsize], m4
paddw m1, s30
paddw m4, s30
FILT_PACK m1, m4, m6, 5, s10
CLIPW m1, m0, m7
CLIPW m4, m0, m7
mova [r0+r4], m1
mova [r0+r4+mmsize], m4
add r4, 2*mmsize
jl .loop
RET
;-----------------------------------------------------------------------------
; void hpel_filter_c( uint16_t *dst, int16_t *buf, intptr_t width );
;-----------------------------------------------------------------------------
cglobal hpel_filter_c, 3,3,10
add r2, r2
add r0, r2
add r1, r2
neg r2
mova m0, [tap1]
mova m7, [tap3]
%if num_mmregs > 8
mova m8, [tap2]
mova m9, [depad]
%define s1 m8
%define s2 m9
%else
%define s1 [tap2]
%define s2 [depad]
%endif
.loop:
movu m1, [r1+r2-4]
movu m2, [r1+r2-2]
mova m3, [r1+r2+0]
movu m4, [r1+r2+2]
movu m5, [r1+r2+4]
movu m6, [r1+r2+6]
pmaddwd m1, m0
pmaddwd m2, m0
pmaddwd m3, s1
pmaddwd m4, s1
pmaddwd m5, m7
pmaddwd m6, m7
paddd m1, s2
paddd m2, s2
paddd m3, m5
paddd m4, m6
paddd m1, m3
paddd m2, m4
psrad m1, 10
psrad m2, 10
pslld m2, 16
pand m1, [pd_ffff]
por m1, m2
CLIPW m1, [pb_0], [pw_pixel_max]
mova [r0+r2], m1
add r2, mmsize
jl .loop
RET
;-----------------------------------------------------------------------------
; void hpel_filter_h( uint16_t *dst, uint16_t *src, intptr_t width );
;-----------------------------------------------------------------------------
cglobal hpel_filter_h, 3,4,8
%define src r1+r2
add r2, r2
add r0, r2
add r1, r2
neg r2
mova m0, [pw_pixel_max]
.loop:
movu m1, [src-4]
movu m2, [src-2]
mova m3, [src+0]
movu m6, [src+2]
movu m4, [src+4]
movu m5, [src+6]
paddw m3, m6 ; c0
paddw m2, m4 ; b0
paddw m1, m5 ; a0
%if mmsize == 16
movu m4, [src-4+mmsize]
movu m5, [src-2+mmsize]
%endif
movu m7, [src+4+mmsize]
movu m6, [src+6+mmsize]
paddw m5, m7 ; b1
paddw m4, m6 ; a1
movu m7, [src+2+mmsize]
mova m6, [src+0+mmsize]
paddw m6, m7 ; c1
FILT_H2 m1, m2, m3, m4, m5, m6
mova m7, [pw_1]
pxor m2, m2
FILT_PACK m1, m4, m7, 1
CLIPW m1, m2, m0
CLIPW m4, m2, m0
mova [r0+r2], m1
mova [r0+r2+mmsize], m4
add r2, mmsize*2
jl .loop
RET
%endmacro ; HPEL_FILTER
INIT_MMX mmx2
HPEL_FILTER
INIT_XMM sse2
HPEL_FILTER
%endif ; HIGH_BIT_DEPTH
%if HIGH_BIT_DEPTH == 0
%macro HPEL_V 1
;-----------------------------------------------------------------------------
; void hpel_filter_v( uint8_t *dst, uint8_t *src, int16_t *buf, intptr_t stride, intptr_t width );
;-----------------------------------------------------------------------------
cglobal hpel_filter_v, 5,6,%1
lea r5, [r1+r3]
sub r1, r3
sub r1, r3
add r0, r4
lea r2, [r2+r4*2]
neg r4
%if cpuflag(ssse3)
mova m0, [filt_mul15]
%else
pxor m0, m0
%endif
.loop:
%if cpuflag(ssse3)
mova m1, [r1]
mova m4, [r1+r3]
mova m2, [r5+r3*2]
mova m5, [r5+r3]
mova m3, [r1+r3*2]
mova m6, [r5]
SBUTTERFLY bw, 1, 4, 7
SBUTTERFLY bw, 2, 5, 7
SBUTTERFLY bw, 3, 6, 7
pmaddubsw m1, m0
pmaddubsw m4, m0
pmaddubsw m2, m0
pmaddubsw m5, m0
pmaddubsw m3, [filt_mul20]
pmaddubsw m6, [filt_mul20]
paddw m1, m2
paddw m4, m5
paddw m1, m3
paddw m4, m6
mova m7, [pw_1024]
%else
LOAD_ADD_2 m1, m4, [r1 ], [r5+r3*2], m6, m7 ; a0 / a1
LOAD_ADD_2 m2, m5, [r1+r3 ], [r5+r3 ], m6, m7 ; b0 / b1
LOAD_ADD m3, [r1+r3*2], [r5 ], m7 ; c0
LOAD_ADD m6, [r1+r3*2+mmsize/2], [r5+mmsize/2], m7 ; c1
FILT_V2 m1, m2, m3, m4, m5, m6
mova m7, [pw_16]
%endif
%if mmsize==32
mova [r2+r4*2], xm1
mova [r2+r4*2+mmsize/2], xm4
vextracti128 [r2+r4*2+mmsize], m1, 1
vextracti128 [r2+r4*2+mmsize*3/2], m4, 1
%else
mova [r2+r4*2], m1
mova [r2+r4*2+mmsize], m4
%endif
FILT_PACK m1, m4, m7, 5
movnta [r0+r4], m1
add r1, mmsize
add r5, mmsize
add r4, mmsize
jl .loop
RET
%endmacro
;-----------------------------------------------------------------------------
; void hpel_filter_c( uint8_t *dst, int16_t *buf, intptr_t width );
;-----------------------------------------------------------------------------
INIT_MMX mmx2
cglobal hpel_filter_c, 3,3
add r0, r2
lea r1, [r1+r2*2]
neg r2
%define src r1+r2*2
movq m7, [pw_32]
.loop:
movq m1, [src-4]
movq m2, [src-2]
movq m3, [src ]
movq m4, [src+4]
movq m5, [src+6]
paddw m3, [src+2] ; c0
paddw m2, m4 ; b0
paddw m1, m5 ; a0
movq m6, [src+8]
paddw m4, [src+14] ; a1
paddw m5, [src+12] ; b1
paddw m6, [src+10] ; c1
FILT_H2 m1, m2, m3, m4, m5, m6
FILT_PACK m1, m4, m7, 6
movntq [r0+r2], m1
add r2, 8
jl .loop
RET
;-----------------------------------------------------------------------------
; void hpel_filter_h( uint8_t *dst, uint8_t *src, intptr_t width );
;-----------------------------------------------------------------------------
INIT_MMX mmx2
cglobal hpel_filter_h, 3,3
add r0, r2
add r1, r2
neg r2
%define src r1+r2
pxor m0, m0
.loop:
movd m1, [src-2]
movd m2, [src-1]
movd m3, [src ]
movd m6, [src+1]
movd m4, [src+2]
movd m5, [src+3]
punpcklbw m1, m0
punpcklbw m2, m0
punpcklbw m3, m0
punpcklbw m6, m0
punpcklbw m4, m0
punpcklbw m5, m0
paddw m3, m6 ; c0
paddw m2, m4 ; b0
paddw m1, m5 ; a0
movd m7, [src+7]
movd m6, [src+6]
punpcklbw m7, m0
punpcklbw m6, m0
paddw m4, m7 ; c1
paddw m5, m6 ; b1
movd m7, [src+5]
movd m6, [src+4]
punpcklbw m7, m0
punpcklbw m6, m0
paddw m6, m7 ; a1
movq m7, [pw_1]
FILT_H2 m1, m2, m3, m4, m5, m6
FILT_PACK m1, m4, m7, 1
movntq [r0+r2], m1
add r2, 8
jl .loop
RET
%macro HPEL_C 0
;-----------------------------------------------------------------------------
; void hpel_filter_c( uint8_t *dst, int16_t *buf, intptr_t width );
;-----------------------------------------------------------------------------
cglobal hpel_filter_c, 3,3,9
add r0, r2
lea r1, [r1+r2*2]
neg r2
%define src r1+r2*2
%ifnidn cpuname, sse2
%if cpuflag(ssse3)
mova m7, [pw_512]
%else
mova m7, [pw_32]
%endif
%define pw_rnd m7
%elif ARCH_X86_64
mova m8, [pw_32]
%define pw_rnd m8
%else
%define pw_rnd [pw_32]
%endif
; This doesn't seem to be faster (with AVX) on Sandy Bridge or Bulldozer...
%if mmsize==32
.loop:
movu m4, [src-4]
movu m5, [src-2]
mova m6, [src+0]
movu m3, [src-4+mmsize]
movu m2, [src-2+mmsize]
mova m1, [src+0+mmsize]
paddw m4, [src+6]
paddw m5, [src+4]
paddw m6, [src+2]
paddw m3, [src+6+mmsize]
paddw m2, [src+4+mmsize]
paddw m1, [src+2+mmsize]
FILT_H2 m4, m5, m6, m3, m2, m1
%else
mova m0, [src-16]
mova m1, [src]
.loop:
mova m2, [src+16]
PALIGNR m4, m1, m0, 12, m7
PALIGNR m5, m1, m0, 14, m0
PALIGNR m0, m2, m1, 6, m7
paddw m4, m0
PALIGNR m0, m2, m1, 4, m7
paddw m5, m0
PALIGNR m6, m2, m1, 2, m7
paddw m6, m1
FILT_H m4, m5, m6
mova m0, m2
mova m5, m2
PALIGNR m2, m1, 12, m7
PALIGNR m5, m1, 14, m1
mova m1, [src+32]
PALIGNR m3, m1, m0, 6, m7
paddw m3, m2
PALIGNR m6, m1, m0, 4, m7
paddw m5, m6
PALIGNR m6, m1, m0, 2, m7
paddw m6, m0
FILT_H m3, m5, m6
%endif
FILT_PACK m4, m3, pw_rnd, 6
%if mmsize==32
vpermq m4, m4, q3120
%endif
movnta [r0+r2], m4
add r2, mmsize
jl .loop
RET
%endmacro
;-----------------------------------------------------------------------------
; void hpel_filter_h( uint8_t *dst, uint8_t *src, intptr_t width );
;-----------------------------------------------------------------------------
INIT_XMM sse2
cglobal hpel_filter_h, 3,3,8
add r0, r2
add r1, r2
neg r2
%define src r1+r2
pxor m0, m0
.loop:
movh m1, [src-2]
movh m2, [src-1]
movh m3, [src ]
movh m4, [src+1]
movh m5, [src+2]
movh m6, [src+3]
punpcklbw m1, m0
punpcklbw m2, m0
punpcklbw m3, m0
punpcklbw m4, m0
punpcklbw m5, m0
punpcklbw m6, m0
paddw m3, m4 ; c0
paddw m2, m5 ; b0
paddw m1, m6 ; a0
movh m4, [src+6]
movh m5, [src+7]
movh m6, [src+10]
movh m7, [src+11]
punpcklbw m4, m0
punpcklbw m5, m0
punpcklbw m6, m0
punpcklbw m7, m0
paddw m5, m6 ; b1
paddw m4, m7 ; a1
movh m6, [src+8]
movh m7, [src+9]
punpcklbw m6, m0
punpcklbw m7, m0
paddw m6, m7 ; c1
mova m7, [pw_1] ; FIXME xmm8
FILT_H2 m1, m2, m3, m4, m5, m6
FILT_PACK m1, m4, m7, 1
movntps [r0+r2], m1
add r2, 16
jl .loop
RET
;-----------------------------------------------------------------------------
; void hpel_filter_h( uint8_t *dst, uint8_t *src, intptr_t width );
;-----------------------------------------------------------------------------
%macro HPEL_H 0
cglobal hpel_filter_h, 3,3
add r0, r2
add r1, r2
neg r2
%define src r1+r2
mova m0, [src-16]
mova m1, [src]
mova m7, [pw_1024]
.loop:
mova m2, [src+16]
; Using unaligned loads instead of palignr is marginally slower on SB and significantly
; slower on Bulldozer, despite their fast load units -- even though it would let us avoid
; the repeated loads of constants for pmaddubsw.
palignr m3, m1, m0, 14
palignr m4, m1, m0, 15
palignr m0, m2, m1, 2
pmaddubsw m3, [filt_mul15]
pmaddubsw m4, [filt_mul15]
pmaddubsw m0, [filt_mul51]
palignr m5, m2, m1, 1
palignr m6, m2, m1, 3
paddw m3, m0
mova m0, m1
pmaddubsw m1, [filt_mul20]
pmaddubsw m5, [filt_mul20]
pmaddubsw m6, [filt_mul51]
paddw m3, m1
paddw m4, m5
paddw m4, m6
FILT_PACK m3, m4, m7, 5
pshufb m3, [hpel_shuf]
mova m1, m2
movntps [r0+r2], m3
add r2, 16
jl .loop
RET
%endmacro
INIT_MMX mmx2
HPEL_V 0
INIT_XMM sse2
HPEL_V 8
%if ARCH_X86_64 == 0
INIT_XMM sse2
HPEL_C
INIT_XMM ssse3
HPEL_C
HPEL_V 0
HPEL_H
INIT_XMM avx
HPEL_C
HPEL_V 0
HPEL_H
INIT_YMM avx2
HPEL_V 8
HPEL_C
INIT_YMM avx2
cglobal hpel_filter_h, 3,3,8
add r0, r2
add r1, r2
neg r2
%define src r1+r2
mova m5, [filt_mul15]
mova m6, [filt_mul20]
mova m7, [filt_mul51]
.loop:
movu m0, [src-2]
movu m1, [src-1]
movu m2, [src+2]
pmaddubsw m0, m5
pmaddubsw m1, m5
pmaddubsw m2, m7
paddw m0, m2
mova m2, [src+0]
movu m3, [src+1]
movu m4, [src+3]
pmaddubsw m2, m6
pmaddubsw m3, m6
pmaddubsw m4, m7
paddw m0, m2
paddw m1, m3
paddw m1, m4
mova m2, [pw_1024]
FILT_PACK m0, m1, m2, 5
pshufb m0, [hpel_shuf]
movnta [r0+r2], m0
add r2, mmsize
jl .loop
RET
%endif
%if ARCH_X86_64
%macro DO_FILT_V 5
;The optimum prefetch distance is difficult to determine in checkasm:
;any prefetch seems slower than not prefetching.
;In real use, the prefetch seems to be a slight win.
;+mmsize is picked somewhat arbitrarily here based on the fact that even one
;loop iteration is going to take longer than the prefetch.
prefetcht0 [r1+r2*2+mmsize]
%if cpuflag(ssse3)
mova m1, [r3]
mova m2, [r3+r2]
mova %3, [r3+r2*2]
mova m3, [r1]
mova %1, [r1+r2]
mova %2, [r1+r2*2]
punpckhbw m4, m1, m2
punpcklbw m1, m2
punpckhbw m2, %1, %2
punpcklbw %1, %2
punpckhbw %2, m3, %3
punpcklbw m3, %3
pmaddubsw m1, m12
pmaddubsw m4, m12
pmaddubsw %1, m0
pmaddubsw m2, m0
pmaddubsw m3, m14
pmaddubsw %2, m14
paddw m1, %1
paddw m4, m2
paddw m1, m3
paddw m4, %2
%else
LOAD_ADD_2 m1, m4, [r3 ], [r1+r2*2], m2, m5 ; a0 / a1
LOAD_ADD_2 m2, m5, [r3+r2 ], [r1+r2 ], m3, m6 ; b0 / b1
LOAD_ADD_2 m3, m6, [r3+r2*2], [r1 ], %3, %4 ; c0 / c1
packuswb %3, %4
FILT_V2 m1, m2, m3, m4, m5, m6
%endif
add r3, mmsize
add r1, mmsize
%if mmsize==32
vinserti128 %1, m1, xm4, 1
vperm2i128 %2, m1, m4, q0301
%else
mova %1, m1
mova %2, m4
%endif
FILT_PACK m1, m4, m15, 5
movntps [r8+r4+%5], m1
%endmacro
%macro FILT_C 3
%if mmsize==32
vperm2i128 m3, %2, %1, q0003
%endif
PALIGNR m1, %2, %1, (mmsize-4), m3
PALIGNR m2, %2, %1, (mmsize-2), m3
%if mmsize==32
vperm2i128 %1, %3, %2, q0003
%endif
PALIGNR m3, %3, %2, 4, %1
PALIGNR m4, %3, %2, 2, %1
paddw m3, m2
%if mmsize==32
mova m2, %1
%endif
mova %1, %3
PALIGNR %3, %3, %2, 6, m2
paddw m4, %2
paddw %3, m1
FILT_H %3, m3, m4
%endmacro
%macro DO_FILT_C 4
FILT_C %1, %2, %3
FILT_C %2, %1, %4
FILT_PACK %3, %4, m15, 6
%if mmsize==32
vpermq %3, %3, q3120
%endif
movntps [r5+r4], %3
%endmacro
%macro ADD8TO16 5
punpckhbw %3, %1, %5
punpcklbw %1, %5
punpcklbw %4, %2, %5
punpckhbw %2, %5
paddw %2, %3
paddw %1, %4
%endmacro
%macro DO_FILT_H 3
%if mmsize==32
vperm2i128 m3, %2, %1, q0003
%endif
PALIGNR m1, %2, %1, (mmsize-2), m3
PALIGNR m2, %2, %1, (mmsize-1), m3
%if mmsize==32
vperm2i128 m3, %3, %2, q0003
%endif
PALIGNR m4, %3, %2, 1 , m3
PALIGNR m5, %3, %2, 2 , m3
PALIGNR m6, %3, %2, 3 , m3
mova %1, %2
%if cpuflag(ssse3)
pmaddubsw m1, m12
pmaddubsw m2, m12
pmaddubsw %2, m14
pmaddubsw m4, m14
pmaddubsw m5, m0
pmaddubsw m6, m0
paddw m1, %2
paddw m2, m4
paddw m1, m5
paddw m2, m6
FILT_PACK m1, m2, m15, 5
pshufb m1, [hpel_shuf]
%else ; ssse3, avx
ADD8TO16 m1, m6, m12, m3, m0 ; a
ADD8TO16 m2, m5, m12, m3, m0 ; b
ADD8TO16 %2, m4, m12, m3, m0 ; c
FILT_V2 m1, m2, %2, m6, m5, m4
FILT_PACK m1, m6, m15, 5
%endif
movntps [r0+r4], m1
mova %2, %3
%endmacro
%macro HPEL 0
;-----------------------------------------------------------------------------
; void hpel_filter( uint8_t *dsth, uint8_t *dstv, uint8_t *dstc,
; uint8_t *src, intptr_t stride, int width, int height )
;-----------------------------------------------------------------------------
cglobal hpel_filter, 7,9,16
mov r7, r3
sub r5d, mmsize
mov r8, r1
and r7, mmsize-1
sub r3, r7
add r0, r5
add r8, r5
add r7, r5
add r5, r2
mov r2, r4
neg r7
lea r1, [r3+r2]
sub r3, r2
sub r3, r2
mov r4, r7
%if cpuflag(ssse3)
mova m0, [filt_mul51]
mova m12, [filt_mul15]
mova m14, [filt_mul20]
mova m15, [pw_1024]
%else
pxor m0, m0
mova m15, [pw_16]
%endif
;ALIGN 16
.loopy:
; first filter_v
DO_FILT_V m8, m7, m13, m12, 0
;ALIGN 16
.loopx:
DO_FILT_V m6, m5, m11, m12, mmsize
.lastx:
%if cpuflag(ssse3)
psrlw m15, 1 ; pw_512
%else
paddw m15, m15 ; pw_32
%endif
DO_FILT_C m9, m8, m7, m6
%if cpuflag(ssse3)
paddw m15, m15 ; pw_1024
%else
psrlw m15, 1 ; pw_16
%endif
mova m7, m5
DO_FILT_H m10, m13, m11
add r4, mmsize
jl .loopx
cmp r4, mmsize
jl .lastx
; setup regs for next y
sub r4, r7
sub r4, r2
sub r1, r4
sub r3, r4
add r0, r2
add r8, r2
add r5, r2
mov r4, r7
sub r6d, 1
jg .loopy
sfence
RET
%endmacro
INIT_XMM sse2
HPEL
INIT_XMM ssse3
HPEL
INIT_XMM avx
HPEL
INIT_YMM avx2
HPEL
%endif ; ARCH_X86_64
%undef movntq
%undef movntps
%undef sfence
%endif ; !HIGH_BIT_DEPTH
%macro PREFETCHNT_ITER 2 ; src, bytes/iteration
%assign %%i 4*(%2) ; prefetch 4 iterations ahead. is this optimal?
%rep (%2+63) / 64 ; assume 64 byte cache lines
prefetchnta [%1+%%i]
%assign %%i %%i + 64
%endrep
%endmacro
;-----------------------------------------------------------------------------
; void plane_copy(_swap)_core( pixel *dst, intptr_t i_dst,
; pixel *src, intptr_t i_src, int w, int h )
;-----------------------------------------------------------------------------
; assumes i_dst and w are multiples of mmsize, and i_dst>w
%macro PLANE_COPY_CORE 1 ; swap
%if %1
cglobal plane_copy_swap_core, 6,7
%if mmsize == 32
vbroadcasti128 m4, [copy_swap_shuf]
%else
mova m4, [copy_swap_shuf]
%endif
%else
cglobal plane_copy_core, 6,7
%endif
FIX_STRIDES r1, r3
%if %1 && HIGH_BIT_DEPTH
shl r4d, 2
%elif %1 || HIGH_BIT_DEPTH
add r4d, r4d
%else
movsxdifnidn r4, r4d
%endif
add r0, r4
add r2, r4
neg r4
.loopy:
lea r6, [r4+4*mmsize]
%if %1
test r6d, r6d
jg .skip
%endif
.loopx:
PREFETCHNT_ITER r2+r6, 4*mmsize
movu m0, [r2+r6-4*mmsize]
movu m1, [r2+r6-3*mmsize]
movu m2, [r2+r6-2*mmsize]
movu m3, [r2+r6-1*mmsize]
%if %1
pshufb m0, m4
pshufb m1, m4
pshufb m2, m4
pshufb m3, m4
%endif
movnta [r0+r6-4*mmsize], m0
movnta [r0+r6-3*mmsize], m1
movnta [r0+r6-2*mmsize], m2
movnta [r0+r6-1*mmsize], m3
add r6, 4*mmsize
jle .loopx
.skip:
PREFETCHNT_ITER r2+r6, 4*mmsize
sub r6, 4*mmsize
jz .end
.loop_end:
movu m0, [r2+r6]
%if %1
pshufb m0, m4
%endif
movnta [r0+r6], m0
add r6, mmsize
jl .loop_end
.end:
add r0, r1
add r2, r3
dec r5d
jg .loopy
sfence
RET
%endmacro
INIT_XMM sse
PLANE_COPY_CORE 0
INIT_XMM ssse3
PLANE_COPY_CORE 1
INIT_YMM avx
PLANE_COPY_CORE 0
INIT_YMM avx2
PLANE_COPY_CORE 1
%macro PLANE_COPY_AVX512 1 ; swap
%if %1
cglobal plane_copy_swap, 6,7
vbroadcasti32x4 m4, [copy_swap_shuf]
%else
cglobal plane_copy, 6,7
%endif
movsxdifnidn r4, r4d
%if %1 && HIGH_BIT_DEPTH
%define %%mload vmovdqu32
lea r2, [r2+4*r4-64]
lea r0, [r0+4*r4-64]
neg r4
mov r6d, r4d
shl r4, 2
or r6d, 0xffff0010
shrx r6d, r6d, r6d ; (1 << (w & 15)) - 1
kmovw k1, r6d
%elif %1 || HIGH_BIT_DEPTH
%define %%mload vmovdqu16
lea r2, [r2+2*r4-64]
lea r0, [r0+2*r4-64]
mov r6d, -1
neg r4
shrx r6d, r6d, r4d
add r4, r4
kmovd k1, r6d
%else
%define %%mload vmovdqu8
lea r2, [r2+1*r4-64]
lea r0, [r0+1*r4-64]
mov r6, -1
neg r4
shrx r6, r6, r4
%if ARCH_X86_64
kmovq k1, r6
%else
kmovd k1, r6d
test r4d, 32
jnz .l32
kxnord k2, k2, k2
kunpckdq k1, k1, k2
.l32:
%endif
%endif
FIX_STRIDES r3, r1
add r4, 4*64
jge .small
mov r6, r4
.loop: ; >256 bytes/row
PREFETCHNT_ITER r2+r4+64, 4*64
movu m0, [r2+r4-3*64]
movu m1, [r2+r4-2*64]
movu m2, [r2+r4-1*64]
movu m3, [r2+r4-0*64]
%if %1
pshufb m0, m4
pshufb m1, m4
pshufb m2, m4
pshufb m3, m4
%endif
movnta [r0+r4-3*64], m0
movnta [r0+r4-2*64], m1
movnta [r0+r4-1*64], m2
movnta [r0+r4-0*64], m3
add r4, 4*64
jl .loop
PREFETCHNT_ITER r2+r4+64, 4*64
sub r4, 3*64
jge .tail
.loop2:
movu m0, [r2+r4]
%if %1
pshufb m0, m4
%endif
movnta [r0+r4], m0
add r4, 64
jl .loop2
.tail:
%%mload m0 {k1}{z}, [r2+r4]
%if %1
pshufb m0, m4
%endif
movnta [r0+r4], m0
add r2, r3
add r0, r1
mov r4, r6
dec r5d
jg .loop
sfence
RET
.small: ; 65-256 bytes/row. skip non-temporal stores
sub r4, 3*64
jge .tiny
mov r6, r4
.small_loop:
PREFETCHNT_ITER r2+r4+64, 64
movu m0, [r2+r4]
%if %1
pshufb m0, m4
%endif
mova [r0+r4], m0
add r4, 64
jl .small_loop
PREFETCHNT_ITER r2+r4+64, 64
%%mload m0 {k1}{z}, [r2+r4]
%if %1
pshufb m0, m4
%endif
mova [r0+r4], m0
add r2, r3
add r0, r1
mov r4, r6
dec r5d
jg .small_loop
RET
.tiny: ; 1-64 bytes/row. skip non-temporal stores
PREFETCHNT_ITER r2+r4+64, 64
%%mload m0 {k1}{z}, [r2+r4]
%if %1
pshufb m0, m4
%endif
mova [r0+r4], m0
add r2, r3
add r0, r1
dec r5d
jg .tiny
RET
%endmacro
INIT_ZMM avx512
PLANE_COPY_AVX512 0
PLANE_COPY_AVX512 1
%macro INTERLEAVE 4-5 ; dst, srcu, srcv, is_aligned, nt_hint
%if HIGH_BIT_DEPTH
%assign x 0
%rep 16/mmsize
mov%4 m0, [%2+(x/2)*mmsize]
mov%4 m1, [%3+(x/2)*mmsize]
punpckhwd m2, m0, m1
punpcklwd m0, m1
mov%5a [%1+(x+0)*mmsize], m0
mov%5a [%1+(x+1)*mmsize], m2
%assign x (x+2)
%endrep
%else
movq m0, [%2]
%if mmsize==16
%ifidn %4, a
punpcklbw m0, [%3]
%else
movq m1, [%3]
punpcklbw m0, m1
%endif
mov%5a [%1], m0
%else
movq m1, [%3]
punpckhbw m2, m0, m1
punpcklbw m0, m1
mov%5a [%1+0], m0
mov%5a [%1+8], m2
%endif
%endif ; HIGH_BIT_DEPTH
%endmacro
%macro DEINTERLEAVE 6 ; dsta, dstb, src, dsta==dstb+8, shuffle constant, is aligned
mov%6 m0, [%3]
%if mmsize == 32
pshufb m0, %5
vpermq m0, m0, q3120
%if %4
mova [%1], m0
%else
mov%6 [%1], xm0
vextracti128 [%2], m0, 1
%endif
%elif HIGH_BIT_DEPTH
mov%6 m1, [%3+mmsize]
psrld m2, m0, 16
psrld m3, m1, 16
pand m0, %5
pand m1, %5
packssdw m0, m1
packssdw m2, m3
mov%6 [%1], m0
mov%6 [%2], m2
%else ; !HIGH_BIT_DEPTH
%if cpuflag(ssse3)
pshufb m0, %5
%else
mova m1, m0
pand m0, %5
psrlw m1, 8
packuswb m0, m1
%endif
%if %4
mova [%1], m0
%else
movq [%1], m0
movhps [%2], m0
%endif
%endif ; HIGH_BIT_DEPTH
%endmacro
%macro PLANE_INTERLEAVE 0
;-----------------------------------------------------------------------------
; void plane_copy_interleave_core( uint8_t *dst, intptr_t i_dst,
; uint8_t *srcu, intptr_t i_srcu,
; uint8_t *srcv, intptr_t i_srcv, int w, int h )
;-----------------------------------------------------------------------------
; assumes i_dst and w are multiples of 16, and i_dst>2*w
cglobal plane_copy_interleave_core, 6,9
mov r6d, r6m
%if HIGH_BIT_DEPTH
FIX_STRIDES r1, r3, r5, r6d
movifnidn r1mp, r1
movifnidn r3mp, r3
mov r6m, r6d
%endif
lea r0, [r0+r6*2]
add r2, r6
add r4, r6
%if ARCH_X86_64
DECLARE_REG_TMP 7,8
%else
DECLARE_REG_TMP 1,3
%endif
mov t1, r1
shr t1, SIZEOF_PIXEL
sub t1, r6
mov t0d, r7m
.loopy:
mov r6d, r6m
neg r6
.prefetch:
prefetchnta [r2+r6]
prefetchnta [r4+r6]
add r6, 64
jl .prefetch
mov r6d, r6m
neg r6
.loopx:
INTERLEAVE r0+r6*2+ 0*SIZEOF_PIXEL, r2+r6+0*SIZEOF_PIXEL, r4+r6+0*SIZEOF_PIXEL, u, nt
INTERLEAVE r0+r6*2+16*SIZEOF_PIXEL, r2+r6+8*SIZEOF_PIXEL, r4+r6+8*SIZEOF_PIXEL, u, nt
add r6, 16*SIZEOF_PIXEL
jl .loopx
.pad:
%assign n 0
%rep SIZEOF_PIXEL
%if mmsize==8
movntq [r0+r6*2+(n+ 0)], m0
movntq [r0+r6*2+(n+ 8)], m0
movntq [r0+r6*2+(n+16)], m0
movntq [r0+r6*2+(n+24)], m0
%else
movntdq [r0+r6*2+(n+ 0)], m0
movntdq [r0+r6*2+(n+16)], m0
%endif
%assign n n+32
%endrep
add r6, 16*SIZEOF_PIXEL
cmp r6, t1
jl .pad
add r0, r1mp
add r2, r3mp
add r4, r5
dec t0d
jg .loopy
sfence
emms
RET
;-----------------------------------------------------------------------------
; void store_interleave_chroma( uint8_t *dst, intptr_t i_dst, uint8_t *srcu, uint8_t *srcv, int height )
;-----------------------------------------------------------------------------
cglobal store_interleave_chroma, 5,5
FIX_STRIDES r1
.loop:
INTERLEAVE r0+ 0, r2+ 0, r3+ 0, a
INTERLEAVE r0+r1, r2+FDEC_STRIDEB, r3+FDEC_STRIDEB, a
add r2, FDEC_STRIDEB*2
add r3, FDEC_STRIDEB*2
lea r0, [r0+r1*2]
sub r4d, 2
jg .loop
RET
%endmacro ; PLANE_INTERLEAVE
%macro DEINTERLEAVE_START 0
%if mmsize == 32
vbroadcasti128 m4, [deinterleave_shuf]
%elif HIGH_BIT_DEPTH
mova m4, [pd_ffff]
%elif cpuflag(ssse3)
mova m4, [deinterleave_shuf]
%else
mova m4, [pw_00ff]
%endif ; HIGH_BIT_DEPTH
%endmacro
%macro PLANE_DEINTERLEAVE 0
;-----------------------------------------------------------------------------
; void plane_copy_deinterleave( pixel *dsta, intptr_t i_dsta,
; pixel *dstb, intptr_t i_dstb,
; pixel *src, intptr_t i_src, int w, int h )
;-----------------------------------------------------------------------------
%if ARCH_X86_64
cglobal plane_copy_deinterleave, 6,9
%define %%w r7
%define %%h r8d
mov r8d, r7m
%else
cglobal plane_copy_deinterleave, 6,7
%define %%w r6m
%define %%h dword r7m
%endif
%if HIGH_BIT_DEPTH
%assign %%n 16
%else
%assign %%n mmsize/2
%endif
DEINTERLEAVE_START
mov r6d, r6m
FIX_STRIDES r1, r3, r5, r6d
add r0, r6
add r2, r6
lea r4, [r4+r6*2]
neg r6
mov %%w, r6
.loop:
DEINTERLEAVE r0+r6, r2+r6, r4+r6*2, 0, m4, u
DEINTERLEAVE r0+r6+%%n, r2+r6+%%n, r4+r6*2+%%n*2, 0, m4, u
add r6, %%n*2
jl .loop
add r0, r1
add r2, r3
add r4, r5
mov r6, %%w
dec %%h
jg .loop
RET
%endmacro ; PLANE_DEINTERLEAVE
%macro LOAD_DEINTERLEAVE_CHROMA 0
;-----------------------------------------------------------------------------
; void load_deinterleave_chroma_fenc( pixel *dst, pixel *src, intptr_t i_src, int height )
;-----------------------------------------------------------------------------
cglobal load_deinterleave_chroma_fenc, 4,4
DEINTERLEAVE_START
FIX_STRIDES r2
.loop:
DEINTERLEAVE r0+ 0, r0+FENC_STRIDEB*1/2, r1+ 0, 1, m4, a
DEINTERLEAVE r0+FENC_STRIDEB, r0+FENC_STRIDEB*3/2, r1+r2, 1, m4, a
add r0, FENC_STRIDEB*2
lea r1, [r1+r2*2]
sub r3d, 2
jg .loop
RET
;-----------------------------------------------------------------------------
; void load_deinterleave_chroma_fdec( pixel *dst, pixel *src, intptr_t i_src, int height )
;-----------------------------------------------------------------------------
cglobal load_deinterleave_chroma_fdec, 4,4
DEINTERLEAVE_START
FIX_STRIDES r2
.loop:
DEINTERLEAVE r0+ 0, r0+FDEC_STRIDEB*1/2, r1+ 0, 0, m4, a
DEINTERLEAVE r0+FDEC_STRIDEB, r0+FDEC_STRIDEB*3/2, r1+r2, 0, m4, a
add r0, FDEC_STRIDEB*2
lea r1, [r1+r2*2]
sub r3d, 2
jg .loop
RET
%endmacro ; LOAD_DEINTERLEAVE_CHROMA
%macro LOAD_DEINTERLEAVE_CHROMA_FDEC_AVX512 0
cglobal load_deinterleave_chroma_fdec, 4,5
vbroadcasti32x8 m0, [deinterleave_shuf32a]
mov r4d, 0x3333ff00
kmovd k1, r4d
lea r4, [r2*3]
kshiftrd k2, k1, 16
.loop:
vbroadcasti128 ym1, [r1]
vbroadcasti32x4 m1 {k1}, [r1+r2]
vbroadcasti128 ym2, [r1+r2*2]
vbroadcasti32x4 m2 {k1}, [r1+r4]
lea r1, [r1+r2*4]
pshufb m1, m0
pshufb m2, m0
vmovdqa32 [r0] {k2}, m1
vmovdqa32 [r0+mmsize] {k2}, m2
add r0, 2*mmsize
sub r3d, 4
jg .loop
RET
%endmacro
%macro LOAD_DEINTERLEAVE_CHROMA_FENC_AVX2 0
cglobal load_deinterleave_chroma_fenc, 4,5
vbroadcasti128 m0, [deinterleave_shuf]
lea r4, [r2*3]
.loop:
mova xm1, [r1] ; 0
vinserti128 ym1, [r1+r2], 1 ; 1
%if mmsize == 64
mova xm2, [r1+r2*4] ; 4
vinserti32x4 m1, [r1+r2*2], 2 ; 2
vinserti32x4 m2, [r1+r4*2], 2 ; 6
vinserti32x4 m1, [r1+r4], 3 ; 3
lea r1, [r1+r2*4]
vinserti32x4 m2, [r1+r2], 1 ; 5
vinserti32x4 m2, [r1+r4], 3 ; 7
%else
mova xm2, [r1+r2*2] ; 2
vinserti128 m2, [r1+r4], 1 ; 3
%endif
lea r1, [r1+r2*4]
pshufb m1, m0
pshufb m2, m0
mova [r0], m1
mova [r0+mmsize], m2
add r0, 2*mmsize
sub r3d, mmsize/8
jg .loop
RET
%endmacro ; LOAD_DEINTERLEAVE_CHROMA_FENC_AVX2
%macro PLANE_DEINTERLEAVE_RGB_CORE 9 ; pw, i_dsta, i_dstb, i_dstc, i_src, w, h, tmp1, tmp2
%if mmsize == 32
vbroadcasti128 m3, [deinterleave_rgb_shuf+(%1-3)*16]
%elif cpuflag(ssse3)
mova m3, [deinterleave_rgb_shuf+(%1-3)*16]
%endif
%%loopy:
mov %8, r6
mov %9, %6
%%loopx:
%if mmsize == 32 && %1 == 3
movu xm0, [%8+0*12]
vinserti128 m0, m0, [%8+1*12], 1
movu xm1, [%8+2*12]
vinserti128 m1, m1, [%8+3*12], 1
%else
movu m0, [%8]
movu m1, [%8+%1*mmsize/4]
%endif
%if cpuflag(ssse3)
pshufb m0, m3 ; a0 a1 a2 a3 a0 a1 a2 a3 b0 b1 b2 b3 c0 c1 c2 c3
pshufb m1, m3 ; a4 a5 a6 a7 a4 a5 a6 a7 b4 b5 b6 b7 c4 c5 c6 c7
%if mmsize == 32
vpblendd m2, m0, m1, 0x22
punpckhdq m0, m1
vpermd m2, m4, m2
vpermd m0, m4, m0
mova [r0+%9], xm2
mova [r2+%9], xm0
vextracti128 [r4+%9], m0, 1
%else
SBUTTERFLY dq, 0, 1, 2
movq [r0+%9], m0
movq [r2+%9], m1
movhps [r4+%9], m1
%endif
%elif %1 == 3
SBUTTERFLY bw, 0, 1, 2
pshufd m2, m0, q0321 ; c0 c4 a1 a5 b1 b5 c1 c5 __ __ __ __ a0 a4 b0 b4
punpcklbw m3, m2, m1 ; c0 c2 c4 c6 a1 a3 a5 a7 b1 b3 b5 b7 c1 c3 c5 c7
punpckhbw m2, m0 ; __ __ __ __ __ __ __ __ a0 a2 a4 a6 b0 b2 b4 b6
pshufd m0, m3, q2103 ; c1 c3 c5 c7 __ __ __ __ a1 a3 a5 a7 b1 b3 b5 b7
punpckhbw m2, m0 ; a0 a1 a2 a3 a4 a5 a6 a7 b0 b1 b2 b3 b4 b5 b6 b7
punpcklbw m3, m0 ; c0 c1 c2 c3 c4 c5 c6 c7
movq [r0+%9], m2
movhps [r2+%9], m2
movq [r4+%9], m3
%else ; %1 == 4
SBUTTERFLY bw, 0, 1, 2
SBUTTERFLY bw, 0, 1, 2
SBUTTERFLY bw, 0, 1, 2
movq [r0+%9], m0
movhps [r2+%9], m0
movq [r4+%9], m1
%endif
add %8, %1*mmsize/2
add %9, mmsize/2
jl %%loopx
add r0, %2
add r2, %3
add r4, %4
add r6, %5
dec %7d
jg %%loopy
%endmacro
%macro PLANE_DEINTERLEAVE_RGB 0
;-----------------------------------------------------------------------------
; void x264_plane_copy_deinterleave_rgb( pixel *dsta, intptr_t i_dsta,
; pixel *dstb, intptr_t i_dstb,
; pixel *dstc, intptr_t i_dstc,
; pixel *src, intptr_t i_src, int pw, int w, int h )
;-----------------------------------------------------------------------------
%if ARCH_X86_64
cglobal plane_copy_deinterleave_rgb, 8,12
%define %%args r1, r3, r5, r7, r8, r9, r10, r11
mov r8d, r9m
mov r9d, r10m
add r0, r8
add r2, r8
add r4, r8
neg r8
%else
cglobal plane_copy_deinterleave_rgb, 1,7
%define %%args r1m, r3m, r5m, r7m, r9m, r1, r3, r5
mov r1, r9m
mov r2, r2m
mov r4, r4m
mov r6, r6m
add r0, r1
add r2, r1
add r4, r1
neg r1
mov r9m, r1
mov r1, r10m
%endif
%if mmsize == 32
mova m4, [deinterleave_shufd]
%endif
cmp dword r8m, 4
je .pw4
PLANE_DEINTERLEAVE_RGB_CORE 3, %%args ; BGR
jmp .ret
.pw4:
PLANE_DEINTERLEAVE_RGB_CORE 4, %%args ; BGRA
.ret:
REP_RET
%endmacro
%macro PLANE_DEINTERLEAVE_V210 0
;-----------------------------------------------------------------------------
; void x264_plane_copy_deinterleave_v210( uint16_t *dsty, intptr_t i_dsty,
; uint16_t *dstc, intptr_t i_dstc,
; uint32_t *src, intptr_t i_src, int w, int h )
;-----------------------------------------------------------------------------
%if ARCH_X86_64
cglobal plane_copy_deinterleave_v210, 8,10,7
%define src r8
%define org_w r9
%define h r7d
%else
cglobal plane_copy_deinterleave_v210, 7,7,7
%define src r4m
%define org_w r6m
%define h dword r7m
%endif
FIX_STRIDES r1, r3, r6d
shl r5, 2
add r0, r6
add r2, r6
neg r6
mov src, r4
mov org_w, r6
%if cpuflag(avx512)
vpbroadcastd m2, [v210_mask]
vpbroadcastd m3, [v210_shuf_avx512]
psrlw m3, 6 ; dw 0, 4
mova m4, [v210_shuf_avx512] ; luma
psrlw m5, m4, 8 ; chroma
%else
%if mmsize == 32
vbroadcasti128 m2, [v210_mask]
vbroadcasti128 m3, [v210_luma_shuf]
vbroadcasti128 m4, [v210_chroma_shuf]
%else
mova m2, [v210_mask]
mova m3, [v210_luma_shuf]
mova m4, [v210_chroma_shuf]
%endif
mova m5, [v210_mult] ; also functions as vpermd index for avx2
pshufd m6, m5, q1102
%endif
ALIGN 16
.loop:
movu m1, [r4]
pandn m0, m2, m1
pand m1, m2
%if cpuflag(avx512)
psrld m0, 10
vpsrlvw m1, m3
mova m6, m0
vpermt2w m0, m4, m1
vpermt2w m1, m5, m6
%else
pshufb m0, m3
pshufb m1, m4
pmulhrsw m0, m5 ; y0 y1 y2 y3 y4 y5 __ __
pmulhrsw m1, m6 ; u0 v0 u1 v1 u2 v2 __ __
%if mmsize == 32
vpermd m0, m5, m0
vpermd m1, m5, m1
%endif
%endif
movu [r0+r6], m0
movu [r2+r6], m1
add r4, mmsize
add r6, mmsize*3/4
jl .loop
add r0, r1
add r2, r3
add src, r5
mov r4, src
mov r6, org_w
dec h
jg .loop
RET
%endmacro ; PLANE_DEINTERLEAVE_V210
INIT_MMX mmx2
PLANE_INTERLEAVE
INIT_XMM sse2
PLANE_INTERLEAVE
PLANE_DEINTERLEAVE
LOAD_DEINTERLEAVE_CHROMA
INIT_YMM avx2
PLANE_DEINTERLEAVE
%if HIGH_BIT_DEPTH
INIT_XMM ssse3
PLANE_DEINTERLEAVE_V210
INIT_XMM avx
PLANE_INTERLEAVE
PLANE_DEINTERLEAVE
LOAD_DEINTERLEAVE_CHROMA
PLANE_DEINTERLEAVE_V210
INIT_YMM avx2
LOAD_DEINTERLEAVE_CHROMA
PLANE_DEINTERLEAVE_V210
INIT_ZMM avx512
PLANE_DEINTERLEAVE_V210
%else
INIT_XMM sse2
PLANE_DEINTERLEAVE_RGB
INIT_XMM ssse3
PLANE_DEINTERLEAVE
LOAD_DEINTERLEAVE_CHROMA
PLANE_DEINTERLEAVE_RGB
INIT_YMM avx2
LOAD_DEINTERLEAVE_CHROMA_FENC_AVX2
PLANE_DEINTERLEAVE_RGB
INIT_ZMM avx512
LOAD_DEINTERLEAVE_CHROMA_FDEC_AVX512
LOAD_DEINTERLEAVE_CHROMA_FENC_AVX2
%endif
; These functions are not general-use; not only do they require aligned input, but memcpy
; requires size to be a multiple of 16 and memzero requires size to be a multiple of 128.
;-----------------------------------------------------------------------------
; void *memcpy_aligned( void *dst, const void *src, size_t n );
;-----------------------------------------------------------------------------
%macro MEMCPY 0
cglobal memcpy_aligned, 3,3
%if mmsize == 32
test r2d, 16
jz .copy32
mova xm0, [r1+r2-16]
mova [r0+r2-16], xm0
sub r2d, 16
jle .ret
.copy32:
%endif
test r2d, mmsize
jz .loop
mova m0, [r1+r2-mmsize]
mova [r0+r2-mmsize], m0
sub r2d, mmsize
jle .ret
.loop:
mova m0, [r1+r2-1*mmsize]
mova m1, [r1+r2-2*mmsize]
mova [r0+r2-1*mmsize], m0
mova [r0+r2-2*mmsize], m1
sub r2d, 2*mmsize
jg .loop
.ret:
RET
%endmacro
;-----------------------------------------------------------------------------
; void *memzero_aligned( void *dst, size_t n );
;-----------------------------------------------------------------------------
%macro MEMZERO 0
cglobal memzero_aligned, 2,2
xorps m0, m0
.loop:
%assign %%i mmsize
%rep 128 / mmsize
movaps [r0 + r1 - %%i], m0
%assign %%i %%i+mmsize
%endrep
sub r1d, 128
jg .loop
RET
%endmacro
INIT_XMM sse
MEMCPY
MEMZERO
INIT_YMM avx
MEMCPY
MEMZERO
INIT_ZMM avx512
MEMZERO
cglobal memcpy_aligned, 3,4
dec r2d ; offset of the last byte
rorx r3d, r2d, 2
and r2d, ~63
and r3d, 15 ; n = number of dwords minus one to copy in the tail
mova m0, [r1+r2]
not r3d ; bits 0-4: (n^15)+16, bits 16-31: 0xffff
shrx r3d, r3d, r3d ; 0xffff >> (n^15)
kmovw k1, r3d ; (1 << (n+1)) - 1
vmovdqa32 [r0+r2] {k1}, m0
sub r2d, 64
jl .ret
.loop:
mova m0, [r1+r2]
mova [r0+r2], m0
sub r2d, 64
jge .loop
.ret:
RET
%if HIGH_BIT_DEPTH == 0
;-----------------------------------------------------------------------------
; void integral_init4h( uint16_t *sum, uint8_t *pix, intptr_t stride )
;-----------------------------------------------------------------------------
%macro INTEGRAL_INIT4H 0
cglobal integral_init4h, 3,4
lea r3, [r0+r2*2]
add r1, r2
neg r2
pxor m4, m4
.loop:
mova xm0, [r1+r2]
mova xm1, [r1+r2+16]
%if mmsize==32
vinserti128 m0, m0, [r1+r2+ 8], 1
vinserti128 m1, m1, [r1+r2+24], 1
%else
palignr m1, m0, 8
%endif
mpsadbw m0, m4, 0
mpsadbw m1, m4, 0
paddw m0, [r0+r2*2]
paddw m1, [r0+r2*2+mmsize]
mova [r3+r2*2 ], m0
mova [r3+r2*2+mmsize], m1
add r2, mmsize
jl .loop
RET
%endmacro
INIT_XMM sse4
INTEGRAL_INIT4H
INIT_YMM avx2
INTEGRAL_INIT4H
%macro INTEGRAL_INIT8H 0
cglobal integral_init8h, 3,4
lea r3, [r0+r2*2]
add r1, r2
neg r2
pxor m4, m4
.loop:
mova xm0, [r1+r2]
mova xm1, [r1+r2+16]
%if mmsize==32
vinserti128 m0, m0, [r1+r2+ 8], 1
vinserti128 m1, m1, [r1+r2+24], 1
mpsadbw m2, m0, m4, 100100b
mpsadbw m3, m1, m4, 100100b
%else
palignr m1, m0, 8
mpsadbw m2, m0, m4, 100b
mpsadbw m3, m1, m4, 100b
%endif
mpsadbw m0, m4, 0
mpsadbw m1, m4, 0
paddw m0, [r0+r2*2]
paddw m1, [r0+r2*2+mmsize]
paddw m0, m2
paddw m1, m3
mova [r3+r2*2 ], m0
mova [r3+r2*2+mmsize], m1
add r2, mmsize
jl .loop
RET
%endmacro
INIT_XMM sse4
INTEGRAL_INIT8H
INIT_XMM avx
INTEGRAL_INIT8H
INIT_YMM avx2
INTEGRAL_INIT8H
%endif ; !HIGH_BIT_DEPTH
%macro INTEGRAL_INIT_8V 0
;-----------------------------------------------------------------------------
; void integral_init8v( uint16_t *sum8, intptr_t stride )
;-----------------------------------------------------------------------------
cglobal integral_init8v, 3,3
add r1, r1
add r0, r1
lea r2, [r0+r1*8]
neg r1
.loop:
mova m0, [r2+r1]
mova m1, [r2+r1+mmsize]
psubw m0, [r0+r1]
psubw m1, [r0+r1+mmsize]
mova [r0+r1], m0
mova [r0+r1+mmsize], m1
add r1, 2*mmsize
jl .loop
RET
%endmacro
INIT_MMX mmx
INTEGRAL_INIT_8V
INIT_XMM sse2
INTEGRAL_INIT_8V
INIT_YMM avx2
INTEGRAL_INIT_8V
;-----------------------------------------------------------------------------
; void integral_init4v( uint16_t *sum8, uint16_t *sum4, intptr_t stride )
;-----------------------------------------------------------------------------
INIT_MMX mmx
cglobal integral_init4v, 3,5
shl r2, 1
lea r3, [r0+r2*4]
lea r4, [r0+r2*8]
mova m0, [r0+r2]
mova m4, [r4+r2]
.loop:
mova m1, m4
psubw m1, m0
mova m4, [r4+r2-8]
mova m0, [r0+r2-8]
paddw m1, m4
mova m3, [r3+r2-8]
psubw m1, m0
psubw m3, m0
mova [r0+r2-8], m1
mova [r1+r2-8], m3
sub r2, 8
jge .loop
RET
INIT_XMM sse2
cglobal integral_init4v, 3,5
shl r2, 1
add r0, r2
add r1, r2
lea r3, [r0+r2*4]
lea r4, [r0+r2*8]
neg r2
.loop:
mova m0, [r0+r2]
mova m1, [r4+r2]
mova m2, m0
mova m4, m1
shufpd m0, [r0+r2+16], 1
shufpd m1, [r4+r2+16], 1
paddw m0, m2
paddw m1, m4
mova m3, [r3+r2]
psubw m1, m0
psubw m3, m2
mova [r0+r2], m1
mova [r1+r2], m3
add r2, 16
jl .loop
RET
INIT_XMM ssse3
cglobal integral_init4v, 3,5
shl r2, 1
add r0, r2
add r1, r2
lea r3, [r0+r2*4]
lea r4, [r0+r2*8]
neg r2
.loop:
mova m2, [r0+r2]
mova m0, [r0+r2+16]
mova m4, [r4+r2]
mova m1, [r4+r2+16]
palignr m0, m2, 8
palignr m1, m4, 8
paddw m0, m2
paddw m1, m4
mova m3, [r3+r2]
psubw m1, m0
psubw m3, m2
mova [r0+r2], m1
mova [r1+r2], m3
add r2, 16
jl .loop
RET
INIT_YMM avx2
cglobal integral_init4v, 3,5
add r2, r2
add r0, r2
add r1, r2
lea r3, [r0+r2*4]
lea r4, [r0+r2*8]
neg r2
.loop:
mova m2, [r0+r2]
movu m1, [r4+r2+8]
paddw m0, m2, [r0+r2+8]
paddw m1, [r4+r2]
mova m3, [r3+r2]
psubw m1, m0
psubw m3, m2
mova [r0+r2], m1
mova [r1+r2], m3
add r2, 32
jl .loop
RET
%macro FILT8x4 7
mova %3, [r0+%7]
mova %4, [r0+r5+%7]
pavgb %3, %4
pavgb %4, [r0+r5*2+%7]
PALIGNR %1, %3, 1, m6
PALIGNR %2, %4, 1, m6
%if cpuflag(xop)
pavgb %1, %3
pavgb %2, %4
%else
pavgb %1, %3
pavgb %2, %4
psrlw %5, %1, 8
psrlw %6, %2, 8
pand %1, m7
pand %2, m7
%endif
%endmacro
%macro FILT32x4U 4
mova m1, [r0+r5]
pavgb m0, m1, [r0]
movu m3, [r0+r5+1]
pavgb m2, m3, [r0+1]
pavgb m1, [r0+r5*2]
pavgb m3, [r0+r5*2+1]
pavgb m0, m2
pavgb m1, m3
mova m3, [r0+r5+mmsize]
pavgb m2, m3, [r0+mmsize]
movu m5, [r0+r5+1+mmsize]
pavgb m4, m5, [r0+1+mmsize]
pavgb m3, [r0+r5*2+mmsize]
pavgb m5, [r0+r5*2+1+mmsize]
pavgb m2, m4
pavgb m3, m5
pshufb m0, m7
pshufb m1, m7
pshufb m2, m7
pshufb m3, m7
punpckhqdq m4, m0, m2
punpcklqdq m0, m0, m2
punpckhqdq m5, m1, m3
punpcklqdq m2, m1, m3
vpermq m0, m0, q3120
vpermq m1, m4, q3120
vpermq m2, m2, q3120
vpermq m3, m5, q3120
mova [%1], m0
mova [%2], m1
mova [%3], m2
mova [%4], m3
%endmacro
%macro FILT16x2 4
mova m3, [r0+%4+mmsize]
mova m2, [r0+%4]
pavgb m3, [r0+%4+r5+mmsize]
pavgb m2, [r0+%4+r5]
PALIGNR %1, m3, 1, m6
pavgb %1, m3
PALIGNR m3, m2, 1, m6
pavgb m3, m2
%if cpuflag(xop)
vpperm m5, m3, %1, m7
vpperm m3, m3, %1, m6
%else
psrlw m5, m3, 8
psrlw m4, %1, 8
pand m3, m7
pand %1, m7
packuswb m3, %1
packuswb m5, m4
%endif
mova [%2], m3
mova [%3], m5
mova %1, m2
%endmacro
%macro FILT8x2U 3
mova m3, [r0+%3+8]
mova m2, [r0+%3]
pavgb m3, [r0+%3+r5+8]
pavgb m2, [r0+%3+r5]
mova m1, [r0+%3+9]
mova m0, [r0+%3+1]
pavgb m1, [r0+%3+r5+9]
pavgb m0, [r0+%3+r5+1]
pavgb m1, m3
pavgb m0, m2
psrlw m3, m1, 8
psrlw m2, m0, 8
pand m1, m7
pand m0, m7
packuswb m0, m1
packuswb m2, m3
mova [%1], m0
mova [%2], m2
%endmacro
%macro FILT8xU 3
mova m3, [r0+%3+8]
mova m2, [r0+%3]
pavgw m3, [r0+%3+r5+8]
pavgw m2, [r0+%3+r5]
movu m1, [r0+%3+10]
movu m0, [r0+%3+2]
pavgw m1, [r0+%3+r5+10]
pavgw m0, [r0+%3+r5+2]
pavgw m1, m3
pavgw m0, m2
psrld m3, m1, 16
psrld m2, m0, 16
pand m1, m7
pand m0, m7
packssdw m0, m1
packssdw m2, m3
movu [%1], m0
mova [%2], m2
%endmacro
%macro FILT8xA 4
mova m3, [r0+%4+mmsize]
mova m2, [r0+%4]
pavgw m3, [r0+%4+r5+mmsize]
pavgw m2, [r0+%4+r5]
PALIGNR %1, m3, 2, m6
pavgw %1, m3
PALIGNR m3, m2, 2, m6
pavgw m3, m2
%if cpuflag(xop)
vpperm m5, m3, %1, m7
vpperm m3, m3, %1, m6
%else
psrld m5, m3, 16
psrld m4, %1, 16
pand m3, m7
pand %1, m7
packssdw m3, %1
packssdw m5, m4
%endif
mova [%2], m3
mova [%3], m5
mova %1, m2
%endmacro
;-----------------------------------------------------------------------------
; void frame_init_lowres_core( uint8_t *src0, uint8_t *dst0, uint8_t *dsth, uint8_t *dstv, uint8_t *dstc,
; intptr_t src_stride, intptr_t dst_stride, int width, int height )
;-----------------------------------------------------------------------------
%macro FRAME_INIT_LOWRES 0
cglobal frame_init_lowres_core, 6,7,(12-4*(BIT_DEPTH/9)) ; 8 for HIGH_BIT_DEPTH, 12 otherwise
%if HIGH_BIT_DEPTH
shl dword r6m, 1
FIX_STRIDES r5
shl dword r7m, 1
%endif
%if mmsize >= 16
add dword r7m, mmsize-1
and dword r7m, ~(mmsize-1)
%endif
; src += 2*(height-1)*stride + 2*width
mov r6d, r8m
dec r6d
imul r6d, r5d
add r6d, r7m
lea r0, [r0+r6*2]
; dst += (height-1)*stride + width
mov r6d, r8m
dec r6d
imul r6d, r6m
add r6d, r7m
add r1, r6
add r2, r6
add r3, r6
add r4, r6
; gap = stride - width
mov r6d, r6m
sub r6d, r7m
PUSH r6
%define dst_gap [rsp+gprsize]
mov r6d, r5d
sub r6d, r7m
shl r6d, 1
PUSH r6
%define src_gap [rsp]
%if HIGH_BIT_DEPTH
%if cpuflag(xop)
mova m6, [deinterleave_shuf32a]
mova m7, [deinterleave_shuf32b]
%else
pcmpeqw m7, m7
psrld m7, 16
%endif
.vloop:
mov r6d, r7m
%ifnidn cpuname, mmx2
mova m0, [r0]
mova m1, [r0+r5]
pavgw m0, m1
pavgw m1, [r0+r5*2]
%endif
.hloop:
sub r0, mmsize*2
sub r1, mmsize
sub r2, mmsize
sub r3, mmsize
sub r4, mmsize
%ifidn cpuname, mmx2
FILT8xU r1, r2, 0
FILT8xU r3, r4, r5
%else
FILT8xA m0, r1, r2, 0
FILT8xA m1, r3, r4, r5
%endif
sub r6d, mmsize
jg .hloop
%else ; !HIGH_BIT_DEPTH
%if cpuflag(avx2)
vbroadcasti128 m7, [deinterleave_shuf]
%elif cpuflag(xop)
mova m6, [deinterleave_shuf32a]
mova m7, [deinterleave_shuf32b]
%else
pcmpeqb m7, m7
psrlw m7, 8
%endif
.vloop:
mov r6d, r7m
%ifnidn cpuname, mmx2
%if mmsize <= 16
mova m0, [r0]
mova m1, [r0+r5]
pavgb m0, m1
pavgb m1, [r0+r5*2]
%endif
%endif
.hloop:
sub r0, mmsize*2
sub r1, mmsize
sub r2, mmsize
sub r3, mmsize
sub r4, mmsize
%if mmsize==32
FILT32x4U r1, r2, r3, r4
%elifdef m8
FILT8x4 m0, m1, m2, m3, m10, m11, mmsize
mova m8, m0
mova m9, m1
FILT8x4 m2, m3, m0, m1, m4, m5, 0
%if cpuflag(xop)
vpperm m4, m2, m8, m7
vpperm m2, m2, m8, m6
vpperm m5, m3, m9, m7
vpperm m3, m3, m9, m6
%else
packuswb m2, m8
packuswb m3, m9
packuswb m4, m10
packuswb m5, m11
%endif
mova [r1], m2
mova [r2], m4
mova [r3], m3
mova [r4], m5
%elifidn cpuname, mmx2
FILT8x2U r1, r2, 0
FILT8x2U r3, r4, r5
%else
FILT16x2 m0, r1, r2, 0
FILT16x2 m1, r3, r4, r5
%endif
sub r6d, mmsize
jg .hloop
%endif ; HIGH_BIT_DEPTH
.skip:
mov r6, dst_gap
sub r0, src_gap
sub r1, r6
sub r2, r6
sub r3, r6
sub r4, r6
dec dword r8m
jg .vloop
ADD rsp, 2*gprsize
emms
RET
%endmacro ; FRAME_INIT_LOWRES
INIT_MMX mmx2
FRAME_INIT_LOWRES
%if ARCH_X86_64 == 0
INIT_MMX cache32, mmx2
FRAME_INIT_LOWRES
%endif
INIT_XMM sse2
FRAME_INIT_LOWRES
INIT_XMM ssse3
FRAME_INIT_LOWRES
INIT_XMM avx
FRAME_INIT_LOWRES
INIT_XMM xop
FRAME_INIT_LOWRES
%if HIGH_BIT_DEPTH==0
INIT_YMM avx2
FRAME_INIT_LOWRES
%endif
;-----------------------------------------------------------------------------
; void mbtree_propagate_cost( int *dst, uint16_t *propagate_in, uint16_t *intra_costs,
; uint16_t *inter_costs, uint16_t *inv_qscales, float *fps_factor, int len )
;-----------------------------------------------------------------------------
%macro MBTREE 0
cglobal mbtree_propagate_cost, 6,6,7
movss m6, [r5]
mov r5d, r6m
lea r0, [r0+r5*2]
add r5d, r5d
add r1, r5
add r2, r5
add r3, r5
add r4, r5
neg r5
pxor m4, m4
shufps m6, m6, 0
mova m5, [pw_3fff]
.loop:
movq m2, [r2+r5] ; intra
movq m0, [r4+r5] ; invq
movq m3, [r3+r5] ; inter
movq m1, [r1+r5] ; prop
pand m3, m5
pminsw m3, m2
punpcklwd m2, m4
punpcklwd m0, m4
pmaddwd m0, m2
punpcklwd m1, m4
punpcklwd m3, m4
%if cpuflag(fma4)
cvtdq2ps m0, m0
cvtdq2ps m1, m1
fmaddps m0, m0, m6, m1
cvtdq2ps m1, m2
psubd m2, m3
cvtdq2ps m2, m2
rcpps m3, m1
mulps m1, m3
mulps m0, m2
addps m2, m3, m3
fnmaddps m3, m1, m3, m2
mulps m0, m3
%else
cvtdq2ps m0, m0
mulps m0, m6 ; intra*invq*fps_factor>>8
cvtdq2ps m1, m1 ; prop
addps m0, m1 ; prop + (intra*invq*fps_factor>>8)
cvtdq2ps m1, m2 ; intra
psubd m2, m3 ; intra - inter
cvtdq2ps m2, m2 ; intra - inter
rcpps m3, m1 ; 1 / intra 1st approximation
mulps m1, m3 ; intra * (1/intra 1st approx)
mulps m1, m3 ; intra * (1/intra 1st approx)^2
mulps m0, m2 ; (prop + (intra*invq*fps_factor>>8)) * (intra - inter)
addps m3, m3 ; 2 * (1/intra 1st approx)
subps m3, m1 ; 2nd approximation for 1/intra
mulps m0, m3 ; / intra
%endif
cvtps2dq m0, m0
packssdw m0, m0
movh [r0+r5], m0
add r5, 8
jl .loop
RET
%endmacro
INIT_XMM sse2
MBTREE
; Bulldozer only has a 128-bit float unit, so the AVX version of this function is actually slower.
INIT_XMM fma4
MBTREE
%macro INT16_UNPACK 1
punpckhwd xm6, xm%1, xm7
punpcklwd xm%1, xm7
vinsertf128 m%1, m%1, xm6, 1
%endmacro
; FIXME: align loads to 16 bytes
%macro MBTREE_AVX 0
cglobal mbtree_propagate_cost, 6,6,8-2*cpuflag(avx2)
vbroadcastss m5, [r5]
mov r5d, r6m
lea r2, [r2+r5*2]
add r5d, r5d
add r4, r5
neg r5
sub r1, r5
sub r3, r5
sub r0, r5
mova xm4, [pw_3fff]
%if notcpuflag(avx2)
pxor xm7, xm7
%endif
.loop:
%if cpuflag(avx2)
pmovzxwd m0, [r2+r5] ; intra
pmovzxwd m1, [r4+r5] ; invq
pmovzxwd m2, [r1+r5] ; prop
pand xm3, xm4, [r3+r5] ; inter
pmovzxwd m3, xm3
pmaddwd m1, m0
psubusw m3, m0, m3
cvtdq2ps m0, m0
cvtdq2ps m1, m1
cvtdq2ps m2, m2
cvtdq2ps m3, m3
fmaddps m1, m1, m5, m2
rcpps m2, m0
mulps m0, m2
mulps m1, m3
addps m3, m2, m2
fnmaddps m2, m2, m0, m3
mulps m1, m2
%else
movu xm0, [r2+r5]
movu xm1, [r4+r5]
movu xm2, [r1+r5]
pand xm3, xm4, [r3+r5]
psubusw xm3, xm0, xm3
INT16_UNPACK 0
INT16_UNPACK 1
INT16_UNPACK 2
INT16_UNPACK 3
cvtdq2ps m0, m0
cvtdq2ps m1, m1
cvtdq2ps m2, m2
cvtdq2ps m3, m3
mulps m1, m0
mulps m1, m5 ; intra*invq*fps_factor>>8
addps m1, m2 ; prop + (intra*invq*fps_factor>>8)
rcpps m2, m0 ; 1 / intra 1st approximation
mulps m0, m2 ; intra * (1/intra 1st approx)
mulps m0, m2 ; intra * (1/intra 1st approx)^2
mulps m1, m3 ; (prop + (intra*invq*fps_factor>>8)) * (intra - inter)
addps m2, m2 ; 2 * (1/intra 1st approx)
subps m2, m0 ; 2nd approximation for 1/intra
mulps m1, m2 ; / intra
%endif
cvtps2dq m1, m1
vextractf128 xm2, m1, 1
packssdw xm1, xm2
mova [r0+r5], xm1
add r5, 16
jl .loop
RET
%endmacro
INIT_YMM avx
MBTREE_AVX
INIT_YMM avx2
MBTREE_AVX
INIT_ZMM avx512
cglobal mbtree_propagate_cost, 6,6
vbroadcastss m5, [r5]
mov r5d, 0x3fff3fff
vpbroadcastd ym4, r5d
mov r5d, r6m
lea r2, [r2+r5*2]
add r5d, r5d
add r1, r5
neg r5
sub r4, r5
sub r3, r5
sub r0, r5
.loop:
pmovzxwd m0, [r2+r5] ; intra
pmovzxwd m1, [r1+r5] ; prop
pmovzxwd m2, [r4+r5] ; invq
pand ym3, ym4, [r3+r5] ; inter
pmovzxwd m3, ym3
psubusw m3, m0, m3
cvtdq2ps m0, m0
cvtdq2ps m1, m1
cvtdq2ps m2, m2
cvtdq2ps m3, m3
vdivps m1, m0, {rn-sae}
fmaddps m1, m2, m5, m1
mulps m1, m3
cvtps2dq m1, m1
vpmovsdw [r0+r5], m1
add r5, 32
jl .loop
RET
%macro MBTREE_PROPAGATE_LIST 0
;-----------------------------------------------------------------------------
; void mbtree_propagate_list_internal( int16_t (*mvs)[2], int16_t *propagate_amount, uint16_t *lowres_costs,
; int16_t *output, int bipred_weight, int mb_y, int len )
;-----------------------------------------------------------------------------
cglobal mbtree_propagate_list_internal, 4,6,8
movh m6, [pw_0to15] ; mb_x
movd m7, r5m
pshuflw m7, m7, 0
punpcklwd m6, m7 ; 0 y 1 y 2 y 3 y
movd m7, r4m
SPLATW m7, m7 ; bipred_weight
psllw m7, 9 ; bipred_weight << 9
mov r5d, r6m
xor r4d, r4d
.loop:
mova m3, [r1+r4*2]
movu m4, [r2+r4*2]
mova m5, [pw_0xc000]
pand m4, m5
pcmpeqw m4, m5
pmulhrsw m5, m3, m7 ; propagate_amount = (propagate_amount * bipred_weight + 32) >> 6
%if cpuflag(avx)
pblendvb m5, m3, m5, m4
%else
pand m5, m4
pandn m4, m3
por m5, m4 ; if( lists_used == 3 )
; propagate_amount = (propagate_amount * bipred_weight + 32) >> 6
%endif
movu m0, [r0+r4*4] ; x,y
movu m1, [r0+r4*4+mmsize]
psraw m2, m0, 5
psraw m3, m1, 5
mova m4, [pd_4]
paddw m2, m6 ; {mbx, mby} = ({x,y}>>5)+{h->mb.i_mb_x,h->mb.i_mb_y}
paddw m6, m4 ; {mbx, mby} += {4, 0}
paddw m3, m6 ; {mbx, mby} = ({x,y}>>5)+{h->mb.i_mb_x,h->mb.i_mb_y}
paddw m6, m4 ; {mbx, mby} += {4, 0}
mova [r3+mmsize*0], m2
mova [r3+mmsize*1], m3
mova m3, [pw_31]
pand m0, m3 ; x &= 31
pand m1, m3 ; y &= 31
packuswb m0, m1
psrlw m1, m0, 3
pand m0, m3 ; x
SWAP 1, 3
pandn m1, m3 ; y premultiplied by (1<<5) for later use of pmulhrsw
mova m3, [pw_32]
psubw m3, m0 ; 32 - x
mova m4, [pw_1024]
psubw m4, m1 ; (32 - y) << 5
pmullw m2, m3, m4 ; idx0weight = (32-y)*(32-x) << 5
pmullw m4, m0 ; idx1weight = (32-y)*x << 5
pmullw m0, m1 ; idx3weight = y*x << 5
pmullw m1, m3 ; idx2weight = y*(32-x) << 5
; avoid overflow in the input to pmulhrsw
psrlw m3, m2, 15
psubw m2, m3 ; idx0weight -= (idx0weight == 32768)
pmulhrsw m2, m5 ; idx0weight * propagate_amount + 512 >> 10
pmulhrsw m4, m5 ; idx1weight * propagate_amount + 512 >> 10
pmulhrsw m1, m5 ; idx2weight * propagate_amount + 512 >> 10
pmulhrsw m0, m5 ; idx3weight * propagate_amount + 512 >> 10
SBUTTERFLY wd, 2, 4, 3
SBUTTERFLY wd, 1, 0, 3
mova [r3+mmsize*2], m2
mova [r3+mmsize*3], m4
mova [r3+mmsize*4], m1
mova [r3+mmsize*5], m0
add r4d, mmsize/2
add r3, mmsize*6
cmp r4d, r5d
jl .loop
REP_RET
%endmacro
INIT_XMM ssse3
MBTREE_PROPAGATE_LIST
INIT_XMM avx
MBTREE_PROPAGATE_LIST
INIT_YMM avx2
cglobal mbtree_propagate_list_internal, 4+2*UNIX64,5+UNIX64,8
mova xm4, [pw_0xc000]
%if UNIX64
shl r4d, 9
shl r5d, 16
movd xm5, r4d
movd xm6, r5d
vpbroadcastw xm5, xm5
vpbroadcastd m6, xm6
%else
vpbroadcastw xm5, r4m
vpbroadcastd m6, r5m
psllw xm5, 9 ; bipred_weight << 9
pslld m6, 16
%endif
mov r4d, r6m
lea r1, [r1+r4*2]
lea r2, [r2+r4*2]
lea r0, [r0+r4*4]
neg r4
por m6, [pd_0123] ; 0 y 1 y 2 y 3 y 4 y 5 y 6 y 7 y
vbroadcasti128 m7, [pw_31]
.loop:
mova xm3, [r1+r4*2]
pand xm0, xm4, [r2+r4*2]
pmulhrsw xm1, xm3, xm5 ; bipred_amount = (propagate_amount * bipred_weight + 32) >> 6
pcmpeqw xm0, xm4
pblendvb xm3, xm3, xm1, xm0 ; (lists_used == 3) ? bipred_amount : propagate_amount
vpermq m3, m3, q1100
movu m0, [r0+r4*4] ; {x, y}
vbroadcasti128 m1, [pd_8]
psraw m2, m0, 5
paddw m2, m6 ; {mbx, mby} = ({x, y} >> 5) + {h->mb.i_mb_x, h->mb.i_mb_y}
paddw m6, m1 ; i_mb_x += 8
mova [r3], m2
mova m1, [pw_32]
pand m0, m7
psubw m1, m0
packuswb m1, m0 ; {32-x, 32-y} {x, y} {32-x, 32-y} {x, y}
psrlw m0, m1, 3
pand m1, [pw_00ff] ; 32-x x 32-x x
pandn m0, m7, m0 ; (32-y y 32-y y) << 5
pshufd m2, m1, q1032
pmullw m1, m0 ; idx0 idx3 idx0 idx3
pmullw m2, m0 ; idx1 idx2 idx1 idx2
pmulhrsw m0, m1, m3 ; (idx0 idx3 idx0 idx3) * propagate_amount + 512 >> 10
pmulhrsw m2, m3 ; (idx1 idx2 idx1 idx2) * propagate_amount + 512 >> 10
psignw m0, m1 ; correct potential overflow in the idx0 input to pmulhrsw
punpcklwd m1, m0, m2 ; idx01weight
punpckhwd m2, m0 ; idx23weight
mova [r3+32], m1
mova [r3+64], m2
add r3, 3*mmsize
add r4, 8
jl .loop
RET
%if ARCH_X86_64
;-----------------------------------------------------------------------------
; void x264_mbtree_propagate_list_internal_avx512( size_t len, uint16_t *ref_costs, int16_t (*mvs)[2], int16_t *propagate_amount,
; uint16_t *lowres_costs, int bipred_weight, int mb_y,
; int width, int height, int stride, int list_mask );
;-----------------------------------------------------------------------------
INIT_ZMM avx512
cglobal mbtree_propagate_list_internal, 5,7,21
mova xm16, [pw_0xc000]
vpbroadcastw xm17, r5m ; bipred_weight << 9
vpbroadcastw ym18, r10m ; 1 << (list+LOWRES_COST_SHIFT)
vbroadcasti32x8 m5, [mbtree_prop_list_avx512_shuf]
vbroadcasti32x8 m6, [pd_0123]
vpord m6, r6m {1to16} ; 0 y 1 y 2 y 3 y 4 y 5 y 6 y 7 y
vbroadcasti128 m7, [pd_8]
vbroadcasti128 m8, [pw_31]
vbroadcasti128 m9, [pw_32]
psllw m10, m9, 4
pcmpeqw ym19, ym19 ; pw_m1
vpbroadcastw ym20, r7m ; width
psrld m11, m7, 3 ; pd_1
psrld m12, m8, 16 ; pd_31
vpbroadcastd m13, r8m ; height
vpbroadcastd m14, r9m ; stride
pslld m15, m14, 16
por m15, m11 ; {1, stride, 1, stride} ...
lea r4, [r4+2*r0] ; lowres_costs
lea r3, [r3+2*r0] ; propagate_amount
lea r2, [r2+4*r0] ; mvs
neg r0
mov r6d, 0x5555ffff
kmovd k4, r6d
kshiftrd k5, k4, 16 ; 0x5555
kshiftlw k6, k4, 8 ; 0xff00
.loop:
vbroadcasti128 ym1, [r4+2*r0]
mova xm4, [r3+2*r0]
vpcmpuw k1, xm1, xm16, 5 ; if (lists_used == 3)
vpmulhrsw xm4 {k1}, xm17 ; propagate_amount = (propagate_amount * bipred_weight + 32) >> 6
vptestmw k1, ym1, ym18
vpermw m4, m5, m4
vbroadcasti32x8 m3, [r2+4*r0] ; {mvx, mvy}
psraw m0, m3, 5
paddw m0, m6 ; {mbx, mby} = ({x, y} >> 5) + {h->mb.i_mb_x, h->mb.i_mb_y}
paddd m6, m7 ; i_mb_x += 8
pand m3, m8 ; {x, y}
vprold m1, m3, 20 ; {y, x} << 4
vpsubw m3 {k4}, m9, m3 ; {32-x, 32-y}, {32-x, y}
vpsubw m1 {k5}, m10, m1 ; ({32-y, x}, {y, x}) << 4
pmullw m3, m1
paddsw m3, m3 ; prevent signed overflow in idx0 (32*32<<5 == 0x8000)
pmulhrsw m2, m3, m4 ; idx01weight idx23weightp
pslld ym1, ym0, 16
psubw ym1, ym19
vmovdqu16 ym1 {k5}, ym0
vpcmpuw k2, ym1, ym20, 1 ; {mbx, mbx+1} < width
kunpckwd k2, k2, k2
psrad m1, m0, 16
vpaddd m1 {k6}, m11
vpcmpud k1 {k1}, m1, m13, 1 ; mby < height | mby+1 < height
pmaddwd m0, m15
vpaddd m0 {k6}, m14 ; idx0 | idx2
vmovdqu16 m2 {k2}{z}, m2 ; idx01weight | idx23weight
vptestmd k1 {k1}, m2, m2 ; mask out offsets with no changes
; We're handling dwords, but the offsets are in words so there may be partial overlaps.
; We can work around this by handling dword-aligned and -unaligned offsets separately.
vptestmd k0, m0, m11
kandnw k2, k0, k1 ; dword-aligned offsets
kmovw k3, k2
vpgatherdd m3 {k2}, [r1+2*m0]
; If there are conflicts in the offsets we have to handle them before storing the results.
; By creating a permutation index using vplzcntd we can resolve all conflicts in parallel
; in ceil(log2(n)) iterations where n is the largest number of duplicate offsets.
vpconflictd m4, m0
vpbroadcastmw2d m1, k1
vptestmd k2, m1, m4
ktestw k2, k2
jz .no_conflicts
pand m1, m4 ; mask away unused offsets to avoid false positives
vplzcntd m1, m1
pxor m1, m12 ; lzcnt gives us the distance from the msb, we want it from the lsb
.conflict_loop:
vpermd m4 {k2}{z}, m1, m2
vpermd m1 {k2}, m1, m1 ; shift the index one step forward
paddsw m2, m4 ; add the weights of conflicting offsets
vpcmpd k2, m1, m12, 2
ktestw k2, k2
jnz .conflict_loop
.no_conflicts:
paddsw m3, m2
vpscatterdd [r1+2*m0] {k3}, m3
kandw k1, k0, k1 ; dword-unaligned offsets
kmovw k2, k1
vpgatherdd m1 {k1}, [r1+2*m0]
paddsw m1, m2 ; all conflicts have already been resolved
vpscatterdd [r1+2*m0] {k2}, m1
add r0, 8
jl .loop
RET
%endif
%macro MBTREE_FIX8 0
;-----------------------------------------------------------------------------
; void mbtree_fix8_pack( uint16_t *dst, float *src, int count )
;-----------------------------------------------------------------------------
cglobal mbtree_fix8_pack, 3,4
%if mmsize == 32
vbroadcastf128 m2, [pf_256]
vbroadcasti128 m3, [mbtree_fix8_pack_shuf]
%else
movaps m2, [pf_256]
mova m3, [mbtree_fix8_pack_shuf]
%endif
sub r2d, mmsize/2
movsxdifnidn r2, r2d
lea r1, [r1+4*r2]
lea r0, [r0+2*r2]
neg r2
jg .skip_loop
.loop:
mulps m0, m2, [r1+4*r2]
mulps m1, m2, [r1+4*r2+mmsize]
cvttps2dq m0, m0
cvttps2dq m1, m1
packssdw m0, m1
pshufb m0, m3
%if mmsize == 32
vpermq m0, m0, q3120
%endif
mova [r0+2*r2], m0
add r2, mmsize/2
jle .loop
.skip_loop:
sub r2, mmsize/2
jz .end
; Do the remaining values in scalar in order to avoid overreading src.
.scalar:
mulss xm0, xm2, [r1+4*r2+2*mmsize]
cvttss2si r3d, xm0
rol r3w, 8
mov [r0+2*r2+mmsize], r3w
inc r2
jl .scalar
.end:
RET
;-----------------------------------------------------------------------------
; void mbtree_fix8_unpack( float *dst, uint16_t *src, int count )
;-----------------------------------------------------------------------------
cglobal mbtree_fix8_unpack, 3,4
%if mmsize == 32
vbroadcastf128 m2, [pf_inv16777216]
%else
movaps m2, [pf_inv16777216]
mova m4, [mbtree_fix8_unpack_shuf+16]
%endif
mova m3, [mbtree_fix8_unpack_shuf]
sub r2d, mmsize/2
movsxdifnidn r2, r2d
lea r1, [r1+2*r2]
lea r0, [r0+4*r2]
neg r2
jg .skip_loop
.loop:
%if mmsize == 32
vbroadcasti128 m0, [r1+2*r2]
vbroadcasti128 m1, [r1+2*r2+16]
pshufb m0, m3
pshufb m1, m3
%else
mova m1, [r1+2*r2]
pshufb m0, m1, m3
pshufb m1, m4
%endif
cvtdq2ps m0, m0
cvtdq2ps m1, m1
mulps m0, m2
mulps m1, m2
movaps [r0+4*r2], m0
movaps [r0+4*r2+mmsize], m1
add r2, mmsize/2
jle .loop
.skip_loop:
sub r2, mmsize/2
jz .end
.scalar:
movzx r3d, word [r1+2*r2+mmsize]
bswap r3d
; Use 3-arg cvtsi2ss as a workaround for the fact that the instruction has a stupid dependency on
; dst which causes terrible performance when used in a loop otherwise. Blame Intel for poor design.
cvtsi2ss xm0, xm2, r3d
mulss xm0, xm2
movss [r0+4*r2+2*mmsize], xm0
inc r2
jl .scalar
.end:
RET
%endmacro
INIT_XMM ssse3
MBTREE_FIX8
INIT_YMM avx2
MBTREE_FIX8
%macro MBTREE_FIX8_AVX512_END 0
add r2, mmsize/2
jle .loop
cmp r2d, mmsize/2
jl .tail
RET
.tail:
; Do the final loop iteration with partial masking to handle the remaining elements.
shrx r3d, r3d, r2d ; (1 << count) - 1
kmovd k1, r3d
kshiftrd k2, k1, 16
jmp .loop
%endmacro
INIT_ZMM avx512
cglobal mbtree_fix8_pack, 3,4
vbroadcastf32x4 m2, [pf_256]
vbroadcasti32x4 m3, [mbtree_fix8_pack_shuf]
psrld xm4, xm3, 4
pmovzxbq m4, xm4
sub r2d, mmsize/2
mov r3d, -1
movsxdifnidn r2, r2d
lea r1, [r1+4*r2]
lea r0, [r0+2*r2]
neg r2
jg .tail
kmovd k1, r3d
kmovw k2, k1
.loop:
vmulps m0 {k1}{z}, m2, [r1+4*r2]
vmulps m1 {k2}{z}, m2, [r1+4*r2+mmsize]
cvttps2dq m0, m0
cvttps2dq m1, m1
packssdw m0, m1
pshufb m0, m3
vpermq m0, m4, m0
vmovdqu16 [r0+2*r2] {k1}, m0
MBTREE_FIX8_AVX512_END
cglobal mbtree_fix8_unpack, 3,4
vbroadcasti32x8 m3, [mbtree_fix8_unpack_shuf]
vbroadcastf32x4 m2, [pf_inv16777216]
sub r2d, mmsize/2
mov r3d, -1
movsxdifnidn r2, r2d
lea r1, [r1+2*r2]
lea r0, [r0+4*r2]
neg r2
jg .tail
kmovw k1, r3d
kmovw k2, k1
.loop:
mova m1, [r1+2*r2]
vshufi32x4 m0, m1, m1, q1100
vshufi32x4 m1, m1, m1, q3322
pshufb m0, m3
pshufb m1, m3
cvtdq2ps m0, m0
cvtdq2ps m1, m1
mulps m0, m2
mulps m1, m2
vmovaps [r0+4*r2] {k1}, m0
vmovaps [r0+4*r2+mmsize] {k2}, m1
MBTREE_FIX8_AVX512_END
|
lbi r0, 27
addi r1, r0, 1
addi r2, r1, 2
addi r1, r2, 3
addi r4, r1, 4
addi r1, r4, 5
addi r6, r1, 6
addi r1, r6, 7
halt
|
; A062776: Greatest common divisor of (n+2)! and n^n.
; Submitted by Jon Maiga
; 1,4,3,16,5,576,7,256,81,25600,11,497664,13,802816,91125,65536,17,1719926784,19,327680000,6751269,507510784,23,495338913792,15625,5670699008,1594323,161128382464,29,401224520171520000000,31,4294967296,19098395217,4964982194176,6565234375,4437222213480873984,37,99230924406784,851162814333,1073741824000000000,41,300692019567635333765922816,43,64391798969073664,102151886748046875,37225065669984256,47,4416491511299491340746752,5764801,137438953472000000000000,462525437577051,32156827239332184064,53
mov $1,$0
add $0,3
seq $0,142 ; Factorial numbers: n! = 1*2*3*4*...*n (order of symmetric group S_n, number of permutations of n letters).
add $1,1
pow $1,$1
gcd $1,$0
mov $0,$1
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.