text
stringlengths
1
1.05M
# multiply 2 numbers together # multiply r0 by r1 and store # the result in r2 # input set r0 23 set r1 11 # output set r2 0 # loops to do for multiplication mov r0 r5 # loop decrementer set r6 -1 loop: jmpz r5 end add r1 r2 r2 add r6 r5 r5 jmp loop end: set r3 0 set r4 0 set r5 0 set r6 0 halt
org 0x7c00 ; Some const value BaseOfStack equ 0x7c00 BaseOfLoader equ 0x9000 OffsetOfLoader equ 0x0100 jmp short Boot_Start nop %include "FAT.inc" Boot_Start: ; Init stack mov ax, cs mov ds, ax mov es, ax mov ss, ax mov sp, BaseOfStack ; Clear screen mov ax, 0600h mov bx, 0700h mov cx, 0000h mov dx, 184fh int 10h ; Display string mov dx, 0000h mov bx, 000fh mov cx, 13 mov bp, StartMessage call Display_Str ; Reset disk xor ah, ah xor dl, dl int 13h ; Search loader.bin mov word [SectorNo], RootDirStartSectors Begin_Search: cmp word [RootDirSizeForLoop], 0 jz No_Loader_Bin dec word [RootDirSizeForLoop] mov ax, BaseOfLoader mov es, ax mov bx, OffsetOfLoader mov ax, [SectorNo] mov cl, 1 call Read_Sector mov si, LoaderFileName ; It make ds:si point to LoaderFileName mov di, OffsetOfLoader cld mov dx, 10h ; One sector has 0x10 directory entry Search_For_Loader_Bin: cmp dx, 0 jz Search_Next_Sector dec dx mov cx, 11 Cmp_File_Name: ; Judge whether find loader.bin cmp cx, 0 jz Find_File dec cx lodsb ; ds:si->al, and then si point to next byte ; the moving direction set by CLD instruction cmp al, byte [es:di] jz Go_On jmp File_Different Go_On: ; Continue comparing file name inc di jmp Cmp_File_Name File_Different: ; Find loader.bin in next directory entry and di, 0ffe0h ; Reset the di to the origin address add di, 20h ; One directory entry is 32 byte ; It make es:di point next directory entry mov si, LoaderFileName ; Reset the si point the start of file name jmp Search_For_Loader_Bin Search_Next_Sector: add word [SectorNo], 1 jmp Begin_Search No_Loader_Bin: ; Fail finding loader.bin, display error mov bx, 008ch mov dx, 0100h mov cx, 21 mov bp, NoLoderMessage call Display_Str jmp $ Find_File: mov ax, RootDirSectorsNum and di, 0ffe0h ; Reset the di to the origin address add di, 1ah ; es:[di+1ah] is DIR_FstClus, point to ; the first cluster in the data area mov cx, word [es:di] push cx ; Push cluster NO into stack add cx, ax ; Calculate the sector NO of the data add cx, SectorsBanlance ; Use formula: Data_sector_start_NO = ; SectorsBanlance(RootDirStartSectors-2) + ; RootDirSectorsNum mov ax, BaseOfLoader mov es, ax mov bx, OffsetOfLoader mov ax, cx Loading_File: call Display_Period mov cl, 1 call Read_Sector ; Read sector from data area pop ax call Get_Fat_Entry cmp ax, 0fffh jz File_Loaded push ax mov dx, RootDirSectorsNum add ax, dx add ax, SectorsBanlance add bx, [BPB_BytesPerSec] jmp Loading_File File_Loaded: jmp BaseOfLoader:OffsetOfLoader %include 'bootloader_func.inc' ; Some variable StartMessage db 'Start Booting' RootDirSizeForLoop dw RootDirSectorsNum SectorNo dw 0 LoaderFileName db 'LOADER BIN' NoLoderMessage db 'Error:No Loader Found' times 510 - ($ - $$) db 0 dw 0xaa55
; A215137: a(n) = 17*n + 1. ; 1,18,35,52,69,86,103,120,137,154,171,188,205,222,239,256,273,290,307,324,341,358,375,392,409,426,443,460,477,494,511,528,545,562,579,596,613,630,647,664,681,698,715,732,749,766,783,800,817,834,851,868,885,902,919,936,953,970,987,1004,1021,1038,1055,1072,1089,1106,1123,1140,1157,1174,1191,1208,1225,1242,1259,1276,1293,1310,1327,1344,1361,1378,1395,1412,1429,1446,1463,1480,1497,1514,1531,1548,1565,1582,1599,1616,1633,1650,1667,1684 mul $0,17 add $0,1
; *************************************************************************************** ; *************************************************************************************** ; ; Name : kernel.asm ; Author : Paul Robson (paul@robsons.org.uk) ; Date : 16th November 2018 ; Purpose : ColorForth Kernel ; ; *************************************************************************************** ; *************************************************************************************** StackTop = $7EF0 ; Top of stack DictionaryPage = $20 ; dictionary page FirstCodePage = $22 opt zxnextreg org $8000 jr Boot org $8004 ; pointer to SysInfo at $8004 dw SystemInformationTable Boot: ld sp,(SIStack) ; reset Z80 Stack di ; disable interrupts nextreg 7,2 ; set turbo port (7) to 2 (14Mhz speed) call GFXInitialise48k ; initialise and clear screen. call GFXConfigure ld a,(SIBootCodePage) ; get the page to start call PAGEInitialise ld hl,(SIBootCodeAddress) db $DD,$01 jp (hl) include "support/macro.asm" ; macro expander include "support/debug.asm" ; debug helper include "support/paging.asm" ; page switcher (not while executing) include "support/farmemory.asm" ; far memory routines include "support/divide.asm" ; division include "support/multiply.asm" ; multiplication include "support/graphics.asm" ; common graphics include "support/keyboard.asm" include "support/screen48k.asm" ; screen "drivers" include "support/screen_layer2.asm" include "support/screen_lores.asm" include "temp/__words.asm" ; built file of words. AlternateFont: ; nicer font include "font.inc" ; can be $3D00 here to save memory include "data.asm" org $C000 db 0 ; start of dictionary, which is empty.
/* brass_cursor.cc: Btree cursor implementation * * Copyright 1999,2000,2001 BrightStation PLC * Copyright 2002,2003,2004,2005,2006,2007,2008,2009,2010,2012 Olly Betts * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 * USA */ #include <config.h> #include "brass_cursor.h" #include "safeerrno.h" #include <xapian/error.h> #include "brass_table.h" #include "debuglog.h" #include "omassert.h" using namespace Brass; #ifdef XAPIAN_DEBUG_LOG static string hex_display_encode(const string & input) { const char * table = "0123456789abcdef"; string result; for (string::const_iterator i = input.begin(); i != input.end(); ++i) { unsigned char val = *i; result += "\\x"; result += table[val/16]; result += table[val%16]; } return result; } #endif #define DIR_START 11 BrassCursor::BrassCursor(const BrassTable *B_) : is_positioned(false), is_after_end(false), tag_status(UNREAD), B(B_), version(B_->cursor_version), level(B_->level) { B->cursor_created_since_last_modification = true; C = new Brass::Cursor[level + 1]; for (int j = 0; j < level; j++) { C[j].n = BLK_UNUSED; C[j].p = new byte[B->block_size]; } C[level].n = B->C[level].n; C[level].p = B->C[level].p; } void BrassCursor::rebuild() { int new_level = B->level; if (new_level <= level) { for (int i = 0; i < new_level; i++) { C[i].n = BLK_UNUSED; } for (int j = new_level; j < level; ++j) { delete C[j].p; } } else { Cursor * old_C = C; C = new Cursor[new_level + 1]; for (int i = 0; i < level; i++) { C[i].p = old_C[i].p; C[i].n = BLK_UNUSED; } delete [] old_C; for (int j = level; j < new_level; j++) { C[j].p = new byte[B->block_size]; C[j].n = BLK_UNUSED; } } level = new_level; C[level].n = B->C[level].n; C[level].p = B->C[level].p; version = B->cursor_version; } BrassCursor::~BrassCursor() { // Use the value of level stored in the cursor rather than the // Btree, since the Btree might have been deleted already. for (int j = 0; j < level; j++) { delete [] C[j].p; } delete [] C; } bool BrassCursor::prev() { LOGCALL(DB, bool, "BrassCursor::prev", NO_ARGS); Assert(!is_after_end); if (B->cursor_version != version || !is_positioned) { // Either the cursor needs rebuilding (in which case find_entry() will // call rebuild() and then reposition the cursor), or we've read the // last key and tag, and we're now not positioned (in which case we // seek to the current key, and then it's as if we read the key but not // the tag). if (!find_entry(current_key)) { // Exact entry was no longer there after rebuild(), and we've // automatically ended up on the entry before it. RETURN(true); } } else if (tag_status != UNREAD) { while (true) { if (! B->prev(C, 0)) { is_positioned = false; RETURN(false); } if (Item(C[0].p, C[0].c).component_of() == 1) { break; } } } while (true) { if (! B->prev(C, 0)) { is_positioned = false; RETURN(false); } if (Item(C[0].p, C[0].c).component_of() == 1) { break; } } get_key(&current_key); tag_status = UNREAD; LOGLINE(DB, "Moved to entry: key=" << hex_display_encode(current_key)); RETURN(true); } bool BrassCursor::next() { LOGCALL(DB, bool, "BrassCursor::next", NO_ARGS); Assert(!is_after_end); if (B->cursor_version != version) { // find_entry() will call rebuild(). (void)find_entry(current_key); // If the key was found, we're now pointing to it, otherwise we're // pointing to the entry before. Either way, we now want to move to // the next key. } if (tag_status == UNREAD) { while (true) { if (! B->next(C, 0)) { is_positioned = false; break; } if (Item(C[0].p, C[0].c).component_of() == 1) { is_positioned = true; break; } } } if (!is_positioned) { is_after_end = true; RETURN(false); } get_key(&current_key); tag_status = UNREAD; LOGLINE(DB, "Moved to entry: key=" << hex_display_encode(current_key)); RETURN(true); } bool BrassCursor::find_entry(const string &key) { LOGCALL(DB, bool, "BrassCursor::find_entry", key); if (B->cursor_version != version) { rebuild(); } is_after_end = false; bool found; is_positioned = true; if (key.size() > BRASS_BTREE_MAX_KEY_LEN) { // Can't find key - too long to possibly be present, so find the // truncated form but ignore "found". B->form_key(key.substr(0, BRASS_BTREE_MAX_KEY_LEN)); (void)(B->find(C)); found = false; } else { B->form_key(key); found = B->find(C); } if (!found) { if (C[0].c < DIR_START) { C[0].c = DIR_START; if (! B->prev(C, 0)) goto done; } while (Item(C[0].p, C[0].c).component_of() != 1) { if (! B->prev(C, 0)) { is_positioned = false; throw Xapian::DatabaseCorruptError("find_entry failed to find any entry at all!"); } } } done: if (found) current_key = key; else get_key(&current_key); tag_status = UNREAD; LOGLINE(DB, "Found entry: key=" << hex_display_encode(current_key)); RETURN(found); } bool BrassCursor::find_entry_ge(const string &key) { LOGCALL(DB, bool, "BrassCursor::find_entry_ge", key); if (B->cursor_version != version) { rebuild(); } is_after_end = false; bool found; is_positioned = true; if (key.size() > BRASS_BTREE_MAX_KEY_LEN) { // Can't find key - too long to possibly be present, so find the // truncated form but ignore "found". B->form_key(key.substr(0, BRASS_BTREE_MAX_KEY_LEN)); (void)(B->find(C)); found = false; } else { B->form_key(key); found = B->find(C); } if (found) { current_key = key; } else { if (! B->next(C, 0)) { is_after_end = true; is_positioned = false; RETURN(false); } Assert(Item(C[0].p, C[0].c).component_of() == 1); get_key(&current_key); } tag_status = UNREAD; LOGLINE(DB, "Found entry: key=" << hex_display_encode(current_key)); RETURN(found); } void BrassCursor::get_key(string * key) const { Assert(B->level <= level); Assert(is_positioned); (void)Item(C[0].p, C[0].c).key().read(key); } bool BrassCursor::read_tag(bool keep_compressed) { LOGCALL(DB, bool, "BrassCursor::read_tag", keep_compressed); if (tag_status == UNREAD) { Assert(B->level <= level); Assert(is_positioned); if (B->read_tag(C, &current_tag, keep_compressed)) { tag_status = COMPRESSED; } else { tag_status = UNCOMPRESSED; } // We need to call B->next(...) after B->read_tag(...) so that the // cursor ends up on the next key. is_positioned = B->next(C, 0); LOGLINE(DB, "tag=" << hex_display_encode(current_tag)); } RETURN(tag_status == COMPRESSED); } bool MutableBrassCursor::del() { Assert(!is_after_end); // MutableBrassCursor is only constructable from a non-const BrassTable* // but we store that in the const BrassTable* "B" member of the BrassCursor // class to avoid duplicating storage. So we know it is safe to cast away // that const again here. (const_cast<BrassTable*>(B))->del(current_key); // If we're iterating an older revision of the tree, then the deletion // happens in a new (uncommitted) revision and the cursor still sees // the deleted key. But if we're iterating the new uncommitted revision // then the deleted key is no longer visible. We need to handle both // cases - either find_entry_ge() finds the deleted key or not. if (!find_entry_ge(current_key)) return is_positioned; return next(); }
// Copyright (c) 2011-2016 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #if defined(HAVE_CONFIG_H) #include "config/herbsters-config.h" #endif #include "fs.h" #include "intro.h" #include "ui_intro.h" #include "guiutil.h" #include "util.h" #include <QFileDialog> #include <QSettings> #include <QMessageBox> #include <cmath> static const uint64_t GB_BYTES = 1000000000LL; /* Minimum free space (in GB) needed for data directory */ static const uint64_t BLOCK_CHAIN_SIZE = 14; /* Minimum free space (in GB) needed for data directory when pruned; Does not include prune target */ static const uint64_t CHAIN_STATE_SIZE = 3; /* Total required space (in GB) depending on user choice (prune, not prune) */ static uint64_t requiredSpace; /* Check free space asynchronously to prevent hanging the UI thread. Up to one request to check a path is in flight to this thread; when the check() function runs, the current path is requested from the associated Intro object. The reply is sent back through a signal. This ensures that no queue of checking requests is built up while the user is still entering the path, and that always the most recently entered path is checked as soon as the thread becomes available. */ class FreespaceChecker : public QObject { Q_OBJECT public: FreespaceChecker(Intro *intro); enum Status { ST_OK, ST_ERROR }; public Q_SLOTS: void check(); Q_SIGNALS: void reply(int status, const QString &message, quint64 available); private: Intro *intro; }; #include "intro.moc" FreespaceChecker::FreespaceChecker(Intro *_intro) { this->intro = _intro; } void FreespaceChecker::check() { QString dataDirStr = intro->getPathToCheck(); fs::path dataDir = GUIUtil::qstringToBoostPath(dataDirStr); uint64_t freeBytesAvailable = 0; int replyStatus = ST_OK; QString replyMessage = tr("A new data directory will be created."); /* Find first parent that exists, so that fs::space does not fail */ fs::path parentDir = dataDir; fs::path parentDirOld = fs::path(); while(parentDir.has_parent_path() && !fs::exists(parentDir)) { parentDir = parentDir.parent_path(); /* Check if we make any progress, break if not to prevent an infinite loop here */ if (parentDirOld == parentDir) break; parentDirOld = parentDir; } try { freeBytesAvailable = fs::space(parentDir).available; if(fs::exists(dataDir)) { if(fs::is_directory(dataDir)) { QString separator = "<code>" + QDir::toNativeSeparators("/") + tr("name") + "</code>"; replyStatus = ST_OK; replyMessage = tr("Directory already exists. Add %1 if you intend to create a new directory here.").arg(separator); } else { replyStatus = ST_ERROR; replyMessage = tr("Path already exists, and is not a directory."); } } } catch (const fs::filesystem_error&) { /* Parent directory does not exist or is not accessible */ replyStatus = ST_ERROR; replyMessage = tr("Cannot create data directory here."); } Q_EMIT reply(replyStatus, replyMessage, freeBytesAvailable); } Intro::Intro(QWidget *parent) : QDialog(parent), ui(new Ui::Intro), thread(0), signalled(false) { ui->setupUi(this); ui->welcomeLabel->setText(ui->welcomeLabel->text().arg(tr(PACKAGE_NAME))); ui->storageLabel->setText(ui->storageLabel->text().arg(tr(PACKAGE_NAME))); ui->lblExplanation1->setText(ui->lblExplanation1->text() .arg(tr(PACKAGE_NAME)) .arg(BLOCK_CHAIN_SIZE) .arg(2009) .arg(tr("herbsters")) ); ui->lblExplanation2->setText(ui->lblExplanation2->text().arg(tr(PACKAGE_NAME))); uint64_t pruneTarget = std::max<int64_t>(0, gArgs.GetArg("-prune", 0)); requiredSpace = BLOCK_CHAIN_SIZE; QString storageRequiresMsg = tr("At least %1 GB of data will be stored in this directory, and it will grow over time."); if (pruneTarget) { uint64_t prunedGBs = std::ceil(pruneTarget * 1024 * 1024.0 / GB_BYTES); if (prunedGBs <= requiredSpace) { requiredSpace = prunedGBs; storageRequiresMsg = tr("Approximately %1 GB of data will be stored in this directory."); } ui->lblExplanation3->setVisible(true); } else { ui->lblExplanation3->setVisible(false); } requiredSpace += CHAIN_STATE_SIZE; ui->sizeWarningLabel->setText( tr("%1 will download and store a copy of the herbsters block chain.").arg(tr(PACKAGE_NAME)) + " " + storageRequiresMsg.arg(requiredSpace) + " " + tr("The wallet will also be stored in this directory.") ); startThread(); } Intro::~Intro() { delete ui; /* Ensure thread is finished before it is deleted */ Q_EMIT stopThread(); thread->wait(); } QString Intro::getDataDirectory() { return ui->dataDirectory->text(); } void Intro::setDataDirectory(const QString &dataDir) { ui->dataDirectory->setText(dataDir); if(dataDir == getDefaultDataDirectory()) { ui->dataDirDefault->setChecked(true); ui->dataDirectory->setEnabled(false); ui->ellipsisButton->setEnabled(false); } else { ui->dataDirCustom->setChecked(true); ui->dataDirectory->setEnabled(true); ui->ellipsisButton->setEnabled(true); } } QString Intro::getDefaultDataDirectory() { return GUIUtil::boostPathToQString(GetDefaultDataDir()); } bool Intro::pickDataDirectory() { QSettings settings; /* If data directory provided on command line, no need to look at settings or show a picking dialog */ if(!gArgs.GetArg("-datadir", "").empty()) return true; /* 1) Default data directory for operating system */ QString dataDir = getDefaultDataDirectory(); /* 2) Allow QSettings to override default dir */ dataDir = settings.value("strDataDir", dataDir).toString(); if(!fs::exists(GUIUtil::qstringToBoostPath(dataDir)) || gArgs.GetBoolArg("-choosedatadir", DEFAULT_CHOOSE_DATADIR) || settings.value("fReset", false).toBool() || gArgs.GetBoolArg("-resetguisettings", false)) { /* If current default data directory does not exist, let the user choose one */ Intro intro; intro.setDataDirectory(dataDir); intro.setWindowIcon(QIcon(":icons/herbsters")); while(true) { if(!intro.exec()) { /* Cancel clicked */ return false; } dataDir = intro.getDataDirectory(); try { TryCreateDirectories(GUIUtil::qstringToBoostPath(dataDir)); break; } catch (const fs::filesystem_error&) { QMessageBox::critical(0, tr(PACKAGE_NAME), tr("Error: Specified data directory \"%1\" cannot be created.").arg(dataDir)); /* fall through, back to choosing screen */ } } settings.setValue("strDataDir", dataDir); settings.setValue("fReset", false); } /* Only override -datadir if different from the default, to make it possible to * override -datadir in the herbsters.conf file in the default data directory * (to be consistent with herbstersd behavior) */ if(dataDir != getDefaultDataDirectory()) gArgs.SoftSetArg("-datadir", GUIUtil::qstringToBoostPath(dataDir).string()); // use OS locale for path setting return true; } void Intro::setStatus(int status, const QString &message, quint64 bytesAvailable) { switch(status) { case FreespaceChecker::ST_OK: ui->errorMessage->setText(message); ui->errorMessage->setStyleSheet(""); break; case FreespaceChecker::ST_ERROR: ui->errorMessage->setText(tr("Error") + ": " + message); ui->errorMessage->setStyleSheet("QLabel { color: #800000 }"); break; } /* Indicate number of bytes available */ if(status == FreespaceChecker::ST_ERROR) { ui->freeSpace->setText(""); } else { QString freeString = tr("%n GB of free space available", "", bytesAvailable/GB_BYTES); if(bytesAvailable < requiredSpace * GB_BYTES) { freeString += " " + tr("(of %n GB needed)", "", requiredSpace); ui->freeSpace->setStyleSheet("QLabel { color: #800000 }"); } else { ui->freeSpace->setStyleSheet(""); } ui->freeSpace->setText(freeString + "."); } /* Don't allow confirm in ERROR state */ ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(status != FreespaceChecker::ST_ERROR); } void Intro::on_dataDirectory_textChanged(const QString &dataDirStr) { /* Disable OK button until check result comes in */ ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false); checkPath(dataDirStr); } void Intro::on_ellipsisButton_clicked() { QString dir = QDir::toNativeSeparators(QFileDialog::getExistingDirectory(0, "Choose data directory", ui->dataDirectory->text())); if(!dir.isEmpty()) ui->dataDirectory->setText(dir); } void Intro::on_dataDirDefault_clicked() { setDataDirectory(getDefaultDataDirectory()); } void Intro::on_dataDirCustom_clicked() { ui->dataDirectory->setEnabled(true); ui->ellipsisButton->setEnabled(true); } void Intro::startThread() { thread = new QThread(this); FreespaceChecker *executor = new FreespaceChecker(this); executor->moveToThread(thread); connect(executor, SIGNAL(reply(int,QString,quint64)), this, SLOT(setStatus(int,QString,quint64))); connect(this, SIGNAL(requestCheck()), executor, SLOT(check())); /* make sure executor object is deleted in its own thread */ connect(this, SIGNAL(stopThread()), executor, SLOT(deleteLater())); connect(this, SIGNAL(stopThread()), thread, SLOT(quit())); thread->start(); } void Intro::checkPath(const QString &dataDir) { mutex.lock(); pathToCheck = dataDir; if(!signalled) { signalled = true; Q_EMIT requestCheck(); } mutex.unlock(); } QString Intro::getPathToCheck() { QString retval; mutex.lock(); retval = pathToCheck; signalled = false; /* new request can be queued now */ mutex.unlock(); return retval; }
// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "content/renderer/media/rtc_video_capture_delegate.h" #include "base/bind.h" RtcVideoCaptureDelegate::RtcVideoCaptureDelegate( const media::VideoCaptureSessionId id, VideoCaptureImplManager* vc_manager) : session_id_(id), vc_manager_(vc_manager), capture_engine_(NULL) { DVLOG(3) << " RtcVideoCaptureDelegate::ctor"; capture_engine_ = vc_manager_->AddDevice(session_id_, this); } RtcVideoCaptureDelegate::~RtcVideoCaptureDelegate() { DVLOG(3) << " RtcVideoCaptureDelegate::dtor"; vc_manager_->RemoveDevice(session_id_, this); } void RtcVideoCaptureDelegate::StartCapture( const media::VideoCaptureCapability& capability, const FrameCapturedCallback& callback) { DVLOG(3) << " RtcVideoCaptureDelegate::StartCapture "; message_loop_proxy_ = base::MessageLoopProxy::current(); captured_callback_ = callback; // Increase the reference count to ensure we are not deleted until // The we are unregistered in RtcVideoCaptureDelegate::OnRemoved. AddRef(); capture_engine_->StartCapture(this, capability); } void RtcVideoCaptureDelegate::StopCapture() { // Immediately make sure we don't provide more frames. captured_callback_.Reset(); capture_engine_->StopCapture(this); } void RtcVideoCaptureDelegate::OnStarted(media::VideoCapture* capture) { DVLOG(3) << " RtcVideoCaptureDelegate::OnStarted"; } void RtcVideoCaptureDelegate::OnStopped(media::VideoCapture* capture) { } void RtcVideoCaptureDelegate::OnPaused(media::VideoCapture* capture) { NOTIMPLEMENTED(); } void RtcVideoCaptureDelegate::OnError(media::VideoCapture* capture, int error_code) { NOTIMPLEMENTED(); } void RtcVideoCaptureDelegate::OnRemoved(media::VideoCapture* capture) { DVLOG(3) << " RtcVideoCaptureDelegate::OnRemoved"; // Balance the AddRef in StartCapture. // This means we are no longer registered as an event handler and can safely // be deleted. Release(); } void RtcVideoCaptureDelegate::OnBufferReady( media::VideoCapture* capture, scoped_refptr<media::VideoCapture::VideoFrameBuffer> buf) { message_loop_proxy_->PostTask( FROM_HERE, base::Bind(&RtcVideoCaptureDelegate::OnBufferReadyOnCaptureThread, this, capture, buf)); } void RtcVideoCaptureDelegate::OnDeviceInfoReceived( media::VideoCapture* capture, const media::VideoCaptureParams& device_info) { NOTIMPLEMENTED(); } void RtcVideoCaptureDelegate::OnBufferReadyOnCaptureThread( media::VideoCapture* capture, scoped_refptr<media::VideoCapture::VideoFrameBuffer> buf) { if (!captured_callback_.is_null()) { captured_callback_.Run(*buf); } capture->FeedBuffer(buf); }
// Copyright (C) 2012-2015 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. #include <exceptions/exceptions.h> #include <dns/name.h> #include <dns/master_loader.h> #include <dns/master_loader_callbacks.h> #include <dns/rrclass.h> #include <dns/rrcollator.h> #include <dns/rdata.h> #include <dns/rrset.h> #include <dns/rrttl.h> #include <gtest/gtest.h> #include <boost/bind.hpp> #include <sstream> #include <vector> using std::vector; using namespace isc::dns; using namespace isc::dns::rdata; namespace { typedef RRCollator::AddRRsetCallback AddRRsetCallback; void addRRset(const RRsetPtr& rrset, vector<ConstRRsetPtr>* to_append, const bool* do_throw) { if (*do_throw) { isc_throw(isc::Unexpected, "faked failure"); } to_append->push_back(rrset); } class RRCollatorTest : public ::testing::Test { protected: RRCollatorTest() : origin_("example.com"), rrclass_(RRClass::IN()), rrttl_(3600), throw_from_callback_(false), collator_(boost::bind(addRRset, _1, &rrsets_, &throw_from_callback_)), rr_callback_(collator_.getCallback()), a_rdata1_(createRdata(RRType::A(), rrclass_, "192.0.2.1")), a_rdata2_(createRdata(RRType::A(), rrclass_, "192.0.2.2")), txt_rdata_(createRdata(RRType::TXT(), rrclass_, "test")), sig_rdata1_(createRdata(RRType::RRSIG(), rrclass_, "A 5 3 3600 20000101000000 20000201000000 " "12345 example.com. FAKE")), sig_rdata2_(createRdata(RRType::RRSIG(), rrclass_, "NS 5 3 3600 20000101000000 20000201000000 " "12345 example.com. FAKE")) {} void checkRRset(const Name& expected_name, const RRClass& expected_class, const RRType& expected_type, const RRTTL& expected_ttl, const vector<ConstRdataPtr>& expected_rdatas) { SCOPED_TRACE(expected_name.toText(true) + "/" + expected_class.toText() + "/" + expected_type.toText()); // This test always clears rrsets_ to confirm RRsets are added // one-by-one ASSERT_EQ(1, rrsets_.size()); ConstRRsetPtr actual = rrsets_[0]; EXPECT_EQ(expected_name, actual->getName()); EXPECT_EQ(expected_class, actual->getClass()); EXPECT_EQ(expected_type, actual->getType()); EXPECT_EQ(expected_ttl, actual->getTTL()); ASSERT_EQ(expected_rdatas.size(), actual->getRdataCount()); vector<ConstRdataPtr>::const_iterator it = expected_rdatas.begin(); for (RdataIteratorPtr rit = actual->getRdataIterator(); !rit->isLast(); rit->next()) { EXPECT_EQ(0, rit->getCurrent().compare(**it)); ++it; } rrsets_.clear(); } const Name origin_; const RRClass rrclass_; const RRTTL rrttl_; vector<ConstRRsetPtr> rrsets_; bool throw_from_callback_; RRCollator collator_; AddRRCallback rr_callback_; const RdataPtr a_rdata1_, a_rdata2_, txt_rdata_, sig_rdata1_, sig_rdata2_; vector<ConstRdataPtr> rdatas_; // placeholder for expected data }; TEST_F(RRCollatorTest, basicCases) { // Add two RRs belonging to the same RRset. These will be buffered. rr_callback_(origin_, rrclass_, RRType::A(), rrttl_, a_rdata1_); EXPECT_TRUE(rrsets_.empty()); // not yet given as an RRset rr_callback_(origin_, rrclass_, RRType::A(), rrttl_, a_rdata2_); EXPECT_TRUE(rrsets_.empty()); // still not given // Add another type of RR. This completes the construction of the A RRset, // which will be given via the callback. rr_callback_(origin_, rrclass_, RRType::TXT(), rrttl_, txt_rdata_); rdatas_.push_back(a_rdata1_); rdatas_.push_back(a_rdata2_); checkRRset(origin_, rrclass_, RRType::A(), rrttl_, rdatas_); // Add the same type of RR but of different name. This should make another // callback for the previous TXT RR. rr_callback_(Name("txt.example.com"), rrclass_, RRType::TXT(), rrttl_, txt_rdata_); rdatas_.clear(); rdatas_.push_back(txt_rdata_); checkRRset(origin_, rrclass_, RRType::TXT(), rrttl_, rdatas_); // Add the same type and name of RR but of different class (rare case // in practice) rr_callback_(Name("txt.example.com"), RRClass::CH(), RRType::TXT(), rrttl_, txt_rdata_); rdatas_.clear(); rdatas_.push_back(txt_rdata_); checkRRset(Name("txt.example.com"), rrclass_, RRType::TXT(), rrttl_, rdatas_); // Tell the collator we are done, then we'll see the last RR as an RRset. collator_.flush(); checkRRset(Name("txt.example.com"), RRClass::CH(), RRType::TXT(), rrttl_, rdatas_); // Redundant flush() will be no-op. collator_.flush(); EXPECT_TRUE(rrsets_.empty()); } TEST_F(RRCollatorTest, minTTLFirst) { // RRs of the same RRset but has different TTLs. The first RR has // the smaller TTL, which should be used for the TTL of the RRset. rr_callback_(origin_, rrclass_, RRType::A(), RRTTL(10), a_rdata1_); rr_callback_(origin_, rrclass_, RRType::A(), RRTTL(20), a_rdata2_); rdatas_.push_back(a_rdata1_); rdatas_.push_back(a_rdata2_); collator_.flush(); checkRRset(origin_, rrclass_, RRType::A(), RRTTL(10), rdatas_); } TEST_F(RRCollatorTest, maxTTLFirst) { // RRs of the same RRset but has different TTLs. The second RR has // the smaller TTL, which should be used for the TTL of the RRset. rr_callback_(origin_, rrclass_, RRType::A(), RRTTL(20), a_rdata1_); rr_callback_(origin_, rrclass_, RRType::A(), RRTTL(10), a_rdata2_); rdatas_.push_back(a_rdata1_); rdatas_.push_back(a_rdata2_); collator_.flush(); checkRRset(origin_, rrclass_, RRType::A(), RRTTL(10), rdatas_); } TEST_F(RRCollatorTest, addRRSIGs) { // RRSIG is special; they are also distinguished by their covered types. rr_callback_(origin_, rrclass_, RRType::RRSIG(), rrttl_, sig_rdata1_); rr_callback_(origin_, rrclass_, RRType::RRSIG(), rrttl_, sig_rdata2_); rdatas_.push_back(sig_rdata1_); checkRRset(origin_, rrclass_, RRType::RRSIG(), rrttl_, rdatas_); } TEST_F(RRCollatorTest, emptyFlush) { collator_.flush(); EXPECT_TRUE(rrsets_.empty()); } TEST_F(RRCollatorTest, throwFromCallback) { // Adding an A RR rr_callback_(origin_, rrclass_, RRType::A(), rrttl_, a_rdata1_); // Adding a TXT RR, which would trigger RRset callback, but in this test // it throws. The added TXT RR will be effectively lost. throw_from_callback_ = true; EXPECT_THROW(rr_callback_(origin_, rrclass_, RRType::TXT(), rrttl_, txt_rdata_), isc::Unexpected); // We'll only see the A RR. throw_from_callback_ = false; collator_.flush(); rdatas_.push_back(a_rdata1_); checkRRset(origin_, rrclass_, RRType::A(), rrttl_, rdatas_); } TEST_F(RRCollatorTest, withMasterLoader) { // Test a simple case with MasterLoader. There shouldn't be anything // special, but that's the mainly intended usage of the collator, so we // check it explicitly. std::istringstream ss("example.com. 3600 IN A 192.0.2.1\n"); MasterLoader loader(ss, origin_, rrclass_, MasterLoaderCallbacks::getNullCallbacks(), collator_.getCallback()); loader.load(); collator_.flush(); rdatas_.push_back(a_rdata1_); checkRRset(origin_, rrclass_, RRType::A(), rrttl_, rdatas_); } }
/****************************************************************************** * * Copyright (c) 2019, the Perspective Authors. * * This file is part of the Perspective library, distributed under the terms of * the Apache License 2.0. The full license can be found in the LICENSE file. * */ #ifdef PSP_ENABLE_PYTHON #include <perspective/python/view.h> namespace perspective { namespace binding { /****************************************************************************** * * View API */ template <> bool is_valid_filter(t_dtype type, t_val date_parser, t_filter_op comp, t_val filter_term) { if (comp == t_filter_op::FILTER_OP_IS_NULL || comp == t_filter_op::FILTER_OP_IS_NOT_NULL) { return true; } else if (type == DTYPE_DATE || type == DTYPE_TIME) { if (py::isinstance<py::str>(filter_term)) { t_val parsed_date = date_parser.attr("parse")(filter_term); return !parsed_date.is_none(); } else { return !filter_term.is_none(); } } else { return !filter_term.is_none(); } }; template <> std::tuple<std::string, std::string, std::vector<t_tscalar>> make_filter_term(t_dtype column_type, t_val date_parser, const std::string& column_name, const std::string& filter_op_str, t_val filter_term) { t_filter_op filter_op = str_to_filter_op(filter_op_str); std::vector<t_tscalar> terms; switch (filter_op) { case FILTER_OP_NOT_IN: case FILTER_OP_IN: { std::vector<std::string> filter_terms = filter_term.cast<std::vector<std::string>>(); for (auto term : filter_terms) { terms.push_back(mktscalar(get_interned_cstr(term.c_str()))); } } break; case FILTER_OP_IS_NULL: case FILTER_OP_IS_NOT_NULL: { terms.push_back(mktscalar(0)); } break; default: { switch (column_type) { case DTYPE_INT32: { terms.push_back(mktscalar(filter_term.cast<std::int32_t>())); } break; case DTYPE_INT64: case DTYPE_FLOAT64: { terms.push_back(mktscalar(filter_term.cast<double>())); } break; case DTYPE_BOOL: { terms.push_back(mktscalar(filter_term.cast<bool>())); } break; case DTYPE_DATE: { if (py::isinstance<py::str>(filter_term)) { t_val parsed_date = date_parser.attr("parse")(filter_term); auto date_components = date_parser.attr("to_date_components")(parsed_date).cast<std::map<std::string, std::int32_t>>(); t_date dt = t_date(date_components["year"], date_components["month"], date_components["day"]); terms.push_back(mktscalar(dt)); } else { auto date_components = date_parser.attr("to_date_components")(filter_term).cast<std::map<std::string, std::int32_t>>(); t_date dt = t_date(date_components["year"], date_components["month"], date_components["day"]); terms.push_back(mktscalar(dt)); } } break; case DTYPE_TIME: { if (py::isinstance<py::str>(filter_term)) { t_val parsed_date = date_parser.attr("parse")(filter_term); std::int64_t ts = date_parser.attr("to_timestamp")(parsed_date).cast<std::int64_t>(); t_tscalar timestamp = mktscalar(t_time(ts)); terms.push_back(timestamp); } else { t_tscalar timestamp = mktscalar( t_time(date_parser.attr("to_timestamp")(filter_term).cast<std::int64_t>())); terms.push_back(timestamp); } } break; default: { terms.push_back( mktscalar(get_interned_cstr(filter_term.cast<std::string>().c_str()))); } } } } return std::make_tuple(column_name, filter_op_str, terms); } template <> std::shared_ptr<t_view_config> make_view_config( std::shared_ptr<t_schema> schema, t_val date_parser, t_val config) { auto row_pivots = config.attr("get_row_pivots")().cast<std::vector<std::string>>(); auto column_pivots = config.attr("get_column_pivots")().cast<std::vector<std::string>>(); auto columns = config.attr("get_columns")().cast<std::vector<std::string>>(); auto sort = config.attr("get_sort")().cast<std::vector<std::vector<std::string>>>(); auto filter_op = config.attr("get_filter_op")().cast<std::string>(); // to preserve order, do not cast to std::map - use keys and python 3.7's guarantee that dicts respect insertion order auto p_aggregates = py::dict(config.attr("get_aggregates")()); tsl::ordered_map<std::string, std::vector<std::string>> aggregates; for (auto& column : columns) { py::str py_column_name = py::str(column); if (p_aggregates.contains(py_column_name)) { if (py::isinstance<py::str>(p_aggregates[py_column_name])) { std::vector<std::string> agg{ p_aggregates[py_column_name].cast<std::string>()}; aggregates[column] = agg; } else { aggregates[column] = p_aggregates[py_column_name].cast<std::vector<std::string>>(); } } }; bool column_only = false; // make sure that primary keys are created for column-only views if (row_pivots.size() == 0 && column_pivots.size() > 0) { row_pivots.push_back("psp_okey"); column_only = true; } auto p_expressions = config.attr("get_expressions")().cast<std::vector<std::vector<t_val>>>(); std::vector<t_computed_expression> expressions; expressions.reserve(p_expressions.size()); // Will either abort() or succeed completely, and this isn't a public // API so we can directly index for speed. for (t_uindex idx = 0; idx < p_expressions.size(); ++idx) { const auto& expr = p_expressions[idx]; std::string expression_alias = expr[0].cast<std::string>(); std::string expression_string = expr[1].cast<std::string>(); std::string parsed_expression_string = expr[2].cast<std::string>(); // Don't allow overwriting of "real" table columns or multiple // columns with the same alias. if (schema->has_column(expression_alias)) { std::stringstream ss; ss << "View creation failed: cannot create expression column '" << expression_alias << "' that overwrites a column that already exists." << std::endl; PSP_COMPLAIN_AND_ABORT(ss.str()); } auto p_column_ids = py::dict(expr[3]); std::vector<std::pair<std::string, std::string>> column_ids; column_ids.resize(p_column_ids.size()); t_uindex cidx = 0; for (const auto& item : p_column_ids) { column_ids[cidx] = std::pair<std::string, std::string>( item.first.cast<std::string>(), item.second.cast<std::string>()); ++cidx; } // If the expression cannot be parsed, it will abort() here. t_computed_expression expression = t_computed_expression_parser::precompute( expression_alias, expression_string, parsed_expression_string, column_ids, schema); expressions.push_back(expression); schema->add_column(expression_alias, expression.get_dtype()); } // construct filters with filter terms, and fill the vector of tuples auto p_filter = config.attr("get_filter")().cast<std::vector<std::vector<t_val>>>(); std::vector<std::tuple<std::string, std::string, std::vector<t_tscalar>>> filter; for (auto f : p_filter) { // parse filter details std::string column_name = f[0].cast<std::string>(); std::string filter_op_str = f[1].cast<std::string>(); t_dtype column_type = schema->get_dtype(column_name); t_filter_op filter_operator = str_to_filter_op(filter_op_str); // validate the filter before it goes into the core engine t_val filter_term = py::none(); if (f.size() > 2) { // null/not null filters do not have a filter term filter_term = f[2]; } if (is_valid_filter(column_type, date_parser, filter_operator, filter_term)) { filter.push_back(make_filter_term(column_type, date_parser, column_name, filter_op_str, filter_term)); } } // create the `t_view_config` auto view_config = std::make_shared<t_view_config>( row_pivots, column_pivots, aggregates, columns, filter, sort, expressions, filter_op, column_only); // transform primitive values into abstractions that the engine can use view_config->init(schema); // set pivot depths if provided if (! config.attr("row_pivot_depth").is_none()) { view_config->set_row_pivot_depth(config.attr("row_pivot_depth").cast<std::int32_t>()); } if (! config.attr("column_pivot_depth").is_none()) { view_config->set_column_pivot_depth(config.attr("column_pivot_depth").cast<std::int32_t>()); } return view_config; } /****************************************************************************** * * make_view */ template <typename CTX_T> std::shared_ptr<View<CTX_T>> make_view(std::shared_ptr<Table> table, const std::string& name, const std::string& separator, t_val view_config, t_val date_parser) { // Use a copy of the table schema that we can freely mutate during // `make_view_config`. std::shared_ptr<t_schema> schema = std::make_shared<t_schema>(table->get_schema()); std::shared_ptr<t_view_config> config = make_view_config<t_val>(schema, date_parser, view_config); { PerspectiveScopedGILRelease acquire(table->get_pool()->get_event_loop_thread_id()); auto ctx = make_context<CTX_T>(table, schema, config, name); auto view_ptr = std::make_shared<View<CTX_T>>(table, ctx, name, separator, config); return view_ptr; } } std::shared_ptr<View<t_ctxunit>> make_view_unit(std::shared_ptr<Table> table, std::string name, std::string separator, t_val view_config, t_val date_parser) { return make_view<t_ctxunit>(table, name, separator, view_config, date_parser); } std::shared_ptr<View<t_ctx0>> make_view_ctx0(std::shared_ptr<Table> table, std::string name, std::string separator, t_val view_config, t_val date_parser) { return make_view<t_ctx0>(table, name, separator, view_config, date_parser); } std::shared_ptr<View<t_ctx1>> make_view_ctx1(std::shared_ptr<Table> table, std::string name, std::string separator, t_val view_config, t_val date_parser) { return make_view<t_ctx1>(table, name, separator, view_config, date_parser); } std::shared_ptr<View<t_ctx2>> make_view_ctx2(std::shared_ptr<Table> table, std::string name, std::string separator, t_val view_config, t_val date_parser) { return make_view<t_ctx2>(table, name, separator, view_config, date_parser); } /****************************************************************************** * * to_arrow */ py::bytes to_arrow_unit( std::shared_ptr<View<t_ctxunit>> view, std::int32_t start_row, std::int32_t end_row, std::int32_t start_col, std::int32_t end_col ) { PerspectiveScopedGILRelease acquire(view->get_event_loop_thread_id()); std::shared_ptr<std::string> str = view->to_arrow(start_row, end_row, start_col, end_col); return py::bytes(*str); } py::bytes to_arrow_zero( std::shared_ptr<View<t_ctx0>> view, std::int32_t start_row, std::int32_t end_row, std::int32_t start_col, std::int32_t end_col ) { PerspectiveScopedGILRelease acquire(view->get_event_loop_thread_id()); std::shared_ptr<std::string> str = view->to_arrow(start_row, end_row, start_col, end_col); return py::bytes(*str); } py::bytes to_arrow_one( std::shared_ptr<View<t_ctx1>> view, std::int32_t start_row, std::int32_t end_row, std::int32_t start_col, std::int32_t end_col ) { PerspectiveScopedGILRelease acquire(view->get_event_loop_thread_id()); std::shared_ptr<std::string> str = view->to_arrow(start_row, end_row, start_col, end_col); return py::bytes(*str); } py::bytes to_arrow_two( std::shared_ptr<View<t_ctx2>> view, std::int32_t start_row, std::int32_t end_row, std::int32_t start_col, std::int32_t end_col ) { PerspectiveScopedGILRelease acquire(view->get_event_loop_thread_id()); std::shared_ptr<std::string> str = view->to_arrow(start_row, end_row, start_col, end_col); return py::bytes(*str); } /****************************************************************************** * * get_row_delta */ py::bytes get_row_delta_unit(std::shared_ptr<View<t_ctxunit>> view) { PerspectiveScopedGILRelease acquire(view->get_event_loop_thread_id()); std::shared_ptr<t_data_slice<t_ctxunit>> slice = view->get_row_delta(); std::shared_ptr<std::string> arrow = view->data_slice_to_arrow(slice); return py::bytes(*arrow); } py::bytes get_row_delta_zero(std::shared_ptr<View<t_ctx0>> view) { PerspectiveScopedGILRelease acquire(view->get_event_loop_thread_id()); std::shared_ptr<t_data_slice<t_ctx0>> slice = view->get_row_delta(); std::shared_ptr<std::string> arrow = view->data_slice_to_arrow(slice); return py::bytes(*arrow); } py::bytes get_row_delta_one(std::shared_ptr<View<t_ctx1>> view) { PerspectiveScopedGILRelease acquire(view->get_event_loop_thread_id()); std::shared_ptr<t_data_slice<t_ctx1>> slice = view->get_row_delta(); std::shared_ptr<std::string> arrow = view->data_slice_to_arrow(slice); return py::bytes(*arrow); } py::bytes get_row_delta_two( std::shared_ptr<View<t_ctx2>> view) { PerspectiveScopedGILRelease acquire(view->get_event_loop_thread_id()); std::shared_ptr<t_data_slice<t_ctx2>> slice = view->get_row_delta(); std::shared_ptr<std::string> arrow = view->data_slice_to_arrow(slice); return py::bytes(*arrow); } } //namespace binding } //namespace perspective #endif
.syntax unified .cpu cortex-m4 .eabi_attribute 27, 3 .eabi_attribute 28, 1 .fpu fpv4-sp-d16 .eabi_attribute 20, 1 .eabi_attribute 21, 1 .eabi_attribute 23, 3 .eabi_attribute 24, 1 .eabi_attribute 25, 1 .eabi_attribute 26, 1 .eabi_attribute 30, 4 .eabi_attribute 18, 4 .thumb .file "Hello_world.c" bl main breakpoint: .word 0xf810f7fa b breakpoint printf: mov r9,lr .word 0xfdf0f7f9 bx r9 sprintf: mov r9,lr .word 0xfdf6f7f9 bx r9 .thumb @.text @.align 1 @.global getc .thumb @.thumb_func getc: @ args = 0, pretend = 0, frame = 0 @ frame_needed = 0, uses_anonymous_args = 0 ldr r2, .L2 push {r3, lr} movw r3, #8617 str r3, [r2, #0] @ 34 "C:/Users/TAJS/DOCUME~1/_Dev/include/ConBASICstartup.c" 1 push {r4,r7} @ 0 "" 2 @ 35 "C:/Users/TAJS/DOCUME~1/_Dev/include/ConBASICstartup.c" 1 mov r4,r0 @ 0 "" 2 .thumb blx r3 @ 37 "C:/Users/TAJS/DOCUME~1/_Dev/include/ConBASICstartup.c" 1 mov r0,r7 @ 0 "" 2 @ 38 "C:/Users/TAJS/DOCUME~1/_Dev/include/ConBASICstartup.c" 1 pop {r4,r7} @ 0 "" 2 @ 39 "C:/Users/TAJS/DOCUME~1/_Dev/include/ConBASICstartup.c" 1 pop {r3,pc} @ 0 "" 2 .thumb movs r0, #0 pop {r3, pc} .L3: @.align 2 .L2: .word 0x02000254 @ BASICfunc - a manual tweak, see .comm below @.align 1 @.global putc .thumb @.thumb_func putc: @ args = 0, pretend = 0, frame = 0 @ frame_needed = 0, uses_anonymous_args = 0 ldr r2, .L5 push {r3, lr} movw r3, #8629 str r3, [r2, #0] @ 46 "C:/Users/TAJS/DOCUME~1/_Dev/include/ConBASICstartup.c" 1 push {r4,r7} @ 0 "" 2 @ 47 "C:/Users/TAJS/DOCUME~1/_Dev/include/ConBASICstartup.c" 1 mov r7, r0 @ 0 "" 2 @ 48 "C:/Users/TAJS/DOCUME~1/_Dev/include/ConBASICstartup.c" 1 mov r4, r1 @ 0 "" 2 .thumb blx r3 @ 50 "C:/Users/TAJS/DOCUME~1/_Dev/include/ConBASICstartup.c" 1 mov r0,r7 @ 0 "" 2 @ 51 "C:/Users/TAJS/DOCUME~1/_Dev/include/ConBASICstartup.c" 1 pop {r4,r7} @ 0 "" 2 @ 52 "C:/Users/TAJS/DOCUME~1/_Dev/include/ConBASICstartup.c" 1 pop {r3,pc} @ 0 "" 2 .thumb movs r0, #0 pop {r3, pc} .L6: @.align 2 .L5: .word 0x02000254 @ BASICfunc - a manual tweak, see .comm below @.align 1 @.global puts .thumb @.thumb_func puts: @ args = 0, pretend = 0, frame = 0 @ frame_needed = 0, uses_anonymous_args = 0 push {r4, lr} mov r4, r0 movs r0, #0 b .L8 .L9: mov r0, r3 movs r1, #0 bl putc uxtb r0, r0 .L8: ldrb r3, [r4], #1 @ zero_extendqisi2 cmp r3, #0 bne .L9 pop {r4, pc} @.align 1 @.global micros .thumb @.thumb_func micros: @ args = 0, pretend = 0, frame = 0 @ frame_needed = 0, uses_anonymous_args = 0 ldr r2, .L11 push {r3, lr} movw r3, #7745 str r3, [r2, #0] @ 69 "C:/Users/TAJS/DOCUME~1/_Dev/include/ConBASICstartup.c" 1 push {r7} @ 0 "" 2 .thumb blx r3 @ 71 "C:/Users/TAJS/DOCUME~1/_Dev/include/ConBASICstartup.c" 1 mov r0,r7 @ 0 "" 2 @ 72 "C:/Users/TAJS/DOCUME~1/_Dev/include/ConBASICstartup.c" 1 pop {r7} @ 0 "" 2 @ 73 "C:/Users/TAJS/DOCUME~1/_Dev/include/ConBASICstartup.c" 1 pop {r3,pc} @ 0 "" 2 .thumb movs r0, #0 pop {r3, pc} .L12: @.align 2 .L11: .word 0x02000254 @ BASICfunc - a manual tweak, see .comm below @.align 1 @.global waitmicro .thumb @.thumb_func waitmicro: @ args = 0, pretend = 0, frame = 0 @ frame_needed = 0, uses_anonymous_args = 0 ldr r2, .L14 push {r3, lr} movw r3, #7777 str r3, [r2, #0] @ 80 "C:/Users/TAJS/DOCUME~1/_Dev/include/ConBASICstartup.c" 1 push {r7} @ 0 "" 2 @ 81 "C:/Users/TAJS/DOCUME~1/_Dev/include/ConBASICstartup.c" 1 mov r7,r0 @ 0 "" 2 .thumb blx r3 @ 83 "C:/Users/TAJS/DOCUME~1/_Dev/include/ConBASICstartup.c" 1 pop {r7} @ 0 "" 2 .thumb pop {r3, pc} .L15: @.align 2 .L14: .word 0x02000254 @ BASICfunc - a manual tweak, see .comm below @.align 1 @.global wait .thumb @.thumb_func wait: @ args = 0, pretend = 0, frame = 0 @ frame_needed = 0, uses_anonymous_args = 0 ldr r2, .L17 push {r3, lr} movw r3, #7783 str r3, [r2, #0] @ 89 "C:/Users/TAJS/DOCUME~1/_Dev/include/ConBASICstartup.c" 1 push {r7} @ 0 "" 2 @ 90 "C:/Users/TAJS/DOCUME~1/_Dev/include/ConBASICstartup.c" 1 mov r7,r0 @ 0 "" 2 .thumb blx r3 @ 92 "C:/Users/TAJS/DOCUME~1/_Dev/include/ConBASICstartup.c" 1 pop {r7} @ 0 "" 2 .thumb pop {r3, pc} .L18: @.align 2 .L17: .word 0x02000254 @ BASICfunc - a manual tweak, see .comm below @.align 1 @.global rdDIR .thumb @.thumb_func rdDIR: @ args = 0, pretend = 0, frame = 0 @ frame_needed = 0, uses_anonymous_args = 0 ldr r2, .L20 push {r3, lr} movw r3, #8569 str r3, [r2, #0] @ 98 "C:/Users/TAJS/DOCUME~1/_Dev/include/ConBASICstartup.c" 1 push {r7} @ 0 "" 2 @ 99 "C:/Users/TAJS/DOCUME~1/_Dev/include/ConBASICstartup.c" 1 mov r7,r0 @ 0 "" 2 .thumb blx r3 @ 101 "C:/Users/TAJS/DOCUME~1/_Dev/include/ConBASICstartup.c" 1 mov r0,r7 @ 0 "" 2 @ 102 "C:/Users/TAJS/DOCUME~1/_Dev/include/ConBASICstartup.c" 1 pop {r7} @ 0 "" 2 @ 103 "C:/Users/TAJS/DOCUME~1/_Dev/include/ConBASICstartup.c" 1 pop {r3,pc} @ 0 "" 2 .thumb movs r0, #0 pop {r3, pc} .L21: @.align 2 .L20: .word 0x02000254 @ BASICfunc - a manual tweak, see .comm below @.align 1 @.global wrDIR .thumb @.thumb_func wrDIR: @ args = 0, pretend = 0, frame = 0 @ frame_needed = 0, uses_anonymous_args = 0 ldr r2, .L23 push {r3, lr} movw r3, #8459 str r3, [r2, #0] @ 110 "C:/Users/TAJS/DOCUME~1/_Dev/include/ConBASICstartup.c" 1 push {r4,r7} @ 0 "" 2 @ 111 "C:/Users/TAJS/DOCUME~1/_Dev/include/ConBASICstartup.c" 1 mov r4,r0 @ 0 "" 2 @ 112 "C:/Users/TAJS/DOCUME~1/_Dev/include/ConBASICstartup.c" 1 mov r7,r1 @ 0 "" 2 .thumb blx r3 @ 114 "C:/Users/TAJS/DOCUME~1/_Dev/include/ConBASICstartup.c" 1 pop {r4,r7} @ 0 "" 2 .thumb pop {r3, pc} .L24: @.align 2 .L23: .word 0x02000254 @ BASICfunc - a manual tweak, see .comm below @.align 1 @.global rdGPIO .thumb @.thumb_func rdGPIO: @ args = 0, pretend = 0, frame = 0 @ frame_needed = 0, uses_anonymous_args = 0 ldr r2, .L26 push {r3, lr} movw r3, #8501 str r3, [r2, #0] @ 120 "C:/Users/TAJS/DOCUME~1/_Dev/include/ConBASICstartup.c" 1 push {r7} @ 0 "" 2 @ 121 "C:/Users/TAJS/DOCUME~1/_Dev/include/ConBASICstartup.c" 1 mov r7,r0 @ 0 "" 2 .thumb blx r3 @ 123 "C:/Users/TAJS/DOCUME~1/_Dev/include/ConBASICstartup.c" 1 mov r0,r7 @ 0 "" 2 @ 124 "C:/Users/TAJS/DOCUME~1/_Dev/include/ConBASICstartup.c" 1 pop {r7} @ 0 "" 2 @ 125 "C:/Users/TAJS/DOCUME~1/_Dev/include/ConBASICstartup.c" 1 pop {r3,pc} @ 0 "" 2 .thumb movs r0, #0 pop {r3, pc} .L27: @.align 2 .L26: .word 0x02000254 @ BASICfunc - a manual tweak, see .comm below @.align 1 @.global wrGPIO .thumb @.thumb_func wrGPIO: @ args = 0, pretend = 0, frame = 0 @ frame_needed = 0, uses_anonymous_args = 0 ldr r2, .L29 push {r3, lr} movw r3, #8537 str r3, [r2, #0] @ 132 "C:/Users/TAJS/DOCUME~1/_Dev/include/ConBASICstartup.c" 1 push {r4,r7} @ 0 "" 2 @ 133 "C:/Users/TAJS/DOCUME~1/_Dev/include/ConBASICstartup.c" 1 mov r4,r0 @ 0 "" 2 @ 134 "C:/Users/TAJS/DOCUME~1/_Dev/include/ConBASICstartup.c" 1 mov r7,r1 @ 0 "" 2 .thumb blx r3 @ 136 "C:/Users/TAJS/DOCUME~1/_Dev/include/ConBASICstartup.c" 1 pop {r4,r7} @ 0 "" 2 .thumb pop {r3, pc} .L30: @.align 2 .L29: .word 0x02000254 @ BASICfunc - a manual tweak, see .comm below @.align 1 @.global intsw .thumb @.thumb_func intsw: @ args = 0, pretend = 0, frame = 0 @ frame_needed = 0, uses_anonymous_args = 0 ldr r2, .L32 push {r3, lr} movw r3, #8353 str r3, [r2, #0] @ 142 "C:/Users/TAJS/DOCUME~1/_Dev/include/ConBASICstartup.c" 1 push {r7} @ 0 "" 2 @ 143 "C:/Users/TAJS/DOCUME~1/_Dev/include/ConBASICstartup.c" 1 mov r7,r0 @ 0 "" 2 .thumb blx r3 @ 145 "C:/Users/TAJS/DOCUME~1/_Dev/include/ConBASICstartup.c" 1 pop {r7} @ 0 "" 2 .thumb pop {r3, pc} .L33: @.align 2 .L32: .word 0x02000254 @ BASICfunc - a manual tweak, see .comm below @.align 1 @.global setbaud .thumb @.thumb_func setbaud: @ args = 0, pretend = 0, frame = 0 @ frame_needed = 0, uses_anonymous_args = 0 ldr r2, .L35 push {r3, lr} movw r3, #8609 str r3, [r2, #0] @ 151 "C:/Users/TAJS/DOCUME~1/_Dev/include/ConBASICstartup.c" 1 push {r4,r7} @ 0 "" 2 @ 152 "C:/Users/TAJS/DOCUME~1/_Dev/include/ConBASICstartup.c" 1 mov r4,r0 @ 0 "" 2 @ 153 "C:/Users/TAJS/DOCUME~1/_Dev/include/ConBASICstartup.c" 1 mov r7,r1 @ 0 "" 2 .thumb blx r3 @ 155 "C:/Users/TAJS/DOCUME~1/_Dev/include/ConBASICstartup.c" 1 pop {r4,r7} @ 0 "" 2 .thumb pop {r3, pc} .L36: @.align 2 .L35: .word 0x02000254 @ BASICfunc - a manual tweak, see .comm below @.align 1 @.global settimer .thumb @.thumb_func settimer: @ args = 0, pretend = 0, frame = 0 @ frame_needed = 0, uses_anonymous_args = 0 ldr r2, .L38 push {r3, lr} movw r3, #7755 str r3, [r2, #0] @ 162 "C:/Users/TAJS/DOCUME~1/_Dev/include/ConBASICstartup.c" 1 push {r7} @ 0 "" 2 @ 163 "C:/Users/TAJS/DOCUME~1/_Dev/include/ConBASICstartup.c" 1 mov r7,r0 @ 0 "" 2 .thumb blx r3 @ 165 "C:/Users/TAJS/DOCUME~1/_Dev/include/ConBASICstartup.c" 1 pop {r7} @ 0 "" 2 .thumb pop {r3, pc} .L39: @.align 2 .L38: .word 0x02000254 @ BASICfunc - a manual tweak, see .comm below @.align 1 @.global flash_write .thumb @.thumb_func flash_write: @ args = 0, pretend = 0, frame = 0 @ frame_needed = 0, uses_anonymous_args = 0 push {r3, lr} @ 170 "C:/Users/TAJS/DOCUME~1/_Dev/include/ConBASICstartup.c" 1 push {r4,r7} @ 0 "" 2 @ 171 "C:/Users/TAJS/DOCUME~1/_Dev/include/ConBASICstartup.c" 1 mov r4,r9 @ 0 "" 2 @ 172 "C:/Users/TAJS/DOCUME~1/_Dev/include/ConBASICstartup.c" 1 push {r4} @ 0 "" 2 @ 173 "C:/Users/TAJS/DOCUME~1/_Dev/include/ConBASICstartup.c" 1 mov r4,r0 @ 0 "" 2 @ 174 "C:/Users/TAJS/DOCUME~1/_Dev/include/ConBASICstartup.c" 1 mov r9,r1 @ 0 "" 2 @ 175 "C:/Users/TAJS/DOCUME~1/_Dev/include/ConBASICstartup.c" 1 mov r7,r2 @ 0 "" 2 .thumb ldr r2, .L41 movw r3, #8363 str r3, [r2, #0] blx r3 @ 178 "C:/Users/TAJS/DOCUME~1/_Dev/include/ConBASICstartup.c" 1 mov r0,r7 @ 0 "" 2 @ 179 "C:/Users/TAJS/DOCUME~1/_Dev/include/ConBASICstartup.c" 1 pop {r4} @ 0 "" 2 @ 180 "C:/Users/TAJS/DOCUME~1/_Dev/include/ConBASICstartup.c" 1 mov r9,r4 @ 0 "" 2 @ 181 "C:/Users/TAJS/DOCUME~1/_Dev/include/ConBASICstartup.c" 1 pop {r4,r7} @ 0 "" 2 @ 182 "C:/Users/TAJS/DOCUME~1/_Dev/include/ConBASICstartup.c" 1 pop {r3,pc} @ 0 "" 2 .thumb movs r0, #0 pop {r3, pc} .L42: @.align 2 .L41: .word 0x02000254 @ BASICfunc - a manual tweak, see .comm below @.align 1 @.global adin .thumb @.thumb_func adin: @ args = 0, pretend = 0, frame = 0 @ frame_needed = 0, uses_anonymous_args = 0 ldr r2, .L44 push {r3, lr} movw r3, #8963 str r3, [r2, #0] @ 190 "C:/Users/TAJS/DOCUME~1/_Dev/include/ConBASICstartup.c" 1 push {r7} @ 0 "" 2 @ 191 "C:/Users/TAJS/DOCUME~1/_Dev/include/ConBASICstartup.c" 1 mov r7,r0 @ 0 "" 2 .thumb blx r3 @ 193 "C:/Users/TAJS/DOCUME~1/_Dev/include/ConBASICstartup.c" 1 mov r0,r7 @ 0 "" 2 @ 194 "C:/Users/TAJS/DOCUME~1/_Dev/include/ConBASICstartup.c" 1 pop {r7} @ 0 "" 2 @ 195 "C:/Users/TAJS/DOCUME~1/_Dev/include/ConBASICstartup.c" 1 pop {r3,pc} @ 0 "" 2 .thumb movs r0, #0 pop {r3, pc} .L45: @.align 2 .L44: .word 0x02000254 @ BASICfunc - a manual tweak, see .comm below .word 0x6c6c6548 .word 0x6f57206f .word 0x2c646c72 .word 0x776f4e20 .word 0x6f726420 .word 0x6e692070 .word 0x74206f74 .word 0x72206568 .word 0x69746e75 .word 0x6420656d .word 0x67756265 .word 0x0d726567 .word 0x20000d0a .word 0x70797420 .word 0x68402065 .word 0x6e2d7865 .word 0x65626d75 .word 0x6f742072 .word 0x73696420 .word 0x79616c70 .word 0x6d656d20 .word 0x2f79726f .word 0x69676572 .word 0x72657473 .word 0x20746120 .word 0x2d786568 .word 0x626d756e .word 0x000d7265 .word 0x79742020 .word 0x40206570 .word 0x2d786568 .word 0x626d756e .word 0x68207265 .word 0x6e2d7865 .word 0x20326d75 .word 0x64206f74 .word 0x6c707369 .word 0x6d207961 .word 0x726f6d65 .word 0x65722f79 .word 0x74736967 .word 0x61207265 .word 0x65682074 .word 0x756e2d78 .word 0x7265626d .word 0x726f6620 .word 0x78656820 .word 0x6d756e5f .word 0x20726562 .word 0x64726f77 .word 0x20000d73 .word 0x70797420 .word 0x68212065 .word 0x6e2d7865 .word 0x65626d75 .word 0x65682072 .word 0x756e2d78 .word 0x7420326d .word 0x6863206f .word 0x65676e61 .word 0x6d656d20 .word 0x2079726f .word 0x65682040 .word 0x756e2d78 .word 0x7265626d .word 0x206f7420 .word 0x2d786568 .word 0x326d756e .word 0x2020000d .word 0x65707974 .word 0x66205e20 .word 0x6320726f .word 0x2065646f .word 0x63206f74 .word 0x69746e6f .word 0x0d65756e .word 0x0d000d0a .word 0x620a0d0a .word 0x6b616572 .word 0x6e696f70 .word 0x6f642074 .word 0x6120656e .word 0x7720646e .word 0x65722765 .word 0x6e6f6320 .word 0x756e6974 .word 0x2e676e69 .word 0x000d2e2e @.section .text.startup,"ax",%progbits @.align 1 @.global main .thumb @.thumb_func main: @ args = 0, pretend = 0, frame = 0 @ frame_needed = 0, uses_anonymous_args = 0 push {r3, lr} ldr r0, .L47 bl puts ldr r0, .L47+4 bl puts ldr r0, .L47+8 bl puts ldr r0, .L47+12 bl puts ldr r0, .L47+16 bl puts bl breakpoint ldr r0, .L47+20 bl puts movs r0, #0 pop {r3, pc} .L48: @.align 2 .L47: .word 0x000081d0 .word 0x00008203 .word 0x00008240 .word 0x0000829b .word 0x000082e2 .word 0x00008303
.global s_prepare_buffers s_prepare_buffers: push %r10 push %r11 push %r12 push %rax push %rcx push %rdi push %rdx push %rsi lea addresses_A_ht+0x1263d, %r11 nop nop and %rax, %rax mov (%r11), %rdx nop nop nop nop xor $43124, %rcx lea addresses_UC_ht+0x72cf, %rsi lea addresses_WC_ht+0x185c5, %rdi nop nop nop nop inc %r12 mov $72, %rcx rep movsb nop nop dec %rax lea addresses_UC_ht+0x4c3d, %rsi lea addresses_D_ht+0x1ed3d, %rdi nop nop nop nop nop sub $44888, %r10 mov $103, %rcx rep movsb nop nop nop nop lfence lea addresses_A_ht+0x101fd, %rsi lea addresses_WC_ht+0x9305, %rdi clflush (%rsi) clflush (%rdi) nop nop sub %r10, %r10 mov $33, %rcx rep movsq nop nop nop nop cmp %r11, %r11 lea addresses_UC_ht+0x1877d, %rcx nop nop nop xor $43137, %rax movups (%rcx), %xmm0 vpextrq $1, %xmm0, %rdx nop sub $4021, %r12 lea addresses_UC_ht+0xbd3d, %rsi lea addresses_A_ht+0x453d, %rdi nop nop nop nop sub $45699, %r11 mov $70, %rcx rep movsw cmp %rdi, %rdi lea addresses_WT_ht+0x973d, %rsi lea addresses_WC_ht+0xb53d, %rdi nop nop nop and $29638, %r11 mov $72, %rcx rep movsl nop sub $51055, %r12 lea addresses_WT_ht+0x1482d, %rsi nop inc %rcx movb (%rsi), %r10b nop nop nop cmp %rdx, %rdx lea addresses_WT_ht+0x1ef29, %rdi nop nop nop nop nop and $43007, %rax mov (%rdi), %r11w nop cmp $59804, %rcx lea addresses_UC_ht+0x553d, %r12 nop nop dec %rcx movl $0x61626364, (%r12) nop xor $2544, %rsi lea addresses_A_ht+0x1a7d, %rdi nop nop nop sub %r11, %r11 movups (%rdi), %xmm7 vpextrq $1, %xmm7, %rax nop xor %rax, %rax lea addresses_A_ht+0x3875, %r11 nop and $22696, %rcx movl $0x61626364, (%r11) nop nop nop nop nop dec %rsi pop %rsi pop %rdx pop %rdi pop %rcx pop %rax pop %r12 pop %r11 pop %r10 ret .global s_faulty_load s_faulty_load: push %r11 push %r12 push %r8 push %r9 push %rbp push %rdi push %rdx // Store lea addresses_WT+0xcbbd, %r12 nop nop nop cmp $8414, %rdx movb $0x51, (%r12) nop nop nop nop xor $53032, %r11 // Load lea addresses_A+0x153d, %r12 clflush (%r12) add $45025, %r8 mov (%r12), %di xor %rbp, %rbp // Faulty Load lea addresses_RW+0x1e53d, %r8 nop sub $41143, %rbp mov (%r8), %di lea oracles, %r11 and $0xff, %rdi shlq $12, %rdi mov (%r11,%rdi,1), %rdi pop %rdx pop %rdi pop %rbp pop %r9 pop %r8 pop %r12 pop %r11 ret /* <gen_faulty_load> [REF] {'src': {'same': False, 'congruent': 0, 'NT': False, 'type': 'addresses_RW', 'size': 1, 'AVXalign': False}, 'OP': 'LOAD'} {'OP': 'STOR', 'dst': {'same': False, 'congruent': 7, 'NT': False, 'type': 'addresses_WT', 'size': 1, 'AVXalign': False}} {'src': {'same': False, 'congruent': 10, 'NT': False, 'type': 'addresses_A', 'size': 2, 'AVXalign': False}, 'OP': 'LOAD'} [Faulty Load] {'src': {'same': True, 'congruent': 0, 'NT': False, 'type': 'addresses_RW', 'size': 2, 'AVXalign': False}, 'OP': 'LOAD'} <gen_prepare_buffer> {'src': {'same': False, 'congruent': 5, 'NT': False, 'type': 'addresses_A_ht', 'size': 8, 'AVXalign': False}, 'OP': 'LOAD'} {'src': {'type': 'addresses_UC_ht', 'congruent': 1, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_WC_ht', 'congruent': 1, 'same': False}} {'src': {'type': 'addresses_UC_ht', 'congruent': 8, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_D_ht', 'congruent': 10, 'same': False}} {'src': {'type': 'addresses_A_ht', 'congruent': 6, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_WC_ht', 'congruent': 3, 'same': False}} {'src': {'same': False, 'congruent': 6, 'NT': False, 'type': 'addresses_UC_ht', 'size': 16, 'AVXalign': False}, 'OP': 'LOAD'} {'src': {'type': 'addresses_UC_ht', 'congruent': 11, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_A_ht', 'congruent': 10, 'same': False}} {'src': {'type': 'addresses_WT_ht', 'congruent': 7, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_WC_ht', 'congruent': 10, 'same': False}} {'src': {'same': False, 'congruent': 4, 'NT': False, 'type': 'addresses_WT_ht', 'size': 1, 'AVXalign': False}, 'OP': 'LOAD'} {'src': {'same': False, 'congruent': 2, 'NT': False, 'type': 'addresses_WT_ht', 'size': 2, 'AVXalign': True}, 'OP': 'LOAD'} {'OP': 'STOR', 'dst': {'same': False, 'congruent': 11, 'NT': False, 'type': 'addresses_UC_ht', 'size': 4, 'AVXalign': False}} {'src': {'same': False, 'congruent': 5, 'NT': False, 'type': 'addresses_A_ht', 'size': 16, 'AVXalign': False}, 'OP': 'LOAD'} {'OP': 'STOR', 'dst': {'same': False, 'congruent': 2, 'NT': True, 'type': 'addresses_A_ht', 'size': 4, 'AVXalign': False}} {'32': 21829} 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 */
; Source name : RANDTEST.ASM ; Executable name : RANDTEST ; Version : 2.0 ; Created date : 12/1/1999 ; Last update : 5/22/2009 ; Author : Jeff Duntemann ; Description : A demo of Unix rand & srand using NASM 2.05 ; ; Build using these commands: ; nasm -f elf -g -F stabs randtest.asm ; gcc randtest.o -o randtest ; [SECTION .data] ; Section containing initialised data Pulls dd 36 ; How many numbers do we pull? Display db 10,'Here is an array of %d %d-bit random numbners:',10,0 ShowArray db '%10d %10d %10d %10d %10d %10d',10,0 CharTbl db '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-@' [SECTION .bss] ; Section containing uninitialized data BUFSIZE equ 70 ; # of randomly chosen chars RandVal resd 1 ; Reserve an integer variable Stash resd 72 ; Reserve an array of 72 integers for randoms RandChar resb BUFSIZE+5 ; Buffer for storing randomly chosen characters [SECTION .text] ; Section containing code extern printf extern puts extern rand extern scanf extern srand extern time ;------------------------------------------------------------------------------ ; Random number generator procedures -- Last update 5/22/2009 ; ; This routine provides 5 entry points, and returns 5 different "sizes" of ; pseudorandom numbers based on the value returned by rand. Note first of ; all that rand pulls a 31-bit value. The high 16 bits are the most "random" ; so to return numbers in a smaller range, you fetch a 31-bit value and then ; right shift it zero-fill all but the number of bits you want. An 8-bit ; random value will range from 0-255, a 7-bit value from 0-127, and so on. ; Respects EBP, ESI, EDI, EBX, and ESP. Returns random value in EAX. ;------------------------------------------------------------------------------ pull31: mov ecx,0 ; For 31 bit random, we don't shift jmp pull pull16: mov ecx,15 ; For 16 bit random, shift by 15 bits jmp pull pull8: mov ecx,23 ; For 8 bit random, shift by 23 bits jmp pull pull7: mov ecx,24 ; For 7 bit random, shift by 24 bits jmp pull pull6: mov ecx,25 ; For 6 bit random, shift by 25 bits jmp pull pull4: mov ecx,27 ; For 4 bit random, shift by 27 bits pull: push ecx ; rand trashes ecx; save shift value on stack call rand ; Call rand for random value; returned in EAX pop ecx ; Pop stashed shift value back into ECX shr eax,cl ; Shift the random value by the chosen factor ; keeping in mind that part we want is in CL ret ; Go home with random number in EAX ;--------------------------------------------------------------------------- ; Newline outputter -- Last update 5/22/2009 ; ; This routine allows you to output a number of newlines to stdout, given ; by the value passed in EAX. Legal values are 1-10. All sacred registers ; are respected. Passing 0 in EAX will result in no newlines being issued. ;--------------------------------------------------------------------------- newline: mov ecx,10 ; We need a skip value, which is 10 minus the sub ecx,eax ; number of newlines the caller wants. add ecx,nl ; This skip value is added to the address of push ecx ; the newline buffer nl before calling printf. call printf ; Display the selected number of newlines add esp,4 ; Stack cleanup for one parm ret ; Go home nl db 10,10,10,10,10,10,10,10,10,10,0 ;; This subroutine displays numbers six at a time ;; Not intended to be general-purpose... shownums: mov esi, dword [Pulls] ; Put pull count into ESI .dorow: mov edi,6 ; Put row element counter into EDI .pushr: dec edi ; Decrement row element counter dec esi ; Decrement pulls counter push dword [Stash+esi*4]; Push number from array onto stack cmp edi,0 ; Have we filled the row yet? jne .pushr ; If not, go push another one push ShowArray ; Push address of base display string call printf ; Display the random numbers add esp,28 ; Stack cleanup: 7 items X 4 bytes = 28 cmp esi,0 ; See if pull count has gone to 0 jnz .dorow ; If not, we go back and do another row! ret ; Done, so go home! ;; This subroutine pulls random values and stuffs them into an ;; integer array. Not intended to be general purpose. Note that ;; the address of the random number generator entry point must ;; be loaded into edi before this is called, or you'll seg fault! puller: mov esi,dword [Pulls] ; Put pull count into ESI .grab: dec esi ; Decrement counter in ESI call edi ; Pull the value; it's returned in eax mov [Stash+esi*4],eax ; Store random value in the array cmp esi,0 ; See if we've pulled 4 yet jne .grab ; Do another if ESI <> 0 ret ; Otherwise, go home! ; MAIN PROGRAM: global main ; Required so linker can find entry point main: push ebp ; Set up stack frame for debugger mov ebp,esp push ebx ; Program must preserve EBP, EBX, ESI, & EDI push esi push edi ;;; Everything before this is boilerplate; use it for all ordinary apps! ; Begin by seeding the random number generator with a time_t value: Seedit: push 0 ; Push a 32-bit null pointer to stack call time ; Returns time_t value (32-bit integer) in EAX add esp,4 ; Stack cleanup for one parm push eax ; Push time_t value in EAX onto stack call srand ; Time_t value is the seed value for random # gen add esp,4 ; Stack cleanup for one parm ; All of the following code blocks are identical except for the size of ; the random value being generated: ; Create and display an array of 31-bit random values mov edi,pull31 ; Copy address of random # subroutine into EDI call puller ; Pull as many numbers as called for in [pulls] push 32 ; Size of numbers being pulled, in bits push dword [Pulls] ; Number of random numbers generated push Display ; Address of base display string call printf ; Display the label add esp,12 ; Stack cleanup: 3 parms X 4 bytes = 12 call shownums ; Display the rows of random numbers ; Create and display an array of 16-bit random values mov edi,pull16 ; Copy address of random # subroutine into edi call puller ; Pull as many numbers as called for in [pulls] push 16 ; Size of numbers being pulled, in bits push dword [Pulls] ; Number of random numbers generated push Display ; Address of base display string call printf ; Display the label add esp,12 ; Stack cleanup: 3 parms X 4 bytes = 12 call shownums ; Display the rows of random numbers ; Create and display an array of 8-bit random values: mov edi,pull8 ; Copy address of random # subroutine into edi call puller ; Pull as many numbers as called for in [pulls] push 8 ; Size of numbers being pulled, in bits push dword [Pulls] ; Number of random numbers generated push Display ; Address of base display string call printf ; Display the label add esp,12 ; Stack cleanup: 3 parms X 4 bytes = 12 call shownums ; Display the rows of random numbers ; Create and display an array of 7-bit random values: mov edi,pull7 ; Copy address of random # subroutine into edi call puller ; Pull as many numbers as called for in [pulls] push 7 ; Size of numbers being pulled, in bits push dword [Pulls] ; Number of random numbers generated push Display ; Address of base display string call printf ; Display the label add esp,12 ; Stack cleanup: 3 parms X 4 bytes = 12 call shownums ; Display the rows of random numbers ; Create and display an array of 4-bit random values: mov edi,pull4 ; Copy addr. of random # subroutine into EDI call puller ; Pull as many #s as called for in [pulls] push 4 ; Size of numbers being pulled, in bits push dword [Pulls] ; Number of random numbers generated push Display ; Address of base display string call printf ; Display the label add esp,12 ; Stack cleanup: 3 parms X 4 bytes = 12 call shownums ; Display the rows of random numbers ; Clear a buffer to nulls: Bufclr: mov ecx, BUFSIZE+5 ; Fill whole buffer plus 5 for safety .loop: dec ecx ; BUFSIZE is 1-based so decrement first! mov byte [RandChar+ecx],0 ; Mov null into the buffer cmp ecx,0 ; Are we done yet? jnz .loop ; If not, go back and stuff another null ; Create a string of random alphanumeric characters: Pulchr: mov ebx, BUFSIZE ; BUFSIZE tells us how many chars to pull .loop: dec ebx ; BUFSIZE is 1-based, so decrement first! mov edi,pull6 ; For random in the range 0-63 call puller ; Go get a random number from 0-63 mov cl,[CharTbl+eax] ; Use random # in eax as offset into table ; and copy character from table into CL mov [RandChar+ebx],cl ; Copy char from CL to character buffer cmp ebx,0 ; Are we done having fun yet? jne .loop ; If not, go back and pull another ; Display the string of random characters: mov eax,1 ; Output a newline call newline ; using the newline procedure push RandChar ; Push the address of the char buffer call puts ; Call puts to display it add esp,4 ; Stack cleanup for one parm mov eax,1 ; Output a newline call newline ; using the newline subroutine ;;; Everything after this is boilerplate; use it for all ordinary apps! pop edi ; Restore saved registers pop esi pop ebx mov esp,ebp ; Destroy stack frame before returning pop ebp ret ; Return control to Linux
#include "rpcprotocol.h" #include "net.h" #include "net/cnodestats.h" #include "cblock.h" #include "ctransaction.h" #include "ctxout.h" #include "ctxin.h" #include "main_const.h" #include "cpubkey.h" #include "init.h" #include "cwallet.h" #include "cmasternodepayments.h" #include "util.h" #include "chainparams.h" #include "cchainparams.h" #include "cbignum.h" #include "main_extern.h" #include "cblockindex.h" #include "miner.h" #include "creservekey.h" json_spirit::Value mintblock(const json_spirit::Array& params, bool fHelp) { CBlock* block; CReserveKey* pMiningKey = NULL; pMiningKey = new CReserveKey(pwalletMain); block = CreateNewBlock(*pMiningKey); bool fAccepted = ProcessBlock(NULL, block); if (!fAccepted) { return "rejected"; } return block->ToString(); } /* // Example json_spirit::Value mintblock(const json_spirit::Array& params, bool fHelp) { CNodeStats stats; pnodeLocalHost->copyStats(stats); return stats.addrName; } */
LDA #$37 BPL LABEL OUT A LABEL: LDA #$FF OUT A
; A144917: a(n) is the maximal odd value attained by A144916(n). ; 1,3,7,13,19,25,31,37,43,49,55,61,67,73,79,85,91,97,103,109,115,121,127,133,139,145,151,157,163,169,175,181,187,193,199,205,211,217,223,229,235,241,247,253,259,265,271,277,283,289,295,301,307,313,319,325,331 mul $0,2 add $0,1 mov $1,$0 trn $0,4 mul $0,2 add $1,$0
extern UnsafeMemoryCopy: PROC .code Md5DotNet PROC push r15 push r14 push r13 push r12 push rdi push rsi push rbp push rbx sub rsp,78h mov rsi,rcx lea rdi,[rsp+38h] mov ecx,10h xor eax,eax rep stos dword ptr [rdi] mov rcx,rsi mov rbx,rcx mov edi,edx mov rsi,r8 lea eax,[rdi+8] cdq and edx,3Fh add eax,edx sar eax,6 lea ebp,[rax+1] mov dword ptr [rsi],67452301h mov dword ptr [rsi+4],0EFCDAB89h mov dword ptr [rsi+8],98BADCFEh mov dword ptr [rsi+0Ch],10325476h xor ecx,ecx lea rdx,[rsp+38h] vxorpd xmm0,xmm0,xmm0 vmovdqu xmmword ptr [rdx],xmm0 vmovdqu xmmword ptr [rdx+10h],xmm0 vmovdqu xmmword ptr [rdx+20h],xmm0 vmovdqu xmmword ptr [rdx+30h],xmm0 xor r14d,r14d test ebp,ebp jle LoopExit lea r15,[rsi+4] lea r12,[rsi+8] lea r13,[rsi+0Ch] LoopStart: mov eax,r14d shl eax,6 lea ecx,[rax+40h] cmp ecx,edi jle AssignInputToBlock cmp eax,edi jl AddRemainingBytesToPadding cmp eax,edi jne ClearPaddingBlock mov byte ptr [rsp+38h],80h jmp SetOriginalLength ClearPaddingBlock: xor ecx,ecx lea rax,[rsp+38h] vxorpd xmm0,xmm0,xmm0 vmovdqu xmmword ptr [rax],xmm0 vmovdqu xmmword ptr [rax+10h],xmm0 vmovdqu xmmword ptr [rax+20h],xmm0 vmovdqu xmmword ptr [rax+30h],xmm0 SetOriginalLength: movsxd rcx,edi shl rcx,3 mov qword ptr [rsp+70h],rcx jmp AssignPaddingToBlock AddRemainingBytesToPadding: sub ecx,edi neg ecx lea r9d,[rcx+40h] lea r10,[rsp+38h] movsxd rcx,eax add rcx,rbx mov qword ptr [rsp+28h],r10 mov rdx,r10 mov dword ptr [rsp+34h],r9d mov r8d,r9d call UnsafeMemoryCopy mov eax,dword ptr [rsp+34h] movsxd rdx,eax mov rcx,qword ptr [rsp+28h] mov byte ptr [rcx+rdx],80h inc eax neg eax add eax,40h cmp eax,8 jl AssignPaddingToBlock movsxd rax,edi shl rax,3 mov qword ptr [rsp+70h],rax AssignPaddingToBlock: lea rax,[rsp+38h] jmp StartInnerLoop AssignInputToBlock: movsxd rax,eax add rax,rbx StartInnerLoop: mov edx,dword ptr [rsi] mov ecx,dword ptr [rsi+4] mov r8d,dword ptr [rsi+8] mov r9d,dword ptr [rsi+0Ch] ;0 mov r10d,r8d xor r10d,r9d and r10d,ecx xor r10d,r9d add edx,r10d mov r10d,dword ptr [rax] lea r11d,[rdx+r10-28955B88h] mov edx,r11d shl edx,7 shr r11d,19h or edx,r11d add edx,ecx ;1 mov r10d,ecx xor r10d,r8d and r10d,edx xor r10d,r8d add r9d,r10d mov r10d,dword ptr [rax+4] lea r11d,[r9+r10-173848AAh] mov r9d,r11d shl r9d,0Ch shr r11d,14h or r9d,r11d add r9d,edx ;2 mov r10d,edx xor r10d,ecx and r10d,r9d xor r10d,ecx add r8d,r10d mov r10d,dword ptr [rax+8] lea r11d,[r8+r10+242070DBh] mov r8d,r11d shl r8d,11h shr r11d,0Fh or r8d,r11d add r8d,r9d ;3 mov r10d,r9d xor r10d,edx and r10d,r8d xor r10d,edx add ecx,r10d mov r10d,dword ptr [rax+0Ch] lea r11d,[rcx+r10-3E423112h] mov ecx,r11d shl ecx,16h shr r11d,0Ah or ecx,r11d add ecx,r8d ;4 mov r10d,r8d xor r10d,r9d and r10d,ecx xor r10d,r9d add edx,r10d mov r10d,dword ptr [rax+10h] lea r11d,[rdx+r10-0A83F051h] mov edx,r11d shl edx,7 shr r11d,19h or edx,r11d add edx,ecx ;5 mov r10d,ecx xor r10d,r8d and r10d,edx xor r10d,r8d add r9d,r10d mov r10d,dword ptr [rax+14h] lea r11d,[r9+r10+4787C62Ah] mov r9d,r11d shl r9d,0Ch shr r11d,14h or r9d,r11d add r9d,edx ;6 mov r10d,edx xor r10d,ecx and r10d,r9d xor r10d,ecx add r8d,r10d mov r10d,dword ptr [rax+18h] lea r11d,[r8+r10-57CFB9EDh] mov r8d,r11d shl r8d,11h shr r11d,0Fh or r8d,r11d add r8d,r9d ;7 mov r10d,r9d xor r10d,edx and r10d,r8d xor r10d,edx add ecx,r10d mov r10d,dword ptr [rax+1Ch] lea r11d,[rcx+r10-2B96AFFh] mov ecx,r11d shl ecx,16h shr r11d,0Ah or ecx,r11d add ecx,r8d ;8 mov r10d,r8d xor r10d,r9d and r10d,ecx xor r10d,r9d add edx,r10d mov r10d,dword ptr [rax+20h] lea r11d,[rdx+r10+698098D8h] mov edx,r11d shl edx,7 shr r11d,19h or edx,r11d add edx,ecx ;9 mov r10d,ecx xor r10d,r8d and r10d,edx xor r10d,r8d add r9d,r10d mov r10d,dword ptr [rax+24h] lea r11d,[r9+r10-74BB0851h] mov r9d,r11d shl r9d,0Ch shr r11d,14h or r9d,r11d add r9d,edx ;10 mov r10d,edx xor r10d,ecx and r10d,r9d xor r10d,ecx add r8d,r10d mov r10d,dword ptr [rax+28h] lea r11d,[r8+r10-0A44Fh] mov r8d,r11d shl r8d,11h shr r11d,0Fh or r8d,r11d add r8d,r9d ;11 mov r10d,r9d xor r10d,edx and r10d,r8d xor r10d,edx add ecx,r10d mov r10d,dword ptr [rax+2Ch] lea r11d,[rcx+r10-76A32842h] mov ecx,r11d shl ecx,16h shr r11d,0Ah or ecx,r11d add ecx,r8d ;12 mov r10d,r8d xor r10d,r9d and r10d,ecx xor r10d,r9d add edx,r10d mov r10d,dword ptr [rax+30h] lea r11d,[rdx+r10+6B901122h] mov edx,r11d shl edx,7 shr r11d,19h or edx,r11d add edx,ecx ;13 mov r10d,ecx xor r10d,r8d and r10d,edx xor r10d,r8d add r9d,r10d mov r10d,dword ptr [rax+34h] lea r11d,[r9+r10-2678E6Dh] mov r9d,r11d shl r9d,0Ch shr r11d,14h or r9d,r11d add r9d,edx ;14 mov r10d,edx xor r10d,ecx and r10d,r9d xor r10d,ecx add r8d,r10d mov r10d,dword ptr [rax+38h] lea r11d,[r8+r10-5986BC72h] mov r8d,r11d shl r8d,11h shr r11d,0Fh or r8d,r11d add r8d,r9d ;15 mov r10d,r9d xor r10d,edx and r10d,r8d xor r10d,edx add ecx,r10d mov r10d,dword ptr [rax+3Ch] lea r11d,[rcx+r10+49B40821h] mov ecx,r11d shl ecx,16h shr r11d,0Ah or ecx,r11d add ecx,r8d ;16 mov r10d,ecx xor r10d,r8d and r10d,r9d xor r10d,r8d add edx,r10d mov r10d,dword ptr [rax+4] lea r11d,[rdx+r10-9E1DA9Eh] mov edx,r11d shl edx,5 shr r11d,1Bh or edx,r11d add edx,ecx ;17 mov r10d,edx xor r10d,ecx and r10d,r8d xor r10d,ecx add r9d,r10d mov r10d,dword ptr [rax+18h] lea r11d,[r9+r10-3FBF4CC0h] mov r9d,r11d shl r9d,9 shr r11d,17h or r9d,r11d add r9d,edx ;18 mov r10d,r9d xor r10d,edx and r10d,ecx xor r10d,edx add r8d,r10d mov r10d,dword ptr [rax+2Ch] lea r11d,[r8+r10+265E5A51h] mov r8d,r11d shl r8d,0Eh shr r11d,12h or r8d,r11d add r8d,r9d ;19 mov r10d,r8d xor r10d,r9d and r10d,edx xor r10d,r9d add ecx,r10d mov r10d,dword ptr [rax] lea r11d,[rcx+r10-16493856h] mov ecx,r11d shl ecx,14h shr r11d,0Ch or ecx,r11d add ecx,r8d ;20 mov r10d,ecx xor r10d,r8d and r10d,r9d xor r10d,r8d add edx,r10d mov r10d,dword ptr [rax+14h] lea r11d,[rdx+r10-29D0EFA3h] mov edx,r11d shl edx,5 shr r11d,1Bh or edx,r11d add edx,ecx ;21 mov r10d,edx xor r10d,ecx and r10d,r8d xor r10d,ecx add r9d,r10d mov r10d,dword ptr [rax+28h] lea r11d,[r9+r10+2441453h] mov r9d,r11d shl r9d,9 shr r11d,17h or r9d,r11d add r9d,edx ;22 mov r10d,r9d xor r10d,edx and r10d,ecx xor r10d,edx add r8d,r10d mov r10d,dword ptr [rax+3Ch] lea r11d,[r8+r10-275E197Fh] mov r8d,r11d shl r8d,0Eh shr r11d,12h or r8d,r11d add r8d,r9d ;23 mov r10d,r8d xor r10d,r9d and r10d,edx xor r10d,r9d add ecx,r10d mov r10d,dword ptr [rax+10h] lea r11d,[rcx+r10-182C0438h] mov ecx,r11d shl ecx,14h shr r11d,0Ch or ecx,r11d add ecx,r8d ;24 mov r10d,ecx xor r10d,r8d and r10d,r9d xor r10d,r8d add edx,r10d mov r10d,dword ptr [rax+24h] lea r11d,[rdx+r10+21E1CDE6h] mov edx,r11d shl edx,5 shr r11d,1Bh or edx,r11d add edx,ecx ;25 mov r10d,edx xor r10d,ecx and r10d,r8d xor r10d,ecx add r9d,r10d mov r10d,dword ptr [rax+38h] lea r11d,[r9+r10-3CC8F82Ah] mov r9d,r11d shl r9d,9 shr r11d,17h or r9d,r11d add r9d,edx ;26 mov r10d,r9d xor r10d,edx and r10d,ecx xor r10d,edx add r8d,r10d mov r10d,dword ptr [rax+0Ch] lea r11d,[r8+r10-0B2AF279h] mov r8d,r11d shl r8d,0Eh shr r11d,12h or r8d,r11d add r8d,r9d ;27 mov r10d,r8d xor r10d,r9d and r10d,edx xor r10d,r9d add ecx,r10d mov r10d,dword ptr [rax+20h] lea r11d,[rcx+r10+455A14EDh] mov ecx,r11d shl ecx,14h shr r11d,0Ch or ecx,r11d add ecx,r8d ;28 mov r10d,ecx xor r10d,r8d and r10d,r9d xor r10d,r8d add edx,r10d mov r10d,dword ptr [rax+34h] lea r11d,[rdx+r10-561C16FBh] mov edx,r11d shl edx,5 shr r11d,1Bh or edx,r11d add edx,ecx ;29 mov r10d,edx xor r10d,ecx and r10d,r8d xor r10d,ecx add r9d,r10d mov r10d,dword ptr [rax+8] lea r11d,[r9+r10-3105C08h] mov r9d,r11d shl r9d,9 shr r11d,17h or r9d,r11d add r9d,edx ;30 mov r10d,r9d xor r10d,edx and r10d,ecx xor r10d,edx add r8d,r10d mov r10d,dword ptr [rax+1Ch] lea r11d,[r8+r10+676F02D9h] mov r8d,r11d shl r8d,0Eh shr r11d,12h or r8d,r11d add r8d,r9d ;31 mov r10d,r8d xor r10d,r9d and r10d,edx xor r10d,r9d add ecx,r10d mov r10d,dword ptr [rax+30h] lea r11d,[rcx+r10-72D5B376h] mov ecx,r11d shl ecx,14h shr r11d,0Ch or ecx,r11d add ecx,r8d ;32 mov r10d,ecx xor r10d,r8d xor r10d,r9d add edx,r10d mov r10d,dword ptr [rax+14h] lea r11d,[rdx+r10-5C6BEh] mov edx,r11d shl edx,4 shr r11d,1Ch or edx,r11d add edx,ecx ;33 mov r10d,edx xor r10d,ecx xor r10d,r8d add r9d,r10d mov r10d,dword ptr [rax+20h] lea r11d,[r9+r10-788E097Fh] mov r9d,r11d shl r9d,0Bh shr r11d,15h or r9d,r11d add r9d,edx ;34 mov r10d,r9d xor r10d,edx xor r10d,ecx add r8d,r10d mov r10d,dword ptr [rax+2Ch] lea r11d,[r8+r10+6D9D6122h] mov r8d,r11d shl r8d,10h shr r11d,10h or r8d,r11d add r8d,r9d ;35 mov r10d,r8d xor r10d,r9d xor r10d,edx add ecx,r10d mov r10d,dword ptr [rax+38h] lea r11d,[rcx+r10-21AC7F4h] mov ecx,r11d shl ecx,17h shr r11d,9 or ecx,r11d add ecx,r8d ;36 mov r10d,ecx xor r10d,r8d xor r10d,r9d add edx,r10d mov r10d,dword ptr [rax+4] lea r11d,[rdx+r10-5B4115BCh] mov edx,r11d shl edx,4 shr r11d,1Ch or edx,r11d add edx,ecx ;37 mov r10d,edx xor r10d,ecx xor r10d,r8d add r9d,r10d mov r10d,dword ptr [rax+10h] lea r11d,[r9+r10+4BDECFA9h] mov r9d,r11d shl r9d,0Bh shr r11d,15h or r9d,r11d add r9d,edx ;38 mov r10d,r9d xor r10d,edx xor r10d,ecx add r8d,r10d mov r10d,dword ptr [rax+1Ch] lea r11d,[r8+r10-944B4A0h] mov r8d,r11d shl r8d,10h shr r11d,10h or r8d,r11d add r8d,r9d ;39 mov r10d,r8d xor r10d,r9d xor r10d,edx add ecx,r10d mov r10d,dword ptr [rax+28h] lea r11d,[rcx+r10-41404390h] mov ecx,r11d shl ecx,17h shr r11d,9 or ecx,r11d add ecx,r8d ;40 mov r10d,ecx xor r10d,r8d xor r10d,r9d add edx,r10d mov r10d,dword ptr [rax+34h] lea r11d,[rdx+r10+289B7EC6h] mov edx,r11d shl edx,4 shr r11d,1Ch or edx,r11d add edx,ecx ;41 mov r10d,edx xor r10d,ecx xor r10d,r8d add r9d,r10d mov r10d,dword ptr [rax] lea r11d,[r9+r10-155ED806h] mov r9d,r11d shl r9d,0Bh shr r11d,15h or r9d,r11d add r9d,edx ;42 mov r10d,r9d xor r10d,edx xor r10d,ecx add r8d,r10d mov r10d,dword ptr [rax+0Ch] lea r11d,[r8+r10-2B10CF7Bh] mov r8d,r11d shl r8d,10h shr r11d,10h or r8d,r11d add r8d,r9d ;43 mov r10d,r8d xor r10d,r9d xor r10d,edx add ecx,r10d mov r10d,dword ptr [rax+18h] lea r11d,[rcx+r10+4881D05h] mov ecx,r11d shl ecx,17h shr r11d,9 or ecx,r11d add ecx,r8d ;44 mov r10d,ecx xor r10d,r8d xor r10d,r9d add edx,r10d mov r10d,dword ptr [rax+24h] lea r11d,[rdx+r10-262B2FC7h] mov edx,r11d shl edx,4 shr r11d,1Ch or edx,r11d add edx,ecx ;45 mov r10d,edx xor r10d,ecx xor r10d,r8d add r9d,r10d mov r10d,dword ptr [rax+30h] lea r11d,[r9+r10-1924661Bh] mov r9d,r11d shl r9d,0Bh shr r11d,15h or r9d,r11d add r9d,edx ;46 mov r10d,r9d xor r10d,edx xor r10d,ecx add r8d,r10d mov r10d,dword ptr [rax+3Ch] lea r11d,[r8+r10+1FA27CF8h] mov r8d,r11d shl r8d,10h shr r11d,10h or r8d,r11d add r8d,r9d ;47 mov r10d,r8d xor r10d,r9d xor r10d,edx add ecx,r10d mov r10d,dword ptr [rax+8] lea r11d,[rcx+r10-3B53A99Bh] mov ecx,r11d shl ecx,17h shr r11d,9 or ecx,r11d add ecx,r8d ;48 mov r10d,r9d not r10d or r10d,ecx xor r10d,r8d add edx,r10d mov r10d,dword ptr [rax] lea r11d,[rdx+r10-0BD6DDBCh] mov edx,r11d shl edx,6 shr r11d,1Ah or edx,r11d add edx,ecx ;49 mov r10d,r8d not r10d or r10d,edx xor r10d,ecx add r9d,r10d mov r10d,dword ptr [rax+1Ch] lea r11d,[r9+r10+432AFF97h] mov r9d,r11d shl r9d,0Ah shr r11d,16h or r9d,r11d add r9d,edx ;50 mov r10d,ecx not r10d or r10d,r9d xor r10d,edx add r8d,r10d mov r10d,dword ptr [rax+38h] lea r11d,[r8+r10-546BDC59h] mov r8d,r11d shl r8d,0Fh shr r11d,11h or r8d,r11d add r8d,r9d ;51 mov r10d,edx not r10d or r10d,r8d xor r10d,r9d add ecx,r10d mov r10d,dword ptr [rax+14h] lea r11d,[rcx+r10-36C5FC7h] mov ecx,r11d shl ecx,15h shr r11d,0Bh or ecx,r11d add ecx,r8d ;52 mov r10d,r9d not r10d or r10d,ecx xor r10d,r8d add edx,r10d mov r10d,dword ptr [rax+30h] lea r11d,[rdx+r10+655B59C3h] mov edx,r11d shl edx,6 shr r11d,1Ah or edx,r11d add edx,ecx ;53 mov r10d,r8d not r10d or r10d,edx xor r10d,ecx add r9d,r10d mov r10d,dword ptr [rax+0Ch] lea r11d,[r9+r10-70F3336Eh] mov r9d,r11d shl r9d,0Ah shr r11d,16h or r9d,r11d add r9d,edx ;54 mov r10d,ecx not r10d or r10d,r9d xor r10d,edx add r8d,r10d mov r10d,dword ptr [rax+28h] lea r11d,[r8+r10-100B83h] mov r8d,r11d shl r8d,0Fh shr r11d,11h or r8d,r11d add r8d,r9d ;55 mov r10d,edx not r10d or r10d,r8d xor r10d,r9d add ecx,r10d mov r10d,dword ptr [rax+4] lea r11d,[rcx+r10-7A7BA22Fh] mov ecx,r11d shl ecx,15h shr r11d,0Bh or ecx,r11d add ecx,r8d ;56 mov r10d,r9d not r10d or r10d,ecx xor r10d,r8d add edx,r10d mov r10d,dword ptr [rax+20h] lea r11d,[rdx+r10+6FA87E4Fh] mov edx,r11d shl edx,6 shr r11d,1Ah or edx,r11d add edx,ecx ;57 mov r10d,r8d not r10d or r10d,edx xor r10d,ecx add r9d,r10d mov r10d,dword ptr [rax+3Ch] lea r11d,[r9+r10-1D31920h] mov r9d,r11d shl r9d,0Ah shr r11d,16h or r9d,r11d add r9d,edx ;58 mov r10d,ecx not r10d or r10d,r9d xor r10d,edx add r8d,r10d mov r10d,dword ptr [rax+18h] lea r11d,[r8+r10-5CFEBCECh] mov r8d,r11d shl r8d,0Fh shr r11d,11h or r8d,r11d add r8d,r9d ;59 mov r10d,edx not r10d or r10d,r8d xor r10d,r9d add ecx,r10d mov r10d,dword ptr [rax+34h] lea r11d,[rcx+r10+4E0811A1h] mov ecx,r11d shl ecx,15h shr r11d,0Bh or ecx,r11d add ecx,r8d ;60 mov r10d,r9d not r10d or r10d,ecx xor r10d,r8d add edx,r10d mov r10d,dword ptr [rax+10h] lea r11d,[rdx+r10-8AC817Eh] mov edx,r11d shl edx,6 shr r11d,1Ah or edx,r11d add edx,ecx ;61 mov r10d,r8d not r10d or r10d,edx xor r10d,ecx add r9d,r10d mov r10d,dword ptr [rax+2Ch] lea r11d,[r9+r10-42C50DCBh] mov r9d,r11d shl r9d,0Ah shr r11d,16h or r9d,r11d add r9d,edx ;62 mov r10d,ecx not r10d or r10d,r9d xor r10d,edx add r8d,r10d mov r10d,dword ptr [rax+8] lea r11d,[r8+r10+2AD7D2BBh] mov r8d,r11d shl r8d,0Fh shr r11d,11h or r8d,r11d add r8d,r9d ;63 mov r10d,edx not r10d or r10d,r8d xor r10d,r9d add ecx,r10d mov eax,dword ptr [rax+24h] lea r11d,[rcx+rax-14792C6Fh] mov eax,r11d shl eax,15h mov ecx,r11d shr ecx,0Bh or eax,ecx add eax,r8d ; end inner "loop" mov ecx,eax add dword ptr [rsi],edx cmp dword ptr [rsi],esi mov rax,r15 add dword ptr [rax],ecx cmp dword ptr [rsi],esi mov rax,r12 add dword ptr [rax],r8d cmp dword ptr [rsi],esi mov rax,r13 add dword ptr [rax],r9d inc r14d cmp r14d,ebp jl LoopStart LoopExit: add rsp,78h pop rbx pop rbp pop rsi pop rdi pop r12 pop r13 pop r14 pop r15 ret Md5DotNet ENDP END
; ; Copyright (C) 2021 by Intel Corporation ; ; Permission to use, copy, modify, and/or distribute this software for any ; purpose with or without fee is hereby granted. ; ; THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH ; REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY ; AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, ; INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM ; LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR ; OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR ; PERFORMANCE OF THIS SOFTWARE. ; ; .globl only_256bit ; void only_256bit(uint64_t count); ; On entry: ; rcx = count .code only_256bit PROC public mov rdx, rsp and rsp, -10h sub rsp, 160 vmovaps xmmword ptr[rsp], xmm6 vmovaps xmmword ptr[rsp+16], xmm7 vmovaps xmmword ptr[rsp+32], xmm8 vmovaps xmmword ptr[rsp+48], xmm9 vmovaps xmmword ptr[rsp+64], xmm10 vmovaps xmmword ptr[rsp+80], xmm11 vmovaps xmmword ptr[rsp+96], xmm12 vmovaps xmmword ptr[rsp+112], xmm13 vmovaps xmmword ptr[rsp+128], xmm14 vmovaps xmmword ptr[rsp+144], xmm15 mov rax, 33 push rax Loop1: vpbroadcastd ymm0, dword ptr [rsp] vfmadd213ps ymm7, ymm7, ymm7 vfmadd213ps ymm8, ymm8, ymm8 vfmadd213ps ymm9, ymm9, ymm9 vfmadd213ps ymm10, ymm10, ymm10 vfmadd213ps ymm11, ymm11, ymm11 vfmadd213ps ymm12, ymm12, ymm12 vfmadd213ps ymm13, ymm13, ymm13 vfmadd213ps ymm14, ymm14, ymm14 vfmadd213ps ymm15, ymm15, ymm15 vfmadd213ps ymm16, ymm16, ymm16 vfmadd213ps ymm17, ymm17, ymm17 vfmadd213ps ymm18, ymm18, ymm18 vpermd ymm1, ymm1, ymm1 vpermd ymm2, ymm2, ymm2 vpermd ymm3, ymm3, ymm3 vpermd ymm4, ymm4, ymm4 vpermd ymm5, ymm5, ymm5 vpermd ymm6, ymm6, ymm6 dec rcx jnle Loop1 pop rax vzeroupper vmovaps xmm6, xmmword ptr[rsp] vmovaps xmm7, xmmword ptr[rsp+16] vmovaps xmm8, xmmword ptr[rsp+32] vmovaps xmm9, xmmword ptr[rsp+48] vmovaps xmm10, xmmword ptr[rsp+64] vmovaps xmm11, xmmword ptr[rsp+80] vmovaps xmm12, xmmword ptr[rsp+96] vmovaps xmm13, xmmword ptr[rsp+112] vmovaps xmm14, xmmword ptr[rsp+128] vmovaps xmm15, xmmword ptr[rsp+144] mov rsp, rdx ret only_256bit ENDP end
//===================================================== // File : portable_perf_analyzer.hh // Author : L. Plagne <laurent.plagne@edf.fr)> // Copyright (C) EDF R&D, mar d�c 3 18:59:35 CET 2002 // Copyright (C) 2008 Gael Guennebaud <gael.guennebaud@inria.fr> //===================================================== // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License // as published by the Free Software Foundation; either version 2 // of the License, or (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // #ifndef _PORTABLE_PERF_ANALYZER_HH #define _PORTABLE_PERF_ANALYZER_HH #include "utilities.h" #include "timers/portable_timer.hh" template <class Action> class Portable_Perf_Analyzer{ public: Portable_Perf_Analyzer( ):_nb_calc(0), m_time_action(0), _chronos(){ MESSAGE("Portable_Perf_Analyzer Ctor"); }; Portable_Perf_Analyzer( const Portable_Perf_Analyzer & ){ INFOS("Copy Ctor not implemented"); exit(0); }; ~Portable_Perf_Analyzer(){ MESSAGE("Portable_Perf_Analyzer Dtor"); }; BTL_DONT_INLINE double eval_mflops(int size) { Action action(size); // action.initialize(); // time_action = time_calculate(action); while (m_time_action < MIN_TIME) { if(_nb_calc==0) _nb_calc = 1; else _nb_calc *= 2; action.initialize(); m_time_action = time_calculate(action); } // optimize for (int i=1; i<BtlConfig::Instance.tries; ++i) { Action _action(size); std::cout << " " << _action.nb_op_base()*_nb_calc/(m_time_action*1e6) << " "; _action.initialize(); m_time_action = std::min(m_time_action, time_calculate(_action)); } double time_action = m_time_action / (double(_nb_calc)); // check if (BtlConfig::Instance.checkResults && size<128) { action.initialize(); action.calculate(); action.check_result(); } return action.nb_op_base()/(time_action*1e6); } BTL_DONT_INLINE double time_calculate(Action & action) { // time measurement action.calculate(); _chronos.start(); for (int ii=0;ii<_nb_calc;ii++) { action.calculate(); } _chronos.stop(); return _chronos.user_time(); } unsigned long long get_nb_calc() { return _nb_calc; } private: unsigned long long _nb_calc; double m_time_action; Portable_Timer _chronos; }; #endif //_PORTABLE_PERF_ANALYZER_HH
<% from pwnlib.shellcraft.aarch64.linux import syscall %> <%page args="timerid"/> <%docstring> Invokes the syscall timer_getoverrun. See 'man 2 timer_getoverrun' for more information. Arguments: timerid(timer_t): timerid </%docstring> ${syscall('SYS_timer_getoverrun', timerid)}
; ; jdsample.asm - upsampling (64-bit SSE2) ; ; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB ; Copyright 2009 D. R. Commander ; ; Based on ; x86 SIMD extension for IJG JPEG library ; Copyright (C) 1999-2006, MIYASAKA Masaru. ; For conditions of distribution and use, see copyright notice in jsimdext.inc ; ; This file should be assembled with NASM (Netwide Assembler), ; can *not* be assembled with Microsoft's MASM or any compatible ; assembler (including Borland's Turbo Assembler). ; NASM is available from http://nasm.sourceforge.net/ or ; http://sourceforge.net/project/showfiles.php?group_id=6208 ; ; [TAB8] %include "jsimdext.inc" ; -------------------------------------------------------------------------- SECTION SEG_CONST alignz 16 global EXTN(jconst_fancy_upsample_sse2) EXTN(jconst_fancy_upsample_sse2): PW_ONE times 8 dw 1 PW_TWO times 8 dw 2 PW_THREE times 8 dw 3 PW_SEVEN times 8 dw 7 PW_EIGHT times 8 dw 8 alignz 16 ; -------------------------------------------------------------------------- SECTION SEG_TEXT BITS 64 ; ; Fancy processing for the common case of 2:1 horizontal and 1:1 vertical. ; ; The upsampling algorithm is linear interpolation between pixel centers, ; also known as a "triangle filter". This is a good compromise between ; speed and visual quality. The centers of the output pixels are 1/4 and 3/4 ; of the way between input pixel centers. ; ; GLOBAL(void) ; jsimd_h2v1_fancy_upsample_sse2 (int max_v_samp_factor, ; JDIMENSION downsampled_width, ; JSAMPARRAY input_data, ; JSAMPARRAY * output_data_ptr); ; ; r10 = int max_v_samp_factor ; r11 = JDIMENSION downsampled_width ; r12 = JSAMPARRAY input_data ; r13 = JSAMPARRAY * output_data_ptr align 16 global EXTN(jsimd_h2v1_fancy_upsample_sse2) EXTN(jsimd_h2v1_fancy_upsample_sse2): push rbp mov rax,rsp mov rbp,rsp collect_args mov rax, r11 ; colctr test rax,rax jz near .return mov rcx, r10 ; rowctr test rcx,rcx jz near .return mov rsi, r12 ; input_data mov rdi, r13 mov rdi, JSAMPARRAY [rdi] ; output_data .rowloop: push rax ; colctr push rdi push rsi mov rsi, JSAMPROW [rsi] ; inptr mov rdi, JSAMPROW [rdi] ; outptr test rax, SIZEOF_XMMWORD-1 jz short .skip mov dl, JSAMPLE [rsi+(rax-1)*SIZEOF_JSAMPLE] mov JSAMPLE [rsi+rax*SIZEOF_JSAMPLE], dl ; insert a dummy sample .skip: pxor xmm0,xmm0 ; xmm0=(all 0's) pcmpeqb xmm7,xmm7 psrldq xmm7,(SIZEOF_XMMWORD-1) pand xmm7, XMMWORD [rsi+0*SIZEOF_XMMWORD] add rax, byte SIZEOF_XMMWORD-1 and rax, byte -SIZEOF_XMMWORD cmp rax, byte SIZEOF_XMMWORD ja short .columnloop .columnloop_last: pcmpeqb xmm6,xmm6 pslldq xmm6,(SIZEOF_XMMWORD-1) pand xmm6, XMMWORD [rsi+0*SIZEOF_XMMWORD] jmp short .upsample .columnloop: movdqa xmm6, XMMWORD [rsi+1*SIZEOF_XMMWORD] pslldq xmm6,(SIZEOF_XMMWORD-1) .upsample: movdqa xmm1, XMMWORD [rsi+0*SIZEOF_XMMWORD] movdqa xmm2,xmm1 movdqa xmm3,xmm1 ; xmm1=( 0 1 2 ... 13 14 15) pslldq xmm2,1 ; xmm2=(-- 0 1 ... 12 13 14) psrldq xmm3,1 ; xmm3=( 1 2 3 ... 14 15 --) por xmm2,xmm7 ; xmm2=(-1 0 1 ... 12 13 14) por xmm3,xmm6 ; xmm3=( 1 2 3 ... 14 15 16) movdqa xmm7,xmm1 psrldq xmm7,(SIZEOF_XMMWORD-1) ; xmm7=(15 -- -- ... -- -- --) movdqa xmm4,xmm1 punpcklbw xmm1,xmm0 ; xmm1=( 0 1 2 3 4 5 6 7) punpckhbw xmm4,xmm0 ; xmm4=( 8 9 10 11 12 13 14 15) movdqa xmm5,xmm2 punpcklbw xmm2,xmm0 ; xmm2=(-1 0 1 2 3 4 5 6) punpckhbw xmm5,xmm0 ; xmm5=( 7 8 9 10 11 12 13 14) movdqa xmm6,xmm3 punpcklbw xmm3,xmm0 ; xmm3=( 1 2 3 4 5 6 7 8) punpckhbw xmm6,xmm0 ; xmm6=( 9 10 11 12 13 14 15 16) pmullw xmm1,[rel PW_THREE] pmullw xmm4,[rel PW_THREE] paddw xmm2,[rel PW_ONE] paddw xmm5,[rel PW_ONE] paddw xmm3,[rel PW_TWO] paddw xmm6,[rel PW_TWO] paddw xmm2,xmm1 paddw xmm5,xmm4 psrlw xmm2,2 ; xmm2=OutLE=( 0 2 4 6 8 10 12 14) psrlw xmm5,2 ; xmm5=OutHE=(16 18 20 22 24 26 28 30) paddw xmm3,xmm1 paddw xmm6,xmm4 psrlw xmm3,2 ; xmm3=OutLO=( 1 3 5 7 9 11 13 15) psrlw xmm6,2 ; xmm6=OutHO=(17 19 21 23 25 27 29 31) psllw xmm3,BYTE_BIT psllw xmm6,BYTE_BIT por xmm2,xmm3 ; xmm2=OutL=( 0 1 2 ... 13 14 15) por xmm5,xmm6 ; xmm5=OutH=(16 17 18 ... 29 30 31) movdqa XMMWORD [rdi+0*SIZEOF_XMMWORD], xmm2 movdqa XMMWORD [rdi+1*SIZEOF_XMMWORD], xmm5 sub rax, byte SIZEOF_XMMWORD add rsi, byte 1*SIZEOF_XMMWORD ; inptr add rdi, byte 2*SIZEOF_XMMWORD ; outptr cmp rax, byte SIZEOF_XMMWORD ja near .columnloop test eax,eax jnz near .columnloop_last pop rsi pop rdi pop rax add rsi, byte SIZEOF_JSAMPROW ; input_data add rdi, byte SIZEOF_JSAMPROW ; output_data dec rcx ; rowctr jg near .rowloop .return: uncollect_args pop rbp ret ; -------------------------------------------------------------------------- ; ; Fancy processing for the common case of 2:1 horizontal and 2:1 vertical. ; Again a triangle filter; see comments for h2v1 case, above. ; ; GLOBAL(void) ; jsimd_h2v2_fancy_upsample_sse2 (int max_v_samp_factor, ; JDIMENSION downsampled_width, ; JSAMPARRAY input_data, ; JSAMPARRAY * output_data_ptr); ; ; r10 = int max_v_samp_factor ; r11 = JDIMENSION downsampled_width ; r12 = JSAMPARRAY input_data ; r13 = JSAMPARRAY * output_data_ptr %define wk(i) rbp-(WK_NUM-(i))*SIZEOF_XMMWORD ; xmmword wk[WK_NUM] %define WK_NUM 4 align 16 global EXTN(jsimd_h2v2_fancy_upsample_sse2) EXTN(jsimd_h2v2_fancy_upsample_sse2): push rbp mov rax,rsp ; rax = original rbp sub rsp, byte 4 and rsp, byte (-SIZEOF_XMMWORD) ; align to 128 bits mov [rsp],rax mov rbp,rsp ; rbp = aligned rbp lea rsp, [wk(0)] collect_args push rbx mov rax, r11 ; colctr test rax,rax jz near .return mov rcx, r10 ; rowctr test rcx,rcx jz near .return mov rsi, r12 ; input_data mov rdi, r13 mov rdi, JSAMPARRAY [rdi] ; output_data .rowloop: push rax ; colctr push rcx push rdi push rsi mov rcx, JSAMPROW [rsi-1*SIZEOF_JSAMPROW] ; inptr1(above) mov rbx, JSAMPROW [rsi+0*SIZEOF_JSAMPROW] ; inptr0 mov rsi, JSAMPROW [rsi+1*SIZEOF_JSAMPROW] ; inptr1(below) mov rdx, JSAMPROW [rdi+0*SIZEOF_JSAMPROW] ; outptr0 mov rdi, JSAMPROW [rdi+1*SIZEOF_JSAMPROW] ; outptr1 test rax, SIZEOF_XMMWORD-1 jz short .skip push rdx mov dl, JSAMPLE [rcx+(rax-1)*SIZEOF_JSAMPLE] mov JSAMPLE [rcx+rax*SIZEOF_JSAMPLE], dl mov dl, JSAMPLE [rbx+(rax-1)*SIZEOF_JSAMPLE] mov JSAMPLE [rbx+rax*SIZEOF_JSAMPLE], dl mov dl, JSAMPLE [rsi+(rax-1)*SIZEOF_JSAMPLE] mov JSAMPLE [rsi+rax*SIZEOF_JSAMPLE], dl ; insert a dummy sample pop rdx .skip: ; -- process the first column block movdqa xmm0, XMMWORD [rbx+0*SIZEOF_XMMWORD] ; xmm0=row[ 0][0] movdqa xmm1, XMMWORD [rcx+0*SIZEOF_XMMWORD] ; xmm1=row[-1][0] movdqa xmm2, XMMWORD [rsi+0*SIZEOF_XMMWORD] ; xmm2=row[+1][0] pxor xmm3,xmm3 ; xmm3=(all 0's) movdqa xmm4,xmm0 punpcklbw xmm0,xmm3 ; xmm0=row[ 0]( 0 1 2 3 4 5 6 7) punpckhbw xmm4,xmm3 ; xmm4=row[ 0]( 8 9 10 11 12 13 14 15) movdqa xmm5,xmm1 punpcklbw xmm1,xmm3 ; xmm1=row[-1]( 0 1 2 3 4 5 6 7) punpckhbw xmm5,xmm3 ; xmm5=row[-1]( 8 9 10 11 12 13 14 15) movdqa xmm6,xmm2 punpcklbw xmm2,xmm3 ; xmm2=row[+1]( 0 1 2 3 4 5 6 7) punpckhbw xmm6,xmm3 ; xmm6=row[+1]( 8 9 10 11 12 13 14 15) pmullw xmm0,[rel PW_THREE] pmullw xmm4,[rel PW_THREE] pcmpeqb xmm7,xmm7 psrldq xmm7,(SIZEOF_XMMWORD-2) paddw xmm1,xmm0 ; xmm1=Int0L=( 0 1 2 3 4 5 6 7) paddw xmm5,xmm4 ; xmm5=Int0H=( 8 9 10 11 12 13 14 15) paddw xmm2,xmm0 ; xmm2=Int1L=( 0 1 2 3 4 5 6 7) paddw xmm6,xmm4 ; xmm6=Int1H=( 8 9 10 11 12 13 14 15) movdqa XMMWORD [rdx+0*SIZEOF_XMMWORD], xmm1 ; temporarily save movdqa XMMWORD [rdx+1*SIZEOF_XMMWORD], xmm5 ; the intermediate data movdqa XMMWORD [rdi+0*SIZEOF_XMMWORD], xmm2 movdqa XMMWORD [rdi+1*SIZEOF_XMMWORD], xmm6 pand xmm1,xmm7 ; xmm1=( 0 -- -- -- -- -- -- --) pand xmm2,xmm7 ; xmm2=( 0 -- -- -- -- -- -- --) movdqa XMMWORD [wk(0)], xmm1 movdqa XMMWORD [wk(1)], xmm2 add rax, byte SIZEOF_XMMWORD-1 and rax, byte -SIZEOF_XMMWORD cmp rax, byte SIZEOF_XMMWORD ja short .columnloop .columnloop_last: ; -- process the last column block pcmpeqb xmm1,xmm1 pslldq xmm1,(SIZEOF_XMMWORD-2) movdqa xmm2,xmm1 pand xmm1, XMMWORD [rdx+1*SIZEOF_XMMWORD] pand xmm2, XMMWORD [rdi+1*SIZEOF_XMMWORD] movdqa XMMWORD [wk(2)], xmm1 ; xmm1=(-- -- -- -- -- -- -- 15) movdqa XMMWORD [wk(3)], xmm2 ; xmm2=(-- -- -- -- -- -- -- 15) jmp near .upsample .columnloop: ; -- process the next column block movdqa xmm0, XMMWORD [rbx+1*SIZEOF_XMMWORD] ; xmm0=row[ 0][1] movdqa xmm1, XMMWORD [rcx+1*SIZEOF_XMMWORD] ; xmm1=row[-1][1] movdqa xmm2, XMMWORD [rsi+1*SIZEOF_XMMWORD] ; xmm2=row[+1][1] pxor xmm3,xmm3 ; xmm3=(all 0's) movdqa xmm4,xmm0 punpcklbw xmm0,xmm3 ; xmm0=row[ 0]( 0 1 2 3 4 5 6 7) punpckhbw xmm4,xmm3 ; xmm4=row[ 0]( 8 9 10 11 12 13 14 15) movdqa xmm5,xmm1 punpcklbw xmm1,xmm3 ; xmm1=row[-1]( 0 1 2 3 4 5 6 7) punpckhbw xmm5,xmm3 ; xmm5=row[-1]( 8 9 10 11 12 13 14 15) movdqa xmm6,xmm2 punpcklbw xmm2,xmm3 ; xmm2=row[+1]( 0 1 2 3 4 5 6 7) punpckhbw xmm6,xmm3 ; xmm6=row[+1]( 8 9 10 11 12 13 14 15) pmullw xmm0,[rel PW_THREE] pmullw xmm4,[rel PW_THREE] paddw xmm1,xmm0 ; xmm1=Int0L=( 0 1 2 3 4 5 6 7) paddw xmm5,xmm4 ; xmm5=Int0H=( 8 9 10 11 12 13 14 15) paddw xmm2,xmm0 ; xmm2=Int1L=( 0 1 2 3 4 5 6 7) paddw xmm6,xmm4 ; xmm6=Int1H=( 8 9 10 11 12 13 14 15) movdqa XMMWORD [rdx+2*SIZEOF_XMMWORD], xmm1 ; temporarily save movdqa XMMWORD [rdx+3*SIZEOF_XMMWORD], xmm5 ; the intermediate data movdqa XMMWORD [rdi+2*SIZEOF_XMMWORD], xmm2 movdqa XMMWORD [rdi+3*SIZEOF_XMMWORD], xmm6 pslldq xmm1,(SIZEOF_XMMWORD-2) ; xmm1=(-- -- -- -- -- -- -- 0) pslldq xmm2,(SIZEOF_XMMWORD-2) ; xmm2=(-- -- -- -- -- -- -- 0) movdqa XMMWORD [wk(2)], xmm1 movdqa XMMWORD [wk(3)], xmm2 .upsample: ; -- process the upper row movdqa xmm7, XMMWORD [rdx+0*SIZEOF_XMMWORD] movdqa xmm3, XMMWORD [rdx+1*SIZEOF_XMMWORD] movdqa xmm0,xmm7 ; xmm7=Int0L=( 0 1 2 3 4 5 6 7) movdqa xmm4,xmm3 ; xmm3=Int0H=( 8 9 10 11 12 13 14 15) psrldq xmm0,2 ; xmm0=( 1 2 3 4 5 6 7 --) pslldq xmm4,(SIZEOF_XMMWORD-2) ; xmm4=(-- -- -- -- -- -- -- 8) movdqa xmm5,xmm7 movdqa xmm6,xmm3 psrldq xmm5,(SIZEOF_XMMWORD-2) ; xmm5=( 7 -- -- -- -- -- -- --) pslldq xmm6,2 ; xmm6=(-- 8 9 10 11 12 13 14) por xmm0,xmm4 ; xmm0=( 1 2 3 4 5 6 7 8) por xmm5,xmm6 ; xmm5=( 7 8 9 10 11 12 13 14) movdqa xmm1,xmm7 movdqa xmm2,xmm3 pslldq xmm1,2 ; xmm1=(-- 0 1 2 3 4 5 6) psrldq xmm2,2 ; xmm2=( 9 10 11 12 13 14 15 --) movdqa xmm4,xmm3 psrldq xmm4,(SIZEOF_XMMWORD-2) ; xmm4=(15 -- -- -- -- -- -- --) por xmm1, XMMWORD [wk(0)] ; xmm1=(-1 0 1 2 3 4 5 6) por xmm2, XMMWORD [wk(2)] ; xmm2=( 9 10 11 12 13 14 15 16) movdqa XMMWORD [wk(0)], xmm4 pmullw xmm7,[rel PW_THREE] pmullw xmm3,[rel PW_THREE] paddw xmm1,[rel PW_EIGHT] paddw xmm5,[rel PW_EIGHT] paddw xmm0,[rel PW_SEVEN] paddw xmm2,[rel PW_SEVEN] paddw xmm1,xmm7 paddw xmm5,xmm3 psrlw xmm1,4 ; xmm1=Out0LE=( 0 2 4 6 8 10 12 14) psrlw xmm5,4 ; xmm5=Out0HE=(16 18 20 22 24 26 28 30) paddw xmm0,xmm7 paddw xmm2,xmm3 psrlw xmm0,4 ; xmm0=Out0LO=( 1 3 5 7 9 11 13 15) psrlw xmm2,4 ; xmm2=Out0HO=(17 19 21 23 25 27 29 31) psllw xmm0,BYTE_BIT psllw xmm2,BYTE_BIT por xmm1,xmm0 ; xmm1=Out0L=( 0 1 2 ... 13 14 15) por xmm5,xmm2 ; xmm5=Out0H=(16 17 18 ... 29 30 31) movdqa XMMWORD [rdx+0*SIZEOF_XMMWORD], xmm1 movdqa XMMWORD [rdx+1*SIZEOF_XMMWORD], xmm5 ; -- process the lower row movdqa xmm6, XMMWORD [rdi+0*SIZEOF_XMMWORD] movdqa xmm4, XMMWORD [rdi+1*SIZEOF_XMMWORD] movdqa xmm7,xmm6 ; xmm6=Int1L=( 0 1 2 3 4 5 6 7) movdqa xmm3,xmm4 ; xmm4=Int1H=( 8 9 10 11 12 13 14 15) psrldq xmm7,2 ; xmm7=( 1 2 3 4 5 6 7 --) pslldq xmm3,(SIZEOF_XMMWORD-2) ; xmm3=(-- -- -- -- -- -- -- 8) movdqa xmm0,xmm6 movdqa xmm2,xmm4 psrldq xmm0,(SIZEOF_XMMWORD-2) ; xmm0=( 7 -- -- -- -- -- -- --) pslldq xmm2,2 ; xmm2=(-- 8 9 10 11 12 13 14) por xmm7,xmm3 ; xmm7=( 1 2 3 4 5 6 7 8) por xmm0,xmm2 ; xmm0=( 7 8 9 10 11 12 13 14) movdqa xmm1,xmm6 movdqa xmm5,xmm4 pslldq xmm1,2 ; xmm1=(-- 0 1 2 3 4 5 6) psrldq xmm5,2 ; xmm5=( 9 10 11 12 13 14 15 --) movdqa xmm3,xmm4 psrldq xmm3,(SIZEOF_XMMWORD-2) ; xmm3=(15 -- -- -- -- -- -- --) por xmm1, XMMWORD [wk(1)] ; xmm1=(-1 0 1 2 3 4 5 6) por xmm5, XMMWORD [wk(3)] ; xmm5=( 9 10 11 12 13 14 15 16) movdqa XMMWORD [wk(1)], xmm3 pmullw xmm6,[rel PW_THREE] pmullw xmm4,[rel PW_THREE] paddw xmm1,[rel PW_EIGHT] paddw xmm0,[rel PW_EIGHT] paddw xmm7,[rel PW_SEVEN] paddw xmm5,[rel PW_SEVEN] paddw xmm1,xmm6 paddw xmm0,xmm4 psrlw xmm1,4 ; xmm1=Out1LE=( 0 2 4 6 8 10 12 14) psrlw xmm0,4 ; xmm0=Out1HE=(16 18 20 22 24 26 28 30) paddw xmm7,xmm6 paddw xmm5,xmm4 psrlw xmm7,4 ; xmm7=Out1LO=( 1 3 5 7 9 11 13 15) psrlw xmm5,4 ; xmm5=Out1HO=(17 19 21 23 25 27 29 31) psllw xmm7,BYTE_BIT psllw xmm5,BYTE_BIT por xmm1,xmm7 ; xmm1=Out1L=( 0 1 2 ... 13 14 15) por xmm0,xmm5 ; xmm0=Out1H=(16 17 18 ... 29 30 31) movdqa XMMWORD [rdi+0*SIZEOF_XMMWORD], xmm1 movdqa XMMWORD [rdi+1*SIZEOF_XMMWORD], xmm0 sub rax, byte SIZEOF_XMMWORD add rcx, byte 1*SIZEOF_XMMWORD ; inptr1(above) add rbx, byte 1*SIZEOF_XMMWORD ; inptr0 add rsi, byte 1*SIZEOF_XMMWORD ; inptr1(below) add rdx, byte 2*SIZEOF_XMMWORD ; outptr0 add rdi, byte 2*SIZEOF_XMMWORD ; outptr1 cmp rax, byte SIZEOF_XMMWORD ja near .columnloop test rax,rax jnz near .columnloop_last pop rsi pop rdi pop rcx pop rax add rsi, byte 1*SIZEOF_JSAMPROW ; input_data add rdi, byte 2*SIZEOF_JSAMPROW ; output_data sub rcx, byte 2 ; rowctr jg near .rowloop .return: pop rbx uncollect_args mov rsp,rbp ; rsp <- aligned rbp pop rsp ; rsp <- original rbp pop rbp ret ; -------------------------------------------------------------------------- ; ; Fast processing for the common case of 2:1 horizontal and 1:1 vertical. ; It's still a box filter. ; ; GLOBAL(void) ; jsimd_h2v1_upsample_sse2 (int max_v_samp_factor, ; JDIMENSION output_width, ; JSAMPARRAY input_data, ; JSAMPARRAY * output_data_ptr); ; ; r10 = int max_v_samp_factor ; r11 = JDIMENSION output_width ; r12 = JSAMPARRAY input_data ; r13 = JSAMPARRAY * output_data_ptr align 16 global EXTN(jsimd_h2v1_upsample_sse2) EXTN(jsimd_h2v1_upsample_sse2): push rbp mov rax,rsp mov rbp,rsp collect_args mov rdx, r11 add rdx, byte (2*SIZEOF_XMMWORD)-1 and rdx, byte -(2*SIZEOF_XMMWORD) jz near .return mov rcx, r10 ; rowctr test rcx,rcx jz short .return mov rsi, r12 ; input_data mov rdi, r13 mov rdi, JSAMPARRAY [rdi] ; output_data .rowloop: push rdi push rsi mov rsi, JSAMPROW [rsi] ; inptr mov rdi, JSAMPROW [rdi] ; outptr mov rax,rdx ; colctr .columnloop: movdqa xmm0, XMMWORD [rsi+0*SIZEOF_XMMWORD] movdqa xmm1,xmm0 punpcklbw xmm0,xmm0 punpckhbw xmm1,xmm1 movdqa XMMWORD [rdi+0*SIZEOF_XMMWORD], xmm0 movdqa XMMWORD [rdi+1*SIZEOF_XMMWORD], xmm1 sub rax, byte 2*SIZEOF_XMMWORD jz short .nextrow movdqa xmm2, XMMWORD [rsi+1*SIZEOF_XMMWORD] movdqa xmm3,xmm2 punpcklbw xmm2,xmm2 punpckhbw xmm3,xmm3 movdqa XMMWORD [rdi+2*SIZEOF_XMMWORD], xmm2 movdqa XMMWORD [rdi+3*SIZEOF_XMMWORD], xmm3 sub rax, byte 2*SIZEOF_XMMWORD jz short .nextrow add rsi, byte 2*SIZEOF_XMMWORD ; inptr add rdi, byte 4*SIZEOF_XMMWORD ; outptr jmp short .columnloop .nextrow: pop rsi pop rdi add rsi, byte SIZEOF_JSAMPROW ; input_data add rdi, byte SIZEOF_JSAMPROW ; output_data dec rcx ; rowctr jg short .rowloop .return: uncollect_args pop rbp ret ; -------------------------------------------------------------------------- ; ; Fast processing for the common case of 2:1 horizontal and 2:1 vertical. ; It's still a box filter. ; ; GLOBAL(void) ; jsimd_h2v2_upsample_sse2 (nt max_v_samp_factor, ; JDIMENSION output_width, ; JSAMPARRAY input_data, ; JSAMPARRAY * output_data_ptr); ; ; r10 = int max_v_samp_factor ; r11 = JDIMENSION output_width ; r12 = JSAMPARRAY input_data ; r13 = JSAMPARRAY * output_data_ptr align 16 global EXTN(jsimd_h2v2_upsample_sse2) EXTN(jsimd_h2v2_upsample_sse2): push rbp mov rax,rsp mov rbp,rsp collect_args push rbx mov rdx, r11 add rdx, byte (2*SIZEOF_XMMWORD)-1 and rdx, byte -(2*SIZEOF_XMMWORD) jz near .return mov rcx, r10 ; rowctr test rcx,rcx jz near .return mov rsi, r12 ; input_data mov rdi, r13 mov rdi, JSAMPARRAY [rdi] ; output_data .rowloop: push rdi push rsi mov rsi, JSAMPROW [rsi] ; inptr mov rbx, JSAMPROW [rdi+0*SIZEOF_JSAMPROW] ; outptr0 mov rdi, JSAMPROW [rdi+1*SIZEOF_JSAMPROW] ; outptr1 mov rax,rdx ; colctr .columnloop: movdqa xmm0, XMMWORD [rsi+0*SIZEOF_XMMWORD] movdqa xmm1,xmm0 punpcklbw xmm0,xmm0 punpckhbw xmm1,xmm1 movdqa XMMWORD [rbx+0*SIZEOF_XMMWORD], xmm0 movdqa XMMWORD [rbx+1*SIZEOF_XMMWORD], xmm1 movdqa XMMWORD [rdi+0*SIZEOF_XMMWORD], xmm0 movdqa XMMWORD [rdi+1*SIZEOF_XMMWORD], xmm1 sub rax, byte 2*SIZEOF_XMMWORD jz short .nextrow movdqa xmm2, XMMWORD [rsi+1*SIZEOF_XMMWORD] movdqa xmm3,xmm2 punpcklbw xmm2,xmm2 punpckhbw xmm3,xmm3 movdqa XMMWORD [rbx+2*SIZEOF_XMMWORD], xmm2 movdqa XMMWORD [rbx+3*SIZEOF_XMMWORD], xmm3 movdqa XMMWORD [rdi+2*SIZEOF_XMMWORD], xmm2 movdqa XMMWORD [rdi+3*SIZEOF_XMMWORD], xmm3 sub rax, byte 2*SIZEOF_XMMWORD jz short .nextrow add rsi, byte 2*SIZEOF_XMMWORD ; inptr add rbx, byte 4*SIZEOF_XMMWORD ; outptr0 add rdi, byte 4*SIZEOF_XMMWORD ; outptr1 jmp short .columnloop .nextrow: pop rsi pop rdi add rsi, byte 1*SIZEOF_JSAMPROW ; input_data add rdi, byte 2*SIZEOF_JSAMPROW ; output_data sub rcx, byte 2 ; rowctr jg near .rowloop .return: pop rbx uncollect_args pop rbp ret ; For some reason, the OS X linker does not honor the request to align the ; segment unless we do this. align 16
CHANNEL1 = 4 CHANNEL2 = 3 CHANNEL3 = 6 PINMASK = ( (1<<CHANNEL1) | (1<<CHANNEL2) | (1<<CHANNEL3) ) PINMASK12 = ( (1<<CHANNEL1) | (1<<CHANNEL2) ) ; ; STATE MACHINE: ; ; .macro softpwm_init ; mov a, #0 ; mov pa, a ; mov a, #( (1<<CHANNEL1) | (1<<CHANNEL2) | (1<<CHANNEL3) ) ; mov pac, a clear out clear off1 clear off2 clear off3 mov a, #1 mov val1, a mov val2, a mov val3, a mov buf1, a mov buf2, a mov buf3, a mov cycle1, a clear cycle2 clear cycle3 .endm ; more logic constraint puzzle than code :-E ; .macro softpwm ?no_reset1, ?merge1, ?no_reset2, ?merge2, ?no_reset3, ?merge3, ?merge3low, ?merge3high ; no edge edge1 edge2 edge3 mov a, out ; 0 + 1 0 0 0 0 xor pa, a ; 1 + 1 <--- 1 1 1 1 mov a, #PINMASK12 ; 2 + 1 2 2 2 2 mov out, a ; 3 + 1 3 3 3 3 nop ; 4 + 1 4 4 4 4 dzsn cycle1 ; 5 + 1 --. 5 5 5 5 goto no_reset1 ; 6 + 2 | 6 7 (6) 6 7 6 7 mov a, val1 ; 7 + 1 <-' 7 mov off1, a ; 8 + 1 8 mov a, #PINMASK ; 9 + 1 9 t1sn pa, #CHANNEL1 ; 10 + 1 10 xor a, #(1<<CHANNEL1) ; 11 + 1 11 dzsn off1 ; 12 + 1 12 xor a, #(1<<CHANNEL1) ; 13 + 1 13 dzsn off2 ; 14 + 1 14 xor a, #(1<<CHANNEL2) ; 15 + 1 15 dzsn off3 ; 16 + 1 16 xor a, #(1<<CHANNEL3) ; 17 + 1 17 xor pa, a ; 18 + 1 <--- 18 mov a, #28 ; 19 + 1 19 mov cycle2, a ; 20 + 1 20 mov a, #55 ; 21 + 1 21 mov cycle3, a ; 22 + 1 22 no_reset3: mov a, #PINMASK ; 23 + 1 23 23 goto merge2 ; 24 + 2 24 25 24 25 no_reset1: mov a, #PINMASK ; 8 + 1 8 8 8 dzsn off1 ; 9 + 1 9 9 9 xor a, #(1<<CHANNEL1) ; 10 + 1 10 10 10 dzsn off2 ; 11 + 1 11 11 11 xor a, #(1<<CHANNEL2) ; 12 + 1 12 12 12 dzsn off3 ; 13 + 1 13 13 13 xor a, #(1<<CHANNEL3) ; 14 + 1 14 14 14 dzsn cycle2 ; 15 + 1 --. 15 15 15 goto no_reset2 ; 16 + 2 | 16 17 (16) 16 17 nop ; 17 + 1 <-' 17 xor pa, a ; 18 + 1 <--- 18 mov a, #57 ; 19 + 1 19 mov cycle1, a ; 20 + 1 20 mov a, val2 ; 21 + 1 21 mov off2, a ; 22 + 1 22 mov a, #PINMASK ; 23 + 1 23 t1sn pa, #CHANNEL2 ; 24 + 1 24 xor a, #(1<<CHANNEL2) ; 25 + 1 25 merge2: set1 out, #CHANNEL3 ; 26 + 1 26 26 26 dzsn off1 ; 27 + 1 27 27 27 xor a, #(1<<CHANNEL1) ; 28 + 1 28 28 28 dzsn off2 ; 29 + 1 29 29 29 xor a, #(1<<CHANNEL2) ; 30 + 1 30 30 30 dzsn off3 ; 31 + 1 31 31 31 xor a, #(1<<CHANNEL3) ; 32 + 1 32 32 32 dzsn off1 ; 33 + 1 33 38 38 set0 out, #CHANNEL1 ; 34 + 1 34 39 39 xor pa, a ; 35 + 1 <--- 35 35 35 dzsn off2 ; 36 + 1 36 40 40 set0 out, #CHANNEL2 ; 37 + 1 37 37 37 goto merge3 ; 38 + 2 38 39 38 39 38 39 no_reset2: xor pa, a ; 18 + 1 <--- 18 18 mov a, #PINMASK ; 19 + 1 19 19 dzsn cycle3 ; 20 + 1 --. 20 20 goto no_reset3 ; 21 + 2 | 21 22 (21) dzsn off1 ; 22 + 1 <-' 22 xor a, #(1<<CHANNEL1) ; 23 + 1 23 dzsn off2 ; 24 + 1 24 xor a, #(1<<CHANNEL2) ; 25 + 1 25 dzsn off3 ; 26 + 1 26 xor a, #(1<<CHANNEL3) ; 27 + 1 27 mov off3, a ; 28 + 1 28 mov a, val3 ; 29 + 1 29 xch a, off3 ; 30 + 1 30 dzsn off1 ; 31 + 1 31 set0 out, #CHANNEL1 ; 32 + 1 32 dzsn off2 ; 33 + 1 33 set0 out, #CHANNEL2 ; 34 + 1 34 xor pa, a ; 35 + 1 <--- 35 t0sn pa, #CHANNEL3 ; 36 + 1 36 edge3 low goto merge3high ; 37 + 2 37 38 (37) dzsn off3 ; 38 + 1 38 set1 out, #CHANNEL3 ; 39 + 1 39 goto merge3low ; 40 + 2 40 41 merge3high: set1 out, #CHANNEL3 ; 39 + 1 39 merge3: dzsn off3 ; 40 + 1 40 40 40 40 set0 out, #CHANNEL3 ; 41 + 1 41 41 41 41 merge3low: .endm
; CALLER linkage for function pointers SECTION code_clib PUBLIC im2_InstallISR PUBLIC _im2_InstallISR EXTERN im2_InstallISR_callee EXTERN ASMDISP_IM2_INSTALLISR_CALLEE .im2_InstallISR ._im2_InstallISR pop af pop de pop hl push hl push de push af jp im2_InstallISR_callee + ASMDISP_IM2_INSTALLISR_CALLEE
.global s_prepare_buffers s_prepare_buffers: ret .global s_faulty_load s_faulty_load: push %r10 push %r11 push %r9 push %rbp push %rbx push %rcx push %rsi // Store lea addresses_RW+0x1a961, %rbx nop nop sub $49431, %r10 mov $0x5152535455565758, %r9 movq %r9, %xmm6 vmovups %ymm6, (%rbx) // Exception!!! nop nop nop nop mov (0), %r9 nop nop nop nop add %r9, %r9 // Store lea addresses_UC+0x1921, %rsi xor %rbp, %rbp mov $0x5152535455565758, %r10 movq %r10, %xmm6 vmovntdq %ymm6, (%rsi) sub $60199, %rbp // Store lea addresses_PSE+0x1aa51, %rsi nop nop nop nop and $40556, %r11 movb $0x51, (%rsi) nop nop xor %rcx, %rcx // Load lea addresses_PSE+0x2821, %r11 nop nop nop nop nop dec %rsi movups (%r11), %xmm6 vpextrq $0, %xmm6, %r10 nop cmp $10638, %r11 // Load lea addresses_A+0x1b721, %rbx inc %rsi movb (%rbx), %r11b // Exception!!! nop nop nop nop nop mov (0), %r9 nop nop nop nop nop and %rcx, %rcx // Faulty Load mov $0x4ebf470000000c21, %r10 nop nop nop sub $16116, %rbx mov (%r10), %ecx lea oracles, %rbp and $0xff, %rcx shlq $12, %rcx mov (%rbp,%rcx,1), %rcx pop %rsi pop %rcx pop %rbx pop %rbp pop %r9 pop %r11 pop %r10 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'type': 'addresses_NC', 'size': 32, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_RW', 'size': 32, 'AVXalign': False, 'NT': False, 'congruent': 4, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_UC', 'size': 32, 'AVXalign': False, 'NT': True, 'congruent': 7, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_PSE', 'size': 1, 'AVXalign': False, 'NT': False, 'congruent': 2, 'same': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_PSE', 'size': 16, 'AVXalign': False, 'NT': False, 'congruent': 9, 'same': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_A', 'size': 1, 'AVXalign': False, 'NT': False, 'congruent': 5, 'same': False}} [Faulty Load] {'OP': 'LOAD', 'src': {'type': 'addresses_NC', 'size': 4, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': True}} <gen_prepare_buffer> {'00': 90} 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 */
; A022931: Number of e^m between Pi^n and Pi^(n+1). ; 1,1,1,1,1,1,2,1,1,1,1,1,1,2,1,1,1,1,1,1,2,1,1,1,1,1,1,2,1,1,1,1,1,1,2,1,1,1,1,1,1,2,1,1,1,1,1,1,2,1,1,1,1,1,1,2,1,1,1,1,1,1,2,1,1,1,1,1,1,2,1,1,1,1,1,1,2,1,1,1,1,1,2,1,1,1,1,1,1,2,1,1,1,1,1,1,2,1,1 mov $2,$0 div $0,80 mov $1,1031 add $2,$0 add $2,1066 mov $3,1031 lpb $2 lpb $3 add $2,$3 sub $3,$3 lpe mul $1,2 add $2,4 gcd $2,7 lpe div $1,2062
; A145696: Numbers Y such that 111*Y^2+37 is a square. ; Submitted by Jon Maiga ; 7,4137,2440823,1440081433,849645604647,501289466660297,295759935683970583,174497860764075983673,102953442090869146396487,60742356335752032297943657,35837887284651608186640361143,21144292755588113078085515130713,12475096887909702064462267286759527,7360286019573968629919659613672990217,4342556276451753581950534709799777468503,2562100842820515039382185559122255033426553,1511635154707827421481907529347420669944197767,891862179176775358159286060129419073012043255977 mov $2,1 lpb $0 sub $0,1 add $3,1 mov $1,$3 mul $1,588 add $2,$1 add $3,$2 lpe mov $0,$3 mul $0,7 add $0,7
// files.cpp -- saving to a file #include <iostream> // not needed for many systems #include <fstream> #include <string> #include <sstream> int main() { using namespace std; string filename = "file"; // create output stream object for new file and call it fout int i; for (i = 0; i < 140; i++) { ostringstream outstr; // manages a string stream outstr << filename << i; string fname = outstr.str(); ofstream fout(fname.c_str()); if (!fout.is_open()) break; fout << "For your eyes only!\n"; // write to file fout.close(); // close file fout.clear(); } cout << "i: " << i << endl; // std::cin.get(); // std::cin.get(); return 0; }
; A288599: a(n) = 2*a(n-1) - a(n-4) for n >= 4, where a(0) = 2, a(1) = 4, a(2) = 6, a(3) = 10, a(4) = 16. ; 2,4,6,10,16,28,50,90,164,300,550,1010,1856,3412,6274,11538,21220,39028,71782,132026,242832,446636,821490,1510954,2779076,5111516,9401542,17292130,31805184,58498852,107596162,197900194,363995204,669491556,1231386950,2264873706,4165752208,7662012860,14092638770,25920403834,47675055460,87688098060,161283557350,296646710866,545618366272,1003548634484,1845813711618,3394980712370,6244343058468,11485137482452,21124461253286,38853941794202,71463540529936,131441943577420,241759425901554,444664910008906,817866279487876,1504290615398332,2766821804895110,5088978699781314,9360091120074752,17215891624751172,31664961444607234,58240944189433154,107121797258791556,197027702892831940,362390444341056646,666539944492680138,1225958091726568720,2254888480560305500,4147386516779554354,7628233089066428570,14030508086406288420,25806127692252271340,47464868867724988326,87301504646383548082,160572501206360807744,295338874720469344148,543212880573213699970,999124256500043851858,1837676011793726895972,3380013148866984447796,6216813417160755195622,11434502577821466539386,21031329143849206182800,38682645138831427917804,71148476860502100639986,130862451143182734740586,240693573142516263298372,442704501146201098678940,814260525431900096717894,1497658599720617458695202,2754623626298718654092032,5066542751451236209505124,9318824977470572322292354,17139991355220527185889506,31525359084142335717686980,57984175416833435225868836,106649525856196298129445318,196159060357172069073001130 lpb $0 seq $0,232508 ; Number of (n+1) X (1+1) 0..2 arrays with every element next to itself plus and minus one within the range 0..2 horizontally, diagonally or antidiagonally, with no adjacent elements equal. mov $1,$0 mov $0,$2 lpe div $1,2 add $1,2 mov $0,$1
section .multiboot_header header_start: dd 0xe85250d6 ; multiboot2 ; architecture dd 0 ; protected mode i386 dd header_end - header_start ; checksum dd 0x100000000 - (0xe85250d6 + 0 + (header_end - header_start)) ; end tag dw 0 dw 0 dd 8 header_end:
// RUN: %clang_cc1 -triple x86_64-apple-macosx10.13.99 -verify -fsyntax-only -std=c++11 -fcxx-exceptions -fexceptions -DUNDERALIGNED %s // RUN: %clang_cc1 -triple arm64-apple-ios10 -verify -fsyntax-only -std=c++11 -fcxx-exceptions -fexceptions -DUNDERALIGNED %s // RUN: %clang_cc1 -triple arm64-apple-tvos10 -verify -fsyntax-only -std=c++11 -fcxx-exceptions -fexceptions -DUNDERALIGNED %s // RUN: %clang_cc1 -triple arm64-apple-watchos4 -verify -fsyntax-only -std=c++11 -fcxx-exceptions -fexceptions -DUNDERALIGNED %s // RUN: %clang_cc1 -triple x86_64-apple-macosx10.14 -verify -fsyntax-only -std=c++11 -fcxx-exceptions -fexceptions %s // RUN: %clang_cc1 -triple arm64-apple-ios12 -verify -fsyntax-only -std=c++11 -fcxx-exceptions -fexceptions %s // RUN: %clang_cc1 -triple arm64-apple-tvos12 -verify -fsyntax-only -std=c++11 -fcxx-exceptions -fexceptions %s // RUN: %clang_cc1 -triple arm64-apple-watchos5 -verify -fsyntax-only -std=c++11 -fcxx-exceptions -fexceptions %s // RUN: %clang_cc1 -triple arm-linux-gnueabi -verify -fsyntax-only -std=c++11 -fcxx-exceptions -fexceptions %s // RUN: %clang_cc1 -triple aarch64-linux-gnueabi -verify -fsyntax-only -std=c++11 -fcxx-exceptions -fexceptions %s // RUN: %clang_cc1 -triple mipsel-linux-gnu -verify -fsyntax-only -std=c++11 -fcxx-exceptions -fexceptions %s // RUN: %clang_cc1 -triple mips64el-linux-gnu -verify -fsyntax-only -std=c++11 -fcxx-exceptions -fexceptions %s // RUN: %clang_cc1 -triple wasm32-unknown-unknown -verify -fsyntax-only -std=c++11 -fcxx-exceptions -fexceptions %s // RUN: %clang_cc1 -triple wasm64-unknown-unknown -verify -fsyntax-only -std=c++11 -fcxx-exceptions -fexceptions %s // RUN: %clang_cc1 -triple x86_64-apple-macosx10.14 -verify -fsyntax-only -std=c++11 -fcxx-exceptions -fexceptions -Wno-underaligned-exception-object -DNODIAG %s // RUN: %clang_cc1 -triple x86_64-windows-msvc -verify -fsyntax-only -std=c++11 -fcxx-exceptions -fexceptions -DNODIAG %s struct S0 { S0(); int m; }; struct Overaligned1 { Overaligned1(); int __attribute__((aligned(16))) m; }; struct __attribute__((aligned(16))) Overaligned2 { Overaligned2(); int m; }; struct Overaligned3 { Overaligned3(); int __attribute__((aligned(64))) m; }; void test0() { throw S0(); } void test1() { throw Overaligned1(); } void test2() { throw Overaligned2(); } void test3() { throw Overaligned3(); } #if defined(NODIAG) // expected-no-diagnostics #elif defined(UNDERALIGNED) // expected-warning@-14 {{underaligned exception object thrown}} // expected-note@-15 {{(16 bytes) is larger than the supported alignment of C++ exception objects on this target (8 bytes)}} // expected-warning@-12 {{underaligned exception object thrown}} // expected-note@-13 {{(16 bytes) is larger than the supported alignment of C++ exception objects on this target (8 bytes)}} // expected-warning@-10 {{underaligned exception object thrown}} // expected-note@-11 {{(64 bytes) is larger than the supported alignment of C++ exception objects on this target (8 bytes)}} #else // expected-warning@-13 {{underaligned exception object thrown}} // expected-note@-14 {{(64 bytes) is larger than the supported alignment of C++ exception objects on this target (16 bytes)}} #endif
//: ---------------------------------------------------------------------------- //: Copyright (C) 2019 Verizon. All Rights Reserved. //: All Rights Reserved //: //: \file: sx_scopes.cc //: \details: TODO //: \author: Reed P. Morrison //: \date: 09/30/2019 //: //: 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. //: //: ---------------------------------------------------------------------------- //: ---------------------------------------------------------------------------- //: includes //: ---------------------------------------------------------------------------- #include "sx_scopes.h" #include "waflz/engine.h" #include "waflz/rqst_ctx.h" #include "waflz/kycb_db.h" #include "waflz/redis_db.h" #include "waflz/lm_db.h" #include "waflz/string_util.h" #include "is2/support/trace.h" #include "is2/support/nbq.h" #include "is2/support/ndebug.h" #include "is2/srvr/api_resp.h" #include "is2/srvr/srvr.h" #include "jspb/jspb.h" #include "support/file_util.h" #include "event.pb.h" #include "profile.pb.h" #include "rapidjson/document.h" #include "rapidjson/stringbuffer.h" #include "rapidjson/prettywriter.h" #include <errno.h> #include <string.h> #include <sys/stat.h> #include <sys/types.h> //: ---------------------------------------------------------------------------- //: constants //: ---------------------------------------------------------------------------- #ifndef STATUS_OK #define STATUS_OK 0 #endif #ifndef STATUS_ERROR #define STATUS_ERROR -1 #endif #define _SCOPEZ_SERVER_SCOPES_ID "waf-scopes-id" namespace ns_scopez_server { //: ---------------------------------------------------------------------------- //: type //: ---------------------------------------------------------------------------- typedef struct _waf_scopes_bg_update { char* m_buf; uint32_t m_buf_len; ns_waflz::scopes_configs* m_scopes_configs; } waf_scopes_bg_update_t; //: ---------------------------------------------------------------------------- //: remove lmdb dir //: ---------------------------------------------------------------------------- static int remove_dir(const std::string& a_db_dir) { int32_t l_s; struct stat l_stat; l_s = stat(a_db_dir.c_str(), &l_stat); if(l_s != 0) { return 0; } std::string l_file1(a_db_dir), l_file2(a_db_dir); l_file1.append("/data.mdb"); l_file2.append("/lock.mdb"); unlink(l_file1.c_str()); unlink(l_file2.c_str()); l_s = rmdir(a_db_dir.c_str()); if(l_s != 0) { return -1; } return 0; } //: ---------------------------------------------------------------------------- //: create_dir for lmdb //: ---------------------------------------------------------------------------- static int create_dir(const std::string& a_db_dir) { int32_t l_s; l_s = remove_dir(a_db_dir); if(l_s != 0) { return -1; } l_s = mkdir(a_db_dir.c_str(), 0700); return l_s; } //: ---------------------------------------------------------------------------- //: create_dir only once for lmdb //: ---------------------------------------------------------------------------- static int create_dir_once(const std::string& a_db_dir) { int32_t l_s; struct stat l_stat; l_s = stat(a_db_dir.c_str(), &l_stat); if(l_s == 0) { return 0; } l_s = create_dir(a_db_dir); return l_s; } //: ---------------------------------------------------------------------------- //: \details: TODO //: \return: TODO //: \param: TODO //: ---------------------------------------------------------------------------- static void* t_load_scopes(void* a_context) { waf_scopes_bg_update_t* l_sc = reinterpret_cast<waf_scopes_bg_update_t*>(a_context); if(!l_sc) { return NULL; } int32_t l_s; l_s = l_sc->m_scopes_configs->load(l_sc->m_buf, l_sc->m_buf_len); if(l_s != WAFLZ_STATUS_OK) { TRC_ERROR("performing scopes->load\n"); if(l_sc->m_buf) { free(l_sc->m_buf); l_sc->m_buf = NULL;} return NULL; } if(l_sc->m_buf) { free(l_sc->m_buf); l_sc->m_buf = NULL;} delete l_sc; return NULL; } //: ---------------------------------------------------------------------------- //: type //: ---------------------------------------------------------------------------- typedef struct _waf_profile_bg_update { char* m_buf; uint32_t m_buf_len; ns_waflz::scopes_configs* m_scopes_configs; } waf_profile_bg_update_t; //: ---------------------------------------------------------------------------- //: \details: TODO //: \return: TODO //: \param: TODO //: ---------------------------------------------------------------------------- static void* t_load_profile(void* a_context) { waf_profile_bg_update_t* l_sc = reinterpret_cast<waf_profile_bg_update_t*>(a_context); if(!l_sc) { return NULL; } int32_t l_s; l_s = l_sc->m_scopes_configs->load_profile(l_sc->m_buf, l_sc->m_buf_len); if(l_s != WAFLZ_STATUS_OK) { TRC_ERROR("performing profile loading\n"); if(l_sc->m_buf) { free(l_sc->m_buf); l_sc->m_buf = NULL;} return NULL; } if(l_sc->m_buf) { free(l_sc->m_buf); l_sc->m_buf = NULL;} delete l_sc; return NULL; } //: ---------------------------------------------------------------------------- //: type //: ---------------------------------------------------------------------------- typedef struct _waf_acl_bg_update { char* m_buf; uint32_t m_buf_len; ns_waflz::scopes_configs* m_scopes_configs; }waf_acl_bg_update_t; //: ---------------------------------------------------------------------------- //: \details: TODO //: \return: TODO //: \param: TODO //: ---------------------------------------------------------------------------- static void* t_load_acl(void* a_context) { waf_acl_bg_update_t* l_sc = reinterpret_cast<waf_acl_bg_update_t*>(a_context); if(!l_sc) { return NULL; } int32_t l_s; l_s = l_sc->m_scopes_configs->load_acl(l_sc->m_buf, l_sc->m_buf_len); if(l_s != WAFLZ_STATUS_OK) { TRC_ERROR("performing acl loading - %s\n", l_sc->m_scopes_configs->get_err_msg()); if(l_sc->m_buf) { free(l_sc->m_buf); l_sc->m_buf = NULL;} return NULL; } if(l_sc->m_buf) { free(l_sc->m_buf); l_sc->m_buf = NULL;} delete l_sc; return NULL; } //: ---------------------------------------------------------------------------- //: type //: ---------------------------------------------------------------------------- typedef struct _waf_rules_bg_update { char* m_buf; uint32_t m_buf_len; ns_waflz::scopes_configs* m_scopes_configs; } waf_rules_bg_update_t; typedef struct _waf_bots_bg_update { char* m_buf; uint32_t m_buf_len; ns_waflz::scopes_configs* m_scopes_configs; } waf_bots_bg_update_t; //: ---------------------------------------------------------------------------- //: \details: TODO //: \return: TODO //: \param: TODO //: ---------------------------------------------------------------------------- static void* t_load_rules(void* a_context) { waf_rules_bg_update_t* l_sc = reinterpret_cast<waf_rules_bg_update_t*>(a_context); if(!l_sc) { return NULL; } int32_t l_s; l_s = l_sc->m_scopes_configs->load_rules(l_sc->m_buf, l_sc->m_buf_len); if(l_s != WAFLZ_STATUS_OK) { TRC_ERROR("performing rules loading\n"); if(l_sc->m_buf) { free(l_sc->m_buf); l_sc->m_buf = NULL;} return NULL; } if(l_sc->m_buf) { free(l_sc->m_buf); l_sc->m_buf = NULL;} delete l_sc; return NULL; } static void* t_load_bots(void* a_context) { waf_bots_bg_update_t* l_sc = reinterpret_cast<waf_bots_bg_update_t*>(a_context); if(!l_sc) { return NULL; } int32_t l_s; l_s = l_sc->m_scopes_configs->load_bots(l_sc->m_buf, l_sc->m_buf_len); if(l_s != WAFLZ_STATUS_OK) { TRC_ERROR("performing bots loading\n"); if(l_sc->m_buf) { free(l_sc->m_buf); l_sc->m_buf = NULL;} return NULL; } if(l_sc->m_buf) { free(l_sc->m_buf); l_sc->m_buf = NULL;} delete l_sc; return NULL; } //: ---------------------------------------------------------------------------- //: \details: TODO //: \return: TODO //: \param: TODO //: ---------------------------------------------------------------------------- ns_is2::h_resp_t update_scopes_h::do_post(ns_is2::session &a_session, ns_is2::rqst &a_rqst, const ns_is2::url_pmap_t &a_url_pmap) { if(!m_scopes_configs) { TRC_ERROR("m_scopes_configs == NULL"); return ns_is2::H_RESP_SERVER_ERROR; } uint64_t l_buf_len = a_rqst.get_body_len(); ns_is2::nbq *l_q = a_rqst.get_body_q(); // copy to buffer char *l_buf; l_buf = (char *)malloc(l_buf_len); l_q->read(l_buf, l_buf_len); int32_t l_s; m_scopes_configs->set_locking(true); if(!m_bg_load) { l_s = m_scopes_configs->load(l_buf, l_buf_len); if(l_s != WAFLZ_STATUS_OK) { TRC_ERROR("update scopes failed %s\n", m_scopes_configs->get_err_msg()); if(l_buf) { free(l_buf); l_buf = NULL; } return ns_is2::H_RESP_SERVER_ERROR; } if(l_buf) { free(l_buf); l_buf = NULL; } } else { waf_scopes_bg_update_t* l_scopes_bg_update = new waf_scopes_bg_update_t(); l_scopes_bg_update->m_buf = l_buf; l_scopes_bg_update->m_buf_len = l_buf_len; l_scopes_bg_update->m_scopes_configs = m_scopes_configs; pthread_t l_t_thread; int32_t l_pthread_error = 0; l_pthread_error = pthread_create(&l_t_thread, NULL, t_load_scopes, l_scopes_bg_update); if (l_pthread_error != 0) { return ns_is2::H_RESP_SERVER_ERROR; } } std::string l_resp_str = "{\"status\": \"success\"}"; ns_is2::api_resp &l_api_resp = ns_is2::create_api_resp(a_session); l_api_resp.add_std_headers(ns_is2::HTTP_STATUS_OK, "application/json", l_resp_str.length(), a_rqst.m_supports_keep_alives, a_session.get_server_name()); l_api_resp.set_body_data(l_resp_str.c_str(), l_resp_str.length()); l_api_resp.set_status(ns_is2::HTTP_STATUS_OK); ns_is2::queue_api_resp(a_session, l_api_resp); return ns_is2::H_RESP_DONE; } //: ---------------------------------------------------------------------------- //: \details: TODO //: \return: TODO //: \param: TODO //: ---------------------------------------------------------------------------- ns_is2::h_resp_t update_limit_h::do_post(ns_is2::session &a_session, ns_is2::rqst &a_rqst, const ns_is2::url_pmap_t &a_url_pmap) { if(!m_scopes_configs) { TRC_ERROR("m_scopes_configs == NULL"); return ns_is2::H_RESP_SERVER_ERROR; } uint64_t l_buf_len = a_rqst.get_body_len(); ns_is2::nbq *l_q = a_rqst.get_body_q(); // copy to buffer char *l_buf; l_buf = (char *)malloc(l_buf_len); l_q->read(l_buf, l_buf_len); // get cust id from header int32_t l_s; l_s = m_scopes_configs->load_limit(l_buf, l_buf_len); if(l_s != WAFLZ_STATUS_OK) { TRC_ERROR("update limit failed %s\n", m_scopes_configs->get_err_msg()); if(l_buf) { free(l_buf); l_buf = NULL; } return ns_is2::H_RESP_SERVER_ERROR; } if(l_buf) { free(l_buf); l_buf = NULL; } std::string l_resp_str = "{\"status\": \"success\"}"; ns_is2::api_resp &l_api_resp = ns_is2::create_api_resp(a_session); l_api_resp.add_std_headers(ns_is2::HTTP_STATUS_OK, "application/json", l_resp_str.length(), a_rqst.m_supports_keep_alives, a_session.get_server_name()); l_api_resp.set_body_data(l_resp_str.c_str(), l_resp_str.length()); l_api_resp.set_status(ns_is2::HTTP_STATUS_OK); ns_is2::queue_api_resp(a_session, l_api_resp); return ns_is2::H_RESP_DONE; } //: ---------------------------------------------------------------------------- //: \details: TODO //: \return: TODO //: \param: TODO //: ---------------------------------------------------------------------------- ns_is2::h_resp_t update_acl_h::do_post(ns_is2::session &a_session, ns_is2::rqst &a_rqst, const ns_is2::url_pmap_t &a_url_pmap) { if(!m_scopes_configs) { TRC_ERROR("m_scopes_configs == NULL"); return ns_is2::H_RESP_SERVER_ERROR; } uint64_t l_buf_len = a_rqst.get_body_len(); ns_is2::nbq *l_q = a_rqst.get_body_q(); // copy to buffer char *l_buf; l_buf = (char *)malloc(l_buf_len); l_q->read(l_buf, l_buf_len); // get cust id from header int32_t l_s; if(!m_bg_load) { l_s = m_scopes_configs->load_acl(l_buf, l_buf_len); if(l_s != WAFLZ_STATUS_OK) { TRC_ERROR("update acl failed %s\n", m_scopes_configs->get_err_msg()); if(l_buf) { free(l_buf); l_buf = NULL; } return ns_is2::H_RESP_SERVER_ERROR; } if(l_buf) { free(l_buf); l_buf = NULL; } } else { waf_acl_bg_update_t* l_acl_bg_update = new waf_acl_bg_update_t(); l_acl_bg_update->m_buf = l_buf; l_acl_bg_update->m_buf_len = l_buf_len; l_acl_bg_update->m_scopes_configs = m_scopes_configs; pthread_t l_t_thread; int32_t l_pthread_error = 0; l_pthread_error = pthread_create(&l_t_thread, NULL, t_load_acl, l_acl_bg_update); if (l_pthread_error != 0) { return ns_is2::H_RESP_SERVER_ERROR; } } std::string l_resp_str = "{\"status\": \"success\"}"; ns_is2::api_resp &l_api_resp = ns_is2::create_api_resp(a_session); l_api_resp.add_std_headers(ns_is2::HTTP_STATUS_OK, "application/json", l_resp_str.length(), a_rqst.m_supports_keep_alives, a_session.get_server_name()); l_api_resp.set_body_data(l_resp_str.c_str(), l_resp_str.length()); l_api_resp.set_status(ns_is2::HTTP_STATUS_OK); ns_is2::queue_api_resp(a_session, l_api_resp); return ns_is2::H_RESP_DONE; } //: ---------------------------------------------------------------------------- //: \details: TODO //: \return: TODO //: \param: TODO //: ---------------------------------------------------------------------------- ns_is2::h_resp_t update_rules_h::do_post(ns_is2::session &a_session, ns_is2::rqst &a_rqst, const ns_is2::url_pmap_t &a_url_pmap) { if(!m_scopes_configs) { TRC_ERROR("m_scopes_configs == NULL"); return ns_is2::H_RESP_SERVER_ERROR; } uint64_t l_buf_len = a_rqst.get_body_len(); ns_is2::nbq *l_q = a_rqst.get_body_q(); // copy to buffer char *l_buf; l_buf = (char *)malloc(l_buf_len); l_q->read(l_buf, l_buf_len); int32_t l_s; if(!m_bg_load) { l_s = m_scopes_configs->load_rules(l_buf, l_buf_len); if(l_s != WAFLZ_STATUS_OK) { printf("update rules failed %s\n", m_scopes_configs->get_err_msg()); if(l_buf) { free(l_buf); l_buf = NULL; } return ns_is2::H_RESP_SERVER_ERROR; } if(l_buf) { free(l_buf); l_buf = NULL; } } else { waf_rules_bg_update_t* l_rules_bg_update = new waf_rules_bg_update_t(); l_rules_bg_update->m_buf = l_buf; l_rules_bg_update->m_buf_len = l_buf_len; l_rules_bg_update->m_scopes_configs = m_scopes_configs; pthread_t l_t_thread; int32_t l_pthread_error = 0; l_pthread_error = pthread_create(&l_t_thread, NULL, t_load_rules, l_rules_bg_update); if (l_pthread_error != 0) { return ns_is2::H_RESP_SERVER_ERROR; } } std::string l_resp_str = "{\"status\": \"success\"}"; ns_is2::api_resp &l_api_resp = ns_is2::create_api_resp(a_session); l_api_resp.add_std_headers(ns_is2::HTTP_STATUS_OK, "application/json", l_resp_str.length(), a_rqst.m_supports_keep_alives, a_session.get_server_name()); l_api_resp.set_body_data(l_resp_str.c_str(), l_resp_str.length()); l_api_resp.set_status(ns_is2::HTTP_STATUS_OK); ns_is2::queue_api_resp(a_session, l_api_resp); return ns_is2::H_RESP_DONE; } //: ---------------------------------------------------------------------------- //: \details: TODO //: \return: TODO //: \param: TODO //: ---------------------------------------------------------------------------- ns_is2::h_resp_t update_bots_h::do_post(ns_is2::session &a_session, ns_is2::rqst &a_rqst, const ns_is2::url_pmap_t &a_url_pmap) { if(!m_scopes_configs) { TRC_ERROR("m_scopes_configs == NULL"); return ns_is2::H_RESP_SERVER_ERROR; } uint64_t l_buf_len = a_rqst.get_body_len(); ns_is2::nbq *l_q = a_rqst.get_body_q(); // copy to buffer char *l_buf; l_buf = (char *)malloc(l_buf_len); l_q->read(l_buf, l_buf_len); int32_t l_s; if(!m_bg_load) { l_s = m_scopes_configs->load_bots(l_buf, l_buf_len); if(l_s != WAFLZ_STATUS_OK) { printf("update bots failed: %s\n", m_scopes_configs->get_err_msg()); if(l_buf) { free(l_buf); l_buf = NULL; } return ns_is2::H_RESP_SERVER_ERROR; } if(l_buf) { free(l_buf); l_buf = NULL; } } else { waf_bots_bg_update_t* l_bots_bg_update = new waf_bots_bg_update_t(); l_bots_bg_update->m_buf = l_buf; l_bots_bg_update->m_buf_len = l_buf_len; l_bots_bg_update->m_scopes_configs = m_scopes_configs; pthread_t l_t_thread; int32_t l_pthread_error = 0; l_pthread_error = pthread_create(&l_t_thread, NULL, t_load_bots, l_bots_bg_update); if (l_pthread_error != 0) { return ns_is2::H_RESP_SERVER_ERROR; } } std::string l_resp_str = "{\"status\": \"success\"}"; ns_is2::api_resp &l_api_resp = ns_is2::create_api_resp(a_session); l_api_resp.add_std_headers(ns_is2::HTTP_STATUS_OK, "application/json", l_resp_str.length(), a_rqst.m_supports_keep_alives, a_session.get_server_name()); l_api_resp.set_body_data(l_resp_str.c_str(), l_resp_str.length()); l_api_resp.set_status(ns_is2::HTTP_STATUS_OK); ns_is2::queue_api_resp(a_session, l_api_resp); return ns_is2::H_RESP_DONE; } //: ---------------------------------------------------------------------------- //: \details: TODO //: \return: TODO //: \param: TODO //: ---------------------------------------------------------------------------- ns_is2::h_resp_t update_profile_h::do_post(ns_is2::session &a_session, ns_is2::rqst &a_rqst, const ns_is2::url_pmap_t &a_url_pmap) { if(!m_scopes_configs) { TRC_ERROR("m_scopes_configs == NULL"); return ns_is2::H_RESP_SERVER_ERROR; } uint64_t l_buf_len = a_rqst.get_body_len(); ns_is2::nbq *l_q = a_rqst.get_body_q(); // copy to buffer char *l_buf; l_buf = (char *)malloc(l_buf_len); l_q->read(l_buf, l_buf_len); int32_t l_s; if(!m_bg_load) { l_s = m_scopes_configs->load_profile(l_buf, l_buf_len); if(l_s != WAFLZ_STATUS_OK) { printf("update profile failed %s\n", m_scopes_configs->get_err_msg()); if(l_buf) { free(l_buf); l_buf = NULL; } return ns_is2::H_RESP_SERVER_ERROR; } if(l_buf) { free(l_buf); l_buf = NULL; } } else { waf_profile_bg_update_t* l_profile_bg_update = new waf_profile_bg_update_t(); l_profile_bg_update->m_buf = l_buf; l_profile_bg_update->m_buf_len = l_buf_len; l_profile_bg_update->m_scopes_configs = m_scopes_configs; pthread_t l_t_thread; int32_t l_pthread_error = 0; l_pthread_error = pthread_create(&l_t_thread, NULL, t_load_profile, l_profile_bg_update); if (l_pthread_error != 0) { return ns_is2::H_RESP_SERVER_ERROR; } } std::string l_resp_str = "{\"status\": \"success\"}"; ns_is2::api_resp &l_api_resp = ns_is2::create_api_resp(a_session); l_api_resp.add_std_headers(ns_is2::HTTP_STATUS_OK, "application/json", l_resp_str.length(), a_rqst.m_supports_keep_alives, a_session.get_server_name()); l_api_resp.set_body_data(l_resp_str.c_str(), l_resp_str.length()); l_api_resp.set_status(ns_is2::HTTP_STATUS_OK); ns_is2::queue_api_resp(a_session, l_api_resp); return ns_is2::H_RESP_DONE; } //: ---------------------------------------------------------------------------- //: \details: TODO //: \return: TODO //: \param: TODO //: ---------------------------------------------------------------------------- sx_scopes::sx_scopes(void): m_bg_load(false), m_is_rand(false), m_use_lmdb(false), m_redis_host(), m_engine(NULL), m_update_scopes_h(NULL), m_update_acl_h(NULL), m_update_rules_h(NULL), m_update_bots_h(NULL), m_update_profile_h(NULL), m_update_limit_h(NULL), m_scopes_configs(NULL), m_config_path(), m_ruleset_dir(), m_geoip2_db(), m_geoip2_isp_db(), m_conf_dir() { } //: ---------------------------------------------------------------------------- //: \details: TODO //: \return: TODO //: \param: TODO //: ---------------------------------------------------------------------------- sx_scopes::~sx_scopes(void) { if(m_engine) { delete m_engine; m_engine = NULL; } if(m_db) { delete m_db; m_db = NULL; } if(m_b_challenge) { delete m_b_challenge; m_b_challenge = NULL; } if(m_update_scopes_h) { delete m_update_scopes_h; m_update_scopes_h = NULL; } if(m_update_acl_h) { delete m_update_acl_h; m_update_acl_h = NULL; } if(m_update_rules_h) { delete m_update_rules_h; m_update_rules_h = NULL; } if(m_update_bots_h) { delete m_update_bots_h; m_update_bots_h = NULL; } if(m_update_profile_h) { delete m_update_profile_h; m_update_profile_h = NULL; } if(m_update_limit_h) {delete m_update_limit_h; m_update_limit_h = NULL; } if(m_scopes_configs) { delete m_scopes_configs; m_scopes_configs = NULL; } if(m_use_lmdb) { remove_dir("/tmp/test_lmdb"); } } //: ---------------------------------------------------------------------------- //: \details: TODO //: \return: TODO //: \param: TODO //: ---------------------------------------------------------------------------- int32_t sx_scopes::init(void) { int32_t l_s; // ------------------------------------------------- // redis db // ------------------------------------------------- if(!m_redis_host.empty()) { m_db = reinterpret_cast<ns_waflz::kv_db *>(new ns_waflz::redis_db()); // ----------------------------------------- // parse host // ----------------------------------------- std::string l_host; uint16_t l_port; size_t l_last = 0; size_t l_next = 0; while((l_next = m_redis_host.find(":", l_last)) != std::string::npos) { l_host = m_redis_host.substr(l_last, l_next-l_last); l_last = l_next + 1; break; } std::string l_port_str; l_port_str = m_redis_host.substr(l_last); if(l_port_str.empty() || l_host.empty()) { NDBG_OUTPUT("error parsing redis host: %s -expected <host>:<port>\n", m_redis_host.c_str()); return STATUS_ERROR; } // TODO -error checking l_port = (uint16_t)strtoul(l_port_str.c_str(), NULL, 10); // TODO -check status m_db->set_opt(ns_waflz::redis_db::OPT_REDIS_HOST, l_host.c_str(), l_host.length()); m_db->set_opt(ns_waflz::redis_db::OPT_REDIS_PORT, NULL, l_port); // ----------------------------------------- // init db // ----------------------------------------- l_s = m_db->init(); if(l_s != STATUS_OK) { NDBG_PRINT("error performing db init: Reason: %s\n", m_db->get_err_msg()); return STATUS_ERROR; } NDBG_PRINT("USING REDIS\n"); } // ------------------------------------------------- // lmdb // ------------------------------------------------- else if(m_use_lmdb) { m_db = reinterpret_cast<ns_waflz::kv_db *>(new ns_waflz::lm_db()); std::string l_db_dir("/tmp/test_lmdb"); if(m_lmdb_interprocess) { l_s = create_dir_once(l_db_dir); if(l_s != STATUS_OK) { NDBG_PRINT("error creating dir -%s\n", l_db_dir.c_str()); return STATUS_ERROR; } } else { l_s = create_dir(l_db_dir); if(l_s != STATUS_OK) { NDBG_PRINT("error creating dir - %s\n", l_db_dir.c_str()); return STATUS_ERROR; } } if(l_s != STATUS_OK) { NDBG_PRINT("error creating dir for lmdb\n"); return STATUS_ERROR; } m_db->set_opt(ns_waflz::lm_db::OPT_LMDB_DIR_PATH, l_db_dir.c_str(), l_db_dir.length()); m_db->set_opt(ns_waflz::lm_db::OPT_LMDB_READERS, NULL, 6); m_db->set_opt(ns_waflz::lm_db::OPT_LMDB_MMAP_SIZE, NULL, 10485760); l_s = m_db->init(); if(l_s != STATUS_OK) { NDBG_PRINT("error performing db init: Reason: %s\n", m_db->get_err_msg()); return STATUS_ERROR; } if(!m_db->get_init()) { printf("error -%s\n", m_db->get_err_msg()); } NDBG_PRINT("USING LMDB\n"); } // ------------------------------------------------- // kyoto // ------------------------------------------------- else { char l_db_file[] = "/tmp/waflz-XXXXXX.kyoto.db"; //uint32_t l_db_buckets = 0; //uint32_t l_db_map = 0; //int l_db_options = 0; //l_db_options |= kyotocabinet::HashDB::TSMALL; //l_db_options |= kyotocabinet::HashDB::TLINEAR; //l_db_options |= kyotocabinet::HashDB::TCOMPRESS; m_db = reinterpret_cast<ns_waflz::kv_db *>(new ns_waflz::kycb_db()); errno = 0; l_s = mkstemps(l_db_file,9); if(l_s == -1) { NDBG_PRINT("error(%d) performing mkstemp(%s) reason[%d]: %s\n", l_s, l_db_file, errno, strerror(errno)); return STATUS_ERROR; } unlink(l_db_file); m_db->set_opt(ns_waflz::kycb_db::OPT_KYCB_DB_FILE_PATH, l_db_file, strlen(l_db_file)); //NDBG_PRINT("l_db_file: %s\n", l_db_file); l_s = m_db->init(); if(l_s != STATUS_OK) { NDBG_PRINT("error performing initialize_cb: Reason: %s\n", m_db->get_err_msg()); return STATUS_ERROR; } } // ------------------------------------------------- // engine // ------------------------------------------------- m_engine = new ns_waflz::engine(); m_engine->set_ruleset_dir(m_ruleset_dir); m_engine->set_geoip2_dbs(m_geoip2_db, m_geoip2_isp_db); l_s = m_engine->init(); if(l_s != WAFLZ_STATUS_OK) { NDBG_PRINT("error initializing engine\n"); return STATUS_ERROR; } // ------------------------------------------------- // init bot challenge // ------------------------------------------------- m_b_challenge = new ns_waflz::challenge(); if(!m_b_challenge_file.empty()) { l_s = m_b_challenge->load_file(m_b_challenge_file.c_str(), m_b_challenge_file.length()); if(l_s != STATUS_OK) { NDBG_PRINT("Error:%s", m_b_challenge->get_err_msg()); } } // ------------------------------------------------- // create scope configs // ------------------------------------------------- m_scopes_configs = new ns_waflz::scopes_configs(*m_engine, *m_db, *m_b_challenge, false); m_scopes_configs->set_conf_dir(m_conf_dir); if(l_s != WAFLZ_STATUS_OK) { // TODO log error return STATUS_ERROR; } m_scopes_configs->set_locking(true); // ------------------------------------------------- // load scopes dir // ------------------------------------------------- if(m_scopes_dir) { if(m_an_list_file.empty()) { NDBG_PRINT("no an list file speified. set -l\n"); return STATUS_ERROR; } char *l_buf = NULL; uint32_t l_buf_len = 0; l_s = ns_waflz::read_file(m_an_list_file.c_str(), &l_buf, l_buf_len); if(l_s != WAFLZ_STATUS_OK) { NDBG_PRINT("error read_file: %s\n", m_an_list_file.c_str()); return STATUS_ERROR; } // ------------------------------------------------- // set an map to allow loading of scopes config // ------------------------------------------------- l_s = m_scopes_configs->load_an_list(l_buf, l_buf_len); if(l_s != WAFLZ_STATUS_OK) { NDBG_PRINT("error loading AN config. reason: %s\n", m_scopes_configs->get_err_msg()); if(l_buf) { free(l_buf); l_buf = NULL; } return STATUS_ERROR; } if(l_buf) { free(l_buf); l_buf = NULL; l_buf_len = 0;} l_s = m_scopes_configs->load_dir(m_config.c_str(), m_config.length()); if(l_s != WAFLZ_STATUS_OK) { NDBG_PRINT("error read dir %s\n", m_config.c_str()); return STATUS_ERROR; } } // ------------------------------------------------- // load single scopes file // ------------------------------------------------- else { char *l_buf = NULL; uint32_t l_buf_len = 0; //NDBG_PRINT("reading file: %s\n", l_instance_file.c_str()); l_s = ns_waflz::read_file(m_config.c_str(), &l_buf, l_buf_len); if(l_s != WAFLZ_STATUS_OK) { NDBG_PRINT("error read_file: %s\n", m_config.c_str()); return STATUS_ERROR; } l_s = m_scopes_configs->load(l_buf, l_buf_len); if(l_s != WAFLZ_STATUS_OK) { NDBG_PRINT("error loading config: %s. reason: %s\n", m_config.c_str(), m_scopes_configs->get_err_msg()); if(l_buf) { free(l_buf); l_buf = NULL; } return STATUS_ERROR; } if(l_buf) { free(l_buf); l_buf = NULL; l_buf_len = 0;} } // ------------------------------------------------- // update end points // ------------------------------------------------- m_update_scopes_h = new update_scopes_h(); m_update_scopes_h->m_scopes_configs = m_scopes_configs; m_update_scopes_h->m_bg_load = m_bg_load; m_lsnr->add_route("/update_scopes", m_update_scopes_h); m_update_acl_h = new update_acl_h(); m_update_acl_h->m_scopes_configs = m_scopes_configs; m_update_acl_h->m_bg_load = m_bg_load; m_lsnr->add_route("/update_acl", m_update_acl_h); m_update_rules_h = new update_rules_h(); m_update_rules_h->m_scopes_configs = m_scopes_configs; m_update_rules_h->m_bg_load = m_bg_load; m_lsnr->add_route("/update_rules", m_update_rules_h); m_update_bots_h = new update_bots_h(); m_update_bots_h->m_scopes_configs = m_scopes_configs; m_update_bots_h->m_bg_load = m_bg_load; m_lsnr->add_route("/update_bots", m_update_bots_h); m_update_profile_h = new update_profile_h(); m_update_profile_h->m_scopes_configs = m_scopes_configs; m_update_profile_h->m_bg_load = m_bg_load; m_lsnr->add_route("/update_profile", m_update_profile_h); m_update_limit_h = new update_limit_h(); m_update_limit_h->m_scopes_configs = m_scopes_configs; m_lsnr->add_route("/update_limit", m_update_limit_h); printf("listeners added\n"); return STATUS_OK; } //: ---------------------------------------------------------------------------- //: \details: TODO //: \return: TODO //: \param: TODO //: ---------------------------------------------------------------------------- ns_is2::h_resp_t sx_scopes::handle_rqst(waflz_pb::enforcement **ao_enf, ns_waflz::rqst_ctx **ao_ctx, ns_is2::session &a_session, ns_is2::rqst &a_rqst, const ns_is2::url_pmap_t &a_url_pmap) { ns_is2::h_resp_t l_resp_code = ns_is2::H_RESP_NONE; if(ao_enf) { *ao_enf = NULL;} if(!m_scopes_configs) { return ns_is2::H_RESP_SERVER_ERROR; } // ------------------------------------------------- // events // ------------------------------------------------- int32_t l_s; waflz_pb::event *l_event_prod = NULL; waflz_pb::event *l_event_audit = NULL; ns_waflz::rqst_ctx *l_ctx = NULL; m_resp = "{\"status\": \"ok\"}"; uint64_t l_id = 0; // ------------------------------------------------- // get id from header if exists // ------------------------------------------------- const ns_is2::mutable_data_map_list_t& l_headers(a_rqst.get_header_map()); ns_is2::mutable_data_t i_hdr; if(ns_is2::find_first(i_hdr, l_headers, _SCOPEZ_SERVER_SCOPES_ID, sizeof(_SCOPEZ_SERVER_SCOPES_ID))) { std::string l_hex; l_hex.assign(i_hdr.m_data, i_hdr.m_len); l_s = ns_waflz::convert_hex_to_uint(l_id, l_hex.c_str()); if(l_s != WAFLZ_STATUS_OK) { NDBG_PRINT("an provided is not a provided hex\n"); return ns_is2::H_RESP_SERVER_ERROR; } } // ------------------------------------------------- // pick rand if id empty // ------------------------------------------------- if(!l_id && m_is_rand) { m_scopes_configs->get_rand_id(l_id); } // ------------------------------------------------- // get first // ------------------------------------------------- else if(!l_id) { m_scopes_configs->get_first_id(l_id); } if(!l_id) { if(l_event_audit) { delete l_event_audit; l_event_audit = NULL; } if(l_event_prod) { delete l_event_prod; l_event_prod = NULL; } if(l_ctx) { delete l_ctx; l_ctx = NULL; } return ns_is2::H_RESP_SERVER_ERROR; } // ------------------------------------------------- // process // ------------------------------------------------- l_s = m_scopes_configs->process(ao_enf, &l_event_audit, &l_event_prod, &a_session, l_id, ns_waflz::PART_MK_ALL, m_callbacks, &l_ctx); if(l_s != WAFLZ_STATUS_OK) { NDBG_PRINT("error processing config. reason: %s\n", m_scopes_configs->get_err_msg()); if(l_event_audit) { delete l_event_audit; l_event_audit = NULL; } if(l_event_prod) { delete l_event_prod; l_event_prod = NULL; } if(l_ctx) { delete l_ctx; l_ctx = NULL; } return ns_is2::H_RESP_SERVER_ERROR; } // ------------------------------------------------- // ************************************************* // R E S P O N S E // ************************************************* // ------------------------------------------------- std::string l_event_str = "{}"; // ------------------------------------------------- // for instances create string with both... // ------------------------------------------------- rapidjson::Document l_event_prod_json; rapidjson::Document l_event_audit_json; if(l_event_audit) { //NDBG_PRINT(" audit event %s", l_event_audit->DebugString().c_str()); l_s = ns_waflz::convert_to_json(l_event_audit_json, *l_event_audit); if(l_s != JSPB_OK) { NDBG_PRINT("error performing convert_to_json.\n"); if(l_event_audit) { delete l_event_audit; l_event_audit = NULL; } if(l_event_prod) { delete l_event_prod; l_event_prod = NULL; } if(l_ctx) { delete l_ctx; l_ctx = NULL; } return ns_is2::H_RESP_SERVER_ERROR; } if(l_event_audit) { delete l_event_audit; l_event_audit = NULL; } } if(l_event_prod) { //NDBG_PRINT(" prod event %s",l_event_prod->DebugString().c_str()); l_s = ns_waflz::convert_to_json(l_event_prod_json, *l_event_prod); if(l_s != JSPB_OK) { NDBG_PRINT("error performing convert_to_json.\n"); if(l_event_audit) { delete l_event_audit; l_event_audit = NULL; } if(l_event_prod) { delete l_event_prod; l_event_prod = NULL; } if(l_ctx) { delete l_ctx; l_ctx = NULL; } return ns_is2::H_RESP_SERVER_ERROR; } } // ------------------------------------------------- // create resp... // ------------------------------------------------- rapidjson::Document l_js_doc; l_js_doc.SetObject(); rapidjson::Document::AllocatorType& l_js_allocator = l_js_doc.GetAllocator(); l_js_doc.AddMember("audit_profile", l_event_audit_json, l_js_allocator); l_js_doc.AddMember("prod_profile", l_event_prod_json, l_js_allocator); rapidjson::StringBuffer l_strbuf; rapidjson::Writer<rapidjson::StringBuffer> l_js_writer(l_strbuf); l_js_doc.Accept(l_js_writer); m_resp.assign(l_strbuf.GetString(), l_strbuf.GetSize()); // ------------------------------------------------- // cleanup // ------------------------------------------------- if(l_event_audit) { delete l_event_audit; l_event_audit = NULL; } if(l_event_prod) { delete l_event_prod; l_event_prod = NULL; } if(ao_ctx) { *ao_ctx = l_ctx; } else if(l_ctx) { delete l_ctx; l_ctx = NULL; } return l_resp_code; } }
;Copyright 2013-2015 by Explorer Developers. ;made by Lab Explorer Developers<1@GhostBirdOS.org> ;Explorer x86 function switch to ;Explorer/arch/x86/kernel/task/switch_to.asm ;version:Alpha ;1/11/2015 1:02 AM %define TASK_STACK 8 global switch_to extern current extern printk extern print_mem [bits 32] ;切换任务函数 ;void switch_to(union task* id); ;参数:id为要切换的任务的id(联合体首地址) ;id:[ESP+4] switch_to: mov eax,[esp+4] mov ecx,[current] ;将current指向新任务 mov [current],eax ;保存相关信息 pushfd push ebp ;pushad mov [ecx+TASK_STACK],esp ;切换堆栈 mov esp,[eax+TASK_STACK] ;还原信息 pop ebp popfd ret
Name: kart-ppu-e.asm Type: file Size: 21779 Last-Modified: '1992-11-18T00:37:59Z' SHA-1: 82752ABDD4C6F4365C472B77D4D45FF029B6AAA5 Description: null
global added_char extern puts section .text ; input: rdi = s1, rsi = s2 ; output: al ; callee saved registers: rbx, rsp, rbp, r12-r15 added_char: sub rsp, 400h ; allocate 100h dword table on stack ; init character counter table xor rax, rax mov ecx, 100h/2 ; init the 100h dwords with 100h/2 qwords .init_loop: mov [rsp+rcx*8-8], rax loop .init_loop ; count characters in string s1 xchg rsi, rdi ; rsi = s1, rdi = s2 cld ; go upwards in the strings .s1_count_loop: lodsb inc dword [rsp+rax*4] test al, al jnz .s1_count_loop ; repeat until end of string ; subtract count of characters in string s2 ; a negative count indicates an added char in s2 mov rsi, rdi ; rsi = s2 .s2_count_loop: lodsb dec dword [rsp+rax*4] js .found ; counter negative: found an added char test al, al jnz .s2_count_loop ; repeat until end of string ; the rip is here: error, not found an added char .found: add rsp, 400h ret
; ; Drawbox sub for drawb(), undrawb(), xordrawb() ; ; Generic high resolution version ; ; ; $Id: w_drawbox.asm $ ; IF !__CPU_INTEL__ && !__CPU_GBZ80__ SECTION code_graphics PUBLIC drawbox ; IN: HL,DE = (x,y). HL' = width, DE' = height .drawbox ; Decrement width/height by 1 dec de dec hl push hl push de exx push hl push de exx ;exx push de ; y delta exx pop bc ; y delta exx push hl inc hl .xloop1 exx call plot_sub ; (hl,de) ex de,hl add hl,bc ; y += delta ex de,hl call plot_sub ; (hl,de) ex de,hl and a sbc hl,bc ; y -= delta ex de,hl inc hl exx dec hl ld a,h or l jr nz,xloop1 pop hl ; restore x exx pop de ; y pop hl exx pop de ; y delta pop hl push hl ; x delta exx pop bc ; x delta inc de exx dec de .yloop1 exx call plot_sub ; (hl,de) add hl,bc ; x += delta call plot_sub ; (hl,de) and a sbc hl,bc ; x -= delta inc de exx dec de ld a,d or e jr nz,yloop1 ret .plot_sub push bc push hl push de call jpix pop de pop hl pop bc ret jpix: jp (ix) ENDIF
[bits 32] [extern IsrHandler] ; Needed that the C code can call the Assembler function "IdtFlush" [GLOBAL IdtFlush] [GLOBAL RaiseInterrupt] ; The following macro emits the ISR assembly routine %macro ISR_NOERRORCODE 1 [GLOBAL Isr%1] Isr%1: cli push byte 0 push byte %1 jmp IsrCommonStub %endmacro ; Emitting our 32 ISR assembly routines ISR_NOERRORCODE 0 ISR_NOERRORCODE 1 ISR_NOERRORCODE 2 ISR_NOERRORCODE 3 ISR_NOERRORCODE 4 ISR_NOERRORCODE 5 ISR_NOERRORCODE 6 ISR_NOERRORCODE 7 ISR_NOERRORCODE 8 ISR_NOERRORCODE 9 ISR_NOERRORCODE 10 ISR_NOERRORCODE 11 ISR_NOERRORCODE 12 ISR_NOERRORCODE 13 ISR_NOERRORCODE 14 ISR_NOERRORCODE 15 ISR_NOERRORCODE 16 ISR_NOERRORCODE 17 ISR_NOERRORCODE 18 ISR_NOERRORCODE 19 ISR_NOERRORCODE 20 ISR_NOERRORCODE 21 ISR_NOERRORCODE 22 ISR_NOERRORCODE 23 ISR_NOERRORCODE 24 ISR_NOERRORCODE 25 ISR_NOERRORCODE 26 ISR_NOERRORCODE 27 ISR_NOERRORCODE 28 ISR_NOERRORCODE 29 ISR_NOERRORCODE 30 ISR_NOERRORCODE 31 ; Common function for ISR handling IsrCommonStub: pusha mov ax, ds push eax mov ax, 0x10 mov ds, ax mov es, ax mov fs, ax mov gs, ax ; Call the ISR handler that is implemented in C call IsrHandler pop eax mov ds, ax mov es, ax mov fs, ax mov gs, ax popa add esp, 8 sti iret ; Loads the IDT table IdtFlush: mov eax, [esp + 4] lidt [eax] ret ; Raises some sample interrupts for testing RaiseInterrupt: int 0x0 int 0x1 int 0x10 int 0x16 ret
/**************************************************************************** Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "CCSet.h" using namespace std; NS_CC_BEGIN __Set::__Set(void) { _set = new set<Ref *>; } __Set::__Set(const __Set &other) { _set = new set<Ref *>(*other._set); // call retain of members __SetIterator iter; for (iter = _set->begin(); iter != _set->end(); ++iter) { if (! (*iter)) { break; } (*iter)->retain(); } } __Set::~__Set(void) { removeAllObjects(); CC_SAFE_DELETE(_set); } void __Set::acceptVisitor(DataVisitor &visitor) { visitor.visit(this); } __Set * __Set::create() { __Set * pRet = new __Set(); if (pRet != NULL) { pRet->autorelease(); } return pRet; } __Set* __Set::copy(void) { __Set *p__Set = new __Set(*this); return p__Set; } __Set* __Set::mutableCopy(void) { return copy(); } int __Set::count(void) { return (int)_set->size(); } void __Set::addObject(Ref *pObject) { if (_set->count(pObject) == 0) { CC_SAFE_RETAIN(pObject); _set->insert(pObject); } } void __Set::removeObject(Ref *pObject) { if (_set->erase(pObject) > 0) { CC_SAFE_RELEASE(pObject); } } void __Set::removeAllObjects() { __SetIterator it = _set->begin(); __SetIterator tmp; while (it != _set->end()) { if (!(*it)) { break; } tmp = it; ++tmp; Ref * obj = *it; _set->erase(it); CC_SAFE_RELEASE(obj); it = tmp; } } bool __Set::containsObject(Ref *pObject) { return _set->find(pObject) != _set->end(); } __SetIterator __Set::begin(void) { return _set->begin(); } __SetIterator __Set::end(void) { return _set->end(); } Ref* __Set::anyObject() { if (!_set || _set->empty()) { return 0; } __SetIterator it; for( it = _set->begin(); it != _set->end(); ++it) { if (*it) { return (*it); } } return 0; } NS_CC_END
; A005915: Hexagonal prism numbers: a(n) = (n + 1)*(3*n^2 + 3*n + 1). ; 1,14,57,148,305,546,889,1352,1953,2710,3641,4764,6097,7658,9465,11536,13889,16542,19513,22820,26481,30514,34937,39768,45025,50726,56889,63532,70673,78330,86521,95264,104577,114478,124985,136116,147889,160322,173433,187240,201761,217014,233017,249788,267345,285706,304889,324912,345793,367550,390201,413764,438257,463698,490105,517496,545889,575302,605753,637260,669841,703514,738297,774208,811265,849486,888889,929492,971313,1014370,1058681,1104264,1151137,1199318,1248825,1299676,1351889,1405482,1460473,1516880,1574721,1634014,1694777,1757028,1820785,1886066,1952889,2021272,2091233,2162790,2235961,2310764,2387217,2465338,2545145,2626656,2709889,2794862,2881593,2970100,3060401,3152514,3246457,3342248,3439905,3539446,3640889,3744252,3849553,3956810,4066041,4177264,4290497,4405758,4523065,4642436,4763889,4887442,5013113,5140920,5270881,5403014,5537337,5673868,5812625,5953626,6096889,6242432,6390273,6540430,6692921,6847764,7004977,7164578,7326585,7491016,7657889,7827222,7999033,8173340,8350161,8529514,8711417,8895888,9082945,9272606,9464889,9659812,9857393,10057650,10260601,10466264,10674657,10885798,11099705,11316396,11535889,11758202,11983353,12211360,12442241,12676014,12912697,13152308,13394865,13640386,13888889,14140392,14394913,14652470,14913081,15176764,15443537,15713418,15986425,16262576,16541889,16824382,17110073,17398980,17691121,17986514,18285177,18587128,18892385,19200966,19512889,19828172,20146833,20468890,20794361,21123264,21455617,21791438,22130745,22473556,22819889,23169762,23523193,23880200,24240801,24605014,24972857,25344348,25719505,26098346,26480889,26867152,27257153,27650910,28048441,28449764,28854897,29263858,29676665,30093336,30513889,30938342,31366713,31799020,32235281,32675514,33119737,33567968,34020225,34476526,34936889,35401332,35869873,36342530,36819321,37300264,37785377,38274678,38768185,39265916,39767889,40274122,40784633,41299440,41818561,42342014,42869817,43401988,43938545,44479506,45024889,45574712,46128993,46687750 mov $1,6 mul $1,$0 add $1,4 pow $1,3 div $1,72 add $1,1
// Copyright 2019 The Fuchsia 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 <gtest/gtest.h> #include "src/developer/debug/debug_agent/integration_tests/message_loop_wrapper.h" #include "src/developer/debug/debug_agent/integration_tests/mock_stream_backend.h" #include "src/developer/debug/debug_agent/integration_tests/so_wrapper.h" #include "src/developer/debug/shared/logging/logging.h" #include "src/developer/debug/shared/zx_status.h" #include "src/lib/fxl/strings/string_printf.h" namespace debug_agent { using namespace debug_ipc; // This tests verifies that in a multithreaded program the debugger is able to // setup a breakpoint that will only affect a single thread and let the others // run without stopping in it. namespace { // Receives the notification from the DebugAgent. // The implementation is at the end of the file. class BreakpointStreamBackend : public MockStreamBackend { public: // In what part of the test we currently are. // This will determine when we quit the loop to let the test verify state. enum class TestStage { // Waits for the first thread start and modules. kWaitingForThreadToStart, // Waits for the other thread starting notifications. kCreatingOtherThreads, // Waits for the one thread to hit the breakpoint and all other threads // to exit. kExpectingBreakpointAndTerminations, // Waiting for the last thread to exit. kWaitingForFinalExit, // Waiting for the process to exit. kDone, kInvalid, }; BreakpointStreamBackend(MessageLoop* loop, size_t thread_count) : loop_(loop), thread_count_(thread_count) {} // API ----------------------------------------------------------------------- // Will send a resume notification to all threads and run the loop. void ResumeAllThreadsAndRunLoop(); // The messages we're interested in handling --------------------------------- // Searches the loaded modules for specific one. void HandleNotifyModules(NotifyModules) override; void HandleNotifyProcessExiting(NotifyProcessExiting) override; void HandleNotifyThreadStarting(NotifyThread) override; void HandleNotifyThreadExiting(NotifyThread) override; void HandleNotifyException(NotifyException) override; // Getters ------------------------------------------------------------------- MessageLoop* loop() const { return loop_; } uint64_t so_test_base_addr() const { return so_test_base_addr_; } zx_koid_t process_koid() const { return process_koid_; } bool process_exited() const { return process_exited_; } int64_t return_code() const { return return_code_; } size_t thread_count() const { return thread_count_; } const auto& thread_koids() const { return thread_koids_; } const auto& thread_starts() const { return thread_starts_; } const auto& thread_excp() const { return thread_excp_; } const auto& thread_exits() const { return thread_exits_; } private: // Every exception should ask whether it should stop the loop and let the test // verify if what happened is correct. This function holds the "script" that // the tests follows in order to work properly. void ShouldQuitLoop(); // Similar to ResumeAllThreadsAndRunLoop, but doesn't run the loop. void ResumeAllThreads(); MessageLoop* loop_; uint64_t so_test_base_addr_ = 0; zx_koid_t process_koid_ = 0; bool process_exited_ = false; int64_t return_code_ = 0; size_t thread_count_ = 0; std::vector<zx_koid_t> thread_koids_; std::vector<NotifyThread> thread_starts_; std::vector<NotifyException> thread_excp_; std::vector<NotifyThread> thread_exits_; bool initial_thread_check_passed_ = false; bool got_modules_check_passed_ = false; bool process_finished_check_passed_ = false; TestStage test_stage_ = TestStage::kWaitingForThreadToStart; }; std::pair<LaunchRequest, LaunchReply> GetLaunchRequest(const BreakpointStreamBackend& backend, std::string exe) { LaunchRequest launch_request = {}; launch_request.argv = {exe, fxl::StringPrintf("%lu", backend.thread_count())}; launch_request.inferior_type = InferiorType::kBinary; return {launch_request, {}}; } constexpr uint32_t kBreakpointId = 1234u; std::pair<AddOrChangeBreakpointRequest, AddOrChangeBreakpointReply> GetBreakpointRequest( zx_koid_t process_koid, zx_koid_t thread_koid, uint64_t address) { // We add a breakpoint in that address. debug_ipc::ProcessBreakpointSettings location = {}; location.process_koid = process_koid; location.thread_koid = thread_koid; location.address = address; debug_ipc::AddOrChangeBreakpointRequest breakpoint_request = {}; breakpoint_request.breakpoint.id = kBreakpointId; breakpoint_request.breakpoint.locations.push_back(location); DEBUG_LOG(Test) << "Setting breakpoint for [P: " << process_koid << ", T: " << thread_koid << "] on 0x" << std::hex << address; return {breakpoint_request, {}}; } } // namespace #if defined(__x86_64__) // TODO(DX-1500): This is flaky on X64 for an unknown reason. TEST(MultithreadedBreakpoint, DISABLED_SWBreakpoint) { #elif defined(__aarch64__) // TODO(DX-1448): Arm64 has an instruction cache that makes a thread sometimes // hit a thread that has been removed, making this test flake. // This has to be fixed in zircon. TEST(MultithreadedBreakpoint, DISABLED_SWBreakpoint) { #endif // Uncomment these is the test is giving you trouble. // Only uncomment SetDebugMode if the test is giving you *real* trouble. // debug_ipc::SetDebugMode(true); // debug_ipc::SetLogCategories({LogCategory::kTest}); // We attempt to load the pre-made .so. static constexpr const char kTestSo[] = "debug_agent_test_so.so"; SoWrapper so_wrapper; ASSERT_TRUE(so_wrapper.Init(kTestSo)) << "Could not load so " << kTestSo; uint64_t symbol_offset = so_wrapper.GetSymbolOffset(kTestSo, "MultithreadedFunctionToBreakOn"); ASSERT_NE(symbol_offset, 0u); MessageLoopWrapper loop_wrapper; { auto* loop = loop_wrapper.loop(); // The stream backend will intercept the calls from the debug agent. // Second arguments is the amount of threads to create. BreakpointStreamBackend backend(loop, 5); RemoteAPI* remote_api = backend.remote_api(); static constexpr const char kExecutable[] = "/pkg/bin/multithreaded_breakpoint_test_exe"; auto [lnch_request, lnch_reply] = GetLaunchRequest(backend, kExecutable); remote_api->OnLaunch(lnch_request, &lnch_reply); ASSERT_EQ(lnch_reply.status, ZX_OK) << ZxStatusToString(lnch_reply.status); backend.ResumeAllThreadsAndRunLoop(); // We should have the correct module by now. ASSERT_NE(backend.so_test_base_addr(), 0u); // We let the main thread spin up all the other threads. backend.ResumeAllThreadsAndRunLoop(); // At this point all sub-threads should have started. ASSERT_EQ(backend.thread_starts().size(), backend.thread_count() + 1); // Set a breakpoint auto& thread_koids = backend.thread_koids(); auto thread_koid = thread_koids[1]; // We get the offset of the loaded function within the process space. uint64_t module_base = backend.so_test_base_addr(); uint64_t module_function = module_base + symbol_offset; DEBUG_LOG(Test) << std::hex << "BASE: 0x" << module_base << ", OFFSET: 0x" << symbol_offset << ", FINAL: 0x" << module_function; auto [brk_request, brk_reply] = GetBreakpointRequest(backend.process_koid(), thread_koid, module_function); remote_api->OnAddOrChangeBreakpoint(brk_request, &brk_reply); ASSERT_EQ(brk_reply.status, ZX_OK) << ZxStatusToString(brk_reply.status); backend.ResumeAllThreadsAndRunLoop(); // At this point all threads should've exited except one in breakpoint and // the initial thread. auto& thread_exits = backend.thread_exits(); ASSERT_EQ(thread_exits.size(), thread_koids.size() - 2); auto& thread_excp = backend.thread_excp(); ASSERT_EQ(thread_excp.size(), 1u); auto& brk_notify = thread_excp.front(); EXPECT_EQ(brk_notify.thread.thread_koid, thread_koid); EXPECT_EQ(brk_notify.type, debug_ipc::NotifyException::Type::kSoftware); ASSERT_EQ(brk_notify.hit_breakpoints.size(), 1u); auto& hit_brk = brk_notify.hit_breakpoints.front(); EXPECT_EQ(hit_brk.id, kBreakpointId); EXPECT_EQ(hit_brk.hit_count, 1u); EXPECT_EQ(hit_brk.should_delete, false); backend.ResumeAllThreadsAndRunLoop(); // At this point all threads and processes should've exited. EXPECT_EQ(backend.thread_exits().size(), backend.thread_starts().size()); ASSERT_TRUE(backend.process_exited()); EXPECT_EQ(backend.return_code(), 0); } } // BreakpointStreamBackend Implementation -------------------------------------- void BreakpointStreamBackend::ResumeAllThreadsAndRunLoop() { ResumeAllThreads(); loop()->Run(); } void BreakpointStreamBackend::ResumeAllThreads() { debug_ipc::ResumeRequest resume_request; resume_request.process_koid = process_koid(); debug_ipc::ResumeReply resume_reply; remote_api()->OnResume(resume_request, &resume_reply); } // Records the exception given from the debug agent. void BreakpointStreamBackend::HandleNotifyException(NotifyException exception) { DEBUG_LOG(Test) << "Received " << NotifyException::TypeToString(exception.type) << " on Thread: " << exception.thread.thread_koid; thread_excp_.push_back(exception); ShouldQuitLoop(); } // Searches the loaded modules for specific one. void BreakpointStreamBackend::HandleNotifyModules(NotifyModules modules) { for (auto& module : modules.modules) { DEBUG_LOG(Test) << "Received module " << module.name; if (module.name == "libdebug_agent_test_so.so") { so_test_base_addr_ = module.base; break; } } ShouldQuitLoop(); } void BreakpointStreamBackend::HandleNotifyProcessExiting(NotifyProcessExiting process) { DEBUG_LOG(Test) << "Process " << process.process_koid << " exiting with return code: " << process.return_code; FXL_DCHECK(process.process_koid == process_koid_); process_exited_ = true; return_code_ = process.return_code; ShouldQuitLoop(); } void BreakpointStreamBackend::HandleNotifyThreadStarting(NotifyThread thread) { if (process_koid_ == 0) { process_koid_ = thread.record.process_koid; DEBUG_LOG(Test) << "Process starting: " << process_koid_; } DEBUG_LOG(Test) << "Thread starting: " << thread.record.thread_koid; thread_starts_.push_back(thread); thread_koids_.push_back(thread.record.thread_koid); ShouldQuitLoop(); } void BreakpointStreamBackend::HandleNotifyThreadExiting(NotifyThread thread) { DEBUG_LOG(Test) << "Thread exiting: " << thread.record.thread_koid; thread_exits_.push_back(thread); ShouldQuitLoop(); } void BreakpointStreamBackend::ShouldQuitLoop() { if (test_stage_ == TestStage::kWaitingForThreadToStart) { // The first thread started, we need to resume it. if (initial_thread_check_passed_ == 0 && thread_starts_.size() == 1u) { initial_thread_check_passed_ = true; ResumeAllThreads(); return; } if (!got_modules_check_passed_ && so_test_base_addr_ != 0u) { got_modules_check_passed_ = true; loop()->QuitNow(); test_stage_ = TestStage::kCreatingOtherThreads; DEBUG_LOG(Test) << "Stage change to CREATING OTHER THREADS"; return; } FXL_NOTREACHED() << "Didn't get thread start or modules."; } if (test_stage_ == TestStage::kCreatingOtherThreads) { if (thread_starts_.size() < thread_count_ + 1) { return; } else if (thread_starts_.size() == thread_count_ + 1) { // We received all the threads we expected for, quit the loop. loop()->QuitNow(); test_stage_ = TestStage::kExpectingBreakpointAndTerminations; DEBUG_LOG(Test) << "Stage change to EXPECTING BREAKPOINT"; return; } FXL_NOTREACHED() << "Didn't get all the thread startups."; } if (test_stage_ == TestStage::kExpectingBreakpointAndTerminations) { // We should only get one breakpoint. if (thread_excp_.size() > 1u) FXL_NOTREACHED() << "Got more than 1 exception."; // All subthreads should exit but one. if (thread_exits_.size() < thread_count_ - 1) return; if (thread_excp_.size() != 1u) FXL_NOTREACHED() << "Should've gotten one breakpoint exception."; if (thread_exits_.size() != thread_count_ - 1) FXL_NOTREACHED() << "All subthreads but one should've exited."; loop()->QuitNow(); test_stage_ = TestStage::kWaitingForFinalExit; DEBUG_LOG(Test) << "Stage change to WAITING FOR FINAL EXIT."; return; } if (test_stage_ == TestStage::kWaitingForFinalExit) { // This is the breakpoint thread. if (thread_exits_.size() < thread_starts_.size()) return; if (thread_exits_.size() == thread_starts_.size()) { test_stage_ = TestStage::kDone; DEBUG_LOG(Test) << "Stage change to DONE."; return; } FXL_NOTREACHED() << "Unexpected thread exit."; } if (test_stage_ == TestStage::kDone) { if (!process_finished_check_passed_ && process_exited_) { process_finished_check_passed_ = true; loop()->QuitNow(); test_stage_ = TestStage::kInvalid; return; } FXL_NOTREACHED() << "Should've only received process exit notification."; } FXL_NOTREACHED() << "Invalid stage."; } } // namespace debug_agent
PUBLIC txtwrchar ; fastcall so in HL! .txtwrchar ld a, l jp 0xB83C
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. /*============================================================================ ** ** Source: test17.c ** ** Purpose: Tests swscanf with floats (compact notation, uppercase) ** ** **==========================================================================*/ #include <palsuite.h> #include "../swscanf.h" int __cdecl main(int argc, char *argv[]) { if (PAL_Initialize(argc, argv)) { return FAIL; } DoFloatTest(convert("123.0"), convert("%G"), 123.0f); DoFloatTest(convert("123.0"), convert("%2G"), 12.0f); DoFloatTest(convert("10E1"), convert("%G"), 100.0f); DoFloatTest(convert("-12.01e-2"), convert("%G"), -0.1201f); DoFloatTest(convert("+12.01e-2"), convert("%G"), 0.1201f); DoFloatTest(convert("-12.01e+2"), convert("%G"), -1201.0f); DoFloatTest(convert("+12.01e+2"), convert("%G"), 1201.0f); DoFloatTest(convert("1234567890.0123456789f"), convert("%G"), 1234567936); PAL_Terminate(); return PASS; }
; ; Memotech MTX stdio ; ; getkey() Wait for keypress ; ; Stefano Bodrato - Aug. 2010 ; ; ; $Id: fgetc_cons.asm,v 1.3 2016/06/12 17:32:01 dom Exp $ ; SECTION code_clib PUBLIC fgetc_cons PUBLIC _fgetc_cons .fgetc_cons ._fgetc_cons call $79 jr z,fgetc_cons ld h,0 ld l,a ret
; A195146: Concentric 16-gonal numbers. ; 0,1,16,33,64,97,144,193,256,321,400,481,576,673,784,897,1024,1153,1296,1441,1600,1761,1936,2113,2304,2497,2704,2913,3136,3361,3600,3841,4096,4353,4624,4897,5184,5473,5776,6081,6400,6721,7056,7393,7744,8097,8464,8833,9216,9601,10000,10401,10816,11233,11664,12097,12544,12993,13456,13921,14400,14881,15376,15873,16384,16897,17424,17953,18496,19041,19600,20161,20736,21313,21904,22497,23104,23713,24336,24961,25600,26241,26896,27553,28224,28897,29584,30273,30976,31681,32400,33121,33856,34593,35344,36097,36864,37633,38416,39201,40000,40801,41616,42433,43264,44097,44944,45793,46656,47521,48400,49281,50176,51073,51984,52897,53824,54753,55696,56641,57600,58561,59536,60513,61504,62497,63504,64513,65536,66561,67600,68641,69696,70753,71824,72897,73984,75073,76176,77281,78400,79521,80656,81793,82944,84097,85264,86433,87616,88801,90000,91201,92416,93633,94864,96097,97344,98593,99856,101121,102400,103681,104976,106273,107584,108897,110224,111553,112896,114241,115600,116961,118336,119713,121104,122497,123904,125313,126736,128161,129600,131041,132496,133953,135424,136897,138384,139873,141376,142881,144400,145921,147456,148993,150544,152097,153664,155233,156816,158401,160000,161601,163216,164833,166464,168097,169744,171393,173056,174721,176400,178081,179776,181473,183184,184897,186624,188353,190096,191841,193600,195361,197136,198913,200704,202497,204304,206113,207936,209761,211600,213441,215296,217153,219024,220897,222784,224673,226576,228481,230400,232321,234256,236193,238144,240097,242064,244033,246016,248001 pow $0,2 mov $1,$0 mov $2,$0 div $2,2 mul $2,6 add $1,$2
#include <cstdio> #define NMAX 10000 int n; int a[NMAX + 10]; int main() { scanf("%d", &n); for (int i = 1; i <= n; i++) scanf("%d", a + i); bool ok = true; for (int i = 2; i <= n; i++) ok &= a[1] >= a[i]; puts(ok ? "S" : "N"); return 0; }
/* * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ #include "ABI40_0_0Scheduler.h" #include <glog/logging.h> #include <ABI40_0_0jsi/ABI40_0_0jsi.h> #include <ABI40_0_0React/core/LayoutContext.h> #include <ABI40_0_0React/debug/SystraceSection.h> #include <ABI40_0_0React/uimanager/ComponentDescriptorRegistry.h> #include <ABI40_0_0React/uimanager/UIManager.h> #include <ABI40_0_0React/uimanager/UIManagerBinding.h> #include <ABI40_0_0React/uimanager/UITemplateProcessor.h> namespace ABI40_0_0facebook { namespace ABI40_0_0React { Scheduler::Scheduler( SchedulerToolbox schedulerToolbox, SchedulerDelegate *delegate) { runtimeExecutor_ = schedulerToolbox.runtimeExecutor; ABI40_0_0ReactNativeConfig_ = schedulerToolbox.contextContainer ->at<std::shared_ptr<const ABI40_0_0ReactNativeConfig>>("ABI40_0_0ReactNativeConfig"); auto uiManager = std::make_shared<UIManager>(); auto eventOwnerBox = std::make_shared<EventBeat::OwnerBox>(); auto eventPipe = [uiManager]( jsi::Runtime &runtime, const EventTarget *eventTarget, const std::string &type, const ValueFactory &payloadFactory) { uiManager->visitBinding([&](UIManagerBinding const &uiManagerBinding) { uiManagerBinding.dispatchEvent( runtime, eventTarget, type, payloadFactory); }); }; auto statePipe = [uiManager](StateUpdate const &stateUpdate) { uiManager->updateState(stateUpdate); }; eventDispatcher_ = std::make_shared<EventDispatcher>( eventPipe, statePipe, schedulerToolbox.synchronousEventBeatFactory, schedulerToolbox.asynchronousEventBeatFactory, eventOwnerBox); eventOwnerBox->owner = eventDispatcher_; componentDescriptorRegistry_ = schedulerToolbox.componentRegistryFactory( eventDispatcher_, schedulerToolbox.contextContainer); rootComponentDescriptor_ = std::make_unique<const RootComponentDescriptor>( ComponentDescriptorParameters{eventDispatcher_, nullptr, nullptr}); uiManager->setDelegate(this); uiManager->setComponentDescriptorRegistry(componentDescriptorRegistry_); runtimeExecutor_([=](jsi::Runtime &runtime) { auto uiManagerBinding = UIManagerBinding::createAndInstallIfNeeded(runtime); uiManagerBinding->attach(uiManager); }); auto componentDescriptorRegistryKey = "ComponentDescriptorRegistry_DO_NOT_USE_PRETTY_PLEASE"; schedulerToolbox.contextContainer->erase(componentDescriptorRegistryKey); schedulerToolbox.contextContainer->insert( componentDescriptorRegistryKey, std::weak_ptr<ComponentDescriptorRegistry const>( componentDescriptorRegistry_)); delegate_ = delegate; uiManager_ = uiManager; } Scheduler::~Scheduler() { LOG(WARNING) << "Scheduler::~Scheduler() was called (address: " << this << ")."; // All Surfaces must be explicitly stopped before destroying `Scheduler`. // The idea is that `UIManager` is allowed to call `Scheduler` only if the // corresponding `ShadowTree` instance exists. // The thread-safety of this operation is guaranteed by this requirement. uiManager_->setDelegate(nullptr); // Then, let's verify that the requirement was satisfied. auto surfaceIds = std::vector<SurfaceId>{}; uiManager_->getShadowTreeRegistry().enumerate( [&](ShadowTree const &shadowTree, bool &stop) { surfaceIds.push_back(shadowTree.getSurfaceId()); }); assert( surfaceIds.size() == 0 && "Scheduler was destroyed with outstanding Surfaces."); if (surfaceIds.size() == 0) { return; } LOG(ERROR) << "Scheduler was destroyed with outstanding Surfaces."; // If we are here, that means assert didn't fire which indicates that we in // production. // Now we have still-running surfaces, which is no good, no good. // That's indeed a sign of a severe issue on the application layer. // At this point, we don't have much to lose, so we are trying to unmount all // outstanding `ShadowTree`s to prevent all stored JSI entities from // overliving the `Scheduler`. (Unmounting `ShadowNode`s disables // `EventEmitter`s which destroys JSI objects.) for (auto surfaceId : surfaceIds) { uiManager_->getShadowTreeRegistry().visit( surfaceId, [](ShadowTree const &shadowTree) { shadowTree.commitEmptyTree(); }); } } void Scheduler::startSurface( SurfaceId surfaceId, const std::string &moduleName, const folly::dynamic &initialProps, const LayoutConstraints &layoutConstraints, const LayoutContext &layoutContext) const { SystraceSection s("Scheduler::startSurface"); auto shadowTree = std::make_unique<ShadowTree>( surfaceId, layoutConstraints, layoutContext, *rootComponentDescriptor_, *uiManager_); auto uiManager = uiManager_; uiManager->getShadowTreeRegistry().add(std::move(shadowTree)); runtimeExecutor_([=](jsi::Runtime &runtime) { uiManager->visitBinding([&](UIManagerBinding const &uiManagerBinding) { uiManagerBinding.startSurface( runtime, surfaceId, moduleName, initialProps); }); }); } void Scheduler::renderTemplateToSurface( SurfaceId surfaceId, const std::string &uiTemplate) { SystraceSection s("Scheduler::renderTemplateToSurface"); try { if (uiTemplate.size() == 0) { return; } NativeModuleRegistry nMR; auto tree = UITemplateProcessor::buildShadowTree( uiTemplate, surfaceId, folly::dynamic::object(), *componentDescriptorRegistry_, nMR, ABI40_0_0ReactNativeConfig_); uiManager_->getShadowTreeRegistry().visit( surfaceId, [=](const ShadowTree &shadowTree) { return shadowTree.tryCommit( [&](RootShadowNode::Shared const &oldRootShadowNode) { return std::make_shared<RootShadowNode>( *oldRootShadowNode, ShadowNodeFragment{ /* .props = */ ShadowNodeFragment::propsPlaceholder(), /* .children = */ std::make_shared<SharedShadowNodeList>( SharedShadowNodeList{tree}), }); }); }); } catch (const std::exception &e) { LOG(ERROR) << " >>>> ABI40_0_0EXCEPTION <<< rendering uiTemplate in " << "Scheduler::renderTemplateToSurface: " << e.what(); } } void Scheduler::stopSurface(SurfaceId surfaceId) const { SystraceSection s("Scheduler::stopSurface"); // Note, we have to do in inside `visit` function while the Shadow Tree // is still being registered. uiManager_->getShadowTreeRegistry().visit( surfaceId, [](ShadowTree const &shadowTree) { // As part of stopping a Surface, we need to properly destroy all // mounted views, so we need to commit an empty tree to trigger all // side-effects that will perform that. shadowTree.commitEmptyTree(); }); // Waiting for all concurrent commits to be finished and unregistering the // `ShadowTree`. uiManager_->getShadowTreeRegistry().remove(surfaceId); // We execute JavaScript/ABI40_0_0React part of the process at the very end to minimize // any visible side-effects of stopping the Surface. Any possible commits from // the JavaScript side will not be able to reference a `ShadowTree` and will // fail silently. auto uiManager = uiManager_; runtimeExecutor_([=](jsi::Runtime &runtime) { uiManager->visitBinding([&](UIManagerBinding const &uiManagerBinding) { uiManagerBinding.stopSurface(runtime, surfaceId); }); }); } Size Scheduler::measureSurface( SurfaceId surfaceId, const LayoutConstraints &layoutConstraints, const LayoutContext &layoutContext) const { SystraceSection s("Scheduler::measureSurface"); Size size; uiManager_->getShadowTreeRegistry().visit( surfaceId, [&](const ShadowTree &shadowTree) { shadowTree.tryCommit( [&](RootShadowNode::Shared const &oldRootShadowNode) { auto rootShadowNode = oldRootShadowNode->clone(layoutConstraints, layoutContext); rootShadowNode->layoutIfNeeded(); size = rootShadowNode->getLayoutMetrics().frame.size; return nullptr; }); }); return size; } MountingCoordinator::Shared Scheduler::findMountingCoordinator( SurfaceId surfaceId) const { MountingCoordinator::Shared mountingCoordinator = nullptr; uiManager_->getShadowTreeRegistry().visit( surfaceId, [&](const ShadowTree &shadowTree) { mountingCoordinator = shadowTree.getMountingCoordinator(); }); return mountingCoordinator; } void Scheduler::constraintSurfaceLayout( SurfaceId surfaceId, const LayoutConstraints &layoutConstraints, const LayoutContext &layoutContext) const { SystraceSection s("Scheduler::constraintSurfaceLayout"); uiManager_->getShadowTreeRegistry().visit( surfaceId, [&](ShadowTree const &shadowTree) { shadowTree.commit([&](RootShadowNode::Shared const &oldRootShadowNode) { return oldRootShadowNode->clone(layoutConstraints, layoutContext); }); }); } ComponentDescriptor const * Scheduler::findComponentDescriptorByHandle_DO_NOT_USE_THIS_IS_BROKEN( ComponentHandle handle) const { return componentDescriptorRegistry_ ->findComponentDescriptorByHandle_DO_NOT_USE_THIS_IS_BROKEN(handle); } #pragma mark - Delegate void Scheduler::setDelegate(SchedulerDelegate *delegate) { delegate_ = delegate; } SchedulerDelegate *Scheduler::getDelegate() const { return delegate_; } #pragma mark - UIManagerDelegate void Scheduler::uiManagerDidFinishTransaction( MountingCoordinator::Shared const &mountingCoordinator) { SystraceSection s("Scheduler::uiManagerDidFinishTransaction"); if (delegate_) { delegate_->schedulerDidFinishTransaction(mountingCoordinator); } } void Scheduler::uiManagerDidCreateShadowNode( const ShadowNode::Shared &shadowNode) { SystraceSection s("Scheduler::uiManagerDidCreateShadowNode"); if (delegate_) { auto shadowView = ShadowView(*shadowNode); delegate_->schedulerDidRequestPreliminaryViewAllocation( shadowNode->getSurfaceId(), shadowView); } } void Scheduler::uiManagerDidDispatchCommand( const ShadowNode::Shared &shadowNode, std::string const &commandName, folly::dynamic const args) { SystraceSection s("Scheduler::uiManagerDispatchCommand"); if (delegate_) { auto shadowView = ShadowView(*shadowNode); delegate_->schedulerDidDispatchCommand(shadowView, commandName, args); } } /* * Set JS responder for a view */ void Scheduler::uiManagerDidSetJSResponder( SurfaceId surfaceId, const ShadowNode::Shared &shadowNode, bool blockNativeResponder) { if (delegate_) { // TODO: the first shadowView paramenter, should be the first parent that // is non virtual. auto shadowView = ShadowView(*shadowNode); delegate_->schedulerDidSetJSResponder( surfaceId, shadowView, shadowView, blockNativeResponder); } } /* * Clear the JSResponder for a view */ void Scheduler::uiManagerDidClearJSResponder() { if (delegate_) { delegate_->schedulerDidClearJSResponder(); } } } // namespace ABI40_0_0React } // namespace ABI40_0_0facebook
// Copyright (c) 2011-2013 The Bitcoin developers // Distributed under the MIT/X11 software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include "addressbookpage.h" #include "ui_addressbookpage.h" #include "addresstablemodel.h" #include "optionsmodel.h" #include "bitcoingui.h" #include "editaddressdialog.h" #include "csvmodelwriter.h" #include "guiutil.h" #ifdef USE_QRCODE #include "qrcodedialog.h" #endif #include <QSortFilterProxyModel> #include <QClipboard> #include <QMessageBox> #include <QMenu> AddressBookPage::AddressBookPage(Mode mode, Tabs tab, QWidget *parent) : QDialog(parent), ui(new Ui::AddressBookPage), model(0), optionsModel(0), mode(mode), tab(tab) { ui->setupUi(this); #ifdef Q_OS_MAC // Icons on push buttons are very uncommon on Mac ui->newAddress->setIcon(QIcon()); ui->copyAddress->setIcon(QIcon()); ui->deleteAddress->setIcon(QIcon()); ui->verifyMessage->setIcon(QIcon()); ui->signMessage->setIcon(QIcon()); ui->exportButton->setIcon(QIcon()); #endif #ifndef USE_QRCODE ui->showQRCode->setVisible(false); #endif switch(mode) { case ForSending: connect(ui->tableView, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(accept())); ui->tableView->setEditTriggers(QAbstractItemView::NoEditTriggers); ui->tableView->setFocus(); ui->exportButton->hide(); break; case ForEditing: ui->buttonBox->setVisible(false); break; } switch(tab) { case SendingTab: ui->labelExplanation->setText(tr("These are your Coin3Fly addresses for sending payments. Always check the amount and the receiving address before sending coins.")); ui->deleteAddress->setVisible(true); ui->signMessage->setVisible(false); break; case ReceivingTab: ui->labelExplanation->setText(tr("These are your Coin3Fly addresses for receiving payments. You may want to give a different one to each sender so you can keep track of who is paying you.")); ui->deleteAddress->setVisible(false); ui->signMessage->setVisible(true); break; } // Context menu actions QAction *copyAddressAction = new QAction(ui->copyAddress->text(), this); QAction *copyLabelAction = new QAction(tr("Copy &Label"), this); QAction *editAction = new QAction(tr("&Edit"), this); QAction *sendCoinsAction = new QAction(tr("Send &Coins"), this); QAction *showQRCodeAction = new QAction(ui->showQRCode->text(), this); QAction *signMessageAction = new QAction(ui->signMessage->text(), this); QAction *verifyMessageAction = new QAction(ui->verifyMessage->text(), this); deleteAction = new QAction(ui->deleteAddress->text(), this); // Build context menu contextMenu = new QMenu(); contextMenu->addAction(copyAddressAction); contextMenu->addAction(copyLabelAction); contextMenu->addAction(editAction); if(tab == SendingTab) contextMenu->addAction(deleteAction); contextMenu->addSeparator(); if(tab == SendingTab) contextMenu->addAction(sendCoinsAction); #ifdef USE_QRCODE contextMenu->addAction(showQRCodeAction); #endif if(tab == ReceivingTab) contextMenu->addAction(signMessageAction); else if(tab == SendingTab) contextMenu->addAction(verifyMessageAction); // Connect signals for context menu actions connect(copyAddressAction, SIGNAL(triggered()), this, SLOT(on_copyAddress_clicked())); connect(copyLabelAction, SIGNAL(triggered()), this, SLOT(onCopyLabelAction())); connect(editAction, SIGNAL(triggered()), this, SLOT(onEditAction())); connect(deleteAction, SIGNAL(triggered()), this, SLOT(on_deleteAddress_clicked())); connect(sendCoinsAction, SIGNAL(triggered()), this, SLOT(onSendCoinsAction())); connect(showQRCodeAction, SIGNAL(triggered()), this, SLOT(on_showQRCode_clicked())); connect(signMessageAction, SIGNAL(triggered()), this, SLOT(on_signMessage_clicked())); connect(verifyMessageAction, SIGNAL(triggered()), this, SLOT(on_verifyMessage_clicked())); connect(ui->tableView, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(contextualMenu(QPoint))); // Pass through accept action from button box connect(ui->buttonBox, SIGNAL(accepted()), this, SLOT(accept())); } AddressBookPage::~AddressBookPage() { delete ui; } void AddressBookPage::setModel(AddressTableModel *model) { this->model = model; if(!model) return; proxyModel = new QSortFilterProxyModel(this); proxyModel->setSourceModel(model); proxyModel->setDynamicSortFilter(true); proxyModel->setSortCaseSensitivity(Qt::CaseInsensitive); proxyModel->setFilterCaseSensitivity(Qt::CaseInsensitive); switch(tab) { case ReceivingTab: // Receive filter proxyModel->setFilterRole(AddressTableModel::TypeRole); proxyModel->setFilterFixedString(AddressTableModel::Receive); break; case SendingTab: // Send filter proxyModel->setFilterRole(AddressTableModel::TypeRole); proxyModel->setFilterFixedString(AddressTableModel::Send); break; } ui->tableView->setModel(proxyModel); ui->tableView->sortByColumn(0, Qt::AscendingOrder); // Set column widths #if QT_VERSION < 0x050000 ui->tableView->horizontalHeader()->setResizeMode(AddressTableModel::Label, QHeaderView::Stretch); ui->tableView->horizontalHeader()->setResizeMode(AddressTableModel::Address, QHeaderView::ResizeToContents); #else ui->tableView->horizontalHeader()->setSectionResizeMode(AddressTableModel::Label, QHeaderView::Stretch); ui->tableView->horizontalHeader()->setSectionResizeMode(AddressTableModel::Address, QHeaderView::ResizeToContents); #endif connect(ui->tableView->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), this, SLOT(selectionChanged())); // Select row for newly created address connect(model, SIGNAL(rowsInserted(QModelIndex,int,int)), this, SLOT(selectNewAddress(QModelIndex,int,int))); selectionChanged(); } void AddressBookPage::setOptionsModel(OptionsModel *optionsModel) { this->optionsModel = optionsModel; } void AddressBookPage::on_copyAddress_clicked() { GUIUtil::copyEntryData(ui->tableView, AddressTableModel::Address); } void AddressBookPage::onCopyLabelAction() { GUIUtil::copyEntryData(ui->tableView, AddressTableModel::Label); } void AddressBookPage::onEditAction() { if(!ui->tableView->selectionModel()) return; QModelIndexList indexes = ui->tableView->selectionModel()->selectedRows(); if(indexes.isEmpty()) return; EditAddressDialog dlg( tab == SendingTab ? EditAddressDialog::EditSendingAddress : EditAddressDialog::EditReceivingAddress); dlg.setModel(model); QModelIndex origIndex = proxyModel->mapToSource(indexes.at(0)); dlg.loadRow(origIndex.row()); dlg.exec(); } void AddressBookPage::on_signMessage_clicked() { QTableView *table = ui->tableView; QModelIndexList indexes = table->selectionModel()->selectedRows(AddressTableModel::Address); foreach (QModelIndex index, indexes) { QString address = index.data().toString(); emit signMessage(address); } } void AddressBookPage::on_verifyMessage_clicked() { QTableView *table = ui->tableView; QModelIndexList indexes = table->selectionModel()->selectedRows(AddressTableModel::Address); foreach (QModelIndex index, indexes) { QString address = index.data().toString(); emit verifyMessage(address); } } void AddressBookPage::onSendCoinsAction() { QTableView *table = ui->tableView; QModelIndexList indexes = table->selectionModel()->selectedRows(AddressTableModel::Address); foreach (QModelIndex index, indexes) { QString address = index.data().toString(); emit sendCoins(address); } } void AddressBookPage::on_newAddress_clicked() { if(!model) return; EditAddressDialog dlg( tab == SendingTab ? EditAddressDialog::NewSendingAddress : EditAddressDialog::NewReceivingAddress, this); dlg.setModel(model); if(dlg.exec()) { newAddressToSelect = dlg.getAddress(); } } void AddressBookPage::on_deleteAddress_clicked() { QTableView *table = ui->tableView; if(!table->selectionModel()) return; QModelIndexList indexes = table->selectionModel()->selectedRows(); if(!indexes.isEmpty()) { table->model()->removeRow(indexes.at(0).row()); } } void AddressBookPage::selectionChanged() { // Set button states based on selected tab and selection QTableView *table = ui->tableView; if(!table->selectionModel()) return; if(table->selectionModel()->hasSelection()) { switch(tab) { case SendingTab: // In sending tab, allow deletion of selection ui->deleteAddress->setEnabled(true); ui->deleteAddress->setVisible(true); deleteAction->setEnabled(true); ui->signMessage->setEnabled(false); ui->signMessage->setVisible(false); ui->verifyMessage->setEnabled(true); ui->verifyMessage->setVisible(true); break; case ReceivingTab: // Deleting receiving addresses, however, is not allowed ui->deleteAddress->setEnabled(false); ui->deleteAddress->setVisible(false); deleteAction->setEnabled(false); ui->signMessage->setEnabled(true); ui->signMessage->setVisible(true); ui->verifyMessage->setEnabled(false); ui->verifyMessage->setVisible(false); break; } ui->copyAddress->setEnabled(true); ui->showQRCode->setEnabled(true); } else { ui->deleteAddress->setEnabled(false); ui->showQRCode->setEnabled(false); ui->copyAddress->setEnabled(false); ui->signMessage->setEnabled(false); ui->verifyMessage->setEnabled(false); } } void AddressBookPage::done(int retval) { QTableView *table = ui->tableView; if(!table->selectionModel() || !table->model()) return; // When this is a tab/widget and not a model dialog, ignore "done" if(mode == ForEditing) return; // Figure out which address was selected, and return it QModelIndexList indexes = table->selectionModel()->selectedRows(AddressTableModel::Address); foreach (QModelIndex index, indexes) { QVariant address = table->model()->data(index); returnValue = address.toString(); } if(returnValue.isEmpty()) { // If no address entry selected, return rejected retval = Rejected; } QDialog::done(retval); } void AddressBookPage::on_exportButton_clicked() { // CSV is currently the only supported format QString filename = GUIUtil::getSaveFileName( this, tr("Export Address Book Data"), QString(), tr("Comma separated file (*.csv)")); if (filename.isNull()) return; CSVModelWriter writer(filename); // name, column, role writer.setModel(proxyModel); writer.addColumn("Label", AddressTableModel::Label, Qt::EditRole); writer.addColumn("Address", AddressTableModel::Address, Qt::EditRole); if(!writer.write()) { QMessageBox::critical(this, tr("Error exporting"), tr("Could not write to file %1.").arg(filename), QMessageBox::Abort, QMessageBox::Abort); } } void AddressBookPage::on_showQRCode_clicked() { #ifdef USE_QRCODE QTableView *table = ui->tableView; QModelIndexList indexes = table->selectionModel()->selectedRows(AddressTableModel::Address); foreach (QModelIndex index, indexes) { QString address = index.data().toString(); QString label = index.sibling(index.row(), 0).data(Qt::EditRole).toString(); QRCodeDialog *dialog = new QRCodeDialog(address, label, tab == ReceivingTab, this); dialog->setModel(optionsModel); dialog->setAttribute(Qt::WA_DeleteOnClose); dialog->show(); } #endif } void AddressBookPage::contextualMenu(const QPoint &point) { QModelIndex index = ui->tableView->indexAt(point); if(index.isValid()) { contextMenu->exec(QCursor::pos()); } } void AddressBookPage::selectNewAddress(const QModelIndex &parent, int begin, int /*end*/) { QModelIndex idx = proxyModel->mapFromSource(model->index(begin, AddressTableModel::Address, parent)); if(idx.isValid() && (idx.data(Qt::EditRole).toString() == newAddressToSelect)) { // Select row of newly created address, once ui->tableView->setFocus(); ui->tableView->selectRow(idx.row()); newAddressToSelect.clear(); } }
; A198954: Expansion of the rotational partition function for a heteronuclear diatomic molecule. ; 1,3,0,5,0,0,7,0,0,0,9,0,0,0,0,11,0,0,0,0,0,13,0,0,0,0,0,0,15,0,0,0,0,0,0,0,17,0,0,0,0,0,0,0,0,19,0,0,0,0,0,0,0,0,0,21,0,0,0,0,0,0,0,0,0,0,23,0,0,0,0,0,0,0,0,0,0,0,25,0,0,0,0,0,0,0,0,0,0,0,0,27,0,0,0,0,0,0,0,0,0,0,0,0,0,29,0,0,0,0,0,0,0,0,0,0,0,0,0,0,31,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,33,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,35,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,37,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,39,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,41,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,43,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 mul $0,2 mov $1,1 lpb $0 sub $0,1 add $1,2 mov $2,$0 trn $0,$1 lpe sub $2,1 lpb $0,2 trn $1,$2 lpe
addi x1 x0 1 addi x1 x0 1 addi x1 x0 1 addi x1 x0 1 addi x1 x0 1 addi x1 x0 1 addi x1 x0 1 addi x1 x0 1 addi x1 x0 1 addi x1 x0 1 addi x1 x0 1 addi x1 x0 1 addi x1 x0 1 addi x1 x0 1 addi x1 x0 1 addi x1 x0 1 jal x0 EXIT EXIT:
Route4_Object: db $2c ; border block def_warps warp 11, 5, 0, MT_MOON_POKECENTER warp 18, 5, 0, MT_MOON_1F warp 24, 5, 7, MT_MOON_B1F def_signs sign 12, 5, 4 ; PokeCenterSignText sign 17, 7, 5 ; Route4Text5 sign 27, 7, 6 ; Route4Text6 def_objects object SPRITE_COOLTRAINER_F, 9, 8, WALK, ANY_DIR, 1 ; person object SPRITE_COOLTRAINER_F, 63, 3, STAY, RIGHT, 2, OPP_LASS, 4 object SPRITE_POKE_BALL, 57, 3, STAY, NONE, 3, TM_WHIRLWIND def_warps_to ROUTE_4
_wait_one: file format elf32-i386 Disassembly of section .text: 00000000 <main>: #include "fcntl.h" #include "syscall.h" #include "traps.h" #include "memlayout.h" int main(int argc, char ** argv){ 0: 55 push %ebp 1: 89 e5 mov %esp,%ebp 3: 83 e4 f0 and $0xfffffff0,%esp 6: 83 ec 30 sub $0x30,%esp int begin = getpid(); 9: e8 c6 04 00 00 call 4d4 <getpid> e: 89 44 24 14 mov %eax,0x14(%esp) int pid = fork(); 12: e8 2d 04 00 00 call 444 <fork> 17: 89 44 24 18 mov %eax,0x18(%esp) int i; int status; if(pid > 0){ 1b: 83 7c 24 18 00 cmpl $0x0,0x18(%esp) 20: 0f 8e 4a 01 00 00 jle 170 <main+0x170> for(i = 0; i < 15 && pid > 0; i++){ 26: c7 44 24 1c 00 00 00 movl $0x0,0x1c(%esp) 2d: 00 2e: eb 29 jmp 59 <main+0x59> pid = fork(); 30: e8 0f 04 00 00 call 444 <fork> 35: 89 44 24 18 mov %eax,0x18(%esp) if(pid < 0) 39: 83 7c 24 18 00 cmpl $0x0,0x18(%esp) 3e: 79 14 jns 54 <main+0x54> printf(1,"errors occur!\n"); 40: c7 44 24 04 a4 09 00 movl $0x9a4,0x4(%esp) 47: 00 48: c7 04 24 01 00 00 00 movl $0x1,(%esp) 4f: e8 89 05 00 00 call 5dd <printf> int begin = getpid(); int pid = fork(); int i; int status; if(pid > 0){ for(i = 0; i < 15 && pid > 0; i++){ 54: 83 44 24 1c 01 addl $0x1,0x1c(%esp) 59: 83 7c 24 1c 0e cmpl $0xe,0x1c(%esp) 5e: 7f 07 jg 67 <main+0x67> 60: 83 7c 24 18 00 cmpl $0x0,0x18(%esp) 65: 7f c9 jg 30 <main+0x30> pid = fork(); if(pid < 0) printf(1,"errors occur!\n"); } if (pid == 0){ 67: 83 7c 24 18 00 cmpl $0x0,0x18(%esp) 6c: 0f 85 2d 01 00 00 jne 19f <main+0x19f> int j = 0; 72: c7 44 24 24 00 00 00 movl $0x0,0x24(%esp) 79: 00 while(j++ < 1000); 7a: 81 7c 24 24 e7 03 00 cmpl $0x3e7,0x24(%esp) 81: 00 82: 0f 9e c0 setle %al 85: 83 44 24 24 01 addl $0x1,0x24(%esp) 8a: 84 c0 test %al,%al 8c: 75 ec jne 7a <main+0x7a> if(getpid() == begin+5) sleep(30); 8e: e8 41 04 00 00 call 4d4 <getpid> 93: 8b 54 24 14 mov 0x14(%esp),%edx 97: 83 c2 05 add $0x5,%edx 9a: 39 d0 cmp %edx,%eax 9c: 75 0c jne aa <main+0xaa> 9e: c7 04 24 1e 00 00 00 movl $0x1e,(%esp) a5: e8 3a 04 00 00 call 4e4 <sleep> printf(1,"pid = %d\n",getpid()); aa: e8 25 04 00 00 call 4d4 <getpid> af: 89 44 24 08 mov %eax,0x8(%esp) b3: c7 44 24 04 b3 09 00 movl $0x9b3,0x4(%esp) ba: 00 bb: c7 04 24 01 00 00 00 movl $0x1,(%esp) c2: e8 16 05 00 00 call 5dd <printf> if(getpid() == begin+10){ c7: e8 08 04 00 00 call 4d4 <getpid> cc: 8b 54 24 14 mov 0x14(%esp),%edx d0: 83 c2 0a add $0xa,%edx d3: 39 d0 cmp %edx,%eax d5: 75 71 jne 148 <main+0x148> printf(1,"pid %d waiting for %d\n",begin+10,begin+5); d7: 8b 44 24 14 mov 0x14(%esp),%eax db: 8d 50 05 lea 0x5(%eax),%edx de: 8b 44 24 14 mov 0x14(%esp),%eax e2: 83 c0 0a add $0xa,%eax e5: 89 54 24 0c mov %edx,0xc(%esp) e9: 89 44 24 08 mov %eax,0x8(%esp) ed: c7 44 24 04 bd 09 00 movl $0x9bd,0x4(%esp) f4: 00 f5: c7 04 24 01 00 00 00 movl $0x1,(%esp) fc: e8 dc 04 00 00 call 5dd <printf> int wpid = waitpid(begin+5,&status,0); 101: 8b 44 24 14 mov 0x14(%esp),%eax 105: 8d 50 05 lea 0x5(%eax),%edx 108: c7 44 24 08 00 00 00 movl $0x0,0x8(%esp) 10f: 00 110: 8d 44 24 10 lea 0x10(%esp),%eax 114: 89 44 24 04 mov %eax,0x4(%esp) 118: 89 14 24 mov %edx,(%esp) 11b: e8 3c 03 00 00 call 45c <waitpid> 120: 89 44 24 28 mov %eax,0x28(%esp) printf(1,"success clean %d, status is %d\n",wpid,status); 124: 8b 44 24 10 mov 0x10(%esp),%eax 128: 89 44 24 0c mov %eax,0xc(%esp) 12c: 8b 44 24 28 mov 0x28(%esp),%eax 130: 89 44 24 08 mov %eax,0x8(%esp) 134: c7 44 24 04 d4 09 00 movl $0x9d4,0x4(%esp) 13b: 00 13c: c7 04 24 01 00 00 00 movl $0x1,(%esp) 143: e8 95 04 00 00 call 5dd <printf> } if(getpid() == begin+5){ 148: e8 87 03 00 00 call 4d4 <getpid> 14d: 8b 54 24 14 mov 0x14(%esp),%edx 151: 83 c2 05 add $0x5,%edx 154: 39 d0 cmp %edx,%eax 156: 75 0c jne 164 <main+0x164> exit(5); 158: c7 04 24 05 00 00 00 movl $0x5,(%esp) 15f: e8 e8 02 00 00 call 44c <exit> } exit(0); 164: c7 04 24 00 00 00 00 movl $0x0,(%esp) 16b: e8 dc 02 00 00 call 44c <exit> } }else if(pid == 0){ 170: 83 7c 24 18 00 cmpl $0x0,0x18(%esp) 175: 75 28 jne 19f <main+0x19f> int j = 0; 177: c7 44 24 2c 00 00 00 movl $0x0,0x2c(%esp) 17e: 00 while(j++ < 1000); 17f: 81 7c 24 2c e7 03 00 cmpl $0x3e7,0x2c(%esp) 186: 00 187: 0f 9e c0 setle %al 18a: 83 44 24 2c 01 addl $0x1,0x2c(%esp) 18f: 84 c0 test %al,%al 191: 75 ec jne 17f <main+0x17f> exit(0); 193: c7 04 24 00 00 00 00 movl $0x0,(%esp) 19a: e8 ad 02 00 00 call 44c <exit> } int going = 1; 19f: c7 44 24 20 01 00 00 movl $0x1,0x20(%esp) 1a6: 00 while(going >= 0){ 1a7: eb 2c jmp 1d5 <main+0x1d5> going = wait(&status); 1a9: 8d 44 24 10 lea 0x10(%esp),%eax 1ad: 89 04 24 mov %eax,(%esp) 1b0: e8 9f 02 00 00 call 454 <wait> 1b5: 89 44 24 20 mov %eax,0x20(%esp) printf(1,"kill %d\n",going); 1b9: 8b 44 24 20 mov 0x20(%esp),%eax 1bd: 89 44 24 08 mov %eax,0x8(%esp) 1c1: c7 44 24 04 f4 09 00 movl $0x9f4,0x4(%esp) 1c8: 00 1c9: c7 04 24 01 00 00 00 movl $0x1,(%esp) 1d0: e8 08 04 00 00 call 5dd <printf> int j = 0; while(j++ < 1000); exit(0); } int going = 1; while(going >= 0){ 1d5: 83 7c 24 20 00 cmpl $0x0,0x20(%esp) 1da: 79 cd jns 1a9 <main+0x1a9> going = wait(&status); printf(1,"kill %d\n",going); } exit(0); 1dc: c7 04 24 00 00 00 00 movl $0x0,(%esp) 1e3: e8 64 02 00 00 call 44c <exit> 000001e8 <stosb>: "cc"); } static inline void stosb(void *addr, int data, int cnt) { 1e8: 55 push %ebp 1e9: 89 e5 mov %esp,%ebp 1eb: 57 push %edi 1ec: 53 push %ebx asm volatile("cld; rep stosb" : 1ed: 8b 4d 08 mov 0x8(%ebp),%ecx 1f0: 8b 55 10 mov 0x10(%ebp),%edx 1f3: 8b 45 0c mov 0xc(%ebp),%eax 1f6: 89 cb mov %ecx,%ebx 1f8: 89 df mov %ebx,%edi 1fa: 89 d1 mov %edx,%ecx 1fc: fc cld 1fd: f3 aa rep stos %al,%es:(%edi) 1ff: 89 ca mov %ecx,%edx 201: 89 fb mov %edi,%ebx 203: 89 5d 08 mov %ebx,0x8(%ebp) 206: 89 55 10 mov %edx,0x10(%ebp) "=D" (addr), "=c" (cnt) : "0" (addr), "1" (cnt), "a" (data) : "memory", "cc"); } 209: 5b pop %ebx 20a: 5f pop %edi 20b: 5d pop %ebp 20c: c3 ret 0000020d <strcpy>: #include "user.h" #include "x86.h" char* strcpy(char *s, char *t) { 20d: 55 push %ebp 20e: 89 e5 mov %esp,%ebp 210: 83 ec 10 sub $0x10,%esp char *os; os = s; 213: 8b 45 08 mov 0x8(%ebp),%eax 216: 89 45 fc mov %eax,-0x4(%ebp) while((*s++ = *t++) != 0) 219: 8b 45 0c mov 0xc(%ebp),%eax 21c: 0f b6 10 movzbl (%eax),%edx 21f: 8b 45 08 mov 0x8(%ebp),%eax 222: 88 10 mov %dl,(%eax) 224: 8b 45 08 mov 0x8(%ebp),%eax 227: 0f b6 00 movzbl (%eax),%eax 22a: 84 c0 test %al,%al 22c: 0f 95 c0 setne %al 22f: 83 45 08 01 addl $0x1,0x8(%ebp) 233: 83 45 0c 01 addl $0x1,0xc(%ebp) 237: 84 c0 test %al,%al 239: 75 de jne 219 <strcpy+0xc> ; return os; 23b: 8b 45 fc mov -0x4(%ebp),%eax } 23e: c9 leave 23f: c3 ret 00000240 <strcmp>: int strcmp(const char *p, const char *q) { 240: 55 push %ebp 241: 89 e5 mov %esp,%ebp while(*p && *p == *q) 243: eb 08 jmp 24d <strcmp+0xd> p++, q++; 245: 83 45 08 01 addl $0x1,0x8(%ebp) 249: 83 45 0c 01 addl $0x1,0xc(%ebp) } int strcmp(const char *p, const char *q) { while(*p && *p == *q) 24d: 8b 45 08 mov 0x8(%ebp),%eax 250: 0f b6 00 movzbl (%eax),%eax 253: 84 c0 test %al,%al 255: 74 10 je 267 <strcmp+0x27> 257: 8b 45 08 mov 0x8(%ebp),%eax 25a: 0f b6 10 movzbl (%eax),%edx 25d: 8b 45 0c mov 0xc(%ebp),%eax 260: 0f b6 00 movzbl (%eax),%eax 263: 38 c2 cmp %al,%dl 265: 74 de je 245 <strcmp+0x5> p++, q++; return (uchar)*p - (uchar)*q; 267: 8b 45 08 mov 0x8(%ebp),%eax 26a: 0f b6 00 movzbl (%eax),%eax 26d: 0f b6 d0 movzbl %al,%edx 270: 8b 45 0c mov 0xc(%ebp),%eax 273: 0f b6 00 movzbl (%eax),%eax 276: 0f b6 c0 movzbl %al,%eax 279: 89 d1 mov %edx,%ecx 27b: 29 c1 sub %eax,%ecx 27d: 89 c8 mov %ecx,%eax } 27f: 5d pop %ebp 280: c3 ret 00000281 <strlen>: uint strlen(char *s) { 281: 55 push %ebp 282: 89 e5 mov %esp,%ebp 284: 83 ec 10 sub $0x10,%esp int n; for(n = 0; s[n]; n++) 287: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%ebp) 28e: eb 04 jmp 294 <strlen+0x13> 290: 83 45 fc 01 addl $0x1,-0x4(%ebp) 294: 8b 45 fc mov -0x4(%ebp),%eax 297: 03 45 08 add 0x8(%ebp),%eax 29a: 0f b6 00 movzbl (%eax),%eax 29d: 84 c0 test %al,%al 29f: 75 ef jne 290 <strlen+0xf> ; return n; 2a1: 8b 45 fc mov -0x4(%ebp),%eax } 2a4: c9 leave 2a5: c3 ret 000002a6 <memset>: void* memset(void *dst, int c, uint n) { 2a6: 55 push %ebp 2a7: 89 e5 mov %esp,%ebp 2a9: 83 ec 0c sub $0xc,%esp stosb(dst, c, n); 2ac: 8b 45 10 mov 0x10(%ebp),%eax 2af: 89 44 24 08 mov %eax,0x8(%esp) 2b3: 8b 45 0c mov 0xc(%ebp),%eax 2b6: 89 44 24 04 mov %eax,0x4(%esp) 2ba: 8b 45 08 mov 0x8(%ebp),%eax 2bd: 89 04 24 mov %eax,(%esp) 2c0: e8 23 ff ff ff call 1e8 <stosb> return dst; 2c5: 8b 45 08 mov 0x8(%ebp),%eax } 2c8: c9 leave 2c9: c3 ret 000002ca <strchr>: char* strchr(const char *s, char c) { 2ca: 55 push %ebp 2cb: 89 e5 mov %esp,%ebp 2cd: 83 ec 04 sub $0x4,%esp 2d0: 8b 45 0c mov 0xc(%ebp),%eax 2d3: 88 45 fc mov %al,-0x4(%ebp) for(; *s; s++) 2d6: eb 14 jmp 2ec <strchr+0x22> if(*s == c) 2d8: 8b 45 08 mov 0x8(%ebp),%eax 2db: 0f b6 00 movzbl (%eax),%eax 2de: 3a 45 fc cmp -0x4(%ebp),%al 2e1: 75 05 jne 2e8 <strchr+0x1e> return (char*)s; 2e3: 8b 45 08 mov 0x8(%ebp),%eax 2e6: eb 13 jmp 2fb <strchr+0x31> } char* strchr(const char *s, char c) { for(; *s; s++) 2e8: 83 45 08 01 addl $0x1,0x8(%ebp) 2ec: 8b 45 08 mov 0x8(%ebp),%eax 2ef: 0f b6 00 movzbl (%eax),%eax 2f2: 84 c0 test %al,%al 2f4: 75 e2 jne 2d8 <strchr+0xe> if(*s == c) return (char*)s; return 0; 2f6: b8 00 00 00 00 mov $0x0,%eax } 2fb: c9 leave 2fc: c3 ret 000002fd <gets>: char* gets(char *buf, int max) { 2fd: 55 push %ebp 2fe: 89 e5 mov %esp,%ebp 300: 83 ec 28 sub $0x28,%esp int i, cc; char c; for(i=0; i+1 < max; ){ 303: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp) 30a: eb 44 jmp 350 <gets+0x53> cc = read(0, &c, 1); 30c: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) 313: 00 314: 8d 45 ef lea -0x11(%ebp),%eax 317: 89 44 24 04 mov %eax,0x4(%esp) 31b: c7 04 24 00 00 00 00 movl $0x0,(%esp) 322: e8 45 01 00 00 call 46c <read> 327: 89 45 f4 mov %eax,-0xc(%ebp) if(cc < 1) 32a: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 32e: 7e 2d jle 35d <gets+0x60> break; buf[i++] = c; 330: 8b 45 f0 mov -0x10(%ebp),%eax 333: 03 45 08 add 0x8(%ebp),%eax 336: 0f b6 55 ef movzbl -0x11(%ebp),%edx 33a: 88 10 mov %dl,(%eax) 33c: 83 45 f0 01 addl $0x1,-0x10(%ebp) if(c == '\n' || c == '\r') 340: 0f b6 45 ef movzbl -0x11(%ebp),%eax 344: 3c 0a cmp $0xa,%al 346: 74 16 je 35e <gets+0x61> 348: 0f b6 45 ef movzbl -0x11(%ebp),%eax 34c: 3c 0d cmp $0xd,%al 34e: 74 0e je 35e <gets+0x61> gets(char *buf, int max) { int i, cc; char c; for(i=0; i+1 < max; ){ 350: 8b 45 f0 mov -0x10(%ebp),%eax 353: 83 c0 01 add $0x1,%eax 356: 3b 45 0c cmp 0xc(%ebp),%eax 359: 7c b1 jl 30c <gets+0xf> 35b: eb 01 jmp 35e <gets+0x61> cc = read(0, &c, 1); if(cc < 1) break; 35d: 90 nop buf[i++] = c; if(c == '\n' || c == '\r') break; } buf[i] = '\0'; 35e: 8b 45 f0 mov -0x10(%ebp),%eax 361: 03 45 08 add 0x8(%ebp),%eax 364: c6 00 00 movb $0x0,(%eax) return buf; 367: 8b 45 08 mov 0x8(%ebp),%eax } 36a: c9 leave 36b: c3 ret 0000036c <stat>: int stat(char *n, struct stat *st) { 36c: 55 push %ebp 36d: 89 e5 mov %esp,%ebp 36f: 83 ec 28 sub $0x28,%esp int fd; int r; fd = open(n, O_RDONLY); 372: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 379: 00 37a: 8b 45 08 mov 0x8(%ebp),%eax 37d: 89 04 24 mov %eax,(%esp) 380: e8 0f 01 00 00 call 494 <open> 385: 89 45 f0 mov %eax,-0x10(%ebp) if(fd < 0) 388: 83 7d f0 00 cmpl $0x0,-0x10(%ebp) 38c: 79 07 jns 395 <stat+0x29> return -1; 38e: b8 ff ff ff ff mov $0xffffffff,%eax 393: eb 23 jmp 3b8 <stat+0x4c> r = fstat(fd, st); 395: 8b 45 0c mov 0xc(%ebp),%eax 398: 89 44 24 04 mov %eax,0x4(%esp) 39c: 8b 45 f0 mov -0x10(%ebp),%eax 39f: 89 04 24 mov %eax,(%esp) 3a2: e8 05 01 00 00 call 4ac <fstat> 3a7: 89 45 f4 mov %eax,-0xc(%ebp) close(fd); 3aa: 8b 45 f0 mov -0x10(%ebp),%eax 3ad: 89 04 24 mov %eax,(%esp) 3b0: e8 c7 00 00 00 call 47c <close> return r; 3b5: 8b 45 f4 mov -0xc(%ebp),%eax } 3b8: c9 leave 3b9: c3 ret 000003ba <atoi>: int atoi(const char *s) { 3ba: 55 push %ebp 3bb: 89 e5 mov %esp,%ebp 3bd: 83 ec 10 sub $0x10,%esp int n; n = 0; 3c0: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%ebp) while('0' <= *s && *s <= '9') 3c7: eb 24 jmp 3ed <atoi+0x33> n = n*10 + *s++ - '0'; 3c9: 8b 55 fc mov -0x4(%ebp),%edx 3cc: 89 d0 mov %edx,%eax 3ce: c1 e0 02 shl $0x2,%eax 3d1: 01 d0 add %edx,%eax 3d3: 01 c0 add %eax,%eax 3d5: 89 c2 mov %eax,%edx 3d7: 8b 45 08 mov 0x8(%ebp),%eax 3da: 0f b6 00 movzbl (%eax),%eax 3dd: 0f be c0 movsbl %al,%eax 3e0: 8d 04 02 lea (%edx,%eax,1),%eax 3e3: 83 e8 30 sub $0x30,%eax 3e6: 89 45 fc mov %eax,-0x4(%ebp) 3e9: 83 45 08 01 addl $0x1,0x8(%ebp) atoi(const char *s) { int n; n = 0; while('0' <= *s && *s <= '9') 3ed: 8b 45 08 mov 0x8(%ebp),%eax 3f0: 0f b6 00 movzbl (%eax),%eax 3f3: 3c 2f cmp $0x2f,%al 3f5: 7e 0a jle 401 <atoi+0x47> 3f7: 8b 45 08 mov 0x8(%ebp),%eax 3fa: 0f b6 00 movzbl (%eax),%eax 3fd: 3c 39 cmp $0x39,%al 3ff: 7e c8 jle 3c9 <atoi+0xf> n = n*10 + *s++ - '0'; return n; 401: 8b 45 fc mov -0x4(%ebp),%eax } 404: c9 leave 405: c3 ret 00000406 <memmove>: void* memmove(void *vdst, void *vsrc, int n) { 406: 55 push %ebp 407: 89 e5 mov %esp,%ebp 409: 83 ec 10 sub $0x10,%esp char *dst, *src; dst = vdst; 40c: 8b 45 08 mov 0x8(%ebp),%eax 40f: 89 45 f8 mov %eax,-0x8(%ebp) src = vsrc; 412: 8b 45 0c mov 0xc(%ebp),%eax 415: 89 45 fc mov %eax,-0x4(%ebp) while(n-- > 0) 418: eb 13 jmp 42d <memmove+0x27> *dst++ = *src++; 41a: 8b 45 fc mov -0x4(%ebp),%eax 41d: 0f b6 10 movzbl (%eax),%edx 420: 8b 45 f8 mov -0x8(%ebp),%eax 423: 88 10 mov %dl,(%eax) 425: 83 45 f8 01 addl $0x1,-0x8(%ebp) 429: 83 45 fc 01 addl $0x1,-0x4(%ebp) { char *dst, *src; dst = vdst; src = vsrc; while(n-- > 0) 42d: 83 7d 10 00 cmpl $0x0,0x10(%ebp) 431: 0f 9f c0 setg %al 434: 83 6d 10 01 subl $0x1,0x10(%ebp) 438: 84 c0 test %al,%al 43a: 75 de jne 41a <memmove+0x14> *dst++ = *src++; return vdst; 43c: 8b 45 08 mov 0x8(%ebp),%eax } 43f: c9 leave 440: c3 ret 441: 90 nop 442: 90 nop 443: 90 nop 00000444 <fork>: name: \ movl $SYS_ ## name, %eax; \ int $T_SYSCALL; \ ret SYSCALL(fork) 444: b8 01 00 00 00 mov $0x1,%eax 449: cd 40 int $0x40 44b: c3 ret 0000044c <exit>: SYSCALL(exit) 44c: b8 02 00 00 00 mov $0x2,%eax 451: cd 40 int $0x40 453: c3 ret 00000454 <wait>: SYSCALL(wait) 454: b8 03 00 00 00 mov $0x3,%eax 459: cd 40 int $0x40 45b: c3 ret 0000045c <waitpid>: SYSCALL(waitpid) 45c: b8 17 00 00 00 mov $0x17,%eax 461: cd 40 int $0x40 463: c3 ret 00000464 <pipe>: SYSCALL(pipe) 464: b8 04 00 00 00 mov $0x4,%eax 469: cd 40 int $0x40 46b: c3 ret 0000046c <read>: SYSCALL(read) 46c: b8 05 00 00 00 mov $0x5,%eax 471: cd 40 int $0x40 473: c3 ret 00000474 <write>: SYSCALL(write) 474: b8 10 00 00 00 mov $0x10,%eax 479: cd 40 int $0x40 47b: c3 ret 0000047c <close>: SYSCALL(close) 47c: b8 15 00 00 00 mov $0x15,%eax 481: cd 40 int $0x40 483: c3 ret 00000484 <kill>: SYSCALL(kill) 484: b8 06 00 00 00 mov $0x6,%eax 489: cd 40 int $0x40 48b: c3 ret 0000048c <exec>: SYSCALL(exec) 48c: b8 07 00 00 00 mov $0x7,%eax 491: cd 40 int $0x40 493: c3 ret 00000494 <open>: SYSCALL(open) 494: b8 0f 00 00 00 mov $0xf,%eax 499: cd 40 int $0x40 49b: c3 ret 0000049c <mknod>: SYSCALL(mknod) 49c: b8 11 00 00 00 mov $0x11,%eax 4a1: cd 40 int $0x40 4a3: c3 ret 000004a4 <unlink>: SYSCALL(unlink) 4a4: b8 12 00 00 00 mov $0x12,%eax 4a9: cd 40 int $0x40 4ab: c3 ret 000004ac <fstat>: SYSCALL(fstat) 4ac: b8 08 00 00 00 mov $0x8,%eax 4b1: cd 40 int $0x40 4b3: c3 ret 000004b4 <link>: SYSCALL(link) 4b4: b8 13 00 00 00 mov $0x13,%eax 4b9: cd 40 int $0x40 4bb: c3 ret 000004bc <mkdir>: SYSCALL(mkdir) 4bc: b8 14 00 00 00 mov $0x14,%eax 4c1: cd 40 int $0x40 4c3: c3 ret 000004c4 <chdir>: SYSCALL(chdir) 4c4: b8 09 00 00 00 mov $0x9,%eax 4c9: cd 40 int $0x40 4cb: c3 ret 000004cc <dup>: SYSCALL(dup) 4cc: b8 0a 00 00 00 mov $0xa,%eax 4d1: cd 40 int $0x40 4d3: c3 ret 000004d4 <getpid>: SYSCALL(getpid) 4d4: b8 0b 00 00 00 mov $0xb,%eax 4d9: cd 40 int $0x40 4db: c3 ret 000004dc <sbrk>: SYSCALL(sbrk) 4dc: b8 0c 00 00 00 mov $0xc,%eax 4e1: cd 40 int $0x40 4e3: c3 ret 000004e4 <sleep>: SYSCALL(sleep) 4e4: b8 0d 00 00 00 mov $0xd,%eax 4e9: cd 40 int $0x40 4eb: c3 ret 000004ec <uptime>: SYSCALL(uptime) 4ec: b8 0e 00 00 00 mov $0xe,%eax 4f1: cd 40 int $0x40 4f3: c3 ret 000004f4 <count>: SYSCALL(count) 4f4: b8 16 00 00 00 mov $0x16,%eax 4f9: cd 40 int $0x40 4fb: c3 ret 000004fc <change_priority>: SYSCALL(change_priority) 4fc: b8 18 00 00 00 mov $0x18,%eax 501: cd 40 int $0x40 503: c3 ret 00000504 <putc>: #include "stat.h" #include "user.h" static void putc(int fd, char c) { 504: 55 push %ebp 505: 89 e5 mov %esp,%ebp 507: 83 ec 28 sub $0x28,%esp 50a: 8b 45 0c mov 0xc(%ebp),%eax 50d: 88 45 f4 mov %al,-0xc(%ebp) write(fd, &c, 1); 510: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) 517: 00 518: 8d 45 f4 lea -0xc(%ebp),%eax 51b: 89 44 24 04 mov %eax,0x4(%esp) 51f: 8b 45 08 mov 0x8(%ebp),%eax 522: 89 04 24 mov %eax,(%esp) 525: e8 4a ff ff ff call 474 <write> } 52a: c9 leave 52b: c3 ret 0000052c <printint>: static void printint(int fd, int xx, int base, int sgn) { 52c: 55 push %ebp 52d: 89 e5 mov %esp,%ebp 52f: 53 push %ebx 530: 83 ec 44 sub $0x44,%esp static char digits[] = "0123456789ABCDEF"; char buf[16]; int i, neg; uint x; neg = 0; 533: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp) if(sgn && xx < 0){ 53a: 83 7d 14 00 cmpl $0x0,0x14(%ebp) 53e: 74 17 je 557 <printint+0x2b> 540: 83 7d 0c 00 cmpl $0x0,0xc(%ebp) 544: 79 11 jns 557 <printint+0x2b> neg = 1; 546: c7 45 f0 01 00 00 00 movl $0x1,-0x10(%ebp) x = -xx; 54d: 8b 45 0c mov 0xc(%ebp),%eax 550: f7 d8 neg %eax 552: 89 45 f4 mov %eax,-0xc(%ebp) char buf[16]; int i, neg; uint x; neg = 0; if(sgn && xx < 0){ 555: eb 06 jmp 55d <printint+0x31> neg = 1; x = -xx; } else { x = xx; 557: 8b 45 0c mov 0xc(%ebp),%eax 55a: 89 45 f4 mov %eax,-0xc(%ebp) } i = 0; 55d: c7 45 ec 00 00 00 00 movl $0x0,-0x14(%ebp) do{ buf[i++] = digits[x % base]; 564: 8b 4d ec mov -0x14(%ebp),%ecx 567: 8b 5d 10 mov 0x10(%ebp),%ebx 56a: 8b 45 f4 mov -0xc(%ebp),%eax 56d: ba 00 00 00 00 mov $0x0,%edx 572: f7 f3 div %ebx 574: 89 d0 mov %edx,%eax 576: 0f b6 80 04 0a 00 00 movzbl 0xa04(%eax),%eax 57d: 88 44 0d dc mov %al,-0x24(%ebp,%ecx,1) 581: 83 45 ec 01 addl $0x1,-0x14(%ebp) }while((x /= base) != 0); 585: 8b 45 10 mov 0x10(%ebp),%eax 588: 89 45 d4 mov %eax,-0x2c(%ebp) 58b: 8b 45 f4 mov -0xc(%ebp),%eax 58e: ba 00 00 00 00 mov $0x0,%edx 593: f7 75 d4 divl -0x2c(%ebp) 596: 89 45 f4 mov %eax,-0xc(%ebp) 599: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 59d: 75 c5 jne 564 <printint+0x38> if(neg) 59f: 83 7d f0 00 cmpl $0x0,-0x10(%ebp) 5a3: 74 28 je 5cd <printint+0xa1> buf[i++] = '-'; 5a5: 8b 45 ec mov -0x14(%ebp),%eax 5a8: c6 44 05 dc 2d movb $0x2d,-0x24(%ebp,%eax,1) 5ad: 83 45 ec 01 addl $0x1,-0x14(%ebp) while(--i >= 0) 5b1: eb 1a jmp 5cd <printint+0xa1> putc(fd, buf[i]); 5b3: 8b 45 ec mov -0x14(%ebp),%eax 5b6: 0f b6 44 05 dc movzbl -0x24(%ebp,%eax,1),%eax 5bb: 0f be c0 movsbl %al,%eax 5be: 89 44 24 04 mov %eax,0x4(%esp) 5c2: 8b 45 08 mov 0x8(%ebp),%eax 5c5: 89 04 24 mov %eax,(%esp) 5c8: e8 37 ff ff ff call 504 <putc> buf[i++] = digits[x % base]; }while((x /= base) != 0); if(neg) buf[i++] = '-'; while(--i >= 0) 5cd: 83 6d ec 01 subl $0x1,-0x14(%ebp) 5d1: 83 7d ec 00 cmpl $0x0,-0x14(%ebp) 5d5: 79 dc jns 5b3 <printint+0x87> putc(fd, buf[i]); } 5d7: 83 c4 44 add $0x44,%esp 5da: 5b pop %ebx 5db: 5d pop %ebp 5dc: c3 ret 000005dd <printf>: // Print to the given fd. Only understands %d, %x, %p, %s. void printf(int fd, char *fmt, ...) { 5dd: 55 push %ebp 5de: 89 e5 mov %esp,%ebp 5e0: 83 ec 38 sub $0x38,%esp char *s; int c, i, state; uint *ap; state = 0; 5e3: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp) ap = (uint*)(void*)&fmt + 1; 5ea: 8d 45 0c lea 0xc(%ebp),%eax 5ed: 83 c0 04 add $0x4,%eax 5f0: 89 45 f4 mov %eax,-0xc(%ebp) for(i = 0; fmt[i]; i++){ 5f3: c7 45 ec 00 00 00 00 movl $0x0,-0x14(%ebp) 5fa: e9 7e 01 00 00 jmp 77d <printf+0x1a0> c = fmt[i] & 0xff; 5ff: 8b 55 0c mov 0xc(%ebp),%edx 602: 8b 45 ec mov -0x14(%ebp),%eax 605: 8d 04 02 lea (%edx,%eax,1),%eax 608: 0f b6 00 movzbl (%eax),%eax 60b: 0f be c0 movsbl %al,%eax 60e: 25 ff 00 00 00 and $0xff,%eax 613: 89 45 e8 mov %eax,-0x18(%ebp) if(state == 0){ 616: 83 7d f0 00 cmpl $0x0,-0x10(%ebp) 61a: 75 2c jne 648 <printf+0x6b> if(c == '%'){ 61c: 83 7d e8 25 cmpl $0x25,-0x18(%ebp) 620: 75 0c jne 62e <printf+0x51> state = '%'; 622: c7 45 f0 25 00 00 00 movl $0x25,-0x10(%ebp) 629: e9 4b 01 00 00 jmp 779 <printf+0x19c> } else { putc(fd, c); 62e: 8b 45 e8 mov -0x18(%ebp),%eax 631: 0f be c0 movsbl %al,%eax 634: 89 44 24 04 mov %eax,0x4(%esp) 638: 8b 45 08 mov 0x8(%ebp),%eax 63b: 89 04 24 mov %eax,(%esp) 63e: e8 c1 fe ff ff call 504 <putc> 643: e9 31 01 00 00 jmp 779 <printf+0x19c> } } else if(state == '%'){ 648: 83 7d f0 25 cmpl $0x25,-0x10(%ebp) 64c: 0f 85 27 01 00 00 jne 779 <printf+0x19c> if(c == 'd'){ 652: 83 7d e8 64 cmpl $0x64,-0x18(%ebp) 656: 75 2d jne 685 <printf+0xa8> printint(fd, *ap, 10, 1); 658: 8b 45 f4 mov -0xc(%ebp),%eax 65b: 8b 00 mov (%eax),%eax 65d: c7 44 24 0c 01 00 00 movl $0x1,0xc(%esp) 664: 00 665: c7 44 24 08 0a 00 00 movl $0xa,0x8(%esp) 66c: 00 66d: 89 44 24 04 mov %eax,0x4(%esp) 671: 8b 45 08 mov 0x8(%ebp),%eax 674: 89 04 24 mov %eax,(%esp) 677: e8 b0 fe ff ff call 52c <printint> ap++; 67c: 83 45 f4 04 addl $0x4,-0xc(%ebp) 680: e9 ed 00 00 00 jmp 772 <printf+0x195> } else if(c == 'x' || c == 'p'){ 685: 83 7d e8 78 cmpl $0x78,-0x18(%ebp) 689: 74 06 je 691 <printf+0xb4> 68b: 83 7d e8 70 cmpl $0x70,-0x18(%ebp) 68f: 75 2d jne 6be <printf+0xe1> printint(fd, *ap, 16, 0); 691: 8b 45 f4 mov -0xc(%ebp),%eax 694: 8b 00 mov (%eax),%eax 696: c7 44 24 0c 00 00 00 movl $0x0,0xc(%esp) 69d: 00 69e: c7 44 24 08 10 00 00 movl $0x10,0x8(%esp) 6a5: 00 6a6: 89 44 24 04 mov %eax,0x4(%esp) 6aa: 8b 45 08 mov 0x8(%ebp),%eax 6ad: 89 04 24 mov %eax,(%esp) 6b0: e8 77 fe ff ff call 52c <printint> ap++; 6b5: 83 45 f4 04 addl $0x4,-0xc(%ebp) } } else if(state == '%'){ if(c == 'd'){ printint(fd, *ap, 10, 1); ap++; } else if(c == 'x' || c == 'p'){ 6b9: e9 b4 00 00 00 jmp 772 <printf+0x195> printint(fd, *ap, 16, 0); ap++; } else if(c == 's'){ 6be: 83 7d e8 73 cmpl $0x73,-0x18(%ebp) 6c2: 75 46 jne 70a <printf+0x12d> s = (char*)*ap; 6c4: 8b 45 f4 mov -0xc(%ebp),%eax 6c7: 8b 00 mov (%eax),%eax 6c9: 89 45 e4 mov %eax,-0x1c(%ebp) ap++; 6cc: 83 45 f4 04 addl $0x4,-0xc(%ebp) if(s == 0) 6d0: 83 7d e4 00 cmpl $0x0,-0x1c(%ebp) 6d4: 75 27 jne 6fd <printf+0x120> s = "(null)"; 6d6: c7 45 e4 fd 09 00 00 movl $0x9fd,-0x1c(%ebp) while(*s != 0){ 6dd: eb 1f jmp 6fe <printf+0x121> putc(fd, *s); 6df: 8b 45 e4 mov -0x1c(%ebp),%eax 6e2: 0f b6 00 movzbl (%eax),%eax 6e5: 0f be c0 movsbl %al,%eax 6e8: 89 44 24 04 mov %eax,0x4(%esp) 6ec: 8b 45 08 mov 0x8(%ebp),%eax 6ef: 89 04 24 mov %eax,(%esp) 6f2: e8 0d fe ff ff call 504 <putc> s++; 6f7: 83 45 e4 01 addl $0x1,-0x1c(%ebp) 6fb: eb 01 jmp 6fe <printf+0x121> } else if(c == 's'){ s = (char*)*ap; ap++; if(s == 0) s = "(null)"; while(*s != 0){ 6fd: 90 nop 6fe: 8b 45 e4 mov -0x1c(%ebp),%eax 701: 0f b6 00 movzbl (%eax),%eax 704: 84 c0 test %al,%al 706: 75 d7 jne 6df <printf+0x102> 708: eb 68 jmp 772 <printf+0x195> putc(fd, *s); s++; } } else if(c == 'c'){ 70a: 83 7d e8 63 cmpl $0x63,-0x18(%ebp) 70e: 75 1d jne 72d <printf+0x150> putc(fd, *ap); 710: 8b 45 f4 mov -0xc(%ebp),%eax 713: 8b 00 mov (%eax),%eax 715: 0f be c0 movsbl %al,%eax 718: 89 44 24 04 mov %eax,0x4(%esp) 71c: 8b 45 08 mov 0x8(%ebp),%eax 71f: 89 04 24 mov %eax,(%esp) 722: e8 dd fd ff ff call 504 <putc> ap++; 727: 83 45 f4 04 addl $0x4,-0xc(%ebp) 72b: eb 45 jmp 772 <printf+0x195> } else if(c == '%'){ 72d: 83 7d e8 25 cmpl $0x25,-0x18(%ebp) 731: 75 17 jne 74a <printf+0x16d> putc(fd, c); 733: 8b 45 e8 mov -0x18(%ebp),%eax 736: 0f be c0 movsbl %al,%eax 739: 89 44 24 04 mov %eax,0x4(%esp) 73d: 8b 45 08 mov 0x8(%ebp),%eax 740: 89 04 24 mov %eax,(%esp) 743: e8 bc fd ff ff call 504 <putc> 748: eb 28 jmp 772 <printf+0x195> } else { // Unknown % sequence. Print it to draw attention. putc(fd, '%'); 74a: c7 44 24 04 25 00 00 movl $0x25,0x4(%esp) 751: 00 752: 8b 45 08 mov 0x8(%ebp),%eax 755: 89 04 24 mov %eax,(%esp) 758: e8 a7 fd ff ff call 504 <putc> putc(fd, c); 75d: 8b 45 e8 mov -0x18(%ebp),%eax 760: 0f be c0 movsbl %al,%eax 763: 89 44 24 04 mov %eax,0x4(%esp) 767: 8b 45 08 mov 0x8(%ebp),%eax 76a: 89 04 24 mov %eax,(%esp) 76d: e8 92 fd ff ff call 504 <putc> } state = 0; 772: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp) int c, i, state; uint *ap; state = 0; ap = (uint*)(void*)&fmt + 1; for(i = 0; fmt[i]; i++){ 779: 83 45 ec 01 addl $0x1,-0x14(%ebp) 77d: 8b 55 0c mov 0xc(%ebp),%edx 780: 8b 45 ec mov -0x14(%ebp),%eax 783: 8d 04 02 lea (%edx,%eax,1),%eax 786: 0f b6 00 movzbl (%eax),%eax 789: 84 c0 test %al,%al 78b: 0f 85 6e fe ff ff jne 5ff <printf+0x22> putc(fd, c); } state = 0; } } } 791: c9 leave 792: c3 ret 793: 90 nop 00000794 <free>: static Header base; static Header *freep; void free(void *ap) { 794: 55 push %ebp 795: 89 e5 mov %esp,%ebp 797: 83 ec 10 sub $0x10,%esp Header *bp, *p; bp = (Header*)ap - 1; 79a: 8b 45 08 mov 0x8(%ebp),%eax 79d: 83 e8 08 sub $0x8,%eax 7a0: 89 45 f8 mov %eax,-0x8(%ebp) for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 7a3: a1 20 0a 00 00 mov 0xa20,%eax 7a8: 89 45 fc mov %eax,-0x4(%ebp) 7ab: eb 24 jmp 7d1 <free+0x3d> if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) 7ad: 8b 45 fc mov -0x4(%ebp),%eax 7b0: 8b 00 mov (%eax),%eax 7b2: 3b 45 fc cmp -0x4(%ebp),%eax 7b5: 77 12 ja 7c9 <free+0x35> 7b7: 8b 45 f8 mov -0x8(%ebp),%eax 7ba: 3b 45 fc cmp -0x4(%ebp),%eax 7bd: 77 24 ja 7e3 <free+0x4f> 7bf: 8b 45 fc mov -0x4(%ebp),%eax 7c2: 8b 00 mov (%eax),%eax 7c4: 3b 45 f8 cmp -0x8(%ebp),%eax 7c7: 77 1a ja 7e3 <free+0x4f> free(void *ap) { Header *bp, *p; bp = (Header*)ap - 1; for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 7c9: 8b 45 fc mov -0x4(%ebp),%eax 7cc: 8b 00 mov (%eax),%eax 7ce: 89 45 fc mov %eax,-0x4(%ebp) 7d1: 8b 45 f8 mov -0x8(%ebp),%eax 7d4: 3b 45 fc cmp -0x4(%ebp),%eax 7d7: 76 d4 jbe 7ad <free+0x19> 7d9: 8b 45 fc mov -0x4(%ebp),%eax 7dc: 8b 00 mov (%eax),%eax 7de: 3b 45 f8 cmp -0x8(%ebp),%eax 7e1: 76 ca jbe 7ad <free+0x19> if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) break; if(bp + bp->s.size == p->s.ptr){ 7e3: 8b 45 f8 mov -0x8(%ebp),%eax 7e6: 8b 40 04 mov 0x4(%eax),%eax 7e9: c1 e0 03 shl $0x3,%eax 7ec: 89 c2 mov %eax,%edx 7ee: 03 55 f8 add -0x8(%ebp),%edx 7f1: 8b 45 fc mov -0x4(%ebp),%eax 7f4: 8b 00 mov (%eax),%eax 7f6: 39 c2 cmp %eax,%edx 7f8: 75 24 jne 81e <free+0x8a> bp->s.size += p->s.ptr->s.size; 7fa: 8b 45 f8 mov -0x8(%ebp),%eax 7fd: 8b 50 04 mov 0x4(%eax),%edx 800: 8b 45 fc mov -0x4(%ebp),%eax 803: 8b 00 mov (%eax),%eax 805: 8b 40 04 mov 0x4(%eax),%eax 808: 01 c2 add %eax,%edx 80a: 8b 45 f8 mov -0x8(%ebp),%eax 80d: 89 50 04 mov %edx,0x4(%eax) bp->s.ptr = p->s.ptr->s.ptr; 810: 8b 45 fc mov -0x4(%ebp),%eax 813: 8b 00 mov (%eax),%eax 815: 8b 10 mov (%eax),%edx 817: 8b 45 f8 mov -0x8(%ebp),%eax 81a: 89 10 mov %edx,(%eax) 81c: eb 0a jmp 828 <free+0x94> } else bp->s.ptr = p->s.ptr; 81e: 8b 45 fc mov -0x4(%ebp),%eax 821: 8b 10 mov (%eax),%edx 823: 8b 45 f8 mov -0x8(%ebp),%eax 826: 89 10 mov %edx,(%eax) if(p + p->s.size == bp){ 828: 8b 45 fc mov -0x4(%ebp),%eax 82b: 8b 40 04 mov 0x4(%eax),%eax 82e: c1 e0 03 shl $0x3,%eax 831: 03 45 fc add -0x4(%ebp),%eax 834: 3b 45 f8 cmp -0x8(%ebp),%eax 837: 75 20 jne 859 <free+0xc5> p->s.size += bp->s.size; 839: 8b 45 fc mov -0x4(%ebp),%eax 83c: 8b 50 04 mov 0x4(%eax),%edx 83f: 8b 45 f8 mov -0x8(%ebp),%eax 842: 8b 40 04 mov 0x4(%eax),%eax 845: 01 c2 add %eax,%edx 847: 8b 45 fc mov -0x4(%ebp),%eax 84a: 89 50 04 mov %edx,0x4(%eax) p->s.ptr = bp->s.ptr; 84d: 8b 45 f8 mov -0x8(%ebp),%eax 850: 8b 10 mov (%eax),%edx 852: 8b 45 fc mov -0x4(%ebp),%eax 855: 89 10 mov %edx,(%eax) 857: eb 08 jmp 861 <free+0xcd> } else p->s.ptr = bp; 859: 8b 45 fc mov -0x4(%ebp),%eax 85c: 8b 55 f8 mov -0x8(%ebp),%edx 85f: 89 10 mov %edx,(%eax) freep = p; 861: 8b 45 fc mov -0x4(%ebp),%eax 864: a3 20 0a 00 00 mov %eax,0xa20 } 869: c9 leave 86a: c3 ret 0000086b <morecore>: static Header* morecore(uint nu) { 86b: 55 push %ebp 86c: 89 e5 mov %esp,%ebp 86e: 83 ec 28 sub $0x28,%esp char *p; Header *hp; if(nu < 4096) 871: 81 7d 08 ff 0f 00 00 cmpl $0xfff,0x8(%ebp) 878: 77 07 ja 881 <morecore+0x16> nu = 4096; 87a: c7 45 08 00 10 00 00 movl $0x1000,0x8(%ebp) p = sbrk(nu * sizeof(Header)); 881: 8b 45 08 mov 0x8(%ebp),%eax 884: c1 e0 03 shl $0x3,%eax 887: 89 04 24 mov %eax,(%esp) 88a: e8 4d fc ff ff call 4dc <sbrk> 88f: 89 45 f0 mov %eax,-0x10(%ebp) if(p == (char*)-1) 892: 83 7d f0 ff cmpl $0xffffffff,-0x10(%ebp) 896: 75 07 jne 89f <morecore+0x34> return 0; 898: b8 00 00 00 00 mov $0x0,%eax 89d: eb 22 jmp 8c1 <morecore+0x56> hp = (Header*)p; 89f: 8b 45 f0 mov -0x10(%ebp),%eax 8a2: 89 45 f4 mov %eax,-0xc(%ebp) hp->s.size = nu; 8a5: 8b 45 f4 mov -0xc(%ebp),%eax 8a8: 8b 55 08 mov 0x8(%ebp),%edx 8ab: 89 50 04 mov %edx,0x4(%eax) free((void*)(hp + 1)); 8ae: 8b 45 f4 mov -0xc(%ebp),%eax 8b1: 83 c0 08 add $0x8,%eax 8b4: 89 04 24 mov %eax,(%esp) 8b7: e8 d8 fe ff ff call 794 <free> return freep; 8bc: a1 20 0a 00 00 mov 0xa20,%eax } 8c1: c9 leave 8c2: c3 ret 000008c3 <malloc>: void* malloc(uint nbytes) { 8c3: 55 push %ebp 8c4: 89 e5 mov %esp,%ebp 8c6: 83 ec 28 sub $0x28,%esp Header *p, *prevp; uint nunits; nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; 8c9: 8b 45 08 mov 0x8(%ebp),%eax 8cc: 83 c0 07 add $0x7,%eax 8cf: c1 e8 03 shr $0x3,%eax 8d2: 83 c0 01 add $0x1,%eax 8d5: 89 45 f4 mov %eax,-0xc(%ebp) if((prevp = freep) == 0){ 8d8: a1 20 0a 00 00 mov 0xa20,%eax 8dd: 89 45 f0 mov %eax,-0x10(%ebp) 8e0: 83 7d f0 00 cmpl $0x0,-0x10(%ebp) 8e4: 75 23 jne 909 <malloc+0x46> base.s.ptr = freep = prevp = &base; 8e6: c7 45 f0 18 0a 00 00 movl $0xa18,-0x10(%ebp) 8ed: 8b 45 f0 mov -0x10(%ebp),%eax 8f0: a3 20 0a 00 00 mov %eax,0xa20 8f5: a1 20 0a 00 00 mov 0xa20,%eax 8fa: a3 18 0a 00 00 mov %eax,0xa18 base.s.size = 0; 8ff: c7 05 1c 0a 00 00 00 movl $0x0,0xa1c 906: 00 00 00 } for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ 909: 8b 45 f0 mov -0x10(%ebp),%eax 90c: 8b 00 mov (%eax),%eax 90e: 89 45 ec mov %eax,-0x14(%ebp) if(p->s.size >= nunits){ 911: 8b 45 ec mov -0x14(%ebp),%eax 914: 8b 40 04 mov 0x4(%eax),%eax 917: 3b 45 f4 cmp -0xc(%ebp),%eax 91a: 72 4d jb 969 <malloc+0xa6> if(p->s.size == nunits) 91c: 8b 45 ec mov -0x14(%ebp),%eax 91f: 8b 40 04 mov 0x4(%eax),%eax 922: 3b 45 f4 cmp -0xc(%ebp),%eax 925: 75 0c jne 933 <malloc+0x70> prevp->s.ptr = p->s.ptr; 927: 8b 45 ec mov -0x14(%ebp),%eax 92a: 8b 10 mov (%eax),%edx 92c: 8b 45 f0 mov -0x10(%ebp),%eax 92f: 89 10 mov %edx,(%eax) 931: eb 26 jmp 959 <malloc+0x96> else { p->s.size -= nunits; 933: 8b 45 ec mov -0x14(%ebp),%eax 936: 8b 40 04 mov 0x4(%eax),%eax 939: 89 c2 mov %eax,%edx 93b: 2b 55 f4 sub -0xc(%ebp),%edx 93e: 8b 45 ec mov -0x14(%ebp),%eax 941: 89 50 04 mov %edx,0x4(%eax) p += p->s.size; 944: 8b 45 ec mov -0x14(%ebp),%eax 947: 8b 40 04 mov 0x4(%eax),%eax 94a: c1 e0 03 shl $0x3,%eax 94d: 01 45 ec add %eax,-0x14(%ebp) p->s.size = nunits; 950: 8b 45 ec mov -0x14(%ebp),%eax 953: 8b 55 f4 mov -0xc(%ebp),%edx 956: 89 50 04 mov %edx,0x4(%eax) } freep = prevp; 959: 8b 45 f0 mov -0x10(%ebp),%eax 95c: a3 20 0a 00 00 mov %eax,0xa20 return (void*)(p + 1); 961: 8b 45 ec mov -0x14(%ebp),%eax 964: 83 c0 08 add $0x8,%eax 967: eb 38 jmp 9a1 <malloc+0xde> } if(p == freep) 969: a1 20 0a 00 00 mov 0xa20,%eax 96e: 39 45 ec cmp %eax,-0x14(%ebp) 971: 75 1b jne 98e <malloc+0xcb> if((p = morecore(nunits)) == 0) 973: 8b 45 f4 mov -0xc(%ebp),%eax 976: 89 04 24 mov %eax,(%esp) 979: e8 ed fe ff ff call 86b <morecore> 97e: 89 45 ec mov %eax,-0x14(%ebp) 981: 83 7d ec 00 cmpl $0x0,-0x14(%ebp) 985: 75 07 jne 98e <malloc+0xcb> return 0; 987: b8 00 00 00 00 mov $0x0,%eax 98c: eb 13 jmp 9a1 <malloc+0xde> nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; if((prevp = freep) == 0){ base.s.ptr = freep = prevp = &base; base.s.size = 0; } for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ 98e: 8b 45 ec mov -0x14(%ebp),%eax 991: 89 45 f0 mov %eax,-0x10(%ebp) 994: 8b 45 ec mov -0x14(%ebp),%eax 997: 8b 00 mov (%eax),%eax 999: 89 45 ec mov %eax,-0x14(%ebp) return (void*)(p + 1); } if(p == freep) if((p = morecore(nunits)) == 0) return 0; } 99c: e9 70 ff ff ff jmp 911 <malloc+0x4e> } 9a1: c9 leave 9a2: c3 ret
#include <nuschl/util/primitives_impl.hpp> #include <algorithm> namespace nuschl::primitive_impl { argument_checker operator&&(const argument_checker &a, const argument_checker &b) { return argument_checker( checker_function([a, b](const std::vector<nuschl::s_exp_ptr> &args) { a(args); b(args); })); } argument_checker all_numbers() { return argument_checker([](const std::vector<s_exp_ptr> &args) -> void { if (std::all_of(args.begin(), args.end(), [](s_exp_ptr e) { return e->is_atom() && e->get_atom()->is_number(); })) { return; } throw eval_argument_error("expects only numbers as arguments."); }); } argument_checker exact_n_args(size_t n) { return argument_checker([n](const std::vector<s_exp_ptr> &args) { if (args.size() == n) return; std::string error_msg = "expects exactly " + std::to_string(n) + " arguments, got " + std::to_string(args.size()) + "."; throw eval_argument_error(error_msg.c_str()); }); } argument_checker least_n_args(size_t n) { return argument_checker([n](const std::vector<s_exp_ptr> &args) { if (args.size() >= n) return; std::string error_msg = "expects at least " + std::to_string(n) + " arguments, got " + std::to_string(args.size()) + "."; throw eval_argument_error(error_msg.c_str()); }); } argument_checker is_list() { return argument_checker([](const std::vector<s_exp_ptr> &args) -> void { exact_n_args(1)(args); if (args[0]->is_cell()) { return; } throw eval_argument_error("expects a list as argument."); }); } }
.MODEL SMALL .STACK 100H .CODE MAIN PROC MOV AH, 01H INT 21H MOV BL, AL MOV AH, 02H MOV DL, 0AH INT 21H MOV DL, 0DH INT 21H MOV DL, BL MOV AH, 02H INT 21H MOV AH, 4CH INT 21H MAIN ENDP END MAIN
; A131119: a(n) = (-1)^n * Sum_{i=1..floor(n/2)} i * floor(n/(n-i)). ; 0,0,2,-1,5,-3,9,-6,14,-10,20,-15,27,-21,35,-28,44,-36,54,-45,65,-55,77,-66,90,-78,104,-91,119,-105,135,-120,152,-136,170,-153,189,-171,209,-190,230,-210,252,-231,275,-253,299,-276,324,-300,350,-325,377,-351,405 lpb $0 mov $2,$0 sub $0,2 seq $2,130472 ; A permutation of the integers: a(n) = (-1)^n * floor( (n+1)/2 ). add $1,$2 add $1,1 lpe mov $0,$1
// This file is part of www.nand2tetris.org // and the book "The Elements of Computing Systems" // by Nisan and Schocken, MIT Press. // File name: projects/04/Fill.asm // Runs an infinite loop that listens to the keyboard input. // When a key is pressed (any key), the program blackens the screen, // i.e. writes "black" in every pixel. When no key is pressed, the // program clears the screen, i.e. writes "white" in every pixel. @8191 D=A @lastScreenAddress M=D // lastScreenAddress = 8191 @i M=D // i = lastScreenAddress (starts backwards) @SCREEN D=A @screenAddress M=D // screenAddress = @SCREEN @color M=0 // Color to fill (0 or -1) @pointer M=0 // Generic pointer (LOOP_FILL) @i D=M @RESET D;JLT // if i < 0 goto RESET @screenAddress D=M+D // D = @SCREEN + @i @pointer M=D // Saves the current screen address @KBD D=M @SET_COLOR_WHITE D;JLE // if @KBD <= 0 goto SET_COLOR_WHITE @SET_COLOR_BLACK D;JGT // if @KBD > 0 goto SET_COLOR_BLACK (CONTINUE) @color D=M @pointer A=M // A = @SCREEN + @i M=D // M = @color @i M=M-1 @LOOP_FILL 0;JMP (RESET) @lastScreenAddress D=M @i M=D // i = lastScreenAddress @LOOP_FILL 0;JMP (SET_COLOR_WHITE) @color M=0 @CONTINUE 0;JMP (SET_COLOR_BLACK) @color M=-1 @CONTINUE 0;JMP
ENDIF End
/*************************************************************** 网易17年校招:地牢逃脱(广搜) 给定一个n行m列的地牢,其中'.'表示可以通行的位置,'X'表示不可通行的障碍,牛牛从(x0,y0)位置出发, 遍历这个地牢,和一般的游戏所不同的是,他每一步只能按照一些指定的步长遍历地牢, 要求每一步都不可以超过地牢的边界,也不能到达障碍上。地牢的出口可能在任意某个可以通行的位置上。 牛牛想知道最坏情况下,他需要多少步才可以离开这个地牢。 - 输入描述: 每个输入包含1个测试用例。 每个测试用例的第一行包含两个整数n和m(1 <= n, m <= 50),表示地牢的长和宽。 接下来的n行,每行m个字符,描述地牢,地牢将至少包含两个'.'。 接下来的一行,包含两个整数x0, y0,表示牛牛的出发位置(0<=x0<n, 0<=y0<m,左上角的坐标为(0, 0),出发位置一定是'.')。 之后的一行包含一个整数k(0<k<=50)表示牛牛合法的步长数, 接下来的k行,每行两个整数dx, dy表示每次可选择移动的行和列步长(-50<=dx, dy<=50) - 输出描述: 输出一行一个数字表示最坏情况下需要多少次移动可以离开地牢,如果永远无法离开,输出-1。 以下测试用例中,牛牛可以上下左右移动。 在所有可通行的位置.上,地牢出口如果被设置在右下角,牛牛想离开需要移动的次数最多,为3次。 输入: 3 3 ... ... ... 0 1 4 1 0 0 1 -1 0 0 -1 输出: 3 ****************************************************************/ /* 我能想到广搜,觉得答案应该是牛牛能到达的最远点(最坏情况是这个最远点到不了)所需的最少步数, 但是想不到用怎样的数据结构防止走回头路(剪枝)。。。 所以看别人的思路,我想不到的数据结构也就是关键,即下面代码中的steps,存储的是: 从起始点出发,到达[i][j]这个点所需要的最少步数为steps[i][j]。 */ #include<iostream> #include<vector> #include<algorithm> #include<queue> #include<limits.h> using namespace std; int main(){ int n,m; cin>>n>>m; vector<vector<char>> maze(n, vector<char>(m)); for (int i=0;i<n;i++){ for (int j=0;j<m;j++){ cin>>maze[i][j]; } } // 起始点坐标 pair<int,int> start_node = {0,0}; cin>>start_node.first>>start_node.second; // 可以走的方向,就是类似常规广搜的四个方向,只是现在是d_cnt种方向 int d_cnt = 0; cin>>d_cnt; vector<pair<int,int>> next_diff(d_cnt); for (int i=0;i<d_cnt;i++){ cin>>next_diff[i].first>>next_diff[i].second; } queue<pair<int,int>> q; vector<vector<int>> steps(n,vector<int>(m, INT_MAX));//初始化为所需步数为无限大 steps[start_node.first][start_node.second] = 0; //起始点所需步数为0 q.push(start_node); while(!q.empty()){ pair<int,int> cur_node = q.front(); q.pop(); pair<int,int> next_node; for (int i=0;i<d_cnt;i++){ next_node.first = cur_node.first + next_diff[i].first; next_node.second = cur_node.second + next_diff[i].second; // 如果下一个点有效 if (next_node.first>=0 && next_node.first<n && next_node.second>=0 && next_node.second<m && maze[next_node.first][next_node.second]=='.'){ // 如果从当前点到达下一个点所需步数比下一个点已记录的所需步数要少, // 则更新下一个点的所需步数,并将下一个点推入队列 if (steps[next_node.first][next_node.second] >steps[cur_node.first][cur_node.second]+1){ steps[next_node.first][next_node.second] = steps[cur_node.first][cur_node.second]+1; q.push(next_node); } } } } int res = 0; for (int i=0;i<n;i++){ for (int j=0;j<m;j++){ // 遍历所有的可达点.的位置所需的最少步数,求出最大的那个(即最远点,即最坏情况) if (maze[i][j]=='.') res = max(res, steps[i][j]); } } // 如果到达最远点(最坏情况)所需步数是无限大,即最坏情况下无法逃脱,更新res为-1 res = res==INT_MAX?-1:res; cout<<res<<endl; return 0; }
; A326395: Expansion of Sum_{k>=1} x^(2*k) * (1 + x^k) / (1 - x^(3*k)). ; 0,1,1,1,1,3,0,2,2,2,1,4,0,2,3,2,1,5,0,3,2,2,1,6,1,2,3,2,1,6,0,3,3,2,2,7,0,2,2,4,1,6,0,3,5,2,1,7,0,3,3,2,1,7,2,4,2,2,1,9,0,2,4,3,2,6,0,3,3,4,1,10,0,2,4,2,2,6,0,5,4,2,1,8,2,2,3,4,1,10,0,3,2,2,2,9,0,3,5,4 add $0,1 mov $2,$0 lpb $0 mov $3,$2 mov $4,$0 cmp $4,0 add $0,$4 dif $3,$0 cmp $3,$2 cmp $3,0 lpb $3 mul $3,$0 add $3,2 mod $3,3 lpe sub $0,1 add $1,$3 lpe mov $0,$1
;; These are the colour values available on ZX Spectrum, if you for example want ;; to have green ink on red paper you can just use (INK_GREEN+PAPER_RED) as the ;; value and store it to the corresponding screen memory address. (which you can ;; get by calling FindColor routine later on) BLACK equ %00000000 BLUE equ %00000001 RED equ %00000010 MAGENTA equ %00000011 GREEN equ %00000100 CYAN equ %00000101 YELLOW equ %00000110 WHITE equ %00000111 INK_BLACK equ %00000000 INK_BLUE equ %00000001 INK_RED equ %00000010 INK_MAGENTA equ %00000011 INK_GREEN equ %00000100 INK_CYAN equ %00000101 INK_YELLOW equ %00000110 INK_WHITE equ %00000111 PAPER_BLACK equ %00000000 PAPER_BLUE equ %00001000 PAPER_RED equ %00010000 PAPER_MAGENTA equ %00011000 PAPER_GREEN equ %00100000 PAPER_CYAN equ %00101000 PAPER_YELLOW equ %00110000 PAPER_WHITE equ %00111000 BRIGHT equ %01000000 FLASH equ %10000000 ;; This is a modifyable PixelAddress pointer, it must be a multiply of 256 ;; for performance and contain 6144 bytes of free memory. The default value is ;; $4000 but for shadow screen one might want to set it to $c000 instead, other ;; values are probably not very useful. PixelAddress dw $4000 ;; This is a modifyable ColorAddress pointer, it must be a multiple of 256 for ;; performance and contain 768 bytes of free memory. The default value is $4000 ;; but for shadow screen one might want to set it to $d800 instead, other values ;; are useful for different kind of backbuffers. ColorAddress dw $5800 ;; This is a modifyable CharAddress pointer, it can be anything but must point ;; to a memory address with 1024 bytes of 8x8 character data. The first 256 ;; bytes are invisible and never used, it can also point to 2048 bytes of ;; character data for example to add full latin1 character support. CharAddress dw $3c00 ;; This is a modifyable RandomSeed variable, it contains a 12-bit value where ;; upper 4 bits define the used 256-byte sequence and lower 8 bits define the ;; current position in the sequence. RandomSeed dw $0000 org (($+8) & $FFF8) ; Aligned to closest 8 bytes BitMasks db $80,$40,$20,$10,$08,$04,$02,$01 ByteMasks db $ff,$7f,$3f,$1f,$0f,$07,$03,$01 ;; ClearScreen routine using SP for faster memory access. ;; input: ;; PixelAddress - the used pixel start address ;; destroys: ;; hl, de, b, flags ClearScreen ld hl,(PixelAddress) ld de,$1800 add hl,de ld (CS_End+1),sp ld sp,hl ld de,$0000 ld b,0 CS_Loop rept 12 push de endm djnz CS_Loop CS_End ld sp,$0000 ret ;; FindRow routine for finding a row start address. ;; input: ;; PixelAddress - the used pixel start address ;; b - Y coordinate (0-191) ;; output: ;; hl - pointer to the pixel address ;; destroys: ;; a, flags FindRow ld hl,(PixelAddress) ld a,b and %00000111 add a,h ld h,a ld a,b and %11000000 rra rra rra add a,h ld h,a ld a,b and %00111000 rla rla ld l,a ret ;; NextRow routine for finding the next row address. ;; input: ;; hl - current pixel address ;; output: ;; hl - next row pixel address ;; destroys: ;; a, flags NextRow inc h ld a,h and 7 ret nz ld a,l add a,32 ld l,a ret c ld a,h sub 8 ld h,a ret ;; LastRow routine for finding the last row address. ;; input: ;; hl - current pixel address ;; output: ;; hl - next row pixel address ;; destroys: ;; a, flags LastRow dec h ld a,h and 7 cp 7 ret nz ld a,l sub 32 ld l,a ret c ld a,h add a,8 ld h,a ret ;; FindPixel routine for finding a pixel address and mask. ;; input: ;; PixelAddress - the used pixel start address ;; b - Y coordinate (0-191) ;; c - X coordinate (0-255) ;; output: ;; hl - pointer to the pixel address ;; a - bitmask for the pixel address ;; destroys: ;; de, flags FindPixel call FindRow ld a,c and %11111000 rra rra rra or l ld l,a ld de,BitMasks ld a,c and %00000111 or e ld e,a ld a,(de) ret ;; GetPixel routine for getting a pixel from screen. ;; input: ;; PixelAddress - the used pixel start address ;; b - Y coordinate (0-191) ;; c - X coordinate (0-255) ;; output: ;; a - pixel value ;; flags - zero flag set if pixel was zero ;; destroys: ;; hl, de GetPixel call FindPixel and (hl) ret ;; SetPixel routine for setting a pixel on screen. ;; input: ;; PixelAddress - the used pixel start address ;; b - Y coordinate (0-191) ;; c - X coordinate (0-255) ;; destroys: ;; hl, de, a, flags SetPixel call FindPixel or (hl) ld (hl),a ret ;; ClearPixel routine for clearing a pixel on screen. ;; input: ;; PixelAddress - the used pixel start address ;; b - Y coordinate (0-191) ;; c - X coordinate (0-255) ;; destroys: ;; hl, de, a, flags ClearPixel call FindPixel cpl and (hl) ld (hl),a ret ;; FindColor routine for finding a color memory address. ;; input: ;; ColorAddress - the used color start address ;; b - Y coordinate (0-23) ;; c - X coordinate (0-31) ;; output: ;; hl - pointer to the color address ;; destroys: ;; flags FindColor ld hl,(ColorAddress) ld a,b and %00011000 rrca rrca rrca add a,h ld h,a ld a,b and %00000111 rrca rrca rrca ld l,a ld a,c and %00011111 or l ld l,a ret ;; PutBlock routine for plotting a 8x8 block on screen. ;; input: ;; PixelAddress - the used pixel start address ;; hl - pointer to 8 bytes of block data ;; b - Y coordinate (0-23) ;; c - X coordinate (0-31) ;; destroys: ;; de, a, flags PutBlock push bc ex de,hl ld a,b rlca rlca rlca ld b,a call FindRow ld a,c add a,l ld l,a ld b,8 PB_Loop ld a,(de) ld (hl),a inc de inc h djnz PB_Loop pop bc ret ;; FindChar routine for finding a character block. ;; input: ;; CharAddress - the used charset font ;; a - character code ;; output: ;; hl - pointer to character block ;; destroys: ;; a, flags FindChar push de ld hl,(CharAddress) ld d,0 rept 3 rla rl d endm ld e,a add hl,de pop de ret ;; PutChar routine for plotting a character on screen. ;; input: ;; PixelAddress - the used pixel start address ;; CharAddress - the used charset font ;; b - Y coordinate (0-23) ;; c - X coordinate (0-31) ;; a - character code ;; destroys: ;; a, flags PutChar push hl call FindChar call PutBlock pop hl ret ;; PutString routine for plotting a string on screen. ;; input: ;; PixelAddress - the used pixel start address ;; CharAddress - the used charset font ;; hl - pointer to the string ;; b - Y coordinate (0-23) ;; c - X coordinate (0-31) ;; destroys: ;; de, a, flags PutString push hl push bc PS_Loop ld a,c cp 32 jr nc,PS_Exit ld a,(hl) or a jr z,PS_Exit call PutChar inc hl inc c jr PS_Loop PS_Exit pop bc pop hl ret ;; RandomByte routine for getting a random number in the range [0,255]. The ;; produced random numbers loop every 256 times unless the seed is changed. ;; See: http://codebase64.org/doku.php?id=base:small_fast_8-bit_prng ;; input: ;; RandomSeed - a 12-bit seed for random ;; output: ;; RandomSeed - lowest 8 bits updated for next step ;; a - random number in the range [0,255] ;; destroys: ;; flags RandomByte push hl ld hl,RNG_Table ld a,(RandomSeed+1) and $0f add a,l ld l,a ld a,0 adc a,h ld h,a ld a,(RandomSeed) or a jr z,RNG_DoXOR sla a jr z,RNG_NoXOR jr nc,RNG_NoXOR RNG_DoXOR xor (hl) RNG_NoXOR ld (RandomSeed),a pop hl ret RNG_Table db $1d,$2b,$2d,$4d,$5f,$63,$65,$69 db $71,$87,$8d,$a9,$c3,$cf,$e7,$f5 ;; DissolveScreen routine for fading color memory from old state to new state. ;; Can be used for fading nicely between an empty screen and a colored screen. ;; input: ;; RandomSeed - a 12-bit seed for random ;; ColorAddress - the used color start address ;; destroys: ;; a, flags DissolveScreen push bc push de push hl ld b,0 DS_Idx defl 0 DS_Loop rept 3 call RandomByte ld d,DS_Idx ld e,a pop hl push hl add hl,de ld a,(hl) ld hl,(ColorAddress) add hl,de ld (hl),a push bc ld b,128 djnz $ pop bc DS_Idx defl DS_Idx+1 endm djnz DS_Loop jr nz,DS_Loop pop hl pop de pop bc ret ;; CopyByte routine for copying a byte to a memory address with a bit offset. ;; For example to copy byte %11100111 in (de) to address (hl) with offset ;; %00010000 would result (hl),(hl+1) containing %00011100,%11100000. If the ;; offset was for example %00000101 the result would be different, namely ;; %00000111,%00111000. For plotting XOR is always used, so if there is already ;; some content it will be modified accordingly. ;; input: ;; hl - output start address ;; de - input byte address ;; a - mask of start bit ;; c - >248 if not overflowing to second byte ;; destroys: ;; bc, a, flags CopyByte ld b,c ; Overflow flag in c ld c,a ; Start mask in c ld a,(de) ; Output byte in a ld d,b ; Overflow flag in d ld b,0xff ; Bitmask in b CB_Rotate rl c jr c,CB_EndRotate srl b rrca jr CB_Rotate CB_EndRotate ld c,a ; Rotated byte in c and b xor (hl) ld (hl),a ld a,d ; Overflow flag in a cp 249 ; Check if >248 ret nc inc hl ld a,b cpl ; Complement of bitmask in a and c xor (hl) ld (hl),a dec hl ret ;; PutByte for putting a byte in (hl) on screen with a pixel location. ;; input: ;; b - Y coordinate (0-191) ;; c - X coordinate (0-255) ;; hl - pointer to the outputted byte ;; destroys: ;; de, a, flags PutByte push bc push hl push hl call FindPixel pop de call CopyByte pop hl pop bc ret ;; PutSprite for putting a 8x8 block in any pixel location. ;; input: ;; b - Y coordinate (0-191) ;; c - X coordinate (0-255) ;; hl - pointer to the sprite data ;; destroys: ;; a, flags PutSprite ld d,8 push bc push hl push de PS_Loop2 call PutByte inc hl inc b ld a,b ; Check if Y coordinate >191 cp 192 jr nc,PS_Out pop de dec d push de jr nz,PS_Loop2 PS_Out pop de pop hl pop bc ret ;; PutChar routine for plotting a character on screen. ;; input: ;; PixelAddress - the used pixel start address ;; CharAddress - the used charset font ;; b - Y coordinate (0-191) ;; c - X coordinate (0-255) ;; a - character code ;; destroys: ;; a, flags PutChar2 call FindChar call PutSprite ret
; A098665: a(n) = Sum_{k = 0..n} binomial(n,k) * binomial(n+1,k+1) * 4^k. ; Submitted by Jon Maiga ; 1,6,43,332,2661,21810,181455,1526040,12939145,110413406,947052723,8157680228,70518067309,611426078346,5315138311383,46308989294640,404274406256145,3535479068797110,30966952059306555,271616893912241532,2385412594943633781,20973327081776664546,184596648548987152863,1626275913552665314632,14339850647307154391961,126545022623598753185550,1117555284474167419694275,9876267630857042915287700,87336431389053218581945725,772783472150397775868522810,6841682289111449147284474855 mov $1,1 mov $2,1 mov $3,$0 add $3,1 mov $4,1 lpb $3 mul $1,$3 mul $2,4 sub $3,1 mul $1,$3 add $5,$4 div $1,$5 add $2,$1 add $4,2 lpe mov $0,$2 div $0,4
// Find Sum of Digits of a Number using while Loop #include<iostream> using namespace std; int main() { int num, rem, sum=0; cout<<"Enter the Number: "; cin>>num; while(num>0) { rem = num%10; sum = sum+rem; num = num/10; } cout<<"\nSum of Digits = "<<sum; cout<<endl; return 0; }
; ; jquant.asm - sample data conversion and quantization (3DNow! & MMX) ; ; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB ; ; Based on the x86 SIMD extension for IJG JPEG library ; Copyright (C) 1999-2006, MIYASAKA Masaru. ; For conditions of distribution and use, see copyright notice in jsimdext.inc ; ; This file should be assembled with NASM (Netwide Assembler), ; can *not* be assembled with Microsoft's MASM or any compatible ; assembler (including Borland's Turbo Assembler). ; NASM is available from http://nasm.sourceforge.net/ or ; http://sourceforge.net/project/showfiles.php?group_id=6208 ; ; [TAB8] %include "jsimdext.inc" %include "jdct.inc" ; -------------------------------------------------------------------------- SECTION SEG_TEXT BITS 32 ; ; Load data into workspace, applying unsigned->signed conversion ; ; GLOBAL(void) ; jsimd_convsamp_float_3dnow (JSAMPARRAY sample_data, JDIMENSION start_col, ; FAST_FLOAT *workspace); ; %define sample_data ebp+8 ; JSAMPARRAY sample_data %define start_col ebp+12 ; JDIMENSION start_col %define workspace ebp+16 ; FAST_FLOAT *workspace align 16 global EXTN(jsimd_convsamp_float_3dnow) PRIVATE EXTN(jsimd_convsamp_float_3dnow): push ebp mov ebp,esp push ebx ; push ecx ; need not be preserved ; push edx ; need not be preserved push esi push edi pcmpeqw mm7,mm7 psllw mm7,7 packsswb mm7,mm7 ; mm7 = PB_CENTERJSAMPLE (0x808080..) mov esi, JSAMPARRAY [sample_data] ; (JSAMPROW *) mov eax, JDIMENSION [start_col] mov edi, POINTER [workspace] ; (DCTELEM *) mov ecx, DCTSIZE/2 alignx 16,7 .convloop: mov ebx, JSAMPROW [esi+0*SIZEOF_JSAMPROW] ; (JSAMPLE *) mov edx, JSAMPROW [esi+1*SIZEOF_JSAMPROW] ; (JSAMPLE *) movq mm0, MMWORD [ebx+eax*SIZEOF_JSAMPLE] movq mm1, MMWORD [edx+eax*SIZEOF_JSAMPLE] psubb mm0,mm7 ; mm0=(01234567) psubb mm1,mm7 ; mm1=(89ABCDEF) punpcklbw mm2,mm0 ; mm2=(*0*1*2*3) punpckhbw mm0,mm0 ; mm0=(*4*5*6*7) punpcklbw mm3,mm1 ; mm3=(*8*9*A*B) punpckhbw mm1,mm1 ; mm1=(*C*D*E*F) punpcklwd mm4,mm2 ; mm4=(***0***1) punpckhwd mm2,mm2 ; mm2=(***2***3) punpcklwd mm5,mm0 ; mm5=(***4***5) punpckhwd mm0,mm0 ; mm0=(***6***7) psrad mm4,(DWORD_BIT-BYTE_BIT) ; mm4=(01) psrad mm2,(DWORD_BIT-BYTE_BIT) ; mm2=(23) pi2fd mm4,mm4 pi2fd mm2,mm2 psrad mm5,(DWORD_BIT-BYTE_BIT) ; mm5=(45) psrad mm0,(DWORD_BIT-BYTE_BIT) ; mm0=(67) pi2fd mm5,mm5 pi2fd mm0,mm0 movq MMWORD [MMBLOCK(0,0,edi,SIZEOF_FAST_FLOAT)], mm4 movq MMWORD [MMBLOCK(0,1,edi,SIZEOF_FAST_FLOAT)], mm2 movq MMWORD [MMBLOCK(0,2,edi,SIZEOF_FAST_FLOAT)], mm5 movq MMWORD [MMBLOCK(0,3,edi,SIZEOF_FAST_FLOAT)], mm0 punpcklwd mm6,mm3 ; mm6=(***8***9) punpckhwd mm3,mm3 ; mm3=(***A***B) punpcklwd mm4,mm1 ; mm4=(***C***D) punpckhwd mm1,mm1 ; mm1=(***E***F) psrad mm6,(DWORD_BIT-BYTE_BIT) ; mm6=(89) psrad mm3,(DWORD_BIT-BYTE_BIT) ; mm3=(AB) pi2fd mm6,mm6 pi2fd mm3,mm3 psrad mm4,(DWORD_BIT-BYTE_BIT) ; mm4=(CD) psrad mm1,(DWORD_BIT-BYTE_BIT) ; mm1=(EF) pi2fd mm4,mm4 pi2fd mm1,mm1 movq MMWORD [MMBLOCK(1,0,edi,SIZEOF_FAST_FLOAT)], mm6 movq MMWORD [MMBLOCK(1,1,edi,SIZEOF_FAST_FLOAT)], mm3 movq MMWORD [MMBLOCK(1,2,edi,SIZEOF_FAST_FLOAT)], mm4 movq MMWORD [MMBLOCK(1,3,edi,SIZEOF_FAST_FLOAT)], mm1 add esi, byte 2*SIZEOF_JSAMPROW add edi, byte 2*DCTSIZE*SIZEOF_FAST_FLOAT dec ecx jnz near .convloop femms ; empty MMX/3DNow! state pop edi pop esi ; pop edx ; need not be preserved ; pop ecx ; need not be preserved pop ebx pop ebp ret ; -------------------------------------------------------------------------- ; ; Quantize/descale the coefficients, and store into coef_block ; ; GLOBAL(void) ; jsimd_quantize_float_3dnow (JCOEFPTR coef_block, FAST_FLOAT *divisors, ; FAST_FLOAT *workspace); ; %define coef_block ebp+8 ; JCOEFPTR coef_block %define divisors ebp+12 ; FAST_FLOAT *divisors %define workspace ebp+16 ; FAST_FLOAT *workspace align 16 global EXTN(jsimd_quantize_float_3dnow) PRIVATE EXTN(jsimd_quantize_float_3dnow): push ebp mov ebp,esp ; push ebx ; unused ; push ecx ; unused ; push edx ; need not be preserved push esi push edi mov eax, 0x4B400000 ; (float)0x00C00000 (rndint_magic) movd mm7,eax punpckldq mm7,mm7 ; mm7={12582912.0F 12582912.0F} mov esi, POINTER [workspace] mov edx, POINTER [divisors] mov edi, JCOEFPTR [coef_block] mov eax, DCTSIZE2/16 alignx 16,7 .quantloop: movq mm0, MMWORD [MMBLOCK(0,0,esi,SIZEOF_FAST_FLOAT)] movq mm1, MMWORD [MMBLOCK(0,1,esi,SIZEOF_FAST_FLOAT)] pfmul mm0, MMWORD [MMBLOCK(0,0,edx,SIZEOF_FAST_FLOAT)] pfmul mm1, MMWORD [MMBLOCK(0,1,edx,SIZEOF_FAST_FLOAT)] movq mm2, MMWORD [MMBLOCK(0,2,esi,SIZEOF_FAST_FLOAT)] movq mm3, MMWORD [MMBLOCK(0,3,esi,SIZEOF_FAST_FLOAT)] pfmul mm2, MMWORD [MMBLOCK(0,2,edx,SIZEOF_FAST_FLOAT)] pfmul mm3, MMWORD [MMBLOCK(0,3,edx,SIZEOF_FAST_FLOAT)] pfadd mm0,mm7 ; mm0=(00 ** 01 **) pfadd mm1,mm7 ; mm1=(02 ** 03 **) pfadd mm2,mm7 ; mm0=(04 ** 05 **) pfadd mm3,mm7 ; mm1=(06 ** 07 **) movq mm4,mm0 punpcklwd mm0,mm1 ; mm0=(00 02 ** **) punpckhwd mm4,mm1 ; mm4=(01 03 ** **) movq mm5,mm2 punpcklwd mm2,mm3 ; mm2=(04 06 ** **) punpckhwd mm5,mm3 ; mm5=(05 07 ** **) punpcklwd mm0,mm4 ; mm0=(00 01 02 03) punpcklwd mm2,mm5 ; mm2=(04 05 06 07) movq mm6, MMWORD [MMBLOCK(1,0,esi,SIZEOF_FAST_FLOAT)] movq mm1, MMWORD [MMBLOCK(1,1,esi,SIZEOF_FAST_FLOAT)] pfmul mm6, MMWORD [MMBLOCK(1,0,edx,SIZEOF_FAST_FLOAT)] pfmul mm1, MMWORD [MMBLOCK(1,1,edx,SIZEOF_FAST_FLOAT)] movq mm3, MMWORD [MMBLOCK(1,2,esi,SIZEOF_FAST_FLOAT)] movq mm4, MMWORD [MMBLOCK(1,3,esi,SIZEOF_FAST_FLOAT)] pfmul mm3, MMWORD [MMBLOCK(1,2,edx,SIZEOF_FAST_FLOAT)] pfmul mm4, MMWORD [MMBLOCK(1,3,edx,SIZEOF_FAST_FLOAT)] pfadd mm6,mm7 ; mm0=(10 ** 11 **) pfadd mm1,mm7 ; mm4=(12 ** 13 **) pfadd mm3,mm7 ; mm0=(14 ** 15 **) pfadd mm4,mm7 ; mm4=(16 ** 17 **) movq mm5,mm6 punpcklwd mm6,mm1 ; mm6=(10 12 ** **) punpckhwd mm5,mm1 ; mm5=(11 13 ** **) movq mm1,mm3 punpcklwd mm3,mm4 ; mm3=(14 16 ** **) punpckhwd mm1,mm4 ; mm1=(15 17 ** **) punpcklwd mm6,mm5 ; mm6=(10 11 12 13) punpcklwd mm3,mm1 ; mm3=(14 15 16 17) movq MMWORD [MMBLOCK(0,0,edi,SIZEOF_JCOEF)], mm0 movq MMWORD [MMBLOCK(0,1,edi,SIZEOF_JCOEF)], mm2 movq MMWORD [MMBLOCK(1,0,edi,SIZEOF_JCOEF)], mm6 movq MMWORD [MMBLOCK(1,1,edi,SIZEOF_JCOEF)], mm3 add esi, byte 16*SIZEOF_FAST_FLOAT add edx, byte 16*SIZEOF_FAST_FLOAT add edi, byte 16*SIZEOF_JCOEF dec eax jnz near .quantloop femms ; empty MMX/3DNow! state pop edi pop esi ; pop edx ; need not be preserved ; pop ecx ; unused ; pop ebx ; unused pop ebp ret ; For some reason, the OS X linker does not honor the request to align the ; segment unless we do this. align 16
INCLUDE "config_private.inc" SECTION code_clib SECTION code_math PUBLIC l_fast_mulu_32_32x32 EXTERN l_fast_mulu_40_32x8, l0_fast_mulu_40_32x8, l0_fast_mulu_32_24x8 EXTERN l_fast_mulu_32_16x16, l_fast_mulu_32_24x16 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; IF __CLIB_OPT_IMATH_FAST & $80 EXTERN error_mulu_overflow_mc ELSE EXTERN l_fast_mulu_16_8x8, l_fast_mulu_24_16x8 ENDIF ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; l_fast_mulu_32_32x32: ; unsigned multiplication of two 32-bit ; multiplicands into a 32-bit product ; ; error reported on overflow ; ; enter : dehl = 32-bit multiplicand ; dehl'= 32-bit multiplicand ; ; exit : success ; ; dehl = 32-bit product ; carry reset ; ; unsigned overflow (LIA-1 enabled only) ; ; dehl = $ffffffff = ULONG_MAX ; carry set, errno = ERANGE ; ; uses : af, bc, de, hl, bc', de', hl', (ixh if loop unrolling disabled, ix if LIA-1 disabled) ; try to reduce multiplication inc d dec d jr NZ, _24b_x ; 25 to 32 bits inc e dec e jr NZ, _16b_x ; 17 to 24 bits inc h dec h jr NZ, _8b_x ; 9 to 16 bits _8_32: ; dehl' * l ld a,l exx ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; IF __CLIB_OPT_IMATH_FAST & $80 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; call l_fast_mulu_40_32x8 or a ret Z overflow: call error_mulu_overflow_mc ld e,l ld d,h ret ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ELSE ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; jp l_fast_mulu_40_32x8 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ENDIF ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; _24b_x: ; dehl * dehl' exx ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; IF __CLIB_OPT_IMATH_FAST & $80 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; inc d dec d jr NZ, overflow ; 24b_24b = 48b inc e dec e jr NZ, overflow ; 24b_16b = 40b inc h dec h jr NZ, overflow ; 24b_8b = 32b ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ELSE ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; inc d dec d jr NZ, _24b_24b inc e dec e jr NZ, _24b_16b inc h dec h jr NZ, _24b_8b ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ENDIF ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; _32_8: ; l * dehl' ld a,l exx ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; IF __CLIB_OPT_IMATH_FAST & $80 call l0_fast_mulu_40_32x8 or a ret Z jr overflow ELSE jp l0_fast_mulu_40_32x8 ENDIF ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; _16b_x: ; ehl * dehl' exx ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; IF __CLIB_OPT_IMATH_FAST & $80 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; inc d dec d jr NZ, overflow ; 16b_24b = 40b inc e dec e jr NZ, overflow ; 16b_16b = 32b ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ELSE ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; inc d dec d jr NZ, _16b_24b inc e dec e jr NZ, _16b_16b ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ENDIF ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; inc h dec h jr NZ, _24_16 _24_8: ; ehl' * l ld a,l exx jp l0_fast_mulu_32_24x8 _8b_x: ; hl * dehl' exx ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; IF __CLIB_OPT_IMATH_FAST & $80 inc d dec d jr NZ, overflow ; 8b_24b = 32b ELSE inc d dec d jr NZ, _8b_24b ENDIF ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; inc e dec e jr Z, _16_16 ; hl' * ehl exx _24_16: ; ehl' * hl push hl exx pop bc jp l_fast_mulu_32_24x16 _16_16: ; hl' * hl push hl exx pop de jp l_fast_mulu_32_16x16 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; IF (__CLIB_OPT_IMATH_FAST & $80) = 0 _24b_24b: ; dehl' * dehl push hl ; save L exx push de ; save d call _24b_16b exx pop de ld e,d pop hl call l_fast_mulu_16_8x8 ld a,l exx add a,d ld d,a or a ret _24b_16b: ; dehl' * ehl exx _16b_24b: ; ehl' * dehl push de push hl exx ld c,h ld b,e ld a,l pop hl pop de push af call l_fast_mulu_32_24x16 ld d,e ld e,h ld h,l ld l,0 exx pop af call l0_fast_mulu_40_32x8 push de push hl exx pop bc add hl,bc ex de,hl pop bc adc hl,bc ex de,hl or a ret _8b_24b: ; hl' * dehl exx _24b_8b: ; dehl' * hl ld a,l exx push de push hl call l0_fast_mulu_40_32x8 exx ld a,h pop hl pop de call l0_fast_mulu_32_24x8 ld d,e ld e,h ld h,l ld l,0 push de push hl exx pop bc add hl,bc ex de,hl pop bc adc hl,bc ex de,hl or a ret _16b_16b: ; ehl' * ehl push hl exx pop bc push hl call l_fast_mulu_32_24x16 exx pop hl call l_fast_mulu_24_16x8 push hl exx pop bc ex de,hl add hl,bc ex de,hl or a ret ENDIF ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; make array to new list include win1_mac_oli section utility xdef ut_ar2nlst ;+++ ; make array to new list ; ; Entry Exit ; d1.l array type (0=abs,1=rel) preserved ; a0 array descriptor preserved ; a1 ptr to list space ; ; error: err.imem ; cc set ;--- ut_ar2nlst subr a0/a2/d1/d2 xjsr ut_arinf ; get array information xjsr ut_allst ; allocate list space bne.s exit move.l a1,a2 bra.s lpe lp move.l a0,(a2)+ add.w d2,a0 lpe dbra d1,lp move.l #0,(a2) ; 0 is end of list marker exit subend end
@256 D=A @SP M=D @RET_9F9CCF12DB D=A @SP A=M M=D @SP M=M+1 @LCL D=M @SP A=M M=D @SP M=M+1 @ARG D=M @SP A=M M=D @SP M=M+1 @THIS D=M @SP A=M M=D @SP M=M+1 @THAT D=M @SP A=M M=D @SP M=M+1 @SP D=M @5 D=D-A @ARG M=D @SP D=M @LCL M=D @Sys.init 0;JMP (RET_9F9CCF12DB) //Sys (Sys.init) @4000 D=A @SP A=M M=D @SP M=M+1 @THIS D=A @0 A=D+A D=A @R15 M=D @SP M=M-1 @SP A=M D=M @R15 A=M M=D @5000 D=A @SP A=M M=D @SP M=M+1 @THIS D=A @1 A=D+A D=A @R15 M=D @SP M=M-1 @SP A=M D=M @R15 A=M M=D @RET_CE9B109FFA D=A @SP A=M M=D @SP M=M+1 @LCL D=M @SP A=M M=D @SP M=M+1 @ARG D=M @SP A=M M=D @SP M=M+1 @THIS D=M @SP A=M M=D @SP M=M+1 @THAT D=M @SP A=M M=D @SP M=M+1 @SP D=M @5 D=D-A @ARG M=D @SP D=M @LCL M=D @Sys.main 0;JMP (RET_CE9B109FFA) @R5 D=A @1 A=D+A D=A @R15 M=D @SP M=M-1 @SP A=M D=M @R15 A=M M=D (Sys.init$LOOP) @Sys.init$LOOP 0;JMP (Sys.main) @0 D=A @SP A=M M=D @SP M=M+1 @0 D=A @SP A=M M=D @SP M=M+1 @0 D=A @SP A=M M=D @SP M=M+1 @0 D=A @SP A=M M=D @SP M=M+1 @0 D=A @SP A=M M=D @SP M=M+1 @4001 D=A @SP A=M M=D @SP M=M+1 @THIS D=A @0 A=D+A D=A @R15 M=D @SP M=M-1 @SP A=M D=M @R15 A=M M=D @5001 D=A @SP A=M M=D @SP M=M+1 @THIS D=A @1 A=D+A D=A @R15 M=D @SP M=M-1 @SP A=M D=M @R15 A=M M=D @200 D=A @SP A=M M=D @SP M=M+1 @LCL D=M @1 A=D+A D=A @R15 M=D @SP M=M-1 @SP A=M D=M @R15 A=M M=D @40 D=A @SP A=M M=D @SP M=M+1 @LCL D=M @2 A=D+A D=A @R15 M=D @SP M=M-1 @SP A=M D=M @R15 A=M M=D @6 D=A @SP A=M M=D @SP M=M+1 @LCL D=M @3 A=D+A D=A @R15 M=D @SP M=M-1 @SP A=M D=M @R15 A=M M=D @123 D=A @SP A=M M=D @SP M=M+1 @RET_07932772B4 D=A @SP A=M M=D @SP M=M+1 @LCL D=M @SP A=M M=D @SP M=M+1 @ARG D=M @SP A=M M=D @SP M=M+1 @THIS D=M @SP A=M M=D @SP M=M+1 @THAT D=M @SP A=M M=D @SP M=M+1 @SP D=M @6 D=D-A @ARG M=D @SP D=M @LCL M=D @Sys.add12 0;JMP (RET_07932772B4) @R5 D=A @0 A=D+A D=A @R15 M=D @SP M=M-1 @SP A=M D=M @R15 A=M M=D @LCL D=M @0 A=D+A D=M @SP A=M M=D @SP M=M+1 @LCL D=M @1 A=D+A D=M @SP A=M M=D @SP M=M+1 @LCL D=M @2 A=D+A D=M @SP A=M M=D @SP M=M+1 @LCL D=M @3 A=D+A D=M @SP A=M M=D @SP M=M+1 @LCL D=M @4 A=D+A D=M @SP A=M M=D @SP M=M+1 @SP M=M-1 @SP A=M D=M @SP M=M-1 @SP A=M D=M+D @SP A=M M=D @SP M=M+1 @SP M=M-1 @SP A=M D=M @SP M=M-1 @SP A=M D=M+D @SP A=M M=D @SP M=M+1 @SP M=M-1 @SP A=M D=M @SP M=M-1 @SP A=M D=M+D @SP A=M M=D @SP M=M+1 @SP M=M-1 @SP A=M D=M @SP M=M-1 @SP A=M D=M+D @SP A=M M=D @SP M=M+1 @LCL D=M @frame M=D @frame D=M @5 A=D-A D=M @RET M=D @SP M=M-1 @SP A=M D=M @ARG A=M M=D @ARG D=M+1 @SP M=D @frame D=M @1 A=D-A D=M @THAT M=D @frame D=M @2 A=D-A D=M @THIS M=D @frame D=M @3 A=D-A D=M @ARG M=D @frame D=M @4 A=D-A D=M @LCL M=D @RET A=M 0;JMP (Sys.add12) @4002 D=A @SP A=M M=D @SP M=M+1 @THIS D=A @0 A=D+A D=A @R15 M=D @SP M=M-1 @SP A=M D=M @R15 A=M M=D @5002 D=A @SP A=M M=D @SP M=M+1 @THIS D=A @1 A=D+A D=A @R15 M=D @SP M=M-1 @SP A=M D=M @R15 A=M M=D @ARG D=M @0 A=D+A D=M @SP A=M M=D @SP M=M+1 @12 D=A @SP A=M M=D @SP M=M+1 @SP M=M-1 @SP A=M D=M @SP M=M-1 @SP A=M D=M+D @SP A=M M=D @SP M=M+1 @LCL D=M @frame M=D @frame D=M @5 A=D-A D=M @RET M=D @SP M=M-1 @SP A=M D=M @ARG A=M M=D @ARG D=M+1 @SP M=D @frame D=M @1 A=D-A D=M @THAT M=D @frame D=M @2 A=D-A D=M @THIS M=D @frame D=M @3 A=D-A D=M @ARG M=D @frame D=M @4 A=D-A D=M @LCL M=D @RET A=M 0;JMP
jmp @main main: mov -3 swp mov -4 add swp mov 18 sub shl jnz @skip nop skip: shr hlt
/* * Clock.asm * * Created: 13.01.2014 20:11:02 * Author: Beni */
; int fputc(int c, FILE *stream) INCLUDE "clib_cfg.asm" SECTION code_clib SECTION code_stdio ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; IF __CLIB_OPT_MULTITHREAD & $02 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; PUBLIC fputc EXTERN asm_fputc fputc: pop af pop ix pop de push de push hl push af jp asm_fputc ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ELSE ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; PUBLIC fputc EXTERN fputc_unlocked defc fputc = fputc_unlocked ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ENDIF ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; A024643: n written in fractional base 7/6. ; Submitted by Jon Maiga ; 0,1,2,3,4,5,6,60,61,62,63,64,65,66,650,651,652,653,654,655,656,6540,6541,6542,6543,6544,6545,6546,65430,65431,65432,65433,65434,65435,65436,654320,654321,654322,654323,654324,654325,654326,6543210,6543211,6543212,6543213,6543214,6543215,6543216,65432100,65432101,65432102,65432103,65432104,65432105,65432106,65432160,65432161,65432162,65432163,65432164,65432165,65432166,654321050,654321051,654321052,654321053,654321054,654321055,654321056,654321640,654321641,654321642,654321643,654321644 mov $3,1 lpb $0 mov $2,$0 div $0,7 mul $0,6 mod $2,7 mul $2,$3 add $1,$2 mul $3,10 lpe mov $0,$1
; Copyright (c) 2004, Intel Corporation. All rights reserved.<BR> ; This program and the accompanying materials ; are licensed and made available under the terms and conditions of the BSD License ; which accompanies this distribution. The full text of the license may be found at ; http://opensource.org/licenses/bsd-license.php ; ; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, ; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. ; ; Module Name: ; ; WriteMm0.Asm ; ; Abstract: ; ; AsmWriteMm0 function ; ; Notes: ; ;------------------------------------------------------------------------------ .code ;------------------------------------------------------------------------------ ; VOID ; EFIAPI ; AsmWriteMm0 ( ; IN UINT64 Value ; ); ;------------------------------------------------------------------------------ AsmWriteMm0 PROC ; ; 64-bit MASM doesn't support MMX instructions, so use opcode here ; DB 48h, 0fh, 6eh, 0c1h ret AsmWriteMm0 ENDP END
; char *_memupr_(void *p, size_t n) SECTION code_string PUBLIC _memupr_ EXTERN asm__memupr _memupr_: pop af pop bc pop hl push hl push bc push af jp asm__memupr
name "hex-bin" org 100h ; load binary value: ; (hex: 5h) mov al, 00000101b ; load hex value: mov bl, 0ah ; load octal value: ; (hex: 8h) mov cl, 10o ; 5 + 10 = 15 (0fh) add al, bl ; 15 - 8 = 7 sub al, cl ; print result in binary: mov bl, al mov cx, 8 print: mov ah, 2 ; print function. mov dl, '0' test bl, 10000000b ; test first bit. jz zero mov dl, '1' zero: int 21h shl bl, 1 loop print ; print binary suffix: mov dl, 'b' int 21h ; wait for any key press: mov ah, 0 int 16h ret
db DEX_ABRA ; pokedex id db 25 ; base hp db 20 ; base attack db 15 ; base defense db 90 ; base speed db 105 ; base special db PSYCHIC ; species type 1 db PSYCHIC ; species type 2 db 200 ; catch rate db 79 ; base exp yield INCBIN "pic/ymon/abra.pic",0,1 ; 55, sprite dimensions dw AbraPicFront dw AbraPicBack ; attacks known at lvl 0 db TELEPORT db 0 db 0 db 0 db 3 ; growth rate ; learnset tmlearn 1,5,6,7,8 tmlearn 9,10 tmlearn 17,18,19,20 tmlearn 29,30,31,32 tmlearn 33,34,35,40 tmlearn 44,45,46 tmlearn 49,50,55 db BANK(AbraPicFront)
/** * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. */ #include <aws/mediapackage-vod/MediaPackageVodEndpoint.h> #include <aws/core/utils/memory/stl/AWSStringStream.h> #include <aws/core/utils/HashingUtils.h> using namespace Aws; using namespace Aws::MediaPackageVod; namespace Aws { namespace MediaPackageVod { namespace MediaPackageVodEndpoint { static const int CN_NORTH_1_HASH = Aws::Utils::HashingUtils::HashString("cn-north-1"); static const int CN_NORTHWEST_1_HASH = Aws::Utils::HashingUtils::HashString("cn-northwest-1"); static const int US_ISO_EAST_1_HASH = Aws::Utils::HashingUtils::HashString("us-iso-east-1"); static const int US_ISOB_EAST_1_HASH = Aws::Utils::HashingUtils::HashString("us-isob-east-1"); Aws::String ForRegion(const Aws::String& regionName, bool useDualStack) { // Fallback to us-east-1 if global endpoint does not exists. Aws::String region = regionName == Aws::Region::AWS_GLOBAL ? Aws::Region::US_EAST_1 : regionName; auto hash = Aws::Utils::HashingUtils::HashString(region.c_str()); Aws::StringStream ss; ss << "mediapackage-vod" << "."; if(useDualStack) { ss << "dualstack."; } ss << region; if (hash == CN_NORTH_1_HASH || hash == CN_NORTHWEST_1_HASH) { ss << ".amazonaws.com.cn"; } else if (hash == US_ISO_EAST_1_HASH) { ss << ".c2s.ic.gov"; } else if (hash == US_ISOB_EAST_1_HASH) { ss << ".sc2s.sgov.gov"; } else { ss << ".amazonaws.com"; } return ss.str(); } } // namespace MediaPackageVodEndpoint } // namespace MediaPackageVod } // namespace Aws
; A027657: Expansion of (1+4*x)/(1-34*x+x^2). ; Submitted by Jon Maiga ; 1,38,1291,43856,1489813,50609786,1719242911,58403649188,1984004829481,67397760553166,2289539853978163,77776957274704376,2642127007485970621,89754541297248296738,3049012277098956118471 lpb $0 sub $0,1 add $3,1 mov $1,$3 mul $1,32 add $2,$1 add $3,4 add $3,$2 lpe mov $0,$3 add $0,1
/* * Copyright 2010-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. * A copy of the License is located at * * http://aws.amazon.com/apache2.0 * * or in the "license" file accompanying this file. This file is distributed * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either * express or implied. See the License for the specific language governing * permissions and limitations under the License. */ #include <aws/resource-groups/model/DeleteGroupResult.h> #include <aws/core/utils/json/JsonSerializer.h> #include <aws/core/AmazonWebServiceResult.h> #include <aws/core/utils/StringUtils.h> #include <aws/core/utils/UnreferencedParam.h> #include <utility> using namespace Aws::ResourceGroups::Model; using namespace Aws::Utils::Json; using namespace Aws::Utils; using namespace Aws; DeleteGroupResult::DeleteGroupResult() { } DeleteGroupResult::DeleteGroupResult(const Aws::AmazonWebServiceResult<JsonValue>& result) { *this = result; } DeleteGroupResult& DeleteGroupResult::operator =(const Aws::AmazonWebServiceResult<JsonValue>& result) { JsonView jsonValue = result.GetPayload().View(); if(jsonValue.ValueExists("Group")) { m_group = jsonValue.GetObject("Group"); } return *this; }
#include "wantbuyparam.hpp" #include "servercommon/servercommon.h" OLD_USE_INTERNAL_NETWORK(); bool WantBuyParam::Serialize(TLVSerializer &outstream) const { bool ret = outstream.Push(count); if (!ret) return false; for (int i = 0; i < count && i < MAX_WANT_BUY_COUNT; ++i) { ret = outstream.Push(wantbuy_list[i].change_state); if (!ret) return false; const char * buyer_name = wantbuy_list[i].wantbuy_item.buyer_name; ret = outstream.Push(wantbuy_list[i].wantbuy_item.buyer_db_index) && outstream.Push(wantbuy_list[i].wantbuy_item.buyer_role_id) && outstream.Push(buyer_name) && outstream.Push(wantbuy_list[i].wantbuy_item.buy_index) && outstream.Push(wantbuy_list[i].wantbuy_item.item_id) && outstream.Push(wantbuy_list[i].wantbuy_item.item_num) && outstream.Push(wantbuy_list[i].wantbuy_item.color) && outstream.Push(wantbuy_list[i].wantbuy_item.level) && outstream.Push(wantbuy_list[i].wantbuy_item.prof) && outstream.Push(wantbuy_list[i].wantbuy_item.gold_per) && outstream.Push(wantbuy_list[i].wantbuy_item.wantbuy_time) && outstream.Push(wantbuy_list[i].wantbuy_item.due_time); if (!ret) return false; } return true; } bool WantBuyParam::Unserialize(TLVUnserializer &instream) { bool ret = instream.Pop(&count); if (!ret) return false; for (int i = 0; i < count && i < MAX_WANT_BUY_COUNT; ++i) { ret = instream.Pop(&wantbuy_list[i].change_state); if (!ret) return false; const char * buyer_name = 0; ret = instream.Pop(&wantbuy_list[i].wantbuy_item.buyer_db_index) && instream.Pop(&wantbuy_list[i].wantbuy_item.buyer_role_id) && instream.Pop(&buyer_name) && instream.Pop(&wantbuy_list[i].wantbuy_item.buy_index) && instream.Pop(&wantbuy_list[i].wantbuy_item.item_id) && instream.Pop(&wantbuy_list[i].wantbuy_item.item_num) && instream.Pop(&wantbuy_list[i].wantbuy_item.color) && instream.Pop(&wantbuy_list[i].wantbuy_item.level) && instream.Pop(&wantbuy_list[i].wantbuy_item.prof) && instream.Pop(&wantbuy_list[i].wantbuy_item.gold_per) && instream.Pop(&wantbuy_list[i].wantbuy_item.wantbuy_time) && instream.Pop(&wantbuy_list[i].wantbuy_item.due_time); if (!ret) return false; STRNCPY(wantbuy_list[i].wantbuy_item.buyer_name, buyer_name, sizeof(wantbuy_list[0].wantbuy_item.buyer_name)); } return true; }
/* * FreeRTOS Kernel V10.2.1 * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * 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. * * http://www.FreeRTOS.org * http://aws.amazon.com/freertos * * 1 tab == 4 spaces! */ #include "FreeRTOSConfig.h" #include "portasm.h" .CODE /* * The RTOS tick ISR. * * If the cooperative scheduler is in use this simply increments the tick * count. * * If the preemptive scheduler is in use a context switch can also occur. */ _vTickISR: portSAVE_CONTEXT call #_xTaskIncrementTick cmp.w #0x00, r15 jeq _SkipContextSwitch call #_vTaskSwitchContext _SkipContextSwitch: portRESTORE_CONTEXT /*-----------------------------------------------------------*/ /* * Manual context switch called by the portYIELD() macro. */ _vPortYield:: /* Mimic an interrupt by pushing the SR. */ push SR /* Now the SR is stacked we can disable interrupts. */ dint /* Save the context of the current task. */ portSAVE_CONTEXT /* Switch to the highest priority task that is ready to run. */ call #_vTaskSwitchContext /* Restore the context of the new task. */ portRESTORE_CONTEXT /*-----------------------------------------------------------*/ /* * Start off the scheduler by initialising the RTOS tick timer, then restoring * the context of the first task. */ _xPortStartScheduler:: /* Setup the hardware to generate the tick. Interrupts are disabled when this function is called. */ call #_prvSetupTimerInterrupt /* Restore the context of the first task that is going to run. */ portRESTORE_CONTEXT /*-----------------------------------------------------------*/ /* Place the tick ISR in the correct vector. */ .VECTORS .KEEP ORG TIMERA0_VECTOR DW _vTickISR END
;**************************************************************************** ;* ;* SciTech OS Portability Manager Library ;* ;* ======================================================================== ;* ;* The contents of this file are subject to the SciTech MGL Public ;* License Version 1.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.scitechsoft.com/mgl-license.txt ;* ;* Software distributed under the License is distributed on an ;* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or ;* implied. See the License for the specific language governing ;* rights and limitations under the License. ;* ;* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc. ;* ;* The Initial Developer of the Original Code is SciTech Software, Inc. ;* All Rights Reserved. ;* ;* ======================================================================== ;* ;* Language: NASM or TASM Assembler ;* Environment: Intel 32 bit Protected Mode. ;* ;* Description: Code for 64-bit arhithmetic ;* ;**************************************************************************** IDEAL include "scitech.mac" header _int64 begcodeseg _int64 ; Start of code segment a_low EQU 04h ; Access a_low directly on stack a_high EQU 08h ; Access a_high directly on stack b_low EQU 0Ch ; Access b_low directly on stack shift EQU 0Ch ; Access shift directly on stack result_2 EQU 0Ch ; Access result directly on stack b_high EQU 10h ; Access b_high directly on stack result_3 EQU 10h ; Access result directly on stack result_4 EQU 14h ; Access result directly on stack ;---------------------------------------------------------------------------- ; void _PM_add64(u32 a_low,u32 a_high,u32 b_low,u32 b_high,__u64 *result); ;---------------------------------------------------------------------------- ; Adds two 64-bit numbers. ;---------------------------------------------------------------------------- cprocstart _PM_add64 mov eax,[esp+a_low] add eax,[esp+b_low] mov edx,[esp+a_high] adc edx,[esp+b_high] mov ecx,[esp+result_4] mov [ecx],eax mov [ecx+4],edx ret cprocend ;---------------------------------------------------------------------------- ; void _PM_sub64(u32 a_low,u32 a_high,u32 b_low,u32 b_high,__u64 *result); ;---------------------------------------------------------------------------- ; Subtracts two 64-bit numbers. ;---------------------------------------------------------------------------- cprocstart _PM_sub64 mov eax,[esp+a_low] sub eax,[esp+b_low] mov edx,[esp+a_high] sbb edx,[esp+b_high] mov ecx,[esp+result_4] mov [ecx],eax mov [ecx+4],edx ret cprocend ;---------------------------------------------------------------------------- ; void _PM_mul64(u32 a_high,u32 a_low,u32 b_high,u32 b_low,__u64 *result); ;---------------------------------------------------------------------------- ; Multiples two 64-bit numbers. ;---------------------------------------------------------------------------- cprocstart _PM_mul64 mov eax,[esp+a_high] mov ecx,[esp+b_high] or ecx,eax mov ecx,[esp+b_low] jnz @@FullMultiply mov eax,[esp+a_low] ; EDX:EAX = b.low * a.low mul ecx mov ecx,[esp+result_4] mov [ecx],eax mov [ecx+4],edx ret @@FullMultiply: push ebx mul ecx ; EDX:EAX = a.high * b.low mov ebx,eax mov eax,[esp+a_low+4] mul [DWORD esp+b_high+4] ; EDX:EAX = b.high * a.low add ebx,eax mov eax,[esp+a_low+4] mul ecx ; EDX:EAX = a.low * b.low add edx,ebx pop ebx mov ecx,[esp+result_4] mov [ecx],eax mov [ecx+4],edx ret cprocend ;---------------------------------------------------------------------------- ; void _PM_div64(u32 a_low,u32 a_high,u32 b_low,u32 b_high,__u64 *result); ;---------------------------------------------------------------------------- ; Divides two 64-bit numbers. ;---------------------------------------------------------------------------- cprocstart _PM_div64 push edi push esi push ebx xor edi,edi mov eax,[esp+a_high+0Ch] or eax,eax jns @@ANotNeg ; Dividend is negative, so negate it and save result for later inc edi mov edx,[esp+a_low+0Ch] neg eax neg edx sbb eax,0 mov [esp+a_high+0Ch],eax mov [esp+a_low+0Ch],edx @@ANotNeg: mov eax,[esp+b_high+0Ch] or eax,eax jns @@BNotNeg ; Divisor is negative, so negate it and save result for later inc edi mov edx,[esp+b_low+0Ch] neg eax neg edx sbb eax,0 mov [esp+b_high+0Ch],eax mov [esp+b_low+0Ch],edx @@BNotNeg: or eax,eax jnz @@BHighNotZero ; b.high is zero, so handle this faster mov ecx,[esp+b_low+0Ch] mov eax,[esp+a_high+0Ch] xor edx,edx div ecx mov ebx,eax mov eax,[esp+a_low+0Ch] div ecx mov edx,ebx jmp @@BHighZero @@BHighNotZero: mov ebx,eax mov ecx,[esp+b_low+0Ch] mov edx,[esp+a_high+0Ch] mov eax,[esp+a_low+0Ch] ; Shift values right until b.high becomes zero @@ShiftLoop: shr ebx,1 rcr ecx,1 shr edx,1 rcr eax,1 or ebx,ebx jnz @@ShiftLoop ; Now complete the divide process div ecx mov esi,eax mul [DWORD esp+b_high+0Ch] mov ecx,eax mov eax,[esp+b_low+0Ch] mul esi add edx,ecx jb @@8 cmp edx,[esp+a_high+0Ch] ja @@8 jb @@9 cmp eax,[esp+a_low+0Ch] jbe @@9 @@8: dec esi @@9: xor edx,edx mov eax,esi @@BHighZero: dec edi jnz @@Done ; The result needs to be negated as either a or b was negative neg edx neg eax sbb edx,0 @@Done: pop ebx pop esi pop edi mov ecx,[esp+result_4] mov [ecx],eax mov [ecx+4],edx ret cprocend ;---------------------------------------------------------------------------- ; __i64 _PM_shr64(u32 a_low,s32 a_high,s32 shift,__u64 *result); ;---------------------------------------------------------------------------- ; Shift a 64-bit number right ;---------------------------------------------------------------------------- cprocstart _PM_shr64 mov eax,[esp+a_low] mov edx,[esp+a_high] mov cl,[esp+shift] shrd edx,eax,cl mov ecx,[esp+result_3] mov [ecx],eax mov [ecx+4],edx ret cprocend ;---------------------------------------------------------------------------- ; __i64 _PM_sar64(u32 a_low,s32 a_high,s32 shift,__u64 *result); ;---------------------------------------------------------------------------- ; Shift a 64-bit number right (signed) ;---------------------------------------------------------------------------- cprocstart _PM_sar64 mov eax,[esp+a_low] mov edx,[esp+a_high] mov cl,[esp+shift] sar edx,cl rcr eax,cl mov ecx,[esp+result_3] mov [ecx],eax mov [ecx+4],edx ret cprocend ;---------------------------------------------------------------------------- ; __i64 _PM_shl64(u32 a_low,s32 a_high,s32 shift,__u64 *result); ;---------------------------------------------------------------------------- ; Shift a 64-bit number left ;---------------------------------------------------------------------------- cprocstart _PM_shl64 mov eax,[esp+a_low] mov edx,[esp+a_high] mov cl,[esp+shift] shld edx,eax,cl mov ecx,[esp+result_3] mov [ecx],eax mov [ecx+4],edx ret cprocend ;---------------------------------------------------------------------------- ; __i64 _PM_neg64(u32 a_low,s32 a_high,__u64 *result); ;---------------------------------------------------------------------------- ; Shift a 64-bit number left ;---------------------------------------------------------------------------- cprocstart _PM_neg64 mov eax,[esp+a_low] mov edx,[esp+a_high] neg eax neg edx sbb eax,0 mov ecx,[esp+result_2] mov [ecx],eax mov [ecx+4],edx ret cprocend endcodeseg _int64 END
; A052459: a(n) = n*(2*n^2 + 1)*(n^2 + 1)/6. ; 1,15,95,374,1105,2701,5775,11180,20049,33835,54351,83810,124865,180649,254815,351576,475745,632775,828799,1070670,1366001,1723205,2151535,2661124,3263025,3969251,4792815,5747770,6849249,8113505,9557951,11201200,13063105,15164799,17528735,20178726,23139985,26439165,30104399,34165340,38653201,43600795,49042575,55014674,61554945,68703001,76500255,84989960,94217249,104229175,115074751,126804990,139472945,153133749,167844655,183665076,200656625,218883155,238410799,259308010,281645601,305496785,330937215,358045024,386900865,417587951,450192095,484801750,521508049,560404845,601588751,645159180,691218385,739871499,791226575,845394626,902489665,962628745,1025931999,1092522680,1162527201,1236075175,1313299455,1394336174,1479324785,1568408101,1661732335,1759447140,1861705649,1968664515,2080483951,2197327770,2319363425,2446762049,2579698495,2718351376,2862903105,3013539935,3170451999,3333833350,3503882001,3680799965,3864793295,4056072124,4254850705,4461347451,4675784975,4898390130,5129394049,5369032185,5617544351,5875174760,6142172065,6418789399,6705284415,7001919326,7308960945,7626680725,7955354799,8295264020,8646694001,9009935155,9385282735,9773036874,10173502625,10586990001,11013814015,11454294720,11908757249,12377531855,12860953951,13359364150,13873108305,14402537549,14948008335,15509882476,16088527185,16684315115,17297624399,17928838690,18578347201,19246544745,19933831775,20640614424,21367304545,22114319751,22882083455,23671024910,24481579249,25314187525,26169296751,27047359940,27948836145,28874190499,29823894255,30798424826,31798265825,32823907105,33875844799,34954581360,36060625601,37194492735,38356704415,39547788774,40768280465,42018720701,43299657295,44611644700,45955244049,47331023195,48739556751,50181426130,51657219585,53167532249,54712966175,56294130376,57911640865,59566120695,61258199999,62988516030,64757713201,66566443125,68415364655,70305143924,72236454385,74209976851,76226399535,78286418090,80390735649,82540062865,84735117951,86976626720,89265322625,91601946799,93987248095,96421983126,98906916305,101442819885,104030473999,106670666700,109364194001,112111859915,114914476495,117772863874,120687850305,123660272201,126690974175,129780809080,132930638049,136141330535,139413764351,142748825710,146147409265,149610418149,153138764015,156733367076,160395156145,164125068675,167924050799,171793057370,175733052001,179745007105,183829903935,187988732624,192222492225,196532190751,200918845215,205383481670,209927135249,214550850205,219255679951,224042687100,228912943505,233867530299,238907537935,244034066226,249248224385,254551131065,259943914399,265427712040,271003671201,276672948695,282436710975,288296134174,294252404145,300306716501,306460276655,312714299860,319070011249,325528645875 mov $3,$0 mov $0,1 add $3,1 mov $1,$3 mov $4,$3 pow $4,2 add $0,$4 mul $1,$0 mov $2,$4 add $2,$0 mul $1,$2 sub $1,6 div $1,6 add $1,1
/*BEGIN_LEGAL Intel Open Source License Copyright (c) 2002-2015 Intel Corporation. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. Neither the name of the Intel Corporation nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE INTEL OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. END_LEGAL */ // This tool demonstrates how to use a "vitual register" to hold // thread-private tool data. We implement an MT-safe tool that // counts dynamic instructions, by accumulating each thread's // instruction count into a thread-private virtual register. // To allow the possibility of layering this tool on top of // other Pin tools we use PIN_ClaimToolRegister to allocate the // register we use. #include <iostream> #include <fstream> #include "pin.H" ofstream OutFile; KNOB<string> KnobOutputFile(KNOB_MODE_WRITEONCE, "pintool", "o", "inscount2_vregs.out", "specify output file name"); PIN_LOCK Lock; UINT64 TotalCount = 0; REG ScratchReg; // First parameter is the number of instructions in this basic block. // Second parameter is the current dynamic instruction count // Return the new count // ADDRINT PIN_FAST_ANALYSIS_CALL DoCount(ADDRINT numInsts, ADDRINT count) { return count + numInsts; } VOID ThreadStart(THREADID tid, CONTEXT *ctxt, INT32 flags, VOID *v) { // When the thread starts, zero the virtual register that holds the // dynamic instruction count. // PIN_SetContextReg(ctxt, ScratchReg, 0); } VOID ThreadFini(THREADID tid, const CONTEXT *ctxt, INT32 code, VOID *v) { // When the thread exits, accumulate the thread's dynamic instruction // count into the total. PIN_GetLock(&Lock, tid+1); TotalCount += PIN_GetContextReg(ctxt, ScratchReg); PIN_ReleaseLock(&Lock); } VOID Trace(TRACE trace, VOID *v) { for (BBL bbl = TRACE_BblHead(trace); BBL_Valid(bbl); bbl = BBL_Next(bbl)) { // The virtual register ScratchReg holds the dynamic instruction // count for each thread. DoCount returns the sum of the basic // block instruction count and G0, we write the result back to G0 BBL_InsertCall(bbl, IPOINT_ANYWHERE, AFUNPTR(DoCount), IARG_FAST_ANALYSIS_CALL, IARG_ADDRINT, BBL_NumIns(bbl), IARG_REG_VALUE, ScratchReg, IARG_RETURN_REGS, ScratchReg, IARG_END); } } VOID Fini(INT32 code, VOID *v) { OutFile << "Count= " << TotalCount << endl; OutFile.close(); } /* ===================================================================== */ /* Print Help Message */ /* ===================================================================== */ INT32 Usage() { cerr << "This Pintool counts the number of dynamic instructions executed" << endl; cerr << endl << KNOB_BASE::StringKnobSummary() << endl; return -1; } /* ===================================================================== */ /* Main */ /* ===================================================================== */ int main(int argc, char * argv[]) { // We accumlate counts into a register, make sure it is 64 bits to // avoid overflow ASSERTX(sizeof(ADDRINT) == sizeof(UINT64)); if (PIN_Init(argc, argv)) return Usage(); OutFile.open(KnobOutputFile.Value().c_str()); PIN_InitLock(&Lock); ScratchReg = PIN_ClaimToolRegister(); if (!REG_valid(ScratchReg)) { std::cerr << "Cannot allocate a scratch register.\n"; std::cerr << std::flush; return 1; } PIN_AddThreadStartFunction(ThreadStart, 0); PIN_AddThreadFiniFunction(ThreadFini, 0); PIN_AddFiniFunction(Fini, 0); TRACE_AddInstrumentFunction(Trace, 0); PIN_StartProgram(); return 0; }
.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 a, ff ldff(45), a ld b, 96 call lwaitly_b ld a, 80 ldff(68), a ld a, ff ld c, 69 ldff(c), a ldff(c), a ldff(c), a ldff(c), a ldff(c), a ldff(c), a xor a, a ldff(c), a ldff(c), a ld a, 40 ldff(41), a ld a, 02 ldff(ff), a xor a, a ldff(0f), a ei ld a, b inc a inc a ldff(45), a ld c, 41 .text@1000 lstatint: nop .text@11be ldff a, (c) jp lprint_a .text@7000 lprint_a: push af ld b, 91 call lwaitly_b xor a, a ldff(40), a ld bc, 7a00 ld hl, 8000 ld d, 00 lprint_copytiles: ld a, (bc) inc bc ld(hl++), a dec d jrnz lprint_copytiles pop af ld b, a srl a srl a srl a srl a ld(9800), a ld a, b and a, 0f ld(9801), a 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 00 00 08 08 22 22 41 41 7f 7f 41 41 41 41 41 41 00 00 7e 7e 41 41 41 41 7e 7e 41 41 41 41 7e 7e 00 00 3e 3e 41 41 40 40 40 40 40 40 41 41 3e 3e 00 00 7e 7e 41 41 41 41 41 41 41 41 41 41 7e 7e 00 00 7f 7f 40 40 40 40 7f 7f 40 40 40 40 7f 7f 00 00 7f 7f 40 40 40 40 7f 7f 40 40 40 40 40 40
.global s_prepare_buffers s_prepare_buffers: push %r10 push %r11 push %r14 push %rbp push %rbx push %rcx push %rdi push %rsi lea addresses_A_ht+0x17306, %rbp nop add $35888, %rdi mov $0x6162636465666768, %rcx movq %rcx, %xmm3 movups %xmm3, (%rbp) nop nop nop dec %r11 lea addresses_UC_ht+0x1c606, %r14 clflush (%r14) nop nop nop nop sub $59093, %r10 movb $0x61, (%r14) nop nop inc %r11 lea addresses_A_ht+0x7f0, %rsi lea addresses_WC_ht+0x5b06, %rdi nop nop nop xor $21134, %r14 mov $112, %rcx rep movsq nop nop nop and %rbp, %rbp lea addresses_D_ht+0x1c306, %rsi lea addresses_WC_ht+0xe4, %rdi nop nop nop nop nop and %r14, %r14 mov $104, %rcx rep movsq and %rbx, %rbx lea addresses_WT_ht+0x8586, %rsi lea addresses_A_ht+0xbf06, %rdi nop nop nop nop nop cmp $64175, %rbx mov $126, %rcx rep movsq nop xor $38224, %rsi lea addresses_WC_ht+0x1ec26, %rbp inc %r10 mov (%rbp), %r11 nop sub %rsi, %rsi lea addresses_WC_ht+0x471c, %rsi lea addresses_WT_ht+0x16706, %rdi nop nop add %r10, %r10 mov $107, %rcx rep movsb nop and $45393, %rcx lea addresses_WT_ht+0x1042c, %rcx nop nop nop nop and %r10, %r10 mov $0x6162636465666768, %r11 movq %r11, %xmm5 vmovups %ymm5, (%rcx) nop nop cmp %rsi, %rsi pop %rsi pop %rdi pop %rcx pop %rbx pop %rbp pop %r14 pop %r11 pop %r10 ret .global s_faulty_load s_faulty_load: push %r15 push %r9 push %rbx push %rcx push %rdx // Faulty Load lea addresses_D+0x1eb06, %rcx clflush (%rcx) nop nop nop add $60637, %rdx movb (%rcx), %bl lea oracles, %r15 and $0xff, %rbx shlq $12, %rbx mov (%r15,%rbx,1), %rbx pop %rdx pop %rcx pop %rbx pop %r9 pop %r15 ret /* <gen_faulty_load> [REF] {'src': {'same': False, 'congruent': 0, 'NT': False, 'type': 'addresses_D', 'size': 2, 'AVXalign': False}, 'OP': 'LOAD'} [Faulty Load] {'src': {'same': True, 'congruent': 0, 'NT': False, 'type': 'addresses_D', 'size': 1, 'AVXalign': False}, 'OP': 'LOAD'} <gen_prepare_buffer> {'OP': 'STOR', 'dst': {'same': False, 'congruent': 10, 'NT': False, 'type': 'addresses_A_ht', 'size': 16, 'AVXalign': False}} {'OP': 'STOR', 'dst': {'same': False, 'congruent': 3, 'NT': False, 'type': 'addresses_UC_ht', 'size': 1, 'AVXalign': False}} {'src': {'type': 'addresses_A_ht', 'congruent': 0, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_WC_ht', 'congruent': 11, 'same': False}} {'src': {'type': 'addresses_D_ht', 'congruent': 8, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_WC_ht', 'congruent': 0, 'same': False}} {'src': {'type': 'addresses_WT_ht', 'congruent': 7, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_A_ht', 'congruent': 10, 'same': False}} {'src': {'same': False, 'congruent': 4, 'NT': False, 'type': 'addresses_WC_ht', 'size': 8, 'AVXalign': False}, 'OP': 'LOAD'} {'src': {'type': 'addresses_WC_ht', 'congruent': 1, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_WT_ht', 'congruent': 10, 'same': False}} {'OP': 'STOR', 'dst': {'same': False, 'congruent': 0, 'NT': False, 'type': 'addresses_WT_ht', 'size': 32, 'AVXalign': False}} {'36': 21829} 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 */
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include "unicodeutil.h" #include <cstdlib> #include "unicodeutil-charprops.cpp" #include "unicodeutil-lowercase.cpp" namespace { class Initialize { public: Initialize() { Fast_UnicodeUtil::InitTables(); } }; Initialize _G_Initializer; } void Fast_UnicodeUtil::InitTables() { /** * Hack for Katakana accent marks (torgeir) */ _compCharProps[(0xFF9E >> 8)][(0xFF9E & 255)] |= 32; _compCharProps[(0xFF9F >> 8)][(0xFF9F & 255)] |= 32; } char * Fast_UnicodeUtil::utf8ncopy(char *dst, const ucs4_t *src, int maxdst, int maxsrc) { char * p = dst; char * edst = dst + maxdst; for (const ucs4_t *esrc(src + maxsrc); (src < esrc) && (*src != 0) && (p < edst); src++) { ucs4_t i(*src); if (i < 128) *p++ = i; else if (i < 0x800) { if (p + 1 >= edst) break; *p++ = (i >> 6) | 0xc0; *p++ = (i & 63) | 0x80; } else if (i < 0x10000) { if (p + 2 >= edst) break; *p++ = (i >> 12) | 0xe0; *p++ = ((i >> 6) & 63) | 0x80; *p++ = (i & 63) | 0x80; } else if (i < 0x200000) { if (p + 3 >= edst) break; *p++ = (i >> 18) | 0xf0; *p++ = ((i >> 12) & 63) | 0x80; *p++ = ((i >> 6) & 63) | 0x80; *p++ = (i & 63) | 0x80; } else if (i < 0x4000000) { if (p + 4 >= edst) break; *p++ = (i >> 24) | 0xf8; *p++ = ((i >> 18) & 63) | 0x80; *p++ = ((i >> 12) & 63) | 0x80; *p++ = ((i >> 6) & 63) | 0x80; *p++ = (i & 63) | 0x80; } else { if (p + 5 >= edst) break; *p++ = (i >> 30) | 0xfc; *p++ = ((i >> 24) & 63) | 0x80; *p++ = ((i >> 18) & 63) | 0x80; *p++ = ((i >> 12) & 63) | 0x80; *p++ = ((i >> 6) & 63) | 0x80; *p++ = (i & 63) | 0x80; } } if (p < edst) *p = 0; return p; } int Fast_UnicodeUtil::utf8cmp(const char *s1, const ucs4_t *s2) { ucs4_t i1; ucs4_t i2; const unsigned char *ps1 = reinterpret_cast<const unsigned char *>(s1); do { i1 = GetUTF8Char(ps1); i2 = *s2++; } while (i1 != 0 && i1 == i2); if (i1 > i2) return 1; if (i1 < i2) return -1; return 0; } size_t Fast_UnicodeUtil::ucs4strlen(const ucs4_t *str) { const ucs4_t *p = str; while (*p++ != 0) { /* Do nothing */ } return p - 1 - str; } ucs4_t * Fast_UnicodeUtil::ucs4copy(ucs4_t *dst, const char *src) { ucs4_t i; ucs4_t *p; const unsigned char *psrc = reinterpret_cast<const unsigned char *>(src); p = dst; while ((i = GetUTF8Char(psrc)) != 0) { if (i != _BadUTF8Char) *p++ = i; } *p = 0; return p; } ucs4_t Fast_UnicodeUtil::GetUTF8CharNonAscii(unsigned const char *&src) { ucs4_t retval; if (*src >= 0xc0) { if (src[1] < 0x80 || src[1] >= 0xc0) { src++; return _BadUTF8Char; } if (*src >= 0xe0) { /* 0xe0..0xff */ if (src[2] < 0x80 || src[2] >= 0xc0) { src += 2; return _BadUTF8Char; } if (*src >= 0xf0) { /* 0xf0..0xff */ if (src[3] < 0x80 || src[3] >= 0xc0) { src += 3; return _BadUTF8Char; } if (*src >= 0xf8) { /* 0xf8..0xff */ if (src[4] < 0x80 || src[4] >= 0xc0) { src += 4; return _BadUTF8Char; } if (*src >= 0xfc) { /* 0xfc..0xff */ if (src[5] < 0x80 || src[5] >= 0xc0) { src += 5; return _BadUTF8Char; } if (*src >= 0xfe) { /* 0xfe..0xff: INVALID */ src += 5; return _BadUTF8Char; } else { /* 0xfc..0xfd: 6 bytes */ retval = ((src[0] & 1) << 30) | ((src[1] & 63) << 24) | ((src[2] & 63) << 18) | ((src[3] & 63) << 12) | ((src[4] & 63) << 6) | (src[5] & 63); if (retval < 0x4000000u) { /* 6 bytes: >= 0x4000000 */ retval = _BadUTF8Char; } src += 6; return retval; } } else { /* 0xf8..0xfb: 5 bytes */ retval = ((src[0] & 3) << 24) | ((src[1] & 63) << 18) | ((src[2] & 63) << 12) | ((src[3] & 63) << 6) | (src[4] & 63); if (retval < 0x200000u) { /* 5 bytes: >= 0x200000 */ retval = _BadUTF8Char; } src += 5; return retval; } } else { /* 0xf0..0xf7: 4 bytes */ retval = ((src[0] & 7) << 18) | ((src[1] & 63) << 12) | ((src[2] & 63) << 6) | (src[3] & 63); if (retval < 0x10000) { /* 4 bytes: >= 0x10000 */ retval = _BadUTF8Char; } src += 4; return retval; } } else { /* 0xe0..0xef: 3 bytes */ retval = ((src[0] & 15) << 12) | ((src[1] & 63) << 6) | (src[2] & 63); if (retval < 0x800) { /* 3 bytes: >= 0x800 */ retval = _BadUTF8Char; } src += 3; return retval; } } else { /* 0xc0..0xdf: 2 bytes */ retval = ((src[0] & 31) << 6) | (src[1] & 63); if (retval < 0x80) { /* 2 bytes: >= 0x80 */ retval = _BadUTF8Char; } src += 2; return retval; } } else { /* 0x80..0xbf: INVALID */ src += 1; return _BadUTF8Char; } } ucs4_t Fast_UnicodeUtil::GetUTF8Char(unsigned const char *&src) { return (*src >= 0x80) ? GetUTF8CharNonAscii(src) : *src++; } /** Move forwards or backwards a number of characters within an UTF8 buffer * Modify pos to yield new position if possible * @param start A pointer to the start of the UTF8 buffer * @param length The length of the UTF8 buffer * @param pos A pointer to the current position within the UTF8 buffer, * updated to reflect new position upon return. @param pos will * point to the start of the offset'th character before or after the character * currently pointed to. * @param offset An offset (+/-) in number of UTF8 characters. * Offset 0 consequently yields a move to the start of the current character. * @return Number of bytes moved, or -1 if out of range. * If -1 is returned, pos is unchanged. */ #define UTF8_STARTCHAR(c) (!((c) & 0x80) || ((c) & 0x40)) int Fast_UnicodeUtil::UTF8move(unsigned const char* start, size_t length, unsigned const char*& pos, off_t offset) { int increment = offset > 0 ? 1 : -1; unsigned const char* p = pos; /* If running backward we first need to get to the start of * the current character, that's an extra step. * Similarly, if we are running forward an are at the start of a character, * we count that character as a step. */ if (increment < 0) { // Already at start? if (p < start) return -1; if (!offset) { if (p > start + length) return -1; } else if (p == start) return -1; // Initially pointing to the first invalid char? if (p == start + length) p += increment; else offset += increment; } else if (p >= start + length) return -1; else if (UTF8_STARTCHAR(*p)) offset += increment; for (; p >= start && p < start+length; p += increment) { /** Are we at start of a character? (both highest bits or none of them set) */ if (UTF8_STARTCHAR(*p)) offset -= increment; // We have "eaten" another character (independent of dir) if (offset == 0) break; } if (offset != 0) { offset -= increment; if (increment < 0) p -= increment; } if (offset == 0) // Enough room to make it.. { int moved = std::abs(p - pos); pos = p; return moved; } else return -1; }
// Copyright 2018 The Fuchsia 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 "mtk-thermal.h" #include <lib/device-protocol/pdev.h> #include <zircon/rights.h> #include <zircon/threads.h> #include <cmath> #include <memory> #include <ddk/binding.h> #include <ddk/metadata.h> #include <ddk/platform-defs.h> #include <ddktl/protocol/clock.h> #include <fbl/alloc_checker.h> #include <fbl/auto_lock.h> #include <soc/mt8167/mt8167-hw.h> namespace { constexpr uint32_t kTsCon1Addr = 0x10018604; constexpr uint32_t kAuxAdcCon1SetAddr = 0x11003008; constexpr uint32_t kAuxAdcCon1ClrAddr = 0x1100300c; constexpr uint32_t kAuxAdcDat11Addr = 0x11003040; constexpr uint32_t kAuxAdcChannel = 11; constexpr uint32_t kAuxAdcBits = 12; constexpr uint32_t kSensorCount = 3; constexpr uint32_t kSrcClkFreq = 66'000'000; constexpr uint32_t kSrcClkDivider = 256; constexpr uint32_t FreqToPeriodUnits(uint32_t freq_hz, uint32_t period) { return (kSrcClkFreq / (kSrcClkDivider * (period + 1) * freq_hz)) - 1; } constexpr uint32_t kThermalPeriod = 1023; constexpr uint32_t kFilterInterval = 0; constexpr uint32_t kSenseInterval = FreqToPeriodUnits(10, kThermalPeriod); constexpr uint32_t kAhbPollPeriod = FreqToPeriodUnits(10, kThermalPeriod); constexpr int32_t FixedPoint(int32_t value) { return (value * 10000) >> 12; } constexpr int32_t RawWithGain(int32_t raw, int32_t gain) { return (FixedPoint(raw) * 10000) / gain; } constexpr int32_t TempWithoutGain(int32_t temp, int32_t gain) { return (((temp * gain) / 10000) << 12) / 10000; } } // namespace namespace thermal { zx_status_t MtkThermal::Create(void* context, zx_device_t* parent) { zx_status_t status; ddk::CompositeProtocolClient composite(parent); if (!composite.is_valid()) { zxlogf(ERROR, "%s: ZX_PROTOCOL_COMPOSITE not available", __FILE__); return ZX_ERR_NOT_SUPPORTED; } zx_device_t* pdev_fragment; size_t actual; composite.GetFragments(&pdev_fragment, 1, &actual); if (actual != 1) { zxlogf(ERROR, "%s: could not get pdev_fragment", __FILE__); return ZX_ERR_NOT_SUPPORTED; } ddk::PDev pdev(pdev_fragment); if (!pdev.is_valid()) { zxlogf(ERROR, "%s: ZX_PROTOCOL_PDEV not available", __FILE__); return ZX_ERR_NOT_SUPPORTED; } pdev_device_info_t info; if ((status = pdev.GetDeviceInfo(&info)) != ZX_OK) { zxlogf(ERROR, "%s: pdev_get_device_info failed", __FILE__); return status; } std::optional<ddk::MmioBuffer> mmio; if ((status = pdev.MapMmio(0, &mmio)) != ZX_OK) { zxlogf(ERROR, "%s: MapMmio failed", __FILE__); return status; } std::optional<ddk::MmioBuffer> fuse_mmio; if ((status = pdev.MapMmio(1, &fuse_mmio)) != ZX_OK) { zxlogf(ERROR, "%s: MapMmio failed", __FILE__); return status; } std::optional<ddk::MmioBuffer> pll_mmio; if ((status = pdev.MapMmio(2, &pll_mmio)) != ZX_OK) { zxlogf(ERROR, "%s: MapMmio failed", __FILE__); return status; } std::optional<ddk::MmioBuffer> pmic_mmio; if ((status = pdev.MapMmio(3, &pmic_mmio)) != ZX_OK) { zxlogf(ERROR, "%s: MapMmio failed", __FILE__); return status; } std::optional<ddk::MmioBuffer> infracfg_mmio; if ((status = pdev.MapMmio(4, &infracfg_mmio)) != ZX_OK) { zxlogf(ERROR, "%s: MapMmio failed", __FILE__); return status; } fuchsia_hardware_thermal_ThermalDeviceInfo thermal_info; status = device_get_metadata(parent, DEVICE_METADATA_THERMAL_CONFIG, &thermal_info, sizeof(thermal_info), &actual); if (status != ZX_OK || actual != sizeof(thermal_info)) { zxlogf(ERROR, "%s: device_get_metadata failed", __FILE__); return status == ZX_OK ? ZX_ERR_INTERNAL : status; } zx::interrupt irq; if ((status = pdev.GetInterrupt(0, &irq)) != ZX_OK) { zxlogf(ERROR, "%s: Failed to get interrupt", __FILE__); return status; } zx::port port; if ((status = zx::port::create(0, &port)) != ZX_OK) { zxlogf(ERROR, "%s: Failed to create port", __FILE__); return status; } fbl::AllocChecker ac; std::unique_ptr<MtkThermal> device(new (&ac) MtkThermal( parent, std::move(*mmio), std::move(*pll_mmio), std::move(*pmic_mmio), std::move(*infracfg_mmio), composite, pdev, thermal_info, std::move(port), std::move(irq), TempCalibration0::Get().ReadFrom(&(*fuse_mmio)), TempCalibration1::Get().ReadFrom(&(*fuse_mmio)), TempCalibration2::Get().ReadFrom(&(*fuse_mmio)))); if (!ac.check()) { zxlogf(ERROR, "%s: MtkThermal alloc failed", __FILE__); return ZX_ERR_NO_MEMORY; } if ((status = device->Init()) != ZX_OK) { return status; } if ((status = device->DdkAdd("mtk-thermal")) != ZX_OK) { zxlogf(ERROR, "%s: DdkAdd failed", __FILE__); return status; } __UNUSED auto* dummy = device.release(); return ZX_OK; } zx_status_t MtkThermal::Init() { auto fragment_count = composite_.GetFragmentCount(); zx_device_t* fragments[fragment_count]; size_t actual; composite_.GetFragments(fragments, fragment_count, &actual); if (fragment_count != actual) { return ZX_ERR_INTERNAL; } // zeroth fragment is pdev for (uint32_t i = 1; i < fragment_count; i++) { clock_protocol_t clock; auto status = device_get_protocol(fragments[i], ZX_PROTOCOL_CLOCK, &clock); if (status != ZX_OK) { zxlogf(ERROR, "%s: Failed to get clock %u", __FILE__, i); return status; } status = clock_enable(&clock); if (status != ZX_OK) { zxlogf(ERROR, "%s: Failed to enable clock %u", __FILE__, i); return status; } } // Set the initial DVFS operating point. The bootloader sets it to 1.001 GHz @ 1.2 V. uint32_t op_idx = thermal_info_.opps[fuchsia_hardware_thermal_PowerDomain_BIG_CLUSTER_POWER_DOMAIN].count - 1; auto status = SetDvfsOpp(static_cast<uint16_t>(op_idx)); if (status != ZX_OK) { return status; } TempMonCtl0::Get().ReadFrom(&mmio_).disable_all().WriteTo(&mmio_); TempMsrCtl0::Get() .ReadFrom(&mmio_) .set_msrctl0(TempMsrCtl0::kSample1) .set_msrctl1(TempMsrCtl0::kSample1) .set_msrctl2(TempMsrCtl0::kSample1) .set_msrctl3(TempMsrCtl0::kSample1) .WriteTo(&mmio_); TempAhbTimeout::Get().FromValue(0xffffffff).WriteTo(&mmio_); TempAdcPnp::Get(0).FromValue(0).WriteTo(&mmio_); TempAdcPnp::Get(1).FromValue(1).WriteTo(&mmio_); TempAdcPnp::Get(2).FromValue(2).WriteTo(&mmio_); // Set the thermal controller to read from the spare registers, then wait for the dummy sensor // reading to end up in TempMsr0-2. TempMonCtl1::Get().ReadFrom(&mmio_).set_period(1).WriteTo(&mmio_); TempMonCtl2::Get().ReadFrom(&mmio_).set_sen_interval(1).WriteTo(&mmio_); TempAhbPoll::Get().FromValue(1).WriteTo(&mmio_); constexpr uint32_t dummy_temp = (1 << kAuxAdcBits) - 1; TempSpare::Get(0).FromValue(dummy_temp | (1 << kAuxAdcBits)).WriteTo(&mmio_); TempPnpMuxAddr::Get().FromValue(TempSpare::Get(2).addr() + MT8167_THERMAL_BASE).WriteTo(&mmio_); TempAdcMuxAddr::Get().FromValue(TempSpare::Get(2).addr() + MT8167_THERMAL_BASE).WriteTo(&mmio_); TempAdcEnAddr::Get().FromValue(TempSpare::Get(1).addr() + MT8167_THERMAL_BASE).WriteTo(&mmio_); TempAdcValidAddr::Get().FromValue(TempSpare::Get(0).addr() + MT8167_THERMAL_BASE).WriteTo(&mmio_); TempAdcVoltAddr::Get().FromValue(TempSpare::Get(0).addr() + MT8167_THERMAL_BASE).WriteTo(&mmio_); TempRdCtrl::Get().ReadFrom(&mmio_).set_diff(TempRdCtrl::kValidVoltageSame).WriteTo(&mmio_); TempAdcValidMask::Get() .ReadFrom(&mmio_) .set_polarity(TempAdcValidMask::kActiveHigh) .set_pos(kAuxAdcBits) .WriteTo(&mmio_); TempAdcVoltageShift::Get().FromValue(0).WriteTo(&mmio_); TempMonCtl0::Get().ReadFrom(&mmio_).enable_all().WriteTo(&mmio_); for (uint32_t i = 0; i < kSensorCount; i++) { auto msr = TempMsr::Get(i).ReadFrom(&mmio_); for (; msr.valid() == 0 || msr.reading() != dummy_temp; msr.ReadFrom(&mmio_)) { } } TempMonCtl0::Get().ReadFrom(&mmio_).disable_all().WriteTo(&mmio_); // Set the thermal controller to get temperature readings from the aux ADC. TempMonCtl1::Get().ReadFrom(&mmio_).set_period(kThermalPeriod).WriteTo(&mmio_); TempMonCtl2::Get() .ReadFrom(&mmio_) .set_sen_interval(kSenseInterval) .set_filt_interval(kFilterInterval) .WriteTo(&mmio_); TempAhbPoll::Get().FromValue(kAhbPollPeriod).WriteTo(&mmio_); TempAdcEn::Get().FromValue(1 << kAuxAdcChannel).WriteTo(&mmio_); TempAdcMux::Get().FromValue(1 << kAuxAdcChannel).WriteTo(&mmio_); TempPnpMuxAddr::Get().FromValue(kTsCon1Addr).WriteTo(&mmio_); TempAdcEnAddr::Get().FromValue(kAuxAdcCon1SetAddr).WriteTo(&mmio_); TempAdcMuxAddr::Get().FromValue(kAuxAdcCon1ClrAddr).WriteTo(&mmio_); TempAdcValidAddr::Get().FromValue(kAuxAdcDat11Addr).WriteTo(&mmio_); TempAdcVoltAddr::Get().FromValue(kAuxAdcDat11Addr).WriteTo(&mmio_); TempAdcWriteCtrl::Get().ReadFrom(&mmio_).set_mux_write_en(1).set_pnp_write_en(1).WriteTo(&mmio_); TempMonCtl0::Get().ReadFrom(&mmio_).enable_real().WriteTo(&mmio_); TempMsrCtl0::Get() .ReadFrom(&mmio_) .set_msrctl0(TempMsrCtl0::kSample4Drop2) .set_msrctl1(TempMsrCtl0::kSample4Drop2) .set_msrctl2(TempMsrCtl0::kSample4Drop2) .set_msrctl3(TempMsrCtl0::kSample4Drop2) .WriteTo(&mmio_); return StartThread(); } void MtkThermal::PmicWrite(uint16_t data, uint32_t addr) { while (PmicReadData::Get().ReadFrom(&pmic_mmio_).status() != PmicReadData::kStateIdle) { } PmicCmd::Get().FromValue(0).set_write(1).set_addr(addr).set_data(data).WriteTo(&pmic_mmio_); } float MtkThermal::RawToTemperature(uint32_t raw, uint32_t sensor) { int32_t vts = cal2_fuse_.get_vts3(); if (sensor == 0) { vts = cal0_fuse_.get_vts0(); } else if (sensor == 1) { vts = cal0_fuse_.get_vts1(); } else if (sensor == 2) { vts = cal2_fuse_.get_vts2(); } // See misc/mediatek/thermal/mt8167/mtk_ts_cpu.c in the Linux kernel source. int32_t gain = 10000 + FixedPoint(cal1_fuse_.get_adc_gain()); int32_t vts_with_gain = RawWithGain(vts - cal1_fuse_.get_adc_offset(), gain); int32_t slope = cal0_fuse_.slope_sign() == 0 ? cal0_fuse_.slope() : -cal0_fuse_.slope(); int32_t temp_c = ((RawWithGain(raw - cal1_fuse_.get_adc_offset(), gain) - vts_with_gain) * 5) / 6; temp_c = (temp_c * 100) / (165 + (cal1_fuse_.id() == 0 ? 0 : slope)); return static_cast<float>(cal0_fuse_.temp_offset() - temp_c) / 10.0f; } uint32_t MtkThermal::TemperatureToRaw(float temp, uint32_t sensor) { int32_t vts = cal2_fuse_.get_vts3(); if (sensor == 0) { vts = cal0_fuse_.get_vts0(); } else if (sensor == 1) { vts = cal0_fuse_.get_vts1(); } else if (sensor == 2) { vts = cal2_fuse_.get_vts2(); } int32_t gain = 10000 + FixedPoint(cal1_fuse_.get_adc_gain()); int32_t vts_with_gain = RawWithGain(vts - cal1_fuse_.get_adc_offset(), gain); int32_t slope = cal0_fuse_.slope_sign() == 0 ? cal0_fuse_.slope() : -cal0_fuse_.slope(); int32_t temp_c = static_cast<int32_t>(cal0_fuse_.temp_offset()) - static_cast<int32_t>(std::round(temp * 10.0f)); temp_c = (temp_c * (165 + (cal1_fuse_.id() == 0 ? 0 : slope))) / 100; return TempWithoutGain(((temp_c * 6) / 5) + vts_with_gain, gain) + cal1_fuse_.get_adc_offset(); } uint32_t MtkThermal::GetRawHot(float temp) { // Find the ADC value corresponding to this temperature for each sensor. ADC values are // inversely proportional to temperature, so the maximum represents the lowest temperature // required to hit the trip point. uint32_t raw_max = 0; for (uint32_t i = 0; i < kSensorCount; i++) { uint32_t raw = TemperatureToRaw(temp, i); if (raw > raw_max) { raw_max = raw; } } return raw_max; } uint32_t MtkThermal::GetRawCold(float temp) { uint32_t raw_min = UINT32_MAX; for (uint32_t i = 0; i < kSensorCount; i++) { uint32_t raw = TemperatureToRaw(temp, i); if (raw < raw_min) { raw_min = raw; } } return raw_min; } float MtkThermal::ReadTemperatureSensors() { uint32_t sensor_values[kSensorCount]; for (uint32_t i = 0; i < countof(sensor_values); i++) { auto msr = TempMsr::Get(i).ReadFrom(&mmio_); while (!msr.valid()) { msr.ReadFrom(&mmio_); } sensor_values[i] = msr.reading(); } float temp = RawToTemperature(sensor_values[0], 0); for (uint32_t i = 1; i < countof(sensor_values); i++) { float sensor_temp = RawToTemperature(sensor_values[i], i); if (sensor_temp > temp) { temp = sensor_temp; } } return temp; } zx_status_t MtkThermal::SetDvfsOpp(uint16_t op_idx) { const fuchsia_hardware_thermal_OperatingPoint& opps = thermal_info_.opps[fuchsia_hardware_thermal_PowerDomain_BIG_CLUSTER_POWER_DOMAIN]; if (op_idx >= opps.count) { return ZX_ERR_OUT_OF_RANGE; } uint32_t new_freq = opps.opp[op_idx].freq_hz; uint32_t new_volt = opps.opp[op_idx].volt_uv; if (new_volt > VprocCon10::kMaxVoltageUv || new_volt < VprocCon10::kMinVoltageUv) { return ZX_ERR_OUT_OF_RANGE; } fbl::AutoLock lock(&dvfs_lock_); auto armpll = ArmPllCon1::Get().ReadFrom(&pll_mmio_); uint32_t old_freq = armpll.frequency(); auto vproc = VprocCon10::Get().FromValue(0).set_voltage(new_volt); if (vproc.voltage() != new_volt) { // The requested voltage is not a multiple of the voltage step. return ZX_ERR_INVALID_ARGS; } // Switch to a stable clock before changing the ARMPLL frequency. auto infra_mux = InfraCfgClkMux::Get().ReadFrom(&infracfg_mmio_); infra_mux.set_ifr_mux_sel(InfraCfgClkMux::kIfrClk26M).WriteTo(&infracfg_mmio_); armpll.set_frequency(new_freq).WriteTo(&pll_mmio_); // Wait for the PLL to stabilize. zx::nanosleep(zx::deadline_after(zx::usec(20))); if (new_freq > old_freq) { PmicWrite(vproc.reg_value(), vproc.reg_addr()); infra_mux.set_ifr_mux_sel(InfraCfgClkMux::kIfrClkArmPll).WriteTo(&infracfg_mmio_); } else { infra_mux.set_ifr_mux_sel(InfraCfgClkMux::kIfrClkArmPll).WriteTo(&infracfg_mmio_); PmicWrite(vproc.reg_value(), vproc.reg_addr()); } current_op_idx_ = op_idx; return ZX_OK; } zx_status_t MtkThermal::DdkMessage(fidl_incoming_msg_t* msg, fidl_txn_t* txn) { return fuchsia_hardware_thermal_Device_dispatch(this, txn, msg, &fidl_ops); } zx_status_t MtkThermal::GetInfo(fidl_txn_t* txn) { return fuchsia_hardware_thermal_DeviceGetInfo_reply(txn, ZX_ERR_NOT_SUPPORTED, nullptr); } zx_status_t MtkThermal::GetDeviceInfo(fidl_txn_t* txn) { return fuchsia_hardware_thermal_DeviceGetDeviceInfo_reply(txn, ZX_OK, &thermal_info_); } zx_status_t MtkThermal::GetDvfsInfo(fuchsia_hardware_thermal_PowerDomain power_domain, fidl_txn_t* txn) { if (power_domain != fuchsia_hardware_thermal_PowerDomain_BIG_CLUSTER_POWER_DOMAIN) { fuchsia_hardware_thermal_DeviceGetDvfsInfo_reply(txn, ZX_ERR_NOT_SUPPORTED, nullptr); } const fuchsia_hardware_thermal_OperatingPoint* info = &thermal_info_.opps[fuchsia_hardware_thermal_PowerDomain_BIG_CLUSTER_POWER_DOMAIN]; return fuchsia_hardware_thermal_DeviceGetDvfsInfo_reply(txn, ZX_OK, info); } zx_status_t MtkThermal::GetTemperatureCelsius(fidl_txn_t* txn) { return fuchsia_hardware_thermal_DeviceGetTemperatureCelsius_reply(txn, ZX_OK, ReadTemperatureSensors()); } zx_status_t MtkThermal::GetStateChangeEvent(fidl_txn_t* txn) { return fuchsia_hardware_thermal_DeviceGetStateChangeEvent_reply(txn, ZX_ERR_NOT_SUPPORTED, ZX_HANDLE_INVALID); } zx_status_t MtkThermal::GetStateChangePort(fidl_txn_t* txn) { zx::port dup; zx_status_t status = GetPort(&dup); return fuchsia_hardware_thermal_DeviceGetStateChangePort_reply(txn, status, dup.release()); } zx_status_t MtkThermal::SetTripCelsius(uint32_t id, float temp, fidl_txn_t* txn) { return fuchsia_hardware_thermal_DeviceSetTripCelsius_reply(txn, ZX_ERR_NOT_SUPPORTED); } zx_status_t MtkThermal::GetDvfsOperatingPoint(fuchsia_hardware_thermal_PowerDomain power_domain, fidl_txn_t* txn) { if (power_domain != fuchsia_hardware_thermal_PowerDomain_BIG_CLUSTER_POWER_DOMAIN) { fuchsia_hardware_thermal_DeviceGetDvfsOperatingPoint_reply(txn, ZX_ERR_NOT_SUPPORTED, 0); } return fuchsia_hardware_thermal_DeviceGetDvfsOperatingPoint_reply(txn, ZX_OK, get_dvfs_opp()); } zx_status_t MtkThermal::SetDvfsOperatingPoint(uint16_t op_idx, fuchsia_hardware_thermal_PowerDomain power_domain, fidl_txn_t* txn) { if (power_domain != fuchsia_hardware_thermal_PowerDomain_BIG_CLUSTER_POWER_DOMAIN) { fuchsia_hardware_thermal_DeviceSetDvfsOperatingPoint_reply(txn, ZX_ERR_NOT_SUPPORTED); } return fuchsia_hardware_thermal_DeviceSetDvfsOperatingPoint_reply(txn, SetDvfsOpp(op_idx)); } zx_status_t MtkThermal::GetFanLevel(fidl_txn_t* txn) { return fuchsia_hardware_thermal_DeviceGetFanLevel_reply(txn, ZX_ERR_NOT_SUPPORTED, 0); } zx_status_t MtkThermal::SetFanLevel(uint32_t fan_level, fidl_txn_t* txn) { return fuchsia_hardware_thermal_DeviceSetFanLevel_reply(txn, ZX_ERR_NOT_SUPPORTED); } zx_status_t MtkThermal::SetTripPoint(size_t trip_pt) { zx_port_packet_t packet; packet.type = ZX_PKT_TYPE_USER; packet.key = trip_pt; zx_status_t status = port_.queue(&packet); if (status != ZX_OK) { zxlogf(ERROR, "%s: Faild to queue packet", __FILE__); return status; } uint32_t raw_hot = 0; uint32_t raw_cold = 0xfff; if (trip_pt > 0) { raw_cold = GetRawCold(thermal_info_.trip_point_info[trip_pt - 1].down_temp_celsius); } if (trip_pt < thermal_info_.num_trip_points - 1) { raw_hot = GetRawHot(thermal_info_.trip_point_info[trip_pt + 1].up_temp_celsius); } // Update the hot and cold interrupt thresholds for the new trip point. TempHotThreshold::Get().ReadFrom(&mmio_).set_threshold(raw_hot).WriteTo(&mmio_); TempHotToNormalThreshold::Get().ReadFrom(&mmio_).set_threshold(raw_hot).WriteTo(&mmio_); TempColdThreshold::Get().ReadFrom(&mmio_).set_threshold(raw_cold).WriteTo(&mmio_); return ZX_OK; } int MtkThermal::Thread() { const fuchsia_hardware_thermal_ThermalTemperatureInfo* trip_pts = thermal_info_.trip_point_info; TempProtCtl::Get().ReadFrom(&mmio_).set_strategy(TempProtCtl::kStrategyMaximum).WriteTo(&mmio_); TempProtStage3::Get() .FromValue(0) .set_threshold(GetRawHot(thermal_info_.critical_temp_celsius)) .WriteTo(&mmio_); float temp = ReadTemperatureSensors(); TempMsrCtl1::Get().ReadFrom(&mmio_).pause_real().WriteTo(&mmio_); // Set the initial trip point based on the current temperature. size_t trip_pt = 0; for (; trip_pt < thermal_info_.num_trip_points - 1; trip_pt++) { if (temp < trip_pts[trip_pt + 1].up_temp_celsius) { break; } } size_t last_trip_pt = trip_pt; SetTripPoint(trip_pt); TempMonInt::Get() .ReadFrom(&mmio_) .set_hot_en_0(1) .set_cold_en_0(1) .set_hot_en_1(1) .set_cold_en_1(1) .set_hot_en_2(1) .set_cold_en_2(1) .set_stage_3_en(1) .WriteTo(&mmio_); TempMsrCtl1::Get().ReadFrom(&mmio_).resume_real().WriteTo(&mmio_); while (1) { zx_status_t status = WaitForInterrupt(); if (status == ZX_ERR_CANCELED) { return thrd_success; } else if (status != ZX_OK) { zxlogf(ERROR, "%s: IRQ wait failed", __FILE__); return thrd_error; } auto int_status = TempMonIntStatus::Get().ReadFrom(&mmio_); auto int_enable = TempMonInt::Get().ReadFrom(&mmio_); uint32_t int_enable_old = int_enable.reg_value(); int_enable.set_reg_value(0).WriteTo(&mmio_); // Read the current temperature then pause periodic measurements so we don't get out of sync // with the hardware. temp = ReadTemperatureSensors(); TempMsrCtl1::Get().ReadFrom(&mmio_).pause_real().WriteTo(&mmio_); if (int_status.stage_3()) { trip_pt = thermal_info_.num_trip_points - 1; if (SetDvfsOpp(0) != ZX_OK) { zxlogf(ERROR, "%s: Failed to set safe operating point", __FILE__); return thrd_error; } } else if (int_status.hot_0() || int_status.hot_1() || int_status.hot_2()) { // Skip to the appropriate trip point for the current temperature. for (; trip_pt < thermal_info_.num_trip_points - 1; trip_pt++) { if (temp < trip_pts[trip_pt + 1].up_temp_celsius) { break; } } } else if (int_status.cold_0() || int_status.cold_1() || int_status.cold_2()) { for (; trip_pt > 0; trip_pt--) { if (temp > trip_pts[trip_pt - 1].down_temp_celsius) { break; } } } if (trip_pt != last_trip_pt) { SetTripPoint(trip_pt); } last_trip_pt = trip_pt; int_enable.set_reg_value(int_enable_old).WriteTo(&mmio_); TempMsrCtl1::Get().ReadFrom(&mmio_).resume_real().WriteTo(&mmio_); } return thrd_success; } zx_status_t MtkThermal::WaitForInterrupt() { return irq_.wait(nullptr); } zx_status_t MtkThermal::StartThread() { return thrd_status_to_zx_status(thrd_create_with_name( &thread_, [](void* arg) -> int { return reinterpret_cast<MtkThermal*>(arg)->Thread(); }, this, "mtk-thermal-thread")); } zx_status_t MtkThermal::StopThread() { irq_.destroy(); JoinThread(); return ZX_OK; } void MtkThermal::DdkRelease() { StopThread(); delete this; } } // namespace thermal static constexpr zx_driver_ops_t mtk_thermal_driver_ops = []() -> zx_driver_ops_t { zx_driver_ops_t ops = {}; ops.version = DRIVER_OPS_VERSION; ops.bind = thermal::MtkThermal::Create; return ops; }(); ZIRCON_DRIVER_BEGIN(mtk_thermal, mtk_thermal_driver_ops, "zircon", "0.1", 3) BI_ABORT_IF(NE, BIND_PROTOCOL, ZX_PROTOCOL_COMPOSITE), BI_ABORT_IF(NE, BIND_PLATFORM_DEV_VID, PDEV_VID_MEDIATEK), BI_MATCH_IF(EQ, BIND_PLATFORM_DEV_DID, PDEV_DID_MEDIATEK_THERMAL), ZIRCON_DRIVER_END(mtk_thermal)
// Copyright 2021 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 "net/dns/dns_config_service_linux.h" #include <netdb.h> #include <netinet/in.h> #include <resolv.h> #include <sys/socket.h> #include <sys/types.h> #include <map> #include <memory> #include <string> #include <type_traits> #include <utility> #include <vector> #include "base/bind.h" #include "base/callback.h" #include "base/check.h" #include "base/files/file_path.h" #include "base/files/file_path_watcher.h" #include "base/location.h" #include "base/logging.h" #include "base/metrics/histogram_macros.h" #include "base/sequence_checker.h" #include "base/threading/scoped_blocking_call.h" #include "base/time/time.h" #include "net/base/ip_endpoint.h" #include "net/dns/dns_config.h" #include "net/dns/nsswitch_reader.h" #include "net/dns/public/resolv_reader.h" #include "net/dns/serial_worker.h" #include "third_party/abseil-cpp/absl/types/optional.h" namespace net { namespace internal { namespace { const base::FilePath::CharType kFilePathHosts[] = FILE_PATH_LITERAL("/etc/hosts"); #ifndef _PATH_RESCONF // Normally defined in <resolv.h> #define _PATH_RESCONF FILE_PATH_LITERAL("/etc/resolv.conf") #endif constexpr base::FilePath::CharType kFilePathResolv[] = _PATH_RESCONF; #ifndef _PATH_NSSWITCH_CONF // Normally defined in <netdb.h> #define _PATH_NSSWITCH_CONF FILE_PATH_LITERAL("/etc/nsswitch.conf") #endif constexpr base::FilePath::CharType kFilePathNsswitch[] = _PATH_NSSWITCH_CONF; absl::optional<DnsConfig> ConvertResStateToDnsConfig( const struct __res_state& res) { absl::optional<std::vector<net::IPEndPoint>> nameservers = GetNameservers(res); DnsConfig dns_config; dns_config.unhandled_options = false; if (!nameservers.has_value()) return absl::nullopt; // Expected to be validated by GetNameservers() DCHECK(res.options & RES_INIT); dns_config.nameservers = std::move(nameservers.value()); dns_config.search.clear(); for (int i = 0; (i < MAXDNSRCH) && res.dnsrch[i]; ++i) { dns_config.search.emplace_back(res.dnsrch[i]); } dns_config.ndots = res.ndots; dns_config.fallback_period = base::Seconds(res.retrans); dns_config.attempts = res.retry; #if defined(RES_ROTATE) dns_config.rotate = res.options & RES_ROTATE; #endif #if !defined(RES_USE_DNSSEC) // Some versions of libresolv don't have support for the DO bit. In this // case, we proceed without it. static const int RES_USE_DNSSEC = 0; #endif // The current implementation assumes these options are set. They normally // cannot be overwritten by /etc/resolv.conf const unsigned kRequiredOptions = RES_RECURSE | RES_DEFNAMES | RES_DNSRCH; if ((res.options & kRequiredOptions) != kRequiredOptions) { dns_config.unhandled_options = true; return dns_config; } const unsigned kUnhandledOptions = RES_USEVC | RES_IGNTC | RES_USE_DNSSEC; if (res.options & kUnhandledOptions) { dns_config.unhandled_options = true; return dns_config; } if (dns_config.nameservers.empty()) return absl::nullopt; // If any name server is 0.0.0.0, assume the configuration is invalid. for (const IPEndPoint& nameserver : dns_config.nameservers) { if (nameserver.address().IsZero()) return absl::nullopt; } return dns_config; } // Helper to add the effective result of `action` to `in_out_parsed_behavior`. // Returns false if `action` results in inconsistent behavior (setting an action // for a status that already has a different action). bool SetActionBehavior(const NsswitchReader::ServiceAction& action, std::map<NsswitchReader::Status, NsswitchReader::Action>& in_out_parsed_behavior) { if (action.negated) { for (NsswitchReader::Status status : {NsswitchReader::Status::kSuccess, NsswitchReader::Status::kNotFound, NsswitchReader::Status::kUnavailable, NsswitchReader::Status::kTryAgain}) { if (status != action.status) { NsswitchReader::ServiceAction effective_action = { /*negated=*/false, status, action.action}; if (!SetActionBehavior(effective_action, in_out_parsed_behavior)) return false; } } } else { if (in_out_parsed_behavior.count(action.status) >= 1 && in_out_parsed_behavior[action.status] != action.action) { return false; } in_out_parsed_behavior[action.status] = action.action; } return true; } // Helper to determine if `actions` match `expected_actions`, meaning `actions` // contains no unknown statuses or actions and for every expectation set in // `expected_actions`, the expected action matches the effective result from // `actions`. bool AreActionsCompatible( const std::vector<NsswitchReader::ServiceAction>& actions, const std::map<NsswitchReader::Status, NsswitchReader::Action> expected_actions) { std::map<NsswitchReader::Status, NsswitchReader::Action> parsed_behavior; for (const NsswitchReader::ServiceAction& action : actions) { if (action.status == NsswitchReader::Status::kUnknown || action.action == NsswitchReader::Action::kUnknown) { return false; } if (!SetActionBehavior(action, parsed_behavior)) return false; } // Default behavior if not configured. if (parsed_behavior.count(NsswitchReader::Status::kSuccess) == 0) parsed_behavior[NsswitchReader::Status::kSuccess] = NsswitchReader::Action::kReturn; if (parsed_behavior.count(NsswitchReader::Status::kNotFound) == 0) parsed_behavior[NsswitchReader::Status::kNotFound] = NsswitchReader::Action::kContinue; if (parsed_behavior.count(NsswitchReader::Status::kUnavailable) == 0) parsed_behavior[NsswitchReader::Status::kUnavailable] = NsswitchReader::Action::kContinue; if (parsed_behavior.count(NsswitchReader::Status::kTryAgain) == 0) parsed_behavior[NsswitchReader::Status::kTryAgain] = NsswitchReader::Action::kContinue; for (const std::pair<const NsswitchReader::Status, NsswitchReader::Action>& expected : expected_actions) { if (parsed_behavior[expected.first] != expected.second) return false; } return true; } // These values are emitted in metrics. Entries should not be renumbered and // numeric values should never be reused. (See NsswitchIncompatibleReason in // tools/metrics/histograms/enums.xml.) enum class IncompatibleNsswitchReason { kFilesMissing = 0, kMultipleFiles = 1, kBadFilesActions = 2, kDnsMissing = 3, kBadDnsActions = 4, kBadMdnsMinimalActions = 5, kBadOtherServiceActions = 6, kUnknownService = 7, kIncompatibleService = 8, kMaxValue = kIncompatibleService }; void RecordIncompatibleNsswitchReason( IncompatibleNsswitchReason reason, absl::optional<NsswitchReader::Service> service_token) { UMA_HISTOGRAM_ENUMERATION("Net.DNS.DnsConfig.Nsswitch.IncompatibleReason", reason); if (service_token) { UMA_HISTOGRAM_ENUMERATION("Net.DNS.DnsConfig.Nsswitch.IncompatibleService", service_token.value()); } } bool IsNsswitchConfigCompatible( const std::vector<NsswitchReader::ServiceSpecification>& nsswitch_hosts) { bool files_found = false; for (const NsswitchReader::ServiceSpecification& specification : nsswitch_hosts) { switch (specification.service) { case NsswitchReader::Service::kUnknown: RecordIncompatibleNsswitchReason( IncompatibleNsswitchReason::kUnknownService, specification.service); return false; case NsswitchReader::Service::kFiles: if (files_found) { RecordIncompatibleNsswitchReason( IncompatibleNsswitchReason::kMultipleFiles, specification.service); return false; } files_found = true; // Chrome will use the result on HOSTS hit and otherwise continue to // DNS. `kFiles` entries must match that behavior to be compatible. if (!AreActionsCompatible(specification.actions, {{NsswitchReader::Status::kSuccess, NsswitchReader::Action::kReturn}, {NsswitchReader::Status::kNotFound, NsswitchReader::Action::kContinue}, {NsswitchReader::Status::kUnavailable, NsswitchReader::Action::kContinue}, {NsswitchReader::Status::kTryAgain, NsswitchReader::Action::kContinue}})) { RecordIncompatibleNsswitchReason( IncompatibleNsswitchReason::kBadFilesActions, specification.service); return false; } break; case NsswitchReader::Service::kDns: if (!files_found) { RecordIncompatibleNsswitchReason( IncompatibleNsswitchReason::kFilesMissing, /*service_token=*/absl::nullopt); return false; } // Chrome will always stop if DNS finds a result or will otherwise // fallback to the system resolver (and get whatever behavior is // configured in nsswitch.conf), so the only compatibility requirement // is that `kDns` entries are configured to return on success. if (!AreActionsCompatible(specification.actions, {{NsswitchReader::Status::kSuccess, NsswitchReader::Action::kReturn}})) { RecordIncompatibleNsswitchReason( IncompatibleNsswitchReason::kBadDnsActions, specification.service); return false; } // Ignore any entries after `kDns` because Chrome will fallback to the // system resolver if a result was not found in DNS. return true; case NsswitchReader::Service::kMdns: case NsswitchReader::Service::kMdns4: case NsswitchReader::Service::kMdns6: case NsswitchReader::Service::kResolve: RecordIncompatibleNsswitchReason( IncompatibleNsswitchReason::kIncompatibleService, specification.service); return false; case NsswitchReader::Service::kMdnsMinimal: case NsswitchReader::Service::kMdns4Minimal: case NsswitchReader::Service::kMdns6Minimal: // Always compatible as long as `kUnavailable` is `kContinue` because // the service is expected to always result in `kUnavailable` for any // names Chrome would attempt to resolve (non-*.local names because // Chrome always delegates *.local names to the system resolver). if (!AreActionsCompatible(specification.actions, {{NsswitchReader::Status::kUnavailable, NsswitchReader::Action::kContinue}})) { RecordIncompatibleNsswitchReason( IncompatibleNsswitchReason::kBadMdnsMinimalActions, specification.service); return false; } break; case NsswitchReader::Service::kMyHostname: case NsswitchReader::Service::kNis: // Similar enough to Chrome behavior (or unlikely to matter for Chrome // resolutions) to be considered compatible unless the actions do // something very weird to skip remaining services without a result. if (!AreActionsCompatible(specification.actions, {{NsswitchReader::Status::kNotFound, NsswitchReader::Action::kContinue}, {NsswitchReader::Status::kUnavailable, NsswitchReader::Action::kContinue}, {NsswitchReader::Status::kTryAgain, NsswitchReader::Action::kContinue}})) { RecordIncompatibleNsswitchReason( IncompatibleNsswitchReason::kBadOtherServiceActions, specification.service); return false; } break; } } RecordIncompatibleNsswitchReason(IncompatibleNsswitchReason::kDnsMissing, /*service_token=*/absl::nullopt); return false; } } // namespace class DnsConfigServiceLinux::Watcher : public DnsConfigService::Watcher { public: explicit Watcher(DnsConfigServiceLinux& service) : DnsConfigService::Watcher(service) {} ~Watcher() override = default; Watcher(const Watcher&) = delete; Watcher& operator=(const Watcher&) = delete; bool Watch() override { CheckOnCorrectSequence(); bool success = true; if (!resolv_watcher_.Watch( base::FilePath(kFilePathResolv), base::FilePathWatcher::Type::kNonRecursive, base::BindRepeating(&Watcher::OnResolvFilePathWatcherChange, base::Unretained(this)))) { LOG(ERROR) << "DNS config (resolv.conf) watch failed to start."; success = false; } if (!nsswitch_watcher_.Watch( base::FilePath(kFilePathNsswitch), base::FilePathWatcher::Type::kNonRecursive, base::BindRepeating(&Watcher::OnNsswitchFilePathWatcherChange, base::Unretained(this)))) { LOG(ERROR) << "DNS nsswitch.conf watch failed to start."; success = false; } if (!hosts_watcher_.Watch( base::FilePath(kFilePathHosts), base::FilePathWatcher::Type::kNonRecursive, base::BindRepeating(&Watcher::OnHostsFilePathWatcherChange, base::Unretained(this)))) { LOG(ERROR) << "DNS hosts watch failed to start."; success = false; } return success; } private: void OnResolvFilePathWatcherChange(const base::FilePath& path, bool error) { UMA_HISTOGRAM_BOOLEAN("Net.DNS.DnsConfig.Resolv.FileChange", true); OnConfigChanged(!error); } void OnNsswitchFilePathWatcherChange(const base::FilePath& path, bool error) { UMA_HISTOGRAM_BOOLEAN("Net.DNS.DnsConfig.Nsswitch.FileChange", true); OnConfigChanged(!error); } void OnHostsFilePathWatcherChange(const base::FilePath& path, bool error) { OnHostsChanged(!error); } base::FilePathWatcher resolv_watcher_; base::FilePathWatcher nsswitch_watcher_; base::FilePathWatcher hosts_watcher_; }; // A SerialWorker that uses libresolv to initialize res_state and converts // it to DnsConfig. class DnsConfigServiceLinux::ConfigReader : public SerialWorker { public: explicit ConfigReader(DnsConfigServiceLinux& service, std::unique_ptr<ResolvReader> resolv_reader, std::unique_ptr<NsswitchReader> nsswitch_reader) : service_(&service), work_item_(std::make_unique<WorkItem>(std::move(resolv_reader), std::move(nsswitch_reader))) { // Allow execution on another thread; nothing thread-specific about // constructor. DETACH_FROM_SEQUENCE(sequence_checker_); } ~ConfigReader() override = default; ConfigReader(const ConfigReader&) = delete; ConfigReader& operator=(const ConfigReader&) = delete; std::unique_ptr<SerialWorker::WorkItem> CreateWorkItem() override { // Reuse same `WorkItem` to allow reuse of contained reader objects. DCHECK(work_item_); return std::move(work_item_); } void OnWorkFinished(std::unique_ptr<SerialWorker::WorkItem> serial_worker_work_item) override { DCHECK(serial_worker_work_item); DCHECK(!work_item_); DCHECK(!IsCancelled()); work_item_.reset(static_cast<WorkItem*>(serial_worker_work_item.release())); if (work_item_->dns_config_.has_value()) { service_->OnConfigRead(std::move(work_item_->dns_config_).value()); } else { LOG(WARNING) << "Failed to read DnsConfig."; } } private: class WorkItem : public SerialWorker::WorkItem { public: WorkItem(std::unique_ptr<ResolvReader> resolv_reader, std::unique_ptr<NsswitchReader> nsswitch_reader) : resolv_reader_(std::move(resolv_reader)), nsswitch_reader_(std::move(nsswitch_reader)) { DCHECK(resolv_reader_); DCHECK(nsswitch_reader_); } void DoWork() override { base::ScopedBlockingCall scoped_blocking_call( FROM_HERE, base::BlockingType::MAY_BLOCK); { std::unique_ptr<ScopedResState> res = resolv_reader_->GetResState(); if (res) { dns_config_ = ConvertResStateToDnsConfig(res->state()); } } UMA_HISTOGRAM_BOOLEAN("Net.DNS.DnsConfig.Resolv.Read", dns_config_.has_value()); if (!dns_config_.has_value()) return; UMA_HISTOGRAM_BOOLEAN("Net.DNS.DnsConfig.Resolv.Valid", dns_config_->IsValid()); UMA_HISTOGRAM_BOOLEAN("Net.DNS.DnsConfig.Resolv.Compatible", !dns_config_->unhandled_options); // Override `fallback_period` value to match default setting on // Windows. dns_config_->fallback_period = kDnsDefaultFallbackPeriod; if (dns_config_ && !dns_config_->unhandled_options) { std::vector<NsswitchReader::ServiceSpecification> nsswitch_hosts = nsswitch_reader_->ReadAndParseHosts(); UMA_HISTOGRAM_COUNTS_100("Net.DNS.DnsConfig.Nsswitch.NumServices", nsswitch_hosts.size()); dns_config_->unhandled_options = !IsNsswitchConfigCompatible(nsswitch_hosts); UMA_HISTOGRAM_BOOLEAN("Net.DNS.DnsConfig.Nsswitch.Compatible", !dns_config_->unhandled_options); } } private: friend class ConfigReader; absl::optional<DnsConfig> dns_config_; std::unique_ptr<ResolvReader> resolv_reader_; std::unique_ptr<NsswitchReader> nsswitch_reader_; }; // Raw pointer to owning DnsConfigService. DnsConfigServiceLinux* const service_; // Null while the `WorkItem` is running on the `ThreadPool`. std::unique_ptr<WorkItem> work_item_; }; DnsConfigServiceLinux::DnsConfigServiceLinux() : DnsConfigService(kFilePathHosts) { // Allow constructing on one thread and living on another. DETACH_FROM_SEQUENCE(sequence_checker_); } DnsConfigServiceLinux::~DnsConfigServiceLinux() { if (config_reader_) config_reader_->Cancel(); } void DnsConfigServiceLinux::ReadConfigNow() { if (!config_reader_) CreateReader(); config_reader_->WorkNow(); } bool DnsConfigServiceLinux::StartWatching() { CreateReader(); watcher_ = std::make_unique<Watcher>(*this); return watcher_->Watch(); } void DnsConfigServiceLinux::CreateReader() { DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); DCHECK(!config_reader_); DCHECK(resolv_reader_); DCHECK(nsswitch_reader_); config_reader_ = std::make_unique<ConfigReader>( *this, std::move(resolv_reader_), std::move(nsswitch_reader_)); } } // namespace internal // static std::unique_ptr<DnsConfigService> DnsConfigService::CreateSystemService() { return std::make_unique<internal::DnsConfigServiceLinux>(); } } // namespace net
; A303331: a(n) is the minimum size of a square integer grid allowing all triples of n points to form triangles of different areas. ; Submitted by Jamie Morken(l1) ; 0,1,1,2,4,6,9,11,15,19 pow $0,2 add $0,30 mul $0,5 div $0,22 sub $0,6
;------------------------------------------------------------------------------ ; @file ; Main routine of the pre-SEC code up through the jump into SEC ; ; Copyright (c) 2008 - 2009, Intel Corporation. All rights reserved.<BR> ; SPDX-License-Identifier: BSD-2-Clause-Patent ; ;------------------------------------------------------------------------------ BITS 16 ; ; Modified: EBX, ECX, EDX, EBP ; ; @param[in,out] RAX/EAX Initial value of the EAX register ; (BIST: Built-in Self Test) ; @param[in,out] DI 'BP': boot-strap processor, or ; 'AP': application processor ; @param[out] RBP/EBP Address of Boot Firmware Volume (BFV) ; @param[out] DS Selector allowing flat access to all addresses ; @param[out] ES Selector allowing flat access to all addresses ; @param[out] FS Selector allowing flat access to all addresses ; @param[out] GS Selector allowing flat access to all addresses ; @param[out] SS Selector allowing flat access to all addresses ; ; @return None This routine jumps to SEC and does not return ; Main16: OneTimeCall EarlyInit16 ; ; Transition the processor from 16-bit real mode to 32-bit flat mode ; OneTimeCall TransitionFromReal16To32BitFlat BITS 32 ; Clear the WorkArea header. The SEV probe routines will populate the ; work area when detected. mov byte[WORK_AREA_GUEST_TYPE], 0 %ifdef ARCH_X64 jmp SearchBfv ; ; Entry point of Main32 ; Main32: OneTimeCall InitTdx SearchBfv: %endif ; ; Search for the Boot Firmware Volume (BFV) ; OneTimeCall Flat32SearchForBfvBase ; ; EBP - Start of BFV ; ; ; Search for the SEC entry point ; OneTimeCall Flat32SearchForSecEntryPoint ; ; ESI - SEC Core entry point ; EBP - Start of BFV ; %ifdef ARCH_IA32 ; ; Restore initial EAX value into the EAX register ; mov eax, esp ; ; Jump to the 32-bit SEC entry point ; jmp esi %else ; ; Transition the processor from 32-bit flat mode to 64-bit flat mode ; OneTimeCall Transition32FlatTo64Flat BITS 64 ; ; Some values were calculated in 32-bit mode. Make sure the upper ; 32-bits of 64-bit registers are zero for these values. ; mov rax, 0x00000000ffffffff and rsi, rax and rbp, rax and rsp, rax ; ; RSI - SEC Core entry point ; RBP - Start of BFV ; ; ; Restore initial EAX value into the RAX register ; mov rax, rsp ; ; Jump to the 64-bit SEC entry point ; jmp rsi %endif
; script start: ; attribution ; value real 3.7 set r2 3700 ; a: r3 set r3 0 store r3 r2 ; asm ; a: r2 set r2 0 load r2 r2 writenumber r2 stop
; A081065: Numbers n such that n^2 = (1/3)*(n+floor(sqrt(3)*n*floor(sqrt(3)*n))). ; 2,24,330,4592,63954,890760,12406682,172802784,2406832290,33522849272,466913057514,6503259955920,90578726325362,1261598908599144,17571805994062650,244743685008277952,3408839784121828674,47479013292697323480,661297346313640700042 add $0,1 mul $0,2 sub $0,1 mov $1,2 mov $2,4 lpb $0 sub $0,1 add $1,$2 add $1,$2 add $2,$1 lpe div $1,6 add $1,1 mov $0,$1
; Open IP V1.01  2004 Marcel Kilgus section ip xdef ip_open xref io_ckchn include 'dev8_keys_err' include 'dev8_keys_qlv' include 'dev8_smsq_qpc_ip_data' include 'dev8_smsq_qpc_keys' stk.reg reg d3/a0 stk.a0 equ 4 ip_open movem.l stk.reg,-(sp) move.l #$dfdfdfdf,d0 move.w (a0)+,d2 and.l (a0)+,d0 cmp.l tcp_name,d0 beq.s ipo_found cmp.l udp_name,d0 beq.s ipo_found cmp.l sck_name,d0 beq.s ipo_sck moveq #err.fdnf,d0 bra.s ipo_exit tcp_name dc.b 'TCP_' udp_name dc.b 'UDP_' sck_name dc.b 'SCK_' ipo_sck cmp.l #4,d3 ; is a channel id in d3? bls.s ipo_found ; ... probably not movem.l d7/a0/a3,-(sp) moveq #0,d0 move.l d3,a0 ; check channel it jsr io_ckchn tst.l d0 bmi.s ipo_ipar cmp.l #chn.id,chn_id(a0) ; really IP channel? bne.s ipo_ipar ; ... no move.l chn_data(a0),d3 ; data address for that channel movem.l (sp)+,d7/a0/a3 ipo_found moveq #chn_end,d1 move.w mem.achp,a2 jsr (a2) bne.s ipo_exit move.l #chn.id,chn_id(a0) move.l a0,a2 ; remember chan-block move.l stk.a0(sp),a1 ; device name dc.w qpc.ipopn ; returns internal ptr in a0 bne.s ipo_error move.l a0,chn_data(a2) ; remember internal ptr in chan block move.l a2,stk.a0(sp) ; return allocated chan block in a0 ipo_exit movem.l (sp)+,stk.reg rts ipo_ipar movem.l (sp)+,d7/a0/a3 moveq #err.ipar,d0 bra.s ipo_exit ipo_error move.l d0,-(sp) move.l a2,a0 move.w mem.rchp,a2 ; error, release CDB jsr (a2) move.l (sp)+,d0 bra.s ipo_exit end
assume cs:codesg codesg segment s: db 4096 dup (0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0) jmp s ; jmp short s jmp near ptr s jmp far ptr s codesg ends end s
.global s_prepare_buffers s_prepare_buffers: push %r10 push %r15 push %rax push %rbx push %rcx push %rdi push %rsi lea addresses_UC_ht+0x1592b, %rax nop and $31565, %rbx movups (%rax), %xmm1 vpextrq $1, %xmm1, %r15 nop nop cmp $37781, %rsi lea addresses_WC_ht+0xb713, %rsi lea addresses_D_ht+0x11193, %rdi nop nop sub $659, %r10 mov $56, %rcx rep movsl nop nop nop nop nop and $4457, %rsi lea addresses_WC_ht+0x1e5d3, %rsi lea addresses_WT_ht+0x14193, %rdi nop nop sub $49281, %r15 mov $108, %rcx rep movsl nop nop nop nop xor %rcx, %rcx pop %rsi pop %rdi pop %rcx pop %rbx pop %rax pop %r15 pop %r10 ret .global s_faulty_load s_faulty_load: push %r10 push %r15 push %r8 push %rax push %rcx push %rdi // Faulty Load lea addresses_D+0x18593, %r15 nop nop nop nop nop sub %r8, %r8 mov (%r15), %rdi lea oracles, %rcx and $0xff, %rdi shlq $12, %rdi mov (%rcx,%rdi,1), %rdi pop %rdi pop %rcx pop %rax pop %r8 pop %r15 pop %r10 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_D', 'NT': False, 'AVXalign': False, 'size': 16, 'congruent': 0}} [Faulty Load] {'OP': 'LOAD', 'src': {'same': True, 'type': 'addresses_D', 'NT': False, 'AVXalign': False, 'size': 8, 'congruent': 0}} <gen_prepare_buffer> {'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_UC_ht', 'NT': False, 'AVXalign': False, 'size': 16, 'congruent': 0}} {'OP': 'REPM', 'src': {'same': True, 'congruent': 5, 'type': 'addresses_WC_ht'}, 'dst': {'same': True, 'congruent': 10, 'type': 'addresses_D_ht'}} {'OP': 'REPM', 'src': {'same': False, 'congruent': 6, 'type': 'addresses_WC_ht'}, 'dst': {'same': False, 'congruent': 9, 'type': 'addresses_WT_ht'}} {'36': 21829} 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 */
; A158058: a(n) = 16*n^2 - 2*n. ; 14,60,138,248,390,564,770,1008,1278,1580,1914,2280,2678,3108,3570,4064,4590,5148,5738,6360,7014,7700,8418,9168,9950,10764,11610,12488,13398,14340,15314,16320,17358,18428,19530,20664,21830,23028,24258,25520,26814,28140,29498,30888,32310,33764,35250,36768,38318,39900,41514,43160,44838,46548,48290,50064,51870,53708,55578,57480,59414,61380,63378,65408,67470,69564,71690,73848,76038,78260,80514,82800,85118,87468,89850,92264,94710,97188,99698,102240,104814,107420,110058,112728,115430,118164,120930 mov $1,8 mul $1,$0 add $1,15 mul $1,$0 mul $1,2 add $1,14 mov $0,$1
; A066446: Number of unordered divisor pairs of n. ; 0,1,1,3,1,6,1,6,3,6,1,15,1,6,6,10,1,15,1,15,6,6,1,28,3,6,6,15,1,28,1,15,6,6,6,36,1,6,6,28,1,28,1,15,15,6,1,45,3,15,6,15,1,28,6,28,6,6,1,66,1,6,15,21,6,28,1,15,6,28,1,66,1,6,15,15,6,28,1,45,10,6,1,66,6,6,6,28,1,66,6,15,6,6,6,66,1,15,15,36 seq $0,5 ; d(n) (also called tau(n) or sigma_0(n)), the number of divisors of n. bin $0,2
.MODEL SMALL .STACK 100H .DATA CR EQU 0DH LF EQU 0AH X DB ? Y DB ? Z DB ? TEMP DB ? MSG1 DB 'ENTER FIRST NUMBER: $' MSG2 DB CR,LF,'ENTER SECOND NUMBER: $' MSG3 DB CR,LF,'ENTER THIRD NUMBER: $' MSG4 DB CR,LF,'SECOND LARGEST NUMBER : $' MSG5 DB CR,LF,'ALL THE NUMBERS ARE EQUAL$' .CODE MAIN PROC ;DATA SEGMENT INITIALIZATION MOV AX, @DATA MOV DS, AX LEA DX, MSG1 MOV AH, 9 INT 21H MOV AH, 1 INT 21H MOV X,AL LEA DX, MSG2 MOV AH, 9 INT 21H MOV AH, 1 INT 21H MOV Y,AL LEA DX, MSG3 MOV AH, 9 INT 21H MOV AH, 1 INT 21H MOV Z,AL MOV AL,Y CMP X,AL JGE ELSE1 MOV AL,Y MOV TEMP,AL MOV AL,X MOV Y,AL MOV AL,TEMP MOV X,AL ELSE1: MOV AL,Z CMP X,AL JGE ELSE2 MOV AL,Z MOV TEMP,AL MOV AL,X MOV Z,AL MOV AL,TEMP MOV X,AL ELSE2: MOV AL,Z CMP Y,AL JGE ELSE3 MOV AL,Z MOV TEMP,AL MOV AL,Y MOV Z,AL MOV AL,TEMP MOV Y,AL ELSE3: ;NOW THE INPUT IS X>=Y>=Z MOV AL,Y CMP X,AL JLE ELSE4 ;X>Y>=Z ;PRINT Y LEA DX, MSG4 MOV AH, 9 INT 21H MOV DL,Y MOV AH, 2 INT 21H JMP EN ELSE4: ;X=Y>=Z MOV AL,Z CMP Y,AL JLE ELSE5 ;X=Y>Z ;PRINT Z LEA DX, MSG4 MOV AH, 9 INT 21H MOV DL,Z MOV AH, 2 INT 21H JMP EN ELSE5: ;X=Y=Z ;ALL NUMBERS ARE EQUAL LEA DX, MSG5 MOV AH, 9 INT 21H EN: ;DOS EXIT MOV AH, 4CH INT 21H MAIN ENDP END MAIN
;CodeVisionAVR C Compiler V3.12 Advanced ;(C) Copyright 1998-2014 Pavel Haiduc, HP InfoTech s.r.l. ;http://www.hpinfotech.com ;Build configuration : Debug ;Chip type : ATmega16 ;Program type : Application ;Clock frequency : 8.000000 MHz ;Memory model : Small ;Optimize for : Size ;(s)printf features : int, width ;(s)scanf features : int, width ;External RAM size : 0 ;Data Stack size : 256 byte(s) ;Heap size : 0 byte(s) ;Promote 'char' to 'int': Yes ;'char' is unsigned : Yes ;8 bit enums : Yes ;Global 'const' stored in FLASH: No ;Enhanced function parameter passing: Yes ;Enhanced core instructions: On ;Automatic register allocation for global variables: On ;Smart register allocation: On #define _MODEL_SMALL_ #pragma AVRPART ADMIN PART_NAME ATmega16 #pragma AVRPART MEMORY PROG_FLASH 16384 #pragma AVRPART MEMORY EEPROM 512 #pragma AVRPART MEMORY INT_SRAM SIZE 1024 #pragma AVRPART MEMORY INT_SRAM START_ADDR 0x60 #define CALL_SUPPORTED 1 .LISTMAC .EQU UDRE=0x5 .EQU RXC=0x7 .EQU USR=0xB .EQU UDR=0xC .EQU SPSR=0xE .EQU SPDR=0xF .EQU EERE=0x0 .EQU EEWE=0x1 .EQU EEMWE=0x2 .EQU EECR=0x1C .EQU EEDR=0x1D .EQU EEARL=0x1E .EQU EEARH=0x1F .EQU WDTCR=0x21 .EQU MCUCR=0x35 .EQU GICR=0x3B .EQU SPL=0x3D .EQU SPH=0x3E .EQU SREG=0x3F .DEF R0X0=R0 .DEF R0X1=R1 .DEF R0X2=R2 .DEF R0X3=R3 .DEF R0X4=R4 .DEF R0X5=R5 .DEF R0X6=R6 .DEF R0X7=R7 .DEF R0X8=R8 .DEF R0X9=R9 .DEF R0XA=R10 .DEF R0XB=R11 .DEF R0XC=R12 .DEF R0XD=R13 .DEF R0XE=R14 .DEF R0XF=R15 .DEF R0X10=R16 .DEF R0X11=R17 .DEF R0X12=R18 .DEF R0X13=R19 .DEF R0X14=R20 .DEF R0X15=R21 .DEF R0X16=R22 .DEF R0X17=R23 .DEF R0X18=R24 .DEF R0X19=R25 .DEF R0X1A=R26 .DEF R0X1B=R27 .DEF R0X1C=R28 .DEF R0X1D=R29 .DEF R0X1E=R30 .DEF R0X1F=R31 .EQU __SRAM_START=0x0060 .EQU __SRAM_END=0x045F .EQU __DSTACK_SIZE=0x0100 .EQU __HEAP_SIZE=0x0000 .EQU __CLEAR_SRAM_SIZE=__SRAM_END-__SRAM_START+1 .MACRO __CPD1N CPI R30,LOW(@0) LDI R26,HIGH(@0) CPC R31,R26 LDI R26,BYTE3(@0) CPC R22,R26 LDI R26,BYTE4(@0) CPC R23,R26 .ENDM .MACRO __CPD2N CPI R26,LOW(@0) LDI R30,HIGH(@0) CPC R27,R30 LDI R30,BYTE3(@0) CPC R24,R30 LDI R30,BYTE4(@0) CPC R25,R30 .ENDM .MACRO __CPWRR CP R@0,R@2 CPC R@1,R@3 .ENDM .MACRO __CPWRN CPI R@0,LOW(@2) LDI R30,HIGH(@2) CPC R@1,R30 .ENDM .MACRO __ADDB1MN SUBI R30,LOW(-@0-(@1)) .ENDM .MACRO __ADDB2MN SUBI R26,LOW(-@0-(@1)) .ENDM .MACRO __ADDW1MN SUBI R30,LOW(-@0-(@1)) SBCI R31,HIGH(-@0-(@1)) .ENDM .MACRO __ADDW2MN SUBI R26,LOW(-@0-(@1)) SBCI R27,HIGH(-@0-(@1)) .ENDM .MACRO __ADDW1FN SUBI R30,LOW(-2*@0-(@1)) SBCI R31,HIGH(-2*@0-(@1)) .ENDM .MACRO __ADDD1FN SUBI R30,LOW(-2*@0-(@1)) SBCI R31,HIGH(-2*@0-(@1)) SBCI R22,BYTE3(-2*@0-(@1)) .ENDM .MACRO __ADDD1N SUBI R30,LOW(-@0) SBCI R31,HIGH(-@0) SBCI R22,BYTE3(-@0) SBCI R23,BYTE4(-@0) .ENDM .MACRO __ADDD2N SUBI R26,LOW(-@0) SBCI R27,HIGH(-@0) SBCI R24,BYTE3(-@0) SBCI R25,BYTE4(-@0) .ENDM .MACRO __SUBD1N SUBI R30,LOW(@0) SBCI R31,HIGH(@0) SBCI R22,BYTE3(@0) SBCI R23,BYTE4(@0) .ENDM .MACRO __SUBD2N SUBI R26,LOW(@0) SBCI R27,HIGH(@0) SBCI R24,BYTE3(@0) SBCI R25,BYTE4(@0) .ENDM .MACRO __ANDBMNN LDS R30,@0+(@1) ANDI R30,LOW(@2) STS @0+(@1),R30 .ENDM .MACRO __ANDWMNN LDS R30,@0+(@1) ANDI R30,LOW(@2) STS @0+(@1),R30 LDS R30,@0+(@1)+1 ANDI R30,HIGH(@2) STS @0+(@1)+1,R30 .ENDM .MACRO __ANDD1N ANDI R30,LOW(@0) ANDI R31,HIGH(@0) ANDI R22,BYTE3(@0) ANDI R23,BYTE4(@0) .ENDM .MACRO __ANDD2N ANDI R26,LOW(@0) ANDI R27,HIGH(@0) ANDI R24,BYTE3(@0) ANDI R25,BYTE4(@0) .ENDM .MACRO __ORBMNN LDS R30,@0+(@1) ORI R30,LOW(@2) STS @0+(@1),R30 .ENDM .MACRO __ORWMNN LDS R30,@0+(@1) ORI R30,LOW(@2) STS @0+(@1),R30 LDS R30,@0+(@1)+1 ORI R30,HIGH(@2) STS @0+(@1)+1,R30 .ENDM .MACRO __ORD1N ORI R30,LOW(@0) ORI R31,HIGH(@0) ORI R22,BYTE3(@0) ORI R23,BYTE4(@0) .ENDM .MACRO __ORD2N ORI R26,LOW(@0) ORI R27,HIGH(@0) ORI R24,BYTE3(@0) ORI R25,BYTE4(@0) .ENDM .MACRO __DELAY_USB LDI R24,LOW(@0) __DELAY_USB_LOOP: DEC R24 BRNE __DELAY_USB_LOOP .ENDM .MACRO __DELAY_USW LDI R24,LOW(@0) LDI R25,HIGH(@0) __DELAY_USW_LOOP: SBIW R24,1 BRNE __DELAY_USW_LOOP .ENDM .MACRO __GETD1S LDD R30,Y+@0 LDD R31,Y+@0+1 LDD R22,Y+@0+2 LDD R23,Y+@0+3 .ENDM .MACRO __GETD2S LDD R26,Y+@0 LDD R27,Y+@0+1 LDD R24,Y+@0+2 LDD R25,Y+@0+3 .ENDM .MACRO __PUTD1S STD Y+@0,R30 STD Y+@0+1,R31 STD Y+@0+2,R22 STD Y+@0+3,R23 .ENDM .MACRO __PUTD2S STD Y+@0,R26 STD Y+@0+1,R27 STD Y+@0+2,R24 STD Y+@0+3,R25 .ENDM .MACRO __PUTDZ2 STD Z+@0,R26 STD Z+@0+1,R27 STD Z+@0+2,R24 STD Z+@0+3,R25 .ENDM .MACRO __CLRD1S STD Y+@0,R30 STD Y+@0+1,R30 STD Y+@0+2,R30 STD Y+@0+3,R30 .ENDM .MACRO __POINTB1MN LDI R30,LOW(@0+(@1)) .ENDM .MACRO __POINTW1MN LDI R30,LOW(@0+(@1)) LDI R31,HIGH(@0+(@1)) .ENDM .MACRO __POINTD1M LDI R30,LOW(@0) LDI R31,HIGH(@0) LDI R22,BYTE3(@0) LDI R23,BYTE4(@0) .ENDM .MACRO __POINTW1FN LDI R30,LOW(2*@0+(@1)) LDI R31,HIGH(2*@0+(@1)) .ENDM .MACRO __POINTD1FN LDI R30,LOW(2*@0+(@1)) LDI R31,HIGH(2*@0+(@1)) LDI R22,BYTE3(2*@0+(@1)) LDI R23,BYTE4(2*@0+(@1)) .ENDM .MACRO __POINTB2MN LDI R26,LOW(@0+(@1)) .ENDM .MACRO __POINTW2MN LDI R26,LOW(@0+(@1)) LDI R27,HIGH(@0+(@1)) .ENDM .MACRO __POINTW2FN LDI R26,LOW(2*@0+(@1)) LDI R27,HIGH(2*@0+(@1)) .ENDM .MACRO __POINTD2FN LDI R26,LOW(2*@0+(@1)) LDI R27,HIGH(2*@0+(@1)) LDI R24,BYTE3(2*@0+(@1)) LDI R25,BYTE4(2*@0+(@1)) .ENDM .MACRO __POINTBRM LDI R@0,LOW(@1) .ENDM .MACRO __POINTWRM LDI R@0,LOW(@2) LDI R@1,HIGH(@2) .ENDM .MACRO __POINTBRMN LDI R@0,LOW(@1+(@2)) .ENDM .MACRO __POINTWRMN LDI R@0,LOW(@2+(@3)) LDI R@1,HIGH(@2+(@3)) .ENDM .MACRO __POINTWRFN LDI R@0,LOW(@2*2+(@3)) LDI R@1,HIGH(@2*2+(@3)) .ENDM .MACRO __GETD1N LDI R30,LOW(@0) LDI R31,HIGH(@0) LDI R22,BYTE3(@0) LDI R23,BYTE4(@0) .ENDM .MACRO __GETD2N LDI R26,LOW(@0) LDI R27,HIGH(@0) LDI R24,BYTE3(@0) LDI R25,BYTE4(@0) .ENDM .MACRO __GETB1MN LDS R30,@0+(@1) .ENDM .MACRO __GETB1HMN LDS R31,@0+(@1) .ENDM .MACRO __GETW1MN LDS R30,@0+(@1) LDS R31,@0+(@1)+1 .ENDM .MACRO __GETD1MN LDS R30,@0+(@1) LDS R31,@0+(@1)+1 LDS R22,@0+(@1)+2 LDS R23,@0+(@1)+3 .ENDM .MACRO __GETBRMN LDS R@0,@1+(@2) .ENDM .MACRO __GETWRMN LDS R@0,@2+(@3) LDS R@1,@2+(@3)+1 .ENDM .MACRO __GETWRZ LDD R@0,Z+@2 LDD R@1,Z+@2+1 .ENDM .MACRO __GETD2Z LDD R26,Z+@0 LDD R27,Z+@0+1 LDD R24,Z+@0+2 LDD R25,Z+@0+3 .ENDM .MACRO __GETB2MN LDS R26,@0+(@1) .ENDM .MACRO __GETW2MN LDS R26,@0+(@1) LDS R27,@0+(@1)+1 .ENDM .MACRO __GETD2MN LDS R26,@0+(@1) LDS R27,@0+(@1)+1 LDS R24,@0+(@1)+2 LDS R25,@0+(@1)+3 .ENDM .MACRO __PUTB1MN STS @0+(@1),R30 .ENDM .MACRO __PUTW1MN STS @0+(@1),R30 STS @0+(@1)+1,R31 .ENDM .MACRO __PUTD1MN STS @0+(@1),R30 STS @0+(@1)+1,R31 STS @0+(@1)+2,R22 STS @0+(@1)+3,R23 .ENDM .MACRO __PUTB1EN LDI R26,LOW(@0+(@1)) LDI R27,HIGH(@0+(@1)) CALL __EEPROMWRB .ENDM .MACRO __PUTW1EN LDI R26,LOW(@0+(@1)) LDI R27,HIGH(@0+(@1)) CALL __EEPROMWRW .ENDM .MACRO __PUTD1EN LDI R26,LOW(@0+(@1)) LDI R27,HIGH(@0+(@1)) CALL __EEPROMWRD .ENDM .MACRO __PUTBR0MN STS @0+(@1),R0 .ENDM .MACRO __PUTBMRN STS @0+(@1),R@2 .ENDM .MACRO __PUTWMRN STS @0+(@1),R@2 STS @0+(@1)+1,R@3 .ENDM .MACRO __PUTBZR STD Z+@1,R@0 .ENDM .MACRO __PUTWZR STD Z+@2,R@0 STD Z+@2+1,R@1 .ENDM .MACRO __GETW1R MOV R30,R@0 MOV R31,R@1 .ENDM .MACRO __GETW2R MOV R26,R@0 MOV R27,R@1 .ENDM .MACRO __GETWRN LDI R@0,LOW(@2) LDI R@1,HIGH(@2) .ENDM .MACRO __PUTW1R MOV R@0,R30 MOV R@1,R31 .ENDM .MACRO __PUTW2R MOV R@0,R26 MOV R@1,R27 .ENDM .MACRO __ADDWRN SUBI R@0,LOW(-@2) SBCI R@1,HIGH(-@2) .ENDM .MACRO __ADDWRR ADD R@0,R@2 ADC R@1,R@3 .ENDM .MACRO __SUBWRN SUBI R@0,LOW(@2) SBCI R@1,HIGH(@2) .ENDM .MACRO __SUBWRR SUB R@0,R@2 SBC R@1,R@3 .ENDM .MACRO __ANDWRN ANDI R@0,LOW(@2) ANDI R@1,HIGH(@2) .ENDM .MACRO __ANDWRR AND R@0,R@2 AND R@1,R@3 .ENDM .MACRO __ORWRN ORI R@0,LOW(@2) ORI R@1,HIGH(@2) .ENDM .MACRO __ORWRR OR R@0,R@2 OR R@1,R@3 .ENDM .MACRO __EORWRR EOR R@0,R@2 EOR R@1,R@3 .ENDM .MACRO __GETWRS LDD R@0,Y+@2 LDD R@1,Y+@2+1 .ENDM .MACRO __PUTBSR STD Y+@1,R@0 .ENDM .MACRO __PUTWSR STD Y+@2,R@0 STD Y+@2+1,R@1 .ENDM .MACRO __MOVEWRR MOV R@0,R@2 MOV R@1,R@3 .ENDM .MACRO __INWR IN R@0,@2 IN R@1,@2+1 .ENDM .MACRO __OUTWR OUT @2+1,R@1 OUT @2,R@0 .ENDM .MACRO __CALL1MN LDS R30,@0+(@1) LDS R31,@0+(@1)+1 ICALL .ENDM .MACRO __CALL1FN LDI R30,LOW(2*@0+(@1)) LDI R31,HIGH(2*@0+(@1)) CALL __GETW1PF ICALL .ENDM .MACRO __CALL2EN PUSH R26 PUSH R27 LDI R26,LOW(@0+(@1)) LDI R27,HIGH(@0+(@1)) CALL __EEPROMRDW POP R27 POP R26 ICALL .ENDM .MACRO __CALL2EX SUBI R26,LOW(-@0) SBCI R27,HIGH(-@0) CALL __EEPROMRDD ICALL .ENDM .MACRO __GETW1STACK IN R30,SPL IN R31,SPH ADIW R30,@0+1 LD R0,Z+ LD R31,Z MOV R30,R0 .ENDM .MACRO __GETD1STACK IN R30,SPL IN R31,SPH ADIW R30,@0+1 LD R0,Z+ LD R1,Z+ LD R22,Z MOVW R30,R0 .ENDM .MACRO __NBST BST R@0,@1 IN R30,SREG LDI R31,0x40 EOR R30,R31 OUT SREG,R30 .ENDM .MACRO __PUTB1SN LDD R26,Y+@0 LDD R27,Y+@0+1 SUBI R26,LOW(-@1) SBCI R27,HIGH(-@1) ST X,R30 .ENDM .MACRO __PUTW1SN LDD R26,Y+@0 LDD R27,Y+@0+1 SUBI R26,LOW(-@1) SBCI R27,HIGH(-@1) ST X+,R30 ST X,R31 .ENDM .MACRO __PUTD1SN LDD R26,Y+@0 LDD R27,Y+@0+1 SUBI R26,LOW(-@1) SBCI R27,HIGH(-@1) CALL __PUTDP1 .ENDM .MACRO __PUTB1SNS LDD R26,Y+@0 LDD R27,Y+@0+1 ADIW R26,@1 ST X,R30 .ENDM .MACRO __PUTW1SNS LDD R26,Y+@0 LDD R27,Y+@0+1 ADIW R26,@1 ST X+,R30 ST X,R31 .ENDM .MACRO __PUTD1SNS LDD R26,Y+@0 LDD R27,Y+@0+1 ADIW R26,@1 CALL __PUTDP1 .ENDM .MACRO __PUTB1PMN LDS R26,@0 LDS R27,@0+1 SUBI R26,LOW(-@1) SBCI R27,HIGH(-@1) ST X,R30 .ENDM .MACRO __PUTW1PMN LDS R26,@0 LDS R27,@0+1 SUBI R26,LOW(-@1) SBCI R27,HIGH(-@1) ST X+,R30 ST X,R31 .ENDM .MACRO __PUTD1PMN LDS R26,@0 LDS R27,@0+1 SUBI R26,LOW(-@1) SBCI R27,HIGH(-@1) CALL __PUTDP1 .ENDM .MACRO __PUTB1PMNS LDS R26,@0 LDS R27,@0+1 ADIW R26,@1 ST X,R30 .ENDM .MACRO __PUTW1PMNS LDS R26,@0 LDS R27,@0+1 ADIW R26,@1 ST X+,R30 ST X,R31 .ENDM .MACRO __PUTD1PMNS LDS R26,@0 LDS R27,@0+1 ADIW R26,@1 CALL __PUTDP1 .ENDM .MACRO __PUTB1RN MOVW R26,R@0 SUBI R26,LOW(-@1) SBCI R27,HIGH(-@1) ST X,R30 .ENDM .MACRO __PUTW1RN MOVW R26,R@0 SUBI R26,LOW(-@1) SBCI R27,HIGH(-@1) ST X+,R30 ST X,R31 .ENDM .MACRO __PUTD1RN MOVW R26,R@0 SUBI R26,LOW(-@1) SBCI R27,HIGH(-@1) CALL __PUTDP1 .ENDM .MACRO __PUTB1RNS MOVW R26,R@0 ADIW R26,@1 ST X,R30 .ENDM .MACRO __PUTW1RNS MOVW R26,R@0 ADIW R26,@1 ST X+,R30 ST X,R31 .ENDM .MACRO __PUTD1RNS MOVW R26,R@0 ADIW R26,@1 CALL __PUTDP1 .ENDM .MACRO __PUTB1RON MOV R26,R@0 MOV R27,R@1 SUBI R26,LOW(-@2) SBCI R27,HIGH(-@2) ST X,R30 .ENDM .MACRO __PUTW1RON MOV R26,R@0 MOV R27,R@1 SUBI R26,LOW(-@2) SBCI R27,HIGH(-@2) ST X+,R30 ST X,R31 .ENDM .MACRO __PUTD1RON MOV R26,R@0 MOV R27,R@1 SUBI R26,LOW(-@2) SBCI R27,HIGH(-@2) CALL __PUTDP1 .ENDM .MACRO __PUTB1RONS MOV R26,R@0 MOV R27,R@1 ADIW R26,@2 ST X,R30 .ENDM .MACRO __PUTW1RONS MOV R26,R@0 MOV R27,R@1 ADIW R26,@2 ST X+,R30 ST X,R31 .ENDM .MACRO __PUTD1RONS MOV R26,R@0 MOV R27,R@1 ADIW R26,@2 CALL __PUTDP1 .ENDM .MACRO __GETB1SX MOVW R30,R28 SUBI R30,LOW(-@0) SBCI R31,HIGH(-@0) LD R30,Z .ENDM .MACRO __GETB1HSX MOVW R30,R28 SUBI R30,LOW(-@0) SBCI R31,HIGH(-@0) LD R31,Z .ENDM .MACRO __GETW1SX MOVW R30,R28 SUBI R30,LOW(-@0) SBCI R31,HIGH(-@0) LD R0,Z+ LD R31,Z MOV R30,R0 .ENDM .MACRO __GETD1SX MOVW R30,R28 SUBI R30,LOW(-@0) SBCI R31,HIGH(-@0) LD R0,Z+ LD R1,Z+ LD R22,Z+ LD R23,Z MOVW R30,R0 .ENDM .MACRO __GETB2SX MOVW R26,R28 SUBI R26,LOW(-@0) SBCI R27,HIGH(-@0) LD R26,X .ENDM .MACRO __GETW2SX MOVW R26,R28 SUBI R26,LOW(-@0) SBCI R27,HIGH(-@0) LD R0,X+ LD R27,X MOV R26,R0 .ENDM .MACRO __GETD2SX MOVW R26,R28 SUBI R26,LOW(-@0) SBCI R27,HIGH(-@0) LD R0,X+ LD R1,X+ LD R24,X+ LD R25,X MOVW R26,R0 .ENDM .MACRO __GETBRSX MOVW R30,R28 SUBI R30,LOW(-@1) SBCI R31,HIGH(-@1) LD R@0,Z .ENDM .MACRO __GETWRSX MOVW R30,R28 SUBI R30,LOW(-@2) SBCI R31,HIGH(-@2) LD R@0,Z+ LD R@1,Z .ENDM .MACRO __GETBRSX2 MOVW R26,R28 SUBI R26,LOW(-@1) SBCI R27,HIGH(-@1) LD R@0,X .ENDM .MACRO __GETWRSX2 MOVW R26,R28 SUBI R26,LOW(-@2) SBCI R27,HIGH(-@2) LD R@0,X+ LD R@1,X .ENDM .MACRO __LSLW8SX MOVW R30,R28 SUBI R30,LOW(-@0) SBCI R31,HIGH(-@0) LD R31,Z CLR R30 .ENDM .MACRO __PUTB1SX MOVW R26,R28 SUBI R26,LOW(-@0) SBCI R27,HIGH(-@0) ST X,R30 .ENDM .MACRO __PUTW1SX MOVW R26,R28 SUBI R26,LOW(-@0) SBCI R27,HIGH(-@0) ST X+,R30 ST X,R31 .ENDM .MACRO __PUTD1SX MOVW R26,R28 SUBI R26,LOW(-@0) SBCI R27,HIGH(-@0) ST X+,R30 ST X+,R31 ST X+,R22 ST X,R23 .ENDM .MACRO __CLRW1SX MOVW R26,R28 SUBI R26,LOW(-@0) SBCI R27,HIGH(-@0) ST X+,R30 ST X,R30 .ENDM .MACRO __CLRD1SX MOVW R26,R28 SUBI R26,LOW(-@0) SBCI R27,HIGH(-@0) ST X+,R30 ST X+,R30 ST X+,R30 ST X,R30 .ENDM .MACRO __PUTB2SX MOVW R30,R28 SUBI R30,LOW(-@0) SBCI R31,HIGH(-@0) ST Z,R26 .ENDM .MACRO __PUTW2SX MOVW R30,R28 SUBI R30,LOW(-@0) SBCI R31,HIGH(-@0) ST Z+,R26 ST Z,R27 .ENDM .MACRO __PUTD2SX MOVW R30,R28 SUBI R30,LOW(-@0) SBCI R31,HIGH(-@0) ST Z+,R26 ST Z+,R27 ST Z+,R24 ST Z,R25 .ENDM .MACRO __PUTBSRX MOVW R30,R28 SUBI R30,LOW(-@1) SBCI R31,HIGH(-@1) ST Z,R@0 .ENDM .MACRO __PUTWSRX MOVW R30,R28 SUBI R30,LOW(-@2) SBCI R31,HIGH(-@2) ST Z+,R@0 ST Z,R@1 .ENDM .MACRO __PUTB1SNX MOVW R26,R28 SUBI R26,LOW(-@0) SBCI R27,HIGH(-@0) LD R0,X+ LD R27,X MOV R26,R0 SUBI R26,LOW(-@1) SBCI R27,HIGH(-@1) ST X,R30 .ENDM .MACRO __PUTW1SNX MOVW R26,R28 SUBI R26,LOW(-@0) SBCI R27,HIGH(-@0) LD R0,X+ LD R27,X MOV R26,R0 SUBI R26,LOW(-@1) SBCI R27,HIGH(-@1) ST X+,R30 ST X,R31 .ENDM .MACRO __PUTD1SNX MOVW R26,R28 SUBI R26,LOW(-@0) SBCI R27,HIGH(-@0) LD R0,X+ LD R27,X MOV R26,R0 SUBI R26,LOW(-@1) SBCI R27,HIGH(-@1) ST X+,R30 ST X+,R31 ST X+,R22 ST X,R23 .ENDM .MACRO __MULBRR MULS R@0,R@1 MOVW R30,R0 .ENDM .MACRO __MULBRRU MUL R@0,R@1 MOVW R30,R0 .ENDM .MACRO __MULBRR0 MULS R@0,R@1 .ENDM .MACRO __MULBRRU0 MUL R@0,R@1 .ENDM .MACRO __MULBNWRU LDI R26,@2 MUL R26,R@0 MOVW R30,R0 MUL R26,R@1 ADD R31,R0 .ENDM ;NAME DEFINITIONS FOR GLOBAL VARIABLES ALLOCATED TO REGISTERS .DEF _rx_wr_index=R5 .DEF _rx_rd_index=R4 .DEF _rx_counter=R6 .DEF _rx_counter_msb=R7 .DEF _tx_wr_index=R9 .DEF _tx_rd_index=R8 .DEF _tx_counter=R10 .DEF _tx_counter_msb=R11 .CSEG .ORG 0x00 ;START OF CODE MARKER __START_OF_CODE: ;INTERRUPT VECTORS JMP __RESET JMP 0x00 JMP 0x00 JMP 0x00 JMP 0x00 JMP 0x00 JMP 0x00 JMP 0x00 JMP 0x00 JMP 0x00 JMP 0x00 JMP _usart_rx_isr JMP 0x00 JMP _usart_tx_isr JMP 0x00 JMP 0x00 JMP 0x00 JMP 0x00 JMP 0x00 JMP 0x00 JMP 0x00 _tbl10_G100: .DB 0x10,0x27,0xE8,0x3,0x64,0x0,0xA,0x0 .DB 0x1,0x0 _tbl16_G100: .DB 0x0,0x10,0x0,0x1,0x10,0x0,0x1,0x0 ;REGISTER BIT VARIABLES INITIALIZATION __REG_BIT_VARS: .DW 0x0000 ;GLOBAL REGISTER VARIABLES INITIALIZATION __REG_VARS: .DB 0x0,0x0,0x0,0x0 .DB 0x0,0x0,0x0,0x0 _0x20000: .DB 0xD,0xA,0x20,0x53,0x6C,0x61,0x76,0x65 .DB 0x20,0x44,0x65,0x76,0x69,0x63,0x65,0x0 .DB 0xD,0xA,0x20,0x52,0x65,0x63,0x65,0x69 .DB 0x76,0x69,0x6E,0x67,0x20,0x3A,0x20,0x20 .DB 0x20,0x20,0x20,0x20,0x20,0x0,0x25,0x64 .DB 0x20,0x20,0x20,0x20,0x0,0xD,0xA,0x20 .DB 0x53,0x65,0x6E,0x64,0x69,0x6E,0x67,0x20 .DB 0x3A,0x20,0x20,0x20,0x20,0x20,0x20,0x20 .DB 0x0 __GLOBAL_INI_TBL: .DW 0x01 .DW 0x02 .DW __REG_BIT_VARS*2 .DW 0x08 .DW 0x04 .DW __REG_VARS*2 .DW 0x10 .DW _0x20003 .DW _0x20000*2 .DW 0x16 .DW _0x20003+16 .DW _0x20000*2+16 .DW 0x14 .DW _0x20003+38 .DW _0x20000*2+45 _0xFFFFFFFF: .DW 0 #define __GLOBAL_INI_TBL_PRESENT 1 __RESET: CLI CLR R30 OUT EECR,R30 ;INTERRUPT VECTORS ARE PLACED ;AT THE START OF FLASH LDI R31,1 OUT GICR,R31 OUT GICR,R30 OUT MCUCR,R30 ;CLEAR R2-R14 LDI R24,(14-2)+1 LDI R26,2 CLR R27 __CLEAR_REG: ST X+,R30 DEC R24 BRNE __CLEAR_REG ;CLEAR SRAM LDI R24,LOW(__CLEAR_SRAM_SIZE) LDI R25,HIGH(__CLEAR_SRAM_SIZE) LDI R26,__SRAM_START __CLEAR_SRAM: ST X+,R30 SBIW R24,1 BRNE __CLEAR_SRAM ;GLOBAL VARIABLES INITIALIZATION LDI R30,LOW(__GLOBAL_INI_TBL*2) LDI R31,HIGH(__GLOBAL_INI_TBL*2) __GLOBAL_INI_NEXT: LPM R24,Z+ LPM R25,Z+ SBIW R24,0 BREQ __GLOBAL_INI_END LPM R26,Z+ LPM R27,Z+ LPM R0,Z+ LPM R1,Z+ MOVW R22,R30 MOVW R30,R0 __GLOBAL_INI_LOOP: LPM R0,Z+ ST X+,R0 SBIW R24,1 BRNE __GLOBAL_INI_LOOP MOVW R30,R22 RJMP __GLOBAL_INI_NEXT __GLOBAL_INI_END: ;HARDWARE STACK POINTER INITIALIZATION LDI R30,LOW(__SRAM_END-__HEAP_SIZE) OUT SPL,R30 LDI R30,HIGH(__SRAM_END-__HEAP_SIZE) OUT SPH,R30 ;DATA STACK POINTER INITIALIZATION LDI R28,LOW(__SRAM_START+__DSTACK_SIZE) LDI R29,HIGH(__SRAM_START+__DSTACK_SIZE) JMP _main .ESEG .ORG 0 .DSEG .ORG 0x160 .CSEG ; ;#define F_CPU 8000000UL /* Define CPU clock Frequency e.g. here its 8MHz */ ;#include <mega16.h> /* Include AVR std. library file */ #ifndef __SLEEP_DEFINED__ #define __SLEEP_DEFINED__ .EQU __se_bit=0x40 .EQU __sm_mask=0xB0 .EQU __sm_powerdown=0x20 .EQU __sm_powersave=0x30 .EQU __sm_standby=0xA0 .EQU __sm_ext_standby=0xB0 .EQU __sm_adc_noise_red=0x10 .SET power_ctrl_reg=mcucr #endif ;#include <delay.h> /* Include inbuilt defined Delay header file */ ;#include <stdio.h> /* Include standard I/O header file */ ;#include <string.h> /* Include string header file */ ; ; ; ;#include "uartf.h" ; ;// Declare your global variables here ; ;#define DATA_REGISTER_EMPTY (1<<UDRE) ;#define RX_COMPLETE (1<<RXC) ;#define FRAMING_ERROR (1<<FE) ;#define PARITY_ERROR (1<<UPE) ;#define DATA_OVERRUN (1<<DOR) ; ;// USART Receiver buffer ;#define RX_BUFFER_SIZE 256 ;char rx_buffer[RX_BUFFER_SIZE]; ; ;#if RX_BUFFER_SIZE <= 256 ;unsigned char rx_wr_index=0,rx_rd_index=0; ;#else ;unsigned int rx_wr_index=0,rx_rd_index=0; ;#endif ; ;#if RX_BUFFER_SIZE < 256 ;unsigned char rx_counter=0; ;#else ;unsigned int rx_counter=0; ;#endif ; ;// This flag is set on USART Receiver buffer overflow ;bit rx_buffer_overflow; ; ;// USART Receiver interrupt service routine ;interrupt [USART_RXC] void usart_rx_isr(void) ; 0000 0029 { .CSEG _usart_rx_isr: ; .FSTART _usart_rx_isr ST -Y,R30 ST -Y,R31 IN R30,SREG ST -Y,R30 ; 0000 002A char status,data; ; 0000 002B status=UCSRA; ST -Y,R17 ST -Y,R16 ; status -> R17 ; data -> R16 IN R17,11 ; 0000 002C data=UDR; IN R16,12 ; 0000 002D if ((status & (FRAMING_ERROR | PARITY_ERROR | DATA_OVERRUN))==0) MOV R30,R17 ANDI R30,LOW(0x1C) BRNE _0x3 ; 0000 002E { ; 0000 002F rx_buffer[rx_wr_index++]=data; MOV R30,R5 INC R5 LDI R31,0 SUBI R30,LOW(-_rx_buffer) SBCI R31,HIGH(-_rx_buffer) ST Z,R16 ; 0000 0030 #if RX_BUFFER_SIZE == 256 ; 0000 0031 // special case for receiver buffer size=256 ; 0000 0032 if (++rx_counter == 0) rx_buffer_overflow=1; MOVW R30,R6 ADIW R30,1 MOVW R6,R30 BRNE _0x4 SET BLD R2,0 ; 0000 0033 #else ; 0000 0034 if (rx_wr_index == RX_BUFFER_SIZE) rx_wr_index=0; ; 0000 0035 if (++rx_counter == RX_BUFFER_SIZE) ; 0000 0036 { ; 0000 0037 rx_counter=0; ; 0000 0038 rx_buffer_overflow=1; ; 0000 0039 } ; 0000 003A #endif ; 0000 003B } _0x4: ; 0000 003C } _0x3: LD R16,Y+ LD R17,Y+ LD R30,Y+ OUT SREG,R30 LD R31,Y+ LD R30,Y+ RETI ; .FEND ; ;#ifndef _DEBUG_TERMINAL_IO_ ;// Get a character from the USART Receiver buffer ;#define _ALTERNATE_GETCHAR_ ;#pragma used+ ;char getchar(void) ; 0000 0043 { ; 0000 0044 char data; ; 0000 0045 while (rx_counter==0); ; data -> R17 ; 0000 0046 data=rx_buffer[rx_rd_index++]; ; 0000 0047 #if RX_BUFFER_SIZE != 256 ; 0000 0048 if (rx_rd_index == RX_BUFFER_SIZE) rx_rd_index=0; ; 0000 0049 #endif ; 0000 004A #asm("cli") ; 0000 004B --rx_counter; ; 0000 004C #asm("sei") ; 0000 004D return data; ; 0000 004E } ;#pragma used- ;#endif ; ;// USART Transmitter buffer ;#define TX_BUFFER_SIZE 256 ;char tx_buffer[TX_BUFFER_SIZE]; ; ;#if TX_BUFFER_SIZE <= 256 ;unsigned char tx_wr_index=0,tx_rd_index=0; ;#else ;unsigned int tx_wr_index=0,tx_rd_index=0; ;#endif ; ;#if TX_BUFFER_SIZE < 256 ;unsigned char tx_counter=0; ;#else ;unsigned int tx_counter=0; ;#endif ; ;// USART Transmitter interrupt service routine ;interrupt [USART_TXC] void usart_tx_isr(void) ; 0000 0064 { _usart_tx_isr: ; .FSTART _usart_tx_isr ST -Y,R0 ST -Y,R30 ST -Y,R31 IN R30,SREG ST -Y,R30 ; 0000 0065 if (tx_counter) MOV R0,R10 OR R0,R11 BREQ _0x8 ; 0000 0066 { ; 0000 0067 --tx_counter; MOVW R30,R10 SBIW R30,1 MOVW R10,R30 ; 0000 0068 UDR=tx_buffer[tx_rd_index++]; MOV R30,R8 INC R8 LDI R31,0 SUBI R30,LOW(-_tx_buffer) SBCI R31,HIGH(-_tx_buffer) LD R30,Z OUT 0xC,R30 ; 0000 0069 #if TX_BUFFER_SIZE != 256 ; 0000 006A if (tx_rd_index == TX_BUFFER_SIZE) tx_rd_index=0; ; 0000 006B #endif ; 0000 006C } ; 0000 006D } _0x8: LD R30,Y+ OUT SREG,R30 LD R31,Y+ LD R30,Y+ LD R0,Y+ RETI ; .FEND ; ;#ifndef _DEBUG_TERMINAL_IO_ ;// Write a character to the USART Transmitter buffer ;#define _ALTERNATE_PUTCHAR_ ;#pragma used+ ;void putchar(char c) ; 0000 0074 { _putchar: ; .FSTART _putchar ; 0000 0075 while (tx_counter == TX_BUFFER_SIZE); ST -Y,R26 ; c -> Y+0 _0x9: LDI R30,LOW(256) LDI R31,HIGH(256) CP R30,R10 CPC R31,R11 BREQ _0x9 ; 0000 0076 #asm("cli") cli ; 0000 0077 if (tx_counter || ((UCSRA & DATA_REGISTER_EMPTY)==0)) MOV R0,R10 OR R0,R11 BRNE _0xD SBIC 0xB,5 RJMP _0xC _0xD: ; 0000 0078 { ; 0000 0079 tx_buffer[tx_wr_index++]=c; MOV R30,R9 INC R9 LDI R31,0 SUBI R30,LOW(-_tx_buffer) SBCI R31,HIGH(-_tx_buffer) LD R26,Y STD Z+0,R26 ; 0000 007A #if TX_BUFFER_SIZE != 256 ; 0000 007B if (tx_wr_index == TX_BUFFER_SIZE) tx_wr_index=0; ; 0000 007C #endif ; 0000 007D ++tx_counter; MOVW R30,R10 ADIW R30,1 MOVW R10,R30 ; 0000 007E } ; 0000 007F else RJMP _0xF _0xC: ; 0000 0080 UDR=c; LD R30,Y OUT 0xC,R30 ; 0000 0081 #asm("sei") _0xF: sei ; 0000 0082 } ADIW R28,1 RET ; .FEND ;#pragma used- ;#endif ; ; ; ; ; ;void uart_init(void) ; 0000 008B { _uart_init: ; .FSTART _uart_init ; 0000 008C UCSRA=(0<<RXC) | (0<<TXC) | (0<<UDRE) | (0<<FE) | (0<<DOR) | (0<<UPE) | (0<<U2X) | (0<<MPCM); LDI R30,LOW(0) OUT 0xB,R30 ; 0000 008D UCSRB=(1<<RXCIE) | (1<<TXCIE) | (0<<UDRIE) | (1<<RXEN) | (1<<TXEN) | (0<<UCSZ2) | (0<<RXB8) | (0<<TXB8); LDI R30,LOW(216) OUT 0xA,R30 ; 0000 008E UCSRC=(1<<URSEL) | (0<<UMSEL) | (0<<UPM1) | (0<<UPM0) | (0<<USBS) | (1<<UCSZ1) | (1<<UCSZ0) | (0<<UCPOL); LDI R30,LOW(134) OUT 0x20,R30 ; 0000 008F UBRRH=0x00; LDI R30,LOW(0) OUT 0x20,R30 ; 0000 0090 UBRRL=0x33; LDI R30,LOW(51) OUT 0x9,R30 ; 0000 0091 } RET ; .FEND ; ; ; ; ; ; ;/* ; * ATmega32_Slave.c ; * http://www.electronicwings.com ; * ; */ ; ; ;#define F_CPU 8000000UL /* Define CPU clock Frequency e.g. here its 8MHz */ ;#include <mega16.h> /* Include AVR std. library file */ #ifndef __SLEEP_DEFINED__ #define __SLEEP_DEFINED__ .EQU __se_bit=0x40 .EQU __sm_mask=0xB0 .EQU __sm_powerdown=0x20 .EQU __sm_powersave=0x30 .EQU __sm_standby=0xA0 .EQU __sm_ext_standby=0xB0 .EQU __sm_adc_noise_red=0x10 .SET power_ctrl_reg=mcucr #endif ;#include <delay.h> /* Include inbuilt defined Delay header file */ ;#include <stdio.h> /* Include standard I/O header file */ ;#include <string.h> /* Include string header file */ ;//#include "LCD_16x2_H_file.h" /* Include LCD header file */ ;#include "I2C_Slave_H_File.h" /* Include I2C slave header file */ ;//#include <cstdint.h> ;#include "uartf.h" ;#define Slave_Address 0x20 ; ;void main(void) ; 0001 0014 { .CSEG _main: ; .FSTART _main ; 0001 0015 char buffer[10]; ; 0001 0016 char count = 0,count3; ; 0001 0017 char Ack_status; ; 0001 0018 ; 0001 0019 uart_init(); SBIW R28,10 ; buffer -> Y+0 ; count -> R17 ; count3 -> R16 ; Ack_status -> R19 LDI R17,0 RCALL _uart_init ; 0001 001A I2C_Slave_Init(Slave_Address); LDI R26,LOW(32) LDI R27,0 RCALL _I2C_Slave_Init ; 0001 001B ; 0001 001C puts("\r\n Slave Device"); __POINTW2MN _0x20003,0 CALL _puts ; 0001 001D ; 0001 001E while (1) _0x20004: ; 0001 001F { ; 0001 0020 switch(I2C_Slave_Listen()) /* Check for any SLA+W or SLA+R */ RCALL _I2C_Slave_Listen ; 0001 0021 { ; 0001 0022 case 0: SBIW R30,0 BRNE _0x2000A ; 0001 0023 { ; 0001 0024 puts("\r\n Receiving : "); __POINTW2MN _0x20003,16 CALL _puts ; 0001 0025 do _0x2000C: ; 0001 0026 { ; 0001 0027 count = I2C_Slave_Receive(); RCALL _I2C_Slave_Receive MOV R17,R30 ; 0001 0028 sprintf(buffer, "%d ", count); CALL SUBOPT_0x0 ; 0001 0029 puts(buffer); ; 0001 002A /* Receive data byte*/ ; 0001 002B } while (count != 255); /* Receive until STOP/REPEATED START received */ CPI R17,255 BRNE _0x2000C ; 0001 002C count = 0; LDI R17,LOW(0) ; 0001 002D break; RJMP _0x20009 ; 0001 002E } ; 0001 002F case 1: _0x2000A: CPI R30,LOW(0x1) LDI R26,HIGH(0x1) CPC R31,R26 BRNE _0x20012 ; 0001 0030 { ; 0001 0031 //count3=10; ; 0001 0032 count = 20; LDI R17,LOW(20) ; 0001 0033 puts("\r\n Sending : "); __POINTW2MN _0x20003,38 CALL _puts ; 0001 0034 do _0x20010: ; 0001 0035 { ; 0001 0036 //Ack_status = I2C_Slave_Transmit(count3); /* Send data byte */ ; 0001 0037 Ack_status = I2C_Slave_Transmit(count); /* Send data byte */ MOV R26,R17 RCALL _I2C_Slave_Transmit MOV R19,R30 ; 0001 0038 //sprintf(buffer, "%d ",count3); ; 0001 0039 sprintf(buffer, "%d ",count); CALL SUBOPT_0x0 ; 0001 003A puts(buffer); ; 0001 003B //count3++; ; 0001 003C count++; SUBI R17,-1 ; 0001 003D } while (Ack_status == 0); /* Send until Acknowledgment is received */ CPI R19,0 BREQ _0x20010 ; 0001 003E break; ; 0001 003F } ; 0001 0040 default: _0x20012: ; 0001 0041 break; ; 0001 0042 } _0x20009: ; 0001 0043 } RJMP _0x20004 ; 0001 0044 } _0x20013: RJMP _0x20013 ; .FEND .DSEG _0x20003: .BYTE 0x3A ; ;/* ; * I2C_Slave_C_File.c ; * ; */ ; ;#include "I2C_Slave_H_File.h" #ifndef __SLEEP_DEFINED__ #define __SLEEP_DEFINED__ .EQU __se_bit=0x40 .EQU __sm_mask=0xB0 .EQU __sm_powerdown=0x20 .EQU __sm_powersave=0x30 .EQU __sm_standby=0xA0 .EQU __sm_ext_standby=0xB0 .EQU __sm_adc_noise_red=0x10 .SET power_ctrl_reg=mcucr #endif ; ;void I2C_Slave_Init(int slave_address) ; 0002 0009 { .CSEG _I2C_Slave_Init: ; .FSTART _I2C_Slave_Init ; 0002 000A TWAR = slave_address; /* Assign address in TWI address register */ ST -Y,R27 ST -Y,R26 ; slave_address -> Y+0 LD R30,Y OUT 0x2,R30 ; 0002 000B TWCR = (1<<TWEN) | (1<<TWEA) | (1<<TWINT); /* Enable TWI, Enable ack generation, clear TWI interrupt */ LDI R30,LOW(196) OUT 0x36,R30 ; 0002 000C } RJMP _0x2060004 ; .FEND ;int I2C_Slave_Listen() ; 0002 000E { _I2C_Slave_Listen: ; .FSTART _I2C_Slave_Listen ; 0002 000F while(1) _0x40003: ; 0002 0010 { ; 0002 0011 int status; /* Declare variable */ ; 0002 0012 while (!(TWCR & (1<<TWINT))); /* Wait to be addressed */ SBIW R28,2 ; status -> Y+0 _0x40006: IN R30,0x36 ANDI R30,LOW(0x80) BREQ _0x40006 ; 0002 0013 status = TWSR & 0xF8; /* Read TWI status register with masking lower three bits */ IN R30,0x1 ANDI R30,LOW(0xF8) LDI R31,0 ST Y,R30 STD Y+1,R31 ; 0002 0014 if (status == 0x60 || status == 0x68) /* Check weather own SLA+W received & ack returned (TWEA = 1) */ LD R26,Y LDD R27,Y+1 CPI R26,LOW(0x60) LDI R30,HIGH(0x60) CPC R27,R30 BREQ _0x4000A CPI R26,LOW(0x68) LDI R30,HIGH(0x68) CPC R27,R30 BRNE _0x40009 _0x4000A: ; 0002 0015 return 0; /* If yes then return 0 to indicate ack returned */ LDI R30,LOW(0) LDI R31,HIGH(0) RJMP _0x2060004 ; 0002 0016 if (status == 0xA8 || status == 0xB0) /* Check weather own SLA+R received & ack returned (TWEA = 1) */ _0x40009: LD R26,Y LDD R27,Y+1 CPI R26,LOW(0xA8) LDI R30,HIGH(0xA8) CPC R27,R30 BREQ _0x4000D CPI R26,LOW(0xB0) LDI R30,HIGH(0xB0) CPC R27,R30 BRNE _0x4000C _0x4000D: ; 0002 0017 return 1; /* If yes then return 1 to indicate ack returned */ LDI R30,LOW(1) LDI R31,HIGH(1) RJMP _0x2060004 ; 0002 0018 if (status == 0x70 || status == 0x78) /* Check weather general call received & ack returned (TWEA = 1) */ _0x4000C: LD R26,Y LDD R27,Y+1 CPI R26,LOW(0x70) LDI R30,HIGH(0x70) CPC R27,R30 BREQ _0x40010 CPI R26,LOW(0x78) LDI R30,HIGH(0x78) CPC R27,R30 BRNE _0x4000F _0x40010: ; 0002 0019 return 2; /* If yes then return 2 to indicate ack returned */ LDI R30,LOW(2) LDI R31,HIGH(2) _0x2060004: ADIW R28,2 RET ; 0002 001A else _0x4000F: ; 0002 001B continue; /* Else continue */ ADIW R28,2 RJMP _0x40003 ; 0002 001C } ; 0002 001D } ; .FEND ; ;int I2C_Slave_Transmit(char data) ; 0002 0020 { _I2C_Slave_Transmit: ; .FSTART _I2C_Slave_Transmit ; 0002 0021 int status; ; 0002 0022 TWDR = data; /* Write data to TWDR to be transmitted */ ST -Y,R26 ST -Y,R17 ST -Y,R16 ; data -> Y+2 ; status -> R16,R17 LDD R30,Y+2 OUT 0x3,R30 ; 0002 0023 TWCR = (1<<TWEN)|(1<<TWINT)|(1<<TWEA); /* Enable TWI and clear interrupt flag */ LDI R30,LOW(196) OUT 0x36,R30 ; 0002 0024 while (!(TWCR & (1<<TWINT))); /* Wait until TWI finish its current job (Write operation) */ _0x40013: IN R30,0x36 ANDI R30,LOW(0x80) BREQ _0x40013 ; 0002 0025 status = TWSR & 0xF8; /* Read TWI status register with masking lower three bits */ IN R30,0x1 ANDI R30,LOW(0xF8) MOV R16,R30 CLR R17 ; 0002 0026 if (status == 0xA0) /* Check weather STOP/REPEATED START received */ LDI R30,LOW(160) LDI R31,HIGH(160) CP R30,R16 CPC R31,R17 BRNE _0x40016 ; 0002 0027 { ; 0002 0028 TWCR |= (1<<TWINT); /* If yes then clear interrupt flag & return -1 */ IN R30,0x36 ORI R30,0x80 OUT 0x36,R30 ; 0002 0029 return -1; LDI R30,LOW(65535) LDI R31,HIGH(65535) LDD R17,Y+1 LDD R16,Y+0 RJMP _0x2060002 ; 0002 002A } ; 0002 002B if (status == 0xB8) /* Check weather data transmitted & ack received */ _0x40016: LDI R30,LOW(184) LDI R31,HIGH(184) CP R30,R16 CPC R31,R17 BRNE _0x40017 ; 0002 002C return 0; /* If yes then return 0 */ LDI R30,LOW(0) LDI R31,HIGH(0) LDD R17,Y+1 LDD R16,Y+0 RJMP _0x2060002 ; 0002 002D if (status == 0xC0) /* Check weather data transmitted & nack received */ _0x40017: LDI R30,LOW(192) LDI R31,HIGH(192) CP R30,R16 CPC R31,R17 BRNE _0x40018 ; 0002 002E { ; 0002 002F TWCR |= (1<<TWINT); /* If yes then clear interrupt flag & return -2 */ IN R30,0x36 ORI R30,0x80 OUT 0x36,R30 ; 0002 0030 return -2; LDI R30,LOW(65534) LDI R31,HIGH(65534) LDD R17,Y+1 LDD R16,Y+0 RJMP _0x2060002 ; 0002 0031 } ; 0002 0032 if (status == 0xC8) /* If last data byte transmitted with ack received TWEA = 0 */ _0x40018: LDI R30,LOW(200) LDI R31,HIGH(200) CP R30,R16 CPC R31,R17 BRNE _0x40019 ; 0002 0033 return -3; /* If yes then return -3 */ LDI R30,LOW(65533) LDI R31,HIGH(65533) LDD R17,Y+1 LDD R16,Y+0 RJMP _0x2060002 ; 0002 0034 else /* else return -4 */ _0x40019: ; 0002 0035 return -4; LDI R30,LOW(65532) LDI R31,HIGH(65532) LDD R17,Y+1 LDD R16,Y+0 RJMP _0x2060002 ; 0002 0036 } ; .FEND ; ;char I2C_Slave_Receive() ; 0002 0039 { _I2C_Slave_Receive: ; .FSTART _I2C_Slave_Receive ; 0002 003A int status; /* Declare variable */ ; 0002 003B TWCR=(1<<TWEN)|(1<<TWEA)|(1<<TWINT); /* Enable TWI, generation of ack and clear interrupt flag */ ST -Y,R17 ST -Y,R16 ; status -> R16,R17 LDI R30,LOW(196) OUT 0x36,R30 ; 0002 003C while (!(TWCR & (1<<TWINT))); /* Wait until TWI finish its current job (read operation) */ _0x4001B: IN R30,0x36 ANDI R30,LOW(0x80) BREQ _0x4001B ; 0002 003D status = TWSR & 0xF8; /* Read TWI status register with masking lower three bits */ IN R30,0x1 ANDI R30,LOW(0xF8) MOV R16,R30 CLR R17 ; 0002 003E if (status == 0x80 || status == 0x90) /* Check weather data received & ack returned (TWEA = 1) */ LDI R30,LOW(128) LDI R31,HIGH(128) CP R30,R16 CPC R31,R17 BREQ _0x4001F LDI R30,LOW(144) LDI R31,HIGH(144) CP R30,R16 CPC R31,R17 BRNE _0x4001E _0x4001F: ; 0002 003F return TWDR; /* If yes then return received data */ IN R30,0x3 RJMP _0x2060003 ; 0002 0040 if (status == 0x88 || status == 0x98) /* Check weather data received, nack returned and switched to not addressed slav ... _0x4001E: LDI R30,LOW(136) LDI R31,HIGH(136) CP R30,R16 CPC R31,R17 BREQ _0x40022 LDI R30,LOW(152) LDI R31,HIGH(152) CP R30,R16 CPC R31,R17 BRNE _0x40021 _0x40022: ; 0002 0041 return TWDR; /* If yes then return received data */ IN R30,0x3 RJMP _0x2060003 ; 0002 0042 if (status == 0xA0) /* Check weather STOP/REPEATED START received */ _0x40021: LDI R30,LOW(160) LDI R31,HIGH(160) CP R30,R16 CPC R31,R17 BRNE _0x40024 ; 0002 0043 { ; 0002 0044 TWCR |= (1<<TWINT); /* If yes then clear interrupt flag & return 0 */ IN R30,0x36 ORI R30,0x80 OUT 0x36,R30 ; 0002 0045 return -1; LDI R30,LOW(255) RJMP _0x2060003 ; 0002 0046 } ; 0002 0047 else _0x40024: ; 0002 0048 return -2; /* Else return 1 */ LDI R30,LOW(254) ; 0002 0049 } _0x2060003: LD R16,Y+ LD R17,Y+ RET ; .FEND #ifndef __SLEEP_DEFINED__ #define __SLEEP_DEFINED__ .EQU __se_bit=0x40 .EQU __sm_mask=0xB0 .EQU __sm_powerdown=0x20 .EQU __sm_powersave=0x30 .EQU __sm_standby=0xA0 .EQU __sm_ext_standby=0xB0 .EQU __sm_adc_noise_red=0x10 .SET power_ctrl_reg=mcucr #endif .CSEG _puts: ; .FSTART _puts ST -Y,R27 ST -Y,R26 ST -Y,R17 _0x2000003: LDD R26,Y+1 LDD R27,Y+1+1 LD R30,X+ STD Y+1,R26 STD Y+1+1,R27 MOV R17,R30 CPI R30,0 BREQ _0x2000005 MOV R26,R17 CALL _putchar RJMP _0x2000003 _0x2000005: LDI R26,LOW(10) CALL _putchar LDD R17,Y+0 _0x2060002: ADIW R28,3 RET ; .FEND _put_buff_G100: ; .FSTART _put_buff_G100 ST -Y,R27 ST -Y,R26 ST -Y,R17 ST -Y,R16 LDD R26,Y+2 LDD R27,Y+2+1 ADIW R26,2 CALL __GETW1P SBIW R30,0 BREQ _0x2000010 LDD R26,Y+2 LDD R27,Y+2+1 ADIW R26,4 CALL __GETW1P MOVW R16,R30 SBIW R30,0 BREQ _0x2000012 __CPWRN 16,17,2 BRLO _0x2000013 MOVW R30,R16 SBIW R30,1 MOVW R16,R30 __PUTW1SNS 2,4 _0x2000012: LDD R26,Y+2 LDD R27,Y+2+1 ADIW R26,2 LD R30,X+ LD R31,X+ ADIW R30,1 ST -X,R31 ST -X,R30 SBIW R30,1 LDD R26,Y+4 STD Z+0,R26 _0x2000013: LDD R26,Y+2 LDD R27,Y+2+1 CALL __GETW1P TST R31 BRMI _0x2000014 LD R30,X+ LD R31,X+ ADIW R30,1 ST -X,R31 ST -X,R30 _0x2000014: RJMP _0x2000015 _0x2000010: LDD R26,Y+2 LDD R27,Y+2+1 LDI R30,LOW(65535) LDI R31,HIGH(65535) ST X+,R30 ST X,R31 _0x2000015: LDD R17,Y+1 LDD R16,Y+0 ADIW R28,5 RET ; .FEND __print_G100: ; .FSTART __print_G100 ST -Y,R27 ST -Y,R26 SBIW R28,6 CALL __SAVELOCR6 LDI R17,0 LDD R26,Y+12 LDD R27,Y+12+1 LDI R30,LOW(0) LDI R31,HIGH(0) ST X+,R30 ST X,R31 _0x2000016: LDD R30,Y+18 LDD R31,Y+18+1 ADIW R30,1 STD Y+18,R30 STD Y+18+1,R31 SBIW R30,1 LPM R30,Z MOV R18,R30 CPI R30,0 BRNE PC+2 RJMP _0x2000018 MOV R30,R17 CPI R30,0 BRNE _0x200001C CPI R18,37 BRNE _0x200001D LDI R17,LOW(1) RJMP _0x200001E _0x200001D: CALL SUBOPT_0x1 _0x200001E: RJMP _0x200001B _0x200001C: CPI R30,LOW(0x1) BRNE _0x200001F CPI R18,37 BRNE _0x2000020 CALL SUBOPT_0x1 RJMP _0x20000CC _0x2000020: LDI R17,LOW(2) LDI R20,LOW(0) LDI R16,LOW(0) CPI R18,45 BRNE _0x2000021 LDI R16,LOW(1) RJMP _0x200001B _0x2000021: CPI R18,43 BRNE _0x2000022 LDI R20,LOW(43) RJMP _0x200001B _0x2000022: CPI R18,32 BRNE _0x2000023 LDI R20,LOW(32) RJMP _0x200001B _0x2000023: RJMP _0x2000024 _0x200001F: CPI R30,LOW(0x2) BRNE _0x2000025 _0x2000024: LDI R21,LOW(0) LDI R17,LOW(3) CPI R18,48 BRNE _0x2000026 ORI R16,LOW(128) RJMP _0x200001B _0x2000026: RJMP _0x2000027 _0x2000025: CPI R30,LOW(0x3) BREQ PC+2 RJMP _0x200001B _0x2000027: CPI R18,48 BRLO _0x200002A CPI R18,58 BRLO _0x200002B _0x200002A: RJMP _0x2000029 _0x200002B: LDI R26,LOW(10) MUL R21,R26 MOV R21,R0 MOV R30,R18 SUBI R30,LOW(48) ADD R21,R30 RJMP _0x200001B _0x2000029: MOV R30,R18 CPI R30,LOW(0x63) BRNE _0x200002F CALL SUBOPT_0x2 LDD R30,Y+16 LDD R31,Y+16+1 LDD R26,Z+4 ST -Y,R26 CALL SUBOPT_0x3 RJMP _0x2000030 _0x200002F: CPI R30,LOW(0x73) BRNE _0x2000032 CALL SUBOPT_0x2 CALL SUBOPT_0x4 CALL _strlen MOV R17,R30 RJMP _0x2000033 _0x2000032: CPI R30,LOW(0x70) BRNE _0x2000035 CALL SUBOPT_0x2 CALL SUBOPT_0x4 CALL _strlenf MOV R17,R30 ORI R16,LOW(8) _0x2000033: ORI R16,LOW(2) ANDI R16,LOW(127) LDI R19,LOW(0) RJMP _0x2000036 _0x2000035: CPI R30,LOW(0x64) BREQ _0x2000039 CPI R30,LOW(0x69) BRNE _0x200003A _0x2000039: ORI R16,LOW(4) RJMP _0x200003B _0x200003A: CPI R30,LOW(0x75) BRNE _0x200003C _0x200003B: LDI R30,LOW(_tbl10_G100*2) LDI R31,HIGH(_tbl10_G100*2) STD Y+6,R30 STD Y+6+1,R31 LDI R17,LOW(5) RJMP _0x200003D _0x200003C: CPI R30,LOW(0x58) BRNE _0x200003F ORI R16,LOW(8) RJMP _0x2000040 _0x200003F: CPI R30,LOW(0x78) BREQ PC+2 RJMP _0x2000071 _0x2000040: LDI R30,LOW(_tbl16_G100*2) LDI R31,HIGH(_tbl16_G100*2) STD Y+6,R30 STD Y+6+1,R31 LDI R17,LOW(4) _0x200003D: SBRS R16,2 RJMP _0x2000042 CALL SUBOPT_0x2 CALL SUBOPT_0x5 LDD R26,Y+11 TST R26 BRPL _0x2000043 LDD R30,Y+10 LDD R31,Y+10+1 CALL __ANEGW1 STD Y+10,R30 STD Y+10+1,R31 LDI R20,LOW(45) _0x2000043: CPI R20,0 BREQ _0x2000044 SUBI R17,-LOW(1) RJMP _0x2000045 _0x2000044: ANDI R16,LOW(251) _0x2000045: RJMP _0x2000046 _0x2000042: CALL SUBOPT_0x2 CALL SUBOPT_0x5 _0x2000046: _0x2000036: SBRC R16,0 RJMP _0x2000047 _0x2000048: CP R17,R21 BRSH _0x200004A SBRS R16,7 RJMP _0x200004B SBRS R16,2 RJMP _0x200004C ANDI R16,LOW(251) MOV R18,R20 SUBI R17,LOW(1) RJMP _0x200004D _0x200004C: LDI R18,LOW(48) _0x200004D: RJMP _0x200004E _0x200004B: LDI R18,LOW(32) _0x200004E: CALL SUBOPT_0x1 SUBI R21,LOW(1) RJMP _0x2000048 _0x200004A: _0x2000047: MOV R19,R17 SBRS R16,1 RJMP _0x200004F _0x2000050: CPI R19,0 BREQ _0x2000052 SBRS R16,3 RJMP _0x2000053 LDD R30,Y+6 LDD R31,Y+6+1 LPM R18,Z+ STD Y+6,R30 STD Y+6+1,R31 RJMP _0x2000054 _0x2000053: LDD R26,Y+6 LDD R27,Y+6+1 LD R18,X+ STD Y+6,R26 STD Y+6+1,R27 _0x2000054: CALL SUBOPT_0x1 CPI R21,0 BREQ _0x2000055 SUBI R21,LOW(1) _0x2000055: SUBI R19,LOW(1) RJMP _0x2000050 _0x2000052: RJMP _0x2000056 _0x200004F: _0x2000058: LDI R18,LOW(48) LDD R30,Y+6 LDD R31,Y+6+1 CALL __GETW1PF STD Y+8,R30 STD Y+8+1,R31 LDD R30,Y+6 LDD R31,Y+6+1 ADIW R30,2 STD Y+6,R30 STD Y+6+1,R31 _0x200005A: LDD R30,Y+8 LDD R31,Y+8+1 LDD R26,Y+10 LDD R27,Y+10+1 CP R26,R30 CPC R27,R31 BRLO _0x200005C SUBI R18,-LOW(1) LDD R26,Y+8 LDD R27,Y+8+1 LDD R30,Y+10 LDD R31,Y+10+1 SUB R30,R26 SBC R31,R27 STD Y+10,R30 STD Y+10+1,R31 RJMP _0x200005A _0x200005C: CPI R18,58 BRLO _0x200005D SBRS R16,3 RJMP _0x200005E SUBI R18,-LOW(7) RJMP _0x200005F _0x200005E: SUBI R18,-LOW(39) _0x200005F: _0x200005D: SBRC R16,4 RJMP _0x2000061 CPI R18,49 BRSH _0x2000063 LDD R26,Y+8 LDD R27,Y+8+1 SBIW R26,1 BRNE _0x2000062 _0x2000063: RJMP _0x20000CD _0x2000062: CP R21,R19 BRLO _0x2000067 SBRS R16,0 RJMP _0x2000068 _0x2000067: RJMP _0x2000066 _0x2000068: LDI R18,LOW(32) SBRS R16,7 RJMP _0x2000069 LDI R18,LOW(48) _0x20000CD: ORI R16,LOW(16) SBRS R16,2 RJMP _0x200006A ANDI R16,LOW(251) ST -Y,R20 CALL SUBOPT_0x3 CPI R21,0 BREQ _0x200006B SUBI R21,LOW(1) _0x200006B: _0x200006A: _0x2000069: _0x2000061: CALL SUBOPT_0x1 CPI R21,0 BREQ _0x200006C SUBI R21,LOW(1) _0x200006C: _0x2000066: SUBI R19,LOW(1) LDD R26,Y+8 LDD R27,Y+8+1 SBIW R26,2 BRLO _0x2000059 RJMP _0x2000058 _0x2000059: _0x2000056: SBRS R16,0 RJMP _0x200006D _0x200006E: CPI R21,0 BREQ _0x2000070 SUBI R21,LOW(1) LDI R30,LOW(32) ST -Y,R30 CALL SUBOPT_0x3 RJMP _0x200006E _0x2000070: _0x200006D: _0x2000071: _0x2000030: _0x20000CC: LDI R17,LOW(0) _0x200001B: RJMP _0x2000016 _0x2000018: LDD R26,Y+12 LDD R27,Y+12+1 CALL __GETW1P CALL __LOADLOCR6 ADIW R28,20 RET ; .FEND _sprintf: ; .FSTART _sprintf PUSH R15 MOV R15,R24 SBIW R28,6 CALL __SAVELOCR4 CALL SUBOPT_0x6 SBIW R30,0 BRNE _0x2000072 LDI R30,LOW(65535) LDI R31,HIGH(65535) RJMP _0x2060001 _0x2000072: MOVW R26,R28 ADIW R26,6 CALL __ADDW2R15 MOVW R16,R26 CALL SUBOPT_0x6 STD Y+6,R30 STD Y+6+1,R31 LDI R30,LOW(0) STD Y+8,R30 STD Y+8+1,R30 MOVW R26,R28 ADIW R26,10 CALL __ADDW2R15 CALL __GETW1P ST -Y,R31 ST -Y,R30 ST -Y,R17 ST -Y,R16 LDI R30,LOW(_put_buff_G100) LDI R31,HIGH(_put_buff_G100) ST -Y,R31 ST -Y,R30 MOVW R26,R28 ADIW R26,10 RCALL __print_G100 MOVW R18,R30 LDD R26,Y+6 LDD R27,Y+6+1 LDI R30,LOW(0) ST X,R30 MOVW R30,R18 _0x2060001: CALL __LOADLOCR4 ADIW R28,10 POP R15 RET ; .FEND .CSEG _strlen: ; .FSTART _strlen ST -Y,R27 ST -Y,R26 ld r26,y+ ld r27,y+ clr r30 clr r31 strlen0: ld r22,x+ tst r22 breq strlen1 adiw r30,1 rjmp strlen0 strlen1: ret ; .FEND _strlenf: ; .FSTART _strlenf ST -Y,R27 ST -Y,R26 clr r26 clr r27 ld r30,y+ ld r31,y+ strlenf0: lpm r0,z+ tst r0 breq strlenf1 adiw r26,1 rjmp strlenf0 strlenf1: movw r30,r26 ret ; .FEND .CSEG .DSEG _rx_buffer: .BYTE 0x100 _tx_buffer: .BYTE 0x100 .CSEG ;OPTIMIZER ADDED SUBROUTINE, CALLED 2 TIMES, CODE SIZE REDUCTION:17 WORDS SUBOPT_0x0: MOVW R30,R28 ST -Y,R31 ST -Y,R30 __POINTW1FN _0x20000,38 ST -Y,R31 ST -Y,R30 MOV R30,R17 CLR R31 CLR R22 CLR R23 CALL __PUTPARD1 LDI R24,4 CALL _sprintf ADIW R28,8 MOVW R26,R28 JMP _puts ;OPTIMIZER ADDED SUBROUTINE, CALLED 5 TIMES, CODE SIZE REDUCTION:13 WORDS SUBOPT_0x1: ST -Y,R18 LDD R26,Y+13 LDD R27,Y+13+1 LDD R30,Y+15 LDD R31,Y+15+1 ICALL RET ;OPTIMIZER ADDED SUBROUTINE, CALLED 5 TIMES, CODE SIZE REDUCTION:9 WORDS SUBOPT_0x2: LDD R30,Y+16 LDD R31,Y+16+1 SBIW R30,4 STD Y+16,R30 STD Y+16+1,R31 RET ;OPTIMIZER ADDED SUBROUTINE, CALLED 3 TIMES, CODE SIZE REDUCTION:3 WORDS SUBOPT_0x3: LDD R26,Y+13 LDD R27,Y+13+1 LDD R30,Y+15 LDD R31,Y+15+1 ICALL RET ;OPTIMIZER ADDED SUBROUTINE, CALLED 2 TIMES, CODE SIZE REDUCTION:4 WORDS SUBOPT_0x4: LDD R26,Y+16 LDD R27,Y+16+1 ADIW R26,4 CALL __GETW1P STD Y+6,R30 STD Y+6+1,R31 LDD R26,Y+6 LDD R27,Y+6+1 RET ;OPTIMIZER ADDED SUBROUTINE, CALLED 2 TIMES, CODE SIZE REDUCTION:2 WORDS SUBOPT_0x5: LDD R26,Y+16 LDD R27,Y+16+1 ADIW R26,4 CALL __GETW1P STD Y+10,R30 STD Y+10+1,R31 RET ;OPTIMIZER ADDED SUBROUTINE, CALLED 2 TIMES, CODE SIZE REDUCTION:1 WORDS SUBOPT_0x6: MOVW R26,R28 ADIW R26,12 CALL __ADDW2R15 CALL __GETW1P RET .CSEG __ADDW2R15: CLR R0 ADD R26,R15 ADC R27,R0 RET __ANEGW1: NEG R31 NEG R30 SBCI R31,0 RET __GETW1P: LD R30,X+ LD R31,X SBIW R26,1 RET __GETW1PF: LPM R0,Z+ LPM R31,Z MOV R30,R0 RET __PUTPARD1: ST -Y,R23 ST -Y,R22 ST -Y,R31 ST -Y,R30 RET __SAVELOCR6: ST -Y,R21 __SAVELOCR5: ST -Y,R20 __SAVELOCR4: ST -Y,R19 __SAVELOCR3: ST -Y,R18 __SAVELOCR2: ST -Y,R17 ST -Y,R16 RET __LOADLOCR6: LDD R21,Y+5 __LOADLOCR5: LDD R20,Y+4 __LOADLOCR4: LDD R19,Y+3 __LOADLOCR3: LDD R18,Y+2 __LOADLOCR2: LDD R17,Y+1 LD R16,Y RET ;END OF CODE MARKER __END_OF_CODE:
; A129654: Number of different ways to represent n as general polygonal number P(m,r) = 1/2*r*((m-2)*r-(m-4)) = n>1, for m,r>1. ; 1,2,2,2,3,2,2,3,3,2,3,2,2,4,3,2,3,2,2,4,3,2,3,3,2,3,4,2,3,2,2,3,3,3,5,2,2,3,3,2,3,2,2,5,3,2,3,3,2,4,3,2,3,4,2,3,3,2,3,2,2,3,4,3,5,2,2,3,4,2,3,2,2,4,3,2,4,2,2,5,3,2,3,3,2,3,3,2,3,4,3,3,3,3,4,2,2,3,4,2 mov $6,$0 mov $8,2 lpb $8 mov $0,$6 mov $2,0 mov $3,0 mov $5,0 sub $8,1 add $0,$8 sub $0,1 lpb $0 mov $7,$0 sub $0,1 add $2,1 add $3,1 div $7,$3 add $3,$2 add $5,$7 lpe mov $4,$8 mov $7,$5 lpb $4 mov $1,$7 sub $4,1 lpe lpe lpb $6 sub $1,$7 mov $6,0 lpe add $1,1 mov $0,$1
#include "StdAfx.h" #include "MGetOptions.h" #include "MVersionConstraint.h" #include "MOpTimeoutController.h" #include "MSecondaryTarget.h" #include <string> using namespace std; #include "skconstants.h" #include "SKGetOptions.h" #include "SKVersionConstraint.h" #include "SKOpTimeoutController.h" #include "SKSecondaryTarget.h" namespace SKManagedClient { MGetOptions::!MGetOptions() { if(pImpl) { delete (SKGetOptions*)pImpl ; pImpl = NULL; } } MGetOptions::~MGetOptions() { this->!MGetOptions(); } MGetOptions::MGetOptions(SKRetrievalType_M retrievalType, MVersionConstraint ^ versionConstraint) { SKGetOptions * pGetOpt = new SKGetOptions( (SKRetrievalType) retrievalType, (SKVersionConstraint *)(versionConstraint->getPImpl()->pVersionConstraint) ); pImpl = pGetOpt; } MGetOptions::MGetOptions(SKRetrievalType_M retrievalType) { SKGetOptions * pGetOpt = new SKGetOptions( (SKRetrievalType) retrievalType ); pImpl = pGetOpt; } MGetOptions::MGetOptions(MOpTimeoutController ^ opTimeoutController, SKRetrievalType_M retrievalType, MVersionConstraint ^ versionConstraint, SKNonExistenceResponse_M nonExistenceResponse, bool verifyChecksums, bool updateSecondariesOnMiss, HashSet<MSecondaryTarget^> ^ secondaryTargets) { SKOpTimeoutController * pOpTimeoutCtrl = (SKOpTimeoutController *) (opTimeoutController->getPImpl()->pOpTimeoutController); std::set<SKSecondaryTarget*> * pTgtSet = new std::set<SKSecondaryTarget*>(); System::Collections::Generic::IEnumerator<MSecondaryTarget^> ^ hse = secondaryTargets->GetEnumerator(); while(hse->MoveNext()){ MSecondaryTarget^ tgt = hse->Current; SKSecondaryTarget * pTgtg = (SKSecondaryTarget *) (tgt->getPImpl()->pSecondaryTarget); pTgtSet->insert(pTgtg); } SKGetOptions * pGetOpt = new SKGetOptions( pOpTimeoutCtrl, (SKRetrievalType) retrievalType, (SKVersionConstraint *)(versionConstraint->getPImpl()->pVersionConstraint), (SKNonExistenceResponse::SKNonExistenceResponse) nonExistenceResponse, verifyChecksums, updateSecondariesOnMiss, pTgtSet ); delete pTgtSet; pImpl = pGetOpt; } MGetOptions::MGetOptions(MOpTimeoutController ^ opTimeoutController, SKRetrievalType_M retrievalType, MVersionConstraint ^ versionConstraint) { SKOpTimeoutController * pOpTimeoutCtrl = (SKOpTimeoutController *) (opTimeoutController->getPImpl()->pOpTimeoutController); SKGetOptions * pGetOpt = new SKGetOptions( pOpTimeoutCtrl, (SKRetrievalType) retrievalType, (SKVersionConstraint *)(versionConstraint->getPImpl()->pVersionConstraint) ); pImpl = pGetOpt; } MGetOptions::MGetOptions(SKGetOptions_M ^ opt) { pImpl = opt->pGetOptions; } SKGetOptions_M ^ MGetOptions::getPImpl() { SKGetOptions_M ^ opt = gcnew SKGetOptions_M; opt->pGetOptions = pImpl; return opt; } //methods MRetrievalOptions ^ MGetOptions::retrievalType(SKRetrievalType_M retrievalType) { ((SKGetOptions*)pImpl)->retrievalType((SKRetrievalType)retrievalType); return this; } MRetrievalOptions ^ MGetOptions::versionConstraint(MVersionConstraint ^ versionConstraint) { ((SKGetOptions*)pImpl)->versionConstraint( (SKVersionConstraint*) (versionConstraint->getPImpl()->pVersionConstraint)); return this; } MRetrievalOptions ^ MGetOptions::waitMode(SKWaitMode_M waitMode) { ((SKGetOptions*)pImpl)->waitMode((SKWaitMode)waitMode); return this; } MRetrievalOptions ^ MGetOptions::nonExistenceResponse(SKNonExistenceResponse_M nonExistenceResponse) { ((SKGetOptions*)pImpl)->nonExistenceResponse((SKNonExistenceResponse::SKNonExistenceResponse)nonExistenceResponse); return this; } SKRetrievalType_M MGetOptions::getRetrievalType() { SKRetrievalType rt = ((SKGetOptions*)pImpl)->getRetrievalType(); return (SKRetrievalType_M) rt; } SKWaitMode_M MGetOptions::getWaitMode() { SKWaitMode wm = ((SKGetOptions*)pImpl)->getWaitMode(); return (SKWaitMode_M) wm; } MVersionConstraint ^ MGetOptions::getVersionConstraint() { SKVersionConstraint * pvc = ((SKGetOptions*)pImpl)->getVersionConstraint(); SKVersionConstraint_M ^ vc_m = gcnew SKVersionConstraint_M; vc_m->pVersionConstraint = pvc; MVersionConstraint ^ mvc = gcnew MVersionConstraint(vc_m); return mvc; } SKNonExistenceResponse_M MGetOptions::getNonExistenceResponse() { SKNonExistenceResponse::SKNonExistenceResponse nr = ((SKGetOptions*)pImpl)->getNonExistenceResponse(); return (SKNonExistenceResponse_M) nr; } bool MGetOptions::getVerifyChecksums() { return ((SKGetOptions*)pImpl)->getVerifyChecksums(); } String ^ MGetOptions::toString() { string cppstr = ((SKGetOptions*)pImpl)->toString(); System::String ^ str = gcnew System::String(cppstr.c_str()); return str; } /* bool MGetOptions::equals(MGetOptions ^ other) { SKGetOptions* pgo = (SKGetOptions*)(other->getPImpl()->pGetOptions) return ((SKGetOptions*)pImpl)->equals(pgo); } bool operator == (MGetOptions ^ go1, MGetOptions ^ go2) const { return go1->equals(go2); //FIXME equals should be expressed through operator == } */ MRetrievalOptions ^ MGetOptions::updateSecondariesOnMiss(bool updateSecondariesOnMiss){ ((SKGetOptions*)pImpl)->updateSecondariesOnMiss(updateSecondariesOnMiss); return this; } bool MGetOptions::getUpdateSecondariesOnMiss(){ return ((SKGetOptions*)pImpl)->getUpdateSecondariesOnMiss(); } MRetrievalOptions ^ MGetOptions::secondaryTargets(HashSet<MSecondaryTarget^> ^ secondaryTargets){ std::set<SKSecondaryTarget*> * pTgtSet = new std::set<SKSecondaryTarget*>(); System::Collections::Generic::IEnumerator<MSecondaryTarget^> ^ hse = secondaryTargets->GetEnumerator(); while(hse->MoveNext()){ MSecondaryTarget^ tgt = hse->Current; SKSecondaryTarget * pTgtg = (SKSecondaryTarget *) (tgt->getPImpl()->pSecondaryTarget); pTgtSet->insert(pTgtg); } ((SKGetOptions*)pImpl)->secondaryTargets( pTgtSet ); delete pTgtSet; return this; } HashSet<MSecondaryTarget^> ^ MGetOptions::getSecondaryTargets(){ std::set<SKSecondaryTarget*> * pTgts = ((SKGetOptions*)pImpl)->getSecondaryTargets(); std::set<SKSecondaryTarget*>::iterator it; HashSet< MSecondaryTarget^ > ^ secondaryTargets = gcnew HashSet< MSecondaryTarget^ >(); for(it=pTgts->begin(); it!=pTgts->end(); it++) { SKSecondaryTarget * pTarget = *it; SKSecondaryTarget_M ^ target = gcnew SKSecondaryTarget_M; target->pSecondaryTarget = pTarget; MSecondaryTarget ^ secondaryTarget = gcnew MSecondaryTarget(target); secondaryTargets->Add(secondaryTarget); } delete pTgts; pTgts = NULL; return secondaryTargets; } bool MGetOptions::equals(MRetrievalOptions ^ other){ if( this->GetType() != MGetOptions::typeid || other->GetType() != this->GetType()) return false; return ((SKGetOptions*)pImpl)->equals((SKGetOptions*)(((MGetOptions^)other)->getPImpl()->pGetOptions)); } }
; ; Copyright (C) 2009-2015 Intel Corporation. ; SPDX-License-Identifier: MIT ; PUBLIC SetXmmScratchesFun extern xmmInitVals:dword .code SetXmmScratchesFun PROC lea rax,xmmInitVals movdqu xmm0, xmmword ptr [rax] movdqu xmm1, xmmword ptr [rax]+32 movdqu xmm2, xmmword ptr [rax]+64 movdqu xmm3, xmmword ptr [rax]+96 movdqu xmm4, xmmword ptr [rax]+128 movdqu xmm5, xmmword ptr [rax]+160 ret SetXmmScratchesFun ENDP end
/* FreeRTOS V9.0.0 - Copyright (C) 2016 Real Time Engineers Ltd. All rights reserved VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION. This file is part of the FreeRTOS distribution. FreeRTOS is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License (version 2) as published by the Free Software Foundation >>>> AND MODIFIED BY <<<< the FreeRTOS exception. *************************************************************************** >>! NOTE: The modification to the GPL is included to allow you to !<< >>! distribute a combined work that includes FreeRTOS without being !<< >>! obliged to provide the source code for proprietary components !<< >>! outside of the FreeRTOS kernel. !<< *************************************************************************** FreeRTOS 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. Full license text is available on the following link: http://www.freertos.org/a00114.html *************************************************************************** * * * FreeRTOS provides completely free yet professionally developed, * * robust, strictly quality controlled, supported, and cross * * platform software that is more than just the market leader, it * * is the industry's de facto standard. * * * * Help yourself get started quickly while simultaneously helping * * to support the FreeRTOS project by purchasing a FreeRTOS * * tutorial book, reference manual, or both: * * http://www.FreeRTOS.org/Documentation * * * *************************************************************************** http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading the FAQ page "My application does not run, what could be wrong?". Have you defined configASSERT()? http://www.FreeRTOS.org/support - In return for receiving this top quality embedded software for free we request you assist our global community by participating in the support forum. http://www.FreeRTOS.org/training - Investing in training allows your team to be as productive as possible as early as possible. Now you can receive FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers Ltd, and the world's leading authority on the world's leading RTOS. http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products, including FreeRTOS+Trace - an indispensable productivity tool, a DOS compatible FAT file system, and our tiny thread aware UDP/IP stack. http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate. Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS. http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS licenses offer ticketed support, indemnification and commercial middleware. http://www.SafeRTOS.com - High Integrity Systems also provide a safety engineered and independently SIL3 certified version for use in safety and mission critical applications that require provable dependability. 1 tab == 4 spaces! */ #include "FreeRTOSConfig.h" #include "portasm.h" .CODE /* * The RTOS tick ISR. * * If the cooperative scheduler is in use this simply increments the tick * count. * * If the preemptive scheduler is in use a context switch can also occur. */ _vTickISR: portSAVE_CONTEXT call #_xTaskIncrementTick cmp.w #0x00, r15 jeq _SkipContextSwitch call #_vTaskSwitchContext _SkipContextSwitch: portRESTORE_CONTEXT /*-----------------------------------------------------------*/ /* * Manual context switch called by the portYIELD() macro. */ _vPortYield:: /* Mimic an interrupt by pushing the SR. */ push SR /* Now the SR is stacked we can disable interrupts. */ dint /* Save the context of the current task. */ portSAVE_CONTEXT /* Switch to the highest priority task that is ready to run. */ call #_vTaskSwitchContext /* Restore the context of the new task. */ portRESTORE_CONTEXT /*-----------------------------------------------------------*/ /* * Start off the scheduler by initialising the RTOS tick timer, then restoring * the context of the first task. */ _xPortStartScheduler:: /* Setup the hardware to generate the tick. Interrupts are disabled when this function is called. */ call #_prvSetupTimerInterrupt /* Restore the context of the first task that is going to run. */ portRESTORE_CONTEXT /*-----------------------------------------------------------*/ /* Place the tick ISR in the correct vector. */ .VECTORS .KEEP ORG TIMERA0_VECTOR DW _vTickISR END
; A103154: Each letter appears an even number of times in the English names for 1 through n taken together (names without "and"). ; 119,139,159,179,199,319,339,359,379,399,519,539,559,579,599,719,739,759,779,799,919,939,959,979,999,1119,1139,1159,1179,1199,1319,1339,1359,1379,1399,1519,1539,1559,1579,1599,1719,1739,1759,1779,1799,1919 mov $1,$0 div $0,5 mul $0,5 add $1,$0 mul $1,20 add $1,119