text stringlengths 1 1.05M |
|---|
MOV XL, 11111110b
MOV XH, 0x00
MOV J, X
; Initialize the D and E register
MOV E, [J]
MOV D, 00000001b
; Add both values
ADD E, D
DATA 0000000011111110b, 00000001b |
//
// Boost.Process
// ~~~~~~~~~~~~~
//
// Copyright (c) 2006, 2007 Julio M. Merino Vidal
// Copyright (c) 2008 Boris Schaeling
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
#include <boost/process.hpp>
#include <string>
#include <vector>
namespace bp = ::boost::process;
bp::child start_child()
{
std::string exec = "bjam";
std::vector<std::string> args;
args.push_back("bjam");
args.push_back("--version");
bp::context ctx;
ctx.stdout_behavior = bp::silence_stream();
return bp::launch(exec, args, ctx);
}
int main()
{
bp::child c = start_child();
bp::status s = c.wait();
return s.exited() ? s.exit_status() : EXIT_FAILURE;
}
|
; A135247: a(n) = 3*a(n-1) + 2*a(n-2) - 6*a(n-3).
; Submitted by Jon Maiga
; 0,0,1,3,11,33,103,309,935,2805,8431,25293,75911,227733,683263,2049789,6149495,18448485,55345711,166037133,498111911,1494335733,4483008223,13449024669,40347076055,121041228165,363123688591,1089371065773,3268113205511,9804339616533,29413018865983,88239056597949,264717169826615,794151509479845,2382454528505071,7147363585515213,21442090756676711,64326272270030133,192978816810352543,578936450431057629,1736809351293697175,5210428053881091525,15631284161644323151,46893852484932969453
mov $5,$0
mov $7,2
lpb $7
mov $0,$5
mov $1,0
mov $3,0
mov $4,0
sub $7,1
add $0,$7
mov $2,4
lpb $0
sub $0,1
trn $1,4
add $3,$2
mov $2,$1
add $1,$4
mul $2,3
add $3,$4
add $4,$1
mov $1,$3
add $2,1
lpe
mov $0,$4
mov $8,$7
mul $8,$4
add $6,$8
lpe
min $5,1
mul $5,$0
mov $0,$6
sub $0,$5
|
SECTION code_fp_math16
PUBLIC cm16_sdcc_ceil
EXTERN cm16_sdcc_read1
EXTERN asm_f16_ceil
.cm16_sdcc_ceil
call cm16_sdcc_read1
jp asm_f16_ceil
|
#include "TextureLoader.h"
#include <iostream>
#include "./stb_image.h"
namespace TEngine
{
// We must define the static variables outside the class first to get memory
std::unordered_map<std::string, Texture*> TextureLoader::mTextureCache;
Texture* TextureLoader::sDefaultAlbedo = nullptr;
Texture* TextureLoader::sDefaultNormal = nullptr;
Texture* TextureLoader::sWhiteTexture = nullptr;
Texture* TextureLoader::sBlackTexture = nullptr;
void TextureLoader::InitDefaultTextures()
{
// Setup texture and minimal filtering because they are 1x1 textures so they require none
TextureSettings srgbTextureSettings, formalTextureSettings;
srgbTextureSettings.IsSRGB = true;
srgbTextureSettings.TextureMinificationFilterMode = GL_NEAREST;
srgbTextureSettings.TextureMagnificationFilterMode = GL_NEAREST;
srgbTextureSettings.HasMips = false;
formalTextureSettings.IsSRGB = false;
formalTextureSettings.TextureMinificationFilterMode = GL_NEAREST;
formalTextureSettings.TextureMagnificationFilterMode = GL_NEAREST;
formalTextureSettings.HasMips = false;
sDefaultAlbedo = Load2DTexture(std::string("res/texture/defaultAlbedo.png"), &srgbTextureSettings);
sDefaultNormal = Load2DTexture(std::string("res/texture/defaultNormal.png"), &formalTextureSettings);
sWhiteTexture = Load2DTexture(std::string("res/texture/white.png"), &formalTextureSettings);
sBlackTexture = Load2DTexture(std::string("res/texture/black.png"), &formalTextureSettings);
}
Texture* TextureLoader::Load2DTexture(const std::string& path, TextureSettings* settings)
{
// check the cache
auto iter = mTextureCache.find(path);
if (iter != mTextureCache.end())
return iter->second;
// load texture
int width, height, numComponents;
unsigned char* data = stbi_load(path.c_str(), &width, &height, &numComponents, 0);
if (!data)
{
std::cout << "TEXTURE LOAD FAIL - path:" << path << "\n";
stbi_image_free(data);
return nullptr;
}
GLenum dataFormat;
switch (numComponents)
{
case 1: dataFormat = GL_RED; break;
case 3: dataFormat = GL_RGB; break;
case 4: dataFormat = GL_RGBA; break;
}
// use the specified of default settings to initialize texture
Texture* texture = nullptr;
if (settings != nullptr)
texture = new Texture(*settings);
else
texture = new Texture();
texture->GetTextureSettings().ChannelNum = numComponents;
texture->Generate2DTexture(width, height, dataFormat, GL_UNSIGNED_BYTE, data);
mTextureCache.insert(std::pair<std::string, Texture*>(path, texture));
stbi_image_free(data);
std::cout << path << " load successfully!\n";
return mTextureCache[path];
}
Cubemap* TextureLoader::LoadCubemapTexture(const std::vector<std::string>& paths, CubemapSettings* settings)
{
// use the specified of default settings to initialize texture
Cubemap* cubemap = nullptr;
if (settings != nullptr)
cubemap = new Cubemap(*settings);
else
cubemap = new Cubemap();
int width, height, numComponents;
for (size_t i = 0; i < paths.size(); i++)
{
unsigned char* data = stbi_load(paths[i].c_str(), &width, &height, &numComponents, 0);
if (data)
{
GLenum dataFormat;
switch (numComponents)
{
case 1: dataFormat = GL_RED; break;
case 3: dataFormat = GL_RGB; break;
case 4: dataFormat = GL_RGBA; break;
}
std::cout << paths[i] << " load successfully!\n";
cubemap->GenerateCubemapFace(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, width, height, dataFormat, GL_UNSIGNED_BYTE, data);
stbi_image_free(data);
}
else
{
std::cout << "TEXTURE LOAD FAIL - path:" << paths[i] << "\n";
stbi_image_free(data);
return nullptr;
}
}
return cubemap;
}
void TextureLoader::DestroyCachedTexture()
{
for (auto& item : mTextureCache)
delete item.second;
}
} |
.include "myTiny13.h"
Main:
sbi DDRB, 0 ; PortB0 is output = OC0A
ldi A, 0b01000011 ; Fast PWM Mode 7 with a toggle on Compare for OC0A
out TCCR0A, A
ldi A, 0b00001101 ; timer: count on every 1024 clock-ticks
out TCCR0B, A ; toggle: only if wgm2 = 1
ldi A, 90
out OCR0A, A ; set Compare for Timer
MainLoop:
rjmp MainLoop
|
//
// Created by windyear_office on 18-1-30.
//
#include "DirectedDFS.h"
DirectedDFS::DirectedDFS(Digraph g, int s) {
//创建标记数组
marked = new bool[g.V()];
for(int i = 0; i < g.V(); i++){
marked[i] = false;
}
count = 0;
DFS(g, s);
}
DirectedDFS::DirectedDFS(Digraph g, vector<int> source){
marked = new bool[g.V()];
for(int i = 0; i < g.V(); i++){
marked[i] = false;
}
count = 0;
for(auto v: source){
if(!marked[v]){
DFS(g, v);
}
}
}
DirectedDFS::~DirectedDFS() {
delete[] marked;//删除动态创建的数组
}
int DirectedDFS::Count() {
return count;
}
bool DirectedDFS::Marked(int v) {
return marked[v];
}
void DirectedDFS::DFS(Digraph g, int s) {
//首先标记访问的节点为已经访问,然后遍历其相邻节点
//如果邻节点还没有被访问, 就递归访问其邻节点
marked[s] = true;
count++;
for(auto V: g.Adj(s)){
if(!Marked(V)){
DFS(g,V);
}
}
} |
; A267452: Total number of ON (black) cells after n iterations of the "Rule 131" elementary cellular automaton starting with a single ON (black) cell.
; Submitted by Christian Krause
; 1,2,4,6,10,13,19,24,30,37,46,53,63,73,84,95,108,120,135,149,164,180,198,214,233,252,272,292,314,335,359,382,406,431,458,483,511,539,568,597,628,658,691,723,756,790,826,860,897,934,972,1010,1050,1089,1131,1172,1214,1257,1302,1345,1391,1437,1484,1531,1580,1628,1679,1729,1780,1832,1886,1938,1993,2048,2104,2160,2218,2275,2335,2394,2454,2515,2578,2639,2703,2767,2832,2897,2964,3030,3099,3167,3236,3306,3378,3448,3521,3594,3668,3742
lpb $0
mov $2,$0
sub $0,1
seq $2,267451 ; Number of ON (black) cells in the n-th iteration of the "Rule 131" elementary cellular automaton starting with a single ON (black) cell.
add $1,$2
lpe
mov $0,$1
add $0,1
|
; A071716: Expansion of (1+x^2*C)*C, where C = (1-(1-4*x)^(1/2))/(2*x) is g.f. for Catalan numbers, A000108.
; 1,1,3,7,19,56,174,561,1859,6292,21658,75582,266798,950912,3417340,12369285,45052515,165002460,607283490,2244901890,8331383610,31030387440,115948830660,434542177290,1632963760974,6151850548776
lpb $0,1
pow $0,2
sub $0,1
lpe
cal $0,167422 ; Expansion of (1+x)*c(x), c(x) the g.f. of A000108.
mov $1,$0
|
; Uppercase a string.
;
; The program runs on CP/M but you need a debugger like DDT or SID to inspect the
; process and the machine state. From SID start the program with this command,
; which runs it until the breakpoint at address 'done':
;
; g,.done
lowera equ 61h ; ASCII lowercase a
lowerz equ 7ah ; ASCII lowercase z
offset equ 32 ; lowercase-uppercase offset
len equ 17 ; String length
org 100h
lxi h, string
mvi c, len
mvi d, lowera
mvi e, lowerz
loop: mvi a, 0
cmp c ; c == 0?
jz done ; Yes
mov a, d
mov b, m ; B holds current character in string
cmp b ; < a?
jnc skip ; Yes, skip to next character
mov a, e
cmp b ; > z?
jc skip ; Yes, skip to next character
mov a, b
sui offset ; Subtract offset to get uppercase
mov m, a
skip: inx h
dcr c
jmp loop
done: ret
string: db 'Mixed Case String'
end |
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "components/sync/driver/sync_service_crypto.h"
#include <utility>
#include "base/bind.h"
#include "base/callback_helpers.h"
#include "base/feature_list.h"
#include "base/metrics/histogram_macros.h"
#include "base/no_destructor.h"
#include "base/sequenced_task_runner.h"
#include "base/threading/sequenced_task_runner_handle.h"
#include "components/sync/base/passphrase_enums.h"
#include "components/sync/driver/sync_driver_switches.h"
#include "components/sync/driver/sync_service.h"
#include "components/sync/engine/nigori/nigori.h"
#include "components/sync/engine/sync_string_conversions.h"
namespace syncer {
namespace {
// Used for UMA.
enum class TrustedVaultFetchKeysAttemptForUMA {
kFirstAttempt,
kSecondAttempt,
kMaxValue = kSecondAttempt
};
// Used for the case where a null client is passed to SyncServiceCrypto.
class EmptyTrustedVaultClient : public TrustedVaultClient {
public:
EmptyTrustedVaultClient() = default;
~EmptyTrustedVaultClient() override = default;
// TrustedVaultClient implementation.
void AddObserver(Observer* observer) override {}
void RemoveObserver(Observer* observer) override {}
void FetchKeys(
const CoreAccountInfo& account_info,
base::OnceCallback<void(const std::vector<std::vector<uint8_t>>&)> cb)
override {
std::move(cb).Run({});
}
void StoreKeys(const std::string& gaia_id,
const std::vector<std::vector<uint8_t>>& keys,
int last_key_version) override {
// Never invoked by SyncServiceCrypto.
NOTREACHED();
}
void RemoveAllStoredKeys() override {
// Never invoked by SyncServiceCrypto.
NOTREACHED();
}
void MarkKeysAsStale(const CoreAccountInfo& account_info,
base::OnceCallback<void(bool)> cb) override {
std::move(cb).Run(false);
}
void GetIsRecoverabilityDegraded(const CoreAccountInfo& account_info,
base::OnceCallback<void(bool)> cb) override {
std::move(cb).Run(false);
}
void AddTrustedRecoveryMethod(const std::string& gaia_id,
const std::vector<uint8_t>& public_key,
base::OnceClosure cb) override {
// Never invoked by SyncServiceCrypto.
NOTREACHED();
}
};
// A SyncEncryptionHandler::Observer implementation that simply posts all calls
// to another task runner.
class SyncEncryptionObserverProxy : public SyncEncryptionHandler::Observer {
public:
SyncEncryptionObserverProxy(
base::WeakPtr<SyncEncryptionHandler::Observer> observer,
scoped_refptr<base::SequencedTaskRunner> task_runner)
: observer_(observer), task_runner_(std::move(task_runner)) {}
void OnPassphraseRequired(
const KeyDerivationParams& key_derivation_params,
const sync_pb::EncryptedData& pending_keys) override {
task_runner_->PostTask(
FROM_HERE,
base::BindOnce(&SyncEncryptionHandler::Observer::OnPassphraseRequired,
observer_, key_derivation_params, pending_keys));
}
void OnPassphraseAccepted() override {
task_runner_->PostTask(
FROM_HERE,
base::BindOnce(&SyncEncryptionHandler::Observer::OnPassphraseAccepted,
observer_));
}
void OnTrustedVaultKeyRequired() override {
task_runner_->PostTask(
FROM_HERE,
base::BindOnce(
&SyncEncryptionHandler::Observer::OnTrustedVaultKeyRequired,
observer_));
}
void OnTrustedVaultKeyAccepted() override {
task_runner_->PostTask(
FROM_HERE,
base::BindOnce(
&SyncEncryptionHandler::Observer::OnTrustedVaultKeyAccepted,
observer_));
}
void OnBootstrapTokenUpdated(const std::string& bootstrap_token,
BootstrapTokenType type) override {
task_runner_->PostTask(
FROM_HERE,
base::BindOnce(
&SyncEncryptionHandler::Observer::OnBootstrapTokenUpdated,
observer_, bootstrap_token, type));
}
void OnEncryptedTypesChanged(ModelTypeSet encrypted_types,
bool encrypt_everything) override {
task_runner_->PostTask(
FROM_HERE,
base::BindOnce(
&SyncEncryptionHandler::Observer::OnEncryptedTypesChanged,
observer_, encrypted_types, encrypt_everything));
}
void OnCryptographerStateChanged(Cryptographer* cryptographer,
bool has_pending_keys) override {
task_runner_->PostTask(
FROM_HERE,
base::BindOnce(
&SyncEncryptionHandler::Observer::OnCryptographerStateChanged,
observer_, /*cryptographer=*/nullptr, has_pending_keys));
}
void OnPassphraseTypeChanged(PassphraseType type,
base::Time passphrase_time) override {
task_runner_->PostTask(
FROM_HERE,
base::BindOnce(
&SyncEncryptionHandler::Observer::OnPassphraseTypeChanged,
observer_, type, passphrase_time));
}
private:
base::WeakPtr<SyncEncryptionHandler::Observer> observer_;
scoped_refptr<base::SequencedTaskRunner> task_runner_;
};
TrustedVaultClient* ResoveNullClient(TrustedVaultClient* client) {
if (client) {
return client;
}
static base::NoDestructor<EmptyTrustedVaultClient> empty_client;
return empty_client.get();
}
// Checks if |passphrase| can be used to decrypt the given pending keys. Returns
// true if decryption was successful. Returns false otherwise. Must be called
// with non-empty pending keys cache.
bool CheckPassphraseAgainstPendingKeys(
const sync_pb::EncryptedData& pending_keys,
const KeyDerivationParams& key_derivation_params,
const std::string& passphrase) {
DCHECK(pending_keys.has_blob());
DCHECK(!passphrase.empty());
if (key_derivation_params.method() == KeyDerivationMethod::UNSUPPORTED) {
DLOG(ERROR) << "Cannot derive keys using an unsupported key derivation "
"method. Rejecting passphrase.";
return false;
}
std::unique_ptr<Nigori> nigori =
Nigori::CreateByDerivation(key_derivation_params, passphrase);
DCHECK(nigori);
std::string plaintext;
bool decrypt_result = nigori->Decrypt(pending_keys.blob(), &plaintext);
DVLOG_IF(1, !decrypt_result) << "Passphrase failed to decrypt pending keys.";
return decrypt_result;
}
} // namespace
SyncServiceCrypto::State::State()
: passphrase_key_derivation_params(KeyDerivationParams::CreateForPbkdf2()) {
}
SyncServiceCrypto::State::~State() = default;
SyncServiceCrypto::SyncServiceCrypto(
const base::RepeatingClosure& notify_observers,
const base::RepeatingClosure& notify_required_user_action_changed,
const base::RepeatingCallback<void(ConfigureReason)>& reconfigure,
TrustedVaultClient* trusted_vault_client)
: notify_observers_(notify_observers),
notify_required_user_action_changed_(notify_required_user_action_changed),
reconfigure_(reconfigure),
trusted_vault_client_(ResoveNullClient(trusted_vault_client)) {
DCHECK(notify_observers_);
DCHECK(reconfigure_);
DCHECK(trusted_vault_client_);
trusted_vault_client_->AddObserver(this);
}
SyncServiceCrypto::~SyncServiceCrypto() {
trusted_vault_client_->RemoveObserver(this);
}
void SyncServiceCrypto::Reset() {
state_ = State();
}
base::Time SyncServiceCrypto::GetExplicitPassphraseTime() const {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
return state_.cached_explicit_passphrase_time;
}
bool SyncServiceCrypto::IsPassphraseRequired() const {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
switch (state_.required_user_action) {
case RequiredUserAction::kUnknownDuringInitialization:
case RequiredUserAction::kNone:
case RequiredUserAction::kFetchingTrustedVaultKeys:
case RequiredUserAction::kTrustedVaultKeyRequired:
case RequiredUserAction::kTrustedVaultKeyRequiredButFetching:
case RequiredUserAction::kTrustedVaultRecoverabilityDegraded:
return false;
case RequiredUserAction::kPassphraseRequired:
return true;
}
NOTREACHED();
return false;
}
bool SyncServiceCrypto::IsUsingSecondaryPassphrase() const {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
return IsExplicitPassphrase(state_.cached_passphrase_type);
}
bool SyncServiceCrypto::IsTrustedVaultKeyRequired() const {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
return state_.required_user_action ==
RequiredUserAction::kTrustedVaultKeyRequired ||
state_.required_user_action ==
RequiredUserAction::kTrustedVaultKeyRequiredButFetching;
}
bool SyncServiceCrypto::IsTrustedVaultRecoverabilityDegraded() const {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
return state_.required_user_action ==
RequiredUserAction::kTrustedVaultRecoverabilityDegraded;
}
bool SyncServiceCrypto::IsEncryptEverythingEnabled() const {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
DCHECK(state_.engine);
return state_.encrypt_everything || state_.encryption_pending;
}
void SyncServiceCrypto::SetEncryptionPassphrase(const std::string& passphrase) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
// This should only be called when the engine has been initialized.
DCHECK(state_.engine);
// We should never be called with an empty passphrase.
DCHECK(!passphrase.empty());
switch (state_.required_user_action) {
case RequiredUserAction::kUnknownDuringInitialization:
case RequiredUserAction::kNone:
case RequiredUserAction::kTrustedVaultRecoverabilityDegraded:
break;
case RequiredUserAction::kPassphraseRequired:
case RequiredUserAction::kFetchingTrustedVaultKeys:
case RequiredUserAction::kTrustedVaultKeyRequired:
case RequiredUserAction::kTrustedVaultKeyRequiredButFetching:
// Cryptographer has pending keys.
NOTREACHED()
<< "Can not set explicit passphrase when decryption is needed.";
return;
}
DVLOG(1) << "Setting explicit passphrase for encryption.";
// SetEncryptionPassphrase() should never be called if we are currently
// encrypted with an explicit passphrase.
DCHECK(!IsExplicitPassphrase(state_.cached_passphrase_type));
state_.engine->SetEncryptionPassphrase(passphrase);
}
bool SyncServiceCrypto::SetDecryptionPassphrase(const std::string& passphrase) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
// We should never be called with an empty passphrase.
DCHECK(!passphrase.empty());
// This should only be called when we have cached pending keys.
DCHECK(state_.cached_pending_keys.has_blob());
// For types other than CUSTOM_PASSPHRASE, we should be using the old PBKDF2
// key derivation method.
if (state_.cached_passphrase_type != PassphraseType::kCustomPassphrase) {
DCHECK_EQ(state_.passphrase_key_derivation_params.method(),
KeyDerivationMethod::PBKDF2_HMAC_SHA1_1003);
}
// Check the passphrase that was provided against our local cache of the
// cryptographer's pending keys (which we cached during a previous
// OnPassphraseRequired() event). If this was unsuccessful, the UI layer can
// immediately call OnPassphraseRequired() again without showing the user a
// spinner.
if (!CheckPassphraseAgainstPendingKeys(
state_.cached_pending_keys, state_.passphrase_key_derivation_params,
passphrase)) {
return false;
}
state_.engine->SetDecryptionPassphrase(passphrase);
// Since we were able to decrypt the cached pending keys with the passphrase
// provided, we immediately alert the UI layer that the passphrase was
// accepted. This will avoid the situation where a user enters a passphrase,
// clicks OK, immediately reopens the advanced settings dialog, and gets an
// unnecessary prompt for a passphrase.
// Note: It is not guaranteed that the passphrase will be accepted by the
// syncer thread, since we could receive a new nigori node while the task is
// pending. This scenario is a valid race, and SetDecryptionPassphrase() can
// trigger a new OnPassphraseRequired() if it needs to.
OnPassphraseAccepted();
return true;
}
bool SyncServiceCrypto::IsTrustedVaultKeyRequiredStateKnown() const {
switch (state_.required_user_action) {
case RequiredUserAction::kUnknownDuringInitialization:
case RequiredUserAction::kFetchingTrustedVaultKeys:
return false;
case RequiredUserAction::kNone:
case RequiredUserAction::kPassphraseRequired:
case RequiredUserAction::kTrustedVaultKeyRequired:
case RequiredUserAction::kTrustedVaultKeyRequiredButFetching:
case RequiredUserAction::kTrustedVaultRecoverabilityDegraded:
return true;
}
NOTREACHED();
return false;
}
PassphraseType SyncServiceCrypto::GetPassphraseType() const {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
return state_.cached_passphrase_type;
}
void SyncServiceCrypto::SetSyncEngine(const CoreAccountInfo& account_info,
SyncEngine* engine) {
DCHECK(engine);
state_.account_info = account_info;
state_.engine = engine;
// Since there was no state changes during engine initialization, now the
// state is known and no user action required.
if (state_.required_user_action ==
RequiredUserAction::kUnknownDuringInitialization) {
UpdateRequiredUserActionAndNotify(RequiredUserAction::kNone);
}
// This indicates OnTrustedVaultKeyRequired() was called as part of the
// engine's initialization.
if (state_.required_user_action ==
RequiredUserAction::kFetchingTrustedVaultKeys) {
FetchTrustedVaultKeys(/*is_second_fetch_attempt=*/false);
}
}
std::unique_ptr<SyncEncryptionHandler::Observer>
SyncServiceCrypto::GetEncryptionObserverProxy() {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
return std::make_unique<SyncEncryptionObserverProxy>(
weak_factory_.GetWeakPtr(), base::SequencedTaskRunnerHandle::Get());
}
ModelTypeSet SyncServiceCrypto::GetEncryptedDataTypes() const {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
DCHECK(state_.encrypted_types.Has(PASSWORDS));
DCHECK(state_.encrypted_types.Has(WIFI_CONFIGURATIONS));
// We may be called during the setup process before we're
// initialized. In this case, we default to the sensitive types.
return state_.encrypted_types;
}
bool SyncServiceCrypto::HasCryptoError() const {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
// This determines whether DataTypeManager should issue crypto errors for
// encrypted datatypes. This may differ from whether the UI represents the
// error state or not.
switch (state_.required_user_action) {
case RequiredUserAction::kUnknownDuringInitialization:
case RequiredUserAction::kNone:
case RequiredUserAction::kTrustedVaultRecoverabilityDegraded:
return false;
case RequiredUserAction::kFetchingTrustedVaultKeys:
case RequiredUserAction::kTrustedVaultKeyRequired:
case RequiredUserAction::kTrustedVaultKeyRequiredButFetching:
case RequiredUserAction::kPassphraseRequired:
return true;
}
NOTREACHED();
return false;
}
void SyncServiceCrypto::OnPassphraseRequired(
const KeyDerivationParams& key_derivation_params,
const sync_pb::EncryptedData& pending_keys) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
// Update our cache of the cryptographer's pending keys.
state_.cached_pending_keys = pending_keys;
// Update the key derivation params to be used.
state_.passphrase_key_derivation_params = key_derivation_params;
DVLOG(1) << "Passphrase required.";
UpdateRequiredUserActionAndNotify(RequiredUserAction::kPassphraseRequired);
// Reconfigure without the encrypted types (excluded implicitly via the
// failed datatypes handler).
reconfigure_.Run(CONFIGURE_REASON_CRYPTO);
}
void SyncServiceCrypto::OnPassphraseAccepted() {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
// Clear our cache of the cryptographer's pending keys.
state_.cached_pending_keys.clear_blob();
// Reset |required_user_action| since we know we no longer require the
// passphrase.
UpdateRequiredUserActionAndNotify(RequiredUserAction::kNone);
// Make sure the data types that depend on the passphrase are started at
// this time.
reconfigure_.Run(CONFIGURE_REASON_CRYPTO);
}
void SyncServiceCrypto::OnTrustedVaultKeyRequired() {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
// To be on the safe since, if a passphrase is required, we avoid overriding
// |state_.required_user_action|.
if (state_.required_user_action != RequiredUserAction::kNone &&
state_.required_user_action !=
RequiredUserAction::kUnknownDuringInitialization) {
return;
}
UpdateRequiredUserActionAndNotify(
RequiredUserAction::kFetchingTrustedVaultKeys);
if (!state_.engine) {
// If SetSyncEngine() hasn't been called yet, it means
// OnTrustedVaultKeyRequired() was called as part of the engine's
// initialization. Fetching the keys is not useful right now because there
// is known engine to feed the keys to, so let's defer fetching until
// SetSyncEngine() is called.
return;
}
FetchTrustedVaultKeys(/*is_second_fetch_attempt=*/false);
}
void SyncServiceCrypto::OnTrustedVaultKeyAccepted() {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
switch (state_.required_user_action) {
case RequiredUserAction::kUnknownDuringInitialization:
case RequiredUserAction::kNone:
case RequiredUserAction::kPassphraseRequired:
case RequiredUserAction::kTrustedVaultRecoverabilityDegraded:
return;
case RequiredUserAction::kFetchingTrustedVaultKeys:
case RequiredUserAction::kTrustedVaultKeyRequired:
case RequiredUserAction::kTrustedVaultKeyRequiredButFetching:
break;
}
UpdateRequiredUserActionAndNotify(RequiredUserAction::kNone);
// Make sure the data types that depend on the decryption key are started at
// this time.
reconfigure_.Run(CONFIGURE_REASON_CRYPTO);
}
void SyncServiceCrypto::OnBootstrapTokenUpdated(
const std::string& bootstrap_token,
BootstrapTokenType type) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
DCHECK(state_.engine);
if (type == PASSPHRASE_BOOTSTRAP_TOKEN) {
state_.engine->SetEncryptionBootstrapToken(bootstrap_token);
} else {
state_.engine->SetKeystoreEncryptionBootstrapToken(bootstrap_token);
}
}
void SyncServiceCrypto::OnEncryptedTypesChanged(ModelTypeSet encrypted_types,
bool encrypt_everything) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
state_.encrypted_types = encrypted_types;
state_.encrypt_everything = encrypt_everything;
DVLOG(1) << "Encrypted types changed to "
<< ModelTypeSetToString(state_.encrypted_types)
<< " (encrypt everything is set to "
<< (state_.encrypt_everything ? "true" : "false") << ")";
DCHECK(state_.encrypted_types.Has(PASSWORDS));
DCHECK(state_.encrypted_types.Has(WIFI_CONFIGURATIONS));
notify_observers_.Run();
}
void SyncServiceCrypto::OnCryptographerStateChanged(
Cryptographer* cryptographer,
bool has_pending_keys) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
// Do nothing.
}
void SyncServiceCrypto::OnPassphraseTypeChanged(PassphraseType type,
base::Time passphrase_time) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
DVLOG(1) << "Passphrase type changed to " << PassphraseTypeToString(type);
state_.cached_passphrase_type = type;
state_.cached_explicit_passphrase_time = passphrase_time;
// Clear recoverability degraded state in case a custom passphrase was set.
if (type != PassphraseType::kTrustedVaultPassphrase &&
state_.required_user_action ==
RequiredUserAction::kTrustedVaultRecoverabilityDegraded) {
UpdateRequiredUserActionAndNotify(RequiredUserAction::kNone);
}
notify_observers_.Run();
}
void SyncServiceCrypto::OnTrustedVaultKeysChanged() {
switch (state_.required_user_action) {
case RequiredUserAction::kUnknownDuringInitialization:
case RequiredUserAction::kNone:
case RequiredUserAction::kPassphraseRequired:
case RequiredUserAction::kTrustedVaultRecoverabilityDegraded:
// If no trusted vault keys are required, there's nothing to do. If they
// later are required, a fetch will be triggered in
// OnTrustedVaultKeyRequired().
return;
case RequiredUserAction::kFetchingTrustedVaultKeys:
case RequiredUserAction::kTrustedVaultKeyRequiredButFetching:
// If there's an ongoing fetch, FetchKeys() cannot be issued immediately
// since that violates the function precondition. However, the in-flight
// FetchKeys() may end up returning stale keys, so let's make sure
// FetchKeys() is invoked again once it becomes possible.
state_.deferred_trusted_vault_fetch_keys_pending = true;
return;
case RequiredUserAction::kTrustedVaultKeyRequired:
UpdateRequiredUserActionAndNotify(
RequiredUserAction::kTrustedVaultKeyRequiredButFetching);
break;
}
FetchTrustedVaultKeys(/*is_second_fetch_attempt=*/false);
}
void SyncServiceCrypto::OnTrustedVaultRecoverabilityChanged() {
RefreshIsRecoverabilityDegraded();
}
void SyncServiceCrypto::FetchTrustedVaultKeys(bool is_second_fetch_attempt) {
DCHECK(state_.engine);
DCHECK(state_.required_user_action ==
RequiredUserAction::kFetchingTrustedVaultKeys ||
state_.required_user_action ==
RequiredUserAction::kTrustedVaultKeyRequiredButFetching);
UMA_HISTOGRAM_ENUMERATION(
"Sync.TrustedVaultFetchKeysAttempt",
is_second_fetch_attempt
? TrustedVaultFetchKeysAttemptForUMA::kSecondAttempt
: TrustedVaultFetchKeysAttemptForUMA::kFirstAttempt);
if (!is_second_fetch_attempt) {
state_.deferred_trusted_vault_fetch_keys_pending = false;
}
trusted_vault_client_->FetchKeys(
state_.account_info,
base::BindOnce(&SyncServiceCrypto::TrustedVaultKeysFetchedFromClient,
weak_factory_.GetWeakPtr(), is_second_fetch_attempt));
}
void SyncServiceCrypto::TrustedVaultKeysFetchedFromClient(
bool is_second_fetch_attempt,
const std::vector<std::vector<uint8_t>>& keys) {
if (state_.required_user_action !=
RequiredUserAction::kFetchingTrustedVaultKeys &&
state_.required_user_action !=
RequiredUserAction::kTrustedVaultKeyRequiredButFetching) {
return;
}
DCHECK(state_.engine);
UMA_HISTOGRAM_COUNTS_100("Sync.TrustedVaultFetchedKeysCount", keys.size());
if (keys.empty()) {
// Nothing to do if no keys have been fetched from the client (e.g. user
// action is required for fetching additional keys). Let's avoid unnecessary
// steps like marking keys as stale.
FetchTrustedVaultKeysCompletedButInsufficient();
return;
}
state_.engine->AddTrustedVaultDecryptionKeys(
keys,
base::BindOnce(&SyncServiceCrypto::TrustedVaultKeysAdded,
weak_factory_.GetWeakPtr(), is_second_fetch_attempt));
}
void SyncServiceCrypto::TrustedVaultKeysAdded(bool is_second_fetch_attempt) {
// Having kFetchingTrustedVaultKeys or kTrustedVaultKeyRequiredButFetching
// indicates OnTrustedVaultKeyAccepted() was not triggered, so the fetched
// trusted vault keys were insufficient.
bool success = state_.required_user_action !=
RequiredUserAction::kFetchingTrustedVaultKeys &&
state_.required_user_action !=
RequiredUserAction::kTrustedVaultKeyRequiredButFetching;
UMA_HISTOGRAM_BOOLEAN("Sync.TrustedVaultAddKeysAttemptIsSuccessful", success);
if (success) {
return;
}
// Let trusted vault client know, that fetched keys were insufficient.
trusted_vault_client_->MarkKeysAsStale(
state_.account_info,
base::BindOnce(&SyncServiceCrypto::TrustedVaultKeysMarkedAsStale,
weak_factory_.GetWeakPtr(), is_second_fetch_attempt));
}
void SyncServiceCrypto::TrustedVaultKeysMarkedAsStale(
bool is_second_fetch_attempt,
bool result) {
if (state_.required_user_action !=
RequiredUserAction::kFetchingTrustedVaultKeys &&
state_.required_user_action !=
RequiredUserAction::kTrustedVaultKeyRequiredButFetching) {
return;
}
// If nothing has changed (determined by |!result| since false negatives are
// disallowed by the API) or this is already a second attempt, the fetching
// procedure can be considered completed.
if (!result || is_second_fetch_attempt) {
FetchTrustedVaultKeysCompletedButInsufficient();
return;
}
FetchTrustedVaultKeys(/*is_second_fetch_attempt=*/true);
}
void SyncServiceCrypto::FetchTrustedVaultKeysCompletedButInsufficient() {
DCHECK(state_.required_user_action ==
RequiredUserAction::kFetchingTrustedVaultKeys ||
state_.required_user_action ==
RequiredUserAction::kTrustedVaultKeyRequiredButFetching);
// If FetchKeys() was intended to be called during an already existing ongoing
// FetchKeys(), it needs to be invoked now that it's possible.
if (state_.deferred_trusted_vault_fetch_keys_pending) {
FetchTrustedVaultKeys(/*is_second_fetch_attempt=*/false);
return;
}
// Reaching this codepath indicates OnTrustedVaultKeyAccepted() was not
// triggered, so the fetched trusted vault keys were insufficient.
UpdateRequiredUserActionAndNotify(
RequiredUserAction::kTrustedVaultKeyRequired);
// Reconfigure without the encrypted types (excluded implicitly via the failed
// datatypes handler).
reconfigure_.Run(CONFIGURE_REASON_CRYPTO);
}
void SyncServiceCrypto::UpdateRequiredUserActionAndNotify(
RequiredUserAction new_required_user_action) {
DCHECK_NE(new_required_user_action,
RequiredUserAction::kUnknownDuringInitialization);
if (state_.required_user_action == new_required_user_action) {
return;
}
state_.required_user_action = new_required_user_action;
notify_required_user_action_changed_.Run();
RefreshIsRecoverabilityDegraded();
}
void SyncServiceCrypto::RefreshIsRecoverabilityDegraded() {
switch (state_.required_user_action) {
case RequiredUserAction::kUnknownDuringInitialization:
case RequiredUserAction::kFetchingTrustedVaultKeys:
case RequiredUserAction::kTrustedVaultKeyRequired:
case RequiredUserAction::kTrustedVaultKeyRequiredButFetching:
case RequiredUserAction::kPassphraseRequired:
return;
case RequiredUserAction::kNone:
case RequiredUserAction::kTrustedVaultRecoverabilityDegraded:
break;
}
if (!base::FeatureList::IsEnabled(
switches::kSyncSupportTrustedVaultPassphraseRecovery)) {
return;
}
trusted_vault_client_->GetIsRecoverabilityDegraded(
state_.account_info,
base::BindOnce(&SyncServiceCrypto::GetIsRecoverabilityDegradedCompleted,
weak_factory_.GetWeakPtr()));
}
void SyncServiceCrypto::GetIsRecoverabilityDegradedCompleted(
bool is_recoverability_degraded) {
// The passphrase type could have changed.
if (state_.cached_passphrase_type !=
PassphraseType::kTrustedVaultPassphrase) {
DCHECK_NE(state_.required_user_action,
RequiredUserAction::kTrustedVaultRecoverabilityDegraded);
return;
}
// Transition from non-degraded to degraded recoverability.
if (is_recoverability_degraded &&
state_.required_user_action == RequiredUserAction::kNone) {
UpdateRequiredUserActionAndNotify(
RequiredUserAction::kTrustedVaultRecoverabilityDegraded);
notify_observers_.Run();
}
// Transition from degraded to non-degraded recoverability.
if (!is_recoverability_degraded &&
state_.required_user_action ==
RequiredUserAction::kTrustedVaultRecoverabilityDegraded) {
UpdateRequiredUserActionAndNotify(RequiredUserAction::kNone);
notify_observers_.Run();
}
}
} // namespace syncer
|
* Toolkit II Net Constants (English) 1985 T.Tebby QJUMP
*
section defs
xdef ms_ntabt
*
ms_ntabt dc.w ntabt_ms-*
*
ntabt_ms dc.w 12
dc.b 'Net aborted',$a
*
end
|
/*
* Copyright © <2010>, Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sub license, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial portions
* of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
* IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* This file was originally licensed under the following license
*
* 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.
*
*/
// Module name: save_Top_Y_16x4.asm
//
// Save a Y 16x4 block
//
//----------------------------------------------------------------
// Symbols need to be defined before including this module
//
// Source region in :ud
// SRC_YD: SRC_YD Base=rxx ElementSize=4 SrcRegion=REGION(8,1) Type=ud // 2 GRFs
//
// Binding table index:
// BI_DEST_Y: Binding table index of Y surface
//
//----------------------------------------------------------------
#if defined(_DEBUG)
mov (1) EntrySignatureC:w 0xDDD5:w
#endif
and.z.f0.1 (16) NULLREGW DualFieldMode<0;1,0>:w 1:w
// FieldModeCurrentMbFlag determines how to access above MB
and.z.f0.0 (1) null:w r[ECM_AddrReg, BitFlags]:ub FieldModeCurrentMbFlag:w
mov (2) MSGSRC.0<1>:ud ORIX_TOP<2;2,1>:w { NoDDClr } // Block origin
mov (1) MSGSRC.2<1>:ud 0x0003000F:ud { NoDDChk } // Block width and height (16x4)
// Pack Y
// Dual field mode
(f0.1) mov (16) MSGPAYLOADD(0)<1> PREV_MB_YD(0) // Compressed inst
(-f0.1) mov (16) MSGPAYLOADD(0)<1> PREV_MB_YD(2) // for dual field mode, write last 4 rows
// Set message descriptor
and.nz.f0.1 (1) NULLREGW BitFields:w BotFieldFlag:w
(f0.0) if (1) ELSE_Y_16x4_SAVE
// Frame picture
mov (1) MSGDSC MSG_LEN(2)+DWBWMSGDSC_WC+BI_DEST_Y:ud // Write 2 GRFs to DEST_Y
// Add vertical offset 16 for bot MB in MBAFF mode
(f0.1) add (1) MSGSRC.1:d MSGSRC.1:d 16:w
ELSE_Y_16x4_SAVE:
else (1) ENDIF_Y_16x4_SAVE
asr (1) MSGSRC.1:d ORIY_CUR:w 1:w // Reduce y by half in field access mode
// Field picture
(f0.1) mov (1) MSGDSC MSG_LEN(2)+DWBWMSGDSC_WC+ENMSGDSCBF+BI_DEST_Y:ud // Write 2 GRFs to DEST_Y bottom field
(-f0.1) mov (1) MSGDSC MSG_LEN(2)+DWBWMSGDSC_WC+ENMSGDSCTF+BI_DEST_Y:ud // Write 2 GRFs to DEST_Y top field
add (1) MSGSRC.1:d MSGSRC.1:d -4:w // for last 4 rows of above MB
endif
ENDIF_Y_16x4_SAVE:
send (8) WritebackResponse(0)<1> MSGHDR MSGSRC<8;8,1>:ud DAPWRITE MSGDSC
// End of save_Top_Y_16x4.asm
|
#define RGBCX_IMPLEMENTATION
#include "rgbcx.h"
|
.size 8000
.text@48
jp lstatint
.text@100
jp lbegin
.data@143
c0
.text@150
lbegin:
ld a, 00
ldff(ff), a
ld a, 30
ldff(00), a
ld a, 01
ldff(4d), a
stop, 00
ld c, 41
ld b, 03
lbegin_waitm3:
ldff a, (c)
and a, b
cmp a, b
jrnz lbegin_waitm3
ld a, 20
ldff(c), a
ld a, 02
ldff(ff), a
ld a, 08
ldff(43), a
ei
.text@1000
lstatint:
nop
.text@1074
ldff a, (c)
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
|
;; generated by encode_room_layouts.py
r10_room_data_rl::
;;0.json
DB $0b, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $05, $0e, $0d, $0b, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $05, $0e, $0e, $0e, $0e, $0b, $13, $13, $13, $13, $13, $13, $13, $13, $05, $0d, $0e, $0e, $0e, $0e, $0e, $0e, $09, $09, $09, $09, $09, $09, $09, $0d, $0e, $0e, $0e, $0e, $0e, $0e, $0e, $08, $39, $39, $39, $39, $39, $39, $39, $06, $0e, $0e, $0e, $0e, $0a, $0a, $08, $39, $39, $39, $38, $39, $39, $39, $39, $02, $0a, $0a, $0a, $0a, $39, $39, $39, $39, $39, $39, $39, $39, $39, $39, $39, $39, $39, $39, $39, $39, $39, $38, $39, $39, $38, $39, $39, $39, $39, $39, $39, $39, $39, $38, $39, $39, $39, $39, $39, $39, $39, $39, $39, $39, $39, $39, $39, $39, $39, $39, $39, $39, $39, $39, $39, $39, $39, $39, $39, $39, $39, $38, $39, $39, $39, $39, $39, $39, $0d, $0d, $0b, $38, $39, $39, $39, $39, $39, $39, $39, $39, $05, $0d, $0d, $0d, $0e, $0e, $0c, $39, $39, $39, $39, $39, $39, $39, $39, $39, $06, $0e, $0e, $0e, $0e, $0e, $0e, $09, $09, $09, $09, $09, $09, $09, $0b, $05, $0e, $0e, $0e, $0e, $0e, $0e, $08, $11, $11, $11, $11, $11, $11, $11, $02, $0a, $0a, $0a, $0a, $0e, $0e, $0c, $11, $12, $12, $12, $12, $12, $12, $12, $11, $11, $11, $11, $11, $06, $0e, $0c, $12, $13, $13, $13, $13, $13, $13, $13, $12, $12, $12, $12, $12, $06,
;;1.json
DB $0e, $0a, $0a, $0a, $0a, $0a, $0a, $0a, $0a, $0a, $08, $11, $11, $11, $11, $12, $0e, $0d, $0b, $11, $11, $11, $11, $11, $11, $11, $11, $12, $12, $12, $12, $13, $0e, $0e, $0e, $0b, $12, $12, $12, $12, $12, $12, $12, $13, $13, $13, $13, $13, $0e, $0e, $0e, $0e, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $0e, $0e, $0e, $08, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $0a, $0a, $08, $39, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $39, $39, $39, $39, $3a, $3a, $3a, $3a, $3a, $3a, $3a, $3a, $3a, $3a, $3a, $3a, $39, $38, $39, $3a, $3a, $3a, $3a, $3a, $3a, $3a, $3a, $3a, $3a, $3a, $3a, $3a, $39, $39, $39, $3a, $3a, $3a, $3a, $3a, $3a, $3a, $3a, $3a, $3a, $3a, $3a, $3a, $39, $39, $39, $3a, $3a, $3a, $3a, $3a, $3a, $3a, $3a, $3a, $3a, $3a, $3a, $3a, $0d, $0d, $0b, $39, $3a, $3a, $3a, $3a, $3a, $3a, $3a, $3a, $3a, $3a, $3a, $3a, $0e, $0e, $0c, $39, $14, $14, $14, $14, $14, $14, $14, $14, $14, $14, $14, $14, $0e, $0e, $0e, $07, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $0e, $0e, $08, $11, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $0e, $0c, $11, $12, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $0e, $0c, $12, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13,
;;2.json
DB $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $3a, $3a, $3a, $3a, $3a, $3a, $3a, $3a, $3a, $3a, $3a, $3a, $3a, $3a, $3a, $3a, $3a, $3a, $3a, $3a, $3a, $3a, $3a, $3a, $3a, $3a, $3a, $3a, $3a, $3a, $3a, $3a, $3a, $3a, $3a, $3a, $3a, $3a, $3a, $3a, $3a, $3a, $3a, $3a, $3a, $3a, $3a, $3a, $3a, $3a, $3a, $3a, $3a, $3a, $3a, $3a, $3a, $3a, $3a, $3a, $3a, $3a, $3a, $3a, $3a, $3a, $3a, $3a, $3a, $3a, $3a, $3a, $3a, $3a, $3a, $3a, $3a, $3a, $3a, $3a, $14, $14, $14, $14, $14, $14, $14, $14, $14, $14, $14, $14, $14, $14, $14, $14, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13, $13,
r10_room_data_rl_end::
|
// David Eberly, Geometric Tools, Redmond WA 98052
// Copyright (c) 1998-2020
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
// https://www.geometrictools.com/License/Boost/LICENSE_1_0.txt
// Version: 4.0.2020.01.10
#include "AdaptiveSkeletonClimbing3Console.h"
#include <Applications/LogReporter.h>
int main()
{
#if defined(_DEBUG)
LogReporter reporter(
"LogReport.txt",
Logger::Listener::LISTEN_FOR_ALL,
Logger::Listener::LISTEN_FOR_ALL,
Logger::Listener::LISTEN_FOR_ALL,
Logger::Listener::LISTEN_FOR_ALL);
#endif
Console::Parameters parameters(L"AdaptiveSkeletonClimbing3Console");
auto console = TheConsoleSystem.Create<AdaptiveSkeletonClimbing3Console>(parameters);
TheConsoleSystem.Execute(console);
TheConsoleSystem.Destroy(console);
return 0;
}
|
; A037536: Base-3 digits are, in order, the first n terms of the periodic sequence with initial period 1,2,1.
; 1,5,16,49,149,448,1345,4037,12112,36337,109013,327040,981121,2943365,8830096,26490289,79470869,238412608,715237825,2145713477,6437140432,19311421297,57934263893,173802791680,521408375041
add $0,1
mov $2,6
lpb $0
sub $0,1
mul $2,3
mov $1,$2
add $1,4
mov $2,$1
div $1,13
lpe
mov $0,$1
|
;NestorWeb CGI script to return the current date on the server.
;This one uses _CONOUT and _STROUT to write the request body to STDOUT,
;but using _WRITE instead is generally recommended.
CR: equ 13
LF: equ 10
_CONOUT: equ 2
_STROUT: equ 9
_GDATE: equ 2Ah
_GTIME: equ 2Ch
org 100h
ld de,HEADERS
ld c,_STROUT
call 5
;Date
ld c,_GDATE ;HL = year, D = month, E = day
call 5
call HL2ASC ;Year
call PRINTBUF
call PRINTDASH
ld a,d
call BYTE2ASC ;Month
call PRINTBUF
call PRINTDASH
ld a,e
call BYTE2ASC ;Day
call PRINTBUF
ld e,' '
ld c,_CONOUT
call 5
;Time
ld c,_GTIME ;H = hour, D = minute, E = seconds
call 5
push hl
ld a,h
call BYTE2ASC ;Hour
call PRINTBUF
call PRINTCOLON
pop hl
ld a,l
call BYTE2ASC ;Minute
call PRINTBUF
call PRINTCOLON
ld a,d
call BYTE2ASC ;Second
call PRINTBUF
ret
PRINTDASH:
push hl
push de
ld e,'-'
ld c,_CONOUT
call 5
pop de
pop hl
ret
PRINTCOLON:
push hl
push de
ld e,':'
ld c,_CONOUT
call 5
pop de
pop hl
ret
PRINTBUF:
push hl
push de
ld a,(buf+1)
cp "0"
jr z,PRINTBUF2
ld e,a
ld c,_CONOUT
call 5
ld a,(buf+2)
ld e,a
ld c,_CONOUT
call 5
PRINTBUF2:
ld a,(buf+3)
ld e,a
ld c,_CONOUT
call 5
ld a,(buf+4)
ld e,a
ld c,_CONOUT
call 5
pop de
pop hl
ret
buf: ds 5
;http://wikiti.brandonw.net/index.php?title=Z80_Routines:Other:DispHL
BYTE2ASC:
ld h,0
ld l,a
HL2ASC:
ld ix,buf
ld bc,-10000
call Num1
ld bc,-1000
call Num1
ld bc,-100
call Num1
ld c,-10
call Num1
ld c,-1
Num1: ld a,'0'-1
Num2: inc a
add hl,bc
jr c,Num2
sbc hl,bc
ld (ix),a
inc ix
ret
HEADERS:
db "Content-Type: text/plain",CR,LF
db CR,LF
db "$" |
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Copyright (c) Berkeley Softworks 1990 -- All Rights Reserved
PROJECT: PC GEOS
MODULE: PCL 4 download font driver
FILE: totalResetInfo.asm
AUTHOR: Dave Durran
REVISION HISTORY:
Name Date Description
---- ---- -----------
Dave 1/92 Initial revision from laserdwn downLoadInfo.asm
DESCRIPTION:
This file contains the device information for the HP LaserJet
Other Printers Supported by this resource:
$Id: totalResetInfo.asm,v 1.1 97/04/18 11:52:24 newdeal Exp $
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
;----------------------------------------------------------------------------
; Special resource for ressetting everything by hand at job end
;----------------------------------------------------------------------------
totalResetInfo segment resource
; info blocks
PrinterInfo < ; ---- PrinterType -------------
< PT_RASTER,
BMF_MONO >,
; ---- PrinterConnections ------
< IC_NO_IEEE488,
CC_NO_CUSTOM,
SC_NO_SCSI,
RC_RS232C,
CC_CENTRONICS,
FC_FILE,
AC_NO_APPLETALK >,
; ---- PrinterSmarts -----------
PS_DOES_FONTS,
;-------Custom Entry Routine-------
NULL,
;-------Custom Exit Routine-------
PrintExitTotalResetPCL,
; ---- Mode Info Offsets -------
offset totalResetlowRes,
offset totalResetmedRes,
offset totalResethiRes,
NULL,
offset totalResetnlq,
; ---- Font Geometry -----------
totalResetFontGeometry,
; ---- Symbol Set list -----------
offset totalResetSymbolSets,
; ---- PaperMargins ------------
< PR_MARGIN_LEFT, ; Tractor Margins
0,
PR_MARGIN_RIGHT,
0 >,
< PR_MARGIN_LEFT, ; ASF Margins
PR_MARGIN_TOP,
PR_MARGIN_RIGHT,
PR_MARGIN_BOTTOM >,
; ---- PaperInputOptions -------
< MF_MANUAL1,
TF_NO_TRACTOR,
ASF_TRAY3 >,
; ---- PaperOutputOptions ------
< OC_COPIES,
PS_REVERSE,
OD_SIMPLEX,
SO_NO_STAPLER,
OS_NO_SORTER,
OB_NO_OUTPUTBIN >,
;
612, ; paper width (points).
NULL, ; Main UI
Pcl4OptionsDialogBox, ; Options UI
PrintEvalSimplex ; UI eval routine.
>
;----------------------------------------------------------------------------
; Graphics modes info
;----------------------------------------------------------------------------
totalResetlowRes GraphicsProperties < LO_RES_X_RES, ; xres
LO_RES_Y_RES, ; yres
LO_RES_BAND_HEIGHT, ; band height
LO_RES_BUFF_HEIGHT, ; buffer height
LO_RES_INTERLEAVE_FACTOR, ;#interleaves
BMF_MONO, ;color format
NULL > ; color format
totalResetmedRes GraphicsProperties < MED_RES_X_RES, ; xres
MED_RES_Y_RES, ; yres
MED_RES_BAND_HEIGHT, ; band height
MED_RES_BUFF_HEIGHT, ; buffer height
MED_RES_INTERLEAVE_FACTOR, ;#interleaves
BMF_MONO, ;color format
NULL > ; color format
totalResethiRes GraphicsProperties < HI_RES_X_RES, ; xres
HI_RES_Y_RES, ; yres
HI_RES_BAND_HEIGHT, ; band height
HI_RES_BUFF_HEIGHT, ; buffer height
HI_RES_INTERLEAVE_FACTOR, ;#interleaves
BMF_MONO, ;color format
NULL > ; color format
;----------------------------------------------------------------------------
; Text modes info
;----------------------------------------------------------------------------
totalResetnlq label word
nptr totalReset_10CPI
word 0 ; table terminator
totalResetSymbolSets label word
word offset pr_codes_SetASCII7 ;ASCII 7 bit
word offset pr_codes_SetIBM437 ;IBM code page 437
word offset pr_codes_SetIBM850 ;IBM code page 850
word NULL ;no IBM code page 860
word NULL ;no IBM code page 863
word NULL ;no IBM code page 865
word offset pr_codes_SetRoman8 ;Roman-8
word offset pr_codes_SetWindows ;MS windows
word offset pr_codes_SetVentura ;Ventura Int'l
word offset pr_codes_SetLatin1 ;ECMA-94 Latin 1
;----------------------------------------------------------------------------
; Font Structures
;----------------------------------------------------------------------------
totalReset_10CPI label word
totalResetFontGeometry DownloadProperties < HP_II_MAX_SOFT_FONTS,
HP_II_MAX_POINTSIZE >
totalResetInfo ends
|
//===--- Task.cpp - Task object and management ----------------------------===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2020 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See https://swift.org/LICENSE.txt for license information
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//
//
// Object management routines for asynchronous task objects.
//
//===----------------------------------------------------------------------===//
#include "../CompatibilityOverride/CompatibilityOverride.h"
#include "swift/Runtime/Concurrency.h"
#include "swift/ABI/Task.h"
#include "swift/ABI/TaskLocal.h"
#include "swift/ABI/TaskOptions.h"
#include "swift/ABI/Metadata.h"
#include "swift/Runtime/Mutex.h"
#include "swift/Runtime/HeapObject.h"
#include "TaskGroupPrivate.h"
#include "TaskPrivate.h"
#include "AsyncCall.h"
#include "Debug.h"
#include "Error.h"
#include <dispatch/dispatch.h>
#if !defined(_WIN32)
#include <dlfcn.h>
#endif
#ifdef __APPLE__
#if __POINTER_WIDTH__ == 64
asm("\n .globl _swift_async_extendedFramePointerFlags" \
"\n _swift_async_extendedFramePointerFlags = 0x1000000000000000");
#elif __ARM64_ARCH_8_32__
asm("\n .globl _swift_async_extendedFramePointerFlags" \
"\n _swift_async_extendedFramePointerFlags = 0x10000000");
#else
asm("\n .globl _swift_async_extendedFramePointerFlags" \
"\n _swift_async_extendedFramePointerFlags = 0x0");
#endif
#endif // __APPLE__
using namespace swift;
using FutureFragment = AsyncTask::FutureFragment;
using TaskGroup = swift::TaskGroup;
void FutureFragment::destroy() {
auto queueHead = waitQueue.load(std::memory_order_acquire);
switch (queueHead.getStatus()) {
case Status::Executing:
assert(false && "destroying a task that never completed");
case Status::Success:
resultType->vw_destroy(getStoragePtr());
break;
case Status::Error:
swift_errorRelease(getError());
break;
}
}
FutureFragment::Status AsyncTask::waitFuture(AsyncTask *waitingTask,
AsyncContext *waitingTaskContext,
TaskContinuationFunction *resumeFn,
AsyncContext *callerContext,
OpaqueValue *result) {
using Status = FutureFragment::Status;
using WaitQueueItem = FutureFragment::WaitQueueItem;
assert(isFuture());
auto fragment = futureFragment();
auto queueHead = fragment->waitQueue.load(std::memory_order_acquire);
bool contextIntialized = false;
while (true) {
switch (queueHead.getStatus()) {
case Status::Error:
case Status::Success:
#if SWIFT_TASK_PRINTF_DEBUG
fprintf(stderr, "[%lu] task %p waiting on task %p, completed immediately\n",
_swift_get_thread_id(), waitingTask, this);
#endif
_swift_tsan_acquire(static_cast<Job *>(this));
if (contextIntialized) waitingTask->flagAsRunning();
// The task is done; we don't need to wait.
return queueHead.getStatus();
case Status::Executing:
#if SWIFT_TASK_PRINTF_DEBUG
fprintf(stderr, "[%lu] task %p waiting on task %p, going to sleep\n",
_swift_get_thread_id(), waitingTask, this);
#endif
_swift_tsan_release(static_cast<Job *>(waitingTask));
// Task is not complete. We'll need to add ourselves to the queue.
break;
}
if (!contextIntialized) {
contextIntialized = true;
auto context =
reinterpret_cast<TaskFutureWaitAsyncContext *>(waitingTaskContext);
context->errorResult = nullptr;
context->successResultPointer = result;
context->ResumeParent = resumeFn;
context->Parent = callerContext;
waitingTask->flagAsSuspended();
}
// Put the waiting task at the beginning of the wait queue.
waitingTask->getNextWaitingTask() = queueHead.getTask();
auto newQueueHead = WaitQueueItem::get(Status::Executing, waitingTask);
if (fragment->waitQueue.compare_exchange_weak(
queueHead, newQueueHead,
/*success*/ std::memory_order_release,
/*failure*/ std::memory_order_acquire)) {
// Escalate the priority of this task based on the priority
// of the waiting task.
swift_task_escalate(this, waitingTask->Flags.getPriority());
_swift_task_clearCurrent();
return FutureFragment::Status::Executing;
}
}
}
void NullaryContinuationJob::process(Job *_job) {
auto *job = cast<NullaryContinuationJob>(_job);
auto *task = job->Task;
auto *continuation = job->Continuation;
_swift_task_dealloc_specific(task, job);
auto *context = cast<ContinuationAsyncContext>(continuation->ResumeContext);
context->setErrorResult(nullptr);
swift_continuation_resume(continuation);
}
void AsyncTask::completeFuture(AsyncContext *context) {
using Status = FutureFragment::Status;
using WaitQueueItem = FutureFragment::WaitQueueItem;
assert(isFuture());
auto fragment = futureFragment();
// If an error was thrown, save it in the future fragment.
auto asyncContextPrefix = reinterpret_cast<FutureAsyncContextPrefix *>(
reinterpret_cast<char *>(context) - sizeof(FutureAsyncContextPrefix));
bool hadErrorResult = false;
auto errorObject = asyncContextPrefix->errorResult;
fragment->getError() = errorObject;
if (errorObject) {
hadErrorResult = true;
}
_swift_tsan_release(static_cast<Job *>(this));
// Update the status to signal completion.
auto newQueueHead = WaitQueueItem::get(
hadErrorResult ? Status::Error : Status::Success,
nullptr
);
auto queueHead = fragment->waitQueue.exchange(
newQueueHead, std::memory_order_acquire);
assert(queueHead.getStatus() == Status::Executing);
// If this is task group child, notify the parent group about the completion.
if (hasGroupChildFragment()) {
// then we must offer into the parent group that we completed,
// so it may `next()` poll completed child tasks in completion order.
auto group = groupChildFragment()->getGroup();
group->offer(this, context);
}
// Schedule every waiting task on the executor.
auto waitingTask = queueHead.getTask();
#if SWIFT_TASK_PRINTF_DEBUG
if (!waitingTask)
fprintf(stderr, "[%lu] task %p had no waiting tasks\n",
_swift_get_thread_id(), this);
#endif
while (waitingTask) {
// Find the next waiting task before we invalidate it by resuming
// the task.
auto nextWaitingTask = waitingTask->getNextWaitingTask();
#if SWIFT_TASK_PRINTF_DEBUG
fprintf(stderr, "[%lu] waking task %p from future of task %p\n",
_swift_get_thread_id(), waitingTask, this);
#endif
// Fill in the return context.
auto waitingContext =
static_cast<TaskFutureWaitAsyncContext *>(waitingTask->ResumeContext);
if (hadErrorResult) {
waitingContext->fillWithError(fragment);
} else {
waitingContext->fillWithSuccess(fragment);
}
_swift_tsan_acquire(static_cast<Job *>(waitingTask));
// Enqueue the waiter on the global executor.
// TODO: allow waiters to fill in a suggested executor
swift_task_enqueueGlobal(waitingTask);
// Move to the next task.
waitingTask = nextWaitingTask;
}
}
SWIFT_CC(swift)
static void destroyJob(SWIFT_CONTEXT HeapObject *obj) {
assert(false && "A non-task job should never be destroyed as heap metadata.");
}
AsyncTask::~AsyncTask() {
flagAsCompleted();
// For a future, destroy the result.
if (isFuture()) {
futureFragment()->destroy();
}
Private.destroy();
}
SWIFT_CC(swift)
static void destroyTask(SWIFT_CONTEXT HeapObject *obj) {
auto task = static_cast<AsyncTask*>(obj);
task->~AsyncTask();
// The task execution itself should always hold a reference to it, so
// if we get here, we know the task has finished running, which means
// swift_task_complete should have been run, which will have torn down
// the task-local allocator. There's actually nothing else to clean up
// here.
#if SWIFT_TASK_PRINTF_DEBUG
fprintf(stderr, "[%lu] destroy task %p\n", _swift_get_thread_id(), task);
#endif
free(task);
}
static ExecutorRef executorForEnqueuedJob(Job *job) {
void *jobQueue = job->SchedulerPrivate[Job::DispatchQueueIndex];
if (jobQueue == DISPATCH_QUEUE_GLOBAL_EXECUTOR)
return ExecutorRef::generic();
else
return ExecutorRef::forOrdinary(reinterpret_cast<HeapObject*>(jobQueue),
_swift_task_getDispatchQueueSerialExecutorWitnessTable());
}
static void jobInvoke(void *obj, void *unused, uint32_t flags) {
(void)unused;
Job *job = reinterpret_cast<Job *>(obj);
swift_job_run(job, executorForEnqueuedJob(job));
}
// Magic constant to identify Swift Job vtables to Dispatch.
static const unsigned long dispatchSwiftObjectType = 1;
FullMetadata<DispatchClassMetadata> swift::jobHeapMetadata = {
{
{
&destroyJob
},
{
/*value witness table*/ nullptr
}
},
{
MetadataKind::Job,
dispatchSwiftObjectType,
jobInvoke
}
};
/// Heap metadata for an asynchronous task.
static FullMetadata<DispatchClassMetadata> taskHeapMetadata = {
{
{
&destroyTask
},
{
/*value witness table*/ nullptr
}
},
{
MetadataKind::Task,
dispatchSwiftObjectType,
jobInvoke
}
};
const void *const swift::_swift_concurrency_debug_jobMetadata =
static_cast<Metadata *>(&jobHeapMetadata);
const void *const swift::_swift_concurrency_debug_asyncTaskMetadata =
static_cast<Metadata *>(&taskHeapMetadata);
static void completeTaskImpl(AsyncTask *task,
AsyncContext *context,
SwiftError *error) {
assert(task && "completing task, but there is no active task registered");
// Store the error result.
auto asyncContextPrefix = reinterpret_cast<AsyncContextPrefix *>(
reinterpret_cast<char *>(context) - sizeof(AsyncContextPrefix));
asyncContextPrefix->errorResult = error;
task->Private.complete(task);
#if SWIFT_TASK_PRINTF_DEBUG
fprintf(stderr, "[%lu] task %p completed\n", _swift_get_thread_id(), task);
#endif
// Complete the future.
// Warning: This deallocates the task in case it's an async let task.
// The task must not be accessed afterwards.
if (task->isFuture()) {
task->completeFuture(context);
}
// TODO: set something in the status?
// if (task->hasChildFragment()) {
// TODO: notify the parent somehow?
// TODO: remove this task from the child-task chain?
// }
}
/// The function that we put in the context of a simple task
/// to handle the final return.
SWIFT_CC(swiftasync)
static void completeTask(SWIFT_ASYNC_CONTEXT AsyncContext *context,
SWIFT_CONTEXT SwiftError *error) {
// Set that there's no longer a running task in the current thread.
auto task = _swift_task_clearCurrent();
assert(task && "completing task, but there is no active task registered");
completeTaskImpl(task, context, error);
}
/// The function that we put in the context of a simple task
/// to handle the final return.
SWIFT_CC(swiftasync)
static void completeTaskAndRelease(SWIFT_ASYNC_CONTEXT AsyncContext *context,
SWIFT_CONTEXT SwiftError *error) {
// Set that there's no longer a running task in the current thread.
auto task = _swift_task_clearCurrent();
assert(task && "completing task, but there is no active task registered");
completeTaskImpl(task, context, error);
// Release the task, balancing the retain that a running task has on itself.
// If it was a group child task, it will remain until the group returns it.
swift_release(task);
}
/// The function that we put in the context of a simple task
/// to handle the final return from a closure.
SWIFT_CC(swiftasync)
static void completeTaskWithClosure(SWIFT_ASYNC_CONTEXT AsyncContext *context,
SWIFT_CONTEXT SwiftError *error) {
// Release the closure context.
auto asyncContextPrefix = reinterpret_cast<AsyncContextPrefix *>(
reinterpret_cast<char *>(context) - sizeof(AsyncContextPrefix));
swift_release((HeapObject *)asyncContextPrefix->closureContext);
// Clean up the rest of the task.
return completeTaskAndRelease(context, error);
}
SWIFT_CC(swiftasync)
static void non_future_adapter(SWIFT_ASYNC_CONTEXT AsyncContext *_context) {
auto asyncContextPrefix = reinterpret_cast<AsyncContextPrefix *>(
reinterpret_cast<char *>(_context) - sizeof(AsyncContextPrefix));
return asyncContextPrefix->asyncEntryPoint(
_context, asyncContextPrefix->closureContext);
}
SWIFT_CC(swiftasync)
static void future_adapter(SWIFT_ASYNC_CONTEXT AsyncContext *_context) {
auto asyncContextPrefix = reinterpret_cast<FutureAsyncContextPrefix *>(
reinterpret_cast<char *>(_context) - sizeof(FutureAsyncContextPrefix));
return asyncContextPrefix->asyncEntryPoint(
asyncContextPrefix->indirectResult, _context,
asyncContextPrefix->closureContext);
}
SWIFT_CC(swiftasync)
static void task_wait_throwing_resume_adapter(SWIFT_ASYNC_CONTEXT AsyncContext *_context) {
auto context = static_cast<TaskFutureWaitAsyncContext *>(_context);
auto resumeWithError =
reinterpret_cast<AsyncVoidClosureEntryPoint *>(context->ResumeParent);
return resumeWithError(context->Parent, context->errorResult);
}
SWIFT_CC(swiftasync)
static void
task_future_wait_resume_adapter(SWIFT_ASYNC_CONTEXT AsyncContext *_context) {
return _context->ResumeParent(_context->Parent);
}
/// Implementation of task creation.
SWIFT_CC(swift)
static AsyncTaskAndContext swift_task_create_commonImpl(
size_t rawTaskCreateFlags,
TaskOptionRecord *options,
const Metadata *futureResultType,
FutureAsyncSignature::FunctionType *function, void *closureContext,
size_t initialContextSize) {
TaskCreateFlags taskCreateFlags(rawTaskCreateFlags);
// Propagate task-creation flags to job flags as appropriate.
JobFlags jobFlags(JobKind::Task, taskCreateFlags.getPriority());
jobFlags.task_setIsChildTask(taskCreateFlags.isChildTask());
if (futureResultType) {
jobFlags.task_setIsFuture(true);
assert(initialContextSize >= sizeof(FutureAsyncContext));
}
// Collect the options we know about.
ExecutorRef executor = ExecutorRef::generic();
TaskGroup *group = nullptr;
AsyncLet *asyncLet = nullptr;
void *asyncLetBuffer = nullptr;
bool hasAsyncLetResultBuffer = false;
for (auto option = options; option; option = option->getParent()) {
switch (option->getKind()) {
case TaskOptionRecordKind::Executor:
executor = cast<ExecutorTaskOptionRecord>(option)->getExecutor();
break;
case TaskOptionRecordKind::TaskGroup:
group = cast<TaskGroupTaskOptionRecord>(option)->getGroup();
assert(group && "Missing group");
jobFlags.task_setIsGroupChildTask(true);
break;
case TaskOptionRecordKind::AsyncLet:
asyncLet = cast<AsyncLetTaskOptionRecord>(option)->getAsyncLet();
assert(asyncLet && "Missing async let storage");
jobFlags.task_setIsAsyncLetTask(true);
jobFlags.task_setIsChildTask(true);
break;
case TaskOptionRecordKind::AsyncLetWithBuffer:
auto *aletRecord = cast<AsyncLetWithBufferTaskOptionRecord>(option);
asyncLet = aletRecord->getAsyncLet();
// TODO: Actually digest the result buffer into the async let task
// context, so that we can emplace the eventual result there instead
// of in a FutureFragment.
hasAsyncLetResultBuffer = true;
asyncLetBuffer = aletRecord->getResultBuffer();
assert(asyncLet && "Missing async let storage");
jobFlags.task_setIsAsyncLetTask(true);
jobFlags.task_setIsChildTask(true);
break;
}
}
// Add to the task group, if requested.
if (taskCreateFlags.addPendingGroupTaskUnconditionally()) {
assert(group && "Missing group");
swift_taskGroup_addPending(group, /*unconditionally=*/true);
}
AsyncTask *parent = nullptr;
if (jobFlags.task_isChildTask()) {
parent = swift_task_getCurrent();
assert(parent != nullptr && "creating a child task with no active task");
}
// Inherit the priority of the currently-executing task if unspecified and
// we want to inherit.
if (jobFlags.getPriority() == JobPriority::Unspecified &&
(jobFlags.task_isChildTask() || taskCreateFlags.inheritContext())) {
AsyncTask *currentTask = parent;
if (!currentTask)
currentTask = swift_task_getCurrent();
if (currentTask)
jobFlags.setPriority(currentTask->getPriority());
else if (taskCreateFlags.inheritContext())
jobFlags.setPriority(swift_task_getCurrentThreadPriority());
}
// Adjust user-interactive priorities down to user-initiated.
if (jobFlags.getPriority() == JobPriority::UserInteractive)
jobFlags.setPriority(JobPriority::UserInitiated);
// If there is still no job priority, use the default priority.
if (jobFlags.getPriority() == JobPriority::Unspecified)
jobFlags.setPriority(JobPriority::Default);
// Figure out the size of the header.
size_t headerSize = sizeof(AsyncTask);
if (parent) {
headerSize += sizeof(AsyncTask::ChildFragment);
}
if (group) {
headerSize += sizeof(AsyncTask::GroupChildFragment);
}
if (futureResultType) {
headerSize += FutureFragment::fragmentSize(futureResultType);
// Add the future async context prefix.
headerSize += sizeof(FutureAsyncContextPrefix);
} else {
// Add the async context prefix.
headerSize += sizeof(AsyncContextPrefix);
}
headerSize = llvm::alignTo(headerSize, llvm::Align(alignof(AsyncContext)));
// Allocate the initial context together with the job.
// This means that we never get rid of this allocation.
size_t amountToAllocate = headerSize + initialContextSize;
assert(amountToAllocate % MaximumAlignment == 0);
unsigned initialSlabSize = 512;
void *allocation = nullptr;
if (asyncLet) {
assert(parent);
// If there isn't enough room in the fixed async let allocation to
// set up the initial context, then we'll have to allocate more space
// from the parent.
if (asyncLet->getSizeOfPreallocatedSpace() < amountToAllocate) {
hasAsyncLetResultBuffer = false;
}
// DEPRECATED. This is separated from the above condition because we
// also have to handle an older async let ABI that did not provide
// space for the initial slab in the compiler-generated preallocation.
if (!hasAsyncLetResultBuffer) {
allocation = _swift_task_alloc_specific(parent,
amountToAllocate + initialSlabSize);
} else {
allocation = asyncLet->getPreallocatedSpace();
assert(asyncLet->getSizeOfPreallocatedSpace() >= amountToAllocate
&& "async let does not preallocate enough space for child task");
initialSlabSize = asyncLet->getSizeOfPreallocatedSpace()
- amountToAllocate;
}
} else {
allocation = malloc(amountToAllocate);
}
#if SWIFT_TASK_PRINTF_DEBUG
fprintf(stderr, "[%lu] allocate task %p, parent = %p, slab %u\n",
_swift_get_thread_id(), allocation, parent, initialSlabSize);
#endif
AsyncContext *initialContext =
reinterpret_cast<AsyncContext*>(
reinterpret_cast<char*>(allocation) + headerSize);
// We can't just use `function` because it uses the new async function entry
// ABI -- passing parameters, closure context, indirect result addresses
// directly -- but AsyncTask->ResumeTask expects the signature to be
// `void (*, *, swiftasync *)`.
// Instead we use an adapter. This adaptor should use the storage prefixed to
// the async context to get at the parameters.
// See e.g. FutureAsyncContextPrefix.
if (!futureResultType) {
auto asyncContextPrefix = reinterpret_cast<AsyncContextPrefix *>(
reinterpret_cast<char *>(allocation) + headerSize -
sizeof(AsyncContextPrefix));
asyncContextPrefix->asyncEntryPoint =
reinterpret_cast<AsyncVoidClosureEntryPoint *>(function);
asyncContextPrefix->closureContext = closureContext;
function = non_future_adapter;
assert(sizeof(AsyncContextPrefix) == 3 * sizeof(void *));
} else {
auto asyncContextPrefix = reinterpret_cast<FutureAsyncContextPrefix *>(
reinterpret_cast<char *>(allocation) + headerSize -
sizeof(FutureAsyncContextPrefix));
asyncContextPrefix->asyncEntryPoint =
reinterpret_cast<AsyncGenericClosureEntryPoint *>(function);
function = future_adapter;
asyncContextPrefix->closureContext = closureContext;
assert(sizeof(FutureAsyncContextPrefix) == 4 * sizeof(void *));
}
// Initialize the task so that resuming it will run the given
// function on the initial context.
AsyncTask *task = nullptr;
if (asyncLet) {
// Initialize the refcount bits to "immortal", so that
// ARC operations don't have any effect on the task.
task = new(allocation) AsyncTask(&taskHeapMetadata,
InlineRefCounts::Immortal, jobFlags,
function, initialContext);
} else {
task = new(allocation) AsyncTask(&taskHeapMetadata, jobFlags,
function, initialContext);
}
// Initialize the child fragment if applicable.
if (parent) {
auto childFragment = task->childFragment();
new (childFragment) AsyncTask::ChildFragment(parent);
}
// Initialize the group child fragment if applicable.
if (group) {
auto groupChildFragment = task->groupChildFragment();
new (groupChildFragment) AsyncTask::GroupChildFragment(group);
}
// Initialize the future fragment if applicable.
if (futureResultType) {
assert(task->isFuture());
auto futureFragment = task->futureFragment();
new (futureFragment) FutureFragment(futureResultType);
// Set up the context for the future so there is no error, and a successful
// result will be written into the future fragment's storage.
auto futureAsyncContextPrefix =
reinterpret_cast<FutureAsyncContextPrefix *>(
reinterpret_cast<char *>(allocation) + headerSize -
sizeof(FutureAsyncContextPrefix));
futureAsyncContextPrefix->indirectResult = futureFragment->getStoragePtr();
}
#if SWIFT_TASK_PRINTF_DEBUG
fprintf(stderr, "[%lu] creating task %p with parent %p\n",
_swift_get_thread_id(), task, parent);
#endif
// Initialize the task-local allocator.
initialContext->ResumeParent = reinterpret_cast<TaskContinuationFunction *>(
asyncLet ? &completeTask
: closureContext ? &completeTaskWithClosure
: &completeTaskAndRelease);
if (asyncLet && initialSlabSize > 0) {
assert(parent);
void *initialSlab = (char*)allocation + amountToAllocate;
task->Private.initializeWithSlab(task, initialSlab, initialSlabSize);
} else {
task->Private.initialize(task);
}
// Perform additional linking between parent and child task.
if (parent) {
// If the parent was already cancelled, we carry this flag forward to the child.
//
// In a task group we would not have allowed the `add` to create a child anymore,
// however better safe than sorry and `async let` are not expressed as task groups,
// so they may have been spawned in any case still.
if (swift_task_isCancelled(parent) ||
(group && group->isCancelled()))
swift_task_cancel(task);
// Initialize task locals with a link to the parent task.
task->_private().Local.initializeLinkParent(task, parent);
}
// Configure the initial context.
//
// FIXME: if we store a null pointer here using the standard ABI for
// signed null pointers, then we'll have to authenticate context pointers
// as if they might be null, even though the only time they ever might
// be is the final hop. Store a signed null instead.
initialContext->Parent = nullptr;
initialContext->Flags = AsyncContextKind::Ordinary;
// Attach to the group, if needed.
if (group) {
swift_taskGroup_attachChild(group, task);
}
// If we're supposed to copy task locals, do so now.
if (taskCreateFlags.copyTaskLocals()) {
swift_task_localsCopyTo(task);
}
// Push the async let task status record.
if (asyncLet) {
asyncLet_addImpl(task, asyncLet, !hasAsyncLetResultBuffer);
}
// If we're supposed to enqueue the task, do so now.
if (taskCreateFlags.enqueueJob()) {
swift_retain(task);
swift_task_enqueue(task, executor);
}
return {task, initialContext};
}
/// Extract the entry point address and initial context size from an async closure value.
template<typename AsyncSignature, uint16_t AuthDiscriminator>
SWIFT_ALWAYS_INLINE // so this doesn't hang out as a ptrauth gadget
std::pair<typename AsyncSignature::FunctionType *, size_t>
getAsyncClosureEntryPointAndContextSize(void *function,
HeapObject *functionContext) {
auto fnPtr =
reinterpret_cast<const AsyncFunctionPointer<AsyncSignature> *>(function);
#if SWIFT_PTRAUTH
fnPtr = (const AsyncFunctionPointer<AsyncSignature> *)ptrauth_auth_data(
(void *)fnPtr, ptrauth_key_process_independent_data, AuthDiscriminator);
#endif
return {reinterpret_cast<typename AsyncSignature::FunctionType *>(
fnPtr->Function.get()),
fnPtr->ExpectedContextSize};
}
SWIFT_CC(swift)
AsyncTaskAndContext swift::swift_task_create(
size_t taskCreateFlags,
TaskOptionRecord *options,
const Metadata *futureResultType,
void *closureEntry, HeapObject *closureContext) {
FutureAsyncSignature::FunctionType *taskEntry;
size_t initialContextSize;
std::tie(taskEntry, initialContextSize)
= getAsyncClosureEntryPointAndContextSize<
FutureAsyncSignature,
SpecialPointerAuthDiscriminators::AsyncFutureFunction
>(closureEntry, closureContext);
return swift_task_create_common(
taskCreateFlags, options, futureResultType, taskEntry, closureContext,
initialContextSize);
}
#ifdef __ARM_ARCH_7K__
__attribute__((noinline))
SWIFT_CC(swiftasync) static void workaround_function_swift_task_future_waitImpl(
OpaqueValue *result, SWIFT_ASYNC_CONTEXT AsyncContext *callerContext,
AsyncTask *task, TaskContinuationFunction resumeFunction,
AsyncContext *callContext) {
// Make sure we don't eliminate calls to this function.
asm volatile("" // Do nothing.
: // Output list, empty.
: "r"(result), "r"(callerContext), "r"(task) // Input list.
: // Clobber list, empty.
);
return;
}
#endif
SWIFT_CC(swiftasync)
static void swift_task_future_waitImpl(
OpaqueValue *result,
SWIFT_ASYNC_CONTEXT AsyncContext *callerContext,
AsyncTask *task,
TaskContinuationFunction *resumeFn,
AsyncContext *callContext) {
// Suspend the waiting task.
auto waitingTask = swift_task_getCurrent();
waitingTask->ResumeTask = task_future_wait_resume_adapter;
waitingTask->ResumeContext = callContext;
// Wait on the future.
assert(task->isFuture());
switch (task->waitFuture(waitingTask, callContext, resumeFn, callerContext,
result)) {
case FutureFragment::Status::Executing:
// The waiting task has been queued on the future.
#ifdef __ARM_ARCH_7K__
return workaround_function_swift_task_future_waitImpl(
result, callerContext, task, resumeFn, callContext);
#else
return;
#endif
case FutureFragment::Status::Success: {
// Run the task with a successful result.
auto future = task->futureFragment();
future->getResultType()->vw_initializeWithCopy(result,
future->getStoragePtr());
return resumeFn(callerContext);
}
case FutureFragment::Status::Error:
swift_Concurrency_fatalError(0, "future reported an error, but wait cannot throw");
}
}
#ifdef __ARM_ARCH_7K__
__attribute__((noinline))
SWIFT_CC(swiftasync) static void workaround_function_swift_task_future_wait_throwingImpl(
OpaqueValue *result, SWIFT_ASYNC_CONTEXT AsyncContext *callerContext,
AsyncTask *task, ThrowingTaskFutureWaitContinuationFunction resumeFunction,
AsyncContext *callContext) {
// Make sure we don't eliminate calls to this function.
asm volatile("" // Do nothing.
: // Output list, empty.
: "r"(result), "r"(callerContext), "r"(task) // Input list.
: // Clobber list, empty.
);
return;
}
#endif
SWIFT_CC(swiftasync)
void swift_task_future_wait_throwingImpl(
OpaqueValue *result, SWIFT_ASYNC_CONTEXT AsyncContext *callerContext,
AsyncTask *task,
ThrowingTaskFutureWaitContinuationFunction *resumeFunction,
AsyncContext *callContext) {
auto waitingTask = swift_task_getCurrent();
// Suspend the waiting task.
waitingTask->ResumeTask = task_wait_throwing_resume_adapter;
waitingTask->ResumeContext = callContext;
auto resumeFn = reinterpret_cast<TaskContinuationFunction *>(resumeFunction);
// Wait on the future.
assert(task->isFuture());
switch (task->waitFuture(waitingTask, callContext, resumeFn, callerContext,
result)) {
case FutureFragment::Status::Executing:
// The waiting task has been queued on the future.
#ifdef __ARM_ARCH_7K__
return workaround_function_swift_task_future_wait_throwingImpl(
result, callerContext, task, resumeFunction, callContext);
#else
return;
#endif
case FutureFragment::Status::Success: {
auto future = task->futureFragment();
future->getResultType()->vw_initializeWithCopy(result,
future->getStoragePtr());
return resumeFunction(callerContext, nullptr /*error*/);
}
case FutureFragment::Status::Error: {
// Run the task with an error result.
auto future = task->futureFragment();
auto error = future->getError();
swift_errorRetain(error);
return resumeFunction(callerContext, error);
}
}
}
namespace {
#if SWIFT_CONCURRENCY_COOPERATIVE_GLOBAL_EXECUTOR
class RunAndBlockSemaphore {
bool Finished = false;
public:
void wait() {
donateThreadToGlobalExecutorUntil([](void *context) {
return *reinterpret_cast<bool*>(context);
}, &Finished);
assert(Finished && "ran out of tasks before we were signalled");
}
void signal() {
Finished = true;
}
};
#else
class RunAndBlockSemaphore {
ConditionVariable Queue;
ConditionVariable::Mutex Lock;
bool Finished = false;
public:
/// Wait for a signal.
void wait() {
Lock.withLockOrWait(Queue, [&] {
return Finished;
});
}
void signal() {
Lock.withLockThenNotifyAll(Queue, [&]{
Finished = true;
});
}
};
#endif
using RunAndBlockSignature =
AsyncSignature<void(HeapObject*), /*throws*/ false>;
struct RunAndBlockContext: AsyncContext {
const void *Function;
HeapObject *FunctionContext;
RunAndBlockSemaphore *Semaphore;
};
using RunAndBlockCalleeContext =
AsyncCalleeContext<RunAndBlockContext, RunAndBlockSignature>;
} // end anonymous namespace
/// Second half of the runAndBlock async function.
SWIFT_CC(swiftasync)
static void runAndBlock_finish(SWIFT_ASYNC_CONTEXT AsyncContext *_context) {
auto calleeContext = static_cast<RunAndBlockCalleeContext*>(_context);
auto context = popAsyncContext(calleeContext);
context->Semaphore->signal();
return context->ResumeParent(context);
}
/// First half of the runAndBlock async function.
SWIFT_CC(swiftasync)
static void runAndBlock_start(SWIFT_ASYNC_CONTEXT AsyncContext *_context,
SWIFT_CONTEXT HeapObject *closureContext) {
auto callerContext = static_cast<RunAndBlockContext*>(_context);
RunAndBlockSignature::FunctionType *function;
size_t calleeContextSize;
auto functionContext = callerContext->FunctionContext;
assert(closureContext == functionContext);
std::tie(function, calleeContextSize)
= getAsyncClosureEntryPointAndContextSize<
RunAndBlockSignature,
SpecialPointerAuthDiscriminators::AsyncRunAndBlockFunction
>(const_cast<void*>(callerContext->Function), functionContext);
auto calleeContext =
pushAsyncContext<RunAndBlockSignature>(callerContext,
calleeContextSize,
&runAndBlock_finish,
functionContext);
return reinterpret_cast<AsyncVoidClosureEntryPoint *>(function)(
calleeContext, functionContext);
}
// TODO: Remove this hack.
void swift::swift_task_runAndBlockThread(const void *function,
HeapObject *functionContext) {
RunAndBlockSemaphore semaphore;
// Set up a task that runs the runAndBlock async function above.
auto flags = TaskCreateFlags();
flags.setPriority(JobPriority::Default);
auto pair = swift_task_create_common(
flags.getOpaqueValue(),
/*options=*/nullptr,
/*futureResultType=*/nullptr,
reinterpret_cast<ThinNullaryAsyncSignature::FunctionType *>(
&runAndBlock_start),
nullptr,
sizeof(RunAndBlockContext));
auto context = static_cast<RunAndBlockContext*>(pair.InitialContext);
context->Function = function;
context->FunctionContext = functionContext;
context->Semaphore = &semaphore;
// Enqueue the task.
swift_task_enqueueGlobal(pair.Task);
// Wait until the task completes.
semaphore.wait();
}
size_t swift::swift_task_getJobFlags(AsyncTask *task) {
return task->Flags.getOpaqueValue();
}
SWIFT_CC(swift)
static AsyncTask *swift_task_suspendImpl() {
auto task = _swift_task_clearCurrent();
task->flagAsSuspended();
return task;
}
SWIFT_CC(swift)
static AsyncTask *swift_continuation_initImpl(ContinuationAsyncContext *context,
AsyncContinuationFlags flags) {
context->Flags = AsyncContextKind::Continuation;
if (flags.canThrow()) context->Flags.setCanThrow(true);
if (flags.isExecutorSwitchForced())
context->Flags.continuation_setIsExecutorSwitchForced(true);
context->ErrorResult = nullptr;
// Set the current executor as the target executor unless there's
// an executor override.
if (!flags.hasExecutorOverride())
context->ResumeToExecutor = ExecutorRef::generic();
// We can initialize this with a relaxed store because resumption
// must happen-after this call.
context->AwaitSynchronization.store(flags.isPreawaited()
? ContinuationStatus::Awaited
: ContinuationStatus::Pending,
std::memory_order_relaxed);
AsyncTask *task;
// A preawait immediately suspends the task.
if (flags.isPreawaited()) {
task = _swift_task_clearCurrent();
assert(task && "initializing a continuation with no current task");
task->flagAsSuspended();
} else {
task = swift_task_getCurrent();
assert(task && "initializing a continuation with no current task");
}
task->ResumeContext = context;
task->ResumeTask = context->ResumeParent;
return task;
}
SWIFT_CC(swiftasync)
static void swift_continuation_awaitImpl(ContinuationAsyncContext *context) {
#ifndef NDEBUG
auto task = swift_task_getCurrent();
assert(task && "awaiting continuation without a task");
assert(task->ResumeContext == context);
assert(task->ResumeTask == context->ResumeParent);
#endif
auto &sync = context->AwaitSynchronization;
auto oldStatus = sync.load(std::memory_order_acquire);
assert((oldStatus == ContinuationStatus::Pending ||
oldStatus == ContinuationStatus::Resumed) &&
"awaiting a corrupt or already-awaited continuation");
// If the status is already Resumed, we can resume immediately.
// Comparing against Pending may be very slightly more compact.
if (oldStatus != ContinuationStatus::Pending) {
if (context->isExecutorSwitchForced())
return swift_task_switch(context, context->ResumeParent,
context->ResumeToExecutor);
return context->ResumeParent(context);
}
// Load the current task (we alreaady did this in assertions builds).
#ifdef NDEBUG
auto task = swift_task_getCurrent();
#endif
// Flag the task as suspended.
task->flagAsSuspended();
// Try to transition to Awaited.
bool success =
sync.compare_exchange_strong(oldStatus, ContinuationStatus::Awaited,
/*success*/ std::memory_order_release,
/*failure*/ std::memory_order_acquire);
// If that succeeded, we have nothing to do.
if (success) {
_swift_task_clearCurrent();
return;
}
// If it failed, it should be because someone concurrently resumed
// (note that the compare-exchange above is strong).
assert(oldStatus == ContinuationStatus::Resumed &&
"continuation was concurrently corrupted or awaited");
// Restore the running state of the task and resume it.
task->flagAsRunning();
if (context->isExecutorSwitchForced())
return swift_task_switch(context, context->ResumeParent,
context->ResumeToExecutor);
return context->ResumeParent(context);
}
static void resumeTaskAfterContinuation(AsyncTask *task,
ContinuationAsyncContext *context) {
auto &sync = context->AwaitSynchronization;
auto status = sync.load(std::memory_order_acquire);
assert(status != ContinuationStatus::Resumed &&
"continuation was already resumed");
// Make sure TSan knows that the resume call happens-before the task
// restarting.
_swift_tsan_release(static_cast<Job *>(task));
// The status should be either Pending or Awaited. If it's Awaited,
// which is probably the most likely option, then we should immediately
// enqueue; we don't need to update the state because there shouldn't
// be a racing attempt to resume the continuation. If it's Pending,
// we need to set it to Resumed; if that fails (with a strong cmpxchg),
// it should be because the original thread concurrently set it to
// Awaited, and so we need to enqueue.
if (status == ContinuationStatus::Pending &&
sync.compare_exchange_strong(status, ContinuationStatus::Resumed,
/*success*/ std::memory_order_release,
/*failure*/ std::memory_order_relaxed)) {
return;
}
assert(status == ContinuationStatus::Awaited &&
"detected concurrent attempt to resume continuation");
// TODO: maybe in some mode we should set the status to Resumed here
// to make a stronger best-effort attempt to catch racing attempts to
// resume the continuation?
swift_task_enqueue(task, context->ResumeToExecutor);
}
SWIFT_CC(swift)
static void swift_continuation_resumeImpl(AsyncTask *task) {
auto context = cast<ContinuationAsyncContext>(task->ResumeContext);
resumeTaskAfterContinuation(task, context);
}
SWIFT_CC(swift)
static void swift_continuation_throwingResumeImpl(AsyncTask *task) {
auto context = cast<ContinuationAsyncContext>(task->ResumeContext);
resumeTaskAfterContinuation(task, context);
}
SWIFT_CC(swift)
static void swift_continuation_throwingResumeWithErrorImpl(AsyncTask *task,
/* +1 */ SwiftError *error) {
auto context = cast<ContinuationAsyncContext>(task->ResumeContext);
context->ErrorResult = error;
resumeTaskAfterContinuation(task, context);
}
bool swift::swift_task_isCancelled(AsyncTask *task) {
return task->isCancelled();
}
SWIFT_CC(swift)
static CancellationNotificationStatusRecord*
swift_task_addCancellationHandlerImpl(
CancellationNotificationStatusRecord::FunctionType handler,
void *context) {
void *allocation =
swift_task_alloc(sizeof(CancellationNotificationStatusRecord));
auto unsigned_handler = swift_auth_code(handler, 3848);
auto *record = new (allocation)
CancellationNotificationStatusRecord(unsigned_handler, context);
if (swift_task_addStatusRecord(record))
return record;
// else, the task was already cancelled, so while the record was added,
// we must run it immediately here since no other task will trigger it.
record->run();
return record;
}
SWIFT_CC(swift)
static void swift_task_removeCancellationHandlerImpl(
CancellationNotificationStatusRecord *record) {
swift_task_removeStatusRecord(record);
swift_task_dealloc(record);
}
SWIFT_CC(swift)
static NullaryContinuationJob*
swift_task_createNullaryContinuationJobImpl(
size_t priority,
AsyncTask *continuation) {
void *allocation =
swift_task_alloc(sizeof(NullaryContinuationJob));
auto *job =
new (allocation) NullaryContinuationJob(
swift_task_getCurrent(), static_cast<JobPriority>(priority),
continuation);
return job;
}
SWIFT_CC(swift)
void swift::swift_continuation_logFailedCheck(const char *message) {
swift_reportError(0, message);
}
SWIFT_CC(swift)
static void swift_task_asyncMainDrainQueueImpl() {
#if SWIFT_CONCURRENCY_COOPERATIVE_GLOBAL_EXECUTOR
bool Finished = false;
donateThreadToGlobalExecutorUntil([](void *context) {
return *reinterpret_cast<bool*>(context);
}, &Finished);
#else
#if defined(_WIN32)
static void(FAR *pfndispatch_main)(void) = NULL;
if (pfndispatch_main)
return pfndispatch_main();
HMODULE hModule = LoadLibraryW(L"dispatch.dll");
if (hModule == NULL)
abort();
pfndispatch_main =
reinterpret_cast<void (FAR *)(void)>(GetProcAddress(hModule,
"dispatch_main"));
if (pfndispatch_main == NULL)
abort();
pfndispatch_main();
exit(0);
#else
// CFRunLoop is not available on non-Darwin targets. Foundation has an
// implementation, but CoreFoundation is not meant to be exposed. We can only
// assume the existence of `CFRunLoopRun` on Darwin platforms, where the
// system provides an implementation of CoreFoundation.
#if defined(__APPLE__)
auto runLoop =
reinterpret_cast<void (*)(void)>(dlsym(RTLD_DEFAULT, "CFRunLoopRun"));
if (runLoop) {
runLoop();
exit(0);
}
#endif
dispatch_main();
#endif
#endif
}
#define OVERRIDE_TASK COMPATIBILITY_OVERRIDE
#include COMPATIBILITY_OVERRIDE_INCLUDE_PATH
|
; 23 - Utilizar ciclo anidado para formar un cuadrado espaciado
; López Garay Luis Felipe
; 15211312
; 14 de Octubre del 2018
.model small
.stack 64
.data
char db '*'
espacio db 3
n_cols dw 20
n_rows dw 6
.code
MAIN PROC
mov ax,@Data
mov ds,ax
mov ah,00h
mov al,03h
int 10h
mov cx,n_rows
CICLO_EXTERNO:
push cx
mov cx,n_cols
CICLO_INTERNO:
; Fila multiplicada
pop ax
push ax
mul espacio
mov dh,al
; Columna multiplicada
mov ax,cx
mul espacio
mov dl,al
; Mover cursor
mov ah,2h
int 10h
; Imprimir caracter
mov dl,char
mov ah,02h
int 21h
loop CICLO_INTERNO
pop cx
loop CICLO_EXTERNO
.exit
ENDP
end MAIN
|
#ifndef EASY_BO_ALGORITHMS_HPP_INCLUDED
#define EASY_BO_ALGORITHMS_HPP_INCLUDED
#include "easy_bo_math.hpp"
namespace easy_bo {
/** \brief Рассчитать центройд окружности
*
* Данная функция принимает на вход массив исхода бинарных опционов, где 1 - удачная сделка, 0 - убыточная сделка.
* Или можно подать на вход профит. Функция найдет модуль вектора между центром окружности и центром ее тяжести.
* Самое лучшее значение данного коэффициента - 0. Самое худшее значение - 1.0
* Функция также имеет настройки через шаблоны.
* is_binary - Флаг указывает, что мы используем бинарные данные.
* is_use_negative - Флаг указывает, что мы используем убыточные сделки как отрицательную массу.
* \param array_profit Массив результата сделок
* \param array_profit_size Размер массива результата сделок
* \param revolutions Количество оборотов окружности, по умолчанию 1. Можно взять 3,5,7 оборота, чтобы исключить влияние повторяющихся неоднородностей
* \return модуль вектора между центром окружности и центром ее тяжести
*/
template<const bool is_binary, const bool is_use_negative, class ARRAY_TYPE>
float calc_centroid_circle(const ARRAY_TYPE &array_profit, const size_t array_profit_size, const uint32_t revolutions = 1) {
if(!easy_bo_math::is_generate_table) easy_bo_math::generate_table_sin_cos();
const double PI = 3.1415926535897932384626433832795;
const double PI_X2 = PI * 2.0;
float angle = 0.0;
float step = (float)((PI_X2 * (double)revolutions) / (double)array_profit_size);
float sum_x = 0.0, sum_y = 0.0;
float center_x = 0.0, center_y = 0.0;
uint32_t counter = 0;
for(size_t i = 0; i < array_profit_size; ++i, angle += step) {
/* если "вес" элемента массива нулевой, нет смысла обрабатывать его */
if(!is_use_negative) {
if(array_profit[i] == 0) continue;
++counter;
}
float mass_x, mass_y;
if(angle > PI_X2) {
easy_bo_math::get_sin_cos(mass_x, mass_y, angle - ((uint32_t)(angle / PI_X2)) * PI_X2);
} else {
easy_bo_math::get_sin_cos(mass_x, mass_y, angle);
}
if(is_binary) {
/* если "вес" элемента массива нулевой, вычитаем */
if(array_profit[i] == 0) {
sum_x -= mass_x;
sum_y -= mass_y;
} else {
sum_x += mass_x;
sum_y += mass_y;
}
} else {
sum_x += array_profit[i] * mass_x;
sum_y += array_profit[i] * mass_y;
}
}
if(is_use_negative) counter = array_profit_size;
center_x = sum_x / (float)counter;
center_y = sum_y / (float)counter;
float temp = center_x * center_x + center_y * center_y;
if(temp == 0.0) return 0.0;
return 1.0/easy_bo_math::inv_sqrt(temp);
}
/** \brief Найти коэффициент лучшей стратегии
*
* Данная функция находит расстояне между лучшей точкой 3D пространства и точкой стратегии
* Три оси 3D пространства соответствуют инверсному винрейту, стабильности стратегии (0 - лучшая стабильность), и инверсному количеству сделок
* \param winrate Винрейт. Принимает значения от 0 до 1
* \param stability Стабильность. Принимает значения от 0 до 1. Лучшее значение 0.
* \param amount_deals Количество сделок
* \param max_amount_deals Максимальное количество сделок
* \param a1 Коэффициент корректировки
* \param a2 Коэффициент корректировки
* \param b1 Коэффициент корректировки
* \param b2 Коэффициент корректировки
* \param c1 Коэффициент корректировки
* \param c2 Коэффициент корректировки
* \return коэффициент лучшей стратегии
*/
float calc_coeff_best3D(
const float winrate,
const float stability,
const float amount_deals,
const float max_amount_deals,
const float a1 = 1.0,
const float a2 = 1.0,
const float b1 = 1.0,
const float b2 = 0.0,
const float c1 = 1.0,
const float c2 = 1.0) {
const float inv_winrate = a1 * (1.0 - winrate * a2);
const float update_stability = stability * b1 + b2;
const float relative_amount_deals = c1 * (1.0 - (amount_deals / max_amount_deals) * c2);
const float temp = inv_winrate * inv_winrate + relative_amount_deals * relative_amount_deals + update_stability * update_stability;
if(temp == 0.0) return 0.0;
return 1.0/easy_bo_math::inv_sqrt(temp);
}
}
#endif // EASY_BO_ALGORITHMS_HPP_INCLUDED
|
; A267811: Binary representation of the n-th iteration of the "Rule 217" elementary cellular automaton starting with a single ON (black) cell.
; Submitted by Jamie Morken(s2.)
; 1,1,11011,1110111,111101111,11111011111,1111110111111,111111101111111,11111111011111111,1111111110111111111,111111111101111111111,11111111111011111111111,1111111111110111111111111,111111111111101111111111111,11111111111111011111111111111,1111111111111110111111111111111,111111111111111101111111111111111,11111111111111111011111111111111111,1111111111111111110111111111111111111,111111111111111111101111111111111111111,11111111111111111111011111111111111111111
lpb $0
mov $2,$0
mov $0,1
seq $2,332120 ; a(n) = 2*(10^(2n+1)-1)/9 - 2*10^n.
lpe
mov $0,$2
div $0,4
mul $0,2
add $0,1
|
%ifdef CONFIG
{
"RegData": {
"RAX": "0xB1B2B3B4B5B6B7B8",
"RSI": "0xE0000040"
},
"MemoryRegions": {
"0x100000000": "4096"
}
}
%endif
mov rdx, 0xe0000000
mov rax, 0x4142434445464748
mov [rdx + 8 * 0], rax
mov rax, 0x5152535455565758
mov [rdx + 8 * 1], rax
mov rax, 0x6162636465666768
mov [rdx + 8 * 2], rax
mov rax, 0x7172737475767778
mov [rdx + 8 * 3], rax
mov rax, 0x8182838485868788
mov [rdx + 8 * 4], rax
mov rax, 0x9192939495969798
mov [rdx + 8 * 5], rax
mov rax, 0xA1A2A3A4A5A6A7A8
mov [rdx + 8 * 6], rax
mov rax, 0xB1B2B3B4B5B6B7B8
mov [rdx + 8 * 7], rax
mov rax, 0x0
mov [rdx + 8 * 8], rax
lea rsi, [rdx + 8 * 0]
cld
mov rax, 0xFF
lodsq
lodsq
lodsq
lodsq
lodsq
lodsq
lodsq
lodsq
hlt
|
; A292643: Rank of (5+r)*n when all the numbers (5-r)*j and (5+r)*k, where r = sqrt(2), j>=1, k>=1, are jointly ranked.
; Submitted by Jamie Morken(w1)
; 2,5,8,11,13,16,19,22,25,27,30,33,36,39,41,44,47,50,52,55,58,61,64,66,69,72,75,78,80,83,86,89,92,94,97,100,103,105,108,111,114,117,119,122,125,128,131,133,136,139,142,145,147,150,153,156,158,161,164,167,170,172,175,178,181,184,186,189,192,195,198,200,203,206,209,211,214,217,220,223,225,228,231,234,237,239,242,245,248,250,253,256,259,262,264,267,270,273,276,278
mov $4,$0
mov $8,$0
lpb $4
mov $0,$8
sub $4,1
sub $0,$4
mov $10,2
mov $11,0
mov $12,$0
lpb $10
mov $0,$12
mov $2,0
mov $5,0
mov $6,0
sub $10,1
add $0,$10
trn $0,1
add $0,1
mov $1,1
mov $3,$0
lpb $3
add $2,$1
mul $1,2
add $6,$2
add $1,$6
add $1,$2
add $2,$1
sub $3,1
add $5,$2
add $6,$5
lpe
mul $1,$0
div $1,$2
add $3,7
mul $1,$3
mov $0,$1
mov $9,$10
mul $9,$1
add $11,$9
lpe
min $12,1
mul $12,$0
mov $0,$11
sub $0,$12
div $0,7
add $0,2
add $7,$0
lpe
mov $0,$7
add $0,2
|
; A036496: Number of lines that intersect the first n points on a spiral on a triangular lattice. The spiral starts at (0,0), goes to (1,0) and (1/2, sqrt(3)/2) and continues counterclockwise.
; 0,3,5,6,7,8,9,9,10,11,11,12,12,13,13,14,14,15,15,15,16,16,17,17,17,18,18,18,19,19,19,20,20,20,21,21,21,21,22,22,22,23,23,23,23,24,24,24,24,25,25,25,25,26,26,26,26,27,27,27,27,27,28,28,28,28,29,29,29,29,29,30,30,30,30,30,31,31,31,31,31,32,32,32,32,32,33,33,33,33,33,33,34,34,34,34,34,35,35,35
mul $0,3
trn $0,1
seq $0,235382 ; a(n) = smallest number of unit squares required to enclose n units of area.
div $0,2
sub $0,2
|
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Copyright (c) GeoWorks 1991 -- All Rights Reserved
PROJECT: PC GEOS
MODULE:
FILE: uiToolControl.asm
AUTHOR: Jon Witort
METHODS:
Name Description
---- -----------
FUNCTIONS:
Scope Name Description
----- ---- -----------
REVISION HISTORY:
Name Date Description
---- ---- -----------
jon 24 feb 1992 Initial version.
DESCRIPTION:
Code for the GrObjToolControlClass
$Id: uiToolControl.asm,v 1.1 97/04/04 18:06:18 newdeal Exp $
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
GrObjUIControllerCode segment resource
COMMENT @----------------------------------------------------------------------
MESSAGE: GrObjToolControlGetInfo --
MSG_GEN_CONTROL_GET_INFO for GrObjToolControlClass
DESCRIPTION: Return group
PASS:
*ds:si - instance data
es - segment of GrObjToolControlClass
ax - The message
cx:dx - GenControlBuildInfo structure to fill in
RETURN:
none
DESTROYED:
bx, si, di, ds, es (message handler)
REGISTER/STACK USAGE:
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
Tony 10/31/91 Initial version
------------------------------------------------------------------------------@
GrObjToolControlGetInfo method dynamic GrObjToolControlClass,
MSG_GEN_CONTROL_GET_INFO
mov si, offset GOTC_dupInfo
call CopyDupInfoCommon
ret
GrObjToolControlGetInfo endm
GOTC_dupInfo GenControlBuildInfo <
0, ; GCBI_flags
GOTC_IniFileKey, ; GCBI_initFileKey
GOTC_gcnList, ; GCBI_gcnList
length GOTC_gcnList, ; GCBI_gcnCount
GOTC_notifyList, ; GCBI_notificationList
length GOTC_notifyList, ; GCBI_notificationCount
GOTCName, ; GCBI_controllerName
0, ; GCBI_dupBlock
0, ; GCBI_childList
0, ; GCBI_childCount
0, ; GCBI_featuresList
0, ; GCBI_featuresCount
0, ; GCBI_features
handle GrObjToolControlToolboxUI, ; GCBI_toolBlock
GOTC_toolList, ; GCBI_toolList
length GOTC_toolList, ; GCBI_toolCount
GOTC_toolFeaturesList, ; GCBI_toolFeaturesList
length GOTC_toolFeaturesList, ; GCBI_toolFeaturesCount
GOTC_DEFAULT_TOOLBOX_FEATURES, ; GCBI_toolFeatures
GOTC_helpContext> ; GCBI_helpContext
if FULL_EXECUTE_IN_PLACE
GrObjControlInfoXIP segment resource
endif
GOTC_helpContext char "dbGrObjTool", 0
GOTC_IniFileKey char "GrObjTool", 0
GOTC_gcnList GCNListType \
<MANUFACTURER_ID_GEOWORKS,
GAGCNLT_APP_TARGET_NOTIFY_GROBJ_CURRENT_TOOL_CHANGE>
GOTC_notifyList NotificationType \
<MANUFACTURER_ID_GEOWORKS, GWNT_GROBJ_CURRENT_TOOL_CHANGE>
;---
GOTC_toolList GenControlChildInfo \
<offset GrObjToolItemGroup, mask GOTCFeatures, mask GCCF_ALWAYS_ADD>
GOTC_toolFeaturesList GenControlFeaturesInfo \
<offset SplineExcl, SplineName, 0>,
<offset PolycurveExcl, PolycurveName, 0>,
<offset PolylineExcl, PolylineName, 0>,
<offset ArcExcl, ArcName, 0>,
<offset EllipseExcl, EllipseName, 0>,
<offset RoundedRectExcl, RoundedRectName, 0>,
<offset RectExcl, RectName, 0>,
<offset LineExcl, LineName, 0>,
<offset TextExcl, TextName, 0>,
<offset ZoomExcl, ZoomName, 0>,
<offset RotatePtrExcl, RotatePtrName, 0>,
<offset PtrExcl, PtrName, 0>
if FULL_EXECUTE_IN_PLACE
GrObjControlInfoXIP ends
endif
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
GrObjToolItemGroupSelectSelfIfMatch
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Description: GrObjToolItem method for MSG_GOTI_SELECT_SELF_IF_MATCH
Called by:
Pass: *ds:si = GrObjToolItem object
ds:di = GrObjToolItem instance
cx:dx = current tool class
bp = specific initialize data
Return: nothing
Destroyed: nothing
Comments:
Revision History:
Name Date Description
---- ------------ -----------
jon Mar 31, 1992 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
GrObjToolItemSelectSelfIfMatch method GrObjToolItemClass, MSG_GOTI_SELECT_SELF_IF_MATCH
cmp dx, ds:[di].GOTII_toolClass.offset
je checkSegment
done:
ret
checkSegment:
cmp cx, ds:[di].GOTII_toolClass.segment
jne done
cmp bp, ds:[di].GOTII_specInitData
jne done
push ax, cx, dx, bp ;save regs
;
; The instance data matches the passed data; tell our
; parent to select us
;
mov ax, MSG_GEN_ITEM_GET_IDENTIFIER
call ObjCallInstanceNoLock
mov_tr cx, ax ;cx <- identifier
clr dx ;not indeterminate
mov ax, MSG_GEN_ITEM_GROUP_SET_SINGLE_SELECTION
call GenCallParent
pop ax, cx, dx, bp ;restore regs
jmp done
GrObjToolItemSelectSelfIfMatch endm
COMMENT @----------------------------------------------------------------------
MESSAGE: GrObjToolControlUpdateUI -- MSG_GEN_CONTROL_UPDATE_UI
for GrObjToolControlClass
DESCRIPTION: Handle notification of type change
PASS:
*ds:si - instance data
es - segment of GrObjToolControlClass
ax - MSG_GEN_CONTROL_UPDATE_UI
ss:bp - GenControlUpdateUIParams
RETURN: nothing
DESTROYED:
bx, si, di, ds, es (message handler)
REGISTER/STACK USAGE:
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
jon 11 feb 1992 Initial version
------------------------------------------------------------------------------@
GrObjToolControlUpdateUI method GrObjToolControlClass,
MSG_GEN_CONTROL_UPDATE_UI
uses ax, cx, dx, bp
.enter
test ss:[bp].GCUUIP_toolboxFeatures, mask GOTCFeatures
LONG jz done
;
; Suck out the info we need
;
push ds:[LMBH_handle] ;save object handle
;
; Get GrObjToolItemGroup's OD for later
;
push ss:[bp].GCUUIP_toolBlock
mov bx, ss:[bp].GCUUIP_dataBlock
call MemLock
mov ds, ax
movdw cxdx, ds:[GONCT_toolClass]
mov bp, ds:[GONCT_specInitData]
call MemUnlock
;
; Create a classed event to send to the tool list entries.
;
; di <- event handle
;
mov bx, segment GrObjToolItemClass
mov si, offset GrObjToolItemClass
mov ax, MSG_GOTI_SELECT_SELF_IF_MATCH
mov di, mask MF_RECORD
call ObjMessage
;
; Set the list indeterminate to begin with
;
pop bx ;^lbx:si <- list
mov si, offset GrObjToolItemGroup
cmpdw cxdx, -1 ;save tool class
pushf ;Z if null class
push di ;save event handle
mov ax, MSG_GEN_ITEM_GROUP_SET_MODIFIED_STATE
mov cx, 1 ;set modified
clr di
call ObjMessage
;
; Send the message to the tool list
; (event handle freed by the list)
;
pop cx ;cx <- event handle
mov ax, MSG_GEN_SEND_TO_CHILDREN
clr di
call ObjMessage
mov ax, MSG_GEN_ITEM_GROUP_IS_MODIFIED
mov di, mask MF_CALL
call ObjMessage
jnc afterSelect
mov ax, MSG_GEN_ITEM_GROUP_SET_SINGLE_SELECTION
mov dx, 1 ;non-determinate
clr di
call ObjMessage
afterSelect:
popf ;Z if null class
pop di ;di <- obj handle
je done
;
; Send a null bitmap message just for kicks
;
mov bx, size VisBitmapNotifyCurrentTool
call GrObjGlobalAllocNotifyBlock
call MemLock
mov ds, ax
movdw ds:[VBNCT_toolClass], -1
call MemUnlock
mov_tr ax, bx ;ax <- notif block
mov bx, di ;bx <- obj handle
call MemDerefDS
mov_tr bx, ax ;ax <- notif block
mov cx, GAGCNLT_APP_TARGET_NOTIFY_BITMAP_CURRENT_TOOL_CHANGE
mov dx, GWNT_BITMAP_CURRENT_TOOL_CHANGE
call GrObjGlobalUpdateControllerLow
done:
.leave
ret
GrObjToolControlUpdateUI endm
GrObjUIControllerCode ends
GrObjUIControllerActionCode segment resource
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
GrObjToolControlSetTool
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Description: GrObjToolControl method for MSG_GOTC_SET_TOOL
Called by:
Pass: *ds:si = GrObjToolControl object
ds:di = GrObjToolControl instance
cx = identifier
Return: nothing
Destroyed: bx, di
Comments:
Revision History:
Name Date Description
---- ------------ -----------
jon Feb 27, 1992 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
GrObjToolControlSetTool method GrObjToolControlClass, MSG_GOTC_SET_TOOL
uses ax, cx, dx, bp
.enter
call GetToolBlockAndFeatures
test ax, mask GOTCFeatures
jz done
push si
mov si, offset GrObjToolItemGroup
mov ax, MSG_GEN_ITEM_GROUP_GET_ITEM_OPTR
mov di, mask MF_FIXUP_DS or mask MF_CALL
call ObjMessage
mov bx, cx
mov si, dx
mov ax, MSG_GOTI_GET_TOOL_CLASS
mov di, mask MF_FIXUP_DS or mask MF_CALL
call ObjMessage
pop si
mov ax, MSG_GH_SET_CURRENT_TOOL
mov bx, segment GrObjHeadClass
mov di, offset GrObjHeadClass
call GenControlOutputActionRegs
done:
.leave
ret
GrObjToolControlSetTool endm
;----
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
GrObjToolItemGetToolClass
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Description: GrObjToolItemGroupEntry method for MSG_GOTI_GET_TOOL_CLASS
Called by:
Pass: *ds:si = GrObjToolItemGroupEntry object
ds:di = GrObjToolItemGroupEntry instance
Return: cxdx = tool class
bp = specific initialize data
Destroyed: nothing
Comments:
Revision History:
Name Date Description
---- ------------ -----------
jon Mar 23, 1992 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
GrObjToolItemGetToolClass method GrObjToolItemClass, MSG_GOTI_GET_TOOL_CLASS
.enter
movdw cxdx, ds:[di].GOTII_toolClass
mov bp, ds:[di].GOTII_specInitData
.leave
ret
GrObjToolItemGetToolClass endm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
GrObjToolControlAddAppToolboxUI
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Description: GrObjToolControl method adding children
Called by: GenControl
Pass: *ds:si = GrObjToolControl object
ds:di = GrObjToolControl instance
^lcx:dx = GrObjToolItem
Return: nothing
Destroyed: nothing
Comments:
Revision History:
Name Date Description
---- ------------ -----------
jon Mar 23, 1992 Initial version.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
GrObjToolControlAddAppToolboxUI method GrObjToolControlClass,
MSG_GEN_CONTROL_ADD_APP_TOOLBOX_UI
uses ax, bp
.enter
mov bp, CCO_LAST ;default is at end
mov ax, ATTR_GROBJ_TOOL_CONTROL_POSITION_FOR_ADDED_TOOLS
call ObjVarFindData
jnc 10$
mov bp, ds:[bx]
10$:
call GetToolBlockAndFeatures
test ax, mask GOTCFeatures
jz done
mov si, offset GrObjToolItemGroup
mov ax, MSG_GEN_ADD_CHILD
clr di
call ObjMessage
done:
.leave
ret
GrObjToolControlAddAppToolboxUI endm
GrObjUIControllerActionCode ends
|
; A190176: a(n) = n^4 + 2^4 + (n+2)^4.
; 32,98,288,722,1568,3042,5408,8978,14112,21218,30752,43218,59168,79202,103968,134162,170528,213858,264992,324818,394272,474338,566048,670482,788768,922082,1071648,1238738,1424672,1630818,1858592,2109458,2384928,2686562,3015968,3374802,3764768,4187618,4645152,5139218,5671712,6244578,6859808,7519442,8225568,8980322,9785888,10644498,11558432,12530018,13561632,14655698,15814688,17041122,18337568,19706642,21151008,22673378,24276512,25963218,27736352,29598818,31553568,33603602,35751968,38001762,40356128,42818258,45391392,48078818,50883872,53809938,56860448,60038882,63348768,66793682,70377248,74103138,77975072,81996818,86172192,90505058,94999328,99658962,104487968,109490402,114670368,120032018,125579552,131317218,137249312,143380178,149714208,156255842,163009568,169979922,177171488,184588898,192236832,200120018,208243232,216611298,225229088,234101522,243233568,252630242,262296608,272237778,282458912,292965218,303761952,314854418,326247968,337948002,349959968,362289362,374941728,387922658,401237792,414892818,428893472,443245538,457954848,473027282,488468768,504285282,520482848,537067538,554045472,571422818,589205792,607400658,626013728,645051362,664519968,684426002,704775968,725576418,746833952,768555218,790746912,813415778,836568608,860212242,884353568,908999522,934157088,959833298,986035232,1012770018,1040044832,1067866898,1096243488,1125181922,1154689568,1184773842,1215442208,1246702178,1278561312,1311027218,1344107552,1377810018,1412142368,1447112402,1482727968,1518996962,1555927328,1593527058,1631804192,1670766818,1710423072,1750781138,1791849248,1833635682,1876148768,1919396882,1963388448,2008131938,2053635872,2099908818,2146959392,2194796258,2243428128,2292863762,2343111968,2394181602,2446081568,2498820818,2552408352,2606853218,2662164512,2718351378,2775423008,2833388642,2892257568,2952039122,3012742688,3074377698,3136953632,3200480018,3264966432,3330422498,3396857888,3464282322,3532705568,3602137442,3672587808,3744066578,3816583712,3890149218,3964773152,4040465618,4117236768,4195096802,4274055968,4354124562,4435312928,4517631458,4601090592,4685700818,4771472672,4858416738,4946543648,5035864082,5126388768,5218128482,5311094048,5405296338,5500746272,5597454818,5695432992,5794691858,5895242528,5997096162,6100263968,6204757202,6310587168,6417765218,6526302752,6636211218,6747502112,6860186978,6974277408,7089785042,7206721568,7325098722,7444928288,7566222098,7688992032,7813250018
add $0,1
pow $0,2
add $0,3
pow $0,2
mov $1,$0
mul $1,2
|
; A016851: a(n) = (5*n)^3.
; 0,125,1000,3375,8000,15625,27000,42875,64000,91125,125000,166375,216000,274625,343000,421875,512000,614125,729000,857375,1000000,1157625,1331000,1520875,1728000,1953125,2197000,2460375,2744000,3048625,3375000,3723875,4096000,4492125,4913000,5359375,5832000,6331625,6859000,7414875,8000000,8615125,9261000,9938375,10648000,11390625,12167000,12977875,13824000,14706125,15625000,16581375,17576000,18609625,19683000,20796875,21952000,23149125,24389000,25672375,27000000,28372625,29791000,31255875,32768000,34328125,35937000,37595375,39304000,41063625,42875000,44738875,46656000,48627125,50653000,52734375,54872000,57066625,59319000,61629875,64000000,66430125,68921000,71473375,74088000,76765625,79507000,82312875,85184000,88121125,91125000,94196375,97336000,100544625,103823000,107171875,110592000,114084125,117649000,121287375,125000000,128787625,132651000,136590875,140608000,144703125,148877000,153130375,157464000,161878625,166375000,170953875,175616000,180362125,185193000,190109375,195112000,200201625,205379000,210644875,216000000,221445125,226981000,232608375,238328000,244140625,250047000,256047875,262144000,268336125,274625000,281011375,287496000,294079625,300763000,307546875,314432000,321419125,328509000,335702375,343000000,350402625,357911000,365525875,373248000,381078125,389017000,397065375,405224000,413493625,421875000,430368875,438976000,447697125,456533000,465484375,474552000,483736625,493039000,502459875,512000000,521660125,531441000,541343375,551368000,561515625,571787000,582182875,592704000,603351125,614125000,625026375,636056000,647214625,658503000,669921875,681472000,693154125,704969000,716917375,729000000,741217625,753571000,766060875,778688000,791453125,804357000,817400375,830584000,843908625,857375000,870983875,884736000,898632125,912673000,926859375,941192000,955671625,970299000,985074875,1000000000,1015075125,1030301000,1045678375,1061208000,1076890625,1092727000,1108717875,1124864000,1141166125,1157625000,1174241375,1191016000,1207949625,1225043000,1242296875,1259712000,1277289125,1295029000,1312932375,1331000000,1349232625,1367631000,1386195875,1404928000,1423828125,1442897000,1462135375,1481544000,1501123625,1520875000,1540798875,1560896000,1581167125,1601613000,1622234375,1643032000,1664006625,1685159000,1706489875,1728000000,1749690125,1771561000,1793613375,1815848000,1838265625,1860867000,1883652875,1906624000,1929781125
mov $1,$0
mul $1,5
pow $1,3
|
.global s_prepare_buffers
s_prepare_buffers:
push %r13
push %r14
push %r8
push %rbp
push %rbx
push %rcx
push %rdi
push %rdx
push %rsi
lea addresses_A_ht+0xae94, %r8
nop
nop
add %rdi, %rdi
and $0xffffffffffffffc0, %r8
vmovaps (%r8), %ymm3
vextracti128 $0, %ymm3, %xmm3
vpextrq $0, %xmm3, %rbp
nop
nop
nop
nop
nop
sub %r13, %r13
lea addresses_WT_ht+0xb979, %rdx
nop
nop
nop
dec %r14
mov (%rdx), %bx
nop
sub %rbx, %rbx
lea addresses_WT_ht+0xcdbc, %rsi
lea addresses_A_ht+0x1bf14, %rdi
nop
sub $31648, %rdx
mov $111, %rcx
rep movsq
nop
nop
cmp %r8, %r8
lea addresses_D_ht+0x1ab24, %r8
nop
nop
nop
nop
nop
add $64447, %rdx
vmovups (%r8), %ymm1
vextracti128 $1, %ymm1, %xmm1
vpextrq $1, %xmm1, %rbp
nop
nop
nop
nop
dec %rbx
lea addresses_WT_ht+0x13614, %rsi
lea addresses_D_ht+0x17414, %rdi
nop
nop
nop
nop
cmp %rbp, %rbp
mov $90, %rcx
rep movsw
nop
nop
nop
nop
cmp $55642, %rdi
lea addresses_UC_ht+0x8c14, %rsi
lea addresses_D_ht+0xa094, %rdi
nop
dec %r13
mov $48, %rcx
rep movsq
nop
nop
nop
nop
dec %rdi
lea addresses_A_ht+0x11e14, %rdi
nop
nop
nop
nop
nop
add %rsi, %rsi
movb $0x61, (%rdi)
nop
lfence
lea addresses_D_ht+0x16414, %rsi
lea addresses_UC_ht+0x17c14, %rdi
nop
nop
nop
cmp %r14, %r14
mov $88, %rcx
rep movsb
nop
nop
nop
nop
nop
xor $44138, %rbp
pop %rsi
pop %rdx
pop %rdi
pop %rcx
pop %rbx
pop %rbp
pop %r8
pop %r14
pop %r13
ret
.global s_faulty_load
s_faulty_load:
push %r11
push %r12
push %r8
push %rax
push %rcx
push %rdx
push %rsi
// Store
lea addresses_normal+0x7904, %rdx
nop
and $9815, %rsi
movw $0x5152, (%rdx)
xor $1163, %r11
// Load
lea addresses_PSE+0x1fb44, %rcx
clflush (%rcx)
add %r12, %r12
vmovups (%rcx), %ymm4
vextracti128 $0, %ymm4, %xmm4
vpextrq $0, %xmm4, %r8
nop
nop
dec %r11
// Store
lea addresses_normal+0xd014, %r11
nop
nop
nop
inc %rsi
movb $0x51, (%r11)
nop
nop
xor $28146, %rsi
// Store
mov $0x414, %rcx
xor $5760, %rdx
mov $0x5152535455565758, %rsi
movq %rsi, (%rcx)
nop
inc %r11
// Load
mov $0x6e0, %rsi
clflush (%rsi)
nop
nop
nop
dec %rax
movb (%rsi), %r12b
cmp $19249, %r8
// Faulty Load
lea addresses_PSE+0x2c14, %rdx
nop
nop
nop
nop
and %rax, %rax
movups (%rdx), %xmm6
vpextrq $1, %xmm6, %rcx
lea oracles, %r12
and $0xff, %rcx
shlq $12, %rcx
mov (%r12,%rcx,1), %rcx
pop %rsi
pop %rdx
pop %rcx
pop %rax
pop %r8
pop %r12
pop %r11
ret
/*
<gen_faulty_load>
[REF]
{'src': {'congruent': 0, 'AVXalign': False, 'same': False, 'size': 1, 'NT': False, 'type': 'addresses_PSE'}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'congruent': 3, 'AVXalign': False, 'same': False, 'size': 2, 'NT': False, 'type': 'addresses_normal'}}
{'src': {'congruent': 4, 'AVXalign': False, 'same': False, 'size': 32, 'NT': False, 'type': 'addresses_PSE'}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'congruent': 9, 'AVXalign': False, 'same': False, 'size': 1, 'NT': False, 'type': 'addresses_normal'}}
{'OP': 'STOR', 'dst': {'congruent': 11, 'AVXalign': False, 'same': False, 'size': 8, 'NT': False, 'type': 'addresses_P'}}
{'src': {'congruent': 2, 'AVXalign': False, 'same': False, 'size': 1, 'NT': False, 'type': 'addresses_P'}, 'OP': 'LOAD'}
[Faulty Load]
{'src': {'congruent': 0, 'AVXalign': False, 'same': True, 'size': 16, 'NT': False, 'type': 'addresses_PSE'}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'src': {'congruent': 6, 'AVXalign': True, 'same': False, 'size': 32, 'NT': False, 'type': 'addresses_A_ht'}, 'OP': 'LOAD'}
{'src': {'congruent': 0, 'AVXalign': False, 'same': False, 'size': 2, 'NT': False, 'type': 'addresses_WT_ht'}, 'OP': 'LOAD'}
{'src': {'congruent': 2, 'same': False, 'type': 'addresses_WT_ht'}, 'OP': 'REPM', 'dst': {'congruent': 3, 'same': False, 'type': 'addresses_A_ht'}}
{'src': {'congruent': 3, 'AVXalign': False, 'same': False, 'size': 32, 'NT': False, 'type': 'addresses_D_ht'}, 'OP': 'LOAD'}
{'src': {'congruent': 9, 'same': False, 'type': 'addresses_WT_ht'}, 'OP': 'REPM', 'dst': {'congruent': 11, 'same': False, 'type': 'addresses_D_ht'}}
{'src': {'congruent': 11, 'same': False, 'type': 'addresses_UC_ht'}, 'OP': 'REPM', 'dst': {'congruent': 6, 'same': False, 'type': 'addresses_D_ht'}}
{'OP': 'STOR', 'dst': {'congruent': 8, 'AVXalign': False, 'same': False, 'size': 1, 'NT': False, 'type': 'addresses_A_ht'}}
{'src': {'congruent': 11, 'same': True, 'type': 'addresses_D_ht'}, 'OP': 'REPM', 'dst': {'congruent': 11, 'same': False, 'type': 'addresses_UC_ht'}}
{'33': 14433}
33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33
*/
|
// Boost.Geometry (aka GGL, Generic Geometry Library)
// Copyright (c) 2015 Barend Gehrels, Amsterdam, the Netherlands.
// This file was modified by Oracle on 2017.
// Modifications copyright (c) 2017 Oracle and/or its affiliates.
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
// Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_HANDLE_COLOCATIONS_HPP
#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_HANDLE_COLOCATIONS_HPP
#include <cstddef>
#include <algorithm>
#include <map>
#include <vector>
#include <boost/core/ignore_unused.hpp>
#include <boost/range.hpp>
#include <boost/geometry/core/point_order.hpp>
#include <boost/geometry/algorithms/detail/overlay/cluster_info.hpp>
#include <boost/geometry/algorithms/detail/overlay/do_reverse.hpp>
#include <boost/geometry/algorithms/detail/overlay/is_self_turn.hpp>
#include <boost/geometry/algorithms/detail/overlay/overlay_type.hpp>
#include <boost/geometry/algorithms/detail/overlay/sort_by_side.hpp>
#include <boost/geometry/algorithms/detail/overlay/turn_info.hpp>
#include <boost/geometry/algorithms/detail/ring_identifier.hpp>
#include <boost/geometry/algorithms/detail/overlay/segment_identifier.hpp>
#if defined(BOOST_GEOMETRY_DEBUG_HANDLE_COLOCATIONS)
# include <iostream>
# include <boost/geometry/algorithms/detail/overlay/debug_turn_info.hpp>
# include <boost/geometry/io/wkt/wkt.hpp>
# define BOOST_GEOMETRY_DEBUG_IDENTIFIER
#endif
namespace boost { namespace geometry
{
#ifndef DOXYGEN_NO_DETAIL
namespace detail { namespace overlay
{
template <typename SegmentRatio>
struct segment_fraction
{
segment_identifier seg_id;
SegmentRatio fraction;
segment_fraction(segment_identifier const& id, SegmentRatio const& fr)
: seg_id(id)
, fraction(fr)
{}
segment_fraction()
{}
bool operator<(segment_fraction<SegmentRatio> const& other) const
{
return seg_id == other.seg_id
? fraction < other.fraction
: seg_id < other.seg_id;
}
};
struct turn_operation_index
{
turn_operation_index(signed_size_type ti = -1,
signed_size_type oi = -1)
: turn_index(ti)
, op_index(oi)
{}
signed_size_type turn_index;
signed_size_type op_index; // only 0,1
};
template <typename Turns>
struct less_by_fraction_and_type
{
inline less_by_fraction_and_type(Turns const& turns)
: m_turns(turns)
{
}
inline bool operator()(turn_operation_index const& left,
turn_operation_index const& right) const
{
typedef typename boost::range_value<Turns>::type turn_type;
typedef typename turn_type::turn_operation_type turn_operation_type;
turn_type const& left_turn = m_turns[left.turn_index];
turn_type const& right_turn = m_turns[right.turn_index];
turn_operation_type const& left_op
= left_turn.operations[left.op_index];
turn_operation_type const& right_op
= right_turn.operations[right.op_index];
if (! (left_op.fraction == right_op.fraction))
{
return left_op.fraction < right_op.fraction;
}
// Order xx first - used to discard any following colocated turn
bool const left_both_xx = left_turn.both(operation_blocked);
bool const right_both_xx = right_turn.both(operation_blocked);
if (left_both_xx && ! right_both_xx)
{
return true;
}
if (! left_both_xx && right_both_xx)
{
return false;
}
bool const left_both_uu = left_turn.both(operation_union);
bool const right_both_uu = right_turn.both(operation_union);
if (left_both_uu && ! right_both_uu)
{
return true;
}
if (! left_both_uu && right_both_uu)
{
return false;
}
turn_operation_type const& left_other_op
= left_turn.operations[1 - left.op_index];
turn_operation_type const& right_other_op
= right_turn.operations[1 - right.op_index];
// Fraction is the same, now sort on ring id, first outer ring,
// then interior rings
return left_other_op.seg_id < right_other_op.seg_id;
}
private:
Turns const& m_turns;
};
template <typename Operation, typename ClusterPerSegment>
inline signed_size_type get_cluster_id(Operation const& op, ClusterPerSegment const& cluster_per_segment)
{
typedef typename ClusterPerSegment::key_type segment_fraction_type;
segment_fraction_type seg_frac(op.seg_id, op.fraction);
typename ClusterPerSegment::const_iterator it
= cluster_per_segment.find(seg_frac);
if (it == cluster_per_segment.end())
{
return -1;
}
return it->second;
}
template <typename Operation, typename ClusterPerSegment>
inline void add_cluster_id(Operation const& op,
ClusterPerSegment& cluster_per_segment, signed_size_type id)
{
typedef typename ClusterPerSegment::key_type segment_fraction_type;
segment_fraction_type seg_frac(op.seg_id, op.fraction);
cluster_per_segment[seg_frac] = id;
}
template <typename Turn, typename ClusterPerSegment>
inline signed_size_type add_turn_to_cluster(Turn const& turn,
ClusterPerSegment& cluster_per_segment, signed_size_type& cluster_id)
{
signed_size_type cid0 = get_cluster_id(turn.operations[0], cluster_per_segment);
signed_size_type cid1 = get_cluster_id(turn.operations[1], cluster_per_segment);
if (cid0 == -1 && cid1 == -1)
{
// Because of this, first cluster ID will be 1
++cluster_id;
add_cluster_id(turn.operations[0], cluster_per_segment, cluster_id);
add_cluster_id(turn.operations[1], cluster_per_segment, cluster_id);
return cluster_id;
}
else if (cid0 == -1 && cid1 != -1)
{
add_cluster_id(turn.operations[0], cluster_per_segment, cid1);
return cid1;
}
else if (cid0 != -1 && cid1 == -1)
{
add_cluster_id(turn.operations[1], cluster_per_segment, cid0);
return cid0;
}
else if (cid0 == cid1)
{
// Both already added to same cluster, no action
return cid0;
}
// Both operations.seg_id/fraction were already part of any cluster, and
// these clusters are not the same. Merge of two clusters is necessary
#if defined(BOOST_GEOMETRY_DEBUG_HANDLE_COLOCATIONS)
std::cout << " TODO: merge " << cid0 << " and " << cid1 << std::endl;
#endif
return cid0;
}
template
<
typename Turns,
typename ClusterPerSegment,
typename Operations,
typename Geometry1,
typename Geometry2
>
inline void handle_colocation_cluster(Turns& turns,
signed_size_type& cluster_id,
ClusterPerSegment& cluster_per_segment,
Operations const& operations,
Geometry1 const& /*geometry1*/, Geometry2 const& /*geometry2*/)
{
typedef typename boost::range_value<Turns>::type turn_type;
typedef typename turn_type::turn_operation_type turn_operation_type;
std::vector<turn_operation_index>::const_iterator vit = operations.begin();
turn_operation_index ref_toi = *vit;
signed_size_type ref_id = -1;
for (++vit; vit != operations.end(); ++vit)
{
turn_type& ref_turn = turns[ref_toi.turn_index];
turn_operation_type const& ref_op
= ref_turn.operations[ref_toi.op_index];
turn_operation_index const& toi = *vit;
turn_type& turn = turns[toi.turn_index];
turn_operation_type const& op = turn.operations[toi.op_index];
BOOST_ASSERT(ref_op.seg_id == op.seg_id);
if (ref_op.fraction == op.fraction)
{
turn_operation_type const& other_op = turn.operations[1 - toi.op_index];
if (ref_id == -1)
{
ref_id = add_turn_to_cluster(ref_turn, cluster_per_segment, cluster_id);
}
BOOST_ASSERT(ref_id != -1);
// ref_turn (both operations) are already added to cluster,
// so also "op" is already added to cluster,
// We only need to add other_op
signed_size_type id = get_cluster_id(other_op, cluster_per_segment);
if (id != -1 && id != ref_id)
{
}
else if (id == -1)
{
// Add to same cluster
add_cluster_id(other_op, cluster_per_segment, ref_id);
id = ref_id;
}
}
else
{
// Not on same fraction on this segment
// assign for next
ref_toi = toi;
ref_id = -1;
}
}
}
template
<
typename Turns,
typename Clusters,
typename ClusterPerSegment
>
inline void assign_cluster_to_turns(Turns& turns,
Clusters& clusters,
ClusterPerSegment const& cluster_per_segment)
{
typedef typename boost::range_value<Turns>::type turn_type;
typedef typename turn_type::turn_operation_type turn_operation_type;
typedef typename ClusterPerSegment::key_type segment_fraction_type;
signed_size_type turn_index = 0;
for (typename boost::range_iterator<Turns>::type it = turns.begin();
it != turns.end(); ++it, ++turn_index)
{
turn_type& turn = *it;
if (turn.discarded)
{
// They were processed (to create proper map) but will not be added
// This might leave a cluster with only 1 turn, which will be fixed
// afterwards
continue;
}
for (int i = 0; i < 2; i++)
{
turn_operation_type const& op = turn.operations[i];
segment_fraction_type seg_frac(op.seg_id, op.fraction);
typename ClusterPerSegment::const_iterator it = cluster_per_segment.find(seg_frac);
if (it != cluster_per_segment.end())
{
#if defined(BOOST_GEOMETRY_DEBUG_HANDLE_COLOCATIONS)
if (turn.is_clustered()
&& turn.cluster_id != it->second)
{
std::cout << " CONFLICT " << std::endl;
}
#endif
turn.cluster_id = it->second;
clusters[turn.cluster_id].turn_indices.insert(turn_index);
}
}
}
}
template <typename Turns, typename Clusters>
inline void remove_clusters(Turns& turns, Clusters& clusters)
{
typename Clusters::iterator it = clusters.begin();
while (it != clusters.end())
{
// Hold iterator and increase. We can erase cit, this keeps the
// iterator valid (cf The standard associative-container erase idiom)
typename Clusters::iterator current_it = it;
++it;
std::set<signed_size_type> const& turn_indices
= current_it->second.turn_indices;
if (turn_indices.size() == 1)
{
signed_size_type const turn_index = *turn_indices.begin();
turns[turn_index].cluster_id = -1;
clusters.erase(current_it);
}
}
}
template <typename Turns, typename Clusters>
inline void cleanup_clusters(Turns& turns, Clusters& clusters)
{
// Removes discarded turns from clusters
for (typename Clusters::iterator mit = clusters.begin();
mit != clusters.end(); ++mit)
{
cluster_info& cinfo = mit->second;
std::set<signed_size_type>& ids = cinfo.turn_indices;
for (std::set<signed_size_type>::iterator sit = ids.begin();
sit != ids.end(); /* no increment */)
{
std::set<signed_size_type>::iterator current_it = sit;
++sit;
signed_size_type const turn_index = *current_it;
if (turns[turn_index].discarded)
{
ids.erase(current_it);
}
}
}
remove_clusters(turns, clusters);
}
template <typename Turn, typename IdSet>
inline void discard_ie_turn(Turn& turn, IdSet& ids, signed_size_type id)
{
turn.discarded = true;
// Set cluster id to -1, but don't clear colocated flags
turn.cluster_id = -1;
// To remove it later from clusters
ids.insert(id);
}
template <bool Reverse>
inline bool is_interior(segment_identifier const& seg_id)
{
return Reverse ? seg_id.ring_index == -1 : seg_id.ring_index >= 0;
}
template <bool Reverse0, bool Reverse1>
inline bool is_ie_turn(segment_identifier const& ext_seg_0,
segment_identifier const& ext_seg_1,
segment_identifier const& int_seg_0,
segment_identifier const& other_seg_1)
{
if (ext_seg_0.source_index == ext_seg_1.source_index)
{
// External turn is a self-turn, dont discard internal turn for this
return false;
}
// Compares two segment identifiers from two turns (external / one internal)
// From first turn [0], both are from same polygon (multi_index),
// one is exterior (-1), the other is interior (>= 0),
// and the second turn [1] handles the same ring
// For difference, where the rings are processed in reversal, all interior
// rings become exterior and vice versa. But also the multi property changes:
// rings originally from the same multi should now be considered as from
// different multi polygons.
// But this is not always the case, and at this point hard to figure out
// (not yet implemented, TODO)
bool const same_multi0 = ! Reverse0
&& ext_seg_0.multi_index == int_seg_0.multi_index;
bool const same_multi1 = ! Reverse1
&& ext_seg_1.multi_index == other_seg_1.multi_index;
boost::ignore_unused(same_multi1);
return same_multi0
&& same_multi1
&& ! is_interior<Reverse0>(ext_seg_0)
&& is_interior<Reverse0>(int_seg_0)
&& ext_seg_1.ring_index == other_seg_1.ring_index;
// The other way round is tested in another call
}
template
<
bool Reverse0, bool Reverse1, // Reverse interpretation interior/exterior
overlay_type OverlayType,
typename Turns,
typename Clusters
>
inline void discard_interior_exterior_turns(Turns& turns, Clusters& clusters)
{
typedef std::set<signed_size_type>::const_iterator set_iterator;
typedef typename boost::range_value<Turns>::type turn_type;
std::set<signed_size_type> ids_to_remove;
for (typename Clusters::iterator cit = clusters.begin();
cit != clusters.end(); ++cit)
{
cluster_info& cinfo = cit->second;
std::set<signed_size_type>& ids = cinfo.turn_indices;
ids_to_remove.clear();
for (set_iterator it = ids.begin(); it != ids.end(); ++it)
{
turn_type& turn = turns[*it];
segment_identifier const& seg_0 = turn.operations[0].seg_id;
segment_identifier const& seg_1 = turn.operations[1].seg_id;
if (! (turn.both(operation_union)
|| turn.combination(operation_union, operation_blocked)))
{
// Not a uu/ux, so cannot be colocated with a iu turn
continue;
}
for (set_iterator int_it = ids.begin(); int_it != ids.end(); ++int_it)
{
if (*it == *int_it)
{
continue;
}
// Turn with, possibly, an interior ring involved
turn_type& int_turn = turns[*int_it];
segment_identifier const& int_seg_0 = int_turn.operations[0].seg_id;
segment_identifier const& int_seg_1 = int_turn.operations[1].seg_id;
if (is_ie_turn<Reverse0, Reverse1>(seg_0, seg_1, int_seg_0, int_seg_1))
{
discard_ie_turn(int_turn, ids_to_remove, *int_it);
}
if (is_ie_turn<Reverse1, Reverse0>(seg_1, seg_0, int_seg_1, int_seg_0))
{
discard_ie_turn(int_turn, ids_to_remove, *int_it);
}
}
}
// Erase from the ids (which cannot be done above)
for (set_iterator sit = ids_to_remove.begin();
sit != ids_to_remove.end(); ++sit)
{
ids.erase(*sit);
}
}
}
template
<
overlay_type OverlayType,
typename Turns,
typename Clusters
>
inline void set_colocation(Turns& turns, Clusters const& clusters)
{
typedef std::set<signed_size_type>::const_iterator set_iterator;
typedef typename boost::range_value<Turns>::type turn_type;
for (typename Clusters::const_iterator cit = clusters.begin();
cit != clusters.end(); ++cit)
{
cluster_info const& cinfo = cit->second;
std::set<signed_size_type> const& ids = cinfo.turn_indices;
bool both_target = false;
for (set_iterator it = ids.begin(); it != ids.end(); ++it)
{
turn_type const& turn = turns[*it];
if (turn.both(operation_from_overlay<OverlayType>::value))
{
both_target = true;
break;
}
}
if (both_target)
{
for (set_iterator it = ids.begin(); it != ids.end(); ++it)
{
turn_type& turn = turns[*it];
if (both_target)
{
turn.has_colocated_both = true;
}
}
}
}
}
template
<
typename Turns,
typename Clusters
>
inline void check_colocation(bool& has_blocked,
int cluster_id, Turns const& turns, Clusters const& clusters)
{
typedef typename boost::range_value<Turns>::type turn_type;
has_blocked = false;
typename Clusters::const_iterator mit = clusters.find(cluster_id);
if (mit == clusters.end())
{
return;
}
cluster_info const& cinfo = mit->second;
for (std::set<signed_size_type>::const_iterator it
= cinfo.turn_indices.begin();
it != cinfo.turn_indices.end(); ++it)
{
turn_type const& turn = turns[*it];
if (turn.any_blocked())
{
has_blocked = true;
}
}
}
// Checks colocated turns and flags combinations of uu/other, possibly a
// combination of a ring touching another geometry's interior ring which is
// tangential to the exterior ring
// This function can be extended to replace handle_tangencies: at each
// colocation incoming and outgoing vectors should be inspected
template
<
bool Reverse1, bool Reverse2,
overlay_type OverlayType,
typename Turns,
typename Clusters,
typename Geometry1,
typename Geometry2
>
inline bool handle_colocations(Turns& turns, Clusters& clusters,
Geometry1 const& geometry1, Geometry2 const& geometry2)
{
typedef std::map
<
segment_identifier,
std::vector<turn_operation_index>
> map_type;
// Create and fill map on segment-identifier Map is sorted on seg_id,
// meaning it is sorted on ring_identifier too. This means that exterior
// rings are handled first. If there is a colocation on the exterior ring,
// that information can be used for the interior ring too
map_type map;
int index = 0;
for (typename boost::range_iterator<Turns>::type
it = boost::begin(turns);
it != boost::end(turns);
++it, ++index)
{
map[it->operations[0].seg_id].push_back(turn_operation_index(index, 0));
map[it->operations[1].seg_id].push_back(turn_operation_index(index, 1));
}
// Check if there are multiple turns on one or more segments,
// if not then nothing is to be done
bool colocations = 0;
for (typename map_type::const_iterator it = map.begin();
it != map.end();
++it)
{
if (it->second.size() > 1u)
{
colocations = true;
break;
}
}
if (! colocations)
{
return false;
}
// Sort all vectors, per same segment
less_by_fraction_and_type<Turns> less(turns);
for (typename map_type::iterator it = map.begin();
it != map.end(); ++it)
{
std::sort(it->second.begin(), it->second.end(), less);
}
typedef typename boost::range_value<Turns>::type turn_type;
typedef typename turn_type::segment_ratio_type segment_ratio_type;
typedef std::map
<
segment_fraction<segment_ratio_type>,
signed_size_type
> cluster_per_segment_type;
cluster_per_segment_type cluster_per_segment;
// Assign to zero, because of pre-increment later the cluster_id
// effectively starts with 1
// (and can later be negated to use uniquely with turn_index)
signed_size_type cluster_id = 0;
for (typename map_type::const_iterator it = map.begin();
it != map.end(); ++it)
{
if (it->second.size() > 1u)
{
handle_colocation_cluster(turns, cluster_id, cluster_per_segment,
it->second, geometry1, geometry2);
}
}
assign_cluster_to_turns(turns, clusters, cluster_per_segment);
// Get colocated information here and not later, to keep information
// on turns which are discarded afterwards
set_colocation<OverlayType>(turns, clusters);
discard_interior_exterior_turns
<
do_reverse<geometry::point_order<Geometry1>::value>::value != Reverse1,
do_reverse<geometry::point_order<Geometry2>::value>::value != Reverse2,
OverlayType
>(turns, clusters);
#if defined(BOOST_GEOMETRY_DEBUG_HANDLE_COLOCATIONS)
std::cout << "*** Colocations " << map.size() << std::endl;
for (typename map_type::const_iterator it = map.begin();
it != map.end(); ++it)
{
std::cout << it->first << std::endl;
for (std::vector<turn_operation_index>::const_iterator vit
= it->second.begin(); vit != it->second.end(); ++vit)
{
turn_operation_index const& toi = *vit;
std::cout << geometry::wkt(turns[toi.turn_index].point)
<< std::boolalpha
<< " discarded=" << turns[toi.turn_index].discarded
<< " colocated(uu)=" << turns[toi.turn_index].colocated_uu
<< " colocated(ii)=" << turns[toi.turn_index].colocated_ii
<< " " << operation_char(turns[toi.turn_index].operations[0].operation)
<< " " << turns[toi.turn_index].operations[0].seg_id
<< " " << turns[toi.turn_index].operations[0].fraction
<< " // " << operation_char(turns[toi.turn_index].operations[1].operation)
<< " " << turns[toi.turn_index].operations[1].seg_id
<< " " << turns[toi.turn_index].operations[1].fraction
<< std::endl;
}
}
#endif // DEBUG
return true;
}
struct is_turn_index
{
is_turn_index(signed_size_type index)
: m_index(index)
{}
template <typename Indexed>
inline bool operator()(Indexed const& indexed) const
{
// Indexed is a indexed_turn_operation<Operation>
return indexed.turn_index == m_index;
}
std::size_t m_index;
};
template
<
bool Reverse1, bool Reverse2,
overlay_type OverlayType,
typename Turns,
typename Clusters,
typename Geometry1,
typename Geometry2,
typename SideStrategy
>
inline void gather_cluster_properties(Clusters& clusters, Turns& turns,
operation_type for_operation,
Geometry1 const& geometry1, Geometry2 const& geometry2,
SideStrategy const& strategy)
{
typedef typename boost::range_value<Turns>::type turn_type;
typedef typename turn_type::point_type point_type;
typedef typename turn_type::turn_operation_type turn_operation_type;
// Define sorter, sorting counter-clockwise such that polygons are on the
// right side
typedef sort_by_side::side_sorter
<
Reverse1, Reverse2, OverlayType, point_type, SideStrategy, std::less<int>
> sbs_type;
for (typename Clusters::iterator mit = clusters.begin();
mit != clusters.end(); ++mit)
{
cluster_info& cinfo = mit->second;
std::set<signed_size_type> const& ids = cinfo.turn_indices;
if (ids.empty())
{
continue;
}
sbs_type sbs(strategy);
point_type turn_point; // should be all the same for all turns in cluster
bool first = true;
for (std::set<signed_size_type>::const_iterator sit = ids.begin();
sit != ids.end(); ++sit)
{
signed_size_type turn_index = *sit;
turn_type const& turn = turns[turn_index];
if (first)
{
turn_point = turn.point;
}
for (int i = 0; i < 2; i++)
{
turn_operation_type const& op = turn.operations[i];
sbs.add(op, turn_index, i, geometry1, geometry2, first);
first = false;
}
}
sbs.apply(turn_point);
sbs.find_open();
sbs.assign_zones(for_operation);
cinfo.open_count = sbs.open_count(for_operation);
bool const set_startable
= OverlayType != overlay_dissolve_union
&& OverlayType != overlay_dissolve_intersection;
// Unset the startable flag for all 'closed' zones. This does not
// apply for self-turns, because those counts are not from both
// polygons
for (std::size_t i = 0; i < sbs.m_ranked_points.size(); i++)
{
const typename sbs_type::rp& ranked = sbs.m_ranked_points[i];
turn_type& turn = turns[ranked.turn_index];
turn_operation_type& op = turn.operations[ranked.operation_index];
if (set_startable
&& for_operation == operation_union && cinfo.open_count == 0)
{
op.enriched.startable = false;
}
if (ranked.direction != sort_by_side::dir_to)
{
continue;
}
op.enriched.count_left = ranked.count_left;
op.enriched.count_right = ranked.count_right;
op.enriched.rank = ranked.rank;
op.enriched.zone = ranked.zone;
if (! set_startable)
{
continue;
}
if (OverlayType != overlay_difference
&& is_self_turn<OverlayType>(turn))
{
// Difference needs the self-turns, TODO: investigate
continue;
}
if ((for_operation == operation_union
&& ranked.count_left != 0)
|| (for_operation == operation_intersection
&& ranked.count_right != 2))
{
op.enriched.startable = false;
}
}
}
}
}} // namespace detail::overlay
#endif //DOXYGEN_NO_DETAIL
}} // namespace boost::geometry
#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_HANDLE_COLOCATIONS_HPP
|
INCLUDE "config_private.inc"
SECTION code_clib
SECTION code_stdlib
PUBLIC __strtoull__
EXTERN l_valid_base, l_eat_ws, l_eat_sign, l_neg_64_dehldehl
EXTERN l_eat_base_prefix, l_char2num, error_llznc, l_mulu_72_64x8
EXTERN l_add_64_dehldehl_a, l_eat_digits, error_llzc
__strtoull__:
; strtoll, strtoull helper
;
; enter : bc = base
; de = char **endp
; hl = char *
;
; exit : carry reset indicates no error
;
; a = 0 (number not negated) or 1 (number negated)
; dehl'dehl = result
; bc = char * (& next unconsumed char in string)
;
; carry set indicates error, A holds error code
;
; a = 0/-1 for invalid string, -2 for invalid base
; dehl'dehl = 0
; bc = original char *
;
; a = 3 indicates negate on unsigned overflow
; bc = char * (& next unconsumed char following number)
;
; a = 2 indicates unsigned overflow
; bc = char * (& next unconsumed char following number)
;
; a = 1 indicates negative underflow
; bc = char * (& next unconsumed char following number)
;
; uses : af, bc, de, hl, af', bc', de', hl', ix
IF __CPU_Z180__ || __CPU_R2K__ || __CPU_R3K__
dec sp
ld ix,0
add ix,sp
call z180_entry
inc sp
ret
z180_entry:
ENDIF
ld a,d
or e
jr z, no_endp
; have char **endp
push de ; save char **endp
call no_endp
; strtoul() done, now must write endp
; bc = char * (first uninterpretted char)
; dehl'dehl = result
; a = error code (if carry set)
; carry set = overflow or error
; stack = char **endp
ex (sp),hl
ld (hl),c
inc hl
ld (hl),b
pop hl
ret
no_endp:
call l_valid_base
ld d,a ; d = base
ld c,l
ld b,h ; bc = original char *
jr z, valid_base ; accept base == 0
jr nc, invalid_base
valid_base:
; bc = original char *
; hl = char *
; d = base
call l_eat_ws ; skip whitespace
call l_eat_sign ; carry set if negative
jr nc, positive
; negative sign found
call positive
; return here to negate result
; bc = char * (first uninterpretted char)
; dehl'dehl = result
; a = error code (if carry set)
; carry set = overflow or error
inc a ; indicate negate applied
ret c ; return if error
; successful conversion, check for signed overflow
exx
ld a,d
exx
add a,a ; carry set if signed overflow
call l_neg_64_dehldehl ; negate, carry flag unaffected
ld a,1
ret
positive:
; bc = original char *
; hl = char *
; d = base
ld a,d ; a = base
call l_eat_base_prefix
ld d,a ; d = base, possibly modified
; there must be at least one valid digit
ld a,(hl)
call l_char2num
jr c, invalid_input
cp d
jr nc, invalid_input
; use generic algorithm
; a = first numerical digit
; hl = char *
IF __CPU_Z180__ || __CPU_R2K__ || __CPU_R3K__
ld (ix+0),d
ELSE
ld ixl,d
ENDIF
ld c,l
ld b,h
inc bc ; bc = & next char to consume
call error_llznc
ld l,a ; dehl'dehl = initial digit
loop:
; bc = char *
; dehl'dehl = result
; ixl = base
; get next digit
ld a,(bc)
call l_char2num ; a = digit
jr c, number_complete
IF __CPU_Z180__ || __CPU_R2K__ || __CPU_R3K__
cp (ix+0)
jr nc, number_complete
ELSE
cp ixl ; digit in [0,base-1] ?
jr nc, number_complete
ENDIF
inc bc ; consume the char
; multiply pending result by base
push af ; save new digit
push bc ; save char *
IF __CPU_Z180__ || __CPU_R2K__ || __CPU_R3K__
ld a,(ix+0)
call l_mulu_72_64x8
ELSE
ld a,ixl ; a = base
call l_mulu_72_64x8 ; a dehl'dehl = dehl'dehl * a
ENDIF
pop bc ; bc = char *
or a ; result > 64 bits ?
jr nz, unsigned_overflow
pop af ; a = new digit
; add digit to result
call l_add_64_dehldehl_a ; dehl'dehl += a
jr nz, loop ; if no overflow
push af
unsigned_overflow:
; bc = char * (next unconsumed char)
; ixl = base
; stack = junk
pop af
u_oflow:
; consume the entire number before reporting error
ld l,c
ld h,b ; hl = char *
IF __CPU_Z180__ || __CPU_R2K__ || __CPU_R3K__
ld c,(ix+0)
ELSE
ld c,ixl ; c = base
ENDIF
call l_eat_digits
ld c,l
ld b,h
ld a,2
scf
; bc = char * (next unconsumed char)
; a = 2 (error overflow)
; carry set for error
ret
invalid_base:
call invalid_input
ld a,-2
ret
invalid_input:
; bc = original char*
xor a
; bc = original char *
; dehl'dehl = 0
; a = 0 (error invalid input string)
; carry set for error
jp error_llzc
number_complete:
xor a ; carry reset and a=0
ret
|
org #4000
execute:
ld (v1), hl
ld hl, (v1)
loop:
jr loop
org #c000
v1: ds virtual 2
|
#include "Common.hpp"
#include <algorithm>
#include <cctype>
#include <functional>
namespace Text
{
static bool __isWhitespace(char chr) { return std::isspace(chr) != 0; }
bool IsWhitespace(const std::string& value) { return std::find_if_not(value.cbegin(), value.cend(), __isWhitespace) == value.cend(); }
bool CompareIgnoreCase(const std::string& a, const std::string& b)
{
return std::equal(a.begin(), a.end(), b.begin(), b.end(), [](char a, char b) { return std::tolower(a) == std::tolower(b); });
}
static void __toCase(const std::string::iterator& begin, const std::string::const_iterator& end, const std::function<char(char)>& callback)
{
std::string::iterator iter = begin;
while(iter != end)
{
*iter = callback(*iter);
iter++;
}
}
static void __toCase(const std::string::const_iterator& begin,
const std::string::const_iterator& end,
std::back_insert_iterator<std::string> result,
const std::function<char(char)>& callback)
{
std::string::const_iterator iter = begin;
while(iter != end)
{
*result = callback(*iter);
iter++;
}
}
std::string& ToLowercase(std::string& value)
{
__toCase(value.begin(), value.cend(), [](char chr) { return static_cast<char>(std::tolower(chr)); });
return value;
}
std::string& ToUppercase(std::string& value)
{
__toCase(value.begin(), value.cend(), [](char chr) { return static_cast<char>(std::toupper(chr)); });
return value;
}
std::string& ToTitleCase(std::string& value)
{
bool isQualifier = true;
__toCase(value.begin(), value.cend(), [&isQualifier](char chr) {
const char tmpResult = static_cast<char>(isQualifier ? std::toupper(chr) : std::tolower(chr));
isQualifier = (std::isspace(chr) != 0) || (std::ispunct(chr) != 0);
return tmpResult;
});
return value;
}
std::string& ToSentenceCase(std::string& value)
{
bool isQualifier = true;
__toCase(value.begin(), value.cend(), [&isQualifier](char chr) {
if(std::isalpha(chr) != 0)
{
const char tmpResult = static_cast<char>(isQualifier ? std::toupper(chr) : std::tolower(chr));
isQualifier = false;
return tmpResult;
}
else
{
if(chr == '.')
{
isQualifier = true;
}
return chr;
}
});
return value;
}
std::string ToLowercaseCopy(const std::string& value)
{
std::string result;
result.reserve(value.size());
__toCase(value.cbegin(), value.cend(), std::back_inserter(result), [](char chr) { return static_cast<char>(std::tolower(chr)); });
return result;
}
std::string ToUppercaseCopy(const std::string& value)
{
std::string result;
result.reserve(value.size());
__toCase(value.cbegin(), value.cend(), std::back_inserter(result), [](char chr) { return static_cast<char>(std::toupper(chr)); });
return result;
}
std::string ToTitleCaseCopy(const std::string& value)
{
std::string result;
result.reserve(value.size());
bool isQualifier = true;
__toCase(value.cbegin(), value.cend(), std::back_inserter(result), [&isQualifier](char chr) {
const char tmpResult = static_cast<char>(isQualifier ? std::toupper(chr) : std::tolower(chr));
isQualifier = (std::isspace(chr) != 0) || (std::ispunct(chr) != 0);
return tmpResult;
});
return result;
}
std::string ToSentenceCaseCopy(const std::string& value)
{
std::string result;
result.reserve(value.size());
bool isQualifier = true;
__toCase(value.cbegin(), value.cend(), std::back_inserter(result), [&isQualifier](char chr) {
if(std::isalpha(chr) != 0)
{
const char tmpResult = static_cast<char>(isQualifier ? std::toupper(chr) : std::tolower(chr));
isQualifier = false;
return tmpResult;
}
else
{
if(chr == '.')
{
isQualifier = true;
}
return chr;
}
});
return result;
}
std::string Trim(const std::string& value)
{
auto begin = std::find_if_not(value.cbegin(), value.cend(), __isWhitespace);
auto end = std::find_if_not(value.rbegin(), value.rend(), __isWhitespace);
return value.substr((begin != value.end()) ? std::distance(value.begin(), begin) : 0u,
(end != value.rend()) ? std::distance(begin, end.base()) : std::string::npos);
}
std::string TrimLeft(const std::string& value)
{
auto begin = std::find_if_not(value.cbegin(), value.cend(), __isWhitespace);
return value.substr((begin != value.end()) ? std::distance(value.begin(), begin) : 0u, std::string::npos);
}
std::string TrimRight(const std::string& value)
{
auto end = std::find_if_not(value.rbegin(), value.rend(), __isWhitespace);
return value.substr(0u, (end != value.rend()) ? std::distance(value.begin(), end.base()) : std::string::npos);
}
std::string& Reverse(std::string& value)
{
auto i = value.begin();
auto j = value.rbegin();
for(; i < j.base(); i++, j++)
{
char tmp = *i;
*i = *j;
*j = tmp;
}
return value;
}
std::string ReverseCopy(const std::string& value)
{
std::string tmpResult;
std::copy(value.rbegin(), value.rend(), std::back_inserter(tmpResult));
return tmpResult;
}
} // namespace Text
|
.global s_prepare_buffers
s_prepare_buffers:
push %r10
push %r11
push %r13
push %r15
push %rcx
push %rdi
push %rdx
push %rsi
lea addresses_UC_ht+0x11dde, %rdx
nop
nop
nop
and $5824, %rcx
movups (%rdx), %xmm1
vpextrq $1, %xmm1, %r13
nop
nop
nop
nop
add $2071, %r10
lea addresses_D_ht+0x2aca, %r11
nop
nop
nop
nop
nop
add $49788, %r15
movl $0x61626364, (%r11)
add %rdx, %rdx
lea addresses_A_ht+0x7d20, %rsi
lea addresses_D_ht+0x8b70, %rdi
nop
sub %r10, %r10
mov $100, %rcx
rep movsq
nop
nop
xor $43079, %rsi
lea addresses_WT_ht+0x15550, %rcx
nop
and %r13, %r13
movl $0x61626364, (%rcx)
nop
nop
xor %r11, %r11
pop %rsi
pop %rdx
pop %rdi
pop %rcx
pop %r15
pop %r13
pop %r11
pop %r10
ret
.global s_faulty_load
s_faulty_load:
push %r10
push %r12
push %r13
push %r14
push %r15
push %r8
push %rdx
// Load
lea addresses_PSE+0x2140, %r10
clflush (%r10)
nop
nop
xor $37874, %r15
movups (%r10), %xmm0
vpextrq $1, %xmm0, %r12
nop
nop
nop
add $56396, %r13
// Faulty Load
lea addresses_UC+0xc520, %r12
nop
nop
nop
and %rdx, %rdx
mov (%r12), %r13
lea oracles, %rdx
and $0xff, %r13
shlq $12, %r13
mov (%rdx,%r13,1), %r13
pop %rdx
pop %r8
pop %r15
pop %r14
pop %r13
pop %r12
pop %r10
ret
/*
<gen_faulty_load>
[REF]
{'src': {'same': False, 'congruent': 0, 'NT': False, 'type': 'addresses_UC', 'size': 2, 'AVXalign': False}, 'OP': 'LOAD'}
{'src': {'same': False, 'congruent': 5, 'NT': False, 'type': 'addresses_PSE', 'size': 16, 'AVXalign': False}, 'OP': 'LOAD'}
[Faulty Load]
{'src': {'same': True, 'congruent': 0, 'NT': False, 'type': 'addresses_UC', 'size': 8, 'AVXalign': False}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'src': {'same': False, 'congruent': 1, 'NT': False, 'type': 'addresses_UC_ht', 'size': 16, 'AVXalign': False}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'same': True, 'congruent': 1, 'NT': False, 'type': 'addresses_D_ht', 'size': 4, 'AVXalign': True}}
{'src': {'type': 'addresses_A_ht', 'congruent': 8, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_D_ht', 'congruent': 4, 'same': False}}
{'OP': 'STOR', 'dst': {'same': False, 'congruent': 3, 'NT': False, 'type': 'addresses_WT_ht', 'size': 4, 'AVXalign': False}}
{'37': 21829}
37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37
*/
|
; A099761: a(n) = ( n*(n+2) )^2.
; 0,9,64,225,576,1225,2304,3969,6400,9801,14400,20449,28224,38025,50176,65025,82944,104329,129600,159201,193600,233289,278784,330625,389376,455625,529984,613089,705600,808201,921600,1046529,1183744,1334025,1498176,1677025,1871424,2082249,2310400,2556801,2822400,3108169,3415104,3744225,4096576,4473225,4875264,5303809,5760000,6245001,6760000,7306209,7884864,8497225,9144576,9828225,10549504,11309769,12110400,12952801,13838400,14768649,15745024,16769025,17842176,18966025,20142144,21372129,22657600
mov $1,2
add $1,$0
mul $1,$0
pow $1,2
mov $0,$1
|
; A037711: Base 6 digits are, in order, the first n terms of the periodic sequence with initial period 1,3,2,0.
; Submitted by Jamie Morken(s1.)
; 1,9,56,336,2017,12105,72632,435792,2614753,15688521,94131128,564786768,3388720609,20332323657,121993941944,731963651664,4391781909985,26350691459913,158104148759480,948624892556880,5691749355341281
add $0,1
mov $2,1
lpb $0
mov $3,$2
lpb $3
add $2,1
mod $3,5
div $4,7
cmp $4,0
sub $3,$4
add $5,1
lpe
sub $0,1
add $2,1
mul $5,6
lpe
mov $0,$5
div $0,6
|
.MACRO LKS_cycle8
nop
nop
nop
nop
nop
nop
nop
nop
.ENDM
.MACRO LKS_printfc
ldx #(\1*2 + \2*64)
rep #$20
lda LKS_PRINTPL-1
and #$FF00
clc
adc #\3
sta LKS_BUF_BG3+0,x
sep #$20
.ENDM
.MACRO LKS_printf_setpal
lda #\1<<2
sta LKS_PRINTPL
.ENDM
.MACRO LKS_printfs
txy
ldx #(\1*2 + \2*64)
jsl LKS_printfs
.ENDM
.MACRO compute_digit_for_base16 ARGS _base
; [input] registre A sur 16 bits qui contient le nombre dans la bonne tranche par rapport à _base
; Autrement dit, _base <= A < (10 * _base)
; [output]
; [X] le registre X contient le chiffre pour la _base
; [A] contient le reste (module _base) ==> donc 0 <= A < _base
;
; _base vaut une puissance non nul de 10
; On détermine les chiffres les uns après les autres depuis le plus grand avec _base = 10000
; Puis ainsi de suite avec _base = 1000, _base = 100 et enfin _base = 10
; Les uns, après les autres, on obtient alors les 5 chiffres qui compose le nombre sur 16 bits.
.IF _base != 10000
cmp #5 * _base
bcc +
ldx #5
sec
sbc #5 * _base
bra ++
+:
ldx #0
++:
.ELSE
ldx #0
.ENDIF
-:
cmp #_base
bcc +
inx
sec
sbc #_base
bra -
+:
.ENDM
.MACRO compute_digit_for_base8 ARGS _base
; [input] registre A sur 16 bits qui contient le nombre dans la bonne tranche par rapport à _base
; Autrement dit, _base <= A < (10 * _base)
; [output]
; [X] le registre X contient le chiffre pour la _base
; [A] contient le reste (module _base) ==> donc 0 <= A < _base
;
; _base vaut une puissance non nul de 10
; On détermine les chiffres les uns après les autres depuis le plus grand avec _base = 10000
; Puis ainsi de suite avec _base = 1000, _base = 100 et enfin _base = 10
; Les uns, après les autres, on obtient alors les 5 chiffres qui compose le nombre sur 16 bits.
.IF _base != 100
cmp #5*_base
bmi +
ldx #5
sec
sbc #5*_base
bra ++
+:
ldx #0
++:
.ELSE
ldx #0
.ENDIF
-:
cmp #_base
bmi +
inx
sec
sbc #_base
bra -
+:
.ENDM
.MACRO LKS_printf16
ldx #(\1*2 + \2*64)
stx MEM_TEMPFUNC
jsl LKS_printf16_draw
.ENDM
.MACRO LKS_printfu16
ldx #(\1*2 + \2*64)
stx MEM_TEMPFUNC
jsl LKS_printfu16_draw
.ENDM
.MACRO LKS_printf8
ldx #(\1*2 + \2*64)
stx MEM_TEMPFUNC
jsl LKS_printf8_draw
.ENDM
.MACRO LKS_printh8
ldx #(\1*2 + \2*64)
stx MEM_TEMPFUNC
jsl LKS_printh8_draw
.ENDM
.MACRO LKS_printh16
ldx #(\1*2 + \2*64)
stx MEM_TEMPFUNC
jsl LKS_printh16_draw
.ENDM
|
// Copyright 2014 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "src/compiler/instruction-selector.h"
#include <limits>
#include "src/assembler-inl.h"
#include "src/base/adapters.h"
#include "src/compiler/compiler-source-position-table.h"
#include "src/compiler/instruction-selector-impl.h"
#include "src/compiler/node-matchers.h"
#include "src/compiler/pipeline.h"
#include "src/compiler/schedule.h"
#include "src/compiler/state-values-utils.h"
#include "src/deoptimizer.h"
namespace v8 {
namespace internal {
namespace compiler {
InstructionSelector::InstructionSelector(
Zone* zone, size_t node_count, Linkage* linkage,
InstructionSequence* sequence, Schedule* schedule,
SourcePositionTable* source_positions, Frame* frame,
EnableSwitchJumpTable enable_switch_jump_table,
SourcePositionMode source_position_mode, Features features,
EnableScheduling enable_scheduling,
EnableRootsRelativeAddressing enable_roots_relative_addressing,
PoisoningMitigationLevel poisoning_level, EnableTraceTurboJson trace_turbo)
: zone_(zone),
linkage_(linkage),
sequence_(sequence),
source_positions_(source_positions),
source_position_mode_(source_position_mode),
features_(features),
schedule_(schedule),
current_block_(nullptr),
instructions_(zone),
continuation_inputs_(sequence->zone()),
continuation_outputs_(sequence->zone()),
defined_(node_count, false, zone),
used_(node_count, false, zone),
effect_level_(node_count, 0, zone),
virtual_registers_(node_count,
InstructionOperand::kInvalidVirtualRegister, zone),
virtual_register_rename_(zone),
scheduler_(nullptr),
enable_scheduling_(enable_scheduling),
enable_roots_relative_addressing_(enable_roots_relative_addressing),
enable_switch_jump_table_(enable_switch_jump_table),
poisoning_level_(poisoning_level),
frame_(frame),
instruction_selection_failed_(false),
instr_origins_(sequence->zone()),
trace_turbo_(trace_turbo) {
instructions_.reserve(node_count);
continuation_inputs_.reserve(5);
continuation_outputs_.reserve(2);
if (trace_turbo_ == kEnableTraceTurboJson) {
instr_origins_.assign(node_count, {-1, 0});
}
}
bool InstructionSelector::SelectInstructions() {
// Mark the inputs of all phis in loop headers as used.
BasicBlockVector* blocks = schedule()->rpo_order();
for (auto const block : *blocks) {
if (!block->IsLoopHeader()) continue;
DCHECK_LE(2u, block->PredecessorCount());
for (Node* const phi : *block) {
if (phi->opcode() != IrOpcode::kPhi) continue;
// Mark all inputs as used.
for (Node* const input : phi->inputs()) {
MarkAsUsed(input);
}
}
}
// Visit each basic block in post order.
for (auto i = blocks->rbegin(); i != blocks->rend(); ++i) {
VisitBlock(*i);
if (instruction_selection_failed()) return false;
}
// Schedule the selected instructions.
if (UseInstructionScheduling()) {
scheduler_ = new (zone()) InstructionScheduler(zone(), sequence());
}
for (auto const block : *blocks) {
InstructionBlock* instruction_block =
sequence()->InstructionBlockAt(RpoNumber::FromInt(block->rpo_number()));
for (size_t i = 0; i < instruction_block->phis().size(); i++) {
UpdateRenamesInPhi(instruction_block->PhiAt(i));
}
size_t end = instruction_block->code_end();
size_t start = instruction_block->code_start();
DCHECK_LE(end, start);
StartBlock(RpoNumber::FromInt(block->rpo_number()));
if (end != start) {
while (start-- > end + 1) {
UpdateRenames(instructions_[start]);
AddInstruction(instructions_[start]);
}
UpdateRenames(instructions_[end]);
AddTerminator(instructions_[end]);
}
EndBlock(RpoNumber::FromInt(block->rpo_number()));
}
#if DEBUG
sequence()->ValidateSSA();
#endif
return true;
}
void InstructionSelector::StartBlock(RpoNumber rpo) {
if (UseInstructionScheduling()) {
DCHECK_NOT_NULL(scheduler_);
scheduler_->StartBlock(rpo);
} else {
sequence()->StartBlock(rpo);
}
}
void InstructionSelector::EndBlock(RpoNumber rpo) {
if (UseInstructionScheduling()) {
DCHECK_NOT_NULL(scheduler_);
scheduler_->EndBlock(rpo);
} else {
sequence()->EndBlock(rpo);
}
}
void InstructionSelector::AddTerminator(Instruction* instr) {
if (UseInstructionScheduling()) {
DCHECK_NOT_NULL(scheduler_);
scheduler_->AddTerminator(instr);
} else {
sequence()->AddInstruction(instr);
}
}
void InstructionSelector::AddInstruction(Instruction* instr) {
if (UseInstructionScheduling()) {
DCHECK_NOT_NULL(scheduler_);
scheduler_->AddInstruction(instr);
} else {
sequence()->AddInstruction(instr);
}
}
Instruction* InstructionSelector::Emit(InstructionCode opcode,
InstructionOperand output,
size_t temp_count,
InstructionOperand* temps) {
size_t output_count = output.IsInvalid() ? 0 : 1;
return Emit(opcode, output_count, &output, 0, nullptr, temp_count, temps);
}
Instruction* InstructionSelector::Emit(InstructionCode opcode,
InstructionOperand output,
InstructionOperand a, size_t temp_count,
InstructionOperand* temps) {
size_t output_count = output.IsInvalid() ? 0 : 1;
return Emit(opcode, output_count, &output, 1, &a, temp_count, temps);
}
Instruction* InstructionSelector::Emit(InstructionCode opcode,
InstructionOperand output,
InstructionOperand a,
InstructionOperand b, size_t temp_count,
InstructionOperand* temps) {
size_t output_count = output.IsInvalid() ? 0 : 1;
InstructionOperand inputs[] = {a, b};
size_t input_count = arraysize(inputs);
return Emit(opcode, output_count, &output, input_count, inputs, temp_count,
temps);
}
Instruction* InstructionSelector::Emit(InstructionCode opcode,
InstructionOperand output,
InstructionOperand a,
InstructionOperand b,
InstructionOperand c, size_t temp_count,
InstructionOperand* temps) {
size_t output_count = output.IsInvalid() ? 0 : 1;
InstructionOperand inputs[] = {a, b, c};
size_t input_count = arraysize(inputs);
return Emit(opcode, output_count, &output, input_count, inputs, temp_count,
temps);
}
Instruction* InstructionSelector::Emit(
InstructionCode opcode, InstructionOperand output, InstructionOperand a,
InstructionOperand b, InstructionOperand c, InstructionOperand d,
size_t temp_count, InstructionOperand* temps) {
size_t output_count = output.IsInvalid() ? 0 : 1;
InstructionOperand inputs[] = {a, b, c, d};
size_t input_count = arraysize(inputs);
return Emit(opcode, output_count, &output, input_count, inputs, temp_count,
temps);
}
Instruction* InstructionSelector::Emit(
InstructionCode opcode, InstructionOperand output, InstructionOperand a,
InstructionOperand b, InstructionOperand c, InstructionOperand d,
InstructionOperand e, size_t temp_count, InstructionOperand* temps) {
size_t output_count = output.IsInvalid() ? 0 : 1;
InstructionOperand inputs[] = {a, b, c, d, e};
size_t input_count = arraysize(inputs);
return Emit(opcode, output_count, &output, input_count, inputs, temp_count,
temps);
}
Instruction* InstructionSelector::Emit(
InstructionCode opcode, InstructionOperand output, InstructionOperand a,
InstructionOperand b, InstructionOperand c, InstructionOperand d,
InstructionOperand e, InstructionOperand f, size_t temp_count,
InstructionOperand* temps) {
size_t output_count = output.IsInvalid() ? 0 : 1;
InstructionOperand inputs[] = {a, b, c, d, e, f};
size_t input_count = arraysize(inputs);
return Emit(opcode, output_count, &output, input_count, inputs, temp_count,
temps);
}
Instruction* InstructionSelector::Emit(
InstructionCode opcode, size_t output_count, InstructionOperand* outputs,
size_t input_count, InstructionOperand* inputs, size_t temp_count,
InstructionOperand* temps) {
if (output_count >= Instruction::kMaxOutputCount ||
input_count >= Instruction::kMaxInputCount ||
temp_count >= Instruction::kMaxTempCount) {
set_instruction_selection_failed();
return nullptr;
}
Instruction* instr =
Instruction::New(instruction_zone(), opcode, output_count, outputs,
input_count, inputs, temp_count, temps);
return Emit(instr);
}
Instruction* InstructionSelector::Emit(Instruction* instr) {
instructions_.push_back(instr);
return instr;
}
bool InstructionSelector::CanCover(Node* user, Node* node) const {
// 1. Both {user} and {node} must be in the same basic block.
if (schedule()->block(node) != schedule()->block(user)) {
return false;
}
// 2. Pure {node}s must be owned by the {user}.
if (node->op()->HasProperty(Operator::kPure)) {
return node->OwnedBy(user);
}
// 3. Impure {node}s must match the effect level of {user}.
if (GetEffectLevel(node) != GetEffectLevel(user)) {
return false;
}
// 4. Only {node} must have value edges pointing to {user}.
for (Edge const edge : node->use_edges()) {
if (edge.from() != user && NodeProperties::IsValueEdge(edge)) {
return false;
}
}
return true;
}
bool InstructionSelector::IsOnlyUserOfNodeInSameBlock(Node* user,
Node* node) const {
BasicBlock* bb_user = schedule()->block(user);
BasicBlock* bb_node = schedule()->block(node);
if (bb_user != bb_node) return false;
for (Edge const edge : node->use_edges()) {
Node* from = edge.from();
if ((from != user) && (schedule()->block(from) == bb_user)) {
return false;
}
}
return true;
}
void InstructionSelector::UpdateRenames(Instruction* instruction) {
for (size_t i = 0; i < instruction->InputCount(); i++) {
TryRename(instruction->InputAt(i));
}
}
void InstructionSelector::UpdateRenamesInPhi(PhiInstruction* phi) {
for (size_t i = 0; i < phi->operands().size(); i++) {
int vreg = phi->operands()[i];
int renamed = GetRename(vreg);
if (vreg != renamed) {
phi->RenameInput(i, renamed);
}
}
}
int InstructionSelector::GetRename(int virtual_register) {
int rename = virtual_register;
while (true) {
if (static_cast<size_t>(rename) >= virtual_register_rename_.size()) break;
int next = virtual_register_rename_[rename];
if (next == InstructionOperand::kInvalidVirtualRegister) {
break;
}
rename = next;
}
return rename;
}
void InstructionSelector::TryRename(InstructionOperand* op) {
if (!op->IsUnallocated()) return;
UnallocatedOperand* unalloc = UnallocatedOperand::cast(op);
int vreg = unalloc->virtual_register();
int rename = GetRename(vreg);
if (rename != vreg) {
*unalloc = UnallocatedOperand(*unalloc, rename);
}
}
void InstructionSelector::SetRename(const Node* node, const Node* rename) {
int vreg = GetVirtualRegister(node);
if (static_cast<size_t>(vreg) >= virtual_register_rename_.size()) {
int invalid = InstructionOperand::kInvalidVirtualRegister;
virtual_register_rename_.resize(vreg + 1, invalid);
}
virtual_register_rename_[vreg] = GetVirtualRegister(rename);
}
int InstructionSelector::GetVirtualRegister(const Node* node) {
DCHECK_NOT_NULL(node);
size_t const id = node->id();
DCHECK_LT(id, virtual_registers_.size());
int virtual_register = virtual_registers_[id];
if (virtual_register == InstructionOperand::kInvalidVirtualRegister) {
virtual_register = sequence()->NextVirtualRegister();
virtual_registers_[id] = virtual_register;
}
return virtual_register;
}
const std::map<NodeId, int> InstructionSelector::GetVirtualRegistersForTesting()
const {
std::map<NodeId, int> virtual_registers;
for (size_t n = 0; n < virtual_registers_.size(); ++n) {
if (virtual_registers_[n] != InstructionOperand::kInvalidVirtualRegister) {
NodeId const id = static_cast<NodeId>(n);
virtual_registers.insert(std::make_pair(id, virtual_registers_[n]));
}
}
return virtual_registers;
}
bool InstructionSelector::IsDefined(Node* node) const {
DCHECK_NOT_NULL(node);
size_t const id = node->id();
DCHECK_LT(id, defined_.size());
return defined_[id];
}
void InstructionSelector::MarkAsDefined(Node* node) {
DCHECK_NOT_NULL(node);
size_t const id = node->id();
DCHECK_LT(id, defined_.size());
defined_[id] = true;
}
bool InstructionSelector::IsUsed(Node* node) const {
DCHECK_NOT_NULL(node);
// TODO(bmeurer): This is a terrible monster hack, but we have to make sure
// that the Retain is actually emitted, otherwise the GC will mess up.
if (node->opcode() == IrOpcode::kRetain) return true;
if (!node->op()->HasProperty(Operator::kEliminatable)) return true;
size_t const id = node->id();
DCHECK_LT(id, used_.size());
return used_[id];
}
void InstructionSelector::MarkAsUsed(Node* node) {
DCHECK_NOT_NULL(node);
size_t const id = node->id();
DCHECK_LT(id, used_.size());
used_[id] = true;
}
int InstructionSelector::GetEffectLevel(Node* node) const {
DCHECK_NOT_NULL(node);
size_t const id = node->id();
DCHECK_LT(id, effect_level_.size());
return effect_level_[id];
}
void InstructionSelector::SetEffectLevel(Node* node, int effect_level) {
DCHECK_NOT_NULL(node);
size_t const id = node->id();
DCHECK_LT(id, effect_level_.size());
effect_level_[id] = effect_level;
}
bool InstructionSelector::CanAddressRelativeToRootsRegister() const {
return enable_roots_relative_addressing_ == kEnableRootsRelativeAddressing &&
CanUseRootsRegister();
}
bool InstructionSelector::CanUseRootsRegister() const {
return linkage()->GetIncomingDescriptor()->flags() &
CallDescriptor::kCanUseRoots;
}
void InstructionSelector::MarkAsRepresentation(MachineRepresentation rep,
const InstructionOperand& op) {
UnallocatedOperand unalloc = UnallocatedOperand::cast(op);
sequence()->MarkAsRepresentation(rep, unalloc.virtual_register());
}
void InstructionSelector::MarkAsRepresentation(MachineRepresentation rep,
Node* node) {
sequence()->MarkAsRepresentation(rep, GetVirtualRegister(node));
}
namespace {
InstructionOperand OperandForDeopt(Isolate* isolate, OperandGenerator* g,
Node* input, FrameStateInputKind kind,
MachineRepresentation rep) {
if (rep == MachineRepresentation::kNone) {
return g->TempImmediate(FrameStateDescriptor::kImpossibleValue);
}
switch (input->opcode()) {
case IrOpcode::kInt32Constant:
case IrOpcode::kInt64Constant:
case IrOpcode::kNumberConstant:
case IrOpcode::kFloat32Constant:
case IrOpcode::kFloat64Constant:
return g->UseImmediate(input);
case IrOpcode::kHeapConstant: {
if (!CanBeTaggedPointer(rep)) {
// If we have inconsistent static and dynamic types, e.g. if we
// smi-check a string, we can get here with a heap object that
// says it is a smi. In that case, we return an invalid instruction
// operand, which will be interpreted as an optimized-out value.
// TODO(jarin) Ideally, we should turn the current instruction
// into an abort (we should never execute it).
return InstructionOperand();
}
Handle<HeapObject> constant = HeapConstantOf(input->op());
Heap::RootListIndex root_index;
if (isolate->heap()->IsRootHandle(constant, &root_index) &&
root_index == Heap::kOptimizedOutRootIndex) {
// For an optimized-out object we return an invalid instruction
// operand, so that we take the fast path for optimized-out values.
return InstructionOperand();
}
return g->UseImmediate(input);
}
case IrOpcode::kArgumentsElementsState:
case IrOpcode::kArgumentsLengthState:
case IrOpcode::kObjectState:
case IrOpcode::kTypedObjectState:
UNREACHABLE();
break;
default:
switch (kind) {
case FrameStateInputKind::kStackSlot:
return g->UseUniqueSlot(input);
case FrameStateInputKind::kAny:
// Currently deopts "wrap" other operations, so the deopt's inputs
// are potentially needed until the end of the deoptimising code.
return g->UseAnyAtEnd(input);
}
}
UNREACHABLE();
}
} // namespace
class StateObjectDeduplicator {
public:
explicit StateObjectDeduplicator(Zone* zone) : objects_(zone) {}
static const size_t kNotDuplicated = SIZE_MAX;
size_t GetObjectId(Node* node) {
DCHECK(node->opcode() == IrOpcode::kTypedObjectState ||
node->opcode() == IrOpcode::kObjectId ||
node->opcode() == IrOpcode::kArgumentsElementsState);
for (size_t i = 0; i < objects_.size(); ++i) {
if (objects_[i] == node) return i;
// ObjectId nodes are the Turbofan way to express objects with the same
// identity in the deopt info. So they should always be mapped to
// previously appearing TypedObjectState nodes.
if (HasObjectId(objects_[i]) && HasObjectId(node) &&
ObjectIdOf(objects_[i]->op()) == ObjectIdOf(node->op())) {
return i;
}
}
DCHECK(node->opcode() == IrOpcode::kTypedObjectState ||
node->opcode() == IrOpcode::kArgumentsElementsState);
return kNotDuplicated;
}
size_t InsertObject(Node* node) {
DCHECK(node->opcode() == IrOpcode::kTypedObjectState ||
node->opcode() == IrOpcode::kObjectId ||
node->opcode() == IrOpcode::kArgumentsElementsState);
size_t id = objects_.size();
objects_.push_back(node);
return id;
}
private:
static bool HasObjectId(Node* node) {
return node->opcode() == IrOpcode::kTypedObjectState ||
node->opcode() == IrOpcode::kObjectId;
}
ZoneVector<Node*> objects_;
};
// Returns the number of instruction operands added to inputs.
size_t InstructionSelector::AddOperandToStateValueDescriptor(
StateValueList* values, InstructionOperandVector* inputs,
OperandGenerator* g, StateObjectDeduplicator* deduplicator, Node* input,
MachineType type, FrameStateInputKind kind, Zone* zone) {
if (input == nullptr) {
values->PushOptimizedOut();
return 0;
}
switch (input->opcode()) {
case IrOpcode::kArgumentsElementsState: {
values->PushArgumentsElements(ArgumentsStateTypeOf(input->op()));
// The elements backing store of an arguments object participates in the
// duplicate object counting, but can itself never appear duplicated.
DCHECK_EQ(StateObjectDeduplicator::kNotDuplicated,
deduplicator->GetObjectId(input));
deduplicator->InsertObject(input);
return 0;
}
case IrOpcode::kArgumentsLengthState: {
values->PushArgumentsLength(ArgumentsStateTypeOf(input->op()));
return 0;
}
case IrOpcode::kObjectState: {
UNREACHABLE();
}
case IrOpcode::kTypedObjectState:
case IrOpcode::kObjectId: {
size_t id = deduplicator->GetObjectId(input);
if (id == StateObjectDeduplicator::kNotDuplicated) {
DCHECK_EQ(IrOpcode::kTypedObjectState, input->opcode());
size_t entries = 0;
id = deduplicator->InsertObject(input);
StateValueList* nested = values->PushRecursiveField(zone, id);
int const input_count = input->op()->ValueInputCount();
ZoneVector<MachineType> const* types = MachineTypesOf(input->op());
for (int i = 0; i < input_count; ++i) {
entries += AddOperandToStateValueDescriptor(
nested, inputs, g, deduplicator, input->InputAt(i), types->at(i),
kind, zone);
}
return entries;
} else {
// Deoptimizer counts duplicate objects for the running id, so we have
// to push the input again.
deduplicator->InsertObject(input);
values->PushDuplicate(id);
return 0;
}
}
default: {
InstructionOperand op =
OperandForDeopt(isolate(), g, input, kind, type.representation());
if (op.kind() == InstructionOperand::INVALID) {
// Invalid operand means the value is impossible or optimized-out.
values->PushOptimizedOut();
return 0;
} else {
inputs->push_back(op);
values->PushPlain(type);
return 1;
}
}
}
}
// Returns the number of instruction operands added to inputs.
size_t InstructionSelector::AddInputsToFrameStateDescriptor(
FrameStateDescriptor* descriptor, Node* state, OperandGenerator* g,
StateObjectDeduplicator* deduplicator, InstructionOperandVector* inputs,
FrameStateInputKind kind, Zone* zone) {
DCHECK_EQ(IrOpcode::kFrameState, state->op()->opcode());
size_t entries = 0;
size_t initial_size = inputs->size();
USE(initial_size); // initial_size is only used for debug.
if (descriptor->outer_state()) {
entries += AddInputsToFrameStateDescriptor(
descriptor->outer_state(), state->InputAt(kFrameStateOuterStateInput),
g, deduplicator, inputs, kind, zone);
}
Node* parameters = state->InputAt(kFrameStateParametersInput);
Node* locals = state->InputAt(kFrameStateLocalsInput);
Node* stack = state->InputAt(kFrameStateStackInput);
Node* context = state->InputAt(kFrameStateContextInput);
Node* function = state->InputAt(kFrameStateFunctionInput);
DCHECK_EQ(descriptor->parameters_count(),
StateValuesAccess(parameters).size());
DCHECK_EQ(descriptor->locals_count(), StateValuesAccess(locals).size());
DCHECK_EQ(descriptor->stack_count(), StateValuesAccess(stack).size());
StateValueList* values_descriptor = descriptor->GetStateValueDescriptors();
DCHECK_EQ(values_descriptor->size(), 0u);
values_descriptor->ReserveSize(descriptor->GetSize());
entries += AddOperandToStateValueDescriptor(
values_descriptor, inputs, g, deduplicator, function,
MachineType::AnyTagged(), FrameStateInputKind::kStackSlot, zone);
for (StateValuesAccess::TypedNode input_node :
StateValuesAccess(parameters)) {
entries += AddOperandToStateValueDescriptor(values_descriptor, inputs, g,
deduplicator, input_node.node,
input_node.type, kind, zone);
}
if (descriptor->HasContext()) {
entries += AddOperandToStateValueDescriptor(
values_descriptor, inputs, g, deduplicator, context,
MachineType::AnyTagged(), FrameStateInputKind::kStackSlot, zone);
}
for (StateValuesAccess::TypedNode input_node : StateValuesAccess(locals)) {
entries += AddOperandToStateValueDescriptor(values_descriptor, inputs, g,
deduplicator, input_node.node,
input_node.type, kind, zone);
}
for (StateValuesAccess::TypedNode input_node : StateValuesAccess(stack)) {
entries += AddOperandToStateValueDescriptor(values_descriptor, inputs, g,
deduplicator, input_node.node,
input_node.type, kind, zone);
}
DCHECK_EQ(initial_size + entries, inputs->size());
return entries;
}
Instruction* InstructionSelector::EmitWithContinuation(
InstructionCode opcode, FlagsContinuation* cont) {
return EmitWithContinuation(opcode, 0, nullptr, 0, nullptr, cont);
}
Instruction* InstructionSelector::EmitWithContinuation(
InstructionCode opcode, InstructionOperand a, FlagsContinuation* cont) {
return EmitWithContinuation(opcode, 0, nullptr, 1, &a, cont);
}
Instruction* InstructionSelector::EmitWithContinuation(
InstructionCode opcode, InstructionOperand a, InstructionOperand b,
FlagsContinuation* cont) {
InstructionOperand inputs[] = {a, b};
return EmitWithContinuation(opcode, 0, nullptr, arraysize(inputs), inputs,
cont);
}
Instruction* InstructionSelector::EmitWithContinuation(
InstructionCode opcode, InstructionOperand a, InstructionOperand b,
InstructionOperand c, FlagsContinuation* cont) {
InstructionOperand inputs[] = {a, b, c};
return EmitWithContinuation(opcode, 0, nullptr, arraysize(inputs), inputs,
cont);
}
Instruction* InstructionSelector::EmitWithContinuation(
InstructionCode opcode, size_t output_count, InstructionOperand* outputs,
size_t input_count, InstructionOperand* inputs, FlagsContinuation* cont) {
OperandGenerator g(this);
opcode = cont->Encode(opcode);
continuation_inputs_.resize(0);
for (size_t i = 0; i < input_count; i++) {
continuation_inputs_.push_back(inputs[i]);
}
continuation_outputs_.resize(0);
for (size_t i = 0; i < output_count; i++) {
continuation_outputs_.push_back(outputs[i]);
}
if (cont->IsBranch()) {
continuation_inputs_.push_back(g.Label(cont->true_block()));
continuation_inputs_.push_back(g.Label(cont->false_block()));
} else if (cont->IsDeoptimize()) {
opcode |= MiscField::encode(static_cast<int>(input_count));
AppendDeoptimizeArguments(&continuation_inputs_, cont->kind(),
cont->reason(), cont->feedback(),
cont->frame_state());
} else if (cont->IsSet()) {
continuation_outputs_.push_back(g.DefineAsRegister(cont->result()));
} else if (cont->IsTrap()) {
int trap_id = static_cast<int>(cont->trap_id());
continuation_inputs_.push_back(g.UseImmediate(trap_id));
} else {
DCHECK(cont->IsNone());
}
size_t const emit_inputs_size = continuation_inputs_.size();
auto* emit_inputs =
emit_inputs_size ? &continuation_inputs_.front() : nullptr;
size_t const emit_outputs_size = continuation_outputs_.size();
auto* emit_outputs =
emit_outputs_size ? &continuation_outputs_.front() : nullptr;
return Emit(opcode, emit_outputs_size, emit_outputs, emit_inputs_size,
emit_inputs, 0, nullptr);
}
void InstructionSelector::AppendDeoptimizeArguments(
InstructionOperandVector* args, DeoptimizeKind kind,
DeoptimizeReason reason, VectorSlotPair const& feedback,
Node* frame_state) {
OperandGenerator g(this);
FrameStateDescriptor* const descriptor = GetFrameStateDescriptor(frame_state);
DCHECK_NE(DeoptimizeKind::kLazy, kind);
int const state_id =
sequence()->AddDeoptimizationEntry(descriptor, kind, reason, feedback);
args->push_back(g.TempImmediate(state_id));
StateObjectDeduplicator deduplicator(instruction_zone());
AddInputsToFrameStateDescriptor(descriptor, frame_state, &g, &deduplicator,
args, FrameStateInputKind::kAny,
instruction_zone());
}
Instruction* InstructionSelector::EmitDeoptimize(
InstructionCode opcode, size_t output_count, InstructionOperand* outputs,
size_t input_count, InstructionOperand* inputs, DeoptimizeKind kind,
DeoptimizeReason reason, VectorSlotPair const& feedback,
Node* frame_state) {
InstructionOperandVector args(instruction_zone());
for (size_t i = 0; i < input_count; ++i) {
args.push_back(inputs[i]);
}
opcode |= MiscField::encode(static_cast<int>(input_count));
AppendDeoptimizeArguments(&args, kind, reason, feedback, frame_state);
return Emit(opcode, output_count, outputs, args.size(), &args.front(), 0,
nullptr);
}
// An internal helper class for generating the operands to calls.
// TODO(bmeurer): Get rid of the CallBuffer business and make
// InstructionSelector::VisitCall platform independent instead.
struct CallBuffer {
CallBuffer(Zone* zone, const CallDescriptor* call_descriptor,
FrameStateDescriptor* frame_state)
: descriptor(call_descriptor),
frame_state_descriptor(frame_state),
output_nodes(zone),
outputs(zone),
instruction_args(zone),
pushed_nodes(zone) {
output_nodes.reserve(call_descriptor->ReturnCount());
outputs.reserve(call_descriptor->ReturnCount());
pushed_nodes.reserve(input_count());
instruction_args.reserve(input_count() + frame_state_value_count());
}
const CallDescriptor* descriptor;
FrameStateDescriptor* frame_state_descriptor;
ZoneVector<PushParameter> output_nodes;
InstructionOperandVector outputs;
InstructionOperandVector instruction_args;
ZoneVector<PushParameter> pushed_nodes;
size_t input_count() const { return descriptor->InputCount(); }
size_t frame_state_count() const { return descriptor->FrameStateCount(); }
size_t frame_state_value_count() const {
return (frame_state_descriptor == nullptr)
? 0
: (frame_state_descriptor->GetTotalSize() +
1); // Include deopt id.
}
};
// TODO(bmeurer): Get rid of the CallBuffer business and make
// InstructionSelector::VisitCall platform independent instead.
void InstructionSelector::InitializeCallBuffer(Node* call, CallBuffer* buffer,
CallBufferFlags flags,
bool is_tail_call,
int stack_param_delta) {
OperandGenerator g(this);
size_t ret_count = buffer->descriptor->ReturnCount();
DCHECK_LE(call->op()->ValueOutputCount(), ret_count);
DCHECK_EQ(
call->op()->ValueInputCount(),
static_cast<int>(buffer->input_count() + buffer->frame_state_count()));
if (ret_count > 0) {
// Collect the projections that represent multiple outputs from this call.
if (ret_count == 1) {
PushParameter result = {call, buffer->descriptor->GetReturnLocation(0)};
buffer->output_nodes.push_back(result);
} else {
buffer->output_nodes.resize(ret_count);
int stack_count = 0;
for (size_t i = 0; i < ret_count; ++i) {
LinkageLocation location = buffer->descriptor->GetReturnLocation(i);
buffer->output_nodes[i] = PushParameter(nullptr, location);
if (location.IsCallerFrameSlot()) {
stack_count += location.GetSizeInPointers();
}
}
for (Edge const edge : call->use_edges()) {
if (!NodeProperties::IsValueEdge(edge)) continue;
Node* node = edge.from();
DCHECK_EQ(IrOpcode::kProjection, node->opcode());
size_t const index = ProjectionIndexOf(node->op());
DCHECK_LT(index, buffer->output_nodes.size());
DCHECK(!buffer->output_nodes[index].node);
buffer->output_nodes[index].node = node;
}
frame_->EnsureReturnSlots(stack_count);
}
// Filter out the outputs that aren't live because no projection uses them.
size_t outputs_needed_by_framestate =
buffer->frame_state_descriptor == nullptr
? 0
: buffer->frame_state_descriptor->state_combine()
.ConsumedOutputCount();
for (size_t i = 0; i < buffer->output_nodes.size(); i++) {
bool output_is_live = buffer->output_nodes[i].node != nullptr ||
i < outputs_needed_by_framestate;
if (output_is_live) {
LinkageLocation location = buffer->output_nodes[i].location;
MachineRepresentation rep = location.GetType().representation();
Node* output = buffer->output_nodes[i].node;
InstructionOperand op = output == nullptr
? g.TempLocation(location)
: g.DefineAsLocation(output, location);
MarkAsRepresentation(rep, op);
if (!UnallocatedOperand::cast(op).HasFixedSlotPolicy()) {
buffer->outputs.push_back(op);
buffer->output_nodes[i].node = nullptr;
}
}
}
}
// The first argument is always the callee code.
Node* callee = call->InputAt(0);
bool call_code_immediate = (flags & kCallCodeImmediate) != 0;
bool call_address_immediate = (flags & kCallAddressImmediate) != 0;
bool call_use_fixed_target_reg = (flags & kCallFixedTargetRegister) != 0;
switch (buffer->descriptor->kind()) {
case CallDescriptor::kCallCodeObject:
// TODO(jgruber, v8:7449): The below is a hack to support tail-calls from
// JS-linkage callers with a register code target. The problem is that the
// code target register may be clobbered before the final jmp by
// AssemblePopArgumentsAdaptorFrame. As a more permanent fix we could
// entirely remove support for tail-calls from JS-linkage callers.
buffer->instruction_args.push_back(
(call_code_immediate && callee->opcode() == IrOpcode::kHeapConstant)
? g.UseImmediate(callee)
: call_use_fixed_target_reg
? g.UseFixed(callee, kJavaScriptCallCodeStartRegister)
: is_tail_call ? g.UseUniqueRegister(callee)
: g.UseRegister(callee));
break;
case CallDescriptor::kCallAddress:
buffer->instruction_args.push_back(
(call_address_immediate &&
callee->opcode() == IrOpcode::kExternalConstant)
? g.UseImmediate(callee)
: call_use_fixed_target_reg
? g.UseFixed(callee, kJavaScriptCallCodeStartRegister)
: g.UseRegister(callee));
break;
case CallDescriptor::kCallWasmFunction:
buffer->instruction_args.push_back(
(call_address_immediate &&
(callee->opcode() == IrOpcode::kRelocatableInt64Constant ||
callee->opcode() == IrOpcode::kRelocatableInt32Constant))
? g.UseImmediate(callee)
: call_use_fixed_target_reg
? g.UseFixed(callee, kJavaScriptCallCodeStartRegister)
: g.UseRegister(callee));
break;
case CallDescriptor::kCallJSFunction:
buffer->instruction_args.push_back(
g.UseLocation(callee, buffer->descriptor->GetInputLocation(0)));
break;
}
DCHECK_EQ(1u, buffer->instruction_args.size());
// Argument 1 is used for poison-alias index (encoded in a word-sized
// immediate. This an index of the operand that aliases with poison register
// or -1 if there is no aliasing.
buffer->instruction_args.push_back(g.TempImmediate(-1));
const size_t poison_alias_index = 1;
DCHECK_EQ(buffer->instruction_args.size() - 1, poison_alias_index);
// If the call needs a frame state, we insert the state information as
// follows (n is the number of value inputs to the frame state):
// arg 2 : deoptimization id.
// arg 3 - arg (n + 2) : value inputs to the frame state.
size_t frame_state_entries = 0;
USE(frame_state_entries); // frame_state_entries is only used for debug.
if (buffer->frame_state_descriptor != nullptr) {
Node* frame_state =
call->InputAt(static_cast<int>(buffer->descriptor->InputCount()));
// If it was a syntactic tail call we need to drop the current frame and
// all the frames on top of it that are either an arguments adaptor frame
// or a tail caller frame.
if (is_tail_call) {
frame_state = NodeProperties::GetFrameStateInput(frame_state);
buffer->frame_state_descriptor =
buffer->frame_state_descriptor->outer_state();
while (buffer->frame_state_descriptor != nullptr &&
buffer->frame_state_descriptor->type() ==
FrameStateType::kArgumentsAdaptor) {
frame_state = NodeProperties::GetFrameStateInput(frame_state);
buffer->frame_state_descriptor =
buffer->frame_state_descriptor->outer_state();
}
}
int const state_id = sequence()->AddDeoptimizationEntry(
buffer->frame_state_descriptor, DeoptimizeKind::kLazy,
DeoptimizeReason::kUnknown, VectorSlotPair());
buffer->instruction_args.push_back(g.TempImmediate(state_id));
StateObjectDeduplicator deduplicator(instruction_zone());
frame_state_entries =
1 + AddInputsToFrameStateDescriptor(
buffer->frame_state_descriptor, frame_state, &g, &deduplicator,
&buffer->instruction_args, FrameStateInputKind::kStackSlot,
instruction_zone());
DCHECK_EQ(2 + frame_state_entries, buffer->instruction_args.size());
}
size_t input_count = static_cast<size_t>(buffer->input_count());
// Split the arguments into pushed_nodes and instruction_args. Pushed
// arguments require an explicit push instruction before the call and do
// not appear as arguments to the call. Everything else ends up
// as an InstructionOperand argument to the call.
auto iter(call->inputs().begin());
size_t pushed_count = 0;
bool call_tail = (flags & kCallTail) != 0;
for (size_t index = 0; index < input_count; ++iter, ++index) {
DCHECK(iter != call->inputs().end());
DCHECK_NE(IrOpcode::kFrameState, (*iter)->op()->opcode());
if (index == 0) continue; // The first argument (callee) is already done.
LinkageLocation location = buffer->descriptor->GetInputLocation(index);
if (call_tail) {
location = LinkageLocation::ConvertToTailCallerLocation(
location, stack_param_delta);
}
InstructionOperand op = g.UseLocation(*iter, location);
UnallocatedOperand unallocated = UnallocatedOperand::cast(op);
if (unallocated.HasFixedSlotPolicy() && !call_tail) {
int stack_index = -unallocated.fixed_slot_index() - 1;
if (static_cast<size_t>(stack_index) >= buffer->pushed_nodes.size()) {
buffer->pushed_nodes.resize(stack_index + 1);
}
PushParameter param = {*iter, location};
buffer->pushed_nodes[stack_index] = param;
pushed_count++;
} else {
// If we do load poisoning and the linkage uses the poisoning register,
// then we request the input in memory location, and during code
// generation, we move the input to the register.
if (poisoning_level_ != PoisoningMitigationLevel::kDontPoison &&
unallocated.HasFixedRegisterPolicy()) {
int reg = unallocated.fixed_register_index();
if (reg == kSpeculationPoisonRegister.code()) {
buffer->instruction_args[poison_alias_index] = g.TempImmediate(
static_cast<int32_t>(buffer->instruction_args.size()));
op = g.UseRegisterOrSlotOrConstant(*iter);
}
}
buffer->instruction_args.push_back(op);
}
}
DCHECK_EQ(input_count, buffer->instruction_args.size() + pushed_count -
frame_state_entries - 1);
if (V8_TARGET_ARCH_STORES_RETURN_ADDRESS_ON_STACK && call_tail &&
stack_param_delta != 0) {
// For tail calls that change the size of their parameter list and keep
// their return address on the stack, move the return address to just above
// the parameters.
LinkageLocation saved_return_location =
LinkageLocation::ForSavedCallerReturnAddress();
InstructionOperand return_address =
g.UsePointerLocation(LinkageLocation::ConvertToTailCallerLocation(
saved_return_location, stack_param_delta),
saved_return_location);
buffer->instruction_args.push_back(return_address);
}
}
bool InstructionSelector::IsSourcePositionUsed(Node* node) {
return (source_position_mode_ == kAllSourcePositions ||
node->opcode() == IrOpcode::kCall ||
node->opcode() == IrOpcode::kCallWithCallerSavedRegisters ||
node->opcode() == IrOpcode::kTrapIf ||
node->opcode() == IrOpcode::kTrapUnless ||
node->opcode() == IrOpcode::kProtectedLoad ||
node->opcode() == IrOpcode::kProtectedStore);
}
void InstructionSelector::VisitBlock(BasicBlock* block) {
DCHECK(!current_block_);
current_block_ = block;
auto current_num_instructions = [&] {
DCHECK_GE(kMaxInt, instructions_.size());
return static_cast<int>(instructions_.size());
};
int current_block_end = current_num_instructions();
int effect_level = 0;
for (Node* const node : *block) {
SetEffectLevel(node, effect_level);
if (node->opcode() == IrOpcode::kStore ||
node->opcode() == IrOpcode::kUnalignedStore ||
node->opcode() == IrOpcode::kCall ||
node->opcode() == IrOpcode::kCallWithCallerSavedRegisters ||
node->opcode() == IrOpcode::kProtectedLoad ||
node->opcode() == IrOpcode::kProtectedStore) {
++effect_level;
}
}
// We visit the control first, then the nodes in the block, so the block's
// control input should be on the same effect level as the last node.
if (block->control_input() != nullptr) {
SetEffectLevel(block->control_input(), effect_level);
}
auto FinishEmittedInstructions = [&](Node* node, int instruction_start) {
if (instruction_selection_failed()) return false;
if (current_num_instructions() == instruction_start) return true;
std::reverse(instructions_.begin() + instruction_start,
instructions_.end());
if (!node) return true;
if (!source_positions_) return true;
SourcePosition source_position = source_positions_->GetSourcePosition(node);
if (source_position.IsKnown() && IsSourcePositionUsed(node)) {
sequence()->SetSourcePosition(instructions_[instruction_start],
source_position);
}
return true;
};
// Generate code for the block control "top down", but schedule the code
// "bottom up".
VisitControl(block);
if (!FinishEmittedInstructions(block->control_input(), current_block_end))
return;
// Visit code in reverse control flow order, because architecture-specific
// matching may cover more than one node at a time.
for (auto node : base::Reversed(*block)) {
int current_node_end = current_num_instructions();
// Skip nodes that are unused or already defined.
if (IsUsed(node) && !IsDefined(node)) {
// Generate code for this node "top down", but schedule the code "bottom
// up".
VisitNode(node);
if (!FinishEmittedInstructions(node, current_node_end)) return;
}
if (trace_turbo_ == kEnableTraceTurboJson) {
instr_origins_[node->id()] = {current_num_instructions(),
current_node_end};
}
}
// We're done with the block.
InstructionBlock* instruction_block =
sequence()->InstructionBlockAt(RpoNumber::FromInt(block->rpo_number()));
if (current_num_instructions() == current_block_end) {
// Avoid empty block: insert a {kArchNop} instruction.
Emit(Instruction::New(sequence()->zone(), kArchNop));
}
instruction_block->set_code_start(current_num_instructions());
instruction_block->set_code_end(current_block_end);
current_block_ = nullptr;
}
void InstructionSelector::VisitControl(BasicBlock* block) {
#ifdef DEBUG
// SSA deconstruction requires targets of branches not to have phis.
// Edge split form guarantees this property, but is more strict.
if (block->SuccessorCount() > 1) {
for (BasicBlock* const successor : block->successors()) {
for (Node* const node : *successor) {
if (IrOpcode::IsPhiOpcode(node->opcode())) {
std::ostringstream str;
str << "You might have specified merged variables for a label with "
<< "only one predecessor." << std::endl
<< "# Current Block: " << *successor << std::endl
<< "# Node: " << *node;
FATAL("%s", str.str().c_str());
}
}
}
}
#endif
Node* input = block->control_input();
int instruction_end = static_cast<int>(instructions_.size());
switch (block->control()) {
case BasicBlock::kGoto:
VisitGoto(block->SuccessorAt(0));
break;
case BasicBlock::kCall: {
DCHECK_EQ(IrOpcode::kCall, input->opcode());
BasicBlock* success = block->SuccessorAt(0);
BasicBlock* exception = block->SuccessorAt(1);
VisitCall(input, exception);
VisitGoto(success);
break;
}
case BasicBlock::kTailCall: {
DCHECK_EQ(IrOpcode::kTailCall, input->opcode());
VisitTailCall(input);
break;
}
case BasicBlock::kBranch: {
DCHECK_EQ(IrOpcode::kBranch, input->opcode());
BasicBlock* tbranch = block->SuccessorAt(0);
BasicBlock* fbranch = block->SuccessorAt(1);
if (tbranch == fbranch) {
VisitGoto(tbranch);
} else {
VisitBranch(input, tbranch, fbranch);
}
break;
}
case BasicBlock::kSwitch: {
DCHECK_EQ(IrOpcode::kSwitch, input->opcode());
// Last successor must be {IfDefault}.
BasicBlock* default_branch = block->successors().back();
DCHECK_EQ(IrOpcode::kIfDefault, default_branch->front()->opcode());
// All other successors must be {IfValue}s.
int32_t min_value = std::numeric_limits<int32_t>::max();
int32_t max_value = std::numeric_limits<int32_t>::min();
size_t case_count = block->SuccessorCount() - 1;
ZoneVector<CaseInfo> cases(case_count, zone());
for (size_t i = 0; i < case_count; ++i) {
BasicBlock* branch = block->SuccessorAt(i);
const IfValueParameters& p = IfValueParametersOf(branch->front()->op());
cases[i] = CaseInfo{p.value(), p.comparison_order(), branch};
if (min_value > p.value()) min_value = p.value();
if (max_value < p.value()) max_value = p.value();
}
SwitchInfo sw(cases, min_value, max_value, default_branch);
VisitSwitch(input, sw);
break;
}
case BasicBlock::kReturn: {
DCHECK_EQ(IrOpcode::kReturn, input->opcode());
VisitReturn(input);
break;
}
case BasicBlock::kDeoptimize: {
DeoptimizeParameters p = DeoptimizeParametersOf(input->op());
Node* value = input->InputAt(0);
VisitDeoptimize(p.kind(), p.reason(), p.feedback(), value);
break;
}
case BasicBlock::kThrow:
DCHECK_EQ(IrOpcode::kThrow, input->opcode());
VisitThrow(input);
break;
case BasicBlock::kNone: {
// Exit block doesn't have control.
DCHECK_NULL(input);
break;
}
default:
UNREACHABLE();
break;
}
if (trace_turbo_ == kEnableTraceTurboJson && input) {
int instruction_start = static_cast<int>(instructions_.size());
instr_origins_[input->id()] = {instruction_start, instruction_end};
}
}
void InstructionSelector::MarkPairProjectionsAsWord32(Node* node) {
Node* projection0 = NodeProperties::FindProjection(node, 0);
if (projection0) {
MarkAsWord32(projection0);
}
Node* projection1 = NodeProperties::FindProjection(node, 1);
if (projection1) {
MarkAsWord32(projection1);
}
}
void InstructionSelector::VisitNode(Node* node) {
DCHECK_NOT_NULL(schedule()->block(node)); // should only use scheduled nodes.
switch (node->opcode()) {
case IrOpcode::kStart:
case IrOpcode::kLoop:
case IrOpcode::kEnd:
case IrOpcode::kBranch:
case IrOpcode::kIfTrue:
case IrOpcode::kIfFalse:
case IrOpcode::kIfSuccess:
case IrOpcode::kSwitch:
case IrOpcode::kIfValue:
case IrOpcode::kIfDefault:
case IrOpcode::kEffectPhi:
case IrOpcode::kMerge:
case IrOpcode::kTerminate:
case IrOpcode::kBeginRegion:
// No code needed for these graph artifacts.
return;
case IrOpcode::kIfException:
return MarkAsReference(node), VisitIfException(node);
case IrOpcode::kFinishRegion:
return MarkAsReference(node), VisitFinishRegion(node);
case IrOpcode::kParameter: {
MachineType type =
linkage()->GetParameterType(ParameterIndexOf(node->op()));
MarkAsRepresentation(type.representation(), node);
return VisitParameter(node);
}
case IrOpcode::kOsrValue:
return MarkAsReference(node), VisitOsrValue(node);
case IrOpcode::kPhi: {
MachineRepresentation rep = PhiRepresentationOf(node->op());
if (rep == MachineRepresentation::kNone) return;
MarkAsRepresentation(rep, node);
return VisitPhi(node);
}
case IrOpcode::kProjection:
return VisitProjection(node);
case IrOpcode::kInt32Constant:
case IrOpcode::kInt64Constant:
case IrOpcode::kExternalConstant:
case IrOpcode::kRelocatableInt32Constant:
case IrOpcode::kRelocatableInt64Constant:
return VisitConstant(node);
case IrOpcode::kFloat32Constant:
return MarkAsFloat32(node), VisitConstant(node);
case IrOpcode::kFloat64Constant:
return MarkAsFloat64(node), VisitConstant(node);
case IrOpcode::kHeapConstant:
return MarkAsReference(node), VisitConstant(node);
case IrOpcode::kNumberConstant: {
double value = OpParameter<double>(node->op());
if (!IsSmiDouble(value)) MarkAsReference(node);
return VisitConstant(node);
}
case IrOpcode::kCall:
return VisitCall(node);
case IrOpcode::kCallWithCallerSavedRegisters:
return VisitCallWithCallerSavedRegisters(node);
case IrOpcode::kDeoptimizeIf:
return VisitDeoptimizeIf(node);
case IrOpcode::kDeoptimizeUnless:
return VisitDeoptimizeUnless(node);
case IrOpcode::kTrapIf:
return VisitTrapIf(node, TrapIdOf(node->op()));
case IrOpcode::kTrapUnless:
return VisitTrapUnless(node, TrapIdOf(node->op()));
case IrOpcode::kFrameState:
case IrOpcode::kStateValues:
case IrOpcode::kObjectState:
return;
case IrOpcode::kDebugAbort:
VisitDebugAbort(node);
return;
case IrOpcode::kDebugBreak:
VisitDebugBreak(node);
return;
case IrOpcode::kUnreachable:
VisitUnreachable(node);
return;
case IrOpcode::kDeadValue:
VisitDeadValue(node);
return;
case IrOpcode::kComment:
VisitComment(node);
return;
case IrOpcode::kRetain:
VisitRetain(node);
return;
case IrOpcode::kLoad: {
LoadRepresentation type = LoadRepresentationOf(node->op());
MarkAsRepresentation(type.representation(), node);
return VisitLoad(node);
}
case IrOpcode::kPoisonedLoad: {
LoadRepresentation type = LoadRepresentationOf(node->op());
MarkAsRepresentation(type.representation(), node);
return VisitPoisonedLoad(node);
}
case IrOpcode::kStore:
return VisitStore(node);
case IrOpcode::kProtectedStore:
return VisitProtectedStore(node);
case IrOpcode::kWord32And:
return MarkAsWord32(node), VisitWord32And(node);
case IrOpcode::kWord32Or:
return MarkAsWord32(node), VisitWord32Or(node);
case IrOpcode::kWord32Xor:
return MarkAsWord32(node), VisitWord32Xor(node);
case IrOpcode::kWord32Shl:
return MarkAsWord32(node), VisitWord32Shl(node);
case IrOpcode::kWord32Shr:
return MarkAsWord32(node), VisitWord32Shr(node);
case IrOpcode::kWord32Sar:
return MarkAsWord32(node), VisitWord32Sar(node);
case IrOpcode::kWord32Ror:
return MarkAsWord32(node), VisitWord32Ror(node);
case IrOpcode::kWord32Equal:
return VisitWord32Equal(node);
case IrOpcode::kWord32Clz:
return MarkAsWord32(node), VisitWord32Clz(node);
case IrOpcode::kWord32Ctz:
return MarkAsWord32(node), VisitWord32Ctz(node);
case IrOpcode::kWord32ReverseBits:
return MarkAsWord32(node), VisitWord32ReverseBits(node);
case IrOpcode::kWord32ReverseBytes:
return MarkAsWord32(node), VisitWord32ReverseBytes(node);
case IrOpcode::kInt32AbsWithOverflow:
return MarkAsWord32(node), VisitInt32AbsWithOverflow(node);
case IrOpcode::kWord32Popcnt:
return MarkAsWord32(node), VisitWord32Popcnt(node);
case IrOpcode::kWord64Popcnt:
return MarkAsWord32(node), VisitWord64Popcnt(node);
case IrOpcode::kWord64And:
return MarkAsWord64(node), VisitWord64And(node);
case IrOpcode::kWord64Or:
return MarkAsWord64(node), VisitWord64Or(node);
case IrOpcode::kWord64Xor:
return MarkAsWord64(node), VisitWord64Xor(node);
case IrOpcode::kWord64Shl:
return MarkAsWord64(node), VisitWord64Shl(node);
case IrOpcode::kWord64Shr:
return MarkAsWord64(node), VisitWord64Shr(node);
case IrOpcode::kWord64Sar:
return MarkAsWord64(node), VisitWord64Sar(node);
case IrOpcode::kWord64Ror:
return MarkAsWord64(node), VisitWord64Ror(node);
case IrOpcode::kWord64Clz:
return MarkAsWord64(node), VisitWord64Clz(node);
case IrOpcode::kWord64Ctz:
return MarkAsWord64(node), VisitWord64Ctz(node);
case IrOpcode::kWord64ReverseBits:
return MarkAsWord64(node), VisitWord64ReverseBits(node);
case IrOpcode::kWord64ReverseBytes:
return MarkAsWord64(node), VisitWord64ReverseBytes(node);
case IrOpcode::kInt64AbsWithOverflow:
return MarkAsWord64(node), VisitInt64AbsWithOverflow(node);
case IrOpcode::kWord64Equal:
return VisitWord64Equal(node);
case IrOpcode::kInt32Add:
return MarkAsWord32(node), VisitInt32Add(node);
case IrOpcode::kInt32AddWithOverflow:
return MarkAsWord32(node), VisitInt32AddWithOverflow(node);
case IrOpcode::kInt32Sub:
return MarkAsWord32(node), VisitInt32Sub(node);
case IrOpcode::kInt32SubWithOverflow:
return VisitInt32SubWithOverflow(node);
case IrOpcode::kInt32Mul:
return MarkAsWord32(node), VisitInt32Mul(node);
case IrOpcode::kInt32MulWithOverflow:
return MarkAsWord32(node), VisitInt32MulWithOverflow(node);
case IrOpcode::kInt32MulHigh:
return VisitInt32MulHigh(node);
case IrOpcode::kInt32Div:
return MarkAsWord32(node), VisitInt32Div(node);
case IrOpcode::kInt32Mod:
return MarkAsWord32(node), VisitInt32Mod(node);
case IrOpcode::kInt32LessThan:
return VisitInt32LessThan(node);
case IrOpcode::kInt32LessThanOrEqual:
return VisitInt32LessThanOrEqual(node);
case IrOpcode::kUint32Div:
return MarkAsWord32(node), VisitUint32Div(node);
case IrOpcode::kUint32LessThan:
return VisitUint32LessThan(node);
case IrOpcode::kUint32LessThanOrEqual:
return VisitUint32LessThanOrEqual(node);
case IrOpcode::kUint32Mod:
return MarkAsWord32(node), VisitUint32Mod(node);
case IrOpcode::kUint32MulHigh:
return VisitUint32MulHigh(node);
case IrOpcode::kInt64Add:
return MarkAsWord64(node), VisitInt64Add(node);
case IrOpcode::kInt64AddWithOverflow:
return MarkAsWord64(node), VisitInt64AddWithOverflow(node);
case IrOpcode::kInt64Sub:
return MarkAsWord64(node), VisitInt64Sub(node);
case IrOpcode::kInt64SubWithOverflow:
return MarkAsWord64(node), VisitInt64SubWithOverflow(node);
case IrOpcode::kInt64Mul:
return MarkAsWord64(node), VisitInt64Mul(node);
case IrOpcode::kInt64Div:
return MarkAsWord64(node), VisitInt64Div(node);
case IrOpcode::kInt64Mod:
return MarkAsWord64(node), VisitInt64Mod(node);
case IrOpcode::kInt64LessThan:
return VisitInt64LessThan(node);
case IrOpcode::kInt64LessThanOrEqual:
return VisitInt64LessThanOrEqual(node);
case IrOpcode::kUint64Div:
return MarkAsWord64(node), VisitUint64Div(node);
case IrOpcode::kUint64LessThan:
return VisitUint64LessThan(node);
case IrOpcode::kUint64LessThanOrEqual:
return VisitUint64LessThanOrEqual(node);
case IrOpcode::kUint64Mod:
return MarkAsWord64(node), VisitUint64Mod(node);
case IrOpcode::kBitcastTaggedToWord:
return MarkAsRepresentation(MachineType::PointerRepresentation(), node),
VisitBitcastTaggedToWord(node);
case IrOpcode::kBitcastWordToTagged:
return MarkAsReference(node), VisitBitcastWordToTagged(node);
case IrOpcode::kBitcastWordToTaggedSigned:
return MarkAsRepresentation(MachineRepresentation::kTaggedSigned, node),
EmitIdentity(node);
case IrOpcode::kChangeFloat32ToFloat64:
return MarkAsFloat64(node), VisitChangeFloat32ToFloat64(node);
case IrOpcode::kChangeInt32ToFloat64:
return MarkAsFloat64(node), VisitChangeInt32ToFloat64(node);
case IrOpcode::kChangeUint32ToFloat64:
return MarkAsFloat64(node), VisitChangeUint32ToFloat64(node);
case IrOpcode::kChangeFloat64ToInt32:
return MarkAsWord32(node), VisitChangeFloat64ToInt32(node);
case IrOpcode::kChangeFloat64ToUint32:
return MarkAsWord32(node), VisitChangeFloat64ToUint32(node);
case IrOpcode::kChangeFloat64ToUint64:
return MarkAsWord64(node), VisitChangeFloat64ToUint64(node);
case IrOpcode::kFloat64SilenceNaN:
MarkAsFloat64(node);
if (CanProduceSignalingNaN(node->InputAt(0))) {
return VisitFloat64SilenceNaN(node);
} else {
return EmitIdentity(node);
}
case IrOpcode::kTruncateFloat64ToUint32:
return MarkAsWord32(node), VisitTruncateFloat64ToUint32(node);
case IrOpcode::kTruncateFloat32ToInt32:
return MarkAsWord32(node), VisitTruncateFloat32ToInt32(node);
case IrOpcode::kTruncateFloat32ToUint32:
return MarkAsWord32(node), VisitTruncateFloat32ToUint32(node);
case IrOpcode::kTryTruncateFloat32ToInt64:
return MarkAsWord64(node), VisitTryTruncateFloat32ToInt64(node);
case IrOpcode::kTryTruncateFloat64ToInt64:
return MarkAsWord64(node), VisitTryTruncateFloat64ToInt64(node);
case IrOpcode::kTryTruncateFloat32ToUint64:
return MarkAsWord64(node), VisitTryTruncateFloat32ToUint64(node);
case IrOpcode::kTryTruncateFloat64ToUint64:
return MarkAsWord64(node), VisitTryTruncateFloat64ToUint64(node);
case IrOpcode::kChangeInt32ToInt64:
return MarkAsWord64(node), VisitChangeInt32ToInt64(node);
case IrOpcode::kChangeUint32ToUint64:
return MarkAsWord64(node), VisitChangeUint32ToUint64(node);
case IrOpcode::kTruncateFloat64ToFloat32:
return MarkAsFloat32(node), VisitTruncateFloat64ToFloat32(node);
case IrOpcode::kTruncateFloat64ToWord32:
return MarkAsWord32(node), VisitTruncateFloat64ToWord32(node);
case IrOpcode::kTruncateInt64ToInt32:
return MarkAsWord32(node), VisitTruncateInt64ToInt32(node);
case IrOpcode::kRoundFloat64ToInt32:
return MarkAsWord32(node), VisitRoundFloat64ToInt32(node);
case IrOpcode::kRoundInt64ToFloat32:
return MarkAsFloat32(node), VisitRoundInt64ToFloat32(node);
case IrOpcode::kRoundInt32ToFloat32:
return MarkAsFloat32(node), VisitRoundInt32ToFloat32(node);
case IrOpcode::kRoundInt64ToFloat64:
return MarkAsFloat64(node), VisitRoundInt64ToFloat64(node);
case IrOpcode::kBitcastFloat32ToInt32:
return MarkAsWord32(node), VisitBitcastFloat32ToInt32(node);
case IrOpcode::kRoundUint32ToFloat32:
return MarkAsFloat32(node), VisitRoundUint32ToFloat32(node);
case IrOpcode::kRoundUint64ToFloat32:
return MarkAsFloat64(node), VisitRoundUint64ToFloat32(node);
case IrOpcode::kRoundUint64ToFloat64:
return MarkAsFloat64(node), VisitRoundUint64ToFloat64(node);
case IrOpcode::kBitcastFloat64ToInt64:
return MarkAsWord64(node), VisitBitcastFloat64ToInt64(node);
case IrOpcode::kBitcastInt32ToFloat32:
return MarkAsFloat32(node), VisitBitcastInt32ToFloat32(node);
case IrOpcode::kBitcastInt64ToFloat64:
return MarkAsFloat64(node), VisitBitcastInt64ToFloat64(node);
case IrOpcode::kFloat32Add:
return MarkAsFloat32(node), VisitFloat32Add(node);
case IrOpcode::kFloat32Sub:
return MarkAsFloat32(node), VisitFloat32Sub(node);
case IrOpcode::kFloat32Neg:
return MarkAsFloat32(node), VisitFloat32Neg(node);
case IrOpcode::kFloat32Mul:
return MarkAsFloat32(node), VisitFloat32Mul(node);
case IrOpcode::kFloat32Div:
return MarkAsFloat32(node), VisitFloat32Div(node);
case IrOpcode::kFloat32Abs:
return MarkAsFloat32(node), VisitFloat32Abs(node);
case IrOpcode::kFloat32Sqrt:
return MarkAsFloat32(node), VisitFloat32Sqrt(node);
case IrOpcode::kFloat32Equal:
return VisitFloat32Equal(node);
case IrOpcode::kFloat32LessThan:
return VisitFloat32LessThan(node);
case IrOpcode::kFloat32LessThanOrEqual:
return VisitFloat32LessThanOrEqual(node);
case IrOpcode::kFloat32Max:
return MarkAsFloat32(node), VisitFloat32Max(node);
case IrOpcode::kFloat32Min:
return MarkAsFloat32(node), VisitFloat32Min(node);
case IrOpcode::kFloat64Add:
return MarkAsFloat64(node), VisitFloat64Add(node);
case IrOpcode::kFloat64Sub:
return MarkAsFloat64(node), VisitFloat64Sub(node);
case IrOpcode::kFloat64Neg:
return MarkAsFloat64(node), VisitFloat64Neg(node);
case IrOpcode::kFloat64Mul:
return MarkAsFloat64(node), VisitFloat64Mul(node);
case IrOpcode::kFloat64Div:
return MarkAsFloat64(node), VisitFloat64Div(node);
case IrOpcode::kFloat64Mod:
return MarkAsFloat64(node), VisitFloat64Mod(node);
case IrOpcode::kFloat64Min:
return MarkAsFloat64(node), VisitFloat64Min(node);
case IrOpcode::kFloat64Max:
return MarkAsFloat64(node), VisitFloat64Max(node);
case IrOpcode::kFloat64Abs:
return MarkAsFloat64(node), VisitFloat64Abs(node);
case IrOpcode::kFloat64Acos:
return MarkAsFloat64(node), VisitFloat64Acos(node);
case IrOpcode::kFloat64Acosh:
return MarkAsFloat64(node), VisitFloat64Acosh(node);
case IrOpcode::kFloat64Asin:
return MarkAsFloat64(node), VisitFloat64Asin(node);
case IrOpcode::kFloat64Asinh:
return MarkAsFloat64(node), VisitFloat64Asinh(node);
case IrOpcode::kFloat64Atan:
return MarkAsFloat64(node), VisitFloat64Atan(node);
case IrOpcode::kFloat64Atanh:
return MarkAsFloat64(node), VisitFloat64Atanh(node);
case IrOpcode::kFloat64Atan2:
return MarkAsFloat64(node), VisitFloat64Atan2(node);
case IrOpcode::kFloat64Cbrt:
return MarkAsFloat64(node), VisitFloat64Cbrt(node);
case IrOpcode::kFloat64Cos:
return MarkAsFloat64(node), VisitFloat64Cos(node);
case IrOpcode::kFloat64Cosh:
return MarkAsFloat64(node), VisitFloat64Cosh(node);
case IrOpcode::kFloat64Exp:
return MarkAsFloat64(node), VisitFloat64Exp(node);
case IrOpcode::kFloat64Expm1:
return MarkAsFloat64(node), VisitFloat64Expm1(node);
case IrOpcode::kFloat64Log:
return MarkAsFloat64(node), VisitFloat64Log(node);
case IrOpcode::kFloat64Log1p:
return MarkAsFloat64(node), VisitFloat64Log1p(node);
case IrOpcode::kFloat64Log10:
return MarkAsFloat64(node), VisitFloat64Log10(node);
case IrOpcode::kFloat64Log2:
return MarkAsFloat64(node), VisitFloat64Log2(node);
case IrOpcode::kFloat64Pow:
return MarkAsFloat64(node), VisitFloat64Pow(node);
case IrOpcode::kFloat64Sin:
return MarkAsFloat64(node), VisitFloat64Sin(node);
case IrOpcode::kFloat64Sinh:
return MarkAsFloat64(node), VisitFloat64Sinh(node);
case IrOpcode::kFloat64Sqrt:
return MarkAsFloat64(node), VisitFloat64Sqrt(node);
case IrOpcode::kFloat64Tan:
return MarkAsFloat64(node), VisitFloat64Tan(node);
case IrOpcode::kFloat64Tanh:
return MarkAsFloat64(node), VisitFloat64Tanh(node);
case IrOpcode::kFloat64Equal:
return VisitFloat64Equal(node);
case IrOpcode::kFloat64LessThan:
return VisitFloat64LessThan(node);
case IrOpcode::kFloat64LessThanOrEqual:
return VisitFloat64LessThanOrEqual(node);
case IrOpcode::kFloat32RoundDown:
return MarkAsFloat32(node), VisitFloat32RoundDown(node);
case IrOpcode::kFloat64RoundDown:
return MarkAsFloat64(node), VisitFloat64RoundDown(node);
case IrOpcode::kFloat32RoundUp:
return MarkAsFloat32(node), VisitFloat32RoundUp(node);
case IrOpcode::kFloat64RoundUp:
return MarkAsFloat64(node), VisitFloat64RoundUp(node);
case IrOpcode::kFloat32RoundTruncate:
return MarkAsFloat32(node), VisitFloat32RoundTruncate(node);
case IrOpcode::kFloat64RoundTruncate:
return MarkAsFloat64(node), VisitFloat64RoundTruncate(node);
case IrOpcode::kFloat64RoundTiesAway:
return MarkAsFloat64(node), VisitFloat64RoundTiesAway(node);
case IrOpcode::kFloat32RoundTiesEven:
return MarkAsFloat32(node), VisitFloat32RoundTiesEven(node);
case IrOpcode::kFloat64RoundTiesEven:
return MarkAsFloat64(node), VisitFloat64RoundTiesEven(node);
case IrOpcode::kFloat64ExtractLowWord32:
return MarkAsWord32(node), VisitFloat64ExtractLowWord32(node);
case IrOpcode::kFloat64ExtractHighWord32:
return MarkAsWord32(node), VisitFloat64ExtractHighWord32(node);
case IrOpcode::kFloat64InsertLowWord32:
return MarkAsFloat64(node), VisitFloat64InsertLowWord32(node);
case IrOpcode::kFloat64InsertHighWord32:
return MarkAsFloat64(node), VisitFloat64InsertHighWord32(node);
case IrOpcode::kTaggedPoisonOnSpeculation:
return MarkAsReference(node), VisitTaggedPoisonOnSpeculation(node);
case IrOpcode::kWord32PoisonOnSpeculation:
return MarkAsWord32(node), VisitWord32PoisonOnSpeculation(node);
case IrOpcode::kWord64PoisonOnSpeculation:
return MarkAsWord64(node), VisitWord64PoisonOnSpeculation(node);
case IrOpcode::kStackSlot:
return VisitStackSlot(node);
case IrOpcode::kLoadStackPointer:
return VisitLoadStackPointer(node);
case IrOpcode::kLoadFramePointer:
return VisitLoadFramePointer(node);
case IrOpcode::kLoadParentFramePointer:
return VisitLoadParentFramePointer(node);
case IrOpcode::kUnalignedLoad: {
LoadRepresentation type = LoadRepresentationOf(node->op());
MarkAsRepresentation(type.representation(), node);
return VisitUnalignedLoad(node);
}
case IrOpcode::kUnalignedStore:
return VisitUnalignedStore(node);
case IrOpcode::kInt32PairAdd:
MarkAsWord32(node);
MarkPairProjectionsAsWord32(node);
return VisitInt32PairAdd(node);
case IrOpcode::kInt32PairSub:
MarkAsWord32(node);
MarkPairProjectionsAsWord32(node);
return VisitInt32PairSub(node);
case IrOpcode::kInt32PairMul:
MarkAsWord32(node);
MarkPairProjectionsAsWord32(node);
return VisitInt32PairMul(node);
case IrOpcode::kWord32PairShl:
MarkAsWord32(node);
MarkPairProjectionsAsWord32(node);
return VisitWord32PairShl(node);
case IrOpcode::kWord32PairShr:
MarkAsWord32(node);
MarkPairProjectionsAsWord32(node);
return VisitWord32PairShr(node);
case IrOpcode::kWord32PairSar:
MarkAsWord32(node);
MarkPairProjectionsAsWord32(node);
return VisitWord32PairSar(node);
case IrOpcode::kWord32AtomicLoad: {
LoadRepresentation type = LoadRepresentationOf(node->op());
MarkAsRepresentation(type.representation(), node);
return VisitWord32AtomicLoad(node);
}
case IrOpcode::kWord64AtomicLoad: {
LoadRepresentation type = LoadRepresentationOf(node->op());
MarkAsRepresentation(type.representation(), node);
return VisitWord64AtomicLoad(node);
}
case IrOpcode::kWord32AtomicStore:
return VisitWord32AtomicStore(node);
case IrOpcode::kWord64AtomicStore:
return VisitWord64AtomicStore(node);
case IrOpcode::kWord32AtomicPairStore:
return VisitWord32AtomicPairStore(node);
case IrOpcode::kWord32AtomicPairLoad: {
MarkAsWord32(node);
MarkPairProjectionsAsWord32(node);
return VisitWord32AtomicPairLoad(node);
}
#define ATOMIC_CASE(name, rep) \
case IrOpcode::k##rep##Atomic##name: { \
MachineType type = AtomicOpType(node->op()); \
MarkAsRepresentation(type.representation(), node); \
return Visit##rep##Atomic##name(node); \
}
ATOMIC_CASE(Add, Word32)
ATOMIC_CASE(Add, Word64)
ATOMIC_CASE(Sub, Word32)
ATOMIC_CASE(Sub, Word64)
ATOMIC_CASE(And, Word32)
ATOMIC_CASE(And, Word64)
ATOMIC_CASE(Or, Word32)
ATOMIC_CASE(Or, Word64)
ATOMIC_CASE(Xor, Word32)
ATOMIC_CASE(Xor, Word64)
ATOMIC_CASE(Exchange, Word32)
ATOMIC_CASE(Exchange, Word64)
ATOMIC_CASE(CompareExchange, Word32)
ATOMIC_CASE(CompareExchange, Word64)
#undef ATOMIC_CASE
#define ATOMIC_CASE(name) \
case IrOpcode::kWord32AtomicPair##name: { \
MarkAsWord32(node); \
MarkPairProjectionsAsWord32(node); \
return VisitWord32AtomicPair##name(node); \
}
ATOMIC_CASE(Add)
ATOMIC_CASE(Sub)
ATOMIC_CASE(And)
ATOMIC_CASE(Or)
ATOMIC_CASE(Xor)
ATOMIC_CASE(Exchange)
ATOMIC_CASE(CompareExchange)
#undef ATOMIC_CASE
case IrOpcode::kSpeculationFence:
return VisitSpeculationFence(node);
case IrOpcode::kProtectedLoad: {
LoadRepresentation type = LoadRepresentationOf(node->op());
MarkAsRepresentation(type.representation(), node);
return VisitProtectedLoad(node);
}
case IrOpcode::kSignExtendWord8ToInt32:
return MarkAsWord32(node), VisitSignExtendWord8ToInt32(node);
case IrOpcode::kSignExtendWord16ToInt32:
return MarkAsWord32(node), VisitSignExtendWord16ToInt32(node);
case IrOpcode::kSignExtendWord8ToInt64:
return MarkAsWord64(node), VisitSignExtendWord8ToInt64(node);
case IrOpcode::kSignExtendWord16ToInt64:
return MarkAsWord64(node), VisitSignExtendWord16ToInt64(node);
case IrOpcode::kSignExtendWord32ToInt64:
return MarkAsWord64(node), VisitSignExtendWord32ToInt64(node);
case IrOpcode::kUnsafePointerAdd:
MarkAsRepresentation(MachineType::PointerRepresentation(), node);
return VisitUnsafePointerAdd(node);
case IrOpcode::kF32x4Splat:
return MarkAsSimd128(node), VisitF32x4Splat(node);
case IrOpcode::kF32x4ExtractLane:
return MarkAsFloat32(node), VisitF32x4ExtractLane(node);
case IrOpcode::kF32x4ReplaceLane:
return MarkAsSimd128(node), VisitF32x4ReplaceLane(node);
case IrOpcode::kF32x4SConvertI32x4:
return MarkAsSimd128(node), VisitF32x4SConvertI32x4(node);
case IrOpcode::kF32x4UConvertI32x4:
return MarkAsSimd128(node), VisitF32x4UConvertI32x4(node);
case IrOpcode::kF32x4Abs:
return MarkAsSimd128(node), VisitF32x4Abs(node);
case IrOpcode::kF32x4Neg:
return MarkAsSimd128(node), VisitF32x4Neg(node);
case IrOpcode::kF32x4RecipApprox:
return MarkAsSimd128(node), VisitF32x4RecipApprox(node);
case IrOpcode::kF32x4RecipSqrtApprox:
return MarkAsSimd128(node), VisitF32x4RecipSqrtApprox(node);
case IrOpcode::kF32x4Add:
return MarkAsSimd128(node), VisitF32x4Add(node);
case IrOpcode::kF32x4AddHoriz:
return MarkAsSimd128(node), VisitF32x4AddHoriz(node);
case IrOpcode::kF32x4Sub:
return MarkAsSimd128(node), VisitF32x4Sub(node);
case IrOpcode::kF32x4Mul:
return MarkAsSimd128(node), VisitF32x4Mul(node);
case IrOpcode::kF32x4Min:
return MarkAsSimd128(node), VisitF32x4Min(node);
case IrOpcode::kF32x4Max:
return MarkAsSimd128(node), VisitF32x4Max(node);
case IrOpcode::kF32x4Eq:
return MarkAsSimd128(node), VisitF32x4Eq(node);
case IrOpcode::kF32x4Ne:
return MarkAsSimd128(node), VisitF32x4Ne(node);
case IrOpcode::kF32x4Lt:
return MarkAsSimd128(node), VisitF32x4Lt(node);
case IrOpcode::kF32x4Le:
return MarkAsSimd128(node), VisitF32x4Le(node);
case IrOpcode::kI32x4Splat:
return MarkAsSimd128(node), VisitI32x4Splat(node);
case IrOpcode::kI32x4ExtractLane:
return MarkAsWord32(node), VisitI32x4ExtractLane(node);
case IrOpcode::kI32x4ReplaceLane:
return MarkAsSimd128(node), VisitI32x4ReplaceLane(node);
case IrOpcode::kI32x4SConvertF32x4:
return MarkAsSimd128(node), VisitI32x4SConvertF32x4(node);
case IrOpcode::kI32x4SConvertI16x8Low:
return MarkAsSimd128(node), VisitI32x4SConvertI16x8Low(node);
case IrOpcode::kI32x4SConvertI16x8High:
return MarkAsSimd128(node), VisitI32x4SConvertI16x8High(node);
case IrOpcode::kI32x4Neg:
return MarkAsSimd128(node), VisitI32x4Neg(node);
case IrOpcode::kI32x4Shl:
return MarkAsSimd128(node), VisitI32x4Shl(node);
case IrOpcode::kI32x4ShrS:
return MarkAsSimd128(node), VisitI32x4ShrS(node);
case IrOpcode::kI32x4Add:
return MarkAsSimd128(node), VisitI32x4Add(node);
case IrOpcode::kI32x4AddHoriz:
return MarkAsSimd128(node), VisitI32x4AddHoriz(node);
case IrOpcode::kI32x4Sub:
return MarkAsSimd128(node), VisitI32x4Sub(node);
case IrOpcode::kI32x4Mul:
return MarkAsSimd128(node), VisitI32x4Mul(node);
case IrOpcode::kI32x4MinS:
return MarkAsSimd128(node), VisitI32x4MinS(node);
case IrOpcode::kI32x4MaxS:
return MarkAsSimd128(node), VisitI32x4MaxS(node);
case IrOpcode::kI32x4Eq:
return MarkAsSimd128(node), VisitI32x4Eq(node);
case IrOpcode::kI32x4Ne:
return MarkAsSimd128(node), VisitI32x4Ne(node);
case IrOpcode::kI32x4GtS:
return MarkAsSimd128(node), VisitI32x4GtS(node);
case IrOpcode::kI32x4GeS:
return MarkAsSimd128(node), VisitI32x4GeS(node);
case IrOpcode::kI32x4UConvertF32x4:
return MarkAsSimd128(node), VisitI32x4UConvertF32x4(node);
case IrOpcode::kI32x4UConvertI16x8Low:
return MarkAsSimd128(node), VisitI32x4UConvertI16x8Low(node);
case IrOpcode::kI32x4UConvertI16x8High:
return MarkAsSimd128(node), VisitI32x4UConvertI16x8High(node);
case IrOpcode::kI32x4ShrU:
return MarkAsSimd128(node), VisitI32x4ShrU(node);
case IrOpcode::kI32x4MinU:
return MarkAsSimd128(node), VisitI32x4MinU(node);
case IrOpcode::kI32x4MaxU:
return MarkAsSimd128(node), VisitI32x4MaxU(node);
case IrOpcode::kI32x4GtU:
return MarkAsSimd128(node), VisitI32x4GtU(node);
case IrOpcode::kI32x4GeU:
return MarkAsSimd128(node), VisitI32x4GeU(node);
case IrOpcode::kI16x8Splat:
return MarkAsSimd128(node), VisitI16x8Splat(node);
case IrOpcode::kI16x8ExtractLane:
return MarkAsWord32(node), VisitI16x8ExtractLane(node);
case IrOpcode::kI16x8ReplaceLane:
return MarkAsSimd128(node), VisitI16x8ReplaceLane(node);
case IrOpcode::kI16x8SConvertI8x16Low:
return MarkAsSimd128(node), VisitI16x8SConvertI8x16Low(node);
case IrOpcode::kI16x8SConvertI8x16High:
return MarkAsSimd128(node), VisitI16x8SConvertI8x16High(node);
case IrOpcode::kI16x8Neg:
return MarkAsSimd128(node), VisitI16x8Neg(node);
case IrOpcode::kI16x8Shl:
return MarkAsSimd128(node), VisitI16x8Shl(node);
case IrOpcode::kI16x8ShrS:
return MarkAsSimd128(node), VisitI16x8ShrS(node);
case IrOpcode::kI16x8SConvertI32x4:
return MarkAsSimd128(node), VisitI16x8SConvertI32x4(node);
case IrOpcode::kI16x8Add:
return MarkAsSimd128(node), VisitI16x8Add(node);
case IrOpcode::kI16x8AddSaturateS:
return MarkAsSimd128(node), VisitI16x8AddSaturateS(node);
case IrOpcode::kI16x8AddHoriz:
return MarkAsSimd128(node), VisitI16x8AddHoriz(node);
case IrOpcode::kI16x8Sub:
return MarkAsSimd128(node), VisitI16x8Sub(node);
case IrOpcode::kI16x8SubSaturateS:
return MarkAsSimd128(node), VisitI16x8SubSaturateS(node);
case IrOpcode::kI16x8Mul:
return MarkAsSimd128(node), VisitI16x8Mul(node);
case IrOpcode::kI16x8MinS:
return MarkAsSimd128(node), VisitI16x8MinS(node);
case IrOpcode::kI16x8MaxS:
return MarkAsSimd128(node), VisitI16x8MaxS(node);
case IrOpcode::kI16x8Eq:
return MarkAsSimd128(node), VisitI16x8Eq(node);
case IrOpcode::kI16x8Ne:
return MarkAsSimd128(node), VisitI16x8Ne(node);
case IrOpcode::kI16x8GtS:
return MarkAsSimd128(node), VisitI16x8GtS(node);
case IrOpcode::kI16x8GeS:
return MarkAsSimd128(node), VisitI16x8GeS(node);
case IrOpcode::kI16x8UConvertI8x16Low:
return MarkAsSimd128(node), VisitI16x8UConvertI8x16Low(node);
case IrOpcode::kI16x8UConvertI8x16High:
return MarkAsSimd128(node), VisitI16x8UConvertI8x16High(node);
case IrOpcode::kI16x8ShrU:
return MarkAsSimd128(node), VisitI16x8ShrU(node);
case IrOpcode::kI16x8UConvertI32x4:
return MarkAsSimd128(node), VisitI16x8UConvertI32x4(node);
case IrOpcode::kI16x8AddSaturateU:
return MarkAsSimd128(node), VisitI16x8AddSaturateU(node);
case IrOpcode::kI16x8SubSaturateU:
return MarkAsSimd128(node), VisitI16x8SubSaturateU(node);
case IrOpcode::kI16x8MinU:
return MarkAsSimd128(node), VisitI16x8MinU(node);
case IrOpcode::kI16x8MaxU:
return MarkAsSimd128(node), VisitI16x8MaxU(node);
case IrOpcode::kI16x8GtU:
return MarkAsSimd128(node), VisitI16x8GtU(node);
case IrOpcode::kI16x8GeU:
return MarkAsSimd128(node), VisitI16x8GeU(node);
case IrOpcode::kI8x16Splat:
return MarkAsSimd128(node), VisitI8x16Splat(node);
case IrOpcode::kI8x16ExtractLane:
return MarkAsWord32(node), VisitI8x16ExtractLane(node);
case IrOpcode::kI8x16ReplaceLane:
return MarkAsSimd128(node), VisitI8x16ReplaceLane(node);
case IrOpcode::kI8x16Neg:
return MarkAsSimd128(node), VisitI8x16Neg(node);
case IrOpcode::kI8x16Shl:
return MarkAsSimd128(node), VisitI8x16Shl(node);
case IrOpcode::kI8x16ShrS:
return MarkAsSimd128(node), VisitI8x16ShrS(node);
case IrOpcode::kI8x16SConvertI16x8:
return MarkAsSimd128(node), VisitI8x16SConvertI16x8(node);
case IrOpcode::kI8x16Add:
return MarkAsSimd128(node), VisitI8x16Add(node);
case IrOpcode::kI8x16AddSaturateS:
return MarkAsSimd128(node), VisitI8x16AddSaturateS(node);
case IrOpcode::kI8x16Sub:
return MarkAsSimd128(node), VisitI8x16Sub(node);
case IrOpcode::kI8x16SubSaturateS:
return MarkAsSimd128(node), VisitI8x16SubSaturateS(node);
case IrOpcode::kI8x16Mul:
return MarkAsSimd128(node), VisitI8x16Mul(node);
case IrOpcode::kI8x16MinS:
return MarkAsSimd128(node), VisitI8x16MinS(node);
case IrOpcode::kI8x16MaxS:
return MarkAsSimd128(node), VisitI8x16MaxS(node);
case IrOpcode::kI8x16Eq:
return MarkAsSimd128(node), VisitI8x16Eq(node);
case IrOpcode::kI8x16Ne:
return MarkAsSimd128(node), VisitI8x16Ne(node);
case IrOpcode::kI8x16GtS:
return MarkAsSimd128(node), VisitI8x16GtS(node);
case IrOpcode::kI8x16GeS:
return MarkAsSimd128(node), VisitI8x16GeS(node);
case IrOpcode::kI8x16ShrU:
return MarkAsSimd128(node), VisitI8x16ShrU(node);
case IrOpcode::kI8x16UConvertI16x8:
return MarkAsSimd128(node), VisitI8x16UConvertI16x8(node);
case IrOpcode::kI8x16AddSaturateU:
return MarkAsSimd128(node), VisitI8x16AddSaturateU(node);
case IrOpcode::kI8x16SubSaturateU:
return MarkAsSimd128(node), VisitI8x16SubSaturateU(node);
case IrOpcode::kI8x16MinU:
return MarkAsSimd128(node), VisitI8x16MinU(node);
case IrOpcode::kI8x16MaxU:
return MarkAsSimd128(node), VisitI8x16MaxU(node);
case IrOpcode::kI8x16GtU:
return MarkAsSimd128(node), VisitI8x16GtU(node);
case IrOpcode::kI8x16GeU:
return MarkAsSimd128(node), VisitI16x8GeU(node);
case IrOpcode::kS128Zero:
return MarkAsSimd128(node), VisitS128Zero(node);
case IrOpcode::kS128And:
return MarkAsSimd128(node), VisitS128And(node);
case IrOpcode::kS128Or:
return MarkAsSimd128(node), VisitS128Or(node);
case IrOpcode::kS128Xor:
return MarkAsSimd128(node), VisitS128Xor(node);
case IrOpcode::kS128Not:
return MarkAsSimd128(node), VisitS128Not(node);
case IrOpcode::kS128Select:
return MarkAsSimd128(node), VisitS128Select(node);
case IrOpcode::kS8x16Shuffle:
return MarkAsSimd128(node), VisitS8x16Shuffle(node);
case IrOpcode::kS1x4AnyTrue:
return MarkAsWord32(node), VisitS1x4AnyTrue(node);
case IrOpcode::kS1x4AllTrue:
return MarkAsWord32(node), VisitS1x4AllTrue(node);
case IrOpcode::kS1x8AnyTrue:
return MarkAsWord32(node), VisitS1x8AnyTrue(node);
case IrOpcode::kS1x8AllTrue:
return MarkAsWord32(node), VisitS1x8AllTrue(node);
case IrOpcode::kS1x16AnyTrue:
return MarkAsWord32(node), VisitS1x16AnyTrue(node);
case IrOpcode::kS1x16AllTrue:
return MarkAsWord32(node), VisitS1x16AllTrue(node);
default:
FATAL("Unexpected operator #%d:%s @ node #%d", node->opcode(),
node->op()->mnemonic(), node->id());
break;
}
}
void InstructionSelector::EmitWordPoisonOnSpeculation(Node* node) {
if (poisoning_level_ != PoisoningMitigationLevel::kDontPoison) {
OperandGenerator g(this);
Node* input_node = NodeProperties::GetValueInput(node, 0);
InstructionOperand input = g.UseRegister(input_node);
InstructionOperand output = g.DefineSameAsFirst(node);
Emit(kArchWordPoisonOnSpeculation, output, input);
} else {
EmitIdentity(node);
}
}
void InstructionSelector::VisitWord32PoisonOnSpeculation(Node* node) {
EmitWordPoisonOnSpeculation(node);
}
void InstructionSelector::VisitWord64PoisonOnSpeculation(Node* node) {
EmitWordPoisonOnSpeculation(node);
}
void InstructionSelector::VisitTaggedPoisonOnSpeculation(Node* node) {
EmitWordPoisonOnSpeculation(node);
}
void InstructionSelector::VisitLoadStackPointer(Node* node) {
OperandGenerator g(this);
Emit(kArchStackPointer, g.DefineAsRegister(node));
}
void InstructionSelector::VisitLoadFramePointer(Node* node) {
OperandGenerator g(this);
Emit(kArchFramePointer, g.DefineAsRegister(node));
}
void InstructionSelector::VisitLoadParentFramePointer(Node* node) {
OperandGenerator g(this);
Emit(kArchParentFramePointer, g.DefineAsRegister(node));
}
void InstructionSelector::VisitFloat64Acos(Node* node) {
VisitFloat64Ieee754Unop(node, kIeee754Float64Acos);
}
void InstructionSelector::VisitFloat64Acosh(Node* node) {
VisitFloat64Ieee754Unop(node, kIeee754Float64Acosh);
}
void InstructionSelector::VisitFloat64Asin(Node* node) {
VisitFloat64Ieee754Unop(node, kIeee754Float64Asin);
}
void InstructionSelector::VisitFloat64Asinh(Node* node) {
VisitFloat64Ieee754Unop(node, kIeee754Float64Asinh);
}
void InstructionSelector::VisitFloat64Atan(Node* node) {
VisitFloat64Ieee754Unop(node, kIeee754Float64Atan);
}
void InstructionSelector::VisitFloat64Atanh(Node* node) {
VisitFloat64Ieee754Unop(node, kIeee754Float64Atanh);
}
void InstructionSelector::VisitFloat64Atan2(Node* node) {
VisitFloat64Ieee754Binop(node, kIeee754Float64Atan2);
}
void InstructionSelector::VisitFloat64Cbrt(Node* node) {
VisitFloat64Ieee754Unop(node, kIeee754Float64Cbrt);
}
void InstructionSelector::VisitFloat64Cos(Node* node) {
VisitFloat64Ieee754Unop(node, kIeee754Float64Cos);
}
void InstructionSelector::VisitFloat64Cosh(Node* node) {
VisitFloat64Ieee754Unop(node, kIeee754Float64Cosh);
}
void InstructionSelector::VisitFloat64Exp(Node* node) {
VisitFloat64Ieee754Unop(node, kIeee754Float64Exp);
}
void InstructionSelector::VisitFloat64Expm1(Node* node) {
VisitFloat64Ieee754Unop(node, kIeee754Float64Expm1);
}
void InstructionSelector::VisitFloat64Log(Node* node) {
VisitFloat64Ieee754Unop(node, kIeee754Float64Log);
}
void InstructionSelector::VisitFloat64Log1p(Node* node) {
VisitFloat64Ieee754Unop(node, kIeee754Float64Log1p);
}
void InstructionSelector::VisitFloat64Log2(Node* node) {
VisitFloat64Ieee754Unop(node, kIeee754Float64Log2);
}
void InstructionSelector::VisitFloat64Log10(Node* node) {
VisitFloat64Ieee754Unop(node, kIeee754Float64Log10);
}
void InstructionSelector::VisitFloat64Pow(Node* node) {
VisitFloat64Ieee754Binop(node, kIeee754Float64Pow);
}
void InstructionSelector::VisitFloat64Sin(Node* node) {
VisitFloat64Ieee754Unop(node, kIeee754Float64Sin);
}
void InstructionSelector::VisitFloat64Sinh(Node* node) {
VisitFloat64Ieee754Unop(node, kIeee754Float64Sinh);
}
void InstructionSelector::VisitFloat64Tan(Node* node) {
VisitFloat64Ieee754Unop(node, kIeee754Float64Tan);
}
void InstructionSelector::VisitFloat64Tanh(Node* node) {
VisitFloat64Ieee754Unop(node, kIeee754Float64Tanh);
}
void InstructionSelector::EmitTableSwitch(const SwitchInfo& sw,
InstructionOperand& index_operand) {
OperandGenerator g(this);
size_t input_count = 2 + sw.value_range();
DCHECK_LE(sw.value_range(), std::numeric_limits<size_t>::max() - 2);
auto* inputs = zone()->NewArray<InstructionOperand>(input_count);
inputs[0] = index_operand;
InstructionOperand default_operand = g.Label(sw.default_branch());
std::fill(&inputs[1], &inputs[input_count], default_operand);
for (const CaseInfo& c : sw.CasesUnsorted()) {
size_t value = c.value - sw.min_value();
DCHECK_LE(0u, value);
DCHECK_LT(value + 2, input_count);
inputs[value + 2] = g.Label(c.branch);
}
Emit(kArchTableSwitch, 0, nullptr, input_count, inputs, 0, nullptr);
}
void InstructionSelector::EmitLookupSwitch(const SwitchInfo& sw,
InstructionOperand& value_operand) {
OperandGenerator g(this);
std::vector<CaseInfo> cases = sw.CasesSortedByOriginalOrder();
size_t input_count = 2 + sw.case_count() * 2;
DCHECK_LE(sw.case_count(), (std::numeric_limits<size_t>::max() - 2) / 2);
auto* inputs = zone()->NewArray<InstructionOperand>(input_count);
inputs[0] = value_operand;
inputs[1] = g.Label(sw.default_branch());
for (size_t index = 0; index < cases.size(); ++index) {
const CaseInfo& c = cases[index];
inputs[index * 2 + 2 + 0] = g.TempImmediate(c.value);
inputs[index * 2 + 2 + 1] = g.Label(c.branch);
}
Emit(kArchLookupSwitch, 0, nullptr, input_count, inputs, 0, nullptr);
}
void InstructionSelector::EmitBinarySearchSwitch(
const SwitchInfo& sw, InstructionOperand& value_operand) {
OperandGenerator g(this);
size_t input_count = 2 + sw.case_count() * 2;
DCHECK_LE(sw.case_count(), (std::numeric_limits<size_t>::max() - 2) / 2);
auto* inputs = zone()->NewArray<InstructionOperand>(input_count);
inputs[0] = value_operand;
inputs[1] = g.Label(sw.default_branch());
std::vector<CaseInfo> cases = sw.CasesSortedByValue();
std::stable_sort(cases.begin(), cases.end(),
[](CaseInfo a, CaseInfo b) { return a.value < b.value; });
for (size_t index = 0; index < cases.size(); ++index) {
const CaseInfo& c = cases[index];
inputs[index * 2 + 2 + 0] = g.TempImmediate(c.value);
inputs[index * 2 + 2 + 1] = g.Label(c.branch);
}
Emit(kArchBinarySearchSwitch, 0, nullptr, input_count, inputs, 0, nullptr);
}
void InstructionSelector::VisitBitcastTaggedToWord(Node* node) {
EmitIdentity(node);
}
void InstructionSelector::VisitBitcastWordToTagged(Node* node) {
OperandGenerator g(this);
Emit(kArchNop, g.DefineSameAsFirst(node), g.Use(node->InputAt(0)));
}
// 32 bit targets do not implement the following instructions.
#if V8_TARGET_ARCH_32_BIT
void InstructionSelector::VisitWord64And(Node* node) { UNIMPLEMENTED(); }
void InstructionSelector::VisitWord64Or(Node* node) { UNIMPLEMENTED(); }
void InstructionSelector::VisitWord64Xor(Node* node) { UNIMPLEMENTED(); }
void InstructionSelector::VisitWord64Shl(Node* node) { UNIMPLEMENTED(); }
void InstructionSelector::VisitWord64Shr(Node* node) { UNIMPLEMENTED(); }
void InstructionSelector::VisitWord64Sar(Node* node) { UNIMPLEMENTED(); }
void InstructionSelector::VisitWord64Ror(Node* node) { UNIMPLEMENTED(); }
void InstructionSelector::VisitWord64Clz(Node* node) { UNIMPLEMENTED(); }
void InstructionSelector::VisitWord64Ctz(Node* node) { UNIMPLEMENTED(); }
void InstructionSelector::VisitWord64ReverseBits(Node* node) {
UNIMPLEMENTED();
}
void InstructionSelector::VisitWord64Popcnt(Node* node) { UNIMPLEMENTED(); }
void InstructionSelector::VisitWord64Equal(Node* node) { UNIMPLEMENTED(); }
void InstructionSelector::VisitInt64Add(Node* node) { UNIMPLEMENTED(); }
void InstructionSelector::VisitInt64AddWithOverflow(Node* node) {
UNIMPLEMENTED();
}
void InstructionSelector::VisitInt64Sub(Node* node) { UNIMPLEMENTED(); }
void InstructionSelector::VisitInt64SubWithOverflow(Node* node) {
UNIMPLEMENTED();
}
void InstructionSelector::VisitInt64Mul(Node* node) { UNIMPLEMENTED(); }
void InstructionSelector::VisitInt64Div(Node* node) { UNIMPLEMENTED(); }
void InstructionSelector::VisitInt64LessThan(Node* node) { UNIMPLEMENTED(); }
void InstructionSelector::VisitInt64LessThanOrEqual(Node* node) {
UNIMPLEMENTED();
}
void InstructionSelector::VisitUint64Div(Node* node) { UNIMPLEMENTED(); }
void InstructionSelector::VisitInt64Mod(Node* node) { UNIMPLEMENTED(); }
void InstructionSelector::VisitUint64LessThan(Node* node) { UNIMPLEMENTED(); }
void InstructionSelector::VisitUint64LessThanOrEqual(Node* node) {
UNIMPLEMENTED();
}
void InstructionSelector::VisitUint64Mod(Node* node) { UNIMPLEMENTED(); }
void InstructionSelector::VisitChangeInt32ToInt64(Node* node) {
UNIMPLEMENTED();
}
void InstructionSelector::VisitChangeUint32ToUint64(Node* node) {
UNIMPLEMENTED();
}
void InstructionSelector::VisitChangeFloat64ToUint64(Node* node) {
UNIMPLEMENTED();
}
void InstructionSelector::VisitTryTruncateFloat32ToInt64(Node* node) {
UNIMPLEMENTED();
}
void InstructionSelector::VisitTryTruncateFloat64ToInt64(Node* node) {
UNIMPLEMENTED();
}
void InstructionSelector::VisitTryTruncateFloat32ToUint64(Node* node) {
UNIMPLEMENTED();
}
void InstructionSelector::VisitTryTruncateFloat64ToUint64(Node* node) {
UNIMPLEMENTED();
}
void InstructionSelector::VisitTruncateInt64ToInt32(Node* node) {
UNIMPLEMENTED();
}
void InstructionSelector::VisitRoundInt64ToFloat32(Node* node) {
UNIMPLEMENTED();
}
void InstructionSelector::VisitRoundInt64ToFloat64(Node* node) {
UNIMPLEMENTED();
}
void InstructionSelector::VisitRoundUint64ToFloat32(Node* node) {
UNIMPLEMENTED();
}
void InstructionSelector::VisitRoundUint64ToFloat64(Node* node) {
UNIMPLEMENTED();
}
void InstructionSelector::VisitBitcastFloat64ToInt64(Node* node) {
UNIMPLEMENTED();
}
void InstructionSelector::VisitBitcastInt64ToFloat64(Node* node) {
UNIMPLEMENTED();
}
void InstructionSelector::VisitSignExtendWord8ToInt64(Node* node) {
UNIMPLEMENTED();
}
void InstructionSelector::VisitSignExtendWord16ToInt64(Node* node) {
UNIMPLEMENTED();
}
void InstructionSelector::VisitSignExtendWord32ToInt64(Node* node) {
UNIMPLEMENTED();
}
#endif // V8_TARGET_ARCH_32_BIT
// 64 bit targets do not implement the following instructions.
#if V8_TARGET_ARCH_64_BIT
void InstructionSelector::VisitInt32PairAdd(Node* node) { UNIMPLEMENTED(); }
void InstructionSelector::VisitInt32PairSub(Node* node) { UNIMPLEMENTED(); }
void InstructionSelector::VisitInt32PairMul(Node* node) { UNIMPLEMENTED(); }
void InstructionSelector::VisitWord32PairShl(Node* node) { UNIMPLEMENTED(); }
void InstructionSelector::VisitWord32PairShr(Node* node) { UNIMPLEMENTED(); }
void InstructionSelector::VisitWord32PairSar(Node* node) { UNIMPLEMENTED(); }
#endif // V8_TARGET_ARCH_64_BIT
#if !V8_TARGET_ARCH_IA32 && !V8_TARGET_ARCH_ARM
void InstructionSelector::VisitWord32AtomicPairLoad(Node* node) {
UNIMPLEMENTED();
}
void InstructionSelector::VisitWord32AtomicPairStore(Node* node) {
UNIMPLEMENTED();
}
void InstructionSelector::VisitWord32AtomicPairAdd(Node* node) {
UNIMPLEMENTED();
}
void InstructionSelector::VisitWord32AtomicPairSub(Node* node) {
UNIMPLEMENTED();
}
void InstructionSelector::VisitWord32AtomicPairAnd(Node* node) {
UNIMPLEMENTED();
}
void InstructionSelector::VisitWord32AtomicPairOr(Node* node) {
UNIMPLEMENTED();
}
void InstructionSelector::VisitWord32AtomicPairXor(Node* node) {
UNIMPLEMENTED();
}
void InstructionSelector::VisitWord32AtomicPairExchange(Node* node) {
UNIMPLEMENTED();
}
void InstructionSelector::VisitWord32AtomicPairCompareExchange(Node* node) {
UNIMPLEMENTED();
}
#endif // !V8_TARGET_ARCH_IA32 && !V8_TARGET_ARCH_ARM
#if !V8_TARGET_ARCH_ARM && !V8_TARGET_ARCH_ARM64 && !V8_TARGET_ARCH_MIPS && \
!V8_TARGET_ARCH_MIPS64 && !V8_TARGET_ARCH_IA32
void InstructionSelector::VisitF32x4SConvertI32x4(Node* node) {
UNIMPLEMENTED();
}
void InstructionSelector::VisitF32x4UConvertI32x4(Node* node) {
UNIMPLEMENTED();
}
#endif // !V8_TARGET_ARCH_ARM && !V8_TARGET_ARCH_ARM64 && !V8_TARGET_ARCH_MIPS
// && !V8_TARGET_ARCH_MIPS64 && !V8_TARGET_ARCH_IA32
#if !V8_TARGET_ARCH_X64 && !V8_TARGET_ARCH_ARM64
void InstructionSelector::VisitWord64AtomicLoad(Node* node) { UNIMPLEMENTED(); }
void InstructionSelector::VisitWord64AtomicStore(Node* node) {
UNIMPLEMENTED();
}
void InstructionSelector::VisitWord64AtomicAdd(Node* node) { UNIMPLEMENTED(); }
void InstructionSelector::VisitWord64AtomicSub(Node* node) { UNIMPLEMENTED(); }
void InstructionSelector::VisitWord64AtomicAnd(Node* node) { UNIMPLEMENTED(); }
void InstructionSelector::VisitWord64AtomicOr(Node* node) { UNIMPLEMENTED(); }
void InstructionSelector::VisitWord64AtomicXor(Node* node) { UNIMPLEMENTED(); }
void InstructionSelector::VisitWord64AtomicExchange(Node* node) {
UNIMPLEMENTED();
}
void InstructionSelector::VisitWord64AtomicCompareExchange(Node* node) {
UNIMPLEMENTED();
}
#endif // !V8_TARGET_ARCH_X64 && !V8_TARGET_ARCH_ARM64
#if !V8_TARGET_ARCH_ARM && !V8_TARGET_ARCH_ARM64 && !V8_TARGET_ARCH_MIPS && \
!V8_TARGET_ARCH_MIPS64 && !V8_TARGET_ARCH_IA32
void InstructionSelector::VisitI32x4SConvertF32x4(Node* node) {
UNIMPLEMENTED();
}
void InstructionSelector::VisitI32x4UConvertF32x4(Node* node) {
UNIMPLEMENTED();
}
void InstructionSelector::VisitI32x4SConvertI16x8Low(Node* node) {
UNIMPLEMENTED();
}
void InstructionSelector::VisitI32x4SConvertI16x8High(Node* node) {
UNIMPLEMENTED();
}
void InstructionSelector::VisitI32x4UConvertI16x8Low(Node* node) {
UNIMPLEMENTED();
}
void InstructionSelector::VisitI32x4UConvertI16x8High(Node* node) {
UNIMPLEMENTED();
}
void InstructionSelector::VisitI16x8SConvertI8x16Low(Node* node) {
UNIMPLEMENTED();
}
void InstructionSelector::VisitI16x8SConvertI8x16High(Node* node) {
UNIMPLEMENTED();
}
void InstructionSelector::VisitI16x8UConvertI8x16Low(Node* node) {
UNIMPLEMENTED();
}
void InstructionSelector::VisitI16x8UConvertI8x16High(Node* node) {
UNIMPLEMENTED();
}
void InstructionSelector::VisitI16x8SConvertI32x4(Node* node) {
UNIMPLEMENTED();
}
void InstructionSelector::VisitI16x8UConvertI32x4(Node* node) {
UNIMPLEMENTED();
}
void InstructionSelector::VisitI8x16SConvertI16x8(Node* node) {
UNIMPLEMENTED();
}
void InstructionSelector::VisitI8x16UConvertI16x8(Node* node) {
UNIMPLEMENTED();
}
void InstructionSelector::VisitI8x16Shl(Node* node) { UNIMPLEMENTED(); }
void InstructionSelector::VisitI8x16ShrS(Node* node) { UNIMPLEMENTED(); }
void InstructionSelector::VisitI8x16ShrU(Node* node) { UNIMPLEMENTED(); }
void InstructionSelector::VisitI8x16Mul(Node* node) { UNIMPLEMENTED(); }
void InstructionSelector::VisitS8x16Shuffle(Node* node) { UNIMPLEMENTED(); }
void InstructionSelector::VisitS1x4AnyTrue(Node* node) { UNIMPLEMENTED(); }
void InstructionSelector::VisitS1x4AllTrue(Node* node) { UNIMPLEMENTED(); }
void InstructionSelector::VisitS1x8AnyTrue(Node* node) { UNIMPLEMENTED(); }
void InstructionSelector::VisitS1x8AllTrue(Node* node) { UNIMPLEMENTED(); }
void InstructionSelector::VisitS1x16AnyTrue(Node* node) { UNIMPLEMENTED(); }
void InstructionSelector::VisitS1x16AllTrue(Node* node) { UNIMPLEMENTED(); }
#endif // !V8_TARGET_ARCH_ARM && !V8_TARGET_ARCH_ARM64 && !V8_TARGET_ARCH_MIPS
// && !V8_TARGET_ARCH_MIPS64 && !V8_TARGET_ARCH_IA32
void InstructionSelector::VisitFinishRegion(Node* node) { EmitIdentity(node); }
void InstructionSelector::VisitParameter(Node* node) {
OperandGenerator g(this);
int index = ParameterIndexOf(node->op());
InstructionOperand op =
linkage()->ParameterHasSecondaryLocation(index)
? g.DefineAsDualLocation(
node, linkage()->GetParameterLocation(index),
linkage()->GetParameterSecondaryLocation(index))
: g.DefineAsLocation(node, linkage()->GetParameterLocation(index));
Emit(kArchNop, op);
}
namespace {
LinkageLocation ExceptionLocation() {
return LinkageLocation::ForRegister(kReturnRegister0.code(),
MachineType::IntPtr());
}
}
void InstructionSelector::VisitIfException(Node* node) {
OperandGenerator g(this);
DCHECK_EQ(IrOpcode::kCall, node->InputAt(1)->opcode());
Emit(kArchNop, g.DefineAsLocation(node, ExceptionLocation()));
}
void InstructionSelector::VisitOsrValue(Node* node) {
OperandGenerator g(this);
int index = OsrValueIndexOf(node->op());
Emit(kArchNop,
g.DefineAsLocation(node, linkage()->GetOsrValueLocation(index)));
}
void InstructionSelector::VisitPhi(Node* node) {
const int input_count = node->op()->ValueInputCount();
DCHECK_EQ(input_count, current_block_->PredecessorCount());
PhiInstruction* phi = new (instruction_zone())
PhiInstruction(instruction_zone(), GetVirtualRegister(node),
static_cast<size_t>(input_count));
sequence()
->InstructionBlockAt(RpoNumber::FromInt(current_block_->rpo_number()))
->AddPhi(phi);
for (int i = 0; i < input_count; ++i) {
Node* const input = node->InputAt(i);
MarkAsUsed(input);
phi->SetInput(static_cast<size_t>(i), GetVirtualRegister(input));
}
}
void InstructionSelector::VisitProjection(Node* node) {
OperandGenerator g(this);
Node* value = node->InputAt(0);
switch (value->opcode()) {
case IrOpcode::kInt32AddWithOverflow:
case IrOpcode::kInt32SubWithOverflow:
case IrOpcode::kInt32MulWithOverflow:
case IrOpcode::kInt64AddWithOverflow:
case IrOpcode::kInt64SubWithOverflow:
case IrOpcode::kTryTruncateFloat32ToInt64:
case IrOpcode::kTryTruncateFloat64ToInt64:
case IrOpcode::kTryTruncateFloat32ToUint64:
case IrOpcode::kTryTruncateFloat64ToUint64:
case IrOpcode::kInt32PairAdd:
case IrOpcode::kInt32PairSub:
case IrOpcode::kInt32PairMul:
case IrOpcode::kWord32PairShl:
case IrOpcode::kWord32PairShr:
case IrOpcode::kWord32PairSar:
case IrOpcode::kInt32AbsWithOverflow:
case IrOpcode::kInt64AbsWithOverflow:
if (ProjectionIndexOf(node->op()) == 0u) {
Emit(kArchNop, g.DefineSameAsFirst(node), g.Use(value));
} else {
DCHECK_EQ(1u, ProjectionIndexOf(node->op()));
MarkAsUsed(value);
}
break;
default:
break;
}
}
void InstructionSelector::VisitConstant(Node* node) {
// We must emit a NOP here because every live range needs a defining
// instruction in the register allocator.
OperandGenerator g(this);
Emit(kArchNop, g.DefineAsConstant(node));
}
void InstructionSelector::VisitCall(Node* node, BasicBlock* handler) {
OperandGenerator g(this);
auto call_descriptor = CallDescriptorOf(node->op());
FrameStateDescriptor* frame_state_descriptor = nullptr;
if (call_descriptor->NeedsFrameState()) {
frame_state_descriptor = GetFrameStateDescriptor(
node->InputAt(static_cast<int>(call_descriptor->InputCount())));
}
CallBuffer buffer(zone(), call_descriptor, frame_state_descriptor);
// Compute InstructionOperands for inputs and outputs.
// TODO(turbofan): on some architectures it's probably better to use
// the code object in a register if there are multiple uses of it.
// Improve constant pool and the heuristics in the register allocator
// for where to emit constants.
CallBufferFlags call_buffer_flags(kCallCodeImmediate | kCallAddressImmediate);
InitializeCallBuffer(node, &buffer, call_buffer_flags, false);
EmitPrepareArguments(&(buffer.pushed_nodes), call_descriptor, node);
// Pass label of exception handler block.
CallDescriptor::Flags flags = call_descriptor->flags();
if (handler) {
DCHECK_EQ(IrOpcode::kIfException, handler->front()->opcode());
flags |= CallDescriptor::kHasExceptionHandler;
buffer.instruction_args.push_back(g.Label(handler));
}
// Select the appropriate opcode based on the call type.
InstructionCode opcode = kArchNop;
switch (call_descriptor->kind()) {
case CallDescriptor::kCallAddress:
opcode = kArchCallCFunction | MiscField::encode(static_cast<int>(
call_descriptor->ParameterCount()));
break;
case CallDescriptor::kCallCodeObject:
opcode = kArchCallCodeObject | MiscField::encode(flags);
break;
case CallDescriptor::kCallJSFunction:
opcode = kArchCallJSFunction | MiscField::encode(flags);
break;
case CallDescriptor::kCallWasmFunction:
opcode = kArchCallWasmFunction | MiscField::encode(flags);
break;
}
// Emit the call instruction.
size_t const output_count = buffer.outputs.size();
auto* outputs = output_count ? &buffer.outputs.front() : nullptr;
Instruction* call_instr =
Emit(opcode, output_count, outputs, buffer.instruction_args.size(),
&buffer.instruction_args.front());
if (instruction_selection_failed()) return;
call_instr->MarkAsCall();
EmitPrepareResults(&(buffer.output_nodes), call_descriptor, node);
}
void InstructionSelector::VisitCallWithCallerSavedRegisters(
Node* node, BasicBlock* handler) {
OperandGenerator g(this);
const auto fp_mode = CallDescriptorOf(node->op())->get_save_fp_mode();
Emit(kArchSaveCallerRegisters | MiscField::encode(static_cast<int>(fp_mode)),
g.NoOutput());
VisitCall(node, handler);
Emit(kArchRestoreCallerRegisters |
MiscField::encode(static_cast<int>(fp_mode)),
g.NoOutput());
}
void InstructionSelector::VisitTailCall(Node* node) {
OperandGenerator g(this);
auto call_descriptor = CallDescriptorOf(node->op());
CallDescriptor* caller = linkage()->GetIncomingDescriptor();
DCHECK(caller->CanTailCall(node));
const CallDescriptor* callee = CallDescriptorOf(node->op());
int stack_param_delta = callee->GetStackParameterDelta(caller);
CallBuffer buffer(zone(), call_descriptor, nullptr);
// Compute InstructionOperands for inputs and outputs.
CallBufferFlags flags(kCallCodeImmediate | kCallTail);
if (IsTailCallAddressImmediate()) {
flags |= kCallAddressImmediate;
}
if (callee->flags() & CallDescriptor::kFixedTargetRegister) {
flags |= kCallFixedTargetRegister;
}
InitializeCallBuffer(node, &buffer, flags, true, stack_param_delta);
// Select the appropriate opcode based on the call type.
InstructionCode opcode;
InstructionOperandVector temps(zone());
if (linkage()->GetIncomingDescriptor()->IsJSFunctionCall()) {
switch (call_descriptor->kind()) {
case CallDescriptor::kCallCodeObject:
opcode = kArchTailCallCodeObjectFromJSFunction;
break;
default:
UNREACHABLE();
return;
}
int temps_count = GetTempsCountForTailCallFromJSFunction();
for (int i = 0; i < temps_count; i++) {
temps.push_back(g.TempRegister());
}
} else {
switch (call_descriptor->kind()) {
case CallDescriptor::kCallCodeObject:
opcode = kArchTailCallCodeObject;
break;
case CallDescriptor::kCallAddress:
opcode = kArchTailCallAddress;
break;
case CallDescriptor::kCallWasmFunction:
opcode = kArchTailCallWasm;
break;
default:
UNREACHABLE();
return;
}
}
opcode |= MiscField::encode(call_descriptor->flags());
Emit(kArchPrepareTailCall, g.NoOutput());
// Add an immediate operand that represents the first slot that is unused
// with respect to the stack pointer that has been updated for the tail call
// instruction. This is used by backends that need to pad arguments for stack
// alignment, in order to store an optional slot of padding above the
// arguments.
int optional_padding_slot = callee->GetFirstUnusedStackSlot();
buffer.instruction_args.push_back(g.TempImmediate(optional_padding_slot));
int first_unused_stack_slot =
(V8_TARGET_ARCH_STORES_RETURN_ADDRESS_ON_STACK ? 1 : 0) +
stack_param_delta;
buffer.instruction_args.push_back(g.TempImmediate(first_unused_stack_slot));
// Emit the tailcall instruction.
Emit(opcode, 0, nullptr, buffer.instruction_args.size(),
&buffer.instruction_args.front(), temps.size(),
temps.empty() ? nullptr : &temps.front());
}
void InstructionSelector::VisitGoto(BasicBlock* target) {
// jump to the next block.
OperandGenerator g(this);
Emit(kArchJmp, g.NoOutput(), g.Label(target));
}
void InstructionSelector::VisitReturn(Node* ret) {
OperandGenerator g(this);
const int input_count = linkage()->GetIncomingDescriptor()->ReturnCount() == 0
? 1
: ret->op()->ValueInputCount();
DCHECK_GE(input_count, 1);
auto value_locations = zone()->NewArray<InstructionOperand>(input_count);
Node* pop_count = ret->InputAt(0);
value_locations[0] = (pop_count->opcode() == IrOpcode::kInt32Constant ||
pop_count->opcode() == IrOpcode::kInt64Constant)
? g.UseImmediate(pop_count)
: g.UseRegister(pop_count);
for (int i = 1; i < input_count; ++i) {
value_locations[i] =
g.UseLocation(ret->InputAt(i), linkage()->GetReturnLocation(i - 1));
}
Emit(kArchRet, 0, nullptr, input_count, value_locations);
}
void InstructionSelector::VisitBranch(Node* branch, BasicBlock* tbranch,
BasicBlock* fbranch) {
if (NeedsPoisoning(IsSafetyCheckOf(branch->op()))) {
FlagsContinuation cont =
FlagsContinuation::ForBranchAndPoison(kNotEqual, tbranch, fbranch);
VisitWordCompareZero(branch, branch->InputAt(0), &cont);
} else {
FlagsContinuation cont =
FlagsContinuation::ForBranch(kNotEqual, tbranch, fbranch);
VisitWordCompareZero(branch, branch->InputAt(0), &cont);
}
}
void InstructionSelector::VisitDeoptimizeIf(Node* node) {
DeoptimizeParameters p = DeoptimizeParametersOf(node->op());
if (NeedsPoisoning(p.is_safety_check())) {
FlagsContinuation cont = FlagsContinuation::ForDeoptimizeAndPoison(
kNotEqual, p.kind(), p.reason(), p.feedback(), node->InputAt(1));
VisitWordCompareZero(node, node->InputAt(0), &cont);
} else {
FlagsContinuation cont = FlagsContinuation::ForDeoptimize(
kNotEqual, p.kind(), p.reason(), p.feedback(), node->InputAt(1));
VisitWordCompareZero(node, node->InputAt(0), &cont);
}
}
void InstructionSelector::VisitDeoptimizeUnless(Node* node) {
DeoptimizeParameters p = DeoptimizeParametersOf(node->op());
if (NeedsPoisoning(p.is_safety_check())) {
FlagsContinuation cont = FlagsContinuation::ForDeoptimizeAndPoison(
kEqual, p.kind(), p.reason(), p.feedback(), node->InputAt(1));
VisitWordCompareZero(node, node->InputAt(0), &cont);
} else {
FlagsContinuation cont = FlagsContinuation::ForDeoptimize(
kEqual, p.kind(), p.reason(), p.feedback(), node->InputAt(1));
VisitWordCompareZero(node, node->InputAt(0), &cont);
}
}
void InstructionSelector::VisitTrapIf(Node* node, TrapId trap_id) {
FlagsContinuation cont =
FlagsContinuation::ForTrap(kNotEqual, trap_id, node->InputAt(1));
VisitWordCompareZero(node, node->InputAt(0), &cont);
}
void InstructionSelector::VisitTrapUnless(Node* node, TrapId trap_id) {
FlagsContinuation cont =
FlagsContinuation::ForTrap(kEqual, trap_id, node->InputAt(1));
VisitWordCompareZero(node, node->InputAt(0), &cont);
}
void InstructionSelector::EmitIdentity(Node* node) {
OperandGenerator g(this);
MarkAsUsed(node->InputAt(0));
SetRename(node, node->InputAt(0));
}
void InstructionSelector::VisitDeoptimize(DeoptimizeKind kind,
DeoptimizeReason reason,
VectorSlotPair const& feedback,
Node* value) {
EmitDeoptimize(kArchDeoptimize, 0, nullptr, 0, nullptr, kind, reason,
feedback, value);
}
void InstructionSelector::VisitThrow(Node* node) {
OperandGenerator g(this);
Emit(kArchThrowTerminator, g.NoOutput());
}
void InstructionSelector::VisitDebugBreak(Node* node) {
OperandGenerator g(this);
Emit(kArchDebugBreak, g.NoOutput());
}
void InstructionSelector::VisitUnreachable(Node* node) {
OperandGenerator g(this);
Emit(kArchDebugBreak, g.NoOutput());
}
void InstructionSelector::VisitDeadValue(Node* node) {
OperandGenerator g(this);
MarkAsRepresentation(DeadValueRepresentationOf(node->op()), node);
Emit(kArchDebugBreak, g.DefineAsConstant(node));
}
void InstructionSelector::VisitComment(Node* node) {
OperandGenerator g(this);
InstructionOperand operand(g.UseImmediate(node));
Emit(kArchComment, 0, nullptr, 1, &operand);
}
void InstructionSelector::VisitUnsafePointerAdd(Node* node) {
#if V8_TARGET_ARCH_64_BIT
VisitInt64Add(node);
#else // V8_TARGET_ARCH_64_BIT
VisitInt32Add(node);
#endif // V8_TARGET_ARCH_64_BIT
}
void InstructionSelector::VisitRetain(Node* node) {
OperandGenerator g(this);
Emit(kArchNop, g.NoOutput(), g.UseAny(node->InputAt(0)));
}
bool InstructionSelector::CanProduceSignalingNaN(Node* node) {
// TODO(jarin) Improve the heuristic here.
if (node->opcode() == IrOpcode::kFloat64Add ||
node->opcode() == IrOpcode::kFloat64Sub ||
node->opcode() == IrOpcode::kFloat64Mul) {
return false;
}
return true;
}
FrameStateDescriptor* InstructionSelector::GetFrameStateDescriptor(
Node* state) {
DCHECK_EQ(IrOpcode::kFrameState, state->opcode());
DCHECK_EQ(kFrameStateInputCount, state->InputCount());
FrameStateInfo state_info = FrameStateInfoOf(state->op());
int parameters = static_cast<int>(
StateValuesAccess(state->InputAt(kFrameStateParametersInput)).size());
int locals = static_cast<int>(
StateValuesAccess(state->InputAt(kFrameStateLocalsInput)).size());
int stack = static_cast<int>(
StateValuesAccess(state->InputAt(kFrameStateStackInput)).size());
DCHECK_EQ(parameters, state_info.parameter_count());
DCHECK_EQ(locals, state_info.local_count());
FrameStateDescriptor* outer_state = nullptr;
Node* outer_node = state->InputAt(kFrameStateOuterStateInput);
if (outer_node->opcode() == IrOpcode::kFrameState) {
outer_state = GetFrameStateDescriptor(outer_node);
}
return new (instruction_zone()) FrameStateDescriptor(
instruction_zone(), state_info.type(), state_info.bailout_id(),
state_info.state_combine(), parameters, locals, stack,
state_info.shared_info(), outer_state);
}
// static
void InstructionSelector::CanonicalizeShuffle(bool inputs_equal,
uint8_t* shuffle,
bool* needs_swap,
bool* is_swizzle) {
*needs_swap = false;
// Inputs equal, then it's a swizzle.
if (inputs_equal) {
*is_swizzle = true;
} else {
// Inputs are distinct; check that both are required.
bool src0_is_used = false;
bool src1_is_used = false;
for (int i = 0; i < kSimd128Size; ++i) {
if (shuffle[i] < kSimd128Size) {
src0_is_used = true;
} else {
src1_is_used = true;
}
}
if (src0_is_used && !src1_is_used) {
*is_swizzle = true;
} else if (src1_is_used && !src0_is_used) {
*needs_swap = true;
*is_swizzle = true;
} else {
*is_swizzle = false;
// Canonicalize general 2 input shuffles so that the first input lanes are
// encountered first. This makes architectural shuffle pattern matching
// easier, since we only need to consider 1 input ordering instead of 2.
if (shuffle[0] >= kSimd128Size) {
// The second operand is used first. Swap inputs and adjust the shuffle.
*needs_swap = true;
for (int i = 0; i < kSimd128Size; ++i) {
shuffle[i] ^= kSimd128Size;
}
}
}
}
if (*is_swizzle) {
for (int i = 0; i < kSimd128Size; ++i) shuffle[i] &= kSimd128Size - 1;
}
}
void InstructionSelector::CanonicalizeShuffle(Node* node, uint8_t* shuffle,
bool* is_swizzle) {
// Get raw shuffle indices.
memcpy(shuffle, OpParameter<uint8_t*>(node->op()), kSimd128Size);
bool needs_swap;
bool inputs_equal = GetVirtualRegister(node->InputAt(0)) ==
GetVirtualRegister(node->InputAt(1));
CanonicalizeShuffle(inputs_equal, shuffle, &needs_swap, is_swizzle);
if (needs_swap) {
SwapShuffleInputs(node);
}
// Duplicate the first input; for some shuffles on some architectures, it's
// easiest to implement a swizzle as a shuffle so it might be used.
if (*is_swizzle) {
node->ReplaceInput(1, node->InputAt(0));
}
}
// static
void InstructionSelector::SwapShuffleInputs(Node* node) {
Node* input0 = node->InputAt(0);
Node* input1 = node->InputAt(1);
node->ReplaceInput(0, input1);
node->ReplaceInput(1, input0);
}
// static
bool InstructionSelector::TryMatchIdentity(const uint8_t* shuffle) {
for (int i = 0; i < kSimd128Size; ++i) {
if (shuffle[i] != i) return false;
}
return true;
}
// static
bool InstructionSelector::TryMatch32x4Shuffle(const uint8_t* shuffle,
uint8_t* shuffle32x4) {
for (int i = 0; i < 4; ++i) {
if (shuffle[i * 4] % 4 != 0) return false;
for (int j = 1; j < 4; ++j) {
if (shuffle[i * 4 + j] - shuffle[i * 4 + j - 1] != 1) return false;
}
shuffle32x4[i] = shuffle[i * 4] / 4;
}
return true;
}
// static
bool InstructionSelector::TryMatch16x8Shuffle(const uint8_t* shuffle,
uint8_t* shuffle16x8) {
for (int i = 0; i < 8; ++i) {
if (shuffle[i * 2] % 2 != 0) return false;
for (int j = 1; j < 2; ++j) {
if (shuffle[i * 2 + j] - shuffle[i * 2 + j - 1] != 1) return false;
}
shuffle16x8[i] = shuffle[i * 2] / 2;
}
return true;
}
// static
bool InstructionSelector::TryMatchConcat(const uint8_t* shuffle,
uint8_t* offset) {
// Don't match the identity shuffle (e.g. [0 1 2 ... 15]).
uint8_t start = shuffle[0];
if (start == 0) return false;
DCHECK_GT(kSimd128Size, start); // The shuffle should be canonicalized.
// A concatenation is a series of consecutive indices, with at most one jump
// in the middle from the last lane to the first.
for (int i = 1; i < kSimd128Size; ++i) {
if ((shuffle[i]) != ((shuffle[i - 1] + 1))) {
if (shuffle[i - 1] != 15) return false;
if (shuffle[i] % kSimd128Size != 0) return false;
}
}
*offset = start;
return true;
}
// static
bool InstructionSelector::TryMatchBlend(const uint8_t* shuffle) {
for (int i = 0; i < 16; ++i) {
if ((shuffle[i] & 0xF) != i) return false;
}
return true;
}
// static
int32_t InstructionSelector::Pack4Lanes(const uint8_t* shuffle) {
int32_t result = 0;
for (int i = 3; i >= 0; --i) {
result <<= 8;
result |= shuffle[i];
}
return result;
}
bool InstructionSelector::NeedsPoisoning(IsSafetyCheck safety_check) const {
switch (poisoning_level_) {
case PoisoningMitigationLevel::kDontPoison:
return false;
case PoisoningMitigationLevel::kPoisonAll:
return safety_check != IsSafetyCheck::kNoSafetyCheck;
case PoisoningMitigationLevel::kPoisonCriticalOnly:
return safety_check == IsSafetyCheck::kCriticalSafetyCheck;
}
UNREACHABLE();
}
} // namespace compiler
} // namespace internal
} // namespace v8
|
SECTION code_fp_math48
PUBLIC cm48_sccz80p_dleq
EXTERN am48_dle_s
; sccz80 float primitive
; left_op <= right_op ?
;
; enter : AC'(BCDEHL') = right_op
; stack = left_op, ret
;
; exit : if true
;
; HL = 1
; carry set
;
; if false
;
; HL = 0
; carry reset
;
; uses : AF, BC, DE, HL
defc cm48_sccz80p_dleq = am48_dle_s
|
;
; Z88dk Generic Floating Point Math Library
;
;
; $Id: dsub.asm,v 1.1 2008/07/27 21:44:57 aralbrec Exp $:
XLIB dsub
LIB minusfa
LIB fadd
.dsub
call minusfa
pop hl ;return address
pop de
pop ix
pop bc
push hl
jp fadd
|
printf:
pusha
mov ah, 0x0e ; Teletype output function
str_loop:
mov al, [si] ; Load a character byte to al
cmp al, 0
jne print_char ; if al != 0, jmp to print_char
popa
ret
print_char:
int 0x10 ; 0x10 interrupt
inc si ; add 1 to si
jmp str_loop
|
; A014640: Even heptagonal numbers (A000566).
; 0,18,34,112,148,286,342,540,616,874,970,1288,1404,1782,1918,2356,2512,3010,3186,3744,3940,4558,4774,5452,5688,6426,6682,7480,7756,8614,8910,9828,10144,11122,11458,12496,12852,13950,14326,15484,15880,17098,17514,18792,19228,20566,21022,22420,22896,24354,24850,26368,26884,28462,28998,30636,31192,32890,33466,35224,35820,37638,38254,40132,40768,42706,43362,45360,46036,48094,48790,50908,51624,53802,54538,56776,57532,59830,60606,62964,63760,66178,66994,69472,70308,72846,73702,76300,77176,79834,80730,83448,84364,87142,88078,90916,91872,94770,95746,98704,99700,102718,103734,106812,107848,110986,112042,115240,116316,119574,120670,123988,125104,128482,129618,133056,134212,137710,138886,142444,143640,147258,148474,152152,153388,157126,158382,162180,163456,167314,168610,172528,173844,177822,179158,183196,184552,188650,190026,194184,195580,199798,201214,205492,206928,211266,212722,217120,218596,223054,224550,229068,230584,235162,236698,241336,242892,247590,249166,253924,255520,260338,261954,266832,268468,273406,275062,280060,281736,286794,288490,293608,295324,300502,302238,307476,309232,314530,316306,321664,323460,328878,330694,336172,338008,343546,345402,351000,352876,358534,360430,366148,368064,373842,375778,381616,383572,389470,391446,397404,399400,405418,407434,413512,415548,421686,423742,429940,432016,438274,440370,446688,448804,455182,457318,463756,465912,472410,474586,481144,483340,489958,492174,498852,501088,507826,510082,516880,519156,526014,528310,535228,537544,544522,546858,553896,556252,563350,565726,572884,575280,582498,584914,592192,594628,601966,604422,611820,614296,621754
mov $1,$0
mov $2,$0
lpb $2,1
lpb $1,1
add $0,2
trn $1,2
lpe
add $3,1
lpb $0,1
sub $0,1
add $5,$3
add $3,5
lpe
add $1,$5
mov $2,$4
lpe
|
; A029759: Number of permutations which are the union of an increasing and a decreasing subsequence.
; Submitted by Christian Krause
; 1,1,2,6,22,86,340,1340,5254,20518,79932,311028,1209916,4707964,18330728,71429176,278586182,1087537414,4249391468,16618640836,65048019092,254814326164,998953992728,3919041821896,15385395144092,60438585676636,237563884988120,934311596780040,3676495517376184,14474185732012088,57011153530262480,224656915621201776,885652912419210822,3492861836026915782,13780479845245611084,54388113081432337380,214729932989712917668,848052809484541707556,3350334574655466140216,13239822072430180232232
mov $1,2
mov $2,2
mov $3,$0
lpb $3
mul $1,$3
sub $1,$2
cmp $4,0
add $5,$4
div $1,$5
div $4,$2
add $2,$1
mul $1,2
mul $2,2
sub $3,1
lpe
add $2,$1
mov $0,$2
div $0,4
|
; A059031: Fifth main diagonal of A059026: a(n) = B(n+4,n) = lcm(n+4,n)/(n+4) + lcm(n+4,n)/n - 1 for all n >= 1.
; 5,3,9,2,13,7,17,4,21,11,25,6,29,15,33,8,37,19,41,10,45,23,49,12,53,27,57,14,61,31,65,16,69,35,73,18,77,39,81,20,85,43,89,22,93,47,97,24,101,51,105,26,109,55,113,28,117,59,121,30,125,63,129,32,133,67
add $0,3
mov $2,2
add $2,$0
mul $0,2
gcd $2,4
div $0,$2
sub $0,1
|
; A001107: 10-gonal (or decagonal) numbers: a(n) = n*(4*n-3).
; 0,1,10,27,52,85,126,175,232,297,370,451,540,637,742,855,976,1105,1242,1387,1540,1701,1870,2047,2232,2425,2626,2835,3052,3277,3510,3751,4000,4257,4522,4795,5076,5365,5662,5967,6280,6601,6930,7267,7612,7965,8326,8695,9072,9457,9850,10251,10660,11077,11502,11935,12376,12825,13282,13747,14220,14701,15190,15687,16192,16705,17226,17755,18292,18837,19390,19951,20520,21097,21682,22275,22876,23485,24102,24727,25360,26001,26650,27307,27972,28645,29326,30015,30712,31417,32130,32851,33580,34317,35062,35815,36576,37345,38122,38907
mov $1,4
mul $1,$0
sub $1,3
mul $1,$0
mov $0,$1
|
; A087330: Sum of all digits of all integers less than or equal to 555...55 (with n 5's) in base 10.
; Submitted by Christian Krause
; 0,15,370,6150,86430,1114210,13641990,161419770,1864197550,21141975330,236419753110,2614197530890,28641975308670,311419753086450,3364197530864230,36141975308642010,386419753086419790
mov $2,$0
lpb $0
sub $0,1
add $1,1
mul $2,10
sub $2,$1
add $1,2
sub $2,$1
add $1,1
lpe
mov $0,$2
div $0,2
mul $0,5
|
; A081271: Vertical of triangular spiral in A051682.
; 1,13,34,64,103,151,208,274,349,433,526,628,739,859,988,1126,1273,1429,1594,1768,1951,2143,2344,2554,2773,3001,3238,3484,3739,4003,4276,4558,4849,5149,5458,5776,6103,6439,6784,7138,7501,7873,8254,8644,9043,9451
mul $0,3
add $0,3
bin $0,2
sub $0,2
mov $1,$0
|
#include "Contour.h"
#include "arithmetics.hpp"
namespace msdfgen {
static double shoelace(const Point2 &a, const Point2 &b) {
return (b.x-a.x)*(a.y+b.y);
}
void Contour::addEdge(const EdgeHolder &edge) {
edges.push_back(edge);
}
#ifdef MSDFGEN_USE_CPP11
void Contour::addEdge(EdgeHolder &&edge) {
edges.push_back((EdgeHolder &&) edge);
}
#endif
EdgeHolder & Contour::addEdge() {
edges.resize(edges.size()+1);
return edges.back();
}
static void boundPoint(double &l, double &b, double &r, double &t, Point2 p) {
if (p.x < l) l = p.x;
if (p.y < b) b = p.y;
if (p.x > r) r = p.x;
if (p.y > t) t = p.y;
}
void Contour::bound(double &l, double &b, double &r, double &t) const {
for (std::vector<EdgeHolder>::const_iterator edge = edges.begin(); edge != edges.end(); ++edge)
(*edge)->bound(l, b, r, t);
}
void Contour::boundMiters(double &l, double &b, double &r, double &t, double border, double miterLimit, int polarity) const {
if (edges.empty())
return;
Vector2 prevDir = edges.back()->direction(1).normalize(true);
for (std::vector<EdgeHolder>::const_iterator edge = edges.begin(); edge != edges.end(); ++edge) {
Vector2 dir = -(*edge)->direction(0).normalize(true);
if (polarity*crossProduct(prevDir, dir) >= 0) {
double miterLength = miterLimit;
double q = .5*(1-dotProduct(prevDir, dir));
if (q > 0)
miterLength = min(1/sqrt(q), miterLimit);
Point2 miter = (*edge)->point(0)+border*miterLength*(prevDir+dir).normalize(true);
boundPoint(l, b, r, t, miter);
}
prevDir = (*edge)->direction(1).normalize(true);
}
}
int Contour::winding() const {
if (edges.empty())
return 0;
double total = 0;
if (edges.size() == 1) {
Point2 a = edges[0]->point(0), b = edges[0]->point(1/3.), c = edges[0]->point(2/3.);
total += shoelace(a, b);
total += shoelace(b, c);
total += shoelace(c, a);
} else if (edges.size() == 2) {
Point2 a = edges[0]->point(0), b = edges[0]->point(.5), c = edges[1]->point(0), d = edges[1]->point(.5);
total += shoelace(a, b);
total += shoelace(b, c);
total += shoelace(c, d);
total += shoelace(d, a);
} else {
Point2 prev = edges.back()->point(0);
for (std::vector<EdgeHolder>::const_iterator edge = edges.begin(); edge != edges.end(); ++edge) {
Point2 cur = (*edge)->point(0);
total += shoelace(prev, cur);
prev = cur;
}
}
return sign(total);
}
void Contour::reverse() {
for (int i = (int) edges.size()/2; i >= 0; --i)
EdgeHolder::swap(edges[i], edges[edges.size()-1-i]);
for (std::vector<EdgeHolder>::iterator edge = edges.begin(); edge != edges.end(); ++edge)
(*edge)->reverse();
}
}
|
; A049211: a(n) = Product_{k=1..n} (9*k - 1); 9-factorial numbers.
; 1,8,136,3536,123760,5445440,288608320,17893715840,1270453824640,101636305971200,9045631231436800,886471860680806400,94852489092846284800,11002888734770169036800,1375361091846271129600000,184298386307400331366400000,26354669241958247385395200000
mov $1,1
mov $2,-1
lpb $0
sub $0,1
add $2,9
mul $1,$2
lpe
mov $0,$1
|
list p=16F877
include <p16f877.inc>
__CONFIG _BODEN_OFF&_CP_OFF&_WRT_ENABLE_ON&_PWRTE_ON&_WDT_OFF&_XT_OSC&_DEBUG_OFF&_CPD_OFF&_LVP_OFF
Loop1 EQU 20h ;
Loop2 EQU 21h ;
Loop3 EQU 22h ;
TEMPH EQU 23H ;
TEMPL EQU 24H ;
temp equ 25H ;
H_byte equ 26H ;
L_byte equ 27H ;
R0 equ 2AH ;
R1 equ 28H ;
R2 equ 29H ;
Byte EQU 2AH ;
Count EQU 2BH ;
Count1 EQU 2CH ;
Count2 EQU 2DH ;
TEMW EQU 2EH ;
TEMSTAT EQU 2FH ;
T_TH_BYTE equ 30H ;
T_H_BYTE equ 31H ;
T_T_BYTE equ 32H ;
T_U_BYTE equ 33H ;
R_TH_BYTE equ 34H ;
R_H_BYTE equ 35H ;
R_T_BYTE equ 36H ;
R_U_BYTE equ 37H ;
T_COUNT equ 38h ;
R_COUNT equ 39h ;
R_TEMP equ 3Ah ;
;Defines for I/O ports that provide LCD data & control
LCD_DATA equ PORTB
LCD_CNTL equ PORTB
; Defines for I/O pins that provide LCD control
RS equ 5
E equ 4
; LCD Module commands
DISP_ON EQU 0x00C ; Display on
DISP_ON_C EQU 0x00E ; Display on, Cursor on
DISP_ON_B EQU 0x00F ; Display on, Cursor on, Blink cursor
DISP_OFF EQU 0x008 ; Display off
CLR_DISP EQU 0x001 ; Clear the Display
ENTRY_INC EQU 0x006 ;
ENTRY_INC_S EQU 0x007 ;
ENTRY_DEC EQU 0x004 ;
ENTRY_DEC_S EQU 0x005 ;
DD_RAM_ADDR EQU 0x080 ; Least Significant 7-bit are for address
DD_RAM_UL EQU 0x080 ; Upper Left coner of the Display
ORG 0000H ; resets vector address
GOTO INIT
ORG 0004H ;
INTER MOVWF TEMW ;Copy W to TEMP register
SWAPF STATUS,0 ;Swap status to be saved into W
CLRF STATUS ;bank 0, regardless of current bank, Clears IRP,RP1,RP0
MOVWF TEMSTAT ;Save status to bank zero STATUS_TEMP register
BTFSC PIR1,4 ;
CALL TRANSMIT ;
BTFSC PIR1,5 ;
CALL RECEIVE ;
BTFSS PIR1,6 ;
GOTO $+3 ;
BSF ADCON0,2 ;
BCF PIR1,6 ;
CLRF STATUS ;bank 0, regardless of current bank, Clears IRP,RP1,RP0
SWAPF TEMSTAT,0 ;Swap STATUS_TEMP register into W
;(sets bank to original state)
MOVWF STATUS ;Move W into STATUS register
SWAPF TEMW,1 ;Swap W_TEMP
SWAPF TEMW,0 ;Swap W_TEMP into W
RETFIE ;return from interrupt(restores pc to original state)
TRANSMIT
BTFSC T_COUNT,0 ;
CALL TR_ST ;
BTFSC T_COUNT,1 ;
CALL TR_TH ;
BTFSC T_COUNT,2 ;
CALL TR_HU ;
BTFSC T_COUNT,3 ;
CALL TR_TE ;
BTFSC T_COUNT,4 ;
CALL TR_UN ;
RLF T_COUNT,1 ;
BTFSS T_COUNT,5 ;
GOTO $+2 ;
CLRF T_COUNT ;
MOVF T_COUNT,0 ;
BTFSC STATUS,2 ;
BSF T_COUNT,0 ;
RETURN
TR_ST
MOVLW 'S' ;
MOVWF TXREG ;
RETURN ;
TR_TH
MOVF T_TH_BYTE,0 ;
MOVWF TXREG ;
RETURN ;
TR_HU
MOVF T_H_BYTE,0 ;
MOVWF TXREG ;
RETURN ;
TR_TE
MOVF T_T_BYTE,0 ;
MOVWF TXREG ;
RETURN ;
TR_UN
MOVF T_U_BYTE,0 ;
MOVWF TXREG ;
RETURN ;
RECEIVE
MOVF RCREG,0 ;
MOVWF R_TEMP ;
MOVLW 'S' ;
SUBWF R_TEMP,0 ;
BTFSS STATUS,2 ;
GOTO $+3 ;
CLRF R_COUNT ;
BSF R_COUNT,0 ;
BTFSC R_COUNT,1 ;
CALL R_TH ;
BTFSC R_COUNT,2 ;
CALL R_HU ;
BTFSC R_COUNT,3 ;
CALL R_TE ;
BTFSC R_COUNT,4 ;
CALL R_UN ;
MOVLW D'1' ;
ADDLW D'1' ;
RLF R_COUNT,1 ;
BTFSS R_COUNT,5 ;
GOTO $+3 ;
CLRF R_COUNT ;
BSF R_COUNT,0 ;
RETURN
R_TH
MOVF R_TEMP,0 ;
MOVWF R_TH_BYTE ;
RETURN ;
R_HU
MOVF R_TEMP,0 ;
MOVWF R_H_BYTE ;
RETURN ;
R_TE
MOVF R_TEMP,0 ;
MOVWF R_T_BYTE ;
RETURN ;
R_UN
MOVF R_TEMP,0 ;
MOVWF R_U_BYTE ;
RETURN ;
INIT
BSF STATUS,RP0 ; Switch to Rambank 1
MOVLW B'10100100' ; Adcon result right justified, pin RA4 Digital, pin RA0 Analogue,1
MOVWF ADCON1 ; Vref+ = Vdd, Vref- = Vss.
BSF TRISC,6 ; Enable transmit pin
BSF TRISC,7 ; Enable Receive pin
BSF STATUS,RP0 ; Go to Bank1
MOVLW 19h ; Set Baud rate 9600
MOVWF SPBRG
MOVLW b'00100000' ; 9-bit transmit, transmitter enabled,b'00100100'
MOVWF TXSTA ; asynchronous mode, high speed mode
BSF PIE1,TXIE ; Enable transmit interrupts
BSF PIE1,RCIE ; Enable receive interrupts
BCF STATUS,RP0 ; Go to Bank 0
MOVLW b'10010000' ; 9-bit receive, receiver enabled,b'10100000'
MOVWF RCSTA ; serial port enabled
MOVLW B'01000001' ; Fosc/32, RA0 input, enable A/D module
MOVWF ADCON0 ;
BSF PIE1,6 ;
MOVLW B'11000000' ;
MOVWF INTCON ;
CLRF T_COUNT ;
CLRF R_COUNT ;
CLRF T_TH_BYTE ;
CLRF T_H_BYTE ;
CLRF T_T_BYTE ;
CLRF T_U_BYTE ;
CLRF R_TH_BYTE ;
CLRF R_H_BYTE ;
CLRF R_T_BYTE ;
CLRF R_U_BYTE ;
call InitLCD ; Initialize LCD display
BSF ADCON0,2 ;
ADREAD
CALL DELAY ;
FDEL BSF STATUS,5 ; Select Bank1
MOVF ADRESL,0 ; Copy a/d info into 4 seperate registers(2 copies of ADRESH
; and 2 copies of ADRESL
BCF STATUS,5 ; //
MOVWF L_byte ; //
MOVWF TEMPL ; //
MOVF ADRESH,0 ; //
MOVWF H_byte ; //
MOVWF TEMPH ; //
CALL MULT ; multiplies a/d result by 5 to make it the same as input voltage
CALL UPDATEDISP ; Update LCD Displays
GOTO ADREAD ; repeat a/d conversion and test if switch one is still pressed
;**************************************************************************************
;**************************************************************************************
UPDATEDISP
call clrLCD ; clear display
CALL CONVERT ; Convert AD value to Thousands , Hundreds,Tens,Units,
call L1homeLCD ; cursor on line 1
movlw 'T' ; Display character
call putcLCD ; //
movlw 'R' ; Display character
call putcLCD ; //
movlw 'A' ; Display character
call putcLCD ; //
movlw 'N' ; Display character
call putcLCD ; //
movlw 'S' ; Display character
call putcLCD ; //
movlw ' ' ; Display character
call putcLCD ; //
movlw '=' ; Display character
call putcLCD ; //
movlw ' ' ; Display character
call putcLCD ; //
swapf R1,0 ; Read character , mask it and display it on LCD
andlw b'00001111' ; //
addlw d'48' ; //
movwf T_TH_BYTE ;
call putcLCD ; //
movf R1,0 ; Read character , mask it and display it on LCD
andlw b'00001111' ; //
addlw d'48' ; //
movwf T_H_BYTE ;
call putcLCD ; //
swapf R2,0 ; Read character , mask it and display it on LCD
andlw b'00001111' ; //
addlw d'48' ; //
movwf T_T_BYTE ;
call putcLCD ; //
movf R2,0 ; Read character , mask it and display it on LCD
andlw b'00001111' ; //
addlw d'48' ; //
movwf T_U_BYTE ;
call putcLCD ; //
movlw ' ' ; Display character
call putcLCD ; //
movlw 'm' ; Display character
call putcLCD ; //
movlw 'V' ; Display character
call putcLCD ; //
call L2homeLCD ; move to start of second line on display
movlw 'R' ; Display character
call putcLCD ; //
movlw 'E' ; Display character
call putcLCD ; //
movlw 'C' ; Display character
call putcLCD ; //
movlw 'E' ; Display character
call putcLCD ; //
movlw 'V' ; Display character
call putcLCD ; //
movlw ' ' ; Display character
call putcLCD ; //
movlw '=' ; Display character
call putcLCD ; //
movlw ' ' ; Display character
call putcLCD ; //
MOVF R_TH_BYTE,0 ;
call putcLCD ; //
MOVF R_H_BYTE,0 ;
call putcLCD ; //
MOVF R_T_BYTE,0 ;
call putcLCD ; //
MOVF R_U_BYTE,0 ;
call putcLCD ; //
movlw ' ' ; Display character
call putcLCD ; //
movlw 'm' ; Display character
call putcLCD ; //
movlw 'V' ; Display character
call putcLCD ; //
RETURN ;
;**************************************************************************************
CONVERT
; Source code for this conversion courtesy of Microchip
;********************************************************************
; Binary To BCD Conversion Routine
; This routine converts a 16 Bit binary Number to a 5 Digit
; BCD Number. This routine is useful since PIC16C55 & PIC16C57
; have two 8 bit ports and one 4 bit port ( total of 5 BCD digits)
;
; The 16 bit binary number is input in locations H_byte and
; L_byte with the high byte in H_byte.
; The 5 digit BCD number is returned in R0, R1 and R2 with R0
; containing the MSD in its right most nibble.
;
; Performance :
; Program Memory : 35
; Clock Cycles : 885
;
;
; Revision Date:
; 1-13-97 Compatibility with MPASMWIN 1.40
;
;*******************************************************************;
bcf STATUS,0 ; clear the carry bit
movlw D'16'
movwf Count
clrf R0
clrf R1
clrf R2
loop16 rlf L_byte, F
rlf H_byte, F
rlf R2, F
rlf R1, F
rlf R0, F
;
decfsz Count, F
goto adjDEC
RETLW 0
;
adjDEC movlw R2
movwf FSR
call adjBCD
;
movlw R1
movwf FSR
call adjBCD
;
movlw R0
movwf FSR
call adjBCD
;
goto loop16
;
adjBCD movlw 3
addwf 0,W
movwf temp
btfsc temp,3 ; test if result > 7
movwf 0
movlw 30
addwf 0,W
movwf temp
btfsc temp,7 ; test if result > 7
movwf 0 ; save as MSD
RETLW 0
;**************************************************************************************
;**************************************************************************************
MULT
rlf L_byte,1 ;
rlf H_byte,1 ;
rlf L_byte,1 ;
rlf H_byte,1 ;
movf TEMPL,0 ;
addwf L_byte,1 ;
btfsc STATUS,0 ;
incf H_byte,1 ;
movf TEMPH,0 ;
addwf H_byte,1 ;
return ;
;**************************************************************************************
;*******************************************************************
;* The LCD Module Subroutines *
;* Command sequence for 2 lines of 5x16 characters *
;*******************************************************************
;
; Subroutines Courtesy of Pat Ellis ( Senior Lecturer)
InitLCD
bcf STATUS,RP0 ; Bank 0
bcf STATUS,RP1
clrf LCD_DATA ; Clear LCD data & control bits
bsf STATUS,RP0 ; Bank 1
movlw 0xc0 ; Initialize inputs/outputs for LCD
movwf LCD_DATA
btfsc PCON,NOT_POR ; Check to see if POR reset or other
goto InitLCDEnd
bcf STATUS,RP0 ; If POR reset occured, full init LCD
call LongDelay
movlw 0x02 ; Init for 4-bit interface
movwf LCD_DATA
bsf LCD_CNTL, E
bcf LCD_CNTL, E
call LongDelay
movlw b'00101000'
call SendCmd
movlw DISP_ON ; Turn display on
call SendCmd
movlw ENTRY_INC ; Configure cursor movement
call SendCmd
movlw DD_RAM_ADDR ; Set writes for display memory
call SendCmd
InitLCDEnd ; Always clear the LCD and set
bcf STATUS,RP0 ; the POR bit when exiting
call clrLCD
bsf STATUS,RP0
bsf PCON,NOT_POR
bcf STATUS,RP0
return
;*******************************************************************
;*SendChar - Sends character to LCD *
;*This routine splits the character into the upper and lower *
;*nibbles and sends them to the LCD, upper nibble first. *
;*******************************************************************
putcLCD
movwf Byte ; Save WREG in Byte variable
call Delay
swapf Byte,W ; Write upper nibble first
andlw 0x0f
movwf LCD_DATA
bsf LCD_CNTL, RS ; Set for data
bsf LCD_CNTL, E ; Clock nibble into LCD
bcf LCD_CNTL, E
movf Byte,W ; Write lower nibble last
andlw 0x0f
movwf LCD_DATA
bsf LCD_CNTL, RS ; Set for data
bsf LCD_CNTL, E ; Clock nibble into LCD
bcf LCD_CNTL, E
return
;*******************************************************************
;* SendCmd - Sends command to LCD *
;* This routine splits the command into the upper and lower *
;* nibbles and sends them to the LCD, upper nibble first. *
;*******************************************************************
SendCmd
movwf Byte ; Save WREG in Byte variable
call Delay
swapf Byte,W ; Send upper nibble first
andlw 0x0f
movwf LCD_DATA
bcf LCD_CNTL,RS ; Clear for command
bsf LCD_CNTL,E ; Clock nibble into LCD
bcf LCD_CNTL,E
movf Byte,W ; Write lower nibble last
andlw 0x0f
movwf LCD_DATA
bcf LCD_CNTL,RS ; Clear for command
bsf LCD_CNTL,E ; Clock nibble into LCD
bcf LCD_CNTL,E
return
;*******************************************************************
;* clrLCD - Clear the contents of the LCD *
;*******************************************************************
clrLCD
movlw CLR_DISP ; Send the command to clear display
call SendCmd
return
;*******************************************************************
;* L1homeLCD - Moves the cursor to home position on Line 1 *
;*******************************************************************
L1homeLCD
movlw DD_RAM_ADDR|0x00 ; Send command to move cursor to
call SendCmd ; home position on line 1
return
;*******************************************************************
;* L2homeLCD - Moves the cursor to home position on Line 2 *
;*******************************************************************
L2homeLCD
movlw DD_RAM_ADDR|0x28 ; Send command to move cursor to
call SendCmd ; home position on line 2
return
;*******************************************************************
;* Delay - Generic LCD delay *
;* Since the microcontroller can not read the busy flag of the *
;* LCD, a specific delay needs to be executed between writes to *
;* the LCD. *
;*******************************************************************
Delay ; 2 cycles for call
; return ; **********************************************remove
clrf Count ; 1 cycle to clear counter variable
Dloop
decfsz Count,f ; These two instructions provide a
goto Dloop ; (256 * 3) -1 cycle count
return ; 2 cycles for return
;*******************************************************************
;* LongDelay - Generic long LCD delay *
;* POR delay for the LCD panel. *
;*******************************************************************
LongDelay
; return ; ***************remove for prog
clrf Count
clrf Count1
movlw 0x03
movwf Count2
LDloop
decfsz Count,f
goto LDloop
decfsz Count1,f
goto LDloop
decfsz Count2,f
goto LDloop
return
;**************************************************************************************
DELAY
; Subroutine delays the processor for +- 0.5 seconds , to allow displays and A/D converter
; to Stabilize
MOVLW 01h ;Set delay for 0.5 Second
MOVWF Loop3 ;Set Loop3 to Loop 3 Times
LOOP
DECFSZ Loop1,1 ;Loop 255 times then move to next loop
Goto LOOP ;Go Back to the beginning of the Loop
DECFSZ Loop2,1 ;Loop 255 times then move to next loop
Goto LOOP ;Go Back to the beginning of the Loop
DECFSZ Loop3,1 ;Loop 5 times then move to next loop
Goto LOOP ;Go Back to the beginning of the Loop
RETURN ;Go back and execute instruction after last call
;**************************************************************************************
;**************************************************************************************
END ;End of Source code
|
//stack
//Runtime: 1072 ms, faster than 5.51% of C++ online submissions for Asteroid Collision.
//Memory Usage: 21 MB, less than 95.21% of C++ online submissions for Asteroid Collision.
class Solution {
public:
vector<int> asteroidCollision(vector<int>& asteroids) {
stack<int> stk;
bool changed = false;
do{
changed = false;
for(int& cur : asteroids){
if(!stk.empty() && stk.top() > 0 && cur < 0){
int prev = stk.top();
if(abs(prev) > abs(cur)){
//do nothing
}else if(abs(prev) == abs(cur)){
stk.pop();
}else{
//abs(prev) < abs(cur)
stk.pop();
stk.push(cur);
}
}else{
stk.push(cur);
}
}
if(stk.size() < asteroids.size()){
changed = true;
}
asteroids.clear();
while(!stk.empty()){
asteroids.insert(asteroids.begin(), stk.top());
stk.pop();
}
}while(changed);
return asteroids;
}
};
//official sol
//stack, keep going left until exploded
//Runtime: 20 ms, faster than 95.41% of C++ online submissions for Asteroid Collision.
//Memory Usage: 18.3 MB, less than 95.21% of C++ online submissions for Asteroid Collision.
//time: O(N), space: O(N)
class Solution {
public:
vector<int> asteroidCollision(vector<int>& asteroids) {
stack<int> stk;
for(int& cur : asteroids){
bool exploded = false;
while(!stk.empty() && stk.top() > 0 && cur < 0){
int prev = stk.top();
if(abs(prev) > abs(cur)){
//do nothing
exploded = true;
break;
}else if(abs(prev) == abs(cur)){
stk.pop();
exploded = true;
break;
}else{
//abs(prev) < abs(cur)
stk.pop();
//cur keeps going left
}
}
if(!exploded){
stk.push(cur);
}
}
asteroids.clear();
while(!stk.empty()){
asteroids.insert(asteroids.begin(), stk.top());
stk.pop();
}
return asteroids;
}
};
//two pointer
//https://leetcode.com/problems/asteroid-collision/solution/131673
//Runtime: 24 ms, faster than 81.17% of C++ online submissions for Asteroid Collision.
//Memory Usage: 17.9 MB, less than 95.21% of C++ online submissions for Asteroid Collision.
class Solution {
public:
vector<int> asteroidCollision(vector<int>& A) {
int n = A.size();
//slow: last filled asteroid's position
int slow = -1, fast = 0;
for(fast = 0; fast < n; ++fast){
bool exploded = false;
while(slow >= 0 && A[slow] > 0 && A[fast] < 0){
if(abs(A[slow]) > abs(A[fast])){
exploded = true;
break;
}else if(abs(A[slow]) == abs(A[fast])){
--slow;
exploded = true;
break;
}else{
--slow;
}
}
if(!exploded){
A[++slow] = A[fast];
}
}
return vector<int>(A.begin(), A.begin()+slow+1);
}
};
|
; A070725: n^7 mod 45.
; 0,1,38,27,4,5,36,43,17,9,10,11,18,22,14,0,16,8,27,19,20,36,13,32,9,25,26,18,37,29,0,31,23,27,34,35,36,28,2,9,40,41,18,7,44,0,1,38,27,4,5,36,43,17,9,10,11,18,22,14,0,16,8,27,19,20,36,13,32,9,25,26,18,37,29,0,31
pow $0,7
mod $0,45
mov $1,$0
|
; A057815: a(n) = gcd(n,binomial(n,floor(n/2))).
; Submitted by Christian Krause
; 1,2,3,2,5,2,7,2,9,2,11,12,13,2,15,2,17,2,19,4,21,2,23,4,25,2,27,4,29,30,31,2,33,2,35,12,37,2,39,20,41,6,43,4,45,2,47,12,49,2,51,4,53,2,55,56,57,2,59,4,61,2,63,2,65,6,67,4,69,14,71,4,73,2,75,4,77,2,79,20,81,2,83,84,85,2,87,8,89,90,91,4,93,2,95,12,97,2,99,4
add $0,1
mov $1,$0
mov $2,$0
div $2,2
bin $1,$2
gcd $1,$0
mov $0,$1
|
.global s_prepare_buffers
s_prepare_buffers:
push %r11
push %r12
push %r14
push %r8
push %rax
push %rdi
push %rsi
lea addresses_normal_ht+0xc5ea, %rax
nop
nop
nop
cmp $48828, %r11
movups (%rax), %xmm6
vpextrq $0, %xmm6, %rsi
nop
nop
nop
nop
nop
xor %rdi, %rdi
lea addresses_UC_ht+0x491e, %rdi
xor %r12, %r12
mov $0x6162636465666768, %r8
movq %r8, (%rdi)
nop
xor %r12, %r12
lea addresses_D_ht+0x1fa, %r11
nop
nop
nop
sub $23389, %r14
movb (%r11), %r12b
nop
nop
nop
nop
nop
xor $36992, %r11
pop %rsi
pop %rdi
pop %rax
pop %r8
pop %r14
pop %r12
pop %r11
ret
.global s_faulty_load
s_faulty_load:
push %r12
push %r13
push %r14
push %r9
push %rbx
push %rcx
push %rdx
// Store
lea addresses_WC+0x73e, %rdx
nop
nop
nop
nop
nop
and $4714, %rcx
mov $0x5152535455565758, %r9
movq %r9, %xmm1
and $0xffffffffffffffc0, %rdx
movaps %xmm1, (%rdx)
nop
nop
inc %r14
// Faulty Load
lea addresses_A+0x657e, %r13
nop
xor $16849, %rbx
mov (%r13), %r9w
lea oracles, %rdx
and $0xff, %r9
shlq $12, %r9
mov (%rdx,%r9,1), %r9
pop %rdx
pop %rcx
pop %rbx
pop %r9
pop %r14
pop %r13
pop %r12
ret
/*
<gen_faulty_load>
[REF]
{'src': {'type': 'addresses_A', 'same': False, 'size': 4, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
{'dst': {'type': 'addresses_WC', 'same': True, 'size': 16, 'congruent': 6, 'NT': False, 'AVXalign': True}, 'OP': 'STOR'}
[Faulty Load]
{'src': {'type': 'addresses_A', 'same': True, 'size': 2, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'src': {'type': 'addresses_normal_ht', 'same': False, 'size': 16, 'congruent': 2, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
{'dst': {'type': 'addresses_UC_ht', 'same': False, 'size': 8, 'congruent': 4, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
{'src': {'type': 'addresses_D_ht', 'same': False, 'size': 1, 'congruent': 2, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
{'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
*/
|
;;##########################################################################
;;
;;Title: Table 2 For IQmath Functions
;;
;;Version: 1.0
;;
;;Contents: IQexp Function Table, Size Of Table = 140x16
;;
;;##########################################################################
;;==========================================================================
;; IQexp Function Table, Size Of Table = 140x16
;;==========================================================================
.def _IQexpTable
.def _IQexpTableMinMax
.def _IQexpTableMinMaxEnd
.def _IQexpTableCoeff
.def _IQexpTableCoeffEnd
.sect "IQmathTablesRam"
_IQexpTable:
_IQexpTableMinMax:
.long 42 ; Q 1 Max Input Value = 20.794415416333
.long -1 ; Q 1 Min Input Value = -0.693147180560
.long 80 ; Q 2 Max Input Value = 20.101268235773
.long -6 ; Q 2 Min Input Value = -1.386294361120
.long 155 ; Q 3 Max Input Value = 19.408121055213
.long -17 ; Q 3 Min Input Value = -2.079441541680
.long 299 ; Q 4 Max Input Value = 18.714973874653
.long -44 ; Q 4 Min Input Value = -2.772588722240
.long 577 ; Q 5 Max Input Value = 18.021826694093
.long -111 ; Q 5 Min Input Value = -3.465735902800
.long 1109 ; Q 6 Max Input Value = 17.328679513533
.long -266 ; Q 6 Min Input Value = -4.158883083360
.long 2129 ; Q 7 Max Input Value = 16.635532332973
.long -621 ; Q 7 Min Input Value = -4.852030263920
.long 4081 ; Q 8 Max Input Value = 15.942385152413
.long -1420 ; Q 8 Min Input Value = -5.545177444480
.long 7808 ; Q 9 Max Input Value = 15.249237971853
.long -3194 ; Q 9 Min Input Value = -6.238324625040
.long 14905 ; Q10 Max Input Value = 14.556090791293
.long -7098 ; Q10 Min Input Value = -6.931471805599
.long 28391 ; Q11 Max Input Value = 13.862943610733
.long -15615 ; Q11 Min Input Value = -7.624618986159
.long 53943 ; Q12 Max Input Value = 13.169796430173
.long -34070 ; Q12 Min Input Value = -8.317766166719
.long 102209 ; Q13 Max Input Value = 12.476649249613
.long -73817 ; Q13 Min Input Value = -9.010913347279
.long 193061 ; Q14 Max Input Value = 11.783502069053
.long -158991 ; Q14 Min Input Value = -9.704060527839
.long 363409 ; Q15 Max Input Value = 11.090354888493
.long -340696 ; Q15 Min Input Value = -10.397207708399
.long 681391 ; Q16 Max Input Value = 10.397207707934
.long -726817 ; Q16 Min Input Value = -11.090354888959
.long 1271931 ; Q17 Max Input Value = 9.704060527374
.long -1544487 ; Q17 Min Input Value = -11.783502069519
.long 2362157 ; Q18 Max Input Value = 9.010913346814
.long -3270679 ; Q18 Min Input Value = -12.476649250079
.long 4360905 ; Q19 Max Input Value = 8.317766166254
.long -6904766 ; Q19 Min Input Value = -13.169796430639
.long 7994992 ; Q20 Max Input Value = 7.624618985694
.long -14536350 ; Q20 Min Input Value = -13.862943611199
.long 14536350 ; Q21 Max Input Value = 6.931471805134
.long -30526335 ; Q21 Min Input Value = -14.556090791759
.long 26165430 ; Q22 Max Input Value = 6.238324624574
.long -63959940 ; Q22 Min Input Value = -15.249237972319
.long 46516320 ; Q23 Max Input Value = 5.545177444014
.long -133734420 ; Q23 Min Input Value = -15.942385152879
.long 81403560 ; Q24 Max Input Value = 4.852030263454
.long -279097919 ; Q24 Min Input Value = -16.635532333439
.long 139548960 ; Q25 Max Input Value = 4.158883082894
.long -581453998 ; Q25 Min Input Value = -17.328679513999
.long 232581599 ; Q26 Max Input Value = 3.465735902334
.long -1209424317 ; Q26 Min Input Value = -18.021826694559
.long 372130559 ; Q27 Max Input Value = 2.772588721774
.long -2147483648 ; Q27 Min Input Value = -16.000000000000
.long 558195838 ; Q28 Max Input Value = 2.079441541214
.long -2147483648 ; Q28 Min Input Value = -8.000000000000
.long 744261118 ; Q29 Max Input Value = 1.386294360654
.long -2147483648 ; Q29 Min Input Value = -4.000000000000
.long 744261117 ; Q30 Max Input Value = 0.693147180094
.long -2147483648 ; Q30 Min Input Value = -2.000000000000
_IQexpTableMinMaxEnd:
_IQexpTableCoeff:
.long 0x0BA2E8BA ; 1/11 in Q31
.long 0x0CCCCCCD ; 1/10 in Q31
.long 0x0E38E38E ; 1/9 in Q31
.long 0x10000000 ; 1/8 in Q31
.long 0x12492492 ; 1/7 in Q31
.long 0x15555555 ; 1/6 in Q31
.long 0x1999999A ; 1/5 in Q31
.long 0x20000000 ; 1/4 in Q31
.long 0x2AAAAAAB ; 1/3 in Q31
.long 0x40000000 ; 1/2 in Q31
_IQexpTableCoeffEnd:
_IQexpTableEnd:
;;
;; End Of File.
;;
|
SECTION .text
USE16
args:
.kernel_base dq 0x100000
.kernel_size dq 0
.stack_base dq 0
.stack_size dq 0
.env_base dq 0
.env_size dq 0
startup:
; enable A20-Line via IO-Port 92, might not work on all motherboards
in al, 0x92
or al, 2
out 0x92, al
%ifdef KERNEL
mov edi, [args.kernel_base]
mov ecx, (kernel_file.end - kernel_file)
mov [args.kernel_size], ecx
mov eax, (kernel_file - boot)/512
add ecx, 511
shr ecx, 9
call load_extent
%else
call redoxfs
test eax, eax
jnz error
%endif
jmp .loaded_kernel
.loaded_kernel:
call memory_map
call vesa
mov si, init_fpu_msg
call print
call initialize.fpu
mov si, init_sse_msg
call print
call initialize.sse
mov si, startup_arch_msg
call print
jmp startup_arch
# load a disk extent into high memory
# eax - sector address
# ecx - sector count
# edi - destination
load_extent:
; loading kernel to 1MiB
; move part of kernel to startup_end via bootsector#load and then copy it up
; repeat until all of the kernel is loaded
buffer_size_sectors equ 127
.lp:
cmp ecx, buffer_size_sectors
jb .break
; saving counter
push eax
push ecx
push edi
; populating buffer
mov ecx, buffer_size_sectors
mov bx, startup_end
mov dx, 0x0
; load sectors
call load
; set up unreal mode
call unreal
pop edi
; move data
mov esi, startup_end
mov ecx, buffer_size_sectors * 512 / 4
cld
a32 rep movsd
pop ecx
pop eax
add eax, buffer_size_sectors
sub ecx, buffer_size_sectors
jmp .lp
.break:
; load the part of the kernel that does not fill the buffer completely
test ecx, ecx
jz .finish ; if cx = 0 => skip
push ecx
push edi
mov bx, startup_end
mov dx, 0x0
call load
; moving remnants of kernel
call unreal
pop edi
pop ecx
mov esi, startup_end
shl ecx, 7 ; * 512 / 4
cld
a32 rep movsd
.finish:
call print_line
ret
%include "config.asm"
%include "descriptor_flags.inc"
%include "gdt_entry.inc"
%include "unreal.asm"
%include "memory_map.asm"
%include "vesa.asm"
%include "initialize.asm"
%ifndef KERNEL
%include "redoxfs.asm"
%endif
init_fpu_msg: db "Init FPU",13,10,0
init_sse_msg: db "Init SSE",13,10,0
init_pit_msg: db "Init PIT",13,10,0
init_pic_msg: db "Init PIC",13,10,0
startup_arch_msg: db "Startup Arch",13,10,0
|
.global s_prepare_buffers
s_prepare_buffers:
push %r11
push %r14
push %r8
push %r9
push %rbp
push %rbx
push %rcx
push %rdi
push %rsi
lea addresses_WC_ht+0x1d909, %rbx
nop
nop
nop
nop
nop
sub $49941, %rbp
movw $0x6162, (%rbx)
nop
nop
nop
nop
nop
inc %rbp
lea addresses_WT_ht+0xc659, %r9
nop
nop
cmp %r11, %r11
vmovups (%r9), %ymm1
vextracti128 $0, %ymm1, %xmm1
vpextrq $1, %xmm1, %rcx
nop
sub $14348, %r9
lea addresses_WT_ht+0x1c529, %r8
nop
nop
nop
nop
nop
dec %r14
movl $0x61626364, (%r8)
nop
inc %r8
lea addresses_D_ht+0x135a9, %rsi
lea addresses_normal_ht+0x7529, %rdi
nop
nop
nop
sub $23839, %rbp
mov $40, %rcx
rep movsw
nop
nop
nop
xor $41148, %rbx
lea addresses_WC_ht+0xbc99, %rsi
lea addresses_A_ht+0x10b09, %rdi
clflush (%rsi)
nop
nop
and %rbp, %rbp
mov $31, %rcx
rep movsq
nop
nop
nop
sub $7191, %rcx
lea addresses_normal_ht+0x7d29, %rsi
lea addresses_UC_ht+0xd339, %rdi
nop
inc %rbp
mov $15, %rcx
rep movsl
nop
nop
nop
nop
add $7162, %rbx
lea addresses_UC_ht+0x15b29, %rsi
lea addresses_WT_ht+0x10ca9, %rdi
clflush (%rdi)
nop
nop
nop
cmp $22172, %r14
mov $5, %rcx
rep movsq
cmp %rcx, %rcx
lea addresses_A_ht+0xad29, %r11
cmp %rsi, %rsi
mov (%r11), %ebx
nop
nop
nop
nop
nop
add %r11, %r11
lea addresses_WT_ht+0xc829, %rsi
lea addresses_D_ht+0xcfb3, %rdi
nop
nop
nop
nop
nop
and %r14, %r14
mov $32, %rcx
rep movsq
nop
nop
nop
inc %rbp
lea addresses_A_ht+0x549, %rsi
lea addresses_UC_ht+0x1a7a9, %rdi
nop
nop
sub $56929, %rbx
mov $73, %rcx
rep movsb
nop
nop
mfence
pop %rsi
pop %rdi
pop %rcx
pop %rbx
pop %rbp
pop %r9
pop %r8
pop %r14
pop %r11
ret
.global s_faulty_load
s_faulty_load:
push %r11
push %r8
push %rax
push %rcx
push %rdx
push %rsi
// Store
lea addresses_D+0xf229, %rcx
clflush (%rcx)
nop
nop
nop
and %rdx, %rdx
mov $0x5152535455565758, %rsi
movq %rsi, %xmm2
movups %xmm2, (%rcx)
nop
nop
nop
nop
xor $1536, %rdx
// Faulty Load
lea addresses_US+0x18d29, %r8
nop
nop
add %rax, %rax
mov (%r8), %ecx
lea oracles, %rdx
and $0xff, %rcx
shlq $12, %rcx
mov (%rdx,%rcx,1), %rcx
pop %rsi
pop %rdx
pop %rcx
pop %rax
pop %r8
pop %r11
ret
/*
<gen_faulty_load>
[REF]
{'src': {'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 0, 'same': False, 'type': 'addresses_US'}, 'OP': 'LOAD'}
{'dst': {'NT': False, 'AVXalign': False, 'size': 16, 'congruent': 8, 'same': False, 'type': 'addresses_D'}, 'OP': 'STOR'}
[Faulty Load]
{'src': {'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 0, 'same': True, 'type': 'addresses_US'}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'dst': {'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 5, 'same': False, 'type': 'addresses_WC_ht'}, 'OP': 'STOR'}
{'src': {'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 4, 'same': False, 'type': 'addresses_WT_ht'}, 'OP': 'LOAD'}
{'dst': {'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 11, 'same': False, 'type': 'addresses_WT_ht'}, 'OP': 'STOR'}
{'src': {'congruent': 4, 'same': False, 'type': 'addresses_D_ht'}, 'dst': {'congruent': 7, 'same': False, 'type': 'addresses_normal_ht'}, 'OP': 'REPM'}
{'src': {'congruent': 3, 'same': False, 'type': 'addresses_WC_ht'}, 'dst': {'congruent': 4, 'same': False, 'type': 'addresses_A_ht'}, 'OP': 'REPM'}
{'src': {'congruent': 11, 'same': False, 'type': 'addresses_normal_ht'}, 'dst': {'congruent': 3, 'same': False, 'type': 'addresses_UC_ht'}, 'OP': 'REPM'}
{'src': {'congruent': 8, 'same': False, 'type': 'addresses_UC_ht'}, 'dst': {'congruent': 6, 'same': False, 'type': 'addresses_WT_ht'}, 'OP': 'REPM'}
{'src': {'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 11, 'same': False, 'type': 'addresses_A_ht'}, 'OP': 'LOAD'}
{'src': {'congruent': 6, 'same': False, 'type': 'addresses_WT_ht'}, 'dst': {'congruent': 1, 'same': False, 'type': 'addresses_D_ht'}, 'OP': 'REPM'}
{'src': {'congruent': 5, 'same': True, 'type': 'addresses_A_ht'}, 'dst': {'congruent': 7, 'same': False, 'type': 'addresses_UC_ht'}, 'OP': 'REPM'}
{'00': 18}
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
*/
|
//
// ip/basic_resolver_entry.hpp
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Copyright (c) 2003-2013 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
#ifndef ASIO_IP_BASIC_RESOLVER_ENTRY_HPP
#define ASIO_IP_BASIC_RESOLVER_ENTRY_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
#include "asio/detail/config.hpp"
#include <string>
#include "asio/detail/push_options.hpp"
namespace asio {
namespace ip {
/// An entry produced by a resolver.
/**
* The asio::ip::basic_resolver_entry class template describes an entry
* as returned by a resolver.
*
* @par Thread Safety
* @e Distinct @e objects: Safe.@n
* @e Shared @e objects: Unsafe.
*/
template <typename InternetProtocol>
class basic_resolver_entry
{
public:
/// The protocol type associated with the endpoint entry.
typedef InternetProtocol protocol_type;
/// The endpoint type associated with the endpoint entry.
typedef typename InternetProtocol::endpoint endpoint_type;
/// Default constructor.
basic_resolver_entry()
{
}
/// Construct with specified endpoint, host name and service name.
basic_resolver_entry(const endpoint_type& ep,
const std::string& host, const std::string& service)
: endpoint_(ep),
host_name_(host),
service_name_(service)
{
}
/// Get the endpoint associated with the entry.
endpoint_type endpoint() const
{
return endpoint_;
}
/// Convert to the endpoint associated with the entry.
operator endpoint_type() const
{
return endpoint_;
}
/// Get the host name associated with the entry.
std::string host_name() const
{
return host_name_;
}
/// Get the service name associated with the entry.
std::string service_name() const
{
return service_name_;
}
private:
endpoint_type endpoint_;
std::string host_name_;
std::string service_name_;
};
} // namespace ip
} // namespace asio
#include "asio/detail/pop_options.hpp"
#endif // ASIO_IP_BASIC_RESOLVER_ENTRY_HPP
|
; uint16_t _random_uniform_cmwc_8_(void *seed)
SECTION code_clib
SECTION code_stdlib
PUBLIC __random_uniform_cmwc_8_
EXTERN __random_uniform_cmwc_8__fastcall
__random_uniform_cmwc_8_:
pop af
pop hl
push hl
push af
jp __random_uniform_cmwc_8__fastcall
|
;------------------------------------------------------------------------------
;
; Copyright (c) 2006, Intel Corporation
; All rights reserved. This program and the accompanying materials
; are licensed and made available under the terms and conditions of the BSD License
; which accompanies this distribution. The full text of the license may be found at
; http://opensource.org/licenses/bsd-license.php
;
; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
;
; Module Name:
;
; ZeroMem.Asm
;
; Abstract:
;
; ZeroMem function
;
; Notes:
;
;------------------------------------------------------------------------------
.386
.model flat,C
.code
;------------------------------------------------------------------------------
; VOID *
; InternalMemZeroMem (
; IN VOID *Buffer,
; IN UINTN Count
; );
;------------------------------------------------------------------------------
InternalMemZeroMem PROC USES edi
xor eax, eax
mov edi, [esp + 8]
mov ecx, [esp + 12]
mov edx, ecx
shr ecx, 2
and edx, 3
push edi
rep stosd
mov ecx, edx
rep stosb
pop eax
ret
InternalMemZeroMem ENDP
END
|
; A040006: Continued fraction for sqrt(10).
; 3,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6
pow $1,$0
gcd $1,4
add $1,2
|
* Sprite keybd
*
* Mode 4
* +|-------------------+
* -aawrrrrrwwararaaawaw-
* |aaawrrrwaawararaawwa|
* |aarrwrwaaaawararaaaa|
* |arrrrwaawaaawararaar|
* |rrrrwaawaaaaawararrr|
* |rrrwaawawaaaaawarrrr|
* |rrrwaaaaawaaaaawrrrr|
* |rrwaraaaaawaaaarwrrw|
* |rwararaaaaawaarrrwwa|
* |wawararaaaaaarrrrwaa|
* |aaawararaaaarrrrwrra|
* |waaawararaarrrwwrarr|
* |awaaawararrrrwawarar|
* |waaaaawarrrrwaaawara|
* |aaawaarrwrwaaawaaawa|
* |aaaaarrrrwaaawaaaaaw|
* +|-------------------+
*
section sprite
xdef mes_keybd
xref mes_zero
mes_keybd
dc.w $0100,$0000
dc.w 20,16,0,0
dc.l mcs_keybd-*
dc.l mes_zero-*
dc.l 0
mcs_keybd
dc.w $203F,$C0D4
dc.w $5050,$0000
dc.w $111F,$202A
dc.w $6060,$0000
dc.w $0A3E,$1015
dc.w $0000,$0000
dc.w $047C,$888A
dc.w $0090,$0000
dc.w $09F9,$0405
dc.w $0070,$0000
dc.w $12F2,$8282
dc.w $00F0,$0000
dc.w $10F0,$4141
dc.w $00F0,$0000
dc.w $20E8,$2021
dc.w $90F0,$0000
dc.w $40D4,$1013
dc.w $60E0,$0000
dc.w $A0AA,$0007
dc.w $40C0,$0000
dc.w $1015,$000F
dc.w $80E0,$0000
dc.w $888A,$039F
dc.w $00B0,$0000
dc.w $4445,$057D
dc.w $0050,$0000
dc.w $8282,$08F8
dc.w $80A0,$0000
dc.w $1013,$A2E2
dc.w $2020,$0000
dc.w $0007,$44C4
dc.w $1010,$0000
*
end
|
; A066810: Expansion of x^2/((1-3*x)*(1-2*x)^2).
; 0,0,1,7,33,131,473,1611,5281,16867,52905,163835,502769,1532883,4651897,14070379,42456897,127894979,384799049,1156756443,3475250065,10436235955,31330727961,94038321227,282211432673,846835624611,2540926304233,7623651327931,22872765923121,68622055865747,205873952225465,617637962803755,1852947174407809,5558910242700163,16676872462021257,50030909443839899,150093329626941137,450281225831404659,1350846220114853209,4052543883024791563,12157642369312745505,36472949098170792035,109418892374489114921
mov $1,2
mov $2,$0
add $2,2
lpb $0
sub $0,1
mul $1,3
mul $2,2
lpe
sub $1,$2
mul $1,2
div $1,4
mov $0,$1
|
.global s_prepare_buffers
s_prepare_buffers:
push %r12
push %r15
push %r8
push %r9
push %rbx
push %rcx
push %rdi
push %rsi
lea addresses_UC_ht+0x1966b, %rsi
lea addresses_A_ht+0x1fa3, %rdi
xor %r12, %r12
mov $80, %rcx
rep movsl
nop
nop
add $34453, %rsi
lea addresses_A_ht+0x1c667, %r9
nop
nop
inc %rdi
movw $0x6162, (%r9)
nop
nop
nop
nop
add %r9, %r9
lea addresses_WT_ht+0x1deb, %rsi
nop
nop
nop
nop
nop
xor $22399, %r8
mov $0x6162636465666768, %rdi
movq %rdi, %xmm3
movups %xmm3, (%rsi)
nop
nop
nop
nop
nop
and $43758, %rdi
lea addresses_normal_ht+0x1ae73, %rdi
nop
nop
nop
and $64658, %r9
mov (%rdi), %r12d
nop
nop
nop
nop
add $20574, %r8
lea addresses_normal_ht+0xac63, %rdi
nop
add %r9, %r9
mov (%rdi), %r8d
nop
nop
nop
nop
add %r12, %r12
lea addresses_UC_ht+0x16c63, %r12
nop
nop
nop
nop
nop
and $56582, %rdi
mov $0x6162636465666768, %r9
movq %r9, %xmm2
movups %xmm2, (%r12)
nop
nop
sub $46831, %rsi
lea addresses_normal_ht+0x76e7, %r12
nop
xor %rbx, %rbx
movb $0x61, (%r12)
add %r12, %r12
lea addresses_D_ht+0x1e6b, %rsi
lea addresses_WC_ht+0x15aa3, %rdi
nop
nop
sub $8348, %r8
mov $52, %rcx
rep movsw
nop
nop
nop
nop
nop
add $14938, %r9
lea addresses_D_ht+0x2723, %rdi
nop
cmp %r9, %r9
movl $0x61626364, (%rdi)
nop
nop
nop
xor %r8, %r8
lea addresses_WT_ht+0x3ea3, %rsi
lea addresses_UC_ht+0x174a3, %rdi
add $44649, %r15
mov $125, %rcx
rep movsl
cmp %rcx, %rcx
lea addresses_D_ht+0x15863, %r8
nop
dec %r15
movb $0x61, (%r8)
nop
nop
nop
nop
nop
cmp %r15, %r15
pop %rsi
pop %rdi
pop %rcx
pop %rbx
pop %r9
pop %r8
pop %r15
pop %r12
ret
.global s_faulty_load
s_faulty_load:
push %r10
push %r11
push %rax
push %rbp
push %rbx
push %rcx
push %rsi
// Store
lea addresses_UC+0x1d6a3, %rcx
nop
nop
sub %rbx, %rbx
mov $0x5152535455565758, %rsi
movq %rsi, %xmm2
vmovaps %ymm2, (%rcx)
nop
nop
nop
nop
sub $38268, %rsi
// Faulty Load
lea addresses_RW+0x3ea3, %r11
nop
nop
nop
nop
nop
and $60246, %r10
mov (%r11), %bp
lea oracles, %rbx
and $0xff, %rbp
shlq $12, %rbp
mov (%rbx,%rbp,1), %rbp
pop %rsi
pop %rcx
pop %rbx
pop %rbp
pop %rax
pop %r11
pop %r10
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'type': 'addresses_RW', 'size': 4, 'AVXalign': False, 'NT': True, 'congruent': 0, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_UC', 'size': 32, 'AVXalign': True, 'NT': False, 'congruent': 10, 'same': False}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'type': 'addresses_RW', 'size': 2, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': True}}
<gen_prepare_buffer>
{'OP': 'REPM', 'src': {'type': 'addresses_UC_ht', 'congruent': 3, 'same': False}, 'dst': {'type': 'addresses_A_ht', 'congruent': 7, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_A_ht', 'size': 2, 'AVXalign': False, 'NT': False, 'congruent': 2, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_WT_ht', 'size': 16, 'AVXalign': False, 'NT': False, 'congruent': 3, 'same': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_normal_ht', 'size': 4, 'AVXalign': True, 'NT': True, 'congruent': 2, 'same': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_normal_ht', 'size': 4, 'AVXalign': False, 'NT': False, 'congruent': 6, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_UC_ht', 'size': 16, 'AVXalign': False, 'NT': False, 'congruent': 6, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_normal_ht', 'size': 1, 'AVXalign': True, 'NT': False, 'congruent': 0, 'same': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_D_ht', 'congruent': 3, 'same': False}, 'dst': {'type': 'addresses_WC_ht', 'congruent': 10, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_D_ht', 'size': 4, 'AVXalign': False, 'NT': False, 'congruent': 7, 'same': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_WT_ht', 'congruent': 11, 'same': False}, 'dst': {'type': 'addresses_UC_ht', 'congruent': 6, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_D_ht', 'size': 1, 'AVXalign': False, 'NT': False, 'congruent': 6, 'same': False}}
{'32': 291}
32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32
*/
|
_sh: formato do arquivo elf32-i386
Desmontagem da seção .text:
00000000 <main>:
return 0;
}
int
main(void)
{
0: f3 0f 1e fb endbr32
4: 8d 4c 24 04 lea 0x4(%esp),%ecx
8: 83 e4 f0 and $0xfffffff0,%esp
b: ff 71 fc pushl -0x4(%ecx)
e: 55 push %ebp
f: 89 e5 mov %esp,%ebp
11: 51 push %ecx
12: 83 ec 04 sub $0x4,%esp
static char buf[100];
int fd;
// Ensure that three file descriptors are open.
while((fd = open("console", O_RDWR)) >= 0){
15: eb 12 jmp 29 <main+0x29>
17: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
1e: 66 90 xchg %ax,%ax
if(fd >= 3){
20: 83 f8 02 cmp $0x2,%eax
23: 0f 8f b7 00 00 00 jg e0 <main+0xe0>
while((fd = open("console", O_RDWR)) >= 0){
29: 83 ec 08 sub $0x8,%esp
2c: 6a 02 push $0x2
2e: 68 f9 12 00 00 push $0x12f9
33: e8 9b 0d 00 00 call dd3 <open>
38: 83 c4 10 add $0x10,%esp
3b: 85 c0 test %eax,%eax
3d: 79 e1 jns 20 <main+0x20>
3f: eb 32 jmp 73 <main+0x73>
41: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
}
}
// Read and run input commands.
while(getcmd(buf, sizeof(buf)) >= 0){
if(buf[0] == 'c' && buf[1] == 'd' && buf[2] == ' '){
48: 80 3d 42 19 00 00 20 cmpb $0x20,0x1942
4f: 74 51 je a2 <main+0xa2>
51: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
int
fork1(void)
{
int pid;
pid = fork();
58: e8 2e 0d 00 00 call d8b <fork>
if(pid == -1)
5d: 83 f8 ff cmp $0xffffffff,%eax
60: 0f 84 9d 00 00 00 je 103 <main+0x103>
if(fork1() == 0)
66: 85 c0 test %eax,%eax
68: 0f 84 80 00 00 00 je ee <main+0xee>
wait();
6e: e8 28 0d 00 00 call d9b <wait>
while(getcmd(buf, sizeof(buf)) >= 0){
73: 83 ec 08 sub $0x8,%esp
76: 6a 64 push $0x64
78: 68 40 19 00 00 push $0x1940
7d: e8 8e 00 00 00 call 110 <getcmd>
82: 83 c4 10 add $0x10,%esp
85: 85 c0 test %eax,%eax
87: 78 14 js 9d <main+0x9d>
if(buf[0] == 'c' && buf[1] == 'd' && buf[2] == ' '){
89: 80 3d 40 19 00 00 63 cmpb $0x63,0x1940
90: 75 c6 jne 58 <main+0x58>
92: 80 3d 41 19 00 00 64 cmpb $0x64,0x1941
99: 75 bd jne 58 <main+0x58>
9b: eb ab jmp 48 <main+0x48>
exit();
9d: e8 f1 0c 00 00 call d93 <exit>
buf[strlen(buf)-1] = 0; // chop \n
a2: 83 ec 0c sub $0xc,%esp
a5: 68 40 19 00 00 push $0x1940
aa: e8 01 0b 00 00 call bb0 <strlen>
if(chdir(buf+3) < 0)
af: c7 04 24 43 19 00 00 movl $0x1943,(%esp)
buf[strlen(buf)-1] = 0; // chop \n
b6: c6 80 3f 19 00 00 00 movb $0x0,0x193f(%eax)
if(chdir(buf+3) < 0)
bd: e8 41 0d 00 00 call e03 <chdir>
c2: 83 c4 10 add $0x10,%esp
c5: 85 c0 test %eax,%eax
c7: 79 aa jns 73 <main+0x73>
printf(2, "cannot cd %s\n", buf+3);
c9: 50 push %eax
ca: 68 43 19 00 00 push $0x1943
cf: 68 01 13 00 00 push $0x1301
d4: 6a 02 push $0x2
d6: e8 15 0e 00 00 call ef0 <printf>
db: 83 c4 10 add $0x10,%esp
de: eb 93 jmp 73 <main+0x73>
close(fd);
e0: 83 ec 0c sub $0xc,%esp
e3: 50 push %eax
e4: e8 d2 0c 00 00 call dbb <close>
break;
e9: 83 c4 10 add $0x10,%esp
ec: eb 85 jmp 73 <main+0x73>
runcmd(parsecmd(buf));
ee: 83 ec 0c sub $0xc,%esp
f1: 68 40 19 00 00 push $0x1940
f6: e8 c5 09 00 00 call ac0 <parsecmd>
fb: 89 04 24 mov %eax,(%esp)
fe: e8 7d 00 00 00 call 180 <runcmd>
panic("fork");
103: 83 ec 0c sub $0xc,%esp
106: 68 82 12 00 00 push $0x1282
10b: e8 50 00 00 00 call 160 <panic>
00000110 <getcmd>:
{
110: f3 0f 1e fb endbr32
114: 55 push %ebp
115: 89 e5 mov %esp,%ebp
117: 56 push %esi
118: 53 push %ebx
119: 8b 75 0c mov 0xc(%ebp),%esi
11c: 8b 5d 08 mov 0x8(%ebp),%ebx
printf(2, "$ ");
11f: 83 ec 08 sub $0x8,%esp
122: 68 58 12 00 00 push $0x1258
127: 6a 02 push $0x2
129: e8 c2 0d 00 00 call ef0 <printf>
memset(buf, 0, nbuf);
12e: 83 c4 0c add $0xc,%esp
131: 56 push %esi
132: 6a 00 push $0x0
134: 53 push %ebx
135: e8 b6 0a 00 00 call bf0 <memset>
gets(buf, nbuf);
13a: 58 pop %eax
13b: 5a pop %edx
13c: 56 push %esi
13d: 53 push %ebx
13e: e8 0d 0b 00 00 call c50 <gets>
if(buf[0] == 0) // EOF
143: 83 c4 10 add $0x10,%esp
146: 31 c0 xor %eax,%eax
148: 80 3b 00 cmpb $0x0,(%ebx)
14b: 0f 94 c0 sete %al
}
14e: 8d 65 f8 lea -0x8(%ebp),%esp
151: 5b pop %ebx
if(buf[0] == 0) // EOF
152: f7 d8 neg %eax
}
154: 5e pop %esi
155: 5d pop %ebp
156: c3 ret
157: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
15e: 66 90 xchg %ax,%ax
00000160 <panic>:
{
160: f3 0f 1e fb endbr32
164: 55 push %ebp
165: 89 e5 mov %esp,%ebp
167: 83 ec 0c sub $0xc,%esp
printf(2, "%s\n", s);
16a: ff 75 08 pushl 0x8(%ebp)
16d: 68 f5 12 00 00 push $0x12f5
172: 6a 02 push $0x2
174: e8 77 0d 00 00 call ef0 <printf>
exit();
179: e8 15 0c 00 00 call d93 <exit>
17e: 66 90 xchg %ax,%ax
00000180 <runcmd>:
{
180: f3 0f 1e fb endbr32
184: 55 push %ebp
185: 89 e5 mov %esp,%ebp
187: 53 push %ebx
188: 83 ec 14 sub $0x14,%esp
18b: 8b 5d 08 mov 0x8(%ebp),%ebx
if(cmd == 0)
18e: 85 db test %ebx,%ebx
190: 74 7e je 210 <runcmd+0x90>
switch(cmd->type){
192: 83 3b 05 cmpl $0x5,(%ebx)
195: 0f 87 04 01 00 00 ja 29f <runcmd+0x11f>
19b: 8b 03 mov (%ebx),%eax
19d: 3e ff 24 85 10 13 00 notrack jmp *0x1310(,%eax,4)
1a4: 00
if(pipe(p) < 0)
1a5: 83 ec 0c sub $0xc,%esp
1a8: 8d 45 f0 lea -0x10(%ebp),%eax
1ab: 50 push %eax
1ac: e8 f2 0b 00 00 call da3 <pipe>
1b1: 83 c4 10 add $0x10,%esp
1b4: 85 c0 test %eax,%eax
1b6: 0f 88 05 01 00 00 js 2c1 <runcmd+0x141>
pid = fork();
1bc: e8 ca 0b 00 00 call d8b <fork>
if(pid == -1)
1c1: 83 f8 ff cmp $0xffffffff,%eax
1c4: 0f 84 60 01 00 00 je 32a <runcmd+0x1aa>
if(fork1() == 0){
1ca: 85 c0 test %eax,%eax
1cc: 0f 84 fc 00 00 00 je 2ce <runcmd+0x14e>
pid = fork();
1d2: e8 b4 0b 00 00 call d8b <fork>
if(pid == -1)
1d7: 83 f8 ff cmp $0xffffffff,%eax
1da: 0f 84 4a 01 00 00 je 32a <runcmd+0x1aa>
if(fork1() == 0){
1e0: 85 c0 test %eax,%eax
1e2: 0f 84 14 01 00 00 je 2fc <runcmd+0x17c>
close(p[0]);
1e8: 83 ec 0c sub $0xc,%esp
1eb: ff 75 f0 pushl -0x10(%ebp)
1ee: e8 c8 0b 00 00 call dbb <close>
close(p[1]);
1f3: 58 pop %eax
1f4: ff 75 f4 pushl -0xc(%ebp)
1f7: e8 bf 0b 00 00 call dbb <close>
wait();
1fc: e8 9a 0b 00 00 call d9b <wait>
wait();
201: e8 95 0b 00 00 call d9b <wait>
break;
206: 83 c4 10 add $0x10,%esp
209: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
exit();
210: e8 7e 0b 00 00 call d93 <exit>
pid = fork();
215: e8 71 0b 00 00 call d8b <fork>
if(pid == -1)
21a: 83 f8 ff cmp $0xffffffff,%eax
21d: 0f 84 07 01 00 00 je 32a <runcmd+0x1aa>
if(fork1() == 0)
223: 85 c0 test %eax,%eax
225: 75 e9 jne 210 <runcmd+0x90>
227: eb 6b jmp 294 <runcmd+0x114>
if(ecmd->argv[0] == 0)
229: 8b 43 04 mov 0x4(%ebx),%eax
22c: 85 c0 test %eax,%eax
22e: 74 e0 je 210 <runcmd+0x90>
exec(ecmd->argv[0], ecmd->argv);
230: 8d 53 04 lea 0x4(%ebx),%edx
233: 51 push %ecx
234: 51 push %ecx
235: 52 push %edx
236: 50 push %eax
237: e8 8f 0b 00 00 call dcb <exec>
printf(2, "exec %s failed\n", ecmd->argv[0]);
23c: 83 c4 0c add $0xc,%esp
23f: ff 73 04 pushl 0x4(%ebx)
242: 68 62 12 00 00 push $0x1262
247: 6a 02 push $0x2
249: e8 a2 0c 00 00 call ef0 <printf>
break;
24e: 83 c4 10 add $0x10,%esp
251: eb bd jmp 210 <runcmd+0x90>
pid = fork();
253: e8 33 0b 00 00 call d8b <fork>
if(pid == -1)
258: 83 f8 ff cmp $0xffffffff,%eax
25b: 0f 84 c9 00 00 00 je 32a <runcmd+0x1aa>
if(fork1() == 0)
261: 85 c0 test %eax,%eax
263: 74 2f je 294 <runcmd+0x114>
wait();
265: e8 31 0b 00 00 call d9b <wait>
runcmd(lcmd->right);
26a: 83 ec 0c sub $0xc,%esp
26d: ff 73 08 pushl 0x8(%ebx)
270: e8 0b ff ff ff call 180 <runcmd>
close(rcmd->fd);
275: 83 ec 0c sub $0xc,%esp
278: ff 73 14 pushl 0x14(%ebx)
27b: e8 3b 0b 00 00 call dbb <close>
if(open(rcmd->file, rcmd->mode) < 0){
280: 58 pop %eax
281: 5a pop %edx
282: ff 73 10 pushl 0x10(%ebx)
285: ff 73 08 pushl 0x8(%ebx)
288: e8 46 0b 00 00 call dd3 <open>
28d: 83 c4 10 add $0x10,%esp
290: 85 c0 test %eax,%eax
292: 78 18 js 2ac <runcmd+0x12c>
runcmd(bcmd->cmd);
294: 83 ec 0c sub $0xc,%esp
297: ff 73 04 pushl 0x4(%ebx)
29a: e8 e1 fe ff ff call 180 <runcmd>
panic("runcmd");
29f: 83 ec 0c sub $0xc,%esp
2a2: 68 5b 12 00 00 push $0x125b
2a7: e8 b4 fe ff ff call 160 <panic>
printf(2, "open %s failed\n", rcmd->file);
2ac: 51 push %ecx
2ad: ff 73 08 pushl 0x8(%ebx)
2b0: 68 72 12 00 00 push $0x1272
2b5: 6a 02 push $0x2
2b7: e8 34 0c 00 00 call ef0 <printf>
exit();
2bc: e8 d2 0a 00 00 call d93 <exit>
panic("pipe");
2c1: 83 ec 0c sub $0xc,%esp
2c4: 68 87 12 00 00 push $0x1287
2c9: e8 92 fe ff ff call 160 <panic>
close(1);
2ce: 83 ec 0c sub $0xc,%esp
2d1: 6a 01 push $0x1
2d3: e8 e3 0a 00 00 call dbb <close>
dup(p[1]);
2d8: 58 pop %eax
2d9: ff 75 f4 pushl -0xc(%ebp)
2dc: e8 2a 0b 00 00 call e0b <dup>
close(p[0]);
2e1: 58 pop %eax
2e2: ff 75 f0 pushl -0x10(%ebp)
2e5: e8 d1 0a 00 00 call dbb <close>
close(p[1]);
2ea: 58 pop %eax
2eb: ff 75 f4 pushl -0xc(%ebp)
2ee: e8 c8 0a 00 00 call dbb <close>
runcmd(pcmd->left);
2f3: 5a pop %edx
2f4: ff 73 04 pushl 0x4(%ebx)
2f7: e8 84 fe ff ff call 180 <runcmd>
close(0);
2fc: 83 ec 0c sub $0xc,%esp
2ff: 6a 00 push $0x0
301: e8 b5 0a 00 00 call dbb <close>
dup(p[0]);
306: 5a pop %edx
307: ff 75 f0 pushl -0x10(%ebp)
30a: e8 fc 0a 00 00 call e0b <dup>
close(p[0]);
30f: 59 pop %ecx
310: ff 75 f0 pushl -0x10(%ebp)
313: e8 a3 0a 00 00 call dbb <close>
close(p[1]);
318: 58 pop %eax
319: ff 75 f4 pushl -0xc(%ebp)
31c: e8 9a 0a 00 00 call dbb <close>
runcmd(pcmd->right);
321: 58 pop %eax
322: ff 73 08 pushl 0x8(%ebx)
325: e8 56 fe ff ff call 180 <runcmd>
panic("fork");
32a: 83 ec 0c sub $0xc,%esp
32d: 68 82 12 00 00 push $0x1282
332: e8 29 fe ff ff call 160 <panic>
337: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
33e: 66 90 xchg %ax,%ax
00000340 <fork1>:
{
340: f3 0f 1e fb endbr32
344: 55 push %ebp
345: 89 e5 mov %esp,%ebp
347: 83 ec 08 sub $0x8,%esp
pid = fork();
34a: e8 3c 0a 00 00 call d8b <fork>
if(pid == -1)
34f: 83 f8 ff cmp $0xffffffff,%eax
352: 74 02 je 356 <fork1+0x16>
return pid;
}
354: c9 leave
355: c3 ret
panic("fork");
356: 83 ec 0c sub $0xc,%esp
359: 68 82 12 00 00 push $0x1282
35e: e8 fd fd ff ff call 160 <panic>
363: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
36a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
00000370 <execcmd>:
//PAGEBREAK!
// Constructors
struct cmd*
execcmd(void)
{
370: f3 0f 1e fb endbr32
374: 55 push %ebp
375: 89 e5 mov %esp,%ebp
377: 53 push %ebx
378: 83 ec 10 sub $0x10,%esp
struct execcmd *cmd;
cmd = malloc(sizeof(*cmd));
37b: 6a 54 push $0x54
37d: e8 ce 0d 00 00 call 1150 <malloc>
memset(cmd, 0, sizeof(*cmd));
382: 83 c4 0c add $0xc,%esp
385: 6a 54 push $0x54
cmd = malloc(sizeof(*cmd));
387: 89 c3 mov %eax,%ebx
memset(cmd, 0, sizeof(*cmd));
389: 6a 00 push $0x0
38b: 50 push %eax
38c: e8 5f 08 00 00 call bf0 <memset>
cmd->type = EXEC;
391: c7 03 01 00 00 00 movl $0x1,(%ebx)
return (struct cmd*)cmd;
}
397: 89 d8 mov %ebx,%eax
399: 8b 5d fc mov -0x4(%ebp),%ebx
39c: c9 leave
39d: c3 ret
39e: 66 90 xchg %ax,%ax
000003a0 <redircmd>:
struct cmd*
redircmd(struct cmd *subcmd, char *file, char *efile, int mode, int fd)
{
3a0: f3 0f 1e fb endbr32
3a4: 55 push %ebp
3a5: 89 e5 mov %esp,%ebp
3a7: 53 push %ebx
3a8: 83 ec 10 sub $0x10,%esp
struct redircmd *cmd;
cmd = malloc(sizeof(*cmd));
3ab: 6a 18 push $0x18
3ad: e8 9e 0d 00 00 call 1150 <malloc>
memset(cmd, 0, sizeof(*cmd));
3b2: 83 c4 0c add $0xc,%esp
3b5: 6a 18 push $0x18
cmd = malloc(sizeof(*cmd));
3b7: 89 c3 mov %eax,%ebx
memset(cmd, 0, sizeof(*cmd));
3b9: 6a 00 push $0x0
3bb: 50 push %eax
3bc: e8 2f 08 00 00 call bf0 <memset>
cmd->type = REDIR;
cmd->cmd = subcmd;
3c1: 8b 45 08 mov 0x8(%ebp),%eax
cmd->type = REDIR;
3c4: c7 03 02 00 00 00 movl $0x2,(%ebx)
cmd->cmd = subcmd;
3ca: 89 43 04 mov %eax,0x4(%ebx)
cmd->file = file;
3cd: 8b 45 0c mov 0xc(%ebp),%eax
3d0: 89 43 08 mov %eax,0x8(%ebx)
cmd->efile = efile;
3d3: 8b 45 10 mov 0x10(%ebp),%eax
3d6: 89 43 0c mov %eax,0xc(%ebx)
cmd->mode = mode;
3d9: 8b 45 14 mov 0x14(%ebp),%eax
3dc: 89 43 10 mov %eax,0x10(%ebx)
cmd->fd = fd;
3df: 8b 45 18 mov 0x18(%ebp),%eax
3e2: 89 43 14 mov %eax,0x14(%ebx)
return (struct cmd*)cmd;
}
3e5: 89 d8 mov %ebx,%eax
3e7: 8b 5d fc mov -0x4(%ebp),%ebx
3ea: c9 leave
3eb: c3 ret
3ec: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
000003f0 <pipecmd>:
struct cmd*
pipecmd(struct cmd *left, struct cmd *right)
{
3f0: f3 0f 1e fb endbr32
3f4: 55 push %ebp
3f5: 89 e5 mov %esp,%ebp
3f7: 53 push %ebx
3f8: 83 ec 10 sub $0x10,%esp
struct pipecmd *cmd;
cmd = malloc(sizeof(*cmd));
3fb: 6a 0c push $0xc
3fd: e8 4e 0d 00 00 call 1150 <malloc>
memset(cmd, 0, sizeof(*cmd));
402: 83 c4 0c add $0xc,%esp
405: 6a 0c push $0xc
cmd = malloc(sizeof(*cmd));
407: 89 c3 mov %eax,%ebx
memset(cmd, 0, sizeof(*cmd));
409: 6a 00 push $0x0
40b: 50 push %eax
40c: e8 df 07 00 00 call bf0 <memset>
cmd->type = PIPE;
cmd->left = left;
411: 8b 45 08 mov 0x8(%ebp),%eax
cmd->type = PIPE;
414: c7 03 03 00 00 00 movl $0x3,(%ebx)
cmd->left = left;
41a: 89 43 04 mov %eax,0x4(%ebx)
cmd->right = right;
41d: 8b 45 0c mov 0xc(%ebp),%eax
420: 89 43 08 mov %eax,0x8(%ebx)
return (struct cmd*)cmd;
}
423: 89 d8 mov %ebx,%eax
425: 8b 5d fc mov -0x4(%ebp),%ebx
428: c9 leave
429: c3 ret
42a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
00000430 <listcmd>:
struct cmd*
listcmd(struct cmd *left, struct cmd *right)
{
430: f3 0f 1e fb endbr32
434: 55 push %ebp
435: 89 e5 mov %esp,%ebp
437: 53 push %ebx
438: 83 ec 10 sub $0x10,%esp
struct listcmd *cmd;
cmd = malloc(sizeof(*cmd));
43b: 6a 0c push $0xc
43d: e8 0e 0d 00 00 call 1150 <malloc>
memset(cmd, 0, sizeof(*cmd));
442: 83 c4 0c add $0xc,%esp
445: 6a 0c push $0xc
cmd = malloc(sizeof(*cmd));
447: 89 c3 mov %eax,%ebx
memset(cmd, 0, sizeof(*cmd));
449: 6a 00 push $0x0
44b: 50 push %eax
44c: e8 9f 07 00 00 call bf0 <memset>
cmd->type = LIST;
cmd->left = left;
451: 8b 45 08 mov 0x8(%ebp),%eax
cmd->type = LIST;
454: c7 03 04 00 00 00 movl $0x4,(%ebx)
cmd->left = left;
45a: 89 43 04 mov %eax,0x4(%ebx)
cmd->right = right;
45d: 8b 45 0c mov 0xc(%ebp),%eax
460: 89 43 08 mov %eax,0x8(%ebx)
return (struct cmd*)cmd;
}
463: 89 d8 mov %ebx,%eax
465: 8b 5d fc mov -0x4(%ebp),%ebx
468: c9 leave
469: c3 ret
46a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
00000470 <backcmd>:
struct cmd*
backcmd(struct cmd *subcmd)
{
470: f3 0f 1e fb endbr32
474: 55 push %ebp
475: 89 e5 mov %esp,%ebp
477: 53 push %ebx
478: 83 ec 10 sub $0x10,%esp
struct backcmd *cmd;
cmd = malloc(sizeof(*cmd));
47b: 6a 08 push $0x8
47d: e8 ce 0c 00 00 call 1150 <malloc>
memset(cmd, 0, sizeof(*cmd));
482: 83 c4 0c add $0xc,%esp
485: 6a 08 push $0x8
cmd = malloc(sizeof(*cmd));
487: 89 c3 mov %eax,%ebx
memset(cmd, 0, sizeof(*cmd));
489: 6a 00 push $0x0
48b: 50 push %eax
48c: e8 5f 07 00 00 call bf0 <memset>
cmd->type = BACK;
cmd->cmd = subcmd;
491: 8b 45 08 mov 0x8(%ebp),%eax
cmd->type = BACK;
494: c7 03 05 00 00 00 movl $0x5,(%ebx)
cmd->cmd = subcmd;
49a: 89 43 04 mov %eax,0x4(%ebx)
return (struct cmd*)cmd;
}
49d: 89 d8 mov %ebx,%eax
49f: 8b 5d fc mov -0x4(%ebp),%ebx
4a2: c9 leave
4a3: c3 ret
4a4: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
4ab: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
4af: 90 nop
000004b0 <gettoken>:
char whitespace[] = " \t\r\n\v";
char symbols[] = "<|>&;()";
int
gettoken(char **ps, char *es, char **q, char **eq)
{
4b0: f3 0f 1e fb endbr32
4b4: 55 push %ebp
4b5: 89 e5 mov %esp,%ebp
4b7: 57 push %edi
4b8: 56 push %esi
4b9: 53 push %ebx
4ba: 83 ec 0c sub $0xc,%esp
char *s;
int ret;
s = *ps;
4bd: 8b 45 08 mov 0x8(%ebp),%eax
{
4c0: 8b 5d 0c mov 0xc(%ebp),%ebx
4c3: 8b 75 10 mov 0x10(%ebp),%esi
s = *ps;
4c6: 8b 38 mov (%eax),%edi
while(s < es && strchr(whitespace, *s))
4c8: 39 df cmp %ebx,%edi
4ca: 72 0b jb 4d7 <gettoken+0x27>
4cc: eb 21 jmp 4ef <gettoken+0x3f>
4ce: 66 90 xchg %ax,%ax
s++;
4d0: 83 c7 01 add $0x1,%edi
while(s < es && strchr(whitespace, *s))
4d3: 39 fb cmp %edi,%ebx
4d5: 74 18 je 4ef <gettoken+0x3f>
4d7: 0f be 07 movsbl (%edi),%eax
4da: 83 ec 08 sub $0x8,%esp
4dd: 50 push %eax
4de: 68 20 19 00 00 push $0x1920
4e3: e8 28 07 00 00 call c10 <strchr>
4e8: 83 c4 10 add $0x10,%esp
4eb: 85 c0 test %eax,%eax
4ed: 75 e1 jne 4d0 <gettoken+0x20>
if(q)
4ef: 85 f6 test %esi,%esi
4f1: 74 02 je 4f5 <gettoken+0x45>
*q = s;
4f3: 89 3e mov %edi,(%esi)
ret = *s;
4f5: 0f b6 07 movzbl (%edi),%eax
switch(*s){
4f8: 3c 3c cmp $0x3c,%al
4fa: 0f 8f d0 00 00 00 jg 5d0 <gettoken+0x120>
500: 3c 3a cmp $0x3a,%al
502: 0f 8f b4 00 00 00 jg 5bc <gettoken+0x10c>
508: 84 c0 test %al,%al
50a: 75 44 jne 550 <gettoken+0xa0>
50c: 31 f6 xor %esi,%esi
ret = 'a';
while(s < es && !strchr(whitespace, *s) && !strchr(symbols, *s))
s++;
break;
}
if(eq)
50e: 8b 55 14 mov 0x14(%ebp),%edx
511: 85 d2 test %edx,%edx
513: 74 05 je 51a <gettoken+0x6a>
*eq = s;
515: 8b 45 14 mov 0x14(%ebp),%eax
518: 89 38 mov %edi,(%eax)
while(s < es && strchr(whitespace, *s))
51a: 39 df cmp %ebx,%edi
51c: 72 09 jb 527 <gettoken+0x77>
51e: eb 1f jmp 53f <gettoken+0x8f>
s++;
520: 83 c7 01 add $0x1,%edi
while(s < es && strchr(whitespace, *s))
523: 39 fb cmp %edi,%ebx
525: 74 18 je 53f <gettoken+0x8f>
527: 0f be 07 movsbl (%edi),%eax
52a: 83 ec 08 sub $0x8,%esp
52d: 50 push %eax
52e: 68 20 19 00 00 push $0x1920
533: e8 d8 06 00 00 call c10 <strchr>
538: 83 c4 10 add $0x10,%esp
53b: 85 c0 test %eax,%eax
53d: 75 e1 jne 520 <gettoken+0x70>
*ps = s;
53f: 8b 45 08 mov 0x8(%ebp),%eax
542: 89 38 mov %edi,(%eax)
return ret;
}
544: 8d 65 f4 lea -0xc(%ebp),%esp
547: 89 f0 mov %esi,%eax
549: 5b pop %ebx
54a: 5e pop %esi
54b: 5f pop %edi
54c: 5d pop %ebp
54d: c3 ret
54e: 66 90 xchg %ax,%ax
switch(*s){
550: 79 5e jns 5b0 <gettoken+0x100>
while(s < es && !strchr(whitespace, *s) && !strchr(symbols, *s))
552: 39 fb cmp %edi,%ebx
554: 77 34 ja 58a <gettoken+0xda>
if(eq)
556: 8b 45 14 mov 0x14(%ebp),%eax
559: be 61 00 00 00 mov $0x61,%esi
55e: 85 c0 test %eax,%eax
560: 75 b3 jne 515 <gettoken+0x65>
562: eb db jmp 53f <gettoken+0x8f>
564: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
while(s < es && !strchr(whitespace, *s) && !strchr(symbols, *s))
568: 0f be 07 movsbl (%edi),%eax
56b: 83 ec 08 sub $0x8,%esp
56e: 50 push %eax
56f: 68 18 19 00 00 push $0x1918
574: e8 97 06 00 00 call c10 <strchr>
579: 83 c4 10 add $0x10,%esp
57c: 85 c0 test %eax,%eax
57e: 75 22 jne 5a2 <gettoken+0xf2>
s++;
580: 83 c7 01 add $0x1,%edi
while(s < es && !strchr(whitespace, *s) && !strchr(symbols, *s))
583: 39 fb cmp %edi,%ebx
585: 74 cf je 556 <gettoken+0xa6>
587: 0f b6 07 movzbl (%edi),%eax
58a: 83 ec 08 sub $0x8,%esp
58d: 0f be f0 movsbl %al,%esi
590: 56 push %esi
591: 68 20 19 00 00 push $0x1920
596: e8 75 06 00 00 call c10 <strchr>
59b: 83 c4 10 add $0x10,%esp
59e: 85 c0 test %eax,%eax
5a0: 74 c6 je 568 <gettoken+0xb8>
ret = 'a';
5a2: be 61 00 00 00 mov $0x61,%esi
5a7: e9 62 ff ff ff jmp 50e <gettoken+0x5e>
5ac: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
switch(*s){
5b0: 3c 26 cmp $0x26,%al
5b2: 74 08 je 5bc <gettoken+0x10c>
5b4: 8d 48 d8 lea -0x28(%eax),%ecx
5b7: 80 f9 01 cmp $0x1,%cl
5ba: 77 96 ja 552 <gettoken+0xa2>
ret = *s;
5bc: 0f be f0 movsbl %al,%esi
s++;
5bf: 83 c7 01 add $0x1,%edi
break;
5c2: e9 47 ff ff ff jmp 50e <gettoken+0x5e>
5c7: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
5ce: 66 90 xchg %ax,%ax
switch(*s){
5d0: 3c 3e cmp $0x3e,%al
5d2: 75 1c jne 5f0 <gettoken+0x140>
if(*s == '>'){
5d4: 80 7f 01 3e cmpb $0x3e,0x1(%edi)
s++;
5d8: 8d 47 01 lea 0x1(%edi),%eax
if(*s == '>'){
5db: 74 1c je 5f9 <gettoken+0x149>
s++;
5dd: 89 c7 mov %eax,%edi
5df: be 3e 00 00 00 mov $0x3e,%esi
5e4: e9 25 ff ff ff jmp 50e <gettoken+0x5e>
5e9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
switch(*s){
5f0: 3c 7c cmp $0x7c,%al
5f2: 74 c8 je 5bc <gettoken+0x10c>
5f4: e9 59 ff ff ff jmp 552 <gettoken+0xa2>
s++;
5f9: 83 c7 02 add $0x2,%edi
ret = '+';
5fc: be 2b 00 00 00 mov $0x2b,%esi
601: e9 08 ff ff ff jmp 50e <gettoken+0x5e>
606: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
60d: 8d 76 00 lea 0x0(%esi),%esi
00000610 <peek>:
int
peek(char **ps, char *es, char *toks)
{
610: f3 0f 1e fb endbr32
614: 55 push %ebp
615: 89 e5 mov %esp,%ebp
617: 57 push %edi
618: 56 push %esi
619: 53 push %ebx
61a: 83 ec 0c sub $0xc,%esp
61d: 8b 7d 08 mov 0x8(%ebp),%edi
620: 8b 75 0c mov 0xc(%ebp),%esi
char *s;
s = *ps;
623: 8b 1f mov (%edi),%ebx
while(s < es && strchr(whitespace, *s))
625: 39 f3 cmp %esi,%ebx
627: 72 0e jb 637 <peek+0x27>
629: eb 24 jmp 64f <peek+0x3f>
62b: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
62f: 90 nop
s++;
630: 83 c3 01 add $0x1,%ebx
while(s < es && strchr(whitespace, *s))
633: 39 de cmp %ebx,%esi
635: 74 18 je 64f <peek+0x3f>
637: 0f be 03 movsbl (%ebx),%eax
63a: 83 ec 08 sub $0x8,%esp
63d: 50 push %eax
63e: 68 20 19 00 00 push $0x1920
643: e8 c8 05 00 00 call c10 <strchr>
648: 83 c4 10 add $0x10,%esp
64b: 85 c0 test %eax,%eax
64d: 75 e1 jne 630 <peek+0x20>
*ps = s;
64f: 89 1f mov %ebx,(%edi)
return *s && strchr(toks, *s);
651: 0f be 03 movsbl (%ebx),%eax
654: 31 d2 xor %edx,%edx
656: 84 c0 test %al,%al
658: 75 0e jne 668 <peek+0x58>
}
65a: 8d 65 f4 lea -0xc(%ebp),%esp
65d: 89 d0 mov %edx,%eax
65f: 5b pop %ebx
660: 5e pop %esi
661: 5f pop %edi
662: 5d pop %ebp
663: c3 ret
664: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
return *s && strchr(toks, *s);
668: 83 ec 08 sub $0x8,%esp
66b: 50 push %eax
66c: ff 75 10 pushl 0x10(%ebp)
66f: e8 9c 05 00 00 call c10 <strchr>
674: 83 c4 10 add $0x10,%esp
677: 31 d2 xor %edx,%edx
679: 85 c0 test %eax,%eax
67b: 0f 95 c2 setne %dl
}
67e: 8d 65 f4 lea -0xc(%ebp),%esp
681: 5b pop %ebx
682: 89 d0 mov %edx,%eax
684: 5e pop %esi
685: 5f pop %edi
686: 5d pop %ebp
687: c3 ret
688: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
68f: 90 nop
00000690 <parseredirs>:
return cmd;
}
struct cmd*
parseredirs(struct cmd *cmd, char **ps, char *es)
{
690: f3 0f 1e fb endbr32
694: 55 push %ebp
695: 89 e5 mov %esp,%ebp
697: 57 push %edi
698: 56 push %esi
699: 53 push %ebx
69a: 83 ec 1c sub $0x1c,%esp
69d: 8b 75 0c mov 0xc(%ebp),%esi
6a0: 8b 5d 10 mov 0x10(%ebp),%ebx
int tok;
char *q, *eq;
while(peek(ps, es, "<>")){
6a3: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
6a7: 90 nop
6a8: 83 ec 04 sub $0x4,%esp
6ab: 68 a9 12 00 00 push $0x12a9
6b0: 53 push %ebx
6b1: 56 push %esi
6b2: e8 59 ff ff ff call 610 <peek>
6b7: 83 c4 10 add $0x10,%esp
6ba: 85 c0 test %eax,%eax
6bc: 74 6a je 728 <parseredirs+0x98>
tok = gettoken(ps, es, 0, 0);
6be: 6a 00 push $0x0
6c0: 6a 00 push $0x0
6c2: 53 push %ebx
6c3: 56 push %esi
6c4: e8 e7 fd ff ff call 4b0 <gettoken>
6c9: 89 c7 mov %eax,%edi
if(gettoken(ps, es, &q, &eq) != 'a')
6cb: 8d 45 e4 lea -0x1c(%ebp),%eax
6ce: 50 push %eax
6cf: 8d 45 e0 lea -0x20(%ebp),%eax
6d2: 50 push %eax
6d3: 53 push %ebx
6d4: 56 push %esi
6d5: e8 d6 fd ff ff call 4b0 <gettoken>
6da: 83 c4 20 add $0x20,%esp
6dd: 83 f8 61 cmp $0x61,%eax
6e0: 75 51 jne 733 <parseredirs+0xa3>
panic("missing file for redirection");
switch(tok){
6e2: 83 ff 3c cmp $0x3c,%edi
6e5: 74 31 je 718 <parseredirs+0x88>
6e7: 83 ff 3e cmp $0x3e,%edi
6ea: 74 05 je 6f1 <parseredirs+0x61>
6ec: 83 ff 2b cmp $0x2b,%edi
6ef: 75 b7 jne 6a8 <parseredirs+0x18>
break;
case '>':
cmd = redircmd(cmd, q, eq, O_WRONLY|O_CREATE, 1);
break;
case '+': // >>
cmd = redircmd(cmd, q, eq, O_WRONLY|O_CREATE, 1);
6f1: 83 ec 0c sub $0xc,%esp
6f4: 6a 01 push $0x1
6f6: 68 01 02 00 00 push $0x201
6fb: ff 75 e4 pushl -0x1c(%ebp)
6fe: ff 75 e0 pushl -0x20(%ebp)
701: ff 75 08 pushl 0x8(%ebp)
704: e8 97 fc ff ff call 3a0 <redircmd>
break;
709: 83 c4 20 add $0x20,%esp
cmd = redircmd(cmd, q, eq, O_WRONLY|O_CREATE, 1);
70c: 89 45 08 mov %eax,0x8(%ebp)
break;
70f: eb 97 jmp 6a8 <parseredirs+0x18>
711: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
cmd = redircmd(cmd, q, eq, O_RDONLY, 0);
718: 83 ec 0c sub $0xc,%esp
71b: 6a 00 push $0x0
71d: 6a 00 push $0x0
71f: eb da jmp 6fb <parseredirs+0x6b>
721: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
}
}
return cmd;
}
728: 8b 45 08 mov 0x8(%ebp),%eax
72b: 8d 65 f4 lea -0xc(%ebp),%esp
72e: 5b pop %ebx
72f: 5e pop %esi
730: 5f pop %edi
731: 5d pop %ebp
732: c3 ret
panic("missing file for redirection");
733: 83 ec 0c sub $0xc,%esp
736: 68 8c 12 00 00 push $0x128c
73b: e8 20 fa ff ff call 160 <panic>
00000740 <parseexec>:
return cmd;
}
struct cmd*
parseexec(char **ps, char *es)
{
740: f3 0f 1e fb endbr32
744: 55 push %ebp
745: 89 e5 mov %esp,%ebp
747: 57 push %edi
748: 56 push %esi
749: 53 push %ebx
74a: 83 ec 30 sub $0x30,%esp
74d: 8b 75 08 mov 0x8(%ebp),%esi
750: 8b 7d 0c mov 0xc(%ebp),%edi
char *q, *eq;
int tok, argc;
struct execcmd *cmd;
struct cmd *ret;
if(peek(ps, es, "("))
753: 68 ac 12 00 00 push $0x12ac
758: 57 push %edi
759: 56 push %esi
75a: e8 b1 fe ff ff call 610 <peek>
75f: 83 c4 10 add $0x10,%esp
762: 85 c0 test %eax,%eax
764: 0f 85 96 00 00 00 jne 800 <parseexec+0xc0>
76a: 89 c3 mov %eax,%ebx
return parseblock(ps, es);
ret = execcmd();
76c: e8 ff fb ff ff call 370 <execcmd>
cmd = (struct execcmd*)ret;
argc = 0;
ret = parseredirs(ret, ps, es);
771: 83 ec 04 sub $0x4,%esp
774: 57 push %edi
775: 56 push %esi
776: 50 push %eax
ret = execcmd();
777: 89 45 d0 mov %eax,-0x30(%ebp)
ret = parseredirs(ret, ps, es);
77a: e8 11 ff ff ff call 690 <parseredirs>
while(!peek(ps, es, "|)&;")){
77f: 83 c4 10 add $0x10,%esp
ret = parseredirs(ret, ps, es);
782: 89 45 d4 mov %eax,-0x2c(%ebp)
while(!peek(ps, es, "|)&;")){
785: eb 1c jmp 7a3 <parseexec+0x63>
787: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
78e: 66 90 xchg %ax,%ax
cmd->argv[argc] = q;
cmd->eargv[argc] = eq;
argc++;
if(argc >= MAXARGS)
panic("too many args");
ret = parseredirs(ret, ps, es);
790: 83 ec 04 sub $0x4,%esp
793: 57 push %edi
794: 56 push %esi
795: ff 75 d4 pushl -0x2c(%ebp)
798: e8 f3 fe ff ff call 690 <parseredirs>
79d: 83 c4 10 add $0x10,%esp
7a0: 89 45 d4 mov %eax,-0x2c(%ebp)
while(!peek(ps, es, "|)&;")){
7a3: 83 ec 04 sub $0x4,%esp
7a6: 68 c3 12 00 00 push $0x12c3
7ab: 57 push %edi
7ac: 56 push %esi
7ad: e8 5e fe ff ff call 610 <peek>
7b2: 83 c4 10 add $0x10,%esp
7b5: 85 c0 test %eax,%eax
7b7: 75 67 jne 820 <parseexec+0xe0>
if((tok=gettoken(ps, es, &q, &eq)) == 0)
7b9: 8d 45 e4 lea -0x1c(%ebp),%eax
7bc: 50 push %eax
7bd: 8d 45 e0 lea -0x20(%ebp),%eax
7c0: 50 push %eax
7c1: 57 push %edi
7c2: 56 push %esi
7c3: e8 e8 fc ff ff call 4b0 <gettoken>
7c8: 83 c4 10 add $0x10,%esp
7cb: 85 c0 test %eax,%eax
7cd: 74 51 je 820 <parseexec+0xe0>
if(tok != 'a')
7cf: 83 f8 61 cmp $0x61,%eax
7d2: 75 6b jne 83f <parseexec+0xff>
cmd->argv[argc] = q;
7d4: 8b 45 e0 mov -0x20(%ebp),%eax
7d7: 8b 55 d0 mov -0x30(%ebp),%edx
7da: 89 44 9a 04 mov %eax,0x4(%edx,%ebx,4)
cmd->eargv[argc] = eq;
7de: 8b 45 e4 mov -0x1c(%ebp),%eax
7e1: 89 44 9a 2c mov %eax,0x2c(%edx,%ebx,4)
argc++;
7e5: 83 c3 01 add $0x1,%ebx
if(argc >= MAXARGS)
7e8: 83 fb 0a cmp $0xa,%ebx
7eb: 75 a3 jne 790 <parseexec+0x50>
panic("too many args");
7ed: 83 ec 0c sub $0xc,%esp
7f0: 68 b5 12 00 00 push $0x12b5
7f5: e8 66 f9 ff ff call 160 <panic>
7fa: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
return parseblock(ps, es);
800: 83 ec 08 sub $0x8,%esp
803: 57 push %edi
804: 56 push %esi
805: e8 66 01 00 00 call 970 <parseblock>
80a: 83 c4 10 add $0x10,%esp
80d: 89 45 d4 mov %eax,-0x2c(%ebp)
}
cmd->argv[argc] = 0;
cmd->eargv[argc] = 0;
return ret;
}
810: 8b 45 d4 mov -0x2c(%ebp),%eax
813: 8d 65 f4 lea -0xc(%ebp),%esp
816: 5b pop %ebx
817: 5e pop %esi
818: 5f pop %edi
819: 5d pop %ebp
81a: c3 ret
81b: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
81f: 90 nop
cmd->argv[argc] = 0;
820: 8b 45 d0 mov -0x30(%ebp),%eax
823: 8d 04 98 lea (%eax,%ebx,4),%eax
826: c7 40 04 00 00 00 00 movl $0x0,0x4(%eax)
cmd->eargv[argc] = 0;
82d: c7 40 2c 00 00 00 00 movl $0x0,0x2c(%eax)
}
834: 8b 45 d4 mov -0x2c(%ebp),%eax
837: 8d 65 f4 lea -0xc(%ebp),%esp
83a: 5b pop %ebx
83b: 5e pop %esi
83c: 5f pop %edi
83d: 5d pop %ebp
83e: c3 ret
panic("syntax");
83f: 83 ec 0c sub $0xc,%esp
842: 68 ae 12 00 00 push $0x12ae
847: e8 14 f9 ff ff call 160 <panic>
84c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
00000850 <parsepipe>:
{
850: f3 0f 1e fb endbr32
854: 55 push %ebp
855: 89 e5 mov %esp,%ebp
857: 57 push %edi
858: 56 push %esi
859: 53 push %ebx
85a: 83 ec 14 sub $0x14,%esp
85d: 8b 75 08 mov 0x8(%ebp),%esi
860: 8b 7d 0c mov 0xc(%ebp),%edi
cmd = parseexec(ps, es);
863: 57 push %edi
864: 56 push %esi
865: e8 d6 fe ff ff call 740 <parseexec>
if(peek(ps, es, "|")){
86a: 83 c4 0c add $0xc,%esp
86d: 68 c8 12 00 00 push $0x12c8
cmd = parseexec(ps, es);
872: 89 c3 mov %eax,%ebx
if(peek(ps, es, "|")){
874: 57 push %edi
875: 56 push %esi
876: e8 95 fd ff ff call 610 <peek>
87b: 83 c4 10 add $0x10,%esp
87e: 85 c0 test %eax,%eax
880: 75 0e jne 890 <parsepipe+0x40>
}
882: 8d 65 f4 lea -0xc(%ebp),%esp
885: 89 d8 mov %ebx,%eax
887: 5b pop %ebx
888: 5e pop %esi
889: 5f pop %edi
88a: 5d pop %ebp
88b: c3 ret
88c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
gettoken(ps, es, 0, 0);
890: 6a 00 push $0x0
892: 6a 00 push $0x0
894: 57 push %edi
895: 56 push %esi
896: e8 15 fc ff ff call 4b0 <gettoken>
cmd = pipecmd(cmd, parsepipe(ps, es));
89b: 58 pop %eax
89c: 5a pop %edx
89d: 57 push %edi
89e: 56 push %esi
89f: e8 ac ff ff ff call 850 <parsepipe>
8a4: 89 5d 08 mov %ebx,0x8(%ebp)
8a7: 83 c4 10 add $0x10,%esp
8aa: 89 45 0c mov %eax,0xc(%ebp)
}
8ad: 8d 65 f4 lea -0xc(%ebp),%esp
8b0: 5b pop %ebx
8b1: 5e pop %esi
8b2: 5f pop %edi
8b3: 5d pop %ebp
cmd = pipecmd(cmd, parsepipe(ps, es));
8b4: e9 37 fb ff ff jmp 3f0 <pipecmd>
8b9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
000008c0 <parseline>:
{
8c0: f3 0f 1e fb endbr32
8c4: 55 push %ebp
8c5: 89 e5 mov %esp,%ebp
8c7: 57 push %edi
8c8: 56 push %esi
8c9: 53 push %ebx
8ca: 83 ec 14 sub $0x14,%esp
8cd: 8b 75 08 mov 0x8(%ebp),%esi
8d0: 8b 7d 0c mov 0xc(%ebp),%edi
cmd = parsepipe(ps, es);
8d3: 57 push %edi
8d4: 56 push %esi
8d5: e8 76 ff ff ff call 850 <parsepipe>
while(peek(ps, es, "&")){
8da: 83 c4 10 add $0x10,%esp
cmd = parsepipe(ps, es);
8dd: 89 c3 mov %eax,%ebx
while(peek(ps, es, "&")){
8df: eb 1f jmp 900 <parseline+0x40>
8e1: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
gettoken(ps, es, 0, 0);
8e8: 6a 00 push $0x0
8ea: 6a 00 push $0x0
8ec: 57 push %edi
8ed: 56 push %esi
8ee: e8 bd fb ff ff call 4b0 <gettoken>
cmd = backcmd(cmd);
8f3: 89 1c 24 mov %ebx,(%esp)
8f6: e8 75 fb ff ff call 470 <backcmd>
8fb: 83 c4 10 add $0x10,%esp
8fe: 89 c3 mov %eax,%ebx
while(peek(ps, es, "&")){
900: 83 ec 04 sub $0x4,%esp
903: 68 ca 12 00 00 push $0x12ca
908: 57 push %edi
909: 56 push %esi
90a: e8 01 fd ff ff call 610 <peek>
90f: 83 c4 10 add $0x10,%esp
912: 85 c0 test %eax,%eax
914: 75 d2 jne 8e8 <parseline+0x28>
if(peek(ps, es, ";")){
916: 83 ec 04 sub $0x4,%esp
919: 68 c6 12 00 00 push $0x12c6
91e: 57 push %edi
91f: 56 push %esi
920: e8 eb fc ff ff call 610 <peek>
925: 83 c4 10 add $0x10,%esp
928: 85 c0 test %eax,%eax
92a: 75 14 jne 940 <parseline+0x80>
}
92c: 8d 65 f4 lea -0xc(%ebp),%esp
92f: 89 d8 mov %ebx,%eax
931: 5b pop %ebx
932: 5e pop %esi
933: 5f pop %edi
934: 5d pop %ebp
935: c3 ret
936: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
93d: 8d 76 00 lea 0x0(%esi),%esi
gettoken(ps, es, 0, 0);
940: 6a 00 push $0x0
942: 6a 00 push $0x0
944: 57 push %edi
945: 56 push %esi
946: e8 65 fb ff ff call 4b0 <gettoken>
cmd = listcmd(cmd, parseline(ps, es));
94b: 58 pop %eax
94c: 5a pop %edx
94d: 57 push %edi
94e: 56 push %esi
94f: e8 6c ff ff ff call 8c0 <parseline>
954: 89 5d 08 mov %ebx,0x8(%ebp)
957: 83 c4 10 add $0x10,%esp
95a: 89 45 0c mov %eax,0xc(%ebp)
}
95d: 8d 65 f4 lea -0xc(%ebp),%esp
960: 5b pop %ebx
961: 5e pop %esi
962: 5f pop %edi
963: 5d pop %ebp
cmd = listcmd(cmd, parseline(ps, es));
964: e9 c7 fa ff ff jmp 430 <listcmd>
969: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
00000970 <parseblock>:
{
970: f3 0f 1e fb endbr32
974: 55 push %ebp
975: 89 e5 mov %esp,%ebp
977: 57 push %edi
978: 56 push %esi
979: 53 push %ebx
97a: 83 ec 10 sub $0x10,%esp
97d: 8b 5d 08 mov 0x8(%ebp),%ebx
980: 8b 75 0c mov 0xc(%ebp),%esi
if(!peek(ps, es, "("))
983: 68 ac 12 00 00 push $0x12ac
988: 56 push %esi
989: 53 push %ebx
98a: e8 81 fc ff ff call 610 <peek>
98f: 83 c4 10 add $0x10,%esp
992: 85 c0 test %eax,%eax
994: 74 4a je 9e0 <parseblock+0x70>
gettoken(ps, es, 0, 0);
996: 6a 00 push $0x0
998: 6a 00 push $0x0
99a: 56 push %esi
99b: 53 push %ebx
99c: e8 0f fb ff ff call 4b0 <gettoken>
cmd = parseline(ps, es);
9a1: 58 pop %eax
9a2: 5a pop %edx
9a3: 56 push %esi
9a4: 53 push %ebx
9a5: e8 16 ff ff ff call 8c0 <parseline>
if(!peek(ps, es, ")"))
9aa: 83 c4 0c add $0xc,%esp
9ad: 68 e8 12 00 00 push $0x12e8
cmd = parseline(ps, es);
9b2: 89 c7 mov %eax,%edi
if(!peek(ps, es, ")"))
9b4: 56 push %esi
9b5: 53 push %ebx
9b6: e8 55 fc ff ff call 610 <peek>
9bb: 83 c4 10 add $0x10,%esp
9be: 85 c0 test %eax,%eax
9c0: 74 2b je 9ed <parseblock+0x7d>
gettoken(ps, es, 0, 0);
9c2: 6a 00 push $0x0
9c4: 6a 00 push $0x0
9c6: 56 push %esi
9c7: 53 push %ebx
9c8: e8 e3 fa ff ff call 4b0 <gettoken>
cmd = parseredirs(cmd, ps, es);
9cd: 83 c4 0c add $0xc,%esp
9d0: 56 push %esi
9d1: 53 push %ebx
9d2: 57 push %edi
9d3: e8 b8 fc ff ff call 690 <parseredirs>
}
9d8: 8d 65 f4 lea -0xc(%ebp),%esp
9db: 5b pop %ebx
9dc: 5e pop %esi
9dd: 5f pop %edi
9de: 5d pop %ebp
9df: c3 ret
panic("parseblock");
9e0: 83 ec 0c sub $0xc,%esp
9e3: 68 cc 12 00 00 push $0x12cc
9e8: e8 73 f7 ff ff call 160 <panic>
panic("syntax - missing )");
9ed: 83 ec 0c sub $0xc,%esp
9f0: 68 d7 12 00 00 push $0x12d7
9f5: e8 66 f7 ff ff call 160 <panic>
9fa: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
00000a00 <nulterminate>:
// NUL-terminate all the counted strings.
struct cmd*
nulterminate(struct cmd *cmd)
{
a00: f3 0f 1e fb endbr32
a04: 55 push %ebp
a05: 89 e5 mov %esp,%ebp
a07: 53 push %ebx
a08: 83 ec 04 sub $0x4,%esp
a0b: 8b 5d 08 mov 0x8(%ebp),%ebx
struct execcmd *ecmd;
struct listcmd *lcmd;
struct pipecmd *pcmd;
struct redircmd *rcmd;
if(cmd == 0)
a0e: 85 db test %ebx,%ebx
a10: 0f 84 9a 00 00 00 je ab0 <nulterminate+0xb0>
return 0;
switch(cmd->type){
a16: 83 3b 05 cmpl $0x5,(%ebx)
a19: 77 6d ja a88 <nulterminate+0x88>
a1b: 8b 03 mov (%ebx),%eax
a1d: 3e ff 24 85 28 13 00 notrack jmp *0x1328(,%eax,4)
a24: 00
a25: 8d 76 00 lea 0x0(%esi),%esi
nulterminate(pcmd->right);
break;
case LIST:
lcmd = (struct listcmd*)cmd;
nulterminate(lcmd->left);
a28: 83 ec 0c sub $0xc,%esp
a2b: ff 73 04 pushl 0x4(%ebx)
a2e: e8 cd ff ff ff call a00 <nulterminate>
nulterminate(lcmd->right);
a33: 58 pop %eax
a34: ff 73 08 pushl 0x8(%ebx)
a37: e8 c4 ff ff ff call a00 <nulterminate>
break;
a3c: 83 c4 10 add $0x10,%esp
a3f: 89 d8 mov %ebx,%eax
bcmd = (struct backcmd*)cmd;
nulterminate(bcmd->cmd);
break;
}
return cmd;
}
a41: 8b 5d fc mov -0x4(%ebp),%ebx
a44: c9 leave
a45: c3 ret
a46: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
a4d: 8d 76 00 lea 0x0(%esi),%esi
nulterminate(bcmd->cmd);
a50: 83 ec 0c sub $0xc,%esp
a53: ff 73 04 pushl 0x4(%ebx)
a56: e8 a5 ff ff ff call a00 <nulterminate>
break;
a5b: 89 d8 mov %ebx,%eax
a5d: 83 c4 10 add $0x10,%esp
}
a60: 8b 5d fc mov -0x4(%ebp),%ebx
a63: c9 leave
a64: c3 ret
a65: 8d 76 00 lea 0x0(%esi),%esi
for(i=0; ecmd->argv[i]; i++)
a68: 8b 4b 04 mov 0x4(%ebx),%ecx
a6b: 8d 43 08 lea 0x8(%ebx),%eax
a6e: 85 c9 test %ecx,%ecx
a70: 74 16 je a88 <nulterminate+0x88>
a72: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
*ecmd->eargv[i] = 0;
a78: 8b 50 24 mov 0x24(%eax),%edx
a7b: 83 c0 04 add $0x4,%eax
a7e: c6 02 00 movb $0x0,(%edx)
for(i=0; ecmd->argv[i]; i++)
a81: 8b 50 fc mov -0x4(%eax),%edx
a84: 85 d2 test %edx,%edx
a86: 75 f0 jne a78 <nulterminate+0x78>
switch(cmd->type){
a88: 89 d8 mov %ebx,%eax
}
a8a: 8b 5d fc mov -0x4(%ebp),%ebx
a8d: c9 leave
a8e: c3 ret
a8f: 90 nop
nulterminate(rcmd->cmd);
a90: 83 ec 0c sub $0xc,%esp
a93: ff 73 04 pushl 0x4(%ebx)
a96: e8 65 ff ff ff call a00 <nulterminate>
*rcmd->efile = 0;
a9b: 8b 43 0c mov 0xc(%ebx),%eax
break;
a9e: 83 c4 10 add $0x10,%esp
*rcmd->efile = 0;
aa1: c6 00 00 movb $0x0,(%eax)
break;
aa4: 89 d8 mov %ebx,%eax
}
aa6: 8b 5d fc mov -0x4(%ebp),%ebx
aa9: c9 leave
aaa: c3 ret
aab: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
aaf: 90 nop
return 0;
ab0: 31 c0 xor %eax,%eax
ab2: eb 8d jmp a41 <nulterminate+0x41>
ab4: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
abb: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
abf: 90 nop
00000ac0 <parsecmd>:
{
ac0: f3 0f 1e fb endbr32
ac4: 55 push %ebp
ac5: 89 e5 mov %esp,%ebp
ac7: 56 push %esi
ac8: 53 push %ebx
es = s + strlen(s);
ac9: 8b 5d 08 mov 0x8(%ebp),%ebx
acc: 83 ec 0c sub $0xc,%esp
acf: 53 push %ebx
ad0: e8 db 00 00 00 call bb0 <strlen>
cmd = parseline(&s, es);
ad5: 59 pop %ecx
ad6: 5e pop %esi
es = s + strlen(s);
ad7: 01 c3 add %eax,%ebx
cmd = parseline(&s, es);
ad9: 8d 45 08 lea 0x8(%ebp),%eax
adc: 53 push %ebx
add: 50 push %eax
ade: e8 dd fd ff ff call 8c0 <parseline>
peek(&s, es, "");
ae3: 83 c4 0c add $0xc,%esp
cmd = parseline(&s, es);
ae6: 89 c6 mov %eax,%esi
peek(&s, es, "");
ae8: 8d 45 08 lea 0x8(%ebp),%eax
aeb: 68 71 12 00 00 push $0x1271
af0: 53 push %ebx
af1: 50 push %eax
af2: e8 19 fb ff ff call 610 <peek>
if(s != es){
af7: 8b 45 08 mov 0x8(%ebp),%eax
afa: 83 c4 10 add $0x10,%esp
afd: 39 d8 cmp %ebx,%eax
aff: 75 12 jne b13 <parsecmd+0x53>
nulterminate(cmd);
b01: 83 ec 0c sub $0xc,%esp
b04: 56 push %esi
b05: e8 f6 fe ff ff call a00 <nulterminate>
}
b0a: 8d 65 f8 lea -0x8(%ebp),%esp
b0d: 89 f0 mov %esi,%eax
b0f: 5b pop %ebx
b10: 5e pop %esi
b11: 5d pop %ebp
b12: c3 ret
printf(2, "leftovers: %s\n", s);
b13: 52 push %edx
b14: 50 push %eax
b15: 68 ea 12 00 00 push $0x12ea
b1a: 6a 02 push $0x2
b1c: e8 cf 03 00 00 call ef0 <printf>
panic("syntax");
b21: c7 04 24 ae 12 00 00 movl $0x12ae,(%esp)
b28: e8 33 f6 ff ff call 160 <panic>
b2d: 66 90 xchg %ax,%ax
b2f: 90 nop
00000b30 <strcpy>:
#include "user.h"
#include "x86.h"
char*
strcpy(char *s, const char *t)
{
b30: f3 0f 1e fb endbr32
b34: 55 push %ebp
char *os;
os = s;
while((*s++ = *t++) != 0)
b35: 31 c0 xor %eax,%eax
{
b37: 89 e5 mov %esp,%ebp
b39: 53 push %ebx
b3a: 8b 4d 08 mov 0x8(%ebp),%ecx
b3d: 8b 5d 0c mov 0xc(%ebp),%ebx
while((*s++ = *t++) != 0)
b40: 0f b6 14 03 movzbl (%ebx,%eax,1),%edx
b44: 88 14 01 mov %dl,(%ecx,%eax,1)
b47: 83 c0 01 add $0x1,%eax
b4a: 84 d2 test %dl,%dl
b4c: 75 f2 jne b40 <strcpy+0x10>
;
return os;
}
b4e: 89 c8 mov %ecx,%eax
b50: 5b pop %ebx
b51: 5d pop %ebp
b52: c3 ret
b53: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
b5a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
00000b60 <strcmp>:
int
strcmp(const char *p, const char *q)
{
b60: f3 0f 1e fb endbr32
b64: 55 push %ebp
b65: 89 e5 mov %esp,%ebp
b67: 53 push %ebx
b68: 8b 4d 08 mov 0x8(%ebp),%ecx
b6b: 8b 55 0c mov 0xc(%ebp),%edx
while(*p && *p == *q)
b6e: 0f b6 01 movzbl (%ecx),%eax
b71: 0f b6 1a movzbl (%edx),%ebx
b74: 84 c0 test %al,%al
b76: 75 19 jne b91 <strcmp+0x31>
b78: eb 26 jmp ba0 <strcmp+0x40>
b7a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
b80: 0f b6 41 01 movzbl 0x1(%ecx),%eax
p++, q++;
b84: 83 c1 01 add $0x1,%ecx
b87: 83 c2 01 add $0x1,%edx
while(*p && *p == *q)
b8a: 0f b6 1a movzbl (%edx),%ebx
b8d: 84 c0 test %al,%al
b8f: 74 0f je ba0 <strcmp+0x40>
b91: 38 d8 cmp %bl,%al
b93: 74 eb je b80 <strcmp+0x20>
return (uchar)*p - (uchar)*q;
b95: 29 d8 sub %ebx,%eax
}
b97: 5b pop %ebx
b98: 5d pop %ebp
b99: c3 ret
b9a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
ba0: 31 c0 xor %eax,%eax
return (uchar)*p - (uchar)*q;
ba2: 29 d8 sub %ebx,%eax
}
ba4: 5b pop %ebx
ba5: 5d pop %ebp
ba6: c3 ret
ba7: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
bae: 66 90 xchg %ax,%ax
00000bb0 <strlen>:
uint
strlen(const char *s)
{
bb0: f3 0f 1e fb endbr32
bb4: 55 push %ebp
bb5: 89 e5 mov %esp,%ebp
bb7: 8b 55 08 mov 0x8(%ebp),%edx
int n;
for(n = 0; s[n]; n++)
bba: 80 3a 00 cmpb $0x0,(%edx)
bbd: 74 21 je be0 <strlen+0x30>
bbf: 31 c0 xor %eax,%eax
bc1: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
bc8: 83 c0 01 add $0x1,%eax
bcb: 80 3c 02 00 cmpb $0x0,(%edx,%eax,1)
bcf: 89 c1 mov %eax,%ecx
bd1: 75 f5 jne bc8 <strlen+0x18>
;
return n;
}
bd3: 89 c8 mov %ecx,%eax
bd5: 5d pop %ebp
bd6: c3 ret
bd7: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
bde: 66 90 xchg %ax,%ax
for(n = 0; s[n]; n++)
be0: 31 c9 xor %ecx,%ecx
}
be2: 5d pop %ebp
be3: 89 c8 mov %ecx,%eax
be5: c3 ret
be6: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
bed: 8d 76 00 lea 0x0(%esi),%esi
00000bf0 <memset>:
void*
memset(void *dst, int c, uint n)
{
bf0: f3 0f 1e fb endbr32
bf4: 55 push %ebp
bf5: 89 e5 mov %esp,%ebp
bf7: 57 push %edi
bf8: 8b 55 08 mov 0x8(%ebp),%edx
}
static inline void
stosb(void *addr, int data, int cnt)
{
asm volatile("cld; rep stosb" :
bfb: 8b 4d 10 mov 0x10(%ebp),%ecx
bfe: 8b 45 0c mov 0xc(%ebp),%eax
c01: 89 d7 mov %edx,%edi
c03: fc cld
c04: f3 aa rep stos %al,%es:(%edi)
stosb(dst, c, n);
return dst;
}
c06: 89 d0 mov %edx,%eax
c08: 5f pop %edi
c09: 5d pop %ebp
c0a: c3 ret
c0b: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
c0f: 90 nop
00000c10 <strchr>:
char*
strchr(const char *s, char c)
{
c10: f3 0f 1e fb endbr32
c14: 55 push %ebp
c15: 89 e5 mov %esp,%ebp
c17: 8b 45 08 mov 0x8(%ebp),%eax
c1a: 0f b6 4d 0c movzbl 0xc(%ebp),%ecx
for(; *s; s++)
c1e: 0f b6 10 movzbl (%eax),%edx
c21: 84 d2 test %dl,%dl
c23: 75 16 jne c3b <strchr+0x2b>
c25: eb 21 jmp c48 <strchr+0x38>
c27: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
c2e: 66 90 xchg %ax,%ax
c30: 0f b6 50 01 movzbl 0x1(%eax),%edx
c34: 83 c0 01 add $0x1,%eax
c37: 84 d2 test %dl,%dl
c39: 74 0d je c48 <strchr+0x38>
if(*s == c)
c3b: 38 d1 cmp %dl,%cl
c3d: 75 f1 jne c30 <strchr+0x20>
return (char*)s;
return 0;
}
c3f: 5d pop %ebp
c40: c3 ret
c41: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
return 0;
c48: 31 c0 xor %eax,%eax
}
c4a: 5d pop %ebp
c4b: c3 ret
c4c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
00000c50 <gets>:
char*
gets(char *buf, int max)
{
c50: f3 0f 1e fb endbr32
c54: 55 push %ebp
c55: 89 e5 mov %esp,%ebp
c57: 57 push %edi
c58: 56 push %esi
int i, cc;
char c;
for(i=0; i+1 < max; ){
c59: 31 f6 xor %esi,%esi
{
c5b: 53 push %ebx
c5c: 89 f3 mov %esi,%ebx
c5e: 83 ec 1c sub $0x1c,%esp
c61: 8b 7d 08 mov 0x8(%ebp),%edi
for(i=0; i+1 < max; ){
c64: eb 33 jmp c99 <gets+0x49>
c66: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
c6d: 8d 76 00 lea 0x0(%esi),%esi
cc = read(0, &c, 1);
c70: 83 ec 04 sub $0x4,%esp
c73: 8d 45 e7 lea -0x19(%ebp),%eax
c76: 6a 01 push $0x1
c78: 50 push %eax
c79: 6a 00 push $0x0
c7b: e8 2b 01 00 00 call dab <read>
if(cc < 1)
c80: 83 c4 10 add $0x10,%esp
c83: 85 c0 test %eax,%eax
c85: 7e 1c jle ca3 <gets+0x53>
break;
buf[i++] = c;
c87: 0f b6 45 e7 movzbl -0x19(%ebp),%eax
c8b: 83 c7 01 add $0x1,%edi
c8e: 88 47 ff mov %al,-0x1(%edi)
if(c == '\n' || c == '\r')
c91: 3c 0a cmp $0xa,%al
c93: 74 23 je cb8 <gets+0x68>
c95: 3c 0d cmp $0xd,%al
c97: 74 1f je cb8 <gets+0x68>
for(i=0; i+1 < max; ){
c99: 83 c3 01 add $0x1,%ebx
c9c: 89 fe mov %edi,%esi
c9e: 3b 5d 0c cmp 0xc(%ebp),%ebx
ca1: 7c cd jl c70 <gets+0x20>
ca3: 89 f3 mov %esi,%ebx
break;
}
buf[i] = '\0';
return buf;
}
ca5: 8b 45 08 mov 0x8(%ebp),%eax
buf[i] = '\0';
ca8: c6 03 00 movb $0x0,(%ebx)
}
cab: 8d 65 f4 lea -0xc(%ebp),%esp
cae: 5b pop %ebx
caf: 5e pop %esi
cb0: 5f pop %edi
cb1: 5d pop %ebp
cb2: c3 ret
cb3: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
cb7: 90 nop
cb8: 8b 75 08 mov 0x8(%ebp),%esi
cbb: 8b 45 08 mov 0x8(%ebp),%eax
cbe: 01 de add %ebx,%esi
cc0: 89 f3 mov %esi,%ebx
buf[i] = '\0';
cc2: c6 03 00 movb $0x0,(%ebx)
}
cc5: 8d 65 f4 lea -0xc(%ebp),%esp
cc8: 5b pop %ebx
cc9: 5e pop %esi
cca: 5f pop %edi
ccb: 5d pop %ebp
ccc: c3 ret
ccd: 8d 76 00 lea 0x0(%esi),%esi
00000cd0 <stat>:
int
stat(const char *n, struct stat *st)
{
cd0: f3 0f 1e fb endbr32
cd4: 55 push %ebp
cd5: 89 e5 mov %esp,%ebp
cd7: 56 push %esi
cd8: 53 push %ebx
int fd;
int r;
fd = open(n, O_RDONLY);
cd9: 83 ec 08 sub $0x8,%esp
cdc: 6a 00 push $0x0
cde: ff 75 08 pushl 0x8(%ebp)
ce1: e8 ed 00 00 00 call dd3 <open>
if(fd < 0)
ce6: 83 c4 10 add $0x10,%esp
ce9: 85 c0 test %eax,%eax
ceb: 78 2b js d18 <stat+0x48>
return -1;
r = fstat(fd, st);
ced: 83 ec 08 sub $0x8,%esp
cf0: ff 75 0c pushl 0xc(%ebp)
cf3: 89 c3 mov %eax,%ebx
cf5: 50 push %eax
cf6: e8 f0 00 00 00 call deb <fstat>
close(fd);
cfb: 89 1c 24 mov %ebx,(%esp)
r = fstat(fd, st);
cfe: 89 c6 mov %eax,%esi
close(fd);
d00: e8 b6 00 00 00 call dbb <close>
return r;
d05: 83 c4 10 add $0x10,%esp
}
d08: 8d 65 f8 lea -0x8(%ebp),%esp
d0b: 89 f0 mov %esi,%eax
d0d: 5b pop %ebx
d0e: 5e pop %esi
d0f: 5d pop %ebp
d10: c3 ret
d11: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
return -1;
d18: be ff ff ff ff mov $0xffffffff,%esi
d1d: eb e9 jmp d08 <stat+0x38>
d1f: 90 nop
00000d20 <atoi>:
int
atoi(const char *s)
{
d20: f3 0f 1e fb endbr32
d24: 55 push %ebp
d25: 89 e5 mov %esp,%ebp
d27: 53 push %ebx
d28: 8b 55 08 mov 0x8(%ebp),%edx
int n;
n = 0;
while('0' <= *s && *s <= '9')
d2b: 0f be 02 movsbl (%edx),%eax
d2e: 8d 48 d0 lea -0x30(%eax),%ecx
d31: 80 f9 09 cmp $0x9,%cl
n = 0;
d34: b9 00 00 00 00 mov $0x0,%ecx
while('0' <= *s && *s <= '9')
d39: 77 1a ja d55 <atoi+0x35>
d3b: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
d3f: 90 nop
n = n*10 + *s++ - '0';
d40: 83 c2 01 add $0x1,%edx
d43: 8d 0c 89 lea (%ecx,%ecx,4),%ecx
d46: 8d 4c 48 d0 lea -0x30(%eax,%ecx,2),%ecx
while('0' <= *s && *s <= '9')
d4a: 0f be 02 movsbl (%edx),%eax
d4d: 8d 58 d0 lea -0x30(%eax),%ebx
d50: 80 fb 09 cmp $0x9,%bl
d53: 76 eb jbe d40 <atoi+0x20>
return n;
}
d55: 89 c8 mov %ecx,%eax
d57: 5b pop %ebx
d58: 5d pop %ebp
d59: c3 ret
d5a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
00000d60 <memmove>:
void*
memmove(void *vdst, const void *vsrc, int n)
{
d60: f3 0f 1e fb endbr32
d64: 55 push %ebp
d65: 89 e5 mov %esp,%ebp
d67: 57 push %edi
d68: 8b 45 10 mov 0x10(%ebp),%eax
d6b: 8b 55 08 mov 0x8(%ebp),%edx
d6e: 56 push %esi
d6f: 8b 75 0c mov 0xc(%ebp),%esi
char *dst;
const char *src;
dst = vdst;
src = vsrc;
while(n-- > 0)
d72: 85 c0 test %eax,%eax
d74: 7e 0f jle d85 <memmove+0x25>
d76: 01 d0 add %edx,%eax
dst = vdst;
d78: 89 d7 mov %edx,%edi
d7a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
*dst++ = *src++;
d80: a4 movsb %ds:(%esi),%es:(%edi)
while(n-- > 0)
d81: 39 f8 cmp %edi,%eax
d83: 75 fb jne d80 <memmove+0x20>
return vdst;
}
d85: 5e pop %esi
d86: 89 d0 mov %edx,%eax
d88: 5f pop %edi
d89: 5d pop %ebp
d8a: c3 ret
00000d8b <fork>:
name: \
movl $SYS_ ## name, %eax; \
int $T_SYSCALL; \
ret
SYSCALL(fork)
d8b: b8 01 00 00 00 mov $0x1,%eax
d90: cd 40 int $0x40
d92: c3 ret
00000d93 <exit>:
SYSCALL(exit)
d93: b8 02 00 00 00 mov $0x2,%eax
d98: cd 40 int $0x40
d9a: c3 ret
00000d9b <wait>:
SYSCALL(wait)
d9b: b8 03 00 00 00 mov $0x3,%eax
da0: cd 40 int $0x40
da2: c3 ret
00000da3 <pipe>:
SYSCALL(pipe)
da3: b8 04 00 00 00 mov $0x4,%eax
da8: cd 40 int $0x40
daa: c3 ret
00000dab <read>:
SYSCALL(read)
dab: b8 05 00 00 00 mov $0x5,%eax
db0: cd 40 int $0x40
db2: c3 ret
00000db3 <write>:
SYSCALL(write)
db3: b8 10 00 00 00 mov $0x10,%eax
db8: cd 40 int $0x40
dba: c3 ret
00000dbb <close>:
SYSCALL(close)
dbb: b8 15 00 00 00 mov $0x15,%eax
dc0: cd 40 int $0x40
dc2: c3 ret
00000dc3 <kill>:
SYSCALL(kill)
dc3: b8 06 00 00 00 mov $0x6,%eax
dc8: cd 40 int $0x40
dca: c3 ret
00000dcb <exec>:
SYSCALL(exec)
dcb: b8 07 00 00 00 mov $0x7,%eax
dd0: cd 40 int $0x40
dd2: c3 ret
00000dd3 <open>:
SYSCALL(open)
dd3: b8 0f 00 00 00 mov $0xf,%eax
dd8: cd 40 int $0x40
dda: c3 ret
00000ddb <mknod>:
SYSCALL(mknod)
ddb: b8 11 00 00 00 mov $0x11,%eax
de0: cd 40 int $0x40
de2: c3 ret
00000de3 <unlink>:
SYSCALL(unlink)
de3: b8 12 00 00 00 mov $0x12,%eax
de8: cd 40 int $0x40
dea: c3 ret
00000deb <fstat>:
SYSCALL(fstat)
deb: b8 08 00 00 00 mov $0x8,%eax
df0: cd 40 int $0x40
df2: c3 ret
00000df3 <link>:
SYSCALL(link)
df3: b8 13 00 00 00 mov $0x13,%eax
df8: cd 40 int $0x40
dfa: c3 ret
00000dfb <mkdir>:
SYSCALL(mkdir)
dfb: b8 14 00 00 00 mov $0x14,%eax
e00: cd 40 int $0x40
e02: c3 ret
00000e03 <chdir>:
SYSCALL(chdir)
e03: b8 09 00 00 00 mov $0x9,%eax
e08: cd 40 int $0x40
e0a: c3 ret
00000e0b <dup>:
SYSCALL(dup)
e0b: b8 0a 00 00 00 mov $0xa,%eax
e10: cd 40 int $0x40
e12: c3 ret
00000e13 <getpid>:
SYSCALL(getpid)
e13: b8 0b 00 00 00 mov $0xb,%eax
e18: cd 40 int $0x40
e1a: c3 ret
00000e1b <sbrk>:
SYSCALL(sbrk)
e1b: b8 0c 00 00 00 mov $0xc,%eax
e20: cd 40 int $0x40
e22: c3 ret
00000e23 <sleep>:
SYSCALL(sleep)
e23: b8 0d 00 00 00 mov $0xd,%eax
e28: cd 40 int $0x40
e2a: c3 ret
00000e2b <uptime>:
SYSCALL(uptime)
e2b: b8 0e 00 00 00 mov $0xe,%eax
e30: cd 40 int $0x40
e32: c3 ret
00000e33 <date>:
e33: b8 16 00 00 00 mov $0x16,%eax
e38: cd 40 int $0x40
e3a: c3 ret
e3b: 66 90 xchg %ax,%ax
e3d: 66 90 xchg %ax,%ax
e3f: 90 nop
00000e40 <printint>:
write(fd, &c, 1);
}
static void
printint(int fd, int xx, int base, int sgn)
{
e40: 55 push %ebp
e41: 89 e5 mov %esp,%ebp
e43: 57 push %edi
e44: 56 push %esi
e45: 53 push %ebx
e46: 83 ec 3c sub $0x3c,%esp
e49: 89 4d c4 mov %ecx,-0x3c(%ebp)
uint x;
neg = 0;
if(sgn && xx < 0){
neg = 1;
x = -xx;
e4c: 89 d1 mov %edx,%ecx
{
e4e: 89 45 b8 mov %eax,-0x48(%ebp)
if(sgn && xx < 0){
e51: 85 d2 test %edx,%edx
e53: 0f 89 7f 00 00 00 jns ed8 <printint+0x98>
e59: f6 45 08 01 testb $0x1,0x8(%ebp)
e5d: 74 79 je ed8 <printint+0x98>
neg = 1;
e5f: c7 45 bc 01 00 00 00 movl $0x1,-0x44(%ebp)
x = -xx;
e66: f7 d9 neg %ecx
} else {
x = xx;
}
i = 0;
e68: 31 db xor %ebx,%ebx
e6a: 8d 75 d7 lea -0x29(%ebp),%esi
e6d: 8d 76 00 lea 0x0(%esi),%esi
do{
buf[i++] = digits[x % base];
e70: 89 c8 mov %ecx,%eax
e72: 31 d2 xor %edx,%edx
e74: 89 cf mov %ecx,%edi
e76: f7 75 c4 divl -0x3c(%ebp)
e79: 0f b6 92 48 13 00 00 movzbl 0x1348(%edx),%edx
e80: 89 45 c0 mov %eax,-0x40(%ebp)
e83: 89 d8 mov %ebx,%eax
e85: 8d 5b 01 lea 0x1(%ebx),%ebx
}while((x /= base) != 0);
e88: 8b 4d c0 mov -0x40(%ebp),%ecx
buf[i++] = digits[x % base];
e8b: 88 14 1e mov %dl,(%esi,%ebx,1)
}while((x /= base) != 0);
e8e: 39 7d c4 cmp %edi,-0x3c(%ebp)
e91: 76 dd jbe e70 <printint+0x30>
if(neg)
e93: 8b 4d bc mov -0x44(%ebp),%ecx
e96: 85 c9 test %ecx,%ecx
e98: 74 0c je ea6 <printint+0x66>
buf[i++] = '-';
e9a: c6 44 1d d8 2d movb $0x2d,-0x28(%ebp,%ebx,1)
buf[i++] = digits[x % base];
e9f: 89 d8 mov %ebx,%eax
buf[i++] = '-';
ea1: ba 2d 00 00 00 mov $0x2d,%edx
while(--i >= 0)
ea6: 8b 7d b8 mov -0x48(%ebp),%edi
ea9: 8d 5c 05 d7 lea -0x29(%ebp,%eax,1),%ebx
ead: eb 07 jmp eb6 <printint+0x76>
eaf: 90 nop
eb0: 0f b6 13 movzbl (%ebx),%edx
eb3: 83 eb 01 sub $0x1,%ebx
write(fd, &c, 1);
eb6: 83 ec 04 sub $0x4,%esp
eb9: 88 55 d7 mov %dl,-0x29(%ebp)
ebc: 6a 01 push $0x1
ebe: 56 push %esi
ebf: 57 push %edi
ec0: e8 ee fe ff ff call db3 <write>
while(--i >= 0)
ec5: 83 c4 10 add $0x10,%esp
ec8: 39 de cmp %ebx,%esi
eca: 75 e4 jne eb0 <printint+0x70>
putc(fd, buf[i]);
}
ecc: 8d 65 f4 lea -0xc(%ebp),%esp
ecf: 5b pop %ebx
ed0: 5e pop %esi
ed1: 5f pop %edi
ed2: 5d pop %ebp
ed3: c3 ret
ed4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
neg = 0;
ed8: c7 45 bc 00 00 00 00 movl $0x0,-0x44(%ebp)
edf: eb 87 jmp e68 <printint+0x28>
ee1: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
ee8: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
eef: 90 nop
00000ef0 <printf>:
// Print to the given fd. Only understands %d, %x, %p, %s.
void
printf(int fd, const char *fmt, ...)
{
ef0: f3 0f 1e fb endbr32
ef4: 55 push %ebp
ef5: 89 e5 mov %esp,%ebp
ef7: 57 push %edi
ef8: 56 push %esi
ef9: 53 push %ebx
efa: 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++){
efd: 8b 75 0c mov 0xc(%ebp),%esi
f00: 0f b6 1e movzbl (%esi),%ebx
f03: 84 db test %bl,%bl
f05: 0f 84 b4 00 00 00 je fbf <printf+0xcf>
ap = (uint*)(void*)&fmt + 1;
f0b: 8d 45 10 lea 0x10(%ebp),%eax
f0e: 83 c6 01 add $0x1,%esi
write(fd, &c, 1);
f11: 8d 7d e7 lea -0x19(%ebp),%edi
state = 0;
f14: 31 d2 xor %edx,%edx
ap = (uint*)(void*)&fmt + 1;
f16: 89 45 d0 mov %eax,-0x30(%ebp)
f19: eb 33 jmp f4e <printf+0x5e>
f1b: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
f1f: 90 nop
f20: 89 55 d4 mov %edx,-0x2c(%ebp)
c = fmt[i] & 0xff;
if(state == 0){
if(c == '%'){
state = '%';
f23: ba 25 00 00 00 mov $0x25,%edx
if(c == '%'){
f28: 83 f8 25 cmp $0x25,%eax
f2b: 74 17 je f44 <printf+0x54>
write(fd, &c, 1);
f2d: 83 ec 04 sub $0x4,%esp
f30: 88 5d e7 mov %bl,-0x19(%ebp)
f33: 6a 01 push $0x1
f35: 57 push %edi
f36: ff 75 08 pushl 0x8(%ebp)
f39: e8 75 fe ff ff call db3 <write>
f3e: 8b 55 d4 mov -0x2c(%ebp),%edx
} else {
putc(fd, c);
f41: 83 c4 10 add $0x10,%esp
for(i = 0; fmt[i]; i++){
f44: 0f b6 1e movzbl (%esi),%ebx
f47: 83 c6 01 add $0x1,%esi
f4a: 84 db test %bl,%bl
f4c: 74 71 je fbf <printf+0xcf>
c = fmt[i] & 0xff;
f4e: 0f be cb movsbl %bl,%ecx
f51: 0f b6 c3 movzbl %bl,%eax
if(state == 0){
f54: 85 d2 test %edx,%edx
f56: 74 c8 je f20 <printf+0x30>
}
} else if(state == '%'){
f58: 83 fa 25 cmp $0x25,%edx
f5b: 75 e7 jne f44 <printf+0x54>
if(c == 'd'){
f5d: 83 f8 64 cmp $0x64,%eax
f60: 0f 84 9a 00 00 00 je 1000 <printf+0x110>
printint(fd, *ap, 10, 1);
ap++;
} else if(c == 'x' || c == 'p'){
f66: 81 e1 f7 00 00 00 and $0xf7,%ecx
f6c: 83 f9 70 cmp $0x70,%ecx
f6f: 74 5f je fd0 <printf+0xe0>
printint(fd, *ap, 16, 0);
ap++;
} else if(c == 's'){
f71: 83 f8 73 cmp $0x73,%eax
f74: 0f 84 d6 00 00 00 je 1050 <printf+0x160>
s = "(null)";
while(*s != 0){
putc(fd, *s);
s++;
}
} else if(c == 'c'){
f7a: 83 f8 63 cmp $0x63,%eax
f7d: 0f 84 8d 00 00 00 je 1010 <printf+0x120>
putc(fd, *ap);
ap++;
} else if(c == '%'){
f83: 83 f8 25 cmp $0x25,%eax
f86: 0f 84 b4 00 00 00 je 1040 <printf+0x150>
write(fd, &c, 1);
f8c: 83 ec 04 sub $0x4,%esp
f8f: c6 45 e7 25 movb $0x25,-0x19(%ebp)
f93: 6a 01 push $0x1
f95: 57 push %edi
f96: ff 75 08 pushl 0x8(%ebp)
f99: e8 15 fe ff ff call db3 <write>
putc(fd, c);
} else {
// Unknown % sequence. Print it to draw attention.
putc(fd, '%');
putc(fd, c);
f9e: 88 5d e7 mov %bl,-0x19(%ebp)
write(fd, &c, 1);
fa1: 83 c4 0c add $0xc,%esp
fa4: 6a 01 push $0x1
fa6: 83 c6 01 add $0x1,%esi
fa9: 57 push %edi
faa: ff 75 08 pushl 0x8(%ebp)
fad: e8 01 fe ff ff call db3 <write>
for(i = 0; fmt[i]; i++){
fb2: 0f b6 5e ff movzbl -0x1(%esi),%ebx
putc(fd, c);
fb6: 83 c4 10 add $0x10,%esp
}
state = 0;
fb9: 31 d2 xor %edx,%edx
for(i = 0; fmt[i]; i++){
fbb: 84 db test %bl,%bl
fbd: 75 8f jne f4e <printf+0x5e>
}
}
}
fbf: 8d 65 f4 lea -0xc(%ebp),%esp
fc2: 5b pop %ebx
fc3: 5e pop %esi
fc4: 5f pop %edi
fc5: 5d pop %ebp
fc6: c3 ret
fc7: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
fce: 66 90 xchg %ax,%ax
printint(fd, *ap, 16, 0);
fd0: 83 ec 0c sub $0xc,%esp
fd3: b9 10 00 00 00 mov $0x10,%ecx
fd8: 6a 00 push $0x0
fda: 8b 5d d0 mov -0x30(%ebp),%ebx
fdd: 8b 45 08 mov 0x8(%ebp),%eax
fe0: 8b 13 mov (%ebx),%edx
fe2: e8 59 fe ff ff call e40 <printint>
ap++;
fe7: 89 d8 mov %ebx,%eax
fe9: 83 c4 10 add $0x10,%esp
state = 0;
fec: 31 d2 xor %edx,%edx
ap++;
fee: 83 c0 04 add $0x4,%eax
ff1: 89 45 d0 mov %eax,-0x30(%ebp)
ff4: e9 4b ff ff ff jmp f44 <printf+0x54>
ff9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
printint(fd, *ap, 10, 1);
1000: 83 ec 0c sub $0xc,%esp
1003: b9 0a 00 00 00 mov $0xa,%ecx
1008: 6a 01 push $0x1
100a: eb ce jmp fda <printf+0xea>
100c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
putc(fd, *ap);
1010: 8b 5d d0 mov -0x30(%ebp),%ebx
write(fd, &c, 1);
1013: 83 ec 04 sub $0x4,%esp
putc(fd, *ap);
1016: 8b 03 mov (%ebx),%eax
write(fd, &c, 1);
1018: 6a 01 push $0x1
ap++;
101a: 83 c3 04 add $0x4,%ebx
write(fd, &c, 1);
101d: 57 push %edi
101e: ff 75 08 pushl 0x8(%ebp)
putc(fd, *ap);
1021: 88 45 e7 mov %al,-0x19(%ebp)
write(fd, &c, 1);
1024: e8 8a fd ff ff call db3 <write>
ap++;
1029: 89 5d d0 mov %ebx,-0x30(%ebp)
102c: 83 c4 10 add $0x10,%esp
state = 0;
102f: 31 d2 xor %edx,%edx
1031: e9 0e ff ff ff jmp f44 <printf+0x54>
1036: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
103d: 8d 76 00 lea 0x0(%esi),%esi
putc(fd, c);
1040: 88 5d e7 mov %bl,-0x19(%ebp)
write(fd, &c, 1);
1043: 83 ec 04 sub $0x4,%esp
1046: e9 59 ff ff ff jmp fa4 <printf+0xb4>
104b: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
104f: 90 nop
s = (char*)*ap;
1050: 8b 45 d0 mov -0x30(%ebp),%eax
1053: 8b 18 mov (%eax),%ebx
ap++;
1055: 83 c0 04 add $0x4,%eax
1058: 89 45 d0 mov %eax,-0x30(%ebp)
if(s == 0)
105b: 85 db test %ebx,%ebx
105d: 74 17 je 1076 <printf+0x186>
while(*s != 0){
105f: 0f b6 03 movzbl (%ebx),%eax
state = 0;
1062: 31 d2 xor %edx,%edx
while(*s != 0){
1064: 84 c0 test %al,%al
1066: 0f 84 d8 fe ff ff je f44 <printf+0x54>
106c: 89 75 d4 mov %esi,-0x2c(%ebp)
106f: 89 de mov %ebx,%esi
1071: 8b 5d 08 mov 0x8(%ebp),%ebx
1074: eb 1a jmp 1090 <printf+0x1a0>
s = "(null)";
1076: bb 40 13 00 00 mov $0x1340,%ebx
while(*s != 0){
107b: 89 75 d4 mov %esi,-0x2c(%ebp)
107e: b8 28 00 00 00 mov $0x28,%eax
1083: 89 de mov %ebx,%esi
1085: 8b 5d 08 mov 0x8(%ebp),%ebx
1088: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
108f: 90 nop
write(fd, &c, 1);
1090: 83 ec 04 sub $0x4,%esp
s++;
1093: 83 c6 01 add $0x1,%esi
1096: 88 45 e7 mov %al,-0x19(%ebp)
write(fd, &c, 1);
1099: 6a 01 push $0x1
109b: 57 push %edi
109c: 53 push %ebx
109d: e8 11 fd ff ff call db3 <write>
while(*s != 0){
10a2: 0f b6 06 movzbl (%esi),%eax
10a5: 83 c4 10 add $0x10,%esp
10a8: 84 c0 test %al,%al
10aa: 75 e4 jne 1090 <printf+0x1a0>
10ac: 8b 75 d4 mov -0x2c(%ebp),%esi
state = 0;
10af: 31 d2 xor %edx,%edx
10b1: e9 8e fe ff ff jmp f44 <printf+0x54>
10b6: 66 90 xchg %ax,%ax
10b8: 66 90 xchg %ax,%ax
10ba: 66 90 xchg %ax,%ax
10bc: 66 90 xchg %ax,%ax
10be: 66 90 xchg %ax,%ax
000010c0 <free>:
static Header base;
static Header *freep;
void
free(void *ap)
{
10c0: f3 0f 1e fb endbr32
10c4: 55 push %ebp
Header *bp, *p;
bp = (Header*)ap - 1;
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
10c5: a1 a4 19 00 00 mov 0x19a4,%eax
{
10ca: 89 e5 mov %esp,%ebp
10cc: 57 push %edi
10cd: 56 push %esi
10ce: 53 push %ebx
10cf: 8b 5d 08 mov 0x8(%ebp),%ebx
10d2: 8b 10 mov (%eax),%edx
bp = (Header*)ap - 1;
10d4: 8d 4b f8 lea -0x8(%ebx),%ecx
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
10d7: 39 c8 cmp %ecx,%eax
10d9: 73 15 jae 10f0 <free+0x30>
10db: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
10df: 90 nop
10e0: 39 d1 cmp %edx,%ecx
10e2: 72 14 jb 10f8 <free+0x38>
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
10e4: 39 d0 cmp %edx,%eax
10e6: 73 10 jae 10f8 <free+0x38>
{
10e8: 89 d0 mov %edx,%eax
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
10ea: 8b 10 mov (%eax),%edx
10ec: 39 c8 cmp %ecx,%eax
10ee: 72 f0 jb 10e0 <free+0x20>
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
10f0: 39 d0 cmp %edx,%eax
10f2: 72 f4 jb 10e8 <free+0x28>
10f4: 39 d1 cmp %edx,%ecx
10f6: 73 f0 jae 10e8 <free+0x28>
break;
if(bp + bp->s.size == p->s.ptr){
10f8: 8b 73 fc mov -0x4(%ebx),%esi
10fb: 8d 3c f1 lea (%ecx,%esi,8),%edi
10fe: 39 fa cmp %edi,%edx
1100: 74 1e je 1120 <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;
1102: 89 53 f8 mov %edx,-0x8(%ebx)
if(p + p->s.size == bp){
1105: 8b 50 04 mov 0x4(%eax),%edx
1108: 8d 34 d0 lea (%eax,%edx,8),%esi
110b: 39 f1 cmp %esi,%ecx
110d: 74 28 je 1137 <free+0x77>
p->s.size += bp->s.size;
p->s.ptr = bp->s.ptr;
} else
p->s.ptr = bp;
110f: 89 08 mov %ecx,(%eax)
freep = p;
}
1111: 5b pop %ebx
freep = p;
1112: a3 a4 19 00 00 mov %eax,0x19a4
}
1117: 5e pop %esi
1118: 5f pop %edi
1119: 5d pop %ebp
111a: c3 ret
111b: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
111f: 90 nop
bp->s.size += p->s.ptr->s.size;
1120: 03 72 04 add 0x4(%edx),%esi
1123: 89 73 fc mov %esi,-0x4(%ebx)
bp->s.ptr = p->s.ptr->s.ptr;
1126: 8b 10 mov (%eax),%edx
1128: 8b 12 mov (%edx),%edx
112a: 89 53 f8 mov %edx,-0x8(%ebx)
if(p + p->s.size == bp){
112d: 8b 50 04 mov 0x4(%eax),%edx
1130: 8d 34 d0 lea (%eax,%edx,8),%esi
1133: 39 f1 cmp %esi,%ecx
1135: 75 d8 jne 110f <free+0x4f>
p->s.size += bp->s.size;
1137: 03 53 fc add -0x4(%ebx),%edx
freep = p;
113a: a3 a4 19 00 00 mov %eax,0x19a4
p->s.size += bp->s.size;
113f: 89 50 04 mov %edx,0x4(%eax)
p->s.ptr = bp->s.ptr;
1142: 8b 53 f8 mov -0x8(%ebx),%edx
1145: 89 10 mov %edx,(%eax)
}
1147: 5b pop %ebx
1148: 5e pop %esi
1149: 5f pop %edi
114a: 5d pop %ebp
114b: c3 ret
114c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
00001150 <malloc>:
return freep;
}
void*
malloc(uint nbytes)
{
1150: f3 0f 1e fb endbr32
1154: 55 push %ebp
1155: 89 e5 mov %esp,%ebp
1157: 57 push %edi
1158: 56 push %esi
1159: 53 push %ebx
115a: 83 ec 1c sub $0x1c,%esp
Header *p, *prevp;
uint nunits;
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
115d: 8b 45 08 mov 0x8(%ebp),%eax
if((prevp = freep) == 0){
1160: 8b 3d a4 19 00 00 mov 0x19a4,%edi
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
1166: 8d 70 07 lea 0x7(%eax),%esi
1169: c1 ee 03 shr $0x3,%esi
116c: 83 c6 01 add $0x1,%esi
if((prevp = freep) == 0){
116f: 85 ff test %edi,%edi
1171: 0f 84 a9 00 00 00 je 1220 <malloc+0xd0>
base.s.ptr = freep = prevp = &base;
base.s.size = 0;
}
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
1177: 8b 07 mov (%edi),%eax
if(p->s.size >= nunits){
1179: 8b 48 04 mov 0x4(%eax),%ecx
117c: 39 f1 cmp %esi,%ecx
117e: 73 6d jae 11ed <malloc+0x9d>
1180: 81 fe 00 10 00 00 cmp $0x1000,%esi
1186: bb 00 10 00 00 mov $0x1000,%ebx
118b: 0f 43 de cmovae %esi,%ebx
p = sbrk(nu * sizeof(Header));
118e: 8d 0c dd 00 00 00 00 lea 0x0(,%ebx,8),%ecx
1195: 89 4d e4 mov %ecx,-0x1c(%ebp)
1198: eb 17 jmp 11b1 <malloc+0x61>
119a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
11a0: 8b 10 mov (%eax),%edx
if(p->s.size >= nunits){
11a2: 8b 4a 04 mov 0x4(%edx),%ecx
11a5: 39 f1 cmp %esi,%ecx
11a7: 73 4f jae 11f8 <malloc+0xa8>
11a9: 8b 3d a4 19 00 00 mov 0x19a4,%edi
11af: 89 d0 mov %edx,%eax
p->s.size = nunits;
}
freep = prevp;
return (void*)(p + 1);
}
if(p == freep)
11b1: 39 c7 cmp %eax,%edi
11b3: 75 eb jne 11a0 <malloc+0x50>
p = sbrk(nu * sizeof(Header));
11b5: 83 ec 0c sub $0xc,%esp
11b8: ff 75 e4 pushl -0x1c(%ebp)
11bb: e8 5b fc ff ff call e1b <sbrk>
if(p == (char*)-1)
11c0: 83 c4 10 add $0x10,%esp
11c3: 83 f8 ff cmp $0xffffffff,%eax
11c6: 74 1b je 11e3 <malloc+0x93>
hp->s.size = nu;
11c8: 89 58 04 mov %ebx,0x4(%eax)
free((void*)(hp + 1));
11cb: 83 ec 0c sub $0xc,%esp
11ce: 83 c0 08 add $0x8,%eax
11d1: 50 push %eax
11d2: e8 e9 fe ff ff call 10c0 <free>
return freep;
11d7: a1 a4 19 00 00 mov 0x19a4,%eax
if((p = morecore(nunits)) == 0)
11dc: 83 c4 10 add $0x10,%esp
11df: 85 c0 test %eax,%eax
11e1: 75 bd jne 11a0 <malloc+0x50>
return 0;
}
}
11e3: 8d 65 f4 lea -0xc(%ebp),%esp
return 0;
11e6: 31 c0 xor %eax,%eax
}
11e8: 5b pop %ebx
11e9: 5e pop %esi
11ea: 5f pop %edi
11eb: 5d pop %ebp
11ec: c3 ret
if(p->s.size >= nunits){
11ed: 89 c2 mov %eax,%edx
11ef: 89 f8 mov %edi,%eax
11f1: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
if(p->s.size == nunits)
11f8: 39 ce cmp %ecx,%esi
11fa: 74 54 je 1250 <malloc+0x100>
p->s.size -= nunits;
11fc: 29 f1 sub %esi,%ecx
11fe: 89 4a 04 mov %ecx,0x4(%edx)
p += p->s.size;
1201: 8d 14 ca lea (%edx,%ecx,8),%edx
p->s.size = nunits;
1204: 89 72 04 mov %esi,0x4(%edx)
freep = prevp;
1207: a3 a4 19 00 00 mov %eax,0x19a4
}
120c: 8d 65 f4 lea -0xc(%ebp),%esp
return (void*)(p + 1);
120f: 8d 42 08 lea 0x8(%edx),%eax
}
1212: 5b pop %ebx
1213: 5e pop %esi
1214: 5f pop %edi
1215: 5d pop %ebp
1216: c3 ret
1217: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
121e: 66 90 xchg %ax,%ax
base.s.ptr = freep = prevp = &base;
1220: c7 05 a4 19 00 00 a8 movl $0x19a8,0x19a4
1227: 19 00 00
base.s.size = 0;
122a: bf a8 19 00 00 mov $0x19a8,%edi
base.s.ptr = freep = prevp = &base;
122f: c7 05 a8 19 00 00 a8 movl $0x19a8,0x19a8
1236: 19 00 00
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
1239: 89 f8 mov %edi,%eax
base.s.size = 0;
123b: c7 05 ac 19 00 00 00 movl $0x0,0x19ac
1242: 00 00 00
if(p->s.size >= nunits){
1245: e9 36 ff ff ff jmp 1180 <malloc+0x30>
124a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
prevp->s.ptr = p->s.ptr;
1250: 8b 0a mov (%edx),%ecx
1252: 89 08 mov %ecx,(%eax)
1254: eb b1 jmp 1207 <malloc+0xb7>
|
SECTION code_fp_am9511
PUBLIC cam32_sccz80_atan2
EXTERN cam32_sccz80_switch_arg
EXTERN _am9511_atan2
.cam32_sccz80_atan2
call cam32_sccz80_switch_arg
jp _am9511_atan2
|
; A006043: A traffic light problem: expansion of 2/(1 - 3*x)^3.
; 2,18,108,540,2430,10206,40824,157464,590490,2165130,7794468,27634932,96722262,334807830,1147912560,3902902704,13172296626,44165935746,147219785820,488149816140,1610894393262,5292938720718,17322344904168,56485907296200,183579198712650,594796603828986,1921650566216724,6191985157809444
mov $1,$0
mov $2,$0
add $2,2
mov $0,$2
bin $0,$1
mov $3,3
pow $3,$1
mul $0,$3
mov $1,$0
sub $1,1
mul $1,2
add $1,2
|
#pragma once
#include "../Animation/AnimationMixer.hpp"
namespace ln {
class SkinnedMeshModel;
/** スキンメッシュアニメーションにおいてキャラクターの挙動を操作するためのクラスです。 */
LN_CLASS()
class AnimationController
: public Object
, public detail::IAnimationMixerCoreHolder {
LN_OBJECT;
public:
/** アニメーションクリップを追加します。 (レイヤー0 へ追加されます) */
LN_METHOD()
AnimationState* addClip(AnimationClip* animationClip) { return m_core->addClip(animationClip); }
/** ステート名を指定してアニメーションクリップを追加します。 (レイヤー0 へ追加されます) */
AnimationState* addClip(const StringView& stateName, AnimationClip* animationClip) { m_core->addClip(stateName, animationClip); }
/** アニメーションクリップを除外します。 (レイヤー0 から除外されます) */
void removeClip(AnimationClip* animationClip) { m_core->removeClip(animationClip); }
/// 再生中であるかを確認する
//bool isPlaying() const;
/// 再生
void play(const StringView& stateName, float duration = 0.3f/*, PlayMode mode = PlayMode_StopSameLayer*/) { m_core->play(stateName, duration); }
/** play */
LN_METHOD()
void play(AnimationState* state, float duration = 0.3f/*, PlayMode mode = PlayMode_StopSameLayer*/) { m_core->play(state, duration); }
///// ブレンド (アニメーションの再生には影響しない。停止中のアニメーションがこの関数によって再生開始されることはない)
//void Blend(const lnKeyChar* animName, lnFloat targetWeight, lnFloat fadeLength);
///// クロスフェード
//void CrossFade(const lnKeyChar* animName, lnFloat fadeLength, PlayMode mode = StopSameLayer);
///// 前のアニメーションが終了した後、再生を開始する
//void PlayQueued(const lnKeyChar* animName, QueueMode queueMode = CompleteOthers, PlayMode playMode = StopSameLayer);
///// 前のアニメーションが終了するとき、クロスフェードで再生を開始する
//void CrossFadeQueued(const lnKeyChar* animName, lnFloat fadeLength, QueueMode queueMode = CompleteOthers, PlayMode playMode = StopSameLayer);
///// 同レイヤー内のアニメーション再生速度の同期
//void SyncLayer(int layer);
const Ref<AnimationMixerCore>& core() const { return m_core; }
public:
void advanceTime(float elapsedTime);
///// AnimationTargetEntity の検索 (見つからなければ NULL)
//detail::AnimationTargetAttributeEntity* findAnimationTargetAttributeEntity(const String& name);
LN_CONSTRUCT_ACCESS:
AnimationController();
bool init();
bool init(SkinnedMeshModel* model);
protected:
detail::AnimationTargetElementBlendLink* onRequireBinidng(const AnimationTrackTargetKey& key) override;
void onUpdateTargetElement(const detail::AnimationTargetElementBlendLink* binding) override;
private:
SkinnedMeshModel* m_model;
Ref<AnimationMixerCore> m_core;
List<Ref<detail::AnimationTargetElementBlendLink>> m_bindings;
};
} // namespace ln
|
; A077953: Expansion of 1/(1-x+2*x^2-2*x^3).
; 1,1,-1,-1,3,3,-5,-5,11,11,-21,-21,43,43,-85,-85,171,171,-341,-341,683,683,-1365,-1365,2731,2731,-5461,-5461,10923,10923,-21845,-21845,43691,43691,-87381,-87381,174763,174763,-349525,-349525,699051,699051,-1398101,-1398101,2796203,2796203,-5592405,-5592405,11184811,11184811,-22369621,-22369621,44739243,44739243,-89478485,-89478485,178956971,178956971,-357913941,-357913941,715827883,715827883,-1431655765,-1431655765,2863311531,2863311531,-5726623061,-5726623061,11453246123,11453246123,-22906492245,-22906492245,45812984491,45812984491,-91625968981,-91625968981,183251937963,183251937963,-366503875925,-366503875925,733007751851,733007751851,-1466015503701,-1466015503701,2932031007403,2932031007403,-5864062014805,-5864062014805,11728124029611,11728124029611,-23456248059221,-23456248059221,46912496118443,46912496118443,-93824992236885,-93824992236885,187649984473771,187649984473771,-375299968947541,-375299968947541,750599937895083,750599937895083,-1501199875790165,-1501199875790165,3002399751580331,3002399751580331,-6004799503160661,-6004799503160661
div $0,2
mov $1,-2
pow $1,$0
sub $1,1
div $1,3
mul $1,2
add $1,1
|
.global s_prepare_buffers
s_prepare_buffers:
push %r15
push %r8
push %r9
push %rbp
push %rcx
push %rdi
push %rdx
push %rsi
lea addresses_D_ht+0xd1b, %rsi
lea addresses_normal_ht+0xebdb, %rdi
nop
nop
nop
sub %r9, %r9
mov $51, %rcx
rep movsw
nop
add %r15, %r15
lea addresses_WT_ht+0x2e3b, %rsi
lea addresses_normal_ht+0x39b5, %rdi
nop
nop
nop
nop
nop
add %rbp, %rbp
mov $24, %rcx
rep movsb
nop
nop
nop
nop
nop
lfence
lea addresses_D_ht+0x1e19b, %r15
nop
nop
inc %rsi
movw $0x6162, (%r15)
sub %rbp, %rbp
lea addresses_normal_ht+0xbe9b, %rcx
nop
nop
nop
nop
nop
xor $41158, %r8
mov (%rcx), %r15w
nop
sub %r8, %r8
lea addresses_normal_ht+0x1055b, %rsi
lea addresses_WC_ht+0xa425, %rdi
nop
nop
nop
and $32430, %rdx
mov $23, %rcx
rep movsl
nop
xor $45954, %r9
pop %rsi
pop %rdx
pop %rdi
pop %rcx
pop %rbp
pop %r9
pop %r8
pop %r15
ret
.global s_faulty_load
s_faulty_load:
push %r12
push %r13
push %r8
push %rcx
push %rdi
push %rdx
push %rsi
// Store
mov $0x31ab51000000051b, %r8
nop
xor %r12, %r12
mov $0x5152535455565758, %rsi
movq %rsi, %xmm4
vmovups %ymm4, (%r8)
nop
nop
xor $36871, %r12
// Load
lea addresses_RW+0x5adb, %rdx
nop
nop
nop
nop
nop
xor %rsi, %rsi
vmovups (%rdx), %ymm2
vextracti128 $1, %ymm2, %xmm2
vpextrq $0, %xmm2, %rcx
nop
and $11553, %rcx
// Store
lea addresses_RW+0x1509b, %rcx
nop
nop
nop
dec %r12
movb $0x51, (%rcx)
nop
nop
nop
nop
sub %rdi, %rdi
// Load
lea addresses_US+0x791b, %rdx
nop
nop
nop
nop
nop
xor $28206, %r13
vmovups (%rdx), %ymm1
vextracti128 $0, %ymm1, %xmm1
vpextrq $1, %xmm1, %r8
and %rcx, %rcx
// Faulty Load
lea addresses_US+0x1651b, %rdi
nop
nop
nop
nop
nop
sub $55930, %rcx
mov (%rdi), %rsi
lea oracles, %r12
and $0xff, %rsi
shlq $12, %rsi
mov (%r12,%rsi,1), %rsi
pop %rsi
pop %rdx
pop %rdi
pop %rcx
pop %r8
pop %r13
pop %r12
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'type': 'addresses_US', 'size': 1, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_NC', 'size': 32, 'AVXalign': False, 'NT': False, 'congruent': 11, 'same': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_RW', 'size': 32, 'AVXalign': False, 'NT': False, 'congruent': 6, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_RW', 'size': 1, 'AVXalign': False, 'NT': False, 'congruent': 7, 'same': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_US', 'size': 32, 'AVXalign': False, 'NT': False, 'congruent': 9, 'same': False}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'type': 'addresses_US', 'size': 8, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': True}}
<gen_prepare_buffer>
{'OP': 'REPM', 'src': {'type': 'addresses_D_ht', 'congruent': 11, 'same': False}, 'dst': {'type': 'addresses_normal_ht', 'congruent': 5, 'same': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_WT_ht', 'congruent': 5, 'same': False}, 'dst': {'type': 'addresses_normal_ht', 'congruent': 1, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_D_ht', 'size': 2, 'AVXalign': False, 'NT': False, 'congruent': 7, 'same': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_normal_ht', 'size': 2, 'AVXalign': False, 'NT': True, 'congruent': 7, 'same': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_normal_ht', 'congruent': 6, 'same': False}, 'dst': {'type': 'addresses_WC_ht', 'congruent': 0, 'same': False}}
{'58': 240}
58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58
*/
|
li $a0, 0x10
sb $a0, 0x2000($zero)
sw $a0, 0x2010($zero)
lb $a1, 0x2000($zero)
lw $a2, 0x2010($zero)
|
// Boost.Geometry - gis-projections (based on PROJ4)
// Copyright (c) 2008-2015 Barend Gehrels, Amsterdam, the Netherlands.
// This file was modified by Oracle on 2017, 2018.
// Modifications copyright (c) 2017-2018, Oracle and/or its affiliates.
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle.
// Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// This file is converted from PROJ4, http://trac.osgeo.org/proj
// PROJ4 is originally written by Gerald Evenden (then of the USGS)
// PROJ4 is maintained by Frank Warmerdam
// PROJ4 is converted to Boost.Geometry by Barend Gehrels
// Last updated version of proj: 5.0.0
// Original copyright notice:
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
#ifndef BOOST_GEOMETRY_PROJECTIONS_OEA_HPP
#define BOOST_GEOMETRY_PROJECTIONS_OEA_HPP
#include <boost/math/special_functions/hypot.hpp>
#include <boost/geometry/srs/projections/impl/aasincos.hpp>
#include <boost/geometry/srs/projections/impl/base_static.hpp>
#include <boost/geometry/srs/projections/impl/base_dynamic.hpp>
#include <boost/geometry/srs/projections/impl/factory_entry.hpp>
#include <boost/geometry/srs/projections/impl/pj_param.hpp>
#include <boost/geometry/srs/projections/impl/projects.hpp>
namespace boost { namespace geometry
{
namespace projections
{
#ifndef DOXYGEN_NO_DETAIL
namespace detail { namespace oea
{
template <typename T>
struct par_oea
{
T theta;
T m, n;
T two_r_m, two_r_n, rm, rn, hm, hn;
T cp0, sp0;
};
// template class, using CRTP to implement forward/inverse
template <typename T, typename Parameters>
struct base_oea_spheroid
: public base_t_fi<base_oea_spheroid<T, Parameters>, T, Parameters>
{
par_oea<T> m_proj_parm;
inline base_oea_spheroid(const Parameters& par)
: base_t_fi<base_oea_spheroid<T, Parameters>, T, Parameters>(*this, par)
{}
// FORWARD(s_forward) sphere
// Project coordinates from geographic (lon, lat) to cartesian (x, y)
inline void fwd(T const& lp_lon, T const& lp_lat, T& xy_x, T& xy_y) const
{
T Az, M, N, cp, sp, cl, shz;
cp = cos(lp_lat);
sp = sin(lp_lat);
cl = cos(lp_lon);
Az = aatan2(cp * sin(lp_lon), this->m_proj_parm.cp0 * sp - this->m_proj_parm.sp0 * cp * cl) + this->m_proj_parm.theta;
shz = sin(0.5 * aacos(this->m_proj_parm.sp0 * sp + this->m_proj_parm.cp0 * cp * cl));
M = aasin(shz * sin(Az));
N = aasin(shz * cos(Az) * cos(M) / cos(M * this->m_proj_parm.two_r_m));
xy_y = this->m_proj_parm.n * sin(N * this->m_proj_parm.two_r_n);
xy_x = this->m_proj_parm.m * sin(M * this->m_proj_parm.two_r_m) * cos(N) / cos(N * this->m_proj_parm.two_r_n);
}
// INVERSE(s_inverse) sphere
// Project coordinates from cartesian (x, y) to geographic (lon, lat)
inline void inv(T const& xy_x, T const& xy_y, T& lp_lon, T& lp_lat) const
{
T N, M, xp, yp, z, Az, cz, sz, cAz;
N = this->m_proj_parm.hn * aasin(xy_y * this->m_proj_parm.rn);
M = this->m_proj_parm.hm * aasin(xy_x * this->m_proj_parm.rm * cos(N * this->m_proj_parm.two_r_n) / cos(N));
xp = 2. * sin(M);
yp = 2. * sin(N) * cos(M * this->m_proj_parm.two_r_m) / cos(M);
cAz = cos(Az = aatan2(xp, yp) - this->m_proj_parm.theta);
z = 2. * aasin(0.5 * boost::math::hypot(xp, yp));
sz = sin(z);
cz = cos(z);
lp_lat = aasin(this->m_proj_parm.sp0 * cz + this->m_proj_parm.cp0 * sz * cAz);
lp_lon = aatan2(sz * sin(Az),
this->m_proj_parm.cp0 * cz - this->m_proj_parm.sp0 * sz * cAz);
}
static inline std::string get_name()
{
return "oea_spheroid";
}
};
// Oblated Equal Area
template <typename Params, typename Parameters, typename T>
inline void setup_oea(Params const& params, Parameters& par, par_oea<T>& proj_parm)
{
if (((proj_parm.n = pj_get_param_f<T, srs::spar::n>(params, "n", srs::dpar::n)) <= 0.) ||
((proj_parm.m = pj_get_param_f<T, srs::spar::m>(params, "m", srs::dpar::m)) <= 0.)) {
BOOST_THROW_EXCEPTION( projection_exception(error_invalid_m_or_n) );
} else {
proj_parm.theta = pj_get_param_r<T, srs::spar::theta>(params, "theta", srs::dpar::theta);
proj_parm.sp0 = sin(par.phi0);
proj_parm.cp0 = cos(par.phi0);
proj_parm.rn = 1./ proj_parm.n;
proj_parm.rm = 1./ proj_parm.m;
proj_parm.two_r_n = 2. * proj_parm.rn;
proj_parm.two_r_m = 2. * proj_parm.rm;
proj_parm.hm = 0.5 * proj_parm.m;
proj_parm.hn = 0.5 * proj_parm.n;
par.es = 0.;
}
}
}} // namespace detail::oea
#endif // doxygen
/*!
\brief Oblated Equal Area projection
\ingroup projections
\tparam Geographic latlong point type
\tparam Cartesian xy point type
\tparam Parameters parameter type
\par Projection characteristics
- Miscellaneous
- Spheroid
\par Projection parameters
- n (real)
- m (real)
- theta: Theta (degrees)
\par Example
\image html ex_oea.gif
*/
template <typename T, typename Parameters>
struct oea_spheroid : public detail::oea::base_oea_spheroid<T, Parameters>
{
template <typename Params>
inline oea_spheroid(Params const& params, Parameters const& par)
: detail::oea::base_oea_spheroid<T, Parameters>(par)
{
detail::oea::setup_oea(params, this->m_par, this->m_proj_parm);
}
};
#ifndef DOXYGEN_NO_DETAIL
namespace detail
{
// Static projection
BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION(srs::spar::proj_oea, oea_spheroid, oea_spheroid)
// Factory entry(s)
BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_ENTRY_FI(oea_entry, oea_spheroid)
BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_INIT_BEGIN(oea_init)
{
BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_INIT_ENTRY(oea, oea_entry)
}
} // namespace detail
#endif // doxygen
} // namespace projections
}} // namespace boost::geometry
#endif // BOOST_GEOMETRY_PROJECTIONS_OEA_HPP
|
map_header SaffronPidgeyHouse, SAFFRON_PIDGEY_HOUSE, HOUSE, 0
end_map_header
|
/*---------------------------------------------------------------------------*\
Copyright (C) 2011 OpenFOAM Foundation
-------------------------------------------------------------------------------
License
This file is part of Caelus.
Caelus 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 3 of the License, or
(at your option) any later version.
Caelus 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 Caelus. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#ifndef uniformFixedValueFvPatchFields_H
#define uniformFixedValueFvPatchFields_H
#include "uniformFixedValueFvPatchField.hpp"
#include "fieldTypes.hpp"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace CML
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
makePatchTypeFieldTypedefs(uniformFixedValue);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace CML
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //
|
//==----------------- sampler_impl.hpp - SYCL standard header file ---------==//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#pragma once
#include <CL/__spirv/spirv_types.hpp>
#include <CL/sycl/context.hpp>
#include <CL/sycl/detail/export.hpp>
#include <CL/sycl/property_list.hpp>
#include <unordered_map>
__SYCL_INLINE_NAMESPACE(cl) {
namespace sycl {
enum class addressing_mode : unsigned int;
enum class filtering_mode : unsigned int;
enum class coordinate_normalization_mode : unsigned int;
namespace detail {
class __SYCL_EXPORT sampler_impl {
public:
sampler_impl(coordinate_normalization_mode normalizationMode,
addressing_mode addressingMode, filtering_mode filteringMode,
const property_list &propList);
sampler_impl(cl_sampler clSampler, const context &syclContext);
addressing_mode get_addressing_mode() const;
filtering_mode get_filtering_mode() const;
coordinate_normalization_mode get_coordinate_normalization_mode() const;
RT::PiSampler getOrCreateSampler(const context &Context);
/// Checks if this sampler_impl has a property of type propertyT.
///
/// \return true if this sampler_impl has a property of type propertyT.
template <typename propertyT> bool has_property() const {
return MPropList.has_property<propertyT>();
}
/// Gets the specified property of this sampler_impl.
///
/// Throws invalid_object_error if this sampler_impl does not have a property
/// of type propertyT.
///
/// \return a copy of the property of type propertyT.
template <typename propertyT> propertyT get_property() const {
return MPropList.get_property<propertyT>();
}
~sampler_impl();
private:
/// Protects all the fields that can be changed by class' methods.
mutex_class MMutex;
std::unordered_map<context, RT::PiSampler> MContextToSampler;
coordinate_normalization_mode MCoordNormMode;
addressing_mode MAddrMode;
filtering_mode MFiltMode;
property_list MPropList;
};
} // namespace detail
} // namespace sycl
} // __SYCL_INLINE_NAMESPACE(cl)
|
;mov si,1100h
;mov di,1200h
;mov cl,[si]
;inc si
;mov al,[si]
;dec cl
;again:
;inc si
;mov bl,[si]
;cmp al,bl
;ahead:
;dec cl
;jnz again
;mov [di],al
;hlt
org 100h
MOV SI,1100H ;Set SI register as point.
MOV CL,[SI] ;Set CL as count for element.
INC SI ;Increment address point
MOV AL,[SI] ;Get first data
DEC CL ;Decrement count
L2: INC SI ;Increment SI
CMP AL,[SI] ;Compare current smallest and next
JNB L1 ;If carry is not set,AL is largest and go to ahead
MOV AL,[SI] ;MOV BL to AL
L1: DEC CL ;Decrement count register
JNZ L2 ; If ZF=0,repeat comparison
MOV DI,1200H ; Store largest data in memory
MOV [DI],AL ; Initialize DI with1200h
HLT ;Halt the program. |
/*
* Copyright (c) 2017, Intel Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
L0:
add (4|M0) a0.0<1>:w r22.0<4;4,1>:w 0x0:uw {AccWrEn}
mov (8|M0) r27.0<1>:ud r0.0<8;8,1>:ud
shl (2|M0) r27.0<1>:d r7.0<2;2,1>:w 0x1:v
mov (1|M0) r27.2<1>:ud 0xF000F:ud
add (4|M0) a0.4<1>:w a0.0<4;4,1>:w r22.8<0;2,1>:w
and (16|M0) r29.0<1>:uw r[a0.0]<16;16,1>:uw 0xF800:uw
and (16|M0) r30.0<1>:uw r[a0.0,32]<16;16,1>:uw 0xF800:uw
shr (16|M0) r29.0<2>:ub r[a0.2,1]<32;16,2>:ub 0x3:uw
shr (16|M0) r30.0<2>:ub r[a0.2,33]<32;16,2>:ub 0x3:uw
shr (16|M0) r[a0.1]<1>:uw r[a0.1]<16;16,1>:uw 0x5:uw
shr (16|M0) r[a0.1,32]<1>:uw r[a0.1,32]<16;16,1>:uw 0x5:uw
and (16|M0) r[a0.1]<1>:uw r[a0.1]<16;16,1>:uw 0x7E0:uw
and (16|M0) r[a0.1,32]<1>:uw r[a0.1,32]<16;16,1>:uw 0x7E0:uw
or (16|M0) r29.0<1>:uw r[a0.1]<16;16,1>:uw r29.0<16;16,1>:uw
or (16|M0) r30.0<1>:uw r[a0.1,32]<16;16,1>:uw r30.0<16;16,1>:uw
add (4|M0) a0.0<1>:w a0.0<4;4,1>:w 0x200:uw
and (16|M0) r38.0<1>:uw r[a0.4]<16;16,1>:uw 0xF800:uw
and (16|M0) r39.0<1>:uw r[a0.4,32]<16;16,1>:uw 0xF800:uw
shr (16|M0) r38.0<2>:ub r[a0.6,1]<32;16,2>:ub 0x3:uw
shr (16|M0) r39.0<2>:ub r[a0.6,33]<32;16,2>:ub 0x3:uw
shr (16|M0) r[a0.5]<1>:uw r[a0.5]<16;16,1>:uw 0x5:uw
shr (16|M0) r[a0.5,32]<1>:uw r[a0.5,32]<16;16,1>:uw 0x5:uw
and (16|M0) r[a0.5]<1>:uw r[a0.5]<16;16,1>:uw 0x7E0:uw
and (16|M0) r[a0.5,32]<1>:uw r[a0.5,32]<16;16,1>:uw 0x7E0:uw
or (16|M0) r38.0<1>:uw r[a0.5]<16;16,1>:uw r38.0<16;16,1>:uw
or (16|M0) r39.0<1>:uw r[a0.5,32]<16;16,1>:uw r39.0<16;16,1>:uw
add (4|M0) a0.4<1>:w a0.4<4;4,1>:w 0x200:uw
mov (8|M0) r28.0<1>:ud r27.0<8;8,1>:ud
mov (8|M0) r37.0<1>:ud r27.0<8;8,1>:ud
and (16|M0) r31.0<1>:uw r[a0.0]<16;16,1>:uw 0xF800:uw
and (16|M0) r32.0<1>:uw r[a0.0,32]<16;16,1>:uw 0xF800:uw
shr (16|M0) r31.0<2>:ub r[a0.2,1]<32;16,2>:ub 0x3:uw
shr (16|M0) r32.0<2>:ub r[a0.2,33]<32;16,2>:ub 0x3:uw
shr (16|M0) r[a0.1]<1>:uw r[a0.1]<16;16,1>:uw 0x5:uw
shr (16|M0) r[a0.1,32]<1>:uw r[a0.1,32]<16;16,1>:uw 0x5:uw
and (16|M0) r[a0.1]<1>:uw r[a0.1]<16;16,1>:uw 0x7E0:uw
and (16|M0) r[a0.1,32]<1>:uw r[a0.1,32]<16;16,1>:uw 0x7E0:uw
or (16|M0) r31.0<1>:uw r[a0.1]<16;16,1>:uw r31.0<16;16,1>:uw
or (16|M0) r32.0<1>:uw r[a0.1,32]<16;16,1>:uw r32.0<16;16,1>:uw
add (4|M0) a0.0<1>:w a0.0<4;4,1>:w 0x200:uw
and (16|M0) r40.0<1>:uw r[a0.4]<16;16,1>:uw 0xF800:uw
and (16|M0) r41.0<1>:uw r[a0.4,32]<16;16,1>:uw 0xF800:uw
shr (16|M0) r40.0<2>:ub r[a0.6,1]<32;16,2>:ub 0x3:uw
shr (16|M0) r41.0<2>:ub r[a0.6,33]<32;16,2>:ub 0x3:uw
shr (16|M0) r[a0.5]<1>:uw r[a0.5]<16;16,1>:uw 0x5:uw
shr (16|M0) r[a0.5,32]<1>:uw r[a0.5,32]<16;16,1>:uw 0x5:uw
and (16|M0) r[a0.5]<1>:uw r[a0.5]<16;16,1>:uw 0x7E0:uw
and (16|M0) r[a0.5,32]<1>:uw r[a0.5,32]<16;16,1>:uw 0x7E0:uw
or (16|M0) r40.0<1>:uw r[a0.5]<16;16,1>:uw r40.0<16;16,1>:uw
or (16|M0) r41.0<1>:uw r[a0.5,32]<16;16,1>:uw r41.0<16;16,1>:uw
add (4|M0) a0.4<1>:w a0.4<4;4,1>:w 0x200:uw
and (16|M0) r33.0<1>:uw r[a0.0]<16;16,1>:uw 0xF800:uw
and (16|M0) r34.0<1>:uw r[a0.0,32]<16;16,1>:uw 0xF800:uw
shr (16|M0) r33.0<2>:ub r[a0.2,1]<32;16,2>:ub 0x3:uw
shr (16|M0) r34.0<2>:ub r[a0.2,33]<32;16,2>:ub 0x3:uw
shr (16|M0) r[a0.1]<1>:uw r[a0.1]<16;16,1>:uw 0x5:uw
shr (16|M0) r[a0.1,32]<1>:uw r[a0.1,32]<16;16,1>:uw 0x5:uw
and (16|M0) r[a0.1]<1>:uw r[a0.1]<16;16,1>:uw 0x7E0:uw
and (16|M0) r[a0.1,32]<1>:uw r[a0.1,32]<16;16,1>:uw 0x7E0:uw
or (16|M0) r33.0<1>:uw r[a0.1]<16;16,1>:uw r33.0<16;16,1>:uw
or (16|M0) r34.0<1>:uw r[a0.1,32]<16;16,1>:uw r34.0<16;16,1>:uw
add (4|M0) a0.0<1>:w a0.0<4;4,1>:w 0x200:uw
and (16|M0) r42.0<1>:uw r[a0.4]<16;16,1>:uw 0xF800:uw
and (16|M0) r43.0<1>:uw r[a0.4,32]<16;16,1>:uw 0xF800:uw
shr (16|M0) r42.0<2>:ub r[a0.6,1]<32;16,2>:ub 0x3:uw
shr (16|M0) r43.0<2>:ub r[a0.6,33]<32;16,2>:ub 0x3:uw
shr (16|M0) r[a0.5]<1>:uw r[a0.5]<16;16,1>:uw 0x5:uw
shr (16|M0) r[a0.5,32]<1>:uw r[a0.5,32]<16;16,1>:uw 0x5:uw
and (16|M0) r[a0.5]<1>:uw r[a0.5]<16;16,1>:uw 0x7E0:uw
and (16|M0) r[a0.5,32]<1>:uw r[a0.5,32]<16;16,1>:uw 0x7E0:uw
or (16|M0) r42.0<1>:uw r[a0.5]<16;16,1>:uw r42.0<16;16,1>:uw
or (16|M0) r43.0<1>:uw r[a0.5,32]<16;16,1>:uw r43.0<16;16,1>:uw
add (4|M0) a0.4<1>:w a0.4<4;4,1>:w 0x200:uw
add (1|M0) r37.0<1>:d r27.0<0;1,0>:d 16:d
and (16|M0) r35.0<1>:uw r[a0.0]<16;16,1>:uw 0xF800:uw
and (16|M0) r36.0<1>:uw r[a0.0,32]<16;16,1>:uw 0xF800:uw
shr (16|M0) r35.0<2>:ub r[a0.2,1]<32;16,2>:ub 0x3:uw
shr (16|M0) r36.0<2>:ub r[a0.2,33]<32;16,2>:ub 0x3:uw
shr (16|M0) r[a0.1]<1>:uw r[a0.1]<16;16,1>:uw 0x5:uw
shr (16|M0) r[a0.1,32]<1>:uw r[a0.1,32]<16;16,1>:uw 0x5:uw
and (16|M0) r[a0.1]<1>:uw r[a0.1]<16;16,1>:uw 0x7E0:uw
and (16|M0) r[a0.1,32]<1>:uw r[a0.1,32]<16;16,1>:uw 0x7E0:uw
or (16|M0) r35.0<1>:uw r[a0.1]<16;16,1>:uw r35.0<16;16,1>:uw
or (16|M0) r36.0<1>:uw r[a0.1,32]<16;16,1>:uw r36.0<16;16,1>:uw
and (16|M0) r44.0<1>:uw r[a0.4]<16;16,1>:uw 0xF800:uw
and (16|M0) r45.0<1>:uw r[a0.4,32]<16;16,1>:uw 0xF800:uw
shr (16|M0) r44.0<2>:ub r[a0.6,1]<32;16,2>:ub 0x3:uw
shr (16|M0) r45.0<2>:ub r[a0.6,33]<32;16,2>:ub 0x3:uw
shr (16|M0) r[a0.5]<1>:uw r[a0.5]<16;16,1>:uw 0x5:uw
shr (16|M0) r[a0.5,32]<1>:uw r[a0.5,32]<16;16,1>:uw 0x5:uw
and (16|M0) r[a0.5]<1>:uw r[a0.5]<16;16,1>:uw 0x7E0:uw
and (16|M0) r[a0.5,32]<1>:uw r[a0.5,32]<16;16,1>:uw 0x7E0:uw
or (16|M0) r44.0<1>:uw r[a0.5]<16;16,1>:uw r44.0<16;16,1>:uw
or (16|M0) r45.0<1>:uw r[a0.5,32]<16;16,1>:uw r45.0<16;16,1>:uw
send (8|M0) null:d r28:ub 0xC 0x120A8018
send (8|M0) null:d r37:ub 0xC 0x120A8018
|
; A025467: Expansion of 1/((1-2x)(1-3x)(1-4x)(1-8x)).
; Submitted by Jon Maiga
; 1,17,191,1813,15855,132909,1089607,8828501,71093759,570671101,4573228023,36617788389,293071750063,2345096538893,18762876780839,150111475106677,1200925773302367,9607542463373085,76860885976538455
mov $1,1
mov $2,$0
mov $3,$0
lpb $2
mov $0,$3
sub $2,1
sub $0,$2
seq $0,16290 ; Expansion of 1/((1-2x)(1-4x)(1-8x)).
mul $1,3
add $1,$0
lpe
mov $0,$1
|
; A105396: A simple "Fractal Jump Sequence" (FJS).
; 3,6,6,3,6,6,3,6,6,3,6,6,3,6,6,3,6,6,3,6,6,3,6,6,3,6,6,3,6,6,3,6,6,3,6,6,3,6,6,3,6,6,3,6,6,3,6,6,3,6,6,3,6,6,3,6,6,3,6,6,3,6,6,3,6,6,3,6,6,3,6,6,3,6,6,3,6,6,3,6,6,3,6,6,3,6,6,3,6,6,3,6,6,3,6,6,3,6,6,3,6,6,3,6,6
gcd $0,3
mov $1,4
div $1,$0
add $1,2
|
#include "SoftmaxLayer.hpp"
double softmax(const double numerator, const double denominator) {
const double MAX = 0.9999999;
const double MIN = 0.0000001;
double output = numerator / denominator;
std::clamp(output, MIN, MAX);
return output;
}
void SoftmaxLayer::forwardPropogate() {
double numerators[neurons.size()];
double offset = 0;
for(int i = 0; i < neurons.size(); i++) {
numerators[i] = neurons[i]->productSum();
if(numerators[i] > offset) {
offset = numerators[i];
}
}
double denominator = 0;
for(int i = 0; i < neurons.size(); i++) {
numerators[i] = std::exp(numerators[i] - offset);
denominator += numerators[i];
}
for(int i = 0; i < neurons.size(); i++) {
neurons[i]->activate([&numerators, &i, &denominator](double z) {
const double MAX = 0.9999999;
const double MIN = 0.0000001;
double output = numerators[i] / denominator;
std::clamp(output, MIN, MAX);
return output;
});
}
}
void SoftmaxLayer::backPropogate(const double learningRate) {
for(auto& neuron : neurons) {
neuron->backPropogate([](const double x) -> double {return x * (1.0 - x);}, learningRate);
}
} |
_getmaxpid_test: file format elf32-i386
Disassembly of section .text:
00000000 <main>:
#include "fcntl.h"
#include "date.h"
//#include "stdio.h"
int main(int argc, char *argv[])
{
0: 8d 4c 24 04 lea 0x4(%esp),%ecx
4: 83 e4 f0 and $0xfffffff0,%esp
7: ff 71 fc pushl -0x4(%ecx)
a: 55 push %ebp
b: 89 e5 mov %esp,%ebp
d: 51 push %ecx
e: 83 ec 04 sub $0x4,%esp
int max;
max = get_max_pid();
11: e8 24 03 00 00 call 33a <get_max_pid>
printf(1, "Maximum PID: %d\n", max);
16: 83 ec 04 sub $0x4,%esp
19: 50 push %eax
1a: 68 58 07 00 00 push $0x758
1f: 6a 01 push $0x1
21: e8 da 03 00 00 call 400 <printf>
exit();
26: e8 57 02 00 00 call 282 <exit>
2b: 66 90 xchg %ax,%ax
2d: 66 90 xchg %ax,%ax
2f: 90 nop
00000030 <strcpy>:
#include "user.h"
#include "x86.h"
char*
strcpy(char *s, const char *t)
{
30: 55 push %ebp
31: 89 e5 mov %esp,%ebp
33: 53 push %ebx
34: 8b 45 08 mov 0x8(%ebp),%eax
37: 8b 4d 0c mov 0xc(%ebp),%ecx
char *os;
os = s;
while((*s++ = *t++) != 0)
3a: 89 c2 mov %eax,%edx
3c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
40: 83 c1 01 add $0x1,%ecx
43: 0f b6 59 ff movzbl -0x1(%ecx),%ebx
47: 83 c2 01 add $0x1,%edx
4a: 84 db test %bl,%bl
4c: 88 5a ff mov %bl,-0x1(%edx)
4f: 75 ef jne 40 <strcpy+0x10>
;
return os;
}
51: 5b pop %ebx
52: 5d pop %ebp
53: c3 ret
54: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
5a: 8d bf 00 00 00 00 lea 0x0(%edi),%edi
00000060 <strcmp>:
int
strcmp(const char *p, const char *q)
{
60: 55 push %ebp
61: 89 e5 mov %esp,%ebp
63: 53 push %ebx
64: 8b 55 08 mov 0x8(%ebp),%edx
67: 8b 4d 0c mov 0xc(%ebp),%ecx
while(*p && *p == *q)
6a: 0f b6 02 movzbl (%edx),%eax
6d: 0f b6 19 movzbl (%ecx),%ebx
70: 84 c0 test %al,%al
72: 75 1c jne 90 <strcmp+0x30>
74: eb 2a jmp a0 <strcmp+0x40>
76: 8d 76 00 lea 0x0(%esi),%esi
79: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
p++, q++;
80: 83 c2 01 add $0x1,%edx
while(*p && *p == *q)
83: 0f b6 02 movzbl (%edx),%eax
p++, q++;
86: 83 c1 01 add $0x1,%ecx
89: 0f b6 19 movzbl (%ecx),%ebx
while(*p && *p == *q)
8c: 84 c0 test %al,%al
8e: 74 10 je a0 <strcmp+0x40>
90: 38 d8 cmp %bl,%al
92: 74 ec je 80 <strcmp+0x20>
return (uchar)*p - (uchar)*q;
94: 29 d8 sub %ebx,%eax
}
96: 5b pop %ebx
97: 5d pop %ebp
98: c3 ret
99: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
a0: 31 c0 xor %eax,%eax
return (uchar)*p - (uchar)*q;
a2: 29 d8 sub %ebx,%eax
}
a4: 5b pop %ebx
a5: 5d pop %ebp
a6: c3 ret
a7: 89 f6 mov %esi,%esi
a9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
000000b0 <strlen>:
uint
strlen(const char *s)
{
b0: 55 push %ebp
b1: 89 e5 mov %esp,%ebp
b3: 8b 4d 08 mov 0x8(%ebp),%ecx
int n;
for(n = 0; s[n]; n++)
b6: 80 39 00 cmpb $0x0,(%ecx)
b9: 74 15 je d0 <strlen+0x20>
bb: 31 d2 xor %edx,%edx
bd: 8d 76 00 lea 0x0(%esi),%esi
c0: 83 c2 01 add $0x1,%edx
c3: 80 3c 11 00 cmpb $0x0,(%ecx,%edx,1)
c7: 89 d0 mov %edx,%eax
c9: 75 f5 jne c0 <strlen+0x10>
;
return n;
}
cb: 5d pop %ebp
cc: c3 ret
cd: 8d 76 00 lea 0x0(%esi),%esi
for(n = 0; s[n]; n++)
d0: 31 c0 xor %eax,%eax
}
d2: 5d pop %ebp
d3: c3 ret
d4: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
da: 8d bf 00 00 00 00 lea 0x0(%edi),%edi
000000e0 <memset>:
void*
memset(void *dst, int c, uint n)
{
e0: 55 push %ebp
e1: 89 e5 mov %esp,%ebp
e3: 57 push %edi
e4: 8b 55 08 mov 0x8(%ebp),%edx
}
static inline void
stosb(void *addr, int data, int cnt)
{
asm volatile("cld; rep stosb" :
e7: 8b 4d 10 mov 0x10(%ebp),%ecx
ea: 8b 45 0c mov 0xc(%ebp),%eax
ed: 89 d7 mov %edx,%edi
ef: fc cld
f0: f3 aa rep stos %al,%es:(%edi)
stosb(dst, c, n);
return dst;
}
f2: 89 d0 mov %edx,%eax
f4: 5f pop %edi
f5: 5d pop %ebp
f6: c3 ret
f7: 89 f6 mov %esi,%esi
f9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
00000100 <strchr>:
char*
strchr(const char *s, char c)
{
100: 55 push %ebp
101: 89 e5 mov %esp,%ebp
103: 53 push %ebx
104: 8b 45 08 mov 0x8(%ebp),%eax
107: 8b 5d 0c mov 0xc(%ebp),%ebx
for(; *s; s++)
10a: 0f b6 10 movzbl (%eax),%edx
10d: 84 d2 test %dl,%dl
10f: 74 1d je 12e <strchr+0x2e>
if(*s == c)
111: 38 d3 cmp %dl,%bl
113: 89 d9 mov %ebx,%ecx
115: 75 0d jne 124 <strchr+0x24>
117: eb 17 jmp 130 <strchr+0x30>
119: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
120: 38 ca cmp %cl,%dl
122: 74 0c je 130 <strchr+0x30>
for(; *s; s++)
124: 83 c0 01 add $0x1,%eax
127: 0f b6 10 movzbl (%eax),%edx
12a: 84 d2 test %dl,%dl
12c: 75 f2 jne 120 <strchr+0x20>
return (char*)s;
return 0;
12e: 31 c0 xor %eax,%eax
}
130: 5b pop %ebx
131: 5d pop %ebp
132: c3 ret
133: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
139: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
00000140 <gets>:
char*
gets(char *buf, int max)
{
140: 55 push %ebp
141: 89 e5 mov %esp,%ebp
143: 57 push %edi
144: 56 push %esi
145: 53 push %ebx
int i, cc;
char c;
for(i=0; i+1 < max; ){
146: 31 f6 xor %esi,%esi
148: 89 f3 mov %esi,%ebx
{
14a: 83 ec 1c sub $0x1c,%esp
14d: 8b 7d 08 mov 0x8(%ebp),%edi
for(i=0; i+1 < max; ){
150: eb 2f jmp 181 <gets+0x41>
152: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
cc = read(0, &c, 1);
158: 8d 45 e7 lea -0x19(%ebp),%eax
15b: 83 ec 04 sub $0x4,%esp
15e: 6a 01 push $0x1
160: 50 push %eax
161: 6a 00 push $0x0
163: e8 32 01 00 00 call 29a <read>
if(cc < 1)
168: 83 c4 10 add $0x10,%esp
16b: 85 c0 test %eax,%eax
16d: 7e 1c jle 18b <gets+0x4b>
break;
buf[i++] = c;
16f: 0f b6 45 e7 movzbl -0x19(%ebp),%eax
173: 83 c7 01 add $0x1,%edi
176: 88 47 ff mov %al,-0x1(%edi)
if(c == '\n' || c == '\r')
179: 3c 0a cmp $0xa,%al
17b: 74 23 je 1a0 <gets+0x60>
17d: 3c 0d cmp $0xd,%al
17f: 74 1f je 1a0 <gets+0x60>
for(i=0; i+1 < max; ){
181: 83 c3 01 add $0x1,%ebx
184: 3b 5d 0c cmp 0xc(%ebp),%ebx
187: 89 fe mov %edi,%esi
189: 7c cd jl 158 <gets+0x18>
18b: 89 f3 mov %esi,%ebx
break;
}
buf[i] = '\0';
return buf;
}
18d: 8b 45 08 mov 0x8(%ebp),%eax
buf[i] = '\0';
190: c6 03 00 movb $0x0,(%ebx)
}
193: 8d 65 f4 lea -0xc(%ebp),%esp
196: 5b pop %ebx
197: 5e pop %esi
198: 5f pop %edi
199: 5d pop %ebp
19a: c3 ret
19b: 90 nop
19c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
1a0: 8b 75 08 mov 0x8(%ebp),%esi
1a3: 8b 45 08 mov 0x8(%ebp),%eax
1a6: 01 de add %ebx,%esi
1a8: 89 f3 mov %esi,%ebx
buf[i] = '\0';
1aa: c6 03 00 movb $0x0,(%ebx)
}
1ad: 8d 65 f4 lea -0xc(%ebp),%esp
1b0: 5b pop %ebx
1b1: 5e pop %esi
1b2: 5f pop %edi
1b3: 5d pop %ebp
1b4: c3 ret
1b5: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
1b9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
000001c0 <stat>:
int
stat(const char *n, struct stat *st)
{
1c0: 55 push %ebp
1c1: 89 e5 mov %esp,%ebp
1c3: 56 push %esi
1c4: 53 push %ebx
int fd;
int r;
fd = open(n, O_RDONLY);
1c5: 83 ec 08 sub $0x8,%esp
1c8: 6a 00 push $0x0
1ca: ff 75 08 pushl 0x8(%ebp)
1cd: e8 f0 00 00 00 call 2c2 <open>
if(fd < 0)
1d2: 83 c4 10 add $0x10,%esp
1d5: 85 c0 test %eax,%eax
1d7: 78 27 js 200 <stat+0x40>
return -1;
r = fstat(fd, st);
1d9: 83 ec 08 sub $0x8,%esp
1dc: ff 75 0c pushl 0xc(%ebp)
1df: 89 c3 mov %eax,%ebx
1e1: 50 push %eax
1e2: e8 f3 00 00 00 call 2da <fstat>
close(fd);
1e7: 89 1c 24 mov %ebx,(%esp)
r = fstat(fd, st);
1ea: 89 c6 mov %eax,%esi
close(fd);
1ec: e8 b9 00 00 00 call 2aa <close>
return r;
1f1: 83 c4 10 add $0x10,%esp
}
1f4: 8d 65 f8 lea -0x8(%ebp),%esp
1f7: 89 f0 mov %esi,%eax
1f9: 5b pop %ebx
1fa: 5e pop %esi
1fb: 5d pop %ebp
1fc: c3 ret
1fd: 8d 76 00 lea 0x0(%esi),%esi
return -1;
200: be ff ff ff ff mov $0xffffffff,%esi
205: eb ed jmp 1f4 <stat+0x34>
207: 89 f6 mov %esi,%esi
209: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
00000210 <atoi>:
int
atoi(const char *s)
{
210: 55 push %ebp
211: 89 e5 mov %esp,%ebp
213: 53 push %ebx
214: 8b 4d 08 mov 0x8(%ebp),%ecx
int n;
n = 0;
while('0' <= *s && *s <= '9')
217: 0f be 11 movsbl (%ecx),%edx
21a: 8d 42 d0 lea -0x30(%edx),%eax
21d: 3c 09 cmp $0x9,%al
n = 0;
21f: b8 00 00 00 00 mov $0x0,%eax
while('0' <= *s && *s <= '9')
224: 77 1f ja 245 <atoi+0x35>
226: 8d 76 00 lea 0x0(%esi),%esi
229: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
n = n*10 + *s++ - '0';
230: 8d 04 80 lea (%eax,%eax,4),%eax
233: 83 c1 01 add $0x1,%ecx
236: 8d 44 42 d0 lea -0x30(%edx,%eax,2),%eax
while('0' <= *s && *s <= '9')
23a: 0f be 11 movsbl (%ecx),%edx
23d: 8d 5a d0 lea -0x30(%edx),%ebx
240: 80 fb 09 cmp $0x9,%bl
243: 76 eb jbe 230 <atoi+0x20>
return n;
}
245: 5b pop %ebx
246: 5d pop %ebp
247: c3 ret
248: 90 nop
249: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
00000250 <memmove>:
void*
memmove(void *vdst, const void *vsrc, int n)
{
250: 55 push %ebp
251: 89 e5 mov %esp,%ebp
253: 56 push %esi
254: 53 push %ebx
255: 8b 5d 10 mov 0x10(%ebp),%ebx
258: 8b 45 08 mov 0x8(%ebp),%eax
25b: 8b 75 0c mov 0xc(%ebp),%esi
char *dst;
const char *src;
dst = vdst;
src = vsrc;
while(n-- > 0)
25e: 85 db test %ebx,%ebx
260: 7e 14 jle 276 <memmove+0x26>
262: 31 d2 xor %edx,%edx
264: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
*dst++ = *src++;
268: 0f b6 0c 16 movzbl (%esi,%edx,1),%ecx
26c: 88 0c 10 mov %cl,(%eax,%edx,1)
26f: 83 c2 01 add $0x1,%edx
while(n-- > 0)
272: 39 d3 cmp %edx,%ebx
274: 75 f2 jne 268 <memmove+0x18>
return vdst;
}
276: 5b pop %ebx
277: 5e pop %esi
278: 5d pop %ebp
279: c3 ret
0000027a <fork>:
name: \
movl $SYS_ ## name, %eax; \
int $T_SYSCALL; \
ret
SYSCALL(fork)
27a: b8 01 00 00 00 mov $0x1,%eax
27f: cd 40 int $0x40
281: c3 ret
00000282 <exit>:
SYSCALL(exit)
282: b8 02 00 00 00 mov $0x2,%eax
287: cd 40 int $0x40
289: c3 ret
0000028a <wait>:
SYSCALL(wait)
28a: b8 03 00 00 00 mov $0x3,%eax
28f: cd 40 int $0x40
291: c3 ret
00000292 <pipe>:
SYSCALL(pipe)
292: b8 04 00 00 00 mov $0x4,%eax
297: cd 40 int $0x40
299: c3 ret
0000029a <read>:
SYSCALL(read)
29a: b8 05 00 00 00 mov $0x5,%eax
29f: cd 40 int $0x40
2a1: c3 ret
000002a2 <write>:
SYSCALL(write)
2a2: b8 10 00 00 00 mov $0x10,%eax
2a7: cd 40 int $0x40
2a9: c3 ret
000002aa <close>:
SYSCALL(close)
2aa: b8 15 00 00 00 mov $0x15,%eax
2af: cd 40 int $0x40
2b1: c3 ret
000002b2 <kill>:
SYSCALL(kill)
2b2: b8 06 00 00 00 mov $0x6,%eax
2b7: cd 40 int $0x40
2b9: c3 ret
000002ba <exec>:
SYSCALL(exec)
2ba: b8 07 00 00 00 mov $0x7,%eax
2bf: cd 40 int $0x40
2c1: c3 ret
000002c2 <open>:
SYSCALL(open)
2c2: b8 0f 00 00 00 mov $0xf,%eax
2c7: cd 40 int $0x40
2c9: c3 ret
000002ca <mknod>:
SYSCALL(mknod)
2ca: b8 11 00 00 00 mov $0x11,%eax
2cf: cd 40 int $0x40
2d1: c3 ret
000002d2 <unlink>:
SYSCALL(unlink)
2d2: b8 12 00 00 00 mov $0x12,%eax
2d7: cd 40 int $0x40
2d9: c3 ret
000002da <fstat>:
SYSCALL(fstat)
2da: b8 08 00 00 00 mov $0x8,%eax
2df: cd 40 int $0x40
2e1: c3 ret
000002e2 <link>:
SYSCALL(link)
2e2: b8 13 00 00 00 mov $0x13,%eax
2e7: cd 40 int $0x40
2e9: c3 ret
000002ea <mkdir>:
SYSCALL(mkdir)
2ea: b8 14 00 00 00 mov $0x14,%eax
2ef: cd 40 int $0x40
2f1: c3 ret
000002f2 <chdir>:
SYSCALL(chdir)
2f2: b8 09 00 00 00 mov $0x9,%eax
2f7: cd 40 int $0x40
2f9: c3 ret
000002fa <dup>:
SYSCALL(dup)
2fa: b8 0a 00 00 00 mov $0xa,%eax
2ff: cd 40 int $0x40
301: c3 ret
00000302 <getpid>:
SYSCALL(getpid)
302: b8 0b 00 00 00 mov $0xb,%eax
307: cd 40 int $0x40
309: c3 ret
0000030a <sbrk>:
SYSCALL(sbrk)
30a: b8 0c 00 00 00 mov $0xc,%eax
30f: cd 40 int $0x40
311: c3 ret
00000312 <sleep>:
SYSCALL(sleep)
312: b8 0d 00 00 00 mov $0xd,%eax
317: cd 40 int $0x40
319: c3 ret
0000031a <uptime>:
SYSCALL(uptime)
31a: b8 0e 00 00 00 mov $0xe,%eax
31f: cd 40 int $0x40
321: c3 ret
00000322 <hello>:
SYSCALL(hello)
322: b8 16 00 00 00 mov $0x16,%eax
327: cd 40 int $0x40
329: c3 ret
0000032a <hello_name>:
SYSCALL(hello_name)
32a: b8 17 00 00 00 mov $0x17,%eax
32f: cd 40 int $0x40
331: c3 ret
00000332 <get_num_proc>:
SYSCALL(get_num_proc)
332: b8 18 00 00 00 mov $0x18,%eax
337: cd 40 int $0x40
339: c3 ret
0000033a <get_max_pid>:
SYSCALL(get_max_pid)
33a: b8 19 00 00 00 mov $0x19,%eax
33f: cd 40 int $0x40
341: c3 ret
00000342 <get_proc_info>:
SYSCALL(get_proc_info)
342: b8 1a 00 00 00 mov $0x1a,%eax
347: cd 40 int $0x40
349: c3 ret
0000034a <get_prior>:
SYSCALL(get_prior)
34a: b8 1b 00 00 00 mov $0x1b,%eax
34f: cd 40 int $0x40
351: c3 ret
00000352 <set_prior>:
SYSCALL(set_prior)
352: b8 1c 00 00 00 mov $0x1c,%eax
357: cd 40 int $0x40
359: c3 ret
35a: 66 90 xchg %ax,%ax
35c: 66 90 xchg %ax,%ax
35e: 66 90 xchg %ax,%ax
00000360 <printint>:
write(fd, &c, 1);
}
static void
printint(int fd, int xx, int base, int sgn)
{
360: 55 push %ebp
361: 89 e5 mov %esp,%ebp
363: 57 push %edi
364: 56 push %esi
365: 53 push %ebx
366: 83 ec 3c sub $0x3c,%esp
char buf[16];
int i, neg;
uint x;
neg = 0;
if(sgn && xx < 0){
369: 85 d2 test %edx,%edx
{
36b: 89 45 c0 mov %eax,-0x40(%ebp)
neg = 1;
x = -xx;
36e: 89 d0 mov %edx,%eax
if(sgn && xx < 0){
370: 79 76 jns 3e8 <printint+0x88>
372: f6 45 08 01 testb $0x1,0x8(%ebp)
376: 74 70 je 3e8 <printint+0x88>
x = -xx;
378: f7 d8 neg %eax
neg = 1;
37a: c7 45 c4 01 00 00 00 movl $0x1,-0x3c(%ebp)
} else {
x = xx;
}
i = 0;
381: 31 f6 xor %esi,%esi
383: 8d 5d d7 lea -0x29(%ebp),%ebx
386: eb 0a jmp 392 <printint+0x32>
388: 90 nop
389: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
do{
buf[i++] = digits[x % base];
390: 89 fe mov %edi,%esi
392: 31 d2 xor %edx,%edx
394: 8d 7e 01 lea 0x1(%esi),%edi
397: f7 f1 div %ecx
399: 0f b6 92 70 07 00 00 movzbl 0x770(%edx),%edx
}while((x /= base) != 0);
3a0: 85 c0 test %eax,%eax
buf[i++] = digits[x % base];
3a2: 88 14 3b mov %dl,(%ebx,%edi,1)
}while((x /= base) != 0);
3a5: 75 e9 jne 390 <printint+0x30>
if(neg)
3a7: 8b 45 c4 mov -0x3c(%ebp),%eax
3aa: 85 c0 test %eax,%eax
3ac: 74 08 je 3b6 <printint+0x56>
buf[i++] = '-';
3ae: c6 44 3d d8 2d movb $0x2d,-0x28(%ebp,%edi,1)
3b3: 8d 7e 02 lea 0x2(%esi),%edi
3b6: 8d 74 3d d7 lea -0x29(%ebp,%edi,1),%esi
3ba: 8b 7d c0 mov -0x40(%ebp),%edi
3bd: 8d 76 00 lea 0x0(%esi),%esi
3c0: 0f b6 06 movzbl (%esi),%eax
write(fd, &c, 1);
3c3: 83 ec 04 sub $0x4,%esp
3c6: 83 ee 01 sub $0x1,%esi
3c9: 6a 01 push $0x1
3cb: 53 push %ebx
3cc: 57 push %edi
3cd: 88 45 d7 mov %al,-0x29(%ebp)
3d0: e8 cd fe ff ff call 2a2 <write>
while(--i >= 0)
3d5: 83 c4 10 add $0x10,%esp
3d8: 39 de cmp %ebx,%esi
3da: 75 e4 jne 3c0 <printint+0x60>
putc(fd, buf[i]);
}
3dc: 8d 65 f4 lea -0xc(%ebp),%esp
3df: 5b pop %ebx
3e0: 5e pop %esi
3e1: 5f pop %edi
3e2: 5d pop %ebp
3e3: c3 ret
3e4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
neg = 0;
3e8: c7 45 c4 00 00 00 00 movl $0x0,-0x3c(%ebp)
3ef: eb 90 jmp 381 <printint+0x21>
3f1: eb 0d jmp 400 <printf>
3f3: 90 nop
3f4: 90 nop
3f5: 90 nop
3f6: 90 nop
3f7: 90 nop
3f8: 90 nop
3f9: 90 nop
3fa: 90 nop
3fb: 90 nop
3fc: 90 nop
3fd: 90 nop
3fe: 90 nop
3ff: 90 nop
00000400 <printf>:
// Print to the given fd. Only understands %d, %x, %p, %s.
void
printf(int fd, const char *fmt, ...)
{
400: 55 push %ebp
401: 89 e5 mov %esp,%ebp
403: 57 push %edi
404: 56 push %esi
405: 53 push %ebx
406: 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++){
409: 8b 75 0c mov 0xc(%ebp),%esi
40c: 0f b6 1e movzbl (%esi),%ebx
40f: 84 db test %bl,%bl
411: 0f 84 b3 00 00 00 je 4ca <printf+0xca>
ap = (uint*)(void*)&fmt + 1;
417: 8d 45 10 lea 0x10(%ebp),%eax
41a: 83 c6 01 add $0x1,%esi
state = 0;
41d: 31 ff xor %edi,%edi
ap = (uint*)(void*)&fmt + 1;
41f: 89 45 d4 mov %eax,-0x2c(%ebp)
422: eb 2f jmp 453 <printf+0x53>
424: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
c = fmt[i] & 0xff;
if(state == 0){
if(c == '%'){
428: 83 f8 25 cmp $0x25,%eax
42b: 0f 84 a7 00 00 00 je 4d8 <printf+0xd8>
write(fd, &c, 1);
431: 8d 45 e2 lea -0x1e(%ebp),%eax
434: 83 ec 04 sub $0x4,%esp
437: 88 5d e2 mov %bl,-0x1e(%ebp)
43a: 6a 01 push $0x1
43c: 50 push %eax
43d: ff 75 08 pushl 0x8(%ebp)
440: e8 5d fe ff ff call 2a2 <write>
445: 83 c4 10 add $0x10,%esp
448: 83 c6 01 add $0x1,%esi
for(i = 0; fmt[i]; i++){
44b: 0f b6 5e ff movzbl -0x1(%esi),%ebx
44f: 84 db test %bl,%bl
451: 74 77 je 4ca <printf+0xca>
if(state == 0){
453: 85 ff test %edi,%edi
c = fmt[i] & 0xff;
455: 0f be cb movsbl %bl,%ecx
458: 0f b6 c3 movzbl %bl,%eax
if(state == 0){
45b: 74 cb je 428 <printf+0x28>
state = '%';
} else {
putc(fd, c);
}
} else if(state == '%'){
45d: 83 ff 25 cmp $0x25,%edi
460: 75 e6 jne 448 <printf+0x48>
if(c == 'd'){
462: 83 f8 64 cmp $0x64,%eax
465: 0f 84 05 01 00 00 je 570 <printf+0x170>
printint(fd, *ap, 10, 1);
ap++;
} else if(c == 'x' || c == 'p'){
46b: 81 e1 f7 00 00 00 and $0xf7,%ecx
471: 83 f9 70 cmp $0x70,%ecx
474: 74 72 je 4e8 <printf+0xe8>
printint(fd, *ap, 16, 0);
ap++;
} else if(c == 's'){
476: 83 f8 73 cmp $0x73,%eax
479: 0f 84 99 00 00 00 je 518 <printf+0x118>
s = "(null)";
while(*s != 0){
putc(fd, *s);
s++;
}
} else if(c == 'c'){
47f: 83 f8 63 cmp $0x63,%eax
482: 0f 84 08 01 00 00 je 590 <printf+0x190>
putc(fd, *ap);
ap++;
} else if(c == '%'){
488: 83 f8 25 cmp $0x25,%eax
48b: 0f 84 ef 00 00 00 je 580 <printf+0x180>
write(fd, &c, 1);
491: 8d 45 e7 lea -0x19(%ebp),%eax
494: 83 ec 04 sub $0x4,%esp
497: c6 45 e7 25 movb $0x25,-0x19(%ebp)
49b: 6a 01 push $0x1
49d: 50 push %eax
49e: ff 75 08 pushl 0x8(%ebp)
4a1: e8 fc fd ff ff call 2a2 <write>
4a6: 83 c4 0c add $0xc,%esp
4a9: 8d 45 e6 lea -0x1a(%ebp),%eax
4ac: 88 5d e6 mov %bl,-0x1a(%ebp)
4af: 6a 01 push $0x1
4b1: 50 push %eax
4b2: ff 75 08 pushl 0x8(%ebp)
4b5: 83 c6 01 add $0x1,%esi
} else {
// Unknown % sequence. Print it to draw attention.
putc(fd, '%');
putc(fd, c);
}
state = 0;
4b8: 31 ff xor %edi,%edi
write(fd, &c, 1);
4ba: e8 e3 fd ff ff call 2a2 <write>
for(i = 0; fmt[i]; i++){
4bf: 0f b6 5e ff movzbl -0x1(%esi),%ebx
write(fd, &c, 1);
4c3: 83 c4 10 add $0x10,%esp
for(i = 0; fmt[i]; i++){
4c6: 84 db test %bl,%bl
4c8: 75 89 jne 453 <printf+0x53>
}
}
}
4ca: 8d 65 f4 lea -0xc(%ebp),%esp
4cd: 5b pop %ebx
4ce: 5e pop %esi
4cf: 5f pop %edi
4d0: 5d pop %ebp
4d1: c3 ret
4d2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
state = '%';
4d8: bf 25 00 00 00 mov $0x25,%edi
4dd: e9 66 ff ff ff jmp 448 <printf+0x48>
4e2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
printint(fd, *ap, 16, 0);
4e8: 83 ec 0c sub $0xc,%esp
4eb: b9 10 00 00 00 mov $0x10,%ecx
4f0: 6a 00 push $0x0
4f2: 8b 7d d4 mov -0x2c(%ebp),%edi
4f5: 8b 45 08 mov 0x8(%ebp),%eax
4f8: 8b 17 mov (%edi),%edx
4fa: e8 61 fe ff ff call 360 <printint>
ap++;
4ff: 89 f8 mov %edi,%eax
501: 83 c4 10 add $0x10,%esp
state = 0;
504: 31 ff xor %edi,%edi
ap++;
506: 83 c0 04 add $0x4,%eax
509: 89 45 d4 mov %eax,-0x2c(%ebp)
50c: e9 37 ff ff ff jmp 448 <printf+0x48>
511: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
s = (char*)*ap;
518: 8b 45 d4 mov -0x2c(%ebp),%eax
51b: 8b 08 mov (%eax),%ecx
ap++;
51d: 83 c0 04 add $0x4,%eax
520: 89 45 d4 mov %eax,-0x2c(%ebp)
if(s == 0)
523: 85 c9 test %ecx,%ecx
525: 0f 84 8e 00 00 00 je 5b9 <printf+0x1b9>
while(*s != 0){
52b: 0f b6 01 movzbl (%ecx),%eax
state = 0;
52e: 31 ff xor %edi,%edi
s = (char*)*ap;
530: 89 cb mov %ecx,%ebx
while(*s != 0){
532: 84 c0 test %al,%al
534: 0f 84 0e ff ff ff je 448 <printf+0x48>
53a: 89 75 d0 mov %esi,-0x30(%ebp)
53d: 89 de mov %ebx,%esi
53f: 8b 5d 08 mov 0x8(%ebp),%ebx
542: 8d 7d e3 lea -0x1d(%ebp),%edi
545: 8d 76 00 lea 0x0(%esi),%esi
write(fd, &c, 1);
548: 83 ec 04 sub $0x4,%esp
s++;
54b: 83 c6 01 add $0x1,%esi
54e: 88 45 e3 mov %al,-0x1d(%ebp)
write(fd, &c, 1);
551: 6a 01 push $0x1
553: 57 push %edi
554: 53 push %ebx
555: e8 48 fd ff ff call 2a2 <write>
while(*s != 0){
55a: 0f b6 06 movzbl (%esi),%eax
55d: 83 c4 10 add $0x10,%esp
560: 84 c0 test %al,%al
562: 75 e4 jne 548 <printf+0x148>
564: 8b 75 d0 mov -0x30(%ebp),%esi
state = 0;
567: 31 ff xor %edi,%edi
569: e9 da fe ff ff jmp 448 <printf+0x48>
56e: 66 90 xchg %ax,%ax
printint(fd, *ap, 10, 1);
570: 83 ec 0c sub $0xc,%esp
573: b9 0a 00 00 00 mov $0xa,%ecx
578: 6a 01 push $0x1
57a: e9 73 ff ff ff jmp 4f2 <printf+0xf2>
57f: 90 nop
write(fd, &c, 1);
580: 83 ec 04 sub $0x4,%esp
583: 88 5d e5 mov %bl,-0x1b(%ebp)
586: 8d 45 e5 lea -0x1b(%ebp),%eax
589: 6a 01 push $0x1
58b: e9 21 ff ff ff jmp 4b1 <printf+0xb1>
putc(fd, *ap);
590: 8b 7d d4 mov -0x2c(%ebp),%edi
write(fd, &c, 1);
593: 83 ec 04 sub $0x4,%esp
putc(fd, *ap);
596: 8b 07 mov (%edi),%eax
write(fd, &c, 1);
598: 6a 01 push $0x1
ap++;
59a: 83 c7 04 add $0x4,%edi
putc(fd, *ap);
59d: 88 45 e4 mov %al,-0x1c(%ebp)
write(fd, &c, 1);
5a0: 8d 45 e4 lea -0x1c(%ebp),%eax
5a3: 50 push %eax
5a4: ff 75 08 pushl 0x8(%ebp)
5a7: e8 f6 fc ff ff call 2a2 <write>
ap++;
5ac: 89 7d d4 mov %edi,-0x2c(%ebp)
5af: 83 c4 10 add $0x10,%esp
state = 0;
5b2: 31 ff xor %edi,%edi
5b4: e9 8f fe ff ff jmp 448 <printf+0x48>
s = "(null)";
5b9: bb 69 07 00 00 mov $0x769,%ebx
while(*s != 0){
5be: b8 28 00 00 00 mov $0x28,%eax
5c3: e9 72 ff ff ff jmp 53a <printf+0x13a>
5c8: 66 90 xchg %ax,%ax
5ca: 66 90 xchg %ax,%ax
5cc: 66 90 xchg %ax,%ax
5ce: 66 90 xchg %ax,%ax
000005d0 <free>:
static Header base;
static Header *freep;
void
free(void *ap)
{
5d0: 55 push %ebp
Header *bp, *p;
bp = (Header*)ap - 1;
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
5d1: a1 14 0a 00 00 mov 0xa14,%eax
{
5d6: 89 e5 mov %esp,%ebp
5d8: 57 push %edi
5d9: 56 push %esi
5da: 53 push %ebx
5db: 8b 5d 08 mov 0x8(%ebp),%ebx
bp = (Header*)ap - 1;
5de: 8d 4b f8 lea -0x8(%ebx),%ecx
5e1: 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)
5e8: 39 c8 cmp %ecx,%eax
5ea: 8b 10 mov (%eax),%edx
5ec: 73 32 jae 620 <free+0x50>
5ee: 39 d1 cmp %edx,%ecx
5f0: 72 04 jb 5f6 <free+0x26>
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
5f2: 39 d0 cmp %edx,%eax
5f4: 72 32 jb 628 <free+0x58>
break;
if(bp + bp->s.size == p->s.ptr){
5f6: 8b 73 fc mov -0x4(%ebx),%esi
5f9: 8d 3c f1 lea (%ecx,%esi,8),%edi
5fc: 39 fa cmp %edi,%edx
5fe: 74 30 je 630 <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;
600: 89 53 f8 mov %edx,-0x8(%ebx)
if(p + p->s.size == bp){
603: 8b 50 04 mov 0x4(%eax),%edx
606: 8d 34 d0 lea (%eax,%edx,8),%esi
609: 39 f1 cmp %esi,%ecx
60b: 74 3a je 647 <free+0x77>
p->s.size += bp->s.size;
p->s.ptr = bp->s.ptr;
} else
p->s.ptr = bp;
60d: 89 08 mov %ecx,(%eax)
freep = p;
60f: a3 14 0a 00 00 mov %eax,0xa14
}
614: 5b pop %ebx
615: 5e pop %esi
616: 5f pop %edi
617: 5d pop %ebp
618: c3 ret
619: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
620: 39 d0 cmp %edx,%eax
622: 72 04 jb 628 <free+0x58>
624: 39 d1 cmp %edx,%ecx
626: 72 ce jb 5f6 <free+0x26>
{
628: 89 d0 mov %edx,%eax
62a: eb bc jmp 5e8 <free+0x18>
62c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
bp->s.size += p->s.ptr->s.size;
630: 03 72 04 add 0x4(%edx),%esi
633: 89 73 fc mov %esi,-0x4(%ebx)
bp->s.ptr = p->s.ptr->s.ptr;
636: 8b 10 mov (%eax),%edx
638: 8b 12 mov (%edx),%edx
63a: 89 53 f8 mov %edx,-0x8(%ebx)
if(p + p->s.size == bp){
63d: 8b 50 04 mov 0x4(%eax),%edx
640: 8d 34 d0 lea (%eax,%edx,8),%esi
643: 39 f1 cmp %esi,%ecx
645: 75 c6 jne 60d <free+0x3d>
p->s.size += bp->s.size;
647: 03 53 fc add -0x4(%ebx),%edx
freep = p;
64a: a3 14 0a 00 00 mov %eax,0xa14
p->s.size += bp->s.size;
64f: 89 50 04 mov %edx,0x4(%eax)
p->s.ptr = bp->s.ptr;
652: 8b 53 f8 mov -0x8(%ebx),%edx
655: 89 10 mov %edx,(%eax)
}
657: 5b pop %ebx
658: 5e pop %esi
659: 5f pop %edi
65a: 5d pop %ebp
65b: c3 ret
65c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
00000660 <malloc>:
return freep;
}
void*
malloc(uint nbytes)
{
660: 55 push %ebp
661: 89 e5 mov %esp,%ebp
663: 57 push %edi
664: 56 push %esi
665: 53 push %ebx
666: 83 ec 0c sub $0xc,%esp
Header *p, *prevp;
uint nunits;
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
669: 8b 45 08 mov 0x8(%ebp),%eax
if((prevp = freep) == 0){
66c: 8b 15 14 0a 00 00 mov 0xa14,%edx
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
672: 8d 78 07 lea 0x7(%eax),%edi
675: c1 ef 03 shr $0x3,%edi
678: 83 c7 01 add $0x1,%edi
if((prevp = freep) == 0){
67b: 85 d2 test %edx,%edx
67d: 0f 84 9d 00 00 00 je 720 <malloc+0xc0>
683: 8b 02 mov (%edx),%eax
685: 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){
688: 39 cf cmp %ecx,%edi
68a: 76 6c jbe 6f8 <malloc+0x98>
68c: 81 ff 00 10 00 00 cmp $0x1000,%edi
692: bb 00 10 00 00 mov $0x1000,%ebx
697: 0f 43 df cmovae %edi,%ebx
p = sbrk(nu * sizeof(Header));
69a: 8d 34 dd 00 00 00 00 lea 0x0(,%ebx,8),%esi
6a1: eb 0e jmp 6b1 <malloc+0x51>
6a3: 90 nop
6a4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
6a8: 8b 02 mov (%edx),%eax
if(p->s.size >= nunits){
6aa: 8b 48 04 mov 0x4(%eax),%ecx
6ad: 39 f9 cmp %edi,%ecx
6af: 73 47 jae 6f8 <malloc+0x98>
p->s.size = nunits;
}
freep = prevp;
return (void*)(p + 1);
}
if(p == freep)
6b1: 39 05 14 0a 00 00 cmp %eax,0xa14
6b7: 89 c2 mov %eax,%edx
6b9: 75 ed jne 6a8 <malloc+0x48>
p = sbrk(nu * sizeof(Header));
6bb: 83 ec 0c sub $0xc,%esp
6be: 56 push %esi
6bf: e8 46 fc ff ff call 30a <sbrk>
if(p == (char*)-1)
6c4: 83 c4 10 add $0x10,%esp
6c7: 83 f8 ff cmp $0xffffffff,%eax
6ca: 74 1c je 6e8 <malloc+0x88>
hp->s.size = nu;
6cc: 89 58 04 mov %ebx,0x4(%eax)
free((void*)(hp + 1));
6cf: 83 ec 0c sub $0xc,%esp
6d2: 83 c0 08 add $0x8,%eax
6d5: 50 push %eax
6d6: e8 f5 fe ff ff call 5d0 <free>
return freep;
6db: 8b 15 14 0a 00 00 mov 0xa14,%edx
if((p = morecore(nunits)) == 0)
6e1: 83 c4 10 add $0x10,%esp
6e4: 85 d2 test %edx,%edx
6e6: 75 c0 jne 6a8 <malloc+0x48>
return 0;
}
}
6e8: 8d 65 f4 lea -0xc(%ebp),%esp
return 0;
6eb: 31 c0 xor %eax,%eax
}
6ed: 5b pop %ebx
6ee: 5e pop %esi
6ef: 5f pop %edi
6f0: 5d pop %ebp
6f1: c3 ret
6f2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
if(p->s.size == nunits)
6f8: 39 cf cmp %ecx,%edi
6fa: 74 54 je 750 <malloc+0xf0>
p->s.size -= nunits;
6fc: 29 f9 sub %edi,%ecx
6fe: 89 48 04 mov %ecx,0x4(%eax)
p += p->s.size;
701: 8d 04 c8 lea (%eax,%ecx,8),%eax
p->s.size = nunits;
704: 89 78 04 mov %edi,0x4(%eax)
freep = prevp;
707: 89 15 14 0a 00 00 mov %edx,0xa14
}
70d: 8d 65 f4 lea -0xc(%ebp),%esp
return (void*)(p + 1);
710: 83 c0 08 add $0x8,%eax
}
713: 5b pop %ebx
714: 5e pop %esi
715: 5f pop %edi
716: 5d pop %ebp
717: c3 ret
718: 90 nop
719: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
base.s.ptr = freep = prevp = &base;
720: c7 05 14 0a 00 00 18 movl $0xa18,0xa14
727: 0a 00 00
72a: c7 05 18 0a 00 00 18 movl $0xa18,0xa18
731: 0a 00 00
base.s.size = 0;
734: b8 18 0a 00 00 mov $0xa18,%eax
739: c7 05 1c 0a 00 00 00 movl $0x0,0xa1c
740: 00 00 00
743: e9 44 ff ff ff jmp 68c <malloc+0x2c>
748: 90 nop
749: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
prevp->s.ptr = p->s.ptr;
750: 8b 08 mov (%eax),%ecx
752: 89 0a mov %ecx,(%edx)
754: eb b1 jmp 707 <malloc+0xa7>
|
; uint in_JoyTimex1(void)
; 2002 aralbrec
XLIB in_JoyTimex1
; exit : A = HL = F000RLDU active high
; uses : AF,HL
; WARNING: farts around with the AY registers -- might
; conflict with an AY sound routine in an interrupt -
; haven't decided what to do about this yet. If you
; have an AY player in an interrupt you can either
; disable interrupts while reading Timex joysticks
; (and risk missing a beat) or sync joystick reads
; with interrupts, eg by putting joystick reads
; into the interrupt routine.
.in_JoyTimex1
ld a,7
out ($f5),a ; select R7 on AY chip
in a,($f6) ; read R7
and $bf ; bit 6 = 0 selects i/o port A read
out ($f6),a
ld a,14
out ($f5),a ; select R14, attached to i/o port A
ld a,2 ; left joystick
in a,($f6)
cpl
and $8f
ld l,a
ld h,0
ret
|
; ================================================================
; Variables
; ================================================================
if !def(incVars)
incVars set 1
SECTION "Variables",HRAM
; ================================================================
; Global variables
; ================================================================
VBACheck ds 1 ; variable used to determine if we're running in VBA
sys_btnHold ds 1 ; held buttons
sys_btnPress ds 1 ; pressed buttons
RasterTime ds 1
if EngineSpeed != -1
VBlankOccurred ds 1
endc
; ================================================================
; Project-specific variables
; ================================================================
; Insert project-specific variables here.
CurrentSong ds 1
SECTION "Visualizer Variables",WRAM0[$c000]
if def(Visualizer)
Sprites: ds 160
WaveDisplayBuffer ds 64
VisualizerTempWave ds 16
DepackedWaveDelta ds 33
VisualizerVarsStart:
CH1Pulse ds 1
CH2Pulse ds 1
CH4Noise ds 1
CH1ComputedFreq ds 2
CH2ComputedFreq ds 2
CH3ComputedFreq ds 2
CH1PianoPos ds 1
CH2PianoPos ds 1
CH3PianoPos ds 1
CH1OutputLevel ds 1
CH2OutputLevel ds 1
CH4OutputLevel ds 1
CH1TempEnvelope ds 1
CH2TempEnvelope ds 1
CH4TempEnvelope ds 1
CH1EnvelopeCounter ds 1
CH2EnvelopeCounter ds 1
CH4EnvelopeCounter ds 1
EnvelopeTimer ds 1
VisualizerVarsEnd:
RasterTimeChar ds 2
SongIDChar ds 3
endc
EmulatorCheck ds 1
; ================================================================
SECTION "Temporary register storage space",HRAM
tempAF ds 2
tempBC ds 2
tempDE ds 2
tempHL ds 2
tempSP ds 2
tempPC ds 2
tempIF ds 1
tempIE ds 1
OAM_DMA ds 10
endc
|
#Demonstrates printing an integer
#Integer to print must be in register $a0
#1 must be in register $v0
li $t0, 45 #Loads the constant 45 (0x2d) to $t0
li $t1, 79 #Loads the constant 79 (0x4f) to $t1
move $a0, $t0 #Copies $t0 to $a0
li $v0, 1 #Sets the system call code for printing an integer
syscall #1 is in $v0, so the integer in $a0 is printed
move $a0, $t1 #Copies $t1 to $a0
#No need to set the system call code again; It is already set to 1 for printing an integer
syscall #1 is in $v0, so the integer in $a0 is printed
#Output of this program is: 4579 |
// File name: projects/04/KeyboardLoop.asm
// Runs an infinite loop that listens to the keyboard input.
// When a key is pressed (any key), the program does something.
@color //Initialize color to be black -1
M=-1
(REDRAW)
@SCREEN
D=A
@addr
M=D //addr = 16384
// (screen's base address)
@8192 //This is the number to be loaded to widthTimesHeight (256*32)
D=A
@widthTimesHeight
M=D
@n
M=D // n = widthTimesHeight
@i
M=0 // i = 0
@DRAWLOOP
0;JMP
(DRAWLOOP)
@i
D=M
@n
D=D-M
@END
D;JGT // if i>n goto END
@color
D=M
@addr
A=M
// RAM can be 0 or -1
M=D //RAM[addr]=-1 or 0 makes 16 pixels black or white
@i
M=M+1 // i = i+1
@1
D=A
@addr
M=D+M //addr = addr + 32
@DRAWLOOP
0;JMP // goto DRAWLOOP
(END)
@KBD
D=M
@CHANGETOWHITE
D;JGT
@color
M=-1
@REDRAW
0;JMP // goto LOOP
(CHANGETOWHITE)
@color
M=0
@REDRAW
0;JMP
|
/*This file is part of the FEBio Studio source code and is licensed under the MIT license
listed below.
See Copyright-FEBio-Studio.txt for details.
Copyright (c) 2021 University of Utah, The Trustees of Columbia University in
the City of New York, and others.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.*/
// FEShellPatch.cpp: implementation of the FEShellPatch class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "FEShellPatch.h"
#include <GeomLib/GPrimitive.h>
#include <GeomLib/geom.h>
#include <MeshLib/FEMesh.h>
#include "FEMultiQuadMesh.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
FEShellPatch::FEShellPatch(GPatch* po)
{
m_pobj = po;
m_t = 0.01;
m_nx = m_ny = 10;
AddDoubleParam(m_t, "t", "Thickness");
AddIntParam(m_nx, "nx", "Nx");
AddIntParam(m_ny, "ny", "Ny");
AddChoiceParam(0, "elem_type", "Element Type")->SetEnumNames("QUAD4\0QUAD8\0QUAD9\0");
}
FEMesh* FEShellPatch::BuildMesh()
{
// get mesh parameters
m_nx = GetIntValue(NX);
m_ny = GetIntValue(NY);
int elemType = GetIntValue(ELEM_TYPE);
// create the MB nodes
FEMultiQuadMesh MQ;
MQ.Build(m_pobj);
MQ.SetFaceSizes(0, m_nx, m_ny);
// update the MB data
switch (elemType)
{
case 0: MQ.SetElementType(FE_QUAD4); break;
case 1: MQ.SetElementType(FE_QUAD8); break;
case 2: MQ.SetElementType(FE_QUAD9); break;
};
MQ.UpdateMQ();
// create the MB
FEMesh* pm = MQ.BuildMesh();
// assign shell thickness
double t = GetFloatValue(T);
pm->SetUniformShellThickness(t);
return pm;
}
//////////////////////////////////////////////////////////////////////
// FECylndricalPatch
//////////////////////////////////////////////////////////////////////
FECylndricalPatch::FECylndricalPatch(GCylindricalPatch* po)
{
m_pobj = po;
m_t = 0.01;
m_nx = m_ny = 10;
AddDoubleParam(m_t, "t", "Thickness");
AddIntParam(m_nx, "nx", "Nx");
AddIntParam(m_ny, "ny", "Ny");
AddChoiceParam(0, "elem_type", "Element Type")->SetEnumNames("QUAD4\0QUAD8\0QUAD9\0");
}
FEMesh* FECylndricalPatch::BuildMesh()
{
return BuildMultiQuadMesh();
}
FEMesh* FECylndricalPatch::BuildMultiQuadMesh()
{
// build the quad mesh data
FEMultiQuadMesh MQ;
MQ.Build(m_pobj);
// set sizes
int nx = GetIntValue(NX);
int ny = GetIntValue(NY);
MQ.SetFaceSizes(0, nx, ny);
int elemType = GetIntValue(ELEM_TYPE);
switch (elemType)
{
case 0: MQ.SetElementType(FE_QUAD4); break;
case 1: MQ.SetElementType(FE_QUAD8); break;
case 2: MQ.SetElementType(FE_QUAD9); break;
};
// Build the mesh
FEMesh* pm = MQ.BuildMesh();
if (pm == nullptr) return nullptr;
// assign shell thickness
double t = GetFloatValue(T);
pm->SetUniformShellThickness(t);
return pm;
}
|
; A184747: floor(n*s+h-h*s), where s=1+sqrt(5), h=1/2; complement of A184746.
; 2,5,8,11,15,18,21,24,28,31,34,37,40,44,47,50,53,57,60,63,66,70,73,76,79,83,86,89,92,95,99,102,105,108,112,115,118,121,125,128,131,134,138,141,144,147,150,154,157,160,163,167,170,173,176,180,183,186,189,193,196,199,202,205,209,212,215,218,222,225,228,231,235,238,241,244,248,251,254,257,261,264,267,270,273,277,280,283,286,290,293,296,299,303,306,309,312,316,319,322,325,328,332,335,338,341,345,348,351,354,358,361,364,367,371,374,377,380,383,387
mov $5,$0
add $5,1
mov $11,$0
lpb $5
mov $0,$11
sub $5,1
sub $0,$5
mov $7,$0
mov $9,2
lpb $9
mov $0,$7
sub $9,1
add $0,$9
sub $0,1
mov $3,$0
add $3,1
mul $0,$3
mov $2,4
mov $4,$0
mul $4,5
add $4,1
mov $6,1
lpb $2
lpb $4
add $6,2
trn $4,$6
lpe
sub $2,1
lpe
div $6,2
mov $10,$9
lpb $10
mov $8,$6
sub $10,1
lpe
lpe
lpb $7
mov $7,0
sub $8,$6
lpe
mov $6,$8
add $6,1
add $1,$6
lpe
|
# programa que pide dos valores y muestra la suma de ambos.
.data
cadena1: .asciiz "Introduce el primer valor: "
cadena2: .asciiz "Introduce el segundo el valor: "
cadena3: .asciiz "La suma es: "
.text
# imprimir la cadena 1.
li $v0, 4
la $a0, cadena1
syscall
# leer el valor
li $v0, 5
syscall
move $t1, $v0
# imprimir la cadena 2.
li $v0, 4
la $a0, cadena2
syscall
# leer el valor
li $v0, 5
syscall
move $t2, $v0
add $t3, $t1, $t2
li $v0, 4
la $a0, cadena3
syscall
li $v0, 1
move $a0, $t3
syscall
|
<%
from pwnlib.shellcraft import common
from pwnlib.shellcraft import i386
from socket import htons
%>
<%page args="port"/>
<%docstring>
Args:
port(int): the listening port
Waits for a connection. Leaves socket in EBP.
ipv4 only
</%docstring>
<%
acceptloop = common.label("acceptloop")
looplabel = common.label("loop")
%>
${acceptloop}:
/* Listens for and accepts a connection on ${int(port)}d forever */
/* Socket file descriptor is placed in EBP */
/* sock = socket(AF_INET, SOCK_STREAM, 0) */
${i386.linux.push(0)}
${i386.linux.push('SOCK_STREAM')}
${i386.linux.push('AF_INET')}
${i386.linux.syscall('SYS_socketcall', 'SYS_socketcall_socket', 'esp')}
${i386.linux.mov('esi', 'eax')} /* keep socket fd */
/* bind(sock, &addr, sizeof addr); // sizeof addr == 0x10 */
${i386.linux.push(0)}
/* ${htons(port)} == htons(${port}) */
${i386.linux.push('AF_INET | (%d << 16)' % htons(port))}
${i386.linux.mov('ecx', 'esp')}
${i386.linux.push(0x10)} /* sizeof addr */
${i386.linux.push('ecx')} /* &addr */
${i386.linux.push('eax')} /* sock */
${i386.linux.syscall('SYS_socketcall', 'SYS_socketcall_bind', 'esp')}
/* listen(sock, whatever) */
${i386.linux.syscall('SYS_socketcall', 'SYS_socketcall_listen')}
${looplabel}:
/* accept(sock, NULL, NULL) */
${i386.linux.push(0x0)}
${i386.linux.push('esi')} /* sock */
${i386.linux.syscall('SYS_socketcall', 'SYS_socketcall_accept', 'esp')}
${i386.linux.mov('ebp', 'eax')} /* keep in-comming socket fd */
${i386.linux.syscall('SYS_fork')}
xchg eax, edi
test edi, edi
${i386.linux.mov('ebx', 'ebp')}
cmovz ebx, esi /* on child we close the server sock instead */
/* close(sock) */
${i386.linux.syscall('SYS_close', 'ebx')}
test edi, edi
jnz ${looplabel}
|
global _main
extern _printf
section .data
char: db 'A'
msg_ok: db 'memset() works as expected.', 10, 0
msg_fail: db 'memset() doesnt work as expected.', 10, 0
section .text
my_memset:
mov edi, [esp + 4]
mov al, byte [esp + 8h]
mov ecx, [esp + 0Ch]
rep stosb
mov eax, [esp + 4]
ret
_main:
push ebp
mov ebp, esp
sub esp, 0Ah
push 0Ah
mov al, byte [char]
push eax
lea eax, [ebp-0Ah]
push eax
call my_memset
add esp, 0Ch
lea edi, [ebp-0Ah]
mov al, [char]
mov ecx, 0Ah
repe scasb
test ecx, ecx
jnz _main_fail
push msg_ok
jmp _main_exit
_main_fail:
push msg_fail
_main_exit:
call _printf
add esp, 4
add esp, 0Ah
mov esp, ebp
pop ebp
ret
|
; itrans.asm
; inverse transform of block 4x4
.686
.mmx
.xmm
.MODEL flat, C
; *************************************************************************
.DATA
ALIGN 16
h_add_1_03 dw 1, 1, 2, 1
h_add_1_12 dw 1, -1, 1, -2
const32 dd 32, 32
const0 dw 0, 0, 0, 0
; structures
;member equ 0h
.CODE
; parameters
dest equ [esp+4]
pred equ [esp+8]
src equ [esp+12]
stride equ [esp+16]
var0 equ qword ptr[edx]
var1 equ qword ptr[edx+08h]
var2 equ qword ptr[edx+10h]
var3 equ qword ptr[edx+18h]
; *************************************************************************
; new proc
; *************************************************************************
;local variables
ALIGN 16
inverse_transform4x4_asm PROC
lea edx, [esp-32] ; temp buffer
mov eax, src
and edx, -32 ; aligned var_array fit in one cache line
movq mm0, [eax] ; src[0 1 2 3]
movq mm1, [eax+8] ; src[4 5 6 7]
movq mm2, [eax+16] ; src[8 9 a b]
movq mm3, [eax+24] ; src[c d e f]
pshufw mm4, mm0, 0d8h ; src[0 2 1 3]
pshufw mm5, mm1, 0d8h ; src[4 6 5 7]
pshufw mm0, mm0, 0d8h ; src[0 2 1 3]
pshufw mm1, mm1, 0d8h ; src[4 6 5 7]
pshufw mm2, mm2, 0d8h ; src[8 a 9 b]
pshufw mm3, mm3, 0d8h ; src[c e d f]
pmaddwd mm4, qword ptr[h_add_1_03] ; m[0 2*c]
pmaddwd mm5, qword ptr[h_add_1_03] ; m[1 2*d]
pmaddwd mm0, qword ptr[h_add_1_12] ; m[4 2*8]
pmaddwd mm1, qword ptr[h_add_1_12] ; m[5 2*9]
movq mm6, mm4
movq mm7, mm0
punpckldq mm4, mm5 ; m[0 1]
punpckldq mm0, mm1 ; m[4 5]
punpckhdq mm6, mm5 ; m[2*c 2*d]
punpckhdq mm7, mm1 ; m[2*8 2*9]
movq mm5, mm2
movq mm1, mm3
pmaddwd mm2, qword ptr[h_add_1_03] ; m[2 2*e]
pmaddwd mm3, qword ptr[h_add_1_03] ; m[3 2*f]
psrad mm6, 1 ; m[c d]
psrad mm7, 1 ; m[8 9]
pmaddwd mm5, qword ptr[h_add_1_12] ; m[6 2*a]
pmaddwd mm1, qword ptr[h_add_1_12] ; m[7 2*b]
movq var0, mm6 ; save m[c d]
movq var1, mm7 ; save m[8 9]
movq mm6, mm2
movq mm7, mm5
punpckldq mm2, mm3 ; m[2 3]
punpckldq mm5, mm1 ; m[6 7]
punpckhdq mm6, mm3 ; m[2*e 2*f]
punpckhdq mm7, mm1 ; m[2*a 2*b]
; here we got m6
; minimize register pressure by using store-forwarding
movq mm3, mm4 ; m[0 1]
movq mm1, mm2 ; m[2 3]
psrad mm6, 1 ; m[e f]
psrad mm7, 1 ; m[a b]
paddd mm4, var0 ; n[0 1]
paddd mm2, mm6 ; n[2 3]
psubd mm3, var0 ; n[c d]
psubd mm1, mm6 ; n[e f]
movq mm6, mm0 ; m[4 5]
movq var2,mm5 ; m[6 7]
psubd mm5, mm7 ; n[a b]
paddd mm7, var2 ; n[6 7]
paddd mm0, var1 ; n[4 5]
psubd mm6, var1 ; n[8 9]
; here we got n and should process it again vertically and horizontally
movq var0, mm1 ; n[e f]
movq mm1, mm5 ; n[a b]
movq var1, mm3 ; n[c d]
movq mm3, mm6 ; n[8 9]
movq var2, mm7 ; n[6 7]
movq mm7, mm2 ; n[2 3]
movq var3, mm0 ; n[4 5]
movq mm0, mm4 ; n[0 1]
punpckldq mm5, var0 ; n[a e]
punpckhdq mm1, var0 ; n[b f]
punpckldq mm6, var1 ; n[8 c]
punpckhdq mm3, var1 ; n[9 d]
punpckldq mm7, var2 ; n[2 6]
punpckhdq mm2, var2 ; n[3 7]
punpckldq mm4, var3 ; n[0 4]
punpckhdq mm0, var3 ; n[1 5]
movq var0, mm6 ; n[8 c]
psubd mm6, mm5 ; o[6 7]
paddd mm5, var0 ; o[2 3]
movq var1, mm3 ; n[9 d]
psrad mm3, 1 ; n[9 d] >> 1
movq var2, mm4 ; n[0 4]
psubd mm4, mm7 ; o[4 5]
psubd mm3, mm1 ; o[a b]
movq var3, mm0 ; n[1 5]
psrad mm1, 1 ; n[b f] >> 1
paddd mm7, var2 ; o[0 1]
psrad mm0, 1 ; n[1 5] >> 1
paddd mm1, var1 ; o[e f]
psubd mm0, mm2 ; o[8 9]
psrad mm2, 1 ; n[3 7] >> 1
paddd mm2, var3 ; o[c d]
; got o ready
paddd mm6, qword ptr[const32] ; o[6 7] + 0.5
paddd mm5, qword ptr[const32] ; o[2 3] + 0.5
paddd mm4, qword ptr[const32] ; o[4 5] + 0.5
paddd mm7, qword ptr[const32] ; o[0 1] + 0.5
movq var0, mm6 ; o[6 7]
psubd mm6, mm3 ; p[a b]
paddd mm3, var0 ; p[6 7]
movq var1, mm5 ; o[2 3]
psubd mm5, mm1 ; p[e f]
paddd mm1, var1 ; p[2 3]
psrad mm6, 6
movq var2, mm4 ; o[4 5]
psubd mm4, mm0 ; p[8 9]
paddd mm0, var2 ; p[4 5]
psrad mm3, 6 ;
movq var3, mm7 ; o[0 1]
psubd mm7, mm2 ; p[c d]
paddd mm2, var3 ; p[0 1]
psrad mm5, 6
mov eax, pred
mov edx, dest
psrad mm1, 6
psrad mm4, 6
psrad mm0, 6
psrad mm7, 6
psrad mm2, 6
; got p result ready here. add pred now.
packssdw mm4, mm6 ; p[8 9 a b]
movd mm6, dword ptr[eax]
packssdw mm0, mm3 ; p[4 5 6 7]
movd mm3, dword ptr[eax+16]
packssdw mm2, mm1 ; p[0 1 2 3]
movd mm1, dword ptr[eax+32]
packssdw mm7, mm5 ; p[c d e f]
movd mm5, dword ptr[eax+48]
punpcklbw mm6, qword ptr[const0]
punpcklbw mm3, qword ptr[const0]
punpcklbw mm1, qword ptr[const0]
punpcklbw mm5, qword ptr[const0]
paddsw mm2, mm6
paddsw mm0, mm3
paddsw mm4, mm1
paddsw mm7, mm5
packuswb mm2, mm2
packuswb mm0, mm0
packuswb mm4, mm4
packuswb mm7, mm7
mov eax, stride
movd [edx], mm2
movd [edx+eax], mm0
lea edx, [edx+eax*2]
movd [edx], mm4
movd [edx+eax], mm7
ret
inverse_transform4x4_asm ENDP
END
; ************************************************************************* |
BITS 32
;TEST_FILE_META_BEGIN
;TEST_TYPE=TEST_F
;TEST_IGNOREFLAGS=
;TEST_FILE_META_END
; ADC32i32
mov eax, 0x778
;TEST_BEGIN_RECORDING
adc eax, 0x6fffffff
;TEST_END_RECORDING
|
; A174542: Partial sums of odd Fibonacci numbers (A014437).
; 1,2,5,10,23,44,99,188,421,798,1785,3382,7563,14328,32039,60696,135721,257114,574925,1089154,2435423,4613732,10316619,19544084,43701901,82790070,185124225,350704366,784198803,1485607536,3321919439,6293134512,14071876561,26658145586,59609425685,112925716858,252509579303,478361013020,1069647742899,2026369768940,4531100550901,8583840088782,19194049946505,36361730124070,81307300336923,154030760585064,344423251294199,652484772464328,1459000305513721,2763969850442378,6180424473349085,11708364174233842,26180698198910063,49597426547377748,110903217268989339,210098070363744836,469793567274867421,889989708002357094,1990077486368459025,3770056902373173214,8430103512748703523,15970217317495049952,35710491537363273119,67650926172353373024,151272069662201796001,286573922006908542050,640798770186170457125,1213946614199987541226,2714467150406883624503,5142360378806858706956,11498667371813704955139,21783388129427422369052,48709136637661703445061,92275912896516548183166,206335213922460518735385,390887039715493615101718,874049992327503778386603,1655824071758491008590040,3702535183232475632281799,7014183326749457649461880,15684190725257406307513801,29712557378756321606437562,66439298084262100862337005,125864412841774744075212130,281441383062305809756861823,533170208745855297907286084,1192204830333485339889784299,2258545247825195935704356468,5050260704396247169315999021,9567351200046639040724711958,21393247647918474017153780385,40527950048011752098603204302,90623251296070143237931120563,171679151392093647435137529168,383886252832199046968878262639,727244555616386341839153320976,1626168262624866331113444171121,3080657373857639014791750813074,6888559303331664371422654947125,13049874051046942401006156573274
lpb $0
mov $2,$0
sub $0,1
seq $2,14437 ; Odd Fibonacci numbers.
add $1,$2
lpe
add $1,1
mov $0,$1
|
;; ----------------------------------------------------------------------------
;;
;; Copyright (c) Microsoft Corporation. All rights reserved.
;;
;; ----------------------------------------------------------------------------
include hal.inc
;public: static void __cdecl Class_Microsoft_Singularity_DebugStub::g_Break(void)"
?g_Break@Class_Microsoft_Singularity_DebugStub@@SAXXZ proc
int 3
ret;
?g_Break@Class_Microsoft_Singularity_DebugStub@@SAXXZ endp
;void __cdecl KdpPause(void)"
?KdpPause@@YAXXZ proc
pause
ret;
?KdpPause@@YAXXZ endp
; NB: Without these, we share routines with the mainline code and we get
; caught in a loop when the debugger inserts a break after the pushfd when
; someone tries to single step through Processor:g_DisableInterrupts!
;
;bool __cdecl KdpDisableInterruptsInline(void)"
?KdpDisableInterruptsInline@@YA_NXZ proc
pushfq
pop rax
test rax, Struct_Microsoft_Singularity_Isal_IX_EFlags_IF
setnz al
nop; // required so that the linker doesn't combine with g_Disable
cli;
ret;
?KdpDisableInterruptsInline@@YA_NXZ endp
;void __cdecl KdpRestoreInterruptsInline(bool)"
?KdpRestoreInterruptsInline@@YAX_N@Z proc
nop;
test cl, cl;
je done;
nop; // required so that the linker doesn't combine with g_Restore
sti;
done:
ret;
?KdpRestoreInterruptsInline@@YAX_N@Z endp
;void __cdecl KdpFlushInstCache(void)"
?KdpFlushInstCache@@YAXXZ proc
wbinvd; // privileged instruction
ret;
?KdpFlushInstCache@@YAXXZ endp
; "unsigned __int64 __cdecl KdpX64ReadMsr(unsigned long)"
?KdpX64ReadMsr@@YA_KK@Z proc
rdmsr;
ret;
?KdpX64ReadMsr@@YA_KK@Z endp
; "void __cdecl KdpX64WriteMsr(unsigned long,unsigned __int64)"
?KdpX64WriteMsr@@YAXK_K@Z proc
mov eax, edx;
shr rdx, 32;
wrmsr;
ret;
?KdpX64WriteMsr@@YAXK_K@Z endp
;?KdpX64ReadMsr@@YA_KK@Z endp
; "void __cdecl KdpX64GetSegmentRegisters(struct Struct_Microsoft_Singularity_Kd_X64Context *)"
?KdpX64GetSegmentRegisters@@YAXPEAUStruct_Microsoft_Singularity_Kd_X64Context@@@Z proc
mov ax,cs
mov [rcx].Struct_Microsoft_Singularity_Kd_X64Context._SegCs, ax
mov ax,gs
mov [rcx].Struct_Microsoft_Singularity_Kd_X64Context._SegGs, ax
mov ax,fs
mov [rcx].Struct_Microsoft_Singularity_Kd_X64Context._SegFs, ax
mov ax,es
mov [rcx].Struct_Microsoft_Singularity_Kd_X64Context._SegEs, ax
mov ax,ds
mov [rcx].Struct_Microsoft_Singularity_Kd_X64Context._SegDs, ax
mov ax,ss
mov [rcx].Struct_Microsoft_Singularity_Kd_X64Context._SegSs, ax
ret;
?KdpX64GetSegmentRegisters@@YAXPEAUStruct_Microsoft_Singularity_Kd_X64Context@@@Z endp
; "void __cdecl KdpX64SetControlReport(struct Struct_Microsoft_Singularity_Kd_X64KdControlReport *)"
?KdpX64SetControlReport@@YAXPEAUStruct_Microsoft_Singularity_Kd_X64KdControlReport@@@Z proc
mov rax, dr6;
mov [rcx].Struct_Microsoft_Singularity_Kd_X64KdControlReport._Dr6, rax;
mov rax, dr7;
mov [rcx].Struct_Microsoft_Singularity_Kd_X64KdControlReport._Dr7, rax;
mov ax, cs
mov [rcx].Struct_Microsoft_Singularity_Kd_X64KdControlReport._SegCs, ax
mov ax, es
mov [rcx].Struct_Microsoft_Singularity_Kd_X64KdControlReport._SegEs, ax
mov ax, ds
mov [rcx].Struct_Microsoft_Singularity_Kd_X64KdControlReport._SegDs, ax
mov ax, fs
mov [rcx].Struct_Microsoft_Singularity_Kd_X64KdControlReport._SegFs, ax
pushfq
pop rax
mov [rcx].Struct_Microsoft_Singularity_Kd_X64KdControlReport._EFlags, eax
ret;
?KdpX64SetControlReport@@YAXPEAUStruct_Microsoft_Singularity_Kd_X64KdControlReport@@@Z endp
; "void __cdecl KdpX64SetControlSet(struct Struct_Microsoft_Singularity_Kd_X64KdControlSet *)"
?KdpX64SetControlSet@@YAXPEBUStruct_Microsoft_Singularity_Kd_X64KdControlSet@@@Z proc
mov rax, [rcx].Struct_Microsoft_Singularity_Kd_X64KdControlSet._Dr7;
mov dr7, rax;
ret;
?KdpX64SetControlSet@@YAXPEBUStruct_Microsoft_Singularity_Kd_X64KdControlSet@@@Z endp
; "void __cdecl KdpX64WriteSpecialRegisters(struct Struct_Microsoft_Singularity_Kd_X64KSpecialRegisters const *)"
?KdpX64ReadSpecialRegisters@@YAXPEAUStruct_Microsoft_Singularity_Kd_X64KSpecialRegisters@@@Z proc
mov rax, dr0;
mov [rcx].Struct_Microsoft_Singularity_Kd_X64KSpecialRegisters._KernelDr0, rax;
mov rax, dr1;
mov [rcx].Struct_Microsoft_Singularity_Kd_X64KSpecialRegisters._KernelDr1, rax;
mov rax, dr2;
mov [rcx].Struct_Microsoft_Singularity_Kd_X64KSpecialRegisters._KernelDr2, rax;
mov rax, dr3;
mov [rcx].Struct_Microsoft_Singularity_Kd_X64KSpecialRegisters._KernelDr3, rax;
mov rax, dr6;
mov [rcx].Struct_Microsoft_Singularity_Kd_X64KSpecialRegisters._KernelDr6, rax;
mov rax, dr7;
mov [rcx].Struct_Microsoft_Singularity_Kd_X64KSpecialRegisters._KernelDr7, rax;
sidt [rcx].Struct_Microsoft_Singularity_Kd_X64KSpecialRegisters._Idtr._Limit;
sgdt [rcx].Struct_Microsoft_Singularity_Kd_X64KSpecialRegisters._Gdtr._Limit;
;; Should we save the segment regs as well?
str ax;
mov [rcx].Struct_Microsoft_Singularity_Kd_X64KSpecialRegisters._Tr, ax;
ret;
?KdpX64ReadSpecialRegisters@@YAXPEAUStruct_Microsoft_Singularity_Kd_X64KSpecialRegisters@@@Z endp
; "void __cdecl KdpX64WriteSpecialRegisters(struct Struct_Microsoft_Singularity_Kd_X64KSpecialRegisters const *)"
?KdpX64WriteSpecialRegisters@@YAXPEBUStruct_Microsoft_Singularity_Kd_X64KSpecialRegisters@@@Z proc
mov rax, [rcx].Struct_Microsoft_Singularity_Kd_X64KSpecialRegisters._KernelDr0;
mov dr0, rax;
mov rax, [rcx].Struct_Microsoft_Singularity_Kd_X64KSpecialRegisters._KernelDr1;
mov dr1, rax;
mov rax, [rcx].Struct_Microsoft_Singularity_Kd_X64KSpecialRegisters._KernelDr2;
mov dr2, rax;
mov rax, [rcx].Struct_Microsoft_Singularity_Kd_X64KSpecialRegisters._KernelDr3;
mov dr3, rax;
mov rax, [rcx].Struct_Microsoft_Singularity_Kd_X64KSpecialRegisters._KernelDr6;
mov dr6, rax;
mov rax, [rcx].Struct_Microsoft_Singularity_Kd_X64KSpecialRegisters._KernelDr7;
mov dr7, rax;
ret;
?KdpX64WriteSpecialRegisters@@YAXPEBUStruct_Microsoft_Singularity_Kd_X64KSpecialRegisters@@@Z endp
;static void KdWriteInt8(UINT16 port, UINT8 value)
?KdWriteInt8@@YAXGE@Z proc
mov al,dl
mov dx,cx
out dx, al
ret;
?KdWriteInt8@@YAXGE@Z ENDP
;static UINT8 KdReadInt8(UINT16 port)
?KdReadInt8@@YAEG@Z proc
mov eax, 0
mov dx, cx
in al, dx
ret;
?KdReadInt8@@YAEG@Z endp
end
|
; A267036: Decimal representation of the n-th iteration of the "Rule 85" elementary cellular automaton starting with a single ON (black) cell.
; 1,3,16,63,256,1023,4096,16383,65536,262143,1048576,4194303,16777216,67108863,268435456,1073741823,4294967296,17179869183,68719476736,274877906943,1099511627776,4398046511103,17592186044416,70368744177663,281474976710656,1125899906842623,4503599627370496,18014398509481983,72057594037927936,288230376151711743,1152921504606846976,4611686018427387903,18446744073709551616,73786976294838206463,295147905179352825856,1180591620717411303423,4722366482869645213696,18889465931478580854783
mov $1,4
pow $1,$0
mov $2,$0
gcd $2,2
add $1,$2
sub $1,2
mov $0,$1
|
; A342676: a(n) is the number of lunar primes less than or equal to n.
; 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6,6,6,6,7,7,7,7,7,7,7,7,7
sub $0,8
div $0,10
|
; ************************************************************************************************
; ************************************************************************************************
;
; Name: 00start.asm
; Purpose: Start up code.
; Created: 21st February 2021
; Reviewed: 11th March 2021
; Author: Paul Robson (paul@robsons.org.uk)
;
; ************************************************************************************************
; ************************************************************************************************
.section code
Start:
jmp GoColdStart ; +0 boot BASIC
jmp GoTokTest ; +3 run tokeniser test code.
.if installed_tokeniser==1 ; +6 address of table of token texts.
.word TokenTableAddress
else
.word 0
.endif
GoColdStart:
.set16 basePage,programMemory ; set up
.set16 endMemory,endOfMemory
jsr InitialiseAll ; initialise everything.
.if installed_interaction == 0 && autorun != 0
.main_run
.else
.interaction_coldstart
.endif
.include "../generated/initialiseall.asm"
GoTokTest:
.tokeniser_test
.send code
; ************************************************************************************************
;
; Changes and Updates
;
; ************************************************************************************************
;
; Date Notes
; ==== =====
; 07-Mar-21 Pre code read v0.01
;
; ************************************************************************************************
|
; A135099: a(1)=1, a(n) = a(n-1) + n^5 if n odd, a(n) = a(n-1) + n^3 if n is even.
; 1,9,252,316,3441,3657,20464,20976,80025,81025,242076,243804,615097,617841,1377216,1381312,2801169,2807001,5283100,5291100,9375201,9385849,15822192,15836016,25601641,25619217,39968124,39990076,60501225,60528225,89157376,89190144,128325537,128364841,180886716,180933372,250277329,250332201,340556400,340620400,456476601,456550689,603559132,603644316,788172441,788269777,1017614784,1017725376,1300200625,1300325625,1645350876,1645491484,2063686977,2063844441,2567128816,2567304432,3168996489,3169191601,3884115900,3884331900,4728928201,4729166529,5721603072,5721865216,6882155841,6882443337,8232568444,8232882876,9796914225,9797257225,11601486576,11601859824,13674931417,13675336641,16048383516,16048822492,18755606649,18756081201,21833137600,21833649600,25320434001,25320985369,29260026012,29260618716,33697671841,33698307897,38682517104,38683198576,44267258025,44267987025,50508308476,50509087164,57465970857,57466801441,65204610816,65205495552,73792835809,73793777001,83303677500,83304677500
mov $2,$0
mov $4,$0
add $4,1
lpb $4
mov $0,$2
sub $4,1
sub $0,$4
add $0,1
mov $3,$0
mod $3,2
mul $3,2
add $3,3
mov $5,$0
pow $5,$3
add $1,$5
lpe
mov $0,$1
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.