text
				 
			stringlengths 1 
			1.05M 
			 | 
|---|
	/*
  EVE - Expressive Vector Engine
  Copyright : EVE Contributors & Maintainers
  SPDX-License-Identifier: MIT
*/
//==================================================================================================
#pragma once
#include <eve/detail/overload.hpp>
namespace eve
{
  //================================================================================================
  //! @addtogroup special
  //! @{
  //! @var lbeta
  //!
  //! @brief Callable object computing the logarithm of the beta function.
  //!
  //! **Required header:** `#include <eve/function/lbeta.hpp>`
  //!
  //! #### Members Functions
  //!
  //! | Member       | Effect                                                     |
  //! |:-------------|:-----------------------------------------------------------|
  //! | `operator()` | the lbeta operation   |
  //! | `operator[]` | Construct a conditional version of current function object |
  //!
  //! ---
  //!
  //!  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
  //!  template< floating_value T, floating_value U > auto operator()( T x, U y ) const noexcept requires compatible< T, U >;
  //!  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  //!
  //! **Parameters**
  //!
  //!`x`, `y`:   [values](@ref eve::value).
  //!
  //! **Return value**
  //!
  //!Returns [elementwise](@ref glossary_elementwise) \f$\displaystyle \log\left(\frac{\Gamma(x)\Gamma(y)}{\Gamma(x+y)}\right)\f$.
  //!
  //! The result type is the [common compatible type](@ref common_compatible) of the two parameters.
  //!
  //! ---
  //!
  //!  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
  //!  auto operator[]( conditional_expression auto cond ) const noexcept;
  //!  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  //!
  //!  Higher-order function generating a masked version of eve::lbeta
  //!
  //!  **Parameters**
  //!
  //!  `cond` : conditional expression
  //!
  //!  **Return value**
  //!
  //!  A Callable object so that the expression `lbeta[cond](x, ...)` is equivalent to `if_else(cond,lbeta(x, ...),x)`
  //!
  //! ---
  //!
  //! #### Supported decorators
  //!
  //!
  //!  *  eve::diff, eve::diff_1st, eve::diff_2nd, eve::diff_nth
  //!
  //!:   **Required header:** `#include <eve/function/diff/lbeta.hpp>`
  //!
  //!:   The expression `derivative_1st(lbeta)(x,y)` and `derivative_2nd(lbeta)(x,y)` computes the partial
  //!    derivatives of \f$f\f$, where \f$f\f$ is the function \f$(x,y) \rightarrow \ \log(\mbox{B}(x,y))\f$.
  //!
  //! #### Example
  //!
  //! @godbolt{doc/core/lbeta.cpp}
  //!
  //!  @}
  //================================================================================================
  EVE_MAKE_CALLABLE(lbeta_, lbeta);
}
#include <eve/module/real/special/function/regular/generic/lbeta.hpp>
 
 | 
					
	; void __CALLEE__ sp1_ClearRect_callee(struct sp1_Rect *r, uchar tile, uchar rflag)
; 01.2008 aralbrec, Sprite Pack v3.0
; ts2068 hi-res version
XLIB sp1_ClearRect_callee
XDEF ASMDISP_SP1_CLEARRECT_CALLEE, ASMDISP_SP1CRSELECT
LIB sp1_GetUpdateStruct_callee, l_jpix
XREF ASMDISP_SP1_GETUPDATESTRUCT_CALLEE, SP1V_DISPWIDTH
.sp1_ClearRect_callee
   pop af
   pop bc
   pop hl
   pop de
   push af
   ld a,c
   push hl
   ex de,hl
   ld d,(hl)
   inc hl
   ld e,(hl)
   inc hl
   ld b,(hl)
   inc hl
   ld c,(hl)
   pop hl   
.asmentry
; Clear a rectangular area on screen, erasing sprites,
; and changing tile depending on flags.
;
; enter :  d = row coord
;          e = col coord
;          b = width
;          c = height
;          l = tile
;          a = bit 0 set for tiles, bit 1 set for tile colours (ignored), bit 2 set for sprites
; uses  : af, bc, de, hl, af', ix
.SP1ClearRect
 
   and $07
   ret z                          ; ret if all flags reset
   push hl
   call SP1CRSELECT               ; ix = address of operation code (depending on flags passed in)
   call sp1_GetUpdateStruct_callee + ASMDISP_SP1_GETUPDATESTRUCT_CALLEE  ; hl = & struct update
   pop de                         ; e = tile
.rowloop
   push bc                        ; save b = width
   push hl                        ; save update position
.colloop
   call l_jpix                    ; apply operation on hl, advance hl to next struct sp1_update to the right
   djnz colloop
   pop hl
   ld bc,9*SP1V_DISPWIDTH
   add hl,bc
   pop bc
   
   dec c
   jp nz, rowloop
   ret
.SP1CRSELECT
   add a,a
   add a,seltbl%256
   ld l,a
   ld h,seltbl/256
   jp nc, noinc0
   inc h
   
.noinc0
   ld a,(hl)
   ld ixl,a
   inc hl
   ld a,(hl)
   ld ixh,a
   ret
   
.seltbl
   defw OPTION0, OPTION1, OPTION2, OPTION1
   defw OPTION4, OPTION5, OPTION4, OPTION5
.OPTION0                                             ; no flags
   ld a,9
   add a,l
   ld l,a
   ret nc
   inc h
   ret
   
.OPTION1                                             ; tile only
   inc hl
   ld (hl),e
   inc hl
   ld (hl),0
   ld a,7
   add a,l
   ld l,a
   ret nc
   inc h
   ret
.OPTION2                                             ; colour only - NOP
   ld a,9
   add a,l
   ld l,a
   ret nc
   inc h
   ret
.OPTION4                                             ; sprite only
   ld a,(hl)
   and $c0
   inc a                                             ; keep bit 6:7 flag, occluding spr count reset to 1
   ld (hl),a
   inc hl
   inc hl
   inc hl
   push hl
   ld a,(hl)                                         ; if no sprites in this tile, done
   or a
   jr z, done
   ld (hl),0                                         ; mark no sprites in this tile
   inc hl
   ld l,(hl)
   ld h,a
.loop                                                ; hl = & struct sp1_cs.ss_draw
   dec hl
   dec hl
   dec hl
   dec hl                                            ; hl = & struct sp1_cs.update
   ld (hl),0                                         ; remove from sprite char from tile
   ld a,16
   add a,l
   ld l,a
   jp nc, noinc1
   inc h
.noinc1                                              ; hl = & struct sp1_cs.next_in_upd
   ld a,(hl)
   or a
   jr z, done
   inc hl
   ld l,(hl)
   ld h,a
   jp loop
.done
   pop hl
   ld a,6
   add a,l
   ld l,a
   ret nc
   inc h
   ret
.OPTION5                                             ; sprite and tile
   inc hl
   ld (hl),e
   inc hl
   ld (hl),0
   dec hl
   dec hl
   jp OPTION4
DEFC ASMDISP_SP1_CLEARRECT_CALLEE = asmentry - sp1_ClearRect_callee
DEFC ASMDISP_SP1CRSELECT = SP1CRSELECT - sp1_ClearRect_callee
 
 | 
					
	#include "input_manager_mobile_io.hpp"
#include "lookup.hpp"
#include "xml_util/pugixml.hpp"
#include "group_feedback.hpp"
#include "group_command.hpp"
#include <iostream> // Note: for debugging output.
namespace hebi {
namespace input {
InputManagerMobileIO::InputManagerMobileIO()
{
  if (!reset())
    std::cout << "Could not find joystick input board!" << std::endl;
}
bool InputManagerMobileIO::reset()
{
  // Cleanup if we already have one!
  if (group_)
    group_.reset();
  // Look for mobile IO
  hebi::Lookup lookup;
  long timeout_ms = 2000; // use a 2 second timeout
  group_ = lookup.getGroupFromNames({"Daisy"}, {"mobileIO"}, timeout_ms);
  if (!group_)
    return false;
  // Set Slider snap positions and button toggle modes.
  GroupCommand cmd(1);
  cmd[0].io().a().setFloat(3, 0);
  cmd[0].io().f().setFloat(3, 0);
  cmd[0].io().b().setInt(7, 1);
  group_->sendCommandWithAcknowledgement(cmd);
  group_->addFeedbackHandler([this] (const GroupFeedback& fbk)
  {
    // TODO: use 'std::atomic' variables for state here? Add mutex?  Does this
    // slow things down due to lock contention?
    const auto& analog = fbk[0].io().a();
    const auto& digital = fbk[0].io().b();
    if (analog.hasFloat(1) && analog.hasFloat(2) && analog.hasFloat(3) &&
        digital.hasInt(1))
    {
      left_horz_raw_ = analog.getFloat(1);
      left_vert_raw_ = analog.getFloat(2);
      slider_1_raw_ = analog.getFloat(3);
      right_horz_raw_ = analog.getFloat(7);
      right_vert_raw_ = analog.getFloat(8);
      // Note: Button is configured at toggle, so don't need to count edges
      mode_ = digital.getInt(7);
      // Check for "Quit"
      if (digital.getInt(8) == 1) {
        has_quit_been_pushed_ = true;
      }
    }
  });
  group_->setFeedbackFrequencyHz(1000); // Don't want to miss button presses!
  return true;
}
void InputManagerMobileIO::printState() const
{
  std::cout << "Rotation (z)" << rot_scale_ * left_horz_raw_ << "\n";
  std::cout << "Rotation (y)" << rot_scale_ * left_vert_raw_ << "\n";
  std::cout << "Translation (z)" << xyz_scale_ * left_horz_raw_ << "\n";
  std::cout << "Translation (y)" << xyz_scale_ * right_vert_raw_ << "\n";
  std::cout << "Height " << xyz_scale_ * getVerticalVelocity() << "\n";
  std::cout << "quit state: " << has_quit_been_pushed_ << "\n";
  std::cout << "Mode: " << mode_ << "\n";
}
Eigen::Vector3f InputManagerMobileIO::getTranslationVelocityCmd() const
{
  Eigen::Vector3f translation_velocity_cmd;
  if (isConnected())
  {
    translation_velocity_cmd <<
      -xyz_scale_ * right_vert_raw_,
      xyz_scale_ * right_horz_raw_,
      xyz_scale_ * getVerticalVelocity();
  }
  else
  {
    translation_velocity_cmd.setZero();
  }
  return translation_velocity_cmd;
}
Eigen::Vector3f InputManagerMobileIO::getRotationVelocityCmd() const
{
  Eigen::Vector3f rotation_velocity_cmd;
  if (isConnected())
  {
    rotation_velocity_cmd <<
      0,
      -rot_scale_ * left_vert_raw_,
      rot_scale_ * left_horz_raw_;
  }
  else
  {
    rotation_velocity_cmd.setZero();
  }
  return rotation_velocity_cmd;
}
bool InputManagerMobileIO::getQuitButtonPushed() const
{
  return has_quit_been_pushed_;
}
size_t InputManagerMobileIO::getMode()
{
  return mode_;
}
  
float InputManagerMobileIO::getVerticalVelocity() const
{
  // Slider dead zone: 0.25
  const float slider_dead_zone_ = 0.25; 
  if (std::abs(slider_1_raw_) < slider_dead_zone_)
    return 0;
  // Scale from [dead_zone, 1] to [0, 1] (and same for [-1, -dead_zone]
  if (slider_1_raw_ > 0)
    return -(slider_1_raw_ - slider_dead_zone_) / (1 - slider_dead_zone_);
  return -(slider_1_raw_ + slider_dead_zone_) / (1 - slider_dead_zone_);
}
} // namespace input
} // namespace hebi
 
 | 
					
	; A019613: Expansion of 1/((1-4*x)*(1-7*x)*(1-9*x)).
; Submitted by Jon Maiga
; 1,20,273,3172,33809,342132,3348241,32033924,301669137,2808831124,25937190929,238042888356,2174659962385,19797924540596,179763483454737,1628947562960068,14738065844679953,133185374228264148,1202467908156866065,10848808229007122660,97825454549743028241,881732358766486235380,7944714121222155031313,71566287407634591849732,644543609166632679333649,5804021641111043489647892,52258098884782436663716881,470476218784537645281134884,4235359270883366408721922577,38125746550996221262990975284
mov $1,1
mov $2,1
mov $3,2
lpb $0
  sub $0,1
  mul $1,9
  mul $3,7
  add $3,2
  add $1,$3
  mul $2,4
  add $2,1
  sub $1,$2
lpe
mov $0,$1
 
 | 
					
	#include "mso/layer.h"
Layer::Layer(int size, int next, int prev){
    this->size() = size;
    this->VALS() = arma::Col<double>(size);
    this->ACTS() = arma::Col<double>(size);
    this->DERS() = arma::Col<double>(size);
    for (int i = 0; i < size; ++i) {
        Perceptron *n = new Perceptron(0.00);
        n->ID() = i;
        this->perceptrons.push_back(n);
        weights = arma::Mat<double>(size, next, arma::fill::randu);
        deltas = arma::Mat<double>(prev, size, arma::fill::zeros);
    }
}
arma::mat& Layer::VALS(){
    for (int i = 0; i < this->vals.size(); ++i) {
        this->vals.at(i) = this->perceptrons.at(i)->VAL();
    }
    return this->vals;
}
arma::mat& Layer::ACTS(int FUNC){
    for (int i = 0; i < this->acts.size(); ++i) {
        this->acts.at(i) = this->perceptrons.at(i)->ACT(FUNC);
    }
    return this->acts;
}
arma::mat& Layer::DERS(int FUNC){
    for (int i = 0; i < this->ders.size(); ++i) {
        this->ders.at(i) = this->perceptrons.at(i)->DER(FUNC);
    }
    return this->ders;
}
Perceptron *Layer::getPerceptron(int i){
    return this->perceptrons.at(i);
}
std::ostream& operator<<(std::ostream& os, Layer& l){
    os << "\tPerceptrons: " << l.perceptrons.size() << "\t\tWeight(IN): " << l.gradients.size() << "\t\tWeight(OUT): " << l.weights.size();
    os << std::endl;
    return os;
}
 
 | 
					
	/*============================================================================
The Medical Imaging Interaction Toolkit (MITK)
Copyright (c) German Cancer Research Center (DKFZ)
All rights reserved.
Use of this source code is governed by a 3-clause BSD license that can be
found in the LICENSE file.
============================================================================*/
#include "mitkPaintbrushTool.h"
#include "mitkAbstractTransformGeometry.h"
#include "mitkBaseRenderer.h"
#include "mitkToolManager.h"
#include "mitkContourModelUtils.h"
#include "mitkLevelWindowProperty.h"
int mitk::PaintbrushTool::m_Size = 1;
mitk::PaintbrushTool::PaintbrushTool(int paintingPixelValue)
  : FeedbackContourTool("PressMoveReleaseWithCTRLInversionAllMouseMoves"),
    m_PaintingPixelValue(paintingPixelValue),
    m_LastContourSize(0) // other than initial mitk::PaintbrushTool::m_Size (around l. 28)
{
  m_MasterContour = ContourModel::New();
  m_MasterContour->Initialize();
  m_CurrentPlane = nullptr;
  m_WorkingNode = DataNode::New();
  m_WorkingNode->SetProperty("levelwindow", mitk::LevelWindowProperty::New(mitk::LevelWindow(0, 1)));
  m_WorkingNode->SetProperty("binary", mitk::BoolProperty::New(true));
}
mitk::PaintbrushTool::~PaintbrushTool()
{
}
void mitk::PaintbrushTool::ConnectActionsAndFunctions()
{
  CONNECT_FUNCTION("PrimaryButtonPressed", OnMousePressed);
  CONNECT_FUNCTION("Move", OnPrimaryButtonPressedMoved);
  CONNECT_FUNCTION("MouseMove", OnMouseMoved);
  CONNECT_FUNCTION("Release", OnMouseReleased);
  CONNECT_FUNCTION("InvertLogic", OnInvertLogic);
}
void mitk::PaintbrushTool::Activated()
{
  Superclass::Activated();
  FeedbackContourTool::SetFeedbackContourVisible(true);
  SizeChanged.Send(m_Size);
  this->GetToolManager()->WorkingDataChanged +=
    mitk::MessageDelegate<mitk::PaintbrushTool>(this, &mitk::PaintbrushTool::OnToolManagerWorkingDataModified);
}
void mitk::PaintbrushTool::Deactivated()
{
  FeedbackContourTool::SetFeedbackContourVisible(false);
  if (this->GetToolManager()->GetDataStorage()->Exists(m_WorkingNode))
    this->GetToolManager()->GetDataStorage()->Remove(m_WorkingNode);
  m_WorkingSlice = nullptr;
  m_CurrentPlane = nullptr;
  this->GetToolManager()->WorkingDataChanged -=
    mitk::MessageDelegate<mitk::PaintbrushTool>(this, &mitk::PaintbrushTool::OnToolManagerWorkingDataModified);
  Superclass::Deactivated();
}
void mitk::PaintbrushTool::SetSize(int value)
{
  m_Size = value;
}
mitk::Point2D mitk::PaintbrushTool::upperLeft(mitk::Point2D p)
{
  p[0] -= 0.5;
  p[1] += 0.5;
  return p;
}
void mitk::PaintbrushTool::UpdateContour(const InteractionPositionEvent *positionEvent)
{
  // MITK_INFO<<"Update...";
  // examine stateEvent and create a contour that matches the pixel mask that we are going to draw
  // mitk::InteractionPositionEvent* positionEvent = dynamic_cast<mitk::InteractionPositionEvent*>( interactionEvent );
  // const PositionEvent* positionEvent = dynamic_cast<const PositionEvent*>(stateEvent->GetEvent());
  if (!positionEvent)
    return;
  // Get Spacing of current Slice
  // mitk::Vector3D vSpacing = m_WorkingSlice->GetSlicedGeometry()->GetPlaneGeometry(0)->GetSpacing();
  //
  // Draw a contour in Square according to selected brush size
  //
  int radius = (m_Size) / 2;
  float fradius = static_cast<float>(m_Size) / 2.0f;
  ContourModel::Pointer contourInImageIndexCoordinates = ContourModel::New();
  // estimate center point of the brush ( relative to the pixel the mouse points on )
  // -- left upper corner for even sizes,
  // -- midpoint for uneven sizes
  mitk::Point2D centerCorrection;
  centerCorrection.Fill(0);
  // even --> correction of [+0.5, +0.5]
  bool evenSize = ((m_Size % 2) == 0);
  if (evenSize)
  {
    centerCorrection[0] += 0.5;
    centerCorrection[1] += 0.5;
  }
  // we will compute the control points for the upper left quarter part of a circle contour
  std::vector<mitk::Point2D> quarterCycleUpperRight;
  std::vector<mitk::Point2D> quarterCycleLowerRight;
  std::vector<mitk::Point2D> quarterCycleLowerLeft;
  std::vector<mitk::Point2D> quarterCycleUpperLeft;
  mitk::Point2D curPoint;
  bool curPointIsInside = true;
  curPoint[0] = 0;
  curPoint[1] = radius;
  quarterCycleUpperRight.push_back(upperLeft(curPoint));
  // to estimate if a pixel is inside the circle, we need to compare against the 'outer radius'
  // i.e. the distance from the midpoint [0,0] to the border of the pixel [0,radius]
  // const float outer_radius = static_cast<float>(radius) + 0.5;
  while (curPoint[1] > 0)
  {
    // Move right until pixel is outside circle
    float curPointX_squared = 0.0f;
    float curPointY_squared = (curPoint[1] - centerCorrection[1]) * (curPoint[1] - centerCorrection[1]);
    while (curPointIsInside)
    {
      // increment posX and chec
      curPoint[0]++;
      curPointX_squared = (curPoint[0] - centerCorrection[0]) * (curPoint[0] - centerCorrection[0]);
      const float len = sqrt(curPointX_squared + curPointY_squared);
      if (len > fradius)
      {
        // found first Pixel in this horizontal line, that is outside the circle
        curPointIsInside = false;
      }
    }
    quarterCycleUpperRight.push_back(upperLeft(curPoint));
    // Move down until pixel is inside circle
    while (!curPointIsInside)
    {
      // increment posX and chec
      curPoint[1]--;
      curPointY_squared = (curPoint[1] - centerCorrection[1]) * (curPoint[1] - centerCorrection[1]);
      const float len = sqrt(curPointX_squared + curPointY_squared);
      if (len <= fradius)
      {
        // found first Pixel in this horizontal line, that is outside the circle
        curPointIsInside = true;
        quarterCycleUpperRight.push_back(upperLeft(curPoint));
      }
      // Quarter cycle is full, when curPoint y position is 0
      if (curPoint[1] <= 0)
        break;
    }
  }
  // QuarterCycle is full! Now copy quarter cycle to other quarters.
  if (!evenSize)
  {
    std::vector<mitk::Point2D>::const_iterator it = quarterCycleUpperRight.begin();
    while (it != quarterCycleUpperRight.end())
    {
      mitk::Point2D p;
      p = *it;
      // the contour points in the lower right corner have same position but with negative y values
      p[1] *= -1;
      quarterCycleLowerRight.push_back(p);
      // the contour points in the lower left corner have same position
      // but with both x,y negative
      p[0] *= -1;
      quarterCycleLowerLeft.push_back(p);
      // the contour points in the upper left corner have same position
      // but with x negative
      p[1] *= -1;
      quarterCycleUpperLeft.push_back(p);
      it++;
    }
  }
  else
  {
    std::vector<mitk::Point2D>::const_iterator it = quarterCycleUpperRight.begin();
    while (it != quarterCycleUpperRight.end())
    {
      mitk::Point2D p, q;
      p = *it;
      q = p;
      // the contour points in the lower right corner have same position but with negative y values
      q[1] *= -1;
      // correct for moved offset if size even = the midpoint is not the midpoint of the current pixel
      // but its upper rigt corner
      q[1] += 1;
      quarterCycleLowerRight.push_back(q);
      q = p;
      // the contour points in the lower left corner have same position
      // but with both x,y negative
      q[1] = -1.0f * q[1] + 1;
      q[0] = -1.0f * q[0] + 1;
      quarterCycleLowerLeft.push_back(q);
      // the contour points in the upper left corner have same position
      // but with x negative
      q = p;
      q[0] *= -1;
      q[0] += 1;
      quarterCycleUpperLeft.push_back(q);
      it++;
    }
  }
  // fill contour with poins in right ordering, starting with the upperRight block
  mitk::Point3D tempPoint;
  for (unsigned int i = 0; i < quarterCycleUpperRight.size(); i++)
  {
    tempPoint[0] = quarterCycleUpperRight[i][0];
    tempPoint[1] = quarterCycleUpperRight[i][1];
    tempPoint[2] = 0;
    contourInImageIndexCoordinates->AddVertex(tempPoint);
  }
  // the lower right has to be parsed in reverse order
  for (int i = quarterCycleLowerRight.size() - 1; i >= 0; i--)
  {
    tempPoint[0] = quarterCycleLowerRight[i][0];
    tempPoint[1] = quarterCycleLowerRight[i][1];
    tempPoint[2] = 0;
    contourInImageIndexCoordinates->AddVertex(tempPoint);
  }
  for (unsigned int i = 0; i < quarterCycleLowerLeft.size(); i++)
  {
    tempPoint[0] = quarterCycleLowerLeft[i][0];
    tempPoint[1] = quarterCycleLowerLeft[i][1];
    tempPoint[2] = 0;
    contourInImageIndexCoordinates->AddVertex(tempPoint);
  }
  // the upper left also has to be parsed in reverse order
  for (int i = quarterCycleUpperLeft.size() - 1; i >= 0; i--)
  {
    tempPoint[0] = quarterCycleUpperLeft[i][0];
    tempPoint[1] = quarterCycleUpperLeft[i][1];
    tempPoint[2] = 0;
    contourInImageIndexCoordinates->AddVertex(tempPoint);
  }
  m_MasterContour = contourInImageIndexCoordinates;
}
/**
  Just show the contour, get one point as the central point and add surrounding points to the contour.
  */
void mitk::PaintbrushTool::OnMousePressed(StateMachineAction *, InteractionEvent *interactionEvent)
{
  if (m_WorkingSlice.IsNull())
    return;
  auto *positionEvent = dynamic_cast<mitk::InteractionPositionEvent *>(interactionEvent);
  if (!positionEvent)
    return;
  m_WorkingSlice->GetGeometry()->WorldToIndex(positionEvent->GetPositionInWorld(), m_LastPosition);
  // create new working node
  // a fresh node is needed to only display the actual drawing process for
  // the undo function
  if (this->GetToolManager()->GetDataStorage()->Exists(m_WorkingNode))
    this->GetToolManager()->GetDataStorage()->Remove(m_WorkingNode);
  m_WorkingSlice = nullptr;
  m_CurrentPlane = nullptr;
  m_WorkingNode = DataNode::New();
  m_WorkingNode->SetProperty("levelwindow", mitk::LevelWindowProperty::New(mitk::LevelWindow(0, 1)));
  m_WorkingNode->SetProperty("binary", mitk::BoolProperty::New(true));
  this->m_WorkingNode->SetVisibility(true);
  m_LastEventSender = positionEvent->GetSender();
  m_LastEventSlice = m_LastEventSender->GetSlice();
  m_MasterContour->SetClosed(true);
  this->MouseMoved(interactionEvent, true);
}
void mitk::PaintbrushTool::OnMouseMoved(StateMachineAction *, InteractionEvent *interactionEvent)
{
  MouseMoved(interactionEvent, false);
}
void mitk::PaintbrushTool::OnPrimaryButtonPressedMoved(StateMachineAction *, InteractionEvent *interactionEvent)
{
  MouseMoved(interactionEvent, true);
}
/**
  Insert the point to the feedback contour,finish to build the contour and at the same time the painting function
  */
void mitk::PaintbrushTool::MouseMoved(mitk::InteractionEvent *interactionEvent, bool leftMouseButtonPressed)
{
  auto *positionEvent = dynamic_cast<mitk::InteractionPositionEvent *>(interactionEvent);
  CheckIfCurrentSliceHasChanged(positionEvent);
  if (m_LastContourSize != m_Size)
  {
    UpdateContour(positionEvent);
    m_LastContourSize = m_Size;
  }
  Point3D worldCoordinates = positionEvent->GetPositionInWorld();
  Point3D indexCoordinates;
  m_WorkingSlice->GetGeometry()->WorldToIndex(worldCoordinates, indexCoordinates);
  // round to nearest voxel center (abort if this hasn't changed)
  if (m_Size % 2 == 0) // even
  {
    indexCoordinates[0] = std::round(indexCoordinates[0]);
    indexCoordinates[1] = std::round(indexCoordinates[1]);
  }
  else // odd
  {
    indexCoordinates[0] = std::round(indexCoordinates[0]);
    indexCoordinates[1] = std::round(indexCoordinates[1]);
  }
  static Point3D lastPos; // uninitialized: if somebody finds out how this can be initialized in a one-liner, tell me
  if (fabs(indexCoordinates[0] - lastPos[0]) > mitk::eps || fabs(indexCoordinates[1] - lastPos[1]) > mitk::eps ||
      fabs(indexCoordinates[2] - lastPos[2]) > mitk::eps || leftMouseButtonPressed)
  {
    lastPos = indexCoordinates;
  }
  else
  {
    return;
  }
  auto contour = ContourModel::New();
  contour->SetClosed(true);
  auto it = m_MasterContour->Begin();
  auto end = m_MasterContour->End();
  while (it != end)
  {
    auto point = (*it)->Coordinates;
    point[0] += indexCoordinates[0];
    point[1] += indexCoordinates[1];
    contour->AddVertex(point);
    ++it;
  }
  if (leftMouseButtonPressed)
  {
    const double dist = indexCoordinates.EuclideanDistanceTo(m_LastPosition);
    const double radius = static_cast<double>(m_Size) / 2.0;
    DataNode *workingNode(this->GetToolManager()->GetWorkingData(0));
    auto workingImage = dynamic_cast<Image*>(workingNode->GetData());
    int activePixelValue = ContourModelUtils::GetActivePixelValue(workingImage);
    // m_PaintingPixelValue only decides whether to paint or erase
    mitk::ContourModelUtils::FillContourInSlice(
      contour, m_WorkingSlice, workingImage, m_PaintingPixelValue * activePixelValue);
    m_WorkingNode->SetData(m_WorkingSlice);
    m_WorkingNode->Modified();
    // if points are >= radius away draw rectangle to fill empty holes
    // in between the 2 points
    if (dist > radius)
    {
      const mitk::Point3D ¤tPos = indexCoordinates;
      mitk::Point3D direction;
      mitk::Point3D vertex;
      mitk::Point3D normal;
      direction[0] = indexCoordinates[0] - m_LastPosition[0];
      direction[1] = indexCoordinates[1] - m_LastPosition[1];
      direction[2] = indexCoordinates[2] - m_LastPosition[2];
      direction[0] = direction.GetVnlVector().normalize()[0];
      direction[1] = direction.GetVnlVector().normalize()[1];
      direction[2] = direction.GetVnlVector().normalize()[2];
      // 90 degrees rotation of direction
      normal[0] = -1.0 * direction[1];
      normal[1] = direction[0];
      contour->Clear();
      // upper left corner
      vertex[0] = m_LastPosition[0] + (normal[0] * radius);
      vertex[1] = m_LastPosition[1] + (normal[1] * radius);
      contour->AddVertex(vertex);
      // upper right corner
      vertex[0] = currentPos[0] + (normal[0] * radius);
      vertex[1] = currentPos[1] + (normal[1] * radius);
      contour->AddVertex(vertex);
      // lower right corner
      vertex[0] = currentPos[0] - (normal[0] * radius);
      vertex[1] = currentPos[1] - (normal[1] * radius);
      contour->AddVertex(vertex);
      // lower left corner
      vertex[0] = m_LastPosition[0] - (normal[0] * radius);
      vertex[1] = m_LastPosition[1] - (normal[1] * radius);
      contour->AddVertex(vertex);
      mitk::ContourModelUtils::FillContourInSlice(contour, m_WorkingSlice, workingImage, m_PaintingPixelValue * activePixelValue);
      m_WorkingNode->SetData(m_WorkingSlice);
      m_WorkingNode->Modified();
    }
  }
  else
  {
    // switched from different renderwindow
    // no activate hover highlighting. Otherwise undo / redo wont work
    this->m_WorkingNode->SetVisibility(false);
  }
  m_LastPosition = indexCoordinates;
  // visualize contour
  ContourModel::Pointer tmp =
    FeedbackContourTool::BackProjectContourFrom2DSlice(m_WorkingSlice->GetGeometry(), contour);
  this->UpdateCurrentFeedbackContour(tmp);
  assert(positionEvent->GetSender()->GetRenderWindow());
  RenderingManager::GetInstance()->RequestUpdate(positionEvent->GetSender()->GetRenderWindow());
}
void mitk::PaintbrushTool::OnMouseReleased(StateMachineAction *, InteractionEvent *interactionEvent)
{
  // When mouse is released write segmentationresult back into image
  auto *positionEvent = dynamic_cast<mitk::InteractionPositionEvent *>(interactionEvent);
  if (!positionEvent)
    return;
  this->WriteBackSegmentationResult(positionEvent, m_WorkingSlice->Clone());
  // deactivate visibility of helper node
  m_WorkingNode->SetVisibility(false);
  RenderingManager::GetInstance()->RequestUpdate(positionEvent->GetSender()->GetRenderWindow());
}
/**
  Called when the CTRL key is pressed. Will change the painting pixel value from 0 to 1 or from 1 to 0.
  */
void mitk::PaintbrushTool::OnInvertLogic(StateMachineAction *, InteractionEvent *)
{
  // Inversion only for 0 and 1 as painting values
  if (m_PaintingPixelValue == 1)
  {
    m_PaintingPixelValue = 0;
    FeedbackContourTool::SetFeedbackContourColor(1.0, 0.0, 0.0);
  }
  else if (m_PaintingPixelValue == 0)
  {
    m_PaintingPixelValue = 1;
    FeedbackContourTool::SetFeedbackContourColorDefault();
  }
  mitk::RenderingManager::GetInstance()->RequestUpdateAll();
}
void mitk::PaintbrushTool::CheckIfCurrentSliceHasChanged(const InteractionPositionEvent *event)
{
  const PlaneGeometry *planeGeometry((event->GetSender()->GetCurrentWorldPlaneGeometry()));
  const auto *abstractTransformGeometry(
    dynamic_cast<const AbstractTransformGeometry *>(event->GetSender()->GetCurrentWorldPlaneGeometry()));
  DataNode *workingNode(this->GetToolManager()->GetWorkingData(0));
  if (!workingNode)
    return;
  Image::Pointer image = dynamic_cast<Image *>(workingNode->GetData());
  if (!image || !planeGeometry || abstractTransformGeometry)
    return;
  if (m_CurrentPlane.IsNull() || m_WorkingSlice.IsNull())
  {
    m_CurrentPlane = planeGeometry;
    m_WorkingSlice = SegTool2D::GetAffectedImageSliceAs2DImage(event, image)->Clone();
    m_WorkingNode->ReplaceProperty("color", workingNode->GetProperty("color"));
    m_WorkingNode->SetData(m_WorkingSlice);
  }
  else
  {
    bool isSameSlice(false);
    isSameSlice = mitk::MatrixEqualElementWise(planeGeometry->GetIndexToWorldTransform()->GetMatrix(),
                                               m_CurrentPlane->GetIndexToWorldTransform()->GetMatrix());
    isSameSlice = mitk::Equal(planeGeometry->GetIndexToWorldTransform()->GetOffset(),
                              m_CurrentPlane->GetIndexToWorldTransform()->GetOffset());
    if (!isSameSlice)
    {
      this->GetToolManager()->GetDataStorage()->Remove(m_WorkingNode);
      m_CurrentPlane = nullptr;
      m_WorkingSlice = nullptr;
      m_WorkingNode = nullptr;
      m_CurrentPlane = planeGeometry;
      m_WorkingSlice = SegTool2D::GetAffectedImageSliceAs2DImage(event, image)->Clone();
      m_WorkingNode = mitk::DataNode::New();
      m_WorkingNode->SetProperty("levelwindow", mitk::LevelWindowProperty::New(mitk::LevelWindow(0, 1)));
      m_WorkingNode->SetProperty("binary", mitk::BoolProperty::New(true));
      m_WorkingNode->SetData(m_WorkingSlice);
      // So that the paintbrush contour vanished in the previous render window
      RenderingManager::GetInstance()->RequestUpdateAll();
    }
  }
  if (!this->GetToolManager()->GetDataStorage()->Exists(m_WorkingNode))
  {
    m_WorkingNode->SetProperty("outline binary", mitk::BoolProperty::New(true));
    m_WorkingNode->SetProperty("color", workingNode->GetProperty("color"));
    m_WorkingNode->SetProperty("name", mitk::StringProperty::New("Paintbrush_Node"));
    m_WorkingNode->SetProperty("helper object", mitk::BoolProperty::New(true));
    m_WorkingNode->SetProperty("opacity", mitk::FloatProperty::New(0.8));
    m_WorkingNode->SetProperty("includeInBoundingBox", mitk::BoolProperty::New(false));
    m_WorkingNode->SetVisibility(
      false, mitk::BaseRenderer::GetInstance(mitk::BaseRenderer::GetRenderWindowByName("stdmulti.widget3")));
    this->GetToolManager()->GetDataStorage()->Add(m_WorkingNode);
  }
}
void mitk::PaintbrushTool::OnToolManagerWorkingDataModified()
{
  // Here we simply set the current working slice to null. The next time the mouse is moved
  // within a renderwindow a new slice will be extracted from the new working data
  m_WorkingSlice = nullptr;
}
 
 | 
					
	; A292278: a(n) = (Fibonacci(3*n-1) + 1)/2 for n >= 1.
; Submitted by Jamie Morken(s2)
; 1,3,11,45,189,799,3383,14329,60697,257115,1089155,4613733,19544085,82790071,350704367,1485607537,6293134513,26658145587,112925716859,478361013021,2026369768941,8583840088783,36361730124071,154030760585065,652484772464329,2763969850442379,11708364174233843,49597426547377749,210098070363744837,889989708002357095,3770056902373173215,15970217317495049953,67650926172353373025,286573922006908542051,1213946614199987541227,5142360378806858706957,21783388129427422369053,92275912896516548183167
mul $0,3
add $0,1
seq $0,74331 ; a(n) = Fibonacci(n+1) - (1 + (-1)^n)/2.
div $0,2
add $0,1
 
 | 
					
	!ifndef is_main !eof
; This file serves as paperwork of the game's design
; it contains variables, explications and other neat stuff
;
; VIDEO DETAILS :
; screensize: 320x240
;
; Layer 0   : map 16x32 8bpp
;       tile data: $1 0000
;       map data : $1 8000
vram_layer0_tilebase_b  = $01
vram_layer0_tilebase    = $0000
vram_layer0_mapbase_b   = $01
vram_layer0_mapbase     = $8000
;
; Layer 1   : text (system default)
;       tile data: system default
;       map data : $0 0000
;vram_layer1_tilebase = 
vram_layer1_mapbase_b   = $00
vram_layer1_mapbase     = $0000
;
; Sprites   :
;       128 8x8 4bpp $0 8000
vram_sprites_base_b     = $00
vram_sprites_base       = $8000
;
;
; GAME DETAILS :
; 
; 
; ADDRESSES AND STUFF
obj_size =      $04
obj_idx_type =  $00
obj_idx_param = $01
obj_idx_pos_x = $02
obj_idx_pos_y = $03
; CONSTANTS
SAVE_FILE    = $01
IO_DEVICE       = $08
IOCHECK_FILE    = $02
FILE_WRITE  = $03
FILE_READ   = $03
IOCHECK     = 15
WFRAME_MOVE = %00000001
WFRAME_CHOR = %00000010
WFRAME_MUSIC= %00000100
DIFFICULTY_EASY     = $00
DIFFICULTY_NORMAL   = $01
DIFFICULTY_HARD     = $02
STATUS_FINISHED_EASY    = %00000001
STATUS_FINISHED_NORMAL  = %00000010
STATUS_FINISHED_HARD    = %00000100
GRAZE_BONUS_EASY    = $01
GRAZE_BONUS_NORMAL  = $02
GRAZE_BONUS_HARD    = $04
INVINCIBILITY_FRAMES = $3C
GAMEOVER_WAIT_S = $03
; LOW USAGE VARIABLES
; $0400 to $07FF
dynamic_string = $0400    ; 0~256 bytes
kernal_irq   = $0500      ; 2 bytes
hiscore_87   = $0502      ; 1 byte
hiscore_65   = $0503      ; 1 byte
hiscore_43   = $0504      ; 1 byte
hiscore_21   = $0505      ; 1 byte
saved_volume = $0506      ; 1 byte
game_status  = $0507      ; 1 byte
psg_vo_cnt   = $050F    ; 1 byte
psg_vo_note  = $0510    ; 8 bytes
psg_vo_instr = $0518    ; 8 bytes
psg_vo_delay = $0520    ; 8 bytes
psg_vo_mode = $0528     ; 8 bytes
psg_vo_deltaLo = $0530  ; 8 bytes
psg_vo_deltaHi = $0538  ; 8 bytes
psg_vo_volumeLo = $0540 ; 8 bytes
psg_vo_volumeHi = $0548 ; 8 bytes
obj_count =     $05FF   ; 1 byte
obj_table =     $0600   ; 512 bytes
; TEMPORARY VARIABLES
; $02 to $21
volume_cooldown = x16_r2
; VARIABLES
; $22 to $7F
unsafe_addr   = $22
unsafe_addr_l = $22
unsafe_addr_h = $23
r_obj_a  = $24 ; address
r_obj_p  = $26 ; param
r_obj_t  = $27 ; type
r_obj_x  = $28 ; x pos
r_obj_y  = $29 ; y pos
r_obj_r0 = $2A ; reg 0
r_obj_r1 = $2B ; reg 1
plyr_x   = $2C
plyr_y   = $2D
; $2E
; $2F
choregraphy_pc    = $30
choregraphy_pc_l  = $30
choregraphy_pc_h  = $31
choregraphy_pos   = $32
choregraphy_pos_l = $32
choregraphy_pos_h = $33
choregraphy_pos_x = $32
choregraphy_pos_y = $33
choregraphy_sleep = $34
choregraphy_reg_a = $35
choregraphy_reg_b = $36
choregraphy_reg_c = $37
composer_pc     = $40
composer_pc_l   = $40
composer_pc_h   = $41
composer_delay  = $42
composer_rythm  = $43
composer_sr     = $44
composer_sr_l   = $44
composer_sr_h   = $45
dividend        = $46
;dividend+1     = $47
divisor         = $48
remainder       = $49
;remainder+1    = $4A
result          = dividend
sfx_duration    = $4B
sfx_freq_l      = $4C
sfx_freq_h      = $4D
sfx_wave        = $4E
sfx_change      = $4F
music_volume    = $50
sfx_volume      = $51
difficulty          = $70
graze_bonus         = $71
score_over_time     = $72
scroll_speed        = $73
invincibility_cnt   = $74
panics              = $75
lives               = $76
score_87            = $77
score_65            = $78
score_43            = $79
score_21            = $7A
rng_seed_0          = $7B
rng_seed_1          = $7C
wait_frame          = $7D
frame_count         = $7E
game_mode           = $7F
!macro game_video_init {
    lda #64         ; \
    sta vera_vscale ;  |- set scale
    lda #64         ;  |
    sta vera_hscale ; /
    ; configure layer 0
    +fn_vera_set_layer0_config vera_layer_config_map_width_32tiles | vera_layer_config_map_height_64tiles | vera_layer_config_color_depth_8bpp
    +fn_vera_set_layer0_tilebase $80 | vera_layer_tilebase_tile_width_8px | vera_layer_tilebase_tile_height_8px
    +fn_vera_set_layer0_mapbase (vram_layer0_mapbase_b << 7) | ((vram_layer0_mapbase >> 9) & %01111111)
    ; set video mode
    +fn_vera_set_video vera_video_mask_sprite | vera_video_mask_layer0 | vera_video_mask_layer1 | vera_video_mask_output_vga
    ; clear the text and background layers
    jsr clear_layer0
    jsr clear_layer1
    +fn_print str_white_on_black
    ; upload tiles
    +fn_vera_upload t_empty, $10|t_empty_bank, t_empty_address, t_empty_packet_size, t_empty_packet_qty
    +fn_vera_direct_upload t_square, t_square_packet_size, t_square_packet_qty
    +fn_vera_direct_upload t_trace_b0, t_trace_b0_packet_size, t_trace_b0_packet_qty
    +fn_vera_direct_upload t_trace_b1, t_trace_b1_packet_size, t_trace_b1_packet_qty
    +fn_vera_direct_upload t_trace_b2, t_trace_b2_packet_size, t_trace_b2_packet_qty
    +fn_vera_direct_upload t_trace_gl, t_trace_gl_packet_size, t_trace_gl_packet_qty
    +fn_vera_direct_upload t_dots, t_dots_packet_size, t_dots_packet_qty
    +fn_vera_direct_upload t_scanl, t_scanl_packet_size, t_scanl_packet_qty
    ; upload sprites
    +fn_vera_upload bullet, $10|bullet_bank, bullet_address, bullet_packet_size, bullet_packet_qty
    +fn_vera_direct_upload bullet_panic, bullet_panic_packet_size, bullet_panic_packet_qty
    +fn_vera_direct_upload bullet_glitch1, bullet_glitch1_packet_size, bullet_glitch1_packet_qty
    +fn_vera_direct_upload bullet_glitch2, bullet_glitch2_packet_size, bullet_glitch2_packet_qty
    +fn_vera_direct_upload player, player_packet_size, player_packet_qty
    +fn_vera_direct_upload touched_player, touched_player_packet_size, touched_player_packet_qty
    +fn_vera_direct_upload virus1, virus1_packet_size, virus1_packet_qty
    +fn_vera_direct_upload virus2, virus2_packet_size, virus2_packet_qty
    +fn_vera_direct_upload virus3, virus3_packet_size, virus3_packet_qty
    +fn_vera_direct_upload virus4, virus4_packet_size, virus4_packet_qty
    +fn_vera_direct_upload virus5, virus5_packet_size, virus5_packet_qty
    +fn_vera_direct_upload virus6, virus6_packet_size, virus6_packet_qty
}
!macro game_init {
    lda #$15        ; \
    sta rng_seed_0  ;  |- rng initialization
    lda #$84        ;  |
    sta rng_seed_1  ; /
    lda $9fbe                       ; \
	cmp #"1"                        ;  |
	bne .emu_check_end              ;  |- detect emulator's magic number
	lda $9fbf                       ;  |
	cmp #"6"                        ;  |
	bne .emu_check_end              ; /
    +fn_locate 0,2, str_emulator_msg; \_ display a message for the emulator
    jsr CHRIN                       ; /
.emu_check_end:
    ; initializes sprites
    +fn_vera_set_address $10 + vera_mem_sprite_bank, vera_mem_sprite
    lda #player_spid                        ; \
    sta vera_data_0                         ;  |
    lda #player_spid_def                    ;  |
    sta vera_data_0                         ;  |
    stz vera_data_0 ; pos x (low)           ;  |- init player sprite
    stz vera_data_0 ; pos x (high)          ;  |
    stz vera_data_0 ; pos y (low)           ;  |
    stz vera_data_0 ; pos y (high)          ;  |
                                            ;  |
    lda #vera_sprite_zdepth_behind_layer1   ;  |
    sta vera_data_0                         ;  |
    lda #player_spid_size                   ;  |
    sta vera_data_0                         ; /
    lda #virus1_spid                        ; \
    sta vera_data_0                         ;  |
    lda #virus1_spid_def                    ;  |
    sta vera_data_0                         ;  |
    stz vera_data_0 ; pos x (low)           ;  |- init virus sprite
    stz vera_data_0 ; pos x (high)          ;  |
    stz vera_data_0 ; pos y (low)           ;  |
    stz vera_data_0 ; pos y (high)          ;  |
                                            ;  |
    lda #vera_sprite_zdepth_behind_layer1   ;  |
    sta vera_data_0                         ;  |
    lda #virus1_spid_size                   ;  |
    sta vera_data_0                         ; /
    ldx #$7D
-                                           ; \
    lda #bullet_spid                        ;  |  
    sta vera_data_0                         ;  |- init all sprites
    lda #bullet_spid_def                    ;  |
    sta vera_data_0 ; addr_mode             ;  |
    stz vera_data_0 ; pos x (low)           ;  |- init bullet sprites
    stz vera_data_0 ; pos x (high)          ;  |
    stz vera_data_0 ; pos y (low)           ;  |
    stz vera_data_0 ; pos y (high)          ;  |
                                            ;  |
    lda #vera_sprite_zdepth_behind_layer1   ;  |
    sta vera_data_0                         ;  |
    lda #bullet_spid_size                   ;  |
    sta vera_data_0                         ;  |
                                            ;  |
    dex                                     ;  |
    bne -                                   ; /
    ; prepare game
    +fn_irq_init kernal_irq, vsync_loop ; initialize vsync loop
    lda #gamemode_title                 ; \_ set gamemode to titlescreen
    sta game_mode                       ; /
    lda #63                             ; \
    sta music_volume                    ;  |- init global volume
    lda #63                             ;  |
    sta sfx_volume                      ; /
    lda #DIFFICULTY_NORMAL              ; \_ init default difficulty
    sta difficulty                      ; /
} 
 | 
					
	;
;	ZX Spectrum specific routines
;	by Stefano Bodrato, 14/09/2006
;
;	int zx_soundchip();
;
;	The result is:
;	- 1 (true) if a sound chip is present
;	- 0 (false) otherwise
;
;	$Id: zx_soundchip.asm,v 1.3 2016-06-10 20:02:05 dom Exp $
;
	SECTION code_clib
	PUBLIC	zx_soundchip
	PUBLIC	_zx_soundchip
	
zx_soundchip:
_zx_soundchip:
	ld	hl,0
	ld	bc,$fffd
	ld	a,11		; envelope register
	out	(c),a
	in	a,(c)
	ld	e,a
	xor	170
	ld	b,$bf
	out	(c),a
	ld	b,$ff
	ld	d,a
	in	a,(c)
	cp	d
	ld	b,$bf
	ld	a,e
	out	(c),a		; restore original value
	ret	nz
	inc	hl
	ret
 
 | 
					
	// Copyright (c) 2009-2016 The Bitcoin Core developers
// Copyright (c) 2017-2019 The Raven Core developers
// Copyright (c) 2020-2021 The redecoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "core_io.h"
#include "base58.h"
#include "consensus/consensus.h"
#include "consensus/validation.h"
#include "script/script.h"
#include "script/standard.h"
#include "serialize.h"
#include "streams.h"
#include <univalue.h>
#include <iomanip>
#include <wallet/wallet.h>
#include "util.h"
#include "utilmoneystr.h"
#include "utilstrencodings.h"
#include "assets/assets.h"
std::string ValueFromAmountString(const CAmount& amount, const int8_t units)
{
    bool sign = amount < 0;
    int64_t n_abs = (sign ? -amount : amount);
    int64_t quotient = n_abs / COIN;
    int64_t remainder = n_abs % COIN;
    remainder = remainder / pow(10, 8 - units);
    if (units == 0 && remainder == 0) {
        return strprintf("%s%d", sign ? "-" : "", quotient);
    }
    else {
        return strprintf("%s%d.%0" + std::to_string(units) + "d", sign ? "-" : "", quotient, remainder);
    }
}
UniValue ValueFromAmount(const CAmount& amount, const int8_t units)
{
    return UniValue(UniValue::VNUM, ValueFromAmountString(amount, units));
}
UniValue ValueFromAmount(const CAmount& amount)
{
    return ValueFromAmount(amount, 8);
}
std::string FormatScript(const CScript& script)
{
    std::string ret;
    CScript::const_iterator it = script.begin();
    opcodetype op;
    while (it != script.end()) {
        CScript::const_iterator it2 = it;
        std::vector<unsigned char> vch;
        if (script.GetOp2(it, op, &vch)) {
            if (op == OP_0) {
                ret += "0 ";
                continue;
            } else if ((op >= OP_1 && op <= OP_16) || op == OP_1NEGATE) {
                ret += strprintf("%i ", op - OP_1NEGATE - 1);
                continue;
            } else if (op >= OP_NOP && op <= OP_NOP10) {
                std::string str(GetOpName(op));
                if (str.substr(0, 3) == std::string("OP_")) {
                    ret += str.substr(3, std::string::npos) + " ";
                    continue;
                }
            }
            if (vch.size() > 0) {
                ret += strprintf("0x%x 0x%x ", HexStr(it2, it - vch.size()), HexStr(it - vch.size(), it));
            } else {
                ret += strprintf("0x%x ", HexStr(it2, it));
            }
            continue;
        }
        ret += strprintf("0x%x ", HexStr(it2, script.end()));
        break;
    }
    return ret.substr(0, ret.size() - 1);
}
const std::map<unsigned char, std::string> mapSigHashTypes = {
    {static_cast<unsigned char>(SIGHASH_ALL), std::string("ALL")},
    {static_cast<unsigned char>(SIGHASH_ALL|SIGHASH_ANYONECANPAY), std::string("ALL|ANYONECANPAY")},
    {static_cast<unsigned char>(SIGHASH_NONE), std::string("NONE")},
    {static_cast<unsigned char>(SIGHASH_NONE|SIGHASH_ANYONECANPAY), std::string("NONE|ANYONECANPAY")},
    {static_cast<unsigned char>(SIGHASH_SINGLE), std::string("SINGLE")},
    {static_cast<unsigned char>(SIGHASH_SINGLE|SIGHASH_ANYONECANPAY), std::string("SINGLE|ANYONECANPAY")},
};
/**
 * Create the assembly string representation of a CScript object.
 * @param[in] script    CScript object to convert into the asm string representation.
 * @param[in] fAttemptSighashDecode    Whether to attempt to decode sighash types on data within the script that matches the format
 *                                     of a signature. Only pass true for scripts you believe could contain signatures. For example,
 *                                     pass false, or omit the this argument (defaults to false), for scriptPubKeys.
 */
std::string ScriptToAsmStr(const CScript& script, const bool fAttemptSighashDecode)
{
    std::string str;
    opcodetype opcode;
    std::vector<unsigned char> vch;
    CScript::const_iterator pc = script.begin();
    while (pc < script.end()) {
        if (!str.empty()) {
            str += " ";
        }
        if (!script.GetOp(pc, opcode, vch)) {
            str += "[error]";
            return str;
        }
        if (opcode == OP_REDE_ASSET) {
            // Once we hit an OP_REDE_ASSET, we know that all the next data should be considered as hex
            str += GetOpName(opcode);
            str += " ";
            str += HexStr(vch);
        } else if (0 <= opcode && opcode <= OP_PUSHDATA4) {
            if (vch.size() <= static_cast<std::vector<unsigned char>::size_type>(4)) {
                str += strprintf("%d", CScriptNum(vch, false).getint());
            } else {
                // the IsUnspendable check makes sure not to try to decode OP_RETURN data that may match the format of a signature
                if (fAttemptSighashDecode && !script.IsUnspendable()) {
                    std::string strSigHashDecode;
                    // goal: only attempt to decode a defined sighash type from data that looks like a signature within a scriptSig.
                    // this won't decode correctly formatted public keys in Pubkey or Multisig scripts due to
                    // the restrictions on the pubkey formats (see IsCompressedOrUncompressedPubKey) being incongruous with the
                    // checks in CheckSignatureEncoding.
                    if (CheckSignatureEncoding(vch, SCRIPT_VERIFY_STRICTENC, nullptr)) {
                        const unsigned char chSigHashType = vch.back();
                        if (mapSigHashTypes.count(chSigHashType)) {
                            strSigHashDecode = "[" + mapSigHashTypes.find(chSigHashType)->second + "]";
                            vch.pop_back(); // remove the sighash type byte. it will be replaced by the decode.
                        }
                    }
                    str += HexStr(vch) + strSigHashDecode;
                } else {
                    str += HexStr(vch);
                }
            }
        } else {
            str += GetOpName(opcode);
        }
    }
    return str;
}
std::string EncodeHexTx(const CTransaction& tx, const int serializeFlags)
{
    CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION | serializeFlags);
    ssTx << tx;
    return HexStr(ssTx.begin(), ssTx.end());
}
void ScriptPubKeyToUniv(const CScript& scriptPubKey,
                        UniValue& out, bool fIncludeHex)
{
    txnouttype type;
    std::vector<CTxDestination> addresses;
    int nRequired;
    out.pushKV("asm", ScriptToAsmStr(scriptPubKey));
    if (fIncludeHex)
        out.pushKV("hex", HexStr(scriptPubKey.begin(), scriptPubKey.end()));
    if (!ExtractDestinations(scriptPubKey, type, addresses, nRequired)) {
        out.pushKV("type", GetTxnOutputType(type));
        return;
    }
    out.pushKV("reqSigs", nRequired);
    out.pushKV("type", GetTxnOutputType(type));
    /** REDE START */
    if (type == TX_NEW_ASSET || type == TX_TRANSFER_ASSET || type == TX_REISSUE_ASSET) {
        UniValue assetInfo(UniValue::VOBJ);
        std::string _assetAddress;
        CAssetOutputEntry data;
        if (GetAssetData(scriptPubKey, data)) {
            assetInfo.pushKV("name", data.assetName);
            assetInfo.pushKV("amount", ValueFromAmount(data.nAmount));
            if (!data.message.empty())
                assetInfo.pushKV("message", EncodeAssetData(data.message));
            if(data.expireTime)
                assetInfo.pushKV("expire_time", data.expireTime);
            switch (type) {
                case TX_NONSTANDARD:
                case TX_PUBKEY:
                case TX_PUBKEYHASH:
                case TX_SCRIPTHASH:
                case TX_MULTISIG:
                case TX_NULL_DATA:
                case TX_WITNESS_V0_SCRIPTHASH:
                case TX_WITNESS_V0_KEYHASH:
                case TX_RESTRICTED_ASSET_DATA:
                default:
                    break;
                case TX_NEW_ASSET:
                    if (IsAssetNameAnOwner(data.assetName)) {
                        // pwnd n00b
                    } else {
                        CNewAsset asset;
                        if (AssetFromScript(scriptPubKey, asset, _assetAddress)) {
                            assetInfo.pushKV("units", asset.units);
                            assetInfo.pushKV("reissuable", asset.nReissuable > 0 ? true : false);
                            if (asset.nHasIPFS > 0) {
                                assetInfo.pushKV("ipfs_hash", EncodeAssetData(asset.strIPFSHash));
                            }
                        }
                    }
                    break;
                case TX_TRANSFER_ASSET:
                    break;
                case TX_REISSUE_ASSET:
                    CReissueAsset asset;
                    if (ReissueAssetFromScript(scriptPubKey, asset, _assetAddress)) {
                        if (asset.nUnits >= 0) {
                            assetInfo.pushKV("units", asset.nUnits);
                        }
                        assetInfo.pushKV("reissuable", asset.nReissuable > 0 ? true : false);
                        if (!asset.strIPFSHash.empty()) {
                            assetInfo.pushKV("ipfs_hash", EncodeAssetData(asset.strIPFSHash));
                        }
                    }
                    break;
            }
        }
        out.pushKV("asset", assetInfo);
    }
    if (type == TX_RESTRICTED_ASSET_DATA) {
        UniValue assetInfo(UniValue::VOBJ);
        CNullAssetTxData data;
        CNullAssetTxVerifierString verifierData;
        std::string address;
        if (AssetNullDataFromScript(scriptPubKey, data, address)) {
            AssetType type;
            IsAssetNameValid(data.asset_name, type);
            if (type == AssetType::QUALIFIER || type == AssetType::SUB_QUALIFIER) {
                assetInfo.pushKV("asset_name", data.asset_name);
                assetInfo.pushKV("qualifier_type", data.flag ? "adding qualifier" : "removing qualifier");
                assetInfo.pushKV("address", address);
            } else if (type == AssetType::RESTRICTED) {
                assetInfo.pushKV("asset_name", data.asset_name);
                assetInfo.pushKV("restricted_type", data.flag ? "freezing address" : "unfreezing address");
                assetInfo.pushKV("address", address);
            }
        } else if (GlobalAssetNullDataFromScript(scriptPubKey, data)) {
            assetInfo.pushKV("restricted_name", data.asset_name);
            assetInfo.pushKV("restricted_type", data.flag ? "freezing" : "unfreezing");
            assetInfo.pushKV("address", "all addresses");
        } else if (AssetNullVerifierDataFromScript(scriptPubKey, verifierData)) {
            assetInfo.pushKV("verifier_string", verifierData.verifier_string);
        }
        out.pushKV("asset_data", assetInfo);
    }
     /** REDE END */
    UniValue a(UniValue::VARR);
    for (const CTxDestination& addr : addresses) {
        a.push_back(EncodeDestination(addr));
    }
    out.pushKV("addresses", a);
}
void TxToUniv(const CTransaction& tx, const uint256& hashBlock, UniValue& entry, bool include_hex, int serialize_flags)
{
    entry.pushKV("txid", tx.GetHash().GetHex());
    entry.pushKV("hash", tx.GetWitnessHash().GetHex());
    entry.pushKV("version", tx.nVersion);
    entry.pushKV("size", (int)::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION));
    entry.pushKV("vsize", (GetTransactionWeight(tx) + WITNESS_SCALE_FACTOR - 1) / WITNESS_SCALE_FACTOR);
    entry.pushKV("locktime", (int64_t)tx.nLockTime);
    UniValue vin(UniValue::VARR);
    for (unsigned int i = 0; i < tx.vin.size(); i++) {
        const CTxIn& txin = tx.vin[i];
        UniValue in(UniValue::VOBJ);
        if (tx.IsCoinBase())
            in.pushKV("coinbase", HexStr(txin.scriptSig.begin(), txin.scriptSig.end()));
        else {
            in.pushKV("txid", txin.prevout.hash.GetHex());
            in.pushKV("vout", (int64_t)txin.prevout.n);
            UniValue o(UniValue::VOBJ);
            o.pushKV("asm", ScriptToAsmStr(txin.scriptSig, true));
            o.pushKV("hex", HexStr(txin.scriptSig.begin(), txin.scriptSig.end()));
            in.pushKV("scriptSig", o);
            if (!tx.vin[i].scriptWitness.IsNull()) {
                UniValue txinwitness(UniValue::VARR);
                for (const auto& item : tx.vin[i].scriptWitness.stack) {
                    txinwitness.push_back(HexStr(item.begin(), item.end()));
                }
                in.pushKV("txinwitness", txinwitness);
            }
        }
        in.pushKV("sequence", (int64_t)txin.nSequence);
        vin.push_back(in);
    }
    entry.pushKV("vin", vin);
    UniValue vout(UniValue::VARR);
    for (unsigned int i = 0; i < tx.vout.size(); i++) {
        const CTxOut& txout = tx.vout[i];
        UniValue out(UniValue::VOBJ);
        out.pushKV("value", ValueFromAmount(txout.nValue));
        out.pushKV("n", (int64_t)i);
        UniValue o(UniValue::VOBJ);
        ScriptPubKeyToUniv(txout.scriptPubKey, o, true);
        out.pushKV("scriptPubKey", o);
        vout.push_back(out);
    }
    entry.pushKV("vout", vout);
    if (!hashBlock.IsNull())
        entry.pushKV("blockhash", hashBlock.GetHex());
    if (include_hex) {
        entry.pushKV("hex", EncodeHexTx(tx, serialize_flags)); // the hex-encoded transaction. used the name "hex" to be consistent with the verbose output of "getrawtransaction".
    }
}
 
 | 
					
	.global s_prepare_buffers
s_prepare_buffers:
push %r11
push %rbp
push %rdx
lea addresses_A_ht+0x1886d, %r11
clflush (%r11)
nop
cmp $18217, %rbp
movups (%r11), %xmm7
vpextrq $1, %xmm7, %rdx
nop
nop
nop
xor %rdx, %rdx
pop %rdx
pop %rbp
pop %r11
ret
    .global s_faulty_load
s_faulty_load:
push %r10
push %r11
push %r13
push %r14
push %r15
push %r8
push %rdi
// Store
lea addresses_WT+0xe5bf, %r13
nop
nop
nop
nop
nop
sub $41447, %r15
mov $0x5152535455565758, %r8
movq %r8, (%r13)
nop
nop
nop
xor %r8, %r8
// Store
lea addresses_WT+0xe5bf, %rdi
nop
nop
nop
nop
nop
cmp %r14, %r14
movb $0x51, (%rdi)
nop
nop
nop
sub %r11, %r11
// Store
lea addresses_D+0x2419, %r15
nop
nop
xor $25361, %r14
movb $0x51, (%r15)
nop
nop
add $60448, %r10
// Store
lea addresses_WT+0xe5bf, %r8
nop
xor %r11, %r11
mov $0x5152535455565758, %r15
movq %r15, (%r8)
nop
and $62163, %r11
// Store
lea addresses_WT+0xe5bf, %rdi
nop
nop
nop
nop
nop
and $52033, %r10
mov $0x5152535455565758, %r15
movq %r15, %xmm3
vmovups %ymm3, (%rdi)
nop
nop
nop
and %r10, %r10
// Faulty Load
lea addresses_WT+0xe5bf, %r13
nop
xor %rdi, %rdi
mov (%r13), %r8w
lea oracles, %r13
and $0xff, %r8
shlq $12, %r8
mov (%r13,%r8,1), %r8
pop %rdi
pop %r8
pop %r15
pop %r14
pop %r13
pop %r11
pop %r10
ret
/*
<gen_faulty_load>
[REF]
{'src': {'NT': False, 'same': True, 'congruent': 0, 'type': 'addresses_WT', 'AVXalign': False, 'size': 2}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'NT': False, 'same': True, 'congruent': 0, 'type': 'addresses_WT', 'AVXalign': False, 'size': 8}}
{'OP': 'STOR', 'dst': {'NT': False, 'same': True, 'congruent': 0, 'type': 'addresses_WT', 'AVXalign': False, 'size': 1}}
{'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 1, 'type': 'addresses_D', 'AVXalign': False, 'size': 1}}
{'OP': 'STOR', 'dst': {'NT': False, 'same': True, 'congruent': 0, 'type': 'addresses_WT', 'AVXalign': False, 'size': 8}}
{'OP': 'STOR', 'dst': {'NT': False, 'same': True, 'congruent': 0, 'type': 'addresses_WT', 'AVXalign': False, 'size': 32}}
[Faulty Load]
{'src': {'NT': False, 'same': True, 'congruent': 0, 'type': 'addresses_WT', 'AVXalign': False, 'size': 2}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'src': {'NT': False, 'same': False, 'congruent': 0, 'type': 'addresses_A_ht', 'AVXalign': False, 'size': 16}, 'OP': 'LOAD'}
{'58': 2}
58 58
*/
 
 | 
					
	;Find the 21th Fibonacci term.
                
mov si,0 ;first fibonacci number f0
mov di,1 ;second fibonacci number f1
mov bx,0
mov cx,19
fibonacci:
     
    mov bx,di
    add di,si
    mov si,bx
    loop fibonacci
    
    
 
 | 
					
	/****************************************************************************
*
*    Copyright (c) 2019 Vivante Corporation
*
*    Permission is hereby granted, free of charge, to any person obtaining a
*    copy of this software and associated documentation files (the "Software"),
*    to deal in the Software without restriction, including without limitation
*    the rights to use, copy, modify, merge, publish, distribute, sublicense,
*    and/or sell copies of the Software, and to permit persons to whom the
*    Software is furnished to do so, subject to the following conditions:
*
*    The above copyright notice and this permission notice shall be included in
*    all copies or substantial portions of the Software.
*
*    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
*    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
*    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
*    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
*    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
*    FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
*    DEALINGS IN THE SOFTWARE.
*
*****************************************************************************/
#include "NpuBackend.hpp"
#include "NpuBackendId.hpp"
#include "NpuWorkloadFactory.hpp"
#include "NpuLayerSupport.hpp"
#include "NpuTensorAllocator.hpp"
#include "NpuBackendContext.hpp"
#include <backendsCommon/IBackendContext.hpp>
#include <backendsCommon/IMemoryManager.hpp>
#include <backendsCommon/BackendRegistry.hpp>
#include <Optimizer.hpp>
#include <boost/cast.hpp>
namespace armnn
{
const BackendId& NPUBackend::GetIdStatic()
{
    static const BackendId s_Id{NpuBackendId()};
    return s_Id;
}
IBackendInternal::IWorkloadFactoryPtr NPUBackend::CreateWorkloadFactory(
    const IBackendInternal::IMemoryManagerSharedPtr& memoryManager) const
{
    return std::make_unique<NpuWorkloadFactory>();
}
IBackendInternal::IBackendContextPtr NPUBackend::CreateBackendContext(const IRuntime::CreationOptions& options) const
{
    return IBackendContextPtr{ new NpuBackendContext{options} };
}
IBackendInternal::IMemoryManagerUniquePtr NPUBackend::CreateMemoryManager() const
{
    return std::make_unique<NPUTensorAllocator>();
}
IBackendInternal::Optimizations NPUBackend::GetOptimizations() const
{
    return Optimizations{};
}
IBackendInternal::ILayerSupportSharedPtr NPUBackend::GetLayerSupport() const
{
    static ILayerSupportSharedPtr layerSupport{new NpuLayerSupport};
    return layerSupport;
}
} // namespace armnn
 
 | 
					
	/*
   Copyright [2019-20] [IBM Corporation]
   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at
       http://www.apache.org/licenses/LICENSE-2.0
   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
*/
#include <iostream>
#include <unistd.h>
#include <boost/program_options.hpp>
#include <common/exceptions.h>
#include <common/str_utils.h> /* random_string */
#include <common/utils.h> /* MiB */
#include <api/components.h>
#include <api/mcas_itf.h>
struct {
  std::string addr;
  std::string device;
  unsigned    debug_level;
  unsigned    patience;
} Options;
int main(int argc, char* argv[])
{
  using namespace component;
  try {
    namespace po = boost::program_options;
    po::options_description desc("Options");
    desc.add_options()("help", "Show help")
      ("debug", po::value<unsigned>()->default_value(0), "Debug level 0-3")
      ("patience", po::value<unsigned>()->default_value(30), "Patience with server (seconds)")
      ("server", po::value<std::string>()->default_value("10.0.0.101:11911:verbs"), "Server address IP:PORT[:PROVIDER]")
      ("device", po::value<std::string>()->default_value("mlx5_0"), "Network device (e.g., mlx5_0)")
      ;
    po::variables_map vm;
    po::store(po::parse_command_line(argc, argv, desc), vm);
    if (vm.count("help") > 0) {
      std::cout << desc;
      return -1;
    }
    Options.addr        = vm["server"].as<std::string>();
    Options.debug_level = vm["debug"].as<unsigned>();
    Options.patience    = vm["patience"].as<unsigned>();
    Options.device      = vm["device"].as<std::string>();
  }
  catch (...) {
    std::cerr << "bad command line option configuration\n";
    return -1;
  }
  /* load component and create factory */
  IBase *comp = load_component("libcomponent-mcasclient.so", mcas_client_factory);
  auto factory = static_cast<IMCAS_factory *>(comp->query_interface(IMCAS_factory::iid()));
  assert(factory);
  /* create instance of MCAS client session */
  auto mcas = factory->mcas_create(1 /* debug level, 0=off */,
                                   Options.patience,
                                   getlogin(),
                                   Options.addr, /* MCAS server endpoint */
                                   Options.device); /* see mcas_client.h */
  factory->release_ref();
  assert(mcas);
  /* open existing pool or create one */
  const std::string poolname = "myBasicPool";
  auto pool = mcas->open_pool(poolname, 0);
  if (pool == IKVStore::POOL_ERROR) {
    /* ok, try to create pool instead */
    pool = mcas->create_pool(poolname, MiB(32));
  }
  assert(pool != IKVStore::POOL_ERROR);
  auto key = common::random_string(8);
  std::string value = "This is my value " + common::random_string(8);
  /* add new item to pool */
  if(mcas->put(pool,
               key,
               value) != S_OK)
    throw General_exception("put failed unexpectedly.");
  std::cout << "Put " << key << " [" << value << "]\n";
  /* get the item back */
  std::string retrieved_value;
  if(mcas->get(pool, key, retrieved_value) != S_OK)
    throw General_exception("get failed unexpectedly.");
  std::cout << "Retrieved [" << retrieved_value << "]\n";
  /* close pool */
  mcas->close_pool(pool);
  /* cleanup */
  mcas->release_ref();
  return 0;
}
 
 | 
					
	#include "Entity.h"
#include "ECS.h"
namespace Logic {
Entity::Entity(std::string name_)
    : name(name_)
{
    id = ECS::GetNewId();
    // Setup();
}
DrawObject Entity::getDrawObject() { return { nullptr, nullptr, nullptr }; }
} 
 | 
					
	;
;
;
; This license is set out in https://raw.githubusercontent.com/Broadcom-Network-Switching-Software/OpenBCM/master/Legal/LICENSE file.
; 
; Copyright 2007-2019 Broadcom Inc. All rights reserved.
; 
;
; This LED program simply mirrors bits from the LED data area directly to
; the LED scan chain, effectively allowing the host CPU to write directly
; to the LEDs as memory-mapped bits.
;
;
; After this program is downloaded and starts executing, it increments
; the byte at address 0x80 once per frame.  This may help the host
; synchronize writes to frame updates, if needed.
;
; Next, the user program should write the length of the scan chain in
; bits to location 0x81.  This only needs to be done once.
;
; Next, the actual LED bits may be updated by writing to bytes to
; addresses 0x82 and above:
;
;	Byte 0x82 bits 7:0 are the first 8 bits on the scan chain
;	Byte 0x83 bits 7:0 are the second 8 bits on the scan chain
;	Etc.
;
; Remember that:
;	LED Data address 0x80 corresponds to PCI offset 0x1e00 (word write).
;	LED Data address 0x81 corresponds to PCI offset 0x1e04 (word write).
;	Etc.
;
BYTE_PTR	equ	0x7f
FRAME_COUNT	equ	0x80
BIT_COUNT	equ	0x81
BIT_DATA	equ	0x82
;
; Main Update Routine
;
;  This routine is called once per tick.
;
update:
	inc	(FRAME_COUNT)
	ld	a,BIT_DATA
	ld	(BYTE_PTR),a
	ld	b,(BIT_COUNT)
loop:
	ld	a,(BYTE_PTR)
	inc	(BYTE_PTR)
	ld	a,(a)
	call	shift_bit
	call	shift_bit
	call	shift_bit
	call	shift_bit
	call	shift_bit
	call	shift_bit
	call	shift_bit
	call	shift_bit
	cmp	b,0
	jnz	loop
	ld	b,(BIT_COUNT)
	send	b
;
; shift_bit
;	A: current byte
;	B: number of bits remaining
;
; Never shifts more than 'B' bits.
;
shift_bit:
	cmp	b,0
	jnz	sb1
	ret
sb1:
	dec	b
	tst	a,7
	ror	a
	jnc	sb2
	pushst	ZERO
	pack
	ret
sb2:
	pushst	ONE
	pack
	ret
;
; Symbolic names for the bits of the port status fields
;
RX		equ	0x0	; received packet
TX		equ	0x1	; transmitted packet
COLL		equ	0x2	; collision indicator
SPEED_C		equ	0x3	; 100 Mbps
SPEED_M		equ	0x4	; 1000 Mbps
DUPLEX		equ	0x5	; half/full duplex
FLOW		equ	0x6	; flow control capable
LINKUP		equ	0x7	; link down/up status
LINKEN		equ	0x8	; link disabled/enabled status
ZERO		equ	0xE	; always 0
ONE		equ	0xF	; always 1
 
 | 
					
	; A138279: Last digit of A136324. After 0, 1, period 4: repeat [1, 2, 5, 6] = A131800.
; 0,1,1,2,5,6,1,2,5,6,1,2,5,6,1,2,5,6,1,2,5,6,1,2,5,6,1,2,5,6,1,2,5,6,1,2,5,6,1,2,5,6,1,2,5,6,1,2,5,6,1,2,5,6,1,2,5,6,1,2,5,6,1,2,5,6,1,2,5,6,1,2,5,6,1,2,5,6,1,2,5,6,1,2,5,6
mov $3,1
lpb $0
  add $0,2
  mod $0,4
  add $2,2
  bin $2,$3
  mov $3,2
lpe
max $2,1
add $0,$2
sub $0,1
 
 | 
					
	// Tests different ways of scrolling up the screen
  // Commodore 64 PRG executable file
.file [name="test-scroll-up.prg", type="prg", segments="Program"]
.segmentdef Program [segments="Basic, Code, Data"]
.segmentdef Basic [start=$0801]
.segmentdef Code [start=$80d]
.segmentdef Data [startAfter="Code"]
.segment Basic
:BasicUpstart(main)
  .label screen = $400
.segment Code
main: {
    // scrollup1()
    jsr scrollup1
    // scrollup2()
    jsr scrollup2
    // scrollup3()
    jsr scrollup3
    // }
    rts
}
scrollup1: {
    .label __4 = 2
    .label line = 4
    .label __5 = 8
    .label __6 = 2
    lda #<0
    sta.z line
    sta.z line+1
  __b1:
    // for (word line = 0; line < 40*24; line += 40)
    lda.z line+1
    cmp #>$28*$18
    bcc __b4
    bne !+
    lda.z line
    cmp #<$28*$18
    bcc __b4
  !:
    // }
    rts
  __b4:
    ldx #0
  __b2:
    // for (byte c=0; c<40; ++c)
    cpx #$28
    bcc __b3
    // line += 40
    lda #$28
    clc
    adc.z line
    sta.z line
    bcc !+
    inc.z line+1
  !:
    jmp __b1
  __b3:
    // line+c
    txa
    clc
    adc.z line
    sta.z __4
    lda #0
    adc.z line+1
    sta.z __4+1
    // screen[line+c] = screen[line+c+40]
    lda.z __4
    clc
    adc #<screen+$28
    sta.z __5
    lda.z __4+1
    adc #>screen+$28
    sta.z __5+1
    lda.z __6
    clc
    adc #<screen
    sta.z __6
    lda.z __6+1
    adc #>screen
    sta.z __6+1
    ldy #0
    lda (__5),y
    sta (__6),y
    // for (byte c=0; c<40; ++c)
    inx
    jmp __b2
}
scrollup2: {
    .label line1 = 6
    .label line2 = 4
    .label l = $a
    lda #0
    sta.z l
    lda #<screen
    sta.z line1
    lda #>screen
    sta.z line1+1
    lda #<screen+$28
    sta.z line2
    lda #>screen+$28
    sta.z line2+1
  __b1:
    ldx #0
  __b2:
    // *line1++ = *line2++
    ldy #0
    lda (line2),y
    sta (line1),y
    // *line1++ = *line2++;
    inc.z line1
    bne !+
    inc.z line1+1
  !:
    inc.z line2
    bne !+
    inc.z line2+1
  !:
    // for (byte c: 0..39)
    inx
    cpx #$28
    bne __b2
    // for( byte l: 0..23 )
    inc.z l
    lda #$18
    cmp.z l
    bne __b1
    // }
    rts
}
scrollup3: {
    .label l2 = 2
    .label line = 6
    .label __3 = 8
    .label __4 = 4
    lda #<0
    sta.z line
    sta.z line+1
  __b1:
    // for (word line = 0; line < 40*24; line += 40)
    lda.z line+1
    cmp #>$28*$18
    bcc __b2
    bne !+
    lda.z line
    cmp #<$28*$18
    bcc __b2
  !:
    // }
    rts
  __b2:
    lda.z line
    sta.z l2
    lda.z line+1
    sta.z l2+1
    ldx #0
  __b3:
    // for (byte c=0; c<40; ++c)
    cpx #$28
    bcc __b4
    // line += 40
    lda #$28
    clc
    adc.z line
    sta.z line
    bcc !+
    inc.z line+1
  !:
    jmp __b1
  __b4:
    // screen[l2++] = screen[l2+40]
    lda.z l2
    clc
    adc #<screen+$28
    sta.z __3
    lda.z l2+1
    adc #>screen+$28
    sta.z __3+1
    lda.z l2
    clc
    adc #<screen
    sta.z __4
    lda.z l2+1
    adc #>screen
    sta.z __4+1
    ldy #0
    lda (__3),y
    sta (__4),y
    // screen[l2++] = screen[l2+40];
    inc.z l2
    bne !+
    inc.z l2+1
  !:
    // for (byte c=0; c<40; ++c)
    inx
    jmp __b3
}
 
 | 
					
	.global s_prepare_buffers
s_prepare_buffers:
push %r10
push %r11
push %r15
push %r9
push %rcx
push %rdi
push %rdx
push %rsi
lea addresses_A_ht+0x14eba, %r11
nop
nop
nop
nop
and $21061, %rdx
mov $0x6162636465666768, %r10
movq %r10, (%r11)
nop
nop
nop
sub $27797, %r9
lea addresses_WT_ht+0x1457a, %rdx
nop
nop
nop
nop
nop
sub %r9, %r9
movups (%rdx), %xmm6
vpextrq $0, %xmm6, %r15
nop
nop
nop
sub $42426, %r10
lea addresses_D_ht+0x9d7a, %rsi
lea addresses_WT_ht+0x1ec7a, %rdi
inc %r10
mov $79, %rcx
rep movsb
nop
nop
add %rcx, %rcx
lea addresses_WT_ht+0xa884, %rcx
add %r15, %r15
vmovups (%rcx), %ymm1
vextracti128 $1, %ymm1, %xmm1
vpextrq $0, %xmm1, %rdi
dec %r10
lea addresses_D_ht+0xad7a, %rsi
lea addresses_UC_ht+0x123fa, %rdi
cmp $25869, %r10
mov $12, %rcx
rep movsq
nop
nop
nop
add %r9, %r9
lea addresses_WT_ht+0x10f7a, %rdx
nop
nop
nop
nop
xor $24924, %rdi
movl $0x61626364, (%rdx)
nop
nop
nop
nop
xor $35314, %r15
lea addresses_WT_ht+0x19a7a, %rsi
lea addresses_UC_ht+0x1857a, %rdi
nop
nop
nop
nop
nop
cmp %r9, %r9
mov $2, %rcx
rep movsl
nop
nop
nop
nop
nop
and %rsi, %rsi
lea addresses_UC_ht+0xa472, %rdi
nop
nop
cmp $26922, %r10
movw $0x6162, (%rdi)
nop
nop
sub $15722, %r15
pop %rsi
pop %rdx
pop %rdi
pop %rcx
pop %r9
pop %r15
pop %r11
pop %r10
ret
    .global s_faulty_load
s_faulty_load:
push %r11
push %r14
push %rax
push %rdi
push %rsi
// Faulty Load
lea addresses_A+0x5d7a, %r14
nop
nop
nop
add $9572, %rax
mov (%r14), %di
lea oracles, %r14
and $0xff, %rdi
shlq $12, %rdi
mov (%r14,%rdi,1), %rdi
pop %rsi
pop %rdi
pop %rax
pop %r14
pop %r11
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_A', 'NT': False, 'AVXalign': False, 'size': 8, 'congruent': 0}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'same': True, 'type': 'addresses_A', 'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 0}}
<gen_prepare_buffer>
{'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_A_ht', 'NT': False, 'AVXalign': False, 'size': 8, 'congruent': 6}}
{'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_WT_ht', 'NT': False, 'AVXalign': False, 'size': 16, 'congruent': 10}}
{'OP': 'REPM', 'src': {'same': True, 'congruent': 11, 'type': 'addresses_D_ht'}, 'dst': {'same': False, 'congruent': 8, 'type': 'addresses_WT_ht'}}
{'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_WT_ht', 'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 1}}
{'OP': 'REPM', 'src': {'same': False, 'congruent': 10, 'type': 'addresses_D_ht'}, 'dst': {'same': False, 'congruent': 6, 'type': 'addresses_UC_ht'}}
{'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_WT_ht', 'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 9}}
{'OP': 'REPM', 'src': {'same': False, 'congruent': 6, 'type': 'addresses_WT_ht'}, 'dst': {'same': False, 'congruent': 11, 'type': 'addresses_UC_ht'}}
{'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_UC_ht', 'NT': True, 'AVXalign': False, 'size': 2, 'congruent': 3}}
{'35': 21829}
35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35
*/
 
 | 
					
	#include <bits/stdc++.h>
using namespace std;
#define lli long long int
int isPrime[1000001];
void buildSieve()
{
  for (int i = 0; i <= 1000000; i ++) isPrime[i] = 1;
  isPrime[0] = isPrime[1] = 0; isPrime[2] = 1;
  for (int i = 2; i <= 1000; i ++)
    for (int j = 2; j * i <= 1000000; j ++)
      isPrime[i*j] = 0;
}
int main()
{
  buildSieve();
  // for (int i = 0; i < 100; i ++)
  //   printf("%d - %s\n", i, isPrime[i] ? "Prime" : "Not Prime");
  int n; scanf("%d", &n);
  while (n --)
  {
    lli x; scanf("%lld", &x);
    double rEnd = sqrt(x); lli end = rEnd;
    int can = 1;
    if (rEnd == end && x != 1) can = isPrime[end];
    else can = 0;
    printf("%s\n", can ? "YES" : "NO");
  }
  return(0);
} 
 | 
					
	; A308047: Sum of subgroup indices of dihedral group, Sum_{H <= D(n)} [D(n):H].
; 3,11,18,35,38,74,66,115,117,166,146,266,198,298,308,403,326,533,402,630,564,682,578,970,713,934,900,1162,902,1444,1026,1491,1316,1558,1396,2093,1446,1930,1812,2390,1766,2692,1938,2730,2522,2794,2306,3658,2565,3441
add $0,1
mov $2,$0
lpb $0
  mov $3,$2
  dif $3,$0
  cmp $3,$2
  cmp $3,0
  mul $3,$0
  sub $0,1
  mov $4,$3
  add $4,1
  mov $5,$4
  mul $5,$3
  add $3,$5
  add $1,$3
lpe
add $1,3
mov $0,$1
 
 | 
					
	; A271939: Number of edges in the n-th order Sierpinski carpet graph.
; 8,88,776,6424,52040,418264,3351944,26833048,214716872,1717892440,13743611912,109950312472,879606751304,7036866765016,56294972383880,450359893862296,3602879495272136,28823036995298392,230584299061751048,1844674401792100120
add $0,1
mov $1,3
pow $1,$0
mov $2,8
pow $2,$0
sub $2,$1
mov $0,$2
mul $0,4
div $0,20
mul $0,8
 
 | 
					
	.global s_prepare_buffers
s_prepare_buffers:
push %r10
push %r14
push %r15
push %rbx
push %rcx
push %rdi
push %rsi
lea addresses_WC_ht+0x17832, %rsi
lea addresses_D_ht+0x19b2, %rdi
nop
nop
and $60497, %rbx
mov $50, %rcx
rep movsw
nop
nop
nop
nop
nop
and %r15, %r15
lea addresses_A_ht+0xcba2, %rsi
lea addresses_D_ht+0x6eb2, %rdi
nop
nop
dec %r15
mov $74, %rcx
rep movsw
nop
cmp %rcx, %rcx
lea addresses_A_ht+0x152b2, %r10
nop
nop
nop
cmp $24956, %rdi
mov $0x6162636465666768, %rbx
movq %rbx, %xmm1
vmovups %ymm1, (%r10)
nop
nop
nop
nop
nop
cmp $57100, %r10
lea addresses_normal_ht+0x1dfc2, %rbx
nop
add %r14, %r14
mov (%rbx), %r10d
nop
nop
nop
nop
nop
xor %r15, %r15
lea addresses_WC_ht+0x22b2, %rbx
sub %r15, %r15
movb (%rbx), %cl
nop
xor %rsi, %rsi
lea addresses_normal_ht+0x6b2, %rsi
clflush (%rsi)
nop
nop
nop
nop
cmp $44394, %r15
movl $0x61626364, (%rsi)
nop
nop
nop
nop
nop
add $13129, %rdi
lea addresses_WC_ht+0x1e032, %rdi
nop
nop
nop
nop
nop
cmp %r15, %r15
movw $0x6162, (%rdi)
nop
nop
nop
nop
and %rdi, %rdi
lea addresses_WT_ht+0x16eb2, %rsi
nop
nop
add $50865, %rdi
mov (%rsi), %r10
nop
nop
nop
inc %rsi
lea addresses_D_ht+0xd2b2, %rcx
nop
sub %rdi, %rdi
movb $0x61, (%rcx)
nop
inc %rsi
pop %rsi
pop %rdi
pop %rcx
pop %rbx
pop %r15
pop %r14
pop %r10
ret
    .global s_faulty_load
s_faulty_load:
push %r9
push %rax
push %rcx
push %rdi
push %rdx
push %rsi
// Faulty Load
lea addresses_RW+0x8eb2, %r9
nop
and $16700, %rdi
movups (%r9), %xmm1
vpextrq $0, %xmm1, %rdx
lea oracles, %r9
and $0xff, %rdx
shlq $12, %rdx
mov (%r9,%rdx,1), %rdx
pop %rsi
pop %rdx
pop %rdi
pop %rcx
pop %rax
pop %r9
ret
/*
<gen_faulty_load>
[REF]
{'src': {'type': 'addresses_RW', 'same': False, 'size': 32, 'congruent': 0, 'NT': False, 'AVXalign': True}, 'OP': 'LOAD'}
[Faulty Load]
{'src': {'type': 'addresses_RW', 'same': True, 'size': 16, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'src': {'type': 'addresses_WC_ht', 'congruent': 7, 'same': False}, 'dst': {'type': 'addresses_D_ht', 'congruent': 8, 'same': True}, 'OP': 'REPM'}
{'src': {'type': 'addresses_A_ht', 'congruent': 4, 'same': False}, 'dst': {'type': 'addresses_D_ht', 'congruent': 11, 'same': False}, 'OP': 'REPM'}
{'dst': {'type': 'addresses_A_ht', 'same': False, 'size': 32, 'congruent': 10, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
{'src': {'type': 'addresses_normal_ht', 'same': False, 'size': 4, 'congruent': 3, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_WC_ht', 'same': False, 'size': 1, 'congruent': 6, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
{'dst': {'type': 'addresses_normal_ht', 'same': False, 'size': 4, 'congruent': 10, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
{'dst': {'type': 'addresses_WC_ht', 'same': False, 'size': 2, 'congruent': 5, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
{'src': {'type': 'addresses_WT_ht', 'same': False, 'size': 8, 'congruent': 7, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
{'dst': {'type': 'addresses_D_ht', 'same': False, 'size': 1, 'congruent': 10, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
{'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
*/
 
 | 
					
	;       Z88 Small C+ Run Time Library 
;       Long functions
;
SECTION code_clib
SECTION code_l_sccz80
PUBLIC    l_glong
PUBLIC    l_glonghlp
;Fetch long dehl from (hl)
.l_glonghlp
    ld a,(hl)
    inc hl
    ld h,(hl)
    ld l,a
.l_glong
    ld e,(hl)
    inc hl
    ld d,(hl)
    inc hl
    ld a,(hl)
    inc hl
    ld h,(hl)
    ld l,a
    ex de,hl
    ret
 
 | 
					
	.global s_prepare_buffers
s_prepare_buffers:
push %r14
push %r15
push %rbp
push %rbx
push %rcx
push %rdi
push %rdx
push %rsi
lea addresses_D_ht+0x1ab0, %rsi
lea addresses_UC_ht+0x14710, %rdi
xor %rbx, %rbx
mov $107, %rcx
rep movsl
nop
nop
nop
nop
add %rbp, %rbp
lea addresses_WT_ht+0xe110, %rsi
lea addresses_normal_ht+0x1d710, %rdi
clflush (%rdi)
nop
nop
nop
nop
nop
sub $27649, %rbp
mov $26, %rcx
rep movsb
nop
nop
nop
nop
nop
xor $37979, %rsi
lea addresses_WC_ht+0x145a4, %rsi
lea addresses_A_ht+0x13890, %rdi
clflush (%rdi)
nop
add %rdx, %rdx
mov $20, %rcx
rep movsb
nop
nop
nop
add %rsi, %rsi
lea addresses_WC_ht+0xc680, %rbp
nop
dec %r14
and $0xffffffffffffffc0, %rbp
movntdqa (%rbp), %xmm7
vpextrq $0, %xmm7, %rcx
nop
nop
nop
nop
cmp $46569, %rdx
lea addresses_UC_ht+0x4890, %rdx
clflush (%rdx)
nop
nop
nop
and $29711, %r14
movups (%rdx), %xmm7
vpextrq $0, %xmm7, %rdi
nop
nop
cmp %rdi, %rdi
lea addresses_WC_ht+0x9910, %rbp
nop
nop
nop
nop
xor $5798, %rdi
movw $0x6162, (%rbp)
nop
nop
nop
xor $52733, %r14
lea addresses_D_ht+0x1b77c, %rsi
lea addresses_normal_ht+0x764e, %rdi
nop
nop
cmp $38253, %r15
mov $57, %rcx
rep movsw
nop
nop
nop
nop
nop
cmp $48622, %r15
lea addresses_A_ht+0x16b50, %rsi
lea addresses_UC_ht+0xc890, %rdi
nop
nop
sub %rbx, %rbx
mov $0, %rcx
rep movsb
add %r15, %r15
lea addresses_WT_ht+0xbd00, %rsi
lea addresses_UC_ht+0x14310, %rdi
nop
nop
nop
nop
nop
and $64464, %rbp
mov $54, %rcx
rep movsb
nop
nop
cmp $64394, %rbx
lea addresses_A_ht+0x1c374, %rbp
xor %rdi, %rdi
mov (%rbp), %esi
nop
nop
nop
nop
sub %rbx, %rbx
pop %rsi
pop %rdx
pop %rdi
pop %rcx
pop %rbx
pop %rbp
pop %r15
pop %r14
ret
    .global s_faulty_load
s_faulty_load:
push %r10
push %r12
push %r13
push %r8
push %rcx
// Faulty Load
lea addresses_D+0x16710, %r13
nop
nop
nop
nop
nop
sub %r8, %r8
mov (%r13), %r10d
lea oracles, %rcx
and $0xff, %r10
shlq $12, %r10
mov (%rcx,%r10,1), %r10
pop %rcx
pop %r8
pop %r13
pop %r12
pop %r10
ret
/*
<gen_faulty_load>
[REF]
{'src': {'type': 'addresses_D', 'AVXalign': False, 'size': 2, 'NT': True, 'same': True, 'congruent': 0}, 'OP': 'LOAD'}
[Faulty Load]
{'src': {'type': 'addresses_D', 'AVXalign': False, 'size': 4, 'NT': False, 'same': True, 'congruent': 0}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'src': {'type': 'addresses_D_ht', 'congruent': 4, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_UC_ht', 'congruent': 11, 'same': False}}
{'src': {'type': 'addresses_WT_ht', 'congruent': 7, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_normal_ht', 'congruent': 11, 'same': False}}
{'src': {'type': 'addresses_WC_ht', 'congruent': 2, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_A_ht', 'congruent': 6, 'same': False}}
{'src': {'type': 'addresses_WC_ht', 'AVXalign': False, 'size': 16, 'NT': True, 'same': False, 'congruent': 1}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_UC_ht', 'AVXalign': False, 'size': 16, 'NT': False, 'same': False, 'congruent': 7}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'type': 'addresses_WC_ht', 'AVXalign': False, 'size': 2, 'NT': False, 'same': True, 'congruent': 9}}
{'src': {'type': 'addresses_D_ht', 'congruent': 0, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_normal_ht', 'congruent': 0, 'same': False}}
{'src': {'type': 'addresses_A_ht', 'congruent': 5, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_UC_ht', 'congruent': 6, 'same': False}}
{'src': {'type': 'addresses_WT_ht', 'congruent': 4, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_UC_ht', 'congruent': 9, 'same': False}}
{'src': {'type': 'addresses_A_ht', 'AVXalign': False, 'size': 4, 'NT': False, 'same': False, 'congruent': 1}, '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
*/
 
 | 
					
	
; void wa_priority_queue_destroy(ba_priority_queue_t *q)
SECTION code_clib
SECTION code_adt_wa_priority_queue
PUBLIC wa_priority_queue_destroy
EXTERN asm_wa_priority_queue_destroy
defc wa_priority_queue_destroy = asm_wa_priority_queue_destroy
 
 | 
					
	//******************************************************************************
// alttp_msu.asm
// 
// Author:        qwertymodo
// Date Created:  1 Nov 2014
// Date Modified: 7 Nov 2014
// Assembler:     bass v14
//
// Implements MSU-1 audio streaming in The Legend of Zelda: A Link to the Past
// Original patch by Conn, disassembled and continued by qwertymodo.
//
// This patch is intended to be applied directly by bass.  Patch should be
// applied to an unheadered ROM.  Requires expanded ROM, but bass can expand the
// ROM if EXPAND_ROM is defined below.
//
// Unheadered ROM MD5: 608C22B8FF930C62DC2DE54BCD6EBA72
//
// Usage: bass -o [romfile] alttp_msu.asm
//
// See README.md for more information
//
//******************************************************************************
arch snes.cpu
macro seek(variable offset) {
  origin ((offset & $7F0000) >> 1) | (offset & $7FFF)
  base offset
}
// Comment out this line if applying to an already expanded ROM
define EXPAND_ROM()
if {defined EXPAND_ROM} {
    origin 0x100000
    fill 0x80000, 0xFF
}
// Header checksum
seek($FFDC)
    dw 0xB2FB // Checksum complement
    dw 0x4D04 // ROM checksum
// the following codes are hooks in the native rom – mainly when music is stored
// to the controller $012C
seek($0080D9)
    jsl msu_main
    nop
    nop
seek($0080F3)
    jsl msu_check
    nop
    nop
seek($00F40F)
    jsl enter_house
    nop
    nop
    nop
seek($00F9C3)
    jsl fade_out
    nop
seek($02934F)
    jsl enter_house
    nop
    nop
    nop
seek($029A04)
    jsl fade_out
    nop
seek($029B14)
    jsl fade_out
    nop
seek($02A027)
    jsl fade_out
    nop
seek($02AAB1)
    jsl fade_out
    nop
seek($02AE7E)
    jsl fade_out
    nop
seek($06B0D8)
    jsl map_open
    nop
seek($06B112)
    jsl full_volume
    nop
seek($06C621)
    jsl great_fairy
    nop
seek($06C847)
    jsl great_fairy
    nop
seek($07AA9C)
    jsl map_open
    nop
seek($07EB90)
    jsl full_volume
    nop
seek($08C606)
    jml boss_victory
    nop
seek($08CD07)
    jsl fade_out
    nop
seek($08D05C)
    jsl full_volume
    nop
seek($098D2C)
    jsl map_open
    nop
seek($09F2B2)
    jsl fade_out
    nop
seek($09F50F)
    jsl fade_out
    nop
seek($0AB940)
    jsl $22EB00
    nop
    nop
    nop
seek($0ABA1E)
    jsl map_open
    nop
seek($0ABC90)
    jsl full_volume
    nop
seek($0AEFB5)
    jsl full_volume
    nop
seek($0CCF7A)
    jsl fade_out
    nop
seek($0CF105)
    jsl fade_out
    nop
seek($0EDA31)
    jsl map_open
    nop
// this code selects whether the current theme is repeated or played one
// time (store to $2007)
seek($22E880)
set_loop:
    lda $0129   // $0129 was free ram, it is a mirror of the current played theme
    cmp #$01    // compares now with the themes 01,08,... which do not repeat
    bne +
    lda #$01    // if match, load #$01 (not repeat) then return
    rts
+;  cmp #$08
    bne +
    lda #$01
    rts
+;  cmp #$0A
    bne +
    lda #$01
    rts
+;  cmp #$0F
    bne +
    lda #$01
    rts
+;  cmp #$13
    bne +
    lda #$01
    rts
+;  cmp #$1D
    bne +
    lda #$01
    rts
+;  cmp #$21
    bne +
    lda #$01
    rts
+;  cmp #$22
    bne +
    lda #$01
    rts
+;  lda #$03    // if no match it is a theme that repeats (#$03)
    rts
seek($22E900)
msu_main:
    lda $4210   // native code overwritten by hook
    jsr msu_load
    jsr msu_play
    lda $012C   // native code overwritten by hook
    rtl
seek($22E910)
msu_load:
    lda $0133
    bne +       // if $0133 is #$0 return
    rts
+;  cmp #$F1    // if $0133 is #$F1 go to music fade out
    beq +
    jsr track_select   // load new track routine if no fade out
    rts
+;  lda $7EE004 // intermediate state (free ram) for fade-out
    bne +
    rts
+;  dec         // fade out decrease volume
    dec         // fade out decrease volume
    cmp #$20    // check if fade out volume is below #$20
    bcc +
    sta $7EE004 // store fade out volume until next routine run
    sta $2006   // store to msu volume register
    rts
+;  lda #$00    // mute sound if volume level is below #$20
    sta $7EE004
    sta $2006
    stz $2005
    stz $0129
    rts
// this routine checks whether music register has to be muted -> this is the case
// when MSU is enabled
seek($22E950)
msu_check:
    sta $0133   // native code
    pha
    lda $2002   // check if MSU is enabled
    cmp #$53
    beq +
    pla
    sta $2140
    rtl         // if not return
+;  lda $2000
    and #$08    // if track missing -> spc fallback
    bne +
    lda #$F1
    sta $2140   // if MSU, mute $2140
+;  pla
    rtl
// SPC fallback (sd2snes only or bsnes 0.89 ff)
seek($22E970)
spc_play:
    lda $2000   // load MSU status
    and #$08    // isolate error bit (track not found)
    bne +
    rts
+;  lda $0129   // if error bit is set, play spc
    sta $2140
    sta $0133
    sta $0130
    stz $2007
    sta $012C
    rts
// track selector - MSU main code
seek($22E990)
track_select:
    lda $0133   // load music register
    cmp #$F4    // check if mute, if yes return
    bne +
    rts
+;  cmp #$F1    // check if fade-out, if yes return
    bne +
    rts
+;  lda $2002   // check if msu-enabled, if not return
    cmp #$53
    beq +
    rts
+;  lda #$00    // reset fade-out counter
    sta $7EE004
    lda $0133   // load music register
    sta $0130   // part of native code
    cmp $0129   // check if track played already
    beq ++      // if played, return
    lda $0133   // load music register
    bne +
    lda $012C   // if #$00 load music control $012C
+;  sta $2004   // store track to play
    sta $0129   // store to free ram (msu track)
    stz $2005   // new track id
    stz $012C   // reset $012C
    lda #$FF
    sta $2006   // max volume
    lda #$01
    sta $0127   // store intermediate free ram to tell new track
    lda $2000   // check msu-status
    beq ++
+;  rts
+;  lda #$F1    // if msu enabled mute spc
    sta $2140
    sta $0133
    rts
// fade-out volume level decrease
seek($22E9F0)
fade_out:
    lda $2002   // check msu enabled
    cmp #$53
    bne ++      // if not -> native fade-out routine
    lda $7EE004 // check if fade-out counter already in fade-out mode
    bne +       // if yes, do not enable
    lda #$F1    // enable counter
    sta $7EE004
+;  lda #$F1    // fade-out mute registers
    sta $012C
    sta $0130
    sta $2140
    sta $0133
    rtl
+;  lda #$F1
    sta $012C
    rtl
// map music volume decrease
seek($22EA20)
map_open:
    lda $2002
    cmp #$53
    bne +
    lda #$75    // set volume to #$75 instead of #$FF
    sta $2006
    rtl
+;  lda #$F2
    sta $012C
    rtl
// restore full volume when back to game from map
seek($22EA50)
full_volume:
    lda $2002
    cmp #$53
    bne +
    lda #$FF
    sta $2006
    rtl
+;  lda #$F3
    sta $012C
    rtl
// lower volume level when entering a house
seek($22EA80)
enter_house:
    cmp #$FF
    bne +
    rtl
+;  tax
    lda $2002
    cmp #$53
    beq +
    stx $012C
    rtl
+;  lda #$FF
    sta $2006
    cpx #$F2    // check if #$F2 (half volume) to be stored, if yes store it to $2006
    beq +
    cpx #$F3
    beq ++
    txa
    jmp $EDD0
+;  lda #$75    // if #$F2, store half volume
    sta $2006
+;  rtl
// these codes cover mainly all ingame spc changes to play the specific msu tracks
// it loads the track to be stored to $2004 and jumps to $EDD0 then
seek($22EB00)
    bne +
    ldx #$F3
+;  lda $2002
    cmp #$53
    bne ++
    lda #$FF
    sta $2006
    cpx #$F3
    beq +
    stx $2004
    txa
    jmp $EDD0
+;  jsr set_loop
    sta $2007
    rtl
+;  stx $012C
    rtl
seek($22EC80)
great_fairy:
    lda $2002
    cmp #$53
    bne +
    lda #$FF
    sta $2006
    lda #$1B
    stz $0129
    jmp $EDD0
    rtl
+;  lda #$1B
    sta $012C
    rtl
seek($22EDD0)
    sta $0130
    sta $012C
    rtl
// code when defeated a boss to let acquire crystal play until end before loading sage in crystal theme
seek($22EDD7)
boss_victory:
    lda $2002
    cmp #$53
    beq ++
    lda $2140
    bne +
    jml $08C60B
+;  jml $08C613
+;  lda $2000
    and #$10
    bne +
    jml $08C60B
+;  jml $08C613
// code to play msu
seek($22EE30)
msu_play:
    lda $0127   // check if new track is induced
    beq +
    bit $2000   // check msu ready
    bvs +
    stz $0127   // reset inducing new track
    lda $0130
    jsr set_loop// select if track is repeated or not
    sta $2007
    jsr spc_play// spc fallback if track not found
+;  rts 
 | 
					
	;;
;; Copyright (c) 2012-2021, Intel Corporation
;;
;; Redistribution and use in source and binary forms, with or without
;; modification, are permitted provided that the following conditions are met:
;;
;;     * Redistributions of source code must retain the above copyright notice,
;;       this list of conditions and the following disclaimer.
;;     * Redistributions in binary form must reproduce the above copyright
;;       notice, this list of conditions and the following disclaimer in the
;;       documentation and/or other materials provided with the distribution.
;;     * Neither the name of Intel Corporation nor the names of its contributors
;;       may be used to endorse or promote products derived from this software
;;       without specific prior written permission.
;;
;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
;; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
;; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
;; DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
;; FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
;; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
;; SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
;; CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
;; OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
;; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
;;
; This code schedules 1 blocks at a time, with 4 lanes per block
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
%define FUNC sha384_block_sse
%include "sse/sha512_one_block_sse.asm"
 
 | 
					
	; A181426: Numerator of Sum_{k=1..n} k^4 / Product_{k=1..n} k^4.
; Submitted by Jamie Morken(w4)
; 1,17,49,59,979,91,167,731,5111,517,1817,6071,109,18241,22289,2771,131,28823,67,51619,11911,34891,15557,257,1949,22313,2267,14123,153931,5273999,1,3167,45091,3569,268309,126947,4217,127,369641,201679,85739
add $0,1
mov $2,$0
lpb $0
  mov $1,$2
  mov $3,$0
  mul $3,$0
  sub $0,1
  pow $3,2
  mul $2,$3
  add $4,$3
lpe
gcd $1,$4
div $4,$1
mov $0,$4
 
 | 
					
	RedPicFront:: INCBIN "gfx/player/red.pic"
ShrinkPic1::  INCBIN "gfx/player/shrink1.pic"
ShrinkPic2::  INCBIN "gfx/player/shrink2.pic"
 
 | 
					
	; A013959: a(n) = sigma_11(n), the sum of the 11th powers of the divisors of n.
; 1,2049,177148,4196353,48828126,362976252,1977326744,8594130945,31381236757,100048830174,285311670612,743375541244,1792160394038,4051542498456,8649804864648,17600780175361,34271896307634,64300154115093,116490258898220,204900053024478,350279478046112,584603613083988,952809757913928,1522433108644860,2384185839843751,3672136647383862,5559091947792280,8297561014164632,12200509765705830,17723450167663752,25408476896404832,36046397799139329,50542391825574576,70223115534342066,96549159399201744,131686747008947221,177917621779460414,238688540482452780,317477629483043624,419635308642959070,550329031716248442,717722650516483488,929293739471222708,1197268484907678036,1532286982406627382,1952307193965638472,2472159215084012304,3117943006504850428,3909821050560314793,4885196785839845799,6071197887104747832,7520537646002543414,9269035929372191598,11390579401026381720,13931234201913233112,16993404958986493080,20636016383301876560,24998844509931245670,30155888444737842660,36297634593180228744,43513917611435838662,52061969160733500768,62050958699411929208,73823022692637345793,87507833532297112788,103561360850602306224,122130132904968017084,143816974886228858802,168788342994936517344,197829227608964373456,231122292121701565272,269694457905705145365,313726685568359708378,364553207026114388286,422353753156640802148,488834247398322191660,564154396676426447328,650511662810756385576,747993810527520928880,859413112100829003486,984776461275559025161,1127624185986593057658,1287831418538085836268,1469896338537236229536,1673432471168087713884,1904122872176535328692,2161295903975256372840,2452005857376236288340,2775173073766990340490,3139656026951179505718,3543686676668915552272,3998326086051385504584,4501060865244323179136,5065454231707141210896,5688001039254907335720,6385547277321933853692,7153014030880804126754,8011223332598085010857,8953433085010371085284,10004885401585844040103
add $0,1
mov $2,$0
mov $3,8
lpb $0
  pow $3,11
  add $1,$3
  mov $3,$2
  mov $4,$0
  cmp $4,0
  add $0,$4
  dif $3,$0
  cmp $3,$2
  cmp $3,0
  mul $3,$0
  sub $0,1
lpe
sub $1,8589934591
mov $0,$1
 
 | 
					
	/* Copyright 2018 The TensorFlow Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
    http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/
#include "tensorflow/lite/micro/all_ops_resolver.h"
#include "tensorflow/lite/micro/kernels/micro_ops.h"
namespace tflite {
AllOpsResolver::AllOpsResolver() {
  // Please keep this list of Builtin Operators in alphabetical order.
  AddAbs();
  AddAdd();
  AddAddN();
  AddArgMax();
  AddArgMin();
  AddAveragePool2D();
  AddBatchToSpaceNd();
  AddCeil();
  AddConcatenation();
  AddConv2D();
  AddCos();
  AddDepthwiseConv2D();
  AddDequantize();
  AddDetectionPostprocess();
  AddElu();
  AddEqual();
  AddEthosU();
  AddFloor();
  AddFloorDiv();
  AddFullyConnected();
  AddGreater();
  AddGreaterEqual();
  AddHardSwish();
  AddL2Normalization();
  AddL2Pool2D();
  AddLeakyRelu();
  AddLess();
  AddLessEqual();
  AddLog();
  AddLogicalAnd();
  AddLogicalNot();
  AddLogicalOr();
  AddLogistic();
  AddMaxPool2D();
  AddMaximum();
  AddMean();
  AddMinimum();
  AddMul();
  AddNeg();
  AddNotEqual();
  AddPack();
  AddPad();
  AddPadV2();
  AddPrelu();
  AddQuantize();
  AddReduceMax();
  AddRelu();
  AddRelu6();
  AddReshape();
  AddResizeNearestNeighbor();
  AddRound();
  AddRsqrt();
  AddShape();
  AddSin();
  AddSoftmax();
  AddSpaceToBatchNd();
  AddSplit();
  AddSplitV();
  AddSqrt();
  AddSquare();
  AddSqueeze();
  AddStridedSlice();
  AddSub();
  AddSvdf();
  AddTanh();
  AddTransposeConv();
  AddUnpack();
}
}  // namespace tflite
 
 | 
					
	
SECTION code_driver
SECTION code_driver_tty
PUBLIC asm_tty_param_b_action
EXTERN asm_tty_state_get_1
EXTERN asm_tty_state_param_store
asm_tty_param_b_action:
   ;  c = action code
   ; stack = & tty.action
   ; command code has one parameter and action is invoked
   ld de,asm_tty_state_get_1
   jp asm_tty_state_param_store
 
 | 
					
	; A212905: Number of (w,x,y,z) with all terms in {0,...,n} and |w-x|+|x-y+|y-z|=2n.
; 1,6,16,26,42,58,82,106,140,174,220,266,326,386,462,538,632,726,840,954,1090,1226,1386,1546,1732,1918,2132,2346,2590,2834,3110,3386,3696,4006,4352,4698,5082,5466,5890,6314,6780,7246,7756,8266,8822
mov $5,$0
mov $7,$0
add $7,1
lpb $7,1
  clr $0,5
  mov $0,$5
  sub $7,1
  sub $0,$7
  lpb $0,1
    div $0,2
    add $1,$0
    mov $3,$0
    sub $3,$0
    mov $0,$4
    add $3,$1
    mov $1,1
    add $3,1
  lpe
  add $1,$3
  pow $1,2
  add $1,1
  trn $3,2
  sub $1,$3
  add $6,$1
lpe
mov $1,$6
 
 | 
					
	 ;
 ; 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.
 ;
;
; Example YASM command lines:
; Windows:  yasm -Xvc -f x64 -rnasm -pnasm -o aes_cbc_dec_by8_sse.obj -g cv8 aes_cbc_dec_by8_sse.asm
; Linux:    yasm -f x64 -f elf64 -X gnu -g dwarf2 -D __linux__ -o aes_cbc_dec_by8_sse.o aes_cbc_dec_by8_sse.asm
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; routines to do AES128/192/256 CBC decrypt "by8"
%define CONCAT(a,b) a %+ b
struc sAesData
.in_block:	resq	1	; UINT8 *in_block
.out_block:	resq	1	; UINT8 *out_block
.expanded_key:	resq	1	; UINT8 *expanded_key
.iv:		resq	1	; UINT8 *iv
.num_blocks:	resd	1	; UINT32 num_blocks
endstruc
; void iDec128_CBC_by8(sAesData *data);
; void iDec192_CBC_by8(sAesData *data);
; void iDec256_CBC_by8(sAesData *data);
; Assume data is unaligned
%define MOVDQ movdqu
%define xdata0	xmm0
%define xdata1	xmm1
%define xdata2	xmm2
%define xdata3	xmm3
%define xdata4	xmm4
%define xdata5	xmm5
%define xdata6	xmm6
%define xdata7	xmm7
%define xIV  	xmm8
%define xkey0 	xmm9
%define xkey2 	xmm10
%define xkey4 	xmm11
%define xkey6 	xmm12
%define xkey8 	xmm13
%define xkeyA	xmm14
%define xkeyB	xmm15
%define xkeytmp1 xdata0
%define xkeytmp3 xdata1
%define xkeytmp5 xdata2
%define xkeytmp7 xdata3
%define xkeytmp9 xdata4
%define xkeytmp11 xdata5
%define xkeytmp12 xdata6
%define xkeytmp13 xdata7
%define xkeytmp14 xkeyA
%ifdef WINABI
%define ARG1	rcx
%else
%define ARG1	rdi
%endif
%define p_in	rdx
%define p_out	r8
%define p_keys	r9
%define p_IV	ARG1
%define num_blks eax
%define tmp	r10
struc STACK_FRAME
.keys		resdq	15
%ifdef WINABI
.xmm_save:	resdq	10
%endif
		resq 1		; for alignment
endstruc
; rounds: aes128 -> 10, aes192 -> 12, aes256 ->14
%define AES128 10
%define AES192 12
%define AES256 14
%macro do_aes 2
%define %%rounds %1
%define %%by   %2
  %assign i 0
  %rep %%by
	MOVDQ	CONCAT(xdata,i), [p_in  + i*16]
  %assign i (i+1)
  %endrep
	movdqa	xkeyA, [p_keys + (%%rounds-1)*16]
  %assign i 0
  %rep %%by
	pxor	CONCAT(xdata,i), xkey0		; round 0
  %assign i (i+1)
  %endrep
	add	p_in, 16*%%by
	
%assign r 3
%rep 4
  %assign rm1 (r-1)
  %assign i 0
  %rep %%by
	aesdec	CONCAT(xdata,i), xkeyA		; round r-2
  %assign i (i+1)
  %endrep
	movdqa	xkeyA, [p_keys + (%%rounds - r)*16]
  %assign i 0
  %rep %%by
	aesdec	CONCAT(xdata,i), CONCAT(xkey, rm1)	; round r-1
  %assign i (i+1)
  %endrep
%assign r (r+2)
%endrep
	;; completed up to round 8, key 9 loaded into xkeyA, r == 11
;; Do the following twice for aes256, once for aes192, and not for aes128
%rep (%%rounds - 10)/2
	movdqa	xkeyB, [p_keys + (%%rounds - (r-1))*16]
  %assign i 0
  %rep %%by
	aesdec	CONCAT(xdata,i), xkeyA		; round r-2
  %assign i (i+1)
  %endrep
	movdqa	xkeyA, [p_keys + (%%rounds - (r))*16]
  %assign i 0
  %rep %%by
	aesdec	CONCAT(xdata,i), xkeyB		; round r-1
  %assign i (i+1)
  %endrep
%assign r (r+2)
%endrep
%if (%%rounds != 10)
	movdqa	xkeyB, [p_keys + (%%rounds - (r-1))*16]
%endif
  %assign i 0
  %rep %%by
	aesdec	CONCAT(xdata,i), xkeyA		; round 9
  %assign i (i+1)
  %endrep
  %assign i 0
  %rep %%by
	aesdeclast	CONCAT(xdata,i), xkeyB		; round 10
  %assign i (i+1)
  %endrep
	pxor	xdata0, xIV
%assign i 1
%rep (%%by - 1)
	MOVDQ	xIV, [p_in  + (i-1)*16 - 16*%%by]
	pxor	CONCAT(xdata,i), xIV
%assign i (i+1)
%endrep
	MOVDQ	xIV, [p_in  + (i-1)*16 - 16*%%by]
%assign i 0
%rep %%by
	MOVDQ	[p_out  + i*16], CONCAT(xdata,i)
%assign i (i+1)
%endrep
%endmacro
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
%macro AES_CBC_DEC_BY8 1
%define %%rounds %1
	sub	rsp, STACK_FRAME_size
%ifdef WINABI
	movdqa	[rsp + STACK_FRAME.xmm_save + 0*16], xmm6
	movdqa	[rsp + STACK_FRAME.xmm_save + 1*16], xmm7
	movdqa	[rsp + STACK_FRAME.xmm_save + 2*16], xmm8
	movdqa	[rsp + STACK_FRAME.xmm_save + 3*16], xmm9
	movdqa	[rsp + STACK_FRAME.xmm_save + 4*16], xmm10
	movdqa	[rsp + STACK_FRAME.xmm_save + 5*16], xmm11
	movdqa	[rsp + STACK_FRAME.xmm_save + 6*16], xmm12
	movdqa	[rsp + STACK_FRAME.xmm_save + 7*16], xmm13
	movdqa	[rsp + STACK_FRAME.xmm_save + 8*16], xmm14
	movdqa	[rsp + STACK_FRAME.xmm_save + 9*16], xmm15
%endif
	mov	p_in,     [ARG1 + sAesData.in_block]
	mov	p_out,    [ARG1 + sAesData.out_block]
	mov	p_keys,   [ARG1 + sAesData.expanded_key]
	mov	num_blks, [ARG1 + sAesData.num_blocks]
	mov	p_IV,     [ARG1 + sAesData.iv] ; clobbers ARG1
	movdqu	xIV, [p_IV]
	;; check align keys
	test	p_keys, 0xf
	jz	.skip_align
	;; do align keys
	movdqu	xkey0,    [p_keys + 16*(%%rounds-0)]
	movdqu	xkeytmp1, [p_keys + 16*(%%rounds-1)]
	movdqu	xkey2,    [p_keys + 16*(%%rounds-2)]
	movdqu	xkeytmp3, [p_keys + 16*(%%rounds-3)]
	movdqu	xkey4,    [p_keys + 16*(%%rounds-4)]
	movdqu	xkeytmp5, [p_keys + 16*(%%rounds-5)]
	movdqu	xkey6,    [p_keys + 16*(%%rounds-6)]
	movdqu	xkeytmp7, [p_keys + 16*(%%rounds-7)]
	movdqu	xkey8,    [p_keys + 16*(%%rounds-8)]
	movdqu	xkeytmp9, [p_keys + 16*(%%rounds-9)]
	movdqu	xkeyB,    [p_keys + 16*(%%rounds-10)]
%if (%%rounds > 10)
	movdqu	xkeytmp11,[p_keys + 16*(%%rounds-11)]
	movdqu	xkeytmp12,[p_keys + 16*(%%rounds-12)]
%endif
%if (%%rounds > 12)
	movdqu	xkeytmp13,[p_keys + 16*(%%rounds-13)]
	movdqu	xkeytmp14,[p_keys + 16*(%%rounds-14)]
%endif
	movdqa	[rsp + STACK_FRAME.keys + 16*(%%rounds-1)], xkeytmp1
	movdqa	[rsp + STACK_FRAME.keys + 16*(%%rounds-3)], xkeytmp3
	movdqa	[rsp + STACK_FRAME.keys + 16*(%%rounds-5)], xkeytmp5
	movdqa	[rsp + STACK_FRAME.keys + 16*(%%rounds-7)], xkeytmp7
	movdqa	[rsp + STACK_FRAME.keys + 16*(%%rounds-9)], xkeytmp9
%if (%%rounds > 10)
	movdqa	[rsp + STACK_FRAME.keys + 16*(%%rounds-10)], xkeyB
	movdqa	[rsp + STACK_FRAME.keys + 16*(%%rounds-11)], xkeytmp11
	movdqa	[rsp + STACK_FRAME.keys + 16*(%%rounds-12)], xkeytmp12
%endif
%if (%%rounds > 12)
	movdqa	[rsp + STACK_FRAME.keys + 16*(%%rounds-13)], xkeytmp13
	movdqa	[rsp + STACK_FRAME.keys + 16*(%%rounds-14)], xkeytmp14
%endif
	lea	p_keys, [rsp + STACK_FRAME.keys]
	jmp .common
.skip_align
	movdqa	xkey0,    [p_keys + 16*(%%rounds-0)]
	movdqa	xkey2,    [p_keys + 16*(%%rounds-2)]
	movdqa	xkey4,    [p_keys + 16*(%%rounds-4)]
	movdqa	xkey6,    [p_keys + 16*(%%rounds-6)]
	movdqa	xkey8,    [p_keys + 16*(%%rounds-8)]
%if (%%rounds == 10)
	movdqa	xkeyB,    [p_keys + 16*(%%rounds-10)]
%endif
.common
	sub	num_blks, 8
	jl	.not8
align 16
.loop
	do_aes	%%rounds, 8
	add	p_out, 8*16
	sub	num_blks, 8
	jge	.loop
	; fewer than 8 remain:
	; num_blks = -1  =>  7 remaining
	;            -8  =>  0 remaining
.not8
	test	num_blks, 4
	jz	.not4
	do_aes	%%rounds, 4
	add	p_out, 4*16
.not4
	test	num_blks, 2
	jz	.not2
	do_aes	%%rounds, 2
	add	p_out, 2*16
.not2
	test	num_blks, 1
	jz	.return
	do_aes	%%rounds, 1
.return
	movdqu	[p_IV], xIV
%ifdef WINABI
	movdqa	xmm6, [rsp + STACK_FRAME.xmm_save + 0*16]
	movdqa	xmm7, [rsp + STACK_FRAME.xmm_save + 1*16]
	movdqa	xmm8, [rsp + STACK_FRAME.xmm_save + 2*16]
	movdqa	xmm9, [rsp + STACK_FRAME.xmm_save + 3*16]
	movdqa	xmm10, [rsp + STACK_FRAME.xmm_save + 4*16]
	movdqa	xmm11, [rsp + STACK_FRAME.xmm_save + 5*16]
	movdqa	xmm12, [rsp + STACK_FRAME.xmm_save + 6*16]
	movdqa	xmm13, [rsp + STACK_FRAME.xmm_save + 7*16]
	movdqa	xmm14, [rsp + STACK_FRAME.xmm_save + 8*16]
	movdqa	xmm15, [rsp + STACK_FRAME.xmm_save + 9*16]
%endif
	add	rsp, STACK_FRAME_size
	ret
%endm
global iDec128_CBC_by8
iDec128_CBC_by8:
	AES_CBC_DEC_BY8 AES128
global iDec192_CBC_by8
iDec192_CBC_by8:
	AES_CBC_DEC_BY8 AES192
global iDec256_CBC_by8
iDec256_CBC_by8:
	AES_CBC_DEC_BY8 AES256
 
 | 
					
	// Copyright 2019 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include <fidl/fuchsia.io/cpp/wire.h>
#include <lib/zxio/cpp/inception.h>
#include <lib/zxio/null.h>
#include <lib/zxio/ops.h>
#include <sys/stat.h>
#include <zircon/syscalls.h>
#include <fbl/algorithm.h>
#include "private.h"
typedef struct zxio_vmo {
  // The |zxio_t| control structure for this object.
  zxio_t io;
  // The underlying VMO that stores the data.
  zx::vmo vmo;
  // The stream through which we will read and write the VMO.
  zx::stream stream;
} zxio_vmo_t;
static_assert(sizeof(zxio_vmo_t) <= sizeof(zxio_storage_t),
              "zxio_vmo_t must fit inside zxio_storage_t.");
static zx_status_t zxio_vmo_close(zxio_t* io) {
  auto file = reinterpret_cast<zxio_vmo_t*>(io);
  file->~zxio_vmo_t();
  return ZX_OK;
}
static zx_status_t zxio_vmo_release(zxio_t* io, zx_handle_t* out_handle) {
  auto file = reinterpret_cast<zxio_vmo_t*>(io);
  *out_handle = file->vmo.release();
  return ZX_OK;
}
static zx_status_t zxio_vmo_reopen(zxio_t* io, zxio_reopen_flags_t flags, zx_handle_t* out_handle) {
  if (flags != zxio_reopen_flags_t{0}) {
    return ZX_ERR_INVALID_ARGS;
  }
  auto file = reinterpret_cast<zxio_vmo_t*>(io);
  zx::vmo vmo;
  zx_status_t status = file->vmo.duplicate(ZX_RIGHT_SAME_RIGHTS, &vmo);
  *out_handle = vmo.release();
  return status;
}
static zx_status_t zxio_vmo_attr_get(zxio_t* io, zxio_node_attributes_t* out_attr) {
  auto file = reinterpret_cast<zxio_vmo_t*>(io);
  uint64_t content_size = 0u;
  zx_status_t status =
      file->vmo.get_property(ZX_PROP_VMO_CONTENT_SIZE, &content_size, sizeof(content_size));
  if (status != ZX_OK) {
    return status;
  }
  *out_attr = {};
  ZXIO_NODE_ATTR_SET(*out_attr, protocols, ZXIO_NODE_PROTOCOL_FILE | ZXIO_NODE_PROTOCOL_MEMORY);
  ZXIO_NODE_ATTR_SET(*out_attr, abilities,
                     ZXIO_OPERATION_READ_BYTES | ZXIO_OPERATION_GET_ATTRIBUTES);
  ZXIO_NODE_ATTR_SET(*out_attr, content_size, content_size);
  return ZX_OK;
}
static zx_status_t zxio_vmo_readv(zxio_t* io, const zx_iovec_t* vector, size_t vector_count,
                                  zxio_flags_t flags, size_t* out_actual) {
  if (flags) {
    return ZX_ERR_NOT_SUPPORTED;
  }
  auto file = reinterpret_cast<zxio_vmo_t*>(io);
  return file->stream.readv(0, vector, vector_count, out_actual);
}
static zx_status_t zxio_vmo_readv_at(zxio_t* io, zx_off_t offset, const zx_iovec_t* vector,
                                     size_t vector_count, zxio_flags_t flags, size_t* out_actual) {
  if (flags) {
    return ZX_ERR_NOT_SUPPORTED;
  }
  auto file = reinterpret_cast<zxio_vmo_t*>(io);
  return file->stream.readv_at(0, offset, vector, vector_count, out_actual);
}
static zx_status_t zxio_vmo_writev(zxio_t* io, const zx_iovec_t* vector, size_t vector_count,
                                   zxio_flags_t flags, size_t* out_actual) {
  if (flags) {
    return ZX_ERR_NOT_SUPPORTED;
  }
  auto file = reinterpret_cast<zxio_vmo_t*>(io);
  return file->stream.writev(0, vector, vector_count, out_actual);
}
static zx_status_t zxio_vmo_writev_at(zxio_t* io, zx_off_t offset, const zx_iovec_t* vector,
                                      size_t vector_count, zxio_flags_t flags, size_t* out_actual) {
  if (flags) {
    return ZX_ERR_NOT_SUPPORTED;
  }
  auto file = reinterpret_cast<zxio_vmo_t*>(io);
  return file->stream.writev_at(0, offset, vector, vector_count, out_actual);
}
static_assert(ZXIO_SEEK_ORIGIN_START == ZX_STREAM_SEEK_ORIGIN_START, "ZXIO should match ZX");
static_assert(ZXIO_SEEK_ORIGIN_CURRENT == ZX_STREAM_SEEK_ORIGIN_CURRENT, "ZXIO should match ZX");
static_assert(ZXIO_SEEK_ORIGIN_END == ZX_STREAM_SEEK_ORIGIN_END, "ZXIO should match ZX");
static zx_status_t zxio_vmo_seek(zxio_t* io, zxio_seek_origin_t start, int64_t offset,
                                 size_t* out_offset) {
  auto file = reinterpret_cast<zxio_vmo_t*>(io);
  return file->stream.seek(static_cast<zx_stream_seek_origin_t>(start), offset, out_offset);
}
zx_status_t zxio_vmo_truncate(zxio_t* io, uint64_t length) {
  auto file = reinterpret_cast<zxio_vmo_t*>(io);
  return file->vmo.set_size(length);
}
static zx_status_t zxio_vmo_vmo_get(zxio_t* io, uint32_t flags, zx_handle_t* out_vmo,
                                    size_t* out_size) {
  auto file = reinterpret_cast<zxio_vmo_t*>(io);
  size_t content_size = 0u;
  zx_status_t status =
      file->vmo.get_property(ZX_PROP_VMO_CONTENT_SIZE, &content_size, sizeof(content_size));
  if (status != ZX_OK) {
    return status;
  }
  return zxio_vmo_get_common(file->vmo, content_size, flags, out_vmo, out_size);
}
static constexpr zxio_ops_t zxio_vmo_ops = []() {
  zxio_ops_t ops = zxio_default_ops;
  ops.close = zxio_vmo_close;
  ops.release = zxio_vmo_release;
  ops.reopen = zxio_vmo_reopen;
  ops.attr_get = zxio_vmo_attr_get;
  ops.readv = zxio_vmo_readv;
  ops.readv_at = zxio_vmo_readv_at;
  ops.writev = zxio_vmo_writev;
  ops.writev_at = zxio_vmo_writev_at;
  ops.seek = zxio_vmo_seek;
  ops.truncate = zxio_vmo_truncate;
  ops.vmo_get = zxio_vmo_vmo_get;
  return ops;
}();
zx_status_t zxio_vmo_init(zxio_storage_t* storage, zx::vmo vmo, zx::stream stream) {
  auto file = new (storage) zxio_vmo_t{
      .io = storage->io,
      .vmo = std::move(vmo),
      .stream = std::move(stream),
  };
  zxio_init(&file->io, &zxio_vmo_ops);
  return ZX_OK;
}
 
 | 
					
	; A026053: (d(n)-r(n))/5, where d = A008778 and r is the periodic sequence with fundamental period (0,3,1,0,1).
; 1,2,5,9,14,21,29,40,53,68,86,106,130,157,187,221,258,300,346,396,451,510,575,645,720,801,887,980,1079,1184,1296,1414,1540,1673,1813,1961,2116,2280,2452,2632,2821,3018,3225,3441,3666,3901,4145,4400,4665,4940,5226,5522,5830,6149,6479,6821
mov $12,$0
mov $14,$0
add $14,1
lpb $14
  clr $0,12
  mov $0,$12
  sub $14,1
  sub $0,$14
  mov $9,$0
  mov $11,$0
  add $11,1
  lpb $11
    mov $0,$9
    sub $11,1
    sub $0,$11
    mov $4,6
    add $4,$0
    mov $6,2
    add $6,$4
    mod $4,5
    mod $4,2
    div $6,5
    add $4,$6
    mov $1,$4
    sub $1,1
    add $10,$1
  lpe
  add $13,$10
lpe
mov $1,$13
 
 | 
					
	; A323294: Number of 3-uniform hypergraphs spanning n labeled vertices where every two edges have two vertices in common.
; 1,0,0,1,11,10,15,21,28,36,45,55,66,78,91,105,120,136,153,171,190,210,231,253,276,300,325,351,378,406,435,465,496,528,561,595,630,666,703,741,780,820,861,903,946,990,1035,1081,1128,1176,1225,1275,1326,1378,1431
mov $3,$0
mov $4,2
lpb $4,1
  mov $0,$3
  sub $4,1
  add $0,$4
  sub $0,1
  mov $5,$0
  sub $0,1
  trn $0,2
  trn $5,2
  add $5,1
  lpb $0,1
    mov $0,0
    add $5,2
    bin $5,3
    mov $7,0
    mov $8,$5
    mov $5,1
    add $8,2
    add $7,$8
    add $5,$7
  lpe
  mov $2,$4
  mov $6,$5
  lpb $2,1
    mov $1,$6
    sub $2,1
  lpe
lpe
lpb $3,1
  sub $1,$6
  mov $3,0
lpe
 
 | 
					
	    include "VasmBuildCompat.asm"
    include "V1_Header.asm"
    ;include "MSX1_V1_VdpMemory.asm"
;
; Hello World .ROM for cartridge environment
;
; Constant definitions
WRTVDP  equ &0047
LDIRVM  equ &005c
CHGMOD  equ &005f
INIT32  equ &006F
;CHPUT   equ &00A2
LINLEN  equ &F3B0
; Compilation address
    org &4000
; ROM header
    db "AB"     ; magic number
    dw Execute  ; program execution address
    dw 0, 0, 0, 0, 0, 0
; Program code entry point
Execute:
    ld a, 2  ; Change screen mode (Screen 2)
    call CHGMOD
    ld bc, 0e201h  ; write 1110 0010 = 0xe2 to VDP(1) 
    call WRTVDP
    ; Color info
    ld hl, &2000
    call VDP_SetWriteAddress
    
    call Finished      ; end
; Halt program execution. Change to "ret" to return to MSX-BASIC.
Finished:
    ; ret
    di
    halt
Palette:
    ds 768*8, &3F
; Padding to make the file size a multiple of 16K
; (Alternatively, include macros.asm and use ALIGN 4000H)
    ds -$ & &3FFF
    include "V1_Footer.asm"
 
 | 
					
	; A313774: Coordination sequence Gal.6.622.5 where G.u.t.v denotes the coordination sequence for a vertex of type v in tiling number t in the Galebach list of u-uniform tilings.
; Submitted by Christian Krause
; 1,5,10,15,21,25,31,37,41,47,52,57,62,67,72,77,83,87,93,99,103,109,114,119,124,129,134,139,145,149,155,161,165,171,176,181,186,191,196,201,207,211,217,223,227,233,238,243,248,253
mov $1,$0
seq $0,312933 ; Coordination sequence Gal.6.131.3 where G.u.t.v denotes the coordination sequence for a vertex of type v in tiling number t in the Galebach list of u-uniform tilings.
mul $1,2
add $1,1
div $1,3
add $0,$1
 
 | 
					
	// Copyright (c) 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "gquiche/quic/core/qpack/qpack_required_insert_count.h"
#include "absl/base/macros.h"
#include "gquiche/quic/platform/api/quic_test.h"
namespace quic {
namespace test {
namespace {
TEST(QpackRequiredInsertCountTest, QpackEncodeRequiredInsertCount) {
  EXPECT_EQ(0u, QpackEncodeRequiredInsertCount(0, 0));
  EXPECT_EQ(0u, QpackEncodeRequiredInsertCount(0, 8));
  EXPECT_EQ(0u, QpackEncodeRequiredInsertCount(0, 1024));
  EXPECT_EQ(2u, QpackEncodeRequiredInsertCount(1, 8));
  EXPECT_EQ(5u, QpackEncodeRequiredInsertCount(20, 8));
  EXPECT_EQ(7u, QpackEncodeRequiredInsertCount(106, 10));
}
// For testing valid decodings, the Encoded Required Insert Count is calculated
// from Required Insert Count, so that there is an expected value to compare
// the decoded value against, and so that intricate inequalities can be
// documented.
struct {
  uint64_t required_insert_count;
  uint64_t max_entries;
  uint64_t total_number_of_inserts;
} kTestData[] = {
    // Maximum dynamic table capacity is zero.
    {0, 0, 0},
    // No dynamic entries in header.
    {0, 100, 0},
    {0, 100, 500},
    // Required Insert Count has not wrapped around yet, no entries evicted.
    {15, 100, 25},
    {20, 100, 10},
    // Required Insert Count has not wrapped around yet, some entries evicted.
    {90, 100, 110},
    // Required Insert Count has wrapped around.
    {234, 100, 180},
    // Required Insert Count has wrapped around many times.
    {5678, 100, 5701},
    // Lowest and highest possible Required Insert Count values
    // for given MaxEntries and total number of insertions.
    {401, 100, 500},
    {600, 100, 500}};
TEST(QpackRequiredInsertCountTest, QpackDecodeRequiredInsertCount) {
  for (size_t i = 0; i < ABSL_ARRAYSIZE(kTestData); ++i) {
    const uint64_t required_insert_count = kTestData[i].required_insert_count;
    const uint64_t max_entries = kTestData[i].max_entries;
    const uint64_t total_number_of_inserts =
        kTestData[i].total_number_of_inserts;
    if (required_insert_count != 0) {
      // Dynamic entries cannot be referenced if dynamic table capacity is zero.
      ASSERT_LT(0u, max_entries) << i;
      // Entry |total_number_of_inserts - 1 - max_entries| and earlier entries
      // are evicted.  Entry |required_insert_count - 1| is referenced.  No
      // evicted entry can be referenced.
      ASSERT_LT(total_number_of_inserts, required_insert_count + max_entries)
          << i;
      // Entry |required_insert_count - 1 - max_entries| and earlier entries are
      // evicted, entry |total_number_of_inserts - 1| is the last acknowledged
      // entry.  Every evicted entry must be acknowledged.
      ASSERT_LE(required_insert_count, total_number_of_inserts + max_entries)
          << i;
    }
    uint64_t encoded_required_insert_count =
        QpackEncodeRequiredInsertCount(required_insert_count, max_entries);
    // Initialize to a value different from the expected output to confirm that
    // QpackDecodeRequiredInsertCount() modifies the value of
    // |decoded_required_insert_count|.
    uint64_t decoded_required_insert_count = required_insert_count + 1;
    EXPECT_TRUE(QpackDecodeRequiredInsertCount(
        encoded_required_insert_count, max_entries, total_number_of_inserts,
        &decoded_required_insert_count))
        << i;
    EXPECT_EQ(decoded_required_insert_count, required_insert_count) << i;
  }
}
// Failures are tested with hardcoded values for encoded required insert count,
// to provide test coverage for values that would never be produced by a well
// behaved encoding function.
struct {
  uint64_t encoded_required_insert_count;
  uint64_t max_entries;
  uint64_t total_number_of_inserts;
} kInvalidTestData[] = {
    // Maximum dynamic table capacity is zero, yet header block
    // claims to have a reference to a dynamic table entry.
    {1, 0, 0},
    {9, 0, 0},
    // Examples from
    // https://github.com/quicwg/base-drafts/issues/2112#issue-389626872.
    {1, 10, 2},
    {18, 10, 2},
    // Encoded Required Insert Count value too small or too large
    // for given MaxEntries and total number of insertions.
    {400, 100, 500},
    {601, 100, 500}};
TEST(QpackRequiredInsertCountTest, DecodeRequiredInsertCountError) {
  for (size_t i = 0; i < ABSL_ARRAYSIZE(kInvalidTestData); ++i) {
    uint64_t decoded_required_insert_count = 0;
    EXPECT_FALSE(QpackDecodeRequiredInsertCount(
        kInvalidTestData[i].encoded_required_insert_count,
        kInvalidTestData[i].max_entries,
        kInvalidTestData[i].total_number_of_inserts,
        &decoded_required_insert_count))
        << i;
  }
}
}  // namespace
}  // namespace test
}  // namespace quic
 
 | 
					
	SFX_Muted_Snare1_2_Ch1:
	unknownnoise0x20 0, 161, 24
	unknownnoise0x20 0, 49, 51
	endchannel
 
 | 
					
	;
;	Old School Computer Architecture - interfacing FLOS
;	Stefano Bodrato, 2011
;
;	Get returns total sectors on current volume (long)
;
;	$Id: get_total_sectors.asm,v 1.6 2016/06/22 22:13:09 dom Exp $
;
    INCLUDE "flos.def"
        SECTION code_clib
	PUBLIC  get_total_sectors
	PUBLIC  _get_total_sectors
	
get_total_sectors:
_get_total_sectors:
	call	kjt_get_total_sectors
	ld	h,0
	ld	l,c
	ret
 
 | 
					
	; $Id: bs3-cpu-decoding-1-asm.asm 69111 2017-10-17 14:26:02Z vboxsync $
;; @file
; BS3Kit - bs3-cpu-decoding-1, assembly helpers and template instantiation.
;
;
; Copyright (C) 2007-2017 Oracle Corporation
;
; This file is part of VirtualBox Open Source Edition (OSE), as
; available from http://www.virtualbox.org. This file is free software;
; you can redistribute it and/or modify it under the terms of the GNU
; General Public License (GPL) as published by the Free Software
; Foundation, in version 2 as it comes in the "COPYING" file of the
; VirtualBox OSE distribution. VirtualBox OSE is distributed in the
; hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
;
; The contents of this file may alternatively be used under the terms
; of the Common Development and Distribution License Version 1.0
; (CDDL) only, as it comes in the "COPYING.CDDL" file of the
; VirtualBox OSE distribution, in which case the provisions of the
; CDDL are applicable instead of those of the GPL.
;
; You may elect to license modified versions of this file under the
; terms and conditions of either the GPL or the CDDL or both.
;
;*********************************************************************************************************************************
;*  Header Files                                                                                                                 *
;*********************************************************************************************************************************
%include "bs3kit.mac"
;
; Instantiate code templates.
;
BS3_INSTANTIATE_TEMPLATE_ESSENTIALS      "bs3-cpu-decoding-1-template.mac"
BS3_INSTANTIATE_COMMON_TEMPLATE          "bs3-cpu-decoding-1-template.mac"
 
 | 
					
	;-Camera Position of Ship----------------------------------------------------------------------------------------------------------
StartOfShipRuntimeData      EQU $
UBnKxlo                     DB  0                       ; INWK+0
UBnKxhi                     DB  0                       ; there are hi medium low as some times these are 24 bit
UBnKxsgn                    DB  0                       ; INWK+2
UBnKylo                     DB  0                       ; INWK+3 \ ylo
UBnKyhi                     DB  0                       ; INWK+4 \ yHi
UBnKysgn                    DB  0                       ; INWK +5
UBnKzlo                     DB  0                       ; INWK +6
UBnKzhi                     DB  0                       ; INWK +7
UBnKzsgn                    DB  0                       ; INWK +8
;-Zero page for when we page data temporarily into page zero to read a second ship, e.g. missile tracking
ZeroPageUBnKxlo             EQU UBnKxlo    - StartOfShipRuntimeData
ZeroPageUBnKxhi             EQU UBnKxhi    - StartOfShipRuntimeData
ZeroPageUBnKxsgn            EQU UBnKxsgn   - StartOfShipRuntimeData
ZeroPageUBnKylo             EQU UBnKylo    - StartOfShipRuntimeData
ZeroPageUBnKyhi             EQU UBnKyhi    - StartOfShipRuntimeData
ZeroPageUBnKysgn            EQU UBnKysgn   - StartOfShipRuntimeData
ZeroPageUBnKzlo             EQU UBnKzlo    - StartOfShipRuntimeData
ZeroPageUBnKzhi             EQU UBnKzhi    - StartOfShipRuntimeData
ZeroPageUBnKzsgn            EQU UBnKzsgn   - StartOfShipRuntimeData
;-Rotation Matrix of Ship----------------------------------------------------------------------------------------------------------
; Rotation data is stored as lohi, but only 15 bits with 16th bit being  a sign bit. Note this is NOT 2'c compliment
; Note they seem to have to be after camera position not quite found why yet, can only assume it does an iy or ix indexed copy? Bu oddly does not affect space station.
UBnkrotmatSidevX            DW  0                       ; INWK +21
UBnkrotmatSidev             equ UBnkrotmatSidevX
UBnkrotmatSidevY            DW  0                       ; INWK +23
UBnkrotmatSidevZ            DW  0                       ; INWK +25
UBnkrotmatRoofvX            DW  0                       ; INWK +15
UBnkrotmatRoofv             equ UBnkrotmatRoofvX
UBnkrotmatRoofvY            DW  0                       ; INWK +17
UBnkrotmatRoofvZ            DW  0                       ; INWK +19
UBnkrotmatNosevX            DW  0                       ; INWK +9
UBnkrotmatNosev             EQU UBnkrotmatNosevX
UBnkrotmatNosevY            DW  0                       ; INWK +11
UBnkrotmatNosevZ            DW  0                       ; INWK +13
; -- Note these must be here for initialise blast as it does a 12 byte ldir
; . Note missile explosion will have to have logic to cause linger if a blast is to be enqued
UBnKMissileBlastRange:      DB  0                       ; copied in when setting up a missile
UBnKMissileBlastDamage:     DB  0                       ; copied in when setting up a missile
UBnKMissileDetonateRange:   DB  0                       ; copied in when setting up a missile, allows for proximity missiles
UBnKMissileDetonateDamage:  DB  0                       ; copied in when setting up a missile
; -- Metadata for ship to help with bank managment
UBnKStartOfRuntimeData:
UBnKSlotNumber              DB  0
UbnKShipUnivBankNbr         DB  0                       ; Present ship universe bank number
UBnkShipModelBank           DB  0                       ; Bank nbr ship was from
UBnKShipModelNbr            DB  0                       ; Ship Id with in the bank
UBnKShipModeID              DB  0                       ; Absolute ship id
; -- Ship AI data
UBnKMissleHitToProcess      DB  0                       ; This is used for enquing missle blasts as we can only do one missile at a time, could make it multi but neeed to smooth CPU usage
UBnKMissileTarget           DB  0                       ; This is the ship slot number for the target from 0 to n if the missile is not hostile to us
UBnKspeed                   DB  0                       ; INWK +27
UBnKAccel                   DB  0                       ; INWK +28
UBnKRotXCounter             DB  0                       ; INWK +29
UBnKRotZCounter             DB  0                       ; INWK +30
UBnKRAT                     DB  0                       ; temporary for rotation magnitude or roll counter, for debugging state
UBnKRAT2                    DB  0                       ; temporary for rotation threshold
UBnKCNT                     DB  0                       ; temp for calculating roll and pitch
UBnKCNT2                    DB  0                       ; roll threshold, max angle boynd ship will slow down
univRAT                     DB  0               ; 99
univRAT2                    DB  0               ; 9A
univRAT2Val                 DB  0               ; 9A
UBnKexplDsp                 DB  0                       ; INWK +31 clear exploding/display state|missiles
UBnkDrawAllFaces            DB  0
UBnkaiatkecm                DB  0                       ; INWK +32 ai_attack_univ_ecm i.e. AI type
UBnKSpawnObject             DB  0
UBnkCam0yLo                 DB  0                       ; INWK +33 ????
UBnkCam0yHi                 DB  0                       ; INWK +34?????
UBnKEnergy                  DB  0                       ; INWK +35
UBnKCloudCounter            DB  0                       ; cloud pixels
UBnKCloudRadius             DB  0                       ; cloud pixels
UBnKRuntimeSize             EQU $-UBnKStartOfRuntimeData
; Flags work as follows:
; UBnKSpawnObject - signals on death to spawn cargo items
; 0 -                   Spawn Cargo 1
; 1 -                   Spawn Cargo 2
; 2 -                   Spawn Cargo 3
; 3 -                   Spawn Cargo 4
; 4 -                   Spawn Alloy 1
; 5 -                   Spawn Alloy 2
; 6 -                   Spawn Alloy 3
; 7 -                   Spawn Alloy 4
; UBnkaiatkecm 
; Bit	                Description
; 7 -                   AI Enabled Flag
; 6 -                   Ship Visible = ShipOnScreen/NotCloaked (cleared or set by check visible or cloaking override)
; 5 -                   Ship is exploding if set, note if its a missile and one already equeued this will have to linger
;                       linger can be done by not erasing ship unit missile equeue handled
; 4 -                   Ship marked as exploded, cleared once aknowledged then bit 5 takes over and UBnKCloudCounter
; 3 -                   Display state - Plot as a Dot
; 2 -                   Nbr of Missiles bit 2
; 1 -                   Nbr of Missiles bit 1
; 0 -                   Nbr of Missiles bit 0
; ShipNewBitsAddr (in blueprint)
;Bit	                Description
;#0	Trader flag         * 0 = not a trader  * 1 = trader
;                       80% of traders are peaceful and mind their own business plying their trade between the planet and space station, but 20% of them moonlight as bounty hunters (see bit #1)
;                       Ships that are traders: Escape pod, Shuttle, Transporter, Anaconda, Rock hermit, Worm
;#1 Bounty hunter flag  * 0 = not a bounty hunter* 1 = bounty hunter
;                       If we are a fugitive or a serious offender and we bump into a bounty hunter, they will become hostile and attack us (see bit #2)
;                       Ships that are bounty hunters: Viper, Fer-de-lance
;#2	Hostile flag        * 0 = not hostile  * 1 = hostile
;                       Hostile ships will attack us on sight; there are quite a few of them
;                       Ships that are hostile: Sidewinder, Mamba, Krait, Adder, Gecko, Cobra Mk I, Worm, Cobra Mk III, Asp Mk II, Python (pirate), Moray, Thargoid, Thargon, Constrictor
;#3	Pirate flag         * 0 = not a pirate * 1 = pirate
;                       Hostile pirates will attack us on sight, but once we get inside the space station safe zone, they will stop
;                       Ships that are pirates: Sidewinder, Mamba, Krait, Adder, Gecko, Cobra Mk I, Cobra Mk III, Asp Mk II, Python (pirate), Moray, Thargoid
;#4	Docking flag        * 0 = not docking * 1 = docking
;                       Traders with their docking flag set fly towards the space station to try to dock, otherwise they aim for the planet
;                       This flag is randomly set for traders when they are spawned
;                       Ships that can be docking: Escape pod, Shuttle, Transporter, Anaconda, Rock hermit, Worm
;#5	Innocent bystander  * 0 = normal * 1 = innocent bystander
;                       If we attack an innocent ship within the space station safe zone, then the station will get angry with us and start spawning cops
;                       Ships that are innocent bystanders: Shuttle, Transporter, Cobra Mk III, Python, Boa, Anaconda, Rock hermit, Cougar
;#6	Cop flag            * 0 = not a cop * 1 = cop
;                       If we destroy a cop, then we instantly become a fugitive (the Transporter isn't actually a cop, but it's clearly under police protection)
;                       Ships that are cops: Viper, Transporter
;#7	Scooped, docked, escape pod flag
;                       For spawned ships, this flag indicates that the ship been scooped or has docked (bit 7 is always clear on spawning)
;                       For blueprints, this flag indicates whether the ship type has an escape pod fitted, so it can launch it when in dire straits
;                       Ships that have escape pods: Cobra Mk III, Python, Boa, Anaconda, Rock hermit, Viper, Mamba, Krait, Adder, Cobra Mk I, Cobra Mk III (pirate), Asp Mk II, Python (pirate), Fer-de-lance
 
 | 
					
	; A166010: a(n) = prime(n)^2-4.
; 0,5,21,45,117,165,285,357,525,837,957,1365,1677,1845,2205,2805,3477,3717,4485,5037,5325,6237,6885,7917,9405,10197,10605,11445,11877,12765,16125,17157,18765,19317,22197,22797,24645,26565,27885,29925,32037,32757,36477,37245,38805,39597,44517,49725,51525,52437,54285,57117,58077,62997,66045,69165,72357,73437,76725,78957,80085,85845,94245,96717,97965,100485,109557,113565,120405,121797,124605,128877,134685,139125,143637,146685,151317,157605,160797,167277,175557,177237,185757,187485,192717,196245,201597,208845,212517,214365,218085,229437,237165,241077,248997,253005,259077,271437,273525,292677
seq $0,6005 ; The odd prime numbers together with 1.
pow $0,2
trn $0,4
 
 | 
					
	; A138041: a(1) = 1, a(2) = 10; for n>2, a(n+1) = 4*a(n) + 6*a(n-1). Also a(n) = upper left term in the 2 X 2 matrix [1,3; 3,3].
; 1,10,46,244,1252,6472,33400,172432,890128,4595104,23721184,122455360,632148544,3263326336,16846196608,86964744448,448936157440,2317533096448,11963749330432,61760195900416,318823279584256,1645854293739520,8496356852463616,43860553172291584,226420353803948032,1168844734249541632,6033901059821854720,31148672644784668672,160798096938069803008,830084423620987224064,4285126276112367714304,22121011646175394201600,114194804241375783092224,589505286842555497578496,3043189972818476688867328,15709791612329239740940288,81098306286227819096965120,418651974818886714833502208,2161197736992913773915799552,11156702796884975384664211456,57593997609497384182151643136,297316207219299389036591841280,1534828814534181861239277223936,7923212501452523779176659943424,40901822893015186284142303117312,211146566580775887811629172129792,1089997203681194668951370507223040,5626868214209434002675257061670912,29047456078924904024409251290021888,149951033600956220113688547530113024,774088870877374304601209697860583424
lpb $0
  mov $2,$0
  trn $0,2
  seq $2,152224 ; a(n)=4*a(n-1)+6*a(n-2), n>1 ; a(0)=1, a(1)=6 .
  add $1,$2
lpe
div $1,6
mul $1,9
add $1,1
mov $0,$1
 
 | 
					
	section .text
global GetValueASM
GetValueASM:
    mov eax, edi ; External params come from EDI
    add eax, 1
    ret 
 | 
					
	
; int fzx_puts(struct fzx_state *fs, char *s)
INCLUDE "clib_cfg.asm"
SECTION code_font_fzx
PUBLIC asm_fzx_puts
EXTERN asm_fzx_putc, __fzx_puts_newline
asm_fzx_puts:
   ; write zero terminated string to window
   ; interpret \n as newline
   ;
   ; enter : ix = struct fzx_state *
   ;         de = char *s
   ;
   ; exit  : hl = number of chars written
   ;
   ;         success
   ;
   ;            de = & terminating NUL in s
   ;            carry reset
   ;
   ;         fail if can't fit window vertically
   ;
   ;            de = & next char in s
   ;            carry set
   ;
   ; uses  : af, bc, de, hl, af'
   
   ld hl,0                     ; number of chars written
loop:
   ld a,(de)
   or a
   ret z
   
   push de
   push hl
   
   cp CHAR_LF
   jr nz, putchar
   call __fzx_puts_newline
   jr loop_rejoin
putchar:
   ld c,a
   call asm_fzx_putc
   jr c, off_screen
loop_rejoin:
   pop hl
   pop de
   
   inc hl
   inc de
   
   jr loop
off_screen:
   dec a
   jr nz, newline
   
   pop hl
   pop de
   
   ret
newline:
   call __fzx_puts_newline
   pop hl
   pop de
   jr loop
 
 | 
					
	// This is a generated file! Please edit source .ksy file and use kaitai-struct-compiler to rebuild
#include "gzip.h"
#include "kaitai/exceptions.h"
gzip_t::gzip_t(kaitai::kstream* p__io, kaitai::kstruct* p__parent, gzip_t* p__root) : kaitai::kstruct(p__io) {
    m__parent = p__parent;
    m__root = this;
    m_flags = nullptr;
    m_extras = nullptr;
    _read();
}
void gzip_t::_read() {
    m_magic = m__io->read_bytes(2);
    if (!(magic() == std::string("\x1F\x8B", 2))) {
        throw kaitai::validation_not_equal_error<std::string>(std::string("\x1F\x8B", 2), magic(), _io(), std::string("/seq/0"));
    }
    m_compression_method = static_cast<gzip_t::compression_methods_t>(m__io->read_u1());
    m_flags = std::unique_ptr<flags_t>(new flags_t(m__io, this, m__root));
    m_mod_time = m__io->read_u4le();
    n_extra_flags = true;
    switch (compression_method()) {
    case gzip_t::COMPRESSION_METHODS_DEFLATE: {
        n_extra_flags = false;
        m_extra_flags = std::unique_ptr<extra_flags_deflate_t>(new extra_flags_deflate_t(m__io, this, m__root));
        break;
    }
    }
    m_os = static_cast<gzip_t::oses_t>(m__io->read_u1());
    n_extras = true;
    if (flags()->has_extra()) {
        n_extras = false;
        m_extras = std::unique_ptr<extras_t>(new extras_t(m__io, this, m__root));
    }
    n_name = true;
    if (flags()->has_name()) {
        n_name = false;
        m_name = m__io->read_bytes_term(0, false, true, true);
    }
    n_comment = true;
    if (flags()->has_comment()) {
        n_comment = false;
        m_comment = m__io->read_bytes_term(0, false, true, true);
    }
    n_header_crc16 = true;
    if (flags()->has_header_crc()) {
        n_header_crc16 = false;
        m_header_crc16 = m__io->read_u2le();
    }
    m_body = m__io->read_bytes(((_io()->size() - _io()->pos()) - 8));
    m_body_crc32 = m__io->read_u4le();
    m_len_uncompressed = m__io->read_u4le();
}
gzip_t::~gzip_t() {
    _clean_up();
}
void gzip_t::_clean_up() {
    if (!n_extra_flags) {
    }
    if (!n_extras) {
    }
    if (!n_name) {
    }
    if (!n_comment) {
    }
    if (!n_header_crc16) {
    }
}
gzip_t::flags_t::flags_t(kaitai::kstream* p__io, gzip_t* p__parent, gzip_t* p__root) : kaitai::kstruct(p__io) {
    m__parent = p__parent;
    m__root = p__root;
    _read();
}
void gzip_t::flags_t::_read() {
    m_reserved1 = m__io->read_bits_int_be(3);
    m_has_comment = m__io->read_bits_int_be(1);
    m_has_name = m__io->read_bits_int_be(1);
    m_has_extra = m__io->read_bits_int_be(1);
    m_has_header_crc = m__io->read_bits_int_be(1);
    m_is_text = m__io->read_bits_int_be(1);
}
gzip_t::flags_t::~flags_t() {
    _clean_up();
}
void gzip_t::flags_t::_clean_up() {
}
gzip_t::extra_flags_deflate_t::extra_flags_deflate_t(kaitai::kstream* p__io, gzip_t* p__parent, gzip_t* p__root) : kaitai::kstruct(p__io) {
    m__parent = p__parent;
    m__root = p__root;
    _read();
}
void gzip_t::extra_flags_deflate_t::_read() {
    m_compression_strength = static_cast<gzip_t::extra_flags_deflate_t::compression_strengths_t>(m__io->read_u1());
}
gzip_t::extra_flags_deflate_t::~extra_flags_deflate_t() {
    _clean_up();
}
void gzip_t::extra_flags_deflate_t::_clean_up() {
}
gzip_t::subfields_t::subfields_t(kaitai::kstream* p__io, gzip_t::extras_t* p__parent, gzip_t* p__root) : kaitai::kstruct(p__io) {
    m__parent = p__parent;
    m__root = p__root;
    m_entries = nullptr;
    _read();
}
void gzip_t::subfields_t::_read() {
    m_entries = std::unique_ptr<std::vector<std::unique_ptr<subfield_t>>>(new std::vector<std::unique_ptr<subfield_t>>());
    {
        int i = 0;
        while (!m__io->is_eof()) {
            m_entries->push_back(std::move(std::unique_ptr<subfield_t>(new subfield_t(m__io, this, m__root))));
            i++;
        }
    }
}
gzip_t::subfields_t::~subfields_t() {
    _clean_up();
}
void gzip_t::subfields_t::_clean_up() {
}
gzip_t::subfield_t::subfield_t(kaitai::kstream* p__io, gzip_t::subfields_t* p__parent, gzip_t* p__root) : kaitai::kstruct(p__io) {
    m__parent = p__parent;
    m__root = p__root;
    _read();
}
void gzip_t::subfield_t::_read() {
    m_id = m__io->read_u2le();
    m_len_data = m__io->read_u2le();
    m_data = m__io->read_bytes(len_data());
}
gzip_t::subfield_t::~subfield_t() {
    _clean_up();
}
void gzip_t::subfield_t::_clean_up() {
}
gzip_t::extras_t::extras_t(kaitai::kstream* p__io, gzip_t* p__parent, gzip_t* p__root) : kaitai::kstruct(p__io) {
    m__parent = p__parent;
    m__root = p__root;
    m_subfields = nullptr;
    m__io__raw_subfields = nullptr;
    _read();
}
void gzip_t::extras_t::_read() {
    m_len_subfields = m__io->read_u2le();
    m__raw_subfields = m__io->read_bytes(len_subfields());
    m__io__raw_subfields = std::unique_ptr<kaitai::kstream>(new kaitai::kstream(m__raw_subfields));
    m_subfields = std::unique_ptr<subfields_t>(new subfields_t(m__io__raw_subfields.get(), this, m__root));
}
gzip_t::extras_t::~extras_t() {
    _clean_up();
}
void gzip_t::extras_t::_clean_up() {
}
 
 | 
					
	; A069943: Let b(1)=b(2)=1, b(n+2)=(1/(n+1))*(b(n+1)+b(n)); then a(n)=numerator(b(n)).
; Submitted by Jon Maiga
; 1,1,1,2,5,13,19,29,191,131,1187,2231,17519,71063,29881,323423,2887921,13237457,2397389,15030317,742458253,3748521653,9670072483,25451905333,10932619111,78684575461,4163946939067,11799518538967,136025604432743
sub $0,1
mov $1,1
lpb $0
  add $2,$1
  mul $2,$0
  sub $0,1
  add $1,$2
  dif $2,-1
lpe
gcd $2,$1
div $1,$2
dif $1,2
mov $0,$1
 
 | 
					
	; A032821: Numbers whose set of base-9 digits is {1,4}.
; Submitted by Simon Strandgaard
; 1,4,10,13,37,40,91,94,118,121,334,337,361,364,820,823,847,850,1063,1066,1090,1093,3007,3010,3034,3037,3250,3253,3277,3280,7381,7384,7408,7411,7624,7627,7651,7654,9568,9571,9595,9598,9811,9814,9838,9841,27064,27067,27091,27094,27307,27310,27334,27337,29251,29254,29278,29281,29494,29497,29521,29524,66430,66433,66457,66460,66673,66676,66700,66703,68617,68620,68644,68647,68860,68863,68887,68890,86113,86116,86140,86143,86356,86359,86383,86386,88300,88303,88327,88330,88543,88546,88570,88573,243577
add $0,1
mov $2,1
lpb $0
  mov $3,$0
  mul $0,2
  sub $0,1
  div $0,4
  mod $3,2
  mul $3,$2
  add $1,$3
  mul $2,9
lpe
mul $1,6
sub $2,$1
mov $0,$2
div $0,2
 
 | 
					
	SFX_Turn_On_PC_3_Ch4:
	duty 2
	squarenote 15, 15, 2, 1984
	squarenote 15, 0, 0, 0
	squarenote 15, 0, 0, 0
	squarenote 3, 8, 1, 1920
	squarenote 3, 8, 1, 1792
	squarenote 3, 8, 1, 1856
	squarenote 3, 8, 1, 1792
	squarenote 3, 8, 1, 1920
	squarenote 3, 8, 1, 1792
	squarenote 3, 8, 1, 1984
	squarenote 3, 8, 1, 1792
	endchannel
 
 | 
					
	; A082309: Expansion of e.g.f.: (1+x)*exp(5*x)*cosh(x).
; Submitted by Jon Maiga
; 1,6,36,218,1336,8280,51776,325792,2057856,13023104,82456576,521826816,3298727936,20822038528,131210919936,825373859840,5182772248576,32487861092352,203308891897856,1270289732337664,7924975155019776,49371882836197376,307174483569934336,1908752200224473088,11846938508222529536,73448992131147366400,454901496977477861376,2814668320757264678912,17399624504693128953856,107467677703435897012224,663226659078594652798976,4089887690959897740967936,25202509858511934493556736,155194232908720180872347648
mov $1,$0
add $1,5
mov $2,1
lpb $0
  sub $0,1
  mov $4,$3
  mul $3,$1
  add $3,$2
  mul $2,$1
  mov $1,5
  add $2,$4
lpe
mov $0,$2
 
 | 
					
	; A085473: a(n) = 6*n^2 + 3*n + 1.
; 1,10,31,64,109,166,235,316,409,514,631,760,901,1054,1219,1396,1585,1786,1999,2224,2461,2710,2971,3244,3529,3826,4135,4456,4789,5134,5491,5860,6241,6634,7039,7456,7885,8326,8779,9244,9721,10210,10711,11224,11749,12286,12835,13396,13969,14554,15151,15760,16381,17014,17659,18316,18985,19666,20359,21064,21781,22510,23251,24004,24769,25546,26335,27136,27949,28774,29611,30460,31321,32194,33079,33976,34885,35806,36739,37684,38641,39610,40591,41584,42589,43606,44635,45676,46729,47794,48871,49960,51061,52174,53299,54436,55585,56746,57919,59104,60301,61510,62731,63964,65209,66466,67735,69016,70309,71614,72931,74260,75601,76954,78319,79696,81085,82486,83899,85324,86761,88210,89671,91144,92629,94126,95635,97156,98689,100234,101791,103360,104941,106534,108139,109756,111385,113026,114679,116344,118021,119710,121411,123124,124849,126586,128335,130096,131869,133654,135451,137260,139081,140914,142759,144616,146485,148366,150259,152164,154081,156010,157951,159904,161869,163846,165835,167836,169849,171874,173911,175960,178021,180094,182179,184276,186385,188506,190639,192784,194941,197110,199291,201484,203689,205906,208135,210376,212629,214894,217171,219460,221761,224074,226399,228736,231085,233446,235819,238204,240601,243010,245431,247864,250309,252766,255235,257716,260209,262714,265231,267760,270301,272854,275419,277996,280585,283186,285799,288424,291061,293710,296371,299044,301729,304426,307135,309856,312589,315334,318091,320860,323641,326434,329239,332056,334885,337726,340579,343444,346321,349210,352111,355024,357949,360886,363835,366796,369769,372754
mov $1,$0
mul $0,6
add $0,3
mul $1,$0
add $1,1
 
 | 
					
	
user/_ls:     file format elf64-littleriscv
Disassembly of section .text:
0000000000000000 <fmtname>:
#include "user/user.h"
#include "kernel/fs.h"
char*
fmtname(char *path)
{
   0:	7179                	addi	sp,sp,-48
   2:	f406                	sd	ra,40(sp)
   4:	f022                	sd	s0,32(sp)
   6:	ec26                	sd	s1,24(sp)
   8:	e84a                	sd	s2,16(sp)
   a:	e44e                	sd	s3,8(sp)
   c:	1800                	addi	s0,sp,48
   e:	84aa                	mv	s1,a0
  static char buf[DIRSIZ+1];
  char *p;
  // Find first character after last slash.
  for(p=path+strlen(path); p >= path && *p != '/'; p--)
  10:	00000097          	auipc	ra,0x0
  14:	30c080e7          	jalr	780(ra) # 31c <strlen>
  18:	02051793          	slli	a5,a0,0x20
  1c:	9381                	srli	a5,a5,0x20
  1e:	97a6                	add	a5,a5,s1
  20:	02f00693          	li	a3,47
  24:	0097e963          	bltu	a5,s1,36 <fmtname+0x36>
  28:	0007c703          	lbu	a4,0(a5)
  2c:	00d70563          	beq	a4,a3,36 <fmtname+0x36>
  30:	17fd                	addi	a5,a5,-1
  32:	fe97fbe3          	bgeu	a5,s1,28 <fmtname+0x28>
    ;
  p++;
  36:	00178493          	addi	s1,a5,1
  // Return blank-padded name.
  if(strlen(p) >= DIRSIZ)
  3a:	8526                	mv	a0,s1
  3c:	00000097          	auipc	ra,0x0
  40:	2e0080e7          	jalr	736(ra) # 31c <strlen>
  44:	2501                	sext.w	a0,a0
  46:	47b5                	li	a5,13
  48:	00a7fa63          	bgeu	a5,a0,5c <fmtname+0x5c>
    return p;
  memmove(buf, p, strlen(p));
  memset(buf+strlen(p), ' ', DIRSIZ-strlen(p));
  return buf;
}
  4c:	8526                	mv	a0,s1
  4e:	70a2                	ld	ra,40(sp)
  50:	7402                	ld	s0,32(sp)
  52:	64e2                	ld	s1,24(sp)
  54:	6942                	ld	s2,16(sp)
  56:	69a2                	ld	s3,8(sp)
  58:	6145                	addi	sp,sp,48
  5a:	8082                	ret
  memmove(buf, p, strlen(p));
  5c:	8526                	mv	a0,s1
  5e:	00000097          	auipc	ra,0x0
  62:	2be080e7          	jalr	702(ra) # 31c <strlen>
  66:	00001997          	auipc	s3,0x1
  6a:	aaa98993          	addi	s3,s3,-1366 # b10 <buf.1120>
  6e:	0005061b          	sext.w	a2,a0
  72:	85a6                	mv	a1,s1
  74:	854e                	mv	a0,s3
  76:	00000097          	auipc	ra,0x0
  7a:	41e080e7          	jalr	1054(ra) # 494 <memmove>
  memset(buf+strlen(p), ' ', DIRSIZ-strlen(p));
  7e:	8526                	mv	a0,s1
  80:	00000097          	auipc	ra,0x0
  84:	29c080e7          	jalr	668(ra) # 31c <strlen>
  88:	0005091b          	sext.w	s2,a0
  8c:	8526                	mv	a0,s1
  8e:	00000097          	auipc	ra,0x0
  92:	28e080e7          	jalr	654(ra) # 31c <strlen>
  96:	1902                	slli	s2,s2,0x20
  98:	02095913          	srli	s2,s2,0x20
  9c:	4639                	li	a2,14
  9e:	9e09                	subw	a2,a2,a0
  a0:	02000593          	li	a1,32
  a4:	01298533          	add	a0,s3,s2
  a8:	00000097          	auipc	ra,0x0
  ac:	29e080e7          	jalr	670(ra) # 346 <memset>
  return buf;
  b0:	84ce                	mv	s1,s3
  b2:	bf69                	j	4c <fmtname+0x4c>
00000000000000b4 <ls>:
void
ls(char *path)
{
  b4:	d9010113          	addi	sp,sp,-624
  b8:	26113423          	sd	ra,616(sp)
  bc:	26813023          	sd	s0,608(sp)
  c0:	24913c23          	sd	s1,600(sp)
  c4:	25213823          	sd	s2,592(sp)
  c8:	25313423          	sd	s3,584(sp)
  cc:	25413023          	sd	s4,576(sp)
  d0:	23513c23          	sd	s5,568(sp)
  d4:	1c80                	addi	s0,sp,624
  d6:	892a                	mv	s2,a0
  char buf[512], *p;
  int fd;
  struct dirent de;
  struct stat st;
  if((fd = open(path, 0)) < 0){
  d8:	4581                	li	a1,0
  da:	00000097          	auipc	ra,0x0
  de:	4b0080e7          	jalr	1200(ra) # 58a <open>
  e2:	06054f63          	bltz	a0,160 <ls+0xac>
  e6:	84aa                	mv	s1,a0
    fprintf(2, "ls: cannot open %s\n", path);
    return;
  }
  if(fstat(fd, &st) < 0){
  e8:	d9840593          	addi	a1,s0,-616
  ec:	00000097          	auipc	ra,0x0
  f0:	4b6080e7          	jalr	1206(ra) # 5a2 <fstat>
  f4:	08054163          	bltz	a0,176 <ls+0xc2>
    fprintf(2, "ls: cannot stat %s\n", path);
    close(fd);
    return;
  }
  switch(st.type){
  f8:	da041783          	lh	a5,-608(s0)
  fc:	0007869b          	sext.w	a3,a5
 100:	4705                	li	a4,1
 102:	08e68a63          	beq	a3,a4,196 <ls+0xe2>
 106:	4709                	li	a4,2
 108:	02e69663          	bne	a3,a4,134 <ls+0x80>
  case T_FILE:
    printf("%s %d %d %l\n", fmtname(path), st.type, st.ino, st.size);
 10c:	854a                	mv	a0,s2
 10e:	00000097          	auipc	ra,0x0
 112:	ef2080e7          	jalr	-270(ra) # 0 <fmtname>
 116:	85aa                	mv	a1,a0
 118:	da843703          	ld	a4,-600(s0)
 11c:	d9c42683          	lw	a3,-612(s0)
 120:	da041603          	lh	a2,-608(s0)
 124:	00001517          	auipc	a0,0x1
 128:	98450513          	addi	a0,a0,-1660 # aa8 <malloc+0x118>
 12c:	00000097          	auipc	ra,0x0
 130:	7a6080e7          	jalr	1958(ra) # 8d2 <printf>
      }
      printf("%s %d %d %d\n", fmtname(buf), st.type, st.ino, st.size);
    }
    break;
  }
  close(fd);
 134:	8526                	mv	a0,s1
 136:	00000097          	auipc	ra,0x0
 13a:	43c080e7          	jalr	1084(ra) # 572 <close>
}
 13e:	26813083          	ld	ra,616(sp)
 142:	26013403          	ld	s0,608(sp)
 146:	25813483          	ld	s1,600(sp)
 14a:	25013903          	ld	s2,592(sp)
 14e:	24813983          	ld	s3,584(sp)
 152:	24013a03          	ld	s4,576(sp)
 156:	23813a83          	ld	s5,568(sp)
 15a:	27010113          	addi	sp,sp,624
 15e:	8082                	ret
    fprintf(2, "ls: cannot open %s\n", path);
 160:	864a                	mv	a2,s2
 162:	00001597          	auipc	a1,0x1
 166:	91658593          	addi	a1,a1,-1770 # a78 <malloc+0xe8>
 16a:	4509                	li	a0,2
 16c:	00000097          	auipc	ra,0x0
 170:	738080e7          	jalr	1848(ra) # 8a4 <fprintf>
    return;
 174:	b7e9                	j	13e <ls+0x8a>
    fprintf(2, "ls: cannot stat %s\n", path);
 176:	864a                	mv	a2,s2
 178:	00001597          	auipc	a1,0x1
 17c:	91858593          	addi	a1,a1,-1768 # a90 <malloc+0x100>
 180:	4509                	li	a0,2
 182:	00000097          	auipc	ra,0x0
 186:	722080e7          	jalr	1826(ra) # 8a4 <fprintf>
    close(fd);
 18a:	8526                	mv	a0,s1
 18c:	00000097          	auipc	ra,0x0
 190:	3e6080e7          	jalr	998(ra) # 572 <close>
    return;
 194:	b76d                	j	13e <ls+0x8a>
    if(strlen(path) + 1 + DIRSIZ + 1 > sizeof buf){
 196:	854a                	mv	a0,s2
 198:	00000097          	auipc	ra,0x0
 19c:	184080e7          	jalr	388(ra) # 31c <strlen>
 1a0:	2541                	addiw	a0,a0,16
 1a2:	20000793          	li	a5,512
 1a6:	00a7fb63          	bgeu	a5,a0,1bc <ls+0x108>
      printf("ls: path too long\n");
 1aa:	00001517          	auipc	a0,0x1
 1ae:	90e50513          	addi	a0,a0,-1778 # ab8 <malloc+0x128>
 1b2:	00000097          	auipc	ra,0x0
 1b6:	720080e7          	jalr	1824(ra) # 8d2 <printf>
      break;
 1ba:	bfad                	j	134 <ls+0x80>
    strcpy(buf, path);
 1bc:	85ca                	mv	a1,s2
 1be:	dc040513          	addi	a0,s0,-576
 1c2:	00000097          	auipc	ra,0x0
 1c6:	112080e7          	jalr	274(ra) # 2d4 <strcpy>
    p = buf+strlen(buf);
 1ca:	dc040513          	addi	a0,s0,-576
 1ce:	00000097          	auipc	ra,0x0
 1d2:	14e080e7          	jalr	334(ra) # 31c <strlen>
 1d6:	02051913          	slli	s2,a0,0x20
 1da:	02095913          	srli	s2,s2,0x20
 1de:	dc040793          	addi	a5,s0,-576
 1e2:	993e                	add	s2,s2,a5
    *p++ = '/';
 1e4:	00190993          	addi	s3,s2,1
 1e8:	02f00793          	li	a5,47
 1ec:	00f90023          	sb	a5,0(s2)
      printf("%s %d %d %d\n", fmtname(buf), st.type, st.ino, st.size);
 1f0:	00001a17          	auipc	s4,0x1
 1f4:	8e0a0a13          	addi	s4,s4,-1824 # ad0 <malloc+0x140>
        printf("ls: cannot stat %s\n", buf);
 1f8:	00001a97          	auipc	s5,0x1
 1fc:	898a8a93          	addi	s5,s5,-1896 # a90 <malloc+0x100>
    while(read(fd, &de, sizeof(de)) == sizeof(de)){
 200:	a801                	j	210 <ls+0x15c>
        printf("ls: cannot stat %s\n", buf);
 202:	dc040593          	addi	a1,s0,-576
 206:	8556                	mv	a0,s5
 208:	00000097          	auipc	ra,0x0
 20c:	6ca080e7          	jalr	1738(ra) # 8d2 <printf>
    while(read(fd, &de, sizeof(de)) == sizeof(de)){
 210:	4641                	li	a2,16
 212:	db040593          	addi	a1,s0,-592
 216:	8526                	mv	a0,s1
 218:	00000097          	auipc	ra,0x0
 21c:	34a080e7          	jalr	842(ra) # 562 <read>
 220:	47c1                	li	a5,16
 222:	f0f519e3          	bne	a0,a5,134 <ls+0x80>
      if(de.inum == 0)
 226:	db045783          	lhu	a5,-592(s0)
 22a:	d3fd                	beqz	a5,210 <ls+0x15c>
      memmove(p, de.name, DIRSIZ);
 22c:	4639                	li	a2,14
 22e:	db240593          	addi	a1,s0,-590
 232:	854e                	mv	a0,s3
 234:	00000097          	auipc	ra,0x0
 238:	260080e7          	jalr	608(ra) # 494 <memmove>
      p[DIRSIZ] = 0;
 23c:	000907a3          	sb	zero,15(s2)
      if(stat(buf, &st) < 0){
 240:	d9840593          	addi	a1,s0,-616
 244:	dc040513          	addi	a0,s0,-576
 248:	00000097          	auipc	ra,0x0
 24c:	1bc080e7          	jalr	444(ra) # 404 <stat>
 250:	fa0549e3          	bltz	a0,202 <ls+0x14e>
      printf("%s %d %d %d\n", fmtname(buf), st.type, st.ino, st.size);
 254:	dc040513          	addi	a0,s0,-576
 258:	00000097          	auipc	ra,0x0
 25c:	da8080e7          	jalr	-600(ra) # 0 <fmtname>
 260:	85aa                	mv	a1,a0
 262:	da843703          	ld	a4,-600(s0)
 266:	d9c42683          	lw	a3,-612(s0)
 26a:	da041603          	lh	a2,-608(s0)
 26e:	8552                	mv	a0,s4
 270:	00000097          	auipc	ra,0x0
 274:	662080e7          	jalr	1634(ra) # 8d2 <printf>
 278:	bf61                	j	210 <ls+0x15c>
000000000000027a <main>:
int
main(int argc, char *argv[])
{
 27a:	1101                	addi	sp,sp,-32
 27c:	ec06                	sd	ra,24(sp)
 27e:	e822                	sd	s0,16(sp)
 280:	e426                	sd	s1,8(sp)
 282:	e04a                	sd	s2,0(sp)
 284:	1000                	addi	s0,sp,32
  int i;
  if(argc < 2){
 286:	4785                	li	a5,1
 288:	02a7d963          	bge	a5,a0,2ba <main+0x40>
 28c:	00858493          	addi	s1,a1,8
 290:	ffe5091b          	addiw	s2,a0,-2
 294:	1902                	slli	s2,s2,0x20
 296:	02095913          	srli	s2,s2,0x20
 29a:	090e                	slli	s2,s2,0x3
 29c:	05c1                	addi	a1,a1,16
 29e:	992e                	add	s2,s2,a1
    ls(".");
    exit(0);
  }
  for(i=1; i<argc; i++)
    ls(argv[i]);
 2a0:	6088                	ld	a0,0(s1)
 2a2:	00000097          	auipc	ra,0x0
 2a6:	e12080e7          	jalr	-494(ra) # b4 <ls>
  for(i=1; i<argc; i++)
 2aa:	04a1                	addi	s1,s1,8
 2ac:	ff249ae3          	bne	s1,s2,2a0 <main+0x26>
  exit(0);
 2b0:	4501                	li	a0,0
 2b2:	00000097          	auipc	ra,0x0
 2b6:	298080e7          	jalr	664(ra) # 54a <exit>
    ls(".");
 2ba:	00001517          	auipc	a0,0x1
 2be:	82650513          	addi	a0,a0,-2010 # ae0 <malloc+0x150>
 2c2:	00000097          	auipc	ra,0x0
 2c6:	df2080e7          	jalr	-526(ra) # b4 <ls>
    exit(0);
 2ca:	4501                	li	a0,0
 2cc:	00000097          	auipc	ra,0x0
 2d0:	27e080e7          	jalr	638(ra) # 54a <exit>
00000000000002d4 <strcpy>:
#include "kernel/fcntl.h"
#include "user/user.h"
char*
strcpy(char *s, const char *t)
{
 2d4:	1141                	addi	sp,sp,-16
 2d6:	e422                	sd	s0,8(sp)
 2d8:	0800                	addi	s0,sp,16
  char *os;
  os = s;
  while((*s++ = *t++) != 0)
 2da:	87aa                	mv	a5,a0
 2dc:	0585                	addi	a1,a1,1
 2de:	0785                	addi	a5,a5,1
 2e0:	fff5c703          	lbu	a4,-1(a1)
 2e4:	fee78fa3          	sb	a4,-1(a5)
 2e8:	fb75                	bnez	a4,2dc <strcpy+0x8>
    ;
  return os;
}
 2ea:	6422                	ld	s0,8(sp)
 2ec:	0141                	addi	sp,sp,16
 2ee:	8082                	ret
00000000000002f0 <strcmp>:
int
strcmp(const char *p, const char *q)
{
 2f0:	1141                	addi	sp,sp,-16
 2f2:	e422                	sd	s0,8(sp)
 2f4:	0800                	addi	s0,sp,16
  while(*p && *p == *q)
 2f6:	00054783          	lbu	a5,0(a0)
 2fa:	cb91                	beqz	a5,30e <strcmp+0x1e>
 2fc:	0005c703          	lbu	a4,0(a1)
 300:	00f71763          	bne	a4,a5,30e <strcmp+0x1e>
    p++, q++;
 304:	0505                	addi	a0,a0,1
 306:	0585                	addi	a1,a1,1
  while(*p && *p == *q)
 308:	00054783          	lbu	a5,0(a0)
 30c:	fbe5                	bnez	a5,2fc <strcmp+0xc>
  return (uchar)*p - (uchar)*q;
 30e:	0005c503          	lbu	a0,0(a1)
}
 312:	40a7853b          	subw	a0,a5,a0
 316:	6422                	ld	s0,8(sp)
 318:	0141                	addi	sp,sp,16
 31a:	8082                	ret
000000000000031c <strlen>:
uint
strlen(const char *s)
{
 31c:	1141                	addi	sp,sp,-16
 31e:	e422                	sd	s0,8(sp)
 320:	0800                	addi	s0,sp,16
  int n;
  for(n = 0; s[n]; n++)
 322:	00054783          	lbu	a5,0(a0)
 326:	cf91                	beqz	a5,342 <strlen+0x26>
 328:	0505                	addi	a0,a0,1
 32a:	87aa                	mv	a5,a0
 32c:	4685                	li	a3,1
 32e:	9e89                	subw	a3,a3,a0
 330:	00f6853b          	addw	a0,a3,a5
 334:	0785                	addi	a5,a5,1
 336:	fff7c703          	lbu	a4,-1(a5)
 33a:	fb7d                	bnez	a4,330 <strlen+0x14>
    ;
  return n;
}
 33c:	6422                	ld	s0,8(sp)
 33e:	0141                	addi	sp,sp,16
 340:	8082                	ret
  for(n = 0; s[n]; n++)
 342:	4501                	li	a0,0
 344:	bfe5                	j	33c <strlen+0x20>
0000000000000346 <memset>:
void*
memset(void *dst, int c, uint n)
{
 346:	1141                	addi	sp,sp,-16
 348:	e422                	sd	s0,8(sp)
 34a:	0800                	addi	s0,sp,16
  char *cdst = (char *) dst;
  int i;
  for(i = 0; i < n; i++){
 34c:	ce09                	beqz	a2,366 <memset+0x20>
 34e:	87aa                	mv	a5,a0
 350:	fff6071b          	addiw	a4,a2,-1
 354:	1702                	slli	a4,a4,0x20
 356:	9301                	srli	a4,a4,0x20
 358:	0705                	addi	a4,a4,1
 35a:	972a                	add	a4,a4,a0
    cdst[i] = c;
 35c:	00b78023          	sb	a1,0(a5)
  for(i = 0; i < n; i++){
 360:	0785                	addi	a5,a5,1
 362:	fee79de3          	bne	a5,a4,35c <memset+0x16>
  }
  return dst;
}
 366:	6422                	ld	s0,8(sp)
 368:	0141                	addi	sp,sp,16
 36a:	8082                	ret
000000000000036c <strchr>:
char*
strchr(const char *s, char c)
{
 36c:	1141                	addi	sp,sp,-16
 36e:	e422                	sd	s0,8(sp)
 370:	0800                	addi	s0,sp,16
  for(; *s; s++)
 372:	00054783          	lbu	a5,0(a0)
 376:	cb99                	beqz	a5,38c <strchr+0x20>
    if(*s == c)
 378:	00f58763          	beq	a1,a5,386 <strchr+0x1a>
  for(; *s; s++)
 37c:	0505                	addi	a0,a0,1
 37e:	00054783          	lbu	a5,0(a0)
 382:	fbfd                	bnez	a5,378 <strchr+0xc>
      return (char*)s;
  return 0;
 384:	4501                	li	a0,0
}
 386:	6422                	ld	s0,8(sp)
 388:	0141                	addi	sp,sp,16
 38a:	8082                	ret
  return 0;
 38c:	4501                	li	a0,0
 38e:	bfe5                	j	386 <strchr+0x1a>
0000000000000390 <gets>:
char*
gets(char *buf, int max)
{
 390:	711d                	addi	sp,sp,-96
 392:	ec86                	sd	ra,88(sp)
 394:	e8a2                	sd	s0,80(sp)
 396:	e4a6                	sd	s1,72(sp)
 398:	e0ca                	sd	s2,64(sp)
 39a:	fc4e                	sd	s3,56(sp)
 39c:	f852                	sd	s4,48(sp)
 39e:	f456                	sd	s5,40(sp)
 3a0:	f05a                	sd	s6,32(sp)
 3a2:	ec5e                	sd	s7,24(sp)
 3a4:	1080                	addi	s0,sp,96
 3a6:	8baa                	mv	s7,a0
 3a8:	8a2e                	mv	s4,a1
  int i, cc;
  char c;
  for(i=0; i+1 < max; ){
 3aa:	892a                	mv	s2,a0
 3ac:	4481                	li	s1,0
    cc = read(0, &c, 1);
    if(cc < 1)
      break;
    buf[i++] = c;
    if(c == '\n' || c == '\r')
 3ae:	4aa9                	li	s5,10
 3b0:	4b35                	li	s6,13
  for(i=0; i+1 < max; ){
 3b2:	89a6                	mv	s3,s1
 3b4:	2485                	addiw	s1,s1,1
 3b6:	0344d863          	bge	s1,s4,3e6 <gets+0x56>
    cc = read(0, &c, 1);
 3ba:	4605                	li	a2,1
 3bc:	faf40593          	addi	a1,s0,-81
 3c0:	4501                	li	a0,0
 3c2:	00000097          	auipc	ra,0x0
 3c6:	1a0080e7          	jalr	416(ra) # 562 <read>
    if(cc < 1)
 3ca:	00a05e63          	blez	a0,3e6 <gets+0x56>
    buf[i++] = c;
 3ce:	faf44783          	lbu	a5,-81(s0)
 3d2:	00f90023          	sb	a5,0(s2)
    if(c == '\n' || c == '\r')
 3d6:	01578763          	beq	a5,s5,3e4 <gets+0x54>
 3da:	0905                	addi	s2,s2,1
 3dc:	fd679be3          	bne	a5,s6,3b2 <gets+0x22>
  for(i=0; i+1 < max; ){
 3e0:	89a6                	mv	s3,s1
 3e2:	a011                	j	3e6 <gets+0x56>
 3e4:	89a6                	mv	s3,s1
      break;
  }
  buf[i] = '\0';
 3e6:	99de                	add	s3,s3,s7
 3e8:	00098023          	sb	zero,0(s3)
  return buf;
}
 3ec:	855e                	mv	a0,s7
 3ee:	60e6                	ld	ra,88(sp)
 3f0:	6446                	ld	s0,80(sp)
 3f2:	64a6                	ld	s1,72(sp)
 3f4:	6906                	ld	s2,64(sp)
 3f6:	79e2                	ld	s3,56(sp)
 3f8:	7a42                	ld	s4,48(sp)
 3fa:	7aa2                	ld	s5,40(sp)
 3fc:	7b02                	ld	s6,32(sp)
 3fe:	6be2                	ld	s7,24(sp)
 400:	6125                	addi	sp,sp,96
 402:	8082                	ret
0000000000000404 <stat>:
int
stat(const char *n, struct stat *st)
{
 404:	1101                	addi	sp,sp,-32
 406:	ec06                	sd	ra,24(sp)
 408:	e822                	sd	s0,16(sp)
 40a:	e426                	sd	s1,8(sp)
 40c:	e04a                	sd	s2,0(sp)
 40e:	1000                	addi	s0,sp,32
 410:	892e                	mv	s2,a1
  int fd;
  int r;
  fd = open(n, O_RDONLY);
 412:	4581                	li	a1,0
 414:	00000097          	auipc	ra,0x0
 418:	176080e7          	jalr	374(ra) # 58a <open>
  if(fd < 0)
 41c:	02054563          	bltz	a0,446 <stat+0x42>
 420:	84aa                	mv	s1,a0
    return -1;
  r = fstat(fd, st);
 422:	85ca                	mv	a1,s2
 424:	00000097          	auipc	ra,0x0
 428:	17e080e7          	jalr	382(ra) # 5a2 <fstat>
 42c:	892a                	mv	s2,a0
  close(fd);
 42e:	8526                	mv	a0,s1
 430:	00000097          	auipc	ra,0x0
 434:	142080e7          	jalr	322(ra) # 572 <close>
  return r;
}
 438:	854a                	mv	a0,s2
 43a:	60e2                	ld	ra,24(sp)
 43c:	6442                	ld	s0,16(sp)
 43e:	64a2                	ld	s1,8(sp)
 440:	6902                	ld	s2,0(sp)
 442:	6105                	addi	sp,sp,32
 444:	8082                	ret
    return -1;
 446:	597d                	li	s2,-1
 448:	bfc5                	j	438 <stat+0x34>
000000000000044a <atoi>:
int
atoi(const char *s)
{
 44a:	1141                	addi	sp,sp,-16
 44c:	e422                	sd	s0,8(sp)
 44e:	0800                	addi	s0,sp,16
  int n;
  n = 0;
  while('0' <= *s && *s <= '9')
 450:	00054603          	lbu	a2,0(a0)
 454:	fd06079b          	addiw	a5,a2,-48
 458:	0ff7f793          	andi	a5,a5,255
 45c:	4725                	li	a4,9
 45e:	02f76963          	bltu	a4,a5,490 <atoi+0x46>
 462:	86aa                	mv	a3,a0
  n = 0;
 464:	4501                	li	a0,0
  while('0' <= *s && *s <= '9')
 466:	45a5                	li	a1,9
    n = n*10 + *s++ - '0';
 468:	0685                	addi	a3,a3,1
 46a:	0025179b          	slliw	a5,a0,0x2
 46e:	9fa9                	addw	a5,a5,a0
 470:	0017979b          	slliw	a5,a5,0x1
 474:	9fb1                	addw	a5,a5,a2
 476:	fd07851b          	addiw	a0,a5,-48
  while('0' <= *s && *s <= '9')
 47a:	0006c603          	lbu	a2,0(a3)
 47e:	fd06071b          	addiw	a4,a2,-48
 482:	0ff77713          	andi	a4,a4,255
 486:	fee5f1e3          	bgeu	a1,a4,468 <atoi+0x1e>
  return n;
}
 48a:	6422                	ld	s0,8(sp)
 48c:	0141                	addi	sp,sp,16
 48e:	8082                	ret
  n = 0;
 490:	4501                	li	a0,0
 492:	bfe5                	j	48a <atoi+0x40>
0000000000000494 <memmove>:
void*
memmove(void *vdst, const void *vsrc, int n)
{
 494:	1141                	addi	sp,sp,-16
 496:	e422                	sd	s0,8(sp)
 498:	0800                	addi	s0,sp,16
  char *dst;
  const char *src;
  dst = vdst;
  src = vsrc;
  if (src > dst) {
 49a:	02b57663          	bgeu	a0,a1,4c6 <memmove+0x32>
    while(n-- > 0)
 49e:	02c05163          	blez	a2,4c0 <memmove+0x2c>
 4a2:	fff6079b          	addiw	a5,a2,-1
 4a6:	1782                	slli	a5,a5,0x20
 4a8:	9381                	srli	a5,a5,0x20
 4aa:	0785                	addi	a5,a5,1
 4ac:	97aa                	add	a5,a5,a0
  dst = vdst;
 4ae:	872a                	mv	a4,a0
      *dst++ = *src++;
 4b0:	0585                	addi	a1,a1,1
 4b2:	0705                	addi	a4,a4,1
 4b4:	fff5c683          	lbu	a3,-1(a1)
 4b8:	fed70fa3          	sb	a3,-1(a4)
    while(n-- > 0)
 4bc:	fee79ae3          	bne	a5,a4,4b0 <memmove+0x1c>
    src += n;
    while(n-- > 0)
      *--dst = *--src;
  }
  return vdst;
}
 4c0:	6422                	ld	s0,8(sp)
 4c2:	0141                	addi	sp,sp,16
 4c4:	8082                	ret
    dst += n;
 4c6:	00c50733          	add	a4,a0,a2
    src += n;
 4ca:	95b2                	add	a1,a1,a2
    while(n-- > 0)
 4cc:	fec05ae3          	blez	a2,4c0 <memmove+0x2c>
 4d0:	fff6079b          	addiw	a5,a2,-1
 4d4:	1782                	slli	a5,a5,0x20
 4d6:	9381                	srli	a5,a5,0x20
 4d8:	fff7c793          	not	a5,a5
 4dc:	97ba                	add	a5,a5,a4
      *--dst = *--src;
 4de:	15fd                	addi	a1,a1,-1
 4e0:	177d                	addi	a4,a4,-1
 4e2:	0005c683          	lbu	a3,0(a1)
 4e6:	00d70023          	sb	a3,0(a4)
    while(n-- > 0)
 4ea:	fee79ae3          	bne	a5,a4,4de <memmove+0x4a>
 4ee:	bfc9                	j	4c0 <memmove+0x2c>
00000000000004f0 <memcmp>:
int
memcmp(const void *s1, const void *s2, uint n)
{
 4f0:	1141                	addi	sp,sp,-16
 4f2:	e422                	sd	s0,8(sp)
 4f4:	0800                	addi	s0,sp,16
  const char *p1 = s1, *p2 = s2;
  while (n-- > 0) {
 4f6:	ca05                	beqz	a2,526 <memcmp+0x36>
 4f8:	fff6069b          	addiw	a3,a2,-1
 4fc:	1682                	slli	a3,a3,0x20
 4fe:	9281                	srli	a3,a3,0x20
 500:	0685                	addi	a3,a3,1
 502:	96aa                	add	a3,a3,a0
    if (*p1 != *p2) {
 504:	00054783          	lbu	a5,0(a0)
 508:	0005c703          	lbu	a4,0(a1)
 50c:	00e79863          	bne	a5,a4,51c <memcmp+0x2c>
      return *p1 - *p2;
    }
    p1++;
 510:	0505                	addi	a0,a0,1
    p2++;
 512:	0585                	addi	a1,a1,1
  while (n-- > 0) {
 514:	fed518e3          	bne	a0,a3,504 <memcmp+0x14>
  }
  return 0;
 518:	4501                	li	a0,0
 51a:	a019                	j	520 <memcmp+0x30>
      return *p1 - *p2;
 51c:	40e7853b          	subw	a0,a5,a4
}
 520:	6422                	ld	s0,8(sp)
 522:	0141                	addi	sp,sp,16
 524:	8082                	ret
  return 0;
 526:	4501                	li	a0,0
 528:	bfe5                	j	520 <memcmp+0x30>
000000000000052a <memcpy>:
void *
memcpy(void *dst, const void *src, uint n)
{
 52a:	1141                	addi	sp,sp,-16
 52c:	e406                	sd	ra,8(sp)
 52e:	e022                	sd	s0,0(sp)
 530:	0800                	addi	s0,sp,16
  return memmove(dst, src, n);
 532:	00000097          	auipc	ra,0x0
 536:	f62080e7          	jalr	-158(ra) # 494 <memmove>
}
 53a:	60a2                	ld	ra,8(sp)
 53c:	6402                	ld	s0,0(sp)
 53e:	0141                	addi	sp,sp,16
 540:	8082                	ret
0000000000000542 <fork>:
# generated by usys.pl - do not edit
#include "kernel/syscall.h"
.global fork
fork:
 li a7, SYS_fork
 542:	4885                	li	a7,1
 ecall
 544:	00000073          	ecall
 ret
 548:	8082                	ret
000000000000054a <exit>:
.global exit
exit:
 li a7, SYS_exit
 54a:	4889                	li	a7,2
 ecall
 54c:	00000073          	ecall
 ret
 550:	8082                	ret
0000000000000552 <wait>:
.global wait
wait:
 li a7, SYS_wait
 552:	488d                	li	a7,3
 ecall
 554:	00000073          	ecall
 ret
 558:	8082                	ret
000000000000055a <pipe>:
.global pipe
pipe:
 li a7, SYS_pipe
 55a:	4891                	li	a7,4
 ecall
 55c:	00000073          	ecall
 ret
 560:	8082                	ret
0000000000000562 <read>:
.global read
read:
 li a7, SYS_read
 562:	4895                	li	a7,5
 ecall
 564:	00000073          	ecall
 ret
 568:	8082                	ret
000000000000056a <write>:
.global write
write:
 li a7, SYS_write
 56a:	48c1                	li	a7,16
 ecall
 56c:	00000073          	ecall
 ret
 570:	8082                	ret
0000000000000572 <close>:
.global close
close:
 li a7, SYS_close
 572:	48d5                	li	a7,21
 ecall
 574:	00000073          	ecall
 ret
 578:	8082                	ret
000000000000057a <kill>:
.global kill
kill:
 li a7, SYS_kill
 57a:	4899                	li	a7,6
 ecall
 57c:	00000073          	ecall
 ret
 580:	8082                	ret
0000000000000582 <exec>:
.global exec
exec:
 li a7, SYS_exec
 582:	489d                	li	a7,7
 ecall
 584:	00000073          	ecall
 ret
 588:	8082                	ret
000000000000058a <open>:
.global open
open:
 li a7, SYS_open
 58a:	48bd                	li	a7,15
 ecall
 58c:	00000073          	ecall
 ret
 590:	8082                	ret
0000000000000592 <mknod>:
.global mknod
mknod:
 li a7, SYS_mknod
 592:	48c5                	li	a7,17
 ecall
 594:	00000073          	ecall
 ret
 598:	8082                	ret
000000000000059a <unlink>:
.global unlink
unlink:
 li a7, SYS_unlink
 59a:	48c9                	li	a7,18
 ecall
 59c:	00000073          	ecall
 ret
 5a0:	8082                	ret
00000000000005a2 <fstat>:
.global fstat
fstat:
 li a7, SYS_fstat
 5a2:	48a1                	li	a7,8
 ecall
 5a4:	00000073          	ecall
 ret
 5a8:	8082                	ret
00000000000005aa <link>:
.global link
link:
 li a7, SYS_link
 5aa:	48cd                	li	a7,19
 ecall
 5ac:	00000073          	ecall
 ret
 5b0:	8082                	ret
00000000000005b2 <mkdir>:
.global mkdir
mkdir:
 li a7, SYS_mkdir
 5b2:	48d1                	li	a7,20
 ecall
 5b4:	00000073          	ecall
 ret
 5b8:	8082                	ret
00000000000005ba <chdir>:
.global chdir
chdir:
 li a7, SYS_chdir
 5ba:	48a5                	li	a7,9
 ecall
 5bc:	00000073          	ecall
 ret
 5c0:	8082                	ret
00000000000005c2 <dup>:
.global dup
dup:
 li a7, SYS_dup
 5c2:	48a9                	li	a7,10
 ecall
 5c4:	00000073          	ecall
 ret
 5c8:	8082                	ret
00000000000005ca <getpid>:
.global getpid
getpid:
 li a7, SYS_getpid
 5ca:	48ad                	li	a7,11
 ecall
 5cc:	00000073          	ecall
 ret
 5d0:	8082                	ret
00000000000005d2 <sbrk>:
.global sbrk
sbrk:
 li a7, SYS_sbrk
 5d2:	48b1                	li	a7,12
 ecall
 5d4:	00000073          	ecall
 ret
 5d8:	8082                	ret
00000000000005da <sleep>:
.global sleep
sleep:
 li a7, SYS_sleep
 5da:	48b5                	li	a7,13
 ecall
 5dc:	00000073          	ecall
 ret
 5e0:	8082                	ret
00000000000005e2 <uptime>:
.global uptime
uptime:
 li a7, SYS_uptime
 5e2:	48b9                	li	a7,14
 ecall
 5e4:	00000073          	ecall
 ret
 5e8:	8082                	ret
00000000000005ea <connect>:
.global connect
connect:
 li a7, SYS_connect
 5ea:	48d9                	li	a7,22
 ecall
 5ec:	00000073          	ecall
 ret
 5f0:	8082                	ret
00000000000005f2 <ntas>:
.global ntas
ntas:
 li a7, SYS_ntas
 5f2:	48dd                	li	a7,23
 ecall
 5f4:	00000073          	ecall
 ret
 5f8:	8082                	ret
00000000000005fa <putc>:
static char digits[] = "0123456789ABCDEF";
static void
putc(int fd, char c)
{
 5fa:	1101                	addi	sp,sp,-32
 5fc:	ec06                	sd	ra,24(sp)
 5fe:	e822                	sd	s0,16(sp)
 600:	1000                	addi	s0,sp,32
 602:	feb407a3          	sb	a1,-17(s0)
  write(fd, &c, 1);
 606:	4605                	li	a2,1
 608:	fef40593          	addi	a1,s0,-17
 60c:	00000097          	auipc	ra,0x0
 610:	f5e080e7          	jalr	-162(ra) # 56a <write>
}
 614:	60e2                	ld	ra,24(sp)
 616:	6442                	ld	s0,16(sp)
 618:	6105                	addi	sp,sp,32
 61a:	8082                	ret
000000000000061c <printint>:
static void
printint(int fd, int xx, int base, int sgn)
{
 61c:	7139                	addi	sp,sp,-64
 61e:	fc06                	sd	ra,56(sp)
 620:	f822                	sd	s0,48(sp)
 622:	f426                	sd	s1,40(sp)
 624:	f04a                	sd	s2,32(sp)
 626:	ec4e                	sd	s3,24(sp)
 628:	0080                	addi	s0,sp,64
 62a:	84aa                	mv	s1,a0
  char buf[16];
  int i, neg;
  uint x;
  neg = 0;
  if(sgn && xx < 0){
 62c:	c299                	beqz	a3,632 <printint+0x16>
 62e:	0805c863          	bltz	a1,6be <printint+0xa2>
    neg = 1;
    x = -xx;
  } else {
    x = xx;
 632:	2581                	sext.w	a1,a1
  neg = 0;
 634:	4881                	li	a7,0
 636:	fc040693          	addi	a3,s0,-64
  }
  i = 0;
 63a:	4701                	li	a4,0
  do{
    buf[i++] = digits[x % base];
 63c:	2601                	sext.w	a2,a2
 63e:	00000517          	auipc	a0,0x0
 642:	4b250513          	addi	a0,a0,1202 # af0 <digits>
 646:	883a                	mv	a6,a4
 648:	2705                	addiw	a4,a4,1
 64a:	02c5f7bb          	remuw	a5,a1,a2
 64e:	1782                	slli	a5,a5,0x20
 650:	9381                	srli	a5,a5,0x20
 652:	97aa                	add	a5,a5,a0
 654:	0007c783          	lbu	a5,0(a5)
 658:	00f68023          	sb	a5,0(a3)
  }while((x /= base) != 0);
 65c:	0005879b          	sext.w	a5,a1
 660:	02c5d5bb          	divuw	a1,a1,a2
 664:	0685                	addi	a3,a3,1
 666:	fec7f0e3          	bgeu	a5,a2,646 <printint+0x2a>
  if(neg)
 66a:	00088b63          	beqz	a7,680 <printint+0x64>
    buf[i++] = '-';
 66e:	fd040793          	addi	a5,s0,-48
 672:	973e                	add	a4,a4,a5
 674:	02d00793          	li	a5,45
 678:	fef70823          	sb	a5,-16(a4)
 67c:	0028071b          	addiw	a4,a6,2
  while(--i >= 0)
 680:	02e05863          	blez	a4,6b0 <printint+0x94>
 684:	fc040793          	addi	a5,s0,-64
 688:	00e78933          	add	s2,a5,a4
 68c:	fff78993          	addi	s3,a5,-1
 690:	99ba                	add	s3,s3,a4
 692:	377d                	addiw	a4,a4,-1
 694:	1702                	slli	a4,a4,0x20
 696:	9301                	srli	a4,a4,0x20
 698:	40e989b3          	sub	s3,s3,a4
    putc(fd, buf[i]);
 69c:	fff94583          	lbu	a1,-1(s2)
 6a0:	8526                	mv	a0,s1
 6a2:	00000097          	auipc	ra,0x0
 6a6:	f58080e7          	jalr	-168(ra) # 5fa <putc>
  while(--i >= 0)
 6aa:	197d                	addi	s2,s2,-1
 6ac:	ff3918e3          	bne	s2,s3,69c <printint+0x80>
}
 6b0:	70e2                	ld	ra,56(sp)
 6b2:	7442                	ld	s0,48(sp)
 6b4:	74a2                	ld	s1,40(sp)
 6b6:	7902                	ld	s2,32(sp)
 6b8:	69e2                	ld	s3,24(sp)
 6ba:	6121                	addi	sp,sp,64
 6bc:	8082                	ret
    x = -xx;
 6be:	40b005bb          	negw	a1,a1
    neg = 1;
 6c2:	4885                	li	a7,1
    x = -xx;
 6c4:	bf8d                	j	636 <printint+0x1a>
00000000000006c6 <vprintf>:
}
// Print to the given fd. Only understands %d, %x, %p, %s.
void
vprintf(int fd, const char *fmt, va_list ap)
{
 6c6:	7119                	addi	sp,sp,-128
 6c8:	fc86                	sd	ra,120(sp)
 6ca:	f8a2                	sd	s0,112(sp)
 6cc:	f4a6                	sd	s1,104(sp)
 6ce:	f0ca                	sd	s2,96(sp)
 6d0:	ecce                	sd	s3,88(sp)
 6d2:	e8d2                	sd	s4,80(sp)
 6d4:	e4d6                	sd	s5,72(sp)
 6d6:	e0da                	sd	s6,64(sp)
 6d8:	fc5e                	sd	s7,56(sp)
 6da:	f862                	sd	s8,48(sp)
 6dc:	f466                	sd	s9,40(sp)
 6de:	f06a                	sd	s10,32(sp)
 6e0:	ec6e                	sd	s11,24(sp)
 6e2:	0100                	addi	s0,sp,128
  char *s;
  int c, i, state;
  state = 0;
  for(i = 0; fmt[i]; i++){
 6e4:	0005c903          	lbu	s2,0(a1)
 6e8:	18090f63          	beqz	s2,886 <vprintf+0x1c0>
 6ec:	8aaa                	mv	s5,a0
 6ee:	8b32                	mv	s6,a2
 6f0:	00158493          	addi	s1,a1,1
  state = 0;
 6f4:	4981                	li	s3,0
      if(c == '%'){
        state = '%';
      } else {
        putc(fd, c);
      }
    } else if(state == '%'){
 6f6:	02500a13          	li	s4,37
      if(c == 'd'){
 6fa:	06400c13          	li	s8,100
        printint(fd, va_arg(ap, int), 10, 1);
      } else if(c == 'l') {
 6fe:	06c00c93          	li	s9,108
        printint(fd, va_arg(ap, uint64), 10, 0);
      } else if(c == 'x') {
 702:	07800d13          	li	s10,120
        printint(fd, va_arg(ap, int), 16, 0);
      } else if(c == 'p') {
 706:	07000d93          	li	s11,112
    putc(fd, digits[x >> (sizeof(uint64) * 8 - 4)]);
 70a:	00000b97          	auipc	s7,0x0
 70e:	3e6b8b93          	addi	s7,s7,998 # af0 <digits>
 712:	a839                	j	730 <vprintf+0x6a>
        putc(fd, c);
 714:	85ca                	mv	a1,s2
 716:	8556                	mv	a0,s5
 718:	00000097          	auipc	ra,0x0
 71c:	ee2080e7          	jalr	-286(ra) # 5fa <putc>
 720:	a019                	j	726 <vprintf+0x60>
    } else if(state == '%'){
 722:	01498f63          	beq	s3,s4,740 <vprintf+0x7a>
  for(i = 0; fmt[i]; i++){
 726:	0485                	addi	s1,s1,1
 728:	fff4c903          	lbu	s2,-1(s1)
 72c:	14090d63          	beqz	s2,886 <vprintf+0x1c0>
    c = fmt[i] & 0xff;
 730:	0009079b          	sext.w	a5,s2
    if(state == 0){
 734:	fe0997e3          	bnez	s3,722 <vprintf+0x5c>
      if(c == '%'){
 738:	fd479ee3          	bne	a5,s4,714 <vprintf+0x4e>
        state = '%';
 73c:	89be                	mv	s3,a5
 73e:	b7e5                	j	726 <vprintf+0x60>
      if(c == 'd'){
 740:	05878063          	beq	a5,s8,780 <vprintf+0xba>
      } else if(c == 'l') {
 744:	05978c63          	beq	a5,s9,79c <vprintf+0xd6>
      } else if(c == 'x') {
 748:	07a78863          	beq	a5,s10,7b8 <vprintf+0xf2>
      } else if(c == 'p') {
 74c:	09b78463          	beq	a5,s11,7d4 <vprintf+0x10e>
        printptr(fd, va_arg(ap, uint64));
      } else if(c == 's'){
 750:	07300713          	li	a4,115
 754:	0ce78663          	beq	a5,a4,820 <vprintf+0x15a>
          s = "(null)";
        while(*s != 0){
          putc(fd, *s);
          s++;
        }
      } else if(c == 'c'){
 758:	06300713          	li	a4,99
 75c:	0ee78e63          	beq	a5,a4,858 <vprintf+0x192>
        putc(fd, va_arg(ap, uint));
      } else if(c == '%'){
 760:	11478863          	beq	a5,s4,870 <vprintf+0x1aa>
        putc(fd, c);
      } else {
        // Unknown % sequence.  Print it to draw attention.
        putc(fd, '%');
 764:	85d2                	mv	a1,s4
 766:	8556                	mv	a0,s5
 768:	00000097          	auipc	ra,0x0
 76c:	e92080e7          	jalr	-366(ra) # 5fa <putc>
        putc(fd, c);
 770:	85ca                	mv	a1,s2
 772:	8556                	mv	a0,s5
 774:	00000097          	auipc	ra,0x0
 778:	e86080e7          	jalr	-378(ra) # 5fa <putc>
      }
      state = 0;
 77c:	4981                	li	s3,0
 77e:	b765                	j	726 <vprintf+0x60>
        printint(fd, va_arg(ap, int), 10, 1);
 780:	008b0913          	addi	s2,s6,8
 784:	4685                	li	a3,1
 786:	4629                	li	a2,10
 788:	000b2583          	lw	a1,0(s6)
 78c:	8556                	mv	a0,s5
 78e:	00000097          	auipc	ra,0x0
 792:	e8e080e7          	jalr	-370(ra) # 61c <printint>
 796:	8b4a                	mv	s6,s2
      state = 0;
 798:	4981                	li	s3,0
 79a:	b771                	j	726 <vprintf+0x60>
        printint(fd, va_arg(ap, uint64), 10, 0);
 79c:	008b0913          	addi	s2,s6,8
 7a0:	4681                	li	a3,0
 7a2:	4629                	li	a2,10
 7a4:	000b2583          	lw	a1,0(s6)
 7a8:	8556                	mv	a0,s5
 7aa:	00000097          	auipc	ra,0x0
 7ae:	e72080e7          	jalr	-398(ra) # 61c <printint>
 7b2:	8b4a                	mv	s6,s2
      state = 0;
 7b4:	4981                	li	s3,0
 7b6:	bf85                	j	726 <vprintf+0x60>
        printint(fd, va_arg(ap, int), 16, 0);
 7b8:	008b0913          	addi	s2,s6,8
 7bc:	4681                	li	a3,0
 7be:	4641                	li	a2,16
 7c0:	000b2583          	lw	a1,0(s6)
 7c4:	8556                	mv	a0,s5
 7c6:	00000097          	auipc	ra,0x0
 7ca:	e56080e7          	jalr	-426(ra) # 61c <printint>
 7ce:	8b4a                	mv	s6,s2
      state = 0;
 7d0:	4981                	li	s3,0
 7d2:	bf91                	j	726 <vprintf+0x60>
        printptr(fd, va_arg(ap, uint64));
 7d4:	008b0793          	addi	a5,s6,8
 7d8:	f8f43423          	sd	a5,-120(s0)
 7dc:	000b3983          	ld	s3,0(s6)
  putc(fd, '0');
 7e0:	03000593          	li	a1,48
 7e4:	8556                	mv	a0,s5
 7e6:	00000097          	auipc	ra,0x0
 7ea:	e14080e7          	jalr	-492(ra) # 5fa <putc>
  putc(fd, 'x');
 7ee:	85ea                	mv	a1,s10
 7f0:	8556                	mv	a0,s5
 7f2:	00000097          	auipc	ra,0x0
 7f6:	e08080e7          	jalr	-504(ra) # 5fa <putc>
 7fa:	4941                	li	s2,16
    putc(fd, digits[x >> (sizeof(uint64) * 8 - 4)]);
 7fc:	03c9d793          	srli	a5,s3,0x3c
 800:	97de                	add	a5,a5,s7
 802:	0007c583          	lbu	a1,0(a5)
 806:	8556                	mv	a0,s5
 808:	00000097          	auipc	ra,0x0
 80c:	df2080e7          	jalr	-526(ra) # 5fa <putc>
  for (i = 0; i < (sizeof(uint64) * 2); i++, x <<= 4)
 810:	0992                	slli	s3,s3,0x4
 812:	397d                	addiw	s2,s2,-1
 814:	fe0914e3          	bnez	s2,7fc <vprintf+0x136>
        printptr(fd, va_arg(ap, uint64));
 818:	f8843b03          	ld	s6,-120(s0)
      state = 0;
 81c:	4981                	li	s3,0
 81e:	b721                	j	726 <vprintf+0x60>
        s = va_arg(ap, char*);
 820:	008b0993          	addi	s3,s6,8
 824:	000b3903          	ld	s2,0(s6)
        if(s == 0)
 828:	02090163          	beqz	s2,84a <vprintf+0x184>
        while(*s != 0){
 82c:	00094583          	lbu	a1,0(s2)
 830:	c9a1                	beqz	a1,880 <vprintf+0x1ba>
          putc(fd, *s);
 832:	8556                	mv	a0,s5
 834:	00000097          	auipc	ra,0x0
 838:	dc6080e7          	jalr	-570(ra) # 5fa <putc>
          s++;
 83c:	0905                	addi	s2,s2,1
        while(*s != 0){
 83e:	00094583          	lbu	a1,0(s2)
 842:	f9e5                	bnez	a1,832 <vprintf+0x16c>
        s = va_arg(ap, char*);
 844:	8b4e                	mv	s6,s3
      state = 0;
 846:	4981                	li	s3,0
 848:	bdf9                	j	726 <vprintf+0x60>
          s = "(null)";
 84a:	00000917          	auipc	s2,0x0
 84e:	29e90913          	addi	s2,s2,670 # ae8 <malloc+0x158>
        while(*s != 0){
 852:	02800593          	li	a1,40
 856:	bff1                	j	832 <vprintf+0x16c>
        putc(fd, va_arg(ap, uint));
 858:	008b0913          	addi	s2,s6,8
 85c:	000b4583          	lbu	a1,0(s6)
 860:	8556                	mv	a0,s5
 862:	00000097          	auipc	ra,0x0
 866:	d98080e7          	jalr	-616(ra) # 5fa <putc>
 86a:	8b4a                	mv	s6,s2
      state = 0;
 86c:	4981                	li	s3,0
 86e:	bd65                	j	726 <vprintf+0x60>
        putc(fd, c);
 870:	85d2                	mv	a1,s4
 872:	8556                	mv	a0,s5
 874:	00000097          	auipc	ra,0x0
 878:	d86080e7          	jalr	-634(ra) # 5fa <putc>
      state = 0;
 87c:	4981                	li	s3,0
 87e:	b565                	j	726 <vprintf+0x60>
        s = va_arg(ap, char*);
 880:	8b4e                	mv	s6,s3
      state = 0;
 882:	4981                	li	s3,0
 884:	b54d                	j	726 <vprintf+0x60>
    }
  }
}
 886:	70e6                	ld	ra,120(sp)
 888:	7446                	ld	s0,112(sp)
 88a:	74a6                	ld	s1,104(sp)
 88c:	7906                	ld	s2,96(sp)
 88e:	69e6                	ld	s3,88(sp)
 890:	6a46                	ld	s4,80(sp)
 892:	6aa6                	ld	s5,72(sp)
 894:	6b06                	ld	s6,64(sp)
 896:	7be2                	ld	s7,56(sp)
 898:	7c42                	ld	s8,48(sp)
 89a:	7ca2                	ld	s9,40(sp)
 89c:	7d02                	ld	s10,32(sp)
 89e:	6de2                	ld	s11,24(sp)
 8a0:	6109                	addi	sp,sp,128
 8a2:	8082                	ret
00000000000008a4 <fprintf>:
void
fprintf(int fd, const char *fmt, ...)
{
 8a4:	715d                	addi	sp,sp,-80
 8a6:	ec06                	sd	ra,24(sp)
 8a8:	e822                	sd	s0,16(sp)
 8aa:	1000                	addi	s0,sp,32
 8ac:	e010                	sd	a2,0(s0)
 8ae:	e414                	sd	a3,8(s0)
 8b0:	e818                	sd	a4,16(s0)
 8b2:	ec1c                	sd	a5,24(s0)
 8b4:	03043023          	sd	a6,32(s0)
 8b8:	03143423          	sd	a7,40(s0)
  va_list ap;
  va_start(ap, fmt);
 8bc:	fe843423          	sd	s0,-24(s0)
  vprintf(fd, fmt, ap);
 8c0:	8622                	mv	a2,s0
 8c2:	00000097          	auipc	ra,0x0
 8c6:	e04080e7          	jalr	-508(ra) # 6c6 <vprintf>
}
 8ca:	60e2                	ld	ra,24(sp)
 8cc:	6442                	ld	s0,16(sp)
 8ce:	6161                	addi	sp,sp,80
 8d0:	8082                	ret
00000000000008d2 <printf>:
void
printf(const char *fmt, ...)
{
 8d2:	711d                	addi	sp,sp,-96
 8d4:	ec06                	sd	ra,24(sp)
 8d6:	e822                	sd	s0,16(sp)
 8d8:	1000                	addi	s0,sp,32
 8da:	e40c                	sd	a1,8(s0)
 8dc:	e810                	sd	a2,16(s0)
 8de:	ec14                	sd	a3,24(s0)
 8e0:	f018                	sd	a4,32(s0)
 8e2:	f41c                	sd	a5,40(s0)
 8e4:	03043823          	sd	a6,48(s0)
 8e8:	03143c23          	sd	a7,56(s0)
  va_list ap;
  va_start(ap, fmt);
 8ec:	00840613          	addi	a2,s0,8
 8f0:	fec43423          	sd	a2,-24(s0)
  vprintf(1, fmt, ap);
 8f4:	85aa                	mv	a1,a0
 8f6:	4505                	li	a0,1
 8f8:	00000097          	auipc	ra,0x0
 8fc:	dce080e7          	jalr	-562(ra) # 6c6 <vprintf>
}
 900:	60e2                	ld	ra,24(sp)
 902:	6442                	ld	s0,16(sp)
 904:	6125                	addi	sp,sp,96
 906:	8082                	ret
0000000000000908 <free>:
static Header base;
static Header *freep;
void
free(void *ap)
{
 908:	1141                	addi	sp,sp,-16
 90a:	e422                	sd	s0,8(sp)
 90c:	0800                	addi	s0,sp,16
  Header *bp, *p;
  bp = (Header*)ap - 1;
 90e:	ff050693          	addi	a3,a0,-16
  for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
 912:	00000797          	auipc	a5,0x0
 916:	1f67b783          	ld	a5,502(a5) # b08 <freep>
 91a:	a805                	j	94a <free+0x42>
    if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
      break;
  if(bp + bp->s.size == p->s.ptr){
    bp->s.size += p->s.ptr->s.size;
 91c:	4618                	lw	a4,8(a2)
 91e:	9db9                	addw	a1,a1,a4
 920:	feb52c23          	sw	a1,-8(a0)
    bp->s.ptr = p->s.ptr->s.ptr;
 924:	6398                	ld	a4,0(a5)
 926:	6318                	ld	a4,0(a4)
 928:	fee53823          	sd	a4,-16(a0)
 92c:	a091                	j	970 <free+0x68>
  } else
    bp->s.ptr = p->s.ptr;
  if(p + p->s.size == bp){
    p->s.size += bp->s.size;
 92e:	ff852703          	lw	a4,-8(a0)
 932:	9e39                	addw	a2,a2,a4
 934:	c790                	sw	a2,8(a5)
    p->s.ptr = bp->s.ptr;
 936:	ff053703          	ld	a4,-16(a0)
 93a:	e398                	sd	a4,0(a5)
 93c:	a099                	j	982 <free+0x7a>
    if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
 93e:	6398                	ld	a4,0(a5)
 940:	00e7e463          	bltu	a5,a4,948 <free+0x40>
 944:	00e6ea63          	bltu	a3,a4,958 <free+0x50>
{
 948:	87ba                	mv	a5,a4
  for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
 94a:	fed7fae3          	bgeu	a5,a3,93e <free+0x36>
 94e:	6398                	ld	a4,0(a5)
 950:	00e6e463          	bltu	a3,a4,958 <free+0x50>
    if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
 954:	fee7eae3          	bltu	a5,a4,948 <free+0x40>
  if(bp + bp->s.size == p->s.ptr){
 958:	ff852583          	lw	a1,-8(a0)
 95c:	6390                	ld	a2,0(a5)
 95e:	02059713          	slli	a4,a1,0x20
 962:	9301                	srli	a4,a4,0x20
 964:	0712                	slli	a4,a4,0x4
 966:	9736                	add	a4,a4,a3
 968:	fae60ae3          	beq	a2,a4,91c <free+0x14>
    bp->s.ptr = p->s.ptr;
 96c:	fec53823          	sd	a2,-16(a0)
  if(p + p->s.size == bp){
 970:	4790                	lw	a2,8(a5)
 972:	02061713          	slli	a4,a2,0x20
 976:	9301                	srli	a4,a4,0x20
 978:	0712                	slli	a4,a4,0x4
 97a:	973e                	add	a4,a4,a5
 97c:	fae689e3          	beq	a3,a4,92e <free+0x26>
  } else
    p->s.ptr = bp;
 980:	e394                	sd	a3,0(a5)
  freep = p;
 982:	00000717          	auipc	a4,0x0
 986:	18f73323          	sd	a5,390(a4) # b08 <freep>
}
 98a:	6422                	ld	s0,8(sp)
 98c:	0141                	addi	sp,sp,16
 98e:	8082                	ret
0000000000000990 <malloc>:
  return freep;
}
void*
malloc(uint nbytes)
{
 990:	7139                	addi	sp,sp,-64
 992:	fc06                	sd	ra,56(sp)
 994:	f822                	sd	s0,48(sp)
 996:	f426                	sd	s1,40(sp)
 998:	f04a                	sd	s2,32(sp)
 99a:	ec4e                	sd	s3,24(sp)
 99c:	e852                	sd	s4,16(sp)
 99e:	e456                	sd	s5,8(sp)
 9a0:	e05a                	sd	s6,0(sp)
 9a2:	0080                	addi	s0,sp,64
  Header *p, *prevp;
  uint nunits;
  nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
 9a4:	02051493          	slli	s1,a0,0x20
 9a8:	9081                	srli	s1,s1,0x20
 9aa:	04bd                	addi	s1,s1,15
 9ac:	8091                	srli	s1,s1,0x4
 9ae:	0014899b          	addiw	s3,s1,1
 9b2:	0485                	addi	s1,s1,1
  if((prevp = freep) == 0){
 9b4:	00000517          	auipc	a0,0x0
 9b8:	15453503          	ld	a0,340(a0) # b08 <freep>
 9bc:	c515                	beqz	a0,9e8 <malloc+0x58>
    base.s.ptr = freep = prevp = &base;
    base.s.size = 0;
  }
  for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
 9be:	611c                	ld	a5,0(a0)
    if(p->s.size >= nunits){
 9c0:	4798                	lw	a4,8(a5)
 9c2:	02977f63          	bgeu	a4,s1,a00 <malloc+0x70>
 9c6:	8a4e                	mv	s4,s3
 9c8:	0009871b          	sext.w	a4,s3
 9cc:	6685                	lui	a3,0x1
 9ce:	00d77363          	bgeu	a4,a3,9d4 <malloc+0x44>
 9d2:	6a05                	lui	s4,0x1
 9d4:	000a0b1b          	sext.w	s6,s4
  p = sbrk(nu * sizeof(Header));
 9d8:	004a1a1b          	slliw	s4,s4,0x4
        p->s.size = nunits;
      }
      freep = prevp;
      return (void*)(p + 1);
    }
    if(p == freep)
 9dc:	00000917          	auipc	s2,0x0
 9e0:	12c90913          	addi	s2,s2,300 # b08 <freep>
  if(p == (char*)-1)
 9e4:	5afd                	li	s5,-1
 9e6:	a88d                	j	a58 <malloc+0xc8>
    base.s.ptr = freep = prevp = &base;
 9e8:	00000797          	auipc	a5,0x0
 9ec:	13878793          	addi	a5,a5,312 # b20 <base>
 9f0:	00000717          	auipc	a4,0x0
 9f4:	10f73c23          	sd	a5,280(a4) # b08 <freep>
 9f8:	e39c                	sd	a5,0(a5)
    base.s.size = 0;
 9fa:	0007a423          	sw	zero,8(a5)
    if(p->s.size >= nunits){
 9fe:	b7e1                	j	9c6 <malloc+0x36>
      if(p->s.size == nunits)
 a00:	02e48b63          	beq	s1,a4,a36 <malloc+0xa6>
        p->s.size -= nunits;
 a04:	4137073b          	subw	a4,a4,s3
 a08:	c798                	sw	a4,8(a5)
        p += p->s.size;
 a0a:	1702                	slli	a4,a4,0x20
 a0c:	9301                	srli	a4,a4,0x20
 a0e:	0712                	slli	a4,a4,0x4
 a10:	97ba                	add	a5,a5,a4
        p->s.size = nunits;
 a12:	0137a423          	sw	s3,8(a5)
      freep = prevp;
 a16:	00000717          	auipc	a4,0x0
 a1a:	0ea73923          	sd	a0,242(a4) # b08 <freep>
      return (void*)(p + 1);
 a1e:	01078513          	addi	a0,a5,16
      if((p = morecore(nunits)) == 0)
        return 0;
  }
}
 a22:	70e2                	ld	ra,56(sp)
 a24:	7442                	ld	s0,48(sp)
 a26:	74a2                	ld	s1,40(sp)
 a28:	7902                	ld	s2,32(sp)
 a2a:	69e2                	ld	s3,24(sp)
 a2c:	6a42                	ld	s4,16(sp)
 a2e:	6aa2                	ld	s5,8(sp)
 a30:	6b02                	ld	s6,0(sp)
 a32:	6121                	addi	sp,sp,64
 a34:	8082                	ret
        prevp->s.ptr = p->s.ptr;
 a36:	6398                	ld	a4,0(a5)
 a38:	e118                	sd	a4,0(a0)
 a3a:	bff1                	j	a16 <malloc+0x86>
  hp->s.size = nu;
 a3c:	01652423          	sw	s6,8(a0)
  free((void*)(hp + 1));
 a40:	0541                	addi	a0,a0,16
 a42:	00000097          	auipc	ra,0x0
 a46:	ec6080e7          	jalr	-314(ra) # 908 <free>
  return freep;
 a4a:	00093503          	ld	a0,0(s2)
      if((p = morecore(nunits)) == 0)
 a4e:	d971                	beqz	a0,a22 <malloc+0x92>
  for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
 a50:	611c                	ld	a5,0(a0)
    if(p->s.size >= nunits){
 a52:	4798                	lw	a4,8(a5)
 a54:	fa9776e3          	bgeu	a4,s1,a00 <malloc+0x70>
    if(p == freep)
 a58:	00093703          	ld	a4,0(s2)
 a5c:	853e                	mv	a0,a5
 a5e:	fef719e3          	bne	a4,a5,a50 <malloc+0xc0>
  p = sbrk(nu * sizeof(Header));
 a62:	8552                	mv	a0,s4
 a64:	00000097          	auipc	ra,0x0
 a68:	b6e080e7          	jalr	-1170(ra) # 5d2 <sbrk>
  if(p == (char*)-1)
 a6c:	fd5518e3          	bne	a0,s5,a3c <malloc+0xac>
        return 0;
 a70:	4501                	li	a0,0
 a72:	bf45                	j	a22 <malloc+0x92>
 
 | 
					
	
; int wv_priority_queue_empty(wv_priority_queue_t *q)
SECTION code_adt_wv_priority_queue
PUBLIC _wv_priority_queue_empty
EXTERN _wa_priority_queue_empty
defc _wv_priority_queue_empty = _wa_priority_queue_empty
 
 | 
					
	; I/O with correct sun out
.MODEL SMALL
.STACK 100H
.DATA
    A DB ?
    B DB ?
.CODE
    MAIN PROC
        
        MOV AX, @DATA
        MOV DS, AX
        
        
        MOV AH, 1
        INT 21H
        MOV A, AL
        SUB A, 48
        
        INT 21H
        MOV B, AL
        SUB B, 48
        
        MOV BH, A
        ADD BH, B
        ADD BH, 48
        
        MOV AH, 2
        MOV DL, 0AH
        INT 21H
        MOV DL, 0DH
        INT 21H
        MOV DL, BH
        INT 21H
        
        MAIN ENDP
    END MAIN
 
 | 
					
	;**	MSCTRLC.ASM - ^C and error handler for MSDOS
;
;
;
	.xlist
	.xcref
	include version.inc
	include mssw.asm
	.cref
	.list
	TITLE	Control C detection, Hard error and EXIT routines
	NAME	IBMCTRLC
;
;	Microsoft Confidential
;	Copyright (C) Microsoft Corporation 1991
;	All Rights Reserved.
;
;**	Low level routines for detecting special characters on CON input,
;	the ^C exit/int code, the Hard error INT 24 code, the
;	process termination code, and the INT 0 divide overflow handler.
;
;	FATAL
;	FATAL1
;	reset_environment
;	DSKSTATCHK
;	SPOOLINT
;	STATCHK
;	CNTCHAND
;	DIVOV
;	CHARHARD
;	HardErr
;
;	Revision history:
;
;	    AN000	version 4.0   Jan 1988
;	    A002	PTM    -- dir >lpt3 hangs
;	    A003	PTM 3957- fake version for IBMCAHE.COM
;
; 	M011: NEC's 8086 clone chip uses Intel's undocumented bit number in
;	      flags register. In order to return to user normally DOS used to
;	      move F202 into flags, which sets bit number 1 in flags uncondit-
;	      ionally. Now it is modified to maintain the state of bit 1.
;
; 	M024: suppressed fail and ignore options if not in the middle of int 
;	      24 and if Ctrl P or ctrl printscrn is pressed in routine 
;	      charhard.
;
	.xlist
	include dosseg.inc
	.xcref
	INCLUDE DOSSYM.INC
	INCLUDE DEVSYM.INC
	include mult.inc
	include pdb.inc
	include dpb.inc
	include exe.inc
	include sf.inc
	include vector.inc
	include filemode.inc
	include mi.inc
	include syscall.inc
	include bugtyp.inc
	.cref
	.list
	I_need	SFN,WORD
	I_NEED	pJFN,DWORD
	i_need	DevIOBuf,BYTE
	i_need	DidCTRLC,BYTE
	i_need	INDOS,BYTE
	i_need	DSKSTCOM,BYTE
	i_need	DSKSTCALL,BYTE
	i_need	DSKSTST,WORD
	i_need	BCON,DWORD
	i_need	DSKCHRET,BYTE
	i_need	DSKSTCNT,WORD
	i_need	IDLEINT,BYTE
	i_need	CONSWAP,BYTE
	i_need	user_SS,WORD
	i_need	user_SP,WORD
	i_need	User_In_AX,WORD
	i_need	ERRORMODE,BYTE
	i_need	ConC_spsave,WORD
	i_need	Exit_type,BYTE
	i_need	PFLAG,BYTE
	i_need	ExitHold,DWORD
	i_need	WPErr,BYTE
	i_need	ReadOp,BYTE
	i_need	CONTSTK,WORD
	i_need	Exit_Code,WORD
	i_need	CurrentPDB,WORD
	i_need	DIVMES,BYTE
	i_need	ALLOWED,BYTE
	i_need	FAILERR,BYTE
	i_need	EXTERR,WORD
	i_need	ERR_TABLE_24,BYTE
	I_need	ErrMap24,BYTE
	I_need	ErrMap24End,BYTE
	I_need	fAborting,BYTE
	I_need	AUXStack,BYTE
	I_need	SCAN_FLAG,BYTE
	I_need	EXTOPEN_ON,BYTE 	      ;AN000; DOS 4.0
	I_need	InterCon,BYTE		      ;AN000; DOS 4.0
	I_need	DOS34_FLAG,WORD 	      ;AN000; DOS 4.0
	I_need	Special_Version,WORD	      ;AN007; DOS 4.0
	I_need	TEMPSEG, WORD
	I_need	DosHasHMA,byte			; M021
ifndef ROMDOS
DOSDATA	SEGMENT
	extrn	LowInt23:near
	extrn	LowInt24:near
	extrn	LowInt28:near
DOSDATA	ENDS
endif ; ROMDOS
DOSCODE SEGMENT
	ASSUME	SS:DOSDATA,CS:DOSCODE
	extrn	DivMesLen:WORD
	allow_getdseg
ifndef ROMDOS
		public	LowInt23Addr		
LowInt23Addr	LABEL	DWORD
	DW	offset DOSDATA:LowInt23, 0
		public	LowInt24Addr
LowInt24Addr	LABEL	DWORD
	DW	offset DOSDATA:LowInt24, 0
		public	LowInt28Addr
LowInt28Addr	LABEL	DWORD
	DW	offset DOSDATA:LowInt28, 0
endif ; ROMDOS
Break	<Checks for ^C in CON I/O>
;---------------------------------------------------------------------------
;
; Procedure Name : DSKSTATCHK
;
; Check for ^C if only one level in
;
;---------------------------------------------------------------------------
procedure   DSKSTATCHK,NEAR	
	CMP	BYTE PTR InDos,1	; SS override
	retnz				; Do NOTHING
	DOSAssume   <SS>,"DskStatChk"
	PUSH	CX
	PUSH	ES
	PUSH	BX
	PUSH	DS
	PUSH	SI
	MOV	BX, SS			; SS is DOSDATA. ES:BX must be set up
	MOV	ES, BX			; for deviocall2
	assume	es:nothing		
	MOV	DS, BX
	MOV	BYTE PTR DskStCom,DEVRDND
	MOV	BYTE PTR DskStCall,DRDNDHL
	MOV	DskStSt,0
 IFDEF  DBCS				;AN000;
	MOV	AL, InterCon		;AN000; get type of status read 2/13/KK
	MOV	BYTE PTR DskChRet,AL	;AN000; load interim flag into packet
 ENDIF					;AN000;
					; DSKSTCALL is in DOSDATA
	MOV	BX,OFFSET DOSDATA:DSKSTCALL
	LDS	SI,BCon
ASSUME	DS:NOTHING
	invoke	DEVIOCALL2
	TESTB	DSKSTST,STBUI		; SS override
	JZ	GotCh			; No characters available
	XOR	AL,AL			; Set zero
RET36:
	POP	SI
	POP	DS
	POP	BX
	POP	ES
	POP	CX
	return
GotCh:
	MOV	AL,BYTE PTR DskChRet	; SS override
DSK1:
	CMP	AL,"C"-"@"
	JNZ	RET36
					; SS used for next 5 instructions 
	MOV	BYTE PTR DskStCom,DEVRD
	MOV	BYTE PTR DskStCall,DRDWRHL
	MOV	BYTE PTR DskChRet,CL
	MOV	DskStSt,0
	MOV	DskStCnt,1
	invoke	DEVIOCALL2		; Eat the ^C
	POP	SI
	POP	DS
	POP	BX			; Clean stack
	POP	ES
	POP	CX
	JMP	CNTCHAND
NOSTOP:
	CMP	AL,"P"-"@"
	JNZ	check_next
				    	; SS override
	CMP	BYTE PTR Scan_Flag,0	; ALT_Q ?
	JZ	INCHKJ			; no
	return
check_next:
	IF	NOT TOGLPRN
	CMP	AL,"N"-"@"
	JZ	INCHKJ
	ENDIF
	CMP	AL,"C"-"@"
	JZ	INCHKJ
check_end:
	return
INCHKJ:
	JMP	INCHK
EndProc DSKSTATCHK
;----------------------------------------------------------------------------
;
; Procedure Name : SpoolInt
;
; SpoolInt - signal processes that the DOS is truly idle.  We are allowed to
; do this ONLY if we are working on a 1-12 system call AND if we are not in
; the middle of an INT 24.
;
;----------------------------------------------------------------------------
procedure   SPOOLINT,NEAR
	PUSHF
	cmp	IdleInt,0		; SS override for IdleInt & ErrorMode
	je	POPFRet
	cmp	ErrorMode,0
	jnz	POPFRet
	
	;
	; Note that we are going to allow an external program to issue system 
	; calls at this time.  We MUST preserve IdleInt across this.
	;
	PUSH	WORD PTR IdleInt
ifndef ROMDOS 
	cmp	[DosHasHMA], 0		; Q: is dos running in HMA (M021)
	jne	do_low_int28		; Y: the int must be done from low mem
	INT	int_spooler		; N: Execute user int 28 handler
	jmp	short spool_ret_addr
do_low_int28:
	call	dword ptr LowInt28Addr
spool_ret_addr:
else
	INT	int_spooler		; if in ROM just do int 
endif ; ROMDOS
	POP	WORD PTR IdleInt
POPFRET:
	POPF
	return
EndProc SPOOLINT
;----------------------------------------------------------------------------
;
; Procedure Name : STATCHK
;
;----------------------------------------------------------------------------
	procedure   STATCHK,NEAR
	invoke	DSKSTATCHK		; Allows ^C to be detected under
					; input redirection
	PUSH	BX
	XOR	BX,BX
	invoke	GET_IO_SFT
	POP	BX
	retc
	MOV	AH,1
	invoke	IOFUNC
	JZ	SPOOLINT
	CMP	AL,"S"-"@"
	JNZ	NOSTOP
					; SS override
	CMP	BYTE PTR Scan_Flag,0	; AN000; ALT_R ?
	JNZ	check_end		; AN000; yes
	XOR	AH,AH
	invoke	IOFUNC			; Eat Cntrl-S
	JMP	SHORT PAUSOSTRT
PRINTOFF:
PRINTON:
	NOT	BYTE PTR PFlag		; SS override
	PUSH	BX
	MOV	BX,4
	invoke	GET_IO_SFT
	POP	BX
	retc
	PUSH	ES
	PUSH	DI
	PUSH	DS
	POP	ES
	MOV	DI,SI			; ES:DI -> SFT
	TESTB	ES:[DI].SF_FLAGS,sf_net_spool
	JZ	NORM_PR 		; Not redirected, echo is OK
	Callinstall NetSpoolEchoCheck,MultNet,38,<AX>,<AX> ; See if allowed
	JNC	NORM_PR 		; Echo is OK
					; SS override
	MOV	BYTE PTR PFlag,0	; If not allowed, disable echo
	Callinstall NetSpoolClose,MultNet,36,<AX>,<AX> ; and close
	JMP	SHORT RETP6
NORM_PR:
	CMP	BYTE PTR PFlag,0	; SS override
	JNZ	PRNOPN
	invoke	DEV_CLOSE_SFT
	JMP	SHORT RETP6
PRNOPN:
	invoke	DEV_OPEN_SFT
RETP6:
	POP	DI
	POP	ES
	return
PAUSOLP:
	CALL	SPOOLINT
PAUSOSTRT:
	MOV	AH,1
	invoke	IOFUNC
	JZ	PAUSOLP
INCHK:
	PUSH	BX
	XOR	BX,BX
	invoke	GET_IO_SFT
	POP	BX
	retc
	XOR	AH,AH
	invoke	IOFUNC
	CMP	AL,"P"-"@"
	;;;;;  7/14/86	ALT_Q key fix
	JZ	PRINTON			; no! must be CTRL_P
NOPRINT:
	;;;;;  7/14/86	ALT_Q key fix
	IF	NOT TOGLPRN
	CMP	AL,"N"-"@"
	JZ	PRINTOFF
	ENDIF
	CMP	AL,"C"-"@"
	retnz
EndProc STATCHK
;	!! NOTE: FALL THROUGH !!
;---------------------------------------------------------------------------
;
; Procedure Name : CNTHAND ( CTRLC_C HANDLER )
;
; "^C" and CR/LF is printed.  Then the user registers are restored and the
; user CTRL-C handler is executed.  At this point the top of the stack has 1)
; the interrupt return address should the user CTRL-C handler wish to allow
; processing to continue; 2) the original interrupt return address to the code
; that performed the function call in the first place.	If the user CTRL-C
; handler wishes to continue, it must leave all registers unchanged and RET
; (not IRET) with carry CLEAR.	If carry is SET then an terminate system call
; is simulated.
;
;---------------------------------------------------------------------------
procedure   CNTCHAND,NEAR
					; SS override
					; AN002; from RAWOUT
	TESTB	Dos34_Flag,CTRL_BREAK_FLAG  
	JNZ	around_deadlock 	; AN002;
	MOV	AL,3			; Display "^C"
	invoke	BUFOUT
	invoke	CRLF
around_deadlock:			;AN002;
	Context DS			; SS is DOSDATA
	CMP	BYTE PTR ConSwap,0
	JZ	NOSWAP
	invoke	SWAPBACK
NOSWAP:
	CLI				; Prepare to play with stack
	MOV	SS,User_SS		; User stack now restored
ASSUME	SS:NOTHING
	MOV	SP,User_SP
					; use macro for restore_world
	restore_world			; User registers now restored
	;
	; CS was used to address these variables. We have to use DOSDATA 
	;
	push	ds
	getdseg	<ds>			; ds -> dosdata
	MOV	BYTE PTR InDos,0	; Go to known state
	MOV	BYTE PTR ErrorMode,0
	MOV	ConC_Spsave,SP		; save his SP
	; User SP has changed because of push. Adjust for it
	add	ConC_Spsave,2		
ifndef ROMDOS
	cmp	[DosHasHMA], 0		; Q: is dos running in HMA (M021)
 	pop	ds	;restore ds
	assume	ds:NOTHING
	jne	do_low_int23		; Y: the int must be done from low mem
	CLC				
	INT	int_ctrl_c		; N: Execute user Ctrl-C handler
	jmp	short ctrlc_ret_addr
do_low_int23:
	clc
	call	dword ptr LowInt23Addr
ctrlc_ret_addr:
else
 	pop	ds	;restore ds
	assume	ds:NOTHING
	CLC
	INT	int_ctrl_c		; Execute user Ctrl-C handler
endif ; ROMDOS
;
; The user has returned to us.	The circumstances we allow are:
;
;   IRET	We retry the operation by redispatching the system call
;   CLC/RETF	POP the stack and retry
;   ... 	Exit the current process with ^C exit
;
; User's may RETURN to us and leave interrupts on.  Turn 'em off just to be
; sure
;
	CLI
	;
	; We have to use DOSDATA for these variables. Previously CS was used 
	;
	push	ax
	mov	ax, ds
	getdseg	<ds>			; ds -> dosdata
	mov	TempSeg, ax
	pop	ax
	MOV	User_In_AX,ax		; save the AX
	PUSHF				; and the flags (maybe new call)
	POP	AX
	;
	; See if the input stack is identical to the output stack
	;
	CMP	SP,ConC_Spsave
	JNZ	ctrlc_try_new		; current SP not the same as saved SP
	;
	; Repeat the operation by redispatching the system call.
	;
ctrlc_repeat:
	MOV	AX,User_In_AX		; ds still points to dosdata 
					
	mov	ds, TempSeg		; restore ds and original sp 
	assume	ds:NOTHING
	transfer    COMMAND
	;
	; The current SP is NOT the same as the input SP.  Presume that he 
	; RETF'd leaving some flags on the stack and examine the input
	;
ctrlc_try_new:
	ADD	SP,2			; pop those flags
	TESTB	AX,f_carry		; did he return with carry?
	JZ	Ctrlc_Repeat		; no carry set, just retry
					
	assume	ds:DOSDATA		;restore ds 
	mov	ds, TempSeg
	assume	ds:NOTHING
	;
	; Well...  time to abort the user.  Signal a ^C exit and use the EXIT 
	; system call..
	;
ctrlc_abort:
	MOV	AX,(EXIT SHL 8) + 0
	push	ds
	getdseg	<ds>			; ds -> dosdata
	
	MOV	DidCTRLC,-1
	pop	ds
	assume	ds:NOTHING
	transfer    COMMAND		; give up by faking $EXIT
EndProc CNTCHAND
Break	<DIVISION OVERFLOW INTERRUPT>
;----------------------------------------------------------------------------
;
; Procedure Name : DIVOV
;
; Default handler for division overflow trap
;
;----------------------------------------------------------------------------
procedure   DIVOV,NEAR
	ASSUME	SS:NOTHING
					; DIVMES is in DOSCODE
	MOV	SI,OFFSET DOSCODE:DIVMES
	MOV	BX,DivMesLen
					; Point SS to dosdata 
	getdseg	<ss>			; we are in an ISR flag is CLI
					; AUXSTACK is in DOSDATA
					; Enough stack for interrupts
	MOV	SP,OFFSET DOSDATA:AUXSTACK 
	CALL	OutMes
	JMP	ctrlc_abort		; Use Ctrl-C abort on divide overflow
EndProc DIVOV
;---------------------------------------------------------------------------
;
; Procedure Name : OutMes
;
;
; OutMes: perform message output
; Inputs:   SS:SI points to message
;	    BX has message length
; Outputs:  message to BCON
;
;Actually, cs:si points to the message now. The segment address is filled in
;at init. time ([dskchret+2]). This will be temporarily changed to DOSCODE. 
;NB. This procedure is called only from DIVOV. -SR
;
;---------------------------------------------------------------------------
procedure   OutMes,NEAR
	Context ES			; get ES addressability
	Context DS			; get DS addressability
	MOV	BYTE PTR DskStCom,DevWrt
	MOV	BYTE PTR DskStCall,DRdWrHL
	MOV	DskStSt,0
	MOV	DskStCnt,BX
					; DSKSTCALL is in DOSDATA
	MOV	BX,OFFSET DOSDATA:DskStCall
	MOV	WORD PTR [DskChRet+1],SI; transfer address (need an EQU)
					; CS is used for string, fill in 
					; segment address 
	MOV	WORD PTR [DskChRet+3],CS
	LDS	SI,BCon
ASSUME	DS:NOTHING
	invoke	DEVIOCALL2
					; ES still points to DOSDATA. ES is
					; not destroyed by deviocall2. So use
					; ES override.
					; DEVIOBUF is in DOSDATA
	MOV	WORD PTR ES:[DskChRet+1],OFFSET DOSDATA:DevIOBuf
	MOV	ES:[DskStCnt],1
	return
EndProc OutMes
Break	<CHARHRD,HARDERR,ERROR -- HANDLE DISK ERRORS AND RETURN TO USER>
;---------------------------------------------------------------------------
;
; Procedure Name : CHARHARD
;
;
; Character device error handler
; Same function as HARDERR
;
;---------------------------------------------------------------------------
procedure   CHARHARD,NEAR
	ASSUME	SS:DOSDATA
		   			; M024 - start
	cmp	byte ptr [ErrorMode], 0	; Q: are we in the middle of int 24
	jne	@f			; Y: allow fail
	OR	AH, allowed_RETRY	; assume ctrl p
	test	byte ptr [PFLAG], -1	; Q: has ctrl p been pressed
	jnz	ctrlp			; Y: 
@@:					; M024 - end
	OR	AH,allowed_FAIL + allowed_IGNORE + allowed_RETRY
ctrlp:					; M024
					; SS override for Allowed and EXITHOLD
	MOV	Allowed,AH
	MOV	WORD PTR EXITHOLD+2,ES
	MOV	WORD PTR EXITHOLD,BP
	PUSH	SI
	AND	DI,STECODE
	MOV	BP,DS			; Device pointer is BP:SI
	CALL	FATALC
	POP	SI
	return
EndProc CHARHARD
;---------------------------------------------------------------------------
;
; Procedure Name : HardErr
;
; Hard disk error handler. Entry conditions:
;	DS:BX = Original disk transfer address
;	DX = Original logical sector number
;	CX = Number of sectors to go (first one gave the error)
;	AX = Hardware error code
;	DI = Original sector transfer count	
;	ES:BP = Base of drive parameters
;	[READOP] = 0 for read, 1 for write
;	Allowed Set with allowed responses to this error (other bits MUST BE 0)
; Output:
;	[FAILERR] will be set if user responded FAIL
;
;--------------------------------------------------------------------------
procedure   HardErr,NEAR
	XCHG	AX,DI			; Error code in DI, count in AX
	AND	DI,STECODE		; And off status bits
	CMP	DI,error_I24_write_protect ; Write Protect Error?
	JNZ	NOSETWRPERR
	PUSH	AX
	MOV	AL,ES:[BP.dpb_drive]
					; SS override
	MOV	BYTE PTR WPERR,AL	; Flag drive with WP error
	POP	AX
NOSETWRPERR:
	SUB	AX,CX			; Number of sectors successfully transferred
	ADD	DX,AX			; First sector number to retry
	PUSH	DX
	MUL	ES:[BP.dpb_sector_size] ; Number of bytes transferred
	POP	DX
	ADD	BX,AX			; First address for retry
	XOR	AH,AH			; Flag disk section in error
	CMP	DX,ES:[BP.dpb_first_FAT]; In reserved area?
	JB	ERRINT
	INC	AH			; Flag for FAT
					; In FAT?
	CMP	DX,ES:[BP.dpb_dir_sector]   
	JAE	TESTDIR 		; No
	MOV	ES:[BP.dpb_free_cnt],-1 ; Err in FAT must force recomp of freespace
	JMP	SHORT ERRINT
TESTDIR:
	INC	AH
					; In directory?
	CMP	DX,ES:[BP.dpb_first_sector] 
	JB	ERRINT
	INC	AH			; Must be in data area
ERRINT:
	SHL	AH,1			; Make room for read/write bit
					; SS override
	OR	AH,BYTE PTR READOP	; Set bit 0
	;
	; If we have a write protect error when writing on a critical area on ,
	; disk, do not allow a retry as this may write out garbage on any 
	; subsequent disk.
	;
	;test	ah,1
	;jz	Not_Crit
	;cmp	ah,5
	;ja	Not_Crit
	;and	Allowed,NOT Allowed_RETRY
Not_Crit:
					; SS override for allowed and EXITHOLD
	OR	AH,Allowed		; Set the allowed_ bits
	entry	FATAL
	MOV	AL,ES:[BP.dpb_drive]	; Get drive number
	entry	FATAL1
	MOV	WORD PTR EXITHOLD+2,ES
	MOV	WORD PTR EXITHOLD,BP	; The only things we preserve
	LES	SI,ES:[BP.dpb_driver_addr]
	MOV	BP,ES			; BP:SI points to the device involved
	;
	; DI has the INT-24-style extended error.  We now map the error code 
	; for this into the normalized get extended error set by using the 
	; ErrMap24 table as a translate table.  Note that we translate ONLY 
	; the device returned codes and leave all others beyond the look up 
	; table alone.
	;
FATALC:
	call	SET_I24_EXTENDED_ERROR
	CMP	DI,error_I24_gen_failure
	JBE	GOT_RIGHT_CODE		; Error codes above gen_failure get
	MOV	DI,error_I24_gen_failure; mapped to gen_failure. Real codes
					;  Only come via GetExtendedError
;**
;
; Entry point used by REDIRector on Network I 24 errors.
;
;	ASSUME	DS:NOTHING,ES:NOTHING,SS:DOSDATA
;
; ALL I 24 regs set up. ALL Extended error info SET. ALLOWED Set.
;     EXITHOLD set for restore of ES:BP.
;
	entry	NET_I24_ENTRY
GOT_RIGHT_CODE:
					; SS override
	CMP	BYTE PTR ErrorMode,0	; No INT 24s if already INT 24
	JZ	NoSetFail
	MOV	AL,3
IF	DEBUG
	JMP	FailRet
ELSE
	JMP	short FailRet
ENDIF
NoSetFail:
					; SS override
	MOV	CONTSTK,SP
	Context ES
	fmt TypINT24,LevLog,<"INT 24: AX = $x DI = $x\n">,<AX,DI>
	;
	; Wango!!!  We may need to free some user state info...  In 
	; particular, we may have locked down a JFN for a user and he may 
	; NEVER return to us. Thus,we need to free it here and then 
	; reallocate it when we come back.
	;
					; SS override for SFN and pJFN
	CMP	SFN,-1
	JZ	NoFree
	SAVE	<DS,SI>
	LDS	SI,pJFN
	MOV	BYTE PTR [SI],0FFH
	RESTORE <SI,DS>
NoFree:
	CLI				; Prepare to play with stack
					; SS override for ERRORMODE, INDOS, 
					; DOS34_FLAG, EXTOPEN_ON
	INC	BYTE PTR ErrorMode	; Flag INT 24 in progress
	DEC	BYTE PTR InDos		; INT 24 handler might not return
	;; Extended Open hooks
					; AN000;IFS.I24 error disabled	      ;AN000;
	TESTB	EXTOPEN_ON,EXT_OPEN_I24_OFF 
	JZ	i24yes			; AN000;IFS.no			      ;AN000;
faili24:				; AN000;
	MOV	AL,3			; AN000;IFS.fake fail		      ;AN000;
	JMP	short passi24 		; AN000;IFS.exit			      ;AN000;
i24yes: 				; AN000;
	;; Extended Open hooks
	MOV	SS,User_SS
ASSUME	SS:NOTHING
	MOV	SP,ES:User_SP		; User stack pointer restored
ifndef ROMDOS
	cmp	[DosHasHMA], 0		; Q: is dos running in HMA (M021)
	jne	do_low_int24		; Y: the int must be done from low mem
	INT	int_fatal_abort 	; Fatal error interrupt vector, 
					; must preserve ES
	jmp	short criterr_ret_addr
do_low_int24:
	call	dword ptr LowInt24Addr
criterr_ret_addr:
else
	INT	int_fatal_abort 	; Fatal error interrupt vector, must preserve ES
endif ; ROMDOS
	MOV	ES:User_SP,SP		; restore our stack
	MOV	ES:User_SS,SS
	MOV	BP,ES
	MOV	SS,BP
ASSUME	SS:DOSDATA
passi24:				; AN000;
					; SS override for nect 3 instructions.
	MOV	SP,CONTSTK
	INC	BYTE PTR InDos		; Back in the DOS
	MOV	BYTE PTR ErrorMode,0	; Back from INT 24
	STI
;;	MOV	ACT_PAGE,-1		; LB. invalidate DOS active page 	;AN000;
;;	invoke	SAVE_MAP		; LB. save user's EMS map                ;AN000;
	fmt TypINT24,LevLog,<"INT 24: User reply = $x\n">,<AX>
FAILRET:
					
	LES	BP,EXITHOLD		; SS override
ASSUME	ES:NOTHING
	;
	; Triage the user's reply.
	;
	CMP	AL,1
	JB	CheckIgnore		; 0 => ignore
	JZ	CheckRetry		; 1 => retry
	CMP	AL,3			; 3 => fail
	JNZ	DoAbort 		; 2, invalid => abort
	;
	; The reply was fail.  See if we are allowed to fail.
	;
					; SS override for ALLOWED, EXTOPEN_ON, 
					; ALLOWED, FAILERR, WpErr, SFN, pJFN
	TESTB	Allowed,allowed_FAIL	; Can we?
	JZ	DoAbort 		; No, do abort
DoFail:
	MOV	AL,3			; just in case...
					; AN000;EO. I24 error disabled
	TESTB	EXTOPEN_ON,EXT_OPEN_I24_OFF 
	JNZ	cleanup 		; AN000;EO. no
	INC	FAILERR			; Tell everybody
CleanUp:
	MOV	WpErr,-1
	CMP	SFN,-1
	retz
	SAVE	<DS,SI,AX>
	MOV	AX,SFN
	LDS	SI,pJFN
	MOV	[SI],AL
	RESTORE <AX,SI,DS>
	return
	;
	; The reply was IGNORE.  See if we are allowed to ignore.
	;
CheckIgnore:
	TESTB	Allowed,allowed_IGNORE 	; Can we?
	JZ	DoFail			; No, do fail
	JMP	CleanUp
	;	
	; The reply was RETRY.	See if we are allowed to retry.
	;
CheckRetry:
	TESTB	Allowed,allowed_RETRY 	; Can we?
	JZ	DoFail			; No, do fail
	JMP	CleanUp
	;
	; The reply was ABORT.
	;
DoAbort:
	Context DS
	CMP	BYTE PTR ConSwap,0
	JZ	NOSWAP2
	invoke	SWAPBACK
NOSWAP2:
	;	
	; See if we are to truly abort.  If we are in the process of aborting, 
	; turn this abort into a fail.
	;
	cmp	fAborting,0
	JNZ	DoFail
	;
	; Set return code
	;
	MOV	BYTE PTR [exit_Type],Exit_hard_error
	XOR	AL,AL
	;
	; we are truly aborting the process.  Go restore information from 
	; the PDB as necessary.
	;
	Transfer    exit_inner
;**
;
; reset_environment checks the DS value against the CurrentPDB.  If they are
; different, then an old-style return is performed.  If they are the same,
; then we release jfns and restore to parent.  We still use the PDB at DS:0 as
; the source of the terminate addresses.
;
; Some subtlety:  We are about to issue a bunch of calls that *may* generate
; INT 24s.  We *cannot* allow the user to restart the abort process; we may
; end up aborting the wrong process or turn a terminate/stay/resident into a
; normal abort and leave interrupt handlers around.  What we do is to set a
; flag that will indicate that if any abort code is seen, we just continue the
; operation.  In essence, we dis-allow the abort response.
;
; output:   none.
;
	entry	reset_environment
	ASSUME	DS:NOTHING,ES:NOTHING
;***	invoke	Reset_Version		; AN007;MS. reset version number
	PUSH	DS			; save PDB of process
	;
	; There are no critical sections in force.  Although we may enter 
	; here with critical sections locked down, they are no longer 
	; relevant. We may safely free all allocated resources.
	;
	MOV	AH,82h
	INT	int_IBM
					; SS override
	MOV	fAborting,-1		; signal abort in progress
					; DOS 4.00 doesn't need it
	CallInstall NetResetEnvironment, multNet, 34  
					; Allow REDIR to clear some stuff
					; On process exit.
	MOV	AL,int_Terminate
	invoke	$Get_interrupt_vector	; and who to go to
	POP	CX			; get ThisPDB
	SAVE	<ES,BX> 		; save return address
	MOV	BX,[CurrentPDB] 	; get currentPDB
	MOV	DS,BX
	MOV	AX,DS:[PDB_Parent_PID]	; get parentPDB
	;
	; AX = parentPDB, BX = CurrentPDB, CX = ThisPDB
	; Only free handles if AX <> BX and BX = CX and [exit_code].upper 
	; is not Exit_keep_process
	;
	
	CMP	AX,BX
	JZ	reset_return		; parentPDB = CurrentPDB
	CMP	BX,CX
	JNZ	reset_return		; CurrentPDB <> ThisPDB
	PUSH	AX			; save parent
					; SS override
	CMP	BYTE PTR [exit_type],Exit_keep_process
	JZ	reset_to_parent 	; keeping this process
	;
	; We are truly removing a process.  Free all allocation blocks 
	; belonging to this PDB
	;
	invoke	arena_free_process
	;
	; Kill off remainder of this process.  Close file handles and signal 
	; to relevant network folks that this process is dead.  Remember that 
	; CurrentPDB is STILL the current process!
	;
	invoke	DOS_ABORT
reset_to_parent:
					; SS override
	POP	[CurrentPDB]		; set up process as parent
reset_return:				; come here for normal return
	Context	DS			; DS is used to refer to DOSDATA  
	MOV	AL,-1
	;
	; make sure that everything is clean In this case ignore any errors, 
	; we cannot "FAIL" the abort, the program being aborted is dead.
	;
	EnterCrit   critDisk
	invoke	FLUSHBUF
	LeaveCrit   critDisk
	;
	; Decrement open ref. count if we had done a virtual open earlier.
	;
	invoke	CHECK_VIRT_OPEN
	CLI
	MOV	BYTE PTR InDos,0	; Go to known state
	MOV	BYTE PTR [WPERR],-1	; Forget about WP error
	MOV	fAborting,0		; let aborts occur
	POP	WORD PTR ExitHold
	POP	WORD PTR ExitHold+2
	;
	; Snake into multitasking... Get stack from CurrentPDB person
	;
	MOV	DS,[CurrentPDB]
	ASSUME	DS:NOTHING
	MOV	SS,WORD PTR DS:[PDB_user_stack+2]
	MOV	SP,WORD PTR DS:[PDB_user_stack]
	ASSUME	SS:NOTHING
	restore_world			; use macro
	ASSUME	ES:NOTHING
	push	ax			; set up ds, but save ds in TEMPSEG 
	mov	ax, ds			; and not on stack.
	getdseg <ds>			; ds ->dosdata
	mov	TempSeg, ax
	pop	ax
					; set up ds to DOSDATA
	MOV	User_SP,AX
	POP	AX			; suck off CS:IP of interrupt...
	POP	AX
	POP	AX
; M011 : BEGIN
;	MOV	AX,0F202h		; STI
	LAHF
	XCHG	AH, AL
	AND	AL, 02
	MOV	AH, 0F2h
; M011 : END
	PUSH	AX
 
	PUSH	WORD PTR [EXITHOLD+2]
	PUSH	WORD PTR [EXITHOLD]
	MOV	AX,User_SP
	mov	ds,TempSeg		; restore ds
	assume	ds:NOTHING
	IRET				; Long return back to user terminate address
EndProc HardErr,NoCheck
;---------------------------------------------------------------------------
;
; Procedure Name : SET_I24_EXTENDED_ERROR
;
; This routine handles extended error codes.
; Input : DI = error code from device
; Output: All EXTERR fields are set
;
;--------------------------------------------------------------------------
Procedure SET_I24_EXTENDED_ERROR,NEAR
	PUSH	AX
					; ErrMap24End is in DOSDATA
	MOV	AX,OFFSET DOSDATA:ErrMap24End
	SUB	AX,OFFSET DOSDATA:ErrMap24
					; Change to dosdata to access 
					; ErrMap24 and EXTERR -SR
	push	ds
	getdseg <ds>			; ds ->dosdata
	;
	; AX is the index of the first unavailable error.  Do not translate 
	; if greater or equal to AX.
	;
	CMP	DI,AX
	MOV	AX,DI
	JAE	NoTrans
	MOV	AL,ErrMap24[DI]
	XOR	AH,AH
NoTrans:
	MOV	[EXTERR],AX
	pop	ds
	assume	ds:nothing
	POP	AX
	;
	; Now Extended error is set correctly.	Translate it to get correct 
	; error locus class and recommended action.
	;
	PUSH	SI
					; ERR_TABLE_24 is in DOSCODE 
	MOV	SI,OFFSET DOSDATA:ERR_TABLE_24
	invoke	CAL_LK			; Set other extended error fields
	POP	SI
	ret
EndProc SET_I24_EXTENDED_ERROR
;--------------------------------------------------------------------------
;
; Proc. name : dos_high
;
; ENTRY: CS = current doscode segment
; 
; EXIT: if CS >=F000 (DOS is in HMA)
;	   CY stc
;	else	     (DOS is LOW)
;	   NC clc	
;
; USED: nothing
;
;-------------------------------------------------------------------------
;
;public	dos_high
;dos_high	proc	near
;
;	push	ax
;	mov	ax, cs
;	cmp	ax, 0f000h		; Q: is current cs >= f000
;	pop	ax
;	cmc				; clc if dos is low
;					; stc if dos is high 
;	ret
;
;dos_high	endp
;
DOSCODE	ENDS
    END
 
 | 
					
	// Copyright Take Vos 2019.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
#include "ttauri/file_view.hpp"
#include "ttauri/required.hpp"
#include <gtest/gtest.h>
#include <iostream>
#include <string>
using namespace std;
using namespace tt;
TEST(file_view, read) {
    ttlet view = file_view(URL("file:file_view.txt"));
    ttlet *test = reinterpret_cast<char const *>(view.bytes().data());
    ASSERT_TRUE(strncmp(test, "The quick brown", 15) == 0);
}
 
 | 
					
		segment	.text
		
		global	VDMethodToFunctionThunk64
proc_frame	VDMethodToFunctionThunk64
		;prolog
		db			48h				;emit REX prefix -- first instruction must be two bytes for hot patching
		push		rbp
		[pushreg	rbp]
		
		mov			rbp, rsp		;create stack pointer
		[setframe	rbp, 0]
		
		mov			[rbp+16], rcx	;save arg1
		[savereg	rcx, 0]
		
		mov			[rbp+24], rdx	;save arg2
		[savereg	rcx, 8]
		mov			[rbp+32], r8	;save arg3
		[savereg	rcx, 16]
		mov			[rbp+40], r9	;save arg4
		[savereg	rcx, 24]
		
		[endprolog]
				
		;re-copy arguments 4 and up
		mov			ecx, [rax+24]
		or			ecx, ecx
		jz			.argsdone
		lea			rdx, [rcx+32]
.argsloop:
		push		qword [rsp+rdx]
		sub			ecx, 8
		jnz			.argsloop
.argsdone:
		
		;load 'this' pointer
		mov			rcx, [rax+16]
		
		;reload arguments 1-3
		mov			rdx, [rbp+16]
		mov			r8, [rbp+24]
		mov			r9, [rbp+32]
		
		;reserve argument 1-4 space on stack
		sub			rsp, 32
		
		;call function
		call		qword [rax+8]
		
		;epilog
		lea			rsp, [rbp]		;pop off stack frame and any additional arg space
		pop			rbp				;restore base pointer
		ret							;all done
endproc_frame
		end
 
 | 
					
	; A157731: a(n) = 18522*n - 10248.
; 8274,26796,45318,63840,82362,100884,119406,137928,156450,174972,193494,212016,230538,249060,267582,286104,304626,323148,341670,360192,378714,397236,415758,434280,452802,471324,489846,508368,526890,545412,563934,582456,600978,619500,638022,656544,675066,693588,712110,730632,749154,767676,786198,804720,823242,841764,860286,878808,897330,915852,934374,952896,971418,989940,1008462,1026984,1045506,1064028,1082550,1101072,1119594,1138116,1156638,1175160,1193682,1212204,1230726,1249248,1267770,1286292,1304814,1323336,1341858,1360380,1378902,1397424,1415946,1434468,1452990,1471512,1490034,1508556,1527078,1545600,1564122,1582644,1601166,1619688,1638210,1656732,1675254,1693776,1712298,1730820,1749342,1767864,1786386,1804908,1823430,1841952,1860474,1878996,1897518,1916040,1934562,1953084,1971606,1990128,2008650,2027172,2045694,2064216,2082738,2101260,2119782,2138304,2156826,2175348,2193870,2212392,2230914,2249436,2267958,2286480,2305002,2323524,2342046,2360568,2379090,2397612,2416134,2434656,2453178,2471700,2490222,2508744,2527266,2545788,2564310,2582832,2601354,2619876,2638398,2656920,2675442,2693964,2712486,2731008,2749530,2768052,2786574,2805096,2823618,2842140,2860662,2879184,2897706,2916228,2934750,2953272,2971794,2990316,3008838,3027360,3045882,3064404,3082926,3101448,3119970,3138492,3157014,3175536,3194058,3212580,3231102,3249624,3268146,3286668,3305190,3323712,3342234,3360756,3379278,3397800,3416322,3434844,3453366,3471888,3490410,3508932,3527454,3545976,3564498,3583020,3601542,3620064,3638586,3657108,3675630,3694152,3712674,3731196,3749718,3768240,3786762,3805284,3823806,3842328,3860850,3879372,3897894,3916416,3934938,3953460,3971982,3990504,4009026,4027548,4046070,4064592,4083114,4101636,4120158,4138680,4157202,4175724,4194246,4212768,4231290,4249812,4268334,4286856,4305378,4323900,4342422,4360944,4379466,4397988,4416510,4435032,4453554,4472076,4490598,4509120,4527642,4546164,4564686,4583208,4601730,4620252
mov $1,$0
mul $1,18522
add $1,8274
 
 | 
					
	; A113763: Non-multiples of 13, or numbers not divisible by 13.
; 1,2,3,4,5,6,7,8,9,10,11,12,14,15,16,17,18,19,20,21,22,23,24,25,27,28,29,30,31,32,33,34,35,36,37,38,40,41,42,43,44,45,46,47,48,49,50,51,53,54,55,56,57,58,59,60,61,62,63,64,66,67,68,69,70,71,72,73,74,75,76,77
mov $1,$0
div $1,12
add $0,$1
add $0,1
 
 | 
					
	; A010888: Digital root of n (repeatedly add the digits of n until a single digit is reached).
; 0,1,2,3,4,5,6,7,8,9,1,2,3,4,5,6,7,8,9,1,2,3,4,5,6,7,8,9,1,2,3,4,5,6,7,8,9,1,2,3,4,5,6,7,8,9,1,2,3,4,5,6,7,8,9,1,2,3,4,5,6,7,8,9,1,2,3,4,5,6,7,8,9,1,2,3,4,5,6,7,8,9,1,2,3,4,5,6,7,8,9,1,2,3,4,5,6,7,8,9,1,2,3,4,5,6,7,8,9,1,2,3,4,5,6,7,8,9,1,2,3,4,5,6,7,8,9,1,2,3,4,5,6,7,8,9,1,2,3,4,5,6,7,8,9,1,2,3,4,5,6,7,8,9,1,2,3,4,5,6,7,8,9,1,2,3,4,5,6,7,8,9,1,2,3,4,5,6,7,8,9,1,2,3,4,5,6,7,8,9,1,2,3,4,5,6,7,8,9,1,2,3,4,5,6,7,8,9,1,2,3,4,5,6,7,8,9,1,2,3,4,5,6,7,8,9,1,2,3,4,5,6,7,8,9,1,2,3,4,5,6,7,8,9,1,2,3,4,5,6
sub $0,1
mod $0,9
add $0,1
mov $1,$0
 
 | 
					
	// Copyright 2019 Esri.
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifdef Q_OS_WIN
#include <Windows.h>
#endif
#include "ChooseCameraController.h"
#include "ArcGISRuntimeEnvironment.h"
#include <QDir>
#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include <QSurfaceFormat>
#define STRINGIZE(x) #x
#define QUOTE(x) STRINGIZE(x)
int main(int argc, char *argv[])
{
#if defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID)
  // Linux requires 3.2 OpenGL Context
  // in order to instance 3D symbols
  QSurfaceFormat fmt = QSurfaceFormat::defaultFormat();
  fmt.setVersion(3, 2);
  QSurfaceFormat::setDefaultFormat(fmt);
#endif
  QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
  QGuiApplication app(argc, argv);
  app.setApplicationName(QStringLiteral("ChooseCameraController - C++"));
  // Use of Esri location services, including basemaps and geocoding,
  // requires authentication using either an ArcGIS identity or an API Key.
  // 1. ArcGIS identity: An ArcGIS named user account that is a member of an
  //    organization in ArcGIS Online or ArcGIS Enterprise.
  // 2. API key: A permanent key that gives your application access to Esri
  //    location services. Visit your ArcGIS Developers Dashboard create a new
  //    API keys or access an existing API key.
  const QString apiKey = QString("");
  if (apiKey.isEmpty())
  {
      qWarning() << "Use of Esri location services, including basemaps, requires" <<
                    "you to authenticate with an ArcGIS identity or set the API Key property.";
  }
  else
  {
      Esri::ArcGISRuntime::ArcGISRuntimeEnvironment::setApiKey(apiKey);
  }
  // Initialize the sample
  ChooseCameraController::init();
  QString arcGISRuntimeImportPath = QUOTE(ARCGIS_RUNTIME_IMPORT_PATH);
#if defined(LINUX_PLATFORM_REPLACEMENT)
  // on some linux platforms the string 'linux' is replaced with 1
  // fix the replacement paths which were created
  QString replaceString = QUOTE(LINUX_PLATFORM_REPLACEMENT);
  arcGISRuntimeImportPath = arcGISRuntimeImportPath.replace(replaceString, "linux", Qt::CaseSensitive);
#endif
  // Initialize application view
  QQmlApplicationEngine engine;
  // Add the import Path
  engine.addImportPath(QDir(QCoreApplication::applicationDirPath()).filePath("qml"));
  // Add the Runtime and Extras path
  engine.addImportPath(arcGISRuntimeImportPath);
  // Set the source
  engine.load(QUrl("qrc:/Samples/Scenes/ChooseCameraController/main.qml"));
  return app.exec();
}
 
 | 
					
	; A051624: 12-gonal (or dodecagonal) numbers: a(n) = n*(5*n-4).
; 0,1,12,33,64,105,156,217,288,369,460,561,672,793,924,1065,1216,1377,1548,1729,1920,2121,2332,2553,2784,3025,3276,3537,3808,4089,4380,4681,4992,5313,5644,5985,6336,6697,7068,7449,7840,8241,8652,9073,9504,9945,10396,10857,11328,11809,12300,12801,13312,13833,14364,14905,15456,16017,16588,17169,17760,18361,18972,19593,20224,20865,21516,22177,22848,23529,24220,24921,25632,26353,27084,27825,28576,29337,30108,30889,31680,32481,33292,34113,34944,35785,36636,37497,38368,39249,40140,41041,41952,42873,43804,44745,45696,46657,47628,48609,49600,50601,51612,52633,53664,54705,55756,56817,57888,58969,60060,61161,62272,63393,64524,65665,66816,67977,69148,70329,71520,72721,73932,75153,76384,77625,78876,80137,81408,82689,83980,85281,86592,87913,89244,90585,91936,93297,94668,96049,97440,98841,100252,101673,103104,104545,105996,107457,108928,110409,111900,113401,114912,116433,117964,119505,121056,122617,124188,125769,127360,128961,130572,132193,133824,135465,137116,138777,140448,142129,143820,145521,147232,148953,150684,152425,154176,155937,157708,159489,161280,163081,164892,166713,168544,170385,172236,174097,175968,177849,179740,181641,183552,185473,187404,189345,191296,193257,195228,197209,199200,201201,203212,205233,207264,209305,211356,213417,215488,217569,219660,221761,223872,225993,228124,230265,232416,234577,236748,238929,241120,243321,245532,247753,249984,252225,254476,256737,259008,261289,263580,265881,268192,270513,272844,275185,277536,279897,282268,284649,287040,289441,291852,294273,296704,299145,301596,304057,306528,309009
mov $1,5
mul $1,$0
sub $1,4
mul $1,$0
 
 | 
					
	;*********************************************
;	Boot1.asm
;		- A Simple Bootloader
;
;	Operating Systems Development Tutorial
;*********************************************
 
bits	16							; We are still in 16 bit Real Mode
org		0x7c00						; We are loaded by BIOS at 0x7C00
start:          jmp loader					; jump over OEM block
;*************************************************;
;	OEM Parameter block
;*************************************************;
TIMES 0Bh-$+start DB 0
bpbBytesPerSector:  	DW 512
bpbSectorsPerCluster: 	DB 1
bpbReservedSectors: 	DW 1
bpbNumberOfFATs: 	    DB 2
bpbRootEntries: 	    DW 224
bpbTotalSectors: 	    DW 2880
bpbMedia: 	            DB 0xF0
bpbSectorsPerFAT: 	    DW 9
bpbSectorsPerTrack: 	DW 18
bpbHeadsPerCylinder: 	DW 2
bpbHiddenSectors: 	    DD 0
bpbTotalSectorsBig:     DD 0
bsDriveNumber: 	        DB 0
bsUnused: 	            DB 0
bsExtBootSignature: 	DB 0x29
bsSerialNumber:	        DD 0xa0a1a2a3
bsVolumeLabel: 	        DB "MOS FLOPPY "
bsFileSystem: 	        DB "FAT12   "
msg						db	"Welcome to My Operating System!", 0
;***************************************
;	Prints a string
;	DS=>SI: 0 terminated string
;***************************************
Print:
			lodsb
			or			al, al				; al=current character
			jz			PrintDone			; null terminator found
			mov			ah,	0eh			; get next character
			int			10h
			jmp			Print
PrintDone:
			ret
;*************************************************;
;	Bootloader Entry Point
;*************************************************;
loader:
	xchg 	bx, bx 
	mov 	eax, 4
	xchg 	bx, bx
	
	xor		bx, bx		; A faster method of clearing BX to 0
	mov		ah, 0x0e
	mov		al, 'A'
	xchg 	bx, bx
	int		0x10
	xor		bx, bx		; A faster method of clearing BX to 0
	mov		ah, 0x0e
	mov		al, 'A'
	xchg 	bx, bx
	int		0x12
	xchg 	bx, bx 		; ax got the memory size got 0x27f or 639 in decimal
						; only 64KB
	
; Error Fix 1 ------------------------------------------
	xor		ax, ax		; Setup segments to insure they are 0. Remember that
	mov		ds, ax		; we have ORG 0x7c00. This means all addresses are based
	mov		es, ax		; from 0x7c00:0. Because the data segments are within the same
						; code segment, null em.
	mov		si, msg
	xchg 	bx, bx
	call	Print
	xchg 	bx, bx
	
	cli					; Clear all Interrupts
	xchg bx, bx
	; hlt					; halt the system
;*************************************************;
;	Bootloader 2 Entry Point
;*************************************************;
 
loader2:
 
.Reset:
	xchg bx, bx
	mov		ah, 0					; reset floppy disk function
	mov		dl, 0					; drive 0 is floppy drive
	int		0x13					; call BIOS
	jc		.Reset					; If Carry Flag (CF) is set, there was an error. Try resetting again
 
	xchg bx, bx
	mov		ax, 0x1000				; we are going to read sector to into address 0x1000:0
	mov		es, ax
	xor		bx, bx
 
	mov		ah, 0x02				; read floppy sector function
	mov		al, 1					; read 1 sector
	mov		ch, 1					; we are reading the second sector past us, so its still on track 1
	mov		cl, 2					; sector to read (The second sector)
	mov		dh, 0					; head number
	mov		dl, 0					; drive number. Remember Drive 0 is floppy drive.
	int		0x13					; call BIOS - Read the sector
	
 
	xchg bx, bx
	jmp		0x1000:0x0				; jump to execute the sector!
 
 
times 510 - ($-$$) db 0						; We have to be 512 bytes. Clear the rest of the bytes with 0
 
dw 0xAA55							; Boot Signiture
 
; End of sector 1, beginning of sector 2 ---------------------------------
 
 
org 0x1000							; This sector is loaded at 0x1000:0 by the bootsector
 
xchg bx, bx
cli								; just halt the system
hlt
 
 | 
					
	; A057658: a(n) = n*(n+1)^2*(n+2)^3*(n+3)^2*(n+4).
; 0,8640,172800,1512000,8467200,35562240,121927680,359251200,940896000,2242468800,4947022080,10231341120,20033395200,37425024000,67118284800,116138603520,194702952960,317346724800,504348768000,783510235200,1192349410560,1780781587200,2614360320000,3778164000000,5381419680000,7562964427200,10497653187840,14403831220800,19551998592000,26274804019200,34978515517440,46156125818880,60402261427200,78430075416000,101090315692800,129392772425280,164530320664320,207905786899200,261161881344000,326214451180800,405289323774720,500963023028160,616207656556800,754440286248000,919577110003200,1116092798069760,1349085343334400,1624346801280000,1948440312000000,2328783813720000,2773740874694400,3292719088127040,3896276492908800,4596236501472000,5405811834931200,6339737984912640,7414416741070080,8648070343243200,10060906837536000,11675297236276800,13515965102868480,15610189203947520,17988019893043200,20682509912064000,23729960319436800,27170182276585920,31046775447663360,35407423791028800,40304209544928000,45793946234131200,51938531548968960,58805320973241600,66467523062880000,75004617303000000,84502795497120000,95055427668801600,106763553482826240,119736400220236800,134091928369152000,149957405921203200,167470012491747840,186777474410681280,208038731959699200,231424639961256000,257118702954220800,285317846221351680,316233223964190720,350091065951827200,387133564001184000,427619799678052800,471826714640037120,520050125074858560,572605781720140800,629830476983808000,692083200717619200,759746346230108160,833226968159308800,912958093860120000,999400089996000000,1093042086059880000
lpb $0
  sub $0,1
  mov $2,$0
  max $2,0
  seq $2,107891 ; a(n) = (n+1)*(n+2)^2*(n+3)^2*(n+4)*(3n^2 + 15n + 20)/2880.
  add $1,$2
lpe
mul $1,8640
mov $0,$1
 
 | 
					
	
    SECTION code_clib
    PUBLIC  __krt_pointxy
.__krt_pointxy
    defc    NEEDpoint = 1
    INCLUDE "pixel_krt.inc"
 
 | 
					
	; A109392: Partial sums of A109391.
; 0,1,13,175,2735,49610,1029386,24088590,628068366,18061990371,568061990371,19398632250697,714854467214665,28276489167109688,1195037205850701368,53742304051553826368,2562499498076052846144
lpb $0
  mov $2,$0
  sub $0,1
  seq $2,109391 ; a(n) = (n^(n+1))*(n + 1)/2 = A000217(n)*A000312(n).
  add $3,$2
lpe
mov $0,$3
 
 | 
					
	include macros.inc
include comparison_predicates.inc
.const
	align 16
	FloatToUint8Min real4 0.0, 0.0, 0.0, 0.0
	FloatToUint8Max real4 1.0, 1.0, 1.0, 1.0
	FloatToUint8Scale real4 255.0, 255.0, 255.0, 255.0
	Uint8Min dword 0
	Uint8Max dword 255
.code
; bool AVX_Packed_Convert_Float_To_Byte_0_255_Range(const float* input, uint32_t arrayLength, uint8_t * output);
AVX_Packed_Convert_Float_To_Byte_0_255_Range proc frame
_CreateFrame F2U_, 0, 96
_SaveXmmRegs xmm6, xmm7, xmm12, xmm13, xmm14, xmm15
_EndProlog
xor eax, eax
test rdx, rdx ; Exit if arrayLenght == 0
jz InvalidArg
test rcx, 0fh ; Exit if not aligned
jnz InvalidArg
test r8, 0fh ; Exit if not aligned
jnz InvalidArg
; Initializations
mov r9, rdx
shr r9d, 2             ; arrayLength >> 2 = arrayLength % 4 = Number of blocks with 4 items
vpxor xmm1, xmm1, xmm1 ; Just zeros
vmovaps xmm13, xmmword ptr [FloatToUint8Scale]
vmovaps xmm14, xmmword ptr [FloatToUint8Min]
vmovaps xmm15, xmmword ptr [FloatToUint8Max]
test r9, r9 ; Do one by one number of blocks is zero
jz OneByOne
@@:
vmovaps xmm0, xmmword ptr [rcx] ; xmm0 have 4 floats
; Values < 0.0F = 0.0F
vcmpps xmm1, xmm0, xmm14, CMP_LT_OS
vandnps xmm2, xmm1, xmm0
; Values > 1.0F = 1.0F
vcmpps xmm3, xmm2, xmm15, CMP_GT_OS
vandps xmm4, xmm3, xmm15
vandnps xmm5, xmm3, xmm2
vorps xmm6, xmm5, xmm4
; Values = values * 255.0F
vmulps xmm7, xmm6, xmm13
; Convert 4 floats to 4 int32_t
vcvtps2dq xmm0, xmm7
; Convert 4 int32_t to 8 uint16_t
;        127                                                           0
; xmm1 = xmm0[3] xmm0[2] xmm0[1] xmm0[0] xmm0[3] xmm0[2] xmm0[1] xmm0[0]
; It's safe to do because the values will never go beyond 255
vpackusdw xmm1, xmm0, xmm0
; Convert 8 uint16_t to 16 uint8_t
;        127                                                              0
; xmm1 = xmm0[3] xmm0[2] xmm0[1] xmm0[0] ... xmm0[3] xmm0[2] xmm0[1] xmm0[0]
; It's safe to do because the values will never go beyond 255
vpackuswb xmm2, xmm1, xmm1
vpextrd eax, xmm2, 0 ; Get the 4 uint_8 converted number (32 bits)
mov dword ptr [r8], eax
add rcx, 16 ; Advance to the next 16 bytes (4 items * sizeof(float))
add r8, type dword
sub rdx, 4
sub r9d, 1
jnz @B
OneByOne:
test rdx, rdx
jz Done
; Get next number.
; Multiply it by uint8_t max value.
; Convert it to int32_t.
vmovss xmm1, real4 ptr [rcx]
vmulss xmm2, xmm1, real4 ptr [FloatToUint8Scale]
vcvtss2si eax, xmm2
; Value < 0 = 0
cmp eax, 0
cmovb eax, dword ptr [Uint8Min]
; Value > 255 = 255
cmp eax, 255
cmova eax, dword ptr [Uint8Max]
mov byte ptr [r8], al
add rcx, type real4 ; Advance to the next number
add r8, type byte
dec rdx
jnz OneByOne
Done:
mov rax, 1
InvalidArg:
_RestoreXmmRegs xmm6, xmm7, xmm8, xmm9, xmm10, xmm11, xmm12, xmm13, xmm14, xmm15
_DeleteFrame
ret
AVX_Packed_Convert_Float_To_Byte_0_255_Range endp
end 
 | 
					
	; A069099: Centered heptagonal numbers.
; 1,8,22,43,71,106,148,197,253,316,386,463,547,638,736,841,953,1072,1198,1331,1471,1618,1772,1933,2101,2276,2458,2647,2843,3046,3256,3473,3697,3928,4166,4411,4663,4922,5188,5461,5741,6028,6322,6623,6931,7246,7568,7897,8233,8576,8926,9283,9647,10018,10396,10781,11173,11572,11978,12391,12811,13238,13672,14113,14561,15016,15478,15947,16423,16906,17396,17893,18397,18908,19426,19951,20483,21022,21568,22121,22681,23248,23822,24403,24991,25586,26188,26797,27413,28036,28666,29303,29947,30598,31256,31921,32593,33272,33958,34651
sub $1,$0
bin $1,2
mul $1,7
add $1,1
mov $0,$1
 
 | 
					
	; A183142: Beatty sequence for 2/(3+sqrt(3)).
; 0,0,1,1,2,2,2,3,3,4,4,5,5,5,6,6,7,7,8,8,8,9,9,10,10,10,11,11,12,12,13,13,13,14,14,15,15,16,16,16,17,17,18,18,19,19,19,20,20,21,21,21,22,22,23,23,24,24,24,25,25,26,26,27,27,27,28,28,29,29,30
mul $0,22
mov $1,21
add $1,$0
div $1,52
mov $0,$1
 
 | 
					
	// Range-based for does not recognize symbolic constants.
// The following should work but gives a not-constant exception
  // Commodore 64 PRG executable file
.file [name="forrangesymbolic.prg", type="prg", segments="Program"]
.segmentdef Program [segments="Basic, Code, Data"]
.segmentdef Basic [start=$0801]
.segmentdef Code [start=$80d]
.segmentdef Data [startAfter="Code"]
.segment Basic
:BasicUpstart(main)
.segment Code
main: {
    .label BITMAP = $2000
    .label b = 2
    lda #<BITMAP+$1fff
    sta.z b
    lda #>BITMAP+$1fff
    sta.z b+1
  __b1:
    // *b = $5a
    lda #$5a
    ldy #0
    sta (b),y
    // for(byte* b : BITMAP+$1fff..BITMAP)
    lda.z b
    bne !+
    dec.z b+1
  !:
    dec.z b
    lda.z b+1
    cmp #>BITMAP-1
    bne __b1
    lda.z b
    cmp #<BITMAP-1
    bne __b1
    // }
    rts
}
 
 | 
					
	dnl  AMD64 mpn_modexact_1_odd -- Hensel norm remainder.
dnl  Copyright 2000-2006, 2011, 2012 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 AMD K8,K9	10
C AMD K10	10
C Intel P4	33
C Intel core2	13
C Intel corei	14.5
C Intel atom	35
C VIA nano	 ?
C The dependent chain in the main loop is
C
C                            cycles
C	sub	%rdx, %rax	1
C	imul	%r9, %rax	4
C	mul	%r8		5
C			      ----
C       total		       10
C
C The mov load from src seems to need to be scheduled back before the jz to
C achieve this speed, out-of-order execution apparently can't completely hide
C the latency otherwise.
C
C The l=src[i]-cbit step is rotated back too, since that allows us to avoid it
C for the first iteration (where there's no cbit).
C
C The code alignment used (32-byte) for the loop also seems necessary.  Without
C that the non-PIC case has adc crossing the 0x60 offset, apparently making it
C run at 11 cycles instead of 10.
ABI_SUPPORT(DOS64)
ABI_SUPPORT(STD64)
ASM_START()
	TEXT
	ALIGN(32)
PROLOGUE(mpn_modexact_1_odd)
	FUNC_ENTRY(3)
	mov	$0, R32(%rcx)
IFDOS(`	jmp	L(ent)		')
PROLOGUE(mpn_modexact_1c_odd)
	FUNC_ENTRY(4)
L(ent):
	C rdi	src
	C rsi	size
	C rdx	divisor
	C rcx	carry
	mov	%rdx, %r8		C d
	shr	R32(%rdx)		C d/2
	LEA(	binvert_limb_table, %r9)
	and	$127, R32(%rdx)
	mov	%rcx, %r10		C initial carry
	movzbl	(%r9,%rdx), R32(%rdx)	C inv 8 bits
	mov	(%rdi), %rax		C src[0]
	lea	(%rdi,%rsi,8), %r11	C src end
	mov	%r8, %rdi		C d, made available to imull
	lea	(%rdx,%rdx), R32(%rcx)	C 2*inv
	imul	R32(%rdx), R32(%rdx)	C inv*inv
	neg	%rsi			C -size
	imul	R32(%rdi), R32(%rdx)	C inv*inv*d
	sub	R32(%rdx), R32(%rcx)	C inv = 2*inv - inv*inv*d, 16 bits
	lea	(%rcx,%rcx), R32(%rdx)	C 2*inv
	imul	R32(%rcx), R32(%rcx)	C inv*inv
	imul	R32(%rdi), R32(%rcx)	C inv*inv*d
	sub	R32(%rcx), R32(%rdx)	C inv = 2*inv - inv*inv*d, 32 bits
	xor	R32(%rcx), R32(%rcx)	C initial cbit
	lea	(%rdx,%rdx), %r9	C 2*inv
	imul	%rdx, %rdx		C inv*inv
	imul	%r8, %rdx		C inv*inv*d
	sub	%rdx, %r9		C inv = 2*inv - inv*inv*d, 64 bits
	mov	%r10, %rdx		C initial climb
	ASSERT(e,`	C d*inv == 1 mod 2^64
	mov	%r8, %r10
	imul	%r9, %r10
	cmp	$1, %r10')
	inc	%rsi
	jz	L(one)
	ALIGN(16)
L(top):
	C rax	l = src[i]-cbit
	C rcx	new cbit, 0 or 1
	C rdx	climb, high of last product
	C rsi	counter, limbs, negative
	C rdi
	C r8	divisor
	C r9	inverse
	C r11	src end ptr
	sub	%rdx, %rax		C l = src[i]-cbit - climb
	adc	$0, %rcx		C more cbit
	imul	%r9, %rax		C q = l * inverse
	mul	%r8			C climb = high (q * d)
	mov	(%r11,%rsi,8), %rax	C src[i+1]
	sub	%rcx, %rax		C next l = src[i+1] - cbit
	setc	R8(%rcx)		C new cbit
	inc	%rsi
	jnz	L(top)
L(one):
	sub	%rdx, %rax		C l = src[i]-cbit - climb
	adc	$0, %rcx		C more cbit
	imul	%r9, %rax		C q = l * inverse
	mul	%r8			C climb = high (q * d)
	lea	(%rcx,%rdx), %rax	C climb+cbit
	FUNC_EXIT()
	ret
EPILOGUE(mpn_modexact_1c_odd)
EPILOGUE(mpn_modexact_1_odd)
 
 | 
					
	; A166482: a(n) = Sum_{k=0..n} C(n+k,2k)*F(2k+1).
; Submitted by Christian Krause
; 1,3,12,51,221,965,4227,18540,81363,357145,1567849,6883059,30218028,132664227,582428789,2557009709,11225925267,49284687948,216372426339,949930508209,4170438905425,18309298027683,80382521554380,352899918350547,1549321295535245,6801918483042581,29862169446239331,131102594994517932,575574070246277043,2526918024435838921,11093819253364657081,48704716352616114963,213826216275376858092,938752018092745272771,4121362510284265901861,18093840134359194658685,79436606217192745937907,348747107327576807042700
mul $0,2
seq $0,131322 ; Row sums of triangle A131321.
 
 | 
					
	#include "dfa.hpp"
#include <fstream>
/*
int main (int argc, char *argv[])
{
    char* fichero= new char[0];
    if(argc!=2){
        cout << "Introduzca el nombre del fichero: ";
        cin >> fichero;
        cin.clear();
    }else{
        fichero=argv[1];
    }
    dfa DFA;
    while(!DFA.leer_fichero(fichero)){
        cout << "Error al abrir fichero, el nombre no es valido, introduzca otro: ";
        cin >> fichero;
        cin.clear();
    }
    int opcion;
    do{
      cout<<endl;
      cout<<"1. Leer fichero."<<endl;
      cout<<"2. Mostrar DFA."<<endl;
      cout<<"3. Mostrar estados de muerte."<<endl;
      cout<<"4. Analizar cadena."<<endl;
      cout<<"5. Minimizar DFA."<<endl;
      cout<<"6. Exportar a fichero."<<endl;
      cout<<"0. Salir."<<endl;
      cout<<"Introduzca una opción: ";
      cin >> opcion;
      
      switch(opcion){
          case 2:
            DFA.mostrar();
            break;
          case 3:
            DFA.mostrar_estados_muerte();
            break;
          case 4:
            DFA.analizar_cadena();
            break;
          case 1: 
            DFA.destruir();
            cout << "Introduzca el nombre del fichero a leer: ";
            cin >> fichero;
            cin.clear();
            if(DFA.leer_fichero(fichero)){
                cout<<"El fichero se ha cargado"<<endl;
            }else{
                cout<<"Error al cargar el fichero"<<endl;
            }
            break;
          case 5:
            {
            dfa DFA2 = DFA.minimizar();
            DFA2.mostrar();
            int op;
            do{
            cout<<endl;
            cout<<"¿Que desea hacer?"<<endl;
            cout<<"1. Guardarlo en un fichero"<<endl;
            cout<<"2. Cargarlo como DFA actual"<<endl;
            cout<<"0. Salir"<<endl;
            cout<<"Introduzca una opcion: ";
            cin>>op;
            switch(op){
                case 1:
                  {
                      DFA2.crear_fichero();
                  }
                break;
                case 2:
                    DFA.copiar(DFA2);
                break;
                case 0:
                break;
            }
            }while(op!=0);
            }
            break;            
          case 6:
            {
                DFA.crear_fichero();
            }
            break;
          case 0:
            break;
          default:
            cout<<"Opción no encontrada."<<endl;
            break;
      }
    }while(opcion!=0);
}
*/
int main (int argc, char *argv[])
{
  char* fichero= new char[0];
  dfa DFA;
  if(argc==1){
    cout<<"Introduzca el nombre del fichero que contiene el DFA: ";
    cin>>fichero;
  }else{
    fichero=argv[1];
  }
  while(!DFA.leer_fichero(fichero)){
    cout<<"Error al abrir fichero, introduzca uno válido: ";
    cin>>fichero;
  }
  if(argc<3){
    cout<<"Introduzca el nombre del fichero donde desea almacenar el GR resultante: ";
    cin>>fichero;
  }else{
    fichero=argv[2];
  }
  {
    DFA.convert2gr(fichero);
  }
  /*
  if(argc>3){
    fichero=argv[3];
  }else{
    cout<<"Introduzca el nombre del fichero que contiene las cadenas que desea analizar: ";
    cin>>fichero;
  }
  {
    ifstream textfile;
    textfile.open(fichero);
    while(!textfile.is_open()){
      cout<<"Error al abrir fichero, introduzca uno válido: ";
      cin>>fichero;
      textfile.open(fichero);
    }
    cout<<"Cadena            NFA          DFA"<<endl;
    cout<<"------------------------------------"<<endl;
    char* cadena= new char[0];
    int n_cadenas;
    textfile>>(int &) n_cadenas;
    for(int i=0; i<n_cadenas; i++){
      textfile>>(char* &) cadena;
      cout<<left<<setw(12)<<setfill(' ')<<cadena<<setw(13)<<setfill(' ')<<(NFA.analizar_cadena(cadena) ? "Aceptada" : "No aceptada")<<(DFA.analizar_cadena_sin(cadena) ? "Aceptada" : "No aceptada")<<endl;
    }
    textfile.close();
  }*/
} 
 | 
					
	; A078427: Sum of all the decimal digits of numbers from 1 to 10^n.
; 46,901,13501,180001,2250001,27000001,315000001,3600000001,40500000001,450000000001,4950000000001,54000000000001,585000000000001,6300000000000001,67500000000000001,720000000000000001,7650000000000000001,81000000000000000001,855000000000000000001,9000000000000000000001,94500000000000000000001,990000000000000000000001,10350000000000000000000001,108000000000000000000000001,1125000000000000000000000001,11700000000000000000000000001,121500000000000000000000000001,1260000000000000000000000000001
mov $1,$0
add $0,1
mov $2,10
pow $2,$1
mul $0,$2
sub $0,1
mul $0,45
add $0,46
 
 | 
					
	; A040420: Continued fraction for sqrt(442).
; 21,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42
pow $1,$0
gcd $1,2
mul $1,21
 
 | 
					
	dnl  HP-PA 1.1 mpn_addmul_1 -- Multiply a limb vector with a limb and add the
dnl  result to a second limb vector.
dnl  Copyright 1992, 1993, 1994, 2000, 2001, 2002 Free Software Foundation,
dnl  Inc.
dnl  This file is part of the GNU MP Library.
dnl  The GNU MP Library is free software; you can redistribute it and/or modify
dnl  it under the terms of the GNU Lesser General Public License as published
dnl  by the Free Software Foundation; either version 3 of the License, or (at
dnl  your option) any later version.
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 Lesser General Public
dnl  License for more details.
dnl  You should have received a copy of the GNU Lesser General Public License
dnl  along with the GNU MP Library.  If not, see http://www.gnu.org/licenses/.
include(`../config.m4')
C INPUT PARAMETERS
C res_ptr	r26
C s1_ptr	r25
C size		r24
C s2_limb	r23
C This runs at 11 cycles/limb on a PA7000.  With the used instructions, it can
C not become faster due to data cache contention after a store.  On the PA7100
C it runs at 10 cycles/limb.
C There are some ideas described in mul_1.asm that applies to this code too.
ASM_START()
PROLOGUE(mpn_addmul_1)
C	.callinfo	frame=64,no_calls
	ldo		64(%r30),%r30
	fldws,ma	4(%r25),%fr5
	stw		%r23,-16(%r30)		C move s2_limb ...
	addib,=		-1,%r24,L(just_one_limb)
	 fldws		-16(%r30),%fr4		C ... into fr4
	add		%r0,%r0,%r0		C clear carry
	xmpyu		%fr4,%fr5,%fr6
	fldws,ma	4(%r25),%fr7
	fstds		%fr6,-16(%r30)
	xmpyu		%fr4,%fr7,%fr8
	ldw		-12(%r30),%r19		C least significant limb in product
	ldw		-16(%r30),%r28
	fstds		%fr8,-16(%r30)
	addib,=		-1,%r24,L(end)
	 ldw		-12(%r30),%r1
C Main loop
LDEF(loop)
	ldws		0(%r26),%r29
	fldws,ma	4(%r25),%fr5
	add		%r29,%r19,%r19
	stws,ma		%r19,4(%r26)
	addc		%r28,%r1,%r19
	xmpyu		%fr4,%fr5,%fr6
	ldw		-16(%r30),%r28
	fstds		%fr6,-16(%r30)
	addc		%r0,%r28,%r28
	addib,<>	-1,%r24,L(loop)
	 ldw		-12(%r30),%r1
LDEF(end)
	ldw		0(%r26),%r29
	add		%r29,%r19,%r19
	stws,ma		%r19,4(%r26)
	addc		%r28,%r1,%r19
	ldw		-16(%r30),%r28
	ldws		0(%r26),%r29
	addc		%r0,%r28,%r28
	add		%r29,%r19,%r19
	stws,ma		%r19,4(%r26)
	addc		%r0,%r28,%r28
	bv		0(%r2)
	 ldo		-64(%r30),%r30
LDEF(just_one_limb)
	xmpyu		%fr4,%fr5,%fr6
	ldw		0(%r26),%r29
	fstds		%fr6,-16(%r30)
	ldw		-12(%r30),%r1
	ldw		-16(%r30),%r28
	add		%r29,%r1,%r19
	stw		%r19,0(%r26)
	addc		%r0,%r28,%r28
	bv		0(%r2)
	 ldo		-64(%r30),%r30
EPILOGUE()
 
 | 
					
	
	map_header CeruleanPokecenter, CERULEAN_POKECENTER, POKECENTER, 0
	end_map_header
 
 | 
					
	[BITS 16]
[ORG 0x7c00]
    
  jmp 0x0:beginning
beginning:
  ; очистка экрана
  mov ax, 0xb800
  mov es, ax
  xor bx, bx
  mov ecx, 80 * 25 * 2
  clearing:
    mov byte [es:bx], 0
    inc bx
  loop clearing
  ; загрузка ядра с диска
  mov ax, 0x800
  mov es, ax
  xor bx, bx
  mov ah, 2
  mov al, 8
  mov dl, 0x80
  mov cx, 2
  xor dh, dh
  int 0x13
   
  mov ax, 0x900
  mov es, ax
  xor bx, bx
  mov ah, 2
  mov al, 8
  mov dl, 0x80
  mov cx, 2
  mov dh, 1
  int 0x13
 
  ; переход на ядро
  jmp 0x8000    
  ; отсчитывание неиспользуемого пространства
  times 510 - ($ - $$) db 0x90
  ; объявление диска загрузочным
  db 0x55
  db 0xaa
 
 | 
					
	.cseg
.org 0x00
rcall main_thread
; include components interrupts
;.include "../../../../../src/kernel/drivers/{driver_name}_int.asm"
.include "../../../../../src/kernel/drivers/soc/timer2_int.asm"
; include components definitions
.include "../../../../../src/kernel/kernel_def.asm"
;.include "../../../src/kernel/drivers/{driver_name}_def.asm"
.include "../../../../../src/kernel/drivers/device_def.asm"
.include "../../../../../src/kernel/drivers/io/device_io_def.asm"
.include "../../../../../src/kernel/drivers/io/out_bit_def.asm"
.include "../../../../../src/kernel/drivers/io/hid/led_def.asm"
.include "../../../../../src/kernel/drivers/soc/timer_base_def.asm"
.include "../../../../../src/kernel/drivers/soc/timer_w_pwm_base_def.asm"
.include "../../../../../src/kernel/drivers/soc/timer2_def.asm"
;.include components data segments
;.include "../../../../../src/kernel/{driver_name}_dseg.asm"
.include "../../../../../src/kernel/drivers/soc/timer2_dseg.asm"
; custom data & descriptors
.dseg
	led1:		.BYTE SZ_ST_LED
	led2:		.BYTE SZ_ST_LED
; main thread
.cseg
; skip interrupts vector
.org 0x14
; include components code segments
.include "../../../../../src/kernel/kernel_cseg.asm"
;.include "../../../../../src/kernel/drivers/{driver_name}_cseg.asm"
.include "../../../../../src/kernel/drivers/device_cseg.asm"
.include "../../../../../src/kernel/drivers/io/device_io_cseg.asm"
.include "../../../../../src/kernel/drivers/io/out_bit_cseg.asm"
.include "../../../../../src/kernel/drivers/io/hid/led_cseg.asm"
.include "../../../../../src/kernel/drivers/soc/timer_base_cseg.asm"
.include "../../../../../src/kernel/drivers/soc/timer_w_pwm_base_cseg.asm"
.include "../../../../../src/kernel/drivers/soc/timer2_cseg.asm"
main_thread:
	; stack initialization
	m_init_stack
	; init leds
	m_led_init led1, DDRC, PORTC, (1 << BIT5)
	m_led_init led2, DDRC, PORTC, (1 << BIT4)
	m_timer2_init TIMER_DIVIDER_1024X, timer2_on_overflow_handler, TIMER_W_PWM_MODE_FAST, 0x7F, timer2_on_compare_handler
	ldi r16, 0x08
	out DDRB, r16
	m_timer2_interrupts_enable
	; init global interrupts
	m_init_interrupts
	;.equ DELAY_TIME = 200000
	main_thread_loop:
		nop
		main_thread_loop_end:
			;m_delay DELAY_TIME
			push r16
			m_timer2_counter_get_value r16
			pop r16
			nop
			rjmp main_thread_loop
		ret
timer2_on_overflow_handler:
	m_led_toggle led1
	ret
timer2_on_compare_handler:
	m_led_toggle led2
	ret
 
 | 
					
	; A062011: a(n) = 2*tau(n) = 2*A000005(n).
; 2,4,4,6,4,8,4,8,6,8,4,12,4,8,8,10,4,12,4,12,8,8,4,16,6,8,8,12,4,16,4,12,8,8,8,18,4,8,8,16,4,16,4,12,12,8,4,20,6,12,8,12,4,16,8,16,8,8,4,24,4,8,12,14,8,16,4,12,8,16,4,24,4,8,12,12,8,16,4,20,10,8,4,24,8,8,8,16,4,24,8,12,8,8,8,24,4,12,12,18
mov $2,$0
mov $4,2
lpb $4
  mov $0,$2
  sub $4,1
  add $0,$4
  trn $0,1
  seq $0,2541 ; a(n) = Sum_{k=1..n-1} floor((n-k)/k).
  mov $3,$0
  mov $5,$4
  mul $5,$0
  add $1,$5
lpe
min $2,1
mul $2,$3
sub $1,$2
mul $1,2
add $1,2
mov $0,$1
 
 | 
					
	.global s_prepare_buffers
s_prepare_buffers:
ret
    .global s_faulty_load
s_faulty_load:
push %r12
push %r13
push %r8
push %rax
push %rcx
push %rdi
push %rdx
// Store
lea addresses_A+0x9045, %r13
nop
nop
nop
nop
dec %rax
mov $0x5152535455565758, %rdx
movq %rdx, %xmm1
vmovups %ymm1, (%r13)
nop
nop
nop
nop
cmp $62102, %rax
// Store
lea addresses_UC+0x18151, %rdi
nop
sub $52738, %rcx
mov $0x5152535455565758, %r12
movq %r12, %xmm6
movups %xmm6, (%rdi)
nop
nop
and %r13, %r13
// Faulty Load
mov $0x3a482e0000000951, %rcx
cmp %rdx, %rdx
mov (%rcx), %r8
lea oracles, %rdi
and $0xff, %r8
shlq $12, %r8
mov (%rdi,%r8,1), %r8
pop %rdx
pop %rdi
pop %rcx
pop %rax
pop %r8
pop %r13
pop %r12
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'type': 'addresses_NC', 'size': 4, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_A', 'size': 32, 'AVXalign': False, 'NT': False, 'congruent': 2, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_UC', 'size': 16, 'AVXalign': False, 'NT': False, 'congruent': 11, 'same': False}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'type': 'addresses_NC', 'size': 8, 'AVXalign': True, 'NT': False, 'congruent': 0, 'same': True}}
<gen_prepare_buffer>
{'0b': 4526, '00': 242}
0b 0b 0b 0b 0b 00 0b 0b 0b 0b 0b 0b 0b 0b 0b 00 0b 0b 0b 0b 00 0b 0b 00 0b 0b 0b 00 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 00 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 00 0b 0b 0b 00 00 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 00 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 00 00 0b 0b 0b 0b 0b 0b 0b 0b 00 0b 0b 00 0b 0b 00 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 00 0b 0b 0b 0b 0b 0b 0b 0b 0b 00 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 00 00 0b 0b 0b 0b 0b 0b 0b 00 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 00 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 00 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 00 0b 0b 0b 0b 0b 00 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 00 0b 0b 00 0b 0b 00 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 00 0b 0b 0b 00 0b 00 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 00 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 00 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 00 0b 0b 00 0b 0b 0b 0b 0b 00 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 00 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 00 0b 0b 0b 0b 0b 0b 00 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 00 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 00 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 00 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 0b 00 0b 0b
*/
 
 | 
					
	; Console Output
; Materials - NASM (32-bit)
; Copyright (c) 2017 Hall & Slonka
; Uses system call information from Chapter 10
SECTION .data
s1: DB "Hello Universe", 10, 0
lenS1: EQU ($ - s1)
SECTION .text
global _main
_main:
print:  mov eax, 4     ; syswrite
	mov ebx, 1     ; stdout
	mov ecx, s1    ; starting address of string
	mov edx, lenS1 ; len of string
	int 80h
done:	
mov eax, 1
mov ebx, 0
int 80h
 
 | 
					
	; A158948: Triangle read by rows, left border = natural numbers repeated (1, 1, 2, 2, 3, 3,...); all other columns = (1, 0, 1, 0, 1, 0,...).
; 1,1,1,2,0,1,2,1,0,1,3,0,1,0,1,3,1,0,1,0,1,4,0,1,0,1,0,1,4,1,0,1,0,1,0,1,5,0,1,0,1,0,1,0,1,5,1,0,1,0,1,0,1,0,1
mov $3,2
mov $5,$0
lpb $3
  mov $0,$5
  sub $3,1
  add $0,$3
  trn $0,1
  seq $0,4202 ; Skip 1, take 1, skip 2, take 2, skip 3, take 3, etc.
  div $0,2
  mov $2,$3
  mul $2,$0
  add $1,$2
  mov $4,$0
lpe
min $5,1
mul $5,$4
sub $1,$5
mov $0,$1
 
 | 
					
	/*
 * Copyright (c) Contributors to the Open 3D Engine Project.
 * For complete copyright and license terms please see the LICENSE at the root of this distribution.
 *
 * SPDX-License-Identifier: Apache-2.0 OR MIT
 *
 */
#include <AzCore/DOM/Backends/JSON/JsonBackend.h>
#include <AzCore/DOM/Backends/JSON/JsonSerializationUtils.h>
#include <AzCore/DOM/DomUtils.h>
#include <AzCore/Name/NameDictionary.h>
#include <AzCore/Serialization/Json/JsonSerialization.h>
#include <AzCore/Serialization/Json/JsonUtils.h>
#include <AzCore/UnitTest/TestTypes.h>
#include <Tests/DOM/DomFixtures.h>
namespace AZ::Dom::Tests
{
    class DomJsonTests : public DomTestFixture
    {
    public:
        void SetUp() override
        {
            DomTestFixture::SetUp();
            m_document = AZStd::make_unique<rapidjson::Document>();
        }
        void TearDown() override
        {
            m_document.reset();
            DomTestFixture::TearDown();
        }
        rapidjson::Value CreateString(const AZStd::string& text)
        {
            rapidjson::Value key;
            key.SetString(text.c_str(), static_cast<rapidjson::SizeType>(text.length()), m_document->GetAllocator());
            return key;
        }
        template<class T>
        void AddValue(const AZStd::string& key, T value)
        {
            m_document->AddMember(CreateString(key), rapidjson::Value(value), m_document->GetAllocator());
        }
        // Validate round-trip serialization to and from rapidjson::Document and a UTF-8 encoded string
        void PerformSerializationChecks()
        {
            // Generate a canonical serializaed representation of this document using rapidjson
            // This will be pretty-printed using the same rapidjson pretty printer we use, so should be binary identical
            // to any output generated by the visitor API
            AZStd::string canonicalSerializedDocument;
            AZ::JsonSerializationUtils::WriteJsonString(*m_document, canonicalSerializedDocument);
            auto visitDocumentFn = [this](AZ::Dom::Visitor& visitor)
            {
                return Json::VisitRapidJsonValue(*m_document, visitor, Lifetime::Temporary);
            };
            // Document -> Document
            {
                auto result = Json::WriteToRapidJsonDocument(visitDocumentFn);
                EXPECT_TRUE(result.IsSuccess());
                EXPECT_EQ(AZ::JsonSerialization::Compare(*m_document, result.GetValue()), AZ::JsonSerializerCompareResult::Equal);
            }
            // Document -> string
            {
                AZStd::string serializedDocument;
                JsonBackend backend;
                auto result = backend.WriteToBuffer(serializedDocument, visitDocumentFn);
                EXPECT_TRUE(result.IsSuccess());
                EXPECT_EQ(canonicalSerializedDocument, serializedDocument);
            }
            // string -> Document
            {
                auto result = Json::WriteToRapidJsonDocument(
                    [&canonicalSerializedDocument](AZ::Dom::Visitor& visitor)
                    {
                        JsonBackend backend;
                        return Dom::Utils::ReadFromString(backend, canonicalSerializedDocument, Lifetime::Temporary, visitor);
                    });
                EXPECT_TRUE(result.IsSuccess());
                EXPECT_EQ(AZ::JsonSerialization::Compare(*m_document, result.GetValue()), JsonSerializerCompareResult::Equal);
            }
            // string -> string
            {
                AZStd::string serializedDocument;
                JsonBackend backend;
                auto result = backend.WriteToBuffer(
                    serializedDocument,
                    [&backend, &canonicalSerializedDocument](AZ::Dom::Visitor& visitor)
                    {
                        return Dom::Utils::ReadFromString(backend, canonicalSerializedDocument, Lifetime::Temporary, visitor);
                    });
                EXPECT_TRUE(result.IsSuccess());
                EXPECT_EQ(canonicalSerializedDocument, serializedDocument);
            }
        }
        AZStd::unique_ptr<rapidjson::Document> m_document;
    };
    TEST_F(DomJsonTests, EmptyArray)
    {
        m_document->SetArray();
        PerformSerializationChecks();
    }
    TEST_F(DomJsonTests, SimpleArray)
    {
        m_document->SetArray();
        for (int i = 0; i < 5; ++i)
        {
            m_document->PushBack(i, m_document->GetAllocator());
        }
        PerformSerializationChecks();
    }
    TEST_F(DomJsonTests, NestedArrays)
    {
        m_document->SetArray();
        for (int j = 0; j < 7; ++j)
        {
            rapidjson::Value nestedArray(rapidjson::kArrayType);
            for (int i = 0; i < 5; ++i)
            {
                nestedArray.PushBack(i, m_document->GetAllocator());
            }
            m_document->PushBack(nestedArray.Move(), m_document->GetAllocator());
        }
        PerformSerializationChecks();
    }
    TEST_F(DomJsonTests, EmptyObject)
    {
        m_document->SetObject();
        PerformSerializationChecks();
    }
    TEST_F(DomJsonTests, SimpleObject)
    {
        m_document->SetObject();
        for (int i = 0; i < 5; ++i)
        {
            m_document->AddMember(CreateString(AZStd::string::format("Key%i", i)), rapidjson::Value(i), m_document->GetAllocator());
        }
        PerformSerializationChecks();
    }
    TEST_F(DomJsonTests, NestedObjects)
    {
        m_document->SetObject();
        for (int j = 0; j < 7; ++j)
        {
            rapidjson::Value nestedObject(rapidjson::kObjectType);
            for (int i = 0; i < 5; ++i)
            {
                nestedObject.AddMember(CreateString(AZStd::string::format("Key%i", i)), rapidjson::Value(i), m_document->GetAllocator());
            }
            m_document->AddMember(CreateString(AZStd::string::format("Obj%i", j)), nestedObject.Move(), m_document->GetAllocator());
        }
        PerformSerializationChecks();
    }
    TEST_F(DomJsonTests, Int64)
    {
        m_document->SetObject();
        AddValue("int64_min", AZStd::numeric_limits<int64_t>::min());
        AddValue("int64_max", AZStd::numeric_limits<int64_t>::max());
        PerformSerializationChecks();
    }
    TEST_F(DomJsonTests, Uint64)
    {
        m_document->SetObject();
        AddValue("uint64_min", AZStd::numeric_limits<uint64_t>::min());
        AddValue("uint64_max", AZStd::numeric_limits<uint64_t>::max());
        PerformSerializationChecks();
    }
    TEST_F(DomJsonTests, Double)
    {
        m_document->SetObject();
        AddValue("double_min", AZStd::numeric_limits<double>::min());
        AddValue("double_max", AZStd::numeric_limits<double>::max());
        PerformSerializationChecks();
    }
    TEST_F(DomJsonTests, Null)
    {
        m_document->SetObject();
        m_document->AddMember(CreateString("null_value"), rapidjson::Value(rapidjson::kNullType), m_document->GetAllocator());
        PerformSerializationChecks();
    }
    TEST_F(DomJsonTests, Bool)
    {
        m_document->SetObject();
        AddValue("true_value", true);
        AddValue("false_value", false);
        PerformSerializationChecks();
    }
    TEST_F(DomJsonTests, String)
    {
        m_document->SetObject();
        m_document->AddMember(CreateString("empty_string"), CreateString(""), m_document->GetAllocator());
        m_document->AddMember(CreateString("short_string"), CreateString("test"), m_document->GetAllocator());
        m_document->AddMember(
            CreateString("long_string"), CreateString("abcdefghijklmnopqrstuvwxyz0123456789"), m_document->GetAllocator());
        PerformSerializationChecks();
    }
} // namespace AZ::Dom::Tests
 
 | 
					
	;------------------------------------------------------------------------------
;
; 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:
;
;   SetMem.nasm
;
; Abstract:
;
;   SetMem function
;
; Notes:
;
;------------------------------------------------------------------------------
    DEFAULT REL
    SECTION .text
;------------------------------------------------------------------------------
;  VOID *
;  InternalMemSetMem (
;    IN VOID   *Buffer,
;    IN UINTN  Count,
;    IN UINT8  Value
;    )
;------------------------------------------------------------------------------
global ASM_PFX(InternalMemSetMem)
ASM_PFX(InternalMemSetMem):
    push    rdi
    mov     rdi, rcx                    ; rdi <- Buffer
    mov     al, r8b                     ; al <- Value
    mov     r9, rdi                     ; r9 <- Buffer as return value
    xor     rcx, rcx
    sub     rcx, rdi
    and     rcx, 15                     ; rcx + rdi aligns on 16-byte boundary
    jz      .0
    cmp     rcx, rdx
    cmova   rcx, rdx
    sub     rdx, rcx
    rep     stosb
.0:
    mov     rcx, rdx
    and     rdx, 15
    shr     rcx, 4
    jz      @SetBytes
    mov     ah, al                      ; ax <- Value repeats twice
    movdqa  [rsp + 0x10], xmm0           ; save xmm0
    movd    xmm0, eax                   ; xmm0[0..16] <- Value repeats twice
    pshuflw xmm0, xmm0, 0               ; xmm0[0..63] <- Value repeats 8 times
    movlhps xmm0, xmm0                  ; xmm0 <- Value repeats 16 times
.1:
    movntdq [rdi], xmm0                 ; rdi should be 16-byte aligned
    add     rdi, 16
    loop    .1
    mfence
    movdqa  xmm0, [rsp + 0x10]           ; restore xmm0
@SetBytes:
    mov     ecx, edx                    ; high 32 bits of rcx are always zero
    rep     stosb
    mov     rax, r9                     ; rax <- Return value
    pop     rdi
    ret
 
 | 
					
	;;
;; Copyright (c) 2012-2018, Intel Corporation
;;
;; Redistribution and use in source and binary forms, with or without
;; modification, are permitted provided that the following conditions are met:
;;
;;     * Redistributions of source code must retain the above copyright notice,
;;       this list of conditions and the following disclaimer.
;;     * Redistributions in binary form must reproduce the above copyright
;;       notice, this list of conditions and the following disclaimer in the
;;       documentation and/or other materials provided with the distribution.
;;     * Neither the name of Intel Corporation nor the names of its contributors
;;       may be used to endorse or promote products derived from this software
;;       without specific prior written permission.
;;
;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
;; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
;; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
;; DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
;; FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
;; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
;; SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
;; CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
;; OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
;; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
;;
%include "include/os.asm"
%include "job_aes_hmac.asm"
%include "mb_mgr_datastruct.asm"
%include "include/reg_sizes.asm"
;%define DO_DBGPRINT
%include "include/dbgprint.asm"
extern sha1_mult_sse
section .data
default rel
align 16
byteswap:	;ddq 0x0c0d0e0f08090a0b0405060700010203
	dq 0x0405060700010203, 0x0c0d0e0f08090a0b
x80:    ;ddq 0x00000000000000000000000000000080
        dq 0x0000000000000080, 0x0000000000000000
x00:    ;ddq 0x00000000000000000000000000000000
        dq 0x0000000000000000, 0x0000000000000000
len_masks:
	;ddq 0x0000000000000000000000000000FFFF
	dq 0x000000000000FFFF, 0x0000000000000000
	;ddq 0x000000000000000000000000FFFF0000
	dq 0x00000000FFFF0000, 0x0000000000000000
	;ddq 0x00000000000000000000FFFF00000000
	dq 0x0000FFFF00000000, 0x0000000000000000
	;ddq 0x0000000000000000FFFF000000000000
	dq 0xFFFF000000000000, 0x0000000000000000
one:	dq  1
two:	dq  2
three:	dq  3
section .text
%if 1
%ifdef LINUX
%define arg1	rdi
%define arg2	rsi
%else
%define arg1	rcx
%define arg2	rdx
%endif
%define state	arg1
%define job	arg2
%define len2	arg2
; idx needs to be in rbx, rbp, r12-r15
%define idx             rbp
%define unused_lanes    rbx
%define lane_data       rbx
%define tmp2		rbx
%define job_rax         rax
%define	tmp1		rax
%define size_offset     rax
%define tmp             rax
%define start_offset    rax
%define tmp3		arg1
%define extra_blocks    arg2
%define p               arg2
%define tmp4		r8
%endif
; This routine clobbers rbx, rbp
struc STACK
_gpr_save:	resq	2
_rsp_save:	resq	1
endstruc
%define APPEND(a,b) a %+ b
; JOB* flush_job_hmac_sse(MB_MGR_HMAC_SHA_1_OOO *state)
; arg 1 : state
MKGLOBAL(flush_job_hmac_sse,function,internal)
flush_job_hmac_sse:
        mov	rax, rsp
        sub	rsp, STACK_size
        and	rsp, -16
	mov	[rsp + _gpr_save + 8*0], rbx
	mov	[rsp + _gpr_save + 8*1], rbp
	mov	[rsp + _rsp_save], rax	; original SP
         DBGPRINTL "enter sha1-sse flush"
	mov	unused_lanes, [state + _unused_lanes]
	bt	unused_lanes, 32+7
	jc	return_null
	; find a lane with a non-null job
	xor	idx, idx
	cmp	qword [state + _ldata + 1 * _HMAC_SHA1_LANE_DATA_size + _job_in_lane], 0
	cmovne	idx, [rel one]
	cmp	qword [state + _ldata + 2 * _HMAC_SHA1_LANE_DATA_size + _job_in_lane], 0
	cmovne	idx, [rel two]
	cmp	qword [state + _ldata + 3 * _HMAC_SHA1_LANE_DATA_size + _job_in_lane], 0
	cmovne	idx, [rel three]
copy_lane_data:
	; copy valid lane (idx) to empty lanes
	movdqa	xmm0, [state + _lens]
	mov	tmp, [state + _args_data_ptr + PTR_SZ*idx]
%assign I 0
%rep 4
	cmp	qword [state + _ldata + I * _HMAC_SHA1_LANE_DATA_size + _job_in_lane], 0
	jne	APPEND(skip_,I)
	mov	[state + _args_data_ptr + PTR_SZ*I], tmp
	por	xmm0, [rel len_masks + 16*I]
APPEND(skip_,I):
%assign I (I+1)
%endrep
	movdqa	[state + _lens], xmm0
	phminposuw	xmm1, xmm0
	pextrw	len2, xmm1, 0	; min value
	pextrw	idx, xmm1, 1	; min index (0...3)
	cmp	len2, 0
	je	len_is_0
	pshuflw	xmm1, xmm1, 0
	psubw	xmm0, xmm1
	movdqa	[state + _lens], xmm0
	; "state" and "args" are the same address, arg1
	; len is arg2
	call	sha1_mult_sse
	; state is intact
len_is_0:
	; process completed job "idx"
	imul	lane_data, idx, _HMAC_SHA1_LANE_DATA_size
	lea	lane_data, [state + _ldata + lane_data]
	mov	DWORD(extra_blocks), [lane_data + _extra_blocks]
	cmp	extra_blocks, 0
	jne	proc_extra_blocks
	cmp	dword [lane_data + _outer_done], 0
	jne	end_loop
proc_outer:
	mov	dword [lane_data + _outer_done], 1
	mov	DWORD(size_offset), [lane_data + _size_offset]
	mov	qword [lane_data + _extra_block + size_offset], 0
	mov	word [state + _lens + 2*idx], 1
	lea	tmp, [lane_data + _outer_block]
	mov	job, [lane_data + _job_in_lane]
	mov	[state + _args_data_ptr + PTR_SZ*idx], tmp
        ;; idx determines which column
        ;; read off from consecutive rows
	movd	xmm0, [state + _args_digest + SHA1_DIGEST_WORD_SIZE*idx + 0*SHA1_DIGEST_ROW_SIZE]
	pinsrd	xmm0, [state + _args_digest + SHA1_DIGEST_WORD_SIZE*idx + 1*SHA1_DIGEST_ROW_SIZE], 1
	pinsrd	xmm0, [state + _args_digest + SHA1_DIGEST_WORD_SIZE*idx + 2*SHA1_DIGEST_ROW_SIZE], 2
	pinsrd	xmm0, [state + _args_digest + SHA1_DIGEST_WORD_SIZE*idx + 3*SHA1_DIGEST_ROW_SIZE], 3
	pshufb	xmm0, [rel byteswap]
	mov	DWORD(tmp),  [state + _args_digest + SHA1_DIGEST_WORD_SIZE*idx + 4*SHA1_DIGEST_ROW_SIZE]
	bswap	DWORD(tmp)
	movdqa	[lane_data + _outer_block], xmm0
	mov	[lane_data + _outer_block + 4*4], DWORD(tmp)
        DBGPRINTL_XMM "sha1 outer hash input words[0-3]", xmm0
        DBGPRINTL64 "sha1 outer hash input word 4", tmp
	mov	tmp, [job + _auth_key_xor_opad]
	movdqu	xmm0, [tmp]
	mov	DWORD(tmp),  [tmp + 4*4]
	movd	[state + _args_digest + SHA1_DIGEST_WORD_SIZE*idx + 0*SHA1_DIGEST_ROW_SIZE], xmm0
	pextrd	[state + _args_digest + SHA1_DIGEST_WORD_SIZE*idx + 1*SHA1_DIGEST_ROW_SIZE], xmm0, 1
	pextrd	[state + _args_digest + SHA1_DIGEST_WORD_SIZE*idx + 2*SHA1_DIGEST_ROW_SIZE], xmm0, 2
	pextrd	[state + _args_digest + SHA1_DIGEST_WORD_SIZE*idx + 3*SHA1_DIGEST_ROW_SIZE], xmm0, 3
	mov	[state + _args_digest + SHA1_DIGEST_WORD_SIZE*idx + 4*SHA1_DIGEST_ROW_SIZE], DWORD(tmp)
	jmp	copy_lane_data
	align	16
proc_extra_blocks:
	mov	DWORD(start_offset), [lane_data + _start_offset]
	mov	[state + _lens + 2*idx], WORD(extra_blocks)
	lea	tmp, [lane_data + _extra_block + start_offset]
	mov	[state + _args_data_ptr + PTR_SZ*idx], tmp
	mov	dword [lane_data + _extra_blocks], 0
	jmp	copy_lane_data
return_null:
	xor	job_rax, job_rax
	jmp	return
	align	16
end_loop:
	mov	job_rax, [lane_data + _job_in_lane]
	mov	qword [lane_data + _job_in_lane], 0
	or	dword [job_rax + _status], STS_COMPLETED_HMAC
	mov	unused_lanes, [state + _unused_lanes]
	shl	unused_lanes, 8
	or	unused_lanes, idx
	mov	[state + _unused_lanes], unused_lanes
	mov	p, [job_rax + _auth_tag_output]
	; copy 12 bytes
	mov	DWORD(tmp2), [state + _args_digest + SHA1_DIGEST_WORD_SIZE*idx + 0*SHA1_DIGEST_ROW_SIZE]
	mov	DWORD(tmp4), [state + _args_digest + SHA1_DIGEST_WORD_SIZE*idx + 1*SHA1_DIGEST_ROW_SIZE]
	bswap	DWORD(tmp2)
	bswap	DWORD(tmp4)
	mov	[p + 0*4], DWORD(tmp2)
	mov	[p + 1*4], DWORD(tmp4)
	mov	DWORD(tmp2), [state + _args_digest + SHA1_DIGEST_WORD_SIZE*idx + 2*SHA1_DIGEST_ROW_SIZE]
	bswap	DWORD(tmp2)
	mov	[p + 2*4], DWORD(tmp2)
        cmp     qword [job_rax + _auth_tag_output_len_in_bytes], 12
        je      return
        ;; copy remaining 8 bytes to return 20 byte digest
        mov	DWORD(tmp2),  [state + _args_digest + SHA1_DIGEST_WORD_SIZE*idx + 3*SHA1_DIGEST_ROW_SIZE]
        mov	DWORD(tmp4), [state + _args_digest + SHA1_DIGEST_WORD_SIZE*idx + 4*SHA1_DIGEST_ROW_SIZE]
        bswap	DWORD(tmp2)
        bswap	DWORD(tmp4)
        mov	[p + 3*SHA1_DIGEST_WORD_SIZE], DWORD(tmp2)
        mov	[p + 4*SHA1_DIGEST_WORD_SIZE], DWORD(tmp4)
return:
	mov	rbx, [rsp + _gpr_save + 8*0]
	mov	rbp, [rsp + _gpr_save + 8*1]
	mov	rsp, [rsp + _rsp_save]	; original SP
	ret
%ifdef LINUX
section .note.GNU-stack noalloc noexec nowrite progbits
%endif
 
 | 
					
		TITLE	LOCK ROUTINES - Routines for file locking
	NAME	LOCK
;
;	Microsoft Confidential
;	Copyright (C) Microsoft Corporation 1991
;	All Rights Reserved.
;
;**	LOCK.ASM - File Locking Routines
;
;	LOCK_CHECK
;	LOCK_VIOLATION
;	$LockOper
;
;	Revision history:
;	  A000	 version 4.00	Jan. 1988
	.xlist
	.xcref
	include version.inc
	include dosseg.inc
	INCLUDE DOSSYM.INC
	INCLUDE DEVSYM.INC
	include lock.inc
	include mult.inc
	include dpb.inc
	include sf.inc
	.cref
	.list
AsmVars <IBM, Installed>
Installed = TRUE
	i_need	THISSFT,DWORD
	i_need	THISDPB,DWORD
	i_need	EXTERR,WORD
	i_need	ALLOWED,BYTE
	i_need	RetryCount,WORD
	I_need	fShare,BYTE
	I_Need	EXTERR_LOCUS,BYTE	; Extended Error Locus
	i_need	JShare,DWORD
	i_need	Lock_Buffer,DWORD	; DOS 4.00
	i_need	Temp_Var,WORD		; DOS 4.00
DOSCODE SEGMENT
	allow_getdseg
	ASSUME	SS:DOSDATA,CS:DOSCODE
BREAK <$LockOper - Lock Calls>
;
;   Assembler usage:
;	    MOV     BX, Handle	       (DOS 3.3)
;	    MOV     CX, OffsetHigh
;	    MOV     DX, OffsetLow
;	    MOV     SI, LengthHigh
;	    MOV     DI, LengthLow
;	    MOV     AH, LockOper
;	    MOV     AL, Request
;	    INT     21h
;
;   Error returns:
;	    AX = error_invalid_handle
;	       = error_invalid_function
;	       = error_lock_violation
;
;   Assembler usage:
;	    MOV     AX, 5C??	       (DOS 4.00)
;
;				    0? lock all
;				    8? lock write
;				    ?2 lock multiple
;				    ?3 unlock multiple
;				    ?4 lock/read
;				    ?5 write/unlock
;				    ?6 add (lseek EOF/lock/write/unlock)
;	    MOV     BX, Handle
;	    MOV     CX, count or size
;	    LDS     DX, buffer
;	    INT     21h
;
;   Error returns:
;	    AX = error_invalid_handle
;	       = error_invalid_function
;	       = error_lock_violation
	procedure   $LockOper,NEAR
	CMP	AL,1
	JA	lock_bad_func
	PUSH	DI			       ; Save LengthLow
	invoke	SFFromHandle		       ; ES:DI -> SFT
	JNC	lock_do 		       ; have valid handle
	POP	DI			       ; Clean stack
	error	error_invalid_handle
lock_bad_func:
	MOV	EXTERR_LOCUS,errLoc_Unk        ; Extended Error Locus;smr;SS Override
	error	error_invalid_function
; Align_buffer call has been deleted, since it corrupts the DTA  (6/5/88) P5013
; Dead code deleted, MD, 23 Mar 90
lock_do:
	MOV	BX,AX				; save AX
	MOV	BP, OFFSET DOSDATA:Lock_Buffer	; get DOS LOCK buffer
	MOV	WORD PTR [BP.Lock_position],DX	; set low offset
	MOV	WORD PTR [BP.Lock_position+2],CX; set high offset
	POP	CX				; get low length
	MOV	WORD PTR [BP.Lock_length],CX	; set low length
	MOV	WORD PTR [BP.Lock_length+2],SI	; set high length
	MOV	CX,1				; one range
;;	PUSH	CS				;
;;	POP	DS				; DS:DX points to
	Context	<ds>
	MOV	DX,BP				;   Lock_Buffer
	TEST	AL,Unlock_all			; function 1
	JNZ	DOS_Unlock			; yes
	JMP	short DOS_Lock			; function 0
DOS_Unlock:
	TESTB	ES:[DI].SF_FLAGS,sf_isnet
	JZ	LOCAL_UNLOCK
	CallInstall Net_Xlock,multNet,10
	JMP	SHORT ValChk
LOCAL_UNLOCK:
if installed
	Call	JShare + 7 * 4					;smr;SS Override
else
	Call	clr_block					;PBUGBUG
endif
ValChk:
	JNC	Lock_OK
lockerror:
	transfer SYS_RET_ERR
Lock_OK:
	MOV	AX,[Temp_VAR]			 ;AN000;;MS. AX= number of bytes;smr;SS Override
	transfer SYS_Ret_OK
DOS_Lock:
	TESTB	ES:[DI].SF_FLAGS,sf_isnet
	JZ	LOCAL_LOCK
	CallInstall NET_XLock,multNet,10
	JMP	ValChk
LOCAL_LOCK:
if installed
	Call	JShare + 6 * 4					;smr;SS Override
else
	Call	Set_Block					;PBUGBUG
endif
	JMP	ValChk
EndProc $LockOper
; Inputs:
;	Outputs of SETUP
;	[USER_ID] Set
;	[PROC_ID] Set
; Function:
;	Check for lock violations on local I/O
;	Retries are attempted with sleeps in between
; Outputs:
;    Carry clear
;	Operation is OK
;    Carry set
;	A lock violation detected
; Outputs of SETUP preserved
procedure   LOCK_CHECK,NEAR
	DOSAssume   <DS>,"Lock_Check"
	MOV	BX,RetryCount		; Number retries
LockRetry:
	SAVE	<BX,AX> 		; save regs
if installed
	call	JShare + 8 * 4
else
	Call	chk_block					;PBUGBUG
endif
	RESTORE <AX,BX> 	; restrore regs
	jnc	ret_label	; There are no locks (retnc)
	Invoke	Idle		; wait a while
	DEC	BX		; remember a retry
	JNZ	LockRetry	; more retries left...
	STC
ret_label:
	return
EndProc LOCK_CHECK
; Inputs:
;	[THISDPB] set
;	[READOP] indicates whether error on read or write
; Function:
;	Handle Lock violation on compatibility (FCB) mode SFTs
; Outputs:
;	Carry set if user says FAIL, causes error_lock_violation
;	Carry clear if user wants a retry
;
; DS, ES, DI, CX preserved, others destroyed
procedure   LOCK_VIOLATION,NEAR
	DOSAssume   <DS>,"Lock_Violation"
	PUSH	DS
	PUSH	ES
	PUSH	DI
	PUSH	CX
	MOV	AX,error_lock_violation
	MOV	[ALLOWED],allowed_FAIL + allowed_RETRY
	LES	BP,[THISDPB]
	MOV	DI,1				; Fake some registers
	MOV	CX,DI
	MOV	DX,ES:[BP.dpb_first_sector]
	invoke	HARDERR
	POP	CX
	POP	DI
	POP	ES
	POP	DS
	CMP	AL,1
	retz			; 1 = retry, carry clear
	STC
	return
EndProc LOCK_VIOLATION
IF  INSTALLED
;	do a retz to return error
Procedure   CheckShare,NEAR
	ASSUME	CS:DOSCODE,SS:NOTHING
	push	ds					;smr;
	getdseg	<ds>			; ds -> dosdata
	CMP     fShare,0
	pop	ds					;smr;
	ASSUME	DS:NOTHING				;smr;
	return
EndProc CheckShare
ENDIF
DOSCODE	ENDS
	END
 
 | 
					
	#include <SigInt.h>
#include "FrameFeeder.h"
#include "StateMachine.h"
#include "boost/program_options.hpp"
using namespace std;
namespace po = boost::program_options;
//Fucntion definitions
unique_ptr<FrameFeeder> createFrameFeeder(FrameSource srcMode, string srcString);
int main(int argc, char* argv[]) /**
	This is the entry point of the application.
	- Initialises the sigInit handler
	- Creates a stateMachine and spins it until user issues a quit signal through the sigInit handler.
	*/
{
	int lReturn 	= 0;
	FrameSource 	lFrameSource;
	std::string 	lSourceStr;
	// Prsing command line options
	{
	  po::options_description	lDesc("Options");
	  lDesc.add_options()
	  ("help,h",
			"\t produces help message")
	  ("Mode,m",
			po::value<FrameSource>(&lFrameSource)->default_value(FrameSource::DIRECTORY),
			"\t selects frame input mode")
	  ("Source,s",
			po::value<string>(&lSourceStr)->default_value("DataSet"),
			"\t provides source configuration");
	  po::variables_map vMap;
	  po::store(po::parse_command_line(argc, argv, lDesc), vMap);
	  po::notify(vMap);
	  if ( vMap.count("help") )
	  {
 	     cout << lDesc <<endl;
	     cout << "	Valid arguments for 'Mode': ";
	     cout << "["<<FrameSource::DIRECTORY<<" ";
	     cout <<FrameSource::STREAM<<" ";
	     cout <<FrameSource::GMSL<<"]";
	     cout <<endl<<endl<< "	Examples:"<<endl;
	     cout<< "	./TUeLaneTracker -m " << FrameSource::DIRECTORY << " -s " << "/home/DataSet" <<endl;
	     cout<<endl<<endl;
	     lReturn = 1;
	  }
	} // End parsing command line options
	unique_ptr<LaneTracker::Config> lPtrConfig;
	if (lReturn == 0) //create Configuration
	{
	  lPtrConfig.reset(new LaneTracker::Config);
	  if(lPtrConfig == nullptr)
	  {
	    lReturn = -1;
	  }
	}
	unique_ptr<FrameFeeder> lPtrFeeder;
	if (lReturn == 0) //create FrameFeeder
	{
	  lPtrFeeder = createFrameFeeder(lFrameSource, lSourceStr);
	  if(lPtrFeeder == nullptr)
	  {
	    lReturn = -1;
	  }
	}
	shared_ptr<SigInt> lPtrSigInt;
	if(lReturn == 0) //create SigInt
	{
	  lPtrSigInt = make_shared<SigInt>();
	  if(lPtrSigInt->sStatus == SigStatus::FAILURE)
	  {
	    lReturn = -1;
	  }
	}
	unique_ptr<StateMachine> lPtrStateMachine;
	if (lReturn==0) //create StateMachine
	{
	  std::cout<<endl<<endl;
	  std::cout<<"******************************"<<std::endl;
	  std::cout<<" Press Ctrl + c to terminate."<<std::endl;
	  std::cout<<"******************************"<<std::endl;
	  try
	  {
	       lPtrStateMachine.reset( new StateMachine( move(lPtrFeeder), *lPtrConfig.get() ) );
	  }
	  catch(const char* msg)
	  {
		cout<<"******************************"<<endl
		<<"Failed to create the StateMachine!"<<endl
		<< msg <<endl
		<<"******************************"<<endl<<endl;
		lReturn =-1;
	  }
	  catch(...)
	  {
		lReturn = -1;
	  }
	}
	States lPreviousState;
	if (lReturn ==0) //Get current State of the stateMachine
	{
	  cout<<lPtrStateMachine->getCurrentState();
	  lPreviousState = lPtrStateMachine->getCurrentState();
	}
    if(lReturn == 0) //spin the stateMachine
    {
       uint64_t        lCyclesCount = 0;
       ProfilerLDT     lProfiler;
       StateMachine&   stateMachine = *lPtrStateMachine.get();
       while (stateMachine.getCurrentState() != States::DISPOSED)
	   {
	     lProfiler.start("StateMachine_Cycle");
	     if (lPtrSigInt->sStatus == SigStatus::STOP)
	      stateMachine.quit();
	     lReturn = stateMachine.spin();
	     lCyclesCount ++;
	     lProfiler.end();
	     if(lPreviousState != stateMachine.getCurrentState())
	     {
	       cout<<endl<<stateMachine.getCurrentState();
	       std::cout.flush();
	       lPreviousState = stateMachine.getCurrentState();
	     }
	     else if (lCyclesCount%100==0)
	     {
	       cout <<endl<<stateMachine.getCurrentState();
	       cout <<"state cycle-count = " << lCyclesCount<<"    Cycle-Time [Min, Avg, Max] : "
	       <<"[ "<<lProfiler.getMinTime("StateMachine_Cycle")<<" "
	       <<lProfiler.getAvgTime("StateMachine_Cycle")<<" "
	       <<lProfiler.getMaxTime("StateMachine_Cycle")<<" "
	       <<" ]";
	     }
	   }// End spinning
    }
    lPtrStateMachine.reset( nullptr);
	cout<<endl<<"The program ended with exit code " <<lReturn<<endl;
	return(lReturn);
}
unique_ptr<FrameFeeder> createFrameFeeder(FrameSource srcMode, string srcString)
{
	unique_ptr<FrameFeeder>	lPtrFeeder;
	/** Create Image Feeder */
	try
	{
	  switch(srcMode)
	  {
            case DIRECTORY:
               lPtrFeeder=  unique_ptr<FrameFeeder>( new ImgStoreFeeder(srcString) );
               break;
            case STREAM:
              lPtrFeeder=  unique_ptr<FrameFeeder>( new StreamFeeder(srcString) );
              break;
            case GMSL:
              throw "NOT IMPLEMENTED";
              break;
	  }
	}
	catch(const char* msg)
	{
	    cout<<"******************************"<<endl
	    <<"Failed to create the FrameFeeder!"<<endl
	    << msg <<endl
	    <<"******************************"<<endl<<endl;
	    lPtrFeeder = nullptr;
	}
	catch (...)
	{
	    cout<<"******************************"<<endl
	    <<"Failed to create the FrameFeeder!"<<endl
	    << "Unknown exception"<<endl
	    <<"******************************"<<endl<<endl;
	   lPtrFeeder = nullptr;
	}
	return lPtrFeeder;
}
 
 | 
					
	SilphCo7Object:
	db $2e ; border block
	db $6 ; warps
	db $0, $10, $1, SILPH_CO_8F
	db $0, $16, $0, SILPH_CO_6F
	db $0, $12, $0, SILPH_CO_ELEVATOR
	db $7, $5, $3, SILPH_CO_11F
	db $3, $5, $8, SILPH_CO_3F
	db $f, $15, $3, SILPH_CO_5F
	db $0 ; signs
	db $b ; objects
	object SPRITE_LAPRAS_GIVER, $1, $5, STAY, NONE, $1 ; person
	object SPRITE_LAPRAS_GIVER, $d, $d, STAY, UP, $2 ; person
	object SPRITE_LAPRAS_GIVER, $7, $a, STAY, NONE, $3 ; person
	object SPRITE_ERIKA, $a, $8, STAY, NONE, $4 ; person
	object SPRITE_ROCKET, $d, $1, STAY, DOWN, $5, OPP_ROCKET, $20
	object SPRITE_OAK_AIDE, $2, $d, STAY, DOWN, $6, OPP_SCIENTIST, $8
	object SPRITE_ROCKET, $14, $2, STAY, LEFT, $7, OPP_ROCKET, $21
	object SPRITE_ROCKET, $13, $e, STAY, RIGHT, $8, OPP_ROCKET, $22
	object SPRITE_BLUE, $3, $7, STAY, UP, $9 ; person
	object SPRITE_BALL, $1, $9, STAY, NONE, $a, CALCIUM
	object SPRITE_BALL, $18, $b, STAY, NONE, $b, TM_03
	; warp-to
	EVENT_DISP SILPH_CO_7F_WIDTH, $0, $10 ; SILPH_CO_8F
	EVENT_DISP SILPH_CO_7F_WIDTH, $0, $16 ; SILPH_CO_6F
	EVENT_DISP SILPH_CO_7F_WIDTH, $0, $12 ; SILPH_CO_ELEVATOR
	EVENT_DISP SILPH_CO_7F_WIDTH, $7, $5 ; SILPH_CO_11F
	EVENT_DISP SILPH_CO_7F_WIDTH, $3, $5 ; SILPH_CO_3F
	EVENT_DISP SILPH_CO_7F_WIDTH, $f, $15 ; SILPH_CO_5F
 
 | 
					
	# $Id: 14_beq_4.asm,v 1.3 2001/03/22 00:39:00 ellard Exp $
#
# Copyright 1999-2001 by the President and Fellows of Harvard College.
# See LICENSE.txt for license information.
#
#@ test of beq.
# OK
	lc r2, $eq
	lc r3, 10
	lc r4, 11
	beq r2, r3, r4
	add r5, r1, r0
	hlt
eq:
	lc r6, 10
	hlt
 
 | 
					
	; A112689: A modified Chebyshev transform of the Jacobsthal numbers.
; 0,1,1,0,1,2,1,1,2,2,2,2,2,3,3,2,3,4,3,3,4,4,4,4,4,5,5,4,5,6,5,5,6,6,6,6,6,7,7,6,7,8,7,7,8,8,8,8,8,9,9,8,9,10,9,9,10,10,10,10,10,11,11,10,11,12,11,11,12,12,12,12,12,13,13,12,13,14,13,13,14,14,14,14,14,15,15,14,15,16,15,15,16,16,16,16,16,17,17,16
mul $0,2
lpb $0
  mov $2,$0
  trn $0,8
  mod $2,6
  mov $3,$2
  min $3,1
  add $1,$3
lpe
mov $0,$1
 
 | 
					
	.global s_prepare_buffers
s_prepare_buffers:
push %r14
push %r15
push %r8
push %rax
push %rbp
push %rcx
push %rdi
push %rsi
lea addresses_WT_ht+0x18945, %rsi
lea addresses_WC_ht+0x7cd7, %rdi
nop
nop
nop
nop
nop
inc %rax
mov $34, %rcx
rep movsb
nop
nop
nop
and $32312, %rdi
lea addresses_WT_ht+0x12f45, %r8
nop
nop
nop
nop
and %rbp, %rbp
mov $0x6162636465666768, %r15
movq %r15, (%r8)
nop
nop
nop
nop
xor %r15, %r15
lea addresses_WC_ht+0x8ec5, %rcx
clflush (%rcx)
nop
nop
dec %rax
mov $0x6162636465666768, %r15
movq %r15, (%rcx)
nop
dec %rax
lea addresses_A_ht+0x7fcd, %rcx
nop
nop
nop
inc %r15
movw $0x6162, (%rcx)
add %rcx, %rcx
lea addresses_WC_ht+0x1c52d, %rax
nop
nop
nop
nop
lfence
movl $0x61626364, (%rax)
nop
nop
nop
nop
nop
dec %rax
lea addresses_UC_ht+0xa199, %rsi
nop
nop
nop
nop
nop
dec %rdi
mov $0x6162636465666768, %r8
movq %r8, (%rsi)
nop
nop
nop
nop
sub %r8, %r8
lea addresses_normal_ht+0x172f9, %rsi
lea addresses_normal_ht+0x9335, %rdi
nop
nop
nop
nop
nop
xor %r14, %r14
mov $52, %rcx
rep movsb
nop
inc %r14
lea addresses_normal_ht+0xfa2d, %rsi
lea addresses_UC_ht+0xc7cb, %rdi
nop
and %r8, %r8
mov $65, %rcx
rep movsl
nop
nop
nop
nop
nop
cmp $48518, %rcx
lea addresses_UC_ht+0x18217, %rsi
and %rcx, %rcx
mov (%rsi), %r8
nop
and %rcx, %rcx
lea addresses_UC_ht+0x2bcb, %rbp
xor $13710, %r8
mov $0x6162636465666768, %r15
movq %r15, %xmm0
movups %xmm0, (%rbp)
nop
sub $56631, %rsi
lea addresses_WC_ht+0x1be45, %rax
nop
nop
nop
dec %rsi
movl $0x61626364, (%rax)
nop
nop
inc %rbp
lea addresses_normal_ht+0x10d45, %r14
nop
nop
nop
nop
nop
sub $46356, %rbp
mov (%r14), %eax
nop
nop
nop
cmp $61686, %r14
lea addresses_normal_ht+0x1b545, %rsi
lea addresses_UC_ht+0x1785, %rdi
xor %rax, %rax
mov $70, %rcx
rep movsq
sub %rax, %rax
lea addresses_WC_ht+0x5785, %rsi
lea addresses_WC_ht+0x1442f, %rdi
clflush (%rsi)
xor %r8, %r8
mov $103, %rcx
rep movsw
nop
nop
nop
xor $31600, %rbp
pop %rsi
pop %rdi
pop %rcx
pop %rbp
pop %rax
pop %r8
pop %r15
pop %r14
ret
    .global s_faulty_load
s_faulty_load:
push %r13
push %r15
push %r8
push %rbx
push %rdi
push %rdx
// Faulty Load
lea addresses_UC+0x17945, %r13
nop
add $14489, %r15
movb (%r13), %bl
lea oracles, %rdx
and $0xff, %rbx
shlq $12, %rbx
mov (%rdx,%rbx,1), %rbx
pop %rdx
pop %rdi
pop %rbx
pop %r8
pop %r15
pop %r13
ret
/*
<gen_faulty_load>
[REF]
{'src': {'NT': False, 'same': False, 'congruent': 0, 'type': 'addresses_UC', 'AVXalign': False, 'size': 16}, 'OP': 'LOAD'}
[Faulty Load]
{'src': {'NT': False, 'same': True, 'congruent': 0, 'type': 'addresses_UC', 'AVXalign': False, 'size': 1}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'src': {'same': True, 'congruent': 9, 'type': 'addresses_WT_ht'}, 'OP': 'REPM', 'dst': {'same': False, 'congruent': 0, 'type': 'addresses_WC_ht'}}
{'OP': 'STOR', 'dst': {'NT': True, 'same': False, 'congruent': 8, 'type': 'addresses_WT_ht', 'AVXalign': True, 'size': 8}}
{'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 5, 'type': 'addresses_WC_ht', 'AVXalign': False, 'size': 8}}
{'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 1, 'type': 'addresses_A_ht', 'AVXalign': False, 'size': 2}}
{'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 3, 'type': 'addresses_WC_ht', 'AVXalign': False, 'size': 4}}
{'OP': 'STOR', 'dst': {'NT': False, 'same': True, 'congruent': 0, 'type': 'addresses_UC_ht', 'AVXalign': False, 'size': 8}}
{'src': {'same': False, 'congruent': 1, 'type': 'addresses_normal_ht'}, 'OP': 'REPM', 'dst': {'same': False, 'congruent': 4, 'type': 'addresses_normal_ht'}}
{'src': {'same': False, 'congruent': 1, 'type': 'addresses_normal_ht'}, 'OP': 'REPM', 'dst': {'same': False, 'congruent': 1, 'type': 'addresses_UC_ht'}}
{'src': {'NT': False, 'same': False, 'congruent': 1, 'type': 'addresses_UC_ht', 'AVXalign': False, 'size': 8}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 0, 'type': 'addresses_UC_ht', 'AVXalign': False, 'size': 16}}
{'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 6, 'type': 'addresses_WC_ht', 'AVXalign': False, 'size': 4}}
{'src': {'NT': False, 'same': False, 'congruent': 5, 'type': 'addresses_normal_ht', 'AVXalign': False, 'size': 4}, 'OP': 'LOAD'}
{'src': {'same': False, 'congruent': 10, 'type': 'addresses_normal_ht'}, 'OP': 'REPM', 'dst': {'same': False, 'congruent': 5, 'type': 'addresses_UC_ht'}}
{'src': {'same': False, 'congruent': 4, 'type': 'addresses_WC_ht'}, 'OP': 'REPM', 'dst': {'same': False, 'congruent': 0, 'type': 'addresses_WC_ht'}}
{'00': 21829}
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
*/
 
 | 
					
	; freemlib for Neo-Geo Example 03: Palette Basics
;==============================================================================;
	; defines
	include "../../src_68k/inc/neogeo.inc"
	include "../../src_68k/inc/ram_bios.inc"
	include "../../src_68k/inc/mess_macro.inc"
	include "ram_user.inc"
;------------------------------------------------------------------------------;
	; headers
	include "header_68k.inc"
	ifd TARGET_CD
		include "header_cd.inc"
	else
		include "header_cart.inc"
	endif
;==============================================================================;
; USER
; Needs to perform actions according to the value in BIOS_USER_REQUEST.
; Must jump back to SYSTEM_RETURN at the end so the BIOS can have control.
USER:
	move.b	d0,REG_DIPSW		; kick watchdog
	lea		BIOS_WORKRAM,sp		; set stack pointer to BIOS_WORKRAM
	move.w	#0,LSPC_MODE		; Disable auto-animation, timer interrupts, set auto-anim speed to 0 frames
	move.w	#7,LSPC_IRQ_ACK		; ack. all IRQs
	move.w	#$2000,sr			; Enable VBlank interrupt, go Supervisor
	; Handle user request
	clr.l	d0
	move.b	(BIOS_USER_REQUEST).l,d0
	lsl.b	#2,d0				; shift value left to get offset into table
	lea		cmds_USER_REQUEST,a0
	movea.l	(a0,d0),a0
	jsr		(a0)
;------------------------------------------------------------------------------;
; BIOS_USER_REQUEST commands
cmds_USER_REQUEST:
	dc.l	userReq_StartupInit	; Command 0 (Initialize)
	dc.l	userReq_Eyecatch	; Command 1 (Custom eyecatch)
	dc.l	userReq_Game		; Command 2 (Demo Game/Game)
	dc.l	userReq_Game		; Command 3 (Title Display)
;------------------------------------------------------------------------------;
; userReq_StartupInit
; Initialize the backup work area.
userReq_StartupInit:
	move.b	d0,REG_DIPSW		; kick watchdog
	jmp		SYSTEM_RETURN
;------------------------------------------------------------------------------;
; userReq_Eyecatch
; Only to be fully coded if your game uses its own eyecatch (value at $114 is 1).
; Otherwise, jmp to SYSTEM_RETURN.
userReq_Eyecatch:
	move.b	d0,REG_DIPSW		; kick watchdog
	jmp		SYSTEM_RETURN
;------------------------------------------------------------------------------;
; userReq_Game
; This is the complex one. For this demo, we're only going to treat it as a
; combination of initialization and main loop, but for a real game, you might
; want to have BIOS_USER_REQUEST commands 2 and 3 do different things.
userReq_Game:
	move.b	d0,REG_DIPSW		; kick watchdog
	; perform your initialization
	move.w	#1,curPalSet		; reset current palette set
	; set up palettes
	move.b	d0,PALETTE_BANK1	; use palette bank 1
	lea		paletteData,a0
	lea		PALETTES,a1
	move.l	#(16*NUM_PALETTES)-1,d7
.ldpal:
	move.w	(a0)+,(a1)+
	dbra	d7,.ldpal
	jsr		FIX_CLEAR			; clear fix layer, add borders on sides
	jsr		LSP_1st				; clear first sprite
	jsr		CreateDisplay		; create initial display
; execution continues into main loop.
;------------------------------------------------------------------------------;
; mainLoop
; The game's main loop. This is where you run the actual game part.
mainLoop:
	move.b	d0,REG_DIPSW		; kick the watchdog
	; do things like:
	;jsr		CheckInput			; check inputs
	jsr		WaitVBlank			; wait for the vblank
	; and other things that would normally happen in a game's main loop.
	jmp		mainLoop
;==============================================================================;
; PLAYER_START
; Called by the BIOS if one of the Start buttons is pressed while the player
; has enough credits (or if the the time runs out on the title menu?).
; We're not using this in this demo.
PLAYER_START:
	move.b	d0,REG_DIPSW		; kick the watchdog
	rts
;==============================================================================;
; DEMO_END
; Called by the BIOS when the Select button is pressed; ends the demo early.
DEMO_END:
	; if necessary, store any items in the (MVS) backup RAM.
	rts
;==============================================================================;
; COIN_SOUND
; Called by the BIOS when a coin is inserted; should play a coin drop sound.
; We don't actually do anything here since this isn't meant to take coins.
COIN_SOUND:
	; Send a sound code
	rts
;==============================================================================;
; VBlank
; VBlank interrupt, run things we want to do every frame.
VBlank:
	; check if the BIOS wants to run its vblank
	btst	#7,BIOS_SYSTEM_MODE
	bne		.gamevbl
	; run BIOS vblank
	jmp		SYSTEM_INT1
	; run the game's vblank
.gamevbl
	movem.l d0-d7/a0-a6,-(sp)	; save registers
	move.w	#4,LSPC_IRQ_ACK		; acknowledge the vblank interrupt
	move.b	d0,REG_DIPSW		; kick the watchdog
	; do things in vblank
	jsr		updateSprSwatches
.endvbl:
	jsr		SYSTEM_IO			; "Call SYSTEM_IO every 1/60 second."
	jsr		MESS_OUT			; Puzzle Bobble calls MESS_OUT just after SYSTEM_IO
	move.b	#0,flag_VBlank		; clear vblank flag so waitVBlank knows to stop
	movem.l (sp)+,d0-d7/a0-a6	; restore registers
	rte
;==============================================================================;
; IRQ2
; Level 2/timer interrupt, unused here. You could use it for effects, though.
IRQ2:
	move.w	#2,LSPC_IRQ_ACK		; ack. interrupt #2 (HBlank)
	move.b	d0,REG_DIPSW		; kick watchdog
	rte
;==============================================================================;
; IRQ3
; Level 3 IRQ, unused here. Might be used for something else on CD, though.
; (More research needed)
IRQ3:
	move.w  #1,LSPC_IRQ_ACK		; acknowledge interrupt 3
	move.b	d0,REG_DIPSW		; kick watchdog
	rte
;==============================================================================;
; WaitVBlank
; Waits for VBlank to finish (via a flag cleared at the end).
WaitVBlank:
	move.b	#1,flag_VBlank
.waitLoop
	tst.b	flag_VBlank
	bne.s	.waitLoop
	rts
;==============================================================================;
; include freemlib function files
	include "../../src_68k/func/palette.asm"
	include "../../src_68k/func/sprites.asm"
	include "../../src_68k/inc/input.inc"
;==============================================================================;
; CreateDisplay
; Creates the display for this demonstration.
CreateDisplay:
	; Initialize the sprites
	jsr		initSprSwatches
	; write "Palette Basics" text on fix layer
	bset.b	#0,BIOS_MESS_BUSY	; tell MESS_OUT we're busy messing with the data
	movea.l	BIOS_MESS_POINT,a0	; get current message pointer
	move.l	#string_PaletteBasics,(a0)+	; add fix layer text
	move.l	a0,BIOS_MESS_POINT  ; Update pointer
	bclr.b	#0,BIOS_MESS_BUSY	; tell MESS_OUT it can run again
	rts
string_PaletteBasics:
	messmac_Format	0,$00FF		; command 01: bytes+end code; top byte $00, end code $FF
	messmac_SetIncr	$20			; command 02: vram auto-increment $20 (horiz.)
	messmac_SetAddr	$70A9		; command 03: set vram addr to $7022
	messmac_OutData
	dc.b	"Palette Basics",$FF,$00
;------------------------------------------------------------------------------;
; initSprSwatches
; Init the sprite layer (16px) swatches. Uses sprites 1-15.
;  SCB |spr1 |spr2 |spr3 |spr4 |spr5 |spr6 |spr7 |spr8 |spr9 |spr10|spr11|spr12|spr13|spr14|spr15
;------+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+------
; SCB1 |$0040|$0080|$00C0|$0100|$0140|$0180|$01C0|$0200|$0240|$0280|$02C0|$0300|$0320|$0340|$0380
; SCB2 |$8001|$8002|$8003|$8004|$8005|$8006|$8007|$8008|$8009|$800A|$800B|$800C|$800D|$800E|$800F
; SCB3 |$8201|$8202|$8203|$8204|$8205|$8206|$8207|$8208|$8209|$820A|$820B|$820C|$820D|$820E|$820F
; SCB4 |$8401|$8402|$8403|$8404|$8405|$8406|$8407|$8408|$8409|$840A|$840B|$840C|$840D|$840E|$840F
initSprSwatches:
	lea.l	LSPC_DATA,a6		; LSPC_DATA is loaded into a6 as shorthand
	; SCB1 ($0000-$6FFF): Tilemaps
	; Each sprite is 64 words long (sprite 1 starts at $0040)
	; * sprite tile LSB
	; * sprite attributes (pppppppp TMSB0000)
	move.w	#$0040,d2			; begin at SCB1, sprite 1
	move.w	#1,2(a6)			; vram increment +1
	move.w	#64,d3				; tile index LSB (modified in loop)
	move.w	#1,d4				; current palette
	asl.w	#8,d4				; shift to upper byte
	move.w	#16-1,d5			; 16 sprites (subtract 1 for loop logic)
.initSwatchSCB1:
	move.w	d2,-2(a6)			; write vram address
	move.w	d3,(a6)				; write tile index LSB
	move.w	d4,(a6)				; write tile attributes
	addi.w	#1,d3				; next tile index
	addi.w	#$40,d2				; go to next sprite
	dbra	d5,.initSwatchSCB1
	; SCB2 ($8000-$81FF): Sprite Shrinking ($00-$0F for X, $00-$FF for Y)
	move.w	#$8001,-2(a6)		; write beginning at SCB2, sprite 1
	move.w	#1,2(a6)			; vram increment +1
	move.w	#$0FFF,d0			; just set the thing to $0FFF for full size
	move.w	#16-1,d1			; 16 sprites (subtract 1 for loop logic)
.initSwatchSCB2:
	move.w	d0,(a6)
	dbra	d1,.initSwatchSCB2
	; SCB3 ($8200-$83FF): Vertical position and more flags
	; The first sprite is going to be the base sprite for this set of swatches.
	; Sprites 2-15 will have the sticky bit set.
	; FEDCBA98 76543210
	; |||||||| ||||||||
	; |||||||| ||++++++- Sprite Size (in tiles)
	; |||||||| |+------- Sticky bit (sprites 2-15 are sticky because I'm lazy as shit)
	; ++++++++-+-------- Y position (496-Y from top border)
	move.w	#$8201,-2(a6)		; write beginning at SCB3, sprite 1
	move.w	#1,2(a6)			; vram increment +1
	; set up first tile
	move.w	#((496-72)<<7)|1,d0
	move.w	d0,(a6)
	; set up the other 15 tiles
	move.w	#$0040,d0
	move.w	#15-1,d1
.initSwatchSCB3:
	move.w	d0,(a6)
	dbra	d1,.initSwatchSCB3
	; SCB4 ($8400-$85FF): Horizontal position
	; FEDCBA98 76543210
	; |||||||| |xxxxxxx
	; ++++++++-+--------X position
	move.w	#$8401,-2(a6)		; write beginning at SCB4, sprite 1
	move.w	#1,2(a6)			; vram increment +1
	; set up first tile
	move.w	#(24<<7),d0
	move.w	d0,(a6)
	rts
;==============================================================================;
; updateSprSwatches
; Update the sprite layer (16px) swatches. Uses sprites 1-15.
updateSprSwatches:
	; SCB1: only the palettes need to change ($0xx1)
	move.w	#$0041,d2			; start at $0041
	move.w	#$0001,LSPC_INCR	; use auto-increment of $1
	move.l	#0,d0
	move.w	curPalSet,d0		; use curPalSet for palette
	asl.w	#8,d0
	; do write loop
	move.w	#16-1,d1			; 16 sprites (subtract 1 for loop logic)
.swatchSCB1:
	move.w	d2,LSPC_ADDR		; set vram address
	move.w	d0,LSPC_DATA
	add.w	#$40,d2				; update vram address
	dbra	d1,.swatchSCB1
.endUpdSprSwatch:
	rts
;==============================================================================;
; CheckInput
; Checks for any inputs and handles them.
; -todo-
; P1 A: increment curPalSet
; P1 B: decrement curPalSet
CheckInput:
	; We're only checking Player 1's inputs here.
	move.b	BIOS_P1CURRENT,d0	; Player 1 current input
	move.b	BIOS_P1CHANGE,d1	; Player 1 input change
	; do a check to see if any of the buttons we're handling have been pressed
;------------------------------------------------------------------------------;
.CheckInput_End:
	rts
;==============================================================================;
	include "paldata.inc"		; Palette Data
 
 | 
					
	; A017399: a(n) = (11*n)^11.
; 0,285311670611,584318301411328,50542106513726817,1196683881290399744,13931233916552734375,103510234140112521216,564154396389137449973,2450808588882738675712,8953382542587164451099,28531167061100000000000,81402749386839761113321,211988959518950443450368,511324276025564512546607,1155388203804953497544704,2467876294615567236328125,5019255990031848807858176,9778171990537733621073763,18336527447218512795850752,33236030376158771102541809,58431830141132800000000000,99938258857146531850367031
pow $0,11
mul $0,285311670611
 
 | 
					
	.macro DISABLE_PLAYER_INVUL P12
            lda P%%1_STATE
            cmp #PS_DYING
            beq DI%%1_X
            lda P%%1_STATE
            cmp #PS_BURIED
            beq DI%%1_X
            lda #0
            sta P%%1_INVUL
            lda #1
            sta P%%1_VISIBLE
            lda #P%%1_X_POSITION
            .if :1 = 1
                sta HPOSP0
                sta HPOSP1
            .endif
            .if :1 = 2
                sta HPOSP2
                sta HPOSP3
            .endif
DI%%1_X     
.endm
.macro ADVANCE_PLAYER_SCORES P12
            lda P%%1_INVUL
            bne AS%%1_2
            lda P%%1_STATE
            cmp #PS_BURIED
            beq AS%%1_X
            cmp #PS_DYING
            beq AS%%1_X
            sed
            lda P%%1_SCORE
            clc
            adc #1
            sta P%%1_SCORE
            cld
            cmp #0
            beq AS%%1_1
            jmp AS%%1_X
AS%%1_1     sed
            clc
            lda P%%1_SCORE_H
            adc #1
            sta P%%1_SCORE_H
            jmp AS%%1_X
AS%%1_2     dec P%%1_INVUL_DISABLE_COUNTER
            bne AS%%1_X
            .if :1 = 2
                jsr DISABLE_INVUL
            .endif
AS%%1_X
.endm
.macro PLAYER_PLAYER_TICK P12
            lda P%%1_STATE
            cmp #PS_IDLE
            jeq PT%%1_INVUL
            cmp #PS_JUMP
            bne PT%%1_1
            JUMP_PLAYER_TICK %%1
            jmp PT%%1_INVUL
PT%%1_1     cmp #PS_DYING
            jne PT%%1_X
            DYING_PLAYER_TICK %%1
            jmp PT%%1_X
PT%%1_INVUL lda P%%1_INVUL
            beq PT%%1_X
            dec P%%1_INVUL_COUNTER
            bne PT%%1_X
            lda #INVUL_COOLDOWN
            sta P%%1_INVUL_COUNTER
            lda P%%1_INVUL
            beq PT%%1_X
            lda P%%1_VISIBLE
            beq PT%%1_2
            dec P%%1_VISIBLE
            lda #$ff
            .if :1 = 1
                sta HPOSP0
                sta HPOSP1
            .endif
            .if :1 = 2
                sta HPOSP2
                sta HPOSP3
            .endif
            jmp PT%%1_X
PT%%1_2     inc P%%1_VISIBLE
            lda #P%%1_X_POSITION
            .if :1 = 1
                sta HPOSP0
                sta HPOSP1
            .endif
            .if :1 = 2
                sta HPOSP2
                sta HPOSP3
            .endif
PT%%1_X
.endm
.macro JUMP_PLAYER_TICK P12
            dec JUMP_COUNTER_%%1
            bne JT%%1_X    ; Do not advance yet
            lda #JUMP_FRAME_ADVANCE
            sta JUMP_COUNTER_%%1
            jsr CLEAR_PLAYERS
            inc P%%1_Y
            jsr PAINT_PLAYERS
            lda P%%1_Y
            cmp #JUMP_FRAME_COUNT/2
            bne JT%%1_2
            ; We're just started to go down, it's too late to interrupt the jump
            lda #1
            sta JUMP_INTERRUPTED_%%1
JT%%1_2     lda P%%1_Y
            sec
            sbc #JUMP_FRAME_COUNT/JUMP_INTERRUPT_RATIO
            bcc JT%%1_1    ; Do not allow to interrupt the jump yet
            INTERRUPT_JUMP %%1
JT%%1_1     lda P%%1_Y
            cmp #JUMP_FRAME_COUNT-1
            bne JT%%1_X
            ; Finish the jump
            lda #PS_IDLE
            sta P%%1_STATE
            lda #0
            sta P%%1_Y
JT%%1_X 
.endm
.macro INTERRUPT_JUMP P12
            .if :1 = 1
                ldy #0
                lda (STRIG_0_SOURCE),y
            .endif
            .if :1 = 2
                ldy #0
                lda (STRIG_1_SOURCE),y
            .endif
            beq IJ%%1_X ; Button still pressed, do not interrupt
            lda JUMP_INTERRUPTED_%%1
            bne IJ%%1_X ; This jump has already been interrupted
            lda #JUMP_FRAME_COUNT-1
            sec
            sbc P%%1_Y
            sta P%%1_Y
            lda #1
            sta JUMP_INTERRUPTED_%%1
IJ%%1_X     
.endm
.macro DYING_PLAYER_TICK P12
            dec DYING_JUMP_COUNTER_%%1
            jne DT%%1_X
            INIT_DYING_COOLDOWN %%1
            ldy DYING_POS_X_P%%1
            lda (P%%1_X_TABLE),y
            cmp #$ff
            beq DT%%1_0
            CLEAR_PLAYER %%1
            inc P%%1_Y
            ldy DYING_POS_X_P%%1
            lda (P%%1_X_TABLE),y
            inc DYING_POS_X_P%%1
            .if :1 = 1
                sta P1_X
                sta HPOSP0
                sta HPOSP1
            .endif
            .if :1 = 2
                sta HPOSP2
                sta HPOSP3
            .endif
            jsr PAINT_PLAYERS
            jmp DT%%1_X
DT%%1_0     lda #0
            .if :1 = 1
                sta P1_X
                sta HPOSP0
                sta HPOSP1
            .endif
            .if :1 = 2
                sta HPOSP2
                sta HPOSP3
            .endif
            CLEAR_PLAYER %%1
            lda #PS_BURIED
            sta P%%1_STATE
DT%%1_X     
.endm
.macro INIT_DYING_COOLDOWN P12
            #if .byte CURRENT_GAME_LEVEL = #0 .or .byte CURRENT_GAME_LEVEL = #1 .or .byte CURRENT_GAME_LEVEL = #2 .or .byte CURRENT_GAME_LEVEL = #4 
                lda #DYING_JUMP_COOLDOWN
                sta DYING_JUMP_COUNTER_%%1
                jmp IDC%%1_X
            #end
            lda #DYING_JUMP_COOLDOWN_FAST
            sta DYING_JUMP_COUNTER_%%1
IDC%%1_X
.endm
.macro CLEAR_PLAYER P12
            ldy P%%1_Y
            lda (P%%1_Y_TABLE),y
            sec
            sbc P%%1_DRAWING_Y_OFFSET
            tay
            ldx #0
@           lda #0
            .if :1 = 1
                sta PMG_P0,y
                sta PMG_P1,y
            .endif
            .if :1 = 2
                sta PMG_P2,y
                sta PMG_P3,y
            .endif
            cpy #PLAYER_DRAW_LIMIT
            beq CP_X
            iny
            inx
            cpx #20
            bne @-
CP_X
.endm
.macro START_JUMP P12
            lda P%%1_STATE
            cmp #PS_IDLE
            bne SJ%%1_X    ; Only idle can jump
            lda #0
            sta JUMP_INTERRUPTED_%%1
            lda #JUMP_FRAME_ADVANCE
            sta JUMP_COUNTER_%%1
            lda #PS_JUMP
            sta P%%1_STATE
SJ%%1_X
.endm
; Death animation depends on the speed of the rotator
; There are 3 death speeds, they are assigned
; to game levels in the following way:
;
; Level | Animation (S-Slow, M-medium, F-fase)
;-------------------
;   1   |     S
;   2   |     S
;   3   |     S
;   4   |     M
;   5   |     S
;   6   |     M
;   7   |     M
;   8   |     F
;   9   |     M
;  10   |     M
;  11   |     F
;  12   |     F
.macro INIT_DYING P12
            CLEAR_PLAYER %%1
            INIT_DYING_PAINT_OFFSET %%1
            lda #PS_DYING
            sta P%%1_STATE
            lda #0
            sta DYING_POS_X_P%%1
            sta P%%1_Y
            lda #1
            sta DYING_JUMP_COUNTER_%%1
            #if .byte CURRENT_GAME_LEVEL = #0 .or .byte CURRENT_GAME_LEVEL = #1 .or .byte CURRENT_GAME_LEVEL = #2 .or .byte CURRENT_GAME_LEVEL = #4 
                mwa #LEFT_KILL_Y_SPEED_1 P%%1_Y_TABLE
                .if :1 = 1
                    mwa #LEFT_KILL_X_SPEED_1 P%%1_X_TABLE
                .endif
                .if :1 = 2
                    mwa #RIGHT_KILL_X_SPEED_1 P%%1_X_TABLE
                .endif
                jmp ID%%1_X
            #end
            #if .byte CURRENT_GAME_LEVEL = #3 .or .byte CURRENT_GAME_LEVEL = #5 .or .byte CURRENT_GAME_LEVEL = #6 .or .byte CURRENT_GAME_LEVEL = #8  .or .byte CURRENT_GAME_LEVEL = #9 
                mwa #LEFT_KILL_Y_SPEED_2 P%%1_Y_TABLE
                .if :1 = 1
                    mwa #LEFT_KILL_X_SPEED_2 P%%1_X_TABLE
                .endif
                .if :1 = 2
                    mwa #RIGHT_KILL_X_SPEED_2 P%%1_X_TABLE
                .endif
                jmp ID%%1_X
            #end
            #if .byte CURRENT_GAME_LEVEL = #7 .or .byte CURRENT_GAME_LEVEL = #10 .or .byte CURRENT_GAME_LEVEL = #11
                mwa #LEFT_KILL_Y_SPEED_3 P%%1_Y_TABLE
                .if :1 = 1
                    mwa #LEFT_KILL_X_SPEED_3 P%%1_X_TABLE
                .endif
                .if :1 = 2
                    mwa #RIGHT_KILL_X_SPEED_3 P%%1_X_TABLE
                .endif
                jmp ID%%1_X
            #end
ID%%1_X
.endm
.macro INIT_DYING_PAINT_OFFSET P12
            ldy #0
            lda (P2_Y_TABLE),y
            ldy P%%1_Y
            sec
            sbc (P2_Y_TABLE),y
            sta P%%1_DRAWING_Y_OFFSET
.endm
.macro CHECK_PLAYER_COLLISIONS P12
            lda P%%1_INVUL
            jne CC%%1_X
            #if .byte P%%1_STATE = #PS_DYING .or .byte P%%1_Y > #6
                jmp CC%%1_X
            #end
            ldy CURRENT_GAME_LEVEL
            lda HIT_FRAMES_0,y
            cmp CURRENT_FRAME
            beq CC_%%1KILLD
            lda HIT_FRAMES_1,y
            cmp CURRENT_FRAME
            beq CC_%%1KILLD
            lda HIT_FRAMES_2,y
            cmp CURRENT_FRAME
            beq CC_%%1KILLD
            jmp CC%%1_X
CC_%%1KILLD INIT_DYING %%1
CC%%1_X
.endm
.macro PRINT_PL P12
            lda #64+128
            sta STATUS_BAR_BUFFER,y
            iny
            lda #%%1+128
            sta STATUS_BAR_BUFFER,y
            iny
            lda #76+128
            sta STATUS_BAR_BUFFER,y
            iny
            lda #77+128
            sta STATUS_BAR_BUFFER,y
            iny
            lda #65+128
            sta STATUS_BAR_BUFFER,y
.endm
.macro AI_PLAYER_TICK P12 JOY
            lda P%%1_CPU
            beq AT%%1_X
            lda P%%1_STATE
            cmp #PS_IDLE
            bne AT%%1_X
            lda P%%1_INVUL
            bne AT%%1_X
            lda CURRENT_GAME_LEVEL
            asl
            asl
            tay
            lda CURRENT_FRAME
            cmp JUMP_FRAMES_PER_LEVEL,y
            beq AT%%1_1
            iny
            cmp JUMP_FRAMES_PER_LEVEL,y
            beq AT%%1_1
            iny
            cmp JUMP_FRAMES_PER_LEVEL,y
            beq AT%%1_1
            iny
            cmp JUMP_FRAMES_PER_LEVEL,y
            beq AT%%1_1
AT%%1_X     jmp AT%%1_5         
AT%%1_1     lda TRIG_HOLD_FRAMES_PER_LEVEL,y
            tax
            ; Consider if AI should randomly skip the jump decision
            lda RANDOM
            sta XTMP
            ldy CURRENT_GAME_LEVEL
            lda AI_SKIP_JUMP_PROBABILITY_PER_LEVEL,y
            sta XTMP+1
            #if .byte XTMP+1 > XTMP
                jmp AT%%1_X
            #end
            ; Consider disrupting the time the AI is holding the jump button
            lda RANDOM
            sta XTMP
            ldy CURRENT_GAME_LEVEL
            lda AI_HOLD_DISRUPTION_PROBABILITY_PER_LEVEL,y
            sta XTMP+1
            #if .byte XTMP+1 > XTMP
                ; Let's dirupt the perfect AI jump a bit
                lda XTMP
                and #%00000001
                beq AT%%1_2
:JUMP_HOLD_DISRUPTION dex
                jmp AT%%1_3
AT%%1_2           
:JUMP_HOLD_DISRUPTION inx
AT%%1_3
            #end
AT%%1_4     lda #0
            sta STRIG%%2_CPU
            #if STRIG%%2_CPU_HOLD = #0
                stx STRIG%%2_CPU_HOLD
            #end
AT%%1_5
.endm
.macro RELEASE_AI_KEY P12 JOY
            lda P%%1_CPU
            beq RAK%%1_X
            lda STRIG%%2_CPU_HOLD
            bne RAK%%1_1
            lda #1
            sta STRIG%%2_CPU
            jmp RAK%%1_X
RAK%%1_1    dec STRIG%%2_CPU_HOLD
RAK%%1_X    
.endm 
 | 
					
	
; float __fadd (float left, float right)
SECTION code_clib
SECTION code_fp_am9511
PUBLIC cam32_sdcc_fadd
EXTERN asm_sdcc_readr, asm_am9511_fadd
.cam32_sdcc_fadd
    ; add two sdcc floats
    ;
    ; enter : stack = sdcc_float right, sdcc_float left, ret
    ;
    ; exit  : DEHL = sdcc_float(left+right)
    ;
    ; uses  : af, bc, de, hl, af', bc', de', hl'
    call asm_sdcc_readr
    jp asm_am9511_fadd      ; enter stack = sdcc_float right, sdcc_float left, ret
                            ;        DEHL = sdcc_float right
                            ; return DEHL = sdcc_float
 
 | 
					
			Subsets and Splits
				
	
				
			
				
No community queries yet
The top public SQL queries from the community will appear here once available.