text stringlengths 1 1.05M |
|---|
; ---------------------------------------------------------------------------
; Animation script - bubbles (LZ)
; ---------------------------------------------------------------------------
dc.w byte_129AA-Ani_obj64
dc.w byte_129B0-Ani_obj64
dc.w byte_129B6-Ani_obj64
dc.w byte_129BE-Ani_obj64
dc.w byte_129BE-Ani_obj64
dc.w byte_129C0-Ani_obj64
dc.w byte_129C6-Ani_obj64
byte_129AA: dc.b $E, 0, 1, 2, $FC, 0
byte_129B0: dc.b $E, 1, 2, 3, 4, $FC
byte_129B6: dc.b $E, 2, 3, 4, 5, 6, $FC, 0
byte_129BE: dc.b 4, $FC
byte_129C0: dc.b 4, 6, 7, 8, $FC, 0
byte_129C6: dc.b $F, $13, $14, $15, $FF
even |
#include "gps.h"
#include "libgpsmm.h" // GPS
#include "math.h"
#include <stdlib.h>
/*
* degrees: converts decimal angle to degree component.
*
*/
int gps::degrees(float angle) {
return abs((int)angle);
}
/*
* minutes: converts decimal angle to minutes component.
*
*/
int gps::minutes(float angle) {
int deg = degrees(angle);
int min = (int)((fabs(angle) - deg) * 60.00);
return min;
}
/*
* seconds: converts decimal angle to seconds component.
*
*/
float gps::seconds(float angle) {
int deg = degrees(angle);
int min = minutes(angle);
float sec = (((fabs(angle) - deg) * 60.00) - (float)min) * 60.00;
return sec;
}
int gps::latitude_degrees() {
return degrees(gps_lat);
}
int gps::latitude_minutes() {
return minutes(gps_lat);
}
float gps::latitude_seconds() {
return seconds(gps_lat);
}
int gps::longitude_degrees() {
return degrees(gps_lon);
}
int gps::longitude_minutes() {
return minutes(gps_lon);
}
float gps::longitude_seconds() {
return seconds(gps_lon);
}
bool gps::start() {
/* Initialize GPS */
gps_rec = new gpsmm("localhost", DEFAULT_GPSD_PORT);
//console_log("** Initializing GPS.");
if (gps_rec->stream(WATCH_ENABLE | WATCH_JSON) == NULL) {
return false;
}
return true;
}
bool gps::stop() {
if(gps_rec->stream(WATCH_DISABLE) == NULL) {
delete gps_rec;
return false;
}
delete gps_rec;
return true;
}
bool gps::update() {
struct gps_data_t* gps_data;
if (gps_rec->waiting(00050000)) {
/* See if we're reading data. */
if ((gps_data = gps_rec->read()) == NULL) {
return false;
}
if (gps_data->status == STATUS_FIX && (gps_data->fix.mode == MODE_2D || gps_data->fix.mode == MODE_3D)) {
/* Fix Obtained, Set Values. */
gps_fix = gps_data->fix.mode;
gps_lon = gps_data->fix.longitude;
gps_lat = gps_data->fix.latitude;
gps_alt = gps_data->fix.altitude;
gps_sat = gps_data->satellites_visible;
gps_use = gps_data->satellites_used;
}
}
return true;
} |
/*!
@file
Forward declares `boost::hana::union_`.
@copyright Louis Dionne 2013-2017
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
*/
#ifndef BOOST_HANA_FWD_UNION_HPP
#define BOOST_HANA_FWD_UNION_HPP
#include <boost/hana/config.hpp>
#include <boost/hana/core/when.hpp>
BOOST_HANA_NAMESPACE_BEGIN
//! Returns the union of two sets.
//! @relates hana::set
//!
//! Given two sets `xs` and `ys`, `union_(xs, ys)` is a new set containing
//! all the elements of `xs` and all the elements of `ys`, without
//! duplicates. For any object `x`, the following holds:
//! @code
//! x ^in^ union_(xs, ys) if and only if x ^in^ xs || x ^in^ ys
//! @endcode
//!
//!
//! @param xs, ys
//! Two sets to compute the union of.
//!
//!
//! Example
//! -------
//! @include example/union.cpp
#ifdef BOOST_HANA_DOXYGEN_INVOKED
constexpr auto union_ = [](auto&& xs, auto&& ys) {
return tag-dispatched;
};
#else
template <typename S, typename = void>
struct union_impl : union_impl<S, when<true>> { };
struct union_t {
template <typename Xs, typename Ys>
constexpr auto operator()(Xs&& xs, Ys&& ys) const;
};
constexpr union_t union_{};
#endif
BOOST_HANA_NAMESPACE_END
#endif // !BOOST_HANA_FWD_UNION_HPP
|
#ifndef DIRECTED_GRAPH_HH
#define DIRECTED_GRAPH_HH
#include <string>
#include <vector>
#include <utility>
#include "Graph.hh"
#include "EdgeType.hh"
#include "Edge.hh"
#include "Vertex.hh"
using namespace std;
template <typename V>
class DirectedGraph : public Graph<V> {
protected:
vector< pair< Vertex*, vector<unsigned int> > > adjacency_;
vector< Edge<V> > edges_;
public:
/* Constructors */
DirectedGraph() : Graph<V>() {}
DirectedGraph(string name) : Graph<V>(name) {}
/* Methods */
unsigned int addEdge(EdgeType type, V distance, unsigned int start, unsigned int end);
unsigned int addVertex(string);
unsigned int addVertex(Vertex*);
Edge<V> getEdge(unsigned int);
Vertex* getVertex(unsigned int);
vector<Edge<V>*> outgoingEdges(unsigned int);
vector<Vertex*> adjacentVertices(unsigned int);
/* Destructor */
~DirectedGraph();
};
#endif
|
; A052760: Expansion of e.g.f.: x^2*(exp(x)-1)^2.
; 0,0,0,0,24,120,420,1260,3472,9072,22860,56100,134904,319176,745108,1719900,3931680,8912352,20053404,44825940,99613960,220200120,484441188,1061157900,2315254704,5033163600,10905189100,23555209860,50734299672,108984793512,233538844980,499289946300,1065151887424,2267742730176,4818953303868,10222022162100,21646635169320,45767171503512,96619584288004,203684529042540,428809534829520,901599534773040,1893359023026828,3971435999523300,8321103999004984,17416264183967880,36415825111936980
mov $2,$0
bin $0,2
mov $3,2
pow $3,$2
sub $3,8
mul $0,$3
div $0,8
mul $0,4
|
// Copyright (c) 2011-2014 The Bitcoin developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "dobbscoingui.h"
#include "dobbscoinunits.h"
#include "clientmodel.h"
#include "guiconstants.h"
#include "guiutil.h"
#include "networkstyle.h"
#include "notificator.h"
#include "openuridialog.h"
#include "optionsdialog.h"
#include "optionsmodel.h"
#include "rpcconsole.h"
#include "utilitydialog.h"
#ifdef ENABLE_WALLET
#include "walletframe.h"
#include "walletmodel.h"
#endif // ENABLE_WALLET
#ifdef Q_OS_MAC
#include "macdockiconhandler.h"
#endif
#include "init.h"
#include "ui_interface.h"
#include "util.h"
#include <iostream>
#include <QAction>
#include <QApplication>
#include <QDateTime>
#include <QDesktopWidget>
#include <QDragEnterEvent>
#include <QIcon>
#include <QListWidget>
#include <QMenuBar>
#include <QMessageBox>
#include <QMimeData>
#include <QProgressBar>
#include <QProgressDialog>
#include <QSettings>
#include <QStackedWidget>
#include <QStatusBar>
#include <QStyle>
#include <QTimer>
#include <QToolBar>
#include <QVBoxLayout>
#if QT_VERSION < 0x050000
#include <QTextDocument>
#include <QUrl>
#else
#include <QUrlQuery>
#endif
const QString DobbscoinGUI::DEFAULT_WALLET = "~Default";
DobbscoinGUI::DobbscoinGUI(const NetworkStyle *networkStyle, QWidget *parent) :
QMainWindow(parent),
clientModel(0),
walletFrame(0),
unitDisplayControl(0),
labelEncryptionIcon(0),
labelConnectionsIcon(0),
labelBlocksIcon(0),
progressBarLabel(0),
progressBar(0),
progressDialog(0),
appMenuBar(0),
overviewAction(0),
historyAction(0),
quitAction(0),
sendCoinsAction(0),
usedSendingAddressesAction(0),
usedReceivingAddressesAction(0),
signMessageAction(0),
verifyMessageAction(0),
aboutAction(0),
receiveCoinsAction(0),
optionsAction(0),
toggleHideAction(0),
encryptWalletAction(0),
backupWalletAction(0),
changePassphraseAction(0),
aboutQtAction(0),
openRPCConsoleAction(0),
openAction(0),
showHelpMessageAction(0),
trayIcon(0),
trayIconMenu(0),
notificator(0),
rpcConsole(0),
prevBlocks(0),
spinnerFrame(0)
{
GUIUtil::restoreWindowGeometry("nWindow", QSize(850, 550), this);
//also .OverviewPage is useful fro some stuff
this->setStyleSheet(".WalletFrame {background-image: url(\":images/bgtile\"); }");
QString windowTitle = tr("Dobbscoin Core") + " - ";
#ifdef ENABLE_WALLET
/* if compiled with wallet support, -disablewallet can still disable the wallet */
enableWallet = !GetBoolArg("-disablewallet", false);
#else
enableWallet = false;
#endif // ENABLE_WALLET
if(enableWallet)
{
windowTitle += tr("Wallet");
} else {
windowTitle += tr("Node");
}
windowTitle += " " + networkStyle->getTitleAddText();
#ifndef Q_OS_MAC
QApplication::setWindowIcon(networkStyle->getAppIcon());
setWindowIcon(networkStyle->getAppIcon());
#else
MacDockIconHandler::instance()->setIcon(networkStyle->getAppIcon());
#endif
setWindowTitle(windowTitle);
#if defined(Q_OS_MAC) && QT_VERSION < 0x050000
// This property is not implemented in Qt 5. Setting it has no effect.
// A replacement API (QtMacUnifiedToolBar) is available in QtMacExtras.
setUnifiedTitleAndToolBarOnMac(true);
#endif
rpcConsole = new RPCConsole(enableWallet ? this : 0);
#ifdef ENABLE_WALLET
if(enableWallet)
{
/** Create wallet frame and make it the central widget */
walletFrame = new WalletFrame(this);
setCentralWidget(walletFrame);
} else
#endif // ENABLE_WALLET
{
/* When compiled without wallet or -disablewallet is provided,
* the central widget is the rpc console.
*/
setCentralWidget(rpcConsole);
}
// Accept D&D of URIs
setAcceptDrops(true);
// Create actions for the toolbar, menu bar and tray/dock icon
// Needs walletFrame to be initialized
createActions(networkStyle);
// Create application menu bar
createMenuBar();
// Create the toolbars
createToolBars();
// Create system tray icon and notification
createTrayIcon(networkStyle);
// Create status bar
statusBar();
// Status bar notification icons
QFrame *frameBlocks = new QFrame();
frameBlocks->setContentsMargins(0,0,0,0);
frameBlocks->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred);
QHBoxLayout *frameBlocksLayout = new QHBoxLayout(frameBlocks);
frameBlocksLayout->setContentsMargins(3,0,3,0);
frameBlocksLayout->setSpacing(3);
unitDisplayControl = new UnitDisplayStatusBarControl();
labelEncryptionIcon = new QLabel();
labelConnectionsIcon = new QLabel();
labelBlocksIcon = new QLabel();
if(enableWallet)
{
frameBlocksLayout->addStretch();
frameBlocksLayout->addWidget(unitDisplayControl);
frameBlocksLayout->addStretch();
frameBlocksLayout->addWidget(labelEncryptionIcon);
}
frameBlocksLayout->addStretch();
frameBlocksLayout->addWidget(labelConnectionsIcon);
frameBlocksLayout->addStretch();
frameBlocksLayout->addWidget(labelBlocksIcon);
frameBlocksLayout->addStretch();
// Progress bar and label for blocks download
progressBarLabel = new QLabel();
progressBarLabel->setVisible(false);
progressBar = new GUIUtil::ProgressBar();
progressBar->setAlignment(Qt::AlignCenter);
progressBar->setVisible(false);
// Override style sheet for progress bar for styles that have a segmented progress bar,
// as they make the text unreadable (workaround for issue #1071)
// See https://qt-project.org/doc/qt-4.8/gallery.html
QString curStyle = QApplication::style()->metaObject()->className();
if(curStyle == "QWindowsStyle" || curStyle == "QWindowsXPStyle")
{
progressBar->setStyleSheet("QProgressBar { background-color: #e8e8e8; border: 1px solid grey; border-radius: 7px; padding: 1px; text-align: center; } QProgressBar::chunk { background: QLinearGradient(x1: 0, y1: 0, x2: 1, y2: 0, stop: 0 #FF8000, stop: 1 orange); border-radius: 7px; margin: 0px; }");
}
statusBar()->addWidget(progressBarLabel);
statusBar()->addWidget(progressBar);
statusBar()->addPermanentWidget(frameBlocks);
connect(openRPCConsoleAction, SIGNAL(triggered()), rpcConsole, SLOT(show()));
// prevents an open debug window from becoming stuck/unusable on client shutdown
connect(quitAction, SIGNAL(triggered()), rpcConsole, SLOT(hide()));
// Install event filter to be able to catch status tip events (QEvent::StatusTip)
this->installEventFilter(this);
// Initially wallet actions should be disabled
setWalletActionsEnabled(false);
// Subscribe to notifications from core
subscribeToCoreSignals();
}
DobbscoinGUI::~DobbscoinGUI()
{
// Unsubscribe from notifications from core
unsubscribeFromCoreSignals();
GUIUtil::saveWindowGeometry("nWindow", this);
if(trayIcon) // Hide tray icon, as deleting will let it linger until quit (on Ubuntu)
trayIcon->hide();
#ifdef Q_OS_MAC
delete appMenuBar;
MacDockIconHandler::cleanup();
#endif
}
void DobbscoinGUI::createActions(const NetworkStyle *networkStyle)
{
QActionGroup *tabGroup = new QActionGroup(this);
overviewAction = new QAction(QIcon(":/icons/overview"), tr("&Overview"), this);
overviewAction->setStatusTip(tr("Show general overview of wallet"));
overviewAction->setToolTip(overviewAction->statusTip());
overviewAction->setCheckable(true);
overviewAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_1));
tabGroup->addAction(overviewAction);
sendCoinsAction = new QAction(QIcon(":/icons/send"), tr("&Send"), this);
sendCoinsAction->setStatusTip(tr("Send coins to a Dobbscoin address"));
sendCoinsAction->setToolTip(sendCoinsAction->statusTip());
sendCoinsAction->setCheckable(true);
sendCoinsAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_2));
tabGroup->addAction(sendCoinsAction);
receiveCoinsAction = new QAction(QIcon(":/icons/receiving_addresses"), tr("&Receive"), this);
receiveCoinsAction->setStatusTip(tr("Request payments (generates QR codes and dobbscoin: URIs)"));
receiveCoinsAction->setToolTip(receiveCoinsAction->statusTip());
receiveCoinsAction->setCheckable(true);
receiveCoinsAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_3));
tabGroup->addAction(receiveCoinsAction);
historyAction = new QAction(QIcon(":/icons/history"), tr("&Transactions"), this);
historyAction->setStatusTip(tr("Browse transaction history"));
historyAction->setToolTip(historyAction->statusTip());
historyAction->setCheckable(true);
historyAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_4));
tabGroup->addAction(historyAction);
#ifdef ENABLE_WALLET
// These showNormalIfMinimized are needed because Send Coins and Receive Coins
// can be triggered from the tray menu, and need to show the GUI to be useful.
connect(overviewAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized()));
connect(overviewAction, SIGNAL(triggered()), this, SLOT(gotoOverviewPage()));
connect(sendCoinsAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized()));
connect(sendCoinsAction, SIGNAL(triggered()), this, SLOT(gotoSendCoinsPage()));
connect(receiveCoinsAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized()));
connect(receiveCoinsAction, SIGNAL(triggered()), this, SLOT(gotoReceiveCoinsPage()));
connect(historyAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized()));
connect(historyAction, SIGNAL(triggered()), this, SLOT(gotoHistoryPage()));
#endif // ENABLE_WALLET
quitAction = new QAction(QIcon(":/icons/quit"), tr("E&xit"), this);
quitAction->setStatusTip(tr("Quit application"));
quitAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Q));
quitAction->setMenuRole(QAction::QuitRole);
aboutAction = new QAction(networkStyle->getAppIcon(), tr("&About Dobbscoin Core"), this);
aboutAction->setStatusTip(tr("Show information about Dobbscoin Core"));
aboutAction->setMenuRole(QAction::AboutRole);
#if QT_VERSION < 0x050000
aboutQtAction = new QAction(QIcon(":/trolltech/qmessagebox/images/qtlogo-64.png"), tr("About &Qt"), this);
#else
aboutQtAction = new QAction(QIcon(":/qt-project.org/qmessagebox/images/qtlogo-64.png"), tr("About &Qt"), this);
#endif
aboutQtAction->setStatusTip(tr("Show information about Qt"));
aboutQtAction->setMenuRole(QAction::AboutQtRole);
optionsAction = new QAction(QIcon(":/icons/options"), tr("&Options..."), this);
optionsAction->setStatusTip(tr("Modify configuration options for Dobbscoin"));
optionsAction->setMenuRole(QAction::PreferencesRole);
toggleHideAction = new QAction(networkStyle->getAppIcon(), tr("&Show / Hide"), this);
toggleHideAction->setStatusTip(tr("Show or hide the main Window"));
encryptWalletAction = new QAction(QIcon(":/icons/lock_closed"), tr("&Encrypt Wallet..."), this);
encryptWalletAction->setStatusTip(tr("Encrypt the private keys that belong to your wallet"));
encryptWalletAction->setCheckable(true);
backupWalletAction = new QAction(QIcon(":/icons/filesave"), tr("&Backup Wallet..."), this);
backupWalletAction->setStatusTip(tr("Backup wallet to another location"));
changePassphraseAction = new QAction(QIcon(":/icons/key"), tr("&Change Passphrase..."), this);
changePassphraseAction->setStatusTip(tr("Change the passphrase used for wallet encryption"));
signMessageAction = new QAction(QIcon(":/icons/edit"), tr("Sign &message..."), this);
signMessageAction->setStatusTip(tr("Sign messages with your Dobbscoin addresses to prove you own them"));
verifyMessageAction = new QAction(QIcon(":/icons/transaction_0"), tr("&Verify message..."), this);
verifyMessageAction->setStatusTip(tr("Verify messages to ensure they were signed with specified Dobbscoin addresses"));
openRPCConsoleAction = new QAction(QIcon(":/icons/debugwindow"), tr("&Debug window"), this);
openRPCConsoleAction->setStatusTip(tr("Open debugging and diagnostic console"));
usedSendingAddressesAction = new QAction(QIcon(":/icons/address-book"), tr("&Sending addresses..."), this);
usedSendingAddressesAction->setStatusTip(tr("Show the list of used sending addresses and labels"));
usedReceivingAddressesAction = new QAction(QIcon(":/icons/address-book"), tr("&Receiving addresses..."), this);
usedReceivingAddressesAction->setStatusTip(tr("Show the list of used receiving addresses and labels"));
openAction = new QAction(QApplication::style()->standardIcon(QStyle::SP_FileIcon), tr("Open &URI..."), this);
openAction->setStatusTip(tr("Open a dobbscoin: URI or payment request"));
showHelpMessageAction = new QAction(QApplication::style()->standardIcon(QStyle::SP_MessageBoxInformation), tr("&Command-line options"), this);
showHelpMessageAction->setMenuRole(QAction::NoRole);
showHelpMessageAction->setStatusTip(tr("Show the Dobbscoin Core help message to get a list with possible Dobbscoin command-line options"));
connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit()));
connect(aboutAction, SIGNAL(triggered()), this, SLOT(aboutClicked()));
connect(aboutQtAction, SIGNAL(triggered()), qApp, SLOT(aboutQt()));
connect(optionsAction, SIGNAL(triggered()), this, SLOT(optionsClicked()));
connect(toggleHideAction, SIGNAL(triggered()), this, SLOT(toggleHidden()));
connect(showHelpMessageAction, SIGNAL(triggered()), this, SLOT(showHelpMessageClicked()));
#ifdef ENABLE_WALLET
if(walletFrame)
{
connect(encryptWalletAction, SIGNAL(triggered(bool)), walletFrame, SLOT(encryptWallet(bool)));
connect(backupWalletAction, SIGNAL(triggered()), walletFrame, SLOT(backupWallet()));
connect(changePassphraseAction, SIGNAL(triggered()), walletFrame, SLOT(changePassphrase()));
connect(signMessageAction, SIGNAL(triggered()), this, SLOT(gotoSignMessageTab()));
connect(verifyMessageAction, SIGNAL(triggered()), this, SLOT(gotoVerifyMessageTab()));
connect(usedSendingAddressesAction, SIGNAL(triggered()), walletFrame, SLOT(usedSendingAddresses()));
connect(usedReceivingAddressesAction, SIGNAL(triggered()), walletFrame, SLOT(usedReceivingAddresses()));
connect(openAction, SIGNAL(triggered()), this, SLOT(openClicked()));
}
#endif // ENABLE_WALLET
}
void DobbscoinGUI::createMenuBar()
{
#ifdef Q_OS_MAC
// Create a decoupled menu bar on Mac which stays even if the window is closed
appMenuBar = new QMenuBar();
#else
// Get the main window's menu bar on other platforms
appMenuBar = menuBar();
#endif
// Configure the menus
QMenu *file = appMenuBar->addMenu(tr("&File"));
if(walletFrame)
{
file->addAction(openAction);
file->addAction(backupWalletAction);
file->addAction(signMessageAction);
file->addAction(verifyMessageAction);
file->addSeparator();
file->addAction(usedSendingAddressesAction);
file->addAction(usedReceivingAddressesAction);
file->addSeparator();
}
file->addAction(quitAction);
QMenu *settings = appMenuBar->addMenu(tr("&Settings"));
if(walletFrame)
{
settings->addAction(encryptWalletAction);
settings->addAction(changePassphraseAction);
settings->addSeparator();
}
settings->addAction(optionsAction);
QMenu *help = appMenuBar->addMenu(tr("&Help"));
if(walletFrame)
{
help->addAction(openRPCConsoleAction);
}
help->addAction(showHelpMessageAction);
help->addSeparator();
help->addAction(aboutAction);
help->addAction(aboutQtAction);
}
void DobbscoinGUI::createToolBars()
{
if(walletFrame)
{
QToolBar *toolbar = addToolBar(tr("Tabs toolbar"));
toolbar->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
toolbar->addAction(overviewAction);
toolbar->addAction(sendCoinsAction);
toolbar->addAction(receiveCoinsAction);
toolbar->addAction(historyAction);
overviewAction->setChecked(true);
}
}
void DobbscoinGUI::setClientModel(ClientModel *clientModel)
{
this->clientModel = clientModel;
if(clientModel)
{
// Create system tray menu (or setup the dock menu) that late to prevent users from calling actions,
// while the client has not yet fully loaded
createTrayIconMenu();
// Keep up to date with client
setNumConnections(clientModel->getNumConnections());
connect(clientModel, SIGNAL(numConnectionsChanged(int)), this, SLOT(setNumConnections(int)));
setNumBlocks(clientModel->getNumBlocks());
connect(clientModel, SIGNAL(numBlocksChanged(int)), this, SLOT(setNumBlocks(int)));
// Receive and report messages from client model
connect(clientModel, SIGNAL(message(QString,QString,unsigned int)), this, SLOT(message(QString,QString,unsigned int)));
// Show progress dialog
connect(clientModel, SIGNAL(showProgress(QString,int)), this, SLOT(showProgress(QString,int)));
rpcConsole->setClientModel(clientModel);
#ifdef ENABLE_WALLET
if(walletFrame)
{
walletFrame->setClientModel(clientModel);
}
#endif // ENABLE_WALLET
unitDisplayControl->setOptionsModel(clientModel->getOptionsModel());
} else {
// Disable possibility to show main window via action
toggleHideAction->setEnabled(false);
if(trayIconMenu)
{
// Disable context menu on tray icon
trayIconMenu->clear();
}
}
}
#ifdef ENABLE_WALLET
bool DobbscoinGUI::addWallet(const QString& name, WalletModel *walletModel)
{
if(!walletFrame)
return false;
setWalletActionsEnabled(true);
return walletFrame->addWallet(name, walletModel);
}
bool DobbscoinGUI::setCurrentWallet(const QString& name)
{
if(!walletFrame)
return false;
return walletFrame->setCurrentWallet(name);
}
void DobbscoinGUI::removeAllWallets()
{
if(!walletFrame)
return;
setWalletActionsEnabled(false);
walletFrame->removeAllWallets();
}
#endif // ENABLE_WALLET
void DobbscoinGUI::setWalletActionsEnabled(bool enabled)
{
overviewAction->setEnabled(enabled);
sendCoinsAction->setEnabled(enabled);
receiveCoinsAction->setEnabled(enabled);
historyAction->setEnabled(enabled);
encryptWalletAction->setEnabled(enabled);
backupWalletAction->setEnabled(enabled);
changePassphraseAction->setEnabled(enabled);
signMessageAction->setEnabled(enabled);
verifyMessageAction->setEnabled(enabled);
usedSendingAddressesAction->setEnabled(enabled);
usedReceivingAddressesAction->setEnabled(enabled);
openAction->setEnabled(enabled);
}
void DobbscoinGUI::createTrayIcon(const NetworkStyle *networkStyle)
{
#ifndef Q_OS_MAC
trayIcon = new QSystemTrayIcon(this);
QString toolTip = tr("Dobbscoin Core client") + " " + networkStyle->getTitleAddText();
trayIcon->setToolTip(toolTip);
trayIcon->setIcon(networkStyle->getAppIcon());
trayIcon->show();
#endif
notificator = new Notificator(QApplication::applicationName(), trayIcon, this);
}
void DobbscoinGUI::createTrayIconMenu()
{
#ifndef Q_OS_MAC
// return if trayIcon is unset (only on non-Mac OSes)
if (!trayIcon)
return;
trayIconMenu = new QMenu(this);
trayIcon->setContextMenu(trayIconMenu);
connect(trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)),
this, SLOT(trayIconActivated(QSystemTrayIcon::ActivationReason)));
#else
// Note: On Mac, the dock icon is used to provide the tray's functionality.
MacDockIconHandler *dockIconHandler = MacDockIconHandler::instance();
dockIconHandler->setMainWindow((QMainWindow *)this);
trayIconMenu = dockIconHandler->dockMenu();
#endif
// Configuration of the tray icon (or dock icon) icon menu
trayIconMenu->addAction(toggleHideAction);
trayIconMenu->addSeparator();
trayIconMenu->addAction(sendCoinsAction);
trayIconMenu->addAction(receiveCoinsAction);
trayIconMenu->addSeparator();
trayIconMenu->addAction(signMessageAction);
trayIconMenu->addAction(verifyMessageAction);
trayIconMenu->addSeparator();
trayIconMenu->addAction(optionsAction);
trayIconMenu->addAction(openRPCConsoleAction);
#ifndef Q_OS_MAC // This is built-in on Mac
trayIconMenu->addSeparator();
trayIconMenu->addAction(quitAction);
#endif
}
#ifndef Q_OS_MAC
void DobbscoinGUI::trayIconActivated(QSystemTrayIcon::ActivationReason reason)
{
if(reason == QSystemTrayIcon::Trigger)
{
// Click on system tray icon triggers show/hide of the main window
toggleHidden();
}
}
#endif
void DobbscoinGUI::optionsClicked()
{
if(!clientModel || !clientModel->getOptionsModel())
return;
OptionsDialog dlg(this, enableWallet);
dlg.setModel(clientModel->getOptionsModel());
dlg.exec();
}
void DobbscoinGUI::aboutClicked()
{
if(!clientModel)
return;
HelpMessageDialog dlg(this, true);
dlg.exec();
}
void DobbscoinGUI::showHelpMessageClicked()
{
HelpMessageDialog *help = new HelpMessageDialog(this, false);
help->setAttribute(Qt::WA_DeleteOnClose);
help->show();
}
#ifdef ENABLE_WALLET
void DobbscoinGUI::openClicked()
{
OpenURIDialog dlg(this);
if(dlg.exec())
{
emit receivedURI(dlg.getURI());
}
}
void DobbscoinGUI::gotoOverviewPage()
{
overviewAction->setChecked(true);
if (walletFrame) walletFrame->gotoOverviewPage();
}
void DobbscoinGUI::gotoHistoryPage()
{
historyAction->setChecked(true);
if (walletFrame) walletFrame->gotoHistoryPage();
}
void DobbscoinGUI::gotoReceiveCoinsPage()
{
receiveCoinsAction->setChecked(true);
if (walletFrame) walletFrame->gotoReceiveCoinsPage();
}
void DobbscoinGUI::gotoSendCoinsPage(QString addr)
{
sendCoinsAction->setChecked(true);
if (walletFrame) walletFrame->gotoSendCoinsPage(addr);
}
void DobbscoinGUI::gotoSignMessageTab(QString addr)
{
if (walletFrame) walletFrame->gotoSignMessageTab(addr);
}
void DobbscoinGUI::gotoVerifyMessageTab(QString addr)
{
if (walletFrame) walletFrame->gotoVerifyMessageTab(addr);
}
#endif // ENABLE_WALLET
void DobbscoinGUI::setNumConnections(int count)
{
QString icon;
switch(count)
{
case 0: icon = ":/icons/connect_0"; break;
case 1: case 2: case 3: icon = ":/icons/connect_1"; break;
case 4: case 5: case 6: icon = ":/icons/connect_2"; break;
case 7: case 8: case 9: icon = ":/icons/connect_3"; break;
default: icon = ":/icons/connect_4"; break;
}
labelConnectionsIcon->setPixmap(QIcon(icon).pixmap(STATUSBAR_ICONSIZE,STATUSBAR_ICONSIZE));
labelConnectionsIcon->setToolTip(tr("%n active connection(s) to Dobbscoin network", "", count));
}
void DobbscoinGUI::setNumBlocks(int count)
{
if(!clientModel)
return;
// Prevent orphan statusbar messages (e.g. hover Quit in main menu, wait until chain-sync starts -> garbelled text)
statusBar()->clearMessage();
// Acquire current block source
enum BlockSource blockSource = clientModel->getBlockSource();
switch (blockSource) {
case BLOCK_SOURCE_NETWORK:
progressBarLabel->setText(tr("Synchronizing with network..."));
break;
case BLOCK_SOURCE_DISK:
progressBarLabel->setText(tr("Importing blocks from disk..."));
break;
case BLOCK_SOURCE_REINDEX:
progressBarLabel->setText(tr("Reindexing blocks on disk..."));
break;
case BLOCK_SOURCE_NONE:
// Case: not Importing, not Reindexing and no network connection
progressBarLabel->setText(tr("No block source available..."));
break;
}
QString tooltip;
QDateTime lastBlockDate = clientModel->getLastBlockDate();
QDateTime currentDate = QDateTime::currentDateTime();
int secs = lastBlockDate.secsTo(currentDate);
tooltip = tr("Processed %n blocks of transaction history.", "", count);
// Set icon state: spinning if catching up, tick otherwise
if(secs < 90*60)
{
tooltip = tr("Up to date") + QString(".<br>") + tooltip;
labelBlocksIcon->setPixmap(QIcon(":/icons/synced").pixmap(STATUSBAR_ICONSIZE, STATUSBAR_ICONSIZE));
#ifdef ENABLE_WALLET
if(walletFrame)
walletFrame->showOutOfSyncWarning(false);
#endif // ENABLE_WALLET
progressBarLabel->setVisible(false);
progressBar->setVisible(false);
}
else
{
// Represent time from last generated block in human readable text
QString timeBehindText;
const int HOUR_IN_SECONDS = 60*60;
const int DAY_IN_SECONDS = 24*60*60;
const int WEEK_IN_SECONDS = 7*24*60*60;
const int YEAR_IN_SECONDS = 31556952; // Average length of year in Gregorian calendar
if(secs < 2*DAY_IN_SECONDS)
{
timeBehindText = tr("%n hour(s)","",secs/HOUR_IN_SECONDS);
}
else if(secs < 2*WEEK_IN_SECONDS)
{
timeBehindText = tr("%n day(s)","",secs/DAY_IN_SECONDS);
}
else if(secs < YEAR_IN_SECONDS)
{
timeBehindText = tr("%n week(s)","",secs/WEEK_IN_SECONDS);
}
else
{
int years = secs / YEAR_IN_SECONDS;
int remainder = secs % YEAR_IN_SECONDS;
timeBehindText = tr("%1 and %2").arg(tr("%n year(s)", "", years)).arg(tr("%n week(s)","", remainder/WEEK_IN_SECONDS));
}
progressBarLabel->setVisible(true);
progressBar->setFormat(tr("%1 behind").arg(timeBehindText));
progressBar->setMaximum(1000000000);
progressBar->setValue(clientModel->getVerificationProgress() * 1000000000.0 + 0.5);
progressBar->setVisible(true);
tooltip = tr("Catching up...") + QString("<br>") + tooltip;
if(count != prevBlocks)
{
labelBlocksIcon->setPixmap(QIcon(QString(
":/movies/spinner-%1").arg(spinnerFrame, 3, 10, QChar('0')))
.pixmap(STATUSBAR_ICONSIZE, STATUSBAR_ICONSIZE));
spinnerFrame = (spinnerFrame + 1) % SPINNER_FRAMES;
}
prevBlocks = count;
#ifdef ENABLE_WALLET
if(walletFrame)
walletFrame->showOutOfSyncWarning(true);
#endif // ENABLE_WALLET
tooltip += QString("<br>");
tooltip += tr("Last received block was generated %1 ago.").arg(timeBehindText);
tooltip += QString("<br>");
tooltip += tr("Transactions after this will not yet be visible.");
}
// Don't word-wrap this (fixed-width) tooltip
tooltip = QString("<nobr>") + tooltip + QString("</nobr>");
labelBlocksIcon->setToolTip(tooltip);
progressBarLabel->setToolTip(tooltip);
progressBar->setToolTip(tooltip);
}
void DobbscoinGUI::message(const QString &title, const QString &message, unsigned int style, bool *ret)
{
QString strTitle = tr("Dobbscoin"); // default title
// Default to information icon
int nMBoxIcon = QMessageBox::Information;
int nNotifyIcon = Notificator::Information;
QString msgType;
// Prefer supplied title over style based title
if (!title.isEmpty()) {
msgType = title;
}
else {
switch (style) {
case CClientUIInterface::MSG_ERROR:
msgType = tr("Error");
break;
case CClientUIInterface::MSG_WARNING:
msgType = tr("Warning");
break;
case CClientUIInterface::MSG_INFORMATION:
msgType = tr("Information");
break;
default:
break;
}
}
// Append title to "Dobbscoin - "
if (!msgType.isEmpty())
strTitle += " - " + msgType;
// Check for error/warning icon
if (style & CClientUIInterface::ICON_ERROR) {
nMBoxIcon = QMessageBox::Critical;
nNotifyIcon = Notificator::Critical;
}
else if (style & CClientUIInterface::ICON_WARNING) {
nMBoxIcon = QMessageBox::Warning;
nNotifyIcon = Notificator::Warning;
}
// Display message
if (style & CClientUIInterface::MODAL) {
// Check for buttons, use OK as default, if none was supplied
QMessageBox::StandardButton buttons;
if (!(buttons = (QMessageBox::StandardButton)(style & CClientUIInterface::BTN_MASK)))
buttons = QMessageBox::Ok;
showNormalIfMinimized();
QMessageBox mBox((QMessageBox::Icon)nMBoxIcon, strTitle, message, buttons, this);
int r = mBox.exec();
if (ret != NULL)
*ret = r == QMessageBox::Ok;
}
else
notificator->notify((Notificator::Class)nNotifyIcon, strTitle, message);
}
void DobbscoinGUI::changeEvent(QEvent *e)
{
QMainWindow::changeEvent(e);
#ifndef Q_OS_MAC // Ignored on Mac
if(e->type() == QEvent::WindowStateChange)
{
if(clientModel && clientModel->getOptionsModel() && clientModel->getOptionsModel()->getMinimizeToTray())
{
QWindowStateChangeEvent *wsevt = static_cast<QWindowStateChangeEvent*>(e);
if(!(wsevt->oldState() & Qt::WindowMinimized) && isMinimized())
{
QTimer::singleShot(0, this, SLOT(hide()));
e->ignore();
}
}
}
#endif
}
void DobbscoinGUI::closeEvent(QCloseEvent *event)
{
#ifndef Q_OS_MAC // Ignored on Mac
if(clientModel && clientModel->getOptionsModel())
{
if(!clientModel->getOptionsModel()->getMinimizeToTray() &&
!clientModel->getOptionsModel()->getMinimizeOnClose())
{
QApplication::quit();
}
}
#endif
QMainWindow::closeEvent(event);
}
#ifdef ENABLE_WALLET
void DobbscoinGUI::incomingTransaction(const QString& date, int unit, const CAmount& amount, const QString& type, const QString& address)
{
// On new transaction, make an info balloon
message((amount)<0 ? tr("Sent transaction") : tr("Incoming transaction"),
tr("Date: %1\n"
"Amount: %2\n"
"Type: %3\n"
"Address: %4\n")
.arg(date)
.arg(DobbscoinUnits::formatWithUnit(unit, amount, true))
.arg(type)
.arg(address), CClientUIInterface::MSG_INFORMATION);
}
#endif // ENABLE_WALLET
void DobbscoinGUI::dragEnterEvent(QDragEnterEvent *event)
{
// Accept only URIs
if(event->mimeData()->hasUrls())
event->acceptProposedAction();
}
void DobbscoinGUI::dropEvent(QDropEvent *event)
{
if(event->mimeData()->hasUrls())
{
foreach(const QUrl &uri, event->mimeData()->urls())
{
emit receivedURI(uri.toString());
}
}
event->acceptProposedAction();
}
bool DobbscoinGUI::eventFilter(QObject *object, QEvent *event)
{
// Catch status tip events
if (event->type() == QEvent::StatusTip)
{
// Prevent adding text from setStatusTip(), if we currently use the status bar for displaying other stuff
if (progressBarLabel->isVisible() || progressBar->isVisible())
return true;
}
return QMainWindow::eventFilter(object, event);
}
#ifdef ENABLE_WALLET
bool DobbscoinGUI::handlePaymentRequest(const SendCoinsRecipient& recipient)
{
// URI has to be valid
if (walletFrame && walletFrame->handlePaymentRequest(recipient))
{
showNormalIfMinimized();
gotoSendCoinsPage();
return true;
}
return false;
}
void DobbscoinGUI::setEncryptionStatus(int status)
{
switch(status)
{
case WalletModel::Unencrypted:
labelEncryptionIcon->hide();
encryptWalletAction->setChecked(false);
changePassphraseAction->setEnabled(false);
encryptWalletAction->setEnabled(true);
break;
case WalletModel::Unlocked:
labelEncryptionIcon->show();
labelEncryptionIcon->setPixmap(QIcon(":/icons/lock_open").pixmap(STATUSBAR_ICONSIZE,STATUSBAR_ICONSIZE));
labelEncryptionIcon->setToolTip(tr("Wallet is <b>encrypted</b> and currently <b>unlocked</b>"));
encryptWalletAction->setChecked(true);
changePassphraseAction->setEnabled(true);
encryptWalletAction->setEnabled(false); // TODO: decrypt currently not supported
break;
case WalletModel::Locked:
labelEncryptionIcon->show();
labelEncryptionIcon->setPixmap(QIcon(":/icons/lock_closed").pixmap(STATUSBAR_ICONSIZE,STATUSBAR_ICONSIZE));
labelEncryptionIcon->setToolTip(tr("Wallet is <b>encrypted</b> and currently <b>locked</b>"));
encryptWalletAction->setChecked(true);
changePassphraseAction->setEnabled(true);
encryptWalletAction->setEnabled(false); // TODO: decrypt currently not supported
break;
}
}
#endif // ENABLE_WALLET
void DobbscoinGUI::showNormalIfMinimized(bool fToggleHidden)
{
if(!clientModel)
return;
// activateWindow() (sometimes) helps with keyboard focus on Windows
if (isHidden())
{
show();
activateWindow();
}
else if (isMinimized())
{
showNormal();
activateWindow();
}
else if (GUIUtil::isObscured(this))
{
raise();
activateWindow();
}
else if(fToggleHidden)
hide();
}
void DobbscoinGUI::toggleHidden()
{
showNormalIfMinimized(true);
}
void DobbscoinGUI::detectShutdown()
{
if (ShutdownRequested())
{
if(rpcConsole)
rpcConsole->hide();
qApp->quit();
}
}
void DobbscoinGUI::showProgress(const QString &title, int nProgress)
{
if (nProgress == 0)
{
progressDialog = new QProgressDialog(title, "", 0, 100);
progressDialog->setWindowModality(Qt::ApplicationModal);
progressDialog->setMinimumDuration(0);
progressDialog->setCancelButton(0);
progressDialog->setAutoClose(false);
progressDialog->setValue(0);
}
else if (nProgress == 100)
{
if (progressDialog)
{
progressDialog->close();
progressDialog->deleteLater();
}
}
else if (progressDialog)
progressDialog->setValue(nProgress);
}
static bool ThreadSafeMessageBox(DobbscoinGUI *gui, const std::string& message, const std::string& caption, unsigned int style)
{
bool modal = (style & CClientUIInterface::MODAL);
// The SECURE flag has no effect in the Qt GUI.
// bool secure = (style & CClientUIInterface::SECURE);
style &= ~CClientUIInterface::SECURE;
bool ret = false;
// In case of modal message, use blocking connection to wait for user to click a button
QMetaObject::invokeMethod(gui, "message",
modal ? GUIUtil::blockingGUIThreadConnection() : Qt::QueuedConnection,
Q_ARG(QString, QString::fromStdString(caption)),
Q_ARG(QString, QString::fromStdString(message)),
Q_ARG(unsigned int, style),
Q_ARG(bool*, &ret));
return ret;
}
void DobbscoinGUI::subscribeToCoreSignals()
{
// Connect signals to client
uiInterface.ThreadSafeMessageBox.connect(boost::bind(ThreadSafeMessageBox, this, _1, _2, _3));
}
void DobbscoinGUI::unsubscribeFromCoreSignals()
{
// Disconnect signals from client
uiInterface.ThreadSafeMessageBox.disconnect(boost::bind(ThreadSafeMessageBox, this, _1, _2, _3));
}
UnitDisplayStatusBarControl::UnitDisplayStatusBarControl() :
optionsModel(0),
menu(0)
{
createContextMenu();
setToolTip(tr("Unit to show amounts in. Click to select another unit."));
}
/** So that it responds to button clicks */
void UnitDisplayStatusBarControl::mousePressEvent(QMouseEvent *event)
{
onDisplayUnitsClicked(event->pos());
}
/** Creates context menu, its actions, and wires up all the relevant signals for mouse events. */
void UnitDisplayStatusBarControl::createContextMenu()
{
menu = new QMenu();
foreach(DobbscoinUnits::Unit u, DobbscoinUnits::availableUnits())
{
QAction *menuAction = new QAction(QString(DobbscoinUnits::name(u)), this);
menuAction->setData(QVariant(u));
menu->addAction(menuAction);
}
connect(menu,SIGNAL(triggered(QAction*)),this,SLOT(onMenuSelection(QAction*)));
}
/** Lets the control know about the Options Model (and its signals) */
void UnitDisplayStatusBarControl::setOptionsModel(OptionsModel *optionsModel)
{
if (optionsModel)
{
this->optionsModel = optionsModel;
// be aware of a display unit change reported by the OptionsModel object.
connect(optionsModel,SIGNAL(displayUnitChanged(int)),this,SLOT(updateDisplayUnit(int)));
// initialize the display units label with the current value in the model.
updateDisplayUnit(optionsModel->getDisplayUnit());
}
}
/** When Display Units are changed on OptionsModel it will refresh the display text of the control on the status bar */
void UnitDisplayStatusBarControl::updateDisplayUnit(int newUnits)
{
setPixmap(QIcon(":/icons/unit_" + DobbscoinUnits::id(newUnits)).pixmap(31,STATUSBAR_ICONSIZE));
}
/** Shows context menu with Display Unit options by the mouse coordinates */
void UnitDisplayStatusBarControl::onDisplayUnitsClicked(const QPoint& point)
{
QPoint globalPos = mapToGlobal(point);
menu->exec(globalPos);
}
/** Tells underlying optionsModel to update its current display unit. */
void UnitDisplayStatusBarControl::onMenuSelection(QAction* action)
{
if (action)
{
optionsModel->setDisplayUnit(action->data());
}
}
|
; A198264: Round(n*sqrt(10)).
; 0,3,6,9,13,16,19,22,25,28,32,35,38,41,44,47,51,54,57,60,63,66,70,73,76,79,82,85,89,92,95,98,101,104,108,111,114,117,120,123,126,130,133,136,139,142,145,149,152,155,158,161,164,168,171,174,177,180,183,187,190,193,196,199,202,206,209,212,215,218,221,225,228,231,234,237,240,243,247,250,253,256,259,262,266,269,272,275,278,281,285,288,291,294,297,300,304,307,310,313,316,319,323,326,329,332,335,338,342,345,348,351,354,357,360,364,367,370,373,376,379,383,386,389,392,395,398,402,405,408,411,414,417,421,424,427,430,433,436,440,443,446,449,452,455,459,462,465,468,471,474,478,481,484,487,490,493,496,500,503,506,509,512,515,519,522,525,528,531,534,538,541,544,547,550,553,557,560,563,566,569,572,576,579,582,585,588,591,595,598,601,604,607,610,613,617,620,623,626,629,632,636,639,642,645,648,651,655,658,661,664,667,670,674,677,680,683,686,689,693,696,699,702,705,708,712,715,718,721,724,727,730,734,737,740,743,746,749,753,756,759,762,765,768,772,775,778,781,784,787
mov $2,$0
lpb $0
lpb $2
add $0,$2
add $1,3
sub $2,1
lpe
sub $1,1
lpb $0
add $1,1
trn $0,$1
lpe
lpe
|
; A048691: a(n) = d(n^2), where d(k) = A000005(k) is the number of divisors of k.
; 1,3,3,5,3,9,3,7,5,9,3,15,3,9,9,9,3,15,3,15,9,9,3,21,5,9,7,15,3,27,3,11,9,9,9,25,3,9,9,21,3,27,3,15,15,9,3,27,5,15,9,15,3,21,9,21,9,9,3,45,3,9,15,13,9,27,3,15,9,27,3,35,3,9,15,15,9,27,3,27,9,9,3,45,9,9,9,21,3,45,9,15,9,9,9,33,3,15,15,25
add $0,1
pow $0,2
trn $0,2
mov $1,$0
add $0,1
seq $0,94820 ; Partial sums of A038548.
seq $1,94820 ; Partial sums of A038548.
sub $0,$1
sub $0,1
mul $0,2
add $0,1
|
.global s_prepare_buffers
s_prepare_buffers:
push %r12
push %r13
push %r14
push %r8
push %rax
push %rcx
lea addresses_WT_ht+0xf5cd, %r12
nop
nop
nop
nop
nop
and $46058, %rcx
mov (%r12), %r14w
nop
nop
nop
nop
nop
add $22589, %r8
lea addresses_D_ht+0x1defb, %r13
nop
nop
inc %r12
mov $0x6162636465666768, %rax
movq %rax, %xmm3
and $0xffffffffffffffc0, %r13
vmovntdq %ymm3, (%r13)
nop
sub %r13, %r13
pop %rcx
pop %rax
pop %r8
pop %r14
pop %r13
pop %r12
ret
.global s_faulty_load
s_faulty_load:
push %r10
push %r9
push %rax
push %rcx
push %rdi
// Faulty Load
lea addresses_WC+0x1dfb1, %r10
nop
nop
nop
nop
add %rax, %rax
mov (%r10), %rcx
lea oracles, %r10
and $0xff, %rcx
shlq $12, %rcx
mov (%r10,%rcx,1), %rcx
pop %rdi
pop %rcx
pop %rax
pop %r9
pop %r10
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_WC', 'NT': False, 'AVXalign': False, 'size': 16, 'congruent': 0}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'same': True, 'type': 'addresses_WC', 'NT': False, 'AVXalign': False, 'size': 8, 'congruent': 0}}
<gen_prepare_buffer>
{'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_WT_ht', 'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 1}}
{'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_D_ht', 'NT': True, 'AVXalign': False, 'size': 32, 'congruent': 1}}
{'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
*/
|
.global s_prepare_buffers
s_prepare_buffers:
push %r10
push %r12
push %rcx
push %rdi
push %rsi
lea addresses_normal_ht+0x1c07f, %rsi
lea addresses_D_ht+0x2fbf, %rdi
clflush (%rdi)
nop
nop
cmp $5018, %r10
mov $11, %rcx
rep movsl
nop
nop
cmp $9200, %rsi
lea addresses_WC_ht+0x1081f, %rcx
clflush (%rcx)
nop
nop
nop
nop
xor %r12, %r12
movl $0x61626364, (%rcx)
nop
inc %r10
pop %rsi
pop %rdi
pop %rcx
pop %r12
pop %r10
ret
.global s_faulty_load
s_faulty_load:
push %r10
push %r11
push %r13
push %r15
push %rax
push %rcx
push %rsi
// Store
lea addresses_RW+0x177bf, %r10
nop
nop
nop
nop
sub %r11, %r11
movw $0x5152, (%r10)
nop
nop
and $2523, %r13
// Store
lea addresses_RW+0x11c3f, %r13
nop
nop
nop
sub %rsi, %rsi
mov $0x5152535455565758, %rax
movq %rax, %xmm1
movups %xmm1, (%r13)
add $1501, %rsi
// Faulty Load
lea addresses_RW+0x177bf, %r15
nop
nop
nop
nop
nop
xor %rax, %rax
movb (%r15), %r10b
lea oracles, %r11
and $0xff, %r10
shlq $12, %r10
mov (%r11,%r10,1), %r10
pop %rsi
pop %rcx
pop %rax
pop %r15
pop %r13
pop %r11
pop %r10
ret
/*
<gen_faulty_load>
[REF]
{'src': {'NT': False, 'same': False, 'congruent': 0, 'type': 'addresses_RW', 'AVXalign': False, 'size': 8}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'NT': False, 'same': True, 'congruent': 0, 'type': 'addresses_RW', 'AVXalign': False, 'size': 2}}
{'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 7, 'type': 'addresses_RW', 'AVXalign': False, 'size': 16}}
[Faulty Load]
{'src': {'NT': False, 'same': True, 'congruent': 0, 'type': 'addresses_RW', 'AVXalign': False, 'size': 1}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'src': {'same': False, 'congruent': 4, 'type': 'addresses_normal_ht'}, 'OP': 'REPM', 'dst': {'same': False, 'congruent': 8, 'type': 'addresses_D_ht'}}
{'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 4, 'type': 'addresses_WC_ht', 'AVXalign': False, 'size': 4}}
{'52': 21829}
52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52
*/
|
; A254896: Octagonal numbers (A000567) that are also centered square numbers (A001844).
; Submitted by Jon Maiga
; 1,481,8321,4617761,79897441,44339739841,767175219361,425750177334721,7366416376406081,4088053158428250401,70732329279075969601,39253486001477883014881,679171818371271083701921,376911968498137474280636161,6521407729268615666629875041,3619108682265630026564785402241,62618556337265429259708976440961,34750681190202611016937595151681121,601263371429014922483109925156231681,333676037169216788719004762081656720801,5773330829842844948417392241641160159201,3203957274148138415077272708570472681449281
mul $0,2
mov $3,1
lpb $0
sub $0,1
cmp $2,4
add $2,$3
mov $3,$1
mov $1,$2
dif $2,2
dif $2,6
mul $2,6
add $3,$2
lpe
pow $3,2
mov $0,$3
div $0,120
mul $0,160
add $0,1
|
; A157988: a(n)=16*n!/(253*43!).
; Submitted by Jamie Morken(s4)
; 5760,270720,12994560,636733440,31836672000,1623670272000,84430854144000,4474835269632000,241641104560128000,13290260750807040000,744254602045194240000,42422512316576071680000
mov $3,1
lpb $0
sub $0,1
mov $2,$3
mul $2,$0
mul $3,47
add $3,$2
lpe
mov $0,$3
mul $0,5760
|
;/*
; * FreeRTOS V202011.00
; * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
; *
; * Permission is hereby granted, free of charge, to any person obtaining a copy of
; * this software and associated documentation files (the "Software"), to deal in
; * the Software without restriction, including without limitation the rights to
; * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
; * the Software, and to permit persons to whom the Software is furnished to do so,
; * subject to the following conditions:
; *
; * The above copyright notice and this permission notice shall be included in all
; * copies or substantial portions of the Software.
; *
; * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
; * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
; * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
; * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
; * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
; * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
; *
; * http://www.FreeRTOS.org
; * http://aws.amazon.com/freertos
; *
; * 1 tab == 4 spaces!
; */
.thumb
.ref ulRegTest1LoopCounter
.ref ulRegTest2LoopCounter
.def vRegTest1Implementation
.def vRegTest2Implementation
ulRegTest1LoopCounterConst: .word ulRegTest1LoopCounter
ulRegTest2LoopCounterConst: .word ulRegTest2LoopCounter
ulNVIC_INT_CTRL: .word 0xe000ed04
;/*-----------------------------------------------------------*/
.align 4
vRegTest1Implementation: .asmfunc
;/* Fill the core registers with known values. */
mov r0, #100
mov r1, #101
mov r2, #102
mov r3, #103
mov r4, #104
mov r5, #105
mov r6, #106
mov r7, #107
mov r8, #108
mov r9, #109
mov r10, #110
mov r11, #111
mov r12, #112
reg1_loop:
cmp r0, #100
bne reg1_error_loop
cmp r1, #101
bne reg1_error_loop
cmp r2, #102
bne reg1_error_loop
cmp r3, #103
bne reg1_error_loop
cmp r4, #104
bne reg1_error_loop
cmp r5, #105
bne reg1_error_loop
cmp r6, #106
bne reg1_error_loop
cmp r7, #107
bne reg1_error_loop
cmp r8, #108
bne reg1_error_loop
cmp r9, #109
bne reg1_error_loop
cmp r10, #110
bne reg1_error_loop
cmp r11, #111
bne reg1_error_loop
cmp r12, #112
bne reg1_error_loop
;/* Everything passed, increment the loop counter. */
push { r0-r1 }
ldr r0, ulRegTest1LoopCounterConst
ldr r1, [r0]
adds r1, r1, #1
str r1, [r0]
pop { r0-r1 }
;/* Start again. */
b reg1_loop
reg1_error_loop:
;/* If this line is hit then there was an error in a core register value.
;The loop ensures the loop counter stops incrementing. */
b reg1_error_loop
.endasmfunc
;/*-----------------------------------------------------------*/
.align 4
vRegTest2Implementation: .asmfunc
;/* Set all the core registers to known values. */
mov r0, #-1
mov r1, #1
mov r2, #2
mov r3, #3
mov r4, #4
mov r5, #5
mov r6, #6
mov r7, #7
mov r8, #8
mov r9, #9
mov r10, #10
mov r11, #11
mov r12, #12
reg2_loop:
cmp r0, #-1
bne reg2_error_loop
cmp r1, #1
bne reg2_error_loop
cmp r2, #2
bne reg2_error_loop
cmp r3, #3
bne reg2_error_loop
cmp r4, #4
bne reg2_error_loop
cmp r5, #5
bne reg2_error_loop
cmp r6, #6
bne reg2_error_loop
cmp r7, #7
bne reg2_error_loop
cmp r8, #8
bne reg2_error_loop
cmp r9, #9
bne reg2_error_loop
cmp r10, #10
bne reg2_error_loop
cmp r11, #11
bne reg2_error_loop
cmp r12, #12
bne reg2_error_loop
;/* Increment the loop counter to indicate this test is still functioning
;correctly. */
push { r0-r1 }
ldr r0, ulRegTest2LoopCounterConst
ldr r1, [r0]
adds r1, r1, #1
str r1, [r0]
;/* Yield to increase test coverage. */
movs r0, #0x01
ldr r1, ulNVIC_INT_CTRL
lsl r0, r0, #28 ;/* Shift to PendSV bit */
str r0, [r1]
dsb
pop { r0-r1 }
;/* Start again. */
b reg2_loop
reg2_error_loop:
;/* If this line is hit then there was an error in a core register value.
;This loop ensures the loop counter variable stops incrementing. */
b reg2_error_loop
;/*-----------------------------------------------------------*/
.end
|
; A176177: a(n) = 2*n*3^(n-1) - (3^n-1)/2.
; 0,1,8,41,176,689,2552,9113,31712,108257,364136,1210505,3985808,13020305,42249560,136314617,437641664,1399018433,4455335624,14140847849,44747066480,141214768241,444565011128,1396457152601,4377657815456,13697832519329,42788074776872,133447955987273,415595062931792,1292538773705297,4014877075845656
mul $0,2
mov $2,$0
lpb $2
sub $0,1
mul $0,3
sub $2,2
lpe
mov $1,$0
div $1,3
|
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// ----------------------------------------------------------------
// K600 Spectrometer (iThemba Labs)
// ----------------------------------------------------------------
//
// Github repository: https://www.github.com/KevinCWLi/K600
//
// Main Author: K.C.W. Li
//
// email: likevincw@gmail.com
//
#include "RunAction.hh"
#include "Analysis.hh"
#include "G4Run.hh"
#include "G4RunManager.hh"
#include "G4UnitsTable.hh"
#include "G4SystemOfUnits.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
RunAction::RunAction()
: G4UserRunAction()
{
// set printing event number per each event
G4RunManager::GetRunManager()->SetPrintProgress(1);
// Create analysis manager
// The choice of analysis technology is done via selectin of a namespace
// in Analysis.hh
G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
G4cout << "Using " << analysisManager->GetType() << G4endl;
// Create directories
//analysisManager->SetHistoDirectoryName("histograms");
//analysisManager->SetNtupleDirectoryName("ntuple");
analysisManager->SetVerboseLevel(1);
//analysisManager->SetFirstHistoId(1);
// Book histograms, ntuple
//
// Creating 1D histograms
/*
//// CAKE DETECTORS, Histograms 1-6
analysisManager->CreateH1("CvsE_CAKE1","CAKE 1 - Counts versus Energy", 10000, 0., 10000.);
analysisManager->CreateH1("CvsE_CAKE2","CAKE 2 - Counts versus Energy", 10000, 0., 10000.);
analysisManager->CreateH1("CvsE_CAKE3","CAKE 3 - Counts versus Energy", 10000, 0., 10000.);
analysisManager->CreateH1("CvsE_CAKE4","CAKE 4 - Counts versus Energy", 10000, 0., 10000.);
analysisManager->CreateH1("CvsE_CAKE5","CAKE 5 - Counts versus Energy", 10000, 0., 10000.);
analysisManager->CreateH1("CvsE_CAKE_EA","Entire CAKE Array - Counts versus Energy", 10000, 0., 10000.);
//// PADDLE DETECTORS, Histograms 7-9
analysisManager->CreateH1("CvsE_PADDLE1","PADDLE 1 - Counts versus Energy", 1000, 0., 100.);
analysisManager->CreateH1("CvsE_PADDLE2","PADDLE 2 - Counts versus Energy", 1000, 0., 100.);
analysisManager->CreateH1("CvsE_PADDLE3","PADDLE 3 - Counts versus Energy", 1000, 0., 100.);
//// CLOVER DETECTORS, Histograms 10-19
analysisManager->CreateH1("CvsE_CLOVER1","CLOVER 1 - Counts versus Energy", 3000, 0., 3000.);
analysisManager->CreateH1("CvsE_CLOVER2","CLOVER 2 - Counts versus Energy", 3000, 0., 3000.);
analysisManager->CreateH1("CvsE_CLOVER3","CLOVER 3 - Counts versus Energy", 3000, 0., 3000.);
analysisManager->CreateH1("CvsE_CLOVER4","CLOVER 4 - Counts versus Energy", 3000, 0., 3000.);
analysisManager->CreateH1("CvsE_CLOVER5","CLOVER 5 - Counts versus Energy", 3000, 0., 3000.);
analysisManager->CreateH1("CvsE_CLOVER6","CLOVER 6 - Counts versus Energy", 3000, 0., 3000.);
analysisManager->CreateH1("CvsE_CLOVER7","CLOVER 7 - Counts versus Energy", 3000, 0., 3000.);
analysisManager->CreateH1("CvsE_CLOVER8","CLOVER 8 - Counts versus Energy", 3000, 0., 3000.);
analysisManager->CreateH1("CvsE_CLOVER9","CLOVER 9 - Counts versus Energy", 3000, 0., 3000.);
analysisManager->CreateH1("CvsE_CLOVER_EA","Entire CLOVER Array - Counts versus Energy", 3000, 0., 3000.);
// Creating 2D histograms
//// PADDLE DETECTORS, Histograms 1-6
analysisManager->CreateH2("PvsE_PADDLE1","PADDLE 1 - Position vs. Energy", 1400, -700., 700., 3, -3*(102/2), 3*(102/2));
analysisManager->CreateH2("PvsE_PADDLE2","PADDLE 2 - Position vs. Energy", 1400, -700., 700., 3, -3*(102/2), 3*(102/2));
analysisManager->CreateH2("PvsE_PADDLE3","PADDLE 3 - Position vs. Energy", 1400, -700., 700., 3, -3*(102/2), 3*(102/2));
analysisManager->CreateH2("EvsTOF_PADDLE1","PADDLE 1 - Energy vs. Time of Flight", 300, 0., 500.*0.3, 40, 0., 40.);
analysisManager->CreateH2("EvsTOF_PADDLE2","PADDLE 2 - Energy vs. Time of Flight", 300, 0., 500.*0.3, 40, 0., 40.);
analysisManager->CreateH2("EvsTOF_PADDLE3","PADDLE 3 - Energy vs. Time of Flight", 300, 0., 500.*0.3, 40, 0., 40.);
*/
////////////////////////////////////////////////////
// DataTreeSim
////////////////////////////////////////////////////
// Creating ntuple
analysisManager->CreateNtuple("SimulationTree", "SimulationTree");
//------------------------------------
// Initial Simulated Particle
// analysisManager->CreateNtupleDColumn(0, "iSimulatedParticle_T", iSimulatedParticle_T);
//--------------------------------
// Scattering Reaction
//analysisManager->CreateNtupleIColumn(0, "nReactionProducts", nReactionProducts);
//analysisManager->CreateNtupleIColumn(0, "reaction_Z", reaction_Z);
//analysisManager->CreateNtupleDColumn(0, "reaction_A", reaction_A);
// analysisManager->CreateNtupleDColumn(0, "reaction_P", reaction_P);
// analysisManager->CreateNtupleDColumn(0, "reaction_T", reaction_T);
analysisManager->CreateNtupleDColumn(0, "reaction_Ex", reaction_Ex);
// analysisManager->CreateNtupleDColumn(0, "reaction_theta_LAB", reaction_theta_LAB);
// analysisManager->CreateNtupleDColumn(0, "reaction_phi_LAB", reaction_phi_LAB);
// analysisManager->CreateNtupleDColumn(0, "reaction_theta_reactionCOM", reaction_theta_reactionCOM);
// analysisManager->CreateNtupleDColumn(0, "reaction_phi_reactionCOM", reaction_phi_reactionCOM);
/*
//--------------------------------
// Recoil Nucleus Decay
analysisManager->CreateNtupleIColumn(0, "nDecayProducts", nDecayProducts);
analysisManager->CreateNtupleIColumn(0, "decay_Z", decay_Z);
analysisManager->CreateNtupleDColumn(0, "decay_A", decay_A);
analysisManager->CreateNtupleDColumn(0, "decay_P", decay_P);
analysisManager->CreateNtupleDColumn(0, "decay_T", decay_T);
analysisManager->CreateNtupleDColumn(0, "decay_theta_LAB", decay_theta_LAB);
analysisManager->CreateNtupleDColumn(0, "decay_phi_LAB", decay_phi_LAB);
analysisManager->CreateNtupleDColumn(0, "decay_theta_recoilCOM", decay_theta_recoilCOM);
analysisManager->CreateNtupleDColumn(0, "decay_phi_recoilCOM", decay_phi_recoilCOM);
analysisManager->CreateNtupleDColumn(0, "decay_theta_reactionCOM", decay_theta_reactionCOM);
analysisManager->CreateNtupleDColumn(0, "decay_phi_reactionCOM", decay_phi_reactionCOM);
//--------------------------------
// CAKE Array
analysisManager->CreateNtupleIColumn(0, "CAKE_detNr", CAKE_detNr);
analysisManager->CreateNtupleIColumn(0, "CAKE_ringNr", CAKE_ringNr);
analysisManager->CreateNtupleIColumn(0, "CAKE_sectorNr", CAKE_sectorNr);
analysisManager->CreateNtupleDColumn(0, "CAKE_hitRadius", CAKE_hitRadius);
*/
/*
//--------------------------------
// CLOVER Detectors
analysisManager->CreateNtupleIColumn(0, "CLOVER_EventFold", CLOVER_eventFold);
analysisManager->CreateNtupleIColumn(0, "CLOVER_NCrystalsTriggered", CLOVER_nCrystalsTriggered);
analysisManager->CreateNtupleIColumn(0, "CLOVER_Number", CLOVER_iD);
analysisManager->CreateNtupleDColumn(0, "CLOVER_EnergyPerCrystal", CLOVER_energyPerCrystal);
analysisManager->CreateNtupleDColumn(0, "CLOVER_Energy", CLOVER_energy);
analysisManager->CreateNtupleDColumn(0, "CLOVER_DetectorTheta", CLOVER_detectorTheta);
analysisManager->CreateNtupleDColumn(0, "CLOVER_DetectorPhi", CLOVER_detectorPhi);
analysisManager->CreateNtupleIColumn(0, "CLOVER_CrystalReflectionIndex", CLOVER_CrystalReflectionIndex);
analysisManager->CreateNtupleDColumn(0, "CLOVER_InitialInteractionTheta", CLOVER_initialInteractionTheta);
analysisManager->CreateNtupleDColumn(0, "CLOVER_InitialInteractionPhi", CLOVER_initialInteractionPhi);
analysisManager->CreateNtupleDColumn(0, "CLOVER_InitialParticleTheta", CLOVER_initialInteractionTheta);
analysisManager->CreateNtupleDColumn(0, "CLOVER_InitialParticlePhi", CLOVER_initialInteractionPhi);
analysisManager->CreateNtupleIColumn(0, "CLOVER_BGOCrystalsTriggered", CLOVER_BGOCrystalsTriggered);
*/
/*
//--------------------------------
// TIGRESS Detector
analysisManager->CreateNtupleDColumn(0, "GammaRayEnergies", reaction_Ex);
analysisManager->CreateNtupleDColumn(0, "TIGRESS_Energy", CLOVER_energy);
analysisManager->CreateNtupleDColumn(0, "TIGRESS_DetectorTheta", CLOVER_detectorTheta);
analysisManager->CreateNtupleDColumn(0, "TIGRESS_DetectorPhi", CLOVER_detectorPhi);
// analysisManager->CreateNtupleIColumn(0, "TIGRESS_EventFold", CLOVER_eventFold);
// analysisManager->CreateNtupleIColumn(0, "TIGRESS_NCrystalsTriggered", CLOVER_nCrystalsTriggered);
// analysisManager->CreateNtupleIColumn(0, "TIGRESS_Number", CLOVER_iD);
// analysisManager->CreateNtupleDColumn(0, "TIGRESS_EnergyPerCrystal", CLOVER_energyPerCrystal);
// analysisManager->CreateNtupleDColumn(0, "TIGRESS_Energy", CLOVER_energy);
// analysisManager->CreateNtupleDColumn(0, "TIGRESS_DetectorTheta", CLOVER_detectorTheta);
// analysisManager->CreateNtupleDColumn(0, "TIGRESS_DetectorPhi", CLOVER_detectorPhi);
// analysisManager->CreateNtupleIColumn(0, "TIGRESS_CrystalReflectionIndex", CLOVER_CrystalReflectionIndex);
// analysisManager->CreateNtupleDColumn(0, "TIGRESS_InitialInteractionTheta", CLOVER_initialInteractionTheta);
// analysisManager->CreateNtupleDColumn(0, "TIGRESS_InitialInteractionPhi", CLOVER_initialInteractionPhi);
// analysisManager->CreateNtupleDColumn(0, "TIGRESS_InitialParticleTheta", CLOVER_initialInteractionTheta);
// analysisManager->CreateNtupleDColumn(0, "TIGRESS_InitialParticlePhi", CLOVER_initialInteractionPhi);
// analysisManager->CreateNtupleIColumn(0, "TIGRESS_BGOCrystalsTriggered", CLOVER_BGOCrystalsTriggered);
//--------------------------------
// LaBr3Ce Detectors
// analysisManager->CreateNtupleIColumn(0, "LaBr3Ce_EventFold", laBr3Ce_eventFold);
analysisManager->CreateNtupleIColumn(0, "LaBr3Ce_Number", laBr3Ce_iD);
analysisManager->CreateNtupleDColumn(0, "LaBr3Ce_Energy", laBr3Ce_energy);
analysisManager->CreateNtupleDColumn(0, "LaBr3Ce_DetectorTheta", laBr3Ce_detectorTheta);
analysisManager->CreateNtupleDColumn(0, "LaBr3Ce_DetectorPhi", laBr3Ce_detectorPhi);
*/
// analysisManager->CreateNtupleDColumn(0, "LaBr3Ce_Theta", laBr3Ce_theta);
// analysisManager->CreateNtupleDColumn(0, "LaBr3Ce_Phi", laBr3Ce_phi);
// analysisManager->CreateNtupleDColumn(0, "LaBr3Ce_xPos", laBr3Ce_xPos); // cm (relative to the target/origin)
// analysisManager->CreateNtupleDColumn(0, "LaBr3Ce_yPos", laBr3Ce_yPos); // cm (relative to the target/origin)
// analysisManager->CreateNtupleDColumn(0, "LaBr3Ce_zPos", laBr3Ce_zPos); // cm (relative to the target/origin)
//--------------------------------------------------------------------------------
// Only the neccessary leaves for the CAKE solid-angle simulation (LAB)
analysisManager->CreateNtupleDColumn(0, "decay_theta_LAB", decay_theta_LAB);
analysisManager->CreateNtupleDColumn(0, "decay_phi_LAB", decay_phi_LAB);
analysisManager->CreateNtupleDColumn(0, "decay_theta_recoilCOM", decay_theta_recoilCOM);
analysisManager->CreateNtupleIColumn(0, "CAKE_detNr", CAKE_detNr);
analysisManager->CreateNtupleIColumn(0, "CAKE_ringNr", CAKE_ringNr);
analysisManager->CreateNtupleIColumn(0, "CAKE_sectorNr", CAKE_sectorNr);
// analysisManager->CreateNtupleDColumn(0, "CAKE_hitRadius", CAKE_hitRadius);
//--------------------------------
// CAKE Array
// analysisManager->CreateNtupleDColumn(0, "DetectableEnergy", detectableEnergy);
analysisManager->FinishNtuple(0);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
RunAction::~RunAction()
{
delete G4AnalysisManager::Instance();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void RunAction::BeginOfRunAction(const G4Run* /*run*/)
{
//inform the runManager to save random number seed
//G4RunManager::GetRunManager()->SetRandomNumberStore(true);
// Get analysis manager
G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
// Open an output file
//
G4String fileName = "K600Output";
analysisManager->OpenFile(fileName);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void RunAction::EndOfRunAction(const G4Run* /*run*/)
{
G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
/*
// print histogram statistics
//
if( analysisManager->GetH1(1) ){
G4cout << "\n ----> print histograms statistic ";
if(isMaster) {
G4cout << "for the entire run \n" << G4endl;
}
else {
G4cout << "for the local thread \n" << G4endl;
}
G4cout << " EAbs : mean = "
<< G4BestUnit(analysisManager->GetH1(1)->mean(), "Energy")
<< " rms = "
<< G4BestUnit(analysisManager->GetH1(1)->rms(), "Energy") << G4endl;
G4cout << " EGap : mean = "
<< G4BestUnit(analysisManager->GetH1(2)->mean(), "Energy")
<< " rms = "
<< G4BestUnit(analysisManager->GetH1(2)->rms(), "Energy") << G4endl;
G4cout << " LAbs : mean = "
<< G4BestUnit(analysisManager->GetH1(3)->mean(), "Length")
<< " rms = "
<< G4BestUnit(analysisManager->GetH1(3)->rms(), "Length") << G4endl;
G4cout << " LGap : mean = "
<< G4BestUnit(analysisManager->GetH1(4)->mean(), "Length")
<< " rms = "
<< G4BestUnit(analysisManager->GetH1(4)->rms(), "Length") << G4endl;
}
*/
// save histograms & ntuple
//
analysisManager->Write();
analysisManager->CloseFile();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
dnl PowerPC-32 mpn_lshiftc.
dnl Copyright 1995, 1998, 2000, 2002-2005, 2010 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 603e: ?
C 604e: 3.0
C 75x (G3): 3.0
C 7400,7410 (G4): 3.0
C 7445,7455 (G4+): 2.5
C 7447,7457 (G4+): 2.25
C power4/ppc970: 2.5
C power5: 2.5
C INPUT PARAMETERS
C rp r3
C up r4
C n r5
C cnt r6
ASM_START()
PROLOGUE(mpn_lshiftc)
cmpwi cr0, r5, 30 C more than 30 limbs?
slwi r0, r5, 2
add r4, r4, r0 C make r4 point at end of s1
add r7, r3, r0 C make r7 point at end of res
bgt L(BIG) C branch if more than 12 limbs
mtctr r5 C copy size into CTR
subfic r8, r6, 32
lwzu r11, -4(r4) C load first s1 limb
srw r3, r11, r8 C compute function return value
bdz L(end1)
L(oop): lwzu r10, -4(r4)
slw r9, r11, r6
srw r12, r10, r8
nor r9, r9, r12
stwu r9, -4(r7)
bdz L(end2)
lwzu r11, -4(r4)
slw r9, r10, r6
srw r12, r11, r8
nor r9, r9, r12
stwu r9, -4(r7)
bdnz L(oop)
L(end1):
slw r0, r11, r6
nor r0, r0, r0
stw r0, -4(r7)
blr
L(end2):
slw r0, r10, r6
nor r0, r0, r0
stw r0, -4(r7)
blr
L(BIG):
stwu r1, -48(r1)
stmw r24, 8(r1) C save registers we are supposed to preserve
lwzu r9, -4(r4)
subfic r8, r6, 32
srw r3, r9, r8 C compute function return value
slw r0, r9, r6
addi r5, r5, -1
andi. r10, r5, 3 C count for spill loop
beq L(e)
mtctr r10
lwzu r28, -4(r4)
bdz L(xe0)
L(loop0):
slw r12, r28, r6
srw r24, r28, r8
lwzu r28, -4(r4)
nor r24, r0, r24
stwu r24, -4(r7)
mr r0, r12
bdnz L(loop0) C taken at most once!
L(xe0): slw r12, r28, r6
srw r24, r28, r8
nor r24, r0, r24
stwu r24, -4(r7)
mr r0, r12
L(e): srwi r5, r5, 2 C count for unrolled loop
addi r5, r5, -1
mtctr r5
lwz r28, -4(r4)
lwz r29, -8(r4)
lwz r30, -12(r4)
lwzu r31, -16(r4)
L(loopU):
slw r9, r28, r6
srw r24, r28, r8
lwz r28, -4(r4)
slw r10, r29, r6
srw r25, r29, r8
lwz r29, -8(r4)
slw r11, r30, r6
srw r26, r30, r8
lwz r30, -12(r4)
slw r12, r31, r6
srw r27, r31, r8
lwzu r31, -16(r4)
nor r24, r0, r24
stw r24, -4(r7)
nor r25, r9, r25
stw r25, -8(r7)
nor r26, r10, r26
stw r26, -12(r7)
nor r27, r11, r27
stwu r27, -16(r7)
mr r0, r12
bdnz L(loopU)
slw r9, r28, r6
srw r24, r28, r8
slw r10, r29, r6
srw r25, r29, r8
slw r11, r30, r6
srw r26, r30, r8
slw r12, r31, r6
srw r27, r31, r8
nor r24, r0, r24
stw r24, -4(r7)
nor r25, r9, r25
stw r25, -8(r7)
nor r26, r10, r26
stw r26, -12(r7)
nor r27, r11, r27
stw r27, -16(r7)
nor r12, r12, r12
stw r12, -20(r7)
lmw r24, 8(r1) C restore registers
addi r1, r1, 48
blr
EPILOGUE()
|
PrintItemDescription:
; Print the description for item [wCurSpecies] at de.
push de
ld hl, ItemDescriptions
ld a, [wCurSpecies]
dec a
ld c, a
ld b, 0
add hl, bc
add hl, bc
ld e, [hl]
inc hl
ld d, [hl]
pop hl
jp PlaceString
INCLUDE "data/items/descriptions.asm"
|
; 这段代码是演示loop循环的使用,用到了那些寄存器
; 用debug查看loop执行后,如何影响cx(减一),cs,ip(二者重新指向s处)的
assume cs:pow
pow segment
start:
mov ax, 2 ; 要计算的数据
mov cx, 0bh ; 计数器, 11 是计算2^12, 汇编中数据不能以字母开头,前边要加0
s: add ax, ax ; 要循环的代码块
loop s ; 循环完一次后,检查有没有下次循环,对应 [ (cx) = (cx)-1; if (cx) > 0 goto s else pass;]
mov ax, 4c00h
int 21h
pow ends
end start |
; void *tshc_py2saddr(uchar y)
SECTION code_clib
SECTION code_arch
PUBLIC tshc_py2saddr
EXTERN zx_py2saddr
defc tshc_py2saddr = zx_py2saddr
; SDCC bridge for Classic
IF __CLASSIC
PUBLIC _tshc_py2saddr
defc _tshc_py2saddr = tshc_py2saddr
ENDIF
|
; void __CALLEE__ HeapSbrk_callee(void *heap, void *addr, unsigned int size)
; 12.2006 aralbrec
SECTION code_clib
PUBLIC HeapSbrk_callee
PUBLIC _HeapSbrk_callee
PUBLIC asm_HeapSbrk
EXTERN asm_HeapFree
.HeapSbrk_callee
._HeapSbrk_callee
pop af
pop bc
pop hl
pop de
push af
.asm_HeapSbrk
; Add a block of memory to the specified heap. The
; block must be at least 4 bytes in size. Adding a
; block that overlaps with one already in the heap
; will wreck the heap.
;
; enter : de = heap pointer
; hl = address of available block
; bc = size of block in bytes >= 4
; exit : block not added if too small
; uses : af, bc, de, hl
.MAHeapSbrk
ld a,b
or a
jr nz, sizeok
ld a,c
sub 4
ret c
.sizeok
dec bc
dec bc
ld (hl),c
inc hl
ld (hl),b
inc hl
jp asm_HeapFree
|
.global s_prepare_buffers
s_prepare_buffers:
push %r10
push %r12
push %r9
push %rbx
push %rcx
push %rdi
push %rsi
lea addresses_WC_ht+0x19bf7, %rsi
lea addresses_UC_ht+0xb221, %rdi
nop
cmp $34007, %rbx
mov $42, %rcx
rep movsw
nop
nop
nop
add %r12, %r12
lea addresses_normal_ht+0x5ee7, %r10
and $55384, %r9
movb (%r10), %bl
nop
nop
nop
add %r9, %r9
lea addresses_A_ht+0x1d117, %rcx
nop
nop
nop
nop
and $11820, %rsi
mov $0x6162636465666768, %rbx
movq %rbx, %xmm3
movups %xmm3, (%rcx)
cmp $49941, %rcx
pop %rsi
pop %rdi
pop %rcx
pop %rbx
pop %r9
pop %r12
pop %r10
ret
.global s_faulty_load
s_faulty_load:
push %r15
push %r8
push %rax
push %rbp
push %rsi
// Faulty Load
lea addresses_RW+0x1aee7, %rax
xor %r15, %r15
mov (%rax), %r8
lea oracles, %rbp
and $0xff, %r8
shlq $12, %r8
mov (%rbp,%r8,1), %r8
pop %rsi
pop %rbp
pop %rax
pop %r8
pop %r15
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'type': 'addresses_RW', 'AVXalign': False, 'congruent': 0, 'size': 32, 'same': False, 'NT': True}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'type': 'addresses_RW', 'AVXalign': False, 'congruent': 0, 'size': 8, 'same': True, 'NT': False}}
<gen_prepare_buffer>
{'OP': 'REPM', 'src': {'type': 'addresses_WC_ht', 'congruent': 4, 'same': False}, 'dst': {'type': 'addresses_UC_ht', 'congruent': 1, 'same': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_normal_ht', 'AVXalign': False, 'congruent': 10, 'size': 1, 'same': False, 'NT': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_A_ht', 'AVXalign': False, 'congruent': 4, 'size': 16, 'same': False, 'NT': False}}
{'32': 21829}
32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32
*/
|
; A204164: Symmetric matrix based on f(i,j)=floor[(i+j)/2], by antidiagonals.
; 1,1,1,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7
mov $1,1
lpb $0,1
add $1,4
sub $0,$1
lpe
div $1,4
add $1,1
|
.data
player: .byte 'B'
distance: .byte 3
size: .word 26
.align 2
state:
.byte 0 # bot_mancala (byte #0)
.byte 1 # top_mancala (byte #1)
.byte 6 # bot_pockets (byte #2)
.byte 6 # top_pockets (byte #3)
.byte 2 # moves_executed (byte #4)
.byte 'B' # player_turn (byte #5)
# game_board (bytes #6-end)
.asciiz
"xxxxxxxxxxxxxxxxxx02xxxxxxxx"
.text
.globl main
main:
la $a0, state
lb $a1, player
lb $a2, distance
lw $a3, size
jal set_pocket
# You must write your own code here to check the correctness of the function implementation.
move $a0, $v0
li $v0, 1
syscall
li $v0, 10
syscall
.include "hw3.asm"
|
; size_t wv_priority_queue_capacity_fastcall(wv_priority_queue_t *q)
SECTION code_clib
SECTION code_adt_wv_priority_queue
PUBLIC _wv_priority_queue_capacity_fastcall
EXTERN asm_wv_priority_queue_capacity
defc _wv_priority_queue_capacity_fastcall = asm_wv_priority_queue_capacity
|
_FRRsanity: file format elf32-i386
Disassembly of section .text:
00000000 <main>:
#include "types.h"
#include "stat.h"
#include "user.h"
int main(void){
0: 8d 4c 24 04 lea 0x4(%esp),%ecx
4: 83 e4 f0 and $0xfffffff0,%esp
7: ff 71 fc pushl -0x4(%ecx)
a: 55 push %ebp
b: 89 e5 mov %esp,%ebp
d: 57 push %edi
e: 56 push %esi
f: 53 push %ebx
10: 51 push %ecx
11: be 0a 00 00 00 mov $0xa,%esi
16: 83 ec 18 sub $0x18,%esp
19: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
int i, j;
int pid, tt, wt, rt;
for(i = 0; i < 10; i++){
if(fork() == 0){ //SE filho imprime
20: e8 f5 02 00 00 call 31a <fork>
25: 85 c0 test %eax,%eax
27: 89 c3 mov %eax,%ebx
29: 74 75 je a0 <main+0xa0>
for(i = 0; i < 10; i++){
2b: 83 ee 01 sub $0x1,%esi
2e: 75 f0 jne 20 <main+0x20>
30: bb 0a 00 00 00 mov $0xa,%ebx
35: 8d 76 00 lea 0x0(%esi),%esi
return 0; //Finaliza execução do processo filho
}
}
for(i = 0; i < 10; i++)
wait(); //pai esperando execução dos filhos
38: e8 ed 02 00 00 call 32a <wait>
for(i = 0; i < 10; i++)
3d: 83 eb 01 sub $0x1,%ebx
40: 75 f6 jne 38 <main+0x38>
//imprime os tempos de execução e espera dos filhos
for(i = 1; i < 11; i++){
42: bb 01 00 00 00 mov $0x1,%ebx
47: 89 f6 mov %esi,%esi
49: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
pid = getpid();
50: e8 4d 03 00 00 call 3a2 <getpid>
55: 89 45 e4 mov %eax,-0x1c(%ebp)
rt = runtime();
58: e8 6d 03 00 00 call 3ca <runtime>
5d: 89 c7 mov %eax,%edi
wt = waittime();
5f: e8 6e 03 00 00 call 3d2 <waittime>
64: 89 c6 mov %eax,%esi
tt = turntime();
66: e8 6f 03 00 00 call 3da <turntime>
printf(1, "Child %d: running time = %d, waiting time = %d, turnaround time = %d\n",
6b: 83 ec 08 sub $0x8,%esp
6e: 50 push %eax
6f: 56 push %esi
70: 8b 75 e4 mov -0x1c(%ebp),%esi
73: 57 push %edi
74: 01 de add %ebx,%esi
for(i = 1; i < 11; i++){
76: 83 c3 01 add $0x1,%ebx
printf(1, "Child %d: running time = %d, waiting time = %d, turnaround time = %d\n",
79: 56 push %esi
7a: 68 0c 08 00 00 push $0x80c
7f: 6a 01 push $0x1
81: e8 0a 04 00 00 call 490 <printf>
for(i = 1; i < 11; i++){
86: 83 c4 20 add $0x20,%esp
89: 83 fb 0b cmp $0xb,%ebx
8c: 75 c2 jne 50 <main+0x50>
pid+i, rt, wt, tt);
}
return 0;
8e: 8d 65 f0 lea -0x10(%ebp),%esp
91: 31 c0 xor %eax,%eax
93: 59 pop %ecx
94: 5b pop %ebx
95: 5e pop %esi
96: 5f pop %edi
97: 5d pop %ebp
98: 8d 61 fc lea -0x4(%ecx),%esp
9b: c3 ret
9c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
printf(1, "child %d prints for the %d time\n", getpid(), j+1);
a0: 83 c3 01 add $0x1,%ebx
a3: e8 fa 02 00 00 call 3a2 <getpid>
a8: 53 push %ebx
a9: 50 push %eax
aa: 68 e8 07 00 00 push $0x7e8
af: 6a 01 push $0x1
b1: e8 da 03 00 00 call 490 <printf>
for(j = 0; j < 1000; j++){
b6: 83 c4 10 add $0x10,%esp
b9: 81 fb e8 03 00 00 cmp $0x3e8,%ebx
bf: 75 df jne a0 <main+0xa0>
c1: eb cb jmp 8e <main+0x8e>
c3: 66 90 xchg %ax,%ax
c5: 66 90 xchg %ax,%ax
c7: 66 90 xchg %ax,%ax
c9: 66 90 xchg %ax,%ax
cb: 66 90 xchg %ax,%ax
cd: 66 90 xchg %ax,%ax
cf: 90 nop
000000d0 <strcpy>:
#include "user.h"
#include "x86.h"
char*
strcpy(char *s, const char *t)
{
d0: 55 push %ebp
d1: 89 e5 mov %esp,%ebp
d3: 53 push %ebx
d4: 8b 45 08 mov 0x8(%ebp),%eax
d7: 8b 4d 0c mov 0xc(%ebp),%ecx
char *os;
os = s;
while((*s++ = *t++) != 0)
da: 89 c2 mov %eax,%edx
dc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
e0: 83 c1 01 add $0x1,%ecx
e3: 0f b6 59 ff movzbl -0x1(%ecx),%ebx
e7: 83 c2 01 add $0x1,%edx
ea: 84 db test %bl,%bl
ec: 88 5a ff mov %bl,-0x1(%edx)
ef: 75 ef jne e0 <strcpy+0x10>
;
return os;
}
f1: 5b pop %ebx
f2: 5d pop %ebp
f3: c3 ret
f4: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
fa: 8d bf 00 00 00 00 lea 0x0(%edi),%edi
00000100 <strcmp>:
int
strcmp(const char *p, const char *q)
{
100: 55 push %ebp
101: 89 e5 mov %esp,%ebp
103: 53 push %ebx
104: 8b 55 08 mov 0x8(%ebp),%edx
107: 8b 4d 0c mov 0xc(%ebp),%ecx
while(*p && *p == *q)
10a: 0f b6 02 movzbl (%edx),%eax
10d: 0f b6 19 movzbl (%ecx),%ebx
110: 84 c0 test %al,%al
112: 75 1c jne 130 <strcmp+0x30>
114: eb 2a jmp 140 <strcmp+0x40>
116: 8d 76 00 lea 0x0(%esi),%esi
119: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
p++, q++;
120: 83 c2 01 add $0x1,%edx
while(*p && *p == *q)
123: 0f b6 02 movzbl (%edx),%eax
p++, q++;
126: 83 c1 01 add $0x1,%ecx
129: 0f b6 19 movzbl (%ecx),%ebx
while(*p && *p == *q)
12c: 84 c0 test %al,%al
12e: 74 10 je 140 <strcmp+0x40>
130: 38 d8 cmp %bl,%al
132: 74 ec je 120 <strcmp+0x20>
return (uchar)*p - (uchar)*q;
134: 29 d8 sub %ebx,%eax
}
136: 5b pop %ebx
137: 5d pop %ebp
138: c3 ret
139: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
140: 31 c0 xor %eax,%eax
return (uchar)*p - (uchar)*q;
142: 29 d8 sub %ebx,%eax
}
144: 5b pop %ebx
145: 5d pop %ebp
146: c3 ret
147: 89 f6 mov %esi,%esi
149: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
00000150 <strlen>:
uint
strlen(const char *s)
{
150: 55 push %ebp
151: 89 e5 mov %esp,%ebp
153: 8b 4d 08 mov 0x8(%ebp),%ecx
int n;
for(n = 0; s[n]; n++)
156: 80 39 00 cmpb $0x0,(%ecx)
159: 74 15 je 170 <strlen+0x20>
15b: 31 d2 xor %edx,%edx
15d: 8d 76 00 lea 0x0(%esi),%esi
160: 83 c2 01 add $0x1,%edx
163: 80 3c 11 00 cmpb $0x0,(%ecx,%edx,1)
167: 89 d0 mov %edx,%eax
169: 75 f5 jne 160 <strlen+0x10>
;
return n;
}
16b: 5d pop %ebp
16c: c3 ret
16d: 8d 76 00 lea 0x0(%esi),%esi
for(n = 0; s[n]; n++)
170: 31 c0 xor %eax,%eax
}
172: 5d pop %ebp
173: c3 ret
174: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
17a: 8d bf 00 00 00 00 lea 0x0(%edi),%edi
00000180 <memset>:
void*
memset(void *dst, int c, uint n)
{
180: 55 push %ebp
181: 89 e5 mov %esp,%ebp
183: 57 push %edi
184: 8b 55 08 mov 0x8(%ebp),%edx
}
static inline void
stosb(void *addr, int data, int cnt)
{
asm volatile("cld; rep stosb" :
187: 8b 4d 10 mov 0x10(%ebp),%ecx
18a: 8b 45 0c mov 0xc(%ebp),%eax
18d: 89 d7 mov %edx,%edi
18f: fc cld
190: f3 aa rep stos %al,%es:(%edi)
stosb(dst, c, n);
return dst;
}
192: 89 d0 mov %edx,%eax
194: 5f pop %edi
195: 5d pop %ebp
196: c3 ret
197: 89 f6 mov %esi,%esi
199: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
000001a0 <strchr>:
char*
strchr(const char *s, char c)
{
1a0: 55 push %ebp
1a1: 89 e5 mov %esp,%ebp
1a3: 53 push %ebx
1a4: 8b 45 08 mov 0x8(%ebp),%eax
1a7: 8b 5d 0c mov 0xc(%ebp),%ebx
for(; *s; s++)
1aa: 0f b6 10 movzbl (%eax),%edx
1ad: 84 d2 test %dl,%dl
1af: 74 1d je 1ce <strchr+0x2e>
if(*s == c)
1b1: 38 d3 cmp %dl,%bl
1b3: 89 d9 mov %ebx,%ecx
1b5: 75 0d jne 1c4 <strchr+0x24>
1b7: eb 17 jmp 1d0 <strchr+0x30>
1b9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
1c0: 38 ca cmp %cl,%dl
1c2: 74 0c je 1d0 <strchr+0x30>
for(; *s; s++)
1c4: 83 c0 01 add $0x1,%eax
1c7: 0f b6 10 movzbl (%eax),%edx
1ca: 84 d2 test %dl,%dl
1cc: 75 f2 jne 1c0 <strchr+0x20>
return (char*)s;
return 0;
1ce: 31 c0 xor %eax,%eax
}
1d0: 5b pop %ebx
1d1: 5d pop %ebp
1d2: c3 ret
1d3: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
1d9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
000001e0 <gets>:
char*
gets(char *buf, int max)
{
1e0: 55 push %ebp
1e1: 89 e5 mov %esp,%ebp
1e3: 57 push %edi
1e4: 56 push %esi
1e5: 53 push %ebx
int i, cc;
char c;
for(i=0; i+1 < max; ){
1e6: 31 f6 xor %esi,%esi
1e8: 89 f3 mov %esi,%ebx
{
1ea: 83 ec 1c sub $0x1c,%esp
1ed: 8b 7d 08 mov 0x8(%ebp),%edi
for(i=0; i+1 < max; ){
1f0: eb 2f jmp 221 <gets+0x41>
1f2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
cc = read(0, &c, 1);
1f8: 8d 45 e7 lea -0x19(%ebp),%eax
1fb: 83 ec 04 sub $0x4,%esp
1fe: 6a 01 push $0x1
200: 50 push %eax
201: 6a 00 push $0x0
203: e8 32 01 00 00 call 33a <read>
if(cc < 1)
208: 83 c4 10 add $0x10,%esp
20b: 85 c0 test %eax,%eax
20d: 7e 1c jle 22b <gets+0x4b>
break;
buf[i++] = c;
20f: 0f b6 45 e7 movzbl -0x19(%ebp),%eax
213: 83 c7 01 add $0x1,%edi
216: 88 47 ff mov %al,-0x1(%edi)
if(c == '\n' || c == '\r')
219: 3c 0a cmp $0xa,%al
21b: 74 23 je 240 <gets+0x60>
21d: 3c 0d cmp $0xd,%al
21f: 74 1f je 240 <gets+0x60>
for(i=0; i+1 < max; ){
221: 83 c3 01 add $0x1,%ebx
224: 3b 5d 0c cmp 0xc(%ebp),%ebx
227: 89 fe mov %edi,%esi
229: 7c cd jl 1f8 <gets+0x18>
22b: 89 f3 mov %esi,%ebx
break;
}
buf[i] = '\0';
return buf;
}
22d: 8b 45 08 mov 0x8(%ebp),%eax
buf[i] = '\0';
230: c6 03 00 movb $0x0,(%ebx)
}
233: 8d 65 f4 lea -0xc(%ebp),%esp
236: 5b pop %ebx
237: 5e pop %esi
238: 5f pop %edi
239: 5d pop %ebp
23a: c3 ret
23b: 90 nop
23c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
240: 8b 75 08 mov 0x8(%ebp),%esi
243: 8b 45 08 mov 0x8(%ebp),%eax
246: 01 de add %ebx,%esi
248: 89 f3 mov %esi,%ebx
buf[i] = '\0';
24a: c6 03 00 movb $0x0,(%ebx)
}
24d: 8d 65 f4 lea -0xc(%ebp),%esp
250: 5b pop %ebx
251: 5e pop %esi
252: 5f pop %edi
253: 5d pop %ebp
254: c3 ret
255: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
259: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
00000260 <stat>:
int
stat(const char *n, struct stat *st)
{
260: 55 push %ebp
261: 89 e5 mov %esp,%ebp
263: 56 push %esi
264: 53 push %ebx
int fd;
int r;
fd = open(n, O_RDONLY);
265: 83 ec 08 sub $0x8,%esp
268: 6a 00 push $0x0
26a: ff 75 08 pushl 0x8(%ebp)
26d: e8 f0 00 00 00 call 362 <open>
if(fd < 0)
272: 83 c4 10 add $0x10,%esp
275: 85 c0 test %eax,%eax
277: 78 27 js 2a0 <stat+0x40>
return -1;
r = fstat(fd, st);
279: 83 ec 08 sub $0x8,%esp
27c: ff 75 0c pushl 0xc(%ebp)
27f: 89 c3 mov %eax,%ebx
281: 50 push %eax
282: e8 f3 00 00 00 call 37a <fstat>
close(fd);
287: 89 1c 24 mov %ebx,(%esp)
r = fstat(fd, st);
28a: 89 c6 mov %eax,%esi
close(fd);
28c: e8 b9 00 00 00 call 34a <close>
return r;
291: 83 c4 10 add $0x10,%esp
}
294: 8d 65 f8 lea -0x8(%ebp),%esp
297: 89 f0 mov %esi,%eax
299: 5b pop %ebx
29a: 5e pop %esi
29b: 5d pop %ebp
29c: c3 ret
29d: 8d 76 00 lea 0x0(%esi),%esi
return -1;
2a0: be ff ff ff ff mov $0xffffffff,%esi
2a5: eb ed jmp 294 <stat+0x34>
2a7: 89 f6 mov %esi,%esi
2a9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
000002b0 <atoi>:
int
atoi(const char *s)
{
2b0: 55 push %ebp
2b1: 89 e5 mov %esp,%ebp
2b3: 53 push %ebx
2b4: 8b 4d 08 mov 0x8(%ebp),%ecx
int n;
n = 0;
while('0' <= *s && *s <= '9')
2b7: 0f be 11 movsbl (%ecx),%edx
2ba: 8d 42 d0 lea -0x30(%edx),%eax
2bd: 3c 09 cmp $0x9,%al
n = 0;
2bf: b8 00 00 00 00 mov $0x0,%eax
while('0' <= *s && *s <= '9')
2c4: 77 1f ja 2e5 <atoi+0x35>
2c6: 8d 76 00 lea 0x0(%esi),%esi
2c9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
n = n*10 + *s++ - '0';
2d0: 8d 04 80 lea (%eax,%eax,4),%eax
2d3: 83 c1 01 add $0x1,%ecx
2d6: 8d 44 42 d0 lea -0x30(%edx,%eax,2),%eax
while('0' <= *s && *s <= '9')
2da: 0f be 11 movsbl (%ecx),%edx
2dd: 8d 5a d0 lea -0x30(%edx),%ebx
2e0: 80 fb 09 cmp $0x9,%bl
2e3: 76 eb jbe 2d0 <atoi+0x20>
return n;
}
2e5: 5b pop %ebx
2e6: 5d pop %ebp
2e7: c3 ret
2e8: 90 nop
2e9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
000002f0 <memmove>:
void*
memmove(void *vdst, const void *vsrc, int n)
{
2f0: 55 push %ebp
2f1: 89 e5 mov %esp,%ebp
2f3: 56 push %esi
2f4: 53 push %ebx
2f5: 8b 5d 10 mov 0x10(%ebp),%ebx
2f8: 8b 45 08 mov 0x8(%ebp),%eax
2fb: 8b 75 0c mov 0xc(%ebp),%esi
char *dst;
const char *src;
dst = vdst;
src = vsrc;
while(n-- > 0)
2fe: 85 db test %ebx,%ebx
300: 7e 14 jle 316 <memmove+0x26>
302: 31 d2 xor %edx,%edx
304: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
*dst++ = *src++;
308: 0f b6 0c 16 movzbl (%esi,%edx,1),%ecx
30c: 88 0c 10 mov %cl,(%eax,%edx,1)
30f: 83 c2 01 add $0x1,%edx
while(n-- > 0)
312: 39 d3 cmp %edx,%ebx
314: 75 f2 jne 308 <memmove+0x18>
return vdst;
}
316: 5b pop %ebx
317: 5e pop %esi
318: 5d pop %ebp
319: c3 ret
0000031a <fork>:
name: \
movl $SYS_ ## name, %eax; \
int $T_SYSCALL; \
ret
SYSCALL(fork)
31a: b8 01 00 00 00 mov $0x1,%eax
31f: cd 40 int $0x40
321: c3 ret
00000322 <exit>:
SYSCALL(exit)
322: b8 02 00 00 00 mov $0x2,%eax
327: cd 40 int $0x40
329: c3 ret
0000032a <wait>:
SYSCALL(wait)
32a: b8 03 00 00 00 mov $0x3,%eax
32f: cd 40 int $0x40
331: c3 ret
00000332 <pipe>:
SYSCALL(pipe)
332: b8 04 00 00 00 mov $0x4,%eax
337: cd 40 int $0x40
339: c3 ret
0000033a <read>:
SYSCALL(read)
33a: b8 05 00 00 00 mov $0x5,%eax
33f: cd 40 int $0x40
341: c3 ret
00000342 <write>:
SYSCALL(write)
342: b8 10 00 00 00 mov $0x10,%eax
347: cd 40 int $0x40
349: c3 ret
0000034a <close>:
SYSCALL(close)
34a: b8 15 00 00 00 mov $0x15,%eax
34f: cd 40 int $0x40
351: c3 ret
00000352 <kill>:
SYSCALL(kill)
352: b8 06 00 00 00 mov $0x6,%eax
357: cd 40 int $0x40
359: c3 ret
0000035a <exec>:
SYSCALL(exec)
35a: b8 07 00 00 00 mov $0x7,%eax
35f: cd 40 int $0x40
361: c3 ret
00000362 <open>:
SYSCALL(open)
362: b8 0f 00 00 00 mov $0xf,%eax
367: cd 40 int $0x40
369: c3 ret
0000036a <mknod>:
SYSCALL(mknod)
36a: b8 11 00 00 00 mov $0x11,%eax
36f: cd 40 int $0x40
371: c3 ret
00000372 <unlink>:
SYSCALL(unlink)
372: b8 12 00 00 00 mov $0x12,%eax
377: cd 40 int $0x40
379: c3 ret
0000037a <fstat>:
SYSCALL(fstat)
37a: b8 08 00 00 00 mov $0x8,%eax
37f: cd 40 int $0x40
381: c3 ret
00000382 <link>:
SYSCALL(link)
382: b8 13 00 00 00 mov $0x13,%eax
387: cd 40 int $0x40
389: c3 ret
0000038a <mkdir>:
SYSCALL(mkdir)
38a: b8 14 00 00 00 mov $0x14,%eax
38f: cd 40 int $0x40
391: c3 ret
00000392 <chdir>:
SYSCALL(chdir)
392: b8 09 00 00 00 mov $0x9,%eax
397: cd 40 int $0x40
399: c3 ret
0000039a <dup>:
SYSCALL(dup)
39a: b8 0a 00 00 00 mov $0xa,%eax
39f: cd 40 int $0x40
3a1: c3 ret
000003a2 <getpid>:
SYSCALL(getpid)
3a2: b8 0b 00 00 00 mov $0xb,%eax
3a7: cd 40 int $0x40
3a9: c3 ret
000003aa <sbrk>:
SYSCALL(sbrk)
3aa: b8 0c 00 00 00 mov $0xc,%eax
3af: cd 40 int $0x40
3b1: c3 ret
000003b2 <sleep>:
SYSCALL(sleep)
3b2: b8 0d 00 00 00 mov $0xd,%eax
3b7: cd 40 int $0x40
3b9: c3 ret
000003ba <uptime>:
SYSCALL(uptime)
3ba: b8 0e 00 00 00 mov $0xe,%eax
3bf: cd 40 int $0x40
3c1: c3 ret
000003c2 <getyear>:
SYSCALL(getyear)
3c2: b8 16 00 00 00 mov $0x16,%eax
3c7: cd 40 int $0x40
3c9: c3 ret
000003ca <runtime>:
SYSCALL(runtime)
3ca: b8 17 00 00 00 mov $0x17,%eax
3cf: cd 40 int $0x40
3d1: c3 ret
000003d2 <waittime>:
SYSCALL(waittime)
3d2: b8 18 00 00 00 mov $0x18,%eax
3d7: cd 40 int $0x40
3d9: c3 ret
000003da <turntime>:
SYSCALL(turntime)
3da: b8 19 00 00 00 mov $0x19,%eax
3df: cd 40 int $0x40
3e1: c3 ret
3e2: 66 90 xchg %ax,%ax
3e4: 66 90 xchg %ax,%ax
3e6: 66 90 xchg %ax,%ax
3e8: 66 90 xchg %ax,%ax
3ea: 66 90 xchg %ax,%ax
3ec: 66 90 xchg %ax,%ax
3ee: 66 90 xchg %ax,%ax
000003f0 <printint>:
write(fd, &c, 1);
}
static void
printint(int fd, int xx, int base, int sgn)
{
3f0: 55 push %ebp
3f1: 89 e5 mov %esp,%ebp
3f3: 57 push %edi
3f4: 56 push %esi
3f5: 53 push %ebx
3f6: 83 ec 3c sub $0x3c,%esp
char buf[16];
int i, neg;
uint x;
neg = 0;
if(sgn && xx < 0){
3f9: 85 d2 test %edx,%edx
{
3fb: 89 45 c0 mov %eax,-0x40(%ebp)
neg = 1;
x = -xx;
3fe: 89 d0 mov %edx,%eax
if(sgn && xx < 0){
400: 79 76 jns 478 <printint+0x88>
402: f6 45 08 01 testb $0x1,0x8(%ebp)
406: 74 70 je 478 <printint+0x88>
x = -xx;
408: f7 d8 neg %eax
neg = 1;
40a: c7 45 c4 01 00 00 00 movl $0x1,-0x3c(%ebp)
} else {
x = xx;
}
i = 0;
411: 31 f6 xor %esi,%esi
413: 8d 5d d7 lea -0x29(%ebp),%ebx
416: eb 0a jmp 422 <printint+0x32>
418: 90 nop
419: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
do{
buf[i++] = digits[x % base];
420: 89 fe mov %edi,%esi
422: 31 d2 xor %edx,%edx
424: 8d 7e 01 lea 0x1(%esi),%edi
427: f7 f1 div %ecx
429: 0f b6 92 5c 08 00 00 movzbl 0x85c(%edx),%edx
}while((x /= base) != 0);
430: 85 c0 test %eax,%eax
buf[i++] = digits[x % base];
432: 88 14 3b mov %dl,(%ebx,%edi,1)
}while((x /= base) != 0);
435: 75 e9 jne 420 <printint+0x30>
if(neg)
437: 8b 45 c4 mov -0x3c(%ebp),%eax
43a: 85 c0 test %eax,%eax
43c: 74 08 je 446 <printint+0x56>
buf[i++] = '-';
43e: c6 44 3d d8 2d movb $0x2d,-0x28(%ebp,%edi,1)
443: 8d 7e 02 lea 0x2(%esi),%edi
446: 8d 74 3d d7 lea -0x29(%ebp,%edi,1),%esi
44a: 8b 7d c0 mov -0x40(%ebp),%edi
44d: 8d 76 00 lea 0x0(%esi),%esi
450: 0f b6 06 movzbl (%esi),%eax
write(fd, &c, 1);
453: 83 ec 04 sub $0x4,%esp
456: 83 ee 01 sub $0x1,%esi
459: 6a 01 push $0x1
45b: 53 push %ebx
45c: 57 push %edi
45d: 88 45 d7 mov %al,-0x29(%ebp)
460: e8 dd fe ff ff call 342 <write>
while(--i >= 0)
465: 83 c4 10 add $0x10,%esp
468: 39 de cmp %ebx,%esi
46a: 75 e4 jne 450 <printint+0x60>
putc(fd, buf[i]);
}
46c: 8d 65 f4 lea -0xc(%ebp),%esp
46f: 5b pop %ebx
470: 5e pop %esi
471: 5f pop %edi
472: 5d pop %ebp
473: c3 ret
474: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
neg = 0;
478: c7 45 c4 00 00 00 00 movl $0x0,-0x3c(%ebp)
47f: eb 90 jmp 411 <printint+0x21>
481: eb 0d jmp 490 <printf>
483: 90 nop
484: 90 nop
485: 90 nop
486: 90 nop
487: 90 nop
488: 90 nop
489: 90 nop
48a: 90 nop
48b: 90 nop
48c: 90 nop
48d: 90 nop
48e: 90 nop
48f: 90 nop
00000490 <printf>:
// Print to the given fd. Only understands %d, %x, %p, %s.
void
printf(int fd, const char *fmt, ...)
{
490: 55 push %ebp
491: 89 e5 mov %esp,%ebp
493: 57 push %edi
494: 56 push %esi
495: 53 push %ebx
496: 83 ec 2c sub $0x2c,%esp
int c, i, state;
uint *ap;
state = 0;
ap = (uint*)(void*)&fmt + 1;
for(i = 0; fmt[i]; i++){
499: 8b 75 0c mov 0xc(%ebp),%esi
49c: 0f b6 1e movzbl (%esi),%ebx
49f: 84 db test %bl,%bl
4a1: 0f 84 b3 00 00 00 je 55a <printf+0xca>
ap = (uint*)(void*)&fmt + 1;
4a7: 8d 45 10 lea 0x10(%ebp),%eax
4aa: 83 c6 01 add $0x1,%esi
state = 0;
4ad: 31 ff xor %edi,%edi
ap = (uint*)(void*)&fmt + 1;
4af: 89 45 d4 mov %eax,-0x2c(%ebp)
4b2: eb 2f jmp 4e3 <printf+0x53>
4b4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
c = fmt[i] & 0xff;
if(state == 0){
if(c == '%'){
4b8: 83 f8 25 cmp $0x25,%eax
4bb: 0f 84 a7 00 00 00 je 568 <printf+0xd8>
write(fd, &c, 1);
4c1: 8d 45 e2 lea -0x1e(%ebp),%eax
4c4: 83 ec 04 sub $0x4,%esp
4c7: 88 5d e2 mov %bl,-0x1e(%ebp)
4ca: 6a 01 push $0x1
4cc: 50 push %eax
4cd: ff 75 08 pushl 0x8(%ebp)
4d0: e8 6d fe ff ff call 342 <write>
4d5: 83 c4 10 add $0x10,%esp
4d8: 83 c6 01 add $0x1,%esi
for(i = 0; fmt[i]; i++){
4db: 0f b6 5e ff movzbl -0x1(%esi),%ebx
4df: 84 db test %bl,%bl
4e1: 74 77 je 55a <printf+0xca>
if(state == 0){
4e3: 85 ff test %edi,%edi
c = fmt[i] & 0xff;
4e5: 0f be cb movsbl %bl,%ecx
4e8: 0f b6 c3 movzbl %bl,%eax
if(state == 0){
4eb: 74 cb je 4b8 <printf+0x28>
state = '%';
} else {
putc(fd, c);
}
} else if(state == '%'){
4ed: 83 ff 25 cmp $0x25,%edi
4f0: 75 e6 jne 4d8 <printf+0x48>
if(c == 'd'){
4f2: 83 f8 64 cmp $0x64,%eax
4f5: 0f 84 05 01 00 00 je 600 <printf+0x170>
printint(fd, *ap, 10, 1);
ap++;
} else if(c == 'x' || c == 'p'){
4fb: 81 e1 f7 00 00 00 and $0xf7,%ecx
501: 83 f9 70 cmp $0x70,%ecx
504: 74 72 je 578 <printf+0xe8>
printint(fd, *ap, 16, 0);
ap++;
} else if(c == 's'){
506: 83 f8 73 cmp $0x73,%eax
509: 0f 84 99 00 00 00 je 5a8 <printf+0x118>
s = "(null)";
while(*s != 0){
putc(fd, *s);
s++;
}
} else if(c == 'c'){
50f: 83 f8 63 cmp $0x63,%eax
512: 0f 84 08 01 00 00 je 620 <printf+0x190>
putc(fd, *ap);
ap++;
} else if(c == '%'){
518: 83 f8 25 cmp $0x25,%eax
51b: 0f 84 ef 00 00 00 je 610 <printf+0x180>
write(fd, &c, 1);
521: 8d 45 e7 lea -0x19(%ebp),%eax
524: 83 ec 04 sub $0x4,%esp
527: c6 45 e7 25 movb $0x25,-0x19(%ebp)
52b: 6a 01 push $0x1
52d: 50 push %eax
52e: ff 75 08 pushl 0x8(%ebp)
531: e8 0c fe ff ff call 342 <write>
536: 83 c4 0c add $0xc,%esp
539: 8d 45 e6 lea -0x1a(%ebp),%eax
53c: 88 5d e6 mov %bl,-0x1a(%ebp)
53f: 6a 01 push $0x1
541: 50 push %eax
542: ff 75 08 pushl 0x8(%ebp)
545: 83 c6 01 add $0x1,%esi
} else {
// Unknown % sequence. Print it to draw attention.
putc(fd, '%');
putc(fd, c);
}
state = 0;
548: 31 ff xor %edi,%edi
write(fd, &c, 1);
54a: e8 f3 fd ff ff call 342 <write>
for(i = 0; fmt[i]; i++){
54f: 0f b6 5e ff movzbl -0x1(%esi),%ebx
write(fd, &c, 1);
553: 83 c4 10 add $0x10,%esp
for(i = 0; fmt[i]; i++){
556: 84 db test %bl,%bl
558: 75 89 jne 4e3 <printf+0x53>
}
}
}
55a: 8d 65 f4 lea -0xc(%ebp),%esp
55d: 5b pop %ebx
55e: 5e pop %esi
55f: 5f pop %edi
560: 5d pop %ebp
561: c3 ret
562: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
state = '%';
568: bf 25 00 00 00 mov $0x25,%edi
56d: e9 66 ff ff ff jmp 4d8 <printf+0x48>
572: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
printint(fd, *ap, 16, 0);
578: 83 ec 0c sub $0xc,%esp
57b: b9 10 00 00 00 mov $0x10,%ecx
580: 6a 00 push $0x0
582: 8b 7d d4 mov -0x2c(%ebp),%edi
585: 8b 45 08 mov 0x8(%ebp),%eax
588: 8b 17 mov (%edi),%edx
58a: e8 61 fe ff ff call 3f0 <printint>
ap++;
58f: 89 f8 mov %edi,%eax
591: 83 c4 10 add $0x10,%esp
state = 0;
594: 31 ff xor %edi,%edi
ap++;
596: 83 c0 04 add $0x4,%eax
599: 89 45 d4 mov %eax,-0x2c(%ebp)
59c: e9 37 ff ff ff jmp 4d8 <printf+0x48>
5a1: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
s = (char*)*ap;
5a8: 8b 45 d4 mov -0x2c(%ebp),%eax
5ab: 8b 08 mov (%eax),%ecx
ap++;
5ad: 83 c0 04 add $0x4,%eax
5b0: 89 45 d4 mov %eax,-0x2c(%ebp)
if(s == 0)
5b3: 85 c9 test %ecx,%ecx
5b5: 0f 84 8e 00 00 00 je 649 <printf+0x1b9>
while(*s != 0){
5bb: 0f b6 01 movzbl (%ecx),%eax
state = 0;
5be: 31 ff xor %edi,%edi
s = (char*)*ap;
5c0: 89 cb mov %ecx,%ebx
while(*s != 0){
5c2: 84 c0 test %al,%al
5c4: 0f 84 0e ff ff ff je 4d8 <printf+0x48>
5ca: 89 75 d0 mov %esi,-0x30(%ebp)
5cd: 89 de mov %ebx,%esi
5cf: 8b 5d 08 mov 0x8(%ebp),%ebx
5d2: 8d 7d e3 lea -0x1d(%ebp),%edi
5d5: 8d 76 00 lea 0x0(%esi),%esi
write(fd, &c, 1);
5d8: 83 ec 04 sub $0x4,%esp
s++;
5db: 83 c6 01 add $0x1,%esi
5de: 88 45 e3 mov %al,-0x1d(%ebp)
write(fd, &c, 1);
5e1: 6a 01 push $0x1
5e3: 57 push %edi
5e4: 53 push %ebx
5e5: e8 58 fd ff ff call 342 <write>
while(*s != 0){
5ea: 0f b6 06 movzbl (%esi),%eax
5ed: 83 c4 10 add $0x10,%esp
5f0: 84 c0 test %al,%al
5f2: 75 e4 jne 5d8 <printf+0x148>
5f4: 8b 75 d0 mov -0x30(%ebp),%esi
state = 0;
5f7: 31 ff xor %edi,%edi
5f9: e9 da fe ff ff jmp 4d8 <printf+0x48>
5fe: 66 90 xchg %ax,%ax
printint(fd, *ap, 10, 1);
600: 83 ec 0c sub $0xc,%esp
603: b9 0a 00 00 00 mov $0xa,%ecx
608: 6a 01 push $0x1
60a: e9 73 ff ff ff jmp 582 <printf+0xf2>
60f: 90 nop
write(fd, &c, 1);
610: 83 ec 04 sub $0x4,%esp
613: 88 5d e5 mov %bl,-0x1b(%ebp)
616: 8d 45 e5 lea -0x1b(%ebp),%eax
619: 6a 01 push $0x1
61b: e9 21 ff ff ff jmp 541 <printf+0xb1>
putc(fd, *ap);
620: 8b 7d d4 mov -0x2c(%ebp),%edi
write(fd, &c, 1);
623: 83 ec 04 sub $0x4,%esp
putc(fd, *ap);
626: 8b 07 mov (%edi),%eax
write(fd, &c, 1);
628: 6a 01 push $0x1
ap++;
62a: 83 c7 04 add $0x4,%edi
putc(fd, *ap);
62d: 88 45 e4 mov %al,-0x1c(%ebp)
write(fd, &c, 1);
630: 8d 45 e4 lea -0x1c(%ebp),%eax
633: 50 push %eax
634: ff 75 08 pushl 0x8(%ebp)
637: e8 06 fd ff ff call 342 <write>
ap++;
63c: 89 7d d4 mov %edi,-0x2c(%ebp)
63f: 83 c4 10 add $0x10,%esp
state = 0;
642: 31 ff xor %edi,%edi
644: e9 8f fe ff ff jmp 4d8 <printf+0x48>
s = "(null)";
649: bb 54 08 00 00 mov $0x854,%ebx
while(*s != 0){
64e: b8 28 00 00 00 mov $0x28,%eax
653: e9 72 ff ff ff jmp 5ca <printf+0x13a>
658: 66 90 xchg %ax,%ax
65a: 66 90 xchg %ax,%ax
65c: 66 90 xchg %ax,%ax
65e: 66 90 xchg %ax,%ax
00000660 <free>:
static Header base;
static Header *freep;
void
free(void *ap)
{
660: 55 push %ebp
Header *bp, *p;
bp = (Header*)ap - 1;
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
661: a1 24 0b 00 00 mov 0xb24,%eax
{
666: 89 e5 mov %esp,%ebp
668: 57 push %edi
669: 56 push %esi
66a: 53 push %ebx
66b: 8b 5d 08 mov 0x8(%ebp),%ebx
bp = (Header*)ap - 1;
66e: 8d 4b f8 lea -0x8(%ebx),%ecx
671: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
678: 39 c8 cmp %ecx,%eax
67a: 8b 10 mov (%eax),%edx
67c: 73 32 jae 6b0 <free+0x50>
67e: 39 d1 cmp %edx,%ecx
680: 72 04 jb 686 <free+0x26>
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
682: 39 d0 cmp %edx,%eax
684: 72 32 jb 6b8 <free+0x58>
break;
if(bp + bp->s.size == p->s.ptr){
686: 8b 73 fc mov -0x4(%ebx),%esi
689: 8d 3c f1 lea (%ecx,%esi,8),%edi
68c: 39 fa cmp %edi,%edx
68e: 74 30 je 6c0 <free+0x60>
bp->s.size += p->s.ptr->s.size;
bp->s.ptr = p->s.ptr->s.ptr;
} else
bp->s.ptr = p->s.ptr;
690: 89 53 f8 mov %edx,-0x8(%ebx)
if(p + p->s.size == bp){
693: 8b 50 04 mov 0x4(%eax),%edx
696: 8d 34 d0 lea (%eax,%edx,8),%esi
699: 39 f1 cmp %esi,%ecx
69b: 74 3a je 6d7 <free+0x77>
p->s.size += bp->s.size;
p->s.ptr = bp->s.ptr;
} else
p->s.ptr = bp;
69d: 89 08 mov %ecx,(%eax)
freep = p;
69f: a3 24 0b 00 00 mov %eax,0xb24
}
6a4: 5b pop %ebx
6a5: 5e pop %esi
6a6: 5f pop %edi
6a7: 5d pop %ebp
6a8: c3 ret
6a9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
6b0: 39 d0 cmp %edx,%eax
6b2: 72 04 jb 6b8 <free+0x58>
6b4: 39 d1 cmp %edx,%ecx
6b6: 72 ce jb 686 <free+0x26>
{
6b8: 89 d0 mov %edx,%eax
6ba: eb bc jmp 678 <free+0x18>
6bc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
bp->s.size += p->s.ptr->s.size;
6c0: 03 72 04 add 0x4(%edx),%esi
6c3: 89 73 fc mov %esi,-0x4(%ebx)
bp->s.ptr = p->s.ptr->s.ptr;
6c6: 8b 10 mov (%eax),%edx
6c8: 8b 12 mov (%edx),%edx
6ca: 89 53 f8 mov %edx,-0x8(%ebx)
if(p + p->s.size == bp){
6cd: 8b 50 04 mov 0x4(%eax),%edx
6d0: 8d 34 d0 lea (%eax,%edx,8),%esi
6d3: 39 f1 cmp %esi,%ecx
6d5: 75 c6 jne 69d <free+0x3d>
p->s.size += bp->s.size;
6d7: 03 53 fc add -0x4(%ebx),%edx
freep = p;
6da: a3 24 0b 00 00 mov %eax,0xb24
p->s.size += bp->s.size;
6df: 89 50 04 mov %edx,0x4(%eax)
p->s.ptr = bp->s.ptr;
6e2: 8b 53 f8 mov -0x8(%ebx),%edx
6e5: 89 10 mov %edx,(%eax)
}
6e7: 5b pop %ebx
6e8: 5e pop %esi
6e9: 5f pop %edi
6ea: 5d pop %ebp
6eb: c3 ret
6ec: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
000006f0 <malloc>:
return freep;
}
void*
malloc(uint nbytes)
{
6f0: 55 push %ebp
6f1: 89 e5 mov %esp,%ebp
6f3: 57 push %edi
6f4: 56 push %esi
6f5: 53 push %ebx
6f6: 83 ec 0c sub $0xc,%esp
Header *p, *prevp;
uint nunits;
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
6f9: 8b 45 08 mov 0x8(%ebp),%eax
if((prevp = freep) == 0){
6fc: 8b 15 24 0b 00 00 mov 0xb24,%edx
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
702: 8d 78 07 lea 0x7(%eax),%edi
705: c1 ef 03 shr $0x3,%edi
708: 83 c7 01 add $0x1,%edi
if((prevp = freep) == 0){
70b: 85 d2 test %edx,%edx
70d: 0f 84 9d 00 00 00 je 7b0 <malloc+0xc0>
713: 8b 02 mov (%edx),%eax
715: 8b 48 04 mov 0x4(%eax),%ecx
base.s.ptr = freep = prevp = &base;
base.s.size = 0;
}
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
if(p->s.size >= nunits){
718: 39 cf cmp %ecx,%edi
71a: 76 6c jbe 788 <malloc+0x98>
71c: 81 ff 00 10 00 00 cmp $0x1000,%edi
722: bb 00 10 00 00 mov $0x1000,%ebx
727: 0f 43 df cmovae %edi,%ebx
p = sbrk(nu * sizeof(Header));
72a: 8d 34 dd 00 00 00 00 lea 0x0(,%ebx,8),%esi
731: eb 0e jmp 741 <malloc+0x51>
733: 90 nop
734: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
738: 8b 02 mov (%edx),%eax
if(p->s.size >= nunits){
73a: 8b 48 04 mov 0x4(%eax),%ecx
73d: 39 f9 cmp %edi,%ecx
73f: 73 47 jae 788 <malloc+0x98>
p->s.size = nunits;
}
freep = prevp;
return (void*)(p + 1);
}
if(p == freep)
741: 39 05 24 0b 00 00 cmp %eax,0xb24
747: 89 c2 mov %eax,%edx
749: 75 ed jne 738 <malloc+0x48>
p = sbrk(nu * sizeof(Header));
74b: 83 ec 0c sub $0xc,%esp
74e: 56 push %esi
74f: e8 56 fc ff ff call 3aa <sbrk>
if(p == (char*)-1)
754: 83 c4 10 add $0x10,%esp
757: 83 f8 ff cmp $0xffffffff,%eax
75a: 74 1c je 778 <malloc+0x88>
hp->s.size = nu;
75c: 89 58 04 mov %ebx,0x4(%eax)
free((void*)(hp + 1));
75f: 83 ec 0c sub $0xc,%esp
762: 83 c0 08 add $0x8,%eax
765: 50 push %eax
766: e8 f5 fe ff ff call 660 <free>
return freep;
76b: 8b 15 24 0b 00 00 mov 0xb24,%edx
if((p = morecore(nunits)) == 0)
771: 83 c4 10 add $0x10,%esp
774: 85 d2 test %edx,%edx
776: 75 c0 jne 738 <malloc+0x48>
return 0;
}
}
778: 8d 65 f4 lea -0xc(%ebp),%esp
return 0;
77b: 31 c0 xor %eax,%eax
}
77d: 5b pop %ebx
77e: 5e pop %esi
77f: 5f pop %edi
780: 5d pop %ebp
781: c3 ret
782: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
if(p->s.size == nunits)
788: 39 cf cmp %ecx,%edi
78a: 74 54 je 7e0 <malloc+0xf0>
p->s.size -= nunits;
78c: 29 f9 sub %edi,%ecx
78e: 89 48 04 mov %ecx,0x4(%eax)
p += p->s.size;
791: 8d 04 c8 lea (%eax,%ecx,8),%eax
p->s.size = nunits;
794: 89 78 04 mov %edi,0x4(%eax)
freep = prevp;
797: 89 15 24 0b 00 00 mov %edx,0xb24
}
79d: 8d 65 f4 lea -0xc(%ebp),%esp
return (void*)(p + 1);
7a0: 83 c0 08 add $0x8,%eax
}
7a3: 5b pop %ebx
7a4: 5e pop %esi
7a5: 5f pop %edi
7a6: 5d pop %ebp
7a7: c3 ret
7a8: 90 nop
7a9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
base.s.ptr = freep = prevp = &base;
7b0: c7 05 24 0b 00 00 28 movl $0xb28,0xb24
7b7: 0b 00 00
7ba: c7 05 28 0b 00 00 28 movl $0xb28,0xb28
7c1: 0b 00 00
base.s.size = 0;
7c4: b8 28 0b 00 00 mov $0xb28,%eax
7c9: c7 05 2c 0b 00 00 00 movl $0x0,0xb2c
7d0: 00 00 00
7d3: e9 44 ff ff ff jmp 71c <malloc+0x2c>
7d8: 90 nop
7d9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
prevp->s.ptr = p->s.ptr;
7e0: 8b 08 mov (%eax),%ecx
7e2: 89 0a mov %ecx,(%edx)
7e4: eb b1 jmp 797 <malloc+0xa7>
|
#ifndef HPP_UTILITY_XML
#define HPP_UTILITY_XML
#include <string>
#include "../vendor/rapidxml.hpp"
// Allocate an XML node
rapidxml::xml_node<>* xml_node(rapidxml::xml_document<>& doc,
const std::string& name, const std::string& value = "",
rapidxml::node_type type = rapidxml::node_element);
// Allocate an XML attribute
rapidxml::xml_attribute<>* xml_attribute(rapidxml::xml_document<>& doc,
const std::string& name, const std::string& value);
#endif
|
//
// Copyright (c) 2011, ARM Limited. All rights reserved.
//
// SPDX-License-Identifier: BSD-2-Clause-Patent
//
//
#include <AutoGen.h>
IMPORT PeiCommonExceptionEntry
EXPORT PeiVectorTable
PRESERVE8
AREA PrePeiCoreException, CODE, READONLY, CODEALIGN, ALIGN=5
//============================================================
//Default Exception Handlers
//============================================================
PeiVectorTable
b _DefaultResetHandler
b _DefaultUndefined
b _DefaultSWI
b _DefaultPrefetchAbort
b _DefaultDataAbort
b _DefaultReserved
b _DefaultIrq
b _DefaultFiq
//
// Default Exception handlers: There is no plan to return from any of these exceptions.
// No context saving at all.
//
_DefaultResetHandler
mov r1, lr
cps #0x13 ; Switch to SVC for common stack
mov r0, #0
blx PeiCommonExceptionEntry
_DefaultUndefined
sub r1, LR, #4
cps #0x13 ; Switch to SVC for common stack
mov r0, #1
blx PeiCommonExceptionEntry
_DefaultSWI
sub r1, LR, #4
cps #0x13 ; Switch to SVC for common stack
mov r0, #2
blx PeiCommonExceptionEntry
_DefaultPrefetchAbort
sub r1, LR, #4
cps #0x13 ; Switch to SVC for common stack
mov r0, #3
blx PeiCommonExceptionEntry
_DefaultDataAbort
sub r1, LR, #8
cps #0x13 ; Switch to SVC for common stack
mov r0, #4
blx PeiCommonExceptionEntry
_DefaultReserved
mov r1, lr
cps #0x13 ; Switch to SVC for common stack
mov r0, #5
blx PeiCommonExceptionEntry
_DefaultIrq
sub r1, LR, #4
cps #0x13 ; Switch to SVC for common stack
mov r0, #6
blx PeiCommonExceptionEntry
_DefaultFiq
sub r1, LR, #4
cps #0x13 ; Switch to SVC for common stack
mov r0, #7
blx PeiCommonExceptionEntry
END
|
#include "BaseLibInternals.h"
;------------------------------------------------------------------------------
;
; Copyright (c) 2006 - 2013, 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:
;
; Thunk.asm
;
; Abstract:
;
; Real mode thunk
;
;------------------------------------------------------------------------------
.686p
.model flat,C
EXTERNDEF C m16Start:BYTE
EXTERNDEF C m16Size:WORD
EXTERNDEF C mThunk16Attr:WORD
EXTERNDEF C m16Gdt:WORD
EXTERNDEF C m16GdtrBase:WORD
EXTERNDEF C mTransition:WORD
;
; Here is the layout of the real mode stack. _ToUserCode() is responsible for
; loading all these registers from real mode stack.
;
IA32_REGS STRUC 4t
_EDI DD ?
_ESI DD ?
_EBP DD ?
_ESP DD ?
_EBX DD ?
_EDX DD ?
_ECX DD ?
_EAX DD ?
_DS DW ?
_ES DW ?
_FS DW ?
_GS DW ?
_EFLAGS DD ?
_EIP DD ?
_CS DW ?
_SS DW ?
IA32_REGS ENDS
.const
;
; These are global constant to convey information to C code.
;
m16Size DW InternalAsmThunk16 - m16Start
mThunk16Attr DW _ThunkAttr - m16Start
m16Gdt DW _NullSegDesc - m16Start
m16GdtrBase DW _16GdtrBase - m16Start
mTransition DW _EntryPoint - m16Start
.code
m16Start LABEL BYTE
SavedGdt LABEL FWORD
DW ?
DD ?
;------------------------------------------------------------------------------
; _BackFromUserCode() takes control in real mode after 'retf' has been executed
; by user code. It will be shadowed to somewhere in memory below 1MB.
;------------------------------------------------------------------------------
_BackFromUserCode PROC
;
; The order of saved registers on the stack matches the order they appears
; in IA32_REGS structure. This facilitates wrapper function to extract them
; into that structure.
;
push ss
push cs
DB 66h
call @Base ; push eip
@Base:
pushf ; pushfd actually
cli ; disable interrupts
push gs
push fs
push es
push ds
pushaw ; pushad actually
DB 66h, 0bah ; mov edx, imm32
_ThunkAttr DD ?
test dl, THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15
jz @1
mov eax, 15cd2401h ; mov ax, 2401h & int 15h
cli ; disable interrupts
jnc @2
@1:
test dl, THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL
jz @2
in al, 92h
or al, 2
out 92h, al ; deactivate A20M#
@2:
xor ax, ax ; xor eax, eax
mov eax, ss ; mov ax, ss
DB 67h
lea bp, [esp + sizeof (IA32_REGS)]
;
; esi's in the following 2 instructions are indeed bp in 16-bit code. Fact
; is "esi" in 32-bit addressing mode has the same encoding of "bp" in 16-
; bit addressing mode.
;
mov word ptr (IA32_REGS ptr [esi - sizeof (IA32_REGS)])._ESP, bp
mov ebx, (IA32_REGS ptr [esi - sizeof (IA32_REGS)])._EIP
shl ax, 4 ; shl eax, 4
add bp, ax ; add ebp, eax
DB 66h, 0b8h ; mov eax, imm32
SavedCr4 DD ?
mov cr4, eax
DB 66h
lgdt fword ptr cs:[edi + (SavedGdt - @Base)]
DB 66h, 0b8h ; mov eax, imm32
SavedCr0 DD ?
mov cr0, eax
DB 0b8h ; mov ax, imm16
SavedSs DW ?
mov ss, eax
DB 66h, 0bch ; mov esp, imm32
SavedEsp DD ?
DB 66h
retf ; return to protected mode
_BackFromUserCode ENDP
_EntryPoint DD _ToUserCode - m16Start
DW 8h
_16Idtr FWORD (1 SHL 10) - 1
_16Gdtr LABEL FWORD
DW GdtEnd - _NullSegDesc - 1
_16GdtrBase DD _NullSegDesc
;------------------------------------------------------------------------------
; _ToUserCode() takes control in real mode before passing control to user code.
; It will be shadowed to somewhere in memory below 1MB.
;------------------------------------------------------------------------------
_ToUserCode PROC
mov edx, ss
mov ss, ecx ; set new segment selectors
mov ds, ecx
mov es, ecx
mov fs, ecx
mov gs, ecx
mov cr0, eax ; real mode starts at next instruction
; which (per SDM) *must* be a far JMP.
DB 0eah
_RealAddr DW 0,0 ; filled in by InternalAsmThunk16
mov cr4, ebp
mov ss, esi ; set up 16-bit stack segment
xchg sp, bx ; set up 16-bit stack pointer
; mov bp, [esp + sizeof(IA32_REGS)
DB 67h
mov ebp, [esp + sizeof(IA32_REGS)] ; BackFromUserCode address from stack
; mov cs:[bp + (SavedSs - _BackFromUserCode)], dx
mov cs:[esi + (SavedSs - _BackFromUserCode)], edx
; mov cs:[bp + (SavedEsp - _BackFromUserCode)], ebx
DB 2eh, 66h, 89h, 9eh
DW SavedEsp - _BackFromUserCode
; lidt cs:[bp + (_16Idtr - _BackFromUserCode)]
DB 2eh, 66h, 0fh, 01h, 9eh
DW _16Idtr - _BackFromUserCode
popaw ; popad actually
pop ds
pop es
pop fs
pop gs
popf ; popfd
DB 66h ; Use 32-bit addressing for "retf" below
retf ; transfer control to user code
_ToUserCode ENDP
_NullSegDesc DQ 0
_16CsDesc LABEL QWORD
DW -1
DW 0
DB 0
DB 9bh
DB 8fh ; 16-bit segment, 4GB limit
DB 0
_16DsDesc LABEL QWORD
DW -1
DW 0
DB 0
DB 93h
DB 8fh ; 16-bit segment, 4GB limit
DB 0
GdtEnd LABEL QWORD
;------------------------------------------------------------------------------
; IA32_REGISTER_SET *
; EFIAPI
; InternalAsmThunk16 (
; IN IA32_REGISTER_SET *RegisterSet,
; IN OUT VOID *Transition
; );
;------------------------------------------------------------------------------
InternalAsmThunk16 PROC USES ebp ebx esi edi ds es fs gs
mov esi, [esp + 36] ; esi <- RegSet, the 1st parameter
movzx edx, (IA32_REGS ptr [esi])._SS
mov edi, (IA32_REGS ptr [esi])._ESP
add edi, - (sizeof (IA32_REGS) + 4) ; reserve stack space
mov ebx, edi ; ebx <- stack offset
imul eax, edx, 16 ; eax <- edx * 16
push sizeof (IA32_REGS) / 4
add edi, eax ; edi <- linear address of 16-bit stack
pop ecx
rep movsd ; copy RegSet
mov eax, [esp + 40] ; eax <- address of transition code
mov esi, edx ; esi <- 16-bit stack segment
lea edx, [eax + (SavedCr0 - m16Start)]
mov ecx, eax
and ecx, 0fh
shl eax, 12
lea ecx, [ecx + (_BackFromUserCode - m16Start)]
mov ax, cx
stosd ; [edi] <- return address of user code
add eax, _RealAddr + 4 - _BackFromUserCode
mov dword ptr [edx + (_RealAddr - SavedCr0)], eax
sgdt fword ptr [edx + (SavedGdt - SavedCr0)]
sidt fword ptr [esp + 36] ; save IDT stack in argument space
mov eax, cr0
mov [edx], eax ; save CR0 in SavedCr0
and eax, 7ffffffeh ; clear PE, PG bits
mov ebp, cr4
mov [edx + (SavedCr4 - SavedCr0)], ebp
and ebp, NOT 30h ; clear PAE, PSE bits
push 10h
pop ecx ; ecx <- selector for data segments
lgdt fword ptr [edx + (_16Gdtr - SavedCr0)]
pushfd ; Save df/if indeed
call fword ptr [edx + (_EntryPoint - SavedCr0)]
popfd
lidt fword ptr [esp + 36] ; restore protected mode IDTR
lea eax, [ebp - sizeof (IA32_REGS)] ; eax <- the address of IA32_REGS
ret
InternalAsmThunk16 ENDP
END
|
; A250429: Number of (n+1)X(5+1) 0..1 arrays with nondecreasing sum of every two consecutive values in every row and column
; Submitted by Jon Maiga
; 256,1600,10000,40000,160000,490000,1500625,3841600,9834496,22127616,49787136,101606400,207360000,392040000,741200625,1317690000,2342560000,3958926400,6690585616,10837642816,17555190016,27429984400,42859350625,64923040000,98344960000,145008640000,213813760000,307891814400,443364212736,625212815616,881647759521,1220273715600,1688960160000,2298862440000,3129007210000,4195123240000,5624486560000,7438383475600,9837262146481,12848668926016,16781934923776,21670887040000,27984100000000,35760400000000
add $0,8
seq $0,331574 ; a(n) is the number of subsets of {1..n} that contain 3 even and 3 odd numbers.
pow $0,2
|
/*
Output "Hello world!" to standard output.
For Aarch64 (ARM64) architecture with GNU assembler, using Linux libc functions.
Assemble with :
as -o hello.o hello.aarch64.linux.libc.gas.asm &&
gcc -o hello hello.o
*/
.global main
.section .text
.balign 4
main:
stp x29, x30, [sp, -16]!
add x29, sp, 0
adrp x0, message
add x0, x0, :lo12:message
bl printf
mov w0, 0
ldp x29, x30, [sp], 16
ret
.section .rodata
.balign 4
message:
.asciz "Hello world!\n\0"
|
; =============================================================================
; Pure64 -- a 64-bit OS loader written in Assembly for x86-64 systems
; Copyright (C) 2008-2014 Return Infinity -- see LICENSE.TXT
;
; INIT CPU
; =============================================================================
init_cpu:
; Disable Cache
mov rax, cr0
btr rax, 29 ; Clear No Write Thru (Bit 29)
bts rax, 30 ; Set Cache Disable (Bit 30)
mov cr0, rax
; Flush Cache
wbinvd
; Diable Paging Global Extensions
mov rax, cr4
btr rax, 7 ; Clear Paging Global Extensions (Bit 7)
mov cr4, rax
mov rax, cr3
mov cr3, rax
; Disable MTRRs and Configure default memory type to UC
mov ecx, 0x000002FF
rdmsr
and eax, 0xFFFFF300 ; Clear MTRR Enable (Bit 11), Fixed Range MTRR Enable (Bit 10), and Default Memory Type (Bits 7:0) to UC (0x00)
wrmsr
; Setup variable-size address ranges
; Cache 0-64 MiB as type 6 (WB) cache
; See example in Intel Volume 3A. Example Base and Mask Calculations
; mov ecx, 0x00000200 ; MTRR_Phys_Base_MSR(0)
; mov edx, 0x00000000 ; Base is EDX:EAX, 0x0000000000000006
; mov eax, 0x00000006 ; Type 6 (write-back cache)
; wrmsr
; mov ecx, 0x00000201 ; MTRR_Phys_Mask_MSR(0)
;; mov edx, 0x00000000 ; Mask is EDX:EAX, 0x0000000001000800 (Because bochs sucks)
;; mov eax, 0x01000800 ; Bit 11 set for Valid
; mov edx, 0x0000000F ; Mask is EDX:EAX, 0x0000000F80000800 (2 GiB)
; mov eax, 0x80000800 ; Bit 11 set for Valid
; wrmsr
; MTRR notes:
; Base 0x0000000000000000 = 0 MiB
; Base 0x0000000080000000 = 2048 MiB, 2048 is 0x800
; Base 0x0000000100000000 = 4096 MiB, 4096 is 0x1000
; Mask 0x0000000F80000000 = 2048 MiB, 0xFFFFFFFFF - F80000000 = 7FFFFFFF = 2147483647 (~2 GiB)
; Mask 0x0000000FC0000000 = 1024 MiB, 0xFFFFFFFFF - FC0000000 = 3FFFFFFF = 1073741823 (~1 GiB)
; Mask 0x0000000FFC000000 = 64 MiB, 0xFFFFFFFFF - FFC000000 = 3FFFFFF = 67108863 (~64 MiB)
; Enable MTRRs
mov ecx, 0x000002FF
rdmsr
bts eax, 11 ; Set MTRR Enable (Bit 11), Only enables Variable Range MTRR's
wrmsr
; Flush Cache
wbinvd
; Enable Cache
mov rax, cr0
btr rax, 29 ; Clear No Write Thru (Bit 29)
btr rax, 30 ; Clear CD (Bit 30)
mov cr0, rax
; Enable Paging Global Extensions
; mov rax, cr4
; bts rax, 7 ; Set Paging Global Extensions (Bit 7)
; mov cr4, rax
; Enable Floating Point
mov rax, cr0
bts rax, 1 ; Set Monitor co-processor (Bit 1)
btr rax, 2 ; Clear Emulation (Bit 2)
mov cr0, rax
; Enable SSE
mov rax, cr4
bts rax, 9 ; Set Operating System Support for FXSAVE and FXSTOR instructions (Bit 9)
bts rax, 10 ; Set Operating System Support for Unmasked SIMD Floating-Point Exceptions (Bit 10)
mov cr4, rax
; Enable Math Co-processor
finit
; Enable and Configure Local APIC
mov rsi, [os_LocalAPICAddress]
cmp rsi, 0x00000000
je noMP ; Skip MP init if we didn't get a valid LAPIC address
xor eax, eax ; Clear Task Priority (bits 7:4) and Priority Sub-Class (bits 3:0)
mov dword [rsi+0x80], eax ; Task Priority Register (TPR)
mov eax, 0x01000000 ; Set bits 31-24 for all cores to be in Group 1
mov dword [rsi+0xD0], eax ; Logical Destination Register
xor eax, eax
sub eax, 1 ; Set EAX to 0xFFFFFFFF; Bits 31-28 set for Flat Mode
mov dword [rsi+0xE0], eax ; Destination Format Register
mov eax, dword [rsi+0xF0] ; Spurious Interrupt Vector Register
mov al, 0xF8
bts eax, 8 ; Enable APIC (Set bit 8)
mov dword [rsi+0xF0], eax
mov eax, dword [rsi+0x320] ; LVT Timer Register
bts eax, 16 ; Set bit 16 for mask interrupts
mov dword [rsi+0x320], eax
; mov eax, dword [rsi+0x350] ; LVT LINT0 Register
; mov al, 0 ;Set interrupt vector (bits 7:0)
; bts eax, 8 ;Delivery Mode (111b==ExtlNT] (bits 10:8)
; bts eax, 9
; bts eax, 10
; bts eax, 15 ;bit15:Set trigger mode to Level (0== Edge, 1== Level)
; btr eax, 16 ;bit16:unmask interrupts (0==Unmasked, 1== Masked)
; mov dword [rsi+0x350], eax
; mov eax, dword [rsi+0x360] ; LVT LINT1 Register
; mov al, 0 ;Set interrupt vector (bits 7:0)
; bts eax, 8 ;Delivery Mode (111b==ExtlNT] (bits 10:8)
; bts eax, 9
; bts eax, 10
; bts eax, 15 ;bit15:Set trigger mode to Edge (0== Edge, 1== Level)
; btr eax, 16 ;bit16:unmask interrupts (0==Unmasked, 1== Masked)
; mov dword [rsi+0x360], eax
; mov eax, dword [rsi+0x370] ; LVT Error Register
; mov al, 0 ;Set interrupt vector (bits 7:0)
; bts eax, 16 ;bit16:Mask interrupts (0==Unmasked, 1== Masked)
; mov dword [rsi+0x370], eax
ret
; =============================================================================
; EOF
|
#include <iostream>
#include "CString.h"
using namespace std;
int main(){
CString s1("toto"), s2('q'), s3;
cout << s1.getString() << endl;
cout << s2.getString() << endl;
cout << "nbrChaines = " << CString::nbr_chaines() << endl; //afficher le nombre de chaines créées
s3 = s1.plus('w');
cout << "s3=" << s3.getString() << endl;
if(s1.plusGrandQue(s2)) //si s1 > s2 au sens alphabetique
cout << "plus grand" << endl;
if(s1.infOuEgale(s2)) //si s1 <= s2 au sens alphabetique
cout << "plus petit" << endl;
s3 = s1.plusGrand(s2); //retourner s1 si s1 > s2, s2 sinon
cout << "s3=" << s3.getString() << endl;
}
|
; A138749: a(n) = 2*a(n-1) - 5*a(n-2).
; Submitted by Jon Maiga
; -1,-7,-9,17,79,73,-249,-863,-481,3353,9111,1457,-42641,-92567,28071,518977,897599,-799687,-6087369,-8176303,14084239,69049993,67678791,-209892383,-758178721,-466895527,2857102551,8048682737,1811852719,-36619708247
add $0,1
mov $2,1
lpb $0
sub $0,1
add $1,$2
mul $2,5
sub $1,$2
add $2,$1
sub $2,2
lpe
mov $0,$2
|
dnl SPARC v9 mpn_mul_1 for T3/T4/T5.
dnl Contributed to the GNU project by David Miller and Torbjörn Granlund.
dnl Copyright 2013 Free Software Foundation, Inc.
dnl This file is part of the GNU MP Library.
dnl
dnl The GNU MP Library is free software; you can redistribute it and/or modify
dnl it under the terms of either:
dnl
dnl * the GNU Lesser General Public License as published by the Free
dnl Software Foundation; either version 3 of the License, or (at your
dnl option) any later version.
dnl
dnl or
dnl
dnl * the GNU General Public License as published by the Free Software
dnl Foundation; either version 2 of the License, or (at your option) any
dnl later version.
dnl
dnl or both in parallel, as here.
dnl
dnl The GNU MP Library is distributed in the hope that it will be useful, but
dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
dnl for more details.
dnl
dnl You should have received copies of the GNU General Public License and the
dnl GNU Lesser General Public License along with the GNU MP Library. If not,
dnl see https://www.gnu.org/licenses/.
include(`../config.m4')
C cycles/limb
C UltraSPARC T3: 23
C UltraSPARC T4: 3
C INPUT PARAMETERS
define(`rp', `%i0')
define(`up', `%i1')
define(`n', `%i2')
define(`v0', `%i3')
ASM_START()
REGISTER(%g2,#scratch)
REGISTER(%g3,#scratch)
PROLOGUE(mpn_mul_1)
save %sp, -176, %sp
and n, 3, %g5
add n, -4, n
brz %g5, L(b0)
cmp %g5, 2
bcs %xcc, L(b1)
nop
be %xcc, L(b2)
nop
L(b3): addcc %g0, %g0, %i5
ldx [up+0], %l0
ldx [up+8], %l1
ldx [up+16], %l2
mulx %l0, v0, %o0
umulxhi(%l0, v0, %o1)
brgz n, L(gt3)
add rp, -8, rp
mulx %l1, v0, %o2
umulxhi(%l1, v0, %o3)
b L(wd3)
nop
L(gt3): ldx [up+24], %l3
mulx %l1, v0, %o2
umulxhi(%l1, v0, %o3)
add up, 24, up
b L(lo3)
add n, -3, n
L(b2): addcc %g0, %g0, %o1
ldx [up+0], %l1
ldx [up+8], %l2
brgz n, L(gt2)
add rp, -16, rp
mulx %l1, v0, %o2
umulxhi(%l1, v0, %o3)
mulx %l2, v0, %o4
umulxhi(%l2, v0, %o5)
b L(wd2)
nop
L(gt2): ldx [up+16], %l3
mulx %l1, v0, %o2
umulxhi(%l1, v0, %o3)
ldx [up+24], %l0
mulx %l2, v0, %o4
umulxhi(%l2, v0, %o5)
add up, 16, up
b L(lo2)
add n, -2, n
L(b1): addcc %g0, %g0, %o3
ldx [up+0], %l2
brgz n, L(gt1)
nop
mulx %l2, v0, %o4
stx %o4, [rp+0]
umulxhi(%l2, v0, %i0)
ret
restore
L(gt1): ldx [up+8], %l3
ldx [up+16], %l0
mulx %l2, v0, %o4
umulxhi(%l2, v0, %o5)
ldx [up+24], %l1
mulx %l3, v0, %i4
umulxhi(%l3, v0, %i5)
add rp, -24, rp
add up, 8, up
b L(lo1)
add n, -1, n
L(b0): addcc %g0, %g0, %o5
ldx [up+0], %l3
ldx [up+8], %l0
ldx [up+16], %l1
mulx %l3, v0, %i4
umulxhi(%l3, v0, %i5)
ldx [up+24], %l2
mulx %l0, v0, %o0
umulxhi(%l0, v0, %o1)
b L(lo0)
nop
ALIGN(16)
L(top): ldx [up+0], %l3 C 0
addxccc(%i4, %o5, %i4) C 0
mulx %l1, v0, %o2 C 1
stx %i4, [rp+0] C 1
umulxhi(%l1, v0, %o3) C 2
L(lo3): ldx [up+8], %l0 C 2
addxccc(%o0, %i5, %o0) C 3
mulx %l2, v0, %o4 C 3
stx %o0, [rp+8] C 4
umulxhi(%l2, v0, %o5) C 4
L(lo2): ldx [up+16], %l1 C 5
addxccc(%o2, %o1, %o2) C 5
mulx %l3, v0, %i4 C 6
stx %o2, [rp+16] C 6
umulxhi(%l3, v0, %i5) C 7
L(lo1): ldx [up+24], %l2 C 7
addxccc(%o4, %o3, %o4) C 8
mulx %l0, v0, %o0 C 8
stx %o4, [rp+24] C 9
umulxhi(%l0, v0, %o1) C 9
add rp, 32, rp C 10
L(lo0): add up, 32, up C 10
brgz n, L(top) C 11
add n, -4, n C 11
L(end): addxccc(%i4, %o5, %i4)
mulx %l1, v0, %o2
stx %i4, [rp+0]
umulxhi(%l1, v0, %o3)
addxccc(%o0, %i5, %o0)
L(wd3): mulx %l2, v0, %o4
stx %o0, [rp+8]
umulxhi(%l2, v0, %o5)
addxccc(%o2, %o1, %o2)
L(wd2): stx %o2, [rp+16]
addxccc(%o4, %o3, %o4)
stx %o4, [rp+24]
addxc( %g0, %o5, %i0)
ret
restore
EPILOGUE()
|
; DV3 IDE Direct Sector Access Address V3.00 1998 Tony Tebby
; use per drive check for lba not per device V3.01 W. Lenerz 2017 Nov 18
section dv3
xdef id_diradd ; direct sector address
xref id_ident
xref dv3_dsector
include 'dev8_keys_err'
include 'dev8_dv3_keys'
include 'dev8_dv3_hd_keys'
include 'dev8_mac_assert'
;+++
; This routine converts the address on drive to cyl/head/sector format if req
;
; d0 cr sector number (may return error code)
; d7 c p drive ID / number
; a3 c p linkage block
; a4 c p drive definition
;
; status return 0 or ERR.MCHK
;
;---
id_diradd
tst.b ddf_lba(a4) ; cylinder head side required?
beq.s idd_rts ; no
assert ddf_heads+2,ddf_scyl
tst.l ddf_heads(a4) ; sectors / sides set?
bne.s idd_convert ; ... yes, convert
move.l d0,-(sp)
jsr id_ident ; identify
bne.s idd_oops ; ... oops
move.l (sp)+,d0
idd_convert
jsr dv3_dsector ; convert sector number
cmp.b d0,d0
idd_rts
rts
idd_oops
addq.l #4,sp
rts
end
|
TITLE PRACTICE PROBLEM 7
.MODEL SMALL
.DATA
STR1 DB 'Enter 3 single digit umbers: $'
STR2 DB 'Sum = $'
.CODE
MAIN PROC
MOV DX, @DATA
MOV DS, DX
LEA DX, STR1 ;1st string
MOV AH, 9
INT 21h
MOV AH,1 ;1st input
INT 21h
MOV CH, AL
MOV AH,1 ;2nd input
INT 21h
ADD CH, AL
SUB CH, '0'
MOV AH,1 ;3rd input
INT 21h
ADD CH, AL
SUB CH, '0'
MOV AH, 2 ;new line
MOV DL, 0Dh
INT 21h
MOV DL, 0Ah
INT 21h
LEA DX, STR2 ;2nd string
MOV AH, 9
INT 21h
MOV AH, 2 ;PRINTING SUM
MOV DL, CH
INT 21h
MOV AH, 4Ch ;RETURN
INT 21h
MAIN ENDP
END MAIN
|
; A266304: Total number of OFF (white) cells after n iterations of the "Rule 15" elementary cellular automaton starting with a single ON (black) cell.
; 0,1,5,6,14,15,27,28,44,45,65,66,90,91,119,120,152,153,189,190,230,231,275,276,324,325,377,378,434,435,495,496,560,561,629,630,702,703,779,780,860,861,945,946,1034,1035,1127,1128,1224,1225,1325,1326,1430,1431,1539,1540,1652,1653,1769,1770,1890,1891,2015,2016,2144,2145,2277,2278,2414,2415,2555,2556,2700,2701,2849,2850,3002,3003,3159,3160,3320,3321,3485,3486,3654,3655,3827,3828,4004,4005,4185,4186,4370,4371,4559,4560,4752,4753,4949,4950,5150,5151,5355,5356,5564,5565,5777,5778,5994,5995,6215,6216,6440,6441,6669,6670,6902,6903,7139,7140,7380,7381,7625,7626,7874,7875,8127,8128,8384,8385,8645,8646,8910,8911,9179,9180,9452,9453,9729,9730,10010,10011,10295,10296,10584,10585,10877,10878,11174,11175,11475,11476,11780,11781,12089,12090,12402,12403,12719,12720,13040,13041,13365,13366,13694,13695,14027,14028,14364,14365,14705,14706,15050,15051,15399,15400,15752,15753,16109,16110,16470,16471,16835,16836,17204,17205,17577,17578,17954,17955,18335,18336,18720,18721,19109,19110,19502,19503,19899,19900,20300,20301,20705,20706,21114,21115,21527,21528,21944,21945,22365,22366,22790,22791,23219,23220,23652,23653,24089,24090,24530,24531,24975,24976,25424,25425,25877,25878,26334,26335,26795,26796,27260,27261,27729,27730,28202,28203,28679,28680,29160,29161,29645,29646,30134,30135,30627,30628,31124,31125
mov $1,$0
div $0,2
add $1,$0
pow $0,2
add $1,$0
add $1,$0
|
include cmacros.inc
sBegin DATA
stacker_lbl db 'STACKER ' ;
oldDTAaddr dd 0
myDTA db 21 dup (0) ; reserved
db 0 ; attrib
dw 0 ; time
dw 0 ; date
dd 0 ; file size
volname db 13 dup (0) ; file name
db 5 dup (0) ; buffer
pattern db 'A:*.*', 0 ; search pattern
sEnd DATA
sBegin CODE
assumes cs,CODE
assumes ds,DATA
;------------------------------------------------------------------------
;
; get_volume_label
;
; gets volume label of a drive
;
; Input:
;
; WORD drive (0=A, 1=B, ...)
; LPSTR lpsz receiving buffer
;
; Output:
;
; void
;
cProc get_volume_label,<NEAR,PUBLIC>,<ds,es,ax,bx,cx,dx,si,di>
parmW drive
parmD lpsz
cBegin
mov ax,_DATA
mov ds,ax
; replace DTA address with ours
mov ah,2fh
int 21h
mov word ptr oldDTAaddr,bx
mov word ptr oldDTAaddr+2,es
mov ah,1ah
lea dx,myDTA
int 21h
; get volume label for the given drive
lea bx,pattern
mov ax,drive
add ax,'A'
mov byte ptr [bx],al
mov dx,bx
mov cx,8
mov ah,4eh
int 21h
; set up destination buffer
cld
les di,lpsz
jc no_volume_label
; copy volume label, insert brackets front and back
mov al,'['
stosb
lea si,volname
mov cx,8
copy_name:
lodsb
cmp al,'.'
je copy_ext
stosb
dec cx
cmp al,0
jnz copy_name
dec di
jmp short copy_done
copy_ext:
mov al,' '
rep stosb
mov cx,3
repnz movsb
strip_tail:
dec di
mov al,byte ptr es:[di]
cmp al,' '
je strip_tail
cmp al,9
je strip_tail
cmp al,0
je strip_tail
inc di
copy_done:
mov al,']'
stosb
no_volume_label:
; store null terminator
xor ax,ax
stosb
; restore DTA address
mov ah,1ah
mov dx,word ptr oldDTAaddr
mov ds,word ptr oldDTAaddr+2
int 21h
cEnd
;------------------------------------------------------------------------
;
; is_CDROM_drive
;
; Determines if a drive is a CDROM drive
;
; Input:
;
; WORD drive (0=A, 1=B, ...)
;
; Output:
;
; returns non-zero for CDROM drive, 0 otherwise
;
cProc is_CDROM_drive,<NEAR,PUBLIC>,<bx,cx>
parmW drive
cBegin
mov ax, 1500h ; first test for presence of MSCDEX
xor bx, bx
int 2fh
mov ax, bx ; MSCDEX is not there if bx is still zero
or ax, ax ; ...so return FALSE from this function
jz no_mscdex
mov ax, 150bh ; MSCDEX driver check API
mov cx, drive ; ...cx is drive index
int 2fh
no_mscdex:
cEnd
;------------------------------------------------------------------------
;
; is_valid_CD
;
; Determines if a CDROM drive contains a valid FAT disk.
; Assumes current drive is a CDROM drive.
;
; Input:
;
; none
;
; Output:
;
; returns non-zero for a valid CDROM disk, 0 otherwise
;
cProc is_valid_CD,<NEAR,PUBLIC>,<bx,cx,dx,ds,es>
cBegin
; replace DTA address with ours
mov ah,2fh
int 21h
mov word ptr oldDTAaddr,bx
mov word ptr oldDTAaddr+2,es
mov ah,1ah
lea dx,myDTA
int 21h
; get "*.*" search pattern
lea dx,pattern
add dx,2 ; go past "A:"
mov cx,8 ; look for directory
mov ah,4eh
clc
int 21h
mov cx,1
jc ivc_found
xor cx,cx
ivc_found:
; restore DTA address
mov ah,1ah
mov dx,word ptr oldDTAaddr
mov ds,word ptr oldDTAaddr+2
int 21h
mov ax,cx
cEnd
;------------------------------------------------------------------------
;
; is_RAM_drive
;
; Determines if a drive is a RAM drive
;
; Input:
;
; WORD drive (0=A, 1=B, ...)
;
; Output:
;
; returns non-zero for RAM drive, 0 otherwise
;
cProc is_RAM_drive,<NEAR,PUBLIC>,<ds,bx,dx>
parmW drive
cBegin
mov dx,drive ; set drive id
inc dx ; this function expects 1-based drive
mov ah,32h
clc
int 21h
jc not_ram ; if failed assume it's not a RAM drive
mov al,ds:[bx+8]
cmp al,1 ; only 1 FAT table, assume it's a RAM drive
je r_done
not_ram:
xor al,al
r_done:
xor ah,ah
cEnd
;------------------------------------------------------------------------
;
; is_Stacker_drive
;
; Determines if a drive is a Stacker drive
;
; Input:
;
; WORD drive (0=A, 1=B, ...)
; LPSTR tempDTA
;
; Output:
;
; returns non-zero for Stacker drive, 0 otherwise
;
ParamBlockStruc struc
LO_sector dw ? ; Lo word of starting sector
HI_sector dw ? ; Hi word of starting sector
SecCount dw ? ; Number of sectors to read
BuffOff dw ? ; Offset of Buffer
BuffSeg dw ? ; Segment of Buffer
ParamBlockStruc ends
cProc is_Stacker_drive,<NEAR,PUBLIC>,<ds,es,bx,cx,dx,di,si>
parmW drive
parmD tempDTA
LocalV ParamBlock, %(size ParamBlockStruc)
cBegin
mov ax,drive ; set drive id
lds bx,tempDTA
mov cx,1
mov dx,0
push bp ; Save BP
int 25h
pop bx ; Remove flags from stack
pop bp ; Restore BP
jnc check_label
; If this has failed, it could be a partition > 32 Meg. So, try
; again assuming Partition size is > 32 Meg. If this also fails,
; this is really an error;
mov ax,drive
mov dx,0
; Fill the parameter block with proper values
mov ParamBlock.LO_sector,dx ; Starting sector
; We get only 16 bit starting sector; So, hi word is made zero
mov ParamBlock.HI_sector,0
; The number of sectors to be read
mov dx,1
mov ParamBlock.SecCount,dx
; The address of the buffer to read into
mov dx,OFF_tempDTA
mov ParamBlock.BuffOff,dx
mov dx,SEG_tempDTA
mov ParamBlock.BuffSeg,dx
; Keep the address of ParamBlock in DS:BX
lea bx,ParamBlock
push ss
pop ds
mov cx,-1 ; > 32Meg partition
push bp ; Save BP
int 25h
pop bx ; Remove the flags on stack
pop bp ; Restore BP
jc not_stacker
check_label:
mov cx,4 ; See if disk label is right
mov ax,_DATA
mov es,ax
lea di,stacker_lbl
lds si,tempDTA
add si,3
repe cmpsw
jcxz found_stacker
jmp short not_stacker
found_stacker:
mov ax,1
jmp short s_done
not_stacker:
xor ax,ax
s_done:
cEnd
;------------------------------------------------------------------------
;
; get_current_drive
;
cProc get_current_drive,<NEAR,PUBLIC>
cBegin
mov ah,19h
int 21h
add al,'a' ; 0=>a, 1=>b, etc
sub ah,ah
cEnd
;------------------------------------------------------------------------
;
; set_current_drive
;
cProc set_current_drive,<NEAR,PUBLIC>
parmW drive
cBegin
mov dl,drive
mov ah,0eh
int 21h
cEnd
;------------------------------------------------------------------------
;
; get_free_space
;
; Input:
;
; WORD drive (0=A, 1=B, ...)
;
; Output:
;
; Returns free disk space in DX:AX
;
cProc get_free_space,<NEAR,PUBLIC>,<bx,cx>
parmW drive
cBegin
mov dl,drive
inc dl ; 1 based
mov ah,36h
int 21h
mul cx
mul bx
cEnd
;------------------------------------------------------------------------
;
; get_boot_drive
;
cProc get_boot_drive,<NEAR,PUBLIC>
cBegin
mov ax,3305h ; ax = 3305h --> Get boot drive A=1,B=2, ect.
int 21h ; Call DOS.
mov al,dl ; Return result in AX.
xor ah,ah
cEnd
;------------------------------------------------------------------------
;
; get_dos_version
;
cProc get_dos_version,<NEAR,PUBLIC,NODATA>, <si>
cBegin
mov ax,3000h
int 21h
cEnd
;------------------------------------------------------------------------
;
; count_valid_drives
;
cProc count_valid_drives,<NEAR,PUBLIC>,<bx,cx,dx,es,di>
parmD drivelist
cBegin
les di,drivelist
xor cx,cx ; # Found so far
mov ah,19h
int 21h ; Get current drive in AL
mov bx,ax ; Save so we can restore it
cld
stosb ; Save it as 1st buff entry
xor dx,dx ; Start with drive A:
find_loop:
mov ah,0eh ; Select the drive
int 21h ; (AL contains max drive)
mov dh,al
mov ah,19h
int 21h
cmp dl,al ; Q: Did change work?
jne short try_next ; N: Invalid
; Y: Found one more
inc cx
cld
stosb
try_next:
inc dl ; DL = Next drive
cmp dl,dh ; Q: Any more drives to check?
jb short find_loop ; Y: Keep looking
mov dl,bl ; DL = Original default drive
mov ah,0eh ; Select drive
int 21h
mov ax,cx ; Return count
cEnd
sEnd CODE
end
|
; A106149: Number of prime factors with multiplicity of the difference between consecutive primes.
; 0,1,1,2,1,2,1,2,2,1,2,2,1,2,2,2,1,2,2,1,2,2,2,3,2,1,2,1,2,2,2,2,1,2,1,2,2,2,2,2,1,2,1,2,1,3,3,2,1,2,2,1,2,2,2,2,1,2,2,1,2,2,2,1,2,2,2,2,1,2,2,3,2,2,2,2,3,2,3,2,1
add $0,1
seq $0,40 ; The prime numbers.
div $0,2
mul $0,2
sub $0,1
seq $0,64722 ; a(1) = 0; for n >= 2, a(n) = n - (largest prime <= n).
seq $0,1222 ; Number of prime divisors of n counted with multiplicity (also called bigomega(n) or Omega(n)).
|
; position independent non-NULL shellcode
BITS 32
section .text
global _start
_start:
jmp start ; jump to program start (keeps PIC offsets from having NULLs)
; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
; get_address(1, 2, 3)
; [esp + 0xC] = (3) strlen(function string)
; [esp + 0x8] = (2) pointer to function string to look for
; [esp + 0x4] = (1) DLL base address
; [esp + 0x0] = return address from call
; - returns in eax the virtual address of the function from the DLL provided
; - all registers are caller saved except for ebp/esp
; - caller responsible for stack cleanup
; - does not modify arguments passed in on the stack
; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
get_address:
mov eax, [esp + 0x4] ; get DLL base address
mov ebx, [eax + 0x3C] ; get RVA of PE header
add ebx, eax ; get virtual address of PE header
mov ebx, [ebx + 0x78] ; get RVA of export table in PE header
add ebx, eax ; get virtual address of export table
mov edx, [ebx + 0x20] ; get RVA of name pointer table in export table
add edx, eax ; get virtual address of name pointer table
mov eax, [ebx + 0x18] ; get number of exported *named* functions from export table
.loop: ; loop through name pointer table backwards
dec eax ; go to the next name pointer
mov ecx, [esp + 0xC] ; get length of target string
mov edi, [esp + 0x8] ; get pointer to target string
mov esi, [edx + (eax * 0x4)] ; get RVA of next pointer from name table (entries are 4 bytes long)
add esi, [esp + 0x4] ; get virtual address of next pointer from name table
repe cmpsb ; compare till ecx = 0 or hit a NULL byte
jnz get_address.loop ; if ecx != 0, then keep looping
mov esi, [ebx + 0x24] ; get the RVA of the ordinal table in export table
add esi, [esp + 0x4] ; get the virtual address of the ordinal table
mov ax, [esi + (eax * 0x2)] ; get the ordinal number of the target function from the ordinal table (entries are 2 bytes long)
mov esi, [ebx + 0x1C] ; get RVA of address table in export table
add esi, [esp + 0x4] ; get the virtual address of the address table
mov eax, [esi + (eax * 0x4)] ; get the RVA of the target function
add eax, [esp + 0x4] ; get the virtual address of the target function
ret
; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
; main routine:
; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
start:
xor ebp, ebp ; keep ebp as constant NULL for program
mov ebx, [fs:ebp + 0x30] ; get address of PEB from TEB
mov ebx, [ebx + 0xC] ; get pointer to PEB_LDR_DATA in PEB
mov ebx, [ebx + 0x14] ; get pointer to LDR_MODULE[0] from Flink of InMemoryOrderModuleList in PEB_LDR_DATA
mov ebx, [ebx] ; get pointer to ntdll.dll
mov ebx, [ebx] ; get pointer to kernel32.dll
mov ebx, [ebx + 0x10] ; get pointer to BaseAddress of kernel32.dll
push LoadLibraryA.len
jmp LoadLibraryA
_LoadLibraryA:
push ebx
call get_address ; get_address(kernel32.dll, 'LoadLibraryA', strlen('LoadLibraryA'))
jmp User32
_User32:
mov esi, [esp]
mov word [esi + User32.len], bp ; get dll pointer and add NULL termination to string
call eax ; LoadLibraryA('user32')
push MessageBoxA.len
jmp MessageBoxA
_MessageBoxA:
push eax
call get_address ; get_address(user32.dll, 'MessageBoxA', strlen('MessageBoxA'))
push ebp
push ebp
jmp msg
_msg:
mov esi, [esp]
mov word [esi + msg.len], bp ; get message pointer and add NULL termination to string
push ebp
call eax ; MessageBox(NULL, message, NULL, NULL)
push ExitProcess.len
jmp ExitProcess
_ExitProcess:
mov ebx, [esp + 0x24] ; load kernel32.dll address off of stack from call to 1st get_address()
push ebx
call get_address ; get_address(kernel32.dll, "ExitProcess", strlen("ExitProcess"))
push ebp
call eax ; ExitProcess(0)
; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
; position independent code (PIC) data:
; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
LoadLibraryA:
call _LoadLibraryA
.string:
; https://docs.microsoft.com/en-us/windows/win32/api/libloaderapi/nf-libloaderapi-loadlibrarya
db "LoadLibraryA"
.len: equ $ - LoadLibraryA.string
User32:
call _User32
.string:
db "user32", 0x30, 0x30 ; NULL byte set at runtime (with a store WORD not BYTE)
.len: equ $ - User32.string - 0x2 ; 2 byte offset to point to first temp 0x30 byte
MessageBoxA:
call _MessageBoxA
.string:
; https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-messageboxa
db "MessageBoxA"
.len: equ $ - MessageBoxA.string
msg:
call _msg
.string:
db "Hello World!", 0x30, 0x30 ; NULL byte set at runtime (with a store WORD not BYTE)
.len: equ $ - msg.string - 0x2 ; 2 byte offset to point to first temp 0x30 byte
ExitProcess:
call _ExitProcess
.string:
; https://docs.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-exitprocess
db "ExitProcess"
.len: equ $ - ExitProcess.string
|
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Copyright (c) Geoworks 1995 -- All Rights Reserved
GEOWORKS CONFIDENTIAL
PROJECT: Socket
MODULE: Modem Driver
FILE: modemParse.asm
AUTHOR: Jennifer Wu, Mar 16, 1995
ROUTINES:
Name Description
---- -----------
Method:
ModemReceiveData Data notification handler
Subroutines:
ModemDataNotify
ModemResponseNotify
ModemBuildResponse
ResponseDoNone
ResponseDoSawBeginCR
ResponseDoRecvResponse
ResponseDoSawEndCR
ResponseDoSawBeginEcho
ResponseDoRecvEcho
ModemParseNoConnection
ModemParseBasicResponse
ModemParseDialResponse
ModemParseAnswerCallResponse
ModemParseEscapeResponse
ModemParseConnectResponse
ModemParseConnectBaud
ModemBaudToUnsignedInt
ModemCheckCommandEcho
REVISION HISTORY:
Name Date Description
---- ---- -----------
jwu 3/16/95 Initial revision
DESCRIPTION:
Code for processing modem responses
$Id: modemParse.asm,v 1.1 97/04/18 11:47:53 newdeal Exp $
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
CommonCode segment resource
;---------------------------------------------------------------------------
; Modem Response Strings
;---------------------------------------------------------------------------
responseOk char "OK"
responseError char "ERROR"
responseBusy char "BUSY"
responseNoDialtone char "NO DIALTONE"
responseNoAnswer char "NO ANSWER"
responseNoCarrier char "NO CARRIER"
responseConnect char "CONNECT"
responseBlacklisted char "BLACKLISTED"
responseDelayed char "DELAYED"
;---------------------------------------------------------------------------
; Data notification handler
;---------------------------------------------------------------------------
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ModemReceiveData
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Data notification handler.
CALLED BY: MSG_MODEM_RECEIVE_DATA
PASS: *ds:si = ModemProcessClass object
RETURN: nothing
DESTROYED: ax, cx, dx, bp
PSEUDO CODE/STRATEGY:
NOTE: If client is not registered for data notification,
then the modem driver will not get further notifications
until the client has read at least one byte from the serial
port.
REVISION HISTORY:
Name Date Description
---- ---- -----------
jwu 3/20/95 Initial version
jwu 9/11/96 keep reading data after a response
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
ModemReceiveData method dynamic ModemProcessClass,
MSG_MODEM_RECEIVE_DATA
;
; Make sure this notification didn't come in after modem
; thread is being destroyed. If it did, just exit because
; the port has been closed.
;
mov bx, handle dgroup
call MemDerefES
tst es:[modemThread]
LONG je exit
dataLoop:
;
; If in command mode, look for a response. Else notify
; client of data.
;
test es:[modemStatus], mask MS_COMMAND_MODE
jnz isResponse
cmp es:[dataNotify].SN_type, SNM_NONE
je flushInput
call ModemDataNotify
jmp exit
isResponse:
;
; Build the modem response. If a complete response has been
; received, send out any needed response notifications. Then,
; parse the response.
;
call ModemBuildResponse
jc exit
cmp es:[respNotify].SN_type, SNM_NONE
je parse
call ModemResponseNotify
parse:
call es:[parser]
;
; Reset response status and response size.
;
lahf
andnf es:[modemStatus], not mask MS_RESPONSE_INFO
mov es:[responseSize], 0
sahf
jc dataLoop
;
; Wake up client, if any, so they can check response. Stop
; response timer, unless it has already expired.
;
test es:[modemStatus], mask MS_CLIENT_BLOCKED
jz exit
clr bx
xchg bx, es:[responseTimer]
EC < tst bx >
EC < ERROR_E RESPONSE_TIMER_MISSING >
mov ax, es:[responseTimerID]
call TimerStop
BitClr es:[modemStatus], MS_CLIENT_BLOCKED
mov bx, es:[responseSem]
call ThreadVSem
;
; Continue reading data in case more follows the response.
;
jmp dataLoop
flushInput:
;
; Make sure port is still open after we release
; es:[responseSem] as another thread could be closing
; modem. Port is closed if es:[portNum] == -1.
;
EC < WARNING MODEM_DRIVER_FLUSHING_INPUT_DATA >
mov bx, es:[portNum]
cmp bx, -1
je exit
mov ax, STREAM_READ
mov di, DR_STREAM_FLUSH
call es:[serialStrategy]
exit:
ret
ModemReceiveData endm
;---------------------------------------------------------------------------
; Subroutines
;---------------------------------------------------------------------------
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ModemDataNotify
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Notify the client of incoming data using the method
requested by the client.
CALLED BY: ModemReceiveData
PASS: es = dgroup
RETURN: nothing
DESTROYED: ax, bx, di, si
REVISION HISTORY:
Name Date Description
---- ---- -----------
jwu 3/20/95 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
ModemDataNotify proc near
CheckHack <SNM_ROUTINE lt SNM_MESSAGE>
mov al, es:[dataNotify].SN_type
cmp al, SNM_ROUTINE
mov ax, es:[dataNotify].SN_data
ja notifyMethod
pushdw es:[dataNotify].SN_dest.SND_routine
call PROCCALLFIXEDORMOVABLE_PASCAL
jmp done
notifyMethod:
mov bx, es:[dataNotify].SN_dest.SND_message.handle
mov si, es:[dataNotify].SN_dest.SND_message.chunk
mov di, mask MF_FORCE_QUEUE
call ObjMessage
done:
ret
ModemDataNotify endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ModemResponseNotify
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Notify the client about a modem response using the method
requested by the client.
CALLED BY: ModemReceiveData
PASS: es = dgroup
response is in responseBuf
responseSize contains size of response (not null terminated)
RETURN: nothing
DESTROYED: ax, bx, cx, dx, bp, di, si
REVISION HISTORY:
Name Date Description
---- ---- -----------
jwu 3/20/95 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
ModemResponseNotify proc near
;
; Figure out how to deliver response to client.
;
CheckHack <SNM_ROUTINE lt SNM_MESSAGE>
mov cx, es:[responseSize]
mov al, es:[respNotify].SN_type
cmp al, SNM_ROUTINE
ja notifyMethod
;
; Do routine notification.
;
mov ax, es:[respNotify].SN_data
mov dx, es
mov bp, offset responseBuf
pushdw es:[respNotify].SN_dest.SND_routine
call PROCCALLFIXEDORMOVABLE_PASCAL
jmp done
notifyMethod:
;
; Allocate a block for the response. If failed, just bail.
;
mov dx, cx ; dx = size
mov_tr ax, cx
mov cx, (mask HAF_LOCK shl 8) or mask HF_SHARABLE or \
mask HF_SWAPABLE
call MemAlloc
jc done
push ds, es
mov ds, ax
segxchg ds, es
clr di ; es:di = dest.
mov si, offset responseBuf ; ds:si = response
mov cx, dx ; cx = size
rep movsb
call MemUnlock
pop ds, es
;
; Send notification.
;
mov_tr cx, dx ; cx = size
mov_tr dx, bx ; ^hdx = response
mov ax, es:[respNotify].SN_data ; ax = msg
movdw bxsi, es:[respNotify].SN_dest.SND_message
mov di, mask MF_FORCE_QUEUE
call ObjMessage
done:
ret
ModemResponseNotify endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ModemBuildResponse
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Build the modem response from the incoming data. The
ending <CR> is included in the response.
CALLED BY: ModemReceiveData
PASS: es = ds = dgroup
RETURN: carry clear if complete response has been received
DESTROYED: ax, bx, cx, di, si
PSEUDO CODE/STRATEGY:
get current state
read loop:
read byte
call the routine for the current response state
go to read loop if more data is needed
storeState:
store the new state into dgroup
REVISION HISTORY:
Name Date Description
---- ---- -----------
jwu 3/20/95 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
ModemBuildResponse proc near
;
; Get the common info now so it's only done once.
;
mov si, offset es:[responseBuf]
add si, es:[responseSize] ; ds:si = place for data
clr ch
mov cl, es:[modemStatus]
andnf cl, mask MS_RESPONSE_INFO ; cl = current state
mov bx, es:[portNum]
readLoop:
;
; Read one byte of data at a time. Then call the appropriate
; routine to process it, depending on the state.
;
mov ax, STREAM_NOBLOCK
mov di, DR_STREAM_READ_BYTE
call es:[serialStrategy] ; al = byte read
jc done
mov bp, cx
shl bp, 1 ; index into table
call cs:responseTable[bp]
jc readLoop
done:
;
; Store the new state in the modem status and update response size.
;
lahf
andnf es:[modemStatus], not mask MS_RESPONSE_INFO
ornf es:[modemStatus], cl
sub si, offset es:[responseBuf]
mov es:[responseSize], si
EC < cmp si, RESPONSE_BUFFER_SIZE >
EC < ERROR_A MODEM_INTERNAL_ERROR ; overflowed buffer >
sahf
ret
responseTable nptr \
offset ResponseDoNone, ; MRS_NONE
offset ResponseDoSawBeginCR, ; MRS_SAW_BEGIN_CR
offset ResponseDoRecvResponse, ; MRS_RECV_RESPONSE
offset ResponseDoSawEndCR, ; MRS_SAW_END_CR
offset ResponseDoSawBeginEcho, ; MRS_SAW_BEGIN_ECHO
offset ResponseDoRecvEcho ; MRS_RECV_ECHO
ModemBuildResponse endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ResponseDoNone
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Process the data byte in the state where nothing has
been received from the modem yet.
CALLED BY: ModemBuildResponse
ResponseDoSawBeginEcho
ResponseDoRecvEcho
PASS: al = byte
ds:si = place for data byte in response buffer
es = dgroup
RETURN: cl = next ModemResponseState
ds:si = place for next data byte
carry set
DESTROYED: nothing
PSEUDO CODE/STRATEGY:
if byte is <CR>, assume it is part of <CR><LF> pair and
set state to MRS_SAW_BEGIN_CR
if byte is "A" or "+", assume it is begining of command echo
and set state to MRS_SAW_BEGIN_ECHO
else if byte is <LF> assume modem is beginning response
without complete leading <CR><LF> pair and
set state to MRS_RECV_RESPONSE
else store byte, assuming modem is beginning response
without leading <CR><LF> pair and set state
to MRS_RECV_RESPONSE
return carry set
REVISION HISTORY:
Name Date Description
---- ---- -----------
jwu 3/20/95 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
ResponseDoNone proc near
EC < cmp si, offset responseBuf >
EC < ERROR_NE MODEM_BAD_RESPONSE_STATE >
EC < cmp cl, MRS_NONE >
EC < ERROR_NE MODEM_BAD_RESPONSE_STATE >
;
; Look for <CR>.
;
cmp al, C_CR
jne checkA
mov cl, MRS_SAW_BEGIN_CR
jmp done
checkA:
;
; Look for "A" or "+". If neither, then assume modem is
; beginning the response without the <CR><LF> pair. Store
; the byte and advance to the appropriate state.
;
mov cl, MRS_SAW_BEGIN_ECHO ; assume echo
cmp al, 'A'
je storeByte
cmp al, '+'
je storeByte
;
; If <LF>, just set state else store byte also.
;
mov cl, MRS_RECV_RESPONSE ; start response
cmp al, C_LF
je done
storeByte:
mov ds:[si], al
inc si
done:
stc
ret
ResponseDoNone endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ResponseDoSawBeginCR
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Process the data byte in the state where only a <CR> has
been received from the modem.
CALLED BY: ModemBuildResponse
PASS: al = byte
ds:si = place for data byte in response buffer
es = dgroup
cl = MRS_SAW_BEGIN_CR
RETURN: cl = next ModemResponseState
ds:si = place for next data byte
carry set
DESTROYED: nothing
PSEUDO CODE/STRATEGY:
If byte is <LF>, set state to MRS_RECV_RESPONSE
else (assume the previous <CR> was line garbage)
return state to MRS_NONE and reprocess byte in case
it is a <CR>
return carry set
REVISION HISTORY:
Name Date Description
---- ---- -----------
jwu 3/20/95 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
ResponseDoSawBeginCR proc near
EC < cmp si, offset responseBuf >
EC < ERROR_NE MODEM_BAD_RESPONSE_STATE >
EC < cmp cl, MRS_SAW_BEGIN_CR >
EC < ERROR_NE MODEM_BAD_RESPONSE_STATE >
;
; Assume a <LF> follows the <CR> for the opening <CR><LF> pair.
;
mov cl, MRS_RECV_RESPONSE
cmp al, C_LF
je done
;
; Reset modem response state and reprocess current byte as it
; may be a <CR>.
;
mov cl, MRS_NONE
call ResponseDoNone
done:
stc
ret
ResponseDoSawBeginCR endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ResponseDoRecvResponse
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Process the data byte as part of the response or check
for the ending <CR><LF> pair.
CALLED BY: ModemBuildResponse
ResponseDoSawEndCR
PASS: al = byte
ds:si = place for data byte in response buffer
es = dgroup
cl = MRS_RECV_RESPONSE
RETURN: cl = next ModemResponseState
ds:si = place for next data byte
carry set
DESTROYED: nothing
PSEUDO CODE/STRATEGY:
If buffer will overflow, discard data in buffer
reprocess byte from start
else
stick the byte in the buffer
if byte is <CR>, assume it is part of <CR><LF> pair and
set state to MRS_SAW_END_CR
return carry set
REVISION HISTORY:
Name Date Description
---- ---- -----------
jwu 3/20/95 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
ResponseDoRecvResponse proc near
EC < cmp cl, MRS_RECV_RESPONSE >
EC < ERROR_NE MODEM_BAD_RESPONSE_STATE >
;
; Check for possible overflow.
; to overflow the buffer so data must be garbage.
;
CheckHack <offset responseBuf + RESPONSE_BUFFER_SIZE eq offset responseSize>
cmp si, offset responseSize
jb storeByte
EC < WARNING MODEM_CORRECTING_RESPONSE_BUFFER_OVERFLOW >
mov si, offset responseBuf
mov cl, MRS_NONE
call ResponseDoNone
jmp done
storeByte:
;
; Store byte and check if end of response.
;
mov ds:[si], al
inc si
cmp al, C_CR
jne done
mov cl, MRS_SAW_END_CR
done:
stc
ret
ResponseDoRecvResponse endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ResponseDoSawEndCR
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Process the data byte where the ending <LF> of the final
<CR><LF> pair is expected.
CALLED BY: ModemBuildResponse
PASS: al = byte
ds:si = place for data byte in response buffer
cl = MRS_SAW_END_CR
RETURN: cl = next ModemResponseState
ds:si = place for next data byte
carry clear if a complete response has been received
DESTROYED: nothing
PSEUDO CODE/STRATEGY:
if byte is LF, return with carry clear
else assume the previous <CR> was part of the data and
stick that into the buffer. Set state back to
MRS_RECV_RESPONSE, and call ResponseDoRecvResponse
REVISION HISTORY:
Name Date Description
---- ---- -----------
jwu 3/20/95 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
ResponseDoSawEndCR proc near
EC < cmp cl, MRS_SAW_END_CR >
EC < ERROR_NE MODEM_BAD_RESPONSE_STATE >
;
; If <LF>, then we have a complete response.
;
cmp al, C_LF
jne notEnd
;
; If response only contains 1 byte, then assume this is the
; start of a new response. The single byte is the <CR> that
; brought us to this phase. Do NOT reprocess the <LF>.
;
cmp si, offset responseBuf + 1 ; only > possible
ja exit ; carry clear
dec si ; discard previous <CR>
mov cl, MRS_RECV_RESPONSE
jmp done
notEnd:
;
; The previous <CR> is part of the response. Continue receiving
; the response. Reprocess the current byte in case it may be a <CR>.
;
mov cl, MRS_RECV_RESPONSE
call ResponseDoRecvResponse
done:
stc
exit:
ret
ResponseDoSawEndCR endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ResponseDoSawBeginEcho
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Process the data byte where the "T" or "+" of the start of a
command echo is expected.
CALLED BY: ModemBuildResponse
PASS: al = byte
ds:si = place for data byte in response buffer
cl = MRS_SAW_BEGIN_ECHO
RETURN: cl = next ModemResponseState
ds:si = place for next data byte
carry set
DESTROYED: nothing
PSEUDO CODE/STRATEGY:
If byte is "T" or "+", store it in response buffer and set
state to MRS_RECV_ECHO
else, decrement SI, set state to MRS_NONE and
call ResponseDoNone to reprocess byte
in case it is a <CR>
REVISION HISTORY:
Name Date Description
---- ---- -----------
jwu 8/17/95 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
ResponseDoSawBeginEcho proc near
EC < cmp cl, MRS_SAW_BEGIN_ECHO >
EC < ERROR_NE MODEM_BAD_RESPONSE_STATE >
;
; If "T" or "+", then assume this is a command echo.
;
cmp al, 'T'
je beginEcho
cmp al, '+'
jne startOver
beginEcho:
mov ds:[si], al
inc si
mov cl, MRS_RECV_ECHO
jmp done
startOver:
;
; Discard "A". Reprocess byte in case it's a <CR>.
;
dec si
mov cl, MRS_NONE
call ResponseDoNone
done:
stc
ret
ResponseDoSawBeginEcho endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ResponseDoRecvEcho
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Process the data byte as part of the command echo or
check for the ending <CR>. <CR> is included in response.
CALLED BY: ModemBuildResponse
PASS: al = byte
ds:si = place for data byte in response buffer
es = dgroup
cl = MRS_RECV_ECHO
RETURN: cl = next ModemResponseState
ds:si = place for next data byte
carry clear if a complete echo has been received
DESTROYED: nothing
PSEUDO CODE/STRATEGY:
If buffer will overflow, discard data in buffer and
reprocess byte from start
else store byte
if <CR>, complete response received
NOTE:
Need to check for overflowing response buffer in case
"AT" or "++" happened to be in the input data stream, causing
us to collect the garbage data as a command echo. We will
continue until a <CR> is received if this check is missing.
REVISION HISTORY:
Name Date Description
---- ---- -----------
jwu 8/17/95 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
ResponseDoRecvEcho proc near
EC < cmp cl, MRS_RECV_ECHO >
EC < ERROR_NE MODEM_BAD_RESPONSE_STATE >
;
; Check for possible overflow. No response or echo is long enough
; to overflow the buffer so data must be garbage.
;
CheckHack <offset responseBuf + RESPONSE_BUFFER_SIZE eq offset responseSize>
cmp si, offset responseSize
jb storeByte
EC < WARNING MODEM_CORRECTING_RESPONSE_BUFFER_OVERFLOW >
mov si, offset responseBuf
mov cl, MRS_NONE
call ResponseDoNone
jmp exit
storeByte:
;
; Store byte and check if end of echo.
;
mov ds:[si], al
inc si
cmp al, C_CR
je exit ; carry clear
stc
exit:
ret
ResponseDoRecvEcho endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ModemParseNoConnection
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Look for a CONNECT response, dropping all others.
CALLED BY: ModemReceiveData
PASS: es = dgroup
RETURN: carry clear if CONNECT received
DESTROYED: ax, cx, dx, ds, di, si
PSEUDO CODE/STRATEGY:
if responseSize < CONNECT, don't bother to compare
compare response to CONNECT, if equal return carry clear
REVISION HISTORY:
Name Date Description
---- ---- -----------
jwu 3/20/95 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
ModemParseNoConnection proc near
;
; Is response at least long enough to be CONNECT? CONNECT
; responses may also be followed by the baud rate.
;
mov cx, size responseConnect
cmp cx, es:[responseSize]
ja notFound ; response too short
;
; Compare with CONNECT.
;
push ds
mov di, offset es:[responseBuf] ; es:di = response
segmov ds, cs, si
mov si, offset responseConnect ; ds:si = "CONNECT"
repe cmpsb
pop ds
jnz notFound
;
; Connected. Parse baud rate to generate more specific result.
; Then set driver to data mode.
;
mov ax, MRC_CONNECT
call ModemParseConnectBaud ; ax = MRC_CONNECT_*
EC < Assert etype, ax, ModemResultCode >
mov es:[result], ax
BitClr es:[modemStatus], MS_COMMAND_MODE
BitClr es:[miscStatus], MSS_MODE_UNCERTAIN
clc
jmp exit
notFound:
stc
exit:
ret
ModemParseNoConnection endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ModemParseBasicResponse
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Look for echo of the command, OK or ERROR responses.
Treat any other as an unexpected response, but keep
looking for more.
CALLED BY: ModemReceiveData
PASS: es = dgroup
RETURN: carry clear if OK or ERROR received
DESTROYED: ax, cx, di, si
PSEUDO CODE/STRATEGY:
compare response to OK
if equal, store result as MRC_OK and return carry clear
compare response to ERROR and NO CARRIER
if equal, store result as MRC_ERROR,
reset parser to no connection because the basic
response is for commands issued when there is no
connection yet
return carry clear
check if response is a command
if yes, return carry set
else store result as MRC_UNKNOWN_RESPONSE and return carry set
REVISION HISTORY:
Name Date Description
---- ---- -----------
jwu 3/21/95 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
ModemParseBasicResponse proc near
uses ds
.enter
;
; Check if response is "OK".
;
segmov ds, cs, cx
mov cx, es:[responseSize]
mov di, offset es:[responseBuf] ; es:di = response
cmp cx, size responseOk
jb unknown ; what's less than OK?
mov ax, MRC_OK ; assume OK
push di, cx
mov si, offset responseOk ; ds:si = "OK"
mov cx, size responseOk
repe cmpsb
pop di, cx
jz stopLooking
;
; Check if response is "ERROR" or "NO CARRIER". We let "NO
; CARRIER" be the same as an ERROR because sometimes the
; initialization sequence will result in NO CARRIER (due to
; hangup problems) and we want to respond to that quickly,
; rather then letting the timeout expire.
;
mov ax, MRC_ERROR ; assume ERROR
cmp cx, size responseNoCarrier
jb checkError
push di, cx
mov si, offset responseNoCarrier
mov cx, size responseNoCarrier
repe cmpsb
pop di, cx
jz stopLooking
checkError:
cmp cx, size responseError
jb checkEcho
push di, cx
mov si, offset responseError
mov cx, size responseError
repe cmpsb
pop di, cx
jnz checkEcho
stopLooking:
;
; Reset parser.
;
mov es:[parser], offset ModemParseNoConnection
clc
jmp exit
checkEcho:
;
; Check if response is an echo of the command sent to the modem.
;
call ModemCheckCommandEcho
clr ax ; assume echo
jz keepLooking
unknown:
mov ax, MRC_UNKNOWN_RESPONSE
keepLooking:
stc
exit:
mov es:[result], ax
.leave
ret
ModemParseBasicResponse endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ModemParseEscapeResponse
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Look for echo of the command, OK or ERROR.
The escape sequence is normally the first part of
a two part sequence. If OK is returned, then the
second part will be sent.
CALLED BY: ModemReceiveData
PASS: es = dgroup
RETURN: carry clear for ModmeReceiveData to stop looking
for properly formatted response. (If OK received,
next command is sent.)
DESTROYED: ax, cx, di, si
PSEUDO CODE/STRATEGY:
compare response to OK
if equal, and an escapeSecondCmd is specified, the second
command is sent; else store result as MRC_OK.
Both cases return carry clear to continue waiting.
compare response to NO CARRIER
if equal, will attempt to do same as OK (some cases this
is needed.)
compare response to ERROR
if equal, store result as MRC_ERROR,
reset parser to no connection because the basic
response is for commands issued when there is no
connection yet
return carry clear
check if response is a command echo
if yes, return carry set
else store result as MRC_UNKNOWN_RESPONSE and return carry set
REVISION HISTORY:
Name Date Description
---- ---- -----------
JimG 8/23/99 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
ModemParseEscapeResponse proc near
uses ds, bx
.enter
;
; Check if response is "OK".
;
segmov ds, cs, cx
mov cx, es:[responseSize]
mov di, offset es:[responseBuf] ; es:di = response
cmp cx, size responseOk
LONG jb unknown ; what's less than OK?
mov ax, MRC_OK ; assume OK
push di, cx
mov si, offset responseOk ; ds:si = "OK"
mov cx, size responseOk
repe cmpsb
pop di, cx
jnz checkNoCarrier
;
; We have an OK (or NO CARRIER). The escape sequence was
; (relatively) successful. Stop the timer and send the
; second part of the command, if any.
;
sendSecondCmd:
push ax
clr bx
xchg bx, es:[responseTimer]
tst bx
jz noTimerSet
mov ax, es:[responseTimerID]
call TimerStop
noTimerSet:
pop ax
call ModemSendEscapeSecondCmd
jc stopLooking ; no 2nd cmd or error
jmp keepLooking ; else sent correctly
; Handle no carrier similarly to OK since it is necessary
; sometimes when hanging up.
;
checkNoCarrier:
mov cx, es:[responseSize]
cmp cx, size responseNoCarrier
jb checkError
mov di, offset es:[responseBuf] ; es:di = response
call ModemParseConnectResponse
jc checkError
cmp ax, MRC_NO_CARRIER
je sendSecondCmd
checkError:
;
; Check if response is "ERROR".
;
cmp cx, size responseError
jb checkEcho
mov ax, MRC_ERROR ; assume ERROR
push di, cx
mov si, offset responseError
mov cx, size responseError
repe cmpsb
pop di, cx
jnz checkEcho
stopLooking:
;
; Reset parser.
;
mov es:[parser], offset ModemParseNoConnection
clc
jmp exit
checkEcho:
;
; Check if response is an echo of the command sent to the modem.
;
call ModemCheckCommandEcho
clr ax ; assume echo
jz keepLooking
unknown:
mov ax, MRC_UNKNOWN_RESPONSE
keepLooking:
stc
exit:
mov es:[result], ax
.leave
ret
ModemParseEscapeResponse endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ModemParseDialResponse
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Look for the responses to dialing a phone number.
(command echo, CONNECT, NO CARRIER, ERROR, NO DIALTONE,
NO ANSWER, BUSY) (if virtual serial: BLACKLISTED, DELAYED)
CALLED BY: ModemReceiveData
PASS: es = dgroup
RETURN: carry clear if no further responses are expected
DESTROYED: ax, cx, di, si
PSEUDO CODE/STRATEGY:
look for CONNECT, NO CARRIER, and ERROR first because
these are common responses to ATD and ATA commands
if not found, then try to match the response to NO DIALTONE,
NO ANSWER, BUSY
ifdef virtual serial, try to match response to BLACKLISTED,
DELAYED
finally, check if response is a command echo
if not, set result to MRC_UNKNOWN_RESPONSE
return carry set
Otherwise, carry is clear for everything except a command echo
REVISION HISTORY:
Name Date Description
---- ---- -----------
jwu 3/21/95 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
ModemParseDialResponse proc near
uses ds
.enter
;
; Attempt to match response to a description of the
; connection status: CONNECT, NO CARRIER, ERROR.
;
segmov ds, cs, cx
mov cx, es:[responseSize]
mov di, offset es:[responseBuf]
call ModemParseConnectResponse ; ax = ModemResultCode
LONG jnc done
;
; Attempt to match response to reasons while dialing failed:
; BUSY, NO ANSWER, NO DIALTONE. Process them in order of
; increasing length to stop comparing as soon as length of
; response is less than the response being compared against.
;
cmp cx, size responseOk
jb checkOther
; If we are aborting the dial and we get an OK, it is the equivalent
; of a no carrier -- I don't know why the modem doesn't just give us
; a no carrier.. anyway, check for that case and return NO_CARRIER
; to the client.
;
test es:[modemStatus], mask MS_ABORT_DIAL
jz skipOK
mov ax, MRC_NO_CARRIER
push di, cx
mov si, offset responseOk
mov cx, size responseOk
repe cmpsb
pop di, cx
jz stopLooking
skipOK:
cmp cx, size responseBusy
jb checkOther
mov ax, MRC_BUSY
push di, cx
mov si, offset responseBusy
mov cx, size responseBusy
repe cmpsb
pop di, cx
jz stopLooking
cmp cx, size responseNoAnswer
jb checkOther
mov ax, MRC_NO_ANSWER
push di, cx
mov si, offset responseNoAnswer
mov cx, size responseNoAnswer
repe cmpsb
pop di, cx
jz stopLooking
cmp cx, size responseNoDialtone
jb checkOther
mov ax, MRC_NO_DIALTONE
push di, cx
mov si, offset responseNoDialtone
mov cx, size responseNoDialtone
repe cmpsb
pop di, cx
jnz checkOther
stopLooking:
clc
jmp done
checkOther:
;
; This label defined to leave room for other responses
; that may be specific to a particular product.
;
ifdef VIRTUAL_SERIAL
;
; Virtual serial may also return DELAYED or BLACKLISTED.
;
cmp cx, size responseDelayed
jb doneVSChecks
mov ax, MRC_DELAYED
push di, cx
mov si, offset responseDelayed
mov cx, size responseDelayed
repe cmpsb
pop di, cx
jz stopLooking
cmp cx, size responseBlacklisted
jb doneVSChecks
mov ax, MRC_BLACKLISTED
push di, cx
mov si, offset responseBlacklisted
mov cx, size responseBlacklisted
repe cmpsb
pop di, cx
jz stopLooking
doneVSChecks:
endif
;
; Check if response is a command echo. If not, then the
; response is a mystery.
;
call ModemCheckCommandEcho
clr ax
jz keepLooking
mov ax, MRC_UNKNOWN_RESPONSE
keepLooking:
stc
done:
mov es:[result], ax
.leave
ret
ModemParseDialResponse endp
ifdef HANGUP_LOG
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ModemParseDialResponse
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Write every response to the dial status command to the log.
When we get an OK, close the file and stop reading responses.
CALLED BY: ModemReceiveData
PASS: es = dgroup
RETURN: carry clear if no further responses are expected
DESTROYED: ax, cx, di, si
PSEUDO CODE/STRATEGY:
If response is OK, close log file and return carry clear
If response is not command echo, write it to log file
Return carry set
REVISION HISTORY:
Name Date Description
---- ---- -----------
dhunter 10/12/00 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
ModemParseDialStatusResponse proc near
uses ds, bx, dx
.enter
;
; Check if response is "OK".
;
segmov ds, cs, cx
mov cx, es:[responseSize]
mov di, offset es:[responseBuf] ; es:di = response
cmp cx, size responseOk
LONG jb notOK
mov ax, MRC_OK ; assume OK
push di, cx
mov si, offset responseOk ; ds:si = "OK"
mov cx, size responseOk
repe cmpsb
pop di, cx
jnz notOK
;
; It's OK. Close the file and return carry clear.
;
mov es:[result], ax
segmov ds, es, ax
mov al, FILE_NO_ERRORS
mov bx, es:[logFile]
mov cx, 2
add di, size responseOk
mov dx, di
inc di
mov {byte}es:[di], C_LF
call FileWrite
mov al, FILE_NO_ERRORS
call FileClose
clc
jmp done
;
; Check if it's a command echo.
;
notOK:
call ModemCheckCommandEcho
jz doneMore
;
; It's another status line. Write it to the log and return
; carry set.
;
segmov ds, es, ax
mov al, FILE_NO_ERRORS
mov bx, es:[logFile]
mov cx, es:[responseSize]
mov dx, offset es:[responseBuf] ; ds:dx = response
mov si, dx
add si, cx
mov {byte}ds:[si], C_LF
inc si
inc cx
call FileWrite
doneMore:
stc
done:
.leave
ret
ModemParseDialStatusResponse endp
endif
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ModemParseAnswerCallResponse
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Look for the response to answering an incoming call.
(command echo, CONNECT, NO CARRIER, ERROR)
CALLED BY: ModemReceiveData
PASS: es = dgroup
RETURN: carry clear if no further responses are expected
DESTROYED: ax, cx, di, si
PSEUDO CODE/STRATEGY:
Look for CONNECT, ERROR, NO CARRIER
if found, store result and return carry clear
else, look for command echo
if not found, response is unknown
return carry set
REVISION HISTORY:
Name Date Description
---- ---- -----------
jwu 3/21/95 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
ModemParseAnswerCallResponse proc near
uses ds
.enter
;
; Attempt to match response to a description of the connection
; status: CONNECT, NO CARRIER, ERROR.
;
segmov ds, cs, cx
mov cx, es:[responseSize]
mov di, offset es:[responseBuf]
call ModemParseConnectResponse ; ax = ModemResultCode
jnc done
;
; Check if response is a command echo. If not, then response
; is a mystery. Store result, but keep looking for a response.
;
call ModemCheckCommandEcho
clr ax
jz keepLooking
mov ax, MRC_UNKNOWN_RESPONSE
keepLooking:
stc
done:
mov es:[result], ax
.leave
ret
ModemParseAnswerCallResponse endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ModemParseConnectResponse
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Match the response against those that describe the status
of a connection: CONNECT, NO CARRIER or ERROR.
CALLED BY: ModemParseDialResponse
ModemParseAnswerCallResponse
PASS: es:di = response (in dgroup)
cx = size of response
RETURN: carry set if no match
else
ax = ModemResultCode
DESTROYED: si (ax if not returned)
PSEUDO CODE/STRATEGY:
Check the responses in increasing order of length so
the we can stop comparing as soon as the response
is too short for a response, plus carry will be set
for us by the cmp instruction.
REVISION HISTORY:
Name Date Description
---- ---- -----------
jwu 3/21/95 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
ModemParseConnectResponse proc near
uses cx, di
.enter
cmp cx, size responseError
jb exit
mov ax, MRC_ERROR
push di, cx
mov si, offset responseError
mov cx, size responseError
repe cmpsb
pop di, cx
jz found
cmp cx, size responseConnect
jb exit
;
; If connected, take state out of command mode.
;
mov ax, MRC_CONNECT
push di, cx
mov si, offset responseConnect
mov cx, size responseConnect
repe cmpsb
mov si, di
pop di, cx
jnz checkCarrier
mov di, si
call ModemParseConnectBaud ; ax = MRC_CONNECT_*
BitClr es:[modemStatus], MS_COMMAND_MODE
BitClr es:[miscStatus], MSS_MODE_UNCERTAIN
jmp found
checkCarrier:
cmp cx, size responseNoCarrier
jb exit
mov ax, MRC_NO_CARRIER
mov si, offset responseNoCarrier
mov cx, size responseNoCarrier
repe cmpsb
stc ; expect the worst...
jnz exit
found:
clc
exit:
.leave
ret
ModemParseConnectResponse endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ModemParseConnectBaud
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Look for the baud rate string after a CONNECT response, if
any, to determine what baud rate the modem is using.
CALLED BY: ModemParseNoConnection
ModemParseConnectResponse
PASS: es:di = byte after CONNECT in response buffer
ax = MRC_CONNECT
RETURN: ax = MRC_CONNECT_* where * is baud rate
DESTROYED: cx, dx, di
PSEUDO CODE/STRATEGY:
if (responseSize - size of CONNECT) > 0
look for a space followed by an ascii decimal string
convert ascii to integer
map to appropriate ModemResultCode
else
return MRC_CONNECT
REVISION HISTORY:
Name Date Description
---- ---- -----------
jwu 3/21/95 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
ModemParseConnectBaud proc near
;
; If there is no data after the CONNECT, then don't bother
; looking for a baud rate.
;
mov cx, es:[responseSize]
sub cx, size responseConnect ; cx = remaining data
jcxz exit
;
; Advance pointer past the space and then convert the ascii number
; to an unsigned integer.
;
EC < cmp {byte}es:[di], C_SPACE >
EC < WARNING_NE UNUSUAL_CONNECT_RESPONSE_FORMAT >
inc di
dec cx ; cx = # chars in number
call ModemBaudToUnsignedInt ; ax = number
;
; save the baud rate
;
mov es:[baudRate], ax
;
; Map the number to a ModemResultCode.
;
cmp ax, 1200
jne try2400
mov ax, MRC_CONNECT_1200
jmp exit
try2400:
cmp ax, 2400
jne try4800
mov ax, MRC_CONNECT_2400
jmp exit
try4800:
cmp ax, 4800
jne try9600
mov ax, MRC_CONNECT_4800
jmp exit
try9600:
cmp ax, 9600
jne noBaud
mov ax, MRC_CONNECT_9600
jmp exit
noBaud:
mov ax, MRC_CONNECT
exit:
ret
ModemParseConnectBaud endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ModemBaudToUnsignedInt
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Convert an ASCII number to an unsigned value.
CALLED BY: ModemParseConnectBaud
PASS: es:di = ASCII string (not null-terminated)
cx = # of chars in ASCII string
RETURN: ax = number
DESTROYED: cx, dx, di
REVISION HISTORY:
Name Date Description
---- ---- -----------
jwu 3/21/95 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
ModemBaudToUnsignedInt proc near
clr ax
digit:
clr dx
mov dl, es:[di]
sub dl, '0'
jb done
cmp dl, 9
ja done
inc di
push dx
mov dx, 10
mul dx
pop dx
jc overflow
add ax, dx
jc overflow
loop digit
done:
ret
overflow:
EC < WARNING MODEM_BAUD_RATE_TOO_BIG >
clr ax ; use no baud rate
jmp done
ModemBaudToUnsignedInt endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ModemCheckCommandEcho
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Check if the response is an echo of the command sent
to the modem.
CALLED BY: ModemParseBasicResponse
ModemParseDialResponse
ModemParseAnswerCallResponse
PASS: es:di = response
RETURN: Z flag set if response is a command echo
DESTROYED: ax
PSEUDO CODE/STRATEGY:
No modem responses begin with "AT" so look
for these at the start of the response.
REVISION HISTORY:
Name Date Description
---- ---- -----------
jwu 3/21/95 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
ModemCheckCommandEcho proc near
;
; Look for 'AT' as first two characters of response.
;
mov ax, es:[di] ; AL = 1st char, AH = 2nd char
cmp al, 'A'
jne checkEsc
cmp ah, 'T' ; Z flag set if equal
jmp exit
checkEsc:
;
; Modem might also be echoing '+++' escape sequence. No normal
; responses begin with '+' so checking first character is enough.
;
cmp al, '+' ; Z flag set if equal
exit:
ret
ModemCheckCommandEcho endp
CommonCode ends
|
bin/kernel_nopage: file format elf32-i386
Disassembly of section .text:
00100000 <kern_entry>:
.text
.globl kern_entry
kern_entry:
# reload temperate gdt (second time) to remap all physical memory
# virtual_addr 0~4G=linear_addr&physical_addr -KERNBASE~4G-KERNBASE
lgdt REALLOC(__gdtdesc)
100000: 0f 01 15 18 90 11 40 lgdtl 0x40119018
movl $KERNEL_DS, %eax
100007: b8 10 00 00 00 mov $0x10,%eax
movw %ax, %ds
10000c: 8e d8 mov %eax,%ds
movw %ax, %es
10000e: 8e c0 mov %eax,%es
movw %ax, %ss
100010: 8e d0 mov %eax,%ss
ljmp $KERNEL_CS, $relocated
100012: ea 19 00 10 00 08 00 ljmp $0x8,$0x100019
00100019 <relocated>:
relocated:
# set ebp, esp
movl $0x0, %ebp
100019: bd 00 00 00 00 mov $0x0,%ebp
# the kernel stack region is from bootstack -- bootstacktop,
# the kernel stack size is KSTACKSIZE (8KB)defined in memlayout.h
movl $bootstacktop, %esp
10001e: bc 00 90 11 00 mov $0x119000,%esp
# now kernel stack is ready , call the first C function
call kern_init
100023: e8 02 00 00 00 call 10002a <kern_init>
00100028 <spin>:
# should never get here
spin:
jmp spin
100028: eb fe jmp 100028 <spin>
0010002a <kern_init>:
int kern_init(void) __attribute__((noreturn));
void grade_backtrace(void);
static void lab1_switch_test(void);
int
kern_init(void) {
10002a: 55 push %ebp
10002b: 89 e5 mov %esp,%ebp
10002d: 83 ec 18 sub $0x18,%esp
extern char edata[], end[];
memset(edata, 0, end - edata);
100030: ba 74 a9 11 00 mov $0x11a974,%edx
100035: b8 36 9a 11 00 mov $0x119a36,%eax
10003a: 29 c2 sub %eax,%edx
10003c: 89 d0 mov %edx,%eax
10003e: 83 ec 04 sub $0x4,%esp
100041: 50 push %eax
100042: 6a 00 push $0x0
100044: 68 36 9a 11 00 push $0x119a36
100049: e8 19 61 00 00 call 106167 <memset>
10004e: 83 c4 10 add $0x10,%esp
cons_init(); // init the console
100051: e8 55 15 00 00 call 1015ab <cons_init>
const char *message = "(THU.CST) os is loading ...";
100056: c7 45 f4 00 69 10 00 movl $0x106900,-0xc(%ebp)
cprintf("%s\n\n", message);
10005d: 83 ec 08 sub $0x8,%esp
100060: ff 75 f4 pushl -0xc(%ebp)
100063: 68 1c 69 10 00 push $0x10691c
100068: e8 fa 01 00 00 call 100267 <cprintf>
10006d: 83 c4 10 add $0x10,%esp
print_kerninfo();
100070: e8 7c 08 00 00 call 1008f1 <print_kerninfo>
grade_backtrace();
100075: e8 74 00 00 00 call 1000ee <grade_backtrace>
pmm_init(); // init physical memory management
10007a: e8 24 33 00 00 call 1033a3 <pmm_init>
pic_init(); // init interrupt controller
10007f: e8 99 16 00 00 call 10171d <pic_init>
idt_init(); // init interrupt descriptor table
100084: e8 1b 18 00 00 call 1018a4 <idt_init>
clock_init(); // init clock interrupt
100089: e8 c4 0c 00 00 call 100d52 <clock_init>
intr_enable(); // enable irq interrupt
10008e: e8 c7 17 00 00 call 10185a <intr_enable>
//LAB1: CAHLLENGE 1 If you try to do it, uncomment lab1_switch_test()
// user/kernel mode switch test
//lab1_switch_test();
/* do nothing */
while (1);
100093: eb fe jmp 100093 <kern_init+0x69>
00100095 <grade_backtrace2>:
}
void __attribute__((noinline))
grade_backtrace2(int arg0, int arg1, int arg2, int arg3) {
100095: 55 push %ebp
100096: 89 e5 mov %esp,%ebp
100098: 83 ec 08 sub $0x8,%esp
mon_backtrace(0, NULL, NULL);
10009b: 83 ec 04 sub $0x4,%esp
10009e: 6a 00 push $0x0
1000a0: 6a 00 push $0x0
1000a2: 6a 00 push $0x0
1000a4: e8 97 0c 00 00 call 100d40 <mon_backtrace>
1000a9: 83 c4 10 add $0x10,%esp
}
1000ac: 90 nop
1000ad: c9 leave
1000ae: c3 ret
001000af <grade_backtrace1>:
void __attribute__((noinline))
grade_backtrace1(int arg0, int arg1) {
1000af: 55 push %ebp
1000b0: 89 e5 mov %esp,%ebp
1000b2: 53 push %ebx
1000b3: 83 ec 04 sub $0x4,%esp
grade_backtrace2(arg0, (int)&arg0, arg1, (int)&arg1);
1000b6: 8d 4d 0c lea 0xc(%ebp),%ecx
1000b9: 8b 55 0c mov 0xc(%ebp),%edx
1000bc: 8d 5d 08 lea 0x8(%ebp),%ebx
1000bf: 8b 45 08 mov 0x8(%ebp),%eax
1000c2: 51 push %ecx
1000c3: 52 push %edx
1000c4: 53 push %ebx
1000c5: 50 push %eax
1000c6: e8 ca ff ff ff call 100095 <grade_backtrace2>
1000cb: 83 c4 10 add $0x10,%esp
}
1000ce: 90 nop
1000cf: 8b 5d fc mov -0x4(%ebp),%ebx
1000d2: c9 leave
1000d3: c3 ret
001000d4 <grade_backtrace0>:
void __attribute__((noinline))
grade_backtrace0(int arg0, int arg1, int arg2) {
1000d4: 55 push %ebp
1000d5: 89 e5 mov %esp,%ebp
1000d7: 83 ec 08 sub $0x8,%esp
grade_backtrace1(arg0, arg2);
1000da: 83 ec 08 sub $0x8,%esp
1000dd: ff 75 10 pushl 0x10(%ebp)
1000e0: ff 75 08 pushl 0x8(%ebp)
1000e3: e8 c7 ff ff ff call 1000af <grade_backtrace1>
1000e8: 83 c4 10 add $0x10,%esp
}
1000eb: 90 nop
1000ec: c9 leave
1000ed: c3 ret
001000ee <grade_backtrace>:
void
grade_backtrace(void) {
1000ee: 55 push %ebp
1000ef: 89 e5 mov %esp,%ebp
1000f1: 83 ec 08 sub $0x8,%esp
grade_backtrace0(0, (int)kern_init, 0xffff0000);
1000f4: b8 2a 00 10 00 mov $0x10002a,%eax
1000f9: 83 ec 04 sub $0x4,%esp
1000fc: 68 00 00 ff ff push $0xffff0000
100101: 50 push %eax
100102: 6a 00 push $0x0
100104: e8 cb ff ff ff call 1000d4 <grade_backtrace0>
100109: 83 c4 10 add $0x10,%esp
}
10010c: 90 nop
10010d: c9 leave
10010e: c3 ret
0010010f <lab1_print_cur_status>:
static void
lab1_print_cur_status(void) {
10010f: 55 push %ebp
100110: 89 e5 mov %esp,%ebp
100112: 83 ec 18 sub $0x18,%esp
static int round = 0;
uint16_t reg1, reg2, reg3, reg4;
asm volatile (
100115: 8c 4d f6 mov %cs,-0xa(%ebp)
100118: 8c 5d f4 mov %ds,-0xc(%ebp)
10011b: 8c 45 f2 mov %es,-0xe(%ebp)
10011e: 8c 55 f0 mov %ss,-0x10(%ebp)
"mov %%cs, %0;"
"mov %%ds, %1;"
"mov %%es, %2;"
"mov %%ss, %3;"
: "=m"(reg1), "=m"(reg2), "=m"(reg3), "=m"(reg4));
cprintf("%d: @ring %d\n", round, reg1 & 3);
100121: 0f b7 45 f6 movzwl -0xa(%ebp),%eax
100125: 0f b7 c0 movzwl %ax,%eax
100128: 83 e0 03 and $0x3,%eax
10012b: 89 c2 mov %eax,%edx
10012d: a1 40 9a 11 00 mov 0x119a40,%eax
100132: 83 ec 04 sub $0x4,%esp
100135: 52 push %edx
100136: 50 push %eax
100137: 68 21 69 10 00 push $0x106921
10013c: e8 26 01 00 00 call 100267 <cprintf>
100141: 83 c4 10 add $0x10,%esp
cprintf("%d: cs = %x\n", round, reg1);
100144: 0f b7 45 f6 movzwl -0xa(%ebp),%eax
100148: 0f b7 d0 movzwl %ax,%edx
10014b: a1 40 9a 11 00 mov 0x119a40,%eax
100150: 83 ec 04 sub $0x4,%esp
100153: 52 push %edx
100154: 50 push %eax
100155: 68 2f 69 10 00 push $0x10692f
10015a: e8 08 01 00 00 call 100267 <cprintf>
10015f: 83 c4 10 add $0x10,%esp
cprintf("%d: ds = %x\n", round, reg2);
100162: 0f b7 45 f4 movzwl -0xc(%ebp),%eax
100166: 0f b7 d0 movzwl %ax,%edx
100169: a1 40 9a 11 00 mov 0x119a40,%eax
10016e: 83 ec 04 sub $0x4,%esp
100171: 52 push %edx
100172: 50 push %eax
100173: 68 3d 69 10 00 push $0x10693d
100178: e8 ea 00 00 00 call 100267 <cprintf>
10017d: 83 c4 10 add $0x10,%esp
cprintf("%d: es = %x\n", round, reg3);
100180: 0f b7 45 f2 movzwl -0xe(%ebp),%eax
100184: 0f b7 d0 movzwl %ax,%edx
100187: a1 40 9a 11 00 mov 0x119a40,%eax
10018c: 83 ec 04 sub $0x4,%esp
10018f: 52 push %edx
100190: 50 push %eax
100191: 68 4b 69 10 00 push $0x10694b
100196: e8 cc 00 00 00 call 100267 <cprintf>
10019b: 83 c4 10 add $0x10,%esp
cprintf("%d: ss = %x\n", round, reg4);
10019e: 0f b7 45 f0 movzwl -0x10(%ebp),%eax
1001a2: 0f b7 d0 movzwl %ax,%edx
1001a5: a1 40 9a 11 00 mov 0x119a40,%eax
1001aa: 83 ec 04 sub $0x4,%esp
1001ad: 52 push %edx
1001ae: 50 push %eax
1001af: 68 59 69 10 00 push $0x106959
1001b4: e8 ae 00 00 00 call 100267 <cprintf>
1001b9: 83 c4 10 add $0x10,%esp
round ++;
1001bc: a1 40 9a 11 00 mov 0x119a40,%eax
1001c1: 83 c0 01 add $0x1,%eax
1001c4: a3 40 9a 11 00 mov %eax,0x119a40
}
1001c9: 90 nop
1001ca: c9 leave
1001cb: c3 ret
001001cc <lab1_switch_to_user>:
static void
lab1_switch_to_user(void) {
1001cc: 55 push %ebp
1001cd: 89 e5 mov %esp,%ebp
//LAB1 CHALLENGE 1 : TODO
}
1001cf: 90 nop
1001d0: 5d pop %ebp
1001d1: c3 ret
001001d2 <lab1_switch_to_kernel>:
static void
lab1_switch_to_kernel(void) {
1001d2: 55 push %ebp
1001d3: 89 e5 mov %esp,%ebp
//LAB1 CHALLENGE 1 : TODO
}
1001d5: 90 nop
1001d6: 5d pop %ebp
1001d7: c3 ret
001001d8 <lab1_switch_test>:
static void
lab1_switch_test(void) {
1001d8: 55 push %ebp
1001d9: 89 e5 mov %esp,%ebp
1001db: 83 ec 08 sub $0x8,%esp
lab1_print_cur_status();
1001de: e8 2c ff ff ff call 10010f <lab1_print_cur_status>
cprintf("+++ switch to user mode +++\n");
1001e3: 83 ec 0c sub $0xc,%esp
1001e6: 68 68 69 10 00 push $0x106968
1001eb: e8 77 00 00 00 call 100267 <cprintf>
1001f0: 83 c4 10 add $0x10,%esp
lab1_switch_to_user();
1001f3: e8 d4 ff ff ff call 1001cc <lab1_switch_to_user>
lab1_print_cur_status();
1001f8: e8 12 ff ff ff call 10010f <lab1_print_cur_status>
cprintf("+++ switch to kernel mode +++\n");
1001fd: 83 ec 0c sub $0xc,%esp
100200: 68 88 69 10 00 push $0x106988
100205: e8 5d 00 00 00 call 100267 <cprintf>
10020a: 83 c4 10 add $0x10,%esp
lab1_switch_to_kernel();
10020d: e8 c0 ff ff ff call 1001d2 <lab1_switch_to_kernel>
lab1_print_cur_status();
100212: e8 f8 fe ff ff call 10010f <lab1_print_cur_status>
}
100217: 90 nop
100218: c9 leave
100219: c3 ret
0010021a <cputch>:
/* *
* cputch - writes a single character @c to stdout, and it will
* increace the value of counter pointed by @cnt.
* */
static void
cputch(int c, int *cnt) {
10021a: 55 push %ebp
10021b: 89 e5 mov %esp,%ebp
10021d: 83 ec 08 sub $0x8,%esp
cons_putc(c);
100220: 83 ec 0c sub $0xc,%esp
100223: ff 75 08 pushl 0x8(%ebp)
100226: e8 b1 13 00 00 call 1015dc <cons_putc>
10022b: 83 c4 10 add $0x10,%esp
(*cnt) ++;
10022e: 8b 45 0c mov 0xc(%ebp),%eax
100231: 8b 00 mov (%eax),%eax
100233: 8d 50 01 lea 0x1(%eax),%edx
100236: 8b 45 0c mov 0xc(%ebp),%eax
100239: 89 10 mov %edx,(%eax)
}
10023b: 90 nop
10023c: c9 leave
10023d: c3 ret
0010023e <vcprintf>:
*
* Call this function if you are already dealing with a va_list.
* Or you probably want cprintf() instead.
* */
int
vcprintf(const char *fmt, va_list ap) {
10023e: 55 push %ebp
10023f: 89 e5 mov %esp,%ebp
100241: 83 ec 18 sub $0x18,%esp
int cnt = 0;
100244: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp)
vprintfmt((void*)cputch, &cnt, fmt, ap);
10024b: ff 75 0c pushl 0xc(%ebp)
10024e: ff 75 08 pushl 0x8(%ebp)
100251: 8d 45 f4 lea -0xc(%ebp),%eax
100254: 50 push %eax
100255: 68 1a 02 10 00 push $0x10021a
10025a: e8 3e 62 00 00 call 10649d <vprintfmt>
10025f: 83 c4 10 add $0x10,%esp
return cnt;
100262: 8b 45 f4 mov -0xc(%ebp),%eax
}
100265: c9 leave
100266: c3 ret
00100267 <cprintf>:
*
* The return value is the number of characters which would be
* written to stdout.
* */
int
cprintf(const char *fmt, ...) {
100267: 55 push %ebp
100268: 89 e5 mov %esp,%ebp
10026a: 83 ec 18 sub $0x18,%esp
va_list ap;
int cnt;
va_start(ap, fmt);
10026d: 8d 45 0c lea 0xc(%ebp),%eax
100270: 89 45 f0 mov %eax,-0x10(%ebp)
cnt = vcprintf(fmt, ap);
100273: 8b 45 f0 mov -0x10(%ebp),%eax
100276: 83 ec 08 sub $0x8,%esp
100279: 50 push %eax
10027a: ff 75 08 pushl 0x8(%ebp)
10027d: e8 bc ff ff ff call 10023e <vcprintf>
100282: 83 c4 10 add $0x10,%esp
100285: 89 45 f4 mov %eax,-0xc(%ebp)
va_end(ap);
return cnt;
100288: 8b 45 f4 mov -0xc(%ebp),%eax
}
10028b: c9 leave
10028c: c3 ret
0010028d <cputchar>:
/* cputchar - writes a single character to stdout */
void
cputchar(int c) {
10028d: 55 push %ebp
10028e: 89 e5 mov %esp,%ebp
100290: 83 ec 08 sub $0x8,%esp
cons_putc(c);
100293: 83 ec 0c sub $0xc,%esp
100296: ff 75 08 pushl 0x8(%ebp)
100299: e8 3e 13 00 00 call 1015dc <cons_putc>
10029e: 83 c4 10 add $0x10,%esp
}
1002a1: 90 nop
1002a2: c9 leave
1002a3: c3 ret
001002a4 <cputs>:
/* *
* cputs- writes the string pointed by @str to stdout and
* appends a newline character.
* */
int
cputs(const char *str) {
1002a4: 55 push %ebp
1002a5: 89 e5 mov %esp,%ebp
1002a7: 83 ec 18 sub $0x18,%esp
int cnt = 0;
1002aa: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp)
char c;
while ((c = *str ++) != '\0') {
1002b1: eb 14 jmp 1002c7 <cputs+0x23>
cputch(c, &cnt);
1002b3: 0f be 45 f7 movsbl -0x9(%ebp),%eax
1002b7: 83 ec 08 sub $0x8,%esp
1002ba: 8d 55 f0 lea -0x10(%ebp),%edx
1002bd: 52 push %edx
1002be: 50 push %eax
1002bf: e8 56 ff ff ff call 10021a <cputch>
1002c4: 83 c4 10 add $0x10,%esp
* */
int
cputs(const char *str) {
int cnt = 0;
char c;
while ((c = *str ++) != '\0') {
1002c7: 8b 45 08 mov 0x8(%ebp),%eax
1002ca: 8d 50 01 lea 0x1(%eax),%edx
1002cd: 89 55 08 mov %edx,0x8(%ebp)
1002d0: 0f b6 00 movzbl (%eax),%eax
1002d3: 88 45 f7 mov %al,-0x9(%ebp)
1002d6: 80 7d f7 00 cmpb $0x0,-0x9(%ebp)
1002da: 75 d7 jne 1002b3 <cputs+0xf>
cputch(c, &cnt);
}
cputch('\n', &cnt);
1002dc: 83 ec 08 sub $0x8,%esp
1002df: 8d 45 f0 lea -0x10(%ebp),%eax
1002e2: 50 push %eax
1002e3: 6a 0a push $0xa
1002e5: e8 30 ff ff ff call 10021a <cputch>
1002ea: 83 c4 10 add $0x10,%esp
return cnt;
1002ed: 8b 45 f0 mov -0x10(%ebp),%eax
}
1002f0: c9 leave
1002f1: c3 ret
001002f2 <getchar>:
/* getchar - reads a single non-zero character from stdin */
int
getchar(void) {
1002f2: 55 push %ebp
1002f3: 89 e5 mov %esp,%ebp
1002f5: 83 ec 18 sub $0x18,%esp
int c;
while ((c = cons_getc()) == 0)
1002f8: e8 28 13 00 00 call 101625 <cons_getc>
1002fd: 89 45 f4 mov %eax,-0xc(%ebp)
100300: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
100304: 74 f2 je 1002f8 <getchar+0x6>
/* do nothing */;
return c;
100306: 8b 45 f4 mov -0xc(%ebp),%eax
}
100309: c9 leave
10030a: c3 ret
0010030b <readline>:
* The readline() function returns the text of the line read. If some errors
* are happened, NULL is returned. The return value is a global variable,
* thus it should be copied before it is used.
* */
char *
readline(const char *prompt) {
10030b: 55 push %ebp
10030c: 89 e5 mov %esp,%ebp
10030e: 83 ec 18 sub $0x18,%esp
if (prompt != NULL) {
100311: 83 7d 08 00 cmpl $0x0,0x8(%ebp)
100315: 74 13 je 10032a <readline+0x1f>
cprintf("%s", prompt);
100317: 83 ec 08 sub $0x8,%esp
10031a: ff 75 08 pushl 0x8(%ebp)
10031d: 68 a7 69 10 00 push $0x1069a7
100322: e8 40 ff ff ff call 100267 <cprintf>
100327: 83 c4 10 add $0x10,%esp
}
int i = 0, c;
10032a: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp)
while (1) {
c = getchar();
100331: e8 bc ff ff ff call 1002f2 <getchar>
100336: 89 45 f0 mov %eax,-0x10(%ebp)
if (c < 0) {
100339: 83 7d f0 00 cmpl $0x0,-0x10(%ebp)
10033d: 79 0a jns 100349 <readline+0x3e>
return NULL;
10033f: b8 00 00 00 00 mov $0x0,%eax
100344: e9 82 00 00 00 jmp 1003cb <readline+0xc0>
}
else if (c >= ' ' && i < BUFSIZE - 1) {
100349: 83 7d f0 1f cmpl $0x1f,-0x10(%ebp)
10034d: 7e 2b jle 10037a <readline+0x6f>
10034f: 81 7d f4 fe 03 00 00 cmpl $0x3fe,-0xc(%ebp)
100356: 7f 22 jg 10037a <readline+0x6f>
cputchar(c);
100358: 83 ec 0c sub $0xc,%esp
10035b: ff 75 f0 pushl -0x10(%ebp)
10035e: e8 2a ff ff ff call 10028d <cputchar>
100363: 83 c4 10 add $0x10,%esp
buf[i ++] = c;
100366: 8b 45 f4 mov -0xc(%ebp),%eax
100369: 8d 50 01 lea 0x1(%eax),%edx
10036c: 89 55 f4 mov %edx,-0xc(%ebp)
10036f: 8b 55 f0 mov -0x10(%ebp),%edx
100372: 88 90 60 9a 11 00 mov %dl,0x119a60(%eax)
100378: eb 4c jmp 1003c6 <readline+0xbb>
}
else if (c == '\b' && i > 0) {
10037a: 83 7d f0 08 cmpl $0x8,-0x10(%ebp)
10037e: 75 1a jne 10039a <readline+0x8f>
100380: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
100384: 7e 14 jle 10039a <readline+0x8f>
cputchar(c);
100386: 83 ec 0c sub $0xc,%esp
100389: ff 75 f0 pushl -0x10(%ebp)
10038c: e8 fc fe ff ff call 10028d <cputchar>
100391: 83 c4 10 add $0x10,%esp
i --;
100394: 83 6d f4 01 subl $0x1,-0xc(%ebp)
100398: eb 2c jmp 1003c6 <readline+0xbb>
}
else if (c == '\n' || c == '\r') {
10039a: 83 7d f0 0a cmpl $0xa,-0x10(%ebp)
10039e: 74 06 je 1003a6 <readline+0x9b>
1003a0: 83 7d f0 0d cmpl $0xd,-0x10(%ebp)
1003a4: 75 8b jne 100331 <readline+0x26>
cputchar(c);
1003a6: 83 ec 0c sub $0xc,%esp
1003a9: ff 75 f0 pushl -0x10(%ebp)
1003ac: e8 dc fe ff ff call 10028d <cputchar>
1003b1: 83 c4 10 add $0x10,%esp
buf[i] = '\0';
1003b4: 8b 45 f4 mov -0xc(%ebp),%eax
1003b7: 05 60 9a 11 00 add $0x119a60,%eax
1003bc: c6 00 00 movb $0x0,(%eax)
return buf;
1003bf: b8 60 9a 11 00 mov $0x119a60,%eax
1003c4: eb 05 jmp 1003cb <readline+0xc0>
}
}
1003c6: e9 66 ff ff ff jmp 100331 <readline+0x26>
}
1003cb: c9 leave
1003cc: c3 ret
001003cd <__panic>:
/* *
* __panic - __panic is called on unresolvable fatal errors. it prints
* "panic: 'message'", and then enters the kernel monitor.
* */
void
__panic(const char *file, int line, const char *fmt, ...) {
1003cd: 55 push %ebp
1003ce: 89 e5 mov %esp,%ebp
1003d0: 83 ec 18 sub $0x18,%esp
if (is_panic) {
1003d3: a1 60 9e 11 00 mov 0x119e60,%eax
1003d8: 85 c0 test %eax,%eax
1003da: 75 4a jne 100426 <__panic+0x59>
goto panic_dead;
}
is_panic = 1;
1003dc: c7 05 60 9e 11 00 01 movl $0x1,0x119e60
1003e3: 00 00 00
// print the 'message'
va_list ap;
va_start(ap, fmt);
1003e6: 8d 45 14 lea 0x14(%ebp),%eax
1003e9: 89 45 f4 mov %eax,-0xc(%ebp)
cprintf("kernel panic at %s:%d:\n ", file, line);
1003ec: 83 ec 04 sub $0x4,%esp
1003ef: ff 75 0c pushl 0xc(%ebp)
1003f2: ff 75 08 pushl 0x8(%ebp)
1003f5: 68 aa 69 10 00 push $0x1069aa
1003fa: e8 68 fe ff ff call 100267 <cprintf>
1003ff: 83 c4 10 add $0x10,%esp
vcprintf(fmt, ap);
100402: 8b 45 f4 mov -0xc(%ebp),%eax
100405: 83 ec 08 sub $0x8,%esp
100408: 50 push %eax
100409: ff 75 10 pushl 0x10(%ebp)
10040c: e8 2d fe ff ff call 10023e <vcprintf>
100411: 83 c4 10 add $0x10,%esp
cprintf("\n");
100414: 83 ec 0c sub $0xc,%esp
100417: 68 c6 69 10 00 push $0x1069c6
10041c: e8 46 fe ff ff call 100267 <cprintf>
100421: 83 c4 10 add $0x10,%esp
100424: eb 01 jmp 100427 <__panic+0x5a>
* "panic: 'message'", and then enters the kernel monitor.
* */
void
__panic(const char *file, int line, const char *fmt, ...) {
if (is_panic) {
goto panic_dead;
100426: 90 nop
vcprintf(fmt, ap);
cprintf("\n");
va_end(ap);
panic_dead:
intr_disable();
100427: e8 35 14 00 00 call 101861 <intr_disable>
while (1) {
kmonitor(NULL);
10042c: 83 ec 0c sub $0xc,%esp
10042f: 6a 00 push $0x0
100431: e8 30 08 00 00 call 100c66 <kmonitor>
100436: 83 c4 10 add $0x10,%esp
}
100439: eb f1 jmp 10042c <__panic+0x5f>
0010043b <__warn>:
}
/* __warn - like panic, but don't */
void
__warn(const char *file, int line, const char *fmt, ...) {
10043b: 55 push %ebp
10043c: 89 e5 mov %esp,%ebp
10043e: 83 ec 18 sub $0x18,%esp
va_list ap;
va_start(ap, fmt);
100441: 8d 45 14 lea 0x14(%ebp),%eax
100444: 89 45 f4 mov %eax,-0xc(%ebp)
cprintf("kernel warning at %s:%d:\n ", file, line);
100447: 83 ec 04 sub $0x4,%esp
10044a: ff 75 0c pushl 0xc(%ebp)
10044d: ff 75 08 pushl 0x8(%ebp)
100450: 68 c8 69 10 00 push $0x1069c8
100455: e8 0d fe ff ff call 100267 <cprintf>
10045a: 83 c4 10 add $0x10,%esp
vcprintf(fmt, ap);
10045d: 8b 45 f4 mov -0xc(%ebp),%eax
100460: 83 ec 08 sub $0x8,%esp
100463: 50 push %eax
100464: ff 75 10 pushl 0x10(%ebp)
100467: e8 d2 fd ff ff call 10023e <vcprintf>
10046c: 83 c4 10 add $0x10,%esp
cprintf("\n");
10046f: 83 ec 0c sub $0xc,%esp
100472: 68 c6 69 10 00 push $0x1069c6
100477: e8 eb fd ff ff call 100267 <cprintf>
10047c: 83 c4 10 add $0x10,%esp
va_end(ap);
}
10047f: 90 nop
100480: c9 leave
100481: c3 ret
00100482 <is_kernel_panic>:
bool
is_kernel_panic(void) {
100482: 55 push %ebp
100483: 89 e5 mov %esp,%ebp
return is_panic;
100485: a1 60 9e 11 00 mov 0x119e60,%eax
}
10048a: 5d pop %ebp
10048b: c3 ret
0010048c <stab_binsearch>:
* stab_binsearch(stabs, &left, &right, N_SO, 0xf0100184);
* will exit setting left = 118, right = 554.
* */
static void
stab_binsearch(const struct stab *stabs, int *region_left, int *region_right,
int type, uintptr_t addr) {
10048c: 55 push %ebp
10048d: 89 e5 mov %esp,%ebp
10048f: 83 ec 20 sub $0x20,%esp
int l = *region_left, r = *region_right, any_matches = 0;
100492: 8b 45 0c mov 0xc(%ebp),%eax
100495: 8b 00 mov (%eax),%eax
100497: 89 45 fc mov %eax,-0x4(%ebp)
10049a: 8b 45 10 mov 0x10(%ebp),%eax
10049d: 8b 00 mov (%eax),%eax
10049f: 89 45 f8 mov %eax,-0x8(%ebp)
1004a2: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp)
while (l <= r) {
1004a9: e9 d2 00 00 00 jmp 100580 <stab_binsearch+0xf4>
int true_m = (l + r) / 2, m = true_m;
1004ae: 8b 55 fc mov -0x4(%ebp),%edx
1004b1: 8b 45 f8 mov -0x8(%ebp),%eax
1004b4: 01 d0 add %edx,%eax
1004b6: 89 c2 mov %eax,%edx
1004b8: c1 ea 1f shr $0x1f,%edx
1004bb: 01 d0 add %edx,%eax
1004bd: d1 f8 sar %eax
1004bf: 89 45 ec mov %eax,-0x14(%ebp)
1004c2: 8b 45 ec mov -0x14(%ebp),%eax
1004c5: 89 45 f0 mov %eax,-0x10(%ebp)
// search for earliest stab with right type
while (m >= l && stabs[m].n_type != type) {
1004c8: eb 04 jmp 1004ce <stab_binsearch+0x42>
m --;
1004ca: 83 6d f0 01 subl $0x1,-0x10(%ebp)
while (l <= r) {
int true_m = (l + r) / 2, m = true_m;
// search for earliest stab with right type
while (m >= l && stabs[m].n_type != type) {
1004ce: 8b 45 f0 mov -0x10(%ebp),%eax
1004d1: 3b 45 fc cmp -0x4(%ebp),%eax
1004d4: 7c 1f jl 1004f5 <stab_binsearch+0x69>
1004d6: 8b 55 f0 mov -0x10(%ebp),%edx
1004d9: 89 d0 mov %edx,%eax
1004db: 01 c0 add %eax,%eax
1004dd: 01 d0 add %edx,%eax
1004df: c1 e0 02 shl $0x2,%eax
1004e2: 89 c2 mov %eax,%edx
1004e4: 8b 45 08 mov 0x8(%ebp),%eax
1004e7: 01 d0 add %edx,%eax
1004e9: 0f b6 40 04 movzbl 0x4(%eax),%eax
1004ed: 0f b6 c0 movzbl %al,%eax
1004f0: 3b 45 14 cmp 0x14(%ebp),%eax
1004f3: 75 d5 jne 1004ca <stab_binsearch+0x3e>
m --;
}
if (m < l) { // no match in [l, m]
1004f5: 8b 45 f0 mov -0x10(%ebp),%eax
1004f8: 3b 45 fc cmp -0x4(%ebp),%eax
1004fb: 7d 0b jge 100508 <stab_binsearch+0x7c>
l = true_m + 1;
1004fd: 8b 45 ec mov -0x14(%ebp),%eax
100500: 83 c0 01 add $0x1,%eax
100503: 89 45 fc mov %eax,-0x4(%ebp)
continue;
100506: eb 78 jmp 100580 <stab_binsearch+0xf4>
}
// actual binary search
any_matches = 1;
100508: c7 45 f4 01 00 00 00 movl $0x1,-0xc(%ebp)
if (stabs[m].n_value < addr) {
10050f: 8b 55 f0 mov -0x10(%ebp),%edx
100512: 89 d0 mov %edx,%eax
100514: 01 c0 add %eax,%eax
100516: 01 d0 add %edx,%eax
100518: c1 e0 02 shl $0x2,%eax
10051b: 89 c2 mov %eax,%edx
10051d: 8b 45 08 mov 0x8(%ebp),%eax
100520: 01 d0 add %edx,%eax
100522: 8b 40 08 mov 0x8(%eax),%eax
100525: 3b 45 18 cmp 0x18(%ebp),%eax
100528: 73 13 jae 10053d <stab_binsearch+0xb1>
*region_left = m;
10052a: 8b 45 0c mov 0xc(%ebp),%eax
10052d: 8b 55 f0 mov -0x10(%ebp),%edx
100530: 89 10 mov %edx,(%eax)
l = true_m + 1;
100532: 8b 45 ec mov -0x14(%ebp),%eax
100535: 83 c0 01 add $0x1,%eax
100538: 89 45 fc mov %eax,-0x4(%ebp)
10053b: eb 43 jmp 100580 <stab_binsearch+0xf4>
} else if (stabs[m].n_value > addr) {
10053d: 8b 55 f0 mov -0x10(%ebp),%edx
100540: 89 d0 mov %edx,%eax
100542: 01 c0 add %eax,%eax
100544: 01 d0 add %edx,%eax
100546: c1 e0 02 shl $0x2,%eax
100549: 89 c2 mov %eax,%edx
10054b: 8b 45 08 mov 0x8(%ebp),%eax
10054e: 01 d0 add %edx,%eax
100550: 8b 40 08 mov 0x8(%eax),%eax
100553: 3b 45 18 cmp 0x18(%ebp),%eax
100556: 76 16 jbe 10056e <stab_binsearch+0xe2>
*region_right = m - 1;
100558: 8b 45 f0 mov -0x10(%ebp),%eax
10055b: 8d 50 ff lea -0x1(%eax),%edx
10055e: 8b 45 10 mov 0x10(%ebp),%eax
100561: 89 10 mov %edx,(%eax)
r = m - 1;
100563: 8b 45 f0 mov -0x10(%ebp),%eax
100566: 83 e8 01 sub $0x1,%eax
100569: 89 45 f8 mov %eax,-0x8(%ebp)
10056c: eb 12 jmp 100580 <stab_binsearch+0xf4>
} else {
// exact match for 'addr', but continue loop to find
// *region_right
*region_left = m;
10056e: 8b 45 0c mov 0xc(%ebp),%eax
100571: 8b 55 f0 mov -0x10(%ebp),%edx
100574: 89 10 mov %edx,(%eax)
l = m;
100576: 8b 45 f0 mov -0x10(%ebp),%eax
100579: 89 45 fc mov %eax,-0x4(%ebp)
addr ++;
10057c: 83 45 18 01 addl $0x1,0x18(%ebp)
static void
stab_binsearch(const struct stab *stabs, int *region_left, int *region_right,
int type, uintptr_t addr) {
int l = *region_left, r = *region_right, any_matches = 0;
while (l <= r) {
100580: 8b 45 fc mov -0x4(%ebp),%eax
100583: 3b 45 f8 cmp -0x8(%ebp),%eax
100586: 0f 8e 22 ff ff ff jle 1004ae <stab_binsearch+0x22>
l = m;
addr ++;
}
}
if (!any_matches) {
10058c: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
100590: 75 0f jne 1005a1 <stab_binsearch+0x115>
*region_right = *region_left - 1;
100592: 8b 45 0c mov 0xc(%ebp),%eax
100595: 8b 00 mov (%eax),%eax
100597: 8d 50 ff lea -0x1(%eax),%edx
10059a: 8b 45 10 mov 0x10(%ebp),%eax
10059d: 89 10 mov %edx,(%eax)
l = *region_right;
for (; l > *region_left && stabs[l].n_type != type; l --)
/* do nothing */;
*region_left = l;
}
}
10059f: eb 3f jmp 1005e0 <stab_binsearch+0x154>
if (!any_matches) {
*region_right = *region_left - 1;
}
else {
// find rightmost region containing 'addr'
l = *region_right;
1005a1: 8b 45 10 mov 0x10(%ebp),%eax
1005a4: 8b 00 mov (%eax),%eax
1005a6: 89 45 fc mov %eax,-0x4(%ebp)
for (; l > *region_left && stabs[l].n_type != type; l --)
1005a9: eb 04 jmp 1005af <stab_binsearch+0x123>
1005ab: 83 6d fc 01 subl $0x1,-0x4(%ebp)
1005af: 8b 45 0c mov 0xc(%ebp),%eax
1005b2: 8b 00 mov (%eax),%eax
1005b4: 3b 45 fc cmp -0x4(%ebp),%eax
1005b7: 7d 1f jge 1005d8 <stab_binsearch+0x14c>
1005b9: 8b 55 fc mov -0x4(%ebp),%edx
1005bc: 89 d0 mov %edx,%eax
1005be: 01 c0 add %eax,%eax
1005c0: 01 d0 add %edx,%eax
1005c2: c1 e0 02 shl $0x2,%eax
1005c5: 89 c2 mov %eax,%edx
1005c7: 8b 45 08 mov 0x8(%ebp),%eax
1005ca: 01 d0 add %edx,%eax
1005cc: 0f b6 40 04 movzbl 0x4(%eax),%eax
1005d0: 0f b6 c0 movzbl %al,%eax
1005d3: 3b 45 14 cmp 0x14(%ebp),%eax
1005d6: 75 d3 jne 1005ab <stab_binsearch+0x11f>
/* do nothing */;
*region_left = l;
1005d8: 8b 45 0c mov 0xc(%ebp),%eax
1005db: 8b 55 fc mov -0x4(%ebp),%edx
1005de: 89 10 mov %edx,(%eax)
}
}
1005e0: 90 nop
1005e1: c9 leave
1005e2: c3 ret
001005e3 <debuginfo_eip>:
* the specified instruction address, @addr. Returns 0 if information
* was found, and negative if not. But even if it returns negative it
* has stored some information into '*info'.
* */
int
debuginfo_eip(uintptr_t addr, struct eipdebuginfo *info) {
1005e3: 55 push %ebp
1005e4: 89 e5 mov %esp,%ebp
1005e6: 83 ec 38 sub $0x38,%esp
const struct stab *stabs, *stab_end;
const char *stabstr, *stabstr_end;
info->eip_file = "<unknown>";
1005e9: 8b 45 0c mov 0xc(%ebp),%eax
1005ec: c7 00 e8 69 10 00 movl $0x1069e8,(%eax)
info->eip_line = 0;
1005f2: 8b 45 0c mov 0xc(%ebp),%eax
1005f5: c7 40 04 00 00 00 00 movl $0x0,0x4(%eax)
info->eip_fn_name = "<unknown>";
1005fc: 8b 45 0c mov 0xc(%ebp),%eax
1005ff: c7 40 08 e8 69 10 00 movl $0x1069e8,0x8(%eax)
info->eip_fn_namelen = 9;
100606: 8b 45 0c mov 0xc(%ebp),%eax
100609: c7 40 0c 09 00 00 00 movl $0x9,0xc(%eax)
info->eip_fn_addr = addr;
100610: 8b 45 0c mov 0xc(%ebp),%eax
100613: 8b 55 08 mov 0x8(%ebp),%edx
100616: 89 50 10 mov %edx,0x10(%eax)
info->eip_fn_narg = 0;
100619: 8b 45 0c mov 0xc(%ebp),%eax
10061c: c7 40 14 00 00 00 00 movl $0x0,0x14(%eax)
stabs = __STAB_BEGIN__;
100623: c7 45 f4 88 7f 10 00 movl $0x107f88,-0xc(%ebp)
stab_end = __STAB_END__;
10062a: c7 45 f0 4c 42 11 00 movl $0x11424c,-0x10(%ebp)
stabstr = __STABSTR_BEGIN__;
100631: c7 45 ec 4d 42 11 00 movl $0x11424d,-0x14(%ebp)
stabstr_end = __STABSTR_END__;
100638: c7 45 e8 a9 6f 11 00 movl $0x116fa9,-0x18(%ebp)
// String table validity checks
if (stabstr_end <= stabstr || stabstr_end[-1] != 0) {
10063f: 8b 45 e8 mov -0x18(%ebp),%eax
100642: 3b 45 ec cmp -0x14(%ebp),%eax
100645: 76 0d jbe 100654 <debuginfo_eip+0x71>
100647: 8b 45 e8 mov -0x18(%ebp),%eax
10064a: 83 e8 01 sub $0x1,%eax
10064d: 0f b6 00 movzbl (%eax),%eax
100650: 84 c0 test %al,%al
100652: 74 0a je 10065e <debuginfo_eip+0x7b>
return -1;
100654: b8 ff ff ff ff mov $0xffffffff,%eax
100659: e9 91 02 00 00 jmp 1008ef <debuginfo_eip+0x30c>
// 'eip'. First, we find the basic source file containing 'eip'.
// Then, we look in that source file for the function. Then we look
// for the line number.
// Search the entire set of stabs for the source file (type N_SO).
int lfile = 0, rfile = (stab_end - stabs) - 1;
10065e: c7 45 e4 00 00 00 00 movl $0x0,-0x1c(%ebp)
100665: 8b 55 f0 mov -0x10(%ebp),%edx
100668: 8b 45 f4 mov -0xc(%ebp),%eax
10066b: 29 c2 sub %eax,%edx
10066d: 89 d0 mov %edx,%eax
10066f: c1 f8 02 sar $0x2,%eax
100672: 69 c0 ab aa aa aa imul $0xaaaaaaab,%eax,%eax
100678: 83 e8 01 sub $0x1,%eax
10067b: 89 45 e0 mov %eax,-0x20(%ebp)
stab_binsearch(stabs, &lfile, &rfile, N_SO, addr);
10067e: ff 75 08 pushl 0x8(%ebp)
100681: 6a 64 push $0x64
100683: 8d 45 e0 lea -0x20(%ebp),%eax
100686: 50 push %eax
100687: 8d 45 e4 lea -0x1c(%ebp),%eax
10068a: 50 push %eax
10068b: ff 75 f4 pushl -0xc(%ebp)
10068e: e8 f9 fd ff ff call 10048c <stab_binsearch>
100693: 83 c4 14 add $0x14,%esp
if (lfile == 0)
100696: 8b 45 e4 mov -0x1c(%ebp),%eax
100699: 85 c0 test %eax,%eax
10069b: 75 0a jne 1006a7 <debuginfo_eip+0xc4>
return -1;
10069d: b8 ff ff ff ff mov $0xffffffff,%eax
1006a2: e9 48 02 00 00 jmp 1008ef <debuginfo_eip+0x30c>
// Search within that file's stabs for the function definition
// (N_FUN).
int lfun = lfile, rfun = rfile;
1006a7: 8b 45 e4 mov -0x1c(%ebp),%eax
1006aa: 89 45 dc mov %eax,-0x24(%ebp)
1006ad: 8b 45 e0 mov -0x20(%ebp),%eax
1006b0: 89 45 d8 mov %eax,-0x28(%ebp)
int lline, rline;
stab_binsearch(stabs, &lfun, &rfun, N_FUN, addr);
1006b3: ff 75 08 pushl 0x8(%ebp)
1006b6: 6a 24 push $0x24
1006b8: 8d 45 d8 lea -0x28(%ebp),%eax
1006bb: 50 push %eax
1006bc: 8d 45 dc lea -0x24(%ebp),%eax
1006bf: 50 push %eax
1006c0: ff 75 f4 pushl -0xc(%ebp)
1006c3: e8 c4 fd ff ff call 10048c <stab_binsearch>
1006c8: 83 c4 14 add $0x14,%esp
if (lfun <= rfun) {
1006cb: 8b 55 dc mov -0x24(%ebp),%edx
1006ce: 8b 45 d8 mov -0x28(%ebp),%eax
1006d1: 39 c2 cmp %eax,%edx
1006d3: 7f 7c jg 100751 <debuginfo_eip+0x16e>
// stabs[lfun] points to the function name
// in the string table, but check bounds just in case.
if (stabs[lfun].n_strx < stabstr_end - stabstr) {
1006d5: 8b 45 dc mov -0x24(%ebp),%eax
1006d8: 89 c2 mov %eax,%edx
1006da: 89 d0 mov %edx,%eax
1006dc: 01 c0 add %eax,%eax
1006de: 01 d0 add %edx,%eax
1006e0: c1 e0 02 shl $0x2,%eax
1006e3: 89 c2 mov %eax,%edx
1006e5: 8b 45 f4 mov -0xc(%ebp),%eax
1006e8: 01 d0 add %edx,%eax
1006ea: 8b 00 mov (%eax),%eax
1006ec: 8b 4d e8 mov -0x18(%ebp),%ecx
1006ef: 8b 55 ec mov -0x14(%ebp),%edx
1006f2: 29 d1 sub %edx,%ecx
1006f4: 89 ca mov %ecx,%edx
1006f6: 39 d0 cmp %edx,%eax
1006f8: 73 22 jae 10071c <debuginfo_eip+0x139>
info->eip_fn_name = stabstr + stabs[lfun].n_strx;
1006fa: 8b 45 dc mov -0x24(%ebp),%eax
1006fd: 89 c2 mov %eax,%edx
1006ff: 89 d0 mov %edx,%eax
100701: 01 c0 add %eax,%eax
100703: 01 d0 add %edx,%eax
100705: c1 e0 02 shl $0x2,%eax
100708: 89 c2 mov %eax,%edx
10070a: 8b 45 f4 mov -0xc(%ebp),%eax
10070d: 01 d0 add %edx,%eax
10070f: 8b 10 mov (%eax),%edx
100711: 8b 45 ec mov -0x14(%ebp),%eax
100714: 01 c2 add %eax,%edx
100716: 8b 45 0c mov 0xc(%ebp),%eax
100719: 89 50 08 mov %edx,0x8(%eax)
}
info->eip_fn_addr = stabs[lfun].n_value;
10071c: 8b 45 dc mov -0x24(%ebp),%eax
10071f: 89 c2 mov %eax,%edx
100721: 89 d0 mov %edx,%eax
100723: 01 c0 add %eax,%eax
100725: 01 d0 add %edx,%eax
100727: c1 e0 02 shl $0x2,%eax
10072a: 89 c2 mov %eax,%edx
10072c: 8b 45 f4 mov -0xc(%ebp),%eax
10072f: 01 d0 add %edx,%eax
100731: 8b 50 08 mov 0x8(%eax),%edx
100734: 8b 45 0c mov 0xc(%ebp),%eax
100737: 89 50 10 mov %edx,0x10(%eax)
addr -= info->eip_fn_addr;
10073a: 8b 45 0c mov 0xc(%ebp),%eax
10073d: 8b 40 10 mov 0x10(%eax),%eax
100740: 29 45 08 sub %eax,0x8(%ebp)
// Search within the function definition for the line number.
lline = lfun;
100743: 8b 45 dc mov -0x24(%ebp),%eax
100746: 89 45 d4 mov %eax,-0x2c(%ebp)
rline = rfun;
100749: 8b 45 d8 mov -0x28(%ebp),%eax
10074c: 89 45 d0 mov %eax,-0x30(%ebp)
10074f: eb 15 jmp 100766 <debuginfo_eip+0x183>
} else {
// Couldn't find function stab! Maybe we're in an assembly
// file. Search the whole file for the line number.
info->eip_fn_addr = addr;
100751: 8b 45 0c mov 0xc(%ebp),%eax
100754: 8b 55 08 mov 0x8(%ebp),%edx
100757: 89 50 10 mov %edx,0x10(%eax)
lline = lfile;
10075a: 8b 45 e4 mov -0x1c(%ebp),%eax
10075d: 89 45 d4 mov %eax,-0x2c(%ebp)
rline = rfile;
100760: 8b 45 e0 mov -0x20(%ebp),%eax
100763: 89 45 d0 mov %eax,-0x30(%ebp)
}
info->eip_fn_namelen = strfind(info->eip_fn_name, ':') - info->eip_fn_name;
100766: 8b 45 0c mov 0xc(%ebp),%eax
100769: 8b 40 08 mov 0x8(%eax),%eax
10076c: 83 ec 08 sub $0x8,%esp
10076f: 6a 3a push $0x3a
100771: 50 push %eax
100772: e8 64 58 00 00 call 105fdb <strfind>
100777: 83 c4 10 add $0x10,%esp
10077a: 89 c2 mov %eax,%edx
10077c: 8b 45 0c mov 0xc(%ebp),%eax
10077f: 8b 40 08 mov 0x8(%eax),%eax
100782: 29 c2 sub %eax,%edx
100784: 8b 45 0c mov 0xc(%ebp),%eax
100787: 89 50 0c mov %edx,0xc(%eax)
// Search within [lline, rline] for the line number stab.
// If found, set info->eip_line to the right line number.
// If not found, return -1.
stab_binsearch(stabs, &lline, &rline, N_SLINE, addr);
10078a: 83 ec 0c sub $0xc,%esp
10078d: ff 75 08 pushl 0x8(%ebp)
100790: 6a 44 push $0x44
100792: 8d 45 d0 lea -0x30(%ebp),%eax
100795: 50 push %eax
100796: 8d 45 d4 lea -0x2c(%ebp),%eax
100799: 50 push %eax
10079a: ff 75 f4 pushl -0xc(%ebp)
10079d: e8 ea fc ff ff call 10048c <stab_binsearch>
1007a2: 83 c4 20 add $0x20,%esp
if (lline <= rline) {
1007a5: 8b 55 d4 mov -0x2c(%ebp),%edx
1007a8: 8b 45 d0 mov -0x30(%ebp),%eax
1007ab: 39 c2 cmp %eax,%edx
1007ad: 7f 24 jg 1007d3 <debuginfo_eip+0x1f0>
info->eip_line = stabs[rline].n_desc;
1007af: 8b 45 d0 mov -0x30(%ebp),%eax
1007b2: 89 c2 mov %eax,%edx
1007b4: 89 d0 mov %edx,%eax
1007b6: 01 c0 add %eax,%eax
1007b8: 01 d0 add %edx,%eax
1007ba: c1 e0 02 shl $0x2,%eax
1007bd: 89 c2 mov %eax,%edx
1007bf: 8b 45 f4 mov -0xc(%ebp),%eax
1007c2: 01 d0 add %edx,%eax
1007c4: 0f b7 40 06 movzwl 0x6(%eax),%eax
1007c8: 0f b7 d0 movzwl %ax,%edx
1007cb: 8b 45 0c mov 0xc(%ebp),%eax
1007ce: 89 50 04 mov %edx,0x4(%eax)
// Search backwards from the line number for the relevant filename stab.
// We can't just use the "lfile" stab because inlined functions
// can interpolate code from a different file!
// Such included source files use the N_SOL stab type.
while (lline >= lfile
1007d1: eb 13 jmp 1007e6 <debuginfo_eip+0x203>
// If not found, return -1.
stab_binsearch(stabs, &lline, &rline, N_SLINE, addr);
if (lline <= rline) {
info->eip_line = stabs[rline].n_desc;
} else {
return -1;
1007d3: b8 ff ff ff ff mov $0xffffffff,%eax
1007d8: e9 12 01 00 00 jmp 1008ef <debuginfo_eip+0x30c>
// can interpolate code from a different file!
// Such included source files use the N_SOL stab type.
while (lline >= lfile
&& stabs[lline].n_type != N_SOL
&& (stabs[lline].n_type != N_SO || !stabs[lline].n_value)) {
lline --;
1007dd: 8b 45 d4 mov -0x2c(%ebp),%eax
1007e0: 83 e8 01 sub $0x1,%eax
1007e3: 89 45 d4 mov %eax,-0x2c(%ebp)
// Search backwards from the line number for the relevant filename stab.
// We can't just use the "lfile" stab because inlined functions
// can interpolate code from a different file!
// Such included source files use the N_SOL stab type.
while (lline >= lfile
1007e6: 8b 55 d4 mov -0x2c(%ebp),%edx
1007e9: 8b 45 e4 mov -0x1c(%ebp),%eax
1007ec: 39 c2 cmp %eax,%edx
1007ee: 7c 56 jl 100846 <debuginfo_eip+0x263>
&& stabs[lline].n_type != N_SOL
1007f0: 8b 45 d4 mov -0x2c(%ebp),%eax
1007f3: 89 c2 mov %eax,%edx
1007f5: 89 d0 mov %edx,%eax
1007f7: 01 c0 add %eax,%eax
1007f9: 01 d0 add %edx,%eax
1007fb: c1 e0 02 shl $0x2,%eax
1007fe: 89 c2 mov %eax,%edx
100800: 8b 45 f4 mov -0xc(%ebp),%eax
100803: 01 d0 add %edx,%eax
100805: 0f b6 40 04 movzbl 0x4(%eax),%eax
100809: 3c 84 cmp $0x84,%al
10080b: 74 39 je 100846 <debuginfo_eip+0x263>
&& (stabs[lline].n_type != N_SO || !stabs[lline].n_value)) {
10080d: 8b 45 d4 mov -0x2c(%ebp),%eax
100810: 89 c2 mov %eax,%edx
100812: 89 d0 mov %edx,%eax
100814: 01 c0 add %eax,%eax
100816: 01 d0 add %edx,%eax
100818: c1 e0 02 shl $0x2,%eax
10081b: 89 c2 mov %eax,%edx
10081d: 8b 45 f4 mov -0xc(%ebp),%eax
100820: 01 d0 add %edx,%eax
100822: 0f b6 40 04 movzbl 0x4(%eax),%eax
100826: 3c 64 cmp $0x64,%al
100828: 75 b3 jne 1007dd <debuginfo_eip+0x1fa>
10082a: 8b 45 d4 mov -0x2c(%ebp),%eax
10082d: 89 c2 mov %eax,%edx
10082f: 89 d0 mov %edx,%eax
100831: 01 c0 add %eax,%eax
100833: 01 d0 add %edx,%eax
100835: c1 e0 02 shl $0x2,%eax
100838: 89 c2 mov %eax,%edx
10083a: 8b 45 f4 mov -0xc(%ebp),%eax
10083d: 01 d0 add %edx,%eax
10083f: 8b 40 08 mov 0x8(%eax),%eax
100842: 85 c0 test %eax,%eax
100844: 74 97 je 1007dd <debuginfo_eip+0x1fa>
lline --;
}
if (lline >= lfile && stabs[lline].n_strx < stabstr_end - stabstr) {
100846: 8b 55 d4 mov -0x2c(%ebp),%edx
100849: 8b 45 e4 mov -0x1c(%ebp),%eax
10084c: 39 c2 cmp %eax,%edx
10084e: 7c 46 jl 100896 <debuginfo_eip+0x2b3>
100850: 8b 45 d4 mov -0x2c(%ebp),%eax
100853: 89 c2 mov %eax,%edx
100855: 89 d0 mov %edx,%eax
100857: 01 c0 add %eax,%eax
100859: 01 d0 add %edx,%eax
10085b: c1 e0 02 shl $0x2,%eax
10085e: 89 c2 mov %eax,%edx
100860: 8b 45 f4 mov -0xc(%ebp),%eax
100863: 01 d0 add %edx,%eax
100865: 8b 00 mov (%eax),%eax
100867: 8b 4d e8 mov -0x18(%ebp),%ecx
10086a: 8b 55 ec mov -0x14(%ebp),%edx
10086d: 29 d1 sub %edx,%ecx
10086f: 89 ca mov %ecx,%edx
100871: 39 d0 cmp %edx,%eax
100873: 73 21 jae 100896 <debuginfo_eip+0x2b3>
info->eip_file = stabstr + stabs[lline].n_strx;
100875: 8b 45 d4 mov -0x2c(%ebp),%eax
100878: 89 c2 mov %eax,%edx
10087a: 89 d0 mov %edx,%eax
10087c: 01 c0 add %eax,%eax
10087e: 01 d0 add %edx,%eax
100880: c1 e0 02 shl $0x2,%eax
100883: 89 c2 mov %eax,%edx
100885: 8b 45 f4 mov -0xc(%ebp),%eax
100888: 01 d0 add %edx,%eax
10088a: 8b 10 mov (%eax),%edx
10088c: 8b 45 ec mov -0x14(%ebp),%eax
10088f: 01 c2 add %eax,%edx
100891: 8b 45 0c mov 0xc(%ebp),%eax
100894: 89 10 mov %edx,(%eax)
}
// Set eip_fn_narg to the number of arguments taken by the function,
// or 0 if there was no containing function.
if (lfun < rfun) {
100896: 8b 55 dc mov -0x24(%ebp),%edx
100899: 8b 45 d8 mov -0x28(%ebp),%eax
10089c: 39 c2 cmp %eax,%edx
10089e: 7d 4a jge 1008ea <debuginfo_eip+0x307>
for (lline = lfun + 1;
1008a0: 8b 45 dc mov -0x24(%ebp),%eax
1008a3: 83 c0 01 add $0x1,%eax
1008a6: 89 45 d4 mov %eax,-0x2c(%ebp)
1008a9: eb 18 jmp 1008c3 <debuginfo_eip+0x2e0>
lline < rfun && stabs[lline].n_type == N_PSYM;
lline ++) {
info->eip_fn_narg ++;
1008ab: 8b 45 0c mov 0xc(%ebp),%eax
1008ae: 8b 40 14 mov 0x14(%eax),%eax
1008b1: 8d 50 01 lea 0x1(%eax),%edx
1008b4: 8b 45 0c mov 0xc(%ebp),%eax
1008b7: 89 50 14 mov %edx,0x14(%eax)
// Set eip_fn_narg to the number of arguments taken by the function,
// or 0 if there was no containing function.
if (lfun < rfun) {
for (lline = lfun + 1;
lline < rfun && stabs[lline].n_type == N_PSYM;
lline ++) {
1008ba: 8b 45 d4 mov -0x2c(%ebp),%eax
1008bd: 83 c0 01 add $0x1,%eax
1008c0: 89 45 d4 mov %eax,-0x2c(%ebp)
// Set eip_fn_narg to the number of arguments taken by the function,
// or 0 if there was no containing function.
if (lfun < rfun) {
for (lline = lfun + 1;
lline < rfun && stabs[lline].n_type == N_PSYM;
1008c3: 8b 55 d4 mov -0x2c(%ebp),%edx
1008c6: 8b 45 d8 mov -0x28(%ebp),%eax
}
// Set eip_fn_narg to the number of arguments taken by the function,
// or 0 if there was no containing function.
if (lfun < rfun) {
for (lline = lfun + 1;
1008c9: 39 c2 cmp %eax,%edx
1008cb: 7d 1d jge 1008ea <debuginfo_eip+0x307>
lline < rfun && stabs[lline].n_type == N_PSYM;
1008cd: 8b 45 d4 mov -0x2c(%ebp),%eax
1008d0: 89 c2 mov %eax,%edx
1008d2: 89 d0 mov %edx,%eax
1008d4: 01 c0 add %eax,%eax
1008d6: 01 d0 add %edx,%eax
1008d8: c1 e0 02 shl $0x2,%eax
1008db: 89 c2 mov %eax,%edx
1008dd: 8b 45 f4 mov -0xc(%ebp),%eax
1008e0: 01 d0 add %edx,%eax
1008e2: 0f b6 40 04 movzbl 0x4(%eax),%eax
1008e6: 3c a0 cmp $0xa0,%al
1008e8: 74 c1 je 1008ab <debuginfo_eip+0x2c8>
lline ++) {
info->eip_fn_narg ++;
}
}
return 0;
1008ea: b8 00 00 00 00 mov $0x0,%eax
}
1008ef: c9 leave
1008f0: c3 ret
001008f1 <print_kerninfo>:
* print_kerninfo - print the information about kernel, including the location
* of kernel entry, the start addresses of data and text segements, the start
* address of free memory and how many memory that kernel has used.
* */
void
print_kerninfo(void) {
1008f1: 55 push %ebp
1008f2: 89 e5 mov %esp,%ebp
1008f4: 83 ec 08 sub $0x8,%esp
extern char etext[], edata[], end[], kern_init[];
cprintf("Special kernel symbols:\n");
1008f7: 83 ec 0c sub $0xc,%esp
1008fa: 68 f2 69 10 00 push $0x1069f2
1008ff: e8 63 f9 ff ff call 100267 <cprintf>
100904: 83 c4 10 add $0x10,%esp
cprintf(" entry 0x%08x (phys)\n", kern_init);
100907: 83 ec 08 sub $0x8,%esp
10090a: 68 2a 00 10 00 push $0x10002a
10090f: 68 0b 6a 10 00 push $0x106a0b
100914: e8 4e f9 ff ff call 100267 <cprintf>
100919: 83 c4 10 add $0x10,%esp
cprintf(" etext 0x%08x (phys)\n", etext);
10091c: 83 ec 08 sub $0x8,%esp
10091f: 68 fe 68 10 00 push $0x1068fe
100924: 68 23 6a 10 00 push $0x106a23
100929: e8 39 f9 ff ff call 100267 <cprintf>
10092e: 83 c4 10 add $0x10,%esp
cprintf(" edata 0x%08x (phys)\n", edata);
100931: 83 ec 08 sub $0x8,%esp
100934: 68 36 9a 11 00 push $0x119a36
100939: 68 3b 6a 10 00 push $0x106a3b
10093e: e8 24 f9 ff ff call 100267 <cprintf>
100943: 83 c4 10 add $0x10,%esp
cprintf(" end 0x%08x (phys)\n", end);
100946: 83 ec 08 sub $0x8,%esp
100949: 68 74 a9 11 00 push $0x11a974
10094e: 68 53 6a 10 00 push $0x106a53
100953: e8 0f f9 ff ff call 100267 <cprintf>
100958: 83 c4 10 add $0x10,%esp
cprintf("Kernel executable memory footprint: %dKB\n", (end - kern_init + 1023)/1024);
10095b: b8 74 a9 11 00 mov $0x11a974,%eax
100960: 05 ff 03 00 00 add $0x3ff,%eax
100965: ba 2a 00 10 00 mov $0x10002a,%edx
10096a: 29 d0 sub %edx,%eax
10096c: 8d 90 ff 03 00 00 lea 0x3ff(%eax),%edx
100972: 85 c0 test %eax,%eax
100974: 0f 48 c2 cmovs %edx,%eax
100977: c1 f8 0a sar $0xa,%eax
10097a: 83 ec 08 sub $0x8,%esp
10097d: 50 push %eax
10097e: 68 6c 6a 10 00 push $0x106a6c
100983: e8 df f8 ff ff call 100267 <cprintf>
100988: 83 c4 10 add $0x10,%esp
}
10098b: 90 nop
10098c: c9 leave
10098d: c3 ret
0010098e <print_debuginfo>:
/* *
* print_debuginfo - read and print the stat information for the address @eip,
* and info.eip_fn_addr should be the first address of the related function.
* */
void
print_debuginfo(uintptr_t eip) {
10098e: 55 push %ebp
10098f: 89 e5 mov %esp,%ebp
100991: 81 ec 28 01 00 00 sub $0x128,%esp
struct eipdebuginfo info;
if (debuginfo_eip(eip, &info) != 0) {
100997: 83 ec 08 sub $0x8,%esp
10099a: 8d 45 dc lea -0x24(%ebp),%eax
10099d: 50 push %eax
10099e: ff 75 08 pushl 0x8(%ebp)
1009a1: e8 3d fc ff ff call 1005e3 <debuginfo_eip>
1009a6: 83 c4 10 add $0x10,%esp
1009a9: 85 c0 test %eax,%eax
1009ab: 74 15 je 1009c2 <print_debuginfo+0x34>
cprintf(" <unknow>: -- 0x%08x --\n", eip);
1009ad: 83 ec 08 sub $0x8,%esp
1009b0: ff 75 08 pushl 0x8(%ebp)
1009b3: 68 96 6a 10 00 push $0x106a96
1009b8: e8 aa f8 ff ff call 100267 <cprintf>
1009bd: 83 c4 10 add $0x10,%esp
}
fnname[j] = '\0';
cprintf(" %s:%d: %s+%d\n", info.eip_file, info.eip_line,
fnname, eip - info.eip_fn_addr);
}
}
1009c0: eb 65 jmp 100a27 <print_debuginfo+0x99>
cprintf(" <unknow>: -- 0x%08x --\n", eip);
}
else {
char fnname[256];
int j;
for (j = 0; j < info.eip_fn_namelen; j ++) {
1009c2: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp)
1009c9: eb 1c jmp 1009e7 <print_debuginfo+0x59>
fnname[j] = info.eip_fn_name[j];
1009cb: 8b 55 e4 mov -0x1c(%ebp),%edx
1009ce: 8b 45 f4 mov -0xc(%ebp),%eax
1009d1: 01 d0 add %edx,%eax
1009d3: 0f b6 00 movzbl (%eax),%eax
1009d6: 8d 8d dc fe ff ff lea -0x124(%ebp),%ecx
1009dc: 8b 55 f4 mov -0xc(%ebp),%edx
1009df: 01 ca add %ecx,%edx
1009e1: 88 02 mov %al,(%edx)
cprintf(" <unknow>: -- 0x%08x --\n", eip);
}
else {
char fnname[256];
int j;
for (j = 0; j < info.eip_fn_namelen; j ++) {
1009e3: 83 45 f4 01 addl $0x1,-0xc(%ebp)
1009e7: 8b 45 e8 mov -0x18(%ebp),%eax
1009ea: 3b 45 f4 cmp -0xc(%ebp),%eax
1009ed: 7f dc jg 1009cb <print_debuginfo+0x3d>
fnname[j] = info.eip_fn_name[j];
}
fnname[j] = '\0';
1009ef: 8d 95 dc fe ff ff lea -0x124(%ebp),%edx
1009f5: 8b 45 f4 mov -0xc(%ebp),%eax
1009f8: 01 d0 add %edx,%eax
1009fa: c6 00 00 movb $0x0,(%eax)
cprintf(" %s:%d: %s+%d\n", info.eip_file, info.eip_line,
fnname, eip - info.eip_fn_addr);
1009fd: 8b 45 ec mov -0x14(%ebp),%eax
int j;
for (j = 0; j < info.eip_fn_namelen; j ++) {
fnname[j] = info.eip_fn_name[j];
}
fnname[j] = '\0';
cprintf(" %s:%d: %s+%d\n", info.eip_file, info.eip_line,
100a00: 8b 55 08 mov 0x8(%ebp),%edx
100a03: 89 d1 mov %edx,%ecx
100a05: 29 c1 sub %eax,%ecx
100a07: 8b 55 e0 mov -0x20(%ebp),%edx
100a0a: 8b 45 dc mov -0x24(%ebp),%eax
100a0d: 83 ec 0c sub $0xc,%esp
100a10: 51 push %ecx
100a11: 8d 8d dc fe ff ff lea -0x124(%ebp),%ecx
100a17: 51 push %ecx
100a18: 52 push %edx
100a19: 50 push %eax
100a1a: 68 b2 6a 10 00 push $0x106ab2
100a1f: e8 43 f8 ff ff call 100267 <cprintf>
100a24: 83 c4 20 add $0x20,%esp
fnname, eip - info.eip_fn_addr);
}
}
100a27: 90 nop
100a28: c9 leave
100a29: c3 ret
00100a2a <read_eip>:
static __noinline uint32_t
read_eip(void) {
100a2a: 55 push %ebp
100a2b: 89 e5 mov %esp,%ebp
100a2d: 83 ec 10 sub $0x10,%esp
uint32_t eip;
asm volatile("movl 4(%%ebp), %0" : "=r" (eip));
100a30: 8b 45 04 mov 0x4(%ebp),%eax
100a33: 89 45 fc mov %eax,-0x4(%ebp)
return eip;
100a36: 8b 45 fc mov -0x4(%ebp),%eax
}
100a39: c9 leave
100a3a: c3 ret
00100a3b <print_stackframe>:
*
* Note that, the length of ebp-chain is limited. In boot/bootasm.S, before jumping
* to the kernel entry, the value of ebp has been set to zero, that's the boundary.
* */
void
print_stackframe(void) {
100a3b: 55 push %ebp
100a3c: 89 e5 mov %esp,%ebp
100a3e: 83 ec 28 sub $0x28,%esp
}
static inline uint32_t
read_ebp(void) {
uint32_t ebp;
asm volatile ("movl %%ebp, %0" : "=r" (ebp));
100a41: 89 e8 mov %ebp,%eax
100a43: 89 45 e4 mov %eax,-0x1c(%ebp)
return ebp;
100a46: 8b 45 e4 mov -0x1c(%ebp),%eax
* (3.4) call print_debuginfo(eip-1) to print the C calling function name and line number, etc.
* (3.5) popup a calling stackframe
* NOTICE: the calling funciton's return addr eip = ss:[ebp+4]
* the calling funciton's ebp = ss:[ebp]
*/
uint32_t current_ebp = read_ebp();
100a49: 89 45 f4 mov %eax,-0xc(%ebp)
uint32_t current_eip = read_eip();
100a4c: e8 d9 ff ff ff call 100a2a <read_eip>
100a51: 89 45 f0 mov %eax,-0x10(%ebp)
for (int i = 0; i < STACKFRAME_DEPTH && current_ebp != 0; ++ i) {
100a54: c7 45 ec 00 00 00 00 movl $0x0,-0x14(%ebp)
100a5b: e9 87 00 00 00 jmp 100ae7 <print_stackframe+0xac>
cprintf("ebp:0x%08x eip:0x%08x args:", current_ebp, current_eip);
100a60: 83 ec 04 sub $0x4,%esp
100a63: ff 75 f0 pushl -0x10(%ebp)
100a66: ff 75 f4 pushl -0xc(%ebp)
100a69: 68 c4 6a 10 00 push $0x106ac4
100a6e: e8 f4 f7 ff ff call 100267 <cprintf>
100a73: 83 c4 10 add $0x10,%esp
for (int argi = 0; argi < 4; ++ argi) {
100a76: c7 45 e8 00 00 00 00 movl $0x0,-0x18(%ebp)
100a7d: eb 29 jmp 100aa8 <print_stackframe+0x6d>
cprintf("0x%08x ", *((uint32_t*) current_ebp + 2 + argi));
100a7f: 8b 45 e8 mov -0x18(%ebp),%eax
100a82: 8d 14 85 00 00 00 00 lea 0x0(,%eax,4),%edx
100a89: 8b 45 f4 mov -0xc(%ebp),%eax
100a8c: 01 d0 add %edx,%eax
100a8e: 83 c0 08 add $0x8,%eax
100a91: 8b 00 mov (%eax),%eax
100a93: 83 ec 08 sub $0x8,%esp
100a96: 50 push %eax
100a97: 68 e0 6a 10 00 push $0x106ae0
100a9c: e8 c6 f7 ff ff call 100267 <cprintf>
100aa1: 83 c4 10 add $0x10,%esp
*/
uint32_t current_ebp = read_ebp();
uint32_t current_eip = read_eip();
for (int i = 0; i < STACKFRAME_DEPTH && current_ebp != 0; ++ i) {
cprintf("ebp:0x%08x eip:0x%08x args:", current_ebp, current_eip);
for (int argi = 0; argi < 4; ++ argi) {
100aa4: 83 45 e8 01 addl $0x1,-0x18(%ebp)
100aa8: 83 7d e8 03 cmpl $0x3,-0x18(%ebp)
100aac: 7e d1 jle 100a7f <print_stackframe+0x44>
cprintf("0x%08x ", *((uint32_t*) current_ebp + 2 + argi));
}
cprintf("\n");
100aae: 83 ec 0c sub $0xc,%esp
100ab1: 68 e8 6a 10 00 push $0x106ae8
100ab6: e8 ac f7 ff ff call 100267 <cprintf>
100abb: 83 c4 10 add $0x10,%esp
print_debuginfo(current_eip - 1);
100abe: 8b 45 f0 mov -0x10(%ebp),%eax
100ac1: 83 e8 01 sub $0x1,%eax
100ac4: 83 ec 0c sub $0xc,%esp
100ac7: 50 push %eax
100ac8: e8 c1 fe ff ff call 10098e <print_debuginfo>
100acd: 83 c4 10 add $0x10,%esp
current_eip = *((uint32_t*)current_ebp + 1);
100ad0: 8b 45 f4 mov -0xc(%ebp),%eax
100ad3: 83 c0 04 add $0x4,%eax
100ad6: 8b 00 mov (%eax),%eax
100ad8: 89 45 f0 mov %eax,-0x10(%ebp)
current_ebp = *((uint32_t*)current_ebp);
100adb: 8b 45 f4 mov -0xc(%ebp),%eax
100ade: 8b 00 mov (%eax),%eax
100ae0: 89 45 f4 mov %eax,-0xc(%ebp)
* NOTICE: the calling funciton's return addr eip = ss:[ebp+4]
* the calling funciton's ebp = ss:[ebp]
*/
uint32_t current_ebp = read_ebp();
uint32_t current_eip = read_eip();
for (int i = 0; i < STACKFRAME_DEPTH && current_ebp != 0; ++ i) {
100ae3: 83 45 ec 01 addl $0x1,-0x14(%ebp)
100ae7: 83 7d ec 13 cmpl $0x13,-0x14(%ebp)
100aeb: 7f 0a jg 100af7 <print_stackframe+0xbc>
100aed: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
100af1: 0f 85 69 ff ff ff jne 100a60 <print_stackframe+0x25>
cprintf("\n");
print_debuginfo(current_eip - 1);
current_eip = *((uint32_t*)current_ebp + 1);
current_ebp = *((uint32_t*)current_ebp);
}
}
100af7: 90 nop
100af8: c9 leave
100af9: c3 ret
00100afa <parse>:
#define MAXARGS 16
#define WHITESPACE " \t\n\r"
/* parse - parse the command buffer into whitespace-separated arguments */
static int
parse(char *buf, char **argv) {
100afa: 55 push %ebp
100afb: 89 e5 mov %esp,%ebp
100afd: 83 ec 18 sub $0x18,%esp
int argc = 0;
100b00: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp)
while (1) {
// find global whitespace
while (*buf != '\0' && strchr(WHITESPACE, *buf) != NULL) {
100b07: eb 0c jmp 100b15 <parse+0x1b>
*buf ++ = '\0';
100b09: 8b 45 08 mov 0x8(%ebp),%eax
100b0c: 8d 50 01 lea 0x1(%eax),%edx
100b0f: 89 55 08 mov %edx,0x8(%ebp)
100b12: c6 00 00 movb $0x0,(%eax)
static int
parse(char *buf, char **argv) {
int argc = 0;
while (1) {
// find global whitespace
while (*buf != '\0' && strchr(WHITESPACE, *buf) != NULL) {
100b15: 8b 45 08 mov 0x8(%ebp),%eax
100b18: 0f b6 00 movzbl (%eax),%eax
100b1b: 84 c0 test %al,%al
100b1d: 74 1e je 100b3d <parse+0x43>
100b1f: 8b 45 08 mov 0x8(%ebp),%eax
100b22: 0f b6 00 movzbl (%eax),%eax
100b25: 0f be c0 movsbl %al,%eax
100b28: 83 ec 08 sub $0x8,%esp
100b2b: 50 push %eax
100b2c: 68 6c 6b 10 00 push $0x106b6c
100b31: e8 72 54 00 00 call 105fa8 <strchr>
100b36: 83 c4 10 add $0x10,%esp
100b39: 85 c0 test %eax,%eax
100b3b: 75 cc jne 100b09 <parse+0xf>
*buf ++ = '\0';
}
if (*buf == '\0') {
100b3d: 8b 45 08 mov 0x8(%ebp),%eax
100b40: 0f b6 00 movzbl (%eax),%eax
100b43: 84 c0 test %al,%al
100b45: 74 69 je 100bb0 <parse+0xb6>
break;
}
// save and scan past next arg
if (argc == MAXARGS - 1) {
100b47: 83 7d f4 0f cmpl $0xf,-0xc(%ebp)
100b4b: 75 12 jne 100b5f <parse+0x65>
cprintf("Too many arguments (max %d).\n", MAXARGS);
100b4d: 83 ec 08 sub $0x8,%esp
100b50: 6a 10 push $0x10
100b52: 68 71 6b 10 00 push $0x106b71
100b57: e8 0b f7 ff ff call 100267 <cprintf>
100b5c: 83 c4 10 add $0x10,%esp
}
argv[argc ++] = buf;
100b5f: 8b 45 f4 mov -0xc(%ebp),%eax
100b62: 8d 50 01 lea 0x1(%eax),%edx
100b65: 89 55 f4 mov %edx,-0xc(%ebp)
100b68: 8d 14 85 00 00 00 00 lea 0x0(,%eax,4),%edx
100b6f: 8b 45 0c mov 0xc(%ebp),%eax
100b72: 01 c2 add %eax,%edx
100b74: 8b 45 08 mov 0x8(%ebp),%eax
100b77: 89 02 mov %eax,(%edx)
while (*buf != '\0' && strchr(WHITESPACE, *buf) == NULL) {
100b79: eb 04 jmp 100b7f <parse+0x85>
buf ++;
100b7b: 83 45 08 01 addl $0x1,0x8(%ebp)
// save and scan past next arg
if (argc == MAXARGS - 1) {
cprintf("Too many arguments (max %d).\n", MAXARGS);
}
argv[argc ++] = buf;
while (*buf != '\0' && strchr(WHITESPACE, *buf) == NULL) {
100b7f: 8b 45 08 mov 0x8(%ebp),%eax
100b82: 0f b6 00 movzbl (%eax),%eax
100b85: 84 c0 test %al,%al
100b87: 0f 84 7a ff ff ff je 100b07 <parse+0xd>
100b8d: 8b 45 08 mov 0x8(%ebp),%eax
100b90: 0f b6 00 movzbl (%eax),%eax
100b93: 0f be c0 movsbl %al,%eax
100b96: 83 ec 08 sub $0x8,%esp
100b99: 50 push %eax
100b9a: 68 6c 6b 10 00 push $0x106b6c
100b9f: e8 04 54 00 00 call 105fa8 <strchr>
100ba4: 83 c4 10 add $0x10,%esp
100ba7: 85 c0 test %eax,%eax
100ba9: 74 d0 je 100b7b <parse+0x81>
buf ++;
}
}
100bab: e9 57 ff ff ff jmp 100b07 <parse+0xd>
// find global whitespace
while (*buf != '\0' && strchr(WHITESPACE, *buf) != NULL) {
*buf ++ = '\0';
}
if (*buf == '\0') {
break;
100bb0: 90 nop
argv[argc ++] = buf;
while (*buf != '\0' && strchr(WHITESPACE, *buf) == NULL) {
buf ++;
}
}
return argc;
100bb1: 8b 45 f4 mov -0xc(%ebp),%eax
}
100bb4: c9 leave
100bb5: c3 ret
00100bb6 <runcmd>:
/* *
* runcmd - parse the input string, split it into separated arguments
* and then lookup and invoke some related commands/
* */
static int
runcmd(char *buf, struct trapframe *tf) {
100bb6: 55 push %ebp
100bb7: 89 e5 mov %esp,%ebp
100bb9: 83 ec 58 sub $0x58,%esp
char *argv[MAXARGS];
int argc = parse(buf, argv);
100bbc: 83 ec 08 sub $0x8,%esp
100bbf: 8d 45 b0 lea -0x50(%ebp),%eax
100bc2: 50 push %eax
100bc3: ff 75 08 pushl 0x8(%ebp)
100bc6: e8 2f ff ff ff call 100afa <parse>
100bcb: 83 c4 10 add $0x10,%esp
100bce: 89 45 f0 mov %eax,-0x10(%ebp)
if (argc == 0) {
100bd1: 83 7d f0 00 cmpl $0x0,-0x10(%ebp)
100bd5: 75 0a jne 100be1 <runcmd+0x2b>
return 0;
100bd7: b8 00 00 00 00 mov $0x0,%eax
100bdc: e9 83 00 00 00 jmp 100c64 <runcmd+0xae>
}
int i;
for (i = 0; i < NCOMMANDS; i ++) {
100be1: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp)
100be8: eb 59 jmp 100c43 <runcmd+0x8d>
if (strcmp(commands[i].name, argv[0]) == 0) {
100bea: 8b 4d b0 mov -0x50(%ebp),%ecx
100bed: 8b 55 f4 mov -0xc(%ebp),%edx
100bf0: 89 d0 mov %edx,%eax
100bf2: 01 c0 add %eax,%eax
100bf4: 01 d0 add %edx,%eax
100bf6: c1 e0 02 shl $0x2,%eax
100bf9: 05 20 90 11 00 add $0x119020,%eax
100bfe: 8b 00 mov (%eax),%eax
100c00: 83 ec 08 sub $0x8,%esp
100c03: 51 push %ecx
100c04: 50 push %eax
100c05: e8 fe 52 00 00 call 105f08 <strcmp>
100c0a: 83 c4 10 add $0x10,%esp
100c0d: 85 c0 test %eax,%eax
100c0f: 75 2e jne 100c3f <runcmd+0x89>
return commands[i].func(argc - 1, argv + 1, tf);
100c11: 8b 55 f4 mov -0xc(%ebp),%edx
100c14: 89 d0 mov %edx,%eax
100c16: 01 c0 add %eax,%eax
100c18: 01 d0 add %edx,%eax
100c1a: c1 e0 02 shl $0x2,%eax
100c1d: 05 28 90 11 00 add $0x119028,%eax
100c22: 8b 10 mov (%eax),%edx
100c24: 8d 45 b0 lea -0x50(%ebp),%eax
100c27: 83 c0 04 add $0x4,%eax
100c2a: 8b 4d f0 mov -0x10(%ebp),%ecx
100c2d: 83 e9 01 sub $0x1,%ecx
100c30: 83 ec 04 sub $0x4,%esp
100c33: ff 75 0c pushl 0xc(%ebp)
100c36: 50 push %eax
100c37: 51 push %ecx
100c38: ff d2 call *%edx
100c3a: 83 c4 10 add $0x10,%esp
100c3d: eb 25 jmp 100c64 <runcmd+0xae>
int argc = parse(buf, argv);
if (argc == 0) {
return 0;
}
int i;
for (i = 0; i < NCOMMANDS; i ++) {
100c3f: 83 45 f4 01 addl $0x1,-0xc(%ebp)
100c43: 8b 45 f4 mov -0xc(%ebp),%eax
100c46: 83 f8 02 cmp $0x2,%eax
100c49: 76 9f jbe 100bea <runcmd+0x34>
if (strcmp(commands[i].name, argv[0]) == 0) {
return commands[i].func(argc - 1, argv + 1, tf);
}
}
cprintf("Unknown command '%s'\n", argv[0]);
100c4b: 8b 45 b0 mov -0x50(%ebp),%eax
100c4e: 83 ec 08 sub $0x8,%esp
100c51: 50 push %eax
100c52: 68 8f 6b 10 00 push $0x106b8f
100c57: e8 0b f6 ff ff call 100267 <cprintf>
100c5c: 83 c4 10 add $0x10,%esp
return 0;
100c5f: b8 00 00 00 00 mov $0x0,%eax
}
100c64: c9 leave
100c65: c3 ret
00100c66 <kmonitor>:
/***** Implementations of basic kernel monitor commands *****/
void
kmonitor(struct trapframe *tf) {
100c66: 55 push %ebp
100c67: 89 e5 mov %esp,%ebp
100c69: 83 ec 18 sub $0x18,%esp
cprintf("Welcome to the kernel debug monitor!!\n");
100c6c: 83 ec 0c sub $0xc,%esp
100c6f: 68 a8 6b 10 00 push $0x106ba8
100c74: e8 ee f5 ff ff call 100267 <cprintf>
100c79: 83 c4 10 add $0x10,%esp
cprintf("Type 'help' for a list of commands.\n");
100c7c: 83 ec 0c sub $0xc,%esp
100c7f: 68 d0 6b 10 00 push $0x106bd0
100c84: e8 de f5 ff ff call 100267 <cprintf>
100c89: 83 c4 10 add $0x10,%esp
if (tf != NULL) {
100c8c: 83 7d 08 00 cmpl $0x0,0x8(%ebp)
100c90: 74 0e je 100ca0 <kmonitor+0x3a>
print_trapframe(tf);
100c92: 83 ec 0c sub $0xc,%esp
100c95: ff 75 08 pushl 0x8(%ebp)
100c98: e8 14 0e 00 00 call 101ab1 <print_trapframe>
100c9d: 83 c4 10 add $0x10,%esp
}
char *buf;
while (1) {
if ((buf = readline("K> ")) != NULL) {
100ca0: 83 ec 0c sub $0xc,%esp
100ca3: 68 f5 6b 10 00 push $0x106bf5
100ca8: e8 5e f6 ff ff call 10030b <readline>
100cad: 83 c4 10 add $0x10,%esp
100cb0: 89 45 f4 mov %eax,-0xc(%ebp)
100cb3: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
100cb7: 74 e7 je 100ca0 <kmonitor+0x3a>
if (runcmd(buf, tf) < 0) {
100cb9: 83 ec 08 sub $0x8,%esp
100cbc: ff 75 08 pushl 0x8(%ebp)
100cbf: ff 75 f4 pushl -0xc(%ebp)
100cc2: e8 ef fe ff ff call 100bb6 <runcmd>
100cc7: 83 c4 10 add $0x10,%esp
100cca: 85 c0 test %eax,%eax
100ccc: 78 02 js 100cd0 <kmonitor+0x6a>
break;
}
}
}
100cce: eb d0 jmp 100ca0 <kmonitor+0x3a>
char *buf;
while (1) {
if ((buf = readline("K> ")) != NULL) {
if (runcmd(buf, tf) < 0) {
break;
100cd0: 90 nop
}
}
}
}
100cd1: 90 nop
100cd2: c9 leave
100cd3: c3 ret
00100cd4 <mon_help>:
/* mon_help - print the information about mon_* functions */
int
mon_help(int argc, char **argv, struct trapframe *tf) {
100cd4: 55 push %ebp
100cd5: 89 e5 mov %esp,%ebp
100cd7: 83 ec 18 sub $0x18,%esp
int i;
for (i = 0; i < NCOMMANDS; i ++) {
100cda: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp)
100ce1: eb 3c jmp 100d1f <mon_help+0x4b>
cprintf("%s - %s\n", commands[i].name, commands[i].desc);
100ce3: 8b 55 f4 mov -0xc(%ebp),%edx
100ce6: 89 d0 mov %edx,%eax
100ce8: 01 c0 add %eax,%eax
100cea: 01 d0 add %edx,%eax
100cec: c1 e0 02 shl $0x2,%eax
100cef: 05 24 90 11 00 add $0x119024,%eax
100cf4: 8b 08 mov (%eax),%ecx
100cf6: 8b 55 f4 mov -0xc(%ebp),%edx
100cf9: 89 d0 mov %edx,%eax
100cfb: 01 c0 add %eax,%eax
100cfd: 01 d0 add %edx,%eax
100cff: c1 e0 02 shl $0x2,%eax
100d02: 05 20 90 11 00 add $0x119020,%eax
100d07: 8b 00 mov (%eax),%eax
100d09: 83 ec 04 sub $0x4,%esp
100d0c: 51 push %ecx
100d0d: 50 push %eax
100d0e: 68 f9 6b 10 00 push $0x106bf9
100d13: e8 4f f5 ff ff call 100267 <cprintf>
100d18: 83 c4 10 add $0x10,%esp
/* mon_help - print the information about mon_* functions */
int
mon_help(int argc, char **argv, struct trapframe *tf) {
int i;
for (i = 0; i < NCOMMANDS; i ++) {
100d1b: 83 45 f4 01 addl $0x1,-0xc(%ebp)
100d1f: 8b 45 f4 mov -0xc(%ebp),%eax
100d22: 83 f8 02 cmp $0x2,%eax
100d25: 76 bc jbe 100ce3 <mon_help+0xf>
cprintf("%s - %s\n", commands[i].name, commands[i].desc);
}
return 0;
100d27: b8 00 00 00 00 mov $0x0,%eax
}
100d2c: c9 leave
100d2d: c3 ret
00100d2e <mon_kerninfo>:
/* *
* mon_kerninfo - call print_kerninfo in kern/debug/kdebug.c to
* print the memory occupancy in kernel.
* */
int
mon_kerninfo(int argc, char **argv, struct trapframe *tf) {
100d2e: 55 push %ebp
100d2f: 89 e5 mov %esp,%ebp
100d31: 83 ec 08 sub $0x8,%esp
print_kerninfo();
100d34: e8 b8 fb ff ff call 1008f1 <print_kerninfo>
return 0;
100d39: b8 00 00 00 00 mov $0x0,%eax
}
100d3e: c9 leave
100d3f: c3 ret
00100d40 <mon_backtrace>:
/* *
* mon_backtrace - call print_stackframe in kern/debug/kdebug.c to
* print a backtrace of the stack.
* */
int
mon_backtrace(int argc, char **argv, struct trapframe *tf) {
100d40: 55 push %ebp
100d41: 89 e5 mov %esp,%ebp
100d43: 83 ec 08 sub $0x8,%esp
print_stackframe();
100d46: e8 f0 fc ff ff call 100a3b <print_stackframe>
return 0;
100d4b: b8 00 00 00 00 mov $0x0,%eax
}
100d50: c9 leave
100d51: c3 ret
00100d52 <clock_init>:
/* *
* clock_init - initialize 8253 clock to interrupt 100 times per second,
* and then enable IRQ_TIMER.
* */
void
clock_init(void) {
100d52: 55 push %ebp
100d53: 89 e5 mov %esp,%ebp
100d55: 83 ec 18 sub $0x18,%esp
100d58: 66 c7 45 f6 43 00 movw $0x43,-0xa(%ebp)
100d5e: c6 45 ef 34 movb $0x34,-0x11(%ebp)
: "memory", "cc");
}
static inline void
outb(uint16_t port, uint8_t data) {
asm volatile ("outb %0, %1" :: "a" (data), "d" (port) : "memory");
100d62: 0f b6 45 ef movzbl -0x11(%ebp),%eax
100d66: 0f b7 55 f6 movzwl -0xa(%ebp),%edx
100d6a: ee out %al,(%dx)
100d6b: 66 c7 45 f4 40 00 movw $0x40,-0xc(%ebp)
100d71: c6 45 f0 9c movb $0x9c,-0x10(%ebp)
100d75: 0f b6 45 f0 movzbl -0x10(%ebp),%eax
100d79: 0f b7 55 f4 movzwl -0xc(%ebp),%edx
100d7d: ee out %al,(%dx)
100d7e: 66 c7 45 f2 40 00 movw $0x40,-0xe(%ebp)
100d84: c6 45 f1 2e movb $0x2e,-0xf(%ebp)
100d88: 0f b6 45 f1 movzbl -0xf(%ebp),%eax
100d8c: 0f b7 55 f2 movzwl -0xe(%ebp),%edx
100d90: ee out %al,(%dx)
outb(TIMER_MODE, TIMER_SEL0 | TIMER_RATEGEN | TIMER_16BIT);
outb(IO_TIMER1, TIMER_DIV(100) % 256);
outb(IO_TIMER1, TIMER_DIV(100) / 256);
// initialize time counter 'ticks' to zero
ticks = 0;
100d91: c7 05 58 a9 11 00 00 movl $0x0,0x11a958
100d98: 00 00 00
cprintf("++ setup timer interrupts\n");
100d9b: 83 ec 0c sub $0xc,%esp
100d9e: 68 02 6c 10 00 push $0x106c02
100da3: e8 bf f4 ff ff call 100267 <cprintf>
100da8: 83 c4 10 add $0x10,%esp
pic_enable(IRQ_TIMER);
100dab: 83 ec 0c sub $0xc,%esp
100dae: 6a 00 push $0x0
100db0: e8 3b 09 00 00 call 1016f0 <pic_enable>
100db5: 83 c4 10 add $0x10,%esp
}
100db8: 90 nop
100db9: c9 leave
100dba: c3 ret
00100dbb <__intr_save>:
#include <x86.h>
#include <intr.h>
#include <mmu.h>
static inline bool
__intr_save(void) {
100dbb: 55 push %ebp
100dbc: 89 e5 mov %esp,%ebp
100dbe: 83 ec 18 sub $0x18,%esp
}
static inline uint32_t
read_eflags(void) {
uint32_t eflags;
asm volatile ("pushfl; popl %0" : "=r" (eflags));
100dc1: 9c pushf
100dc2: 58 pop %eax
100dc3: 89 45 f4 mov %eax,-0xc(%ebp)
return eflags;
100dc6: 8b 45 f4 mov -0xc(%ebp),%eax
if (read_eflags() & FL_IF) {
100dc9: 25 00 02 00 00 and $0x200,%eax
100dce: 85 c0 test %eax,%eax
100dd0: 74 0c je 100dde <__intr_save+0x23>
intr_disable();
100dd2: e8 8a 0a 00 00 call 101861 <intr_disable>
return 1;
100dd7: b8 01 00 00 00 mov $0x1,%eax
100ddc: eb 05 jmp 100de3 <__intr_save+0x28>
}
return 0;
100dde: b8 00 00 00 00 mov $0x0,%eax
}
100de3: c9 leave
100de4: c3 ret
00100de5 <__intr_restore>:
static inline void
__intr_restore(bool flag) {
100de5: 55 push %ebp
100de6: 89 e5 mov %esp,%ebp
100de8: 83 ec 08 sub $0x8,%esp
if (flag) {
100deb: 83 7d 08 00 cmpl $0x0,0x8(%ebp)
100def: 74 05 je 100df6 <__intr_restore+0x11>
intr_enable();
100df1: e8 64 0a 00 00 call 10185a <intr_enable>
}
}
100df6: 90 nop
100df7: c9 leave
100df8: c3 ret
00100df9 <delay>:
#include <memlayout.h>
#include <sync.h>
/* stupid I/O delay routine necessitated by historical PC design flaws */
static void
delay(void) {
100df9: 55 push %ebp
100dfa: 89 e5 mov %esp,%ebp
100dfc: 83 ec 10 sub $0x10,%esp
100dff: 66 c7 45 fe 84 00 movw $0x84,-0x2(%ebp)
static inline void invlpg(void *addr) __attribute__((always_inline));
static inline uint8_t
inb(uint16_t port) {
uint8_t data;
asm volatile ("inb %1, %0" : "=a" (data) : "d" (port) : "memory");
100e05: 0f b7 45 fe movzwl -0x2(%ebp),%eax
100e09: 89 c2 mov %eax,%edx
100e0b: ec in (%dx),%al
100e0c: 88 45 f4 mov %al,-0xc(%ebp)
100e0f: 66 c7 45 fc 84 00 movw $0x84,-0x4(%ebp)
100e15: 0f b7 45 fc movzwl -0x4(%ebp),%eax
100e19: 89 c2 mov %eax,%edx
100e1b: ec in (%dx),%al
100e1c: 88 45 f5 mov %al,-0xb(%ebp)
100e1f: 66 c7 45 fa 84 00 movw $0x84,-0x6(%ebp)
100e25: 0f b7 45 fa movzwl -0x6(%ebp),%eax
100e29: 89 c2 mov %eax,%edx
100e2b: ec in (%dx),%al
100e2c: 88 45 f6 mov %al,-0xa(%ebp)
100e2f: 66 c7 45 f8 84 00 movw $0x84,-0x8(%ebp)
100e35: 0f b7 45 f8 movzwl -0x8(%ebp),%eax
100e39: 89 c2 mov %eax,%edx
100e3b: ec in (%dx),%al
100e3c: 88 45 f7 mov %al,-0x9(%ebp)
inb(0x84);
inb(0x84);
inb(0x84);
inb(0x84);
}
100e3f: 90 nop
100e40: c9 leave
100e41: c3 ret
00100e42 <cga_init>:
static uint16_t addr_6845;
/* TEXT-mode CGA/VGA display output */
static void
cga_init(void) {
100e42: 55 push %ebp
100e43: 89 e5 mov %esp,%ebp
100e45: 83 ec 20 sub $0x20,%esp
volatile uint16_t *cp = (uint16_t *)(CGA_BUF + KERNBASE);
100e48: c7 45 fc 00 80 0b c0 movl $0xc00b8000,-0x4(%ebp)
uint16_t was = *cp;
100e4f: 8b 45 fc mov -0x4(%ebp),%eax
100e52: 0f b7 00 movzwl (%eax),%eax
100e55: 66 89 45 fa mov %ax,-0x6(%ebp)
*cp = (uint16_t) 0xA55A;
100e59: 8b 45 fc mov -0x4(%ebp),%eax
100e5c: 66 c7 00 5a a5 movw $0xa55a,(%eax)
if (*cp != 0xA55A) {
100e61: 8b 45 fc mov -0x4(%ebp),%eax
100e64: 0f b7 00 movzwl (%eax),%eax
100e67: 66 3d 5a a5 cmp $0xa55a,%ax
100e6b: 74 12 je 100e7f <cga_init+0x3d>
cp = (uint16_t*)(MONO_BUF + KERNBASE);
100e6d: c7 45 fc 00 00 0b c0 movl $0xc00b0000,-0x4(%ebp)
addr_6845 = MONO_BASE;
100e74: 66 c7 05 86 9e 11 00 movw $0x3b4,0x119e86
100e7b: b4 03
100e7d: eb 13 jmp 100e92 <cga_init+0x50>
} else {
*cp = was;
100e7f: 8b 45 fc mov -0x4(%ebp),%eax
100e82: 0f b7 55 fa movzwl -0x6(%ebp),%edx
100e86: 66 89 10 mov %dx,(%eax)
addr_6845 = CGA_BASE;
100e89: 66 c7 05 86 9e 11 00 movw $0x3d4,0x119e86
100e90: d4 03
}
// Extract cursor location
uint32_t pos;
outb(addr_6845, 14);
100e92: 0f b7 05 86 9e 11 00 movzwl 0x119e86,%eax
100e99: 0f b7 c0 movzwl %ax,%eax
100e9c: 66 89 45 f8 mov %ax,-0x8(%ebp)
100ea0: c6 45 ea 0e movb $0xe,-0x16(%ebp)
: "memory", "cc");
}
static inline void
outb(uint16_t port, uint8_t data) {
asm volatile ("outb %0, %1" :: "a" (data), "d" (port) : "memory");
100ea4: 0f b6 45 ea movzbl -0x16(%ebp),%eax
100ea8: 0f b7 55 f8 movzwl -0x8(%ebp),%edx
100eac: ee out %al,(%dx)
pos = inb(addr_6845 + 1) << 8;
100ead: 0f b7 05 86 9e 11 00 movzwl 0x119e86,%eax
100eb4: 83 c0 01 add $0x1,%eax
100eb7: 0f b7 c0 movzwl %ax,%eax
100eba: 66 89 45 f2 mov %ax,-0xe(%ebp)
static inline void invlpg(void *addr) __attribute__((always_inline));
static inline uint8_t
inb(uint16_t port) {
uint8_t data;
asm volatile ("inb %1, %0" : "=a" (data) : "d" (port) : "memory");
100ebe: 0f b7 45 f2 movzwl -0xe(%ebp),%eax
100ec2: 89 c2 mov %eax,%edx
100ec4: ec in (%dx),%al
100ec5: 88 45 eb mov %al,-0x15(%ebp)
return data;
100ec8: 0f b6 45 eb movzbl -0x15(%ebp),%eax
100ecc: 0f b6 c0 movzbl %al,%eax
100ecf: c1 e0 08 shl $0x8,%eax
100ed2: 89 45 f4 mov %eax,-0xc(%ebp)
outb(addr_6845, 15);
100ed5: 0f b7 05 86 9e 11 00 movzwl 0x119e86,%eax
100edc: 0f b7 c0 movzwl %ax,%eax
100edf: 66 89 45 f0 mov %ax,-0x10(%ebp)
100ee3: c6 45 ec 0f movb $0xf,-0x14(%ebp)
: "memory", "cc");
}
static inline void
outb(uint16_t port, uint8_t data) {
asm volatile ("outb %0, %1" :: "a" (data), "d" (port) : "memory");
100ee7: 0f b6 45 ec movzbl -0x14(%ebp),%eax
100eeb: 0f b7 55 f0 movzwl -0x10(%ebp),%edx
100eef: ee out %al,(%dx)
pos |= inb(addr_6845 + 1);
100ef0: 0f b7 05 86 9e 11 00 movzwl 0x119e86,%eax
100ef7: 83 c0 01 add $0x1,%eax
100efa: 0f b7 c0 movzwl %ax,%eax
100efd: 66 89 45 ee mov %ax,-0x12(%ebp)
static inline void invlpg(void *addr) __attribute__((always_inline));
static inline uint8_t
inb(uint16_t port) {
uint8_t data;
asm volatile ("inb %1, %0" : "=a" (data) : "d" (port) : "memory");
100f01: 0f b7 45 ee movzwl -0x12(%ebp),%eax
100f05: 89 c2 mov %eax,%edx
100f07: ec in (%dx),%al
100f08: 88 45 ed mov %al,-0x13(%ebp)
return data;
100f0b: 0f b6 45 ed movzbl -0x13(%ebp),%eax
100f0f: 0f b6 c0 movzbl %al,%eax
100f12: 09 45 f4 or %eax,-0xc(%ebp)
crt_buf = (uint16_t*) cp;
100f15: 8b 45 fc mov -0x4(%ebp),%eax
100f18: a3 80 9e 11 00 mov %eax,0x119e80
crt_pos = pos;
100f1d: 8b 45 f4 mov -0xc(%ebp),%eax
100f20: 66 a3 84 9e 11 00 mov %ax,0x119e84
}
100f26: 90 nop
100f27: c9 leave
100f28: c3 ret
00100f29 <serial_init>:
static bool serial_exists = 0;
static void
serial_init(void) {
100f29: 55 push %ebp
100f2a: 89 e5 mov %esp,%ebp
100f2c: 83 ec 28 sub $0x28,%esp
100f2f: 66 c7 45 f6 fa 03 movw $0x3fa,-0xa(%ebp)
100f35: c6 45 da 00 movb $0x0,-0x26(%ebp)
: "memory", "cc");
}
static inline void
outb(uint16_t port, uint8_t data) {
asm volatile ("outb %0, %1" :: "a" (data), "d" (port) : "memory");
100f39: 0f b6 45 da movzbl -0x26(%ebp),%eax
100f3d: 0f b7 55 f6 movzwl -0xa(%ebp),%edx
100f41: ee out %al,(%dx)
100f42: 66 c7 45 f4 fb 03 movw $0x3fb,-0xc(%ebp)
100f48: c6 45 db 80 movb $0x80,-0x25(%ebp)
100f4c: 0f b6 45 db movzbl -0x25(%ebp),%eax
100f50: 0f b7 55 f4 movzwl -0xc(%ebp),%edx
100f54: ee out %al,(%dx)
100f55: 66 c7 45 f2 f8 03 movw $0x3f8,-0xe(%ebp)
100f5b: c6 45 dc 0c movb $0xc,-0x24(%ebp)
100f5f: 0f b6 45 dc movzbl -0x24(%ebp),%eax
100f63: 0f b7 55 f2 movzwl -0xe(%ebp),%edx
100f67: ee out %al,(%dx)
100f68: 66 c7 45 f0 f9 03 movw $0x3f9,-0x10(%ebp)
100f6e: c6 45 dd 00 movb $0x0,-0x23(%ebp)
100f72: 0f b6 45 dd movzbl -0x23(%ebp),%eax
100f76: 0f b7 55 f0 movzwl -0x10(%ebp),%edx
100f7a: ee out %al,(%dx)
100f7b: 66 c7 45 ee fb 03 movw $0x3fb,-0x12(%ebp)
100f81: c6 45 de 03 movb $0x3,-0x22(%ebp)
100f85: 0f b6 45 de movzbl -0x22(%ebp),%eax
100f89: 0f b7 55 ee movzwl -0x12(%ebp),%edx
100f8d: ee out %al,(%dx)
100f8e: 66 c7 45 ec fc 03 movw $0x3fc,-0x14(%ebp)
100f94: c6 45 df 00 movb $0x0,-0x21(%ebp)
100f98: 0f b6 45 df movzbl -0x21(%ebp),%eax
100f9c: 0f b7 55 ec movzwl -0x14(%ebp),%edx
100fa0: ee out %al,(%dx)
100fa1: 66 c7 45 ea f9 03 movw $0x3f9,-0x16(%ebp)
100fa7: c6 45 e0 01 movb $0x1,-0x20(%ebp)
100fab: 0f b6 45 e0 movzbl -0x20(%ebp),%eax
100faf: 0f b7 55 ea movzwl -0x16(%ebp),%edx
100fb3: ee out %al,(%dx)
100fb4: 66 c7 45 e8 fd 03 movw $0x3fd,-0x18(%ebp)
static inline void invlpg(void *addr) __attribute__((always_inline));
static inline uint8_t
inb(uint16_t port) {
uint8_t data;
asm volatile ("inb %1, %0" : "=a" (data) : "d" (port) : "memory");
100fba: 0f b7 45 e8 movzwl -0x18(%ebp),%eax
100fbe: 89 c2 mov %eax,%edx
100fc0: ec in (%dx),%al
100fc1: 88 45 e1 mov %al,-0x1f(%ebp)
return data;
100fc4: 0f b6 45 e1 movzbl -0x1f(%ebp),%eax
// Enable rcv interrupts
outb(COM1 + COM_IER, COM_IER_RDI);
// Clear any preexisting overrun indications and interrupts
// Serial port doesn't exist if COM_LSR returns 0xFF
serial_exists = (inb(COM1 + COM_LSR) != 0xFF);
100fc8: 3c ff cmp $0xff,%al
100fca: 0f 95 c0 setne %al
100fcd: 0f b6 c0 movzbl %al,%eax
100fd0: a3 88 9e 11 00 mov %eax,0x119e88
100fd5: 66 c7 45 e6 fa 03 movw $0x3fa,-0x1a(%ebp)
static inline void invlpg(void *addr) __attribute__((always_inline));
static inline uint8_t
inb(uint16_t port) {
uint8_t data;
asm volatile ("inb %1, %0" : "=a" (data) : "d" (port) : "memory");
100fdb: 0f b7 45 e6 movzwl -0x1a(%ebp),%eax
100fdf: 89 c2 mov %eax,%edx
100fe1: ec in (%dx),%al
100fe2: 88 45 e2 mov %al,-0x1e(%ebp)
100fe5: 66 c7 45 e4 f8 03 movw $0x3f8,-0x1c(%ebp)
100feb: 0f b7 45 e4 movzwl -0x1c(%ebp),%eax
100fef: 89 c2 mov %eax,%edx
100ff1: ec in (%dx),%al
100ff2: 88 45 e3 mov %al,-0x1d(%ebp)
(void) inb(COM1+COM_IIR);
(void) inb(COM1+COM_RX);
if (serial_exists) {
100ff5: a1 88 9e 11 00 mov 0x119e88,%eax
100ffa: 85 c0 test %eax,%eax
100ffc: 74 0d je 10100b <serial_init+0xe2>
pic_enable(IRQ_COM1);
100ffe: 83 ec 0c sub $0xc,%esp
101001: 6a 04 push $0x4
101003: e8 e8 06 00 00 call 1016f0 <pic_enable>
101008: 83 c4 10 add $0x10,%esp
}
}
10100b: 90 nop
10100c: c9 leave
10100d: c3 ret
0010100e <lpt_putc_sub>:
static void
lpt_putc_sub(int c) {
10100e: 55 push %ebp
10100f: 89 e5 mov %esp,%ebp
101011: 83 ec 10 sub $0x10,%esp
int i;
for (i = 0; !(inb(LPTPORT + 1) & 0x80) && i < 12800; i ++) {
101014: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%ebp)
10101b: eb 09 jmp 101026 <lpt_putc_sub+0x18>
delay();
10101d: e8 d7 fd ff ff call 100df9 <delay>
}
static void
lpt_putc_sub(int c) {
int i;
for (i = 0; !(inb(LPTPORT + 1) & 0x80) && i < 12800; i ++) {
101022: 83 45 fc 01 addl $0x1,-0x4(%ebp)
101026: 66 c7 45 f4 79 03 movw $0x379,-0xc(%ebp)
10102c: 0f b7 45 f4 movzwl -0xc(%ebp),%eax
101030: 89 c2 mov %eax,%edx
101032: ec in (%dx),%al
101033: 88 45 f3 mov %al,-0xd(%ebp)
return data;
101036: 0f b6 45 f3 movzbl -0xd(%ebp),%eax
10103a: 84 c0 test %al,%al
10103c: 78 09 js 101047 <lpt_putc_sub+0x39>
10103e: 81 7d fc ff 31 00 00 cmpl $0x31ff,-0x4(%ebp)
101045: 7e d6 jle 10101d <lpt_putc_sub+0xf>
delay();
}
outb(LPTPORT + 0, c);
101047: 8b 45 08 mov 0x8(%ebp),%eax
10104a: 0f b6 c0 movzbl %al,%eax
10104d: 66 c7 45 f8 78 03 movw $0x378,-0x8(%ebp)
101053: 88 45 f0 mov %al,-0x10(%ebp)
: "memory", "cc");
}
static inline void
outb(uint16_t port, uint8_t data) {
asm volatile ("outb %0, %1" :: "a" (data), "d" (port) : "memory");
101056: 0f b6 45 f0 movzbl -0x10(%ebp),%eax
10105a: 0f b7 55 f8 movzwl -0x8(%ebp),%edx
10105e: ee out %al,(%dx)
10105f: 66 c7 45 f6 7a 03 movw $0x37a,-0xa(%ebp)
101065: c6 45 f1 0d movb $0xd,-0xf(%ebp)
101069: 0f b6 45 f1 movzbl -0xf(%ebp),%eax
10106d: 0f b7 55 f6 movzwl -0xa(%ebp),%edx
101071: ee out %al,(%dx)
101072: 66 c7 45 fa 7a 03 movw $0x37a,-0x6(%ebp)
101078: c6 45 f2 08 movb $0x8,-0xe(%ebp)
10107c: 0f b6 45 f2 movzbl -0xe(%ebp),%eax
101080: 0f b7 55 fa movzwl -0x6(%ebp),%edx
101084: ee out %al,(%dx)
outb(LPTPORT + 2, 0x08 | 0x04 | 0x01);
outb(LPTPORT + 2, 0x08);
}
101085: 90 nop
101086: c9 leave
101087: c3 ret
00101088 <lpt_putc>:
/* lpt_putc - copy console output to parallel port */
static void
lpt_putc(int c) {
101088: 55 push %ebp
101089: 89 e5 mov %esp,%ebp
if (c != '\b') {
10108b: 83 7d 08 08 cmpl $0x8,0x8(%ebp)
10108f: 74 0d je 10109e <lpt_putc+0x16>
lpt_putc_sub(c);
101091: ff 75 08 pushl 0x8(%ebp)
101094: e8 75 ff ff ff call 10100e <lpt_putc_sub>
101099: 83 c4 04 add $0x4,%esp
else {
lpt_putc_sub('\b');
lpt_putc_sub(' ');
lpt_putc_sub('\b');
}
}
10109c: eb 1e jmp 1010bc <lpt_putc+0x34>
lpt_putc(int c) {
if (c != '\b') {
lpt_putc_sub(c);
}
else {
lpt_putc_sub('\b');
10109e: 6a 08 push $0x8
1010a0: e8 69 ff ff ff call 10100e <lpt_putc_sub>
1010a5: 83 c4 04 add $0x4,%esp
lpt_putc_sub(' ');
1010a8: 6a 20 push $0x20
1010aa: e8 5f ff ff ff call 10100e <lpt_putc_sub>
1010af: 83 c4 04 add $0x4,%esp
lpt_putc_sub('\b');
1010b2: 6a 08 push $0x8
1010b4: e8 55 ff ff ff call 10100e <lpt_putc_sub>
1010b9: 83 c4 04 add $0x4,%esp
}
}
1010bc: 90 nop
1010bd: c9 leave
1010be: c3 ret
001010bf <cga_putc>:
/* cga_putc - print character to console */
static void
cga_putc(int c) {
1010bf: 55 push %ebp
1010c0: 89 e5 mov %esp,%ebp
1010c2: 53 push %ebx
1010c3: 83 ec 14 sub $0x14,%esp
// set black on white
if (!(c & ~0xFF)) {
1010c6: 8b 45 08 mov 0x8(%ebp),%eax
1010c9: b0 00 mov $0x0,%al
1010cb: 85 c0 test %eax,%eax
1010cd: 75 07 jne 1010d6 <cga_putc+0x17>
c |= 0x0700;
1010cf: 81 4d 08 00 07 00 00 orl $0x700,0x8(%ebp)
}
switch (c & 0xff) {
1010d6: 8b 45 08 mov 0x8(%ebp),%eax
1010d9: 0f b6 c0 movzbl %al,%eax
1010dc: 83 f8 0a cmp $0xa,%eax
1010df: 74 4e je 10112f <cga_putc+0x70>
1010e1: 83 f8 0d cmp $0xd,%eax
1010e4: 74 59 je 10113f <cga_putc+0x80>
1010e6: 83 f8 08 cmp $0x8,%eax
1010e9: 0f 85 8a 00 00 00 jne 101179 <cga_putc+0xba>
case '\b':
if (crt_pos > 0) {
1010ef: 0f b7 05 84 9e 11 00 movzwl 0x119e84,%eax
1010f6: 66 85 c0 test %ax,%ax
1010f9: 0f 84 a0 00 00 00 je 10119f <cga_putc+0xe0>
crt_pos --;
1010ff: 0f b7 05 84 9e 11 00 movzwl 0x119e84,%eax
101106: 83 e8 01 sub $0x1,%eax
101109: 66 a3 84 9e 11 00 mov %ax,0x119e84
crt_buf[crt_pos] = (c & ~0xff) | ' ';
10110f: a1 80 9e 11 00 mov 0x119e80,%eax
101114: 0f b7 15 84 9e 11 00 movzwl 0x119e84,%edx
10111b: 0f b7 d2 movzwl %dx,%edx
10111e: 01 d2 add %edx,%edx
101120: 01 d0 add %edx,%eax
101122: 8b 55 08 mov 0x8(%ebp),%edx
101125: b2 00 mov $0x0,%dl
101127: 83 ca 20 or $0x20,%edx
10112a: 66 89 10 mov %dx,(%eax)
}
break;
10112d: eb 70 jmp 10119f <cga_putc+0xe0>
case '\n':
crt_pos += CRT_COLS;
10112f: 0f b7 05 84 9e 11 00 movzwl 0x119e84,%eax
101136: 83 c0 50 add $0x50,%eax
101139: 66 a3 84 9e 11 00 mov %ax,0x119e84
case '\r':
crt_pos -= (crt_pos % CRT_COLS);
10113f: 0f b7 1d 84 9e 11 00 movzwl 0x119e84,%ebx
101146: 0f b7 0d 84 9e 11 00 movzwl 0x119e84,%ecx
10114d: 0f b7 c1 movzwl %cx,%eax
101150: 69 c0 cd cc 00 00 imul $0xcccd,%eax,%eax
101156: c1 e8 10 shr $0x10,%eax
101159: 89 c2 mov %eax,%edx
10115b: 66 c1 ea 06 shr $0x6,%dx
10115f: 89 d0 mov %edx,%eax
101161: c1 e0 02 shl $0x2,%eax
101164: 01 d0 add %edx,%eax
101166: c1 e0 04 shl $0x4,%eax
101169: 29 c1 sub %eax,%ecx
10116b: 89 ca mov %ecx,%edx
10116d: 89 d8 mov %ebx,%eax
10116f: 29 d0 sub %edx,%eax
101171: 66 a3 84 9e 11 00 mov %ax,0x119e84
break;
101177: eb 27 jmp 1011a0 <cga_putc+0xe1>
default:
crt_buf[crt_pos ++] = c; // write the character
101179: 8b 0d 80 9e 11 00 mov 0x119e80,%ecx
10117f: 0f b7 05 84 9e 11 00 movzwl 0x119e84,%eax
101186: 8d 50 01 lea 0x1(%eax),%edx
101189: 66 89 15 84 9e 11 00 mov %dx,0x119e84
101190: 0f b7 c0 movzwl %ax,%eax
101193: 01 c0 add %eax,%eax
101195: 01 c8 add %ecx,%eax
101197: 8b 55 08 mov 0x8(%ebp),%edx
10119a: 66 89 10 mov %dx,(%eax)
break;
10119d: eb 01 jmp 1011a0 <cga_putc+0xe1>
case '\b':
if (crt_pos > 0) {
crt_pos --;
crt_buf[crt_pos] = (c & ~0xff) | ' ';
}
break;
10119f: 90 nop
crt_buf[crt_pos ++] = c; // write the character
break;
}
// What is the purpose of this?
if (crt_pos >= CRT_SIZE) {
1011a0: 0f b7 05 84 9e 11 00 movzwl 0x119e84,%eax
1011a7: 66 3d cf 07 cmp $0x7cf,%ax
1011ab: 76 59 jbe 101206 <cga_putc+0x147>
int i;
memmove(crt_buf, crt_buf + CRT_COLS, (CRT_SIZE - CRT_COLS) * sizeof(uint16_t));
1011ad: a1 80 9e 11 00 mov 0x119e80,%eax
1011b2: 8d 90 a0 00 00 00 lea 0xa0(%eax),%edx
1011b8: a1 80 9e 11 00 mov 0x119e80,%eax
1011bd: 83 ec 04 sub $0x4,%esp
1011c0: 68 00 0f 00 00 push $0xf00
1011c5: 52 push %edx
1011c6: 50 push %eax
1011c7: e8 db 4f 00 00 call 1061a7 <memmove>
1011cc: 83 c4 10 add $0x10,%esp
for (i = CRT_SIZE - CRT_COLS; i < CRT_SIZE; i ++) {
1011cf: c7 45 f4 80 07 00 00 movl $0x780,-0xc(%ebp)
1011d6: eb 15 jmp 1011ed <cga_putc+0x12e>
crt_buf[i] = 0x0700 | ' ';
1011d8: a1 80 9e 11 00 mov 0x119e80,%eax
1011dd: 8b 55 f4 mov -0xc(%ebp),%edx
1011e0: 01 d2 add %edx,%edx
1011e2: 01 d0 add %edx,%eax
1011e4: 66 c7 00 20 07 movw $0x720,(%eax)
// What is the purpose of this?
if (crt_pos >= CRT_SIZE) {
int i;
memmove(crt_buf, crt_buf + CRT_COLS, (CRT_SIZE - CRT_COLS) * sizeof(uint16_t));
for (i = CRT_SIZE - CRT_COLS; i < CRT_SIZE; i ++) {
1011e9: 83 45 f4 01 addl $0x1,-0xc(%ebp)
1011ed: 81 7d f4 cf 07 00 00 cmpl $0x7cf,-0xc(%ebp)
1011f4: 7e e2 jle 1011d8 <cga_putc+0x119>
crt_buf[i] = 0x0700 | ' ';
}
crt_pos -= CRT_COLS;
1011f6: 0f b7 05 84 9e 11 00 movzwl 0x119e84,%eax
1011fd: 83 e8 50 sub $0x50,%eax
101200: 66 a3 84 9e 11 00 mov %ax,0x119e84
}
// move that little blinky thing
outb(addr_6845, 14);
101206: 0f b7 05 86 9e 11 00 movzwl 0x119e86,%eax
10120d: 0f b7 c0 movzwl %ax,%eax
101210: 66 89 45 f2 mov %ax,-0xe(%ebp)
101214: c6 45 e8 0e movb $0xe,-0x18(%ebp)
101218: 0f b6 45 e8 movzbl -0x18(%ebp),%eax
10121c: 0f b7 55 f2 movzwl -0xe(%ebp),%edx
101220: ee out %al,(%dx)
outb(addr_6845 + 1, crt_pos >> 8);
101221: 0f b7 05 84 9e 11 00 movzwl 0x119e84,%eax
101228: 66 c1 e8 08 shr $0x8,%ax
10122c: 0f b6 c0 movzbl %al,%eax
10122f: 0f b7 15 86 9e 11 00 movzwl 0x119e86,%edx
101236: 83 c2 01 add $0x1,%edx
101239: 0f b7 d2 movzwl %dx,%edx
10123c: 66 89 55 f0 mov %dx,-0x10(%ebp)
101240: 88 45 e9 mov %al,-0x17(%ebp)
101243: 0f b6 45 e9 movzbl -0x17(%ebp),%eax
101247: 0f b7 55 f0 movzwl -0x10(%ebp),%edx
10124b: ee out %al,(%dx)
outb(addr_6845, 15);
10124c: 0f b7 05 86 9e 11 00 movzwl 0x119e86,%eax
101253: 0f b7 c0 movzwl %ax,%eax
101256: 66 89 45 ee mov %ax,-0x12(%ebp)
10125a: c6 45 ea 0f movb $0xf,-0x16(%ebp)
10125e: 0f b6 45 ea movzbl -0x16(%ebp),%eax
101262: 0f b7 55 ee movzwl -0x12(%ebp),%edx
101266: ee out %al,(%dx)
outb(addr_6845 + 1, crt_pos);
101267: 0f b7 05 84 9e 11 00 movzwl 0x119e84,%eax
10126e: 0f b6 c0 movzbl %al,%eax
101271: 0f b7 15 86 9e 11 00 movzwl 0x119e86,%edx
101278: 83 c2 01 add $0x1,%edx
10127b: 0f b7 d2 movzwl %dx,%edx
10127e: 66 89 55 ec mov %dx,-0x14(%ebp)
101282: 88 45 eb mov %al,-0x15(%ebp)
101285: 0f b6 45 eb movzbl -0x15(%ebp),%eax
101289: 0f b7 55 ec movzwl -0x14(%ebp),%edx
10128d: ee out %al,(%dx)
}
10128e: 90 nop
10128f: 8b 5d fc mov -0x4(%ebp),%ebx
101292: c9 leave
101293: c3 ret
00101294 <serial_putc_sub>:
static void
serial_putc_sub(int c) {
101294: 55 push %ebp
101295: 89 e5 mov %esp,%ebp
101297: 83 ec 10 sub $0x10,%esp
int i;
for (i = 0; !(inb(COM1 + COM_LSR) & COM_LSR_TXRDY) && i < 12800; i ++) {
10129a: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%ebp)
1012a1: eb 09 jmp 1012ac <serial_putc_sub+0x18>
delay();
1012a3: e8 51 fb ff ff call 100df9 <delay>
}
static void
serial_putc_sub(int c) {
int i;
for (i = 0; !(inb(COM1 + COM_LSR) & COM_LSR_TXRDY) && i < 12800; i ++) {
1012a8: 83 45 fc 01 addl $0x1,-0x4(%ebp)
1012ac: 66 c7 45 f8 fd 03 movw $0x3fd,-0x8(%ebp)
static inline void invlpg(void *addr) __attribute__((always_inline));
static inline uint8_t
inb(uint16_t port) {
uint8_t data;
asm volatile ("inb %1, %0" : "=a" (data) : "d" (port) : "memory");
1012b2: 0f b7 45 f8 movzwl -0x8(%ebp),%eax
1012b6: 89 c2 mov %eax,%edx
1012b8: ec in (%dx),%al
1012b9: 88 45 f7 mov %al,-0x9(%ebp)
return data;
1012bc: 0f b6 45 f7 movzbl -0x9(%ebp),%eax
1012c0: 0f b6 c0 movzbl %al,%eax
1012c3: 83 e0 20 and $0x20,%eax
1012c6: 85 c0 test %eax,%eax
1012c8: 75 09 jne 1012d3 <serial_putc_sub+0x3f>
1012ca: 81 7d fc ff 31 00 00 cmpl $0x31ff,-0x4(%ebp)
1012d1: 7e d0 jle 1012a3 <serial_putc_sub+0xf>
delay();
}
outb(COM1 + COM_TX, c);
1012d3: 8b 45 08 mov 0x8(%ebp),%eax
1012d6: 0f b6 c0 movzbl %al,%eax
1012d9: 66 c7 45 fa f8 03 movw $0x3f8,-0x6(%ebp)
1012df: 88 45 f6 mov %al,-0xa(%ebp)
: "memory", "cc");
}
static inline void
outb(uint16_t port, uint8_t data) {
asm volatile ("outb %0, %1" :: "a" (data), "d" (port) : "memory");
1012e2: 0f b6 45 f6 movzbl -0xa(%ebp),%eax
1012e6: 0f b7 55 fa movzwl -0x6(%ebp),%edx
1012ea: ee out %al,(%dx)
}
1012eb: 90 nop
1012ec: c9 leave
1012ed: c3 ret
001012ee <serial_putc>:
/* serial_putc - print character to serial port */
static void
serial_putc(int c) {
1012ee: 55 push %ebp
1012ef: 89 e5 mov %esp,%ebp
if (c != '\b') {
1012f1: 83 7d 08 08 cmpl $0x8,0x8(%ebp)
1012f5: 74 0d je 101304 <serial_putc+0x16>
serial_putc_sub(c);
1012f7: ff 75 08 pushl 0x8(%ebp)
1012fa: e8 95 ff ff ff call 101294 <serial_putc_sub>
1012ff: 83 c4 04 add $0x4,%esp
else {
serial_putc_sub('\b');
serial_putc_sub(' ');
serial_putc_sub('\b');
}
}
101302: eb 1e jmp 101322 <serial_putc+0x34>
serial_putc(int c) {
if (c != '\b') {
serial_putc_sub(c);
}
else {
serial_putc_sub('\b');
101304: 6a 08 push $0x8
101306: e8 89 ff ff ff call 101294 <serial_putc_sub>
10130b: 83 c4 04 add $0x4,%esp
serial_putc_sub(' ');
10130e: 6a 20 push $0x20
101310: e8 7f ff ff ff call 101294 <serial_putc_sub>
101315: 83 c4 04 add $0x4,%esp
serial_putc_sub('\b');
101318: 6a 08 push $0x8
10131a: e8 75 ff ff ff call 101294 <serial_putc_sub>
10131f: 83 c4 04 add $0x4,%esp
}
}
101322: 90 nop
101323: c9 leave
101324: c3 ret
00101325 <cons_intr>:
/* *
* cons_intr - called by device interrupt routines to feed input
* characters into the circular console input buffer.
* */
static void
cons_intr(int (*proc)(void)) {
101325: 55 push %ebp
101326: 89 e5 mov %esp,%ebp
101328: 83 ec 18 sub $0x18,%esp
int c;
while ((c = (*proc)()) != -1) {
10132b: eb 33 jmp 101360 <cons_intr+0x3b>
if (c != 0) {
10132d: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
101331: 74 2d je 101360 <cons_intr+0x3b>
cons.buf[cons.wpos ++] = c;
101333: a1 a4 a0 11 00 mov 0x11a0a4,%eax
101338: 8d 50 01 lea 0x1(%eax),%edx
10133b: 89 15 a4 a0 11 00 mov %edx,0x11a0a4
101341: 8b 55 f4 mov -0xc(%ebp),%edx
101344: 88 90 a0 9e 11 00 mov %dl,0x119ea0(%eax)
if (cons.wpos == CONSBUFSIZE) {
10134a: a1 a4 a0 11 00 mov 0x11a0a4,%eax
10134f: 3d 00 02 00 00 cmp $0x200,%eax
101354: 75 0a jne 101360 <cons_intr+0x3b>
cons.wpos = 0;
101356: c7 05 a4 a0 11 00 00 movl $0x0,0x11a0a4
10135d: 00 00 00
* characters into the circular console input buffer.
* */
static void
cons_intr(int (*proc)(void)) {
int c;
while ((c = (*proc)()) != -1) {
101360: 8b 45 08 mov 0x8(%ebp),%eax
101363: ff d0 call *%eax
101365: 89 45 f4 mov %eax,-0xc(%ebp)
101368: 83 7d f4 ff cmpl $0xffffffff,-0xc(%ebp)
10136c: 75 bf jne 10132d <cons_intr+0x8>
if (cons.wpos == CONSBUFSIZE) {
cons.wpos = 0;
}
}
}
}
10136e: 90 nop
10136f: c9 leave
101370: c3 ret
00101371 <serial_proc_data>:
/* serial_proc_data - get data from serial port */
static int
serial_proc_data(void) {
101371: 55 push %ebp
101372: 89 e5 mov %esp,%ebp
101374: 83 ec 10 sub $0x10,%esp
101377: 66 c7 45 f8 fd 03 movw $0x3fd,-0x8(%ebp)
static inline void invlpg(void *addr) __attribute__((always_inline));
static inline uint8_t
inb(uint16_t port) {
uint8_t data;
asm volatile ("inb %1, %0" : "=a" (data) : "d" (port) : "memory");
10137d: 0f b7 45 f8 movzwl -0x8(%ebp),%eax
101381: 89 c2 mov %eax,%edx
101383: ec in (%dx),%al
101384: 88 45 f7 mov %al,-0x9(%ebp)
return data;
101387: 0f b6 45 f7 movzbl -0x9(%ebp),%eax
if (!(inb(COM1 + COM_LSR) & COM_LSR_DATA)) {
10138b: 0f b6 c0 movzbl %al,%eax
10138e: 83 e0 01 and $0x1,%eax
101391: 85 c0 test %eax,%eax
101393: 75 07 jne 10139c <serial_proc_data+0x2b>
return -1;
101395: b8 ff ff ff ff mov $0xffffffff,%eax
10139a: eb 2a jmp 1013c6 <serial_proc_data+0x55>
10139c: 66 c7 45 fa f8 03 movw $0x3f8,-0x6(%ebp)
static inline void invlpg(void *addr) __attribute__((always_inline));
static inline uint8_t
inb(uint16_t port) {
uint8_t data;
asm volatile ("inb %1, %0" : "=a" (data) : "d" (port) : "memory");
1013a2: 0f b7 45 fa movzwl -0x6(%ebp),%eax
1013a6: 89 c2 mov %eax,%edx
1013a8: ec in (%dx),%al
1013a9: 88 45 f6 mov %al,-0xa(%ebp)
return data;
1013ac: 0f b6 45 f6 movzbl -0xa(%ebp),%eax
}
int c = inb(COM1 + COM_RX);
1013b0: 0f b6 c0 movzbl %al,%eax
1013b3: 89 45 fc mov %eax,-0x4(%ebp)
if (c == 127) {
1013b6: 83 7d fc 7f cmpl $0x7f,-0x4(%ebp)
1013ba: 75 07 jne 1013c3 <serial_proc_data+0x52>
c = '\b';
1013bc: c7 45 fc 08 00 00 00 movl $0x8,-0x4(%ebp)
}
return c;
1013c3: 8b 45 fc mov -0x4(%ebp),%eax
}
1013c6: c9 leave
1013c7: c3 ret
001013c8 <serial_intr>:
/* serial_intr - try to feed input characters from serial port */
void
serial_intr(void) {
1013c8: 55 push %ebp
1013c9: 89 e5 mov %esp,%ebp
1013cb: 83 ec 08 sub $0x8,%esp
if (serial_exists) {
1013ce: a1 88 9e 11 00 mov 0x119e88,%eax
1013d3: 85 c0 test %eax,%eax
1013d5: 74 10 je 1013e7 <serial_intr+0x1f>
cons_intr(serial_proc_data);
1013d7: 83 ec 0c sub $0xc,%esp
1013da: 68 71 13 10 00 push $0x101371
1013df: e8 41 ff ff ff call 101325 <cons_intr>
1013e4: 83 c4 10 add $0x10,%esp
}
}
1013e7: 90 nop
1013e8: c9 leave
1013e9: c3 ret
001013ea <kbd_proc_data>:
*
* The kbd_proc_data() function gets data from the keyboard.
* If we finish a character, return it, else 0. And return -1 if no data.
* */
static int
kbd_proc_data(void) {
1013ea: 55 push %ebp
1013eb: 89 e5 mov %esp,%ebp
1013ed: 83 ec 18 sub $0x18,%esp
1013f0: 66 c7 45 ec 64 00 movw $0x64,-0x14(%ebp)
static inline void invlpg(void *addr) __attribute__((always_inline));
static inline uint8_t
inb(uint16_t port) {
uint8_t data;
asm volatile ("inb %1, %0" : "=a" (data) : "d" (port) : "memory");
1013f6: 0f b7 45 ec movzwl -0x14(%ebp),%eax
1013fa: 89 c2 mov %eax,%edx
1013fc: ec in (%dx),%al
1013fd: 88 45 eb mov %al,-0x15(%ebp)
return data;
101400: 0f b6 45 eb movzbl -0x15(%ebp),%eax
int c;
uint8_t data;
static uint32_t shift;
if ((inb(KBSTATP) & KBS_DIB) == 0) {
101404: 0f b6 c0 movzbl %al,%eax
101407: 83 e0 01 and $0x1,%eax
10140a: 85 c0 test %eax,%eax
10140c: 75 0a jne 101418 <kbd_proc_data+0x2e>
return -1;
10140e: b8 ff ff ff ff mov $0xffffffff,%eax
101413: e9 5d 01 00 00 jmp 101575 <kbd_proc_data+0x18b>
101418: 66 c7 45 f0 60 00 movw $0x60,-0x10(%ebp)
static inline void invlpg(void *addr) __attribute__((always_inline));
static inline uint8_t
inb(uint16_t port) {
uint8_t data;
asm volatile ("inb %1, %0" : "=a" (data) : "d" (port) : "memory");
10141e: 0f b7 45 f0 movzwl -0x10(%ebp),%eax
101422: 89 c2 mov %eax,%edx
101424: ec in (%dx),%al
101425: 88 45 ea mov %al,-0x16(%ebp)
return data;
101428: 0f b6 45 ea movzbl -0x16(%ebp),%eax
}
data = inb(KBDATAP);
10142c: 88 45 f3 mov %al,-0xd(%ebp)
if (data == 0xE0) {
10142f: 80 7d f3 e0 cmpb $0xe0,-0xd(%ebp)
101433: 75 17 jne 10144c <kbd_proc_data+0x62>
// E0 escape character
shift |= E0ESC;
101435: a1 a8 a0 11 00 mov 0x11a0a8,%eax
10143a: 83 c8 40 or $0x40,%eax
10143d: a3 a8 a0 11 00 mov %eax,0x11a0a8
return 0;
101442: b8 00 00 00 00 mov $0x0,%eax
101447: e9 29 01 00 00 jmp 101575 <kbd_proc_data+0x18b>
} else if (data & 0x80) {
10144c: 0f b6 45 f3 movzbl -0xd(%ebp),%eax
101450: 84 c0 test %al,%al
101452: 79 47 jns 10149b <kbd_proc_data+0xb1>
// Key released
data = (shift & E0ESC ? data : data & 0x7F);
101454: a1 a8 a0 11 00 mov 0x11a0a8,%eax
101459: 83 e0 40 and $0x40,%eax
10145c: 85 c0 test %eax,%eax
10145e: 75 09 jne 101469 <kbd_proc_data+0x7f>
101460: 0f b6 45 f3 movzbl -0xd(%ebp),%eax
101464: 83 e0 7f and $0x7f,%eax
101467: eb 04 jmp 10146d <kbd_proc_data+0x83>
101469: 0f b6 45 f3 movzbl -0xd(%ebp),%eax
10146d: 88 45 f3 mov %al,-0xd(%ebp)
shift &= ~(shiftcode[data] | E0ESC);
101470: 0f b6 45 f3 movzbl -0xd(%ebp),%eax
101474: 0f b6 80 60 90 11 00 movzbl 0x119060(%eax),%eax
10147b: 83 c8 40 or $0x40,%eax
10147e: 0f b6 c0 movzbl %al,%eax
101481: f7 d0 not %eax
101483: 89 c2 mov %eax,%edx
101485: a1 a8 a0 11 00 mov 0x11a0a8,%eax
10148a: 21 d0 and %edx,%eax
10148c: a3 a8 a0 11 00 mov %eax,0x11a0a8
return 0;
101491: b8 00 00 00 00 mov $0x0,%eax
101496: e9 da 00 00 00 jmp 101575 <kbd_proc_data+0x18b>
} else if (shift & E0ESC) {
10149b: a1 a8 a0 11 00 mov 0x11a0a8,%eax
1014a0: 83 e0 40 and $0x40,%eax
1014a3: 85 c0 test %eax,%eax
1014a5: 74 11 je 1014b8 <kbd_proc_data+0xce>
// Last character was an E0 escape; or with 0x80
data |= 0x80;
1014a7: 80 4d f3 80 orb $0x80,-0xd(%ebp)
shift &= ~E0ESC;
1014ab: a1 a8 a0 11 00 mov 0x11a0a8,%eax
1014b0: 83 e0 bf and $0xffffffbf,%eax
1014b3: a3 a8 a0 11 00 mov %eax,0x11a0a8
}
shift |= shiftcode[data];
1014b8: 0f b6 45 f3 movzbl -0xd(%ebp),%eax
1014bc: 0f b6 80 60 90 11 00 movzbl 0x119060(%eax),%eax
1014c3: 0f b6 d0 movzbl %al,%edx
1014c6: a1 a8 a0 11 00 mov 0x11a0a8,%eax
1014cb: 09 d0 or %edx,%eax
1014cd: a3 a8 a0 11 00 mov %eax,0x11a0a8
shift ^= togglecode[data];
1014d2: 0f b6 45 f3 movzbl -0xd(%ebp),%eax
1014d6: 0f b6 80 60 91 11 00 movzbl 0x119160(%eax),%eax
1014dd: 0f b6 d0 movzbl %al,%edx
1014e0: a1 a8 a0 11 00 mov 0x11a0a8,%eax
1014e5: 31 d0 xor %edx,%eax
1014e7: a3 a8 a0 11 00 mov %eax,0x11a0a8
c = charcode[shift & (CTL | SHIFT)][data];
1014ec: a1 a8 a0 11 00 mov 0x11a0a8,%eax
1014f1: 83 e0 03 and $0x3,%eax
1014f4: 8b 14 85 60 95 11 00 mov 0x119560(,%eax,4),%edx
1014fb: 0f b6 45 f3 movzbl -0xd(%ebp),%eax
1014ff: 01 d0 add %edx,%eax
101501: 0f b6 00 movzbl (%eax),%eax
101504: 0f b6 c0 movzbl %al,%eax
101507: 89 45 f4 mov %eax,-0xc(%ebp)
if (shift & CAPSLOCK) {
10150a: a1 a8 a0 11 00 mov 0x11a0a8,%eax
10150f: 83 e0 08 and $0x8,%eax
101512: 85 c0 test %eax,%eax
101514: 74 22 je 101538 <kbd_proc_data+0x14e>
if ('a' <= c && c <= 'z')
101516: 83 7d f4 60 cmpl $0x60,-0xc(%ebp)
10151a: 7e 0c jle 101528 <kbd_proc_data+0x13e>
10151c: 83 7d f4 7a cmpl $0x7a,-0xc(%ebp)
101520: 7f 06 jg 101528 <kbd_proc_data+0x13e>
c += 'A' - 'a';
101522: 83 6d f4 20 subl $0x20,-0xc(%ebp)
101526: eb 10 jmp 101538 <kbd_proc_data+0x14e>
else if ('A' <= c && c <= 'Z')
101528: 83 7d f4 40 cmpl $0x40,-0xc(%ebp)
10152c: 7e 0a jle 101538 <kbd_proc_data+0x14e>
10152e: 83 7d f4 5a cmpl $0x5a,-0xc(%ebp)
101532: 7f 04 jg 101538 <kbd_proc_data+0x14e>
c += 'a' - 'A';
101534: 83 45 f4 20 addl $0x20,-0xc(%ebp)
}
// Process special keys
// Ctrl-Alt-Del: reboot
if (!(~shift & (CTL | ALT)) && c == KEY_DEL) {
101538: a1 a8 a0 11 00 mov 0x11a0a8,%eax
10153d: f7 d0 not %eax
10153f: 83 e0 06 and $0x6,%eax
101542: 85 c0 test %eax,%eax
101544: 75 2c jne 101572 <kbd_proc_data+0x188>
101546: 81 7d f4 e9 00 00 00 cmpl $0xe9,-0xc(%ebp)
10154d: 75 23 jne 101572 <kbd_proc_data+0x188>
cprintf("Rebooting!\n");
10154f: 83 ec 0c sub $0xc,%esp
101552: 68 1d 6c 10 00 push $0x106c1d
101557: e8 0b ed ff ff call 100267 <cprintf>
10155c: 83 c4 10 add $0x10,%esp
10155f: 66 c7 45 ee 92 00 movw $0x92,-0x12(%ebp)
101565: c6 45 e9 03 movb $0x3,-0x17(%ebp)
: "memory", "cc");
}
static inline void
outb(uint16_t port, uint8_t data) {
asm volatile ("outb %0, %1" :: "a" (data), "d" (port) : "memory");
101569: 0f b6 45 e9 movzbl -0x17(%ebp),%eax
10156d: 0f b7 55 ee movzwl -0x12(%ebp),%edx
101571: ee out %al,(%dx)
outb(0x92, 0x3); // courtesy of Chris Frost
}
return c;
101572: 8b 45 f4 mov -0xc(%ebp),%eax
}
101575: c9 leave
101576: c3 ret
00101577 <kbd_intr>:
/* kbd_intr - try to feed input characters from keyboard */
static void
kbd_intr(void) {
101577: 55 push %ebp
101578: 89 e5 mov %esp,%ebp
10157a: 83 ec 08 sub $0x8,%esp
cons_intr(kbd_proc_data);
10157d: 83 ec 0c sub $0xc,%esp
101580: 68 ea 13 10 00 push $0x1013ea
101585: e8 9b fd ff ff call 101325 <cons_intr>
10158a: 83 c4 10 add $0x10,%esp
}
10158d: 90 nop
10158e: c9 leave
10158f: c3 ret
00101590 <kbd_init>:
static void
kbd_init(void) {
101590: 55 push %ebp
101591: 89 e5 mov %esp,%ebp
101593: 83 ec 08 sub $0x8,%esp
// drain the kbd buffer
kbd_intr();
101596: e8 dc ff ff ff call 101577 <kbd_intr>
pic_enable(IRQ_KBD);
10159b: 83 ec 0c sub $0xc,%esp
10159e: 6a 01 push $0x1
1015a0: e8 4b 01 00 00 call 1016f0 <pic_enable>
1015a5: 83 c4 10 add $0x10,%esp
}
1015a8: 90 nop
1015a9: c9 leave
1015aa: c3 ret
001015ab <cons_init>:
/* cons_init - initializes the console devices */
void
cons_init(void) {
1015ab: 55 push %ebp
1015ac: 89 e5 mov %esp,%ebp
1015ae: 83 ec 08 sub $0x8,%esp
cga_init();
1015b1: e8 8c f8 ff ff call 100e42 <cga_init>
serial_init();
1015b6: e8 6e f9 ff ff call 100f29 <serial_init>
kbd_init();
1015bb: e8 d0 ff ff ff call 101590 <kbd_init>
if (!serial_exists) {
1015c0: a1 88 9e 11 00 mov 0x119e88,%eax
1015c5: 85 c0 test %eax,%eax
1015c7: 75 10 jne 1015d9 <cons_init+0x2e>
cprintf("serial port does not exist!!\n");
1015c9: 83 ec 0c sub $0xc,%esp
1015cc: 68 29 6c 10 00 push $0x106c29
1015d1: e8 91 ec ff ff call 100267 <cprintf>
1015d6: 83 c4 10 add $0x10,%esp
}
}
1015d9: 90 nop
1015da: c9 leave
1015db: c3 ret
001015dc <cons_putc>:
/* cons_putc - print a single character @c to console devices */
void
cons_putc(int c) {
1015dc: 55 push %ebp
1015dd: 89 e5 mov %esp,%ebp
1015df: 83 ec 18 sub $0x18,%esp
bool intr_flag;
local_intr_save(intr_flag);
1015e2: e8 d4 f7 ff ff call 100dbb <__intr_save>
1015e7: 89 45 f4 mov %eax,-0xc(%ebp)
{
lpt_putc(c);
1015ea: 83 ec 0c sub $0xc,%esp
1015ed: ff 75 08 pushl 0x8(%ebp)
1015f0: e8 93 fa ff ff call 101088 <lpt_putc>
1015f5: 83 c4 10 add $0x10,%esp
cga_putc(c);
1015f8: 83 ec 0c sub $0xc,%esp
1015fb: ff 75 08 pushl 0x8(%ebp)
1015fe: e8 bc fa ff ff call 1010bf <cga_putc>
101603: 83 c4 10 add $0x10,%esp
serial_putc(c);
101606: 83 ec 0c sub $0xc,%esp
101609: ff 75 08 pushl 0x8(%ebp)
10160c: e8 dd fc ff ff call 1012ee <serial_putc>
101611: 83 c4 10 add $0x10,%esp
}
local_intr_restore(intr_flag);
101614: 83 ec 0c sub $0xc,%esp
101617: ff 75 f4 pushl -0xc(%ebp)
10161a: e8 c6 f7 ff ff call 100de5 <__intr_restore>
10161f: 83 c4 10 add $0x10,%esp
}
101622: 90 nop
101623: c9 leave
101624: c3 ret
00101625 <cons_getc>:
/* *
* cons_getc - return the next input character from console,
* or 0 if none waiting.
* */
int
cons_getc(void) {
101625: 55 push %ebp
101626: 89 e5 mov %esp,%ebp
101628: 83 ec 18 sub $0x18,%esp
int c = 0;
10162b: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp)
bool intr_flag;
local_intr_save(intr_flag);
101632: e8 84 f7 ff ff call 100dbb <__intr_save>
101637: 89 45 f0 mov %eax,-0x10(%ebp)
{
// poll for any pending input characters,
// so that this function works even when interrupts are disabled
// (e.g., when called from the kernel monitor).
serial_intr();
10163a: e8 89 fd ff ff call 1013c8 <serial_intr>
kbd_intr();
10163f: e8 33 ff ff ff call 101577 <kbd_intr>
// grab the next character from the input buffer.
if (cons.rpos != cons.wpos) {
101644: 8b 15 a0 a0 11 00 mov 0x11a0a0,%edx
10164a: a1 a4 a0 11 00 mov 0x11a0a4,%eax
10164f: 39 c2 cmp %eax,%edx
101651: 74 31 je 101684 <cons_getc+0x5f>
c = cons.buf[cons.rpos ++];
101653: a1 a0 a0 11 00 mov 0x11a0a0,%eax
101658: 8d 50 01 lea 0x1(%eax),%edx
10165b: 89 15 a0 a0 11 00 mov %edx,0x11a0a0
101661: 0f b6 80 a0 9e 11 00 movzbl 0x119ea0(%eax),%eax
101668: 0f b6 c0 movzbl %al,%eax
10166b: 89 45 f4 mov %eax,-0xc(%ebp)
if (cons.rpos == CONSBUFSIZE) {
10166e: a1 a0 a0 11 00 mov 0x11a0a0,%eax
101673: 3d 00 02 00 00 cmp $0x200,%eax
101678: 75 0a jne 101684 <cons_getc+0x5f>
cons.rpos = 0;
10167a: c7 05 a0 a0 11 00 00 movl $0x0,0x11a0a0
101681: 00 00 00
}
}
}
local_intr_restore(intr_flag);
101684: 83 ec 0c sub $0xc,%esp
101687: ff 75 f0 pushl -0x10(%ebp)
10168a: e8 56 f7 ff ff call 100de5 <__intr_restore>
10168f: 83 c4 10 add $0x10,%esp
return c;
101692: 8b 45 f4 mov -0xc(%ebp),%eax
}
101695: c9 leave
101696: c3 ret
00101697 <pic_setmask>:
// Initial IRQ mask has interrupt 2 enabled (for slave 8259A).
static uint16_t irq_mask = 0xFFFF & ~(1 << IRQ_SLAVE);
static bool did_init = 0;
static void
pic_setmask(uint16_t mask) {
101697: 55 push %ebp
101698: 89 e5 mov %esp,%ebp
10169a: 83 ec 14 sub $0x14,%esp
10169d: 8b 45 08 mov 0x8(%ebp),%eax
1016a0: 66 89 45 ec mov %ax,-0x14(%ebp)
irq_mask = mask;
1016a4: 0f b7 45 ec movzwl -0x14(%ebp),%eax
1016a8: 66 a3 70 95 11 00 mov %ax,0x119570
if (did_init) {
1016ae: a1 ac a0 11 00 mov 0x11a0ac,%eax
1016b3: 85 c0 test %eax,%eax
1016b5: 74 36 je 1016ed <pic_setmask+0x56>
outb(IO_PIC1 + 1, mask);
1016b7: 0f b7 45 ec movzwl -0x14(%ebp),%eax
1016bb: 0f b6 c0 movzbl %al,%eax
1016be: 66 c7 45 fe 21 00 movw $0x21,-0x2(%ebp)
1016c4: 88 45 fa mov %al,-0x6(%ebp)
1016c7: 0f b6 45 fa movzbl -0x6(%ebp),%eax
1016cb: 0f b7 55 fe movzwl -0x2(%ebp),%edx
1016cf: ee out %al,(%dx)
outb(IO_PIC2 + 1, mask >> 8);
1016d0: 0f b7 45 ec movzwl -0x14(%ebp),%eax
1016d4: 66 c1 e8 08 shr $0x8,%ax
1016d8: 0f b6 c0 movzbl %al,%eax
1016db: 66 c7 45 fc a1 00 movw $0xa1,-0x4(%ebp)
1016e1: 88 45 fb mov %al,-0x5(%ebp)
1016e4: 0f b6 45 fb movzbl -0x5(%ebp),%eax
1016e8: 0f b7 55 fc movzwl -0x4(%ebp),%edx
1016ec: ee out %al,(%dx)
}
}
1016ed: 90 nop
1016ee: c9 leave
1016ef: c3 ret
001016f0 <pic_enable>:
void
pic_enable(unsigned int irq) {
1016f0: 55 push %ebp
1016f1: 89 e5 mov %esp,%ebp
pic_setmask(irq_mask & ~(1 << irq));
1016f3: 8b 45 08 mov 0x8(%ebp),%eax
1016f6: ba 01 00 00 00 mov $0x1,%edx
1016fb: 89 c1 mov %eax,%ecx
1016fd: d3 e2 shl %cl,%edx
1016ff: 89 d0 mov %edx,%eax
101701: f7 d0 not %eax
101703: 89 c2 mov %eax,%edx
101705: 0f b7 05 70 95 11 00 movzwl 0x119570,%eax
10170c: 21 d0 and %edx,%eax
10170e: 0f b7 c0 movzwl %ax,%eax
101711: 50 push %eax
101712: e8 80 ff ff ff call 101697 <pic_setmask>
101717: 83 c4 04 add $0x4,%esp
}
10171a: 90 nop
10171b: c9 leave
10171c: c3 ret
0010171d <pic_init>:
/* pic_init - initialize the 8259A interrupt controllers */
void
pic_init(void) {
10171d: 55 push %ebp
10171e: 89 e5 mov %esp,%ebp
101720: 83 ec 30 sub $0x30,%esp
did_init = 1;
101723: c7 05 ac a0 11 00 01 movl $0x1,0x11a0ac
10172a: 00 00 00
10172d: 66 c7 45 fe 21 00 movw $0x21,-0x2(%ebp)
101733: c6 45 d6 ff movb $0xff,-0x2a(%ebp)
101737: 0f b6 45 d6 movzbl -0x2a(%ebp),%eax
10173b: 0f b7 55 fe movzwl -0x2(%ebp),%edx
10173f: ee out %al,(%dx)
101740: 66 c7 45 fc a1 00 movw $0xa1,-0x4(%ebp)
101746: c6 45 d7 ff movb $0xff,-0x29(%ebp)
10174a: 0f b6 45 d7 movzbl -0x29(%ebp),%eax
10174e: 0f b7 55 fc movzwl -0x4(%ebp),%edx
101752: ee out %al,(%dx)
101753: 66 c7 45 fa 20 00 movw $0x20,-0x6(%ebp)
101759: c6 45 d8 11 movb $0x11,-0x28(%ebp)
10175d: 0f b6 45 d8 movzbl -0x28(%ebp),%eax
101761: 0f b7 55 fa movzwl -0x6(%ebp),%edx
101765: ee out %al,(%dx)
101766: 66 c7 45 f8 21 00 movw $0x21,-0x8(%ebp)
10176c: c6 45 d9 20 movb $0x20,-0x27(%ebp)
101770: 0f b6 45 d9 movzbl -0x27(%ebp),%eax
101774: 0f b7 55 f8 movzwl -0x8(%ebp),%edx
101778: ee out %al,(%dx)
101779: 66 c7 45 f6 21 00 movw $0x21,-0xa(%ebp)
10177f: c6 45 da 04 movb $0x4,-0x26(%ebp)
101783: 0f b6 45 da movzbl -0x26(%ebp),%eax
101787: 0f b7 55 f6 movzwl -0xa(%ebp),%edx
10178b: ee out %al,(%dx)
10178c: 66 c7 45 f4 21 00 movw $0x21,-0xc(%ebp)
101792: c6 45 db 03 movb $0x3,-0x25(%ebp)
101796: 0f b6 45 db movzbl -0x25(%ebp),%eax
10179a: 0f b7 55 f4 movzwl -0xc(%ebp),%edx
10179e: ee out %al,(%dx)
10179f: 66 c7 45 f2 a0 00 movw $0xa0,-0xe(%ebp)
1017a5: c6 45 dc 11 movb $0x11,-0x24(%ebp)
1017a9: 0f b6 45 dc movzbl -0x24(%ebp),%eax
1017ad: 0f b7 55 f2 movzwl -0xe(%ebp),%edx
1017b1: ee out %al,(%dx)
1017b2: 66 c7 45 f0 a1 00 movw $0xa1,-0x10(%ebp)
1017b8: c6 45 dd 28 movb $0x28,-0x23(%ebp)
1017bc: 0f b6 45 dd movzbl -0x23(%ebp),%eax
1017c0: 0f b7 55 f0 movzwl -0x10(%ebp),%edx
1017c4: ee out %al,(%dx)
1017c5: 66 c7 45 ee a1 00 movw $0xa1,-0x12(%ebp)
1017cb: c6 45 de 02 movb $0x2,-0x22(%ebp)
1017cf: 0f b6 45 de movzbl -0x22(%ebp),%eax
1017d3: 0f b7 55 ee movzwl -0x12(%ebp),%edx
1017d7: ee out %al,(%dx)
1017d8: 66 c7 45 ec a1 00 movw $0xa1,-0x14(%ebp)
1017de: c6 45 df 03 movb $0x3,-0x21(%ebp)
1017e2: 0f b6 45 df movzbl -0x21(%ebp),%eax
1017e6: 0f b7 55 ec movzwl -0x14(%ebp),%edx
1017ea: ee out %al,(%dx)
1017eb: 66 c7 45 ea 20 00 movw $0x20,-0x16(%ebp)
1017f1: c6 45 e0 68 movb $0x68,-0x20(%ebp)
1017f5: 0f b6 45 e0 movzbl -0x20(%ebp),%eax
1017f9: 0f b7 55 ea movzwl -0x16(%ebp),%edx
1017fd: ee out %al,(%dx)
1017fe: 66 c7 45 e8 20 00 movw $0x20,-0x18(%ebp)
101804: c6 45 e1 0a movb $0xa,-0x1f(%ebp)
101808: 0f b6 45 e1 movzbl -0x1f(%ebp),%eax
10180c: 0f b7 55 e8 movzwl -0x18(%ebp),%edx
101810: ee out %al,(%dx)
101811: 66 c7 45 e6 a0 00 movw $0xa0,-0x1a(%ebp)
101817: c6 45 e2 68 movb $0x68,-0x1e(%ebp)
10181b: 0f b6 45 e2 movzbl -0x1e(%ebp),%eax
10181f: 0f b7 55 e6 movzwl -0x1a(%ebp),%edx
101823: ee out %al,(%dx)
101824: 66 c7 45 e4 a0 00 movw $0xa0,-0x1c(%ebp)
10182a: c6 45 e3 0a movb $0xa,-0x1d(%ebp)
10182e: 0f b6 45 e3 movzbl -0x1d(%ebp),%eax
101832: 0f b7 55 e4 movzwl -0x1c(%ebp),%edx
101836: ee out %al,(%dx)
outb(IO_PIC1, 0x0a); // read IRR by default
outb(IO_PIC2, 0x68); // OCW3
outb(IO_PIC2, 0x0a); // OCW3
if (irq_mask != 0xFFFF) {
101837: 0f b7 05 70 95 11 00 movzwl 0x119570,%eax
10183e: 66 83 f8 ff cmp $0xffff,%ax
101842: 74 13 je 101857 <pic_init+0x13a>
pic_setmask(irq_mask);
101844: 0f b7 05 70 95 11 00 movzwl 0x119570,%eax
10184b: 0f b7 c0 movzwl %ax,%eax
10184e: 50 push %eax
10184f: e8 43 fe ff ff call 101697 <pic_setmask>
101854: 83 c4 04 add $0x4,%esp
}
}
101857: 90 nop
101858: c9 leave
101859: c3 ret
0010185a <intr_enable>:
#include <x86.h>
#include <intr.h>
/* intr_enable - enable irq interrupt */
void
intr_enable(void) {
10185a: 55 push %ebp
10185b: 89 e5 mov %esp,%ebp
asm volatile ("lidt (%0)" :: "r" (pd) : "memory");
}
static inline void
sti(void) {
asm volatile ("sti");
10185d: fb sti
sti();
}
10185e: 90 nop
10185f: 5d pop %ebp
101860: c3 ret
00101861 <intr_disable>:
/* intr_disable - disable irq interrupt */
void
intr_disable(void) {
101861: 55 push %ebp
101862: 89 e5 mov %esp,%ebp
}
static inline void
cli(void) {
asm volatile ("cli" ::: "memory");
101864: fa cli
cli();
}
101865: 90 nop
101866: 5d pop %ebp
101867: c3 ret
00101868 <print_ticks>:
#include <console.h>
#include <kdebug.h>
#define TICK_NUM 100
static void print_ticks() {
101868: 55 push %ebp
101869: 89 e5 mov %esp,%ebp
10186b: 83 ec 08 sub $0x8,%esp
cprintf("%d ticks\n",TICK_NUM);
10186e: 83 ec 08 sub $0x8,%esp
101871: 6a 64 push $0x64
101873: 68 60 6c 10 00 push $0x106c60
101878: e8 ea e9 ff ff call 100267 <cprintf>
10187d: 83 c4 10 add $0x10,%esp
#ifdef DEBUG_GRADE
cprintf("End of Test.\n");
101880: 83 ec 0c sub $0xc,%esp
101883: 68 6a 6c 10 00 push $0x106c6a
101888: e8 da e9 ff ff call 100267 <cprintf>
10188d: 83 c4 10 add $0x10,%esp
panic("EOT: kernel seems ok.");
101890: 83 ec 04 sub $0x4,%esp
101893: 68 78 6c 10 00 push $0x106c78
101898: 6a 12 push $0x12
10189a: 68 8e 6c 10 00 push $0x106c8e
10189f: e8 29 eb ff ff call 1003cd <__panic>
001018a4 <idt_init>:
sizeof(idt) - 1, (uintptr_t)idt
};
/* idt_init - initialize IDT to each of the entry points in kern/trap/vectors.S */
void
idt_init(void) {
1018a4: 55 push %ebp
1018a5: 89 e5 mov %esp,%ebp
1018a7: 83 ec 10 sub $0x10,%esp
* (3) After setup the contents of IDT, you will let CPU know where is the IDT by using 'lidt' instruction.
* You don't know the meaning of this instruction? just google it! and check the libs/x86.h to know more.
* Notice: the argument of lidt is idt_pd. try to find it!
*/
extern uintptr_t __vectors[];
for (int i = 0; i < 256; ++ i) {
1018aa: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%ebp)
1018b1: e9 97 01 00 00 jmp 101a4d <idt_init+0x1a9>
// cprintf("vectors %d: 0x%08x\n", i, __vectors[i]);
if (i == T_SYSCALL || i == T_SWITCH_TOK) {
1018b6: 81 7d fc 80 00 00 00 cmpl $0x80,-0x4(%ebp)
1018bd: 74 0a je 1018c9 <idt_init+0x25>
1018bf: 83 7d fc 79 cmpl $0x79,-0x4(%ebp)
1018c3: 0f 85 c1 00 00 00 jne 10198a <idt_init+0xe6>
SETGATE(idt[i], 1, KERNEL_CS, __vectors[i], DPL_USER);
1018c9: 8b 45 fc mov -0x4(%ebp),%eax
1018cc: 8b 04 85 00 96 11 00 mov 0x119600(,%eax,4),%eax
1018d3: 89 c2 mov %eax,%edx
1018d5: 8b 45 fc mov -0x4(%ebp),%eax
1018d8: 66 89 14 c5 c0 a0 11 mov %dx,0x11a0c0(,%eax,8)
1018df: 00
1018e0: 8b 45 fc mov -0x4(%ebp),%eax
1018e3: 66 c7 04 c5 c2 a0 11 movw $0x8,0x11a0c2(,%eax,8)
1018ea: 00 08 00
1018ed: 8b 45 fc mov -0x4(%ebp),%eax
1018f0: 0f b6 14 c5 c4 a0 11 movzbl 0x11a0c4(,%eax,8),%edx
1018f7: 00
1018f8: 83 e2 e0 and $0xffffffe0,%edx
1018fb: 88 14 c5 c4 a0 11 00 mov %dl,0x11a0c4(,%eax,8)
101902: 8b 45 fc mov -0x4(%ebp),%eax
101905: 0f b6 14 c5 c4 a0 11 movzbl 0x11a0c4(,%eax,8),%edx
10190c: 00
10190d: 83 e2 1f and $0x1f,%edx
101910: 88 14 c5 c4 a0 11 00 mov %dl,0x11a0c4(,%eax,8)
101917: 8b 45 fc mov -0x4(%ebp),%eax
10191a: 0f b6 14 c5 c5 a0 11 movzbl 0x11a0c5(,%eax,8),%edx
101921: 00
101922: 83 ca 0f or $0xf,%edx
101925: 88 14 c5 c5 a0 11 00 mov %dl,0x11a0c5(,%eax,8)
10192c: 8b 45 fc mov -0x4(%ebp),%eax
10192f: 0f b6 14 c5 c5 a0 11 movzbl 0x11a0c5(,%eax,8),%edx
101936: 00
101937: 83 e2 ef and $0xffffffef,%edx
10193a: 88 14 c5 c5 a0 11 00 mov %dl,0x11a0c5(,%eax,8)
101941: 8b 45 fc mov -0x4(%ebp),%eax
101944: 0f b6 14 c5 c5 a0 11 movzbl 0x11a0c5(,%eax,8),%edx
10194b: 00
10194c: 83 ca 60 or $0x60,%edx
10194f: 88 14 c5 c5 a0 11 00 mov %dl,0x11a0c5(,%eax,8)
101956: 8b 45 fc mov -0x4(%ebp),%eax
101959: 0f b6 14 c5 c5 a0 11 movzbl 0x11a0c5(,%eax,8),%edx
101960: 00
101961: 83 ca 80 or $0xffffff80,%edx
101964: 88 14 c5 c5 a0 11 00 mov %dl,0x11a0c5(,%eax,8)
10196b: 8b 45 fc mov -0x4(%ebp),%eax
10196e: 8b 04 85 00 96 11 00 mov 0x119600(,%eax,4),%eax
101975: c1 e8 10 shr $0x10,%eax
101978: 89 c2 mov %eax,%edx
10197a: 8b 45 fc mov -0x4(%ebp),%eax
10197d: 66 89 14 c5 c6 a0 11 mov %dx,0x11a0c6(,%eax,8)
101984: 00
101985: e9 bf 00 00 00 jmp 101a49 <idt_init+0x1a5>
} else {
SETGATE(idt[i], 0, KERNEL_CS, __vectors[i], DPL_KERNEL);
10198a: 8b 45 fc mov -0x4(%ebp),%eax
10198d: 8b 04 85 00 96 11 00 mov 0x119600(,%eax,4),%eax
101994: 89 c2 mov %eax,%edx
101996: 8b 45 fc mov -0x4(%ebp),%eax
101999: 66 89 14 c5 c0 a0 11 mov %dx,0x11a0c0(,%eax,8)
1019a0: 00
1019a1: 8b 45 fc mov -0x4(%ebp),%eax
1019a4: 66 c7 04 c5 c2 a0 11 movw $0x8,0x11a0c2(,%eax,8)
1019ab: 00 08 00
1019ae: 8b 45 fc mov -0x4(%ebp),%eax
1019b1: 0f b6 14 c5 c4 a0 11 movzbl 0x11a0c4(,%eax,8),%edx
1019b8: 00
1019b9: 83 e2 e0 and $0xffffffe0,%edx
1019bc: 88 14 c5 c4 a0 11 00 mov %dl,0x11a0c4(,%eax,8)
1019c3: 8b 45 fc mov -0x4(%ebp),%eax
1019c6: 0f b6 14 c5 c4 a0 11 movzbl 0x11a0c4(,%eax,8),%edx
1019cd: 00
1019ce: 83 e2 1f and $0x1f,%edx
1019d1: 88 14 c5 c4 a0 11 00 mov %dl,0x11a0c4(,%eax,8)
1019d8: 8b 45 fc mov -0x4(%ebp),%eax
1019db: 0f b6 14 c5 c5 a0 11 movzbl 0x11a0c5(,%eax,8),%edx
1019e2: 00
1019e3: 83 e2 f0 and $0xfffffff0,%edx
1019e6: 83 ca 0e or $0xe,%edx
1019e9: 88 14 c5 c5 a0 11 00 mov %dl,0x11a0c5(,%eax,8)
1019f0: 8b 45 fc mov -0x4(%ebp),%eax
1019f3: 0f b6 14 c5 c5 a0 11 movzbl 0x11a0c5(,%eax,8),%edx
1019fa: 00
1019fb: 83 e2 ef and $0xffffffef,%edx
1019fe: 88 14 c5 c5 a0 11 00 mov %dl,0x11a0c5(,%eax,8)
101a05: 8b 45 fc mov -0x4(%ebp),%eax
101a08: 0f b6 14 c5 c5 a0 11 movzbl 0x11a0c5(,%eax,8),%edx
101a0f: 00
101a10: 83 e2 9f and $0xffffff9f,%edx
101a13: 88 14 c5 c5 a0 11 00 mov %dl,0x11a0c5(,%eax,8)
101a1a: 8b 45 fc mov -0x4(%ebp),%eax
101a1d: 0f b6 14 c5 c5 a0 11 movzbl 0x11a0c5(,%eax,8),%edx
101a24: 00
101a25: 83 ca 80 or $0xffffff80,%edx
101a28: 88 14 c5 c5 a0 11 00 mov %dl,0x11a0c5(,%eax,8)
101a2f: 8b 45 fc mov -0x4(%ebp),%eax
101a32: 8b 04 85 00 96 11 00 mov 0x119600(,%eax,4),%eax
101a39: c1 e8 10 shr $0x10,%eax
101a3c: 89 c2 mov %eax,%edx
101a3e: 8b 45 fc mov -0x4(%ebp),%eax
101a41: 66 89 14 c5 c6 a0 11 mov %dx,0x11a0c6(,%eax,8)
101a48: 00
* (3) After setup the contents of IDT, you will let CPU know where is the IDT by using 'lidt' instruction.
* You don't know the meaning of this instruction? just google it! and check the libs/x86.h to know more.
* Notice: the argument of lidt is idt_pd. try to find it!
*/
extern uintptr_t __vectors[];
for (int i = 0; i < 256; ++ i) {
101a49: 83 45 fc 01 addl $0x1,-0x4(%ebp)
101a4d: 81 7d fc ff 00 00 00 cmpl $0xff,-0x4(%ebp)
101a54: 0f 8e 5c fe ff ff jle 1018b6 <idt_init+0x12>
101a5a: c7 45 f8 80 95 11 00 movl $0x119580,-0x8(%ebp)
}
}
static inline void
lidt(struct pseudodesc *pd) {
asm volatile ("lidt (%0)" :: "r" (pd) : "memory");
101a61: 8b 45 f8 mov -0x8(%ebp),%eax
101a64: 0f 01 18 lidtl (%eax)
} else {
SETGATE(idt[i], 0, KERNEL_CS, __vectors[i], DPL_KERNEL);
}
}
lidt(&idt_pd);
}
101a67: 90 nop
101a68: c9 leave
101a69: c3 ret
00101a6a <trapname>:
static const char *
trapname(int trapno) {
101a6a: 55 push %ebp
101a6b: 89 e5 mov %esp,%ebp
"Alignment Check",
"Machine-Check",
"SIMD Floating-Point Exception"
};
if (trapno < sizeof(excnames)/sizeof(const char * const)) {
101a6d: 8b 45 08 mov 0x8(%ebp),%eax
101a70: 83 f8 13 cmp $0x13,%eax
101a73: 77 0c ja 101a81 <trapname+0x17>
return excnames[trapno];
101a75: 8b 45 08 mov 0x8(%ebp),%eax
101a78: 8b 04 85 00 70 10 00 mov 0x107000(,%eax,4),%eax
101a7f: eb 18 jmp 101a99 <trapname+0x2f>
}
if (trapno >= IRQ_OFFSET && trapno < IRQ_OFFSET + 16) {
101a81: 83 7d 08 1f cmpl $0x1f,0x8(%ebp)
101a85: 7e 0d jle 101a94 <trapname+0x2a>
101a87: 83 7d 08 2f cmpl $0x2f,0x8(%ebp)
101a8b: 7f 07 jg 101a94 <trapname+0x2a>
return "Hardware Interrupt";
101a8d: b8 9f 6c 10 00 mov $0x106c9f,%eax
101a92: eb 05 jmp 101a99 <trapname+0x2f>
}
return "(unknown trap)";
101a94: b8 b2 6c 10 00 mov $0x106cb2,%eax
}
101a99: 5d pop %ebp
101a9a: c3 ret
00101a9b <trap_in_kernel>:
/* trap_in_kernel - test if trap happened in kernel */
bool
trap_in_kernel(struct trapframe *tf) {
101a9b: 55 push %ebp
101a9c: 89 e5 mov %esp,%ebp
return (tf->tf_cs == (uint16_t)KERNEL_CS);
101a9e: 8b 45 08 mov 0x8(%ebp),%eax
101aa1: 0f b7 40 3c movzwl 0x3c(%eax),%eax
101aa5: 66 83 f8 08 cmp $0x8,%ax
101aa9: 0f 94 c0 sete %al
101aac: 0f b6 c0 movzbl %al,%eax
}
101aaf: 5d pop %ebp
101ab0: c3 ret
00101ab1 <print_trapframe>:
"TF", "IF", "DF", "OF", NULL, NULL, "NT", NULL,
"RF", "VM", "AC", "VIF", "VIP", "ID", NULL, NULL,
};
void
print_trapframe(struct trapframe *tf) {
101ab1: 55 push %ebp
101ab2: 89 e5 mov %esp,%ebp
101ab4: 83 ec 18 sub $0x18,%esp
cprintf("trapframe at %p\n", tf);
101ab7: 83 ec 08 sub $0x8,%esp
101aba: ff 75 08 pushl 0x8(%ebp)
101abd: 68 f3 6c 10 00 push $0x106cf3
101ac2: e8 a0 e7 ff ff call 100267 <cprintf>
101ac7: 83 c4 10 add $0x10,%esp
print_regs(&tf->tf_regs);
101aca: 8b 45 08 mov 0x8(%ebp),%eax
101acd: 83 ec 0c sub $0xc,%esp
101ad0: 50 push %eax
101ad1: e8 b8 01 00 00 call 101c8e <print_regs>
101ad6: 83 c4 10 add $0x10,%esp
cprintf(" ds 0x----%04x\n", tf->tf_ds);
101ad9: 8b 45 08 mov 0x8(%ebp),%eax
101adc: 0f b7 40 2c movzwl 0x2c(%eax),%eax
101ae0: 0f b7 c0 movzwl %ax,%eax
101ae3: 83 ec 08 sub $0x8,%esp
101ae6: 50 push %eax
101ae7: 68 04 6d 10 00 push $0x106d04
101aec: e8 76 e7 ff ff call 100267 <cprintf>
101af1: 83 c4 10 add $0x10,%esp
cprintf(" es 0x----%04x\n", tf->tf_es);
101af4: 8b 45 08 mov 0x8(%ebp),%eax
101af7: 0f b7 40 28 movzwl 0x28(%eax),%eax
101afb: 0f b7 c0 movzwl %ax,%eax
101afe: 83 ec 08 sub $0x8,%esp
101b01: 50 push %eax
101b02: 68 17 6d 10 00 push $0x106d17
101b07: e8 5b e7 ff ff call 100267 <cprintf>
101b0c: 83 c4 10 add $0x10,%esp
cprintf(" fs 0x----%04x\n", tf->tf_fs);
101b0f: 8b 45 08 mov 0x8(%ebp),%eax
101b12: 0f b7 40 24 movzwl 0x24(%eax),%eax
101b16: 0f b7 c0 movzwl %ax,%eax
101b19: 83 ec 08 sub $0x8,%esp
101b1c: 50 push %eax
101b1d: 68 2a 6d 10 00 push $0x106d2a
101b22: e8 40 e7 ff ff call 100267 <cprintf>
101b27: 83 c4 10 add $0x10,%esp
cprintf(" gs 0x----%04x\n", tf->tf_gs);
101b2a: 8b 45 08 mov 0x8(%ebp),%eax
101b2d: 0f b7 40 20 movzwl 0x20(%eax),%eax
101b31: 0f b7 c0 movzwl %ax,%eax
101b34: 83 ec 08 sub $0x8,%esp
101b37: 50 push %eax
101b38: 68 3d 6d 10 00 push $0x106d3d
101b3d: e8 25 e7 ff ff call 100267 <cprintf>
101b42: 83 c4 10 add $0x10,%esp
cprintf(" trap 0x%08x %s\n", tf->tf_trapno, trapname(tf->tf_trapno));
101b45: 8b 45 08 mov 0x8(%ebp),%eax
101b48: 8b 40 30 mov 0x30(%eax),%eax
101b4b: 83 ec 0c sub $0xc,%esp
101b4e: 50 push %eax
101b4f: e8 16 ff ff ff call 101a6a <trapname>
101b54: 83 c4 10 add $0x10,%esp
101b57: 89 c2 mov %eax,%edx
101b59: 8b 45 08 mov 0x8(%ebp),%eax
101b5c: 8b 40 30 mov 0x30(%eax),%eax
101b5f: 83 ec 04 sub $0x4,%esp
101b62: 52 push %edx
101b63: 50 push %eax
101b64: 68 50 6d 10 00 push $0x106d50
101b69: e8 f9 e6 ff ff call 100267 <cprintf>
101b6e: 83 c4 10 add $0x10,%esp
cprintf(" err 0x%08x\n", tf->tf_err);
101b71: 8b 45 08 mov 0x8(%ebp),%eax
101b74: 8b 40 34 mov 0x34(%eax),%eax
101b77: 83 ec 08 sub $0x8,%esp
101b7a: 50 push %eax
101b7b: 68 62 6d 10 00 push $0x106d62
101b80: e8 e2 e6 ff ff call 100267 <cprintf>
101b85: 83 c4 10 add $0x10,%esp
cprintf(" eip 0x%08x\n", tf->tf_eip);
101b88: 8b 45 08 mov 0x8(%ebp),%eax
101b8b: 8b 40 38 mov 0x38(%eax),%eax
101b8e: 83 ec 08 sub $0x8,%esp
101b91: 50 push %eax
101b92: 68 71 6d 10 00 push $0x106d71
101b97: e8 cb e6 ff ff call 100267 <cprintf>
101b9c: 83 c4 10 add $0x10,%esp
cprintf(" cs 0x----%04x\n", tf->tf_cs);
101b9f: 8b 45 08 mov 0x8(%ebp),%eax
101ba2: 0f b7 40 3c movzwl 0x3c(%eax),%eax
101ba6: 0f b7 c0 movzwl %ax,%eax
101ba9: 83 ec 08 sub $0x8,%esp
101bac: 50 push %eax
101bad: 68 80 6d 10 00 push $0x106d80
101bb2: e8 b0 e6 ff ff call 100267 <cprintf>
101bb7: 83 c4 10 add $0x10,%esp
cprintf(" flag 0x%08x ", tf->tf_eflags);
101bba: 8b 45 08 mov 0x8(%ebp),%eax
101bbd: 8b 40 40 mov 0x40(%eax),%eax
101bc0: 83 ec 08 sub $0x8,%esp
101bc3: 50 push %eax
101bc4: 68 93 6d 10 00 push $0x106d93
101bc9: e8 99 e6 ff ff call 100267 <cprintf>
101bce: 83 c4 10 add $0x10,%esp
int i, j;
for (i = 0, j = 1; i < sizeof(IA32flags) / sizeof(IA32flags[0]); i ++, j <<= 1) {
101bd1: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp)
101bd8: c7 45 f0 01 00 00 00 movl $0x1,-0x10(%ebp)
101bdf: eb 3f jmp 101c20 <print_trapframe+0x16f>
if ((tf->tf_eflags & j) && IA32flags[i] != NULL) {
101be1: 8b 45 08 mov 0x8(%ebp),%eax
101be4: 8b 50 40 mov 0x40(%eax),%edx
101be7: 8b 45 f0 mov -0x10(%ebp),%eax
101bea: 21 d0 and %edx,%eax
101bec: 85 c0 test %eax,%eax
101bee: 74 29 je 101c19 <print_trapframe+0x168>
101bf0: 8b 45 f4 mov -0xc(%ebp),%eax
101bf3: 8b 04 85 a0 95 11 00 mov 0x1195a0(,%eax,4),%eax
101bfa: 85 c0 test %eax,%eax
101bfc: 74 1b je 101c19 <print_trapframe+0x168>
cprintf("%s,", IA32flags[i]);
101bfe: 8b 45 f4 mov -0xc(%ebp),%eax
101c01: 8b 04 85 a0 95 11 00 mov 0x1195a0(,%eax,4),%eax
101c08: 83 ec 08 sub $0x8,%esp
101c0b: 50 push %eax
101c0c: 68 a2 6d 10 00 push $0x106da2
101c11: e8 51 e6 ff ff call 100267 <cprintf>
101c16: 83 c4 10 add $0x10,%esp
cprintf(" eip 0x%08x\n", tf->tf_eip);
cprintf(" cs 0x----%04x\n", tf->tf_cs);
cprintf(" flag 0x%08x ", tf->tf_eflags);
int i, j;
for (i = 0, j = 1; i < sizeof(IA32flags) / sizeof(IA32flags[0]); i ++, j <<= 1) {
101c19: 83 45 f4 01 addl $0x1,-0xc(%ebp)
101c1d: d1 65 f0 shll -0x10(%ebp)
101c20: 8b 45 f4 mov -0xc(%ebp),%eax
101c23: 83 f8 17 cmp $0x17,%eax
101c26: 76 b9 jbe 101be1 <print_trapframe+0x130>
if ((tf->tf_eflags & j) && IA32flags[i] != NULL) {
cprintf("%s,", IA32flags[i]);
}
}
cprintf("IOPL=%d\n", (tf->tf_eflags & FL_IOPL_MASK) >> 12);
101c28: 8b 45 08 mov 0x8(%ebp),%eax
101c2b: 8b 40 40 mov 0x40(%eax),%eax
101c2e: 25 00 30 00 00 and $0x3000,%eax
101c33: c1 e8 0c shr $0xc,%eax
101c36: 83 ec 08 sub $0x8,%esp
101c39: 50 push %eax
101c3a: 68 a6 6d 10 00 push $0x106da6
101c3f: e8 23 e6 ff ff call 100267 <cprintf>
101c44: 83 c4 10 add $0x10,%esp
if (!trap_in_kernel(tf)) {
101c47: 83 ec 0c sub $0xc,%esp
101c4a: ff 75 08 pushl 0x8(%ebp)
101c4d: e8 49 fe ff ff call 101a9b <trap_in_kernel>
101c52: 83 c4 10 add $0x10,%esp
101c55: 85 c0 test %eax,%eax
101c57: 75 32 jne 101c8b <print_trapframe+0x1da>
cprintf(" esp 0x%08x\n", tf->tf_esp);
101c59: 8b 45 08 mov 0x8(%ebp),%eax
101c5c: 8b 40 44 mov 0x44(%eax),%eax
101c5f: 83 ec 08 sub $0x8,%esp
101c62: 50 push %eax
101c63: 68 af 6d 10 00 push $0x106daf
101c68: e8 fa e5 ff ff call 100267 <cprintf>
101c6d: 83 c4 10 add $0x10,%esp
cprintf(" ss 0x----%04x\n", tf->tf_ss);
101c70: 8b 45 08 mov 0x8(%ebp),%eax
101c73: 0f b7 40 48 movzwl 0x48(%eax),%eax
101c77: 0f b7 c0 movzwl %ax,%eax
101c7a: 83 ec 08 sub $0x8,%esp
101c7d: 50 push %eax
101c7e: 68 be 6d 10 00 push $0x106dbe
101c83: e8 df e5 ff ff call 100267 <cprintf>
101c88: 83 c4 10 add $0x10,%esp
}
}
101c8b: 90 nop
101c8c: c9 leave
101c8d: c3 ret
00101c8e <print_regs>:
void
print_regs(struct pushregs *regs) {
101c8e: 55 push %ebp
101c8f: 89 e5 mov %esp,%ebp
101c91: 83 ec 08 sub $0x8,%esp
cprintf(" edi 0x%08x\n", regs->reg_edi);
101c94: 8b 45 08 mov 0x8(%ebp),%eax
101c97: 8b 00 mov (%eax),%eax
101c99: 83 ec 08 sub $0x8,%esp
101c9c: 50 push %eax
101c9d: 68 d1 6d 10 00 push $0x106dd1
101ca2: e8 c0 e5 ff ff call 100267 <cprintf>
101ca7: 83 c4 10 add $0x10,%esp
cprintf(" esi 0x%08x\n", regs->reg_esi);
101caa: 8b 45 08 mov 0x8(%ebp),%eax
101cad: 8b 40 04 mov 0x4(%eax),%eax
101cb0: 83 ec 08 sub $0x8,%esp
101cb3: 50 push %eax
101cb4: 68 e0 6d 10 00 push $0x106de0
101cb9: e8 a9 e5 ff ff call 100267 <cprintf>
101cbe: 83 c4 10 add $0x10,%esp
cprintf(" ebp 0x%08x\n", regs->reg_ebp);
101cc1: 8b 45 08 mov 0x8(%ebp),%eax
101cc4: 8b 40 08 mov 0x8(%eax),%eax
101cc7: 83 ec 08 sub $0x8,%esp
101cca: 50 push %eax
101ccb: 68 ef 6d 10 00 push $0x106def
101cd0: e8 92 e5 ff ff call 100267 <cprintf>
101cd5: 83 c4 10 add $0x10,%esp
cprintf(" oesp 0x%08x\n", regs->reg_oesp);
101cd8: 8b 45 08 mov 0x8(%ebp),%eax
101cdb: 8b 40 0c mov 0xc(%eax),%eax
101cde: 83 ec 08 sub $0x8,%esp
101ce1: 50 push %eax
101ce2: 68 fe 6d 10 00 push $0x106dfe
101ce7: e8 7b e5 ff ff call 100267 <cprintf>
101cec: 83 c4 10 add $0x10,%esp
cprintf(" ebx 0x%08x\n", regs->reg_ebx);
101cef: 8b 45 08 mov 0x8(%ebp),%eax
101cf2: 8b 40 10 mov 0x10(%eax),%eax
101cf5: 83 ec 08 sub $0x8,%esp
101cf8: 50 push %eax
101cf9: 68 0d 6e 10 00 push $0x106e0d
101cfe: e8 64 e5 ff ff call 100267 <cprintf>
101d03: 83 c4 10 add $0x10,%esp
cprintf(" edx 0x%08x\n", regs->reg_edx);
101d06: 8b 45 08 mov 0x8(%ebp),%eax
101d09: 8b 40 14 mov 0x14(%eax),%eax
101d0c: 83 ec 08 sub $0x8,%esp
101d0f: 50 push %eax
101d10: 68 1c 6e 10 00 push $0x106e1c
101d15: e8 4d e5 ff ff call 100267 <cprintf>
101d1a: 83 c4 10 add $0x10,%esp
cprintf(" ecx 0x%08x\n", regs->reg_ecx);
101d1d: 8b 45 08 mov 0x8(%ebp),%eax
101d20: 8b 40 18 mov 0x18(%eax),%eax
101d23: 83 ec 08 sub $0x8,%esp
101d26: 50 push %eax
101d27: 68 2b 6e 10 00 push $0x106e2b
101d2c: e8 36 e5 ff ff call 100267 <cprintf>
101d31: 83 c4 10 add $0x10,%esp
cprintf(" eax 0x%08x\n", regs->reg_eax);
101d34: 8b 45 08 mov 0x8(%ebp),%eax
101d37: 8b 40 1c mov 0x1c(%eax),%eax
101d3a: 83 ec 08 sub $0x8,%esp
101d3d: 50 push %eax
101d3e: 68 3a 6e 10 00 push $0x106e3a
101d43: e8 1f e5 ff ff call 100267 <cprintf>
101d48: 83 c4 10 add $0x10,%esp
}
101d4b: 90 nop
101d4c: c9 leave
101d4d: c3 ret
00101d4e <trap_dispatch>:
/* trap_dispatch - dispatch based on what type of trap occurred */
static void
trap_dispatch(struct trapframe *tf) {
101d4e: 55 push %ebp
101d4f: 89 e5 mov %esp,%ebp
101d51: 83 ec 18 sub $0x18,%esp
char c;
switch (tf->tf_trapno) {
101d54: 8b 45 08 mov 0x8(%ebp),%eax
101d57: 8b 40 30 mov 0x30(%eax),%eax
101d5a: 83 f8 2f cmp $0x2f,%eax
101d5d: 77 21 ja 101d80 <trap_dispatch+0x32>
101d5f: 83 f8 2e cmp $0x2e,%eax
101d62: 0f 83 32 02 00 00 jae 101f9a <trap_dispatch+0x24c>
101d68: 83 f8 21 cmp $0x21,%eax
101d6b: 0f 84 87 00 00 00 je 101df8 <trap_dispatch+0xaa>
101d71: 83 f8 24 cmp $0x24,%eax
101d74: 74 5b je 101dd1 <trap_dispatch+0x83>
101d76: 83 f8 20 cmp $0x20,%eax
101d79: 74 1c je 101d97 <trap_dispatch+0x49>
101d7b: e9 e4 01 00 00 jmp 101f64 <trap_dispatch+0x216>
101d80: 83 f8 78 cmp $0x78,%eax
101d83: 0f 84 4c 01 00 00 je 101ed5 <trap_dispatch+0x187>
101d89: 83 f8 79 cmp $0x79,%eax
101d8c: 0f 84 95 01 00 00 je 101f27 <trap_dispatch+0x1d9>
101d92: e9 cd 01 00 00 jmp 101f64 <trap_dispatch+0x216>
/* handle the timer interrupt */
/* (1) After a timer interrupt, you should record this event using a global variable (increase it), such as ticks in kern/driver/clock.c
* (2) Every TICK_NUM cycle, you can print some info using a funciton, such as print_ticks().
* (3) Too Simple? Yes, I think so!
*/
ticks ++;
101d97: a1 58 a9 11 00 mov 0x11a958,%eax
101d9c: 83 c0 01 add $0x1,%eax
101d9f: a3 58 a9 11 00 mov %eax,0x11a958
if (ticks % TICK_NUM == 0) {
101da4: 8b 0d 58 a9 11 00 mov 0x11a958,%ecx
101daa: ba 1f 85 eb 51 mov $0x51eb851f,%edx
101daf: 89 c8 mov %ecx,%eax
101db1: f7 e2 mul %edx
101db3: 89 d0 mov %edx,%eax
101db5: c1 e8 05 shr $0x5,%eax
101db8: 6b c0 64 imul $0x64,%eax,%eax
101dbb: 29 c1 sub %eax,%ecx
101dbd: 89 c8 mov %ecx,%eax
101dbf: 85 c0 test %eax,%eax
101dc1: 0f 85 d6 01 00 00 jne 101f9d <trap_dispatch+0x24f>
print_ticks();
101dc7: e8 9c fa ff ff call 101868 <print_ticks>
}
break;
101dcc: e9 cc 01 00 00 jmp 101f9d <trap_dispatch+0x24f>
case IRQ_OFFSET + IRQ_COM1:
c = cons_getc();
101dd1: e8 4f f8 ff ff call 101625 <cons_getc>
101dd6: 88 45 f7 mov %al,-0x9(%ebp)
cprintf("serial [%03d] %c\n", c, c);
101dd9: 0f be 55 f7 movsbl -0x9(%ebp),%edx
101ddd: 0f be 45 f7 movsbl -0x9(%ebp),%eax
101de1: 83 ec 04 sub $0x4,%esp
101de4: 52 push %edx
101de5: 50 push %eax
101de6: 68 49 6e 10 00 push $0x106e49
101deb: e8 77 e4 ff ff call 100267 <cprintf>
101df0: 83 c4 10 add $0x10,%esp
break;
101df3: e9 af 01 00 00 jmp 101fa7 <trap_dispatch+0x259>
case IRQ_OFFSET + IRQ_KBD:
c = cons_getc();
101df8: e8 28 f8 ff ff call 101625 <cons_getc>
101dfd: 88 45 f7 mov %al,-0x9(%ebp)
cprintf("kbd [%03d] %c\n", c, c);
101e00: 0f be 55 f7 movsbl -0x9(%ebp),%edx
101e04: 0f be 45 f7 movsbl -0x9(%ebp),%eax
101e08: 83 ec 04 sub $0x4,%esp
101e0b: 52 push %edx
101e0c: 50 push %eax
101e0d: 68 5b 6e 10 00 push $0x106e5b
101e12: e8 50 e4 ff ff call 100267 <cprintf>
101e17: 83 c4 10 add $0x10,%esp
if (c == '0') {
101e1a: 80 7d f7 30 cmpb $0x30,-0x9(%ebp)
101e1e: 75 46 jne 101e66 <trap_dispatch+0x118>
cprintf("Now switched to kernel mode");
101e20: 83 ec 0c sub $0xc,%esp
101e23: 68 6a 6e 10 00 push $0x106e6a
101e28: e8 3a e4 ff ff call 100267 <cprintf>
101e2d: 83 c4 10 add $0x10,%esp
if (tf->tf_cs != KERNEL_CS) {
101e30: 8b 45 08 mov 0x8(%ebp),%eax
101e33: 0f b7 40 3c movzwl 0x3c(%eax),%eax
101e37: 66 83 f8 08 cmp $0x8,%ax
101e3b: 0f 84 5f 01 00 00 je 101fa0 <trap_dispatch+0x252>
tf->tf_cs = KERNEL_CS;
101e41: 8b 45 08 mov 0x8(%ebp),%eax
101e44: 66 c7 40 3c 08 00 movw $0x8,0x3c(%eax)
tf->tf_ds = tf->tf_es = KERNEL_DS;
101e4a: 8b 45 08 mov 0x8(%ebp),%eax
101e4d: 66 c7 40 28 10 00 movw $0x10,0x28(%eax)
101e53: 8b 45 08 mov 0x8(%ebp),%eax
101e56: 0f b7 50 28 movzwl 0x28(%eax),%edx
101e5a: 8b 45 08 mov 0x8(%ebp),%eax
101e5d: 66 89 50 2c mov %dx,0x2c(%eax)
tf->tf_cs = USER_CS;
tf->tf_ds = tf->tf_es = tf->tf_ss = USER_DS;
tf->tf_eflags |= FL_IOPL_MASK;
}
}
break;
101e61: e9 3a 01 00 00 jmp 101fa0 <trap_dispatch+0x252>
cprintf("Now switched to kernel mode");
if (tf->tf_cs != KERNEL_CS) {
tf->tf_cs = KERNEL_CS;
tf->tf_ds = tf->tf_es = KERNEL_DS;
}
} else if (c == '3') {
101e66: 80 7d f7 33 cmpb $0x33,-0x9(%ebp)
101e6a: 0f 85 30 01 00 00 jne 101fa0 <trap_dispatch+0x252>
cprintf("Now switched to user mode");
101e70: 83 ec 0c sub $0xc,%esp
101e73: 68 86 6e 10 00 push $0x106e86
101e78: e8 ea e3 ff ff call 100267 <cprintf>
101e7d: 83 c4 10 add $0x10,%esp
if (tf->tf_cs != USER_CS) {
101e80: 8b 45 08 mov 0x8(%ebp),%eax
101e83: 0f b7 40 3c movzwl 0x3c(%eax),%eax
101e87: 66 83 f8 1b cmp $0x1b,%ax
101e8b: 0f 84 0f 01 00 00 je 101fa0 <trap_dispatch+0x252>
tf->tf_cs = USER_CS;
101e91: 8b 45 08 mov 0x8(%ebp),%eax
101e94: 66 c7 40 3c 1b 00 movw $0x1b,0x3c(%eax)
tf->tf_ds = tf->tf_es = tf->tf_ss = USER_DS;
101e9a: 8b 45 08 mov 0x8(%ebp),%eax
101e9d: 66 c7 40 48 23 00 movw $0x23,0x48(%eax)
101ea3: 8b 45 08 mov 0x8(%ebp),%eax
101ea6: 0f b7 50 48 movzwl 0x48(%eax),%edx
101eaa: 8b 45 08 mov 0x8(%ebp),%eax
101ead: 66 89 50 28 mov %dx,0x28(%eax)
101eb1: 8b 45 08 mov 0x8(%ebp),%eax
101eb4: 0f b7 50 28 movzwl 0x28(%eax),%edx
101eb8: 8b 45 08 mov 0x8(%ebp),%eax
101ebb: 66 89 50 2c mov %dx,0x2c(%eax)
tf->tf_eflags |= FL_IOPL_MASK;
101ebf: 8b 45 08 mov 0x8(%ebp),%eax
101ec2: 8b 40 40 mov 0x40(%eax),%eax
101ec5: 80 cc 30 or $0x30,%ah
101ec8: 89 c2 mov %eax,%edx
101eca: 8b 45 08 mov 0x8(%ebp),%eax
101ecd: 89 50 40 mov %edx,0x40(%eax)
}
}
break;
101ed0: e9 cb 00 00 00 jmp 101fa0 <trap_dispatch+0x252>
//LAB1 CHALLENGE 1 : YOUR CODE you should modify below codes.
case T_SWITCH_TOU:
if (tf->tf_cs != USER_CS) {
101ed5: 8b 45 08 mov 0x8(%ebp),%eax
101ed8: 0f b7 40 3c movzwl 0x3c(%eax),%eax
101edc: 66 83 f8 1b cmp $0x1b,%ax
101ee0: 0f 84 bd 00 00 00 je 101fa3 <trap_dispatch+0x255>
tf->tf_cs = USER_CS;
101ee6: 8b 45 08 mov 0x8(%ebp),%eax
101ee9: 66 c7 40 3c 1b 00 movw $0x1b,0x3c(%eax)
tf->tf_ds = tf->tf_es = tf->tf_ss = USER_DS;
101eef: 8b 45 08 mov 0x8(%ebp),%eax
101ef2: 66 c7 40 48 23 00 movw $0x23,0x48(%eax)
101ef8: 8b 45 08 mov 0x8(%ebp),%eax
101efb: 0f b7 50 48 movzwl 0x48(%eax),%edx
101eff: 8b 45 08 mov 0x8(%ebp),%eax
101f02: 66 89 50 28 mov %dx,0x28(%eax)
101f06: 8b 45 08 mov 0x8(%ebp),%eax
101f09: 0f b7 50 28 movzwl 0x28(%eax),%edx
101f0d: 8b 45 08 mov 0x8(%ebp),%eax
101f10: 66 89 50 2c mov %dx,0x2c(%eax)
tf->tf_eflags |= FL_IOPL_MASK;
101f14: 8b 45 08 mov 0x8(%ebp),%eax
101f17: 8b 40 40 mov 0x40(%eax),%eax
101f1a: 80 cc 30 or $0x30,%ah
101f1d: 89 c2 mov %eax,%edx
101f1f: 8b 45 08 mov 0x8(%ebp),%eax
101f22: 89 50 40 mov %edx,0x40(%eax)
}
break;
101f25: eb 7c jmp 101fa3 <trap_dispatch+0x255>
case T_SWITCH_TOK:
if (tf->tf_cs != KERNEL_CS) {
101f27: 8b 45 08 mov 0x8(%ebp),%eax
101f2a: 0f b7 40 3c movzwl 0x3c(%eax),%eax
101f2e: 66 83 f8 08 cmp $0x8,%ax
101f32: 74 72 je 101fa6 <trap_dispatch+0x258>
tf->tf_cs = KERNEL_CS;
101f34: 8b 45 08 mov 0x8(%ebp),%eax
101f37: 66 c7 40 3c 08 00 movw $0x8,0x3c(%eax)
tf->tf_ds = tf->tf_es = tf->tf_ss = KERNEL_DS;
101f3d: 8b 45 08 mov 0x8(%ebp),%eax
101f40: 66 c7 40 48 10 00 movw $0x10,0x48(%eax)
101f46: 8b 45 08 mov 0x8(%ebp),%eax
101f49: 0f b7 50 48 movzwl 0x48(%eax),%edx
101f4d: 8b 45 08 mov 0x8(%ebp),%eax
101f50: 66 89 50 28 mov %dx,0x28(%eax)
101f54: 8b 45 08 mov 0x8(%ebp),%eax
101f57: 0f b7 50 28 movzwl 0x28(%eax),%edx
101f5b: 8b 45 08 mov 0x8(%ebp),%eax
101f5e: 66 89 50 2c mov %dx,0x2c(%eax)
}
break;
101f62: eb 42 jmp 101fa6 <trap_dispatch+0x258>
case IRQ_OFFSET + IRQ_IDE2:
/* do nothing */
break;
default:
// in kernel, it must be a mistake
if ((tf->tf_cs & 3) == 0) {
101f64: 8b 45 08 mov 0x8(%ebp),%eax
101f67: 0f b7 40 3c movzwl 0x3c(%eax),%eax
101f6b: 0f b7 c0 movzwl %ax,%eax
101f6e: 83 e0 03 and $0x3,%eax
101f71: 85 c0 test %eax,%eax
101f73: 75 32 jne 101fa7 <trap_dispatch+0x259>
print_trapframe(tf);
101f75: 83 ec 0c sub $0xc,%esp
101f78: ff 75 08 pushl 0x8(%ebp)
101f7b: e8 31 fb ff ff call 101ab1 <print_trapframe>
101f80: 83 c4 10 add $0x10,%esp
panic("unexpected trap in kernel.\n");
101f83: 83 ec 04 sub $0x4,%esp
101f86: 68 a0 6e 10 00 push $0x106ea0
101f8b: 68 d1 00 00 00 push $0xd1
101f90: 68 8e 6c 10 00 push $0x106c8e
101f95: e8 33 e4 ff ff call 1003cd <__panic>
}
break;
case IRQ_OFFSET + IRQ_IDE1:
case IRQ_OFFSET + IRQ_IDE2:
/* do nothing */
break;
101f9a: 90 nop
101f9b: eb 0a jmp 101fa7 <trap_dispatch+0x259>
*/
ticks ++;
if (ticks % TICK_NUM == 0) {
print_ticks();
}
break;
101f9d: 90 nop
101f9e: eb 07 jmp 101fa7 <trap_dispatch+0x259>
tf->tf_cs = USER_CS;
tf->tf_ds = tf->tf_es = tf->tf_ss = USER_DS;
tf->tf_eflags |= FL_IOPL_MASK;
}
}
break;
101fa0: 90 nop
101fa1: eb 04 jmp 101fa7 <trap_dispatch+0x259>
if (tf->tf_cs != USER_CS) {
tf->tf_cs = USER_CS;
tf->tf_ds = tf->tf_es = tf->tf_ss = USER_DS;
tf->tf_eflags |= FL_IOPL_MASK;
}
break;
101fa3: 90 nop
101fa4: eb 01 jmp 101fa7 <trap_dispatch+0x259>
case T_SWITCH_TOK:
if (tf->tf_cs != KERNEL_CS) {
tf->tf_cs = KERNEL_CS;
tf->tf_ds = tf->tf_es = tf->tf_ss = KERNEL_DS;
}
break;
101fa6: 90 nop
if ((tf->tf_cs & 3) == 0) {
print_trapframe(tf);
panic("unexpected trap in kernel.\n");
}
}
}
101fa7: 90 nop
101fa8: c9 leave
101fa9: c3 ret
00101faa <trap>:
* trap - handles or dispatches an exception/interrupt. if and when trap() returns,
* the code in kern/trap/trapentry.S restores the old CPU state saved in the
* trapframe and then uses the iret instruction to return from the exception.
* */
void
trap(struct trapframe *tf) {
101faa: 55 push %ebp
101fab: 89 e5 mov %esp,%ebp
101fad: 83 ec 08 sub $0x8,%esp
// dispatch based on what type of trap occurred
trap_dispatch(tf);
101fb0: 83 ec 0c sub $0xc,%esp
101fb3: ff 75 08 pushl 0x8(%ebp)
101fb6: e8 93 fd ff ff call 101d4e <trap_dispatch>
101fbb: 83 c4 10 add $0x10,%esp
}
101fbe: 90 nop
101fbf: c9 leave
101fc0: c3 ret
00101fc1 <vector0>:
# handler
.text
.globl __alltraps
.globl vector0
vector0:
pushl $0
101fc1: 6a 00 push $0x0
pushl $0
101fc3: 6a 00 push $0x0
jmp __alltraps
101fc5: e9 67 0a 00 00 jmp 102a31 <__alltraps>
00101fca <vector1>:
.globl vector1
vector1:
pushl $0
101fca: 6a 00 push $0x0
pushl $1
101fcc: 6a 01 push $0x1
jmp __alltraps
101fce: e9 5e 0a 00 00 jmp 102a31 <__alltraps>
00101fd3 <vector2>:
.globl vector2
vector2:
pushl $0
101fd3: 6a 00 push $0x0
pushl $2
101fd5: 6a 02 push $0x2
jmp __alltraps
101fd7: e9 55 0a 00 00 jmp 102a31 <__alltraps>
00101fdc <vector3>:
.globl vector3
vector3:
pushl $0
101fdc: 6a 00 push $0x0
pushl $3
101fde: 6a 03 push $0x3
jmp __alltraps
101fe0: e9 4c 0a 00 00 jmp 102a31 <__alltraps>
00101fe5 <vector4>:
.globl vector4
vector4:
pushl $0
101fe5: 6a 00 push $0x0
pushl $4
101fe7: 6a 04 push $0x4
jmp __alltraps
101fe9: e9 43 0a 00 00 jmp 102a31 <__alltraps>
00101fee <vector5>:
.globl vector5
vector5:
pushl $0
101fee: 6a 00 push $0x0
pushl $5
101ff0: 6a 05 push $0x5
jmp __alltraps
101ff2: e9 3a 0a 00 00 jmp 102a31 <__alltraps>
00101ff7 <vector6>:
.globl vector6
vector6:
pushl $0
101ff7: 6a 00 push $0x0
pushl $6
101ff9: 6a 06 push $0x6
jmp __alltraps
101ffb: e9 31 0a 00 00 jmp 102a31 <__alltraps>
00102000 <vector7>:
.globl vector7
vector7:
pushl $0
102000: 6a 00 push $0x0
pushl $7
102002: 6a 07 push $0x7
jmp __alltraps
102004: e9 28 0a 00 00 jmp 102a31 <__alltraps>
00102009 <vector8>:
.globl vector8
vector8:
pushl $8
102009: 6a 08 push $0x8
jmp __alltraps
10200b: e9 21 0a 00 00 jmp 102a31 <__alltraps>
00102010 <vector9>:
.globl vector9
vector9:
pushl $9
102010: 6a 09 push $0x9
jmp __alltraps
102012: e9 1a 0a 00 00 jmp 102a31 <__alltraps>
00102017 <vector10>:
.globl vector10
vector10:
pushl $10
102017: 6a 0a push $0xa
jmp __alltraps
102019: e9 13 0a 00 00 jmp 102a31 <__alltraps>
0010201e <vector11>:
.globl vector11
vector11:
pushl $11
10201e: 6a 0b push $0xb
jmp __alltraps
102020: e9 0c 0a 00 00 jmp 102a31 <__alltraps>
00102025 <vector12>:
.globl vector12
vector12:
pushl $12
102025: 6a 0c push $0xc
jmp __alltraps
102027: e9 05 0a 00 00 jmp 102a31 <__alltraps>
0010202c <vector13>:
.globl vector13
vector13:
pushl $13
10202c: 6a 0d push $0xd
jmp __alltraps
10202e: e9 fe 09 00 00 jmp 102a31 <__alltraps>
00102033 <vector14>:
.globl vector14
vector14:
pushl $14
102033: 6a 0e push $0xe
jmp __alltraps
102035: e9 f7 09 00 00 jmp 102a31 <__alltraps>
0010203a <vector15>:
.globl vector15
vector15:
pushl $0
10203a: 6a 00 push $0x0
pushl $15
10203c: 6a 0f push $0xf
jmp __alltraps
10203e: e9 ee 09 00 00 jmp 102a31 <__alltraps>
00102043 <vector16>:
.globl vector16
vector16:
pushl $0
102043: 6a 00 push $0x0
pushl $16
102045: 6a 10 push $0x10
jmp __alltraps
102047: e9 e5 09 00 00 jmp 102a31 <__alltraps>
0010204c <vector17>:
.globl vector17
vector17:
pushl $17
10204c: 6a 11 push $0x11
jmp __alltraps
10204e: e9 de 09 00 00 jmp 102a31 <__alltraps>
00102053 <vector18>:
.globl vector18
vector18:
pushl $0
102053: 6a 00 push $0x0
pushl $18
102055: 6a 12 push $0x12
jmp __alltraps
102057: e9 d5 09 00 00 jmp 102a31 <__alltraps>
0010205c <vector19>:
.globl vector19
vector19:
pushl $0
10205c: 6a 00 push $0x0
pushl $19
10205e: 6a 13 push $0x13
jmp __alltraps
102060: e9 cc 09 00 00 jmp 102a31 <__alltraps>
00102065 <vector20>:
.globl vector20
vector20:
pushl $0
102065: 6a 00 push $0x0
pushl $20
102067: 6a 14 push $0x14
jmp __alltraps
102069: e9 c3 09 00 00 jmp 102a31 <__alltraps>
0010206e <vector21>:
.globl vector21
vector21:
pushl $0
10206e: 6a 00 push $0x0
pushl $21
102070: 6a 15 push $0x15
jmp __alltraps
102072: e9 ba 09 00 00 jmp 102a31 <__alltraps>
00102077 <vector22>:
.globl vector22
vector22:
pushl $0
102077: 6a 00 push $0x0
pushl $22
102079: 6a 16 push $0x16
jmp __alltraps
10207b: e9 b1 09 00 00 jmp 102a31 <__alltraps>
00102080 <vector23>:
.globl vector23
vector23:
pushl $0
102080: 6a 00 push $0x0
pushl $23
102082: 6a 17 push $0x17
jmp __alltraps
102084: e9 a8 09 00 00 jmp 102a31 <__alltraps>
00102089 <vector24>:
.globl vector24
vector24:
pushl $0
102089: 6a 00 push $0x0
pushl $24
10208b: 6a 18 push $0x18
jmp __alltraps
10208d: e9 9f 09 00 00 jmp 102a31 <__alltraps>
00102092 <vector25>:
.globl vector25
vector25:
pushl $0
102092: 6a 00 push $0x0
pushl $25
102094: 6a 19 push $0x19
jmp __alltraps
102096: e9 96 09 00 00 jmp 102a31 <__alltraps>
0010209b <vector26>:
.globl vector26
vector26:
pushl $0
10209b: 6a 00 push $0x0
pushl $26
10209d: 6a 1a push $0x1a
jmp __alltraps
10209f: e9 8d 09 00 00 jmp 102a31 <__alltraps>
001020a4 <vector27>:
.globl vector27
vector27:
pushl $0
1020a4: 6a 00 push $0x0
pushl $27
1020a6: 6a 1b push $0x1b
jmp __alltraps
1020a8: e9 84 09 00 00 jmp 102a31 <__alltraps>
001020ad <vector28>:
.globl vector28
vector28:
pushl $0
1020ad: 6a 00 push $0x0
pushl $28
1020af: 6a 1c push $0x1c
jmp __alltraps
1020b1: e9 7b 09 00 00 jmp 102a31 <__alltraps>
001020b6 <vector29>:
.globl vector29
vector29:
pushl $0
1020b6: 6a 00 push $0x0
pushl $29
1020b8: 6a 1d push $0x1d
jmp __alltraps
1020ba: e9 72 09 00 00 jmp 102a31 <__alltraps>
001020bf <vector30>:
.globl vector30
vector30:
pushl $0
1020bf: 6a 00 push $0x0
pushl $30
1020c1: 6a 1e push $0x1e
jmp __alltraps
1020c3: e9 69 09 00 00 jmp 102a31 <__alltraps>
001020c8 <vector31>:
.globl vector31
vector31:
pushl $0
1020c8: 6a 00 push $0x0
pushl $31
1020ca: 6a 1f push $0x1f
jmp __alltraps
1020cc: e9 60 09 00 00 jmp 102a31 <__alltraps>
001020d1 <vector32>:
.globl vector32
vector32:
pushl $0
1020d1: 6a 00 push $0x0
pushl $32
1020d3: 6a 20 push $0x20
jmp __alltraps
1020d5: e9 57 09 00 00 jmp 102a31 <__alltraps>
001020da <vector33>:
.globl vector33
vector33:
pushl $0
1020da: 6a 00 push $0x0
pushl $33
1020dc: 6a 21 push $0x21
jmp __alltraps
1020de: e9 4e 09 00 00 jmp 102a31 <__alltraps>
001020e3 <vector34>:
.globl vector34
vector34:
pushl $0
1020e3: 6a 00 push $0x0
pushl $34
1020e5: 6a 22 push $0x22
jmp __alltraps
1020e7: e9 45 09 00 00 jmp 102a31 <__alltraps>
001020ec <vector35>:
.globl vector35
vector35:
pushl $0
1020ec: 6a 00 push $0x0
pushl $35
1020ee: 6a 23 push $0x23
jmp __alltraps
1020f0: e9 3c 09 00 00 jmp 102a31 <__alltraps>
001020f5 <vector36>:
.globl vector36
vector36:
pushl $0
1020f5: 6a 00 push $0x0
pushl $36
1020f7: 6a 24 push $0x24
jmp __alltraps
1020f9: e9 33 09 00 00 jmp 102a31 <__alltraps>
001020fe <vector37>:
.globl vector37
vector37:
pushl $0
1020fe: 6a 00 push $0x0
pushl $37
102100: 6a 25 push $0x25
jmp __alltraps
102102: e9 2a 09 00 00 jmp 102a31 <__alltraps>
00102107 <vector38>:
.globl vector38
vector38:
pushl $0
102107: 6a 00 push $0x0
pushl $38
102109: 6a 26 push $0x26
jmp __alltraps
10210b: e9 21 09 00 00 jmp 102a31 <__alltraps>
00102110 <vector39>:
.globl vector39
vector39:
pushl $0
102110: 6a 00 push $0x0
pushl $39
102112: 6a 27 push $0x27
jmp __alltraps
102114: e9 18 09 00 00 jmp 102a31 <__alltraps>
00102119 <vector40>:
.globl vector40
vector40:
pushl $0
102119: 6a 00 push $0x0
pushl $40
10211b: 6a 28 push $0x28
jmp __alltraps
10211d: e9 0f 09 00 00 jmp 102a31 <__alltraps>
00102122 <vector41>:
.globl vector41
vector41:
pushl $0
102122: 6a 00 push $0x0
pushl $41
102124: 6a 29 push $0x29
jmp __alltraps
102126: e9 06 09 00 00 jmp 102a31 <__alltraps>
0010212b <vector42>:
.globl vector42
vector42:
pushl $0
10212b: 6a 00 push $0x0
pushl $42
10212d: 6a 2a push $0x2a
jmp __alltraps
10212f: e9 fd 08 00 00 jmp 102a31 <__alltraps>
00102134 <vector43>:
.globl vector43
vector43:
pushl $0
102134: 6a 00 push $0x0
pushl $43
102136: 6a 2b push $0x2b
jmp __alltraps
102138: e9 f4 08 00 00 jmp 102a31 <__alltraps>
0010213d <vector44>:
.globl vector44
vector44:
pushl $0
10213d: 6a 00 push $0x0
pushl $44
10213f: 6a 2c push $0x2c
jmp __alltraps
102141: e9 eb 08 00 00 jmp 102a31 <__alltraps>
00102146 <vector45>:
.globl vector45
vector45:
pushl $0
102146: 6a 00 push $0x0
pushl $45
102148: 6a 2d push $0x2d
jmp __alltraps
10214a: e9 e2 08 00 00 jmp 102a31 <__alltraps>
0010214f <vector46>:
.globl vector46
vector46:
pushl $0
10214f: 6a 00 push $0x0
pushl $46
102151: 6a 2e push $0x2e
jmp __alltraps
102153: e9 d9 08 00 00 jmp 102a31 <__alltraps>
00102158 <vector47>:
.globl vector47
vector47:
pushl $0
102158: 6a 00 push $0x0
pushl $47
10215a: 6a 2f push $0x2f
jmp __alltraps
10215c: e9 d0 08 00 00 jmp 102a31 <__alltraps>
00102161 <vector48>:
.globl vector48
vector48:
pushl $0
102161: 6a 00 push $0x0
pushl $48
102163: 6a 30 push $0x30
jmp __alltraps
102165: e9 c7 08 00 00 jmp 102a31 <__alltraps>
0010216a <vector49>:
.globl vector49
vector49:
pushl $0
10216a: 6a 00 push $0x0
pushl $49
10216c: 6a 31 push $0x31
jmp __alltraps
10216e: e9 be 08 00 00 jmp 102a31 <__alltraps>
00102173 <vector50>:
.globl vector50
vector50:
pushl $0
102173: 6a 00 push $0x0
pushl $50
102175: 6a 32 push $0x32
jmp __alltraps
102177: e9 b5 08 00 00 jmp 102a31 <__alltraps>
0010217c <vector51>:
.globl vector51
vector51:
pushl $0
10217c: 6a 00 push $0x0
pushl $51
10217e: 6a 33 push $0x33
jmp __alltraps
102180: e9 ac 08 00 00 jmp 102a31 <__alltraps>
00102185 <vector52>:
.globl vector52
vector52:
pushl $0
102185: 6a 00 push $0x0
pushl $52
102187: 6a 34 push $0x34
jmp __alltraps
102189: e9 a3 08 00 00 jmp 102a31 <__alltraps>
0010218e <vector53>:
.globl vector53
vector53:
pushl $0
10218e: 6a 00 push $0x0
pushl $53
102190: 6a 35 push $0x35
jmp __alltraps
102192: e9 9a 08 00 00 jmp 102a31 <__alltraps>
00102197 <vector54>:
.globl vector54
vector54:
pushl $0
102197: 6a 00 push $0x0
pushl $54
102199: 6a 36 push $0x36
jmp __alltraps
10219b: e9 91 08 00 00 jmp 102a31 <__alltraps>
001021a0 <vector55>:
.globl vector55
vector55:
pushl $0
1021a0: 6a 00 push $0x0
pushl $55
1021a2: 6a 37 push $0x37
jmp __alltraps
1021a4: e9 88 08 00 00 jmp 102a31 <__alltraps>
001021a9 <vector56>:
.globl vector56
vector56:
pushl $0
1021a9: 6a 00 push $0x0
pushl $56
1021ab: 6a 38 push $0x38
jmp __alltraps
1021ad: e9 7f 08 00 00 jmp 102a31 <__alltraps>
001021b2 <vector57>:
.globl vector57
vector57:
pushl $0
1021b2: 6a 00 push $0x0
pushl $57
1021b4: 6a 39 push $0x39
jmp __alltraps
1021b6: e9 76 08 00 00 jmp 102a31 <__alltraps>
001021bb <vector58>:
.globl vector58
vector58:
pushl $0
1021bb: 6a 00 push $0x0
pushl $58
1021bd: 6a 3a push $0x3a
jmp __alltraps
1021bf: e9 6d 08 00 00 jmp 102a31 <__alltraps>
001021c4 <vector59>:
.globl vector59
vector59:
pushl $0
1021c4: 6a 00 push $0x0
pushl $59
1021c6: 6a 3b push $0x3b
jmp __alltraps
1021c8: e9 64 08 00 00 jmp 102a31 <__alltraps>
001021cd <vector60>:
.globl vector60
vector60:
pushl $0
1021cd: 6a 00 push $0x0
pushl $60
1021cf: 6a 3c push $0x3c
jmp __alltraps
1021d1: e9 5b 08 00 00 jmp 102a31 <__alltraps>
001021d6 <vector61>:
.globl vector61
vector61:
pushl $0
1021d6: 6a 00 push $0x0
pushl $61
1021d8: 6a 3d push $0x3d
jmp __alltraps
1021da: e9 52 08 00 00 jmp 102a31 <__alltraps>
001021df <vector62>:
.globl vector62
vector62:
pushl $0
1021df: 6a 00 push $0x0
pushl $62
1021e1: 6a 3e push $0x3e
jmp __alltraps
1021e3: e9 49 08 00 00 jmp 102a31 <__alltraps>
001021e8 <vector63>:
.globl vector63
vector63:
pushl $0
1021e8: 6a 00 push $0x0
pushl $63
1021ea: 6a 3f push $0x3f
jmp __alltraps
1021ec: e9 40 08 00 00 jmp 102a31 <__alltraps>
001021f1 <vector64>:
.globl vector64
vector64:
pushl $0
1021f1: 6a 00 push $0x0
pushl $64
1021f3: 6a 40 push $0x40
jmp __alltraps
1021f5: e9 37 08 00 00 jmp 102a31 <__alltraps>
001021fa <vector65>:
.globl vector65
vector65:
pushl $0
1021fa: 6a 00 push $0x0
pushl $65
1021fc: 6a 41 push $0x41
jmp __alltraps
1021fe: e9 2e 08 00 00 jmp 102a31 <__alltraps>
00102203 <vector66>:
.globl vector66
vector66:
pushl $0
102203: 6a 00 push $0x0
pushl $66
102205: 6a 42 push $0x42
jmp __alltraps
102207: e9 25 08 00 00 jmp 102a31 <__alltraps>
0010220c <vector67>:
.globl vector67
vector67:
pushl $0
10220c: 6a 00 push $0x0
pushl $67
10220e: 6a 43 push $0x43
jmp __alltraps
102210: e9 1c 08 00 00 jmp 102a31 <__alltraps>
00102215 <vector68>:
.globl vector68
vector68:
pushl $0
102215: 6a 00 push $0x0
pushl $68
102217: 6a 44 push $0x44
jmp __alltraps
102219: e9 13 08 00 00 jmp 102a31 <__alltraps>
0010221e <vector69>:
.globl vector69
vector69:
pushl $0
10221e: 6a 00 push $0x0
pushl $69
102220: 6a 45 push $0x45
jmp __alltraps
102222: e9 0a 08 00 00 jmp 102a31 <__alltraps>
00102227 <vector70>:
.globl vector70
vector70:
pushl $0
102227: 6a 00 push $0x0
pushl $70
102229: 6a 46 push $0x46
jmp __alltraps
10222b: e9 01 08 00 00 jmp 102a31 <__alltraps>
00102230 <vector71>:
.globl vector71
vector71:
pushl $0
102230: 6a 00 push $0x0
pushl $71
102232: 6a 47 push $0x47
jmp __alltraps
102234: e9 f8 07 00 00 jmp 102a31 <__alltraps>
00102239 <vector72>:
.globl vector72
vector72:
pushl $0
102239: 6a 00 push $0x0
pushl $72
10223b: 6a 48 push $0x48
jmp __alltraps
10223d: e9 ef 07 00 00 jmp 102a31 <__alltraps>
00102242 <vector73>:
.globl vector73
vector73:
pushl $0
102242: 6a 00 push $0x0
pushl $73
102244: 6a 49 push $0x49
jmp __alltraps
102246: e9 e6 07 00 00 jmp 102a31 <__alltraps>
0010224b <vector74>:
.globl vector74
vector74:
pushl $0
10224b: 6a 00 push $0x0
pushl $74
10224d: 6a 4a push $0x4a
jmp __alltraps
10224f: e9 dd 07 00 00 jmp 102a31 <__alltraps>
00102254 <vector75>:
.globl vector75
vector75:
pushl $0
102254: 6a 00 push $0x0
pushl $75
102256: 6a 4b push $0x4b
jmp __alltraps
102258: e9 d4 07 00 00 jmp 102a31 <__alltraps>
0010225d <vector76>:
.globl vector76
vector76:
pushl $0
10225d: 6a 00 push $0x0
pushl $76
10225f: 6a 4c push $0x4c
jmp __alltraps
102261: e9 cb 07 00 00 jmp 102a31 <__alltraps>
00102266 <vector77>:
.globl vector77
vector77:
pushl $0
102266: 6a 00 push $0x0
pushl $77
102268: 6a 4d push $0x4d
jmp __alltraps
10226a: e9 c2 07 00 00 jmp 102a31 <__alltraps>
0010226f <vector78>:
.globl vector78
vector78:
pushl $0
10226f: 6a 00 push $0x0
pushl $78
102271: 6a 4e push $0x4e
jmp __alltraps
102273: e9 b9 07 00 00 jmp 102a31 <__alltraps>
00102278 <vector79>:
.globl vector79
vector79:
pushl $0
102278: 6a 00 push $0x0
pushl $79
10227a: 6a 4f push $0x4f
jmp __alltraps
10227c: e9 b0 07 00 00 jmp 102a31 <__alltraps>
00102281 <vector80>:
.globl vector80
vector80:
pushl $0
102281: 6a 00 push $0x0
pushl $80
102283: 6a 50 push $0x50
jmp __alltraps
102285: e9 a7 07 00 00 jmp 102a31 <__alltraps>
0010228a <vector81>:
.globl vector81
vector81:
pushl $0
10228a: 6a 00 push $0x0
pushl $81
10228c: 6a 51 push $0x51
jmp __alltraps
10228e: e9 9e 07 00 00 jmp 102a31 <__alltraps>
00102293 <vector82>:
.globl vector82
vector82:
pushl $0
102293: 6a 00 push $0x0
pushl $82
102295: 6a 52 push $0x52
jmp __alltraps
102297: e9 95 07 00 00 jmp 102a31 <__alltraps>
0010229c <vector83>:
.globl vector83
vector83:
pushl $0
10229c: 6a 00 push $0x0
pushl $83
10229e: 6a 53 push $0x53
jmp __alltraps
1022a0: e9 8c 07 00 00 jmp 102a31 <__alltraps>
001022a5 <vector84>:
.globl vector84
vector84:
pushl $0
1022a5: 6a 00 push $0x0
pushl $84
1022a7: 6a 54 push $0x54
jmp __alltraps
1022a9: e9 83 07 00 00 jmp 102a31 <__alltraps>
001022ae <vector85>:
.globl vector85
vector85:
pushl $0
1022ae: 6a 00 push $0x0
pushl $85
1022b0: 6a 55 push $0x55
jmp __alltraps
1022b2: e9 7a 07 00 00 jmp 102a31 <__alltraps>
001022b7 <vector86>:
.globl vector86
vector86:
pushl $0
1022b7: 6a 00 push $0x0
pushl $86
1022b9: 6a 56 push $0x56
jmp __alltraps
1022bb: e9 71 07 00 00 jmp 102a31 <__alltraps>
001022c0 <vector87>:
.globl vector87
vector87:
pushl $0
1022c0: 6a 00 push $0x0
pushl $87
1022c2: 6a 57 push $0x57
jmp __alltraps
1022c4: e9 68 07 00 00 jmp 102a31 <__alltraps>
001022c9 <vector88>:
.globl vector88
vector88:
pushl $0
1022c9: 6a 00 push $0x0
pushl $88
1022cb: 6a 58 push $0x58
jmp __alltraps
1022cd: e9 5f 07 00 00 jmp 102a31 <__alltraps>
001022d2 <vector89>:
.globl vector89
vector89:
pushl $0
1022d2: 6a 00 push $0x0
pushl $89
1022d4: 6a 59 push $0x59
jmp __alltraps
1022d6: e9 56 07 00 00 jmp 102a31 <__alltraps>
001022db <vector90>:
.globl vector90
vector90:
pushl $0
1022db: 6a 00 push $0x0
pushl $90
1022dd: 6a 5a push $0x5a
jmp __alltraps
1022df: e9 4d 07 00 00 jmp 102a31 <__alltraps>
001022e4 <vector91>:
.globl vector91
vector91:
pushl $0
1022e4: 6a 00 push $0x0
pushl $91
1022e6: 6a 5b push $0x5b
jmp __alltraps
1022e8: e9 44 07 00 00 jmp 102a31 <__alltraps>
001022ed <vector92>:
.globl vector92
vector92:
pushl $0
1022ed: 6a 00 push $0x0
pushl $92
1022ef: 6a 5c push $0x5c
jmp __alltraps
1022f1: e9 3b 07 00 00 jmp 102a31 <__alltraps>
001022f6 <vector93>:
.globl vector93
vector93:
pushl $0
1022f6: 6a 00 push $0x0
pushl $93
1022f8: 6a 5d push $0x5d
jmp __alltraps
1022fa: e9 32 07 00 00 jmp 102a31 <__alltraps>
001022ff <vector94>:
.globl vector94
vector94:
pushl $0
1022ff: 6a 00 push $0x0
pushl $94
102301: 6a 5e push $0x5e
jmp __alltraps
102303: e9 29 07 00 00 jmp 102a31 <__alltraps>
00102308 <vector95>:
.globl vector95
vector95:
pushl $0
102308: 6a 00 push $0x0
pushl $95
10230a: 6a 5f push $0x5f
jmp __alltraps
10230c: e9 20 07 00 00 jmp 102a31 <__alltraps>
00102311 <vector96>:
.globl vector96
vector96:
pushl $0
102311: 6a 00 push $0x0
pushl $96
102313: 6a 60 push $0x60
jmp __alltraps
102315: e9 17 07 00 00 jmp 102a31 <__alltraps>
0010231a <vector97>:
.globl vector97
vector97:
pushl $0
10231a: 6a 00 push $0x0
pushl $97
10231c: 6a 61 push $0x61
jmp __alltraps
10231e: e9 0e 07 00 00 jmp 102a31 <__alltraps>
00102323 <vector98>:
.globl vector98
vector98:
pushl $0
102323: 6a 00 push $0x0
pushl $98
102325: 6a 62 push $0x62
jmp __alltraps
102327: e9 05 07 00 00 jmp 102a31 <__alltraps>
0010232c <vector99>:
.globl vector99
vector99:
pushl $0
10232c: 6a 00 push $0x0
pushl $99
10232e: 6a 63 push $0x63
jmp __alltraps
102330: e9 fc 06 00 00 jmp 102a31 <__alltraps>
00102335 <vector100>:
.globl vector100
vector100:
pushl $0
102335: 6a 00 push $0x0
pushl $100
102337: 6a 64 push $0x64
jmp __alltraps
102339: e9 f3 06 00 00 jmp 102a31 <__alltraps>
0010233e <vector101>:
.globl vector101
vector101:
pushl $0
10233e: 6a 00 push $0x0
pushl $101
102340: 6a 65 push $0x65
jmp __alltraps
102342: e9 ea 06 00 00 jmp 102a31 <__alltraps>
00102347 <vector102>:
.globl vector102
vector102:
pushl $0
102347: 6a 00 push $0x0
pushl $102
102349: 6a 66 push $0x66
jmp __alltraps
10234b: e9 e1 06 00 00 jmp 102a31 <__alltraps>
00102350 <vector103>:
.globl vector103
vector103:
pushl $0
102350: 6a 00 push $0x0
pushl $103
102352: 6a 67 push $0x67
jmp __alltraps
102354: e9 d8 06 00 00 jmp 102a31 <__alltraps>
00102359 <vector104>:
.globl vector104
vector104:
pushl $0
102359: 6a 00 push $0x0
pushl $104
10235b: 6a 68 push $0x68
jmp __alltraps
10235d: e9 cf 06 00 00 jmp 102a31 <__alltraps>
00102362 <vector105>:
.globl vector105
vector105:
pushl $0
102362: 6a 00 push $0x0
pushl $105
102364: 6a 69 push $0x69
jmp __alltraps
102366: e9 c6 06 00 00 jmp 102a31 <__alltraps>
0010236b <vector106>:
.globl vector106
vector106:
pushl $0
10236b: 6a 00 push $0x0
pushl $106
10236d: 6a 6a push $0x6a
jmp __alltraps
10236f: e9 bd 06 00 00 jmp 102a31 <__alltraps>
00102374 <vector107>:
.globl vector107
vector107:
pushl $0
102374: 6a 00 push $0x0
pushl $107
102376: 6a 6b push $0x6b
jmp __alltraps
102378: e9 b4 06 00 00 jmp 102a31 <__alltraps>
0010237d <vector108>:
.globl vector108
vector108:
pushl $0
10237d: 6a 00 push $0x0
pushl $108
10237f: 6a 6c push $0x6c
jmp __alltraps
102381: e9 ab 06 00 00 jmp 102a31 <__alltraps>
00102386 <vector109>:
.globl vector109
vector109:
pushl $0
102386: 6a 00 push $0x0
pushl $109
102388: 6a 6d push $0x6d
jmp __alltraps
10238a: e9 a2 06 00 00 jmp 102a31 <__alltraps>
0010238f <vector110>:
.globl vector110
vector110:
pushl $0
10238f: 6a 00 push $0x0
pushl $110
102391: 6a 6e push $0x6e
jmp __alltraps
102393: e9 99 06 00 00 jmp 102a31 <__alltraps>
00102398 <vector111>:
.globl vector111
vector111:
pushl $0
102398: 6a 00 push $0x0
pushl $111
10239a: 6a 6f push $0x6f
jmp __alltraps
10239c: e9 90 06 00 00 jmp 102a31 <__alltraps>
001023a1 <vector112>:
.globl vector112
vector112:
pushl $0
1023a1: 6a 00 push $0x0
pushl $112
1023a3: 6a 70 push $0x70
jmp __alltraps
1023a5: e9 87 06 00 00 jmp 102a31 <__alltraps>
001023aa <vector113>:
.globl vector113
vector113:
pushl $0
1023aa: 6a 00 push $0x0
pushl $113
1023ac: 6a 71 push $0x71
jmp __alltraps
1023ae: e9 7e 06 00 00 jmp 102a31 <__alltraps>
001023b3 <vector114>:
.globl vector114
vector114:
pushl $0
1023b3: 6a 00 push $0x0
pushl $114
1023b5: 6a 72 push $0x72
jmp __alltraps
1023b7: e9 75 06 00 00 jmp 102a31 <__alltraps>
001023bc <vector115>:
.globl vector115
vector115:
pushl $0
1023bc: 6a 00 push $0x0
pushl $115
1023be: 6a 73 push $0x73
jmp __alltraps
1023c0: e9 6c 06 00 00 jmp 102a31 <__alltraps>
001023c5 <vector116>:
.globl vector116
vector116:
pushl $0
1023c5: 6a 00 push $0x0
pushl $116
1023c7: 6a 74 push $0x74
jmp __alltraps
1023c9: e9 63 06 00 00 jmp 102a31 <__alltraps>
001023ce <vector117>:
.globl vector117
vector117:
pushl $0
1023ce: 6a 00 push $0x0
pushl $117
1023d0: 6a 75 push $0x75
jmp __alltraps
1023d2: e9 5a 06 00 00 jmp 102a31 <__alltraps>
001023d7 <vector118>:
.globl vector118
vector118:
pushl $0
1023d7: 6a 00 push $0x0
pushl $118
1023d9: 6a 76 push $0x76
jmp __alltraps
1023db: e9 51 06 00 00 jmp 102a31 <__alltraps>
001023e0 <vector119>:
.globl vector119
vector119:
pushl $0
1023e0: 6a 00 push $0x0
pushl $119
1023e2: 6a 77 push $0x77
jmp __alltraps
1023e4: e9 48 06 00 00 jmp 102a31 <__alltraps>
001023e9 <vector120>:
.globl vector120
vector120:
pushl $0
1023e9: 6a 00 push $0x0
pushl $120
1023eb: 6a 78 push $0x78
jmp __alltraps
1023ed: e9 3f 06 00 00 jmp 102a31 <__alltraps>
001023f2 <vector121>:
.globl vector121
vector121:
pushl $0
1023f2: 6a 00 push $0x0
pushl $121
1023f4: 6a 79 push $0x79
jmp __alltraps
1023f6: e9 36 06 00 00 jmp 102a31 <__alltraps>
001023fb <vector122>:
.globl vector122
vector122:
pushl $0
1023fb: 6a 00 push $0x0
pushl $122
1023fd: 6a 7a push $0x7a
jmp __alltraps
1023ff: e9 2d 06 00 00 jmp 102a31 <__alltraps>
00102404 <vector123>:
.globl vector123
vector123:
pushl $0
102404: 6a 00 push $0x0
pushl $123
102406: 6a 7b push $0x7b
jmp __alltraps
102408: e9 24 06 00 00 jmp 102a31 <__alltraps>
0010240d <vector124>:
.globl vector124
vector124:
pushl $0
10240d: 6a 00 push $0x0
pushl $124
10240f: 6a 7c push $0x7c
jmp __alltraps
102411: e9 1b 06 00 00 jmp 102a31 <__alltraps>
00102416 <vector125>:
.globl vector125
vector125:
pushl $0
102416: 6a 00 push $0x0
pushl $125
102418: 6a 7d push $0x7d
jmp __alltraps
10241a: e9 12 06 00 00 jmp 102a31 <__alltraps>
0010241f <vector126>:
.globl vector126
vector126:
pushl $0
10241f: 6a 00 push $0x0
pushl $126
102421: 6a 7e push $0x7e
jmp __alltraps
102423: e9 09 06 00 00 jmp 102a31 <__alltraps>
00102428 <vector127>:
.globl vector127
vector127:
pushl $0
102428: 6a 00 push $0x0
pushl $127
10242a: 6a 7f push $0x7f
jmp __alltraps
10242c: e9 00 06 00 00 jmp 102a31 <__alltraps>
00102431 <vector128>:
.globl vector128
vector128:
pushl $0
102431: 6a 00 push $0x0
pushl $128
102433: 68 80 00 00 00 push $0x80
jmp __alltraps
102438: e9 f4 05 00 00 jmp 102a31 <__alltraps>
0010243d <vector129>:
.globl vector129
vector129:
pushl $0
10243d: 6a 00 push $0x0
pushl $129
10243f: 68 81 00 00 00 push $0x81
jmp __alltraps
102444: e9 e8 05 00 00 jmp 102a31 <__alltraps>
00102449 <vector130>:
.globl vector130
vector130:
pushl $0
102449: 6a 00 push $0x0
pushl $130
10244b: 68 82 00 00 00 push $0x82
jmp __alltraps
102450: e9 dc 05 00 00 jmp 102a31 <__alltraps>
00102455 <vector131>:
.globl vector131
vector131:
pushl $0
102455: 6a 00 push $0x0
pushl $131
102457: 68 83 00 00 00 push $0x83
jmp __alltraps
10245c: e9 d0 05 00 00 jmp 102a31 <__alltraps>
00102461 <vector132>:
.globl vector132
vector132:
pushl $0
102461: 6a 00 push $0x0
pushl $132
102463: 68 84 00 00 00 push $0x84
jmp __alltraps
102468: e9 c4 05 00 00 jmp 102a31 <__alltraps>
0010246d <vector133>:
.globl vector133
vector133:
pushl $0
10246d: 6a 00 push $0x0
pushl $133
10246f: 68 85 00 00 00 push $0x85
jmp __alltraps
102474: e9 b8 05 00 00 jmp 102a31 <__alltraps>
00102479 <vector134>:
.globl vector134
vector134:
pushl $0
102479: 6a 00 push $0x0
pushl $134
10247b: 68 86 00 00 00 push $0x86
jmp __alltraps
102480: e9 ac 05 00 00 jmp 102a31 <__alltraps>
00102485 <vector135>:
.globl vector135
vector135:
pushl $0
102485: 6a 00 push $0x0
pushl $135
102487: 68 87 00 00 00 push $0x87
jmp __alltraps
10248c: e9 a0 05 00 00 jmp 102a31 <__alltraps>
00102491 <vector136>:
.globl vector136
vector136:
pushl $0
102491: 6a 00 push $0x0
pushl $136
102493: 68 88 00 00 00 push $0x88
jmp __alltraps
102498: e9 94 05 00 00 jmp 102a31 <__alltraps>
0010249d <vector137>:
.globl vector137
vector137:
pushl $0
10249d: 6a 00 push $0x0
pushl $137
10249f: 68 89 00 00 00 push $0x89
jmp __alltraps
1024a4: e9 88 05 00 00 jmp 102a31 <__alltraps>
001024a9 <vector138>:
.globl vector138
vector138:
pushl $0
1024a9: 6a 00 push $0x0
pushl $138
1024ab: 68 8a 00 00 00 push $0x8a
jmp __alltraps
1024b0: e9 7c 05 00 00 jmp 102a31 <__alltraps>
001024b5 <vector139>:
.globl vector139
vector139:
pushl $0
1024b5: 6a 00 push $0x0
pushl $139
1024b7: 68 8b 00 00 00 push $0x8b
jmp __alltraps
1024bc: e9 70 05 00 00 jmp 102a31 <__alltraps>
001024c1 <vector140>:
.globl vector140
vector140:
pushl $0
1024c1: 6a 00 push $0x0
pushl $140
1024c3: 68 8c 00 00 00 push $0x8c
jmp __alltraps
1024c8: e9 64 05 00 00 jmp 102a31 <__alltraps>
001024cd <vector141>:
.globl vector141
vector141:
pushl $0
1024cd: 6a 00 push $0x0
pushl $141
1024cf: 68 8d 00 00 00 push $0x8d
jmp __alltraps
1024d4: e9 58 05 00 00 jmp 102a31 <__alltraps>
001024d9 <vector142>:
.globl vector142
vector142:
pushl $0
1024d9: 6a 00 push $0x0
pushl $142
1024db: 68 8e 00 00 00 push $0x8e
jmp __alltraps
1024e0: e9 4c 05 00 00 jmp 102a31 <__alltraps>
001024e5 <vector143>:
.globl vector143
vector143:
pushl $0
1024e5: 6a 00 push $0x0
pushl $143
1024e7: 68 8f 00 00 00 push $0x8f
jmp __alltraps
1024ec: e9 40 05 00 00 jmp 102a31 <__alltraps>
001024f1 <vector144>:
.globl vector144
vector144:
pushl $0
1024f1: 6a 00 push $0x0
pushl $144
1024f3: 68 90 00 00 00 push $0x90
jmp __alltraps
1024f8: e9 34 05 00 00 jmp 102a31 <__alltraps>
001024fd <vector145>:
.globl vector145
vector145:
pushl $0
1024fd: 6a 00 push $0x0
pushl $145
1024ff: 68 91 00 00 00 push $0x91
jmp __alltraps
102504: e9 28 05 00 00 jmp 102a31 <__alltraps>
00102509 <vector146>:
.globl vector146
vector146:
pushl $0
102509: 6a 00 push $0x0
pushl $146
10250b: 68 92 00 00 00 push $0x92
jmp __alltraps
102510: e9 1c 05 00 00 jmp 102a31 <__alltraps>
00102515 <vector147>:
.globl vector147
vector147:
pushl $0
102515: 6a 00 push $0x0
pushl $147
102517: 68 93 00 00 00 push $0x93
jmp __alltraps
10251c: e9 10 05 00 00 jmp 102a31 <__alltraps>
00102521 <vector148>:
.globl vector148
vector148:
pushl $0
102521: 6a 00 push $0x0
pushl $148
102523: 68 94 00 00 00 push $0x94
jmp __alltraps
102528: e9 04 05 00 00 jmp 102a31 <__alltraps>
0010252d <vector149>:
.globl vector149
vector149:
pushl $0
10252d: 6a 00 push $0x0
pushl $149
10252f: 68 95 00 00 00 push $0x95
jmp __alltraps
102534: e9 f8 04 00 00 jmp 102a31 <__alltraps>
00102539 <vector150>:
.globl vector150
vector150:
pushl $0
102539: 6a 00 push $0x0
pushl $150
10253b: 68 96 00 00 00 push $0x96
jmp __alltraps
102540: e9 ec 04 00 00 jmp 102a31 <__alltraps>
00102545 <vector151>:
.globl vector151
vector151:
pushl $0
102545: 6a 00 push $0x0
pushl $151
102547: 68 97 00 00 00 push $0x97
jmp __alltraps
10254c: e9 e0 04 00 00 jmp 102a31 <__alltraps>
00102551 <vector152>:
.globl vector152
vector152:
pushl $0
102551: 6a 00 push $0x0
pushl $152
102553: 68 98 00 00 00 push $0x98
jmp __alltraps
102558: e9 d4 04 00 00 jmp 102a31 <__alltraps>
0010255d <vector153>:
.globl vector153
vector153:
pushl $0
10255d: 6a 00 push $0x0
pushl $153
10255f: 68 99 00 00 00 push $0x99
jmp __alltraps
102564: e9 c8 04 00 00 jmp 102a31 <__alltraps>
00102569 <vector154>:
.globl vector154
vector154:
pushl $0
102569: 6a 00 push $0x0
pushl $154
10256b: 68 9a 00 00 00 push $0x9a
jmp __alltraps
102570: e9 bc 04 00 00 jmp 102a31 <__alltraps>
00102575 <vector155>:
.globl vector155
vector155:
pushl $0
102575: 6a 00 push $0x0
pushl $155
102577: 68 9b 00 00 00 push $0x9b
jmp __alltraps
10257c: e9 b0 04 00 00 jmp 102a31 <__alltraps>
00102581 <vector156>:
.globl vector156
vector156:
pushl $0
102581: 6a 00 push $0x0
pushl $156
102583: 68 9c 00 00 00 push $0x9c
jmp __alltraps
102588: e9 a4 04 00 00 jmp 102a31 <__alltraps>
0010258d <vector157>:
.globl vector157
vector157:
pushl $0
10258d: 6a 00 push $0x0
pushl $157
10258f: 68 9d 00 00 00 push $0x9d
jmp __alltraps
102594: e9 98 04 00 00 jmp 102a31 <__alltraps>
00102599 <vector158>:
.globl vector158
vector158:
pushl $0
102599: 6a 00 push $0x0
pushl $158
10259b: 68 9e 00 00 00 push $0x9e
jmp __alltraps
1025a0: e9 8c 04 00 00 jmp 102a31 <__alltraps>
001025a5 <vector159>:
.globl vector159
vector159:
pushl $0
1025a5: 6a 00 push $0x0
pushl $159
1025a7: 68 9f 00 00 00 push $0x9f
jmp __alltraps
1025ac: e9 80 04 00 00 jmp 102a31 <__alltraps>
001025b1 <vector160>:
.globl vector160
vector160:
pushl $0
1025b1: 6a 00 push $0x0
pushl $160
1025b3: 68 a0 00 00 00 push $0xa0
jmp __alltraps
1025b8: e9 74 04 00 00 jmp 102a31 <__alltraps>
001025bd <vector161>:
.globl vector161
vector161:
pushl $0
1025bd: 6a 00 push $0x0
pushl $161
1025bf: 68 a1 00 00 00 push $0xa1
jmp __alltraps
1025c4: e9 68 04 00 00 jmp 102a31 <__alltraps>
001025c9 <vector162>:
.globl vector162
vector162:
pushl $0
1025c9: 6a 00 push $0x0
pushl $162
1025cb: 68 a2 00 00 00 push $0xa2
jmp __alltraps
1025d0: e9 5c 04 00 00 jmp 102a31 <__alltraps>
001025d5 <vector163>:
.globl vector163
vector163:
pushl $0
1025d5: 6a 00 push $0x0
pushl $163
1025d7: 68 a3 00 00 00 push $0xa3
jmp __alltraps
1025dc: e9 50 04 00 00 jmp 102a31 <__alltraps>
001025e1 <vector164>:
.globl vector164
vector164:
pushl $0
1025e1: 6a 00 push $0x0
pushl $164
1025e3: 68 a4 00 00 00 push $0xa4
jmp __alltraps
1025e8: e9 44 04 00 00 jmp 102a31 <__alltraps>
001025ed <vector165>:
.globl vector165
vector165:
pushl $0
1025ed: 6a 00 push $0x0
pushl $165
1025ef: 68 a5 00 00 00 push $0xa5
jmp __alltraps
1025f4: e9 38 04 00 00 jmp 102a31 <__alltraps>
001025f9 <vector166>:
.globl vector166
vector166:
pushl $0
1025f9: 6a 00 push $0x0
pushl $166
1025fb: 68 a6 00 00 00 push $0xa6
jmp __alltraps
102600: e9 2c 04 00 00 jmp 102a31 <__alltraps>
00102605 <vector167>:
.globl vector167
vector167:
pushl $0
102605: 6a 00 push $0x0
pushl $167
102607: 68 a7 00 00 00 push $0xa7
jmp __alltraps
10260c: e9 20 04 00 00 jmp 102a31 <__alltraps>
00102611 <vector168>:
.globl vector168
vector168:
pushl $0
102611: 6a 00 push $0x0
pushl $168
102613: 68 a8 00 00 00 push $0xa8
jmp __alltraps
102618: e9 14 04 00 00 jmp 102a31 <__alltraps>
0010261d <vector169>:
.globl vector169
vector169:
pushl $0
10261d: 6a 00 push $0x0
pushl $169
10261f: 68 a9 00 00 00 push $0xa9
jmp __alltraps
102624: e9 08 04 00 00 jmp 102a31 <__alltraps>
00102629 <vector170>:
.globl vector170
vector170:
pushl $0
102629: 6a 00 push $0x0
pushl $170
10262b: 68 aa 00 00 00 push $0xaa
jmp __alltraps
102630: e9 fc 03 00 00 jmp 102a31 <__alltraps>
00102635 <vector171>:
.globl vector171
vector171:
pushl $0
102635: 6a 00 push $0x0
pushl $171
102637: 68 ab 00 00 00 push $0xab
jmp __alltraps
10263c: e9 f0 03 00 00 jmp 102a31 <__alltraps>
00102641 <vector172>:
.globl vector172
vector172:
pushl $0
102641: 6a 00 push $0x0
pushl $172
102643: 68 ac 00 00 00 push $0xac
jmp __alltraps
102648: e9 e4 03 00 00 jmp 102a31 <__alltraps>
0010264d <vector173>:
.globl vector173
vector173:
pushl $0
10264d: 6a 00 push $0x0
pushl $173
10264f: 68 ad 00 00 00 push $0xad
jmp __alltraps
102654: e9 d8 03 00 00 jmp 102a31 <__alltraps>
00102659 <vector174>:
.globl vector174
vector174:
pushl $0
102659: 6a 00 push $0x0
pushl $174
10265b: 68 ae 00 00 00 push $0xae
jmp __alltraps
102660: e9 cc 03 00 00 jmp 102a31 <__alltraps>
00102665 <vector175>:
.globl vector175
vector175:
pushl $0
102665: 6a 00 push $0x0
pushl $175
102667: 68 af 00 00 00 push $0xaf
jmp __alltraps
10266c: e9 c0 03 00 00 jmp 102a31 <__alltraps>
00102671 <vector176>:
.globl vector176
vector176:
pushl $0
102671: 6a 00 push $0x0
pushl $176
102673: 68 b0 00 00 00 push $0xb0
jmp __alltraps
102678: e9 b4 03 00 00 jmp 102a31 <__alltraps>
0010267d <vector177>:
.globl vector177
vector177:
pushl $0
10267d: 6a 00 push $0x0
pushl $177
10267f: 68 b1 00 00 00 push $0xb1
jmp __alltraps
102684: e9 a8 03 00 00 jmp 102a31 <__alltraps>
00102689 <vector178>:
.globl vector178
vector178:
pushl $0
102689: 6a 00 push $0x0
pushl $178
10268b: 68 b2 00 00 00 push $0xb2
jmp __alltraps
102690: e9 9c 03 00 00 jmp 102a31 <__alltraps>
00102695 <vector179>:
.globl vector179
vector179:
pushl $0
102695: 6a 00 push $0x0
pushl $179
102697: 68 b3 00 00 00 push $0xb3
jmp __alltraps
10269c: e9 90 03 00 00 jmp 102a31 <__alltraps>
001026a1 <vector180>:
.globl vector180
vector180:
pushl $0
1026a1: 6a 00 push $0x0
pushl $180
1026a3: 68 b4 00 00 00 push $0xb4
jmp __alltraps
1026a8: e9 84 03 00 00 jmp 102a31 <__alltraps>
001026ad <vector181>:
.globl vector181
vector181:
pushl $0
1026ad: 6a 00 push $0x0
pushl $181
1026af: 68 b5 00 00 00 push $0xb5
jmp __alltraps
1026b4: e9 78 03 00 00 jmp 102a31 <__alltraps>
001026b9 <vector182>:
.globl vector182
vector182:
pushl $0
1026b9: 6a 00 push $0x0
pushl $182
1026bb: 68 b6 00 00 00 push $0xb6
jmp __alltraps
1026c0: e9 6c 03 00 00 jmp 102a31 <__alltraps>
001026c5 <vector183>:
.globl vector183
vector183:
pushl $0
1026c5: 6a 00 push $0x0
pushl $183
1026c7: 68 b7 00 00 00 push $0xb7
jmp __alltraps
1026cc: e9 60 03 00 00 jmp 102a31 <__alltraps>
001026d1 <vector184>:
.globl vector184
vector184:
pushl $0
1026d1: 6a 00 push $0x0
pushl $184
1026d3: 68 b8 00 00 00 push $0xb8
jmp __alltraps
1026d8: e9 54 03 00 00 jmp 102a31 <__alltraps>
001026dd <vector185>:
.globl vector185
vector185:
pushl $0
1026dd: 6a 00 push $0x0
pushl $185
1026df: 68 b9 00 00 00 push $0xb9
jmp __alltraps
1026e4: e9 48 03 00 00 jmp 102a31 <__alltraps>
001026e9 <vector186>:
.globl vector186
vector186:
pushl $0
1026e9: 6a 00 push $0x0
pushl $186
1026eb: 68 ba 00 00 00 push $0xba
jmp __alltraps
1026f0: e9 3c 03 00 00 jmp 102a31 <__alltraps>
001026f5 <vector187>:
.globl vector187
vector187:
pushl $0
1026f5: 6a 00 push $0x0
pushl $187
1026f7: 68 bb 00 00 00 push $0xbb
jmp __alltraps
1026fc: e9 30 03 00 00 jmp 102a31 <__alltraps>
00102701 <vector188>:
.globl vector188
vector188:
pushl $0
102701: 6a 00 push $0x0
pushl $188
102703: 68 bc 00 00 00 push $0xbc
jmp __alltraps
102708: e9 24 03 00 00 jmp 102a31 <__alltraps>
0010270d <vector189>:
.globl vector189
vector189:
pushl $0
10270d: 6a 00 push $0x0
pushl $189
10270f: 68 bd 00 00 00 push $0xbd
jmp __alltraps
102714: e9 18 03 00 00 jmp 102a31 <__alltraps>
00102719 <vector190>:
.globl vector190
vector190:
pushl $0
102719: 6a 00 push $0x0
pushl $190
10271b: 68 be 00 00 00 push $0xbe
jmp __alltraps
102720: e9 0c 03 00 00 jmp 102a31 <__alltraps>
00102725 <vector191>:
.globl vector191
vector191:
pushl $0
102725: 6a 00 push $0x0
pushl $191
102727: 68 bf 00 00 00 push $0xbf
jmp __alltraps
10272c: e9 00 03 00 00 jmp 102a31 <__alltraps>
00102731 <vector192>:
.globl vector192
vector192:
pushl $0
102731: 6a 00 push $0x0
pushl $192
102733: 68 c0 00 00 00 push $0xc0
jmp __alltraps
102738: e9 f4 02 00 00 jmp 102a31 <__alltraps>
0010273d <vector193>:
.globl vector193
vector193:
pushl $0
10273d: 6a 00 push $0x0
pushl $193
10273f: 68 c1 00 00 00 push $0xc1
jmp __alltraps
102744: e9 e8 02 00 00 jmp 102a31 <__alltraps>
00102749 <vector194>:
.globl vector194
vector194:
pushl $0
102749: 6a 00 push $0x0
pushl $194
10274b: 68 c2 00 00 00 push $0xc2
jmp __alltraps
102750: e9 dc 02 00 00 jmp 102a31 <__alltraps>
00102755 <vector195>:
.globl vector195
vector195:
pushl $0
102755: 6a 00 push $0x0
pushl $195
102757: 68 c3 00 00 00 push $0xc3
jmp __alltraps
10275c: e9 d0 02 00 00 jmp 102a31 <__alltraps>
00102761 <vector196>:
.globl vector196
vector196:
pushl $0
102761: 6a 00 push $0x0
pushl $196
102763: 68 c4 00 00 00 push $0xc4
jmp __alltraps
102768: e9 c4 02 00 00 jmp 102a31 <__alltraps>
0010276d <vector197>:
.globl vector197
vector197:
pushl $0
10276d: 6a 00 push $0x0
pushl $197
10276f: 68 c5 00 00 00 push $0xc5
jmp __alltraps
102774: e9 b8 02 00 00 jmp 102a31 <__alltraps>
00102779 <vector198>:
.globl vector198
vector198:
pushl $0
102779: 6a 00 push $0x0
pushl $198
10277b: 68 c6 00 00 00 push $0xc6
jmp __alltraps
102780: e9 ac 02 00 00 jmp 102a31 <__alltraps>
00102785 <vector199>:
.globl vector199
vector199:
pushl $0
102785: 6a 00 push $0x0
pushl $199
102787: 68 c7 00 00 00 push $0xc7
jmp __alltraps
10278c: e9 a0 02 00 00 jmp 102a31 <__alltraps>
00102791 <vector200>:
.globl vector200
vector200:
pushl $0
102791: 6a 00 push $0x0
pushl $200
102793: 68 c8 00 00 00 push $0xc8
jmp __alltraps
102798: e9 94 02 00 00 jmp 102a31 <__alltraps>
0010279d <vector201>:
.globl vector201
vector201:
pushl $0
10279d: 6a 00 push $0x0
pushl $201
10279f: 68 c9 00 00 00 push $0xc9
jmp __alltraps
1027a4: e9 88 02 00 00 jmp 102a31 <__alltraps>
001027a9 <vector202>:
.globl vector202
vector202:
pushl $0
1027a9: 6a 00 push $0x0
pushl $202
1027ab: 68 ca 00 00 00 push $0xca
jmp __alltraps
1027b0: e9 7c 02 00 00 jmp 102a31 <__alltraps>
001027b5 <vector203>:
.globl vector203
vector203:
pushl $0
1027b5: 6a 00 push $0x0
pushl $203
1027b7: 68 cb 00 00 00 push $0xcb
jmp __alltraps
1027bc: e9 70 02 00 00 jmp 102a31 <__alltraps>
001027c1 <vector204>:
.globl vector204
vector204:
pushl $0
1027c1: 6a 00 push $0x0
pushl $204
1027c3: 68 cc 00 00 00 push $0xcc
jmp __alltraps
1027c8: e9 64 02 00 00 jmp 102a31 <__alltraps>
001027cd <vector205>:
.globl vector205
vector205:
pushl $0
1027cd: 6a 00 push $0x0
pushl $205
1027cf: 68 cd 00 00 00 push $0xcd
jmp __alltraps
1027d4: e9 58 02 00 00 jmp 102a31 <__alltraps>
001027d9 <vector206>:
.globl vector206
vector206:
pushl $0
1027d9: 6a 00 push $0x0
pushl $206
1027db: 68 ce 00 00 00 push $0xce
jmp __alltraps
1027e0: e9 4c 02 00 00 jmp 102a31 <__alltraps>
001027e5 <vector207>:
.globl vector207
vector207:
pushl $0
1027e5: 6a 00 push $0x0
pushl $207
1027e7: 68 cf 00 00 00 push $0xcf
jmp __alltraps
1027ec: e9 40 02 00 00 jmp 102a31 <__alltraps>
001027f1 <vector208>:
.globl vector208
vector208:
pushl $0
1027f1: 6a 00 push $0x0
pushl $208
1027f3: 68 d0 00 00 00 push $0xd0
jmp __alltraps
1027f8: e9 34 02 00 00 jmp 102a31 <__alltraps>
001027fd <vector209>:
.globl vector209
vector209:
pushl $0
1027fd: 6a 00 push $0x0
pushl $209
1027ff: 68 d1 00 00 00 push $0xd1
jmp __alltraps
102804: e9 28 02 00 00 jmp 102a31 <__alltraps>
00102809 <vector210>:
.globl vector210
vector210:
pushl $0
102809: 6a 00 push $0x0
pushl $210
10280b: 68 d2 00 00 00 push $0xd2
jmp __alltraps
102810: e9 1c 02 00 00 jmp 102a31 <__alltraps>
00102815 <vector211>:
.globl vector211
vector211:
pushl $0
102815: 6a 00 push $0x0
pushl $211
102817: 68 d3 00 00 00 push $0xd3
jmp __alltraps
10281c: e9 10 02 00 00 jmp 102a31 <__alltraps>
00102821 <vector212>:
.globl vector212
vector212:
pushl $0
102821: 6a 00 push $0x0
pushl $212
102823: 68 d4 00 00 00 push $0xd4
jmp __alltraps
102828: e9 04 02 00 00 jmp 102a31 <__alltraps>
0010282d <vector213>:
.globl vector213
vector213:
pushl $0
10282d: 6a 00 push $0x0
pushl $213
10282f: 68 d5 00 00 00 push $0xd5
jmp __alltraps
102834: e9 f8 01 00 00 jmp 102a31 <__alltraps>
00102839 <vector214>:
.globl vector214
vector214:
pushl $0
102839: 6a 00 push $0x0
pushl $214
10283b: 68 d6 00 00 00 push $0xd6
jmp __alltraps
102840: e9 ec 01 00 00 jmp 102a31 <__alltraps>
00102845 <vector215>:
.globl vector215
vector215:
pushl $0
102845: 6a 00 push $0x0
pushl $215
102847: 68 d7 00 00 00 push $0xd7
jmp __alltraps
10284c: e9 e0 01 00 00 jmp 102a31 <__alltraps>
00102851 <vector216>:
.globl vector216
vector216:
pushl $0
102851: 6a 00 push $0x0
pushl $216
102853: 68 d8 00 00 00 push $0xd8
jmp __alltraps
102858: e9 d4 01 00 00 jmp 102a31 <__alltraps>
0010285d <vector217>:
.globl vector217
vector217:
pushl $0
10285d: 6a 00 push $0x0
pushl $217
10285f: 68 d9 00 00 00 push $0xd9
jmp __alltraps
102864: e9 c8 01 00 00 jmp 102a31 <__alltraps>
00102869 <vector218>:
.globl vector218
vector218:
pushl $0
102869: 6a 00 push $0x0
pushl $218
10286b: 68 da 00 00 00 push $0xda
jmp __alltraps
102870: e9 bc 01 00 00 jmp 102a31 <__alltraps>
00102875 <vector219>:
.globl vector219
vector219:
pushl $0
102875: 6a 00 push $0x0
pushl $219
102877: 68 db 00 00 00 push $0xdb
jmp __alltraps
10287c: e9 b0 01 00 00 jmp 102a31 <__alltraps>
00102881 <vector220>:
.globl vector220
vector220:
pushl $0
102881: 6a 00 push $0x0
pushl $220
102883: 68 dc 00 00 00 push $0xdc
jmp __alltraps
102888: e9 a4 01 00 00 jmp 102a31 <__alltraps>
0010288d <vector221>:
.globl vector221
vector221:
pushl $0
10288d: 6a 00 push $0x0
pushl $221
10288f: 68 dd 00 00 00 push $0xdd
jmp __alltraps
102894: e9 98 01 00 00 jmp 102a31 <__alltraps>
00102899 <vector222>:
.globl vector222
vector222:
pushl $0
102899: 6a 00 push $0x0
pushl $222
10289b: 68 de 00 00 00 push $0xde
jmp __alltraps
1028a0: e9 8c 01 00 00 jmp 102a31 <__alltraps>
001028a5 <vector223>:
.globl vector223
vector223:
pushl $0
1028a5: 6a 00 push $0x0
pushl $223
1028a7: 68 df 00 00 00 push $0xdf
jmp __alltraps
1028ac: e9 80 01 00 00 jmp 102a31 <__alltraps>
001028b1 <vector224>:
.globl vector224
vector224:
pushl $0
1028b1: 6a 00 push $0x0
pushl $224
1028b3: 68 e0 00 00 00 push $0xe0
jmp __alltraps
1028b8: e9 74 01 00 00 jmp 102a31 <__alltraps>
001028bd <vector225>:
.globl vector225
vector225:
pushl $0
1028bd: 6a 00 push $0x0
pushl $225
1028bf: 68 e1 00 00 00 push $0xe1
jmp __alltraps
1028c4: e9 68 01 00 00 jmp 102a31 <__alltraps>
001028c9 <vector226>:
.globl vector226
vector226:
pushl $0
1028c9: 6a 00 push $0x0
pushl $226
1028cb: 68 e2 00 00 00 push $0xe2
jmp __alltraps
1028d0: e9 5c 01 00 00 jmp 102a31 <__alltraps>
001028d5 <vector227>:
.globl vector227
vector227:
pushl $0
1028d5: 6a 00 push $0x0
pushl $227
1028d7: 68 e3 00 00 00 push $0xe3
jmp __alltraps
1028dc: e9 50 01 00 00 jmp 102a31 <__alltraps>
001028e1 <vector228>:
.globl vector228
vector228:
pushl $0
1028e1: 6a 00 push $0x0
pushl $228
1028e3: 68 e4 00 00 00 push $0xe4
jmp __alltraps
1028e8: e9 44 01 00 00 jmp 102a31 <__alltraps>
001028ed <vector229>:
.globl vector229
vector229:
pushl $0
1028ed: 6a 00 push $0x0
pushl $229
1028ef: 68 e5 00 00 00 push $0xe5
jmp __alltraps
1028f4: e9 38 01 00 00 jmp 102a31 <__alltraps>
001028f9 <vector230>:
.globl vector230
vector230:
pushl $0
1028f9: 6a 00 push $0x0
pushl $230
1028fb: 68 e6 00 00 00 push $0xe6
jmp __alltraps
102900: e9 2c 01 00 00 jmp 102a31 <__alltraps>
00102905 <vector231>:
.globl vector231
vector231:
pushl $0
102905: 6a 00 push $0x0
pushl $231
102907: 68 e7 00 00 00 push $0xe7
jmp __alltraps
10290c: e9 20 01 00 00 jmp 102a31 <__alltraps>
00102911 <vector232>:
.globl vector232
vector232:
pushl $0
102911: 6a 00 push $0x0
pushl $232
102913: 68 e8 00 00 00 push $0xe8
jmp __alltraps
102918: e9 14 01 00 00 jmp 102a31 <__alltraps>
0010291d <vector233>:
.globl vector233
vector233:
pushl $0
10291d: 6a 00 push $0x0
pushl $233
10291f: 68 e9 00 00 00 push $0xe9
jmp __alltraps
102924: e9 08 01 00 00 jmp 102a31 <__alltraps>
00102929 <vector234>:
.globl vector234
vector234:
pushl $0
102929: 6a 00 push $0x0
pushl $234
10292b: 68 ea 00 00 00 push $0xea
jmp __alltraps
102930: e9 fc 00 00 00 jmp 102a31 <__alltraps>
00102935 <vector235>:
.globl vector235
vector235:
pushl $0
102935: 6a 00 push $0x0
pushl $235
102937: 68 eb 00 00 00 push $0xeb
jmp __alltraps
10293c: e9 f0 00 00 00 jmp 102a31 <__alltraps>
00102941 <vector236>:
.globl vector236
vector236:
pushl $0
102941: 6a 00 push $0x0
pushl $236
102943: 68 ec 00 00 00 push $0xec
jmp __alltraps
102948: e9 e4 00 00 00 jmp 102a31 <__alltraps>
0010294d <vector237>:
.globl vector237
vector237:
pushl $0
10294d: 6a 00 push $0x0
pushl $237
10294f: 68 ed 00 00 00 push $0xed
jmp __alltraps
102954: e9 d8 00 00 00 jmp 102a31 <__alltraps>
00102959 <vector238>:
.globl vector238
vector238:
pushl $0
102959: 6a 00 push $0x0
pushl $238
10295b: 68 ee 00 00 00 push $0xee
jmp __alltraps
102960: e9 cc 00 00 00 jmp 102a31 <__alltraps>
00102965 <vector239>:
.globl vector239
vector239:
pushl $0
102965: 6a 00 push $0x0
pushl $239
102967: 68 ef 00 00 00 push $0xef
jmp __alltraps
10296c: e9 c0 00 00 00 jmp 102a31 <__alltraps>
00102971 <vector240>:
.globl vector240
vector240:
pushl $0
102971: 6a 00 push $0x0
pushl $240
102973: 68 f0 00 00 00 push $0xf0
jmp __alltraps
102978: e9 b4 00 00 00 jmp 102a31 <__alltraps>
0010297d <vector241>:
.globl vector241
vector241:
pushl $0
10297d: 6a 00 push $0x0
pushl $241
10297f: 68 f1 00 00 00 push $0xf1
jmp __alltraps
102984: e9 a8 00 00 00 jmp 102a31 <__alltraps>
00102989 <vector242>:
.globl vector242
vector242:
pushl $0
102989: 6a 00 push $0x0
pushl $242
10298b: 68 f2 00 00 00 push $0xf2
jmp __alltraps
102990: e9 9c 00 00 00 jmp 102a31 <__alltraps>
00102995 <vector243>:
.globl vector243
vector243:
pushl $0
102995: 6a 00 push $0x0
pushl $243
102997: 68 f3 00 00 00 push $0xf3
jmp __alltraps
10299c: e9 90 00 00 00 jmp 102a31 <__alltraps>
001029a1 <vector244>:
.globl vector244
vector244:
pushl $0
1029a1: 6a 00 push $0x0
pushl $244
1029a3: 68 f4 00 00 00 push $0xf4
jmp __alltraps
1029a8: e9 84 00 00 00 jmp 102a31 <__alltraps>
001029ad <vector245>:
.globl vector245
vector245:
pushl $0
1029ad: 6a 00 push $0x0
pushl $245
1029af: 68 f5 00 00 00 push $0xf5
jmp __alltraps
1029b4: e9 78 00 00 00 jmp 102a31 <__alltraps>
001029b9 <vector246>:
.globl vector246
vector246:
pushl $0
1029b9: 6a 00 push $0x0
pushl $246
1029bb: 68 f6 00 00 00 push $0xf6
jmp __alltraps
1029c0: e9 6c 00 00 00 jmp 102a31 <__alltraps>
001029c5 <vector247>:
.globl vector247
vector247:
pushl $0
1029c5: 6a 00 push $0x0
pushl $247
1029c7: 68 f7 00 00 00 push $0xf7
jmp __alltraps
1029cc: e9 60 00 00 00 jmp 102a31 <__alltraps>
001029d1 <vector248>:
.globl vector248
vector248:
pushl $0
1029d1: 6a 00 push $0x0
pushl $248
1029d3: 68 f8 00 00 00 push $0xf8
jmp __alltraps
1029d8: e9 54 00 00 00 jmp 102a31 <__alltraps>
001029dd <vector249>:
.globl vector249
vector249:
pushl $0
1029dd: 6a 00 push $0x0
pushl $249
1029df: 68 f9 00 00 00 push $0xf9
jmp __alltraps
1029e4: e9 48 00 00 00 jmp 102a31 <__alltraps>
001029e9 <vector250>:
.globl vector250
vector250:
pushl $0
1029e9: 6a 00 push $0x0
pushl $250
1029eb: 68 fa 00 00 00 push $0xfa
jmp __alltraps
1029f0: e9 3c 00 00 00 jmp 102a31 <__alltraps>
001029f5 <vector251>:
.globl vector251
vector251:
pushl $0
1029f5: 6a 00 push $0x0
pushl $251
1029f7: 68 fb 00 00 00 push $0xfb
jmp __alltraps
1029fc: e9 30 00 00 00 jmp 102a31 <__alltraps>
00102a01 <vector252>:
.globl vector252
vector252:
pushl $0
102a01: 6a 00 push $0x0
pushl $252
102a03: 68 fc 00 00 00 push $0xfc
jmp __alltraps
102a08: e9 24 00 00 00 jmp 102a31 <__alltraps>
00102a0d <vector253>:
.globl vector253
vector253:
pushl $0
102a0d: 6a 00 push $0x0
pushl $253
102a0f: 68 fd 00 00 00 push $0xfd
jmp __alltraps
102a14: e9 18 00 00 00 jmp 102a31 <__alltraps>
00102a19 <vector254>:
.globl vector254
vector254:
pushl $0
102a19: 6a 00 push $0x0
pushl $254
102a1b: 68 fe 00 00 00 push $0xfe
jmp __alltraps
102a20: e9 0c 00 00 00 jmp 102a31 <__alltraps>
00102a25 <vector255>:
.globl vector255
vector255:
pushl $0
102a25: 6a 00 push $0x0
pushl $255
102a27: 68 ff 00 00 00 push $0xff
jmp __alltraps
102a2c: e9 00 00 00 00 jmp 102a31 <__alltraps>
00102a31 <__alltraps>:
.text
.globl __alltraps
__alltraps:
# push registers to build a trap frame
# therefore make the stack look like a struct trapframe
pushl %ds
102a31: 1e push %ds
pushl %es
102a32: 06 push %es
pushl %fs
102a33: 0f a0 push %fs
pushl %gs
102a35: 0f a8 push %gs
pushal
102a37: 60 pusha
# load GD_KDATA into %ds and %es to set up data segments for kernel
movl $GD_KDATA, %eax
102a38: b8 10 00 00 00 mov $0x10,%eax
movw %ax, %ds
102a3d: 8e d8 mov %eax,%ds
movw %ax, %es
102a3f: 8e c0 mov %eax,%es
# push %esp to pass a pointer to the trapframe as an argument to trap()
pushl %esp
102a41: 54 push %esp
# call trap(tf), where tf=%esp
call trap
102a42: e8 63 f5 ff ff call 101faa <trap>
# pop the pushed stack pointer
popl %esp
102a47: 5c pop %esp
00102a48 <__trapret>:
# return falls through to trapret...
.globl __trapret
__trapret:
# restore registers from stack
popal
102a48: 61 popa
# restore %ds, %es, %fs and %gs
popl %gs
102a49: 0f a9 pop %gs
popl %fs
102a4b: 0f a1 pop %fs
popl %es
102a4d: 07 pop %es
popl %ds
102a4e: 1f pop %ds
# get rid of the trap number and error code
addl $0x8, %esp
102a4f: 83 c4 08 add $0x8,%esp
iret
102a52: cf iret
00102a53 <page2ppn>:
extern struct Page *pages;
extern size_t npage;
static inline ppn_t
page2ppn(struct Page *page) {
102a53: 55 push %ebp
102a54: 89 e5 mov %esp,%ebp
return page - pages;
102a56: 8b 45 08 mov 0x8(%ebp),%eax
102a59: 8b 15 64 a9 11 00 mov 0x11a964,%edx
102a5f: 29 d0 sub %edx,%eax
102a61: c1 f8 02 sar $0x2,%eax
102a64: 69 c0 cd cc cc cc imul $0xcccccccd,%eax,%eax
}
102a6a: 5d pop %ebp
102a6b: c3 ret
00102a6c <page2pa>:
static inline uintptr_t
page2pa(struct Page *page) {
102a6c: 55 push %ebp
102a6d: 89 e5 mov %esp,%ebp
return page2ppn(page) << PGSHIFT;
102a6f: ff 75 08 pushl 0x8(%ebp)
102a72: e8 dc ff ff ff call 102a53 <page2ppn>
102a77: 83 c4 04 add $0x4,%esp
102a7a: c1 e0 0c shl $0xc,%eax
}
102a7d: c9 leave
102a7e: c3 ret
00102a7f <pa2page>:
static inline struct Page *
pa2page(uintptr_t pa) {
102a7f: 55 push %ebp
102a80: 89 e5 mov %esp,%ebp
102a82: 83 ec 08 sub $0x8,%esp
if (PPN(pa) >= npage) {
102a85: 8b 45 08 mov 0x8(%ebp),%eax
102a88: c1 e8 0c shr $0xc,%eax
102a8b: 89 c2 mov %eax,%edx
102a8d: a1 c0 a8 11 00 mov 0x11a8c0,%eax
102a92: 39 c2 cmp %eax,%edx
102a94: 72 14 jb 102aaa <pa2page+0x2b>
panic("pa2page called with invalid pa");
102a96: 83 ec 04 sub $0x4,%esp
102a99: 68 50 70 10 00 push $0x107050
102a9e: 6a 5a push $0x5a
102aa0: 68 6f 70 10 00 push $0x10706f
102aa5: e8 23 d9 ff ff call 1003cd <__panic>
}
return &pages[PPN(pa)];
102aaa: 8b 0d 64 a9 11 00 mov 0x11a964,%ecx
102ab0: 8b 45 08 mov 0x8(%ebp),%eax
102ab3: c1 e8 0c shr $0xc,%eax
102ab6: 89 c2 mov %eax,%edx
102ab8: 89 d0 mov %edx,%eax
102aba: c1 e0 02 shl $0x2,%eax
102abd: 01 d0 add %edx,%eax
102abf: c1 e0 02 shl $0x2,%eax
102ac2: 01 c8 add %ecx,%eax
}
102ac4: c9 leave
102ac5: c3 ret
00102ac6 <page2kva>:
static inline void *
page2kva(struct Page *page) {
102ac6: 55 push %ebp
102ac7: 89 e5 mov %esp,%ebp
102ac9: 83 ec 18 sub $0x18,%esp
return KADDR(page2pa(page));
102acc: ff 75 08 pushl 0x8(%ebp)
102acf: e8 98 ff ff ff call 102a6c <page2pa>
102ad4: 83 c4 04 add $0x4,%esp
102ad7: 89 45 f4 mov %eax,-0xc(%ebp)
102ada: 8b 45 f4 mov -0xc(%ebp),%eax
102add: c1 e8 0c shr $0xc,%eax
102ae0: 89 45 f0 mov %eax,-0x10(%ebp)
102ae3: a1 c0 a8 11 00 mov 0x11a8c0,%eax
102ae8: 39 45 f0 cmp %eax,-0x10(%ebp)
102aeb: 72 14 jb 102b01 <page2kva+0x3b>
102aed: ff 75 f4 pushl -0xc(%ebp)
102af0: 68 80 70 10 00 push $0x107080
102af5: 6a 61 push $0x61
102af7: 68 6f 70 10 00 push $0x10706f
102afc: e8 cc d8 ff ff call 1003cd <__panic>
102b01: 8b 45 f4 mov -0xc(%ebp),%eax
102b04: 2d 00 00 00 40 sub $0x40000000,%eax
}
102b09: c9 leave
102b0a: c3 ret
00102b0b <pte2page>:
kva2page(void *kva) {
return pa2page(PADDR(kva));
}
static inline struct Page *
pte2page(pte_t pte) {
102b0b: 55 push %ebp
102b0c: 89 e5 mov %esp,%ebp
102b0e: 83 ec 08 sub $0x8,%esp
if (!(pte & PTE_P)) {
102b11: 8b 45 08 mov 0x8(%ebp),%eax
102b14: 83 e0 01 and $0x1,%eax
102b17: 85 c0 test %eax,%eax
102b19: 75 14 jne 102b2f <pte2page+0x24>
panic("pte2page called with invalid pte");
102b1b: 83 ec 04 sub $0x4,%esp
102b1e: 68 a4 70 10 00 push $0x1070a4
102b23: 6a 6c push $0x6c
102b25: 68 6f 70 10 00 push $0x10706f
102b2a: e8 9e d8 ff ff call 1003cd <__panic>
}
return pa2page(PTE_ADDR(pte));
102b2f: 8b 45 08 mov 0x8(%ebp),%eax
102b32: 25 00 f0 ff ff and $0xfffff000,%eax
102b37: 83 ec 0c sub $0xc,%esp
102b3a: 50 push %eax
102b3b: e8 3f ff ff ff call 102a7f <pa2page>
102b40: 83 c4 10 add $0x10,%esp
}
102b43: c9 leave
102b44: c3 ret
00102b45 <pde2page>:
static inline struct Page *
pde2page(pde_t pde) {
102b45: 55 push %ebp
102b46: 89 e5 mov %esp,%ebp
102b48: 83 ec 08 sub $0x8,%esp
return pa2page(PDE_ADDR(pde));
102b4b: 8b 45 08 mov 0x8(%ebp),%eax
102b4e: 25 00 f0 ff ff and $0xfffff000,%eax
102b53: 83 ec 0c sub $0xc,%esp
102b56: 50 push %eax
102b57: e8 23 ff ff ff call 102a7f <pa2page>
102b5c: 83 c4 10 add $0x10,%esp
}
102b5f: c9 leave
102b60: c3 ret
00102b61 <page_ref>:
static inline int
page_ref(struct Page *page) {
102b61: 55 push %ebp
102b62: 89 e5 mov %esp,%ebp
return page->ref;
102b64: 8b 45 08 mov 0x8(%ebp),%eax
102b67: 8b 00 mov (%eax),%eax
}
102b69: 5d pop %ebp
102b6a: c3 ret
00102b6b <set_page_ref>:
static inline void
set_page_ref(struct Page *page, int val) {
102b6b: 55 push %ebp
102b6c: 89 e5 mov %esp,%ebp
page->ref = val;
102b6e: 8b 45 08 mov 0x8(%ebp),%eax
102b71: 8b 55 0c mov 0xc(%ebp),%edx
102b74: 89 10 mov %edx,(%eax)
}
102b76: 90 nop
102b77: 5d pop %ebp
102b78: c3 ret
00102b79 <page_ref_inc>:
static inline int
page_ref_inc(struct Page *page) {
102b79: 55 push %ebp
102b7a: 89 e5 mov %esp,%ebp
page->ref += 1;
102b7c: 8b 45 08 mov 0x8(%ebp),%eax
102b7f: 8b 00 mov (%eax),%eax
102b81: 8d 50 01 lea 0x1(%eax),%edx
102b84: 8b 45 08 mov 0x8(%ebp),%eax
102b87: 89 10 mov %edx,(%eax)
return page->ref;
102b89: 8b 45 08 mov 0x8(%ebp),%eax
102b8c: 8b 00 mov (%eax),%eax
}
102b8e: 5d pop %ebp
102b8f: c3 ret
00102b90 <page_ref_dec>:
static inline int
page_ref_dec(struct Page *page) {
102b90: 55 push %ebp
102b91: 89 e5 mov %esp,%ebp
page->ref -= 1;
102b93: 8b 45 08 mov 0x8(%ebp),%eax
102b96: 8b 00 mov (%eax),%eax
102b98: 8d 50 ff lea -0x1(%eax),%edx
102b9b: 8b 45 08 mov 0x8(%ebp),%eax
102b9e: 89 10 mov %edx,(%eax)
return page->ref;
102ba0: 8b 45 08 mov 0x8(%ebp),%eax
102ba3: 8b 00 mov (%eax),%eax
}
102ba5: 5d pop %ebp
102ba6: c3 ret
00102ba7 <__intr_save>:
#include <x86.h>
#include <intr.h>
#include <mmu.h>
static inline bool
__intr_save(void) {
102ba7: 55 push %ebp
102ba8: 89 e5 mov %esp,%ebp
102baa: 83 ec 18 sub $0x18,%esp
}
static inline uint32_t
read_eflags(void) {
uint32_t eflags;
asm volatile ("pushfl; popl %0" : "=r" (eflags));
102bad: 9c pushf
102bae: 58 pop %eax
102baf: 89 45 f4 mov %eax,-0xc(%ebp)
return eflags;
102bb2: 8b 45 f4 mov -0xc(%ebp),%eax
if (read_eflags() & FL_IF) {
102bb5: 25 00 02 00 00 and $0x200,%eax
102bba: 85 c0 test %eax,%eax
102bbc: 74 0c je 102bca <__intr_save+0x23>
intr_disable();
102bbe: e8 9e ec ff ff call 101861 <intr_disable>
return 1;
102bc3: b8 01 00 00 00 mov $0x1,%eax
102bc8: eb 05 jmp 102bcf <__intr_save+0x28>
}
return 0;
102bca: b8 00 00 00 00 mov $0x0,%eax
}
102bcf: c9 leave
102bd0: c3 ret
00102bd1 <__intr_restore>:
static inline void
__intr_restore(bool flag) {
102bd1: 55 push %ebp
102bd2: 89 e5 mov %esp,%ebp
102bd4: 83 ec 08 sub $0x8,%esp
if (flag) {
102bd7: 83 7d 08 00 cmpl $0x0,0x8(%ebp)
102bdb: 74 05 je 102be2 <__intr_restore+0x11>
intr_enable();
102bdd: e8 78 ec ff ff call 10185a <intr_enable>
}
}
102be2: 90 nop
102be3: c9 leave
102be4: c3 ret
00102be5 <lgdt>:
/* *
* lgdt - load the global descriptor table register and reset the
* data/code segement registers for kernel.
* */
static inline void
lgdt(struct pseudodesc *pd) {
102be5: 55 push %ebp
102be6: 89 e5 mov %esp,%ebp
asm volatile ("lgdt (%0)" :: "r" (pd));
102be8: 8b 45 08 mov 0x8(%ebp),%eax
102beb: 0f 01 10 lgdtl (%eax)
asm volatile ("movw %%ax, %%gs" :: "a" (USER_DS));
102bee: b8 23 00 00 00 mov $0x23,%eax
102bf3: 8e e8 mov %eax,%gs
asm volatile ("movw %%ax, %%fs" :: "a" (USER_DS));
102bf5: b8 23 00 00 00 mov $0x23,%eax
102bfa: 8e e0 mov %eax,%fs
asm volatile ("movw %%ax, %%es" :: "a" (KERNEL_DS));
102bfc: b8 10 00 00 00 mov $0x10,%eax
102c01: 8e c0 mov %eax,%es
asm volatile ("movw %%ax, %%ds" :: "a" (KERNEL_DS));
102c03: b8 10 00 00 00 mov $0x10,%eax
102c08: 8e d8 mov %eax,%ds
asm volatile ("movw %%ax, %%ss" :: "a" (KERNEL_DS));
102c0a: b8 10 00 00 00 mov $0x10,%eax
102c0f: 8e d0 mov %eax,%ss
// reload cs
asm volatile ("ljmp %0, $1f\n 1:\n" :: "i" (KERNEL_CS));
102c11: ea 18 2c 10 00 08 00 ljmp $0x8,$0x102c18
}
102c18: 90 nop
102c19: 5d pop %ebp
102c1a: c3 ret
00102c1b <load_esp0>:
* load_esp0 - change the ESP0 in default task state segment,
* so that we can use different kernel stack when we trap frame
* user to kernel.
* */
void
load_esp0(uintptr_t esp0) {
102c1b: 55 push %ebp
102c1c: 89 e5 mov %esp,%ebp
ts.ts_esp0 = esp0;
102c1e: 8b 45 08 mov 0x8(%ebp),%eax
102c21: a3 e4 a8 11 00 mov %eax,0x11a8e4
}
102c26: 90 nop
102c27: 5d pop %ebp
102c28: c3 ret
00102c29 <gdt_init>:
/* gdt_init - initialize the default GDT and TSS */
static void
gdt_init(void) {
102c29: 55 push %ebp
102c2a: 89 e5 mov %esp,%ebp
102c2c: 83 ec 10 sub $0x10,%esp
// set boot kernel stack and default SS0
load_esp0((uintptr_t)bootstacktop);
102c2f: b8 00 90 11 00 mov $0x119000,%eax
102c34: 50 push %eax
102c35: e8 e1 ff ff ff call 102c1b <load_esp0>
102c3a: 83 c4 04 add $0x4,%esp
ts.ts_ss0 = KERNEL_DS;
102c3d: 66 c7 05 e8 a8 11 00 movw $0x10,0x11a8e8
102c44: 10 00
// initialize the TSS filed of the gdt
gdt[SEG_TSS] = SEGTSS(STS_T32A, (uintptr_t)&ts, sizeof(ts), DPL_KERNEL);
102c46: 66 c7 05 28 9a 11 00 movw $0x68,0x119a28
102c4d: 68 00
102c4f: b8 e0 a8 11 00 mov $0x11a8e0,%eax
102c54: 66 a3 2a 9a 11 00 mov %ax,0x119a2a
102c5a: b8 e0 a8 11 00 mov $0x11a8e0,%eax
102c5f: c1 e8 10 shr $0x10,%eax
102c62: a2 2c 9a 11 00 mov %al,0x119a2c
102c67: 0f b6 05 2d 9a 11 00 movzbl 0x119a2d,%eax
102c6e: 83 e0 f0 and $0xfffffff0,%eax
102c71: 83 c8 09 or $0x9,%eax
102c74: a2 2d 9a 11 00 mov %al,0x119a2d
102c79: 0f b6 05 2d 9a 11 00 movzbl 0x119a2d,%eax
102c80: 83 e0 ef and $0xffffffef,%eax
102c83: a2 2d 9a 11 00 mov %al,0x119a2d
102c88: 0f b6 05 2d 9a 11 00 movzbl 0x119a2d,%eax
102c8f: 83 e0 9f and $0xffffff9f,%eax
102c92: a2 2d 9a 11 00 mov %al,0x119a2d
102c97: 0f b6 05 2d 9a 11 00 movzbl 0x119a2d,%eax
102c9e: 83 c8 80 or $0xffffff80,%eax
102ca1: a2 2d 9a 11 00 mov %al,0x119a2d
102ca6: 0f b6 05 2e 9a 11 00 movzbl 0x119a2e,%eax
102cad: 83 e0 f0 and $0xfffffff0,%eax
102cb0: a2 2e 9a 11 00 mov %al,0x119a2e
102cb5: 0f b6 05 2e 9a 11 00 movzbl 0x119a2e,%eax
102cbc: 83 e0 ef and $0xffffffef,%eax
102cbf: a2 2e 9a 11 00 mov %al,0x119a2e
102cc4: 0f b6 05 2e 9a 11 00 movzbl 0x119a2e,%eax
102ccb: 83 e0 df and $0xffffffdf,%eax
102cce: a2 2e 9a 11 00 mov %al,0x119a2e
102cd3: 0f b6 05 2e 9a 11 00 movzbl 0x119a2e,%eax
102cda: 83 c8 40 or $0x40,%eax
102cdd: a2 2e 9a 11 00 mov %al,0x119a2e
102ce2: 0f b6 05 2e 9a 11 00 movzbl 0x119a2e,%eax
102ce9: 83 e0 7f and $0x7f,%eax
102cec: a2 2e 9a 11 00 mov %al,0x119a2e
102cf1: b8 e0 a8 11 00 mov $0x11a8e0,%eax
102cf6: c1 e8 18 shr $0x18,%eax
102cf9: a2 2f 9a 11 00 mov %al,0x119a2f
// reload all segment registers
lgdt(&gdt_pd);
102cfe: 68 30 9a 11 00 push $0x119a30
102d03: e8 dd fe ff ff call 102be5 <lgdt>
102d08: 83 c4 04 add $0x4,%esp
102d0b: 66 c7 45 fe 28 00 movw $0x28,-0x2(%ebp)
asm volatile ("cli" ::: "memory");
}
static inline void
ltr(uint16_t sel) {
asm volatile ("ltr %0" :: "r" (sel) : "memory");
102d11: 0f b7 45 fe movzwl -0x2(%ebp),%eax
102d15: 0f 00 d8 ltr %ax
// load the TSS
ltr(GD_TSS);
}
102d18: 90 nop
102d19: c9 leave
102d1a: c3 ret
00102d1b <init_pmm_manager>:
//init_pmm_manager - initialize a pmm_manager instance
static void
init_pmm_manager(void) {
102d1b: 55 push %ebp
102d1c: 89 e5 mov %esp,%ebp
102d1e: 83 ec 08 sub $0x8,%esp
pmm_manager = &default_pmm_manager;
102d21: c7 05 5c a9 11 00 00 movl $0x107b00,0x11a95c
102d28: 7b 10 00
// pmm_manager = &buddy_pmm_manager;
cprintf("memory management: %s\n", pmm_manager->name);
102d2b: a1 5c a9 11 00 mov 0x11a95c,%eax
102d30: 8b 00 mov (%eax),%eax
102d32: 83 ec 08 sub $0x8,%esp
102d35: 50 push %eax
102d36: 68 d0 70 10 00 push $0x1070d0
102d3b: e8 27 d5 ff ff call 100267 <cprintf>
102d40: 83 c4 10 add $0x10,%esp
pmm_manager->init();
102d43: a1 5c a9 11 00 mov 0x11a95c,%eax
102d48: 8b 40 04 mov 0x4(%eax),%eax
102d4b: ff d0 call *%eax
}
102d4d: 90 nop
102d4e: c9 leave
102d4f: c3 ret
00102d50 <init_memmap>:
//init_memmap - call pmm->init_memmap to build Page struct for free memory
static void
init_memmap(struct Page *base, size_t n) {
102d50: 55 push %ebp
102d51: 89 e5 mov %esp,%ebp
102d53: 83 ec 08 sub $0x8,%esp
pmm_manager->init_memmap(base, n);
102d56: a1 5c a9 11 00 mov 0x11a95c,%eax
102d5b: 8b 40 08 mov 0x8(%eax),%eax
102d5e: 83 ec 08 sub $0x8,%esp
102d61: ff 75 0c pushl 0xc(%ebp)
102d64: ff 75 08 pushl 0x8(%ebp)
102d67: ff d0 call *%eax
102d69: 83 c4 10 add $0x10,%esp
}
102d6c: 90 nop
102d6d: c9 leave
102d6e: c3 ret
00102d6f <alloc_pages>:
//alloc_pages - call pmm->alloc_pages to allocate a continuous n*PAGESIZE memory
struct Page *
alloc_pages(size_t n) {
102d6f: 55 push %ebp
102d70: 89 e5 mov %esp,%ebp
102d72: 83 ec 18 sub $0x18,%esp
struct Page *page=NULL;
102d75: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp)
bool intr_flag;
local_intr_save(intr_flag);
102d7c: e8 26 fe ff ff call 102ba7 <__intr_save>
102d81: 89 45 f0 mov %eax,-0x10(%ebp)
{
page = pmm_manager->alloc_pages(n);
102d84: a1 5c a9 11 00 mov 0x11a95c,%eax
102d89: 8b 40 0c mov 0xc(%eax),%eax
102d8c: 83 ec 0c sub $0xc,%esp
102d8f: ff 75 08 pushl 0x8(%ebp)
102d92: ff d0 call *%eax
102d94: 83 c4 10 add $0x10,%esp
102d97: 89 45 f4 mov %eax,-0xc(%ebp)
}
local_intr_restore(intr_flag);
102d9a: 83 ec 0c sub $0xc,%esp
102d9d: ff 75 f0 pushl -0x10(%ebp)
102da0: e8 2c fe ff ff call 102bd1 <__intr_restore>
102da5: 83 c4 10 add $0x10,%esp
return page;
102da8: 8b 45 f4 mov -0xc(%ebp),%eax
}
102dab: c9 leave
102dac: c3 ret
00102dad <free_pages>:
//free_pages - call pmm->free_pages to free a continuous n*PAGESIZE memory
void
free_pages(struct Page *base, size_t n) {
102dad: 55 push %ebp
102dae: 89 e5 mov %esp,%ebp
102db0: 83 ec 18 sub $0x18,%esp
bool intr_flag;
local_intr_save(intr_flag);
102db3: e8 ef fd ff ff call 102ba7 <__intr_save>
102db8: 89 45 f4 mov %eax,-0xc(%ebp)
{
pmm_manager->free_pages(base, n);
102dbb: a1 5c a9 11 00 mov 0x11a95c,%eax
102dc0: 8b 40 10 mov 0x10(%eax),%eax
102dc3: 83 ec 08 sub $0x8,%esp
102dc6: ff 75 0c pushl 0xc(%ebp)
102dc9: ff 75 08 pushl 0x8(%ebp)
102dcc: ff d0 call *%eax
102dce: 83 c4 10 add $0x10,%esp
}
local_intr_restore(intr_flag);
102dd1: 83 ec 0c sub $0xc,%esp
102dd4: ff 75 f4 pushl -0xc(%ebp)
102dd7: e8 f5 fd ff ff call 102bd1 <__intr_restore>
102ddc: 83 c4 10 add $0x10,%esp
}
102ddf: 90 nop
102de0: c9 leave
102de1: c3 ret
00102de2 <nr_free_pages>:
//nr_free_pages - call pmm->nr_free_pages to get the size (nr*PAGESIZE)
//of current free memory
size_t
nr_free_pages(void) {
102de2: 55 push %ebp
102de3: 89 e5 mov %esp,%ebp
102de5: 83 ec 18 sub $0x18,%esp
size_t ret;
bool intr_flag;
local_intr_save(intr_flag);
102de8: e8 ba fd ff ff call 102ba7 <__intr_save>
102ded: 89 45 f4 mov %eax,-0xc(%ebp)
{
ret = pmm_manager->nr_free_pages();
102df0: a1 5c a9 11 00 mov 0x11a95c,%eax
102df5: 8b 40 14 mov 0x14(%eax),%eax
102df8: ff d0 call *%eax
102dfa: 89 45 f0 mov %eax,-0x10(%ebp)
}
local_intr_restore(intr_flag);
102dfd: 83 ec 0c sub $0xc,%esp
102e00: ff 75 f4 pushl -0xc(%ebp)
102e03: e8 c9 fd ff ff call 102bd1 <__intr_restore>
102e08: 83 c4 10 add $0x10,%esp
return ret;
102e0b: 8b 45 f0 mov -0x10(%ebp),%eax
}
102e0e: c9 leave
102e0f: c3 ret
00102e10 <page_init>:
/* pmm_init - initialize the physical memory management */
static void
page_init(void) {
102e10: 55 push %ebp
102e11: 89 e5 mov %esp,%ebp
102e13: 57 push %edi
102e14: 56 push %esi
102e15: 53 push %ebx
102e16: 83 ec 7c sub $0x7c,%esp
// e820map is at 0xC0008000 (PA) defined in bootloader.
struct e820map *memmap = (struct e820map *)(0x8000 + KERNBASE);
102e19: c7 45 c4 00 80 00 c0 movl $0xc0008000,-0x3c(%ebp)
uint64_t maxpa = 0;
102e20: c7 45 e0 00 00 00 00 movl $0x0,-0x20(%ebp)
102e27: c7 45 e4 00 00 00 00 movl $0x0,-0x1c(%ebp)
cprintf("e820map:\n");
102e2e: 83 ec 0c sub $0xc,%esp
102e31: 68 e7 70 10 00 push $0x1070e7
102e36: e8 2c d4 ff ff call 100267 <cprintf>
102e3b: 83 c4 10 add $0x10,%esp
int i;
for (i = 0; i < memmap->nr_map; i ++) {
102e3e: c7 45 dc 00 00 00 00 movl $0x0,-0x24(%ebp)
102e45: e9 fc 00 00 00 jmp 102f46 <page_init+0x136>
uint64_t begin = memmap->map[i].addr, end = begin + memmap->map[i].size;
102e4a: 8b 4d c4 mov -0x3c(%ebp),%ecx
102e4d: 8b 55 dc mov -0x24(%ebp),%edx
102e50: 89 d0 mov %edx,%eax
102e52: c1 e0 02 shl $0x2,%eax
102e55: 01 d0 add %edx,%eax
102e57: c1 e0 02 shl $0x2,%eax
102e5a: 01 c8 add %ecx,%eax
102e5c: 8b 50 08 mov 0x8(%eax),%edx
102e5f: 8b 40 04 mov 0x4(%eax),%eax
102e62: 89 45 b8 mov %eax,-0x48(%ebp)
102e65: 89 55 bc mov %edx,-0x44(%ebp)
102e68: 8b 4d c4 mov -0x3c(%ebp),%ecx
102e6b: 8b 55 dc mov -0x24(%ebp),%edx
102e6e: 89 d0 mov %edx,%eax
102e70: c1 e0 02 shl $0x2,%eax
102e73: 01 d0 add %edx,%eax
102e75: c1 e0 02 shl $0x2,%eax
102e78: 01 c8 add %ecx,%eax
102e7a: 8b 48 0c mov 0xc(%eax),%ecx
102e7d: 8b 58 10 mov 0x10(%eax),%ebx
102e80: 8b 45 b8 mov -0x48(%ebp),%eax
102e83: 8b 55 bc mov -0x44(%ebp),%edx
102e86: 01 c8 add %ecx,%eax
102e88: 11 da adc %ebx,%edx
102e8a: 89 45 b0 mov %eax,-0x50(%ebp)
102e8d: 89 55 b4 mov %edx,-0x4c(%ebp)
cprintf(" memory: %08llx, [%08llx, %08llx], type = %d.\n",
102e90: 8b 4d c4 mov -0x3c(%ebp),%ecx
102e93: 8b 55 dc mov -0x24(%ebp),%edx
102e96: 89 d0 mov %edx,%eax
102e98: c1 e0 02 shl $0x2,%eax
102e9b: 01 d0 add %edx,%eax
102e9d: c1 e0 02 shl $0x2,%eax
102ea0: 01 c8 add %ecx,%eax
102ea2: 83 c0 14 add $0x14,%eax
102ea5: 8b 00 mov (%eax),%eax
102ea7: 89 45 84 mov %eax,-0x7c(%ebp)
102eaa: 8b 45 b0 mov -0x50(%ebp),%eax
102ead: 8b 55 b4 mov -0x4c(%ebp),%edx
102eb0: 83 c0 ff add $0xffffffff,%eax
102eb3: 83 d2 ff adc $0xffffffff,%edx
102eb6: 89 c1 mov %eax,%ecx
102eb8: 89 d3 mov %edx,%ebx
102eba: 8b 55 c4 mov -0x3c(%ebp),%edx
102ebd: 89 55 80 mov %edx,-0x80(%ebp)
102ec0: 8b 55 dc mov -0x24(%ebp),%edx
102ec3: 89 d0 mov %edx,%eax
102ec5: c1 e0 02 shl $0x2,%eax
102ec8: 01 d0 add %edx,%eax
102eca: c1 e0 02 shl $0x2,%eax
102ecd: 03 45 80 add -0x80(%ebp),%eax
102ed0: 8b 50 10 mov 0x10(%eax),%edx
102ed3: 8b 40 0c mov 0xc(%eax),%eax
102ed6: ff 75 84 pushl -0x7c(%ebp)
102ed9: 53 push %ebx
102eda: 51 push %ecx
102edb: ff 75 bc pushl -0x44(%ebp)
102ede: ff 75 b8 pushl -0x48(%ebp)
102ee1: 52 push %edx
102ee2: 50 push %eax
102ee3: 68 f4 70 10 00 push $0x1070f4
102ee8: e8 7a d3 ff ff call 100267 <cprintf>
102eed: 83 c4 20 add $0x20,%esp
memmap->map[i].size, begin, end - 1, memmap->map[i].type);
if (memmap->map[i].type == E820_ARM) {
102ef0: 8b 4d c4 mov -0x3c(%ebp),%ecx
102ef3: 8b 55 dc mov -0x24(%ebp),%edx
102ef6: 89 d0 mov %edx,%eax
102ef8: c1 e0 02 shl $0x2,%eax
102efb: 01 d0 add %edx,%eax
102efd: c1 e0 02 shl $0x2,%eax
102f00: 01 c8 add %ecx,%eax
102f02: 83 c0 14 add $0x14,%eax
102f05: 8b 00 mov (%eax),%eax
102f07: 83 f8 01 cmp $0x1,%eax
102f0a: 75 36 jne 102f42 <page_init+0x132>
// KMEMSIZE restricts the maximum detected physical address.
// Thus the block with starting address >= KMEMSIZE will not be recognized.
if (maxpa < end && begin < KMEMSIZE) {
102f0c: 8b 45 e0 mov -0x20(%ebp),%eax
102f0f: 8b 55 e4 mov -0x1c(%ebp),%edx
102f12: 3b 55 b4 cmp -0x4c(%ebp),%edx
102f15: 77 2b ja 102f42 <page_init+0x132>
102f17: 3b 55 b4 cmp -0x4c(%ebp),%edx
102f1a: 72 05 jb 102f21 <page_init+0x111>
102f1c: 3b 45 b0 cmp -0x50(%ebp),%eax
102f1f: 73 21 jae 102f42 <page_init+0x132>
102f21: 83 7d bc 00 cmpl $0x0,-0x44(%ebp)
102f25: 77 1b ja 102f42 <page_init+0x132>
102f27: 83 7d bc 00 cmpl $0x0,-0x44(%ebp)
102f2b: 72 09 jb 102f36 <page_init+0x126>
102f2d: 81 7d b8 ff ff ff 37 cmpl $0x37ffffff,-0x48(%ebp)
102f34: 77 0c ja 102f42 <page_init+0x132>
maxpa = end;
102f36: 8b 45 b0 mov -0x50(%ebp),%eax
102f39: 8b 55 b4 mov -0x4c(%ebp),%edx
102f3c: 89 45 e0 mov %eax,-0x20(%ebp)
102f3f: 89 55 e4 mov %edx,-0x1c(%ebp)
struct e820map *memmap = (struct e820map *)(0x8000 + KERNBASE);
uint64_t maxpa = 0;
cprintf("e820map:\n");
int i;
for (i = 0; i < memmap->nr_map; i ++) {
102f42: 83 45 dc 01 addl $0x1,-0x24(%ebp)
102f46: 8b 45 c4 mov -0x3c(%ebp),%eax
102f49: 8b 00 mov (%eax),%eax
102f4b: 3b 45 dc cmp -0x24(%ebp),%eax
102f4e: 0f 8f f6 fe ff ff jg 102e4a <page_init+0x3a>
if (maxpa < end && begin < KMEMSIZE) {
maxpa = end;
}
}
}
if (maxpa > KMEMSIZE) {
102f54: 83 7d e4 00 cmpl $0x0,-0x1c(%ebp)
102f58: 72 1d jb 102f77 <page_init+0x167>
102f5a: 83 7d e4 00 cmpl $0x0,-0x1c(%ebp)
102f5e: 77 09 ja 102f69 <page_init+0x159>
102f60: 81 7d e0 00 00 00 38 cmpl $0x38000000,-0x20(%ebp)
102f67: 76 0e jbe 102f77 <page_init+0x167>
maxpa = KMEMSIZE;
102f69: c7 45 e0 00 00 00 38 movl $0x38000000,-0x20(%ebp)
102f70: c7 45 e4 00 00 00 00 movl $0x0,-0x1c(%ebp)
}
// Provided in kernel.ld - End of kernel bss.
extern char end[];
cprintf("Detected maxpa = %08llx\n", maxpa);
102f77: 83 ec 04 sub $0x4,%esp
102f7a: ff 75 e4 pushl -0x1c(%ebp)
102f7d: ff 75 e0 pushl -0x20(%ebp)
102f80: 68 24 71 10 00 push $0x107124
102f85: e8 dd d2 ff ff call 100267 <cprintf>
102f8a: 83 c4 10 add $0x10,%esp
// Here, npage is only used for an estimation of how many entries in the page table.
npage = maxpa / PGSIZE;
102f8d: 8b 45 e0 mov -0x20(%ebp),%eax
102f90: 8b 55 e4 mov -0x1c(%ebp),%edx
102f93: 0f ac d0 0c shrd $0xc,%edx,%eax
102f97: c1 ea 0c shr $0xc,%edx
102f9a: a3 c0 a8 11 00 mov %eax,0x11a8c0
// virtual address of physical pages descriptor array.
// The array starts at the end of the kernel code.
pages = (struct Page *)ROUNDUP((void *)end, PGSIZE);
102f9f: c7 45 ac 00 10 00 00 movl $0x1000,-0x54(%ebp)
102fa6: b8 74 a9 11 00 mov $0x11a974,%eax
102fab: 8d 50 ff lea -0x1(%eax),%edx
102fae: 8b 45 ac mov -0x54(%ebp),%eax
102fb1: 01 d0 add %edx,%eax
102fb3: 89 45 a8 mov %eax,-0x58(%ebp)
102fb6: 8b 45 a8 mov -0x58(%ebp),%eax
102fb9: ba 00 00 00 00 mov $0x0,%edx
102fbe: f7 75 ac divl -0x54(%ebp)
102fc1: 8b 45 a8 mov -0x58(%ebp),%eax
102fc4: 29 d0 sub %edx,%eax
102fc6: a3 64 a9 11 00 mov %eax,0x11a964
for (i = 0; i < npage; i ++) {
102fcb: c7 45 dc 00 00 00 00 movl $0x0,-0x24(%ebp)
102fd2: eb 2f jmp 103003 <page_init+0x1f3>
SetPageReserved(pages + i);
102fd4: 8b 0d 64 a9 11 00 mov 0x11a964,%ecx
102fda: 8b 55 dc mov -0x24(%ebp),%edx
102fdd: 89 d0 mov %edx,%eax
102fdf: c1 e0 02 shl $0x2,%eax
102fe2: 01 d0 add %edx,%eax
102fe4: c1 e0 02 shl $0x2,%eax
102fe7: 01 c8 add %ecx,%eax
102fe9: 83 c0 04 add $0x4,%eax
102fec: c7 45 90 00 00 00 00 movl $0x0,-0x70(%ebp)
102ff3: 89 45 8c mov %eax,-0x74(%ebp)
* Note that @nr may be almost arbitrarily large; this function is not
* restricted to acting on a single-word quantity.
* */
static inline void
set_bit(int nr, volatile void *addr) {
asm volatile ("btsl %1, %0" :"=m" (*(volatile long *)addr) : "Ir" (nr));
102ff6: 8b 45 8c mov -0x74(%ebp),%eax
102ff9: 8b 55 90 mov -0x70(%ebp),%edx
102ffc: 0f ab 10 bts %edx,(%eax)
npage = maxpa / PGSIZE;
// virtual address of physical pages descriptor array.
// The array starts at the end of the kernel code.
pages = (struct Page *)ROUNDUP((void *)end, PGSIZE);
for (i = 0; i < npage; i ++) {
102fff: 83 45 dc 01 addl $0x1,-0x24(%ebp)
103003: 8b 55 dc mov -0x24(%ebp),%edx
103006: a1 c0 a8 11 00 mov 0x11a8c0,%eax
10300b: 39 c2 cmp %eax,%edx
10300d: 72 c5 jb 102fd4 <page_init+0x1c4>
SetPageReserved(pages + i);
}
uintptr_t freemem = PADDR((uintptr_t)pages + sizeof(struct Page) * npage);
10300f: 8b 15 c0 a8 11 00 mov 0x11a8c0,%edx
103015: 89 d0 mov %edx,%eax
103017: c1 e0 02 shl $0x2,%eax
10301a: 01 d0 add %edx,%eax
10301c: c1 e0 02 shl $0x2,%eax
10301f: 89 c2 mov %eax,%edx
103021: a1 64 a9 11 00 mov 0x11a964,%eax
103026: 01 d0 add %edx,%eax
103028: 89 45 a4 mov %eax,-0x5c(%ebp)
10302b: 81 7d a4 ff ff ff bf cmpl $0xbfffffff,-0x5c(%ebp)
103032: 77 17 ja 10304b <page_init+0x23b>
103034: ff 75 a4 pushl -0x5c(%ebp)
103037: 68 40 71 10 00 push $0x107140
10303c: 68 e4 00 00 00 push $0xe4
103041: 68 64 71 10 00 push $0x107164
103046: e8 82 d3 ff ff call 1003cd <__panic>
10304b: 8b 45 a4 mov -0x5c(%ebp),%eax
10304e: 05 00 00 00 40 add $0x40000000,%eax
103053: 89 45 a0 mov %eax,-0x60(%ebp)
cprintf("Kernel ends at (va): %08x, Total pages = %d, which takes up %d.\n",
103056: 8b 15 c0 a8 11 00 mov 0x11a8c0,%edx
10305c: 89 d0 mov %edx,%eax
10305e: c1 e0 02 shl $0x2,%eax
103061: 01 d0 add %edx,%eax
103063: c1 e0 02 shl $0x2,%eax
103066: 89 c1 mov %eax,%ecx
103068: a1 c0 a8 11 00 mov 0x11a8c0,%eax
10306d: ba 74 a9 11 00 mov $0x11a974,%edx
103072: 51 push %ecx
103073: 50 push %eax
103074: 52 push %edx
103075: 68 74 71 10 00 push $0x107174
10307a: e8 e8 d1 ff ff call 100267 <cprintf>
10307f: 83 c4 10 add $0x10,%esp
(uintptr_t)end, npage, sizeof(struct Page) * npage);
cprintf("Freemem = (pa) %08x\n", freemem);
103082: 83 ec 08 sub $0x8,%esp
103085: ff 75 a0 pushl -0x60(%ebp)
103088: 68 b5 71 10 00 push $0x1071b5
10308d: e8 d5 d1 ff ff call 100267 <cprintf>
103092: 83 c4 10 add $0x10,%esp
for (i = 0; i < memmap->nr_map; i ++) {
103095: c7 45 dc 00 00 00 00 movl $0x0,-0x24(%ebp)
10309c: e9 85 01 00 00 jmp 103226 <page_init+0x416>
uint64_t begin = memmap->map[i].addr, end = begin + memmap->map[i].size;
1030a1: 8b 4d c4 mov -0x3c(%ebp),%ecx
1030a4: 8b 55 dc mov -0x24(%ebp),%edx
1030a7: 89 d0 mov %edx,%eax
1030a9: c1 e0 02 shl $0x2,%eax
1030ac: 01 d0 add %edx,%eax
1030ae: c1 e0 02 shl $0x2,%eax
1030b1: 01 c8 add %ecx,%eax
1030b3: 8b 50 08 mov 0x8(%eax),%edx
1030b6: 8b 40 04 mov 0x4(%eax),%eax
1030b9: 89 45 d0 mov %eax,-0x30(%ebp)
1030bc: 89 55 d4 mov %edx,-0x2c(%ebp)
1030bf: 8b 4d c4 mov -0x3c(%ebp),%ecx
1030c2: 8b 55 dc mov -0x24(%ebp),%edx
1030c5: 89 d0 mov %edx,%eax
1030c7: c1 e0 02 shl $0x2,%eax
1030ca: 01 d0 add %edx,%eax
1030cc: c1 e0 02 shl $0x2,%eax
1030cf: 01 c8 add %ecx,%eax
1030d1: 8b 48 0c mov 0xc(%eax),%ecx
1030d4: 8b 58 10 mov 0x10(%eax),%ebx
1030d7: 8b 45 d0 mov -0x30(%ebp),%eax
1030da: 8b 55 d4 mov -0x2c(%ebp),%edx
1030dd: 01 c8 add %ecx,%eax
1030df: 11 da adc %ebx,%edx
1030e1: 89 45 c8 mov %eax,-0x38(%ebp)
1030e4: 89 55 cc mov %edx,-0x34(%ebp)
if (memmap->map[i].type == E820_ARM) {
1030e7: 8b 4d c4 mov -0x3c(%ebp),%ecx
1030ea: 8b 55 dc mov -0x24(%ebp),%edx
1030ed: 89 d0 mov %edx,%eax
1030ef: c1 e0 02 shl $0x2,%eax
1030f2: 01 d0 add %edx,%eax
1030f4: c1 e0 02 shl $0x2,%eax
1030f7: 01 c8 add %ecx,%eax
1030f9: 83 c0 14 add $0x14,%eax
1030fc: 8b 00 mov (%eax),%eax
1030fe: 83 f8 01 cmp $0x1,%eax
103101: 0f 85 1b 01 00 00 jne 103222 <page_init+0x412>
if (begin < freemem) {
103107: 8b 45 a0 mov -0x60(%ebp),%eax
10310a: ba 00 00 00 00 mov $0x0,%edx
10310f: 3b 55 d4 cmp -0x2c(%ebp),%edx
103112: 72 17 jb 10312b <page_init+0x31b>
103114: 3b 55 d4 cmp -0x2c(%ebp),%edx
103117: 77 05 ja 10311e <page_init+0x30e>
103119: 3b 45 d0 cmp -0x30(%ebp),%eax
10311c: 76 0d jbe 10312b <page_init+0x31b>
begin = freemem;
10311e: 8b 45 a0 mov -0x60(%ebp),%eax
103121: 89 45 d0 mov %eax,-0x30(%ebp)
103124: c7 45 d4 00 00 00 00 movl $0x0,-0x2c(%ebp)
}
if (end > KMEMSIZE) {
10312b: 83 7d cc 00 cmpl $0x0,-0x34(%ebp)
10312f: 72 1d jb 10314e <page_init+0x33e>
103131: 83 7d cc 00 cmpl $0x0,-0x34(%ebp)
103135: 77 09 ja 103140 <page_init+0x330>
103137: 81 7d c8 00 00 00 38 cmpl $0x38000000,-0x38(%ebp)
10313e: 76 0e jbe 10314e <page_init+0x33e>
end = KMEMSIZE;
103140: c7 45 c8 00 00 00 38 movl $0x38000000,-0x38(%ebp)
103147: c7 45 cc 00 00 00 00 movl $0x0,-0x34(%ebp)
}
// Gather all available blocks and build pages linked list.
if (begin < end) {
10314e: 8b 45 d0 mov -0x30(%ebp),%eax
103151: 8b 55 d4 mov -0x2c(%ebp),%edx
103154: 3b 55 cc cmp -0x34(%ebp),%edx
103157: 0f 87 c5 00 00 00 ja 103222 <page_init+0x412>
10315d: 3b 55 cc cmp -0x34(%ebp),%edx
103160: 72 09 jb 10316b <page_init+0x35b>
103162: 3b 45 c8 cmp -0x38(%ebp),%eax
103165: 0f 83 b7 00 00 00 jae 103222 <page_init+0x412>
begin = ROUNDUP(begin, PGSIZE);
10316b: c7 45 9c 00 10 00 00 movl $0x1000,-0x64(%ebp)
103172: 8b 55 d0 mov -0x30(%ebp),%edx
103175: 8b 45 9c mov -0x64(%ebp),%eax
103178: 01 d0 add %edx,%eax
10317a: 83 e8 01 sub $0x1,%eax
10317d: 89 45 98 mov %eax,-0x68(%ebp)
103180: 8b 45 98 mov -0x68(%ebp),%eax
103183: ba 00 00 00 00 mov $0x0,%edx
103188: f7 75 9c divl -0x64(%ebp)
10318b: 8b 45 98 mov -0x68(%ebp),%eax
10318e: 29 d0 sub %edx,%eax
103190: ba 00 00 00 00 mov $0x0,%edx
103195: 89 45 d0 mov %eax,-0x30(%ebp)
103198: 89 55 d4 mov %edx,-0x2c(%ebp)
end = ROUNDDOWN(end, PGSIZE);
10319b: 8b 45 c8 mov -0x38(%ebp),%eax
10319e: 89 45 94 mov %eax,-0x6c(%ebp)
1031a1: 8b 45 94 mov -0x6c(%ebp),%eax
1031a4: ba 00 00 00 00 mov $0x0,%edx
1031a9: 89 c3 mov %eax,%ebx
1031ab: 81 e3 00 f0 ff ff and $0xfffff000,%ebx
1031b1: 89 de mov %ebx,%esi
1031b3: 89 d0 mov %edx,%eax
1031b5: 83 e0 00 and $0x0,%eax
1031b8: 89 c7 mov %eax,%edi
1031ba: 89 75 c8 mov %esi,-0x38(%ebp)
1031bd: 89 7d cc mov %edi,-0x34(%ebp)
if (begin < end) {
1031c0: 8b 45 d0 mov -0x30(%ebp),%eax
1031c3: 8b 55 d4 mov -0x2c(%ebp),%edx
1031c6: 3b 55 cc cmp -0x34(%ebp),%edx
1031c9: 77 57 ja 103222 <page_init+0x412>
1031cb: 3b 55 cc cmp -0x34(%ebp),%edx
1031ce: 72 05 jb 1031d5 <page_init+0x3c5>
1031d0: 3b 45 c8 cmp -0x38(%ebp),%eax
1031d3: 73 4d jae 103222 <page_init+0x412>
cprintf("Detected one allocatable block (pa) start = %08llx, end = %08llx\n", begin, end);
1031d5: 83 ec 0c sub $0xc,%esp
1031d8: ff 75 cc pushl -0x34(%ebp)
1031db: ff 75 c8 pushl -0x38(%ebp)
1031de: ff 75 d4 pushl -0x2c(%ebp)
1031e1: ff 75 d0 pushl -0x30(%ebp)
1031e4: 68 cc 71 10 00 push $0x1071cc
1031e9: e8 79 d0 ff ff call 100267 <cprintf>
1031ee: 83 c4 20 add $0x20,%esp
// pa2page converts physical address into its page descriptor's virtual address.
init_memmap(pa2page(begin), (end - begin) / PGSIZE);
1031f1: 8b 45 c8 mov -0x38(%ebp),%eax
1031f4: 8b 55 cc mov -0x34(%ebp),%edx
1031f7: 2b 45 d0 sub -0x30(%ebp),%eax
1031fa: 1b 55 d4 sbb -0x2c(%ebp),%edx
1031fd: 0f ac d0 0c shrd $0xc,%edx,%eax
103201: c1 ea 0c shr $0xc,%edx
103204: 89 c3 mov %eax,%ebx
103206: 8b 45 d0 mov -0x30(%ebp),%eax
103209: 83 ec 0c sub $0xc,%esp
10320c: 50 push %eax
10320d: e8 6d f8 ff ff call 102a7f <pa2page>
103212: 83 c4 10 add $0x10,%esp
103215: 83 ec 08 sub $0x8,%esp
103218: 53 push %ebx
103219: 50 push %eax
10321a: e8 31 fb ff ff call 102d50 <init_memmap>
10321f: 83 c4 10 add $0x10,%esp
cprintf("Kernel ends at (va): %08x, Total pages = %d, which takes up %d.\n",
(uintptr_t)end, npage, sizeof(struct Page) * npage);
cprintf("Freemem = (pa) %08x\n", freemem);
for (i = 0; i < memmap->nr_map; i ++) {
103222: 83 45 dc 01 addl $0x1,-0x24(%ebp)
103226: 8b 45 c4 mov -0x3c(%ebp),%eax
103229: 8b 00 mov (%eax),%eax
10322b: 3b 45 dc cmp -0x24(%ebp),%eax
10322e: 0f 8f 6d fe ff ff jg 1030a1 <page_init+0x291>
init_memmap(pa2page(begin), (end - begin) / PGSIZE);
}
}
}
}
}
103234: 90 nop
103235: 8d 65 f4 lea -0xc(%ebp),%esp
103238: 5b pop %ebx
103239: 5e pop %esi
10323a: 5f pop %edi
10323b: 5d pop %ebp
10323c: c3 ret
0010323d <enable_paging>:
static void
enable_paging(void) {
10323d: 55 push %ebp
10323e: 89 e5 mov %esp,%ebp
103240: 83 ec 10 sub $0x10,%esp
lcr3(boot_cr3);
103243: a1 60 a9 11 00 mov 0x11a960,%eax
103248: 89 45 fc mov %eax,-0x4(%ebp)
asm volatile ("mov %0, %%cr0" :: "r" (cr0) : "memory");
}
static inline void
lcr3(uintptr_t cr3) {
asm volatile ("mov %0, %%cr3" :: "r" (cr3) : "memory");
10324b: 8b 45 fc mov -0x4(%ebp),%eax
10324e: 0f 22 d8 mov %eax,%cr3
}
static inline uintptr_t
rcr0(void) {
uintptr_t cr0;
asm volatile ("mov %%cr0, %0" : "=r" (cr0) :: "memory");
103251: 0f 20 c0 mov %cr0,%eax
103254: 89 45 f4 mov %eax,-0xc(%ebp)
return cr0;
103257: 8b 45 f4 mov -0xc(%ebp),%eax
// turn on paging
uint32_t cr0 = rcr0();
10325a: 89 45 f8 mov %eax,-0x8(%ebp)
cr0 |= CR0_PE | CR0_PG | CR0_AM | CR0_WP | CR0_NE | CR0_TS | CR0_EM | CR0_MP;
10325d: 81 4d f8 2f 00 05 80 orl $0x8005002f,-0x8(%ebp)
cr0 &= ~(CR0_TS | CR0_EM);
103264: 83 65 f8 f3 andl $0xfffffff3,-0x8(%ebp)
103268: 8b 45 f8 mov -0x8(%ebp),%eax
10326b: 89 45 f0 mov %eax,-0x10(%ebp)
asm volatile ("pushl %0; popfl" :: "r" (eflags));
}
static inline void
lcr0(uintptr_t cr0) {
asm volatile ("mov %0, %%cr0" :: "r" (cr0) : "memory");
10326e: 8b 45 f0 mov -0x10(%ebp),%eax
103271: 0f 22 c0 mov %eax,%cr0
lcr0(cr0);
}
103274: 90 nop
103275: c9 leave
103276: c3 ret
00103277 <boot_map_segment>:
// la: linear address of this memory need to map (after x86 segment map)
// size: memory size
// pa: physical address of this memory
// perm: permission of this memory
static void
boot_map_segment(pde_t *pgdir, uintptr_t la, size_t size, uintptr_t pa, uint32_t perm) {
103277: 55 push %ebp
103278: 89 e5 mov %esp,%ebp
10327a: 83 ec 28 sub $0x28,%esp
assert(PGOFF(la) == PGOFF(pa));
10327d: 8b 45 0c mov 0xc(%ebp),%eax
103280: 33 45 14 xor 0x14(%ebp),%eax
103283: 25 ff 0f 00 00 and $0xfff,%eax
103288: 85 c0 test %eax,%eax
10328a: 74 19 je 1032a5 <boot_map_segment+0x2e>
10328c: 68 0e 72 10 00 push $0x10720e
103291: 68 25 72 10 00 push $0x107225
103296: 68 14 01 00 00 push $0x114
10329b: 68 64 71 10 00 push $0x107164
1032a0: e8 28 d1 ff ff call 1003cd <__panic>
size_t n = ROUNDUP(size + PGOFF(la), PGSIZE) / PGSIZE;
1032a5: c7 45 f0 00 10 00 00 movl $0x1000,-0x10(%ebp)
1032ac: 8b 45 0c mov 0xc(%ebp),%eax
1032af: 25 ff 0f 00 00 and $0xfff,%eax
1032b4: 89 c2 mov %eax,%edx
1032b6: 8b 45 10 mov 0x10(%ebp),%eax
1032b9: 01 c2 add %eax,%edx
1032bb: 8b 45 f0 mov -0x10(%ebp),%eax
1032be: 01 d0 add %edx,%eax
1032c0: 83 e8 01 sub $0x1,%eax
1032c3: 89 45 ec mov %eax,-0x14(%ebp)
1032c6: 8b 45 ec mov -0x14(%ebp),%eax
1032c9: ba 00 00 00 00 mov $0x0,%edx
1032ce: f7 75 f0 divl -0x10(%ebp)
1032d1: 8b 45 ec mov -0x14(%ebp),%eax
1032d4: 29 d0 sub %edx,%eax
1032d6: c1 e8 0c shr $0xc,%eax
1032d9: 89 45 f4 mov %eax,-0xc(%ebp)
la = ROUNDDOWN(la, PGSIZE);
1032dc: 8b 45 0c mov 0xc(%ebp),%eax
1032df: 89 45 e8 mov %eax,-0x18(%ebp)
1032e2: 8b 45 e8 mov -0x18(%ebp),%eax
1032e5: 25 00 f0 ff ff and $0xfffff000,%eax
1032ea: 89 45 0c mov %eax,0xc(%ebp)
pa = ROUNDDOWN(pa, PGSIZE);
1032ed: 8b 45 14 mov 0x14(%ebp),%eax
1032f0: 89 45 e4 mov %eax,-0x1c(%ebp)
1032f3: 8b 45 e4 mov -0x1c(%ebp),%eax
1032f6: 25 00 f0 ff ff and $0xfffff000,%eax
1032fb: 89 45 14 mov %eax,0x14(%ebp)
for (; n > 0; n --, la += PGSIZE, pa += PGSIZE) {
1032fe: eb 57 jmp 103357 <boot_map_segment+0xe0>
pte_t *ptep = get_pte(pgdir, la, 1);
103300: 83 ec 04 sub $0x4,%esp
103303: 6a 01 push $0x1
103305: ff 75 0c pushl 0xc(%ebp)
103308: ff 75 08 pushl 0x8(%ebp)
10330b: e8 98 01 00 00 call 1034a8 <get_pte>
103310: 83 c4 10 add $0x10,%esp
103313: 89 45 e0 mov %eax,-0x20(%ebp)
assert(ptep != NULL);
103316: 83 7d e0 00 cmpl $0x0,-0x20(%ebp)
10331a: 75 19 jne 103335 <boot_map_segment+0xbe>
10331c: 68 3a 72 10 00 push $0x10723a
103321: 68 25 72 10 00 push $0x107225
103326: 68 1a 01 00 00 push $0x11a
10332b: 68 64 71 10 00 push $0x107164
103330: e8 98 d0 ff ff call 1003cd <__panic>
*ptep = pa | PTE_P | perm;
103335: 8b 45 14 mov 0x14(%ebp),%eax
103338: 0b 45 18 or 0x18(%ebp),%eax
10333b: 83 c8 01 or $0x1,%eax
10333e: 89 c2 mov %eax,%edx
103340: 8b 45 e0 mov -0x20(%ebp),%eax
103343: 89 10 mov %edx,(%eax)
boot_map_segment(pde_t *pgdir, uintptr_t la, size_t size, uintptr_t pa, uint32_t perm) {
assert(PGOFF(la) == PGOFF(pa));
size_t n = ROUNDUP(size + PGOFF(la), PGSIZE) / PGSIZE;
la = ROUNDDOWN(la, PGSIZE);
pa = ROUNDDOWN(pa, PGSIZE);
for (; n > 0; n --, la += PGSIZE, pa += PGSIZE) {
103345: 83 6d f4 01 subl $0x1,-0xc(%ebp)
103349: 81 45 0c 00 10 00 00 addl $0x1000,0xc(%ebp)
103350: 81 45 14 00 10 00 00 addl $0x1000,0x14(%ebp)
103357: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
10335b: 75 a3 jne 103300 <boot_map_segment+0x89>
pte_t *ptep = get_pte(pgdir, la, 1);
assert(ptep != NULL);
*ptep = pa | PTE_P | perm;
}
}
10335d: 90 nop
10335e: c9 leave
10335f: c3 ret
00103360 <boot_alloc_page>:
//boot_alloc_page - allocate one page using pmm->alloc_pages(1)
// return value: the kernel virtual address of this allocated page
//note: this function is used to get the memory for PDT(Page Directory Table)&PT(Page Table)
static void *
boot_alloc_page(void) {
103360: 55 push %ebp
103361: 89 e5 mov %esp,%ebp
103363: 83 ec 18 sub $0x18,%esp
struct Page *p = alloc_page();
103366: 83 ec 0c sub $0xc,%esp
103369: 6a 01 push $0x1
10336b: e8 ff f9 ff ff call 102d6f <alloc_pages>
103370: 83 c4 10 add $0x10,%esp
103373: 89 45 f4 mov %eax,-0xc(%ebp)
if (p == NULL) {
103376: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
10337a: 75 17 jne 103393 <boot_alloc_page+0x33>
panic("boot_alloc_page failed.\n");
10337c: 83 ec 04 sub $0x4,%esp
10337f: 68 47 72 10 00 push $0x107247
103384: 68 26 01 00 00 push $0x126
103389: 68 64 71 10 00 push $0x107164
10338e: e8 3a d0 ff ff call 1003cd <__panic>
}
return page2kva(p);
103393: 83 ec 0c sub $0xc,%esp
103396: ff 75 f4 pushl -0xc(%ebp)
103399: e8 28 f7 ff ff call 102ac6 <page2kva>
10339e: 83 c4 10 add $0x10,%esp
}
1033a1: c9 leave
1033a2: c3 ret
001033a3 <pmm_init>:
//pmm_init - setup a pmm to manage physical memory, build PDT&PT to setup paging mechanism
// - check the correctness of pmm & paging mechanism, print PDT&PT
void
pmm_init(void) {
1033a3: 55 push %ebp
1033a4: 89 e5 mov %esp,%ebp
1033a6: 83 ec 18 sub $0x18,%esp
//We need to alloc/free the physical memory (granularity is 4KB or other size).
//So a framework of physical memory manager (struct pmm_manager)is defined in pmm.h
//First we should init a physical memory manager(pmm) based on the framework.
//Then pmm can alloc/free the physical memory.
//Now the first_fit/best_fit/worst_fit/buddy_system pmm are available.
init_pmm_manager();
1033a9: e8 6d f9 ff ff call 102d1b <init_pmm_manager>
// detect physical memory space, reserve already used memory,
// then use pmm->init_memmap to create free page list
page_init();
1033ae: e8 5d fa ff ff call 102e10 <page_init>
//use pmm->check to verify the correctness of the alloc/free function in a pmm
check_alloc_page();
1033b3: e8 2d 04 00 00 call 1037e5 <check_alloc_page>
// create boot_pgdir, an initial page directory(Page Directory Table, PDT)
boot_pgdir = boot_alloc_page();
1033b8: e8 a3 ff ff ff call 103360 <boot_alloc_page>
1033bd: a3 c4 a8 11 00 mov %eax,0x11a8c4
memset(boot_pgdir, 0, PGSIZE);
1033c2: a1 c4 a8 11 00 mov 0x11a8c4,%eax
1033c7: 83 ec 04 sub $0x4,%esp
1033ca: 68 00 10 00 00 push $0x1000
1033cf: 6a 00 push $0x0
1033d1: 50 push %eax
1033d2: e8 90 2d 00 00 call 106167 <memset>
1033d7: 83 c4 10 add $0x10,%esp
boot_cr3 = PADDR(boot_pgdir);
1033da: a1 c4 a8 11 00 mov 0x11a8c4,%eax
1033df: 89 45 f4 mov %eax,-0xc(%ebp)
1033e2: 81 7d f4 ff ff ff bf cmpl $0xbfffffff,-0xc(%ebp)
1033e9: 77 17 ja 103402 <pmm_init+0x5f>
1033eb: ff 75 f4 pushl -0xc(%ebp)
1033ee: 68 40 71 10 00 push $0x107140
1033f3: 68 40 01 00 00 push $0x140
1033f8: 68 64 71 10 00 push $0x107164
1033fd: e8 cb cf ff ff call 1003cd <__panic>
103402: 8b 45 f4 mov -0xc(%ebp),%eax
103405: 05 00 00 00 40 add $0x40000000,%eax
10340a: a3 60 a9 11 00 mov %eax,0x11a960
check_pgdir();
10340f: e8 f4 03 00 00 call 103808 <check_pgdir>
static_assert(KERNBASE % PTSIZE == 0 && KERNTOP % PTSIZE == 0);
// recursively insert boot_pgdir in itself
// to form a virtual page table at virtual address VPT
boot_pgdir[PDX(VPT)] = PADDR(boot_pgdir) | PTE_P | PTE_W;
103414: a1 c4 a8 11 00 mov 0x11a8c4,%eax
103419: 8d 90 ac 0f 00 00 lea 0xfac(%eax),%edx
10341f: a1 c4 a8 11 00 mov 0x11a8c4,%eax
103424: 89 45 f0 mov %eax,-0x10(%ebp)
103427: 81 7d f0 ff ff ff bf cmpl $0xbfffffff,-0x10(%ebp)
10342e: 77 17 ja 103447 <pmm_init+0xa4>
103430: ff 75 f0 pushl -0x10(%ebp)
103433: 68 40 71 10 00 push $0x107140
103438: 68 48 01 00 00 push $0x148
10343d: 68 64 71 10 00 push $0x107164
103442: e8 86 cf ff ff call 1003cd <__panic>
103447: 8b 45 f0 mov -0x10(%ebp),%eax
10344a: 05 00 00 00 40 add $0x40000000,%eax
10344f: 83 c8 03 or $0x3,%eax
103452: 89 02 mov %eax,(%edx)
// map all physical memory to linear memory with base linear addr KERNBASE
//linear_addr KERNBASE~KERNBASE+KMEMSIZE = phy_addr 0~KMEMSIZE
//But shouldn't use this map until enable_paging() & gdt_init() finished.
boot_map_segment(boot_pgdir, KERNBASE, KMEMSIZE, 0, PTE_W);
103454: a1 c4 a8 11 00 mov 0x11a8c4,%eax
103459: 83 ec 0c sub $0xc,%esp
10345c: 6a 02 push $0x2
10345e: 6a 00 push $0x0
103460: 68 00 00 00 38 push $0x38000000
103465: 68 00 00 00 c0 push $0xc0000000
10346a: 50 push %eax
10346b: e8 07 fe ff ff call 103277 <boot_map_segment>
103470: 83 c4 20 add $0x20,%esp
//temporary map:
//virtual_addr 3G~3G+4M = linear_addr 0~4M = linear_addr 3G~3G+4M = phy_addr 0~4M
boot_pgdir[0] = boot_pgdir[PDX(KERNBASE)];
103473: a1 c4 a8 11 00 mov 0x11a8c4,%eax
103478: 8b 15 c4 a8 11 00 mov 0x11a8c4,%edx
10347e: 8b 92 00 0c 00 00 mov 0xc00(%edx),%edx
103484: 89 10 mov %edx,(%eax)
enable_paging();
103486: e8 b2 fd ff ff call 10323d <enable_paging>
//reload gdt(third time,the last time) to map all physical memory
//virtual_addr 0~4G=liear_addr 0~4G
//then set kernel stack(ss:esp) in TSS, setup TSS in gdt, load TSS
gdt_init();
10348b: e8 99 f7 ff ff call 102c29 <gdt_init>
//disable the map of virtual_addr 0~4M
boot_pgdir[0] = 0;
103490: a1 c4 a8 11 00 mov 0x11a8c4,%eax
103495: c7 00 00 00 00 00 movl $0x0,(%eax)
//now the basic virtual memory map(see memalyout.h) is established.
//check the correctness of the basic virtual memory map.
check_boot_pgdir();
10349b: e8 ce 08 00 00 call 103d6e <check_boot_pgdir>
print_pgdir();
1034a0: e8 c4 0c 00 00 call 104169 <print_pgdir>
}
1034a5: 90 nop
1034a6: c9 leave
1034a7: c3 ret
001034a8 <get_pte>:
// pgdir: the kernel virtual base address of PDT
// la: the linear address need to map
// create: a logical value to decide if alloc a page for PT
// return vaule: the kernel virtual address of this pte
pte_t *
get_pte(pde_t *pgdir, uintptr_t la, bool create) {
1034a8: 55 push %ebp
1034a9: 89 e5 mov %esp,%ebp
1034ab: 83 ec 28 sub $0x28,%esp
* DEFINEs:
* PTE_P 0x001 // page table/directory entry flags bit : Present
* PTE_W 0x002 // page table/directory entry flags bit : Writeable
* PTE_U 0x004 // page table/directory entry flags bit : User can access
*/
pde_t *pdep = pgdir + PDX(la); // (1) find page directory entry
1034ae: 8b 45 0c mov 0xc(%ebp),%eax
1034b1: c1 e8 16 shr $0x16,%eax
1034b4: 8d 14 85 00 00 00 00 lea 0x0(,%eax,4),%edx
1034bb: 8b 45 08 mov 0x8(%ebp),%eax
1034be: 01 d0 add %edx,%eax
1034c0: 89 45 f4 mov %eax,-0xc(%ebp)
if (((*pdep) & PTE_P) != 1) { // (2) check if entry is not present
1034c3: 8b 45 f4 mov -0xc(%ebp),%eax
1034c6: 8b 00 mov (%eax),%eax
1034c8: 83 e0 01 and $0x1,%eax
1034cb: 85 c0 test %eax,%eax
1034cd: 0f 85 bd 00 00 00 jne 103590 <get_pte+0xe8>
if (!create) return NULL; // (3) check if creating is needed, then alloc page for page table
1034d3: 83 7d 10 00 cmpl $0x0,0x10(%ebp)
1034d7: 75 0a jne 1034e3 <get_pte+0x3b>
1034d9: b8 00 00 00 00 mov $0x0,%eax
1034de: e9 fe 00 00 00 jmp 1035e1 <get_pte+0x139>
struct Page* ptPage;
assert(ptPage = alloc_page());
1034e3: 83 ec 0c sub $0xc,%esp
1034e6: 6a 01 push $0x1
1034e8: e8 82 f8 ff ff call 102d6f <alloc_pages>
1034ed: 83 c4 10 add $0x10,%esp
1034f0: 89 45 f0 mov %eax,-0x10(%ebp)
1034f3: 83 7d f0 00 cmpl $0x0,-0x10(%ebp)
1034f7: 75 19 jne 103512 <get_pte+0x6a>
1034f9: 68 60 72 10 00 push $0x107260
1034fe: 68 25 72 10 00 push $0x107225
103503: 68 87 01 00 00 push $0x187
103508: 68 64 71 10 00 push $0x107164
10350d: e8 bb ce ff ff call 1003cd <__panic>
set_page_ref(ptPage, 1); // (4) set page reference
103512: 83 ec 08 sub $0x8,%esp
103515: 6a 01 push $0x1
103517: ff 75 f0 pushl -0x10(%ebp)
10351a: e8 4c f6 ff ff call 102b6b <set_page_ref>
10351f: 83 c4 10 add $0x10,%esp
uintptr_t pa = page2pa(ptPage); // (5) get linear address of page
103522: 83 ec 0c sub $0xc,%esp
103525: ff 75 f0 pushl -0x10(%ebp)
103528: e8 3f f5 ff ff call 102a6c <page2pa>
10352d: 83 c4 10 add $0x10,%esp
103530: 89 45 ec mov %eax,-0x14(%ebp)
memset(KADDR(pa), 0, PGSIZE); // (6) clear page content using memset
103533: 8b 45 ec mov -0x14(%ebp),%eax
103536: 89 45 e8 mov %eax,-0x18(%ebp)
103539: 8b 45 e8 mov -0x18(%ebp),%eax
10353c: c1 e8 0c shr $0xc,%eax
10353f: 89 45 e4 mov %eax,-0x1c(%ebp)
103542: a1 c0 a8 11 00 mov 0x11a8c0,%eax
103547: 39 45 e4 cmp %eax,-0x1c(%ebp)
10354a: 72 17 jb 103563 <get_pte+0xbb>
10354c: ff 75 e8 pushl -0x18(%ebp)
10354f: 68 80 70 10 00 push $0x107080
103554: 68 8a 01 00 00 push $0x18a
103559: 68 64 71 10 00 push $0x107164
10355e: e8 6a ce ff ff call 1003cd <__panic>
103563: 8b 45 e8 mov -0x18(%ebp),%eax
103566: 2d 00 00 00 40 sub $0x40000000,%eax
10356b: 83 ec 04 sub $0x4,%esp
10356e: 68 00 10 00 00 push $0x1000
103573: 6a 00 push $0x0
103575: 50 push %eax
103576: e8 ec 2b 00 00 call 106167 <memset>
10357b: 83 c4 10 add $0x10,%esp
*pdep = ((pa & ~0x0FFF) | PTE_U | PTE_W | PTE_P); // (7) set page directory entry's permission
10357e: 8b 45 ec mov -0x14(%ebp),%eax
103581: 25 00 f0 ff ff and $0xfffff000,%eax
103586: 83 c8 07 or $0x7,%eax
103589: 89 c2 mov %eax,%edx
10358b: 8b 45 f4 mov -0xc(%ebp),%eax
10358e: 89 10 mov %edx,(%eax)
}
return ((pte_t*)KADDR((*pdep) & ~0xFFF)) + PTX(la); // (8) return page table entry
103590: 8b 45 f4 mov -0xc(%ebp),%eax
103593: 8b 00 mov (%eax),%eax
103595: 25 00 f0 ff ff and $0xfffff000,%eax
10359a: 89 45 e0 mov %eax,-0x20(%ebp)
10359d: 8b 45 e0 mov -0x20(%ebp),%eax
1035a0: c1 e8 0c shr $0xc,%eax
1035a3: 89 45 dc mov %eax,-0x24(%ebp)
1035a6: a1 c0 a8 11 00 mov 0x11a8c0,%eax
1035ab: 39 45 dc cmp %eax,-0x24(%ebp)
1035ae: 72 17 jb 1035c7 <get_pte+0x11f>
1035b0: ff 75 e0 pushl -0x20(%ebp)
1035b3: 68 80 70 10 00 push $0x107080
1035b8: 68 8d 01 00 00 push $0x18d
1035bd: 68 64 71 10 00 push $0x107164
1035c2: e8 06 ce ff ff call 1003cd <__panic>
1035c7: 8b 45 e0 mov -0x20(%ebp),%eax
1035ca: 2d 00 00 00 40 sub $0x40000000,%eax
1035cf: 89 c2 mov %eax,%edx
1035d1: 8b 45 0c mov 0xc(%ebp),%eax
1035d4: c1 e8 0c shr $0xc,%eax
1035d7: 25 ff 03 00 00 and $0x3ff,%eax
1035dc: c1 e0 02 shl $0x2,%eax
1035df: 01 d0 add %edx,%eax
}
1035e1: c9 leave
1035e2: c3 ret
001035e3 <get_page>:
//get_page - get related Page struct for linear address la using PDT pgdir
struct Page *
get_page(pde_t *pgdir, uintptr_t la, pte_t **ptep_store) {
1035e3: 55 push %ebp
1035e4: 89 e5 mov %esp,%ebp
1035e6: 83 ec 18 sub $0x18,%esp
pte_t *ptep = get_pte(pgdir, la, 0);
1035e9: 83 ec 04 sub $0x4,%esp
1035ec: 6a 00 push $0x0
1035ee: ff 75 0c pushl 0xc(%ebp)
1035f1: ff 75 08 pushl 0x8(%ebp)
1035f4: e8 af fe ff ff call 1034a8 <get_pte>
1035f9: 83 c4 10 add $0x10,%esp
1035fc: 89 45 f4 mov %eax,-0xc(%ebp)
if (ptep_store != NULL) {
1035ff: 83 7d 10 00 cmpl $0x0,0x10(%ebp)
103603: 74 08 je 10360d <get_page+0x2a>
*ptep_store = ptep;
103605: 8b 45 10 mov 0x10(%ebp),%eax
103608: 8b 55 f4 mov -0xc(%ebp),%edx
10360b: 89 10 mov %edx,(%eax)
}
if (ptep != NULL && *ptep & PTE_P) {
10360d: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
103611: 74 1f je 103632 <get_page+0x4f>
103613: 8b 45 f4 mov -0xc(%ebp),%eax
103616: 8b 00 mov (%eax),%eax
103618: 83 e0 01 and $0x1,%eax
10361b: 85 c0 test %eax,%eax
10361d: 74 13 je 103632 <get_page+0x4f>
return pte2page(*ptep);
10361f: 8b 45 f4 mov -0xc(%ebp),%eax
103622: 8b 00 mov (%eax),%eax
103624: 83 ec 0c sub $0xc,%esp
103627: 50 push %eax
103628: e8 de f4 ff ff call 102b0b <pte2page>
10362d: 83 c4 10 add $0x10,%esp
103630: eb 05 jmp 103637 <get_page+0x54>
}
return NULL;
103632: b8 00 00 00 00 mov $0x0,%eax
}
103637: c9 leave
103638: c3 ret
00103639 <page_remove_pte>:
//page_remove_pte - free an Page sturct which is related linear address la
// - and clean(invalidate) pte which is related linear address la
//note: PT is changed, so the TLB need to be invalidate
static inline void
page_remove_pte(pde_t *pgdir, uintptr_t la, pte_t *ptep) {
103639: 55 push %ebp
10363a: 89 e5 mov %esp,%ebp
10363c: 83 ec 18 sub $0x18,%esp
* tlb_invalidate(pde_t *pgdir, uintptr_t la) : Invalidate a TLB entry, but only if the page tables being
* edited are the ones currently in use by the processor.
* DEFINEs:
* PTE_P 0x001 // page table/directory entry flags bit : Present
*/
if (((*ptep) & PTE_P) == 1) { //(1) check if this page table entry is present
10363f: 8b 45 10 mov 0x10(%ebp),%eax
103642: 8b 00 mov (%eax),%eax
103644: 83 e0 01 and $0x1,%eax
103647: 85 c0 test %eax,%eax
103649: 74 55 je 1036a0 <page_remove_pte+0x67>
struct Page *page = pte2page(*ptep); //(2) find corresponding page to pte
10364b: 8b 45 10 mov 0x10(%ebp),%eax
10364e: 8b 00 mov (%eax),%eax
103650: 83 ec 0c sub $0xc,%esp
103653: 50 push %eax
103654: e8 b2 f4 ff ff call 102b0b <pte2page>
103659: 83 c4 10 add $0x10,%esp
10365c: 89 45 f4 mov %eax,-0xc(%ebp)
page_ref_dec(page); //(3) decrease page reference
10365f: 83 ec 0c sub $0xc,%esp
103662: ff 75 f4 pushl -0xc(%ebp)
103665: e8 26 f5 ff ff call 102b90 <page_ref_dec>
10366a: 83 c4 10 add $0x10,%esp
if (page->ref == 0) {
10366d: 8b 45 f4 mov -0xc(%ebp),%eax
103670: 8b 00 mov (%eax),%eax
103672: 85 c0 test %eax,%eax
103674: 75 10 jne 103686 <page_remove_pte+0x4d>
free_page(page); //(4) and free this page when page reference reachs 0
103676: 83 ec 08 sub $0x8,%esp
103679: 6a 01 push $0x1
10367b: ff 75 f4 pushl -0xc(%ebp)
10367e: e8 2a f7 ff ff call 102dad <free_pages>
103683: 83 c4 10 add $0x10,%esp
}
(*ptep) = 0; //(5) clear second page table entry
103686: 8b 45 10 mov 0x10(%ebp),%eax
103689: c7 00 00 00 00 00 movl $0x0,(%eax)
tlb_invalidate(pgdir, la); //(6) flush tlb
10368f: 83 ec 08 sub $0x8,%esp
103692: ff 75 0c pushl 0xc(%ebp)
103695: ff 75 08 pushl 0x8(%ebp)
103698: e8 f8 00 00 00 call 103795 <tlb_invalidate>
10369d: 83 c4 10 add $0x10,%esp
}
// Should I check whether all entries in PT is not present and recycle the PT?
// Then Maybe I should set the pde to be not present.
}
1036a0: 90 nop
1036a1: c9 leave
1036a2: c3 ret
001036a3 <page_remove>:
//page_remove - free an Page which is related linear address la and has an validated pte
void
page_remove(pde_t *pgdir, uintptr_t la) {
1036a3: 55 push %ebp
1036a4: 89 e5 mov %esp,%ebp
1036a6: 83 ec 18 sub $0x18,%esp
pte_t *ptep = get_pte(pgdir, la, 0);
1036a9: 83 ec 04 sub $0x4,%esp
1036ac: 6a 00 push $0x0
1036ae: ff 75 0c pushl 0xc(%ebp)
1036b1: ff 75 08 pushl 0x8(%ebp)
1036b4: e8 ef fd ff ff call 1034a8 <get_pte>
1036b9: 83 c4 10 add $0x10,%esp
1036bc: 89 45 f4 mov %eax,-0xc(%ebp)
if (ptep != NULL) {
1036bf: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
1036c3: 74 14 je 1036d9 <page_remove+0x36>
page_remove_pte(pgdir, la, ptep);
1036c5: 83 ec 04 sub $0x4,%esp
1036c8: ff 75 f4 pushl -0xc(%ebp)
1036cb: ff 75 0c pushl 0xc(%ebp)
1036ce: ff 75 08 pushl 0x8(%ebp)
1036d1: e8 63 ff ff ff call 103639 <page_remove_pte>
1036d6: 83 c4 10 add $0x10,%esp
}
}
1036d9: 90 nop
1036da: c9 leave
1036db: c3 ret
001036dc <page_insert>:
// la: the linear address need to map
// perm: the permission of this Page which is setted in related pte
// return value: always 0
//note: PT is changed, so the TLB need to be invalidate
int
page_insert(pde_t *pgdir, struct Page *page, uintptr_t la, uint32_t perm) {
1036dc: 55 push %ebp
1036dd: 89 e5 mov %esp,%ebp
1036df: 83 ec 18 sub $0x18,%esp
pte_t *ptep = get_pte(pgdir, la, 1);
1036e2: 83 ec 04 sub $0x4,%esp
1036e5: 6a 01 push $0x1
1036e7: ff 75 10 pushl 0x10(%ebp)
1036ea: ff 75 08 pushl 0x8(%ebp)
1036ed: e8 b6 fd ff ff call 1034a8 <get_pte>
1036f2: 83 c4 10 add $0x10,%esp
1036f5: 89 45 f4 mov %eax,-0xc(%ebp)
if (ptep == NULL) {
1036f8: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
1036fc: 75 0a jne 103708 <page_insert+0x2c>
return -E_NO_MEM;
1036fe: b8 fc ff ff ff mov $0xfffffffc,%eax
103703: e9 8b 00 00 00 jmp 103793 <page_insert+0xb7>
}
page_ref_inc(page);
103708: 83 ec 0c sub $0xc,%esp
10370b: ff 75 0c pushl 0xc(%ebp)
10370e: e8 66 f4 ff ff call 102b79 <page_ref_inc>
103713: 83 c4 10 add $0x10,%esp
if (*ptep & PTE_P) {
103716: 8b 45 f4 mov -0xc(%ebp),%eax
103719: 8b 00 mov (%eax),%eax
10371b: 83 e0 01 and $0x1,%eax
10371e: 85 c0 test %eax,%eax
103720: 74 40 je 103762 <page_insert+0x86>
struct Page *p = pte2page(*ptep);
103722: 8b 45 f4 mov -0xc(%ebp),%eax
103725: 8b 00 mov (%eax),%eax
103727: 83 ec 0c sub $0xc,%esp
10372a: 50 push %eax
10372b: e8 db f3 ff ff call 102b0b <pte2page>
103730: 83 c4 10 add $0x10,%esp
103733: 89 45 f0 mov %eax,-0x10(%ebp)
if (p == page) {
103736: 8b 45 f0 mov -0x10(%ebp),%eax
103739: 3b 45 0c cmp 0xc(%ebp),%eax
10373c: 75 10 jne 10374e <page_insert+0x72>
page_ref_dec(page);
10373e: 83 ec 0c sub $0xc,%esp
103741: ff 75 0c pushl 0xc(%ebp)
103744: e8 47 f4 ff ff call 102b90 <page_ref_dec>
103749: 83 c4 10 add $0x10,%esp
10374c: eb 14 jmp 103762 <page_insert+0x86>
}
else {
page_remove_pte(pgdir, la, ptep);
10374e: 83 ec 04 sub $0x4,%esp
103751: ff 75 f4 pushl -0xc(%ebp)
103754: ff 75 10 pushl 0x10(%ebp)
103757: ff 75 08 pushl 0x8(%ebp)
10375a: e8 da fe ff ff call 103639 <page_remove_pte>
10375f: 83 c4 10 add $0x10,%esp
}
}
*ptep = page2pa(page) | PTE_P | perm;
103762: 83 ec 0c sub $0xc,%esp
103765: ff 75 0c pushl 0xc(%ebp)
103768: e8 ff f2 ff ff call 102a6c <page2pa>
10376d: 83 c4 10 add $0x10,%esp
103770: 0b 45 14 or 0x14(%ebp),%eax
103773: 83 c8 01 or $0x1,%eax
103776: 89 c2 mov %eax,%edx
103778: 8b 45 f4 mov -0xc(%ebp),%eax
10377b: 89 10 mov %edx,(%eax)
tlb_invalidate(pgdir, la);
10377d: 83 ec 08 sub $0x8,%esp
103780: ff 75 10 pushl 0x10(%ebp)
103783: ff 75 08 pushl 0x8(%ebp)
103786: e8 0a 00 00 00 call 103795 <tlb_invalidate>
10378b: 83 c4 10 add $0x10,%esp
return 0;
10378e: b8 00 00 00 00 mov $0x0,%eax
}
103793: c9 leave
103794: c3 ret
00103795 <tlb_invalidate>:
// invalidate a TLB entry, but only if the page tables being
// edited are the ones currently in use by the processor.
void
tlb_invalidate(pde_t *pgdir, uintptr_t la) {
103795: 55 push %ebp
103796: 89 e5 mov %esp,%ebp
103798: 83 ec 18 sub $0x18,%esp
}
static inline uintptr_t
rcr3(void) {
uintptr_t cr3;
asm volatile ("mov %%cr3, %0" : "=r" (cr3) :: "memory");
10379b: 0f 20 d8 mov %cr3,%eax
10379e: 89 45 ec mov %eax,-0x14(%ebp)
return cr3;
1037a1: 8b 55 ec mov -0x14(%ebp),%edx
if (rcr3() == PADDR(pgdir)) {
1037a4: 8b 45 08 mov 0x8(%ebp),%eax
1037a7: 89 45 f0 mov %eax,-0x10(%ebp)
1037aa: 81 7d f0 ff ff ff bf cmpl $0xbfffffff,-0x10(%ebp)
1037b1: 77 17 ja 1037ca <tlb_invalidate+0x35>
1037b3: ff 75 f0 pushl -0x10(%ebp)
1037b6: 68 40 71 10 00 push $0x107140
1037bb: 68 e9 01 00 00 push $0x1e9
1037c0: 68 64 71 10 00 push $0x107164
1037c5: e8 03 cc ff ff call 1003cd <__panic>
1037ca: 8b 45 f0 mov -0x10(%ebp),%eax
1037cd: 05 00 00 00 40 add $0x40000000,%eax
1037d2: 39 c2 cmp %eax,%edx
1037d4: 75 0c jne 1037e2 <tlb_invalidate+0x4d>
invlpg((void *)la);
1037d6: 8b 45 0c mov 0xc(%ebp),%eax
1037d9: 89 45 f4 mov %eax,-0xc(%ebp)
}
static inline void
invlpg(void *addr) {
asm volatile ("invlpg (%0)" :: "r" (addr) : "memory");
1037dc: 8b 45 f4 mov -0xc(%ebp),%eax
1037df: 0f 01 38 invlpg (%eax)
}
}
1037e2: 90 nop
1037e3: c9 leave
1037e4: c3 ret
001037e5 <check_alloc_page>:
static void
check_alloc_page(void) {
1037e5: 55 push %ebp
1037e6: 89 e5 mov %esp,%ebp
1037e8: 83 ec 08 sub $0x8,%esp
pmm_manager->check();
1037eb: a1 5c a9 11 00 mov 0x11a95c,%eax
1037f0: 8b 40 18 mov 0x18(%eax),%eax
1037f3: ff d0 call *%eax
cprintf("check_alloc_page() succeeded!\n");
1037f5: 83 ec 0c sub $0xc,%esp
1037f8: 68 78 72 10 00 push $0x107278
1037fd: e8 65 ca ff ff call 100267 <cprintf>
103802: 83 c4 10 add $0x10,%esp
}
103805: 90 nop
103806: c9 leave
103807: c3 ret
00103808 <check_pgdir>:
static void
check_pgdir(void) {
103808: 55 push %ebp
103809: 89 e5 mov %esp,%ebp
10380b: 83 ec 28 sub $0x28,%esp
assert(npage <= KMEMSIZE / PGSIZE);
10380e: a1 c0 a8 11 00 mov 0x11a8c0,%eax
103813: 3d 00 80 03 00 cmp $0x38000,%eax
103818: 76 19 jbe 103833 <check_pgdir+0x2b>
10381a: 68 97 72 10 00 push $0x107297
10381f: 68 25 72 10 00 push $0x107225
103824: 68 f6 01 00 00 push $0x1f6
103829: 68 64 71 10 00 push $0x107164
10382e: e8 9a cb ff ff call 1003cd <__panic>
assert(boot_pgdir != NULL && (uint32_t)PGOFF(boot_pgdir) == 0);
103833: a1 c4 a8 11 00 mov 0x11a8c4,%eax
103838: 85 c0 test %eax,%eax
10383a: 74 0e je 10384a <check_pgdir+0x42>
10383c: a1 c4 a8 11 00 mov 0x11a8c4,%eax
103841: 25 ff 0f 00 00 and $0xfff,%eax
103846: 85 c0 test %eax,%eax
103848: 74 19 je 103863 <check_pgdir+0x5b>
10384a: 68 b4 72 10 00 push $0x1072b4
10384f: 68 25 72 10 00 push $0x107225
103854: 68 f7 01 00 00 push $0x1f7
103859: 68 64 71 10 00 push $0x107164
10385e: e8 6a cb ff ff call 1003cd <__panic>
assert(get_page(boot_pgdir, 0x0, NULL) == NULL);
103863: a1 c4 a8 11 00 mov 0x11a8c4,%eax
103868: 83 ec 04 sub $0x4,%esp
10386b: 6a 00 push $0x0
10386d: 6a 00 push $0x0
10386f: 50 push %eax
103870: e8 6e fd ff ff call 1035e3 <get_page>
103875: 83 c4 10 add $0x10,%esp
103878: 85 c0 test %eax,%eax
10387a: 74 19 je 103895 <check_pgdir+0x8d>
10387c: 68 ec 72 10 00 push $0x1072ec
103881: 68 25 72 10 00 push $0x107225
103886: 68 f8 01 00 00 push $0x1f8
10388b: 68 64 71 10 00 push $0x107164
103890: e8 38 cb ff ff call 1003cd <__panic>
struct Page *p1, *p2;
p1 = alloc_page();
103895: 83 ec 0c sub $0xc,%esp
103898: 6a 01 push $0x1
10389a: e8 d0 f4 ff ff call 102d6f <alloc_pages>
10389f: 83 c4 10 add $0x10,%esp
1038a2: 89 45 f4 mov %eax,-0xc(%ebp)
assert(page_insert(boot_pgdir, p1, 0x0, 0) == 0);
1038a5: a1 c4 a8 11 00 mov 0x11a8c4,%eax
1038aa: 6a 00 push $0x0
1038ac: 6a 00 push $0x0
1038ae: ff 75 f4 pushl -0xc(%ebp)
1038b1: 50 push %eax
1038b2: e8 25 fe ff ff call 1036dc <page_insert>
1038b7: 83 c4 10 add $0x10,%esp
1038ba: 85 c0 test %eax,%eax
1038bc: 74 19 je 1038d7 <check_pgdir+0xcf>
1038be: 68 14 73 10 00 push $0x107314
1038c3: 68 25 72 10 00 push $0x107225
1038c8: 68 fc 01 00 00 push $0x1fc
1038cd: 68 64 71 10 00 push $0x107164
1038d2: e8 f6 ca ff ff call 1003cd <__panic>
pte_t *ptep;
assert((ptep = get_pte(boot_pgdir, 0x0, 0)) != NULL);
1038d7: a1 c4 a8 11 00 mov 0x11a8c4,%eax
1038dc: 83 ec 04 sub $0x4,%esp
1038df: 6a 00 push $0x0
1038e1: 6a 00 push $0x0
1038e3: 50 push %eax
1038e4: e8 bf fb ff ff call 1034a8 <get_pte>
1038e9: 83 c4 10 add $0x10,%esp
1038ec: 89 45 f0 mov %eax,-0x10(%ebp)
1038ef: 83 7d f0 00 cmpl $0x0,-0x10(%ebp)
1038f3: 75 19 jne 10390e <check_pgdir+0x106>
1038f5: 68 40 73 10 00 push $0x107340
1038fa: 68 25 72 10 00 push $0x107225
1038ff: 68 ff 01 00 00 push $0x1ff
103904: 68 64 71 10 00 push $0x107164
103909: e8 bf ca ff ff call 1003cd <__panic>
assert(pte2page(*ptep) == p1);
10390e: 8b 45 f0 mov -0x10(%ebp),%eax
103911: 8b 00 mov (%eax),%eax
103913: 83 ec 0c sub $0xc,%esp
103916: 50 push %eax
103917: e8 ef f1 ff ff call 102b0b <pte2page>
10391c: 83 c4 10 add $0x10,%esp
10391f: 3b 45 f4 cmp -0xc(%ebp),%eax
103922: 74 19 je 10393d <check_pgdir+0x135>
103924: 68 6d 73 10 00 push $0x10736d
103929: 68 25 72 10 00 push $0x107225
10392e: 68 00 02 00 00 push $0x200
103933: 68 64 71 10 00 push $0x107164
103938: e8 90 ca ff ff call 1003cd <__panic>
assert(page_ref(p1) == 1);
10393d: 83 ec 0c sub $0xc,%esp
103940: ff 75 f4 pushl -0xc(%ebp)
103943: e8 19 f2 ff ff call 102b61 <page_ref>
103948: 83 c4 10 add $0x10,%esp
10394b: 83 f8 01 cmp $0x1,%eax
10394e: 74 19 je 103969 <check_pgdir+0x161>
103950: 68 83 73 10 00 push $0x107383
103955: 68 25 72 10 00 push $0x107225
10395a: 68 01 02 00 00 push $0x201
10395f: 68 64 71 10 00 push $0x107164
103964: e8 64 ca ff ff call 1003cd <__panic>
ptep = &((pte_t *)KADDR(PDE_ADDR(boot_pgdir[0])))[1];
103969: a1 c4 a8 11 00 mov 0x11a8c4,%eax
10396e: 8b 00 mov (%eax),%eax
103970: 25 00 f0 ff ff and $0xfffff000,%eax
103975: 89 45 ec mov %eax,-0x14(%ebp)
103978: 8b 45 ec mov -0x14(%ebp),%eax
10397b: c1 e8 0c shr $0xc,%eax
10397e: 89 45 e8 mov %eax,-0x18(%ebp)
103981: a1 c0 a8 11 00 mov 0x11a8c0,%eax
103986: 39 45 e8 cmp %eax,-0x18(%ebp)
103989: 72 17 jb 1039a2 <check_pgdir+0x19a>
10398b: ff 75 ec pushl -0x14(%ebp)
10398e: 68 80 70 10 00 push $0x107080
103993: 68 03 02 00 00 push $0x203
103998: 68 64 71 10 00 push $0x107164
10399d: e8 2b ca ff ff call 1003cd <__panic>
1039a2: 8b 45 ec mov -0x14(%ebp),%eax
1039a5: 2d 00 00 00 40 sub $0x40000000,%eax
1039aa: 83 c0 04 add $0x4,%eax
1039ad: 89 45 f0 mov %eax,-0x10(%ebp)
assert(get_pte(boot_pgdir, PGSIZE, 0) == ptep);
1039b0: a1 c4 a8 11 00 mov 0x11a8c4,%eax
1039b5: 83 ec 04 sub $0x4,%esp
1039b8: 6a 00 push $0x0
1039ba: 68 00 10 00 00 push $0x1000
1039bf: 50 push %eax
1039c0: e8 e3 fa ff ff call 1034a8 <get_pte>
1039c5: 83 c4 10 add $0x10,%esp
1039c8: 3b 45 f0 cmp -0x10(%ebp),%eax
1039cb: 74 19 je 1039e6 <check_pgdir+0x1de>
1039cd: 68 98 73 10 00 push $0x107398
1039d2: 68 25 72 10 00 push $0x107225
1039d7: 68 04 02 00 00 push $0x204
1039dc: 68 64 71 10 00 push $0x107164
1039e1: e8 e7 c9 ff ff call 1003cd <__panic>
p2 = alloc_page();
1039e6: 83 ec 0c sub $0xc,%esp
1039e9: 6a 01 push $0x1
1039eb: e8 7f f3 ff ff call 102d6f <alloc_pages>
1039f0: 83 c4 10 add $0x10,%esp
1039f3: 89 45 e4 mov %eax,-0x1c(%ebp)
assert(page_insert(boot_pgdir, p2, PGSIZE, PTE_U | PTE_W) == 0);
1039f6: a1 c4 a8 11 00 mov 0x11a8c4,%eax
1039fb: 6a 06 push $0x6
1039fd: 68 00 10 00 00 push $0x1000
103a02: ff 75 e4 pushl -0x1c(%ebp)
103a05: 50 push %eax
103a06: e8 d1 fc ff ff call 1036dc <page_insert>
103a0b: 83 c4 10 add $0x10,%esp
103a0e: 85 c0 test %eax,%eax
103a10: 74 19 je 103a2b <check_pgdir+0x223>
103a12: 68 c0 73 10 00 push $0x1073c0
103a17: 68 25 72 10 00 push $0x107225
103a1c: 68 07 02 00 00 push $0x207
103a21: 68 64 71 10 00 push $0x107164
103a26: e8 a2 c9 ff ff call 1003cd <__panic>
assert((ptep = get_pte(boot_pgdir, PGSIZE, 0)) != NULL);
103a2b: a1 c4 a8 11 00 mov 0x11a8c4,%eax
103a30: 83 ec 04 sub $0x4,%esp
103a33: 6a 00 push $0x0
103a35: 68 00 10 00 00 push $0x1000
103a3a: 50 push %eax
103a3b: e8 68 fa ff ff call 1034a8 <get_pte>
103a40: 83 c4 10 add $0x10,%esp
103a43: 89 45 f0 mov %eax,-0x10(%ebp)
103a46: 83 7d f0 00 cmpl $0x0,-0x10(%ebp)
103a4a: 75 19 jne 103a65 <check_pgdir+0x25d>
103a4c: 68 f8 73 10 00 push $0x1073f8
103a51: 68 25 72 10 00 push $0x107225
103a56: 68 08 02 00 00 push $0x208
103a5b: 68 64 71 10 00 push $0x107164
103a60: e8 68 c9 ff ff call 1003cd <__panic>
assert(*ptep & PTE_U);
103a65: 8b 45 f0 mov -0x10(%ebp),%eax
103a68: 8b 00 mov (%eax),%eax
103a6a: 83 e0 04 and $0x4,%eax
103a6d: 85 c0 test %eax,%eax
103a6f: 75 19 jne 103a8a <check_pgdir+0x282>
103a71: 68 28 74 10 00 push $0x107428
103a76: 68 25 72 10 00 push $0x107225
103a7b: 68 09 02 00 00 push $0x209
103a80: 68 64 71 10 00 push $0x107164
103a85: e8 43 c9 ff ff call 1003cd <__panic>
assert(*ptep & PTE_W);
103a8a: 8b 45 f0 mov -0x10(%ebp),%eax
103a8d: 8b 00 mov (%eax),%eax
103a8f: 83 e0 02 and $0x2,%eax
103a92: 85 c0 test %eax,%eax
103a94: 75 19 jne 103aaf <check_pgdir+0x2a7>
103a96: 68 36 74 10 00 push $0x107436
103a9b: 68 25 72 10 00 push $0x107225
103aa0: 68 0a 02 00 00 push $0x20a
103aa5: 68 64 71 10 00 push $0x107164
103aaa: e8 1e c9 ff ff call 1003cd <__panic>
assert(boot_pgdir[0] & PTE_U);
103aaf: a1 c4 a8 11 00 mov 0x11a8c4,%eax
103ab4: 8b 00 mov (%eax),%eax
103ab6: 83 e0 04 and $0x4,%eax
103ab9: 85 c0 test %eax,%eax
103abb: 75 19 jne 103ad6 <check_pgdir+0x2ce>
103abd: 68 44 74 10 00 push $0x107444
103ac2: 68 25 72 10 00 push $0x107225
103ac7: 68 0b 02 00 00 push $0x20b
103acc: 68 64 71 10 00 push $0x107164
103ad1: e8 f7 c8 ff ff call 1003cd <__panic>
assert(page_ref(p2) == 1);
103ad6: 83 ec 0c sub $0xc,%esp
103ad9: ff 75 e4 pushl -0x1c(%ebp)
103adc: e8 80 f0 ff ff call 102b61 <page_ref>
103ae1: 83 c4 10 add $0x10,%esp
103ae4: 83 f8 01 cmp $0x1,%eax
103ae7: 74 19 je 103b02 <check_pgdir+0x2fa>
103ae9: 68 5a 74 10 00 push $0x10745a
103aee: 68 25 72 10 00 push $0x107225
103af3: 68 0c 02 00 00 push $0x20c
103af8: 68 64 71 10 00 push $0x107164
103afd: e8 cb c8 ff ff call 1003cd <__panic>
assert(page_insert(boot_pgdir, p1, PGSIZE, 0) == 0);
103b02: a1 c4 a8 11 00 mov 0x11a8c4,%eax
103b07: 6a 00 push $0x0
103b09: 68 00 10 00 00 push $0x1000
103b0e: ff 75 f4 pushl -0xc(%ebp)
103b11: 50 push %eax
103b12: e8 c5 fb ff ff call 1036dc <page_insert>
103b17: 83 c4 10 add $0x10,%esp
103b1a: 85 c0 test %eax,%eax
103b1c: 74 19 je 103b37 <check_pgdir+0x32f>
103b1e: 68 6c 74 10 00 push $0x10746c
103b23: 68 25 72 10 00 push $0x107225
103b28: 68 0e 02 00 00 push $0x20e
103b2d: 68 64 71 10 00 push $0x107164
103b32: e8 96 c8 ff ff call 1003cd <__panic>
assert(page_ref(p1) == 2);
103b37: 83 ec 0c sub $0xc,%esp
103b3a: ff 75 f4 pushl -0xc(%ebp)
103b3d: e8 1f f0 ff ff call 102b61 <page_ref>
103b42: 83 c4 10 add $0x10,%esp
103b45: 83 f8 02 cmp $0x2,%eax
103b48: 74 19 je 103b63 <check_pgdir+0x35b>
103b4a: 68 98 74 10 00 push $0x107498
103b4f: 68 25 72 10 00 push $0x107225
103b54: 68 0f 02 00 00 push $0x20f
103b59: 68 64 71 10 00 push $0x107164
103b5e: e8 6a c8 ff ff call 1003cd <__panic>
assert(page_ref(p2) == 0);
103b63: 83 ec 0c sub $0xc,%esp
103b66: ff 75 e4 pushl -0x1c(%ebp)
103b69: e8 f3 ef ff ff call 102b61 <page_ref>
103b6e: 83 c4 10 add $0x10,%esp
103b71: 85 c0 test %eax,%eax
103b73: 74 19 je 103b8e <check_pgdir+0x386>
103b75: 68 aa 74 10 00 push $0x1074aa
103b7a: 68 25 72 10 00 push $0x107225
103b7f: 68 10 02 00 00 push $0x210
103b84: 68 64 71 10 00 push $0x107164
103b89: e8 3f c8 ff ff call 1003cd <__panic>
assert((ptep = get_pte(boot_pgdir, PGSIZE, 0)) != NULL);
103b8e: a1 c4 a8 11 00 mov 0x11a8c4,%eax
103b93: 83 ec 04 sub $0x4,%esp
103b96: 6a 00 push $0x0
103b98: 68 00 10 00 00 push $0x1000
103b9d: 50 push %eax
103b9e: e8 05 f9 ff ff call 1034a8 <get_pte>
103ba3: 83 c4 10 add $0x10,%esp
103ba6: 89 45 f0 mov %eax,-0x10(%ebp)
103ba9: 83 7d f0 00 cmpl $0x0,-0x10(%ebp)
103bad: 75 19 jne 103bc8 <check_pgdir+0x3c0>
103baf: 68 f8 73 10 00 push $0x1073f8
103bb4: 68 25 72 10 00 push $0x107225
103bb9: 68 11 02 00 00 push $0x211
103bbe: 68 64 71 10 00 push $0x107164
103bc3: e8 05 c8 ff ff call 1003cd <__panic>
assert(pte2page(*ptep) == p1);
103bc8: 8b 45 f0 mov -0x10(%ebp),%eax
103bcb: 8b 00 mov (%eax),%eax
103bcd: 83 ec 0c sub $0xc,%esp
103bd0: 50 push %eax
103bd1: e8 35 ef ff ff call 102b0b <pte2page>
103bd6: 83 c4 10 add $0x10,%esp
103bd9: 3b 45 f4 cmp -0xc(%ebp),%eax
103bdc: 74 19 je 103bf7 <check_pgdir+0x3ef>
103bde: 68 6d 73 10 00 push $0x10736d
103be3: 68 25 72 10 00 push $0x107225
103be8: 68 12 02 00 00 push $0x212
103bed: 68 64 71 10 00 push $0x107164
103bf2: e8 d6 c7 ff ff call 1003cd <__panic>
assert((*ptep & PTE_U) == 0);
103bf7: 8b 45 f0 mov -0x10(%ebp),%eax
103bfa: 8b 00 mov (%eax),%eax
103bfc: 83 e0 04 and $0x4,%eax
103bff: 85 c0 test %eax,%eax
103c01: 74 19 je 103c1c <check_pgdir+0x414>
103c03: 68 bc 74 10 00 push $0x1074bc
103c08: 68 25 72 10 00 push $0x107225
103c0d: 68 13 02 00 00 push $0x213
103c12: 68 64 71 10 00 push $0x107164
103c17: e8 b1 c7 ff ff call 1003cd <__panic>
page_remove(boot_pgdir, 0x0);
103c1c: a1 c4 a8 11 00 mov 0x11a8c4,%eax
103c21: 83 ec 08 sub $0x8,%esp
103c24: 6a 00 push $0x0
103c26: 50 push %eax
103c27: e8 77 fa ff ff call 1036a3 <page_remove>
103c2c: 83 c4 10 add $0x10,%esp
assert(page_ref(p1) == 1);
103c2f: 83 ec 0c sub $0xc,%esp
103c32: ff 75 f4 pushl -0xc(%ebp)
103c35: e8 27 ef ff ff call 102b61 <page_ref>
103c3a: 83 c4 10 add $0x10,%esp
103c3d: 83 f8 01 cmp $0x1,%eax
103c40: 74 19 je 103c5b <check_pgdir+0x453>
103c42: 68 83 73 10 00 push $0x107383
103c47: 68 25 72 10 00 push $0x107225
103c4c: 68 16 02 00 00 push $0x216
103c51: 68 64 71 10 00 push $0x107164
103c56: e8 72 c7 ff ff call 1003cd <__panic>
assert(page_ref(p2) == 0);
103c5b: 83 ec 0c sub $0xc,%esp
103c5e: ff 75 e4 pushl -0x1c(%ebp)
103c61: e8 fb ee ff ff call 102b61 <page_ref>
103c66: 83 c4 10 add $0x10,%esp
103c69: 85 c0 test %eax,%eax
103c6b: 74 19 je 103c86 <check_pgdir+0x47e>
103c6d: 68 aa 74 10 00 push $0x1074aa
103c72: 68 25 72 10 00 push $0x107225
103c77: 68 17 02 00 00 push $0x217
103c7c: 68 64 71 10 00 push $0x107164
103c81: e8 47 c7 ff ff call 1003cd <__panic>
page_remove(boot_pgdir, PGSIZE);
103c86: a1 c4 a8 11 00 mov 0x11a8c4,%eax
103c8b: 83 ec 08 sub $0x8,%esp
103c8e: 68 00 10 00 00 push $0x1000
103c93: 50 push %eax
103c94: e8 0a fa ff ff call 1036a3 <page_remove>
103c99: 83 c4 10 add $0x10,%esp
assert(page_ref(p1) == 0);
103c9c: 83 ec 0c sub $0xc,%esp
103c9f: ff 75 f4 pushl -0xc(%ebp)
103ca2: e8 ba ee ff ff call 102b61 <page_ref>
103ca7: 83 c4 10 add $0x10,%esp
103caa: 85 c0 test %eax,%eax
103cac: 74 19 je 103cc7 <check_pgdir+0x4bf>
103cae: 68 d1 74 10 00 push $0x1074d1
103cb3: 68 25 72 10 00 push $0x107225
103cb8: 68 1a 02 00 00 push $0x21a
103cbd: 68 64 71 10 00 push $0x107164
103cc2: e8 06 c7 ff ff call 1003cd <__panic>
assert(page_ref(p2) == 0);
103cc7: 83 ec 0c sub $0xc,%esp
103cca: ff 75 e4 pushl -0x1c(%ebp)
103ccd: e8 8f ee ff ff call 102b61 <page_ref>
103cd2: 83 c4 10 add $0x10,%esp
103cd5: 85 c0 test %eax,%eax
103cd7: 74 19 je 103cf2 <check_pgdir+0x4ea>
103cd9: 68 aa 74 10 00 push $0x1074aa
103cde: 68 25 72 10 00 push $0x107225
103ce3: 68 1b 02 00 00 push $0x21b
103ce8: 68 64 71 10 00 push $0x107164
103ced: e8 db c6 ff ff call 1003cd <__panic>
assert(page_ref(pde2page(boot_pgdir[0])) == 1);
103cf2: a1 c4 a8 11 00 mov 0x11a8c4,%eax
103cf7: 8b 00 mov (%eax),%eax
103cf9: 83 ec 0c sub $0xc,%esp
103cfc: 50 push %eax
103cfd: e8 43 ee ff ff call 102b45 <pde2page>
103d02: 83 c4 10 add $0x10,%esp
103d05: 83 ec 0c sub $0xc,%esp
103d08: 50 push %eax
103d09: e8 53 ee ff ff call 102b61 <page_ref>
103d0e: 83 c4 10 add $0x10,%esp
103d11: 83 f8 01 cmp $0x1,%eax
103d14: 74 19 je 103d2f <check_pgdir+0x527>
103d16: 68 e4 74 10 00 push $0x1074e4
103d1b: 68 25 72 10 00 push $0x107225
103d20: 68 1d 02 00 00 push $0x21d
103d25: 68 64 71 10 00 push $0x107164
103d2a: e8 9e c6 ff ff call 1003cd <__panic>
free_page(pde2page(boot_pgdir[0]));
103d2f: a1 c4 a8 11 00 mov 0x11a8c4,%eax
103d34: 8b 00 mov (%eax),%eax
103d36: 83 ec 0c sub $0xc,%esp
103d39: 50 push %eax
103d3a: e8 06 ee ff ff call 102b45 <pde2page>
103d3f: 83 c4 10 add $0x10,%esp
103d42: 83 ec 08 sub $0x8,%esp
103d45: 6a 01 push $0x1
103d47: 50 push %eax
103d48: e8 60 f0 ff ff call 102dad <free_pages>
103d4d: 83 c4 10 add $0x10,%esp
boot_pgdir[0] = 0;
103d50: a1 c4 a8 11 00 mov 0x11a8c4,%eax
103d55: c7 00 00 00 00 00 movl $0x0,(%eax)
cprintf("check_pgdir() succeeded!\n");
103d5b: 83 ec 0c sub $0xc,%esp
103d5e: 68 0b 75 10 00 push $0x10750b
103d63: e8 ff c4 ff ff call 100267 <cprintf>
103d68: 83 c4 10 add $0x10,%esp
}
103d6b: 90 nop
103d6c: c9 leave
103d6d: c3 ret
00103d6e <check_boot_pgdir>:
static void
check_boot_pgdir(void) {
103d6e: 55 push %ebp
103d6f: 89 e5 mov %esp,%ebp
103d71: 83 ec 28 sub $0x28,%esp
pte_t *ptep;
int i;
for (i = 0; i < npage; i += PGSIZE) {
103d74: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp)
103d7b: e9 a3 00 00 00 jmp 103e23 <check_boot_pgdir+0xb5>
assert((ptep = get_pte(boot_pgdir, (uintptr_t)KADDR(i), 0)) != NULL);
103d80: 8b 45 f4 mov -0xc(%ebp),%eax
103d83: 89 45 f0 mov %eax,-0x10(%ebp)
103d86: 8b 45 f0 mov -0x10(%ebp),%eax
103d89: c1 e8 0c shr $0xc,%eax
103d8c: 89 45 ec mov %eax,-0x14(%ebp)
103d8f: a1 c0 a8 11 00 mov 0x11a8c0,%eax
103d94: 39 45 ec cmp %eax,-0x14(%ebp)
103d97: 72 17 jb 103db0 <check_boot_pgdir+0x42>
103d99: ff 75 f0 pushl -0x10(%ebp)
103d9c: 68 80 70 10 00 push $0x107080
103da1: 68 29 02 00 00 push $0x229
103da6: 68 64 71 10 00 push $0x107164
103dab: e8 1d c6 ff ff call 1003cd <__panic>
103db0: 8b 45 f0 mov -0x10(%ebp),%eax
103db3: 2d 00 00 00 40 sub $0x40000000,%eax
103db8: 89 c2 mov %eax,%edx
103dba: a1 c4 a8 11 00 mov 0x11a8c4,%eax
103dbf: 83 ec 04 sub $0x4,%esp
103dc2: 6a 00 push $0x0
103dc4: 52 push %edx
103dc5: 50 push %eax
103dc6: e8 dd f6 ff ff call 1034a8 <get_pte>
103dcb: 83 c4 10 add $0x10,%esp
103dce: 89 45 e8 mov %eax,-0x18(%ebp)
103dd1: 83 7d e8 00 cmpl $0x0,-0x18(%ebp)
103dd5: 75 19 jne 103df0 <check_boot_pgdir+0x82>
103dd7: 68 28 75 10 00 push $0x107528
103ddc: 68 25 72 10 00 push $0x107225
103de1: 68 29 02 00 00 push $0x229
103de6: 68 64 71 10 00 push $0x107164
103deb: e8 dd c5 ff ff call 1003cd <__panic>
assert(PTE_ADDR(*ptep) == i);
103df0: 8b 45 e8 mov -0x18(%ebp),%eax
103df3: 8b 00 mov (%eax),%eax
103df5: 25 00 f0 ff ff and $0xfffff000,%eax
103dfa: 89 c2 mov %eax,%edx
103dfc: 8b 45 f4 mov -0xc(%ebp),%eax
103dff: 39 c2 cmp %eax,%edx
103e01: 74 19 je 103e1c <check_boot_pgdir+0xae>
103e03: 68 65 75 10 00 push $0x107565
103e08: 68 25 72 10 00 push $0x107225
103e0d: 68 2a 02 00 00 push $0x22a
103e12: 68 64 71 10 00 push $0x107164
103e17: e8 b1 c5 ff ff call 1003cd <__panic>
static void
check_boot_pgdir(void) {
pte_t *ptep;
int i;
for (i = 0; i < npage; i += PGSIZE) {
103e1c: 81 45 f4 00 10 00 00 addl $0x1000,-0xc(%ebp)
103e23: 8b 55 f4 mov -0xc(%ebp),%edx
103e26: a1 c0 a8 11 00 mov 0x11a8c0,%eax
103e2b: 39 c2 cmp %eax,%edx
103e2d: 0f 82 4d ff ff ff jb 103d80 <check_boot_pgdir+0x12>
assert((ptep = get_pte(boot_pgdir, (uintptr_t)KADDR(i), 0)) != NULL);
assert(PTE_ADDR(*ptep) == i);
}
assert(PDE_ADDR(boot_pgdir[PDX(VPT)]) == PADDR(boot_pgdir));
103e33: a1 c4 a8 11 00 mov 0x11a8c4,%eax
103e38: 05 ac 0f 00 00 add $0xfac,%eax
103e3d: 8b 00 mov (%eax),%eax
103e3f: 25 00 f0 ff ff and $0xfffff000,%eax
103e44: 89 c2 mov %eax,%edx
103e46: a1 c4 a8 11 00 mov 0x11a8c4,%eax
103e4b: 89 45 e4 mov %eax,-0x1c(%ebp)
103e4e: 81 7d e4 ff ff ff bf cmpl $0xbfffffff,-0x1c(%ebp)
103e55: 77 17 ja 103e6e <check_boot_pgdir+0x100>
103e57: ff 75 e4 pushl -0x1c(%ebp)
103e5a: 68 40 71 10 00 push $0x107140
103e5f: 68 2d 02 00 00 push $0x22d
103e64: 68 64 71 10 00 push $0x107164
103e69: e8 5f c5 ff ff call 1003cd <__panic>
103e6e: 8b 45 e4 mov -0x1c(%ebp),%eax
103e71: 05 00 00 00 40 add $0x40000000,%eax
103e76: 39 c2 cmp %eax,%edx
103e78: 74 19 je 103e93 <check_boot_pgdir+0x125>
103e7a: 68 7c 75 10 00 push $0x10757c
103e7f: 68 25 72 10 00 push $0x107225
103e84: 68 2d 02 00 00 push $0x22d
103e89: 68 64 71 10 00 push $0x107164
103e8e: e8 3a c5 ff ff call 1003cd <__panic>
assert(boot_pgdir[0] == 0);
103e93: a1 c4 a8 11 00 mov 0x11a8c4,%eax
103e98: 8b 00 mov (%eax),%eax
103e9a: 85 c0 test %eax,%eax
103e9c: 74 19 je 103eb7 <check_boot_pgdir+0x149>
103e9e: 68 b0 75 10 00 push $0x1075b0
103ea3: 68 25 72 10 00 push $0x107225
103ea8: 68 2f 02 00 00 push $0x22f
103ead: 68 64 71 10 00 push $0x107164
103eb2: e8 16 c5 ff ff call 1003cd <__panic>
struct Page *p;
p = alloc_page();
103eb7: 83 ec 0c sub $0xc,%esp
103eba: 6a 01 push $0x1
103ebc: e8 ae ee ff ff call 102d6f <alloc_pages>
103ec1: 83 c4 10 add $0x10,%esp
103ec4: 89 45 e0 mov %eax,-0x20(%ebp)
assert(page_insert(boot_pgdir, p, 0x100, PTE_W) == 0);
103ec7: a1 c4 a8 11 00 mov 0x11a8c4,%eax
103ecc: 6a 02 push $0x2
103ece: 68 00 01 00 00 push $0x100
103ed3: ff 75 e0 pushl -0x20(%ebp)
103ed6: 50 push %eax
103ed7: e8 00 f8 ff ff call 1036dc <page_insert>
103edc: 83 c4 10 add $0x10,%esp
103edf: 85 c0 test %eax,%eax
103ee1: 74 19 je 103efc <check_boot_pgdir+0x18e>
103ee3: 68 c4 75 10 00 push $0x1075c4
103ee8: 68 25 72 10 00 push $0x107225
103eed: 68 33 02 00 00 push $0x233
103ef2: 68 64 71 10 00 push $0x107164
103ef7: e8 d1 c4 ff ff call 1003cd <__panic>
assert(page_ref(p) == 1);
103efc: 83 ec 0c sub $0xc,%esp
103eff: ff 75 e0 pushl -0x20(%ebp)
103f02: e8 5a ec ff ff call 102b61 <page_ref>
103f07: 83 c4 10 add $0x10,%esp
103f0a: 83 f8 01 cmp $0x1,%eax
103f0d: 74 19 je 103f28 <check_boot_pgdir+0x1ba>
103f0f: 68 f2 75 10 00 push $0x1075f2
103f14: 68 25 72 10 00 push $0x107225
103f19: 68 34 02 00 00 push $0x234
103f1e: 68 64 71 10 00 push $0x107164
103f23: e8 a5 c4 ff ff call 1003cd <__panic>
assert(page_insert(boot_pgdir, p, 0x100 + PGSIZE, PTE_W) == 0);
103f28: a1 c4 a8 11 00 mov 0x11a8c4,%eax
103f2d: 6a 02 push $0x2
103f2f: 68 00 11 00 00 push $0x1100
103f34: ff 75 e0 pushl -0x20(%ebp)
103f37: 50 push %eax
103f38: e8 9f f7 ff ff call 1036dc <page_insert>
103f3d: 83 c4 10 add $0x10,%esp
103f40: 85 c0 test %eax,%eax
103f42: 74 19 je 103f5d <check_boot_pgdir+0x1ef>
103f44: 68 04 76 10 00 push $0x107604
103f49: 68 25 72 10 00 push $0x107225
103f4e: 68 35 02 00 00 push $0x235
103f53: 68 64 71 10 00 push $0x107164
103f58: e8 70 c4 ff ff call 1003cd <__panic>
assert(page_ref(p) == 2);
103f5d: 83 ec 0c sub $0xc,%esp
103f60: ff 75 e0 pushl -0x20(%ebp)
103f63: e8 f9 eb ff ff call 102b61 <page_ref>
103f68: 83 c4 10 add $0x10,%esp
103f6b: 83 f8 02 cmp $0x2,%eax
103f6e: 74 19 je 103f89 <check_boot_pgdir+0x21b>
103f70: 68 3b 76 10 00 push $0x10763b
103f75: 68 25 72 10 00 push $0x107225
103f7a: 68 36 02 00 00 push $0x236
103f7f: 68 64 71 10 00 push $0x107164
103f84: e8 44 c4 ff ff call 1003cd <__panic>
const char *str = "ucore: Hello world!!";
103f89: c7 45 dc 4c 76 10 00 movl $0x10764c,-0x24(%ebp)
strcpy((void *)0x100, str);
103f90: 83 ec 08 sub $0x8,%esp
103f93: ff 75 dc pushl -0x24(%ebp)
103f96: 68 00 01 00 00 push $0x100
103f9b: e8 ee 1e 00 00 call 105e8e <strcpy>
103fa0: 83 c4 10 add $0x10,%esp
assert(strcmp((void *)0x100, (void *)(0x100 + PGSIZE)) == 0);
103fa3: 83 ec 08 sub $0x8,%esp
103fa6: 68 00 11 00 00 push $0x1100
103fab: 68 00 01 00 00 push $0x100
103fb0: e8 53 1f 00 00 call 105f08 <strcmp>
103fb5: 83 c4 10 add $0x10,%esp
103fb8: 85 c0 test %eax,%eax
103fba: 74 19 je 103fd5 <check_boot_pgdir+0x267>
103fbc: 68 64 76 10 00 push $0x107664
103fc1: 68 25 72 10 00 push $0x107225
103fc6: 68 3a 02 00 00 push $0x23a
103fcb: 68 64 71 10 00 push $0x107164
103fd0: e8 f8 c3 ff ff call 1003cd <__panic>
*(char *)(page2kva(p) + 0x100) = '\0';
103fd5: 83 ec 0c sub $0xc,%esp
103fd8: ff 75 e0 pushl -0x20(%ebp)
103fdb: e8 e6 ea ff ff call 102ac6 <page2kva>
103fe0: 83 c4 10 add $0x10,%esp
103fe3: 05 00 01 00 00 add $0x100,%eax
103fe8: c6 00 00 movb $0x0,(%eax)
assert(strlen((const char *)0x100) == 0);
103feb: 83 ec 0c sub $0xc,%esp
103fee: 68 00 01 00 00 push $0x100
103ff3: e8 3e 1e 00 00 call 105e36 <strlen>
103ff8: 83 c4 10 add $0x10,%esp
103ffb: 85 c0 test %eax,%eax
103ffd: 74 19 je 104018 <check_boot_pgdir+0x2aa>
103fff: 68 9c 76 10 00 push $0x10769c
104004: 68 25 72 10 00 push $0x107225
104009: 68 3d 02 00 00 push $0x23d
10400e: 68 64 71 10 00 push $0x107164
104013: e8 b5 c3 ff ff call 1003cd <__panic>
free_page(p);
104018: 83 ec 08 sub $0x8,%esp
10401b: 6a 01 push $0x1
10401d: ff 75 e0 pushl -0x20(%ebp)
104020: e8 88 ed ff ff call 102dad <free_pages>
104025: 83 c4 10 add $0x10,%esp
free_page(pde2page(boot_pgdir[0]));
104028: a1 c4 a8 11 00 mov 0x11a8c4,%eax
10402d: 8b 00 mov (%eax),%eax
10402f: 83 ec 0c sub $0xc,%esp
104032: 50 push %eax
104033: e8 0d eb ff ff call 102b45 <pde2page>
104038: 83 c4 10 add $0x10,%esp
10403b: 83 ec 08 sub $0x8,%esp
10403e: 6a 01 push $0x1
104040: 50 push %eax
104041: e8 67 ed ff ff call 102dad <free_pages>
104046: 83 c4 10 add $0x10,%esp
boot_pgdir[0] = 0;
104049: a1 c4 a8 11 00 mov 0x11a8c4,%eax
10404e: c7 00 00 00 00 00 movl $0x0,(%eax)
cprintf("check_boot_pgdir() succeeded!\n");
104054: 83 ec 0c sub $0xc,%esp
104057: 68 c0 76 10 00 push $0x1076c0
10405c: e8 06 c2 ff ff call 100267 <cprintf>
104061: 83 c4 10 add $0x10,%esp
}
104064: 90 nop
104065: c9 leave
104066: c3 ret
00104067 <perm2str>:
//perm2str - use string 'u,r,w,-' to present the permission
static const char *
perm2str(int perm) {
104067: 55 push %ebp
104068: 89 e5 mov %esp,%ebp
static char str[4];
str[0] = (perm & PTE_U) ? 'u' : '-';
10406a: 8b 45 08 mov 0x8(%ebp),%eax
10406d: 83 e0 04 and $0x4,%eax
104070: 85 c0 test %eax,%eax
104072: 74 07 je 10407b <perm2str+0x14>
104074: b8 75 00 00 00 mov $0x75,%eax
104079: eb 05 jmp 104080 <perm2str+0x19>
10407b: b8 2d 00 00 00 mov $0x2d,%eax
104080: a2 48 a9 11 00 mov %al,0x11a948
str[1] = 'r';
104085: c6 05 49 a9 11 00 72 movb $0x72,0x11a949
str[2] = (perm & PTE_W) ? 'w' : '-';
10408c: 8b 45 08 mov 0x8(%ebp),%eax
10408f: 83 e0 02 and $0x2,%eax
104092: 85 c0 test %eax,%eax
104094: 74 07 je 10409d <perm2str+0x36>
104096: b8 77 00 00 00 mov $0x77,%eax
10409b: eb 05 jmp 1040a2 <perm2str+0x3b>
10409d: b8 2d 00 00 00 mov $0x2d,%eax
1040a2: a2 4a a9 11 00 mov %al,0x11a94a
str[3] = '\0';
1040a7: c6 05 4b a9 11 00 00 movb $0x0,0x11a94b
return str;
1040ae: b8 48 a9 11 00 mov $0x11a948,%eax
}
1040b3: 5d pop %ebp
1040b4: c3 ret
001040b5 <get_pgtable_items>:
// table: the beginning addr of table
// left_store: the pointer of the high side of table's next range
// right_store: the pointer of the low side of table's next range
// return value: 0 - not a invalid item range, perm - a valid item range with perm permission
static int
get_pgtable_items(size_t left, size_t right, size_t start, uintptr_t *table, size_t *left_store, size_t *right_store) {
1040b5: 55 push %ebp
1040b6: 89 e5 mov %esp,%ebp
1040b8: 83 ec 10 sub $0x10,%esp
if (start >= right) {
1040bb: 8b 45 10 mov 0x10(%ebp),%eax
1040be: 3b 45 0c cmp 0xc(%ebp),%eax
1040c1: 72 0e jb 1040d1 <get_pgtable_items+0x1c>
return 0;
1040c3: b8 00 00 00 00 mov $0x0,%eax
1040c8: e9 9a 00 00 00 jmp 104167 <get_pgtable_items+0xb2>
}
while (start < right && !(table[start] & PTE_P)) {
start ++;
1040cd: 83 45 10 01 addl $0x1,0x10(%ebp)
static int
get_pgtable_items(size_t left, size_t right, size_t start, uintptr_t *table, size_t *left_store, size_t *right_store) {
if (start >= right) {
return 0;
}
while (start < right && !(table[start] & PTE_P)) {
1040d1: 8b 45 10 mov 0x10(%ebp),%eax
1040d4: 3b 45 0c cmp 0xc(%ebp),%eax
1040d7: 73 18 jae 1040f1 <get_pgtable_items+0x3c>
1040d9: 8b 45 10 mov 0x10(%ebp),%eax
1040dc: 8d 14 85 00 00 00 00 lea 0x0(,%eax,4),%edx
1040e3: 8b 45 14 mov 0x14(%ebp),%eax
1040e6: 01 d0 add %edx,%eax
1040e8: 8b 00 mov (%eax),%eax
1040ea: 83 e0 01 and $0x1,%eax
1040ed: 85 c0 test %eax,%eax
1040ef: 74 dc je 1040cd <get_pgtable_items+0x18>
start ++;
}
if (start < right) {
1040f1: 8b 45 10 mov 0x10(%ebp),%eax
1040f4: 3b 45 0c cmp 0xc(%ebp),%eax
1040f7: 73 69 jae 104162 <get_pgtable_items+0xad>
if (left_store != NULL) {
1040f9: 83 7d 18 00 cmpl $0x0,0x18(%ebp)
1040fd: 74 08 je 104107 <get_pgtable_items+0x52>
*left_store = start;
1040ff: 8b 45 18 mov 0x18(%ebp),%eax
104102: 8b 55 10 mov 0x10(%ebp),%edx
104105: 89 10 mov %edx,(%eax)
}
int perm = (table[start ++] & PTE_USER);
104107: 8b 45 10 mov 0x10(%ebp),%eax
10410a: 8d 50 01 lea 0x1(%eax),%edx
10410d: 89 55 10 mov %edx,0x10(%ebp)
104110: 8d 14 85 00 00 00 00 lea 0x0(,%eax,4),%edx
104117: 8b 45 14 mov 0x14(%ebp),%eax
10411a: 01 d0 add %edx,%eax
10411c: 8b 00 mov (%eax),%eax
10411e: 83 e0 07 and $0x7,%eax
104121: 89 45 fc mov %eax,-0x4(%ebp)
while (start < right && (table[start] & PTE_USER) == perm) {
104124: eb 04 jmp 10412a <get_pgtable_items+0x75>
start ++;
104126: 83 45 10 01 addl $0x1,0x10(%ebp)
if (start < right) {
if (left_store != NULL) {
*left_store = start;
}
int perm = (table[start ++] & PTE_USER);
while (start < right && (table[start] & PTE_USER) == perm) {
10412a: 8b 45 10 mov 0x10(%ebp),%eax
10412d: 3b 45 0c cmp 0xc(%ebp),%eax
104130: 73 1d jae 10414f <get_pgtable_items+0x9a>
104132: 8b 45 10 mov 0x10(%ebp),%eax
104135: 8d 14 85 00 00 00 00 lea 0x0(,%eax,4),%edx
10413c: 8b 45 14 mov 0x14(%ebp),%eax
10413f: 01 d0 add %edx,%eax
104141: 8b 00 mov (%eax),%eax
104143: 83 e0 07 and $0x7,%eax
104146: 89 c2 mov %eax,%edx
104148: 8b 45 fc mov -0x4(%ebp),%eax
10414b: 39 c2 cmp %eax,%edx
10414d: 74 d7 je 104126 <get_pgtable_items+0x71>
start ++;
}
if (right_store != NULL) {
10414f: 83 7d 1c 00 cmpl $0x0,0x1c(%ebp)
104153: 74 08 je 10415d <get_pgtable_items+0xa8>
*right_store = start;
104155: 8b 45 1c mov 0x1c(%ebp),%eax
104158: 8b 55 10 mov 0x10(%ebp),%edx
10415b: 89 10 mov %edx,(%eax)
}
return perm;
10415d: 8b 45 fc mov -0x4(%ebp),%eax
104160: eb 05 jmp 104167 <get_pgtable_items+0xb2>
}
return 0;
104162: b8 00 00 00 00 mov $0x0,%eax
}
104167: c9 leave
104168: c3 ret
00104169 <print_pgdir>:
//print_pgdir - print the PDT&PT
void
print_pgdir(void) {
104169: 55 push %ebp
10416a: 89 e5 mov %esp,%ebp
10416c: 57 push %edi
10416d: 56 push %esi
10416e: 53 push %ebx
10416f: 83 ec 2c sub $0x2c,%esp
cprintf("-------------------- BEGIN --------------------\n");
104172: 83 ec 0c sub $0xc,%esp
104175: 68 e0 76 10 00 push $0x1076e0
10417a: e8 e8 c0 ff ff call 100267 <cprintf>
10417f: 83 c4 10 add $0x10,%esp
size_t left, right = 0, perm;
104182: c7 45 dc 00 00 00 00 movl $0x0,-0x24(%ebp)
while ((perm = get_pgtable_items(0, NPDEENTRY, right, vpd, &left, &right)) != 0) {
104189: e9 e5 00 00 00 jmp 104273 <print_pgdir+0x10a>
cprintf("PDE(%03x) %08x-%08x %08x %s\n", right - left,
10418e: 8b 45 e4 mov -0x1c(%ebp),%eax
104191: 83 ec 0c sub $0xc,%esp
104194: 50 push %eax
104195: e8 cd fe ff ff call 104067 <perm2str>
10419a: 83 c4 10 add $0x10,%esp
10419d: 89 c7 mov %eax,%edi
left * PTSIZE, right * PTSIZE, (right - left) * PTSIZE, perm2str(perm));
10419f: 8b 55 dc mov -0x24(%ebp),%edx
1041a2: 8b 45 e0 mov -0x20(%ebp),%eax
1041a5: 29 c2 sub %eax,%edx
1041a7: 89 d0 mov %edx,%eax
void
print_pgdir(void) {
cprintf("-------------------- BEGIN --------------------\n");
size_t left, right = 0, perm;
while ((perm = get_pgtable_items(0, NPDEENTRY, right, vpd, &left, &right)) != 0) {
cprintf("PDE(%03x) %08x-%08x %08x %s\n", right - left,
1041a9: c1 e0 16 shl $0x16,%eax
1041ac: 89 c3 mov %eax,%ebx
1041ae: 8b 45 dc mov -0x24(%ebp),%eax
1041b1: c1 e0 16 shl $0x16,%eax
1041b4: 89 c1 mov %eax,%ecx
1041b6: 8b 45 e0 mov -0x20(%ebp),%eax
1041b9: c1 e0 16 shl $0x16,%eax
1041bc: 89 c2 mov %eax,%edx
1041be: 8b 75 dc mov -0x24(%ebp),%esi
1041c1: 8b 45 e0 mov -0x20(%ebp),%eax
1041c4: 29 c6 sub %eax,%esi
1041c6: 89 f0 mov %esi,%eax
1041c8: 83 ec 08 sub $0x8,%esp
1041cb: 57 push %edi
1041cc: 53 push %ebx
1041cd: 51 push %ecx
1041ce: 52 push %edx
1041cf: 50 push %eax
1041d0: 68 11 77 10 00 push $0x107711
1041d5: e8 8d c0 ff ff call 100267 <cprintf>
1041da: 83 c4 20 add $0x20,%esp
left * PTSIZE, right * PTSIZE, (right - left) * PTSIZE, perm2str(perm));
size_t l, r = left * NPTEENTRY;
1041dd: 8b 45 e0 mov -0x20(%ebp),%eax
1041e0: c1 e0 0a shl $0xa,%eax
1041e3: 89 45 d4 mov %eax,-0x2c(%ebp)
while ((perm = get_pgtable_items(left * NPTEENTRY, right * NPTEENTRY, r, vpt, &l, &r)) != 0) {
1041e6: eb 4f jmp 104237 <print_pgdir+0xce>
cprintf(" |-- PTE(%05x) %08x-%08x %08x %s\n", r - l,
1041e8: 8b 45 e4 mov -0x1c(%ebp),%eax
1041eb: 83 ec 0c sub $0xc,%esp
1041ee: 50 push %eax
1041ef: e8 73 fe ff ff call 104067 <perm2str>
1041f4: 83 c4 10 add $0x10,%esp
1041f7: 89 c7 mov %eax,%edi
l * PGSIZE, r * PGSIZE, (r - l) * PGSIZE, perm2str(perm));
1041f9: 8b 55 d4 mov -0x2c(%ebp),%edx
1041fc: 8b 45 d8 mov -0x28(%ebp),%eax
1041ff: 29 c2 sub %eax,%edx
104201: 89 d0 mov %edx,%eax
while ((perm = get_pgtable_items(0, NPDEENTRY, right, vpd, &left, &right)) != 0) {
cprintf("PDE(%03x) %08x-%08x %08x %s\n", right - left,
left * PTSIZE, right * PTSIZE, (right - left) * PTSIZE, perm2str(perm));
size_t l, r = left * NPTEENTRY;
while ((perm = get_pgtable_items(left * NPTEENTRY, right * NPTEENTRY, r, vpt, &l, &r)) != 0) {
cprintf(" |-- PTE(%05x) %08x-%08x %08x %s\n", r - l,
104203: c1 e0 0c shl $0xc,%eax
104206: 89 c3 mov %eax,%ebx
104208: 8b 45 d4 mov -0x2c(%ebp),%eax
10420b: c1 e0 0c shl $0xc,%eax
10420e: 89 c1 mov %eax,%ecx
104210: 8b 45 d8 mov -0x28(%ebp),%eax
104213: c1 e0 0c shl $0xc,%eax
104216: 89 c2 mov %eax,%edx
104218: 8b 75 d4 mov -0x2c(%ebp),%esi
10421b: 8b 45 d8 mov -0x28(%ebp),%eax
10421e: 29 c6 sub %eax,%esi
104220: 89 f0 mov %esi,%eax
104222: 83 ec 08 sub $0x8,%esp
104225: 57 push %edi
104226: 53 push %ebx
104227: 51 push %ecx
104228: 52 push %edx
104229: 50 push %eax
10422a: 68 30 77 10 00 push $0x107730
10422f: e8 33 c0 ff ff call 100267 <cprintf>
104234: 83 c4 20 add $0x20,%esp
size_t left, right = 0, perm;
while ((perm = get_pgtable_items(0, NPDEENTRY, right, vpd, &left, &right)) != 0) {
cprintf("PDE(%03x) %08x-%08x %08x %s\n", right - left,
left * PTSIZE, right * PTSIZE, (right - left) * PTSIZE, perm2str(perm));
size_t l, r = left * NPTEENTRY;
while ((perm = get_pgtable_items(left * NPTEENTRY, right * NPTEENTRY, r, vpt, &l, &r)) != 0) {
104237: be 00 00 c0 fa mov $0xfac00000,%esi
10423c: 8b 45 d4 mov -0x2c(%ebp),%eax
10423f: 8b 55 dc mov -0x24(%ebp),%edx
104242: 89 d3 mov %edx,%ebx
104244: c1 e3 0a shl $0xa,%ebx
104247: 8b 55 e0 mov -0x20(%ebp),%edx
10424a: 89 d1 mov %edx,%ecx
10424c: c1 e1 0a shl $0xa,%ecx
10424f: 83 ec 08 sub $0x8,%esp
104252: 8d 55 d4 lea -0x2c(%ebp),%edx
104255: 52 push %edx
104256: 8d 55 d8 lea -0x28(%ebp),%edx
104259: 52 push %edx
10425a: 56 push %esi
10425b: 50 push %eax
10425c: 53 push %ebx
10425d: 51 push %ecx
10425e: e8 52 fe ff ff call 1040b5 <get_pgtable_items>
104263: 83 c4 20 add $0x20,%esp
104266: 89 45 e4 mov %eax,-0x1c(%ebp)
104269: 83 7d e4 00 cmpl $0x0,-0x1c(%ebp)
10426d: 0f 85 75 ff ff ff jne 1041e8 <print_pgdir+0x7f>
//print_pgdir - print the PDT&PT
void
print_pgdir(void) {
cprintf("-------------------- BEGIN --------------------\n");
size_t left, right = 0, perm;
while ((perm = get_pgtable_items(0, NPDEENTRY, right, vpd, &left, &right)) != 0) {
104273: b9 00 b0 fe fa mov $0xfafeb000,%ecx
104278: 8b 45 dc mov -0x24(%ebp),%eax
10427b: 83 ec 08 sub $0x8,%esp
10427e: 8d 55 dc lea -0x24(%ebp),%edx
104281: 52 push %edx
104282: 8d 55 e0 lea -0x20(%ebp),%edx
104285: 52 push %edx
104286: 51 push %ecx
104287: 50 push %eax
104288: 68 00 04 00 00 push $0x400
10428d: 6a 00 push $0x0
10428f: e8 21 fe ff ff call 1040b5 <get_pgtable_items>
104294: 83 c4 20 add $0x20,%esp
104297: 89 45 e4 mov %eax,-0x1c(%ebp)
10429a: 83 7d e4 00 cmpl $0x0,-0x1c(%ebp)
10429e: 0f 85 ea fe ff ff jne 10418e <print_pgdir+0x25>
while ((perm = get_pgtable_items(left * NPTEENTRY, right * NPTEENTRY, r, vpt, &l, &r)) != 0) {
cprintf(" |-- PTE(%05x) %08x-%08x %08x %s\n", r - l,
l * PGSIZE, r * PGSIZE, (r - l) * PGSIZE, perm2str(perm));
}
}
cprintf("--------------------- END ---------------------\n");
1042a4: 83 ec 0c sub $0xc,%esp
1042a7: 68 54 77 10 00 push $0x107754
1042ac: e8 b6 bf ff ff call 100267 <cprintf>
1042b1: 83 c4 10 add $0x10,%esp
}
1042b4: 90 nop
1042b5: 8d 65 f4 lea -0xc(%ebp),%esp
1042b8: 5b pop %ebx
1042b9: 5e pop %esi
1042ba: 5f pop %edi
1042bb: 5d pop %ebp
1042bc: c3 ret
001042bd <page2ppn>:
extern struct Page *pages;
extern size_t npage;
static inline ppn_t
page2ppn(struct Page *page) {
1042bd: 55 push %ebp
1042be: 89 e5 mov %esp,%ebp
return page - pages;
1042c0: 8b 45 08 mov 0x8(%ebp),%eax
1042c3: 8b 15 64 a9 11 00 mov 0x11a964,%edx
1042c9: 29 d0 sub %edx,%eax
1042cb: c1 f8 02 sar $0x2,%eax
1042ce: 69 c0 cd cc cc cc imul $0xcccccccd,%eax,%eax
}
1042d4: 5d pop %ebp
1042d5: c3 ret
001042d6 <page2pa>:
static inline uintptr_t
page2pa(struct Page *page) {
1042d6: 55 push %ebp
1042d7: 89 e5 mov %esp,%ebp
return page2ppn(page) << PGSHIFT;
1042d9: ff 75 08 pushl 0x8(%ebp)
1042dc: e8 dc ff ff ff call 1042bd <page2ppn>
1042e1: 83 c4 04 add $0x4,%esp
1042e4: c1 e0 0c shl $0xc,%eax
}
1042e7: c9 leave
1042e8: c3 ret
001042e9 <page_ref>:
pde2page(pde_t pde) {
return pa2page(PDE_ADDR(pde));
}
static inline int
page_ref(struct Page *page) {
1042e9: 55 push %ebp
1042ea: 89 e5 mov %esp,%ebp
return page->ref;
1042ec: 8b 45 08 mov 0x8(%ebp),%eax
1042ef: 8b 00 mov (%eax),%eax
}
1042f1: 5d pop %ebp
1042f2: c3 ret
001042f3 <set_page_ref>:
static inline void
set_page_ref(struct Page *page, int val) {
1042f3: 55 push %ebp
1042f4: 89 e5 mov %esp,%ebp
page->ref = val;
1042f6: 8b 45 08 mov 0x8(%ebp),%eax
1042f9: 8b 55 0c mov 0xc(%ebp),%edx
1042fc: 89 10 mov %edx,(%eax)
}
1042fe: 90 nop
1042ff: 5d pop %ebp
104300: c3 ret
00104301 <default_init>:
#define free_list (free_area.free_list)
#define nr_free (free_area.nr_free)
static void
default_init(void) {
104301: 55 push %ebp
104302: 89 e5 mov %esp,%ebp
104304: 83 ec 10 sub $0x10,%esp
104307: c7 45 fc 68 a9 11 00 movl $0x11a968,-0x4(%ebp)
* list_init - initialize a new entry
* @elm: new entry to be initialized
* */
static inline void
list_init(list_entry_t *elm) {
elm->prev = elm->next = elm;
10430e: 8b 45 fc mov -0x4(%ebp),%eax
104311: 8b 55 fc mov -0x4(%ebp),%edx
104314: 89 50 04 mov %edx,0x4(%eax)
104317: 8b 45 fc mov -0x4(%ebp),%eax
10431a: 8b 50 04 mov 0x4(%eax),%edx
10431d: 8b 45 fc mov -0x4(%ebp),%eax
104320: 89 10 mov %edx,(%eax)
list_init(&free_list);
nr_free = 0;
104322: c7 05 70 a9 11 00 00 movl $0x0,0x11a970
104329: 00 00 00
}
10432c: 90 nop
10432d: c9 leave
10432e: c3 ret
0010432f <default_init_memmap>:
static void
default_init_memmap(struct Page *base, size_t n) {
10432f: 55 push %ebp
104330: 89 e5 mov %esp,%ebp
104332: 83 ec 38 sub $0x38,%esp
assert(n > 0);
104335: 83 7d 0c 00 cmpl $0x0,0xc(%ebp)
104339: 75 16 jne 104351 <default_init_memmap+0x22>
10433b: 68 88 77 10 00 push $0x107788
104340: 68 8e 77 10 00 push $0x10778e
104345: 6a 46 push $0x46
104347: 68 a3 77 10 00 push $0x1077a3
10434c: e8 7c c0 ff ff call 1003cd <__panic>
struct Page *p = base;
104351: 8b 45 08 mov 0x8(%ebp),%eax
104354: 89 45 f4 mov %eax,-0xc(%ebp)
for (; p != base + n; p ++) {
104357: eb 6c jmp 1043c5 <default_init_memmap+0x96>
// Before: the page must have been set reserved in page_init.
assert(PageReserved(p));
104359: 8b 45 f4 mov -0xc(%ebp),%eax
10435c: 83 c0 04 add $0x4,%eax
10435f: c7 45 e8 00 00 00 00 movl $0x0,-0x18(%ebp)
104366: 89 45 e4 mov %eax,-0x1c(%ebp)
* @addr: the address to count from
* */
static inline bool
test_bit(int nr, volatile void *addr) {
int oldbit;
asm volatile ("btl %2, %1; sbbl %0,%0" : "=r" (oldbit) : "m" (*(volatile long *)addr), "Ir" (nr));
104369: 8b 45 e4 mov -0x1c(%ebp),%eax
10436c: 8b 55 e8 mov -0x18(%ebp),%edx
10436f: 0f a3 10 bt %edx,(%eax)
104372: 19 c0 sbb %eax,%eax
104374: 89 45 e0 mov %eax,-0x20(%ebp)
return oldbit != 0;
104377: 83 7d e0 00 cmpl $0x0,-0x20(%ebp)
10437b: 0f 95 c0 setne %al
10437e: 0f b6 c0 movzbl %al,%eax
104381: 85 c0 test %eax,%eax
104383: 75 16 jne 10439b <default_init_memmap+0x6c>
104385: 68 b9 77 10 00 push $0x1077b9
10438a: 68 8e 77 10 00 push $0x10778e
10438f: 6a 4a push $0x4a
104391: 68 a3 77 10 00 push $0x1077a3
104396: e8 32 c0 ff ff call 1003cd <__panic>
// Initialize flags, property and ref
p->flags = p->property = 0;
10439b: 8b 45 f4 mov -0xc(%ebp),%eax
10439e: c7 40 08 00 00 00 00 movl $0x0,0x8(%eax)
1043a5: 8b 45 f4 mov -0xc(%ebp),%eax
1043a8: 8b 50 08 mov 0x8(%eax),%edx
1043ab: 8b 45 f4 mov -0xc(%ebp),%eax
1043ae: 89 50 04 mov %edx,0x4(%eax)
set_page_ref(p, 0);
1043b1: 83 ec 08 sub $0x8,%esp
1043b4: 6a 00 push $0x0
1043b6: ff 75 f4 pushl -0xc(%ebp)
1043b9: e8 35 ff ff ff call 1042f3 <set_page_ref>
1043be: 83 c4 10 add $0x10,%esp
static void
default_init_memmap(struct Page *base, size_t n) {
assert(n > 0);
struct Page *p = base;
for (; p != base + n; p ++) {
1043c1: 83 45 f4 14 addl $0x14,-0xc(%ebp)
1043c5: 8b 55 0c mov 0xc(%ebp),%edx
1043c8: 89 d0 mov %edx,%eax
1043ca: c1 e0 02 shl $0x2,%eax
1043cd: 01 d0 add %edx,%eax
1043cf: c1 e0 02 shl $0x2,%eax
1043d2: 89 c2 mov %eax,%edx
1043d4: 8b 45 08 mov 0x8(%ebp),%eax
1043d7: 01 d0 add %edx,%eax
1043d9: 3b 45 f4 cmp -0xc(%ebp),%eax
1043dc: 0f 85 77 ff ff ff jne 104359 <default_init_memmap+0x2a>
// Initialize flags, property and ref
p->flags = p->property = 0;
set_page_ref(p, 0);
}
// The base page is the start of continuous free pages.
base->property = n;
1043e2: 8b 45 08 mov 0x8(%ebp),%eax
1043e5: 8b 55 0c mov 0xc(%ebp),%edx
1043e8: 89 50 08 mov %edx,0x8(%eax)
SetPageProperty(base);
1043eb: 8b 45 08 mov 0x8(%ebp),%eax
1043ee: 83 c0 04 add $0x4,%eax
1043f1: c7 45 ec 01 00 00 00 movl $0x1,-0x14(%ebp)
1043f8: 89 45 cc mov %eax,-0x34(%ebp)
* Note that @nr may be almost arbitrarily large; this function is not
* restricted to acting on a single-word quantity.
* */
static inline void
set_bit(int nr, volatile void *addr) {
asm volatile ("btsl %1, %0" :"=m" (*(volatile long *)addr) : "Ir" (nr));
1043fb: 8b 45 cc mov -0x34(%ebp),%eax
1043fe: 8b 55 ec mov -0x14(%ebp),%edx
104401: 0f ab 10 bts %edx,(%eax)
nr_free += n;
104404: 8b 15 70 a9 11 00 mov 0x11a970,%edx
10440a: 8b 45 0c mov 0xc(%ebp),%eax
10440d: 01 d0 add %edx,%eax
10440f: a3 70 a9 11 00 mov %eax,0x11a970
list_add_before(&free_list, &(base->page_link));
104414: 8b 45 08 mov 0x8(%ebp),%eax
104417: 83 c0 0c add $0xc,%eax
10441a: c7 45 f0 68 a9 11 00 movl $0x11a968,-0x10(%ebp)
104421: 89 45 dc mov %eax,-0x24(%ebp)
* Insert the new element @elm *before* the element @listelm which
* is already in the list.
* */
static inline void
list_add_before(list_entry_t *listelm, list_entry_t *elm) {
__list_add(elm, listelm->prev, listelm);
104424: 8b 45 f0 mov -0x10(%ebp),%eax
104427: 8b 00 mov (%eax),%eax
104429: 8b 55 dc mov -0x24(%ebp),%edx
10442c: 89 55 d8 mov %edx,-0x28(%ebp)
10442f: 89 45 d4 mov %eax,-0x2c(%ebp)
104432: 8b 45 f0 mov -0x10(%ebp),%eax
104435: 89 45 d0 mov %eax,-0x30(%ebp)
* This is only for internal list manipulation where we know
* the prev/next entries already!
* */
static inline void
__list_add(list_entry_t *elm, list_entry_t *prev, list_entry_t *next) {
prev->next = next->prev = elm;
104438: 8b 45 d0 mov -0x30(%ebp),%eax
10443b: 8b 55 d8 mov -0x28(%ebp),%edx
10443e: 89 10 mov %edx,(%eax)
104440: 8b 45 d0 mov -0x30(%ebp),%eax
104443: 8b 10 mov (%eax),%edx
104445: 8b 45 d4 mov -0x2c(%ebp),%eax
104448: 89 50 04 mov %edx,0x4(%eax)
elm->next = next;
10444b: 8b 45 d8 mov -0x28(%ebp),%eax
10444e: 8b 55 d0 mov -0x30(%ebp),%edx
104451: 89 50 04 mov %edx,0x4(%eax)
elm->prev = prev;
104454: 8b 45 d8 mov -0x28(%ebp),%eax
104457: 8b 55 d4 mov -0x2c(%ebp),%edx
10445a: 89 10 mov %edx,(%eax)
}
10445c: 90 nop
10445d: c9 leave
10445e: c3 ret
0010445f <default_alloc_pages>:
static struct Page *
default_alloc_pages(size_t n) {
10445f: 55 push %ebp
104460: 89 e5 mov %esp,%ebp
104462: 83 ec 68 sub $0x68,%esp
assert(n > 0);
104465: 83 7d 08 00 cmpl $0x0,0x8(%ebp)
104469: 75 16 jne 104481 <default_alloc_pages+0x22>
10446b: 68 88 77 10 00 push $0x107788
104470: 68 8e 77 10 00 push $0x10778e
104475: 6a 58 push $0x58
104477: 68 a3 77 10 00 push $0x1077a3
10447c: e8 4c bf ff ff call 1003cd <__panic>
if (n > nr_free) {
104481: a1 70 a9 11 00 mov 0x11a970,%eax
104486: 3b 45 08 cmp 0x8(%ebp),%eax
104489: 73 0a jae 104495 <default_alloc_pages+0x36>
return NULL;
10448b: b8 00 00 00 00 mov $0x0,%eax
104490: e9 a8 01 00 00 jmp 10463d <default_alloc_pages+0x1de>
}
struct Page *page = NULL;
104495: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp)
list_entry_t *le = &free_list;
10449c: c7 45 f0 68 a9 11 00 movl $0x11a968,-0x10(%ebp)
while ((le = list_next(le)) != &free_list) {
1044a3: eb 1c jmp 1044c1 <default_alloc_pages+0x62>
struct Page *p = le2page(le, page_link);
1044a5: 8b 45 f0 mov -0x10(%ebp),%eax
1044a8: 83 e8 0c sub $0xc,%eax
1044ab: 89 45 e4 mov %eax,-0x1c(%ebp)
if (p->property >= n) {
1044ae: 8b 45 e4 mov -0x1c(%ebp),%eax
1044b1: 8b 40 08 mov 0x8(%eax),%eax
1044b4: 3b 45 08 cmp 0x8(%ebp),%eax
1044b7: 72 08 jb 1044c1 <default_alloc_pages+0x62>
page = p;
1044b9: 8b 45 e4 mov -0x1c(%ebp),%eax
1044bc: 89 45 f4 mov %eax,-0xc(%ebp)
break;
1044bf: eb 18 jmp 1044d9 <default_alloc_pages+0x7a>
1044c1: 8b 45 f0 mov -0x10(%ebp),%eax
1044c4: 89 45 c8 mov %eax,-0x38(%ebp)
* list_next - get the next entry
* @listelm: the list head
**/
static inline list_entry_t *
list_next(list_entry_t *listelm) {
return listelm->next;
1044c7: 8b 45 c8 mov -0x38(%ebp),%eax
1044ca: 8b 40 04 mov 0x4(%eax),%eax
if (n > nr_free) {
return NULL;
}
struct Page *page = NULL;
list_entry_t *le = &free_list;
while ((le = list_next(le)) != &free_list) {
1044cd: 89 45 f0 mov %eax,-0x10(%ebp)
1044d0: 81 7d f0 68 a9 11 00 cmpl $0x11a968,-0x10(%ebp)
1044d7: 75 cc jne 1044a5 <default_alloc_pages+0x46>
if (p->property >= n) {
page = p;
break;
}
}
if (page != NULL) {
1044d9: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
1044dd: 0f 84 57 01 00 00 je 10463a <default_alloc_pages+0x1db>
for (int i = 1; i < n; ++ i) {
1044e3: c7 45 ec 01 00 00 00 movl $0x1,-0x14(%ebp)
1044ea: eb 4e jmp 10453a <default_alloc_pages+0xdb>
struct Page *p = page + i;
1044ec: 8b 55 ec mov -0x14(%ebp),%edx
1044ef: 89 d0 mov %edx,%eax
1044f1: c1 e0 02 shl $0x2,%eax
1044f4: 01 d0 add %edx,%eax
1044f6: c1 e0 02 shl $0x2,%eax
1044f9: 89 c2 mov %eax,%edx
1044fb: 8b 45 f4 mov -0xc(%ebp),%eax
1044fe: 01 d0 add %edx,%eax
104500: 89 45 e0 mov %eax,-0x20(%ebp)
// assert(!PageReserved(p));
ClearPageProperty(p);
104503: 8b 45 e0 mov -0x20(%ebp),%eax
104506: 83 c0 04 add $0x4,%eax
104509: c7 45 e8 01 00 00 00 movl $0x1,-0x18(%ebp)
104510: 89 45 c4 mov %eax,-0x3c(%ebp)
* @nr: the bit to clear
* @addr: the address to start counting from
* */
static inline void
clear_bit(int nr, volatile void *addr) {
asm volatile ("btrl %1, %0" :"=m" (*(volatile long *)addr) : "Ir" (nr));
104513: 8b 45 c4 mov -0x3c(%ebp),%eax
104516: 8b 55 e8 mov -0x18(%ebp),%edx
104519: 0f b3 10 btr %edx,(%eax)
p->property = 0;
10451c: 8b 45 e0 mov -0x20(%ebp),%eax
10451f: c7 40 08 00 00 00 00 movl $0x0,0x8(%eax)
set_page_ref(p, 0);
104526: 83 ec 08 sub $0x8,%esp
104529: 6a 00 push $0x0
10452b: ff 75 e0 pushl -0x20(%ebp)
10452e: e8 c0 fd ff ff call 1042f3 <set_page_ref>
104533: 83 c4 10 add $0x10,%esp
page = p;
break;
}
}
if (page != NULL) {
for (int i = 1; i < n; ++ i) {
104536: 83 45 ec 01 addl $0x1,-0x14(%ebp)
10453a: 8b 45 ec mov -0x14(%ebp),%eax
10453d: 3b 45 08 cmp 0x8(%ebp),%eax
104540: 72 aa jb 1044ec <default_alloc_pages+0x8d>
// assert(!PageReserved(p));
ClearPageProperty(p);
p->property = 0;
set_page_ref(p, 0);
}
if (page->property > n) {
104542: 8b 45 f4 mov -0xc(%ebp),%eax
104545: 8b 40 08 mov 0x8(%eax),%eax
104548: 3b 45 08 cmp 0x8(%ebp),%eax
10454b: 0f 86 98 00 00 00 jbe 1045e9 <default_alloc_pages+0x18a>
struct Page *p = page + n;
104551: 8b 55 08 mov 0x8(%ebp),%edx
104554: 89 d0 mov %edx,%eax
104556: c1 e0 02 shl $0x2,%eax
104559: 01 d0 add %edx,%eax
10455b: c1 e0 02 shl $0x2,%eax
10455e: 89 c2 mov %eax,%edx
104560: 8b 45 f4 mov -0xc(%ebp),%eax
104563: 01 d0 add %edx,%eax
104565: 89 45 d8 mov %eax,-0x28(%ebp)
p->property = page->property - n;
104568: 8b 45 f4 mov -0xc(%ebp),%eax
10456b: 8b 40 08 mov 0x8(%eax),%eax
10456e: 2b 45 08 sub 0x8(%ebp),%eax
104571: 89 c2 mov %eax,%edx
104573: 8b 45 d8 mov -0x28(%ebp),%eax
104576: 89 50 08 mov %edx,0x8(%eax)
SetPageProperty(p);
104579: 8b 45 d8 mov -0x28(%ebp),%eax
10457c: 83 c0 04 add $0x4,%eax
10457f: c7 45 d0 01 00 00 00 movl $0x1,-0x30(%ebp)
104586: 89 45 a8 mov %eax,-0x58(%ebp)
* Note that @nr may be almost arbitrarily large; this function is not
* restricted to acting on a single-word quantity.
* */
static inline void
set_bit(int nr, volatile void *addr) {
asm volatile ("btsl %1, %0" :"=m" (*(volatile long *)addr) : "Ir" (nr));
104589: 8b 45 a8 mov -0x58(%ebp),%eax
10458c: 8b 55 d0 mov -0x30(%ebp),%edx
10458f: 0f ab 10 bts %edx,(%eax)
list_add(&(page->page_link), &(p->page_link));
104592: 8b 45 d8 mov -0x28(%ebp),%eax
104595: 83 c0 0c add $0xc,%eax
104598: 8b 55 f4 mov -0xc(%ebp),%edx
10459b: 83 c2 0c add $0xc,%edx
10459e: 89 55 dc mov %edx,-0x24(%ebp)
1045a1: 89 45 c0 mov %eax,-0x40(%ebp)
1045a4: 8b 45 dc mov -0x24(%ebp),%eax
1045a7: 89 45 bc mov %eax,-0x44(%ebp)
1045aa: 8b 45 c0 mov -0x40(%ebp),%eax
1045ad: 89 45 b8 mov %eax,-0x48(%ebp)
* Insert the new element @elm *after* the element @listelm which
* is already in the list.
* */
static inline void
list_add_after(list_entry_t *listelm, list_entry_t *elm) {
__list_add(elm, listelm, listelm->next);
1045b0: 8b 45 bc mov -0x44(%ebp),%eax
1045b3: 8b 40 04 mov 0x4(%eax),%eax
1045b6: 8b 55 b8 mov -0x48(%ebp),%edx
1045b9: 89 55 b4 mov %edx,-0x4c(%ebp)
1045bc: 8b 55 bc mov -0x44(%ebp),%edx
1045bf: 89 55 b0 mov %edx,-0x50(%ebp)
1045c2: 89 45 ac mov %eax,-0x54(%ebp)
* This is only for internal list manipulation where we know
* the prev/next entries already!
* */
static inline void
__list_add(list_entry_t *elm, list_entry_t *prev, list_entry_t *next) {
prev->next = next->prev = elm;
1045c5: 8b 45 ac mov -0x54(%ebp),%eax
1045c8: 8b 55 b4 mov -0x4c(%ebp),%edx
1045cb: 89 10 mov %edx,(%eax)
1045cd: 8b 45 ac mov -0x54(%ebp),%eax
1045d0: 8b 10 mov (%eax),%edx
1045d2: 8b 45 b0 mov -0x50(%ebp),%eax
1045d5: 89 50 04 mov %edx,0x4(%eax)
elm->next = next;
1045d8: 8b 45 b4 mov -0x4c(%ebp),%eax
1045db: 8b 55 ac mov -0x54(%ebp),%edx
1045de: 89 50 04 mov %edx,0x4(%eax)
elm->prev = prev;
1045e1: 8b 45 b4 mov -0x4c(%ebp),%eax
1045e4: 8b 55 b0 mov -0x50(%ebp),%edx
1045e7: 89 10 mov %edx,(%eax)
}
list_del(&(page->page_link));
1045e9: 8b 45 f4 mov -0xc(%ebp),%eax
1045ec: 83 c0 0c add $0xc,%eax
1045ef: 89 45 cc mov %eax,-0x34(%ebp)
* Note: list_empty() on @listelm does not return true after this, the entry is
* in an undefined state.
* */
static inline void
list_del(list_entry_t *listelm) {
__list_del(listelm->prev, listelm->next);
1045f2: 8b 45 cc mov -0x34(%ebp),%eax
1045f5: 8b 40 04 mov 0x4(%eax),%eax
1045f8: 8b 55 cc mov -0x34(%ebp),%edx
1045fb: 8b 12 mov (%edx),%edx
1045fd: 89 55 a0 mov %edx,-0x60(%ebp)
104600: 89 45 9c mov %eax,-0x64(%ebp)
* This is only for internal list manipulation where we know
* the prev/next entries already!
* */
static inline void
__list_del(list_entry_t *prev, list_entry_t *next) {
prev->next = next;
104603: 8b 45 a0 mov -0x60(%ebp),%eax
104606: 8b 55 9c mov -0x64(%ebp),%edx
104609: 89 50 04 mov %edx,0x4(%eax)
next->prev = prev;
10460c: 8b 45 9c mov -0x64(%ebp),%eax
10460f: 8b 55 a0 mov -0x60(%ebp),%edx
104612: 89 10 mov %edx,(%eax)
nr_free -= n;
104614: a1 70 a9 11 00 mov 0x11a970,%eax
104619: 2b 45 08 sub 0x8(%ebp),%eax
10461c: a3 70 a9 11 00 mov %eax,0x11a970
ClearPageProperty(page);
104621: 8b 45 f4 mov -0xc(%ebp),%eax
104624: 83 c0 04 add $0x4,%eax
104627: c7 45 d4 01 00 00 00 movl $0x1,-0x2c(%ebp)
10462e: 89 45 a4 mov %eax,-0x5c(%ebp)
* @nr: the bit to clear
* @addr: the address to start counting from
* */
static inline void
clear_bit(int nr, volatile void *addr) {
asm volatile ("btrl %1, %0" :"=m" (*(volatile long *)addr) : "Ir" (nr));
104631: 8b 45 a4 mov -0x5c(%ebp),%eax
104634: 8b 55 d4 mov -0x2c(%ebp),%edx
104637: 0f b3 10 btr %edx,(%eax)
}
return page;
10463a: 8b 45 f4 mov -0xc(%ebp),%eax
}
10463d: c9 leave
10463e: c3 ret
0010463f <default_free_pages>:
static void
default_free_pages(struct Page *base, size_t n) {
10463f: 55 push %ebp
104640: 89 e5 mov %esp,%ebp
104642: 81 ec 98 00 00 00 sub $0x98,%esp
assert(n > 0);
104648: 83 7d 0c 00 cmpl $0x0,0xc(%ebp)
10464c: 75 16 jne 104664 <default_free_pages+0x25>
10464e: 68 88 77 10 00 push $0x107788
104653: 68 8e 77 10 00 push $0x10778e
104658: 6a 7c push $0x7c
10465a: 68 a3 77 10 00 push $0x1077a3
10465f: e8 69 bd ff ff call 1003cd <__panic>
struct Page *p = base;
104664: 8b 45 08 mov 0x8(%ebp),%eax
104667: 89 45 f4 mov %eax,-0xc(%ebp)
for (; p != base + n; p ++) {
10466a: e9 8c 00 00 00 jmp 1046fb <default_free_pages+0xbc>
assert(!PageReserved(p) && !PageProperty(p));
10466f: 8b 45 f4 mov -0xc(%ebp),%eax
104672: 83 c0 04 add $0x4,%eax
104675: c7 45 bc 00 00 00 00 movl $0x0,-0x44(%ebp)
10467c: 89 45 b8 mov %eax,-0x48(%ebp)
* @addr: the address to count from
* */
static inline bool
test_bit(int nr, volatile void *addr) {
int oldbit;
asm volatile ("btl %2, %1; sbbl %0,%0" : "=r" (oldbit) : "m" (*(volatile long *)addr), "Ir" (nr));
10467f: 8b 45 b8 mov -0x48(%ebp),%eax
104682: 8b 55 bc mov -0x44(%ebp),%edx
104685: 0f a3 10 bt %edx,(%eax)
104688: 19 c0 sbb %eax,%eax
10468a: 89 45 b4 mov %eax,-0x4c(%ebp)
return oldbit != 0;
10468d: 83 7d b4 00 cmpl $0x0,-0x4c(%ebp)
104691: 0f 95 c0 setne %al
104694: 0f b6 c0 movzbl %al,%eax
104697: 85 c0 test %eax,%eax
104699: 75 2c jne 1046c7 <default_free_pages+0x88>
10469b: 8b 45 f4 mov -0xc(%ebp),%eax
10469e: 83 c0 04 add $0x4,%eax
1046a1: c7 45 e4 01 00 00 00 movl $0x1,-0x1c(%ebp)
1046a8: 89 45 b0 mov %eax,-0x50(%ebp)
* @addr: the address to count from
* */
static inline bool
test_bit(int nr, volatile void *addr) {
int oldbit;
asm volatile ("btl %2, %1; sbbl %0,%0" : "=r" (oldbit) : "m" (*(volatile long *)addr), "Ir" (nr));
1046ab: 8b 45 b0 mov -0x50(%ebp),%eax
1046ae: 8b 55 e4 mov -0x1c(%ebp),%edx
1046b1: 0f a3 10 bt %edx,(%eax)
1046b4: 19 c0 sbb %eax,%eax
1046b6: 89 45 ac mov %eax,-0x54(%ebp)
return oldbit != 0;
1046b9: 83 7d ac 00 cmpl $0x0,-0x54(%ebp)
1046bd: 0f 95 c0 setne %al
1046c0: 0f b6 c0 movzbl %al,%eax
1046c3: 85 c0 test %eax,%eax
1046c5: 74 16 je 1046dd <default_free_pages+0x9e>
1046c7: 68 cc 77 10 00 push $0x1077cc
1046cc: 68 8e 77 10 00 push $0x10778e
1046d1: 6a 7f push $0x7f
1046d3: 68 a3 77 10 00 push $0x1077a3
1046d8: e8 f0 bc ff ff call 1003cd <__panic>
p->flags = 0;
1046dd: 8b 45 f4 mov -0xc(%ebp),%eax
1046e0: c7 40 04 00 00 00 00 movl $0x0,0x4(%eax)
set_page_ref(p, 0);
1046e7: 83 ec 08 sub $0x8,%esp
1046ea: 6a 00 push $0x0
1046ec: ff 75 f4 pushl -0xc(%ebp)
1046ef: e8 ff fb ff ff call 1042f3 <set_page_ref>
1046f4: 83 c4 10 add $0x10,%esp
static void
default_free_pages(struct Page *base, size_t n) {
assert(n > 0);
struct Page *p = base;
for (; p != base + n; p ++) {
1046f7: 83 45 f4 14 addl $0x14,-0xc(%ebp)
1046fb: 8b 55 0c mov 0xc(%ebp),%edx
1046fe: 89 d0 mov %edx,%eax
104700: c1 e0 02 shl $0x2,%eax
104703: 01 d0 add %edx,%eax
104705: c1 e0 02 shl $0x2,%eax
104708: 89 c2 mov %eax,%edx
10470a: 8b 45 08 mov 0x8(%ebp),%eax
10470d: 01 d0 add %edx,%eax
10470f: 3b 45 f4 cmp -0xc(%ebp),%eax
104712: 0f 85 57 ff ff ff jne 10466f <default_free_pages+0x30>
assert(!PageReserved(p) && !PageProperty(p));
p->flags = 0;
set_page_ref(p, 0);
}
base->property = n;
104718: 8b 45 08 mov 0x8(%ebp),%eax
10471b: 8b 55 0c mov 0xc(%ebp),%edx
10471e: 89 50 08 mov %edx,0x8(%eax)
SetPageProperty(base);
104721: 8b 45 08 mov 0x8(%ebp),%eax
104724: 83 c0 04 add $0x4,%eax
104727: c7 45 d8 01 00 00 00 movl $0x1,-0x28(%ebp)
10472e: 89 45 a8 mov %eax,-0x58(%ebp)
* Note that @nr may be almost arbitrarily large; this function is not
* restricted to acting on a single-word quantity.
* */
static inline void
set_bit(int nr, volatile void *addr) {
asm volatile ("btsl %1, %0" :"=m" (*(volatile long *)addr) : "Ir" (nr));
104731: 8b 45 a8 mov -0x58(%ebp),%eax
104734: 8b 55 d8 mov -0x28(%ebp),%edx
104737: 0f ab 10 bts %edx,(%eax)
10473a: c7 45 e0 68 a9 11 00 movl $0x11a968,-0x20(%ebp)
* list_next - get the next entry
* @listelm: the list head
**/
static inline list_entry_t *
list_next(list_entry_t *listelm) {
return listelm->next;
104741: 8b 45 e0 mov -0x20(%ebp),%eax
104744: 8b 40 04 mov 0x4(%eax),%eax
list_entry_t *le = list_next(&free_list);
104747: 89 45 f0 mov %eax,-0x10(%ebp)
struct Page *merge_previous = NULL;
10474a: c7 45 ec 00 00 00 00 movl $0x0,-0x14(%ebp)
struct Page *merge_next = NULL;
104751: c7 45 e8 00 00 00 00 movl $0x0,-0x18(%ebp)
while (le != &free_list) {
104758: eb 66 jmp 1047c0 <default_free_pages+0x181>
p = le2page(le, page_link);
10475a: 8b 45 f0 mov -0x10(%ebp),%eax
10475d: 83 e8 0c sub $0xc,%eax
104760: 89 45 f4 mov %eax,-0xc(%ebp)
104763: 8b 45 f0 mov -0x10(%ebp),%eax
104766: 89 45 dc mov %eax,-0x24(%ebp)
104769: 8b 45 dc mov -0x24(%ebp),%eax
10476c: 8b 40 04 mov 0x4(%eax),%eax
le = list_next(le);
10476f: 89 45 f0 mov %eax,-0x10(%ebp)
if (base + base->property == p) {
104772: 8b 45 08 mov 0x8(%ebp),%eax
104775: 8b 50 08 mov 0x8(%eax),%edx
104778: 89 d0 mov %edx,%eax
10477a: c1 e0 02 shl $0x2,%eax
10477d: 01 d0 add %edx,%eax
10477f: c1 e0 02 shl $0x2,%eax
104782: 89 c2 mov %eax,%edx
104784: 8b 45 08 mov 0x8(%ebp),%eax
104787: 01 d0 add %edx,%eax
104789: 3b 45 f4 cmp -0xc(%ebp),%eax
10478c: 75 08 jne 104796 <default_free_pages+0x157>
merge_next = p;
10478e: 8b 45 f4 mov -0xc(%ebp),%eax
104791: 89 45 e8 mov %eax,-0x18(%ebp)
break;
104794: eb 36 jmp 1047cc <default_free_pages+0x18d>
}
else if (p + p->property == base) {
104796: 8b 45 f4 mov -0xc(%ebp),%eax
104799: 8b 50 08 mov 0x8(%eax),%edx
10479c: 89 d0 mov %edx,%eax
10479e: c1 e0 02 shl $0x2,%eax
1047a1: 01 d0 add %edx,%eax
1047a3: c1 e0 02 shl $0x2,%eax
1047a6: 89 c2 mov %eax,%edx
1047a8: 8b 45 f4 mov -0xc(%ebp),%eax
1047ab: 01 d0 add %edx,%eax
1047ad: 3b 45 08 cmp 0x8(%ebp),%eax
1047b0: 75 06 jne 1047b8 <default_free_pages+0x179>
merge_previous = p;
1047b2: 8b 45 f4 mov -0xc(%ebp),%eax
1047b5: 89 45 ec mov %eax,-0x14(%ebp)
}
if (p > base) break;
1047b8: 8b 45 f4 mov -0xc(%ebp),%eax
1047bb: 3b 45 08 cmp 0x8(%ebp),%eax
1047be: 77 0b ja 1047cb <default_free_pages+0x18c>
base->property = n;
SetPageProperty(base);
list_entry_t *le = list_next(&free_list);
struct Page *merge_previous = NULL;
struct Page *merge_next = NULL;
while (le != &free_list) {
1047c0: 81 7d f0 68 a9 11 00 cmpl $0x11a968,-0x10(%ebp)
1047c7: 75 91 jne 10475a <default_free_pages+0x11b>
1047c9: eb 01 jmp 1047cc <default_free_pages+0x18d>
break;
}
else if (p + p->property == base) {
merge_previous = p;
}
if (p > base) break;
1047cb: 90 nop
}
nr_free += n;
1047cc: 8b 15 70 a9 11 00 mov 0x11a970,%edx
1047d2: 8b 45 0c mov 0xc(%ebp),%eax
1047d5: 01 d0 add %edx,%eax
1047d7: a3 70 a9 11 00 mov %eax,0x11a970
// Try to merge base with merge_previous and merge_next.
if (merge_previous != NULL) {
1047dc: 83 7d ec 00 cmpl $0x0,-0x14(%ebp)
1047e0: 74 33 je 104815 <default_free_pages+0x1d6>
merge_previous->property += base->property;
1047e2: 8b 45 ec mov -0x14(%ebp),%eax
1047e5: 8b 50 08 mov 0x8(%eax),%edx
1047e8: 8b 45 08 mov 0x8(%ebp),%eax
1047eb: 8b 40 08 mov 0x8(%eax),%eax
1047ee: 01 c2 add %eax,%edx
1047f0: 8b 45 ec mov -0x14(%ebp),%eax
1047f3: 89 50 08 mov %edx,0x8(%eax)
ClearPageProperty(base);
1047f6: 8b 45 08 mov 0x8(%ebp),%eax
1047f9: 83 c0 04 add $0x4,%eax
1047fc: c7 45 d4 01 00 00 00 movl $0x1,-0x2c(%ebp)
104803: 89 45 a4 mov %eax,-0x5c(%ebp)
* @nr: the bit to clear
* @addr: the address to start counting from
* */
static inline void
clear_bit(int nr, volatile void *addr) {
asm volatile ("btrl %1, %0" :"=m" (*(volatile long *)addr) : "Ir" (nr));
104806: 8b 45 a4 mov -0x5c(%ebp),%eax
104809: 8b 55 d4 mov -0x2c(%ebp),%edx
10480c: 0f b3 10 btr %edx,(%eax)
base = merge_previous;
10480f: 8b 45 ec mov -0x14(%ebp),%eax
104812: 89 45 08 mov %eax,0x8(%ebp)
}
if (merge_next != NULL) {
104815: 83 7d e8 00 cmpl $0x0,-0x18(%ebp)
104819: 0f 84 a8 00 00 00 je 1048c7 <default_free_pages+0x288>
base->property += merge_next->property;
10481f: 8b 45 08 mov 0x8(%ebp),%eax
104822: 8b 50 08 mov 0x8(%eax),%edx
104825: 8b 45 e8 mov -0x18(%ebp),%eax
104828: 8b 40 08 mov 0x8(%eax),%eax
10482b: 01 c2 add %eax,%edx
10482d: 8b 45 08 mov 0x8(%ebp),%eax
104830: 89 50 08 mov %edx,0x8(%eax)
ClearPageProperty(merge_next);
104833: 8b 45 e8 mov -0x18(%ebp),%eax
104836: 83 c0 04 add $0x4,%eax
104839: c7 45 d0 01 00 00 00 movl $0x1,-0x30(%ebp)
104840: 89 45 a0 mov %eax,-0x60(%ebp)
104843: 8b 45 a0 mov -0x60(%ebp),%eax
104846: 8b 55 d0 mov -0x30(%ebp),%edx
104849: 0f b3 10 btr %edx,(%eax)
if (merge_previous == NULL) {
10484c: 83 7d ec 00 cmpl $0x0,-0x14(%ebp)
104850: 75 4a jne 10489c <default_free_pages+0x25d>
list_add_before(&(merge_next->page_link), &(base->page_link));
104852: 8b 45 08 mov 0x8(%ebp),%eax
104855: 83 c0 0c add $0xc,%eax
104858: 8b 55 e8 mov -0x18(%ebp),%edx
10485b: 83 c2 0c add $0xc,%edx
10485e: 89 55 cc mov %edx,-0x34(%ebp)
104861: 89 45 9c mov %eax,-0x64(%ebp)
* Insert the new element @elm *before* the element @listelm which
* is already in the list.
* */
static inline void
list_add_before(list_entry_t *listelm, list_entry_t *elm) {
__list_add(elm, listelm->prev, listelm);
104864: 8b 45 cc mov -0x34(%ebp),%eax
104867: 8b 00 mov (%eax),%eax
104869: 8b 55 9c mov -0x64(%ebp),%edx
10486c: 89 55 98 mov %edx,-0x68(%ebp)
10486f: 89 45 94 mov %eax,-0x6c(%ebp)
104872: 8b 45 cc mov -0x34(%ebp),%eax
104875: 89 45 90 mov %eax,-0x70(%ebp)
* This is only for internal list manipulation where we know
* the prev/next entries already!
* */
static inline void
__list_add(list_entry_t *elm, list_entry_t *prev, list_entry_t *next) {
prev->next = next->prev = elm;
104878: 8b 45 90 mov -0x70(%ebp),%eax
10487b: 8b 55 98 mov -0x68(%ebp),%edx
10487e: 89 10 mov %edx,(%eax)
104880: 8b 45 90 mov -0x70(%ebp),%eax
104883: 8b 10 mov (%eax),%edx
104885: 8b 45 94 mov -0x6c(%ebp),%eax
104888: 89 50 04 mov %edx,0x4(%eax)
elm->next = next;
10488b: 8b 45 98 mov -0x68(%ebp),%eax
10488e: 8b 55 90 mov -0x70(%ebp),%edx
104891: 89 50 04 mov %edx,0x4(%eax)
elm->prev = prev;
104894: 8b 45 98 mov -0x68(%ebp),%eax
104897: 8b 55 94 mov -0x6c(%ebp),%edx
10489a: 89 10 mov %edx,(%eax)
}
list_del(&(merge_next->page_link));
10489c: 8b 45 e8 mov -0x18(%ebp),%eax
10489f: 83 c0 0c add $0xc,%eax
1048a2: 89 45 c8 mov %eax,-0x38(%ebp)
* Note: list_empty() on @listelm does not return true after this, the entry is
* in an undefined state.
* */
static inline void
list_del(list_entry_t *listelm) {
__list_del(listelm->prev, listelm->next);
1048a5: 8b 45 c8 mov -0x38(%ebp),%eax
1048a8: 8b 40 04 mov 0x4(%eax),%eax
1048ab: 8b 55 c8 mov -0x38(%ebp),%edx
1048ae: 8b 12 mov (%edx),%edx
1048b0: 89 55 8c mov %edx,-0x74(%ebp)
1048b3: 89 45 88 mov %eax,-0x78(%ebp)
* This is only for internal list manipulation where we know
* the prev/next entries already!
* */
static inline void
__list_del(list_entry_t *prev, list_entry_t *next) {
prev->next = next;
1048b6: 8b 45 8c mov -0x74(%ebp),%eax
1048b9: 8b 55 88 mov -0x78(%ebp),%edx
1048bc: 89 50 04 mov %edx,0x4(%eax)
next->prev = prev;
1048bf: 8b 45 88 mov -0x78(%ebp),%eax
1048c2: 8b 55 8c mov -0x74(%ebp),%edx
1048c5: 89 10 mov %edx,(%eax)
}
if (merge_next == NULL && merge_previous == NULL) {
1048c7: 83 7d e8 00 cmpl $0x0,-0x18(%ebp)
1048cb: 0f 85 fc 00 00 00 jne 1049cd <default_free_pages+0x38e>
1048d1: 83 7d ec 00 cmpl $0x0,-0x14(%ebp)
1048d5: 0f 85 f2 00 00 00 jne 1049cd <default_free_pages+0x38e>
if (p > base && p != (base + n)) {
1048db: 8b 45 f4 mov -0xc(%ebp),%eax
1048de: 3b 45 08 cmp 0x8(%ebp),%eax
1048e1: 76 7b jbe 10495e <default_free_pages+0x31f>
1048e3: 8b 55 0c mov 0xc(%ebp),%edx
1048e6: 89 d0 mov %edx,%eax
1048e8: c1 e0 02 shl $0x2,%eax
1048eb: 01 d0 add %edx,%eax
1048ed: c1 e0 02 shl $0x2,%eax
1048f0: 89 c2 mov %eax,%edx
1048f2: 8b 45 08 mov 0x8(%ebp),%eax
1048f5: 01 d0 add %edx,%eax
1048f7: 3b 45 f4 cmp -0xc(%ebp),%eax
1048fa: 74 62 je 10495e <default_free_pages+0x31f>
list_add_before(&(p->page_link), &(base->page_link));
1048fc: 8b 45 08 mov 0x8(%ebp),%eax
1048ff: 83 c0 0c add $0xc,%eax
104902: 8b 55 f4 mov -0xc(%ebp),%edx
104905: 83 c2 0c add $0xc,%edx
104908: 89 55 c4 mov %edx,-0x3c(%ebp)
10490b: 89 45 84 mov %eax,-0x7c(%ebp)
* Insert the new element @elm *before* the element @listelm which
* is already in the list.
* */
static inline void
list_add_before(list_entry_t *listelm, list_entry_t *elm) {
__list_add(elm, listelm->prev, listelm);
10490e: 8b 45 c4 mov -0x3c(%ebp),%eax
104911: 8b 00 mov (%eax),%eax
104913: 8b 55 84 mov -0x7c(%ebp),%edx
104916: 89 55 80 mov %edx,-0x80(%ebp)
104919: 89 85 7c ff ff ff mov %eax,-0x84(%ebp)
10491f: 8b 45 c4 mov -0x3c(%ebp),%eax
104922: 89 85 78 ff ff ff mov %eax,-0x88(%ebp)
* This is only for internal list manipulation where we know
* the prev/next entries already!
* */
static inline void
__list_add(list_entry_t *elm, list_entry_t *prev, list_entry_t *next) {
prev->next = next->prev = elm;
104928: 8b 85 78 ff ff ff mov -0x88(%ebp),%eax
10492e: 8b 55 80 mov -0x80(%ebp),%edx
104931: 89 10 mov %edx,(%eax)
104933: 8b 85 78 ff ff ff mov -0x88(%ebp),%eax
104939: 8b 10 mov (%eax),%edx
10493b: 8b 85 7c ff ff ff mov -0x84(%ebp),%eax
104941: 89 50 04 mov %edx,0x4(%eax)
elm->next = next;
104944: 8b 45 80 mov -0x80(%ebp),%eax
104947: 8b 95 78 ff ff ff mov -0x88(%ebp),%edx
10494d: 89 50 04 mov %edx,0x4(%eax)
elm->prev = prev;
104950: 8b 45 80 mov -0x80(%ebp),%eax
104953: 8b 95 7c ff ff ff mov -0x84(%ebp),%edx
104959: 89 10 mov %edx,(%eax)
10495b: 90 nop
} else {
list_add_before(&free_list, &(base->page_link));
}
}
}
10495c: eb 6f jmp 1049cd <default_free_pages+0x38e>
}
if (merge_next == NULL && merge_previous == NULL) {
if (p > base && p != (base + n)) {
list_add_before(&(p->page_link), &(base->page_link));
} else {
list_add_before(&free_list, &(base->page_link));
10495e: 8b 45 08 mov 0x8(%ebp),%eax
104961: 83 c0 0c add $0xc,%eax
104964: c7 45 c0 68 a9 11 00 movl $0x11a968,-0x40(%ebp)
10496b: 89 85 74 ff ff ff mov %eax,-0x8c(%ebp)
* Insert the new element @elm *before* the element @listelm which
* is already in the list.
* */
static inline void
list_add_before(list_entry_t *listelm, list_entry_t *elm) {
__list_add(elm, listelm->prev, listelm);
104971: 8b 45 c0 mov -0x40(%ebp),%eax
104974: 8b 00 mov (%eax),%eax
104976: 8b 95 74 ff ff ff mov -0x8c(%ebp),%edx
10497c: 89 95 70 ff ff ff mov %edx,-0x90(%ebp)
104982: 89 85 6c ff ff ff mov %eax,-0x94(%ebp)
104988: 8b 45 c0 mov -0x40(%ebp),%eax
10498b: 89 85 68 ff ff ff mov %eax,-0x98(%ebp)
* This is only for internal list manipulation where we know
* the prev/next entries already!
* */
static inline void
__list_add(list_entry_t *elm, list_entry_t *prev, list_entry_t *next) {
prev->next = next->prev = elm;
104991: 8b 85 68 ff ff ff mov -0x98(%ebp),%eax
104997: 8b 95 70 ff ff ff mov -0x90(%ebp),%edx
10499d: 89 10 mov %edx,(%eax)
10499f: 8b 85 68 ff ff ff mov -0x98(%ebp),%eax
1049a5: 8b 10 mov (%eax),%edx
1049a7: 8b 85 6c ff ff ff mov -0x94(%ebp),%eax
1049ad: 89 50 04 mov %edx,0x4(%eax)
elm->next = next;
1049b0: 8b 85 70 ff ff ff mov -0x90(%ebp),%eax
1049b6: 8b 95 68 ff ff ff mov -0x98(%ebp),%edx
1049bc: 89 50 04 mov %edx,0x4(%eax)
elm->prev = prev;
1049bf: 8b 85 70 ff ff ff mov -0x90(%ebp),%eax
1049c5: 8b 95 6c ff ff ff mov -0x94(%ebp),%edx
1049cb: 89 10 mov %edx,(%eax)
}
}
}
1049cd: 90 nop
1049ce: c9 leave
1049cf: c3 ret
001049d0 <default_nr_free_pages>:
static size_t
default_nr_free_pages(void) {
1049d0: 55 push %ebp
1049d1: 89 e5 mov %esp,%ebp
return nr_free;
1049d3: a1 70 a9 11 00 mov 0x11a970,%eax
}
1049d8: 5d pop %ebp
1049d9: c3 ret
001049da <basic_check>:
cprintf("+ 1 = %x, 1.next = %x, prev = %x\n", &(p2->page_link), p2->page_link.next, p2->page_link.prev);
cprintf("+ 2 = %x, 2.next = %x, prev = %x\n", &(p3->page_link), p3->page_link.next, p3->page_link.prev);
}
*/
static void
basic_check(void) {
1049da: 55 push %ebp
1049db: 89 e5 mov %esp,%ebp
1049dd: 83 ec 38 sub $0x38,%esp
struct Page *p0, *p1, *p2;
p0 = p1 = p2 = NULL;
1049e0: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp)
1049e7: 8b 45 f4 mov -0xc(%ebp),%eax
1049ea: 89 45 f0 mov %eax,-0x10(%ebp)
1049ed: 8b 45 f0 mov -0x10(%ebp),%eax
1049f0: 89 45 ec mov %eax,-0x14(%ebp)
assert((p0 = alloc_page()) != NULL);
1049f3: 83 ec 0c sub $0xc,%esp
1049f6: 6a 01 push $0x1
1049f8: e8 72 e3 ff ff call 102d6f <alloc_pages>
1049fd: 83 c4 10 add $0x10,%esp
104a00: 89 45 ec mov %eax,-0x14(%ebp)
104a03: 83 7d ec 00 cmpl $0x0,-0x14(%ebp)
104a07: 75 19 jne 104a22 <basic_check+0x48>
104a09: 68 f1 77 10 00 push $0x1077f1
104a0e: 68 8e 77 10 00 push $0x10778e
104a13: 68 be 00 00 00 push $0xbe
104a18: 68 a3 77 10 00 push $0x1077a3
104a1d: e8 ab b9 ff ff call 1003cd <__panic>
assert((p1 = alloc_page()) != NULL);
104a22: 83 ec 0c sub $0xc,%esp
104a25: 6a 01 push $0x1
104a27: e8 43 e3 ff ff call 102d6f <alloc_pages>
104a2c: 83 c4 10 add $0x10,%esp
104a2f: 89 45 f0 mov %eax,-0x10(%ebp)
104a32: 83 7d f0 00 cmpl $0x0,-0x10(%ebp)
104a36: 75 19 jne 104a51 <basic_check+0x77>
104a38: 68 0d 78 10 00 push $0x10780d
104a3d: 68 8e 77 10 00 push $0x10778e
104a42: 68 bf 00 00 00 push $0xbf
104a47: 68 a3 77 10 00 push $0x1077a3
104a4c: e8 7c b9 ff ff call 1003cd <__panic>
assert((p2 = alloc_page()) != NULL);
104a51: 83 ec 0c sub $0xc,%esp
104a54: 6a 01 push $0x1
104a56: e8 14 e3 ff ff call 102d6f <alloc_pages>
104a5b: 83 c4 10 add $0x10,%esp
104a5e: 89 45 f4 mov %eax,-0xc(%ebp)
104a61: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
104a65: 75 19 jne 104a80 <basic_check+0xa6>
104a67: 68 29 78 10 00 push $0x107829
104a6c: 68 8e 77 10 00 push $0x10778e
104a71: 68 c0 00 00 00 push $0xc0
104a76: 68 a3 77 10 00 push $0x1077a3
104a7b: e8 4d b9 ff ff call 1003cd <__panic>
assert(p0 != p1 && p0 != p2 && p1 != p2);
104a80: 8b 45 ec mov -0x14(%ebp),%eax
104a83: 3b 45 f0 cmp -0x10(%ebp),%eax
104a86: 74 10 je 104a98 <basic_check+0xbe>
104a88: 8b 45 ec mov -0x14(%ebp),%eax
104a8b: 3b 45 f4 cmp -0xc(%ebp),%eax
104a8e: 74 08 je 104a98 <basic_check+0xbe>
104a90: 8b 45 f0 mov -0x10(%ebp),%eax
104a93: 3b 45 f4 cmp -0xc(%ebp),%eax
104a96: 75 19 jne 104ab1 <basic_check+0xd7>
104a98: 68 48 78 10 00 push $0x107848
104a9d: 68 8e 77 10 00 push $0x10778e
104aa2: 68 c2 00 00 00 push $0xc2
104aa7: 68 a3 77 10 00 push $0x1077a3
104aac: e8 1c b9 ff ff call 1003cd <__panic>
assert(page_ref(p0) == 0 && page_ref(p1) == 0 && page_ref(p2) == 0);
104ab1: 83 ec 0c sub $0xc,%esp
104ab4: ff 75 ec pushl -0x14(%ebp)
104ab7: e8 2d f8 ff ff call 1042e9 <page_ref>
104abc: 83 c4 10 add $0x10,%esp
104abf: 85 c0 test %eax,%eax
104ac1: 75 24 jne 104ae7 <basic_check+0x10d>
104ac3: 83 ec 0c sub $0xc,%esp
104ac6: ff 75 f0 pushl -0x10(%ebp)
104ac9: e8 1b f8 ff ff call 1042e9 <page_ref>
104ace: 83 c4 10 add $0x10,%esp
104ad1: 85 c0 test %eax,%eax
104ad3: 75 12 jne 104ae7 <basic_check+0x10d>
104ad5: 83 ec 0c sub $0xc,%esp
104ad8: ff 75 f4 pushl -0xc(%ebp)
104adb: e8 09 f8 ff ff call 1042e9 <page_ref>
104ae0: 83 c4 10 add $0x10,%esp
104ae3: 85 c0 test %eax,%eax
104ae5: 74 19 je 104b00 <basic_check+0x126>
104ae7: 68 6c 78 10 00 push $0x10786c
104aec: 68 8e 77 10 00 push $0x10778e
104af1: 68 c3 00 00 00 push $0xc3
104af6: 68 a3 77 10 00 push $0x1077a3
104afb: e8 cd b8 ff ff call 1003cd <__panic>
assert(page2pa(p0) < npage * PGSIZE);
104b00: 83 ec 0c sub $0xc,%esp
104b03: ff 75 ec pushl -0x14(%ebp)
104b06: e8 cb f7 ff ff call 1042d6 <page2pa>
104b0b: 83 c4 10 add $0x10,%esp
104b0e: 89 c2 mov %eax,%edx
104b10: a1 c0 a8 11 00 mov 0x11a8c0,%eax
104b15: c1 e0 0c shl $0xc,%eax
104b18: 39 c2 cmp %eax,%edx
104b1a: 72 19 jb 104b35 <basic_check+0x15b>
104b1c: 68 a8 78 10 00 push $0x1078a8
104b21: 68 8e 77 10 00 push $0x10778e
104b26: 68 c5 00 00 00 push $0xc5
104b2b: 68 a3 77 10 00 push $0x1077a3
104b30: e8 98 b8 ff ff call 1003cd <__panic>
assert(page2pa(p1) < npage * PGSIZE);
104b35: 83 ec 0c sub $0xc,%esp
104b38: ff 75 f0 pushl -0x10(%ebp)
104b3b: e8 96 f7 ff ff call 1042d6 <page2pa>
104b40: 83 c4 10 add $0x10,%esp
104b43: 89 c2 mov %eax,%edx
104b45: a1 c0 a8 11 00 mov 0x11a8c0,%eax
104b4a: c1 e0 0c shl $0xc,%eax
104b4d: 39 c2 cmp %eax,%edx
104b4f: 72 19 jb 104b6a <basic_check+0x190>
104b51: 68 c5 78 10 00 push $0x1078c5
104b56: 68 8e 77 10 00 push $0x10778e
104b5b: 68 c6 00 00 00 push $0xc6
104b60: 68 a3 77 10 00 push $0x1077a3
104b65: e8 63 b8 ff ff call 1003cd <__panic>
assert(page2pa(p2) < npage * PGSIZE);
104b6a: 83 ec 0c sub $0xc,%esp
104b6d: ff 75 f4 pushl -0xc(%ebp)
104b70: e8 61 f7 ff ff call 1042d6 <page2pa>
104b75: 83 c4 10 add $0x10,%esp
104b78: 89 c2 mov %eax,%edx
104b7a: a1 c0 a8 11 00 mov 0x11a8c0,%eax
104b7f: c1 e0 0c shl $0xc,%eax
104b82: 39 c2 cmp %eax,%edx
104b84: 72 19 jb 104b9f <basic_check+0x1c5>
104b86: 68 e2 78 10 00 push $0x1078e2
104b8b: 68 8e 77 10 00 push $0x10778e
104b90: 68 c7 00 00 00 push $0xc7
104b95: 68 a3 77 10 00 push $0x1077a3
104b9a: e8 2e b8 ff ff call 1003cd <__panic>
list_entry_t free_list_store = free_list;
104b9f: a1 68 a9 11 00 mov 0x11a968,%eax
104ba4: 8b 15 6c a9 11 00 mov 0x11a96c,%edx
104baa: 89 45 d0 mov %eax,-0x30(%ebp)
104bad: 89 55 d4 mov %edx,-0x2c(%ebp)
104bb0: c7 45 e4 68 a9 11 00 movl $0x11a968,-0x1c(%ebp)
* list_init - initialize a new entry
* @elm: new entry to be initialized
* */
static inline void
list_init(list_entry_t *elm) {
elm->prev = elm->next = elm;
104bb7: 8b 45 e4 mov -0x1c(%ebp),%eax
104bba: 8b 55 e4 mov -0x1c(%ebp),%edx
104bbd: 89 50 04 mov %edx,0x4(%eax)
104bc0: 8b 45 e4 mov -0x1c(%ebp),%eax
104bc3: 8b 50 04 mov 0x4(%eax),%edx
104bc6: 8b 45 e4 mov -0x1c(%ebp),%eax
104bc9: 89 10 mov %edx,(%eax)
104bcb: c7 45 d8 68 a9 11 00 movl $0x11a968,-0x28(%ebp)
* list_empty - tests whether a list is empty
* @list: the list to test.
* */
static inline bool
list_empty(list_entry_t *list) {
return list->next == list;
104bd2: 8b 45 d8 mov -0x28(%ebp),%eax
104bd5: 8b 40 04 mov 0x4(%eax),%eax
104bd8: 39 45 d8 cmp %eax,-0x28(%ebp)
104bdb: 0f 94 c0 sete %al
104bde: 0f b6 c0 movzbl %al,%eax
list_init(&free_list);
assert(list_empty(&free_list));
104be1: 85 c0 test %eax,%eax
104be3: 75 19 jne 104bfe <basic_check+0x224>
104be5: 68 ff 78 10 00 push $0x1078ff
104bea: 68 8e 77 10 00 push $0x10778e
104bef: 68 cb 00 00 00 push $0xcb
104bf4: 68 a3 77 10 00 push $0x1077a3
104bf9: e8 cf b7 ff ff call 1003cd <__panic>
unsigned int nr_free_store = nr_free;
104bfe: a1 70 a9 11 00 mov 0x11a970,%eax
104c03: 89 45 e0 mov %eax,-0x20(%ebp)
nr_free = 0;
104c06: c7 05 70 a9 11 00 00 movl $0x0,0x11a970
104c0d: 00 00 00
assert(alloc_page() == NULL);
104c10: 83 ec 0c sub $0xc,%esp
104c13: 6a 01 push $0x1
104c15: e8 55 e1 ff ff call 102d6f <alloc_pages>
104c1a: 83 c4 10 add $0x10,%esp
104c1d: 85 c0 test %eax,%eax
104c1f: 74 19 je 104c3a <basic_check+0x260>
104c21: 68 16 79 10 00 push $0x107916
104c26: 68 8e 77 10 00 push $0x10778e
104c2b: 68 d0 00 00 00 push $0xd0
104c30: 68 a3 77 10 00 push $0x1077a3
104c35: e8 93 b7 ff ff call 1003cd <__panic>
free_page(p0);
104c3a: 83 ec 08 sub $0x8,%esp
104c3d: 6a 01 push $0x1
104c3f: ff 75 ec pushl -0x14(%ebp)
104c42: e8 66 e1 ff ff call 102dad <free_pages>
104c47: 83 c4 10 add $0x10,%esp
free_page(p1);
104c4a: 83 ec 08 sub $0x8,%esp
104c4d: 6a 01 push $0x1
104c4f: ff 75 f0 pushl -0x10(%ebp)
104c52: e8 56 e1 ff ff call 102dad <free_pages>
104c57: 83 c4 10 add $0x10,%esp
free_page(p2);
104c5a: 83 ec 08 sub $0x8,%esp
104c5d: 6a 01 push $0x1
104c5f: ff 75 f4 pushl -0xc(%ebp)
104c62: e8 46 e1 ff ff call 102dad <free_pages>
104c67: 83 c4 10 add $0x10,%esp
assert(nr_free == 3);
104c6a: a1 70 a9 11 00 mov 0x11a970,%eax
104c6f: 83 f8 03 cmp $0x3,%eax
104c72: 74 19 je 104c8d <basic_check+0x2b3>
104c74: 68 2b 79 10 00 push $0x10792b
104c79: 68 8e 77 10 00 push $0x10778e
104c7e: 68 d4 00 00 00 push $0xd4
104c83: 68 a3 77 10 00 push $0x1077a3
104c88: e8 40 b7 ff ff call 1003cd <__panic>
assert((p0 = alloc_page()) != NULL);
104c8d: 83 ec 0c sub $0xc,%esp
104c90: 6a 01 push $0x1
104c92: e8 d8 e0 ff ff call 102d6f <alloc_pages>
104c97: 83 c4 10 add $0x10,%esp
104c9a: 89 45 ec mov %eax,-0x14(%ebp)
104c9d: 83 7d ec 00 cmpl $0x0,-0x14(%ebp)
104ca1: 75 19 jne 104cbc <basic_check+0x2e2>
104ca3: 68 f1 77 10 00 push $0x1077f1
104ca8: 68 8e 77 10 00 push $0x10778e
104cad: 68 d5 00 00 00 push $0xd5
104cb2: 68 a3 77 10 00 push $0x1077a3
104cb7: e8 11 b7 ff ff call 1003cd <__panic>
assert((p1 = alloc_page()) != NULL);
104cbc: 83 ec 0c sub $0xc,%esp
104cbf: 6a 01 push $0x1
104cc1: e8 a9 e0 ff ff call 102d6f <alloc_pages>
104cc6: 83 c4 10 add $0x10,%esp
104cc9: 89 45 f0 mov %eax,-0x10(%ebp)
104ccc: 83 7d f0 00 cmpl $0x0,-0x10(%ebp)
104cd0: 75 19 jne 104ceb <basic_check+0x311>
104cd2: 68 0d 78 10 00 push $0x10780d
104cd7: 68 8e 77 10 00 push $0x10778e
104cdc: 68 d6 00 00 00 push $0xd6
104ce1: 68 a3 77 10 00 push $0x1077a3
104ce6: e8 e2 b6 ff ff call 1003cd <__panic>
assert((p2 = alloc_page()) != NULL);
104ceb: 83 ec 0c sub $0xc,%esp
104cee: 6a 01 push $0x1
104cf0: e8 7a e0 ff ff call 102d6f <alloc_pages>
104cf5: 83 c4 10 add $0x10,%esp
104cf8: 89 45 f4 mov %eax,-0xc(%ebp)
104cfb: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
104cff: 75 19 jne 104d1a <basic_check+0x340>
104d01: 68 29 78 10 00 push $0x107829
104d06: 68 8e 77 10 00 push $0x10778e
104d0b: 68 d7 00 00 00 push $0xd7
104d10: 68 a3 77 10 00 push $0x1077a3
104d15: e8 b3 b6 ff ff call 1003cd <__panic>
assert(alloc_page() == NULL);
104d1a: 83 ec 0c sub $0xc,%esp
104d1d: 6a 01 push $0x1
104d1f: e8 4b e0 ff ff call 102d6f <alloc_pages>
104d24: 83 c4 10 add $0x10,%esp
104d27: 85 c0 test %eax,%eax
104d29: 74 19 je 104d44 <basic_check+0x36a>
104d2b: 68 16 79 10 00 push $0x107916
104d30: 68 8e 77 10 00 push $0x10778e
104d35: 68 d9 00 00 00 push $0xd9
104d3a: 68 a3 77 10 00 push $0x1077a3
104d3f: e8 89 b6 ff ff call 1003cd <__panic>
free_page(p0);
104d44: 83 ec 08 sub $0x8,%esp
104d47: 6a 01 push $0x1
104d49: ff 75 ec pushl -0x14(%ebp)
104d4c: e8 5c e0 ff ff call 102dad <free_pages>
104d51: 83 c4 10 add $0x10,%esp
104d54: c7 45 e8 68 a9 11 00 movl $0x11a968,-0x18(%ebp)
104d5b: 8b 45 e8 mov -0x18(%ebp),%eax
104d5e: 8b 40 04 mov 0x4(%eax),%eax
104d61: 39 45 e8 cmp %eax,-0x18(%ebp)
104d64: 0f 94 c0 sete %al
104d67: 0f b6 c0 movzbl %al,%eax
assert(!list_empty(&free_list));
104d6a: 85 c0 test %eax,%eax
104d6c: 74 19 je 104d87 <basic_check+0x3ad>
104d6e: 68 38 79 10 00 push $0x107938
104d73: 68 8e 77 10 00 push $0x10778e
104d78: 68 dc 00 00 00 push $0xdc
104d7d: 68 a3 77 10 00 push $0x1077a3
104d82: e8 46 b6 ff ff call 1003cd <__panic>
struct Page *p;
assert((p = alloc_page()) == p0);
104d87: 83 ec 0c sub $0xc,%esp
104d8a: 6a 01 push $0x1
104d8c: e8 de df ff ff call 102d6f <alloc_pages>
104d91: 83 c4 10 add $0x10,%esp
104d94: 89 45 dc mov %eax,-0x24(%ebp)
104d97: 8b 45 dc mov -0x24(%ebp),%eax
104d9a: 3b 45 ec cmp -0x14(%ebp),%eax
104d9d: 74 19 je 104db8 <basic_check+0x3de>
104d9f: 68 50 79 10 00 push $0x107950
104da4: 68 8e 77 10 00 push $0x10778e
104da9: 68 df 00 00 00 push $0xdf
104dae: 68 a3 77 10 00 push $0x1077a3
104db3: e8 15 b6 ff ff call 1003cd <__panic>
assert(alloc_page() == NULL);
104db8: 83 ec 0c sub $0xc,%esp
104dbb: 6a 01 push $0x1
104dbd: e8 ad df ff ff call 102d6f <alloc_pages>
104dc2: 83 c4 10 add $0x10,%esp
104dc5: 85 c0 test %eax,%eax
104dc7: 74 19 je 104de2 <basic_check+0x408>
104dc9: 68 16 79 10 00 push $0x107916
104dce: 68 8e 77 10 00 push $0x10778e
104dd3: 68 e0 00 00 00 push $0xe0
104dd8: 68 a3 77 10 00 push $0x1077a3
104ddd: e8 eb b5 ff ff call 1003cd <__panic>
assert(nr_free == 0);
104de2: a1 70 a9 11 00 mov 0x11a970,%eax
104de7: 85 c0 test %eax,%eax
104de9: 74 19 je 104e04 <basic_check+0x42a>
104deb: 68 69 79 10 00 push $0x107969
104df0: 68 8e 77 10 00 push $0x10778e
104df5: 68 e2 00 00 00 push $0xe2
104dfa: 68 a3 77 10 00 push $0x1077a3
104dff: e8 c9 b5 ff ff call 1003cd <__panic>
free_list = free_list_store;
104e04: 8b 45 d0 mov -0x30(%ebp),%eax
104e07: 8b 55 d4 mov -0x2c(%ebp),%edx
104e0a: a3 68 a9 11 00 mov %eax,0x11a968
104e0f: 89 15 6c a9 11 00 mov %edx,0x11a96c
nr_free = nr_free_store;
104e15: 8b 45 e0 mov -0x20(%ebp),%eax
104e18: a3 70 a9 11 00 mov %eax,0x11a970
free_page(p);
104e1d: 83 ec 08 sub $0x8,%esp
104e20: 6a 01 push $0x1
104e22: ff 75 dc pushl -0x24(%ebp)
104e25: e8 83 df ff ff call 102dad <free_pages>
104e2a: 83 c4 10 add $0x10,%esp
free_page(p1);
104e2d: 83 ec 08 sub $0x8,%esp
104e30: 6a 01 push $0x1
104e32: ff 75 f0 pushl -0x10(%ebp)
104e35: e8 73 df ff ff call 102dad <free_pages>
104e3a: 83 c4 10 add $0x10,%esp
free_page(p2);
104e3d: 83 ec 08 sub $0x8,%esp
104e40: 6a 01 push $0x1
104e42: ff 75 f4 pushl -0xc(%ebp)
104e45: e8 63 df ff ff call 102dad <free_pages>
104e4a: 83 c4 10 add $0x10,%esp
}
104e4d: 90 nop
104e4e: c9 leave
104e4f: c3 ret
00104e50 <default_check>:
// LAB2: below code is used to check the first fit allocation algorithm (your EXERCISE 1)
// NOTICE: You SHOULD NOT CHANGE basic_check, default_check functions!
static void
default_check(void) {
104e50: 55 push %ebp
104e51: 89 e5 mov %esp,%ebp
104e53: 81 ec 88 00 00 00 sub $0x88,%esp
int count = 0, total = 0;
104e59: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp)
104e60: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp)
list_entry_t *le = &free_list;
104e67: c7 45 ec 68 a9 11 00 movl $0x11a968,-0x14(%ebp)
while ((le = list_next(le)) != &free_list) {
104e6e: eb 60 jmp 104ed0 <default_check+0x80>
struct Page *p = le2page(le, page_link);
104e70: 8b 45 ec mov -0x14(%ebp),%eax
104e73: 83 e8 0c sub $0xc,%eax
104e76: 89 45 e4 mov %eax,-0x1c(%ebp)
assert(PageProperty(p));
104e79: 8b 45 e4 mov -0x1c(%ebp),%eax
104e7c: 83 c0 04 add $0x4,%eax
104e7f: c7 45 ac 01 00 00 00 movl $0x1,-0x54(%ebp)
104e86: 89 45 a8 mov %eax,-0x58(%ebp)
* @addr: the address to count from
* */
static inline bool
test_bit(int nr, volatile void *addr) {
int oldbit;
asm volatile ("btl %2, %1; sbbl %0,%0" : "=r" (oldbit) : "m" (*(volatile long *)addr), "Ir" (nr));
104e89: 8b 45 a8 mov -0x58(%ebp),%eax
104e8c: 8b 55 ac mov -0x54(%ebp),%edx
104e8f: 0f a3 10 bt %edx,(%eax)
104e92: 19 c0 sbb %eax,%eax
104e94: 89 45 a4 mov %eax,-0x5c(%ebp)
return oldbit != 0;
104e97: 83 7d a4 00 cmpl $0x0,-0x5c(%ebp)
104e9b: 0f 95 c0 setne %al
104e9e: 0f b6 c0 movzbl %al,%eax
104ea1: 85 c0 test %eax,%eax
104ea3: 75 19 jne 104ebe <default_check+0x6e>
104ea5: 68 76 79 10 00 push $0x107976
104eaa: 68 8e 77 10 00 push $0x10778e
104eaf: 68 f3 00 00 00 push $0xf3
104eb4: 68 a3 77 10 00 push $0x1077a3
104eb9: e8 0f b5 ff ff call 1003cd <__panic>
count ++, total += p->property;
104ebe: 83 45 f4 01 addl $0x1,-0xc(%ebp)
104ec2: 8b 45 e4 mov -0x1c(%ebp),%eax
104ec5: 8b 50 08 mov 0x8(%eax),%edx
104ec8: 8b 45 f0 mov -0x10(%ebp),%eax
104ecb: 01 d0 add %edx,%eax
104ecd: 89 45 f0 mov %eax,-0x10(%ebp)
104ed0: 8b 45 ec mov -0x14(%ebp),%eax
104ed3: 89 45 e0 mov %eax,-0x20(%ebp)
* list_next - get the next entry
* @listelm: the list head
**/
static inline list_entry_t *
list_next(list_entry_t *listelm) {
return listelm->next;
104ed6: 8b 45 e0 mov -0x20(%ebp),%eax
104ed9: 8b 40 04 mov 0x4(%eax),%eax
// NOTICE: You SHOULD NOT CHANGE basic_check, default_check functions!
static void
default_check(void) {
int count = 0, total = 0;
list_entry_t *le = &free_list;
while ((le = list_next(le)) != &free_list) {
104edc: 89 45 ec mov %eax,-0x14(%ebp)
104edf: 81 7d ec 68 a9 11 00 cmpl $0x11a968,-0x14(%ebp)
104ee6: 75 88 jne 104e70 <default_check+0x20>
struct Page *p = le2page(le, page_link);
assert(PageProperty(p));
count ++, total += p->property;
}
assert(total == nr_free_pages());
104ee8: e8 f5 de ff ff call 102de2 <nr_free_pages>
104eed: 89 c2 mov %eax,%edx
104eef: 8b 45 f0 mov -0x10(%ebp),%eax
104ef2: 39 c2 cmp %eax,%edx
104ef4: 74 19 je 104f0f <default_check+0xbf>
104ef6: 68 86 79 10 00 push $0x107986
104efb: 68 8e 77 10 00 push $0x10778e
104f00: 68 f6 00 00 00 push $0xf6
104f05: 68 a3 77 10 00 push $0x1077a3
104f0a: e8 be b4 ff ff call 1003cd <__panic>
basic_check();
104f0f: e8 c6 fa ff ff call 1049da <basic_check>
struct Page *p0 = alloc_pages(5), *p1, *p2;
104f14: 83 ec 0c sub $0xc,%esp
104f17: 6a 05 push $0x5
104f19: e8 51 de ff ff call 102d6f <alloc_pages>
104f1e: 83 c4 10 add $0x10,%esp
104f21: 89 45 dc mov %eax,-0x24(%ebp)
struct Page *p0_saved = p0;
104f24: 8b 45 dc mov -0x24(%ebp),%eax
104f27: 89 45 d8 mov %eax,-0x28(%ebp)
assert(p0 != NULL);
104f2a: 83 7d dc 00 cmpl $0x0,-0x24(%ebp)
104f2e: 75 19 jne 104f49 <default_check+0xf9>
104f30: 68 9f 79 10 00 push $0x10799f
104f35: 68 8e 77 10 00 push $0x10778e
104f3a: 68 fd 00 00 00 push $0xfd
104f3f: 68 a3 77 10 00 push $0x1077a3
104f44: e8 84 b4 ff ff call 1003cd <__panic>
assert(!PageProperty(p0));
104f49: 8b 45 dc mov -0x24(%ebp),%eax
104f4c: 83 c0 04 add $0x4,%eax
104f4f: c7 45 e8 01 00 00 00 movl $0x1,-0x18(%ebp)
104f56: 89 45 a0 mov %eax,-0x60(%ebp)
* @addr: the address to count from
* */
static inline bool
test_bit(int nr, volatile void *addr) {
int oldbit;
asm volatile ("btl %2, %1; sbbl %0,%0" : "=r" (oldbit) : "m" (*(volatile long *)addr), "Ir" (nr));
104f59: 8b 45 a0 mov -0x60(%ebp),%eax
104f5c: 8b 55 e8 mov -0x18(%ebp),%edx
104f5f: 0f a3 10 bt %edx,(%eax)
104f62: 19 c0 sbb %eax,%eax
104f64: 89 45 9c mov %eax,-0x64(%ebp)
return oldbit != 0;
104f67: 83 7d 9c 00 cmpl $0x0,-0x64(%ebp)
104f6b: 0f 95 c0 setne %al
104f6e: 0f b6 c0 movzbl %al,%eax
104f71: 85 c0 test %eax,%eax
104f73: 74 19 je 104f8e <default_check+0x13e>
104f75: 68 aa 79 10 00 push $0x1079aa
104f7a: 68 8e 77 10 00 push $0x10778e
104f7f: 68 fe 00 00 00 push $0xfe
104f84: 68 a3 77 10 00 push $0x1077a3
104f89: e8 3f b4 ff ff call 1003cd <__panic>
list_entry_t free_list_store = free_list;
104f8e: a1 68 a9 11 00 mov 0x11a968,%eax
104f93: 8b 15 6c a9 11 00 mov 0x11a96c,%edx
104f99: 89 85 7c ff ff ff mov %eax,-0x84(%ebp)
104f9f: 89 55 80 mov %edx,-0x80(%ebp)
104fa2: c7 45 cc 68 a9 11 00 movl $0x11a968,-0x34(%ebp)
* list_init - initialize a new entry
* @elm: new entry to be initialized
* */
static inline void
list_init(list_entry_t *elm) {
elm->prev = elm->next = elm;
104fa9: 8b 45 cc mov -0x34(%ebp),%eax
104fac: 8b 55 cc mov -0x34(%ebp),%edx
104faf: 89 50 04 mov %edx,0x4(%eax)
104fb2: 8b 45 cc mov -0x34(%ebp),%eax
104fb5: 8b 50 04 mov 0x4(%eax),%edx
104fb8: 8b 45 cc mov -0x34(%ebp),%eax
104fbb: 89 10 mov %edx,(%eax)
104fbd: c7 45 d4 68 a9 11 00 movl $0x11a968,-0x2c(%ebp)
* list_empty - tests whether a list is empty
* @list: the list to test.
* */
static inline bool
list_empty(list_entry_t *list) {
return list->next == list;
104fc4: 8b 45 d4 mov -0x2c(%ebp),%eax
104fc7: 8b 40 04 mov 0x4(%eax),%eax
104fca: 39 45 d4 cmp %eax,-0x2c(%ebp)
104fcd: 0f 94 c0 sete %al
104fd0: 0f b6 c0 movzbl %al,%eax
list_init(&free_list);
assert(list_empty(&free_list));
104fd3: 85 c0 test %eax,%eax
104fd5: 75 19 jne 104ff0 <default_check+0x1a0>
104fd7: 68 ff 78 10 00 push $0x1078ff
104fdc: 68 8e 77 10 00 push $0x10778e
104fe1: 68 02 01 00 00 push $0x102
104fe6: 68 a3 77 10 00 push $0x1077a3
104feb: e8 dd b3 ff ff call 1003cd <__panic>
assert(alloc_page() == NULL);
104ff0: 83 ec 0c sub $0xc,%esp
104ff3: 6a 01 push $0x1
104ff5: e8 75 dd ff ff call 102d6f <alloc_pages>
104ffa: 83 c4 10 add $0x10,%esp
104ffd: 85 c0 test %eax,%eax
104fff: 74 19 je 10501a <default_check+0x1ca>
105001: 68 16 79 10 00 push $0x107916
105006: 68 8e 77 10 00 push $0x10778e
10500b: 68 03 01 00 00 push $0x103
105010: 68 a3 77 10 00 push $0x1077a3
105015: e8 b3 b3 ff ff call 1003cd <__panic>
unsigned int nr_free_store = nr_free;
10501a: a1 70 a9 11 00 mov 0x11a970,%eax
10501f: 89 45 c8 mov %eax,-0x38(%ebp)
nr_free = 0;
105022: c7 05 70 a9 11 00 00 movl $0x0,0x11a970
105029: 00 00 00
free_pages(p0 + 2, 3);
10502c: 8b 45 dc mov -0x24(%ebp),%eax
10502f: 83 c0 28 add $0x28,%eax
105032: 83 ec 08 sub $0x8,%esp
105035: 6a 03 push $0x3
105037: 50 push %eax
105038: e8 70 dd ff ff call 102dad <free_pages>
10503d: 83 c4 10 add $0x10,%esp
assert(alloc_pages(4) == NULL);
105040: 83 ec 0c sub $0xc,%esp
105043: 6a 04 push $0x4
105045: e8 25 dd ff ff call 102d6f <alloc_pages>
10504a: 83 c4 10 add $0x10,%esp
10504d: 85 c0 test %eax,%eax
10504f: 74 19 je 10506a <default_check+0x21a>
105051: 68 bc 79 10 00 push $0x1079bc
105056: 68 8e 77 10 00 push $0x10778e
10505b: 68 09 01 00 00 push $0x109
105060: 68 a3 77 10 00 push $0x1077a3
105065: e8 63 b3 ff ff call 1003cd <__panic>
assert(PageProperty(p0 + 2) && p0[2].property == 3);
10506a: 8b 45 dc mov -0x24(%ebp),%eax
10506d: 83 c0 28 add $0x28,%eax
105070: 83 c0 04 add $0x4,%eax
105073: c7 45 d0 01 00 00 00 movl $0x1,-0x30(%ebp)
10507a: 89 45 98 mov %eax,-0x68(%ebp)
* @addr: the address to count from
* */
static inline bool
test_bit(int nr, volatile void *addr) {
int oldbit;
asm volatile ("btl %2, %1; sbbl %0,%0" : "=r" (oldbit) : "m" (*(volatile long *)addr), "Ir" (nr));
10507d: 8b 45 98 mov -0x68(%ebp),%eax
105080: 8b 55 d0 mov -0x30(%ebp),%edx
105083: 0f a3 10 bt %edx,(%eax)
105086: 19 c0 sbb %eax,%eax
105088: 89 45 94 mov %eax,-0x6c(%ebp)
return oldbit != 0;
10508b: 83 7d 94 00 cmpl $0x0,-0x6c(%ebp)
10508f: 0f 95 c0 setne %al
105092: 0f b6 c0 movzbl %al,%eax
105095: 85 c0 test %eax,%eax
105097: 74 0e je 1050a7 <default_check+0x257>
105099: 8b 45 dc mov -0x24(%ebp),%eax
10509c: 83 c0 28 add $0x28,%eax
10509f: 8b 40 08 mov 0x8(%eax),%eax
1050a2: 83 f8 03 cmp $0x3,%eax
1050a5: 74 19 je 1050c0 <default_check+0x270>
1050a7: 68 d4 79 10 00 push $0x1079d4
1050ac: 68 8e 77 10 00 push $0x10778e
1050b1: 68 0a 01 00 00 push $0x10a
1050b6: 68 a3 77 10 00 push $0x1077a3
1050bb: e8 0d b3 ff ff call 1003cd <__panic>
assert((p1 = alloc_pages(3)) != NULL);
1050c0: 83 ec 0c sub $0xc,%esp
1050c3: 6a 03 push $0x3
1050c5: e8 a5 dc ff ff call 102d6f <alloc_pages>
1050ca: 83 c4 10 add $0x10,%esp
1050cd: 89 45 c0 mov %eax,-0x40(%ebp)
1050d0: 83 7d c0 00 cmpl $0x0,-0x40(%ebp)
1050d4: 75 19 jne 1050ef <default_check+0x29f>
1050d6: 68 00 7a 10 00 push $0x107a00
1050db: 68 8e 77 10 00 push $0x10778e
1050e0: 68 0b 01 00 00 push $0x10b
1050e5: 68 a3 77 10 00 push $0x1077a3
1050ea: e8 de b2 ff ff call 1003cd <__panic>
assert(alloc_page() == NULL);
1050ef: 83 ec 0c sub $0xc,%esp
1050f2: 6a 01 push $0x1
1050f4: e8 76 dc ff ff call 102d6f <alloc_pages>
1050f9: 83 c4 10 add $0x10,%esp
1050fc: 85 c0 test %eax,%eax
1050fe: 74 19 je 105119 <default_check+0x2c9>
105100: 68 16 79 10 00 push $0x107916
105105: 68 8e 77 10 00 push $0x10778e
10510a: 68 0c 01 00 00 push $0x10c
10510f: 68 a3 77 10 00 push $0x1077a3
105114: e8 b4 b2 ff ff call 1003cd <__panic>
assert(p0 + 2 == p1);
105119: 8b 45 dc mov -0x24(%ebp),%eax
10511c: 83 c0 28 add $0x28,%eax
10511f: 3b 45 c0 cmp -0x40(%ebp),%eax
105122: 74 19 je 10513d <default_check+0x2ed>
105124: 68 1e 7a 10 00 push $0x107a1e
105129: 68 8e 77 10 00 push $0x10778e
10512e: 68 0d 01 00 00 push $0x10d
105133: 68 a3 77 10 00 push $0x1077a3
105138: e8 90 b2 ff ff call 1003cd <__panic>
p2 = p0 + 1;
10513d: 8b 45 dc mov -0x24(%ebp),%eax
105140: 83 c0 14 add $0x14,%eax
105143: 89 45 bc mov %eax,-0x44(%ebp)
free_page(p0);
105146: 83 ec 08 sub $0x8,%esp
105149: 6a 01 push $0x1
10514b: ff 75 dc pushl -0x24(%ebp)
10514e: e8 5a dc ff ff call 102dad <free_pages>
105153: 83 c4 10 add $0x10,%esp
free_pages(p1, 3);
105156: 83 ec 08 sub $0x8,%esp
105159: 6a 03 push $0x3
10515b: ff 75 c0 pushl -0x40(%ebp)
10515e: e8 4a dc ff ff call 102dad <free_pages>
105163: 83 c4 10 add $0x10,%esp
assert(PageProperty(p0) && p0->property == 1);
105166: 8b 45 dc mov -0x24(%ebp),%eax
105169: 83 c0 04 add $0x4,%eax
10516c: c7 45 c4 01 00 00 00 movl $0x1,-0x3c(%ebp)
105173: 89 45 90 mov %eax,-0x70(%ebp)
* @addr: the address to count from
* */
static inline bool
test_bit(int nr, volatile void *addr) {
int oldbit;
asm volatile ("btl %2, %1; sbbl %0,%0" : "=r" (oldbit) : "m" (*(volatile long *)addr), "Ir" (nr));
105176: 8b 45 90 mov -0x70(%ebp),%eax
105179: 8b 55 c4 mov -0x3c(%ebp),%edx
10517c: 0f a3 10 bt %edx,(%eax)
10517f: 19 c0 sbb %eax,%eax
105181: 89 45 8c mov %eax,-0x74(%ebp)
return oldbit != 0;
105184: 83 7d 8c 00 cmpl $0x0,-0x74(%ebp)
105188: 0f 95 c0 setne %al
10518b: 0f b6 c0 movzbl %al,%eax
10518e: 85 c0 test %eax,%eax
105190: 74 0b je 10519d <default_check+0x34d>
105192: 8b 45 dc mov -0x24(%ebp),%eax
105195: 8b 40 08 mov 0x8(%eax),%eax
105198: 83 f8 01 cmp $0x1,%eax
10519b: 74 19 je 1051b6 <default_check+0x366>
10519d: 68 2c 7a 10 00 push $0x107a2c
1051a2: 68 8e 77 10 00 push $0x10778e
1051a7: 68 12 01 00 00 push $0x112
1051ac: 68 a3 77 10 00 push $0x1077a3
1051b1: e8 17 b2 ff ff call 1003cd <__panic>
assert(PageProperty(p1) && p1->property == 3);
1051b6: 8b 45 c0 mov -0x40(%ebp),%eax
1051b9: 83 c0 04 add $0x4,%eax
1051bc: c7 45 b8 01 00 00 00 movl $0x1,-0x48(%ebp)
1051c3: 89 45 88 mov %eax,-0x78(%ebp)
* @addr: the address to count from
* */
static inline bool
test_bit(int nr, volatile void *addr) {
int oldbit;
asm volatile ("btl %2, %1; sbbl %0,%0" : "=r" (oldbit) : "m" (*(volatile long *)addr), "Ir" (nr));
1051c6: 8b 45 88 mov -0x78(%ebp),%eax
1051c9: 8b 55 b8 mov -0x48(%ebp),%edx
1051cc: 0f a3 10 bt %edx,(%eax)
1051cf: 19 c0 sbb %eax,%eax
1051d1: 89 45 84 mov %eax,-0x7c(%ebp)
return oldbit != 0;
1051d4: 83 7d 84 00 cmpl $0x0,-0x7c(%ebp)
1051d8: 0f 95 c0 setne %al
1051db: 0f b6 c0 movzbl %al,%eax
1051de: 85 c0 test %eax,%eax
1051e0: 74 0b je 1051ed <default_check+0x39d>
1051e2: 8b 45 c0 mov -0x40(%ebp),%eax
1051e5: 8b 40 08 mov 0x8(%eax),%eax
1051e8: 83 f8 03 cmp $0x3,%eax
1051eb: 74 19 je 105206 <default_check+0x3b6>
1051ed: 68 54 7a 10 00 push $0x107a54
1051f2: 68 8e 77 10 00 push $0x10778e
1051f7: 68 13 01 00 00 push $0x113
1051fc: 68 a3 77 10 00 push $0x1077a3
105201: e8 c7 b1 ff ff call 1003cd <__panic>
assert((p0 = alloc_page()) == p2 - 1);
105206: 83 ec 0c sub $0xc,%esp
105209: 6a 01 push $0x1
10520b: e8 5f db ff ff call 102d6f <alloc_pages>
105210: 83 c4 10 add $0x10,%esp
105213: 89 45 dc mov %eax,-0x24(%ebp)
105216: 8b 45 bc mov -0x44(%ebp),%eax
105219: 83 e8 14 sub $0x14,%eax
10521c: 39 45 dc cmp %eax,-0x24(%ebp)
10521f: 74 19 je 10523a <default_check+0x3ea>
105221: 68 7a 7a 10 00 push $0x107a7a
105226: 68 8e 77 10 00 push $0x10778e
10522b: 68 15 01 00 00 push $0x115
105230: 68 a3 77 10 00 push $0x1077a3
105235: e8 93 b1 ff ff call 1003cd <__panic>
free_page(p0);
10523a: 83 ec 08 sub $0x8,%esp
10523d: 6a 01 push $0x1
10523f: ff 75 dc pushl -0x24(%ebp)
105242: e8 66 db ff ff call 102dad <free_pages>
105247: 83 c4 10 add $0x10,%esp
assert((p0 = alloc_pages(2)) == p2 + 1);
10524a: 83 ec 0c sub $0xc,%esp
10524d: 6a 02 push $0x2
10524f: e8 1b db ff ff call 102d6f <alloc_pages>
105254: 83 c4 10 add $0x10,%esp
105257: 89 45 dc mov %eax,-0x24(%ebp)
10525a: 8b 45 bc mov -0x44(%ebp),%eax
10525d: 83 c0 14 add $0x14,%eax
105260: 39 45 dc cmp %eax,-0x24(%ebp)
105263: 74 19 je 10527e <default_check+0x42e>
105265: 68 98 7a 10 00 push $0x107a98
10526a: 68 8e 77 10 00 push $0x10778e
10526f: 68 17 01 00 00 push $0x117
105274: 68 a3 77 10 00 push $0x1077a3
105279: e8 4f b1 ff ff call 1003cd <__panic>
free_pages(p0, 2);
10527e: 83 ec 08 sub $0x8,%esp
105281: 6a 02 push $0x2
105283: ff 75 dc pushl -0x24(%ebp)
105286: e8 22 db ff ff call 102dad <free_pages>
10528b: 83 c4 10 add $0x10,%esp
free_page(p2);
10528e: 83 ec 08 sub $0x8,%esp
105291: 6a 01 push $0x1
105293: ff 75 bc pushl -0x44(%ebp)
105296: e8 12 db ff ff call 102dad <free_pages>
10529b: 83 c4 10 add $0x10,%esp
assert((p0 = alloc_pages(5)) != NULL);
10529e: 83 ec 0c sub $0xc,%esp
1052a1: 6a 05 push $0x5
1052a3: e8 c7 da ff ff call 102d6f <alloc_pages>
1052a8: 83 c4 10 add $0x10,%esp
1052ab: 89 45 dc mov %eax,-0x24(%ebp)
1052ae: 83 7d dc 00 cmpl $0x0,-0x24(%ebp)
1052b2: 75 19 jne 1052cd <default_check+0x47d>
1052b4: 68 b8 7a 10 00 push $0x107ab8
1052b9: 68 8e 77 10 00 push $0x10778e
1052be: 68 1c 01 00 00 push $0x11c
1052c3: 68 a3 77 10 00 push $0x1077a3
1052c8: e8 00 b1 ff ff call 1003cd <__panic>
assert(alloc_page() == NULL);
1052cd: 83 ec 0c sub $0xc,%esp
1052d0: 6a 01 push $0x1
1052d2: e8 98 da ff ff call 102d6f <alloc_pages>
1052d7: 83 c4 10 add $0x10,%esp
1052da: 85 c0 test %eax,%eax
1052dc: 74 19 je 1052f7 <default_check+0x4a7>
1052de: 68 16 79 10 00 push $0x107916
1052e3: 68 8e 77 10 00 push $0x10778e
1052e8: 68 1d 01 00 00 push $0x11d
1052ed: 68 a3 77 10 00 push $0x1077a3
1052f2: e8 d6 b0 ff ff call 1003cd <__panic>
assert(nr_free == 0);
1052f7: a1 70 a9 11 00 mov 0x11a970,%eax
1052fc: 85 c0 test %eax,%eax
1052fe: 74 19 je 105319 <default_check+0x4c9>
105300: 68 69 79 10 00 push $0x107969
105305: 68 8e 77 10 00 push $0x10778e
10530a: 68 1f 01 00 00 push $0x11f
10530f: 68 a3 77 10 00 push $0x1077a3
105314: e8 b4 b0 ff ff call 1003cd <__panic>
nr_free = nr_free_store;
105319: 8b 45 c8 mov -0x38(%ebp),%eax
10531c: a3 70 a9 11 00 mov %eax,0x11a970
free_list = free_list_store;
105321: 8b 85 7c ff ff ff mov -0x84(%ebp),%eax
105327: 8b 55 80 mov -0x80(%ebp),%edx
10532a: a3 68 a9 11 00 mov %eax,0x11a968
10532f: 89 15 6c a9 11 00 mov %edx,0x11a96c
free_pages(p0, 5);
105335: 83 ec 08 sub $0x8,%esp
105338: 6a 05 push $0x5
10533a: ff 75 dc pushl -0x24(%ebp)
10533d: e8 6b da ff ff call 102dad <free_pages>
105342: 83 c4 10 add $0x10,%esp
le = &free_list;
105345: c7 45 ec 68 a9 11 00 movl $0x11a968,-0x14(%ebp)
while ((le = list_next(le)) != &free_list) {
10534c: eb 1d jmp 10536b <default_check+0x51b>
struct Page *p = le2page(le, page_link);
10534e: 8b 45 ec mov -0x14(%ebp),%eax
105351: 83 e8 0c sub $0xc,%eax
105354: 89 45 b0 mov %eax,-0x50(%ebp)
count --, total -= p->property;
105357: 83 6d f4 01 subl $0x1,-0xc(%ebp)
10535b: 8b 55 f0 mov -0x10(%ebp),%edx
10535e: 8b 45 b0 mov -0x50(%ebp),%eax
105361: 8b 40 08 mov 0x8(%eax),%eax
105364: 29 c2 sub %eax,%edx
105366: 89 d0 mov %edx,%eax
105368: 89 45 f0 mov %eax,-0x10(%ebp)
10536b: 8b 45 ec mov -0x14(%ebp),%eax
10536e: 89 45 b4 mov %eax,-0x4c(%ebp)
* list_next - get the next entry
* @listelm: the list head
**/
static inline list_entry_t *
list_next(list_entry_t *listelm) {
return listelm->next;
105371: 8b 45 b4 mov -0x4c(%ebp),%eax
105374: 8b 40 04 mov 0x4(%eax),%eax
free_list = free_list_store;
free_pages(p0, 5);
le = &free_list;
while ((le = list_next(le)) != &free_list) {
105377: 89 45 ec mov %eax,-0x14(%ebp)
10537a: 81 7d ec 68 a9 11 00 cmpl $0x11a968,-0x14(%ebp)
105381: 75 cb jne 10534e <default_check+0x4fe>
struct Page *p = le2page(le, page_link);
count --, total -= p->property;
}
assert(count == 0);
105383: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
105387: 74 19 je 1053a2 <default_check+0x552>
105389: 68 d6 7a 10 00 push $0x107ad6
10538e: 68 8e 77 10 00 push $0x10778e
105393: 68 2a 01 00 00 push $0x12a
105398: 68 a3 77 10 00 push $0x1077a3
10539d: e8 2b b0 ff ff call 1003cd <__panic>
assert(total == 0);
1053a2: 83 7d f0 00 cmpl $0x0,-0x10(%ebp)
1053a6: 74 19 je 1053c1 <default_check+0x571>
1053a8: 68 e1 7a 10 00 push $0x107ae1
1053ad: 68 8e 77 10 00 push $0x10778e
1053b2: 68 2b 01 00 00 push $0x12b
1053b7: 68 a3 77 10 00 push $0x1077a3
1053bc: e8 0c b0 ff ff call 1003cd <__panic>
}
1053c1: 90 nop
1053c2: c9 leave
1053c3: c3 ret
001053c4 <page2ppn>:
extern struct Page *pages;
extern size_t npage;
static inline ppn_t
page2ppn(struct Page *page) {
1053c4: 55 push %ebp
1053c5: 89 e5 mov %esp,%ebp
return page - pages;
1053c7: 8b 45 08 mov 0x8(%ebp),%eax
1053ca: 8b 15 64 a9 11 00 mov 0x11a964,%edx
1053d0: 29 d0 sub %edx,%eax
1053d2: c1 f8 02 sar $0x2,%eax
1053d5: 69 c0 cd cc cc cc imul $0xcccccccd,%eax,%eax
}
1053db: 5d pop %ebp
1053dc: c3 ret
001053dd <page2pa>:
static inline uintptr_t
page2pa(struct Page *page) {
1053dd: 55 push %ebp
1053de: 89 e5 mov %esp,%ebp
return page2ppn(page) << PGSHIFT;
1053e0: ff 75 08 pushl 0x8(%ebp)
1053e3: e8 dc ff ff ff call 1053c4 <page2ppn>
1053e8: 83 c4 04 add $0x4,%esp
1053eb: c1 e0 0c shl $0xc,%eax
}
1053ee: c9 leave
1053ef: c3 ret
001053f0 <set_page_ref>:
page_ref(struct Page *page) {
return page->ref;
}
static inline void
set_page_ref(struct Page *page, int val) {
1053f0: 55 push %ebp
1053f1: 89 e5 mov %esp,%ebp
page->ref = val;
1053f3: 8b 45 08 mov 0x8(%ebp),%eax
1053f6: 8b 55 0c mov 0xc(%ebp),%edx
1053f9: 89 10 mov %edx,(%eax)
}
1053fb: 90 nop
1053fc: 5d pop %ebp
1053fd: c3 ret
001053fe <buddy_find_first_zero>:
#define RIGHT_LEAF(index) ((index) * 2 + 2)
#define PARENT(index) ( ((index) + 1) / 2 - 1)
#define MAX(a, b) ((a) > (b) ? (a) : (b))
static unsigned int
buddy_find_first_zero(unsigned int bit_array) {
1053fe: 55 push %ebp
1053ff: 89 e5 mov %esp,%ebp
105401: 83 ec 10 sub $0x10,%esp
unsigned pos = 0;
105404: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%ebp)
while (bit_array >>= 1) ++ pos;
10540b: eb 04 jmp 105411 <buddy_find_first_zero+0x13>
10540d: 83 45 fc 01 addl $0x1,-0x4(%ebp)
105411: d1 6d 08 shrl 0x8(%ebp)
105414: 83 7d 08 00 cmpl $0x0,0x8(%ebp)
105418: 75 f3 jne 10540d <buddy_find_first_zero+0xf>
return pos;
10541a: 8b 45 fc mov -0x4(%ebp),%eax
}
10541d: c9 leave
10541e: c3 ret
0010541f <buddy_node_index_to_page>:
static struct Page*
buddy_node_index_to_page(unsigned int index, unsigned int node_size) {
10541f: 55 push %ebp
105420: 89 e5 mov %esp,%ebp
return buddy_allocatable_base + ((index + 1) * node_size - buddy_max_pages);
105422: 8b 0d 54 a9 11 00 mov 0x11a954,%ecx
105428: 8b 45 08 mov 0x8(%ebp),%eax
10542b: 83 c0 01 add $0x1,%eax
10542e: 0f af 45 0c imul 0xc(%ebp),%eax
105432: 89 c2 mov %eax,%edx
105434: a1 50 a9 11 00 mov 0x11a950,%eax
105439: 29 c2 sub %eax,%edx
10543b: 89 d0 mov %edx,%eax
10543d: c1 e0 02 shl $0x2,%eax
105440: 01 d0 add %edx,%eax
105442: c1 e0 02 shl $0x2,%eax
105445: 01 c8 add %ecx,%eax
}
105447: 5d pop %ebp
105448: c3 ret
00105449 <buddy_init>:
static void
buddy_init(void) {
105449: 55 push %ebp
10544a: 89 e5 mov %esp,%ebp
// do nothing.
}
10544c: 90 nop
10544d: 5d pop %ebp
10544e: c3 ret
0010544f <buddy_init_memmap>:
static void
buddy_init_memmap(struct Page *base, size_t n) {
10544f: 55 push %ebp
105450: 89 e5 mov %esp,%ebp
105452: 83 ec 58 sub $0x58,%esp
assert(n > 0);
105455: 83 7d 0c 00 cmpl $0x0,0xc(%ebp)
105459: 75 16 jne 105471 <buddy_init_memmap+0x22>
10545b: 68 1c 7b 10 00 push $0x107b1c
105460: 68 22 7b 10 00 push $0x107b22
105465: 6a 28 push $0x28
105467: 68 37 7b 10 00 push $0x107b37
10546c: e8 5c af ff ff call 1003cd <__panic>
// Calculate maximum manageable memory zone
unsigned int max_pages = 1;
105471: c7 45 f4 01 00 00 00 movl $0x1,-0xc(%ebp)
for (unsigned int i = 1; i < BUDDY_MAX_DEPTH; ++ i) {
105478: c7 45 f0 01 00 00 00 movl $0x1,-0x10(%ebp)
10547f: eb 23 jmp 1054a4 <buddy_init_memmap+0x55>
// Should consider the page for storing 'longest' array.
if (max_pages + max_pages / 512 >= n) {
105481: 8b 45 f4 mov -0xc(%ebp),%eax
105484: c1 e8 09 shr $0x9,%eax
105487: 89 c2 mov %eax,%edx
105489: 8b 45 f4 mov -0xc(%ebp),%eax
10548c: 01 d0 add %edx,%eax
10548e: 3b 45 0c cmp 0xc(%ebp),%eax
105491: 72 0a jb 10549d <buddy_init_memmap+0x4e>
max_pages /= 2;
105493: 8b 45 f4 mov -0xc(%ebp),%eax
105496: d1 e8 shr %eax
105498: 89 45 f4 mov %eax,-0xc(%ebp)
break;
10549b: eb 0d jmp 1054aa <buddy_init_memmap+0x5b>
}
max_pages *= 2;
10549d: d1 65 f4 shll -0xc(%ebp)
static void
buddy_init_memmap(struct Page *base, size_t n) {
assert(n > 0);
// Calculate maximum manageable memory zone
unsigned int max_pages = 1;
for (unsigned int i = 1; i < BUDDY_MAX_DEPTH; ++ i) {
1054a0: 83 45 f0 01 addl $0x1,-0x10(%ebp)
1054a4: 83 7d f0 1d cmpl $0x1d,-0x10(%ebp)
1054a8: 76 d7 jbe 105481 <buddy_init_memmap+0x32>
max_pages /= 2;
break;
}
max_pages *= 2;
}
unsigned int longest_array_pages = max_pages / 512 + 1;
1054aa: 8b 45 f4 mov -0xc(%ebp),%eax
1054ad: c1 e8 09 shr $0x9,%eax
1054b0: 83 c0 01 add $0x1,%eax
1054b3: 89 45 dc mov %eax,-0x24(%ebp)
cprintf("BUDDY: Maximum manageable pages = %d, pages for storing longest = %d\n",
1054b6: 83 ec 04 sub $0x4,%esp
1054b9: ff 75 dc pushl -0x24(%ebp)
1054bc: ff 75 f4 pushl -0xc(%ebp)
1054bf: 68 4c 7b 10 00 push $0x107b4c
1054c4: e8 9e ad ff ff call 100267 <cprintf>
1054c9: 83 c4 10 add $0x10,%esp
max_pages, longest_array_pages);
buddy_longest = (unsigned int*)KADDR(page2pa(base));
1054cc: 83 ec 0c sub $0xc,%esp
1054cf: ff 75 08 pushl 0x8(%ebp)
1054d2: e8 06 ff ff ff call 1053dd <page2pa>
1054d7: 83 c4 10 add $0x10,%esp
1054da: 89 45 d8 mov %eax,-0x28(%ebp)
1054dd: 8b 45 d8 mov -0x28(%ebp),%eax
1054e0: c1 e8 0c shr $0xc,%eax
1054e3: 89 45 d4 mov %eax,-0x2c(%ebp)
1054e6: a1 c0 a8 11 00 mov 0x11a8c0,%eax
1054eb: 39 45 d4 cmp %eax,-0x2c(%ebp)
1054ee: 72 14 jb 105504 <buddy_init_memmap+0xb5>
1054f0: ff 75 d8 pushl -0x28(%ebp)
1054f3: 68 94 7b 10 00 push $0x107b94
1054f8: 6a 36 push $0x36
1054fa: 68 37 7b 10 00 push $0x107b37
1054ff: e8 c9 ae ff ff call 1003cd <__panic>
105504: 8b 45 d8 mov -0x28(%ebp),%eax
105507: 2d 00 00 00 40 sub $0x40000000,%eax
10550c: a3 4c a9 11 00 mov %eax,0x11a94c
buddy_max_pages = max_pages;
105511: 8b 45 f4 mov -0xc(%ebp),%eax
105514: a3 50 a9 11 00 mov %eax,0x11a950
unsigned int node_size = max_pages * 2;
105519: 8b 45 f4 mov -0xc(%ebp),%eax
10551c: 01 c0 add %eax,%eax
10551e: 89 45 ec mov %eax,-0x14(%ebp)
for (unsigned int i = 0; i < 2 * max_pages - 1; ++ i) {
105521: c7 45 e8 00 00 00 00 movl $0x0,-0x18(%ebp)
105528: eb 2b jmp 105555 <buddy_init_memmap+0x106>
if (IS_POWER_OF_2(i + 1)) node_size /= 2;
10552a: 8b 45 e8 mov -0x18(%ebp),%eax
10552d: 83 c0 01 add $0x1,%eax
105530: 23 45 e8 and -0x18(%ebp),%eax
105533: 85 c0 test %eax,%eax
105535: 75 08 jne 10553f <buddy_init_memmap+0xf0>
105537: 8b 45 ec mov -0x14(%ebp),%eax
10553a: d1 e8 shr %eax
10553c: 89 45 ec mov %eax,-0x14(%ebp)
buddy_longest[i] = node_size;
10553f: a1 4c a9 11 00 mov 0x11a94c,%eax
105544: 8b 55 e8 mov -0x18(%ebp),%edx
105547: c1 e2 02 shl $0x2,%edx
10554a: 01 c2 add %eax,%edx
10554c: 8b 45 ec mov -0x14(%ebp),%eax
10554f: 89 02 mov %eax,(%edx)
max_pages, longest_array_pages);
buddy_longest = (unsigned int*)KADDR(page2pa(base));
buddy_max_pages = max_pages;
unsigned int node_size = max_pages * 2;
for (unsigned int i = 0; i < 2 * max_pages - 1; ++ i) {
105551: 83 45 e8 01 addl $0x1,-0x18(%ebp)
105555: 8b 45 f4 mov -0xc(%ebp),%eax
105558: 01 c0 add %eax,%eax
10555a: 83 e8 01 sub $0x1,%eax
10555d: 3b 45 e8 cmp -0x18(%ebp),%eax
105560: 77 c8 ja 10552a <buddy_init_memmap+0xdb>
if (IS_POWER_OF_2(i + 1)) node_size /= 2;
buddy_longest[i] = node_size;
}
for (int i = 0; i < longest_array_pages; ++ i) {
105562: c7 45 e4 00 00 00 00 movl $0x0,-0x1c(%ebp)
105569: eb 34 jmp 10559f <buddy_init_memmap+0x150>
struct Page *p = base + i;
10556b: 8b 55 e4 mov -0x1c(%ebp),%edx
10556e: 89 d0 mov %edx,%eax
105570: c1 e0 02 shl $0x2,%eax
105573: 01 d0 add %edx,%eax
105575: c1 e0 02 shl $0x2,%eax
105578: 89 c2 mov %eax,%edx
10557a: 8b 45 08 mov 0x8(%ebp),%eax
10557d: 01 d0 add %edx,%eax
10557f: 89 45 d0 mov %eax,-0x30(%ebp)
SetPageReserved(p);
105582: 8b 45 d0 mov -0x30(%ebp),%eax
105585: 83 c0 04 add $0x4,%eax
105588: c7 45 c0 00 00 00 00 movl $0x0,-0x40(%ebp)
10558f: 89 45 bc mov %eax,-0x44(%ebp)
* Note that @nr may be almost arbitrarily large; this function is not
* restricted to acting on a single-word quantity.
* */
static inline void
set_bit(int nr, volatile void *addr) {
asm volatile ("btsl %1, %0" :"=m" (*(volatile long *)addr) : "Ir" (nr));
105592: 8b 45 bc mov -0x44(%ebp),%eax
105595: 8b 55 c0 mov -0x40(%ebp),%edx
105598: 0f ab 10 bts %edx,(%eax)
for (unsigned int i = 0; i < 2 * max_pages - 1; ++ i) {
if (IS_POWER_OF_2(i + 1)) node_size /= 2;
buddy_longest[i] = node_size;
}
for (int i = 0; i < longest_array_pages; ++ i) {
10559b: 83 45 e4 01 addl $0x1,-0x1c(%ebp)
10559f: 8b 45 e4 mov -0x1c(%ebp),%eax
1055a2: 3b 45 dc cmp -0x24(%ebp),%eax
1055a5: 72 c4 jb 10556b <buddy_init_memmap+0x11c>
struct Page *p = base + i;
SetPageReserved(p);
}
struct Page *p = base + longest_array_pages;
1055a7: 8b 55 dc mov -0x24(%ebp),%edx
1055aa: 89 d0 mov %edx,%eax
1055ac: c1 e0 02 shl $0x2,%eax
1055af: 01 d0 add %edx,%eax
1055b1: c1 e0 02 shl $0x2,%eax
1055b4: 89 c2 mov %eax,%edx
1055b6: 8b 45 08 mov 0x8(%ebp),%eax
1055b9: 01 d0 add %edx,%eax
1055bb: 89 45 e0 mov %eax,-0x20(%ebp)
buddy_allocatable_base = p;
1055be: 8b 45 e0 mov -0x20(%ebp),%eax
1055c1: a3 54 a9 11 00 mov %eax,0x11a954
for (; p != base + n; p ++) {
1055c6: e9 88 00 00 00 jmp 105653 <buddy_init_memmap+0x204>
assert(PageReserved(p));
1055cb: 8b 45 e0 mov -0x20(%ebp),%eax
1055ce: 83 c0 04 add $0x4,%eax
1055d1: c7 45 cc 00 00 00 00 movl $0x0,-0x34(%ebp)
1055d8: 89 45 b8 mov %eax,-0x48(%ebp)
* @addr: the address to count from
* */
static inline bool
test_bit(int nr, volatile void *addr) {
int oldbit;
asm volatile ("btl %2, %1; sbbl %0,%0" : "=r" (oldbit) : "m" (*(volatile long *)addr), "Ir" (nr));
1055db: 8b 45 b8 mov -0x48(%ebp),%eax
1055de: 8b 55 cc mov -0x34(%ebp),%edx
1055e1: 0f a3 10 bt %edx,(%eax)
1055e4: 19 c0 sbb %eax,%eax
1055e6: 89 45 b4 mov %eax,-0x4c(%ebp)
return oldbit != 0;
1055e9: 83 7d b4 00 cmpl $0x0,-0x4c(%ebp)
1055ed: 0f 95 c0 setne %al
1055f0: 0f b6 c0 movzbl %al,%eax
1055f3: 85 c0 test %eax,%eax
1055f5: 75 16 jne 10560d <buddy_init_memmap+0x1be>
1055f7: 68 b7 7b 10 00 push $0x107bb7
1055fc: 68 22 7b 10 00 push $0x107b22
105601: 6a 47 push $0x47
105603: 68 37 7b 10 00 push $0x107b37
105608: e8 c0 ad ff ff call 1003cd <__panic>
ClearPageReserved(p);
10560d: 8b 45 e0 mov -0x20(%ebp),%eax
105610: 83 c0 04 add $0x4,%eax
105613: c7 45 c4 00 00 00 00 movl $0x0,-0x3c(%ebp)
10561a: 89 45 ac mov %eax,-0x54(%ebp)
* @nr: the bit to clear
* @addr: the address to start counting from
* */
static inline void
clear_bit(int nr, volatile void *addr) {
asm volatile ("btrl %1, %0" :"=m" (*(volatile long *)addr) : "Ir" (nr));
10561d: 8b 45 ac mov -0x54(%ebp),%eax
105620: 8b 55 c4 mov -0x3c(%ebp),%edx
105623: 0f b3 10 btr %edx,(%eax)
SetPageProperty(p);
105626: 8b 45 e0 mov -0x20(%ebp),%eax
105629: 83 c0 04 add $0x4,%eax
10562c: c7 45 c8 01 00 00 00 movl $0x1,-0x38(%ebp)
105633: 89 45 b0 mov %eax,-0x50(%ebp)
* Note that @nr may be almost arbitrarily large; this function is not
* restricted to acting on a single-word quantity.
* */
static inline void
set_bit(int nr, volatile void *addr) {
asm volatile ("btsl %1, %0" :"=m" (*(volatile long *)addr) : "Ir" (nr));
105636: 8b 45 b0 mov -0x50(%ebp),%eax
105639: 8b 55 c8 mov -0x38(%ebp),%edx
10563c: 0f ab 10 bts %edx,(%eax)
set_page_ref(p, 0);
10563f: 83 ec 08 sub $0x8,%esp
105642: 6a 00 push $0x0
105644: ff 75 e0 pushl -0x20(%ebp)
105647: e8 a4 fd ff ff call 1053f0 <set_page_ref>
10564c: 83 c4 10 add $0x10,%esp
SetPageReserved(p);
}
struct Page *p = base + longest_array_pages;
buddy_allocatable_base = p;
for (; p != base + n; p ++) {
10564f: 83 45 e0 14 addl $0x14,-0x20(%ebp)
105653: 8b 55 0c mov 0xc(%ebp),%edx
105656: 89 d0 mov %edx,%eax
105658: c1 e0 02 shl $0x2,%eax
10565b: 01 d0 add %edx,%eax
10565d: c1 e0 02 shl $0x2,%eax
105660: 89 c2 mov %eax,%edx
105662: 8b 45 08 mov 0x8(%ebp),%eax
105665: 01 d0 add %edx,%eax
105667: 3b 45 e0 cmp -0x20(%ebp),%eax
10566a: 0f 85 5b ff ff ff jne 1055cb <buddy_init_memmap+0x17c>
assert(PageReserved(p));
ClearPageReserved(p);
SetPageProperty(p);
set_page_ref(p, 0);
}
}
105670: 90 nop
105671: c9 leave
105672: c3 ret
00105673 <buddy_fix_size>:
static size_t
buddy_fix_size(size_t before) {
105673: 55 push %ebp
105674: 89 e5 mov %esp,%ebp
105676: 83 ec 10 sub $0x10,%esp
unsigned int ffz = buddy_find_first_zero(before) + 1;
105679: ff 75 08 pushl 0x8(%ebp)
10567c: e8 7d fd ff ff call 1053fe <buddy_find_first_zero>
105681: 83 c4 04 add $0x4,%esp
105684: 83 c0 01 add $0x1,%eax
105687: 89 45 fc mov %eax,-0x4(%ebp)
return (1 << ffz);
10568a: 8b 45 fc mov -0x4(%ebp),%eax
10568d: ba 01 00 00 00 mov $0x1,%edx
105692: 89 c1 mov %eax,%ecx
105694: d3 e2 shl %cl,%edx
105696: 89 d0 mov %edx,%eax
}
105698: c9 leave
105699: c3 ret
0010569a <buddy_alloc_pages>:
static struct Page *
buddy_alloc_pages(size_t n) {
10569a: 55 push %ebp
10569b: 89 e5 mov %esp,%ebp
10569d: 53 push %ebx
10569e: 83 ec 24 sub $0x24,%esp
assert(n > 0);
1056a1: 83 7d 08 00 cmpl $0x0,0x8(%ebp)
1056a5: 75 16 jne 1056bd <buddy_alloc_pages+0x23>
1056a7: 68 1c 7b 10 00 push $0x107b1c
1056ac: 68 22 7b 10 00 push $0x107b22
1056b1: 6a 56 push $0x56
1056b3: 68 37 7b 10 00 push $0x107b37
1056b8: e8 10 ad ff ff call 1003cd <__panic>
if (!IS_POWER_OF_2(n)) {
1056bd: 8b 45 08 mov 0x8(%ebp),%eax
1056c0: 83 e8 01 sub $0x1,%eax
1056c3: 23 45 08 and 0x8(%ebp),%eax
1056c6: 85 c0 test %eax,%eax
1056c8: 74 11 je 1056db <buddy_alloc_pages+0x41>
n = buddy_fix_size(n);
1056ca: 83 ec 0c sub $0xc,%esp
1056cd: ff 75 08 pushl 0x8(%ebp)
1056d0: e8 9e ff ff ff call 105673 <buddy_fix_size>
1056d5: 83 c4 10 add $0x10,%esp
1056d8: 89 45 08 mov %eax,0x8(%ebp)
}
if (n > buddy_longest[0]) {
1056db: a1 4c a9 11 00 mov 0x11a94c,%eax
1056e0: 8b 00 mov (%eax),%eax
1056e2: 3b 45 08 cmp 0x8(%ebp),%eax
1056e5: 73 0a jae 1056f1 <buddy_alloc_pages+0x57>
return NULL;
1056e7: b8 00 00 00 00 mov $0x0,%eax
1056ec: e9 17 01 00 00 jmp 105808 <buddy_alloc_pages+0x16e>
}
// Find the top node for allocation.
// Starting from root
unsigned int index = 0;
1056f1: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp)
// The size of current node
unsigned int node_size;
// go from the root and find the most suitable position
for (node_size = buddy_max_pages; node_size != n; node_size /= 2) {
1056f8: a1 50 a9 11 00 mov 0x11a950,%eax
1056fd: 89 45 f0 mov %eax,-0x10(%ebp)
105700: eb 37 jmp 105739 <buddy_alloc_pages+0x9f>
if (buddy_longest[LEFT_LEAF(index)] >= n) {
105702: a1 4c a9 11 00 mov 0x11a94c,%eax
105707: 8b 55 f4 mov -0xc(%ebp),%edx
10570a: c1 e2 03 shl $0x3,%edx
10570d: 83 c2 04 add $0x4,%edx
105710: 01 d0 add %edx,%eax
105712: 8b 00 mov (%eax),%eax
105714: 3b 45 08 cmp 0x8(%ebp),%eax
105717: 72 0d jb 105726 <buddy_alloc_pages+0x8c>
index = LEFT_LEAF(index);
105719: 8b 45 f4 mov -0xc(%ebp),%eax
10571c: 01 c0 add %eax,%eax
10571e: 83 c0 01 add $0x1,%eax
105721: 89 45 f4 mov %eax,-0xc(%ebp)
105724: eb 0b jmp 105731 <buddy_alloc_pages+0x97>
} else {
index = RIGHT_LEAF(index);
105726: 8b 45 f4 mov -0xc(%ebp),%eax
105729: 83 c0 01 add $0x1,%eax
10572c: 01 c0 add %eax,%eax
10572e: 89 45 f4 mov %eax,-0xc(%ebp)
unsigned int index = 0;
// The size of current node
unsigned int node_size;
// go from the root and find the most suitable position
for (node_size = buddy_max_pages; node_size != n; node_size /= 2) {
105731: 8b 45 f0 mov -0x10(%ebp),%eax
105734: d1 e8 shr %eax
105736: 89 45 f0 mov %eax,-0x10(%ebp)
105739: 8b 45 f0 mov -0x10(%ebp),%eax
10573c: 3b 45 08 cmp 0x8(%ebp),%eax
10573f: 75 c1 jne 105702 <buddy_alloc_pages+0x68>
index = RIGHT_LEAF(index);
}
}
// Allocate all pages under this node.
buddy_longest[index] = 0;
105741: a1 4c a9 11 00 mov 0x11a94c,%eax
105746: 8b 55 f4 mov -0xc(%ebp),%edx
105749: c1 e2 02 shl $0x2,%edx
10574c: 01 d0 add %edx,%eax
10574e: c7 00 00 00 00 00 movl $0x0,(%eax)
struct Page* new_page = buddy_node_index_to_page(index, node_size);
105754: 83 ec 08 sub $0x8,%esp
105757: ff 75 f0 pushl -0x10(%ebp)
10575a: ff 75 f4 pushl -0xc(%ebp)
10575d: e8 bd fc ff ff call 10541f <buddy_node_index_to_page>
105762: 83 c4 10 add $0x10,%esp
105765: 89 45 e8 mov %eax,-0x18(%ebp)
for (struct Page* p = new_page; p != (new_page + node_size); ++ p) {
105768: 8b 45 e8 mov -0x18(%ebp),%eax
10576b: 89 45 ec mov %eax,-0x14(%ebp)
10576e: eb 2d jmp 10579d <buddy_alloc_pages+0x103>
// Set new allocated page ref = 0;
set_page_ref(p, 0);
105770: 83 ec 08 sub $0x8,%esp
105773: 6a 00 push $0x0
105775: ff 75 ec pushl -0x14(%ebp)
105778: e8 73 fc ff ff call 1053f0 <set_page_ref>
10577d: 83 c4 10 add $0x10,%esp
// Set property = not free.
ClearPageProperty(p);
105780: 8b 45 ec mov -0x14(%ebp),%eax
105783: 83 c0 04 add $0x4,%eax
105786: c7 45 e4 01 00 00 00 movl $0x1,-0x1c(%ebp)
10578d: 89 45 e0 mov %eax,-0x20(%ebp)
* @nr: the bit to clear
* @addr: the address to start counting from
* */
static inline void
clear_bit(int nr, volatile void *addr) {
asm volatile ("btrl %1, %0" :"=m" (*(volatile long *)addr) : "Ir" (nr));
105790: 8b 45 e0 mov -0x20(%ebp),%eax
105793: 8b 55 e4 mov -0x1c(%ebp),%edx
105796: 0f b3 10 btr %edx,(%eax)
}
// Allocate all pages under this node.
buddy_longest[index] = 0;
struct Page* new_page = buddy_node_index_to_page(index, node_size);
for (struct Page* p = new_page; p != (new_page + node_size); ++ p) {
105799: 83 45 ec 14 addl $0x14,-0x14(%ebp)
10579d: 8b 55 f0 mov -0x10(%ebp),%edx
1057a0: 89 d0 mov %edx,%eax
1057a2: c1 e0 02 shl $0x2,%eax
1057a5: 01 d0 add %edx,%eax
1057a7: c1 e0 02 shl $0x2,%eax
1057aa: 89 c2 mov %eax,%edx
1057ac: 8b 45 e8 mov -0x18(%ebp),%eax
1057af: 01 d0 add %edx,%eax
1057b1: 3b 45 ec cmp -0x14(%ebp),%eax
1057b4: 75 ba jne 105770 <buddy_alloc_pages+0xd6>
// Set property = not free.
ClearPageProperty(p);
}
// Update parent longest value because this node is used.
while (index) {
1057b6: eb 47 jmp 1057ff <buddy_alloc_pages+0x165>
index = PARENT(index);
1057b8: 8b 45 f4 mov -0xc(%ebp),%eax
1057bb: 83 c0 01 add $0x1,%eax
1057be: d1 e8 shr %eax
1057c0: 83 e8 01 sub $0x1,%eax
1057c3: 89 45 f4 mov %eax,-0xc(%ebp)
buddy_longest[index] =
1057c6: a1 4c a9 11 00 mov 0x11a94c,%eax
1057cb: 8b 55 f4 mov -0xc(%ebp),%edx
1057ce: c1 e2 02 shl $0x2,%edx
1057d1: 8d 0c 10 lea (%eax,%edx,1),%ecx
MAX(buddy_longest[LEFT_LEAF(index)], buddy_longest[RIGHT_LEAF(index)]);
1057d4: a1 4c a9 11 00 mov 0x11a94c,%eax
1057d9: 8b 55 f4 mov -0xc(%ebp),%edx
1057dc: 83 c2 01 add $0x1,%edx
1057df: c1 e2 03 shl $0x3,%edx
1057e2: 01 d0 add %edx,%eax
1057e4: 8b 10 mov (%eax),%edx
1057e6: a1 4c a9 11 00 mov 0x11a94c,%eax
1057eb: 8b 5d f4 mov -0xc(%ebp),%ebx
1057ee: c1 e3 03 shl $0x3,%ebx
1057f1: 83 c3 04 add $0x4,%ebx
1057f4: 01 d8 add %ebx,%eax
1057f6: 8b 00 mov (%eax),%eax
1057f8: 39 c2 cmp %eax,%edx
1057fa: 0f 43 c2 cmovae %edx,%eax
}
// Update parent longest value because this node is used.
while (index) {
index = PARENT(index);
buddy_longest[index] =
1057fd: 89 01 mov %eax,(%ecx)
// Set property = not free.
ClearPageProperty(p);
}
// Update parent longest value because this node is used.
while (index) {
1057ff: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
105803: 75 b3 jne 1057b8 <buddy_alloc_pages+0x11e>
index = PARENT(index);
buddy_longest[index] =
MAX(buddy_longest[LEFT_LEAF(index)], buddy_longest[RIGHT_LEAF(index)]);
}
return new_page;
105805: 8b 45 e8 mov -0x18(%ebp),%eax
}
105808: 8b 5d fc mov -0x4(%ebp),%ebx
10580b: c9 leave
10580c: c3 ret
0010580d <buddy_free_pages>:
static void
buddy_free_pages(struct Page *base, size_t n) {
10580d: 55 push %ebp
10580e: 89 e5 mov %esp,%ebp
105810: 83 ec 48 sub $0x48,%esp
assert(n > 0);
105813: 83 7d 0c 00 cmpl $0x0,0xc(%ebp)
105817: 75 19 jne 105832 <buddy_free_pages+0x25>
105819: 68 1c 7b 10 00 push $0x107b1c
10581e: 68 22 7b 10 00 push $0x107b22
105823: 68 82 00 00 00 push $0x82
105828: 68 37 7b 10 00 push $0x107b37
10582d: e8 9b ab ff ff call 1003cd <__panic>
// Find the base-correponded node and its size;
unsigned int index = (unsigned int)(base - buddy_allocatable_base) + buddy_max_pages - 1;
105832: 8b 45 08 mov 0x8(%ebp),%eax
105835: 8b 15 54 a9 11 00 mov 0x11a954,%edx
10583b: 29 d0 sub %edx,%eax
10583d: c1 f8 02 sar $0x2,%eax
105840: 69 c0 cd cc cc cc imul $0xcccccccd,%eax,%eax
105846: 89 c2 mov %eax,%edx
105848: a1 50 a9 11 00 mov 0x11a950,%eax
10584d: 01 d0 add %edx,%eax
10584f: 83 e8 01 sub $0x1,%eax
105852: 89 45 f4 mov %eax,-0xc(%ebp)
unsigned int node_size = 1;
105855: c7 45 f0 01 00 00 00 movl $0x1,-0x10(%ebp)
// Starting from the leaf and find the first (lowest) node has longest = 0;
while (buddy_longest[index] != 0) {
10585c: eb 30 jmp 10588e <buddy_free_pages+0x81>
node_size *= 2;
10585e: d1 65 f0 shll -0x10(%ebp)
// cannot find the corresponding node for the base.
assert(index != 0);
105861: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
105865: 75 19 jne 105880 <buddy_free_pages+0x73>
105867: 68 c7 7b 10 00 push $0x107bc7
10586c: 68 22 7b 10 00 push $0x107b22
105871: 68 8b 00 00 00 push $0x8b
105876: 68 37 7b 10 00 push $0x107b37
10587b: e8 4d ab ff ff call 1003cd <__panic>
index = PARENT(index);
105880: 8b 45 f4 mov -0xc(%ebp),%eax
105883: 83 c0 01 add $0x1,%eax
105886: d1 e8 shr %eax
105888: 83 e8 01 sub $0x1,%eax
10588b: 89 45 f4 mov %eax,-0xc(%ebp)
// Find the base-correponded node and its size;
unsigned int index = (unsigned int)(base - buddy_allocatable_base) + buddy_max_pages - 1;
unsigned int node_size = 1;
// Starting from the leaf and find the first (lowest) node has longest = 0;
while (buddy_longest[index] != 0) {
10588e: a1 4c a9 11 00 mov 0x11a94c,%eax
105893: 8b 55 f4 mov -0xc(%ebp),%edx
105896: c1 e2 02 shl $0x2,%edx
105899: 01 d0 add %edx,%eax
10589b: 8b 00 mov (%eax),%eax
10589d: 85 c0 test %eax,%eax
10589f: 75 bd jne 10585e <buddy_free_pages+0x51>
// NOTICE: Be careful when releasing memory if the following line is commented.
// assert(node_size == n);
// Free the pages.
struct Page *p = base;
1058a1: 8b 45 08 mov 0x8(%ebp),%eax
1058a4: 89 45 ec mov %eax,-0x14(%ebp)
for (; p != base + n; p ++) {
1058a7: e9 9e 00 00 00 jmp 10594a <buddy_free_pages+0x13d>
assert(!PageReserved(p) && !PageProperty(p));
1058ac: 8b 45 ec mov -0x14(%ebp),%eax
1058af: 83 c0 04 add $0x4,%eax
1058b2: c7 45 d8 00 00 00 00 movl $0x0,-0x28(%ebp)
1058b9: 89 45 d4 mov %eax,-0x2c(%ebp)
* @addr: the address to count from
* */
static inline bool
test_bit(int nr, volatile void *addr) {
int oldbit;
asm volatile ("btl %2, %1; sbbl %0,%0" : "=r" (oldbit) : "m" (*(volatile long *)addr), "Ir" (nr));
1058bc: 8b 45 d4 mov -0x2c(%ebp),%eax
1058bf: 8b 55 d8 mov -0x28(%ebp),%edx
1058c2: 0f a3 10 bt %edx,(%eax)
1058c5: 19 c0 sbb %eax,%eax
1058c7: 89 45 d0 mov %eax,-0x30(%ebp)
return oldbit != 0;
1058ca: 83 7d d0 00 cmpl $0x0,-0x30(%ebp)
1058ce: 0f 95 c0 setne %al
1058d1: 0f b6 c0 movzbl %al,%eax
1058d4: 85 c0 test %eax,%eax
1058d6: 75 2c jne 105904 <buddy_free_pages+0xf7>
1058d8: 8b 45 ec mov -0x14(%ebp),%eax
1058db: 83 c0 04 add $0x4,%eax
1058de: c7 45 e8 01 00 00 00 movl $0x1,-0x18(%ebp)
1058e5: 89 45 cc mov %eax,-0x34(%ebp)
* @addr: the address to count from
* */
static inline bool
test_bit(int nr, volatile void *addr) {
int oldbit;
asm volatile ("btl %2, %1; sbbl %0,%0" : "=r" (oldbit) : "m" (*(volatile long *)addr), "Ir" (nr));
1058e8: 8b 45 cc mov -0x34(%ebp),%eax
1058eb: 8b 55 e8 mov -0x18(%ebp),%edx
1058ee: 0f a3 10 bt %edx,(%eax)
1058f1: 19 c0 sbb %eax,%eax
1058f3: 89 45 c8 mov %eax,-0x38(%ebp)
return oldbit != 0;
1058f6: 83 7d c8 00 cmpl $0x0,-0x38(%ebp)
1058fa: 0f 95 c0 setne %al
1058fd: 0f b6 c0 movzbl %al,%eax
105900: 85 c0 test %eax,%eax
105902: 74 19 je 10591d <buddy_free_pages+0x110>
105904: 68 d4 7b 10 00 push $0x107bd4
105909: 68 22 7b 10 00 push $0x107b22
10590e: 68 95 00 00 00 push $0x95
105913: 68 37 7b 10 00 push $0x107b37
105918: e8 b0 aa ff ff call 1003cd <__panic>
SetPageProperty(p);
10591d: 8b 45 ec mov -0x14(%ebp),%eax
105920: 83 c0 04 add $0x4,%eax
105923: c7 45 e4 01 00 00 00 movl $0x1,-0x1c(%ebp)
10592a: 89 45 c4 mov %eax,-0x3c(%ebp)
* Note that @nr may be almost arbitrarily large; this function is not
* restricted to acting on a single-word quantity.
* */
static inline void
set_bit(int nr, volatile void *addr) {
asm volatile ("btsl %1, %0" :"=m" (*(volatile long *)addr) : "Ir" (nr));
10592d: 8b 45 c4 mov -0x3c(%ebp),%eax
105930: 8b 55 e4 mov -0x1c(%ebp),%edx
105933: 0f ab 10 bts %edx,(%eax)
set_page_ref(p, 0);
105936: 83 ec 08 sub $0x8,%esp
105939: 6a 00 push $0x0
10593b: ff 75 ec pushl -0x14(%ebp)
10593e: e8 ad fa ff ff call 1053f0 <set_page_ref>
105943: 83 c4 10 add $0x10,%esp
// NOTICE: Be careful when releasing memory if the following line is commented.
// assert(node_size == n);
// Free the pages.
struct Page *p = base;
for (; p != base + n; p ++) {
105946: 83 45 ec 14 addl $0x14,-0x14(%ebp)
10594a: 8b 55 0c mov 0xc(%ebp),%edx
10594d: 89 d0 mov %edx,%eax
10594f: c1 e0 02 shl $0x2,%eax
105952: 01 d0 add %edx,%eax
105954: c1 e0 02 shl $0x2,%eax
105957: 89 c2 mov %eax,%edx
105959: 8b 45 08 mov 0x8(%ebp),%eax
10595c: 01 d0 add %edx,%eax
10595e: 3b 45 ec cmp -0x14(%ebp),%eax
105961: 0f 85 45 ff ff ff jne 1058ac <buddy_free_pages+0x9f>
SetPageProperty(p);
set_page_ref(p, 0);
}
// Update longest.
buddy_longest[index] = node_size;
105967: a1 4c a9 11 00 mov 0x11a94c,%eax
10596c: 8b 55 f4 mov -0xc(%ebp),%edx
10596f: c1 e2 02 shl $0x2,%edx
105972: 01 c2 add %eax,%edx
105974: 8b 45 f0 mov -0x10(%ebp),%eax
105977: 89 02 mov %eax,(%edx)
while (index != 0) {
105979: eb 75 jmp 1059f0 <buddy_free_pages+0x1e3>
// Starting from this node, try to merge all the way to parent.
// The condition for merging is (left_child + right_child = node_size)
index = PARENT(index);
10597b: 8b 45 f4 mov -0xc(%ebp),%eax
10597e: 83 c0 01 add $0x1,%eax
105981: d1 e8 shr %eax
105983: 83 e8 01 sub $0x1,%eax
105986: 89 45 f4 mov %eax,-0xc(%ebp)
node_size *= 2;
105989: d1 65 f0 shll -0x10(%ebp)
unsigned int left_longest = buddy_longest[LEFT_LEAF(index)];
10598c: a1 4c a9 11 00 mov 0x11a94c,%eax
105991: 8b 55 f4 mov -0xc(%ebp),%edx
105994: c1 e2 03 shl $0x3,%edx
105997: 83 c2 04 add $0x4,%edx
10599a: 01 d0 add %edx,%eax
10599c: 8b 00 mov (%eax),%eax
10599e: 89 45 e0 mov %eax,-0x20(%ebp)
unsigned int right_longest = buddy_longest[RIGHT_LEAF(index)];
1059a1: a1 4c a9 11 00 mov 0x11a94c,%eax
1059a6: 8b 55 f4 mov -0xc(%ebp),%edx
1059a9: 83 c2 01 add $0x1,%edx
1059ac: c1 e2 03 shl $0x3,%edx
1059af: 01 d0 add %edx,%eax
1059b1: 8b 00 mov (%eax),%eax
1059b3: 89 45 dc mov %eax,-0x24(%ebp)
if (left_longest + right_longest == node_size) {
1059b6: 8b 55 e0 mov -0x20(%ebp),%edx
1059b9: 8b 45 dc mov -0x24(%ebp),%eax
1059bc: 01 d0 add %edx,%eax
1059be: 3b 45 f0 cmp -0x10(%ebp),%eax
1059c1: 75 14 jne 1059d7 <buddy_free_pages+0x1ca>
buddy_longest[index] = node_size;
1059c3: a1 4c a9 11 00 mov 0x11a94c,%eax
1059c8: 8b 55 f4 mov -0xc(%ebp),%edx
1059cb: c1 e2 02 shl $0x2,%edx
1059ce: 01 c2 add %eax,%edx
1059d0: 8b 45 f0 mov -0x10(%ebp),%eax
1059d3: 89 02 mov %eax,(%edx)
1059d5: eb 19 jmp 1059f0 <buddy_free_pages+0x1e3>
} else {
// update because the child is updated.
buddy_longest[index] = MAX(left_longest, right_longest);
1059d7: a1 4c a9 11 00 mov 0x11a94c,%eax
1059dc: 8b 55 f4 mov -0xc(%ebp),%edx
1059df: c1 e2 02 shl $0x2,%edx
1059e2: 01 c2 add %eax,%edx
1059e4: 8b 45 e0 mov -0x20(%ebp),%eax
1059e7: 39 45 dc cmp %eax,-0x24(%ebp)
1059ea: 0f 43 45 dc cmovae -0x24(%ebp),%eax
1059ee: 89 02 mov %eax,(%edx)
set_page_ref(p, 0);
}
// Update longest.
buddy_longest[index] = node_size;
while (index != 0) {
1059f0: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
1059f4: 75 85 jne 10597b <buddy_free_pages+0x16e>
} else {
// update because the child is updated.
buddy_longest[index] = MAX(left_longest, right_longest);
}
}
}
1059f6: 90 nop
1059f7: c9 leave
1059f8: c3 ret
001059f9 <buddy_nr_free_pages>:
static size_t
buddy_nr_free_pages(void) {
1059f9: 55 push %ebp
1059fa: 89 e5 mov %esp,%ebp
return buddy_longest[0];
1059fc: a1 4c a9 11 00 mov 0x11a94c,%eax
105a01: 8b 00 mov (%eax),%eax
}
105a03: 5d pop %ebp
105a04: c3 ret
00105a05 <buddy_check>:
static void
buddy_check(void) {
105a05: 55 push %ebp
105a06: 89 e5 mov %esp,%ebp
105a08: 81 ec 98 00 00 00 sub $0x98,%esp
int all_pages = nr_free_pages();
105a0e: e8 cf d3 ff ff call 102de2 <nr_free_pages>
105a13: 89 45 f4 mov %eax,-0xc(%ebp)
struct Page* p0, *p1, *p2, *p3, *p4;
assert(alloc_pages(all_pages + 1) == NULL);
105a16: 8b 45 f4 mov -0xc(%ebp),%eax
105a19: 83 c0 01 add $0x1,%eax
105a1c: 83 ec 0c sub $0xc,%esp
105a1f: 50 push %eax
105a20: e8 4a d3 ff ff call 102d6f <alloc_pages>
105a25: 83 c4 10 add $0x10,%esp
105a28: 85 c0 test %eax,%eax
105a2a: 74 19 je 105a45 <buddy_check+0x40>
105a2c: 68 fc 7b 10 00 push $0x107bfc
105a31: 68 22 7b 10 00 push $0x107b22
105a36: 68 b6 00 00 00 push $0xb6
105a3b: 68 37 7b 10 00 push $0x107b37
105a40: e8 88 a9 ff ff call 1003cd <__panic>
p0 = alloc_pages(1);
105a45: 83 ec 0c sub $0xc,%esp
105a48: 6a 01 push $0x1
105a4a: e8 20 d3 ff ff call 102d6f <alloc_pages>
105a4f: 83 c4 10 add $0x10,%esp
105a52: 89 45 f0 mov %eax,-0x10(%ebp)
assert(p0 != NULL);
105a55: 83 7d f0 00 cmpl $0x0,-0x10(%ebp)
105a59: 75 19 jne 105a74 <buddy_check+0x6f>
105a5b: 68 1f 7c 10 00 push $0x107c1f
105a60: 68 22 7b 10 00 push $0x107b22
105a65: 68 b9 00 00 00 push $0xb9
105a6a: 68 37 7b 10 00 push $0x107b37
105a6f: e8 59 a9 ff ff call 1003cd <__panic>
p1 = alloc_pages(2);
105a74: 83 ec 0c sub $0xc,%esp
105a77: 6a 02 push $0x2
105a79: e8 f1 d2 ff ff call 102d6f <alloc_pages>
105a7e: 83 c4 10 add $0x10,%esp
105a81: 89 45 ec mov %eax,-0x14(%ebp)
assert(p1 == p0 + 2);
105a84: 8b 45 f0 mov -0x10(%ebp),%eax
105a87: 83 c0 28 add $0x28,%eax
105a8a: 3b 45 ec cmp -0x14(%ebp),%eax
105a8d: 74 19 je 105aa8 <buddy_check+0xa3>
105a8f: 68 2a 7c 10 00 push $0x107c2a
105a94: 68 22 7b 10 00 push $0x107b22
105a99: 68 bb 00 00 00 push $0xbb
105a9e: 68 37 7b 10 00 push $0x107b37
105aa3: e8 25 a9 ff ff call 1003cd <__panic>
assert(!PageReserved(p0) && !PageReserved(p1));
105aa8: 8b 45 f0 mov -0x10(%ebp),%eax
105aab: 83 c0 04 add $0x4,%eax
105aae: c7 45 bc 00 00 00 00 movl $0x0,-0x44(%ebp)
105ab5: 89 45 b8 mov %eax,-0x48(%ebp)
* @addr: the address to count from
* */
static inline bool
test_bit(int nr, volatile void *addr) {
int oldbit;
asm volatile ("btl %2, %1; sbbl %0,%0" : "=r" (oldbit) : "m" (*(volatile long *)addr), "Ir" (nr));
105ab8: 8b 45 b8 mov -0x48(%ebp),%eax
105abb: 8b 55 bc mov -0x44(%ebp),%edx
105abe: 0f a3 10 bt %edx,(%eax)
105ac1: 19 c0 sbb %eax,%eax
105ac3: 89 45 b4 mov %eax,-0x4c(%ebp)
return oldbit != 0;
105ac6: 83 7d b4 00 cmpl $0x0,-0x4c(%ebp)
105aca: 0f 95 c0 setne %al
105acd: 0f b6 c0 movzbl %al,%eax
105ad0: 85 c0 test %eax,%eax
105ad2: 75 2c jne 105b00 <buddy_check+0xfb>
105ad4: 8b 45 ec mov -0x14(%ebp),%eax
105ad7: 83 c0 04 add $0x4,%eax
105ada: c7 45 e8 00 00 00 00 movl $0x0,-0x18(%ebp)
105ae1: 89 45 b0 mov %eax,-0x50(%ebp)
* @addr: the address to count from
* */
static inline bool
test_bit(int nr, volatile void *addr) {
int oldbit;
asm volatile ("btl %2, %1; sbbl %0,%0" : "=r" (oldbit) : "m" (*(volatile long *)addr), "Ir" (nr));
105ae4: 8b 45 b0 mov -0x50(%ebp),%eax
105ae7: 8b 55 e8 mov -0x18(%ebp),%edx
105aea: 0f a3 10 bt %edx,(%eax)
105aed: 19 c0 sbb %eax,%eax
105aef: 89 45 ac mov %eax,-0x54(%ebp)
return oldbit != 0;
105af2: 83 7d ac 00 cmpl $0x0,-0x54(%ebp)
105af6: 0f 95 c0 setne %al
105af9: 0f b6 c0 movzbl %al,%eax
105afc: 85 c0 test %eax,%eax
105afe: 74 19 je 105b19 <buddy_check+0x114>
105b00: 68 38 7c 10 00 push $0x107c38
105b05: 68 22 7b 10 00 push $0x107b22
105b0a: 68 bc 00 00 00 push $0xbc
105b0f: 68 37 7b 10 00 push $0x107b37
105b14: e8 b4 a8 ff ff call 1003cd <__panic>
assert(!PageProperty(p0) && !PageProperty(p1));
105b19: 8b 45 f0 mov -0x10(%ebp),%eax
105b1c: 83 c0 04 add $0x4,%eax
105b1f: c7 45 e4 01 00 00 00 movl $0x1,-0x1c(%ebp)
105b26: 89 45 a8 mov %eax,-0x58(%ebp)
* @addr: the address to count from
* */
static inline bool
test_bit(int nr, volatile void *addr) {
int oldbit;
asm volatile ("btl %2, %1; sbbl %0,%0" : "=r" (oldbit) : "m" (*(volatile long *)addr), "Ir" (nr));
105b29: 8b 45 a8 mov -0x58(%ebp),%eax
105b2c: 8b 55 e4 mov -0x1c(%ebp),%edx
105b2f: 0f a3 10 bt %edx,(%eax)
105b32: 19 c0 sbb %eax,%eax
105b34: 89 45 a4 mov %eax,-0x5c(%ebp)
return oldbit != 0;
105b37: 83 7d a4 00 cmpl $0x0,-0x5c(%ebp)
105b3b: 0f 95 c0 setne %al
105b3e: 0f b6 c0 movzbl %al,%eax
105b41: 85 c0 test %eax,%eax
105b43: 75 2c jne 105b71 <buddy_check+0x16c>
105b45: 8b 45 ec mov -0x14(%ebp),%eax
105b48: 83 c0 04 add $0x4,%eax
105b4b: c7 45 e0 01 00 00 00 movl $0x1,-0x20(%ebp)
105b52: 89 45 a0 mov %eax,-0x60(%ebp)
* @addr: the address to count from
* */
static inline bool
test_bit(int nr, volatile void *addr) {
int oldbit;
asm volatile ("btl %2, %1; sbbl %0,%0" : "=r" (oldbit) : "m" (*(volatile long *)addr), "Ir" (nr));
105b55: 8b 45 a0 mov -0x60(%ebp),%eax
105b58: 8b 55 e0 mov -0x20(%ebp),%edx
105b5b: 0f a3 10 bt %edx,(%eax)
105b5e: 19 c0 sbb %eax,%eax
105b60: 89 45 9c mov %eax,-0x64(%ebp)
return oldbit != 0;
105b63: 83 7d 9c 00 cmpl $0x0,-0x64(%ebp)
105b67: 0f 95 c0 setne %al
105b6a: 0f b6 c0 movzbl %al,%eax
105b6d: 85 c0 test %eax,%eax
105b6f: 74 19 je 105b8a <buddy_check+0x185>
105b71: 68 60 7c 10 00 push $0x107c60
105b76: 68 22 7b 10 00 push $0x107b22
105b7b: 68 bd 00 00 00 push $0xbd
105b80: 68 37 7b 10 00 push $0x107b37
105b85: e8 43 a8 ff ff call 1003cd <__panic>
p2 = alloc_pages(1);
105b8a: 83 ec 0c sub $0xc,%esp
105b8d: 6a 01 push $0x1
105b8f: e8 db d1 ff ff call 102d6f <alloc_pages>
105b94: 83 c4 10 add $0x10,%esp
105b97: 89 45 d8 mov %eax,-0x28(%ebp)
assert(p2 == p0 + 1);
105b9a: 8b 45 f0 mov -0x10(%ebp),%eax
105b9d: 83 c0 14 add $0x14,%eax
105ba0: 3b 45 d8 cmp -0x28(%ebp),%eax
105ba3: 74 19 je 105bbe <buddy_check+0x1b9>
105ba5: 68 87 7c 10 00 push $0x107c87
105baa: 68 22 7b 10 00 push $0x107b22
105baf: 68 c0 00 00 00 push $0xc0
105bb4: 68 37 7b 10 00 push $0x107b37
105bb9: e8 0f a8 ff ff call 1003cd <__panic>
p3 = alloc_pages(2);
105bbe: 83 ec 0c sub $0xc,%esp
105bc1: 6a 02 push $0x2
105bc3: e8 a7 d1 ff ff call 102d6f <alloc_pages>
105bc8: 83 c4 10 add $0x10,%esp
105bcb: 89 45 d4 mov %eax,-0x2c(%ebp)
assert(p3 == p0 + 4);
105bce: 8b 45 f0 mov -0x10(%ebp),%eax
105bd1: 83 c0 50 add $0x50,%eax
105bd4: 3b 45 d4 cmp -0x2c(%ebp),%eax
105bd7: 74 19 je 105bf2 <buddy_check+0x1ed>
105bd9: 68 94 7c 10 00 push $0x107c94
105bde: 68 22 7b 10 00 push $0x107b22
105be3: 68 c3 00 00 00 push $0xc3
105be8: 68 37 7b 10 00 push $0x107b37
105bed: e8 db a7 ff ff call 1003cd <__panic>
assert(!PageProperty(p3) && !PageProperty(p3 + 1) && PageProperty(p3 + 2));
105bf2: 8b 45 d4 mov -0x2c(%ebp),%eax
105bf5: 83 c0 04 add $0x4,%eax
105bf8: c7 45 dc 01 00 00 00 movl $0x1,-0x24(%ebp)
105bff: 89 45 98 mov %eax,-0x68(%ebp)
* @addr: the address to count from
* */
static inline bool
test_bit(int nr, volatile void *addr) {
int oldbit;
asm volatile ("btl %2, %1; sbbl %0,%0" : "=r" (oldbit) : "m" (*(volatile long *)addr), "Ir" (nr));
105c02: 8b 45 98 mov -0x68(%ebp),%eax
105c05: 8b 55 dc mov -0x24(%ebp),%edx
105c08: 0f a3 10 bt %edx,(%eax)
105c0b: 19 c0 sbb %eax,%eax
105c0d: 89 45 94 mov %eax,-0x6c(%ebp)
return oldbit != 0;
105c10: 83 7d 94 00 cmpl $0x0,-0x6c(%ebp)
105c14: 0f 95 c0 setne %al
105c17: 0f b6 c0 movzbl %al,%eax
105c1a: 85 c0 test %eax,%eax
105c1c: 75 5e jne 105c7c <buddy_check+0x277>
105c1e: 8b 45 d4 mov -0x2c(%ebp),%eax
105c21: 83 c0 14 add $0x14,%eax
105c24: 83 c0 04 add $0x4,%eax
105c27: c7 45 d0 01 00 00 00 movl $0x1,-0x30(%ebp)
105c2e: 89 45 90 mov %eax,-0x70(%ebp)
* @addr: the address to count from
* */
static inline bool
test_bit(int nr, volatile void *addr) {
int oldbit;
asm volatile ("btl %2, %1; sbbl %0,%0" : "=r" (oldbit) : "m" (*(volatile long *)addr), "Ir" (nr));
105c31: 8b 45 90 mov -0x70(%ebp),%eax
105c34: 8b 55 d0 mov -0x30(%ebp),%edx
105c37: 0f a3 10 bt %edx,(%eax)
105c3a: 19 c0 sbb %eax,%eax
105c3c: 89 45 8c mov %eax,-0x74(%ebp)
return oldbit != 0;
105c3f: 83 7d 8c 00 cmpl $0x0,-0x74(%ebp)
105c43: 0f 95 c0 setne %al
105c46: 0f b6 c0 movzbl %al,%eax
105c49: 85 c0 test %eax,%eax
105c4b: 75 2f jne 105c7c <buddy_check+0x277>
105c4d: 8b 45 d4 mov -0x2c(%ebp),%eax
105c50: 83 c0 28 add $0x28,%eax
105c53: 83 c0 04 add $0x4,%eax
105c56: c7 45 cc 01 00 00 00 movl $0x1,-0x34(%ebp)
105c5d: 89 45 88 mov %eax,-0x78(%ebp)
* @addr: the address to count from
* */
static inline bool
test_bit(int nr, volatile void *addr) {
int oldbit;
asm volatile ("btl %2, %1; sbbl %0,%0" : "=r" (oldbit) : "m" (*(volatile long *)addr), "Ir" (nr));
105c60: 8b 45 88 mov -0x78(%ebp),%eax
105c63: 8b 55 cc mov -0x34(%ebp),%edx
105c66: 0f a3 10 bt %edx,(%eax)
105c69: 19 c0 sbb %eax,%eax
105c6b: 89 45 84 mov %eax,-0x7c(%ebp)
return oldbit != 0;
105c6e: 83 7d 84 00 cmpl $0x0,-0x7c(%ebp)
105c72: 0f 95 c0 setne %al
105c75: 0f b6 c0 movzbl %al,%eax
105c78: 85 c0 test %eax,%eax
105c7a: 75 19 jne 105c95 <buddy_check+0x290>
105c7c: 68 a4 7c 10 00 push $0x107ca4
105c81: 68 22 7b 10 00 push $0x107b22
105c86: 68 c4 00 00 00 push $0xc4
105c8b: 68 37 7b 10 00 push $0x107b37
105c90: e8 38 a7 ff ff call 1003cd <__panic>
free_pages(p1, 2);
105c95: 83 ec 08 sub $0x8,%esp
105c98: 6a 02 push $0x2
105c9a: ff 75 ec pushl -0x14(%ebp)
105c9d: e8 0b d1 ff ff call 102dad <free_pages>
105ca2: 83 c4 10 add $0x10,%esp
assert(PageProperty(p1) && PageProperty(p1 + 1));
105ca5: 8b 45 ec mov -0x14(%ebp),%eax
105ca8: 83 c0 04 add $0x4,%eax
105cab: c7 45 c8 01 00 00 00 movl $0x1,-0x38(%ebp)
105cb2: 89 45 80 mov %eax,-0x80(%ebp)
* @addr: the address to count from
* */
static inline bool
test_bit(int nr, volatile void *addr) {
int oldbit;
asm volatile ("btl %2, %1; sbbl %0,%0" : "=r" (oldbit) : "m" (*(volatile long *)addr), "Ir" (nr));
105cb5: 8b 45 80 mov -0x80(%ebp),%eax
105cb8: 8b 55 c8 mov -0x38(%ebp),%edx
105cbb: 0f a3 10 bt %edx,(%eax)
105cbe: 19 c0 sbb %eax,%eax
105cc0: 89 85 7c ff ff ff mov %eax,-0x84(%ebp)
return oldbit != 0;
105cc6: 83 bd 7c ff ff ff 00 cmpl $0x0,-0x84(%ebp)
105ccd: 0f 95 c0 setne %al
105cd0: 0f b6 c0 movzbl %al,%eax
105cd3: 85 c0 test %eax,%eax
105cd5: 74 3b je 105d12 <buddy_check+0x30d>
105cd7: 8b 45 ec mov -0x14(%ebp),%eax
105cda: 83 c0 14 add $0x14,%eax
105cdd: 83 c0 04 add $0x4,%eax
105ce0: c7 45 c4 01 00 00 00 movl $0x1,-0x3c(%ebp)
105ce7: 89 85 78 ff ff ff mov %eax,-0x88(%ebp)
* @addr: the address to count from
* */
static inline bool
test_bit(int nr, volatile void *addr) {
int oldbit;
asm volatile ("btl %2, %1; sbbl %0,%0" : "=r" (oldbit) : "m" (*(volatile long *)addr), "Ir" (nr));
105ced: 8b 85 78 ff ff ff mov -0x88(%ebp),%eax
105cf3: 8b 55 c4 mov -0x3c(%ebp),%edx
105cf6: 0f a3 10 bt %edx,(%eax)
105cf9: 19 c0 sbb %eax,%eax
105cfb: 89 85 74 ff ff ff mov %eax,-0x8c(%ebp)
return oldbit != 0;
105d01: 83 bd 74 ff ff ff 00 cmpl $0x0,-0x8c(%ebp)
105d08: 0f 95 c0 setne %al
105d0b: 0f b6 c0 movzbl %al,%eax
105d0e: 85 c0 test %eax,%eax
105d10: 75 19 jne 105d2b <buddy_check+0x326>
105d12: 68 e8 7c 10 00 push $0x107ce8
105d17: 68 22 7b 10 00 push $0x107b22
105d1c: 68 c7 00 00 00 push $0xc7
105d21: 68 37 7b 10 00 push $0x107b37
105d26: e8 a2 a6 ff ff call 1003cd <__panic>
assert(p1->ref == 0);
105d2b: 8b 45 ec mov -0x14(%ebp),%eax
105d2e: 8b 00 mov (%eax),%eax
105d30: 85 c0 test %eax,%eax
105d32: 74 19 je 105d4d <buddy_check+0x348>
105d34: 68 11 7d 10 00 push $0x107d11
105d39: 68 22 7b 10 00 push $0x107b22
105d3e: 68 c8 00 00 00 push $0xc8
105d43: 68 37 7b 10 00 push $0x107b37
105d48: e8 80 a6 ff ff call 1003cd <__panic>
free_pages(p0, 1);
105d4d: 83 ec 08 sub $0x8,%esp
105d50: 6a 01 push $0x1
105d52: ff 75 f0 pushl -0x10(%ebp)
105d55: e8 53 d0 ff ff call 102dad <free_pages>
105d5a: 83 c4 10 add $0x10,%esp
free_pages(p2, 1);
105d5d: 83 ec 08 sub $0x8,%esp
105d60: 6a 01 push $0x1
105d62: ff 75 d8 pushl -0x28(%ebp)
105d65: e8 43 d0 ff ff call 102dad <free_pages>
105d6a: 83 c4 10 add $0x10,%esp
p4 = alloc_pages(2);
105d6d: 83 ec 0c sub $0xc,%esp
105d70: 6a 02 push $0x2
105d72: e8 f8 cf ff ff call 102d6f <alloc_pages>
105d77: 83 c4 10 add $0x10,%esp
105d7a: 89 45 c0 mov %eax,-0x40(%ebp)
assert(p4 == p0);
105d7d: 8b 45 c0 mov -0x40(%ebp),%eax
105d80: 3b 45 f0 cmp -0x10(%ebp),%eax
105d83: 74 19 je 105d9e <buddy_check+0x399>
105d85: 68 1e 7d 10 00 push $0x107d1e
105d8a: 68 22 7b 10 00 push $0x107b22
105d8f: 68 ce 00 00 00 push $0xce
105d94: 68 37 7b 10 00 push $0x107b37
105d99: e8 2f a6 ff ff call 1003cd <__panic>
free_pages(p4, 2);
105d9e: 83 ec 08 sub $0x8,%esp
105da1: 6a 02 push $0x2
105da3: ff 75 c0 pushl -0x40(%ebp)
105da6: e8 02 d0 ff ff call 102dad <free_pages>
105dab: 83 c4 10 add $0x10,%esp
assert((*(p4 + 1)).ref == 0);
105dae: 8b 45 c0 mov -0x40(%ebp),%eax
105db1: 83 c0 14 add $0x14,%eax
105db4: 8b 00 mov (%eax),%eax
105db6: 85 c0 test %eax,%eax
105db8: 74 19 je 105dd3 <buddy_check+0x3ce>
105dba: 68 27 7d 10 00 push $0x107d27
105dbf: 68 22 7b 10 00 push $0x107b22
105dc4: 68 d0 00 00 00 push $0xd0
105dc9: 68 37 7b 10 00 push $0x107b37
105dce: e8 fa a5 ff ff call 1003cd <__panic>
assert(nr_free_pages() == all_pages / 2);
105dd3: e8 0a d0 ff ff call 102de2 <nr_free_pages>
105dd8: 89 c1 mov %eax,%ecx
105dda: 8b 45 f4 mov -0xc(%ebp),%eax
105ddd: 89 c2 mov %eax,%edx
105ddf: c1 ea 1f shr $0x1f,%edx
105de2: 01 d0 add %edx,%eax
105de4: d1 f8 sar %eax
105de6: 39 c1 cmp %eax,%ecx
105de8: 74 19 je 105e03 <buddy_check+0x3fe>
105dea: 68 3c 7d 10 00 push $0x107d3c
105def: 68 22 7b 10 00 push $0x107b22
105df4: 68 d2 00 00 00 push $0xd2
105df9: 68 37 7b 10 00 push $0x107b37
105dfe: e8 ca a5 ff ff call 1003cd <__panic>
free_pages(p3, 2);
105e03: 83 ec 08 sub $0x8,%esp
105e06: 6a 02 push $0x2
105e08: ff 75 d4 pushl -0x2c(%ebp)
105e0b: e8 9d cf ff ff call 102dad <free_pages>
105e10: 83 c4 10 add $0x10,%esp
p1 = alloc_pages(33);
105e13: 83 ec 0c sub $0xc,%esp
105e16: 6a 21 push $0x21
105e18: e8 52 cf ff ff call 102d6f <alloc_pages>
105e1d: 83 c4 10 add $0x10,%esp
105e20: 89 45 ec mov %eax,-0x14(%ebp)
free_pages(p1, 64);
105e23: 83 ec 08 sub $0x8,%esp
105e26: 6a 40 push $0x40
105e28: ff 75 ec pushl -0x14(%ebp)
105e2b: e8 7d cf ff ff call 102dad <free_pages>
105e30: 83 c4 10 add $0x10,%esp
}
105e33: 90 nop
105e34: c9 leave
105e35: c3 ret
00105e36 <strlen>:
* @s: the input string
*
* The strlen() function returns the length of string @s.
* */
size_t
strlen(const char *s) {
105e36: 55 push %ebp
105e37: 89 e5 mov %esp,%ebp
105e39: 83 ec 10 sub $0x10,%esp
size_t cnt = 0;
105e3c: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%ebp)
while (*s ++ != '\0') {
105e43: eb 04 jmp 105e49 <strlen+0x13>
cnt ++;
105e45: 83 45 fc 01 addl $0x1,-0x4(%ebp)
* The strlen() function returns the length of string @s.
* */
size_t
strlen(const char *s) {
size_t cnt = 0;
while (*s ++ != '\0') {
105e49: 8b 45 08 mov 0x8(%ebp),%eax
105e4c: 8d 50 01 lea 0x1(%eax),%edx
105e4f: 89 55 08 mov %edx,0x8(%ebp)
105e52: 0f b6 00 movzbl (%eax),%eax
105e55: 84 c0 test %al,%al
105e57: 75 ec jne 105e45 <strlen+0xf>
cnt ++;
}
return cnt;
105e59: 8b 45 fc mov -0x4(%ebp),%eax
}
105e5c: c9 leave
105e5d: c3 ret
00105e5e <strnlen>:
* The return value is strlen(s), if that is less than @len, or
* @len if there is no '\0' character among the first @len characters
* pointed by @s.
* */
size_t
strnlen(const char *s, size_t len) {
105e5e: 55 push %ebp
105e5f: 89 e5 mov %esp,%ebp
105e61: 83 ec 10 sub $0x10,%esp
size_t cnt = 0;
105e64: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%ebp)
while (cnt < len && *s ++ != '\0') {
105e6b: eb 04 jmp 105e71 <strnlen+0x13>
cnt ++;
105e6d: 83 45 fc 01 addl $0x1,-0x4(%ebp)
* pointed by @s.
* */
size_t
strnlen(const char *s, size_t len) {
size_t cnt = 0;
while (cnt < len && *s ++ != '\0') {
105e71: 8b 45 fc mov -0x4(%ebp),%eax
105e74: 3b 45 0c cmp 0xc(%ebp),%eax
105e77: 73 10 jae 105e89 <strnlen+0x2b>
105e79: 8b 45 08 mov 0x8(%ebp),%eax
105e7c: 8d 50 01 lea 0x1(%eax),%edx
105e7f: 89 55 08 mov %edx,0x8(%ebp)
105e82: 0f b6 00 movzbl (%eax),%eax
105e85: 84 c0 test %al,%al
105e87: 75 e4 jne 105e6d <strnlen+0xf>
cnt ++;
}
return cnt;
105e89: 8b 45 fc mov -0x4(%ebp),%eax
}
105e8c: c9 leave
105e8d: c3 ret
00105e8e <strcpy>:
* To avoid overflows, the size of array pointed by @dst should be long enough to
* contain the same string as @src (including the terminating null character), and
* should not overlap in memory with @src.
* */
char *
strcpy(char *dst, const char *src) {
105e8e: 55 push %ebp
105e8f: 89 e5 mov %esp,%ebp
105e91: 57 push %edi
105e92: 56 push %esi
105e93: 83 ec 20 sub $0x20,%esp
105e96: 8b 45 08 mov 0x8(%ebp),%eax
105e99: 89 45 f4 mov %eax,-0xc(%ebp)
105e9c: 8b 45 0c mov 0xc(%ebp),%eax
105e9f: 89 45 f0 mov %eax,-0x10(%ebp)
#ifndef __HAVE_ARCH_STRCPY
#define __HAVE_ARCH_STRCPY
static inline char *
__strcpy(char *dst, const char *src) {
int d0, d1, d2;
asm volatile (
105ea2: 8b 55 f0 mov -0x10(%ebp),%edx
105ea5: 8b 45 f4 mov -0xc(%ebp),%eax
105ea8: 89 d1 mov %edx,%ecx
105eaa: 89 c2 mov %eax,%edx
105eac: 89 ce mov %ecx,%esi
105eae: 89 d7 mov %edx,%edi
105eb0: ac lods %ds:(%esi),%al
105eb1: aa stos %al,%es:(%edi)
105eb2: 84 c0 test %al,%al
105eb4: 75 fa jne 105eb0 <strcpy+0x22>
105eb6: 89 fa mov %edi,%edx
105eb8: 89 f1 mov %esi,%ecx
105eba: 89 4d ec mov %ecx,-0x14(%ebp)
105ebd: 89 55 e8 mov %edx,-0x18(%ebp)
105ec0: 89 45 e4 mov %eax,-0x1c(%ebp)
"stosb;"
"testb %%al, %%al;"
"jne 1b;"
: "=&S" (d0), "=&D" (d1), "=&a" (d2)
: "0" (src), "1" (dst) : "memory");
return dst;
105ec3: 8b 45 f4 mov -0xc(%ebp),%eax
#ifdef __HAVE_ARCH_STRCPY
return __strcpy(dst, src);
105ec6: 90 nop
char *p = dst;
while ((*p ++ = *src ++) != '\0')
/* nothing */;
return dst;
#endif /* __HAVE_ARCH_STRCPY */
}
105ec7: 83 c4 20 add $0x20,%esp
105eca: 5e pop %esi
105ecb: 5f pop %edi
105ecc: 5d pop %ebp
105ecd: c3 ret
00105ece <strncpy>:
* @len: maximum number of characters to be copied from @src
*
* The return value is @dst
* */
char *
strncpy(char *dst, const char *src, size_t len) {
105ece: 55 push %ebp
105ecf: 89 e5 mov %esp,%ebp
105ed1: 83 ec 10 sub $0x10,%esp
char *p = dst;
105ed4: 8b 45 08 mov 0x8(%ebp),%eax
105ed7: 89 45 fc mov %eax,-0x4(%ebp)
while (len > 0) {
105eda: eb 21 jmp 105efd <strncpy+0x2f>
if ((*p = *src) != '\0') {
105edc: 8b 45 0c mov 0xc(%ebp),%eax
105edf: 0f b6 10 movzbl (%eax),%edx
105ee2: 8b 45 fc mov -0x4(%ebp),%eax
105ee5: 88 10 mov %dl,(%eax)
105ee7: 8b 45 fc mov -0x4(%ebp),%eax
105eea: 0f b6 00 movzbl (%eax),%eax
105eed: 84 c0 test %al,%al
105eef: 74 04 je 105ef5 <strncpy+0x27>
src ++;
105ef1: 83 45 0c 01 addl $0x1,0xc(%ebp)
}
p ++, len --;
105ef5: 83 45 fc 01 addl $0x1,-0x4(%ebp)
105ef9: 83 6d 10 01 subl $0x1,0x10(%ebp)
* The return value is @dst
* */
char *
strncpy(char *dst, const char *src, size_t len) {
char *p = dst;
while (len > 0) {
105efd: 83 7d 10 00 cmpl $0x0,0x10(%ebp)
105f01: 75 d9 jne 105edc <strncpy+0xe>
if ((*p = *src) != '\0') {
src ++;
}
p ++, len --;
}
return dst;
105f03: 8b 45 08 mov 0x8(%ebp),%eax
}
105f06: c9 leave
105f07: c3 ret
00105f08 <strcmp>:
* - A value greater than zero indicates that the first character that does
* not match has a greater value in @s1 than in @s2;
* - And a value less than zero indicates the opposite.
* */
int
strcmp(const char *s1, const char *s2) {
105f08: 55 push %ebp
105f09: 89 e5 mov %esp,%ebp
105f0b: 57 push %edi
105f0c: 56 push %esi
105f0d: 83 ec 20 sub $0x20,%esp
105f10: 8b 45 08 mov 0x8(%ebp),%eax
105f13: 89 45 f4 mov %eax,-0xc(%ebp)
105f16: 8b 45 0c mov 0xc(%ebp),%eax
105f19: 89 45 f0 mov %eax,-0x10(%ebp)
#ifndef __HAVE_ARCH_STRCMP
#define __HAVE_ARCH_STRCMP
static inline int
__strcmp(const char *s1, const char *s2) {
int d0, d1, ret;
asm volatile (
105f1c: 8b 55 f4 mov -0xc(%ebp),%edx
105f1f: 8b 45 f0 mov -0x10(%ebp),%eax
105f22: 89 d1 mov %edx,%ecx
105f24: 89 c2 mov %eax,%edx
105f26: 89 ce mov %ecx,%esi
105f28: 89 d7 mov %edx,%edi
105f2a: ac lods %ds:(%esi),%al
105f2b: ae scas %es:(%edi),%al
105f2c: 75 08 jne 105f36 <strcmp+0x2e>
105f2e: 84 c0 test %al,%al
105f30: 75 f8 jne 105f2a <strcmp+0x22>
105f32: 31 c0 xor %eax,%eax
105f34: eb 04 jmp 105f3a <strcmp+0x32>
105f36: 19 c0 sbb %eax,%eax
105f38: 0c 01 or $0x1,%al
105f3a: 89 fa mov %edi,%edx
105f3c: 89 f1 mov %esi,%ecx
105f3e: 89 45 ec mov %eax,-0x14(%ebp)
105f41: 89 4d e8 mov %ecx,-0x18(%ebp)
105f44: 89 55 e4 mov %edx,-0x1c(%ebp)
"orb $1, %%al;"
"3:"
: "=a" (ret), "=&S" (d0), "=&D" (d1)
: "1" (s1), "2" (s2)
: "memory");
return ret;
105f47: 8b 45 ec mov -0x14(%ebp),%eax
#ifdef __HAVE_ARCH_STRCMP
return __strcmp(s1, s2);
105f4a: 90 nop
while (*s1 != '\0' && *s1 == *s2) {
s1 ++, s2 ++;
}
return (int)((unsigned char)*s1 - (unsigned char)*s2);
#endif /* __HAVE_ARCH_STRCMP */
}
105f4b: 83 c4 20 add $0x20,%esp
105f4e: 5e pop %esi
105f4f: 5f pop %edi
105f50: 5d pop %ebp
105f51: c3 ret
00105f52 <strncmp>:
* they are equal to each other, it continues with the following pairs until
* the characters differ, until a terminating null-character is reached, or
* until @n characters match in both strings, whichever happens first.
* */
int
strncmp(const char *s1, const char *s2, size_t n) {
105f52: 55 push %ebp
105f53: 89 e5 mov %esp,%ebp
while (n > 0 && *s1 != '\0' && *s1 == *s2) {
105f55: eb 0c jmp 105f63 <strncmp+0x11>
n --, s1 ++, s2 ++;
105f57: 83 6d 10 01 subl $0x1,0x10(%ebp)
105f5b: 83 45 08 01 addl $0x1,0x8(%ebp)
105f5f: 83 45 0c 01 addl $0x1,0xc(%ebp)
* the characters differ, until a terminating null-character is reached, or
* until @n characters match in both strings, whichever happens first.
* */
int
strncmp(const char *s1, const char *s2, size_t n) {
while (n > 0 && *s1 != '\0' && *s1 == *s2) {
105f63: 83 7d 10 00 cmpl $0x0,0x10(%ebp)
105f67: 74 1a je 105f83 <strncmp+0x31>
105f69: 8b 45 08 mov 0x8(%ebp),%eax
105f6c: 0f b6 00 movzbl (%eax),%eax
105f6f: 84 c0 test %al,%al
105f71: 74 10 je 105f83 <strncmp+0x31>
105f73: 8b 45 08 mov 0x8(%ebp),%eax
105f76: 0f b6 10 movzbl (%eax),%edx
105f79: 8b 45 0c mov 0xc(%ebp),%eax
105f7c: 0f b6 00 movzbl (%eax),%eax
105f7f: 38 c2 cmp %al,%dl
105f81: 74 d4 je 105f57 <strncmp+0x5>
n --, s1 ++, s2 ++;
}
return (n == 0) ? 0 : (int)((unsigned char)*s1 - (unsigned char)*s2);
105f83: 83 7d 10 00 cmpl $0x0,0x10(%ebp)
105f87: 74 18 je 105fa1 <strncmp+0x4f>
105f89: 8b 45 08 mov 0x8(%ebp),%eax
105f8c: 0f b6 00 movzbl (%eax),%eax
105f8f: 0f b6 d0 movzbl %al,%edx
105f92: 8b 45 0c mov 0xc(%ebp),%eax
105f95: 0f b6 00 movzbl (%eax),%eax
105f98: 0f b6 c0 movzbl %al,%eax
105f9b: 29 c2 sub %eax,%edx
105f9d: 89 d0 mov %edx,%eax
105f9f: eb 05 jmp 105fa6 <strncmp+0x54>
105fa1: b8 00 00 00 00 mov $0x0,%eax
}
105fa6: 5d pop %ebp
105fa7: c3 ret
00105fa8 <strchr>:
*
* The strchr() function returns a pointer to the first occurrence of
* character in @s. If the value is not found, the function returns 'NULL'.
* */
char *
strchr(const char *s, char c) {
105fa8: 55 push %ebp
105fa9: 89 e5 mov %esp,%ebp
105fab: 83 ec 04 sub $0x4,%esp
105fae: 8b 45 0c mov 0xc(%ebp),%eax
105fb1: 88 45 fc mov %al,-0x4(%ebp)
while (*s != '\0') {
105fb4: eb 14 jmp 105fca <strchr+0x22>
if (*s == c) {
105fb6: 8b 45 08 mov 0x8(%ebp),%eax
105fb9: 0f b6 00 movzbl (%eax),%eax
105fbc: 3a 45 fc cmp -0x4(%ebp),%al
105fbf: 75 05 jne 105fc6 <strchr+0x1e>
return (char *)s;
105fc1: 8b 45 08 mov 0x8(%ebp),%eax
105fc4: eb 13 jmp 105fd9 <strchr+0x31>
}
s ++;
105fc6: 83 45 08 01 addl $0x1,0x8(%ebp)
* The strchr() function returns a pointer to the first occurrence of
* character in @s. If the value is not found, the function returns 'NULL'.
* */
char *
strchr(const char *s, char c) {
while (*s != '\0') {
105fca: 8b 45 08 mov 0x8(%ebp),%eax
105fcd: 0f b6 00 movzbl (%eax),%eax
105fd0: 84 c0 test %al,%al
105fd2: 75 e2 jne 105fb6 <strchr+0xe>
if (*s == c) {
return (char *)s;
}
s ++;
}
return NULL;
105fd4: b8 00 00 00 00 mov $0x0,%eax
}
105fd9: c9 leave
105fda: c3 ret
00105fdb <strfind>:
* The strfind() function is like strchr() except that if @c is
* not found in @s, then it returns a pointer to the null byte at the
* end of @s, rather than 'NULL'.
* */
char *
strfind(const char *s, char c) {
105fdb: 55 push %ebp
105fdc: 89 e5 mov %esp,%ebp
105fde: 83 ec 04 sub $0x4,%esp
105fe1: 8b 45 0c mov 0xc(%ebp),%eax
105fe4: 88 45 fc mov %al,-0x4(%ebp)
while (*s != '\0') {
105fe7: eb 0f jmp 105ff8 <strfind+0x1d>
if (*s == c) {
105fe9: 8b 45 08 mov 0x8(%ebp),%eax
105fec: 0f b6 00 movzbl (%eax),%eax
105fef: 3a 45 fc cmp -0x4(%ebp),%al
105ff2: 74 10 je 106004 <strfind+0x29>
break;
}
s ++;
105ff4: 83 45 08 01 addl $0x1,0x8(%ebp)
* not found in @s, then it returns a pointer to the null byte at the
* end of @s, rather than 'NULL'.
* */
char *
strfind(const char *s, char c) {
while (*s != '\0') {
105ff8: 8b 45 08 mov 0x8(%ebp),%eax
105ffb: 0f b6 00 movzbl (%eax),%eax
105ffe: 84 c0 test %al,%al
106000: 75 e7 jne 105fe9 <strfind+0xe>
106002: eb 01 jmp 106005 <strfind+0x2a>
if (*s == c) {
break;
106004: 90 nop
}
s ++;
}
return (char *)s;
106005: 8b 45 08 mov 0x8(%ebp),%eax
}
106008: c9 leave
106009: c3 ret
0010600a <strtol>:
* an optional "0x" or "0X" prefix.
*
* The strtol() function returns the converted integral number as a long int value.
* */
long
strtol(const char *s, char **endptr, int base) {
10600a: 55 push %ebp
10600b: 89 e5 mov %esp,%ebp
10600d: 83 ec 10 sub $0x10,%esp
int neg = 0;
106010: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%ebp)
long val = 0;
106017: c7 45 f8 00 00 00 00 movl $0x0,-0x8(%ebp)
// gobble initial whitespace
while (*s == ' ' || *s == '\t') {
10601e: eb 04 jmp 106024 <strtol+0x1a>
s ++;
106020: 83 45 08 01 addl $0x1,0x8(%ebp)
strtol(const char *s, char **endptr, int base) {
int neg = 0;
long val = 0;
// gobble initial whitespace
while (*s == ' ' || *s == '\t') {
106024: 8b 45 08 mov 0x8(%ebp),%eax
106027: 0f b6 00 movzbl (%eax),%eax
10602a: 3c 20 cmp $0x20,%al
10602c: 74 f2 je 106020 <strtol+0x16>
10602e: 8b 45 08 mov 0x8(%ebp),%eax
106031: 0f b6 00 movzbl (%eax),%eax
106034: 3c 09 cmp $0x9,%al
106036: 74 e8 je 106020 <strtol+0x16>
s ++;
}
// plus/minus sign
if (*s == '+') {
106038: 8b 45 08 mov 0x8(%ebp),%eax
10603b: 0f b6 00 movzbl (%eax),%eax
10603e: 3c 2b cmp $0x2b,%al
106040: 75 06 jne 106048 <strtol+0x3e>
s ++;
106042: 83 45 08 01 addl $0x1,0x8(%ebp)
106046: eb 15 jmp 10605d <strtol+0x53>
}
else if (*s == '-') {
106048: 8b 45 08 mov 0x8(%ebp),%eax
10604b: 0f b6 00 movzbl (%eax),%eax
10604e: 3c 2d cmp $0x2d,%al
106050: 75 0b jne 10605d <strtol+0x53>
s ++, neg = 1;
106052: 83 45 08 01 addl $0x1,0x8(%ebp)
106056: c7 45 fc 01 00 00 00 movl $0x1,-0x4(%ebp)
}
// hex or octal base prefix
if ((base == 0 || base == 16) && (s[0] == '0' && s[1] == 'x')) {
10605d: 83 7d 10 00 cmpl $0x0,0x10(%ebp)
106061: 74 06 je 106069 <strtol+0x5f>
106063: 83 7d 10 10 cmpl $0x10,0x10(%ebp)
106067: 75 24 jne 10608d <strtol+0x83>
106069: 8b 45 08 mov 0x8(%ebp),%eax
10606c: 0f b6 00 movzbl (%eax),%eax
10606f: 3c 30 cmp $0x30,%al
106071: 75 1a jne 10608d <strtol+0x83>
106073: 8b 45 08 mov 0x8(%ebp),%eax
106076: 83 c0 01 add $0x1,%eax
106079: 0f b6 00 movzbl (%eax),%eax
10607c: 3c 78 cmp $0x78,%al
10607e: 75 0d jne 10608d <strtol+0x83>
s += 2, base = 16;
106080: 83 45 08 02 addl $0x2,0x8(%ebp)
106084: c7 45 10 10 00 00 00 movl $0x10,0x10(%ebp)
10608b: eb 2a jmp 1060b7 <strtol+0xad>
}
else if (base == 0 && s[0] == '0') {
10608d: 83 7d 10 00 cmpl $0x0,0x10(%ebp)
106091: 75 17 jne 1060aa <strtol+0xa0>
106093: 8b 45 08 mov 0x8(%ebp),%eax
106096: 0f b6 00 movzbl (%eax),%eax
106099: 3c 30 cmp $0x30,%al
10609b: 75 0d jne 1060aa <strtol+0xa0>
s ++, base = 8;
10609d: 83 45 08 01 addl $0x1,0x8(%ebp)
1060a1: c7 45 10 08 00 00 00 movl $0x8,0x10(%ebp)
1060a8: eb 0d jmp 1060b7 <strtol+0xad>
}
else if (base == 0) {
1060aa: 83 7d 10 00 cmpl $0x0,0x10(%ebp)
1060ae: 75 07 jne 1060b7 <strtol+0xad>
base = 10;
1060b0: c7 45 10 0a 00 00 00 movl $0xa,0x10(%ebp)
// digits
while (1) {
int dig;
if (*s >= '0' && *s <= '9') {
1060b7: 8b 45 08 mov 0x8(%ebp),%eax
1060ba: 0f b6 00 movzbl (%eax),%eax
1060bd: 3c 2f cmp $0x2f,%al
1060bf: 7e 1b jle 1060dc <strtol+0xd2>
1060c1: 8b 45 08 mov 0x8(%ebp),%eax
1060c4: 0f b6 00 movzbl (%eax),%eax
1060c7: 3c 39 cmp $0x39,%al
1060c9: 7f 11 jg 1060dc <strtol+0xd2>
dig = *s - '0';
1060cb: 8b 45 08 mov 0x8(%ebp),%eax
1060ce: 0f b6 00 movzbl (%eax),%eax
1060d1: 0f be c0 movsbl %al,%eax
1060d4: 83 e8 30 sub $0x30,%eax
1060d7: 89 45 f4 mov %eax,-0xc(%ebp)
1060da: eb 48 jmp 106124 <strtol+0x11a>
}
else if (*s >= 'a' && *s <= 'z') {
1060dc: 8b 45 08 mov 0x8(%ebp),%eax
1060df: 0f b6 00 movzbl (%eax),%eax
1060e2: 3c 60 cmp $0x60,%al
1060e4: 7e 1b jle 106101 <strtol+0xf7>
1060e6: 8b 45 08 mov 0x8(%ebp),%eax
1060e9: 0f b6 00 movzbl (%eax),%eax
1060ec: 3c 7a cmp $0x7a,%al
1060ee: 7f 11 jg 106101 <strtol+0xf7>
dig = *s - 'a' + 10;
1060f0: 8b 45 08 mov 0x8(%ebp),%eax
1060f3: 0f b6 00 movzbl (%eax),%eax
1060f6: 0f be c0 movsbl %al,%eax
1060f9: 83 e8 57 sub $0x57,%eax
1060fc: 89 45 f4 mov %eax,-0xc(%ebp)
1060ff: eb 23 jmp 106124 <strtol+0x11a>
}
else if (*s >= 'A' && *s <= 'Z') {
106101: 8b 45 08 mov 0x8(%ebp),%eax
106104: 0f b6 00 movzbl (%eax),%eax
106107: 3c 40 cmp $0x40,%al
106109: 7e 3c jle 106147 <strtol+0x13d>
10610b: 8b 45 08 mov 0x8(%ebp),%eax
10610e: 0f b6 00 movzbl (%eax),%eax
106111: 3c 5a cmp $0x5a,%al
106113: 7f 32 jg 106147 <strtol+0x13d>
dig = *s - 'A' + 10;
106115: 8b 45 08 mov 0x8(%ebp),%eax
106118: 0f b6 00 movzbl (%eax),%eax
10611b: 0f be c0 movsbl %al,%eax
10611e: 83 e8 37 sub $0x37,%eax
106121: 89 45 f4 mov %eax,-0xc(%ebp)
}
else {
break;
}
if (dig >= base) {
106124: 8b 45 f4 mov -0xc(%ebp),%eax
106127: 3b 45 10 cmp 0x10(%ebp),%eax
10612a: 7d 1a jge 106146 <strtol+0x13c>
break;
}
s ++, val = (val * base) + dig;
10612c: 83 45 08 01 addl $0x1,0x8(%ebp)
106130: 8b 45 f8 mov -0x8(%ebp),%eax
106133: 0f af 45 10 imul 0x10(%ebp),%eax
106137: 89 c2 mov %eax,%edx
106139: 8b 45 f4 mov -0xc(%ebp),%eax
10613c: 01 d0 add %edx,%eax
10613e: 89 45 f8 mov %eax,-0x8(%ebp)
// we don't properly detect overflow!
}
106141: e9 71 ff ff ff jmp 1060b7 <strtol+0xad>
}
else {
break;
}
if (dig >= base) {
break;
106146: 90 nop
}
s ++, val = (val * base) + dig;
// we don't properly detect overflow!
}
if (endptr) {
106147: 83 7d 0c 00 cmpl $0x0,0xc(%ebp)
10614b: 74 08 je 106155 <strtol+0x14b>
*endptr = (char *) s;
10614d: 8b 45 0c mov 0xc(%ebp),%eax
106150: 8b 55 08 mov 0x8(%ebp),%edx
106153: 89 10 mov %edx,(%eax)
}
return (neg ? -val : val);
106155: 83 7d fc 00 cmpl $0x0,-0x4(%ebp)
106159: 74 07 je 106162 <strtol+0x158>
10615b: 8b 45 f8 mov -0x8(%ebp),%eax
10615e: f7 d8 neg %eax
106160: eb 03 jmp 106165 <strtol+0x15b>
106162: 8b 45 f8 mov -0x8(%ebp),%eax
}
106165: c9 leave
106166: c3 ret
00106167 <memset>:
* @n: number of bytes to be set to the value
*
* The memset() function returns @s.
* */
void *
memset(void *s, char c, size_t n) {
106167: 55 push %ebp
106168: 89 e5 mov %esp,%ebp
10616a: 57 push %edi
10616b: 83 ec 24 sub $0x24,%esp
10616e: 8b 45 0c mov 0xc(%ebp),%eax
106171: 88 45 d8 mov %al,-0x28(%ebp)
#ifdef __HAVE_ARCH_MEMSET
return __memset(s, c, n);
106174: 0f be 45 d8 movsbl -0x28(%ebp),%eax
106178: 8b 55 08 mov 0x8(%ebp),%edx
10617b: 89 55 f8 mov %edx,-0x8(%ebp)
10617e: 88 45 f7 mov %al,-0x9(%ebp)
106181: 8b 45 10 mov 0x10(%ebp),%eax
106184: 89 45 f0 mov %eax,-0x10(%ebp)
#ifndef __HAVE_ARCH_MEMSET
#define __HAVE_ARCH_MEMSET
static inline void *
__memset(void *s, char c, size_t n) {
int d0, d1;
asm volatile (
106187: 8b 4d f0 mov -0x10(%ebp),%ecx
10618a: 0f b6 45 f7 movzbl -0x9(%ebp),%eax
10618e: 8b 55 f8 mov -0x8(%ebp),%edx
106191: 89 d7 mov %edx,%edi
106193: f3 aa rep stos %al,%es:(%edi)
106195: 89 fa mov %edi,%edx
106197: 89 4d ec mov %ecx,-0x14(%ebp)
10619a: 89 55 e8 mov %edx,-0x18(%ebp)
"rep; stosb;"
: "=&c" (d0), "=&D" (d1)
: "0" (n), "a" (c), "1" (s)
: "memory");
return s;
10619d: 8b 45 f8 mov -0x8(%ebp),%eax
1061a0: 90 nop
while (n -- > 0) {
*p ++ = c;
}
return s;
#endif /* __HAVE_ARCH_MEMSET */
}
1061a1: 83 c4 24 add $0x24,%esp
1061a4: 5f pop %edi
1061a5: 5d pop %ebp
1061a6: c3 ret
001061a7 <memmove>:
* @n: number of bytes to copy
*
* The memmove() function returns @dst.
* */
void *
memmove(void *dst, const void *src, size_t n) {
1061a7: 55 push %ebp
1061a8: 89 e5 mov %esp,%ebp
1061aa: 57 push %edi
1061ab: 56 push %esi
1061ac: 53 push %ebx
1061ad: 83 ec 30 sub $0x30,%esp
1061b0: 8b 45 08 mov 0x8(%ebp),%eax
1061b3: 89 45 f0 mov %eax,-0x10(%ebp)
1061b6: 8b 45 0c mov 0xc(%ebp),%eax
1061b9: 89 45 ec mov %eax,-0x14(%ebp)
1061bc: 8b 45 10 mov 0x10(%ebp),%eax
1061bf: 89 45 e8 mov %eax,-0x18(%ebp)
#ifndef __HAVE_ARCH_MEMMOVE
#define __HAVE_ARCH_MEMMOVE
static inline void *
__memmove(void *dst, const void *src, size_t n) {
if (dst < src) {
1061c2: 8b 45 f0 mov -0x10(%ebp),%eax
1061c5: 3b 45 ec cmp -0x14(%ebp),%eax
1061c8: 73 42 jae 10620c <memmove+0x65>
1061ca: 8b 45 f0 mov -0x10(%ebp),%eax
1061cd: 89 45 e4 mov %eax,-0x1c(%ebp)
1061d0: 8b 45 ec mov -0x14(%ebp),%eax
1061d3: 89 45 e0 mov %eax,-0x20(%ebp)
1061d6: 8b 45 e8 mov -0x18(%ebp),%eax
1061d9: 89 45 dc mov %eax,-0x24(%ebp)
"andl $3, %%ecx;"
"jz 1f;"
"rep; movsb;"
"1:"
: "=&c" (d0), "=&D" (d1), "=&S" (d2)
: "0" (n / 4), "g" (n), "1" (dst), "2" (src)
1061dc: 8b 45 dc mov -0x24(%ebp),%eax
1061df: c1 e8 02 shr $0x2,%eax
1061e2: 89 c1 mov %eax,%ecx
#ifndef __HAVE_ARCH_MEMCPY
#define __HAVE_ARCH_MEMCPY
static inline void *
__memcpy(void *dst, const void *src, size_t n) {
int d0, d1, d2;
asm volatile (
1061e4: 8b 55 e4 mov -0x1c(%ebp),%edx
1061e7: 8b 45 e0 mov -0x20(%ebp),%eax
1061ea: 89 d7 mov %edx,%edi
1061ec: 89 c6 mov %eax,%esi
1061ee: f3 a5 rep movsl %ds:(%esi),%es:(%edi)
1061f0: 8b 4d dc mov -0x24(%ebp),%ecx
1061f3: 83 e1 03 and $0x3,%ecx
1061f6: 74 02 je 1061fa <memmove+0x53>
1061f8: f3 a4 rep movsb %ds:(%esi),%es:(%edi)
1061fa: 89 f0 mov %esi,%eax
1061fc: 89 fa mov %edi,%edx
1061fe: 89 4d d8 mov %ecx,-0x28(%ebp)
106201: 89 55 d4 mov %edx,-0x2c(%ebp)
106204: 89 45 d0 mov %eax,-0x30(%ebp)
"rep; movsb;"
"1:"
: "=&c" (d0), "=&D" (d1), "=&S" (d2)
: "0" (n / 4), "g" (n), "1" (dst), "2" (src)
: "memory");
return dst;
106207: 8b 45 e4 mov -0x1c(%ebp),%eax
#ifdef __HAVE_ARCH_MEMMOVE
return __memmove(dst, src, n);
10620a: eb 36 jmp 106242 <memmove+0x9b>
asm volatile (
"std;"
"rep; movsb;"
"cld;"
: "=&c" (d0), "=&S" (d1), "=&D" (d2)
: "0" (n), "1" (n - 1 + src), "2" (n - 1 + dst)
10620c: 8b 45 e8 mov -0x18(%ebp),%eax
10620f: 8d 50 ff lea -0x1(%eax),%edx
106212: 8b 45 ec mov -0x14(%ebp),%eax
106215: 01 c2 add %eax,%edx
106217: 8b 45 e8 mov -0x18(%ebp),%eax
10621a: 8d 48 ff lea -0x1(%eax),%ecx
10621d: 8b 45 f0 mov -0x10(%ebp),%eax
106220: 8d 1c 01 lea (%ecx,%eax,1),%ebx
__memmove(void *dst, const void *src, size_t n) {
if (dst < src) {
return __memcpy(dst, src, n);
}
int d0, d1, d2;
asm volatile (
106223: 8b 45 e8 mov -0x18(%ebp),%eax
106226: 89 c1 mov %eax,%ecx
106228: 89 d8 mov %ebx,%eax
10622a: 89 d6 mov %edx,%esi
10622c: 89 c7 mov %eax,%edi
10622e: fd std
10622f: f3 a4 rep movsb %ds:(%esi),%es:(%edi)
106231: fc cld
106232: 89 f8 mov %edi,%eax
106234: 89 f2 mov %esi,%edx
106236: 89 4d cc mov %ecx,-0x34(%ebp)
106239: 89 55 c8 mov %edx,-0x38(%ebp)
10623c: 89 45 c4 mov %eax,-0x3c(%ebp)
"rep; movsb;"
"cld;"
: "=&c" (d0), "=&S" (d1), "=&D" (d2)
: "0" (n), "1" (n - 1 + src), "2" (n - 1 + dst)
: "memory");
return dst;
10623f: 8b 45 f0 mov -0x10(%ebp),%eax
*d ++ = *s ++;
}
}
return dst;
#endif /* __HAVE_ARCH_MEMMOVE */
}
106242: 83 c4 30 add $0x30,%esp
106245: 5b pop %ebx
106246: 5e pop %esi
106247: 5f pop %edi
106248: 5d pop %ebp
106249: c3 ret
0010624a <memcpy>:
* it always copies exactly @n bytes. To avoid overflows, the size of arrays pointed
* by both @src and @dst, should be at least @n bytes, and should not overlap
* (for overlapping memory area, memmove is a safer approach).
* */
void *
memcpy(void *dst, const void *src, size_t n) {
10624a: 55 push %ebp
10624b: 89 e5 mov %esp,%ebp
10624d: 57 push %edi
10624e: 56 push %esi
10624f: 83 ec 20 sub $0x20,%esp
106252: 8b 45 08 mov 0x8(%ebp),%eax
106255: 89 45 f4 mov %eax,-0xc(%ebp)
106258: 8b 45 0c mov 0xc(%ebp),%eax
10625b: 89 45 f0 mov %eax,-0x10(%ebp)
10625e: 8b 45 10 mov 0x10(%ebp),%eax
106261: 89 45 ec mov %eax,-0x14(%ebp)
"andl $3, %%ecx;"
"jz 1f;"
"rep; movsb;"
"1:"
: "=&c" (d0), "=&D" (d1), "=&S" (d2)
: "0" (n / 4), "g" (n), "1" (dst), "2" (src)
106264: 8b 45 ec mov -0x14(%ebp),%eax
106267: c1 e8 02 shr $0x2,%eax
10626a: 89 c1 mov %eax,%ecx
#ifndef __HAVE_ARCH_MEMCPY
#define __HAVE_ARCH_MEMCPY
static inline void *
__memcpy(void *dst, const void *src, size_t n) {
int d0, d1, d2;
asm volatile (
10626c: 8b 55 f4 mov -0xc(%ebp),%edx
10626f: 8b 45 f0 mov -0x10(%ebp),%eax
106272: 89 d7 mov %edx,%edi
106274: 89 c6 mov %eax,%esi
106276: f3 a5 rep movsl %ds:(%esi),%es:(%edi)
106278: 8b 4d ec mov -0x14(%ebp),%ecx
10627b: 83 e1 03 and $0x3,%ecx
10627e: 74 02 je 106282 <memcpy+0x38>
106280: f3 a4 rep movsb %ds:(%esi),%es:(%edi)
106282: 89 f0 mov %esi,%eax
106284: 89 fa mov %edi,%edx
106286: 89 4d e8 mov %ecx,-0x18(%ebp)
106289: 89 55 e4 mov %edx,-0x1c(%ebp)
10628c: 89 45 e0 mov %eax,-0x20(%ebp)
"rep; movsb;"
"1:"
: "=&c" (d0), "=&D" (d1), "=&S" (d2)
: "0" (n / 4), "g" (n), "1" (dst), "2" (src)
: "memory");
return dst;
10628f: 8b 45 f4 mov -0xc(%ebp),%eax
#ifdef __HAVE_ARCH_MEMCPY
return __memcpy(dst, src, n);
106292: 90 nop
while (n -- > 0) {
*d ++ = *s ++;
}
return dst;
#endif /* __HAVE_ARCH_MEMCPY */
}
106293: 83 c4 20 add $0x20,%esp
106296: 5e pop %esi
106297: 5f pop %edi
106298: 5d pop %ebp
106299: c3 ret
0010629a <memcmp>:
* match in both memory blocks has a greater value in @v1 than in @v2
* as if evaluated as unsigned char values;
* - And a value less than zero indicates the opposite.
* */
int
memcmp(const void *v1, const void *v2, size_t n) {
10629a: 55 push %ebp
10629b: 89 e5 mov %esp,%ebp
10629d: 83 ec 10 sub $0x10,%esp
const char *s1 = (const char *)v1;
1062a0: 8b 45 08 mov 0x8(%ebp),%eax
1062a3: 89 45 fc mov %eax,-0x4(%ebp)
const char *s2 = (const char *)v2;
1062a6: 8b 45 0c mov 0xc(%ebp),%eax
1062a9: 89 45 f8 mov %eax,-0x8(%ebp)
while (n -- > 0) {
1062ac: eb 30 jmp 1062de <memcmp+0x44>
if (*s1 != *s2) {
1062ae: 8b 45 fc mov -0x4(%ebp),%eax
1062b1: 0f b6 10 movzbl (%eax),%edx
1062b4: 8b 45 f8 mov -0x8(%ebp),%eax
1062b7: 0f b6 00 movzbl (%eax),%eax
1062ba: 38 c2 cmp %al,%dl
1062bc: 74 18 je 1062d6 <memcmp+0x3c>
return (int)((unsigned char)*s1 - (unsigned char)*s2);
1062be: 8b 45 fc mov -0x4(%ebp),%eax
1062c1: 0f b6 00 movzbl (%eax),%eax
1062c4: 0f b6 d0 movzbl %al,%edx
1062c7: 8b 45 f8 mov -0x8(%ebp),%eax
1062ca: 0f b6 00 movzbl (%eax),%eax
1062cd: 0f b6 c0 movzbl %al,%eax
1062d0: 29 c2 sub %eax,%edx
1062d2: 89 d0 mov %edx,%eax
1062d4: eb 1a jmp 1062f0 <memcmp+0x56>
}
s1 ++, s2 ++;
1062d6: 83 45 fc 01 addl $0x1,-0x4(%ebp)
1062da: 83 45 f8 01 addl $0x1,-0x8(%ebp)
* */
int
memcmp(const void *v1, const void *v2, size_t n) {
const char *s1 = (const char *)v1;
const char *s2 = (const char *)v2;
while (n -- > 0) {
1062de: 8b 45 10 mov 0x10(%ebp),%eax
1062e1: 8d 50 ff lea -0x1(%eax),%edx
1062e4: 89 55 10 mov %edx,0x10(%ebp)
1062e7: 85 c0 test %eax,%eax
1062e9: 75 c3 jne 1062ae <memcmp+0x14>
if (*s1 != *s2) {
return (int)((unsigned char)*s1 - (unsigned char)*s2);
}
s1 ++, s2 ++;
}
return 0;
1062eb: b8 00 00 00 00 mov $0x0,%eax
}
1062f0: c9 leave
1062f1: c3 ret
001062f2 <printnum>:
* @width: maximum number of digits, if the actual width is less than @width, use @padc instead
* @padc: character that padded on the left if the actual width is less than @width
* */
static void
printnum(void (*putch)(int, void*), void *putdat,
unsigned long long num, unsigned base, int width, int padc) {
1062f2: 55 push %ebp
1062f3: 89 e5 mov %esp,%ebp
1062f5: 83 ec 38 sub $0x38,%esp
1062f8: 8b 45 10 mov 0x10(%ebp),%eax
1062fb: 89 45 d0 mov %eax,-0x30(%ebp)
1062fe: 8b 45 14 mov 0x14(%ebp),%eax
106301: 89 45 d4 mov %eax,-0x2c(%ebp)
unsigned long long result = num;
106304: 8b 45 d0 mov -0x30(%ebp),%eax
106307: 8b 55 d4 mov -0x2c(%ebp),%edx
10630a: 89 45 e8 mov %eax,-0x18(%ebp)
10630d: 89 55 ec mov %edx,-0x14(%ebp)
unsigned mod = do_div(result, base);
106310: 8b 45 18 mov 0x18(%ebp),%eax
106313: 89 45 e4 mov %eax,-0x1c(%ebp)
106316: 8b 45 e8 mov -0x18(%ebp),%eax
106319: 8b 55 ec mov -0x14(%ebp),%edx
10631c: 89 45 e0 mov %eax,-0x20(%ebp)
10631f: 89 55 f0 mov %edx,-0x10(%ebp)
106322: 8b 45 f0 mov -0x10(%ebp),%eax
106325: 89 45 f4 mov %eax,-0xc(%ebp)
106328: 83 7d f0 00 cmpl $0x0,-0x10(%ebp)
10632c: 74 1c je 10634a <printnum+0x58>
10632e: 8b 45 f0 mov -0x10(%ebp),%eax
106331: ba 00 00 00 00 mov $0x0,%edx
106336: f7 75 e4 divl -0x1c(%ebp)
106339: 89 55 f4 mov %edx,-0xc(%ebp)
10633c: 8b 45 f0 mov -0x10(%ebp),%eax
10633f: ba 00 00 00 00 mov $0x0,%edx
106344: f7 75 e4 divl -0x1c(%ebp)
106347: 89 45 f0 mov %eax,-0x10(%ebp)
10634a: 8b 45 e0 mov -0x20(%ebp),%eax
10634d: 8b 55 f4 mov -0xc(%ebp),%edx
106350: f7 75 e4 divl -0x1c(%ebp)
106353: 89 45 e0 mov %eax,-0x20(%ebp)
106356: 89 55 dc mov %edx,-0x24(%ebp)
106359: 8b 45 e0 mov -0x20(%ebp),%eax
10635c: 8b 55 f0 mov -0x10(%ebp),%edx
10635f: 89 45 e8 mov %eax,-0x18(%ebp)
106362: 89 55 ec mov %edx,-0x14(%ebp)
106365: 8b 45 dc mov -0x24(%ebp),%eax
106368: 89 45 d8 mov %eax,-0x28(%ebp)
// first recursively print all preceding (more significant) digits
if (num >= base) {
10636b: 8b 45 18 mov 0x18(%ebp),%eax
10636e: ba 00 00 00 00 mov $0x0,%edx
106373: 3b 55 d4 cmp -0x2c(%ebp),%edx
106376: 77 41 ja 1063b9 <printnum+0xc7>
106378: 3b 55 d4 cmp -0x2c(%ebp),%edx
10637b: 72 05 jb 106382 <printnum+0x90>
10637d: 3b 45 d0 cmp -0x30(%ebp),%eax
106380: 77 37 ja 1063b9 <printnum+0xc7>
printnum(putch, putdat, result, base, width - 1, padc);
106382: 8b 45 1c mov 0x1c(%ebp),%eax
106385: 83 e8 01 sub $0x1,%eax
106388: 83 ec 04 sub $0x4,%esp
10638b: ff 75 20 pushl 0x20(%ebp)
10638e: 50 push %eax
10638f: ff 75 18 pushl 0x18(%ebp)
106392: ff 75 ec pushl -0x14(%ebp)
106395: ff 75 e8 pushl -0x18(%ebp)
106398: ff 75 0c pushl 0xc(%ebp)
10639b: ff 75 08 pushl 0x8(%ebp)
10639e: e8 4f ff ff ff call 1062f2 <printnum>
1063a3: 83 c4 20 add $0x20,%esp
1063a6: eb 1b jmp 1063c3 <printnum+0xd1>
} else {
// print any needed pad characters before first digit
while (-- width > 0)
putch(padc, putdat);
1063a8: 83 ec 08 sub $0x8,%esp
1063ab: ff 75 0c pushl 0xc(%ebp)
1063ae: ff 75 20 pushl 0x20(%ebp)
1063b1: 8b 45 08 mov 0x8(%ebp),%eax
1063b4: ff d0 call *%eax
1063b6: 83 c4 10 add $0x10,%esp
// first recursively print all preceding (more significant) digits
if (num >= base) {
printnum(putch, putdat, result, base, width - 1, padc);
} else {
// print any needed pad characters before first digit
while (-- width > 0)
1063b9: 83 6d 1c 01 subl $0x1,0x1c(%ebp)
1063bd: 83 7d 1c 00 cmpl $0x0,0x1c(%ebp)
1063c1: 7f e5 jg 1063a8 <printnum+0xb6>
putch(padc, putdat);
}
// then print this (the least significant) digit
putch("0123456789abcdef"[mod], putdat);
1063c3: 8b 45 d8 mov -0x28(%ebp),%eax
1063c6: 05 0c 7e 10 00 add $0x107e0c,%eax
1063cb: 0f b6 00 movzbl (%eax),%eax
1063ce: 0f be c0 movsbl %al,%eax
1063d1: 83 ec 08 sub $0x8,%esp
1063d4: ff 75 0c pushl 0xc(%ebp)
1063d7: 50 push %eax
1063d8: 8b 45 08 mov 0x8(%ebp),%eax
1063db: ff d0 call *%eax
1063dd: 83 c4 10 add $0x10,%esp
}
1063e0: 90 nop
1063e1: c9 leave
1063e2: c3 ret
001063e3 <getuint>:
* getuint - get an unsigned int of various possible sizes from a varargs list
* @ap: a varargs list pointer
* @lflag: determines the size of the vararg that @ap points to
* */
static unsigned long long
getuint(va_list *ap, int lflag) {
1063e3: 55 push %ebp
1063e4: 89 e5 mov %esp,%ebp
if (lflag >= 2) {
1063e6: 83 7d 0c 01 cmpl $0x1,0xc(%ebp)
1063ea: 7e 14 jle 106400 <getuint+0x1d>
return va_arg(*ap, unsigned long long);
1063ec: 8b 45 08 mov 0x8(%ebp),%eax
1063ef: 8b 00 mov (%eax),%eax
1063f1: 8d 48 08 lea 0x8(%eax),%ecx
1063f4: 8b 55 08 mov 0x8(%ebp),%edx
1063f7: 89 0a mov %ecx,(%edx)
1063f9: 8b 50 04 mov 0x4(%eax),%edx
1063fc: 8b 00 mov (%eax),%eax
1063fe: eb 30 jmp 106430 <getuint+0x4d>
}
else if (lflag) {
106400: 83 7d 0c 00 cmpl $0x0,0xc(%ebp)
106404: 74 16 je 10641c <getuint+0x39>
return va_arg(*ap, unsigned long);
106406: 8b 45 08 mov 0x8(%ebp),%eax
106409: 8b 00 mov (%eax),%eax
10640b: 8d 48 04 lea 0x4(%eax),%ecx
10640e: 8b 55 08 mov 0x8(%ebp),%edx
106411: 89 0a mov %ecx,(%edx)
106413: 8b 00 mov (%eax),%eax
106415: ba 00 00 00 00 mov $0x0,%edx
10641a: eb 14 jmp 106430 <getuint+0x4d>
}
else {
return va_arg(*ap, unsigned int);
10641c: 8b 45 08 mov 0x8(%ebp),%eax
10641f: 8b 00 mov (%eax),%eax
106421: 8d 48 04 lea 0x4(%eax),%ecx
106424: 8b 55 08 mov 0x8(%ebp),%edx
106427: 89 0a mov %ecx,(%edx)
106429: 8b 00 mov (%eax),%eax
10642b: ba 00 00 00 00 mov $0x0,%edx
}
}
106430: 5d pop %ebp
106431: c3 ret
00106432 <getint>:
* getint - same as getuint but signed, we can't use getuint because of sign extension
* @ap: a varargs list pointer
* @lflag: determines the size of the vararg that @ap points to
* */
static long long
getint(va_list *ap, int lflag) {
106432: 55 push %ebp
106433: 89 e5 mov %esp,%ebp
if (lflag >= 2) {
106435: 83 7d 0c 01 cmpl $0x1,0xc(%ebp)
106439: 7e 14 jle 10644f <getint+0x1d>
return va_arg(*ap, long long);
10643b: 8b 45 08 mov 0x8(%ebp),%eax
10643e: 8b 00 mov (%eax),%eax
106440: 8d 48 08 lea 0x8(%eax),%ecx
106443: 8b 55 08 mov 0x8(%ebp),%edx
106446: 89 0a mov %ecx,(%edx)
106448: 8b 50 04 mov 0x4(%eax),%edx
10644b: 8b 00 mov (%eax),%eax
10644d: eb 28 jmp 106477 <getint+0x45>
}
else if (lflag) {
10644f: 83 7d 0c 00 cmpl $0x0,0xc(%ebp)
106453: 74 12 je 106467 <getint+0x35>
return va_arg(*ap, long);
106455: 8b 45 08 mov 0x8(%ebp),%eax
106458: 8b 00 mov (%eax),%eax
10645a: 8d 48 04 lea 0x4(%eax),%ecx
10645d: 8b 55 08 mov 0x8(%ebp),%edx
106460: 89 0a mov %ecx,(%edx)
106462: 8b 00 mov (%eax),%eax
106464: 99 cltd
106465: eb 10 jmp 106477 <getint+0x45>
}
else {
return va_arg(*ap, int);
106467: 8b 45 08 mov 0x8(%ebp),%eax
10646a: 8b 00 mov (%eax),%eax
10646c: 8d 48 04 lea 0x4(%eax),%ecx
10646f: 8b 55 08 mov 0x8(%ebp),%edx
106472: 89 0a mov %ecx,(%edx)
106474: 8b 00 mov (%eax),%eax
106476: 99 cltd
}
}
106477: 5d pop %ebp
106478: c3 ret
00106479 <printfmt>:
* @putch: specified putch function, print a single character
* @putdat: used by @putch function
* @fmt: the format string to use
* */
void
printfmt(void (*putch)(int, void*), void *putdat, const char *fmt, ...) {
106479: 55 push %ebp
10647a: 89 e5 mov %esp,%ebp
10647c: 83 ec 18 sub $0x18,%esp
va_list ap;
va_start(ap, fmt);
10647f: 8d 45 14 lea 0x14(%ebp),%eax
106482: 89 45 f4 mov %eax,-0xc(%ebp)
vprintfmt(putch, putdat, fmt, ap);
106485: 8b 45 f4 mov -0xc(%ebp),%eax
106488: 50 push %eax
106489: ff 75 10 pushl 0x10(%ebp)
10648c: ff 75 0c pushl 0xc(%ebp)
10648f: ff 75 08 pushl 0x8(%ebp)
106492: e8 06 00 00 00 call 10649d <vprintfmt>
106497: 83 c4 10 add $0x10,%esp
va_end(ap);
}
10649a: 90 nop
10649b: c9 leave
10649c: c3 ret
0010649d <vprintfmt>:
*
* Call this function if you are already dealing with a va_list.
* Or you probably want printfmt() instead.
* */
void
vprintfmt(void (*putch)(int, void*), void *putdat, const char *fmt, va_list ap) {
10649d: 55 push %ebp
10649e: 89 e5 mov %esp,%ebp
1064a0: 56 push %esi
1064a1: 53 push %ebx
1064a2: 83 ec 20 sub $0x20,%esp
register int ch, err;
unsigned long long num;
int base, width, precision, lflag, altflag;
while (1) {
while ((ch = *(unsigned char *)fmt ++) != '%') {
1064a5: eb 17 jmp 1064be <vprintfmt+0x21>
if (ch == '\0') {
1064a7: 85 db test %ebx,%ebx
1064a9: 0f 84 8e 03 00 00 je 10683d <vprintfmt+0x3a0>
return;
}
putch(ch, putdat);
1064af: 83 ec 08 sub $0x8,%esp
1064b2: ff 75 0c pushl 0xc(%ebp)
1064b5: 53 push %ebx
1064b6: 8b 45 08 mov 0x8(%ebp),%eax
1064b9: ff d0 call *%eax
1064bb: 83 c4 10 add $0x10,%esp
register int ch, err;
unsigned long long num;
int base, width, precision, lflag, altflag;
while (1) {
while ((ch = *(unsigned char *)fmt ++) != '%') {
1064be: 8b 45 10 mov 0x10(%ebp),%eax
1064c1: 8d 50 01 lea 0x1(%eax),%edx
1064c4: 89 55 10 mov %edx,0x10(%ebp)
1064c7: 0f b6 00 movzbl (%eax),%eax
1064ca: 0f b6 d8 movzbl %al,%ebx
1064cd: 83 fb 25 cmp $0x25,%ebx
1064d0: 75 d5 jne 1064a7 <vprintfmt+0xa>
}
putch(ch, putdat);
}
// Process a %-escape sequence
char padc = ' ';
1064d2: c6 45 db 20 movb $0x20,-0x25(%ebp)
width = precision = -1;
1064d6: c7 45 e4 ff ff ff ff movl $0xffffffff,-0x1c(%ebp)
1064dd: 8b 45 e4 mov -0x1c(%ebp),%eax
1064e0: 89 45 e8 mov %eax,-0x18(%ebp)
lflag = altflag = 0;
1064e3: c7 45 dc 00 00 00 00 movl $0x0,-0x24(%ebp)
1064ea: 8b 45 dc mov -0x24(%ebp),%eax
1064ed: 89 45 e0 mov %eax,-0x20(%ebp)
reswitch:
switch (ch = *(unsigned char *)fmt ++) {
1064f0: 8b 45 10 mov 0x10(%ebp),%eax
1064f3: 8d 50 01 lea 0x1(%eax),%edx
1064f6: 89 55 10 mov %edx,0x10(%ebp)
1064f9: 0f b6 00 movzbl (%eax),%eax
1064fc: 0f b6 d8 movzbl %al,%ebx
1064ff: 8d 43 dd lea -0x23(%ebx),%eax
106502: 83 f8 55 cmp $0x55,%eax
106505: 0f 87 05 03 00 00 ja 106810 <vprintfmt+0x373>
10650b: 8b 04 85 30 7e 10 00 mov 0x107e30(,%eax,4),%eax
106512: ff e0 jmp *%eax
// flag to pad on the right
case '-':
padc = '-';
106514: c6 45 db 2d movb $0x2d,-0x25(%ebp)
goto reswitch;
106518: eb d6 jmp 1064f0 <vprintfmt+0x53>
// flag to pad with 0's instead of spaces
case '0':
padc = '0';
10651a: c6 45 db 30 movb $0x30,-0x25(%ebp)
goto reswitch;
10651e: eb d0 jmp 1064f0 <vprintfmt+0x53>
// width field
case '1' ... '9':
for (precision = 0; ; ++ fmt) {
106520: c7 45 e4 00 00 00 00 movl $0x0,-0x1c(%ebp)
precision = precision * 10 + ch - '0';
106527: 8b 55 e4 mov -0x1c(%ebp),%edx
10652a: 89 d0 mov %edx,%eax
10652c: c1 e0 02 shl $0x2,%eax
10652f: 01 d0 add %edx,%eax
106531: 01 c0 add %eax,%eax
106533: 01 d8 add %ebx,%eax
106535: 83 e8 30 sub $0x30,%eax
106538: 89 45 e4 mov %eax,-0x1c(%ebp)
ch = *fmt;
10653b: 8b 45 10 mov 0x10(%ebp),%eax
10653e: 0f b6 00 movzbl (%eax),%eax
106541: 0f be d8 movsbl %al,%ebx
if (ch < '0' || ch > '9') {
106544: 83 fb 2f cmp $0x2f,%ebx
106547: 7e 39 jle 106582 <vprintfmt+0xe5>
106549: 83 fb 39 cmp $0x39,%ebx
10654c: 7f 34 jg 106582 <vprintfmt+0xe5>
padc = '0';
goto reswitch;
// width field
case '1' ... '9':
for (precision = 0; ; ++ fmt) {
10654e: 83 45 10 01 addl $0x1,0x10(%ebp)
precision = precision * 10 + ch - '0';
ch = *fmt;
if (ch < '0' || ch > '9') {
break;
}
}
106552: eb d3 jmp 106527 <vprintfmt+0x8a>
goto process_precision;
case '*':
precision = va_arg(ap, int);
106554: 8b 45 14 mov 0x14(%ebp),%eax
106557: 8d 50 04 lea 0x4(%eax),%edx
10655a: 89 55 14 mov %edx,0x14(%ebp)
10655d: 8b 00 mov (%eax),%eax
10655f: 89 45 e4 mov %eax,-0x1c(%ebp)
goto process_precision;
106562: eb 1f jmp 106583 <vprintfmt+0xe6>
case '.':
if (width < 0)
106564: 83 7d e8 00 cmpl $0x0,-0x18(%ebp)
106568: 79 86 jns 1064f0 <vprintfmt+0x53>
width = 0;
10656a: c7 45 e8 00 00 00 00 movl $0x0,-0x18(%ebp)
goto reswitch;
106571: e9 7a ff ff ff jmp 1064f0 <vprintfmt+0x53>
case '#':
altflag = 1;
106576: c7 45 dc 01 00 00 00 movl $0x1,-0x24(%ebp)
goto reswitch;
10657d: e9 6e ff ff ff jmp 1064f0 <vprintfmt+0x53>
ch = *fmt;
if (ch < '0' || ch > '9') {
break;
}
}
goto process_precision;
106582: 90 nop
case '#':
altflag = 1;
goto reswitch;
process_precision:
if (width < 0)
106583: 83 7d e8 00 cmpl $0x0,-0x18(%ebp)
106587: 0f 89 63 ff ff ff jns 1064f0 <vprintfmt+0x53>
width = precision, precision = -1;
10658d: 8b 45 e4 mov -0x1c(%ebp),%eax
106590: 89 45 e8 mov %eax,-0x18(%ebp)
106593: c7 45 e4 ff ff ff ff movl $0xffffffff,-0x1c(%ebp)
goto reswitch;
10659a: e9 51 ff ff ff jmp 1064f0 <vprintfmt+0x53>
// long flag (doubled for long long)
case 'l':
lflag ++;
10659f: 83 45 e0 01 addl $0x1,-0x20(%ebp)
goto reswitch;
1065a3: e9 48 ff ff ff jmp 1064f0 <vprintfmt+0x53>
// character
case 'c':
putch(va_arg(ap, int), putdat);
1065a8: 8b 45 14 mov 0x14(%ebp),%eax
1065ab: 8d 50 04 lea 0x4(%eax),%edx
1065ae: 89 55 14 mov %edx,0x14(%ebp)
1065b1: 8b 00 mov (%eax),%eax
1065b3: 83 ec 08 sub $0x8,%esp
1065b6: ff 75 0c pushl 0xc(%ebp)
1065b9: 50 push %eax
1065ba: 8b 45 08 mov 0x8(%ebp),%eax
1065bd: ff d0 call *%eax
1065bf: 83 c4 10 add $0x10,%esp
break;
1065c2: e9 71 02 00 00 jmp 106838 <vprintfmt+0x39b>
// error message
case 'e':
err = va_arg(ap, int);
1065c7: 8b 45 14 mov 0x14(%ebp),%eax
1065ca: 8d 50 04 lea 0x4(%eax),%edx
1065cd: 89 55 14 mov %edx,0x14(%ebp)
1065d0: 8b 18 mov (%eax),%ebx
if (err < 0) {
1065d2: 85 db test %ebx,%ebx
1065d4: 79 02 jns 1065d8 <vprintfmt+0x13b>
err = -err;
1065d6: f7 db neg %ebx
}
if (err > MAXERROR || (p = error_string[err]) == NULL) {
1065d8: 83 fb 06 cmp $0x6,%ebx
1065db: 7f 0b jg 1065e8 <vprintfmt+0x14b>
1065dd: 8b 34 9d f0 7d 10 00 mov 0x107df0(,%ebx,4),%esi
1065e4: 85 f6 test %esi,%esi
1065e6: 75 19 jne 106601 <vprintfmt+0x164>
printfmt(putch, putdat, "error %d", err);
1065e8: 53 push %ebx
1065e9: 68 1d 7e 10 00 push $0x107e1d
1065ee: ff 75 0c pushl 0xc(%ebp)
1065f1: ff 75 08 pushl 0x8(%ebp)
1065f4: e8 80 fe ff ff call 106479 <printfmt>
1065f9: 83 c4 10 add $0x10,%esp
}
else {
printfmt(putch, putdat, "%s", p);
}
break;
1065fc: e9 37 02 00 00 jmp 106838 <vprintfmt+0x39b>
}
if (err > MAXERROR || (p = error_string[err]) == NULL) {
printfmt(putch, putdat, "error %d", err);
}
else {
printfmt(putch, putdat, "%s", p);
106601: 56 push %esi
106602: 68 26 7e 10 00 push $0x107e26
106607: ff 75 0c pushl 0xc(%ebp)
10660a: ff 75 08 pushl 0x8(%ebp)
10660d: e8 67 fe ff ff call 106479 <printfmt>
106612: 83 c4 10 add $0x10,%esp
}
break;
106615: e9 1e 02 00 00 jmp 106838 <vprintfmt+0x39b>
// string
case 's':
if ((p = va_arg(ap, char *)) == NULL) {
10661a: 8b 45 14 mov 0x14(%ebp),%eax
10661d: 8d 50 04 lea 0x4(%eax),%edx
106620: 89 55 14 mov %edx,0x14(%ebp)
106623: 8b 30 mov (%eax),%esi
106625: 85 f6 test %esi,%esi
106627: 75 05 jne 10662e <vprintfmt+0x191>
p = "(null)";
106629: be 29 7e 10 00 mov $0x107e29,%esi
}
if (width > 0 && padc != '-') {
10662e: 83 7d e8 00 cmpl $0x0,-0x18(%ebp)
106632: 7e 76 jle 1066aa <vprintfmt+0x20d>
106634: 80 7d db 2d cmpb $0x2d,-0x25(%ebp)
106638: 74 70 je 1066aa <vprintfmt+0x20d>
for (width -= strnlen(p, precision); width > 0; width --) {
10663a: 8b 45 e4 mov -0x1c(%ebp),%eax
10663d: 83 ec 08 sub $0x8,%esp
106640: 50 push %eax
106641: 56 push %esi
106642: e8 17 f8 ff ff call 105e5e <strnlen>
106647: 83 c4 10 add $0x10,%esp
10664a: 89 c2 mov %eax,%edx
10664c: 8b 45 e8 mov -0x18(%ebp),%eax
10664f: 29 d0 sub %edx,%eax
106651: 89 45 e8 mov %eax,-0x18(%ebp)
106654: eb 17 jmp 10666d <vprintfmt+0x1d0>
putch(padc, putdat);
106656: 0f be 45 db movsbl -0x25(%ebp),%eax
10665a: 83 ec 08 sub $0x8,%esp
10665d: ff 75 0c pushl 0xc(%ebp)
106660: 50 push %eax
106661: 8b 45 08 mov 0x8(%ebp),%eax
106664: ff d0 call *%eax
106666: 83 c4 10 add $0x10,%esp
case 's':
if ((p = va_arg(ap, char *)) == NULL) {
p = "(null)";
}
if (width > 0 && padc != '-') {
for (width -= strnlen(p, precision); width > 0; width --) {
106669: 83 6d e8 01 subl $0x1,-0x18(%ebp)
10666d: 83 7d e8 00 cmpl $0x0,-0x18(%ebp)
106671: 7f e3 jg 106656 <vprintfmt+0x1b9>
putch(padc, putdat);
}
}
for (; (ch = *p ++) != '\0' && (precision < 0 || -- precision >= 0); width --) {
106673: eb 35 jmp 1066aa <vprintfmt+0x20d>
if (altflag && (ch < ' ' || ch > '~')) {
106675: 83 7d dc 00 cmpl $0x0,-0x24(%ebp)
106679: 74 1c je 106697 <vprintfmt+0x1fa>
10667b: 83 fb 1f cmp $0x1f,%ebx
10667e: 7e 05 jle 106685 <vprintfmt+0x1e8>
106680: 83 fb 7e cmp $0x7e,%ebx
106683: 7e 12 jle 106697 <vprintfmt+0x1fa>
putch('?', putdat);
106685: 83 ec 08 sub $0x8,%esp
106688: ff 75 0c pushl 0xc(%ebp)
10668b: 6a 3f push $0x3f
10668d: 8b 45 08 mov 0x8(%ebp),%eax
106690: ff d0 call *%eax
106692: 83 c4 10 add $0x10,%esp
106695: eb 0f jmp 1066a6 <vprintfmt+0x209>
}
else {
putch(ch, putdat);
106697: 83 ec 08 sub $0x8,%esp
10669a: ff 75 0c pushl 0xc(%ebp)
10669d: 53 push %ebx
10669e: 8b 45 08 mov 0x8(%ebp),%eax
1066a1: ff d0 call *%eax
1066a3: 83 c4 10 add $0x10,%esp
if (width > 0 && padc != '-') {
for (width -= strnlen(p, precision); width > 0; width --) {
putch(padc, putdat);
}
}
for (; (ch = *p ++) != '\0' && (precision < 0 || -- precision >= 0); width --) {
1066a6: 83 6d e8 01 subl $0x1,-0x18(%ebp)
1066aa: 89 f0 mov %esi,%eax
1066ac: 8d 70 01 lea 0x1(%eax),%esi
1066af: 0f b6 00 movzbl (%eax),%eax
1066b2: 0f be d8 movsbl %al,%ebx
1066b5: 85 db test %ebx,%ebx
1066b7: 74 26 je 1066df <vprintfmt+0x242>
1066b9: 83 7d e4 00 cmpl $0x0,-0x1c(%ebp)
1066bd: 78 b6 js 106675 <vprintfmt+0x1d8>
1066bf: 83 6d e4 01 subl $0x1,-0x1c(%ebp)
1066c3: 83 7d e4 00 cmpl $0x0,-0x1c(%ebp)
1066c7: 79 ac jns 106675 <vprintfmt+0x1d8>
}
else {
putch(ch, putdat);
}
}
for (; width > 0; width --) {
1066c9: eb 14 jmp 1066df <vprintfmt+0x242>
putch(' ', putdat);
1066cb: 83 ec 08 sub $0x8,%esp
1066ce: ff 75 0c pushl 0xc(%ebp)
1066d1: 6a 20 push $0x20
1066d3: 8b 45 08 mov 0x8(%ebp),%eax
1066d6: ff d0 call *%eax
1066d8: 83 c4 10 add $0x10,%esp
}
else {
putch(ch, putdat);
}
}
for (; width > 0; width --) {
1066db: 83 6d e8 01 subl $0x1,-0x18(%ebp)
1066df: 83 7d e8 00 cmpl $0x0,-0x18(%ebp)
1066e3: 7f e6 jg 1066cb <vprintfmt+0x22e>
putch(' ', putdat);
}
break;
1066e5: e9 4e 01 00 00 jmp 106838 <vprintfmt+0x39b>
// (signed) decimal
case 'd':
num = getint(&ap, lflag);
1066ea: 83 ec 08 sub $0x8,%esp
1066ed: ff 75 e0 pushl -0x20(%ebp)
1066f0: 8d 45 14 lea 0x14(%ebp),%eax
1066f3: 50 push %eax
1066f4: e8 39 fd ff ff call 106432 <getint>
1066f9: 83 c4 10 add $0x10,%esp
1066fc: 89 45 f0 mov %eax,-0x10(%ebp)
1066ff: 89 55 f4 mov %edx,-0xc(%ebp)
if ((long long)num < 0) {
106702: 8b 45 f0 mov -0x10(%ebp),%eax
106705: 8b 55 f4 mov -0xc(%ebp),%edx
106708: 85 d2 test %edx,%edx
10670a: 79 23 jns 10672f <vprintfmt+0x292>
putch('-', putdat);
10670c: 83 ec 08 sub $0x8,%esp
10670f: ff 75 0c pushl 0xc(%ebp)
106712: 6a 2d push $0x2d
106714: 8b 45 08 mov 0x8(%ebp),%eax
106717: ff d0 call *%eax
106719: 83 c4 10 add $0x10,%esp
num = -(long long)num;
10671c: 8b 45 f0 mov -0x10(%ebp),%eax
10671f: 8b 55 f4 mov -0xc(%ebp),%edx
106722: f7 d8 neg %eax
106724: 83 d2 00 adc $0x0,%edx
106727: f7 da neg %edx
106729: 89 45 f0 mov %eax,-0x10(%ebp)
10672c: 89 55 f4 mov %edx,-0xc(%ebp)
}
base = 10;
10672f: c7 45 ec 0a 00 00 00 movl $0xa,-0x14(%ebp)
goto number;
106736: e9 9f 00 00 00 jmp 1067da <vprintfmt+0x33d>
// unsigned decimal
case 'u':
num = getuint(&ap, lflag);
10673b: 83 ec 08 sub $0x8,%esp
10673e: ff 75 e0 pushl -0x20(%ebp)
106741: 8d 45 14 lea 0x14(%ebp),%eax
106744: 50 push %eax
106745: e8 99 fc ff ff call 1063e3 <getuint>
10674a: 83 c4 10 add $0x10,%esp
10674d: 89 45 f0 mov %eax,-0x10(%ebp)
106750: 89 55 f4 mov %edx,-0xc(%ebp)
base = 10;
106753: c7 45 ec 0a 00 00 00 movl $0xa,-0x14(%ebp)
goto number;
10675a: eb 7e jmp 1067da <vprintfmt+0x33d>
// (unsigned) octal
case 'o':
num = getuint(&ap, lflag);
10675c: 83 ec 08 sub $0x8,%esp
10675f: ff 75 e0 pushl -0x20(%ebp)
106762: 8d 45 14 lea 0x14(%ebp),%eax
106765: 50 push %eax
106766: e8 78 fc ff ff call 1063e3 <getuint>
10676b: 83 c4 10 add $0x10,%esp
10676e: 89 45 f0 mov %eax,-0x10(%ebp)
106771: 89 55 f4 mov %edx,-0xc(%ebp)
base = 8;
106774: c7 45 ec 08 00 00 00 movl $0x8,-0x14(%ebp)
goto number;
10677b: eb 5d jmp 1067da <vprintfmt+0x33d>
// pointer
case 'p':
putch('0', putdat);
10677d: 83 ec 08 sub $0x8,%esp
106780: ff 75 0c pushl 0xc(%ebp)
106783: 6a 30 push $0x30
106785: 8b 45 08 mov 0x8(%ebp),%eax
106788: ff d0 call *%eax
10678a: 83 c4 10 add $0x10,%esp
putch('x', putdat);
10678d: 83 ec 08 sub $0x8,%esp
106790: ff 75 0c pushl 0xc(%ebp)
106793: 6a 78 push $0x78
106795: 8b 45 08 mov 0x8(%ebp),%eax
106798: ff d0 call *%eax
10679a: 83 c4 10 add $0x10,%esp
num = (unsigned long long)(uintptr_t)va_arg(ap, void *);
10679d: 8b 45 14 mov 0x14(%ebp),%eax
1067a0: 8d 50 04 lea 0x4(%eax),%edx
1067a3: 89 55 14 mov %edx,0x14(%ebp)
1067a6: 8b 00 mov (%eax),%eax
1067a8: 89 45 f0 mov %eax,-0x10(%ebp)
1067ab: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp)
base = 16;
1067b2: c7 45 ec 10 00 00 00 movl $0x10,-0x14(%ebp)
goto number;
1067b9: eb 1f jmp 1067da <vprintfmt+0x33d>
// (unsigned) hexadecimal
case 'x':
num = getuint(&ap, lflag);
1067bb: 83 ec 08 sub $0x8,%esp
1067be: ff 75 e0 pushl -0x20(%ebp)
1067c1: 8d 45 14 lea 0x14(%ebp),%eax
1067c4: 50 push %eax
1067c5: e8 19 fc ff ff call 1063e3 <getuint>
1067ca: 83 c4 10 add $0x10,%esp
1067cd: 89 45 f0 mov %eax,-0x10(%ebp)
1067d0: 89 55 f4 mov %edx,-0xc(%ebp)
base = 16;
1067d3: c7 45 ec 10 00 00 00 movl $0x10,-0x14(%ebp)
number:
printnum(putch, putdat, num, base, width, padc);
1067da: 0f be 55 db movsbl -0x25(%ebp),%edx
1067de: 8b 45 ec mov -0x14(%ebp),%eax
1067e1: 83 ec 04 sub $0x4,%esp
1067e4: 52 push %edx
1067e5: ff 75 e8 pushl -0x18(%ebp)
1067e8: 50 push %eax
1067e9: ff 75 f4 pushl -0xc(%ebp)
1067ec: ff 75 f0 pushl -0x10(%ebp)
1067ef: ff 75 0c pushl 0xc(%ebp)
1067f2: ff 75 08 pushl 0x8(%ebp)
1067f5: e8 f8 fa ff ff call 1062f2 <printnum>
1067fa: 83 c4 20 add $0x20,%esp
break;
1067fd: eb 39 jmp 106838 <vprintfmt+0x39b>
// escaped '%' character
case '%':
putch(ch, putdat);
1067ff: 83 ec 08 sub $0x8,%esp
106802: ff 75 0c pushl 0xc(%ebp)
106805: 53 push %ebx
106806: 8b 45 08 mov 0x8(%ebp),%eax
106809: ff d0 call *%eax
10680b: 83 c4 10 add $0x10,%esp
break;
10680e: eb 28 jmp 106838 <vprintfmt+0x39b>
// unrecognized escape sequence - just print it literally
default:
putch('%', putdat);
106810: 83 ec 08 sub $0x8,%esp
106813: ff 75 0c pushl 0xc(%ebp)
106816: 6a 25 push $0x25
106818: 8b 45 08 mov 0x8(%ebp),%eax
10681b: ff d0 call *%eax
10681d: 83 c4 10 add $0x10,%esp
for (fmt --; fmt[-1] != '%'; fmt --)
106820: 83 6d 10 01 subl $0x1,0x10(%ebp)
106824: eb 04 jmp 10682a <vprintfmt+0x38d>
106826: 83 6d 10 01 subl $0x1,0x10(%ebp)
10682a: 8b 45 10 mov 0x10(%ebp),%eax
10682d: 83 e8 01 sub $0x1,%eax
106830: 0f b6 00 movzbl (%eax),%eax
106833: 3c 25 cmp $0x25,%al
106835: 75 ef jne 106826 <vprintfmt+0x389>
/* do nothing */;
break;
106837: 90 nop
}
}
106838: e9 68 fc ff ff jmp 1064a5 <vprintfmt+0x8>
int base, width, precision, lflag, altflag;
while (1) {
while ((ch = *(unsigned char *)fmt ++) != '%') {
if (ch == '\0') {
return;
10683d: 90 nop
for (fmt --; fmt[-1] != '%'; fmt --)
/* do nothing */;
break;
}
}
}
10683e: 8d 65 f8 lea -0x8(%ebp),%esp
106841: 5b pop %ebx
106842: 5e pop %esi
106843: 5d pop %ebp
106844: c3 ret
00106845 <sprintputch>:
* sprintputch - 'print' a single character in a buffer
* @ch: the character will be printed
* @b: the buffer to place the character @ch
* */
static void
sprintputch(int ch, struct sprintbuf *b) {
106845: 55 push %ebp
106846: 89 e5 mov %esp,%ebp
b->cnt ++;
106848: 8b 45 0c mov 0xc(%ebp),%eax
10684b: 8b 40 08 mov 0x8(%eax),%eax
10684e: 8d 50 01 lea 0x1(%eax),%edx
106851: 8b 45 0c mov 0xc(%ebp),%eax
106854: 89 50 08 mov %edx,0x8(%eax)
if (b->buf < b->ebuf) {
106857: 8b 45 0c mov 0xc(%ebp),%eax
10685a: 8b 10 mov (%eax),%edx
10685c: 8b 45 0c mov 0xc(%ebp),%eax
10685f: 8b 40 04 mov 0x4(%eax),%eax
106862: 39 c2 cmp %eax,%edx
106864: 73 12 jae 106878 <sprintputch+0x33>
*b->buf ++ = ch;
106866: 8b 45 0c mov 0xc(%ebp),%eax
106869: 8b 00 mov (%eax),%eax
10686b: 8d 48 01 lea 0x1(%eax),%ecx
10686e: 8b 55 0c mov 0xc(%ebp),%edx
106871: 89 0a mov %ecx,(%edx)
106873: 8b 55 08 mov 0x8(%ebp),%edx
106876: 88 10 mov %dl,(%eax)
}
}
106878: 90 nop
106879: 5d pop %ebp
10687a: c3 ret
0010687b <snprintf>:
* @str: the buffer to place the result into
* @size: the size of buffer, including the trailing null space
* @fmt: the format string to use
* */
int
snprintf(char *str, size_t size, const char *fmt, ...) {
10687b: 55 push %ebp
10687c: 89 e5 mov %esp,%ebp
10687e: 83 ec 18 sub $0x18,%esp
va_list ap;
int cnt;
va_start(ap, fmt);
106881: 8d 45 14 lea 0x14(%ebp),%eax
106884: 89 45 f0 mov %eax,-0x10(%ebp)
cnt = vsnprintf(str, size, fmt, ap);
106887: 8b 45 f0 mov -0x10(%ebp),%eax
10688a: 50 push %eax
10688b: ff 75 10 pushl 0x10(%ebp)
10688e: ff 75 0c pushl 0xc(%ebp)
106891: ff 75 08 pushl 0x8(%ebp)
106894: e8 0b 00 00 00 call 1068a4 <vsnprintf>
106899: 83 c4 10 add $0x10,%esp
10689c: 89 45 f4 mov %eax,-0xc(%ebp)
va_end(ap);
return cnt;
10689f: 8b 45 f4 mov -0xc(%ebp),%eax
}
1068a2: c9 leave
1068a3: c3 ret
001068a4 <vsnprintf>:
*
* Call this function if you are already dealing with a va_list.
* Or you probably want snprintf() instead.
* */
int
vsnprintf(char *str, size_t size, const char *fmt, va_list ap) {
1068a4: 55 push %ebp
1068a5: 89 e5 mov %esp,%ebp
1068a7: 83 ec 18 sub $0x18,%esp
struct sprintbuf b = {str, str + size - 1, 0};
1068aa: 8b 45 08 mov 0x8(%ebp),%eax
1068ad: 89 45 ec mov %eax,-0x14(%ebp)
1068b0: 8b 45 0c mov 0xc(%ebp),%eax
1068b3: 8d 50 ff lea -0x1(%eax),%edx
1068b6: 8b 45 08 mov 0x8(%ebp),%eax
1068b9: 01 d0 add %edx,%eax
1068bb: 89 45 f0 mov %eax,-0x10(%ebp)
1068be: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp)
if (str == NULL || b.buf > b.ebuf) {
1068c5: 83 7d 08 00 cmpl $0x0,0x8(%ebp)
1068c9: 74 0a je 1068d5 <vsnprintf+0x31>
1068cb: 8b 55 ec mov -0x14(%ebp),%edx
1068ce: 8b 45 f0 mov -0x10(%ebp),%eax
1068d1: 39 c2 cmp %eax,%edx
1068d3: 76 07 jbe 1068dc <vsnprintf+0x38>
return -E_INVAL;
1068d5: b8 fd ff ff ff mov $0xfffffffd,%eax
1068da: eb 20 jmp 1068fc <vsnprintf+0x58>
}
// print the string to the buffer
vprintfmt((void*)sprintputch, &b, fmt, ap);
1068dc: ff 75 14 pushl 0x14(%ebp)
1068df: ff 75 10 pushl 0x10(%ebp)
1068e2: 8d 45 ec lea -0x14(%ebp),%eax
1068e5: 50 push %eax
1068e6: 68 45 68 10 00 push $0x106845
1068eb: e8 ad fb ff ff call 10649d <vprintfmt>
1068f0: 83 c4 10 add $0x10,%esp
// null terminate the buffer
*b.buf = '\0';
1068f3: 8b 45 ec mov -0x14(%ebp),%eax
1068f6: c6 00 00 movb $0x0,(%eax)
return b.cnt;
1068f9: 8b 45 f4 mov -0xc(%ebp),%eax
}
1068fc: c9 leave
1068fd: c3 ret
|
/*
* Copyright (c) 2013 The WebRTC 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 "modules/audio_coding/neteq/statistics_calculator.h"
#include <assert.h>
#include <string.h> // memset
#include <algorithm>
#include "modules/audio_coding/neteq/delay_manager.h"
#include "rtc_base/checks.h"
#include "rtc_base/numerics/safe_conversions.h"
#include "system_wrappers/include/metrics.h"
namespace webrtc {
namespace {
size_t AddIntToSizeTWithLowerCap(int a, size_t b) {
const size_t ret = b + a;
// If a + b is negative, resulting in a negative wrap, cap it to zero instead.
static_assert(sizeof(size_t) >= sizeof(int),
"int must not be wider than size_t for this to work");
return (a < 0 && ret > b) ? 0 : ret;
}
constexpr int kInterruptionLenMs = 150;
} // namespace
// Allocating the static const so that it can be passed by reference to
// RTC_DCHECK.
const size_t StatisticsCalculator::kLenWaitingTimes;
StatisticsCalculator::PeriodicUmaLogger::PeriodicUmaLogger(
const std::string& uma_name,
int report_interval_ms,
int max_value)
: uma_name_(uma_name),
report_interval_ms_(report_interval_ms),
max_value_(max_value),
timer_(0) {}
StatisticsCalculator::PeriodicUmaLogger::~PeriodicUmaLogger() = default;
void StatisticsCalculator::PeriodicUmaLogger::AdvanceClock(int step_ms) {
timer_ += step_ms;
if (timer_ < report_interval_ms_) {
return;
}
LogToUma(Metric());
Reset();
timer_ -= report_interval_ms_;
RTC_DCHECK_GE(timer_, 0);
}
void StatisticsCalculator::PeriodicUmaLogger::LogToUma(int value) const {
RTC_HISTOGRAM_COUNTS_SPARSE(uma_name_, value, 1, max_value_, 50);
}
StatisticsCalculator::PeriodicUmaCount::PeriodicUmaCount(
const std::string& uma_name,
int report_interval_ms,
int max_value)
: PeriodicUmaLogger(uma_name, report_interval_ms, max_value) {}
StatisticsCalculator::PeriodicUmaCount::~PeriodicUmaCount() {
// Log the count for the current (incomplete) interval.
LogToUma(Metric());
}
void StatisticsCalculator::PeriodicUmaCount::RegisterSample() {
++counter_;
}
int StatisticsCalculator::PeriodicUmaCount::Metric() const {
return counter_;
}
void StatisticsCalculator::PeriodicUmaCount::Reset() {
counter_ = 0;
}
StatisticsCalculator::PeriodicUmaAverage::PeriodicUmaAverage(
const std::string& uma_name,
int report_interval_ms,
int max_value)
: PeriodicUmaLogger(uma_name, report_interval_ms, max_value) {}
StatisticsCalculator::PeriodicUmaAverage::~PeriodicUmaAverage() {
// Log the average for the current (incomplete) interval.
LogToUma(Metric());
}
void StatisticsCalculator::PeriodicUmaAverage::RegisterSample(int value) {
sum_ += value;
++counter_;
}
int StatisticsCalculator::PeriodicUmaAverage::Metric() const {
return counter_ == 0 ? 0 : static_cast<int>(sum_ / counter_);
}
void StatisticsCalculator::PeriodicUmaAverage::Reset() {
sum_ = 0.0;
counter_ = 0;
}
StatisticsCalculator::StatisticsCalculator()
: preemptive_samples_(0),
accelerate_samples_(0),
added_zero_samples_(0),
expanded_speech_samples_(0),
expanded_noise_samples_(0),
discarded_packets_(0),
lost_timestamps_(0),
timestamps_since_last_report_(0),
secondary_decoded_samples_(0),
discarded_secondary_packets_(0),
delayed_packet_outage_counter_(
"WebRTC.Audio.DelayedPacketOutageEventsPerMinute",
60000, // 60 seconds report interval.
100),
excess_buffer_delay_("WebRTC.Audio.AverageExcessBufferDelayMs",
60000, // 60 seconds report interval.
1000),
buffer_full_counter_("WebRTC.Audio.JitterBufferFullPerMinute",
60000, // 60 seconds report interval.
100) {}
StatisticsCalculator::~StatisticsCalculator() = default;
void StatisticsCalculator::Reset() {
preemptive_samples_ = 0;
accelerate_samples_ = 0;
added_zero_samples_ = 0;
expanded_speech_samples_ = 0;
expanded_noise_samples_ = 0;
secondary_decoded_samples_ = 0;
discarded_secondary_packets_ = 0;
waiting_times_.clear();
}
void StatisticsCalculator::ResetMcu() {
discarded_packets_ = 0;
lost_timestamps_ = 0;
timestamps_since_last_report_ = 0;
}
void StatisticsCalculator::ExpandedVoiceSamples(size_t num_samples,
bool is_new_concealment_event) {
expanded_speech_samples_ += num_samples;
ConcealedSamplesCorrection(rtc::dchecked_cast<int>(num_samples), true);
lifetime_stats_.concealment_events += is_new_concealment_event;
}
void StatisticsCalculator::ExpandedNoiseSamples(size_t num_samples,
bool is_new_concealment_event) {
expanded_noise_samples_ += num_samples;
ConcealedSamplesCorrection(rtc::dchecked_cast<int>(num_samples), false);
lifetime_stats_.concealment_events += is_new_concealment_event;
}
void StatisticsCalculator::ExpandedVoiceSamplesCorrection(int num_samples) {
expanded_speech_samples_ =
AddIntToSizeTWithLowerCap(num_samples, expanded_speech_samples_);
ConcealedSamplesCorrection(num_samples, true);
}
void StatisticsCalculator::ExpandedNoiseSamplesCorrection(int num_samples) {
expanded_noise_samples_ =
AddIntToSizeTWithLowerCap(num_samples, expanded_noise_samples_);
ConcealedSamplesCorrection(num_samples, false);
}
void StatisticsCalculator::DecodedOutputPlayed() {
decoded_output_played_ = true;
}
void StatisticsCalculator::EndExpandEvent(int fs_hz) {
RTC_DCHECK_GE(lifetime_stats_.concealed_samples,
concealed_samples_at_event_end_);
const int event_duration_ms =
1000 *
(lifetime_stats_.concealed_samples - concealed_samples_at_event_end_) /
fs_hz;
if (event_duration_ms >= kInterruptionLenMs && decoded_output_played_) {
lifetime_stats_.interruption_count++;
lifetime_stats_.total_interruption_duration_ms += event_duration_ms;
RTC_HISTOGRAM_COUNTS("WebRTC.Audio.AudioInterruptionMs", event_duration_ms,
/*min=*/150, /*max=*/5000, /*bucket_count=*/50);
}
concealed_samples_at_event_end_ = lifetime_stats_.concealed_samples;
}
void StatisticsCalculator::ConcealedSamplesCorrection(int num_samples,
bool is_voice) {
if (num_samples < 0) {
// Store negative correction to subtract from future positive additions.
// See also the function comment in the header file.
concealed_samples_correction_ -= num_samples;
if (!is_voice) {
silent_concealed_samples_correction_ -= num_samples;
}
return;
}
const size_t canceled_out =
std::min(static_cast<size_t>(num_samples), concealed_samples_correction_);
concealed_samples_correction_ -= canceled_out;
lifetime_stats_.concealed_samples += num_samples - canceled_out;
if (!is_voice) {
const size_t silent_canceled_out = std::min(
static_cast<size_t>(num_samples), silent_concealed_samples_correction_);
silent_concealed_samples_correction_ -= silent_canceled_out;
lifetime_stats_.silent_concealed_samples +=
num_samples - silent_canceled_out;
}
}
void StatisticsCalculator::PreemptiveExpandedSamples(size_t num_samples) {
preemptive_samples_ += num_samples;
operations_and_state_.preemptive_samples += num_samples;
lifetime_stats_.inserted_samples_for_deceleration += num_samples;
}
void StatisticsCalculator::AcceleratedSamples(size_t num_samples) {
accelerate_samples_ += num_samples;
operations_and_state_.accelerate_samples += num_samples;
lifetime_stats_.removed_samples_for_acceleration += num_samples;
}
void StatisticsCalculator::AddZeros(size_t num_samples) {
added_zero_samples_ += num_samples;
}
void StatisticsCalculator::PacketsDiscarded(size_t num_packets) {
operations_and_state_.discarded_primary_packets += num_packets;
}
void StatisticsCalculator::SecondaryPacketsDiscarded(size_t num_packets) {
discarded_secondary_packets_ += num_packets;
lifetime_stats_.fec_packets_discarded += num_packets;
}
void StatisticsCalculator::SecondaryPacketsReceived(size_t num_packets) {
lifetime_stats_.fec_packets_received += num_packets;
}
void StatisticsCalculator::LostSamples(size_t num_samples) {
lost_timestamps_ += num_samples;
}
void StatisticsCalculator::IncreaseCounter(size_t num_samples, int fs_hz) {
const int time_step_ms =
rtc::CheckedDivExact(static_cast<int>(1000 * num_samples), fs_hz);
delayed_packet_outage_counter_.AdvanceClock(time_step_ms);
excess_buffer_delay_.AdvanceClock(time_step_ms);
buffer_full_counter_.AdvanceClock(time_step_ms);
timestamps_since_last_report_ += static_cast<uint32_t>(num_samples);
if (timestamps_since_last_report_ >
static_cast<uint32_t>(fs_hz * kMaxReportPeriod)) {
lost_timestamps_ = 0;
timestamps_since_last_report_ = 0;
discarded_packets_ = 0;
}
lifetime_stats_.total_samples_received += num_samples;
}
void StatisticsCalculator::JitterBufferDelay(size_t num_samples,
uint64_t waiting_time_ms) {
lifetime_stats_.jitter_buffer_delay_ms += waiting_time_ms * num_samples;
lifetime_stats_.jitter_buffer_emitted_count += num_samples;
}
void StatisticsCalculator::SecondaryDecodedSamples(int num_samples) {
secondary_decoded_samples_ += num_samples;
}
void StatisticsCalculator::FlushedPacketBuffer() {
operations_and_state_.packet_buffer_flushes++;
buffer_full_counter_.RegisterSample();
}
void StatisticsCalculator::ReceivedPacket() {
++lifetime_stats_.jitter_buffer_packets_received;
}
void StatisticsCalculator::RelativePacketArrivalDelay(size_t delay_ms) {
lifetime_stats_.relative_packet_arrival_delay_ms += delay_ms;
}
void StatisticsCalculator::LogDelayedPacketOutageEvent(int num_samples,
int fs_hz) {
int outage_duration_ms = num_samples / (fs_hz / 1000);
RTC_HISTOGRAM_COUNTS("WebRTC.Audio.DelayedPacketOutageEventMs",
outage_duration_ms, 1 /* min */, 2000 /* max */,
100 /* bucket count */);
delayed_packet_outage_counter_.RegisterSample();
lifetime_stats_.delayed_packet_outage_samples += num_samples;
}
void StatisticsCalculator::StoreWaitingTime(int waiting_time_ms) {
excess_buffer_delay_.RegisterSample(waiting_time_ms);
RTC_DCHECK_LE(waiting_times_.size(), kLenWaitingTimes);
if (waiting_times_.size() == kLenWaitingTimes) {
// Erase first value.
waiting_times_.pop_front();
}
waiting_times_.push_back(waiting_time_ms);
operations_and_state_.last_waiting_time_ms = waiting_time_ms;
}
void StatisticsCalculator::GetNetworkStatistics(int fs_hz,
size_t num_samples_in_buffers,
size_t samples_per_packet,
NetEqNetworkStatistics* stats) {
RTC_DCHECK_GT(fs_hz, 0);
RTC_DCHECK(stats);
stats->added_zero_samples = added_zero_samples_;
stats->current_buffer_size_ms =
static_cast<uint16_t>(num_samples_in_buffers * 1000 / fs_hz);
stats->packet_loss_rate =
CalculateQ14Ratio(lost_timestamps_, timestamps_since_last_report_);
stats->accelerate_rate =
CalculateQ14Ratio(accelerate_samples_, timestamps_since_last_report_);
stats->preemptive_rate =
CalculateQ14Ratio(preemptive_samples_, timestamps_since_last_report_);
stats->expand_rate =
CalculateQ14Ratio(expanded_speech_samples_ + expanded_noise_samples_,
timestamps_since_last_report_);
stats->speech_expand_rate = CalculateQ14Ratio(expanded_speech_samples_,
timestamps_since_last_report_);
stats->secondary_decoded_rate = CalculateQ14Ratio(
secondary_decoded_samples_, timestamps_since_last_report_);
const size_t discarded_secondary_samples =
discarded_secondary_packets_ * samples_per_packet;
stats->secondary_discarded_rate =
CalculateQ14Ratio(discarded_secondary_samples,
static_cast<uint32_t>(discarded_secondary_samples +
secondary_decoded_samples_));
if (waiting_times_.size() == 0) {
stats->mean_waiting_time_ms = -1;
stats->median_waiting_time_ms = -1;
stats->min_waiting_time_ms = -1;
stats->max_waiting_time_ms = -1;
} else {
std::sort(waiting_times_.begin(), waiting_times_.end());
// Find mid-point elements. If the size is odd, the two values
// |middle_left| and |middle_right| will both be the one middle element; if
// the size is even, they will be the the two neighboring elements at the
// middle of the list.
const int middle_left = waiting_times_[(waiting_times_.size() - 1) / 2];
const int middle_right = waiting_times_[waiting_times_.size() / 2];
// Calculate the average of the two. (Works also for odd sizes.)
stats->median_waiting_time_ms = (middle_left + middle_right) / 2;
stats->min_waiting_time_ms = waiting_times_.front();
stats->max_waiting_time_ms = waiting_times_.back();
double sum = 0;
for (auto time : waiting_times_) {
sum += time;
}
stats->mean_waiting_time_ms = static_cast<int>(sum / waiting_times_.size());
}
// Reset counters.
ResetMcu();
Reset();
}
NetEqLifetimeStatistics StatisticsCalculator::GetLifetimeStatistics() const {
return lifetime_stats_;
}
NetEqOperationsAndState StatisticsCalculator::GetOperationsAndState() const {
return operations_and_state_;
}
uint16_t StatisticsCalculator::CalculateQ14Ratio(size_t numerator,
uint32_t denominator) {
if (numerator == 0) {
return 0;
} else if (numerator < denominator) {
// Ratio must be smaller than 1 in Q14.
assert((numerator << 14) / denominator < (1 << 14));
return static_cast<uint16_t>((numerator << 14) / denominator);
} else {
// Will not produce a ratio larger than 1, since this is probably an error.
return 1 << 14;
}
}
} // namespace webrtc
|
.size 8000
.text@48
jp lstatint
.text@100
jp lbegin
.data@143
c0
.text@150
lbegin:
ld a, 00
ldff(ff), a
ld b, 91
call lwaitly_b
ld a, b1
ldff(40), a
ld a, a5
ldff(4b), a
ld c, 41
ld b, 03
lbegin_waitm3:
ldff a, (c)
and a, b
cmp a, b
jrnz lbegin_waitm3
ld a, 20
ldff(c), a
xor a, a
ldff(0f), a
ld a, 02
ldff(ff), a
ld a, 00
ldff(43), a
ei
.text@1000
lstatint:
ld a, 08
ldff(41), a
xor a, a
ldff(0f), a
.text@1033
ldff a, (0f)
and a, b
jp lprint_a
.text@7000
lprint_a:
push af
ld b, 91
call lwaitly_b
xor a, a
ldff(40), a
pop af
ld(9800), a
ld bc, 7a00
ld hl, 8000
ld d, a0
lprint_copytiles:
ld a, (bc)
inc bc
ld(hl++), a
dec d
jrnz lprint_copytiles
ld a, c0
ldff(47), a
ld a, 80
ldff(68), a
ld a, ff
ldff(69), a
ldff(69), a
ldff(69), a
ldff(69), a
ldff(69), a
ldff(69), a
xor a, a
ldff(69), a
ldff(69), a
ldff(43), a
ld a, 91
ldff(40), a
lprint_limbo:
jr lprint_limbo
.text@7400
lwaitly_b:
ld c, 44
lwaitly_b_loop:
ldff a, (c)
cmp a, b
jrnz lwaitly_b_loop
ret
.data@7a00
00 00 7f 7f 41 41 41 41
41 41 41 41 41 41 7f 7f
00 00 08 08 08 08 08 08
08 08 08 08 08 08 08 08
00 00 7f 7f 01 01 01 01
7f 7f 40 40 40 40 7f 7f
00 00 7f 7f 01 01 01 01
3f 3f 01 01 01 01 7f 7f
00 00 41 41 41 41 41 41
7f 7f 01 01 01 01 01 01
00 00 7f 7f 40 40 40 40
7e 7e 01 01 01 01 7e 7e
00 00 7f 7f 40 40 40 40
7f 7f 41 41 41 41 7f 7f
00 00 7f 7f 01 01 02 02
04 04 08 08 10 10 10 10
00 00 3e 3e 41 41 41 41
3e 3e 41 41 41 41 3e 3e
00 00 7f 7f 41 41 41 41
7f 7f 01 01 01 01 7f 7f
|
/*
+----------------------------------------------------------------------+
| HipHop for PHP |
+----------------------------------------------------------------------+
| Copyright (c) 2010-present Facebook, Inc. (http://www.facebook.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
*/
#include "hphp/runtime/base/program-functions.h"
#include "hphp/runtime/base/array-init.h"
#include "hphp/runtime/base/backtrace.h"
#include "hphp/runtime/base/builtin-functions.h"
#include "hphp/runtime/base/code-coverage.h"
#include "hphp/runtime/base/config.h"
#include "hphp/runtime/base/execution-context.h"
#include "hphp/runtime/base/extended-logger.h"
#include "hphp/runtime/base/externals.h"
#include "hphp/runtime/base/file-util.h"
#include "hphp/runtime/base/hhprof.h"
#include "hphp/runtime/base/ini-setting.h"
#include "hphp/runtime/base/member-reflection.h"
#include "hphp/runtime/base/memory-manager.h"
#include "hphp/runtime/base/perf-mem-event.h"
#include "hphp/runtime/base/php-globals.h"
#include "hphp/runtime/base/plain-file.h"
#include "hphp/runtime/base/runtime-error.h"
#include "hphp/runtime/base/runtime-option.h"
#include "hphp/runtime/base/stat-cache.h"
#include "hphp/runtime/base/stream-wrapper-registry.h"
#include "hphp/runtime/base/surprise-flags.h"
#include "hphp/runtime/base/init-fini-node.h"
#include "hphp/runtime/base/unit-cache.h"
#include "hphp/runtime/base/thread-safe-setlocale.h"
#include "hphp/runtime/base/variable-serializer.h"
#include "hphp/runtime/base/zend-math.h"
#include "hphp/runtime/base/zend-strtod.h"
#include "hphp/runtime/debugger/debugger.h"
#include "hphp/runtime/debugger/debugger_client.h"
#include "hphp/runtime/debugger/debugger_hook_handler.h"
#include "hphp/runtime/ext/apc/ext_apc.h"
#include "hphp/runtime/ext/xhprof/ext_xhprof.h"
#include "hphp/runtime/ext/extension-registry.h"
#include "hphp/runtime/ext/json/ext_json.h"
#include "hphp/runtime/ext/std/ext_std_file.h"
#include "hphp/runtime/ext/std/ext_std_function.h"
#include "hphp/runtime/ext/std/ext_std_variable.h"
#include "hphp/runtime/ext/xdebug/status.h"
#include "hphp/runtime/ext/xenon/ext_xenon.h"
#include "hphp/runtime/server/admin-request-handler.h"
#include "hphp/runtime/server/cli-server.h"
#include "hphp/runtime/server/http-request-handler.h"
#include "hphp/runtime/server/log-writer.h"
#include "hphp/runtime/server/rpc-request-handler.h"
#include "hphp/runtime/server/http-server.h"
#include "hphp/runtime/server/pagelet-server.h"
#include "hphp/runtime/server/replay-transport.h"
#include "hphp/runtime/server/server-note.h"
#include "hphp/runtime/server/server-stats.h"
#include "hphp/runtime/server/xbox-server.h"
#include "hphp/runtime/vm/debug/debug.h"
#include "hphp/runtime/vm/jit/code-cache.h"
#include "hphp/runtime/vm/jit/tc.h"
#include "hphp/runtime/vm/jit/mcgen.h"
#include "hphp/runtime/vm/jit/translator.h"
#include "hphp/runtime/vm/extern-compiler.h"
#include "hphp/runtime/vm/repo.h"
#include "hphp/runtime/vm/runtime.h"
#include "hphp/runtime/vm/treadmill.h"
#include "hphp/util/abi-cxx.h"
#include "hphp/util/arch.h"
#include "hphp/util/boot-stats.h"
#include "hphp/util/build-info.h"
#include "hphp/util/compatibility.h"
#include "hphp/util/capability.h"
#include "hphp/util/embedded-data.h"
#include "hphp/util/hardware-counter.h"
#include "hphp/util/hphp-config.h"
#include "hphp/util/kernel-version.h"
#ifndef _MSC_VER
#include "hphp/util/light-process.h"
#endif
#include "hphp/util/perf-event.h"
#include "hphp/util/process-exec.h"
#include "hphp/util/process.h"
#include "hphp/util/service-data.h"
#include "hphp/util/shm-counter.h"
#include "hphp/util/stack-trace.h"
#include "hphp/util/timer.h"
#include "hphp/util/type-scan.h"
#include "hphp/zend/zend-string.h"
#include <folly/CPortability.h>
#include <folly/Portability.h>
#include <folly/Random.h>
#include <folly/Range.h>
#include <folly/Singleton.h>
#include <folly/portability/Fcntl.h>
#include <folly/portability/Libgen.h>
#include <folly/portability/Stdlib.h>
#include <folly/portability/Unistd.h>
#include <boost/algorithm/string/replace.hpp>
#include <boost/program_options/options_description.hpp>
#include <boost/program_options/positional_options.hpp>
#include <boost/program_options/variables_map.hpp>
#include <boost/filesystem.hpp>
#include <oniguruma.h>
// Onigurama defines UChar to unsigned char, but ICU4C defines it to signed
// 16-bit int. This is supposed to be resolved by ONIG_ESCAPE_UCHAR_COLLISION,
// however this isn't fully supported in 6.8.0 or 6.8.1.
//
// As of 2018-03-21, not in any release; hopefully will be in 6.8.2 - it's
// resolved by this commit:
//
// https://github.com/kkos/oniguruma/commit/e79406479b6be4a56e40ede6c1a87b51fba073a2
#undef UChar
#include <signal.h>
#include <libxml/parser.h>
#include <chrono>
#include <exception>
#include <fstream>
#include <iterator>
#include <map>
#include <memory>
#include <string>
#include <vector>
#ifdef _MSC_VER
#include <windows.h>
#include <winuser.h>
#endif
using namespace boost::program_options;
using std::cout;
constexpr auto MAX_INPUT_NESTING_LEVEL = 64;
namespace HPHP {
///////////////////////////////////////////////////////////////////////////////
// Forward declarations.
void initialize_repo();
/*
* XXX: VM process initialization is handled through a function
* pointer so libhphp_runtime.a can be linked into programs that don't
* actually initialize the VM.
*/
void (*g_vmProcessInit)();
void timezone_init();
void pcre_init();
void pcre_reinit();
///////////////////////////////////////////////////////////////////////////////
// helpers
struct ProgramOptions {
std::string mode;
std::vector<std::string> config;
std::vector<std::string> confStrings;
std::vector<std::string> iniStrings;
int port;
int portfd;
int sslportfd;
int admin_port;
std::string user;
std::string file;
std::string lint;
bool isTempFile;
int count;
bool noSafeAccessCheck;
std::vector<std::string> args;
std::string buildId;
std::string instanceId;
int xhprofFlags;
std::string show;
std::string parse;
int vsDebugPort;
bool vsDebugNoWait;
Eval::DebuggerClientOptions debugger_options;
};
struct StartTime {
StartTime() : startTime(time(nullptr)) {}
time_t startTime;
};
static bool registrationComplete = false;
static StartTime s_startTime;
static std::string tempFile;
std::vector<std::string> s_config_files;
std::vector<std::string> s_ini_strings;
time_t start_time() {
return s_startTime.startTime;
}
const StaticString
s_HPHP("HPHP"),
s_HHVM("HHVM"),
s_HHVM_JIT("HHVM_JIT"),
s_HHVM_ARCH("HHVM_ARCH"),
s_REQUEST_START_TIME("REQUEST_START_TIME"),
s_REQUEST_TIME("REQUEST_TIME"),
s_REQUEST_TIME_FLOAT("REQUEST_TIME_FLOAT"),
s_DOCUMENT_ROOT("DOCUMENT_ROOT"),
s_SCRIPT_FILENAME("SCRIPT_FILENAME"),
s_SCRIPT_NAME("SCRIPT_NAME"),
s_PHP_SELF("PHP_SELF"),
s_argc("argc"),
s_argv("argv"),
s_PWD("PWD"),
s_HOSTNAME("HOSTNAME"),
s__SERVER("_SERVER"),
s__ENV("_ENV");
static __thread bool s_sessionInitialized{false};
static void process_cmd_arguments(int argc, char **argv) {
php_global_set(s_argc, Variant(argc));
Array argvArray(staticEmptyArray());
for (int i = 0; i < argc; i++) {
argvArray.append(String(argv[i]));
}
php_global_set(s_argv, argvArray);
}
static void process_env_variables(Array& variables, char** envp,
std::map<std::string, std::string>& envVariables) {
for (auto& kv : envVariables) {
variables.set(String(kv.first), String(kv.second));
}
for (char **env = envp; env && *env; env++) {
char *p = strchr(*env, '=');
if (p) {
String name(*env, p - *env, CopyString);
register_variable(variables, (char*)name.data(),
String(p + 1, CopyString));
}
}
}
void process_env_variables(Array& variables) {
process_env_variables(variables, environ, RuntimeOption::EnvVariables);
}
// Handle adding a variable to an array, supporting keys that look
// like array expressions (like 'FOO[][key1][k2]').
void register_variable(Array& variables, char *name, const Variant& value,
bool overwrite /* = true */) {
// ignore leading spaces in the variable name
char *var = name;
while (*var && *var == ' ') {
var++;
}
// ensure that we don't have spaces or dots in the variable name
// (not binary safe)
bool is_array = false;
char *ip = nullptr; // index pointer
char *p = var;
for (; *p; p++) {
if (*p == ' ' || *p == '.') {
*p = '_';
} else if (*p == '[') {
is_array = true;
ip = p;
*p = 0;
break;
}
}
int var_len = p - var;
if (var_len == 0) {
// empty variable name, or variable name with a space in it
return;
}
// GPC elements holds Variants that are acting as smart pointers to
// RefDatas that we've created in the process of a multi-dim key.
std::vector<Variant> gpc_elements;
if (is_array) gpc_elements.reserve(MAX_INPUT_NESTING_LEVEL);
// The array pointer we're currently adding to. If we're doing a
// multi-dimensional set, this will point at the m_data.parr inside
// of a RefData sometimes (via toArrRef on the variants in
// gpc_elements).
Array* symtable = &variables;
char* index = var;
int index_len = var_len;
if (is_array) {
int nest_level = 0;
while (true) {
if (++nest_level > MAX_INPUT_NESTING_LEVEL) {
Logger::Warning("Input variable nesting level exceeded");
return;
}
ip++;
char *index_s = ip;
int new_idx_len = 0;
if (isspace(*ip)) {
ip++;
}
if (*ip == ']') {
index_s = nullptr;
} else {
ip = strchr(ip, ']');
if (!ip) {
// PHP variables cannot contain '[' in their names,
// so we replace the character with a '_'
*(index_s - 1) = '_';
index_len = 0;
if (index) {
index_len = strlen(index);
}
goto plain_var;
}
*ip = 0;
new_idx_len = strlen(index_s);
}
if (!index) {
auto lval = symtable->lvalAt();
lval.type() = KindOfPersistentArray;
lval.val().parr = staticEmptyArray();
gpc_elements.push_back(uninit_null());
gpc_elements.back().assignRef(tvAsVariant(lval.tv_ptr()));
} else {
String key(index, index_len, CopyString);
auto const v = symtable->rvalAt(key).unboxed();
if (isNullType(v.type()) || !isArrayLikeType(v.type())) {
symtable->set(key, Array::Create());
}
gpc_elements.push_back(uninit_null());
gpc_elements.back().assignRef(
tvAsVariant(symtable->lvalAt(key).tv_ptr())
);
}
symtable = &gpc_elements.back().toArrRef();
/* ip pointed to the '[' character, now obtain the key */
index = index_s;
index_len = new_idx_len;
ip++;
if (*ip == '[') {
is_array = true;
*ip = 0;
} else {
goto plain_var;
}
}
} else {
plain_var:
if (!index) {
symtable->append(value);
} else {
String key(index, index_len, CopyString);
if (overwrite || !symtable->exists(key)) {
symtable->set(key, value);
}
}
}
}
enum class ContextOfException {
ReqInit = 1,
Invoke,
Handler,
};
static void handle_exception_append_bt(std::string& errorMsg,
const ExtendedException& e) {
Array bt = e.getBacktrace();
if (!bt.empty()) {
errorMsg += ExtendedLogger::StringOfStackTrace(bt);
}
}
void bump_counter_and_rethrow(bool isPsp) {
try {
throw;
} catch (const RequestTimeoutException& e) {
if (isPsp) {
static auto requestTimeoutPSPCounter = ServiceData::createTimeSeries(
"requests_timed_out_psp", {ServiceData::StatsType::COUNT});
requestTimeoutPSPCounter->addValue(1);
ServerStats::Log("request.timed_out.psp", 1);
} else {
static auto requestTimeoutCounter = ServiceData::createTimeSeries(
"requests_timed_out_non_psp", {ServiceData::StatsType::COUNT});
requestTimeoutCounter->addValue(1);
ServerStats::Log("request.timed_out.non_psp", 1);
}
throw;
} catch (const RequestCPUTimeoutException& e) {
if (isPsp) {
static auto requestCPUTimeoutPSPCounter = ServiceData::createTimeSeries(
"requests_cpu_timed_out_psp", {ServiceData::StatsType::COUNT});
requestCPUTimeoutPSPCounter->addValue(1);
ServerStats::Log("request.cpu_timed_out.psp", 1);
} else {
static auto requestCPUTimeoutCounter = ServiceData::createTimeSeries(
"requests_cpu_timed_out_non_psp", {ServiceData::StatsType::COUNT});
requestCPUTimeoutCounter->addValue(1);
ServerStats::Log("request.cpu_timed_out.non_psp", 1);
}
throw;
} catch (const RequestMemoryExceededException& e) {
if (isPsp) {
static auto requestMemoryExceededPSPCounter =
ServiceData::createTimeSeries(
"requests_memory_exceeded_psp", {ServiceData::StatsType::COUNT});
requestMemoryExceededPSPCounter->addValue(1);
ServerStats::Log("request.memory_exceeded.psp", 1);
} else {
static auto requestMemoryExceededCounter = ServiceData::createTimeSeries(
"requests_memory_exceeded_non_psp", {ServiceData::StatsType::COUNT});
requestMemoryExceededCounter->addValue(1);
ServerStats::Log("request.memory_exceeded.non_psp", 1);
}
#ifdef USE_JEMALLOC
// Capture a pprof (C++) dump when we OOM a request
// TODO: (t3753133) Should dump a PHP-instrumented pprof dump here as well
jemalloc_pprof_dump("", false);
#endif
throw;
}
}
static void handle_exception_helper(bool& ret,
ExecutionContext* context,
std::string& errorMsg,
ContextOfException where,
bool& error,
bool richErrorMsg) {
// Clear oom/timeout while handling exception and restore them afterwards.
auto& flags = stackLimitAndSurprise();
auto const origFlags = flags.fetch_and(~ResourceFlags) & ResourceFlags;
SCOPE_EXIT {
flags.fetch_or(origFlags);
};
try {
bump_counter_and_rethrow(false /* isPsp */);
} catch (const Eval::DebuggerException &e) {
throw;
} catch (const ExitException &e) {
if (where == ContextOfException::ReqInit) {
ret = false;
} else if (where != ContextOfException::Handler &&
!context->getExitCallback().isNull() &&
is_callable(context->getExitCallback())) {
Array stack = e.getBacktrace();
Array argv = make_packed_array(tl_exit_code, stack);
vm_call_user_func(context->getExitCallback(), argv);
}
} catch (const XDebugExitExn&) {
// Do nothing, this is normal behavior.
} catch (const PhpFileDoesNotExistException &e) {
ret = false;
if (where != ContextOfException::Handler) {
raise_notice("%s", e.getMessage().c_str());
} else {
Logger::Error("%s", e.getMessage().c_str());
}
if (richErrorMsg) {
handle_exception_append_bt(errorMsg, e);
}
} catch (const Exception &e) {
bool oldRet = ret;
bool origError = error;
std::string origErrorMsg = errorMsg;
ret = false;
error = true;
errorMsg = "";
if (where == ContextOfException::Handler) {
errorMsg = "Exception handler threw an exception: ";
}
errorMsg += e.what();
if (where == ContextOfException::Invoke) {
bool handlerRet = context->onFatalError(e);
if (handlerRet) {
ret = oldRet;
error = origError;
errorMsg = origErrorMsg;
}
} else {
Logger::Error("%s", errorMsg.c_str());
}
if (richErrorMsg) {
const ExtendedException *ee = dynamic_cast<const ExtendedException *>(&e);
if (ee) {
handle_exception_append_bt(errorMsg, *ee);
}
}
} catch (const Object &e) {
bool oldRet = ret;
bool origError = error;
auto const origErrorMsg = errorMsg;
ret = false;
error = true;
errorMsg = "";
if (where == ContextOfException::Handler) {
errorMsg = "Exception handler threw an object exception: ";
}
try {
errorMsg += e.toString().data();
} catch (...) {
errorMsg += "(unable to call toString())";
}
if (where == ContextOfException::Invoke) {
bool handlerRet = context->onUnhandledException(e);
if (handlerRet) {
ret = oldRet;
error = origError;
errorMsg = origErrorMsg;
}
} else {
Logger::Error("%s", errorMsg.c_str());
}
} catch (...) {
ret = false;
error = true;
errorMsg = "(unknown exception was thrown)";
Logger::Error("%s", errorMsg.c_str());
}
}
static bool hphp_chdir_file(const std::string& filename) {
bool ret = false;
String s = File::TranslatePath(filename);
char *buf = strndup(s.data(), s.size());
char *dir = dirname(buf);
assertx(dir);
if (dir) {
if (File::IsVirtualDirectory(dir)) {
g_context->setCwd(String(dir, CopyString));
ret = true;
} else {
struct stat sb;
stat(dir, &sb);
if ((sb.st_mode & S_IFMT) == S_IFDIR) {
ret = true;
if (*dir != '.') {
g_context->setCwd(String(dir, CopyString));
}
}
}
}
free(buf);
return ret;
}
static void handle_resource_exceeded_exception() {
try {
throw;
} catch (RequestTimeoutException&) {
setSurpriseFlag(TimedOutFlag);
} catch (RequestCPUTimeoutException&) {
setSurpriseFlag(CPUTimedOutFlag);
} catch (RequestMemoryExceededException&) {
setSurpriseFlag(MemExceededFlag);
} catch (...) {}
}
void handle_destructor_exception(const char* situation) {
std::string errorMsg;
try {
throw;
} catch (ExitException &e) {
// ExitException is fine, no need to show a warning.
TI().setPendingException(e.clone());
return;
} catch (Object &e) {
// For user exceptions, invoke the user exception handler
errorMsg = situation;
errorMsg += " threw an object exception: ";
try {
errorMsg += e.toString().data();
} catch (...) {
handle_resource_exceeded_exception();
errorMsg += "(unable to call toString())";
}
} catch (Exception &e) {
TI().setPendingException(e.clone());
errorMsg = situation;
errorMsg += " raised a fatal error: ";
errorMsg += e.what();
} catch (...) {
errorMsg = situation;
errorMsg += " threw an unknown exception";
}
// For fatal errors and unknown exceptions, we raise a warning.
// If there is a user error handler it will be invoked, otherwise
// the default error handler will be invoked.
try {
raise_warning_unsampled("%s", errorMsg.c_str());
} catch (...) {
handle_resource_exceeded_exception();
// The user error handler fataled or threw an exception,
// print out the error message directly to the log
Logger::Warning("%s", errorMsg.c_str());
}
}
void init_command_line_session(int argc, char** argv) {
StackTraceNoHeap::AddExtraLogging("ThreadType", "CLI");
std::string args;
for (int i = 0; i < argc; i++) {
if (i) args += " ";
args += argv[i];
}
StackTraceNoHeap::AddExtraLogging("Arguments", args.c_str());
hphp_session_init();
auto const context = g_context.getNoCheck();
context->obSetImplicitFlush(true);
}
void
init_command_line_globals(int argc, char** argv, char** envp,
int xhprof,
std::map<std::string, std::string>& serverVariables,
std::map<std::string, std::string>& envVariables) {
auto& variablesOrder = RID().getVariablesOrder();
if (variablesOrder.find('e') != std::string::npos ||
variablesOrder.find('E') != std::string::npos) {
Array envArr(Array::Create());
process_env_variables(envArr, envp, envVariables);
envArr.set(s_HPHP, 1);
envArr.set(s_HHVM, 1);
if (RuntimeOption::EvalJit) {
envArr.set(s_HHVM_JIT, 1);
}
switch (arch()) {
case Arch::X64:
envArr.set(s_HHVM_ARCH, "x64");
break;
case Arch::ARM:
envArr.set(s_HHVM_ARCH, "arm");
break;
case Arch::PPC64:
envArr.set(s_HHVM_ARCH, "ppc64");
break;
}
php_global_set(s__ENV, envArr);
}
process_cmd_arguments(argc, argv);
if (variablesOrder.find('s') != std::string::npos ||
variablesOrder.find('S') != std::string::npos) {
Array serverArr(Array::Create());
process_env_variables(serverArr, envp, envVariables);
time_t now;
struct timeval tp = {0};
double now_double;
if (!gettimeofday(&tp, nullptr)) {
now_double = (double)(tp.tv_sec + tp.tv_usec / 1000000.00);
now = tp.tv_sec;
} else {
now = time(nullptr);
now_double = (double)now;
}
String file = empty_string();
if (argc > 0) {
file = String::attach(StringData::Make(argv[0], CopyString));
}
serverArr.set(s_REQUEST_START_TIME, now);
serverArr.set(s_REQUEST_TIME, now);
serverArr.set(s_REQUEST_TIME_FLOAT, now_double);
serverArr.set(s_DOCUMENT_ROOT, empty_string_variant_ref);
serverArr.set(s_SCRIPT_FILENAME, file);
serverArr.set(s_SCRIPT_NAME, file);
serverArr.set(s_PHP_SELF, file);
serverArr.set(s_argv, php_global(s_argv));
serverArr.set(s_argc, php_global(s_argc));
serverArr.set(s_PWD, g_context->getCwd());
char hostname[1024];
if (RuntimeOption::ServerExecutionMode() &&
!is_cli_mode() &&
!gethostname(hostname, sizeof(hostname))) {
// gethostname may not null-terminate
hostname[sizeof(hostname) - 1] = '\0';
serverArr.set(s_HOSTNAME, String(hostname, CopyString));
}
for (auto& kv : serverVariables) {
serverArr.set(String(kv.first.c_str()), String(kv.second.c_str()));
}
php_global_set(s__SERVER, serverArr);
}
if (xhprof) {
HHVM_FN(xhprof_enable)(xhprof, uninit_null().toArray());
}
if (RuntimeOption::RequestTimeoutSeconds) {
RID().setTimeout(RuntimeOption::RequestTimeoutSeconds);
}
if (RuntimeOption::XenonForceAlwaysOn) {
Xenon::getInstance().surpriseAll();
}
InitFiniNode::GlobalsInit();
// Initialize the debugger
DEBUGGER_ATTACHED_ONLY(phpDebuggerRequestInitHook());
}
void execute_command_line_begin(int argc, char **argv, int xhprof) {
init_command_line_session(argc, argv);
init_command_line_globals(argc, argv, environ, xhprof,
RuntimeOption::ServerVariables,
RuntimeOption::EnvVariables);
}
void execute_command_line_end(int xhprof, bool coverage, const char *program) {
if (RuntimeOption::EvalDumpTC ||
RuntimeOption::EvalDumpIR ||
RuntimeOption::EvalDumpRegion) {
jit::mcgen::joinWorkerThreads();
jit::tc::dump();
}
if (xhprof) {
Variant profileData = HHVM_FN(xhprof_disable)();
if (!profileData.isNull()) {
HHVM_FN(var_dump)(Variant::attach(
HHVM_FN(json_encode)(HHVM_FN(xhprof_disable)())
));
}
}
g_context->onShutdownPostSend(); // runs more php
Eval::Debugger::InterruptPSPEnded(program);
hphp_context_exit();
hphp_session_exit();
auto& ti = TI();
if (coverage && ti.m_reqInjectionData.getCoverage() &&
!RuntimeOption::CodeCoverageOutputFile.empty()) {
ti.m_coverage->Report(RuntimeOption::CodeCoverageOutputFile);
}
}
#if defined(__APPLE__) || defined(_MSC_VER)
const void* __hot_start = nullptr;
const void* __hot_end = nullptr;
#define AT_END_OF_TEXT
#else
#define AT_END_OF_TEXT __attribute__((__section__(".stub")))
#endif
#define ALIGN_HUGE_PAGE __attribute__((__aligned__(2 * 1024 * 1024)))
static void
NEVER_INLINE AT_END_OF_TEXT ALIGN_HUGE_PAGE __attribute__((__optimize__("2")))
hugifyText(char* from, char* to) {
#if !FOLLY_SANITIZE && defined MADV_HUGEPAGE
if (from > to || (to - from) < sizeof(uint64_t)) {
// This shouldn't happen if HHVM is behaving correctly (I think),
// but if it does then there is nothing to do and we should bail
// out early because the call to wordcpy() below can't handle
// zero size or negative sizes.
return;
}
size_t sz = to - from;
void* mem = malloc(sz);
memcpy(mem, from, sz);
// This maps out a portion of our executable
// We need to be very careful about what we do
// until we replace the original code
mmap(from, sz,
PROT_READ | PROT_WRITE | PROT_EXEC,
MAP_PRIVATE | MAP_ANONYMOUS | MAP_FIXED,
-1, 0);
// This is in glibc, which isn't a problem, except for
// the trampoline code in .plt, which we dealt with
// in the linker script
madvise(from, sz, MADV_HUGEPAGE);
// Don't use memcpy because its probably one of the
// functions thats been mapped out.
// Needs the attribute((optimize("2")) to prevent
// g++ from turning this back into memcpy(!)
wordcpy((uint64_t*)from, (uint64_t*)mem, sz / sizeof(uint64_t));
mprotect(from, sz, PROT_READ | PROT_EXEC);
free(mem);
mlock(from, to - from);
Debug::DebugInfo::setPidMapOverlay(from, to);
std::stringstream ss;
ss << "Mapped text section onto huge pages from " <<
std::hex << (uint64_t*)from << " to " << (uint64_t*)to;
Logger::Info(ss.str());
#endif
}
static void pagein_self(void) {
#if defined(USE_JEMALLOC) && (JEMALLOC_VERSION_MAJOR >= 5)
// jemalloc 5 has background threads, which handle purging asynchronously.
bool background_threads = false;
if (mallctlRead("background_thread", &background_threads)) {
background_threads = false;
Logger::Warning("Failed to determine jemalloc background thread state");
}
if (background_threads &&
mallctlWrite("background_thread", false, /* errorOK */ true)) {
Logger::Warning("Failed to disable jemalloc background threads");
}
SCOPE_EXIT {
if (background_threads &&
mallctlWrite("background_thread", true, /* errorOK */ true)) {
Logger::Warning("Failed to enable jemalloc background threads");
}
};
#endif
// Other than the jemalloc background threads, which should've been stopped by
// now, the only thread allowed here is the current one. Check that and alarm
// people when they accidentally created threads before this point.
int nThreads = Process::GetNumThreads();
if (nThreads > 1) {
Logger::Error("%d threads running, cannot hugify text!", nThreads);
fprintf(stderr,
"HHVM is broken: %u threads running in hugifyText()!\n",
nThreads);
if (debug) {
throw std::runtime_error{"you cannot create threads before pagein_self"};
}
}
auto mapped_huge = false;
#ifdef __linux__
auto const try_map_huge =
hugePagesSupported() &&
RuntimeOption::EvalMaxHotTextHugePages > 0 &&
(char*)__hot_start != nullptr && (char*)__hot_end != nullptr &&
nThreads <= 1;
SCOPE_EXIT {
if (try_map_huge != mapped_huge) {
Logger::Warning("Failed to hugify the .text section");
}
};
#else
// MacOS doesn't have transparent huge pages. It uses mmap() with
// VM_FLAGS_SUPERPAGE_SIZE_2MB, which we don't do here, so don't bother.
auto constexpr try_map_huge = false;
#endif
BootStats::Block timer("mapping self");
char mapname[PATH_MAX];
// pad due to the spaces between the inode number and the mapname
auto const bufsz =
sizeof(unsigned long) * 4 + sizeof(mapname) + sizeof(char) * 11 + 100;
auto buf = static_cast<char*>(malloc(bufsz));
if (auto fp = fopen("/proc/self/maps", "r")) {
while (!feof(fp)) {
if (fgets(buf, bufsz, fp) == 0)
break;
unsigned long begin, end, inode, pgoff;
char perm[5];
char dev[11];
int r = sscanf(buf, "%lx-%lx %4s %lx %10s %ld %s",
&begin, &end, perm, &pgoff, dev, &inode, mapname);
// page in read-only segments that correspond to a file on disk
if (r != 7 ||
perm[0] != 'r' ||
perm[1] != '-' ||
access(mapname, F_OK) != 0) {
continue;
}
auto beginPtr = (char*)begin;
auto endPtr = (char*)end;
auto hotStart = (char*)__hot_start;
auto hotEnd = (char*)__hot_end;
const size_t hugePageBytes = 2L * 1024 * 1024;
if (mlock(beginPtr, end - begin) == 0) {
if (try_map_huge && beginPtr <= hotStart && hotEnd <= endPtr) {
char* from = hotStart - ((intptr_t)hotStart & (hugePageBytes - 1));
char* to = hotEnd + (hugePageBytes - 1);
to -= (intptr_t)to & (hugePageBytes - 1);
const size_t maxHugeHotTextBytes =
RuntimeOption::EvalMaxHotTextHugePages * hugePageBytes;
if (to - from > maxHugeHotTextBytes) {
to = from + maxHugeHotTextBytes;
}
if (to <= (void*)hugifyText) {
mapped_huge = true;
hugifyText(from, to);
}
}
if (!RuntimeOption::LockCodeMemory) {
munlock(beginPtr, end - begin);
}
}
}
fclose(fp);
}
free(buf);
}
/* Sets RuntimeOption::ExecutionMode according to commandline options prior to
* config load. Returns false upon unrecognized mode.
*/
static bool set_execution_mode(folly::StringPiece mode) {
if (mode == "daemon" || mode == "server" || mode == "replay") {
RuntimeOption::ServerMode = true;
Logger::Escape = true;
return true;
} else if (mode == "run" || mode == "debug" || mode == "translate" ||
mode == "dumphhas" || mode == "verify" || mode == "vsdebug") {
// We don't run PHP in "translate" mode, so just treat it like cli mode.
RuntimeOption::ServerMode = false;
Logger::Escape = false;
return true;
}
// Invalid mode.
return false;
}
/* Reads a file into the OS page cache, with rate limiting. */
static bool readahead_rate(const char* path, int64_t mbPerSec) {
int ret = open(path, O_RDONLY);
if (ret < 0) return false;
const int fd = ret;
SCOPE_EXIT { close(fd); };
constexpr size_t kReadaheadBytes = 1 << 20;
std::unique_ptr<char[]> buf(new char[kReadaheadBytes]);
int64_t total = 0;
auto startTime = std::chrono::steady_clock::now();
do {
ret = read(fd, buf.get(), kReadaheadBytes);
if (ret > 0) {
total += ret;
// Unit math: bytes / (MB / seconds) = microseconds
auto endTime = startTime + std::chrono::microseconds(total / mbPerSec);
auto sleepT = endTime - std::chrono::steady_clock::now();
// Don't sleep too frequently.
if (sleepT >= std::chrono::seconds(1)) {
Logger::Info(folly::sformat(
"readahead sleeping {}ms after total {}b",
std::chrono::duration_cast<std::chrono::milliseconds>(sleepT).count(),
total));
/* sleep override */ std::this_thread::sleep_for(sleepT);
}
}
} while (ret > 0);
return ret == 0;
}
static int start_server(const std::string &username, int xhprof) {
if (!registrationComplete) {
folly::SingletonVault::singleton()->registrationComplete();
registrationComplete = true;
}
BootStats::start();
HttpServer::CheckMemAndWait();
InitFiniNode::ServerPreInit();
if (!RuntimeOption::EvalUnixServerPath.empty()) {
init_cli_server(RuntimeOption::EvalUnixServerPath.c_str());
}
// Before we start the webserver, make sure the entire
// binary is paged into memory.
pagein_self();
BootStats::mark("pagein_self");
set_execution_mode("server");
#if !defined(SKIP_USER_CHANGE)
if (!username.empty()) {
if (Logger::UseCronolog) {
for (const auto& el : RuntimeOption::ErrorLogs) {
Cronolog::changeOwner(username, el.second.symLink);
}
}
if (!Capability::ChangeUnixUser(username, RuntimeOption::AllowRunAsRoot)) {
_exit(1);
}
LightProcess::ChangeUser(username);
compilers_set_user(username);
} else if (getuid() == 0 && !RuntimeOption::AllowRunAsRoot) {
Logger::Error("hhvm not allowed to run as root unless "
"-vServer.AllowRunAsRoot=1 is used.");
_exit(1);
}
Capability::SetDumpable();
// Include hugetlb pages in core dumps.
Process::SetCoreDumpHugePages();
#endif
hphp_process_init();
SCOPE_EXIT {
hphp_process_exit();
try { Logger::Info("all servers stopped"); } catch(...) {}
};
HttpRequestHandler::GetAccessLog().init
(RuntimeOption::AccessLogDefaultFormat, RuntimeOption::AccessLogs,
username);
AdminRequestHandler::GetAccessLog().init
(RuntimeOption::AdminLogFormat, RuntimeOption::AdminLogSymLink,
RuntimeOption::AdminLogFile,
username);
RPCRequestHandler::GetAccessLog().init
(RuntimeOption::AccessLogDefaultFormat, RuntimeOption::RPCLogs,
username);
SCOPE_EXIT { HttpRequestHandler::GetAccessLog().flushAllWriters(); };
SCOPE_EXIT { AdminRequestHandler::GetAccessLog().flushAllWriters(); };
SCOPE_EXIT { RPCRequestHandler::GetAccessLog().flushAllWriters(); };
SCOPE_EXIT { Logger::FlushAll(); };
if (RuntimeOption::ServerInternalWarmupThreads > 0) {
HttpServer::CheckMemAndWait();
InitFiniNode::WarmupConcurrentStart(
RuntimeOption::ServerInternalWarmupThreads);
}
HttpServer::CheckMemAndWait();
// Create the HttpServer before any warmup requests to properly
// initialize the process
HttpServer::Server = std::make_shared<HttpServer>();
if (xhprof) {
HHVM_FN(xhprof_enable)(xhprof, uninit_null().toArray());
}
std::unique_ptr<std::thread> readaheadThread;
if (RuntimeOption::RepoLocalReadaheadRate > 0 &&
!RuntimeOption::RepoLocalPath.empty()) {
HttpServer::CheckMemAndWait();
readaheadThread = std::make_unique<std::thread>([&] {
BootStats::Block timer("Readahead Repo");
auto path = RuntimeOption::RepoLocalPath.c_str();
Logger::Info("readahead %s", path);
#ifdef __linux__
// glibc doesn't have a wrapper for ioprio_set(), so we need to use
// syscall(). The constants here are consistent with the kernel source.
// See http://lxr.free-electrons.com/source/include/linux/ioprio.h
auto constexpr IOPRIO_CLASS_SHIFT = 13;
enum {
IOPRIO_CLASS_NONE,
IOPRIO_CLASS_RT,
IOPRIO_CLASS_BE,
IOPRIO_CLASS_IDLE,
};
// Set to lowest IO priority.
constexpr int ioprio = (IOPRIO_CLASS_IDLE << IOPRIO_CLASS_SHIFT);
// ioprio_set() is available starting kernel 2.6.13
KernelVersion version;
if (version.m_major > 2 ||
(version.m_major == 2 &&
(version.m_minor > 6 ||
(version.m_minor == 6 && version.m_release >= 13)))) {
syscall(SYS_ioprio_set,
1 /* IOPRIO_WHO_PROCESS, in fact, it is this thread */,
0 /* current thread */,
ioprio);
}
#endif
const auto mbPerSec = RuntimeOption::RepoLocalReadaheadRate;
if (!readahead_rate(path, mbPerSec)) {
Logger::Error("readahead failed: %s", strerror(errno));
}
});
if (!RuntimeOption::RepoLocalReadaheadConcurrent) {
// TODO(10152762): Run this concurrently with non-disk warmup.
readaheadThread->join();
readaheadThread.reset();
}
}
if (RuntimeOption::ServerInternalWarmupThreads > 0) {
BootStats::Block timer("concurrentWaitForEnd");
InitFiniNode::WarmupConcurrentWaitForEnd();
}
if (RuntimeOption::RepoPreload) {
HttpServer::CheckMemAndWait();
BootStats::Block timer("Preloading Repo");
profileWarmupStart();
preloadRepo();
profileWarmupEnd();
}
// If we have any warmup requests, replay them before listening for
// real connections
{
Logger::Info("Warming up");
if (!RuntimeOption::EvalJitProfileWarmupRequests) profileWarmupStart();
SCOPE_EXIT { profileWarmupEnd(); };
std::map<std::string, int> seen;
for (auto& file : RuntimeOption::ServerWarmupRequests) {
HttpServer::CheckMemAndWait();
// Take only the last part
folly::StringPiece f(file);
auto pos = f.rfind('/');
std::string str(pos == f.npos ? file : f.subpiece(pos + 1).str());
auto count = seen[str];
BootStats::Block timer(folly::sformat("warmup:{}:{}", str, count++));
seen[str] = count;
HttpRequestHandler handler(0);
ReplayTransport rt;
timespec start;
Timer::GetMonotonicTime(start);
std::string error;
Logger::Info("Replaying warmup request %s", file.c_str());
try {
rt.onRequestStart(start);
rt.replayInput(Hdf(file));
handler.run(&rt);
timespec stop;
Timer::GetMonotonicTime(stop);
Logger::Info("Finished successfully in %ld seconds",
stop.tv_sec - start.tv_sec);
} catch (std::exception& e) {
error = e.what();
}
if (error.size()) {
Logger::Info("Got exception during warmup: %s", error.c_str());
}
}
}
BootStats::mark("warmup");
if (RuntimeOption::StopOldServer) HttpServer::StopOldServer();
if (RuntimeOption::EvalEnableNuma && !getenv("HHVM_DISABLE_NUMA")) {
#ifdef USE_JEMALLOC
unsigned narenas;
size_t mib[3];
size_t miblen = 3;
if (mallctlWrite<uint64_t>("epoch", 1, true) == 0 &&
mallctlRead("arenas.narenas", &narenas, true) == 0 &&
mallctlnametomib("arena.0.purge", mib, &miblen) == 0) {
mib[1] = size_t(narenas);
mallctlbymib(mib, miblen, nullptr, nullptr, nullptr, 0);
}
#endif
enable_numa(RuntimeOption::EvalEnableNumaLocal);
BootStats::mark("enable_numa");
}
HttpServer::CheckMemAndWait(true); // Final wait
if (readaheadThread.get()) {
readaheadThread->join();
readaheadThread.reset();
}
if (!RuntimeOption::EvalUnixServerPath.empty()) {
start_cli_server();
}
SlabManager::init(); // allocate hugetlb pages for pooled slabs
HttpServer::Server->runOrExitProcess();
HttpServer::Server.reset();
return 0;
}
static void logSettings() {
if (RuntimeOption::ServerLogSettingsOnStartup) {
Logger::Info("Settings: %s\n", IniSetting::GetAllAsJSON().c_str());
}
}
static InitFiniNode s_logSettings(logSettings, InitFiniNode::When::ServerInit);
std::string translate_stack(const char *hexencoded, bool with_frame_numbers) {
if (!hexencoded || !*hexencoded) {
return "";
}
StackTrace st(hexencoded);
std::vector<std::shared_ptr<StackFrameExtra>> frames;
st.get(frames);
std::ostringstream out;
for (size_t i = 0; i < frames.size(); i++) {
auto f = frames[i];
if (with_frame_numbers) {
out << "# " << (i < 10 ? " " : "") << i << ' ';
}
out << f->toString();
out << '\n';
}
return out.str();
}
///////////////////////////////////////////////////////////////////////////////
static void prepare_args(int &argc,
char **&argv,
const std::vector<std::string> &args,
const char *file) {
argv = (char **)malloc((args.size() + 2) * sizeof(char*));
argc = 0;
if (file && *file) {
argv[argc++] = (char*)file;
}
for (int i = 0; i < (int)args.size(); i++) {
argv[argc++] = (char*)args[i].c_str();
}
argv[argc] = nullptr;
}
static int execute_program_impl(int argc, char **argv);
int execute_program(int argc, char **argv) {
int ret_code = -1;
try {
try {
initialize_repo();
ret_code = execute_program_impl(argc, argv);
} catch (const Exception &e) {
Logger::Error("Uncaught exception: %s", e.what());
throw;
} catch (const std::exception &e) {
Logger::Error("Uncaught exception: %s", e.what());
throw;
} catch (...) {
Logger::Error("Uncaught exception: (unknown)");
throw;
}
if (tempFile.length() && boost::filesystem::exists(tempFile)) {
boost::filesystem::remove(tempFile);
}
} catch (...) {
if (HttpServer::Server ||
folly::SingletonVault::singleton()->livingSingletonCount()) {
// an exception was thrown that prevented proper shutdown. Its not
// safe to destroy the globals, or run atexit handlers.
// abort() so it shows up as a crash, and we can diagnose/fix the
// exception
abort();
}
}
return ret_code;
}
static bool open_server_log_files() {
bool openedLog = false;
for (const auto& el : RuntimeOption::ErrorLogs) {
bool ok = true;
const auto& name = el.first;
const auto& errlog = el.second;
if (!errlog.logFile.empty()) {
if (errlog.isPipeOutput()) {
auto output = popen(errlog.logFile.substr(1).c_str(), "w");
ok = (output != nullptr);
Logger::SetOutput(name, output, true);
} else if (Logger::UseCronolog && errlog.hasTemplate()) {
auto cronoLog = Logger::CronoOutput(name);
always_assert(cronoLog);
cronoLog->m_template = errlog.logFile;
cronoLog->setPeriodicity();
if (errlog.periodMultiplier) {
cronoLog->m_periodMultiple = errlog.periodMultiplier;
}
cronoLog->m_linkName = errlog.symLink;
} else {
auto output = fopen(errlog.logFile.c_str(), "a");
ok = (output != nullptr);
Logger::SetOutput(name, output, false);
}
if (!ok) Logger::Error("Can't open log file: %s", errlog.logFile.c_str());
openedLog |= ok;
}
}
return openedLog;
}
static int compute_hhvm_argc(const options_description& desc,
int argc, char** argv) {
enum ArgCode {
NO_ARG = 0,
ARG_REQUIRED = 1,
ARG_OPTIONAL = 2
};
const auto& vec = desc.options();
std::map<std::string,ArgCode> long_options;
std::map<std::string,ArgCode> short_options;
// Build lookup maps for the short options and the long options
for (unsigned i = 0; i < vec.size(); ++i) {
auto opt = vec[i];
auto long_name = opt->long_name();
ArgCode code = NO_ARG;
if (opt->semantic()->max_tokens() == 1) {
if (opt->semantic()->min_tokens() == 1) {
code = ARG_REQUIRED;
} else {
code = ARG_OPTIONAL;
}
}
long_options[long_name] = code;
auto format_name = opt->format_name();
if (format_name.size() >= 2 && format_name[0] == '-' &&
format_name[1] != '-') {
auto short_name = format_name.substr(1,1);
short_options[short_name] = code;
}
}
// Loop over the args
int pos = 1;
while (pos < argc) {
const char* str = argv[pos];
int len = strlen(str);
if (len == 2 && memcmp(str, "--", 2) == 0) {
// We found "--". All args after this are intended for the
// PHP application
++pos;
break;
}
if (len >= 3 && str[0] == '-' && str[1] == '-') {
// Handle long options
++pos;
std::string s(str+2);
auto it = long_options.find(s);
if (it != long_options.end() && it->second != NO_ARG && pos < argc &&
(it->second == ARG_REQUIRED || argv[pos][0] != '-')) {
++pos;
}
} else if (len >= 2 && str[0] == '-') {
// Handle short options
++pos;
std::string s;
s.append(1, str[1]);
auto it = short_options.find(s);
if (it != short_options.end() && it->second != 0 && len == 2 &&
pos < argc && (it->second == ARG_REQUIRED || argv[pos][0] != '-')) {
++pos;
}
} else {
// We've found a non-option argument. This arg and all args
// that follow are intended for the PHP application
break;
}
}
return pos;
}
/*
* alloc.h defines a minimum C++ stack size but that only applies to threads we
* manually create. When the main thread will be executing PHP rather than just
* managing a server, make sure its stack is big enough.
*/
static void set_stack_size() {
struct rlimit rlim;
if (getrlimit(RLIMIT_STACK, &rlim) != 0) return;
if (rlim.rlim_cur < kStackSizeMinimum || rlim.rlim_cur == RLIM_INFINITY) {
#ifdef _WIN32
Logger::Error("stack limit too small, use peflags -x to increase %zd\n",
kStackSizeMinimum);
#else
rlim.rlim_cur = kStackSizeMinimum;
if (setrlimit(RLIMIT_STACK, &rlim)) {
Logger::Error("failed to set stack limit to %zd\n", kStackSizeMinimum);
}
#endif
}
}
#if defined(BOOST_VERSION) && BOOST_VERSION <= 105400
std::string get_right_option_name(const basic_parsed_options<char>& opts,
std::string& wrong_name) {
// Remove any - from the wrong name for better comparing
// since it will probably come prepended with --
wrong_name.erase(
std::remove(wrong_name.begin(), wrong_name.end(), '-'), wrong_name.end());
for (basic_option<char> opt : opts.options) {
std::string s_opt = opt.string_key;
// We are only dealing with options that have a - in them.
if (s_opt.find("-") != std::string::npos) {
if (s_opt.find(wrong_name) != std::string::npos) {
return s_opt;
}
}
}
return "";
}
#endif
static int execute_program_impl(int argc, char** argv) {
std::string usage = "Usage:\n\n ";
usage += argv[0];
usage += " [-m <mode>] [<options>] [<arg1>] [<arg2>] ...\n\nOptions";
ProgramOptions po;
options_description desc(usage.c_str());
desc.add_options()
("help", "display this message")
("version", "display version number")
("modules", "display modules")
("info", "PHP information")
("php", "emulate the standard php command line")
("compiler-id", "display the git hash for the compiler")
("repo-schema", "display the repository schema id")
("mode,m", value<std::string>(&po.mode)->default_value("run"),
"run | debug (d) | vsdebug | server (s) | daemon | replay | "
"translate (t) | verify")
("interactive,a", "Shortcut for --mode debug") // -a is from PHP5
("config,c", value<std::vector<std::string>>(&po.config)->composing(),
"load specified config file")
("config-value,v",
value<std::vector<std::string>>(&po.confStrings)->composing(),
"individual configuration string in a format of name=value, where "
"name can be any valid configuration for a config file")
("define,d", value<std::vector<std::string>>(&po.iniStrings)->composing(),
"define an ini setting in the same format ( foo[=bar] ) as provided in a "
".ini file")
("no-config", "don't use the default php.ini")
("port,p", value<int>(&po.port)->default_value(-1),
"start an HTTP server at specified port")
("port-fd", value<int>(&po.portfd)->default_value(-1),
"use specified fd instead of creating a socket")
("ssl-port-fd", value<int>(&po.sslportfd)->default_value(-1),
"use specified fd for SSL instead of creating a socket")
("admin-port", value<int>(&po.admin_port)->default_value(-1),
"start admin listener at specified port")
("debug-config", value<std::string>(&po.debugger_options.configFName),
"load specified debugger config file")
("debug-host,h",
value<std::string>(&po.debugger_options.host)->implicit_value("localhost"),
"connect to debugger server at specified address")
("debug-port", value<int>(&po.debugger_options.port)->default_value(-1),
"connect to debugger server at specified port")
("debug-extension", value<std::string>(&po.debugger_options.extension),
"PHP file that extends command 'arg'")
("debug-cmd", value<std::vector<std::string>>(
&po.debugger_options.cmds)->composing(),
"executes this debugger command and returns its output in stdout")
("debug-sandbox",
value<std::string>(&po.debugger_options.sandbox)->default_value("default"),
"initial sandbox to attach to when debugger is started")
("user,u", value<std::string>(&po.user),
"run server under this user account")
("file,f", value<std::string>(&po.file),
"execute specified file")
("lint,l", value<std::string>(&po.lint),
"lint specified file")
("show,w", value<std::string>(&po.show),
"output specified file and do nothing else")
("temp-file",
"file specified is temporary and removed after execution")
("count", value<int>(&po.count)->default_value(1),
"how many times to repeat execution")
("no-safe-access-check",
value<bool>(&po.noSafeAccessCheck)->default_value(false),
"whether to ignore safe file access check")
("arg", value<std::vector<std::string>>(&po.args)->composing(),
"arguments")
("extra-header", value<std::string>(&Logger::ExtraHeader),
"extra-header to add to log lines")
("build-id", value<std::string>(&po.buildId),
"unique identifier of compiled server code")
("instance-id", value<std::string>(&po.instanceId),
"unique identifier of server instance")
("xhprof-flags", value<int>(&po.xhprofFlags)->default_value(0),
"Set XHProf flags")
("vsDebugPort", value<int>(&po.vsDebugPort)->default_value(-1),
"Debugger port to listen on for the VS Code debugger extension")
("vsDebugNoWait", value<bool>(&po.vsDebugNoWait)->default_value(false),
"Indicates the debugger should not block script startup waiting for "
"a debugger client to attach. Only applies if vsDebugPort is specified.")
;
positional_options_description p;
p.add("arg", -1);
variables_map vm;
// Before invoking the boost command line parser, we do a manual pass
// to find the first occurrence of either "--" or a non-option argument
// in order to determine which arguments should be consumed by HHVM and
// which arguments should be passed along to the PHP application. This
// is necessary so that the boost command line parser doesn't choke on
// args intended for the PHP application.
int hhvm_argc = compute_hhvm_argc(desc, argc, argv);
// Need to have a parent try for opts so I can use opts in the catch of
// one of the sub-tries below.
try {
// Invoke the boost command line parser to parse the args for HHVM.
auto opts = command_line_parser(hhvm_argc, argv)
.options(desc)
.positional(p)
// If these style options are changed, compute_hhvm_argc() will
// need to be updated appropriately
.style(command_line_style::default_style &
~command_line_style::allow_guessing &
~command_line_style::allow_sticky &
~command_line_style::long_allow_adjacent)
.run();
try {
// Manually append the args for the PHP application.
int pos = 0;
for (unsigned m = 0; m < opts.options.size(); ++m) {
const auto& bo = opts.options[m];
if (bo.string_key == "arg") {
++pos;
}
}
for (unsigned m = hhvm_argc; m < argc; ++m) {
std::string str = argv[m];
basic_option<char> bo;
bo.string_key = "arg";
bo.position_key = pos++;
bo.value.push_back(str);
bo.original_tokens.push_back(str);
bo.unregistered = false;
bo.case_insensitive = false;
opts.options.push_back(bo);
}
// Process the options
store(opts, vm);
notify(vm);
if (vm.count("interactive") /* or -a */) po.mode = "debug";
else if (po.mode.empty()) po.mode = "run";
else if (po.mode == "d") po.mode = "debug";
else if (po.mode == "s") po.mode = "server";
else if (po.mode == "t") po.mode = "translate";
if (!set_execution_mode(po.mode)) {
Logger::Error("Error in command line: invalid mode: %s",
po.mode.c_str());
cout << desc << "\n";
return -1;
}
if (po.config.empty() && !vm.count("no-config")
&& ::getenv("HHVM_NO_DEFAULT_CONFIGS") == nullptr) {
auto file_callback = [&po] (const char *filename) {
Logger::Verbose("Using default config file: %s", filename);
po.config.push_back(filename);
};
add_default_config_files_globbed(DEFAULT_CONFIG_DIR "/php*.ini",
file_callback);
add_default_config_files_globbed(DEFAULT_CONFIG_DIR "/config*.hdf",
file_callback);
}
const auto env_config = ::getenv("HHVM_CONFIG_FILE");
if (env_config != nullptr) {
add_default_config_files_globbed(
env_config,
[&po](const char* filename) {
Logger::Verbose("Using config file from environment: %s", filename);
po.config.push_back(filename);
}
);
}
// When we upgrade boost, we can remove this and also get rid of the parent
// try statement and move opts back into the original try block
#if defined(BOOST_VERSION) && BOOST_VERSION >= 105000 && BOOST_VERSION <= 105400
} catch (const error_with_option_name &e) {
std::string wrong_name = e.get_option_name();
std::string right_name = get_right_option_name(opts, wrong_name);
std::string message = e.what();
if (right_name != "") {
boost::replace_all(message, wrong_name, right_name);
}
Logger::Error("Error in command line: %s", message.c_str());
cout << desc << "\n";
return -1;
#endif
} catch (const error &e) {
Logger::Error("Error in command line: %s", e.what());
cout << desc << "\n";
return -1;
} catch (...) {
Logger::Error("Error in command line.");
cout << desc << "\n";
return -1;
}
} catch (const error &e) {
Logger::Error("Error in command line: %s", e.what());
cout << desc << "\n";
return -1;
} catch (...) {
Logger::Error("Error in command line parsing.");
cout << desc << "\n";
return -1;
}
// reuse -h for help command if possible
if (vm.count("help") || (vm.count("debug-host") && po.mode != "debug")) {
cout << desc << "\n";
return 0;
}
if (vm.count("version")) {
cout << "HipHop VM";
cout << " " << HHVM_VERSION;
cout << " (" << (debug ? "dbg" : "rel") << ")\n";
cout << "Compiler: " << compilerId() << "\n";
cout << "Repo schema: " << repoSchemaId() << "\n";
return 0;
}
if (vm.count("modules")) {
Array exts = ExtensionRegistry::getLoaded();
cout << "[PHP Modules]" << "\n";
for (ArrayIter iter(exts); iter; ++iter) {
cout << iter.second().toString().toCppString() << "\n";
}
return 0;
}
if (vm.count("compiler-id")) {
cout << compilerId() << "\n";
return 0;
}
if (vm.count("repo-schema")) {
cout << repoSchemaId() << "\n";
return 0;
}
if (!po.show.empty()) {
auto f = req::make<PlainFile>();
f->open(po.show, "r");
if (!f->valid()) {
Logger::Error("Unable to open file %s", po.show.c_str());
return 1;
}
f->print();
f->close();
return 0;
}
po.isTempFile = vm.count("temp-file");
// forget the source for systemlib.php unless we are debugging
if (po.mode != "debug" && po.mode != "vsdebug") SystemLib::s_source = "";
if (po.mode == "vsdebug") {
RuntimeOption::EnableVSDebugger = true;
RuntimeOption::VSDebuggerListenPort = po.vsDebugPort;
RuntimeOption::VSDebuggerNoWait = po.vsDebugNoWait;
}
// we need to initialize pcre cache table very early
pcre_init();
tl_heap.getCheck();
if (RuntimeOption::ServerExecutionMode()) {
// Create the hardware counter before reading options,
// so that the main thread never has inherit set in server
// mode
HardwareCounter::s_counter.getCheck();
}
std::vector<std::string> messages;
// We want the ini map to be freed after processing and loading the options
// So put this in its own block
{
IniSettingMap ini = IniSettingMap();
Hdf config;
s_config_files = po.config;
// Start with .hdf and .ini files
for (auto& filename : s_config_files) {
if (boost::filesystem::exists(filename)) {
Config::ParseConfigFile(filename, ini, config);
} else {
Logger::Warning(
"The configuration file %s does not exist",
filename.c_str()
);
}
}
// Now, take care of CLI options and then officially load and bind things
s_ini_strings = po.iniStrings;
RuntimeOption::Load(ini, config, po.iniStrings, po.confStrings, &messages);
std::vector<std::string> badnodes;
config.lint(badnodes);
for (const auto& badnode : badnodes) {
const auto msg = "Possible bad config node: " + badnode;
fprintf(stderr, "%s\n", msg.c_str());
messages.push_back(msg);
}
}
std::vector<int> inherited_fds;
RuntimeOption::BuildId = po.buildId;
RuntimeOption::InstanceId = po.instanceId;
// Do this as early as possible to avoid creating temp files and spawing
// light processes. Correct compilation still requires loading all of the
// ini/hdf/cli options.
if (po.mode == "dumphhas" || po.mode == "verify") {
if (po.file.empty() && po.args.empty()) {
std::cerr << "Nothing to do. Pass a php file to compile.\n";
return 1;
}
auto const file = [] (std::string file) -> std::string {
if (!FileUtil::isAbsolutePath(file)) {
return SourceRootInfo::GetCurrentSourceRoot() + std::move(file);
}
return file;
}(po.file.empty() ? po.args[0] : po.file);
RuntimeOption::RepoCommit = false; // avoid initializing a repo
std::fstream fs(file, std::ios::in);
if (!fs) {
std::cerr << "Unable to open \"" << file << "\"\n";
return 1;
}
std::stringstream contents;
contents << fs.rdbuf();
auto const str = contents.str();
auto const md5 = MD5{mangleUnitMd5(string_md5(str))};
compilers_start();
hphp_thread_init();
g_context.getCheck();
SCOPE_EXIT { hphp_thread_exit(); };
// Initialize compiler state
compile_file(0, 0, MD5(), 0);
if (po.mode == "dumphhas") RuntimeOption::EvalDumpHhas = true;
else RuntimeOption::EvalVerifyOnly = true;
SystemLib::s_inited = true;
// Ensure write to SystemLib::s_inited is visible by other threads.
std::atomic_thread_fence(std::memory_order_release);
auto compiled = compile_file(str.c_str(), str.size(), md5, file.c_str(),
nullptr);
if (po.mode == "verify") {
return 0;
}
// This will dump the hhas for file as EvalDumpHhas was set
if (!compiled) {
std::cerr << "Unable to compile \"" << file << "\"\n";
return 1;
}
return 0;
}
if (po.port != -1) {
RuntimeOption::ServerPort = po.port;
}
if (po.portfd != -1) {
RuntimeOption::ServerPortFd = po.portfd;
inherited_fds.push_back(po.portfd);
}
if (po.sslportfd != -1) {
RuntimeOption::SSLPortFd = po.sslportfd;
inherited_fds.push_back(po.sslportfd);
}
if (po.admin_port != -1) {
RuntimeOption::AdminServerPort = po.admin_port;
}
if (po.noSafeAccessCheck) {
RuntimeOption::SafeFileAccess = false;
}
IniSetting::s_system_settings_are_set = true;
tl_heap->resetRuntimeOptions();
auto opened_logs = open_server_log_files();
if (po.mode == "daemon") {
if (!opened_logs) {
Logger::Error("Log file not specified under daemon mode.\n\n");
}
proc::daemonize();
}
if (RuntimeOption::ServerExecutionMode()) {
for (auto const& m : messages) {
Logger::Info(m);
}
}
#ifndef _MSC_VER
// Defer the initialization of light processes until the log file handle is
// created, so that light processes can log to the right place. If we ever
// lose a light process, stop the server instead of proceeding in an
// uncertain state. Don't start them in DumpHhas mode because
// it _Exit()s after loading the first non-systemlib unit.
if (!RuntimeOption::EvalDumpHhas) {
LightProcess::SetLostChildHandler([](pid_t /*child*/) {
if (!HttpServer::Server) return;
if (!HttpServer::Server->isStopped()) {
HttpServer::Server->stopOnSignal(SIGCHLD);
}
});
LightProcess::Initialize(RuntimeOption::LightProcessFilePrefix,
RuntimeOption::LightProcessCount,
RuntimeOption::EvalRecordSubprocessTimes,
inherited_fds);
}
#endif
#ifdef USE_JEMALLOC_EXTENT_HOOKS
// Set up extent hook so that we can place jemalloc metadata on 1G pages.
// This needs to be done after initializing LightProcess (which forks),
// because the child process does malloc which won't work with jemalloc
// metadata on 1G huge pages.
setup_jemalloc_metadata_extent_hook(
RuntimeOption::EvalEnableArenaMetadata1GPage,
RuntimeOption::EvalEnableNumaArenaMetadata1GPage,
RuntimeOption::EvalArenaMetadataReservedSize
);
#endif
// We want to do this as early as possible because any allocations before-hand
// will get a generic unknown type type-index.
try {
type_scan::init();
} catch (const type_scan::InitException& exn) {
Logger::Error("Unable to initialize GC type-scanners: %s", exn.what());
exit(HPHP_EXIT_FAILURE);
}
ThreadLocalManager::GetManager().initTypeIndices();
// It's okay if this fails.
init_member_reflection();
if (!ShmCounters::initialize(true, Logger::Error)) {
exit(HPHP_EXIT_FAILURE);
}
// Initialize compiler state
compile_file(0, 0, MD5(), 0);
if (!po.lint.empty()) {
Logger::LogHeader = false;
Logger::LogLevel = Logger::LogInfo;
Logger::UseCronolog = false;
Logger::UseLogFile = true;
// we're linting, reset whatever logger settings and write once to stdout
Logger::ClearThreadLog();
for (auto& el : RuntimeOption::ErrorLogs) {
const auto& name = el.first;
Logger::SetTheLogger(name, nullptr);
}
Logger::SetTheLogger(Logger::DEFAULT, new Logger());
if (po.isTempFile) {
tempFile = po.lint;
}
hphp_process_init();
SCOPE_EXIT { hphp_process_exit(); };
try {
auto const unit = lookupUnit(
makeStaticString(po.lint.c_str()), "", nullptr);
if (unit == nullptr) {
throw FileOpenException(po.lint);
}
const StringData* msg;
int line;
if (unit->compileTimeFatal(msg, line)) {
VMParserFrame parserFrame;
parserFrame.filename = po.lint.c_str();
parserFrame.lineNumber = line;
Array bt = createBacktrace(BacktraceArgs()
.withSelf()
.setParserFrame(&parserFrame));
raise_fatal_error(msg->data(), bt);
}
} catch (FileOpenException &e) {
Logger::Error("%s", e.getMessage().c_str());
return 1;
} catch (const FatalErrorException& e) {
RuntimeOption::CallUserHandlerOnFatals = false;
RuntimeOption::AlwaysLogUnhandledExceptions = false;
g_context->onFatalError(e);
return 1;
}
Logger::Info("No syntax errors detected in %s", po.lint.c_str());
return 0;
}
if (argc <= 1 || po.mode == "run" || po.mode == "debug" ||
po.mode == "vsdebug") {
set_stack_size();
if (po.isTempFile) {
tempFile = po.file;
}
set_execution_mode("run");
/* recreate the hardware counters for the main thread now that we know
* whether to include subprocess times */
HardwareCounter::s_counter.destroy();
HardwareCounter::s_counter.getCheck();
int new_argc;
char **new_argv;
prepare_args(new_argc, new_argv, po.args, po.file.c_str());
std::string const cliFile = !po.file.empty() ? po.file :
new_argv[0] ? new_argv[0] : "";
if (po.mode != "debug" && cliFile.empty()) {
std::cerr << "Nothing to do. Either pass a .php file to run, or "
"use -m server\n";
return 1;
}
Repo::setCliFile(cliFile);
int ret = 0;
hphp_process_init();
SCOPE_EXIT { hphp_process_exit(); };
if (RuntimeOption::EvalUseRemoteUnixServer != "no" &&
!RuntimeOption::EvalUnixServerPath.empty() &&
(!po.file.empty() || !po.args.empty())) {
std::vector<std::string> args;
if (!po.file.empty()) {
args.emplace_back(po.file);
}
args.insert(args.end(), po.args.begin(), po.args.end());
run_command_on_cli_server(
RuntimeOption::EvalUnixServerPath.c_str(), args
);
if (RuntimeOption::EvalUseRemoteUnixServer == "only") {
Logger::Error("Failed to connect to unix server.");
exit(255);
}
}
std::string file;
if (new_argc > 0) {
file = new_argv[0];
}
if (po.mode == "debug") {
StackTraceNoHeap::AddExtraLogging("IsDebugger", "True");
RuntimeOption::EnableHphpdDebugger = true;
po.debugger_options.fileName = file;
po.debugger_options.user = po.user;
Eval::DebuggerProxyPtr localProxy =
Eval::Debugger::StartClient(po.debugger_options);
if (!localProxy) {
Logger::Error("Failed to start debugger client\n\n");
return 1;
}
Eval::Debugger::RegisterSandbox(localProxy->getDummyInfo());
std::shared_ptr<std::vector<std::string>> client_args;
bool restart = false;
ret = 0;
while (true) {
try {
assertx(po.debugger_options.fileName == file);
execute_command_line_begin(new_argc, new_argv, po.xhprofFlags);
// Set the proxy for this thread to be the localProxy we just
// created. If we're script debugging, this will be the proxy that
// does all of our work. If we're remote debugging, this proxy will
// go unused until we finally stop it when the user quits the
// debugger.
g_context->setSandboxId(localProxy->getDummyInfo().id());
if (restart) {
// Systemlib.php is not loaded again, so we need this if we
// are to hit any breakpoints in systemlib.
proxySetBreakPoints(localProxy.get());
}
Eval::Debugger::DebuggerSession(po.debugger_options, restart);
restart = false;
execute_command_line_end(po.xhprofFlags, true, file.c_str());
} catch (const Eval::DebuggerRestartException &e) {
execute_command_line_end(0, false, nullptr);
if (!e.m_args->empty()) {
file = e.m_args->at(0);
po.debugger_options.fileName = file;
client_args = e.m_args;
free(new_argv);
prepare_args(new_argc, new_argv, *client_args, nullptr);
}
restart = true;
} catch (const Eval::DebuggerClientExitException &e) {
execute_command_line_end(0, false, nullptr);
break; // end user quitting debugger
}
}
} else {
ret = 0;
for (int i = 0; i < po.count; i++) {
execute_command_line_begin(new_argc, new_argv, po.xhprofFlags);
ret = 255;
if (hphp_invoke_simple(file, false /* warmup only */)) {
ret = tl_exit_code;
}
execute_command_line_end(po.xhprofFlags, true, file.c_str());
}
}
free(new_argv);
return ret;
}
if (po.mode == "daemon" || po.mode == "server") {
if (!po.user.empty()) RuntimeOption::ServerUser = po.user;
return start_server(RuntimeOption::ServerUser, po.xhprofFlags);
}
if (po.mode == "replay" && !po.args.empty()) {
RuntimeOption::RecordInput = false;
set_execution_mode("server");
HttpServer server; // so we initialize runtime properly
HttpRequestHandler handler(0);
for (int i = 0; i < po.count; i++) {
for (unsigned int j = 0; j < po.args.size(); j++) {
ReplayTransport rt;
rt.replayInput(po.args[j].c_str());
handler.run(&rt);
printf("%s\n", rt.getResponse().c_str());
}
}
return 0;
}
if (po.mode == "translate" && !po.args.empty()) {
printf("%s", translate_stack(po.args[0].c_str()).c_str());
return 0;
}
cout << desc << "\n";
return -1;
}
String canonicalize_path(const String& p, const char* root, int rootLen) {
String path = FileUtil::canonicalize(p);
if (path.charAt(0) == '/') {
auto const& sourceRoot = RuntimeOption::SourceRoot;
int len = sourceRoot.size();
if (len && strncmp(path.data(), sourceRoot.c_str(), len) == 0) {
return path.substr(len);
}
if (root && rootLen && strncmp(path.data(), root, rootLen) == 0) {
return path.substr(rootLen);
}
}
return path;
}
static std::string systemlib_split(const std::string& slib, std::string* hhas) {
auto pos = slib.find("\n<?hhas\n");
if (pos != std::string::npos) {
if (hhas) *hhas = slib.substr(pos + 8);
return slib.substr(0, pos);
}
return slib;
}
// Retrieve a systemlib (or mini systemlib) from the
// current executable or another ELF object file.
//
// Additionally, when retrieving the main systemlib
// from the current executable, honor the
// HHVM_SYSTEMLIB environment variable as an override.
std::string get_systemlib(std::string* hhas,
const std::string §ion /*= "systemlib" */,
const std::string &filename /*= "" */) {
if (filename.empty() && section == "systemlib") {
if (auto const file = getenv("HHVM_SYSTEMLIB")) {
std::ifstream ifs(file);
if (ifs.good()) {
return systemlib_split(std::string(
std::istreambuf_iterator<char>(ifs),
std::istreambuf_iterator<char>()), hhas);
}
}
}
embedded_data desc;
if (!get_embedded_data(section.c_str(), &desc, filename)) return "";
auto const data = read_embedded_data(desc);
return systemlib_split(data, hhas);
}
///////////////////////////////////////////////////////////////////////////////
// C++ ffi
#ifndef _MSC_VER
static void on_timeout(int sig, siginfo_t* info, void* /*context*/) {
if (sig == SIGVTALRM && info && info->si_code == SI_TIMER) {
auto data = (RequestTimer*)info->si_value.sival_ptr;
if (data) {
data->onTimeout();
} else {
Xenon::getInstance().onTimer();
}
}
}
#endif
/*
* Update constants to their real values and sync some runtime options
*/
static void update_constants_and_options() {
assertx(ExtensionRegistry::modulesInitialised());
// If extension constants were used in the ini files (e.g., E_ALL) they
// would have come out as 0 in the previous pass until we load and
// initialize our extensions, which we do in RuntimeOption::Load() via
// ExtensionRegistry::ModuleLoad() and in ExtensionRegistry::ModuleInit()
// in hphp_process_init(). We will re-import and set only the constants that
// have been now bound to their proper value.
IniSettingMap ini = IniSettingMap();
for (auto& filename: s_config_files) {
SuppressHackArrCompatNotices shacn;
Config::ParseIniFile(filename, ini, true);
}
// Reset the INI settings from the CLI.
for (auto& iniStr: s_ini_strings) {
SuppressHackArrCompatNotices shacn;
Config::ParseIniString(iniStr, ini, true);
}
// Reset, possibly, some request dependent runtime options based on certain
// setting values. Do this here so we ensure the constants have been loaded
// correctly (e.g., error_reporting E_ALL, etc.)
Variant sys;
if (IniSetting::GetSystem("error_reporting", sys)) {
RuntimeOption::RuntimeErrorReportingLevel = sys.toInt64();
RID().setErrorReportingLevel(RuntimeOption::RuntimeErrorReportingLevel);
}
if (IniSetting::GetSystem("memory_limit", sys)) {
RID().setMemoryLimit(sys.toString().toCppString());
RuntimeOption::RequestMemoryMaxBytes = RID().getMemoryLimitNumeric();
}
}
void hphp_thread_init() {
#ifdef USE_JEMALLOC_EXTENT_HOOKS
high_arena_tcache_create();
#endif
ServerStats::GetLogger();
zend_get_bigint_data();
zend_rand_init();
get_server_note();
tl_heap.getCheck()->init();
assertx(ThreadInfo::s_threadInfo.isNull());
ThreadInfo::s_threadInfo.getCheck()->init();
HardwareCounter::s_counter.getCheck();
ExtensionRegistry::threadInit();
InitFiniNode::ThreadInit();
// Ensure that there's no request-allocated memory. This call must happen at
// least once after RDS has been initialized by ThreadInfo::init(), to ensure
// MemoryManager::resetGC() sets a proper trigger threshold.
hphp_memory_cleanup();
}
void hphp_thread_exit() {
InitFiniNode::ThreadFini();
ExtensionRegistry::threadShutdown();
if (!g_context.isNull()) g_context.destroy();
#ifdef USE_JEMALLOC_EXTENT_HOOKS
high_arena_tcache_destroy();
#endif
}
void hphp_process_init() {
pthread_attr_t attr;
// Linux+GNU extension
#if defined(_GNU_SOURCE) && defined(__linux__)
if (pthread_getattr_np(pthread_self(), &attr) != 0 ) {
Logger::Error("pthread_getattr_np failed before checking stack limits");
_exit(1);
}
#else
if (pthread_attr_init(&attr) != 0 ) {
Logger::Error("pthread_attr_init failed before checking stack limits");
_exit(1);
}
#endif
init_stack_limits(&attr);
if (pthread_attr_destroy(&attr) != 0 ) {
Logger::Error("pthread_attr_destroy failed after checking stack limits");
_exit(1);
}
BootStats::mark("pthread_init");
Process::InitProcessStatics();
BootStats::mark("Process::InitProcessStatics");
HHProf::Init();
tl_miter_table.getCheck();
// initialize the tzinfo cache.
timezone_init();
BootStats::mark("timezone_init");
// start any external compilers
compilers_start();
BootStats::mark("compilers_start");
hphp_thread_init();
#ifndef _MSC_VER
struct sigaction action = {};
action.sa_sigaction = on_timeout;
action.sa_flags = SA_SIGINFO | SA_NODEFER;
sigaction(SIGVTALRM, &action, nullptr);
#endif
// start takes milliseconds, Period is a double in seconds
Xenon::getInstance().start(1000 * RuntimeOption::XenonPeriodSeconds);
BootStats::mark("xenon");
// reinitialize pcre table
pcre_reinit();
BootStats::mark("pcre_reinit");
// the liboniguruma docs say this isnt needed,
// but the implementation of init is not
// thread safe due to bugs
onig_init();
BootStats::mark("onig_init");
// simple xml also needs one time init
xmlInitParser();
BootStats::mark("xmlInitParser");
g_context.getCheck();
// Some event handlers are registered during the startup process.
g_context->acceptRequestEventHandlers(true);
if (!registrationComplete) {
folly::SingletonVault::singleton()->registrationComplete();
registrationComplete = true;
}
InitFiniNode::ProcessPreInit();
// TODO(9795696): Race in thread map may trigger spurious logging at
// thread exit, so for now, only spawn threads if we're a server.
const uint32_t maxWorkers = RuntimeOption::ServerExecutionMode() ? 3 : 0;
InitFiniNode::ProcessInitConcurrentStart(maxWorkers);
SCOPE_EXIT {
InitFiniNode::ProcessInitConcurrentWaitForEnd();
BootStats::mark("extra_process_init_concurrent_wait");
};
g_vmProcessInit();
BootStats::mark("g_vmProcessInit");
PageletServer::Restart();
BootStats::mark("PageletServer::Restart");
XboxServer::Restart();
BootStats::mark("XboxServer::Restart");
Stream::RegisterCoreWrappers();
BootStats::mark("Stream::RegisterCoreWrappers");
ExtensionRegistry::moduleInit();
BootStats::mark("ExtensionRegistry::moduleInit");
// Now that constants have been bound we can update options using constants
// in ini files (e.g., E_ALL) and sync some other options
update_constants_and_options();
InitFiniNode::ProcessInit();
BootStats::mark("extra_process_init");
{
UnlimitSerializationScope unlimit;
// TODO(9755792): Add real execution mode for snapshot generation.
if (apcExtension::PrimeLibraryUpgradeDest != "") {
Timer timer(Timer::WallTime, "optimizeApcPrime");
apc_load(apcExtension::LoadThread);
} else {
apc_load(apcExtension::LoadThread);
}
BootStats::mark("apc_load");
}
rds::requestExit();
BootStats::mark("rds::requestExit");
// Reset the preloaded g_context
ExecutionContext *context = g_context.getNoCheck();
context->onRequestShutdown(); // TODO T20898959 kill early REH usage.
context->~ExecutionContext();
new (context) ExecutionContext();
BootStats::mark("ExecutionContext");
// TODO(9755792): Add real execution mode for snapshot generation.
if (apcExtension::PrimeLibraryUpgradeDest != "") {
Logger::Info("APC PrimeLibrary upgrade mode completed; exiting.");
hphp_process_exit();
exit(0);
}
}
static void handle_exception(bool& ret, ExecutionContext* context,
std::string& errorMsg, ContextOfException where,
bool& error, bool richErrorMsg) {
assertx(where == ContextOfException::Invoke ||
where == ContextOfException::ReqInit);
try {
handle_exception_helper(ret, context, errorMsg, where, error, richErrorMsg);
} catch (const ExitException &e) {
// Got an ExitException during exception handling, handle
// similarly to the case below but don't call obEndAll().
} catch (...) {
handle_exception_helper(ret, context, errorMsg, ContextOfException::Handler,
error, richErrorMsg);
context->obEndAll();
}
}
static void handle_reqinit_exception(bool &ret, ExecutionContext *context,
std::string &errorMsg, bool &error) {
handle_exception(ret, context, errorMsg, ContextOfException::ReqInit, error,
false);
}
static void handle_invoke_exception(bool &ret, ExecutionContext *context,
std::string &errorMsg, bool &error,
bool richErrorMsg) {
handle_exception(ret, context, errorMsg, ContextOfException::Invoke, error,
richErrorMsg);
}
static bool hphp_warmup(ExecutionContext *context,
const std::string &reqInitFunc,
const std::string &reqInitDoc, bool &error) {
bool ret = true;
error = false;
std::string errorMsg;
ServerStatsHelper ssh("reqinit");
try {
if (!reqInitDoc.empty()) {
include_impl_invoke(reqInitDoc, true);
}
if (!reqInitFunc.empty()) {
invoke(reqInitFunc.c_str(), Array());
}
context->backupSession();
} catch (...) {
handle_reqinit_exception(ret, context, errorMsg, error);
}
return ret;
}
void hphp_session_init(Transport* transport) {
assertx(!s_sessionInitialized);
g_context.getCheck();
AsioSession::Init();
Socket::clearLastError();
TI().onSessionInit();
tl_heap->resetExternalStats();
g_thread_safe_locale_handler->reset();
Treadmill::startRequest();
#ifdef ENABLE_SIMPLE_COUNTER
SimpleCounter::Enabled = true;
StackTrace::Enabled = true;
#endif
// Ordering is sensitive; StatCache::requestInit produces work that
// must be done in ExecutionContext::requestInit.
StatCache::requestInit();
// Allow request event handlers to be created now that a new request has
// started.
g_context->acceptRequestEventHandlers(true);
g_context->requestInit();
if (transport != nullptr) g_context->setTransport(transport);
s_sessionInitialized = true;
ExtensionRegistry::requestInit();
// Sample function calls for this request
if (RID().logFunctionCalls()) {
EventHook::Enable();
}
auto const pme_freq = RuntimeOption::EvalPerfMemEventRequestFreq;
if (pme_freq > 0 && folly::Random::rand32(pme_freq) == 0) {
// Enable memory access sampling for this request.
perf_event_enable(
RuntimeOption::EvalPerfMemEventSampleFreq,
[] (PerfEvent) { setSurpriseFlag(PendingPerfEventFlag); }
);
}
}
bool hphp_invoke_simple(const std::string& filename, bool warmupOnly) {
bool error;
std::string errorMsg;
return hphp_invoke(g_context.getNoCheck(), filename, false, null_array,
uninit_null(), "", "", error, errorMsg,
true /* once */,
warmupOnly,
false /* richErrorMsg */,
RuntimeOption::EvalPreludePath);
}
const StaticString s_slash("/");
static void run_prelude(std::string prelude, String cmd,
const char* currentDir) {
prelude = "/" + prelude;
struct stat s;
auto cwd = resolveVmInclude(cmd.get(), currentDir, &s);
if (cwd.isNull()) return;
auto const w = Stream::getWrapperFromURI(cwd, nullptr, false);
do {
cwd = f_dirname(cwd);
auto const f = String::attach(
StringData::Make(cwd.data(), prelude.data())
);
if (w->access(f, R_OK) == 0) {
require(f.data(), false, currentDir, true);
break;
}
} while (!cwd.empty() && !cwd.equal(s_slash));
}
bool hphp_invoke(ExecutionContext *context, const std::string &cmd,
bool func, const Array& funcParams, VRefParam funcRet,
const std::string &reqInitFunc, const std::string &reqInitDoc,
bool &error, std::string &errorMsg,
bool once, bool warmupOnly,
bool richErrorMsg, const std::string& prelude) {
bool isServer =
RuntimeOption::ServerExecutionMode() && !is_cli_mode();
error = false;
// Make sure we have the right current working directory within the repo
// based on what server.source_root was set to (current process directory
// being the default)
if (RuntimeOption::RepoAuthoritative) {
context->setCwd(RuntimeOption::SourceRoot);
}
String oldCwd;
if (isServer) {
oldCwd = context->getCwd();
}
if (!hphp_warmup(context, reqInitFunc, reqInitDoc, error)) {
if (isServer) context->setCwd(oldCwd);
return false;
}
tl_heap->resetCouldOOM(isStandardRequest());
RID().resetTimer();
bool ret = true;
if (!warmupOnly) {
try {
ServerStatsHelper ssh("invoke");
if (!RuntimeOption::AutoPrependFile.empty() &&
RuntimeOption::AutoPrependFile != "none") {
require(RuntimeOption::AutoPrependFile, false,
context->getCwd().data(), true);
}
if (!prelude.empty()) {
run_prelude(prelude, String(cmd, CopyString), context->getCwd().data());
}
if (func) {
funcRet.assignIfRef(invoke(cmd.c_str(), funcParams));
} else {
if (isServer) hphp_chdir_file(cmd);
include_impl_invoke(cmd.c_str(), once);
}
if (!RuntimeOption::AutoAppendFile.empty() &&
RuntimeOption::AutoAppendFile != "none") {
require(RuntimeOption::AutoAppendFile, false,
context->getCwd().data(), true);
}
} catch (...) {
handle_invoke_exception(ret, context, errorMsg, error, richErrorMsg);
}
}
try {
context->onShutdownPreSend();
} catch (...) {
handle_invoke_exception(ret, context, errorMsg, error, richErrorMsg);
}
if (isServer) context->setCwd(oldCwd);
return ret;
}
void hphp_context_shutdown() {
// Run shutdown handlers. This may cause user code to run.
g_thread_safe_locale_handler->reset();
auto const context = g_context.getNoCheck();
context->destructObjects();
context->onRequestShutdown();
try {
// Shutdown the debugger. This can throw, but we don't care about what the
// error is.
DEBUGGER_ATTACHED_ONLY(phpDebuggerRequestShutdownHook());
} catch (...) {
// Gotta catch 'em all!
}
// Extensions could have shutdown handlers
ExtensionRegistry::requestShutdown();
InitFiniNode::RequestFini();
// Extension shutdown could have re-initialized some
// request locals
context->onRequestShutdown();
// This causes request event handler registration to fail until the next
// request starts.
context->acceptRequestEventHandlers(false);
}
void hphp_context_exit(bool shutdown /* = true */) {
if (shutdown) {
hphp_context_shutdown();
}
// Clean up a bunch of request state. No user code after this point.
MemoryManager::setExiting();
auto const context = g_context.getNoCheck();
context->requestExit();
context->obProtect(false);
context->obEndAll();
}
void hphp_memory_cleanup() {
auto& mm = *tl_heap;
// sweep functions are allowed to access g_context,
// so we can't destroy it yet
mm.sweep();
// We should never have any registered RequestEventHandlers. If we do
// something after onRequestShutdown registered a RequestEventHandler.
// Its now too late to run the requestShutdown functions, but if we carry
// on, requestInit and requestShutdown will never be called again.
// I considered just clearing the inited flags; which works for some
// RequestEventHandlers - but its a disaster for others. So just fail hard
// here.
always_assert(g_context.isNull() || !g_context->hasRequestEventHandlers());
// g_context is request allocated, and has some members that need
// cleanup, so destroy it before its too late
g_context.destroy();
weakref_cleanup();
mm.resetAllocator();
mm.resetCouldOOM();
}
void hphp_session_exit(const Transport* transport) {
assertx(s_sessionInitialized);
// Server note and INI have to live long enough for the access log to fire.
// RequestLocal is too early.
ServerNote::Reset();
IniSetting::ResetSavedDefaults();
// In JitPGO mode, check if it's time to schedule the retranslation of all
// profiled functions and, if so, schedule it.
jit::mcgen::checkRetranslateAll();
jit::tc::requestExit();
// Similarly, apc strings could be in the ServerNote array, and
// it's possible they are scheduled to be destroyed after this request
// finishes.
Treadmill::finishRequest();
TI().onSessionExit();
// We might have events from after the final surprise flag check of the
// request, so consume them here.
perf_event_consume(record_perf_mem_event);
perf_event_disable();
{
ServerStatsHelper ssh("rollback");
hphp_memory_cleanup();
}
assertx(tl_heap->empty());
s_sessionInitialized = false;
s_extra_request_nanoseconds = 0;
if (transport) {
std::unique_ptr<StructuredLogEntry> entry;
if (RuntimeOption::EvalProfileHWStructLog) {
entry = std::make_unique<StructuredLogEntry>();
entry->setInt("response_code", transport->getResponseCode());
}
HardwareCounter::UpdateServiceData(transport->getCpuTime(),
transport->getWallTime(),
entry.get(),
true /*psp*/);
if (entry) StructuredLog::log("hhvm_request_perf", *entry);
}
}
void hphp_process_exit() noexcept {
// We want to do clean up on a best-effort basis: don't skip later steps if
// an earlier step fails, and don't propagate exceptions ouf of this function
#define LOG_AND_IGNORE(voidexpr) try { voidexpr; } catch (...) { \
Logger::Error("got exception in cleanup step: " #voidexpr); }
LOG_AND_IGNORE(teardown_cli_server())
LOG_AND_IGNORE(Xenon::getInstance().stop())
LOG_AND_IGNORE(jit::mcgen::joinWorkerThreads())
LOG_AND_IGNORE(jit::tc::processExit())
LOG_AND_IGNORE(PageletServer::Stop())
LOG_AND_IGNORE(XboxServer::Stop())
// Debugger::Stop() needs an execution context
LOG_AND_IGNORE(g_context.getCheck())
LOG_AND_IGNORE(Eval::Debugger::Stop())
LOG_AND_IGNORE(g_context.destroy())
LOG_AND_IGNORE(ExtensionRegistry::moduleShutdown())
LOG_AND_IGNORE(compilers_shutdown())
#ifndef _MSC_VER
LOG_AND_IGNORE(LightProcess::Close())
#endif
LOG_AND_IGNORE(InitFiniNode::ProcessFini())
LOG_AND_IGNORE(folly::SingletonVault::singleton()->destroyInstances())
LOG_AND_IGNORE(embedded_data_cleanup())
#undef LOG_AND_IGNORE
}
bool is_hphp_session_initialized() {
return s_sessionInitialized;
}
static struct SetThreadInitFini {
template<class ThreadT> static typename std::enable_if<
std::is_integral<ThreadT>::value || std::is_pointer<ThreadT>::value>::type
recordThreadAddr(ThreadT threadId, char* stackAddr, size_t stackSize) {
// In the current glibc implementation, pthread_t is a 64-bit unsigned
// integer, whose value equals the address of the thread control block
// (TCB). In x64_64, this is right above the TLS block. In addition,
// TLS and TCB sits at the high end of the stack, i.e.,
//
// stackAddr + stackSize ----> +---------------+
// | TCB |
// threadId ----> +---------------+
// | TLS |
// +---------------+
// | Stack |
// . .
// . .
// stackAddr ----> +---------------+
auto const tcbBase = reinterpret_cast<char*>(threadId);
auto stackEnd = stackAddr + stackSize;
if (tcbBase > stackAddr && tcbBase < stackEnd) { // the expected layout
// TCB
Debug::DebugInfo::recordDataMap(
tcbBase, stackEnd,
folly::sformat("Thread-{}", static_cast<void*>(tcbBase)));
// TLS
auto const tlsRange = getCppTdata();
auto const tlsSize = (tlsRange.second + 15) / 16 * 16;
stackEnd = tcbBase - tlsSize;
if (tlsSize) {
Debug::DebugInfo::recordDataMap(
stackEnd, tcbBase,
folly::sformat("TLS-{}", static_cast<void*>(tcbBase)));
}
}
Debug::DebugInfo::recordDataMap(
stackAddr, stackEnd,
folly::sformat("Stack-{}", static_cast<void*>(tcbBase)));
}
template <class ThreadT>
static typename std::enable_if<!std::is_integral<ThreadT>::value &&
!std::is_pointer<ThreadT>::value>::type
recordThreadAddr(ThreadT /*threadId*/, char* stackAddr, size_t stackSize) {
// pthread_t is not an integer or pointer to TCB in this pthread
// implementation. But we can still figure out where TLS is.
auto const tlsRange = getCppTdata();
auto const tlsSize = (tlsRange.second + 15) / 16 * 16;
auto const tlsBaseAddr = reinterpret_cast<char*>(tlsBase());
Debug::DebugInfo::recordDataMap(
tlsBaseAddr, tlsBaseAddr + tlsSize,
folly::sformat("TLS-{}", static_cast<void*>(stackAddr)));
Debug::DebugInfo::recordDataMap(
stackAddr, stackAddr + stackSize,
folly::sformat("Stack-{}", static_cast<void*>(stackAddr)));
}
SetThreadInitFini() {
AsyncFuncImpl::SetThreadInitFunc(
[] (void*) {
#if defined(_GNU_SOURCE) && defined(__linux__)
if (RuntimeOption::EvalPerfDataMap) {
pthread_t threadId = pthread_self();
pthread_attr_t attr;
pthread_getattr_np(threadId, &attr);
void* stackAddr{nullptr};
size_t stackSize{0};
pthread_attr_getstack(&attr, &stackAddr, &stackSize);
pthread_attr_destroy(&attr);
recordThreadAddr(threadId, static_cast<char*>(stackAddr), stackSize);
}
#endif
hphp_thread_init();
},
nullptr);
AsyncFuncImpl::SetThreadFiniFunc([](void*) { hphp_thread_exit(); },
nullptr);
}
} s_SetThreadInitFini;
///////////////////////////////////////////////////////////////////////////////
}
|
; Listing generated by Microsoft (R) Optimizing Compiler Version 14.00.50727.42
TITLE c:\Documents and Settings\Michael\Desktop\bte_lighter\Demos\Demo11\SysCore\Kernel\mmngr_virtual.cpp
.686P
.XMM
include listing.inc
.model flat
INCLUDELIB LIBCMT
INCLUDELIB OLDNAMES
PUBLIC ?_cur_directory@@3PAUpdirectory@@A ; _cur_directory
PUBLIC ?_cur_pdbr@@3IA ; _cur_pdbr
_BSS SEGMENT
?_cur_directory@@3PAUpdirectory@@A DD 01H DUP (?) ; _cur_directory
?_cur_pdbr@@3IA DD 01H DUP (?) ; _cur_pdbr
_BSS ENDS
PUBLIC ?vmmngr_ptable_virt_to_index@@YAII@Z ; vmmngr_ptable_virt_to_index
; Function compile flags: /Ogtpy
; File c:\documents and settings\michael\desktop\bte_lighter\demos\demo11\syscore\kernel\mmngr_virtual.cpp
; COMDAT ?vmmngr_ptable_virt_to_index@@YAII@Z
_TEXT SEGMENT
_addr$ = 8 ; size = 4
?vmmngr_ptable_virt_to_index@@YAII@Z PROC ; vmmngr_ptable_virt_to_index, COMDAT
; 64 :
; 65 : //! return index only if address doesnt exceed page table address space size
; 66 : return (addr >= PTABLE_ADDR_SPACE_SIZE) ? 0 : addr/PAGE_SIZE;
mov eax, DWORD PTR _addr$[esp-4]
cmp eax, 4194304 ; 00400000H
jb SHORT $LN3@vmmngr_pta
xor eax, eax
; 67 : }
ret 0
$LN3@vmmngr_pta:
; 64 :
; 65 : //! return index only if address doesnt exceed page table address space size
; 66 : return (addr >= PTABLE_ADDR_SPACE_SIZE) ? 0 : addr/PAGE_SIZE;
shr eax, 12 ; 0000000cH
; 67 : }
ret 0
?vmmngr_ptable_virt_to_index@@YAII@Z ENDP ; vmmngr_ptable_virt_to_index
_TEXT ENDS
PUBLIC ?vmmngr_ptable_lookup_entry@@YAPAIPAUptable@@I@Z ; vmmngr_ptable_lookup_entry
; Function compile flags: /Ogtpy
; COMDAT ?vmmngr_ptable_lookup_entry@@YAPAIPAUptable@@I@Z
_TEXT SEGMENT
_p$ = 8 ; size = 4
_addr$ = 12 ; size = 4
?vmmngr_ptable_lookup_entry@@YAPAIPAUptable@@I@Z PROC ; vmmngr_ptable_lookup_entry, COMDAT
; 70 :
; 71 : if (p)
mov ecx, DWORD PTR _p$[esp-4]
test ecx, ecx
je SHORT $LN1@vmmngr_pta@2
; 72 : return &p->m_entries[ vmmngr_ptable_virt_to_index (addr) ];
mov eax, DWORD PTR _addr$[esp-4]
cmp eax, 4194304 ; 00400000H
jb SHORT $LN6@vmmngr_pta@2
xor eax, eax
lea eax, DWORD PTR [ecx+eax*4]
; 74 : }
ret 0
; 72 : return &p->m_entries[ vmmngr_ptable_virt_to_index (addr) ];
$LN6@vmmngr_pta@2:
shr eax, 12 ; 0000000cH
lea eax, DWORD PTR [ecx+eax*4]
; 74 : }
ret 0
$LN1@vmmngr_pta@2:
; 73 : return 0;
xor eax, eax
; 74 : }
ret 0
?vmmngr_ptable_lookup_entry@@YAPAIPAUptable@@I@Z ENDP ; vmmngr_ptable_lookup_entry
_TEXT ENDS
PUBLIC ?vmmngr_ptable_clear@@YAXPAUptable@@@Z ; vmmngr_ptable_clear
EXTRN ?memset@@YAPAXPAXDI@Z:PROC ; memset
; Function compile flags: /Ogtpy
; COMDAT ?vmmngr_ptable_clear@@YAXPAUptable@@@Z
_TEXT SEGMENT
_p$ = 8 ; size = 4
?vmmngr_ptable_clear@@YAXPAUptable@@@Z PROC ; vmmngr_ptable_clear, COMDAT
; 77 :
; 78 : if (p)
mov eax, DWORD PTR _p$[esp-4]
test eax, eax
je SHORT $LN1@vmmngr_pta@3
; 79 : memset ( p,0,sizeof (ptable) );
push 4096 ; 00001000H
push 0
push eax
call ?memset@@YAPAXPAXDI@Z ; memset
add esp, 12 ; 0000000cH
$LN1@vmmngr_pta@3:
; 80 : }
ret 0
?vmmngr_ptable_clear@@YAXPAUptable@@@Z ENDP ; vmmngr_ptable_clear
_TEXT ENDS
PUBLIC ?vmmngr_pdirectory_clear@@YAXPAUpdirectory@@@Z ; vmmngr_pdirectory_clear
; Function compile flags: /Ogtpy
; COMDAT ?vmmngr_pdirectory_clear@@YAXPAUpdirectory@@@Z
_TEXT SEGMENT
_dir$ = 8 ; size = 4
?vmmngr_pdirectory_clear@@YAXPAUpdirectory@@@Z PROC ; vmmngr_pdirectory_clear, COMDAT
; 83 :
; 84 : if (dir)
mov eax, DWORD PTR _dir$[esp-4]
test eax, eax
je SHORT $LN1@vmmngr_pdi
; 85 : memset ( dir,0,sizeof (pdirectory) );
push 4096 ; 00001000H
push 0
push eax
call ?memset@@YAPAXPAXDI@Z ; memset
add esp, 12 ; 0000000cH
$LN1@vmmngr_pdi:
; 86 : }
ret 0
?vmmngr_pdirectory_clear@@YAXPAUpdirectory@@@Z ENDP ; vmmngr_pdirectory_clear
_TEXT ENDS
PUBLIC ?vmmngr_pdirectory_virt_to_index@@YAII@Z ; vmmngr_pdirectory_virt_to_index
; Function compile flags: /Ogtpy
; COMDAT ?vmmngr_pdirectory_virt_to_index@@YAII@Z
_TEXT SEGMENT
_addr$ = 8 ; size = 4
?vmmngr_pdirectory_virt_to_index@@YAII@Z PROC ; vmmngr_pdirectory_virt_to_index, COMDAT
; 89 :
; 90 : //! return index only if address doesnt exceed 4gb (page directory address space size)
; 91 : return (addr >= DTABLE_ADDR_SPACE_SIZE) ? 0 : addr/PAGE_SIZE;
mov eax, DWORD PTR _addr$[esp-4]
xor ecx, ecx
cmp ecx, 1
jl SHORT $LN3@vmmngr_pdi@2
jg SHORT $LN5@vmmngr_pdi@2
test eax, eax
jb SHORT $LN3@vmmngr_pdi@2
$LN5@vmmngr_pdi@2:
xor eax, eax
; 92 : }
ret 0
$LN3@vmmngr_pdi@2:
; 89 :
; 90 : //! return index only if address doesnt exceed 4gb (page directory address space size)
; 91 : return (addr >= DTABLE_ADDR_SPACE_SIZE) ? 0 : addr/PAGE_SIZE;
shr eax, 12 ; 0000000cH
; 92 : }
ret 0
?vmmngr_pdirectory_virt_to_index@@YAII@Z ENDP ; vmmngr_pdirectory_virt_to_index
_TEXT ENDS
PUBLIC ?vmmngr_pdirectory_lookup_entry@@YAPAIPAUpdirectory@@I@Z ; vmmngr_pdirectory_lookup_entry
; Function compile flags: /Ogtpy
; COMDAT ?vmmngr_pdirectory_lookup_entry@@YAPAIPAUpdirectory@@I@Z
_TEXT SEGMENT
_p$ = 8 ; size = 4
_addr$ = 12 ; size = 4
?vmmngr_pdirectory_lookup_entry@@YAPAIPAUpdirectory@@I@Z PROC ; vmmngr_pdirectory_lookup_entry, COMDAT
; 95 :
; 96 : if (p)
mov ecx, DWORD PTR _p$[esp-4]
test ecx, ecx
je SHORT $LN1@vmmngr_pdi@3
; 97 : return &p->m_entries[ vmmngr_ptable_virt_to_index (addr) ];
mov eax, DWORD PTR _addr$[esp-4]
cmp eax, 4194304 ; 00400000H
jb SHORT $LN6@vmmngr_pdi@3
xor eax, eax
lea eax, DWORD PTR [ecx+eax*4]
; 99 : }
ret 0
; 97 : return &p->m_entries[ vmmngr_ptable_virt_to_index (addr) ];
$LN6@vmmngr_pdi@3:
shr eax, 12 ; 0000000cH
lea eax, DWORD PTR [ecx+eax*4]
; 99 : }
ret 0
$LN1@vmmngr_pdi@3:
; 98 : return 0;
xor eax, eax
; 99 : }
ret 0
?vmmngr_pdirectory_lookup_entry@@YAPAIPAUpdirectory@@I@Z ENDP ; vmmngr_pdirectory_lookup_entry
_TEXT ENDS
PUBLIC ?vmmngr_switch_pdirectory@@YA_NPAUpdirectory@@@Z ; vmmngr_switch_pdirectory
EXTRN ?pmmngr_load_PDBR@@YAXI@Z:PROC ; pmmngr_load_PDBR
; Function compile flags: /Ogtpy
; COMDAT ?vmmngr_switch_pdirectory@@YA_NPAUpdirectory@@@Z
_TEXT SEGMENT
_dir$ = 8 ; size = 4
?vmmngr_switch_pdirectory@@YA_NPAUpdirectory@@@Z PROC ; vmmngr_switch_pdirectory, COMDAT
; 102 :
; 103 : if (!dir)
mov eax, DWORD PTR _dir$[esp-4]
test eax, eax
jne SHORT $LN1@vmmngr_swi
; 104 : return false;
xor al, al
; 109 : }
ret 0
$LN1@vmmngr_swi:
; 105 :
; 106 : _cur_directory = dir;
mov DWORD PTR ?_cur_directory@@3PAUpdirectory@@A, eax ; _cur_directory
; 107 : pmmngr_load_PDBR (_cur_pdbr);
mov eax, DWORD PTR ?_cur_pdbr@@3IA ; _cur_pdbr
push eax
call ?pmmngr_load_PDBR@@YAXI@Z ; pmmngr_load_PDBR
add esp, 4
; 108 : return true;
mov al, 1
; 109 : }
ret 0
?vmmngr_switch_pdirectory@@YA_NPAUpdirectory@@@Z ENDP ; vmmngr_switch_pdirectory
_TEXT ENDS
PUBLIC ?vmmngr_flush_tlb_entry@@YAXI@Z ; vmmngr_flush_tlb_entry
; Function compile flags: /Ogtpy
; COMDAT ?vmmngr_flush_tlb_entry@@YAXI@Z
_TEXT SEGMENT
_addr$ = 8 ; size = 4
?vmmngr_flush_tlb_entry@@YAXI@Z PROC ; vmmngr_flush_tlb_entry, COMDAT
; 112 :
; 113 : #ifdef _MSC_VER
; 114 : _asm {
; 115 : cli
cli
; 116 : invlpg addr
invlpg DWORD PTR _addr$[esp-4]
; 117 : sti
sti
; 118 : }
; 119 : #endif
; 120 : }
ret 0
?vmmngr_flush_tlb_entry@@YAXI@Z ENDP ; vmmngr_flush_tlb_entry
_TEXT ENDS
PUBLIC ?vmmngr_get_directory@@YAPAUpdirectory@@XZ ; vmmngr_get_directory
; Function compile flags: /Ogtpy
; COMDAT ?vmmngr_get_directory@@YAPAUpdirectory@@XZ
_TEXT SEGMENT
?vmmngr_get_directory@@YAPAUpdirectory@@XZ PROC ; vmmngr_get_directory, COMDAT
; 123 :
; 124 : return _cur_directory;
mov eax, DWORD PTR ?_cur_directory@@3PAUpdirectory@@A ; _cur_directory
; 125 : }
ret 0
?vmmngr_get_directory@@YAPAUpdirectory@@XZ ENDP ; vmmngr_get_directory
_TEXT ENDS
PUBLIC ?vmmngr_alloc_page@@YA_NPAI@Z ; vmmngr_alloc_page
EXTRN ?pt_entry_add_attrib@@YAXPAII@Z:PROC ; pt_entry_add_attrib
EXTRN ?pt_entry_set_frame@@YAXPAII@Z:PROC ; pt_entry_set_frame
EXTRN ?pmmngr_alloc_block@@YAPAXXZ:PROC ; pmmngr_alloc_block
; Function compile flags: /Ogtpy
; COMDAT ?vmmngr_alloc_page@@YA_NPAI@Z
_TEXT SEGMENT
_e$ = 8 ; size = 4
?vmmngr_alloc_page@@YA_NPAI@Z PROC ; vmmngr_alloc_page, COMDAT
; 128 :
; 129 : //! allocate a free physical frame
; 130 : void* p = pmmngr_alloc_block ();
call ?pmmngr_alloc_block@@YAPAXXZ ; pmmngr_alloc_block
; 131 : if (!p)
test eax, eax
jne SHORT $LN1@vmmngr_all
; 132 : return false;
xor al, al
; 139 : }
ret 0
$LN1@vmmngr_all:
push esi
; 133 :
; 134 : //! map it to the page
; 135 : pt_entry_set_frame (e, (physical_addr)p);
mov esi, DWORD PTR _e$[esp]
push eax
push esi
call ?pt_entry_set_frame@@YAXPAII@Z ; pt_entry_set_frame
; 136 : pt_entry_add_attrib (e, I86_PTE_PRESENT);
push 1
push esi
call ?pt_entry_add_attrib@@YAXPAII@Z ; pt_entry_add_attrib
add esp, 16 ; 00000010H
; 137 :
; 138 : return true;
mov al, 1
pop esi
; 139 : }
ret 0
?vmmngr_alloc_page@@YA_NPAI@Z ENDP ; vmmngr_alloc_page
_TEXT ENDS
PUBLIC ?vmmngr_free_page@@YAXPAI@Z ; vmmngr_free_page
EXTRN ?pt_entry_del_attrib@@YAXPAII@Z:PROC ; pt_entry_del_attrib
EXTRN ?pmmngr_free_block@@YAXPAX@Z:PROC ; pmmngr_free_block
EXTRN ?pt_entry_pfn@@YAII@Z:PROC ; pt_entry_pfn
; Function compile flags: /Ogtpy
; COMDAT ?vmmngr_free_page@@YAXPAI@Z
_TEXT SEGMENT
_e$ = 8 ; size = 4
?vmmngr_free_page@@YAXPAI@Z PROC ; vmmngr_free_page, COMDAT
; 141 : void vmmngr_free_page (pt_entry* e) {
push esi
; 142 :
; 143 : void* p = (void*)pt_entry_pfn (*e);
mov esi, DWORD PTR _e$[esp]
mov eax, DWORD PTR [esi]
push eax
call ?pt_entry_pfn@@YAII@Z ; pt_entry_pfn
add esp, 4
; 144 : if (p)
test eax, eax
je SHORT $LN1@vmmngr_fre
; 145 : pmmngr_free_block (p);
push eax
call ?pmmngr_free_block@@YAXPAX@Z ; pmmngr_free_block
add esp, 4
$LN1@vmmngr_fre:
; 146 :
; 147 : pt_entry_del_attrib (e, I86_PTE_PRESENT);
push 1
push esi
call ?pt_entry_del_attrib@@YAXPAII@Z ; pt_entry_del_attrib
add esp, 8
pop esi
; 148 : }
ret 0
?vmmngr_free_page@@YAXPAI@Z ENDP ; vmmngr_free_page
_TEXT ENDS
PUBLIC ?vmmngr_initialize@@YAXXZ ; vmmngr_initialize
EXTRN ?pmmngr_paging_enable@@YAX_N@Z:PROC ; pmmngr_paging_enable
EXTRN ?pd_entry_set_frame@@YAXPAII@Z:PROC ; pd_entry_set_frame
EXTRN ?pd_entry_add_attrib@@YAXPAII@Z:PROC ; pd_entry_add_attrib
EXTRN ?pmmngr_alloc_blocks@@YAPAXI@Z:PROC ; pmmngr_alloc_blocks
; Function compile flags: /Ogtpy
; COMDAT ?vmmngr_initialize@@YAXXZ
_TEXT SEGMENT
_page$2784 = -4 ; size = 4
?vmmngr_initialize@@YAXXZ PROC ; vmmngr_initialize, COMDAT
; 150 : void vmmngr_initialize () {
push ecx
push edi
; 151 :
; 152 : //! allocate default page table
; 153 : ptable* table = (ptable*) pmmngr_alloc_block ();
call ?pmmngr_alloc_block@@YAPAXXZ ; pmmngr_alloc_block
mov edi, eax
; 154 : if (!table)
test edi, edi
je $LN6@vmmngr_ini
push ebx
push esi
; 155 : return;
; 156 :
; 157 : //! clear page table
; 158 : vmmngr_ptable_clear (table);
push 4096 ; 00001000H
push 0
push edi
call ?memset@@YAPAXPAXDI@Z ; memset
add esp, 12 ; 0000000cH
; 159 :
; 160 : //! idenitity map the page table (First 4mb of virtual memory mapped to same phys address)
; 161 : for (int i=0, frame=0; i<1024; i++, frame+=4096) {
xor esi, esi
mov ebx, 1024 ; 00000400H
npad 6
$LL4@vmmngr_ini:
; 162 :
; 163 : //! create a new page
; 164 : pt_entry page=0;
; 165 : pt_entry_add_attrib (&page, I86_PTE_PRESENT);
lea eax, DWORD PTR _page$2784[esp+16]
push 1
push eax
mov DWORD PTR _page$2784[esp+24], 0
call ?pt_entry_add_attrib@@YAXPAII@Z ; pt_entry_add_attrib
; 166 : pt_entry_set_frame (&page, frame);
lea ecx, DWORD PTR _page$2784[esp+24]
push esi
push ecx
call ?pt_entry_set_frame@@YAXPAII@Z ; pt_entry_set_frame
add esp, 16 ; 00000010H
; 167 :
; 168 : //! ...and add it to the page table
; 169 : table->m_entries [vmmngr_ptable_virt_to_index (frame) ] = page;
cmp esi, 4194304 ; 00400000H
jb SHORT $LN13@vmmngr_ini
xor eax, eax
jmp SHORT $LN14@vmmngr_ini
$LN13@vmmngr_ini:
mov eax, esi
shr eax, 12 ; 0000000cH
$LN14@vmmngr_ini:
mov edx, DWORD PTR _page$2784[esp+16]
add esi, 4096 ; 00001000H
sub ebx, 1
mov DWORD PTR [edi+eax*4], edx
jne SHORT $LL4@vmmngr_ini
; 170 : }
; 171 :
; 172 : //! create default directory table
; 173 : pdirectory* dir = (pdirectory*) pmmngr_alloc_blocks (3);
push 3
call ?pmmngr_alloc_blocks@@YAPAXI@Z ; pmmngr_alloc_blocks
mov esi, eax
add esp, 4
; 174 : if (!dir)
test esi, esi
je SHORT $LN32@vmmngr_ini
; 175 : return;
; 176 :
; 177 : //! clear directory table and set it as current
; 178 : vmmngr_pdirectory_clear (dir);
push 4096 ; 00001000H
push 0
push esi
call ?memset@@YAPAXPAXDI@Z ; memset
; 179 :
; 180 : //! get first entry in dir table and set it up to point to our table
; 181 : pd_entry* entry = vmmngr_pdirectory_lookup_entry (dir,0);
; 182 : pd_entry_add_attrib (entry, I86_PDE_PRESENT);
push 1
push esi
call ?pd_entry_add_attrib@@YAXPAII@Z ; pd_entry_add_attrib
; 183 : pd_entry_add_attrib (entry, I86_PDE_WRITABLE);
push 2
push esi
call ?pd_entry_add_attrib@@YAXPAII@Z ; pd_entry_add_attrib
; 184 : pd_entry_set_frame (entry, (physical_addr)table);
push edi
push esi
call ?pd_entry_set_frame@@YAXPAII@Z ; pd_entry_set_frame
; 185 :
; 186 : //! store current PDBR
; 187 : _cur_pdbr = (physical_addr) &dir->m_entries;
; 188 :
; 189 : //! switch to our page directory
; 190 : vmmngr_switch_pdirectory (dir);
push esi
mov DWORD PTR ?_cur_pdbr@@3IA, esi ; _cur_pdbr
mov DWORD PTR ?_cur_directory@@3PAUpdirectory@@A, esi ; _cur_directory
call ?pmmngr_load_PDBR@@YAXI@Z ; pmmngr_load_PDBR
; 191 :
; 192 : //! enable paging
; 193 : pmmngr_paging_enable (true);
push 1
call ?pmmngr_paging_enable@@YAX_N@Z ; pmmngr_paging_enable
add esp, 44 ; 0000002cH
$LN32@vmmngr_ini:
pop esi
pop ebx
$LN6@vmmngr_ini:
pop edi
; 194 : }
pop ecx
ret 0
?vmmngr_initialize@@YAXXZ ENDP ; vmmngr_initialize
_TEXT ENDS
END
|
.global s_prepare_buffers
s_prepare_buffers:
push %r12
push %r13
push %r9
push %rbx
push %rcx
push %rdi
push %rdx
push %rsi
lea addresses_WT_ht+0x12446, %r9
nop
nop
nop
nop
and %rbx, %rbx
mov (%r9), %r12
xor %rcx, %rcx
lea addresses_normal_ht+0x6d5a, %rdx
nop
nop
nop
inc %r13
movl $0x61626364, (%rdx)
nop
add %rcx, %rcx
lea addresses_WT_ht+0x188fa, %rbx
nop
xor $3080, %r9
movl $0x61626364, (%rbx)
nop
nop
nop
nop
nop
and $245, %rdx
lea addresses_UC_ht+0x23fa, %rsi
lea addresses_WT_ht+0x13e5a, %rdi
nop
nop
nop
nop
and $26319, %r12
mov $1, %rcx
rep movsq
nop
nop
nop
nop
and %r9, %r9
lea addresses_WC_ht+0xc55a, %r12
nop
and %rdx, %rdx
movl $0x61626364, (%r12)
nop
nop
nop
dec %rbx
lea addresses_UC_ht+0x16d22, %rsi
lea addresses_normal_ht+0x505a, %rdi
clflush (%rdi)
nop
dec %r12
mov $67, %rcx
rep movsb
nop
nop
nop
inc %r12
lea addresses_UC_ht+0xe39a, %rdi
nop
nop
nop
add %rsi, %rsi
mov $0x6162636465666768, %r13
movq %r13, (%rdi)
inc %rsi
lea addresses_D_ht+0x1b55a, %r13
cmp $40625, %rbx
mov $0x6162636465666768, %rcx
movq %rcx, %xmm6
vmovups %ymm6, (%r13)
cmp $19868, %rbx
pop %rsi
pop %rdx
pop %rdi
pop %rcx
pop %rbx
pop %r9
pop %r13
pop %r12
ret
.global s_faulty_load
s_faulty_load:
push %r12
push %r15
push %rax
push %rbp
push %rcx
push %rdi
push %rsi
// REPMOV
lea addresses_normal+0x965a, %rsi
lea addresses_WC+0x2bef, %rdi
clflush (%rsi)
nop
xor $34285, %r12
mov $97, %rcx
rep movsw
nop
and %rax, %rax
// REPMOV
lea addresses_UC+0x215a, %rsi
lea addresses_UC+0x135a, %rdi
nop
nop
sub $45826, %rbp
mov $115, %rcx
rep movsb
// Exception!!!
nop
nop
nop
mov (0), %rdi
nop
nop
nop
nop
xor $5814, %rdi
// Store
mov $0xc5a, %rbp
nop
nop
nop
nop
dec %r15
movl $0x51525354, (%rbp)
nop
cmp $32476, %rdi
// Store
lea addresses_WT+0x95a, %rbp
nop
nop
nop
nop
inc %rcx
mov $0x5152535455565758, %rsi
movq %rsi, %xmm4
and $0xffffffffffffffc0, %rbp
movaps %xmm4, (%rbp)
nop
nop
cmp %rbp, %rbp
// Store
lea addresses_D+0x1f1da, %rbp
nop
nop
nop
nop
nop
add $44752, %rsi
mov $0x5152535455565758, %r12
movq %r12, (%rbp)
nop
nop
add $40703, %r15
// Store
lea addresses_US+0x1d95a, %rbp
nop
nop
nop
nop
nop
sub $23459, %rax
mov $0x5152535455565758, %rcx
movq %rcx, %xmm6
vmovups %ymm6, (%rbp)
and %r15, %r15
// Load
lea addresses_RW+0xb61a, %rbp
nop
nop
nop
nop
sub %r12, %r12
mov (%rbp), %r15
cmp %rcx, %rcx
// Load
lea addresses_US+0x3eda, %rsi
clflush (%rsi)
nop
nop
nop
nop
and $64991, %r12
mov (%rsi), %eax
inc %r15
// Faulty Load
lea addresses_A+0x755a, %rdi
clflush (%rdi)
nop
sub $413, %rsi
movups (%rdi), %xmm6
vpextrq $1, %xmm6, %r15
lea oracles, %rcx
and $0xff, %r15
shlq $12, %r15
mov (%rcx,%r15,1), %r15
pop %rsi
pop %rdi
pop %rcx
pop %rbp
pop %rax
pop %r15
pop %r12
ret
/*
<gen_faulty_load>
[REF]
{'src': {'type': 'addresses_A', 'AVXalign': False, 'size': 16, 'NT': False, 'same': True, 'congruent': 0}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_normal', 'congruent': 8, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_WC', 'congruent': 0, 'same': False}}
{'src': {'type': 'addresses_UC', 'congruent': 10, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_UC', 'congruent': 8, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_P', 'AVXalign': False, 'size': 4, 'NT': True, 'same': False, 'congruent': 8}}
{'OP': 'STOR', 'dst': {'type': 'addresses_WT', 'AVXalign': True, 'size': 16, 'NT': False, 'same': True, 'congruent': 8}}
{'OP': 'STOR', 'dst': {'type': 'addresses_D', 'AVXalign': False, 'size': 8, 'NT': False, 'same': False, 'congruent': 4}}
{'OP': 'STOR', 'dst': {'type': 'addresses_US', 'AVXalign': False, 'size': 32, 'NT': False, 'same': False, 'congruent': 7}}
{'src': {'type': 'addresses_RW', 'AVXalign': False, 'size': 8, 'NT': True, 'same': False, 'congruent': 3}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_US', 'AVXalign': False, 'size': 4, 'NT': False, 'same': False, 'congruent': 7}, 'OP': 'LOAD'}
[Faulty Load]
{'src': {'type': 'addresses_A', 'AVXalign': False, 'size': 16, 'NT': False, 'same': True, 'congruent': 0}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'src': {'type': 'addresses_WT_ht', 'AVXalign': False, 'size': 8, 'NT': False, 'same': False, 'congruent': 1}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'type': 'addresses_normal_ht', 'AVXalign': True, 'size': 4, 'NT': False, 'same': False, 'congruent': 8}}
{'OP': 'STOR', 'dst': {'type': 'addresses_WT_ht', 'AVXalign': False, 'size': 4, 'NT': False, 'same': False, 'congruent': 5}}
{'src': {'type': 'addresses_UC_ht', 'congruent': 5, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_WT_ht', 'congruent': 8, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_WC_ht', 'AVXalign': False, 'size': 4, 'NT': False, 'same': True, 'congruent': 7}}
{'src': {'type': 'addresses_UC_ht', 'congruent': 3, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_normal_ht', 'congruent': 4, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_UC_ht', 'AVXalign': False, 'size': 8, 'NT': False, 'same': False, 'congruent': 2}}
{'OP': 'STOR', 'dst': {'type': 'addresses_D_ht', 'AVXalign': False, 'size': 32, 'NT': False, 'same': True, 'congruent': 10}}
{'08': 15, '00': 14329, '44': 1, '38': 20, '34': 7452, '94': 1, 'ff': 11}
00 00 00 00 34 34 34 00 00 34 34 34 34 00 34 34 00 34 00 00 00 00 34 34 00 00 34 34 00 00 34 34 00 00 00 34 34 34 34 00 34 34 34 34 00 00 00 00 00 00 00 00 34 34 00 00 00 34 00 34 00 00 00 00 00 00 00 00 00 00 00 00 00 34 00 00 34 00 00 00 00 00 00 00 00 34 34 00 00 00 00 00 00 00 34 34 34 00 00 00 34 00 00 00 34 00 00 34 34 00 34 00 34 00 00 00 00 00 00 00 34 00 34 00 34 00 00 00 00 00 00 34 00 00 34 34 00 00 34 00 34 00 00 00 34 00 00 34 00 00 00 00 00 00 34 00 00 34 00 00 00 00 00 00 34 00 00 00 34 00 34 34 00 00 00 00 00 00 00 00 34 00 34 34 34 34 00 34 00 34 00 00 34 34 00 00 00 34 00 00 34 34 34 34 00 00 00 00 00 00 34 00 00 00 00 34 00 34 00 34 34 34 34 00 00 00 34 00 00 00 00 34 00 00 34 00 00 00 00 34 34 34 34 00 34 00 34 34 34 00 00 34 00 00 00 34 00 00 00 00 00 00 34 34 00 00 00 00 34 34 00 00 00 00 00 00 00 00 00 00 34 00 00 34 00 00 00 00 34 00 00 34 00 00 34 34 34 00 00 00 00 00 00 00 34 34 34 00 00 34 00 34 00 00 34 00 00 00 00 00 00 00 00 ff 00 34 34 00 34 00 00 00 34 00 34 34 34 00 00 00 00 34 00 00 34 00 00 34 34 34 00 34 00 00 34 00 34 00 34 00 34 00 34 00 34 00 00 34 00 00 00 00 34 00 34 00 34 00 00 00 00 00 00 34 00 00 00 34 34 00 00 34 00 00 34 00 00 00 00 00 34 00 00 00 34 00 00 00 00 00 34 00 34 00 00 34 34 00 34 00 34 00 00 00 00 34 00 34 00 00 34 34 00 34 00 34 00 00 34 00 00 34 00 00 34 00 00 34 00 00 34 00 00 34 00 00 00 00 34 00 00 00 00 00 00 34 00 00 00 00 00 34 00 34 00 00 00 00 00 00 34 34 00 00 34 00 00 34 00 00 00 34 00 00 00 00 00 00 00 00 00 00 34 34 34 34 34 34 34 00 34 00 00 00 00 34 00 00 00 00 00 00 34 00 00 00 08 00 34 00 00 34 34 00 00 00 34 34 00 34 00 00 34 00 00 34 34 00 00 00 34 00 00 00 00 00 00 34 00 00 00 00 34 00 34 00 00 00 34 00 00 00 34 00 34 00 00 00 00 00 00 34 00 34 00 00 34 34 34 00 34 00 00 34 34 00 00 34 34 00 00 00 00 00 00 34 34 00 00 00 00 00 00 00 34 00 00 00 00 34 34 34 00 34 00 00 34 34 00 34 00 34 00 34 00 00 00 00 00 34 00 34 00 34 00 00 00 34 00 34 34 34 00 00 34 34 34 34 34 34 00 34 00 34 34 34 34 00 34 00 34 00 00 34 34 00 34 00 34 34 00 00 34 00 34 00 00 00 00 34 00 34 00 00 34 00 00 00 00 00 00 00 34 34 00 00 00 00 00 00 00 00 00 00 34 00 34 00 00 00 00 34 00 00 00 00 00 00 34 34 00 00 00 34 00 00 34 00 34 00 00 34 00 00 34 00 00 34 00 00 34 00 00 34 00 00 34 00 00 34 34 00 00 00 00 00 00 00 00 34 00 00 00 00 00 34 00 00 34 34 00 00 34 00 00 00 00 00 34 34 34 34 34 00 00 00 00 00 34 00 00 34 00 34 00 00 00 34 00 00 00 00 00 34 34 00 00 00 34 00 34 34 00 00 34 00 34 34 34 34 00 00 00 34 00 00 00 34 00 00 34 00 00 00 00 00 00 00 00 34 00 00 00 00 00 34 34 00 00 34 34 34 08 00 00 34 00 00 34 00 00 34 00 00 34 00 34 00 00 34 00 00 00 34 34 00 34 34 34 00 00 00 34 00 34 00 00 34 00 00 34 00 00 00 00 00 00 00 00 00 00 00 00 00 00 34 00 00 34 00 00 34 00 00 00 00 00 00 00 34 00 00 00 00 00 00 00 34 00 00 00 00 34 00 34 00 34 00 00 34 34 34 34 00 00 00 34 34 00 00 00 00 00 34 00 00 00 00 00 00 00 00 00 00 00 00 00 00 34 00 00 00 34 34 00 00 34 00 00 34 00 00 00 00 00 00 00 00 00 00
*/
|
###############################################################################
# Copyright 2019 Intel Corporation
# All Rights Reserved.
#
# If this software was obtained under the Intel Simplified Software License,
# the following terms apply:
#
# The source code, information and material ("Material") contained herein is
# owned by Intel Corporation or its suppliers or licensors, and title to such
# Material remains with Intel Corporation or its suppliers or licensors. The
# Material contains proprietary information of Intel or its suppliers and
# licensors. The Material is protected by worldwide copyright laws and treaty
# provisions. No part of the Material may be used, copied, reproduced,
# modified, published, uploaded, posted, transmitted, distributed or disclosed
# in any way without Intel's prior express written permission. No license under
# any patent, copyright or other intellectual property rights in the Material
# is granted to or conferred upon you, either expressly, by implication,
# inducement, estoppel or otherwise. Any license under such intellectual
# property rights must be express and approved by Intel in writing.
#
# Unless otherwise agreed by Intel in writing, you may not remove or alter this
# notice or any other notice embedded in Materials by Intel or Intel's
# suppliers or licensors in any way.
#
#
# If this software was obtained under the Apache License, Version 2.0 (the
# "License"), the following terms apply:
#
# You may not use this file except in compliance with the License. You may
# obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
#
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#
# See the License for the specific language governing permissions and
# limitations under the License.
###############################################################################
.section .note.GNU-stack,"",%progbits
.text
p224r1_data:
_prime224r1:
.long 0x1, 0x0, 0x0, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF
.p2align 5, 0x90
.type g9_add_224, @function
g9_add_224:
movl (%esi), %eax
addl (%ebx), %eax
movl %eax, (%edi)
movl (4)(%esi), %eax
adcl (4)(%ebx), %eax
movl %eax, (4)(%edi)
movl (8)(%esi), %eax
adcl (8)(%ebx), %eax
movl %eax, (8)(%edi)
movl (12)(%esi), %eax
adcl (12)(%ebx), %eax
movl %eax, (12)(%edi)
movl (16)(%esi), %eax
adcl (16)(%ebx), %eax
movl %eax, (16)(%edi)
movl (20)(%esi), %eax
adcl (20)(%ebx), %eax
movl %eax, (20)(%edi)
movl (24)(%esi), %eax
adcl (24)(%ebx), %eax
movl %eax, (24)(%edi)
mov $(0), %eax
adc $(0), %eax
ret
.Lfe1:
.size g9_add_224, .Lfe1-(g9_add_224)
.p2align 5, 0x90
.type g9_sub_224, @function
g9_sub_224:
movl (%esi), %eax
subl (%ebx), %eax
movl %eax, (%edi)
movl (4)(%esi), %eax
sbbl (4)(%ebx), %eax
movl %eax, (4)(%edi)
movl (8)(%esi), %eax
sbbl (8)(%ebx), %eax
movl %eax, (8)(%edi)
movl (12)(%esi), %eax
sbbl (12)(%ebx), %eax
movl %eax, (12)(%edi)
movl (16)(%esi), %eax
sbbl (16)(%ebx), %eax
movl %eax, (16)(%edi)
movl (20)(%esi), %eax
sbbl (20)(%ebx), %eax
movl %eax, (20)(%edi)
movl (24)(%esi), %eax
sbbl (24)(%ebx), %eax
movl %eax, (24)(%edi)
mov $(0), %eax
adc $(0), %eax
ret
.Lfe2:
.size g9_sub_224, .Lfe2-(g9_sub_224)
.p2align 5, 0x90
.type g9_shl_224, @function
g9_shl_224:
movdqu (%esi), %xmm0
movdqu (12)(%esi), %xmm1
movl (24)(%esi), %eax
psrldq $(4), %xmm1
movdqa %xmm0, %xmm2
psllq $(1), %xmm0
psrlq $(63), %xmm2
movdqa %xmm1, %xmm3
psllq $(1), %xmm1
psrlq $(63), %xmm3
palignr $(8), %xmm2, %xmm3
pslldq $(8), %xmm2
por %xmm3, %xmm1
por %xmm2, %xmm0
movdqu %xmm0, (%edi)
movq %xmm1, (16)(%edi)
psrldq $(8), %xmm1
movd %xmm1, (24)(%edi)
shr $(31), %eax
ret
.Lfe3:
.size g9_shl_224, .Lfe3-(g9_shl_224)
.p2align 5, 0x90
.type g9_shr_224, @function
g9_shr_224:
movdqu (%esi), %xmm0
movdqu (12)(%esi), %xmm2
movd %eax, %xmm1
palignr $(4), %xmm2, %xmm1
movdqa %xmm0, %xmm2
psrlq $(1), %xmm0
psllq $(63), %xmm2
movdqa %xmm1, %xmm3
psrlq $(1), %xmm1
psllq $(63), %xmm3
movdqa %xmm3, %xmm4
palignr $(8), %xmm2, %xmm3
psrldq $(8), %xmm4
por %xmm3, %xmm0
por %xmm4, %xmm1
movdqu %xmm0, (%edi)
movq %xmm1, (16)(%edi)
psrldq $(8), %xmm1
movd %xmm1, (24)(%edi)
ret
.Lfe4:
.size g9_shr_224, .Lfe4-(g9_shr_224)
.p2align 5, 0x90
.globl g9_p224r1_add
.type g9_p224r1_add, @function
g9_p224r1_add:
push %ebp
mov %esp, %ebp
push %ebx
push %esi
push %edi
mov %esp, %eax
sub $(32), %esp
and $(-16), %esp
movl %eax, (28)(%esp)
movl (8)(%ebp), %edi
movl (12)(%ebp), %esi
movl (16)(%ebp), %ebx
call g9_add_224
mov %eax, %edx
lea (%esp), %edi
movl (8)(%ebp), %esi
lea p224r1_data, %ebx
lea ((_prime224r1-p224r1_data))(%ebx), %ebx
call g9_sub_224
lea (%esp), %esi
movl (8)(%ebp), %edi
sub %eax, %edx
cmovne %edi, %esi
movdqu (%esi), %xmm0
movq (16)(%esi), %xmm1
movd (24)(%esi), %xmm2
movdqu %xmm0, (%edi)
movq %xmm1, (16)(%edi)
movd %xmm2, (24)(%edi)
mov (28)(%esp), %esp
pop %edi
pop %esi
pop %ebx
pop %ebp
ret
.Lfe5:
.size g9_p224r1_add, .Lfe5-(g9_p224r1_add)
.p2align 5, 0x90
.globl g9_p224r1_sub
.type g9_p224r1_sub, @function
g9_p224r1_sub:
push %ebp
mov %esp, %ebp
push %ebx
push %esi
push %edi
mov %esp, %eax
sub $(32), %esp
and $(-16), %esp
movl %eax, (28)(%esp)
movl (8)(%ebp), %edi
movl (12)(%ebp), %esi
movl (16)(%ebp), %ebx
call g9_sub_224
mov %eax, %edx
lea (%esp), %edi
movl (8)(%ebp), %esi
lea p224r1_data, %ebx
lea ((_prime224r1-p224r1_data))(%ebx), %ebx
call g9_add_224
lea (%esp), %esi
movl (8)(%ebp), %edi
test %edx, %edx
cmove %edi, %esi
movdqu (%esi), %xmm0
movq (16)(%esi), %xmm1
movd (24)(%esi), %xmm2
movdqu %xmm0, (%edi)
movq %xmm1, (16)(%edi)
movd %xmm2, (24)(%edi)
mov (28)(%esp), %esp
pop %edi
pop %esi
pop %ebx
pop %ebp
ret
.Lfe6:
.size g9_p224r1_sub, .Lfe6-(g9_p224r1_sub)
.p2align 5, 0x90
.globl g9_p224r1_neg
.type g9_p224r1_neg, @function
g9_p224r1_neg:
push %ebp
mov %esp, %ebp
push %ebx
push %esi
push %edi
mov %esp, %eax
sub $(32), %esp
and $(-16), %esp
movl %eax, (28)(%esp)
movl (8)(%ebp), %edi
movl (12)(%ebp), %esi
mov $(0), %eax
subl (%esi), %eax
movl %eax, (%edi)
mov $(0), %eax
sbbl (4)(%esi), %eax
movl %eax, (4)(%edi)
mov $(0), %eax
sbbl (8)(%esi), %eax
movl %eax, (8)(%edi)
mov $(0), %eax
sbbl (12)(%esi), %eax
movl %eax, (12)(%edi)
mov $(0), %eax
sbbl (16)(%esi), %eax
movl %eax, (16)(%edi)
mov $(0), %eax
sbbl (20)(%esi), %eax
movl %eax, (20)(%edi)
mov $(0), %eax
sbbl (24)(%esi), %eax
movl %eax, (24)(%edi)
sbb %edx, %edx
lea (%esp), %edi
movl (8)(%ebp), %esi
lea p224r1_data, %ebx
lea ((_prime224r1-p224r1_data))(%ebx), %ebx
call g9_add_224
lea (%esp), %esi
movl (8)(%ebp), %edi
test %edx, %edx
cmove %edi, %esi
movdqu (%esi), %xmm0
movq (16)(%esi), %xmm1
movd (24)(%esi), %xmm2
movdqu %xmm0, (%edi)
movq %xmm1, (16)(%edi)
movd %xmm2, (24)(%edi)
mov (28)(%esp), %esp
pop %edi
pop %esi
pop %ebx
pop %ebp
ret
.Lfe7:
.size g9_p224r1_neg, .Lfe7-(g9_p224r1_neg)
.p2align 5, 0x90
.globl g9_p224r1_mul_by_2
.type g9_p224r1_mul_by_2, @function
g9_p224r1_mul_by_2:
push %ebp
mov %esp, %ebp
push %ebx
push %esi
push %edi
mov %esp, %eax
sub $(32), %esp
and $(-16), %esp
movl %eax, (28)(%esp)
lea (%esp), %edi
movl (12)(%ebp), %esi
call g9_shl_224
mov %eax, %edx
mov %edi, %esi
movl (8)(%ebp), %edi
lea p224r1_data, %ebx
lea ((_prime224r1-p224r1_data))(%ebx), %ebx
call g9_sub_224
sub %eax, %edx
cmove %edi, %esi
movdqu (%esi), %xmm0
movq (16)(%esi), %xmm1
movd (24)(%esi), %xmm2
movdqu %xmm0, (%edi)
movq %xmm1, (16)(%edi)
movd %xmm2, (24)(%edi)
mov (28)(%esp), %esp
pop %edi
pop %esi
pop %ebx
pop %ebp
ret
.Lfe8:
.size g9_p224r1_mul_by_2, .Lfe8-(g9_p224r1_mul_by_2)
.p2align 5, 0x90
.globl g9_p224r1_mul_by_3
.type g9_p224r1_mul_by_3, @function
g9_p224r1_mul_by_3:
push %ebp
mov %esp, %ebp
push %ebx
push %esi
push %edi
mov %esp, %eax
sub $(64), %esp
and $(-16), %esp
movl %eax, (60)(%esp)
lea p224r1_data, %eax
lea ((_prime224r1-p224r1_data))(%eax), %eax
movl %eax, (56)(%esp)
lea (%esp), %edi
movl (12)(%ebp), %esi
call g9_shl_224
mov %eax, %edx
mov %edi, %esi
lea (28)(%esp), %edi
mov (56)(%esp), %ebx
call g9_sub_224
sub %eax, %edx
cmove %edi, %esi
movdqu (%esi), %xmm0
movq (16)(%esi), %xmm1
movd (24)(%esi), %xmm2
movdqu %xmm0, (%edi)
movq %xmm1, (16)(%edi)
movd %xmm2, (24)(%edi)
mov %edi, %esi
movl (12)(%ebp), %ebx
call g9_add_224
mov %eax, %edx
movl (8)(%ebp), %edi
mov (56)(%esp), %ebx
call g9_sub_224
sub %eax, %edx
cmove %edi, %esi
movdqu (%esi), %xmm0
movq (16)(%esi), %xmm1
movd (24)(%esi), %xmm2
movdqu %xmm0, (%edi)
movq %xmm1, (16)(%edi)
movd %xmm2, (24)(%edi)
mov (60)(%esp), %esp
pop %edi
pop %esi
pop %ebx
pop %ebp
ret
.Lfe9:
.size g9_p224r1_mul_by_3, .Lfe9-(g9_p224r1_mul_by_3)
.p2align 5, 0x90
.globl g9_p224r1_div_by_2
.type g9_p224r1_div_by_2, @function
g9_p224r1_div_by_2:
push %ebp
mov %esp, %ebp
push %ebx
push %esi
push %edi
mov %esp, %eax
sub $(32), %esp
and $(-16), %esp
movl %eax, (28)(%esp)
lea (%esp), %edi
movl (12)(%ebp), %esi
lea p224r1_data, %ebx
lea ((_prime224r1-p224r1_data))(%ebx), %ebx
call g9_add_224
mov $(0), %edx
movl (%esi), %ecx
and $(1), %ecx
cmovne %edi, %esi
cmove %edx, %eax
movl (8)(%ebp), %edi
call g9_shr_224
mov (28)(%esp), %esp
pop %edi
pop %esi
pop %ebx
pop %ebp
ret
.Lfe10:
.size g9_p224r1_div_by_2, .Lfe10-(g9_p224r1_div_by_2)
.p2align 5, 0x90
.globl g9_p224r1_mul_mont_slm
.type g9_p224r1_mul_mont_slm, @function
g9_p224r1_mul_mont_slm:
push %ebp
mov %esp, %ebp
push %ebx
push %esi
push %edi
push %ebp
mov %esp, %eax
sub $(48), %esp
and $(-16), %esp
movl %eax, (44)(%esp)
pxor %mm0, %mm0
movq %mm0, (%esp)
movq %mm0, (8)(%esp)
movq %mm0, (16)(%esp)
movq %mm0, (24)(%esp)
movl (8)(%ebp), %edi
movl (12)(%ebp), %esi
movl (16)(%ebp), %ebp
movl %edi, (32)(%esp)
movl %esi, (36)(%esp)
movl %ebp, (40)(%esp)
mov $(7), %edi
movd (4)(%esi), %mm1
movd (8)(%esi), %mm2
movd (12)(%esi), %mm3
movd (16)(%esi), %mm4
.p2align 5, 0x90
.Lmmul_loopgas_11:
movd %edi, %mm7
movl (%ebp), %edx
movl (%esi), %eax
movd %edx, %mm0
add $(4), %ebp
movl %ebp, (40)(%esp)
pmuludq %mm0, %mm1
pmuludq %mm0, %mm2
mul %edx
addl (%esp), %eax
adc $(0), %edx
pmuludq %mm0, %mm3
pmuludq %mm0, %mm4
movd %mm1, %ecx
psrlq $(32), %mm1
add %edx, %ecx
movd %mm1, %edx
adc $(0), %edx
addl (4)(%esp), %ecx
movd (20)(%esi), %mm1
adc $(0), %edx
movd %mm2, %ebx
psrlq $(32), %mm2
add %edx, %ebx
movd %mm2, %edx
adc $(0), %edx
addl (8)(%esp), %ebx
movd (24)(%esi), %mm2
adc $(0), %edx
pmuludq %mm0, %mm1
pmuludq %mm0, %mm2
movd %mm3, %ebp
psrlq $(32), %mm3
add %edx, %ebp
movd %mm3, %edx
adc $(0), %edx
addl (12)(%esp), %ebp
adc $(0), %edx
movd %mm4, %edi
psrlq $(32), %mm4
add %edx, %edi
movd %mm4, %edx
adc $(0), %edx
addl (16)(%esp), %edi
adc $(0), %edx
neg %eax
adc $(0), %ecx
movl %ecx, (%esp)
adc $(0), %ebx
movl %ebx, (4)(%esp)
mov %eax, %ecx
sbb $(0), %eax
sub %eax, %ebp
movl %ebp, (8)(%esp)
mov %ecx, %eax
mov $(0), %ebp
sbb $(0), %edi
movl %edi, (12)(%esp)
adc $(0), %ebp
movd %mm1, %ecx
psrlq $(32), %mm1
add %edx, %ecx
movd %mm1, %edx
adc $(0), %edx
addl (20)(%esp), %ecx
adc $(0), %edx
movd %mm2, %ebx
psrlq $(32), %mm2
add %edx, %ebx
movd %mm2, %edx
adc $(0), %edx
addl (24)(%esp), %ebx
adc $(0), %edx
sub %ebp, %ecx
movl %ecx, (16)(%esp)
sbb $(0), %ebx
movl %ebx, (20)(%esp)
movd %mm7, %edi
sbb $(0), %eax
mov $(0), %ebx
addl (28)(%esp), %edx
adc $(0), %ebx
add %eax, %edx
movl %edx, (24)(%esp)
adc $(0), %ebx
movl %ebx, (28)(%esp)
sub $(1), %edi
movd (4)(%esi), %mm1
movd (8)(%esi), %mm2
movd (12)(%esi), %mm3
movd (16)(%esi), %mm4
jz .Lexit_mmul_loopgas_11
movl (40)(%esp), %ebp
jmp .Lmmul_loopgas_11
.Lexit_mmul_loopgas_11:
emms
mov (32)(%esp), %edi
lea (%esp), %esi
lea p224r1_data, %ebx
lea ((_prime224r1-p224r1_data))(%ebx), %ebx
call g9_sub_224
movl (28)(%esp), %edx
sub %eax, %edx
cmove %edi, %esi
movdqu (%esi), %xmm0
movq (16)(%esi), %xmm1
movd (24)(%esi), %xmm2
movdqu %xmm0, (%edi)
movq %xmm1, (16)(%edi)
movd %xmm2, (24)(%edi)
mov (44)(%esp), %esp
pop %ebp
pop %edi
pop %esi
pop %ebx
pop %ebp
ret
.Lfe11:
.size g9_p224r1_mul_mont_slm, .Lfe11-(g9_p224r1_mul_mont_slm)
.p2align 5, 0x90
.globl g9_p224r1_sqr_mont_slm
.type g9_p224r1_sqr_mont_slm, @function
g9_p224r1_sqr_mont_slm:
push %ebp
mov %esp, %ebp
push %esi
push %edi
movl (12)(%ebp), %esi
movl (8)(%ebp), %edi
push %esi
push %esi
push %edi
call g9_p224r1_mul_mont_slm
add $(12), %esp
pop %edi
pop %esi
pop %ebp
ret
.Lfe12:
.size g9_p224r1_sqr_mont_slm, .Lfe12-(g9_p224r1_sqr_mont_slm)
.p2align 5, 0x90
.globl g9_p224r1_mred
.type g9_p224r1_mred, @function
g9_p224r1_mred:
push %ebp
mov %esp, %ebp
push %ebx
push %esi
push %edi
movl (12)(%ebp), %esi
mov $(7), %ecx
xor %edx, %edx
.p2align 5, 0x90
.Lmred_loopgas_13:
movl (%esi), %eax
neg %eax
mov $(0), %ebx
movl %ebx, (%esi)
movl (4)(%esi), %ebx
adc $(0), %ebx
movl %ebx, (4)(%esi)
movl (8)(%esi), %ebx
adc $(0), %ebx
movl %ebx, (8)(%esi)
push %eax
movl (12)(%esi), %ebx
sbb $(0), %eax
sub %eax, %ebx
movl %ebx, (12)(%esi)
pop %eax
movl (16)(%esi), %ebx
sbb $(0), %ebx
movl %ebx, (16)(%esi)
movl (20)(%esi), %ebx
sbb $(0), %ebx
movl %ebx, (20)(%esi)
movl (24)(%esi), %ebx
sbb $(0), %ebx
movl %ebx, (24)(%esi)
movl (28)(%esi), %ebx
sbb $(0), %eax
add %edx, %eax
mov $(0), %edx
adc $(0), %edx
add %eax, %ebx
movl %ebx, (28)(%esi)
adc $(0), %edx
lea (4)(%esi), %esi
sub $(1), %ecx
jnz .Lmred_loopgas_13
movl (8)(%ebp), %edi
lea p224r1_data, %ebx
lea ((_prime224r1-p224r1_data))(%ebx), %ebx
call g9_sub_224
sub %eax, %edx
cmove %edi, %esi
movdqu (%esi), %xmm0
movq (16)(%esi), %xmm1
movd (24)(%esi), %xmm2
movdqu %xmm0, (%edi)
movq %xmm1, (16)(%edi)
movd %xmm2, (24)(%edi)
pop %edi
pop %esi
pop %ebx
pop %ebp
ret
.Lfe13:
.size g9_p224r1_mred, .Lfe13-(g9_p224r1_mred)
.p2align 5, 0x90
.globl g9_p224r1_select_pp_w5
.type g9_p224r1_select_pp_w5, @function
g9_p224r1_select_pp_w5:
push %ebp
mov %esp, %ebp
push %esi
push %edi
pxor %xmm0, %xmm0
movl (8)(%ebp), %edi
movl (12)(%ebp), %esi
movl (16)(%ebp), %eax
movd %eax, %xmm7
pshufd $(0), %xmm7, %xmm7
mov $(1), %edx
movd %edx, %xmm6
pshufd $(0), %xmm6, %xmm6
movdqa %xmm0, (%edi)
movdqa %xmm0, (16)(%edi)
movdqa %xmm0, (32)(%edi)
movdqa %xmm0, (48)(%edi)
movdqa %xmm0, (64)(%edi)
pxor %xmm3, %xmm3
movdqa %xmm6, %xmm5
mov $(16), %ecx
.p2align 5, 0x90
.Lselect_loopgas_14:
movdqa %xmm5, %xmm4
pcmpeqd %xmm7, %xmm4
movdqu (%esi), %xmm0
pand %xmm4, %xmm0
por (%edi), %xmm0
movdqa %xmm0, (%edi)
movdqu (16)(%esi), %xmm1
pand %xmm4, %xmm1
por (16)(%edi), %xmm1
movdqa %xmm1, (16)(%edi)
movdqu (32)(%esi), %xmm0
pand %xmm4, %xmm0
por (32)(%edi), %xmm0
movdqa %xmm0, (32)(%edi)
movdqu (48)(%esi), %xmm1
pand %xmm4, %xmm1
por (48)(%edi), %xmm1
movdqa %xmm1, (48)(%edi)
movdqu (64)(%esi), %xmm0
pand %xmm4, %xmm0
por (64)(%edi), %xmm0
movdqa %xmm0, (64)(%edi)
movd (80)(%esi), %xmm1
pand %xmm4, %xmm1
por %xmm1, %xmm3
paddd %xmm6, %xmm5
add $(84), %esi
sub $(1), %ecx
jnz .Lselect_loopgas_14
movd %xmm3, (80)(%edi)
pop %edi
pop %esi
pop %ebp
ret
.Lfe14:
.size g9_p224r1_select_pp_w5, .Lfe14-(g9_p224r1_select_pp_w5)
|
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// This file has been auto-generated by code_generator_v8.py. DO NOT MODIFY!
#include "config.h"
#include "IDBObjectStoreParameters.h"
namespace blink {
IDBObjectStoreParameters::IDBObjectStoreParameters()
{
setAutoIncrement(false);
}
DEFINE_TRACE(IDBObjectStoreParameters)
{
visitor->trace(m_keyPath);
}
} // namespace blink
|
.global s_prepare_buffers
s_prepare_buffers:
push %r11
push %r14
push %r9
push %rax
push %rcx
push %rdi
push %rsi
lea addresses_D_ht+0x1c230, %rsi
lea addresses_WT_ht+0xcc04, %rdi
nop
nop
nop
nop
nop
cmp $53795, %rax
mov $95, %rcx
rep movsl
nop
cmp $61926, %r9
lea addresses_WC_ht+0x14664, %rsi
lea addresses_WC_ht+0x5fb4, %rdi
nop
nop
nop
nop
nop
add $180, %r9
mov $59, %rcx
rep movsl
nop
nop
nop
nop
sub $11485, %rdi
lea addresses_UC_ht+0xe864, %rsi
lfence
mov (%rsi), %r9
nop
add %r11, %r11
lea addresses_normal_ht+0x17264, %rax
nop
nop
nop
nop
nop
cmp $48479, %r9
movb (%rax), %cl
sub %r9, %r9
lea addresses_normal_ht+0xe434, %rsi
lea addresses_WC_ht+0x9364, %rdi
nop
add $335, %r11
mov $123, %rcx
rep movsb
nop
inc %rdi
lea addresses_normal_ht+0x11664, %r11
cmp $24925, %r14
movb $0x61, (%r11)
nop
nop
nop
nop
nop
add $48737, %rsi
lea addresses_WT_ht+0x6c64, %r9
nop
nop
nop
and $38395, %r14
movb $0x61, (%r9)
nop
nop
nop
nop
inc %rsi
lea addresses_D_ht+0xaa08, %rax
sub $8931, %r9
movl $0x61626364, (%rax)
nop
nop
dec %r11
lea addresses_D_ht+0x9de4, %rsi
nop
nop
add $45801, %rax
mov $0x6162636465666768, %rdi
movq %rdi, %xmm4
movups %xmm4, (%rsi)
nop
nop
nop
nop
nop
sub $50005, %r9
lea addresses_WT_ht+0x15ba4, %rsi
nop
nop
xor $35395, %r14
mov $0x6162636465666768, %rdi
movq %rdi, %xmm2
vmovups %ymm2, (%rsi)
nop
nop
nop
cmp %r9, %r9
lea addresses_normal_ht+0x5864, %rsi
lea addresses_A_ht+0x14aa4, %rdi
add %rax, %rax
mov $96, %rcx
rep movsl
nop
sub $5583, %r14
lea addresses_WT_ht+0x16bb8, %rsi
lea addresses_UC_ht+0x15e64, %rdi
nop
nop
nop
cmp %r11, %r11
mov $3, %rcx
rep movsb
nop
nop
nop
nop
nop
xor $42845, %rdi
lea addresses_A_ht+0x1b664, %r14
nop
nop
nop
nop
inc %r9
movups (%r14), %xmm5
vpextrq $0, %xmm5, %rax
nop
nop
nop
nop
add %r11, %r11
pop %rsi
pop %rdi
pop %rcx
pop %rax
pop %r9
pop %r14
pop %r11
ret
.global s_faulty_load
s_faulty_load:
push %r11
push %r12
push %r15
push %r8
push %rax
push %rdx
push %rsi
// Store
mov $0x4d8c490000000254, %rsi
nop
nop
nop
nop
nop
add $3625, %rdx
movw $0x5152, (%rsi)
inc %r8
// Store
lea addresses_PSE+0x138f4, %rdx
nop
nop
add %r12, %r12
movb $0x51, (%rdx)
nop
nop
dec %r11
// Faulty Load
lea addresses_US+0xe664, %r8
xor $51894, %rax
mov (%r8), %r12d
lea oracles, %r8
and $0xff, %r12
shlq $12, %r12
mov (%r8,%r12,1), %r12
pop %rsi
pop %rdx
pop %rax
pop %r8
pop %r15
pop %r12
pop %r11
ret
/*
<gen_faulty_load>
[REF]
{'src': {'same': False, 'congruent': 0, 'NT': False, 'type': 'addresses_US', 'size': 1, 'AVXalign': False}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'same': False, 'congruent': 4, 'NT': False, 'type': 'addresses_NC', 'size': 2, 'AVXalign': False}}
{'OP': 'STOR', 'dst': {'same': False, 'congruent': 2, 'NT': False, 'type': 'addresses_PSE', 'size': 1, 'AVXalign': False}}
[Faulty Load]
{'src': {'same': True, 'congruent': 0, 'NT': False, 'type': 'addresses_US', 'size': 4, 'AVXalign': False}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'src': {'type': 'addresses_D_ht', 'congruent': 1, 'same': True}, 'OP': 'REPM', 'dst': {'type': 'addresses_WT_ht', 'congruent': 4, 'same': False}}
{'src': {'type': 'addresses_WC_ht', 'congruent': 7, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_WC_ht', 'congruent': 4, 'same': True}}
{'src': {'same': False, 'congruent': 7, 'NT': True, 'type': 'addresses_UC_ht', 'size': 8, 'AVXalign': False}, 'OP': 'LOAD'}
{'src': {'same': False, 'congruent': 9, 'NT': False, 'type': 'addresses_normal_ht', 'size': 1, 'AVXalign': True}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_normal_ht', 'congruent': 4, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_WC_ht', 'congruent': 8, 'same': False}}
{'OP': 'STOR', 'dst': {'same': False, 'congruent': 11, 'NT': False, 'type': 'addresses_normal_ht', 'size': 1, 'AVXalign': True}}
{'OP': 'STOR', 'dst': {'same': False, 'congruent': 8, 'NT': False, 'type': 'addresses_WT_ht', 'size': 1, 'AVXalign': False}}
{'OP': 'STOR', 'dst': {'same': True, 'congruent': 2, 'NT': False, 'type': 'addresses_D_ht', 'size': 4, 'AVXalign': False}}
{'OP': 'STOR', 'dst': {'same': False, 'congruent': 6, 'NT': False, 'type': 'addresses_D_ht', 'size': 16, 'AVXalign': False}}
{'OP': 'STOR', 'dst': {'same': False, 'congruent': 3, 'NT': False, 'type': 'addresses_WT_ht', 'size': 32, 'AVXalign': False}}
{'src': {'type': 'addresses_normal_ht', 'congruent': 8, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_A_ht', 'congruent': 6, 'same': False}}
{'src': {'type': 'addresses_WT_ht', 'congruent': 2, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_UC_ht', 'congruent': 11, 'same': False}}
{'src': {'same': False, 'congruent': 11, 'NT': False, 'type': 'addresses_A_ht', 'size': 16, 'AVXalign': False}, 'OP': 'LOAD'}
{'00': 410}
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
*/
|
default rel
%define XMMWORD
%define YMMWORD
%define ZMMWORD
section .text code align=64
EXTERN OPENSSL_ia32cap_P
global rsaz_512_sqr
ALIGN 32
rsaz_512_sqr:
mov QWORD[8+rsp],rdi ;WIN64 prologue
mov QWORD[16+rsp],rsi
mov rax,rsp
$L$SEH_begin_rsaz_512_sqr:
mov rdi,rcx
mov rsi,rdx
mov rdx,r8
mov rcx,r9
mov r8,QWORD[40+rsp]
push rbx
push rbp
push r12
push r13
push r14
push r15
sub rsp,128+24
$L$sqr_body:
mov rbp,rdx
mov rdx,QWORD[rsi]
mov rax,QWORD[8+rsi]
mov QWORD[128+rsp],rcx
mov r11d,0x80100
and r11d,DWORD[((OPENSSL_ia32cap_P+8))]
cmp r11d,0x80100
je NEAR $L$oop_sqrx
jmp NEAR $L$oop_sqr
ALIGN 32
$L$oop_sqr:
mov DWORD[((128+8))+rsp],r8d
mov rbx,rdx
mul rdx
mov r8,rax
mov rax,QWORD[16+rsi]
mov r9,rdx
mul rbx
add r9,rax
mov rax,QWORD[24+rsi]
mov r10,rdx
adc r10,0
mul rbx
add r10,rax
mov rax,QWORD[32+rsi]
mov r11,rdx
adc r11,0
mul rbx
add r11,rax
mov rax,QWORD[40+rsi]
mov r12,rdx
adc r12,0
mul rbx
add r12,rax
mov rax,QWORD[48+rsi]
mov r13,rdx
adc r13,0
mul rbx
add r13,rax
mov rax,QWORD[56+rsi]
mov r14,rdx
adc r14,0
mul rbx
add r14,rax
mov rax,rbx
mov r15,rdx
adc r15,0
add r8,r8
mov rcx,r9
adc r9,r9
mul rax
mov QWORD[rsp],rax
add r8,rdx
adc r9,0
mov QWORD[8+rsp],r8
shr rcx,63
mov r8,QWORD[8+rsi]
mov rax,QWORD[16+rsi]
mul r8
add r10,rax
mov rax,QWORD[24+rsi]
mov rbx,rdx
adc rbx,0
mul r8
add r11,rax
mov rax,QWORD[32+rsi]
adc rdx,0
add r11,rbx
mov rbx,rdx
adc rbx,0
mul r8
add r12,rax
mov rax,QWORD[40+rsi]
adc rdx,0
add r12,rbx
mov rbx,rdx
adc rbx,0
mul r8
add r13,rax
mov rax,QWORD[48+rsi]
adc rdx,0
add r13,rbx
mov rbx,rdx
adc rbx,0
mul r8
add r14,rax
mov rax,QWORD[56+rsi]
adc rdx,0
add r14,rbx
mov rbx,rdx
adc rbx,0
mul r8
add r15,rax
mov rax,r8
adc rdx,0
add r15,rbx
mov r8,rdx
mov rdx,r10
adc r8,0
add rdx,rdx
lea r10,[r10*2+rcx]
mov rbx,r11
adc r11,r11
mul rax
add r9,rax
adc r10,rdx
adc r11,0
mov QWORD[16+rsp],r9
mov QWORD[24+rsp],r10
shr rbx,63
mov r9,QWORD[16+rsi]
mov rax,QWORD[24+rsi]
mul r9
add r12,rax
mov rax,QWORD[32+rsi]
mov rcx,rdx
adc rcx,0
mul r9
add r13,rax
mov rax,QWORD[40+rsi]
adc rdx,0
add r13,rcx
mov rcx,rdx
adc rcx,0
mul r9
add r14,rax
mov rax,QWORD[48+rsi]
adc rdx,0
add r14,rcx
mov rcx,rdx
adc rcx,0
mul r9
mov r10,r12
lea r12,[r12*2+rbx]
add r15,rax
mov rax,QWORD[56+rsi]
adc rdx,0
add r15,rcx
mov rcx,rdx
adc rcx,0
mul r9
shr r10,63
add r8,rax
mov rax,r9
adc rdx,0
add r8,rcx
mov r9,rdx
adc r9,0
mov rcx,r13
lea r13,[r13*2+r10]
mul rax
add r11,rax
adc r12,rdx
adc r13,0
mov QWORD[32+rsp],r11
mov QWORD[40+rsp],r12
shr rcx,63
mov r10,QWORD[24+rsi]
mov rax,QWORD[32+rsi]
mul r10
add r14,rax
mov rax,QWORD[40+rsi]
mov rbx,rdx
adc rbx,0
mul r10
add r15,rax
mov rax,QWORD[48+rsi]
adc rdx,0
add r15,rbx
mov rbx,rdx
adc rbx,0
mul r10
mov r12,r14
lea r14,[r14*2+rcx]
add r8,rax
mov rax,QWORD[56+rsi]
adc rdx,0
add r8,rbx
mov rbx,rdx
adc rbx,0
mul r10
shr r12,63
add r9,rax
mov rax,r10
adc rdx,0
add r9,rbx
mov r10,rdx
adc r10,0
mov rbx,r15
lea r15,[r15*2+r12]
mul rax
add r13,rax
adc r14,rdx
adc r15,0
mov QWORD[48+rsp],r13
mov QWORD[56+rsp],r14
shr rbx,63
mov r11,QWORD[32+rsi]
mov rax,QWORD[40+rsi]
mul r11
add r8,rax
mov rax,QWORD[48+rsi]
mov rcx,rdx
adc rcx,0
mul r11
add r9,rax
mov rax,QWORD[56+rsi]
adc rdx,0
mov r12,r8
lea r8,[r8*2+rbx]
add r9,rcx
mov rcx,rdx
adc rcx,0
mul r11
shr r12,63
add r10,rax
mov rax,r11
adc rdx,0
add r10,rcx
mov r11,rdx
adc r11,0
mov rcx,r9
lea r9,[r9*2+r12]
mul rax
add r15,rax
adc r8,rdx
adc r9,0
mov QWORD[64+rsp],r15
mov QWORD[72+rsp],r8
shr rcx,63
mov r12,QWORD[40+rsi]
mov rax,QWORD[48+rsi]
mul r12
add r10,rax
mov rax,QWORD[56+rsi]
mov rbx,rdx
adc rbx,0
mul r12
add r11,rax
mov rax,r12
mov r15,r10
lea r10,[r10*2+rcx]
adc rdx,0
shr r15,63
add r11,rbx
mov r12,rdx
adc r12,0
mov rbx,r11
lea r11,[r11*2+r15]
mul rax
add r9,rax
adc r10,rdx
adc r11,0
mov QWORD[80+rsp],r9
mov QWORD[88+rsp],r10
mov r13,QWORD[48+rsi]
mov rax,QWORD[56+rsi]
mul r13
add r12,rax
mov rax,r13
mov r13,rdx
adc r13,0
xor r14,r14
shl rbx,1
adc r12,r12
adc r13,r13
adc r14,r14
mul rax
add r11,rax
adc r12,rdx
adc r13,0
mov QWORD[96+rsp],r11
mov QWORD[104+rsp],r12
mov rax,QWORD[56+rsi]
mul rax
add r13,rax
adc rdx,0
add r14,rdx
mov QWORD[112+rsp],r13
mov QWORD[120+rsp],r14
mov r8,QWORD[rsp]
mov r9,QWORD[8+rsp]
mov r10,QWORD[16+rsp]
mov r11,QWORD[24+rsp]
mov r12,QWORD[32+rsp]
mov r13,QWORD[40+rsp]
mov r14,QWORD[48+rsp]
mov r15,QWORD[56+rsp]
call __rsaz_512_reduce
add r8,QWORD[64+rsp]
adc r9,QWORD[72+rsp]
adc r10,QWORD[80+rsp]
adc r11,QWORD[88+rsp]
adc r12,QWORD[96+rsp]
adc r13,QWORD[104+rsp]
adc r14,QWORD[112+rsp]
adc r15,QWORD[120+rsp]
sbb rcx,rcx
call __rsaz_512_subtract
mov rdx,r8
mov rax,r9
mov r8d,DWORD[((128+8))+rsp]
mov rsi,rdi
dec r8d
jnz NEAR $L$oop_sqr
jmp NEAR $L$sqr_tail
ALIGN 32
$L$oop_sqrx:
mov DWORD[((128+8))+rsp],r8d
DB 102,72,15,110,199
DB 102,72,15,110,205
mulx r9,r8,rax
mulx r10,rcx,QWORD[16+rsi]
xor rbp,rbp
mulx r11,rax,QWORD[24+rsi]
adcx r9,rcx
mulx r12,rcx,QWORD[32+rsi]
adcx r10,rax
mulx r13,rax,QWORD[40+rsi]
adcx r11,rcx
DB 0xc4,0x62,0xf3,0xf6,0xb6,0x30,0x00,0x00,0x00
adcx r12,rax
adcx r13,rcx
DB 0xc4,0x62,0xfb,0xf6,0xbe,0x38,0x00,0x00,0x00
adcx r14,rax
adcx r15,rbp
mov rcx,r9
shld r9,r8,1
shl r8,1
xor ebp,ebp
mulx rdx,rax,rdx
adcx r8,rdx
mov rdx,QWORD[8+rsi]
adcx r9,rbp
mov QWORD[rsp],rax
mov QWORD[8+rsp],r8
mulx rbx,rax,QWORD[16+rsi]
adox r10,rax
adcx r11,rbx
DB 0xc4,0x62,0xc3,0xf6,0x86,0x18,0x00,0x00,0x00
adox r11,rdi
adcx r12,r8
mulx rbx,rax,QWORD[32+rsi]
adox r12,rax
adcx r13,rbx
mulx r8,rdi,QWORD[40+rsi]
adox r13,rdi
adcx r14,r8
DB 0xc4,0xe2,0xfb,0xf6,0x9e,0x30,0x00,0x00,0x00
adox r14,rax
adcx r15,rbx
DB 0xc4,0x62,0xc3,0xf6,0x86,0x38,0x00,0x00,0x00
adox r15,rdi
adcx r8,rbp
adox r8,rbp
mov rbx,r11
shld r11,r10,1
shld r10,rcx,1
xor ebp,ebp
mulx rcx,rax,rdx
mov rdx,QWORD[16+rsi]
adcx r9,rax
adcx r10,rcx
adcx r11,rbp
mov QWORD[16+rsp],r9
DB 0x4c,0x89,0x94,0x24,0x18,0x00,0x00,0x00
DB 0xc4,0x62,0xc3,0xf6,0x8e,0x18,0x00,0x00,0x00
adox r12,rdi
adcx r13,r9
mulx rcx,rax,QWORD[32+rsi]
adox r13,rax
adcx r14,rcx
mulx r9,rdi,QWORD[40+rsi]
adox r14,rdi
adcx r15,r9
DB 0xc4,0xe2,0xfb,0xf6,0x8e,0x30,0x00,0x00,0x00
adox r15,rax
adcx r8,rcx
DB 0xc4,0x62,0xc3,0xf6,0x8e,0x38,0x00,0x00,0x00
adox r8,rdi
adcx r9,rbp
adox r9,rbp
mov rcx,r13
shld r13,r12,1
shld r12,rbx,1
xor ebp,ebp
mulx rdx,rax,rdx
adcx r11,rax
adcx r12,rdx
mov rdx,QWORD[24+rsi]
adcx r13,rbp
mov QWORD[32+rsp],r11
DB 0x4c,0x89,0xa4,0x24,0x28,0x00,0x00,0x00
DB 0xc4,0xe2,0xfb,0xf6,0x9e,0x20,0x00,0x00,0x00
adox r14,rax
adcx r15,rbx
mulx r10,rdi,QWORD[40+rsi]
adox r15,rdi
adcx r8,r10
mulx rbx,rax,QWORD[48+rsi]
adox r8,rax
adcx r9,rbx
mulx r10,rdi,QWORD[56+rsi]
adox r9,rdi
adcx r10,rbp
adox r10,rbp
DB 0x66
mov rbx,r15
shld r15,r14,1
shld r14,rcx,1
xor ebp,ebp
mulx rdx,rax,rdx
adcx r13,rax
adcx r14,rdx
mov rdx,QWORD[32+rsi]
adcx r15,rbp
mov QWORD[48+rsp],r13
mov QWORD[56+rsp],r14
DB 0xc4,0x62,0xc3,0xf6,0x9e,0x28,0x00,0x00,0x00
adox r8,rdi
adcx r9,r11
mulx rcx,rax,QWORD[48+rsi]
adox r9,rax
adcx r10,rcx
mulx r11,rdi,QWORD[56+rsi]
adox r10,rdi
adcx r11,rbp
adox r11,rbp
mov rcx,r9
shld r9,r8,1
shld r8,rbx,1
xor ebp,ebp
mulx rdx,rax,rdx
adcx r15,rax
adcx r8,rdx
mov rdx,QWORD[40+rsi]
adcx r9,rbp
mov QWORD[64+rsp],r15
mov QWORD[72+rsp],r8
DB 0xc4,0xe2,0xfb,0xf6,0x9e,0x30,0x00,0x00,0x00
adox r10,rax
adcx r11,rbx
DB 0xc4,0x62,0xc3,0xf6,0xa6,0x38,0x00,0x00,0x00
adox r11,rdi
adcx r12,rbp
adox r12,rbp
mov rbx,r11
shld r11,r10,1
shld r10,rcx,1
xor ebp,ebp
mulx rdx,rax,rdx
adcx r9,rax
adcx r10,rdx
mov rdx,QWORD[48+rsi]
adcx r11,rbp
mov QWORD[80+rsp],r9
mov QWORD[88+rsp],r10
DB 0xc4,0x62,0xfb,0xf6,0xae,0x38,0x00,0x00,0x00
adox r12,rax
adox r13,rbp
xor r14,r14
shld r14,r13,1
shld r13,r12,1
shld r12,rbx,1
xor ebp,ebp
mulx rdx,rax,rdx
adcx r11,rax
adcx r12,rdx
mov rdx,QWORD[56+rsi]
adcx r13,rbp
DB 0x4c,0x89,0x9c,0x24,0x60,0x00,0x00,0x00
DB 0x4c,0x89,0xa4,0x24,0x68,0x00,0x00,0x00
mulx rdx,rax,rdx
adox r13,rax
adox rdx,rbp
DB 0x66
add r14,rdx
mov QWORD[112+rsp],r13
mov QWORD[120+rsp],r14
DB 102,72,15,126,199
DB 102,72,15,126,205
mov rdx,QWORD[128+rsp]
mov r8,QWORD[rsp]
mov r9,QWORD[8+rsp]
mov r10,QWORD[16+rsp]
mov r11,QWORD[24+rsp]
mov r12,QWORD[32+rsp]
mov r13,QWORD[40+rsp]
mov r14,QWORD[48+rsp]
mov r15,QWORD[56+rsp]
call __rsaz_512_reducex
add r8,QWORD[64+rsp]
adc r9,QWORD[72+rsp]
adc r10,QWORD[80+rsp]
adc r11,QWORD[88+rsp]
adc r12,QWORD[96+rsp]
adc r13,QWORD[104+rsp]
adc r14,QWORD[112+rsp]
adc r15,QWORD[120+rsp]
sbb rcx,rcx
call __rsaz_512_subtract
mov rdx,r8
mov rax,r9
mov r8d,DWORD[((128+8))+rsp]
mov rsi,rdi
dec r8d
jnz NEAR $L$oop_sqrx
$L$sqr_tail:
lea rax,[((128+24+48))+rsp]
mov r15,QWORD[((-48))+rax]
mov r14,QWORD[((-40))+rax]
mov r13,QWORD[((-32))+rax]
mov r12,QWORD[((-24))+rax]
mov rbp,QWORD[((-16))+rax]
mov rbx,QWORD[((-8))+rax]
lea rsp,[rax]
$L$sqr_epilogue:
mov rdi,QWORD[8+rsp] ;WIN64 epilogue
mov rsi,QWORD[16+rsp]
DB 0F3h,0C3h ;repret
$L$SEH_end_rsaz_512_sqr:
global rsaz_512_mul
ALIGN 32
rsaz_512_mul:
mov QWORD[8+rsp],rdi ;WIN64 prologue
mov QWORD[16+rsp],rsi
mov rax,rsp
$L$SEH_begin_rsaz_512_mul:
mov rdi,rcx
mov rsi,rdx
mov rdx,r8
mov rcx,r9
mov r8,QWORD[40+rsp]
push rbx
push rbp
push r12
push r13
push r14
push r15
sub rsp,128+24
$L$mul_body:
DB 102,72,15,110,199
DB 102,72,15,110,201
mov QWORD[128+rsp],r8
mov r11d,0x80100
and r11d,DWORD[((OPENSSL_ia32cap_P+8))]
cmp r11d,0x80100
je NEAR $L$mulx
mov rbx,QWORD[rdx]
mov rbp,rdx
call __rsaz_512_mul
DB 102,72,15,126,199
DB 102,72,15,126,205
mov r8,QWORD[rsp]
mov r9,QWORD[8+rsp]
mov r10,QWORD[16+rsp]
mov r11,QWORD[24+rsp]
mov r12,QWORD[32+rsp]
mov r13,QWORD[40+rsp]
mov r14,QWORD[48+rsp]
mov r15,QWORD[56+rsp]
call __rsaz_512_reduce
jmp NEAR $L$mul_tail
ALIGN 32
$L$mulx:
mov rbp,rdx
mov rdx,QWORD[rdx]
call __rsaz_512_mulx
DB 102,72,15,126,199
DB 102,72,15,126,205
mov rdx,QWORD[128+rsp]
mov r8,QWORD[rsp]
mov r9,QWORD[8+rsp]
mov r10,QWORD[16+rsp]
mov r11,QWORD[24+rsp]
mov r12,QWORD[32+rsp]
mov r13,QWORD[40+rsp]
mov r14,QWORD[48+rsp]
mov r15,QWORD[56+rsp]
call __rsaz_512_reducex
$L$mul_tail:
add r8,QWORD[64+rsp]
adc r9,QWORD[72+rsp]
adc r10,QWORD[80+rsp]
adc r11,QWORD[88+rsp]
adc r12,QWORD[96+rsp]
adc r13,QWORD[104+rsp]
adc r14,QWORD[112+rsp]
adc r15,QWORD[120+rsp]
sbb rcx,rcx
call __rsaz_512_subtract
lea rax,[((128+24+48))+rsp]
mov r15,QWORD[((-48))+rax]
mov r14,QWORD[((-40))+rax]
mov r13,QWORD[((-32))+rax]
mov r12,QWORD[((-24))+rax]
mov rbp,QWORD[((-16))+rax]
mov rbx,QWORD[((-8))+rax]
lea rsp,[rax]
$L$mul_epilogue:
mov rdi,QWORD[8+rsp] ;WIN64 epilogue
mov rsi,QWORD[16+rsp]
DB 0F3h,0C3h ;repret
$L$SEH_end_rsaz_512_mul:
global rsaz_512_mul_gather4
ALIGN 32
rsaz_512_mul_gather4:
mov QWORD[8+rsp],rdi ;WIN64 prologue
mov QWORD[16+rsp],rsi
mov rax,rsp
$L$SEH_begin_rsaz_512_mul_gather4:
mov rdi,rcx
mov rsi,rdx
mov rdx,r8
mov rcx,r9
mov r8,QWORD[40+rsp]
mov r9,QWORD[48+rsp]
push rbx
push rbp
push r12
push r13
push r14
push r15
sub rsp,328
movaps XMMWORD[160+rsp],xmm6
movaps XMMWORD[176+rsp],xmm7
movaps XMMWORD[192+rsp],xmm8
movaps XMMWORD[208+rsp],xmm9
movaps XMMWORD[224+rsp],xmm10
movaps XMMWORD[240+rsp],xmm11
movaps XMMWORD[256+rsp],xmm12
movaps XMMWORD[272+rsp],xmm13
movaps XMMWORD[288+rsp],xmm14
movaps XMMWORD[304+rsp],xmm15
$L$mul_gather4_body:
movd xmm8,r9d
movdqa xmm1,XMMWORD[(($L$inc+16))]
movdqa xmm0,XMMWORD[$L$inc]
pshufd xmm8,xmm8,0
movdqa xmm7,xmm1
movdqa xmm2,xmm1
paddd xmm1,xmm0
pcmpeqd xmm0,xmm8
movdqa xmm3,xmm7
paddd xmm2,xmm1
pcmpeqd xmm1,xmm8
movdqa xmm4,xmm7
paddd xmm3,xmm2
pcmpeqd xmm2,xmm8
movdqa xmm5,xmm7
paddd xmm4,xmm3
pcmpeqd xmm3,xmm8
movdqa xmm6,xmm7
paddd xmm5,xmm4
pcmpeqd xmm4,xmm8
paddd xmm6,xmm5
pcmpeqd xmm5,xmm8
paddd xmm7,xmm6
pcmpeqd xmm6,xmm8
pcmpeqd xmm7,xmm8
movdqa xmm8,XMMWORD[rdx]
movdqa xmm9,XMMWORD[16+rdx]
movdqa xmm10,XMMWORD[32+rdx]
movdqa xmm11,XMMWORD[48+rdx]
pand xmm8,xmm0
movdqa xmm12,XMMWORD[64+rdx]
pand xmm9,xmm1
movdqa xmm13,XMMWORD[80+rdx]
pand xmm10,xmm2
movdqa xmm14,XMMWORD[96+rdx]
pand xmm11,xmm3
movdqa xmm15,XMMWORD[112+rdx]
lea rbp,[128+rdx]
pand xmm12,xmm4
pand xmm13,xmm5
pand xmm14,xmm6
pand xmm15,xmm7
por xmm8,xmm10
por xmm9,xmm11
por xmm8,xmm12
por xmm9,xmm13
por xmm8,xmm14
por xmm9,xmm15
por xmm8,xmm9
pshufd xmm9,xmm8,0x4e
por xmm8,xmm9
mov r11d,0x80100
and r11d,DWORD[((OPENSSL_ia32cap_P+8))]
cmp r11d,0x80100
je NEAR $L$mulx_gather
DB 102,76,15,126,195
mov QWORD[128+rsp],r8
mov QWORD[((128+8))+rsp],rdi
mov QWORD[((128+16))+rsp],rcx
mov rax,QWORD[rsi]
mov rcx,QWORD[8+rsi]
mul rbx
mov QWORD[rsp],rax
mov rax,rcx
mov r8,rdx
mul rbx
add r8,rax
mov rax,QWORD[16+rsi]
mov r9,rdx
adc r9,0
mul rbx
add r9,rax
mov rax,QWORD[24+rsi]
mov r10,rdx
adc r10,0
mul rbx
add r10,rax
mov rax,QWORD[32+rsi]
mov r11,rdx
adc r11,0
mul rbx
add r11,rax
mov rax,QWORD[40+rsi]
mov r12,rdx
adc r12,0
mul rbx
add r12,rax
mov rax,QWORD[48+rsi]
mov r13,rdx
adc r13,0
mul rbx
add r13,rax
mov rax,QWORD[56+rsi]
mov r14,rdx
adc r14,0
mul rbx
add r14,rax
mov rax,QWORD[rsi]
mov r15,rdx
adc r15,0
lea rdi,[8+rsp]
mov ecx,7
jmp NEAR $L$oop_mul_gather
ALIGN 32
$L$oop_mul_gather:
movdqa xmm8,XMMWORD[rbp]
movdqa xmm9,XMMWORD[16+rbp]
movdqa xmm10,XMMWORD[32+rbp]
movdqa xmm11,XMMWORD[48+rbp]
pand xmm8,xmm0
movdqa xmm12,XMMWORD[64+rbp]
pand xmm9,xmm1
movdqa xmm13,XMMWORD[80+rbp]
pand xmm10,xmm2
movdqa xmm14,XMMWORD[96+rbp]
pand xmm11,xmm3
movdqa xmm15,XMMWORD[112+rbp]
lea rbp,[128+rbp]
pand xmm12,xmm4
pand xmm13,xmm5
pand xmm14,xmm6
pand xmm15,xmm7
por xmm8,xmm10
por xmm9,xmm11
por xmm8,xmm12
por xmm9,xmm13
por xmm8,xmm14
por xmm9,xmm15
por xmm8,xmm9
pshufd xmm9,xmm8,0x4e
por xmm8,xmm9
DB 102,76,15,126,195
mul rbx
add r8,rax
mov rax,QWORD[8+rsi]
mov QWORD[rdi],r8
mov r8,rdx
adc r8,0
mul rbx
add r9,rax
mov rax,QWORD[16+rsi]
adc rdx,0
add r8,r9
mov r9,rdx
adc r9,0
mul rbx
add r10,rax
mov rax,QWORD[24+rsi]
adc rdx,0
add r9,r10
mov r10,rdx
adc r10,0
mul rbx
add r11,rax
mov rax,QWORD[32+rsi]
adc rdx,0
add r10,r11
mov r11,rdx
adc r11,0
mul rbx
add r12,rax
mov rax,QWORD[40+rsi]
adc rdx,0
add r11,r12
mov r12,rdx
adc r12,0
mul rbx
add r13,rax
mov rax,QWORD[48+rsi]
adc rdx,0
add r12,r13
mov r13,rdx
adc r13,0
mul rbx
add r14,rax
mov rax,QWORD[56+rsi]
adc rdx,0
add r13,r14
mov r14,rdx
adc r14,0
mul rbx
add r15,rax
mov rax,QWORD[rsi]
adc rdx,0
add r14,r15
mov r15,rdx
adc r15,0
lea rdi,[8+rdi]
dec ecx
jnz NEAR $L$oop_mul_gather
mov QWORD[rdi],r8
mov QWORD[8+rdi],r9
mov QWORD[16+rdi],r10
mov QWORD[24+rdi],r11
mov QWORD[32+rdi],r12
mov QWORD[40+rdi],r13
mov QWORD[48+rdi],r14
mov QWORD[56+rdi],r15
mov rdi,QWORD[((128+8))+rsp]
mov rbp,QWORD[((128+16))+rsp]
mov r8,QWORD[rsp]
mov r9,QWORD[8+rsp]
mov r10,QWORD[16+rsp]
mov r11,QWORD[24+rsp]
mov r12,QWORD[32+rsp]
mov r13,QWORD[40+rsp]
mov r14,QWORD[48+rsp]
mov r15,QWORD[56+rsp]
call __rsaz_512_reduce
jmp NEAR $L$mul_gather_tail
ALIGN 32
$L$mulx_gather:
DB 102,76,15,126,194
mov QWORD[128+rsp],r8
mov QWORD[((128+8))+rsp],rdi
mov QWORD[((128+16))+rsp],rcx
mulx r8,rbx,QWORD[rsi]
mov QWORD[rsp],rbx
xor edi,edi
mulx r9,rax,QWORD[8+rsi]
mulx r10,rbx,QWORD[16+rsi]
adcx r8,rax
mulx r11,rax,QWORD[24+rsi]
adcx r9,rbx
mulx r12,rbx,QWORD[32+rsi]
adcx r10,rax
mulx r13,rax,QWORD[40+rsi]
adcx r11,rbx
mulx r14,rbx,QWORD[48+rsi]
adcx r12,rax
mulx r15,rax,QWORD[56+rsi]
adcx r13,rbx
adcx r14,rax
DB 0x67
mov rbx,r8
adcx r15,rdi
mov rcx,-7
jmp NEAR $L$oop_mulx_gather
ALIGN 32
$L$oop_mulx_gather:
movdqa xmm8,XMMWORD[rbp]
movdqa xmm9,XMMWORD[16+rbp]
movdqa xmm10,XMMWORD[32+rbp]
movdqa xmm11,XMMWORD[48+rbp]
pand xmm8,xmm0
movdqa xmm12,XMMWORD[64+rbp]
pand xmm9,xmm1
movdqa xmm13,XMMWORD[80+rbp]
pand xmm10,xmm2
movdqa xmm14,XMMWORD[96+rbp]
pand xmm11,xmm3
movdqa xmm15,XMMWORD[112+rbp]
lea rbp,[128+rbp]
pand xmm12,xmm4
pand xmm13,xmm5
pand xmm14,xmm6
pand xmm15,xmm7
por xmm8,xmm10
por xmm9,xmm11
por xmm8,xmm12
por xmm9,xmm13
por xmm8,xmm14
por xmm9,xmm15
por xmm8,xmm9
pshufd xmm9,xmm8,0x4e
por xmm8,xmm9
DB 102,76,15,126,194
DB 0xc4,0x62,0xfb,0xf6,0x86,0x00,0x00,0x00,0x00
adcx rbx,rax
adox r8,r9
mulx r9,rax,QWORD[8+rsi]
adcx r8,rax
adox r9,r10
mulx r10,rax,QWORD[16+rsi]
adcx r9,rax
adox r10,r11
DB 0xc4,0x62,0xfb,0xf6,0x9e,0x18,0x00,0x00,0x00
adcx r10,rax
adox r11,r12
mulx r12,rax,QWORD[32+rsi]
adcx r11,rax
adox r12,r13
mulx r13,rax,QWORD[40+rsi]
adcx r12,rax
adox r13,r14
DB 0xc4,0x62,0xfb,0xf6,0xb6,0x30,0x00,0x00,0x00
adcx r13,rax
DB 0x67
adox r14,r15
mulx r15,rax,QWORD[56+rsi]
mov QWORD[64+rcx*8+rsp],rbx
adcx r14,rax
adox r15,rdi
mov rbx,r8
adcx r15,rdi
inc rcx
jnz NEAR $L$oop_mulx_gather
mov QWORD[64+rsp],r8
mov QWORD[((64+8))+rsp],r9
mov QWORD[((64+16))+rsp],r10
mov QWORD[((64+24))+rsp],r11
mov QWORD[((64+32))+rsp],r12
mov QWORD[((64+40))+rsp],r13
mov QWORD[((64+48))+rsp],r14
mov QWORD[((64+56))+rsp],r15
mov rdx,QWORD[128+rsp]
mov rdi,QWORD[((128+8))+rsp]
mov rbp,QWORD[((128+16))+rsp]
mov r8,QWORD[rsp]
mov r9,QWORD[8+rsp]
mov r10,QWORD[16+rsp]
mov r11,QWORD[24+rsp]
mov r12,QWORD[32+rsp]
mov r13,QWORD[40+rsp]
mov r14,QWORD[48+rsp]
mov r15,QWORD[56+rsp]
call __rsaz_512_reducex
$L$mul_gather_tail:
add r8,QWORD[64+rsp]
adc r9,QWORD[72+rsp]
adc r10,QWORD[80+rsp]
adc r11,QWORD[88+rsp]
adc r12,QWORD[96+rsp]
adc r13,QWORD[104+rsp]
adc r14,QWORD[112+rsp]
adc r15,QWORD[120+rsp]
sbb rcx,rcx
call __rsaz_512_subtract
lea rax,[((128+24+48))+rsp]
movaps xmm6,XMMWORD[((160-200))+rax]
movaps xmm7,XMMWORD[((176-200))+rax]
movaps xmm8,XMMWORD[((192-200))+rax]
movaps xmm9,XMMWORD[((208-200))+rax]
movaps xmm10,XMMWORD[((224-200))+rax]
movaps xmm11,XMMWORD[((240-200))+rax]
movaps xmm12,XMMWORD[((256-200))+rax]
movaps xmm13,XMMWORD[((272-200))+rax]
movaps xmm14,XMMWORD[((288-200))+rax]
movaps xmm15,XMMWORD[((304-200))+rax]
lea rax,[176+rax]
mov r15,QWORD[((-48))+rax]
mov r14,QWORD[((-40))+rax]
mov r13,QWORD[((-32))+rax]
mov r12,QWORD[((-24))+rax]
mov rbp,QWORD[((-16))+rax]
mov rbx,QWORD[((-8))+rax]
lea rsp,[rax]
$L$mul_gather4_epilogue:
mov rdi,QWORD[8+rsp] ;WIN64 epilogue
mov rsi,QWORD[16+rsp]
DB 0F3h,0C3h ;repret
$L$SEH_end_rsaz_512_mul_gather4:
global rsaz_512_mul_scatter4
ALIGN 32
rsaz_512_mul_scatter4:
mov QWORD[8+rsp],rdi ;WIN64 prologue
mov QWORD[16+rsp],rsi
mov rax,rsp
$L$SEH_begin_rsaz_512_mul_scatter4:
mov rdi,rcx
mov rsi,rdx
mov rdx,r8
mov rcx,r9
mov r8,QWORD[40+rsp]
mov r9,QWORD[48+rsp]
push rbx
push rbp
push r12
push r13
push r14
push r15
mov r9d,r9d
sub rsp,128+24
$L$mul_scatter4_body:
lea r8,[r9*8+r8]
DB 102,72,15,110,199
DB 102,72,15,110,202
DB 102,73,15,110,208
mov QWORD[128+rsp],rcx
mov rbp,rdi
mov r11d,0x80100
and r11d,DWORD[((OPENSSL_ia32cap_P+8))]
cmp r11d,0x80100
je NEAR $L$mulx_scatter
mov rbx,QWORD[rdi]
call __rsaz_512_mul
DB 102,72,15,126,199
DB 102,72,15,126,205
mov r8,QWORD[rsp]
mov r9,QWORD[8+rsp]
mov r10,QWORD[16+rsp]
mov r11,QWORD[24+rsp]
mov r12,QWORD[32+rsp]
mov r13,QWORD[40+rsp]
mov r14,QWORD[48+rsp]
mov r15,QWORD[56+rsp]
call __rsaz_512_reduce
jmp NEAR $L$mul_scatter_tail
ALIGN 32
$L$mulx_scatter:
mov rdx,QWORD[rdi]
call __rsaz_512_mulx
DB 102,72,15,126,199
DB 102,72,15,126,205
mov rdx,QWORD[128+rsp]
mov r8,QWORD[rsp]
mov r9,QWORD[8+rsp]
mov r10,QWORD[16+rsp]
mov r11,QWORD[24+rsp]
mov r12,QWORD[32+rsp]
mov r13,QWORD[40+rsp]
mov r14,QWORD[48+rsp]
mov r15,QWORD[56+rsp]
call __rsaz_512_reducex
$L$mul_scatter_tail:
add r8,QWORD[64+rsp]
adc r9,QWORD[72+rsp]
adc r10,QWORD[80+rsp]
adc r11,QWORD[88+rsp]
adc r12,QWORD[96+rsp]
adc r13,QWORD[104+rsp]
adc r14,QWORD[112+rsp]
adc r15,QWORD[120+rsp]
DB 102,72,15,126,214
sbb rcx,rcx
call __rsaz_512_subtract
mov QWORD[rsi],r8
mov QWORD[128+rsi],r9
mov QWORD[256+rsi],r10
mov QWORD[384+rsi],r11
mov QWORD[512+rsi],r12
mov QWORD[640+rsi],r13
mov QWORD[768+rsi],r14
mov QWORD[896+rsi],r15
lea rax,[((128+24+48))+rsp]
mov r15,QWORD[((-48))+rax]
mov r14,QWORD[((-40))+rax]
mov r13,QWORD[((-32))+rax]
mov r12,QWORD[((-24))+rax]
mov rbp,QWORD[((-16))+rax]
mov rbx,QWORD[((-8))+rax]
lea rsp,[rax]
$L$mul_scatter4_epilogue:
mov rdi,QWORD[8+rsp] ;WIN64 epilogue
mov rsi,QWORD[16+rsp]
DB 0F3h,0C3h ;repret
$L$SEH_end_rsaz_512_mul_scatter4:
global rsaz_512_mul_by_one
ALIGN 32
rsaz_512_mul_by_one:
mov QWORD[8+rsp],rdi ;WIN64 prologue
mov QWORD[16+rsp],rsi
mov rax,rsp
$L$SEH_begin_rsaz_512_mul_by_one:
mov rdi,rcx
mov rsi,rdx
mov rdx,r8
mov rcx,r9
push rbx
push rbp
push r12
push r13
push r14
push r15
sub rsp,128+24
$L$mul_by_one_body:
mov eax,DWORD[((OPENSSL_ia32cap_P+8))]
mov rbp,rdx
mov QWORD[128+rsp],rcx
mov r8,QWORD[rsi]
pxor xmm0,xmm0
mov r9,QWORD[8+rsi]
mov r10,QWORD[16+rsi]
mov r11,QWORD[24+rsi]
mov r12,QWORD[32+rsi]
mov r13,QWORD[40+rsi]
mov r14,QWORD[48+rsi]
mov r15,QWORD[56+rsi]
movdqa XMMWORD[rsp],xmm0
movdqa XMMWORD[16+rsp],xmm0
movdqa XMMWORD[32+rsp],xmm0
movdqa XMMWORD[48+rsp],xmm0
movdqa XMMWORD[64+rsp],xmm0
movdqa XMMWORD[80+rsp],xmm0
movdqa XMMWORD[96+rsp],xmm0
and eax,0x80100
cmp eax,0x80100
je NEAR $L$by_one_callx
call __rsaz_512_reduce
jmp NEAR $L$by_one_tail
ALIGN 32
$L$by_one_callx:
mov rdx,QWORD[128+rsp]
call __rsaz_512_reducex
$L$by_one_tail:
mov QWORD[rdi],r8
mov QWORD[8+rdi],r9
mov QWORD[16+rdi],r10
mov QWORD[24+rdi],r11
mov QWORD[32+rdi],r12
mov QWORD[40+rdi],r13
mov QWORD[48+rdi],r14
mov QWORD[56+rdi],r15
lea rax,[((128+24+48))+rsp]
mov r15,QWORD[((-48))+rax]
mov r14,QWORD[((-40))+rax]
mov r13,QWORD[((-32))+rax]
mov r12,QWORD[((-24))+rax]
mov rbp,QWORD[((-16))+rax]
mov rbx,QWORD[((-8))+rax]
lea rsp,[rax]
$L$mul_by_one_epilogue:
mov rdi,QWORD[8+rsp] ;WIN64 epilogue
mov rsi,QWORD[16+rsp]
DB 0F3h,0C3h ;repret
$L$SEH_end_rsaz_512_mul_by_one:
ALIGN 32
__rsaz_512_reduce:
mov rbx,r8
imul rbx,QWORD[((128+8))+rsp]
mov rax,QWORD[rbp]
mov ecx,8
jmp NEAR $L$reduction_loop
ALIGN 32
$L$reduction_loop:
mul rbx
mov rax,QWORD[8+rbp]
neg r8
mov r8,rdx
adc r8,0
mul rbx
add r9,rax
mov rax,QWORD[16+rbp]
adc rdx,0
add r8,r9
mov r9,rdx
adc r9,0
mul rbx
add r10,rax
mov rax,QWORD[24+rbp]
adc rdx,0
add r9,r10
mov r10,rdx
adc r10,0
mul rbx
add r11,rax
mov rax,QWORD[32+rbp]
adc rdx,0
add r10,r11
mov rsi,QWORD[((128+8))+rsp]
adc rdx,0
mov r11,rdx
mul rbx
add r12,rax
mov rax,QWORD[40+rbp]
adc rdx,0
imul rsi,r8
add r11,r12
mov r12,rdx
adc r12,0
mul rbx
add r13,rax
mov rax,QWORD[48+rbp]
adc rdx,0
add r12,r13
mov r13,rdx
adc r13,0
mul rbx
add r14,rax
mov rax,QWORD[56+rbp]
adc rdx,0
add r13,r14
mov r14,rdx
adc r14,0
mul rbx
mov rbx,rsi
add r15,rax
mov rax,QWORD[rbp]
adc rdx,0
add r14,r15
mov r15,rdx
adc r15,0
dec ecx
jne NEAR $L$reduction_loop
DB 0F3h,0C3h ;repret
ALIGN 32
__rsaz_512_reducex:
imul rdx,r8
xor rsi,rsi
mov ecx,8
jmp NEAR $L$reduction_loopx
ALIGN 32
$L$reduction_loopx:
mov rbx,r8
mulx r8,rax,QWORD[rbp]
adcx rax,rbx
adox r8,r9
mulx r9,rax,QWORD[8+rbp]
adcx r8,rax
adox r9,r10
mulx r10,rbx,QWORD[16+rbp]
adcx r9,rbx
adox r10,r11
mulx r11,rbx,QWORD[24+rbp]
adcx r10,rbx
adox r11,r12
DB 0xc4,0x62,0xe3,0xf6,0xa5,0x20,0x00,0x00,0x00
mov rax,rdx
mov rdx,r8
adcx r11,rbx
adox r12,r13
mulx rdx,rbx,QWORD[((128+8))+rsp]
mov rdx,rax
mulx r13,rax,QWORD[40+rbp]
adcx r12,rax
adox r13,r14
DB 0xc4,0x62,0xfb,0xf6,0xb5,0x30,0x00,0x00,0x00
adcx r13,rax
adox r14,r15
mulx r15,rax,QWORD[56+rbp]
mov rdx,rbx
adcx r14,rax
adox r15,rsi
adcx r15,rsi
dec ecx
jne NEAR $L$reduction_loopx
DB 0F3h,0C3h ;repret
ALIGN 32
__rsaz_512_subtract:
mov QWORD[rdi],r8
mov QWORD[8+rdi],r9
mov QWORD[16+rdi],r10
mov QWORD[24+rdi],r11
mov QWORD[32+rdi],r12
mov QWORD[40+rdi],r13
mov QWORD[48+rdi],r14
mov QWORD[56+rdi],r15
mov r8,QWORD[rbp]
mov r9,QWORD[8+rbp]
neg r8
not r9
and r8,rcx
mov r10,QWORD[16+rbp]
and r9,rcx
not r10
mov r11,QWORD[24+rbp]
and r10,rcx
not r11
mov r12,QWORD[32+rbp]
and r11,rcx
not r12
mov r13,QWORD[40+rbp]
and r12,rcx
not r13
mov r14,QWORD[48+rbp]
and r13,rcx
not r14
mov r15,QWORD[56+rbp]
and r14,rcx
not r15
and r15,rcx
add r8,QWORD[rdi]
adc r9,QWORD[8+rdi]
adc r10,QWORD[16+rdi]
adc r11,QWORD[24+rdi]
adc r12,QWORD[32+rdi]
adc r13,QWORD[40+rdi]
adc r14,QWORD[48+rdi]
adc r15,QWORD[56+rdi]
mov QWORD[rdi],r8
mov QWORD[8+rdi],r9
mov QWORD[16+rdi],r10
mov QWORD[24+rdi],r11
mov QWORD[32+rdi],r12
mov QWORD[40+rdi],r13
mov QWORD[48+rdi],r14
mov QWORD[56+rdi],r15
DB 0F3h,0C3h ;repret
ALIGN 32
__rsaz_512_mul:
lea rdi,[8+rsp]
mov rax,QWORD[rsi]
mul rbx
mov QWORD[rdi],rax
mov rax,QWORD[8+rsi]
mov r8,rdx
mul rbx
add r8,rax
mov rax,QWORD[16+rsi]
mov r9,rdx
adc r9,0
mul rbx
add r9,rax
mov rax,QWORD[24+rsi]
mov r10,rdx
adc r10,0
mul rbx
add r10,rax
mov rax,QWORD[32+rsi]
mov r11,rdx
adc r11,0
mul rbx
add r11,rax
mov rax,QWORD[40+rsi]
mov r12,rdx
adc r12,0
mul rbx
add r12,rax
mov rax,QWORD[48+rsi]
mov r13,rdx
adc r13,0
mul rbx
add r13,rax
mov rax,QWORD[56+rsi]
mov r14,rdx
adc r14,0
mul rbx
add r14,rax
mov rax,QWORD[rsi]
mov r15,rdx
adc r15,0
lea rbp,[8+rbp]
lea rdi,[8+rdi]
mov ecx,7
jmp NEAR $L$oop_mul
ALIGN 32
$L$oop_mul:
mov rbx,QWORD[rbp]
mul rbx
add r8,rax
mov rax,QWORD[8+rsi]
mov QWORD[rdi],r8
mov r8,rdx
adc r8,0
mul rbx
add r9,rax
mov rax,QWORD[16+rsi]
adc rdx,0
add r8,r9
mov r9,rdx
adc r9,0
mul rbx
add r10,rax
mov rax,QWORD[24+rsi]
adc rdx,0
add r9,r10
mov r10,rdx
adc r10,0
mul rbx
add r11,rax
mov rax,QWORD[32+rsi]
adc rdx,0
add r10,r11
mov r11,rdx
adc r11,0
mul rbx
add r12,rax
mov rax,QWORD[40+rsi]
adc rdx,0
add r11,r12
mov r12,rdx
adc r12,0
mul rbx
add r13,rax
mov rax,QWORD[48+rsi]
adc rdx,0
add r12,r13
mov r13,rdx
adc r13,0
mul rbx
add r14,rax
mov rax,QWORD[56+rsi]
adc rdx,0
add r13,r14
mov r14,rdx
lea rbp,[8+rbp]
adc r14,0
mul rbx
add r15,rax
mov rax,QWORD[rsi]
adc rdx,0
add r14,r15
mov r15,rdx
adc r15,0
lea rdi,[8+rdi]
dec ecx
jnz NEAR $L$oop_mul
mov QWORD[rdi],r8
mov QWORD[8+rdi],r9
mov QWORD[16+rdi],r10
mov QWORD[24+rdi],r11
mov QWORD[32+rdi],r12
mov QWORD[40+rdi],r13
mov QWORD[48+rdi],r14
mov QWORD[56+rdi],r15
DB 0F3h,0C3h ;repret
ALIGN 32
__rsaz_512_mulx:
mulx r8,rbx,QWORD[rsi]
mov rcx,-6
mulx r9,rax,QWORD[8+rsi]
mov QWORD[8+rsp],rbx
mulx r10,rbx,QWORD[16+rsi]
adc r8,rax
mulx r11,rax,QWORD[24+rsi]
adc r9,rbx
mulx r12,rbx,QWORD[32+rsi]
adc r10,rax
mulx r13,rax,QWORD[40+rsi]
adc r11,rbx
mulx r14,rbx,QWORD[48+rsi]
adc r12,rax
mulx r15,rax,QWORD[56+rsi]
mov rdx,QWORD[8+rbp]
adc r13,rbx
adc r14,rax
adc r15,0
xor rdi,rdi
jmp NEAR $L$oop_mulx
ALIGN 32
$L$oop_mulx:
mov rbx,r8
mulx r8,rax,QWORD[rsi]
adcx rbx,rax
adox r8,r9
mulx r9,rax,QWORD[8+rsi]
adcx r8,rax
adox r9,r10
mulx r10,rax,QWORD[16+rsi]
adcx r9,rax
adox r10,r11
mulx r11,rax,QWORD[24+rsi]
adcx r10,rax
adox r11,r12
DB 0x3e,0xc4,0x62,0xfb,0xf6,0xa6,0x20,0x00,0x00,0x00
adcx r11,rax
adox r12,r13
mulx r13,rax,QWORD[40+rsi]
adcx r12,rax
adox r13,r14
mulx r14,rax,QWORD[48+rsi]
adcx r13,rax
adox r14,r15
mulx r15,rax,QWORD[56+rsi]
mov rdx,QWORD[64+rcx*8+rbp]
mov QWORD[((8+64-8))+rcx*8+rsp],rbx
adcx r14,rax
adox r15,rdi
adcx r15,rdi
inc rcx
jnz NEAR $L$oop_mulx
mov rbx,r8
mulx r8,rax,QWORD[rsi]
adcx rbx,rax
adox r8,r9
DB 0xc4,0x62,0xfb,0xf6,0x8e,0x08,0x00,0x00,0x00
adcx r8,rax
adox r9,r10
DB 0xc4,0x62,0xfb,0xf6,0x96,0x10,0x00,0x00,0x00
adcx r9,rax
adox r10,r11
mulx r11,rax,QWORD[24+rsi]
adcx r10,rax
adox r11,r12
mulx r12,rax,QWORD[32+rsi]
adcx r11,rax
adox r12,r13
mulx r13,rax,QWORD[40+rsi]
adcx r12,rax
adox r13,r14
DB 0xc4,0x62,0xfb,0xf6,0xb6,0x30,0x00,0x00,0x00
adcx r13,rax
adox r14,r15
DB 0xc4,0x62,0xfb,0xf6,0xbe,0x38,0x00,0x00,0x00
adcx r14,rax
adox r15,rdi
adcx r15,rdi
mov QWORD[((8+64-8))+rsp],rbx
mov QWORD[((8+64))+rsp],r8
mov QWORD[((8+64+8))+rsp],r9
mov QWORD[((8+64+16))+rsp],r10
mov QWORD[((8+64+24))+rsp],r11
mov QWORD[((8+64+32))+rsp],r12
mov QWORD[((8+64+40))+rsp],r13
mov QWORD[((8+64+48))+rsp],r14
mov QWORD[((8+64+56))+rsp],r15
DB 0F3h,0C3h ;repret
global rsaz_512_scatter4
ALIGN 16
rsaz_512_scatter4:
lea rcx,[r8*8+rcx]
mov r9d,8
jmp NEAR $L$oop_scatter
ALIGN 16
$L$oop_scatter:
mov rax,QWORD[rdx]
lea rdx,[8+rdx]
mov QWORD[rcx],rax
lea rcx,[128+rcx]
dec r9d
jnz NEAR $L$oop_scatter
DB 0F3h,0C3h ;repret
global rsaz_512_gather4
ALIGN 16
rsaz_512_gather4:
$L$SEH_begin_rsaz_512_gather4:
DB 0x48,0x81,0xec,0xa8,0x00,0x00,0x00
DB 0x0f,0x29,0x34,0x24
DB 0x0f,0x29,0x7c,0x24,0x10
DB 0x44,0x0f,0x29,0x44,0x24,0x20
DB 0x44,0x0f,0x29,0x4c,0x24,0x30
DB 0x44,0x0f,0x29,0x54,0x24,0x40
DB 0x44,0x0f,0x29,0x5c,0x24,0x50
DB 0x44,0x0f,0x29,0x64,0x24,0x60
DB 0x44,0x0f,0x29,0x6c,0x24,0x70
DB 0x44,0x0f,0x29,0xb4,0x24,0x80,0,0,0
DB 0x44,0x0f,0x29,0xbc,0x24,0x90,0,0,0
movd xmm8,r8d
movdqa xmm1,XMMWORD[(($L$inc+16))]
movdqa xmm0,XMMWORD[$L$inc]
pshufd xmm8,xmm8,0
movdqa xmm7,xmm1
movdqa xmm2,xmm1
paddd xmm1,xmm0
pcmpeqd xmm0,xmm8
movdqa xmm3,xmm7
paddd xmm2,xmm1
pcmpeqd xmm1,xmm8
movdqa xmm4,xmm7
paddd xmm3,xmm2
pcmpeqd xmm2,xmm8
movdqa xmm5,xmm7
paddd xmm4,xmm3
pcmpeqd xmm3,xmm8
movdqa xmm6,xmm7
paddd xmm5,xmm4
pcmpeqd xmm4,xmm8
paddd xmm6,xmm5
pcmpeqd xmm5,xmm8
paddd xmm7,xmm6
pcmpeqd xmm6,xmm8
pcmpeqd xmm7,xmm8
mov r9d,8
jmp NEAR $L$oop_gather
ALIGN 16
$L$oop_gather:
movdqa xmm8,XMMWORD[rdx]
movdqa xmm9,XMMWORD[16+rdx]
movdqa xmm10,XMMWORD[32+rdx]
movdqa xmm11,XMMWORD[48+rdx]
pand xmm8,xmm0
movdqa xmm12,XMMWORD[64+rdx]
pand xmm9,xmm1
movdqa xmm13,XMMWORD[80+rdx]
pand xmm10,xmm2
movdqa xmm14,XMMWORD[96+rdx]
pand xmm11,xmm3
movdqa xmm15,XMMWORD[112+rdx]
lea rdx,[128+rdx]
pand xmm12,xmm4
pand xmm13,xmm5
pand xmm14,xmm6
pand xmm15,xmm7
por xmm8,xmm10
por xmm9,xmm11
por xmm8,xmm12
por xmm9,xmm13
por xmm8,xmm14
por xmm9,xmm15
por xmm8,xmm9
pshufd xmm9,xmm8,0x4e
por xmm8,xmm9
movq QWORD[rcx],xmm8
lea rcx,[8+rcx]
dec r9d
jnz NEAR $L$oop_gather
movaps xmm6,XMMWORD[rsp]
movaps xmm7,XMMWORD[16+rsp]
movaps xmm8,XMMWORD[32+rsp]
movaps xmm9,XMMWORD[48+rsp]
movaps xmm10,XMMWORD[64+rsp]
movaps xmm11,XMMWORD[80+rsp]
movaps xmm12,XMMWORD[96+rsp]
movaps xmm13,XMMWORD[112+rsp]
movaps xmm14,XMMWORD[128+rsp]
movaps xmm15,XMMWORD[144+rsp]
add rsp,0xa8
DB 0F3h,0C3h ;repret
$L$SEH_end_rsaz_512_gather4:
ALIGN 64
$L$inc:
DD 0,0,1,1
DD 2,2,2,2
EXTERN __imp_RtlVirtualUnwind
ALIGN 16
se_handler:
push rsi
push rdi
push rbx
push rbp
push r12
push r13
push r14
push r15
pushfq
sub rsp,64
mov rax,QWORD[120+r8]
mov rbx,QWORD[248+r8]
mov rsi,QWORD[8+r9]
mov r11,QWORD[56+r9]
mov r10d,DWORD[r11]
lea r10,[r10*1+rsi]
cmp rbx,r10
jb NEAR $L$common_seh_tail
mov rax,QWORD[152+r8]
mov r10d,DWORD[4+r11]
lea r10,[r10*1+rsi]
cmp rbx,r10
jae NEAR $L$common_seh_tail
lea rax,[((128+24+48))+rax]
lea rbx,[$L$mul_gather4_epilogue]
cmp rbx,r10
jne NEAR $L$se_not_in_mul_gather4
lea rax,[176+rax]
lea rsi,[((-48-168))+rax]
lea rdi,[512+r8]
mov ecx,20
DD 0xa548f3fc
$L$se_not_in_mul_gather4:
mov rbx,QWORD[((-8))+rax]
mov rbp,QWORD[((-16))+rax]
mov r12,QWORD[((-24))+rax]
mov r13,QWORD[((-32))+rax]
mov r14,QWORD[((-40))+rax]
mov r15,QWORD[((-48))+rax]
mov QWORD[144+r8],rbx
mov QWORD[160+r8],rbp
mov QWORD[216+r8],r12
mov QWORD[224+r8],r13
mov QWORD[232+r8],r14
mov QWORD[240+r8],r15
$L$common_seh_tail:
mov rdi,QWORD[8+rax]
mov rsi,QWORD[16+rax]
mov QWORD[152+r8],rax
mov QWORD[168+r8],rsi
mov QWORD[176+r8],rdi
mov rdi,QWORD[40+r9]
mov rsi,r8
mov ecx,154
DD 0xa548f3fc
mov rsi,r9
xor rcx,rcx
mov rdx,QWORD[8+rsi]
mov r8,QWORD[rsi]
mov r9,QWORD[16+rsi]
mov r10,QWORD[40+rsi]
lea r11,[56+rsi]
lea r12,[24+rsi]
mov QWORD[32+rsp],r10
mov QWORD[40+rsp],r11
mov QWORD[48+rsp],r12
mov QWORD[56+rsp],rcx
call QWORD[__imp_RtlVirtualUnwind]
mov eax,1
add rsp,64
popfq
pop r15
pop r14
pop r13
pop r12
pop rbp
pop rbx
pop rdi
pop rsi
DB 0F3h,0C3h ;repret
section .pdata rdata align=4
ALIGN 4
DD $L$SEH_begin_rsaz_512_sqr wrt ..imagebase
DD $L$SEH_end_rsaz_512_sqr wrt ..imagebase
DD $L$SEH_info_rsaz_512_sqr wrt ..imagebase
DD $L$SEH_begin_rsaz_512_mul wrt ..imagebase
DD $L$SEH_end_rsaz_512_mul wrt ..imagebase
DD $L$SEH_info_rsaz_512_mul wrt ..imagebase
DD $L$SEH_begin_rsaz_512_mul_gather4 wrt ..imagebase
DD $L$SEH_end_rsaz_512_mul_gather4 wrt ..imagebase
DD $L$SEH_info_rsaz_512_mul_gather4 wrt ..imagebase
DD $L$SEH_begin_rsaz_512_mul_scatter4 wrt ..imagebase
DD $L$SEH_end_rsaz_512_mul_scatter4 wrt ..imagebase
DD $L$SEH_info_rsaz_512_mul_scatter4 wrt ..imagebase
DD $L$SEH_begin_rsaz_512_mul_by_one wrt ..imagebase
DD $L$SEH_end_rsaz_512_mul_by_one wrt ..imagebase
DD $L$SEH_info_rsaz_512_mul_by_one wrt ..imagebase
DD $L$SEH_begin_rsaz_512_gather4 wrt ..imagebase
DD $L$SEH_end_rsaz_512_gather4 wrt ..imagebase
DD $L$SEH_info_rsaz_512_gather4 wrt ..imagebase
section .xdata rdata align=8
ALIGN 8
$L$SEH_info_rsaz_512_sqr:
DB 9,0,0,0
DD se_handler wrt ..imagebase
DD $L$sqr_body wrt ..imagebase,$L$sqr_epilogue wrt ..imagebase
$L$SEH_info_rsaz_512_mul:
DB 9,0,0,0
DD se_handler wrt ..imagebase
DD $L$mul_body wrt ..imagebase,$L$mul_epilogue wrt ..imagebase
$L$SEH_info_rsaz_512_mul_gather4:
DB 9,0,0,0
DD se_handler wrt ..imagebase
DD $L$mul_gather4_body wrt ..imagebase,$L$mul_gather4_epilogue wrt ..imagebase
$L$SEH_info_rsaz_512_mul_scatter4:
DB 9,0,0,0
DD se_handler wrt ..imagebase
DD $L$mul_scatter4_body wrt ..imagebase,$L$mul_scatter4_epilogue wrt ..imagebase
$L$SEH_info_rsaz_512_mul_by_one:
DB 9,0,0,0
DD se_handler wrt ..imagebase
DD $L$mul_by_one_body wrt ..imagebase,$L$mul_by_one_epilogue wrt ..imagebase
$L$SEH_info_rsaz_512_gather4:
DB 0x01,0x46,0x16,0x00
DB 0x46,0xf8,0x09,0x00
DB 0x3d,0xe8,0x08,0x00
DB 0x34,0xd8,0x07,0x00
DB 0x2e,0xc8,0x06,0x00
DB 0x28,0xb8,0x05,0x00
DB 0x22,0xa8,0x04,0x00
DB 0x1c,0x98,0x03,0x00
DB 0x16,0x88,0x02,0x00
DB 0x10,0x78,0x01,0x00
DB 0x0b,0x68,0x00,0x00
DB 0x07,0x01,0x15,0x00
|
; A239186: Sum of the largest two parts in the partitions of 4n into 4 parts with smallest part equal to 1.
; 2,23,93,243,492,878,1432,2165,3123,4337,5810,7596,9726,12195,15065,18367,22088,26298,31028,36257,42063,48477,55470,63128,71482,80495,90261,100811,112100,124230,137232,151053,165803,181513,198122,215748,234422,254075,274833,296727,319680,343826,369196,395705,423495,452597,482918,514608,547698,582087,617933,655267,693980,734238,776072,819365,864291,910881,959010,1008860,1060462,1113683,1168713,1225583,1284152,1344618,1407012,1471185,1537343,1605517,1675550,1747656,1821866,1898015,1976325,2056827
mov $4,$0
mul $0,2
seq $0,239195 ; Sum of the next to smallest parts in the partitions of 4n into 4 parts with smallest part = 1.
add $0,1
mov $2,$4
mul $2,3
add $0,$2
mov $3,$4
mul $3,$4
mov $2,$3
mul $2,2
add $0,$2
|
SECTION code_clib
SECTION code_fp_math48
PUBLIC am48_double8
EXTERN am48_double16
am48_double8:
; 8-bit integer to double
;
; enter : L = 8-bit integer n
;
; exit : AC = AC' (AC' saved)
; AC'= (double)(n)
;
; uses : af, bc, de, hl, af', bc', de', hl'
ld a,l ; sign extend L into HL
add a,a
sbc a,a
ld h,a
jp am48_double16
|
;
; Z88 Graphics Functions - Small C+ stubs
;
; Written around the Interlogic Standard Library
;
; Trace a relative line in the stencil vectors
;
; Stefano Bodrato - 08/10/2009
;
;
; $Id: w_stencil_add_liner.asm,v 1.3 2016-04-23 20:37:40 dom Exp $
;
;; void stencil_add_liner(int dx, int dy, unsigned char *stencil)
IF !__CPU_INTEL__
SECTION code_graphics
PUBLIC stencil_add_liner
PUBLIC _stencil_add_liner
EXTERN line_r
EXTERN stencil_add_pixel
EXTERN swapgfxbk
EXTERN swapgfxbk1
EXTERN __graphics_end
EXTERN stencil_ptr
.stencil_add_liner
._stencil_add_liner
push ix
ld ix,2
add ix,sp
ld l,(ix+2) ;pointer to stencil
ld h,(ix+3)
ld (stencil_ptr),hl
ld d,(ix+5)
ld e,(ix+4) ;y0
ld h,(ix+7)
ld l,(ix+6) ;x0
call swapgfxbk
ld ix,stencil_add_pixel
call line_r
jp __graphics_end
ENDIF
|
TITLE rc5-586.asm
IF @Version LT 800
ECHO MASM version 8.00 or later is strongly recommended.
ENDIF
.486
.MODEL FLAT
OPTION DOTNAME
IF @Version LT 800
.text$ SEGMENT PAGE 'CODE'
ELSE
.text$ SEGMENT ALIGN(64) 'CODE'
ENDIF
ALIGN 16
_RC5_32_encrypt PROC PUBLIC
$L_RC5_32_encrypt_begin::
;
push ebp
push esi
push edi
mov edx,DWORD PTR 16[esp]
mov ebp,DWORD PTR 20[esp]
; Load the 2 words
mov edi,DWORD PTR [edx]
mov esi,DWORD PTR 4[edx]
push ebx
mov ebx,DWORD PTR [ebp]
add edi,DWORD PTR 4[ebp]
add esi,DWORD PTR 8[ebp]
xor edi,esi
mov eax,DWORD PTR 12[ebp]
mov ecx,esi
rol edi,cl
add edi,eax
xor esi,edi
mov eax,DWORD PTR 16[ebp]
mov ecx,edi
rol esi,cl
add esi,eax
xor edi,esi
mov eax,DWORD PTR 20[ebp]
mov ecx,esi
rol edi,cl
add edi,eax
xor esi,edi
mov eax,DWORD PTR 24[ebp]
mov ecx,edi
rol esi,cl
add esi,eax
xor edi,esi
mov eax,DWORD PTR 28[ebp]
mov ecx,esi
rol edi,cl
add edi,eax
xor esi,edi
mov eax,DWORD PTR 32[ebp]
mov ecx,edi
rol esi,cl
add esi,eax
xor edi,esi
mov eax,DWORD PTR 36[ebp]
mov ecx,esi
rol edi,cl
add edi,eax
xor esi,edi
mov eax,DWORD PTR 40[ebp]
mov ecx,edi
rol esi,cl
add esi,eax
xor edi,esi
mov eax,DWORD PTR 44[ebp]
mov ecx,esi
rol edi,cl
add edi,eax
xor esi,edi
mov eax,DWORD PTR 48[ebp]
mov ecx,edi
rol esi,cl
add esi,eax
xor edi,esi
mov eax,DWORD PTR 52[ebp]
mov ecx,esi
rol edi,cl
add edi,eax
xor esi,edi
mov eax,DWORD PTR 56[ebp]
mov ecx,edi
rol esi,cl
add esi,eax
xor edi,esi
mov eax,DWORD PTR 60[ebp]
mov ecx,esi
rol edi,cl
add edi,eax
xor esi,edi
mov eax,DWORD PTR 64[ebp]
mov ecx,edi
rol esi,cl
add esi,eax
xor edi,esi
mov eax,DWORD PTR 68[ebp]
mov ecx,esi
rol edi,cl
add edi,eax
xor esi,edi
mov eax,DWORD PTR 72[ebp]
mov ecx,edi
rol esi,cl
add esi,eax
cmp ebx,8
je $L000rc5_exit
xor edi,esi
mov eax,DWORD PTR 76[ebp]
mov ecx,esi
rol edi,cl
add edi,eax
xor esi,edi
mov eax,DWORD PTR 80[ebp]
mov ecx,edi
rol esi,cl
add esi,eax
xor edi,esi
mov eax,DWORD PTR 84[ebp]
mov ecx,esi
rol edi,cl
add edi,eax
xor esi,edi
mov eax,DWORD PTR 88[ebp]
mov ecx,edi
rol esi,cl
add esi,eax
xor edi,esi
mov eax,DWORD PTR 92[ebp]
mov ecx,esi
rol edi,cl
add edi,eax
xor esi,edi
mov eax,DWORD PTR 96[ebp]
mov ecx,edi
rol esi,cl
add esi,eax
xor edi,esi
mov eax,DWORD PTR 100[ebp]
mov ecx,esi
rol edi,cl
add edi,eax
xor esi,edi
mov eax,DWORD PTR 104[ebp]
mov ecx,edi
rol esi,cl
add esi,eax
cmp ebx,12
je $L000rc5_exit
xor edi,esi
mov eax,DWORD PTR 108[ebp]
mov ecx,esi
rol edi,cl
add edi,eax
xor esi,edi
mov eax,DWORD PTR 112[ebp]
mov ecx,edi
rol esi,cl
add esi,eax
xor edi,esi
mov eax,DWORD PTR 116[ebp]
mov ecx,esi
rol edi,cl
add edi,eax
xor esi,edi
mov eax,DWORD PTR 120[ebp]
mov ecx,edi
rol esi,cl
add esi,eax
xor edi,esi
mov eax,DWORD PTR 124[ebp]
mov ecx,esi
rol edi,cl
add edi,eax
xor esi,edi
mov eax,DWORD PTR 128[ebp]
mov ecx,edi
rol esi,cl
add esi,eax
xor edi,esi
mov eax,DWORD PTR 132[ebp]
mov ecx,esi
rol edi,cl
add edi,eax
xor esi,edi
mov eax,DWORD PTR 136[ebp]
mov ecx,edi
rol esi,cl
add esi,eax
$L000rc5_exit:
mov DWORD PTR [edx],edi
mov DWORD PTR 4[edx],esi
pop ebx
pop edi
pop esi
pop ebp
ret
_RC5_32_encrypt ENDP
ALIGN 16
_RC5_32_decrypt PROC PUBLIC
$L_RC5_32_decrypt_begin::
;
push ebp
push esi
push edi
mov edx,DWORD PTR 16[esp]
mov ebp,DWORD PTR 20[esp]
; Load the 2 words
mov edi,DWORD PTR [edx]
mov esi,DWORD PTR 4[edx]
push ebx
mov ebx,DWORD PTR [ebp]
cmp ebx,12
je $L001rc5_dec_12
cmp ebx,8
je $L002rc5_dec_8
mov eax,DWORD PTR 136[ebp]
sub esi,eax
mov ecx,edi
ror esi,cl
xor esi,edi
mov eax,DWORD PTR 132[ebp]
sub edi,eax
mov ecx,esi
ror edi,cl
xor edi,esi
mov eax,DWORD PTR 128[ebp]
sub esi,eax
mov ecx,edi
ror esi,cl
xor esi,edi
mov eax,DWORD PTR 124[ebp]
sub edi,eax
mov ecx,esi
ror edi,cl
xor edi,esi
mov eax,DWORD PTR 120[ebp]
sub esi,eax
mov ecx,edi
ror esi,cl
xor esi,edi
mov eax,DWORD PTR 116[ebp]
sub edi,eax
mov ecx,esi
ror edi,cl
xor edi,esi
mov eax,DWORD PTR 112[ebp]
sub esi,eax
mov ecx,edi
ror esi,cl
xor esi,edi
mov eax,DWORD PTR 108[ebp]
sub edi,eax
mov ecx,esi
ror edi,cl
xor edi,esi
$L001rc5_dec_12:
mov eax,DWORD PTR 104[ebp]
sub esi,eax
mov ecx,edi
ror esi,cl
xor esi,edi
mov eax,DWORD PTR 100[ebp]
sub edi,eax
mov ecx,esi
ror edi,cl
xor edi,esi
mov eax,DWORD PTR 96[ebp]
sub esi,eax
mov ecx,edi
ror esi,cl
xor esi,edi
mov eax,DWORD PTR 92[ebp]
sub edi,eax
mov ecx,esi
ror edi,cl
xor edi,esi
mov eax,DWORD PTR 88[ebp]
sub esi,eax
mov ecx,edi
ror esi,cl
xor esi,edi
mov eax,DWORD PTR 84[ebp]
sub edi,eax
mov ecx,esi
ror edi,cl
xor edi,esi
mov eax,DWORD PTR 80[ebp]
sub esi,eax
mov ecx,edi
ror esi,cl
xor esi,edi
mov eax,DWORD PTR 76[ebp]
sub edi,eax
mov ecx,esi
ror edi,cl
xor edi,esi
$L002rc5_dec_8:
mov eax,DWORD PTR 72[ebp]
sub esi,eax
mov ecx,edi
ror esi,cl
xor esi,edi
mov eax,DWORD PTR 68[ebp]
sub edi,eax
mov ecx,esi
ror edi,cl
xor edi,esi
mov eax,DWORD PTR 64[ebp]
sub esi,eax
mov ecx,edi
ror esi,cl
xor esi,edi
mov eax,DWORD PTR 60[ebp]
sub edi,eax
mov ecx,esi
ror edi,cl
xor edi,esi
mov eax,DWORD PTR 56[ebp]
sub esi,eax
mov ecx,edi
ror esi,cl
xor esi,edi
mov eax,DWORD PTR 52[ebp]
sub edi,eax
mov ecx,esi
ror edi,cl
xor edi,esi
mov eax,DWORD PTR 48[ebp]
sub esi,eax
mov ecx,edi
ror esi,cl
xor esi,edi
mov eax,DWORD PTR 44[ebp]
sub edi,eax
mov ecx,esi
ror edi,cl
xor edi,esi
mov eax,DWORD PTR 40[ebp]
sub esi,eax
mov ecx,edi
ror esi,cl
xor esi,edi
mov eax,DWORD PTR 36[ebp]
sub edi,eax
mov ecx,esi
ror edi,cl
xor edi,esi
mov eax,DWORD PTR 32[ebp]
sub esi,eax
mov ecx,edi
ror esi,cl
xor esi,edi
mov eax,DWORD PTR 28[ebp]
sub edi,eax
mov ecx,esi
ror edi,cl
xor edi,esi
mov eax,DWORD PTR 24[ebp]
sub esi,eax
mov ecx,edi
ror esi,cl
xor esi,edi
mov eax,DWORD PTR 20[ebp]
sub edi,eax
mov ecx,esi
ror edi,cl
xor edi,esi
mov eax,DWORD PTR 16[ebp]
sub esi,eax
mov ecx,edi
ror esi,cl
xor esi,edi
mov eax,DWORD PTR 12[ebp]
sub edi,eax
mov ecx,esi
ror edi,cl
xor edi,esi
sub esi,DWORD PTR 8[ebp]
sub edi,DWORD PTR 4[ebp]
$L003rc5_exit:
mov DWORD PTR [edx],edi
mov DWORD PTR 4[edx],esi
pop ebx
pop edi
pop esi
pop ebp
ret
_RC5_32_decrypt ENDP
ALIGN 16
_RC5_32_cbc_encrypt PROC PUBLIC
$L_RC5_32_cbc_encrypt_begin::
;
push ebp
push ebx
push esi
push edi
mov ebp,DWORD PTR 28[esp]
; getting iv ptr from parameter 4
mov ebx,DWORD PTR 36[esp]
mov esi,DWORD PTR [ebx]
mov edi,DWORD PTR 4[ebx]
push edi
push esi
push edi
push esi
mov ebx,esp
mov esi,DWORD PTR 36[esp]
mov edi,DWORD PTR 40[esp]
; getting encrypt flag from parameter 5
mov ecx,DWORD PTR 56[esp]
; get and push parameter 3
mov eax,DWORD PTR 48[esp]
push eax
push ebx
cmp ecx,0
jz $L004decrypt
and ebp,4294967288
mov eax,DWORD PTR 8[esp]
mov ebx,DWORD PTR 12[esp]
jz $L005encrypt_finish
$L006encrypt_loop:
mov ecx,DWORD PTR [esi]
mov edx,DWORD PTR 4[esi]
xor eax,ecx
xor ebx,edx
mov DWORD PTR 8[esp],eax
mov DWORD PTR 12[esp],ebx
call $L_RC5_32_encrypt_begin
mov eax,DWORD PTR 8[esp]
mov ebx,DWORD PTR 12[esp]
mov DWORD PTR [edi],eax
mov DWORD PTR 4[edi],ebx
add esi,8
add edi,8
sub ebp,8
jnz $L006encrypt_loop
$L005encrypt_finish:
mov ebp,DWORD PTR 52[esp]
and ebp,7
jz $L007finish
call $L008PIC_point
$L008PIC_point:
pop edx
lea ecx,DWORD PTR ($L009cbc_enc_jmp_table-$L008PIC_point)[edx]
mov ebp,DWORD PTR [ebp*4+ecx]
add ebp,edx
xor ecx,ecx
xor edx,edx
jmp ebp
$L010ej7:
mov dh,BYTE PTR 6[esi]
shl edx,8
$L011ej6:
mov dh,BYTE PTR 5[esi]
$L012ej5:
mov dl,BYTE PTR 4[esi]
$L013ej4:
mov ecx,DWORD PTR [esi]
jmp $L014ejend
$L015ej3:
mov ch,BYTE PTR 2[esi]
shl ecx,8
$L016ej2:
mov ch,BYTE PTR 1[esi]
$L017ej1:
mov cl,BYTE PTR [esi]
$L014ejend:
xor eax,ecx
xor ebx,edx
mov DWORD PTR 8[esp],eax
mov DWORD PTR 12[esp],ebx
call $L_RC5_32_encrypt_begin
mov eax,DWORD PTR 8[esp]
mov ebx,DWORD PTR 12[esp]
mov DWORD PTR [edi],eax
mov DWORD PTR 4[edi],ebx
jmp $L007finish
$L004decrypt:
and ebp,4294967288
mov eax,DWORD PTR 16[esp]
mov ebx,DWORD PTR 20[esp]
jz $L018decrypt_finish
$L019decrypt_loop:
mov eax,DWORD PTR [esi]
mov ebx,DWORD PTR 4[esi]
mov DWORD PTR 8[esp],eax
mov DWORD PTR 12[esp],ebx
call $L_RC5_32_decrypt_begin
mov eax,DWORD PTR 8[esp]
mov ebx,DWORD PTR 12[esp]
mov ecx,DWORD PTR 16[esp]
mov edx,DWORD PTR 20[esp]
xor ecx,eax
xor edx,ebx
mov eax,DWORD PTR [esi]
mov ebx,DWORD PTR 4[esi]
mov DWORD PTR [edi],ecx
mov DWORD PTR 4[edi],edx
mov DWORD PTR 16[esp],eax
mov DWORD PTR 20[esp],ebx
add esi,8
add edi,8
sub ebp,8
jnz $L019decrypt_loop
$L018decrypt_finish:
mov ebp,DWORD PTR 52[esp]
and ebp,7
jz $L007finish
mov eax,DWORD PTR [esi]
mov ebx,DWORD PTR 4[esi]
mov DWORD PTR 8[esp],eax
mov DWORD PTR 12[esp],ebx
call $L_RC5_32_decrypt_begin
mov eax,DWORD PTR 8[esp]
mov ebx,DWORD PTR 12[esp]
mov ecx,DWORD PTR 16[esp]
mov edx,DWORD PTR 20[esp]
xor ecx,eax
xor edx,ebx
mov eax,DWORD PTR [esi]
mov ebx,DWORD PTR 4[esi]
$L020dj7:
ror edx,16
mov BYTE PTR 6[edi],dl
shr edx,16
$L021dj6:
mov BYTE PTR 5[edi],dh
$L022dj5:
mov BYTE PTR 4[edi],dl
$L023dj4:
mov DWORD PTR [edi],ecx
jmp $L024djend
$L025dj3:
ror ecx,16
mov BYTE PTR 2[edi],cl
shl ecx,16
$L026dj2:
mov BYTE PTR 1[esi],ch
$L027dj1:
mov BYTE PTR [esi],cl
$L024djend:
jmp $L007finish
$L007finish:
mov ecx,DWORD PTR 60[esp]
add esp,24
mov DWORD PTR [ecx],eax
mov DWORD PTR 4[ecx],ebx
pop edi
pop esi
pop ebx
pop ebp
ret
ALIGN 64
$L009cbc_enc_jmp_table:
DD 0
DD $L017ej1-$L008PIC_point
DD $L016ej2-$L008PIC_point
DD $L015ej3-$L008PIC_point
DD $L013ej4-$L008PIC_point
DD $L012ej5-$L008PIC_point
DD $L011ej6-$L008PIC_point
DD $L010ej7-$L008PIC_point
ALIGN 64
_RC5_32_cbc_encrypt ENDP
.text$ ENDS
END
|
; https://wiki.osdev.org/Babystep2
; Writing a string message using the BIOS calls.
; Set cursor to the beginning of the screen.
; Initialize the address of the message.
; BIOS loads the boot sector at 0x07C0
; More info: https://www.glamenv-septzen.net/en/view/6
mov ax, 0x7C0
mov ds, ax ; segment of the string
mov si, msg ; offset of the string
call bios_print ; call the procedure
; after call the execution continues below to hang label
hang:
jmp hang ; infinite loop
bios_print:
; https://en.wikipedia.org/wiki/INT_10H
; http://vitaly_filatov.tripod.com/ng/asm/asm_023.15.html
; BIOS interrupt 0x10 with method 0x0E - teletype output:
; print character of a string while interpreting some characters
mov ah, 0x02 ; set cursor
mov bh, 0 ; page number
mov dh, 0 ; row
mov dl, 0 ; column
int 0x10 ; call the BIOS interrupt
print_char:
lodsb ; load a byte of string from DS:SI address to AL
cmp al, 0 ; set zero flag when AL = 0 (end of string)
je done ; jump to label "done" when zero flag is set
mov ah, 0x0E ; teletype output
mov bh, 0 ; display page number (active page, there might be other pages...)
int 0x10 ; call the BIOS interrupt
jmp print_char
done:
ret ; return from the procedure
; data: message + \r\n\0 - zero-terminated string
msg:
db 'baby 02 - procedure', 13, 10, 'Hello, world!', 13, 10, 0
; padding with boot signature
times 512 - 2 - ($-$$) db 0
db 0x55
db 0xAA
|
; A255993: Number of length n+2 0..1 arrays with at most one downstep in every n consecutive neighbor pairs.
; 8,16,28,45,68,98,136,183,240,308,388,481,588,710,848,1003,1176,1368,1580,1813,2068,2346,2648,2975,3328,3708,4116,4553,5020,5518,6048,6611,7208,7840,8508,9213,9956,10738,11560,12423,13328,14276,15268,16305,17388,18518,19696,20923,22200,23528,24908,26341,27828,29370,30968,32623,34336,36108,37940,39833,41788,43806,45888,48035,50248,52528,54876,57293,59780,62338,64968,67671,70448,73300,76228,79233,82316,85478,88720,92043,95448,98936,102508,106165,109908,113738,117656,121663,125760,129948,134228
add $0,4
mov $1,$0
bin $0,3
add $0,$1
add $0,$1
sub $0,4
|
.global s_prepare_buffers
s_prepare_buffers:
push %r11
push %r13
push %r14
push %r9
push %rax
push %rbx
push %rcx
push %rdi
push %rdx
push %rsi
lea addresses_A_ht+0x3d14, %rbx
clflush (%rbx)
nop
nop
nop
cmp %rax, %rax
vmovups (%rbx), %ymm0
vextracti128 $0, %ymm0, %xmm0
vpextrq $1, %xmm0, %r11
nop
nop
nop
nop
nop
cmp %r9, %r9
lea addresses_WT_ht+0x19ccd, %r14
nop
sub %rbx, %rbx
movw $0x6162, (%r14)
nop
nop
nop
nop
nop
and %r14, %r14
lea addresses_UC_ht+0xa84d, %r11
nop
nop
nop
nop
xor $3297, %r13
mov (%r11), %r9
nop
nop
nop
nop
nop
dec %rdx
lea addresses_normal_ht+0x10ecd, %r9
nop
nop
nop
nop
inc %r11
mov $0x6162636465666768, %r14
movq %r14, %xmm5
movups %xmm5, (%r9)
nop
nop
nop
and %rdx, %rdx
lea addresses_UC_ht+0x162cd, %rdx
nop
nop
nop
nop
nop
cmp %rax, %rax
mov $0x6162636465666768, %r14
movq %r14, %xmm1
vmovups %ymm1, (%rdx)
nop
nop
nop
nop
nop
xor $51059, %r14
lea addresses_normal_ht+0x4fc9, %r13
cmp %r9, %r9
mov (%r13), %edx
nop
xor %rbx, %rbx
lea addresses_D_ht+0xa88d, %r9
clflush (%r9)
inc %rdx
mov (%r9), %r13w
nop
nop
cmp $20157, %r9
lea addresses_normal_ht+0x21cd, %rbx
nop
nop
nop
nop
nop
dec %r13
mov (%rbx), %r11d
add $17834, %rax
lea addresses_D_ht+0x144cd, %r14
nop
nop
nop
and %r13, %r13
mov (%r14), %r9w
nop
xor $20616, %rax
lea addresses_WC_ht+0xaa1d, %rsi
lea addresses_A_ht+0x1073f, %rdi
nop
lfence
mov $83, %rcx
rep movsw
nop
nop
nop
nop
nop
xor $25525, %rbx
lea addresses_D_ht+0x1175d, %rcx
nop
nop
nop
nop
nop
sub $64845, %r11
movl $0x61626364, (%rcx)
nop
nop
add %rsi, %rsi
lea addresses_A_ht+0x194cd, %r14
nop
nop
xor %rax, %rax
movb (%r14), %r11b
nop
nop
nop
nop
add %rcx, %rcx
pop %rsi
pop %rdx
pop %rdi
pop %rcx
pop %rbx
pop %rax
pop %r9
pop %r14
pop %r13
pop %r11
ret
.global s_faulty_load
s_faulty_load:
push %r12
push %r14
push %r9
push %rdi
push %rdx
push %rsi
// Store
lea addresses_D+0x73b5, %r14
nop
nop
nop
nop
sub %r12, %r12
mov $0x5152535455565758, %rdx
movq %rdx, %xmm2
vmovups %ymm2, (%r14)
nop
nop
nop
nop
cmp $44631, %r12
// Faulty Load
lea addresses_D+0x1f4cd, %r12
nop
nop
nop
xor %rsi, %rsi
mov (%r12), %r9d
lea oracles, %r14
and $0xff, %r9
shlq $12, %r9
mov (%r14,%r9,1), %r9
pop %rsi
pop %rdx
pop %rdi
pop %r9
pop %r14
pop %r12
ret
/*
<gen_faulty_load>
[REF]
{'src': {'congruent': 0, 'AVXalign': False, 'same': False, 'size': 4, 'NT': False, 'type': 'addresses_D'}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'congruent': 3, 'AVXalign': False, 'same': False, 'size': 32, 'NT': False, 'type': 'addresses_D'}}
[Faulty Load]
{'src': {'congruent': 0, 'AVXalign': False, 'same': True, 'size': 4, 'NT': False, 'type': 'addresses_D'}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'src': {'congruent': 0, 'AVXalign': False, 'same': False, 'size': 32, 'NT': False, 'type': 'addresses_A_ht'}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'congruent': 9, 'AVXalign': False, 'same': False, 'size': 2, 'NT': False, 'type': 'addresses_WT_ht'}}
{'src': {'congruent': 6, 'AVXalign': False, 'same': False, 'size': 8, 'NT': False, 'type': 'addresses_UC_ht'}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'congruent': 9, 'AVXalign': False, 'same': False, 'size': 16, 'NT': False, 'type': 'addresses_normal_ht'}}
{'OP': 'STOR', 'dst': {'congruent': 9, 'AVXalign': False, 'same': False, 'size': 32, 'NT': False, 'type': 'addresses_UC_ht'}}
{'src': {'congruent': 1, 'AVXalign': False, 'same': False, 'size': 4, 'NT': False, 'type': 'addresses_normal_ht'}, 'OP': 'LOAD'}
{'src': {'congruent': 6, 'AVXalign': False, 'same': False, 'size': 2, 'NT': False, 'type': 'addresses_D_ht'}, 'OP': 'LOAD'}
{'src': {'congruent': 8, 'AVXalign': True, 'same': False, 'size': 4, 'NT': True, 'type': 'addresses_normal_ht'}, 'OP': 'LOAD'}
{'src': {'congruent': 9, 'AVXalign': False, 'same': False, 'size': 2, 'NT': False, 'type': 'addresses_D_ht'}, 'OP': 'LOAD'}
{'src': {'congruent': 1, 'same': False, 'type': 'addresses_WC_ht'}, 'OP': 'REPM', 'dst': {'congruent': 0, 'same': False, 'type': 'addresses_A_ht'}}
{'OP': 'STOR', 'dst': {'congruent': 4, 'AVXalign': False, 'same': False, 'size': 4, 'NT': False, 'type': 'addresses_D_ht'}}
{'src': {'congruent': 8, 'AVXalign': False, 'same': False, 'size': 1, 'NT': False, 'type': 'addresses_A_ht'}, 'OP': 'LOAD'}
{'36': 21829}
36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36
*/
|
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 28
rst 28
rst 30
rst 30
rst 38
rst 38
rst 38
rst 38
cp $fe
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
ld e, a
ld e, a
xor e
xor e
push de
push de
ld a, [$fffa]
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
ld d, l
ld d, l
xor d
xor d
ld d, l
ld d, l
ld a, [$fdfa]
<error>
cp $fe
rst 38
rst 38
ld a, [$55fa]
ld d, l
xor e
xor e
ld e, a
ld e, a
rst 38
rst 38
ld e, a
ld e, a
xor d
xor d
ld d, l
ld d, l
xor d
xor d
ld d, l
ld d, l
xor d
xor d
push de
push de
cp $fe
push af
push af
xor e
xor e
ld d, a
ld d, a
rst 38
rst 38
ld e, l
ld e, l
xor d
xor d
ld d, l
ld d, l
cp e
cp e
ld a, l
ld a, l
cp $fe
rst 18
rst 18
xor e
xor e
ld d, l
ld d, l
xor d
xor d
ld e, l
ld e, l
ld [$d5ea], a
push de
xor d
xor d
ld d, l
ld d, l
xor d
xor d
ld d, l
ld d, l
ldi a, [hl]
ldi a, [hl]
dec b
dec b
ld a, [$7ffa]
ld a, a
xor a
xor a
ld d, l
ld d, l
xor d
xor d
ld d, l
ld d, l
xor d
xor d
ld d, b
ld d, b
xor e
xor e
<error>
<error>
ld [$55ea], a
ld d, l
xor d
xor d
ld d, l
ld d, l
ld a, [bc]
ld a, [bc]
nop
nop
xor a
xor a
ld d, l
ld d, l
xor d
xor d
ld d, l
ld d, l
xor d
xor d
ld d, l
ld d, l
xor d
xor d
ld d, b
ld d, b
rst 38
rst 38
ccf
ccf
rr a
rr a
inc bc
inc bc
add a, b
add a, b
ldh a, [$ff00 + $f0]
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 20
rst 20
rr a
rr a
rst 38
rst 38
<error>
<error>
ldh a, [$ff00 + $f0]
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 8
rst 8
rlc a
rlc a
inc bc
inc bc
ld bc, $ff01
rst 38
<error>
<error>
ldh a, [$ff00 + $f0]
add a, h
add a, h
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
nop
rst 28
stop
stop
rst 28
add a, b
ld a, a
nop
di
nop
ret nz
ldh a, [$ff00 + $00]
inc a
nop
ret nz
ccf
rlc a
ldhl sp, d
ld a, a
add a, b
cp $01
ccf
ret nz
rrc a
ldh a, [$ff00 + $00]
rrc a
rr a
nop
ld a, a
add a, b
ld c, $f1
ldh a, [$ff00 + $0f]
inc bc
<error>
sbc a, a
ld h, b
rst 38
nop
rr a
ldh [$ff00 + $3e], a
ld bc, $38c7
ld bc, $3cfe
jp .l_00ff
rst 38
nop
cp $01
ldh a, [$ff00 + $0f]
ld bc, $1cf8
nop
rlc a
nop
ld e, $00
ld h, b
nop
nop
nop
rlc a
nop
rst 38
nop
rst 38
ccf
jr c, 0.l_0152
ldh [$ff00 + $00], a
inc bc
nop
ld c, $00
inc a
inc c
rst 38
ccf
rst 38
rst 38
rst 38
rst 38
nop
nop
ld [hl], b
nop
<error>
nop
rst 38
nop
ccf
nop
inc bc
nop
ldh [$ff00 + $e0], a
rst 38
rst 38
nop
nop
nop
nop
nop
nop
add a, b
nop
<error>
nop
pop hl
nop
rr a
nop
cp $00
rst 38
rst 38
cp $fe
ldh [$ff00 + $e0], a
nop
nop
nop
nop
add a, e
add a, e
rst 38
rst 38
rst 38
rst 38
jp .l_0ec3
ld c, $30
jr nc, 0.l_0197
nop
ld [hl], b
ld [hl], b
<error>
<error>
rst 38
rst 38
rst 38
rst 38
add a, b
add a, b
ldh [$ff00 + $e0], a
ld a, [hl]
ld a, [hl]
ld a, a
ld a, a
ccf
ccf
rrc a
rrc a
rlc a
rlc a
pop hl
pop hl
ld a, a
ld a, a
rrc a
rrc a
nop
nop
add a, b
add a, b
cp $fe
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
ldhl sp, d
ldhl sp, d
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
inc bc
inc bc
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
cp a
ccf
rst 18
rr a
ld l, a
adc a, a
scf
rst 0
dec de
<error>
add hl, bc
pop af
dec c
pop af
ld b, $f8
ld b, $f8
rlc a
ldhl sp, d
rlc a
ldhl sp, d
rlc a
ldhl sp, d
rrc a
ldh a, [$ff00 + $0f]
pop af
rr a
pop hl
ld a, $c2
rst 38
cp $fd
<error>
rst 38
<error>
ei
ldhl sp, d
rst 38
ldhl sp, d
rst 30
ldh a, [$ff00 + $ff]
ldh a, [$ff00 + $ee]
ldh [$ff00 + $ff], a
nop
rst 38
nop
and $00
add a, $00
add a, $00
adc a, $00
ld a, h
nop
ld a, b
nop
rlc a
nop
ld c, $00
ld e, $00
inc e
nop
ld a, b
nop
ldh [$ff00 + $00], a
pop bc
ld bc, $03c3
nop
nop
nop
nop
ld sp, $3131
ld sp, $3333
rst 30
rst 30
rst 20
rst 20
jp .l_ffc3
rst 38
rst 38
rst 38
rst 38
rst 38
rst 8
rst 8
adc a, a
adc a, a
adc a, a
adc a, a
rrc a
rrc a
rrc a
rrc a
ld a, [$d0e5]
rst 8
<error>
pop bc
rst 28
rst 8
rst 38
rst 38
<error>
<error>
rst 30
ldh a, [$ff00 + $fe]
ldh [$ff00 + $3f], a
pop bc
nop
rst 38
ld sp, hl
ldhl sp, d
rst 38
rst 38
rst 38
rst 38
inc bc
inc bc
ld a, b
nop
ld a, b
nop
di
ret nz
di
nop
ld [hl], $c0
sbc a, [hl]
add a, b
ldhl sp, d
ldhl sp, d
cp $fe
ccf
ccf
rst 0
rlc a
nop
nop
ld e, $1e
dec sp
inc hl
dec sp
inc hl
inc hl
inc hl
ld e, $1e
adc a, [hl]
adc a, [hl]
<error>
<error>
rst 38
rst 38
cp a
cp a
sbc a, a
sbc a, a
rr a
rr a
ccf
ccf
ld a, a
ld a, a
rst 28
adc a, a
rst 28
adc a, a
ldhl sp, d
ldhl sp, d
ldhl sp, d
ldhl sp, d
ld a, l
ld a, l
ccf
ccf
dec e
inc e
ccf
jr c, 0.l_0324
ld [hl], b
ld a, a
ld [hl], b
adc a, a
adc a, a
rst 38
rst 38
ei
ei
di
sub a, e
rst 30
scf
cp a
ccf
rst 38
ld a, a
cp a
ccf
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
add a, a
cp a
cp a
rst 18
sbc a, a
xor a
rst 8
sub a, a
rst 20
dec bc
ld [hl], e
rrc a
ld [hl], e
dec b
ld sp, hl
rlc a
ld sp, hl
cp $03
<error>
dec b
ldhl sp, d
dec bc
ldh a, [$ff00 + $37]
ret nz
rst 8
add a, c
ld a, [hl]
and $19
ldhl sp, d
rlc a
ld [bc], a
<error>
inc bc
<error>
inc bc
<error>
inc bc
<error>
rlc a
ldhl sp, d
ld b, $f8
rrc a
pop af
ld a, [hl]
add a, d
<error>
ldh [$ff00 + $d8], a
ret nz
ld sp, hl
ret nz
cp c
add a, b
or e
add a, b
di
add a, b
ld a, a
nop
rst 38
nop
ldh a, [$ff00 + $00]
pop af
nop
di
nop
rst 20
nop
add a, a
nop
rlc a
nop
ld b, $00
ld b, $00
jp .l_c003
nop
jp nz, .l_c602
ld b, $86
ld b, $0e
ld c, $1c
inc e
jr 0.l_0348
add a, e
add a, e
inc bc
inc bc
rlc a
rlc a
rrc a
rrc a
ld c, $0e
inc a
inc a
ld a, h
ld a, h
ld a, l
ld a, l
rr a
rr a
ccf
ccf
ld a, a
ld a, a
rst 30
rst 30
rst 30
rst 30
rst 28
rst 28
rst 38
rst 38
rst 38
rst 38
cp a
cp a
rst 18
sbc a, a
xor a
rst 8
sub a, a
rst 20
sbc a, a
rst 20
dec bc
ld [hl], e
rrc a
di
dec b
ld sp, hl
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
cp $fe
rst 38
cp $fd
<error>
<error>
<error>
ei
ldhl sp, d
rst 38
ldhl sp, d
rst 30
add a, h
adc a, a
ld [hl], h
ld a, $38
rlc a
ld sp, hl
rlc a
ld sp, hl
rlc a
ld sp, hl
ld b, $f8
ld c, $f2
ld a, $c3
<error>
dec b
ldhl sp, d
dec de
nop
nop
ld bc, $3701
ld [hl], $3f
jr c, 0.l_03d8
jr nc, 0.l_037a
ret nc
rst 38
ldh [$ff00 + $bf], a
and b
rr a
stop
rst 38
ldhl sp, d
rst 38
ld b, $ff
ld bc, $00ff
ldh [$ff00 + $1f], a
<error>
inc bc
cp $01
rst 18
rr a
rst 30
rlc a
ld sp, hl
ld bc, $80ff
rst 38
nop
rst 38
nop
ccf
ret nz
nop
rst 38
ldh a, [$ff00 + $f0]
call c, func_e0c3
sbc a, a
ldhl sp, d
ld a, a
and $07
<error>
ld bc, $c03e
rst 38
stop
nop
cp $40
ccf
stop
rst 8
ld [$00f7], sp
rst 38
nop
rst 38
add a, b
rst 38
ld b, b
ld a, a
add a, c
add a, c
ld l, [hl]
ldh [$ff00 + $13], a
ldh a, [$ff00 + $08]
ldhl sp, d
inc b
<error>
ld b, $fa
add a, b
ld a, h
ld b, c
cp a
rst 38
rst 38
ld a, a
ld a, a
sbc a, b
jr 0.l_03c3
inc c
ld h, h
inc b
ldd [hl], a
ld [bc], a
stop
nop
ld bc, $f001
ldh a, [$ff00 + $00]
nop
rrc a
nop
ld a, a
nop
rst 38
nop
ccf
nop
inc e
nop
nop
nop
rr a
rr a
rlc a
rlc a
pop hl
ld bc, $00f0
ldh a, [$ff00 + $00]
add a, b
nop
nop
nop
nop
nop
<error>
ei
rst 38
ldh a, [$ff00 + $ff]
rst 38
<error>
<error>
ldh a, [$ff00 + $ef]
rst 18
ret nz
rst 18
rst 18
ld h, b
ld e, a
inc e
add sp, d
call nz, func_ff3c
ldh [c], a
ld a, e
sub a, d
rr a
<error>
rst 30
inc b
adc a, a
adc a, b
rst 38
ld [hl], b
ldh a, [$ff00 + $60]
or c
jr nc, 0.l_0430
jr z, 0.l_04be
and h
ld l, e
or d
rst 0
dec de
rst 0
ld e, e
add a, a
cp c
rst 38
jp .l_4c7f
ld a, a
ld d, b
ld a, a
ld d, b
ld a, a
ld h, b
ld a, a
ld h, b
ld a, a
ld h, b
ld a, a
ld b, b
ldhl sp, d
add a, a
pop hl
ld e, $c7
jr c, 0.l_0436
jr nc, 0.l_0428
ld b, b
cp a
ld b, b
<error>
nop
ldh a, [$ff00 + $00]
jr c, 0.l_0439
pop hl
ld e, $c3
inc a
rst 0
jr c, 0.l_0400
ld a, b
adc a, a
ld [hl], b
rst 8
jr nc, 0.l_044e
jr nc, 0.l_0480
inc c
cp a
ld b, e
cp a
ld b, b
rr a
ldh [$ff00 + $07], a
ldhl sp, d
nop
rst 38
nop
rst 38
add a, b
ld a, a
ccf
ccf
rst 38
ret nz
rst 38
nop
rst 38
nop
pop af
ld c, $07
ldhl sp, d
rr a
ldh [$ff00 + $3f], a
ret nz
pop bc
sbc a, a
ldh [$ff00 + $6f], a
ldhl sp, d
rr a
<error>
rlc a
cp $03
cp $03
rst 38
ld bc, $0fef
nop
nop
add a, b
add a, b
add a, b
add a, b
ld b, b
ret nz
ld b, b
ret nz
jr nz, 0.l_049c
jr nz, 0.l_049e
stop
ldh a, [$ff00 + $00]
nop
nop
nop
nop
nop
nop
nop
ld [bc], a
ld [bc], a
ld [bc], a
ld [bc], a
inc bc
inc bc
inc bc
inc bc
nop
nop
nop
nop
inc bc
inc bc
rrc a
rrc a
ccf
ccf
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
nop
rst 38
nop
ld a, $00
ldhl sp, d
ldhl sp, d
rst 20
ldh [$ff00 + $f1], a
ldh a, [$ff00 + $fc]
<error>
rst 38
rst 38
<error>
dec b
ldhl sp, d
dec de
ret nz
rst 8
jp nz, .l_f83d
rlc a
<error>
ld [bc], a
ld a, a
nop
sbc a, a
add a, b
and b
ccf
ld e, a
sub a, b
jr z, 0.l_04ce
ccf
rst 8
rl a
and $1d
push hl
ld e, $e4
dec e
and $7f
and b
cp a
jr nz, 0.l_055b
ld b, b
add a, [hl]
add a, b
add a, $00
adc a, $00
<error>
add a, b
ld a, b
ld b, b
rst 38
ret nz
rst 38
ret nz
rst 38
ret nz
rst 38
ret nz
rst 18
ret nz
rst 18
ret nz
ld l, a
ld h, b
inc l
jr nz, 0.l_0511
nop
ret nz
nop
pop bc
ld bc, $0181
add a, e
inc bc
add a, e
inc bc
rlc a
rlc a
ld b, $06
rst 28
stop
ld a, a
nop
ld a, a
nop
ld a, a
nop
ccf
inc b
cp l
add a, h
sbc a, h
add a, h
adc a, $c2
add a, b
ld a, a
ret nz
ccf
ldh a, [$ff00 + $0f]
<error>
inc bc
rst 38
nop
rst 38
nop
rst 38
nop
ccf
nop
ld a, a
add a, b
rrc a
ldh a, [$ff00 + $1f]
ldh [$ff00 + $07], a
ldhl sp, d
add a, c
ld a, [hl]
rst 38
nop
rst 38
nop
rst 38
nop
cp c
ld [hl], $fc
ld e, $fe
rlc a
rst 38
inc bc
<error>
dec e
rst 38
ld [$06fd], sp
<error>
dec b
stop
ldh a, [$ff00 + $88]
ld l, b
ld [$0878], sp
ld a, b
ld [$8438], sp
inc [hl]
call z, func_cc14
call nc, func_0707
rlc a
rlc a
rlc a
rlc a
rrc a
rrc a
rrc a
rrc a
rr a
rr a
rr a
rr a
ccf
ccf
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 8
rst 8
adc a, a
adc a, a
adc a, a
adc a, a
adc a, a
adc a, a
ld e, e
ld e, b
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
pop hl
pop hl
ret nz
ret nz
add a, b
add a, b
nop
nop
rst 38
rst 38
rst 20
ldh [$ff00 + $f1], a
ldh a, [$ff00 + $fc]
<error>
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
nop
rrc a
push hl
ld a, [de]
ldhl sp, d
rlc a
ld a, a
nop
ld e, $00
cp $fe
rst 28
ldh [$ff00 + $f3], a
ldh a, [$ff00 + $19]
ldh [c], a
jr c, 0.l_05af
ldh a, [$ff00 + $17]
ldh [$ff00 + $2f], a
ret nz
rst 18
ld [$b1f7], sp
ld c, [hl]
rst 20
jr 0.l_0615
jr nz, 0.l_0624
ld sp, $7c7c
or $f6
rst 30
rst 30
rst 28
rst 28
rst 38
rst 38
rst 38
rst 38
dec b
dec b
dec b
dec b
add a, h
add a, h
add a, d
add a, d
jp nz, .l_f1c2
pop af
rst 28
rst 28
rst 28
<error>
jp .l_60c1
ld h, b
jr nc, 0.l_0646
cp $7e
ei
ld c, e
cp a
jr z, 0.l_05bc
ld l, b
rst 30
nop
rlc a
nop
add a, b
add a, b
ld h, b
ld h, b
ccf
ccf
rst 30
rst 30
inc a
inc a
ld a, [hl]
halt
or l
sub a, a
rst 38
nop
ld a, $00
ld bc, $e301
ldh [c], a
sub a, $d5
ld l, h
ld c, a
inc [hl]
ld h, $33
inc hl
<error>
inc c
ld l, b
ld h, a
ret nz
cp [hl]
dec l
pop bc
dec de
add a, [hl]
ld de, $d700
call nz, func_0d0d
call c, func_9f44
add a, e
rst 18
add a, e
rst 28
inc bc
rst 28
inc bc
<error>
inc bc
rst 28
rlc a
rst 38
rst 38
rst 38
rst 38
rst 8
rst 8
rst 0
rst 0
jp .l_e1c3
pop hl
ld h, b
ld h, b
nop
nop
nop
nop
ldh [$ff00 + $e0], a
ldhl sp, d
ldhl sp, d
rst 38
rst 38
ei
ld sp, hl
ei
ldhl sp, d
<error>
<error>
ld a, $3e
rrc a
rrc a
<error>
<error>
rst 38
rst 38
<error>
<error>
ei
ldhl sp, d
ei
ldhl sp, d
rst 30
ldh a, [$ff00 + $f7]
ldh a, [$ff00 + $ee]
ldh [$ff00 + $7f], a
inc bc
<error>
<error>
sbc a, a
add a, b
rst 20
ld h, b
sbc a, c
jr 0.l_069a
rrc a
ld [hl], d
ld [bc], a
ld [hl], c
ld bc, $7d03
daa
reti
rst 8
ld sp, $02fe
<error>
dec b
ld sp, hl
cp $7e
ld bc, $809f
and b
jr nz, 0.l_0703
sub a, b
add hl, sp
reti
dec a
call func_eb1b
dec e
jp [hl]
ldd a, [hl]
call z, func_16f1
rst 28
push hl
rst 10
add a, $de
set 3, [hl]
set 3, a
ret
call c, func_a0cb
add a, e
and h
add a, a
rst 8
ret nz
rrc a
ldh a, [$ff00 + $07]
ldhl sp, d
nop
rst 38
ldh [$ff00 + $1f], a
ldh [$ff00 + $ef], a
jr c, 0.l_06a5
nop
cp $b8
ld e, $e1
inc e
di
nop
rr a
ldh [$ff00 + $07], a
ldhl sp, d
inc bc
<error>
inc bc
<error>
jp .l_39fc
ld hl, $2139
add hl, sp
ld hl, $22bb
or [hl]
dec h
<error>
ld l, e
<error>
ld d, e
add sp, d
ld h, a
sbc a, e
sbc a, b
ldhl sp, d
rst 20
add a, b
add a, a
adc a, h
ld a, a
rlc a
ld a, [$e21f]
rst 38
add a, a
rst 38
rst 18
cp l
ld bc, $fc22
ld sp, $71de
sbc a, [hl]
rst 38
stop
rst 38
cp $ff
rst 38
rst 38
rst 38
rst 38
rst 38
rst 18
rr a
scf
ld b, a
sbc a, e
pop hl
adc a, c
<error>
call z, func_ecb7
rst 10
ldhl sp, d
rst 28
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
ld a, a
ld a, a
cp a
ccf
sbc a, a
rr a
rst 30
ld [hl], b
rst 18
ld e, a
call func_824c
ld [bc], a
add a, a
rlc a
ld c, $0e
inc e
inc e
jr 0.l_0768
pop hl
ld l, [hl]
and b
sbc a, a
ld sp, hl
ld b, $7f
nop
<error>
pop bc
ld a, l
ld a, h
ld [hl], a
ld [hl], b
ld a, l
ld l, h
ldh a, [$ff00 + $77]
call c, func_ee5b
ld c, l
sub a, a
and [hl]
ld a, [bc]
ld [hl], d
ld c, e
or e
sbc a, e
ld h, e
rst 30
rlc a
ld a, a
cp a
rrc a
rst 30
inc bc
<error>
add a, c
ld a, [hl]
ret nz
ccf
ld h, b
rr a
ld h, b
rr a
ld h, b
rr a
and d
add a, e
and b
add a, b
pop de
pop bc
ret nc
ret nz
call nz, func_ea40
ld l, b
ld a, h
<error>
ld a, [hl]
cp [hl]
jr nz, 0.l_078e
inc bc
ret nz
inc e
<error>
add a, b
ldh a, [$ff00 + $c6]
cp c
ld h, b
ld e, a
rst 18
ret nz
rst 28
ldh [$ff00 + $e3], a
inc a
rlc a
ldhl sp, d
rlc a
ldhl sp, d
rrc a
pop af
rr a
<error>
ld a, a
adc a, a
ld sp, hl
add hl, sp
pop hl
pop hl
pop af
ld l, [hl]
pop hl
ld e, [hl]
<error>
call c, func_bfcf
rst 10
sbc a, c
add a, a
cp e
ld c, $72
adc a, [hl]
ld [hl], d
rst 38
ld a, a
ldhl sp, d
ld a, b
pop hl
pop hl
add a, d
add a, d
dec b
inc b
rlc a
inc b
rrc a
ld [$101f], sp
pop af
pop af
add a, b
add a, b
jr 0.l_07d6
ld a, [hl]
nop
cp $00
rst 38
nop
rst 38
nop
rst 38
nop
<error>
ld a, [$3c3f]
rr a
ld e, $0f
rrc a
rrc a
rrc a
rlc a
rlc a
rlc a
rlc a
rlc a
rlc a
cp a
rr a
cp a
rst 18
xor a
rst 8
ccf
rst 8
ld l, a
adc a, a
rst 38
rr a
rst 38
cpl
rst 18
rst 28
or [hl]
add a, [hl]
and b
add a, b
pop hl
sbc a, [hl]
ret nz
cp a
or b
adc a, a
rst 18
ret nz
rst 30
ldh a, [$ff00 + $fc]
<error>
dec a
inc a
rst 30
ldh a, [$ff00 + $fc]
inc bc
nop
rst 38
nop
rst 38
nop
rst 38
add a, b
ld a, a
ldh [$ff00 + $1f], a
ret nz
ccf
add a, b
ld a, a
nop
rst 38
ld bc, $01fe
cp $03
<error>
rrc a
ldh a, [$ff00 + $7f]
add a, b
rst 38
ccf
ei
stop
ldh a, [$ff00 + $1d]
ld sp, hl
inc c
ldhl sp, d
ld c, $fe
inc b
cp $06
rst 38
inc bc
rst 28
rst 28
ldh a, [$ff00 + $f0]
ld d, b
sub a, b
inc h
call nz, func_e216
sub a, e
ld h, l
sub a, c
ld h, [hl]
ld sp, hl
ld c, $db
jp .l_82fa
ld a, e
ld b, d
ld [hl], a
ld b, [hl]
ld a, $2e
scf
ld [hl], $87
add a, l
adc a, $4e
sbc a, h
ld h, h
ld a, h
sbc a, h
xor l
dec [hl]
ld e, $26
dec e
<error>
dec sp
ret z
rst 38
ldhl sp, d
dec sp
inc bc
ld a, a
ld h, b
cp a
add a, b
ld a, a
nop
rst 38
nop
rst 38
nop
rst 38
nop
rst 38
nop
sbc a, a
add a, b
rst 38
nop
rst 38
nop
rst 38
nop
cp $00
cp $00
<error>
nop
ldh a, [$ff00 + $00]
pop hl
ld bc, $0707
ld b, $06
rrc a
ld c, $0f
rrc a
dec e
inc e
ld a, $3c
ld a, b
ld a, b
di
di
xor a
ld c, a
ccf
rst 18
rst 18
rr a
rr a
rr a
ccf
ccf
ld a, a
ld a, a
rst 38
rst 38
rst 38
rst 38
ldhl sp, d
ldhl sp, d
<error>
<error>
ld a, a
ld a, a
ld a, a
ld a, a
ld a, a
ld a, a
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
nop
ld a, a
nop
ld a, a
nop
cp a
add a, b
rst 18
ret nz
rst 20
ldh [$ff00 + $fc], a
<error>
rst 38
rst 38
rst 38
nop
rst 38
nop
rst 38
nop
rst 38
nop
rst 38
nop
rst 38
nop
ccf
nop
pop hl
ldh [$ff00 + $ff], a
inc bc
rst 38
ld bc, $01ff
rst 38
ld bc, $01ff
rst 38
ld [bc], a
rst 38
ld [bc], a
rst 38
inc b
ldh a, [$ff00 + $ff]
jr c, 0.l_091b
<error>
ld [de], a
rst 28
ld [$07f7], sp
push af
inc b
di
ld [bc], a
ld a, [$a402]
inc hl
cp b
rl a
cp a
ld e, $19
ld l, c
jr 0.l_08f2
dec d
<error>
sub a, l
ld h, h
<error>
inc b
ld [hl], d
xor h
jr z, 0.l_08db
jr nc, 0.l_08dd
<error>
adc a, e
rst 0
ret nz
ld a, h
ld a, h
<error>
inc hl
ld sp, hl
ld bc, $6067
reti
sbc a, b
sub a, h
inc h
sbc a, [hl]
ld h, $89
ld sp, $7249
add hl, bc
ldd [hl], a
cp b
add a, e
<error>
inc bc
rst 0
rlc a
dec bc
dec bc
dec bc
dec bc
inc de
inc de
and e
and e
ld h, a
ld h, a
rst 20
ld h, a
rrc a
ld [$707f], sp
rst 38
nop
ld a, h
nop
add a, b
add a, b
ldhl sp, d
ldhl sp, d
cp $fe
rst 38
rst 38
ld sp, hl
ld bc, $01fd
ld a, l
ld bc, $00fc
<error>
nop
ld a, b
nop
nop
nop
add a, b
add a, b
ld a, d
ld [de], a
ld b, [hl]
ld e, d
add a, $3a
add a, $ba
xor $92
ld a, [$b782]
add a, l
<error>
push hl
<error>
nop
cp $00
cp $00
ld a, [hl]
nop
ld a, h
nop
ld a, h
nop
jr c, 0.l_097e
nop
nop
ldhl sp, d
rst 8
ld l, b
ld h, a
dec a
ldd [hl], a
ld e, $18
ld a, [de]
dec de
rrc a
inc c
dec e
inc e
ccf
ld a, $a3
inc hl
inc bc
ld b, e
inc sp
ld d, e
inc sp
<error>
scf
rst 10
ld e, a
sbc a, a
rst 18
rrc a
sbc a, a
rrc a
<error>
sbc a, l
ldh [$ff00 + $9c], a
cp $82
cp d
add a, d
rlc a
add a, e
rrc a
rst 30
rst 30
rlc a
rr a
rr a
nop
nop
ld bc, $0701
rlc a
ccf
ccf
rst 38
rst 38
cp $fe
<error>
<error>
ldh a, [$ff00 + $f0]
ld a, a
ld a, a
cp $f3
jp [hl]
ldh [$ff00 + $a4], a
and d
rl a
stop
jr 0.l_09e4
rrc a
rrc a
rlc a
rlc a
xor a
adc a, a
cpl
rst 8
ld e, a
sbc a, a
rr a
rr a
ccf
ccf
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
jp .l_60c1
ld h, b
jr nc, 0.l_0a16
ld e, $1e
adc a, e
adc a, e
ld l, a
ld l, c
ld l, a
add hl, bc
rst 30
nop
rlc a
nop
add a, b
add a, b
ld h, b
ld h, b
ccf
ccf
rst 38
rst 38
ld h, d
ld h, d
add a, c
add a, c
nop
nop
rst 8
ret nz
rrc a
ldh a, [$ff00 + $03]
<error>
nop
rst 38
ldh [$ff00 + $1f], a
ldh [$ff00 + $ef], a
jr c, 0.l_09d5
ld b, h
cp b
ld a, h
ld a, h
cp $02
rst 38
nop
ld a, a
add a, b
rrc a
ldh a, [$ff00 + $07]
ldhl sp, d
inc bc
<error>
jp .l_44fc
jp .l_ce01
rr a
rst 38
adc a, a
rst 28
rst 8
cp a
nop
ccf
ldh [$ff00 + $f8], a
rst 28
ldh [$ff00 + $63], a
<error>
<error>
<error>
and $f8
rst 0
reti
rrc a
inc sp
rr a
rst 20
add hl, sp
ret
pop de
ld de, $f0f7
rst 38
rst 38
ld d, b
sub a, b
inc h
call nz, func_e216
sub a, e
ld h, l
sub a, c
ld h, [hl]
ld sp, hl
ld c, $23
inc hl
adc a, d
add a, d
ld a, e
ld b, d
ld [hl], a
ld b, [hl]
ld a, $2e
scf
ld [hl], $87
add a, l
adc a, $4e
nop
nop
nop
nop
ld b, h
ld b, h
jr z, 0.l_0a90
stop
stop
jr z, 0.l_0a94
ld b, h
ld b, h
nop
nop
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
<error>
<error>
ld a, [$fff9]
ld sp, hl
push af
di
<error>
<error>
rst 38
rst 38
pop bc
pop bc
add a, e
ld a, h
inc sp
call z, func_f9e7
ld h, $fb
ld l, $f3
call z, func_b0f0
add a, b
pop af
ldh a, [$ff00 + $1e]
ld e, $93
ld h, e
<error>
ret nz
jr c, 0.l_0a3c
add hl, sp
and b
ld sp, $c320
inc bc
ret nz
nop
ld b, d
ld [bc], a
add a, $c6
ld a, [hl]
ld a, [hl]
ld e, $1e
add a, a
rlc a
inc bc
inc bc
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
rlc a
nop
rr a
nop
ld a, $00
nop
nop
nop
nop
nop
nop
nop
nop
nop
jr nz, 0.l_0a4c
jr 0.l_0a8e
inc c
jr nz, 0.l_0ad1
nop
nop
nop
ld b, h
ld b, h
jr z, 0.l_0b00
stop
stop
jr z, 0.l_0b04
ld b, h
ld b, h
nop
nop
nop
nop
nop
nop
ld b, h
ld b, h
jr z, 0.l_0b10
stop
stop
jr z, 0.l_0b14
ld b, h
ld b, h
nop
nop
nop
nop
nop
nop
ld b, h
ld b, h
jr z, 0.l_0b20
stop
stop
jr z, 0.l_0b24
ld b, h
ld b, h
nop
nop
nop
nop
rrc a
nop
ccf
nop
rst 38
nop
ldhl sp, d
rlc a
ldh [$ff00 + $1f], a
add a, b
ld a, a
nop
add a, $00
jr nz, 0.l_0b16
nop
rst 8
nop
rst 38
nop
cp $01
ld a, b
add a, a
nop
ldhl sp, d
nop
ld a, b
ld a, h
nop
cp $00
rst 38
nop
rst 38
nop
inc bc
<error>
nop
rlc a
nop
rlc a
nop
dec c
nop
ld b, b
nop
nop
add a, b
nop
rst 38
nop
rst 38
nop
ld a, a
add a, b
rrc a
ldh a, [$ff00 + $00]
sbc a, a
nop
add a, [hl]
nop
<error>
nop
call z, func_6f00
nop
inc a
nop
inc b
nop
inc bc
nop
nop
nop
ld a, h
nop
ccf
nop
pop hl
nop
ldh [$ff00 + $00], a
<error>
nop
adc a, a
nop
nop
nop
nop
nop
ld a, b
nop
ldh [$ff00 + $00], a
rst 38
nop
jp .l_8000
nop
nop
nop
nop
nop
nop
nop
sbc a, c
nop
jp [hl]
nop
rlc a
nop
inc bc
nop
nop
nop
nop
nop
nop
nop
nop
rst 38
nop
rst 38
add a, b
rst 38
jr c, 0.l_0b86
ld a, [hl]
rst 38
rst 38
rst 38
rrc a
rst 38
cp a
rst 38
rst 38
rst 38
nop
rst 38
stop
rst 38
jr c, 0.l_0b96
ld a, h
rst 38
ld a, a
rst 38
rst 20
rst 38
rst 28
rst 38
rst 38
rst 38
ld a, $ff
ld a, a
rst 38
rrc a
rst 38
rst 0
rst 38
<error>
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rlc a
rst 38
rrc a
rst 38
sbc a, [hl]
rst 38
cp [hl]
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
ei
rst 38
ei
rst 38
ld sp, hl
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
cp $ff
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
<error>
rst 38
ld a, [hl]
rst 38
cp $ff
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
<error>
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
ld bc, $3f00
nop
rst 38
nop
nop
nop
nop
nop
nop
nop
nop
nop
ld a, a
nop
rst 38
nop
rst 38
nop
rst 38
nop
nop
nop
rlc a
nop
rr a
nop
ld a, a
nop
rst 38
nop
rst 38
nop
rst 38
nop
rst 38
nop
rrc a
nop
rst 38
nop
rst 38
nop
rst 38
nop
rst 38
nop
rst 38
nop
rst 38
nop
rst 38
nop
nop
nop
nop
nop
nop
nop
nop
nop
ld bc, $0700
nop
ld a, a
nop
rst 38
nop
ld bc, $0700
nop
rrc a
nop
rr a
nop
rst 38
nop
rst 38
nop
rst 38
nop
rst 38
nop
ld bc, $0100
nop
inc bc
nop
rlc a
nop
rrc a
nop
ccf
nop
ld a, a
nop
rst 38
nop
ldh [$ff00 + $00], a
rst 38
nop
rst 38
nop
rst 38
nop
rst 38
nop
rst 38
nop
rst 38
nop
rst 38
nop
nop
nop
add a, b
nop
ldhl sp, d
nop
rst 38
nop
rst 38
nop
rst 38
nop
rst 38
nop
rst 38
nop
nop
nop
nop
nop
nop
nop
nop
nop
ldh a, [$ff00 + $00]
rst 38
nop
rst 38
nop
rst 38
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
add a, b
nop
ldh a, [$ff00 + $00]
rst 38
nop
add a, b
nop
add a, b
nop
ret nz
nop
ldh [$ff00 + $00], a
ldh a, [$ff00 + $00]
<error>
nop
cp $00
rst 38
nop
add a, b
nop
ldh [$ff00 + $00], a
ldh a, [$ff00 + $00]
ldhl sp, d
nop
rst 38
nop
rst 38
nop
rst 38
nop
rst 38
nop
nop
nop
nop
nop
nop
nop
nop
nop
add a, b
nop
ldh [$ff00 + $00], a
cp $00
rst 38
nop
rst 38
nop
ld a, $00
nop
nop
nop
nop
nop
ret nz
nop
pop af
nop
rst 38
nop
rst 38
rst 38
nop
ld c, $00
nop
nop
nop
nop
nop
ld bc, $c700
nop
rst 38
nop
rst 38
nop
nop
nop
nop
nop
ld bc, $0100
nop
inc bc
nop
inc bc
nop
rlc a
nop
rlc a
nop
ld c, [hl]
nop
adc a, a
nop
rr a
nop
ccf
nop
pop af
nop
ldh [$ff00 + $00], a
ldh [$ff00 + $00], a
ret nz
ld b, $10
inc bc
jr 0.l_0d28
sbc a, h
ld bc, $01fc
cp $01
ldh a, [$ff00 + $00]
ldh [$ff00 + $00], a
ld h, b
nop
nop
nop
nop
add a, b
nop
add a, b
nop
ret nz
nop
ret nz
nop
ldh [$ff00 + $00], a
ldh [$ff00 + $00], a
nop
dec c
nop
ld [$0800], sp
nop
ld [$1000], sp
nop
stop
nop
stop
nop
add hl, de
nop
ret nz
nop
ret nz
nop
ret nz
nop
ldh [$ff00 + $00], a
pop af
nop
rst 38
nop
rst 38
nop
rst 38
nop
ld h, b
nop
ld h, b
nop
ld [hl], b
nop
ldhl sp, d
nop
cp $00
cp $00
cp $00
<error>
ldh a, [$ff00 + $00]
ldh a, [$ff00 + $00]
ldh a, [$ff00 + $00]
ldh a, [$ff00 + $00]
ldhl sp, d
nop
ldhl sp, d
nop
ldhl sp, d
nop
ldhl sp, d
nop
nop
rr a
nop
rr a
nop
ld e, $00
inc e
nop
inc e
nop
inc e
nop
inc c
nop
ld c, $00
cp $00
<error>
nop
ld a, h
nop
inc a
nop
inc e
nop
ld c, $00
rrc a
nop
rrc a
nop
jr c, 0.l_0da3
jr 0.l_0da6
jr 0.l_0da8
jr 0.l_0dac
jr 0.l_0dae
jr c, 0.l_0db4
ldh a, [$ff00 + $0f]
ldh [$ff00 + $f8], a
nop
ldhl sp, d
nop
ldhl sp, d
nop
ldhl sp, d
nop
ldhl sp, d
nop
ldhl sp, d
nop
ldh a, [$ff00 + $00]
ldh a, [$ff00 + $00]
ld [$1807], sp
inc bc
ld a, $00
ccf
nop
ld a, a
nop
ld a, a
nop
ld a, a
nop
rst 38
nop
nop
ld e, $00
<error>
ld bc, $fffc
nop
rst 38
nop
rst 38
nop
rst 38
nop
rst 38
nop
rr a
nop
ccf
nop
rst 38
nop
rst 38
nop
rst 38
nop
rst 38
nop
rst 38
nop
rst 38
nop
ldh a, [$ff00 + $00]
ldhl sp, d
nop
<error>
nop
<error>
nop
cp $00
cp $00
cp $00
rst 38
nop
rst 38
ei
rst 38
ld sp, hl
rst 38
ei
rst 38
ldh a, [$ff00 + $ff]
pop af
rst 38
ccf
rst 38
nop
rst 38
nop
rst 38
cp $ff
<error>
rst 38
<error>
rst 38
<error>
rst 38
ldhl sp, d
rst 38
rlc a
rst 38
nop
rst 38
nop
rst 38
cp $ff
cp $ff
<error>
rst 38
<error>
rst 38
ld a, a
rst 38
ret nz
rst 38
nop
rst 38
nop
rst 38
ld a, c
rst 38
ei
rst 38
ld a, c
rst 38
di
rst 38
ld sp, hl
rst 38
rrc a
rst 38
nop
rst 38
nop
nop
rst 38
nop
rst 28
nop
ld a, a
nop
<error>
nop
ld [hl], a
nop
xor d
nop
ld c, l
nop
sub a, b
inc e
inc e
ldi [hl], a
ld a, $5d
ld a, a
ld d, c
ld a, a
ld d, c
ld a, a
ld e, l
ld a, a
ldi [hl], a
ld a, $1d
inc e
nop
inc c
inc c
rr a
dec e
ccf
inc c
rr a
inc c
rr a
dec l
rr a
ld l, h
rr a
ldh [$ff00 + $0c], a
ld [$e3e3], sp
rst 30
or [hl]
rst 38
di
rst 38
jr nc, 0.l_0e79
or [hl]
rst 38
<error>
rst 30
ld [$20e3], sp
adc a, [hl]
adc a, [hl]
rst 18
<error>
rst 38
add a, $ff
jp .l_dbff
rst 38
adc a, [hl]
rst 18
jr nz, 0.l_0e1e
ldh a, [$ff00 + $06]
halt
rrc a
halt
adc a, a
ld [hl], a
rrc a
halt
adc a, a
halt
adc a, a
halt
adc a, a
ldh a, [$ff00 + $06]
ld bc, $6c6c
rst 38
ld h, c
rst 38
ld l, l
rst 38
<error>
rst 38
ld l, l
rst 38
ld l, l
rst 38
nop
ld l, l
ldh a, [$ff00 + $06]
ld b, $6f
ld l, a
rst 38
or $ff
or [hl]
rst 38
or [hl]
rst 38
or [hl]
rst 38
nop
or [hl]
rst 38
nop
nop
ld [hl], d
ld [hl], d
rst 38
<error>
rst 38
ei
rst 38
jp .l_7bff
rst 38
nop
ld a, e
add a, b
ld bc, $c701
rst 0
rst 38
<error>
rst 38
ld l, l
rst 38
ld l, l
rst 38
ld h, a
rst 38
nop
ld h, a
nop
add a, b
add a, b
call c, func_fe9c
or [hl]
rst 38
or [hl]
rst 38
or [hl]
rst 38
sbc a, h
cp $00
sbc a, h
nop
nop
nop
nop
ld b, h
ld b, h
jr z, 0.l_0f20
stop
stop
jr z, 0.l_0f24
ld b, h
ld b, h
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
ld bc, $0100
nop
inc bc
nop
rlc a
nop
rrc a
nop
ccf
nop
ld a, a
nop
rst 38
nop
rst 38
nop
rst 38
nop
rst 38
nop
rst 38
nop
rst 38
nop
rst 38
nop
rst 38
nop
rst 38
nop
rst 38
nop
rst 38
nop
rst 38
nop
rst 38
nop
rst 38
nop
rst 38
nop
rst 38
nop
rst 38
nop
rst 38
nop
rst 38
nop
rst 38
nop
rst 38
nop
rst 38
nop
rst 38
nop
rst 38
nop
rst 38
nop
rst 38
nop
rst 38
nop
rst 38
nop
rst 38
nop
rst 38
nop
rst 38
nop
rst 38
nop
rst 38
nop
rst 38
nop
rst 38
nop
rst 38
nop
rst 38
nop
rst 38
nop
rst 38
nop
rst 38
nop
rst 38
nop
rst 38
nop
rst 38
nop
rst 38
nop
rst 38
nop
rst 38
nop
rst 38
nop
rst 38
nop
rst 38
nop
add a, b
nop
add a, b
nop
ret nz
nop
ldh [$ff00 + $00], a
ldh a, [$ff00 + $00]
<error>
nop
cp $00
rst 38
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
ld b, h
ld b, h
jr z, 0.l_0fd0
stop
stop
jr z, 0.l_0fd4
ld b, h
ld b, h
nop
nop
nop
nop
nop
nop
ld b, h
ld b, h
jr z, 0.l_0fe0
stop
stop
jr z, 0.l_0fe4
ld b, h
ld b, h
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
rst 38
nop
rst 38
nop
rst 38
nop
rst 38
nop
rst 38
nop
rst 38
nop
rst 38
nop
rst 38
nop
nop
rst 38
nop
rst 38
nop
rst 38
nop
rst 38
nop
rst 38
nop
rst 38
nop
rst 38
nop
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
nop
rst 28
stop
stop
rst 28
add a, b
ld a, a
nop
di
nop
ret nz
ldh a, [$ff00 + $00]
inc a
nop
ret nz
ccf
rlc a
ldhl sp, d
ld a, a
add a, b
cp $01
ccf
ret nz
rrc a
ldh a, [$ff00 + $00]
rrc a
rr a
nop
ld a, a
add a, b
ld c, $f1
ldh a, [$ff00 + $0f]
inc bc
<error>
sbc a, a
ld h, b
rst 38
nop
rr a
ldh [$ff00 + $3e], a
ld bc, $38c7
ld bc, $3cfe
jp .l_00ff
rst 38
nop
cp $01
ldh a, [$ff00 + $0f]
ld bc, $1cf8
nop
rlc a
nop
ld e, $00
ld h, b
nop
nop
nop
rlc a
nop
rst 38
nop
rst 38
ccf
jr c, 0.l_1052
ldh [$ff00 + $00], a
inc bc
nop
ld c, $00
inc a
inc c
rst 38
ccf
rst 38
rst 38
rst 38
rst 38
nop
nop
ld [hl], b
nop
<error>
nop
rst 38
nop
ccf
nop
inc bc
nop
ldh [$ff00 + $e0], a
rst 38
rst 38
nop
nop
nop
nop
nop
nop
add a, b
nop
<error>
nop
pop hl
nop
rr a
nop
cp $00
nop
nop
rst 38
nop
rst 28
stop
stop
rst 28
add a, b
ld a, a
nop
di
nop
ret nz
ret nz
nop
nop
nop
ret nz
ccf
rlc a
ldhl sp, d
ld a, a
add a, b
cp $01
ccf
ret nz
rrc a
ldh a, [$ff00 + $00]
rrc a
nop
nop
ld a, a
add a, b
ld c, $f1
ldh a, [$ff00 + $0f]
inc bc
<error>
sbc a, a
ld h, b
rst 38
nop
rr a
ldh [$ff00 + $00], a
nop
rst 0
jr c, 0.l_10b6
cp $3c
jp .l_00ff
rst 38
nop
cp $01
ldh a, [$ff00 + $0f]
jr nc, 0.l_10c2
rr a
nop
rr a
nop
ldh a, [$ff00 + $00]
nop
nop
rlc a
nop
rst 38
nop
rst 38
ccf
inc a
nop
ldh a, [$ff00 + $00]
jp .l_0e00
nop
inc a
inc c
rst 38
ccf
rst 38
rst 38
rst 38
rst 38
ld c, $01
ld [hl], b
nop
<error>
nop
rst 38
nop
ccf
nop
inc bc
nop
ldh [$ff00 + $e0], a
rst 38
rst 38
inc bc
ldhl sp, d
nop
nop
nop
nop
add a, b
nop
<error>
nop
pop hl
nop
rr a
nop
cp $00
nop
nop
nop
nop
rst 38
nop
rst 28
stop
stop
rst 28
add a, b
ld a, a
nop
di
nop
ret nz
nop
nop
nop
nop
ret nz
ccf
rlc a
ldhl sp, d
ld a, a
add a, b
cp $01
ccf
ret nz
rrc a
ldh a, [$ff00 + $00]
nop
nop
nop
ld a, a
add a, b
ld c, $f1
ldh a, [$ff00 + $0f]
inc bc
<error>
sbc a, a
ld h, b
rst 38
nop
nop
nop
nop
nop
rst 0
jr c, 0.l_1138
cp $3c
jp .l_00ff
rst 38
nop
cp $01
ldh [$ff00 + $00], a
di
nop
rr a
nop
ld a, b
nop
ret nz
nop
rlc a
nop
rst 38
nop
rst 38
ccf
nop
rrc a
ldh [$ff00 + $00], a
inc bc
nop
ld c, $00
inc a
inc c
rst 38
ccf
rst 38
rst 38
rst 38
rst 38
rrc a
add a, b
ld [hl], d
ld bc, $00fc
rst 38
nop
ccf
nop
inc bc
nop
ldh [$ff00 + $e0], a
rst 38
rst 38
ldh a, [$ff00 + $0f]
nop
ldhl sp, d
nop
nop
add a, b
nop
<error>
nop
pop hl
nop
rr a
nop
cp $00
nop
nop
nop
nop
nop
nop
rst 38
nop
rst 28
stop
stop
rst 28
add a, b
ld a, a
nop
di
nop
nop
nop
nop
nop
nop
ret nz
ccf
rlc a
ldhl sp, d
ld a, a
add a, b
cp $01
ccf
ret nz
nop
nop
nop
nop
nop
nop
ld a, a
add a, b
ld c, $f1
ldh a, [$ff00 + $0f]
inc bc
<error>
sbc a, a
ld h, b
nop
nop
nop
nop
nop
nop
rst 0
jr c, 0.l_11ba
cp $3c
jp .l_00ff
rst 38
nop
nop
ret nz
ldh a, [$ff00 + $00]
ccf
nop
ld a, b
nop
ldh [$ff00 + $00], a
rlc a
nop
rst 38
nop
rst 38
ccf
rrc a
ldh a, [$ff00 + $40]
inc c
add a, e
nop
ld c, $00
inc a
inc c
rst 38
ccf
rst 38
rst 38
rst 38
rst 38
adc a, a
nop
ld [hl], e
nop
<error>
nop
rst 38
nop
ccf
nop
inc bc
nop
ldh [$ff00 + $e0], a
rst 38
rst 38
cp $01
ldh a, [$ff00 + $0f]
nop
ld a, b
add a, b
nop
<error>
nop
pop hl
nop
rr a
nop
cp $00
nop
nop
rrc a
nop
ccf
nop
rst 38
nop
ldhl sp, d
rlc a
ldh [$ff00 + $1f], a
add a, b
ld a, a
nop
add a, $00
jr nz, 0.l_1216
nop
rst 8
nop
rst 38
nop
cp $01
ld a, b
add a, a
nop
ldhl sp, d
nop
ld a, b
ld a, h
nop
cp $00
rst 38
nop
rst 38
nop
inc bc
<error>
nop
rlc a
nop
rlc a
nop
dec c
nop
ld b, b
nop
nop
add a, b
nop
rst 38
nop
rst 38
nop
ld a, a
add a, b
rrc a
ldh a, [$ff00 + $00]
sbc a, a
nop
add a, [hl]
nop
<error>
nop
call z, func_6f00
nop
inc a
nop
inc b
nop
inc bc
nop
nop
nop
ld a, h
nop
ccf
nop
pop hl
nop
ldh [$ff00 + $00], a
<error>
nop
adc a, a
nop
nop
nop
nop
nop
ld a, b
nop
ldh [$ff00 + $00], a
rst 38
nop
jp .l_8000
nop
nop
nop
nop
nop
nop
nop
sbc a, c
nop
jp [hl]
nop
rlc a
nop
inc bc
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
rrc a
nop
ccf
nop
ldhl sp, d
rlc a
ldh [$ff00 + $1f], a
add a, b
ld a, h
nop
adc a, b
nop
ld [$2000], sp
inc bc
nop
rst 8
nop
cp $01
ld a, b
add a, a
nop
cp $00
<error>
nop
ccf
ld a, h
nop
cp $00
rst 38
nop
inc bc
<error>
nop
add a, a
nop
rlc a
nop
ld a, h
nop
ldhl sp, d
nop
ld b, b
nop
nop
add a, b
nop
rst 38
nop
ld a, a
add a, b
rrc a
ldh a, [$ff00 + $00]
rst 18
nop
sbc a, c
nop
<error>
nop
ld [hl], e
nop
ldd a, [hl]
nop
ld b, $00
inc bc
nop
nop
nop
nop
nop
nop
nop
pop af
nop
ldh a, [$ff00 + $00]
reti
nop
adc a, a
nop
nop
nop
nop
nop
nop
nop
nop
nop
rst 38
nop
jp .l_8000
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
rlc a
nop
inc bc
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
rrc a
nop
jr c, 0.l_130d
ldh [$ff00 + $1c], a
add a, b
ld a, b
nop
ret z
nop
adc a, h
nop
di
nop
jr nz, 0.l_1316
nop
adc a, $01
jr nc, 0.l_12e7
nop
ld a, $00
scf
nop
ldhl sp, d
nop
ldhl sp, d
ld a, h
nop
cp $00
inc bc
<error>
nop
rrc a
nop
inc c
nop
rst 38
nop
ld a, b
nop
ld h, b
nop
ld b, b
nop
nop
add a, b
nop
ld a, a
add a, b
rlc a
ldhl sp, d
nop
rst 18
nop
ld [hl], l
nop
inc sp
nop
ld a, [de]
nop
rlc a
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
call z, func_8700
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
ret nz
nop
add a, b
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
rlc a
nop
ccf
nop
ret z
nop
adc a, e
nop
ld a, h
nop
ld e, $00
inc bc
nop
jr nz, 0.l_1393
ld bc, $cf00
nop
ld a, a
nop
<error>
nop
ldhl sp, d
nop
call func_0700
nop
nop
nop
<error>
nop
rlc a
nop
cp $00
ld e, [hl]
nop
ld h, e
nop
ret nz
nop
nop
nop
ld b, b
nop
nop
nop
add a, b
nop
rst 38
nop
ld [$c700], a
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
ld bc, $0600
ld bc, $0708
jr c, 0.l_1411
jr nz, 0.l_142b
ld l, $11
ld e, $05
dec hl
ld d, $45
dec sp
add a, d
ld a, l
add a, a
ld a, b
ld a, c
ld b, $11
ld c, $20
rr a
ccf
nop
nop
nop
ldh a, [$ff00 + $00]
ld l, [hl]
ldh a, [$ff00 + $05]
cp $1d
ldh [c], a
ld a, $d0
ldhl sp, d
stop
ldhl sp, d
ld d, b
<error>
ld e, b
<error>
ldhl sp, d
ld a, b
ldh a, [$ff00 + $f0]
nop
ldh [$ff00 + $c0], a
ldh a, [$ff00 + $c0]
ret z
jr nc, 0.l_1437
nop
ld bc, $0600
ld bc, $0708
jr c, 0.l_144f
jr nz, 0.l_1469
ld l, $11
ld e, $05
dec de
ld b, $25
dec de
ldi [hl], a
dec e
ld b, e
inc a
ld b, a
jr c, 0.l_1496
ld [bc], a
ld [$1007], sp
rrc a
rr a
nop
ldh a, [$ff00 + $00]
ld l, h
ldh a, [$ff00 + $06]
<error>
ld a, [de]
<error>
ld a, $d0
ldhl sp, d
stop
ldhl sp, d
ld d, b
<error>
ld e, b
<error>
ldhl sp, d
ld a, b
ldh a, [$ff00 + $f0]
nop
ldh [$ff00 + $c0], a
ldh [$ff00 + $c0], a
ldh [$ff00 + $00], a
stop
ldh [$ff00 + $f0], a
nop
ld bc, $1e00
ld bc, $0f10
stop
rrc a
ld d, $09
rrc a
ld [bc], a
rl a
ld a, [bc]
daa
dec de
daa
add hl, de
ld b, d
dec a
ld b, e
inc a
daa
jr 0.l_14b5
inc bc
ld [$1007], sp
rrc a
rr a
nop
ldh [$ff00 + $00], a
ld a, b
ldh [$ff00 + $04], a
ldhl sp, d
ld b, $fc
ld a, [bc]
<error>
ld a, [de]
<error>
ld a, h
sub a, b
ldhl sp, d
ld d, b
<error>
ret c
<error>
ldhl sp, d
ld a, b
ldh [$ff00 + $f0], a
nop
ld e, b
or b
ld a, b
or b
jr nc, 0.l_147e
ldh a, [$ff00 + $00]
nop
nop
rrc a
nop
ld [$0807], sp
rlc a
dec bc
inc b
rlc a
ld bc, $050b
inc de
dec c
inc de
inc c
ld hl, $211e
ld e, $13
inc c
ld c, $01
ld [$1007], sp
rrc a
rr a
nop
ldh a, [$ff00 + $00]
inc a
ldh a, [$ff00 + $02]
<error>
inc bc
cp $05
ld a, [$728d]
cp [hl]
ld c, b
<error>
xor b
cp $ec
ld a, [hl]
<error>
cp h
ld [hl], b
ldhl sp, d
nop
inc l
ret c
inc a
ret c
jr c, 0.l_14be
ldh a, [$ff00 + $00]
rrc a
nop
ld a, a
rlc a
rst 38
nop
ld a, a
rlc a
rst 38
inc c
ld a, a
rl a
cpl
dec e
ld d, $0f
ccf
nop
ld d, h
dec sp
ld a, e
scf
jr c, 0.l_151f
ccf
jr 0.l_154a
inc e
rl a
inc c
ld c, $01
ret nz
nop
or b
ld b, b
ldhl sp, d
sub a, b
ldhl sp, d
jr nc, 0.l_151d
xor b
or d
<error>
and d
call c, func_00fc
inc h
ret c
ld e, $ec
sbc a, $ec
inc e
ldh [$ff00 + $fe], a
inc c
ld a, [$f41c]
jr 0.l_1577
nop
rlc a
nop
rrc a
nop
rr a
nop
ccf
inc de
ccf
inc d
daa
rr a
rl a
rrc a
dec c
inc bc
dec de
inc b
ld l, $19
dec a
dec de
inc e
inc bc
rl a
inc c
rr a
inc c
rl a
inc c
ld c, $01
ldh a, [$ff00 + $00]
ret z
jr nc, 0.l_1549
jr 0.l_1565
<error>
cp $94
<error>
<error>
xor $70
call c, func_f6e0
ld [$f60b], sp
<error>
or $0e
ldh a, [$ff00 + $fe]
nop
<error>
ld c, $fa
dec e
inc a
ld [bc], a
nop
nop
nop
nop
ld b, h
ld b, h
jr z, 0.l_15b0
stop
stop
jr z, 0.l_15b4
ld b, h
ld b, h
nop
nop
nop
nop
nop
nop
ld b, h
ld b, h
jr z, 0.l_15c0
stop
stop
jr z, 0.l_15c4
ld b, h
ld b, h
nop
nop
nop
nop
nop
nop
ld b, h
ld b, h
jr z, 0.l_15d0
stop
stop
jr z, 0.l_15d4
ld b, h
ld b, h
nop
nop
nop
nop
nop
nop
ld b, h
ld b, h
jr z, 0.l_15e0
stop
stop
jr z, 0.l_15e4
ld b, h
ld b, h
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
ld bc, $0000
nop
inc b
nop
ld [$0000], sp
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
ld b, b
nop
ld b, b
nop
ld b, b
nop
ld b, b
nop
ld b, b
nop
ld b, b
nop
ret nz
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
inc b
nop
ret z
nop
jr c, 0.l_1610
rr a
nop
rr a
nop
rrc a
nop
rlc a
nop
inc bc
nop
nop
nop
nop
nop
nop
nop
rr a
nop
ld e, a
nop
add a, a
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
add a, b
nop
<error>
nop
rst 38
nop
rst 38
nop
rst 38
nop
rst 38
nop
jr 0.l_163e
nop
nop
ret nz
nop
rst 38
nop
rst 38
nop
sbc a, $00
ret nz
nop
ld d, b
nop
ld c, b
nop
ld c, [hl]
nop
ld a, [hl]
nop
ld a, a
nop
rst 38
nop
rst 38
nop
rst 38
nop
rst 38
nop
ld a, a
nop
ld c, $00
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
ret nz
nop
ldh [$ff00 + $00], a
rst 38
nop
rst 38
nop
rst 38
nop
add a, $00
nop
nop
ret nz
ret nz
ld h, b
ld h, b
jr nc, 0.l_16b6
jr 0.l_16a0
inc c
inc c
ld b, $06
inc bc
inc bc
ld bc, $0001
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
add a, b
add a, b
ret nz
ret nz
ld b, b
ld b, b
ld h, b
ld h, b
jr nz, 0.l_16ca
jr nc, 0.l_16dc
stop
stop
jr 0.l_16c8
ld [$0c08], sp
inc c
inc b
inc b
inc b
inc b
nop
nop
nop
nop
nop
nop
nop
nop
ld bc, $0101
ld bc, $0303
ld c, $0e
jr 0.l_16e2
jr 0.l_16e4
inc e
inc e
ld c, $0e
inc bc
inc bc
ld bc, $0101
ld bc, $0707
ld e, $1e
ld a, h
ld a, h
ldh [$ff00 + $e0], a
ret nz
ret nz
ld bc, $0301
inc bc
ld e, $1e
jr c, 0.l_1720
jr nc, 0.l_171a
ld h, b
ld h, b
ld h, b
ld h, b
ld h, b
ld h, b
ld [hl], b
ld [hl], b
inc e
inc e
ld b, $06
ld b, $06
ld [bc], a
ld [bc], a
ld [bc], a
ld [bc], a
ld [bc], a
ld [bc], a
ld bc, $0001
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
inc bc
inc bc
ld e, $1e
jr nc, 0.l_1746
jr nz, $41738
jr nz, 0.l_173a
jr nz, 0.l_173c
ld b, b
ld b, b
add a, b
add a, b
jr c, 0.l_175a
ld [hl], b
ld [hl], b
ldh [$ff00 + $e0], a
ldh [$ff00 + $e0], a
ld h, b
ld h, b
ld [hl], b
ld [hl], b
jr c, 0.l_1766
inc e
inc e
ld c, $0e
rlc a
rlc a
rlc a
rlc a
rlc a
rlc a
ld e, $1e
inc a
inc a
jr c, 0.l_1776
jr c, 0.l_1778
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
add a, b
nop
ld h, c
nop
ccf
nop
rrc a
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
pop hl
nop
rst 38
nop
adc a, $00
add a, b
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
ld bc, $0300
ld bc, $0103
ld bc, $0000
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
inc c
nop
ld c, $04
rlc a
ld [bc], a
inc bc
ld bc, $0103
rlc a
ld [bc], a
ld c, $04
inc c
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
ld bc, $0100
nop
ld bc, $0f00
ld bc, $0f1f
rrc a
ld bc, $0001
ld bc, $0100
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
add a, b
nop
ret nz
add a, b
ret nz
add a, b
ret nz
add a, b
ldhl sp, d
ret nz
<error>
ldhl sp, d
ldhl sp, d
ret nz
ret nz
add a, b
ret nz
add a, b
ret nz
add a, b
add a, b
nop
nop
nop
nop
nop
inc [hl]
bit 4, b
sbc a, a
ld d, h
xor e
ldh [$ff00 + $1f], a
and b
ld e, a
ret z
scf
and b
ld e, a
ld d, b
xor a
ld b, c
add a, d
inc b
pop bc
nop
pop hl
ldi [hl], a
ret nz
nop
ldh a, [$ff00 + $00]
ldhl sp, d
stop
<error>
add a, [hl]
ld a, c
ld [bc], a
<error>
inc bc
<error>
adc a, c
halt
ld e, [hl]
and c
ld d, l
xor d
ld a, [$ec05]
inc de
ldh a, [$ff00 + $0f]
ret nz
ccf
ld d, b
cp a
sub a, b
ld a, a
xor b
ld l, a
add hl, hl
rst 28
ld h, $e6
ld h, h
call nz, func_c667
nop
rst 38
jr nz, 0.l_1843
ld h, b
rst 38
and c
cp a
ld h, e
ccf
sub a, l
ld e, l
sbc a, e
ld e, c
sub a, e
ld d, c
nop
rst 38
nop
rst 38
nop
rst 38
nop
rst 38
nop
rst 38
nop
rst 38
nop
rst 38
nop
rst 38
xor b
ld d, a
ret z
scf
or $09
ld l, d
sub a, l
ld a, e
add a, h
jr c, 0.l_182c
ld [bc], a
ldh [$ff00 + $30], a
ret nz
ld bc, $07fe
ldhl sp, d
ld e, c
and [hl]
ld c, e
or h
rl a
add sp, d
ld l, d
dec d
sbc a, h
inc bc
ld [$0307], sp
<error>
dec d
ld [$f50a], a
ld b, l
cp d
dec hl
call nc, func_21de
ld [hl], h
adc a, e
ret c
daa
add a, h
ld a, h
add a, a
ld a, a
add a, h
ld a, h
inc b
<error>
inc b
<error>
inc b
<error>
inc b
<error>
ld [bc], a
cp $c3
ld b, b
jp .l_83c0
add a, b
add a, e
add a, b
add a, a
add a, b
add a, a
add a, b
add a, a
add a, b
rrc a
nop
ldh [$ff00 + $60], a
ldh [$ff00 + $60], a
ldh [$ff00 + $60], a
ldh [$ff00 + $60], a
ldh [$ff00 + $60], a
ldh [$ff00 + $60], a
ldh [$ff00 + $60], a
ret nc
ld [hl], b
pop af
ld de, $10f0
ldh a, [$ff00 + $10]
ldh a, [$ff00 + $10]
pop af
stop
di
stop
inc bc
nop
rlc a
nop
cp $83
ld a, [hl]
ld b, e
rst 38
daa
ei
inc l
di
inc e
or $19
<error>
dec sp
call nz, func_187b
rst 38
ld a, b
rst 38
<error>
adc a, a
rst 38
rrc a
cp b
ld a, b
ld h, b
ldh [$ff00 + $c0], a
ret nz
rst 0
add a, a
ld a, $c3
ld e, $e3
ld e, $e3
adc a, $f3
ld a, a
ld [hl], c
rr a
jr 0.l_190c
inc c
rst 0
add a, $74
adc a, e
jr z, 0.l_18db
ld d, $e9
dec c
<error>
inc bc
<error>
nop
rst 38
nop
rst 38
nop
rst 38
ld d, [hl]
xor c
xor h
ld d, e
reti
daa
ld [hl], e
adc a, [hl]
rst 0
inc a
inc c
ldhl sp, d
ld [$1df8], sp
ldh a, [$ff00 + $3c]
rst 38
rst 38
jp .l_01ff
rst 38
nop
rst 38
inc bc
ld a, a
nop
rst 38
nop
ld a, a
add a, b
jp [hl]
ret
ld a, c
ld a, c
ld h, a
ld b, [hl]
<error>
add a, b
rst 20
jp .l_2cec
pop af
stop
rst 0
nop
add a, a
ld b, a
jp [hl]
jp [hl]
add hl, de
reti
ld a, a
rst 38
rst 38
add a, b
ld a, a
nop
cp $00
adc a, h
ld [hl], b
nop
rst 38
ret nz
rst 38
ldh a, [$ff00 + $3f]
ld sp, hl
adc a, [hl]
<error>
ld b, $ff
ld [bc], a
ld a, a
ld bc, $011f
ld a, b
add a, h
push de
ldi a, [hl]
ldh [$ff00 + $1f], a
ret z
scf
and b
ld e, a
ret nc
cpl
and b
ld e, a
ret z
scf
jr 0.l_1979
ld d, h
xor e
inc e
<error>
ld l, $d1
ld e, $e1
ld c, d
or l
sbc a, [hl]
ld h, c
inc l
<error>
ldh [$ff00 + $1f], a
nop
rst 38
nop
rst 38
nop
rst 38
nop
rst 38
nop
rst 38
nop
rst 38
ld bc, $02fe
cp $02
cp $02
cp $01
rst 38
ld bc, $70ff
adc a, a
ldhl sp, d
rlc a
sbc a, h
ld h, e
rrc a
nop
rr a
nop
ccf
nop
rst 38
ld bc, $01ff
cp $83
ld a, h
rst 0
jr c, 0.l_19af
sbc a, b
ldh a, [$ff00 + $9c]
ldh a, [$ff00 + $ce]
cp b
rst 8
jr c, 0.l_19a0
sbc a, h
ld [hl], a
call z, func_f63b
dec c
ei
rrc a
nop
rr a
ld bc, $033e
<error>
rlc a
ldhl sp, d
rrc a
ldh a, [$ff00 + $1f]
ldh [$ff00 + $3f], a
ret nz
rst 38
add a, c
rst 38
add hl, bc
rst 38
dec bc
cp $1b
cp $1f
cp $1e
rst 38
ld e, $ff
ld e, $ff
call z, func_d80c
jr 0.l_19b5
stop
ret nc
stop
ret nc
stop
ld sp, hl
jr 0.l_19dc
rrc a
ldh a, [$ff00 + $00]
inc hl
inc hl
inc de
inc de
add hl, bc
add hl, bc
add hl, bc
add hl, bc
ld sp, hl
add hl, bc
ldh a, [$ff00 + $30]
ret nz
ret nz
nop
nop
nop
rst 38
nop
rst 38
nop
rst 38
ld bc, $01ff
rst 38
ld bc, $01ff
rst 38
add a, c
ld a, a
rr a
ldh a, [$ff00 + $1f]
ldh a, [$ff00 + $9f]
ldh a, [$ff00 + $9f]
ldh a, [$ff00 + $de]
ld [hl], c
cp $31
<error>
inc bc
ld a, b
add a, a
ccf
ret nz
ccf
ret nz
rr a
ldh [$ff00 + $0f], a
ldh a, [$ff00 + $27]
ldhl sp, d
ld sp, $28fe
rst 28
ld b, [hl]
rst 0
rst 0
nop
rst 38
nop
cp $01
<error>
inc bc
ldhl sp, d
rlc a
pop bc
ccf
ld b, $fe
jr c, 0.l_1a38
adc a, h
ld [hl], b
ld c, $f0
rlc a
ldhl sp, d
ld b, a
ldhl sp, d
<error>
cp h
<error>
inc a
pop hl
ld a, $71
ld e, $1f
nop
ld l, a
nop
ccf
nop
rst 38
nop
rst 38
nop
rst 38
nop
<error>
nop
<error>
nop
<error>
sbc a, e
<error>
adc a, l
cp l
jp nz, .l_e09f
add a, a
ldhl sp, d
add a, b
rst 38
ret nz
ld a, a
ret nz
ld a, a
sbc a, h
ld h, e
jr c, 0.l_1a3b
ldh a, [$ff00 + $0f]
ldh [$ff00 + $1f], a
add a, b
ld a, a
nop
rst 38
ld bc, $02fe
<error>
adc a, b
rst 38
sbc a, a
<error>
cp d
ldh [c], a
jp c, .l_dee2
<error>
ld c, [hl]
<error>
ld c, a
ldhl sp, d
inc sp
<error>
nop
rst 38
ldh a, [$ff00 + $0f]
inc c
inc bc
ld b, $01
ld b, $01
ld c, $01
dec e
inc bc
ld sp, hl
rlc a
adc a, a
ldh a, [$ff00 + $8f]
ldh a, [$ff00 + $47]
ldhl sp, d
ld b, a
ldhl sp, d
and e
<error>
and b
rst 38
sub a, b
rst 38
add sp, d
rst 38
ret nz
nop
ldh [$ff00 + $00], a
ldh a, [$ff00 + $00]
ldhl sp, d
nop
<error>
nop
rst 38
nop
ld a, a
add a, b
ccf
ret nz
inc bc
ld [bc], a
ld bc, $0001
nop
nop
nop
nop
nop
nop
nop
ret nz
nop
ret nz
nop
rrc a
nop
nop
nop
ld e, $00
ld bc, $0000
nop
nop
nop
ld [bc], a
nop
ld bc, $8000
nop
ld h, b
nop
nop
nop
add a, b
nop
ld b, b
nop
nop
nop
nop
nop
nop
nop
add a, b
rst 38
add a, b
rst 38
add a, b
rst 38
add a, b
rst 38
ld b, b
ld a, a
ld b, b
ld a, a
ld b, b
ld a, a
ld b, b
ld a, a
ret
ccf
adc a, $3f
ld l, a
sbc a, c
xor a
ld e, b
ld h, a
sbc a, h
and h
ld e, a
jp nz, .l_413f
cp a
nop
rst 38
add a, d
rst 38
pop bc
rst 38
pop bc
ccf
add a, c
ld a, a
ld bc, $01ff
rst 38
add a, c
rst 38
ld e, c
reti
add a, b
and h
nop
nop
add a, b
add a, b
ldh a, [$ff00 + $70]
ret z
ret z
add a, h
add a, h
adc a, h
adc a, h
jp .l_00c3
inc b
nop
nop
nop
nop
ld bc, $0300
ld bc, $0206
inc b
inc b
ldh a, [$ff00 + $9f]
jr c, 0.l_1b93
ld a, h
rlc a
ld a, a
inc de
cp $f7
ld e, $1f
ld c, $0b
ld l, a
ld l, [hl]
pop af
nop
jr nc, 0.l_1b14
dec c
ldh a, [$ff00 + $1f]
ldh [$ff00 + $1f], a
ldh [$ff00 + $1f], a
ldh [$ff00 + $38], a
rst 30
add sp, d
cpl
ldh [$ff00 + $3f], a
ldhl sp, d
rr a
rst 38
rlc a
rst 38
nop
rst 38
nop
rst 28
stop
rrc a
di
rr a
rst 20
dec h
ld a, [$f966]
ld [$ecb5], a
inc sp
jp z, .l_9c75
di
scf
ldhl sp, d
or $d8
ld hl, $18fe
rst 38
rrc a
rst 38
inc b
rst 38
inc b
rst 38
dec b
cp $05
cp $04
rst 38
<error>
rr a
rrc a
<error>
rst 38
ldhl sp, d
jr 0.l_1b78
ldh [$ff00 + $00], a
add a, b
nop
add a, b
nop
ret nz
nop
inc a
rst 38
add a, [hl]
ld a, a
jp .l_f13f
rrc a
inc e
rr a
ld h, $27
ld h, $23
ld l, $23
rrc a
ldh a, [$ff00 + $07]
ldhl sp, d
inc bc
<error>
add a, a
ldhl sp, d
rst 0
ldhl sp, d
rst 0
ldhl sp, d
add a, a
ldhl sp, d
add a, a
ldhl sp, d
ret nz
nop
add a, b
nop
add a, b
nop
add a, b
nop
add a, b
nop
add a, b
nop
ret nz
nop
ret nz
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
rst 38
rst 38
nop
nop
nop
ld l, d
nop
adc a, [hl]
nop
adc a, d
nop
ld l, d
nop
nop
rst 38
rst 38
ld b, b
ld a, a
ld b, b
ld a, a
jr nz, 0.l_1c35
jr nz, 0.l_1c37
jr nz, 0.l_1c39
jr nz, 0.l_1c3b
jr nz, 0.l_1c3d
jr nz, 0.l_1c3f
add a, b
ld a, a
nop
rst 38
nop
rst 38
nop
rst 38
inc c
rst 38
rrc a
ei
rrc a
ldhl sp, d
rlc a
<error>
ld [hl], c
rst 38
ld hl, $21ff
rst 38
inc de
rst 38
inc h
<error>
ret z
ldhl sp, d
ret z
jr c, 0.l_1bde
ld a, a
sub a, d
sub a, [hl]
sbc a, [hl]
sub a, [hl]
call z, func_a08c
sbc a, b
add a, c
add a, b
add a, b
add a, d
add a, h
add a, h
ld b, b
ld b, d
nop
inc b
inc b
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
ld bc, $9f00
cp d
rst 38
cp d
ld a, a
ld [hl], d
rr a
ldh [c], a
rst 38
inc b
cp $05
<error>
dec bc
<error>
di
call nz, func_4447
rst 10
ld b, h
rst 10
ld d, h
rst 10
ld b, h
rst 10
ld c, [hl]
rst 8
ld d, c
pop de
ld h, b
ldh [$ff00 + $1f], a
ldh [$ff00 + $3f], a
ret nz
ld bc, $03fe
<error>
inc bc
rst 38
ld b, $fb
rrc a
pop af
adc a, a
ldh a, [$ff00 + $e0]
inc a
and $38
rst 8
ld [hl], b
adc a, d
push af
inc e
<error>
inc e
<error>
ld a, [de]
push hl
sbc a, h
<error>
ld b, $ff
ld [bc], a
rst 38
ld bc, $01ff
rst 38
ld bc, $01ff
rst 38
ld bc, $00ff
rst 38
ldh [$ff00 + $00], a
ld a, a
add a, b
rr a
ldh [$ff00 + $8f], a
ldh a, [$ff00 + $70]
rst 38
rrc a
rst 38
nop
rst 38
sub a, b
rst 28
cp $17
<error>
rr a
di
rrc a
rst 0
ld a, $1f
<error>
or $fa
ld c, $f2
ccf
jp .l_f887
add a, a
ldhl sp, d
add a, a
ldhl sp, d
rst 0
ldhl sp, d
rst 0
ld a, b
jp .l_c37c
ld a, h
jp .l_c07c
nop
ret nz
nop
ldh [$ff00 + $00], a
ldh [$ff00 + $00], a
ldh a, [$ff00 + $00]
ldh a, [$ff00 + $00]
ldhl sp, d
nop
<error>
nop
rst 38
rst 38
nop
ld bc, $ea00
nop
xor e
nop
ret z
nop
xor e
nop
nop
rst 38
rst 38
rst 38
rst 38
nop
add a, b
nop
ldd a, [hl]
nop
sub a, d
nop
sub a, d
nop
ld [de], a
nop
nop
rst 38
rst 38
jr nz, 0.l_1d31
jr nz, 0.l_1d33
jr nz, 0.l_1d35
jr nz, 0.l_1d37
jr nz, 0.l_1d39
jr nz, 0.l_1d3b
jr nz, 0.l_1d3d
jr nz, 0.l_1d3f
ld b, $fd
ld [bc], a
rst 38
ld [bc], a
rst 38
ld bc, $00ff
rst 38
inc e
<error>
ldi a, [hl]
push de
ld h, l
sbc a, d
ld h, c
pop hl
ld b, b
ret nz
ld b, h
call z, func_ceca
add a, a
add a, a
add a, a
add a, h
ld b, b
ret nz
ld a, b
ldh [$ff00 + $c0], a
ret nz
pop bc
pop bc
pop hl
pop hl
pop hl
pop hl
ld sp, hl
pop af
ld a, a
ld sp, hl
rst 38
inc c
rr a
ld [bc], a
ld bc, $c300
ret nz
<error>
ldh [$ff00 + $27], a
jr nz, 0.l_1d28
rst 20
ldhl sp, d
ret z
ldh a, [$ff00 + $10]
ldh a, [$ff00 + $10]
ldhl sp, d
ld b, a
rst 38
scf
ldhl sp, d
ld c, b
ldh a, [$ff00 + $30]
or $92
ld [hl], a
ld [hl], e
rrc a
ld c, $07
nop
ldh [$ff00 + $e0], a
sub a, b
sub a, b
sbc a, c
adc a, c
sbc a, $4f
cp $4b
or $4b
xor h
ld d, a
rst 38
rrc a
add a, a
ldhl sp, d
add a, e
<error>
nop
rst 38
nop
rst 38
nop
rst 38
ld bc, $01ff
cp $81
cp $fa
ld h, l
cp $19
dec e
ld [$f11e], a
ld h, a
ldhl sp, d
add a, c
cp $80
rst 38
ret nz
ld a, a
rst 38
rst 38
nop
rlc a
nop
sub a, h
nop
rst 10
nop
or h
nop
sub a, a
nop
nop
rst 38
rst 38
add a, a
ldhl sp, d
jp .l_60fc
rst 38
jr c, 0.l_1d97
rrc a
rst 38
nop
rst 38
nop
rst 38
nop
rst 38
rst 38
ld bc, $07f8
nop
rst 38
inc bc
rst 38
rst 38
cp $10
rst 38
inc c
rst 38
inc bc
rst 38
pop hl
cp $30
rst 38
ld [hl], b
rst 38
add sp, d
rst 18
<error>
rr a
rlc a
rst 38
ld a, [de]
rst 38
<error>
rst 38
rst 38
nop
rst 38
nop
ld a, a
add a, b
ccf
ret nz
rrc a
ldh a, [$ff00 + $03]
<error>
ldh a, [$ff00 + $ff]
nop
rst 38
nop
nop
ret nz
nop
ldhl sp, d
nop
rst 38
nop
rst 38
nop
rst 38
nop
ld a, a
add a, b
rst 38
nop
nop
nop
nop
nop
nop
nop
nop
nop
add a, b
nop
add a, b
nop
add a, b
nop
ret nz
nop
jr nz, 0.l_1e31
stop
rr a
stop
rr a
ld [$080f], sp
rrc a
inc b
rlc a
inc b
rlc a
ld [bc], a
inc bc
add a, b
ld a, a
pop bc
ld a, $c0
ccf
ld h, c
sbc a, [hl]
ld l, $d1
inc e
<error>
nop
rst 38
nop
rst 38
cp [hl]
ld [hl], b
sbc a, a
ld a, h
rst 38
ld h, a
ld h, e
ret nz
rst 0
ret nz
rst 28
add a, b
rst 38
add a, b
rst 38
add a, b
rlc a
ld bc, $0083
<error>
nop
di
ret nz
or e
ld h, b
sub a, e
ld [hl], b
sub a, e
ld [hl], b
inc de
ldh a, [$ff00 + $f0]
stop
ldh a, [$ff00 + $f0]
pop af
sub a, b
pop af
sub a, c
pop af
ret nc
or e
ldh a, [$ff00 + $93]
ldh a, [$ff00 + $93]
ldh a, [$ff00 + $1f]
nop
rst 38
nop
rst 38
nop
rst 38
rst 38
add a, a
<error>
add a, a
<error>
adc a, a
ldhl sp, d
rst 8
ldhl sp, d
rst 38
stop
rst 38
jr nz, 0.l_1e46
ret nz
ldh [$ff00 + $80], a
ei
nop
rst 38
nop
rst 18
jr nz, 0.l_1e3e
jr nz, 0.l_1e52
ld a, [hl]
ldhl sp, d
rrc a
<error>
rlc a
ld a, [$fa07]
rlc a
ld a, [$f107]
rrc a
pop af
rrc a
ldh [$ff00 + $3f], a
ldh [$ff00 + $3f], a
ld [hl], b
sbc a, a
ld [hl], b
sbc a, a
jr c, 0.l_1e49
jr c, 0.l_1e4b
inc e
rst 20
rrc a
di
nop
rst 38
nop
rst 38
nop
rst 38
ret nz
rst 38
jr nc, 0.l_1ec9
ld [$040f], sp
rlc a
ld [bc], a
inc bc
rst 38
rst 38
nop
ld [hl], $00
ld a, a
nop
ld a, a
nop
ld a, $00
inc e
nop
ld [$ffff], sp
cp $ff
ld a, [de]
rlc a
ld a, [de]
rlc a
add hl, de
rlc a
add hl, de
rlc a
add hl, de
rlc a
add hl, de
rlc a
rst 38
rst 38
ldhl sp, d
nop
ld a, b
add a, b
ld a, h
add a, b
inc a
ret nz
ld a, $c0
ccf
ret nz
rr a
ldh [$ff00 + $9f], a
ldh [$ff00 + $00], a
nop
nop
nop
nop
nop
nop
nop
inc bc
inc bc
inc b
inc b
adc a, c
add hl, bc
add a, d
ld [bc], a
ld b, c
ld b, c
ld hl, $2321
ld hl, $1113
rl a
ld de, $898f
adc a, a
adc a, c
rlc a
rlc a
ret nz
nop
add a, b
nop
add a, b
nop
ret nz
nop
ret nz
nop
ldh a, [$ff00 + $00]
ldh [$ff00 + $00], a
add a, b
nop
ld [$040f], sp
rlc a
inc b
rlc a
ld [bc], a
inc bc
ld [bc], a
inc bc
ld bc, $0101
ld bc, $0101
ldh [$ff00 + $1f], a
ldhl sp, d
rlc a
ld e, h
and e
or [hl]
ld c, c
dec c
<error>
ld d, e
xor h
dec b
ld a, [$e51a]
cp $81
ld l, h
<error>
ld c, b
rst 30
jr z, 0.l_1f17
inc d
rst 38
rrc a
rst 38
add a, h
ld a, h
add a, h
ld a, h
inc de
ldh a, [$ff00 + $13]
ldh a, [$ff00 + $33]
ldh a, [$ff00 + $a3]
ldh [$ff00 + $a3], a
ldh [$ff00 + $e3], a
ldh [$ff00 + $e3], a
ld h, b
jp .l_9340
ldh a, [$ff00 + $93]
ldh a, [$ff00 + $91]
ldh a, [$ff00 + $91]
ldh a, [$ff00 + $91]
ldh a, [$ff00 + $d1]
ld [hl], b
pop de
ld [hl], b
pop hl
ld h, b
bit 7, h
ret z
ld a, a
ret z
ld a, a
rst 0
ld a, a
call nz, func_e47c
inc a
add sp, d
jr c, 0.l_1f4d
ld a, $9f
ld h, b
sbc a, a
ldh [$ff00 + $9f], a
ldh [$ff00 + $8c], a
di
ld h, b
ld a, a
ld de, $3e1f
rrc a
inc a
rlc a
pop bc
ccf
pop bc
ccf
ld bc, $01ff
rst 38
ld [bc], a
rst 38
ld [bc], a
rst 38
inc b
rst 38
ld [$0fff], sp
pop af
ld a, [hl]
add a, e
ld a, h
add a, a
ld a, b
sbc a, a
ld a, b
adc a, a
inc a
rst 0
inc a
rst 0
ld a, $c3
ld bc, $0001
nop
nop
nop
nop
nop
nop
nop
ld a, b
nop
ldh a, [$ff00 + $00]
ret nz
nop
nop
rst 38
add a, b
rst 38
ld b, b
ld a, a
jr nz, 0.l_1fd7
jr nz, 0.l_1fd9
stop
rr a
stop
rr a
ld [$810f], sp
add a, c
add a, c
add a, c
add a, c
add a, c
add a, c
add a, c
add a, c
add a, c
add a, c
add a, c
ld b, c
ld b, c
ld b, c
ld b, c
rst 38
rst 38
add a, b
add a, b
add a, b
add a, b
add a, b
add a, b
add a, b
add a, b
add a, b
add a, b
add a, b
add a, b
add a, c
add a, c
rst 38
rst 38
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
rst 38
rst 38
add a, c
add a, c
add a, b
add a, b
add a, b
add a, b
add a, b
add a, b
add a, b
add a, b
add a, b
add a, b
add a, b
add a, b
rst 38
rst 38
rst 38
rst 38
ld bc, $0101
ld bc, $0101
ld bc, $0101
ld bc, $0101
add a, c
add a, c
add a, c
add a, c
add a, c
add a, c
add a, c
add a, c
add a, c
add a, c
add a, c
add a, c
add a, c
add a, c
add a, c
add a, c
add a, c
add a, c
rst 38
nop
cpl
nop
ldh a, [$ff00 + $00]
jp .l_1f00
nop
<error>
nop
rrc a
nop
rlc a
nop
rst 38
nop
ldh [$ff00 + $00], a
ccf
nop
di
nop
nop
nop
cp $00
rlc a
nop
<error>
nop
nop
nop
ld [bc], a
nop
ldhl sp, d
nop
ccf
nop
nop
nop
add a, b
nop
inc b
nop
ld bc, $7f00
nop
nop
nop
nop
nop
add a, a
nop
ld a, h
nop
add a, b
nop
nop
nop
push af
nop
inc bc
inc bc
dec b
ld b, $ff
rlc a
ccf
nop
nop
nop
add a, a
rlc a
ld e, $18
dec sp
daa
rst 0
add a, a
ld a, d
adc a, $fc
<error>
rst 38
jr nc, 0.l_20d5
stop
ldhl sp, d
ret nc
ldh a, [$ff00 + $30]
<error>
ldh a, [$ff00 + $3f]
nop
rrc a
nop
rlc a
nop
rlc a
nop
inc bc
nop
inc bc
nop
nop
nop
nop
nop
rst 38
nop
rst 38
nop
rst 38
nop
rst 38
nop
rst 38
nop
rst 38
nop
rr a
nop
rlc a
nop
rst 38
nop
rst 38
nop
rst 38
nop
cp $00
<error>
nop
<error>
nop
ldhl sp, d
nop
ldhl sp, d
nop
<error>
nop
ldh [$ff00 + $00], a
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
ldhl sp, d
nop
ldh [$ff00 + $00], a
ret nz
nop
add a, b
nop
add a, c
ld bc, $0302
ld [bc], a
inc bc
inc b
rlc a
ld bc, $1f01
rr a
ld h, e
ld a, h
add a, b
rst 38
nop
rst 38
inc bc
rst 38
inc e
rst 38
ld h, e
<error>
ldhl sp, d
ldhl sp, d
sbc a, $e6
<error>
dec sp
dec [hl]
rst 8
rlc a
rst 38
rst 38
cp $ee
inc e
ld b, $fc
ld a, a
ld a, a
sbc a, h
<error>
ld a, $ff
ld d, e
pop hl
and c
ret nz
and c
ret nz
or e
ret nz
sbc a, a
ldh [$ff00 + $07], a
rlc a
<error>
call c, func_f32f
xor l
cp $70
rst 38
ld a, a
rst 18
ld e, [hl]
rst 8
ld e, b
rst 8
ldh [$ff00 + $e0], a
ld a, [hl]
cp $b1
rst 8
ret nz
ccf
nop
rst 38
<error>
rst 38
ld a, e
add a, a
ld b, $f9
<error>
nop
inc bc
nop
ldh a, [$ff00 + $00]
nop
nop
rrc a
nop
ldh a, [$ff00 + $00]
rr a
nop
ld sp, hl
nop
nop
nop
rst 38
nop
nop
nop
rr a
nop
ldh [$ff00 + $00], a
rlc a
nop
ldhl sp, d
nop
add a, b
nop
rst 38
nop
<error>
nop
rlc a
nop
ld b, b
nop
nop
nop
ld [bc], a
nop
nop
nop
nop
nop
add a, b
nop
inc bc
nop
rst 38
nop
ldhl sp, d
nop
ld bc, $0000
nop
nop
nop
ld b, b
nop
rst 28
ld e, h
sub a, h
ei
and e
rst 38
cp $ff
<error>
ld [hl], e
ld h, c
nop
nop
nop
nop
nop
ld a, b
jr 0.l_216e
<error>
<error>
<error>
ld e, $f8
ld sp, hl
ldh [$ff00 + $e0], a
nop
nop
nop
ld b, b
nop
inc bc
nop
ld bc, $0100
nop
ld bc, $0000
nop
nop
nop
nop
nop
nop
nop
ldhl sp, d
nop
ret nz
nop
add a, b
nop
add a, b
nop
add a, b
nop
nop
nop
nop
nop
nop
nop
rrc a
rrc a
rst 38
jr nc, 0.l_217e
add a, $b7
ldhl sp, d
sbc a, a
ldh a, [$ff00 + $5c]
di
cp b
ld a, a
ld a, a
ld a, a
rst 38
rst 38
rst 38
nop
rst 38
nop
rst 38
nop
add a, e
ld a, h
nop
rst 38
rst 38
rst 38
ld h, d
add a, c
dec b
rlc a
rlc a
rlc a
inc b
rlc a
ld [$180f], sp
rl a
jr nc, 0.l_21db
jr nc, 0.l_21ed
ld [$800f], sp
rst 38
inc bc
rst 38
rlc a
rst 38
inc c
rst 38
add hl, de
cp $30
rst 38
jr nz, 0.l_21bd
ld b, b
rst 38
rst 38
<error>
push bc
cp $36
rst 8
rst 0
ccf
inc b
rst 38
dec de
<error>
inc [hl]
ei
add hl, hl
rst 30
ld b, b
rst 38
cp a
ld a, a
ld d, c
ldh [$ff00 + $d1], a
ldh [$ff00 + $4e], a
pop af
ld h, c
rst 38
rst 38
rst 38
adc a, [hl]
rst 38
rst 28
rst 18
ld c, c
cp $38
rst 38
ld a, [hl]
rst 38
ld b, a
rst 38
jp [hl]
rst 30
inc [hl]
ei
ld [de], a
<error>
pop hl
cp $d8
ccf
ld a, $cf
dec bc
rst 30
ld bc, $80ff
rst 38
ret nz
rst 38
ret nz
rst 38
rlc a
nop
inc bc
nop
add a, c
add a, b
ld b, c
ret nz
jr nz, 0.l_21ea
jr nz, 0.l_21ec
sub a, b
ldh a, [$ff00 + $d0]
ldh a, [$ff00 + $38]
ccf
ld h, b
ld e, a
ld b, c
ld a, a
ld [hl], d
ld a, a
ld a, [bc]
rrc a
<error>
rst 38
<error>
sbc a, a
add a, h
rst 38
add a, b
rst 38
add a, b
rst 38
nop
rst 38
ld bc, $01ff
rst 38
inc bc
rst 38
inc bc
rst 38
inc bc
rst 38
ld h, c
rst 38
jp .l_83ff
rst 38
add a, d
rst 38
add a, [hl]
rst 38
ld b, $ff
inc b
rst 38
<error>
rst 38
and h
rst 18
inc h
rst 18
inc h
rst 18
inc b
rst 38
rlc a
rst 38
rlc a
cp $06
<error>
inc b
rst 38
ld e, d
cp l
jr z, 0.l_2233
jr z, 0.l_2235
inc c
rst 38
add a, h
rst 38
add a, h
ld a, a
ld b, $ff
ld [bc], a
rst 38
ldh [$ff00 + $ff], a
ld h, b
rst 38
jr nc, 0.l_2265
jr nc, 0.l_2267
jr nc, 0.l_2269
stop
rst 38
stop
rst 38
stop
rst 38
ld hl, $21ff
rst 38
rl a
rst 38
inc d
<error>
ld d, $fa
dec bc
<error>
add hl, bc
rst 38
add hl, bc
rst 38
ld c, b
rst 38
ld c, b
rst 38
ld b, c
rst 38
ld hl, $21ff
rst 38
ld de, $09ff
rst 38
rlc a
rst 38
rst 38
rst 38
cp a
rst 38
cp a
rst 38
rr a
rst 38
rr a
rst 38
ld c, $ff
inc b
rst 38
nop
rst 38
stop
rst 38
stop
rst 38
stop
rst 38
stop
rst 38
inc de
rst 38
sub a, b
rst 38
sub a, b
rst 38
add a, b
rst 38
rrc a
rst 38
rrc a
rst 38
rrc a
cp $1f
cp $9e
rst 38
rst 38
rst 38
rst 38
ld a, a
ld a, a
rst 38
add a, d
rst 38
add a, d
ld a, a
ld [bc], a
rst 38
ld [bc], a
rst 38
ld [de], a
rst 38
jr nc, 0.l_22cb
ldh [$ff00 + $ff], a
pop bc
rst 38
ccf
rst 38
ccf
rst 38
ccf
rst 38
rst 38
rst 38
ld a, [hl]
rst 38
ld l, h
rst 38
ret nz
rst 38
add a, b
rst 38
pop hl
rst 18
pop bc
cp a
add a, d
rst 38
add a, d
rst 38
call nz, func_44ff
rst 38
ld c, b
rst 38
ld [hl], b
rst 38
nop
nop
nop
nop
inc h
inc h
jr 0.l_2310
jr 0.l_2312
inc h
inc h
nop
nop
nop
nop
jr nc, 0.l_22f2
ld [$04f8], sp
<error>
inc b
<error>
add a, d
cp $c2
cp $42
cp $61
rst 38
adc a, h
rst 38
adc a, c
rst 38
adc a, c
rst 38
adc a, b
rst 38
adc a, b
rst 38
adc a, b
rst 38
adc a, b
rst 38
ld c, b
rst 38
inc bc
rst 38
add a, a
rst 38
rst 0
cp $e6
rst 38
cp $7f
ld a, [hl]
cp a
ld a, $ff
ld a, [hl]
rst 38
call z, func_c8ff
ccf
ld [$08ff], sp
rst 38
ld [$08ff], sp
rst 38
ld [$10ff], sp
rst 38
inc b
rst 38
inc b
rst 38
<error>
rst 38
inc a
rst 38
inc a
rst 8
inc e
rst 28
inc c
rst 38
rrc a
rst 38
ld [bc], a
rst 38
ld [bc], a
rst 38
ld [bc], a
rst 38
ld [bc], a
rst 38
ld [bc], a
rst 38
ldi [hl], a
rst 38
ldh [c], a
rst 38
jp nz, .l_11ff
rst 38
rl a
rst 38
rr a
rst 38
cp $fd
ld a, h
ei
jr c, 0.l_236b
inc a
rst 38
ld a, $ff
ret
rst 38
adc a, c
rst 38
add hl, bc
rst 38
add hl, bc
rst 38
add hl, bc
rst 38
add hl, bc
rst 38
add hl, bc
rst 38
ld l, c
rst 38
ldh a, [$ff00 + $e0]
rst 18
ccf
rst 38
nop
rst 38
nop
rst 38
nop
rr a
ldh [$ff00 + $c0], a
rst 38
ccf
rst 38
nop
nop
rst 38
rst 38
rst 38
nop
rst 38
nop
rst 38
nop
jp .l_003c
rst 38
rst 38
rst 38
add a, b
rst 38
pop bc
rst 38
jp .l_e7ff
rst 38
cp [hl]
rst 38
cp h
rst 38
sbc a, e
<error>
and a
ret c
rst 38
rst 38
rst 38
rst 38
pop bc
rst 38
sbc a, [hl]
pop hl
ld a, a
add a, b
ld [bc], a
<error>
nop
rst 38
sub a, b
ld l, a
add a, c
rst 38
pop bc
rst 38
<error>
rst 38
rst 20
rst 38
ccf
rst 38
dec e
rst 38
ld c, c
cp a
pop hl
rr a
cp a
ret nz
<error>
<error>
pop bc
cp $c1
cp $c8
rst 30
sbc a, h
<error>
cp [hl]
pop bc
cp [hl]
pop bc
rst 38
nop
rst 38
nop
rst 38
nop
rst 38
nop
sub a, d
ld l, l
nop
rst 38
nop
rst 38
inc a
jp .l_03fd
ld sp, hl
rlc a
pop af
rrc a
and c
ld e, a
dec b
ei
dec c
di
cpl
<error>
rst 38
inc bc
cp $00
inc bc
nop
inc e
nop
ldh [c], a
ld bc, $0001
ld b, $01
jr nc, 0.l_241d
ret nz
ccf
rst 38
ld bc, $0181
ldd [hl], a
rrc a
rrc a
<error>
cp a
ld [hl], b
ccf
ldh [$ff00 + $5f], a
ldh [$ff00 + $5f], a
ldh [$ff00 + $bf], a
ret nz
ccf
ret nz
cpl
ret nc
rrc a
ldh a, [$ff00 + $07]
ldhl sp, d
ldh [c], a
dec e
ldh [$ff00 + $1f], a
ldh a, [$ff00 + $0f]
rst 38
nop
rst 38
nop
rst 38
nop
rst 38
nop
ccf
ret nz
add hl, de
and $00
rst 38
ldh [$ff00 + $1f], a
<error>
inc bc
<error>
inc bc
ldhl sp, d
rlc a
ldhl sp, d
rlc a
or b
ld c, a
ld bc, $03fe
<error>
rlc a
ldhl sp, d
rst 38
nop
pop bc
add a, b
call z, func_f070
ccf
<error>
ld c, $fc
rlc a
ld a, [$fa07]
rlc a
ld a, a
nop
ret nz
nop
jr c, 0.l_2466
ld b, a
add a, b
add a, b
nop
ld h, b
add a, b
inc c
ldh a, [$ff00 + $03]
<error>
ld b, b
ccf
jr nc, 0.l_2483
sub a, [hl]
ld bc, $033c
stop
rrc a
jr c, 0.l_2483
rst 38
nop
rrc a
nop
ld b, e
<error>
ld h, c
cp $3c
rst 38
ld [bc], a
rst 38
ld bc, $00ff
rst 38
ret nz
ccf
ld c, $01
ld sp, hl
ld b, $ff
nop
rst 38
nop
ld a, a
add a, b
inc e
<error>
rst 0
rst 38
ld a, b
rst 38
nop
rst 38
ldh a, [$ff00 + $0f]
ld sp, hl
ld b, $ff
nop
rst 38
nop
ld a, [hl]
add a, c
cp l
jp $ffff
nop
rst 38
rst 8
jr nc, 0.l_24b2
nop
rst 38
nop
cp $01
inc a
jp .l_ffe3
ld e, $ff
nop
rst 38
jp nz, .l_863f
ld a, a
inc a
rst 38
ld b, b
rst 38
add a, b
rst 38
nop
rst 38
inc bc
<error>
ld [hl], b
add a, b
ld [bc], a
<error>
inc c
ldh a, [$ff00 + $69]
add a, b
inc a
ret nz
ld [$1cf0], sp
ldh [$ff00 + $ff], a
nop
ldh a, [$ff00 + $00]
rr a
rrc a
rst 30
ldhl sp, d
rst 38
nop
rst 38
nop
rst 38
nop
add a, b
ld a, a
rst 38
rst 38
inc a
jp .l_fcfc
ld a, [$890e]
ld a, a
ld sp, hl
rrc a
rst 38
rlc a
ld a, [hl]
add a, a
dec b
cp $fd
cp $00
nop
nop
rst 38
add a, c
ld a, $18
rst 20
nop
rst 38
jr nc, 0.l_24db
nop
rst 38
inc bc
<error>
nop
nop
nop
rst 38
adc a, h
ld [hl], e
nop
rst 38
ld b, b
sbc a, a
nop
rst 38
nop
rst 38
ld b, $f9
nop
rst 38
nop
rst 38
nop
rst 38
jr nc, 0.l_24f7
nop
rst 38
nop
rst 38
nop
rst 38
nop
rst 38
nop
rst 38
nop
rst 38
nop
rst 38
ld h, b
sbc a, a
nop
rst 38
nop
rst 38
nop
rst 38
nop
rst 38
ld bc, $2cfe
<error>
nop
rst 38
nop
rst 38
nop
rst 38
nop
rst 38
ld [hl], d
adc a, h
add hl, de
ldh [$ff00 + $c0], a
ccf
inc [hl]
rlc b
rst 38
nop
rst 38
nop
rst 38
nop
rst 38
jr nz, 0.l_257d
jp nz, .l_0401
inc bc
inc bc
rst 38
rst 38
rst 38
ldh a, [$ff00 + $ff]
nop
rst 38
nop
rst 38
rlc a
ldhl sp, d
dec sp
call nz, func_f804
ldh [$ff00 + $ff], a
rst 38
rst 38
rrc a
rst 38
nop
rst 38
nop
rst 38
ldh [$ff00 + $1f], a
<error>
inc bc
nop
nop
nop
rst 38
ld [hl], b
adc a, a
ld [bc], a
ld sp, hl
nop
rst 38
nop
rst 38
inc c
di
nop
rst 38
nop
nop
nop
rst 38
jp nz, .l_003c
rst 38
jr nc, 0.l_2569
nop
rst 38
nop
rst 38
ld bc, $00fe
rst 38
nop
rst 38
nop
rst 38
ld bc, $40fe
cp a
nop
rst 38
nop
rst 38
nop
rst 38
nop
rst 38
nop
rst 38
nop
rst 38
add a, b
ld a, a
ld [bc], a
<error>
nop
rst 38
nop
rst 38
nop
rst 38
nop
rst 38
ld h, c
sbc a, [hl]
rlc a
ldhl sp, d
<error>
inc bc
nop
rst 38
nop
rst 38
nop
rst 38
ld h, b
sbc a, a
nop
rst 38
jp nz, .l_383d
rst 0
rlc a
ldhl sp, d
nop
rst 38
nop
rst 38
nop
rst 38
jr c, 0.l_25a7
jr 0.l_25c2
rlc a
nop
ldh a, [$ff00 + $0f]
nop
rst 38
nop
rst 38
rlc a
ldhl sp, d
ccf
ret nz
ei
inc b
jr nz, 0.l_2611
pop bc
ld c, $30
ret nz
ld b, $f9
nop
rst 38
add a, b
ld a, a
ldh a, [$ff00 + $0f]
rst 38
nop
nop
nop
nop
rst 38
jr nc, 0.l_25d4
nop
rst 38
ld b, $f9
nop
rst 38
nop
rst 38
add a, b
ld a, a
nop
nop
nop
rst 38
add a, d
ld a, h
jr 0.l_25ff
nop
rst 38
nop
rst 38
nop
rst 38
inc c
di
nop
rst 38
nop
rst 38
nop
rst 38
inc c
di
nop
rst 38
nop
rst 38
nop
rst 38
nop
rst 38
nop
rst 38
nop
rst 38
nop
rst 38
nop
rst 38
ld [bc], a
<error>
nop
rst 38
nop
rst 38
nop
rst 38
nop
rst 38
nop
rst 38
jr nc, 0.l_2615
rlc a
ldhl sp, d
adc a, [hl]
ld [hl], c
ldhl sp, d
rlc a
nop
rst 38
nop
rst 38
nop
rst 38
nop
rst 38
ld b, $f9
ldh a, [$ff00 + $0f]
ccf
ret nz
nop
rst 38
nop
rst 38
nop
rst 38
nop
rst 38
nop
rst 38
inc c
di
ld [hl], e
adc a, h
jr 0.l_264a
inc b
nop
rst 38
nop
rst 38
nop
nop
rst 38
nop
rst 38
add hl, de
and $e6
add hl, de
dec c
nop
jr nc, 0.l_267c
rst 38
nop
rst 38
nop
nop
nop
nop
rst 38
jp .l_003c
rst 38
inc c
di
nop
rst 38
nop
rst 38
jr nc, 0.l_265f
nop
nop
nop
rst 38
ld a, [bc]
pop af
jr nz, 0.l_2637
nop
rst 38
nop
rst 38
nop
rst 38
ret nz
ccf
nop
rst 38
nop
rst 38
nop
rst 38
nop
rst 38
ld h, b
sbc a, a
nop
rst 38
nop
rst 38
ld bc, $00fe
rst 38
nop
rst 38
nop
rst 38
nop
rst 38
jr 0.l_26a1
nop
rst 38
nop
rst 38
ret nz
ccf
nop
rst 38
nop
rst 38
nop
rst 38
nop
rst 38
ld b, b
cp a
jr 0.l_26ac
ret z
rlc a
ld h, b
sbc a, a
nop
rst 38
nop
rst 38
nop
rst 38
nop
rst 38
nop
rst 38
ld [hl], b
rrc a
jr 0.l_26be
ld c, $f1
rrc a
rst 38
ldh [$ff00 + $ff], a
nop
rst 38
nop
rst 38
rst 0
jr c, 0.l_2723
rst 0
call nz, func_1738
ldh [$ff00 + $e0], a
rst 38
rrc a
rst 38
nop
rst 38
nop
rst 38
pop bc
ld a, $3c
jp .l_1867
call nz, func_0303
nop
inc b
inc bc
add hl, sp
rlc a
ld b, b
ccf
ld b, b
ccf
jr nz, 0.l_272b
jr nc, 0.l_271d
jr nz, 0.l_272f
stop
rrc a
jr nz, 0.l_2733
jr nz, 0.l_2735
jr nc, 0.l_2727
inc e
inc bc
inc de
inc c
ld [$0707], sp
nop
inc bc
nop
rlc a
inc bc
dec de
inc b
dec a
inc de
add hl, sp
rl a
jr c, 0.l_2743
add hl, hl
rl a
jr 0.l_2737
inc d
dec bc
ldi [hl], a
dec e
ld hl, $381e
rlc a
jr 0.l_2749
rl a
rrc a
ld [$0707], sp
nop
ret nz
nop
ldh [$ff00 + $c0], a
ldhl sp, d
jr nz, 0.l_2783
ret z
inc e
add sp, d
ld e, h
xor b
inc [hl]
ret z
sbc a, b
ldh [$ff00 + $18], a
ldh [$ff00 + $14], a
add sp, d
inc h
ret c
call z, func_1830
ldh a, [$ff00 + $e8]
ldh a, [$ff00 + $10]
ldh [$ff00 + $e0], a
nop
rrc a
nop
ld [hl], $0f
ld h, b
ccf
ld d, b
cpl
inc sp
inc c
rr a
ld [bc], a
rr a
ld a, [bc]
ccf
ld e, $2e
dec e
inc d
dec bc
inc c
inc bc
inc d
dec bc
dec de
inc b
stop
rrc a
ld [$0707], sp
nop
add a, b
nop
ld b, b
add a, b
jr nc, 0.l_2746
ld [$04f0], sp
ldhl sp, d
inc b
ldhl sp, d
ld [$04f0], sp
ldhl sp, d
inc b
ldhl sp, d
ld [bc], a
<error>
ld [bc], a
<error>
ld [bc], a
<error>
inc b
ldhl sp, d
ldhl sp, d
nop
stop
ldh [$ff00 + $e0], a
nop
nop
nop
nop
nop
ld b, h
nop
jr z, 0.l_27a8
stop
nop
jr z, 0.l_27ac
ld b, h
nop
nop
nop
nop
nop
nop
nop
ld b, h
nop
jr z, 0.l_27b8
stop
nop
jr z, 0.l_27bc
ld b, h
nop
nop
nop
nop
nop
nop
nop
nop
nop
ld bc, $0f00
ld bc, $0e1f
ld c, $00
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
ld bc, $0300
ld bc, $0207
ld c, $04
ld c, $04
inc b
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
jr c, 0.l_2806
ld a, h
jr c, 0.l_27a7
ld a, h
sbc a, a
ld h, [hl]
rst 30
inc bc
rlc a
inc bc
ld [bc], a
ld bc, $0001
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
jr c, 0.l_2822
ld a, h
jr c, 0.l_27e3
ld a, h
sbc a, [hl]
ld a, h
sbc a, [hl]
ld h, h
ld l, a
ld b, $07
inc bc
rlc a
inc bc
ld [bc], a
ld bc, $0001
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
ldh [$ff00 + $00], a
sub a, b
ld h, b
sub a, b
ld h, b
ldhl sp, d
ld [hl], b
ld a, b
jr nc, 0.l_288a
jr 0.l_286c
rrc a
rrc a
rlc a
ld b, $01
ld bc, $0000
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
ld h, b
nop
sub a, b
ld h, b
sub a, c
ld h, b
rst 28
ld [hl], c
rst 38
ccf
ld a, $19
add hl, de
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
ld bc, $0300
ld bc, $0307
ld b, $03
rlc a
ld [bc], a
rrc a
ld b, $1f
ld c, $7e
inc e
sbc a, [hl]
ld a, h
adc a, h
ld a, b
ldhl sp, d
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
inc bc
nop
rrc a
inc bc
rr a
rrc a
ld a, $19
ld a, l
jr c, 0.l_292d
jr nc, 0.l_28af
ld [hl], b
adc a, b
ld [hl], b
adc a, b
ld [hl], b
ld c, b
jr nc, 0.l_28f7
nop
nop
nop
ld [bc], a
nop
rlc a
ld [bc], a
rlc a
ld [bc], a
rrc a
dec b
dec c
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
inc c
nop
ld e, $0c
rrc a
ld [bc], a
inc bc
ld bc, $0001
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
rst 38
nop
rst 38
ld b, d
rst 38
inc h
rst 38
jr 0.l_2908
jr 0.l_290a
inc h
rst 38
ld b, d
rst 38
nop
rst 38
nop
rst 38
ld b, d
rst 38
inc h
rst 38
jr 0.l_2918
jr 0.l_291a
inc h
rst 38
ld b, d
rst 38
nop
rst 38
nop
rst 38
ld b, d
rst 38
inc h
rst 38
jr 0.l_2928
jr 0.l_292a
inc h
rst 38
ld b, d
rst 38
nop
rst 38
nop
rst 38
ld b, d
rst 38
inc h
rst 38
jr 0.l_2938
jr 0.l_293a
inc h
rst 38
ld b, d
rst 38
nop
rst 38
nop
rst 38
ld b, d
rst 38
inc h
rst 38
jr 0.l_2948
jr 0.l_294a
inc h
rst 38
ld b, d
rst 38
nop
rst 38
nop
rst 38
ld b, d
rst 38
inc h
rst 38
jr 0.l_2958
jr 0.l_295a
inc h
rst 38
ld b, d
rst 38
nop
rst 38
nop
rst 38
ld b, d
rst 38
inc h
rst 38
jr 0.l_2968
jr 0.l_296a
inc h
rst 38
ld b, d
rst 38
nop
rst 38
nop
rst 38
ld b, d
rst 38
inc h
rst 38
jr 0.l_2978
jr 0.l_297a
inc h
rst 38
ld b, d
rst 38
nop
rst 38
nop
rst 38
ld b, d
rst 38
inc h
rst 38
jr 0.l_2988
jr 0.l_298a
inc h
rst 38
ld b, d
rst 38
nop
rst 38
nop
rst 38
ld b, d
rst 38
inc h
rst 38
jr 0.l_2998
jr 0.l_299a
inc h
rst 38
ld b, d
rst 38
nop
rst 38
nop
rst 38
ld b, d
rst 38
inc h
rst 38
jr 0.l_29a8
jr 0.l_29aa
inc h
rst 38
ld b, d
rst 38
nop
rst 38
nop
rst 38
ld b, d
rst 38
inc h
rst 38
jr 0.l_29b8
jr 0.l_29ba
inc h
rst 38
ld b, d
rst 38
nop
rst 38
nop
rst 38
ld b, d
rst 38
inc h
rst 38
jr 0.l_29c8
jr 0.l_29ca
inc h
rst 38
ld b, d
rst 38
nop
rst 38
nop
rst 38
ld b, d
rst 38
inc h
rst 38
jr 0.l_29d8
jr 0.l_29da
inc h
rst 38
ld b, d
rst 38
nop
rst 38
nop
rst 38
ld b, d
rst 38
inc h
rst 38
jr 0.l_29e8
jr 0.l_29ea
inc h
rst 38
ld b, d
rst 38
nop
rst 38
nop
rst 38
ld b, d
rst 38
inc h
rst 38
jr 0.l_29f8
jr 0.l_29fa
inc h
rst 38
ld b, d
rst 38
nop
nop
nop
ld a, [hl]
nop
rst 38
inc a
rst 38
ld h, [hl]
rst 38
ld h, [hl]
rst 38
ld h, [hl]
rst 38
ld h, [hl]
rst 38
ld h, [hl]
nop
nop
cp $00
rst 38
ld a, h
rst 38
ld h, [hl]
rst 38
ld h, [hl]
rst 38
ld h, [hl]
rst 38
ld h, [hl]
cp $7c
nop
nop
ld a, [hl]
nop
rst 38
inc a
rst 38
ld h, [hl]
rst 38
ld h, [hl]
rst 38
ld h, [hl]
rst 38
ld h, b
ldh a, [$ff00 + $60]
nop
nop
<error>
nop
cp $78
rst 38
ld h, h
rst 38
ld h, [hl]
rst 38
ld h, [hl]
rst 38
ld h, [hl]
rst 38
ld h, [hl]
nop
nop
rst 38
nop
rst 38
ld a, [hl]
rst 38
ld h, b
ldh a, [$ff00 + $60]
ldh a, [$ff00 + $60]
cp $60
cp $7c
rst 38
inc a
ld a, [hl]
jr 0.l_2a91
jr 0.l_2a93
jr 0.l_2a95
jr 0.l_2a97
jr 0.l_2a99
nop
nop
nop
cp $7c
rst 38
ld h, [hl]
rst 38
ld h, [hl]
rst 38
ld h, [hl]
rst 38
ld h, [hl]
rst 38
ld h, [hl]
rst 38
nop
nop
nop
nop
nop
ld a, [hl]
nop
ld a, [hl]
inc a
inc a
jr 0.l_2ab5
jr 0.l_2ab7
jr 0.l_2ab9
jr 0.l_2abb
jr 0.l_2a81
nop
ccf
nop
ccf
ld e, $3f
inc c
ld e, $0c
ld e, $0c
ld e, $0c
ld e, $0c
nop
nop
rst 38
nop
rst 38
ld h, [hl]
rst 38
ld h, [hl]
cp $6c
<error>
ld a, b
ldhl sp, d
ld [hl], b
ldhl sp, d
ld [hl], b
nop
nop
rst 30
nop
rst 30
ld h, d
rst 38
ld h, d
rst 38
halt
rst 38
ld a, [hl]
rst 38
ld a, [hl]
rst 38
ld a, [hl]
nop
nop
rst 30
nop
rst 30
ld h, d
rst 38
ld h, d
rst 38
ld [hl], d
rst 38
ld [hl], d
rst 38
ld a, d
rst 38
ld a, d
nop
nop
ld a, [hl]
nop
rst 38
inc a
rst 38
ld h, [hl]
rst 38
ld h, [hl]
rst 38
ld h, [hl]
rst 38
ld h, b
ld a, [hl]
inc a
nop
nop
rst 38
nop
rst 38
ld a, [hl]
rst 38
jr 0.l_2b15
jr 0.l_2b17
jr 0.l_2b19
jr 0.l_2b1b
jr 0.l_2ae1
nop
rst 38
nop
rst 38
ld l, d
rst 38
ld l, d
rst 38
ld l, d
rst 38
ld l, d
rst 38
ld l, d
rst 38
ld l, d
rst 38
nop
rst 38
ld l, d
rst 38
ld l, d
rst 38
ld l, d
rst 38
ld l, d
rst 38
ld a, [hl]
rst 38
inc d
ld a, [hl]
nop
rst 38
ld a, [hl]
rst 38
ld h, [hl]
rst 38
ld h, [hl]
rst 38
ld h, [hl]
rst 38
ld h, [hl]
rst 38
ld h, [hl]
rst 38
nop
nop
nop
rst 38
ld h, [hl]
rst 38
ld h, [hl]
rst 38
ld h, [hl]
rst 38
ld h, [hl]
rst 38
ld h, [hl]
rst 38
ld a, h
cp $00
nop
nop
rst 38
ld h, b
rst 38
ld l, [hl]
rst 38
ld h, [hl]
rst 38
ld h, [hl]
rst 38
ld h, [hl]
rst 38
ldd a, [hl]
ld a, [hl]
nop
nop
nop
rst 38
ld h, [hl]
rst 38
ld h, [hl]
rst 38
ld h, [hl]
rst 38
ld h, [hl]
rst 38
ld h, h
cp $78
<error>
nop
nop
nop
cp $60
ldh a, [$ff00 + $60]
ldh a, [$ff00 + $60]
ldh a, [$ff00 + $60]
rst 38
ld h, b
rst 38
ld a, [hl]
rst 38
nop
nop
nop
cp $60
ldh a, [$ff00 + $60]
ldh a, [$ff00 + $60]
ldh a, [$ff00 + $60]
ldh a, [$ff00 + $60]
ldh a, [$ff00 + $60]
ldh a, [$ff00 + $00]
nop
nop
rst 38
ld h, [hl]
rst 38
ld h, [hl]
rst 38
ld h, [hl]
rst 38
ld h, [hl]
rst 38
ld h, [hl]
rst 38
ld h, [hl]
rst 38
nop
nop
nop
nop
nop
rst 38
nop
rst 38
ld a, [hl]
rst 38
ld c, $3f
ld c, $3f
inc e
ld a, $1c
ld a, [hl]
inc e
ld e, $0c
cp $0c
cp $6c
cp $6c
cp $6c
cp $38
ld a, h
nop
nop
nop
<error>
ld a, b
<error>
ld a, b
cp $6c
cp $6c
rst 38
ld h, [hl]
rst 38
ld h, [hl]
rst 38
nop
nop
nop
rst 38
ld a, [hl]
rst 38
ld l, d
rst 38
ld l, d
rst 38
ld l, d
rst 38
ld h, d
rst 30
ld h, d
rst 30
nop
nop
nop
rst 38
ld l, [hl]
rst 38
ld l, [hl]
rst 38
ld h, [hl]
rst 38
ld h, [hl]
rst 38
ld h, d
rst 30
ld h, d
rst 30
nop
nop
nop
rst 38
ld b, $ff
ld h, [hl]
rst 38
ld h, [hl]
rst 38
ld h, [hl]
rst 38
ld h, [hl]
rst 38
inc a
ld a, [hl]
nop
nop
nop
inc a
jr 0.l_2c0f
jr 0.l_2c11
jr 0.l_2c13
jr 0.l_2c15
jr 0.l_2c17
jr 0.l_2c19
nop
nop
nop
rst 38
ld l, d
rst 38
ld l, d
rst 38
ld a, [hl]
rst 38
ld a, [hl]
rst 38
ld a, $7f
inc d
ld a, $00
nop
nop
rst 30
nop
rst 38
ld h, d
rst 38
ld [hl], h
cp $38
ld a, a
inc e
rst 38
ld l, $ff
ld b, [hl]
rst 28
nop
jr 0.l_2c02
inc a
jr 0.l_2c83
inc h
rst 38
ld h, [hl]
rst 38
ld a, [hl]
rst 38
ld h, [hl]
rst 38
ld h, [hl]
rst 38
nop
inc a
nop
ld a, [hl]
inc a
rst 38
ld h, [hl]
rst 38
ld h, b
rst 38
ld h, b
rst 38
ld h, [hl]
ld a, [hl]
inc a
inc a
nop
ldhl sp, d
nop
<error>
ld a, b
cp $64
rst 38
ld h, [hl]
rst 38
ld h, [hl]
cp $64
<error>
ld a, b
ldhl sp, d
nop
rst 38
nop
rst 38
ld a, [hl]
rst 38
ld h, b
cp $7c
cp $60
rst 38
ld h, b
rst 38
ld a, [hl]
rst 38
nop
ld a, [hl]
nop
rst 38
inc a
rst 38
ld h, [hl]
rst 38
ld h, b
rst 38
ld l, [hl]
rst 38
ld h, [hl]
rst 38
ld a, $7e
nop
rst 38
nop
rst 38
ld h, [hl]
rst 38
ld h, [hl]
rst 38
ld a, [hl]
rst 38
ld h, [hl]
rst 38
ld h, [hl]
rst 38
ld h, [hl]
rst 38
nop
ld a, [hl]
nop
ld a, [hl]
inc a
inc a
jr 0.l_2ca3
jr 0.l_2ca5
jr 0.l_2ca7
jr 0.l_2ceb
inc a
ld a, [hl]
nop
rst 38
nop
rst 38
ld h, [hl]
rst 38
ld l, h
cp $78
cp $78
rst 38
ld l, h
rst 38
ld h, [hl]
rst 38
nop
ldh a, [$ff00 + $00]
ldh a, [$ff00 + $60]
ldh a, [$ff00 + $60]
ldh a, [$ff00 + $60]
ldh a, [$ff00 + $60]
rst 38
ld h, b
rst 38
ld a, [hl]
rst 38
nop
<error>
nop
rst 30
ld h, d
rst 38
halt
rst 38
ld a, [hl]
rst 38
ld l, d
rst 38
ld h, d
rst 30
ld h, d
rst 30
nop
rst 20
nop
rst 30
ld h, d
rst 38
ld [hl], d
rst 38
ld a, d
rst 38
ld l, [hl]
rst 38
ld h, [hl]
rst 30
ld h, d
di
nop
inc a
nop
ld a, [hl]
inc a
rst 38
ld h, [hl]
rst 38
ld h, [hl]
rst 38
ld h, [hl]
rst 38
ld h, [hl]
ld a, [hl]
inc a
inc a
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
ld bc, $0200
ld bc, $0205
rlc a
ld bc, $0206
inc b
nop
inc b
nop
ld e, $00
ld [de], a
nop
add hl, hl
stop
jr z, 0.l_2cf0
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
ret nz
nop
jr nz, 0.l_2cae
sub a, b
ld h, b
ld h, b
add a, b
jr nz, 0.l_2d34
jr nz, 0.l_2cf6
jr nz, 0.l_2cf8
ld a, b
nop
ld c, b
nop
ld [hl], h
ld [$08f4], sp
<error>
nop
cp $7c
rst 38
ld h, [hl]
rst 38
ld h, [hl]
cp $7c
<error>
ld h, b
ldh a, [$ff00 + $60]
ldh a, [$ff00 + $00]
<error>
nop
cp $7c
rst 38
ld h, [hl]
rst 38
ld h, [hl]
cp $7c
cp $6c
rst 38
ld h, [hl]
rst 30
nop
ld a, $00
ld a, [hl]
inc a
<error>
ld h, b
ld a, [hl]
inc a
rst 38
ld b, $ff
ld h, [hl]
ld a, [hl]
inc a
inc a
nop
rst 38
nop
rst 38
ld a, [hl]
rst 38
jr 0.l_2d73
jr 0.l_2d75
jr 0.l_2d77
jr 0.l_2d79
jr 0.l_2d7b
nop
rst 20
nop
rst 38
ld h, [hl]
rst 38
ld h, [hl]
rst 38
ld h, [hl]
rst 38
ld h, [hl]
rst 38
ld h, [hl]
ld a, [hl]
inc a
inc a
nop
rst 38
nop
rst 38
ld h, [hl]
rst 38
ld h, [hl]
rst 38
ld h, [hl]
rst 38
inc h
ld a, [hl]
inc a
ld a, [hl]
jr 0.l_2d9b
nop
rst 38
nop
rst 38
ld b, d
rst 38
inc h
rst 38
jr 0.l_2d68
jr 0.l_2d6a
inc h
rst 38
ld b, d
rst 38
nop
rst 38
nop
rst 38
ld b, d
rst 38
inc h
rst 38
jr 0.l_2d78
jr 0.l_2d7a
inc h
rst 38
ld b, d
rst 38
nop
rst 38
nop
rst 38
ld b, d
rst 38
inc h
rst 38
jr 0.l_2d88
jr 0.l_2d8a
inc h
rst 38
ld b, d
rst 38
nop
rst 38
nop
rst 38
ld b, d
rst 38
inc h
rst 38
jr 0.l_2d98
jr 0.l_2d9a
inc h
rst 38
ld b, d
rst 38
nop
rst 38
nop
rst 38
ld b, d
rst 38
inc h
rst 38
jr 0.l_2da8
jr 0.l_2daa
inc h
rst 38
ld b, d
rst 38
nop
rst 38
nop
rst 38
ld b, d
rst 38
inc h
rst 38
jr 0.l_2db8
jr 0.l_2dba
inc h
rst 38
ld b, d
rst 38
nop
nop
nop
nop
nop
nop
nop
inc bc
nop
rrc a
inc bc
rr a
rrc a
ld a, a
rr a
xor $77
ld a, l
ld b, $1d
ld c, $1a
inc c
ldd a, [hl]
inc e
inc [hl]
jr 0.l_2e43
jr nc, 0.l_2e2d
jr nz, 0.l_2e3f
nop
nop
nop
nop
nop
rrc a
nop
ccf
rrc a
ld a, a
ccf
rst 38
ld [hl], a
rst 38
ld b, a
ld e, l
ld c, $1e
inc c
ldd a, [hl]
inc e
ldd a, [hl]
inc e
inc [hl]
jr 0.l_2e0d
ld [$0018], sp
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
ld [bc], a
nop
rst 38
ld [bc], a
add a, l
ld a, d
rst 38
ld [bc], a
add a, l
ld a, d
add a, l
nop
rst 38
nop
ld a, h
nop
rr a
nop
nop
nop
stop
nop
add hl, hl
nop
ld c, a
jr nz, 0.l_2e7c
inc hl
ld d, e
jr nz, 0.l_2e7d
jr nz, 0.l_2ea7
jr nz, 0.l_2e29
nop
rrc a
ldh a, [$ff00 + $ff]
nop
nop
rst 38
nop
nop
rst 38
nop
rst 38
nop
pop af
nop
ld e, h
nop
nop
nop
<error>
nop
<error>
inc b
ld [$eac4], a
inc b
ldd a, [hl]
inc b
ld a, [hl]
inc b
rst 38
nop
ldhl sp, d
rlc a
rst 38
ld [$eb14], sp
inc d
nop
rst 38
nop
rst 38
nop
rst 30
nop
nop
nop
adc a, b
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
inc e
nop
rst 38
stop
add hl, hl
sub a, $ff
jr nz, 0.l_2ec4
xor [hl]
ld d, c
nop
rst 38
nop
rr a
nop
ldh a, [$ff00 + $00]
ldh [$ff00 + $00], a
ld [$0000], sp
nop
nop
nop
nop
nop
nop
nop
nop
nop
ld [bc], a
nop
rst 38
ld [bc], a
add a, l
ld a, d
rst 38
ld [bc], a
add a, l
ld a, d
add a, l
nop
rst 38
nop
rst 38
nop
jr c, 0.l_2e9c
rlc a
nop
nop
nop
add hl, hl
nop
ld c, a
jr nz, 0.l_2efc
inc hl
ld d, e
jr nz, 0.l_2efd
jr nz, 0.l_2f27
jr nz, 0.l_2ea9
nop
rrc a
ldh a, [$ff00 + $ff]
nop
nop
rst 38
nop
nop
rst 38
nop
rlc a
nop
cp a
nop
ret nz
nop
ld c, b
nop
<error>
nop
<error>
inc b
ld [$eac4], a
inc b
ldd a, [hl]
inc b
ld a, [hl]
inc b
rst 38
nop
ldhl sp, d
rlc a
rst 38
ld [$eb14], sp
inc d
nop
rst 38
nop
di
nop
inc a
nop
pop hl
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
inc e
nop
rst 38
stop
add hl, hl
sub a, $ff
jr nz, 0.l_2f44
xor [hl]
ld d, c
nop
rst 38
nop
rst 38
nop
ld c, $00
ret nz
nop
ld b, b
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
ld [bc], a
nop
rst 38
ld [bc], a
add a, l
ld a, d
rst 38
ld [bc], a
add a, l
ld a, d
add a, l
nop
rst 38
nop
rlc a
nop
ld a, [hl]
nop
stop
nop
ld bc, $2900
nop
ld c, a
jr nz, 0.l_2f7c
inc hl
ld d, e
jr nz, 0.l_2f7d
jr nz, 0.l_2fa7
jr nz, 0.l_2f29
nop
rrc a
ldh a, [$ff00 + $ff]
nop
nop
rst 38
nop
nop
rst 38
nop
rst 38
nop
inc bc
nop
ld a, [de]
nop
nop
nop
<error>
nop
<error>
inc b
ld [$eac4], a
inc b
ldd a, [hl]
inc b
ld a, [hl]
inc b
rst 38
nop
ldhl sp, d
rlc a
rst 38
ld [$eb14], sp
inc d
nop
rst 38
nop
add a, e
nop
ldh [$ff00 + $00], a
jr 0.l_2f5e
ld b, b
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
inc e
nop
rst 38
stop
add hl, hl
sub a, $ff
jr nz, 0.l_2fc4
xor [hl]
ld d, c
nop
rst 38
nop
ldhl sp, d
nop
ld a, [hl]
nop
inc b
nop
add a, b
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
ld [bc], a
nop
rst 38
ld [bc], a
add a, l
ld a, d
rst 38
ld [bc], a
add a, l
ld a, d
add a, l
nop
rst 38
nop
ccf
nop
ld bc, $1800
nop
nop
nop
add hl, hl
nop
ld c, a
jr nz, 0.l_2ffc
inc hl
ld d, e
jr nz, 0.l_2ffd
jr nz, 0.l_3027
jr nz, 0.l_2fa9
nop
rrc a
ldh a, [$ff00 + $ff]
nop
nop
rst 38
nop
nop
rst 38
nop
ei
nop
ld a, $00
ld bc, $1200
nop
<error>
nop
<error>
inc b
ld [$eac4], a
inc b
ldd a, [hl]
inc b
ld a, [hl]
inc b
rst 38
nop
ldhl sp, d
rlc a
rst 38
ld [$eb14], sp
inc d
nop
rst 38
nop
rst 38
nop
ld bc, $c000
nop
stop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
inc e
nop
rst 38
stop
add hl, hl
sub a, $ff
jr nz, 0.l_3044
xor [hl]
ld d, c
nop
rst 38
nop
<error>
nop
ldh a, [$ff00 + $00]
inc e
nop
nop
nop
rst 38
rst 38
rst 30
rst 38
ret nz
ldh a, [$ff00 + $e0]
ldh [$ff00 + $cb], a
ldh [$ff00 + $87], a
ret nz
adc a, [hl]
ret nz
sbc a, a
ret nz
rst 38
rst 38
xor a
rst 38
ret nc
ld c, $3b
nop
ret nz
nop
rst 38
nop
ld sp, hl
ld b, $fa
inc b
rst 38
rst 38
jp nz, .l_25ff
ld d, b
ld bc, $4f20
nop
cp $01
ei
inc b
rst 28
nop
rst 38
rst 38
rrc a
rst 38
or l
rrc a
sbc a, e
rlc a
ei
rlc a
jp [hl]
rl a
ld a, l
inc bc
push af
dec bc
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
ldh [$ff00 + $ff], a
rst 20
rst 38
rst 28
rst 38
rst 28
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
cp a
rst 38
ld bc, $80ff
rst 38
ldh [$ff00 + $ff], a
ldh [$ff00 + $ff], a
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
ld a, a
rst 38
ld a, $ff
inc c
rst 38
nop
rst 38
inc bc
<error>
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
ldhl sp, d
rst 38
ld bc, $50ff
xor a
nop
rst 38
nop
rst 38
rst 38
rst 38
ld a, a
rst 38
ccf
rst 38
ccf
rst 38
rr a
rst 38
ccf
rst 28
ccf
rst 28
rr a
rst 28
rst 20
rst 38
pop hl
rst 38
<error>
rst 38
rst 20
rst 38
rst 20
rst 38
rst 20
rst 38
ldh [$ff00 + $ff], a
ldh [$ff00 + $ff], a
ldhl sp, d
rst 38
<error>
rst 38
cp $ff
sbc a, $ff
sbc a, [hl]
rst 38
inc de
<error>
rr a
ldh [$ff00 + $1f], a
ldh [$ff00 + $00], a
rst 38
nop
rst 38
nop
rst 38
jr 0.l_30b7
ldi [hl], a
<error>
push de
jr z, 0.l_30a8
stop
rst 38
nop
nop
rst 38
nop
rst 38
add hl, de
rst 38
ld a, a
rst 38
rst 38
rst 38
dec bc
rst 38
sub a, b
ld l, a
ldh a, [$ff00 + $0f]
nop
rst 38
ld bc, $81ff
rst 38
ldh [$ff00 + $ff], a
ldh a, [$ff00 + $ff]
di
<error>
sbc a, a
ld h, b
rst 38
nop
add a, $ff
rst 28
rst 38
rst 28
rst 38
add a, $ff
jr nc, 0.l_30e9
add a, [hl]
ld a, c
add a, [hl]
ld a, c
rst 8
jr nc, 0.l_3121
rst 38
ld a, b
rst 38
ld a, b
rst 38
jr nc, 0.l_30f7
ret nz
rst 38
jr 0.l_30e3
rr a
ldh [$ff00 + $3f], a
ret nz
xor a
ret nz
and a
ret z
<error>
add a, b
rst 38
add a, b
jp .l_e0fc
rst 38
xor b
rst 38
rst 38
rst 38
call c, func_ff20
nop
cp a
nop
rst 38
nop
rrc a
ldh a, [$ff00 + $73]
adc a, a
ld c, $ff
rst 38
rst 38
rst 38
nop
rst 30
ld [$00ff], sp
or a
ld a, b
ld d, e
<error>
ld a, h
add a, a
ld [hl], $ff
rst 38
rst 38
push bc
inc hl
jp [hl]
rlc a
jp .l_570f
rrc a
xor l
rr a
ld l, c
sbc a, a
dec bc
rst 38
rst 38
rst 38
ld h, b
rst 38
ret z
rst 30
sbc a, b
rst 20
ldi [hl], a
<error>
rlc a
ldhl sp, d
ccf
ret nz
rst 38
nop
rst 38
nop
nop
rst 38
nop
rst 38
jr 0.l_3155
jr 0.l_314f
ld [bc], a
<error>
rst 38
nop
rst 38
nop
rst 38
nop
nop
rst 38
nop
rst 38
inc bc
rst 38
rl a
rst 28
ld a, $c7
<error>
rrc a
<error>
rrc a
ldh a, [$ff00 + $0f]
rr a
rst 28
ld a, a
rst 38
cp a
rst 38
ccf
rst 38
ccf
rst 38
dec de
rst 38
rl a
ei
ccf
rst 38
ldh a, [$ff00 + $ff]
pop af
rst 38
ei
cp $f8
rst 38
<error>
rst 38
ldhl sp, d
rst 38
ldhl sp, d
rst 38
ldh a, [$ff00 + $ff]
inc sp
call z, func_c738
add hl, sp
add a, $1e
pop hl
ld e, $e1
inc e
<error>
inc e
<error>
inc a
jp .l_00ff
add a, b
ld a, a
nop
rst 38
nop
rst 38
nop
inc e
nop
inc e
nop
inc e
nop
rst 38
rst 20
jr 0.l_3142
ld [hl], b
ld c, a
or b
ccf
ret nz
ccf
ld b, b
rr a
ld h, b
rr a
ld h, b
rl a
add sp, d
ldh a, [$ff00 + $0f]
ldh a, [$ff00 + $0f]
ld sp, hl
ld b, $ff
nop
rst 38
nop
rst 38
nop
rst 38
nop
ccf
ret nz
rst 38
nop
rst 38
nop
rst 38
nop
rst 38
nop
rst 38
nop
rst 38
nop
rst 38
nop
rst 38
nop
ld sp, hl
ld b, $f0
rrc a
ldh a, [$ff00 + $0f]
ld sp, hl
ld b, $ff
nop
rst 38
nop
rst 38
nop
rst 38
nop
rst 38
nop
rst 38
nop
rst 38
nop
rst 38
nop
inc h
<error>
ld l, l
sub a, d
ld h, l
sbc a, d
pop af
ld c, $ef
stop
rst 18
jr nz, 0.l_31be
ld b, [hl]
or a
ld c, b
ld [bc], a
<error>
ld [hl], h
adc a, e
<error>
ldi [hl], a
jp .l_cf3c
jr nc, 0.l_31ca
ld c, b
ld a, e
add a, h
or a
ld c, b
call func_1832
rst 20
<error>
ldi [hl], a
pop hl
ld e, $ff
nop
rst 38
nop
adc a, a
ld [hl], b
rst 20
jr 0.l_324d
<error>
ld l, l
sub a, d
ld h, l
sbc a, d
pop af
ld c, $07
ld e, b
inc bc
cp h
ld bc, $70fe
rst 38
rst 38
rst 38
ldhl sp, d
rst 38
rst 38
rst 38
rst 38
rst 38
di
inc c
di
inc c
ei
inc b
ei
inc b
<error>
ld [bc], a
rst 38
nop
rst 38
nop
rst 38
nop
cpl
rst 38
cpl
rst 38
dec sp
rst 38
scf
ei
sub a, e
ccf
dec de
ccf
rst 28
rr a
rst 20
rr a
ldh a, [$ff00 + $ff]
ldh a, [$ff00 + $ff]
pop af
rst 38
<error>
rst 38
rst 20
rst 38
adc a, $ff
<error>
rst 38
jp .l_3cff
jp .l_c33c
add a, $f9
jp nz, .l_80fc
cp $c0
cp $c0
cp $a0
sbc a, $00
rst 38
nop
<error>
nop
<error>
nop
ld [hl], $00
inc e
nop
adc a, b
nop
ld h, e
nop
nop
ld e, $e1
ld e, $e1
ld sp, $20cf
rr a
nop
ccf
nop
cp a
nop
ccf
inc bc
inc a
rst 38
nop
rst 18
nop
rr a
ret nz
rst 18
jr nz, 0.l_32b8
ldh a, [$ff00 + $47]
cp b
ld hl, $1fde
ldh [$ff00 + $f8], a
rlc a
ldh a, [$ff00 + $0f]
ret nz
ccf
ret nz
ccf
add a, b
ld a, a
add a, h
ld a, e
add a, [hl]
ld a, c
rst 8
jr nc, 0.l_32e0
ldh [$ff00 + $0f], a
ldh a, [$ff00 + $1f]
ldh [$ff00 + $7f], a
add a, b
ccf
ret nz
rr a
ldh [$ff00 + $1f], a
ldh [$ff00 + $1f], a
ldh [$ff00 + $f3], a
rrc a
di
rrc a
di
rrc a
<error>
rr a
<error>
rr a
rst 10
cpl
rst 18
daa
rst 10
cpl
ld b, $f8
ld a, $c0
ccf
ret nz
ld a, a
add a, b
ld a, b
add a, a
jr nc, 0.l_32b4
jr nc, 0.l_32b9
inc sp
call z, func_1c00
nop
add a, b
nop
ld h, e
add a, b
nop
nop
<error>
nop
ld a, $00
rst 38
pop bc
ld a, $31
ld c, $3f
add a, b
ld a, a
nop
rst 38
nop
rrc a
ldh a, [$ff00 + $07]
ld [$e807], sp
rst 20
jr 0.l_32e0
ccf
rst 8
ccf
jp .l_e33f
rr a
di
rrc a
di
rrc a
di
rrc a
di
rrc a
ldh [$ff00 + $ff], a
ldh [$ff00 + $ff], a
ldh [$ff00 + $ff], a
ldh [$ff00 + $ff], a
and $ff
rst 28
rst 38
rst 28
rst 38
and $ff
rr a
ldh [$ff00 + $1f], a
ldh [$ff00 + $3f], a
ret nz
ccf
ret nz
ld c, $f1
ld b, h
ei
ld b, h
ei
ld c, $f1
add a, b
ld a, a
add a, b
ld a, a
sub a, h
ld l, e
rst 38
nop
ld a, a
add a, b
ccf
ret nz
ccf
ret nz
ld a, a
add a, b
cp a
ld b, b
ld e, a
add a, b
ld e, b
add a, a
ret nc
rrc a
di
inc c
rst 30
ld [$08f7], sp
rst 38
nop
rst 8
jr nc, 0.l_3300
ld h, d
ld e, $e1
cp a
ld b, b
cp $00
rst 38
nop
adc a, l
nop
ld [hl], e
nop
rst 38
nop
rst 38
nop
ld b, $79
push bc
ldd a, [hl]
<error>
ld [$13e8], sp
ret z
inc sp
and a
ld b, b
rst 10
jr nz, 0.l_336a
jr 0.l_331a
ld a, [bc]
ld [hl], $49
add a, l
ld a, d
xor d
ld d, h
sub a, h
ld l, b
call nz, func_ff39
nop
rst 38
nop
and c
ld c, [hl]
cp c
ld b, $44
jr c, 0.l_3406
sub a, b
ld d, c
and d
and a
ld b, b
pop hl
rst 38
<error>
rst 38
<error>
rst 38
pop hl
rst 38
ldh [$ff00 + $ff], a
ldh [$ff00 + $ff], a
ldh [$ff00 + $ff], a
ldh [$ff00 + $ff], a
sbc a, c
and $d0
rst 28
ret nc
rst 28
sbc a, c
and $2f
ldh a, [$ff00 + $67]
ldhl sp, d
ld h, a
ldhl sp, d
cpl
ldh a, [$ff00 + $fe]
nop
rst 38
nop
rst 28
jr nc, 0.l_33da
<error>
ld a, e
add a, b
ld a, e
add a, b
rst 0
nop
rst 38
nop
rst 38
nop
rst 38
nop
rst 38
nop
rst 38
nop
cp $01
ldhl sp, d
rlc a
<error>
dec c
add sp, d
rl a
rst 38
nop
rst 38
nop
rst 38
nop
push hl
ld a, [de]
sub a, d
ld a, l
jr z, 0.l_33c3
nop
rst 38
nop
ld [hl], a
rst 0
jr c, 0.l_33b2
ld b, b
ld a, e
add a, b
add a, h
ei
adc a, h
di
ld sp, $03ce
<error>
rlc a
ld a, b
cp a
nop
ld a, [hl]
ld bc, $02fd
rst 38
nop
<error>
stop
rst 10
jr nz, 0.l_340c
nop
ld e, a
add a, b
rr a
ldh [$ff00 + $1f], a
ldh [$ff00 + $1f], a
ldh [$ff00 + $1f], a
ldh [$ff00 + $1f], a
ldh [$ff00 + $1f], a
ldh [$ff00 + $3f], a
ret nz
rr a
ldh [$ff00 + $ff], a
nop
rst 38
nop
rst 28
stop
rst 30
nop
rst 38
nop
rst 38
nop
rst 38
nop
rst 38
nop
ret nz
ld a, $c0
dec sp
add a, b
ld [hl], l
add a, b
ld a, e
nop
rst 28
nop
rst 10
ld bc, $01ee
cp $00
xor d
nop
ld [hl], a
nop
rst 38
nop
rst 38
ccf
ret nz
rst 38
nop
rst 38
nop
rst 38
nop
rrc a
or b
rr a
ld h, b
ccf
ret nz
ld a, a
add a, b
rst 38
nop
rst 38
nop
rst 38
nop
rst 38
nop
rst 38
nop
rst 38
nop
rst 38
nop
rst 38
nop
cp $01
<error>
inc bc
ldh a, [$ff00 + $0f]
add a, b
ld a, a
sbc a, a
ldh [$ff00 + $1f], a
ldh [$ff00 + $3f], a
ret nz
ccf
ret nz
ld e, $e1
add hl, de
rst 20
nop
rst 38
ld h, b
rst 38
rst 38
nop
cp $01
or $09
add a, a
ld a, b
inc bc
<error>
ld bc, $80fe
ld a, a
nop
rst 38
<error>
inc bc
ld b, e
cp h
jr nc, 0.l_3465
ld c, $f1
add a, c
ld a, [hl]
ldh a, [$ff00 + $0f]
ld a, a
add a, b
rr a
ldh [$ff00 + $01], a
cp $06
ld sp, hl
ldhl sp, d
rlc a
inc bc
<error>
<error>
inc bc
ld bc, $fffe
nop
rst 38
nop
cp c
ld a, [hl]
dec sp
and $23
call c, func_70ce
inc a
ret nz
ldh [$ff00 + $01], a
ldh [$ff00 + $1f], a
nop
rst 38
rst 38
nop
inc b
ei
jr c, 0.l_348d
pop bc
ld a, $07
ldhl sp, d
ld a, [hl]
add a, c
ldhl sp, d
rlc a
ret nz
ccf
rst 38
nop
ld a, a
add a, b
pop af
ld c, $f3
inc c
or [hl]
ld c, c
inc a
jp $c738
ld sp, $e7ce
jr 0.l_34c2
jr nz, 0.l_34a2
ld b, b
ld a, l
ret nz
ld [hl], e
ret z
ld e, e
add a, h
rst 0
jr c, 0.l_347b
ld [hl], e
cp $01
<error>
dec bc
ldhl sp, d
rlc a
ldh a, [$ff00 + $0f]
ldh a, [$ff00 + $0f]
ldh [$ff00 + $1f], a
ldh [$ff00 + $1f], a
ldh [$ff00 + $1f], a
nop
rst 38
ld [$04ff], sp
swap b
add a, a
jr nc, 0.l_3491
nop
rst 8
nop
rst 38
nop
rst 38
ldh [$ff00 + $ff], a
pop af
rst 38
<error>
rst 38
rst 20
rst 38
rst 20
rst 38
rst 28
rst 38
<error>
cp $c0
rst 38
ldh [$ff00 + $ff], a
ldh [$ff00 + $ff], a
ldh [$ff00 + $ff], a
and b
rst 38
ldhl sp, d
ldh [$ff00 + $d8], a
jr nz, 0.l_3505
jr nz, 0.l_350b
jr nz, 0.l_3531
rst 38
nop
rst 38
nop
rst 38
nop
rst 38
jr nc, 0.l_353b
ld [hl], b
nop
ld [hl], b
nop
cp b
ret nz
nop
rst 38
nop
rst 38
ld [bc], a
rst 38
ld bc, $00fe
rst 38
ld h, b
rlc a
ldh [$ff00 + $01], a
di
nop
nop
rst 38
nop
rst 38
nop
rst 38
nop
rst 38
nop
pop af
nop
ldh [$ff00 + $00], a
ldh [$ff00 + $80], a
ld h, b
nop
rst 38
nop
rst 38
nop
rst 38
nop
rst 38
stop
rst 38
nop
rst 30
nop
rst 38
nop
rst 38
nop
rst 38
ld [$24ff], sp
ei
ld b, h
ei
nop
rst 30
jr nc, 0.l_354b
nop
rst 38
nop
rst 38
nop
rst 38
nop
rst 38
ld [$00ff], sp
rst 38
ld bc, $06ff
rst 38
inc c
rst 38
ld [$33ff], sp
call z, func_c936
dec a
jp .l_c73a
di
adc a, $12
<error>
inc h
ret
dec l
jp nz, .l_e11e
di
call z, func_ae51
sub a, b
ld h, a
and h
ld d, e
ld d, [hl]
xor c
inc bc
sbc a, h
or c
ld c, [hl]
ld a, a
add a, b
ld h, a
sbc a, b
<error>
inc e
ldh [$ff00 + $1f], a
ld l, b
sub a, a
ld h, b
sbc a, a
ld h, b
sbc a, a
ldh [c], a
dec e
ldh [$ff00 + $1e], a
pop bc
inc a
pop bc
inc a
ret nz
ld a, $10
rst 38
ld [$20f7], sp
rst 38
stop
rst 28
inc bc
ld a, h
add a, a
jr c, 0.l_3564
jr nc, 0.l_35e6
ld [hl], b
rr a
ldh [$ff00 + $1f], a
ldh [$ff00 + $3f], a
ret nz
ccf
ret nz
add a, b
rst 38
call z, func_efff
rst 38
rst 20
rst 38
rst 20
rst 38
<error>
rst 38
pop hl
rst 38
ldh [$ff00 + $ff], a
call c, func_3e20
ret nz
rr a
ldh [$ff00 + $ef], a
ldh a, [$ff00 + $60]
rst 38
ret nc
rst 28
<error>
di
<error>
<error>
jr c, 0.l_3582
<error>
nop
ld a, [hl]
nop
cp $01
nop
rst 38
ld [$04ff], sp
ei
nop
rst 38
di
nop
ld a, [$f801]
rlc a
nop
rst 38
inc e
<error>
inc bc
<error>
ld bc, $70fe
adc a, a
ret nz
ld sp, $ff00
nop
rst 38
ld h, b
sbc a, a
stop
rst 28
rrc a
ldh a, [$ff00 + $81]
ld a, [hl]
ret nz
ccf
ld [$04ff], sp
ei
nop
rst 38
nop
rst 38
nop
rst 38
add a, b
ld a, a
ldh a, [$ff00 + $0f]
ccf
ret nz
nop
rst 38
nop
rst 38
nop
rst 38
nop
rst 38
rrc a
ldh a, [$ff00 + $3f]
ret nz
ret nz
ccf
nop
rst 38
ld [bc], a
rst 38
add hl, bc
cp $15
ld a, [$f748]
jr nz, 0.l_3639
add a, b
rst 38
ld [hl], b
adc a, a
ccf
ret nz
ld e, $c1
di
inc c
or e
ld c, h
ld [hl], $c9
inc a
jp $c738
or c
ld c, [hl]
inc sp
call z, func_e718
inc c
di
add a, [hl]
ld a, c
jp .l_613c
sbc a, [hl]
ldh a, [$ff00 + $0f]
sbc a, b
ld h, a
inc c
di
ldh [$ff00 + $1f], a
ld h, b
sbc a, a
ld h, b
sbc a, a
ld h, d
sbc a, l
ldh [$ff00 + $1f], a
<error>
inc e
ld h, a
sbc a, b
ld l, a
sub a, b
jr nz, 0.l_3671
add a, b
rst 38
ld b, b
cp a
nop
cp $c1
inc a
pop bc
inc a
ret nz
ld a, $e0
rr a
ccf
ret nz
ccf
ret nz
rr a
ldh [$ff00 + $1f], a
ld h, b
adc a, a
jr nc, 0.l_363a
jr nc, 0.l_36b4
ld a, b
inc bc
<error>
ld h, c
cp $00
rst 38
jr 0.l_369d
ld c, $f1
rrc a
ldh a, [$ff00 + $1f]
ldh [$ff00 + $3f], a
ret nz
sbc a, a
ldh [$ff00 + $f3], a
inc c
rst 8
jr nc, 0.l_36ff
push bc
add a, b
rst 38
ld [bc], a
<error>
ld [hl], h
adc a, e
ld [hl], a
add a, b
rst 8
nop
<error>
inc bc
add a, a
ld a, b
ld bc, $78fe
add a, a
adc a, [hl]
ld [hl], c
ld bc, $00fe
rst 38
<error>
inc bc
nop
rst 38
nop
rst 38
add a, h
ld a, a
ldh [c], a
dec e
ld a, d
adc a, h
dec d
add sp, d
nop
rst 38
nop
rst 38
inc c
di
nop
rst 38
rlc a
ldhl sp, d
ld a, a
add a, b
ldh a, [$ff00 + $0f]
add a, b
ld a, a
nop
rst 38
rst 38
nop
ld [hl], b
adc a, a
ld c, $f1
add a, e
ld a, h
pop hl
ld e, $38
rst 0
ld c, $f1
nop
rst 38
nop
rst 38
ld [hl], $c9
cp h
ld b, e
jr c, 0.l_36dd
jr nc, 0.l_36e7
ld sp, $33ce
call z, func_807f
rst 38
nop
ld e, $e1
inc sp
call z, func_9c63
rst 8
jr nc, 0.l_36e8
ld b, b
rst 38
nop
rst 38
nop
rst 38
nop
ldh [$ff00 + $1f], a
ldh [$ff00 + $1f], a
ldh [$ff00 + $1f], a
ldh a, [$ff00 + $0f]
ldh a, [$ff00 + $0f]
ldhl sp, d
rlc a
<error>
dec bc
cp $01
ld bc, $01fe
xor $00
rst 10
nop
rst 28
add a, b
ld a, a
add a, b
ld a, e
ret nz
dec [hl]
ret nz
dec sp
rst 38
nop
rst 38
nop
rst 38
nop
ccf
ret nz
nop
rst 38
ld b, b
rst 38
jr nz, 0.l_373d
nop
ld a, e
rst 38
nop
rst 38
nop
rst 38
nop
rst 38
nop
ld a, a
add a, b
ccf
ret nz
rr a
ldh [$ff00 + $0f], a
or b
add a, b
ld a, a
jp .l_e33f
rrc a
rst 38
inc bc
ld sp, hl
rlc a
pop af
rrc a
ldh a, [$ff00 + $0f]
ld sp, hl
rlc a
ld [hl], a
rst 38
rst 38
rst 38
di
rst 38
dec sp
rst 38
ld e, a
cp a
ld h, a
rst 38
jp .l_1bff
rst 20
add sp, d
rst 38
<error>
rst 38
<error>
rst 38
<error>
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
nop
rst 38
nop
jp .l_003c
rst 38
inc a
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
nop
rst 38
nop
rst 38
nop
pop af
ld c, $00
rst 38
ld c, $ff
rst 38
rst 38
rst 38
rst 38
ldh [$ff00 + $1e], a
ldh a, [$ff00 + $0f]
ldhl sp, d
rlc a
cp $01
nop
rst 38
nop
rst 38
rst 38
rst 38
rst 38
rst 38
nop
or l
nop
ld a, e
nop
rst 38
nop
rst 38
ccf
rst 38
ld bc, $ffff
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
<error>
inc bc
<error>
inc bc
ld sp, hl
rlc a
di
rrc a
rlc a
cp $1e
rst 38
rst 38
rst 38
rst 38
rst 38
ld a, a
rst 38
rst 38
ret nz
ldh [$ff00 + $80], a
pop bc
add a, b
jp .l_e780
add a, b
rst 8
add a, b
ret nz
add a, b
rst 38
rst 38
rst 38
nop
ld [$b020], sp
nop
ldh [$ff00 + $04], a
ret nz
nop
nop
nop
ld bc, $ff00
rst 38
rst 38
nop
nop
nop
add a, b
add a, b
nop
nop
nop
nop
ret nz
nop
add a, b
nop
rst 38
rst 38
rst 38
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
ccf
rst 38
ccf
rst 38
scf
di
ccf
di
dec l
rst 38
jr c, 0.l_3833
ldd a, [hl]
rst 20
jr c, 0.l_3837
add a, b
rst 38
add a, b
rst 38
add a, b
rst 38
add a, b
rst 38
add a, b
rst 38
add a, b
rst 38
add a, b
rst 38
add a, b
rst 38
ld bc, $01ff
rst 38
ld bc, $01ff
rst 38
ld bc, $01ff
rst 38
ld bc, $01ff
rst 38
<error>
rst 38
call c, func_fccf
rst 8
inc [hl]
rst 38
inc c
rst 38
xor h
ld a, a
adc a, h
ld a, a
adc a, h
ld a, a
rst 38
rst 38
rst 38
nop
nop
nop
nop
nop
inc bc
inc bc
rrc a
rrc a
ld a, $3f
rst 38
ei
cp $ff
rst 28
inc de
inc bc
dec b
ld b, a
ld a, e
rst 8
<error>
rst 38
rst 38
rst 38
pop af
rst 38
pop af
ret nc
sbc a, a
ret nc
cp a
ldhl sp, d
cp a
<error>
cp a
<error>
cp e
rst 38
or [hl]
cp $bc
cp $bd
inc c
rst 38
inc e
rst 38
jr c, 0.l_38b5
ld [hl], b
rst 38
ldh a, [$ff00 + $ff]
ret c
rst 20
ld [$18cf], sp
rr a
rr a
or $0f
rst 38
rr a
rst 38
ccf
cp $3f
rst 38
ld e, a
rst 18
scf
or a
rrc a
rrc a
adc a, b
ldh [$ff00 + $00], a
ldhl sp, d
dec b
<error>
sbc a, [hl]
rst 38
ld a, $ff
<error>
rst 38
rst 38
cp $ff
cp $01
nop
ld b, e
nop
ld b, c
ld [bc], a
nop
rst 20
add a, b
ld a, a
add a, b
ld a, a
ld bc, $00fe
rst 38
inc d
<error>
ld [$1005], sp
rrc a
nop
ccf
ld h, l
sbc a, e
rst 38
rrc a
rst 38
rl a
add a, b
ld a, a
ret nz
add a, b
ret nz
add a, b
ret nz
add a, b
ret nz
add a, b
ret nz
add a, b
ret nz
add a, b
ret nz
add a, b
ret nz
add a, b
inc bc
nop
ld c, $00
inc e
nop
ld a, b
nop
ldh a, [$ff00 + $00]
ld bc, $0100
nop
inc bc
nop
dec b
nop
ld b, $00
ld [$3100], sp
ld bc, $07c7
daa
rlc a
rst 38
rrc a
xor $0d
nop
nop
rr a
nop
ccf
ld bc, $9f9f
cp $fe
rst 38
rst 38
rst 38
rst 38
ld a, [hl]
cp $0c
inc c
rst 38
rst 38
ld sp, hl
rst 38
ei
rst 8
rst 38
adc a, a
and a
rlc a
ld [$0006], sp
rrc a
ldh [$ff00 + $f8], a
add a, $f7
call func_ffff
rst 38
cp $ff
<error>
rst 38
rst 38
ld a, b
ld a, a
add a, b
nop
nop
nop
ret nz
cp b
ldhl sp, d
rst 38
<error>
dec bc
adc a, c
add a, c
ld b, c
ld bc, $0101
ld bc, $0303
rlc a
rlc a
rrc a
rrc a
rr a
rr a
rst 38
rst 38
<error>
rst 38
ret nz
rst 38
ld h, b
rst 28
rst 38
<error>
ld sp, hl
rst 38
ldh a, [$ff00 + $ff]
add a, b
rst 38
ldd [hl], a
rst 28
rrc a
rst 38
ccf
cp $7f
rst 38
rst 38
pop hl
rst 28
pop af
ei
rst 8
cp $8d
ld e, l
and a
ei
rlc a
rst 38
dec c
<error>
rr a
<error>
cp e
cp $bf
cp $bf
cp $bd
jp c, .l_e49f
sbc a, a
rst 28
sbc a, a
rst 38
sbc a, a
inc a
cp [hl]
inc a
cp $10
rst 38
nop
rst 38
nop
rst 38
and b
rst 18
ld a, b
xor a
ldh a, [$ff00 + $ff]
rlc a
rrc a
rlc a
rr a
nop
ccf
jr nz, 0.l_39a5
nop
ei
nop
ldh a, [$ff00 + $40]
and b
ldh [$ff00 + $01], a
rst 38
<error>
rst 38
ldhl sp, d
rr a
<error>
ccf
sbc a, $7e
cpl
inc a
rst 18
jr c, 0.l_39bd
ld [hl], d
cp a
nop
rst 38
add a, b
ld a, a
call nz, func_9c3b
ld h, e
ld c, $f1
ccf
pop bc
ld a, [hl]
add a, c
ld c, l
sub a, d
nop
rst 38
nop
rst 38
nop
rst 38
nop
rst 38
ld bc, $03fe
<error>
rst 8
ret nc
push hl
nop
ret nz
add a, b
ret nz
add a, b
pop bc
add a, c
jp nz, .l_c282
add a, d
call nz, func_c484
add a, h
ret nz
add a, b
rlc a
nop
inc bc
nop
rlc a
ld bc, $010f
rr a
inc bc
rrc a
rlc a
rrc a
rrc a
rrc a
rrc a
<error>
dec de
<error>
ld [hl], e
ldh [$ff00 + $fc], a
ldh [$ff00 + $c8], a
ret nz
ret nc
add a, b
add a, b
nop
add a, b
add a, b
add a, c
ld a, h
cp h
cp h
ld [bc], a
ld e, b
rlc a
stop
rrc a
nop
ccf
rrc a
ld a, a
sub a, a
ld a, a
dec a
<error>
nop
rr a
nop
ccf
ld e, $ed
ccf
rst 38
ldh a, [$ff00 + $ff]
rst 28
rst 38
or a
rst 38
ccf
rst 38
add a, a
ld a, b
ld bc, $00fe
rst 38
call nz, func_deff
rst 38
cp $ff
rst 38
rst 38
rst 38
rst 38
nop
nop
nop
nop
inc e
ldh [$ff00 + $0c], a
ldh a, [$ff00 + $06]
ldhl sp, d
inc bc
<error>
adc a, d
<error>
cp $fc
add sp, d
rst 28
jr c, 0.l_3ab3
inc a
ccf
ld a, $3f
ccf
ccf
rr a
rr a
rlc a
rlc a
ld bc, $1f03
rst 38
rlc a
rst 38
ld b, $ff
ld c, $ff
cp $ff
ld a, a
ld a, a
rst 18
call c, func_f0ff
jp .l_013d
rst 38
inc bc
<error>
ld bc, $03ff
<error>
rlc a
ld sp, hl
add a, a
pop af
<error>
<error>
rst 18
sbc a, a
rst 8
adc a, a
jp .l_c783
adc a, a
rst 0
cp a
jp .l_c0bf
cp a
ret nz
cp a
ldh a, [$ff00 + $ff]
jp [hl]
rst 38
ldh a, [$ff00 + $ff]
pop af
rst 38
<error>
rst 38
rst 0
rst 38
rlc a
rst 38
rst 28
inc sp
ret nz
inc de
add a, b
add a, a
nop
rlc a
nop
rrc a
add a, b
sbc a, e
ldh [$ff00 + $d6], a
ldh [$ff00 + $81], a
nop
pop bc
inc a
cp $6d
<error>
jr 0.l_3aae
nop
add a, b
nop
nop
add hl, bc
nop
ld e, $80
ld a, $c0
and e
inc d
dec b
ld c, $0b
dec c
rr a
ld e, $35
ld [hl], $03
inc c
ld bc, $030e
inc e
ei
jr 0.l_3ae3
ld [hl], b
ldh [$ff00 + $00], a
pop hl
nop
di
nop
<error>
inc bc
ldhl sp, d
rlc a
ldhl sp, d
rlc a
ld e, l
bit 3, l
rst 18
ld e, l
bit 3, l
jp .l_c35d
ld d, l
bit 3, l
jp .l_d34d
rrc a
rrc a
rr a
rr a
rrc a
rrc a
ccf
ccf
ld a, $3e
dec [hl]
inc [hl]
ld h, b
ld h, b
ld h, c
ld h, b
jp nz, .l_80c1
add a, a
pop af
rrc a
<error>
rr a
rst 28
rr a
rst 18
ccf
sbc a, a
rr a
ccf
ccf
ld [hl], d
di
and $ff
call c, func_9fff
rst 38
cp [hl]
rst 38
rst 38
<error>
rst 38
<error>
rst 38
ei
rrc a
rst 38
rr a
rst 38
ccf
rst 38
ld e, [hl]
rst 18
cp $ff
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
ld a, a
rst 38
ld a, a
rst 38
ld a, a
adc a, a
rst 38
rst 38
rst 38
rst 28
rst 38
rst 38
rst 38
rst 38
cp $fc
<error>
rst 38
cp $ff
cp $ff
rst 38
rst 38
rst 38
rst 38
rst 8
rst 8
ccf
rst 38
dec e
inc bc
ld a, $d1
ld a, [hl]
ld sp, hl
<error>
ld a, [$faf4]
ldhl sp, d
cp $f8
cp $fc
<error>
rst 38
ldh [$ff00 + $ff], a
ldh [$ff00 + $ff], a
ld h, b
jr nc, 0.l_3b37
nop
rr a
nop
rr a
nop
rr a
nop
rrc a
<error>
dec e
add a, a
ld a, c
rlc a
push af
rrc a
ld sp, hl
rr a
rst 38
rr a
rst 38
ccf
<error>
ld a, e
sbc a, l
pop bc
cp [hl]
<error>
cp h
<error>
sbc a, c
pop bc
add a, c
ret nz
add a, b
<error>
sbc a, h
rst 38
ret nz
ld a, a
rst 38
ret z
ld c, e
ldh a, [$ff00 + $f7]
ldh a, [$ff00 + $f7]
ldh [$ff00 + $e7], a
ret nz
jp .l_03fe
rst 38
inc bc
rst 38
rst 38
nop
jp .l_e700
rlc a
ldhl sp, d
rrc a
ldh a, [$ff00 + $0f]
ldh [$ff00 + $3f], a
ldh [$ff00 + $ff], a
ret nz
rst 38
rst 38
ld c, $f1
ld c, $f9
rlc a
or $80
ld h, b
add a, b
nop
rst 20
jr 0.l_3bdc
nop
rst 38
rst 38
ld bc, $033e
<error>
rlc a
ldhl sp, d
inc bc
ld [hl], b
inc bc
nop
rrc a
ldh a, [$ff00 + $ff]
nop
rst 38
rst 38
ldhl sp, d
rlc a
ldhl sp, d
inc bc
<error>
ld bc, $c031
ldh [$ff00 + $00], a
rst 38
nop
rst 38
nop
rst 38
rst 38
cp d
sub a, a
cp d
cp a
cp d
sub a, a
cp d
add a, a
cp d
rst 0
or d
adc a, a
cp d
add a, a
cp d
add a, a
ld h, c
ld h, b
jp .l_cff0
ld a, [$fcee]
inc e
<error>
ld a, $fa
inc a
ld a, h
ld a, a
<error>
ccf
ccf
cp a
ld a, a
halt
scf
inc h
daa
inc [hl]
scf
inc [hl]
scf
ld a, $3f
sbc a, a
rr a
rst 38
rst 38
ld a, $ff
rr a
rst 38
rr a
rst 38
ccf
rst 38
ld a, a
rst 38
rst 38
rst 38
rst 38
rst 38
rrc a
rst 38
ld h, a
rst 38
<error>
rst 38
rst 30
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
cp $ff
rst 38
rst 38
ld sp, hl
rst 38
jp [hl]
rst 28
pop af
rst 38
di
rst 38
rst 38
rst 20
rst 38
rst 20
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
push af
rst 38
<error>
<error>
ldh [c], a
<error>
<error>
ld sp, hl
cp $ff
ldhl sp, d
<error>
di
cp $fb
<error>
ei
ld sp, hl
cp $18
rr a
rr a
ld e, $8f
inc c
adc a, a
nop
cpl
ret nz
ld b, a
add a, b
rst 0
nop
rst 0
nop
rst 38
rr a
rst 38
ccf
<error>
ccf
<error>
dec e
sbc a, e
dec l
or a
ld e, e
ld a, a
dec a
ld b, e
ld a, l
rst 38
rst 38
nop
nop
ld bc, $9300
nop
sbc a, e
nop
sbc a, e
nop
ld h, h
sbc a, e
rst 38
rst 38
rst 38
ldhl sp, d
rst 38
ldhl sp, d
rst 38
ldh a, [$ff00 + $ff]
ldh a, [$ff00 + $07]
ldhl sp, d
inc hl
call c, func_da77
ld a, a
<error>
ldhl sp, d
rl a
<error>
inc bc
cp $01
cp a
nop
rst 38
nop
ld a, a
nop
<error>
ld b, $fd
adc a, [hl]
rlc a
pop af
rl a
pop hl
daa
pop de
rst 38
ld bc, $01f7
rst 30
ld bc, $05fb
add a, a
ld a, c
inc b
rst 38
ld b, $fd
ld b, $fd
ld b, $fd
ld b, $fd
ld b, $fd
ld b, $fd
inc b
rst 38
ldh a, [$ff00 + $ff]
ldh a, [$ff00 + $ff]
ldh a, [$ff00 + $ff]
ldh a, [$ff00 + $ff]
or b
rst 38
ldh a, [$ff00 + $ff]
ldh a, [$ff00 + $ff]
ldh a, [$ff00 + $ff]
ret nz
add a, b
ret nz
add a, b
ret nz
add a, c
jp .l_c383
add a, e
rst 8
adc a, a
rst 8
adc a, a
rst 18
sbc a, a
rst 38
ldhl sp, d
cp $f0
<error>
<error>
ldh [$ff00 + $ff], a
ei
cp $ff
<error>
rst 38
<error>
rst 38
ld a, [$1f5f]
rr a
rr a
ld e, a
rr a
cp a
ccf
ccf
ccf
cpl
daa
ccf
scf
sbc a, a
rrc a
rst 38
rst 38
rst 38
ld sp, hl
rst 38
ei
rst 38
rst 20
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 30
rst 30
adc a, $ff
adc a, a
rst 38
ccf
rst 38
rst 38
rst 0
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
ld a, a
rst 38
ld a, a
rst 38
rst 38
rst 38
rst 38
<error>
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 8
rst 38
add a, e
rst 38
ld sp, hl
cp $fc
rst 38
cp $ff
<error>
rst 38
push hl
cp $e5
cp $c4
cp $cd
cp $e7
dec b
ld a, $81
cp $03
cp $07
cp a
rlc a
halt
dec bc
rst 20
jr 0.l_3d8e
inc c
ld bc, $03ff
<error>
ld bc, $03ff
<error>
rlc a
ld sp, hl
adc a, a
ld [hl], c
rst 18
add hl, hl
rst 38
inc de
ret nz
ccf
ldh [$ff00 + $1f], a
pop af
rrc a
rst 38
rrc a
rst 38
rrc a
rst 30
rrc a
ldh a, [$ff00 + $0f]
ldhl sp, d
rlc a
ld a, a
<error>
rst 38
push de
rst 38
<error>
push hl
pop af
call func_83e0
jp nz, .l_8103
ld b, $80
xor $07
ret c
inc bc
add a, h
inc bc
inc b
rlc a
ld c, $07
sbc a, a
inc c
cp $19
cp [hl]
add a, c
inc bc
<error>
rlc a
ld sp, hl
inc bc
<error>
rlc a
ld sp, hl
rlc a
pop af
rlc a
pop hl
rlc a
pop af
rlc a
pop hl
dec b
<error>
dec b
<error>
dec b
<error>
dec b
<error>
dec b
<error>
dec b
<error>
rlc a
<error>
dec b
<error>
jr nc, 0.l_3df1
jr nc, 0.l_3df3
jr nc, 0.l_3df5
or b
rst 38
jr nc, 0.l_3df9
ld [hl], b
rst 38
ld [hl], b
rst 38
jr nc, 0.l_3dff
rst 38
cp a
rst 38
cp a
rst 18
sbc a, a
<error>
adc a, [hl]
add sp, d
sub a, a
ret nc
cp a
ldh [$ff00 + $bf], a
ldh [$ff00 + $bf], a
<error>
cp $fc
cp $fb
<error>
ld a, a
rst 30
ld a, a
rst 18
ccf
rst 38
ccf
rst 38
ld a, a
rst 38
rst 38
daa
rst 38
inc bc
pop bc
ld b, c
pop bc
add a, b
jp nz, .l_c281
ret nz
pop af
add a, b
or c
ret nz
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
ld a, a
ldh a, [$ff00 + $3f]
ret nz
ccf
rst 38
rst 38
cpl
nop
reti
ld h, $d9
ld h, $fb
inc b
ei
inc b
inc b
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
ld sp, hl
rst 38
ldhl sp, d
rst 38
ld [hl], b
ld a, a
pop af
rst 38
inc sp
ccf
rlc a
rst 38
rrc a
rst 38
xor a
rst 28
rst 38
rst 38
ld a, a
rst 38
rst 38
rst 38
xor $ed
ldh [$ff00 + $fe], a
ld sp, hl
<error>
jp [hl]
sbc a, $f0
<error>
ret nz
ld sp, hl
add sp, d
pop de
ldhl sp, d
add a, c
reti
ld b, $b9
ld b, $ff
ld [$0ffe], sp
ld e, $f9
inc e
rst 38
ld e, h
cp a
cp h
ld a, a
cp b
ld e, a
ld a, h
rst 30
ld a, a
cp l
ld a, a
ld a, l
ld a, a
ld sp, hl
ld [hl], a
or c
ld [hl], a
add a, c
ld [hl], a
add a, c
rst 38
ld bc, $01ff
ld a, h
inc bc
rst 38
nop
xor [hl]
ld bc, $0b50
nop
add a, a
nop
rlc a
nop
rrc a
nop
sbc a, a
dec c
ret nz
cpl
sub a, b
ld e, $e1
rr a
ldh [$ff00 + $3f], a
ret nz
ld a, [hl]
add a, c
dec a
jp nz, .l_8e77
rst 38
rst 38
nop
nop
rst 38
nop
rst 38
nop
rst 38
nop
rst 38
nop
nop
rst 38
rst 38
rst 38
rlc a
pop hl
rlc a
pop bc
rrc a
add a, c
rr a
ld bc, $013f
ld a, a
ld b, c
ld a, a
ld bc, $01ff
rst 38
rst 38
sbc a, l
add a, b
and d
<error>
and [hl]
reti
or a
adc a, b
or a
adc a, b
ret nz
cp a
rst 38
rst 38
rst 38
rst 38
inc bc
ld bc, $03c5
<error>
inc bc
ei
rlc a
<error>
inc bc
ld bc, $ffff
rst 38
add sp, d
cp a
ret c
sbc a, a
rst 10
sub a, l
cp $bf
rst 38
cp a
sbc a, $9f
ret z
sbc a, a
ret nz
sbc a, a
ccf
rst 38
ccf
rst 18
ld l, [hl]
cp a
ld e, a
rst 38
rst 38
rst 38
rr a
rst 38
rrc a
rst 38
rr a
rst 38
inc sp
ret nz
ccf
ret nz
inc a
ret nz
adc a, b
ldh a, [$ff00 + $c0]
ldhl sp, d
pop hl
<error>
di
<error>
rst 28
ldhl sp, d
add a, b
ld a, a
add a, b
ld a, a
nop
ld a, a
nop
ld a, $a0
inc e
ld h, b
nop
ret nz
jr nz, 0.l_3f04
inc h
pop hl
rst 38
nop
rst 38
ld bc, $00ff
rst 38
nop
rst 38
nop
ld a, a
add a, b
dec sp
ld h, b
ld bc, $3f3f
ei
rst 38
add a, c
ldhl sp, d
ld [bc], a
<error>
rlc a
ldhl sp, d
ld [bc], a
<error>
ld b, $f8
ld b, $f1
add a, b
rst 38
nop
cp $00
rst 38
nop
cp $00
ld a, h
ld b, b
inc a
ret nz
ld a, $00
rst 38
ld [hl], b
ld c, $40
rr a
inc bc
cp l
inc bc
rr a
rlc a
ld a, $0f
inc a
ccf
ld a, h
ld a, a
ldhl sp, d
ld a, h
rst 38
<error>
<error>
cp a
<error>
rst 18
ld h, b
rst 38
nop
<error>
inc bc
ldhl sp, d
rlc a
ldhl sp, d
rl a
ld [hl], e
dec b
ld [hl], e
dec b
ld a, a
ld bc, $09f7
rlc a
pop af
rlc a
ld sp, hl
rlc a
pop af
rlc a
ld sp, hl
nop
rst 38
ld de, $3fee
ret nz
rst 38
ld b, b
cp $80
<error>
add a, d
rst 38
ld b, b
rst 38
rst 38
add sp, d
rr a
di
ld e, $ff
inc a
<error>
ld a, h
ld a, b
ld a, b
rst 38
jr nc, 0.l_3fbc
nop
rst 38
rst 38
rst 38
inc e
rst 38
ld a, h
rst 38
ld a, b
ccf
jr nc, 0.l_3fd8
nop
rst 38
nop
rst 38
nop
rst 38
rst 38
ld a, a
ld bc, $11d7
rst 20
dec h
rst 38
ld a, c
rst 38
ld sp, hl
rst 38
pop af
rst 38
ld h, e
cp $ff
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
rst 38
nop
rst 38
nop
rst 38
nop
rst 38
nop
rst 38
nop
rst 38
nop
rst 38
nop
rst 38
nop
rst 38
|
.SET MODE GRAPHICS
.ORIG x3000
CLEAR
AND R0,R0,#0 ;; x
AND R1,R1,#0 ;; y
AND R3,R3,#0 ;; char to poke
LD R4,ROWS
LD R6,COLS
LOOP: POKE R0,R1,R3
ADD R3,R3,#1
ADD R0,R0,#1
ADD R5,R0,R4
BRz NEXT
BR LOOP
HALT
NEXT AND R0,R0,#0
ADD R1,R1,#1
ADD R5,R1,R6
BRz DONE
BR LOOP
DONE HALT
ROWS .FILL #-32
COLS .FILL #-8
.END
|
; A158874: a(n) = (n + 4)*(n + 3)*(n + 2)*(n + 1)*n / 5 = 24*A000389(n+4).
; 0,24,144,504,1344,3024,6048,11088,19008,30888,48048,72072,104832,148512,205632,279072,372096,488376,632016,807576,1020096,1275120,1578720,1937520,2358720,2850120,3420144,4077864,4833024,5696064,6678144,7791168,9047808,10461528,12046608,13818168,15792192,17985552,20416032,23102352,26064192,29322216,32898096,36814536,41095296,45765216,50850240,56377440,62375040,68872440,75900240,83490264,91675584,100490544,109970784,120153264,131076288,142779528,155304048,168692328,182988288,198237312,214486272,231783552,250179072,269724312,290472336,312477816,335797056,360488016,386610336,414225360,443396160,474187560,506666160,540900360,576960384,614918304,654848064,696825504,740928384,787236408,835831248,886796568,940218048,996183408,1054782432,1116106992,1180251072,1247310792,1317384432,1390572456,1466977536,1546704576,1629860736,1716555456,1806900480,1901009880,1999000080,2100989880
add $0,4
bin $0,5
mul $0,24
|
; A008475: If n = Product (p_j^k_j) then a(n) = Sum (p_j^k_j) (a(1) = 0 by convention).
; 0,2,3,4,5,5,7,8,9,7,11,7,13,9,8,16,17,11,19,9,10,13,23,11,25,15,27,11,29,10,31,32,14,19,12,13,37,21,16,13,41,12,43,15,14,25,47,19,49,27,20,17,53,29,16,15,22,31,59,12,61,33,16,64,18,16,67,21,26,14,71,17,73,39,28,23,18,18,79,21,81,43,83,14,22,45,32,19,89,16,20,27,34,49,24,35,97,51,20,29
lpb $0
mov $2,$0
seq $2,28233 ; If n = p_1^e_1 * ... * p_k^e_k, p_1 < ... < p_k primes, then a(n) = p_1^e_1, with a(1) = 1.
div $0,$2
add $1,$2
lpe
mov $0,$1
|
#include<bits/stdc++.h>
#include<unistd.h>
using namespace std;
#define FZ(n) memset((n),0,sizeof(n))
#define FMO(n) memset((n),-1,sizeof(n))
#define F first
#define S second
#define PB push_back
#define ALL(x) begin(x),end(x)
#define SZ(x) ((int)(x).size())
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define REP(i,x) for (int i=0; i<(x); i++)
#define REP1(i,a,b) for (int i=(a); i<=(b); i++)
#ifdef ONLINE_JUDGE
#define FILEIO(name) \
freopen(name".in", "r", stdin); \
freopen(name".out", "w", stdout);
#else
#define FILEIO(name)
#endif
template<typename A, typename B>
ostream& operator <<(ostream &s, const pair<A,B> &p) {
return s<<"("<<p.first<<","<<p.second<<")";
}
template<typename T>
ostream& operator <<(ostream &s, const vector<T> &c) {
s<<"[ ";
for (auto it : c) s << it << " ";
s<<"]";
return s;
}
// Let's Fight!
#define int long long
const int MX = 55;
const int MV = 123;
const int MM = 1111;
int L, N;
struct ACautomata{
struct Node{
int cnt,dp;
Node *go[26], *fail;
int mask, id;
Node (){
cnt = 0;
dp = -1;
memset(go,0,sizeof(go));
fail = 0;
mask = 0;
}
};
Node *root, pool[1048];
int nMem;
vector<Node*> nd;
Node* new_Node(){
pool[nMem] = Node();
pool[nMem].id = nMem;
nd.PB(&pool[nMem]);
return &pool[nMem++];
}
void init(){
nMem = 0;
for (int l=0; l<=L; l++) {
for (int i=0; i<=SZ(nd); i++) {
for (int j=0; j<=(1<<N); j++) {
vt[l][i][j] = false;
}
}
}
nd.clear();
va.clear();
FZ(vt2);
root = new_Node();
}
void add(const string &str, int m){
insert(root,str,0, m);
}
void insert(Node *cur, const string &str, int pos, int m){
if (pos >= (int)str.size()){
cur->cnt++;
cur->mask |= m;
return;
}
int c = str[pos]-'a';
if (cur->go[c] == 0){
cur->go[c] = new_Node();
}
insert(cur->go[c],str,pos+1,m);
}
void make_fail(){
queue<Node*> que;
que.push(root);
while (!que.empty()){
Node* fr=que.front();
que.pop();
for (int i=0; i<26; i++){
if (fr->go[i]){
Node *ptr = fr->fail;
while (ptr && !ptr->go[i]) ptr = ptr->fail;
if (!ptr) fr->go[i]->fail = root;
else {
fr->go[i]->fail = ptr->go[i];
fr->go[i]->mask |= fr->go[i]->fail->mask;
}
que.push(fr->go[i]);
}
}
}
}
int vt2[MV][30];
int mem2[MV][30];
int walk(int cur, char c) {
Node* cv = nd[cur];
int t = c - 'a';
if (vt2[cur][t]) return mem2[cur][t];
vt2[cur][t] = true;
if (cv->go[t]) return mem2[cur][t] = cv->go[t]->id;
else {
if (cv == root) return mem2[cur][t] = 0;
else return mem2[cur][t] = walk(cv->fail->id, c);
}
}
int mem[MX][MV][MM];
bool vt[MX][MV][MM];
int dp(int pos, int cv, int mask) {
int xmask = mask | (nd[cv]->mask);
if (pos == L) {
if (xmask == (1<<N)-1) return 1;
return 0;
}
if (vt[pos][cv][mask]) return mem[pos][cv][mask];
vt[pos][cv][mask] = true;
int ans = 0;
for (char c='a'; c<='z'; c++) {
int nx = walk(cv, c);
ans += dp(pos+1, nx, xmask);
}
return mem[pos][cv][mask] = ans;
}
vector<string> va;
void dump(int pos, int cv, int mask, string s) {
if (not dp(pos, cv, mask)) return;
int xmask = mask | (nd[cv]->mask);
if (pos == L) {
if (xmask == (1<<N)-1) {
va.PB(s);
}
return;
}
for (char c='a'; c<='z'; c++) {
int nx = walk(cv, c);
dump(pos+1, nx, xmask, s+c);
}
}
} ac;
void solve() {
for (int i=0; i<N; i++) {
string s; cin >> s;
ac.add(s, 1<<i);
}
ac.make_fail();
int t;
cout << (t = ac.dp(0, 0, 0)) << " suspects" << endl;
assert(t >= 0);
if (t <= 42) {
ac.dump(0, 0, 0, "");
for (auto x: ac.va) {
cout << x << endl;
}
}
ac.init();
}
int32_t main() {
IOS;
ac.init();
int cas = 0;
while (true) {
cin >> L >> N;
if (not L and not N) break;
cas++;
cout << "Case " << cas << ": ";
solve();
}
return 0;
}
|
; A028200: Expansion of 1/((1-6x)(1-7x)(1-8x)(1-9x)).
; Submitted by Jon Maiga
; 1,30,565,8550,113701,1388310,15958405,175419750,1863406501,19269697590,195034120645,1939826329350,19018419228901,184245490086870,1767124523521285,16805853434269350,158682246543588901,1489103597614860150,13900428943759584325,129167969123500551750,1195561200062262214501,11028224823511158641430,101425994612323844773765,930396563966744183768550,8515382613678968335553701,77782168725546348649174710,709254009021396663686993605,6457455850718736455083791750,58713643872780486341794774501
mov $1,1
mov $2,$0
mov $3,$0
lpb $2
mov $0,$3
sub $2,1
sub $0,$2
seq $0,20782 ; Expansion of 1/((1-7x)(1-8x)(1-9x)).
sub $0,$1
mul $1,7
add $1,$0
lpe
mov $0,$1
|
; void bit_beep_di(uint16_t duration_ms, uint16_t frequency_hz)
SECTION code_clib
SECTION code_sound_bit
PUBLIC _bit_beep_di
EXTERN asm_bit_beep_di
_bit_beep_di:
pop af
pop hl
pop de
push de
push hl
push af
jp asm_bit_beep_di
|
// Windows/PropVariant.cpp
#include "StdAfx.h"
#include "PropVariant.h"
#include "../Common/Defs.h"
namespace NWindows {
namespace NCOM {
CPropVariant::CPropVariant(const PROPVARIANT& varSrc)
{
vt = VT_EMPTY;
InternalCopy(&varSrc);
}
CPropVariant::CPropVariant(const CPropVariant& varSrc)
{
vt = VT_EMPTY;
InternalCopy(&varSrc);
}
CPropVariant::CPropVariant(BSTR bstrSrc)
{
vt = VT_EMPTY;
*this = bstrSrc;
}
CPropVariant::CPropVariant(LPCOLESTR lpszSrc)
{
vt = VT_EMPTY;
*this = lpszSrc;
}
CPropVariant& CPropVariant::operator=(const CPropVariant& varSrc)
{
InternalCopy(&varSrc);
return *this;
}
CPropVariant& CPropVariant::operator=(const PROPVARIANT& varSrc)
{
InternalCopy(&varSrc);
return *this;
}
CPropVariant& CPropVariant::operator=(BSTR bstrSrc)
{
*this = (LPCOLESTR)bstrSrc;
return *this;
}
CPropVariant& CPropVariant::operator=(LPCOLESTR lpszSrc)
{
InternalClear();
vt = VT_BSTR;
wReserved1 = 0;
bstrVal = ::SysAllocString(lpszSrc);
if (bstrVal == NULL && lpszSrc != NULL)
{
vt = VT_ERROR;
scode = E_OUTOFMEMORY;
}
return *this;
}
CPropVariant& CPropVariant::operator=(bool bSrc)
{
if (vt != VT_BOOL)
{
InternalClear();
vt = VT_BOOL;
}
boolVal = bSrc ? VARIANT_TRUE : VARIANT_FALSE;
return *this;
}
CPropVariant& CPropVariant::operator=(UInt32 value)
{
if (vt != VT_UI4)
{
InternalClear();
vt = VT_UI4;
}
ulVal = value;
return *this;
}
CPropVariant& CPropVariant::operator=(UInt64 value)
{
if (vt != VT_UI8)
{
InternalClear();
vt = VT_UI8;
}
uhVal.QuadPart = value;
return *this;
}
CPropVariant& CPropVariant::operator=(const FILETIME &value)
{
if (vt != VT_FILETIME)
{
InternalClear();
vt = VT_FILETIME;
}
filetime = value;
return *this;
}
CPropVariant& CPropVariant::operator=(Int32 value)
{
if (vt != VT_I4)
{
InternalClear();
vt = VT_I4;
}
lVal = value;
return *this;
}
CPropVariant& CPropVariant::operator=(Byte value)
{
if (vt != VT_UI1)
{
InternalClear();
vt = VT_UI1;
}
bVal = value;
return *this;
}
CPropVariant& CPropVariant::operator=(Int16 value)
{
if (vt != VT_I2)
{
InternalClear();
vt = VT_I2;
}
iVal = value;
return *this;
}
/*
CPropVariant& CPropVariant::operator=(LONG value)
{
if (vt != VT_I4)
{
InternalClear();
vt = VT_I4;
}
lVal = value;
return *this;
}
*/
static HRESULT MyPropVariantClear(PROPVARIANT *propVariant)
{
switch(propVariant->vt)
{
case VT_UI1:
case VT_I1:
case VT_I2:
case VT_UI2:
case VT_BOOL:
case VT_I4:
case VT_UI4:
case VT_R4:
case VT_INT:
case VT_UINT:
case VT_ERROR:
case VT_FILETIME:
case VT_UI8:
case VT_R8:
case VT_CY:
case VT_DATE:
propVariant->vt = VT_EMPTY;
propVariant->wReserved1 = 0;
return S_OK;
}
return ::VariantClear((VARIANTARG *)propVariant);
}
HRESULT CPropVariant::Clear()
{
return MyPropVariantClear(this);
}
HRESULT CPropVariant::Copy(const PROPVARIANT* pSrc)
{
::VariantClear((tagVARIANT *)this);
switch(pSrc->vt)
{
case VT_UI1:
case VT_I1:
case VT_I2:
case VT_UI2:
case VT_BOOL:
case VT_I4:
case VT_UI4:
case VT_R4:
case VT_INT:
case VT_UINT:
case VT_ERROR:
case VT_FILETIME:
case VT_UI8:
case VT_R8:
case VT_CY:
case VT_DATE:
memmove((PROPVARIANT*)this, pSrc, sizeof(PROPVARIANT));
return S_OK;
}
return ::VariantCopy((tagVARIANT *)this, (tagVARIANT *)(pSrc));
}
HRESULT CPropVariant::Attach(PROPVARIANT* pSrc)
{
HRESULT hr = Clear();
if (FAILED(hr))
return hr;
memcpy(this, pSrc, sizeof(PROPVARIANT));
pSrc->vt = VT_EMPTY;
return S_OK;
}
HRESULT CPropVariant::Detach(PROPVARIANT* pDest)
{
HRESULT hr = MyPropVariantClear(pDest);
if (FAILED(hr))
return hr;
memcpy(pDest, this, sizeof(PROPVARIANT));
vt = VT_EMPTY;
return S_OK;
}
HRESULT CPropVariant::InternalClear()
{
HRESULT hr = Clear();
if (FAILED(hr))
{
vt = VT_ERROR;
scode = hr;
}
return hr;
}
void CPropVariant::InternalCopy(const PROPVARIANT* pSrc)
{
HRESULT hr = Copy(pSrc);
if (FAILED(hr))
{
vt = VT_ERROR;
scode = hr;
}
}
int CPropVariant::Compare(const CPropVariant &a)
{
if (vt != a.vt)
return 0; // it's mean some bug
switch (vt)
{
case VT_EMPTY:
return 0;
/*
case VT_I1:
return MyCompare(cVal, a.cVal);
*/
case VT_UI1:
return MyCompare(bVal, a.bVal);
case VT_I2:
return MyCompare(iVal, a.iVal);
case VT_UI2:
return MyCompare(uiVal, a.uiVal);
case VT_I4:
return MyCompare(lVal, a.lVal);
/*
case VT_INT:
return MyCompare(intVal, a.intVal);
*/
case VT_UI4:
return MyCompare(ulVal, a.ulVal);
/*
case VT_UINT:
return MyCompare(uintVal, a.uintVal);
*/
case VT_I8:
return MyCompare(hVal.QuadPart, a.hVal.QuadPart);
case VT_UI8:
return MyCompare(uhVal.QuadPart, a.uhVal.QuadPart);
case VT_BOOL:
return -MyCompare(boolVal, a.boolVal);
case VT_FILETIME:
return ::CompareFileTime(&filetime, &a.filetime);
case VT_BSTR:
return 0; // Not implemented
// return MyCompare(aPropVarint.cVal);
default:
return 0;
}
}
}}
|
//===--- RewriteObjC.cpp - Playground for the code rewriter ---------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// Hacks and fun related to the code rewriter.
//
//===----------------------------------------------------------------------===//
#include "clang/Rewrite/Frontend/ASTConsumers.h"
#include "clang/AST/AST.h"
#include "clang/AST/ASTConsumer.h"
#include "clang/AST/Attr.h"
#include "clang/AST/ParentMap.h"
#include "clang/Basic/CharInfo.h"
#include "clang/Basic/Diagnostic.h"
#include "clang/Basic/IdentifierTable.h"
#include "clang/Basic/SourceManager.h"
#include "clang/Basic/TargetInfo.h"
#include "clang/Lex/Lexer.h"
#include "clang/Rewrite/Core/Rewriter.h"
#include "llvm/ADT/DenseSet.h"
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/raw_ostream.h"
#include <memory>
#ifdef CLANG_ENABLE_OBJC_REWRITER
using namespace clang;
using llvm::utostr;
namespace {
class RewriteModernObjC : public ASTConsumer {
protected:
enum {
BLOCK_FIELD_IS_OBJECT = 3, /* id, NSObject, __attribute__((NSObject)),
block, ... */
BLOCK_FIELD_IS_BLOCK = 7, /* a block variable */
BLOCK_FIELD_IS_BYREF = 8, /* the on stack structure holding the
__block variable */
BLOCK_FIELD_IS_WEAK = 16, /* declared __weak, only used in byref copy
helpers */
BLOCK_BYREF_CALLER = 128, /* called from __block (byref) copy/dispose
support routines */
BLOCK_BYREF_CURRENT_MAX = 256
};
enum {
BLOCK_NEEDS_FREE = (1 << 24),
BLOCK_HAS_COPY_DISPOSE = (1 << 25),
BLOCK_HAS_CXX_OBJ = (1 << 26),
BLOCK_IS_GC = (1 << 27),
BLOCK_IS_GLOBAL = (1 << 28),
BLOCK_HAS_DESCRIPTOR = (1 << 29)
};
Rewriter Rewrite;
DiagnosticsEngine &Diags;
const LangOptions &LangOpts;
ASTContext *Context;
SourceManager *SM;
TranslationUnitDecl *TUDecl;
FileID MainFileID;
const char *MainFileStart, *MainFileEnd;
Stmt *CurrentBody;
ParentMap *PropParentMap; // created lazily.
std::string InFileName;
raw_ostream* OutFile;
std::string Preamble;
TypeDecl *ProtocolTypeDecl;
VarDecl *GlobalVarDecl;
Expr *GlobalConstructionExp;
unsigned RewriteFailedDiag;
unsigned GlobalBlockRewriteFailedDiag;
// ObjC string constant support.
unsigned NumObjCStringLiterals;
VarDecl *ConstantStringClassReference;
RecordDecl *NSStringRecord;
// ObjC foreach break/continue generation support.
int BcLabelCount;
unsigned TryFinallyContainsReturnDiag;
// Needed for super.
ObjCMethodDecl *CurMethodDef;
RecordDecl *SuperStructDecl;
RecordDecl *ConstantStringDecl;
FunctionDecl *MsgSendFunctionDecl;
FunctionDecl *MsgSendSuperFunctionDecl;
FunctionDecl *MsgSendStretFunctionDecl;
FunctionDecl *MsgSendSuperStretFunctionDecl;
FunctionDecl *MsgSendFpretFunctionDecl;
FunctionDecl *GetClassFunctionDecl;
FunctionDecl *GetMetaClassFunctionDecl;
FunctionDecl *GetSuperClassFunctionDecl;
FunctionDecl *SelGetUidFunctionDecl;
FunctionDecl *CFStringFunctionDecl;
FunctionDecl *SuperConstructorFunctionDecl;
FunctionDecl *CurFunctionDef;
/* Misc. containers needed for meta-data rewrite. */
SmallVector<ObjCImplementationDecl *, 8> ClassImplementation;
SmallVector<ObjCCategoryImplDecl *, 8> CategoryImplementation;
llvm::SmallPtrSet<ObjCInterfaceDecl*, 8> ObjCSynthesizedStructs;
llvm::SmallPtrSet<ObjCProtocolDecl*, 8> ObjCSynthesizedProtocols;
llvm::SmallPtrSet<ObjCInterfaceDecl*, 8> ObjCWrittenInterfaces;
llvm::SmallPtrSet<TagDecl*, 32> GlobalDefinedTags;
SmallVector<ObjCInterfaceDecl*, 32> ObjCInterfacesSeen;
/// DefinedNonLazyClasses - List of defined "non-lazy" classes.
SmallVector<ObjCInterfaceDecl*, 8> DefinedNonLazyClasses;
/// DefinedNonLazyCategories - List of defined "non-lazy" categories.
SmallVector<ObjCCategoryDecl *, 8> DefinedNonLazyCategories;
SmallVector<Stmt *, 32> Stmts;
SmallVector<int, 8> ObjCBcLabelNo;
// Remember all the @protocol(<expr>) expressions.
llvm::SmallPtrSet<ObjCProtocolDecl *, 32> ProtocolExprDecls;
llvm::DenseSet<uint64_t> CopyDestroyCache;
// Block expressions.
SmallVector<BlockExpr *, 32> Blocks;
SmallVector<int, 32> InnerDeclRefsCount;
SmallVector<DeclRefExpr *, 32> InnerDeclRefs;
SmallVector<DeclRefExpr *, 32> BlockDeclRefs;
// Block related declarations.
SmallVector<ValueDecl *, 8> BlockByCopyDecls;
llvm::SmallPtrSet<ValueDecl *, 8> BlockByCopyDeclsPtrSet;
SmallVector<ValueDecl *, 8> BlockByRefDecls;
llvm::SmallPtrSet<ValueDecl *, 8> BlockByRefDeclsPtrSet;
llvm::DenseMap<ValueDecl *, unsigned> BlockByRefDeclNo;
llvm::SmallPtrSet<ValueDecl *, 8> ImportedBlockDecls;
llvm::SmallPtrSet<VarDecl *, 8> ImportedLocalExternalDecls;
llvm::DenseMap<BlockExpr *, std::string> RewrittenBlockExprs;
llvm::DenseMap<ObjCInterfaceDecl *,
llvm::SmallPtrSet<ObjCIvarDecl *, 8> > ReferencedIvars;
// ivar bitfield grouping containers
llvm::DenseSet<const ObjCInterfaceDecl *> ObjCInterefaceHasBitfieldGroups;
llvm::DenseMap<const ObjCIvarDecl* , unsigned> IvarGroupNumber;
// This container maps an <class, group number for ivar> tuple to the type
// of the struct where the bitfield belongs.
llvm::DenseMap<std::pair<const ObjCInterfaceDecl*, unsigned>, QualType> GroupRecordType;
SmallVector<FunctionDecl*, 32> FunctionDefinitionsSeen;
// This maps an original source AST to it's rewritten form. This allows
// us to avoid rewriting the same node twice (which is very uncommon).
// This is needed to support some of the exotic property rewriting.
llvm::DenseMap<Stmt *, Stmt *> ReplacedNodes;
// Needed for header files being rewritten
bool IsHeader;
bool SilenceRewriteMacroWarning;
bool GenerateLineInfo;
bool objc_impl_method;
bool DisableReplaceStmt;
class DisableReplaceStmtScope {
RewriteModernObjC &R;
bool SavedValue;
public:
DisableReplaceStmtScope(RewriteModernObjC &R)
: R(R), SavedValue(R.DisableReplaceStmt) {
R.DisableReplaceStmt = true;
}
~DisableReplaceStmtScope() {
R.DisableReplaceStmt = SavedValue;
}
};
void InitializeCommon(ASTContext &context);
public:
llvm::DenseMap<ObjCMethodDecl*, std::string> MethodInternalNames;
// Top Level Driver code.
bool HandleTopLevelDecl(DeclGroupRef D) override {
for (DeclGroupRef::iterator I = D.begin(), E = D.end(); I != E; ++I) {
if (ObjCInterfaceDecl *Class = dyn_cast<ObjCInterfaceDecl>(*I)) {
if (!Class->isThisDeclarationADefinition()) {
RewriteForwardClassDecl(D);
break;
} else {
// Keep track of all interface declarations seen.
ObjCInterfacesSeen.push_back(Class);
break;
}
}
if (ObjCProtocolDecl *Proto = dyn_cast<ObjCProtocolDecl>(*I)) {
if (!Proto->isThisDeclarationADefinition()) {
RewriteForwardProtocolDecl(D);
break;
}
}
if (FunctionDecl *FDecl = dyn_cast<FunctionDecl>(*I)) {
// Under modern abi, we cannot translate body of the function
// yet until all class extensions and its implementation is seen.
// This is because they may introduce new bitfields which must go
// into their grouping struct.
if (FDecl->isThisDeclarationADefinition() &&
// Not c functions defined inside an objc container.
!FDecl->isTopLevelDeclInObjCContainer()) {
FunctionDefinitionsSeen.push_back(FDecl);
break;
}
}
HandleTopLevelSingleDecl(*I);
}
return true;
}
void HandleTopLevelDeclInObjCContainer(DeclGroupRef D) override {
for (DeclGroupRef::iterator I = D.begin(), E = D.end(); I != E; ++I) {
if (TypedefNameDecl *TD = dyn_cast<TypedefNameDecl>(*I)) {
if (isTopLevelBlockPointerType(TD->getUnderlyingType()))
RewriteBlockPointerDecl(TD);
else if (TD->getUnderlyingType()->isFunctionPointerType())
CheckFunctionPointerDecl(TD->getUnderlyingType(), TD);
else
RewriteObjCQualifiedInterfaceTypes(TD);
}
}
return;
}
void HandleTopLevelSingleDecl(Decl *D);
void HandleDeclInMainFile(Decl *D);
RewriteModernObjC(std::string inFile, raw_ostream *OS,
DiagnosticsEngine &D, const LangOptions &LOpts,
bool silenceMacroWarn, bool LineInfo);
~RewriteModernObjC() {}
void HandleTranslationUnit(ASTContext &C) override;
void ReplaceStmt(Stmt *Old, Stmt *New) {
ReplaceStmtWithRange(Old, New, Old->getSourceRange());
}
void ReplaceStmtWithRange(Stmt *Old, Stmt *New, SourceRange SrcRange) {
assert(Old != nullptr && New != nullptr && "Expected non-null Stmt's");
Stmt *ReplacingStmt = ReplacedNodes[Old];
if (ReplacingStmt)
return; // We can't rewrite the same node twice.
if (DisableReplaceStmt)
return;
// Measure the old text.
int Size = Rewrite.getRangeSize(SrcRange);
if (Size == -1) {
Diags.Report(Context->getFullLoc(Old->getLocStart()), RewriteFailedDiag)
<< Old->getSourceRange();
return;
}
// Get the new text.
std::string SStr;
llvm::raw_string_ostream S(SStr);
New->printPretty(S, nullptr, PrintingPolicy(LangOpts));
const std::string &Str = S.str();
// If replacement succeeded or warning disabled return with no warning.
if (!Rewrite.ReplaceText(SrcRange.getBegin(), Size, Str)) {
ReplacedNodes[Old] = New;
return;
}
if (SilenceRewriteMacroWarning)
return;
Diags.Report(Context->getFullLoc(Old->getLocStart()), RewriteFailedDiag)
<< Old->getSourceRange();
}
void InsertText(SourceLocation Loc, StringRef Str,
bool InsertAfter = true) {
// If insertion succeeded or warning disabled return with no warning.
if (!Rewrite.InsertText(Loc, Str, InsertAfter) ||
SilenceRewriteMacroWarning)
return;
Diags.Report(Context->getFullLoc(Loc), RewriteFailedDiag);
}
void ReplaceText(SourceLocation Start, unsigned OrigLength,
StringRef Str) {
// If removal succeeded or warning disabled return with no warning.
if (!Rewrite.ReplaceText(Start, OrigLength, Str) ||
SilenceRewriteMacroWarning)
return;
Diags.Report(Context->getFullLoc(Start), RewriteFailedDiag);
}
// Syntactic Rewriting.
void RewriteRecordBody(RecordDecl *RD);
void RewriteInclude();
void RewriteLineDirective(const Decl *D);
void ConvertSourceLocationToLineDirective(SourceLocation Loc,
std::string &LineString);
void RewriteForwardClassDecl(DeclGroupRef D);
void RewriteForwardClassDecl(const SmallVectorImpl<Decl *> &DG);
void RewriteForwardClassEpilogue(ObjCInterfaceDecl *ClassDecl,
const std::string &typedefString);
void RewriteImplementations();
void RewritePropertyImplDecl(ObjCPropertyImplDecl *PID,
ObjCImplementationDecl *IMD,
ObjCCategoryImplDecl *CID);
void RewriteInterfaceDecl(ObjCInterfaceDecl *Dcl);
void RewriteImplementationDecl(Decl *Dcl);
void RewriteObjCMethodDecl(const ObjCInterfaceDecl *IDecl,
ObjCMethodDecl *MDecl, std::string &ResultStr);
void RewriteTypeIntoString(QualType T, std::string &ResultStr,
const FunctionType *&FPRetType);
void RewriteByRefString(std::string &ResultStr, const std::string &Name,
ValueDecl *VD, bool def=false);
void RewriteCategoryDecl(ObjCCategoryDecl *Dcl);
void RewriteProtocolDecl(ObjCProtocolDecl *Dcl);
void RewriteForwardProtocolDecl(DeclGroupRef D);
void RewriteForwardProtocolDecl(const SmallVectorImpl<Decl *> &DG);
void RewriteMethodDeclaration(ObjCMethodDecl *Method);
void RewriteProperty(ObjCPropertyDecl *prop);
void RewriteFunctionDecl(FunctionDecl *FD);
void RewriteBlockPointerType(std::string& Str, QualType Type);
void RewriteBlockPointerTypeVariable(std::string& Str, ValueDecl *VD);
void RewriteBlockLiteralFunctionDecl(FunctionDecl *FD);
void RewriteObjCQualifiedInterfaceTypes(Decl *Dcl);
void RewriteTypeOfDecl(VarDecl *VD);
void RewriteObjCQualifiedInterfaceTypes(Expr *E);
std::string getIvarAccessString(ObjCIvarDecl *D);
// Expression Rewriting.
Stmt *RewriteFunctionBodyOrGlobalInitializer(Stmt *S);
Stmt *RewriteAtEncode(ObjCEncodeExpr *Exp);
Stmt *RewritePropertyOrImplicitGetter(PseudoObjectExpr *Pseudo);
Stmt *RewritePropertyOrImplicitSetter(PseudoObjectExpr *Pseudo);
Stmt *RewriteAtSelector(ObjCSelectorExpr *Exp);
Stmt *RewriteMessageExpr(ObjCMessageExpr *Exp);
Stmt *RewriteObjCStringLiteral(ObjCStringLiteral *Exp);
Stmt *RewriteObjCBoolLiteralExpr(ObjCBoolLiteralExpr *Exp);
Stmt *RewriteObjCBoxedExpr(ObjCBoxedExpr *Exp);
Stmt *RewriteObjCArrayLiteralExpr(ObjCArrayLiteral *Exp);
Stmt *RewriteObjCDictionaryLiteralExpr(ObjCDictionaryLiteral *Exp);
Stmt *RewriteObjCProtocolExpr(ObjCProtocolExpr *Exp);
Stmt *RewriteObjCTryStmt(ObjCAtTryStmt *S);
Stmt *RewriteObjCAutoreleasePoolStmt(ObjCAutoreleasePoolStmt *S);
Stmt *RewriteObjCSynchronizedStmt(ObjCAtSynchronizedStmt *S);
Stmt *RewriteObjCThrowStmt(ObjCAtThrowStmt *S);
Stmt *RewriteObjCForCollectionStmt(ObjCForCollectionStmt *S,
SourceLocation OrigEnd);
Stmt *RewriteBreakStmt(BreakStmt *S);
Stmt *RewriteContinueStmt(ContinueStmt *S);
void RewriteCastExpr(CStyleCastExpr *CE);
void RewriteImplicitCastObjCExpr(CastExpr *IE);
void RewriteLinkageSpec(LinkageSpecDecl *LSD);
// Computes ivar bitfield group no.
unsigned ObjCIvarBitfieldGroupNo(ObjCIvarDecl *IV);
// Names field decl. for ivar bitfield group.
void ObjCIvarBitfieldGroupDecl(ObjCIvarDecl *IV, std::string &Result);
// Names struct type for ivar bitfield group.
void ObjCIvarBitfieldGroupType(ObjCIvarDecl *IV, std::string &Result);
// Names symbol for ivar bitfield group field offset.
void ObjCIvarBitfieldGroupOffset(ObjCIvarDecl *IV, std::string &Result);
// Given an ivar bitfield, it builds (or finds) its group record type.
QualType GetGroupRecordTypeForObjCIvarBitfield(ObjCIvarDecl *IV);
QualType SynthesizeBitfieldGroupStructType(
ObjCIvarDecl *IV,
SmallVectorImpl<ObjCIvarDecl *> &IVars);
// Block rewriting.
void RewriteBlocksInFunctionProtoType(QualType funcType, NamedDecl *D);
// Block specific rewrite rules.
void RewriteBlockPointerDecl(NamedDecl *VD);
void RewriteByRefVar(VarDecl *VD, bool firstDecl, bool lastDecl);
Stmt *RewriteBlockDeclRefExpr(DeclRefExpr *VD);
Stmt *RewriteLocalVariableExternalStorage(DeclRefExpr *DRE);
void RewriteBlockPointerFunctionArgs(FunctionDecl *FD);
void RewriteObjCInternalStruct(ObjCInterfaceDecl *CDecl,
std::string &Result);
void RewriteObjCFieldDecl(FieldDecl *fieldDecl, std::string &Result);
bool IsTagDefinedInsideClass(ObjCContainerDecl *IDecl, TagDecl *Tag,
bool &IsNamedDefinition);
void RewriteLocallyDefinedNamedAggregates(FieldDecl *fieldDecl,
std::string &Result);
bool RewriteObjCFieldDeclType(QualType &Type, std::string &Result);
void RewriteIvarOffsetSymbols(ObjCInterfaceDecl *CDecl,
std::string &Result);
void Initialize(ASTContext &context) override;
// Misc. AST transformation routines. Sometimes they end up calling
// rewriting routines on the new ASTs.
CallExpr *SynthesizeCallToFunctionDecl(FunctionDecl *FD,
Expr **args, unsigned nargs,
SourceLocation StartLoc=SourceLocation(),
SourceLocation EndLoc=SourceLocation());
Expr *SynthMsgSendStretCallExpr(FunctionDecl *MsgSendStretFlavor,
QualType returnType,
SmallVectorImpl<QualType> &ArgTypes,
SmallVectorImpl<Expr*> &MsgExprs,
ObjCMethodDecl *Method);
Stmt *SynthMessageExpr(ObjCMessageExpr *Exp,
SourceLocation StartLoc=SourceLocation(),
SourceLocation EndLoc=SourceLocation());
void SynthCountByEnumWithState(std::string &buf);
void SynthMsgSendFunctionDecl();
void SynthMsgSendSuperFunctionDecl();
void SynthMsgSendStretFunctionDecl();
void SynthMsgSendFpretFunctionDecl();
void SynthMsgSendSuperStretFunctionDecl();
void SynthGetClassFunctionDecl();
void SynthGetMetaClassFunctionDecl();
void SynthGetSuperClassFunctionDecl();
void SynthSelGetUidFunctionDecl();
void SynthSuperConstructorFunctionDecl();
// Rewriting metadata
template<typename MethodIterator>
void RewriteObjCMethodsMetaData(MethodIterator MethodBegin,
MethodIterator MethodEnd,
bool IsInstanceMethod,
StringRef prefix,
StringRef ClassName,
std::string &Result);
void RewriteObjCProtocolMetaData(ObjCProtocolDecl *Protocol,
std::string &Result);
void RewriteObjCProtocolListMetaData(
const ObjCList<ObjCProtocolDecl> &Prots,
StringRef prefix, StringRef ClassName, std::string &Result);
void RewriteObjCClassMetaData(ObjCImplementationDecl *IDecl,
std::string &Result);
void RewriteClassSetupInitHook(std::string &Result);
void RewriteMetaDataIntoBuffer(std::string &Result);
void WriteImageInfo(std::string &Result);
void RewriteObjCCategoryImplDecl(ObjCCategoryImplDecl *CDecl,
std::string &Result);
void RewriteCategorySetupInitHook(std::string &Result);
// Rewriting ivar
void RewriteIvarOffsetComputation(ObjCIvarDecl *ivar,
std::string &Result);
Stmt *RewriteObjCIvarRefExpr(ObjCIvarRefExpr *IV);
std::string SynthesizeByrefCopyDestroyHelper(VarDecl *VD, int flag);
std::string SynthesizeBlockHelperFuncs(BlockExpr *CE, int i,
StringRef funcName, std::string Tag);
std::string SynthesizeBlockFunc(BlockExpr *CE, int i,
StringRef funcName, std::string Tag);
std::string SynthesizeBlockImpl(BlockExpr *CE,
std::string Tag, std::string Desc);
std::string SynthesizeBlockDescriptor(std::string DescTag,
std::string ImplTag,
int i, StringRef funcName,
unsigned hasCopy);
Stmt *SynthesizeBlockCall(CallExpr *Exp, const Expr* BlockExp);
void SynthesizeBlockLiterals(SourceLocation FunLocStart,
StringRef FunName);
FunctionDecl *SynthBlockInitFunctionDecl(StringRef name);
Stmt *SynthBlockInitExpr(BlockExpr *Exp,
const SmallVectorImpl<DeclRefExpr *> &InnerBlockDeclRefs);
// Misc. helper routines.
QualType getProtocolType();
void WarnAboutReturnGotoStmts(Stmt *S);
void CheckFunctionPointerDecl(QualType dType, NamedDecl *ND);
void InsertBlockLiteralsWithinFunction(FunctionDecl *FD);
void InsertBlockLiteralsWithinMethod(ObjCMethodDecl *MD);
bool IsDeclStmtInForeachHeader(DeclStmt *DS);
void CollectBlockDeclRefInfo(BlockExpr *Exp);
void GetBlockDeclRefExprs(Stmt *S);
void GetInnerBlockDeclRefExprs(Stmt *S,
SmallVectorImpl<DeclRefExpr *> &InnerBlockDeclRefs,
llvm::SmallPtrSetImpl<const DeclContext *> &InnerContexts);
// We avoid calling Type::isBlockPointerType(), since it operates on the
// canonical type. We only care if the top-level type is a closure pointer.
bool isTopLevelBlockPointerType(QualType T) {
return isa<BlockPointerType>(T);
}
/// convertBlockPointerToFunctionPointer - Converts a block-pointer type
/// to a function pointer type and upon success, returns true; false
/// otherwise.
bool convertBlockPointerToFunctionPointer(QualType &T) {
if (isTopLevelBlockPointerType(T)) {
const BlockPointerType *BPT = T->getAs<BlockPointerType>();
T = Context->getPointerType(BPT->getPointeeType());
return true;
}
return false;
}
bool convertObjCTypeToCStyleType(QualType &T);
bool needToScanForQualifiers(QualType T);
QualType getSuperStructType();
QualType getConstantStringStructType();
QualType convertFunctionTypeOfBlocks(const FunctionType *FT);
bool BufferContainsPPDirectives(const char *startBuf, const char *endBuf);
void convertToUnqualifiedObjCType(QualType &T) {
if (T->isObjCQualifiedIdType()) {
bool isConst = T.isConstQualified();
T = isConst ? Context->getObjCIdType().withConst()
: Context->getObjCIdType();
}
else if (T->isObjCQualifiedClassType())
T = Context->getObjCClassType();
else if (T->isObjCObjectPointerType() &&
T->getPointeeType()->isObjCQualifiedInterfaceType()) {
if (const ObjCObjectPointerType * OBJPT =
T->getAsObjCInterfacePointerType()) {
const ObjCInterfaceType *IFaceT = OBJPT->getInterfaceType();
T = QualType(IFaceT, 0);
T = Context->getPointerType(T);
}
}
}
// FIXME: This predicate seems like it would be useful to add to ASTContext.
bool isObjCType(QualType T) {
if (!LangOpts.ObjC1 && !LangOpts.ObjC2)
return false;
QualType OCT = Context->getCanonicalType(T).getUnqualifiedType();
if (OCT == Context->getCanonicalType(Context->getObjCIdType()) ||
OCT == Context->getCanonicalType(Context->getObjCClassType()))
return true;
if (const PointerType *PT = OCT->getAs<PointerType>()) {
if (isa<ObjCInterfaceType>(PT->getPointeeType()) ||
PT->getPointeeType()->isObjCQualifiedIdType())
return true;
}
return false;
}
bool PointerTypeTakesAnyBlockArguments(QualType QT);
bool PointerTypeTakesAnyObjCQualifiedType(QualType QT);
void GetExtentOfArgList(const char *Name, const char *&LParen,
const char *&RParen);
void QuoteDoublequotes(std::string &From, std::string &To) {
for (unsigned i = 0; i < From.length(); i++) {
if (From[i] == '"')
To += "\\\"";
else
To += From[i];
}
}
QualType getSimpleFunctionType(QualType result,
ArrayRef<QualType> args,
bool variadic = false) {
if (result == Context->getObjCInstanceType())
result = Context->getObjCIdType();
FunctionProtoType::ExtProtoInfo fpi;
fpi.Variadic = variadic;
return Context->getFunctionType(result, args, fpi);
}
// Helper function: create a CStyleCastExpr with trivial type source info.
CStyleCastExpr* NoTypeInfoCStyleCastExpr(ASTContext *Ctx, QualType Ty,
CastKind Kind, Expr *E) {
TypeSourceInfo *TInfo = Ctx->getTrivialTypeSourceInfo(Ty, SourceLocation());
return CStyleCastExpr::Create(*Ctx, Ty, VK_RValue, Kind, E, nullptr,
TInfo, SourceLocation(), SourceLocation());
}
bool ImplementationIsNonLazy(const ObjCImplDecl *OD) const {
IdentifierInfo* II = &Context->Idents.get("load");
Selector LoadSel = Context->Selectors.getSelector(0, &II);
return OD->getClassMethod(LoadSel) != nullptr;
}
StringLiteral *getStringLiteral(StringRef Str) {
QualType StrType = Context->getConstantArrayType(
Context->CharTy, llvm::APInt(32, Str.size() + 1), ArrayType::Normal,
0);
return StringLiteral::Create(*Context, Str, StringLiteral::Ascii,
/*Pascal=*/false, StrType, SourceLocation());
}
};
}
void RewriteModernObjC::RewriteBlocksInFunctionProtoType(QualType funcType,
NamedDecl *D) {
if (const FunctionProtoType *fproto
= dyn_cast<FunctionProtoType>(funcType.IgnoreParens())) {
for (const auto &I : fproto->param_types())
if (isTopLevelBlockPointerType(I)) {
// All the args are checked/rewritten. Don't call twice!
RewriteBlockPointerDecl(D);
break;
}
}
}
void RewriteModernObjC::CheckFunctionPointerDecl(QualType funcType, NamedDecl *ND) {
const PointerType *PT = funcType->getAs<PointerType>();
if (PT && PointerTypeTakesAnyBlockArguments(funcType))
RewriteBlocksInFunctionProtoType(PT->getPointeeType(), ND);
}
static bool IsHeaderFile(const std::string &Filename) {
std::string::size_type DotPos = Filename.rfind('.');
if (DotPos == std::string::npos) {
// no file extension
return false;
}
std::string Ext = std::string(Filename.begin()+DotPos+1, Filename.end());
// C header: .h
// C++ header: .hh or .H;
return Ext == "h" || Ext == "hh" || Ext == "H";
}
RewriteModernObjC::RewriteModernObjC(std::string inFile, raw_ostream* OS,
DiagnosticsEngine &D, const LangOptions &LOpts,
bool silenceMacroWarn,
bool LineInfo)
: Diags(D), LangOpts(LOpts), InFileName(inFile), OutFile(OS),
SilenceRewriteMacroWarning(silenceMacroWarn), GenerateLineInfo(LineInfo) {
IsHeader = IsHeaderFile(inFile);
RewriteFailedDiag = Diags.getCustomDiagID(DiagnosticsEngine::Warning,
"rewriting sub-expression within a macro (may not be correct)");
// FIXME. This should be an error. But if block is not called, it is OK. And it
// may break including some headers.
GlobalBlockRewriteFailedDiag = Diags.getCustomDiagID(DiagnosticsEngine::Warning,
"rewriting block literal declared in global scope is not implemented");
TryFinallyContainsReturnDiag = Diags.getCustomDiagID(
DiagnosticsEngine::Warning,
"rewriter doesn't support user-specified control flow semantics "
"for @try/@finally (code may not execute properly)");
}
std::unique_ptr<ASTConsumer> clang::CreateModernObjCRewriter(
const std::string &InFile, raw_ostream *OS, DiagnosticsEngine &Diags,
const LangOptions &LOpts, bool SilenceRewriteMacroWarning, bool LineInfo) {
return llvm::make_unique<RewriteModernObjC>(
InFile, OS, Diags, LOpts, SilenceRewriteMacroWarning, LineInfo);
}
void RewriteModernObjC::InitializeCommon(ASTContext &context) {
Context = &context;
SM = &Context->getSourceManager();
TUDecl = Context->getTranslationUnitDecl();
MsgSendFunctionDecl = nullptr;
MsgSendSuperFunctionDecl = nullptr;
MsgSendStretFunctionDecl = nullptr;
MsgSendSuperStretFunctionDecl = nullptr;
MsgSendFpretFunctionDecl = nullptr;
GetClassFunctionDecl = nullptr;
GetMetaClassFunctionDecl = nullptr;
GetSuperClassFunctionDecl = nullptr;
SelGetUidFunctionDecl = nullptr;
CFStringFunctionDecl = nullptr;
ConstantStringClassReference = nullptr;
NSStringRecord = nullptr;
CurMethodDef = nullptr;
CurFunctionDef = nullptr;
GlobalVarDecl = nullptr;
GlobalConstructionExp = nullptr;
SuperStructDecl = nullptr;
ProtocolTypeDecl = nullptr;
ConstantStringDecl = nullptr;
BcLabelCount = 0;
SuperConstructorFunctionDecl = nullptr;
NumObjCStringLiterals = 0;
PropParentMap = nullptr;
CurrentBody = nullptr;
DisableReplaceStmt = false;
objc_impl_method = false;
// Get the ID and start/end of the main file.
MainFileID = SM->getMainFileID();
const llvm::MemoryBuffer *MainBuf = SM->getBuffer(MainFileID);
MainFileStart = MainBuf->getBufferStart();
MainFileEnd = MainBuf->getBufferEnd();
Rewrite.setSourceMgr(Context->getSourceManager(), Context->getLangOpts());
}
//===----------------------------------------------------------------------===//
// Top Level Driver Code
//===----------------------------------------------------------------------===//
void RewriteModernObjC::HandleTopLevelSingleDecl(Decl *D) {
if (Diags.hasErrorOccurred())
return;
// Two cases: either the decl could be in the main file, or it could be in a
// #included file. If the former, rewrite it now. If the later, check to see
// if we rewrote the #include/#import.
SourceLocation Loc = D->getLocation();
Loc = SM->getExpansionLoc(Loc);
// If this is for a builtin, ignore it.
if (Loc.isInvalid()) return;
// Look for built-in declarations that we need to refer during the rewrite.
if (FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
RewriteFunctionDecl(FD);
} else if (VarDecl *FVD = dyn_cast<VarDecl>(D)) {
// declared in <Foundation/NSString.h>
if (FVD->getName() == "_NSConstantStringClassReference") {
ConstantStringClassReference = FVD;
return;
}
} else if (ObjCCategoryDecl *CD = dyn_cast<ObjCCategoryDecl>(D)) {
RewriteCategoryDecl(CD);
} else if (ObjCProtocolDecl *PD = dyn_cast<ObjCProtocolDecl>(D)) {
if (PD->isThisDeclarationADefinition())
RewriteProtocolDecl(PD);
} else if (LinkageSpecDecl *LSD = dyn_cast<LinkageSpecDecl>(D)) {
// FIXME. This will not work in all situations and leaving it out
// is harmless.
// RewriteLinkageSpec(LSD);
// Recurse into linkage specifications
for (DeclContext::decl_iterator DI = LSD->decls_begin(),
DIEnd = LSD->decls_end();
DI != DIEnd; ) {
if (ObjCInterfaceDecl *IFace = dyn_cast<ObjCInterfaceDecl>((*DI))) {
if (!IFace->isThisDeclarationADefinition()) {
SmallVector<Decl *, 8> DG;
SourceLocation StartLoc = IFace->getLocStart();
do {
if (isa<ObjCInterfaceDecl>(*DI) &&
!cast<ObjCInterfaceDecl>(*DI)->isThisDeclarationADefinition() &&
StartLoc == (*DI)->getLocStart())
DG.push_back(*DI);
else
break;
++DI;
} while (DI != DIEnd);
RewriteForwardClassDecl(DG);
continue;
}
else {
// Keep track of all interface declarations seen.
ObjCInterfacesSeen.push_back(IFace);
++DI;
continue;
}
}
if (ObjCProtocolDecl *Proto = dyn_cast<ObjCProtocolDecl>((*DI))) {
if (!Proto->isThisDeclarationADefinition()) {
SmallVector<Decl *, 8> DG;
SourceLocation StartLoc = Proto->getLocStart();
do {
if (isa<ObjCProtocolDecl>(*DI) &&
!cast<ObjCProtocolDecl>(*DI)->isThisDeclarationADefinition() &&
StartLoc == (*DI)->getLocStart())
DG.push_back(*DI);
else
break;
++DI;
} while (DI != DIEnd);
RewriteForwardProtocolDecl(DG);
continue;
}
}
HandleTopLevelSingleDecl(*DI);
++DI;
}
}
// If we have a decl in the main file, see if we should rewrite it.
if (SM->isWrittenInMainFile(Loc))
return HandleDeclInMainFile(D);
}
//===----------------------------------------------------------------------===//
// Syntactic (non-AST) Rewriting Code
//===----------------------------------------------------------------------===//
void RewriteModernObjC::RewriteInclude() {
SourceLocation LocStart = SM->getLocForStartOfFile(MainFileID);
StringRef MainBuf = SM->getBufferData(MainFileID);
const char *MainBufStart = MainBuf.begin();
const char *MainBufEnd = MainBuf.end();
size_t ImportLen = strlen("import");
// Loop over the whole file, looking for includes.
for (const char *BufPtr = MainBufStart; BufPtr < MainBufEnd; ++BufPtr) {
if (*BufPtr == '#') {
if (++BufPtr == MainBufEnd)
return;
while (*BufPtr == ' ' || *BufPtr == '\t')
if (++BufPtr == MainBufEnd)
return;
if (!strncmp(BufPtr, "import", ImportLen)) {
// replace import with include
SourceLocation ImportLoc =
LocStart.getLocWithOffset(BufPtr-MainBufStart);
ReplaceText(ImportLoc, ImportLen, "include");
BufPtr += ImportLen;
}
}
}
}
static void WriteInternalIvarName(const ObjCInterfaceDecl *IDecl,
ObjCIvarDecl *IvarDecl, std::string &Result) {
Result += "OBJC_IVAR_$_";
Result += IDecl->getName();
Result += "$";
Result += IvarDecl->getName();
}
std::string
RewriteModernObjC::getIvarAccessString(ObjCIvarDecl *D) {
const ObjCInterfaceDecl *ClassDecl = D->getContainingInterface();
// Build name of symbol holding ivar offset.
std::string IvarOffsetName;
if (D->isBitField())
ObjCIvarBitfieldGroupOffset(D, IvarOffsetName);
else
WriteInternalIvarName(ClassDecl, D, IvarOffsetName);
std::string S = "(*(";
QualType IvarT = D->getType();
if (D->isBitField())
IvarT = GetGroupRecordTypeForObjCIvarBitfield(D);
if (!isa<TypedefType>(IvarT) && IvarT->isRecordType()) {
RecordDecl *RD = IvarT->getAs<RecordType>()->getDecl();
RD = RD->getDefinition();
if (RD && !RD->getDeclName().getAsIdentifierInfo()) {
// decltype(((Foo_IMPL*)0)->bar) *
ObjCContainerDecl *CDecl =
dyn_cast<ObjCContainerDecl>(D->getDeclContext());
// ivar in class extensions requires special treatment.
if (ObjCCategoryDecl *CatDecl = dyn_cast<ObjCCategoryDecl>(CDecl))
CDecl = CatDecl->getClassInterface();
std::string RecName = CDecl->getName();
RecName += "_IMPL";
RecordDecl *RD = RecordDecl::Create(*Context, TTK_Struct, TUDecl,
SourceLocation(), SourceLocation(),
&Context->Idents.get(RecName.c_str()));
QualType PtrStructIMPL = Context->getPointerType(Context->getTagDeclType(RD));
unsigned UnsignedIntSize =
static_cast<unsigned>(Context->getTypeSize(Context->UnsignedIntTy));
Expr *Zero = IntegerLiteral::Create(*Context,
llvm::APInt(UnsignedIntSize, 0),
Context->UnsignedIntTy, SourceLocation());
Zero = NoTypeInfoCStyleCastExpr(Context, PtrStructIMPL, CK_BitCast, Zero);
ParenExpr *PE = new (Context) ParenExpr(SourceLocation(), SourceLocation(),
Zero);
FieldDecl *FD = FieldDecl::Create(*Context, nullptr, SourceLocation(),
SourceLocation(),
&Context->Idents.get(D->getNameAsString()),
IvarT, nullptr,
/*BitWidth=*/nullptr, /*Mutable=*/true,
ICIS_NoInit);
MemberExpr *ME = new (Context) MemberExpr(PE, true, FD, SourceLocation(),
FD->getType(), VK_LValue,
OK_Ordinary);
IvarT = Context->getDecltypeType(ME, ME->getType());
}
}
convertObjCTypeToCStyleType(IvarT);
QualType castT = Context->getPointerType(IvarT);
std::string TypeString(castT.getAsString(Context->getPrintingPolicy()));
S += TypeString;
S += ")";
// ((char *)self + IVAR_OFFSET_SYMBOL_NAME)
S += "((char *)self + ";
S += IvarOffsetName;
S += "))";
if (D->isBitField()) {
S += ".";
S += D->getNameAsString();
}
ReferencedIvars[const_cast<ObjCInterfaceDecl *>(ClassDecl)].insert(D);
return S;
}
/// mustSynthesizeSetterGetterMethod - returns true if setter or getter has not
/// been found in the class implementation. In this case, it must be synthesized.
static bool mustSynthesizeSetterGetterMethod(ObjCImplementationDecl *IMP,
ObjCPropertyDecl *PD,
bool getter) {
return getter ? !IMP->getInstanceMethod(PD->getGetterName())
: !IMP->getInstanceMethod(PD->getSetterName());
}
void RewriteModernObjC::RewritePropertyImplDecl(ObjCPropertyImplDecl *PID,
ObjCImplementationDecl *IMD,
ObjCCategoryImplDecl *CID) {
static bool objcGetPropertyDefined = false;
static bool objcSetPropertyDefined = false;
SourceLocation startGetterSetterLoc;
if (PID->getLocStart().isValid()) {
SourceLocation startLoc = PID->getLocStart();
InsertText(startLoc, "// ");
const char *startBuf = SM->getCharacterData(startLoc);
assert((*startBuf == '@') && "bogus @synthesize location");
const char *semiBuf = strchr(startBuf, ';');
assert((*semiBuf == ';') && "@synthesize: can't find ';'");
startGetterSetterLoc = startLoc.getLocWithOffset(semiBuf-startBuf+1);
}
else
startGetterSetterLoc = IMD ? IMD->getLocEnd() : CID->getLocEnd();
if (PID->getPropertyImplementation() == ObjCPropertyImplDecl::Dynamic)
return; // FIXME: is this correct?
// Generate the 'getter' function.
ObjCPropertyDecl *PD = PID->getPropertyDecl();
ObjCIvarDecl *OID = PID->getPropertyIvarDecl();
assert(IMD && OID && "Synthesized ivars must be attached to @implementation");
unsigned Attributes = PD->getPropertyAttributes();
if (mustSynthesizeSetterGetterMethod(IMD, PD, true /*getter*/)) {
bool GenGetProperty = !(Attributes & ObjCPropertyDecl::OBJC_PR_nonatomic) &&
(Attributes & (ObjCPropertyDecl::OBJC_PR_retain |
ObjCPropertyDecl::OBJC_PR_copy));
std::string Getr;
if (GenGetProperty && !objcGetPropertyDefined) {
objcGetPropertyDefined = true;
// FIXME. Is this attribute correct in all cases?
Getr = "\nextern \"C\" __declspec(dllimport) "
"id objc_getProperty(id, SEL, long, bool);\n";
}
RewriteObjCMethodDecl(OID->getContainingInterface(),
PD->getGetterMethodDecl(), Getr);
Getr += "{ ";
// Synthesize an explicit cast to gain access to the ivar.
// See objc-act.c:objc_synthesize_new_getter() for details.
if (GenGetProperty) {
// return objc_getProperty(self, _cmd, offsetof(ClassDecl, OID), 1)
Getr += "typedef ";
const FunctionType *FPRetType = nullptr;
RewriteTypeIntoString(PD->getGetterMethodDecl()->getReturnType(), Getr,
FPRetType);
Getr += " _TYPE";
if (FPRetType) {
Getr += ")"; // close the precedence "scope" for "*".
// Now, emit the argument types (if any).
if (const FunctionProtoType *FT = dyn_cast<FunctionProtoType>(FPRetType)){
Getr += "(";
for (unsigned i = 0, e = FT->getNumParams(); i != e; ++i) {
if (i) Getr += ", ";
std::string ParamStr =
FT->getParamType(i).getAsString(Context->getPrintingPolicy());
Getr += ParamStr;
}
if (FT->isVariadic()) {
if (FT->getNumParams())
Getr += ", ";
Getr += "...";
}
Getr += ")";
} else
Getr += "()";
}
Getr += ";\n";
Getr += "return (_TYPE)";
Getr += "objc_getProperty(self, _cmd, ";
RewriteIvarOffsetComputation(OID, Getr);
Getr += ", 1)";
}
else
Getr += "return " + getIvarAccessString(OID);
Getr += "; }";
InsertText(startGetterSetterLoc, Getr);
}
if (PD->isReadOnly() ||
!mustSynthesizeSetterGetterMethod(IMD, PD, false /*setter*/))
return;
// Generate the 'setter' function.
std::string Setr;
bool GenSetProperty = Attributes & (ObjCPropertyDecl::OBJC_PR_retain |
ObjCPropertyDecl::OBJC_PR_copy);
if (GenSetProperty && !objcSetPropertyDefined) {
objcSetPropertyDefined = true;
// FIXME. Is this attribute correct in all cases?
Setr = "\nextern \"C\" __declspec(dllimport) "
"void objc_setProperty (id, SEL, long, id, bool, bool);\n";
}
RewriteObjCMethodDecl(OID->getContainingInterface(),
PD->getSetterMethodDecl(), Setr);
Setr += "{ ";
// Synthesize an explicit cast to initialize the ivar.
// See objc-act.c:objc_synthesize_new_setter() for details.
if (GenSetProperty) {
Setr += "objc_setProperty (self, _cmd, ";
RewriteIvarOffsetComputation(OID, Setr);
Setr += ", (id)";
Setr += PD->getName();
Setr += ", ";
if (Attributes & ObjCPropertyDecl::OBJC_PR_nonatomic)
Setr += "0, ";
else
Setr += "1, ";
if (Attributes & ObjCPropertyDecl::OBJC_PR_copy)
Setr += "1)";
else
Setr += "0)";
}
else {
Setr += getIvarAccessString(OID) + " = ";
Setr += PD->getName();
}
Setr += "; }\n";
InsertText(startGetterSetterLoc, Setr);
}
static void RewriteOneForwardClassDecl(ObjCInterfaceDecl *ForwardDecl,
std::string &typedefString) {
typedefString += "\n#ifndef _REWRITER_typedef_";
typedefString += ForwardDecl->getNameAsString();
typedefString += "\n";
typedefString += "#define _REWRITER_typedef_";
typedefString += ForwardDecl->getNameAsString();
typedefString += "\n";
typedefString += "typedef struct objc_object ";
typedefString += ForwardDecl->getNameAsString();
// typedef struct { } _objc_exc_Classname;
typedefString += ";\ntypedef struct {} _objc_exc_";
typedefString += ForwardDecl->getNameAsString();
typedefString += ";\n#endif\n";
}
void RewriteModernObjC::RewriteForwardClassEpilogue(ObjCInterfaceDecl *ClassDecl,
const std::string &typedefString) {
SourceLocation startLoc = ClassDecl->getLocStart();
const char *startBuf = SM->getCharacterData(startLoc);
const char *semiPtr = strchr(startBuf, ';');
// Replace the @class with typedefs corresponding to the classes.
ReplaceText(startLoc, semiPtr-startBuf+1, typedefString);
}
void RewriteModernObjC::RewriteForwardClassDecl(DeclGroupRef D) {
std::string typedefString;
for (DeclGroupRef::iterator I = D.begin(), E = D.end(); I != E; ++I) {
if (ObjCInterfaceDecl *ForwardDecl = dyn_cast<ObjCInterfaceDecl>(*I)) {
if (I == D.begin()) {
// Translate to typedef's that forward reference structs with the same name
// as the class. As a convenience, we include the original declaration
// as a comment.
typedefString += "// @class ";
typedefString += ForwardDecl->getNameAsString();
typedefString += ";";
}
RewriteOneForwardClassDecl(ForwardDecl, typedefString);
}
else
HandleTopLevelSingleDecl(*I);
}
DeclGroupRef::iterator I = D.begin();
RewriteForwardClassEpilogue(cast<ObjCInterfaceDecl>(*I), typedefString);
}
void RewriteModernObjC::RewriteForwardClassDecl(
const SmallVectorImpl<Decl *> &D) {
std::string typedefString;
for (unsigned i = 0; i < D.size(); i++) {
ObjCInterfaceDecl *ForwardDecl = cast<ObjCInterfaceDecl>(D[i]);
if (i == 0) {
typedefString += "// @class ";
typedefString += ForwardDecl->getNameAsString();
typedefString += ";";
}
RewriteOneForwardClassDecl(ForwardDecl, typedefString);
}
RewriteForwardClassEpilogue(cast<ObjCInterfaceDecl>(D[0]), typedefString);
}
void RewriteModernObjC::RewriteMethodDeclaration(ObjCMethodDecl *Method) {
// When method is a synthesized one, such as a getter/setter there is
// nothing to rewrite.
if (Method->isImplicit())
return;
SourceLocation LocStart = Method->getLocStart();
SourceLocation LocEnd = Method->getLocEnd();
if (SM->getExpansionLineNumber(LocEnd) >
SM->getExpansionLineNumber(LocStart)) {
InsertText(LocStart, "#if 0\n");
ReplaceText(LocEnd, 1, ";\n#endif\n");
} else {
InsertText(LocStart, "// ");
}
}
void RewriteModernObjC::RewriteProperty(ObjCPropertyDecl *prop) {
SourceLocation Loc = prop->getAtLoc();
ReplaceText(Loc, 0, "// ");
// FIXME: handle properties that are declared across multiple lines.
}
void RewriteModernObjC::RewriteCategoryDecl(ObjCCategoryDecl *CatDecl) {
SourceLocation LocStart = CatDecl->getLocStart();
// FIXME: handle category headers that are declared across multiple lines.
if (CatDecl->getIvarRBraceLoc().isValid()) {
ReplaceText(LocStart, 1, "/** ");
ReplaceText(CatDecl->getIvarRBraceLoc(), 1, "**/ ");
}
else {
ReplaceText(LocStart, 0, "// ");
}
for (auto *I : CatDecl->properties())
RewriteProperty(I);
for (auto *I : CatDecl->instance_methods())
RewriteMethodDeclaration(I);
for (auto *I : CatDecl->class_methods())
RewriteMethodDeclaration(I);
// Lastly, comment out the @end.
ReplaceText(CatDecl->getAtEndRange().getBegin(),
strlen("@end"), "/* @end */\n");
}
void RewriteModernObjC::RewriteProtocolDecl(ObjCProtocolDecl *PDecl) {
SourceLocation LocStart = PDecl->getLocStart();
assert(PDecl->isThisDeclarationADefinition());
// FIXME: handle protocol headers that are declared across multiple lines.
ReplaceText(LocStart, 0, "// ");
for (auto *I : PDecl->instance_methods())
RewriteMethodDeclaration(I);
for (auto *I : PDecl->class_methods())
RewriteMethodDeclaration(I);
for (auto *I : PDecl->properties())
RewriteProperty(I);
// Lastly, comment out the @end.
SourceLocation LocEnd = PDecl->getAtEndRange().getBegin();
ReplaceText(LocEnd, strlen("@end"), "/* @end */\n");
// Must comment out @optional/@required
const char *startBuf = SM->getCharacterData(LocStart);
const char *endBuf = SM->getCharacterData(LocEnd);
for (const char *p = startBuf; p < endBuf; p++) {
if (*p == '@' && !strncmp(p+1, "optional", strlen("optional"))) {
SourceLocation OptionalLoc = LocStart.getLocWithOffset(p-startBuf);
ReplaceText(OptionalLoc, strlen("@optional"), "/* @optional */");
}
else if (*p == '@' && !strncmp(p+1, "required", strlen("required"))) {
SourceLocation OptionalLoc = LocStart.getLocWithOffset(p-startBuf);
ReplaceText(OptionalLoc, strlen("@required"), "/* @required */");
}
}
}
void RewriteModernObjC::RewriteForwardProtocolDecl(DeclGroupRef D) {
SourceLocation LocStart = (*D.begin())->getLocStart();
if (LocStart.isInvalid())
llvm_unreachable("Invalid SourceLocation");
// FIXME: handle forward protocol that are declared across multiple lines.
ReplaceText(LocStart, 0, "// ");
}
void
RewriteModernObjC::RewriteForwardProtocolDecl(const SmallVectorImpl<Decl *> &DG) {
SourceLocation LocStart = DG[0]->getLocStart();
if (LocStart.isInvalid())
llvm_unreachable("Invalid SourceLocation");
// FIXME: handle forward protocol that are declared across multiple lines.
ReplaceText(LocStart, 0, "// ");
}
void
RewriteModernObjC::RewriteLinkageSpec(LinkageSpecDecl *LSD) {
SourceLocation LocStart = LSD->getExternLoc();
if (LocStart.isInvalid())
llvm_unreachable("Invalid extern SourceLocation");
ReplaceText(LocStart, 0, "// ");
if (!LSD->hasBraces())
return;
// FIXME. We don't rewrite well if '{' is not on same line as 'extern'.
SourceLocation LocRBrace = LSD->getRBraceLoc();
if (LocRBrace.isInvalid())
llvm_unreachable("Invalid rbrace SourceLocation");
ReplaceText(LocRBrace, 0, "// ");
}
void RewriteModernObjC::RewriteTypeIntoString(QualType T, std::string &ResultStr,
const FunctionType *&FPRetType) {
if (T->isObjCQualifiedIdType())
ResultStr += "id";
else if (T->isFunctionPointerType() ||
T->isBlockPointerType()) {
// needs special handling, since pointer-to-functions have special
// syntax (where a decaration models use).
QualType retType = T;
QualType PointeeTy;
if (const PointerType* PT = retType->getAs<PointerType>())
PointeeTy = PT->getPointeeType();
else if (const BlockPointerType *BPT = retType->getAs<BlockPointerType>())
PointeeTy = BPT->getPointeeType();
if ((FPRetType = PointeeTy->getAs<FunctionType>())) {
ResultStr +=
FPRetType->getReturnType().getAsString(Context->getPrintingPolicy());
ResultStr += "(*";
}
} else
ResultStr += T.getAsString(Context->getPrintingPolicy());
}
void RewriteModernObjC::RewriteObjCMethodDecl(const ObjCInterfaceDecl *IDecl,
ObjCMethodDecl *OMD,
std::string &ResultStr) {
//fprintf(stderr,"In RewriteObjCMethodDecl\n");
const FunctionType *FPRetType = nullptr;
ResultStr += "\nstatic ";
RewriteTypeIntoString(OMD->getReturnType(), ResultStr, FPRetType);
ResultStr += " ";
// Unique method name
std::string NameStr;
if (OMD->isInstanceMethod())
NameStr += "_I_";
else
NameStr += "_C_";
NameStr += IDecl->getNameAsString();
NameStr += "_";
if (ObjCCategoryImplDecl *CID =
dyn_cast<ObjCCategoryImplDecl>(OMD->getDeclContext())) {
NameStr += CID->getNameAsString();
NameStr += "_";
}
// Append selector names, replacing ':' with '_'
{
std::string selString = OMD->getSelector().getAsString();
int len = selString.size();
for (int i = 0; i < len; i++)
if (selString[i] == ':')
selString[i] = '_';
NameStr += selString;
}
// Remember this name for metadata emission
MethodInternalNames[OMD] = NameStr;
ResultStr += NameStr;
// Rewrite arguments
ResultStr += "(";
// invisible arguments
if (OMD->isInstanceMethod()) {
QualType selfTy = Context->getObjCInterfaceType(IDecl);
selfTy = Context->getPointerType(selfTy);
if (!LangOpts.MicrosoftExt) {
if (ObjCSynthesizedStructs.count(const_cast<ObjCInterfaceDecl*>(IDecl)))
ResultStr += "struct ";
}
// When rewriting for Microsoft, explicitly omit the structure name.
ResultStr += IDecl->getNameAsString();
ResultStr += " *";
}
else
ResultStr += Context->getObjCClassType().getAsString(
Context->getPrintingPolicy());
ResultStr += " self, ";
ResultStr += Context->getObjCSelType().getAsString(Context->getPrintingPolicy());
ResultStr += " _cmd";
// Method arguments.
for (const auto *PDecl : OMD->params()) {
ResultStr += ", ";
if (PDecl->getType()->isObjCQualifiedIdType()) {
ResultStr += "id ";
ResultStr += PDecl->getNameAsString();
} else {
std::string Name = PDecl->getNameAsString();
QualType QT = PDecl->getType();
// Make sure we convert "t (^)(...)" to "t (*)(...)".
(void)convertBlockPointerToFunctionPointer(QT);
QT.getAsStringInternal(Name, Context->getPrintingPolicy());
ResultStr += Name;
}
}
if (OMD->isVariadic())
ResultStr += ", ...";
ResultStr += ") ";
if (FPRetType) {
ResultStr += ")"; // close the precedence "scope" for "*".
// Now, emit the argument types (if any).
if (const FunctionProtoType *FT = dyn_cast<FunctionProtoType>(FPRetType)) {
ResultStr += "(";
for (unsigned i = 0, e = FT->getNumParams(); i != e; ++i) {
if (i) ResultStr += ", ";
std::string ParamStr =
FT->getParamType(i).getAsString(Context->getPrintingPolicy());
ResultStr += ParamStr;
}
if (FT->isVariadic()) {
if (FT->getNumParams())
ResultStr += ", ";
ResultStr += "...";
}
ResultStr += ")";
} else {
ResultStr += "()";
}
}
}
void RewriteModernObjC::RewriteImplementationDecl(Decl *OID) {
ObjCImplementationDecl *IMD = dyn_cast<ObjCImplementationDecl>(OID);
ObjCCategoryImplDecl *CID = dyn_cast<ObjCCategoryImplDecl>(OID);
if (IMD) {
if (IMD->getIvarRBraceLoc().isValid()) {
ReplaceText(IMD->getLocStart(), 1, "/** ");
ReplaceText(IMD->getIvarRBraceLoc(), 1, "**/ ");
}
else {
InsertText(IMD->getLocStart(), "// ");
}
}
else
InsertText(CID->getLocStart(), "// ");
for (auto *OMD : IMD ? IMD->instance_methods() : CID->instance_methods()) {
std::string ResultStr;
RewriteObjCMethodDecl(OMD->getClassInterface(), OMD, ResultStr);
SourceLocation LocStart = OMD->getLocStart();
SourceLocation LocEnd = OMD->getCompoundBody()->getLocStart();
const char *startBuf = SM->getCharacterData(LocStart);
const char *endBuf = SM->getCharacterData(LocEnd);
ReplaceText(LocStart, endBuf-startBuf, ResultStr);
}
for (auto *OMD : IMD ? IMD->class_methods() : CID->class_methods()) {
std::string ResultStr;
RewriteObjCMethodDecl(OMD->getClassInterface(), OMD, ResultStr);
SourceLocation LocStart = OMD->getLocStart();
SourceLocation LocEnd = OMD->getCompoundBody()->getLocStart();
const char *startBuf = SM->getCharacterData(LocStart);
const char *endBuf = SM->getCharacterData(LocEnd);
ReplaceText(LocStart, endBuf-startBuf, ResultStr);
}
for (auto *I : IMD ? IMD->property_impls() : CID->property_impls())
RewritePropertyImplDecl(I, IMD, CID);
InsertText(IMD ? IMD->getLocEnd() : CID->getLocEnd(), "// ");
}
void RewriteModernObjC::RewriteInterfaceDecl(ObjCInterfaceDecl *ClassDecl) {
// Do not synthesize more than once.
if (ObjCSynthesizedStructs.count(ClassDecl))
return;
// Make sure super class's are written before current class is written.
ObjCInterfaceDecl *SuperClass = ClassDecl->getSuperClass();
while (SuperClass) {
RewriteInterfaceDecl(SuperClass);
SuperClass = SuperClass->getSuperClass();
}
std::string ResultStr;
if (!ObjCWrittenInterfaces.count(ClassDecl->getCanonicalDecl())) {
// we haven't seen a forward decl - generate a typedef.
RewriteOneForwardClassDecl(ClassDecl, ResultStr);
RewriteIvarOffsetSymbols(ClassDecl, ResultStr);
RewriteObjCInternalStruct(ClassDecl, ResultStr);
// Mark this typedef as having been written into its c++ equivalent.
ObjCWrittenInterfaces.insert(ClassDecl->getCanonicalDecl());
for (auto *I : ClassDecl->properties())
RewriteProperty(I);
for (auto *I : ClassDecl->instance_methods())
RewriteMethodDeclaration(I);
for (auto *I : ClassDecl->class_methods())
RewriteMethodDeclaration(I);
// Lastly, comment out the @end.
ReplaceText(ClassDecl->getAtEndRange().getBegin(), strlen("@end"),
"/* @end */\n");
}
}
Stmt *RewriteModernObjC::RewritePropertyOrImplicitSetter(PseudoObjectExpr *PseudoOp) {
SourceRange OldRange = PseudoOp->getSourceRange();
// We just magically know some things about the structure of this
// expression.
ObjCMessageExpr *OldMsg =
cast<ObjCMessageExpr>(PseudoOp->getSemanticExpr(
PseudoOp->getNumSemanticExprs() - 1));
// Because the rewriter doesn't allow us to rewrite rewritten code,
// we need to suppress rewriting the sub-statements.
Expr *Base;
SmallVector<Expr*, 2> Args;
{
DisableReplaceStmtScope S(*this);
// Rebuild the base expression if we have one.
Base = nullptr;
if (OldMsg->getReceiverKind() == ObjCMessageExpr::Instance) {
Base = OldMsg->getInstanceReceiver();
Base = cast<OpaqueValueExpr>(Base)->getSourceExpr();
Base = cast<Expr>(RewriteFunctionBodyOrGlobalInitializer(Base));
}
unsigned numArgs = OldMsg->getNumArgs();
for (unsigned i = 0; i < numArgs; i++) {
Expr *Arg = OldMsg->getArg(i);
if (isa<OpaqueValueExpr>(Arg))
Arg = cast<OpaqueValueExpr>(Arg)->getSourceExpr();
Arg = cast<Expr>(RewriteFunctionBodyOrGlobalInitializer(Arg));
Args.push_back(Arg);
}
}
// TODO: avoid this copy.
SmallVector<SourceLocation, 1> SelLocs;
OldMsg->getSelectorLocs(SelLocs);
ObjCMessageExpr *NewMsg = nullptr;
switch (OldMsg->getReceiverKind()) {
case ObjCMessageExpr::Class:
NewMsg = ObjCMessageExpr::Create(*Context, OldMsg->getType(),
OldMsg->getValueKind(),
OldMsg->getLeftLoc(),
OldMsg->getClassReceiverTypeInfo(),
OldMsg->getSelector(),
SelLocs,
OldMsg->getMethodDecl(),
Args,
OldMsg->getRightLoc(),
OldMsg->isImplicit());
break;
case ObjCMessageExpr::Instance:
NewMsg = ObjCMessageExpr::Create(*Context, OldMsg->getType(),
OldMsg->getValueKind(),
OldMsg->getLeftLoc(),
Base,
OldMsg->getSelector(),
SelLocs,
OldMsg->getMethodDecl(),
Args,
OldMsg->getRightLoc(),
OldMsg->isImplicit());
break;
case ObjCMessageExpr::SuperClass:
case ObjCMessageExpr::SuperInstance:
NewMsg = ObjCMessageExpr::Create(*Context, OldMsg->getType(),
OldMsg->getValueKind(),
OldMsg->getLeftLoc(),
OldMsg->getSuperLoc(),
OldMsg->getReceiverKind() == ObjCMessageExpr::SuperInstance,
OldMsg->getSuperType(),
OldMsg->getSelector(),
SelLocs,
OldMsg->getMethodDecl(),
Args,
OldMsg->getRightLoc(),
OldMsg->isImplicit());
break;
}
Stmt *Replacement = SynthMessageExpr(NewMsg);
ReplaceStmtWithRange(PseudoOp, Replacement, OldRange);
return Replacement;
}
Stmt *RewriteModernObjC::RewritePropertyOrImplicitGetter(PseudoObjectExpr *PseudoOp) {
SourceRange OldRange = PseudoOp->getSourceRange();
// We just magically know some things about the structure of this
// expression.
ObjCMessageExpr *OldMsg =
cast<ObjCMessageExpr>(PseudoOp->getResultExpr()->IgnoreImplicit());
// Because the rewriter doesn't allow us to rewrite rewritten code,
// we need to suppress rewriting the sub-statements.
Expr *Base = nullptr;
SmallVector<Expr*, 1> Args;
{
DisableReplaceStmtScope S(*this);
// Rebuild the base expression if we have one.
if (OldMsg->getReceiverKind() == ObjCMessageExpr::Instance) {
Base = OldMsg->getInstanceReceiver();
Base = cast<OpaqueValueExpr>(Base)->getSourceExpr();
Base = cast<Expr>(RewriteFunctionBodyOrGlobalInitializer(Base));
}
unsigned numArgs = OldMsg->getNumArgs();
for (unsigned i = 0; i < numArgs; i++) {
Expr *Arg = OldMsg->getArg(i);
if (isa<OpaqueValueExpr>(Arg))
Arg = cast<OpaqueValueExpr>(Arg)->getSourceExpr();
Arg = cast<Expr>(RewriteFunctionBodyOrGlobalInitializer(Arg));
Args.push_back(Arg);
}
}
// Intentionally empty.
SmallVector<SourceLocation, 1> SelLocs;
ObjCMessageExpr *NewMsg = nullptr;
switch (OldMsg->getReceiverKind()) {
case ObjCMessageExpr::Class:
NewMsg = ObjCMessageExpr::Create(*Context, OldMsg->getType(),
OldMsg->getValueKind(),
OldMsg->getLeftLoc(),
OldMsg->getClassReceiverTypeInfo(),
OldMsg->getSelector(),
SelLocs,
OldMsg->getMethodDecl(),
Args,
OldMsg->getRightLoc(),
OldMsg->isImplicit());
break;
case ObjCMessageExpr::Instance:
NewMsg = ObjCMessageExpr::Create(*Context, OldMsg->getType(),
OldMsg->getValueKind(),
OldMsg->getLeftLoc(),
Base,
OldMsg->getSelector(),
SelLocs,
OldMsg->getMethodDecl(),
Args,
OldMsg->getRightLoc(),
OldMsg->isImplicit());
break;
case ObjCMessageExpr::SuperClass:
case ObjCMessageExpr::SuperInstance:
NewMsg = ObjCMessageExpr::Create(*Context, OldMsg->getType(),
OldMsg->getValueKind(),
OldMsg->getLeftLoc(),
OldMsg->getSuperLoc(),
OldMsg->getReceiverKind() == ObjCMessageExpr::SuperInstance,
OldMsg->getSuperType(),
OldMsg->getSelector(),
SelLocs,
OldMsg->getMethodDecl(),
Args,
OldMsg->getRightLoc(),
OldMsg->isImplicit());
break;
}
Stmt *Replacement = SynthMessageExpr(NewMsg);
ReplaceStmtWithRange(PseudoOp, Replacement, OldRange);
return Replacement;
}
/// SynthCountByEnumWithState - To print:
/// ((NSUInteger (*)
/// (id, SEL, struct __objcFastEnumerationState *, id *, NSUInteger))
/// (void *)objc_msgSend)((id)l_collection,
/// sel_registerName(
/// "countByEnumeratingWithState:objects:count:"),
/// &enumState,
/// (id *)__rw_items, (NSUInteger)16)
///
void RewriteModernObjC::SynthCountByEnumWithState(std::string &buf) {
buf += "((_WIN_NSUInteger (*) (id, SEL, struct __objcFastEnumerationState *, "
"id *, _WIN_NSUInteger))(void *)objc_msgSend)";
buf += "\n\t\t";
buf += "((id)l_collection,\n\t\t";
buf += "sel_registerName(\"countByEnumeratingWithState:objects:count:\"),";
buf += "\n\t\t";
buf += "&enumState, "
"(id *)__rw_items, (_WIN_NSUInteger)16)";
}
/// RewriteBreakStmt - Rewrite for a break-stmt inside an ObjC2's foreach
/// statement to exit to its outer synthesized loop.
///
Stmt *RewriteModernObjC::RewriteBreakStmt(BreakStmt *S) {
if (Stmts.empty() || !isa<ObjCForCollectionStmt>(Stmts.back()))
return S;
// replace break with goto __break_label
std::string buf;
SourceLocation startLoc = S->getLocStart();
buf = "goto __break_label_";
buf += utostr(ObjCBcLabelNo.back());
ReplaceText(startLoc, strlen("break"), buf);
return nullptr;
}
void RewriteModernObjC::ConvertSourceLocationToLineDirective(
SourceLocation Loc,
std::string &LineString) {
if (Loc.isFileID() && GenerateLineInfo) {
LineString += "\n#line ";
PresumedLoc PLoc = SM->getPresumedLoc(Loc);
LineString += utostr(PLoc.getLine());
LineString += " \"";
LineString += Lexer::Stringify(PLoc.getFilename());
LineString += "\"\n";
}
}
/// RewriteContinueStmt - Rewrite for a continue-stmt inside an ObjC2's foreach
/// statement to continue with its inner synthesized loop.
///
Stmt *RewriteModernObjC::RewriteContinueStmt(ContinueStmt *S) {
if (Stmts.empty() || !isa<ObjCForCollectionStmt>(Stmts.back()))
return S;
// replace continue with goto __continue_label
std::string buf;
SourceLocation startLoc = S->getLocStart();
buf = "goto __continue_label_";
buf += utostr(ObjCBcLabelNo.back());
ReplaceText(startLoc, strlen("continue"), buf);
return nullptr;
}
/// RewriteObjCForCollectionStmt - Rewriter for ObjC2's foreach statement.
/// It rewrites:
/// for ( type elem in collection) { stmts; }
/// Into:
/// {
/// type elem;
/// struct __objcFastEnumerationState enumState = { 0 };
/// id __rw_items[16];
/// id l_collection = (id)collection;
/// NSUInteger limit = [l_collection countByEnumeratingWithState:&enumState
/// objects:__rw_items count:16];
/// if (limit) {
/// unsigned long startMutations = *enumState.mutationsPtr;
/// do {
/// unsigned long counter = 0;
/// do {
/// if (startMutations != *enumState.mutationsPtr)
/// objc_enumerationMutation(l_collection);
/// elem = (type)enumState.itemsPtr[counter++];
/// stmts;
/// __continue_label: ;
/// } while (counter < limit);
/// } while ((limit = [l_collection countByEnumeratingWithState:&enumState
/// objects:__rw_items count:16]));
/// elem = nil;
/// __break_label: ;
/// }
/// else
/// elem = nil;
/// }
///
Stmt *RewriteModernObjC::RewriteObjCForCollectionStmt(ObjCForCollectionStmt *S,
SourceLocation OrigEnd) {
assert(!Stmts.empty() && "ObjCForCollectionStmt - Statement stack empty");
assert(isa<ObjCForCollectionStmt>(Stmts.back()) &&
"ObjCForCollectionStmt Statement stack mismatch");
assert(!ObjCBcLabelNo.empty() &&
"ObjCForCollectionStmt - Label No stack empty");
SourceLocation startLoc = S->getLocStart();
const char *startBuf = SM->getCharacterData(startLoc);
StringRef elementName;
std::string elementTypeAsString;
std::string buf;
// line directive first.
SourceLocation ForEachLoc = S->getForLoc();
ConvertSourceLocationToLineDirective(ForEachLoc, buf);
buf += "{\n\t";
if (DeclStmt *DS = dyn_cast<DeclStmt>(S->getElement())) {
// type elem;
NamedDecl* D = cast<NamedDecl>(DS->getSingleDecl());
QualType ElementType = cast<ValueDecl>(D)->getType();
if (ElementType->isObjCQualifiedIdType() ||
ElementType->isObjCQualifiedInterfaceType())
// Simply use 'id' for all qualified types.
elementTypeAsString = "id";
else
elementTypeAsString = ElementType.getAsString(Context->getPrintingPolicy());
buf += elementTypeAsString;
buf += " ";
elementName = D->getName();
buf += elementName;
buf += ";\n\t";
}
else {
DeclRefExpr *DR = cast<DeclRefExpr>(S->getElement());
elementName = DR->getDecl()->getName();
ValueDecl *VD = cast<ValueDecl>(DR->getDecl());
if (VD->getType()->isObjCQualifiedIdType() ||
VD->getType()->isObjCQualifiedInterfaceType())
// Simply use 'id' for all qualified types.
elementTypeAsString = "id";
else
elementTypeAsString = VD->getType().getAsString(Context->getPrintingPolicy());
}
// struct __objcFastEnumerationState enumState = { 0 };
buf += "struct __objcFastEnumerationState enumState = { 0 };\n\t";
// id __rw_items[16];
buf += "id __rw_items[16];\n\t";
// id l_collection = (id)
buf += "id l_collection = (id)";
// Find start location of 'collection' the hard way!
const char *startCollectionBuf = startBuf;
startCollectionBuf += 3; // skip 'for'
startCollectionBuf = strchr(startCollectionBuf, '(');
startCollectionBuf++; // skip '('
// find 'in' and skip it.
while (*startCollectionBuf != ' ' ||
*(startCollectionBuf+1) != 'i' || *(startCollectionBuf+2) != 'n' ||
(*(startCollectionBuf+3) != ' ' &&
*(startCollectionBuf+3) != '[' && *(startCollectionBuf+3) != '('))
startCollectionBuf++;
startCollectionBuf += 3;
// Replace: "for (type element in" with string constructed thus far.
ReplaceText(startLoc, startCollectionBuf - startBuf, buf);
// Replace ')' in for '(' type elem in collection ')' with ';'
SourceLocation rightParenLoc = S->getRParenLoc();
const char *rparenBuf = SM->getCharacterData(rightParenLoc);
SourceLocation lparenLoc = startLoc.getLocWithOffset(rparenBuf-startBuf);
buf = ";\n\t";
// unsigned long limit = [l_collection countByEnumeratingWithState:&enumState
// objects:__rw_items count:16];
// which is synthesized into:
// NSUInteger limit =
// ((NSUInteger (*)
// (id, SEL, struct __objcFastEnumerationState *, id *, NSUInteger))
// (void *)objc_msgSend)((id)l_collection,
// sel_registerName(
// "countByEnumeratingWithState:objects:count:"),
// (struct __objcFastEnumerationState *)&state,
// (id *)__rw_items, (NSUInteger)16);
buf += "_WIN_NSUInteger limit =\n\t\t";
SynthCountByEnumWithState(buf);
buf += ";\n\t";
/// if (limit) {
/// unsigned long startMutations = *enumState.mutationsPtr;
/// do {
/// unsigned long counter = 0;
/// do {
/// if (startMutations != *enumState.mutationsPtr)
/// objc_enumerationMutation(l_collection);
/// elem = (type)enumState.itemsPtr[counter++];
buf += "if (limit) {\n\t";
buf += "unsigned long startMutations = *enumState.mutationsPtr;\n\t";
buf += "do {\n\t\t";
buf += "unsigned long counter = 0;\n\t\t";
buf += "do {\n\t\t\t";
buf += "if (startMutations != *enumState.mutationsPtr)\n\t\t\t\t";
buf += "objc_enumerationMutation(l_collection);\n\t\t\t";
buf += elementName;
buf += " = (";
buf += elementTypeAsString;
buf += ")enumState.itemsPtr[counter++];";
// Replace ')' in for '(' type elem in collection ')' with all of these.
ReplaceText(lparenLoc, 1, buf);
/// __continue_label: ;
/// } while (counter < limit);
/// } while ((limit = [l_collection countByEnumeratingWithState:&enumState
/// objects:__rw_items count:16]));
/// elem = nil;
/// __break_label: ;
/// }
/// else
/// elem = nil;
/// }
///
buf = ";\n\t";
buf += "__continue_label_";
buf += utostr(ObjCBcLabelNo.back());
buf += ": ;";
buf += "\n\t\t";
buf += "} while (counter < limit);\n\t";
buf += "} while ((limit = ";
SynthCountByEnumWithState(buf);
buf += "));\n\t";
buf += elementName;
buf += " = ((";
buf += elementTypeAsString;
buf += ")0);\n\t";
buf += "__break_label_";
buf += utostr(ObjCBcLabelNo.back());
buf += ": ;\n\t";
buf += "}\n\t";
buf += "else\n\t\t";
buf += elementName;
buf += " = ((";
buf += elementTypeAsString;
buf += ")0);\n\t";
buf += "}\n";
// Insert all these *after* the statement body.
// FIXME: If this should support Obj-C++, support CXXTryStmt
if (isa<CompoundStmt>(S->getBody())) {
SourceLocation endBodyLoc = OrigEnd.getLocWithOffset(1);
InsertText(endBodyLoc, buf);
} else {
/* Need to treat single statements specially. For example:
*
* for (A *a in b) if (stuff()) break;
* for (A *a in b) xxxyy;
*
* The following code simply scans ahead to the semi to find the actual end.
*/
const char *stmtBuf = SM->getCharacterData(OrigEnd);
const char *semiBuf = strchr(stmtBuf, ';');
assert(semiBuf && "Can't find ';'");
SourceLocation endBodyLoc = OrigEnd.getLocWithOffset(semiBuf-stmtBuf+1);
InsertText(endBodyLoc, buf);
}
Stmts.pop_back();
ObjCBcLabelNo.pop_back();
return nullptr;
}
static void Write_RethrowObject(std::string &buf) {
buf += "{ struct _FIN { _FIN(id reth) : rethrow(reth) {}\n";
buf += "\t~_FIN() { if (rethrow) objc_exception_throw(rethrow); }\n";
buf += "\tid rethrow;\n";
buf += "\t} _fin_force_rethow(_rethrow);";
}
/// RewriteObjCSynchronizedStmt -
/// This routine rewrites @synchronized(expr) stmt;
/// into:
/// objc_sync_enter(expr);
/// @try stmt @finally { objc_sync_exit(expr); }
///
Stmt *RewriteModernObjC::RewriteObjCSynchronizedStmt(ObjCAtSynchronizedStmt *S) {
// Get the start location and compute the semi location.
SourceLocation startLoc = S->getLocStart();
const char *startBuf = SM->getCharacterData(startLoc);
assert((*startBuf == '@') && "bogus @synchronized location");
std::string buf;
SourceLocation SynchLoc = S->getAtSynchronizedLoc();
ConvertSourceLocationToLineDirective(SynchLoc, buf);
buf += "{ id _rethrow = 0; id _sync_obj = (id)";
const char *lparenBuf = startBuf;
while (*lparenBuf != '(') lparenBuf++;
ReplaceText(startLoc, lparenBuf-startBuf+1, buf);
buf = "; objc_sync_enter(_sync_obj);\n";
buf += "try {\n\tstruct _SYNC_EXIT { _SYNC_EXIT(id arg) : sync_exit(arg) {}";
buf += "\n\t~_SYNC_EXIT() {objc_sync_exit(sync_exit);}";
buf += "\n\tid sync_exit;";
buf += "\n\t} _sync_exit(_sync_obj);\n";
// We can't use S->getSynchExpr()->getLocEnd() to find the end location, since
// the sync expression is typically a message expression that's already
// been rewritten! (which implies the SourceLocation's are invalid).
SourceLocation RParenExprLoc = S->getSynchBody()->getLocStart();
const char *RParenExprLocBuf = SM->getCharacterData(RParenExprLoc);
while (*RParenExprLocBuf != ')') RParenExprLocBuf--;
RParenExprLoc = startLoc.getLocWithOffset(RParenExprLocBuf-startBuf);
SourceLocation LBranceLoc = S->getSynchBody()->getLocStart();
const char *LBraceLocBuf = SM->getCharacterData(LBranceLoc);
assert (*LBraceLocBuf == '{');
ReplaceText(RParenExprLoc, (LBraceLocBuf - SM->getCharacterData(RParenExprLoc) + 1), buf);
SourceLocation startRBraceLoc = S->getSynchBody()->getLocEnd();
assert((*SM->getCharacterData(startRBraceLoc) == '}') &&
"bogus @synchronized block");
buf = "} catch (id e) {_rethrow = e;}\n";
Write_RethrowObject(buf);
buf += "}\n";
buf += "}\n";
ReplaceText(startRBraceLoc, 1, buf);
return nullptr;
}
void RewriteModernObjC::WarnAboutReturnGotoStmts(Stmt *S)
{
// Perform a bottom up traversal of all children.
for (Stmt::child_range CI = S->children(); CI; ++CI)
if (*CI)
WarnAboutReturnGotoStmts(*CI);
if (isa<ReturnStmt>(S) || isa<GotoStmt>(S)) {
Diags.Report(Context->getFullLoc(S->getLocStart()),
TryFinallyContainsReturnDiag);
}
return;
}
Stmt *RewriteModernObjC::RewriteObjCAutoreleasePoolStmt(ObjCAutoreleasePoolStmt *S) {
SourceLocation startLoc = S->getAtLoc();
ReplaceText(startLoc, strlen("@autoreleasepool"), "/* @autoreleasepool */");
ReplaceText(S->getSubStmt()->getLocStart(), 1,
"{ __AtAutoreleasePool __autoreleasepool; ");
return nullptr;
}
Stmt *RewriteModernObjC::RewriteObjCTryStmt(ObjCAtTryStmt *S) {
ObjCAtFinallyStmt *finalStmt = S->getFinallyStmt();
bool noCatch = S->getNumCatchStmts() == 0;
std::string buf;
SourceLocation TryLocation = S->getAtTryLoc();
ConvertSourceLocationToLineDirective(TryLocation, buf);
if (finalStmt) {
if (noCatch)
buf += "{ id volatile _rethrow = 0;\n";
else {
buf += "{ id volatile _rethrow = 0;\ntry {\n";
}
}
// Get the start location and compute the semi location.
SourceLocation startLoc = S->getLocStart();
const char *startBuf = SM->getCharacterData(startLoc);
assert((*startBuf == '@') && "bogus @try location");
if (finalStmt)
ReplaceText(startLoc, 1, buf);
else
// @try -> try
ReplaceText(startLoc, 1, "");
for (unsigned I = 0, N = S->getNumCatchStmts(); I != N; ++I) {
ObjCAtCatchStmt *Catch = S->getCatchStmt(I);
VarDecl *catchDecl = Catch->getCatchParamDecl();
startLoc = Catch->getLocStart();
bool AtRemoved = false;
if (catchDecl) {
QualType t = catchDecl->getType();
if (const ObjCObjectPointerType *Ptr = t->getAs<ObjCObjectPointerType>()) {
// Should be a pointer to a class.
ObjCInterfaceDecl *IDecl = Ptr->getObjectType()->getInterface();
if (IDecl) {
std::string Result;
ConvertSourceLocationToLineDirective(Catch->getLocStart(), Result);
startBuf = SM->getCharacterData(startLoc);
assert((*startBuf == '@') && "bogus @catch location");
SourceLocation rParenLoc = Catch->getRParenLoc();
const char *rParenBuf = SM->getCharacterData(rParenLoc);
// _objc_exc_Foo *_e as argument to catch.
Result += "catch (_objc_exc_"; Result += IDecl->getNameAsString();
Result += " *_"; Result += catchDecl->getNameAsString();
Result += ")";
ReplaceText(startLoc, rParenBuf-startBuf+1, Result);
// Foo *e = (Foo *)_e;
Result.clear();
Result = "{ ";
Result += IDecl->getNameAsString();
Result += " *"; Result += catchDecl->getNameAsString();
Result += " = ("; Result += IDecl->getNameAsString(); Result += "*)";
Result += "_"; Result += catchDecl->getNameAsString();
Result += "; ";
SourceLocation lBraceLoc = Catch->getCatchBody()->getLocStart();
ReplaceText(lBraceLoc, 1, Result);
AtRemoved = true;
}
}
}
if (!AtRemoved)
// @catch -> catch
ReplaceText(startLoc, 1, "");
}
if (finalStmt) {
buf.clear();
SourceLocation FinallyLoc = finalStmt->getLocStart();
if (noCatch) {
ConvertSourceLocationToLineDirective(FinallyLoc, buf);
buf += "catch (id e) {_rethrow = e;}\n";
}
else {
buf += "}\n";
ConvertSourceLocationToLineDirective(FinallyLoc, buf);
buf += "catch (id e) {_rethrow = e;}\n";
}
SourceLocation startFinalLoc = finalStmt->getLocStart();
ReplaceText(startFinalLoc, 8, buf);
Stmt *body = finalStmt->getFinallyBody();
SourceLocation startFinalBodyLoc = body->getLocStart();
buf.clear();
Write_RethrowObject(buf);
ReplaceText(startFinalBodyLoc, 1, buf);
SourceLocation endFinalBodyLoc = body->getLocEnd();
ReplaceText(endFinalBodyLoc, 1, "}\n}");
// Now check for any return/continue/go statements within the @try.
WarnAboutReturnGotoStmts(S->getTryBody());
}
return nullptr;
}
// This can't be done with ReplaceStmt(S, ThrowExpr), since
// the throw expression is typically a message expression that's already
// been rewritten! (which implies the SourceLocation's are invalid).
Stmt *RewriteModernObjC::RewriteObjCThrowStmt(ObjCAtThrowStmt *S) {
// Get the start location and compute the semi location.
SourceLocation startLoc = S->getLocStart();
const char *startBuf = SM->getCharacterData(startLoc);
assert((*startBuf == '@') && "bogus @throw location");
std::string buf;
/* void objc_exception_throw(id) __attribute__((noreturn)); */
if (S->getThrowExpr())
buf = "objc_exception_throw(";
else
buf = "throw";
// handle "@ throw" correctly.
const char *wBuf = strchr(startBuf, 'w');
assert((*wBuf == 'w') && "@throw: can't find 'w'");
ReplaceText(startLoc, wBuf-startBuf+1, buf);
SourceLocation endLoc = S->getLocEnd();
const char *endBuf = SM->getCharacterData(endLoc);
const char *semiBuf = strchr(endBuf, ';');
assert((*semiBuf == ';') && "@throw: can't find ';'");
SourceLocation semiLoc = startLoc.getLocWithOffset(semiBuf-startBuf);
if (S->getThrowExpr())
ReplaceText(semiLoc, 1, ");");
return nullptr;
}
Stmt *RewriteModernObjC::RewriteAtEncode(ObjCEncodeExpr *Exp) {
// Create a new string expression.
std::string StrEncoding;
Context->getObjCEncodingForType(Exp->getEncodedType(), StrEncoding);
Expr *Replacement = getStringLiteral(StrEncoding);
ReplaceStmt(Exp, Replacement);
// Replace this subexpr in the parent.
// delete Exp; leak for now, see RewritePropertyOrImplicitSetter() usage for more info.
return Replacement;
}
Stmt *RewriteModernObjC::RewriteAtSelector(ObjCSelectorExpr *Exp) {
if (!SelGetUidFunctionDecl)
SynthSelGetUidFunctionDecl();
assert(SelGetUidFunctionDecl && "Can't find sel_registerName() decl");
// Create a call to sel_registerName("selName").
SmallVector<Expr*, 8> SelExprs;
SelExprs.push_back(getStringLiteral(Exp->getSelector().getAsString()));
CallExpr *SelExp = SynthesizeCallToFunctionDecl(SelGetUidFunctionDecl,
&SelExprs[0], SelExprs.size());
ReplaceStmt(Exp, SelExp);
// delete Exp; leak for now, see RewritePropertyOrImplicitSetter() usage for more info.
return SelExp;
}
CallExpr *RewriteModernObjC::SynthesizeCallToFunctionDecl(
FunctionDecl *FD, Expr **args, unsigned nargs, SourceLocation StartLoc,
SourceLocation EndLoc) {
// Get the type, we will need to reference it in a couple spots.
QualType msgSendType = FD->getType();
// Create a reference to the objc_msgSend() declaration.
DeclRefExpr *DRE =
new (Context) DeclRefExpr(FD, false, msgSendType, VK_LValue, SourceLocation());
// Now, we cast the reference to a pointer to the objc_msgSend type.
QualType pToFunc = Context->getPointerType(msgSendType);
ImplicitCastExpr *ICE =
ImplicitCastExpr::Create(*Context, pToFunc, CK_FunctionToPointerDecay,
DRE, nullptr, VK_RValue);
const FunctionType *FT = msgSendType->getAs<FunctionType>();
CallExpr *Exp =
new (Context) CallExpr(*Context, ICE, llvm::makeArrayRef(args, nargs),
FT->getCallResultType(*Context),
VK_RValue, EndLoc);
return Exp;
}
static bool scanForProtocolRefs(const char *startBuf, const char *endBuf,
const char *&startRef, const char *&endRef) {
while (startBuf < endBuf) {
if (*startBuf == '<')
startRef = startBuf; // mark the start.
if (*startBuf == '>') {
if (startRef && *startRef == '<') {
endRef = startBuf; // mark the end.
return true;
}
return false;
}
startBuf++;
}
return false;
}
static void scanToNextArgument(const char *&argRef) {
int angle = 0;
while (*argRef != ')' && (*argRef != ',' || angle > 0)) {
if (*argRef == '<')
angle++;
else if (*argRef == '>')
angle--;
argRef++;
}
assert(angle == 0 && "scanToNextArgument - bad protocol type syntax");
}
bool RewriteModernObjC::needToScanForQualifiers(QualType T) {
if (T->isObjCQualifiedIdType())
return true;
if (const PointerType *PT = T->getAs<PointerType>()) {
if (PT->getPointeeType()->isObjCQualifiedIdType())
return true;
}
if (T->isObjCObjectPointerType()) {
T = T->getPointeeType();
return T->isObjCQualifiedInterfaceType();
}
if (T->isArrayType()) {
QualType ElemTy = Context->getBaseElementType(T);
return needToScanForQualifiers(ElemTy);
}
return false;
}
void RewriteModernObjC::RewriteObjCQualifiedInterfaceTypes(Expr *E) {
QualType Type = E->getType();
if (needToScanForQualifiers(Type)) {
SourceLocation Loc, EndLoc;
if (const CStyleCastExpr *ECE = dyn_cast<CStyleCastExpr>(E)) {
Loc = ECE->getLParenLoc();
EndLoc = ECE->getRParenLoc();
} else {
Loc = E->getLocStart();
EndLoc = E->getLocEnd();
}
// This will defend against trying to rewrite synthesized expressions.
if (Loc.isInvalid() || EndLoc.isInvalid())
return;
const char *startBuf = SM->getCharacterData(Loc);
const char *endBuf = SM->getCharacterData(EndLoc);
const char *startRef = nullptr, *endRef = nullptr;
if (scanForProtocolRefs(startBuf, endBuf, startRef, endRef)) {
// Get the locations of the startRef, endRef.
SourceLocation LessLoc = Loc.getLocWithOffset(startRef-startBuf);
SourceLocation GreaterLoc = Loc.getLocWithOffset(endRef-startBuf+1);
// Comment out the protocol references.
InsertText(LessLoc, "/*");
InsertText(GreaterLoc, "*/");
}
}
}
void RewriteModernObjC::RewriteObjCQualifiedInterfaceTypes(Decl *Dcl) {
SourceLocation Loc;
QualType Type;
const FunctionProtoType *proto = nullptr;
if (VarDecl *VD = dyn_cast<VarDecl>(Dcl)) {
Loc = VD->getLocation();
Type = VD->getType();
}
else if (FunctionDecl *FD = dyn_cast<FunctionDecl>(Dcl)) {
Loc = FD->getLocation();
// Check for ObjC 'id' and class types that have been adorned with protocol
// information (id<p>, C<p>*). The protocol references need to be rewritten!
const FunctionType *funcType = FD->getType()->getAs<FunctionType>();
assert(funcType && "missing function type");
proto = dyn_cast<FunctionProtoType>(funcType);
if (!proto)
return;
Type = proto->getReturnType();
}
else if (FieldDecl *FD = dyn_cast<FieldDecl>(Dcl)) {
Loc = FD->getLocation();
Type = FD->getType();
}
else if (TypedefNameDecl *TD = dyn_cast<TypedefNameDecl>(Dcl)) {
Loc = TD->getLocation();
Type = TD->getUnderlyingType();
}
else
return;
if (needToScanForQualifiers(Type)) {
// Since types are unique, we need to scan the buffer.
const char *endBuf = SM->getCharacterData(Loc);
const char *startBuf = endBuf;
while (*startBuf != ';' && *startBuf != '<' && startBuf != MainFileStart)
startBuf--; // scan backward (from the decl location) for return type.
const char *startRef = nullptr, *endRef = nullptr;
if (scanForProtocolRefs(startBuf, endBuf, startRef, endRef)) {
// Get the locations of the startRef, endRef.
SourceLocation LessLoc = Loc.getLocWithOffset(startRef-endBuf);
SourceLocation GreaterLoc = Loc.getLocWithOffset(endRef-endBuf+1);
// Comment out the protocol references.
InsertText(LessLoc, "/*");
InsertText(GreaterLoc, "*/");
}
}
if (!proto)
return; // most likely, was a variable
// Now check arguments.
const char *startBuf = SM->getCharacterData(Loc);
const char *startFuncBuf = startBuf;
for (unsigned i = 0; i < proto->getNumParams(); i++) {
if (needToScanForQualifiers(proto->getParamType(i))) {
// Since types are unique, we need to scan the buffer.
const char *endBuf = startBuf;
// scan forward (from the decl location) for argument types.
scanToNextArgument(endBuf);
const char *startRef = nullptr, *endRef = nullptr;
if (scanForProtocolRefs(startBuf, endBuf, startRef, endRef)) {
// Get the locations of the startRef, endRef.
SourceLocation LessLoc =
Loc.getLocWithOffset(startRef-startFuncBuf);
SourceLocation GreaterLoc =
Loc.getLocWithOffset(endRef-startFuncBuf+1);
// Comment out the protocol references.
InsertText(LessLoc, "/*");
InsertText(GreaterLoc, "*/");
}
startBuf = ++endBuf;
}
else {
// If the function name is derived from a macro expansion, then the
// argument buffer will not follow the name. Need to speak with Chris.
while (*startBuf && *startBuf != ')' && *startBuf != ',')
startBuf++; // scan forward (from the decl location) for argument types.
startBuf++;
}
}
}
void RewriteModernObjC::RewriteTypeOfDecl(VarDecl *ND) {
QualType QT = ND->getType();
const Type* TypePtr = QT->getAs<Type>();
if (!isa<TypeOfExprType>(TypePtr))
return;
while (isa<TypeOfExprType>(TypePtr)) {
const TypeOfExprType *TypeOfExprTypePtr = cast<TypeOfExprType>(TypePtr);
QT = TypeOfExprTypePtr->getUnderlyingExpr()->getType();
TypePtr = QT->getAs<Type>();
}
// FIXME. This will not work for multiple declarators; as in:
// __typeof__(a) b,c,d;
std::string TypeAsString(QT.getAsString(Context->getPrintingPolicy()));
SourceLocation DeclLoc = ND->getTypeSpecStartLoc();
const char *startBuf = SM->getCharacterData(DeclLoc);
if (ND->getInit()) {
std::string Name(ND->getNameAsString());
TypeAsString += " " + Name + " = ";
Expr *E = ND->getInit();
SourceLocation startLoc;
if (const CStyleCastExpr *ECE = dyn_cast<CStyleCastExpr>(E))
startLoc = ECE->getLParenLoc();
else
startLoc = E->getLocStart();
startLoc = SM->getExpansionLoc(startLoc);
const char *endBuf = SM->getCharacterData(startLoc);
ReplaceText(DeclLoc, endBuf-startBuf-1, TypeAsString);
}
else {
SourceLocation X = ND->getLocEnd();
X = SM->getExpansionLoc(X);
const char *endBuf = SM->getCharacterData(X);
ReplaceText(DeclLoc, endBuf-startBuf-1, TypeAsString);
}
}
// SynthSelGetUidFunctionDecl - SEL sel_registerName(const char *str);
void RewriteModernObjC::SynthSelGetUidFunctionDecl() {
IdentifierInfo *SelGetUidIdent = &Context->Idents.get("sel_registerName");
SmallVector<QualType, 16> ArgTys;
ArgTys.push_back(Context->getPointerType(Context->CharTy.withConst()));
QualType getFuncType =
getSimpleFunctionType(Context->getObjCSelType(), ArgTys);
SelGetUidFunctionDecl = FunctionDecl::Create(*Context, TUDecl,
SourceLocation(),
SourceLocation(),
SelGetUidIdent, getFuncType,
nullptr, SC_Extern);
}
void RewriteModernObjC::RewriteFunctionDecl(FunctionDecl *FD) {
// declared in <objc/objc.h>
if (FD->getIdentifier() &&
FD->getName() == "sel_registerName") {
SelGetUidFunctionDecl = FD;
return;
}
RewriteObjCQualifiedInterfaceTypes(FD);
}
void RewriteModernObjC::RewriteBlockPointerType(std::string& Str, QualType Type) {
std::string TypeString(Type.getAsString(Context->getPrintingPolicy()));
const char *argPtr = TypeString.c_str();
if (!strchr(argPtr, '^')) {
Str += TypeString;
return;
}
while (*argPtr) {
Str += (*argPtr == '^' ? '*' : *argPtr);
argPtr++;
}
}
// FIXME. Consolidate this routine with RewriteBlockPointerType.
void RewriteModernObjC::RewriteBlockPointerTypeVariable(std::string& Str,
ValueDecl *VD) {
QualType Type = VD->getType();
std::string TypeString(Type.getAsString(Context->getPrintingPolicy()));
const char *argPtr = TypeString.c_str();
int paren = 0;
while (*argPtr) {
switch (*argPtr) {
case '(':
Str += *argPtr;
paren++;
break;
case ')':
Str += *argPtr;
paren--;
break;
case '^':
Str += '*';
if (paren == 1)
Str += VD->getNameAsString();
break;
default:
Str += *argPtr;
break;
}
argPtr++;
}
}
void RewriteModernObjC::RewriteBlockLiteralFunctionDecl(FunctionDecl *FD) {
SourceLocation FunLocStart = FD->getTypeSpecStartLoc();
const FunctionType *funcType = FD->getType()->getAs<FunctionType>();
const FunctionProtoType *proto = dyn_cast<FunctionProtoType>(funcType);
if (!proto)
return;
QualType Type = proto->getReturnType();
std::string FdStr = Type.getAsString(Context->getPrintingPolicy());
FdStr += " ";
FdStr += FD->getName();
FdStr += "(";
unsigned numArgs = proto->getNumParams();
for (unsigned i = 0; i < numArgs; i++) {
QualType ArgType = proto->getParamType(i);
RewriteBlockPointerType(FdStr, ArgType);
if (i+1 < numArgs)
FdStr += ", ";
}
if (FD->isVariadic()) {
FdStr += (numArgs > 0) ? ", ...);\n" : "...);\n";
}
else
FdStr += ");\n";
InsertText(FunLocStart, FdStr);
}
// SynthSuperConstructorFunctionDecl - id __rw_objc_super(id obj, id super);
void RewriteModernObjC::SynthSuperConstructorFunctionDecl() {
if (SuperConstructorFunctionDecl)
return;
IdentifierInfo *msgSendIdent = &Context->Idents.get("__rw_objc_super");
SmallVector<QualType, 16> ArgTys;
QualType argT = Context->getObjCIdType();
assert(!argT.isNull() && "Can't find 'id' type");
ArgTys.push_back(argT);
ArgTys.push_back(argT);
QualType msgSendType = getSimpleFunctionType(Context->getObjCIdType(),
ArgTys);
SuperConstructorFunctionDecl = FunctionDecl::Create(*Context, TUDecl,
SourceLocation(),
SourceLocation(),
msgSendIdent, msgSendType,
nullptr, SC_Extern);
}
// SynthMsgSendFunctionDecl - id objc_msgSend(id self, SEL op, ...);
void RewriteModernObjC::SynthMsgSendFunctionDecl() {
IdentifierInfo *msgSendIdent = &Context->Idents.get("objc_msgSend");
SmallVector<QualType, 16> ArgTys;
QualType argT = Context->getObjCIdType();
assert(!argT.isNull() && "Can't find 'id' type");
ArgTys.push_back(argT);
argT = Context->getObjCSelType();
assert(!argT.isNull() && "Can't find 'SEL' type");
ArgTys.push_back(argT);
QualType msgSendType = getSimpleFunctionType(Context->getObjCIdType(),
ArgTys, /*isVariadic=*/true);
MsgSendFunctionDecl = FunctionDecl::Create(*Context, TUDecl,
SourceLocation(),
SourceLocation(),
msgSendIdent, msgSendType, nullptr,
SC_Extern);
}
// SynthMsgSendSuperFunctionDecl - id objc_msgSendSuper(void);
void RewriteModernObjC::SynthMsgSendSuperFunctionDecl() {
IdentifierInfo *msgSendIdent = &Context->Idents.get("objc_msgSendSuper");
SmallVector<QualType, 2> ArgTys;
ArgTys.push_back(Context->VoidTy);
QualType msgSendType = getSimpleFunctionType(Context->getObjCIdType(),
ArgTys, /*isVariadic=*/true);
MsgSendSuperFunctionDecl = FunctionDecl::Create(*Context, TUDecl,
SourceLocation(),
SourceLocation(),
msgSendIdent, msgSendType,
nullptr, SC_Extern);
}
// SynthMsgSendStretFunctionDecl - id objc_msgSend_stret(id self, SEL op, ...);
void RewriteModernObjC::SynthMsgSendStretFunctionDecl() {
IdentifierInfo *msgSendIdent = &Context->Idents.get("objc_msgSend_stret");
SmallVector<QualType, 16> ArgTys;
QualType argT = Context->getObjCIdType();
assert(!argT.isNull() && "Can't find 'id' type");
ArgTys.push_back(argT);
argT = Context->getObjCSelType();
assert(!argT.isNull() && "Can't find 'SEL' type");
ArgTys.push_back(argT);
QualType msgSendType = getSimpleFunctionType(Context->getObjCIdType(),
ArgTys, /*isVariadic=*/true);
MsgSendStretFunctionDecl = FunctionDecl::Create(*Context, TUDecl,
SourceLocation(),
SourceLocation(),
msgSendIdent, msgSendType,
nullptr, SC_Extern);
}
// SynthMsgSendSuperStretFunctionDecl -
// id objc_msgSendSuper_stret(void);
void RewriteModernObjC::SynthMsgSendSuperStretFunctionDecl() {
IdentifierInfo *msgSendIdent =
&Context->Idents.get("objc_msgSendSuper_stret");
SmallVector<QualType, 2> ArgTys;
ArgTys.push_back(Context->VoidTy);
QualType msgSendType = getSimpleFunctionType(Context->getObjCIdType(),
ArgTys, /*isVariadic=*/true);
MsgSendSuperStretFunctionDecl = FunctionDecl::Create(*Context, TUDecl,
SourceLocation(),
SourceLocation(),
msgSendIdent,
msgSendType, nullptr,
SC_Extern);
}
// SynthMsgSendFpretFunctionDecl - double objc_msgSend_fpret(id self, SEL op, ...);
void RewriteModernObjC::SynthMsgSendFpretFunctionDecl() {
IdentifierInfo *msgSendIdent = &Context->Idents.get("objc_msgSend_fpret");
SmallVector<QualType, 16> ArgTys;
QualType argT = Context->getObjCIdType();
assert(!argT.isNull() && "Can't find 'id' type");
ArgTys.push_back(argT);
argT = Context->getObjCSelType();
assert(!argT.isNull() && "Can't find 'SEL' type");
ArgTys.push_back(argT);
QualType msgSendType = getSimpleFunctionType(Context->DoubleTy,
ArgTys, /*isVariadic=*/true);
MsgSendFpretFunctionDecl = FunctionDecl::Create(*Context, TUDecl,
SourceLocation(),
SourceLocation(),
msgSendIdent, msgSendType,
nullptr, SC_Extern);
}
// SynthGetClassFunctionDecl - Class objc_getClass(const char *name);
void RewriteModernObjC::SynthGetClassFunctionDecl() {
IdentifierInfo *getClassIdent = &Context->Idents.get("objc_getClass");
SmallVector<QualType, 16> ArgTys;
ArgTys.push_back(Context->getPointerType(Context->CharTy.withConst()));
QualType getClassType = getSimpleFunctionType(Context->getObjCClassType(),
ArgTys);
GetClassFunctionDecl = FunctionDecl::Create(*Context, TUDecl,
SourceLocation(),
SourceLocation(),
getClassIdent, getClassType,
nullptr, SC_Extern);
}
// SynthGetSuperClassFunctionDecl - Class class_getSuperclass(Class cls);
void RewriteModernObjC::SynthGetSuperClassFunctionDecl() {
IdentifierInfo *getSuperClassIdent =
&Context->Idents.get("class_getSuperclass");
SmallVector<QualType, 16> ArgTys;
ArgTys.push_back(Context->getObjCClassType());
QualType getClassType = getSimpleFunctionType(Context->getObjCClassType(),
ArgTys);
GetSuperClassFunctionDecl = FunctionDecl::Create(*Context, TUDecl,
SourceLocation(),
SourceLocation(),
getSuperClassIdent,
getClassType, nullptr,
SC_Extern);
}
// SynthGetMetaClassFunctionDecl - Class objc_getMetaClass(const char *name);
void RewriteModernObjC::SynthGetMetaClassFunctionDecl() {
IdentifierInfo *getClassIdent = &Context->Idents.get("objc_getMetaClass");
SmallVector<QualType, 16> ArgTys;
ArgTys.push_back(Context->getPointerType(Context->CharTy.withConst()));
QualType getClassType = getSimpleFunctionType(Context->getObjCClassType(),
ArgTys);
GetMetaClassFunctionDecl = FunctionDecl::Create(*Context, TUDecl,
SourceLocation(),
SourceLocation(),
getClassIdent, getClassType,
nullptr, SC_Extern);
}
Stmt *RewriteModernObjC::RewriteObjCStringLiteral(ObjCStringLiteral *Exp) {
assert (Exp != nullptr && "Expected non-null ObjCStringLiteral");
QualType strType = getConstantStringStructType();
std::string S = "__NSConstantStringImpl_";
std::string tmpName = InFileName;
unsigned i;
for (i=0; i < tmpName.length(); i++) {
char c = tmpName.at(i);
// replace any non-alphanumeric characters with '_'.
if (!isAlphanumeric(c))
tmpName[i] = '_';
}
S += tmpName;
S += "_";
S += utostr(NumObjCStringLiterals++);
Preamble += "static __NSConstantStringImpl " + S;
Preamble += " __attribute__ ((section (\"__DATA, __cfstring\"))) = {__CFConstantStringClassReference,";
Preamble += "0x000007c8,"; // utf8_str
// The pretty printer for StringLiteral handles escape characters properly.
std::string prettyBufS;
llvm::raw_string_ostream prettyBuf(prettyBufS);
Exp->getString()->printPretty(prettyBuf, nullptr, PrintingPolicy(LangOpts));
Preamble += prettyBuf.str();
Preamble += ",";
Preamble += utostr(Exp->getString()->getByteLength()) + "};\n";
VarDecl *NewVD = VarDecl::Create(*Context, TUDecl, SourceLocation(),
SourceLocation(), &Context->Idents.get(S),
strType, nullptr, SC_Static);
DeclRefExpr *DRE = new (Context) DeclRefExpr(NewVD, false, strType, VK_LValue,
SourceLocation());
Expr *Unop = new (Context) UnaryOperator(DRE, UO_AddrOf,
Context->getPointerType(DRE->getType()),
VK_RValue, OK_Ordinary,
SourceLocation());
// cast to NSConstantString *
CastExpr *cast = NoTypeInfoCStyleCastExpr(Context, Exp->getType(),
CK_CPointerToObjCPointerCast, Unop);
ReplaceStmt(Exp, cast);
// delete Exp; leak for now, see RewritePropertyOrImplicitSetter() usage for more info.
return cast;
}
Stmt *RewriteModernObjC::RewriteObjCBoolLiteralExpr(ObjCBoolLiteralExpr *Exp) {
unsigned IntSize =
static_cast<unsigned>(Context->getTypeSize(Context->IntTy));
Expr *FlagExp = IntegerLiteral::Create(*Context,
llvm::APInt(IntSize, Exp->getValue()),
Context->IntTy, Exp->getLocation());
CastExpr *cast = NoTypeInfoCStyleCastExpr(Context, Context->ObjCBuiltinBoolTy,
CK_BitCast, FlagExp);
ParenExpr *PE = new (Context) ParenExpr(Exp->getLocation(), Exp->getExprLoc(),
cast);
ReplaceStmt(Exp, PE);
return PE;
}
Stmt *RewriteModernObjC::RewriteObjCBoxedExpr(ObjCBoxedExpr *Exp) {
// synthesize declaration of helper functions needed in this routine.
if (!SelGetUidFunctionDecl)
SynthSelGetUidFunctionDecl();
// use objc_msgSend() for all.
if (!MsgSendFunctionDecl)
SynthMsgSendFunctionDecl();
if (!GetClassFunctionDecl)
SynthGetClassFunctionDecl();
FunctionDecl *MsgSendFlavor = MsgSendFunctionDecl;
SourceLocation StartLoc = Exp->getLocStart();
SourceLocation EndLoc = Exp->getLocEnd();
// Synthesize a call to objc_msgSend().
SmallVector<Expr*, 4> MsgExprs;
SmallVector<Expr*, 4> ClsExprs;
// Create a call to objc_getClass("<BoxingClass>"). It will be the 1st argument.
ObjCMethodDecl *BoxingMethod = Exp->getBoxingMethod();
ObjCInterfaceDecl *BoxingClass = BoxingMethod->getClassInterface();
IdentifierInfo *clsName = BoxingClass->getIdentifier();
ClsExprs.push_back(getStringLiteral(clsName->getName()));
CallExpr *Cls = SynthesizeCallToFunctionDecl(GetClassFunctionDecl,
&ClsExprs[0],
ClsExprs.size(),
StartLoc, EndLoc);
MsgExprs.push_back(Cls);
// Create a call to sel_registerName("<BoxingMethod>:"), etc.
// it will be the 2nd argument.
SmallVector<Expr*, 4> SelExprs;
SelExprs.push_back(
getStringLiteral(BoxingMethod->getSelector().getAsString()));
CallExpr *SelExp = SynthesizeCallToFunctionDecl(SelGetUidFunctionDecl,
&SelExprs[0], SelExprs.size(),
StartLoc, EndLoc);
MsgExprs.push_back(SelExp);
// User provided sub-expression is the 3rd, and last, argument.
Expr *subExpr = Exp->getSubExpr();
if (ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(subExpr)) {
QualType type = ICE->getType();
const Expr *SubExpr = ICE->IgnoreParenImpCasts();
CastKind CK = CK_BitCast;
if (SubExpr->getType()->isIntegralType(*Context) && type->isBooleanType())
CK = CK_IntegralToBoolean;
subExpr = NoTypeInfoCStyleCastExpr(Context, type, CK, subExpr);
}
MsgExprs.push_back(subExpr);
SmallVector<QualType, 4> ArgTypes;
ArgTypes.push_back(Context->getObjCIdType());
ArgTypes.push_back(Context->getObjCSelType());
for (const auto PI : BoxingMethod->parameters())
ArgTypes.push_back(PI->getType());
QualType returnType = Exp->getType();
// Get the type, we will need to reference it in a couple spots.
QualType msgSendType = MsgSendFlavor->getType();
// Create a reference to the objc_msgSend() declaration.
DeclRefExpr *DRE = new (Context) DeclRefExpr(MsgSendFlavor, false, msgSendType,
VK_LValue, SourceLocation());
CastExpr *cast = NoTypeInfoCStyleCastExpr(Context,
Context->getPointerType(Context->VoidTy),
CK_BitCast, DRE);
// Now do the "normal" pointer to function cast.
QualType castType =
getSimpleFunctionType(returnType, ArgTypes, BoxingMethod->isVariadic());
castType = Context->getPointerType(castType);
cast = NoTypeInfoCStyleCastExpr(Context, castType, CK_BitCast,
cast);
// Don't forget the parens to enforce the proper binding.
ParenExpr *PE = new (Context) ParenExpr(StartLoc, EndLoc, cast);
const FunctionType *FT = msgSendType->getAs<FunctionType>();
CallExpr *CE = new (Context)
CallExpr(*Context, PE, MsgExprs, FT->getReturnType(), VK_RValue, EndLoc);
ReplaceStmt(Exp, CE);
return CE;
}
Stmt *RewriteModernObjC::RewriteObjCArrayLiteralExpr(ObjCArrayLiteral *Exp) {
// synthesize declaration of helper functions needed in this routine.
if (!SelGetUidFunctionDecl)
SynthSelGetUidFunctionDecl();
// use objc_msgSend() for all.
if (!MsgSendFunctionDecl)
SynthMsgSendFunctionDecl();
if (!GetClassFunctionDecl)
SynthGetClassFunctionDecl();
FunctionDecl *MsgSendFlavor = MsgSendFunctionDecl;
SourceLocation StartLoc = Exp->getLocStart();
SourceLocation EndLoc = Exp->getLocEnd();
// Build the expression: __NSContainer_literal(int, ...).arr
QualType IntQT = Context->IntTy;
QualType NSArrayFType =
getSimpleFunctionType(Context->VoidTy, IntQT, true);
std::string NSArrayFName("__NSContainer_literal");
FunctionDecl *NSArrayFD = SynthBlockInitFunctionDecl(NSArrayFName);
DeclRefExpr *NSArrayDRE =
new (Context) DeclRefExpr(NSArrayFD, false, NSArrayFType, VK_RValue,
SourceLocation());
SmallVector<Expr*, 16> InitExprs;
unsigned NumElements = Exp->getNumElements();
unsigned UnsignedIntSize =
static_cast<unsigned>(Context->getTypeSize(Context->UnsignedIntTy));
Expr *count = IntegerLiteral::Create(*Context,
llvm::APInt(UnsignedIntSize, NumElements),
Context->UnsignedIntTy, SourceLocation());
InitExprs.push_back(count);
for (unsigned i = 0; i < NumElements; i++)
InitExprs.push_back(Exp->getElement(i));
Expr *NSArrayCallExpr =
new (Context) CallExpr(*Context, NSArrayDRE, InitExprs,
NSArrayFType, VK_LValue, SourceLocation());
FieldDecl *ARRFD = FieldDecl::Create(*Context, nullptr, SourceLocation(),
SourceLocation(),
&Context->Idents.get("arr"),
Context->getPointerType(Context->VoidPtrTy),
nullptr, /*BitWidth=*/nullptr,
/*Mutable=*/true, ICIS_NoInit);
MemberExpr *ArrayLiteralME =
new (Context) MemberExpr(NSArrayCallExpr, false, ARRFD,
SourceLocation(),
ARRFD->getType(), VK_LValue,
OK_Ordinary);
QualType ConstIdT = Context->getObjCIdType().withConst();
CStyleCastExpr * ArrayLiteralObjects =
NoTypeInfoCStyleCastExpr(Context,
Context->getPointerType(ConstIdT),
CK_BitCast,
ArrayLiteralME);
// Synthesize a call to objc_msgSend().
SmallVector<Expr*, 32> MsgExprs;
SmallVector<Expr*, 4> ClsExprs;
QualType expType = Exp->getType();
// Create a call to objc_getClass("NSArray"). It will be th 1st argument.
ObjCInterfaceDecl *Class =
expType->getPointeeType()->getAs<ObjCObjectType>()->getInterface();
IdentifierInfo *clsName = Class->getIdentifier();
ClsExprs.push_back(getStringLiteral(clsName->getName()));
CallExpr *Cls = SynthesizeCallToFunctionDecl(GetClassFunctionDecl,
&ClsExprs[0],
ClsExprs.size(),
StartLoc, EndLoc);
MsgExprs.push_back(Cls);
// Create a call to sel_registerName("arrayWithObjects:count:").
// it will be the 2nd argument.
SmallVector<Expr*, 4> SelExprs;
ObjCMethodDecl *ArrayMethod = Exp->getArrayWithObjectsMethod();
SelExprs.push_back(
getStringLiteral(ArrayMethod->getSelector().getAsString()));
CallExpr *SelExp = SynthesizeCallToFunctionDecl(SelGetUidFunctionDecl,
&SelExprs[0], SelExprs.size(),
StartLoc, EndLoc);
MsgExprs.push_back(SelExp);
// (const id [])objects
MsgExprs.push_back(ArrayLiteralObjects);
// (NSUInteger)cnt
Expr *cnt = IntegerLiteral::Create(*Context,
llvm::APInt(UnsignedIntSize, NumElements),
Context->UnsignedIntTy, SourceLocation());
MsgExprs.push_back(cnt);
SmallVector<QualType, 4> ArgTypes;
ArgTypes.push_back(Context->getObjCIdType());
ArgTypes.push_back(Context->getObjCSelType());
for (const auto *PI : ArrayMethod->params())
ArgTypes.push_back(PI->getType());
QualType returnType = Exp->getType();
// Get the type, we will need to reference it in a couple spots.
QualType msgSendType = MsgSendFlavor->getType();
// Create a reference to the objc_msgSend() declaration.
DeclRefExpr *DRE = new (Context) DeclRefExpr(MsgSendFlavor, false, msgSendType,
VK_LValue, SourceLocation());
CastExpr *cast = NoTypeInfoCStyleCastExpr(Context,
Context->getPointerType(Context->VoidTy),
CK_BitCast, DRE);
// Now do the "normal" pointer to function cast.
QualType castType =
getSimpleFunctionType(returnType, ArgTypes, ArrayMethod->isVariadic());
castType = Context->getPointerType(castType);
cast = NoTypeInfoCStyleCastExpr(Context, castType, CK_BitCast,
cast);
// Don't forget the parens to enforce the proper binding.
ParenExpr *PE = new (Context) ParenExpr(StartLoc, EndLoc, cast);
const FunctionType *FT = msgSendType->getAs<FunctionType>();
CallExpr *CE = new (Context)
CallExpr(*Context, PE, MsgExprs, FT->getReturnType(), VK_RValue, EndLoc);
ReplaceStmt(Exp, CE);
return CE;
}
Stmt *RewriteModernObjC::RewriteObjCDictionaryLiteralExpr(ObjCDictionaryLiteral *Exp) {
// synthesize declaration of helper functions needed in this routine.
if (!SelGetUidFunctionDecl)
SynthSelGetUidFunctionDecl();
// use objc_msgSend() for all.
if (!MsgSendFunctionDecl)
SynthMsgSendFunctionDecl();
if (!GetClassFunctionDecl)
SynthGetClassFunctionDecl();
FunctionDecl *MsgSendFlavor = MsgSendFunctionDecl;
SourceLocation StartLoc = Exp->getLocStart();
SourceLocation EndLoc = Exp->getLocEnd();
// Build the expression: __NSContainer_literal(int, ...).arr
QualType IntQT = Context->IntTy;
QualType NSDictFType =
getSimpleFunctionType(Context->VoidTy, IntQT, true);
std::string NSDictFName("__NSContainer_literal");
FunctionDecl *NSDictFD = SynthBlockInitFunctionDecl(NSDictFName);
DeclRefExpr *NSDictDRE =
new (Context) DeclRefExpr(NSDictFD, false, NSDictFType, VK_RValue,
SourceLocation());
SmallVector<Expr*, 16> KeyExprs;
SmallVector<Expr*, 16> ValueExprs;
unsigned NumElements = Exp->getNumElements();
unsigned UnsignedIntSize =
static_cast<unsigned>(Context->getTypeSize(Context->UnsignedIntTy));
Expr *count = IntegerLiteral::Create(*Context,
llvm::APInt(UnsignedIntSize, NumElements),
Context->UnsignedIntTy, SourceLocation());
KeyExprs.push_back(count);
ValueExprs.push_back(count);
for (unsigned i = 0; i < NumElements; i++) {
ObjCDictionaryElement Element = Exp->getKeyValueElement(i);
KeyExprs.push_back(Element.Key);
ValueExprs.push_back(Element.Value);
}
// (const id [])objects
Expr *NSValueCallExpr =
new (Context) CallExpr(*Context, NSDictDRE, ValueExprs,
NSDictFType, VK_LValue, SourceLocation());
FieldDecl *ARRFD = FieldDecl::Create(*Context, nullptr, SourceLocation(),
SourceLocation(),
&Context->Idents.get("arr"),
Context->getPointerType(Context->VoidPtrTy),
nullptr, /*BitWidth=*/nullptr,
/*Mutable=*/true, ICIS_NoInit);
MemberExpr *DictLiteralValueME =
new (Context) MemberExpr(NSValueCallExpr, false, ARRFD,
SourceLocation(),
ARRFD->getType(), VK_LValue,
OK_Ordinary);
QualType ConstIdT = Context->getObjCIdType().withConst();
CStyleCastExpr * DictValueObjects =
NoTypeInfoCStyleCastExpr(Context,
Context->getPointerType(ConstIdT),
CK_BitCast,
DictLiteralValueME);
// (const id <NSCopying> [])keys
Expr *NSKeyCallExpr =
new (Context) CallExpr(*Context, NSDictDRE, KeyExprs,
NSDictFType, VK_LValue, SourceLocation());
MemberExpr *DictLiteralKeyME =
new (Context) MemberExpr(NSKeyCallExpr, false, ARRFD,
SourceLocation(),
ARRFD->getType(), VK_LValue,
OK_Ordinary);
CStyleCastExpr * DictKeyObjects =
NoTypeInfoCStyleCastExpr(Context,
Context->getPointerType(ConstIdT),
CK_BitCast,
DictLiteralKeyME);
// Synthesize a call to objc_msgSend().
SmallVector<Expr*, 32> MsgExprs;
SmallVector<Expr*, 4> ClsExprs;
QualType expType = Exp->getType();
// Create a call to objc_getClass("NSArray"). It will be th 1st argument.
ObjCInterfaceDecl *Class =
expType->getPointeeType()->getAs<ObjCObjectType>()->getInterface();
IdentifierInfo *clsName = Class->getIdentifier();
ClsExprs.push_back(getStringLiteral(clsName->getName()));
CallExpr *Cls = SynthesizeCallToFunctionDecl(GetClassFunctionDecl,
&ClsExprs[0],
ClsExprs.size(),
StartLoc, EndLoc);
MsgExprs.push_back(Cls);
// Create a call to sel_registerName("arrayWithObjects:count:").
// it will be the 2nd argument.
SmallVector<Expr*, 4> SelExprs;
ObjCMethodDecl *DictMethod = Exp->getDictWithObjectsMethod();
SelExprs.push_back(getStringLiteral(DictMethod->getSelector().getAsString()));
CallExpr *SelExp = SynthesizeCallToFunctionDecl(SelGetUidFunctionDecl,
&SelExprs[0], SelExprs.size(),
StartLoc, EndLoc);
MsgExprs.push_back(SelExp);
// (const id [])objects
MsgExprs.push_back(DictValueObjects);
// (const id <NSCopying> [])keys
MsgExprs.push_back(DictKeyObjects);
// (NSUInteger)cnt
Expr *cnt = IntegerLiteral::Create(*Context,
llvm::APInt(UnsignedIntSize, NumElements),
Context->UnsignedIntTy, SourceLocation());
MsgExprs.push_back(cnt);
SmallVector<QualType, 8> ArgTypes;
ArgTypes.push_back(Context->getObjCIdType());
ArgTypes.push_back(Context->getObjCSelType());
for (const auto *PI : DictMethod->params()) {
QualType T = PI->getType();
if (const PointerType* PT = T->getAs<PointerType>()) {
QualType PointeeTy = PT->getPointeeType();
convertToUnqualifiedObjCType(PointeeTy);
T = Context->getPointerType(PointeeTy);
}
ArgTypes.push_back(T);
}
QualType returnType = Exp->getType();
// Get the type, we will need to reference it in a couple spots.
QualType msgSendType = MsgSendFlavor->getType();
// Create a reference to the objc_msgSend() declaration.
DeclRefExpr *DRE = new (Context) DeclRefExpr(MsgSendFlavor, false, msgSendType,
VK_LValue, SourceLocation());
CastExpr *cast = NoTypeInfoCStyleCastExpr(Context,
Context->getPointerType(Context->VoidTy),
CK_BitCast, DRE);
// Now do the "normal" pointer to function cast.
QualType castType =
getSimpleFunctionType(returnType, ArgTypes, DictMethod->isVariadic());
castType = Context->getPointerType(castType);
cast = NoTypeInfoCStyleCastExpr(Context, castType, CK_BitCast,
cast);
// Don't forget the parens to enforce the proper binding.
ParenExpr *PE = new (Context) ParenExpr(StartLoc, EndLoc, cast);
const FunctionType *FT = msgSendType->getAs<FunctionType>();
CallExpr *CE = new (Context)
CallExpr(*Context, PE, MsgExprs, FT->getReturnType(), VK_RValue, EndLoc);
ReplaceStmt(Exp, CE);
return CE;
}
// struct __rw_objc_super {
// struct objc_object *object; struct objc_object *superClass;
// };
QualType RewriteModernObjC::getSuperStructType() {
if (!SuperStructDecl) {
SuperStructDecl = RecordDecl::Create(*Context, TTK_Struct, TUDecl,
SourceLocation(), SourceLocation(),
&Context->Idents.get("__rw_objc_super"));
QualType FieldTypes[2];
// struct objc_object *object;
FieldTypes[0] = Context->getObjCIdType();
// struct objc_object *superClass;
FieldTypes[1] = Context->getObjCIdType();
// Create fields
for (unsigned i = 0; i < 2; ++i) {
SuperStructDecl->addDecl(FieldDecl::Create(*Context, SuperStructDecl,
SourceLocation(),
SourceLocation(), nullptr,
FieldTypes[i], nullptr,
/*BitWidth=*/nullptr,
/*Mutable=*/false,
ICIS_NoInit));
}
SuperStructDecl->completeDefinition();
}
return Context->getTagDeclType(SuperStructDecl);
}
QualType RewriteModernObjC::getConstantStringStructType() {
if (!ConstantStringDecl) {
ConstantStringDecl = RecordDecl::Create(*Context, TTK_Struct, TUDecl,
SourceLocation(), SourceLocation(),
&Context->Idents.get("__NSConstantStringImpl"));
QualType FieldTypes[4];
// struct objc_object *receiver;
FieldTypes[0] = Context->getObjCIdType();
// int flags;
FieldTypes[1] = Context->IntTy;
// char *str;
FieldTypes[2] = Context->getPointerType(Context->CharTy);
// long length;
FieldTypes[3] = Context->LongTy;
// Create fields
for (unsigned i = 0; i < 4; ++i) {
ConstantStringDecl->addDecl(FieldDecl::Create(*Context,
ConstantStringDecl,
SourceLocation(),
SourceLocation(), nullptr,
FieldTypes[i], nullptr,
/*BitWidth=*/nullptr,
/*Mutable=*/true,
ICIS_NoInit));
}
ConstantStringDecl->completeDefinition();
}
return Context->getTagDeclType(ConstantStringDecl);
}
/// getFunctionSourceLocation - returns start location of a function
/// definition. Complication arises when function has declared as
/// extern "C" or extern "C" {...}
static SourceLocation getFunctionSourceLocation (RewriteModernObjC &R,
FunctionDecl *FD) {
if (FD->isExternC() && !FD->isMain()) {
const DeclContext *DC = FD->getDeclContext();
if (const LinkageSpecDecl *LSD = dyn_cast<LinkageSpecDecl>(DC))
// if it is extern "C" {...}, return function decl's own location.
if (!LSD->getRBraceLoc().isValid())
return LSD->getExternLoc();
}
if (FD->getStorageClass() != SC_None)
R.RewriteBlockLiteralFunctionDecl(FD);
return FD->getTypeSpecStartLoc();
}
void RewriteModernObjC::RewriteLineDirective(const Decl *D) {
SourceLocation Location = D->getLocation();
if (Location.isFileID() && GenerateLineInfo) {
std::string LineString("\n#line ");
PresumedLoc PLoc = SM->getPresumedLoc(Location);
LineString += utostr(PLoc.getLine());
LineString += " \"";
LineString += Lexer::Stringify(PLoc.getFilename());
if (isa<ObjCMethodDecl>(D))
LineString += "\"";
else LineString += "\"\n";
Location = D->getLocStart();
if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
if (FD->isExternC() && !FD->isMain()) {
const DeclContext *DC = FD->getDeclContext();
if (const LinkageSpecDecl *LSD = dyn_cast<LinkageSpecDecl>(DC))
// if it is extern "C" {...}, return function decl's own location.
if (!LSD->getRBraceLoc().isValid())
Location = LSD->getExternLoc();
}
}
InsertText(Location, LineString);
}
}
/// SynthMsgSendStretCallExpr - This routine translates message expression
/// into a call to objc_msgSend_stret() entry point. Tricky part is that
/// nil check on receiver must be performed before calling objc_msgSend_stret.
/// MsgSendStretFlavor - function declaration objc_msgSend_stret(...)
/// msgSendType - function type of objc_msgSend_stret(...)
/// returnType - Result type of the method being synthesized.
/// ArgTypes - type of the arguments passed to objc_msgSend_stret, starting with receiver type.
/// MsgExprs - list of argument expressions being passed to objc_msgSend_stret,
/// starting with receiver.
/// Method - Method being rewritten.
Expr *RewriteModernObjC::SynthMsgSendStretCallExpr(FunctionDecl *MsgSendStretFlavor,
QualType returnType,
SmallVectorImpl<QualType> &ArgTypes,
SmallVectorImpl<Expr*> &MsgExprs,
ObjCMethodDecl *Method) {
// Now do the "normal" pointer to function cast.
QualType castType = getSimpleFunctionType(returnType, ArgTypes,
Method ? Method->isVariadic()
: false);
castType = Context->getPointerType(castType);
// build type for containing the objc_msgSend_stret object.
static unsigned stretCount=0;
std::string name = "__Stret"; name += utostr(stretCount);
std::string str =
"extern \"C\" void * __cdecl memset(void *_Dst, int _Val, size_t _Size);\n";
str += "namespace {\n";
str += "struct "; str += name;
str += " {\n\t";
str += name;
str += "(id receiver, SEL sel";
for (unsigned i = 2; i < ArgTypes.size(); i++) {
std::string ArgName = "arg"; ArgName += utostr(i);
ArgTypes[i].getAsStringInternal(ArgName, Context->getPrintingPolicy());
str += ", "; str += ArgName;
}
// could be vararg.
for (unsigned i = ArgTypes.size(); i < MsgExprs.size(); i++) {
std::string ArgName = "arg"; ArgName += utostr(i);
MsgExprs[i]->getType().getAsStringInternal(ArgName,
Context->getPrintingPolicy());
str += ", "; str += ArgName;
}
str += ") {\n";
str += "\t unsigned size = sizeof(";
str += returnType.getAsString(Context->getPrintingPolicy()); str += ");\n";
str += "\t if (size == 1 || size == 2 || size == 4 || size == 8)\n";
str += "\t s = (("; str += castType.getAsString(Context->getPrintingPolicy());
str += ")(void *)objc_msgSend)(receiver, sel";
for (unsigned i = 2; i < ArgTypes.size(); i++) {
str += ", arg"; str += utostr(i);
}
// could be vararg.
for (unsigned i = ArgTypes.size(); i < MsgExprs.size(); i++) {
str += ", arg"; str += utostr(i);
}
str+= ");\n";
str += "\t else if (receiver == 0)\n";
str += "\t memset((void*)&s, 0, sizeof(s));\n";
str += "\t else\n";
str += "\t s = (("; str += castType.getAsString(Context->getPrintingPolicy());
str += ")(void *)objc_msgSend_stret)(receiver, sel";
for (unsigned i = 2; i < ArgTypes.size(); i++) {
str += ", arg"; str += utostr(i);
}
// could be vararg.
for (unsigned i = ArgTypes.size(); i < MsgExprs.size(); i++) {
str += ", arg"; str += utostr(i);
}
str += ");\n";
str += "\t}\n";
str += "\t"; str += returnType.getAsString(Context->getPrintingPolicy());
str += " s;\n";
str += "};\n};\n\n";
SourceLocation FunLocStart;
if (CurFunctionDef)
FunLocStart = getFunctionSourceLocation(*this, CurFunctionDef);
else {
assert(CurMethodDef && "SynthMsgSendStretCallExpr - CurMethodDef is null");
FunLocStart = CurMethodDef->getLocStart();
}
InsertText(FunLocStart, str);
++stretCount;
// AST for __Stretn(receiver, args).s;
IdentifierInfo *ID = &Context->Idents.get(name);
FunctionDecl *FD = FunctionDecl::Create(*Context, TUDecl, SourceLocation(),
SourceLocation(), ID, castType,
nullptr, SC_Extern, false, false);
DeclRefExpr *DRE = new (Context) DeclRefExpr(FD, false, castType, VK_RValue,
SourceLocation());
CallExpr *STCE = new (Context) CallExpr(*Context, DRE, MsgExprs,
castType, VK_LValue, SourceLocation());
FieldDecl *FieldD = FieldDecl::Create(*Context, nullptr, SourceLocation(),
SourceLocation(),
&Context->Idents.get("s"),
returnType, nullptr,
/*BitWidth=*/nullptr,
/*Mutable=*/true, ICIS_NoInit);
MemberExpr *ME = new (Context) MemberExpr(STCE, false, FieldD, SourceLocation(),
FieldD->getType(), VK_LValue,
OK_Ordinary);
return ME;
}
Stmt *RewriteModernObjC::SynthMessageExpr(ObjCMessageExpr *Exp,
SourceLocation StartLoc,
SourceLocation EndLoc) {
if (!SelGetUidFunctionDecl)
SynthSelGetUidFunctionDecl();
if (!MsgSendFunctionDecl)
SynthMsgSendFunctionDecl();
if (!MsgSendSuperFunctionDecl)
SynthMsgSendSuperFunctionDecl();
if (!MsgSendStretFunctionDecl)
SynthMsgSendStretFunctionDecl();
if (!MsgSendSuperStretFunctionDecl)
SynthMsgSendSuperStretFunctionDecl();
if (!MsgSendFpretFunctionDecl)
SynthMsgSendFpretFunctionDecl();
if (!GetClassFunctionDecl)
SynthGetClassFunctionDecl();
if (!GetSuperClassFunctionDecl)
SynthGetSuperClassFunctionDecl();
if (!GetMetaClassFunctionDecl)
SynthGetMetaClassFunctionDecl();
// default to objc_msgSend().
FunctionDecl *MsgSendFlavor = MsgSendFunctionDecl;
// May need to use objc_msgSend_stret() as well.
FunctionDecl *MsgSendStretFlavor = nullptr;
if (ObjCMethodDecl *mDecl = Exp->getMethodDecl()) {
QualType resultType = mDecl->getReturnType();
if (resultType->isRecordType())
MsgSendStretFlavor = MsgSendStretFunctionDecl;
else if (resultType->isRealFloatingType())
MsgSendFlavor = MsgSendFpretFunctionDecl;
}
// Synthesize a call to objc_msgSend().
SmallVector<Expr*, 8> MsgExprs;
switch (Exp->getReceiverKind()) {
case ObjCMessageExpr::SuperClass: {
MsgSendFlavor = MsgSendSuperFunctionDecl;
if (MsgSendStretFlavor)
MsgSendStretFlavor = MsgSendSuperStretFunctionDecl;
assert(MsgSendFlavor && "MsgSendFlavor is NULL!");
ObjCInterfaceDecl *ClassDecl = CurMethodDef->getClassInterface();
SmallVector<Expr*, 4> InitExprs;
// set the receiver to self, the first argument to all methods.
InitExprs.push_back(
NoTypeInfoCStyleCastExpr(Context, Context->getObjCIdType(),
CK_BitCast,
new (Context) DeclRefExpr(CurMethodDef->getSelfDecl(),
false,
Context->getObjCIdType(),
VK_RValue,
SourceLocation()))
); // set the 'receiver'.
// (id)class_getSuperclass((Class)objc_getClass("CurrentClass"))
SmallVector<Expr*, 8> ClsExprs;
ClsExprs.push_back(getStringLiteral(ClassDecl->getIdentifier()->getName()));
// (Class)objc_getClass("CurrentClass")
CallExpr *Cls = SynthesizeCallToFunctionDecl(GetMetaClassFunctionDecl,
&ClsExprs[0],
ClsExprs.size(),
StartLoc,
EndLoc);
ClsExprs.clear();
ClsExprs.push_back(Cls);
Cls = SynthesizeCallToFunctionDecl(GetSuperClassFunctionDecl,
&ClsExprs[0], ClsExprs.size(),
StartLoc, EndLoc);
// (id)class_getSuperclass((Class)objc_getClass("CurrentClass"))
// To turn off a warning, type-cast to 'id'
InitExprs.push_back( // set 'super class', using class_getSuperclass().
NoTypeInfoCStyleCastExpr(Context,
Context->getObjCIdType(),
CK_BitCast, Cls));
// struct __rw_objc_super
QualType superType = getSuperStructType();
Expr *SuperRep;
if (LangOpts.MicrosoftExt) {
SynthSuperConstructorFunctionDecl();
// Simulate a constructor call...
DeclRefExpr *DRE = new (Context) DeclRefExpr(SuperConstructorFunctionDecl,
false, superType, VK_LValue,
SourceLocation());
SuperRep = new (Context) CallExpr(*Context, DRE, InitExprs,
superType, VK_LValue,
SourceLocation());
// The code for super is a little tricky to prevent collision with
// the structure definition in the header. The rewriter has it's own
// internal definition (__rw_objc_super) that is uses. This is why
// we need the cast below. For example:
// (struct __rw_objc_super *)&__rw_objc_super((id)self, (id)objc_getClass("SUPER"))
//
SuperRep = new (Context) UnaryOperator(SuperRep, UO_AddrOf,
Context->getPointerType(SuperRep->getType()),
VK_RValue, OK_Ordinary,
SourceLocation());
SuperRep = NoTypeInfoCStyleCastExpr(Context,
Context->getPointerType(superType),
CK_BitCast, SuperRep);
} else {
// (struct __rw_objc_super) { <exprs from above> }
InitListExpr *ILE =
new (Context) InitListExpr(*Context, SourceLocation(), InitExprs,
SourceLocation());
TypeSourceInfo *superTInfo
= Context->getTrivialTypeSourceInfo(superType);
SuperRep = new (Context) CompoundLiteralExpr(SourceLocation(), superTInfo,
superType, VK_LValue,
ILE, false);
// struct __rw_objc_super *
SuperRep = new (Context) UnaryOperator(SuperRep, UO_AddrOf,
Context->getPointerType(SuperRep->getType()),
VK_RValue, OK_Ordinary,
SourceLocation());
}
MsgExprs.push_back(SuperRep);
break;
}
case ObjCMessageExpr::Class: {
SmallVector<Expr*, 8> ClsExprs;
ObjCInterfaceDecl *Class
= Exp->getClassReceiver()->getAs<ObjCObjectType>()->getInterface();
IdentifierInfo *clsName = Class->getIdentifier();
ClsExprs.push_back(getStringLiteral(clsName->getName()));
CallExpr *Cls = SynthesizeCallToFunctionDecl(GetClassFunctionDecl,
&ClsExprs[0],
ClsExprs.size(),
StartLoc, EndLoc);
CastExpr *ArgExpr = NoTypeInfoCStyleCastExpr(Context,
Context->getObjCIdType(),
CK_BitCast, Cls);
MsgExprs.push_back(ArgExpr);
break;
}
case ObjCMessageExpr::SuperInstance:{
MsgSendFlavor = MsgSendSuperFunctionDecl;
if (MsgSendStretFlavor)
MsgSendStretFlavor = MsgSendSuperStretFunctionDecl;
assert(MsgSendFlavor && "MsgSendFlavor is NULL!");
ObjCInterfaceDecl *ClassDecl = CurMethodDef->getClassInterface();
SmallVector<Expr*, 4> InitExprs;
InitExprs.push_back(
NoTypeInfoCStyleCastExpr(Context, Context->getObjCIdType(),
CK_BitCast,
new (Context) DeclRefExpr(CurMethodDef->getSelfDecl(),
false,
Context->getObjCIdType(),
VK_RValue, SourceLocation()))
); // set the 'receiver'.
// (id)class_getSuperclass((Class)objc_getClass("CurrentClass"))
SmallVector<Expr*, 8> ClsExprs;
ClsExprs.push_back(getStringLiteral(ClassDecl->getIdentifier()->getName()));
// (Class)objc_getClass("CurrentClass")
CallExpr *Cls = SynthesizeCallToFunctionDecl(GetClassFunctionDecl,
&ClsExprs[0],
ClsExprs.size(),
StartLoc, EndLoc);
ClsExprs.clear();
ClsExprs.push_back(Cls);
Cls = SynthesizeCallToFunctionDecl(GetSuperClassFunctionDecl,
&ClsExprs[0], ClsExprs.size(),
StartLoc, EndLoc);
// (id)class_getSuperclass((Class)objc_getClass("CurrentClass"))
// To turn off a warning, type-cast to 'id'
InitExprs.push_back(
// set 'super class', using class_getSuperclass().
NoTypeInfoCStyleCastExpr(Context, Context->getObjCIdType(),
CK_BitCast, Cls));
// struct __rw_objc_super
QualType superType = getSuperStructType();
Expr *SuperRep;
if (LangOpts.MicrosoftExt) {
SynthSuperConstructorFunctionDecl();
// Simulate a constructor call...
DeclRefExpr *DRE = new (Context) DeclRefExpr(SuperConstructorFunctionDecl,
false, superType, VK_LValue,
SourceLocation());
SuperRep = new (Context) CallExpr(*Context, DRE, InitExprs,
superType, VK_LValue, SourceLocation());
// The code for super is a little tricky to prevent collision with
// the structure definition in the header. The rewriter has it's own
// internal definition (__rw_objc_super) that is uses. This is why
// we need the cast below. For example:
// (struct __rw_objc_super *)&__rw_objc_super((id)self, (id)objc_getClass("SUPER"))
//
SuperRep = new (Context) UnaryOperator(SuperRep, UO_AddrOf,
Context->getPointerType(SuperRep->getType()),
VK_RValue, OK_Ordinary,
SourceLocation());
SuperRep = NoTypeInfoCStyleCastExpr(Context,
Context->getPointerType(superType),
CK_BitCast, SuperRep);
} else {
// (struct __rw_objc_super) { <exprs from above> }
InitListExpr *ILE =
new (Context) InitListExpr(*Context, SourceLocation(), InitExprs,
SourceLocation());
TypeSourceInfo *superTInfo
= Context->getTrivialTypeSourceInfo(superType);
SuperRep = new (Context) CompoundLiteralExpr(SourceLocation(), superTInfo,
superType, VK_RValue, ILE,
false);
}
MsgExprs.push_back(SuperRep);
break;
}
case ObjCMessageExpr::Instance: {
// Remove all type-casts because it may contain objc-style types; e.g.
// Foo<Proto> *.
Expr *recExpr = Exp->getInstanceReceiver();
while (CStyleCastExpr *CE = dyn_cast<CStyleCastExpr>(recExpr))
recExpr = CE->getSubExpr();
CastKind CK = recExpr->getType()->isObjCObjectPointerType()
? CK_BitCast : recExpr->getType()->isBlockPointerType()
? CK_BlockPointerToObjCPointerCast
: CK_CPointerToObjCPointerCast;
recExpr = NoTypeInfoCStyleCastExpr(Context, Context->getObjCIdType(),
CK, recExpr);
MsgExprs.push_back(recExpr);
break;
}
}
// Create a call to sel_registerName("selName"), it will be the 2nd argument.
SmallVector<Expr*, 8> SelExprs;
SelExprs.push_back(getStringLiteral(Exp->getSelector().getAsString()));
CallExpr *SelExp = SynthesizeCallToFunctionDecl(SelGetUidFunctionDecl,
&SelExprs[0], SelExprs.size(),
StartLoc,
EndLoc);
MsgExprs.push_back(SelExp);
// Now push any user supplied arguments.
for (unsigned i = 0; i < Exp->getNumArgs(); i++) {
Expr *userExpr = Exp->getArg(i);
// Make all implicit casts explicit...ICE comes in handy:-)
if (ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(userExpr)) {
// Reuse the ICE type, it is exactly what the doctor ordered.
QualType type = ICE->getType();
if (needToScanForQualifiers(type))
type = Context->getObjCIdType();
// Make sure we convert "type (^)(...)" to "type (*)(...)".
(void)convertBlockPointerToFunctionPointer(type);
const Expr *SubExpr = ICE->IgnoreParenImpCasts();
CastKind CK;
if (SubExpr->getType()->isIntegralType(*Context) &&
type->isBooleanType()) {
CK = CK_IntegralToBoolean;
} else if (type->isObjCObjectPointerType()) {
if (SubExpr->getType()->isBlockPointerType()) {
CK = CK_BlockPointerToObjCPointerCast;
} else if (SubExpr->getType()->isPointerType()) {
CK = CK_CPointerToObjCPointerCast;
} else {
CK = CK_BitCast;
}
} else {
CK = CK_BitCast;
}
userExpr = NoTypeInfoCStyleCastExpr(Context, type, CK, userExpr);
}
// Make id<P...> cast into an 'id' cast.
else if (CStyleCastExpr *CE = dyn_cast<CStyleCastExpr>(userExpr)) {
if (CE->getType()->isObjCQualifiedIdType()) {
while ((CE = dyn_cast<CStyleCastExpr>(userExpr)))
userExpr = CE->getSubExpr();
CastKind CK;
if (userExpr->getType()->isIntegralType(*Context)) {
CK = CK_IntegralToPointer;
} else if (userExpr->getType()->isBlockPointerType()) {
CK = CK_BlockPointerToObjCPointerCast;
} else if (userExpr->getType()->isPointerType()) {
CK = CK_CPointerToObjCPointerCast;
} else {
CK = CK_BitCast;
}
userExpr = NoTypeInfoCStyleCastExpr(Context, Context->getObjCIdType(),
CK, userExpr);
}
}
MsgExprs.push_back(userExpr);
// We've transferred the ownership to MsgExprs. For now, we *don't* null
// out the argument in the original expression (since we aren't deleting
// the ObjCMessageExpr). See RewritePropertyOrImplicitSetter() usage for more info.
//Exp->setArg(i, 0);
}
// Generate the funky cast.
CastExpr *cast;
SmallVector<QualType, 8> ArgTypes;
QualType returnType;
// Push 'id' and 'SEL', the 2 implicit arguments.
if (MsgSendFlavor == MsgSendSuperFunctionDecl)
ArgTypes.push_back(Context->getPointerType(getSuperStructType()));
else
ArgTypes.push_back(Context->getObjCIdType());
ArgTypes.push_back(Context->getObjCSelType());
if (ObjCMethodDecl *OMD = Exp->getMethodDecl()) {
// Push any user argument types.
for (const auto *PI : OMD->params()) {
QualType t = PI->getType()->isObjCQualifiedIdType()
? Context->getObjCIdType()
: PI->getType();
// Make sure we convert "t (^)(...)" to "t (*)(...)".
(void)convertBlockPointerToFunctionPointer(t);
ArgTypes.push_back(t);
}
returnType = Exp->getType();
convertToUnqualifiedObjCType(returnType);
(void)convertBlockPointerToFunctionPointer(returnType);
} else {
returnType = Context->getObjCIdType();
}
// Get the type, we will need to reference it in a couple spots.
QualType msgSendType = MsgSendFlavor->getType();
// Create a reference to the objc_msgSend() declaration.
DeclRefExpr *DRE = new (Context) DeclRefExpr(MsgSendFlavor, false, msgSendType,
VK_LValue, SourceLocation());
// Need to cast objc_msgSend to "void *" (to workaround a GCC bandaid).
// If we don't do this cast, we get the following bizarre warning/note:
// xx.m:13: warning: function called through a non-compatible type
// xx.m:13: note: if this code is reached, the program will abort
cast = NoTypeInfoCStyleCastExpr(Context,
Context->getPointerType(Context->VoidTy),
CK_BitCast, DRE);
// Now do the "normal" pointer to function cast.
// If we don't have a method decl, force a variadic cast.
const ObjCMethodDecl *MD = Exp->getMethodDecl();
QualType castType =
getSimpleFunctionType(returnType, ArgTypes, MD ? MD->isVariadic() : true);
castType = Context->getPointerType(castType);
cast = NoTypeInfoCStyleCastExpr(Context, castType, CK_BitCast,
cast);
// Don't forget the parens to enforce the proper binding.
ParenExpr *PE = new (Context) ParenExpr(StartLoc, EndLoc, cast);
const FunctionType *FT = msgSendType->getAs<FunctionType>();
CallExpr *CE = new (Context)
CallExpr(*Context, PE, MsgExprs, FT->getReturnType(), VK_RValue, EndLoc);
Stmt *ReplacingStmt = CE;
if (MsgSendStretFlavor) {
// We have the method which returns a struct/union. Must also generate
// call to objc_msgSend_stret and hang both varieties on a conditional
// expression which dictate which one to envoke depending on size of
// method's return type.
Expr *STCE = SynthMsgSendStretCallExpr(MsgSendStretFlavor,
returnType,
ArgTypes, MsgExprs,
Exp->getMethodDecl());
ReplacingStmt = STCE;
}
// delete Exp; leak for now, see RewritePropertyOrImplicitSetter() usage for more info.
return ReplacingStmt;
}
Stmt *RewriteModernObjC::RewriteMessageExpr(ObjCMessageExpr *Exp) {
Stmt *ReplacingStmt = SynthMessageExpr(Exp, Exp->getLocStart(),
Exp->getLocEnd());
// Now do the actual rewrite.
ReplaceStmt(Exp, ReplacingStmt);
// delete Exp; leak for now, see RewritePropertyOrImplicitSetter() usage for more info.
return ReplacingStmt;
}
// typedef struct objc_object Protocol;
QualType RewriteModernObjC::getProtocolType() {
if (!ProtocolTypeDecl) {
TypeSourceInfo *TInfo
= Context->getTrivialTypeSourceInfo(Context->getObjCIdType());
ProtocolTypeDecl = TypedefDecl::Create(*Context, TUDecl,
SourceLocation(), SourceLocation(),
&Context->Idents.get("Protocol"),
TInfo);
}
return Context->getTypeDeclType(ProtocolTypeDecl);
}
/// RewriteObjCProtocolExpr - Rewrite a protocol expression into
/// a synthesized/forward data reference (to the protocol's metadata).
/// The forward references (and metadata) are generated in
/// RewriteModernObjC::HandleTranslationUnit().
Stmt *RewriteModernObjC::RewriteObjCProtocolExpr(ObjCProtocolExpr *Exp) {
std::string Name = "_OBJC_PROTOCOL_REFERENCE_$_" +
Exp->getProtocol()->getNameAsString();
IdentifierInfo *ID = &Context->Idents.get(Name);
VarDecl *VD = VarDecl::Create(*Context, TUDecl, SourceLocation(),
SourceLocation(), ID, getProtocolType(),
nullptr, SC_Extern);
DeclRefExpr *DRE = new (Context) DeclRefExpr(VD, false, getProtocolType(),
VK_LValue, SourceLocation());
CastExpr *castExpr =
NoTypeInfoCStyleCastExpr(
Context, Context->getPointerType(DRE->getType()), CK_BitCast, DRE);
ReplaceStmt(Exp, castExpr);
ProtocolExprDecls.insert(Exp->getProtocol()->getCanonicalDecl());
// delete Exp; leak for now, see RewritePropertyOrImplicitSetter() usage for more info.
return castExpr;
}
bool RewriteModernObjC::BufferContainsPPDirectives(const char *startBuf,
const char *endBuf) {
while (startBuf < endBuf) {
if (*startBuf == '#') {
// Skip whitespace.
for (++startBuf; startBuf[0] == ' ' || startBuf[0] == '\t'; ++startBuf)
;
if (!strncmp(startBuf, "if", strlen("if")) ||
!strncmp(startBuf, "ifdef", strlen("ifdef")) ||
!strncmp(startBuf, "ifndef", strlen("ifndef")) ||
!strncmp(startBuf, "define", strlen("define")) ||
!strncmp(startBuf, "undef", strlen("undef")) ||
!strncmp(startBuf, "else", strlen("else")) ||
!strncmp(startBuf, "elif", strlen("elif")) ||
!strncmp(startBuf, "endif", strlen("endif")) ||
!strncmp(startBuf, "pragma", strlen("pragma")) ||
!strncmp(startBuf, "include", strlen("include")) ||
!strncmp(startBuf, "import", strlen("import")) ||
!strncmp(startBuf, "include_next", strlen("include_next")))
return true;
}
startBuf++;
}
return false;
}
/// IsTagDefinedInsideClass - This routine checks that a named tagged type
/// is defined inside an objective-c class. If so, it returns true.
bool RewriteModernObjC::IsTagDefinedInsideClass(ObjCContainerDecl *IDecl,
TagDecl *Tag,
bool &IsNamedDefinition) {
if (!IDecl)
return false;
SourceLocation TagLocation;
if (RecordDecl *RD = dyn_cast<RecordDecl>(Tag)) {
RD = RD->getDefinition();
if (!RD || !RD->getDeclName().getAsIdentifierInfo())
return false;
IsNamedDefinition = true;
TagLocation = RD->getLocation();
return Context->getSourceManager().isBeforeInTranslationUnit(
IDecl->getLocation(), TagLocation);
}
if (EnumDecl *ED = dyn_cast<EnumDecl>(Tag)) {
if (!ED || !ED->getDeclName().getAsIdentifierInfo())
return false;
IsNamedDefinition = true;
TagLocation = ED->getLocation();
return Context->getSourceManager().isBeforeInTranslationUnit(
IDecl->getLocation(), TagLocation);
}
return false;
}
/// RewriteObjCFieldDeclType - This routine rewrites a type into the buffer.
/// It handles elaborated types, as well as enum types in the process.
bool RewriteModernObjC::RewriteObjCFieldDeclType(QualType &Type,
std::string &Result) {
if (isa<TypedefType>(Type)) {
Result += "\t";
return false;
}
if (Type->isArrayType()) {
QualType ElemTy = Context->getBaseElementType(Type);
return RewriteObjCFieldDeclType(ElemTy, Result);
}
else if (Type->isRecordType()) {
RecordDecl *RD = Type->getAs<RecordType>()->getDecl();
if (RD->isCompleteDefinition()) {
if (RD->isStruct())
Result += "\n\tstruct ";
else if (RD->isUnion())
Result += "\n\tunion ";
else
assert(false && "class not allowed as an ivar type");
Result += RD->getName();
if (GlobalDefinedTags.count(RD)) {
// struct/union is defined globally, use it.
Result += " ";
return true;
}
Result += " {\n";
for (auto *FD : RD->fields())
RewriteObjCFieldDecl(FD, Result);
Result += "\t} ";
return true;
}
}
else if (Type->isEnumeralType()) {
EnumDecl *ED = Type->getAs<EnumType>()->getDecl();
if (ED->isCompleteDefinition()) {
Result += "\n\tenum ";
Result += ED->getName();
if (GlobalDefinedTags.count(ED)) {
// Enum is globall defined, use it.
Result += " ";
return true;
}
Result += " {\n";
for (const auto *EC : ED->enumerators()) {
Result += "\t"; Result += EC->getName(); Result += " = ";
llvm::APSInt Val = EC->getInitVal();
Result += Val.toString(10);
Result += ",\n";
}
Result += "\t} ";
return true;
}
}
Result += "\t";
convertObjCTypeToCStyleType(Type);
return false;
}
/// RewriteObjCFieldDecl - This routine rewrites a field into the buffer.
/// It handles elaborated types, as well as enum types in the process.
void RewriteModernObjC::RewriteObjCFieldDecl(FieldDecl *fieldDecl,
std::string &Result) {
QualType Type = fieldDecl->getType();
std::string Name = fieldDecl->getNameAsString();
bool EleboratedType = RewriteObjCFieldDeclType(Type, Result);
if (!EleboratedType)
Type.getAsStringInternal(Name, Context->getPrintingPolicy());
Result += Name;
if (fieldDecl->isBitField()) {
Result += " : "; Result += utostr(fieldDecl->getBitWidthValue(*Context));
}
else if (EleboratedType && Type->isArrayType()) {
const ArrayType *AT = Context->getAsArrayType(Type);
do {
if (const ConstantArrayType *CAT = dyn_cast<ConstantArrayType>(AT)) {
Result += "[";
llvm::APInt Dim = CAT->getSize();
Result += utostr(Dim.getZExtValue());
Result += "]";
}
AT = Context->getAsArrayType(AT->getElementType());
} while (AT);
}
Result += ";\n";
}
/// RewriteLocallyDefinedNamedAggregates - This routine rewrites locally defined
/// named aggregate types into the input buffer.
void RewriteModernObjC::RewriteLocallyDefinedNamedAggregates(FieldDecl *fieldDecl,
std::string &Result) {
QualType Type = fieldDecl->getType();
if (isa<TypedefType>(Type))
return;
if (Type->isArrayType())
Type = Context->getBaseElementType(Type);
ObjCContainerDecl *IDecl =
dyn_cast<ObjCContainerDecl>(fieldDecl->getDeclContext());
TagDecl *TD = nullptr;
if (Type->isRecordType()) {
TD = Type->getAs<RecordType>()->getDecl();
}
else if (Type->isEnumeralType()) {
TD = Type->getAs<EnumType>()->getDecl();
}
if (TD) {
if (GlobalDefinedTags.count(TD))
return;
bool IsNamedDefinition = false;
if (IsTagDefinedInsideClass(IDecl, TD, IsNamedDefinition)) {
RewriteObjCFieldDeclType(Type, Result);
Result += ";";
}
if (IsNamedDefinition)
GlobalDefinedTags.insert(TD);
}
}
unsigned RewriteModernObjC::ObjCIvarBitfieldGroupNo(ObjCIvarDecl *IV) {
const ObjCInterfaceDecl *CDecl = IV->getContainingInterface();
if (ObjCInterefaceHasBitfieldGroups.count(CDecl)) {
return IvarGroupNumber[IV];
}
unsigned GroupNo = 0;
SmallVector<const ObjCIvarDecl *, 8> IVars;
for (const ObjCIvarDecl *IVD = CDecl->all_declared_ivar_begin();
IVD; IVD = IVD->getNextIvar())
IVars.push_back(IVD);
for (unsigned i = 0, e = IVars.size(); i < e; i++)
if (IVars[i]->isBitField()) {
IvarGroupNumber[IVars[i++]] = ++GroupNo;
while (i < e && IVars[i]->isBitField())
IvarGroupNumber[IVars[i++]] = GroupNo;
if (i < e)
--i;
}
ObjCInterefaceHasBitfieldGroups.insert(CDecl);
return IvarGroupNumber[IV];
}
QualType RewriteModernObjC::SynthesizeBitfieldGroupStructType(
ObjCIvarDecl *IV,
SmallVectorImpl<ObjCIvarDecl *> &IVars) {
std::string StructTagName;
ObjCIvarBitfieldGroupType(IV, StructTagName);
RecordDecl *RD = RecordDecl::Create(*Context, TTK_Struct,
Context->getTranslationUnitDecl(),
SourceLocation(), SourceLocation(),
&Context->Idents.get(StructTagName));
for (unsigned i=0, e = IVars.size(); i < e; i++) {
ObjCIvarDecl *Ivar = IVars[i];
RD->addDecl(FieldDecl::Create(*Context, RD, SourceLocation(), SourceLocation(),
&Context->Idents.get(Ivar->getName()),
Ivar->getType(),
nullptr, /*Expr *BW */Ivar->getBitWidth(),
false, ICIS_NoInit));
}
RD->completeDefinition();
return Context->getTagDeclType(RD);
}
QualType RewriteModernObjC::GetGroupRecordTypeForObjCIvarBitfield(ObjCIvarDecl *IV) {
const ObjCInterfaceDecl *CDecl = IV->getContainingInterface();
unsigned GroupNo = ObjCIvarBitfieldGroupNo(IV);
std::pair<const ObjCInterfaceDecl*, unsigned> tuple = std::make_pair(CDecl, GroupNo);
if (GroupRecordType.count(tuple))
return GroupRecordType[tuple];
SmallVector<ObjCIvarDecl *, 8> IVars;
for (const ObjCIvarDecl *IVD = CDecl->all_declared_ivar_begin();
IVD; IVD = IVD->getNextIvar()) {
if (IVD->isBitField())
IVars.push_back(const_cast<ObjCIvarDecl *>(IVD));
else {
if (!IVars.empty()) {
unsigned GroupNo = ObjCIvarBitfieldGroupNo(IVars[0]);
// Generate the struct type for this group of bitfield ivars.
GroupRecordType[std::make_pair(CDecl, GroupNo)] =
SynthesizeBitfieldGroupStructType(IVars[0], IVars);
IVars.clear();
}
}
}
if (!IVars.empty()) {
// Do the last one.
unsigned GroupNo = ObjCIvarBitfieldGroupNo(IVars[0]);
GroupRecordType[std::make_pair(CDecl, GroupNo)] =
SynthesizeBitfieldGroupStructType(IVars[0], IVars);
}
QualType RetQT = GroupRecordType[tuple];
assert(!RetQT.isNull() && "GetGroupRecordTypeForObjCIvarBitfield struct type is NULL");
return RetQT;
}
/// ObjCIvarBitfieldGroupDecl - Names field decl. for ivar bitfield group.
/// Name would be: classname__GRBF_n where n is the group number for this ivar.
void RewriteModernObjC::ObjCIvarBitfieldGroupDecl(ObjCIvarDecl *IV,
std::string &Result) {
const ObjCInterfaceDecl *CDecl = IV->getContainingInterface();
Result += CDecl->getName();
Result += "__GRBF_";
unsigned GroupNo = ObjCIvarBitfieldGroupNo(IV);
Result += utostr(GroupNo);
return;
}
/// ObjCIvarBitfieldGroupType - Names struct type for ivar bitfield group.
/// Name of the struct would be: classname__T_n where n is the group number for
/// this ivar.
void RewriteModernObjC::ObjCIvarBitfieldGroupType(ObjCIvarDecl *IV,
std::string &Result) {
const ObjCInterfaceDecl *CDecl = IV->getContainingInterface();
Result += CDecl->getName();
Result += "__T_";
unsigned GroupNo = ObjCIvarBitfieldGroupNo(IV);
Result += utostr(GroupNo);
return;
}
/// ObjCIvarBitfieldGroupOffset - Names symbol for ivar bitfield group field offset.
/// Name would be: OBJC_IVAR_$_classname__GRBF_n where n is the group number for
/// this ivar.
void RewriteModernObjC::ObjCIvarBitfieldGroupOffset(ObjCIvarDecl *IV,
std::string &Result) {
Result += "OBJC_IVAR_$_";
ObjCIvarBitfieldGroupDecl(IV, Result);
}
#define SKIP_BITFIELDS(IX, ENDIX, VEC) { \
while ((IX < ENDIX) && VEC[IX]->isBitField()) \
++IX; \
if (IX < ENDIX) \
--IX; \
}
/// RewriteObjCInternalStruct - Rewrite one internal struct corresponding to
/// an objective-c class with ivars.
void RewriteModernObjC::RewriteObjCInternalStruct(ObjCInterfaceDecl *CDecl,
std::string &Result) {
assert(CDecl && "Class missing in SynthesizeObjCInternalStruct");
assert(CDecl->getName() != "" &&
"Name missing in SynthesizeObjCInternalStruct");
ObjCInterfaceDecl *RCDecl = CDecl->getSuperClass();
SmallVector<ObjCIvarDecl *, 8> IVars;
for (ObjCIvarDecl *IVD = CDecl->all_declared_ivar_begin();
IVD; IVD = IVD->getNextIvar())
IVars.push_back(IVD);
SourceLocation LocStart = CDecl->getLocStart();
SourceLocation LocEnd = CDecl->getEndOfDefinitionLoc();
const char *startBuf = SM->getCharacterData(LocStart);
const char *endBuf = SM->getCharacterData(LocEnd);
// If no ivars and no root or if its root, directly or indirectly,
// have no ivars (thus not synthesized) then no need to synthesize this class.
if ((!CDecl->isThisDeclarationADefinition() || IVars.size() == 0) &&
(!RCDecl || !ObjCSynthesizedStructs.count(RCDecl))) {
endBuf += Lexer::MeasureTokenLength(LocEnd, *SM, LangOpts);
ReplaceText(LocStart, endBuf-startBuf, Result);
return;
}
// Insert named struct/union definitions inside class to
// outer scope. This follows semantics of locally defined
// struct/unions in objective-c classes.
for (unsigned i = 0, e = IVars.size(); i < e; i++)
RewriteLocallyDefinedNamedAggregates(IVars[i], Result);
// Insert named structs which are syntheized to group ivar bitfields
// to outer scope as well.
for (unsigned i = 0, e = IVars.size(); i < e; i++)
if (IVars[i]->isBitField()) {
ObjCIvarDecl *IV = IVars[i];
QualType QT = GetGroupRecordTypeForObjCIvarBitfield(IV);
RewriteObjCFieldDeclType(QT, Result);
Result += ";";
// skip over ivar bitfields in this group.
SKIP_BITFIELDS(i , e, IVars);
}
Result += "\nstruct ";
Result += CDecl->getNameAsString();
Result += "_IMPL {\n";
if (RCDecl && ObjCSynthesizedStructs.count(RCDecl)) {
Result += "\tstruct "; Result += RCDecl->getNameAsString();
Result += "_IMPL "; Result += RCDecl->getNameAsString();
Result += "_IVARS;\n";
}
for (unsigned i = 0, e = IVars.size(); i < e; i++) {
if (IVars[i]->isBitField()) {
ObjCIvarDecl *IV = IVars[i];
Result += "\tstruct ";
ObjCIvarBitfieldGroupType(IV, Result); Result += " ";
ObjCIvarBitfieldGroupDecl(IV, Result); Result += ";\n";
// skip over ivar bitfields in this group.
SKIP_BITFIELDS(i , e, IVars);
}
else
RewriteObjCFieldDecl(IVars[i], Result);
}
Result += "};\n";
endBuf += Lexer::MeasureTokenLength(LocEnd, *SM, LangOpts);
ReplaceText(LocStart, endBuf-startBuf, Result);
// Mark this struct as having been generated.
if (!ObjCSynthesizedStructs.insert(CDecl).second)
llvm_unreachable("struct already synthesize- RewriteObjCInternalStruct");
}
/// RewriteIvarOffsetSymbols - Rewrite ivar offset symbols of those ivars which
/// have been referenced in an ivar access expression.
void RewriteModernObjC::RewriteIvarOffsetSymbols(ObjCInterfaceDecl *CDecl,
std::string &Result) {
// write out ivar offset symbols which have been referenced in an ivar
// access expression.
llvm::SmallPtrSet<ObjCIvarDecl *, 8> Ivars = ReferencedIvars[CDecl];
if (Ivars.empty())
return;
llvm::DenseSet<std::pair<const ObjCInterfaceDecl*, unsigned> > GroupSymbolOutput;
for (ObjCIvarDecl *IvarDecl : Ivars) {
const ObjCInterfaceDecl *IDecl = IvarDecl->getContainingInterface();
unsigned GroupNo = 0;
if (IvarDecl->isBitField()) {
GroupNo = ObjCIvarBitfieldGroupNo(IvarDecl);
if (GroupSymbolOutput.count(std::make_pair(IDecl, GroupNo)))
continue;
}
Result += "\n";
if (LangOpts.MicrosoftExt)
Result += "__declspec(allocate(\".objc_ivar$B\")) ";
Result += "extern \"C\" ";
if (LangOpts.MicrosoftExt &&
IvarDecl->getAccessControl() != ObjCIvarDecl::Private &&
IvarDecl->getAccessControl() != ObjCIvarDecl::Package)
Result += "__declspec(dllimport) ";
Result += "unsigned long ";
if (IvarDecl->isBitField()) {
ObjCIvarBitfieldGroupOffset(IvarDecl, Result);
GroupSymbolOutput.insert(std::make_pair(IDecl, GroupNo));
}
else
WriteInternalIvarName(CDecl, IvarDecl, Result);
Result += ";";
}
}
//===----------------------------------------------------------------------===//
// Meta Data Emission
//===----------------------------------------------------------------------===//
/// RewriteImplementations - This routine rewrites all method implementations
/// and emits meta-data.
void RewriteModernObjC::RewriteImplementations() {
int ClsDefCount = ClassImplementation.size();
int CatDefCount = CategoryImplementation.size();
// Rewrite implemented methods
for (int i = 0; i < ClsDefCount; i++) {
ObjCImplementationDecl *OIMP = ClassImplementation[i];
ObjCInterfaceDecl *CDecl = OIMP->getClassInterface();
if (CDecl->isImplicitInterfaceDecl())
assert(false &&
"Legacy implicit interface rewriting not supported in moder abi");
RewriteImplementationDecl(OIMP);
}
for (int i = 0; i < CatDefCount; i++) {
ObjCCategoryImplDecl *CIMP = CategoryImplementation[i];
ObjCInterfaceDecl *CDecl = CIMP->getClassInterface();
if (CDecl->isImplicitInterfaceDecl())
assert(false &&
"Legacy implicit interface rewriting not supported in moder abi");
RewriteImplementationDecl(CIMP);
}
}
void RewriteModernObjC::RewriteByRefString(std::string &ResultStr,
const std::string &Name,
ValueDecl *VD, bool def) {
assert(BlockByRefDeclNo.count(VD) &&
"RewriteByRefString: ByRef decl missing");
if (def)
ResultStr += "struct ";
ResultStr += "__Block_byref_" + Name +
"_" + utostr(BlockByRefDeclNo[VD]) ;
}
static bool HasLocalVariableExternalStorage(ValueDecl *VD) {
if (VarDecl *Var = dyn_cast<VarDecl>(VD))
return (Var->isFunctionOrMethodVarDecl() && !Var->hasLocalStorage());
return false;
}
std::string RewriteModernObjC::SynthesizeBlockFunc(BlockExpr *CE, int i,
StringRef funcName,
std::string Tag) {
const FunctionType *AFT = CE->getFunctionType();
QualType RT = AFT->getReturnType();
std::string StructRef = "struct " + Tag;
SourceLocation BlockLoc = CE->getExprLoc();
std::string S;
ConvertSourceLocationToLineDirective(BlockLoc, S);
S += "static " + RT.getAsString(Context->getPrintingPolicy()) + " __" +
funcName.str() + "_block_func_" + utostr(i);
BlockDecl *BD = CE->getBlockDecl();
if (isa<FunctionNoProtoType>(AFT)) {
// No user-supplied arguments. Still need to pass in a pointer to the
// block (to reference imported block decl refs).
S += "(" + StructRef + " *__cself)";
} else if (BD->param_empty()) {
S += "(" + StructRef + " *__cself)";
} else {
const FunctionProtoType *FT = cast<FunctionProtoType>(AFT);
assert(FT && "SynthesizeBlockFunc: No function proto");
S += '(';
// first add the implicit argument.
S += StructRef + " *__cself, ";
std::string ParamStr;
for (BlockDecl::param_iterator AI = BD->param_begin(),
E = BD->param_end(); AI != E; ++AI) {
if (AI != BD->param_begin()) S += ", ";
ParamStr = (*AI)->getNameAsString();
QualType QT = (*AI)->getType();
(void)convertBlockPointerToFunctionPointer(QT);
QT.getAsStringInternal(ParamStr, Context->getPrintingPolicy());
S += ParamStr;
}
if (FT->isVariadic()) {
if (!BD->param_empty()) S += ", ";
S += "...";
}
S += ')';
}
S += " {\n";
// Create local declarations to avoid rewriting all closure decl ref exprs.
// First, emit a declaration for all "by ref" decls.
for (SmallVectorImpl<ValueDecl *>::iterator I = BlockByRefDecls.begin(),
E = BlockByRefDecls.end(); I != E; ++I) {
S += " ";
std::string Name = (*I)->getNameAsString();
std::string TypeString;
RewriteByRefString(TypeString, Name, (*I));
TypeString += " *";
Name = TypeString + Name;
S += Name + " = __cself->" + (*I)->getNameAsString() + "; // bound by ref\n";
}
// Next, emit a declaration for all "by copy" declarations.
for (SmallVectorImpl<ValueDecl *>::iterator I = BlockByCopyDecls.begin(),
E = BlockByCopyDecls.end(); I != E; ++I) {
S += " ";
// Handle nested closure invocation. For example:
//
// void (^myImportedClosure)(void);
// myImportedClosure = ^(void) { setGlobalInt(x + y); };
//
// void (^anotherClosure)(void);
// anotherClosure = ^(void) {
// myImportedClosure(); // import and invoke the closure
// };
//
if (isTopLevelBlockPointerType((*I)->getType())) {
RewriteBlockPointerTypeVariable(S, (*I));
S += " = (";
RewriteBlockPointerType(S, (*I)->getType());
S += ")";
S += "__cself->" + (*I)->getNameAsString() + "; // bound by copy\n";
}
else {
std::string Name = (*I)->getNameAsString();
QualType QT = (*I)->getType();
if (HasLocalVariableExternalStorage(*I))
QT = Context->getPointerType(QT);
QT.getAsStringInternal(Name, Context->getPrintingPolicy());
S += Name + " = __cself->" +
(*I)->getNameAsString() + "; // bound by copy\n";
}
}
std::string RewrittenStr = RewrittenBlockExprs[CE];
const char *cstr = RewrittenStr.c_str();
while (*cstr++ != '{') ;
S += cstr;
S += "\n";
return S;
}
std::string RewriteModernObjC::SynthesizeBlockHelperFuncs(BlockExpr *CE, int i,
StringRef funcName,
std::string Tag) {
std::string StructRef = "struct " + Tag;
std::string S = "static void __";
S += funcName;
S += "_block_copy_" + utostr(i);
S += "(" + StructRef;
S += "*dst, " + StructRef;
S += "*src) {";
for (ValueDecl *VD : ImportedBlockDecls) {
S += "_Block_object_assign((void*)&dst->";
S += VD->getNameAsString();
S += ", (void*)src->";
S += VD->getNameAsString();
if (BlockByRefDeclsPtrSet.count(VD))
S += ", " + utostr(BLOCK_FIELD_IS_BYREF) + "/*BLOCK_FIELD_IS_BYREF*/);";
else if (VD->getType()->isBlockPointerType())
S += ", " + utostr(BLOCK_FIELD_IS_BLOCK) + "/*BLOCK_FIELD_IS_BLOCK*/);";
else
S += ", " + utostr(BLOCK_FIELD_IS_OBJECT) + "/*BLOCK_FIELD_IS_OBJECT*/);";
}
S += "}\n";
S += "\nstatic void __";
S += funcName;
S += "_block_dispose_" + utostr(i);
S += "(" + StructRef;
S += "*src) {";
for (ValueDecl *VD : ImportedBlockDecls) {
S += "_Block_object_dispose((void*)src->";
S += VD->getNameAsString();
if (BlockByRefDeclsPtrSet.count(VD))
S += ", " + utostr(BLOCK_FIELD_IS_BYREF) + "/*BLOCK_FIELD_IS_BYREF*/);";
else if (VD->getType()->isBlockPointerType())
S += ", " + utostr(BLOCK_FIELD_IS_BLOCK) + "/*BLOCK_FIELD_IS_BLOCK*/);";
else
S += ", " + utostr(BLOCK_FIELD_IS_OBJECT) + "/*BLOCK_FIELD_IS_OBJECT*/);";
}
S += "}\n";
return S;
}
std::string RewriteModernObjC::SynthesizeBlockImpl(BlockExpr *CE, std::string Tag,
std::string Desc) {
std::string S = "\nstruct " + Tag;
std::string Constructor = " " + Tag;
S += " {\n struct __block_impl impl;\n";
S += " struct " + Desc;
S += "* Desc;\n";
Constructor += "(void *fp, "; // Invoke function pointer.
Constructor += "struct " + Desc; // Descriptor pointer.
Constructor += " *desc";
if (BlockDeclRefs.size()) {
// Output all "by copy" declarations.
for (SmallVectorImpl<ValueDecl *>::iterator I = BlockByCopyDecls.begin(),
E = BlockByCopyDecls.end(); I != E; ++I) {
S += " ";
std::string FieldName = (*I)->getNameAsString();
std::string ArgName = "_" + FieldName;
// Handle nested closure invocation. For example:
//
// void (^myImportedBlock)(void);
// myImportedBlock = ^(void) { setGlobalInt(x + y); };
//
// void (^anotherBlock)(void);
// anotherBlock = ^(void) {
// myImportedBlock(); // import and invoke the closure
// };
//
if (isTopLevelBlockPointerType((*I)->getType())) {
S += "struct __block_impl *";
Constructor += ", void *" + ArgName;
} else {
QualType QT = (*I)->getType();
if (HasLocalVariableExternalStorage(*I))
QT = Context->getPointerType(QT);
QT.getAsStringInternal(FieldName, Context->getPrintingPolicy());
QT.getAsStringInternal(ArgName, Context->getPrintingPolicy());
Constructor += ", " + ArgName;
}
S += FieldName + ";\n";
}
// Output all "by ref" declarations.
for (SmallVectorImpl<ValueDecl *>::iterator I = BlockByRefDecls.begin(),
E = BlockByRefDecls.end(); I != E; ++I) {
S += " ";
std::string FieldName = (*I)->getNameAsString();
std::string ArgName = "_" + FieldName;
{
std::string TypeString;
RewriteByRefString(TypeString, FieldName, (*I));
TypeString += " *";
FieldName = TypeString + FieldName;
ArgName = TypeString + ArgName;
Constructor += ", " + ArgName;
}
S += FieldName + "; // by ref\n";
}
// Finish writing the constructor.
Constructor += ", int flags=0)";
// Initialize all "by copy" arguments.
bool firsTime = true;
for (SmallVectorImpl<ValueDecl *>::iterator I = BlockByCopyDecls.begin(),
E = BlockByCopyDecls.end(); I != E; ++I) {
std::string Name = (*I)->getNameAsString();
if (firsTime) {
Constructor += " : ";
firsTime = false;
}
else
Constructor += ", ";
if (isTopLevelBlockPointerType((*I)->getType()))
Constructor += Name + "((struct __block_impl *)_" + Name + ")";
else
Constructor += Name + "(_" + Name + ")";
}
// Initialize all "by ref" arguments.
for (SmallVectorImpl<ValueDecl *>::iterator I = BlockByRefDecls.begin(),
E = BlockByRefDecls.end(); I != E; ++I) {
std::string Name = (*I)->getNameAsString();
if (firsTime) {
Constructor += " : ";
firsTime = false;
}
else
Constructor += ", ";
Constructor += Name + "(_" + Name + "->__forwarding)";
}
Constructor += " {\n";
if (GlobalVarDecl)
Constructor += " impl.isa = &_NSConcreteGlobalBlock;\n";
else
Constructor += " impl.isa = &_NSConcreteStackBlock;\n";
Constructor += " impl.Flags = flags;\n impl.FuncPtr = fp;\n";
Constructor += " Desc = desc;\n";
} else {
// Finish writing the constructor.
Constructor += ", int flags=0) {\n";
if (GlobalVarDecl)
Constructor += " impl.isa = &_NSConcreteGlobalBlock;\n";
else
Constructor += " impl.isa = &_NSConcreteStackBlock;\n";
Constructor += " impl.Flags = flags;\n impl.FuncPtr = fp;\n";
Constructor += " Desc = desc;\n";
}
Constructor += " ";
Constructor += "}\n";
S += Constructor;
S += "};\n";
return S;
}
std::string RewriteModernObjC::SynthesizeBlockDescriptor(std::string DescTag,
std::string ImplTag, int i,
StringRef FunName,
unsigned hasCopy) {
std::string S = "\nstatic struct " + DescTag;
S += " {\n size_t reserved;\n";
S += " size_t Block_size;\n";
if (hasCopy) {
S += " void (*copy)(struct ";
S += ImplTag; S += "*, struct ";
S += ImplTag; S += "*);\n";
S += " void (*dispose)(struct ";
S += ImplTag; S += "*);\n";
}
S += "} ";
S += DescTag + "_DATA = { 0, sizeof(struct ";
S += ImplTag + ")";
if (hasCopy) {
S += ", __" + FunName.str() + "_block_copy_" + utostr(i);
S += ", __" + FunName.str() + "_block_dispose_" + utostr(i);
}
S += "};\n";
return S;
}
void RewriteModernObjC::SynthesizeBlockLiterals(SourceLocation FunLocStart,
StringRef FunName) {
bool RewriteSC = (GlobalVarDecl &&
!Blocks.empty() &&
GlobalVarDecl->getStorageClass() == SC_Static &&
GlobalVarDecl->getType().getCVRQualifiers());
if (RewriteSC) {
std::string SC(" void __");
SC += GlobalVarDecl->getNameAsString();
SC += "() {}";
InsertText(FunLocStart, SC);
}
// Insert closures that were part of the function.
for (unsigned i = 0, count=0; i < Blocks.size(); i++) {
CollectBlockDeclRefInfo(Blocks[i]);
// Need to copy-in the inner copied-in variables not actually used in this
// block.
for (int j = 0; j < InnerDeclRefsCount[i]; j++) {
DeclRefExpr *Exp = InnerDeclRefs[count++];
ValueDecl *VD = Exp->getDecl();
BlockDeclRefs.push_back(Exp);
if (!VD->hasAttr<BlocksAttr>()) {
if (!BlockByCopyDeclsPtrSet.count(VD)) {
BlockByCopyDeclsPtrSet.insert(VD);
BlockByCopyDecls.push_back(VD);
}
continue;
}
if (!BlockByRefDeclsPtrSet.count(VD)) {
BlockByRefDeclsPtrSet.insert(VD);
BlockByRefDecls.push_back(VD);
}
// imported objects in the inner blocks not used in the outer
// blocks must be copied/disposed in the outer block as well.
if (VD->getType()->isObjCObjectPointerType() ||
VD->getType()->isBlockPointerType())
ImportedBlockDecls.insert(VD);
}
std::string ImplTag = "__" + FunName.str() + "_block_impl_" + utostr(i);
std::string DescTag = "__" + FunName.str() + "_block_desc_" + utostr(i);
std::string CI = SynthesizeBlockImpl(Blocks[i], ImplTag, DescTag);
InsertText(FunLocStart, CI);
std::string CF = SynthesizeBlockFunc(Blocks[i], i, FunName, ImplTag);
InsertText(FunLocStart, CF);
if (ImportedBlockDecls.size()) {
std::string HF = SynthesizeBlockHelperFuncs(Blocks[i], i, FunName, ImplTag);
InsertText(FunLocStart, HF);
}
std::string BD = SynthesizeBlockDescriptor(DescTag, ImplTag, i, FunName,
ImportedBlockDecls.size() > 0);
InsertText(FunLocStart, BD);
BlockDeclRefs.clear();
BlockByRefDecls.clear();
BlockByRefDeclsPtrSet.clear();
BlockByCopyDecls.clear();
BlockByCopyDeclsPtrSet.clear();
ImportedBlockDecls.clear();
}
if (RewriteSC) {
// Must insert any 'const/volatile/static here. Since it has been
// removed as result of rewriting of block literals.
std::string SC;
if (GlobalVarDecl->getStorageClass() == SC_Static)
SC = "static ";
if (GlobalVarDecl->getType().isConstQualified())
SC += "const ";
if (GlobalVarDecl->getType().isVolatileQualified())
SC += "volatile ";
if (GlobalVarDecl->getType().isRestrictQualified())
SC += "restrict ";
InsertText(FunLocStart, SC);
}
if (GlobalConstructionExp) {
// extra fancy dance for global literal expression.
// Always the latest block expression on the block stack.
std::string Tag = "__";
Tag += FunName;
Tag += "_block_impl_";
Tag += utostr(Blocks.size()-1);
std::string globalBuf = "static ";
globalBuf += Tag; globalBuf += " ";
std::string SStr;
llvm::raw_string_ostream constructorExprBuf(SStr);
GlobalConstructionExp->printPretty(constructorExprBuf, nullptr,
PrintingPolicy(LangOpts));
globalBuf += constructorExprBuf.str();
globalBuf += ";\n";
InsertText(FunLocStart, globalBuf);
GlobalConstructionExp = nullptr;
}
Blocks.clear();
InnerDeclRefsCount.clear();
InnerDeclRefs.clear();
RewrittenBlockExprs.clear();
}
void RewriteModernObjC::InsertBlockLiteralsWithinFunction(FunctionDecl *FD) {
SourceLocation FunLocStart =
(!Blocks.empty()) ? getFunctionSourceLocation(*this, FD)
: FD->getTypeSpecStartLoc();
StringRef FuncName = FD->getName();
SynthesizeBlockLiterals(FunLocStart, FuncName);
}
static void BuildUniqueMethodName(std::string &Name,
ObjCMethodDecl *MD) {
ObjCInterfaceDecl *IFace = MD->getClassInterface();
Name = IFace->getName();
Name += "__" + MD->getSelector().getAsString();
// Convert colons to underscores.
std::string::size_type loc = 0;
while ((loc = Name.find(":", loc)) != std::string::npos)
Name.replace(loc, 1, "_");
}
void RewriteModernObjC::InsertBlockLiteralsWithinMethod(ObjCMethodDecl *MD) {
//fprintf(stderr,"In InsertBlockLiteralsWitinMethod\n");
//SourceLocation FunLocStart = MD->getLocStart();
SourceLocation FunLocStart = MD->getLocStart();
std::string FuncName;
BuildUniqueMethodName(FuncName, MD);
SynthesizeBlockLiterals(FunLocStart, FuncName);
}
void RewriteModernObjC::GetBlockDeclRefExprs(Stmt *S) {
for (Stmt::child_range CI = S->children(); CI; ++CI)
if (*CI) {
if (BlockExpr *CBE = dyn_cast<BlockExpr>(*CI))
GetBlockDeclRefExprs(CBE->getBody());
else
GetBlockDeclRefExprs(*CI);
}
// Handle specific things.
if (DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(S)) {
if (DRE->refersToEnclosingLocal()) {
// FIXME: Handle enums.
if (!isa<FunctionDecl>(DRE->getDecl()))
BlockDeclRefs.push_back(DRE);
if (HasLocalVariableExternalStorage(DRE->getDecl()))
BlockDeclRefs.push_back(DRE);
}
}
return;
}
void RewriteModernObjC::GetInnerBlockDeclRefExprs(Stmt *S,
SmallVectorImpl<DeclRefExpr *> &InnerBlockDeclRefs,
llvm::SmallPtrSetImpl<const DeclContext *> &InnerContexts) {
for (Stmt::child_range CI = S->children(); CI; ++CI)
if (*CI) {
if (BlockExpr *CBE = dyn_cast<BlockExpr>(*CI)) {
InnerContexts.insert(cast<DeclContext>(CBE->getBlockDecl()));
GetInnerBlockDeclRefExprs(CBE->getBody(),
InnerBlockDeclRefs,
InnerContexts);
}
else
GetInnerBlockDeclRefExprs(*CI,
InnerBlockDeclRefs,
InnerContexts);
}
// Handle specific things.
if (DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(S)) {
if (DRE->refersToEnclosingLocal()) {
if (!isa<FunctionDecl>(DRE->getDecl()) &&
!InnerContexts.count(DRE->getDecl()->getDeclContext()))
InnerBlockDeclRefs.push_back(DRE);
if (VarDecl *Var = dyn_cast<VarDecl>(DRE->getDecl()))
if (Var->isFunctionOrMethodVarDecl())
ImportedLocalExternalDecls.insert(Var);
}
}
return;
}
/// convertObjCTypeToCStyleType - This routine converts such objc types
/// as qualified objects, and blocks to their closest c/c++ types that
/// it can. It returns true if input type was modified.
bool RewriteModernObjC::convertObjCTypeToCStyleType(QualType &T) {
QualType oldT = T;
convertBlockPointerToFunctionPointer(T);
if (T->isFunctionPointerType()) {
QualType PointeeTy;
if (const PointerType* PT = T->getAs<PointerType>()) {
PointeeTy = PT->getPointeeType();
if (const FunctionType *FT = PointeeTy->getAs<FunctionType>()) {
T = convertFunctionTypeOfBlocks(FT);
T = Context->getPointerType(T);
}
}
}
convertToUnqualifiedObjCType(T);
return T != oldT;
}
/// convertFunctionTypeOfBlocks - This routine converts a function type
/// whose result type may be a block pointer or whose argument type(s)
/// might be block pointers to an equivalent function type replacing
/// all block pointers to function pointers.
QualType RewriteModernObjC::convertFunctionTypeOfBlocks(const FunctionType *FT) {
const FunctionProtoType *FTP = dyn_cast<FunctionProtoType>(FT);
// FTP will be null for closures that don't take arguments.
// Generate a funky cast.
SmallVector<QualType, 8> ArgTypes;
QualType Res = FT->getReturnType();
bool modified = convertObjCTypeToCStyleType(Res);
if (FTP) {
for (auto &I : FTP->param_types()) {
QualType t = I;
// Make sure we convert "t (^)(...)" to "t (*)(...)".
if (convertObjCTypeToCStyleType(t))
modified = true;
ArgTypes.push_back(t);
}
}
QualType FuncType;
if (modified)
FuncType = getSimpleFunctionType(Res, ArgTypes);
else FuncType = QualType(FT, 0);
return FuncType;
}
Stmt *RewriteModernObjC::SynthesizeBlockCall(CallExpr *Exp, const Expr *BlockExp) {
// Navigate to relevant type information.
const BlockPointerType *CPT = nullptr;
if (const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(BlockExp)) {
CPT = DRE->getType()->getAs<BlockPointerType>();
} else if (const MemberExpr *MExpr = dyn_cast<MemberExpr>(BlockExp)) {
CPT = MExpr->getType()->getAs<BlockPointerType>();
}
else if (const ParenExpr *PRE = dyn_cast<ParenExpr>(BlockExp)) {
return SynthesizeBlockCall(Exp, PRE->getSubExpr());
}
else if (const ImplicitCastExpr *IEXPR = dyn_cast<ImplicitCastExpr>(BlockExp))
CPT = IEXPR->getType()->getAs<BlockPointerType>();
else if (const ConditionalOperator *CEXPR =
dyn_cast<ConditionalOperator>(BlockExp)) {
Expr *LHSExp = CEXPR->getLHS();
Stmt *LHSStmt = SynthesizeBlockCall(Exp, LHSExp);
Expr *RHSExp = CEXPR->getRHS();
Stmt *RHSStmt = SynthesizeBlockCall(Exp, RHSExp);
Expr *CONDExp = CEXPR->getCond();
ConditionalOperator *CondExpr =
new (Context) ConditionalOperator(CONDExp,
SourceLocation(), cast<Expr>(LHSStmt),
SourceLocation(), cast<Expr>(RHSStmt),
Exp->getType(), VK_RValue, OK_Ordinary);
return CondExpr;
} else if (const ObjCIvarRefExpr *IRE = dyn_cast<ObjCIvarRefExpr>(BlockExp)) {
CPT = IRE->getType()->getAs<BlockPointerType>();
} else if (const PseudoObjectExpr *POE
= dyn_cast<PseudoObjectExpr>(BlockExp)) {
CPT = POE->getType()->castAs<BlockPointerType>();
} else {
assert(1 && "RewriteBlockClass: Bad type");
}
assert(CPT && "RewriteBlockClass: Bad type");
const FunctionType *FT = CPT->getPointeeType()->getAs<FunctionType>();
assert(FT && "RewriteBlockClass: Bad type");
const FunctionProtoType *FTP = dyn_cast<FunctionProtoType>(FT);
// FTP will be null for closures that don't take arguments.
RecordDecl *RD = RecordDecl::Create(*Context, TTK_Struct, TUDecl,
SourceLocation(), SourceLocation(),
&Context->Idents.get("__block_impl"));
QualType PtrBlock = Context->getPointerType(Context->getTagDeclType(RD));
// Generate a funky cast.
SmallVector<QualType, 8> ArgTypes;
// Push the block argument type.
ArgTypes.push_back(PtrBlock);
if (FTP) {
for (auto &I : FTP->param_types()) {
QualType t = I;
// Make sure we convert "t (^)(...)" to "t (*)(...)".
if (!convertBlockPointerToFunctionPointer(t))
convertToUnqualifiedObjCType(t);
ArgTypes.push_back(t);
}
}
// Now do the pointer to function cast.
QualType PtrToFuncCastType = getSimpleFunctionType(Exp->getType(), ArgTypes);
PtrToFuncCastType = Context->getPointerType(PtrToFuncCastType);
CastExpr *BlkCast = NoTypeInfoCStyleCastExpr(Context, PtrBlock,
CK_BitCast,
const_cast<Expr*>(BlockExp));
// Don't forget the parens to enforce the proper binding.
ParenExpr *PE = new (Context) ParenExpr(SourceLocation(), SourceLocation(),
BlkCast);
//PE->dump();
FieldDecl *FD = FieldDecl::Create(*Context, nullptr, SourceLocation(),
SourceLocation(),
&Context->Idents.get("FuncPtr"),
Context->VoidPtrTy, nullptr,
/*BitWidth=*/nullptr, /*Mutable=*/true,
ICIS_NoInit);
MemberExpr *ME = new (Context) MemberExpr(PE, true, FD, SourceLocation(),
FD->getType(), VK_LValue,
OK_Ordinary);
CastExpr *FunkCast = NoTypeInfoCStyleCastExpr(Context, PtrToFuncCastType,
CK_BitCast, ME);
PE = new (Context) ParenExpr(SourceLocation(), SourceLocation(), FunkCast);
SmallVector<Expr*, 8> BlkExprs;
// Add the implicit argument.
BlkExprs.push_back(BlkCast);
// Add the user arguments.
for (CallExpr::arg_iterator I = Exp->arg_begin(),
E = Exp->arg_end(); I != E; ++I) {
BlkExprs.push_back(*I);
}
CallExpr *CE = new (Context) CallExpr(*Context, PE, BlkExprs,
Exp->getType(), VK_RValue,
SourceLocation());
return CE;
}
// We need to return the rewritten expression to handle cases where the
// DeclRefExpr is embedded in another expression being rewritten.
// For example:
//
// int main() {
// __block Foo *f;
// __block int i;
//
// void (^myblock)() = ^() {
// [f test]; // f is a DeclRefExpr embedded in a message (which is being rewritten).
// i = 77;
// };
//}
Stmt *RewriteModernObjC::RewriteBlockDeclRefExpr(DeclRefExpr *DeclRefExp) {
// Rewrite the byref variable into BYREFVAR->__forwarding->BYREFVAR
// for each DeclRefExp where BYREFVAR is name of the variable.
ValueDecl *VD = DeclRefExp->getDecl();
bool isArrow = DeclRefExp->refersToEnclosingLocal();
FieldDecl *FD = FieldDecl::Create(*Context, nullptr, SourceLocation(),
SourceLocation(),
&Context->Idents.get("__forwarding"),
Context->VoidPtrTy, nullptr,
/*BitWidth=*/nullptr, /*Mutable=*/true,
ICIS_NoInit);
MemberExpr *ME = new (Context) MemberExpr(DeclRefExp, isArrow,
FD, SourceLocation(),
FD->getType(), VK_LValue,
OK_Ordinary);
StringRef Name = VD->getName();
FD = FieldDecl::Create(*Context, nullptr, SourceLocation(), SourceLocation(),
&Context->Idents.get(Name),
Context->VoidPtrTy, nullptr,
/*BitWidth=*/nullptr, /*Mutable=*/true,
ICIS_NoInit);
ME = new (Context) MemberExpr(ME, true, FD, SourceLocation(),
DeclRefExp->getType(), VK_LValue, OK_Ordinary);
// Need parens to enforce precedence.
ParenExpr *PE = new (Context) ParenExpr(DeclRefExp->getExprLoc(),
DeclRefExp->getExprLoc(),
ME);
ReplaceStmt(DeclRefExp, PE);
return PE;
}
// Rewrites the imported local variable V with external storage
// (static, extern, etc.) as *V
//
Stmt *RewriteModernObjC::RewriteLocalVariableExternalStorage(DeclRefExpr *DRE) {
ValueDecl *VD = DRE->getDecl();
if (VarDecl *Var = dyn_cast<VarDecl>(VD))
if (!ImportedLocalExternalDecls.count(Var))
return DRE;
Expr *Exp = new (Context) UnaryOperator(DRE, UO_Deref, DRE->getType(),
VK_LValue, OK_Ordinary,
DRE->getLocation());
// Need parens to enforce precedence.
ParenExpr *PE = new (Context) ParenExpr(SourceLocation(), SourceLocation(),
Exp);
ReplaceStmt(DRE, PE);
return PE;
}
void RewriteModernObjC::RewriteCastExpr(CStyleCastExpr *CE) {
SourceLocation LocStart = CE->getLParenLoc();
SourceLocation LocEnd = CE->getRParenLoc();
// Need to avoid trying to rewrite synthesized casts.
if (LocStart.isInvalid())
return;
// Need to avoid trying to rewrite casts contained in macros.
if (!Rewriter::isRewritable(LocStart) || !Rewriter::isRewritable(LocEnd))
return;
const char *startBuf = SM->getCharacterData(LocStart);
const char *endBuf = SM->getCharacterData(LocEnd);
QualType QT = CE->getType();
const Type* TypePtr = QT->getAs<Type>();
if (isa<TypeOfExprType>(TypePtr)) {
const TypeOfExprType *TypeOfExprTypePtr = cast<TypeOfExprType>(TypePtr);
QT = TypeOfExprTypePtr->getUnderlyingExpr()->getType();
std::string TypeAsString = "(";
RewriteBlockPointerType(TypeAsString, QT);
TypeAsString += ")";
ReplaceText(LocStart, endBuf-startBuf+1, TypeAsString);
return;
}
// advance the location to startArgList.
const char *argPtr = startBuf;
while (*argPtr++ && (argPtr < endBuf)) {
switch (*argPtr) {
case '^':
// Replace the '^' with '*'.
LocStart = LocStart.getLocWithOffset(argPtr-startBuf);
ReplaceText(LocStart, 1, "*");
break;
}
}
return;
}
void RewriteModernObjC::RewriteImplicitCastObjCExpr(CastExpr *IC) {
CastKind CastKind = IC->getCastKind();
if (CastKind != CK_BlockPointerToObjCPointerCast &&
CastKind != CK_AnyPointerToBlockPointerCast)
return;
QualType QT = IC->getType();
(void)convertBlockPointerToFunctionPointer(QT);
std::string TypeString(QT.getAsString(Context->getPrintingPolicy()));
std::string Str = "(";
Str += TypeString;
Str += ")";
InsertText(IC->getSubExpr()->getLocStart(), &Str[0], Str.size());
return;
}
void RewriteModernObjC::RewriteBlockPointerFunctionArgs(FunctionDecl *FD) {
SourceLocation DeclLoc = FD->getLocation();
unsigned parenCount = 0;
// We have 1 or more arguments that have closure pointers.
const char *startBuf = SM->getCharacterData(DeclLoc);
const char *startArgList = strchr(startBuf, '(');
assert((*startArgList == '(') && "Rewriter fuzzy parser confused");
parenCount++;
// advance the location to startArgList.
DeclLoc = DeclLoc.getLocWithOffset(startArgList-startBuf);
assert((DeclLoc.isValid()) && "Invalid DeclLoc");
const char *argPtr = startArgList;
while (*argPtr++ && parenCount) {
switch (*argPtr) {
case '^':
// Replace the '^' with '*'.
DeclLoc = DeclLoc.getLocWithOffset(argPtr-startArgList);
ReplaceText(DeclLoc, 1, "*");
break;
case '(':
parenCount++;
break;
case ')':
parenCount--;
break;
}
}
return;
}
bool RewriteModernObjC::PointerTypeTakesAnyBlockArguments(QualType QT) {
const FunctionProtoType *FTP;
const PointerType *PT = QT->getAs<PointerType>();
if (PT) {
FTP = PT->getPointeeType()->getAs<FunctionProtoType>();
} else {
const BlockPointerType *BPT = QT->getAs<BlockPointerType>();
assert(BPT && "BlockPointerTypeTakeAnyBlockArguments(): not a block pointer type");
FTP = BPT->getPointeeType()->getAs<FunctionProtoType>();
}
if (FTP) {
for (const auto &I : FTP->param_types())
if (isTopLevelBlockPointerType(I))
return true;
}
return false;
}
bool RewriteModernObjC::PointerTypeTakesAnyObjCQualifiedType(QualType QT) {
const FunctionProtoType *FTP;
const PointerType *PT = QT->getAs<PointerType>();
if (PT) {
FTP = PT->getPointeeType()->getAs<FunctionProtoType>();
} else {
const BlockPointerType *BPT = QT->getAs<BlockPointerType>();
assert(BPT && "BlockPointerTypeTakeAnyBlockArguments(): not a block pointer type");
FTP = BPT->getPointeeType()->getAs<FunctionProtoType>();
}
if (FTP) {
for (const auto &I : FTP->param_types()) {
if (I->isObjCQualifiedIdType())
return true;
if (I->isObjCObjectPointerType() &&
I->getPointeeType()->isObjCQualifiedInterfaceType())
return true;
}
}
return false;
}
void RewriteModernObjC::GetExtentOfArgList(const char *Name, const char *&LParen,
const char *&RParen) {
const char *argPtr = strchr(Name, '(');
assert((*argPtr == '(') && "Rewriter fuzzy parser confused");
LParen = argPtr; // output the start.
argPtr++; // skip past the left paren.
unsigned parenCount = 1;
while (*argPtr && parenCount) {
switch (*argPtr) {
case '(': parenCount++; break;
case ')': parenCount--; break;
default: break;
}
if (parenCount) argPtr++;
}
assert((*argPtr == ')') && "Rewriter fuzzy parser confused");
RParen = argPtr; // output the end
}
void RewriteModernObjC::RewriteBlockPointerDecl(NamedDecl *ND) {
if (FunctionDecl *FD = dyn_cast<FunctionDecl>(ND)) {
RewriteBlockPointerFunctionArgs(FD);
return;
}
// Handle Variables and Typedefs.
SourceLocation DeclLoc = ND->getLocation();
QualType DeclT;
if (VarDecl *VD = dyn_cast<VarDecl>(ND))
DeclT = VD->getType();
else if (TypedefNameDecl *TDD = dyn_cast<TypedefNameDecl>(ND))
DeclT = TDD->getUnderlyingType();
else if (FieldDecl *FD = dyn_cast<FieldDecl>(ND))
DeclT = FD->getType();
else
llvm_unreachable("RewriteBlockPointerDecl(): Decl type not yet handled");
const char *startBuf = SM->getCharacterData(DeclLoc);
const char *endBuf = startBuf;
// scan backward (from the decl location) for the end of the previous decl.
while (*startBuf != '^' && *startBuf != ';' && startBuf != MainFileStart)
startBuf--;
SourceLocation Start = DeclLoc.getLocWithOffset(startBuf-endBuf);
std::string buf;
unsigned OrigLength=0;
// *startBuf != '^' if we are dealing with a pointer to function that
// may take block argument types (which will be handled below).
if (*startBuf == '^') {
// Replace the '^' with '*', computing a negative offset.
buf = '*';
startBuf++;
OrigLength++;
}
while (*startBuf != ')') {
buf += *startBuf;
startBuf++;
OrigLength++;
}
buf += ')';
OrigLength++;
if (PointerTypeTakesAnyBlockArguments(DeclT) ||
PointerTypeTakesAnyObjCQualifiedType(DeclT)) {
// Replace the '^' with '*' for arguments.
// Replace id<P> with id/*<>*/
DeclLoc = ND->getLocation();
startBuf = SM->getCharacterData(DeclLoc);
const char *argListBegin, *argListEnd;
GetExtentOfArgList(startBuf, argListBegin, argListEnd);
while (argListBegin < argListEnd) {
if (*argListBegin == '^')
buf += '*';
else if (*argListBegin == '<') {
buf += "/*";
buf += *argListBegin++;
OrigLength++;
while (*argListBegin != '>') {
buf += *argListBegin++;
OrigLength++;
}
buf += *argListBegin;
buf += "*/";
}
else
buf += *argListBegin;
argListBegin++;
OrigLength++;
}
buf += ')';
OrigLength++;
}
ReplaceText(Start, OrigLength, buf);
return;
}
/// SynthesizeByrefCopyDestroyHelper - This routine synthesizes:
/// void __Block_byref_id_object_copy(struct Block_byref_id_object *dst,
/// struct Block_byref_id_object *src) {
/// _Block_object_assign (&_dest->object, _src->object,
/// BLOCK_BYREF_CALLER | BLOCK_FIELD_IS_OBJECT
/// [|BLOCK_FIELD_IS_WEAK]) // object
/// _Block_object_assign(&_dest->object, _src->object,
/// BLOCK_BYREF_CALLER | BLOCK_FIELD_IS_BLOCK
/// [|BLOCK_FIELD_IS_WEAK]) // block
/// }
/// And:
/// void __Block_byref_id_object_dispose(struct Block_byref_id_object *_src) {
/// _Block_object_dispose(_src->object,
/// BLOCK_BYREF_CALLER | BLOCK_FIELD_IS_OBJECT
/// [|BLOCK_FIELD_IS_WEAK]) // object
/// _Block_object_dispose(_src->object,
/// BLOCK_BYREF_CALLER | BLOCK_FIELD_IS_BLOCK
/// [|BLOCK_FIELD_IS_WEAK]) // block
/// }
std::string RewriteModernObjC::SynthesizeByrefCopyDestroyHelper(VarDecl *VD,
int flag) {
std::string S;
if (CopyDestroyCache.count(flag))
return S;
CopyDestroyCache.insert(flag);
S = "static void __Block_byref_id_object_copy_";
S += utostr(flag);
S += "(void *dst, void *src) {\n";
// offset into the object pointer is computed as:
// void * + void* + int + int + void* + void *
unsigned IntSize =
static_cast<unsigned>(Context->getTypeSize(Context->IntTy));
unsigned VoidPtrSize =
static_cast<unsigned>(Context->getTypeSize(Context->VoidPtrTy));
unsigned offset = (VoidPtrSize*4 + IntSize + IntSize)/Context->getCharWidth();
S += " _Block_object_assign((char*)dst + ";
S += utostr(offset);
S += ", *(void * *) ((char*)src + ";
S += utostr(offset);
S += "), ";
S += utostr(flag);
S += ");\n}\n";
S += "static void __Block_byref_id_object_dispose_";
S += utostr(flag);
S += "(void *src) {\n";
S += " _Block_object_dispose(*(void * *) ((char*)src + ";
S += utostr(offset);
S += "), ";
S += utostr(flag);
S += ");\n}\n";
return S;
}
/// RewriteByRefVar - For each __block typex ND variable this routine transforms
/// the declaration into:
/// struct __Block_byref_ND {
/// void *__isa; // NULL for everything except __weak pointers
/// struct __Block_byref_ND *__forwarding;
/// int32_t __flags;
/// int32_t __size;
/// void *__Block_byref_id_object_copy; // If variable is __block ObjC object
/// void *__Block_byref_id_object_dispose; // If variable is __block ObjC object
/// typex ND;
/// };
///
/// It then replaces declaration of ND variable with:
/// struct __Block_byref_ND ND = {__isa=0B, __forwarding=&ND, __flags=some_flag,
/// __size=sizeof(struct __Block_byref_ND),
/// ND=initializer-if-any};
///
///
void RewriteModernObjC::RewriteByRefVar(VarDecl *ND, bool firstDecl,
bool lastDecl) {
int flag = 0;
int isa = 0;
SourceLocation DeclLoc = ND->getTypeSpecStartLoc();
if (DeclLoc.isInvalid())
// If type location is missing, it is because of missing type (a warning).
// Use variable's location which is good for this case.
DeclLoc = ND->getLocation();
const char *startBuf = SM->getCharacterData(DeclLoc);
SourceLocation X = ND->getLocEnd();
X = SM->getExpansionLoc(X);
const char *endBuf = SM->getCharacterData(X);
std::string Name(ND->getNameAsString());
std::string ByrefType;
RewriteByRefString(ByrefType, Name, ND, true);
ByrefType += " {\n";
ByrefType += " void *__isa;\n";
RewriteByRefString(ByrefType, Name, ND);
ByrefType += " *__forwarding;\n";
ByrefType += " int __flags;\n";
ByrefType += " int __size;\n";
// Add void *__Block_byref_id_object_copy;
// void *__Block_byref_id_object_dispose; if needed.
QualType Ty = ND->getType();
bool HasCopyAndDispose = Context->BlockRequiresCopying(Ty, ND);
if (HasCopyAndDispose) {
ByrefType += " void (*__Block_byref_id_object_copy)(void*, void*);\n";
ByrefType += " void (*__Block_byref_id_object_dispose)(void*);\n";
}
QualType T = Ty;
(void)convertBlockPointerToFunctionPointer(T);
T.getAsStringInternal(Name, Context->getPrintingPolicy());
ByrefType += " " + Name + ";\n";
ByrefType += "};\n";
// Insert this type in global scope. It is needed by helper function.
SourceLocation FunLocStart;
if (CurFunctionDef)
FunLocStart = getFunctionSourceLocation(*this, CurFunctionDef);
else {
assert(CurMethodDef && "RewriteByRefVar - CurMethodDef is null");
FunLocStart = CurMethodDef->getLocStart();
}
InsertText(FunLocStart, ByrefType);
if (Ty.isObjCGCWeak()) {
flag |= BLOCK_FIELD_IS_WEAK;
isa = 1;
}
if (HasCopyAndDispose) {
flag = BLOCK_BYREF_CALLER;
QualType Ty = ND->getType();
// FIXME. Handle __weak variable (BLOCK_FIELD_IS_WEAK) as well.
if (Ty->isBlockPointerType())
flag |= BLOCK_FIELD_IS_BLOCK;
else
flag |= BLOCK_FIELD_IS_OBJECT;
std::string HF = SynthesizeByrefCopyDestroyHelper(ND, flag);
if (!HF.empty())
Preamble += HF;
}
// struct __Block_byref_ND ND =
// {0, &ND, some_flag, __size=sizeof(struct __Block_byref_ND),
// initializer-if-any};
bool hasInit = (ND->getInit() != nullptr);
// FIXME. rewriter does not support __block c++ objects which
// require construction.
if (hasInit)
if (CXXConstructExpr *CExp = dyn_cast<CXXConstructExpr>(ND->getInit())) {
CXXConstructorDecl *CXXDecl = CExp->getConstructor();
if (CXXDecl && CXXDecl->isDefaultConstructor())
hasInit = false;
}
unsigned flags = 0;
if (HasCopyAndDispose)
flags |= BLOCK_HAS_COPY_DISPOSE;
Name = ND->getNameAsString();
ByrefType.clear();
RewriteByRefString(ByrefType, Name, ND);
std::string ForwardingCastType("(");
ForwardingCastType += ByrefType + " *)";
ByrefType += " " + Name + " = {(void*)";
ByrefType += utostr(isa);
ByrefType += "," + ForwardingCastType + "&" + Name + ", ";
ByrefType += utostr(flags);
ByrefType += ", ";
ByrefType += "sizeof(";
RewriteByRefString(ByrefType, Name, ND);
ByrefType += ")";
if (HasCopyAndDispose) {
ByrefType += ", __Block_byref_id_object_copy_";
ByrefType += utostr(flag);
ByrefType += ", __Block_byref_id_object_dispose_";
ByrefType += utostr(flag);
}
if (!firstDecl) {
// In multiple __block declarations, and for all but 1st declaration,
// find location of the separating comma. This would be start location
// where new text is to be inserted.
DeclLoc = ND->getLocation();
const char *startDeclBuf = SM->getCharacterData(DeclLoc);
const char *commaBuf = startDeclBuf;
while (*commaBuf != ',')
commaBuf--;
assert((*commaBuf == ',') && "RewriteByRefVar: can't find ','");
DeclLoc = DeclLoc.getLocWithOffset(commaBuf - startDeclBuf);
startBuf = commaBuf;
}
if (!hasInit) {
ByrefType += "};\n";
unsigned nameSize = Name.size();
// for block or function pointer declaration. Name is aleady
// part of the declaration.
if (Ty->isBlockPointerType() || Ty->isFunctionPointerType())
nameSize = 1;
ReplaceText(DeclLoc, endBuf-startBuf+nameSize, ByrefType);
}
else {
ByrefType += ", ";
SourceLocation startLoc;
Expr *E = ND->getInit();
if (const CStyleCastExpr *ECE = dyn_cast<CStyleCastExpr>(E))
startLoc = ECE->getLParenLoc();
else
startLoc = E->getLocStart();
startLoc = SM->getExpansionLoc(startLoc);
endBuf = SM->getCharacterData(startLoc);
ReplaceText(DeclLoc, endBuf-startBuf, ByrefType);
const char separator = lastDecl ? ';' : ',';
const char *startInitializerBuf = SM->getCharacterData(startLoc);
const char *separatorBuf = strchr(startInitializerBuf, separator);
assert((*separatorBuf == separator) &&
"RewriteByRefVar: can't find ';' or ','");
SourceLocation separatorLoc =
startLoc.getLocWithOffset(separatorBuf-startInitializerBuf);
InsertText(separatorLoc, lastDecl ? "}" : "};\n");
}
return;
}
void RewriteModernObjC::CollectBlockDeclRefInfo(BlockExpr *Exp) {
// Add initializers for any closure decl refs.
GetBlockDeclRefExprs(Exp->getBody());
if (BlockDeclRefs.size()) {
// Unique all "by copy" declarations.
for (unsigned i = 0; i < BlockDeclRefs.size(); i++)
if (!BlockDeclRefs[i]->getDecl()->hasAttr<BlocksAttr>()) {
if (!BlockByCopyDeclsPtrSet.count(BlockDeclRefs[i]->getDecl())) {
BlockByCopyDeclsPtrSet.insert(BlockDeclRefs[i]->getDecl());
BlockByCopyDecls.push_back(BlockDeclRefs[i]->getDecl());
}
}
// Unique all "by ref" declarations.
for (unsigned i = 0; i < BlockDeclRefs.size(); i++)
if (BlockDeclRefs[i]->getDecl()->hasAttr<BlocksAttr>()) {
if (!BlockByRefDeclsPtrSet.count(BlockDeclRefs[i]->getDecl())) {
BlockByRefDeclsPtrSet.insert(BlockDeclRefs[i]->getDecl());
BlockByRefDecls.push_back(BlockDeclRefs[i]->getDecl());
}
}
// Find any imported blocks...they will need special attention.
for (unsigned i = 0; i < BlockDeclRefs.size(); i++)
if (BlockDeclRefs[i]->getDecl()->hasAttr<BlocksAttr>() ||
BlockDeclRefs[i]->getType()->isObjCObjectPointerType() ||
BlockDeclRefs[i]->getType()->isBlockPointerType())
ImportedBlockDecls.insert(BlockDeclRefs[i]->getDecl());
}
}
FunctionDecl *RewriteModernObjC::SynthBlockInitFunctionDecl(StringRef name) {
IdentifierInfo *ID = &Context->Idents.get(name);
QualType FType = Context->getFunctionNoProtoType(Context->VoidPtrTy);
return FunctionDecl::Create(*Context, TUDecl, SourceLocation(),
SourceLocation(), ID, FType, nullptr, SC_Extern,
false, false);
}
Stmt *RewriteModernObjC::SynthBlockInitExpr(BlockExpr *Exp,
const SmallVectorImpl<DeclRefExpr *> &InnerBlockDeclRefs) {
const BlockDecl *block = Exp->getBlockDecl();
Blocks.push_back(Exp);
CollectBlockDeclRefInfo(Exp);
// Add inner imported variables now used in current block.
int countOfInnerDecls = 0;
if (!InnerBlockDeclRefs.empty()) {
for (unsigned i = 0; i < InnerBlockDeclRefs.size(); i++) {
DeclRefExpr *Exp = InnerBlockDeclRefs[i];
ValueDecl *VD = Exp->getDecl();
if (!VD->hasAttr<BlocksAttr>() && !BlockByCopyDeclsPtrSet.count(VD)) {
// We need to save the copied-in variables in nested
// blocks because it is needed at the end for some of the API generations.
// See SynthesizeBlockLiterals routine.
InnerDeclRefs.push_back(Exp); countOfInnerDecls++;
BlockDeclRefs.push_back(Exp);
BlockByCopyDeclsPtrSet.insert(VD);
BlockByCopyDecls.push_back(VD);
}
if (VD->hasAttr<BlocksAttr>() && !BlockByRefDeclsPtrSet.count(VD)) {
InnerDeclRefs.push_back(Exp); countOfInnerDecls++;
BlockDeclRefs.push_back(Exp);
BlockByRefDeclsPtrSet.insert(VD);
BlockByRefDecls.push_back(VD);
}
}
// Find any imported blocks...they will need special attention.
for (unsigned i = 0; i < InnerBlockDeclRefs.size(); i++)
if (InnerBlockDeclRefs[i]->getDecl()->hasAttr<BlocksAttr>() ||
InnerBlockDeclRefs[i]->getType()->isObjCObjectPointerType() ||
InnerBlockDeclRefs[i]->getType()->isBlockPointerType())
ImportedBlockDecls.insert(InnerBlockDeclRefs[i]->getDecl());
}
InnerDeclRefsCount.push_back(countOfInnerDecls);
std::string FuncName;
if (CurFunctionDef)
FuncName = CurFunctionDef->getNameAsString();
else if (CurMethodDef)
BuildUniqueMethodName(FuncName, CurMethodDef);
else if (GlobalVarDecl)
FuncName = std::string(GlobalVarDecl->getNameAsString());
bool GlobalBlockExpr =
block->getDeclContext()->getRedeclContext()->isFileContext();
if (GlobalBlockExpr && !GlobalVarDecl) {
Diags.Report(block->getLocation(), GlobalBlockRewriteFailedDiag);
GlobalBlockExpr = false;
}
std::string BlockNumber = utostr(Blocks.size()-1);
std::string Func = "__" + FuncName + "_block_func_" + BlockNumber;
// Get a pointer to the function type so we can cast appropriately.
QualType BFT = convertFunctionTypeOfBlocks(Exp->getFunctionType());
QualType FType = Context->getPointerType(BFT);
FunctionDecl *FD;
Expr *NewRep;
// Simulate a constructor call...
std::string Tag;
if (GlobalBlockExpr)
Tag = "__global_";
else
Tag = "__";
Tag += FuncName + "_block_impl_" + BlockNumber;
FD = SynthBlockInitFunctionDecl(Tag);
DeclRefExpr *DRE = new (Context) DeclRefExpr(FD, false, FType, VK_RValue,
SourceLocation());
SmallVector<Expr*, 4> InitExprs;
// Initialize the block function.
FD = SynthBlockInitFunctionDecl(Func);
DeclRefExpr *Arg = new (Context) DeclRefExpr(FD, false, FD->getType(),
VK_LValue, SourceLocation());
CastExpr *castExpr = NoTypeInfoCStyleCastExpr(Context, Context->VoidPtrTy,
CK_BitCast, Arg);
InitExprs.push_back(castExpr);
// Initialize the block descriptor.
std::string DescData = "__" + FuncName + "_block_desc_" + BlockNumber + "_DATA";
VarDecl *NewVD = VarDecl::Create(*Context, TUDecl,
SourceLocation(), SourceLocation(),
&Context->Idents.get(DescData.c_str()),
Context->VoidPtrTy, nullptr,
SC_Static);
UnaryOperator *DescRefExpr =
new (Context) UnaryOperator(new (Context) DeclRefExpr(NewVD, false,
Context->VoidPtrTy,
VK_LValue,
SourceLocation()),
UO_AddrOf,
Context->getPointerType(Context->VoidPtrTy),
VK_RValue, OK_Ordinary,
SourceLocation());
InitExprs.push_back(DescRefExpr);
// Add initializers for any closure decl refs.
if (BlockDeclRefs.size()) {
Expr *Exp;
// Output all "by copy" declarations.
for (SmallVectorImpl<ValueDecl *>::iterator I = BlockByCopyDecls.begin(),
E = BlockByCopyDecls.end(); I != E; ++I) {
if (isObjCType((*I)->getType())) {
// FIXME: Conform to ABI ([[obj retain] autorelease]).
FD = SynthBlockInitFunctionDecl((*I)->getName());
Exp = new (Context) DeclRefExpr(FD, false, FD->getType(),
VK_LValue, SourceLocation());
if (HasLocalVariableExternalStorage(*I)) {
QualType QT = (*I)->getType();
QT = Context->getPointerType(QT);
Exp = new (Context) UnaryOperator(Exp, UO_AddrOf, QT, VK_RValue,
OK_Ordinary, SourceLocation());
}
} else if (isTopLevelBlockPointerType((*I)->getType())) {
FD = SynthBlockInitFunctionDecl((*I)->getName());
Arg = new (Context) DeclRefExpr(FD, false, FD->getType(),
VK_LValue, SourceLocation());
Exp = NoTypeInfoCStyleCastExpr(Context, Context->VoidPtrTy,
CK_BitCast, Arg);
} else {
FD = SynthBlockInitFunctionDecl((*I)->getName());
Exp = new (Context) DeclRefExpr(FD, false, FD->getType(),
VK_LValue, SourceLocation());
if (HasLocalVariableExternalStorage(*I)) {
QualType QT = (*I)->getType();
QT = Context->getPointerType(QT);
Exp = new (Context) UnaryOperator(Exp, UO_AddrOf, QT, VK_RValue,
OK_Ordinary, SourceLocation());
}
}
InitExprs.push_back(Exp);
}
// Output all "by ref" declarations.
for (SmallVectorImpl<ValueDecl *>::iterator I = BlockByRefDecls.begin(),
E = BlockByRefDecls.end(); I != E; ++I) {
ValueDecl *ND = (*I);
std::string Name(ND->getNameAsString());
std::string RecName;
RewriteByRefString(RecName, Name, ND, true);
IdentifierInfo *II = &Context->Idents.get(RecName.c_str()
+ sizeof("struct"));
RecordDecl *RD = RecordDecl::Create(*Context, TTK_Struct, TUDecl,
SourceLocation(), SourceLocation(),
II);
assert(RD && "SynthBlockInitExpr(): Can't find RecordDecl");
QualType castT = Context->getPointerType(Context->getTagDeclType(RD));
FD = SynthBlockInitFunctionDecl((*I)->getName());
Exp = new (Context) DeclRefExpr(FD, false, FD->getType(), VK_LValue,
SourceLocation());
bool isNestedCapturedVar = false;
if (block)
for (const auto &CI : block->captures()) {
const VarDecl *variable = CI.getVariable();
if (variable == ND && CI.isNested()) {
assert (CI.isByRef() &&
"SynthBlockInitExpr - captured block variable is not byref");
isNestedCapturedVar = true;
break;
}
}
// captured nested byref variable has its address passed. Do not take
// its address again.
if (!isNestedCapturedVar)
Exp = new (Context) UnaryOperator(Exp, UO_AddrOf,
Context->getPointerType(Exp->getType()),
VK_RValue, OK_Ordinary, SourceLocation());
Exp = NoTypeInfoCStyleCastExpr(Context, castT, CK_BitCast, Exp);
InitExprs.push_back(Exp);
}
}
if (ImportedBlockDecls.size()) {
// generate BLOCK_HAS_COPY_DISPOSE(have helper funcs) | BLOCK_HAS_DESCRIPTOR
int flag = (BLOCK_HAS_COPY_DISPOSE | BLOCK_HAS_DESCRIPTOR);
unsigned IntSize =
static_cast<unsigned>(Context->getTypeSize(Context->IntTy));
Expr *FlagExp = IntegerLiteral::Create(*Context, llvm::APInt(IntSize, flag),
Context->IntTy, SourceLocation());
InitExprs.push_back(FlagExp);
}
NewRep = new (Context) CallExpr(*Context, DRE, InitExprs,
FType, VK_LValue, SourceLocation());
if (GlobalBlockExpr) {
assert (!GlobalConstructionExp &&
"SynthBlockInitExpr - GlobalConstructionExp must be null");
GlobalConstructionExp = NewRep;
NewRep = DRE;
}
NewRep = new (Context) UnaryOperator(NewRep, UO_AddrOf,
Context->getPointerType(NewRep->getType()),
VK_RValue, OK_Ordinary, SourceLocation());
NewRep = NoTypeInfoCStyleCastExpr(Context, FType, CK_BitCast,
NewRep);
// Put Paren around the call.
NewRep = new (Context) ParenExpr(SourceLocation(), SourceLocation(),
NewRep);
BlockDeclRefs.clear();
BlockByRefDecls.clear();
BlockByRefDeclsPtrSet.clear();
BlockByCopyDecls.clear();
BlockByCopyDeclsPtrSet.clear();
ImportedBlockDecls.clear();
return NewRep;
}
bool RewriteModernObjC::IsDeclStmtInForeachHeader(DeclStmt *DS) {
if (const ObjCForCollectionStmt * CS =
dyn_cast<ObjCForCollectionStmt>(Stmts.back()))
return CS->getElement() == DS;
return false;
}
//===----------------------------------------------------------------------===//
// Function Body / Expression rewriting
//===----------------------------------------------------------------------===//
Stmt *RewriteModernObjC::RewriteFunctionBodyOrGlobalInitializer(Stmt *S) {
if (isa<SwitchStmt>(S) || isa<WhileStmt>(S) ||
isa<DoStmt>(S) || isa<ForStmt>(S))
Stmts.push_back(S);
else if (isa<ObjCForCollectionStmt>(S)) {
Stmts.push_back(S);
ObjCBcLabelNo.push_back(++BcLabelCount);
}
// Pseudo-object operations and ivar references need special
// treatment because we're going to recursively rewrite them.
if (PseudoObjectExpr *PseudoOp = dyn_cast<PseudoObjectExpr>(S)) {
if (isa<BinaryOperator>(PseudoOp->getSyntacticForm())) {
return RewritePropertyOrImplicitSetter(PseudoOp);
} else {
return RewritePropertyOrImplicitGetter(PseudoOp);
}
} else if (ObjCIvarRefExpr *IvarRefExpr = dyn_cast<ObjCIvarRefExpr>(S)) {
return RewriteObjCIvarRefExpr(IvarRefExpr);
}
else if (isa<OpaqueValueExpr>(S))
S = cast<OpaqueValueExpr>(S)->getSourceExpr();
SourceRange OrigStmtRange = S->getSourceRange();
// Perform a bottom up rewrite of all children.
for (Stmt::child_range CI = S->children(); CI; ++CI)
if (*CI) {
Stmt *childStmt = (*CI);
Stmt *newStmt = RewriteFunctionBodyOrGlobalInitializer(childStmt);
if (newStmt) {
*CI = newStmt;
}
}
if (BlockExpr *BE = dyn_cast<BlockExpr>(S)) {
SmallVector<DeclRefExpr *, 8> InnerBlockDeclRefs;
llvm::SmallPtrSet<const DeclContext *, 8> InnerContexts;
InnerContexts.insert(BE->getBlockDecl());
ImportedLocalExternalDecls.clear();
GetInnerBlockDeclRefExprs(BE->getBody(),
InnerBlockDeclRefs, InnerContexts);
// Rewrite the block body in place.
Stmt *SaveCurrentBody = CurrentBody;
CurrentBody = BE->getBody();
PropParentMap = nullptr;
// block literal on rhs of a property-dot-sytax assignment
// must be replaced by its synthesize ast so getRewrittenText
// works as expected. In this case, what actually ends up on RHS
// is the blockTranscribed which is the helper function for the
// block literal; as in: self.c = ^() {[ace ARR];};
bool saveDisableReplaceStmt = DisableReplaceStmt;
DisableReplaceStmt = false;
RewriteFunctionBodyOrGlobalInitializer(BE->getBody());
DisableReplaceStmt = saveDisableReplaceStmt;
CurrentBody = SaveCurrentBody;
PropParentMap = nullptr;
ImportedLocalExternalDecls.clear();
// Now we snarf the rewritten text and stash it away for later use.
std::string Str = Rewrite.getRewrittenText(BE->getSourceRange());
RewrittenBlockExprs[BE] = Str;
Stmt *blockTranscribed = SynthBlockInitExpr(BE, InnerBlockDeclRefs);
//blockTranscribed->dump();
ReplaceStmt(S, blockTranscribed);
return blockTranscribed;
}
// Handle specific things.
if (ObjCEncodeExpr *AtEncode = dyn_cast<ObjCEncodeExpr>(S))
return RewriteAtEncode(AtEncode);
if (ObjCSelectorExpr *AtSelector = dyn_cast<ObjCSelectorExpr>(S))
return RewriteAtSelector(AtSelector);
if (ObjCStringLiteral *AtString = dyn_cast<ObjCStringLiteral>(S))
return RewriteObjCStringLiteral(AtString);
if (ObjCBoolLiteralExpr *BoolLitExpr = dyn_cast<ObjCBoolLiteralExpr>(S))
return RewriteObjCBoolLiteralExpr(BoolLitExpr);
if (ObjCBoxedExpr *BoxedExpr = dyn_cast<ObjCBoxedExpr>(S))
return RewriteObjCBoxedExpr(BoxedExpr);
if (ObjCArrayLiteral *ArrayLitExpr = dyn_cast<ObjCArrayLiteral>(S))
return RewriteObjCArrayLiteralExpr(ArrayLitExpr);
if (ObjCDictionaryLiteral *DictionaryLitExpr =
dyn_cast<ObjCDictionaryLiteral>(S))
return RewriteObjCDictionaryLiteralExpr(DictionaryLitExpr);
if (ObjCMessageExpr *MessExpr = dyn_cast<ObjCMessageExpr>(S)) {
#if 0
// Before we rewrite it, put the original message expression in a comment.
SourceLocation startLoc = MessExpr->getLocStart();
SourceLocation endLoc = MessExpr->getLocEnd();
const char *startBuf = SM->getCharacterData(startLoc);
const char *endBuf = SM->getCharacterData(endLoc);
std::string messString;
messString += "// ";
messString.append(startBuf, endBuf-startBuf+1);
messString += "\n";
// FIXME: Missing definition of
// InsertText(clang::SourceLocation, char const*, unsigned int).
// InsertText(startLoc, messString.c_str(), messString.size());
// Tried this, but it didn't work either...
// ReplaceText(startLoc, 0, messString.c_str(), messString.size());
#endif
return RewriteMessageExpr(MessExpr);
}
if (ObjCAutoreleasePoolStmt *StmtAutoRelease =
dyn_cast<ObjCAutoreleasePoolStmt>(S)) {
return RewriteObjCAutoreleasePoolStmt(StmtAutoRelease);
}
if (ObjCAtTryStmt *StmtTry = dyn_cast<ObjCAtTryStmt>(S))
return RewriteObjCTryStmt(StmtTry);
if (ObjCAtSynchronizedStmt *StmtTry = dyn_cast<ObjCAtSynchronizedStmt>(S))
return RewriteObjCSynchronizedStmt(StmtTry);
if (ObjCAtThrowStmt *StmtThrow = dyn_cast<ObjCAtThrowStmt>(S))
return RewriteObjCThrowStmt(StmtThrow);
if (ObjCProtocolExpr *ProtocolExp = dyn_cast<ObjCProtocolExpr>(S))
return RewriteObjCProtocolExpr(ProtocolExp);
if (ObjCForCollectionStmt *StmtForCollection =
dyn_cast<ObjCForCollectionStmt>(S))
return RewriteObjCForCollectionStmt(StmtForCollection,
OrigStmtRange.getEnd());
if (BreakStmt *StmtBreakStmt =
dyn_cast<BreakStmt>(S))
return RewriteBreakStmt(StmtBreakStmt);
if (ContinueStmt *StmtContinueStmt =
dyn_cast<ContinueStmt>(S))
return RewriteContinueStmt(StmtContinueStmt);
// Need to check for protocol refs (id <P>, Foo <P> *) in variable decls
// and cast exprs.
if (DeclStmt *DS = dyn_cast<DeclStmt>(S)) {
// FIXME: What we're doing here is modifying the type-specifier that
// precedes the first Decl. In the future the DeclGroup should have
// a separate type-specifier that we can rewrite.
// NOTE: We need to avoid rewriting the DeclStmt if it is within
// the context of an ObjCForCollectionStmt. For example:
// NSArray *someArray;
// for (id <FooProtocol> index in someArray) ;
// This is because RewriteObjCForCollectionStmt() does textual rewriting
// and it depends on the original text locations/positions.
if (Stmts.empty() || !IsDeclStmtInForeachHeader(DS))
RewriteObjCQualifiedInterfaceTypes(*DS->decl_begin());
// Blocks rewrite rules.
for (DeclStmt::decl_iterator DI = DS->decl_begin(), DE = DS->decl_end();
DI != DE; ++DI) {
Decl *SD = *DI;
if (ValueDecl *ND = dyn_cast<ValueDecl>(SD)) {
if (isTopLevelBlockPointerType(ND->getType()))
RewriteBlockPointerDecl(ND);
else if (ND->getType()->isFunctionPointerType())
CheckFunctionPointerDecl(ND->getType(), ND);
if (VarDecl *VD = dyn_cast<VarDecl>(SD)) {
if (VD->hasAttr<BlocksAttr>()) {
static unsigned uniqueByrefDeclCount = 0;
assert(!BlockByRefDeclNo.count(ND) &&
"RewriteFunctionBodyOrGlobalInitializer: Duplicate byref decl");
BlockByRefDeclNo[ND] = uniqueByrefDeclCount++;
RewriteByRefVar(VD, (DI == DS->decl_begin()), ((DI+1) == DE));
}
else
RewriteTypeOfDecl(VD);
}
}
if (TypedefNameDecl *TD = dyn_cast<TypedefNameDecl>(SD)) {
if (isTopLevelBlockPointerType(TD->getUnderlyingType()))
RewriteBlockPointerDecl(TD);
else if (TD->getUnderlyingType()->isFunctionPointerType())
CheckFunctionPointerDecl(TD->getUnderlyingType(), TD);
}
}
}
if (CStyleCastExpr *CE = dyn_cast<CStyleCastExpr>(S))
RewriteObjCQualifiedInterfaceTypes(CE);
if (isa<SwitchStmt>(S) || isa<WhileStmt>(S) ||
isa<DoStmt>(S) || isa<ForStmt>(S)) {
assert(!Stmts.empty() && "Statement stack is empty");
assert ((isa<SwitchStmt>(Stmts.back()) || isa<WhileStmt>(Stmts.back()) ||
isa<DoStmt>(Stmts.back()) || isa<ForStmt>(Stmts.back()))
&& "Statement stack mismatch");
Stmts.pop_back();
}
// Handle blocks rewriting.
if (DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(S)) {
ValueDecl *VD = DRE->getDecl();
if (VD->hasAttr<BlocksAttr>())
return RewriteBlockDeclRefExpr(DRE);
if (HasLocalVariableExternalStorage(VD))
return RewriteLocalVariableExternalStorage(DRE);
}
if (CallExpr *CE = dyn_cast<CallExpr>(S)) {
if (CE->getCallee()->getType()->isBlockPointerType()) {
Stmt *BlockCall = SynthesizeBlockCall(CE, CE->getCallee());
ReplaceStmt(S, BlockCall);
return BlockCall;
}
}
if (CStyleCastExpr *CE = dyn_cast<CStyleCastExpr>(S)) {
RewriteCastExpr(CE);
}
if (ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(S)) {
RewriteImplicitCastObjCExpr(ICE);
}
#if 0
if (ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(S)) {
CastExpr *Replacement = new (Context) CastExpr(ICE->getType(),
ICE->getSubExpr(),
SourceLocation());
// Get the new text.
std::string SStr;
llvm::raw_string_ostream Buf(SStr);
Replacement->printPretty(Buf);
const std::string &Str = Buf.str();
printf("CAST = %s\n", &Str[0]);
InsertText(ICE->getSubExpr()->getLocStart(), &Str[0], Str.size());
delete S;
return Replacement;
}
#endif
// Return this stmt unmodified.
return S;
}
void RewriteModernObjC::RewriteRecordBody(RecordDecl *RD) {
for (auto *FD : RD->fields()) {
if (isTopLevelBlockPointerType(FD->getType()))
RewriteBlockPointerDecl(FD);
if (FD->getType()->isObjCQualifiedIdType() ||
FD->getType()->isObjCQualifiedInterfaceType())
RewriteObjCQualifiedInterfaceTypes(FD);
}
}
/// HandleDeclInMainFile - This is called for each top-level decl defined in the
/// main file of the input.
void RewriteModernObjC::HandleDeclInMainFile(Decl *D) {
switch (D->getKind()) {
case Decl::Function: {
FunctionDecl *FD = cast<FunctionDecl>(D);
if (FD->isOverloadedOperator())
return;
// Since function prototypes don't have ParmDecl's, we check the function
// prototype. This enables us to rewrite function declarations and
// definitions using the same code.
RewriteBlocksInFunctionProtoType(FD->getType(), FD);
if (!FD->isThisDeclarationADefinition())
break;
// FIXME: If this should support Obj-C++, support CXXTryStmt
if (CompoundStmt *Body = dyn_cast_or_null<CompoundStmt>(FD->getBody())) {
CurFunctionDef = FD;
CurrentBody = Body;
Body =
cast_or_null<CompoundStmt>(RewriteFunctionBodyOrGlobalInitializer(Body));
FD->setBody(Body);
CurrentBody = nullptr;
if (PropParentMap) {
delete PropParentMap;
PropParentMap = nullptr;
}
// This synthesizes and inserts the block "impl" struct, invoke function,
// and any copy/dispose helper functions.
InsertBlockLiteralsWithinFunction(FD);
RewriteLineDirective(D);
CurFunctionDef = nullptr;
}
break;
}
case Decl::ObjCMethod: {
ObjCMethodDecl *MD = cast<ObjCMethodDecl>(D);
if (CompoundStmt *Body = MD->getCompoundBody()) {
CurMethodDef = MD;
CurrentBody = Body;
Body =
cast_or_null<CompoundStmt>(RewriteFunctionBodyOrGlobalInitializer(Body));
MD->setBody(Body);
CurrentBody = nullptr;
if (PropParentMap) {
delete PropParentMap;
PropParentMap = nullptr;
}
InsertBlockLiteralsWithinMethod(MD);
RewriteLineDirective(D);
CurMethodDef = nullptr;
}
break;
}
case Decl::ObjCImplementation: {
ObjCImplementationDecl *CI = cast<ObjCImplementationDecl>(D);
ClassImplementation.push_back(CI);
break;
}
case Decl::ObjCCategoryImpl: {
ObjCCategoryImplDecl *CI = cast<ObjCCategoryImplDecl>(D);
CategoryImplementation.push_back(CI);
break;
}
case Decl::Var: {
VarDecl *VD = cast<VarDecl>(D);
RewriteObjCQualifiedInterfaceTypes(VD);
if (isTopLevelBlockPointerType(VD->getType()))
RewriteBlockPointerDecl(VD);
else if (VD->getType()->isFunctionPointerType()) {
CheckFunctionPointerDecl(VD->getType(), VD);
if (VD->getInit()) {
if (CStyleCastExpr *CE = dyn_cast<CStyleCastExpr>(VD->getInit())) {
RewriteCastExpr(CE);
}
}
} else if (VD->getType()->isRecordType()) {
RecordDecl *RD = VD->getType()->getAs<RecordType>()->getDecl();
if (RD->isCompleteDefinition())
RewriteRecordBody(RD);
}
if (VD->getInit()) {
GlobalVarDecl = VD;
CurrentBody = VD->getInit();
RewriteFunctionBodyOrGlobalInitializer(VD->getInit());
CurrentBody = nullptr;
if (PropParentMap) {
delete PropParentMap;
PropParentMap = nullptr;
}
SynthesizeBlockLiterals(VD->getTypeSpecStartLoc(), VD->getName());
GlobalVarDecl = nullptr;
// This is needed for blocks.
if (CStyleCastExpr *CE = dyn_cast<CStyleCastExpr>(VD->getInit())) {
RewriteCastExpr(CE);
}
}
break;
}
case Decl::TypeAlias:
case Decl::Typedef: {
if (TypedefNameDecl *TD = dyn_cast<TypedefNameDecl>(D)) {
if (isTopLevelBlockPointerType(TD->getUnderlyingType()))
RewriteBlockPointerDecl(TD);
else if (TD->getUnderlyingType()->isFunctionPointerType())
CheckFunctionPointerDecl(TD->getUnderlyingType(), TD);
else
RewriteObjCQualifiedInterfaceTypes(TD);
}
break;
}
case Decl::CXXRecord:
case Decl::Record: {
RecordDecl *RD = cast<RecordDecl>(D);
if (RD->isCompleteDefinition())
RewriteRecordBody(RD);
break;
}
default:
break;
}
// Nothing yet.
}
/// Write_ProtocolExprReferencedMetadata - This routine writer out the
/// protocol reference symbols in the for of:
/// struct _protocol_t *PROTOCOL_REF = &PROTOCOL_METADATA.
static void Write_ProtocolExprReferencedMetadata(ASTContext *Context,
ObjCProtocolDecl *PDecl,
std::string &Result) {
// Also output .objc_protorefs$B section and its meta-data.
if (Context->getLangOpts().MicrosoftExt)
Result += "static ";
Result += "struct _protocol_t *";
Result += "_OBJC_PROTOCOL_REFERENCE_$_";
Result += PDecl->getNameAsString();
Result += " = &";
Result += "_OBJC_PROTOCOL_"; Result += PDecl->getNameAsString();
Result += ";\n";
}
void RewriteModernObjC::HandleTranslationUnit(ASTContext &C) {
if (Diags.hasErrorOccurred())
return;
RewriteInclude();
for (unsigned i = 0, e = FunctionDefinitionsSeen.size(); i < e; i++) {
// translation of function bodies were postponed until all class and
// their extensions and implementations are seen. This is because, we
// cannot build grouping structs for bitfields until they are all seen.
FunctionDecl *FDecl = FunctionDefinitionsSeen[i];
HandleTopLevelSingleDecl(FDecl);
}
// Here's a great place to add any extra declarations that may be needed.
// Write out meta data for each @protocol(<expr>).
for (ObjCProtocolDecl *ProtDecl : ProtocolExprDecls) {
RewriteObjCProtocolMetaData(ProtDecl, Preamble);
Write_ProtocolExprReferencedMetadata(Context, ProtDecl, Preamble);
}
InsertText(SM->getLocForStartOfFile(MainFileID), Preamble, false);
if (ClassImplementation.size() || CategoryImplementation.size())
RewriteImplementations();
for (unsigned i = 0, e = ObjCInterfacesSeen.size(); i < e; i++) {
ObjCInterfaceDecl *CDecl = ObjCInterfacesSeen[i];
// Write struct declaration for the class matching its ivar declarations.
// Note that for modern abi, this is postponed until the end of TU
// because class extensions and the implementation might declare their own
// private ivars.
RewriteInterfaceDecl(CDecl);
}
// Get the buffer corresponding to MainFileID. If we haven't changed it, then
// we are done.
if (const RewriteBuffer *RewriteBuf =
Rewrite.getRewriteBufferFor(MainFileID)) {
//printf("Changed:\n");
*OutFile << std::string(RewriteBuf->begin(), RewriteBuf->end());
} else {
llvm::errs() << "No changes\n";
}
if (ClassImplementation.size() || CategoryImplementation.size() ||
ProtocolExprDecls.size()) {
// Rewrite Objective-c meta data*
std::string ResultStr;
RewriteMetaDataIntoBuffer(ResultStr);
// Emit metadata.
*OutFile << ResultStr;
}
// Emit ImageInfo;
{
std::string ResultStr;
WriteImageInfo(ResultStr);
*OutFile << ResultStr;
}
OutFile->flush();
}
void RewriteModernObjC::Initialize(ASTContext &context) {
InitializeCommon(context);
Preamble += "#ifndef __OBJC2__\n";
Preamble += "#define __OBJC2__\n";
Preamble += "#endif\n";
// declaring objc_selector outside the parameter list removes a silly
// scope related warning...
if (IsHeader)
Preamble = "#pragma once\n";
Preamble += "struct objc_selector; struct objc_class;\n";
Preamble += "struct __rw_objc_super { \n\tstruct objc_object *object; ";
Preamble += "\n\tstruct objc_object *superClass; ";
// Add a constructor for creating temporary objects.
Preamble += "\n\t__rw_objc_super(struct objc_object *o, struct objc_object *s) ";
Preamble += ": object(o), superClass(s) {} ";
Preamble += "\n};\n";
if (LangOpts.MicrosoftExt) {
// Define all sections using syntax that makes sense.
// These are currently generated.
Preamble += "\n#pragma section(\".objc_classlist$B\", long, read, write)\n";
Preamble += "#pragma section(\".objc_catlist$B\", long, read, write)\n";
Preamble += "#pragma section(\".objc_imageinfo$B\", long, read, write)\n";
Preamble += "#pragma section(\".objc_nlclslist$B\", long, read, write)\n";
Preamble += "#pragma section(\".objc_nlcatlist$B\", long, read, write)\n";
// These are generated but not necessary for functionality.
Preamble += "#pragma section(\".cat_cls_meth$B\", long, read, write)\n";
Preamble += "#pragma section(\".inst_meth$B\", long, read, write)\n";
Preamble += "#pragma section(\".cls_meth$B\", long, read, write)\n";
Preamble += "#pragma section(\".objc_ivar$B\", long, read, write)\n";
// These need be generated for performance. Currently they are not,
// using API calls instead.
Preamble += "#pragma section(\".objc_selrefs$B\", long, read, write)\n";
Preamble += "#pragma section(\".objc_classrefs$B\", long, read, write)\n";
Preamble += "#pragma section(\".objc_superrefs$B\", long, read, write)\n";
}
Preamble += "#ifndef _REWRITER_typedef_Protocol\n";
Preamble += "typedef struct objc_object Protocol;\n";
Preamble += "#define _REWRITER_typedef_Protocol\n";
Preamble += "#endif\n";
if (LangOpts.MicrosoftExt) {
Preamble += "#define __OBJC_RW_DLLIMPORT extern \"C\" __declspec(dllimport)\n";
Preamble += "#define __OBJC_RW_STATICIMPORT extern \"C\"\n";
}
else
Preamble += "#define __OBJC_RW_DLLIMPORT extern\n";
Preamble += "__OBJC_RW_DLLIMPORT void objc_msgSend(void);\n";
Preamble += "__OBJC_RW_DLLIMPORT void objc_msgSendSuper(void);\n";
Preamble += "__OBJC_RW_DLLIMPORT void objc_msgSend_stret(void);\n";
Preamble += "__OBJC_RW_DLLIMPORT void objc_msgSendSuper_stret(void);\n";
Preamble += "__OBJC_RW_DLLIMPORT void objc_msgSend_fpret(void);\n";
Preamble += "__OBJC_RW_DLLIMPORT struct objc_class *objc_getClass";
Preamble += "(const char *);\n";
Preamble += "__OBJC_RW_DLLIMPORT struct objc_class *class_getSuperclass";
Preamble += "(struct objc_class *);\n";
Preamble += "__OBJC_RW_DLLIMPORT struct objc_class *objc_getMetaClass";
Preamble += "(const char *);\n";
Preamble += "__OBJC_RW_DLLIMPORT void objc_exception_throw( struct objc_object *);\n";
// @synchronized hooks.
Preamble += "__OBJC_RW_DLLIMPORT int objc_sync_enter( struct objc_object *);\n";
Preamble += "__OBJC_RW_DLLIMPORT int objc_sync_exit( struct objc_object *);\n";
Preamble += "__OBJC_RW_DLLIMPORT Protocol *objc_getProtocol(const char *);\n";
Preamble += "#ifdef _WIN64\n";
Preamble += "typedef unsigned long long _WIN_NSUInteger;\n";
Preamble += "#else\n";
Preamble += "typedef unsigned int _WIN_NSUInteger;\n";
Preamble += "#endif\n";
Preamble += "#ifndef __FASTENUMERATIONSTATE\n";
Preamble += "struct __objcFastEnumerationState {\n\t";
Preamble += "unsigned long state;\n\t";
Preamble += "void **itemsPtr;\n\t";
Preamble += "unsigned long *mutationsPtr;\n\t";
Preamble += "unsigned long extra[5];\n};\n";
Preamble += "__OBJC_RW_DLLIMPORT void objc_enumerationMutation(struct objc_object *);\n";
Preamble += "#define __FASTENUMERATIONSTATE\n";
Preamble += "#endif\n";
Preamble += "#ifndef __NSCONSTANTSTRINGIMPL\n";
Preamble += "struct __NSConstantStringImpl {\n";
Preamble += " int *isa;\n";
Preamble += " int flags;\n";
Preamble += " char *str;\n";
Preamble += "#if _WIN64\n";
Preamble += " long long length;\n";
Preamble += "#else\n";
Preamble += " long length;\n";
Preamble += "#endif\n";
Preamble += "};\n";
Preamble += "#ifdef CF_EXPORT_CONSTANT_STRING\n";
Preamble += "extern \"C\" __declspec(dllexport) int __CFConstantStringClassReference[];\n";
Preamble += "#else\n";
Preamble += "__OBJC_RW_DLLIMPORT int __CFConstantStringClassReference[];\n";
Preamble += "#endif\n";
Preamble += "#define __NSCONSTANTSTRINGIMPL\n";
Preamble += "#endif\n";
// Blocks preamble.
Preamble += "#ifndef BLOCK_IMPL\n";
Preamble += "#define BLOCK_IMPL\n";
Preamble += "struct __block_impl {\n";
Preamble += " void *isa;\n";
Preamble += " int Flags;\n";
Preamble += " int Reserved;\n";
Preamble += " void *FuncPtr;\n";
Preamble += "};\n";
Preamble += "// Runtime copy/destroy helper functions (from Block_private.h)\n";
Preamble += "#ifdef __OBJC_EXPORT_BLOCKS\n";
Preamble += "extern \"C\" __declspec(dllexport) "
"void _Block_object_assign(void *, const void *, const int);\n";
Preamble += "extern \"C\" __declspec(dllexport) void _Block_object_dispose(const void *, const int);\n";
Preamble += "extern \"C\" __declspec(dllexport) void *_NSConcreteGlobalBlock[32];\n";
Preamble += "extern \"C\" __declspec(dllexport) void *_NSConcreteStackBlock[32];\n";
Preamble += "#else\n";
Preamble += "__OBJC_RW_DLLIMPORT void _Block_object_assign(void *, const void *, const int);\n";
Preamble += "__OBJC_RW_DLLIMPORT void _Block_object_dispose(const void *, const int);\n";
Preamble += "__OBJC_RW_DLLIMPORT void *_NSConcreteGlobalBlock[32];\n";
Preamble += "__OBJC_RW_DLLIMPORT void *_NSConcreteStackBlock[32];\n";
Preamble += "#endif\n";
Preamble += "#endif\n";
if (LangOpts.MicrosoftExt) {
Preamble += "#undef __OBJC_RW_DLLIMPORT\n";
Preamble += "#undef __OBJC_RW_STATICIMPORT\n";
Preamble += "#ifndef KEEP_ATTRIBUTES\n"; // We use this for clang tests.
Preamble += "#define __attribute__(X)\n";
Preamble += "#endif\n";
Preamble += "#ifndef __weak\n";
Preamble += "#define __weak\n";
Preamble += "#endif\n";
Preamble += "#ifndef __block\n";
Preamble += "#define __block\n";
Preamble += "#endif\n";
}
else {
Preamble += "#define __block\n";
Preamble += "#define __weak\n";
}
// Declarations required for modern objective-c array and dictionary literals.
Preamble += "\n#include <stdarg.h>\n";
Preamble += "struct __NSContainer_literal {\n";
Preamble += " void * *arr;\n";
Preamble += " __NSContainer_literal (unsigned int count, ...) {\n";
Preamble += "\tva_list marker;\n";
Preamble += "\tva_start(marker, count);\n";
Preamble += "\tarr = new void *[count];\n";
Preamble += "\tfor (unsigned i = 0; i < count; i++)\n";
Preamble += "\t arr[i] = va_arg(marker, void *);\n";
Preamble += "\tva_end( marker );\n";
Preamble += " };\n";
Preamble += " ~__NSContainer_literal() {\n";
Preamble += "\tdelete[] arr;\n";
Preamble += " }\n";
Preamble += "};\n";
// Declaration required for implementation of @autoreleasepool statement.
Preamble += "extern \"C\" __declspec(dllimport) void * objc_autoreleasePoolPush(void);\n";
Preamble += "extern \"C\" __declspec(dllimport) void objc_autoreleasePoolPop(void *);\n\n";
Preamble += "struct __AtAutoreleasePool {\n";
Preamble += " __AtAutoreleasePool() {atautoreleasepoolobj = objc_autoreleasePoolPush();}\n";
Preamble += " ~__AtAutoreleasePool() {objc_autoreleasePoolPop(atautoreleasepoolobj);}\n";
Preamble += " void * atautoreleasepoolobj;\n";
Preamble += "};\n";
// NOTE! Windows uses LLP64 for 64bit mode. So, cast pointer to long long
// as this avoids warning in any 64bit/32bit compilation model.
Preamble += "\n#define __OFFSETOFIVAR__(TYPE, MEMBER) ((long long) &((TYPE *)0)->MEMBER)\n";
}
/// RewriteIvarOffsetComputation - This rutine synthesizes computation of
/// ivar offset.
void RewriteModernObjC::RewriteIvarOffsetComputation(ObjCIvarDecl *ivar,
std::string &Result) {
Result += "__OFFSETOFIVAR__(struct ";
Result += ivar->getContainingInterface()->getNameAsString();
if (LangOpts.MicrosoftExt)
Result += "_IMPL";
Result += ", ";
if (ivar->isBitField())
ObjCIvarBitfieldGroupDecl(ivar, Result);
else
Result += ivar->getNameAsString();
Result += ")";
}
/// WriteModernMetadataDeclarations - Writes out metadata declarations for modern ABI.
/// struct _prop_t {
/// const char *name;
/// char *attributes;
/// }
/// struct _prop_list_t {
/// uint32_t entsize; // sizeof(struct _prop_t)
/// uint32_t count_of_properties;
/// struct _prop_t prop_list[count_of_properties];
/// }
/// struct _protocol_t;
/// struct _protocol_list_t {
/// long protocol_count; // Note, this is 32/64 bit
/// struct _protocol_t * protocol_list[protocol_count];
/// }
/// struct _objc_method {
/// SEL _cmd;
/// const char *method_type;
/// char *_imp;
/// }
/// struct _method_list_t {
/// uint32_t entsize; // sizeof(struct _objc_method)
/// uint32_t method_count;
/// struct _objc_method method_list[method_count];
/// }
/// struct _protocol_t {
/// id isa; // NULL
/// const char *protocol_name;
/// const struct _protocol_list_t * protocol_list; // super protocols
/// const struct method_list_t *instance_methods;
/// const struct method_list_t *class_methods;
/// const struct method_list_t *optionalInstanceMethods;
/// const struct method_list_t *optionalClassMethods;
/// const struct _prop_list_t * properties;
/// const uint32_t size; // sizeof(struct _protocol_t)
/// const uint32_t flags; // = 0
/// const char ** extendedMethodTypes;
/// }
/// struct _ivar_t {
/// unsigned long int *offset; // pointer to ivar offset location
/// const char *name;
/// const char *type;
/// uint32_t alignment;
/// uint32_t size;
/// }
/// struct _ivar_list_t {
/// uint32 entsize; // sizeof(struct _ivar_t)
/// uint32 count;
/// struct _ivar_t list[count];
/// }
/// struct _class_ro_t {
/// uint32_t flags;
/// uint32_t instanceStart;
/// uint32_t instanceSize;
/// uint32_t reserved; // only when building for 64bit targets
/// const uint8_t *ivarLayout;
/// const char *name;
/// const struct _method_list_t *baseMethods;
/// const struct _protocol_list_t *baseProtocols;
/// const struct _ivar_list_t *ivars;
/// const uint8_t *weakIvarLayout;
/// const struct _prop_list_t *properties;
/// }
/// struct _class_t {
/// struct _class_t *isa;
/// struct _class_t *superclass;
/// void *cache;
/// IMP *vtable;
/// struct _class_ro_t *ro;
/// }
/// struct _category_t {
/// const char *name;
/// struct _class_t *cls;
/// const struct _method_list_t *instance_methods;
/// const struct _method_list_t *class_methods;
/// const struct _protocol_list_t *protocols;
/// const struct _prop_list_t *properties;
/// }
/// MessageRefTy - LLVM for:
/// struct _message_ref_t {
/// IMP messenger;
/// SEL name;
/// };
/// SuperMessageRefTy - LLVM for:
/// struct _super_message_ref_t {
/// SUPER_IMP messenger;
/// SEL name;
/// };
static void WriteModernMetadataDeclarations(ASTContext *Context, std::string &Result) {
static bool meta_data_declared = false;
if (meta_data_declared)
return;
Result += "\nstruct _prop_t {\n";
Result += "\tconst char *name;\n";
Result += "\tconst char *attributes;\n";
Result += "};\n";
Result += "\nstruct _protocol_t;\n";
Result += "\nstruct _objc_method {\n";
Result += "\tstruct objc_selector * _cmd;\n";
Result += "\tconst char *method_type;\n";
Result += "\tvoid *_imp;\n";
Result += "};\n";
Result += "\nstruct _protocol_t {\n";
Result += "\tvoid * isa; // NULL\n";
Result += "\tconst char *protocol_name;\n";
Result += "\tconst struct _protocol_list_t * protocol_list; // super protocols\n";
Result += "\tconst struct method_list_t *instance_methods;\n";
Result += "\tconst struct method_list_t *class_methods;\n";
Result += "\tconst struct method_list_t *optionalInstanceMethods;\n";
Result += "\tconst struct method_list_t *optionalClassMethods;\n";
Result += "\tconst struct _prop_list_t * properties;\n";
Result += "\tconst unsigned int size; // sizeof(struct _protocol_t)\n";
Result += "\tconst unsigned int flags; // = 0\n";
Result += "\tconst char ** extendedMethodTypes;\n";
Result += "};\n";
Result += "\nstruct _ivar_t {\n";
Result += "\tunsigned long int *offset; // pointer to ivar offset location\n";
Result += "\tconst char *name;\n";
Result += "\tconst char *type;\n";
Result += "\tunsigned int alignment;\n";
Result += "\tunsigned int size;\n";
Result += "};\n";
Result += "\nstruct _class_ro_t {\n";
Result += "\tunsigned int flags;\n";
Result += "\tunsigned int instanceStart;\n";
Result += "\tunsigned int instanceSize;\n";
const llvm::Triple &Triple(Context->getTargetInfo().getTriple());
if (Triple.getArch() == llvm::Triple::x86_64)
Result += "\tunsigned int reserved;\n";
Result += "\tconst unsigned char *ivarLayout;\n";
Result += "\tconst char *name;\n";
Result += "\tconst struct _method_list_t *baseMethods;\n";
Result += "\tconst struct _objc_protocol_list *baseProtocols;\n";
Result += "\tconst struct _ivar_list_t *ivars;\n";
Result += "\tconst unsigned char *weakIvarLayout;\n";
Result += "\tconst struct _prop_list_t *properties;\n";
Result += "};\n";
Result += "\nstruct _class_t {\n";
Result += "\tstruct _class_t *isa;\n";
Result += "\tstruct _class_t *superclass;\n";
Result += "\tvoid *cache;\n";
Result += "\tvoid *vtable;\n";
Result += "\tstruct _class_ro_t *ro;\n";
Result += "};\n";
Result += "\nstruct _category_t {\n";
Result += "\tconst char *name;\n";
Result += "\tstruct _class_t *cls;\n";
Result += "\tconst struct _method_list_t *instance_methods;\n";
Result += "\tconst struct _method_list_t *class_methods;\n";
Result += "\tconst struct _protocol_list_t *protocols;\n";
Result += "\tconst struct _prop_list_t *properties;\n";
Result += "};\n";
Result += "extern \"C\" __declspec(dllimport) struct objc_cache _objc_empty_cache;\n";
Result += "#pragma warning(disable:4273)\n";
meta_data_declared = true;
}
static void Write_protocol_list_t_TypeDecl(std::string &Result,
long super_protocol_count) {
Result += "struct /*_protocol_list_t*/"; Result += " {\n";
Result += "\tlong protocol_count; // Note, this is 32/64 bit\n";
Result += "\tstruct _protocol_t *super_protocols[";
Result += utostr(super_protocol_count); Result += "];\n";
Result += "}";
}
static void Write_method_list_t_TypeDecl(std::string &Result,
unsigned int method_count) {
Result += "struct /*_method_list_t*/"; Result += " {\n";
Result += "\tunsigned int entsize; // sizeof(struct _objc_method)\n";
Result += "\tunsigned int method_count;\n";
Result += "\tstruct _objc_method method_list[";
Result += utostr(method_count); Result += "];\n";
Result += "}";
}
static void Write__prop_list_t_TypeDecl(std::string &Result,
unsigned int property_count) {
Result += "struct /*_prop_list_t*/"; Result += " {\n";
Result += "\tunsigned int entsize; // sizeof(struct _prop_t)\n";
Result += "\tunsigned int count_of_properties;\n";
Result += "\tstruct _prop_t prop_list[";
Result += utostr(property_count); Result += "];\n";
Result += "}";
}
static void Write__ivar_list_t_TypeDecl(std::string &Result,
unsigned int ivar_count) {
Result += "struct /*_ivar_list_t*/"; Result += " {\n";
Result += "\tunsigned int entsize; // sizeof(struct _prop_t)\n";
Result += "\tunsigned int count;\n";
Result += "\tstruct _ivar_t ivar_list[";
Result += utostr(ivar_count); Result += "];\n";
Result += "}";
}
static void Write_protocol_list_initializer(ASTContext *Context, std::string &Result,
ArrayRef<ObjCProtocolDecl *> SuperProtocols,
StringRef VarName,
StringRef ProtocolName) {
if (SuperProtocols.size() > 0) {
Result += "\nstatic ";
Write_protocol_list_t_TypeDecl(Result, SuperProtocols.size());
Result += " "; Result += VarName;
Result += ProtocolName;
Result += " __attribute__ ((used, section (\"__DATA,__objc_const\"))) = {\n";
Result += "\t"; Result += utostr(SuperProtocols.size()); Result += ",\n";
for (unsigned i = 0, e = SuperProtocols.size(); i < e; i++) {
ObjCProtocolDecl *SuperPD = SuperProtocols[i];
Result += "\t&"; Result += "_OBJC_PROTOCOL_";
Result += SuperPD->getNameAsString();
if (i == e-1)
Result += "\n};\n";
else
Result += ",\n";
}
}
}
static void Write_method_list_t_initializer(RewriteModernObjC &RewriteObj,
ASTContext *Context, std::string &Result,
ArrayRef<ObjCMethodDecl *> Methods,
StringRef VarName,
StringRef TopLevelDeclName,
bool MethodImpl) {
if (Methods.size() > 0) {
Result += "\nstatic ";
Write_method_list_t_TypeDecl(Result, Methods.size());
Result += " "; Result += VarName;
Result += TopLevelDeclName;
Result += " __attribute__ ((used, section (\"__DATA,__objc_const\"))) = {\n";
Result += "\t"; Result += "sizeof(_objc_method)"; Result += ",\n";
Result += "\t"; Result += utostr(Methods.size()); Result += ",\n";
for (unsigned i = 0, e = Methods.size(); i < e; i++) {
ObjCMethodDecl *MD = Methods[i];
if (i == 0)
Result += "\t{{(struct objc_selector *)\"";
else
Result += "\t{(struct objc_selector *)\"";
Result += (MD)->getSelector().getAsString(); Result += "\"";
Result += ", ";
std::string MethodTypeString;
Context->getObjCEncodingForMethodDecl(MD, MethodTypeString);
Result += "\""; Result += MethodTypeString; Result += "\"";
Result += ", ";
if (!MethodImpl)
Result += "0";
else {
Result += "(void *)";
Result += RewriteObj.MethodInternalNames[MD];
}
if (i == e-1)
Result += "}}\n";
else
Result += "},\n";
}
Result += "};\n";
}
}
static void Write_prop_list_t_initializer(RewriteModernObjC &RewriteObj,
ASTContext *Context, std::string &Result,
ArrayRef<ObjCPropertyDecl *> Properties,
const Decl *Container,
StringRef VarName,
StringRef ProtocolName) {
if (Properties.size() > 0) {
Result += "\nstatic ";
Write__prop_list_t_TypeDecl(Result, Properties.size());
Result += " "; Result += VarName;
Result += ProtocolName;
Result += " __attribute__ ((used, section (\"__DATA,__objc_const\"))) = {\n";
Result += "\t"; Result += "sizeof(_prop_t)"; Result += ",\n";
Result += "\t"; Result += utostr(Properties.size()); Result += ",\n";
for (unsigned i = 0, e = Properties.size(); i < e; i++) {
ObjCPropertyDecl *PropDecl = Properties[i];
if (i == 0)
Result += "\t{{\"";
else
Result += "\t{\"";
Result += PropDecl->getName(); Result += "\",";
std::string PropertyTypeString, QuotePropertyTypeString;
Context->getObjCEncodingForPropertyDecl(PropDecl, Container, PropertyTypeString);
RewriteObj.QuoteDoublequotes(PropertyTypeString, QuotePropertyTypeString);
Result += "\""; Result += QuotePropertyTypeString; Result += "\"";
if (i == e-1)
Result += "}}\n";
else
Result += "},\n";
}
Result += "};\n";
}
}
// Metadata flags
enum MetaDataDlags {
CLS = 0x0,
CLS_META = 0x1,
CLS_ROOT = 0x2,
OBJC2_CLS_HIDDEN = 0x10,
CLS_EXCEPTION = 0x20,
/// (Obsolete) ARC-specific: this class has a .release_ivars method
CLS_HAS_IVAR_RELEASER = 0x40,
/// class was compiled with -fobjc-arr
CLS_COMPILED_BY_ARC = 0x80 // (1<<7)
};
static void Write__class_ro_t_initializer(ASTContext *Context, std::string &Result,
unsigned int flags,
const std::string &InstanceStart,
const std::string &InstanceSize,
ArrayRef<ObjCMethodDecl *>baseMethods,
ArrayRef<ObjCProtocolDecl *>baseProtocols,
ArrayRef<ObjCIvarDecl *>ivars,
ArrayRef<ObjCPropertyDecl *>Properties,
StringRef VarName,
StringRef ClassName) {
Result += "\nstatic struct _class_ro_t ";
Result += VarName; Result += ClassName;
Result += " __attribute__ ((used, section (\"__DATA,__objc_const\"))) = {\n";
Result += "\t";
Result += llvm::utostr(flags); Result += ", ";
Result += InstanceStart; Result += ", ";
Result += InstanceSize; Result += ", \n";
Result += "\t";
const llvm::Triple &Triple(Context->getTargetInfo().getTriple());
if (Triple.getArch() == llvm::Triple::x86_64)
// uint32_t const reserved; // only when building for 64bit targets
Result += "(unsigned int)0, \n\t";
// const uint8_t * const ivarLayout;
Result += "0, \n\t";
Result += "\""; Result += ClassName; Result += "\",\n\t";
bool metaclass = ((flags & CLS_META) != 0);
if (baseMethods.size() > 0) {
Result += "(const struct _method_list_t *)&";
if (metaclass)
Result += "_OBJC_$_CLASS_METHODS_";
else
Result += "_OBJC_$_INSTANCE_METHODS_";
Result += ClassName;
Result += ",\n\t";
}
else
Result += "0, \n\t";
if (!metaclass && baseProtocols.size() > 0) {
Result += "(const struct _objc_protocol_list *)&";
Result += "_OBJC_CLASS_PROTOCOLS_$_"; Result += ClassName;
Result += ",\n\t";
}
else
Result += "0, \n\t";
if (!metaclass && ivars.size() > 0) {
Result += "(const struct _ivar_list_t *)&";
Result += "_OBJC_$_INSTANCE_VARIABLES_"; Result += ClassName;
Result += ",\n\t";
}
else
Result += "0, \n\t";
// weakIvarLayout
Result += "0, \n\t";
if (!metaclass && Properties.size() > 0) {
Result += "(const struct _prop_list_t *)&";
Result += "_OBJC_$_PROP_LIST_"; Result += ClassName;
Result += ",\n";
}
else
Result += "0, \n";
Result += "};\n";
}
static void Write_class_t(ASTContext *Context, std::string &Result,
StringRef VarName,
const ObjCInterfaceDecl *CDecl, bool metaclass) {
bool rootClass = (!CDecl->getSuperClass());
const ObjCInterfaceDecl *RootClass = CDecl;
if (!rootClass) {
// Find the Root class
RootClass = CDecl->getSuperClass();
while (RootClass->getSuperClass()) {
RootClass = RootClass->getSuperClass();
}
}
if (metaclass && rootClass) {
// Need to handle a case of use of forward declaration.
Result += "\n";
Result += "extern \"C\" ";
if (CDecl->getImplementation())
Result += "__declspec(dllexport) ";
else
Result += "__declspec(dllimport) ";
Result += "struct _class_t OBJC_CLASS_$_";
Result += CDecl->getNameAsString();
Result += ";\n";
}
// Also, for possibility of 'super' metadata class not having been defined yet.
if (!rootClass) {
ObjCInterfaceDecl *SuperClass = CDecl->getSuperClass();
Result += "\n";
Result += "extern \"C\" ";
if (SuperClass->getImplementation())
Result += "__declspec(dllexport) ";
else
Result += "__declspec(dllimport) ";
Result += "struct _class_t ";
Result += VarName;
Result += SuperClass->getNameAsString();
Result += ";\n";
if (metaclass && RootClass != SuperClass) {
Result += "extern \"C\" ";
if (RootClass->getImplementation())
Result += "__declspec(dllexport) ";
else
Result += "__declspec(dllimport) ";
Result += "struct _class_t ";
Result += VarName;
Result += RootClass->getNameAsString();
Result += ";\n";
}
}
Result += "\nextern \"C\" __declspec(dllexport) struct _class_t ";
Result += VarName; Result += CDecl->getNameAsString();
Result += " __attribute__ ((used, section (\"__DATA,__objc_data\"))) = {\n";
Result += "\t";
if (metaclass) {
if (!rootClass) {
Result += "0, // &"; Result += VarName;
Result += RootClass->getNameAsString();
Result += ",\n\t";
Result += "0, // &"; Result += VarName;
Result += CDecl->getSuperClass()->getNameAsString();
Result += ",\n\t";
}
else {
Result += "0, // &"; Result += VarName;
Result += CDecl->getNameAsString();
Result += ",\n\t";
Result += "0, // &OBJC_CLASS_$_"; Result += CDecl->getNameAsString();
Result += ",\n\t";
}
}
else {
Result += "0, // &OBJC_METACLASS_$_";
Result += CDecl->getNameAsString();
Result += ",\n\t";
if (!rootClass) {
Result += "0, // &"; Result += VarName;
Result += CDecl->getSuperClass()->getNameAsString();
Result += ",\n\t";
}
else
Result += "0,\n\t";
}
Result += "0, // (void *)&_objc_empty_cache,\n\t";
Result += "0, // unused, was (void *)&_objc_empty_vtable,\n\t";
if (metaclass)
Result += "&_OBJC_METACLASS_RO_$_";
else
Result += "&_OBJC_CLASS_RO_$_";
Result += CDecl->getNameAsString();
Result += ",\n};\n";
// Add static function to initialize some of the meta-data fields.
// avoid doing it twice.
if (metaclass)
return;
const ObjCInterfaceDecl *SuperClass =
rootClass ? CDecl : CDecl->getSuperClass();
Result += "static void OBJC_CLASS_SETUP_$_";
Result += CDecl->getNameAsString();
Result += "(void ) {\n";
Result += "\tOBJC_METACLASS_$_"; Result += CDecl->getNameAsString();
Result += ".isa = "; Result += "&OBJC_METACLASS_$_";
Result += RootClass->getNameAsString(); Result += ";\n";
Result += "\tOBJC_METACLASS_$_"; Result += CDecl->getNameAsString();
Result += ".superclass = ";
if (rootClass)
Result += "&OBJC_CLASS_$_";
else
Result += "&OBJC_METACLASS_$_";
Result += SuperClass->getNameAsString(); Result += ";\n";
Result += "\tOBJC_METACLASS_$_"; Result += CDecl->getNameAsString();
Result += ".cache = "; Result += "&_objc_empty_cache"; Result += ";\n";
Result += "\tOBJC_CLASS_$_"; Result += CDecl->getNameAsString();
Result += ".isa = "; Result += "&OBJC_METACLASS_$_";
Result += CDecl->getNameAsString(); Result += ";\n";
if (!rootClass) {
Result += "\tOBJC_CLASS_$_"; Result += CDecl->getNameAsString();
Result += ".superclass = "; Result += "&OBJC_CLASS_$_";
Result += SuperClass->getNameAsString(); Result += ";\n";
}
Result += "\tOBJC_CLASS_$_"; Result += CDecl->getNameAsString();
Result += ".cache = "; Result += "&_objc_empty_cache"; Result += ";\n";
Result += "}\n";
}
static void Write_category_t(RewriteModernObjC &RewriteObj, ASTContext *Context,
std::string &Result,
ObjCCategoryDecl *CatDecl,
ObjCInterfaceDecl *ClassDecl,
ArrayRef<ObjCMethodDecl *> InstanceMethods,
ArrayRef<ObjCMethodDecl *> ClassMethods,
ArrayRef<ObjCProtocolDecl *> RefedProtocols,
ArrayRef<ObjCPropertyDecl *> ClassProperties) {
StringRef CatName = CatDecl->getName();
StringRef ClassName = ClassDecl->getName();
// must declare an extern class object in case this class is not implemented
// in this TU.
Result += "\n";
Result += "extern \"C\" ";
if (ClassDecl->getImplementation())
Result += "__declspec(dllexport) ";
else
Result += "__declspec(dllimport) ";
Result += "struct _class_t ";
Result += "OBJC_CLASS_$_"; Result += ClassName;
Result += ";\n";
Result += "\nstatic struct _category_t ";
Result += "_OBJC_$_CATEGORY_";
Result += ClassName; Result += "_$_"; Result += CatName;
Result += " __attribute__ ((used, section (\"__DATA,__objc_const\"))) = \n";
Result += "{\n";
Result += "\t\""; Result += ClassName; Result += "\",\n";
Result += "\t0, // &"; Result += "OBJC_CLASS_$_"; Result += ClassName;
Result += ",\n";
if (InstanceMethods.size() > 0) {
Result += "\t(const struct _method_list_t *)&";
Result += "_OBJC_$_CATEGORY_INSTANCE_METHODS_";
Result += ClassName; Result += "_$_"; Result += CatName;
Result += ",\n";
}
else
Result += "\t0,\n";
if (ClassMethods.size() > 0) {
Result += "\t(const struct _method_list_t *)&";
Result += "_OBJC_$_CATEGORY_CLASS_METHODS_";
Result += ClassName; Result += "_$_"; Result += CatName;
Result += ",\n";
}
else
Result += "\t0,\n";
if (RefedProtocols.size() > 0) {
Result += "\t(const struct _protocol_list_t *)&";
Result += "_OBJC_CATEGORY_PROTOCOLS_$_";
Result += ClassName; Result += "_$_"; Result += CatName;
Result += ",\n";
}
else
Result += "\t0,\n";
if (ClassProperties.size() > 0) {
Result += "\t(const struct _prop_list_t *)&"; Result += "_OBJC_$_PROP_LIST_";
Result += ClassName; Result += "_$_"; Result += CatName;
Result += ",\n";
}
else
Result += "\t0,\n";
Result += "};\n";
// Add static function to initialize the class pointer in the category structure.
Result += "static void OBJC_CATEGORY_SETUP_$_";
Result += ClassDecl->getNameAsString();
Result += "_$_";
Result += CatName;
Result += "(void ) {\n";
Result += "\t_OBJC_$_CATEGORY_";
Result += ClassDecl->getNameAsString();
Result += "_$_";
Result += CatName;
Result += ".cls = "; Result += "&OBJC_CLASS_$_"; Result += ClassName;
Result += ";\n}\n";
}
static void Write__extendedMethodTypes_initializer(RewriteModernObjC &RewriteObj,
ASTContext *Context, std::string &Result,
ArrayRef<ObjCMethodDecl *> Methods,
StringRef VarName,
StringRef ProtocolName) {
if (Methods.size() == 0)
return;
Result += "\nstatic const char *";
Result += VarName; Result += ProtocolName;
Result += " [] __attribute__ ((used, section (\"__DATA,__objc_const\"))) = \n";
Result += "{\n";
for (unsigned i = 0, e = Methods.size(); i < e; i++) {
ObjCMethodDecl *MD = Methods[i];
std::string MethodTypeString, QuoteMethodTypeString;
Context->getObjCEncodingForMethodDecl(MD, MethodTypeString, true);
RewriteObj.QuoteDoublequotes(MethodTypeString, QuoteMethodTypeString);
Result += "\t\""; Result += QuoteMethodTypeString; Result += "\"";
if (i == e-1)
Result += "\n};\n";
else {
Result += ",\n";
}
}
}
static void Write_IvarOffsetVar(RewriteModernObjC &RewriteObj,
ASTContext *Context,
std::string &Result,
ArrayRef<ObjCIvarDecl *> Ivars,
ObjCInterfaceDecl *CDecl) {
// FIXME. visibilty of offset symbols may have to be set; for Darwin
// this is what happens:
/**
if (Ivar->getAccessControl() == ObjCIvarDecl::Private ||
Ivar->getAccessControl() == ObjCIvarDecl::Package ||
Class->getVisibility() == HiddenVisibility)
Visibility shoud be: HiddenVisibility;
else
Visibility shoud be: DefaultVisibility;
*/
Result += "\n";
for (unsigned i =0, e = Ivars.size(); i < e; i++) {
ObjCIvarDecl *IvarDecl = Ivars[i];
if (Context->getLangOpts().MicrosoftExt)
Result += "__declspec(allocate(\".objc_ivar$B\")) ";
if (!Context->getLangOpts().MicrosoftExt ||
IvarDecl->getAccessControl() == ObjCIvarDecl::Private ||
IvarDecl->getAccessControl() == ObjCIvarDecl::Package)
Result += "extern \"C\" unsigned long int ";
else
Result += "extern \"C\" __declspec(dllexport) unsigned long int ";
if (Ivars[i]->isBitField())
RewriteObj.ObjCIvarBitfieldGroupOffset(IvarDecl, Result);
else
WriteInternalIvarName(CDecl, IvarDecl, Result);
Result += " __attribute__ ((used, section (\"__DATA,__objc_ivar\")))";
Result += " = ";
RewriteObj.RewriteIvarOffsetComputation(IvarDecl, Result);
Result += ";\n";
if (Ivars[i]->isBitField()) {
// skip over rest of the ivar bitfields.
SKIP_BITFIELDS(i , e, Ivars);
}
}
}
static void Write__ivar_list_t_initializer(RewriteModernObjC &RewriteObj,
ASTContext *Context, std::string &Result,
ArrayRef<ObjCIvarDecl *> OriginalIvars,
StringRef VarName,
ObjCInterfaceDecl *CDecl) {
if (OriginalIvars.size() > 0) {
Write_IvarOffsetVar(RewriteObj, Context, Result, OriginalIvars, CDecl);
SmallVector<ObjCIvarDecl *, 8> Ivars;
// strip off all but the first ivar bitfield from each group of ivars.
// Such ivars in the ivar list table will be replaced by their grouping struct
// 'ivar'.
for (unsigned i = 0, e = OriginalIvars.size(); i < e; i++) {
if (OriginalIvars[i]->isBitField()) {
Ivars.push_back(OriginalIvars[i]);
// skip over rest of the ivar bitfields.
SKIP_BITFIELDS(i , e, OriginalIvars);
}
else
Ivars.push_back(OriginalIvars[i]);
}
Result += "\nstatic ";
Write__ivar_list_t_TypeDecl(Result, Ivars.size());
Result += " "; Result += VarName;
Result += CDecl->getNameAsString();
Result += " __attribute__ ((used, section (\"__DATA,__objc_const\"))) = {\n";
Result += "\t"; Result += "sizeof(_ivar_t)"; Result += ",\n";
Result += "\t"; Result += utostr(Ivars.size()); Result += ",\n";
for (unsigned i =0, e = Ivars.size(); i < e; i++) {
ObjCIvarDecl *IvarDecl = Ivars[i];
if (i == 0)
Result += "\t{{";
else
Result += "\t {";
Result += "(unsigned long int *)&";
if (Ivars[i]->isBitField())
RewriteObj.ObjCIvarBitfieldGroupOffset(IvarDecl, Result);
else
WriteInternalIvarName(CDecl, IvarDecl, Result);
Result += ", ";
Result += "\"";
if (Ivars[i]->isBitField())
RewriteObj.ObjCIvarBitfieldGroupDecl(Ivars[i], Result);
else
Result += IvarDecl->getName();
Result += "\", ";
QualType IVQT = IvarDecl->getType();
if (IvarDecl->isBitField())
IVQT = RewriteObj.GetGroupRecordTypeForObjCIvarBitfield(IvarDecl);
std::string IvarTypeString, QuoteIvarTypeString;
Context->getObjCEncodingForType(IVQT, IvarTypeString,
IvarDecl);
RewriteObj.QuoteDoublequotes(IvarTypeString, QuoteIvarTypeString);
Result += "\""; Result += QuoteIvarTypeString; Result += "\", ";
// FIXME. this alignment represents the host alignment and need be changed to
// represent the target alignment.
unsigned Align = Context->getTypeAlign(IVQT)/8;
Align = llvm::Log2_32(Align);
Result += llvm::utostr(Align); Result += ", ";
CharUnits Size = Context->getTypeSizeInChars(IVQT);
Result += llvm::utostr(Size.getQuantity());
if (i == e-1)
Result += "}}\n";
else
Result += "},\n";
}
Result += "};\n";
}
}
/// RewriteObjCProtocolMetaData - Rewrite protocols meta-data.
void RewriteModernObjC::RewriteObjCProtocolMetaData(ObjCProtocolDecl *PDecl,
std::string &Result) {
// Do not synthesize the protocol more than once.
if (ObjCSynthesizedProtocols.count(PDecl->getCanonicalDecl()))
return;
WriteModernMetadataDeclarations(Context, Result);
if (ObjCProtocolDecl *Def = PDecl->getDefinition())
PDecl = Def;
// Must write out all protocol definitions in current qualifier list,
// and in their nested qualifiers before writing out current definition.
for (auto *I : PDecl->protocols())
RewriteObjCProtocolMetaData(I, Result);
// Construct method lists.
std::vector<ObjCMethodDecl *> InstanceMethods, ClassMethods;
std::vector<ObjCMethodDecl *> OptInstanceMethods, OptClassMethods;
for (auto *MD : PDecl->instance_methods()) {
if (MD->getImplementationControl() == ObjCMethodDecl::Optional) {
OptInstanceMethods.push_back(MD);
} else {
InstanceMethods.push_back(MD);
}
}
for (auto *MD : PDecl->class_methods()) {
if (MD->getImplementationControl() == ObjCMethodDecl::Optional) {
OptClassMethods.push_back(MD);
} else {
ClassMethods.push_back(MD);
}
}
std::vector<ObjCMethodDecl *> AllMethods;
for (unsigned i = 0, e = InstanceMethods.size(); i < e; i++)
AllMethods.push_back(InstanceMethods[i]);
for (unsigned i = 0, e = ClassMethods.size(); i < e; i++)
AllMethods.push_back(ClassMethods[i]);
for (unsigned i = 0, e = OptInstanceMethods.size(); i < e; i++)
AllMethods.push_back(OptInstanceMethods[i]);
for (unsigned i = 0, e = OptClassMethods.size(); i < e; i++)
AllMethods.push_back(OptClassMethods[i]);
Write__extendedMethodTypes_initializer(*this, Context, Result,
AllMethods,
"_OBJC_PROTOCOL_METHOD_TYPES_",
PDecl->getNameAsString());
// Protocol's super protocol list
SmallVector<ObjCProtocolDecl *, 8> SuperProtocols(PDecl->protocols());
Write_protocol_list_initializer(Context, Result, SuperProtocols,
"_OBJC_PROTOCOL_REFS_",
PDecl->getNameAsString());
Write_method_list_t_initializer(*this, Context, Result, InstanceMethods,
"_OBJC_PROTOCOL_INSTANCE_METHODS_",
PDecl->getNameAsString(), false);
Write_method_list_t_initializer(*this, Context, Result, ClassMethods,
"_OBJC_PROTOCOL_CLASS_METHODS_",
PDecl->getNameAsString(), false);
Write_method_list_t_initializer(*this, Context, Result, OptInstanceMethods,
"_OBJC_PROTOCOL_OPT_INSTANCE_METHODS_",
PDecl->getNameAsString(), false);
Write_method_list_t_initializer(*this, Context, Result, OptClassMethods,
"_OBJC_PROTOCOL_OPT_CLASS_METHODS_",
PDecl->getNameAsString(), false);
// Protocol's property metadata.
SmallVector<ObjCPropertyDecl *, 8> ProtocolProperties(PDecl->properties());
Write_prop_list_t_initializer(*this, Context, Result, ProtocolProperties,
/* Container */nullptr,
"_OBJC_PROTOCOL_PROPERTIES_",
PDecl->getNameAsString());
// Writer out root metadata for current protocol: struct _protocol_t
Result += "\n";
if (LangOpts.MicrosoftExt)
Result += "static ";
Result += "struct _protocol_t _OBJC_PROTOCOL_";
Result += PDecl->getNameAsString();
Result += " __attribute__ ((used, section (\"__DATA,__datacoal_nt,coalesced\"))) = {\n";
Result += "\t0,\n"; // id is; is null
Result += "\t\""; Result += PDecl->getNameAsString(); Result += "\",\n";
if (SuperProtocols.size() > 0) {
Result += "\t(const struct _protocol_list_t *)&"; Result += "_OBJC_PROTOCOL_REFS_";
Result += PDecl->getNameAsString(); Result += ",\n";
}
else
Result += "\t0,\n";
if (InstanceMethods.size() > 0) {
Result += "\t(const struct method_list_t *)&_OBJC_PROTOCOL_INSTANCE_METHODS_";
Result += PDecl->getNameAsString(); Result += ",\n";
}
else
Result += "\t0,\n";
if (ClassMethods.size() > 0) {
Result += "\t(const struct method_list_t *)&_OBJC_PROTOCOL_CLASS_METHODS_";
Result += PDecl->getNameAsString(); Result += ",\n";
}
else
Result += "\t0,\n";
if (OptInstanceMethods.size() > 0) {
Result += "\t(const struct method_list_t *)&_OBJC_PROTOCOL_OPT_INSTANCE_METHODS_";
Result += PDecl->getNameAsString(); Result += ",\n";
}
else
Result += "\t0,\n";
if (OptClassMethods.size() > 0) {
Result += "\t(const struct method_list_t *)&_OBJC_PROTOCOL_OPT_CLASS_METHODS_";
Result += PDecl->getNameAsString(); Result += ",\n";
}
else
Result += "\t0,\n";
if (ProtocolProperties.size() > 0) {
Result += "\t(const struct _prop_list_t *)&_OBJC_PROTOCOL_PROPERTIES_";
Result += PDecl->getNameAsString(); Result += ",\n";
}
else
Result += "\t0,\n";
Result += "\t"; Result += "sizeof(_protocol_t)"; Result += ",\n";
Result += "\t0,\n";
if (AllMethods.size() > 0) {
Result += "\t(const char **)&"; Result += "_OBJC_PROTOCOL_METHOD_TYPES_";
Result += PDecl->getNameAsString();
Result += "\n};\n";
}
else
Result += "\t0\n};\n";
if (LangOpts.MicrosoftExt)
Result += "static ";
Result += "struct _protocol_t *";
Result += "_OBJC_LABEL_PROTOCOL_$_"; Result += PDecl->getNameAsString();
Result += " = &_OBJC_PROTOCOL_"; Result += PDecl->getNameAsString();
Result += ";\n";
// Mark this protocol as having been generated.
if (!ObjCSynthesizedProtocols.insert(PDecl->getCanonicalDecl()).second)
llvm_unreachable("protocol already synthesized");
}
void RewriteModernObjC::RewriteObjCProtocolListMetaData(
const ObjCList<ObjCProtocolDecl> &Protocols,
StringRef prefix, StringRef ClassName,
std::string &Result) {
if (Protocols.empty()) return;
for (unsigned i = 0; i != Protocols.size(); i++)
RewriteObjCProtocolMetaData(Protocols[i], Result);
// Output the top lovel protocol meta-data for the class.
/* struct _objc_protocol_list {
struct _objc_protocol_list *next;
int protocol_count;
struct _objc_protocol *class_protocols[];
}
*/
Result += "\n";
if (LangOpts.MicrosoftExt)
Result += "__declspec(allocate(\".cat_cls_meth$B\")) ";
Result += "static struct {\n";
Result += "\tstruct _objc_protocol_list *next;\n";
Result += "\tint protocol_count;\n";
Result += "\tstruct _objc_protocol *class_protocols[";
Result += utostr(Protocols.size());
Result += "];\n} _OBJC_";
Result += prefix;
Result += "_PROTOCOLS_";
Result += ClassName;
Result += " __attribute__ ((used, section (\"__OBJC, __cat_cls_meth\")))= "
"{\n\t0, ";
Result += utostr(Protocols.size());
Result += "\n";
Result += "\t,{&_OBJC_PROTOCOL_";
Result += Protocols[0]->getNameAsString();
Result += " \n";
for (unsigned i = 1; i != Protocols.size(); i++) {
Result += "\t ,&_OBJC_PROTOCOL_";
Result += Protocols[i]->getNameAsString();
Result += "\n";
}
Result += "\t }\n};\n";
}
/// hasObjCExceptionAttribute - Return true if this class or any super
/// class has the __objc_exception__ attribute.
/// FIXME. Move this to ASTContext.cpp as it is also used for IRGen.
static bool hasObjCExceptionAttribute(ASTContext &Context,
const ObjCInterfaceDecl *OID) {
if (OID->hasAttr<ObjCExceptionAttr>())
return true;
if (const ObjCInterfaceDecl *Super = OID->getSuperClass())
return hasObjCExceptionAttribute(Context, Super);
return false;
}
void RewriteModernObjC::RewriteObjCClassMetaData(ObjCImplementationDecl *IDecl,
std::string &Result) {
ObjCInterfaceDecl *CDecl = IDecl->getClassInterface();
// Explicitly declared @interface's are already synthesized.
if (CDecl->isImplicitInterfaceDecl())
assert(false &&
"Legacy implicit interface rewriting not supported in moder abi");
WriteModernMetadataDeclarations(Context, Result);
SmallVector<ObjCIvarDecl *, 8> IVars;
for (ObjCIvarDecl *IVD = CDecl->all_declared_ivar_begin();
IVD; IVD = IVD->getNextIvar()) {
// Ignore unnamed bit-fields.
if (!IVD->getDeclName())
continue;
IVars.push_back(IVD);
}
Write__ivar_list_t_initializer(*this, Context, Result, IVars,
"_OBJC_$_INSTANCE_VARIABLES_",
CDecl);
// Build _objc_method_list for class's instance methods if needed
SmallVector<ObjCMethodDecl *, 32> InstanceMethods(IDecl->instance_methods());
// If any of our property implementations have associated getters or
// setters, produce metadata for them as well.
for (const auto *Prop : IDecl->property_impls()) {
if (Prop->getPropertyImplementation() == ObjCPropertyImplDecl::Dynamic)
continue;
if (!Prop->getPropertyIvarDecl())
continue;
ObjCPropertyDecl *PD = Prop->getPropertyDecl();
if (!PD)
continue;
if (ObjCMethodDecl *Getter = PD->getGetterMethodDecl())
if (mustSynthesizeSetterGetterMethod(IDecl, PD, true /*getter*/))
InstanceMethods.push_back(Getter);
if (PD->isReadOnly())
continue;
if (ObjCMethodDecl *Setter = PD->getSetterMethodDecl())
if (mustSynthesizeSetterGetterMethod(IDecl, PD, false /*setter*/))
InstanceMethods.push_back(Setter);
}
Write_method_list_t_initializer(*this, Context, Result, InstanceMethods,
"_OBJC_$_INSTANCE_METHODS_",
IDecl->getNameAsString(), true);
SmallVector<ObjCMethodDecl *, 32> ClassMethods(IDecl->class_methods());
Write_method_list_t_initializer(*this, Context, Result, ClassMethods,
"_OBJC_$_CLASS_METHODS_",
IDecl->getNameAsString(), true);
// Protocols referenced in class declaration?
// Protocol's super protocol list
std::vector<ObjCProtocolDecl *> RefedProtocols;
const ObjCList<ObjCProtocolDecl> &Protocols = CDecl->getReferencedProtocols();
for (ObjCList<ObjCProtocolDecl>::iterator I = Protocols.begin(),
E = Protocols.end();
I != E; ++I) {
RefedProtocols.push_back(*I);
// Must write out all protocol definitions in current qualifier list,
// and in their nested qualifiers before writing out current definition.
RewriteObjCProtocolMetaData(*I, Result);
}
Write_protocol_list_initializer(Context, Result,
RefedProtocols,
"_OBJC_CLASS_PROTOCOLS_$_",
IDecl->getNameAsString());
// Protocol's property metadata.
SmallVector<ObjCPropertyDecl *, 8> ClassProperties(CDecl->properties());
Write_prop_list_t_initializer(*this, Context, Result, ClassProperties,
/* Container */IDecl,
"_OBJC_$_PROP_LIST_",
CDecl->getNameAsString());
// Data for initializing _class_ro_t metaclass meta-data
uint32_t flags = CLS_META;
std::string InstanceSize;
std::string InstanceStart;
bool classIsHidden = CDecl->getVisibility() == HiddenVisibility;
if (classIsHidden)
flags |= OBJC2_CLS_HIDDEN;
if (!CDecl->getSuperClass())
// class is root
flags |= CLS_ROOT;
InstanceSize = "sizeof(struct _class_t)";
InstanceStart = InstanceSize;
Write__class_ro_t_initializer(Context, Result, flags,
InstanceStart, InstanceSize,
ClassMethods,
nullptr,
nullptr,
nullptr,
"_OBJC_METACLASS_RO_$_",
CDecl->getNameAsString());
// Data for initializing _class_ro_t meta-data
flags = CLS;
if (classIsHidden)
flags |= OBJC2_CLS_HIDDEN;
if (hasObjCExceptionAttribute(*Context, CDecl))
flags |= CLS_EXCEPTION;
if (!CDecl->getSuperClass())
// class is root
flags |= CLS_ROOT;
InstanceSize.clear();
InstanceStart.clear();
if (!ObjCSynthesizedStructs.count(CDecl)) {
InstanceSize = "0";
InstanceStart = "0";
}
else {
InstanceSize = "sizeof(struct ";
InstanceSize += CDecl->getNameAsString();
InstanceSize += "_IMPL)";
ObjCIvarDecl *IVD = CDecl->all_declared_ivar_begin();
if (IVD) {
RewriteIvarOffsetComputation(IVD, InstanceStart);
}
else
InstanceStart = InstanceSize;
}
Write__class_ro_t_initializer(Context, Result, flags,
InstanceStart, InstanceSize,
InstanceMethods,
RefedProtocols,
IVars,
ClassProperties,
"_OBJC_CLASS_RO_$_",
CDecl->getNameAsString());
Write_class_t(Context, Result,
"OBJC_METACLASS_$_",
CDecl, /*metaclass*/true);
Write_class_t(Context, Result,
"OBJC_CLASS_$_",
CDecl, /*metaclass*/false);
if (ImplementationIsNonLazy(IDecl))
DefinedNonLazyClasses.push_back(CDecl);
}
void RewriteModernObjC::RewriteClassSetupInitHook(std::string &Result) {
int ClsDefCount = ClassImplementation.size();
if (!ClsDefCount)
return;
Result += "#pragma section(\".objc_inithooks$B\", long, read, write)\n";
Result += "__declspec(allocate(\".objc_inithooks$B\")) ";
Result += "static void *OBJC_CLASS_SETUP[] = {\n";
for (int i = 0; i < ClsDefCount; i++) {
ObjCImplementationDecl *IDecl = ClassImplementation[i];
ObjCInterfaceDecl *CDecl = IDecl->getClassInterface();
Result += "\t(void *)&OBJC_CLASS_SETUP_$_";
Result += CDecl->getName(); Result += ",\n";
}
Result += "};\n";
}
void RewriteModernObjC::RewriteMetaDataIntoBuffer(std::string &Result) {
int ClsDefCount = ClassImplementation.size();
int CatDefCount = CategoryImplementation.size();
// For each implemented class, write out all its meta data.
for (int i = 0; i < ClsDefCount; i++)
RewriteObjCClassMetaData(ClassImplementation[i], Result);
RewriteClassSetupInitHook(Result);
// For each implemented category, write out all its meta data.
for (int i = 0; i < CatDefCount; i++)
RewriteObjCCategoryImplDecl(CategoryImplementation[i], Result);
RewriteCategorySetupInitHook(Result);
if (ClsDefCount > 0) {
if (LangOpts.MicrosoftExt)
Result += "__declspec(allocate(\".objc_classlist$B\")) ";
Result += "static struct _class_t *L_OBJC_LABEL_CLASS_$ [";
Result += llvm::utostr(ClsDefCount); Result += "]";
Result +=
" __attribute__((used, section (\"__DATA, __objc_classlist,"
"regular,no_dead_strip\")))= {\n";
for (int i = 0; i < ClsDefCount; i++) {
Result += "\t&OBJC_CLASS_$_";
Result += ClassImplementation[i]->getNameAsString();
Result += ",\n";
}
Result += "};\n";
if (!DefinedNonLazyClasses.empty()) {
if (LangOpts.MicrosoftExt)
Result += "__declspec(allocate(\".objc_nlclslist$B\")) \n";
Result += "static struct _class_t *_OBJC_LABEL_NONLAZY_CLASS_$[] = {\n\t";
for (unsigned i = 0, e = DefinedNonLazyClasses.size(); i < e; i++) {
Result += "\t&OBJC_CLASS_$_"; Result += DefinedNonLazyClasses[i]->getNameAsString();
Result += ",\n";
}
Result += "};\n";
}
}
if (CatDefCount > 0) {
if (LangOpts.MicrosoftExt)
Result += "__declspec(allocate(\".objc_catlist$B\")) ";
Result += "static struct _category_t *L_OBJC_LABEL_CATEGORY_$ [";
Result += llvm::utostr(CatDefCount); Result += "]";
Result +=
" __attribute__((used, section (\"__DATA, __objc_catlist,"
"regular,no_dead_strip\")))= {\n";
for (int i = 0; i < CatDefCount; i++) {
Result += "\t&_OBJC_$_CATEGORY_";
Result +=
CategoryImplementation[i]->getClassInterface()->getNameAsString();
Result += "_$_";
Result += CategoryImplementation[i]->getNameAsString();
Result += ",\n";
}
Result += "};\n";
}
if (!DefinedNonLazyCategories.empty()) {
if (LangOpts.MicrosoftExt)
Result += "__declspec(allocate(\".objc_nlcatlist$B\")) \n";
Result += "static struct _category_t *_OBJC_LABEL_NONLAZY_CATEGORY_$[] = {\n\t";
for (unsigned i = 0, e = DefinedNonLazyCategories.size(); i < e; i++) {
Result += "\t&_OBJC_$_CATEGORY_";
Result +=
DefinedNonLazyCategories[i]->getClassInterface()->getNameAsString();
Result += "_$_";
Result += DefinedNonLazyCategories[i]->getNameAsString();
Result += ",\n";
}
Result += "};\n";
}
}
void RewriteModernObjC::WriteImageInfo(std::string &Result) {
if (LangOpts.MicrosoftExt)
Result += "__declspec(allocate(\".objc_imageinfo$B\")) \n";
Result += "static struct IMAGE_INFO { unsigned version; unsigned flag; } ";
// version 0, ObjCABI is 2
Result += "_OBJC_IMAGE_INFO = { 0, 2 };\n";
}
/// RewriteObjCCategoryImplDecl - Rewrite metadata for each category
/// implementation.
void RewriteModernObjC::RewriteObjCCategoryImplDecl(ObjCCategoryImplDecl *IDecl,
std::string &Result) {
WriteModernMetadataDeclarations(Context, Result);
ObjCInterfaceDecl *ClassDecl = IDecl->getClassInterface();
// Find category declaration for this implementation.
ObjCCategoryDecl *CDecl
= ClassDecl->FindCategoryDeclaration(IDecl->getIdentifier());
std::string FullCategoryName = ClassDecl->getNameAsString();
FullCategoryName += "_$_";
FullCategoryName += CDecl->getNameAsString();
// Build _objc_method_list for class's instance methods if needed
SmallVector<ObjCMethodDecl *, 32> InstanceMethods(IDecl->instance_methods());
// If any of our property implementations have associated getters or
// setters, produce metadata for them as well.
for (const auto *Prop : IDecl->property_impls()) {
if (Prop->getPropertyImplementation() == ObjCPropertyImplDecl::Dynamic)
continue;
if (!Prop->getPropertyIvarDecl())
continue;
ObjCPropertyDecl *PD = Prop->getPropertyDecl();
if (!PD)
continue;
if (ObjCMethodDecl *Getter = PD->getGetterMethodDecl())
InstanceMethods.push_back(Getter);
if (PD->isReadOnly())
continue;
if (ObjCMethodDecl *Setter = PD->getSetterMethodDecl())
InstanceMethods.push_back(Setter);
}
Write_method_list_t_initializer(*this, Context, Result, InstanceMethods,
"_OBJC_$_CATEGORY_INSTANCE_METHODS_",
FullCategoryName, true);
SmallVector<ObjCMethodDecl *, 32> ClassMethods(IDecl->class_methods());
Write_method_list_t_initializer(*this, Context, Result, ClassMethods,
"_OBJC_$_CATEGORY_CLASS_METHODS_",
FullCategoryName, true);
// Protocols referenced in class declaration?
// Protocol's super protocol list
SmallVector<ObjCProtocolDecl *, 8> RefedProtocols(CDecl->protocols());
for (auto *I : CDecl->protocols())
// Must write out all protocol definitions in current qualifier list,
// and in their nested qualifiers before writing out current definition.
RewriteObjCProtocolMetaData(I, Result);
Write_protocol_list_initializer(Context, Result,
RefedProtocols,
"_OBJC_CATEGORY_PROTOCOLS_$_",
FullCategoryName);
// Protocol's property metadata.
SmallVector<ObjCPropertyDecl *, 8> ClassProperties(CDecl->properties());
Write_prop_list_t_initializer(*this, Context, Result, ClassProperties,
/* Container */IDecl,
"_OBJC_$_PROP_LIST_",
FullCategoryName);
Write_category_t(*this, Context, Result,
CDecl,
ClassDecl,
InstanceMethods,
ClassMethods,
RefedProtocols,
ClassProperties);
// Determine if this category is also "non-lazy".
if (ImplementationIsNonLazy(IDecl))
DefinedNonLazyCategories.push_back(CDecl);
}
void RewriteModernObjC::RewriteCategorySetupInitHook(std::string &Result) {
int CatDefCount = CategoryImplementation.size();
if (!CatDefCount)
return;
Result += "#pragma section(\".objc_inithooks$B\", long, read, write)\n";
Result += "__declspec(allocate(\".objc_inithooks$B\")) ";
Result += "static void *OBJC_CATEGORY_SETUP[] = {\n";
for (int i = 0; i < CatDefCount; i++) {
ObjCCategoryImplDecl *IDecl = CategoryImplementation[i];
ObjCCategoryDecl *CatDecl= IDecl->getCategoryDecl();
ObjCInterfaceDecl *ClassDecl = IDecl->getClassInterface();
Result += "\t(void *)&OBJC_CATEGORY_SETUP_$_";
Result += ClassDecl->getName();
Result += "_$_";
Result += CatDecl->getName();
Result += ",\n";
}
Result += "};\n";
}
// RewriteObjCMethodsMetaData - Rewrite methods metadata for instance or
/// class methods.
template<typename MethodIterator>
void RewriteModernObjC::RewriteObjCMethodsMetaData(MethodIterator MethodBegin,
MethodIterator MethodEnd,
bool IsInstanceMethod,
StringRef prefix,
StringRef ClassName,
std::string &Result) {
if (MethodBegin == MethodEnd) return;
if (!objc_impl_method) {
/* struct _objc_method {
SEL _cmd;
char *method_types;
void *_imp;
}
*/
Result += "\nstruct _objc_method {\n";
Result += "\tSEL _cmd;\n";
Result += "\tchar *method_types;\n";
Result += "\tvoid *_imp;\n";
Result += "};\n";
objc_impl_method = true;
}
// Build _objc_method_list for class's methods if needed
/* struct {
struct _objc_method_list *next_method;
int method_count;
struct _objc_method method_list[];
}
*/
unsigned NumMethods = std::distance(MethodBegin, MethodEnd);
Result += "\n";
if (LangOpts.MicrosoftExt) {
if (IsInstanceMethod)
Result += "__declspec(allocate(\".inst_meth$B\")) ";
else
Result += "__declspec(allocate(\".cls_meth$B\")) ";
}
Result += "static struct {\n";
Result += "\tstruct _objc_method_list *next_method;\n";
Result += "\tint method_count;\n";
Result += "\tstruct _objc_method method_list[";
Result += utostr(NumMethods);
Result += "];\n} _OBJC_";
Result += prefix;
Result += IsInstanceMethod ? "INSTANCE" : "CLASS";
Result += "_METHODS_";
Result += ClassName;
Result += " __attribute__ ((used, section (\"__OBJC, __";
Result += IsInstanceMethod ? "inst" : "cls";
Result += "_meth\")))= ";
Result += "{\n\t0, " + utostr(NumMethods) + "\n";
Result += "\t,{{(SEL)\"";
Result += (*MethodBegin)->getSelector().getAsString().c_str();
std::string MethodTypeString;
Context->getObjCEncodingForMethodDecl(*MethodBegin, MethodTypeString);
Result += "\", \"";
Result += MethodTypeString;
Result += "\", (void *)";
Result += MethodInternalNames[*MethodBegin];
Result += "}\n";
for (++MethodBegin; MethodBegin != MethodEnd; ++MethodBegin) {
Result += "\t ,{(SEL)\"";
Result += (*MethodBegin)->getSelector().getAsString().c_str();
std::string MethodTypeString;
Context->getObjCEncodingForMethodDecl(*MethodBegin, MethodTypeString);
Result += "\", \"";
Result += MethodTypeString;
Result += "\", (void *)";
Result += MethodInternalNames[*MethodBegin];
Result += "}\n";
}
Result += "\t }\n};\n";
}
Stmt *RewriteModernObjC::RewriteObjCIvarRefExpr(ObjCIvarRefExpr *IV) {
SourceRange OldRange = IV->getSourceRange();
Expr *BaseExpr = IV->getBase();
// Rewrite the base, but without actually doing replaces.
{
DisableReplaceStmtScope S(*this);
BaseExpr = cast<Expr>(RewriteFunctionBodyOrGlobalInitializer(BaseExpr));
IV->setBase(BaseExpr);
}
ObjCIvarDecl *D = IV->getDecl();
Expr *Replacement = IV;
if (BaseExpr->getType()->isObjCObjectPointerType()) {
const ObjCInterfaceType *iFaceDecl =
dyn_cast<ObjCInterfaceType>(BaseExpr->getType()->getPointeeType());
assert(iFaceDecl && "RewriteObjCIvarRefExpr - iFaceDecl is null");
// lookup which class implements the instance variable.
ObjCInterfaceDecl *clsDeclared = nullptr;
iFaceDecl->getDecl()->lookupInstanceVariable(D->getIdentifier(),
clsDeclared);
assert(clsDeclared && "RewriteObjCIvarRefExpr(): Can't find class");
// Build name of symbol holding ivar offset.
std::string IvarOffsetName;
if (D->isBitField())
ObjCIvarBitfieldGroupOffset(D, IvarOffsetName);
else
WriteInternalIvarName(clsDeclared, D, IvarOffsetName);
ReferencedIvars[clsDeclared].insert(D);
// cast offset to "char *".
CastExpr *castExpr = NoTypeInfoCStyleCastExpr(Context,
Context->getPointerType(Context->CharTy),
CK_BitCast,
BaseExpr);
VarDecl *NewVD = VarDecl::Create(*Context, TUDecl, SourceLocation(),
SourceLocation(), &Context->Idents.get(IvarOffsetName),
Context->UnsignedLongTy, nullptr,
SC_Extern);
DeclRefExpr *DRE = new (Context) DeclRefExpr(NewVD, false,
Context->UnsignedLongTy, VK_LValue,
SourceLocation());
BinaryOperator *addExpr =
new (Context) BinaryOperator(castExpr, DRE, BO_Add,
Context->getPointerType(Context->CharTy),
VK_RValue, OK_Ordinary, SourceLocation(), false);
// Don't forget the parens to enforce the proper binding.
ParenExpr *PE = new (Context) ParenExpr(SourceLocation(),
SourceLocation(),
addExpr);
QualType IvarT = D->getType();
if (D->isBitField())
IvarT = GetGroupRecordTypeForObjCIvarBitfield(D);
if (!isa<TypedefType>(IvarT) && IvarT->isRecordType()) {
RecordDecl *RD = IvarT->getAs<RecordType>()->getDecl();
RD = RD->getDefinition();
if (RD && !RD->getDeclName().getAsIdentifierInfo()) {
// decltype(((Foo_IMPL*)0)->bar) *
ObjCContainerDecl *CDecl =
dyn_cast<ObjCContainerDecl>(D->getDeclContext());
// ivar in class extensions requires special treatment.
if (ObjCCategoryDecl *CatDecl = dyn_cast<ObjCCategoryDecl>(CDecl))
CDecl = CatDecl->getClassInterface();
std::string RecName = CDecl->getName();
RecName += "_IMPL";
RecordDecl *RD = RecordDecl::Create(*Context, TTK_Struct, TUDecl,
SourceLocation(), SourceLocation(),
&Context->Idents.get(RecName.c_str()));
QualType PtrStructIMPL = Context->getPointerType(Context->getTagDeclType(RD));
unsigned UnsignedIntSize =
static_cast<unsigned>(Context->getTypeSize(Context->UnsignedIntTy));
Expr *Zero = IntegerLiteral::Create(*Context,
llvm::APInt(UnsignedIntSize, 0),
Context->UnsignedIntTy, SourceLocation());
Zero = NoTypeInfoCStyleCastExpr(Context, PtrStructIMPL, CK_BitCast, Zero);
ParenExpr *PE = new (Context) ParenExpr(SourceLocation(), SourceLocation(),
Zero);
FieldDecl *FD = FieldDecl::Create(*Context, nullptr, SourceLocation(),
SourceLocation(),
&Context->Idents.get(D->getNameAsString()),
IvarT, nullptr,
/*BitWidth=*/nullptr,
/*Mutable=*/true, ICIS_NoInit);
MemberExpr *ME = new (Context) MemberExpr(PE, true, FD, SourceLocation(),
FD->getType(), VK_LValue,
OK_Ordinary);
IvarT = Context->getDecltypeType(ME, ME->getType());
}
}
convertObjCTypeToCStyleType(IvarT);
QualType castT = Context->getPointerType(IvarT);
castExpr = NoTypeInfoCStyleCastExpr(Context,
castT,
CK_BitCast,
PE);
Expr *Exp = new (Context) UnaryOperator(castExpr, UO_Deref, IvarT,
VK_LValue, OK_Ordinary,
SourceLocation());
PE = new (Context) ParenExpr(OldRange.getBegin(),
OldRange.getEnd(),
Exp);
if (D->isBitField()) {
FieldDecl *FD = FieldDecl::Create(*Context, nullptr, SourceLocation(),
SourceLocation(),
&Context->Idents.get(D->getNameAsString()),
D->getType(), nullptr,
/*BitWidth=*/D->getBitWidth(),
/*Mutable=*/true, ICIS_NoInit);
MemberExpr *ME = new (Context) MemberExpr(PE, /*isArrow*/false, FD, SourceLocation(),
FD->getType(), VK_LValue,
OK_Ordinary);
Replacement = ME;
}
else
Replacement = PE;
}
ReplaceStmtWithRange(IV, Replacement, OldRange);
return Replacement;
}
#endif
|
; A066729: a(n) = Product_{d|n, d<n} d if n is composite, n otherwise.
; 1,2,3,2,5,6,7,8,3,10,11,144,13,14,15,64,17,324,19,400,21,22,23,13824,5,26,27,784,29,27000,31,1024,33,34,35,279936,37,38,39,64000,41,74088,43,1936,2025,46,47,5308416,7,2500,51,2704,53,157464,55,175616,57,58,59,777600000,61,62,3969,32768,65,287496,67,4624,69,343000,71,1934917632,73,74,5625,5776,77,474552,79,40960000,729,82,83,4182119424,85,86,87,681472,89,5904900000,91,8464,93,94,95,8153726976,97,9604,9801,10000000
add $0,1
mov $1,1
mov $2,2
mov $3,$0
mov $4,$0
lpb $3
mov $0,$4
mov $5,$4
mov $6,0
lpb $5
add $6,1
mov $7,$0
div $0,$2
mod $7,$2
cmp $7,0
sub $5,$7
lpe
mov $0,$1
sub $3,1
cmp $6,0
cmp $6,0
mov $7,$2
pow $7,$6
mul $1,$7
add $2,1
mov $7,$0
cmp $7,1
cmp $7,0
sub $3,$7
lpe
mov $0,$1
|
/**************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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 _TOOLS_INETDEF_HXX
#define _TOOLS_INETDEF_HXX
//============================================================================
#if defined WNT
#define TOOLS_INETDEF_OS "Win32"
#elif defined OS2
#define TOOLS_INETDEF_OS "OS/2"
#elif defined UNX
#if defined AIX
#define TOOLS_INETDEF_OS "AIX"
#elif defined HPUX
#define TOOLS_INETDEF_OS "HP/UX"
#elif defined SOLARIS && defined SPARC
#define TOOLS_INETDEF_OS "Solaris Sparc"
#elif defined SOLARIS && defined INTEL
#define TOOLS_INETDEF_OS "Solaris x86"
#elif defined SCO
#define TOOLS_INETDEF_OS "SCO"
#elif defined NETBSD && defined X86
#define TOOLS_INETDEF_OS "NETBSD x86"
#elif defined NETBSD && defined ARM32
#define TOOLS_INETDEF_OS "NETBSD ARM32"
#elif defined NETBSD && defined SPARC
#define TOOLS_INETDEF_OS "NETBSD Sparc"
#elif defined LINUX && defined X86
#define TOOLS_INETDEF_OS "Linux"
#elif defined FREEBSD && defined X86
#define TOOLS_INETDEF_OS "FreeBSD/i386"
#elif defined FREEBSD && defined X86_64
#define TOOLS_INETDEF_OS "FreeBSD/amd64"
#elif defined SINIX
#define TOOLS_INETDEF_OS "SINIX"
#else // AIX, HPUX, SOLARIS, ...
#define TOOLS_INETDEF_OS "Unix"
#endif // AIX, HPUX, SOLARIS, ...
#else // WNT, ...
#define TOOLS_INETDEF_OS "unknown OS"
#endif // WN, ...
#define TOOLS_INETDEF_PRODUCT "StarOffice/5.2"
#define TOOLS_INETDEF_MOZILLA "Mozilla/3.0"
#define INET_PRODUCTNAME TOOLS_INETDEF_PRODUCT " (" TOOLS_INETDEF_OS ")"
#define INET_DEF_CALLERNAME TOOLS_INETDEF_MOZILLA " (compatible; " \
TOOLS_INETDEF_PRODUCT "; " TOOLS_INETDEF_OS ")"
//============================================================================
// The following definitions seem obsolete and might get removed in future.
#define INET_PERS_CERT_HOMEPAGE "http://www.stardivision.de/certs.html"
#define INET_PERS_CERT_HOMEPAGE_INT \
"http://www.stardivision.de/certs/certs##.html"
// the above definitions are only used in svx/source/options/optinet2.cxx
#if defined __RSC
#define INET_UNDEFINED 0
#define INET_NAME_RESOLVE_START 1
#define INET_NAME_RESOLVE_ERROR 2
#define INET_NAME_RESOLVE_SUCCESS 3
#define INET_CONNECT_START 4
#define INET_CONNECT_ERROR 5
#define INET_CONNECT_SUCCESS 6
#define INET_WRITE_START 7
#define INET_WRITE_STATUS 8
#define INET_WRITE_ERROR 9
#define INET_WRITE_SUCCESS 10
#define INET_READ_START 11
#define INET_READ_STATUS 12
#define INET_READ_ERROR 13
#define INET_READ_SUCCESS 14
#define INET_CLOSING_CONNECTION 15
#define INET_CONNECTION_CLOSED 16
#define INET_REQUEST_CANCELED 17
#define INET_CONNECTION_CANCELED 18
#define INET_SESSION_CANCELED 19
#define INET_AUTHENTICATION 20
#define INET_OFFLINE_ERROR 21
#define INET_PROXY_AUTHENTICATION 22
#endif // __RSC
// the above definitions are only used in sfx2/source/doc/doc.src
#endif // _TOOLS_INETDEF_HXX
|
; A334172: Bitwise XNOR of prime(n) and prime(n + 1).
; Submitted by Christian Krause
; 2,1,5,3,9,3,29,27,21,29,5,51,61,59,37,49,57,1,123,113,121,99,117,71,123,125,115,121,99,113,3,245,253,225,253,245,193,251,245,225,249,245,129,251,253,235,243,195,249,243,249,225,245,5,505,501,509,485
add $0,1
mov $5,$0
sub $0,1
seq $0,40 ; The prime numbers.
seq $5,40 ; The prime numbers.
mov $2,$5
seq $2,70939 ; Length of binary representation of n.
mov $4,1
lpb $2
mov $3,$0
div $0,2
add $3,1
add $3,$5
mod $3,2
mul $3,$4
add $1,$3
sub $2,1
mul $4,2
div $5,2
lpe
mov $0,$1
|
;; hello-os
;; TAB=4
ORG 0x7c00 ; メモリの読み込み位置を指定
CYLS EQU 20 ; #define CYLS = 10
;; FAT12フォーマットフロッピーディスク用の記述
JMP entry
DB 0x90
DB "HARIBOTE" ; ブートセクタの名前
DW 512 ; 1セクタの大きさ
DB 1 ; クラスタの大きさ
DW 1 ; FATの開始位置
DB 2 ; FATの個数
DW 224 ; ルートディレクトリ領域の大きさ
DW 2880 ; ドライブの大きさ
DB 0xf0 ; メディアのタイプ
DW 9 ; FAT領域の長さ
DW 18 ; 1トラック中のセクタ数
DW 2 ; ヘッドの数
DD 0 ; パーティションを使用していなければ0
DD 2880 ; ドライブの大きさ
DB 0, 0, 0x29 ; 固定値?
DD 0xffffffff ; ボリュームシリアル番号?
DB "HELLO-OS " ; ディスク名
DB "FAT12 " ; フォーマット名
RESB 18 ; 18バイト空ける
;; プログラム本体
entry:
MOV AX,0 ; 代入処理 AX=0
MOV SS,AX
MOV SP,0x7c00
MOV DS,AX
; ディスクを読む
MOV AX,0x0820
MOV ES,AX
MOV CH,0 ; シリンダ0
MOV DH,0 ; ヘッドセット0
MOV CL,2 ; セクタ2
readloop:
MOV SI,0 ; 失敗数を数えるレジスタ(source index)
retry:
MOV AH,0x02 ; AH=0x02 : ディスク読み込み
MOV AL,1 ; 1セクタ
MOV BX,0
MOV DL,0x00 ; Aドライブ
INT 0x13 ; ディスクBIOSの呼び出し
JNC next ; エラーが起きなければnextへ
ADD SI,1
CMP SI,5 ; SIと5を比較する
JAE error ; SI >= 5ならばerror
MOV AH,0x00
MOV DL,0x00 ; Aドライブ
INT 0x13 ; ドライブのリセット
JMP retry
next:
MOV AX,ES ; アドレスを0x200進める
ADD AX,0x0020
MOV ES,AX ; ADD ES, 0x020の命令がないため2行使っている
ADD CL,1 ; CLに1をたす(セクタを進める)
CMP CL,18 ; CLと18を比較
JBE readloop ; CL <= 18だったらreadloopに飛ぶ(条件ジャンプ)
MOV CL,1 ; 19セクタ目に突入しようとしたらシリンダを進める
ADD DH,1
CMP DH,2
JB readloop ; DH < 2だったらreadloopへ
MOV DH,0
ADD CH,1
CMP CH,CYLS
JB readloop ; CH < CYLSだったらreadloopへ
; ブートセクタの読み込みが終わったのでOS本体を実行する
MOV [0x0ff0], CH ; IPLがどこまで読んだのかをメモ
JMP 0xc200
putloop:
MOV AL,[SI]
ADD SI,1
CMP AL,0
JE fin
MOV AH,0x0e ; 1文字表示ファンクション
MOV BX,15 ; カラーコード
INT 0x10 ; ビデオBIOS呼び出し
JMP putloop
fin:
HLT ; 何かあるまでCPUを停止
JMP fin ; 無限ループ
error:
MOV SI,msg
msg:
DB 0x0a, 0x0a
DB "hello,worlds"
DB 0x0a ; 改行
DB 0
RESB 0x7dfe - 0x7c00 - ($ - $$) ;; 現在から0x1fdまでを0で埋める
; END CODE
DB 0x55, 0xaa
|
@256
D=A
@SP
M=D
@3
D=A
@SP
M=M+1
A=M-1
M=D
@5
D=A
@SP
M=M+1
A=M-1
M=D
@7
D=A
@SP
M=M+1
A=M-1
M=D
@3
D=A
@SP
M=M+1
A=M-1
M=D
@LCL
D=M
@1
D=D+A
@15
M=D
@SP
AM=M-1
D=M
@15
A=M
M=D
@SP
M=M-1
A=M
D=M
@SP
M=M-1
A=M
D=D+M
@SP
A=M
M=D
@SP
M=M+1
|
; Object Mappings Subtype Frame Arttile
dbglistobj Obj_Ring, Map_Ring, 0, 0, make_art_tile($3D2,3,1)
dbglistobj Obj_2PItem, Map_2PItem, 0, 0, make_art_tile($3C6,0,0)
dbglistobj Obj_PathSwap, Map_PathSwap, 9, 1, make_art_tile($3D2,3,0)
dbglistobj Obj_PathSwap, Map_PathSwap, $D, 5, make_art_tile($3D2,3,0)
dbglistobj Obj_Spring, Map_2PSpring, $81, 0, make_art_tile($391,0,0)
dbglistobj Obj_Spring, Map_2PSpring, $90, 3, make_art_tile($3AD,0,0)
dbglistobj Obj_Spring, Map_2PSpring, $A0, 6, make_art_tile($391,0,0)
dbglistobj Obj_Spikes, Map_2PSpikes, 0, 0, make_art_tile($391,0,0)
dbglistobj Obj_2PRetractingSpring, Map_2PSpring, 0, 0, make_art_tile($391,0,0)
dbglistobj Obj_2PRetractingSpring, Map_2PSpring, $10, 3, make_art_tile($3AD,0,0)
dbglistobj Obj_2PRetractingSpring, Map_2PSpring, $20, 6, make_art_tile($391,0,0)
dbglistobj Obj_2PRetractingSpring, Map_2PSpring, $30, 3, make_art_tile($3AD,0,0)
dbglistobj Obj_2PRetractingSpring, Map_2PSpring, $40, 0, make_art_tile($391,0,0)
dbglistobj Obj_2PRetractingSpring, Map_2PSpring, $50, 6, make_art_tile($391,0,0)
dbglistobj Obj_2PRetractingSpring, Map_2PSpring, $E0, 0, make_art_tile($391,0,0)
dbglistobj Obj_2PRetractingSpring, Map_2PSpring, $F0, 6, make_art_tile($391,0,0)
dbglistobj Obj_Button, Map_2PButton, 0, 2, make_art_tile($3AD,0,0)
dbglistobj Obj_HCZCGZFan, Map_CGZFan, 0, 0, make_art_tile($300,3,0)
dbglistobj Obj_CGZBladePlatform, Map_CGZBladePlatform, 0, 0, make_art_tile($300,3,0)
dbglistobj Obj_2PGoalMarker, Map_2PGoalMarker, 0, 0, make_art_tile($6BC,0,0)
|
#include <topological_sort.h>
#include <limits>
#include <set>
#include <stack>
using namespace std;
namespace Graph
{
TopologicalSort::TopologicalSort(const IGraph &rG) :
_marked (rG.vertices(), false),
_reversePost ()
{
for(int v = 0; v < rG.vertices(); ++v)
dfs(rG, v);
}
TopologicalSort::~TopologicalSort()
{}
void TopologicalSort::dfs(const IGraph &rG, int v)
{
_marked[v] = true;
const IGraph::container_t & rAdjList = rG.adjacent(v);
for(IGraph::const_iterator it = rAdjList.begin(); it != rAdjList.end(); ++it)
{
if(!_marked[*it])
dfs(rG, *it);
_reversePost.push(v);
}
}
bool TopologicalSort::hasPathTo(int v)
{
return _marked[v];
}
void TopologicalSort::pathTo(stack<int> &rPath, int v)
{
rPath = _reversePost;
}
}
|
// seed 4
lbi r0, 128 // icount 0
slbi r0, 0 // icount 1
lbi r1, 128 // icount 2
slbi r1, 0 // icount 3
lbi r2, 128 // icount 4
slbi r2, 0 // icount 5
lbi r3, 128 // icount 6
slbi r3, 0 // icount 7
lbi r4, 128 // icount 8
slbi r4, 0 // icount 9
lbi r5, 128 // icount 10
slbi r5, 0 // icount 11
lbi r6, 128 // icount 12
slbi r6, 0 // icount 13
lbi r7, 128 // icount 14
nop // to align meminst icount 15
slbi r7, 0 // icount 16
nop // to align meminst icount 17
st r2, r0, 10 // icount 18
st r2, r0, 0 // icount 19
addi r1, r1, -6 // change base addr // icount 20
nop // to align meminst icount 21
ld r4, r1, -12 // icount 22
nop // to align meminst icount 23
ld r3, r1, -16 // icount 24
ld r2, r0, 10 // icount 25
addi r1, r1, 14 // change base addr // icount 26
nop // to align meminst icount 27
st r2, r1, 8 // icount 28
nop // to align meminst icount 29
ld r6, r1, 0 // icount 30
nop // to align meminst icount 31
ld r3, r1, 0 // icount 32
nop // to align meminst icount 33
ld r5, r1, -6 // icount 34
ld r2, r0, 4 // icount 35
addi r0, r0, 2 // change base addr // icount 36
nop // to align meminst icount 37
st r4, r0, 0 // icount 38
nop // to align meminst icount 39
ld r2, r0, 12 // icount 40
nop // to align meminst icount 41
ld r4, r0, 14 // icount 42
nop // to align meminst icount 43
st r2, r0, 8 // icount 44
nop // to align meminst icount 45
stu r5, r1, 14 // icount 46
nop // to align meminst icount 47
ld r4, r0, 4 // icount 48
nop // to align meminst icount 49
stu r5, r0, -6 // icount 50
nop // to align meminst icount 51
ld r6, r0, 6 // icount 52
nop // to align meminst icount 53
ld r5, r0, 4 // icount 54
nop // to align meminst icount 55
st r3, r1, 4 // icount 56
nop // to align meminst icount 57
ld r4, r1, -2 // icount 58
nop // to align meminst icount 59
ld r2, r1, -2 // icount 60
ld r2, r0, -14 // icount 61
roli r6, r2, 14 // icount 62
nop // to align meminst icount 63
ld r3, r0, 4 // icount 64
nop // to align meminst icount 65
ld r5, r1, 14 // icount 66
nop // to align meminst icount 67
ld r6, r1, -8 // icount 68
nop // to align meminst icount 69
ld r5, r1, 6 // icount 70
nop // to align meminst icount 71
st r2, r0, 14 // icount 72
nop // to align meminst icount 73
ld r6, r0, 4 // icount 74
nop // to align meminst icount 75
ld r5, r1, -6 // icount 76
nop // to align meminst icount 77
ld r4, r1, -4 // icount 78
nop // to align meminst icount 79
stu r5, r0, 0 // icount 80
nop // to align meminst icount 81
ld r2, r1, 0 // icount 82
nop // to align meminst icount 83
ld r2, r0, 10 // icount 84
nop // to align meminst icount 85
st r2, r0, 6 // icount 86
ld r2, r1, 12 // icount 87
addi r1, r1, -2 // change base addr // icount 88
nop // to align meminst icount 89
st r3, r1, -6 // icount 90
nop // to align meminst icount 91
ld r4, r0, -4 // icount 92
nop // to align meminst icount 93
ld r2, r0, 12 // icount 94
nop // to align meminst icount 95
stu r2, r0, -16 // icount 96
nop // to align meminst icount 97
stu r3, r0, -4 // icount 98
nop // to align meminst icount 99
ld r4, r0, 0 // icount 100
nop // to align meminst icount 101
st r4, r0, 2 // icount 102
nop // to align meminst icount 103
stu r3, r1, -10 // icount 104
nop // to align meminst icount 105
st r5, r1, 10 // icount 106
nop // to align meminst icount 107
st r6, r1, 10 // icount 108
nop // to align meminst icount 109
ld r5, r1, -8 // icount 110
nop // to align meminst icount 111
st r6, r0, -6 // icount 112
nop // to align meminst icount 113
st r3, r0, 4 // icount 114
ld r2, r1, -2 // icount 115
addi r1, r1, -2 // change base addr // icount 116
st r3, r1, 0 // icount 117
sll r3, r7, r6 // icount 118
nop // to align meminst icount 119
stu r4, r0, -16 // icount 120
nop // to align meminst icount 121
stu r6, r1, 14 // icount 122
nop // to align meminst icount 123
ld r2, r0, -12 // icount 124
nop // to align meminst icount 125
stu r3, r1, 0 // icount 126
nop // to align meminst icount 127
stu r4, r1, 6 // icount 128
nop // to align meminst icount 129
stu r4, r0, -16 // icount 130
nop // to align meminst icount 131
stu r3, r0, 8 // icount 132
nop // to align meminst icount 133
stu r6, r0, -2 // icount 134
st r3, r1, -4 // icount 135
sle r5, r7, r2 // icount 136
nop // to align meminst icount 137
stu r2, r0, 12 // icount 138
nop // to align meminst icount 139
ld r6, r1, -16 // icount 140
nop // to align meminst icount 141
ld r3, r0, 10 // icount 142
nop // to align meminst icount 143
stu r5, r0, -16 // icount 144
stu r6, r1, -2 // icount 145
seq r3, r5, r0 // icount 146
nop // to align meminst icount 147
st r3, r0, -2 // icount 148
nop // to align meminst icount 149
ld r2, r1, 0 // icount 150
nop // to align meminst icount 151
stu r6, r1, -16 // icount 152
nop // to align meminst icount 153
stu r2, r0, 6 // icount 154
nop // to align meminst icount 155
ld r4, r1, -16 // icount 156
nop // to align meminst icount 157
stu r5, r1, 10 // icount 158
nop // to align meminst icount 159
ld r2, r0, 2 // icount 160
nop // to align meminst icount 161
ld r2, r1, 12 // icount 162
nop // to align meminst icount 163
stu r5, r1, 4 // icount 164
nop // to align meminst icount 165
st r5, r0, -16 // icount 166
nop // to align meminst icount 167
stu r3, r0, 2 // icount 168
nop // to align meminst icount 169
ld r3, r1, 12 // icount 170
nop // to align meminst icount 171
ld r6, r1, -14 // icount 172
nop // to align meminst icount 173
stu r5, r0, -2 // icount 174
nop // to align meminst icount 175
ld r2, r0, 14 // icount 176
nop // to align meminst icount 177
stu r5, r1, -10 // icount 178
nop // to align meminst icount 179
stu r2, r1, 6 // icount 180
nop // to align meminst icount 181
st r5, r0, -6 // icount 182
nop // to align meminst icount 183
stu r5, r0, 4 // icount 184
nop // to align meminst icount 185
st r6, r0, -14 // icount 186
nop // to align meminst icount 187
stu r3, r1, -12 // icount 188
nop // to align meminst icount 189
st r4, r1, 8 // icount 190
nop // to align meminst icount 191
st r3, r1, 14 // icount 192
nop // to align meminst icount 193
ld r4, r0, 12 // icount 194
nop // to align meminst icount 195
ld r2, r0, 8 // icount 196
nop // to align meminst icount 197
st r5, r1, -4 // icount 198
nop // to align meminst icount 199
stu r5, r1, 0 // icount 200
nop // to align meminst icount 201
st r3, r0, 10 // icount 202
nop // to align meminst icount 203
ld r2, r0, -8 // icount 204
nop // to align meminst icount 205
ld r5, r1, 10 // icount 206
nop // to align meminst icount 207
stu r4, r1, 6 // icount 208
nop // to align meminst icount 209
ld r2, r0, -4 // icount 210
nop // to align meminst icount 211
st r5, r1, -4 // icount 212
nop // to align meminst icount 213
stu r6, r0, -6 // icount 214
stu r4, r0, -8 // icount 215
addi r0, r0, 6 // change base addr // icount 216
nop // to align meminst icount 217
stu r5, r1, 4 // icount 218
nop // to align meminst icount 219
ld r2, r1, 10 // icount 220
nop // to align meminst icount 221
ld r6, r0, -10 // icount 222
nop // to align meminst icount 223
stu r6, r0, -16 // icount 224
nop // to align meminst icount 225
stu r2, r0, 0 // icount 226
nop // to align meminst icount 227
ld r5, r0, 0 // icount 228
nop // to align meminst icount 229
stu r2, r1, -2 // icount 230
nop // to align meminst icount 231
ld r5, r1, -10 // icount 232
nop // to align meminst icount 233
ld r6, r1, -14 // icount 234
nop // to align meminst icount 235
ld r5, r1, -4 // icount 236
nop // to align meminst icount 237
ld r3, r1, 8 // icount 238
nop // to align meminst icount 239
st r4, r1, 14 // icount 240
nop // to align meminst icount 241
st r4, r0, 12 // icount 242
nop // to align meminst icount 243
st r2, r0, 0 // icount 244
nop // to align meminst icount 245
st r5, r1, 14 // icount 246
nop // to align meminst icount 247
ld r4, r0, -6 // icount 248
nop // to align meminst icount 249
ld r2, r1, -4 // icount 250
nop // to align meminst icount 251
ld r6, r1, 6 // icount 252
stu r5, r1, -14 // icount 253
andn r5, r6, r5 // icount 254
nop // to align meminst icount 255
stu r4, r0, 8 // icount 256
nop // to align meminst icount 257
stu r2, r0, 12 // icount 258
nop // to align meminst icount 259
stu r3, r1, 0 // icount 260
nop // to align meminst icount 261
ld r3, r0, 0 // icount 262
nop // to align meminst icount 263
stu r5, r0, 4 // icount 264
nop // to align meminst icount 265
st r5, r1, -14 // icount 266
nop // to align meminst icount 267
ld r4, r1, -4 // icount 268
nop // to align meminst icount 269
st r2, r1, -10 // icount 270
nop // to align meminst icount 271
st r5, r1, -4 // icount 272
nop // to align meminst icount 273
ld r5, r1, 14 // icount 274
nop // to align meminst icount 275
ld r5, r0, 14 // icount 276
nop // to align meminst icount 277
st r4, r0, 4 // icount 278
nop // to align meminst icount 279
stu r4, r0, 4 // icount 280
nop // to align meminst icount 281
ld r2, r1, 0 // icount 282
nop // to align meminst icount 283
ld r5, r1, 0 // icount 284
nop // to align meminst icount 285
stu r6, r0, 6 // icount 286
nop // to align meminst icount 287
ld r2, r1, -2 // icount 288
nop // to align meminst icount 289
ld r2, r0, -10 // icount 290
nop // to align meminst icount 291
ld r5, r1, -4 // icount 292
nop // to align meminst icount 293
ld r6, r0, -12 // icount 294
nop // to align meminst icount 295
st r2, r0, 6 // icount 296
nop // to align meminst icount 297
st r3, r0, 10 // icount 298
nop // to align meminst icount 299
ld r6, r1, -14 // icount 300
nop // to align meminst icount 301
ld r3, r1, 2 // icount 302
nop // to align meminst icount 303
ld r3, r1, -6 // icount 304
nop // to align meminst icount 305
st r6, r1, 8 // icount 306
nop // to align meminst icount 307
stu r6, r1, -8 // icount 308
nop // to align meminst icount 309
ld r2, r0, -16 // icount 310
nop // to align meminst icount 311
st r5, r1, -6 // icount 312
nop // to align meminst icount 313
st r3, r1, -8 // icount 314
nop // to align meminst icount 315
st r3, r1, 0 // icount 316
nop // to align meminst icount 317
ld r6, r0, 10 // icount 318
nop // to align meminst icount 319
ld r2, r0, -12 // icount 320
nop // to align meminst icount 321
st r3, r1, 14 // icount 322
nop // to align meminst icount 323
st r6, r0, -16 // icount 324
nop // to align meminst icount 325
stu r3, r1, -10 // icount 326
nop // to align meminst icount 327
ld r6, r1, 14 // icount 328
nop // to align meminst icount 329
st r5, r0, -12 // icount 330
nop // to align meminst icount 331
stu r6, r1, -12 // icount 332
nop // to align meminst icount 333
ld r3, r1, 10 // icount 334
nop // to align meminst icount 335
ld r6, r1, -14 // icount 336
nop // to align meminst icount 337
ld r3, r1, 12 // icount 338
nop // to align meminst icount 339
st r6, r0, -12 // icount 340
nop // to align meminst icount 341
ld r5, r1, 8 // icount 342
nop // to align meminst icount 343
ld r6, r0, -2 // icount 344
stu r3, r0, 14 // icount 345
addi r0, r0, 4 // change base addr // icount 346
nop // to align meminst icount 347
ld r5, r0, 0 // icount 348
nop // to align meminst icount 349
ld r5, r0, 12 // icount 350
nop // to align meminst icount 351
stu r3, r0, 0 // icount 352
nop // to align meminst icount 353
ld r3, r1, 6 // icount 354
nop // to align meminst icount 355
st r4, r0, 14 // icount 356
nop // to align meminst icount 357
ld r3, r1, -6 // icount 358
nop // to align meminst icount 359
st r2, r1, 10 // icount 360
nop // to align meminst icount 361
stu r3, r1, 4 // icount 362
nop // to align meminst icount 363
ld r3, r0, -14 // icount 364
nop // to align meminst icount 365
ld r5, r1, 14 // icount 366
nop // to align meminst icount 367
st r3, r0, -8 // icount 368
nop // to align meminst icount 369
ld r6, r0, 12 // icount 370
nop // to align meminst icount 371
ld r6, r1, -6 // icount 372
nop // to align meminst icount 373
st r4, r0, -8 // icount 374
nop // to align meminst icount 375
stu r6, r1, -6 // icount 376
nop // to align meminst icount 377
ld r2, r1, 0 // icount 378
nop // to align meminst icount 379
ld r6, r1, 12 // icount 380
nop // to align meminst icount 381
ld r6, r0, -14 // icount 382
nop // to align meminst icount 383
ld r4, r0, 12 // icount 384
nop // to align meminst icount 385
ld r4, r1, 10 // icount 386
nop // to align meminst icount 387
ld r3, r0, 0 // icount 388
nop // to align meminst icount 389
ld r4, r1, 14 // icount 390
nop // to align meminst icount 391
st r6, r0, -4 // icount 392
ld r6, r1, -4 // icount 393
addi r0, r0, 6 // change base addr // icount 394
nop // to align meminst icount 395
ld r4, r0, 2 // icount 396
nop // to align meminst icount 397
ld r5, r1, -10 // icount 398
nop // to align meminst icount 399
st r5, r0, 0 // icount 400
nop // to align meminst icount 401
stu r5, r1, 14 // icount 402
nop // to align meminst icount 403
stu r2, r1, -6 // icount 404
nop // to align meminst icount 405
ld r2, r0, -14 // icount 406
nop // to align meminst icount 407
stu r5, r0, 0 // icount 408
nop // to align meminst icount 409
st r6, r1, -2 // icount 410
nop // to align meminst icount 411
stu r4, r1, 6 // icount 412
nop // to align meminst icount 413
ld r2, r0, 6 // icount 414
nop // to align meminst icount 415
stu r4, r1, 12 // icount 416
nop // to align meminst icount 417
st r5, r0, -4 // icount 418
nop // to align meminst icount 419
ld r2, r0, 2 // icount 420
nop // to align meminst icount 421
st r5, r0, -4 // icount 422
nop // to align meminst icount 423
stu r3, r1, -10 // icount 424
stu r3, r1, -6 // icount 425
sub r4, r4, r1 // icount 426
nop // to align meminst icount 427
stu r4, r0, 12 // icount 428
nop // to align meminst icount 429
stu r3, r1, 10 // icount 430
nop // to align meminst icount 431
ld r5, r0, -10 // icount 432
nop // to align meminst icount 433
ld r6, r0, -6 // icount 434
st r3, r0, 12 // icount 435
addi r1, r1, 14 // change base addr // icount 436
nop // to align meminst icount 437
stu r6, r1, 8 // icount 438
nop // to align meminst icount 439
stu r6, r0, -16 // icount 440
nop // to align meminst icount 441
st r6, r1, -8 // icount 442
nop // to align meminst icount 443
ld r5, r1, -8 // icount 444
nop // to align meminst icount 445
ld r2, r0, -14 // icount 446
nop // to align meminst icount 447
st r4, r0, 14 // icount 448
nop // to align meminst icount 449
stu r2, r0, 12 // icount 450
nop // to align meminst icount 451
ld r3, r0, 4 // icount 452
nop // to align meminst icount 453
stu r5, r0, -8 // icount 454
nop // to align meminst icount 455
st r6, r1, 10 // icount 456
nop // to align meminst icount 457
ld r6, r0, -6 // icount 458
nop // to align meminst icount 459
ld r2, r0, 2 // icount 460
nop // to align meminst icount 461
stu r5, r1, 8 // icount 462
nop // to align meminst icount 463
st r6, r1, -10 // icount 464
nop // to align meminst icount 465
ld r2, r1, 10 // icount 466
nop // to align meminst icount 467
stu r4, r0, -16 // icount 468
ld r2, r0, 4 // icount 469
rol r7, r7, r2 // icount 470
nop // to align meminst icount 471
ld r3, r0, -16 // icount 472
st r2, r0, 2 // icount 473
sco r7, r1, r3 // icount 474
nop // to align meminst icount 475
ld r5, r1, 14 // icount 476
ld r2, r1, 0 // icount 477
addi r1, r1, -4 // change base addr // icount 478
stu r2, r1, -14 // icount 479
rol r7, r7, r1 // icount 480
nop // to align meminst icount 481
st r3, r0, -8 // icount 482
st r5, r1, 10 // icount 483
andni r5, r5, 1 // icount 484
nop // to align meminst icount 485
ld r7, r5, 6 // icount 486
nop // to align meminst icount 487
st r2, r0, -8 // icount 488
nop // to align meminst icount 489
ld r6, r0, 4 // icount 490
nop // to align meminst icount 491
stu r3, r0, -14 // icount 492
nop // to align meminst icount 493
ld r5, r1, -4 // icount 494
nop // to align meminst icount 495
st r4, r1, -8 // icount 496
nop // to align meminst icount 497
ld r2, r0, -8 // icount 498
nop // to align meminst icount 499
ld r3, r0, -8 // icount 500
nop // to align meminst icount 501
ld r5, r1, -14 // icount 502
nop // to align meminst icount 503
stu r2, r0, 8 // icount 504
nop // to align meminst icount 505
ld r3, r0, -10 // icount 506
nop // to align meminst icount 507
ld r6, r0, 0 // icount 508
nop // to align meminst icount 509
ld r2, r0, -6 // icount 510
nop // to align meminst icount 511
ld r3, r0, -8 // icount 512
nop // to align meminst icount 513
ld r6, r1, -2 // icount 514
nop // to align meminst icount 515
ld r6, r1, -2 // icount 516
nop // to align meminst icount 517
ld r6, r0, -10 // icount 518
nop // to align meminst icount 519
stu r6, r0, 2 // icount 520
nop // to align meminst icount 521
st r2, r0, -6 // icount 522
nop // to align meminst icount 523
ld r2, r0, -10 // icount 524
nop // to align meminst icount 525
st r6, r1, -16 // icount 526
nop // to align meminst icount 527
ld r5, r1, 2 // icount 528
nop // to align meminst icount 529
ld r5, r0, -6 // icount 530
nop // to align meminst icount 531
ld r6, r1, -6 // icount 532
nop // to align meminst icount 533
stu r2, r1, -12 // icount 534
nop // to align meminst icount 535
stu r4, r0, -6 // icount 536
ld r4, r0, -2 // icount 537
xori r5, r0, 6 // icount 538
nop // to align meminst icount 539
ld r5, r0, 6 // icount 540
nop // to align meminst icount 541
stu r5, r0, -6 // icount 542
nop // to align meminst icount 543
stu r4, r0, 12 // icount 544
nop // to align meminst icount 545
st r4, r0, -10 // icount 546
nop // to align meminst icount 547
st r5, r1, 6 // icount 548
nop // to align meminst icount 549
st r3, r0, -8 // icount 550
nop // to align meminst icount 551
ld r4, r0, 12 // icount 552
nop // to align meminst icount 553
st r5, r1, -8 // icount 554
nop // to align meminst icount 555
ld r2, r0, -6 // icount 556
nop // to align meminst icount 557
st r5, r1, 4 // icount 558
nop // to align meminst icount 559
st r5, r0, -8 // icount 560
nop // to align meminst icount 561
ld r2, r1, 6 // icount 562
nop // to align meminst icount 563
stu r2, r1, -12 // icount 564
nop // to align meminst icount 565
ld r5, r0, -4 // icount 566
nop // to align meminst icount 567
ld r2, r1, -4 // icount 568
nop // to align meminst icount 569
ld r2, r0, -14 // icount 570
nop // to align meminst icount 571
st r6, r0, -14 // icount 572
nop // to align meminst icount 573
ld r2, r1, 4 // icount 574
nop // to align meminst icount 575
st r4, r1, 12 // icount 576
nop // to align meminst icount 577
st r2, r0, 6 // icount 578
nop // to align meminst icount 579
ld r5, r1, -10 // icount 580
st r4, r0, 2 // icount 581
sle r5, r0, r1 // icount 582
nop // to align meminst icount 583
st r6, r1, 12 // icount 584
nop // to align meminst icount 585
stu r5, r0, -12 // icount 586
nop // to align meminst icount 587
st r4, r0, -2 // icount 588
nop // to align meminst icount 589
ld r2, r1, -16 // icount 590
nop // to align meminst icount 591
st r2, r0, 8 // icount 592
ld r6, r1, 12 // icount 593
add r7, r5, r2 // icount 594
nop // to align meminst icount 595
ld r2, r0, -10 // icount 596
nop // to align meminst icount 597
ld r3, r1, 10 // icount 598
nop // to align meminst icount 599
st r6, r1, -12 // icount 600
nop // to align meminst icount 601
ld r3, r1, -10 // icount 602
stu r2, r1, -12 // icount 603
subi r2, r6, 9 // icount 604
nop // to align meminst icount 605
ld r4, r1, 2 // icount 606
nop // to align meminst icount 607
ld r3, r1, -4 // icount 608
nop // to align meminst icount 609
ld r6, r1, 10 // icount 610
nop // to align meminst icount 611
stu r5, r1, -8 // icount 612
nop // to align meminst icount 613
ld r5, r0, -14 // icount 614
nop // to align meminst icount 615
ld r5, r1, -2 // icount 616
nop // to align meminst icount 617
ld r5, r1, 8 // icount 618
nop // to align meminst icount 619
ld r3, r0, 6 // icount 620
nop // to align meminst icount 621
ld r5, r0, -4 // icount 622
ld r5, r1, 4 // icount 623
lbi r7, 0 // icount 624
lbi r6, 0 // icount 625
nop // to align branch icount 626
bnez r3, 28 // icount 627
xor r7, r4, r1 // icount 628
slli r4, r5, 3 // icount 629
srl r6, r4, r0 // icount 630
rol r5, r0, r0 // icount 631
srli r3, r6, 8 // icount 632
slt r4, r0, r0 // icount 633
sll r2, r5, r6 // icount 634
xori r6, r5, 9 // icount 635
ror r7, r1, r6 // icount 636
nop // to align meminst icount 637
andni r2, r2, 1 // icount 638
st r3, r2, 0 // icount 639
slbi r3, 11 // icount 640
nop // to align meminst icount 641
andni r0, r0, 1 // icount 642
st r5, r0, 0 // icount 643
slt r2, r3, r5 // icount 644
nop // to align meminst icount 645
andni r1, r1, 1 // icount 646
ld r5, r1, 2 // icount 647
xori r2, r0, 4 // icount 648
slli r3, r7, 14 // icount 649
slli r4, r3, 1 // icount 650
rori r5, r3, 1 // icount 651
srl r7, r0, r7 // icount 652
nop // to align meminst icount 653
andni r4, r4, 1 // icount 654
stu r5, r4, 8 // icount 655
seq r5, r2, r1 // icount 656
add r2, r2, r4 // icount 657
slli r3, r1, 13 // icount 658
nop // to align meminst icount 659
andni r2, r2, 1 // icount 660
st r2, r2, 10 // icount 661
rol r3, r5, r3 // icount 662
xori r2, r2, 1 // icount 663
addi r2, r7, 4 // icount 664
nop // to align meminst icount 665
ror r2, r5, r2 // icount 666
nop // to align meminst icount 667
ld r5, r0, -6 // icount 668
nop // to align meminst icount 669
st r6, r1, -8 // icount 670
nop // to align meminst icount 671
ld r4, r0, 0 // icount 672
nop // to align meminst icount 673
ld r2, r0, 12 // icount 674
nop // to align meminst icount 675
ld r3, r0, -14 // icount 676
nop // to align meminst icount 677
stu r5, r1, -6 // icount 678
nop // to align meminst icount 679
ld r2, r0, 12 // icount 680
nop // to align meminst icount 681
stu r2, r0, 8 // icount 682
nop // to align meminst icount 683
ld r2, r0, -14 // icount 684
nop // to align meminst icount 685
st r5, r1, 14 // icount 686
nop // to align meminst icount 687
stu r2, r1, 14 // icount 688
nop // to align meminst icount 689
st r5, r1, -2 // icount 690
nop // to align meminst icount 691
ld r4, r1, -8 // icount 692
nop // to align meminst icount 693
stu r5, r0, -8 // icount 694
nop // to align meminst icount 695
ld r6, r1, 6 // icount 696
nop // to align meminst icount 697
stu r6, r1, 12 // icount 698
nop // to align meminst icount 699
ld r4, r0, -10 // icount 700
nop // to align meminst icount 701
st r6, r0, 8 // icount 702
nop // to align meminst icount 703
ld r3, r0, -4 // icount 704
nop // to align meminst icount 705
st r6, r0, -10 // icount 706
nop // to align meminst icount 707
stu r6, r0, 14 // icount 708
nop // to align meminst icount 709
stu r3, r0, 8 // icount 710
nop // to align meminst icount 711
ld r6, r1, -6 // icount 712
nop // to align meminst icount 713
ld r6, r0, -16 // icount 714
nop // to align meminst icount 715
ld r4, r0, 14 // icount 716
nop // to align meminst icount 717
ld r4, r0, -2 // icount 718
nop // to align meminst icount 719
stu r5, r0, 6 // icount 720
nop // to align meminst icount 721
st r4, r1, 14 // icount 722
nop // to align meminst icount 723
ld r6, r1, 8 // icount 724
nop // to align meminst icount 725
ld r6, r1, 8 // icount 726
nop // to align meminst icount 727
ld r3, r0, 14 // icount 728
nop // to align meminst icount 729
st r6, r1, -10 // icount 730
nop // to align meminst icount 731
ld r2, r1, -4 // icount 732
nop // to align meminst icount 733
st r4, r1, 10 // icount 734
nop // to align meminst icount 735
ld r5, r0, -14 // icount 736
nop // to align meminst icount 737
st r3, r1, 0 // icount 738
nop // to align meminst icount 739
st r4, r1, -12 // icount 740
nop // to align meminst icount 741
stu r2, r0, -16 // icount 742
nop // to align meminst icount 743
ld r4, r1, 12 // icount 744
nop // to align meminst icount 745
ld r2, r1, -12 // icount 746
nop // to align meminst icount 747
ld r6, r0, -14 // icount 748
nop // to align meminst icount 749
stu r2, r0, -10 // icount 750
nop // to align meminst icount 751
st r6, r0, -12 // icount 752
nop // to align meminst icount 753
ld r3, r1, -2 // icount 754
nop // to align meminst icount 755
stu r4, r1, 2 // icount 756
nop // to align meminst icount 757
ld r2, r1, -10 // icount 758
nop // to align meminst icount 759
ld r6, r1, 0 // icount 760
nop // to align meminst icount 761
ld r4, r1, 14 // icount 762
nop // to align meminst icount 763
st r5, r0, 4 // icount 764
nop // to align meminst icount 765
stu r2, r1, -10 // icount 766
nop // to align meminst icount 767
stu r5, r0, -14 // icount 768
nop // to align meminst icount 769
stu r3, r0, -2 // icount 770
nop // to align meminst icount 771
ld r6, r0, 12 // icount 772
nop // to align meminst icount 773
ld r5, r0, 12 // icount 774
nop // to align meminst icount 775
ld r2, r0, -16 // icount 776
nop // to align meminst icount 777
ld r6, r1, 8 // icount 778
nop // to align meminst icount 779
st r4, r1, -8 // icount 780
nop // to align meminst icount 781
ld r4, r0, 4 // icount 782
nop // to align meminst icount 783
ld r3, r1, 8 // icount 784
nop // to align meminst icount 785
ld r4, r1, 0 // icount 786
nop // to align meminst icount 787
ld r4, r0, 12 // icount 788
nop // to align meminst icount 789
stu r4, r1, -2 // icount 790
nop // to align meminst icount 791
ld r6, r0, -8 // icount 792
nop // to align meminst icount 793
ld r3, r1, 10 // icount 794
nop // to align meminst icount 795
st r2, r1, -8 // icount 796
nop // to align meminst icount 797
ld r2, r1, -12 // icount 798
nop // to align meminst icount 799
ld r6, r1, 2 // icount 800
nop // to align meminst icount 801
st r4, r0, 8 // icount 802
nop // to align meminst icount 803
stu r4, r1, -10 // icount 804
nop // to align meminst icount 805
st r5, r1, 14 // icount 806
nop // to align meminst icount 807
stu r3, r0, -16 // icount 808
nop // to align meminst icount 809
stu r2, r1, 14 // icount 810
nop // to align meminst icount 811
st r4, r1, -16 // icount 812
nop // to align meminst icount 813
ld r4, r1, 6 // icount 814
nop // to align meminst icount 815
ld r3, r0, 6 // icount 816
nop // to align meminst icount 817
ld r4, r1, -8 // icount 818
nop // to align meminst icount 819
ld r3, r1, -2 // icount 820
nop // to align meminst icount 821
ld r5, r1, -14 // icount 822
nop // to align meminst icount 823
ld r6, r0, -16 // icount 824
nop // to align meminst icount 825
ld r6, r0, 4 // icount 826
nop // to align meminst icount 827
st r2, r1, -2 // icount 828
nop // to align meminst icount 829
ld r4, r1, -4 // icount 830
nop // to align meminst icount 831
st r4, r1, -4 // icount 832
nop // to align meminst icount 833
ld r6, r1, -10 // icount 834
nop // to align meminst icount 835
stu r2, r0, 6 // icount 836
nop // to align meminst icount 837
stu r3, r0, 4 // icount 838
nop // to align meminst icount 839
ld r3, r1, 2 // icount 840
nop // to align meminst icount 841
st r2, r0, 12 // icount 842
nop // to align meminst icount 843
ld r2, r0, 0 // icount 844
nop // to align meminst icount 845
stu r4, r0, 12 // icount 846
nop // to align meminst icount 847
ld r2, r0, -12 // icount 848
nop // to align meminst icount 849
stu r2, r0, 6 // icount 850
nop // to align meminst icount 851
st r4, r0, -10 // icount 852
nop // to align meminst icount 853
stu r3, r0, 6 // icount 854
nop // to align meminst icount 855
ld r4, r1, 2 // icount 856
nop // to align meminst icount 857
st r3, r0, 12 // icount 858
nop // to align meminst icount 859
ld r4, r0, 12 // icount 860
nop // to align meminst icount 861
ld r4, r0, 0 // icount 862
nop // to align meminst icount 863
ld r2, r1, -4 // icount 864
nop // to align meminst icount 865
stu r6, r1, 4 // icount 866
nop // to align meminst icount 867
st r3, r1, 0 // icount 868
nop // to align meminst icount 869
st r5, r1, 8 // icount 870
nop // to align meminst icount 871
ld r6, r1, -4 // icount 872
nop // to align meminst icount 873
stu r4, r0, 0 // icount 874
nop // to align meminst icount 875
ld r5, r0, -4 // icount 876
nop // to align meminst icount 877
ld r5, r0, -16 // icount 878
nop // to align meminst icount 879
ld r5, r0, 8 // icount 880
nop // to align meminst icount 881
ld r2, r0, 8 // icount 882
nop // to align meminst icount 883
ld r3, r1, 14 // icount 884
nop // to align meminst icount 885
stu r4, r1, -14 // icount 886
nop // to align meminst icount 887
stu r6, r0, 0 // icount 888
nop // to align meminst icount 889
ld r2, r0, -2 // icount 890
nop // to align meminst icount 891
ld r3, r0, 10 // icount 892
nop // to align meminst icount 893
st r4, r0, -14 // icount 894
nop // to align meminst icount 895
st r3, r0, -8 // icount 896
nop // to align meminst icount 897
st r2, r0, -6 // icount 898
nop // to align meminst icount 899
st r6, r0, -8 // icount 900
st r3, r0, -8 // icount 901
addi r0, r0, 6 // change base addr // icount 902
nop // to align meminst icount 903
stu r3, r1, 6 // icount 904
nop // to align meminst icount 905
stu r2, r0, -6 // icount 906
nop // to align meminst icount 907
st r2, r1, 8 // icount 908
nop // to align meminst icount 909
st r5, r1, 8 // icount 910
nop // to align meminst icount 911
ld r6, r1, -12 // icount 912
nop // to align meminst icount 913
ld r4, r1, -10 // icount 914
nop // to align meminst icount 915
stu r5, r0, 14 // icount 916
nop // to align meminst icount 917
st r6, r0, -12 // icount 918
nop // to align meminst icount 919
ld r3, r0, -8 // icount 920
nop // to align meminst icount 921
ld r2, r0, 8 // icount 922
nop // to align meminst icount 923
ld r5, r0, -4 // icount 924
nop // to align meminst icount 925
stu r2, r1, -2 // icount 926
nop // to align meminst icount 927
ld r6, r1, 6 // icount 928
nop // to align meminst icount 929
ld r5, r1, 0 // icount 930
nop // to align meminst icount 931
st r4, r0, -6 // icount 932
nop // to align meminst icount 933
st r5, r0, 14 // icount 934
nop // to align meminst icount 935
stu r3, r0, -10 // icount 936
nop // to align meminst icount 937
st r3, r0, 0 // icount 938
nop // to align meminst icount 939
stu r5, r0, 12 // icount 940
nop // to align meminst icount 941
stu r5, r1, 8 // icount 942
nop // to align meminst icount 943
ld r4, r0, 10 // icount 944
stu r6, r1, 14 // icount 945
slt r4, r7, r2 // icount 946
nop // to align meminst icount 947
st r2, r1, 12 // icount 948
nop // to align meminst icount 949
ld r5, r0, 14 // icount 950
nop // to align meminst icount 951
ld r2, r0, -14 // icount 952
nop // to align meminst icount 953
st r6, r0, -2 // icount 954
nop // to align meminst icount 955
stu r2, r1, -4 // icount 956
nop // to align meminst icount 957
ld r5, r1, -6 // icount 958
nop // to align meminst icount 959
st r3, r0, -10 // icount 960
nop // to align meminst icount 961
ld r2, r1, -8 // icount 962
nop // to align meminst icount 963
ld r2, r0, 4 // icount 964
nop // to align meminst icount 965
ld r5, r1, -16 // icount 966
nop // to align meminst icount 967
stu r3, r0, -12 // icount 968
nop // to align meminst icount 969
stu r2, r0, 6 // icount 970
nop // to align meminst icount 971
ld r3, r0, -14 // icount 972
nop // to align meminst icount 973
stu r5, r0, 12 // icount 974
nop // to align meminst icount 975
stu r4, r0, 12 // icount 976
nop // to align meminst icount 977
stu r3, r1, 14 // icount 978
nop // to align meminst icount 979
ld r5, r0, -12 // icount 980
nop // to align meminst icount 981
st r2, r1, 6 // icount 982
nop // to align meminst icount 983
ld r5, r1, 4 // icount 984
nop // to align meminst icount 985
stu r6, r1, -10 // icount 986
nop // to align meminst icount 987
stu r5, r1, 12 // icount 988
nop // to align meminst icount 989
stu r4, r1, 4 // icount 990
nop // to align meminst icount 991
st r6, r0, -12 // icount 992
nop // to align meminst icount 993
stu r6, r1, 12 // icount 994
nop // to align meminst icount 995
st r5, r0, 4 // icount 996
stu r3, r1, 8 // icount 997
sle r7, r0, r0 // icount 998
nop // to align meminst icount 999
stu r6, r0, 14 // icount 1000
nop // to align meminst icount 1001
st r2, r0, -2 // icount 1002
nop // to align meminst icount 1003
stu r6, r0, 8 // icount 1004
nop // to align meminst icount 1005
st r4, r0, 10 // icount 1006
nop // to align meminst icount 1007
st r6, r0, 12 // icount 1008
nop // to align meminst icount 1009
ld r4, r1, 14 // icount 1010
nop // to align meminst icount 1011
ld r4, r0, 6 // icount 1012
nop // to align meminst icount 1013
stu r2, r0, 12 // icount 1014
ld r5, r1, -4 // icount 1015
add r5, r5, r2 // icount 1016
nop // to align meminst icount 1017
stu r3, r1, -2 // icount 1018
nop // to align meminst icount 1019
ld r4, r1, 4 // icount 1020
nop // to align meminst icount 1021
ld r2, r0, 6 // icount 1022
nop // to align meminst icount 1023
ld r4, r0, 10 // icount 1024
nop // to align meminst icount 1025
stu r4, r1, 2 // icount 1026
nop // to align meminst icount 1027
ld r4, r0, 12 // icount 1028
nop // to align meminst icount 1029
ld r5, r0, -10 // icount 1030
nop // to align meminst icount 1031
st r3, r0, -16 // icount 1032
nop // to align meminst icount 1033
stu r6, r0, -14 // icount 1034
nop // to align meminst icount 1035
ld r5, r0, -6 // icount 1036
nop // to align meminst icount 1037
ld r2, r0, 12 // icount 1038
nop // to align meminst icount 1039
ld r5, r1, 12 // icount 1040
nop // to align meminst icount 1041
ld r2, r0, 10 // icount 1042
nop // to align meminst icount 1043
stu r2, r0, 14 // icount 1044
nop // to align meminst icount 1045
st r6, r0, -10 // icount 1046
nop // to align meminst icount 1047
ld r2, r1, 8 // icount 1048
nop // to align meminst icount 1049
stu r4, r1, 10 // icount 1050
nop // to align meminst icount 1051
ld r2, r1, -16 // icount 1052
nop // to align meminst icount 1053
ld r2, r0, -4 // icount 1054
nop // to align meminst icount 1055
ld r2, r1, -4 // icount 1056
nop // to align meminst icount 1057
ld r5, r1, 4 // icount 1058
nop // to align meminst icount 1059
stu r4, r0, 2 // icount 1060
nop // to align meminst icount 1061
ld r5, r0, -6 // icount 1062
nop // to align meminst icount 1063
st r4, r1, 2 // icount 1064
nop // to align meminst icount 1065
ld r4, r0, -4 // icount 1066
nop // to align meminst icount 1067
ld r3, r1, -12 // icount 1068
nop // to align meminst icount 1069
ld r2, r1, -8 // icount 1070
nop // to align meminst icount 1071
ld r2, r0, -6 // icount 1072
nop // to align meminst icount 1073
stu r3, r1, -8 // icount 1074
nop // to align meminst icount 1075
st r3, r1, 6 // icount 1076
nop // to align meminst icount 1077
stu r5, r1, 4 // icount 1078
nop // to align meminst icount 1079
st r5, r0, -6 // icount 1080
nop // to align meminst icount 1081
ld r5, r0, -2 // icount 1082
nop // to align meminst icount 1083
st r5, r1, -4 // icount 1084
nop // to align meminst icount 1085
ld r2, r1, 14 // icount 1086
nop // to align meminst icount 1087
stu r2, r0, -12 // icount 1088
nop // to align meminst icount 1089
stu r4, r1, -4 // icount 1090
nop // to align meminst icount 1091
st r2, r1, -12 // icount 1092
nop // to align meminst icount 1093
stu r6, r0, -12 // icount 1094
nop // to align meminst icount 1095
ld r5, r1, 0 // icount 1096
nop // to align meminst icount 1097
st r2, r0, 14 // icount 1098
nop // to align meminst icount 1099
st r4, r0, -4 // icount 1100
nop // to align meminst icount 1101
ld r6, r0, 6 // icount 1102
nop // to align meminst icount 1103
stu r3, r1, -8 // icount 1104
nop // to align meminst icount 1105
st r6, r0, -6 // icount 1106
nop // to align meminst icount 1107
ld r2, r0, 4 // icount 1108
nop // to align meminst icount 1109
stu r4, r0, -16 // icount 1110
nop // to align meminst icount 1111
ld r2, r0, 0 // icount 1112
nop // to align meminst icount 1113
ld r4, r0, 14 // icount 1114
nop // to align meminst icount 1115
st r6, r1, 0 // icount 1116
nop // to align meminst icount 1117
stu r6, r1, 2 // icount 1118
nop // to align meminst icount 1119
ld r3, r1, 0 // icount 1120
nop // to align meminst icount 1121
ld r5, r0, 6 // icount 1122
nop // to align meminst icount 1123
stu r3, r1, -2 // icount 1124
nop // to align meminst icount 1125
stu r6, r1, -10 // icount 1126
nop // to align meminst icount 1127
stu r6, r1, 14 // icount 1128
nop // to align meminst icount 1129
ld r2, r0, -6 // icount 1130
nop // to align meminst icount 1131
ld r4, r0, -16 // icount 1132
nop // to align meminst icount 1133
st r5, r1, -4 // icount 1134
nop // to align meminst icount 1135
stu r3, r0, 14 // icount 1136
nop // to align meminst icount 1137
ld r5, r1, 12 // icount 1138
nop // to align meminst icount 1139
stu r6, r1, 6 // icount 1140
nop // to align meminst icount 1141
st r4, r0, -12 // icount 1142
nop // to align meminst icount 1143
ld r2, r1, 8 // icount 1144
nop // to align meminst icount 1145
stu r2, r1, 12 // icount 1146
nop // to align meminst icount 1147
ld r6, r1, 2 // icount 1148
nop // to align meminst icount 1149
ld r4, r0, 12 // icount 1150
nop // to align meminst icount 1151
st r5, r0, 12 // icount 1152
nop // to align meminst icount 1153
ld r5, r1, 10 // icount 1154
nop // to align meminst icount 1155
stu r6, r1, -8 // icount 1156
nop // to align meminst icount 1157
ld r3, r0, -16 // icount 1158
nop // to align meminst icount 1159
ld r4, r0, -6 // icount 1160
nop // to align meminst icount 1161
st r2, r1, 8 // icount 1162
nop // to align meminst icount 1163
stu r3, r1, 0 // icount 1164
nop // to align meminst icount 1165
ld r4, r0, 8 // icount 1166
nop // to align meminst icount 1167
ld r4, r0, -12 // icount 1168
nop // to align meminst icount 1169
ld r4, r0, 12 // icount 1170
nop // to align meminst icount 1171
st r6, r1, 6 // icount 1172
nop // to align meminst icount 1173
ld r2, r0, -14 // icount 1174
nop // to align meminst icount 1175
st r5, r0, -14 // icount 1176
nop // to align meminst icount 1177
stu r2, r1, -12 // icount 1178
nop // to align meminst icount 1179
st r4, r1, 2 // icount 1180
nop // to align meminst icount 1181
ld r2, r0, -16 // icount 1182
nop // to align meminst icount 1183
st r3, r0, 14 // icount 1184
nop // to align meminst icount 1185
st r6, r0, 8 // icount 1186
nop // to align meminst icount 1187
ld r5, r1, -12 // icount 1188
nop // to align meminst icount 1189
st r2, r1, 6 // icount 1190
nop // to align meminst icount 1191
st r3, r1, -8 // icount 1192
nop // to align meminst icount 1193
ld r5, r0, 2 // icount 1194
nop // to align meminst icount 1195
stu r4, r0, 2 // icount 1196
nop // to align meminst icount 1197
stu r6, r1, 8 // icount 1198
nop // to align meminst icount 1199
stu r6, r1, 12 // icount 1200
nop // to align meminst icount 1201
ld r3, r0, -4 // icount 1202
nop // to align meminst icount 1203
ld r2, r1, 10 // icount 1204
nop // to align meminst icount 1205
stu r3, r0, -12 // icount 1206
nop // to align meminst icount 1207
ld r3, r1, 12 // icount 1208
nop // to align meminst icount 1209
st r5, r0, -6 // icount 1210
nop // to align meminst icount 1211
stu r5, r0, -14 // icount 1212
nop // to align meminst icount 1213
stu r5, r0, 6 // icount 1214
nop // to align meminst icount 1215
ld r6, r0, -6 // icount 1216
nop // to align meminst icount 1217
ld r3, r0, -4 // icount 1218
nop // to align meminst icount 1219
stu r2, r1, 6 // icount 1220
nop // to align meminst icount 1221
st r5, r0, -14 // icount 1222
ld r6, r0, 14 // icount 1223
srl r7, r3, r2 // icount 1224
nop // to align meminst icount 1225
st r3, r0, -12 // icount 1226
nop // to align meminst icount 1227
ld r4, r0, -14 // icount 1228
nop // to align meminst icount 1229
ld r2, r1, -6 // icount 1230
nop // to align meminst icount 1231
stu r4, r1, -10 // icount 1232
nop // to align meminst icount 1233
stu r3, r0, -6 // icount 1234
nop // to align meminst icount 1235
st r5, r0, -14 // icount 1236
nop // to align meminst icount 1237
ld r6, r1, -6 // icount 1238
nop // to align meminst icount 1239
stu r5, r1, 6 // icount 1240
nop // to align meminst icount 1241
stu r4, r0, -6 // icount 1242
nop // to align meminst icount 1243
ld r3, r0, -4 // icount 1244
nop // to align meminst icount 1245
stu r2, r0, -14 // icount 1246
nop // to align meminst icount 1247
ld r3, r1, -4 // icount 1248
nop // to align meminst icount 1249
stu r2, r1, 8 // icount 1250
nop // to align meminst icount 1251
ld r2, r0, 2 // icount 1252
nop // to align meminst icount 1253
st r3, r0, 6 // icount 1254
nop // to align meminst icount 1255
stu r3, r1, 6 // icount 1256
nop // to align meminst icount 1257
ld r6, r1, -12 // icount 1258
nop // to align meminst icount 1259
ld r6, r1, -16 // icount 1260
nop // to align meminst icount 1261
st r5, r0, -4 // icount 1262
nop // to align meminst icount 1263
ld r3, r0, -16 // icount 1264
nop // to align meminst icount 1265
ld r3, r1, 14 // icount 1266
nop // to align meminst icount 1267
st r5, r1, -10 // icount 1268
nop // to align meminst icount 1269
ld r2, r0, -8 // icount 1270
nop // to align meminst icount 1271
ld r5, r0, 4 // icount 1272
nop // to align meminst icount 1273
ld r4, r1, 12 // icount 1274
nop // to align meminst icount 1275
st r5, r0, -14 // icount 1276
nop // to align meminst icount 1277
ld r3, r0, 4 // icount 1278
nop // to align meminst icount 1279
stu r4, r1, -10 // icount 1280
nop // to align meminst icount 1281
st r2, r0, -6 // icount 1282
nop // to align meminst icount 1283
ld r4, r1, 2 // icount 1284
nop // to align meminst icount 1285
st r4, r0, 4 // icount 1286
nop // to align meminst icount 1287
ld r3, r0, -2 // icount 1288
nop // to align meminst icount 1289
ld r4, r1, 12 // icount 1290
nop // to align meminst icount 1291
ld r3, r1, -2 // icount 1292
nop // to align meminst icount 1293
ld r2, r1, -8 // icount 1294
nop // to align meminst icount 1295
ld r3, r1, -6 // icount 1296
nop // to align meminst icount 1297
stu r5, r1, -2 // icount 1298
nop // to align meminst icount 1299
stu r2, r1, 12 // icount 1300
nop // to align meminst icount 1301
st r3, r1, 12 // icount 1302
nop // to align meminst icount 1303
ld r3, r1, -16 // icount 1304
nop // to align meminst icount 1305
stu r5, r0, -8 // icount 1306
nop // to align meminst icount 1307
st r5, r0, 12 // icount 1308
nop // to align meminst icount 1309
ld r3, r1, 10 // icount 1310
nop // to align meminst icount 1311
st r6, r1, 4 // icount 1312
nop // to align meminst icount 1313
ld r3, r1, -6 // icount 1314
nop // to align meminst icount 1315
stu r6, r1, -2 // icount 1316
nop // to align meminst icount 1317
ld r6, r0, 0 // icount 1318
nop // to align meminst icount 1319
stu r3, r0, -12 // icount 1320
nop // to align meminst icount 1321
ld r6, r0, -4 // icount 1322
nop // to align meminst icount 1323
st r3, r0, -4 // icount 1324
nop // to align meminst icount 1325
st r4, r1, 6 // icount 1326
nop // to align meminst icount 1327
ld r2, r0, -2 // icount 1328
nop // to align meminst icount 1329
stu r5, r0, -4 // icount 1330
nop // to align meminst icount 1331
st r4, r0, 12 // icount 1332
nop // to align meminst icount 1333
ld r5, r0, 0 // icount 1334
nop // to align meminst icount 1335
ld r3, r0, 14 // icount 1336
nop // to align meminst icount 1337
ld r4, r0, -2 // icount 1338
nop // to align meminst icount 1339
stu r2, r0, 0 // icount 1340
nop // to align meminst icount 1341
stu r6, r1, -4 // icount 1342
nop // to align meminst icount 1343
ld r3, r0, 0 // icount 1344
nop // to align meminst icount 1345
stu r2, r0, 12 // icount 1346
nop // to align meminst icount 1347
ld r5, r0, 0 // icount 1348
nop // to align meminst icount 1349
stu r2, r0, 10 // icount 1350
nop // to align meminst icount 1351
stu r5, r1, 12 // icount 1352
nop // to align meminst icount 1353
stu r2, r1, -2 // icount 1354
nop // to align meminst icount 1355
ld r2, r0, 2 // icount 1356
nop // to align meminst icount 1357
stu r5, r1, 12 // icount 1358
nop // to align meminst icount 1359
stu r2, r0, -4 // icount 1360
st r4, r0, -16 // icount 1361
addi r1, r1, -10 // change base addr // icount 1362
nop // to align meminst icount 1363
ld r6, r1, 0 // icount 1364
nop // to align meminst icount 1365
st r5, r0, 12 // icount 1366
nop // to align meminst icount 1367
stu r3, r1, 6 // icount 1368
nop // to align meminst icount 1369
ld r3, r1, -12 // icount 1370
nop // to align meminst icount 1371
ld r6, r1, 4 // icount 1372
nop // to align meminst icount 1373
st r3, r1, 2 // icount 1374
nop // to align meminst icount 1375
ld r5, r0, 14 // icount 1376
nop // to align meminst icount 1377
st r3, r1, 14 // icount 1378
nop // to align meminst icount 1379
ld r2, r1, 6 // icount 1380
nop // to align meminst icount 1381
st r6, r0, 4 // icount 1382
nop // to align meminst icount 1383
ld r5, r1, 0 // icount 1384
nop // to align meminst icount 1385
stu r6, r1, -12 // icount 1386
nop // to align meminst icount 1387
ld r6, r0, 6 // icount 1388
nop // to align meminst icount 1389
stu r6, r1, 10 // icount 1390
nop // to align meminst icount 1391
st r2, r0, 10 // icount 1392
nop // to align meminst icount 1393
ld r2, r1, -10 // icount 1394
nop // to align meminst icount 1395
st r6, r1, 6 // icount 1396
nop // to align meminst icount 1397
st r3, r0, -2 // icount 1398
nop // to align meminst icount 1399
stu r3, r0, -10 // icount 1400
nop // to align meminst icount 1401
ld r5, r0, 12 // icount 1402
nop // to align meminst icount 1403
stu r6, r0, -12 // icount 1404
nop // to align meminst icount 1405
st r3, r0, 0 // icount 1406
nop // to align meminst icount 1407
ld r5, r0, 2 // icount 1408
nop // to align meminst icount 1409
st r5, r0, -8 // icount 1410
nop // to align meminst icount 1411
ld r6, r0, -10 // icount 1412
nop // to align meminst icount 1413
st r3, r0, -10 // icount 1414
nop // to align meminst icount 1415
ld r5, r0, -10 // icount 1416
nop // to align meminst icount 1417
st r2, r1, -12 // icount 1418
nop // to align meminst icount 1419
stu r4, r0, 4 // icount 1420
nop // to align meminst icount 1421
stu r5, r0, -16 // icount 1422
nop // to align meminst icount 1423
stu r5, r0, 2 // icount 1424
nop // to align meminst icount 1425
st r5, r0, -8 // icount 1426
nop // to align meminst icount 1427
ld r4, r0, 14 // icount 1428
nop // to align meminst icount 1429
st r3, r0, -2 // icount 1430
nop // to align meminst icount 1431
stu r5, r0, -4 // icount 1432
nop // to align meminst icount 1433
stu r2, r1, -10 // icount 1434
nop // to align meminst icount 1435
st r5, r0, 0 // icount 1436
nop // to align meminst icount 1437
stu r2, r0, -12 // icount 1438
st r6, r0, 4 // icount 1439
sub r6, r2, r2 // icount 1440
st r6, r0, 12 // icount 1441
sll r3, r6, r7 // icount 1442
nop // to align meminst icount 1443
ld r2, r1, 14 // icount 1444
nop // to align meminst icount 1445
stu r2, r0, 10 // icount 1446
nop // to align meminst icount 1447
st r2, r0, -16 // icount 1448
nop // to align meminst icount 1449
st r3, r1, 2 // icount 1450
nop // to align meminst icount 1451
ld r6, r1, 14 // icount 1452
nop // to align meminst icount 1453
ld r4, r1, -10 // icount 1454
nop // to align meminst icount 1455
ld r6, r0, 6 // icount 1456
nop // to align meminst icount 1457
stu r3, r0, 10 // icount 1458
nop // to align meminst icount 1459
ld r2, r0, 0 // icount 1460
nop // to align meminst icount 1461
st r4, r0, 8 // icount 1462
nop // to align meminst icount 1463
stu r6, r1, 12 // icount 1464
nop // to align meminst icount 1465
ld r2, r1, -16 // icount 1466
nop // to align meminst icount 1467
ld r2, r0, 14 // icount 1468
nop // to align meminst icount 1469
st r3, r0, -2 // icount 1470
nop // to align meminst icount 1471
stu r5, r1, 2 // icount 1472
nop // to align meminst icount 1473
st r4, r1, 10 // icount 1474
ld r2, r1, -16 // icount 1475
andni r6, r6, 1 // icount 1476
nop // to align meminst icount 1477
ld r5, r6, 0 // icount 1478
nop // to align meminst icount 1479
ld r4, r1, 10 // icount 1480
nop // to align meminst icount 1481
ld r3, r0, 8 // icount 1482
nop // to align meminst icount 1483
ld r4, r0, 6 // icount 1484
nop // to align meminst icount 1485
ld r2, r0, 4 // icount 1486
nop // to align meminst icount 1487
ld r4, r0, -6 // icount 1488
nop // to align meminst icount 1489
stu r4, r0, 2 // icount 1490
nop // to align meminst icount 1491
st r6, r0, -4 // icount 1492
nop // to align meminst icount 1493
stu r6, r0, 2 // icount 1494
nop // to align meminst icount 1495
stu r6, r0, 6 // icount 1496
nop // to align meminst icount 1497
ld r4, r0, -16 // icount 1498
nop // to align meminst icount 1499
ld r4, r0, -6 // icount 1500
nop // to align meminst icount 1501
ld r5, r0, 2 // icount 1502
nop // to align meminst icount 1503
ld r5, r1, 4 // icount 1504
nop // to align meminst icount 1505
ld r3, r1, 0 // icount 1506
nop // to align meminst icount 1507
stu r2, r0, -4 // icount 1508
nop // to align meminst icount 1509
stu r3, r1, 10 // icount 1510
nop // to align meminst icount 1511
st r2, r0, -14 // icount 1512
nop // to align meminst icount 1513
st r4, r0, 0 // icount 1514
nop // to align meminst icount 1515
ld r3, r0, 14 // icount 1516
nop // to align meminst icount 1517
stu r6, r0, 4 // icount 1518
nop // to align meminst icount 1519
ld r5, r1, 10 // icount 1520
nop // to align meminst icount 1521
stu r4, r1, -2 // icount 1522
nop // to align meminst icount 1523
stu r3, r1, -14 // icount 1524
nop // to align meminst icount 1525
ld r6, r0, -10 // icount 1526
nop // to align meminst icount 1527
stu r4, r1, -14 // icount 1528
nop // to align meminst icount 1529
ld r2, r0, 4 // icount 1530
nop // to align meminst icount 1531
stu r4, r0, -16 // icount 1532
nop // to align meminst icount 1533
st r6, r0, 6 // icount 1534
nop // to align meminst icount 1535
st r3, r1, 0 // icount 1536
nop // to align meminst icount 1537
st r2, r0, -16 // icount 1538
stu r4, r0, -8 // icount 1539
roli r4, r5, 2 // icount 1540
nop // to align meminst icount 1541
stu r3, r1, 12 // icount 1542
nop // to align meminst icount 1543
stu r3, r0, -12 // icount 1544
nop // to align meminst icount 1545
stu r3, r1, -8 // icount 1546
nop // to align meminst icount 1547
ld r5, r1, -6 // icount 1548
nop // to align meminst icount 1549
ld r5, r0, -2 // icount 1550
nop // to align meminst icount 1551
ld r2, r1, -12 // icount 1552
nop // to align meminst icount 1553
st r5, r0, -6 // icount 1554
nop // to align meminst icount 1555
ld r4, r1, -10 // icount 1556
nop // to align meminst icount 1557
ld r2, r1, 2 // icount 1558
nop // to align meminst icount 1559
stu r4, r0, 8 // icount 1560
nop // to align meminst icount 1561
ld r6, r1, -12 // icount 1562
nop // to align meminst icount 1563
ld r5, r0, 8 // icount 1564
nop // to align meminst icount 1565
ld r6, r0, 10 // icount 1566
nop // to align meminst icount 1567
st r6, r1, 8 // icount 1568
nop // to align meminst icount 1569
st r3, r1, -2 // icount 1570
nop // to align meminst icount 1571
stu r2, r0, -4 // icount 1572
nop // to align meminst icount 1573
ld r2, r1, 2 // icount 1574
nop // to align meminst icount 1575
ld r4, r0, 10 // icount 1576
nop // to align meminst icount 1577
st r5, r0, -16 // icount 1578
nop // to align meminst icount 1579
st r6, r0, 0 // icount 1580
nop // to align meminst icount 1581
st r6, r1, 6 // icount 1582
nop // to align meminst icount 1583
st r4, r0, 0 // icount 1584
nop // to align meminst icount 1585
ld r5, r0, 4 // icount 1586
nop // to align meminst icount 1587
st r5, r0, 8 // icount 1588
nop // to align meminst icount 1589
stu r5, r1, 14 // icount 1590
nop // to align meminst icount 1591
stu r4, r1, 0 // icount 1592
nop // to align meminst icount 1593
ld r5, r0, -2 // icount 1594
nop // to align meminst icount 1595
st r2, r1, 6 // icount 1596
nop // to align meminst icount 1597
st r5, r1, -6 // icount 1598
nop // to align meminst icount 1599
st r4, r0, 2 // icount 1600
nop // to align meminst icount 1601
ld r3, r0, 4 // icount 1602
nop // to align meminst icount 1603
st r5, r0, 2 // icount 1604
nop // to align meminst icount 1605
ld r5, r1, 0 // icount 1606
nop // to align meminst icount 1607
ld r5, r0, -6 // icount 1608
nop // to align meminst icount 1609
st r5, r0, -14 // icount 1610
nop // to align meminst icount 1611
ld r3, r0, -16 // icount 1612
nop // to align meminst icount 1613
stu r6, r1, 12 // icount 1614
nop // to align meminst icount 1615
ld r5, r0, 12 // icount 1616
nop // to align meminst icount 1617
stu r6, r1, -14 // icount 1618
nop // to align meminst icount 1619
ld r2, r1, 14 // icount 1620
st r6, r1, 12 // icount 1621
sco r3, r0, r1 // icount 1622
nop // to align meminst icount 1623
stu r3, r0, -12 // icount 1624
nop // to align meminst icount 1625
stu r2, r1, -16 // icount 1626
ld r6, r0, 0 // icount 1627
andni r0, r0, 1 // icount 1628
nop // to align meminst icount 1629
ld r6, r0, 10 // icount 1630
nop // to align meminst icount 1631
stu r3, r1, 12 // icount 1632
nop // to align meminst icount 1633
st r3, r0, 14 // icount 1634
nop // to align meminst icount 1635
stu r4, r0, 6 // icount 1636
nop // to align meminst icount 1637
ld r5, r0, -16 // icount 1638
nop // to align meminst icount 1639
st r3, r0, -4 // icount 1640
nop // to align meminst icount 1641
st r4, r1, -8 // icount 1642
nop // to align meminst icount 1643
stu r6, r1, 14 // icount 1644
nop // to align meminst icount 1645
ld r2, r0, 2 // icount 1646
nop // to align meminst icount 1647
ld r2, r0, 12 // icount 1648
nop // to align meminst icount 1649
ld r4, r0, 2 // icount 1650
nop // to align meminst icount 1651
ld r3, r1, -16 // icount 1652
nop // to align meminst icount 1653
stu r6, r1, -6 // icount 1654
nop // to align meminst icount 1655
ld r3, r1, 4 // icount 1656
nop // to align meminst icount 1657
st r2, r0, 2 // icount 1658
nop // to align meminst icount 1659
st r6, r0, -2 // icount 1660
nop // to align meminst icount 1661
stu r3, r1, -4 // icount 1662
nop // to align meminst icount 1663
ld r5, r1, 4 // icount 1664
nop // to align meminst icount 1665
st r5, r0, 8 // icount 1666
nop // to align meminst icount 1667
ld r6, r1, 0 // icount 1668
nop // to align meminst icount 1669
ld r2, r1, -16 // icount 1670
nop // to align meminst icount 1671
ld r2, r1, -2 // icount 1672
nop // to align meminst icount 1673
ld r5, r0, -4 // icount 1674
nop // to align meminst icount 1675
st r2, r0, -2 // icount 1676
nop // to align meminst icount 1677
st r6, r0, -16 // icount 1678
nop // to align meminst icount 1679
stu r3, r0, 12 // icount 1680
nop // to align meminst icount 1681
st r3, r0, 8 // icount 1682
nop // to align meminst icount 1683
ld r5, r1, 14 // icount 1684
nop // to align meminst icount 1685
stu r5, r0, -4 // icount 1686
nop // to align meminst icount 1687
ld r5, r1, -4 // icount 1688
nop // to align meminst icount 1689
ld r4, r1, 14 // icount 1690
nop // to align meminst icount 1691
ld r5, r0, -12 // icount 1692
nop // to align meminst icount 1693
ld r2, r0, 12 // icount 1694
nop // to align meminst icount 1695
ld r4, r1, 4 // icount 1696
nop // to align meminst icount 1697
st r6, r0, -8 // icount 1698
nop // to align meminst icount 1699
stu r5, r0, -16 // icount 1700
nop // to align meminst icount 1701
st r5, r1, -2 // icount 1702
nop // to align meminst icount 1703
st r5, r0, -16 // icount 1704
nop // to align meminst icount 1705
st r6, r0, -16 // icount 1706
nop // to align meminst icount 1707
stu r2, r0, -6 // icount 1708
nop // to align meminst icount 1709
stu r3, r1, 0 // icount 1710
st r4, r1, -16 // icount 1711
andni r5, r5, 1 // icount 1712
nop // to align meminst icount 1713
ld r7, r5, 0 // icount 1714
nop // to align meminst icount 1715
stu r6, r1, -12 // icount 1716
nop // to align meminst icount 1717
ld r6, r0, 12 // icount 1718
nop // to align meminst icount 1719
st r5, r1, 0 // icount 1720
nop // to align meminst icount 1721
stu r5, r1, -14 // icount 1722
nop // to align meminst icount 1723
ld r3, r0, 4 // icount 1724
nop // to align meminst icount 1725
ld r4, r1, 0 // icount 1726
nop // to align meminst icount 1727
ld r6, r1, 10 // icount 1728
nop // to align meminst icount 1729
st r3, r1, -14 // icount 1730
nop // to align meminst icount 1731
ld r4, r1, -6 // icount 1732
nop // to align meminst icount 1733
ld r4, r1, 2 // icount 1734
nop // to align meminst icount 1735
stu r3, r1, 0 // icount 1736
nop // to align meminst icount 1737
ld r4, r1, -12 // icount 1738
nop // to align meminst icount 1739
ld r5, r1, 0 // icount 1740
nop // to align meminst icount 1741
ld r2, r1, -2 // icount 1742
nop // to align meminst icount 1743
ld r6, r1, -6 // icount 1744
nop // to align meminst icount 1745
st r2, r1, -14 // icount 1746
nop // to align meminst icount 1747
ld r6, r0, 12 // icount 1748
nop // to align meminst icount 1749
st r4, r0, -10 // icount 1750
nop // to align meminst icount 1751
ld r5, r0, -12 // icount 1752
nop // to align meminst icount 1753
ld r4, r0, -6 // icount 1754
nop // to align meminst icount 1755
stu r3, r1, 12 // icount 1756
nop // to align meminst icount 1757
stu r5, r1, -8 // icount 1758
nop // to align meminst icount 1759
ld r3, r0, 14 // icount 1760
nop // to align meminst icount 1761
ld r5, r0, -14 // icount 1762
nop // to align meminst icount 1763
st r6, r1, 2 // icount 1764
nop // to align meminst icount 1765
st r5, r0, -12 // icount 1766
nop // to align meminst icount 1767
st r6, r0, 14 // icount 1768
ld r2, r1, 10 // icount 1769
andni r1, r1, 1 // icount 1770
nop // to align meminst icount 1771
st r7, r1, 12 // icount 1772
nop // to align meminst icount 1773
ld r4, r0, -12 // icount 1774
nop // to align meminst icount 1775
ld r2, r0, -4 // icount 1776
nop // to align meminst icount 1777
st r3, r1, 4 // icount 1778
nop // to align meminst icount 1779
ld r5, r0, 10 // icount 1780
nop // to align meminst icount 1781
ld r2, r1, 8 // icount 1782
nop // to align meminst icount 1783
stu r3, r1, -8 // icount 1784
nop // to align meminst icount 1785
ld r4, r0, 2 // icount 1786
nop // to align meminst icount 1787
ld r6, r0, -2 // icount 1788
nop // to align meminst icount 1789
st r4, r1, 8 // icount 1790
nop // to align meminst icount 1791
ld r5, r1, 6 // icount 1792
nop // to align meminst icount 1793
ld r5, r1, 6 // icount 1794
nop // to align meminst icount 1795
ld r4, r1, -12 // icount 1796
nop // to align meminst icount 1797
ld r3, r0, -4 // icount 1798
nop // to align meminst icount 1799
st r4, r1, -2 // icount 1800
nop // to align meminst icount 1801
ld r4, r1, -8 // icount 1802
nop // to align meminst icount 1803
st r4, r0, 12 // icount 1804
nop // to align meminst icount 1805
stu r2, r0, 14 // icount 1806
nop // to align meminst icount 1807
stu r4, r1, 12 // icount 1808
nop // to align meminst icount 1809
ld r2, r1, 8 // icount 1810
nop // to align meminst icount 1811
ld r6, r0, -14 // icount 1812
nop // to align meminst icount 1813
stu r5, r0, 0 // icount 1814
nop // to align meminst icount 1815
stu r6, r1, -2 // icount 1816
nop // to align meminst icount 1817
stu r2, r0, -14 // icount 1818
nop // to align meminst icount 1819
ld r4, r0, -8 // icount 1820
nop // to align meminst icount 1821
st r6, r1, 2 // icount 1822
nop // to align meminst icount 1823
st r2, r1, -16 // icount 1824
nop // to align meminst icount 1825
stu r3, r0, -14 // icount 1826
nop // to align meminst icount 1827
ld r3, r1, -16 // icount 1828
nop // to align meminst icount 1829
stu r4, r0, -16 // icount 1830
nop // to align meminst icount 1831
stu r4, r0, 6 // icount 1832
nop // to align meminst icount 1833
st r2, r1, -8 // icount 1834
nop // to align meminst icount 1835
st r2, r0, 4 // icount 1836
nop // to align meminst icount 1837
ld r5, r0, -16 // icount 1838
nop // to align meminst icount 1839
stu r3, r0, -10 // icount 1840
nop // to align meminst icount 1841
st r5, r0, 0 // icount 1842
nop // to align meminst icount 1843
stu r6, r1, 12 // icount 1844
nop // to align meminst icount 1845
stu r5, r0, -14 // icount 1846
nop // to align meminst icount 1847
ld r2, r1, -12 // icount 1848
nop // to align meminst icount 1849
ld r6, r0, -4 // icount 1850
nop // to align meminst icount 1851
st r2, r1, 6 // icount 1852
nop // to align meminst icount 1853
ld r4, r0, -8 // icount 1854
nop // to align meminst icount 1855
st r5, r0, -14 // icount 1856
nop // to align meminst icount 1857
ld r5, r0, 6 // icount 1858
nop // to align meminst icount 1859
st r6, r1, -14 // icount 1860
nop // to align meminst icount 1861
ld r4, r1, -6 // icount 1862
nop // to align meminst icount 1863
stu r4, r0, -10 // icount 1864
nop // to align meminst icount 1865
st r2, r1, -6 // icount 1866
nop // to align meminst icount 1867
stu r6, r0, -14 // icount 1868
nop // to align meminst icount 1869
st r3, r1, 14 // icount 1870
nop // to align meminst icount 1871
stu r5, r0, 12 // icount 1872
nop // to align meminst icount 1873
st r3, r1, -10 // icount 1874
nop // to align meminst icount 1875
ld r2, r0, 2 // icount 1876
nop // to align meminst icount 1877
ld r3, r0, -14 // icount 1878
nop // to align meminst icount 1879
st r3, r0, -6 // icount 1880
nop // to align meminst icount 1881
st r5, r0, 2 // icount 1882
nop // to align meminst icount 1883
ld r2, r0, 4 // icount 1884
nop // to align meminst icount 1885
ld r2, r1, 0 // icount 1886
nop // to align meminst icount 1887
st r5, r1, -12 // icount 1888
nop // to align meminst icount 1889
ld r2, r0, -16 // icount 1890
nop // to align meminst icount 1891
stu r3, r0, 10 // icount 1892
nop // to align meminst icount 1893
ld r4, r0, -12 // icount 1894
nop // to align meminst icount 1895
ld r2, r1, 14 // icount 1896
nop // to align meminst icount 1897
st r3, r1, -4 // icount 1898
nop // to align meminst icount 1899
st r5, r0, 14 // icount 1900
nop // to align meminst icount 1901
st r5, r0, -16 // icount 1902
nop // to align meminst icount 1903
st r6, r0, 12 // icount 1904
nop // to align meminst icount 1905
ld r6, r1, 0 // icount 1906
nop // to align meminst icount 1907
stu r2, r0, 14 // icount 1908
nop // to align meminst icount 1909
st r4, r0, 4 // icount 1910
nop // to align meminst icount 1911
ld r6, r1, 4 // icount 1912
stu r6, r0, -8 // icount 1913
srl r4, r2, r2 // icount 1914
nop // to align meminst icount 1915
st r4, r0, -12 // icount 1916
nop // to align meminst icount 1917
stu r4, r0, -4 // icount 1918
nop // to align meminst icount 1919
ld r5, r0, 2 // icount 1920
nop // to align meminst icount 1921
st r2, r0, -4 // icount 1922
nop // to align meminst icount 1923
stu r2, r1, 0 // icount 1924
nop // to align meminst icount 1925
st r6, r1, -6 // icount 1926
nop // to align meminst icount 1927
st r6, r1, 0 // icount 1928
nop // to align meminst icount 1929
ld r5, r1, -10 // icount 1930
nop // to align meminst icount 1931
stu r3, r1, -14 // icount 1932
nop // to align meminst icount 1933
ld r4, r0, 12 // icount 1934
nop // to align meminst icount 1935
stu r5, r0, -6 // icount 1936
nop // to align meminst icount 1937
ld r5, r0, 8 // icount 1938
ld r4, r0, -8 // icount 1939
lbi r6, 0 // icount 1940
lbi r4, 0 // icount 1941
nop // to align branch icount 1942
bgez r3, 8 // icount 1943
andn r3, r7, r5 // icount 1944
sll r2, r0, r0 // icount 1945
andni r4, r4, 1 // icount 1946
stu r2, r4, 12 // icount 1947
subi r2, r0, 2 // icount 1948
rol r4, r1, r5 // icount 1949
srli r6, r1, 0 // icount 1950
sub r7, r2, r2 // icount 1951
roli r5, r0, 4 // icount 1952
nop // to align meminst icount 1953
stu r3, r0, 12 // icount 1954
nop // to align meminst icount 1955
stu r3, r1, 6 // icount 1956
nop // to align meminst icount 1957
ld r4, r0, 2 // icount 1958
nop // to align meminst icount 1959
ld r4, r1, 6 // icount 1960
nop // to align meminst icount 1961
st r5, r1, -10 // icount 1962
nop // to align meminst icount 1963
ld r6, r0, 14 // icount 1964
nop // to align meminst icount 1965
st r3, r0, -8 // icount 1966
nop // to align meminst icount 1967
ld r3, r0, -6 // icount 1968
nop // to align meminst icount 1969
stu r2, r1, -16 // icount 1970
nop // to align meminst icount 1971
stu r4, r0, 12 // icount 1972
nop // to align meminst icount 1973
ld r2, r1, 2 // icount 1974
nop // to align meminst icount 1975
st r6, r1, 6 // icount 1976
nop // to align meminst icount 1977
stu r4, r1, -14 // icount 1978
nop // to align meminst icount 1979
ld r3, r0, -2 // icount 1980
nop // to align meminst icount 1981
st r2, r1, -6 // icount 1982
ld r5, r1, 12 // icount 1983
lbi r4, 13 // icount 1984
nop // to align meminst icount 1985
ld r2, r1, -2 // icount 1986
nop // to align meminst icount 1987
st r3, r0, -14 // icount 1988
nop // to align meminst icount 1989
ld r6, r1, 2 // icount 1990
stu r2, r0, -6 // icount 1991
addi r1, r1, 2 // change base addr // icount 1992
nop // to align meminst icount 1993
ld r6, r1, -14 // icount 1994
nop // to align meminst icount 1995
stu r5, r0, -2 // icount 1996
nop // to align meminst icount 1997
stu r5, r1, 12 // icount 1998
nop // to align meminst icount 1999
ld r3, r1, -10 // icount 2000
nop // to align meminst icount 2001
ld r6, r0, -6 // icount 2002
nop // to align meminst icount 2003
ld r5, r0, -12 // icount 2004
nop // to align meminst icount 2005
st r4, r0, 12 // icount 2006
nop // to align meminst icount 2007
ld r5, r0, 4 // icount 2008
nop // to align meminst icount 2009
st r5, r1, -16 // icount 2010
nop // to align meminst icount 2011
stu r2, r0, -14 // icount 2012
nop // to align meminst icount 2013
stu r6, r1, 0 // icount 2014
nop // to align meminst icount 2015
st r2, r1, -2 // icount 2016
nop // to align meminst icount 2017
ld r4, r1, -16 // icount 2018
nop // to align meminst icount 2019
ld r6, r0, 6 // icount 2020
nop // to align meminst icount 2021
ld r3, r0, -14 // icount 2022
nop // to align meminst icount 2023
ld r3, r0, -14 // icount 2024
nop // to align meminst icount 2025
st r6, r0, -10 // icount 2026
nop // to align meminst icount 2027
ld r5, r0, 4 // icount 2028
nop // to align meminst icount 2029
stu r3, r0, -2 // icount 2030
nop // to align meminst icount 2031
ld r5, r1, -4 // icount 2032
nop // to align meminst icount 2033
stu r2, r1, 10 // icount 2034
nop // to align meminst icount 2035
stu r6, r1, -16 // icount 2036
nop // to align meminst icount 2037
ld r4, r1, -4 // icount 2038
nop // to align meminst icount 2039
stu r2, r1, -4 // icount 2040
ld r4, r1, -12 // icount 2041
halt // icount 2042
|
; A142250: Primes congruent to 1 mod 43.
; Submitted by Simon Strandgaard
; 173,431,947,1033,1291,1549,1721,1979,2237,2753,3011,3527,3613,4129,4817,4903,5333,5419,5591,5849,6451,6709,6967,7741,8171,8429,9203,9461,9547,9719,10321,10837,11353,11783,12041,13159,13331,13417,13933,14449,14621,14879,15137,15739,16427,16943,17029,18061,18233,18749,19609,19867,20297,20641,20899,21157,21587,21673,22189,22447,22619,22877,22963,23909,24683,25457,25801,26317,26489,26833,27091,27779,28123,29327,29671,30187,30703,31219,31391,31477,31649,31907,32251,32423,32939,33713,34057,34487
mov $2,$0
add $2,2
pow $2,2
lpb $2
sub $2,1
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,43
mov $4,$0
max $4,0
cmp $4,$0
mul $2,$4
lpe
mov $0,$1
mul $0,2
sub $0,85
|
; int fsetpos(FILE *stream, const fpos_t *pos)
INCLUDE "clib_cfg.asm"
SECTION code_stdio
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
IF __CLIB_OPT_MULTITHREAD & $02
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
PUBLIC fsetpos
EXTERN asm_fsetpos
fsetpos:
pop af
pop hl
pop ix
push hl
push hl
push af
jp asm_fsetpos
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
ELSE
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
PUBLIC fsetpos
EXTERN fsetpos_unlocked
defc fsetpos = fsetpos_unlocked
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
ENDIF
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
.ORIG x3000
AND R0, R0, #0 ;0x3000
AND R1, R1, #0 ;0x3002
AND R2, R2, #0 ;0x3004
AND R3, R3, #0 ;0x3006
LEA R0, COUNTER ;0x3008
LDW R0, R0, #0 ;0x300A
LEA R1, DATA ;0x300C
LDW R1, R1, #0 ;0x300E
LOOP LDB R3, R1, #0 ;0x3010
ADD R2, R2, R3 ;0x3012
ADD R1, R1, #1 ;0x3014
ADD R0, R0, #-1 ;0x3016
BRp LOOP ;0x3018
LEA R0, STORE ;0x301A
LDW R0, R0, #0 ;0x301C
STW R2, R0, #0 ;0x301E
JMP R2 ;0x3020
HALT ;0x3022
STORE .FILL xC014 ;0x3024
COUNTER .FILL x0014 ;0x3026
DATA .FILL xC000 ;0x3028
.END
|
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14
// XFAIL: dylib-has-no-bad_any_cast && !no-exceptions
// <any>
// template <class T, class ...Args> any(in_place_type_t<T>, Args&&...);
// template <class T, class U, class ...Args>
// any(in_place_type_t<T>, initializer_list<U>, Args&&...);
// Test construction from a value.
// Concerns:
// ---------
// 1. The value is properly move/copied depending on the value category.
// 2. Both small and large values are properly handled.
#include <any>
#include <cassert>
#include "any_helpers.h"
#include "count_new.h"
#include "test_macros.h"
#include "test_convertible.h"
using std::any;
using std::any_cast;
template <class Type>
void test_in_place_type() {
// constructing from a small type should perform no allocations.
DisableAllocationGuard g(isSmallType<Type>()); ((void)g);
assert(Type::count == 0);
Type::reset();
{
any a(std::in_place_type<Type>);
assert(Type::count == 1);
assert(Type::copied == 0);
assert(Type::moved == 0);
assertContains<Type>(a, 0);
}
assert(Type::count == 0);
Type::reset();
{ // Test that the in_place argument is properly decayed
any a(std::in_place_type<Type&>);
assert(Type::count == 1);
assert(Type::copied == 0);
assert(Type::moved == 0);
assertContains<Type>(a, 0);
}
assert(Type::count == 0);
Type::reset();
{
any a(std::in_place_type<Type>, 101);
assert(Type::count == 1);
assert(Type::copied == 0);
assert(Type::moved == 0);
assertContains<Type>(a, 101);
}
assert(Type::count == 0);
Type::reset();
{
any a(std::in_place_type<Type>, -1, 42, -1);
assert(Type::count == 1);
assert(Type::copied == 0);
assert(Type::moved == 0);
assertContains<Type>(a, 42);
}
assert(Type::count == 0);
Type::reset();
}
template <class Type>
void test_in_place_type_tracked() {
// constructing from a small type should perform no allocations.
DisableAllocationGuard g(isSmallType<Type>()); ((void)g);
{
any a(std::in_place_type<Type>);
assertArgsMatch<Type>(a);
}
{
any a(std::in_place_type<Type>, -1, 42, -1);
assertArgsMatch<Type, int, int, int>(a);
}
// initializer_list constructor tests
{
any a(std::in_place_type<Type>, {-1, 42, -1});
assertArgsMatch<Type, std::initializer_list<int>>(a);
}
{
int x = 42;
any a(std::in_place_type<Type&>, {-1, 42, -1}, x);
assertArgsMatch<Type, std::initializer_list<int>, int&>(a);
}
}
void test_func() {}
void test_in_place_type_decayed() {
{
using Type = decltype(test_func);
using DecayT = void(*)();
any a(std::in_place_type<Type>, test_func);
assert(containsType<DecayT>(a));
assert(any_cast<DecayT>(a) == test_func);
}
{
int my_arr[5];
using Type = int(&)[5];
using DecayT = int*;
any a(std::in_place_type<Type>, my_arr);
assert(containsType<DecayT>(a));
assert(any_cast<DecayT>(a) == my_arr);
}
{
using Type = int[5];
using DecayT = int*;
any a(std::in_place_type<Type>);
assert(containsType<DecayT>(a));
assert(any_cast<DecayT>(a) == nullptr);
}
}
void test_ctor_sfinae() {
{
// Test that the init-list ctor SFINAE's away properly when
// construction would be ill-formed.
using IL = std::initializer_list<int>;
static_assert(!std::is_constructible<std::any,
std::in_place_type_t<int>, IL>::value, "");
static_assert(std::is_constructible<std::any,
std::in_place_type_t<small_tracked_t>, IL>::value, "");
}
{
// Test that the tagged dispatch constructor SFINAE's away when the
// argument is non-copyable
struct NoCopy {
NoCopy() = default;
NoCopy(NoCopy const&) = delete;
NoCopy(int) {}
NoCopy(std::initializer_list<int>, int) {}
};
using Tag = std::in_place_type_t<NoCopy>;
using RefTag = std::in_place_type_t<NoCopy&>;
using IL = std::initializer_list<int>;
static_assert(!std::is_constructible<std::any, Tag>::value, "");
static_assert(!std::is_constructible<std::any, Tag, int>::value, "");
static_assert(!std::is_constructible<std::any, Tag, IL, int>::value, "");
static_assert(!std::is_constructible<std::any, RefTag>::value, "");
static_assert(!std::is_constructible<std::any, RefTag, int>::value, "");
static_assert(!std::is_constructible<std::any, RefTag, IL, int>::value, "");
}
}
struct Implicit {
Implicit(int) {}
Implicit(int, int, int) {}
Implicit(std::initializer_list<int>, int) {}
};
void test_constructor_explicit() {
using I = Implicit;
using IT = std::in_place_type_t<I>;
static_assert(!test_convertible<std::any, IT, int>(), "");
static_assert(std::is_constructible<std::any, IT, int>::value, "");
static_assert(!test_convertible<std::any, IT, int, int, int>(), "");
static_assert(std::is_constructible<std::any, IT, int, int, int>::value, "");
static_assert(!test_convertible<std::any, IT, std::initializer_list<int>&, int>(), "");
static_assert(std::is_constructible<std::any, IT, std::initializer_list<int>&, int>::value, "");
}
int main(int, char**) {
test_in_place_type<small>();
test_in_place_type<large>();
test_in_place_type<small_throws_on_copy>();
test_in_place_type<large_throws_on_copy>();
test_in_place_type<throws_on_move>();
test_in_place_type_tracked<small_tracked_t>();
test_in_place_type_tracked<large_tracked_t>();
test_in_place_type_decayed();
test_ctor_sfinae();
test_constructor_explicit();
return 0;
}
|
/*************************************************************************
* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
* *
* Author: The ALICE Off-line Project. *
* Contributors are mentioned in the code where appropriate. *
* *
* Permission to use, copy, modify and distribute this software and its *
* documentation strictly for non-commercial purposes is hereby granted *
* without fee, provided that the above copyright notice appears in all *
* copies and that both the copyright notice and this permission notice *
* appear in the supporting documentation. The authors make no claims *
* about the suitability of this software for any purpose. It is *
* provided "as is" without express or implied warranty. *
*************************************************************************
* $Id$ */
/**
* @file AliFMDParameters.cxx
* @author Christian Holm Christensen <cholm@nbi.dk>
* @date Mon Mar 27 12:44:26 2006
* @brief Manager of FMD parameters
*/
//____________________________________________________________________
//
// Forward Multiplicity Detector based on Silicon wafers.
//
// This class is a singleton that handles various parameters of
// the FMD detectors.
// The manager normally serves the parameters from the Conditions
// Database (CDB). These are retrivied by the member function
// `Init'. Optionally, the class can serve hard-coded constants, if
// no CDB is available.
//
#include "AliFMDDebug.h" // ALILOG_H
#include "AliFMDParameters.h" // ALIFMDPARAMETERS_H
#include "AliFMDGeometry.h" // ALIFMDGEOMETRY_H
#include "AliFMDRing.h" // ALIFMDRING_H
#include "AliFMDCalibGain.h" // ALIFMDCALIBGAIN_H
#include "AliFMDCalibPedestal.h" // ALIFMDCALIBPEDESTAL_H
#include "AliFMDCalibSampleRate.h" // ALIFMDCALIBSAMPLERATE_H
#include "AliFMDCalibStripRange.h" // ALIFMDCALIBSTRIPRANGE_H
#include "AliFMDAltroMapping.h" // ALIFMDALTROMAPPING_H
#include <AliCDBManager.h> // ALICDBMANAGER_H
#include <AliCDBEntry.h> // ALICDBMANAGER_H
#include <AliFMDPreprocessor.h>
#include <AliLog.h>
#include <Riostream.h>
#include <sstream>
#include <TSystem.h>
#include <TArrayF.h>
#include <TH2D.h>
//====================================================================
ClassImp(AliFMDParameters)
#if 0
; // This is here to keep Emacs for indenting the next line
#endif
//____________________________________________________________________
AliFMDParameters* AliFMDParameters::fgInstance = 0;
//____________________________________________________________________
const char* AliFMDParameters::fgkPulseGain = "FMD/Calib/PulseGain";
const char* AliFMDParameters::fgkPedestal = "FMD/Calib/Pedestal";
const char* AliFMDParameters::fgkDead = "FMD/Calib/Dead";
const char* AliFMDParameters::fgkSampleRate = "FMD/Calib/SampleRate";
const char* AliFMDParameters::fgkAltroMap = "FMD/Calib/AltroMap";
const char* AliFMDParameters::fgkZeroSuppression = "FMD/Calib/ZeroSuppression";
const char* AliFMDParameters::fgkStripRange = "FMD/Calib/StripRange";
const char* AliFMDParameters::fkPedestalShuttleID = "pedestals";
const char* AliFMDParameters::fkGainShuttleID = "gains";
const char* AliFMDParameters::fkConditionsShuttleID = "conditions";
//____________________________________________________________________
AliFMDParameters*
AliFMDParameters::Instance()
{
//
// Get static instance
//
if (!fgInstance) fgInstance = new AliFMDParameters;
return fgInstance;
}
//____________________________________________________________________
AliFMDParameters::AliFMDParameters()
: fIsInit(kFALSE),
fkSiDeDxMip(1.664),
fVA1MipRange(0),
fAltroChannelSize(0),
fChannelsPerAltro(0),
fPedestalFactor(0),
fZSPre(1),
fZSPost(1),
fZSPedSubtract(kTRUE),
fFixedPedestal(100),
fFixedPedestalWidth(2),
fFixedZeroSuppression(1),
fFixedSampleRate(2),
fFixedThreshold(0),
fFixedMinStrip(0),
fFixedMaxStrip(127),
fFixedPulseGain(2),
fEdepMip(0),
fHasCompleteHeader(kTRUE),
fZeroSuppression(0),
fSampleRate(0),
fPedestal(0),
fPulseGain(0),
fDeadMap(0),
fAltroMap(0),
fStripRange(0),
fRunNo(-1)
{
//
// Default constructor
//
SetVA1MipRange();
SetAltroChannelSize();
SetChannelsPerAltro();
SetZeroSuppression();
SetSampleRate();
SetPedestal();
SetPedestalWidth();
SetPedestalFactor();
SetThreshold();
SetStripRange();
SetGain();
fAltroMap = new AliFMDAltroMapping;
fAltroMap->SetBit(TObject::kCanDelete);
}
//__________________________________________________________________
Bool_t
AliFMDParameters::CheckForNewRun()
{
Int_t run = AliCDBManager::Instance()->GetRun();
if (run != fRunNo) {
fIsInit = false;
fRunNo = run;
}
return run != fRunNo;
}
//__________________________________________________________________
UShort_t
AliFMDParameters::Init(Bool_t forceReInit, UInt_t what)
{
//
// Initialize the manager. This tries to read the parameters from
// CDB. If that fails, the class uses the hard-coded parameters.
//
// Parameters:
// forceReInit Force (re-)initalize flag
// what What to initialize
//
if (forceReInit) fIsInit = kFALSE;
CheckForNewRun();
if (fIsInit) return 0;
UShort_t errMask = 0;
if (what & kPulseGain) errMask |= InitPulseGain();
if (what & kPedestal) errMask |= InitPedestal();
if (what & kDeadMap) errMask |= InitDeadMap();
if (what & kSampleRate) errMask |= InitSampleRate();
if (what & kZeroSuppression) errMask |= InitZeroSuppression();
if (what & kAltroMap) errMask |= InitAltroMap();
if (what & kStripRange) errMask |= InitStripRange();
fIsInit = kTRUE;
return errMask;
}
//__________________________________________________________________
UShort_t
AliFMDParameters::Init(AliFMDPreprocessor* pp, Bool_t forceReInit, UInt_t what)
{
//
// Initialize the manager. This tries to read the parameters from
// CDB. If that fails, the class uses the hard-coded parameters.
//
// Parameters:
// pp Preprocessor
// forceReInit Force (re-)initalize flag
// what What to initialize
//
if (forceReInit) fIsInit = kFALSE;
CheckForNewRun();
if (fIsInit) return 0;
UShort_t errMask = 0;
if (what & kPulseGain) errMask |= InitPulseGain(pp);
if (what & kPedestal) errMask |= InitPedestal(pp);
if (what & kDeadMap) errMask |= InitDeadMap(pp);
if (what & kSampleRate) errMask |= InitSampleRate(pp);
if (what & kZeroSuppression) errMask |= InitZeroSuppression(pp);
if (what & kAltroMap) errMask |= InitAltroMap(pp);
if (what & kStripRange) errMask |= InitStripRange(pp);
fIsInit = kTRUE;
return errMask;
}
//__________________________________________________________________
Bool_t
AliFMDParameters::CheckFile(const char* prefix,
const char* path,
int number,
TString& f) const
{
//
// Check if the file <i>prefix</i><i>number</i> exists in @a path,
// and write the full path to @a f.
//
// Parameters:
// prefix File prefix (cond, peds, gains, ...)
// path Path to files
// number Detector number (1, 2, or 3)
// f On return full path to file (if found)
//
// Return:
// @c true if file exists and is readable, @c false otherwise
//
f = (Form("%s%d.csv", prefix, number));
AliFMDDebug(5, ("Checking if %s exists in %s ...", f.Data(), path));
f = gSystem->Which(path, f.Data());
AliFMDDebug(5, ("Got back '%s'", f.Data()));
return !f.IsNull();
}
//__________________________________________________________________
UShort_t
AliFMDParameters::Init(const char* path, Bool_t forceReInit, UInt_t what)
{
//
// Initialize the manager. This will try to read some calibrations
// (sample rate, strip range, gains, pedestals) from local comma
// separated value (CSV) files in the directory pointed at by @a
// path. If they are not found, then they will be retrieved from
// OCDB as appropriately. Other calibrations are always read from
// OCDB.
//
// The CSV files should be named as
//
// - Pedestals: <tt>peds</tt><i>det_number</i><tt>.csv</tt>
// - Gains: <tt>gains</tt><i>det_number</i><tt>.csv</tt>
// - Sample Rate: <tt>conditions</tt><i>det_number</i><tt>.csv</tt>
// - Strip Range: <tt>conditions</tt><i>det_number</i><tt>.csv</tt>
//
// where <i>det_number</i> is the detector number (1, 2, or 3).
//
// Parameters:
// path Where to look for the CSV files
// forceReInit Always reinitialise
// what What calibrations to load.
//
if (forceReInit) fIsInit = kFALSE;
CheckForNewRun();
if (fIsInit) return 0;
AliFMDCalibStripRange* range = 0;
AliFMDCalibSampleRate* rate = 0;
AliFMDCalibPedestal* peds = 0;
AliFMDCalibGain* gains = 0;
for (Int_t i = 1; i <= 3; i++) {
TString f;
if (((what & kSampleRate) || (what & kStripRange)) &&
CheckFile("conditions", path, i, f)) {
if (!rate && (what & kSampleRate)) rate = new AliFMDCalibSampleRate;
if (!range && (what & kStripRange)) range = new AliFMDCalibStripRange;
std::ifstream in(f.Data());
if (range) range->ReadFromFile(in);
if (rate) rate->ReadFromFile(in);
in.close();
}
if ((what & kPedestal) && CheckFile("peds", path, i, f)) {
if (!peds) peds = new AliFMDCalibPedestal;
std::ifstream in(f.Data());
peds->ReadFromFile(in);
in.close();
}
if ((what & kPulseGain) && CheckFile("gains", path, i, f)) {
if (!gains) gains = new AliFMDCalibGain;
std::ifstream in(f.Data());
gains->ReadFromFile(in);
in.close();
}
}
if (range) what &= ~kStripRange;
if (rate) what &= ~kSampleRate;
if (peds) what &= ~kPedestal;
if (gains) what &= ~kPulseGain;
UShort_t ret = Init(kFALSE, what);
if (range) SetStripRange(range);
if (rate) SetSampleRate(rate);
if (peds) SetPedestal(peds);
if (gains) SetGain(gains);
fIsInit = kTRUE;
return ret;
}
//__________________________________________________________________
void
AliFMDParameters::MakeDeadMap(Float_t maxNoise,
Float_t minGain,
Float_t maxGain)
{
//
// Automatically generate a dead map from the pedestals and gains.
// A channel is marked as dead of the noise is too high (currently
// more than 10 ADC counts), or the gain is unreasonable (currently
// larger than 10, or smaller than 0.1).
//
// The procedure does not overwrite channels previously marked as
// dead - e.g., channels marked as dead in the calibration loaded
// from OCDB will continue to be marked as dead. That is, this
// procedure will never make a channel un-dead.
//
// Parameters:
// maxNoise Maximum noise value before a channel is marked
// as dead.
// minGain Minimum value of the calibrated gain before a
// channel is considered dead.
// maxGain Maximum value of the calibrated gain before a
// channel is considered dead.
//
if (fPedestal)
fDeadMap = fPedestal->MakeDeadMap(maxNoise, fDeadMap);
if (fPulseGain)
fDeadMap = fPulseGain->MakeDeadMap(minGain, maxGain, fDeadMap);
}
//__________________________________________________________________
#define DET2IDX(det,ring,sec,str) \
(det * 1000 + (ring == 'I' ? 0 : 512) + str)
//__________________________________________________________________
void
AliFMDParameters::Draw(Option_t* option)
{
//
// Draw parameters.
//
// Parameters:
// option What to draw. Should be one of
// - dead Dead channels
// - threshold Threshold
// - gain Gain
// - pedestal Pedestal
// - noise Noise (or pedestal width)
// - zero Zero suppression
// - rate Sampling rate (VA1 clock / ALTRO clock)
// - min Minimum strip read out
// - max Maximum strip read out
// - map hardware address
//
TString opt(option);
enum {
kLocalPulseGain, // Path to PulseGain calib object
kLocalThreshold, // Path to PulseGain calib object
kLocalPedestal, // Path to Pedestal calib object
kLocalPedestalWidth, // Path to Pedestal calib object
kLocalDead, // Path to Dead calib object
kLocalSampleRate, // Path to SampleRate calib object
kLocalAltroMap, // Path to AltroMap calib object
kLocalZeroSuppression, // Path to ZeroSuppression cal object
kLocalMinStripRange, // Path to strip range cal object
kLocalMaxStripRange // Path to strip range cal object
} what;
if (opt.Contains("dead", TString::kIgnoreCase))
what = kLocalDead;
else if (opt.Contains("threshold",TString::kIgnoreCase))
what = kLocalThreshold;
else if (opt.Contains("gain",TString::kIgnoreCase))
what = kLocalPulseGain;
else if (opt.Contains("pedestal",TString::kIgnoreCase))
what = kLocalPedestal;
else if (opt.Contains("noise",TString::kIgnoreCase))
what = kLocalPedestalWidth;
else if (opt.Contains("zero",TString::kIgnoreCase))
what = kLocalZeroSuppression;
else if (opt.Contains("rate",TString::kIgnoreCase))
what = kLocalSampleRate;
else if (opt.Contains("min",TString::kIgnoreCase))
what = kLocalMinStripRange;
else if (opt.Contains("max",TString::kIgnoreCase))
what = kLocalMaxStripRange;
else if (opt.Contains("map",TString::kIgnoreCase))
what = kLocalAltroMap;
else {
Warning("Draw", "unknown parameter: %s\n\tShould be one of\n\t"
"dead, threshold, gain, pedestal, noise, zero, rate, "
"min, max, map",
option);
return;
}
TArrayD xbins(3 * 512 + 2 * 256 + 5);
Int_t i = 1;
Bool_t skip = kTRUE;
for (UShort_t det = 1; det <= 3; det++) {
UShort_t nRings = (det == 1 ? 1 : 2);
for (UShort_t iring = 0; iring < nRings; iring++) {
UShort_t nStrip = (iring == 0 ? 512 : 256);
Char_t ring = (iring == 0 ? 'I' : 'O');
for (UShort_t str = 0; str < nStrip; str++) {
// UShort_t nSec = (iring == 0 ? 20 : 40);
// Char_t ring = (iring == 0 ? 'I' : 'O');
// for (UShort_t sec = 0; sec < nSec; sec++) {
Int_t idx = DET2IDX(det, ring, 0, str);
// Int_t idx = DET2IDX(det, ring, sec, 0);
if (skip) {
xbins[i-1] = idx - .5;
skip = kFALSE;
}
xbins[i] = idx + .5;
i++;
}
skip = kTRUE;
i++;
}
}
TArrayD ybins(41);
for (/*Int_t*/ i = 0; i < ybins.fN; i++) ybins[i] = Float_t(i - .5);
TH2D* hist = new TH2D("calib", Form("Calibration %s", option),
xbins.fN-1, xbins.fArray,
ybins.fN-1, ybins.fArray);
hist->GetXaxis()->SetTitle("1000 #times detector + 512 #times ring + strip");
hist->GetYaxis()->SetTitle("sector");
// hist->Draw("Lego");
// return;
for (UShort_t det = 1; det <= 3; det++) {
UShort_t nRings = (det == 1 ? 1 : 2);
for (UShort_t iring = 0; iring < nRings; iring++) {
UShort_t nSector = (iring == 0 ? 20 : 40);
UShort_t nStrip = (iring == 0 ? 512 : 256);
Char_t ring = (iring == 0 ? 'I' : 'O');
for (UShort_t sec = 0; sec < nSector; sec++) {
for (UShort_t str = 0; str < nStrip; str++) {
Int_t idx = DET2IDX(det, ring, sec, str);
UShort_t ddl, addr, time, sam=0;
Double_t val = 0;
switch (what) {
case kLocalPulseGain: // Path to PulseGain calib object
val = GetPulseGain(det,ring,sec,str); break;
case kLocalThreshold: // Path to PulseGain calib object
val = GetThreshold(); break;
case kLocalPedestal: // Path to Pedestal calib object
val = GetPedestal(det,ring,sec,str); break;
case kLocalPedestalWidth: // Path to Pedestal calib object
val = GetPedestalWidth(det,ring,sec,str); break;
case kLocalDead: // Path to Dead calib object
val = IsDead(det,ring,sec,str); break;
case kLocalSampleRate: // Path to SampleRate calib object
val = GetSampleRate(det,ring,sec,str); break;
case kLocalAltroMap: // Path to AltroMap calib object
Detector2Hardware(det,ring,sec,str,sam,ddl,addr,time);
val = addr; break;
case kLocalZeroSuppression: // Path to ZeroSuppression cal object
val = GetZeroSuppression(det,ring,sec,str); break;
case kLocalMinStripRange: // Path to strip range cal object
val = GetMinStrip(det,ring,sec,str); break;
case kLocalMaxStripRange: // Path to strip range cal object
val = GetMaxStrip(det,ring,sec,str); break;
}
hist->Fill(idx,sec,val);
// hist->Fill(idx,str,val);
}
}
}
}
hist->Draw("lego");
}
//__________________________________________________________________
void
AliFMDParameters::Print(Option_t* option) const
{
// Print information.
// If option contains an 'A' then everything is printed.
// If the option contains the string "FMD" the function will search
// for detector, ring, sector, and strip numbers to print, in the
// format
//
// FMD<detector><ring>[<sector>,<string>]
//
// The wild card '*' means all of <detector>, <ring>, <sector>, or
// <strip>.
TString opt(option);
Bool_t showStrips = opt.Contains("a", TString::kIgnoreCase);
UShort_t ds[] = { 1, 2, 3, 0 };
Char_t rs[] = { 'I', 'O', '\0' };
UShort_t minStrip = 0;
UShort_t maxStrip = 512;
UShort_t minSector = 0;
UShort_t maxSector = 40;
if (opt.Contains("fmd",TString::kIgnoreCase)) {
Int_t i = opt.Index("fmd",TString::kIgnoreCase);
Int_t j = opt.Index("]",TString::kIgnoreCase);
if (j != kNPOS)
showStrips = kTRUE;
else
j = opt.Length();
enum {
kReadDet,
kReadRing,
kReadLbrack,
kReadSector,
kReadComma,
kReadStrip,
kReadRbrack,
kEnd
} state = kReadDet;
std::stringstream s(opt(i+4, j-i-3).Data());
while (state != kEnd) {
Char_t tmp = s.peek();
if (tmp == ' ' || tmp == '\t') {
s.get();
continue;
}
switch (state) {
case kReadDet: { // First, try to kRead the detector
if (tmp == '*') s.get();
else {
UShort_t det;
s >> det;
if (!s.bad()) {
ds[0] = det;
ds[1] = 0;
}
}
state = (s.bad() ? kEnd : kReadRing);
} break;
case kReadRing: { // Then try to read the ring;
Char_t ring;
s >> ring;
if (ring != '*' && !s.bad()) {
rs[0] = ring;
rs[1] = '\0';
}
state = (s.bad() ? kEnd : kReadLbrack);
} break;
case kReadLbrack: { // Try to read a left bracket
Char_t lbrack;
s >> lbrack;
state = (s.bad() ? kEnd : kReadSector);
} break;
case kReadSector: { // Try to read a sector
if (tmp == '*') s.get();
else {
UShort_t sec;
s >> sec;
if (!s.bad()) {
minSector = sec;
maxSector = sec + 1;
}
}
state = (s.bad() ? kEnd : kReadComma);
} break;
case kReadComma: { // Try to read a left bracket
Char_t comma;
s >> comma;
state = (s.bad() ? kEnd : kReadStrip);
} break;
case kReadStrip: { // Try to read a strip
if (tmp == '*') s.get();
else {
UShort_t str;
s >> str;
if (!s.bad()) {
minStrip = str;
maxStrip = str + 1;
}
}
state = (s.bad() ? kEnd : kReadRbrack);
} break;
case kReadRbrack: { // Try to read a left bracket
Char_t rbrack;
s >> rbrack;
state = kEnd;
} break;
case kEnd:
break;
}
}
}
UShort_t* dp = ds;
UShort_t det;
while ((det = *(dp++))) {
Char_t* rp = rs;
Char_t ring;
while ((ring = *(rp++))) {
if (det == 1 && ring == 'O') continue;
UShort_t min = GetMinStrip(det, ring, 0, 0);
UShort_t max = GetMaxStrip(det, ring, 0, 0);
std::cout << "FMD" << det << ring
<< " Strip range: "
<< std::setw(3) << min << ","
<< std::setw(3) << max << std::endl;
UShort_t nSec = ( ring == 'I' ? 20 : 40 );
UShort_t nStr = ( ring == 'I' ? 512 : 256 );
for (UShort_t sec = minSector; sec < maxSector && sec < nSec; sec++) {
UShort_t rate = GetSampleRate(det, ring, sec, 0);
std::cout << "FMD" << det << ring << "[" << std::setw(2) << sec
<< "] sample rate: " << rate << std::endl;
if (!showStrips) continue;
std::cout
<< " Strip | Pedestal | Gain | ZS thr. | Address\n"
<< "--------+-------------------+------------+---------+---------"
<< std::endl;
for (UShort_t str = minStrip; str < nStr && str < maxStrip; str++) {
if (str == minStrip) std::cout << std::setw(3) << sec << ",";
else std::cout << " ";
std::cout << std::setw(3) << str << " | ";
if (IsDead(det, ring, sec, str)) {
std::cout << "dead" << std::endl;
continue;
}
UShort_t ddl, addr, time, sam=0;
Detector2Hardware(det, ring, sec, str, sam, ddl, addr, time);
std::cout << std::setw(7) << GetPedestal(det, ring, sec, str)
<< "+/-" << std::setw(7)
<< GetPedestalWidth(det, ring, sec, str)
<< " | " << std::setw(10)
<< GetPulseGain(det, ring, sec, str)
<< " | " << std::setw(7)
<< GetZeroSuppression(det, ring, sec, str)
<< " | 0x" << std::hex << std::setw(4)
<< std::setfill('0') << ddl << ",0x" << std::setw(3)
<< addr << std::dec << std::setfill(' ') << std::endl;
} // for (strip)
} // for (sector)
std::cout
<< "============================================================="
<< std::endl;
} // while (ring)
} // while (det)
}
//__________________________________________________________________
AliCDBEntry*
AliFMDParameters::GetEntry(const char* path, AliFMDPreprocessor* pp,
Bool_t fatal) const
{
//
// Get an entry from either global AliCDBManager or passed
// AliFMDPreprocessor.
//
// Parameters:
// path Path to CDB object.
// pp AliFMDPreprocessor
// fatal If true, raise a fatal flag if we didn't get the entry.
// Return:
// AliCDBEntry if found
//
AliCDBEntry* entry = 0;
if (!pp) {
AliCDBManager* cdb = AliCDBManager::Instance();
entry = cdb->Get(path);
}
else {
const char* third = gSystem->BaseName(path);
const char* second = gSystem->BaseName(gSystem->DirName(path));
entry = pp->GetFromCDB(second, third);
}
if (!entry) {
TString msg(Form("No %s found in CDB, perhaps you need to "
"use AliFMDCalibFaker?", path));
if (fatal) { AliFatal(msg.Data()); }
else AliLog::Message(AliLog::kWarning, msg.Data(), "FMD",
"AliFMDParameters", "GetEntry", __FILE__,
__LINE__);
return 0;
}
if (entry && AliLog::GetDebugLevel("FMD", "") > 0) {
AliInfoF("Got entry %p for %s", entry, path);
entry->PrintId();
entry->PrintMetaData();
entry->Print();
}
return entry;
}
//__________________________________________________________________
UShort_t
AliFMDParameters::InitPulseGain(AliFMDPreprocessor* pp)
{
//
// Initialize gains. Try to get them from CDB
//
// Parameters:
// pp Pre-processor if called from shuttle
//
AliCDBEntry* gain = GetEntry(fgkPulseGain, pp);
if (!gain) return kPulseGain;
AliFMDDebug(5, ("Got gain from CDB"));
fPulseGain = dynamic_cast<AliFMDCalibGain*>(gain->GetObject());
if (!fPulseGain) {
AliError("Invalid pulser gain object from CDB");
return kPulseGain;
}
if (!fPulseGain->Values().Ptr()) {
AliError("Empty pulser gain object from CDB");
return kPulseGain;
}
return 0;
}
//__________________________________________________________________
UShort_t
AliFMDParameters::InitPedestal(AliFMDPreprocessor* pp)
{
//
// Initialize pedestals. Try to get them from CDB
//
// Parameters:
// pp Pre-processor if called from shuttle
//
AliCDBEntry* pedestal = GetEntry(fgkPedestal, pp);
if (!pedestal) return kPedestal;
AliFMDDebug(5, ("Got pedestal from CDB"));
fPedestal = dynamic_cast<AliFMDCalibPedestal*>(pedestal->GetObject());
if (!fPedestal) {
AliError("Invalid pedestal object from CDB");
return kPedestal;
}
if (!fPedestal->Values().Ptr()) {
AliError("Empty pedestal object from CDB");
return kPedestal;
}
return 0;
}
//__________________________________________________________________
UShort_t
AliFMDParameters::InitDeadMap(AliFMDPreprocessor* pp)
{
//
// Initialize dead map. Try to get it from CDB
//
// Parameters:
// pp Pre-processor if called from shuttle
//
AliCDBEntry* deadMap = GetEntry(fgkDead, pp);
if (!deadMap) return kDeadMap;
AliFMDDebug(5, ("Got dead map from CDB"));
fDeadMap = dynamic_cast<AliFMDCalibDeadMap*>(deadMap->GetObject());
if (!fDeadMap) {
AliError("Invalid dead map object from CDB");
return kDeadMap;
}
if (!fDeadMap->Ptr()) {
AliError("Empty dead map object from CDB");
return kDeadMap;
}
return 0;
}
//__________________________________________________________________
UShort_t
AliFMDParameters::InitZeroSuppression(AliFMDPreprocessor* pp)
{
//
// Initialize zero suppression thresholds. Try to get them from CDB
//
// Parameters:
// pp Pre-processor if called from shuttle
//
AliCDBEntry* zeroSup = GetEntry(fgkZeroSuppression, pp);
if (!zeroSup) return kZeroSuppression;
AliFMDDebug(5, ("Got zero suppression from CDB"));
fZeroSuppression =
dynamic_cast<AliFMDCalibZeroSuppression*>(zeroSup->GetObject());
if (!fZeroSuppression) {
AliError("Invalid zero suppression object from CDB");
return kZeroSuppression;
}
if (!fZeroSuppression->Ptr()) {
AliWarningF("Empty zero suppression object from CDB, assuming %d",
fFixedZeroSuppression);
AliCDBManager* cdbMan = AliCDBManager::Instance();
if(!cdbMan || !cdbMan->GetCacheFlag())
delete fZeroSuppression;
fZeroSuppression = 0;
}
return 0;
}
//__________________________________________________________________
UShort_t
AliFMDParameters::InitSampleRate(AliFMDPreprocessor* pp)
{
//
// Initialize sample rates. Try to get them from CDB
//
// Parameters:
// pp Pre-processor if called from shuttle
//
AliCDBEntry* sampRat = GetEntry(fgkSampleRate, pp);
if (!sampRat) return kSampleRate;
AliFMDDebug(5, ("Got zero suppression from CDB"));
fSampleRate = dynamic_cast<AliFMDCalibSampleRate*>(sampRat->GetObject());
if (!fSampleRate) {
AliError("Invalid sample rate object from CDB");
return kSampleRate;
}
if (!fSampleRate->Rates().Ptr()) {
AliError("empty sample rate object from CDB");
return kSampleRate;
}
return 0;
}
//__________________________________________________________________
UShort_t
AliFMDParameters::InitAltroMap(AliFMDPreprocessor* pp)
{
//
// Initialize hardware map. Try to get it from CDB
//
// Parameters:
// pp Pre-processor if called from shuttle
//
if (fAltroMap && fAltroMap->TestBit(TObject::kCanDelete)) {
// Let's remove it from possible CDB manager cache
AliCDBManager::Instance()->UnloadFromCache(fgkAltroMap);
delete fAltroMap;
fAltroMap = 0;
}
AliCDBEntry* hwMap = GetEntry(fgkAltroMap, pp, kFALSE);
if (hwMap && hwMap->GetObject()) {
AliFMDDebug(5, ("Got ALTRO map from CDB"));
fAltroMap = dynamic_cast<AliFMDAltroMapping*>(hwMap->GetObject());
if (fAltroMap) fAltroMap->ResetBit(TObject::kCanDelete);
}
if (!fAltroMap) {
AliError("Invalid ALTRO map object from CDB");
fAltroMap = new AliFMDAltroMapping;
fAltroMap->SetBit(TObject::kCanDelete);
// return kAltroMap;
}
return 0;
}
//__________________________________________________________________
UShort_t
AliFMDParameters::InitStripRange(AliFMDPreprocessor* pp)
{
//
// Initialize strip range. Try to get it from CDB
//
// Parameters:
// pp Pre-processor if called from shuttle
//
AliCDBEntry* range = GetEntry(fgkStripRange, pp);
if (!range) return kStripRange;
AliFMDDebug(5, ("Got strip range from CDB"));
fStripRange = dynamic_cast<AliFMDCalibStripRange*>(range->GetObject());
if (!fStripRange) {
AliError("Invalid strip range object from CDB");
return kStripRange;
}
if (!fStripRange->Ranges().Ptr()) {
AliError("Empty strip range object from CDB");
return kStripRange;
}
return 0;
}
//__________________________________________________________________
Float_t
AliFMDParameters::GetThreshold() const
{
//
// Get the threshold in the pulser gain
//
//
// Return:
// Threshold from pulser
//
if (!fPulseGain) return fFixedThreshold;
return fPulseGain->Threshold();
}
//__________________________________________________________________
Float_t
AliFMDParameters::GetPulseGain(UShort_t detector, Char_t ring,
UShort_t sector, UShort_t strip) const
{
//
// Gain of pre-amp. for strip, sector, ring, detector
//
// For simulations this is normally set to
//
// @f[
// \frac{\mbox{VA1_MIP_Range}{\mbox{ALTRO_channel_size}}\mbox{MIP_Energy_Loss}
// @f]
//
//
// Parameters:
// detector Detector # (1-3)
// ring Ring ID ('I' or 'O')
// sector Sector number (0-39)
// strip Strip number (0-511)
//
// Return:
// Gain of pre-amp.
//
if (!fPulseGain) {
if (fFixedPulseGain <= 0)
fFixedPulseGain = fVA1MipRange * GetEdepMip() / fAltroChannelSize;
return fFixedPulseGain;
}
AliFMDDebug(50, ("pulse gain for FMD%d%c[%2d,%3d]=%f",
detector, ring, sector, strip,
fPulseGain->Value(detector, ring, sector, strip)));
return fPulseGain->Value(detector, ring, sector, strip);
}
//__________________________________________________________________
Bool_t
AliFMDParameters::IsDead(UShort_t detector, Char_t ring,
UShort_t sector, UShort_t strip) const
{
//
// Whether the strip is considered dead
//
// Parameters:
// detector Detector # (1-3)
// ring Ring ID ('I' or 'O')
// sector Sector number (0-39)
// strip Strip number (0-511)
//
// Return:
// @c true if the strip is considered dead, @c false if it's
// OK.
//
if (!fDeadMap) return kFALSE;
AliFMDDebug(50, ("Dead for FMD%d%c[%2d,%3d]=%s",
detector, ring, sector, strip,
fDeadMap->operator()(detector, ring, sector, strip) ?
"no" : "yes"));
return fDeadMap->operator()(detector, ring, sector, strip);
}
//__________________________________________________________________
UShort_t
AliFMDParameters::GetZeroSuppression(UShort_t detector, Char_t ring,
UShort_t sector, UShort_t strip) const
{
//
// zero suppression threshold (in ADC counts)
//
// Parameters:
// detector Detector # (1-3)
// ring Ring ID ('I' or 'O')
// sector Sector number (0-39)
// strip Strip number (0-511)
//
// Return:
// zero suppression threshold (in ADC counts)
//
if (!fZeroSuppression) return fFixedZeroSuppression;
// In case of empty zero suppression objects.
if (!fZeroSuppression->Ptr() ||
fZeroSuppression->MaxIndex() <= 0) return fFixedZeroSuppression;
// Need to map strip to ALTRO chip.
AliFMDDebug(50, ("zero sup. for FMD%d%c[%2d,%3d]=%d",
detector, ring, sector, strip,
fZeroSuppression->operator()(detector, ring,
sector, strip)));
return fZeroSuppression->operator()(detector, ring, sector, strip/128);
}
//__________________________________________________________________
UShort_t
AliFMDParameters::GetSampleRate(UShort_t det, Char_t ring, UShort_t sector,
UShort_t str) const
{
//
// Get the sampling rate
//
// Parameters:
// detector Detector # (1-3)
// ring Ring ID ('I' or 'O')
// sector Sector number (0-39)
// strip Strip number (0-511)
//
// Return:
// The sampling rate
//
if (!fSampleRate) return fFixedSampleRate;
// Need to map sector to digitizier card.
UInt_t ret = fSampleRate->Rate(det, ring, sector, str);
AliFMDDebug(50, ("Sample rate for FMD%d%c[%2d,%3d]=%d",
det, ring, sector, str, ret));
return ret;
}
//__________________________________________________________________
UShort_t
AliFMDParameters::GetMinStrip(UShort_t det, Char_t ring, UShort_t sector,
UShort_t str) const
{
//
// Get the minimum strip in the read-out range
//
// Parameters:
// detector Detector # (1-3)
// ring Ring ID ('I' or 'O')
// sector Sector number (0-39)
// strip Strip number (0-511)
//
// Return:
// Minimum strip
//
if (!fStripRange) return fFixedMinStrip;
// Need to map sector to digitizier card.
UInt_t ret = fStripRange->Min(det, ring, sector, str);
AliFMDDebug(50, ("Min strip # for FMD%d%c[%2d,%3d]=%d",
det, ring, sector, str, ret));
return ret;
}
//__________________________________________________________________
UShort_t
AliFMDParameters::GetMaxStrip(UShort_t det, Char_t ring, UShort_t sector,
UShort_t str) const
{
//
// Get the maximum strip in the read-out range
//
// Parameters:
// detector Detector # (1-3)
// ring Ring ID ('I' or 'O')
// sector Sector number (0-39)
// strip Strip number (0-511)
//
// Return:
// Maximum strip
//
if (!fStripRange) return fFixedMaxStrip;
// Need to map sector to digitizier card.
UInt_t ret = fStripRange->Max(det, ring, sector, str);
AliFMDDebug(50, ("Max strip # for FMD%d%c[%2d,%3d]=%d",
det, ring, sector, str, ret));
return ret;
}
//__________________________________________________________________
Float_t
AliFMDParameters::GetPedestal(UShort_t detector, Char_t ring,
UShort_t sector, UShort_t strip) const
{
//
// Get mean of pedestal
//
// Parameters:
// detector Detector # (1-3)
// ring Ring ID ('I' or 'O')
// sector Sector number (0-39)
// strip Strip number (0-511)
//
// Return:
// Mean of pedestal
//
if (!fPedestal) return fFixedPedestal;
AliFMDDebug(50, ("pedestal for FMD%d%c[%2d,%3d]=%f",
detector, ring, sector, strip,
fPedestal->Value(detector, ring, sector, strip)));
return fPedestal->Value(detector, ring, sector, strip);
}
//__________________________________________________________________
Float_t
AliFMDParameters::GetPedestalWidth(UShort_t detector, Char_t ring,
UShort_t sector, UShort_t strip) const
{
//
// Width of pedestal
//
// Parameters:
// detector Detector # (1-3)
// ring Ring ID ('I' or 'O')
// sector Sector number (0-39)
// strip Strip number (0-511)
//
// Return:
// Width of pedestal
//
if (!fPedestal) return fFixedPedestalWidth;
AliFMDDebug(50, ("pedetal width for FMD%d%c[%2d,%3d]=%f",
detector, ring, sector, strip,
fPedestal->Width(detector, ring, sector, strip)));
return fPedestal->Width(detector, ring, sector, strip);
}
//__________________________________________________________________
AliFMDAltroMapping*
AliFMDParameters::GetAltroMap() const
{
//
// Get the map that translates hardware to detector coordinates
//
// Return:
// Get the map that translates hardware to detector
// coordinates
//
return fAltroMap;
}
//____________________________________________________________________
Bool_t
AliFMDParameters::Hardware2Detector(UShort_t ddl, UShort_t addr,
UShort_t timebin,
UShort_t& det, Char_t& ring,
UShort_t& sec, Short_t& str,
UShort_t& sam) const
{
//
// Map a hardware address into a detector index.
//
// Parameters:
// ddl Hardware DDL number
// addr Hardware address.
// timebin Timebin
// det On return, the detector #
// ring On return, the ring ID
// sec On return, the sector #
// str On return, the base of strip #
// sam On return, the sample number for this strip
//
// Return:
// @c true on success, false otherwise
//
if (!fAltroMap) return kFALSE;
UShort_t board, chip, chan;
fAltroMap->ChannelAddress(addr, board, chip, chan);
return Hardware2Detector(ddl,board,chip,chan,timebin,det,ring,sec,str,sam);
}
//____________________________________________________________________
Bool_t
AliFMDParameters::Hardware2Detector(UShort_t ddl, UShort_t board,
UShort_t chip, UShort_t chan,
UShort_t timebin,
UShort_t& det, Char_t& ring,
UShort_t& sec, Short_t& str,
UShort_t& sam) const
{
//
// Map a hardware address into a detector index.
//
// Parameters:
// ddl Hardware DDL number
// board FEC number
// altro ALTRO number
// channel Channel number
// timebin Timebin
// det On return, the detector #
// ring On return, the ring ID
// sec On return, the sector #
// str On return, the base of strip #
// sam On return, the sample number for this strip
//
// Return:
// @c true on success, false otherwise
//
if (!fAltroMap) {
AliFMDDebug(1, ("No ALTRO map available"));
return kFALSE;
}
if (fAltroMap->DDL2Detector(ddl) < 0) {
AliFMDDebug(1, ("Invalid DDL number %d", ddl));
return kFALSE;
}
det = fAltroMap->DDL2Detector(ddl);
Short_t stripBase = 0;
if (!fAltroMap->Channel2StripBase(board,chip,chan, ring, sec, stripBase)) {
AliFMDDebug(1, ("Failed to translate "
"%d/0x%02x/0x%x/0x%x/%04d -> "
"FMD%d%c[%2d,%3d] to detector",
ddl, board, chip, chan, timebin,
det, ring, sec, stripBase));
return kFALSE;
}
UShort_t preSamples = GetPreSamples(det, ring, sec, stripBase);
UShort_t sampleRate = GetSampleRate(det, ring, sec, stripBase);
Short_t stripOff = 0;
fAltroMap->Timebin2Strip(sec, timebin, preSamples, sampleRate, stripOff, sam);
str = stripBase + stripOff;
AliFMDDebug(50, ("%d/0x%02x/0x%x/0x%x/%04d -> FMD%d%c[%02d,%03d]-%d"
" (pre=%2d, rate=%d)",
ddl, board, chip, chan, timebin,
det, ring, sec, str, sam, preSamples, sampleRate));
return kTRUE;
}
//____________________________________________________________________
Bool_t
AliFMDParameters::Detector2Hardware(UShort_t det, Char_t ring,
UShort_t sec, UShort_t str,
UShort_t sam,
UShort_t& ddl, UShort_t& board,
UShort_t& altro, UShort_t& channel,
UShort_t& timebin) const
{
//
// Map a detector index into a hardware address.
//
// Parameters:
// det The detector #
// ring The ring ID
// sec The sector #
// str The strip #
// sam The sample number
// ddl On return, hardware DDL number
// board On return, the FEC board address (local to DDL)
// altro On return, the ALTRO number (local to FEC)
// channel On return, the channel number (local to ALTRO)
// timebin On return, the timebin number (local to ALTRO)
//
// Return:
// @c true on success, false otherwise
//
if (!fAltroMap) {
AliFMDDebug(1, ("No ALTRO map available"));
return kFALSE;
}
UShort_t preSamples = GetPreSamples(det, ring, sec, str);
UShort_t sampleRate = GetSampleRate(det, ring, sec, str);
UShort_t strip = str - GetMinStrip(det,ring,sec,str);
return fAltroMap->Detector2Hardware(det, ring, sec, strip, sam,
preSamples, sampleRate,
ddl, board, altro, channel, timebin);
}
//____________________________________________________________________
Bool_t
AliFMDParameters::Detector2Hardware(UShort_t det, Char_t ring,
UShort_t sec, UShort_t str,
UShort_t sam,
UShort_t& ddl, UShort_t& addr,
UShort_t& timebin) const
{
//
// Map a detector index into a hardware address.
//
// Parameters:
// det The detector #
// ring The ring ID
// sec The sector #
// str The strip #
// sam The sample number
// ddl On return, hardware DDL number
// addr On return, hardware address.
// timebin On return, the timebin number (local to ALTRO)
//
// Return:
// @c true on success, false otherwise
//
if (!fAltroMap) return kFALSE;
UShort_t preSamples = GetPreSamples(det, ring, sec, str);
UShort_t sampleRate = GetSampleRate(det, ring, sec, str);
UShort_t strip = str - GetMinStrip(det,ring,sec,str);
return fAltroMap->Detector2Hardware(det, ring, sec, strip, sam,
preSamples, sampleRate,
ddl, addr, timebin);
}
//__________________________________________________________________
Float_t
AliFMDParameters::GetEdepMip() const
{
//
// Return:
// The average energy deposited by one MIP
//
if (fEdepMip <= 0){
AliFMDGeometry* fmd = AliFMDGeometry::Instance();
fEdepMip = (fkSiDeDxMip
* fmd->GetRing('I')->GetSiThickness()
* fmd->GetSiDensity());
}
return fEdepMip;
}
//____________________________________________________________________
Float_t
AliFMDParameters::GetDACPerMIP() const
{
//
// This is the conversion from Digital-to-Analog-Converter setting
// to the number of MIPs. The number was measured in the NBI lab during
// August 2008.
//
// Return:
// The conversion factor from DAC to ADC
//
return 29.67;
}
//____________________________________________________________________
//
// EOF
//
|
// Quick reset
origin 0x109FB8
base 0x8018D0C8
jal QuickReset
origin 0x10B204
base 0x8018E314
j SkipResults
nop
SkipResults_Return:
pullvar pc, origin
scope QuickReset: {
Input:
lui t0, 0x8004
lli t1, 0xF010 // A, B, Z, R, Start
lli t2, 0x04 // Loop counter
Loop:
lhu t3, 0x5228 (t0) // Input
beq t3, t1, Reset // If input == A, B, Z, R, Start; skip results screen
addiu t2, -0x01 // Decrement loop counter
bnez t2, Loop // Break if loop counter == 0
addiu t0, 0x0A // Update pointer
b End
nop
Reset:
lui t0, 0x800A
lli t1, 0x02 // Skip results screen
sb t1, 0x4AE2 (t0)
lli t1, 0x07 // Reset
sb t1, 0x4D19 (t0)
End:
j 0x8011485C
nop
}
scope SkipResults: {
lli t6, 0x18 // Original instruction
lui t0, 0x800A
lbu t0, 0x4AE2 (t0) // Result
lli t1, 0x02
bne t0, t1, End // If result == skip
nop
lli t6, 0x10 // Skip results screen
End:
j SkipResults_Return
sb t6, 0 (v0) // Original instruction
}
pushvar origin, pc
|
_ln: file format elf32-i386
Disassembly of section .text:
00000000 <main>:
#include "stat.h"
#include "user.h"
int
main(int argc, char *argv[])
{
0: 8d 4c 24 04 lea 0x4(%esp),%ecx
4: 83 e4 f0 and $0xfffffff0,%esp
if(argc != 3){
7: 83 39 03 cmpl $0x3,(%ecx)
{
a: ff 71 fc pushl -0x4(%ecx)
d: 55 push %ebp
e: 89 e5 mov %esp,%ebp
10: 53 push %ebx
11: 51 push %ecx
12: 8b 59 04 mov 0x4(%ecx),%ebx
if(argc != 3){
15: 74 13 je 2a <main+0x2a>
printf(2, "Usage: ln old new\n");
17: 52 push %edx
18: 52 push %edx
19: 68 68 07 00 00 push $0x768
1e: 6a 02 push $0x2
20: e8 eb 03 00 00 call 410 <printf>
exit();
25: e8 88 02 00 00 call 2b2 <exit>
}
if(link(argv[1], argv[2]) < 0)
2a: 50 push %eax
2b: 50 push %eax
2c: ff 73 08 pushl 0x8(%ebx)
2f: ff 73 04 pushl 0x4(%ebx)
32: e8 db 02 00 00 call 312 <link>
37: 83 c4 10 add $0x10,%esp
3a: 85 c0 test %eax,%eax
3c: 78 05 js 43 <main+0x43>
printf(2, "link %s %s: failed\n", argv[1], argv[2]);
exit();
3e: e8 6f 02 00 00 call 2b2 <exit>
printf(2, "link %s %s: failed\n", argv[1], argv[2]);
43: ff 73 08 pushl 0x8(%ebx)
46: ff 73 04 pushl 0x4(%ebx)
49: 68 7b 07 00 00 push $0x77b
4e: 6a 02 push $0x2
50: e8 bb 03 00 00 call 410 <printf>
55: 83 c4 10 add $0x10,%esp
58: eb e4 jmp 3e <main+0x3e>
5a: 66 90 xchg %ax,%ax
5c: 66 90 xchg %ax,%ax
5e: 66 90 xchg %ax,%ax
00000060 <strcpy>:
60: 55 push %ebp
61: 89 e5 mov %esp,%ebp
63: 53 push %ebx
64: 8b 45 08 mov 0x8(%ebp),%eax
67: 8b 4d 0c mov 0xc(%ebp),%ecx
6a: 89 c2 mov %eax,%edx
6c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
70: 83 c1 01 add $0x1,%ecx
73: 0f b6 59 ff movzbl -0x1(%ecx),%ebx
77: 83 c2 01 add $0x1,%edx
7a: 84 db test %bl,%bl
7c: 88 5a ff mov %bl,-0x1(%edx)
7f: 75 ef jne 70 <strcpy+0x10>
81: 5b pop %ebx
82: 5d pop %ebp
83: c3 ret
84: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
8a: 8d bf 00 00 00 00 lea 0x0(%edi),%edi
00000090 <strcmp>:
90: 55 push %ebp
91: 89 e5 mov %esp,%ebp
93: 53 push %ebx
94: 8b 55 08 mov 0x8(%ebp),%edx
97: 8b 4d 0c mov 0xc(%ebp),%ecx
9a: 0f b6 02 movzbl (%edx),%eax
9d: 0f b6 19 movzbl (%ecx),%ebx
a0: 84 c0 test %al,%al
a2: 75 1c jne c0 <strcmp+0x30>
a4: eb 2a jmp d0 <strcmp+0x40>
a6: 8d 76 00 lea 0x0(%esi),%esi
a9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
b0: 83 c2 01 add $0x1,%edx
b3: 0f b6 02 movzbl (%edx),%eax
b6: 83 c1 01 add $0x1,%ecx
b9: 0f b6 19 movzbl (%ecx),%ebx
bc: 84 c0 test %al,%al
be: 74 10 je d0 <strcmp+0x40>
c0: 38 d8 cmp %bl,%al
c2: 74 ec je b0 <strcmp+0x20>
c4: 29 d8 sub %ebx,%eax
c6: 5b pop %ebx
c7: 5d pop %ebp
c8: c3 ret
c9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
d0: 31 c0 xor %eax,%eax
d2: 29 d8 sub %ebx,%eax
d4: 5b pop %ebx
d5: 5d pop %ebp
d6: c3 ret
d7: 89 f6 mov %esi,%esi
d9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
000000e0 <strlen>:
e0: 55 push %ebp
e1: 89 e5 mov %esp,%ebp
e3: 8b 4d 08 mov 0x8(%ebp),%ecx
e6: 80 39 00 cmpb $0x0,(%ecx)
e9: 74 15 je 100 <strlen+0x20>
eb: 31 d2 xor %edx,%edx
ed: 8d 76 00 lea 0x0(%esi),%esi
f0: 83 c2 01 add $0x1,%edx
f3: 80 3c 11 00 cmpb $0x0,(%ecx,%edx,1)
f7: 89 d0 mov %edx,%eax
f9: 75 f5 jne f0 <strlen+0x10>
fb: 5d pop %ebp
fc: c3 ret
fd: 8d 76 00 lea 0x0(%esi),%esi
100: 31 c0 xor %eax,%eax
102: 5d pop %ebp
103: c3 ret
104: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
10a: 8d bf 00 00 00 00 lea 0x0(%edi),%edi
00000110 <memset>:
110: 55 push %ebp
111: 89 e5 mov %esp,%ebp
113: 57 push %edi
114: 8b 55 08 mov 0x8(%ebp),%edx
117: 8b 4d 10 mov 0x10(%ebp),%ecx
11a: 8b 45 0c mov 0xc(%ebp),%eax
11d: 89 d7 mov %edx,%edi
11f: fc cld
120: f3 aa rep stos %al,%es:(%edi)
122: 89 d0 mov %edx,%eax
124: 5f pop %edi
125: 5d pop %ebp
126: c3 ret
127: 89 f6 mov %esi,%esi
129: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
00000130 <strchr>:
130: 55 push %ebp
131: 89 e5 mov %esp,%ebp
133: 53 push %ebx
134: 8b 45 08 mov 0x8(%ebp),%eax
137: 8b 5d 0c mov 0xc(%ebp),%ebx
13a: 0f b6 10 movzbl (%eax),%edx
13d: 84 d2 test %dl,%dl
13f: 74 1d je 15e <strchr+0x2e>
141: 38 d3 cmp %dl,%bl
143: 89 d9 mov %ebx,%ecx
145: 75 0d jne 154 <strchr+0x24>
147: eb 17 jmp 160 <strchr+0x30>
149: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
150: 38 ca cmp %cl,%dl
152: 74 0c je 160 <strchr+0x30>
154: 83 c0 01 add $0x1,%eax
157: 0f b6 10 movzbl (%eax),%edx
15a: 84 d2 test %dl,%dl
15c: 75 f2 jne 150 <strchr+0x20>
15e: 31 c0 xor %eax,%eax
160: 5b pop %ebx
161: 5d pop %ebp
162: c3 ret
163: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
169: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
00000170 <gets>:
170: 55 push %ebp
171: 89 e5 mov %esp,%ebp
173: 57 push %edi
174: 56 push %esi
175: 53 push %ebx
176: 31 f6 xor %esi,%esi
178: 89 f3 mov %esi,%ebx
17a: 83 ec 1c sub $0x1c,%esp
17d: 8b 7d 08 mov 0x8(%ebp),%edi
180: eb 2f jmp 1b1 <gets+0x41>
182: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
188: 8d 45 e7 lea -0x19(%ebp),%eax
18b: 83 ec 04 sub $0x4,%esp
18e: 6a 01 push $0x1
190: 50 push %eax
191: 6a 00 push $0x0
193: e8 32 01 00 00 call 2ca <read>
198: 83 c4 10 add $0x10,%esp
19b: 85 c0 test %eax,%eax
19d: 7e 1c jle 1bb <gets+0x4b>
19f: 0f b6 45 e7 movzbl -0x19(%ebp),%eax
1a3: 83 c7 01 add $0x1,%edi
1a6: 88 47 ff mov %al,-0x1(%edi)
1a9: 3c 0a cmp $0xa,%al
1ab: 74 23 je 1d0 <gets+0x60>
1ad: 3c 0d cmp $0xd,%al
1af: 74 1f je 1d0 <gets+0x60>
1b1: 83 c3 01 add $0x1,%ebx
1b4: 3b 5d 0c cmp 0xc(%ebp),%ebx
1b7: 89 fe mov %edi,%esi
1b9: 7c cd jl 188 <gets+0x18>
1bb: 89 f3 mov %esi,%ebx
1bd: 8b 45 08 mov 0x8(%ebp),%eax
1c0: c6 03 00 movb $0x0,(%ebx)
1c3: 8d 65 f4 lea -0xc(%ebp),%esp
1c6: 5b pop %ebx
1c7: 5e pop %esi
1c8: 5f pop %edi
1c9: 5d pop %ebp
1ca: c3 ret
1cb: 90 nop
1cc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
1d0: 8b 75 08 mov 0x8(%ebp),%esi
1d3: 8b 45 08 mov 0x8(%ebp),%eax
1d6: 01 de add %ebx,%esi
1d8: 89 f3 mov %esi,%ebx
1da: c6 03 00 movb $0x0,(%ebx)
1dd: 8d 65 f4 lea -0xc(%ebp),%esp
1e0: 5b pop %ebx
1e1: 5e pop %esi
1e2: 5f pop %edi
1e3: 5d pop %ebp
1e4: c3 ret
1e5: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
1e9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
000001f0 <stat>:
1f0: 55 push %ebp
1f1: 89 e5 mov %esp,%ebp
1f3: 56 push %esi
1f4: 53 push %ebx
1f5: 83 ec 08 sub $0x8,%esp
1f8: 6a 00 push $0x0
1fa: ff 75 08 pushl 0x8(%ebp)
1fd: e8 f0 00 00 00 call 2f2 <open>
202: 83 c4 10 add $0x10,%esp
205: 85 c0 test %eax,%eax
207: 78 27 js 230 <stat+0x40>
209: 83 ec 08 sub $0x8,%esp
20c: ff 75 0c pushl 0xc(%ebp)
20f: 89 c3 mov %eax,%ebx
211: 50 push %eax
212: e8 f3 00 00 00 call 30a <fstat>
217: 89 1c 24 mov %ebx,(%esp)
21a: 89 c6 mov %eax,%esi
21c: e8 b9 00 00 00 call 2da <close>
221: 83 c4 10 add $0x10,%esp
224: 8d 65 f8 lea -0x8(%ebp),%esp
227: 89 f0 mov %esi,%eax
229: 5b pop %ebx
22a: 5e pop %esi
22b: 5d pop %ebp
22c: c3 ret
22d: 8d 76 00 lea 0x0(%esi),%esi
230: be ff ff ff ff mov $0xffffffff,%esi
235: eb ed jmp 224 <stat+0x34>
237: 89 f6 mov %esi,%esi
239: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
00000240 <atoi>:
240: 55 push %ebp
241: 89 e5 mov %esp,%ebp
243: 53 push %ebx
244: 8b 4d 08 mov 0x8(%ebp),%ecx
247: 0f be 11 movsbl (%ecx),%edx
24a: 8d 42 d0 lea -0x30(%edx),%eax
24d: 3c 09 cmp $0x9,%al
24f: b8 00 00 00 00 mov $0x0,%eax
254: 77 1f ja 275 <atoi+0x35>
256: 8d 76 00 lea 0x0(%esi),%esi
259: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
260: 8d 04 80 lea (%eax,%eax,4),%eax
263: 83 c1 01 add $0x1,%ecx
266: 8d 44 42 d0 lea -0x30(%edx,%eax,2),%eax
26a: 0f be 11 movsbl (%ecx),%edx
26d: 8d 5a d0 lea -0x30(%edx),%ebx
270: 80 fb 09 cmp $0x9,%bl
273: 76 eb jbe 260 <atoi+0x20>
275: 5b pop %ebx
276: 5d pop %ebp
277: c3 ret
278: 90 nop
279: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
00000280 <memmove>:
280: 55 push %ebp
281: 89 e5 mov %esp,%ebp
283: 56 push %esi
284: 53 push %ebx
285: 8b 5d 10 mov 0x10(%ebp),%ebx
288: 8b 45 08 mov 0x8(%ebp),%eax
28b: 8b 75 0c mov 0xc(%ebp),%esi
28e: 85 db test %ebx,%ebx
290: 7e 14 jle 2a6 <memmove+0x26>
292: 31 d2 xor %edx,%edx
294: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
298: 0f b6 0c 16 movzbl (%esi,%edx,1),%ecx
29c: 88 0c 10 mov %cl,(%eax,%edx,1)
29f: 83 c2 01 add $0x1,%edx
2a2: 39 d3 cmp %edx,%ebx
2a4: 75 f2 jne 298 <memmove+0x18>
2a6: 5b pop %ebx
2a7: 5e pop %esi
2a8: 5d pop %ebp
2a9: c3 ret
000002aa <fork>:
2aa: b8 01 00 00 00 mov $0x1,%eax
2af: cd 40 int $0x40
2b1: c3 ret
000002b2 <exit>:
2b2: b8 02 00 00 00 mov $0x2,%eax
2b7: cd 40 int $0x40
2b9: c3 ret
000002ba <wait>:
2ba: b8 03 00 00 00 mov $0x3,%eax
2bf: cd 40 int $0x40
2c1: c3 ret
000002c2 <pipe>:
2c2: b8 04 00 00 00 mov $0x4,%eax
2c7: cd 40 int $0x40
2c9: c3 ret
000002ca <read>:
2ca: b8 05 00 00 00 mov $0x5,%eax
2cf: cd 40 int $0x40
2d1: c3 ret
000002d2 <write>:
2d2: b8 10 00 00 00 mov $0x10,%eax
2d7: cd 40 int $0x40
2d9: c3 ret
000002da <close>:
2da: b8 15 00 00 00 mov $0x15,%eax
2df: cd 40 int $0x40
2e1: c3 ret
000002e2 <kill>:
2e2: b8 06 00 00 00 mov $0x6,%eax
2e7: cd 40 int $0x40
2e9: c3 ret
000002ea <exec>:
2ea: b8 07 00 00 00 mov $0x7,%eax
2ef: cd 40 int $0x40
2f1: c3 ret
000002f2 <open>:
2f2: b8 0f 00 00 00 mov $0xf,%eax
2f7: cd 40 int $0x40
2f9: c3 ret
000002fa <mknod>:
2fa: b8 11 00 00 00 mov $0x11,%eax
2ff: cd 40 int $0x40
301: c3 ret
00000302 <unlink>:
302: b8 12 00 00 00 mov $0x12,%eax
307: cd 40 int $0x40
309: c3 ret
0000030a <fstat>:
30a: b8 08 00 00 00 mov $0x8,%eax
30f: cd 40 int $0x40
311: c3 ret
00000312 <link>:
312: b8 13 00 00 00 mov $0x13,%eax
317: cd 40 int $0x40
319: c3 ret
0000031a <mkdir>:
31a: b8 14 00 00 00 mov $0x14,%eax
31f: cd 40 int $0x40
321: c3 ret
00000322 <chdir>:
322: b8 09 00 00 00 mov $0x9,%eax
327: cd 40 int $0x40
329: c3 ret
0000032a <dup>:
32a: b8 0a 00 00 00 mov $0xa,%eax
32f: cd 40 int $0x40
331: c3 ret
00000332 <getpid>:
332: b8 0b 00 00 00 mov $0xb,%eax
337: cd 40 int $0x40
339: c3 ret
0000033a <sbrk>:
33a: b8 0c 00 00 00 mov $0xc,%eax
33f: cd 40 int $0x40
341: c3 ret
00000342 <sleep>:
342: b8 0d 00 00 00 mov $0xd,%eax
347: cd 40 int $0x40
349: c3 ret
0000034a <uptime>:
34a: b8 0e 00 00 00 mov $0xe,%eax
34f: cd 40 int $0x40
351: c3 ret
00000352 <getNumProc>:
352: b8 16 00 00 00 mov $0x16,%eax
357: cd 40 int $0x40
359: c3 ret
0000035a <chpr>:
35a: b8 17 00 00 00 mov $0x17,%eax
35f: cd 40 int $0x40
361: c3 ret
362: 66 90 xchg %ax,%ax
364: 66 90 xchg %ax,%ax
366: 66 90 xchg %ax,%ax
368: 66 90 xchg %ax,%ax
36a: 66 90 xchg %ax,%ax
36c: 66 90 xchg %ax,%ax
36e: 66 90 xchg %ax,%ax
00000370 <printint>:
write(fd, &c, 1);
}
static void
printint(int fd, int xx, int base, int sgn)
{
370: 55 push %ebp
371: 89 e5 mov %esp,%ebp
373: 57 push %edi
374: 56 push %esi
375: 53 push %ebx
376: 83 ec 3c sub $0x3c,%esp
char buf[16];
int i, neg;
uint x;
neg = 0;
if(sgn && xx < 0){
379: 85 d2 test %edx,%edx
{
37b: 89 45 c0 mov %eax,-0x40(%ebp)
neg = 1;
x = -xx;
37e: 89 d0 mov %edx,%eax
if(sgn && xx < 0){
380: 79 76 jns 3f8 <printint+0x88>
382: f6 45 08 01 testb $0x1,0x8(%ebp)
386: 74 70 je 3f8 <printint+0x88>
x = -xx;
388: f7 d8 neg %eax
neg = 1;
38a: c7 45 c4 01 00 00 00 movl $0x1,-0x3c(%ebp)
} else {
x = xx;
}
i = 0;
391: 31 f6 xor %esi,%esi
393: 8d 5d d7 lea -0x29(%ebp),%ebx
396: eb 0a jmp 3a2 <printint+0x32>
398: 90 nop
399: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
do{
buf[i++] = digits[x % base];
3a0: 89 fe mov %edi,%esi
3a2: 31 d2 xor %edx,%edx
3a4: 8d 7e 01 lea 0x1(%esi),%edi
3a7: f7 f1 div %ecx
3a9: 0f b6 92 98 07 00 00 movzbl 0x798(%edx),%edx
}while((x /= base) != 0);
3b0: 85 c0 test %eax,%eax
buf[i++] = digits[x % base];
3b2: 88 14 3b mov %dl,(%ebx,%edi,1)
}while((x /= base) != 0);
3b5: 75 e9 jne 3a0 <printint+0x30>
if(neg)
3b7: 8b 45 c4 mov -0x3c(%ebp),%eax
3ba: 85 c0 test %eax,%eax
3bc: 74 08 je 3c6 <printint+0x56>
buf[i++] = '-';
3be: c6 44 3d d8 2d movb $0x2d,-0x28(%ebp,%edi,1)
3c3: 8d 7e 02 lea 0x2(%esi),%edi
3c6: 8d 74 3d d7 lea -0x29(%ebp,%edi,1),%esi
3ca: 8b 7d c0 mov -0x40(%ebp),%edi
3cd: 8d 76 00 lea 0x0(%esi),%esi
3d0: 0f b6 06 movzbl (%esi),%eax
write(fd, &c, 1);
3d3: 83 ec 04 sub $0x4,%esp
3d6: 83 ee 01 sub $0x1,%esi
3d9: 6a 01 push $0x1
3db: 53 push %ebx
3dc: 57 push %edi
3dd: 88 45 d7 mov %al,-0x29(%ebp)
3e0: e8 ed fe ff ff call 2d2 <write>
while(--i >= 0)
3e5: 83 c4 10 add $0x10,%esp
3e8: 39 de cmp %ebx,%esi
3ea: 75 e4 jne 3d0 <printint+0x60>
putc(fd, buf[i]);
}
3ec: 8d 65 f4 lea -0xc(%ebp),%esp
3ef: 5b pop %ebx
3f0: 5e pop %esi
3f1: 5f pop %edi
3f2: 5d pop %ebp
3f3: c3 ret
3f4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
neg = 0;
3f8: c7 45 c4 00 00 00 00 movl $0x0,-0x3c(%ebp)
3ff: eb 90 jmp 391 <printint+0x21>
401: eb 0d jmp 410 <printf>
403: 90 nop
404: 90 nop
405: 90 nop
406: 90 nop
407: 90 nop
408: 90 nop
409: 90 nop
40a: 90 nop
40b: 90 nop
40c: 90 nop
40d: 90 nop
40e: 90 nop
40f: 90 nop
00000410 <printf>:
// Print to the given fd. Only understands %d, %x, %p, %s.
void
printf(int fd, char *fmt, ...)
{
410: 55 push %ebp
411: 89 e5 mov %esp,%ebp
413: 57 push %edi
414: 56 push %esi
415: 53 push %ebx
416: 83 ec 2c sub $0x2c,%esp
int c, i, state;
uint *ap;
state = 0;
ap = (uint*)(void*)&fmt + 1;
for(i = 0; fmt[i]; i++){
419: 8b 75 0c mov 0xc(%ebp),%esi
41c: 0f b6 1e movzbl (%esi),%ebx
41f: 84 db test %bl,%bl
421: 0f 84 b3 00 00 00 je 4da <printf+0xca>
ap = (uint*)(void*)&fmt + 1;
427: 8d 45 10 lea 0x10(%ebp),%eax
42a: 83 c6 01 add $0x1,%esi
state = 0;
42d: 31 ff xor %edi,%edi
ap = (uint*)(void*)&fmt + 1;
42f: 89 45 d4 mov %eax,-0x2c(%ebp)
432: eb 2f jmp 463 <printf+0x53>
434: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
c = fmt[i] & 0xff;
if(state == 0){
if(c == '%'){
438: 83 f8 25 cmp $0x25,%eax
43b: 0f 84 a7 00 00 00 je 4e8 <printf+0xd8>
write(fd, &c, 1);
441: 8d 45 e2 lea -0x1e(%ebp),%eax
444: 83 ec 04 sub $0x4,%esp
447: 88 5d e2 mov %bl,-0x1e(%ebp)
44a: 6a 01 push $0x1
44c: 50 push %eax
44d: ff 75 08 pushl 0x8(%ebp)
450: e8 7d fe ff ff call 2d2 <write>
455: 83 c4 10 add $0x10,%esp
458: 83 c6 01 add $0x1,%esi
for(i = 0; fmt[i]; i++){
45b: 0f b6 5e ff movzbl -0x1(%esi),%ebx
45f: 84 db test %bl,%bl
461: 74 77 je 4da <printf+0xca>
if(state == 0){
463: 85 ff test %edi,%edi
c = fmt[i] & 0xff;
465: 0f be cb movsbl %bl,%ecx
468: 0f b6 c3 movzbl %bl,%eax
if(state == 0){
46b: 74 cb je 438 <printf+0x28>
state = '%';
} else {
putc(fd, c);
}
} else if(state == '%'){
46d: 83 ff 25 cmp $0x25,%edi
470: 75 e6 jne 458 <printf+0x48>
if(c == 'd'){
472: 83 f8 64 cmp $0x64,%eax
475: 0f 84 05 01 00 00 je 580 <printf+0x170>
printint(fd, *ap, 10, 1);
ap++;
} else if(c == 'x' || c == 'p'){
47b: 81 e1 f7 00 00 00 and $0xf7,%ecx
481: 83 f9 70 cmp $0x70,%ecx
484: 74 72 je 4f8 <printf+0xe8>
printint(fd, *ap, 16, 0);
ap++;
} else if(c == 's'){
486: 83 f8 73 cmp $0x73,%eax
489: 0f 84 99 00 00 00 je 528 <printf+0x118>
s = "(null)";
while(*s != 0){
putc(fd, *s);
s++;
}
} else if(c == 'c'){
48f: 83 f8 63 cmp $0x63,%eax
492: 0f 84 08 01 00 00 je 5a0 <printf+0x190>
putc(fd, *ap);
ap++;
} else if(c == '%'){
498: 83 f8 25 cmp $0x25,%eax
49b: 0f 84 ef 00 00 00 je 590 <printf+0x180>
write(fd, &c, 1);
4a1: 8d 45 e7 lea -0x19(%ebp),%eax
4a4: 83 ec 04 sub $0x4,%esp
4a7: c6 45 e7 25 movb $0x25,-0x19(%ebp)
4ab: 6a 01 push $0x1
4ad: 50 push %eax
4ae: ff 75 08 pushl 0x8(%ebp)
4b1: e8 1c fe ff ff call 2d2 <write>
4b6: 83 c4 0c add $0xc,%esp
4b9: 8d 45 e6 lea -0x1a(%ebp),%eax
4bc: 88 5d e6 mov %bl,-0x1a(%ebp)
4bf: 6a 01 push $0x1
4c1: 50 push %eax
4c2: ff 75 08 pushl 0x8(%ebp)
4c5: 83 c6 01 add $0x1,%esi
} else {
// Unknown % sequence. Print it to draw attention.
putc(fd, '%');
putc(fd, c);
}
state = 0;
4c8: 31 ff xor %edi,%edi
write(fd, &c, 1);
4ca: e8 03 fe ff ff call 2d2 <write>
for(i = 0; fmt[i]; i++){
4cf: 0f b6 5e ff movzbl -0x1(%esi),%ebx
write(fd, &c, 1);
4d3: 83 c4 10 add $0x10,%esp
for(i = 0; fmt[i]; i++){
4d6: 84 db test %bl,%bl
4d8: 75 89 jne 463 <printf+0x53>
}
}
}
4da: 8d 65 f4 lea -0xc(%ebp),%esp
4dd: 5b pop %ebx
4de: 5e pop %esi
4df: 5f pop %edi
4e0: 5d pop %ebp
4e1: c3 ret
4e2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
state = '%';
4e8: bf 25 00 00 00 mov $0x25,%edi
4ed: e9 66 ff ff ff jmp 458 <printf+0x48>
4f2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
printint(fd, *ap, 16, 0);
4f8: 83 ec 0c sub $0xc,%esp
4fb: b9 10 00 00 00 mov $0x10,%ecx
500: 6a 00 push $0x0
502: 8b 7d d4 mov -0x2c(%ebp),%edi
505: 8b 45 08 mov 0x8(%ebp),%eax
508: 8b 17 mov (%edi),%edx
50a: e8 61 fe ff ff call 370 <printint>
ap++;
50f: 89 f8 mov %edi,%eax
511: 83 c4 10 add $0x10,%esp
state = 0;
514: 31 ff xor %edi,%edi
ap++;
516: 83 c0 04 add $0x4,%eax
519: 89 45 d4 mov %eax,-0x2c(%ebp)
51c: e9 37 ff ff ff jmp 458 <printf+0x48>
521: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
s = (char*)*ap;
528: 8b 45 d4 mov -0x2c(%ebp),%eax
52b: 8b 08 mov (%eax),%ecx
ap++;
52d: 83 c0 04 add $0x4,%eax
530: 89 45 d4 mov %eax,-0x2c(%ebp)
if(s == 0)
533: 85 c9 test %ecx,%ecx
535: 0f 84 8e 00 00 00 je 5c9 <printf+0x1b9>
while(*s != 0){
53b: 0f b6 01 movzbl (%ecx),%eax
state = 0;
53e: 31 ff xor %edi,%edi
s = (char*)*ap;
540: 89 cb mov %ecx,%ebx
while(*s != 0){
542: 84 c0 test %al,%al
544: 0f 84 0e ff ff ff je 458 <printf+0x48>
54a: 89 75 d0 mov %esi,-0x30(%ebp)
54d: 89 de mov %ebx,%esi
54f: 8b 5d 08 mov 0x8(%ebp),%ebx
552: 8d 7d e3 lea -0x1d(%ebp),%edi
555: 8d 76 00 lea 0x0(%esi),%esi
write(fd, &c, 1);
558: 83 ec 04 sub $0x4,%esp
s++;
55b: 83 c6 01 add $0x1,%esi
55e: 88 45 e3 mov %al,-0x1d(%ebp)
write(fd, &c, 1);
561: 6a 01 push $0x1
563: 57 push %edi
564: 53 push %ebx
565: e8 68 fd ff ff call 2d2 <write>
while(*s != 0){
56a: 0f b6 06 movzbl (%esi),%eax
56d: 83 c4 10 add $0x10,%esp
570: 84 c0 test %al,%al
572: 75 e4 jne 558 <printf+0x148>
574: 8b 75 d0 mov -0x30(%ebp),%esi
state = 0;
577: 31 ff xor %edi,%edi
579: e9 da fe ff ff jmp 458 <printf+0x48>
57e: 66 90 xchg %ax,%ax
printint(fd, *ap, 10, 1);
580: 83 ec 0c sub $0xc,%esp
583: b9 0a 00 00 00 mov $0xa,%ecx
588: 6a 01 push $0x1
58a: e9 73 ff ff ff jmp 502 <printf+0xf2>
58f: 90 nop
write(fd, &c, 1);
590: 83 ec 04 sub $0x4,%esp
593: 88 5d e5 mov %bl,-0x1b(%ebp)
596: 8d 45 e5 lea -0x1b(%ebp),%eax
599: 6a 01 push $0x1
59b: e9 21 ff ff ff jmp 4c1 <printf+0xb1>
putc(fd, *ap);
5a0: 8b 7d d4 mov -0x2c(%ebp),%edi
write(fd, &c, 1);
5a3: 83 ec 04 sub $0x4,%esp
putc(fd, *ap);
5a6: 8b 07 mov (%edi),%eax
write(fd, &c, 1);
5a8: 6a 01 push $0x1
ap++;
5aa: 83 c7 04 add $0x4,%edi
putc(fd, *ap);
5ad: 88 45 e4 mov %al,-0x1c(%ebp)
write(fd, &c, 1);
5b0: 8d 45 e4 lea -0x1c(%ebp),%eax
5b3: 50 push %eax
5b4: ff 75 08 pushl 0x8(%ebp)
5b7: e8 16 fd ff ff call 2d2 <write>
ap++;
5bc: 89 7d d4 mov %edi,-0x2c(%ebp)
5bf: 83 c4 10 add $0x10,%esp
state = 0;
5c2: 31 ff xor %edi,%edi
5c4: e9 8f fe ff ff jmp 458 <printf+0x48>
s = "(null)";
5c9: bb 8f 07 00 00 mov $0x78f,%ebx
while(*s != 0){
5ce: b8 28 00 00 00 mov $0x28,%eax
5d3: e9 72 ff ff ff jmp 54a <printf+0x13a>
5d8: 66 90 xchg %ax,%ax
5da: 66 90 xchg %ax,%ax
5dc: 66 90 xchg %ax,%ax
5de: 66 90 xchg %ax,%ax
000005e0 <free>:
static Header base;
static Header *freep;
void
free(void *ap)
{
5e0: 55 push %ebp
Header *bp, *p;
bp = (Header*)ap - 1;
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
5e1: a1 40 0a 00 00 mov 0xa40,%eax
{
5e6: 89 e5 mov %esp,%ebp
5e8: 57 push %edi
5e9: 56 push %esi
5ea: 53 push %ebx
5eb: 8b 5d 08 mov 0x8(%ebp),%ebx
bp = (Header*)ap - 1;
5ee: 8d 4b f8 lea -0x8(%ebx),%ecx
5f1: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
5f8: 39 c8 cmp %ecx,%eax
5fa: 8b 10 mov (%eax),%edx
5fc: 73 32 jae 630 <free+0x50>
5fe: 39 d1 cmp %edx,%ecx
600: 72 04 jb 606 <free+0x26>
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
602: 39 d0 cmp %edx,%eax
604: 72 32 jb 638 <free+0x58>
break;
if(bp + bp->s.size == p->s.ptr){
606: 8b 73 fc mov -0x4(%ebx),%esi
609: 8d 3c f1 lea (%ecx,%esi,8),%edi
60c: 39 fa cmp %edi,%edx
60e: 74 30 je 640 <free+0x60>
bp->s.size += p->s.ptr->s.size;
bp->s.ptr = p->s.ptr->s.ptr;
} else
bp->s.ptr = p->s.ptr;
610: 89 53 f8 mov %edx,-0x8(%ebx)
if(p + p->s.size == bp){
613: 8b 50 04 mov 0x4(%eax),%edx
616: 8d 34 d0 lea (%eax,%edx,8),%esi
619: 39 f1 cmp %esi,%ecx
61b: 74 3a je 657 <free+0x77>
p->s.size += bp->s.size;
p->s.ptr = bp->s.ptr;
} else
p->s.ptr = bp;
61d: 89 08 mov %ecx,(%eax)
freep = p;
61f: a3 40 0a 00 00 mov %eax,0xa40
}
624: 5b pop %ebx
625: 5e pop %esi
626: 5f pop %edi
627: 5d pop %ebp
628: c3 ret
629: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
630: 39 d0 cmp %edx,%eax
632: 72 04 jb 638 <free+0x58>
634: 39 d1 cmp %edx,%ecx
636: 72 ce jb 606 <free+0x26>
{
638: 89 d0 mov %edx,%eax
63a: eb bc jmp 5f8 <free+0x18>
63c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
bp->s.size += p->s.ptr->s.size;
640: 03 72 04 add 0x4(%edx),%esi
643: 89 73 fc mov %esi,-0x4(%ebx)
bp->s.ptr = p->s.ptr->s.ptr;
646: 8b 10 mov (%eax),%edx
648: 8b 12 mov (%edx),%edx
64a: 89 53 f8 mov %edx,-0x8(%ebx)
if(p + p->s.size == bp){
64d: 8b 50 04 mov 0x4(%eax),%edx
650: 8d 34 d0 lea (%eax,%edx,8),%esi
653: 39 f1 cmp %esi,%ecx
655: 75 c6 jne 61d <free+0x3d>
p->s.size += bp->s.size;
657: 03 53 fc add -0x4(%ebx),%edx
freep = p;
65a: a3 40 0a 00 00 mov %eax,0xa40
p->s.size += bp->s.size;
65f: 89 50 04 mov %edx,0x4(%eax)
p->s.ptr = bp->s.ptr;
662: 8b 53 f8 mov -0x8(%ebx),%edx
665: 89 10 mov %edx,(%eax)
}
667: 5b pop %ebx
668: 5e pop %esi
669: 5f pop %edi
66a: 5d pop %ebp
66b: c3 ret
66c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
00000670 <malloc>:
return freep;
}
void*
malloc(uint nbytes)
{
670: 55 push %ebp
671: 89 e5 mov %esp,%ebp
673: 57 push %edi
674: 56 push %esi
675: 53 push %ebx
676: 83 ec 0c sub $0xc,%esp
Header *p, *prevp;
uint nunits;
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
679: 8b 45 08 mov 0x8(%ebp),%eax
if((prevp = freep) == 0){
67c: 8b 15 40 0a 00 00 mov 0xa40,%edx
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
682: 8d 78 07 lea 0x7(%eax),%edi
685: c1 ef 03 shr $0x3,%edi
688: 83 c7 01 add $0x1,%edi
if((prevp = freep) == 0){
68b: 85 d2 test %edx,%edx
68d: 0f 84 9d 00 00 00 je 730 <malloc+0xc0>
693: 8b 02 mov (%edx),%eax
695: 8b 48 04 mov 0x4(%eax),%ecx
base.s.ptr = freep = prevp = &base;
base.s.size = 0;
}
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
if(p->s.size >= nunits){
698: 39 cf cmp %ecx,%edi
69a: 76 6c jbe 708 <malloc+0x98>
69c: 81 ff 00 10 00 00 cmp $0x1000,%edi
6a2: bb 00 10 00 00 mov $0x1000,%ebx
6a7: 0f 43 df cmovae %edi,%ebx
p = sbrk(nu * sizeof(Header));
6aa: 8d 34 dd 00 00 00 00 lea 0x0(,%ebx,8),%esi
6b1: eb 0e jmp 6c1 <malloc+0x51>
6b3: 90 nop
6b4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
6b8: 8b 02 mov (%edx),%eax
if(p->s.size >= nunits){
6ba: 8b 48 04 mov 0x4(%eax),%ecx
6bd: 39 f9 cmp %edi,%ecx
6bf: 73 47 jae 708 <malloc+0x98>
p->s.size = nunits;
}
freep = prevp;
return (void*)(p + 1);
}
if(p == freep)
6c1: 39 05 40 0a 00 00 cmp %eax,0xa40
6c7: 89 c2 mov %eax,%edx
6c9: 75 ed jne 6b8 <malloc+0x48>
p = sbrk(nu * sizeof(Header));
6cb: 83 ec 0c sub $0xc,%esp
6ce: 56 push %esi
6cf: e8 66 fc ff ff call 33a <sbrk>
if(p == (char*)-1)
6d4: 83 c4 10 add $0x10,%esp
6d7: 83 f8 ff cmp $0xffffffff,%eax
6da: 74 1c je 6f8 <malloc+0x88>
hp->s.size = nu;
6dc: 89 58 04 mov %ebx,0x4(%eax)
free((void*)(hp + 1));
6df: 83 ec 0c sub $0xc,%esp
6e2: 83 c0 08 add $0x8,%eax
6e5: 50 push %eax
6e6: e8 f5 fe ff ff call 5e0 <free>
return freep;
6eb: 8b 15 40 0a 00 00 mov 0xa40,%edx
if((p = morecore(nunits)) == 0)
6f1: 83 c4 10 add $0x10,%esp
6f4: 85 d2 test %edx,%edx
6f6: 75 c0 jne 6b8 <malloc+0x48>
return 0;
}
}
6f8: 8d 65 f4 lea -0xc(%ebp),%esp
return 0;
6fb: 31 c0 xor %eax,%eax
}
6fd: 5b pop %ebx
6fe: 5e pop %esi
6ff: 5f pop %edi
700: 5d pop %ebp
701: c3 ret
702: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
if(p->s.size == nunits)
708: 39 cf cmp %ecx,%edi
70a: 74 54 je 760 <malloc+0xf0>
p->s.size -= nunits;
70c: 29 f9 sub %edi,%ecx
70e: 89 48 04 mov %ecx,0x4(%eax)
p += p->s.size;
711: 8d 04 c8 lea (%eax,%ecx,8),%eax
p->s.size = nunits;
714: 89 78 04 mov %edi,0x4(%eax)
freep = prevp;
717: 89 15 40 0a 00 00 mov %edx,0xa40
}
71d: 8d 65 f4 lea -0xc(%ebp),%esp
return (void*)(p + 1);
720: 83 c0 08 add $0x8,%eax
}
723: 5b pop %ebx
724: 5e pop %esi
725: 5f pop %edi
726: 5d pop %ebp
727: c3 ret
728: 90 nop
729: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
base.s.ptr = freep = prevp = &base;
730: c7 05 40 0a 00 00 44 movl $0xa44,0xa40
737: 0a 00 00
73a: c7 05 44 0a 00 00 44 movl $0xa44,0xa44
741: 0a 00 00
base.s.size = 0;
744: b8 44 0a 00 00 mov $0xa44,%eax
749: c7 05 48 0a 00 00 00 movl $0x0,0xa48
750: 00 00 00
753: e9 44 ff ff ff jmp 69c <malloc+0x2c>
758: 90 nop
759: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
prevp->s.ptr = p->s.ptr;
760: 8b 08 mov (%eax),%ecx
762: 89 0a mov %ecx,(%edx)
764: eb b1 jmp 717 <malloc+0xa7>
|
/*
* Copyright (c) 2015 Cryptonomex, Inc., and contributors.
*
* The MIT License
*
* 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.
*/
#pragma once
#include <graphene/chain/evaluator.hpp>
#include <graphene/chain/protocol/types.hpp>
namespace graphene { namespace chain {
class account_object;
class asset_object;
class asset_bitasset_data_object;
class call_order_object;
struct call_order_update_operation;
struct limit_order_cancel_operation;
struct limit_order_create_operation;
class limit_order_create_evaluator : public evaluator<limit_order_create_evaluator>
{
public:
typedef limit_order_create_operation operation_type;
void_result do_evaluate( const limit_order_create_operation& o );
object_id_type do_apply( const limit_order_create_operation& o );
asset calculate_market_fee( const asset_object* aobj, const asset& trade_amount );
share_type _deferred_fee = 0;
const limit_order_create_operation* _op = nullptr;
const account_object* _seller = nullptr;
const account_object* _account_to_credit = nullptr;
const asset_object* _sell_asset = nullptr;
const asset_object* _receive_asset = nullptr;
};
class limit_order_cancel_evaluator : public evaluator<limit_order_cancel_evaluator>
{
public:
typedef limit_order_cancel_operation operation_type;
void_result do_evaluate( const limit_order_cancel_operation& o );
asset do_apply( const limit_order_cancel_operation& o );
const limit_order_object* _order;
};
class call_order_update_evaluator : public evaluator<call_order_update_evaluator>
{
public:
typedef call_order_update_operation operation_type;
void_result do_evaluate( const call_order_update_operation& o );
void_result do_apply( const call_order_update_operation& o );
bool _closing_order = false;
const asset_object* _debt_asset = nullptr;
const account_object* _paying_account = nullptr;
const call_order_object* _order = nullptr;
const asset_bitasset_data_object* _bitasset_data = nullptr;
};
} } // graphene::chain
|
#pragma once
#include "indexer/mwm_set.hpp"
#include "indexer/rank_table.hpp"
#include "geometry/point2d.hpp"
#include "geometry/rect2d.hpp"
#include "geometry/tree4d.hpp"
#include "base/macros.hpp"
#include "std/unique_ptr.hpp"
#include "std/unordered_set.hpp"
class Index;
namespace search
{
class VillagesCache;
struct LocalityItem
{
LocalityItem(string const & name, m2::PointD const & center, uint64_t population);
string m_name;
m2::PointD m_center;
uint64_t m_population;
};
string DebugPrint(LocalityItem const & item);
class LocalitySelector
{
public:
LocalitySelector(string & name, m2::PointD const & p);
void operator()(LocalityItem const & item);
private:
string & m_name;
m2::PointD m_p;
double m_bestScore;
};
class LocalityFinder
{
public:
class Holder
{
public:
Holder(double radiusMeters);
bool IsCovered(m2::RectD const & rect) const;
void SetCovered(m2::PointD const & p);
void Add(LocalityItem const & item);
void ForEachInVicinity(m2::RectD const & rect, LocalitySelector & selector) const;
m2::RectD GetRect(m2::PointD const & p) const;
m2::RectD GetDRect(m2::PointD const & p) const;
void Clear();
private:
double const m_radiusMeters;
m4::Tree<bool> m_coverage;
m4::Tree<LocalityItem> m_localities;
DISALLOW_COPY_AND_MOVE(Holder);
};
LocalityFinder(Index const & index, VillagesCache & villagesCache);
void SetLanguage(int8_t lang);
void GetLocality(m2::PointD const & p, string & name);
void ClearCache();
private:
void LoadVicinity(m2::PointD const & p, bool loadCities, bool loadVillages);
void UpdateMaps();
Index const & m_index;
VillagesCache & m_villagesCache;
int8_t m_lang;
Holder m_cities;
Holder m_villages;
m4::Tree<MwmSet::MwmId> m_maps;
MwmSet::MwmId m_worldId;
bool m_mapsLoaded;
unique_ptr<RankTable> m_ranks;
map<MwmSet::MwmId, unordered_set<uint32_t>> m_loadedIds;
};
} // namespace search
|
;===============================================================================
; Copyright 2015-2018 Intel Corporation
; All Rights Reserved.
;
; If this software was obtained under the Intel Simplified Software License,
; the following terms apply:
;
; The source code, information and material ("Material") contained herein is
; owned by Intel Corporation or its suppliers or licensors, and title to such
; Material remains with Intel Corporation or its suppliers or licensors. The
; Material contains proprietary information of Intel or its suppliers and
; licensors. The Material is protected by worldwide copyright laws and treaty
; provisions. No part of the Material may be used, copied, reproduced,
; modified, published, uploaded, posted, transmitted, distributed or disclosed
; in any way without Intel's prior express written permission. No license under
; any patent, copyright or other intellectual property rights in the Material
; is granted to or conferred upon you, either expressly, by implication,
; inducement, estoppel or otherwise. Any license under such intellectual
; property rights must be express and approved by Intel in writing.
;
; Unless otherwise agreed by Intel in writing, you may not remove or alter this
; notice or any other notice embedded in Materials by Intel or Intel's
; suppliers or licensors in any way.
;
;
; If this software was obtained under the Apache License, Version 2.0 (the
; "License"), the following terms apply:
;
; You may not use this file except in compliance with the License. You may
; obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
;
;
; Unless required by applicable law or agreed to in writing, software
; distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
; WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
;
; See the License for the specific language governing permissions and
; limitations under the License.
;===============================================================================
;
;
; Purpose: Cryptography Primitive.
; Big Number Operations
;
; Content:
; cpMulAdc_BNU_school()
;
;
include asmdefs.inc
include ia_32e.inc
include pcpbnumulschool.inc
include pcpvariant.inc
IF (_ADCOX_NI_ENABLING_ EQ _FEATURE_OFF_) OR (_ADCOX_NI_ENABLING_ EQ _FEATURE_TICKTOCK_)
IF (_IPP32E GE _IPP32E_M7) AND (_IPP32E LT _IPP32E_L9)
IPPCODE SEGMENT 'CODE' ALIGN (IPP_ALIGN_FACTOR)
;*************************************************************
;* Ipp64u cpMulAdc_BNU_school(Ipp64u* pR;
;* const Ipp64u* pA, int aSize,
;* const Ipp64u* pB, int bSize)
;* returns pR[aSize+bSize]
;*
;*************************************************************
ALIGN IPP_ALIGN_FACTOR
IPPASM cpMulAdc_BNU_school PROC PUBLIC FRAME
USES_GPR rbx,rbp,rsi,rdi,r12,r13,r14,r15
LOCAL_FRAME = (1*sizeof(qword))
USES_XMM
COMP_ABI 5
; rdi = pDst
; rsi = pSrcA
; edx = lenA
; rcx = pSrcB
; r8d = lenB
;;
;; stack structure:
;;counterB = (0)
;;counterA = (counterB+sizeof(qword))
counterA = (0)
cmp edx, r8d
jl general_case_mul_entry
jg general_case_mul
IF (_IPP32E LT _IPP32E_E9)
cmp edx, 4
ELSE
cmp edx, 8
ENDIF
jg general_case_mul
IF (_IPP32E GE _IPP32E_E9)
cmp edx, 4
jg more_then_4
ENDIF
cmp edx, 3
ja mul_4x4
jz mul_3x3
jp mul_2x2
; mul_1x1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; fixed-size multipliers (1-4)
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
ALIGN IPP_ALIGN_FACTOR
mul_1x1:
mov rax, qword ptr [rsi]
mul qword ptr [rcx]
mov qword ptr [rdi], rax
mov qword ptr [rdi+sizeof(qword)], rdx
mov rax, qword ptr [rdi+sizeof(qword)*1]
REST_XMM
REST_GPR
ret
ALIGN IPP_ALIGN_FACTOR
mul_2x2:
mov r8, [rcx]
mov r9, [rcx+sizeof(qword)*1]
MUL_NxN 2, rdi, rsi, rcx, rbx, rbp, r15, r14, r13, r12, r11, r10, r9, r8
mov rax, qword ptr [rdi+sizeof(qword)*3]
REST_XMM
REST_GPR
ret
ALIGN IPP_ALIGN_FACTOR
mul_3x3:
mov r8, [rcx]
mov r9, [rcx+sizeof(qword)*1]
mov r10,[rcx+sizeof(qword)*2]
MUL_NxN 3, rdi, rsi, rcx, rbx, rbp, r15, r14, r13, r12, r11, r10, r9, r8
mov rax, qword ptr [rdi+sizeof(qword)*5]
REST_XMM
REST_GPR
ret
ALIGN IPP_ALIGN_FACTOR
mul_4x4:
mov r8, [rcx]
mov r9, [rcx+sizeof(qword)*1]
mov r10,[rcx+sizeof(qword)*2]
mov r11,[rcx+sizeof(qword)*3]
MUL_NxN 4, rdi, rsi, rcx, rbx, rbp, r15, r14, r13, r12, r11, r10, r9, r8
mov rax, qword ptr [rdi+sizeof(qword)*7]
REST_XMM
REST_GPR
ret
IF (_IPP32E GE _IPP32E_E9)
more_then_4:
cmp edx, 7
ja mul_8x8
jz mul_7x7
jp mul_6x6
; mul_5x5
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; fixed-size multipliers (5-8)
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
ALIGN IPP_ALIGN_FACTOR
mul_5x5:
mov r8, [rcx]
mov r9, [rcx+sizeof(qword)*1]
mov r10,[rcx+sizeof(qword)*2]
mov r11,[rcx+sizeof(qword)*3]
mov r12,[rcx+sizeof(qword)*4]
MUL_NxN 5, rdi, rsi, rcx, rbx, rbp, r15, r14, r13, r12, r11, r10, r9, r8
mov rax, qword ptr [rdi+sizeof(qword)*9]
REST_XMM
REST_GPR
ret
ALIGN IPP_ALIGN_FACTOR
mul_6x6:
mov r8, [rcx]
mov r9, [rcx+sizeof(qword)*1]
mov r10,[rcx+sizeof(qword)*2]
mov r11,[rcx+sizeof(qword)*3]
mov r12,[rcx+sizeof(qword)*4]
mov r13,[rcx+sizeof(qword)*5]
MUL_NxN 6, rdi, rsi, rcx, rbx, rbp, r15, r14, r13, r12, r11, r10, r9, r8
mov rax, qword ptr [rdi+sizeof(qword)*11]
REST_XMM
REST_GPR
ret
ALIGN IPP_ALIGN_FACTOR
mul_7x7:
mov r8, [rcx]
mov r9, [rcx+sizeof(qword)*1]
mov r10,[rcx+sizeof(qword)*2]
mov r11,[rcx+sizeof(qword)*3]
mov r12,[rcx+sizeof(qword)*4]
mov r13,[rcx+sizeof(qword)*5]
mov r14,[rcx+sizeof(qword)*6]
MUL_NxN 7, rdi, rsi, rcx, rbx, rbp, r15, r14, r13, r12, r11, r10, r9, r8
mov rax, qword ptr [rdi+sizeof(qword)*13]
REST_XMM
REST_GPR
ret
ALIGN IPP_ALIGN_FACTOR
mul_8x8:
mov r8, [rcx]
mov r9, [rcx+sizeof(qword)*1]
mov r10,[rcx+sizeof(qword)*2]
mov r11,[rcx+sizeof(qword)*3]
mov r12,[rcx+sizeof(qword)*4]
mov r13,[rcx+sizeof(qword)*5]
mov r14,[rcx+sizeof(qword)*6]
mov r15,[rcx+sizeof(qword)*7]
MUL_NxN 8, rdi, rsi, rcx, rbx, rbp, r15, r14, r13, r12, r11, r10, r9, r8
mov rax, qword ptr [rdi+sizeof(qword)*15]
REST_XMM
REST_GPR
ret
ENDIF
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; general case multiplier
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
ALIGN IPP_ALIGN_FACTOR
general_case_mul_entry:
; swap operands if lenA < lenB then exchange operands
xor rsi, rcx
xor edx, r8d
xor rcx, rsi
xor r8d, edx
xor rsi, rcx
xor edx, r8d
B0 equ r10 ; b[i], b[i+1]
B1 equ r11
T0 equ r12 ; temporary
T1 equ r13
T2 equ r14
T3 equ r15
idx equ rbx ; index
rDst equ rdi
rSrc equ rsi
ALIGN IPP_ALIGN_FACTOR
general_case_mul:
movsxd rdx, edx ; expand length
movsxd r8, r8d
lea rdi, [rdi+rdx*sizeof(qword)-sizeof(qword)*4] ; rdi = &R[lenA-4]
lea rsi, [rsi+rdx*sizeof(qword)-sizeof(qword)*4] ; rsi = &A[lenA-4]
mov idx, 4 ; negative
sub idx, rdx ; A-counter
mov qword ptr [rsp+counterA], idx
mov rax, qword ptr [rsi+idx*sizeof(qword)] ; a[0]
mov B0, qword ptr [rcx] ; b[0]
test r8, 1
jz init_even_B
;********** lenSrcB = 2*n+ 1 (multiply only) *********************
init_odd_B:
xor T0, T0
cmp idx, 0
jge skip_mul1
MULx1 rdi, rsi, idx, B0, T0, T1, T2, T3
skip_mul1:
cmp idx, 2
ja fin_mul1x4n_1 ; idx=3
jz fin_mul1x4n_2 ; idx=2
jp fin_mul1x4n_3 ; idx=1
; fin_mul1x4n_4 ; idx=0
fin_mul1x4n_4:
MULx1_4N_4_ELOG rdi, rsi, B0, T0,T1,T2,T3
add rcx, sizeof(qword)
add r8, 1
jmp mla2x4n_4
fin_mul1x4n_3:
MULx1_4N_3_ELOG rdi, rsi, B0, T0,T1,T2,T3
add rcx, sizeof(qword)
add r8, 1
jmp mla2x4n_3
fin_mul1x4n_2:
MULx1_4N_2_ELOG rdi, rsi, B0, T0,T1,T2,T3
add rcx, sizeof(qword)
add r8, 1
jmp mla2x4n_2
fin_mul1x4n_1:
MULx1_4N_1_ELOG rdi, rsi, B0, T0,T1,T2,T3
add rcx, sizeof(qword)
add r8, 1
jmp mla2x4n_1
;********** lenSrcB = 2*n (multiply only) ************************
init_even_B:
mov rbp, rax
mul B0 ; {T2:T1:T0} = a[0]*B0
mov B1, qword ptr [rcx+sizeof(qword)]
xor T2, T2
mov T0, rax
mov rax, rbp ; restore a[0]
mov T1, rdx
cmp idx, 0
jge skip_mul_nx2
MULx2 rdi, rsi, idx, B0,B1, T0,T1,T2,T3
skip_mul_nx2:
cmp idx, 2
ja fin_mul2x4n_1 ; idx=3
jz fin_mul2x4n_2 ; idx=2
jp fin_mul2x4n_3 ; idx=1
; fin_mul2x4n_4 ; idx=0
fin_mul2x4n_4:
MULx2_4N_4_ELOG rdi, rsi, B0,B1, T0,T1,T2,T3
add rcx, sizeof(qword)*2
ALIGN IPP_ALIGN_FACTOR
mla2x4n_4:
sub r8, 2
jz quit
MLAx2_PLOG B0,B1, rcx, T0,T1,T2,T3
cmp idx, 0
jz skip_mla_x2
MLAx2 rdi, rsi, idx, B0,B1, T0,T1,T2,T3
skip_mla_x2:
MLAx2_4N_4_ELOG rdi, rsi, B0,B1, T0,T1,T2,T3
add rcx, sizeof(qword)*2
jmp mla2x4n_4
fin_mul2x4n_3:
MULx2_4N_3_ELOG rdi, rsi, B0,B1, T0,T1,T2,T3
add rcx, sizeof(qword)*2
ALIGN IPP_ALIGN_FACTOR
mla2x4n_3:
sub r8, 2
jz quit
MLAx2_PLOG B0,B1, rcx, T0,T1,T2,T3
MLAx2 rdi, rsi, idx, B0,B1, T0,T1,T2,T3
MLAx2_4N_3_ELOG rdi, rsi, B0,B1, T0,T1,T2,T3
add rcx, sizeof(qword)*2
jmp mla2x4n_3
fin_mul2x4n_2:
MULx2_4N_2_ELOG rdi, rsi, B0,B1, T0,T1,T2,T3
add rcx, sizeof(qword)*2
ALIGN IPP_ALIGN_FACTOR
mla2x4n_2:
sub r8, 2
jz quit
MLAx2_PLOG B0,B1, rcx, T0,T1,T2,T3
MLAx2 rdi, rsi, idx, B0,B1, T0,T1,T2,T3
MLAx2_4N_2_ELOG rdi, rsi, B0,B1, T0,T1,T2,T3
add rcx, sizeof(qword)*2
jmp mla2x4n_2
fin_mul2x4n_1:
MULx2_4N_1_ELOG rdi, rsi, B0,B1, T0,T1,T2,T3
add rcx, sizeof(qword)*2
ALIGN IPP_ALIGN_FACTOR
mla2x4n_1:
sub r8, 2
jz quit
MLAx2_PLOG B0,B1, rcx, T0,T1,T2,T3
MLAx2 rdi, rsi, idx, B0,B1, T0,T1,T2,T3
MLAx2_4N_1_ELOG rdi, rsi, B0,B1, T0,T1,T2,T3
add rcx, sizeof(qword)*2
jmp mla2x4n_1
quit:
mov rax, rdx
REST_XMM
REST_GPR
ret
IPPASM cpMulAdc_BNU_school ENDP
ENDIF
ENDIF ;; _ADCOX_NI_ENABLING_
END
|
; A065172: Inverse permutation to A065171.
; 1,3,5,2,9,7,13,4,17,11,21,6,25,15,29,8,33,19,37,10,41,23,45,12,49,27,53,14,57,31,61,16,65,35,69,18,73,39,77,20,81,43,85,22,89,47,93,24,97,51,101,26,105,55,109,28,113,59,117,30,121,63,125,32,129,67,133,34,137
sub $0,1
sub $1,$0
dif $0,2
add $0,2
add $1,$0
gcd $1,2
mul $0,$1
sub $0,1
|
// lambdas3_1.cpp : lambda which outputs each element and calculates sum of all
#include <algorithm>
#include <iostream>
int main() {
auto data = { 1.0, 2.2, 3.1, 2.1, 0.5, 1.6 };
double sum{};
auto sum_and_average = [&](const auto& elem){
std::cout << elem << " ";
sum += elem;
};
std::for_each(begin(data), end(data), sum_and_average);
std::cout << "\nSum: " << sum << '\n';
} |
;------------------------------------------------------------------------------
;
; 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:
;
; ReadMm0.Asm
;
; Abstract:
;
; AsmReadMm0 function
;
; Notes:
;
;------------------------------------------------------------------------------
.586
.model flat,C
.mmx
.code
;------------------------------------------------------------------------------
; UINT64
; EFIAPI
; AsmReadMm0 (
; VOID
; );
;------------------------------------------------------------------------------
AsmReadMm0 PROC
push eax
push eax
movq [esp], mm0
pop eax
pop edx
ret
AsmReadMm0 ENDP
END
|
; A226741: Column 4 of array in A226513.
; 75,308,807,1704,3155,5340,8463,12752,18459,25860,35255,46968,61347,78764,99615,124320,153323,187092,226119,270920,322035,380028,445487,519024,601275,692900,794583,907032,1030979,1167180,1316415,1479488,1657227,1850484,2060135,2287080,2532243,2796572,3081039,3386640,3714395,4065348,4440567,4841144,5268195,5722860,6206303,6719712,7264299,7841300,8451975,9097608,9779507,10499004,11257455,12056240,12896763,13780452,14708759,15683160,16705155,17776268,18898047,20072064,21299915,22583220,23923623
mov $1,75
mov $2,138
mov $5,$0
mov $6,$0
lpb $2
add $1,$5
sub $2,1
lpe
mov $3,$6
lpb $3
sub $3,1
add $4,$5
lpe
mov $2,78
mov $5,$4
lpb $2
add $1,$5
sub $2,1
lpe
mov $3,$6
mov $4,0
lpb $3
sub $3,1
add $4,$5
lpe
mov $2,16
mov $5,$4
lpb $2
add $1,$5
sub $2,1
lpe
mov $3,$6
mov $4,0
lpb $3
sub $3,1
add $4,$5
lpe
mov $2,1
mov $5,$4
lpb $2
add $1,$5
sub $2,1
lpe
mov $0,$1
|
.global s_prepare_buffers
s_prepare_buffers:
push %r10
push %r13
push %r14
push %rax
push %rcx
push %rdi
push %rdx
push %rsi
lea addresses_UC_ht+0x1047a, %r13
nop
nop
nop
add $41447, %rax
mov $0x6162636465666768, %r14
movq %r14, %xmm4
movups %xmm4, (%r13)
inc %r10
lea addresses_UC_ht+0xbc3a, %rsi
lea addresses_UC_ht+0xe86b, %rdi
nop
nop
nop
add $53588, %r14
mov $124, %rcx
rep movsw
nop
and %rsi, %rsi
lea addresses_A_ht+0x7b3a, %rax
nop
nop
nop
nop
add %rsi, %rsi
movups (%rax), %xmm7
vpextrq $0, %xmm7, %rcx
nop
nop
cmp $17418, %rsi
lea addresses_normal_ht+0x443a, %rsi
lea addresses_normal_ht+0x1803a, %rdi
and $31039, %rdx
mov $24, %rcx
rep movsq
nop
and $36125, %r14
lea addresses_A_ht+0xba3a, %r10
inc %r14
and $0xffffffffffffffc0, %r10
vmovntdqa (%r10), %ymm0
vextracti128 $1, %ymm0, %xmm0
vpextrq $0, %xmm0, %rdi
nop
nop
and $60538, %rdi
lea addresses_UC_ht+0x983a, %r13
nop
nop
cmp %rsi, %rsi
movups (%r13), %xmm5
vpextrq $0, %xmm5, %rdx
nop
nop
nop
nop
nop
cmp $34614, %rsi
lea addresses_UC_ht+0xe8fa, %rdx
nop
nop
nop
and %r13, %r13
mov (%rdx), %rax
nop
nop
inc %rdx
lea addresses_WC_ht+0x833a, %r14
nop
and %rdi, %rdi
mov (%r14), %eax
nop
sub $44719, %rdx
lea addresses_WT_ht+0x1063a, %rsi
lea addresses_normal_ht+0x1edd6, %rdi
nop
nop
add %rax, %rax
mov $123, %rcx
rep movsl
nop
sub %rdx, %rdx
lea addresses_UC_ht+0x1ddae, %r14
nop
nop
nop
nop
nop
dec %rsi
mov $0x6162636465666768, %rdx
movq %rdx, (%r14)
nop
nop
nop
nop
xor $58687, %r10
lea addresses_A_ht+0x984a, %rsi
nop
nop
nop
nop
inc %rcx
mov $0x6162636465666768, %rax
movq %rax, %xmm4
movups %xmm4, (%rsi)
nop
nop
nop
nop
xor $58, %r14
lea addresses_A_ht+0x6d3a, %rsi
nop
nop
nop
nop
inc %rdi
movb (%rsi), %dl
nop
nop
nop
nop
nop
cmp $35565, %rax
lea addresses_WT_ht+0x15c3a, %rdi
nop
nop
nop
add %rdx, %rdx
movups (%rdi), %xmm7
vpextrq $0, %xmm7, %rcx
nop
nop
nop
nop
and $10779, %rcx
lea addresses_A_ht+0x1c3a, %r13
nop
xor %rdx, %rdx
mov $0x6162636465666768, %rcx
movq %rcx, %xmm4
movups %xmm4, (%r13)
nop
xor $43754, %rax
lea addresses_WC_ht+0x10a4c, %r14
clflush (%r14)
add $37194, %r13
movw $0x6162, (%r14)
nop
nop
nop
nop
sub $41583, %r10
pop %rsi
pop %rdx
pop %rdi
pop %rcx
pop %rax
pop %r14
pop %r13
pop %r10
ret
.global s_faulty_load
s_faulty_load:
push %r13
push %r15
push %r9
push %rbp
push %rbx
push %rcx
push %rdx
// Store
lea addresses_WT+0x1e33a, %rbp
nop
nop
nop
and %r9, %r9
mov $0x5152535455565758, %rcx
movq %rcx, %xmm6
vmovups %ymm6, (%rbp)
nop
nop
nop
nop
nop
and %r13, %r13
// Store
lea addresses_RW+0x1fe3a, %rcx
nop
nop
and $43320, %r15
movw $0x5152, (%rcx)
nop
nop
nop
dec %r13
// Store
mov $0x5c9ca7000000043a, %rbx
and $55424, %rbp
mov $0x5152535455565758, %rdx
movq %rdx, %xmm2
vmovups %ymm2, (%rbx)
nop
nop
nop
nop
nop
cmp %rbx, %rbx
// Store
lea addresses_US+0xa43a, %r9
nop
xor %rdx, %rdx
movb $0x51, (%r9)
inc %r13
// Faulty Load
mov $0x5c9ca7000000043a, %r9
nop
nop
nop
nop
nop
sub %rcx, %rcx
mov (%r9), %bx
lea oracles, %r9
and $0xff, %rbx
shlq $12, %rbx
mov (%r9,%rbx,1), %rbx
pop %rdx
pop %rcx
pop %rbx
pop %rbp
pop %r9
pop %r15
pop %r13
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'size': 8, 'NT': False, 'type': 'addresses_NC', 'same': False, 'AVXalign': False, 'congruent': 0}}
{'OP': 'STOR', 'dst': {'size': 32, 'NT': False, 'type': 'addresses_WT', 'same': False, 'AVXalign': False, 'congruent': 8}}
{'OP': 'STOR', 'dst': {'size': 2, 'NT': False, 'type': 'addresses_RW', 'same': False, 'AVXalign': True, 'congruent': 7}}
{'OP': 'STOR', 'dst': {'size': 32, 'NT': False, 'type': 'addresses_NC', 'same': True, 'AVXalign': False, 'congruent': 0}}
{'OP': 'STOR', 'dst': {'size': 1, 'NT': False, 'type': 'addresses_US', 'same': False, 'AVXalign': False, 'congruent': 11}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'size': 2, 'NT': False, 'type': 'addresses_NC', 'same': True, 'AVXalign': False, 'congruent': 0}}
<gen_prepare_buffer>
{'OP': 'STOR', 'dst': {'size': 16, 'NT': False, 'type': 'addresses_UC_ht', 'same': False, 'AVXalign': False, 'congruent': 6}}
{'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_UC_ht', 'congruent': 11}, 'dst': {'same': False, 'type': 'addresses_UC_ht', 'congruent': 0}}
{'OP': 'LOAD', 'src': {'size': 16, 'NT': False, 'type': 'addresses_A_ht', 'same': True, 'AVXalign': False, 'congruent': 8}}
{'OP': 'REPM', 'src': {'same': True, 'type': 'addresses_normal_ht', 'congruent': 11}, 'dst': {'same': False, 'type': 'addresses_normal_ht', 'congruent': 10}}
{'OP': 'LOAD', 'src': {'size': 32, 'NT': True, 'type': 'addresses_A_ht', 'same': False, 'AVXalign': False, 'congruent': 6}}
{'OP': 'LOAD', 'src': {'size': 16, 'NT': False, 'type': 'addresses_UC_ht', 'same': False, 'AVXalign': False, 'congruent': 10}}
{'OP': 'LOAD', 'src': {'size': 8, 'NT': False, 'type': 'addresses_UC_ht', 'same': False, 'AVXalign': False, 'congruent': 3}}
{'OP': 'LOAD', 'src': {'size': 4, 'NT': False, 'type': 'addresses_WC_ht', 'same': False, 'AVXalign': False, 'congruent': 7}}
{'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_WT_ht', 'congruent': 8}, 'dst': {'same': False, 'type': 'addresses_normal_ht', 'congruent': 1}}
{'OP': 'STOR', 'dst': {'size': 8, 'NT': False, 'type': 'addresses_UC_ht', 'same': True, 'AVXalign': True, 'congruent': 1}}
{'OP': 'STOR', 'dst': {'size': 16, 'NT': False, 'type': 'addresses_A_ht', 'same': False, 'AVXalign': False, 'congruent': 4}}
{'OP': 'LOAD', 'src': {'size': 1, 'NT': False, 'type': 'addresses_A_ht', 'same': True, 'AVXalign': False, 'congruent': 8}}
{'OP': 'LOAD', 'src': {'size': 16, 'NT': False, 'type': 'addresses_WT_ht', 'same': False, 'AVXalign': False, 'congruent': 10}}
{'OP': 'STOR', 'dst': {'size': 16, 'NT': False, 'type': 'addresses_A_ht', 'same': False, 'AVXalign': False, 'congruent': 11}}
{'OP': 'STOR', 'dst': {'size': 2, 'NT': False, 'type': 'addresses_WC_ht', 'same': False, 'AVXalign': False, 'congruent': 1}}
{'fe': 1, '1e': 1, '58': 1179, '51': 20561, '38': 1, '00': 85, 'f0': 1}
51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 00 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 00 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 58 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 00 51 51 51 58 51 51 51 51 51 51 51 51 51 51 58 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 00 51 51 51 58 51 58 51 51 51 51 51 51 51 51 51 51 58 51 51 51 51 51 51 51 51 51 51 51 51 58 51 51 51 58 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 58 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 58 51 51 51 51 51 51 51 51 51 51 51 51 51 58 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 58 51 51 51 51 51 51 51 51 51 51 51 51 51 51 58 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 58 51 51 51 51 51 51 51 58 51 58 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 58 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 58 51 58 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 58 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 58 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 58 51 51 51 51 51 51 51 51 51 51 51 51 58 51 51 51 51 51 51 51 51 51 51 51 51 51 58 51 51 51 51 51 51 51 51 51 51 51 51 58 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 58 51 51 51 51 51 51 51 51 51 51 51 51 51 51 58 51 51 51 51 51 51 51 51 51 51 51 51 58 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 58 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 58 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 58 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 58 51 00 51 51 51 51 51 51 51 51 51 51 51 51 51 58 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 58 51 51 51 51 51 51 51 51 51 58 51 51 51 51 58 51 51 51 51 51 51 51 51 51 51 51 58 51 58 58 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 58 51 51 51 51 51 51 51 51 51 51 51 51 51 51 58 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 58 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 58 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 58 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 58 51 51 51 51 51 51 51 51 51 51 51 58 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 58 58 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 58 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 58 58 51 51 51 51 51 51 51 51 51
*/
|
; A184550: Super-birthdays (falling on the same weekday), version 2 (birth within 1 and 2 years after a February 29).
; 0,6,11,17,28,34,39,45,56,62,67,73,84,90,95,101,112,118,123,129,140,146,151,157,168,174,179,185,196,202,207,213,224,230,235,241,252,258,263,269,280,286,291,297,308,314,319,325,336,342,347,353,364,370,375,381,392,398,403,409,420,426,431,437,448,454,459,465,476,482,487,493,504,510,515,521,532,538,543,549,560,566,571,577,588,594,599,605,616,622,627,633,644,650,655,661,672,678,683,689,700,706,711,717,728,734,739,745,756,762,767,773,784,790,795,801,812,818,823,829,840,846,851,857,868,874,879,885,896,902,907,913,924,930,935,941,952,958,963,969,980,986,991,997,1008,1014,1019,1025,1036,1042,1047,1053,1064,1070,1075,1081,1092,1098,1103,1109,1120,1126,1131,1137,1148,1154,1159,1165,1176,1182,1187,1193,1204,1210,1215,1221,1232,1238,1243,1249,1260,1266,1271,1277,1288,1294,1299,1305,1316,1322,1327,1333,1344,1350,1355,1361,1372,1378,1383,1389,1400,1406,1411,1417,1428,1434,1439,1445,1456,1462,1467,1473,1484,1490,1495,1501,1512,1518,1523,1529,1540,1546,1551,1557,1568,1574,1579,1585,1596,1602,1607,1613,1624,1630,1635,1641,1652,1658,1663,1669,1680,1686,1691,1697,1708,1714,1719,1725,1736,1742
mov $2,$0
lpb $0,1
mov $3,$0
lpb $3,1
sub $0,2
add $1,7
mov $3,3
lpe
trn $0,2
add $4,1
add $1,$4
mov $4,0
lpe
lpb $2,1
add $1,5
sub $2,1
lpe
|
.MEMORYMAP
DEFAULTSLOT 0
SLOT 0 START $F000 SIZE $1000 NAME "ROM"
SLOT 1 START $80 SIZE $80 NAME "RAM"
.ENDME
.ROMBANKSIZE $1000
.ROMBANKS 1
.include "vcs.inc"
.include "macro.inc"
|
;
;********************************************************************************************************
; uC/OS-II
; The Real-Time Kernel
;
;
; (c) Copyright 2009-2016; Micrium, Inc.; Weston, FL
; All rights reserved. Protected by international copyright laws.
;
; ARM Cortex-M4 Port
;
; File : OS_CPU_A.ASM
; Version : V2.92.12.00
; By : JJL
; BAN
; JBL
;
; For : ARMv7 Cortex-M4
; Mode : Thumb-2 ISA
; Toolchain : RealView Development Suite
; RealView Microcontroller Development Kit (MDK)
; ARM Developer Suite (ADS)
; Keil uVision
;********************************************************************************************************
;
;********************************************************************************************************
; PUBLIC FUNCTIONS
;********************************************************************************************************
EXTERN OSRunning ; External references
EXTERN OSPrioCur
EXTERN OSPrioHighRdy
EXTERN OSTCBCur
EXTERN OSTCBHighRdy
EXTERN OSIntExit
EXTERN OSTaskSwHook
EXTERN OS_CPU_ExceptStkBase
EXPORT OS_CPU_SR_Save ; Functions declared in this file
EXPORT OS_CPU_SR_Restore
EXPORT OSStartHighRdy
EXPORT OSCtxSw
EXPORT OSIntCtxSw
EXPORT OS_CPU_PendSVHandler
IF {FPU} != "SoftVFP"
EXPORT OS_CPU_FP_Reg_Push
EXPORT OS_CPU_FP_Reg_Pop
ENDIF
;********************************************************************************************************
; EQUATES
;********************************************************************************************************
NVIC_INT_CTRL EQU 0xE000ED04 ; Interrupt control state register.
NVIC_SYSPRI14 EQU 0xE000ED22 ; System priority register (priority 14).
NVIC_PENDSV_PRI EQU 0xFF ; PendSV priority value (lowest).
NVIC_PENDSVSET EQU 0x10000000 ; Value to trigger PendSV exception.
;********************************************************************************************************
; CODE GENERATION DIRECTIVES
;********************************************************************************************************
AREA |.text|, CODE, READONLY, ALIGN=2
THUMB
REQUIRE8
PRESERVE8
;********************************************************************************************************
; FLOATING POINT REGISTERS PUSH
; void OS_CPU_FP_Reg_Push (CPU_STK *stkPtr)
;
; Note(s) : 1) This function saves S0-S31, and FPSCR registers of the Floating Point Unit.
;
; 2) Pseudo-code is:
; a) Get FPSCR register value;
; b) Push value on process stack;
; c) Push remaining regs S0-S31 on process stack;
; d) Update OSTCBCurPtr->StkPtr;
;********************************************************************************************************
IF {FPU} != "SoftVFP"
OS_CPU_FP_Reg_Push
MRS R1, PSP ; PSP is process stack pointer
CBZ R1, OS_CPU_FP_nosave ; Skip FP register save the first time
VMRS R1, FPSCR
STR R1, [R0, #-4]!
VSTMDB R0!, {S0-S31}
LDR R1, =OSTCBCur
LDR R2, [R1]
STR R0, [R2]
OS_CPU_FP_nosave
BX LR
ENDIF
;********************************************************************************************************
; FLOATING POINT REGISTERS POP
; void OS_CPU_FP_Reg_Pop (CPU_STK *stkPtr)
;
; Note(s) : 1) This function restores S0-S31, and FPSCR registers of the Floating Point Unit.
;
; 2) Pseudo-code is:
; a) Restore regs S0-S31 of new process stack;
; b) Restore FPSCR reg value
; c) Update OSTCBHighRdyPtr->StkPtr pointer of new proces stack;
;********************************************************************************************************
IF {FPU} != "SoftVFP"
OS_CPU_FP_Reg_Pop
VLDMIA R0!, {S0-S31}
LDMIA R0!, {R1}
VMSR FPSCR, R1
LDR R1, =OSTCBHighRdy
LDR R2, [R1]
STR R0, [R2]
BX LR
ENDIF
;********************************************************************************************************
; CRITICAL SECTION METHOD 3 FUNCTIONS
;
; Description: Disable/Enable interrupts by preserving the state of interrupts. Generally speaking you
; would store the state of the interrupt disable flag in the local variable 'cpu_sr' and then
; disable interrupts. 'cpu_sr' is allocated in all of uC/OS-II's functions that need to
; disable interrupts. You would restore the interrupt disable state by copying back 'cpu_sr'
; into the CPU's status register.
;
; Prototypes : OS_CPU_SR OS_CPU_SR_Save(void);
; void OS_CPU_SR_Restore(OS_CPU_SR cpu_sr);
;
;
; Note(s) : 1) These functions are used in general like this:
;
; void Task (void *p_arg)
; {
; #if OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU status register */
; OS_CPU_SR cpu_sr;
; #endif
;
; :
; :
; OS_ENTER_CRITICAL(); /* cpu_sr = OS_CPU_SaveSR(); */
; :
; :
; OS_EXIT_CRITICAL(); /* OS_CPU_RestoreSR(cpu_sr); */
; :
; :
; }
;********************************************************************************************************
OS_CPU_SR_Save
MRS R0, PRIMASK ; Set prio int mask to mask all (except faults)
CPSID I
BX LR
OS_CPU_SR_Restore
MSR PRIMASK, R0
BX LR
;********************************************************************************************************
; START MULTITASKING
; void OSStartHighRdy(void)
;
; Note(s) : 1) This function triggers a PendSV exception (essentially, causes a context switch) to cause
; the first task to start.
;
; 2) OSStartHighRdy() MUST:
; a) Setup PendSV exception priority to lowest;
; b) Set initial PSP to 0, to tell context switcher this is first run;
; c) Set the main stack to OS_CPU_ExceptStkBase
; d) Set OSRunning to TRUE;
; e) Trigger PendSV exception;
; f) Enable interrupts (tasks will run with interrupts enabled).
;********************************************************************************************************
OSStartHighRdy
LDR R0, =NVIC_SYSPRI14 ; Set the PendSV exception priority
LDR R1, =NVIC_PENDSV_PRI
STRB R1, [R0]
MOVS R0, #0 ; Set the PSP to 0 for initial context switch call
MSR PSP, R0
BL OSTaskSwHook ; Call OSTaskSwHook for FPU Pop
LDR R0, =OS_CPU_ExceptStkBase ; Initialize the MSP to the OS_CPU_ExceptStkBase
LDR R1, [R0]
MSR MSP, R1
LDR R0, =OSRunning ; OSRunning = TRUE
MOVS R1, #1
STRB R1, [R0]
LDR R0, =NVIC_INT_CTRL ; Trigger the PendSV exception (causes context switch)
LDR R1, =NVIC_PENDSVSET
STR R1, [R0]
CPSIE I ; Enable interrupts at processor level
OSStartHang
B OSStartHang ; Should never get here
;********************************************************************************************************
; PERFORM A CONTEXT SWITCH (From task level) - OSCtxSw()
;
; Note(s) : 1) OSCtxSw() is called when OS wants to perform a task context switch. This function
; triggers the PendSV exception which is where the real work is done.
;********************************************************************************************************
OSCtxSw
LDR R0, =NVIC_INT_CTRL ; Trigger the PendSV exception (causes context switch)
LDR R1, =NVIC_PENDSVSET
STR R1, [R0]
BX LR
;********************************************************************************************************
; PERFORM A CONTEXT SWITCH (From interrupt level) - OSIntCtxSw()
;
; Note(s) : 1) OSIntCtxSw() is called by OSIntExit() when it determines a context switch is needed as
; the result of an interrupt. This function simply triggers a PendSV exception which will
; be handled when there are no more interrupts active and interrupts are enabled.
;********************************************************************************************************
OSIntCtxSw
LDR R0, =NVIC_INT_CTRL ; Trigger the PendSV exception (causes context switch)
LDR R1, =NVIC_PENDSVSET
STR R1, [R0]
BX LR
;********************************************************************************************************
; HANDLE PendSV EXCEPTION
; void OS_CPU_PendSVHandler(void)
;
; Note(s) : 1) PendSV is used to cause a context switch. This is a recommended method for performing
; context switches with Cortex-M3. This is because the Cortex-M3 auto-saves half of the
; processor context on any exception, and restores same on return from exception. So only
; saving of R4-R11 is required and fixing up the stack pointers. Using the PendSV exception
; this way means that context saving and restoring is identical whether it is initiated from
; a thread or occurs due to an interrupt or exception.
;
; 2) Pseudo-code is:
; a) Get the process SP, if 0 then skip (goto d) the saving part (first context switch);
; b) Save remaining regs r4-r11 on process stack;
; c) Save the process SP in its TCB, OSTCBCur->OSTCBStkPtr = SP;
; d) Call OSTaskSwHook();
; e) Get current high priority, OSPrioCur = OSPrioHighRdy;
; f) Get current ready thread TCB, OSTCBCur = OSTCBHighRdy;
; g) Get new process SP from TCB, SP = OSTCBHighRdy->OSTCBStkPtr;
; h) Restore R4-R11 from new process stack;
; i) Perform exception return which will restore remaining context.
;
; 3) On entry into PendSV handler:
; a) The following have been saved on the process stack (by processor):
; xPSR, PC, LR, R12, R0-R3
; b) Processor mode is switched to Handler mode (from Thread mode)
; c) Stack is Main stack (switched from Process stack)
; d) OSTCBCur points to the OS_TCB of the task to suspend
; OSTCBHighRdy points to the OS_TCB of the task to resume
;
; 4) Since PendSV is set to lowest priority in the system (by OSStartHighRdy() above), we
; know that it will only be run when no other exception or interrupt is active, and
; therefore safe to assume that context being switched out was using the process stack (PSP).
;********************************************************************************************************
OS_CPU_PendSVHandler
CPSID I ; Prevent interruption during context switch
MRS R0, PSP ; PSP is process stack pointer
CBZ R0, OS_CPU_PendSVHandler_nosave ; Skip register save the first time
SUBS R0, R0, #0x20 ; Save remaining regs r4-11 on process stack
STM R0, {R4-R11}
LDR R1, =OSTCBCur ; OSTCBCur->OSTCBStkPtr = SP;
LDR R1, [R1]
STR R0, [R1] ; R0 is SP of process being switched out
; At this point, entire context of process has been saved
OS_CPU_PendSVHandler_nosave
PUSH {R14} ; Save LR exc_return value
LDR R0, =OSTaskSwHook ; OSTaskSwHook();
BLX R0
POP {R14}
LDR R0, =OSPrioCur ; OSPrioCur = OSPrioHighRdy;
LDR R1, =OSPrioHighRdy
LDRB R2, [R1]
STRB R2, [R0]
LDR R0, =OSTCBCur ; OSTCBCur = OSTCBHighRdy;
LDR R1, =OSTCBHighRdy
LDR R2, [R1]
STR R2, [R0]
LDR R0, [R2] ; R0 is new process SP; SP = OSTCBHighRdy->OSTCBStkPtr;
LDM R0, {R4-R11} ; Restore r4-11 from new process stack
ADDS R0, R0, #0x20
MSR PSP, R0 ; Load PSP with new process SP
ORR LR, LR, #0xF4 ; Ensure exception return uses process stack
CPSIE I
BX LR ; Exception return will restore remaining context
END
|
#include "compiler/tensor.h"
#include <cstdint>
#include <cstdlib>
#include <cstring>
#include <sstream>
#include <chainerx/routines/creation.h>
#include <common/log.h>
#include <compiler/serializer_util.h>
#include <runtime/chainerx_util.h>
namespace chainer_compiler {
namespace {
typedef std::unique_ptr<void, decltype(&std::free)> UniqueData;
template <typename From, typename To>
UniqueData LoadDataFromRepeated(const ::google::protobuf::RepeatedField<From>& a) {
static_assert(sizeof(From) >= sizeof(To), "invalid load");
UniqueData p(std::malloc(sizeof(To) * a.size()), &std::free);
for (int i = 0; i < a.size(); ++i) {
static_cast<To*>(p.get())[i] = a.Get(i);
}
return p;
}
template <typename From, typename To>
UniqueData LoadDataFromTypedData(const void* data, int64_t num_elements) {
UniqueData p(std::malloc(num_elements * sizeof(To)), &std::free);
for (int i = 0; i < num_elements; ++i) {
static_cast<To*>(p.get())[i] = reinterpret_cast<const From*>(data)[i];
}
return p;
}
template <typename From>
UniqueData LoadDataFromTypedData(Dtype dtype, const void* data, int64_t num_elements) {
switch (dtype) {
case Dtype::kBool:
return LoadDataFromTypedData<From, bool>(data, num_elements);
case Dtype::kInt8:
return LoadDataFromTypedData<From, int8_t>(data, num_elements);
case Dtype::kInt16:
return LoadDataFromTypedData<From, int16_t>(data, num_elements);
case Dtype::kInt32:
return LoadDataFromTypedData<From, int32_t>(data, num_elements);
case Dtype::kInt64:
return LoadDataFromTypedData<From, int64_t>(data, num_elements);
case Dtype::kUInt8:
return LoadDataFromTypedData<From, uint8_t>(data, num_elements);
case Dtype::kFloat16: {
UniqueData p(std::malloc(num_elements * sizeof(chainerx::Float16)), &std::free);
auto out_base_ptr = static_cast<chainerx::Float16*>(p.get());
for (int i = 0; i < num_elements; ++i) {
out_base_ptr[i] = chainerx::Float16(reinterpret_cast<const From*>(data)[i]);
}
return p;
}
case Dtype::kFloat32:
return LoadDataFromTypedData<From, float>(data, num_elements);
case Dtype::kFloat64:
return LoadDataFromTypedData<From, double>(data, num_elements);
default:
CHECK(false) << "Unknown dtype: " << dtype;
}
}
template <typename From, typename To>
void DumpDataToRepeated(const Tensor& t, ::google::protobuf::RepeatedField<To>* a) {
CHECK_LE(static_cast<size_t>(t.ElementSize()), sizeof(To));
for (int64_t i = 0; i < t.NumElements(); ++i) {
a->Add(t.Get<From>(i));
}
}
template <typename To>
void DumpDataToRepeated(const Tensor& t, ::google::protobuf::RepeatedField<To>* a) {
DumpDataToRepeated<To, To>(t, a);
}
absl::variant<chainerx::Array, std::vector<std::string>> TensorProtoToArray(onnx::TensorProto const& xtensor) {
CHECK(!xtensor.has_segment()) << "Segmented TensorProto not supported";
Dtype dtype(xtensor.data_type());
chainerx::Shape shape(xtensor.dims().begin(), xtensor.dims().end());
if (xtensor.data_type() == onnx::TensorProto::STRING) {
CHECK_LT(shape.size(), 2) << ">1D string tensor is not supported";
return std::vector<std::string>(xtensor.string_data().begin(), xtensor.string_data().end());
}
if (xtensor.has_raw_data()) {
CHECK_EQ(0, xtensor.float_data_size());
CHECK_EQ(0, xtensor.int32_data_size());
CHECK_EQ(0, xtensor.string_data_size());
CHECK_EQ(0, xtensor.int64_data_size());
CHECK_EQ(0, xtensor.double_data_size());
CHECK_EQ(0, xtensor.uint64_data_size());
return runtime::MakeHostArray(dtype.chx(), std::move(shape), xtensor.raw_data().data());
} else {
UniqueData data(NULL, &std::free);
switch (dtype) {
case Dtype::kBool:
data = LoadDataFromRepeated<int32_t, bool>(xtensor.int32_data());
break;
case Dtype::kInt8:
data = LoadDataFromRepeated<int32_t, int8_t>(xtensor.int32_data());
break;
case Dtype::kInt16:
data = LoadDataFromRepeated<int32_t, int16_t>(xtensor.int32_data());
break;
case Dtype::kInt32:
data = LoadDataFromRepeated<int32_t, int32_t>(xtensor.int32_data());
break;
case Dtype::kInt64:
data = LoadDataFromRepeated<int64_t, int64_t>(xtensor.int64_data());
break;
case Dtype::kUInt8:
data = LoadDataFromRepeated<int32_t, uint8_t>(xtensor.int32_data());
break;
case Dtype::kFloat16: {
auto a = xtensor.int32_data();
UniqueData p(std::malloc(sizeof(chainerx::Float16) * a.size()), &std::free);
for (int i = 0; i < a.size(); ++i) {
static_cast<chainerx::Float16*>(p.get())[i] = chainerx::Float16::FromData(a.Get(i));
}
data = std::move(p);
} break;
case Dtype::kFloat32:
data = LoadDataFromRepeated<float, float>(xtensor.float_data());
break;
case Dtype::kFloat64:
data = LoadDataFromRepeated<double, double>(xtensor.double_data());
break;
default:
CHECK(false) << "Unknown data type: " << dtype.ToString();
}
return runtime::MakeHostArray(dtype.chx(), std::move(shape), data.get());
}
}
} // namespace
Tensor::Tensor(const onnx::TensorProto& xtensor)
: data_(TensorProtoToArray(xtensor)), name_(xtensor.name()), doc_string_(xtensor.doc_string()) {
}
Tensor::Tensor(std::string const& name, chainerx::Array ary) : data_(chainerx::AsContiguous(ary)), name_(name) {
}
Tensor::~Tensor() {
if (data_.index() == 0) {
CHECK(chx().IsContiguous());
}
}
void Tensor::ToONNX(onnx::TensorProto* xtensor) const {
if (data_.index() == 1) {
xtensor->set_data_type(onnx::TensorProto::STRING);
DUMP_STRING(xtensor, name);
DUMP_STRING(xtensor, doc_string);
for (const std::string& s : absl::get<1>(data_)) {
xtensor->add_string_data(s);
}
return;
}
for (int64_t d : dims()) xtensor->add_dims(d);
xtensor->set_data_type(dtype().ToONNX());
DUMP_STRING(xtensor, name);
DUMP_STRING(xtensor, doc_string);
switch (dtype()) {
case Dtype::kBool:
DumpDataToRepeated<bool, int>(*this, xtensor->mutable_int32_data());
break;
case Dtype::kInt8:
DumpDataToRepeated<int8_t, int>(*this, xtensor->mutable_int32_data());
break;
case Dtype::kInt16:
DumpDataToRepeated<int16_t, int>(*this, xtensor->mutable_int32_data());
break;
case Dtype::kInt32:
DumpDataToRepeated(*this, xtensor->mutable_int32_data());
break;
case Dtype::kInt64:
DumpDataToRepeated(*this, xtensor->mutable_int64_data());
break;
case Dtype::kUInt8:
DumpDataToRepeated<uint8_t, int>(*this, xtensor->mutable_int32_data());
break;
case Dtype::kFloat16: {
auto a = xtensor->mutable_int32_data();
CHECK_LE(static_cast<size_t>(ElementSize()), sizeof(int));
for (int64_t i = 0; i < NumElements(); ++i) {
a->Add(Get<chainerx::Float16>(i).data());
}
} break;
case Dtype::kFloat32:
DumpDataToRepeated(*this, xtensor->mutable_float_data());
break;
case Dtype::kFloat64:
DumpDataToRepeated(*this, xtensor->mutable_double_data());
break;
default:
CHECK(false) << "Unknown data type: " << dtype().ToString();
}
}
std::string Tensor::DebugString() const {
onnx::TensorProto xtensor;
ToONNX(&xtensor);
return xtensor.DebugString();
}
const std::vector<int64_t> Tensor::dims() const {
chainerx::Shape const& s = chx().shape();
return std::vector<int64_t>(s.begin(), s.end());
}
Dtype Tensor::dtype() const {
if (data_.index() == 1) {
return Dtype(onnx::TensorProto::STRING);
}
return Dtype(chx().dtype());
}
int Tensor::ElementSize() const {
return dtype().SizeOf();
}
int64_t Tensor::NumElements() const {
return chx().shape().GetTotalSize();
}
template <typename T>
Tensor::Tensor(const std::string& name, Dtype dtype, const std::vector<int64_t>& dims, const std::vector<T>& data)
: data_(runtime::MakeHostArray(
dtype.chx(), chainerx::Shape(dims.begin(), dims.end()), LoadDataFromTypedData<T>(dtype, data.data(), data.size()).get())),
name_(name) {
}
template Tensor::Tensor(const std::string& name, Dtype dtype, const std::vector<int64_t>& dims, const std::vector<double>& data);
template Tensor::Tensor(const std::string& name, Dtype dtype, const std::vector<int64_t>& dims, const std::vector<float>& data);
template Tensor::Tensor(const std::string& name, Dtype dtype, const std::vector<int64_t>& dims, const std::vector<int>& data);
template Tensor::Tensor(const std::string& name, Dtype dtype, const std::vector<int64_t>& dims, const std::vector<int64_t>& data);
Tensor::Tensor(const std::string& name, const Tensor& t) : data_(t.data_), name_(name), doc_string_(t.doc_string_) {
}
bool Tensor::IsArray() const {
return absl::holds_alternative<chainerx::Array>(data_);
}
const chainerx::Array& Tensor::chx() const {
CHECK(IsArray());
return absl::get<0>(data_);
}
const std::vector<std::string>& Tensor::str() const {
CHECK(!IsArray());
return absl::get<1>(data_);
}
} // namespace chainer_compiler
|
// 14. Hacer un programa que calcule el cuadrado de una suma. (a + b)^2 = a^2 + b^2 + 2ab
#include <iostream>
#include <math.h>
using namespace std;
int main()
{
float a, b, resultado;
cout << "Ingrese valores para a y b " << endl;
cin >> a >> b;
resultado = pow(a, 2) + pow(b, 2) + (2 * a * b);
cout << "Resultado es: " << resultado << endl;
return 0;
}
|
object_const_def ; object_event constants
const MOUNTMOONSQUARE_FAIRY1
const MOUNTMOONSQUARE_FAIRY2
const MOUNTMOONSQUARE_ROCK
MountMoonSquare_MapScripts:
db 1 ; scene scripts
scene_script .DummyScene ; SCENE_DEFAULT
db 2 ; callbacks
callback MAPCALLBACK_NEWMAP, .DisappearMoonStone
callback MAPCALLBACK_OBJECTS, .DisappearRock
.DummyScene:
end
.DisappearMoonStone:
setevent EVENT_MOUNT_MOON_SQUARE_HIDDEN_MOON_STONE
return
.DisappearRock:
disappear MOUNTMOONSQUARE_ROCK
return
ClefairyDance:
checkflag ENGINE_MT_MOON_SQUARE_CLEFAIRY
iftrue .NoDancing
readvar VAR_WEEKDAY
ifnotequal MONDAY, .NoDancing
checktime NITE
iffalse .NoDancing
appear MOUNTMOONSQUARE_FAIRY1
appear MOUNTMOONSQUARE_FAIRY2
applymovement PLAYER, PlayerWalksUpToDancingClefairies
pause 15
appear MOUNTMOONSQUARE_ROCK
turnobject MOUNTMOONSQUARE_FAIRY1, RIGHT
cry CLEFAIRY
waitsfx
pause 30
follow MOUNTMOONSQUARE_FAIRY1, MOUNTMOONSQUARE_FAIRY2
cry CLEFAIRY
applymovement MOUNTMOONSQUARE_FAIRY1, ClefairyDanceStep1
cry CLEFAIRY
applymovement MOUNTMOONSQUARE_FAIRY1, ClefairyDanceStep2
cry CLEFAIRY
applymovement MOUNTMOONSQUARE_FAIRY1, ClefairyDanceStep3
cry CLEFAIRY
applymovement MOUNTMOONSQUARE_FAIRY1, ClefairyDanceStep4
cry CLEFAIRY
applymovement MOUNTMOONSQUARE_FAIRY1, ClefairyDanceStep5
stopfollow
applymovement MOUNTMOONSQUARE_FAIRY2, ClefairyDanceStep6
follow MOUNTMOONSQUARE_FAIRY1, MOUNTMOONSQUARE_FAIRY2
applymovement MOUNTMOONSQUARE_FAIRY1, ClefairyDanceStep7
stopfollow
turnobject MOUNTMOONSQUARE_FAIRY1, DOWN
pause 10
showemote EMOTE_SHOCK, MOUNTMOONSQUARE_FAIRY1, 15
turnobject MOUNTMOONSQUARE_FAIRY1, DOWN
cry CLEFAIRY
pause 15
follow MOUNTMOONSQUARE_FAIRY1, MOUNTMOONSQUARE_FAIRY2
applymovement MOUNTMOONSQUARE_FAIRY1, ClefairyFleeMovement
disappear MOUNTMOONSQUARE_FAIRY1
disappear MOUNTMOONSQUARE_FAIRY2
stopfollow
clearevent EVENT_MOUNT_MOON_SQUARE_HIDDEN_MOON_STONE
setflag ENGINE_MT_MOON_SQUARE_CLEFAIRY
end
.NoDancing:
end
MountMoonSquareHiddenMoonStone:
hiddenitem MOON_STONE, EVENT_MOUNT_MOON_SQUARE_HIDDEN_MOON_STONE
DontLitterSign:
jumptext DontLitterSignText
MtMoonSquareRock:
jumpstd smashrock
PlayerWalksUpToDancingClefairies:
step UP
step_end
ClefairyDanceStep1:
slow_step DOWN
slow_jump_step DOWN
step_end
ClefairyDanceStep2:
slow_jump_step RIGHT
step_end
ClefairyDanceStep3:
slow_step UP
slow_jump_step UP
step_end
ClefairyDanceStep4:
slow_jump_step LEFT
step_end
ClefairyDanceStep5:
slow_step DOWN
slow_jump_step DOWN
step_end
ClefairyDanceStep6:
slow_step DOWN
step_end
ClefairyDanceStep7:
slow_step RIGHT
step_end
ClefairyFleeMovement:
step RIGHT
step RIGHT
step RIGHT
jump_step RIGHT
step RIGHT
step RIGHT
step_end
DontLitterSignText:
text "MT.MOON SQUARE"
line "DON'T LITTER"
done
MountMoonSquare_MapEvents:
db 0, 0 ; filler
db 3 ; warp events
warp_event 20, 5, MOUNT_MOON, 5
warp_event 22, 11, MOUNT_MOON, 6
warp_event 13, 7, MOUNT_MOON_GIFT_SHOP, 1
db 1 ; coord events
coord_event 7, 11, SCENE_DEFAULT, ClefairyDance
db 2 ; bg events
bg_event 7, 7, BGEVENT_ITEM, MountMoonSquareHiddenMoonStone
bg_event 17, 7, BGEVENT_READ, DontLitterSign
db 3 ; object events
object_event 6, 6, SPRITE_FAIRY, SPRITEMOVEDATA_STANDING_DOWN, 0, 0, -1, -1, 0, OBJECTTYPE_SCRIPT, 0, ObjectEvent, EVENT_MT_MOON_SQUARE_CLEFAIRY
object_event 7, 6, SPRITE_FAIRY, SPRITEMOVEDATA_STANDING_DOWN, 0, 0, -1, -1, 0, OBJECTTYPE_SCRIPT, 0, ObjectEvent, EVENT_MT_MOON_SQUARE_CLEFAIRY
object_event 7, 7, SPRITE_ROCK, SPRITEMOVEDATA_SMASHABLE_ROCK, 0, 0, -1, -1, 0, OBJECTTYPE_SCRIPT, 0, MtMoonSquareRock, EVENT_MT_MOON_SQUARE_ROCK
|
#include "eval/eval/container_access_step.h"
#include <cstdint>
#include "google/protobuf/arena.h"
#include "absl/status/status.h"
#include "absl/status/statusor.h"
#include "absl/strings/str_cat.h"
#include "eval/eval/evaluator_core.h"
#include "eval/eval/expression_step_base.h"
#include "eval/public/cel_value.h"
#include "eval/public/unknown_attribute_set.h"
namespace google::api::expr::runtime {
namespace {
inline constexpr int kNumContainerAccessArguments = 2;
// ContainerAccessStep performs message field access specified by Expr::Select
// message.
class ContainerAccessStep : public ExpressionStepBase {
public:
explicit ContainerAccessStep(int64_t expr_id) : ExpressionStepBase(expr_id) {}
absl::Status Evaluate(ExecutionFrame* frame) const override;
private:
using ValueAttributePair = std::pair<CelValue, AttributeTrail>;
ValueAttributePair PerformLookup(ExecutionFrame* frame) const;
CelValue LookupInMap(const CelMap* cel_map, const CelValue& key,
google::protobuf::Arena* arena) const;
CelValue LookupInList(const CelList* cel_list, const CelValue& key,
google::protobuf::Arena* arena) const;
};
inline CelValue ContainerAccessStep::LookupInMap(const CelMap* cel_map,
const CelValue& key,
google::protobuf::Arena* arena) const {
auto status = CelValue::CheckMapKeyType(key);
if (!status.ok()) {
return CreateErrorValue(arena, status);
}
absl::optional<CelValue> maybe_value = (*cel_map)[key];
if (maybe_value.has_value()) {
return maybe_value.value();
}
return CreateNoSuchKeyError(arena, "Key not found in map");
}
inline CelValue ContainerAccessStep::LookupInList(const CelList* cel_list,
const CelValue& key,
google::protobuf::Arena* arena) const {
switch (key.type()) {
case CelValue::Type::kInt64: {
int64_t idx = key.Int64OrDie();
if (idx < 0 || idx >= cel_list->size()) {
return CreateErrorValue(arena,
absl::StrCat("Index error: index=", idx,
" size=", cel_list->size()));
}
return (*cel_list)[idx];
}
default: {
return CreateErrorValue(
arena, absl::StrCat("Index error: expected integer type, got ",
CelValue::TypeName(key.type())));
}
}
}
ContainerAccessStep::ValueAttributePair ContainerAccessStep::PerformLookup(
ExecutionFrame* frame) const {
auto input_args = frame->value_stack().GetSpan(kNumContainerAccessArguments);
AttributeTrail trail;
const CelValue& container = input_args[0];
const CelValue& key = input_args[1];
if (frame->enable_unknowns()) {
auto unknown_set =
frame->attribute_utility().MergeUnknowns(input_args, nullptr);
if (unknown_set) {
return {CelValue::CreateUnknownSet(unknown_set), trail};
}
// We guarantee that GetAttributeSpan can aquire this number of arguments
// by calling HasEnough() at the beginning of Execute() method.
auto input_attrs =
frame->value_stack().GetAttributeSpan(kNumContainerAccessArguments);
auto container_trail = input_attrs[0];
trail = container_trail.Step(CelAttributeQualifier::Create(key),
frame->arena());
if (frame->attribute_utility().CheckForUnknown(trail,
/*use_partial=*/false)) {
auto unknown_set = google::protobuf::Arena::Create<UnknownSet>(
frame->arena(), UnknownAttributeSet({trail.attribute()}));
return {CelValue::CreateUnknownSet(unknown_set), trail};
}
}
for (const auto& value : input_args) {
if (value.IsError()) {
return {value, trail};
}
}
// Select steps can be applied to either maps or messages
switch (container.type()) {
case CelValue::Type::kMap: {
const CelMap* cel_map = container.MapOrDie();
return {LookupInMap(cel_map, key, frame->arena()), trail};
}
case CelValue::Type::kList: {
const CelList* cel_list = container.ListOrDie();
return {LookupInList(cel_list, key, frame->arena()), trail};
}
default: {
auto error = CreateErrorValue(
frame->arena(), absl::InvalidArgumentError(absl::StrCat(
"Invalid container type: '",
CelValue::TypeName(container.type()), "'")));
return {error, trail};
}
}
}
absl::Status ContainerAccessStep::Evaluate(ExecutionFrame* frame) const {
if (!frame->value_stack().HasEnough(kNumContainerAccessArguments)) {
return absl::Status(
absl::StatusCode::kInternal,
"Insufficient arguments supplied for ContainerAccess-type expression");
}
auto result = PerformLookup(frame);
frame->value_stack().Pop(kNumContainerAccessArguments);
frame->value_stack().Push(result.first, result.second);
return absl::OkStatus();
}
} // namespace
// Factory method for Select - based Execution step
absl::StatusOr<std::unique_ptr<ExpressionStep>> CreateContainerAccessStep(
const google::api::expr::v1alpha1::Expr::Call* call, int64_t expr_id) {
int arg_count = call->args_size() + (call->has_target() ? 1 : 0);
if (arg_count != kNumContainerAccessArguments) {
return absl::InvalidArgumentError(absl::StrCat(
"Invalid argument count for index operation: ", arg_count));
}
return absl::make_unique<ContainerAccessStep>(expr_id);
}
} // namespace google::api::expr::runtime
|
; Copyright (c) 2004, Intel Corporation. All rights reserved.<BR>
; This program and the accompanying materials
; are licensed and made available under the terms and conditions of the BSD License
; which accompanies this distribution. The full text of the license may be found at
; http://opensource.org/licenses/bsd-license.php
;
; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
;
; Module Name:
;
; Invd.Asm
;
; Abstract:
;
; AsmInvd function
;
; Notes:
;
;------------------------------------------------------------------------------
.code
;------------------------------------------------------------------------------
; VOID
; EFIAPI
; AsmInvd (
; VOID
; );
;------------------------------------------------------------------------------
AsmInvd PROC
invd
ret
AsmInvd ENDP
END
|
//===-- tsan_flags_test.cc ------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file is a part of ThreadSanitizer (TSan), a race detector.
//
//===----------------------------------------------------------------------===//
#include "tsan_flags.h"
#include "tsan_rtl.h"
#include "gtest/gtest.h"
namespace __tsan {
TEST(Flags, Basic) {
ScopedInRtl in_rtl;
// At least should not crash.
Flags f;
InitializeFlags(&f, 0);
InitializeFlags(&f, "");
}
TEST(Flags, DefaultValues) {
ScopedInRtl in_rtl;
Flags f;
f.enable_annotations = false;
f.exitcode = -11;
InitializeFlags(&f, "");
EXPECT_EQ(66, f.exitcode);
EXPECT_EQ(true, f.enable_annotations);
}
} // namespace __tsan
|
.386
.model flat,stdcall
option casemap:none
.data
currWindow dd 0
public currWindow
cdeg dd 0
public cdeg
pindeg dd 360 DUP(0)
public pindeg
pinnum dd 0
public pinnum
psin dd 360 DUP(0)
public psin
pcos dd 360 DUP(0)
public pcos
ginterval dd 0
public ginterval
end |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.