text stringlengths 1 1.05M |
|---|
dnl AMD K6 mpn_divexact_by3 -- mpn division by 3, expecting no remainder.
dnl
dnl K6: 11.0 cycles/limb
dnl Copyright (C) 2000 Free Software Foundation, Inc.
dnl
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
dnl modify it under the terms of the GNU Lesser General Public License as
dnl published by the Free Software Foundation; either version 2.1 of the
dnl License, or (at your option) any later version.
dnl
dnl The GNU MP Library is distributed in the hope that it will be useful,
dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
dnl Lesser General Public License for more details.
dnl
dnl You should have received a copy of the GNU Lesser General Public
dnl License along with the GNU MP Library; see the file COPYING.LIB. If
dnl not, write to the Free Software Foundation, Inc., 59 Temple Place -
dnl Suite 330, Boston, MA 02111-1307, USA.
include(`../config.m4')
C mp_limb_t mpn_divexact_by3c (mp_ptr dst, mp_srcptr src, mp_size_t size,
C mp_limb_t carry);
C
C Using %esi in (%esi,%ecx,4) or 0(%esi,%ecx,4) addressing modes doesn't
C lead to vector decoding, unlike plain (%esi) does.
defframe(PARAM_CARRY,16)
defframe(PARAM_SIZE, 12)
defframe(PARAM_SRC, 8)
defframe(PARAM_DST, 4)
dnl multiplicative inverse of 3, modulo 2^32
deflit(INVERSE_3, 0xAAAAAAAB)
.text
ALIGN(32)
PROLOGUE(mpn_divexact_by3c)
deflit(`FRAME',0)
movl PARAM_SIZE, %ecx
pushl %esi defframe_pushl(SAVE_ESI)
movl PARAM_SRC, %esi
pushl %edi defframe_pushl(SAVE_EDI)
movl PARAM_DST, %edi
pushl %ebx defframe_pushl(SAVE_EBX)
movl PARAM_CARRY, %ebx
leal (%esi,%ecx,4), %esi
pushl $3 defframe_pushl(VAR_THREE)
leal (%edi,%ecx,4), %edi
negl %ecx
C Need 32 alignment for claimed speed, to avoid the movl store
C opcode/modrm crossing a cache line boundary
ALIGN(32)
L(top):
C eax scratch, low product
C ebx carry limb (0 to 3)
C ecx counter, limbs, negative
C edx scratch, high product
C esi &src[size]
C edi &dst[size]
C ebp
C
C The 0(%esi,%ecx,4) form pads so the finishup "movl %ebx, %eax"
C doesn't cross a 32 byte boundary, saving a couple of cycles
C (that's a fixed couple, not per loop).
Zdisp( movl, 0,(%esi,%ecx,4), %eax)
subl %ebx, %eax
setc %bl
imull $INVERSE_3, %eax
movl %eax, (%edi,%ecx,4)
addl $2, %ecx
mull VAR_THREE
addl %edx, %ebx
loop L(top)
movl SAVE_ESI, %esi
movl %ebx, %eax
movl SAVE_EBX, %ebx
movl SAVE_EDI, %edi
addl $FRAME, %esp
ret
EPILOGUE()
|
.data
.text
addi $t0, $zero, 30
addi $t1, $zero, 5
div $s0, $t0, 10
# Print
li $v0, 1
add $a0, $zero, $s0
syscall |
dnl Intel Pentium-III mpn_popcount, mpn_hamdist -- population count and
dnl hamming distance.
dnl Copyright 2000, 2002, 2004 Free Software Foundation, Inc.
dnl
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
dnl modify it under the terms of the GNU Lesser General Public License as
dnl published by the Free Software Foundation; either version 2.1 of the
dnl License, or (at your option) any later version.
dnl
dnl The GNU MP Library is distributed in the hope that it will be useful,
dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
dnl Lesser General Public License for more details.
dnl
dnl You should have received a copy of the GNU Lesser General Public
dnl License along with the GNU MP Library; see the file COPYING.LIB. If
dnl not, write to the Free Software Foundation, Inc., 51 Franklin Street,
dnl Fifth Floor, Boston, MA 02110-1301, USA.
include(`../config.m4')
C popcount hamdist
C P3: 6.5 7 cycles/limb
include_mpn(`x86/k7/mmx/hamdist.asm')
|
/*
THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO
END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS
AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
*/
#include <stdlib.h>
#include <string.h>
#include "mem/mem.h"
#include "fix/fix.h"
#include "misc/types.h"
#include "2d/gr.h"
#include "ui.h"
#include "platform/key.h"
#define Middle(x) ((2*(x)+1)/4)
extern void ui_draw_shad(short x1, short y1, short x2, short y2, short c1, short c2);
void ui_draw_box_in1(short x1, short y1, short x2, short y2)
{
gr_setcolor(CWHITE);
gr_urect(x1 + 1, y1 + 1, x2 - 1, y2 - 1);
ui_draw_shad(x1 + 0, y1 + 0, x2 - 0, y2 - 0, CGREY, CBRIGHT);
}
void ui_draw_icon(UI_GADGET_ICON* icon)
{
int height, width, avg;
int x, y;
if ((icon->status == 1) || (icon->position != icon->oldposition))
{
icon->status = 0;
ui_mouse_hide();
gr_set_current_canvas(icon->canvas);
gr_get_string_size(icon->text, &width, &height, &avg);
x = ((icon->width - 1) / 2) - ((width - 1) / 2);
y = ((icon->height - 1) / 2) - ((height - 1) / 2);
if (icon->position == 1)
{
// Draw pressed
ui_draw_box_in(0, 0, icon->width, icon->height);
x += 2; y += 2;
}
else if (icon->flag)
{
// Draw part out
ui_draw_box_in1(0, 0, icon->width, icon->height);
x += 1; y += 1;
}
else
{
// Draw released!
ui_draw_box_out(0, 0, icon->width, icon->height);
}
gr_set_fontcolor(CBLACK, -1);
gr_ustring(x, y, icon->text);
ui_mouse_show();
}
}
UI_GADGET_ICON* ui_add_gadget_icon(UI_WINDOW* wnd, const char* text, short x, short y, short w, short h, int k, int (*f)(void))
{
UI_GADGET_ICON* icon;
icon = (UI_GADGET_ICON*)ui_gadget_add(wnd, 9, x, y, x + w - 1, y + h - 1);
icon->width = w;
icon->height = h;
MALLOC( icon->text, char, strlen( text )+2);//Hack by KRB //[ISB] whoops, forgot to unhack by ISB
icon->textLen = strlen(text) + 2;
//icon->text = (char*)malloc((strlen(text) + 2) * sizeof(char));
strcpy_s(icon->text, icon->textLen, text);
icon->trap_key = k;
icon->user_function = f;
icon->oldposition = 0;
icon->position = 0;
icon->pressed = 0;
icon->canvas->cv_font = ui_small_font;
// Call twice to get original;
if (f)
{
icon->flag = (int8_t)f();
icon->flag = (int8_t)f();
}
else {
icon->flag = 0;
}
return icon;
}
void ui_icon_do(UI_GADGET_ICON* icon, int keypress)
{
int OnMe;
OnMe = ui_mouse_on_gadget((UI_GADGET*)icon);
icon->oldposition = icon->position;
if (B1_PRESSED && OnMe)
{
icon->position = 1;
}
else {
icon->position = 0;
}
icon->pressed = 0;
if ((icon->position == 0) && (icon->oldposition == 1) && OnMe)
icon->pressed = 1;
if (icon->pressed == 1 || keypress == icon->trap_key)
{
icon->status = 1;
icon->flag = (int8_t)icon->user_function();
if (keypress == icon->trap_key) last_keypress = 0;
}
ui_draw_icon(icon);
}
|
.byte $01 ; Unknown purpose
.byte OBJ_GREENPIRANHA_FIRE, $0A, $14
.byte OBJ_GREENPIRANHA_FIRE, $12, $14
.byte OBJ_GREENPIRANHA, $1E, $15
.byte OBJ_GREENPIRANHA_FIREC, $2C, $12
.byte OBJ_REDPIRANHA, $31, $15
.byte OBJ_GREENPIRANHA_FIRE, $33, $13
.byte OBJ_GREENPIRANHA_FIRE, $3A, $14
.byte $FF ; Terminator
|
// Copyright © 1996-2018, Valve Corporation, All rights reserved.
//
// Purpose: Engineer's Dispenser
//
// $NoKeywords: $
#include "cbase.h"
#include "tf_obj_dispenser.h"
#include "engine/IEngineSound.h"
#include "tf_player.h"
#include "tf_team.h"
#include "vguiscreen.h"
#include "world.h"
#include "explode.h"
#include "triggers.h"
#include "tier0/include/memdbgon.h"
// Ground placed version
#define DISPENSER_MODEL_PLACEMENT "models/buildables/dispenser_blueprint.mdl"
#define DISPENSER_MODEL_BUILDING "models/buildables/dispenser.mdl"
#define DISPENSER_MODEL "models/buildables/dispenser_light.mdl"
#define DISPENSER_MINS Vector( -20, -20, 0)
#define DISPENSER_MAXS Vector( 20, 20, 55) // tweak me
#define DISPENSER_TRIGGER_MINS Vector(-70, -70, 0)
#define DISPENSER_TRIGGER_MAXS Vector( 70, 70, 50) // tweak me
#define REFILL_CONTEXT "RefillContext"
#define DISPENSE_CONTEXT "DispenseContext"
//-----------------------------------------------------------------------------
// Purpose: SendProxy that converts the Healing list UtlVector to entindices
//-----------------------------------------------------------------------------
void SendProxy_HealingList( const SendProp *pProp, const void *pStruct, const void *pData, DVariant *pOut, int iElement, int objectID )
{
CObjectDispenser *pDispenser = (CObjectDispenser*)pStruct;
// If this assertion fails, then SendProxyArrayLength_HealingArray must have failed.
Assert( iElement < pDispenser->m_hHealingTargets.Size() );
CBaseEntity *pEnt = pDispenser->m_hHealingTargets[iElement].Get();
EHANDLE hOther = pEnt;
SendProxy_EHandleToInt( pProp, pStruct, &hOther, pOut, iElement, objectID );
}
int SendProxyArrayLength_HealingArray( const void *pStruct, int objectID )
{
CObjectDispenser *pDispenser = (CObjectDispenser*)pStruct;
return pDispenser->m_hHealingTargets.Count();
}
IMPLEMENT_SERVERCLASS_ST( CObjectDispenser, DT_ObjectDispenser )
SendPropInt( SENDINFO( m_iAmmoMetal ), 10 ),
SendPropArray2(
SendProxyArrayLength_HealingArray,
SendPropInt("healing_array_element", 0, SIZEOF_IGNORE, NUM_NETWORKED_EHANDLE_BITS, SPROP_UNSIGNED, SendProxy_HealingList),
MAX_PLAYERS,
0,
"healing_array"
)
END_SEND_TABLE()
BEGIN_DATADESC( CObjectDispenser )
DEFINE_THINKFUNC( RefillThink ),
DEFINE_THINKFUNC( DispenseThink ),
END_DATADESC()
LINK_ENTITY_TO_CLASS(obj_dispenser, CObjectDispenser);
PRECACHE_REGISTER(obj_dispenser);
#define DISPENSER_MAX_HEALTH 150
// How much of each ammo gets added per refill
#define DISPENSER_REFILL_METAL_AMMO 40
// How much ammo is given our per use
#define DISPENSER_DROP_PRIMARY 40
#define DISPENSER_DROP_SECONDARY 40
#define DISPENSER_DROP_METAL 40
ConVar obj_dispenser_heal_rate( "obj_dispenser_heal_rate", "10.0", FCVAR_CHEAT |FCVAR_DEVELOPMENTONLY );
class CDispenserTouchTrigger : public CBaseTrigger
{
DECLARE_CLASS( CDispenserTouchTrigger, CBaseTrigger );
public:
CDispenserTouchTrigger() {}
void Spawn( void )
{
BaseClass::Spawn();
AddSpawnFlags( SF_TRIGGER_ALLOW_CLIENTS );
InitTrigger();
SetSolid( SOLID_BBOX );
UTIL_SetSize(this, Vector(-70,-70,-70), Vector(70,70,70) );
}
virtual void StartTouch( CBaseEntity *pEntity )
{
CBaseEntity *pParent = GetOwnerEntity();
if ( pParent )
{
pParent->StartTouch( pEntity );
}
}
virtual void EndTouch( CBaseEntity *pEntity )
{
CBaseEntity *pParent = GetOwnerEntity();
if ( pParent )
{
pParent->EndTouch( pEntity );
}
}
};
LINK_ENTITY_TO_CLASS( dispenser_touch_trigger, CDispenserTouchTrigger );
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
CObjectDispenser::CObjectDispenser()
{
SetMaxHealth( DISPENSER_MAX_HEALTH );
m_iHealth = DISPENSER_MAX_HEALTH;
UseClientSideAnimation();
m_hTouchingEntities.Purge();
SetType( OBJ_DISPENSER );
}
CObjectDispenser::~CObjectDispenser()
{
if ( m_hTouchTrigger.Get() )
{
UTIL_Remove( m_hTouchTrigger );
}
int iSize = m_hHealingTargets.Count();
for ( int i = iSize-1; i >= 0; i-- )
{
EHANDLE hOther = m_hHealingTargets[i];
StopHealing( hOther );
}
StopSound( "Building_Dispenser.Idle" );
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CObjectDispenser::Spawn()
{
SetModel( DISPENSER_MODEL_PLACEMENT );
SetSolid( SOLID_BBOX );
UTIL_SetSize(this, DISPENSER_MINS, DISPENSER_MAXS);
m_takedamage = DAMAGE_YES;
m_iAmmoMetal = 0;
BaseClass::Spawn();
}
//-----------------------------------------------------------------------------
// Purpose: Start building the object
//-----------------------------------------------------------------------------
bool CObjectDispenser::StartBuilding( CBaseEntity *pBuilder )
{
SetModel( DISPENSER_MODEL_BUILDING );
CreateBuildPoints();
return BaseClass::StartBuilding( pBuilder );
}
void CObjectDispenser::SetModel( const char *pModel )
{
BaseClass::SetModel( pModel );
UTIL_SetSize(this, DISPENSER_MINS, DISPENSER_MAXS);
}
//-----------------------------------------------------------------------------
// Purpose: Finished building
//-----------------------------------------------------------------------------
void CObjectDispenser::OnGoActive( void )
{
CTFPlayer *pBuilder = GetBuilder();
Assert( pBuilder );
if ( !pBuilder )
return;
SetModel( DISPENSER_MODEL );
// Put some ammo in the Dispenser
m_iAmmoMetal = 25;
// Begin thinking
SetContextThink( &CObjectDispenser::RefillThink, gpGlobals->curtime + 3, REFILL_CONTEXT );
SetContextThink( &CObjectDispenser::DispenseThink, gpGlobals->curtime + 0.1, DISPENSE_CONTEXT );
m_flNextAmmoDispense = gpGlobals->curtime + 0.5;
m_hTouchTrigger = CBaseEntity::Create( "dispenser_touch_trigger", GetAbsOrigin(), vec3_angle, this );
BaseClass::OnGoActive();
EmitSound( "Building_Dispenser.Idle" );
}
//-----------------------------------------------------------------------------
// Spawn the vgui control screens on the object
//-----------------------------------------------------------------------------
void CObjectDispenser::GetControlPanelInfo( int nPanelIndex, const char *&pPanelName )
{
// Panels 0 and 1 are both control panels for now
if ( nPanelIndex == 0 || nPanelIndex == 1 )
{
if ( GetTeamNumber() == TF_TEAM_RED )
{
pPanelName = "screen_obj_dispenser_red";
}
else
{
pPanelName = "screen_obj_dispenser_blue";
}
}
else
{
BaseClass::GetControlPanelInfo( nPanelIndex, pPanelName );
}
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CObjectDispenser::Precache()
{
BaseClass::Precache();
int iModelIndex;
PrecacheModel( DISPENSER_MODEL_PLACEMENT );
iModelIndex = PrecacheModel( DISPENSER_MODEL_BUILDING );
PrecacheGibsForModel( iModelIndex );
iModelIndex = PrecacheModel( DISPENSER_MODEL );
PrecacheGibsForModel( iModelIndex );
PrecacheVGuiScreen( "screen_obj_dispenser_blue" );
PrecacheVGuiScreen( "screen_obj_dispenser_red" );
PrecacheScriptSound( "Building_Dispenser.Idle" );
PrecacheScriptSound( "Building_Dispenser.GenerateMetal" );
PrecacheScriptSound( "Building_Dispenser.Heal" );
PrecacheParticleSystem( "dispenser_heal_red" );
PrecacheParticleSystem( "dispenser_heal_blue" );
}
//-----------------------------------------------------------------------------
// If detonated, do some damage
//-----------------------------------------------------------------------------
void CObjectDispenser::DetonateObject( void )
{
/*
float flDamage = std::min( 100 + m_iAmmoMetal, 250 );
ExplosionCreate(
GetAbsOrigin(),
GetAbsAngles(),
GetBuilder(),
flDamage, //magnitude
flDamage, //radius
0,
0.0f, //explosion force
this, //inflictor
DMG_BLAST | DMG_HALF_FALLOFF);
*/
BaseClass::DetonateObject();
}
//-----------------------------------------------------------------------------
// Handle commands sent from vgui panels on the client
//-----------------------------------------------------------------------------
bool CObjectDispenser::ClientCommand( CTFPlayer *pPlayer, const CCommand &args )
{
const char *pCmd = args[0];
if ( FStrEq( pCmd, "use" ) )
{
// I can't do anything if I'm not active
if ( !ShouldBeActive() )
return true;
// player used the dispenser
if ( DispenseAmmo( pPlayer ) )
{
CSingleUserRecipientFilter filter( pPlayer );
pPlayer->EmitSound( filter, pPlayer->entindex(), "BaseCombatCharacter.AmmoPickup" );
}
return true;
}
else if ( FStrEq( pCmd, "repair" ) )
{
Command_Repair( pPlayer );
return true;
}
return BaseClass::ClientCommand( pPlayer, args );
}
bool CObjectDispenser::DispenseAmmo( CTFPlayer *pPlayer )
{
int iTotalPickedUp = 0;
// primary
int iPrimary = pPlayer->GiveAmmo( DISPENSER_DROP_PRIMARY, TF_AMMO_PRIMARY );
iTotalPickedUp += iPrimary;
// secondary
int iSecondary = pPlayer->GiveAmmo( DISPENSER_DROP_SECONDARY, TF_AMMO_SECONDARY );
iTotalPickedUp += iSecondary;
// metal
int iMetal = pPlayer->GiveAmmo( std::min( m_iAmmoMetal, DISPENSER_DROP_METAL ), TF_AMMO_METAL );
m_iAmmoMetal -= iMetal;
iTotalPickedUp += iMetal;
if ( iTotalPickedUp > 0 )
{
EmitSound( "BaseCombatCharacter.AmmoPickup" );
return true;
}
// return false if we didn't pick up anything
return false;
}
void CObjectDispenser::RefillThink( void )
{
SetContextThink( &CObjectDispenser::RefillThink, gpGlobals->curtime + 6, REFILL_CONTEXT );
if ( IsDisabled() )
{
return;
}
// Auto-refill half the amount as tfc, but twice as often
if ( m_iAmmoMetal < DISPENSER_MAX_METAL_AMMO )
{
m_iAmmoMetal = std::min( m_iAmmoMetal + DISPENSER_MAX_METAL_AMMO * 0.1, DISPENSER_MAX_METAL_AMMO );
EmitSound( "Building_Dispenser.GenerateMetal" );
}
}
//-----------------------------------------------------------------------------
// Generate ammo over time
//-----------------------------------------------------------------------------
void CObjectDispenser::DispenseThink( void )
{
if ( IsDisabled() )
{
// Don't heal or dispense ammo
SetContextThink( &CObjectDispenser::DispenseThink, gpGlobals->curtime + 0.1, DISPENSE_CONTEXT );
// stop healing everyone
for ( int i=m_hHealingTargets.Count()-1; i>=0; i-- )
{
EHANDLE hEnt = m_hHealingTargets[i];
CBaseEntity *pOther = hEnt.Get();
if ( pOther )
{
StopHealing( pOther );
}
}
return;
}
if ( m_flNextAmmoDispense <= gpGlobals->curtime )
{
int iNumNearbyPlayers = 0;
// find players in sphere, that are visible
static float flRadius = 64;
Vector vecOrigin = GetAbsOrigin() + Vector(0,0,32);
CBaseEntity *pListOfNearbyEntities[32];
int iNumberOfNearbyEntities = UTIL_EntitiesInSphere( pListOfNearbyEntities, 32, vecOrigin, flRadius, FL_CLIENT );
for ( int i=0;i<iNumberOfNearbyEntities;i++ )
{
CTFPlayer *pPlayer = ToTFPlayer( pListOfNearbyEntities[i] );
if ( !pPlayer || !pPlayer->IsAlive() )
continue;
DispenseAmmo( pPlayer );
iNumNearbyPlayers++;
}
// Try to dispense more often when no players are around so we
// give it as soon as possible when a new player shows up
m_flNextAmmoDispense = gpGlobals->curtime + ( ( iNumNearbyPlayers > 0 ) ? 1.0 : 0.1 );
}
// for each player in touching list
int iSize = m_hTouchingEntities.Count();
for ( int i = iSize-1; i >= 0; i-- )
{
EHANDLE hOther = m_hTouchingEntities[i];
CBaseEntity *pEnt = hOther.Get();
bool bHealingTarget = IsHealingTarget( pEnt );
bool bValidHealTarget = CouldHealTarget( pEnt );
if ( bHealingTarget && !bValidHealTarget )
{
// if we can't see them, remove them from healing list
// does nothing if we are not healing them already
StopHealing( pEnt );
}
else if ( !bHealingTarget && bValidHealTarget )
{
// if we can see them, add to healing list
// does nothing if we are healing them already
StartHealing( pEnt );
}
}
SetContextThink( &CObjectDispenser::DispenseThink, gpGlobals->curtime + 0.1, DISPENSE_CONTEXT );
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CObjectDispenser::StartTouch( CBaseEntity *pOther )
{
// add to touching entities
EHANDLE hOther = pOther;
m_hTouchingEntities.AddToTail( hOther );
if ( !IsBuilding() && !IsDisabled() && CouldHealTarget( pOther ) && !IsHealingTarget( pOther ) )
{
// try to start healing them
StartHealing( pOther );
}
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CObjectDispenser::EndTouch( CBaseEntity *pOther )
{
// remove from touching entities
EHANDLE hOther = pOther;
m_hTouchingEntities.FindAndRemove( hOther );
// remove from healing list
StopHealing( pOther );
}
//-----------------------------------------------------------------------------
// Purpose: Try to start healing this target
//-----------------------------------------------------------------------------
void CObjectDispenser::StartHealing( CBaseEntity *pOther )
{
AddHealingTarget( pOther );
CTFPlayer *pPlayer = ToTFPlayer( pOther );
if ( pPlayer )
{
pPlayer->m_Shared.Heal( GetOwner(), obj_dispenser_heal_rate.GetFloat(), true );
}
}
//-----------------------------------------------------------------------------
// Purpose: Stop healing this target
//-----------------------------------------------------------------------------
void CObjectDispenser::StopHealing( CBaseEntity *pOther )
{
bool bFound = false;
EHANDLE hOther = pOther;
bFound = m_hHealingTargets.FindAndRemove( hOther );
if ( bFound )
{
CTFPlayer *pPlayer = ToTFPlayer( pOther );
if ( pPlayer )
{
pPlayer->m_Shared.StopHealing( GetOwner() );
}
}
}
//-----------------------------------------------------------------------------
// Purpose: Is this a valid heal target? and not already healing them?
//-----------------------------------------------------------------------------
bool CObjectDispenser::CouldHealTarget( CBaseEntity *pTarget )
{
if ( !pTarget->FVisible( this, MASK_BLOCKLOS ) )
return false;
if ( pTarget->IsPlayer() && pTarget->IsAlive() )
{
CTFPlayer *pTFPlayer = ToTFPlayer( pTarget );
// don't heal enemies unless they are disguised as our team
int iTeam = GetTeamNumber();
int iPlayerTeam = pTFPlayer->GetTeamNumber();
if ( iPlayerTeam != iTeam && pTFPlayer->m_Shared.InCond( TF_COND_DISGUISED ) )
{
iPlayerTeam = pTFPlayer->m_Shared.GetDisguiseTeam();
}
if ( iPlayerTeam != iTeam )
{
return false;
}
return true;
}
return false;
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CObjectDispenser::AddHealingTarget( CBaseEntity *pOther )
{
// add to tail
EHANDLE hOther = pOther;
m_hHealingTargets.AddToTail( hOther );
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CObjectDispenser::RemoveHealingTarget( CBaseEntity *pOther )
{
// remove
EHANDLE hOther = pOther;
m_hHealingTargets.FindAndRemove( hOther );
}
//-----------------------------------------------------------------------------
// Purpose: Are we healing this target already
//-----------------------------------------------------------------------------
bool CObjectDispenser::IsHealingTarget( CBaseEntity *pTarget )
{
EHANDLE hOther = pTarget;
return m_hHealingTargets.HasElement( hOther );
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
int CObjectDispenser::DrawDebugTextOverlays(void)
{
int text_offset = BaseClass::DrawDebugTextOverlays();
if (m_debugOverlays & OVERLAY_TEXT_BIT)
{
char tempstr[512];
Q_snprintf( tempstr, sizeof( tempstr ),"Metal: %d", m_iAmmoMetal );
EntityText(text_offset,tempstr,0);
text_offset++;
}
return text_offset;
}
|
;worksheet 2
;exercise 21
; SNAKE
; 0 1 2 3 .... 9
; tail[0] --> head[9]
%TITLE "Automatic movement with delay"
.8086
.MODEL small
.STACK 256
;-----------------------------;
; DATA SEGEMENT ;
;-----------------------------;
DATA SEGMENT
direction db 00h ; 0 - right , 1 - down , 2 - left , 3 - up
delay dw 0350h ; INT 15H 86H: Wait
; Expects: AH 86H
; CX,DX interval in microseconds (1,000,000ths of a second)
; CX is high word, DX is low word
snake_len equ 0Ah
sl db snake_len
snake_row db snake_len dup (00h) ; snake cords data
snake_col db snake_len dup (00h) ; snake cords data
head_dl db 00h
head_dh db 00h
tail_dl db 00h
tail_dh db 00h
is_snake_visible db 0 ; status flag for first 10 moves, when it's less then ten
; first position 0,0 will be displayed. main goal is to simulate
; snake's roll out.
ENTER_KEY equ 0Dh
ESC_KEY equ 1Bh ; exit
SPACE_CHR equ 20h
U_KEY equ 48h ; arrow keys
D_KEY equ 50h
L_KEY equ 4Bh
R_KEY equ 4Dh
F1_KEY equ 3Bh ; function keys
F2_KEY equ 3Ch
F3_KEY equ 3Dh
F4_KEY equ 3Eh
F5_KEY equ 3Fh
F6_KEY equ 40h
F7_KEY equ 41h
F8_KEY equ 42h
row db 0
col db 0
star db "*"
color db 5fh ; current color
color_bg db 00h
color_yellow db 0EEh
color_grey db 07Fh
color_blue db 01Fh
color_green db 02Fh
color_bblue db 0BFh
color_red db 04Fh
color_pink db 0CFh
color_brown db 06Fh
color_white db 0FFh
DATA ENDS
;-----------------------------;
; END OF DATA SEGEMENT ;
;-----------------------------;
;-----------------------------;
; CODE SEGEMENT ;
;-----------------------------;
CODE SEGMENT
ASSUME CS:CODE , DS:DATA
Main PROC
mov ax , DATA ; load data segment
mov ds , ax
;call ClrScr ; there is no need for this call for now
; cursor starting position
mov ah , 02h
mov bh , 00h ; page
mov bl , color ; color
xor dx , dx ; starting position dh , dl
int 10h
jmp printSnake ; first position 0,0 , start main loop
; main loop
readUntilESC:
mov ah , 0Bh ; check stdin status , returns al
int 21h
cmp al , 00h
je continue_mov
mov ah , 07h ; read keyboard input
int 21h
; 0 - right , 1 - down , 2 - left , 3 - up
cmp al , U_KEY
je Change_dir_UP
cmp al , D_KEY
je Change_dir_DOWN
cmp al , L_KEY
je Change_dir_LEFT
cmp al , R_KEY
je Change_dir_RIGHT
; function keys go here
cmp al , F1_KEY
je F1
cmp al , F2_KEY
je F2
cmp al , F3_KEY
je F3
cmp al , F4_KEY
je F4
cmp al , F5_KEY
je F5
cmp al , F6_KEY
je F6
cmp al , F7_KEY
je F7
cmp al , F7_KEY
je F8
cmp al , ESC_KEY
jne readUntilESC ; loop until ESC
jmp Exit
; 0 - right , 1 - down , 2 - left , 3 - up
Change_dir_RIGHT:
mov direction , 00h
jmp continue_mov
Change_dir_DOWN:
mov direction , 01h
jmp continue_mov
Change_dir_LEFT:
mov direction , 02h
jmp continue_mov
Change_dir_UP:
mov direction , 03h
jmp continue_mov
; decide where to move head
continue_mov:
cmp direction , 03h
je UP
cmp direction , 01h
je DOWN
cmp direction , 02h
je LEFT
cmp direction , 00h
je RIGHT
; check console borders. resolution 80x25 (0-79 x 0-24)
UP:
cmp dh , 0
je border_top
dec dh
jmp update_head
DOWN:
cmp dh , 23
je border_down
inc dh
jmp update_head
LEFT:
cmp dl , 0
je border_left
dec dl
jmp update_head
RIGHT:
cmp dl , 79
je border_right
inc dl
jmp update_head
; check edges
border_top:
mov dh , 23
jmp update_head
border_down:
mov dh , 0
jmp update_head
border_left:
mov dl , 79
jmp update_head
border_right:
mov dl , 0
jmp update_head
; colors
F1:
mov bl , color_grey
jmp update_color
F2:
mov bl , color_blue
jmp update_color
F3:
mov bl , color_green
jmp update_color
F4:
mov bl , color_bblue
jmp update_color
F5:
mov bl , color_red
jmp update_color
F6:
mov bl , color_pink
jmp update_color
F7:
mov bl , color_brown
jmp update_color
F8:
mov bl , color_white
jmp update_color
; update variables
update_color:
mov color , bl
jmp printSnake
update_head: ; save new head position
mov head_dl , dl
mov head_dh , dh
update_snake:
call UpdateSnake
jmp printSnake
printSnake:
call DrawSnake
; delay
; INT 15h / AH = 86h - BIOS wait function
; CX:DX = interval in microseconds
push dx ; save head postion and wait
mov cx , 01h
mov dx , delay
mov ah , 86h
int 15h
pop dx
jmp readUntilESC ; main loop
Exit:
mov ah , 4Ch
int 21h
Main ENDP
;-----------------------------;
; PROCEDURES ;
;-----------------------------;
UpdateSnake PROC
xor cx , cx
mov cx , 01h
xor si , si
; update tail
mov dh , snake_row[si]
mov dl , snake_col[si]
mov tail_dh , dh
mov tail_dl , dl
Update:
mov si , cx
mov dh , snake_row[si]
mov dl , snake_col[si]
dec si
cmp si , snake_len
je ExitUpdate
mov snake_row[si] , dh
mov snake_col[si] , dl
inc cx
cmp cx , snake_len
jne Update
ExitUpdate:
; update head
mov dh , head_dh
mov dl , head_dl
mov snake_row[snake_len - 1] , dh
mov snake_col[snake_len - 1] , dl
xor cx , cx
ret
UpdateSnake ENDP
DrawSnake PROC
; Set cursor position
; int 10h
; AH = 02h BH = Page Number, DH = Row, DL = Column < !!
; Write character and attribute at cursor position
; int 10h
; AH = 09h AL = Character, BH = Page Number, BL = Color,
; CX = Number of times to print character
xor cx , cx
mov al , SPACE_CHR ; space - char
mov bh , 00h
DrawLoop: ; draw snake
mov si , cx
mov dh , snake_row[si]
mov dl , snake_col[si]
mov ah , 02h ; set position
int 10h
mov ah , 09h ; draw char
push cx
mov cx , 01h
mov bl , color
int 10h
pop cx
inc cx
cmp cx , snake_len
jne DrawLoop
cmp is_snake_visible , 10
je erase_tail
inc is_snake_visible
cmp is_snake_visible , 10
jl head_update
; erase previous tail
erase_tail:
mov dh , tail_dh
mov dl , tail_dl
mov ah , 02h ; set position
int 10h
mov ah , 09h ; draw char
mov cx , 01h
mov bl , 00h
int 10h
; set cursor to head postion and change color to snake color
head_update:
mov dh , snake_row[snake_len - 1]
mov dl , snake_col[snake_len - 1]
mov ah , 02h ; set position
mov bl , color
int 10h
xor cx , cx
ret
DrawSnake ENDP
ClrScr PROC
; Clear screen , just in case
mov dl , 20h
mov cx , 4000
whole_screen:
mov ah , 02h
int 21h
loop whole_screen
ret
ClrScr ENDP
;-----------------------------;
; END OF PROCEDURES ;
;-----------------------------;
CODE ENDS
;-----------------------------;
; END OF CODE SEGEMENT ;
;-----------------------------;
END Main |
; A142935: Primes congruent to 23 mod 64.
; Submitted by Jon Maiga
; 23,151,599,727,919,983,1303,1367,1559,1879,2647,2711,2903,3607,3671,3863,4567,4759,4951,5399,5527,5591,5783,6359,6551,6679,6871,7127,7639,7703,8087,8599,8663,9239,9431,9623,10007,10391,10711,10903,11159,11287,11351,11863,11927,12119,12503,12823,13399,13463,13591,14423,14551,15319,15383,15511,15767,15959,16087,17047,17239,17431,17623,18199,18583,18839,19031,19543,19927,19991,20183,20759,20887,21143,21911,22039,22679,22807,22871,23063,23447,23767,23831,24023,24151,24407,24919,25111,25303,25367
mov $2,$0
add $2,6
pow $2,2
lpb $2
mov $3,$4
add $3,22
seq $3,10051 ; Characteristic function of primes: 1 if n is prime, else 0.
sub $0,$3
mov $1,$0
max $1,0
cmp $1,$0
mul $2,$1
sub $2,1
add $4,64
lpe
mov $0,$4
add $0,23
|
; A081039: 4th binomial transform of (1,3,0,0,0,0,0,.....).
; 1,7,40,208,1024,4864,22528,102400,458752,2031616,8912896,38797312,167772160,721420288,3087007744,13153337344,55834574848,236223201280,996432412672,4191888080896,17592186044416,73667279060992,307863255777280,1284229581242368,5348024557502464,22236523160141824,92323792361095168,382805968326492160,1585267068834414592,6557241057451442176,27093655358260903936,111833385946864156672,461168601842738790400,1900014639592083816448,7821419487252849885184,32171121664549458018304,132226261520350065983488
mov $1,$0
mul $0,3
add $0,4
mov $2,4
pow $2,$1
mul $0,$2
div $0,4
|
; ===============================================================
; Jun 2007
; ===============================================================
;
; void *zx_cyx2aaddr(uchar row, uchar col)
;
; Attribute address of character square at row, col.
;
; ===============================================================
SECTION code_arch
PUBLIC asm_zx_cyx2aaddr
asm_zx_cyx2aaddr:
; enter : h = valid character y coordinate
; l = valid character x coordinate
;
; exit : hl = attribute address corresponding to character
;
; uses : af, hl
ld a,h
rrca
rrca
rrca
ld h,a
and $e0
or l
ld l,a
ld a,h
and $03
or $58
ld h,a
ret
|
; Default Window Theme ;)
align 4
wm_color dd 0x808080
;wm_color dd 0x004288
window_title dd 0xFFFFFF
window_inactive_title dd 0xC0C0C0
window_border dd 0x303030
window_active_border dd 0x303030
window_active_outline dd 0x00A2E8
window_close_color dd 0xD80000
window_background dd 0xD0D0D0
window_opacity db 1 ; valid values are 0 to 4, 0 = opaque, 1 = less transparent, 4 = most transparent.
align 4
window_border_x_min dw 0 ; min x pos for a 0 width window
window_border_y_min dw 24 ; min y pos for a 0 height window
window_close_position db 0 ; 0 = left, 1 = right, for now this has no effect
align 4
window_close_x dw 4
window_close_y dw 4
window_close_width dw 16
window_close_height dw 16
window_title_x dw 24
window_title_y dw 4
window_canvas_x dw 0
window_canvas_y dw 24
|
; this sample gets two numbers from the user,
; then it calculates the sum of these numbers,
; and prints it out.
name "calc"
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; these maros are copied from emu8086.inc ;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; this macro prints a string that is given as a parameter, example:
; PRINTN 'hello world!'
; the same as PRINT, but new line is automatically added.
PRINTN MACRO sdat
LOCAL next_char, s_dcl, printed, skip_dcl
PUSH AX ; store registers...
PUSH SI ;
JMP skip_dcl ; skip declaration.
s_dcl DB sdat, 0Dh,0Ah, 0
skip_dcl:
LEA SI, s_dcl
next_char:
MOV AL, CS:[SI]
CMP AL, 0
JZ printed
INC SI
MOV AH, 0Eh ; teletype function.
INT 10h
JMP next_char
printed:
POP SI ; re-store registers...
POP AX ;
ENDM
; this macro prints a char in AL and advances
; the current cursor position:
PUTC MACRO char
PUSH AX
MOV AL, char
MOV AH, 0Eh
INT 10h
POP AX
ENDM
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
org 100h
jmp start ; skip data.
msg1 db 0Dh,0Ah, 'input numbers in this range: [-32768..32767]', 0Dh,0Ah
db 0Dh,0Ah, 'enter first number: $'
msg2 db 0Dh,0Ah, 'enter second number: $'
msg3 db 0Dh,0Ah, 'the sum is: $'
; declaration of variable:
num dw ?
start:
; print first message
mov dx, offset msg1
mov ah, 9
int 21h
call scan_num
; keep first number:
mov num, cx
; print second message
mov dx, offset msg2
mov ah, 9
int 21h
call scan_num
; add numbers:
add num, cx
jo overflow
; print the result:
mov dx, offset msg3
mov ah, 9
int 21h
mov ax, num
call print_num
jmp exit
; process overlow error:
overflow:
printn 'we have overflow!'
exit:
; wait for any key press:
mov ah, 0
int 16h
ret ; return control to operating system.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; these functions are copied from emu8086.inc ;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; gets the multi-digit SIGNED number from the keyboard,
; and stores the result in CX register:
SCAN_NUM PROC NEAR
PUSH DX
PUSH AX
PUSH SI
MOV CX, 0
; reset flag:
MOV CS:make_minus, 0
next_digit:
; get char from keyboard
; into AL:
MOV AH, 00h
INT 16h
; and print it:
MOV AH, 0Eh
INT 10h
; check for MINUS:
CMP AL, '-'
JE set_minus
; check for ENTER key:
CMP AL, 0Dh ; carriage return?
JNE not_cr
JMP stop_input
not_cr:
CMP AL, 8 ; 'BACKSPACE' pressed?
JNE backspace_checked
MOV DX, 0 ; remove last digit by
MOV AX, CX ; division:
DIV CS:ten ; AX = DX:AX / 10 (DX-rem).
MOV CX, AX
PUTC ' ' ; clear position.
PUTC 8 ; backspace again.
JMP next_digit
backspace_checked:
; allow only digits:
CMP AL, '0'
JAE ok_AE_0
JMP remove_not_digit
ok_AE_0:
CMP AL, '9'
JBE ok_digit
remove_not_digit:
PUTC 8 ; backspace.
PUTC ' ' ; clear last entered not digit.
PUTC 8 ; backspace again.
JMP next_digit ; wait for next input.
ok_digit:
; multiply CX by 10 (first time the result is zero)
PUSH AX
MOV AX, CX
MUL CS:ten ; DX:AX = AX*10
MOV CX, AX
POP AX
; check if the number is too big
; (result should be 16 bits)
CMP DX, 0
JNE too_big
; convert from ASCII code:
SUB AL, 30h
; add AL to CX:
MOV AH, 0
MOV DX, CX ; backup, in case the result will be too big.
ADD CX, AX
JC too_big2 ; jump if the number is too big.
JMP next_digit
set_minus:
MOV CS:make_minus, 1
JMP next_digit
too_big2:
MOV CX, DX ; restore the backuped value before add.
MOV DX, 0 ; DX was zero before backup!
too_big:
MOV AX, CX
DIV CS:ten ; reverse last DX:AX = AX*10, make AX = DX:AX / 10
MOV CX, AX
PUTC 8 ; backspace.
PUTC ' ' ; clear last entered digit.
PUTC 8 ; backspace again.
JMP next_digit ; wait for Enter/Backspace.
stop_input:
; check flag:
CMP CS:make_minus, 0
JE not_minus
NEG CX
not_minus:
POP SI
POP AX
POP DX
RET
make_minus DB ? ; used as a flag.
SCAN_NUM ENDP
; this procedure prints number in AX,
; used with PRINT_NUM_UNS to print signed numbers:
PRINT_NUM PROC NEAR
PUSH DX
PUSH AX
CMP AX, 0
JNZ not_zero
PUTC '0'
JMP printed
not_zero:
; the check SIGN of AX,
; make absolute if it's negative:
CMP AX, 0
JNS positive
NEG AX
PUTC '-'
positive:
CALL PRINT_NUM_UNS
printed:
POP AX
POP DX
RET
PRINT_NUM ENDP
; this procedure prints out an unsigned
; number in AX (not just a single digit)
; allowed values are from 0 to 65535 (FFFF)
PRINT_NUM_UNS PROC NEAR
PUSH AX
PUSH BX
PUSH CX
PUSH DX
; flag to prevent printing zeros before number:
MOV CX, 1
; (result of "/ 10000" is always less or equal to 9).
MOV BX, 10000 ; 2710h - divider.
; AX is zero?
CMP AX, 0
JZ print_zero
begin_print:
; check divider (if zero go to end_print):
CMP BX,0
JZ end_print
; avoid printing zeros before number:
CMP CX, 0
JE calc
; if AX<BX then result of DIV will be zero:
CMP AX, BX
JB skip
calc:
MOV CX, 0 ; set flag.
MOV DX, 0
DIV BX ; AX = DX:AX / BX (DX=remainder).
; print last digit
; AH is always ZERO, so it's ignored
ADD AL, 30h ; convert to ASCII code.
PUTC AL
MOV AX, DX ; get remainder from last div.
skip:
; calculate BX=BX/10
PUSH AX
MOV DX, 0
MOV AX, BX
DIV CS:ten ; AX = DX:AX / 10 (DX=remainder).
MOV BX, AX
POP AX
JMP begin_print
print_zero:
PUTC '0'
end_print:
POP DX
POP CX
POP BX
POP AX
RET
PRINT_NUM_UNS ENDP
ten DW 10 ; used as multiplier/divider by SCAN_NUM & PRINT_NUM_UNS.
|
; A165857: Totally multiplicative sequence with a(p) = 36.
; 1,36,36,1296,36,1296,36,46656,1296,1296,36,46656,36,1296,1296,1679616,36,46656,36,46656,1296,1296,36,1679616,1296,1296,46656,46656,36,46656,36,60466176,1296,1296,1296,1679616,36,1296,1296,1679616,36,46656,36,46656,46656,1296,36,60466176,1296,46656,1296,46656,36,1679616,1296,1679616,1296,1296,36,1679616,36,1296,46656,2176782336,1296,46656,36,46656,1296,46656,36,60466176,36,1296,46656,46656,1296,46656,36,60466176,1679616,1296,36,1679616,1296,1296,1296,1679616,36,1679616,1296,46656,1296,1296,1296,2176782336,36,46656,46656,1679616
seq $0,1222 ; Number of prime divisors of n counted with multiplicity (also called bigomega(n) or Omega(n)).
mov $1,36
pow $1,$0
mov $0,$1
|
_ln: file format elf32-i386
Disassembly of section .text:
00000000 <main>:
#include "stat.h"
#include "user.h"
int
main(int argc, char *argv[])
{
0: 8d 4c 24 04 lea 0x4(%esp),%ecx
4: 83 e4 f0 and $0xfffffff0,%esp
7: ff 71 fc pushl -0x4(%ecx)
a: 55 push %ebp
b: 89 e5 mov %esp,%ebp
d: 53 push %ebx
e: 51 push %ecx
f: 89 cb mov %ecx,%ebx
if(argc != 3){
11: 83 3b 03 cmpl $0x3,(%ebx)
14: 74 17 je 2d <main+0x2d>
printf(2, "Usage: ln old new\n");
16: 83 ec 08 sub $0x8,%esp
19: 68 28 08 00 00 push $0x828
1e: 6a 02 push $0x2
20: e8 4d 04 00 00 call 472 <printf>
25: 83 c4 10 add $0x10,%esp
exit();
28: e8 9e 02 00 00 call 2cb <exit>
}
if(link(argv[1], argv[2]) < 0)
2d: 8b 43 04 mov 0x4(%ebx),%eax
30: 83 c0 08 add $0x8,%eax
33: 8b 10 mov (%eax),%edx
35: 8b 43 04 mov 0x4(%ebx),%eax
38: 83 c0 04 add $0x4,%eax
3b: 8b 00 mov (%eax),%eax
3d: 83 ec 08 sub $0x8,%esp
40: 52 push %edx
41: 50 push %eax
42: e8 e4 02 00 00 call 32b <link>
47: 83 c4 10 add $0x10,%esp
4a: 85 c0 test %eax,%eax
4c: 79 21 jns 6f <main+0x6f>
printf(2, "link %s %s: failed\n", argv[1], argv[2]);
4e: 8b 43 04 mov 0x4(%ebx),%eax
51: 83 c0 08 add $0x8,%eax
54: 8b 10 mov (%eax),%edx
56: 8b 43 04 mov 0x4(%ebx),%eax
59: 83 c0 04 add $0x4,%eax
5c: 8b 00 mov (%eax),%eax
5e: 52 push %edx
5f: 50 push %eax
60: 68 3b 08 00 00 push $0x83b
65: 6a 02 push $0x2
67: e8 06 04 00 00 call 472 <printf>
6c: 83 c4 10 add $0x10,%esp
exit();
6f: e8 57 02 00 00 call 2cb <exit>
00000074 <stosb>:
"cc");
}
static inline void
stosb(void *addr, int data, int cnt)
{
74: 55 push %ebp
75: 89 e5 mov %esp,%ebp
77: 57 push %edi
78: 53 push %ebx
asm volatile("cld; rep stosb" :
79: 8b 4d 08 mov 0x8(%ebp),%ecx
7c: 8b 55 10 mov 0x10(%ebp),%edx
7f: 8b 45 0c mov 0xc(%ebp),%eax
82: 89 cb mov %ecx,%ebx
84: 89 df mov %ebx,%edi
86: 89 d1 mov %edx,%ecx
88: fc cld
89: f3 aa rep stos %al,%es:(%edi)
8b: 89 ca mov %ecx,%edx
8d: 89 fb mov %edi,%ebx
8f: 89 5d 08 mov %ebx,0x8(%ebp)
92: 89 55 10 mov %edx,0x10(%ebp)
"=D" (addr), "=c" (cnt) :
"0" (addr), "1" (cnt), "a" (data) :
"memory", "cc");
}
95: 90 nop
96: 5b pop %ebx
97: 5f pop %edi
98: 5d pop %ebp
99: c3 ret
0000009a <strcpy>:
#include "user.h"
#include "x86.h"
char*
strcpy(char *s, char *t)
{
9a: 55 push %ebp
9b: 89 e5 mov %esp,%ebp
9d: 83 ec 10 sub $0x10,%esp
char *os;
os = s;
a0: 8b 45 08 mov 0x8(%ebp),%eax
a3: 89 45 fc mov %eax,-0x4(%ebp)
while((*s++ = *t++) != 0)
a6: 90 nop
a7: 8b 45 08 mov 0x8(%ebp),%eax
aa: 8d 50 01 lea 0x1(%eax),%edx
ad: 89 55 08 mov %edx,0x8(%ebp)
b0: 8b 55 0c mov 0xc(%ebp),%edx
b3: 8d 4a 01 lea 0x1(%edx),%ecx
b6: 89 4d 0c mov %ecx,0xc(%ebp)
b9: 0f b6 12 movzbl (%edx),%edx
bc: 88 10 mov %dl,(%eax)
be: 0f b6 00 movzbl (%eax),%eax
c1: 84 c0 test %al,%al
c3: 75 e2 jne a7 <strcpy+0xd>
;
return os;
c5: 8b 45 fc mov -0x4(%ebp),%eax
}
c8: c9 leave
c9: c3 ret
000000ca <strcmp>:
int
strcmp(const char *p, const char *q)
{
ca: 55 push %ebp
cb: 89 e5 mov %esp,%ebp
while(*p && *p == *q)
cd: eb 08 jmp d7 <strcmp+0xd>
p++, q++;
cf: 83 45 08 01 addl $0x1,0x8(%ebp)
d3: 83 45 0c 01 addl $0x1,0xc(%ebp)
}
int
strcmp(const char *p, const char *q)
{
while(*p && *p == *q)
d7: 8b 45 08 mov 0x8(%ebp),%eax
da: 0f b6 00 movzbl (%eax),%eax
dd: 84 c0 test %al,%al
df: 74 10 je f1 <strcmp+0x27>
e1: 8b 45 08 mov 0x8(%ebp),%eax
e4: 0f b6 10 movzbl (%eax),%edx
e7: 8b 45 0c mov 0xc(%ebp),%eax
ea: 0f b6 00 movzbl (%eax),%eax
ed: 38 c2 cmp %al,%dl
ef: 74 de je cf <strcmp+0x5>
p++, q++;
return (uchar)*p - (uchar)*q;
f1: 8b 45 08 mov 0x8(%ebp),%eax
f4: 0f b6 00 movzbl (%eax),%eax
f7: 0f b6 d0 movzbl %al,%edx
fa: 8b 45 0c mov 0xc(%ebp),%eax
fd: 0f b6 00 movzbl (%eax),%eax
100: 0f b6 c0 movzbl %al,%eax
103: 29 c2 sub %eax,%edx
105: 89 d0 mov %edx,%eax
}
107: 5d pop %ebp
108: c3 ret
00000109 <strlen>:
uint
strlen(char *s)
{
109: 55 push %ebp
10a: 89 e5 mov %esp,%ebp
10c: 83 ec 10 sub $0x10,%esp
int n;
for(n = 0; s[n]; n++)
10f: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%ebp)
116: eb 04 jmp 11c <strlen+0x13>
118: 83 45 fc 01 addl $0x1,-0x4(%ebp)
11c: 8b 55 fc mov -0x4(%ebp),%edx
11f: 8b 45 08 mov 0x8(%ebp),%eax
122: 01 d0 add %edx,%eax
124: 0f b6 00 movzbl (%eax),%eax
127: 84 c0 test %al,%al
129: 75 ed jne 118 <strlen+0xf>
;
return n;
12b: 8b 45 fc mov -0x4(%ebp),%eax
}
12e: c9 leave
12f: c3 ret
00000130 <memset>:
void*
memset(void *dst, int c, uint n)
{
130: 55 push %ebp
131: 89 e5 mov %esp,%ebp
stosb(dst, c, n);
133: 8b 45 10 mov 0x10(%ebp),%eax
136: 50 push %eax
137: ff 75 0c pushl 0xc(%ebp)
13a: ff 75 08 pushl 0x8(%ebp)
13d: e8 32 ff ff ff call 74 <stosb>
142: 83 c4 0c add $0xc,%esp
return dst;
145: 8b 45 08 mov 0x8(%ebp),%eax
}
148: c9 leave
149: c3 ret
0000014a <strchr>:
char*
strchr(const char *s, char c)
{
14a: 55 push %ebp
14b: 89 e5 mov %esp,%ebp
14d: 83 ec 04 sub $0x4,%esp
150: 8b 45 0c mov 0xc(%ebp),%eax
153: 88 45 fc mov %al,-0x4(%ebp)
for(; *s; s++)
156: eb 14 jmp 16c <strchr+0x22>
if(*s == c)
158: 8b 45 08 mov 0x8(%ebp),%eax
15b: 0f b6 00 movzbl (%eax),%eax
15e: 3a 45 fc cmp -0x4(%ebp),%al
161: 75 05 jne 168 <strchr+0x1e>
return (char*)s;
163: 8b 45 08 mov 0x8(%ebp),%eax
166: eb 13 jmp 17b <strchr+0x31>
}
char*
strchr(const char *s, char c)
{
for(; *s; s++)
168: 83 45 08 01 addl $0x1,0x8(%ebp)
16c: 8b 45 08 mov 0x8(%ebp),%eax
16f: 0f b6 00 movzbl (%eax),%eax
172: 84 c0 test %al,%al
174: 75 e2 jne 158 <strchr+0xe>
if(*s == c)
return (char*)s;
return 0;
176: b8 00 00 00 00 mov $0x0,%eax
}
17b: c9 leave
17c: c3 ret
0000017d <gets>:
char*
gets(char *buf, int max)
{
17d: 55 push %ebp
17e: 89 e5 mov %esp,%ebp
180: 83 ec 18 sub $0x18,%esp
int i, cc;
char c;
for(i=0; i+1 < max; ){
183: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp)
18a: eb 42 jmp 1ce <gets+0x51>
cc = read(0, &c, 1);
18c: 83 ec 04 sub $0x4,%esp
18f: 6a 01 push $0x1
191: 8d 45 ef lea -0x11(%ebp),%eax
194: 50 push %eax
195: 6a 00 push $0x0
197: e8 47 01 00 00 call 2e3 <read>
19c: 83 c4 10 add $0x10,%esp
19f: 89 45 f0 mov %eax,-0x10(%ebp)
if(cc < 1)
1a2: 83 7d f0 00 cmpl $0x0,-0x10(%ebp)
1a6: 7e 33 jle 1db <gets+0x5e>
break;
buf[i++] = c;
1a8: 8b 45 f4 mov -0xc(%ebp),%eax
1ab: 8d 50 01 lea 0x1(%eax),%edx
1ae: 89 55 f4 mov %edx,-0xc(%ebp)
1b1: 89 c2 mov %eax,%edx
1b3: 8b 45 08 mov 0x8(%ebp),%eax
1b6: 01 c2 add %eax,%edx
1b8: 0f b6 45 ef movzbl -0x11(%ebp),%eax
1bc: 88 02 mov %al,(%edx)
if(c == '\n' || c == '\r')
1be: 0f b6 45 ef movzbl -0x11(%ebp),%eax
1c2: 3c 0a cmp $0xa,%al
1c4: 74 16 je 1dc <gets+0x5f>
1c6: 0f b6 45 ef movzbl -0x11(%ebp),%eax
1ca: 3c 0d cmp $0xd,%al
1cc: 74 0e je 1dc <gets+0x5f>
gets(char *buf, int max)
{
int i, cc;
char c;
for(i=0; i+1 < max; ){
1ce: 8b 45 f4 mov -0xc(%ebp),%eax
1d1: 83 c0 01 add $0x1,%eax
1d4: 3b 45 0c cmp 0xc(%ebp),%eax
1d7: 7c b3 jl 18c <gets+0xf>
1d9: eb 01 jmp 1dc <gets+0x5f>
cc = read(0, &c, 1);
if(cc < 1)
break;
1db: 90 nop
buf[i++] = c;
if(c == '\n' || c == '\r')
break;
}
buf[i] = '\0';
1dc: 8b 55 f4 mov -0xc(%ebp),%edx
1df: 8b 45 08 mov 0x8(%ebp),%eax
1e2: 01 d0 add %edx,%eax
1e4: c6 00 00 movb $0x0,(%eax)
return buf;
1e7: 8b 45 08 mov 0x8(%ebp),%eax
}
1ea: c9 leave
1eb: c3 ret
000001ec <stat>:
int
stat(char *n, struct stat *st)
{
1ec: 55 push %ebp
1ed: 89 e5 mov %esp,%ebp
1ef: 83 ec 18 sub $0x18,%esp
int fd;
int r;
fd = open(n, O_RDONLY);
1f2: 83 ec 08 sub $0x8,%esp
1f5: 6a 00 push $0x0
1f7: ff 75 08 pushl 0x8(%ebp)
1fa: e8 0c 01 00 00 call 30b <open>
1ff: 83 c4 10 add $0x10,%esp
202: 89 45 f4 mov %eax,-0xc(%ebp)
if(fd < 0)
205: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
209: 79 07 jns 212 <stat+0x26>
return -1;
20b: b8 ff ff ff ff mov $0xffffffff,%eax
210: eb 25 jmp 237 <stat+0x4b>
r = fstat(fd, st);
212: 83 ec 08 sub $0x8,%esp
215: ff 75 0c pushl 0xc(%ebp)
218: ff 75 f4 pushl -0xc(%ebp)
21b: e8 03 01 00 00 call 323 <fstat>
220: 83 c4 10 add $0x10,%esp
223: 89 45 f0 mov %eax,-0x10(%ebp)
close(fd);
226: 83 ec 0c sub $0xc,%esp
229: ff 75 f4 pushl -0xc(%ebp)
22c: e8 c2 00 00 00 call 2f3 <close>
231: 83 c4 10 add $0x10,%esp
return r;
234: 8b 45 f0 mov -0x10(%ebp),%eax
}
237: c9 leave
238: c3 ret
00000239 <atoi>:
int
atoi(const char *s)
{
239: 55 push %ebp
23a: 89 e5 mov %esp,%ebp
23c: 83 ec 10 sub $0x10,%esp
int n;
n = 0;
23f: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%ebp)
while('0' <= *s && *s <= '9')
246: eb 25 jmp 26d <atoi+0x34>
n = n*10 + *s++ - '0';
248: 8b 55 fc mov -0x4(%ebp),%edx
24b: 89 d0 mov %edx,%eax
24d: c1 e0 02 shl $0x2,%eax
250: 01 d0 add %edx,%eax
252: 01 c0 add %eax,%eax
254: 89 c1 mov %eax,%ecx
256: 8b 45 08 mov 0x8(%ebp),%eax
259: 8d 50 01 lea 0x1(%eax),%edx
25c: 89 55 08 mov %edx,0x8(%ebp)
25f: 0f b6 00 movzbl (%eax),%eax
262: 0f be c0 movsbl %al,%eax
265: 01 c8 add %ecx,%eax
267: 83 e8 30 sub $0x30,%eax
26a: 89 45 fc mov %eax,-0x4(%ebp)
atoi(const char *s)
{
int n;
n = 0;
while('0' <= *s && *s <= '9')
26d: 8b 45 08 mov 0x8(%ebp),%eax
270: 0f b6 00 movzbl (%eax),%eax
273: 3c 2f cmp $0x2f,%al
275: 7e 0a jle 281 <atoi+0x48>
277: 8b 45 08 mov 0x8(%ebp),%eax
27a: 0f b6 00 movzbl (%eax),%eax
27d: 3c 39 cmp $0x39,%al
27f: 7e c7 jle 248 <atoi+0xf>
n = n*10 + *s++ - '0';
return n;
281: 8b 45 fc mov -0x4(%ebp),%eax
}
284: c9 leave
285: c3 ret
00000286 <memmove>:
void*
memmove(void *vdst, void *vsrc, int n)
{
286: 55 push %ebp
287: 89 e5 mov %esp,%ebp
289: 83 ec 10 sub $0x10,%esp
char *dst, *src;
dst = vdst;
28c: 8b 45 08 mov 0x8(%ebp),%eax
28f: 89 45 fc mov %eax,-0x4(%ebp)
src = vsrc;
292: 8b 45 0c mov 0xc(%ebp),%eax
295: 89 45 f8 mov %eax,-0x8(%ebp)
while(n-- > 0)
298: eb 17 jmp 2b1 <memmove+0x2b>
*dst++ = *src++;
29a: 8b 45 fc mov -0x4(%ebp),%eax
29d: 8d 50 01 lea 0x1(%eax),%edx
2a0: 89 55 fc mov %edx,-0x4(%ebp)
2a3: 8b 55 f8 mov -0x8(%ebp),%edx
2a6: 8d 4a 01 lea 0x1(%edx),%ecx
2a9: 89 4d f8 mov %ecx,-0x8(%ebp)
2ac: 0f b6 12 movzbl (%edx),%edx
2af: 88 10 mov %dl,(%eax)
{
char *dst, *src;
dst = vdst;
src = vsrc;
while(n-- > 0)
2b1: 8b 45 10 mov 0x10(%ebp),%eax
2b4: 8d 50 ff lea -0x1(%eax),%edx
2b7: 89 55 10 mov %edx,0x10(%ebp)
2ba: 85 c0 test %eax,%eax
2bc: 7f dc jg 29a <memmove+0x14>
*dst++ = *src++;
return vdst;
2be: 8b 45 08 mov 0x8(%ebp),%eax
}
2c1: c9 leave
2c2: c3 ret
000002c3 <fork>:
name: \
movl $SYS_ ## name, %eax; \
int $T_SYSCALL; \
ret
SYSCALL(fork)
2c3: b8 01 00 00 00 mov $0x1,%eax
2c8: cd 40 int $0x40
2ca: c3 ret
000002cb <exit>:
SYSCALL(exit)
2cb: b8 02 00 00 00 mov $0x2,%eax
2d0: cd 40 int $0x40
2d2: c3 ret
000002d3 <wait>:
SYSCALL(wait)
2d3: b8 03 00 00 00 mov $0x3,%eax
2d8: cd 40 int $0x40
2da: c3 ret
000002db <pipe>:
SYSCALL(pipe)
2db: b8 04 00 00 00 mov $0x4,%eax
2e0: cd 40 int $0x40
2e2: c3 ret
000002e3 <read>:
SYSCALL(read)
2e3: b8 05 00 00 00 mov $0x5,%eax
2e8: cd 40 int $0x40
2ea: c3 ret
000002eb <write>:
SYSCALL(write)
2eb: b8 10 00 00 00 mov $0x10,%eax
2f0: cd 40 int $0x40
2f2: c3 ret
000002f3 <close>:
SYSCALL(close)
2f3: b8 15 00 00 00 mov $0x15,%eax
2f8: cd 40 int $0x40
2fa: c3 ret
000002fb <kill>:
SYSCALL(kill)
2fb: b8 06 00 00 00 mov $0x6,%eax
300: cd 40 int $0x40
302: c3 ret
00000303 <exec>:
SYSCALL(exec)
303: b8 07 00 00 00 mov $0x7,%eax
308: cd 40 int $0x40
30a: c3 ret
0000030b <open>:
SYSCALL(open)
30b: b8 0f 00 00 00 mov $0xf,%eax
310: cd 40 int $0x40
312: c3 ret
00000313 <mknod>:
SYSCALL(mknod)
313: b8 11 00 00 00 mov $0x11,%eax
318: cd 40 int $0x40
31a: c3 ret
0000031b <unlink>:
SYSCALL(unlink)
31b: b8 12 00 00 00 mov $0x12,%eax
320: cd 40 int $0x40
322: c3 ret
00000323 <fstat>:
SYSCALL(fstat)
323: b8 08 00 00 00 mov $0x8,%eax
328: cd 40 int $0x40
32a: c3 ret
0000032b <link>:
SYSCALL(link)
32b: b8 13 00 00 00 mov $0x13,%eax
330: cd 40 int $0x40
332: c3 ret
00000333 <mkdir>:
SYSCALL(mkdir)
333: b8 14 00 00 00 mov $0x14,%eax
338: cd 40 int $0x40
33a: c3 ret
0000033b <chdir>:
SYSCALL(chdir)
33b: b8 09 00 00 00 mov $0x9,%eax
340: cd 40 int $0x40
342: c3 ret
00000343 <dup>:
SYSCALL(dup)
343: b8 0a 00 00 00 mov $0xa,%eax
348: cd 40 int $0x40
34a: c3 ret
0000034b <getpid>:
SYSCALL(getpid)
34b: b8 0b 00 00 00 mov $0xb,%eax
350: cd 40 int $0x40
352: c3 ret
00000353 <sbrk>:
SYSCALL(sbrk)
353: b8 0c 00 00 00 mov $0xc,%eax
358: cd 40 int $0x40
35a: c3 ret
0000035b <sleep>:
SYSCALL(sleep)
35b: b8 0d 00 00 00 mov $0xd,%eax
360: cd 40 int $0x40
362: c3 ret
00000363 <uptime>:
SYSCALL(uptime)
363: b8 0e 00 00 00 mov $0xe,%eax
368: cd 40 int $0x40
36a: c3 ret
0000036b <halt>:
SYSCALL(halt)
36b: b8 16 00 00 00 mov $0x16,%eax
370: cd 40 int $0x40
372: c3 ret
00000373 <thread_create>:
SYSCALL(thread_create)
373: b8 17 00 00 00 mov $0x17,%eax
378: cd 40 int $0x40
37a: c3 ret
0000037b <thread_exit>:
SYSCALL(thread_exit)
37b: b8 18 00 00 00 mov $0x18,%eax
380: cd 40 int $0x40
382: c3 ret
00000383 <thread_join>:
SYSCALL(thread_join)
383: b8 19 00 00 00 mov $0x19,%eax
388: cd 40 int $0x40
38a: c3 ret
0000038b <gettid>:
SYSCALL(gettid)
38b: b8 1a 00 00 00 mov $0x1a,%eax
390: cd 40 int $0x40
392: c3 ret
00000393 <clone>:
SYSCALL(clone)
393: b8 1b 00 00 00 mov $0x1b,%eax
398: cd 40 int $0x40
39a: c3 ret
0000039b <putc>:
#include "stat.h"
#include "user.h"
static void
putc(int fd, char c)
{
39b: 55 push %ebp
39c: 89 e5 mov %esp,%ebp
39e: 83 ec 18 sub $0x18,%esp
3a1: 8b 45 0c mov 0xc(%ebp),%eax
3a4: 88 45 f4 mov %al,-0xc(%ebp)
write(fd, &c, 1);
3a7: 83 ec 04 sub $0x4,%esp
3aa: 6a 01 push $0x1
3ac: 8d 45 f4 lea -0xc(%ebp),%eax
3af: 50 push %eax
3b0: ff 75 08 pushl 0x8(%ebp)
3b3: e8 33 ff ff ff call 2eb <write>
3b8: 83 c4 10 add $0x10,%esp
}
3bb: 90 nop
3bc: c9 leave
3bd: c3 ret
000003be <printint>:
static void
printint(int fd, int xx, int base, int sgn)
{
3be: 55 push %ebp
3bf: 89 e5 mov %esp,%ebp
3c1: 53 push %ebx
3c2: 83 ec 24 sub $0x24,%esp
static char digits[] = "0123456789ABCDEF";
char buf[16];
int i, neg;
uint x;
neg = 0;
3c5: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp)
if(sgn && xx < 0){
3cc: 83 7d 14 00 cmpl $0x0,0x14(%ebp)
3d0: 74 17 je 3e9 <printint+0x2b>
3d2: 83 7d 0c 00 cmpl $0x0,0xc(%ebp)
3d6: 79 11 jns 3e9 <printint+0x2b>
neg = 1;
3d8: c7 45 f0 01 00 00 00 movl $0x1,-0x10(%ebp)
x = -xx;
3df: 8b 45 0c mov 0xc(%ebp),%eax
3e2: f7 d8 neg %eax
3e4: 89 45 ec mov %eax,-0x14(%ebp)
3e7: eb 06 jmp 3ef <printint+0x31>
} else {
x = xx;
3e9: 8b 45 0c mov 0xc(%ebp),%eax
3ec: 89 45 ec mov %eax,-0x14(%ebp)
}
i = 0;
3ef: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp)
do{
buf[i++] = digits[x % base];
3f6: 8b 4d f4 mov -0xc(%ebp),%ecx
3f9: 8d 41 01 lea 0x1(%ecx),%eax
3fc: 89 45 f4 mov %eax,-0xc(%ebp)
3ff: 8b 5d 10 mov 0x10(%ebp),%ebx
402: 8b 45 ec mov -0x14(%ebp),%eax
405: ba 00 00 00 00 mov $0x0,%edx
40a: f7 f3 div %ebx
40c: 89 d0 mov %edx,%eax
40e: 0f b6 80 a4 0a 00 00 movzbl 0xaa4(%eax),%eax
415: 88 44 0d dc mov %al,-0x24(%ebp,%ecx,1)
}while((x /= base) != 0);
419: 8b 5d 10 mov 0x10(%ebp),%ebx
41c: 8b 45 ec mov -0x14(%ebp),%eax
41f: ba 00 00 00 00 mov $0x0,%edx
424: f7 f3 div %ebx
426: 89 45 ec mov %eax,-0x14(%ebp)
429: 83 7d ec 00 cmpl $0x0,-0x14(%ebp)
42d: 75 c7 jne 3f6 <printint+0x38>
if(neg)
42f: 83 7d f0 00 cmpl $0x0,-0x10(%ebp)
433: 74 2d je 462 <printint+0xa4>
buf[i++] = '-';
435: 8b 45 f4 mov -0xc(%ebp),%eax
438: 8d 50 01 lea 0x1(%eax),%edx
43b: 89 55 f4 mov %edx,-0xc(%ebp)
43e: c6 44 05 dc 2d movb $0x2d,-0x24(%ebp,%eax,1)
while(--i >= 0)
443: eb 1d jmp 462 <printint+0xa4>
putc(fd, buf[i]);
445: 8d 55 dc lea -0x24(%ebp),%edx
448: 8b 45 f4 mov -0xc(%ebp),%eax
44b: 01 d0 add %edx,%eax
44d: 0f b6 00 movzbl (%eax),%eax
450: 0f be c0 movsbl %al,%eax
453: 83 ec 08 sub $0x8,%esp
456: 50 push %eax
457: ff 75 08 pushl 0x8(%ebp)
45a: e8 3c ff ff ff call 39b <putc>
45f: 83 c4 10 add $0x10,%esp
buf[i++] = digits[x % base];
}while((x /= base) != 0);
if(neg)
buf[i++] = '-';
while(--i >= 0)
462: 83 6d f4 01 subl $0x1,-0xc(%ebp)
466: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
46a: 79 d9 jns 445 <printint+0x87>
putc(fd, buf[i]);
}
46c: 90 nop
46d: 8b 5d fc mov -0x4(%ebp),%ebx
470: c9 leave
471: c3 ret
00000472 <printf>:
// Print to the given fd. Only understands %d, %x, %p, %s.
void
printf(int fd, char *fmt, ...)
{
472: 55 push %ebp
473: 89 e5 mov %esp,%ebp
475: 83 ec 28 sub $0x28,%esp
char *s;
int c, i, state;
uint *ap;
state = 0;
478: c7 45 ec 00 00 00 00 movl $0x0,-0x14(%ebp)
ap = (uint*)(void*)&fmt + 1;
47f: 8d 45 0c lea 0xc(%ebp),%eax
482: 83 c0 04 add $0x4,%eax
485: 89 45 e8 mov %eax,-0x18(%ebp)
for(i = 0; fmt[i]; i++){
488: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp)
48f: e9 59 01 00 00 jmp 5ed <printf+0x17b>
c = fmt[i] & 0xff;
494: 8b 55 0c mov 0xc(%ebp),%edx
497: 8b 45 f0 mov -0x10(%ebp),%eax
49a: 01 d0 add %edx,%eax
49c: 0f b6 00 movzbl (%eax),%eax
49f: 0f be c0 movsbl %al,%eax
4a2: 25 ff 00 00 00 and $0xff,%eax
4a7: 89 45 e4 mov %eax,-0x1c(%ebp)
if(state == 0){
4aa: 83 7d ec 00 cmpl $0x0,-0x14(%ebp)
4ae: 75 2c jne 4dc <printf+0x6a>
if(c == '%'){
4b0: 83 7d e4 25 cmpl $0x25,-0x1c(%ebp)
4b4: 75 0c jne 4c2 <printf+0x50>
state = '%';
4b6: c7 45 ec 25 00 00 00 movl $0x25,-0x14(%ebp)
4bd: e9 27 01 00 00 jmp 5e9 <printf+0x177>
} else {
putc(fd, c);
4c2: 8b 45 e4 mov -0x1c(%ebp),%eax
4c5: 0f be c0 movsbl %al,%eax
4c8: 83 ec 08 sub $0x8,%esp
4cb: 50 push %eax
4cc: ff 75 08 pushl 0x8(%ebp)
4cf: e8 c7 fe ff ff call 39b <putc>
4d4: 83 c4 10 add $0x10,%esp
4d7: e9 0d 01 00 00 jmp 5e9 <printf+0x177>
}
} else if(state == '%'){
4dc: 83 7d ec 25 cmpl $0x25,-0x14(%ebp)
4e0: 0f 85 03 01 00 00 jne 5e9 <printf+0x177>
if(c == 'd'){
4e6: 83 7d e4 64 cmpl $0x64,-0x1c(%ebp)
4ea: 75 1e jne 50a <printf+0x98>
printint(fd, *ap, 10, 1);
4ec: 8b 45 e8 mov -0x18(%ebp),%eax
4ef: 8b 00 mov (%eax),%eax
4f1: 6a 01 push $0x1
4f3: 6a 0a push $0xa
4f5: 50 push %eax
4f6: ff 75 08 pushl 0x8(%ebp)
4f9: e8 c0 fe ff ff call 3be <printint>
4fe: 83 c4 10 add $0x10,%esp
ap++;
501: 83 45 e8 04 addl $0x4,-0x18(%ebp)
505: e9 d8 00 00 00 jmp 5e2 <printf+0x170>
} else if(c == 'x' || c == 'p'){
50a: 83 7d e4 78 cmpl $0x78,-0x1c(%ebp)
50e: 74 06 je 516 <printf+0xa4>
510: 83 7d e4 70 cmpl $0x70,-0x1c(%ebp)
514: 75 1e jne 534 <printf+0xc2>
printint(fd, *ap, 16, 0);
516: 8b 45 e8 mov -0x18(%ebp),%eax
519: 8b 00 mov (%eax),%eax
51b: 6a 00 push $0x0
51d: 6a 10 push $0x10
51f: 50 push %eax
520: ff 75 08 pushl 0x8(%ebp)
523: e8 96 fe ff ff call 3be <printint>
528: 83 c4 10 add $0x10,%esp
ap++;
52b: 83 45 e8 04 addl $0x4,-0x18(%ebp)
52f: e9 ae 00 00 00 jmp 5e2 <printf+0x170>
} else if(c == 's'){
534: 83 7d e4 73 cmpl $0x73,-0x1c(%ebp)
538: 75 43 jne 57d <printf+0x10b>
s = (char*)*ap;
53a: 8b 45 e8 mov -0x18(%ebp),%eax
53d: 8b 00 mov (%eax),%eax
53f: 89 45 f4 mov %eax,-0xc(%ebp)
ap++;
542: 83 45 e8 04 addl $0x4,-0x18(%ebp)
if(s == 0)
546: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
54a: 75 25 jne 571 <printf+0xff>
s = "(null)";
54c: c7 45 f4 4f 08 00 00 movl $0x84f,-0xc(%ebp)
while(*s != 0){
553: eb 1c jmp 571 <printf+0xff>
putc(fd, *s);
555: 8b 45 f4 mov -0xc(%ebp),%eax
558: 0f b6 00 movzbl (%eax),%eax
55b: 0f be c0 movsbl %al,%eax
55e: 83 ec 08 sub $0x8,%esp
561: 50 push %eax
562: ff 75 08 pushl 0x8(%ebp)
565: e8 31 fe ff ff call 39b <putc>
56a: 83 c4 10 add $0x10,%esp
s++;
56d: 83 45 f4 01 addl $0x1,-0xc(%ebp)
} else if(c == 's'){
s = (char*)*ap;
ap++;
if(s == 0)
s = "(null)";
while(*s != 0){
571: 8b 45 f4 mov -0xc(%ebp),%eax
574: 0f b6 00 movzbl (%eax),%eax
577: 84 c0 test %al,%al
579: 75 da jne 555 <printf+0xe3>
57b: eb 65 jmp 5e2 <printf+0x170>
putc(fd, *s);
s++;
}
} else if(c == 'c'){
57d: 83 7d e4 63 cmpl $0x63,-0x1c(%ebp)
581: 75 1d jne 5a0 <printf+0x12e>
putc(fd, *ap);
583: 8b 45 e8 mov -0x18(%ebp),%eax
586: 8b 00 mov (%eax),%eax
588: 0f be c0 movsbl %al,%eax
58b: 83 ec 08 sub $0x8,%esp
58e: 50 push %eax
58f: ff 75 08 pushl 0x8(%ebp)
592: e8 04 fe ff ff call 39b <putc>
597: 83 c4 10 add $0x10,%esp
ap++;
59a: 83 45 e8 04 addl $0x4,-0x18(%ebp)
59e: eb 42 jmp 5e2 <printf+0x170>
} else if(c == '%'){
5a0: 83 7d e4 25 cmpl $0x25,-0x1c(%ebp)
5a4: 75 17 jne 5bd <printf+0x14b>
putc(fd, c);
5a6: 8b 45 e4 mov -0x1c(%ebp),%eax
5a9: 0f be c0 movsbl %al,%eax
5ac: 83 ec 08 sub $0x8,%esp
5af: 50 push %eax
5b0: ff 75 08 pushl 0x8(%ebp)
5b3: e8 e3 fd ff ff call 39b <putc>
5b8: 83 c4 10 add $0x10,%esp
5bb: eb 25 jmp 5e2 <printf+0x170>
} else {
// Unknown % sequence. Print it to draw attention.
putc(fd, '%');
5bd: 83 ec 08 sub $0x8,%esp
5c0: 6a 25 push $0x25
5c2: ff 75 08 pushl 0x8(%ebp)
5c5: e8 d1 fd ff ff call 39b <putc>
5ca: 83 c4 10 add $0x10,%esp
putc(fd, c);
5cd: 8b 45 e4 mov -0x1c(%ebp),%eax
5d0: 0f be c0 movsbl %al,%eax
5d3: 83 ec 08 sub $0x8,%esp
5d6: 50 push %eax
5d7: ff 75 08 pushl 0x8(%ebp)
5da: e8 bc fd ff ff call 39b <putc>
5df: 83 c4 10 add $0x10,%esp
}
state = 0;
5e2: c7 45 ec 00 00 00 00 movl $0x0,-0x14(%ebp)
int c, i, state;
uint *ap;
state = 0;
ap = (uint*)(void*)&fmt + 1;
for(i = 0; fmt[i]; i++){
5e9: 83 45 f0 01 addl $0x1,-0x10(%ebp)
5ed: 8b 55 0c mov 0xc(%ebp),%edx
5f0: 8b 45 f0 mov -0x10(%ebp),%eax
5f3: 01 d0 add %edx,%eax
5f5: 0f b6 00 movzbl (%eax),%eax
5f8: 84 c0 test %al,%al
5fa: 0f 85 94 fe ff ff jne 494 <printf+0x22>
putc(fd, c);
}
state = 0;
}
}
}
600: 90 nop
601: c9 leave
602: c3 ret
00000603 <free>:
static Header base;
static Header *freep;
void
free(void *ap)
{
603: 55 push %ebp
604: 89 e5 mov %esp,%ebp
606: 83 ec 10 sub $0x10,%esp
Header *bp, *p;
bp = (Header*)ap - 1;
609: 8b 45 08 mov 0x8(%ebp),%eax
60c: 83 e8 08 sub $0x8,%eax
60f: 89 45 f8 mov %eax,-0x8(%ebp)
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
612: a1 c0 0a 00 00 mov 0xac0,%eax
617: 89 45 fc mov %eax,-0x4(%ebp)
61a: eb 24 jmp 640 <free+0x3d>
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
61c: 8b 45 fc mov -0x4(%ebp),%eax
61f: 8b 00 mov (%eax),%eax
621: 3b 45 fc cmp -0x4(%ebp),%eax
624: 77 12 ja 638 <free+0x35>
626: 8b 45 f8 mov -0x8(%ebp),%eax
629: 3b 45 fc cmp -0x4(%ebp),%eax
62c: 77 24 ja 652 <free+0x4f>
62e: 8b 45 fc mov -0x4(%ebp),%eax
631: 8b 00 mov (%eax),%eax
633: 3b 45 f8 cmp -0x8(%ebp),%eax
636: 77 1a ja 652 <free+0x4f>
free(void *ap)
{
Header *bp, *p;
bp = (Header*)ap - 1;
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
638: 8b 45 fc mov -0x4(%ebp),%eax
63b: 8b 00 mov (%eax),%eax
63d: 89 45 fc mov %eax,-0x4(%ebp)
640: 8b 45 f8 mov -0x8(%ebp),%eax
643: 3b 45 fc cmp -0x4(%ebp),%eax
646: 76 d4 jbe 61c <free+0x19>
648: 8b 45 fc mov -0x4(%ebp),%eax
64b: 8b 00 mov (%eax),%eax
64d: 3b 45 f8 cmp -0x8(%ebp),%eax
650: 76 ca jbe 61c <free+0x19>
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
break;
if(bp + bp->s.size == p->s.ptr){
652: 8b 45 f8 mov -0x8(%ebp),%eax
655: 8b 40 04 mov 0x4(%eax),%eax
658: 8d 14 c5 00 00 00 00 lea 0x0(,%eax,8),%edx
65f: 8b 45 f8 mov -0x8(%ebp),%eax
662: 01 c2 add %eax,%edx
664: 8b 45 fc mov -0x4(%ebp),%eax
667: 8b 00 mov (%eax),%eax
669: 39 c2 cmp %eax,%edx
66b: 75 24 jne 691 <free+0x8e>
bp->s.size += p->s.ptr->s.size;
66d: 8b 45 f8 mov -0x8(%ebp),%eax
670: 8b 50 04 mov 0x4(%eax),%edx
673: 8b 45 fc mov -0x4(%ebp),%eax
676: 8b 00 mov (%eax),%eax
678: 8b 40 04 mov 0x4(%eax),%eax
67b: 01 c2 add %eax,%edx
67d: 8b 45 f8 mov -0x8(%ebp),%eax
680: 89 50 04 mov %edx,0x4(%eax)
bp->s.ptr = p->s.ptr->s.ptr;
683: 8b 45 fc mov -0x4(%ebp),%eax
686: 8b 00 mov (%eax),%eax
688: 8b 10 mov (%eax),%edx
68a: 8b 45 f8 mov -0x8(%ebp),%eax
68d: 89 10 mov %edx,(%eax)
68f: eb 0a jmp 69b <free+0x98>
} else
bp->s.ptr = p->s.ptr;
691: 8b 45 fc mov -0x4(%ebp),%eax
694: 8b 10 mov (%eax),%edx
696: 8b 45 f8 mov -0x8(%ebp),%eax
699: 89 10 mov %edx,(%eax)
if(p + p->s.size == bp){
69b: 8b 45 fc mov -0x4(%ebp),%eax
69e: 8b 40 04 mov 0x4(%eax),%eax
6a1: 8d 14 c5 00 00 00 00 lea 0x0(,%eax,8),%edx
6a8: 8b 45 fc mov -0x4(%ebp),%eax
6ab: 01 d0 add %edx,%eax
6ad: 3b 45 f8 cmp -0x8(%ebp),%eax
6b0: 75 20 jne 6d2 <free+0xcf>
p->s.size += bp->s.size;
6b2: 8b 45 fc mov -0x4(%ebp),%eax
6b5: 8b 50 04 mov 0x4(%eax),%edx
6b8: 8b 45 f8 mov -0x8(%ebp),%eax
6bb: 8b 40 04 mov 0x4(%eax),%eax
6be: 01 c2 add %eax,%edx
6c0: 8b 45 fc mov -0x4(%ebp),%eax
6c3: 89 50 04 mov %edx,0x4(%eax)
p->s.ptr = bp->s.ptr;
6c6: 8b 45 f8 mov -0x8(%ebp),%eax
6c9: 8b 10 mov (%eax),%edx
6cb: 8b 45 fc mov -0x4(%ebp),%eax
6ce: 89 10 mov %edx,(%eax)
6d0: eb 08 jmp 6da <free+0xd7>
} else
p->s.ptr = bp;
6d2: 8b 45 fc mov -0x4(%ebp),%eax
6d5: 8b 55 f8 mov -0x8(%ebp),%edx
6d8: 89 10 mov %edx,(%eax)
freep = p;
6da: 8b 45 fc mov -0x4(%ebp),%eax
6dd: a3 c0 0a 00 00 mov %eax,0xac0
}
6e2: 90 nop
6e3: c9 leave
6e4: c3 ret
000006e5 <morecore>:
static Header*
morecore(uint nu)
{
6e5: 55 push %ebp
6e6: 89 e5 mov %esp,%ebp
6e8: 83 ec 18 sub $0x18,%esp
char *p;
Header *hp;
if(nu < 4096)
6eb: 81 7d 08 ff 0f 00 00 cmpl $0xfff,0x8(%ebp)
6f2: 77 07 ja 6fb <morecore+0x16>
nu = 4096;
6f4: c7 45 08 00 10 00 00 movl $0x1000,0x8(%ebp)
p = sbrk(nu * sizeof(Header));
6fb: 8b 45 08 mov 0x8(%ebp),%eax
6fe: c1 e0 03 shl $0x3,%eax
701: 83 ec 0c sub $0xc,%esp
704: 50 push %eax
705: e8 49 fc ff ff call 353 <sbrk>
70a: 83 c4 10 add $0x10,%esp
70d: 89 45 f4 mov %eax,-0xc(%ebp)
if(p == (char*)-1)
710: 83 7d f4 ff cmpl $0xffffffff,-0xc(%ebp)
714: 75 07 jne 71d <morecore+0x38>
return 0;
716: b8 00 00 00 00 mov $0x0,%eax
71b: eb 26 jmp 743 <morecore+0x5e>
hp = (Header*)p;
71d: 8b 45 f4 mov -0xc(%ebp),%eax
720: 89 45 f0 mov %eax,-0x10(%ebp)
hp->s.size = nu;
723: 8b 45 f0 mov -0x10(%ebp),%eax
726: 8b 55 08 mov 0x8(%ebp),%edx
729: 89 50 04 mov %edx,0x4(%eax)
free((void*)(hp + 1));
72c: 8b 45 f0 mov -0x10(%ebp),%eax
72f: 83 c0 08 add $0x8,%eax
732: 83 ec 0c sub $0xc,%esp
735: 50 push %eax
736: e8 c8 fe ff ff call 603 <free>
73b: 83 c4 10 add $0x10,%esp
return freep;
73e: a1 c0 0a 00 00 mov 0xac0,%eax
}
743: c9 leave
744: c3 ret
00000745 <malloc>:
void*
malloc(uint nbytes)
{
745: 55 push %ebp
746: 89 e5 mov %esp,%ebp
748: 83 ec 18 sub $0x18,%esp
Header *p, *prevp;
uint nunits;
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
74b: 8b 45 08 mov 0x8(%ebp),%eax
74e: 83 c0 07 add $0x7,%eax
751: c1 e8 03 shr $0x3,%eax
754: 83 c0 01 add $0x1,%eax
757: 89 45 ec mov %eax,-0x14(%ebp)
if((prevp = freep) == 0){
75a: a1 c0 0a 00 00 mov 0xac0,%eax
75f: 89 45 f0 mov %eax,-0x10(%ebp)
762: 83 7d f0 00 cmpl $0x0,-0x10(%ebp)
766: 75 23 jne 78b <malloc+0x46>
base.s.ptr = freep = prevp = &base;
768: c7 45 f0 b8 0a 00 00 movl $0xab8,-0x10(%ebp)
76f: 8b 45 f0 mov -0x10(%ebp),%eax
772: a3 c0 0a 00 00 mov %eax,0xac0
777: a1 c0 0a 00 00 mov 0xac0,%eax
77c: a3 b8 0a 00 00 mov %eax,0xab8
base.s.size = 0;
781: c7 05 bc 0a 00 00 00 movl $0x0,0xabc
788: 00 00 00
}
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
78b: 8b 45 f0 mov -0x10(%ebp),%eax
78e: 8b 00 mov (%eax),%eax
790: 89 45 f4 mov %eax,-0xc(%ebp)
if(p->s.size >= nunits){
793: 8b 45 f4 mov -0xc(%ebp),%eax
796: 8b 40 04 mov 0x4(%eax),%eax
799: 3b 45 ec cmp -0x14(%ebp),%eax
79c: 72 4d jb 7eb <malloc+0xa6>
if(p->s.size == nunits)
79e: 8b 45 f4 mov -0xc(%ebp),%eax
7a1: 8b 40 04 mov 0x4(%eax),%eax
7a4: 3b 45 ec cmp -0x14(%ebp),%eax
7a7: 75 0c jne 7b5 <malloc+0x70>
prevp->s.ptr = p->s.ptr;
7a9: 8b 45 f4 mov -0xc(%ebp),%eax
7ac: 8b 10 mov (%eax),%edx
7ae: 8b 45 f0 mov -0x10(%ebp),%eax
7b1: 89 10 mov %edx,(%eax)
7b3: eb 26 jmp 7db <malloc+0x96>
else {
p->s.size -= nunits;
7b5: 8b 45 f4 mov -0xc(%ebp),%eax
7b8: 8b 40 04 mov 0x4(%eax),%eax
7bb: 2b 45 ec sub -0x14(%ebp),%eax
7be: 89 c2 mov %eax,%edx
7c0: 8b 45 f4 mov -0xc(%ebp),%eax
7c3: 89 50 04 mov %edx,0x4(%eax)
p += p->s.size;
7c6: 8b 45 f4 mov -0xc(%ebp),%eax
7c9: 8b 40 04 mov 0x4(%eax),%eax
7cc: c1 e0 03 shl $0x3,%eax
7cf: 01 45 f4 add %eax,-0xc(%ebp)
p->s.size = nunits;
7d2: 8b 45 f4 mov -0xc(%ebp),%eax
7d5: 8b 55 ec mov -0x14(%ebp),%edx
7d8: 89 50 04 mov %edx,0x4(%eax)
}
freep = prevp;
7db: 8b 45 f0 mov -0x10(%ebp),%eax
7de: a3 c0 0a 00 00 mov %eax,0xac0
return (void*)(p + 1);
7e3: 8b 45 f4 mov -0xc(%ebp),%eax
7e6: 83 c0 08 add $0x8,%eax
7e9: eb 3b jmp 826 <malloc+0xe1>
}
if(p == freep)
7eb: a1 c0 0a 00 00 mov 0xac0,%eax
7f0: 39 45 f4 cmp %eax,-0xc(%ebp)
7f3: 75 1e jne 813 <malloc+0xce>
if((p = morecore(nunits)) == 0)
7f5: 83 ec 0c sub $0xc,%esp
7f8: ff 75 ec pushl -0x14(%ebp)
7fb: e8 e5 fe ff ff call 6e5 <morecore>
800: 83 c4 10 add $0x10,%esp
803: 89 45 f4 mov %eax,-0xc(%ebp)
806: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
80a: 75 07 jne 813 <malloc+0xce>
return 0;
80c: b8 00 00 00 00 mov $0x0,%eax
811: eb 13 jmp 826 <malloc+0xe1>
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
if((prevp = freep) == 0){
base.s.ptr = freep = prevp = &base;
base.s.size = 0;
}
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
813: 8b 45 f4 mov -0xc(%ebp),%eax
816: 89 45 f0 mov %eax,-0x10(%ebp)
819: 8b 45 f4 mov -0xc(%ebp),%eax
81c: 8b 00 mov (%eax),%eax
81e: 89 45 f4 mov %eax,-0xc(%ebp)
return (void*)(p + 1);
}
if(p == freep)
if((p = morecore(nunits)) == 0)
return 0;
}
821: e9 6d ff ff ff jmp 793 <malloc+0x4e>
}
826: c9 leave
827: c3 ret
|
#include "Hammer.h"
#define HAMMER_CODE 'H'
#define HAMMER_STATE '0'
Hammer::Hammer(int posX, int posY, int width, int height, int speedX, int speedY) :
Entity(HAMMER_CODE, posX, posY, width, height, speedX, speedY, HAMMER_STATE,'T')
{}
Hammer::~Hammer(){} |
; A303589: Floor(n*alpha)-1, where alpha is the number with continued fraction expansion [1;1,2,3,4,5,...] (A247844).
; 0,2,4,5,7,9,10,12,14,15,17,19,21,22,24,26,27,29,31,32,34,36,38,39,41,43,44,46,48,49,51,53,55,56,58,60,61,63,65,66,68,70,72,73,75,77,78,80,82,83,85,87,88,90,92,94,95,97,99,100,102,104,105,107,109,111,112,114
add $0,1
mov $1,36
mov $2,5
mul $2,$0
mul $1,$2
sub $1,1
div $1,106
sub $1,1
|
; int dup2(int fd, int fd2)
SECTION code_clib
SECTION code_fcntl
PUBLIC _dup2
EXTERN asm_dup2
_dup2:
pop af
pop hl
pop de
push de
push hl
push af
jp asm_dup2
|
#include <atomic>
#include <utility>
#include <common/instance_id.hpp>
namespace
{
std::uint32_t get_id()
{
static std::atomic<std::uint32_t> uid{0};
return ++uid;
}
} // namespace
namespace framework
{
InstanceId::InstanceId()
: m_id(get_id())
{}
bool operator==(const InstanceId& lhs, const InstanceId& rhs)
{
return lhs.m_id == rhs.m_id;
}
bool operator==(const InstanceId& lhs, const InstanceId::ValueType& rhs)
{
return lhs.m_id == rhs;
}
bool operator!=(const InstanceId& lhs, const InstanceId& rhs)
{
return !(lhs == rhs);
}
bool operator!=(const InstanceId& lhs, const InstanceId::ValueType& rhs)
{
return !(lhs == rhs);
}
bool operator<(const InstanceId& lhs, const InstanceId& rhs)
{
return lhs.m_id < rhs.m_id;
}
bool operator>(const InstanceId& lhs, const InstanceId& rhs)
{
return rhs < lhs;
}
void swap(InstanceId& lhs, InstanceId& rhs) noexcept
{
using std::swap;
swap(lhs.m_id, rhs.m_id);
}
std::ostream& operator<<(std::ostream& os, const InstanceId& instance_id)
{
os << instance_id.m_id;
return os;
}
} // namespace framework
|
global _print_space
_print_space:
push bp
mov bp, sp
call os_print_space
pop bp
ret |
/* -*- c-file-style:"stroustrup"; indent-tabs-mode: nil -*- */
#include "pubnub.hpp"
#include <iostream>
#include <exception>
/* Please note that this sample is the same whether you use the Pubnub
C "sync" or "callback" interface during the build.
Also, code that assumes C++ 11 features is protected by the
standard "feature test" macro, hopefully your compiler has
implemented it correctly.
*/
int main()
{
try {
enum pubnub_res res;
std::string chan("hello_world");
pubnub::context pb("demo", "demo");
/* Leave this commented out to use the default - which is
blocking I/O on most platforms. Uncomment to use non-
blocking I/O.
*/
pb.set_blocking_io(pubnub::non_blocking);
if (0 != pb.set_uuid_v4_random()) {
pb.set_uuid("zeka-peka-iz-jendeka");
}
else {
std::cout << "Generated UUID: " << pb.uuid() << std::endl;
}
pb.set_auth("danaske");
pb.set_transaction_timeout(
#if __cplusplus >= 201103L
std::chrono::seconds(10)
#else
10000
#endif
);
std::cout << "First subscribe / connect" << std::endl;
if (PNR_OK == pb.subscribe(chan).await()) {
std::cout << "Subscribe/connected!" << std::endl;
}
else {
std::cout << "Subscribe failed!" << std::endl;
}
#if PUBNUB_CRYPTO_API
std::cout << "Publishing encrypted" << std::endl;
pubnub::futres futres = pb.publish_encrypted(chan, "\"Hello world from C++!\"", "KUKUMENEGRDNA");
#else
std::cout << "Publishing" << std::endl;
pubnub::futres futres = pb.publish(chan, "\"Hello world from C++!\"");
#endif
res = futres.await();
if (PNR_OK == res) {
std::cout << "Published! Response from Pubnub: " << pb.last_publish_result() << std::endl;
}
else if (PNR_PUBLISH_FAILED == res) {
std::cout << "Published failed on Pubnub, description: " << pb.last_publish_result() << std::endl;
}
else {
std::cout << "Publishing failed with code: " << res << std::endl;
}
std::cout << "Subscribing" << std::endl;
if (PNR_OK == pb.subscribe(chan).await()) {
std::cout << "Subscribed! Got messages:" << std::endl;
/// Lets illustrate getting all the message in a vector,
/// and iterating over it
#if __cplusplus >= 201103L
#if PUBNUB_CRYPTO_API
auto msg = pb.get_all_decrypted("KUKUMENEGRDNA");
#else
auto msg = pb.get_all();
#endif
for (auto it = msg.begin(); it != msg.end(); ++it) {
std::cout << *it << std::endl;
}
#else
#if PUBNUB_CRYPTO_API
std::vector<std::string> msg = pb.get_all_decrypted("KUKUMENEGRDNA");
#else
std::vector<std::string> msg = pb.get_all();
#endif
for (std::vector<std::string>::iterator it = msg.begin(); it != msg.end(); ++it) {
std::cout << *it << std::endl;
}
#endif
}
else {
std::cout << "Subscribe failed!" << std::endl;
}
std::cout << "Getting time" << std::endl;
if (PNR_OK == pb.time().await()) {
std::cout << "Gotten time " << pb.get() << "; last time token="<< pb.last_time_token() << std::endl;
}
else {
std::cout << "Getting time failed!" << std::endl;
}
std::cout << "Getting history" << std::endl;
res = pb.history(chan).await();
if (PNR_OK == res) {
std::cout << "Got history! Messages:" << std::endl;
/// Lets illustrate getting all the message in a vector,
/// and then accessing each vector index in a loop
#if __cplusplus >= 201103L
auto msg = pb.get_all();
/// a for-each loop for C++11
for (auto &&m : msg) {
std::cout << m << std::endl;
}
#else
std::vector<std::string> msg = pb.get_all();
for (unsigned i = 0; i < msg.size(); ++i) {
std::cout << msg.at(i) << std::endl;
}
#endif
}
else {
std::cout << "Getting history failed! error code: " << res << std::endl;
}
std::cout << "Getting history with `include_token`" << std::endl;
if (PNR_OK == pb.history(chan, 10, true).await()) {
std::cout << "Got history with time token! Messages:" << std::endl;
/// Here we illustrate getting the messages one-by-one
std::string msg;
do {
msg = pb.get();
std::cout << msg << std::endl;
} while (!msg.empty());
}
else {
std::cout << "Getting history with time token failed!" << std::endl;
}
std::cout << "Getting here-now presence" << std::endl;
if (PNR_OK == pb.here_now(chan).await()) {
std::cout << "Got here-now presence: " << pb.get() << std::endl;
}
else {
std::cout << "Getting here-now presence failed!" << std::endl;
}
/** Global here_now presence for "demo" subscribe key is _very_
long, so we disable it. Enable to try out, or if you use
a "real" subscribe key*/
#if 0
std::cout << "Getting global here-now presence" << std::endl;
if (PNR_OK == pb.global_here_now().await()) {
std::cout << "Got global here-now presence: " << pb.get() << std::endl;
}
}
else {
std::cout << "Getting here-now presence failed!" << std::endl;
}
#endif
std::cout << "Getting where-now presence" << std::endl;
if (PNR_OK == pb.where_now().await()) {
std::cout << "Got where-now presence: " << pb.get() << std::endl;
}
else {
std::cout << "Getting where-now presence failed!" << std::endl;
}
std::cout << "Setting state" << std::endl;
if (PNR_OK == pb.set_state(chan, "", pb.uuid(), "{\"x\":5}").await()) {
std::cout << "State was set: " << pb.get() << std::endl;
}
else {
std::cout << "Setting state failed!" << std::endl;
}
std::cout << "Getting state" << std::endl;
if (PNR_OK == pb.state_get(chan).await()) {
std::cout << "State gotten: " << pb.get() << std::endl;
}
else {
std::cout << "Getting state failed!" << std::endl;
}
}
catch (std::exception &exc) {
std::cout << "Caught exception: " << exc.what() << std::endl;
}
std::cout << "Pubnub C++ " <<
#if defined(PUBNUB_CALLBACK_API)
"callback" <<
#else
"sync" <<
#endif
" demo over." << std::endl;
return 0;
}
|
// Copyright (c) 2017-2018, The Monero Project
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification, are
// permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice, this list of
// conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright notice, this list
// of conditions and the following disclaimer in the documentation and/or other
// materials provided with the distribution.
//
// 3. Neither the name of the copyright holder nor the names of its contributors may be
// used to endorse or promote products derived from this software without specific
// prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
// THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
#if defined(HAVE_HIDAPI)
#include <hidapi/hidapi.h>
#include "device_io.hpp"
#pragma once
namespace hw {
namespace io {
/** HID class base. Commands are formated as follow:
*
* |----------------------------------------------------------|
* | 2 bytes | 1 byte | 2 bytes | 2 bytes | len bytes |
* |-----------|----------|-----------|----------|------------|
* | channel | tag | sequence | len | payload |
* |----------------------------------------------------------|
*/
struct hid_conn_params {
unsigned int vid;
unsigned int pid;
int interface_number;
unsigned short usage_page;
bool interface_OR_page ;
};
class device_io_hid: device_io {
private:
unsigned short channel;
unsigned char tag;
unsigned int packet_size;
unsigned int timeout;
unsigned int usb_vid;
unsigned int usb_pid;
hid_device *usb_device;
void io_hid_log(int read, unsigned char* buf, int buf_len);
void io_hid_init();
void io_hid_exit() ;
void io_hid_open(int vid, int pid, int mode);
void io_hid_close (void);
unsigned int wrapCommand(const unsigned char *command, size_t command_len, unsigned char *out, size_t out_len);
unsigned int unwrapReponse(const unsigned char *data, size_t data_len, unsigned char *out, size_t out_len);
public:
bool hid_verbose = false;
static const unsigned int OR_SELECT = 1;
static const unsigned int AND_SELECT = 2;
static const unsigned short DEFAULT_CHANNEL = 0x0001;
static const unsigned char DEFAULT_TAG = 0x01;
static const unsigned int DEFAULT_PACKET_SIZE = 64;
static const unsigned int DEFAULT_TIMEOUT = 120000;
device_io_hid(unsigned short channel, unsigned char tag, unsigned int packet_zize, unsigned int timeout);
device_io_hid();
~device_io_hid() {};
void init();
void connect(void *params);
void connect(unsigned int vid, unsigned int pid, int interface_number, unsigned short usage_page, bool interface_OR_page );
bool connected() const;
int exchange(unsigned char *command, unsigned int cmd_len, unsigned char *response, unsigned int max_resp_len);
void disconnect();
void release();
};
};
};
#endif //#if defined(HAVE_HIDAPI)
|
; A199405: y-values in the solution to 13*x^2 - 12 = y^2.
; Submitted by Christian Krause
; 1,14,25,155,274,1691,2989,18446,32605,201215,355666,2194919,3879721,23942894,42321265,261176915,461654194,2849003171,5035874869,31077857966,54932969365,339007434455,599226788146,3698003921039,6536561700241,40339035696974,71302951914505,440031388745675,777795909359314,4800006240505451,8484452051037949,52360037256814286,92551176652058125,571160403584451695,1009578491121601426,6230404402172154359,11012812225685557561,67963288020309246254,120131355991419531745,741365763821229554435
add $0,1
mov $2,1
lpb $0
mov $3,$0
mul $0,2
sub $0,1
div $0,2
add $2,$1
sub $1,$2
sub $3,1
mod $3,2
mul $3,12
mul $3,$2
add $1,$3
add $2,2
lpe
mov $0,$2
sub $0,2
|
/**********
Copyright (c) 2019, Xilinx, Inc.
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
**********/
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#include <iostream>
#include "bitmap.h"
BitmapInterface::BitmapInterface(const char *f) : filename(f) {
core = NULL;
dib = NULL;
image = NULL;
magicNumber = 0;
fileSize = 0;
offsetOfImage = 0;
sizeOfDIB = 0;
sizeOfImage = 0;
height = -1;
width = -1;
}
BitmapInterface::~BitmapInterface() {
if (core != NULL)
delete[] core;
if (dib != NULL)
delete[] dib;
if (image != NULL)
delete[] image;
}
bool BitmapInterface::readBitmapFile() {
// First, open the bitmap file
int fd;
unsigned int fileSize;
fd = open(filename, O_RDONLY);
if (fd < 0) {
std::cerr << "Cannot read image file " << filename << std::endl;
return false;
}
core = new char[14];
read(fd, core, 14);
magicNumber = (*(unsigned short *)(&(core[0])));
fileSize = (*(unsigned int *)(&(core[2])));
offsetOfImage = (*(unsigned int *)(&(core[10])));
// Just read in the DIB, but don't process it
sizeOfDIB = offsetOfImage - 14;
dib = new char[sizeOfDIB];
read(fd, dib, sizeOfDIB);
width = (*(int *)(&(dib[4])));
height = (*(int *)(&(dib[8])));
sizeOfImage = fileSize - 14 - sizeOfDIB;
int numPixels = sizeOfImage / 3; // RGB
image = new int[numPixels];
for (int i = 0; i < numPixels; ++i) {
// Use an integer for every pixel even though we might not need that
// much space (padding 0 bits in the rest of the integer)
image[i] = 0;
read(fd, &(image[i]), 3);
}
return true;
}
bool BitmapInterface::writeBitmapFile(int *otherImage) {
int fd;
fd = open("output.bmp", O_WRONLY | O_CREAT, 0644);
if (fd < 0) {
std::cerr << "Cannot open output.bmp for writing!" << std::endl;
return false;
}
write(fd, core, 14);
write(fd, dib, sizeOfDIB);
int numPixels = sizeOfImage / 3;
int *outputImage = otherImage != NULL ? otherImage : image;
for (int i = 0; i < numPixels; ++i) {
write(fd, &(outputImage[i]), 3);
}
return true;
}
|
;5-2.asm 计算Y=5X-18,用正常程序格式
data segment
x db -6 ;x初始为-6
y dw ? ;y初始为空
cc db 0ah,0dh,'Y=$'
data ends
code segment
assume cs:code,ds:data
start:
mov ax,data
mov ds,ax
mov al,5 ;5X
imul x
sub ax,18 ;-18
jns let0 ;结果不为负则转移
neg ax ;结果为负,求绝对值,-ax -> ax
let0:
mov y,ax ;保存结果,ax -> y
;将ax中的二进制数变为十进制数,并显示
mov cx,0
mov bx,10
let1:
mov dx,0
inc cx ;统计余数个数
idiv bx ;AX/10,商在AX,余数在DX
push dx ;保存余数
cmp ax,0 ;商为0,则退出循环
jnz let1
mov dx,offset cc ;9号功能显示提示
mov ah,9
int 21h
let2: ;循环执行cx次,显示十进制结果
pop ax ;将余数弹入ax
add ax,0030h ;调整为ASCII码
mov dl,al ;2号功能,显示一个字符
mov ah,2
int 21h
dec cx
cmp cx,0
jnz let2
mov ah,4ch
int 21h
code ends
end start
|
COMMENT @----------------------------------------------------------------------
Copyright (c) GeoWorks 1988 -- All Rights Reserved
PROJECT: PC GEOS
MODULE: CommonUI/CSpec
FILE: cspecSummons.asm
ROUTINES:
Name Description
---- -----------
GLB OLBuildSummons Convert a generic summons to the OL equivalent
REVISION HISTORY:
Name Date Description
---- ---- -----------
Tony 2/89 Initial version
DESCRIPTION:
This file contains routines to handle the Open Look implementation
of a generic summons.
$Id: cspecSummons.asm,v 1.1 97/04/07 10:51:22 newdeal Exp $
------------------------------------------------------------------------------@
;GenSummons class is no more - brianc 12/30/91
|
.686 ; create 32 bit code, required for "cpuid" instruction
.model flat, stdcall ; 32 bit memory model
option casemap: none ; case sensitive
option language: stdcall
.code
;stdcall calling convention used for 32-bit
; EBP+28 pedx:NEAR PTR DWORD
; EBP+24 pecx:NEAR PTR DWORD
; EBP+20 pebx:NEAR PTR DWORD
; EBP+16 peax:NEAR PTR DWORD
; EBP+12 vecx:DWORD
; EBP+8 veax:DWORD
; EBP+4 callers EIP
; EBP+0 callers EBP
cpuidl proc veax:DWORD, vecx:DWORD, peax:NEAR PTR DWORD, pebx:NEAR PTR DWORD, pecx:NEAR PTR DWORD, pedx:NEAR PTR DWORD
;push ebp
;mov ebp,esp
push ebx
mov eax, veax
mov ecx, vecx
cpuid
push eax
mov eax, pedx
mov dword ptr [eax],edx
mov eax, pecx
mov dword ptr [eax],ecx
mov eax, pebx
mov dword ptr [eax],ebx
pop ebx
mov eax, peax
mov dword ptr [eax],ebx
pop ebx
xor eax,eax
;mov esp,ebp
;pop ebp
;ret 24
ret
cpuidl endp
; To be called on a 486 processor or later
; EAX != 0 => CPUID instruction exists
cpuidt proc
pushfd
pop eax ; Get EFLAGS in EAX
mov ecx, eax ; ECX is an original copy of EFLAGS
xor eax, 200000h ; Toggle bit 21 of the EFLAGS register
push eax ;
popfd ;
pushfd ;
pop eax ; with result in EAX
xor eax,ecx ; Check if bit can be toggled
; If it can be toggled, EAX=200000, implies CPU supports CPUID
ret
cpuidt endp
end
|
#include <bits/stdc++.h>
using namespace std;
/*
* Complete the downToZero function below.
*/
int downToZero(int n) {
/*
* Write your code here.
*/
if(n==0) {
return 0;
}
int ctr[1000007];
queue<int> q;
q.push(n);
ctr[n] = 1;
while(!q.empty()) {
int curr = q.front();
q.pop();
if(ctr[curr-1] == 0) {
ctr[curr-1] = ctr[curr] + 1;
if(curr-1 == 0)
break;
q.push(curr-1);
}
for(int i=2;i*i<=curr;i++) {
if(curr%i == 0) {
int factor = max(i, curr/i);
if(ctr[factor] == 0) {
ctr[factor] = ctr[curr] + 1;
q.push(factor);
}
}
}
}
int tmp = ctr[0] - 1;
memset(ctr, 0, sizeof(ctr));
return tmp;
}
int main()
{
ofstream fout(getenv("OUTPUT_PATH"));
int q;
cin >> q;
cin.ignore(numeric_limits<streamsize>::max(), '\n');
for (int q_itr = 0; q_itr < q; q_itr++) {
int n;
cin >> n;
cin.ignore(numeric_limits<streamsize>::max(), '\n');
int result = downToZero(n);
fout << result << "\n";
}
fout.close();
return 0;
}
|
.386p
_DATA segment use32 dword public 'DATA' ;IGNORE
a db 1
b dw 2
c dd 3
d db 4
e db 5
f db 6
g dd 12345
h db -1
h2 db 1
_DATA ends ;IGNORE
_TEXT segment use32 dword public 'CODE' ;IGNORE
assume cs:_TEXT,ds:_DATA
start: ;IGNORE
mov ebx,0aabbccddh
cmp bl,0ddh
jne failure
cmp bh,0cch
jne failure
mov eax,256+3+65536
mov a,al
cmp a,3
jne failure
mov a,ah
cmp a,1
jne failure
mov b,ax
cmp b,256+3
jne failure
mov c,eax
cmp c,256+3+65536
jne failure
mov byte ptr [a],5
cmp byte ptr [a],5
jne failure
mov a,5
cmp a,5
jne failure
mov [a],5
cmp [a],5
jne failure
xor ebx,ebx
mov bx,word ptr [d]
cmp bx,4+5*256
jne failure
xor ebx,ebx
mov bx,word ptr [e]
cmp bx,6*256+5
jne failure
mov ecx,-1
mov bx,5
movzx ecx,bx
cmp ecx,5
jne failure
xor ecx,ecx
mov cx,-5
movsx ecx,cx
cmp ecx,-5
jne failure
xor ebx,ebx
mov bl,-1
movsx bx,bl
cmp bx,-1
jne failure
mov ebx,0FFFFFFFFh
mov bl,1
movsx bx,bl
cmp bx,1
jne failure
xor ebx,ebx
movsx bx,byte ptr [h]
cmp bx,-1
jne failure
xor ebx,ebx
movsx bx,byte ptr [h2]
cmp bx,1
jne failure
;TOFIX: test in dosbox if this works
xor ebx,ebx
movsx bx,[h2]
cmp bx,1
jne failure
mov ebx,[g]
cmp ebx,12345
jne failure
mov ebx,g
cmp ebx,12345
jne failure
MOV al,0
JMP exitLabel
failure:
mov al,1
exitLabel:
mov ah,4ch ; AH=4Ch - Exit To DOS
int 21h ; DOS INT 21h
_TEXT ends ;IGNORE
stackseg segment para stack 'STACK' ;IGNORE
db 1000h dup(?)
stackseg ends ;IGNORE
end start ;IGNORE
|
; A258943: Exponential reversion of Fibonacci numbers A000045.
; Submitted by Simon Strandgaard
; 1,-1,1,2,-25,132,-209,-5104,77121,-550000,-1212751,104886144,-1708324409,11026947008,204999609375,-8086017144832,130002259664321,-256459066769664,-50556576336151391,1626772400000000000,-22785408268305809049,-251717732965479463936
mov $1,1
mov $3,$0
mov $4,1
lpb $3
mul $1,$3
mul $4,$3
add $1,$4
mul $1,$3
sub $2,1
div $1,$2
sub $3,1
add $4,$1
lpe
mov $0,$4
|
/**********************************************************************
Audacity: A Digital Audio Editor
ScrubbingToolBar.cpp
Paul Licameli
See ScrubbingToolBar.h for details
*******************************************************************/
// Much of this is imitative of EditToolBar. Should there be a common base
// class?
#include "../Audacity.h"
#include "ScrubbingToolBar.h"
// For compilers that support precompilation, includes "wx/wx.h".
#include <wx/wxprec.h>
#ifndef WX_PRECOMP
#include <wx/event.h>
#include <wx/image.h>
#include <wx/intl.h>
#include <wx/sizer.h>
#include <wx/tooltip.h>
#endif
#include "../AllThemeResources.h"
#include "../AudioIO.h"
#include "../ImageManipulation.h"
#include "../Internat.h"
#include "../Prefs.h"
#include "../Project.h"
#include "../Theme.h"
#include "../Track.h"
#include "../UndoManager.h"
#include "../widgets/AButton.h"
#include "../widgets/Ruler.h"
#include "../tracks/ui/Scrubbing.h"
#include "../Experimental.h"
IMPLEMENT_CLASS(ScrubbingToolBar, ToolBar);
//const int BUTTON_WIDTH = 27;
//const int SEPARATOR_WIDTH = 14;
////////////////////////////////////////////////////////////
/// Methods for ScrubbingToolBar
////////////////////////////////////////////////////////////
BEGIN_EVENT_TABLE( ScrubbingToolBar, ToolBar )
EVT_COMMAND_RANGE( STBFirstButton,
STBFirstButton + STBNumButtons - 1,
wxEVT_COMMAND_BUTTON_CLICKED,
ScrubbingToolBar::OnButton )
END_EVENT_TABLE()
//Standard contructor
ScrubbingToolBar::ScrubbingToolBar()
: ToolBar(ScrubbingBarID, _("Scrub"), wxT("Scrub"))
{
}
ScrubbingToolBar::~ScrubbingToolBar()
{
}
void ScrubbingToolBar::Create(wxWindow * parent)
{
ToolBar::Create(parent);
}
/// This is a convenience function that allows for button creation in
/// MakeButtons() with fewer arguments
/// Very similar to code in ControlToolBar...
AButton *ScrubbingToolBar::AddButton
(teBmps eEnabledUp, teBmps eEnabledDown, teBmps eDisabled,
int id,
const wxChar *label,
bool toggle)
{
AButton *&r = mButtons[id];
r = ToolBar::MakeButton
(this,
bmpRecoloredUpSmall, bmpRecoloredDownSmall, bmpRecoloredHiliteSmall,
eEnabledUp, eEnabledDown, eDisabled,
wxWindowID(id),
wxDefaultPosition,
toggle,
theTheme.ImageSize( bmpRecoloredUpSmall ));
r->SetLabel(label);
// JKC: Unlike ControlToolBar, does not have a focus rect. Shouldn't it?
// r->SetFocusRect( r->GetRect().Deflate( 4, 4 ) );
Add( r, 0, wxALIGN_CENTER );
return r;
}
void ScrubbingToolBar::Populate()
{
SetBackgroundColour( theTheme.Colour( clrMedium ) );
MakeButtonBackgroundsSmall();
/* Buttons */
AddButton(bmpScrub, bmpScrub, bmpScrubDisabled, STBScrubID,
_("Scrub"), true);
AddButton(bmpSeek, bmpSeek, bmpSeekDisabled, STBSeekID,
_("Seek"), true);
AddButton(bmpToggleScrubRuler, bmpToggleScrubRuler, bmpToggleScrubRuler,
STBRulerID,
_("Scrub Ruler"), true);
RegenerateTooltips();
}
void ScrubbingToolBar::UpdatePrefs()
{
RegenerateTooltips();
// Set label to pull in language change
SetLabel(_("Scrubbing"));
// Give base class a chance
ToolBar::UpdatePrefs();
}
void ScrubbingToolBar::RegenerateTooltips()
{
#if wxUSE_TOOLTIPS
std::vector<wxString> commands;
auto fn = [&]
(AButton &button, const wxString &label, const wxString &command)
{
commands.clear();
commands.push_back(label);
commands.push_back(command);
ToolBar::SetButtonToolTip(button, commands);
};
auto project = GetActiveProject();
if (project) {
auto &scrubber = project->GetScrubber();
const auto scrubButton = mButtons[STBScrubID];
const auto seekButton = mButtons[STBSeekID];
wxString label;
label = (
scrubber.Scrubs()
/* i18n-hint: These commands assist the user in finding a sound by ear. ...
"Scrubbing" is variable-speed playback, ...
"Seeking" is normal speed playback but with skips
*/
? _("Stop Scrubbing")
: _("Start Scrubbing")
);
fn(*scrubButton, label, wxT("Scrub"));
label = (
scrubber.Seeks()
/* i18n-hint: These commands assist the user in finding a sound by ear. ...
"Scrubbing" is variable-speed playback, ...
"Seeking" is normal speed playback but with skips
*/
? _("Stop Seeking")
: _("Start Seeking")
);
fn(*seekButton, label, wxT("Seek"));
label = (
project->GetRulerPanel()->ShowingScrubRuler()
? _("Hide Scrub Ruler")
: _("Show Scrub Ruler")
);
fn(*mButtons[STBRulerID], label, wxT("ToggleScrubRuler"));
}
#endif
}
void ScrubbingToolBar::OnButton(wxCommandEvent &event)
{
AudacityProject *p = GetActiveProject();
if (!p) return;
auto &scrubber = p->GetScrubber();
int id = event.GetId();
switch (id) {
case STBScrubID:
scrubber.OnScrub(event);
break;
case STBSeekID:
scrubber.OnSeek(event);
break;
case STBRulerID:
scrubber.OnToggleScrubRuler(event);
break;
default:
wxASSERT(false);
}
EnableDisableButtons();
}
void ScrubbingToolBar::EnableDisableButtons()
{
const auto scrubButton = mButtons[STBScrubID];
scrubButton->SetEnabled(true);
const auto seekButton = mButtons[STBSeekID];
seekButton->SetEnabled(true);
AudacityProject *p = GetActiveProject();
if (!p) return;
auto &scrubber = p->GetScrubber();
const auto canScrub = scrubber.CanScrub();
if (scrubber.Scrubs()) {
scrubButton->PushDown();
scrubButton->Enable();
}
else {
scrubButton->PopUp();
if (canScrub)
scrubButton->Enable();
else
scrubButton->Disable();
}
if (scrubber.Seeks()) {
seekButton->PushDown();
seekButton->Enable();
}
else {
seekButton->PopUp();
if (canScrub)
seekButton->Enable();
else
seekButton->Disable();
}
const auto barButton = mButtons[STBRulerID];
barButton->Enable();
if (p->GetRulerPanel()->ShowingScrubRuler())
barButton->PushDown();
else
barButton->PopUp();
RegenerateTooltips();
scrubber.CheckMenuItems();
}
|
; CRT0 for the ZX80
;
; Stefano Bodrato Dec. 2012
;
; If an error occurs (eg. out if screen) we just drop back to BASIC
;
; ZX80 works in FAST mode only, thus the screen is visible only
; during a PAUSE or waiting for a keypress.
;
;
; - - - - - - -
;
; $Id: zx80_crt0.asm,v 1.15 2016-07-15 21:03:25 dom Exp $
;
; - - - - - - -
MODULE zx80_crt0
;-------
; Include zcc_opt.def to find out information about us
;-------
defc crt0 = 1
INCLUDE "zcc_opt.def"
;-------
; Some general scope declarations
;-------
EXTERN _main ;main() is always external to crt0 code
PUBLIC cleanup ;jp'd to by exit()
PUBLIC l_dcal ;jp(hl)
PUBLIC save81 ;Save ZX81 critical registers
PUBLIC restore81 ;Restore ZX81 critical registers
PUBLIC zx_fast
PUBLIC zx_slow
PUBLIC _zx_fast
PUBLIC _zx_slow
;; PUBLIC frames ;Frame counter for time()
PUBLIC _FRAMES
defc _FRAMES = 16414 ; Timer
EXTERN filltxt ; used by custom CLS
IF !DEFINED_CRT_ORG_CODE
defc CRT_ORG_CODE = 16525
ENDIF
defc CONSOLE_ROWS = 24
defc CONSOLE_COLUMNS = 32
defc TAR__clib_exit_stack_size = 0
defc TAR__register_sp = -1
defc CRT_KEY_DEL = 12
defc __CPU_CLOCK = 3250000
INCLUDE "crt/classic/crt_rules.inc"
org CRT_ORG_CODE
start:
ld l,0
call filltxt
LD (IY+$12),24 ; set DF-SZ to 24 lines.
;call zx80_cls
;call 1863 ; CLS
;call $6e0 ;; N/L-LINE (PRPOS)
;ld a,0
;call $720
;call 1474 ; CL-EOD - clear to end of display
; (zx81) this would be after 'hrg_on', sometimes
; the stack will be moved to make room
; for high-resolution graphics.
ld (start1+1),sp ;Save entry stack
INCLUDE "crt/classic/crt_init_sp.asm"
INCLUDE "crt/classic/crt_init_atexit.asm"
call crt0_init_bss
ld (exitsp),sp
; Optional definition for auto MALLOC init
; it assumes we have free space between the end of
; the compiled program and the stack pointer
IF DEFINED_USING_amalloc
INCLUDE "crt/classic/crt_init_amalloc.asm"
ENDIF
call _main ;Call user program
cleanup:
;
; Deallocate memory which has been allocated here!
;
push hl ; keep return code
IF CRT_ENABLE_STDIO = 1
EXTERN closeall
call closeall
ENDIF
; ld iy,16384 ; no ix/iy swap here
;LD (IY+$12),2 ; set DF-SZ to 24 lines.
;call 1863
pop hl ; return code (for BASIC)
start1: ld sp,0 ;Restore stack to entry value
;jp $283
;ret ; oddly EightyOne gets unstable without this 'ret' !!
;jp restore81
restore81:
; ex af,af
; ld a,(a1save)
; ex af,af
ld iy,16384 ; no ix/iy swap here
save81:
zx_fast:
zx_slow:
_zx_fast:
_zx_slow:
ret
l_dcal: jp (hl) ;Used for function pointer calls
;zx80_cls:
; LD HL,($400A) ; fetch E-LINE
; INC HL ; address the next location.
; LD (HL),$76 ; insert a newline.
; INC HL ; address the next location.
; LD ($400C),HL ; set D-FILE to start of dynamic display file.
; LD (IY+$12),$02 ; set DF-SZ to 2 lines.
;zx80_cls2:
; call $6e0 ;; N/L-LINE (PRPOS)
; ld a,0
; call $720
; ld a,($4025) ; S_POSN_Y
; dec a
; jr nz,zx80_cls2
; jp $747 ; CLS
INCLUDE "crt/classic/crt_runtime_selection.asm"
INCLUDE "crt/classic/crt_section.asm"
|
#include <boost/config/warning_disable.hpp>
#include <boost/spirit/include/qi.hpp>
#include <boost/spirit/include/phoenix_core.hpp>
#include <boost/spirit/include/phoenix_operator.hpp>
#include <boost/spirit/include/phoenix_stl.hpp>
#include <iostream>
#include <string>
#include <vector>
namespace client{
namespace qi = boost::spirit::qi;
namespace ascii = boost::spirit::ascii;
template <typename Iterator>
bool parse_numbers(Iterator first, Iterator last, std::vector<double>& v){
using qi::double_;
using qi::phrase_parse;
using qi::_1;
using ascii::space;
bool r = phrase_parse(first, last,
(
double_ % ','
),
space, v);
if(first != last)
return false;
return r;
}
}
int main(){
std::string str;
while(getline(std::cin, str)){
if(str.empty() || str[0] == 'q' || str[0] == 'Q')
break;
std::vector<double> v;
if(client::parse_numbers(str.begin(), str.end(), v)){
std::cout << "Parsing succeeded\n";
for(std::vector<double>::size_type i = 0; i < v.size(); ++i)
std::cout << i << ": " << v[i] << std::endl;
}
else{
std::cout << "Parsing failed\n";
}
}
return 0;
}
|
; A102846: a(0)=1, a(1)=1, a(n) = a(n-1)*a(n-2) + 2.
; Submitted by Jon Maiga
; 1,1,3,5,17,87,1481,128849,190825371,24587658227981,4691949003375676905953,115364038518117215020660724770070895,541282185550473269502054702460138578085934426170057537937
mov $1,1
mov $2,1
mov $3,1
lpb $0
sub $0,1
mov $3,$2
mov $2,$1
mov $1,$3
add $2,2
mul $1,$2
lpe
mov $0,$3
|
###############################################################################
# Copyright 2019 Intel Corporation
# All Rights Reserved.
#
# If this software was obtained under the Intel Simplified Software License,
# the following terms apply:
#
# The source code, information and material ("Material") contained herein is
# owned by Intel Corporation or its suppliers or licensors, and title to such
# Material remains with Intel Corporation or its suppliers or licensors. The
# Material contains proprietary information of Intel or its suppliers and
# licensors. The Material is protected by worldwide copyright laws and treaty
# provisions. No part of the Material may be used, copied, reproduced,
# modified, published, uploaded, posted, transmitted, distributed or disclosed
# in any way without Intel's prior express written permission. No license under
# any patent, copyright or other intellectual property rights in the Material
# is granted to or conferred upon you, either expressly, by implication,
# inducement, estoppel or otherwise. Any license under such intellectual
# property rights must be express and approved by Intel in writing.
#
# Unless otherwise agreed by Intel in writing, you may not remove or alter this
# notice or any other notice embedded in Materials by Intel or Intel's
# suppliers or licensors in any way.
#
#
# If this software was obtained under the Apache License, Version 2.0 (the
# "License"), the following terms apply:
#
# You may not use this file except in compliance with the License. You may
# obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
#
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#
# See the License for the specific language governing permissions and
# limitations under the License.
###############################################################################
.section .note.GNU-stack,"",%progbits
.text
.p2align 5, 0x90
SWP_BYTE:
pByteSwp:
.byte 3,2,1,0, 7,6,5,4, 11,10,9,8, 15,14,13,12
.p2align 5, 0x90
.globl UpdateSHA256
.type UpdateSHA256, @function
UpdateSHA256:
push %ebp
mov %esp, %ebp
push %ebx
push %esi
push %edi
sub $(52), %esp
.Lsha256_block_loopgas_1:
movl (8)(%ebp), %eax
vmovdqu (%eax), %xmm0
vmovdqu (16)(%eax), %xmm1
vmovdqu %xmm0, (%esp)
vmovdqu %xmm1, (16)(%esp)
movl (12)(%ebp), %eax
movl (20)(%ebp), %ebx
call .L__0000gas_1
.L__0000gas_1:
pop %ecx
sub $(.L__0000gas_1-SWP_BYTE), %ecx
movdqa ((pByteSwp-SWP_BYTE))(%ecx), %xmm6
vmovdqu (%eax), %xmm0
vmovdqu (16)(%eax), %xmm1
vmovdqu (32)(%eax), %xmm2
vmovdqu (48)(%eax), %xmm3
mov (16)(%esp), %eax
mov (%esp), %edx
vpshufb %xmm6, %xmm0, %xmm0
vpaddd (%ebx), %xmm0, %xmm7
vmovdqu %xmm7, (32)(%esp)
mov %eax, %esi
shrd $(6), %esi, %esi
mov %eax, %ecx
shrd $(11), %ecx, %ecx
xor %ecx, %esi
shrd $(14), %ecx, %ecx
xor %ecx, %esi
mov (20)(%esp), %edi
xor (24)(%esp), %edi
and %eax, %edi
xor (24)(%esp), %edi
mov (28)(%esp), %eax
add %esi, %eax
add %edi, %eax
addl (32)(%esp), %eax
movl (4)(%esp), %esi
movl (8)(%esp), %ecx
mov %edx, %edi
xor %ecx, %edi
xor %esi, %ecx
and %ecx, %edi
xor %esi, %ecx
xor %ecx, %edi
mov %edx, %esi
shrd $(2), %esi, %esi
mov %edx, %ecx
shrd $(13), %ecx, %ecx
xor %ecx, %esi
shrd $(9), %ecx, %ecx
xor %ecx, %esi
lea (%edi,%esi), %edx
add %eax, %edx
add (12)(%esp), %eax
mov %edx, (28)(%esp)
mov %eax, (12)(%esp)
mov %eax, %esi
shrd $(6), %esi, %esi
mov %eax, %ecx
shrd $(11), %ecx, %ecx
xor %ecx, %esi
shrd $(14), %ecx, %ecx
xor %ecx, %esi
mov (16)(%esp), %edi
xor (20)(%esp), %edi
and %eax, %edi
xor (20)(%esp), %edi
mov (24)(%esp), %eax
add %esi, %eax
add %edi, %eax
addl (36)(%esp), %eax
movl (%esp), %esi
movl (4)(%esp), %ecx
mov %edx, %edi
xor %ecx, %edi
xor %esi, %ecx
and %ecx, %edi
xor %esi, %ecx
xor %ecx, %edi
mov %edx, %esi
shrd $(2), %esi, %esi
mov %edx, %ecx
shrd $(13), %ecx, %ecx
xor %ecx, %esi
shrd $(9), %ecx, %ecx
xor %ecx, %esi
lea (%edi,%esi), %edx
add %eax, %edx
add (8)(%esp), %eax
mov %edx, (24)(%esp)
mov %eax, (8)(%esp)
mov %eax, %esi
shrd $(6), %esi, %esi
mov %eax, %ecx
shrd $(11), %ecx, %ecx
xor %ecx, %esi
shrd $(14), %ecx, %ecx
xor %ecx, %esi
mov (12)(%esp), %edi
xor (16)(%esp), %edi
and %eax, %edi
xor (16)(%esp), %edi
mov (20)(%esp), %eax
add %esi, %eax
add %edi, %eax
addl (40)(%esp), %eax
movl (28)(%esp), %esi
movl (%esp), %ecx
mov %edx, %edi
xor %ecx, %edi
xor %esi, %ecx
and %ecx, %edi
xor %esi, %ecx
xor %ecx, %edi
mov %edx, %esi
shrd $(2), %esi, %esi
mov %edx, %ecx
shrd $(13), %ecx, %ecx
xor %ecx, %esi
shrd $(9), %ecx, %ecx
xor %ecx, %esi
lea (%edi,%esi), %edx
add %eax, %edx
add (4)(%esp), %eax
mov %edx, (20)(%esp)
mov %eax, (4)(%esp)
mov %eax, %esi
shrd $(6), %esi, %esi
mov %eax, %ecx
shrd $(11), %ecx, %ecx
xor %ecx, %esi
shrd $(14), %ecx, %ecx
xor %ecx, %esi
mov (8)(%esp), %edi
xor (12)(%esp), %edi
and %eax, %edi
xor (12)(%esp), %edi
mov (16)(%esp), %eax
add %esi, %eax
add %edi, %eax
addl (44)(%esp), %eax
movl (24)(%esp), %esi
movl (28)(%esp), %ecx
mov %edx, %edi
xor %ecx, %edi
xor %esi, %ecx
and %ecx, %edi
xor %esi, %ecx
xor %ecx, %edi
mov %edx, %esi
shrd $(2), %esi, %esi
mov %edx, %ecx
shrd $(13), %ecx, %ecx
xor %ecx, %esi
shrd $(9), %ecx, %ecx
xor %ecx, %esi
lea (%edi,%esi), %edx
add %eax, %edx
add (%esp), %eax
mov %edx, (16)(%esp)
mov %eax, (%esp)
vpshufb %xmm6, %xmm1, %xmm1
vpaddd (16)(%ebx), %xmm1, %xmm7
vmovdqu %xmm7, (32)(%esp)
mov %eax, %esi
shrd $(6), %esi, %esi
mov %eax, %ecx
shrd $(11), %ecx, %ecx
xor %ecx, %esi
shrd $(14), %ecx, %ecx
xor %ecx, %esi
mov (4)(%esp), %edi
xor (8)(%esp), %edi
and %eax, %edi
xor (8)(%esp), %edi
mov (12)(%esp), %eax
add %esi, %eax
add %edi, %eax
addl (32)(%esp), %eax
movl (20)(%esp), %esi
movl (24)(%esp), %ecx
mov %edx, %edi
xor %ecx, %edi
xor %esi, %ecx
and %ecx, %edi
xor %esi, %ecx
xor %ecx, %edi
mov %edx, %esi
shrd $(2), %esi, %esi
mov %edx, %ecx
shrd $(13), %ecx, %ecx
xor %ecx, %esi
shrd $(9), %ecx, %ecx
xor %ecx, %esi
lea (%edi,%esi), %edx
add %eax, %edx
add (28)(%esp), %eax
mov %edx, (12)(%esp)
mov %eax, (28)(%esp)
mov %eax, %esi
shrd $(6), %esi, %esi
mov %eax, %ecx
shrd $(11), %ecx, %ecx
xor %ecx, %esi
shrd $(14), %ecx, %ecx
xor %ecx, %esi
mov (%esp), %edi
xor (4)(%esp), %edi
and %eax, %edi
xor (4)(%esp), %edi
mov (8)(%esp), %eax
add %esi, %eax
add %edi, %eax
addl (36)(%esp), %eax
movl (16)(%esp), %esi
movl (20)(%esp), %ecx
mov %edx, %edi
xor %ecx, %edi
xor %esi, %ecx
and %ecx, %edi
xor %esi, %ecx
xor %ecx, %edi
mov %edx, %esi
shrd $(2), %esi, %esi
mov %edx, %ecx
shrd $(13), %ecx, %ecx
xor %ecx, %esi
shrd $(9), %ecx, %ecx
xor %ecx, %esi
lea (%edi,%esi), %edx
add %eax, %edx
add (24)(%esp), %eax
mov %edx, (8)(%esp)
mov %eax, (24)(%esp)
mov %eax, %esi
shrd $(6), %esi, %esi
mov %eax, %ecx
shrd $(11), %ecx, %ecx
xor %ecx, %esi
shrd $(14), %ecx, %ecx
xor %ecx, %esi
mov (28)(%esp), %edi
xor (%esp), %edi
and %eax, %edi
xor (%esp), %edi
mov (4)(%esp), %eax
add %esi, %eax
add %edi, %eax
addl (40)(%esp), %eax
movl (12)(%esp), %esi
movl (16)(%esp), %ecx
mov %edx, %edi
xor %ecx, %edi
xor %esi, %ecx
and %ecx, %edi
xor %esi, %ecx
xor %ecx, %edi
mov %edx, %esi
shrd $(2), %esi, %esi
mov %edx, %ecx
shrd $(13), %ecx, %ecx
xor %ecx, %esi
shrd $(9), %ecx, %ecx
xor %ecx, %esi
lea (%edi,%esi), %edx
add %eax, %edx
add (20)(%esp), %eax
mov %edx, (4)(%esp)
mov %eax, (20)(%esp)
mov %eax, %esi
shrd $(6), %esi, %esi
mov %eax, %ecx
shrd $(11), %ecx, %ecx
xor %ecx, %esi
shrd $(14), %ecx, %ecx
xor %ecx, %esi
mov (24)(%esp), %edi
xor (28)(%esp), %edi
and %eax, %edi
xor (28)(%esp), %edi
mov (%esp), %eax
add %esi, %eax
add %edi, %eax
addl (44)(%esp), %eax
movl (8)(%esp), %esi
movl (12)(%esp), %ecx
mov %edx, %edi
xor %ecx, %edi
xor %esi, %ecx
and %ecx, %edi
xor %esi, %ecx
xor %ecx, %edi
mov %edx, %esi
shrd $(2), %esi, %esi
mov %edx, %ecx
shrd $(13), %ecx, %ecx
xor %ecx, %esi
shrd $(9), %ecx, %ecx
xor %ecx, %esi
lea (%edi,%esi), %edx
add %eax, %edx
add (16)(%esp), %eax
mov %edx, (%esp)
mov %eax, (16)(%esp)
vpshufb %xmm6, %xmm2, %xmm2
vpaddd (32)(%ebx), %xmm2, %xmm7
vmovdqu %xmm7, (32)(%esp)
mov %eax, %esi
shrd $(6), %esi, %esi
mov %eax, %ecx
shrd $(11), %ecx, %ecx
xor %ecx, %esi
shrd $(14), %ecx, %ecx
xor %ecx, %esi
mov (20)(%esp), %edi
xor (24)(%esp), %edi
and %eax, %edi
xor (24)(%esp), %edi
mov (28)(%esp), %eax
add %esi, %eax
add %edi, %eax
addl (32)(%esp), %eax
movl (4)(%esp), %esi
movl (8)(%esp), %ecx
mov %edx, %edi
xor %ecx, %edi
xor %esi, %ecx
and %ecx, %edi
xor %esi, %ecx
xor %ecx, %edi
mov %edx, %esi
shrd $(2), %esi, %esi
mov %edx, %ecx
shrd $(13), %ecx, %ecx
xor %ecx, %esi
shrd $(9), %ecx, %ecx
xor %ecx, %esi
lea (%edi,%esi), %edx
add %eax, %edx
add (12)(%esp), %eax
mov %edx, (28)(%esp)
mov %eax, (12)(%esp)
mov %eax, %esi
shrd $(6), %esi, %esi
mov %eax, %ecx
shrd $(11), %ecx, %ecx
xor %ecx, %esi
shrd $(14), %ecx, %ecx
xor %ecx, %esi
mov (16)(%esp), %edi
xor (20)(%esp), %edi
and %eax, %edi
xor (20)(%esp), %edi
mov (24)(%esp), %eax
add %esi, %eax
add %edi, %eax
addl (36)(%esp), %eax
movl (%esp), %esi
movl (4)(%esp), %ecx
mov %edx, %edi
xor %ecx, %edi
xor %esi, %ecx
and %ecx, %edi
xor %esi, %ecx
xor %ecx, %edi
mov %edx, %esi
shrd $(2), %esi, %esi
mov %edx, %ecx
shrd $(13), %ecx, %ecx
xor %ecx, %esi
shrd $(9), %ecx, %ecx
xor %ecx, %esi
lea (%edi,%esi), %edx
add %eax, %edx
add (8)(%esp), %eax
mov %edx, (24)(%esp)
mov %eax, (8)(%esp)
mov %eax, %esi
shrd $(6), %esi, %esi
mov %eax, %ecx
shrd $(11), %ecx, %ecx
xor %ecx, %esi
shrd $(14), %ecx, %ecx
xor %ecx, %esi
mov (12)(%esp), %edi
xor (16)(%esp), %edi
and %eax, %edi
xor (16)(%esp), %edi
mov (20)(%esp), %eax
add %esi, %eax
add %edi, %eax
addl (40)(%esp), %eax
movl (28)(%esp), %esi
movl (%esp), %ecx
mov %edx, %edi
xor %ecx, %edi
xor %esi, %ecx
and %ecx, %edi
xor %esi, %ecx
xor %ecx, %edi
mov %edx, %esi
shrd $(2), %esi, %esi
mov %edx, %ecx
shrd $(13), %ecx, %ecx
xor %ecx, %esi
shrd $(9), %ecx, %ecx
xor %ecx, %esi
lea (%edi,%esi), %edx
add %eax, %edx
add (4)(%esp), %eax
mov %edx, (20)(%esp)
mov %eax, (4)(%esp)
mov %eax, %esi
shrd $(6), %esi, %esi
mov %eax, %ecx
shrd $(11), %ecx, %ecx
xor %ecx, %esi
shrd $(14), %ecx, %ecx
xor %ecx, %esi
mov (8)(%esp), %edi
xor (12)(%esp), %edi
and %eax, %edi
xor (12)(%esp), %edi
mov (16)(%esp), %eax
add %esi, %eax
add %edi, %eax
addl (44)(%esp), %eax
movl (24)(%esp), %esi
movl (28)(%esp), %ecx
mov %edx, %edi
xor %ecx, %edi
xor %esi, %ecx
and %ecx, %edi
xor %esi, %ecx
xor %ecx, %edi
mov %edx, %esi
shrd $(2), %esi, %esi
mov %edx, %ecx
shrd $(13), %ecx, %ecx
xor %ecx, %esi
shrd $(9), %ecx, %ecx
xor %ecx, %esi
lea (%edi,%esi), %edx
add %eax, %edx
add (%esp), %eax
mov %edx, (16)(%esp)
mov %eax, (%esp)
vpshufb %xmm6, %xmm3, %xmm3
vpaddd (48)(%ebx), %xmm3, %xmm7
vmovdqu %xmm7, (32)(%esp)
mov %eax, %esi
shrd $(6), %esi, %esi
mov %eax, %ecx
shrd $(11), %ecx, %ecx
xor %ecx, %esi
shrd $(14), %ecx, %ecx
xor %ecx, %esi
mov (4)(%esp), %edi
xor (8)(%esp), %edi
and %eax, %edi
xor (8)(%esp), %edi
mov (12)(%esp), %eax
add %esi, %eax
add %edi, %eax
addl (32)(%esp), %eax
movl (20)(%esp), %esi
movl (24)(%esp), %ecx
mov %edx, %edi
xor %ecx, %edi
xor %esi, %ecx
and %ecx, %edi
xor %esi, %ecx
xor %ecx, %edi
mov %edx, %esi
shrd $(2), %esi, %esi
mov %edx, %ecx
shrd $(13), %ecx, %ecx
xor %ecx, %esi
shrd $(9), %ecx, %ecx
xor %ecx, %esi
lea (%edi,%esi), %edx
add %eax, %edx
add (28)(%esp), %eax
mov %edx, (12)(%esp)
mov %eax, (28)(%esp)
mov %eax, %esi
shrd $(6), %esi, %esi
mov %eax, %ecx
shrd $(11), %ecx, %ecx
xor %ecx, %esi
shrd $(14), %ecx, %ecx
xor %ecx, %esi
mov (%esp), %edi
xor (4)(%esp), %edi
and %eax, %edi
xor (4)(%esp), %edi
mov (8)(%esp), %eax
add %esi, %eax
add %edi, %eax
addl (36)(%esp), %eax
movl (16)(%esp), %esi
movl (20)(%esp), %ecx
mov %edx, %edi
xor %ecx, %edi
xor %esi, %ecx
and %ecx, %edi
xor %esi, %ecx
xor %ecx, %edi
mov %edx, %esi
shrd $(2), %esi, %esi
mov %edx, %ecx
shrd $(13), %ecx, %ecx
xor %ecx, %esi
shrd $(9), %ecx, %ecx
xor %ecx, %esi
lea (%edi,%esi), %edx
add %eax, %edx
add (24)(%esp), %eax
mov %edx, (8)(%esp)
mov %eax, (24)(%esp)
mov %eax, %esi
shrd $(6), %esi, %esi
mov %eax, %ecx
shrd $(11), %ecx, %ecx
xor %ecx, %esi
shrd $(14), %ecx, %ecx
xor %ecx, %esi
mov (28)(%esp), %edi
xor (%esp), %edi
and %eax, %edi
xor (%esp), %edi
mov (4)(%esp), %eax
add %esi, %eax
add %edi, %eax
addl (40)(%esp), %eax
movl (12)(%esp), %esi
movl (16)(%esp), %ecx
mov %edx, %edi
xor %ecx, %edi
xor %esi, %ecx
and %ecx, %edi
xor %esi, %ecx
xor %ecx, %edi
mov %edx, %esi
shrd $(2), %esi, %esi
mov %edx, %ecx
shrd $(13), %ecx, %ecx
xor %ecx, %esi
shrd $(9), %ecx, %ecx
xor %ecx, %esi
lea (%edi,%esi), %edx
add %eax, %edx
add (20)(%esp), %eax
mov %edx, (4)(%esp)
mov %eax, (20)(%esp)
mov %eax, %esi
shrd $(6), %esi, %esi
mov %eax, %ecx
shrd $(11), %ecx, %ecx
xor %ecx, %esi
shrd $(14), %ecx, %ecx
xor %ecx, %esi
mov (24)(%esp), %edi
xor (28)(%esp), %edi
and %eax, %edi
xor (28)(%esp), %edi
mov (%esp), %eax
add %esi, %eax
add %edi, %eax
addl (44)(%esp), %eax
movl (8)(%esp), %esi
movl (12)(%esp), %ecx
mov %edx, %edi
xor %ecx, %edi
xor %esi, %ecx
and %ecx, %edi
xor %esi, %ecx
xor %ecx, %edi
mov %edx, %esi
shrd $(2), %esi, %esi
mov %edx, %ecx
shrd $(13), %ecx, %ecx
xor %ecx, %esi
shrd $(9), %ecx, %ecx
xor %ecx, %esi
lea (%edi,%esi), %edx
add %eax, %edx
add (16)(%esp), %eax
mov %edx, (%esp)
mov %eax, (16)(%esp)
movl $(48), (48)(%esp)
.Lloop_16_63gas_1:
add $(64), %ebx
vpshufd $(250), %xmm3, %xmm6
vpsrld $(10), %xmm6, %xmm4
vpsrlq $(17), %xmm6, %xmm6
vpxor %xmm6, %xmm4, %xmm4
vpsrlq $(2), %xmm6, %xmm6
vpxor %xmm6, %xmm4, %xmm4
vpshufd $(165), %xmm0, %xmm6
vpsrld $(3), %xmm6, %xmm5
vpsrlq $(7), %xmm6, %xmm6
vpxor %xmm6, %xmm5, %xmm5
vpsrlq $(11), %xmm6, %xmm6
vpxor %xmm6, %xmm5, %xmm5
vpshufd $(80), %xmm0, %xmm7
vpaddd %xmm5, %xmm4, %xmm4
vpshufd $(165), %xmm2, %xmm6
vpaddd %xmm4, %xmm7, %xmm7
vpaddd %xmm6, %xmm7, %xmm7
vpshufd $(160), %xmm7, %xmm6
vpsrld $(10), %xmm6, %xmm4
vpsrlq $(17), %xmm6, %xmm6
vpxor %xmm6, %xmm4, %xmm4
vpsrlq $(2), %xmm6, %xmm6
vpxor %xmm6, %xmm4, %xmm4
vpalignr $(12), %xmm0, %xmm1, %xmm6
vpshufd $(80), %xmm6, %xmm6
vpsrld $(3), %xmm6, %xmm5
vpsrlq $(7), %xmm6, %xmm6
vpxor %xmm6, %xmm5, %xmm5
vpsrlq $(11), %xmm6, %xmm6
vpxor %xmm6, %xmm5, %xmm5
vpalignr $(12), %xmm2, %xmm3, %xmm6
vpshufd $(250), %xmm0, %xmm0
vpaddd %xmm5, %xmm4, %xmm4
vpshufd $(80), %xmm6, %xmm6
vpaddd %xmm4, %xmm0, %xmm0
vpaddd %xmm6, %xmm0, %xmm0
vpshufd $(136), %xmm7, %xmm7
vpshufd $(136), %xmm0, %xmm0
vpalignr $(8), %xmm7, %xmm0, %xmm0
vpaddd (%ebx), %xmm0, %xmm7
vmovdqu %xmm7, (32)(%esp)
mov %eax, %esi
shrd $(6), %esi, %esi
mov %eax, %ecx
shrd $(11), %ecx, %ecx
xor %ecx, %esi
shrd $(14), %ecx, %ecx
xor %ecx, %esi
mov (20)(%esp), %edi
xor (24)(%esp), %edi
and %eax, %edi
xor (24)(%esp), %edi
mov (28)(%esp), %eax
add %esi, %eax
add %edi, %eax
addl (32)(%esp), %eax
movl (4)(%esp), %esi
movl (8)(%esp), %ecx
mov %edx, %edi
xor %ecx, %edi
xor %esi, %ecx
and %ecx, %edi
xor %esi, %ecx
xor %ecx, %edi
mov %edx, %esi
shrd $(2), %esi, %esi
mov %edx, %ecx
shrd $(13), %ecx, %ecx
xor %ecx, %esi
shrd $(9), %ecx, %ecx
xor %ecx, %esi
lea (%edi,%esi), %edx
add %eax, %edx
add (12)(%esp), %eax
mov %edx, (28)(%esp)
mov %eax, (12)(%esp)
mov %eax, %esi
shrd $(6), %esi, %esi
mov %eax, %ecx
shrd $(11), %ecx, %ecx
xor %ecx, %esi
shrd $(14), %ecx, %ecx
xor %ecx, %esi
mov (16)(%esp), %edi
xor (20)(%esp), %edi
and %eax, %edi
xor (20)(%esp), %edi
mov (24)(%esp), %eax
add %esi, %eax
add %edi, %eax
addl (36)(%esp), %eax
movl (%esp), %esi
movl (4)(%esp), %ecx
mov %edx, %edi
xor %ecx, %edi
xor %esi, %ecx
and %ecx, %edi
xor %esi, %ecx
xor %ecx, %edi
mov %edx, %esi
shrd $(2), %esi, %esi
mov %edx, %ecx
shrd $(13), %ecx, %ecx
xor %ecx, %esi
shrd $(9), %ecx, %ecx
xor %ecx, %esi
lea (%edi,%esi), %edx
add %eax, %edx
add (8)(%esp), %eax
mov %edx, (24)(%esp)
mov %eax, (8)(%esp)
mov %eax, %esi
shrd $(6), %esi, %esi
mov %eax, %ecx
shrd $(11), %ecx, %ecx
xor %ecx, %esi
shrd $(14), %ecx, %ecx
xor %ecx, %esi
mov (12)(%esp), %edi
xor (16)(%esp), %edi
and %eax, %edi
xor (16)(%esp), %edi
mov (20)(%esp), %eax
add %esi, %eax
add %edi, %eax
addl (40)(%esp), %eax
movl (28)(%esp), %esi
movl (%esp), %ecx
mov %edx, %edi
xor %ecx, %edi
xor %esi, %ecx
and %ecx, %edi
xor %esi, %ecx
xor %ecx, %edi
mov %edx, %esi
shrd $(2), %esi, %esi
mov %edx, %ecx
shrd $(13), %ecx, %ecx
xor %ecx, %esi
shrd $(9), %ecx, %ecx
xor %ecx, %esi
lea (%edi,%esi), %edx
add %eax, %edx
add (4)(%esp), %eax
mov %edx, (20)(%esp)
mov %eax, (4)(%esp)
mov %eax, %esi
shrd $(6), %esi, %esi
mov %eax, %ecx
shrd $(11), %ecx, %ecx
xor %ecx, %esi
shrd $(14), %ecx, %ecx
xor %ecx, %esi
mov (8)(%esp), %edi
xor (12)(%esp), %edi
and %eax, %edi
xor (12)(%esp), %edi
mov (16)(%esp), %eax
add %esi, %eax
add %edi, %eax
addl (44)(%esp), %eax
movl (24)(%esp), %esi
movl (28)(%esp), %ecx
mov %edx, %edi
xor %ecx, %edi
xor %esi, %ecx
and %ecx, %edi
xor %esi, %ecx
xor %ecx, %edi
mov %edx, %esi
shrd $(2), %esi, %esi
mov %edx, %ecx
shrd $(13), %ecx, %ecx
xor %ecx, %esi
shrd $(9), %ecx, %ecx
xor %ecx, %esi
lea (%edi,%esi), %edx
add %eax, %edx
add (%esp), %eax
mov %edx, (16)(%esp)
mov %eax, (%esp)
vpshufd $(250), %xmm0, %xmm6
vpsrld $(10), %xmm6, %xmm4
vpsrlq $(17), %xmm6, %xmm6
vpxor %xmm6, %xmm4, %xmm4
vpsrlq $(2), %xmm6, %xmm6
vpxor %xmm6, %xmm4, %xmm4
vpshufd $(165), %xmm1, %xmm6
vpsrld $(3), %xmm6, %xmm5
vpsrlq $(7), %xmm6, %xmm6
vpxor %xmm6, %xmm5, %xmm5
vpsrlq $(11), %xmm6, %xmm6
vpxor %xmm6, %xmm5, %xmm5
vpshufd $(80), %xmm1, %xmm7
vpaddd %xmm5, %xmm4, %xmm4
vpshufd $(165), %xmm3, %xmm6
vpaddd %xmm4, %xmm7, %xmm7
vpaddd %xmm6, %xmm7, %xmm7
vpshufd $(160), %xmm7, %xmm6
vpsrld $(10), %xmm6, %xmm4
vpsrlq $(17), %xmm6, %xmm6
vpxor %xmm6, %xmm4, %xmm4
vpsrlq $(2), %xmm6, %xmm6
vpxor %xmm6, %xmm4, %xmm4
vpalignr $(12), %xmm1, %xmm2, %xmm6
vpshufd $(80), %xmm6, %xmm6
vpsrld $(3), %xmm6, %xmm5
vpsrlq $(7), %xmm6, %xmm6
vpxor %xmm6, %xmm5, %xmm5
vpsrlq $(11), %xmm6, %xmm6
vpxor %xmm6, %xmm5, %xmm5
vpalignr $(12), %xmm3, %xmm0, %xmm6
vpshufd $(250), %xmm1, %xmm1
vpaddd %xmm5, %xmm4, %xmm4
vpshufd $(80), %xmm6, %xmm6
vpaddd %xmm4, %xmm1, %xmm1
vpaddd %xmm6, %xmm1, %xmm1
vpshufd $(136), %xmm7, %xmm7
vpshufd $(136), %xmm1, %xmm1
vpalignr $(8), %xmm7, %xmm1, %xmm1
vpaddd (16)(%ebx), %xmm1, %xmm7
vmovdqu %xmm7, (32)(%esp)
mov %eax, %esi
shrd $(6), %esi, %esi
mov %eax, %ecx
shrd $(11), %ecx, %ecx
xor %ecx, %esi
shrd $(14), %ecx, %ecx
xor %ecx, %esi
mov (4)(%esp), %edi
xor (8)(%esp), %edi
and %eax, %edi
xor (8)(%esp), %edi
mov (12)(%esp), %eax
add %esi, %eax
add %edi, %eax
addl (32)(%esp), %eax
movl (20)(%esp), %esi
movl (24)(%esp), %ecx
mov %edx, %edi
xor %ecx, %edi
xor %esi, %ecx
and %ecx, %edi
xor %esi, %ecx
xor %ecx, %edi
mov %edx, %esi
shrd $(2), %esi, %esi
mov %edx, %ecx
shrd $(13), %ecx, %ecx
xor %ecx, %esi
shrd $(9), %ecx, %ecx
xor %ecx, %esi
lea (%edi,%esi), %edx
add %eax, %edx
add (28)(%esp), %eax
mov %edx, (12)(%esp)
mov %eax, (28)(%esp)
mov %eax, %esi
shrd $(6), %esi, %esi
mov %eax, %ecx
shrd $(11), %ecx, %ecx
xor %ecx, %esi
shrd $(14), %ecx, %ecx
xor %ecx, %esi
mov (%esp), %edi
xor (4)(%esp), %edi
and %eax, %edi
xor (4)(%esp), %edi
mov (8)(%esp), %eax
add %esi, %eax
add %edi, %eax
addl (36)(%esp), %eax
movl (16)(%esp), %esi
movl (20)(%esp), %ecx
mov %edx, %edi
xor %ecx, %edi
xor %esi, %ecx
and %ecx, %edi
xor %esi, %ecx
xor %ecx, %edi
mov %edx, %esi
shrd $(2), %esi, %esi
mov %edx, %ecx
shrd $(13), %ecx, %ecx
xor %ecx, %esi
shrd $(9), %ecx, %ecx
xor %ecx, %esi
lea (%edi,%esi), %edx
add %eax, %edx
add (24)(%esp), %eax
mov %edx, (8)(%esp)
mov %eax, (24)(%esp)
mov %eax, %esi
shrd $(6), %esi, %esi
mov %eax, %ecx
shrd $(11), %ecx, %ecx
xor %ecx, %esi
shrd $(14), %ecx, %ecx
xor %ecx, %esi
mov (28)(%esp), %edi
xor (%esp), %edi
and %eax, %edi
xor (%esp), %edi
mov (4)(%esp), %eax
add %esi, %eax
add %edi, %eax
addl (40)(%esp), %eax
movl (12)(%esp), %esi
movl (16)(%esp), %ecx
mov %edx, %edi
xor %ecx, %edi
xor %esi, %ecx
and %ecx, %edi
xor %esi, %ecx
xor %ecx, %edi
mov %edx, %esi
shrd $(2), %esi, %esi
mov %edx, %ecx
shrd $(13), %ecx, %ecx
xor %ecx, %esi
shrd $(9), %ecx, %ecx
xor %ecx, %esi
lea (%edi,%esi), %edx
add %eax, %edx
add (20)(%esp), %eax
mov %edx, (4)(%esp)
mov %eax, (20)(%esp)
mov %eax, %esi
shrd $(6), %esi, %esi
mov %eax, %ecx
shrd $(11), %ecx, %ecx
xor %ecx, %esi
shrd $(14), %ecx, %ecx
xor %ecx, %esi
mov (24)(%esp), %edi
xor (28)(%esp), %edi
and %eax, %edi
xor (28)(%esp), %edi
mov (%esp), %eax
add %esi, %eax
add %edi, %eax
addl (44)(%esp), %eax
movl (8)(%esp), %esi
movl (12)(%esp), %ecx
mov %edx, %edi
xor %ecx, %edi
xor %esi, %ecx
and %ecx, %edi
xor %esi, %ecx
xor %ecx, %edi
mov %edx, %esi
shrd $(2), %esi, %esi
mov %edx, %ecx
shrd $(13), %ecx, %ecx
xor %ecx, %esi
shrd $(9), %ecx, %ecx
xor %ecx, %esi
lea (%edi,%esi), %edx
add %eax, %edx
add (16)(%esp), %eax
mov %edx, (%esp)
mov %eax, (16)(%esp)
vpshufd $(250), %xmm1, %xmm6
vpsrld $(10), %xmm6, %xmm4
vpsrlq $(17), %xmm6, %xmm6
vpxor %xmm6, %xmm4, %xmm4
vpsrlq $(2), %xmm6, %xmm6
vpxor %xmm6, %xmm4, %xmm4
vpshufd $(165), %xmm2, %xmm6
vpsrld $(3), %xmm6, %xmm5
vpsrlq $(7), %xmm6, %xmm6
vpxor %xmm6, %xmm5, %xmm5
vpsrlq $(11), %xmm6, %xmm6
vpxor %xmm6, %xmm5, %xmm5
vpshufd $(80), %xmm2, %xmm7
vpaddd %xmm5, %xmm4, %xmm4
vpshufd $(165), %xmm0, %xmm6
vpaddd %xmm4, %xmm7, %xmm7
vpaddd %xmm6, %xmm7, %xmm7
vpshufd $(160), %xmm7, %xmm6
vpsrld $(10), %xmm6, %xmm4
vpsrlq $(17), %xmm6, %xmm6
vpxor %xmm6, %xmm4, %xmm4
vpsrlq $(2), %xmm6, %xmm6
vpxor %xmm6, %xmm4, %xmm4
vpalignr $(12), %xmm2, %xmm3, %xmm6
vpshufd $(80), %xmm6, %xmm6
vpsrld $(3), %xmm6, %xmm5
vpsrlq $(7), %xmm6, %xmm6
vpxor %xmm6, %xmm5, %xmm5
vpsrlq $(11), %xmm6, %xmm6
vpxor %xmm6, %xmm5, %xmm5
vpalignr $(12), %xmm0, %xmm1, %xmm6
vpshufd $(250), %xmm2, %xmm2
vpaddd %xmm5, %xmm4, %xmm4
vpshufd $(80), %xmm6, %xmm6
vpaddd %xmm4, %xmm2, %xmm2
vpaddd %xmm6, %xmm2, %xmm2
vpshufd $(136), %xmm7, %xmm7
vpshufd $(136), %xmm2, %xmm2
vpalignr $(8), %xmm7, %xmm2, %xmm2
vpaddd (32)(%ebx), %xmm2, %xmm7
vmovdqu %xmm7, (32)(%esp)
mov %eax, %esi
shrd $(6), %esi, %esi
mov %eax, %ecx
shrd $(11), %ecx, %ecx
xor %ecx, %esi
shrd $(14), %ecx, %ecx
xor %ecx, %esi
mov (20)(%esp), %edi
xor (24)(%esp), %edi
and %eax, %edi
xor (24)(%esp), %edi
mov (28)(%esp), %eax
add %esi, %eax
add %edi, %eax
addl (32)(%esp), %eax
movl (4)(%esp), %esi
movl (8)(%esp), %ecx
mov %edx, %edi
xor %ecx, %edi
xor %esi, %ecx
and %ecx, %edi
xor %esi, %ecx
xor %ecx, %edi
mov %edx, %esi
shrd $(2), %esi, %esi
mov %edx, %ecx
shrd $(13), %ecx, %ecx
xor %ecx, %esi
shrd $(9), %ecx, %ecx
xor %ecx, %esi
lea (%edi,%esi), %edx
add %eax, %edx
add (12)(%esp), %eax
mov %edx, (28)(%esp)
mov %eax, (12)(%esp)
mov %eax, %esi
shrd $(6), %esi, %esi
mov %eax, %ecx
shrd $(11), %ecx, %ecx
xor %ecx, %esi
shrd $(14), %ecx, %ecx
xor %ecx, %esi
mov (16)(%esp), %edi
xor (20)(%esp), %edi
and %eax, %edi
xor (20)(%esp), %edi
mov (24)(%esp), %eax
add %esi, %eax
add %edi, %eax
addl (36)(%esp), %eax
movl (%esp), %esi
movl (4)(%esp), %ecx
mov %edx, %edi
xor %ecx, %edi
xor %esi, %ecx
and %ecx, %edi
xor %esi, %ecx
xor %ecx, %edi
mov %edx, %esi
shrd $(2), %esi, %esi
mov %edx, %ecx
shrd $(13), %ecx, %ecx
xor %ecx, %esi
shrd $(9), %ecx, %ecx
xor %ecx, %esi
lea (%edi,%esi), %edx
add %eax, %edx
add (8)(%esp), %eax
mov %edx, (24)(%esp)
mov %eax, (8)(%esp)
mov %eax, %esi
shrd $(6), %esi, %esi
mov %eax, %ecx
shrd $(11), %ecx, %ecx
xor %ecx, %esi
shrd $(14), %ecx, %ecx
xor %ecx, %esi
mov (12)(%esp), %edi
xor (16)(%esp), %edi
and %eax, %edi
xor (16)(%esp), %edi
mov (20)(%esp), %eax
add %esi, %eax
add %edi, %eax
addl (40)(%esp), %eax
movl (28)(%esp), %esi
movl (%esp), %ecx
mov %edx, %edi
xor %ecx, %edi
xor %esi, %ecx
and %ecx, %edi
xor %esi, %ecx
xor %ecx, %edi
mov %edx, %esi
shrd $(2), %esi, %esi
mov %edx, %ecx
shrd $(13), %ecx, %ecx
xor %ecx, %esi
shrd $(9), %ecx, %ecx
xor %ecx, %esi
lea (%edi,%esi), %edx
add %eax, %edx
add (4)(%esp), %eax
mov %edx, (20)(%esp)
mov %eax, (4)(%esp)
mov %eax, %esi
shrd $(6), %esi, %esi
mov %eax, %ecx
shrd $(11), %ecx, %ecx
xor %ecx, %esi
shrd $(14), %ecx, %ecx
xor %ecx, %esi
mov (8)(%esp), %edi
xor (12)(%esp), %edi
and %eax, %edi
xor (12)(%esp), %edi
mov (16)(%esp), %eax
add %esi, %eax
add %edi, %eax
addl (44)(%esp), %eax
movl (24)(%esp), %esi
movl (28)(%esp), %ecx
mov %edx, %edi
xor %ecx, %edi
xor %esi, %ecx
and %ecx, %edi
xor %esi, %ecx
xor %ecx, %edi
mov %edx, %esi
shrd $(2), %esi, %esi
mov %edx, %ecx
shrd $(13), %ecx, %ecx
xor %ecx, %esi
shrd $(9), %ecx, %ecx
xor %ecx, %esi
lea (%edi,%esi), %edx
add %eax, %edx
add (%esp), %eax
mov %edx, (16)(%esp)
mov %eax, (%esp)
vpshufd $(250), %xmm2, %xmm6
vpsrld $(10), %xmm6, %xmm4
vpsrlq $(17), %xmm6, %xmm6
vpxor %xmm6, %xmm4, %xmm4
vpsrlq $(2), %xmm6, %xmm6
vpxor %xmm6, %xmm4, %xmm4
vpshufd $(165), %xmm3, %xmm6
vpsrld $(3), %xmm6, %xmm5
vpsrlq $(7), %xmm6, %xmm6
vpxor %xmm6, %xmm5, %xmm5
vpsrlq $(11), %xmm6, %xmm6
vpxor %xmm6, %xmm5, %xmm5
vpshufd $(80), %xmm3, %xmm7
vpaddd %xmm5, %xmm4, %xmm4
vpshufd $(165), %xmm1, %xmm6
vpaddd %xmm4, %xmm7, %xmm7
vpaddd %xmm6, %xmm7, %xmm7
vpshufd $(160), %xmm7, %xmm6
vpsrld $(10), %xmm6, %xmm4
vpsrlq $(17), %xmm6, %xmm6
vpxor %xmm6, %xmm4, %xmm4
vpsrlq $(2), %xmm6, %xmm6
vpxor %xmm6, %xmm4, %xmm4
vpalignr $(12), %xmm3, %xmm0, %xmm6
vpshufd $(80), %xmm6, %xmm6
vpsrld $(3), %xmm6, %xmm5
vpsrlq $(7), %xmm6, %xmm6
vpxor %xmm6, %xmm5, %xmm5
vpsrlq $(11), %xmm6, %xmm6
vpxor %xmm6, %xmm5, %xmm5
vpalignr $(12), %xmm1, %xmm2, %xmm6
vpshufd $(250), %xmm3, %xmm3
vpaddd %xmm5, %xmm4, %xmm4
vpshufd $(80), %xmm6, %xmm6
vpaddd %xmm4, %xmm3, %xmm3
vpaddd %xmm6, %xmm3, %xmm3
vpshufd $(136), %xmm7, %xmm7
vpshufd $(136), %xmm3, %xmm3
vpalignr $(8), %xmm7, %xmm3, %xmm3
vpaddd (48)(%ebx), %xmm3, %xmm7
vmovdqu %xmm7, (32)(%esp)
mov %eax, %esi
shrd $(6), %esi, %esi
mov %eax, %ecx
shrd $(11), %ecx, %ecx
xor %ecx, %esi
shrd $(14), %ecx, %ecx
xor %ecx, %esi
mov (4)(%esp), %edi
xor (8)(%esp), %edi
and %eax, %edi
xor (8)(%esp), %edi
mov (12)(%esp), %eax
add %esi, %eax
add %edi, %eax
addl (32)(%esp), %eax
movl (20)(%esp), %esi
movl (24)(%esp), %ecx
mov %edx, %edi
xor %ecx, %edi
xor %esi, %ecx
and %ecx, %edi
xor %esi, %ecx
xor %ecx, %edi
mov %edx, %esi
shrd $(2), %esi, %esi
mov %edx, %ecx
shrd $(13), %ecx, %ecx
xor %ecx, %esi
shrd $(9), %ecx, %ecx
xor %ecx, %esi
lea (%edi,%esi), %edx
add %eax, %edx
add (28)(%esp), %eax
mov %edx, (12)(%esp)
mov %eax, (28)(%esp)
mov %eax, %esi
shrd $(6), %esi, %esi
mov %eax, %ecx
shrd $(11), %ecx, %ecx
xor %ecx, %esi
shrd $(14), %ecx, %ecx
xor %ecx, %esi
mov (%esp), %edi
xor (4)(%esp), %edi
and %eax, %edi
xor (4)(%esp), %edi
mov (8)(%esp), %eax
add %esi, %eax
add %edi, %eax
addl (36)(%esp), %eax
movl (16)(%esp), %esi
movl (20)(%esp), %ecx
mov %edx, %edi
xor %ecx, %edi
xor %esi, %ecx
and %ecx, %edi
xor %esi, %ecx
xor %ecx, %edi
mov %edx, %esi
shrd $(2), %esi, %esi
mov %edx, %ecx
shrd $(13), %ecx, %ecx
xor %ecx, %esi
shrd $(9), %ecx, %ecx
xor %ecx, %esi
lea (%edi,%esi), %edx
add %eax, %edx
add (24)(%esp), %eax
mov %edx, (8)(%esp)
mov %eax, (24)(%esp)
mov %eax, %esi
shrd $(6), %esi, %esi
mov %eax, %ecx
shrd $(11), %ecx, %ecx
xor %ecx, %esi
shrd $(14), %ecx, %ecx
xor %ecx, %esi
mov (28)(%esp), %edi
xor (%esp), %edi
and %eax, %edi
xor (%esp), %edi
mov (4)(%esp), %eax
add %esi, %eax
add %edi, %eax
addl (40)(%esp), %eax
movl (12)(%esp), %esi
movl (16)(%esp), %ecx
mov %edx, %edi
xor %ecx, %edi
xor %esi, %ecx
and %ecx, %edi
xor %esi, %ecx
xor %ecx, %edi
mov %edx, %esi
shrd $(2), %esi, %esi
mov %edx, %ecx
shrd $(13), %ecx, %ecx
xor %ecx, %esi
shrd $(9), %ecx, %ecx
xor %ecx, %esi
lea (%edi,%esi), %edx
add %eax, %edx
add (20)(%esp), %eax
mov %edx, (4)(%esp)
mov %eax, (20)(%esp)
mov %eax, %esi
shrd $(6), %esi, %esi
mov %eax, %ecx
shrd $(11), %ecx, %ecx
xor %ecx, %esi
shrd $(14), %ecx, %ecx
xor %ecx, %esi
mov (24)(%esp), %edi
xor (28)(%esp), %edi
and %eax, %edi
xor (28)(%esp), %edi
mov (%esp), %eax
add %esi, %eax
add %edi, %eax
addl (44)(%esp), %eax
movl (8)(%esp), %esi
movl (12)(%esp), %ecx
mov %edx, %edi
xor %ecx, %edi
xor %esi, %ecx
and %ecx, %edi
xor %esi, %ecx
xor %ecx, %edi
mov %edx, %esi
shrd $(2), %esi, %esi
mov %edx, %ecx
shrd $(13), %ecx, %ecx
xor %ecx, %esi
shrd $(9), %ecx, %ecx
xor %ecx, %esi
lea (%edi,%esi), %edx
add %eax, %edx
add (16)(%esp), %eax
mov %edx, (%esp)
mov %eax, (16)(%esp)
subl $(16), (48)(%esp)
jg .Lloop_16_63gas_1
movl (8)(%ebp), %eax
vmovdqu (%esp), %xmm0
vmovdqu (16)(%esp), %xmm1
vmovdqu (%eax), %xmm7
vpaddd %xmm0, %xmm7, %xmm7
vmovdqu %xmm7, (%eax)
vmovdqu (16)(%eax), %xmm7
vpaddd %xmm1, %xmm7, %xmm7
vmovdqu %xmm7, (16)(%eax)
addl $(64), (12)(%ebp)
subl $(64), (16)(%ebp)
jg .Lsha256_block_loopgas_1
add $(52), %esp
pop %edi
pop %esi
pop %ebx
pop %ebp
ret
.Lfe1:
.size UpdateSHA256, .Lfe1-(UpdateSHA256)
|
;
; Copyright (c) 2020 Phillip Stevens
;
; This Source Code Form is subject to the terms of the Mozilla Public
; License, v. 2.0. If a copy of the MPL was not distributed with this
; file, You can obtain one at http://mozilla.org/MPL/2.0/.
;
; feilipu, August 2020
;
;-------------------------------------------------------------------------
; asm_am9511_atan - am9511 floating point arctangent
;-------------------------------------------------------------------------
SECTION code_clib
SECTION code_fp_am9511
EXTERN __IO_APU_CONTROL
EXTERN __IO_APU_OP_ATAN
EXTERN asm_am9511_pushf
EXTERN asm_am9511_pushf_fastcall
EXTERN asm_am9511_popf
PUBLIC asm_am9511_atan, asm_am9511_atan_fastcall
.asm_am9511_atan
ld hl,2
add hl,sp
call asm_am9511_pushf ; x
ld a,__IO_APU_OP_ATAN
out (__IO_APU_CONTROL),a ; atan(x)
jp asm_am9511_popf
.asm_am9511_atan_fastcall
call asm_am9511_pushf_fastcall ; x
ld a,__IO_APU_OP_ATAN
out (__IO_APU_CONTROL),a ; atan(x)
jp asm_am9511_popf
|
//
// main.cpp
//
// Created by Nissim Hadar on 2 Nov 2017.
// Copyright 2013 High Fidelity, Inc.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
#include <QtWidgets/QApplication>
#include "ui/AutoTester.h"
AutoTester* autoTester;
int main(int argc, char *argv[]) {
// Only parameter is "--testFolder"
QString testFolder;
if (argc == 3) {
if (QString(argv[1]) == "--testFolder") {
testFolder = QString(argv[2]);
}
}
QApplication application(argc, argv);
autoTester = new AutoTester();
if (!testFolder.isNull()) {
autoTester->runFromCommandLine(testFolder);
} else {
autoTester->show();
}
return application.exec();
}
|
// We index overrides.
//- @f defines/binding CF
class C { virtual void f() { } };
//- @f defines/binding DF
//- DF overrides CF
class D : public C { void f() override { } };
|
; ----------------------------------------------------------------
; Z88DK INTERFACE LIBRARY FOR THE NIRVANA ENGINE - by Einar Saukas
;
; See "nirvana-.h" for further details
; ----------------------------------------------------------------
; void NIRVANAM_tiles(unsigned char *addr)
; fastcall
SECTION code_clib
SECTION code_nirvanam
PUBLIC _NIRVANAM_tiles_fastcall
EXTERN asm_NIRVANAM_tiles
defc _NIRVANAM_tiles_fastcall = asm_NIRVANAM_tiles
|
\ ROM Filing System for Electron Wifi Board
\ (C) 2021 John Wike
\
\ low level read and write routines for the EEPROM
\ Workspace
include "electron.asm"
\ Bank 0: &0000 - &3FFF mfa = 1 bank = 0 the first two banks are the "hidden" banks used by the filing system
\ Bank 1: &4000 - &7FFF mfa = 1 bank = 1
\ Bank 2: &8000 - &BFFF mfa = 0 bank = 0 this is the bank that the Electron Wifi ROM occupies
\ Bank 3: &C000 - &FFFF mfa = 0 bank = 1 the first sector $8000 to $9000 is program area, the rest is filing system
\ UART registers
uart_thr = uart+8
uart_dll = uart+8
uart_dlm = uart+9
uart_afr = uart+10
uart_lcr = uart+11
uart_mcr = uart+12
org rwcode \ code will be copied to $FD00 and run from there
.rw
\ entry to write byte
JMP Write_Byte \note that this is assembled independently so these are local references
JMP Read_Byte \ entry to read byte
\ entry point from format code during update
LDA $F4 \ so this always points to Bank 3
STA banktable
LDA #$00
STA mfatable
STA zrfsptr
STA rfssrc
LDA #$80
STA zrfsptr+1 \ start location in EEPROM is $8000
LDA #HI(dload)
STA rfssrc+1 \ source is the download area
.Update_Loop
LDY #$00
LDA (rfssrc),Y \ read byte from ram
JSR Write_Byte \ write byte to eeprom
INC rfssrc \ inc ram pointer
BNE Src_Ok
INC rfssrc+1
LDA #'.'
JSR osasci \ print "."to indicate progress
.Src_Ok
INC zrfsptr
BNE Ptr_Ok
INC zrfsptr+1 \ inc eeprom pointer
.Ptr_Ok
LDA zrfsptr+1
CMP #$90
BNE Update_Loop \ loop until $9000 reached
JSR osnewl
JMP dload+$1003 \ return to update code in update2.asm
.Read_Byte \ enter with EPROM address in zrfsptr, mfa in mfatable and bank in banktable
PHP
SEI \ set interrupt flag
LDY mfatable
STY uart_mcr \ set bit 15 of eeprom
LDY banktable
LDA #$0F
STA $FE05
STY $FE05 \ set bit 14 of eeprom
LDY #$00
LDA (zrfsptr),Y \ read byte from eeprom
STY uart_mcr \ reset Bank 3 to return to program
LDY $F4
STY $FE05
PLP \ clear interrupt flag
RTS
\ entry to write byte, enter with EPROM address in zrfsptr, mfa in mfatable and bank in banktable
.Write_Byte
PHP
SEI \ set interrupt flag
PHA \ save A
LDA #$08 \ set Bank 1
STA uart_mcr
LDA #$0F
STA $FE05
LDA $F4
ORA #$01 \ note to self: this line may not be necessary
STA $FE05
LDY #$AA
STY $9555 \ write $AA to $9555 ($5555 in bank 1)
AND #$06 \ mask lsb of slot number
STA $FE05
LDY #$55
STY $AAAA \ write $55 to $AAAA ($2AAA in bank 0)
STY uart_thr
ORA #$01 \ set lsb of slot number
STA $FE05
LDY #$A0
STY $9555 \ write $A0 to $9555 ($5555 in bank 1)
LDY mfatable
STY uart_mcr \ set bit 15 of eeprom
LDY banktable \ set bit 14 of eeprom
STY $FE05
LDY #$00
PLA \ restore A
STA (zrfsptr),Y \ write to EEPROM
STY uart_mcr \ reset Bank 3 to return to program
LDY $F4
STY $FE05
.Wait
LDA $8000 \ read byte from eeprom
EOR $8000 \ compare with previous read
AND #$40
BNE Wait \ wait until bit 6 is the same
PLP \ clear interrupt flag
RTS
.rw_end
SAVE "rw.bin", rw, rw_end
|
.global s_prepare_buffers
s_prepare_buffers:
push %r11
push %r14
push %r8
push %rcx
push %rdi
push %rdx
push %rsi
lea addresses_D_ht+0x1167a, %rsi
lea addresses_normal_ht+0x522e, %rdi
nop
nop
nop
nop
nop
sub $36281, %r8
mov $19, %rcx
rep movsw
nop
nop
nop
nop
nop
add %r14, %r14
lea addresses_WT_ht+0x18632, %rcx
nop
add %rdx, %rdx
mov $0x6162636465666768, %rdi
movq %rdi, %xmm6
movups %xmm6, (%rcx)
nop
nop
nop
nop
cmp %rsi, %rsi
lea addresses_D_ht+0x1395, %rdi
nop
nop
nop
add $17272, %r11
movb $0x61, (%rdi)
nop
nop
and $28114, %rdx
lea addresses_D_ht+0x9232, %rsi
nop
nop
nop
nop
nop
add %rdi, %rdi
mov (%rsi), %rdx
nop
nop
nop
nop
nop
sub $52005, %rdx
lea addresses_A_ht+0x1632, %r8
nop
sub $53410, %r14
movw $0x6162, (%r8)
nop
add %rsi, %rsi
lea addresses_A_ht+0x1199a, %rdx
nop
and %r8, %r8
mov (%rdx), %cx
and %rsi, %rsi
lea addresses_normal_ht+0x1c632, %rsi
cmp %rdx, %rdx
mov $0x6162636465666768, %r14
movq %r14, (%rsi)
add %rcx, %rcx
pop %rsi
pop %rdx
pop %rdi
pop %rcx
pop %r8
pop %r14
pop %r11
ret
.global s_faulty_load
s_faulty_load:
push %r14
push %r9
push %rax
push %rbp
push %rcx
push %rdi
push %rdx
// Store
lea addresses_RW+0x1d632, %rax
cmp %rbp, %rbp
mov $0x5152535455565758, %rdx
movq %rdx, %xmm2
movups %xmm2, (%rax)
xor $54870, %rbp
// Faulty Load
lea addresses_RW+0x1d632, %rcx
nop
nop
nop
nop
nop
inc %rdi
movups (%rcx), %xmm2
vpextrq $1, %xmm2, %r14
lea oracles, %rbp
and $0xff, %r14
shlq $12, %r14
mov (%rbp,%r14,1), %r14
pop %rdx
pop %rdi
pop %rcx
pop %rbp
pop %rax
pop %r9
pop %r14
ret
/*
<gen_faulty_load>
[REF]
{'src': {'same': False, 'congruent': 0, 'NT': False, 'type': 'addresses_RW', 'size': 1, 'AVXalign': False}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'same': True, 'congruent': 0, 'NT': False, 'type': 'addresses_RW', 'size': 16, 'AVXalign': False}}
[Faulty Load]
{'src': {'same': True, 'congruent': 0, 'NT': False, 'type': 'addresses_RW', 'size': 16, 'AVXalign': False}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'src': {'type': 'addresses_D_ht', 'congruent': 2, 'same': True}, 'OP': 'REPM', 'dst': {'type': 'addresses_normal_ht', 'congruent': 2, 'same': False}}
{'OP': 'STOR', 'dst': {'same': False, 'congruent': 11, 'NT': False, 'type': 'addresses_WT_ht', 'size': 16, 'AVXalign': False}}
{'OP': 'STOR', 'dst': {'same': False, 'congruent': 0, 'NT': True, 'type': 'addresses_D_ht', 'size': 1, 'AVXalign': False}}
{'src': {'same': True, 'congruent': 10, 'NT': True, 'type': 'addresses_D_ht', 'size': 8, 'AVXalign': False}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'same': False, 'congruent': 10, 'NT': False, 'type': 'addresses_A_ht', 'size': 2, 'AVXalign': False}}
{'src': {'same': False, 'congruent': 0, 'NT': False, 'type': 'addresses_A_ht', 'size': 2, 'AVXalign': False}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'same': False, 'congruent': 10, 'NT': False, 'type': 'addresses_normal_ht', 'size': 8, 'AVXalign': False}}
{'00': 21829}
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
*/
|
; A017371: a(n) = (10*n + 8)^7.
; 2097152,612220032,13492928512,114415582592,587068342272,2207984167552,6722988818432,17565568854912,40867559636992,86812553324672,171382426877952,318547390056832,562949953421312,953133216331392,1555363874947072,2458100350228352,3777156435935232,5661610866627712,8300513205665792,11930436453209472,16843926774218752,23398900746453632,32029040528474112,43255237347640192,57698133708111872,76091814718849152,99298698941612032,128325679158960512,164341563462254592,208695867059654272,262939005204119552
mul $0,10
add $0,8
pow $0,7
|
pushl %eax;ret
x: pushl %eax; ret
y: pushl %eax; z: ret
|
// https://www.codechef.com/START11B/problems/FILLGRID
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
ll gcd(ll a, ll b)
{
if (b == 0)
return a;
return gcd(b, a % b);
}
ll to_number(string s)
{
ll ans = 0;
int n = s.size(), i;
for (i = 0; i < n; i++)
{
ans = ans * 10 + (s[i] - '0');
}
return ans;
}
int main()
{
int t;
cin >> t;
while (t--)
{
ll n, i, j;
cin >> n;
if (n == 1)
{
cout << -1 << endl;
}
else if (n == 2)
{
for (i = 0; i < n; i++)
{
for (j = 0; j < n; j++)
{
cout << -1 << " ";
}
cout << endl;
}
}
else
{
for (i = 0; i < n; i++)
{
for (j = 0; j < n; j++)
{
if (i == j)
cout << -1 << " ";
else
cout << 1 << " ";
}
cout << endl;
}
}
}
return 0;
} |
// Copyright 2021 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "components/subresource_filter/content/browser/ad_tagging_browser_test_utils.h"
#include <string>
#include "base/bind.h"
#include "base/strings/stringprintf.h"
#include "components/subresource_filter/content/browser/content_subresource_filter_throttle_manager.h"
#include "content/public/test/browser_test_utils.h"
#include "content/public/test/test_navigation_observer.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace subresource_filter {
namespace {
content::RenderFrameHost* CreateFrameImpl(
const content::ToRenderFrameHost& adapter,
const GURL& url,
bool ad_script) {
content::RenderFrameHost* rfh = adapter.render_frame_host();
std::string name = GetUniqueFrameName();
std::string script = base::StringPrintf(
"%s('%s','%s');", ad_script ? "createAdFrame" : "createFrame",
url.spec().c_str(), name.c_str());
content::WebContents* web_contents =
content::WebContents::FromRenderFrameHost(rfh);
content::TestNavigationObserver navigation_observer(web_contents, 1);
EXPECT_TRUE(content::ExecuteScript(rfh, script));
navigation_observer.Wait();
EXPECT_TRUE(navigation_observer.last_navigation_succeeded())
<< navigation_observer.last_net_error_code();
return content::FrameMatchingPredicate(
web_contents, base::BindRepeating(&content::FrameMatchesName, name));
}
} // namespace
std::string GetUniqueFrameName() {
static uint32_t frame_count = 0;
return base::StringPrintf("frame_%d", frame_count++);
}
content::RenderFrameHost* CreateSrcFrameFromAdScript(
const content::ToRenderFrameHost& adapter,
const GURL& url) {
return CreateFrameImpl(adapter, url, true /* ad_script */);
}
content::RenderFrameHost* CreateSrcFrame(
const content::ToRenderFrameHost& adapter,
const GURL& url) {
return CreateFrameImpl(adapter, url, false /* ad_script */);
}
void ExpectFrameAdEvidence(
content::RenderFrameHost* frame_host,
bool parent_is_ad,
blink::mojom::FilterListResult filter_list_result,
blink::mojom::FrameCreationStackEvidence created_by_ad_script) {
ExpectFrameAdEvidence(frame_host, parent_is_ad, filter_list_result,
filter_list_result, created_by_ad_script);
}
void ExpectFrameAdEvidence(
content::RenderFrameHost* frame_host,
bool parent_is_ad,
blink::mojom::FilterListResult latest_filter_list_result,
blink::mojom::FilterListResult most_restrictive_filter_list_result,
blink::mojom::FrameCreationStackEvidence created_by_ad_script) {
auto* throttle_manager =
ContentSubresourceFilterThrottleManager::FromWebContents(
content::WebContents::FromRenderFrameHost(frame_host));
absl::optional<blink::FrameAdEvidence> ad_evidence =
throttle_manager->GetAdEvidenceForFrame(frame_host);
ASSERT_TRUE(ad_evidence.has_value());
EXPECT_TRUE(ad_evidence->is_complete());
EXPECT_EQ(ad_evidence->parent_is_ad(), parent_is_ad);
EXPECT_EQ(ad_evidence->latest_filter_list_result(),
latest_filter_list_result);
EXPECT_EQ(ad_evidence->most_restrictive_filter_list_result(),
most_restrictive_filter_list_result);
EXPECT_EQ(ad_evidence->created_by_ad_script(), created_by_ad_script);
}
} // namespace subresource_filter
|
//-------------------------------------------------------------------------
/*
Copyright (C) 2010-2019 EDuke32 developers and contributors
Copyright (C) 2019 Nuke.YKT
Copyright (C) 2020 Christoph Oelckers
This file is part of Raze.
NBlood is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License version 2
as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
//-------------------------------------------------------------------------
#include "ns.h" // Must come before everything else!
#include "build.h"
#include "compat.h"
#include "c_bind.h"
#include "razemenu.h"
#include "gamestate.h"
#include "v_video.h"
#include "v_draw.h"
#include "vm.h"
#include "blood.h"
bool ShowOptionMenu();
BEGIN_BLD_NS
class CGameMenuItemQAV
{
public:
QAV* data;
int duration;
int lastTick;
bool bWideScreen;
bool bClearBackground;
CGameMenuItemQAV(int, int, const char*, bool widescreen = false, bool clearbackground = false);
void Draw(void);
};
CGameMenuItemQAV::CGameMenuItemQAV(int a3, int a4, const char* name, bool widescreen, bool clearbackground)
{
bWideScreen = widescreen;
bClearBackground = clearbackground;
if (name)
{
data = getQAV(fileSystem.GetResourceId(fileSystem.FindFile(name)));
if (data)
{
data->x = a3;
data->y = a4;
duration = data->duration;
lastTick = I_GetTime(data->ticrate);
}
}
}
void CGameMenuItemQAV::Draw(void)
{
if (bClearBackground)
twod->ClearScreen();
if (data)
{
qavProcessTicker(data, &duration, &lastTick);
if (duration <= 0 || duration > data->duration)
{
duration = data->duration;
}
auto currentDuration = data->duration - duration;
auto smoothratio = !cl_interpolate || cl_capfps? MaxSmoothRatio : I_GetTimeFrac(data->ticrate) * MaxSmoothRatio;
data->Play(currentDuration - data->ticksPerFrame, currentDuration, -1, NULL);
if (bWideScreen)
{
int xdim43 = scale(ydim, 4, 3);
int nCount = (twod->GetWidth() + xdim43 - 1) / xdim43;
int backX = data->x;
for (int i = 0; i < nCount; i++)
{
data->Draw(currentDuration, 10 + kQavOrientationLeft, 0, 0, false, smoothratio);
data->x += 320;
}
data->x = backX;
}
else
data->Draw(currentDuration, 10, 0, 0, false, smoothratio);
}
}
static std::unique_ptr<CGameMenuItemQAV> itemBloodQAV; // This must be global to ensure that the animation remains consistent across menus.
void UpdateNetworkMenus(void)
{
// For now disable the network menu item as it is not functional.
for (auto name : { NAME_Mainmenu, NAME_IngameMenu })
{
DMenuDescriptor** desc = MenuDescriptors.CheckKey(name);
if (desc != NULL && (*desc)->IsKindOf(RUNTIME_CLASS(DListMenuDescriptor)))
{
DListMenuDescriptor* ld = static_cast<DListMenuDescriptor*>(*desc);
for (auto& li : ld->mItems)
{
if (li->mAction == NAME_MultiMenu)
{
li->mEnabled = -1;
}
}
}
}
}
//----------------------------------------------------------------------------
//
// Menu related game interface functions
//
//----------------------------------------------------------------------------
void GameInterface::MenuOpened()
{
itemBloodQAV.reset(new CGameMenuItemQAV(160, 100, "BDRIP.QAV", true));
}
void GameInterface::MenuClosed()
{
itemBloodQAV.reset();
}
bool GameInterface::CanSave()
{
return (gamestate == GS_LEVEL && gPlayer[myconnectindex].pXSprite->health != 0);
}
FSavegameInfo GameInterface::GetSaveSig()
{
return { SAVESIG_BLD, MINSAVEVER_BLD, SAVEVER_BLD };
}
END_BLD_NS
using namespace Blood;
//----------------------------------------------------------------------------
//
//
//
//----------------------------------------------------------------------------
DEFINE_ACTION_FUNCTION(DListMenuItemBloodDripDrawer, Draw)
{
// For narrow screens this would be mispositioned so skip drawing it there.
double ratio = ActiveRatio(screen->GetWidth(), screen->GetHeight());
if (ratio > 1.32) itemBloodQAV->Draw();
return 0;
}
DEFINE_ACTION_FUNCTION(_ImageScrollerPageQavDrawer, LoadQav)
{
PARAM_PROLOGUE;
PARAM_STRING(str);
auto qav = new CGameMenuItemQAV(160, 100, str, false, true);
ACTION_RETURN_POINTER(qav);
}
DEFINE_ACTION_FUNCTION(_ImageScrollerPageQavDrawer, DestroyQav)
{
PARAM_PROLOGUE;
PARAM_POINTER(qav, CGameMenuItemQAV);
if (qav) delete qav;
return 0;
}
DEFINE_ACTION_FUNCTION(_ImageScrollerPageQavDrawer, DrawQav)
{
PARAM_PROLOGUE;
PARAM_POINTER(qav, CGameMenuItemQAV);
qav->Draw();
return 0;
}
|
.global s_prepare_buffers
s_prepare_buffers:
push %r11
push %r13
push %r8
push %r9
push %rbp
push %rbx
push %rcx
push %rdi
push %rsi
lea addresses_WT_ht+0x1bc07, %rcx
nop
nop
nop
nop
nop
sub $38679, %rbx
movw $0x6162, (%rcx)
nop
nop
nop
nop
dec %r8
lea addresses_A_ht+0x2633, %r11
nop
nop
nop
dec %r13
mov $0x6162636465666768, %r8
movq %r8, %xmm4
movups %xmm4, (%r11)
nop
add $55707, %r13
lea addresses_D_ht+0x5007, %r9
nop
nop
nop
nop
xor %rbp, %rbp
vmovups (%r9), %ymm4
vextracti128 $0, %ymm4, %xmm4
vpextrq $0, %xmm4, %r11
nop
nop
nop
nop
nop
sub %rcx, %rcx
lea addresses_UC_ht+0x8407, %rbp
nop
and %rcx, %rcx
mov (%rbp), %r8
nop
nop
nop
nop
and $43852, %r13
lea addresses_D_ht+0x7ac7, %rbp
nop
nop
mfence
mov (%rbp), %r9d
nop
nop
lfence
lea addresses_WT_ht+0xaf39, %rsi
lea addresses_WT_ht+0x7a87, %rdi
clflush (%rsi)
nop
nop
nop
add $11348, %r9
mov $7, %rcx
rep movsw
nop
inc %r13
lea addresses_normal_ht+0x16807, %rsi
lea addresses_UC_ht+0x1dc07, %rdi
nop
nop
nop
dec %rbx
mov $95, %rcx
rep movsq
nop
inc %rcx
lea addresses_UC_ht+0x1907, %rdi
nop
nop
cmp %r8, %r8
movb (%rdi), %r9b
and $50122, %r8
pop %rsi
pop %rdi
pop %rcx
pop %rbx
pop %rbp
pop %r9
pop %r8
pop %r13
pop %r11
ret
.global s_faulty_load
s_faulty_load:
push %r13
push %r15
push %r9
push %rax
push %rcx
push %rdi
push %rdx
push %rsi
// REPMOV
lea addresses_D+0x17037, %rsi
lea addresses_PSE+0x1a0c7, %rdi
nop
nop
and %r13, %r13
mov $58, %rcx
rep movsw
add $22116, %rsi
// Store
lea addresses_WT+0x1bd07, %r15
nop
nop
nop
nop
nop
add %rdi, %rdi
movl $0x51525354, (%r15)
nop
nop
inc %rsi
// REPMOV
lea addresses_D+0x14717, %rsi
mov $0x3a9, %rdi
nop
nop
nop
and %rax, %rax
mov $25, %rcx
rep movsb
nop
cmp %rax, %rax
// Store
lea addresses_A+0x9007, %r13
nop
nop
cmp $13275, %rdx
mov $0x5152535455565758, %rax
movq %rax, (%r13)
nop
nop
xor $27132, %r9
// Load
mov $0x1f79f0000000407, %r15
nop
nop
nop
nop
nop
sub $13498, %rax
mov (%r15), %si
nop
nop
nop
cmp %rsi, %rsi
// Store
mov $0x247e0b0000000307, %rax
nop
nop
nop
add %r9, %r9
movw $0x5152, (%rax)
nop
nop
nop
nop
dec %r13
// Load
lea addresses_UC+0x1e5bb, %r9
nop
add $55002, %rcx
movups (%r9), %xmm3
vpextrq $0, %xmm3, %rdi
nop
nop
nop
xor %rdx, %rdx
// Load
lea addresses_normal+0xa807, %rsi
nop
nop
nop
sub %rdx, %rdx
movups (%rsi), %xmm5
vpextrq $0, %xmm5, %r9
nop
nop
nop
nop
nop
inc %r9
// Faulty Load
lea addresses_A+0x9007, %r15
nop
dec %rax
mov (%r15), %dx
lea oracles, %rcx
and $0xff, %rdx
shlq $12, %rdx
mov (%rcx,%rdx,1), %rdx
pop %rsi
pop %rdx
pop %rdi
pop %rcx
pop %rax
pop %r9
pop %r15
pop %r13
ret
/*
<gen_faulty_load>
[REF]
{'src': {'type': 'addresses_A', 'same': False, 'size': 1, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_D', 'congruent': 4, 'same': False}, 'dst': {'type': 'addresses_PSE', 'congruent': 6, 'same': False}, 'OP': 'REPM'}
{'dst': {'type': 'addresses_WT', 'same': False, 'size': 4, 'congruent': 8, 'NT': False, 'AVXalign': True}, 'OP': 'STOR'}
{'src': {'type': 'addresses_D', 'congruent': 4, 'same': False}, 'dst': {'type': 'addresses_P', 'congruent': 0, 'same': False}, 'OP': 'REPM'}
{'dst': {'type': 'addresses_A', 'same': True, 'size': 8, 'congruent': 0, 'NT': False, 'AVXalign': True}, 'OP': 'STOR'}
{'src': {'type': 'addresses_NC', 'same': False, 'size': 2, 'congruent': 10, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
{'dst': {'type': 'addresses_NC', 'same': False, 'size': 2, 'congruent': 8, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
{'src': {'type': 'addresses_UC', 'same': False, 'size': 16, 'congruent': 2, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_normal', 'same': False, 'size': 16, 'congruent': 8, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
[Faulty Load]
{'src': {'type': 'addresses_A', 'same': True, 'size': 2, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'dst': {'type': 'addresses_WT_ht', 'same': False, 'size': 2, 'congruent': 8, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
{'dst': {'type': 'addresses_A_ht', 'same': False, 'size': 16, 'congruent': 2, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
{'src': {'type': 'addresses_D_ht', 'same': False, 'size': 32, 'congruent': 9, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_UC_ht', 'same': False, 'size': 8, 'congruent': 10, 'NT': True, 'AVXalign': False}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_D_ht', 'same': False, 'size': 4, 'congruent': 1, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_WT_ht', 'congruent': 1, 'same': False}, 'dst': {'type': 'addresses_WT_ht', 'congruent': 6, 'same': False}, 'OP': 'REPM'}
{'src': {'type': 'addresses_normal_ht', 'congruent': 11, 'same': False}, 'dst': {'type': 'addresses_UC_ht', 'congruent': 10, 'same': False}, 'OP': 'REPM'}
{'src': {'type': 'addresses_UC_ht', 'same': True, 'size': 1, 'congruent': 8, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
{'58': 394}
58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58
*/
|
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "content/browser/picture_in_picture/picture_in_picture_window_controller_impl.h"
#include <set>
#include <utility>
#include "components/viz/common/surfaces/surface_id.h"
#include "content/browser/media/media_web_contents_observer.h"
#include "content/browser/media/session/media_session_impl.h"
#include "content/browser/picture_in_picture/picture_in_picture_session.h"
#include "content/browser/web_contents/web_contents_impl.h"
#include "content/public/browser/content_browser_client.h"
#include "content/public/browser/overlay_window.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_delegate.h" // for PictureInPictureResult
#include "content/public/browser/web_contents_observer.h"
#include "content/public/common/content_client.h"
namespace content {
// static
PictureInPictureWindowController*
PictureInPictureWindowController::GetOrCreateForWebContents(
WebContents* web_contents) {
return PictureInPictureWindowControllerImpl::GetOrCreateForWebContents(
web_contents);
}
// static
PictureInPictureWindowControllerImpl*
PictureInPictureWindowControllerImpl::GetOrCreateForWebContents(
WebContents* web_contents) {
DCHECK(web_contents);
// This is a no-op if the controller already exists.
CreateForWebContents(web_contents);
return FromWebContents(web_contents);
}
PictureInPictureWindowControllerImpl::~PictureInPictureWindowControllerImpl() =
default;
PictureInPictureWindowControllerImpl::PictureInPictureWindowControllerImpl(
WebContents* web_contents)
: WebContentsObserver(web_contents) {
DCHECK(web_contents);
EnsureWindow();
DCHECK(window_) << "Picture in Picture requires a valid window.";
}
void PictureInPictureWindowControllerImpl::Show() {
DCHECK(window_);
DCHECK(surface_id_.is_valid());
MediaSessionImpl* media_session = MediaSessionImpl::Get(web_contents());
media_session_action_play_handled_ = media_session->ShouldRouteAction(
media_session::mojom::MediaSessionAction::kPlay);
media_session_action_pause_handled_ = media_session->ShouldRouteAction(
media_session::mojom::MediaSessionAction::kPause);
media_session_action_skip_ad_handled_ = media_session->ShouldRouteAction(
media_session::mojom::MediaSessionAction::kSkipAd);
media_session_action_next_track_handled_ = media_session->ShouldRouteAction(
media_session::mojom::MediaSessionAction::kNextTrack);
media_session_action_previous_track_handled_ =
media_session->ShouldRouteAction(
media_session::mojom::MediaSessionAction::kPreviousTrack);
media_session_action_toggle_microphone_handled_ =
media_session->ShouldRouteAction(
media_session::mojom::MediaSessionAction::kToggleMicrophone);
media_session_action_toggle_camera_handled_ =
media_session->ShouldRouteAction(
media_session::mojom::MediaSessionAction::kToggleCamera);
media_session_action_hang_up_handled_ = media_session->ShouldRouteAction(
media_session::mojom::MediaSessionAction::kHangUp);
UpdatePlayPauseButtonVisibility();
window_->SetSkipAdButtonVisibility(media_session_action_skip_ad_handled_);
window_->SetNextTrackButtonVisibility(
media_session_action_next_track_handled_);
window_->SetPreviousTrackButtonVisibility(
media_session_action_previous_track_handled_);
window_->SetMicrophoneMuted(microphone_muted_);
window_->SetToggleMicrophoneButtonVisibility(
media_session_action_toggle_microphone_handled_);
window_->SetCameraState(camera_turned_on_);
window_->SetToggleCameraButtonVisibility(
media_session_action_toggle_camera_handled_);
window_->SetHangUpButtonVisibility(media_session_action_hang_up_handled_);
window_->ShowInactive();
GetWebContentsImpl()->SetHasPictureInPictureVideo(true);
}
void PictureInPictureWindowControllerImpl::FocusInitiator() {
GetWebContentsImpl()->Activate();
}
void PictureInPictureWindowControllerImpl::Close(bool should_pause_video) {
if (!window_ || !window_->IsVisible())
return;
window_->Hide();
CloseInternal(should_pause_video);
}
void PictureInPictureWindowControllerImpl::CloseAndFocusInitiator() {
Close(false /* should_pause_video */);
FocusInitiator();
}
void PictureInPictureWindowControllerImpl::OnWindowDestroyed(
bool should_pause_video) {
window_ = nullptr;
CloseInternal(should_pause_video);
}
void PictureInPictureWindowControllerImpl::EmbedSurface(
const viz::SurfaceId& surface_id,
const gfx::Size& natural_size) {
EnsureWindow();
DCHECK(window_);
DCHECK(active_session_);
DCHECK(surface_id.is_valid());
surface_id_ = surface_id;
// Update the playback state in step with the video surface id. If the surface
// id was updated for the same video, this is a no-op. This could be updated
// for a different video if another media player on the same WebContents
// enters Picture-in-Picture mode.
UpdatePlaybackState(IsPlayerActive(), false);
window_->UpdateVideoSize(natural_size);
window_->SetSurfaceId(surface_id_);
}
OverlayWindow* PictureInPictureWindowControllerImpl::GetWindowForTesting() {
return window_.get();
}
void PictureInPictureWindowControllerImpl::UpdateLayerBounds() {
if (active_session_ && window_ && window_->IsVisible())
active_session_->NotifyWindowResized(window_->GetBounds().size());
}
bool PictureInPictureWindowControllerImpl::IsPlayerActive() {
if (!active_session_)
return false;
return GetWebContentsImpl()->media_web_contents_observer()->IsPlayerActive(
active_session_->player_id());
}
WebContents* PictureInPictureWindowControllerImpl::GetWebContents() {
return web_contents();
}
void PictureInPictureWindowControllerImpl::UpdatePlaybackState(
bool is_playing,
bool reached_end_of_stream) {
if (!window_)
return;
if (reached_end_of_stream) {
window_->SetPlaybackState(OverlayWindow::PlaybackState::kEndOfVideo);
return;
}
DCHECK(active_session_);
window_->SetPlaybackState(is_playing ? OverlayWindow::PlaybackState::kPlaying
: OverlayWindow::PlaybackState::kPaused);
}
bool PictureInPictureWindowControllerImpl::TogglePlayPause() {
DCHECK(window_);
DCHECK(active_session_);
if (IsPlayerActive()) {
if (media_session_action_pause_handled_) {
MediaSessionImpl::Get(web_contents())
->Suspend(MediaSession::SuspendType::kUI);
return true /* still playing */;
}
active_session_->GetMediaPlayerRemote()->RequestPause(
/*triggered_by_user=*/false);
return false /* paused */;
}
if (media_session_action_play_handled_) {
MediaSessionImpl::Get(web_contents())
->Resume(MediaSession::SuspendType::kUI);
return false /* still paused */;
}
active_session_->GetMediaPlayerRemote()->RequestPlay();
return true /* playing */;
}
PictureInPictureResult PictureInPictureWindowControllerImpl::StartSession(
PictureInPictureServiceImpl* service,
const MediaPlayerId& player_id,
mojo::PendingAssociatedRemote<media::mojom::MediaPlayer> player_remote,
const viz::SurfaceId& surface_id,
const gfx::Size& natural_size,
bool show_play_pause_button,
mojo::PendingRemote<blink::mojom::PictureInPictureSessionObserver> observer,
mojo::PendingRemote<blink::mojom::PictureInPictureSession>* session_remote,
gfx::Size* window_size) {
auto result =
GetWebContentsImpl()->EnterPictureInPicture(surface_id, natural_size);
// Picture-in-Picture may not be supported by all embedders, so we should only
// create the session if the EnterPictureInPicture request was successful.
if (result != PictureInPictureResult::kSuccess)
return result;
if (active_session_)
active_session_->Disconnect();
active_session_ = std::make_unique<PictureInPictureSession>(
service, player_id, std::move(player_remote),
session_remote->InitWithNewPipeAndPassReceiver(), std::move(observer));
EmbedSurface(surface_id, natural_size);
SetShowPlayPauseButton(show_play_pause_button);
Show();
*window_size = GetSize();
return result;
}
void PictureInPictureWindowControllerImpl::OnServiceDeleted(
PictureInPictureServiceImpl* service) {
if (!active_session_ || active_session_->service() != service)
return;
active_session_->Shutdown();
active_session_ = nullptr;
}
void PictureInPictureWindowControllerImpl::SetShowPlayPauseButton(
bool show_play_pause_button) {
always_show_play_pause_button_ = show_play_pause_button;
UpdatePlayPauseButtonVisibility();
}
void PictureInPictureWindowControllerImpl::SkipAd() {
if (media_session_action_skip_ad_handled_)
MediaSession::Get(web_contents())->SkipAd();
}
void PictureInPictureWindowControllerImpl::NextTrack() {
if (media_session_action_next_track_handled_)
MediaSession::Get(web_contents())->NextTrack();
}
void PictureInPictureWindowControllerImpl::PreviousTrack() {
if (media_session_action_previous_track_handled_)
MediaSession::Get(web_contents())->PreviousTrack();
}
void PictureInPictureWindowControllerImpl::ToggleMicrophone() {
if (!media_session_action_toggle_microphone_handled_)
return;
MediaSession::Get(web_contents())->ToggleMicrophone();
}
void PictureInPictureWindowControllerImpl::ToggleCamera() {
if (!media_session_action_toggle_camera_handled_)
return;
MediaSession::Get(web_contents())->ToggleCamera();
}
void PictureInPictureWindowControllerImpl::HangUp() {
if (media_session_action_hang_up_handled_)
MediaSession::Get(web_contents())->HangUp();
}
void PictureInPictureWindowControllerImpl::MediaSessionInfoChanged(
const media_session::mojom::MediaSessionInfoPtr& info) {
if (!info)
return;
microphone_muted_ =
info->microphone_state == media_session::mojom::MicrophoneState::kMuted;
camera_turned_on_ =
info->camera_state == media_session::mojom::CameraState::kTurnedOn;
if (!window_)
return;
window_->SetMicrophoneMuted(microphone_muted_);
window_->SetCameraState(camera_turned_on_);
}
void PictureInPictureWindowControllerImpl::MediaSessionActionsChanged(
const std::set<media_session::mojom::MediaSessionAction>& actions) {
// TODO(crbug.com/919842): Currently, the first Media Session to be created
// (independently of the frame) will be used. This means, we could show a
// Skip Ad button for a PiP video from another frame. Ideally, we should have
// a Media Session per frame, not per tab. This is not implemented yet.
media_session_action_pause_handled_ =
actions.find(media_session::mojom::MediaSessionAction::kPause) !=
actions.end();
media_session_action_play_handled_ =
actions.find(media_session::mojom::MediaSessionAction::kPlay) !=
actions.end();
media_session_action_skip_ad_handled_ =
actions.find(media_session::mojom::MediaSessionAction::kSkipAd) !=
actions.end();
media_session_action_next_track_handled_ =
actions.find(media_session::mojom::MediaSessionAction::kNextTrack) !=
actions.end();
media_session_action_previous_track_handled_ =
actions.find(media_session::mojom::MediaSessionAction::kPreviousTrack) !=
actions.end();
media_session_action_toggle_microphone_handled_ =
actions.find(
media_session::mojom::MediaSessionAction::kToggleMicrophone) !=
actions.end();
media_session_action_toggle_camera_handled_ =
actions.find(media_session::mojom::MediaSessionAction::kToggleCamera) !=
actions.end();
media_session_action_hang_up_handled_ =
actions.find(media_session::mojom::MediaSessionAction::kHangUp) !=
actions.end();
if (!window_)
return;
UpdatePlayPauseButtonVisibility();
window_->SetSkipAdButtonVisibility(media_session_action_skip_ad_handled_);
window_->SetNextTrackButtonVisibility(
media_session_action_next_track_handled_);
window_->SetPreviousTrackButtonVisibility(
media_session_action_previous_track_handled_);
window_->SetToggleMicrophoneButtonVisibility(
media_session_action_toggle_microphone_handled_);
window_->SetToggleCameraButtonVisibility(
media_session_action_toggle_camera_handled_);
window_->SetHangUpButtonVisibility(media_session_action_hang_up_handled_);
}
gfx::Size PictureInPictureWindowControllerImpl::GetSize() {
return window_->GetBounds().size();
}
void PictureInPictureWindowControllerImpl::MediaStartedPlaying(
const MediaPlayerInfo&,
const MediaPlayerId& media_player_id) {
if (web_contents()->IsBeingDestroyed())
return;
if (!active_session_ || active_session_->player_id() != media_player_id)
return;
UpdatePlaybackState(true /* is_playing */, false /* reached_end_of_stream */);
}
void PictureInPictureWindowControllerImpl::MediaStoppedPlaying(
const MediaPlayerInfo&,
const MediaPlayerId& media_player_id,
WebContentsObserver::MediaStoppedReason reason) {
if (web_contents()->IsBeingDestroyed())
return;
if (!active_session_ || active_session_->player_id() != media_player_id)
return;
UpdatePlaybackState(
false /* is_playing */,
reason == WebContentsObserver::MediaStoppedReason::kReachedEndOfStream);
}
void PictureInPictureWindowControllerImpl::WebContentsDestroyed() {
if (window_)
window_->Close();
}
void PictureInPictureWindowControllerImpl::OnLeavingPictureInPicture(
bool should_pause_video) {
DCHECK(active_session_);
if (IsPlayerActive() && should_pause_video) {
// Pause the current video so there is only one video playing at a time.
active_session_->GetMediaPlayerRemote()->RequestPause(
/*triggered_by_user=*/false);
}
active_session_->Shutdown();
active_session_ = nullptr;
}
void PictureInPictureWindowControllerImpl::CloseInternal(
bool should_pause_video) {
// We shouldn't have an empty active_session_ in this case but (at least for
// there tests), extensions seem to be closing the window before the
// WebContents is marked as being destroyed. It leads to `CloseInternal()`
// being called twice. This early check avoids the rest of the code having to
// be aware of this oddity.
if (web_contents()->IsBeingDestroyed() || !active_session_)
return;
GetWebContentsImpl()->SetHasPictureInPictureVideo(false);
OnLeavingPictureInPicture(should_pause_video);
surface_id_ = viz::SurfaceId();
}
void PictureInPictureWindowControllerImpl::EnsureWindow() {
if (window_)
return;
window_ =
GetContentClient()->browser()->CreateWindowForPictureInPicture(this);
}
void PictureInPictureWindowControllerImpl::UpdatePlayPauseButtonVisibility() {
if (!window_)
return;
window_->SetPlayPauseButtonVisibility((media_session_action_pause_handled_ &&
media_session_action_play_handled_) ||
always_show_play_pause_button_);
}
WebContentsImpl* PictureInPictureWindowControllerImpl::GetWebContentsImpl() {
return static_cast<WebContentsImpl*>(web_contents());
}
WEB_CONTENTS_USER_DATA_KEY_IMPL(PictureInPictureWindowControllerImpl)
} // namespace content
|
/*
Print.cpp - Base class that provides print() and println()
Copyright (c) 2008 David A. Mellis. All right reserved.
Modified by Brian T. Park 2019.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Modified 23 November 2006 by David A. Mellis
Modified 03 August 2015 by Chuck Todd
Modified 2018 by Brian T. Park
*/
#include <stdlib.h>
#include <stdio.h> // vsnprintf
#include <stdarg.h> // va_list, va_start()
#include <math.h> // isnan(), isinf()
#include "pgmspace.h"
#include "Print.h"
// Size of the internal printf() buffer
#define PRINTF_BUFFER_SIZE 250
// Public Methods //////////////////////////////////////////////////////////////
/* default implementation: may be overridden */
size_t Print::write(const uint8_t *buffer, size_t size)
{
size_t n = 0;
while (size--) {
if (write(*buffer++)) n++;
else break;
}
return n;
}
size_t Print::print(const __FlashStringHelper *ifsh)
{
PGM_P p = reinterpret_cast<PGM_P>(ifsh);
size_t n = 0;
while (1) {
unsigned char c = pgm_read_byte(p++);
if (c == 0) break;
if (write(c)) n++;
else break;
}
return n;
}
size_t Print::print(const String &s)
{
return write(s.c_str(), s.length());
}
size_t Print::print(const char str[])
{
return write(str);
}
size_t Print::print(char c)
{
return write(c);
}
size_t Print::print(unsigned char b, int base)
{
return print((unsigned long) b, base);
}
size_t Print::print(int n, int base)
{
return print((long) n, base);
}
size_t Print::print(unsigned int n, int base)
{
return print((unsigned long) n, base);
}
size_t Print::print(long n, int base)
{
if (base == 0) {
return write(n);
} else if (base == 10) {
if (n < 0) {
int t = print('-');
n = -n;
return printNumber(n, 10) + t;
}
return printNumber(n, 10);
} else {
return printNumber(n, base);
}
}
size_t Print::print(unsigned long n, int base)
{
if (base == 0) return write(n);
else return printNumber(n, base);
}
size_t Print::print(double n, int digits)
{
return printFloat(n, digits);
}
size_t Print::println(const __FlashStringHelper *ifsh)
{
size_t n = print(ifsh);
n += println();
return n;
}
size_t Print::print(const Printable& x)
{
return x.printTo(*this);
}
size_t Print::println(void)
{
return write("\r\n");
}
size_t Print::println(const String &s)
{
size_t n = print(s);
n += println();
return n;
}
size_t Print::println(const char c[])
{
size_t n = print(c);
n += println();
return n;
}
size_t Print::println(char c)
{
size_t n = print(c);
n += println();
return n;
}
size_t Print::println(unsigned char b, int base)
{
size_t n = print(b, base);
n += println();
return n;
}
size_t Print::println(int num, int base)
{
size_t n = print(num, base);
n += println();
return n;
}
size_t Print::println(unsigned int num, int base)
{
size_t n = print(num, base);
n += println();
return n;
}
size_t Print::println(long num, int base)
{
size_t n = print(num, base);
n += println();
return n;
}
size_t Print::println(unsigned long num, int base)
{
size_t n = print(num, base);
n += println();
return n;
}
size_t Print::println(double num, int digits)
{
size_t n = print(num, digits);
n += println();
return n;
}
size_t Print::println(const Printable& x)
{
size_t n = print(x);
n += println();
return n;
}
size_t Print::printf(const char* fmt, ...) {
char buf[PRINTF_BUFFER_SIZE];
va_list args;
va_start(args, fmt);
int status = vsnprintf(buf, PRINTF_BUFFER_SIZE, fmt, args);
va_end(args);
if (status >= 0) {
buf[PRINTF_BUFFER_SIZE - 1] = '\0';
size_t n = print(buf);
return n;
} else {
return 0;
}
}
// Private Methods /////////////////////////////////////////////////////////////
size_t Print::printNumber(unsigned long n, uint8_t base)
{
char buf[8 * sizeof(long) + 1]; // Assumes 8-bit chars plus zero byte.
char *str = &buf[sizeof(buf) - 1];
*str = '\0';
// prevent crash if called with base == 1
if (base < 2) base = 10;
do {
char c = n % base;
n /= base;
*--str = c < 10 ? c + '0' : c + 'A' - 10;
} while(n);
return write(str);
}
size_t Print::printFloat(double number, uint8_t digits)
{
size_t n = 0;
if (isnan(number)) return print("nan");
if (isinf(number)) return print("inf");
if (number > 4294967040.0) return print ("ovf"); // constant determined empirically
if (number <-4294967040.0) return print ("ovf"); // constant determined empirically
// Handle negative numbers
if (number < 0.0)
{
n += print('-');
number = -number;
}
// Round correctly so that print(1.999, 2) prints as "2.00"
double rounding = 0.5;
for (uint8_t i=0; i<digits; ++i)
rounding /= 10.0;
number += rounding;
// Extract the integer part of the number and print it
unsigned long int_part = (unsigned long)number;
double remainder = number - (double)int_part;
n += print(int_part);
// Print the decimal point, but only if there are digits beyond
if (digits > 0) {
n += print('.');
}
// Extract digits from the remainder one at a time
while (digits-- > 0)
{
remainder *= 10.0;
unsigned int toPrint = (unsigned int)(remainder);
n += print(toPrint);
remainder -= toPrint;
}
return n;
}
|
#include "httpd.h"
#include "log.h"
#define JPEG_QUALITY 80
string Httpd::ApiKey="";
Httpd * Httpd::me=NULL;
void Httpd::start(int port, ILightController * light, IStatus * status) throw (ThreadCreateException){
if (Httpd::me==NULL) {
Httpd::me=new Httpd(port, light,status);
Httpd::me->running=true;
if(pthread_create(Httpd::me->thread, NULL, Httpd::run, Httpd::me)) {
Log::logger->log("HTTPD",ERROR) << "Can't create HTTPD thread " << strerror (errno) << endl;
throw ThreadCreateException();
}
}
}
void Httpd::stop() {
Httpd::me->running=false;
pthread_join(*(Httpd::me->thread), NULL);
delete Httpd::me;
Httpd::me=NULL;
}
void * Httpd::run(void * httpd) {
Httpd * me=(Httpd *) httpd;
Log::logger->log("HTTPD",DEBUG) << "Sarting HTTPD server" <<endl;
me->server=new HttpServer(me->port,20, true);
me->server->add(HTTP_GET, "/api/image", Httpd::captureLiveImage);
me->server->add(HTTP_GET, "/api/pause", Httpd::togglePause);
me->server->add(HTTP_GET, "/api/status", Httpd::getStatus);
me->server->run();
return NULL;
}
Httpd::Httpd(int port, ILightController * light, IStatus * status) {
this->port=port;
this->light=light;
this->appstatus=status;
this->thread= (pthread_t *) malloc(sizeof(pthread_t));
}
Httpd::~Httpd() {
free(this->thread);
}
int Httpd::togglePause(HttpRequest * request, HttpResponse * response) {
string apikey="";
try {
apikey=request->getHeader("apikey");
} catch(std::out_of_range &e) {}
Httpd * me=Httpd::me;
if (apikey!=Httpd::ApiKey) {
Log::logger->log("HTTPD", DEBUG) << "Forbbiden request" <<endl;
response->setStatusCode(403);
response->setStatusMessage("FORBIDDEN");
response->send();
delete response;
delete request;
} else {
Httpd * me=Httpd::me;
bool state=me->light->togglePause();
response->setStatusCode(200);
response->setStatusMessage("OK");
response->setContentType("application/json");
if (state) {
response->setBody("{\"pause\": true}", 15);
} else {
response->setBody("{\"pause\": false}", 16);
}
response->send();
delete response;
delete request;
}
return 0;
}
int Httpd::getStatus(HttpRequest * request, HttpResponse * response) {
string apikey="";
try {
apikey=request->getHeader("apikey");
} catch(std::out_of_range &e) {}
Httpd * me=Httpd::me;
if (apikey!=Httpd::ApiKey) {
Log::logger->log("HTTPD", DEBUG) << "Forbbiden request" <<endl;
response->setStatusCode(403);
response->setStatusMessage("FORBIDDEN");
response->send();
delete response;
delete request;
} else {
Httpd * me=Httpd::me;
string status=me->appstatus->jsonStatus();
response->setStatusCode(200);
response->setStatusMessage("OK");
response->setContentType("application/json");
response->setBody(status.c_str(), status.length());
response->send();
delete response;
delete request;
}
return 0;
}
int Httpd::captureLiveImage(HttpRequest * request, HttpResponse * response) {
string apikey="";
try {
apikey=request->getHeader("apikey");
} catch(std::out_of_range &e) {}
Httpd * me=Httpd::me;
if (apikey!=Httpd::ApiKey) {
Log::logger->log("HTTPD", DEBUG) << "Forbbiden request" <<endl;
response->setStatusCode(403);
response->setStatusMessage("FORBIDDEN");
response->send();
delete response;
delete request;
} else {
pthread_t httpd_thread;
HttpContext * context=new HttpContext(request, response);
if(pthread_create(&httpd_thread, NULL, Httpd::sendCapturedImage, context)) {
Log::logger->log("HTTPD",ERROR) << "Can't create send image thread " << strerror (errno) << endl;
} else {
if(pthread_detach(httpd_thread)) {
Log::logger->log("HTTPD",ERROR) << "Can't detach send image thread " << strerror (errno) << endl;
}
}
}
return 0;
}
void * Httpd::sendCapturedImage(void * params) {
HttpContext * context=(HttpContext *) params;
char * buffer=NULL;
unsigned long size=0;
Httpd * me=Httpd::me;
me->light->lightOn();
Camera * camera=new Camera();
try {
camera->init();
try {
camera->capture();
buffer=(char *) camera->toJpeg(&size,JPEG_QUALITY);
context->response->setStatusCode(200);
context->response->setStatusMessage("OK");
context->response->setContentType("image/jpeg");
context->response->setBody(buffer, size);
} catch(CameraOpenException &e) {
context->response->setStatusCode(500);
context->response->setStatusMessage("Internal Server Error");
context->response->setContentType("application/json");
context->response->setBody("{\"message\": \"Can't capture the image\"}", 38);
}
}catch(CameraOpenException &e) {
context->response->setStatusCode(500);
context->response->setStatusMessage("Internal Server Error");
context->response->setContentType("application/json");
context->response->setBody("{\"message\": \"Can't initialize the Camera\"}", 42);
}
me->light->lightOff();
context->response->send();
delete camera;
delete context;
if (size>0) {
free(buffer);
}
return NULL;
} |
#include "PythonEntityPrototypeGenerator.h"
#include "Interface/PrototypeServiceInterface.h"
#include "Interface/ScriptServiceInterface.h"
#include "Environment/Python/PythonEventReceiver.h"
#include "PythonEntityBehavior.h"
#include "Kernel/FactoryPool.h"
#include "Kernel/AssertionFactory.h"
#include "Kernel/AssertionMemoryPanic.h"
#include "Kernel/Logger.h"
#include "Kernel/Document.h"
#include "Kernel/ConstStringHelper.h"
#include "pybind/pybind.hpp"
namespace Mengine
{
//////////////////////////////////////////////////////////////////////////
PythonEntityPrototypeGenerator::PythonEntityPrototypeGenerator()
{
}
//////////////////////////////////////////////////////////////////////////
PythonEntityPrototypeGenerator::~PythonEntityPrototypeGenerator()
{
}
//////////////////////////////////////////////////////////////////////////
void PythonEntityPrototypeGenerator::setGenerator( const pybind::object & _generator )
{
m_generator = _generator;
}
//////////////////////////////////////////////////////////////////////////
const pybind::object & PythonEntityPrototypeGenerator::getGenerator() const
{
return m_generator;
}
//////////////////////////////////////////////////////////////////////////
bool PythonEntityPrototypeGenerator::initialize()
{
if( FactoryPrototypeGenerator::initialize() == false )
{
return false;
}
if( m_generator.is_callable() == false )
{
return false;
}
return true;
}
//////////////////////////////////////////////////////////////////////////
void PythonEntityPrototypeGenerator::finalize()
{
FactoryPrototypeGenerator::finalize();
if( m_eventable != nullptr )
{
EventationInterface * eventation = m_eventable->getEventation();
eventation->removeEvents();
m_eventable = nullptr;
}
m_generator = nullptr;
}
//////////////////////////////////////////////////////////////////////////
FactoryPtr PythonEntityPrototypeGenerator::_initializeFactory()
{
FactoryPtr factory = Helper::makeFactoryPool<PythonEntityBehavior, 128>( MENGINE_DOCUMENT_FACTORABLE );
return factory;
}
//////////////////////////////////////////////////////////////////////////
void PythonEntityPrototypeGenerator::_finalizeFactory()
{
//Empty
}
//////////////////////////////////////////////////////////////////////////
void PythonEntityPrototypeGenerator::setPythonType( const pybind::object & _type )
{
m_type = _type;
}
//////////////////////////////////////////////////////////////////////////
const pybind::object & PythonEntityPrototypeGenerator::getPythonType()
{
if( m_type.is_invalid() == false )
{
return m_type;
}
pybind::object py_type = m_generator.call( m_prototype );
EventablePtr eventable = SCRIPT_SERVICE()
->eventableEntity( py_type );
MENGINE_ASSERTION_MEMORY_PANIC( eventable, "type '%s' prototype '%s' invalid eventable entity"
, m_category.c_str()
, m_prototype.c_str()
);
m_eventable = eventable;
m_type = py_type;
return m_type;
}
//////////////////////////////////////////////////////////////////////////
FactorablePointer PythonEntityPrototypeGenerator::generate( const DocumentPtr & _doc )
{
const pybind::object & py_type = this->getPythonType();
if( py_type.is_invalid() == true )
{
return nullptr;
}
pybind::object py_entity = py_type.call();
if( py_entity.is_invalid() == true )
{
LOGGER_ERROR( "can't create object '%s' '%s' (invalid create) (doc: %s)"
, m_category.c_str()
, m_prototype.c_str()
, MENGINE_DOCUMENT_STR( _doc )
);
return nullptr;
}
EntityPtr entity = PROTOTYPE_SERVICE()
->generatePrototype( STRINGIZE_STRING_LOCAL( "Node" ), m_category, _doc );
MENGINE_ASSERTION_MEMORY_PANIC( entity, "can't generate '%s' '%s' doc '%s'"
, m_category.c_str()
, m_prototype.c_str()
, MENGINE_DOCUMENT_STR( _doc )
);
entity->setPrototype( m_prototype );
entity->setBehaviorEventable( m_eventable );
const FactoryPtr & factory = this->getPrototypeFactory();
PythonEntityBehaviorPtr behavior = factory->createObject( _doc );
behavior->setScriptObject( py_entity );
entity->setBehavior( behavior );
if( entity->create() == false )
{
LOGGER_ERROR( "invalid create entity category '%s' prototype '%s' (doc: %s)"
, m_category.c_str()
, m_prototype.c_str()
, MENGINE_DOCUMENT_STR( _doc )
);
return nullptr;
}
return entity;
}
} |
global _main
extern _printf
section .data
matriz times 12 dw 2
LONG_ELEM equ 2
CANT_FIL equ 4
CANT_COL equ 3
elem db '%d ',0
crlf db 10,13,0
section .bss
fil resw 1
col resw 1
section .text
_main:
;Imprimo la matriz con los valores iniciales
call printMat
call printCRLF
;Modifico un elemento
mov word[fil],2
mov word[col],3
call getOffset
mov word[matriz+ebx],3
;Imprimo la matriz modificada
call printMat
ret
;*************************************************************************************
; Rutinas Internas
;*************************************************************************************
;*************************************************************************************
;Rutina printMat
;*************************************************************************************
printMat:
mov word[fil],1 ;fila = 1
mov word[col],1 ;columna = 1
verifyEnd:
cmp word[fil],CANT_FIL
jg finPrintMat ;ultima fila?
cmp word[col],CANT_COL
jg nextFil ;ultima columna?
call getOffset ;obtengo desplazamiento en ebx
mov ax,[matriz+ebx] ;copio el elemento de la matriz en ax
cwde ;convierto word a doubleword (extiendo signo de ax en eax)
printElem:
push eax ;copio el elemento a imprimir en la pila
push elem ;copio la dir del string con el formato a imprimir en la pila
call _printf ;imprimo elemento
add esp,8
inc word[col] ;muevo a proxima columna
jmp verifyEnd
nextFil:
call printCRLF ;imprimo fin de linea para imrpmir sgte fila abajo
inc word[fil] ;muevo a la proxima fila
mov word[col],1 ;reinicio columna en 1
jmp verifyEnd
finPrintMat:
ret
;*************************************************************************************
;Rutina getOffset
;deja en ebx el deplazamiento del elemento situado en (fil,col)
;*************************************************************************************
getOffset:
mov ax,[fil] ;ax = fila
dec ax ;ax = fila-1
imul ax,LONG_ELEM ;ax = (fila-1) * longElem
imul ax,CANT_COL ;ax = (fila-1) * longElem * cantCol = (fila-1) * longFila
sub ebx,ebx
mov bx,[col] ;bx = (columna)
dec bx ;bx = (columna-1)
imul bx,LONG_ELEM ;bx = (columna-1) * longElem
add bx,ax ;ebx = desplazamiento
ret
;*************************************************************************************
;Rutina para imprimir fin de linea
;*************************************************************************************
printCRLF:
push crlf
call _printf
add esp,4
ret
|
/*
Problem:
https://leetcode.com/problems/implement-queue-using-stacks/
Implement a first in first out (FIFO) queue using only two stacks.
The implemented queue should support all the functions of a normal queue (push, peek, pop, and empty).
*/
#include <iostream>
#include <vector>
using namespace std;
class MyQueue {
private:
vector<int> stack;
int top;
public:
MyQueue() {
this->top = -1;
}
void push(int x) {
this->top += 1;
this->stack.push_back(x);
}
int pop() {
vector<int> tmp;
int tmpTop = this->top;
while(tmpTop >= 0) {
tmp.push_back( this->stack[tmpTop] );
this->stack.pop_back();
tmpTop--;
}
int val = tmp[this->top];
tmpTop = this->top-1;
tmp.pop_back();
this->top -= 1;
while(tmpTop >= 0) {
this->stack.push_back( tmp[tmpTop] );
tmp.pop_back();
tmpTop--;
}
return val;
}
int peek() {
vector<int> tmp;
int tmpTop = this->top;
while(tmpTop >= 0) {
tmp.push_back( this->stack[tmpTop] );
this->stack.pop_back();
tmpTop--;
}
int val = tmp[this->top];
tmpTop = this->top;
while(tmpTop >= 0) {
this->stack.push_back( tmp[tmpTop] );
tmp.pop_back();
tmpTop--;
}
return val;
}
bool empty() {
if(this->top < 0) {
return true;
}
return false;
}
};
/**
* Your MyQueue object will be instantiated and called as such:
* MyQueue* obj = new MyQueue();
* obj->push(x);
* int param_2 = obj->pop();
* int param_3 = obj->peek();
* bool param_4 = obj->empty();
*/
|
//
// Created by zhangyongcheng on 18-8-7.
//
#include "watch_event_buffer.h"
namespace sharkstore {
namespace dataserver {
namespace watch {
void printBufferValue(CEventBufferValue &val) {
FLOG_DEBUG("key:%s value:%s version:%"
PRId64,
EncodeToHexString(val.key(0)).c_str(), EncodeToHexString(val.value()).c_str(),
val.version());
}
bool operator < (const struct SGroupKey &l, const struct SGroupKey &r) {
return l.key_ < r.key_;
}
bool CEventBuffer::thread_flag_=true;
int32_t CEventBuffer::milli_timeout_ = EVENT_BUFFER_TIME_OUT;
CEventBuffer::CEventBuffer() {
mapGroupBuffer.clear();
// create_thread();
}
CEventBuffer::CEventBuffer(const int &mapSize, const int &queueSize) {
map_capacity_ = mapSize>MAX_EVENT_BUFFER_MAP_SIZE?MAX_EVENT_BUFFER_MAP_SIZE:mapSize;
queue_capacity_ = queueSize>MAX_EVENT_QUEUE_SIZE?MAX_EVENT_QUEUE_SIZE:queueSize;
map_capacity_ = map_capacity_>0?map_capacity_:DEFAULT_EVENT_BUFFER_MAP_SIZE;
queue_capacity_ = queue_capacity_>0?queue_capacity_:DEFAULT_EVENT_QUEUE_SIZE;
mapGroupBuffer.clear();
// create_thread();
}
CEventBuffer::~CEventBuffer() {
for(auto it : mapGroupBuffer) {
delete it.second;
}
loop_flag_ = false;
// clear_thread_.join();
}
BufferReturnPair CEventBuffer::loadFromBuffer(const std::string &grpKey, int64_t userVersion,
std::vector<CEventBufferValue> &result) {
std::lock_guard<std::mutex> lock(buffer_mutex_);
int32_t resultCnt{0};
BufferReturnPair retPair = std::make_pair(-1, std::make_pair(0,0));
if(isEmpty() || userVersion == 0) {
return retPair;
}
int32_t from(0), to(0);
auto it = mapGroupBuffer.find(grpKey);
if(it != mapGroupBuffer.end()) {
//to do 遍历获取版本范围内变更
resultCnt = it->second->getData(userVersion, result);
from = it->second->lowerVersion();
to = it->second->upperVersion();
}
retPair = std::make_pair(resultCnt, std::make_pair(from, to));
return retPair;
}
bool CEventBuffer::enQueue(const std::string &grpKey, const CEventBufferValue *bufferValue) {
std::lock_guard<std::mutex> lock(buffer_mutex_);
bool ret{false};
int64_t queueLength(0);
GroupKey key(grpKey);
auto it = mapGroupBuffer.find(key);
if(it == mapGroupBuffer.end()) {
//to do escasp from map
if(isFull()) {
GroupKey k(listGroupBuffer.begin()->key_, listGroupBuffer.begin()->create_time_);
listGroupBuffer.pop_front();
FLOG_INFO("buffer_map auto pop key:%s", EncodeToHexString(k.key_).c_str());
auto itMap = mapGroupBuffer.find(k);
if(itMap != mapGroupBuffer.end()) {
deQueue(itMap->second);
mapGroupBuffer.erase(itMap);
map_size_--;
FLOG_INFO("map pop success, key:%s create(ms):%" PRId64 " map-length:%" PRId32, k.key_.c_str(), k.create_time_, map_size_);
} else {
FLOG_INFO("map pop error, key:%s create(ms):%" PRId64 " map-length:%" PRId32, k.key_.c_str(), k.create_time_, map_size_);
}
}
auto grpValue = new GroupValue(queue_capacity_);
if(grpValue->enQueue(*bufferValue)) {
listGroupBuffer.push_back(key);
auto result = mapGroupBuffer.emplace(std::make_pair(key, grpValue));
if(result.second) {
ret = true;
} else {
FLOG_INFO("mapGroupBuffer emplace error, key:%s", EncodeToHexString(grpKey).c_str());
ret = false;
}
queueLength = grpValue->length();
if(ret)
map_size_++;
} else {
FLOG_WARN("map[%s]->queue is full[%" PRId32 "]", EncodeToHexString(grpKey).c_str(), queue_capacity_);
ret = false;
}
} else {
ret = it->second->enQueue(*bufferValue);
if(!ret) {
FLOG_WARN("map[%s]->queue is full..", EncodeToHexString(grpKey).c_str());
}
queueLength = it->second->length();
}
FLOG_DEBUG("capacity:%" PRId32 "-%" PRId32 " >>>emplace to queue, key:%s value:%s version:%"
PRId64 " map-length:%" PRId32 " queue-length:%" PRId64,
map_capacity_, queue_capacity_, EncodeToHexString(grpKey).c_str(), bufferValue->value().c_str(),
bufferValue->version(), map_size_, queueLength);
return ret;
}
bool CEventBuffer::deQueue(GroupValue *grpVal) {
//std::lock_guard<std::mutex> lock(buffer_mutex_);
if(grpVal != nullptr) {
grpVal->clearQueue();
delete grpVal;
}
return true;
}
}
}
} |
.data
stack : .word 0 # Puntatore all'ultimo elemento inserito nello stack
stack_n : .word 0 # Nummero di elementi attualmente nello stack
first_string: .asciiz "Ascissa: "
second_string: .asciiz "Ordinata: "
third_string: .asciiz "Angolo: "
# Nodo di esempio:
# struct{
# int x;
# int y;
# int angle;
# int *next;
# }
.text
.globl stack_pop
.globl stack_print
.globl stack_push
# Si implementi una struttura dati di tipo stack (LIFO) che permetta di salvare in memoria dinamicamente strutture del tipo:
# struct {
# int x;
# int y;
# int angle;
# int *next;
# }
#
# Si implementino in particolare le funzioni:
# stack_push(x,y,angle) che inserisca un elemento nello stack
# stack_pop() che rimuova un elemento dallo stack e lo restituisca all'utente (si restituisca 0 nel caso di stack vuoto)
# stack_print() che stampi l'intero contenuto dello stack
#
# Suggerimento: si utilizzi la syscall sbrk per l'allocazione dinamica della memoria.
stack_pop:
la $t0, stack
lw $t0, ($t0) # $t0 <-- puntatore alla cima dello stack
la $t1, stack_n
lw $t1, ($t1)
bnez $t1, first_for # if (len(stack) == 0) then return 0
sw $zero, ($t2)
sw $zero, 4($t2)
sw $zero, 8($t2)
jr $ra
# Lo stack dovrebbe essere organizzato così:
# int *next;
# int angle;
# int y;
# int x;
# E l'indirizzo di ogni elemento dovrebbe puntare a int x, quindi l'offset da usare per ottenere il puntatore
# al prossimo elemento è 12.
first_for: lw $t3, 12($t0)
beqz $t3, return
move $t0, $t3
j first_for
# Arrivato qui, ho zero in $t3 e l'indirizzo dell'ultimo elemento dello stack in $t0
return: lw $t7, ($t0) # $t7 <-- x
lw $t8, 4($t0) # $t8 <-- y
lw $t9, 8($t0) # $t9 <-- angle
# Pulisco un po' i registri
li $t0, 0
li $t1, 0
li $t2, 0
li $t3, 0
li $t4, 0
li $t5, 0
li $t6, 0
la $t0, stack
lw $t0, ($t0)
# Aggiorno stack_n
la $t1, stack_n
lw $t2, ($t1)
addi $t2, $t2, -1
sw $t2, ($t1)
li $t1, 1 # Serve per il ciclo seguente
# Devo fare in modo che adesso l'ultimo elemento abbia zero nel campo int *next: non penso possa evitare di utilizzare
# un altro ciclo. La condizione è basata su stack_n, perché non sono riuscito a fare diversamente
second_for: beq $t1, $t2, reset
beq $zero, $t2, pop_return # Se stack_n - 1 = 0, ho un unico elemento nello stack. Non serve il ciclo
lw $t3, 12($t0)
move $t0, $t3
addi $t2, $t2, -1
j second_for
# Arrivato qui, ho l'indirizzo da rimpiazzare con zero in [$t3] + 12 (ricorda l'organizzazione degli elementi)
# A meno che non abbia preso subito la branch di second_for
reset: beqz $t3, if
sw $zero, 12($t3)
pop_return: move $t2, $a0 # $t2 <-- base address dell'array in cui memorizzare valori di ritorno
sw $t7, ($t2)
sw $t8, 4($t2)
sw $t9, 8($t2)
jr $ra
# Se arrivo qui, ho fatto il pop di tutti gli elementi dello stack tranne uno. Devo aggiornare il campo *next di quello
if: sw $zero, 12($t0)
j pop_return
stack_print:
la $t0, stack
lw $t0, ($t0) # $t0 <-- puntatore alla cima dello stack
print_for: beqz $t0, print_return
lw $t1, ($t0)
lw $t2, 4($t0)
lw $t3, 8($t0)
li $v0, 56
la $a0, first_string
move $a1, $t1
syscall
la $a0, second_string
move $a1, $t2
syscall
la $a0, third_string
move $a1, $t3
syscall
# Metto qui la branch, altrimenti non mi stamperebbe l'ultimo elemento dello stack
lw $t0, 12($t0)
j print_for
print_return: jr $ra
# Input :
# a0 : x value
# a1 : y value
# a2 : angle value
# Output:
# ---------
stack_push: # Inserisce un elemento nello stack
move $t0, $a0
move $t1, $a1
move $t2, $a2
la $t8, stack
lw $t7, 0($t8)
la $t9, stack_n
li $a0, 16 # malloc(4*4 bytes)
li $v0, 9
syscall
sw $t0, 0($v0) # inizializza nuovo nodo
sw $t1, 4($v0)
sw $t2, 8($v0)
sw $t7, 12($v0) # next = *old_stack
lw $t3, 0($t9) # stack_n++
addi $t3, $t3, 1
sw $v0, 0($t8) # aggiorna lo stack pointer al nodo appena creato
sw $t3, 0($t9) # aggiorna il contatore di elementi
jr $ra # ritorna al chiamante
|
; A100504: a(n) = (4*n^3 + 6*n^2 + 8*n + 6)/3.
; 2,8,26,64,130,232,378,576,834,1160,1562,2048,2626,3304,4090,4992,6018,7176,8474,9920,11522,13288,15226,17344,19650,22152,24858,27776,30914,34280,37882,41728,45826,50184,54810,59712,64898,70376,76154,82240,88642,95368,102426,109824,117570,125672,134138,142976,152194,161800,171802,182208,193026,204264,215930,228032,240578,253576,267034,280960,295362,310248,325626,341504,357890,374792,392218,410176,428674,447720,467322,487488,508226,529544,551450,573952,597058,620776,645114,670080,695682,721928,748826,776384,804610,833512,863098,893376,924354,956040,988442,1021568,1055426,1090024,1125370,1161472,1198338,1235976,1274394,1313600
add $0,1
mul $0,2
mov $1,$0
bin $0,3
add $0,$1
|
;
; jidctfst.asm - fast integer IDCT (SSE2)
;
; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
; Copyright (C) 2016, D. R. Commander.
;
; Based on the x86 SIMD extension for IJG JPEG library
; Copyright (C) 1999-2006, MIYASAKA Masaru.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
; This file should be assembled with NASM (Netwide Assembler),
; can *not* be assembled with Microsoft's MASM or any compatible
; assembler (including Borland's Turbo Assembler).
; NASM is available from http://nasm.sourceforge.net/ or
; http://sourceforge.net/project/showfiles.php?group_id=6208
;
; This file contains a fast, not so accurate integer implementation of
; the inverse DCT (Discrete Cosine Transform). The following code is
; based directly on the IJG's original jidctfst.c; see the jidctfst.c
; for more details.
%include "jsimdext.inc"
%include "jdct.inc"
; --------------------------------------------------------------------------
%define CONST_BITS 8 ; 14 is also OK.
%define PASS1_BITS 2
%if IFAST_SCALE_BITS != PASS1_BITS
%error "'IFAST_SCALE_BITS' must be equal to 'PASS1_BITS'."
%endif
%if CONST_BITS == 8
F_1_082 equ 277 ; FIX(1.082392200)
F_1_414 equ 362 ; FIX(1.414213562)
F_1_847 equ 473 ; FIX(1.847759065)
F_2_613 equ 669 ; FIX(2.613125930)
F_1_613 equ (F_2_613 - 256) ; FIX(2.613125930) - FIX(1)
%else
; NASM cannot do compile-time arithmetic on floating-point constants.
%define DESCALE(x, n) (((x) + (1 << ((n) - 1))) >> (n))
F_1_082 equ DESCALE(1162209775, 30 - CONST_BITS) ; FIX(1.082392200)
F_1_414 equ DESCALE(1518500249, 30 - CONST_BITS) ; FIX(1.414213562)
F_1_847 equ DESCALE(1984016188, 30 - CONST_BITS) ; FIX(1.847759065)
F_2_613 equ DESCALE(2805822602, 30 - CONST_BITS) ; FIX(2.613125930)
F_1_613 equ (F_2_613 - (1 << CONST_BITS)) ; FIX(2.613125930) - FIX(1)
%endif
; --------------------------------------------------------------------------
SECTION SEG_CONST
; PRE_MULTIPLY_SCALE_BITS <= 2 (to avoid overflow)
; CONST_BITS + CONST_SHIFT + PRE_MULTIPLY_SCALE_BITS == 16 (for pmulhw)
%define PRE_MULTIPLY_SCALE_BITS 2
%define CONST_SHIFT (16 - PRE_MULTIPLY_SCALE_BITS - CONST_BITS)
alignz 32
GLOBAL_DATA(jconst_idct_ifast_sse2)
EXTN(jconst_idct_ifast_sse2):
PW_F1414 times 8 dw F_1_414 << CONST_SHIFT
PW_F1847 times 8 dw F_1_847 << CONST_SHIFT
PW_MF1613 times 8 dw -F_1_613 << CONST_SHIFT
PW_F1082 times 8 dw F_1_082 << CONST_SHIFT
PB_CENTERJSAMP times 16 db CENTERJSAMPLE
alignz 32
; --------------------------------------------------------------------------
SECTION SEG_TEXT
BITS 32
;
; Perform dequantization and inverse DCT on one block of coefficients.
;
; GLOBAL(void)
; jsimd_idct_ifast_sse2(void *dct_table, JCOEFPTR coef_block,
; JSAMPARRAY output_buf, JDIMENSION output_col)
;
%define dct_table(b) (b) + 8 ; jpeg_component_info *compptr
%define coef_block(b) (b) + 12 ; JCOEFPTR coef_block
%define output_buf(b) (b) + 16 ; JSAMPARRAY output_buf
%define output_col(b) (b) + 20 ; JDIMENSION output_col
%define original_ebp ebp + 0
%define wk(i) ebp - (WK_NUM - (i)) * SIZEOF_XMMWORD
; xmmword wk[WK_NUM]
%define WK_NUM 2
align 32
GLOBAL_FUNCTION(jsimd_idct_ifast_sse2)
EXTN(jsimd_idct_ifast_sse2):
push ebp
mov eax, esp ; eax = original ebp
sub esp, byte 4
and esp, byte (-SIZEOF_XMMWORD) ; align to 128 bits
mov [esp], eax
mov ebp, esp ; ebp = aligned ebp
lea esp, [wk(0)]
pushpic ebx
; push ecx ; unused
; push edx ; need not be preserved
push esi
push edi
get_GOT ebx ; get GOT address
; ---- Pass 1: process columns from input.
; mov eax, [original_ebp]
mov edx, POINTER [dct_table(eax)] ; quantptr
mov esi, JCOEFPTR [coef_block(eax)] ; inptr
%ifndef NO_ZERO_COLUMN_TEST_IFAST_SSE2
mov eax, DWORD [DWBLOCK(1,0,esi,SIZEOF_JCOEF)]
or eax, DWORD [DWBLOCK(2,0,esi,SIZEOF_JCOEF)]
jnz near .columnDCT
movdqa xmm0, XMMWORD [XMMBLOCK(1,0,esi,SIZEOF_JCOEF)]
movdqa xmm1, XMMWORD [XMMBLOCK(2,0,esi,SIZEOF_JCOEF)]
por xmm0, XMMWORD [XMMBLOCK(3,0,esi,SIZEOF_JCOEF)]
por xmm1, XMMWORD [XMMBLOCK(4,0,esi,SIZEOF_JCOEF)]
por xmm0, XMMWORD [XMMBLOCK(5,0,esi,SIZEOF_JCOEF)]
por xmm1, XMMWORD [XMMBLOCK(6,0,esi,SIZEOF_JCOEF)]
por xmm0, XMMWORD [XMMBLOCK(7,0,esi,SIZEOF_JCOEF)]
por xmm1, xmm0
packsswb xmm1, xmm1
packsswb xmm1, xmm1
movd eax, xmm1
test eax, eax
jnz short .columnDCT
; -- AC terms all zero
movdqa xmm0, XMMWORD [XMMBLOCK(0,0,esi,SIZEOF_JCOEF)]
pmullw xmm0, XMMWORD [XMMBLOCK(0,0,edx,SIZEOF_ISLOW_MULT_TYPE)]
movdqa xmm7, xmm0 ; xmm0=in0=(00 01 02 03 04 05 06 07)
punpcklwd xmm0, xmm0 ; xmm0=(00 00 01 01 02 02 03 03)
punpckhwd xmm7, xmm7 ; xmm7=(04 04 05 05 06 06 07 07)
pshufd xmm6, xmm0, 0x00 ; xmm6=col0=(00 00 00 00 00 00 00 00)
pshufd xmm2, xmm0, 0x55 ; xmm2=col1=(01 01 01 01 01 01 01 01)
pshufd xmm5, xmm0, 0xAA ; xmm5=col2=(02 02 02 02 02 02 02 02)
pshufd xmm0, xmm0, 0xFF ; xmm0=col3=(03 03 03 03 03 03 03 03)
pshufd xmm1, xmm7, 0x00 ; xmm1=col4=(04 04 04 04 04 04 04 04)
pshufd xmm4, xmm7, 0x55 ; xmm4=col5=(05 05 05 05 05 05 05 05)
pshufd xmm3, xmm7, 0xAA ; xmm3=col6=(06 06 06 06 06 06 06 06)
pshufd xmm7, xmm7, 0xFF ; xmm7=col7=(07 07 07 07 07 07 07 07)
movdqa XMMWORD [wk(0)], xmm2 ; wk(0)=col1
movdqa XMMWORD [wk(1)], xmm0 ; wk(1)=col3
jmp near .column_end
alignx 16, 7
%endif
.columnDCT:
; -- Even part
movdqa xmm0, XMMWORD [XMMBLOCK(0,0,esi,SIZEOF_JCOEF)]
movdqa xmm1, XMMWORD [XMMBLOCK(2,0,esi,SIZEOF_JCOEF)]
pmullw xmm0, XMMWORD [XMMBLOCK(0,0,edx,SIZEOF_IFAST_MULT_TYPE)]
pmullw xmm1, XMMWORD [XMMBLOCK(2,0,edx,SIZEOF_IFAST_MULT_TYPE)]
movdqa xmm2, XMMWORD [XMMBLOCK(4,0,esi,SIZEOF_JCOEF)]
movdqa xmm3, XMMWORD [XMMBLOCK(6,0,esi,SIZEOF_JCOEF)]
pmullw xmm2, XMMWORD [XMMBLOCK(4,0,edx,SIZEOF_IFAST_MULT_TYPE)]
pmullw xmm3, XMMWORD [XMMBLOCK(6,0,edx,SIZEOF_IFAST_MULT_TYPE)]
movdqa xmm4, xmm0
movdqa xmm5, xmm1
psubw xmm0, xmm2 ; xmm0=tmp11
psubw xmm1, xmm3
paddw xmm4, xmm2 ; xmm4=tmp10
paddw xmm5, xmm3 ; xmm5=tmp13
psllw xmm1, PRE_MULTIPLY_SCALE_BITS
pmulhw xmm1, [GOTOFF(ebx,PW_F1414)]
psubw xmm1, xmm5 ; xmm1=tmp12
movdqa xmm6, xmm4
movdqa xmm7, xmm0
psubw xmm4, xmm5 ; xmm4=tmp3
psubw xmm0, xmm1 ; xmm0=tmp2
paddw xmm6, xmm5 ; xmm6=tmp0
paddw xmm7, xmm1 ; xmm7=tmp1
movdqa XMMWORD [wk(1)], xmm4 ; wk(1)=tmp3
movdqa XMMWORD [wk(0)], xmm0 ; wk(0)=tmp2
; -- Odd part
movdqa xmm2, XMMWORD [XMMBLOCK(1,0,esi,SIZEOF_JCOEF)]
movdqa xmm3, XMMWORD [XMMBLOCK(3,0,esi,SIZEOF_JCOEF)]
pmullw xmm2, XMMWORD [XMMBLOCK(1,0,edx,SIZEOF_IFAST_MULT_TYPE)]
pmullw xmm3, XMMWORD [XMMBLOCK(3,0,edx,SIZEOF_IFAST_MULT_TYPE)]
movdqa xmm5, XMMWORD [XMMBLOCK(5,0,esi,SIZEOF_JCOEF)]
movdqa xmm1, XMMWORD [XMMBLOCK(7,0,esi,SIZEOF_JCOEF)]
pmullw xmm5, XMMWORD [XMMBLOCK(5,0,edx,SIZEOF_IFAST_MULT_TYPE)]
pmullw xmm1, XMMWORD [XMMBLOCK(7,0,edx,SIZEOF_IFAST_MULT_TYPE)]
movdqa xmm4, xmm2
movdqa xmm0, xmm5
psubw xmm2, xmm1 ; xmm2=z12
psubw xmm5, xmm3 ; xmm5=z10
paddw xmm4, xmm1 ; xmm4=z11
paddw xmm0, xmm3 ; xmm0=z13
movdqa xmm1, xmm5 ; xmm1=z10(unscaled)
psllw xmm2, PRE_MULTIPLY_SCALE_BITS
psllw xmm5, PRE_MULTIPLY_SCALE_BITS
movdqa xmm3, xmm4
psubw xmm4, xmm0
paddw xmm3, xmm0 ; xmm3=tmp7
psllw xmm4, PRE_MULTIPLY_SCALE_BITS
pmulhw xmm4, [GOTOFF(ebx,PW_F1414)] ; xmm4=tmp11
; To avoid overflow...
;
; (Original)
; tmp12 = -2.613125930 * z10 + z5;
;
; (This implementation)
; tmp12 = (-1.613125930 - 1) * z10 + z5;
; = -1.613125930 * z10 - z10 + z5;
movdqa xmm0, xmm5
paddw xmm5, xmm2
pmulhw xmm5, [GOTOFF(ebx,PW_F1847)] ; xmm5=z5
pmulhw xmm0, [GOTOFF(ebx,PW_MF1613)]
pmulhw xmm2, [GOTOFF(ebx,PW_F1082)]
psubw xmm0, xmm1
psubw xmm2, xmm5 ; xmm2=tmp10
paddw xmm0, xmm5 ; xmm0=tmp12
; -- Final output stage
psubw xmm0, xmm3 ; xmm0=tmp6
movdqa xmm1, xmm6
movdqa xmm5, xmm7
paddw xmm6, xmm3 ; xmm6=data0=(00 01 02 03 04 05 06 07)
paddw xmm7, xmm0 ; xmm7=data1=(10 11 12 13 14 15 16 17)
psubw xmm1, xmm3 ; xmm1=data7=(70 71 72 73 74 75 76 77)
psubw xmm5, xmm0 ; xmm5=data6=(60 61 62 63 64 65 66 67)
psubw xmm4, xmm0 ; xmm4=tmp5
movdqa xmm3, xmm6 ; transpose coefficients(phase 1)
punpcklwd xmm6, xmm7 ; xmm6=(00 10 01 11 02 12 03 13)
punpckhwd xmm3, xmm7 ; xmm3=(04 14 05 15 06 16 07 17)
movdqa xmm0, xmm5 ; transpose coefficients(phase 1)
punpcklwd xmm5, xmm1 ; xmm5=(60 70 61 71 62 72 63 73)
punpckhwd xmm0, xmm1 ; xmm0=(64 74 65 75 66 76 67 77)
movdqa xmm7, XMMWORD [wk(0)] ; xmm7=tmp2
movdqa xmm1, XMMWORD [wk(1)] ; xmm1=tmp3
movdqa XMMWORD [wk(0)], xmm5 ; wk(0)=(60 70 61 71 62 72 63 73)
movdqa XMMWORD [wk(1)], xmm0 ; wk(1)=(64 74 65 75 66 76 67 77)
paddw xmm2, xmm4 ; xmm2=tmp4
movdqa xmm5, xmm7
movdqa xmm0, xmm1
paddw xmm7, xmm4 ; xmm7=data2=(20 21 22 23 24 25 26 27)
paddw xmm1, xmm2 ; xmm1=data4=(40 41 42 43 44 45 46 47)
psubw xmm5, xmm4 ; xmm5=data5=(50 51 52 53 54 55 56 57)
psubw xmm0, xmm2 ; xmm0=data3=(30 31 32 33 34 35 36 37)
movdqa xmm4, xmm7 ; transpose coefficients(phase 1)
punpcklwd xmm7, xmm0 ; xmm7=(20 30 21 31 22 32 23 33)
punpckhwd xmm4, xmm0 ; xmm4=(24 34 25 35 26 36 27 37)
movdqa xmm2, xmm1 ; transpose coefficients(phase 1)
punpcklwd xmm1, xmm5 ; xmm1=(40 50 41 51 42 52 43 53)
punpckhwd xmm2, xmm5 ; xmm2=(44 54 45 55 46 56 47 57)
movdqa xmm0, xmm3 ; transpose coefficients(phase 2)
punpckldq xmm3, xmm4 ; xmm3=(04 14 24 34 05 15 25 35)
punpckhdq xmm0, xmm4 ; xmm0=(06 16 26 36 07 17 27 37)
movdqa xmm5, xmm6 ; transpose coefficients(phase 2)
punpckldq xmm6, xmm7 ; xmm6=(00 10 20 30 01 11 21 31)
punpckhdq xmm5, xmm7 ; xmm5=(02 12 22 32 03 13 23 33)
movdqa xmm4, XMMWORD [wk(0)] ; xmm4=(60 70 61 71 62 72 63 73)
movdqa xmm7, XMMWORD [wk(1)] ; xmm7=(64 74 65 75 66 76 67 77)
movdqa XMMWORD [wk(0)], xmm3 ; wk(0)=(04 14 24 34 05 15 25 35)
movdqa XMMWORD [wk(1)], xmm0 ; wk(1)=(06 16 26 36 07 17 27 37)
movdqa xmm3, xmm1 ; transpose coefficients(phase 2)
punpckldq xmm1, xmm4 ; xmm1=(40 50 60 70 41 51 61 71)
punpckhdq xmm3, xmm4 ; xmm3=(42 52 62 72 43 53 63 73)
movdqa xmm0, xmm2 ; transpose coefficients(phase 2)
punpckldq xmm2, xmm7 ; xmm2=(44 54 64 74 45 55 65 75)
punpckhdq xmm0, xmm7 ; xmm0=(46 56 66 76 47 57 67 77)
movdqa xmm4, xmm6 ; transpose coefficients(phase 3)
punpcklqdq xmm6, xmm1 ; xmm6=col0=(00 10 20 30 40 50 60 70)
punpckhqdq xmm4, xmm1 ; xmm4=col1=(01 11 21 31 41 51 61 71)
movdqa xmm7, xmm5 ; transpose coefficients(phase 3)
punpcklqdq xmm5, xmm3 ; xmm5=col2=(02 12 22 32 42 52 62 72)
punpckhqdq xmm7, xmm3 ; xmm7=col3=(03 13 23 33 43 53 63 73)
movdqa xmm1, XMMWORD [wk(0)] ; xmm1=(04 14 24 34 05 15 25 35)
movdqa xmm3, XMMWORD [wk(1)] ; xmm3=(06 16 26 36 07 17 27 37)
movdqa XMMWORD [wk(0)], xmm4 ; wk(0)=col1
movdqa XMMWORD [wk(1)], xmm7 ; wk(1)=col3
movdqa xmm4, xmm1 ; transpose coefficients(phase 3)
punpcklqdq xmm1, xmm2 ; xmm1=col4=(04 14 24 34 44 54 64 74)
punpckhqdq xmm4, xmm2 ; xmm4=col5=(05 15 25 35 45 55 65 75)
movdqa xmm7, xmm3 ; transpose coefficients(phase 3)
punpcklqdq xmm3, xmm0 ; xmm3=col6=(06 16 26 36 46 56 66 76)
punpckhqdq xmm7, xmm0 ; xmm7=col7=(07 17 27 37 47 57 67 77)
.column_end:
; -- Prefetch the next coefficient block
prefetchnta [esi + DCTSIZE2*SIZEOF_JCOEF + 0*32]
prefetchnta [esi + DCTSIZE2*SIZEOF_JCOEF + 1*32]
prefetchnta [esi + DCTSIZE2*SIZEOF_JCOEF + 2*32]
prefetchnta [esi + DCTSIZE2*SIZEOF_JCOEF + 3*32]
; ---- Pass 2: process rows from work array, store into output array.
mov eax, [original_ebp]
mov edi, JSAMPARRAY [output_buf(eax)] ; (JSAMPROW *)
mov eax, JDIMENSION [output_col(eax)]
; -- Even part
; xmm6=col0, xmm5=col2, xmm1=col4, xmm3=col6
movdqa xmm2, xmm6
movdqa xmm0, xmm5
psubw xmm6, xmm1 ; xmm6=tmp11
psubw xmm5, xmm3
paddw xmm2, xmm1 ; xmm2=tmp10
paddw xmm0, xmm3 ; xmm0=tmp13
psllw xmm5, PRE_MULTIPLY_SCALE_BITS
pmulhw xmm5, [GOTOFF(ebx,PW_F1414)]
psubw xmm5, xmm0 ; xmm5=tmp12
movdqa xmm1, xmm2
movdqa xmm3, xmm6
psubw xmm2, xmm0 ; xmm2=tmp3
psubw xmm6, xmm5 ; xmm6=tmp2
paddw xmm1, xmm0 ; xmm1=tmp0
paddw xmm3, xmm5 ; xmm3=tmp1
movdqa xmm0, XMMWORD [wk(0)] ; xmm0=col1
movdqa xmm5, XMMWORD [wk(1)] ; xmm5=col3
movdqa XMMWORD [wk(0)], xmm2 ; wk(0)=tmp3
movdqa XMMWORD [wk(1)], xmm6 ; wk(1)=tmp2
; -- Odd part
; xmm0=col1, xmm5=col3, xmm4=col5, xmm7=col7
movdqa xmm2, xmm0
movdqa xmm6, xmm4
psubw xmm0, xmm7 ; xmm0=z12
psubw xmm4, xmm5 ; xmm4=z10
paddw xmm2, xmm7 ; xmm2=z11
paddw xmm6, xmm5 ; xmm6=z13
movdqa xmm7, xmm4 ; xmm7=z10(unscaled)
psllw xmm0, PRE_MULTIPLY_SCALE_BITS
psllw xmm4, PRE_MULTIPLY_SCALE_BITS
movdqa xmm5, xmm2
psubw xmm2, xmm6
paddw xmm5, xmm6 ; xmm5=tmp7
psllw xmm2, PRE_MULTIPLY_SCALE_BITS
pmulhw xmm2, [GOTOFF(ebx,PW_F1414)] ; xmm2=tmp11
; To avoid overflow...
;
; (Original)
; tmp12 = -2.613125930 * z10 + z5;
;
; (This implementation)
; tmp12 = (-1.613125930 - 1) * z10 + z5;
; = -1.613125930 * z10 - z10 + z5;
movdqa xmm6, xmm4
paddw xmm4, xmm0
pmulhw xmm4, [GOTOFF(ebx,PW_F1847)] ; xmm4=z5
pmulhw xmm6, [GOTOFF(ebx,PW_MF1613)]
pmulhw xmm0, [GOTOFF(ebx,PW_F1082)]
psubw xmm6, xmm7
psubw xmm0, xmm4 ; xmm0=tmp10
paddw xmm6, xmm4 ; xmm6=tmp12
; -- Final output stage
psubw xmm6, xmm5 ; xmm6=tmp6
movdqa xmm7, xmm1
movdqa xmm4, xmm3
paddw xmm1, xmm5 ; xmm1=data0=(00 10 20 30 40 50 60 70)
paddw xmm3, xmm6 ; xmm3=data1=(01 11 21 31 41 51 61 71)
psraw xmm1, (PASS1_BITS+3) ; descale
psraw xmm3, (PASS1_BITS+3) ; descale
psubw xmm7, xmm5 ; xmm7=data7=(07 17 27 37 47 57 67 77)
psubw xmm4, xmm6 ; xmm4=data6=(06 16 26 36 46 56 66 76)
psraw xmm7, (PASS1_BITS+3) ; descale
psraw xmm4, (PASS1_BITS+3) ; descale
psubw xmm2, xmm6 ; xmm2=tmp5
packsswb xmm1, xmm4 ; xmm1=(00 10 20 30 40 50 60 70 06 16 26 36 46 56 66 76)
packsswb xmm3, xmm7 ; xmm3=(01 11 21 31 41 51 61 71 07 17 27 37 47 57 67 77)
movdqa xmm5, XMMWORD [wk(1)] ; xmm5=tmp2
movdqa xmm6, XMMWORD [wk(0)] ; xmm6=tmp3
paddw xmm0, xmm2 ; xmm0=tmp4
movdqa xmm4, xmm5
movdqa xmm7, xmm6
paddw xmm5, xmm2 ; xmm5=data2=(02 12 22 32 42 52 62 72)
paddw xmm6, xmm0 ; xmm6=data4=(04 14 24 34 44 54 64 74)
psraw xmm5, (PASS1_BITS+3) ; descale
psraw xmm6, (PASS1_BITS+3) ; descale
psubw xmm4, xmm2 ; xmm4=data5=(05 15 25 35 45 55 65 75)
psubw xmm7, xmm0 ; xmm7=data3=(03 13 23 33 43 53 63 73)
psraw xmm4, (PASS1_BITS+3) ; descale
psraw xmm7, (PASS1_BITS+3) ; descale
movdqa xmm2, [GOTOFF(ebx,PB_CENTERJSAMP)] ; xmm2=[PB_CENTERJSAMP]
packsswb xmm5, xmm6 ; xmm5=(02 12 22 32 42 52 62 72 04 14 24 34 44 54 64 74)
packsswb xmm7, xmm4 ; xmm7=(03 13 23 33 43 53 63 73 05 15 25 35 45 55 65 75)
paddb xmm1, xmm2
paddb xmm3, xmm2
paddb xmm5, xmm2
paddb xmm7, xmm2
movdqa xmm0, xmm1 ; transpose coefficients(phase 1)
punpcklbw xmm1, xmm3 ; xmm1=(00 01 10 11 20 21 30 31 40 41 50 51 60 61 70 71)
punpckhbw xmm0, xmm3 ; xmm0=(06 07 16 17 26 27 36 37 46 47 56 57 66 67 76 77)
movdqa xmm6, xmm5 ; transpose coefficients(phase 1)
punpcklbw xmm5, xmm7 ; xmm5=(02 03 12 13 22 23 32 33 42 43 52 53 62 63 72 73)
punpckhbw xmm6, xmm7 ; xmm6=(04 05 14 15 24 25 34 35 44 45 54 55 64 65 74 75)
movdqa xmm4, xmm1 ; transpose coefficients(phase 2)
punpcklwd xmm1, xmm5 ; xmm1=(00 01 02 03 10 11 12 13 20 21 22 23 30 31 32 33)
punpckhwd xmm4, xmm5 ; xmm4=(40 41 42 43 50 51 52 53 60 61 62 63 70 71 72 73)
movdqa xmm2, xmm6 ; transpose coefficients(phase 2)
punpcklwd xmm6, xmm0 ; xmm6=(04 05 06 07 14 15 16 17 24 25 26 27 34 35 36 37)
punpckhwd xmm2, xmm0 ; xmm2=(44 45 46 47 54 55 56 57 64 65 66 67 74 75 76 77)
movdqa xmm3, xmm1 ; transpose coefficients(phase 3)
punpckldq xmm1, xmm6 ; xmm1=(00 01 02 03 04 05 06 07 10 11 12 13 14 15 16 17)
punpckhdq xmm3, xmm6 ; xmm3=(20 21 22 23 24 25 26 27 30 31 32 33 34 35 36 37)
movdqa xmm7, xmm4 ; transpose coefficients(phase 3)
punpckldq xmm4, xmm2 ; xmm4=(40 41 42 43 44 45 46 47 50 51 52 53 54 55 56 57)
punpckhdq xmm7, xmm2 ; xmm7=(60 61 62 63 64 65 66 67 70 71 72 73 74 75 76 77)
pshufd xmm5, xmm1, 0x4E ; xmm5=(10 11 12 13 14 15 16 17 00 01 02 03 04 05 06 07)
pshufd xmm0, xmm3, 0x4E ; xmm0=(30 31 32 33 34 35 36 37 20 21 22 23 24 25 26 27)
pshufd xmm6, xmm4, 0x4E ; xmm6=(50 51 52 53 54 55 56 57 40 41 42 43 44 45 46 47)
pshufd xmm2, xmm7, 0x4E ; xmm2=(70 71 72 73 74 75 76 77 60 61 62 63 64 65 66 67)
mov edx, JSAMPROW [edi+0*SIZEOF_JSAMPROW]
mov esi, JSAMPROW [edi+2*SIZEOF_JSAMPROW]
movq XMM_MMWORD [edx+eax*SIZEOF_JSAMPLE], xmm1
movq XMM_MMWORD [esi+eax*SIZEOF_JSAMPLE], xmm3
mov edx, JSAMPROW [edi+4*SIZEOF_JSAMPROW]
mov esi, JSAMPROW [edi+6*SIZEOF_JSAMPROW]
movq XMM_MMWORD [edx+eax*SIZEOF_JSAMPLE], xmm4
movq XMM_MMWORD [esi+eax*SIZEOF_JSAMPLE], xmm7
mov edx, JSAMPROW [edi+1*SIZEOF_JSAMPROW]
mov esi, JSAMPROW [edi+3*SIZEOF_JSAMPROW]
movq XMM_MMWORD [edx+eax*SIZEOF_JSAMPLE], xmm5
movq XMM_MMWORD [esi+eax*SIZEOF_JSAMPLE], xmm0
mov edx, JSAMPROW [edi+5*SIZEOF_JSAMPROW]
mov esi, JSAMPROW [edi+7*SIZEOF_JSAMPROW]
movq XMM_MMWORD [edx+eax*SIZEOF_JSAMPLE], xmm6
movq XMM_MMWORD [esi+eax*SIZEOF_JSAMPLE], xmm2
pop edi
pop esi
; pop edx ; need not be preserved
; pop ecx ; unused
poppic ebx
mov esp, ebp ; esp <- aligned ebp
pop esp ; esp <- original ebp
pop ebp
ret
; For some reason, the OS X linker does not honor the request to align the
; segment unless we do this.
align 32
|
info: scarlet.asm, Anonymous
main:
// select a random direction and distance to move
rand [dir], 4
rand [count], 5 //edit
add [count], 1 //edit
loop:
// check if I'm top of food and eat if so
sense r2
jns noFood
eat
noFood:
// see if we're over a collection point and
// release some energy
energy r9
div r9, 2
cmp r9, 2000
jl notEnufEnergy
sense r5
cmp r5, 0xFFFF // are we on a colleciton point?
jne notEnufEnergy
getxy r12, r13 // remember the location of this collection point.
sub r9, 6
release r9 //edit // drain my energy by 500, but get 500 points, assuming
// that we're releasing on a collection point
notEnufEnergy:
// move me
cmp [count], 0 // moved enough in this direction; try a new one
je newDir
travel [dir]
jns sayHello // bumped into another org or the wall
sub [count], 1
jmp loop
sayHello: // (appears to) corrupts the memory of the drones
mov r0, [dir]
poke [dir], 10
jns newDir
charge [dir], 100
//poke [dir], 40
//poke [dir], 50
//poke [dir], 60
//poke [dir], 70
//poke [dir], 80
//poke [dir], 90
//poke [dir], 100
newDir:
rand [dir], 4 // select a new direction
jmp move
move:
// select a random direction and distance to move
rand [count], 5 //edit
add [count], 1 //edit
jmp loop
dir:
data { 0 } // our initial direction
count: // our initial count of how far to move in the cur dir
data { 0 }
|
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "filestorhandlerimpl.h"
#include "filestormetrics.h"
#include <vespa/storageapi/message/bucketsplitting.h>
#include <vespa/storageapi/message/persistence.h>
#include <vespa/storageapi/message/removelocation.h>
#include <vespa/storage/bucketdb/storbucketdb.h>
#include <vespa/storage/common/bucketmessages.h>
#include <vespa/storage/common/statusmessages.h>
#include <vespa/storage/common/bucketoperationlogger.h>
#include <vespa/storage/common/messagebucket.h>
#include <vespa/storage/persistence/messages.h>
#include <vespa/storageapi/message/stat.h>
#include <vespa/vespalib/stllike/hash_map.hpp>
#include <vespa/vespalib/util/exceptions.h>
#include <vespa/log/log.h>
LOG_SETUP(".persistence.filestor.handler.impl");
using document::BucketSpace;
namespace storage {
namespace {
uint32_t merge_soft_limit_from_thread_count(uint32_t num_threads) noexcept {
// Rationale: to avoid starving client ops we want to ensure that not all persistence
// threads can be blocked by processing merges all at the same time. We therefore allocate
// half of the threads to non-merge operations.
// This a _soft_ limit since the current operation locking design means there is a small
// window of time between when the limit is checked and when its updated. There are no
// correctness violations as a consequence of this, but non-merge liveness may be impacted.
// There must always be at least 1 thread that can process merges, or the system would stall.
return std::max(1u, num_threads / 2);
}
}
FileStorHandlerImpl::FileStorHandlerImpl(uint32_t numThreads, uint32_t numStripes, MessageSender& sender,
FileStorMetrics& metrics,
[[maybe_unused]] const spi::PartitionStateList& partitions,
ServiceLayerComponentRegister& compReg)
: _component(compReg, "filestorhandlerimpl"),
_diskInfo(),
_messageSender(sender),
_bucketIdFactory(_component.getBucketIdFactory()),
_getNextMessageTimeout(100),
_activeMergesSoftLimit(merge_soft_limit_from_thread_count(numThreads)),
_activeMerges(0),
_paused(false)
{
_diskInfo.reserve(_component.getDiskCount());
for (uint32_t i(0); i < _component.getDiskCount(); i++) {
_diskInfo.emplace_back(*this, sender, numStripes);
}
for (uint32_t i=0; i<_diskInfo.size(); ++i) {
_diskInfo[i].metrics = metrics.disks[i].get();
assert(_diskInfo[i].metrics != 0);
uint32_t j(0);
for (Stripe & stripe : _diskInfo[i].getStripes()) {
stripe.setMetrics(metrics.disks[i]->stripes[j++].get());
}
}
if (_diskInfo.size() == 0) {
throw vespalib::IllegalArgumentException("No disks configured", VESPA_STRLOC);
}
// Add update hook, so we will get callbacks each 5 seconds to update
// metrics.
_component.registerMetricUpdateHook(*this, framework::SecondTime(5));
}
FileStorHandlerImpl::~FileStorHandlerImpl() = default;
void
FileStorHandlerImpl::addMergeStatus(const document::Bucket& bucket, MergeStatus::SP status)
{
vespalib::LockGuard mlock(_mergeStatesLock);
if (_mergeStates.find(bucket) != _mergeStates.end()) {;
LOG(warning, "A merge status already existed for %s. Overwriting it.", bucket.toString().c_str());
}
_mergeStates[bucket] = status;
}
MergeStatus&
FileStorHandlerImpl::editMergeStatus(const document::Bucket& bucket)
{
vespalib::LockGuard mlock(_mergeStatesLock);
MergeStatus::SP status = _mergeStates[bucket];
if (status.get() == 0) {
throw vespalib::IllegalStateException("No merge state exist for " + bucket.toString(), VESPA_STRLOC);
}
return *status;
}
bool
FileStorHandlerImpl::isMerging(const document::Bucket& bucket) const
{
vespalib::LockGuard mlock(_mergeStatesLock);
return (_mergeStates.find(bucket) != _mergeStates.end());
}
uint32_t
FileStorHandlerImpl::getNumActiveMerges() const
{
vespalib::LockGuard mlock(_mergeStatesLock);
return _mergeStates.size();
}
void
FileStorHandlerImpl::clearMergeStatus(const document::Bucket& bucket, const api::ReturnCode* code)
{
vespalib::LockGuard mlock(_mergeStatesLock);
auto it = _mergeStates.find(bucket);
if (it == _mergeStates.end()) {
if (code != 0) {
LOG(debug, "Merge state not present at the time of clear. "
"Could not fail merge of bucket %s with code %s.",
bucket.toString().c_str(), code->toString().c_str());
} else {
LOG(debug, "No merge state to clear for bucket %s.",
bucket.toString().c_str());
}
return;
}
if (code != 0) {
MergeStatus::SP statusPtr(it->second);
assert(statusPtr.get());
MergeStatus& status(*statusPtr);
if (status.reply.get()) {
status.reply->setResult(*code);
LOG(debug, "Aborting merge. Replying merge of %s with code %s.",
bucket.toString().c_str(), code->toString().c_str());
_messageSender.sendReply(status.reply);
}
if (status.pendingGetDiff.get()) {
status.pendingGetDiff->setResult(*code);
LOG(debug, "Aborting merge. Replying getdiff of %s with code %s.",
bucket.toString().c_str(), code->toString().c_str());
_messageSender.sendReply(status.pendingGetDiff);
}
if (status.pendingApplyDiff.get()) {
status.pendingApplyDiff->setResult(*code);
LOG(debug, "Aborting merge. Replying applydiff of %s with code %s.",
bucket.toString().c_str(), code->toString().c_str());
_messageSender.sendReply(status.pendingApplyDiff);
}
}
_mergeStates.erase(bucket);
}
void
FileStorHandlerImpl::flush(bool killPendingMerges)
{
for (uint32_t i=0; i<_diskInfo.size(); ++i) {
LOG(debug, "Wait until queues and bucket locks released for disk '%d'", i);
_diskInfo[i].flush();
LOG(debug, "All queues and bucket locks released for disk '%d'", i);
}
if (killPendingMerges) {
api::ReturnCode code(api::ReturnCode::ABORTED, "Storage node is shutting down");
for (auto & entry : _mergeStates)
{
MergeStatus& s(*entry.second);
if (s.pendingGetDiff.get() != 0) {
s.pendingGetDiff->setResult(code);
_messageSender.sendReply(s.pendingGetDiff);
}
if (s.pendingApplyDiff.get() != 0) {
s.pendingApplyDiff->setResult(code);
_messageSender.sendReply(s.pendingApplyDiff);
}
if (s.reply.get() != 0) {
s.reply->setResult(code);
_messageSender.sendReply(s.reply);
}
}
_mergeStates.clear();
}
}
void
FileStorHandlerImpl::reply(api::StorageMessage& msg, DiskState state) const
{
if (!msg.getType().isReply()) {
std::shared_ptr<api::StorageReply> rep = static_cast<api::StorageCommand&>(msg).makeReply();
if (state == FileStorHandler::DISABLED) {
rep->setResult(api::ReturnCode(api::ReturnCode::DISK_FAILURE, "Disk disabled"));
} else {
rep->setResult(api::ReturnCode(api::ReturnCode::ABORTED, "Shutting down storage node."));
}
_messageSender.sendReply(rep);
}
}
void
FileStorHandlerImpl::setDiskState(uint16_t diskId, DiskState state)
{
Disk& disk = _diskInfo[diskId];
// Mark disk closed
disk.setState(state);
if (state != FileStorHandler::AVAILABLE) {
disk.flush();
}
}
FileStorHandler::DiskState
FileStorHandlerImpl::getDiskState(uint16_t disk) const
{
return _diskInfo[disk].getState();
}
void
FileStorHandlerImpl::close()
{
for (uint32_t i=0; i<_diskInfo.size(); ++i) {
if (getDiskState(i) == FileStorHandler::AVAILABLE) {
LOG(debug, "AVAILABLE -> CLOSED disk[%d]", i);
setDiskState(i, FileStorHandler::CLOSED);
}
LOG(debug, "Closing disk[%d]", i);
_diskInfo[i].broadcast();
LOG(debug, "Closed disk[%d]", i);
}
}
uint32_t
FileStorHandlerImpl::getQueueSize() const
{
size_t count = 0;
for (const auto & disk : _diskInfo) {
count += disk.getQueueSize();
}
return count;
}
bool
FileStorHandlerImpl::schedule(const std::shared_ptr<api::StorageMessage>& msg, uint16_t diskId)
{
assert(diskId < _diskInfo.size());
Disk& disk(_diskInfo[diskId]);
return disk.schedule(msg);
}
bool
FileStorHandlerImpl::messageMayBeAborted(const api::StorageMessage& msg)
{
if (msg.getType().isReply()) {
return false;
}
// Create/DeleteBucket have already updated the bucket database before
// being scheduled and must be allowed through to avoid getting out of
// sync between the service layer and the provider.
switch (msg.getType().getId()) {
case api::MessageType::PUT_ID:
case api::MessageType::REMOVE_ID:
case api::MessageType::REVERT_ID:
case api::MessageType::MERGEBUCKET_ID:
case api::MessageType::GETBUCKETDIFF_ID:
case api::MessageType::APPLYBUCKETDIFF_ID:
case api::MessageType::SPLITBUCKET_ID:
case api::MessageType::JOINBUCKETS_ID:
case api::MessageType::UPDATE_ID:
case api::MessageType::REMOVELOCATION_ID:
case api::MessageType::SETBUCKETSTATE_ID:
return true;
default:
return false;
}
}
void
FileStorHandlerImpl::abortQueuedCommandsForBuckets(Disk& disk, const AbortBucketOperationsCommand& cmd)
{
api::ReturnCode abortedCode(api::ReturnCode::ABORTED,
"Sending distributor no longer owns bucket operation was bound to, "
"or storage node went down");
auto aborted = disk.abort(cmd);
for (auto & msgReply : aborted) {
msgReply->setResult(abortedCode);
_messageSender.sendReply(msgReply);
}
}
void
FileStorHandlerImpl::abortQueuedOperations(const AbortBucketOperationsCommand& cmd)
{
// Do queue clearing and active operation waiting in two passes
// to allow disk threads to drain running operations in parallel.
for (Disk & disk : _diskInfo) {
abortQueuedCommandsForBuckets(disk, cmd);
}
for (Disk & disk : _diskInfo) {
disk.waitInactive(cmd);
}
}
void
FileStorHandlerImpl::updateMetrics(const MetricLockGuard &)
{
for (Disk & disk : _diskInfo) {
vespalib::MonitorGuard lockGuard(_mergeStatesLock);
disk.metrics->pendingMerges.addValue(_mergeStates.size());
disk.metrics->queueSize.addValue(disk.getQueueSize());
for (auto & entry : disk.metrics->averageQueueWaitingTime.getMetricMap()) {
metrics::LoadType loadType(entry.first, "ignored");
for (const auto & stripe : disk.metrics->stripes) {
const auto & m = stripe->averageQueueWaitingTime[loadType];
entry.second->addTotalValueWithCount(m.getTotal(), m.getCount());
}
}
}
}
uint32_t
FileStorHandlerImpl::getNextStripeId(uint32_t disk) {
return _diskInfo[disk].getNextStripeId();
}
FileStorHandler::LockedMessage &
FileStorHandlerImpl::getNextMessage(uint16_t diskId, uint32_t stripeId, FileStorHandler::LockedMessage& lck)
{
document::Bucket bucket(lck.first->getBucket());
LOG(spam, "Disk %d retrieving message for buffered bucket %s", diskId, bucket.getBucketId().toString().c_str());
assert(diskId < _diskInfo.size());
Disk& disk(_diskInfo[diskId]);
if (disk.isClosed()) {
lck.second.reset();
return lck;
}
return disk.getNextMessage(stripeId, lck);
}
bool
FileStorHandlerImpl::tryHandlePause(uint16_t disk) const
{
if (isPaused()) {
// Wait a single time to see if filestor gets unpaused.
if (!_diskInfo[disk].isClosed()) {
vespalib::MonitorGuard g(_pauseMonitor);
g.wait(100);
}
return !isPaused();
}
return true;
}
bool
FileStorHandlerImpl::messageTimedOutInQueue(const api::StorageMessage& msg, vespalib::duration waitTime)
{
if (msg.getType().isReply()) {
return false; // Replies must always be processed and cannot time out.
}
return (waitTime >= static_cast<const api::StorageCommand&>(msg).getTimeout());
}
std::unique_ptr<api::StorageReply>
FileStorHandlerImpl::makeQueueTimeoutReply(api::StorageMessage& msg)
{
assert(!msg.getType().isReply());
std::unique_ptr<api::StorageReply> msgReply = static_cast<api::StorageCommand&>(msg).makeReply();
msgReply->setResult(api::ReturnCode(api::ReturnCode::TIMEOUT, "Message waited too long in storage queue"));
return msgReply;
}
FileStorHandler::LockedMessage
FileStorHandlerImpl::getNextMessage(uint16_t disk, uint32_t stripeId)
{
assert(disk < _diskInfo.size());
if (!tryHandlePause(disk)) {
return {}; // Still paused, return to allow tick.
}
return _diskInfo[disk].getNextMessage(stripeId, _getNextMessageTimeout);
}
std::shared_ptr<FileStorHandler::BucketLockInterface>
FileStorHandlerImpl::Stripe::lock(const document::Bucket &bucket, api::LockingRequirements lockReq) {
vespalib::MonitorGuard guard(_lock);
while (isLocked(guard, bucket, lockReq)) {
LOG(spam, "Contending for filestor lock for %s with %s access",
bucket.getBucketId().toString().c_str(), api::to_string(lockReq));
guard.wait(100);
}
auto locker = std::make_shared<BucketLock>(guard, *this, bucket, 255, api::MessageType::INTERNAL_ID, 0, lockReq);
guard.broadcast();
return locker;
}
namespace {
struct MultiLockGuard {
std::map<uint16_t, vespalib::Monitor*> monitors;
std::vector<std::shared_ptr<vespalib::MonitorGuard>> guards;
MultiLockGuard() = default;
void addLock(vespalib::Monitor& monitor, uint16_t index) {
monitors[index] = &monitor;
}
void lock() {
for (auto & entry : monitors) {
guards.push_back(std::make_shared<vespalib::MonitorGuard>(*entry.second));
}
}
};
}
namespace {
document::DocumentId getDocId(const api::StorageMessage& msg) {
switch (msg.getType().getId()) {
case api::MessageType::GET_ID:
return static_cast<const api::GetCommand&>(msg).getDocumentId();
break;
case api::MessageType::PUT_ID:
return static_cast<const api::PutCommand&>(msg).getDocumentId();
break;
case api::MessageType::UPDATE_ID:
return static_cast<const api::UpdateCommand&>(msg).getDocumentId();
break;
case api::MessageType::REMOVE_ID:
return static_cast<const api::RemoveCommand&>(msg).getDocumentId();
break;
default:
LOG_ABORT("should not be reached");
}
}
uint32_t findCommonBits(document::BucketId a, document::BucketId b) {
if (a.getUsedBits() > b.getUsedBits()) {
a.setUsedBits(b.getUsedBits());
} else {
b.setUsedBits(a.getUsedBits());
}
for (uint32_t i=a.getUsedBits() - 1; i>0; --i) {
if (a == b) return i + 1;
a.setUsedBits(i);
b.setUsedBits(i);
}
return (a == b ? 1 : 0);
}
}
int
FileStorHandlerImpl::calculateTargetBasedOnDocId(const api::StorageMessage& msg, std::vector<RemapInfo*>& targets)
{
document::DocumentId id(getDocId(msg));
document::Bucket bucket(msg.getBucket().getBucketSpace(), _bucketIdFactory.getBucketId(id));
for (uint32_t i = 0; i < targets.size(); i++) {
if (targets[i]->bucket.getBucketId().getRawId() != 0 &&
targets[i]->bucket.getBucketSpace() == bucket.getBucketSpace() &&
targets[i]->bucket.getBucketId().contains(bucket.getBucketId())) {
return i;
}
}
return -1;
}
namespace {
const char *
splitOrJoin(FileStorHandlerImpl::Operation op) {
return (op == FileStorHandlerImpl::Operation::SPLIT) ? "Bucket was just split" : "Bucket was just joined";
}
}
document::Bucket
FileStorHandlerImpl::remapMessage(api::StorageMessage& msg, const document::Bucket& source, Operation op,
std::vector<RemapInfo*>& targets, uint16_t& targetDisk, api::ReturnCode& returnCode)
{
document::Bucket newBucket = source;
switch (msg.getType().getId()) {
case api::MessageType::GET_ID:
case api::MessageType::PUT_ID:
case api::MessageType::UPDATE_ID:
case api::MessageType::REMOVE_ID:
// Move to correct queue
{
api::BucketCommand& cmd(static_cast<api::BucketCommand&>(msg));
if (cmd.getBucket() == source) {
if (op == SPLIT) {
int idx = calculateTargetBasedOnDocId(msg, targets);
if (idx > -1) {
cmd.remapBucketId(targets[idx]->bucket.getBucketId());
targets[idx]->foundInQueue = true;
targetDisk = targets[idx]->diskIndex;
#if defined(ENABLE_BUCKET_OPERATION_LOGGING)
{
vespalib::string desc = vespalib::make_string(
"Remapping %s from %s to %s, targetDisk = %u",
cmd.toString().c_str(), source.toString().c_str(),
targets[idx]->bid.toString().c_str(), targetDisk);
LOG_BUCKET_OPERATION_NO_LOCK(source, desc);
LOG_BUCKET_OPERATION_NO_LOCK(targets[idx]->bid, desc);
}
#endif
newBucket = targets[idx]->bucket;
} else {
document::DocumentId did(getDocId(msg));
document::BucketId bucket = _bucketIdFactory.getBucketId(did);
uint32_t commonBits(findCommonBits(targets[0]->bucket.getBucketId(), bucket));
if (commonBits < source.getBucketId().getUsedBits()) {
std::ostringstream ost;
ost << bucket << " belongs in neither "
<< targets[0]->bucket.getBucketId() << " nor " << targets[1]->bucket.getBucketId()
<< ". Cannot remap it after split. It "
<< "did not belong in the original "
<< "bucket " << source.getBucketId();
LOG(error, "Error remapping %s after split %s",
cmd.getType().toString().c_str(), ost.str().c_str());
returnCode = api::ReturnCode(api::ReturnCode::REJECTED, ost.str());
} else {
std::ostringstream ost;
assert(targets.size() == 2);
ost << "Bucket " << source.getBucketId() << " was split and "
<< "neither bucket " << targets[0]->bucket.getBucketId() << " nor "
<< targets[1]->bucket.getBucketId() << " fit for this operation. "
<< "Failing operation so distributor can create "
<< "bucket on correct node.";
LOG(debug, "%s", ost.str().c_str());
returnCode = api::ReturnCode(api::ReturnCode::BUCKET_DELETED, ost.str());
}
}
} else {
LOG(debug, "Remapping %s operation to bucket %s",
cmd.toString().c_str(), targets[0]->bucket.getBucketId().toString().c_str());
cmd.remapBucketId(targets[0]->bucket.getBucketId());
newBucket = targets[0]->bucket;
targetDisk = targets[0]->diskIndex;
#ifdef ENABLE_BUCKET_OPERATION_LOGGING
{
vespalib::string desc = vespalib::make_string(
"Remapping %s from %s to %s, targetDisk = %u",
cmd.toString().c_str(), source.toString().c_str(),
targets[0]->bid.toString().c_str(), targetDisk);
LOG_BUCKET_OPERATION_NO_LOCK(source, desc);
LOG_BUCKET_OPERATION_NO_LOCK(targets[0]->bid, desc);
}
#endif
}
} else {
LOG(debug, "Did not remap %s with bucket %s from bucket %s",
cmd.toString().c_str(), cmd.getBucketId().toString().c_str(), source.toString().c_str());
LOG_ABORT("should not be reached");
}
break;
}
case api::MessageType::MERGEBUCKET_ID:
case api::MessageType::GETBUCKETDIFF_ID:
case api::MessageType::GETBUCKETDIFF_REPLY_ID:
case api::MessageType::APPLYBUCKETDIFF_ID:
case api::MessageType::APPLYBUCKETDIFF_REPLY_ID:
// Move to correct queue including filestor thread state
// if op == MOVE. If op != MOVE, fail with bucket not found
// and clear filestor thread state
{
api::BucketCommand& cmd(static_cast<api::BucketCommand&>(msg));
if (cmd.getBucket() == source) {
if (op != MOVE) {
std::ostringstream ost;
ost << "Bucket " << (op == SPLIT ? "split" : "joined")
<< ". Cannot remap merge, so aborting it";
api::ReturnCode code(api::ReturnCode::BUCKET_DELETED, ost.str());
clearMergeStatus(cmd.getBucket(), &code);
}
}
// Follow onto next to move queue or fail
}
[[fallthrough]];
case api::MessageType::SPLITBUCKET_ID:
// Move to correct queue if op == MOVE
// Fail with bucket not found if op is JOIN
// Ok if op is SPLIT, as we have already done as requested.
{
api::BucketCommand& cmd(static_cast<api::BucketCommand&>(msg));
if (cmd.getBucket() == source) {
if (op == MOVE) {
targetDisk = targets[0]->diskIndex;
} else if (op == SPLIT) {
returnCode = api::ReturnCode(api::ReturnCode::BUCKET_DELETED, "Bucket split while operation enqueued");
} else {
returnCode = api::ReturnCode(api::ReturnCode::BUCKET_DELETED, "Bucket was just joined");
}
}
break;
}
case api::MessageType::STAT_ID:
case api::MessageType::REVERT_ID:
case api::MessageType::REMOVELOCATION_ID:
case api::MessageType::SETBUCKETSTATE_ID:
{
// Move to correct queue if op == MOVE
// Fail with bucket not found if op != MOVE
api::BucketCommand& cmd(static_cast<api::BucketCommand&>(msg));
if (cmd.getBucket() == source) {
if (op == MOVE) {
targetDisk = targets[0]->diskIndex;
} else {
returnCode = api::ReturnCode(api::ReturnCode::BUCKET_DELETED, splitOrJoin(op));
}
}
break;
}
case api::MessageType::CREATEBUCKET_ID:
case api::MessageType::DELETEBUCKET_ID:
case api::MessageType::JOINBUCKETS_ID:
// Move to correct queue if op == MOVE. Otherwise ignore.
{
api::BucketCommand& cmd(static_cast<api::BucketCommand&>(msg));
if (cmd.getBucket() == source) {
if (op == MOVE) {
targetDisk = targets[0]->diskIndex;
}
}
break;
}
case api::MessageType::INTERNAL_ID:
{
const api::InternalCommand& icmd(static_cast<const api::InternalCommand&>(msg));
document::Bucket bucket;
switch(icmd.getType()) {
case RequestStatusPage::ID:
// Ignore
break;
case CreateIteratorCommand::ID:
bucket = static_cast<CreateIteratorCommand&>(msg).getBucket();
// Move to correct queue if op == MOVE
// Fail with bucket not found if op != MOVE
if (bucket == source) {
if (op == MOVE) {
targetDisk = targets[0]->diskIndex;
} else {
returnCode = api::ReturnCode(api::ReturnCode::BUCKET_DELETED, splitOrJoin(op));
}
}
break;
case GetIterCommand::ID:
bucket = static_cast<GetIterCommand&>(msg).getBucket();
[[fallthrough]];
case RepairBucketCommand::ID:
if (bucket.getBucketId().getRawId() == 0) {
bucket = static_cast<RepairBucketCommand&>(msg).getBucket();
}
// Move to correct queue if op == MOVE
// Fail with bucket not found if op != MOVE
if (bucket == source) {
if (op == MOVE) {
targetDisk = targets[0]->diskIndex;
} else {
returnCode = api::ReturnCode(api::ReturnCode::BUCKET_DELETED, splitOrJoin(op));
}
}
break;
case BucketDiskMoveCommand::ID:
// Fail bucket not found if op != MOVE
// Fail and log error if op == MOVE
{
api::BucketCommand& cmd(static_cast<api::BucketCommand&>(msg));
if (cmd.getBucket() == source) {
if (op == MOVE) {
returnCode = api::ReturnCode(api::ReturnCode::INTERNAL_FAILURE,
"Multiple bucket disk move commands pending at the same time "
" towards bucket " + source.toString());
} else {
returnCode = api::ReturnCode(api::ReturnCode::BUCKET_DELETED, splitOrJoin(op));
}
}
break;
}
case ReadBucketInfo::ID:
case RecheckBucketInfoCommand::ID:
{
LOG(debug, "While remapping load for bucket %s for reason %u, "
"we abort read bucket info request for this bucket.",
source.getBucketId().toString().c_str(), op);
break;
}
case InternalBucketJoinCommand::ID:
default:
// Fail and log error
{
LOG(error, "Attempted (and failed) to remap %s which should not be processed at this time",
msg.toString(true).c_str());
returnCode = api::ReturnCode(api::ReturnCode::INTERNAL_FAILURE,
"No such message should be processed at this time.");
break;
}
}
break;
}
default:
{
returnCode = api::ReturnCode(api::ReturnCode::INTERNAL_FAILURE, "Unknown message type in persistence layer");
LOG(error, "Unknown message type in persistence layer: %s", msg.toString().c_str());
}
} // End of switch
return newBucket;
}
void
FileStorHandlerImpl::remapQueueNoLock(Disk& from, const RemapInfo& source,
std::vector<RemapInfo*>& targets, Operation op)
{
BucketIdx& idx(from.stripe(source.bucket).exposeBucketIdx());
auto range(idx.equal_range(source.bucket));
std::vector<MessageEntry> entriesFound;
// Find all the messages for the given bucket.
for (BucketIdx::iterator i = range.first; i != range.second; ++i) {
assert(i->_bucket == source.bucket);
entriesFound.push_back(std::move(*i));
}
// Remove them
idx.erase(range.first, range.second);
// Reinsert all that can be remapped.
for (uint32_t i = 0; i < entriesFound.size(); ++i) {
// If set to something other than source.diskIndex, move this message
// to that queue.
MessageEntry& entry = entriesFound[i];
uint16_t targetDisk = source.diskIndex;
// If not OK, reply to this message with the following message
api::ReturnCode returnCode(api::ReturnCode::OK);
api::StorageMessage& msg(*entry._command);
assert(entry._bucket == source.bucket);
document::Bucket bucket = remapMessage(msg, source.bucket, op, targets, targetDisk, returnCode);
if (returnCode.getResult() != api::ReturnCode::OK) {
// Fail message if errorcode set
if (!msg.getType().isReply()) {
std::shared_ptr<api::StorageReply> rep = static_cast<api::StorageCommand&>(msg).makeReply();
LOG(spam, "Sending reply %s because remapping failed: %s",
msg.toString().c_str(), returnCode.toString().c_str());
rep->setResult(returnCode);
_messageSender.sendReply(rep);
}
} else {
entry._bucket = bucket;
// Move to correct disk queue if needed
_diskInfo[targetDisk].stripe(bucket).exposeQueue().emplace_back(std::move(entry));
}
}
}
void
FileStorHandlerImpl::remapQueue(const RemapInfo& source, RemapInfo& target, Operation op)
{
// Use a helper class to lock to solve issue that some buckets might be
// the same bucket. Will fix order if we accept wrong order later.
MultiLockGuard guard;
Disk& from(_diskInfo[source.diskIndex]);
guard.addLock(from.stripe(source.bucket).exposeLock(), source.diskIndex);
Disk& to1(_diskInfo[target.diskIndex]);
if (target.bucket.getBucketId().getRawId() != 0) {
guard.addLock(to1.stripe(target.bucket).exposeLock(), target.diskIndex);
}
std::vector<RemapInfo*> targets;
targets.push_back(&target);
guard.lock();
remapQueueNoLock(from, source, targets, op);
}
void
FileStorHandlerImpl::remapQueue(const RemapInfo& source, RemapInfo& target1, RemapInfo& target2, Operation op)
{
// Use a helper class to lock to solve issue that some buckets might be
// the same bucket. Will fix order if we accept wrong order later.
MultiLockGuard guard;
Disk& from(_diskInfo[source.diskIndex]);
guard.addLock(from.stripe(source.bucket).exposeLock(), source.diskIndex);
Disk& to1(_diskInfo[target1.diskIndex]);
if (target1.bucket.getBucketId().getRawId() != 0) {
guard.addLock(to1.stripe(target1.bucket).exposeLock(), target1.diskIndex);
}
Disk& to2(_diskInfo[target2.diskIndex]);
if (target2.bucket.getBucketId().getRawId() != 0) {
guard.addLock(to2.stripe(target2.bucket).exposeLock(), target2.diskIndex);
}
guard.lock();
std::vector<RemapInfo*> targets;
targets.push_back(&target1);
targets.push_back(&target2);
remapQueueNoLock(from, source, targets, op);
}
void
FileStorHandlerImpl::Stripe::failOperations(const document::Bucket &bucket, const api::ReturnCode& err)
{
vespalib::MonitorGuard guard(_lock);
BucketIdx& idx(bmi::get<2>(_queue));
std::pair<BucketIdx::iterator, BucketIdx::iterator> range(idx.equal_range(bucket));
for (auto iter = range.first; iter != range.second;) {
// We want to post delete bucket to list before calling this
// function in order to release bucket database lock. Thus we
// cannot delete the delete bucket operation itself
if (iter->_command->getType() != api::MessageType::DELETEBUCKET) {
if (!iter->_command->getType().isReply()) {
std::shared_ptr<api::StorageReply> msgReply = static_cast<api::StorageCommand&>(*iter->_command).makeReply();
msgReply->setResult(err);
_messageSender.sendReply(msgReply);
}
iter = idx.erase(iter);
} else {
++iter;
}
}
}
void
FileStorHandlerImpl::sendCommand(const std::shared_ptr<api::StorageCommand>& msg)
{
_messageSender.sendCommand(msg);
}
void
FileStorHandlerImpl::sendReply(const std::shared_ptr<api::StorageReply>& msg)
{
_messageSender.sendReply(msg);
}
FileStorHandlerImpl::MessageEntry::MessageEntry(const std::shared_ptr<api::StorageMessage>& cmd,
const document::Bucket &bucket)
: _command(cmd),
_timer(),
_bucket(bucket),
_priority(cmd->getPriority())
{ }
FileStorHandlerImpl::MessageEntry::MessageEntry(const MessageEntry& entry)
: _command(entry._command),
_timer(entry._timer),
_bucket(entry._bucket),
_priority(entry._priority)
{ }
FileStorHandlerImpl::MessageEntry::MessageEntry(MessageEntry && entry) noexcept
: _command(std::move(entry._command)),
_timer(entry._timer),
_bucket(entry._bucket),
_priority(entry._priority)
{ }
FileStorHandlerImpl::MessageEntry::~MessageEntry() = default;
FileStorHandlerImpl::Disk::Disk(const FileStorHandlerImpl & owner, MessageSender & messageSender, uint32_t numStripes)
: metrics(0),
_nextStripeId(0),
_stripes(numStripes, Stripe(owner, messageSender)),
state(FileStorHandler::AVAILABLE)
{
assert(numStripes > 0);
}
FileStorHandlerImpl::Disk::Disk(Disk && rhs) noexcept
: metrics(std::move(rhs.metrics)),
_nextStripeId(rhs._nextStripeId),
_stripes(std::move(rhs._stripes)),
state(rhs.state.load())
{ }
FileStorHandlerImpl::Disk::~Disk() = default;
FileStorHandlerImpl::Stripe::~Stripe() = default;
void
FileStorHandlerImpl::Disk::flush()
{
for (auto & stripe : _stripes) {
stripe.flush();
}
}
void
FileStorHandlerImpl::Disk::broadcast()
{
for (auto & stripe : _stripes) {
stripe.broadcast();
}
}
bool
FileStorHandlerImpl::Disk::schedule(const std::shared_ptr<api::StorageMessage>& msg)
{
MessageEntry messageEntry(msg, getStorageMessageBucket(*msg));
if (getState() == FileStorHandler::AVAILABLE) {
stripe(messageEntry._bucket).schedule(std::move(messageEntry));
} else {
return false;
}
return true;
}
FileStorHandlerImpl::Stripe::Stripe(const FileStorHandlerImpl & owner, MessageSender & messageSender)
: _owner(owner),
_messageSender(messageSender)
{ }
FileStorHandler::LockedMessage
FileStorHandlerImpl::Stripe::getNextMessage(uint32_t timeout, Disk & disk)
{
vespalib::MonitorGuard guard(_lock);
// Try to grab a message+lock, immediately retrying once after a wait
// if none can be found and then exiting if the same is the case on the
// second attempt. This is key to allowing the run loop to register
// ticks at regular intervals while not busy-waiting.
for (int attempt = 0; (attempt < 2) && ! disk.isClosed() && !_owner.isPaused(); ++attempt) {
PriorityIdx& idx(bmi::get<1>(_queue));
PriorityIdx::iterator iter(idx.begin()), end(idx.end());
while (iter != end && operationIsInhibited(guard, iter->_bucket, *iter->_command)) {
iter++;
}
if (iter != end) {
return getMessage(guard, idx, iter);
}
if (attempt == 0) {
guard.wait(timeout);
}
}
return {}; // No message fetched.
}
FileStorHandler::LockedMessage &
FileStorHandlerImpl::Stripe::getNextMessage(FileStorHandler::LockedMessage& lck)
{
const document::Bucket & bucket = lck.second->getBucket();
vespalib::MonitorGuard guard(_lock);
BucketIdx& idx = bmi::get<2>(_queue);
std::pair<BucketIdx::iterator, BucketIdx::iterator> range = idx.equal_range(bucket);
// No more for this bucket.
if (range.first == range.second) {
lck.second.reset();
return lck;
}
api::StorageMessage & m(*range.first->_command);
// For now, don't allow batching of operations across lock requirement modes.
// We might relax this requirement later once we're 100% sure it can't trigger
// any unfortunate edge cases.
if (lck.first->lockingRequirements() != m.lockingRequirements()) {
lck.second.reset();
return lck;
}
std::chrono::milliseconds waitTime(uint64_t(range.first->_timer.stop(_metrics->averageQueueWaitingTime[m.getLoadType()])));
if (!messageTimedOutInQueue(m, waitTime)) {
std::shared_ptr<api::StorageMessage> msg = std::move(range.first->_command);
idx.erase(range.first);
lck.second.swap(msg);
guard.broadcast();
} else {
std::shared_ptr<api::StorageReply> msgReply = static_cast<api::StorageCommand&>(m).makeReply();
idx.erase(range.first);
guard.broadcast();
guard.unlock();
msgReply->setResult(api::ReturnCode(api::ReturnCode::TIMEOUT, "Message waited too long in storage queue"));
_messageSender.sendReply(msgReply);
lck.second.reset();
}
return lck;
}
FileStorHandler::LockedMessage
FileStorHandlerImpl::Stripe::getMessage(vespalib::MonitorGuard & guard, PriorityIdx & idx, PriorityIdx::iterator iter) {
api::StorageMessage & m(*iter->_command);
std::chrono::milliseconds waitTime(uint64_t(iter->_timer.stop(_metrics->averageQueueWaitingTime[m.getLoadType()])));
std::shared_ptr<api::StorageMessage> msg = std::move(iter->_command);
document::Bucket bucket(iter->_bucket);
idx.erase(iter); // iter not used after this point.
if (!messageTimedOutInQueue(*msg, waitTime)) {
auto locker = std::make_unique<BucketLock>(guard, *this, bucket, msg->getPriority(),
msg->getType().getId(), msg->getMsgId(),
msg->lockingRequirements());
guard.unlock();
return FileStorHandler::LockedMessage(std::move(locker), std::move(msg));
} else {
std::shared_ptr<api::StorageReply> msgReply(makeQueueTimeoutReply(*msg));
guard.broadcast(); // XXX: needed here?
guard.unlock();
_messageSender.sendReply(msgReply);
return {};
}
}
void
FileStorHandlerImpl::Disk::waitUntilNoLocks() const
{
for (const auto & stripe : _stripes) {
stripe.waitUntilNoLocks();
}
}
void
FileStorHandlerImpl::Stripe::waitUntilNoLocks() const
{
vespalib::MonitorGuard lockGuard(_lock);
while (!_lockedBuckets.empty()) {
lockGuard.wait();
}
}
void
FileStorHandlerImpl::Disk::waitInactive(const AbortBucketOperationsCommand& cmd) const {
for (auto & stripe : _stripes) {
stripe.waitInactive(cmd);
}
}
void
FileStorHandlerImpl::Stripe::waitInactive(const AbortBucketOperationsCommand& cmd) const {
vespalib::MonitorGuard lockGuard(_lock);
while (hasActive(lockGuard, cmd)) {
lockGuard.wait();
}
}
bool
FileStorHandlerImpl::Stripe::hasActive(vespalib::MonitorGuard &, const AbortBucketOperationsCommand& cmd) const {
for (auto& lockedBucket : _lockedBuckets) {
if (cmd.shouldAbort(lockedBucket.first)) {
LOG(spam, "Disk had active operation for aborted bucket %s, waiting for it to complete...",
lockedBucket.first.toString().c_str());
return true;
}
}
return false;
}
std::vector<std::shared_ptr<api::StorageReply>>
FileStorHandlerImpl::Disk::abort(const AbortBucketOperationsCommand& cmd)
{
std::vector<std::shared_ptr<api::StorageReply>> aborted;
for (auto & stripe : _stripes) {
stripe.abort(aborted, cmd);
}
return aborted;
}
void FileStorHandlerImpl::Stripe::abort(std::vector<std::shared_ptr<api::StorageReply>> & aborted,
const AbortBucketOperationsCommand& cmd)
{
vespalib::MonitorGuard lockGuard(_lock);
for (auto it(_queue.begin()); it != _queue.end();) {
api::StorageMessage& msg(*it->_command);
if (messageMayBeAborted(msg) && cmd.shouldAbort(it->_bucket)) {
aborted.emplace_back(static_cast<api::StorageCommand&>(msg).makeReply());
it = _queue.erase(it);
} else {
++it;
}
}
}
bool FileStorHandlerImpl::Stripe::schedule(MessageEntry messageEntry)
{
vespalib::MonitorGuard lockGuard(_lock);
_queue.emplace_back(std::move(messageEntry));
lockGuard.broadcast();
return true;
}
void
FileStorHandlerImpl::Stripe::flush()
{
vespalib::MonitorGuard lockGuard(_lock);
while (!(_queue.empty() && _lockedBuckets.empty())) {
LOG(debug, "Still %ld in queue and %ld locked buckets", _queue.size(), _lockedBuckets.size());
lockGuard.wait(100);
}
}
void FileStorHandlerImpl::Stripe::release(const document::Bucket & bucket,
api::LockingRequirements reqOfReleasedLock,
api::StorageMessage::Id lockMsgId) {
vespalib::MonitorGuard guard(_lock);
auto iter = _lockedBuckets.find(bucket);
assert(iter != _lockedBuckets.end());
auto& entry = iter->second;
if (reqOfReleasedLock == api::LockingRequirements::Exclusive) {
assert(entry._exclusiveLock);
assert(entry._exclusiveLock->msgId == lockMsgId);
if (entry._exclusiveLock->msgType == api::MessageType::MERGEBUCKET_ID) {
auto before = _owner._activeMerges.fetch_sub(1, std::memory_order_relaxed);
assert(before > 0);
}
entry._exclusiveLock.reset();
} else {
assert(!entry._exclusiveLock);
auto shared_iter = entry._sharedLocks.find(lockMsgId);
assert(shared_iter != entry._sharedLocks.end());
entry._sharedLocks.erase(shared_iter);
}
if (!entry._exclusiveLock && entry._sharedLocks.empty()) {
_lockedBuckets.erase(iter); // No more locks held
}
guard.broadcast();
}
void FileStorHandlerImpl::Stripe::lock(const vespalib::MonitorGuard &, const document::Bucket & bucket,
api::LockingRequirements lockReq, const LockEntry & lockEntry) {
auto& entry = _lockedBuckets[bucket];
assert(!entry._exclusiveLock);
if (lockReq == api::LockingRequirements::Exclusive) {
assert(entry._sharedLocks.empty());
if (lockEntry.msgType == api::MessageType::MERGEBUCKET_ID) {
_owner._activeMerges.fetch_add(1, std::memory_order_relaxed);
}
entry._exclusiveLock = lockEntry;
} else {
// TODO use a hash set with a custom comparator/hasher instead...?
auto inserted = entry._sharedLocks.insert(std::make_pair(lockEntry.msgId, lockEntry));
(void) inserted;
assert(inserted.second);
}
}
bool
FileStorHandlerImpl::Stripe::isLocked(const vespalib::MonitorGuard &, const document::Bucket& bucket,
api::LockingRequirements lockReq) const noexcept
{
if (bucket.getBucketId().getRawId() == 0) {
return false;
}
auto iter = _lockedBuckets.find(bucket);
if (iter == _lockedBuckets.end()) {
return false;
}
if (iter->second._exclusiveLock) {
return true;
}
// Shared locks can be taken alongside other shared locks, but exclusive locks
// require that no shared locks are currently present.
return ((lockReq == api::LockingRequirements::Exclusive)
&& !iter->second._sharedLocks.empty());
}
bool
FileStorHandlerImpl::Stripe::operationIsInhibited(const vespalib::MonitorGuard& guard, const document::Bucket& bucket,
const api::StorageMessage& msg) const noexcept
{
if ((msg.getType() == api::MessageType::MERGEBUCKET)
&& (_owner._activeMerges.load(std::memory_order_relaxed) > _owner._activeMergesSoftLimit))
{
return true;
}
return isLocked(guard, bucket, msg.lockingRequirements());
}
uint32_t
FileStorHandlerImpl::Disk::getQueueSize() const noexcept
{
size_t sum(0);
for (const auto & stripe : _stripes) {
sum += stripe.getQueueSize();
}
return sum;
}
uint32_t
FileStorHandlerImpl::getQueueSize(uint16_t disk) const
{
return _diskInfo[disk].getQueueSize();
}
FileStorHandlerImpl::BucketLock::BucketLock(const vespalib::MonitorGuard & guard, Stripe& stripe,
const document::Bucket &bucket, uint8_t priority,
api::MessageType::Id msgType, api::StorageMessage::Id msgId,
api::LockingRequirements lockReq)
: _stripe(stripe),
_bucket(bucket),
_uniqueMsgId(msgId),
_lockReq(lockReq)
{
if (_bucket.getBucketId().getRawId() != 0) {
_stripe.lock(guard, _bucket, lockReq, Stripe::LockEntry(priority, msgType, msgId));
LOG(debug, "Locked bucket %s for message %" PRIu64 " with priority %u in mode %s",
bucket.getBucketId().toString().c_str(), msgId, priority, api::to_string(lockReq));
}
}
FileStorHandlerImpl::BucketLock::~BucketLock() {
if (_bucket.getBucketId().getRawId() != 0) {
_stripe.release(_bucket, _lockReq, _uniqueMsgId);
LOG(debug, "Unlocked bucket %s for message %" PRIu64 " in mode %s",
_bucket.getBucketId().toString().c_str(), _uniqueMsgId, api::to_string(_lockReq));
}
}
std::string
FileStorHandlerImpl::Disk::dumpQueue() const
{
std::ostringstream os;
for (const Stripe & stripe : _stripes) {
stripe.dumpQueue(os);
}
return os.str();
}
void
FileStorHandlerImpl::Disk::dumpQueueHtml(std::ostream & os) const
{
for (const Stripe & stripe : _stripes) {
stripe.dumpQueueHtml(os);
}
}
void
FileStorHandlerImpl::Disk::dumpActiveHtml(std::ostream & os) const
{
for (const Stripe & stripe : _stripes) {
stripe.dumpActiveHtml(os);
}
}
void
FileStorHandlerImpl::Stripe::dumpQueueHtml(std::ostream & os) const
{
vespalib::MonitorGuard guard(_lock);
const PriorityIdx& idx = bmi::get<1>(_queue);
for (const auto & entry : idx) {
os << "<li>" << entry._command->toString() << " (priority: "
<< (int)entry._command->getPriority() << ")</li>\n";
}
}
namespace {
void dump_lock_entry(const document::BucketId& bucketId, const FileStorHandlerImpl::Stripe::LockEntry& entry,
api::LockingRequirements lock_mode, FileStorHandlerImpl::Clock::time_point now_ts, std::ostream& os) {
os << api::MessageType::get(entry.msgType).getName() << ":" << entry.msgId << " ("
<< bucketId << ", " << api::to_string(lock_mode)
<< " lock) Running for " << std::chrono::duration_cast<std::chrono::seconds>(now_ts - entry.timestamp).count() << " secs<br/>\n";
}
}
void
FileStorHandlerImpl::Stripe::dumpActiveHtml(std::ostream & os) const
{
Clock::time_point now = Clock::now();
vespalib::MonitorGuard guard(_lock);
for (const auto & e : _lockedBuckets) {
if (e.second._exclusiveLock) {
dump_lock_entry(e.first.getBucketId(), *e.second._exclusiveLock,
api::LockingRequirements::Exclusive, now, os);
}
for (const auto& shared : e.second._sharedLocks) {
dump_lock_entry(e.first.getBucketId(), shared.second,
api::LockingRequirements::Shared, now, os);
}
}
}
void
FileStorHandlerImpl::Stripe::dumpQueue(std::ostream & os) const
{
vespalib::MonitorGuard guard(_lock);
const PriorityIdx& idx = bmi::get<1>(_queue);
for (const auto & entry : idx) {
os << entry._bucket.getBucketId() << ": " << entry._command->toString() << " (priority: "
<< (int)entry._command->getPriority() << ")\n";
}
}
void
FileStorHandlerImpl::getStatus(std::ostream& out, const framework::HttpUrlPath& path) const
{
bool verbose = path.hasAttribute("verbose");
out << "<h1>Filestor handler</h1>\n";
for (uint32_t i=0; i<_diskInfo.size(); ++i) {
out << "<h2>Disk " << i << "</h2>\n";
const Disk& disk(_diskInfo[i]);
out << "Queue size: " << disk.getQueueSize() << "<br>\n";
out << "Disk state: ";
switch (disk.getState()) {
case FileStorHandler::AVAILABLE: out << "AVAILABLE"; break;
case FileStorHandler::DISABLED: out << "DISABLED"; break;
case FileStorHandler::CLOSED: out << "CLOSED"; break;
}
out << "<h4>Active operations</h4>\n";
disk.dumpActiveHtml(out);
if (!verbose) continue;
out << "<h4>Input queue</h4>\n";
out << "<ul>\n";
disk.dumpQueueHtml(out);
out << "</ul>\n";
}
vespalib::LockGuard mergeGuard(_mergeStatesLock);
out << "<tr><td>Active merge operations</td><td>" << _mergeStates.size() << "</td></tr>\n";
if (verbose) {
out << "<h4>Active merges</h4>\n";
if (_mergeStates.size() == 0) {
out << "None\n";
}
for (auto & entry : _mergeStates) {
out << "<b>" << entry.first.toString() << "</b><br>\n";
}
}
}
void
FileStorHandlerImpl::waitUntilNoLocks()
{
for (const auto & disk : _diskInfo) {
disk.waitUntilNoLocks();
}
}
ResumeGuard
FileStorHandlerImpl::pause()
{
_paused.store(true, std::memory_order_relaxed);
waitUntilNoLocks();
return ResumeGuard(*this);
}
void
FileStorHandlerImpl::resume()
{
vespalib::MonitorGuard g(_pauseMonitor);
_paused.store(false, std::memory_order_relaxed);
g.broadcast();
}
} // storage
|
#include <AK/QuickSort.h>
#include <AK/String.h>
#include <AK/StringBuilder.h>
#include <AK/Vector.h>
#include <LibCore/CDirIterator.h>
#include <dirent.h>
#include <errno.h>
#include <fcntl.h>
#include <getopt.h>
#include <grp.h>
#include <pwd.h>
#include <stdio.h>
#include <string.h>
#include <sys/ioctl.h>
#include <sys/stat.h>
#include <time.h>
#include <unistd.h>
static int do_file_system_object_long(const char* path);
static int do_file_system_object_short(const char* path);
static bool flag_colorize = true;
static bool flag_long = false;
static bool flag_show_dotfiles = false;
static bool flag_show_inode = false;
static bool flag_print_numeric = false;
static bool flag_human_readable = false;
static bool flag_sort_by_timestamp = false;
static bool flag_reverse_sort = false;
static int terminal_rows = 0;
static int terminal_columns = 0;
static bool output_is_terminal = false;
int main(int argc, char** argv)
{
struct winsize ws;
int rc = ioctl(STDOUT_FILENO, TIOCGWINSZ, &ws);
if (rc == 0) {
terminal_rows = ws.ws_row;
terminal_columns = ws.ws_col;
output_is_terminal = true;
}
static const char* valid_option_characters = "ltraiGnh";
int opt;
while ((opt = getopt(argc, argv, valid_option_characters)) != -1) {
switch (opt) {
case 'a':
flag_show_dotfiles = true;
break;
case 'l':
flag_long = true;
break;
case 't':
flag_sort_by_timestamp = true;
break;
case 'r':
flag_reverse_sort = true;
break;
case 'G':
flag_colorize = false;
break;
case 'i':
flag_show_inode = true;
break;
case 'n':
flag_print_numeric = true;
break;
case 'h':
flag_human_readable = true;
break;
default:
fprintf(stderr, "usage: ls [-%s] [paths...]\n", valid_option_characters);
return 1;
}
}
auto do_file_system_object = [&](const char* path) {
if (flag_long)
return do_file_system_object_long(path);
return do_file_system_object_short(path);
};
int status = 0;
if (optind >= argc) {
status = do_file_system_object(".");
} else if (optind + 1 >= argc) {
status = do_file_system_object(argv[optind]);
} else {
for (; optind < argc; ++optind) {
printf("%s:\n", argv[optind]);
status = do_file_system_object(argv[optind]);
}
}
return status;
}
int print_name(const struct stat& st, const String& name, const char* path_for_link_resolution = nullptr)
{
int nprinted = name.length();
if (!flag_colorize || !output_is_terminal) {
printf("%s", name.characters());
} else {
const char* begin_color = "";
const char* end_color = "\033[0m";
if (S_ISLNK(st.st_mode))
begin_color = "\033[36;1m";
else if (S_ISDIR(st.st_mode))
begin_color = "\033[34;1m";
else if (st.st_mode & 0111)
begin_color = "\033[32;1m";
else if (S_ISSOCK(st.st_mode))
begin_color = "\033[35;1m";
else if (S_ISCHR(st.st_mode) || S_ISBLK(st.st_mode))
begin_color = "\033[33;1m";
printf("%s%s%s", begin_color, name.characters(), end_color);
}
if (S_ISLNK(st.st_mode)) {
if (path_for_link_resolution) {
char linkbuf[PATH_MAX];
ssize_t nread = readlink(path_for_link_resolution, linkbuf, sizeof(linkbuf));
if (nread < 0)
perror("readlink failed");
else
nprinted += printf(" -> %s", linkbuf);
} else {
nprinted += printf("@");
}
} else if (S_ISDIR(st.st_mode)) {
nprinted += printf("/");
} else if (st.st_mode & 0111) {
nprinted += printf("*");
}
return nprinted;
}
// FIXME: Remove this hackery once printf() supports floats.
// FIXME: Also, we should probably round the sizes in ls -lh output.
static String number_string_with_one_decimal(float number, const char* suffix)
{
float decimals = number - (int)number;
return String::format("%d.%d%s", (int)number, (int)(decimals * 10), suffix);
}
static String human_readable_size(size_t size)
{
if (size < 1 * KB)
return String::number(size);
if (size < 1 * MB)
return number_string_with_one_decimal((float)size / (float)KB, "K");
if (size < 1 * GB)
return number_string_with_one_decimal((float)size / (float)MB, "M");
return number_string_with_one_decimal((float)size / (float)GB, "G");
}
bool print_filesystem_object(const String& path, const String& name, const struct stat& st)
{
if (flag_show_inode)
printf("%08u ", st.st_ino);
if (S_ISDIR(st.st_mode))
printf("d");
else if (S_ISLNK(st.st_mode))
printf("l");
else if (S_ISBLK(st.st_mode))
printf("b");
else if (S_ISCHR(st.st_mode))
printf("c");
else if (S_ISFIFO(st.st_mode))
printf("f");
else if (S_ISSOCK(st.st_mode))
printf("s");
else if (S_ISREG(st.st_mode))
printf("-");
else
printf("?");
printf("%c%c%c%c%c%c%c%c",
st.st_mode & S_IRUSR ? 'r' : '-',
st.st_mode & S_IWUSR ? 'w' : '-',
st.st_mode & S_ISUID ? 's' : (st.st_mode & S_IXUSR ? 'x' : '-'),
st.st_mode & S_IRGRP ? 'r' : '-',
st.st_mode & S_IWGRP ? 'w' : '-',
st.st_mode & S_ISGID ? 's' : (st.st_mode & S_IXGRP ? 'x' : '-'),
st.st_mode & S_IROTH ? 'r' : '-',
st.st_mode & S_IWOTH ? 'w' : '-');
if (st.st_mode & S_ISVTX)
printf("t");
else
printf("%c", st.st_mode & S_IXOTH ? 'x' : '-');
passwd* pwd = getpwuid(st.st_uid);
group* grp = getgrgid(st.st_gid);
if (!flag_print_numeric && pwd) {
printf(" %5s", pwd->pw_name);
} else {
printf(" %5u", st.st_uid);
}
if (!flag_print_numeric && grp) {
printf(" %5s", grp->gr_name);
} else {
printf(" %5u", st.st_gid);
}
if (S_ISCHR(st.st_mode) || S_ISBLK(st.st_mode)) {
printf(" %4u,%4u ", major(st.st_rdev), minor(st.st_rdev));
} else {
if (flag_human_readable) {
ASSERT(st.st_size > 0);
printf(" %10s ", human_readable_size((size_t)st.st_size).characters());
} else {
printf(" %10u ", st.st_size);
}
}
auto* tm = localtime(&st.st_mtime);
printf(" %4u-%02u-%02u %02u:%02u:%02u ",
tm->tm_year + 1900,
tm->tm_mon + 1,
tm->tm_mday,
tm->tm_hour,
tm->tm_min,
tm->tm_sec);
print_name(st, name, path.characters());
printf("\n");
return true;
}
int do_file_system_object_long(const char* path)
{
CDirIterator di(path, !flag_show_dotfiles ? CDirIterator::SkipDots : CDirIterator::Flags::NoFlags);
if (di.has_error()) {
if (di.error() == ENOTDIR) {
struct stat stat;
int rc = lstat(path, &stat);
if (rc < 0) {
perror("lstat");
memset(&stat, 0, sizeof(stat));
}
if (print_filesystem_object(path, path, stat))
return 0;
return 2;
}
fprintf(stderr, "CDirIterator: %s\n", di.error_string());
return 1;
}
struct FileMetadata {
String name;
String path;
struct stat stat;
};
Vector<FileMetadata> files;
while (di.has_next()) {
FileMetadata metadata;
metadata.name = di.next_path();
ASSERT(!metadata.name.is_empty());
if (metadata.name[0] == '.' && !flag_show_dotfiles)
continue;
StringBuilder builder;
builder.append(path);
builder.append('/');
builder.append(metadata.name);
metadata.path = builder.to_string();
ASSERT(!metadata.path.is_null());
int rc = lstat(metadata.path.characters(), &metadata.stat);
if (rc < 0) {
perror("lstat");
memset(&metadata.stat, 0, sizeof(metadata.stat));
}
files.append(move(metadata));
}
quick_sort(files.begin(), files.end(), [](auto& a, auto& b) {
if (flag_sort_by_timestamp) {
if (flag_reverse_sort)
return a.stat.st_mtime > b.stat.st_mtime;
return a.stat.st_mtime < b.stat.st_mtime;
}
// Fine, sort by name then!
if (flag_reverse_sort)
return a.name > b.name;
return a.name < b.name;
});
for (auto& file : files) {
if (!print_filesystem_object(file.path, file.name, file.stat))
return 2;
}
return 0;
}
bool print_filesystem_object_short(const char* path, const char* name, int* nprinted)
{
struct stat st;
int rc = lstat(path, &st);
if (rc == -1) {
printf("lstat(%s) failed: %s\n", path, strerror(errno));
return false;
}
*nprinted = print_name(st, name);
return true;
}
int do_file_system_object_short(const char* path)
{
CDirIterator di(path, !flag_show_dotfiles ? CDirIterator::SkipDots : CDirIterator::Flags::NoFlags);
if (di.has_error()) {
if (di.error() == ENOTDIR) {
int nprinted;
bool status = print_filesystem_object_short(path, path, &nprinted);
printf("\n");
if (status)
return 0;
return 2;
}
fprintf(stderr, "CDirIterator: %s\n", di.error_string());
return 1;
}
Vector<String> names;
int longest_name = 0;
while (di.has_next()) {
String name = di.next_path();
names.append(name);
if (names.last().length() > longest_name)
longest_name = name.length();
}
quick_sort(names.begin(), names.end(), [](auto& a, auto& b) { return a < b; });
int printed_on_row = 0;
int nprinted;
for (int i = 0; i < names.size(); ++i) {
auto& name = names[i];
StringBuilder builder;
builder.append(path);
builder.append('/');
builder.append(name);
if (!print_filesystem_object_short(builder.to_string().characters(), name.characters(), &nprinted))
return 2;
int offset = 0;
if (terminal_columns > longest_name)
offset = terminal_columns % longest_name / (terminal_columns / longest_name);
// The offset must be at least 2 because:
// - With each file an aditional char is printed e.g. '@','*'.
// - Each filename must be separated by a space.
int column_width = longest_name + (offset > 0 ? offset : 2);
printed_on_row += column_width;
for (int j = nprinted; i != (names.size() - 1) && j < column_width; ++j)
printf(" ");
if ((printed_on_row + column_width) >= terminal_columns) {
printf("\n");
printed_on_row = 0;
}
}
if (printed_on_row)
printf("\n");
return 0;
}
|
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/plugins/plugin_observer.h"
#include "base/auto_reset.h"
#include "base/bind.h"
#include "base/stl_util.h"
#include "base/utf_string_conversions.h"
#include "chrome/browser/api/infobars/confirm_infobar_delegate.h"
#include "chrome/browser/api/infobars/simple_alert_infobar_delegate.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/content_settings/host_content_settings_map.h"
#include "chrome/browser/infobars/infobar_tab_helper.h"
#include "chrome/browser/lifetime/application_lifetime.h"
#include "chrome/browser/metrics/metrics_service.h"
#include "chrome/browser/plugins/plugin_finder.h"
#include "chrome/browser/plugins/plugin_infobar_delegates.h"
#include "chrome/browser/plugins/plugin_metadata.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/tab_modal_confirm_dialog.h"
#include "chrome/common/render_messages.h"
#include "chrome/common/url_constants.h"
#include "content/public/browser/plugin_service.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_delegate.h"
#include "grit/generated_resources.h"
#include "grit/theme_resources.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/resource/resource_bundle.h"
#include "webkit/plugins/webplugininfo.h"
#if defined(ENABLE_PLUGIN_INSTALLATION)
#include "chrome/browser/plugins/plugin_installer.h"
#include "chrome/browser/plugins/plugin_installer_observer.h"
#include "chrome/browser/ui/tab_modal_confirm_dialog_delegate.h"
#endif // defined(ENABLE_PLUGIN_INSTALLATION)
#if defined(OS_WIN)
#include "base/win/metro.h"
#endif
using content::OpenURLParams;
using content::PluginService;
using content::Referrer;
using content::WebContents;
DEFINE_WEB_CONTENTS_USER_DATA_KEY(PluginObserver)
namespace {
#if defined(ENABLE_PLUGIN_INSTALLATION)
// ConfirmInstallDialogDelegate ------------------------------------------------
class ConfirmInstallDialogDelegate : public TabModalConfirmDialogDelegate,
public WeakPluginInstallerObserver {
public:
ConfirmInstallDialogDelegate(content::WebContents* web_contents,
PluginInstaller* installer,
scoped_ptr<PluginMetadata> plugin_metadata);
// TabModalConfirmDialogDelegate methods:
virtual string16 GetTitle() OVERRIDE;
virtual string16 GetMessage() OVERRIDE;
virtual string16 GetAcceptButtonTitle() OVERRIDE;
virtual void OnAccepted() OVERRIDE;
virtual void OnCanceled() OVERRIDE;
// WeakPluginInstallerObserver methods:
virtual void DownloadStarted() OVERRIDE;
virtual void OnlyWeakObserversLeft() OVERRIDE;
private:
content::WebContents* web_contents_;
scoped_ptr<PluginMetadata> plugin_metadata_;
};
ConfirmInstallDialogDelegate::ConfirmInstallDialogDelegate(
content::WebContents* web_contents,
PluginInstaller* installer,
scoped_ptr<PluginMetadata> plugin_metadata)
: TabModalConfirmDialogDelegate(web_contents),
WeakPluginInstallerObserver(installer),
web_contents_(web_contents),
plugin_metadata_(plugin_metadata.Pass()) {
}
string16 ConfirmInstallDialogDelegate::GetTitle() {
return l10n_util::GetStringFUTF16(
IDS_PLUGIN_CONFIRM_INSTALL_DIALOG_TITLE, plugin_metadata_->name());
}
string16 ConfirmInstallDialogDelegate::GetMessage() {
return l10n_util::GetStringFUTF16(IDS_PLUGIN_CONFIRM_INSTALL_DIALOG_MSG,
plugin_metadata_->name());
}
string16 ConfirmInstallDialogDelegate::GetAcceptButtonTitle() {
return l10n_util::GetStringUTF16(
IDS_PLUGIN_CONFIRM_INSTALL_DIALOG_ACCEPT_BUTTON);
}
void ConfirmInstallDialogDelegate::OnAccepted() {
installer()->StartInstalling(plugin_metadata_->plugin_url(), web_contents_);
}
void ConfirmInstallDialogDelegate::OnCanceled() {
}
void ConfirmInstallDialogDelegate::DownloadStarted() {
Cancel();
}
void ConfirmInstallDialogDelegate::OnlyWeakObserversLeft() {
Cancel();
}
#endif // defined(ENABLE_PLUGIN_INSTALLATION)
const char* kEnableJavaByDefaultForTheseDomains[] = {
"1stnationalbank.com",
"53.com",
"77bank.co.jp",
"aabar.com",
"aareal-bank.com",
"ab.lv",
"abcbrasil.com.br",
"abchina.com",
"ablv.com",
"abnamro.cl",
"abnamro.com",
"abnamro.nl",
"abnamroprivatebanking.com",
"aboutsantander.co.uk",
"accbank.com",
"accbank.ie",
"accival.com.mx",
"adcb.com",
"adcbactive.com",
"adib.ae",
"advanzia.com",
"aegon.com",
"aegonbank.nl",
"afbank.com",
"afbca.com",
"afcmerchantbank.com",
"affin.com.my",
"affinbank.com.my",
"afgrp.com",
"aforebanamex.com.mx",
"aforeinbursa.com.mx",
"agfirst.com",
"aib.ie",
"aibcm.com",
"aibcorporate.ie",
"aibgb.co.uk",
"aibgroup.com",
"aibifs.com",
"aibinternational.co.im",
"aibjerseyisleofman.com",
"aichibank.co.jp",
"akb.ch",
"al-bank.dk",
"alahli.com",
"alfransi.com.sa",
"alhilalbank.ae",
"ally.com",
"almbrand.dk",
"alpha.gr",
"alrajhibank.com",
"alterna.ca",
"americanexpress.com",
"amerisbank.com",
"amp.com.au",
"anb.com.sa",
"andbank-monaco.mc",
"andelskassen.dk",
"anz.co.nz",
"anz.com",
"appkb.ch",
"argenta.be",
"asb.co.nz",
"asbhawaii.com",
"asnbank.nl",
"atebank.de",
"athloncarlease.com",
"atticabank.gr",
"autobank.at",
"axa.be",
"axabanque.fr",
"b2bbank.com",
"baj.com.sa",
"baltikums.eu",
"baltikums.lv",
"banamex.com",
"banca-e.com",
"bancaditalia.it",
"bancaesperia.it",
"bancaja.es",
"bancamediolanum.it",
"bancoazteca.com.mx",
"bancoazteca.com.pa",
"bancoazteca.com.pe",
"bancoazteca.com.sv",
"bancobest.pt",
"bancobic.pt",
"bancobisel.com.ar",
"bancobpi.pt",
"bancochile.cl",
"bancodelbajio.com.mx",
"bancodevalencia.es",
"bancoestado.cl",
"bancoetcheverria.es",
"bancofinancieroydeahorros.com",
"bancofrances.com.ar",
"bancogalicia.com",
"bancoinbursa.com",
"bancomediolanum.es",
"bancomer.com",
"bancomer.com.mx",
"bancomext.com",
"bancoparis.cl",
"bancopastor.es",
"bancopatagonia.com.ar",
"bancopenta.cl",
"bancopopolare.it",
"bancopopular.es",
"bancopopular.pt",
"bancoripley.cl",
"bancosabadellmiami.com",
"bancovotorantim.com.br",
"bancsabadell.com",
"banesto.es",
"banif.pt",
"bank.lv",
"bankaustria.at",
"bankcomm.com",
"bankcoop.ch",
"bankia.com",
"bankia.es",
"bankinter.com",
"banklenz.de",
"banknh.com",
"banknordik.dk",
"banknorwegian.no",
"bankofamerica.com",
"bankofamerica.com.mx",
"bankofbaroda.com",
"bankofbotetourt.com",
"bankofcanada.ca",
"bankofcyprus.co.uk",
"bankofcyprus.com",
"bankofcyprus.com.cy",
"bankofcyprus.com.ua",
"bankofcyprus.gr",
"bankofcyprus.ro",
"bankofengland.co.uk",
"bankofhamptonroads.com",
"bankofindia.com",
"bankofireland.com",
"bankofireland.ie",
"bankofirelandmortgages.co.uk",
"bankofnc.com",
"bankofnevada.com",
"bankofscotland.co.uk",
"bankofscotland.nl",
"bankofsingapore.com",
"bankoncit.com",
"bankpime.es",
"banksa.com.au",
"banksterling.com",
"bankwest.ca",
"bankwest.com.au",
"bankzweiplus.ch",
"banorte-generali.com",
"banorte-ixe.com.mx",
"banorte.com",
"banque-france.fr",
"banque-pasche-group.com",
"banquedeluxembourg.com",
"banquedirecte.fr",
"banquehavilland.com",
"banqueinvik.se",
"banquepopulaire.fr",
"banregio.com",
"banxico.org.mx",
"bapro.com.ar",
"barcap.com",
"barclays.co.uk",
"barclays.com",
"barclays.pt",
"barclaysstockbrokers.co.uk",
"barclayswealth.com",
"barodanzltd.co.nz",
"bawagpsk.com",
"bayernlb.de",
"bb.com.br",
"bb.com.mx",
"bbk.es",
"bbva.com",
"bbva.com",
"bbva.pt",
"bbvacompass.com",
"bc.gov.br",
"bccbrescia.it",
"bcee.lu",
"bcentral.cl",
"bcf.ch",
"bcge.ch",
"bci.cl",
"bcimiami.com",
"bcl.lu",
"bcra.gov.ar",
"bcv.ch",
"bdc.ca",
"bde.es",
"bekb.ch",
"bendigoadelaide.com.au",
"bendigobank.com.au",
"bes.pt",
"best.pt",
"bgl.lu",
"bgz.pl",
"bib.eu",
"bib.lv",
"bil.com",
"binck.com",
"binck.nl",
"birchhillequity.com",
"bis.org",
"bkb.ch",
"bmedonline.es",
"bmedonline.it",
"bmn.es",
"bmo.com",
"bmocm.com",
"bna.com.ar",
"bnbank.no",
"bndes.gov.br",
"bnm.gov.my",
"bnpparibas.com",
"bnpparibas.com.ar",
"bnpparibasfortis.be",
"bnu.com.mo",
"bnymellon.com",
"bnz.co.nz",
"boc.cn",
"bocomny.com",
"boiusa.com",
"boj.or.jp",
"bok.or.kr",
"boq.com.au",
"boy.co.jp",
"bpb.it",
"bpce.fr",
"bpm.it",
"bpo.be",
"bportugal.pt",
"bpv.it",
"bradesco.com.br",
"bred.fr",
"bremerlandesbank.de",
"bridgewaterbank.ca",
"bridgewaterbankmn.com",
"britannia.co.uk",
"bsibank.com",
"bsp.com.fj",
"bsp.com.pg",
"bsp.com.sb",
"bundesbank.de",
"busanbank.co.kr",
"ca-cib.com",
"caisse-epargne.fr",
"caissedesdepots.fr",
"caixa.gov.br",
"caixabank.com",
"caixacapitalizacao.com.br",
"caixacatalunya.com",
"caixacultural.com.br",
"caixagalicia.es",
"caixaseguros.com.br",
"caixavidaeprevidencia.com.br",
"cajaespana-duero.es",
"cajamadrid.com",
"cam.es",
"canadiantire.ca",
"capitalone.ca",
"capitalone.com",
"carnegie.lu",
"carnegie.se",
"casden.fr",
"castlebank.com",
"catalunyacaixa.com",
"cbd.ae",
"cbonline.co.uk",
"cbscanterbury.co.nz",
"cbutah.com",
"ccb.com",
"ccbusa.com",
"cdb.com.cn",
"ceb.cz",
"cebbank.com",
"centralbankutah.com",
"cfm.mc",
"cfs.co.uk",
"cgd.pt",
"chibabank.co.jp",
"cibc.com",
"cic.com.sg",
"cic.fr",
"cimb-principal.com.my",
"cimb-principalislamic.com",
"cimb.com",
"cimbbank.com.kh",
"cimbbank.com.my",
"cimbbank.com.sg",
"cimbislamic.com",
"cimbniaga.com",
"cimbniagasyariah.com",
"cimbsecurities.com",
"cimbthai.com",
"cit.com",
"citi.co.nz",
"citi.com",
"citibanamex.com",
"citibank.ca",
"citibank.co.uk",
"citibank.com",
"citibank.com.sg",
"citicards.ca",
"citifinancial.ca",
"citizensbank.ca",
"citizensbank.com",
"citizensbankfx.ca",
"citynationalcm.com",
"claridenleu.com",
"cmb.mc",
"cmbc.com.cn",
"cmbchina.com",
"cnb.com",
"cnb.cz",
"co-operativebank.co.nz",
"co-operativebank.co.uk",
"co-operativebankinggroup.co.uk",
"co-operativeinsurance.co.uk",
"co-operativeinvestments.co.uk",
"coletaylor.com",
"comerica.com",
"commbank.com.au",
"commercebank.com",
"commerzbank.com",
"commerzbank.lu",
"compartamos.com",
"concorsimediolanum.it",
"consultorbancapersonal.es",
"corpbanca.cl",
"cpb.gr",
"credem.it",
"credit-agricole.com",
"credit-agricole.ro",
"credit-cooperatif.coop",
"credit-cooperatif.fr",
"credit-du-nord.fr",
"credit-suisse.com",
"crediteurope.be",
"crediteurope.ch",
"crediteurope.com.mt",
"crediteurope.com.ua",
"crediteurope.de",
"crediteurope.nl",
"crediteurope.ro",
"crediteurope.ru",
"crediteuropebank.com",
"crediteuropeleasing.ru",
"creditmobilierdemonaco.com",
"creditmutuel.fr",
"creditonebank.com",
"creditonefriends.com",
"crelan.be",
"cresco.no",
"csas.cz",
"csob.cz",
"ctfs.com",
"cwbank.com",
"cwbankgroup.com",
"danskebank.com",
"danskebank.ie",
"danskebank.lv",
"danskebank.no",
"danskebank.se",
"db.com",
"dbc.ca",
"dbs.com",
"dcbank.ca",
"dedhamsavings.com",
"degussa-bank.de",
"delagelanden.com",
"delen.lu",
"deutsche-bank.de",
"deutschebank.com",
"dexia-privatebanking.com",
"dexia.be",
"dgbfg.co.kr",
"dhbbank.com",
"dib.ae",
"directaccess.com.my",
"dkb.co.jp",
"dkb.de",
"dnb.lv",
"dnb.nl",
"dnb.no",
"dnbnor.com",
"dresdner-bank.com",
"duncanlawrie.com",
"dundeewealth.com",
"dvbbank.com",
"dz-privatbank.com",
"dzbank.com",
"e-private.com",
"easybank.at",
"ecitic.com",
"edmond-de-rothschild.com",
"edmond-de-rothschild.eu",
"efgbank.com",
"efggroup.com",
"efginternational.com",
"efirstbank.com",
"egg.com",
"ekspressbank.no",
"emiratesislamicbank.ae",
"emiratesnbd.com",
"emporiki.gr",
"ersteprivatebanking.at",
"esfg.com",
"eurobank.gr",
"eurohypo.com",
"europabank.be",
"expobank.eu",
"falconbank.com",
"falconnational.com",
"falconpb.com",
"falconprivatebank.com",
"familybanker.it",
"farmcreditbank.com",
"fbbank.gr",
"fgb.ae",
"fibabanka.com.tr",
"fih.dk",
"financenow.co.nz",
"fininvest.it",
"firstnational.com",
"firsttrustbank.co.uk",
"five-starbank.com",
"fnbc.ca",
"fnbk.com",
"fnbsd.com",
"fnni.com",
"fnsouthwest.com",
"fokus.no",
"fokus.no",
"forex.fi",
"forex.no",
"forex.se",
"forexbank.dk",
"forextrading.com",
"fortis.nl",
"fortuna.lu",
"freo.nl",
"frieslandbank.nl",
"fukuokabank.co.jp",
"gemoneybank.lv",
"generalbank.ca",
"generali.com",
"geniki.gr",
"gfgsa.com",
"gkb.ch",
"glkb.ch",
"golifestore.com",
"greatwesternbank.com",
"groupama.com",
"grupobancopopular.com",
"grupobancosabadell.com",
"gruppobancasella.it",
"gruppocarige.it",
"gruppoesperia.it",
"gruppovenetobanca.it",
"habibbank.com",
"halifax.co.uk",
"hanabank.com",
"handelsbanken.co.uk",
"handelsbanken.fi",
"handelsbanken.lv",
"handelsbanken.nl",
"handelsbanken.no",
"handelsbanken.se",
"handelsbanken.us",
"hbru.ru",
"hbsbank.co.nz",
"hbsnz.com",
"heartland.co.nz",
"helaba-invest.de",
"helaba-trust.de",
"helaba.de",
"hellenicbank.com",
"hellenicnetbanking.com",
"heritage.com.au",
"hipo.lv",
"hipotecario.com.ar",
"homequitybank.ca",
"hottinger.co.uk",
"hottinger.com",
"hottinger.lu",
"hsbc.ae",
"hsbc.ca",
"hsbc.cl",
"hsbc.co.in",
"hsbc.co.uk",
"hsbc.com",
"hsbc.com.ar",
"hsbc.com.br",
"hsbc.com.cn",
"hsbc.com.mx",
"hsbc.com.sg",
"hsbc.fr",
"hsbc.gr",
"hsbcprivatebankfrance.com",
"hsh-nordbank.com",
"hsh-nordbank.de",
"hxb.com.cn",
"hypo-alpe-adria.com",
"hypothekenbankfrankfurt.com",
"hypotirol.com",
"hypovbg.at",
"hypovereinsbank.de",
"ibk.co.kr",
"icbc.com.ar",
"icbc.com.cn",
"icicibank.com",
"ifsag.ch",
"ikano.co.uk",
"ikano.no",
"ikanobank.com",
"ikanobank.de",
"ikanobank.dk",
"ikanobank.fi",
"ikanobank.pl",
"ikanobank.se",
"ikanogroup.com",
"ikb.de",
"inbursa.com",
"inbursa.com.mx",
"inbweb.com",
"ing.be",
"ing.com",
"ingcasadebolsa.com",
"ingcommercialbanking.com",
"ingdirect.ca",
"ingdirect.com.au",
"inggrupofinanciero.com",
"intesasanpaolo.com",
"ipic.ae",
"irishlife.ie",
"irishlifepermanent.ie",
"isdb.org",
"itau.cl",
"itau.co.jp",
"itau.com",
"itau.com.ar",
"itau.com.br",
"itau.com.py",
"itau.com.uy",
"itauprivatebank.com",
"itausecurities.com",
"ixe.com.mx",
"jamesonbank.com",
"japanpost.jp",
"jbic.go.jp",
"jpmorganchase.com",
"jsafrasarasin.com",
"juliusbaer.com",
"juliusbaer.com",
"jyskebank.com",
"jyskebank.dk",
"kasbank.com",
"kb.cz",
"kbc.be",
"kbc.com",
"kbc.ie",
"kbc.ie",
"kbstar.com",
"kdb.co.kr",
"keb.co.kr",
"kempen.nl",
"key.com",
"keytradebank.com",
"keytradebank.nl",
"kfw.de",
"kiwibank.co.nz",
"kjbank.com",
"kommunalkredit.at",
"kutxa.net",
"kutxabank.es",
"kyotobank.co.jp",
"labanquepostale.fr",
"lacaixa.com",
"laconiasavings.com",
"landbobanken.dk",
"landkreditt.no",
"landkredittbank.no",
"laposte.fr",
"lasergroup.eu",
"laurentianbank.com",
"lbb.de",
"lbb.lv",
"lbbw.de",
"lbbw.lu",
"lblux.lu",
"lcl.com",
"lgt-capital-partners.com",
"lgt.com",
"liberbank.es",
"libertyhomefinancial.com",
"lkb.lv",
"lloydsbankinggroup.com",
"lloydstsb.com",
"lombardodier.com",
"lukb.ch",
"lutherburbanksavings.com",
"macquarie.com.au",
"macro.com.ar",
"mangroupplc.com",
"manulife.com",
"manulifebank.ca",
"marac.co.nz",
"martinmaurel.com",
"mas.gov.sg",
"mashreqbank.com",
"maybank.com.my",
"maybank2u.com.sg",
"mbfinancial.com",
"mbna.ca",
"mediobanca.it",
"mediolanum.com",
"mediolanum.it",
"mediolanumcorporateuniversity.it",
"mediolanumgestionefondi.it",
"mediolanuminternationalfunds.it",
"mediolanuminternationallife.it",
"mediolanumprimafila.it",
"mediolanumprivatebanker.it",
"mediolanumresidence.it",
"mediolanumvita.it",
"meespierson.an",
"meespierson.nl",
"meigin.com",
"mercantildobrasil.com.br",
"millenniumbank.gr",
"millenniumbcp.pt",
"mizuho-fg.co.jp",
"mmwarburg.lu",
"moncana.com",
"monex.com.mx",
"monteparma.it",
"montepaschi.be",
"montepio.pt",
"morganstanley.com",
"mps.it",
"mufg.jp",
"myctfs.com",
"mywealthcareonline.com",
"nab.com.au",
"nabgroup.com",
"nantobank.co.jp",
"naspadub.ie",
"nationalbank.co.nz",
"nationalirishbank.ie",
"nationalirishbank.ie",
"nationwide.co.uk",
"nationwideinternational.com",
"natixis.com",
"natwest.com",
"nbad.com",
"nbb.be",
"nbc.ca",
"nbg.gr",
"newyorkcommercialbank.com",
"nibc.nl",
"nkb.ch",
"nochubank.or.jp",
"nomura.com",
"nomuraholdings.com",
"nonghyup.com",
"noorbank.com",
"noorinternetbanking.com",
"nordea.com",
"nordea.dk",
"nordea.lu",
"nordea.lv",
"nordea.no",
"nordeaprivatebanking.no",
"nordlandsbanken.no",
"nordlb.com",
"nordlb.de",
"norges-bank.no",
"northernbank.co.uk",
"norvik.lv",
"norwaysavingsbank.com",
"nossacaixa.com.br",
"novacaixagalicia.es",
"nrsbank.dk",
"nykredit.com",
"nykredit.dk",
"oberbank.at",
"obvion.nl",
"ocbc.com",
"oddo.eu",
"oddo.fr",
"oekb.at",
"oenb.at",
"oest.no",
"oitabank.co.jp",
"orbay.nl",
"pacecu.ca",
"panelliniabank.gr",
"pasche.ch",
"passbanca.it",
"patria-finance.com",
"pbebank.com",
"pbgate.net",
"pcfinancial.ca",
"permanenttsb.ie",
"permanenttsbgroup.ie",
"pggwrightsonfinance.co.nz",
"pictet.com",
"pioneerbnk.com",
"pioneerelpaso.com",
"pioneermidland.com",
"pioneersb.com",
"piraeusbank.gr",
"pnc.com",
"postbank.com",
"previred.com",
"probank.gr",
"proton.gr",
"psbc.com",
"psd-berlin-brandenburg.de",
"puertoricofarmcredit.com",
"pwbank.com",
"rabobank.be",
"rabobank.co.nz",
"rabodirect.co.nz",
"rabovastgoedgroep.nl",
"raiffeisen.ch",
"raiffeisen.lu",
"rakbank.ae",
"rakbankdirect.ae",
"rakbankonline.ae",
"rb.cz",
"rba.gov.au",
"rbc.com",
"rbcadvicecentre.com",
"rbcbank.com",
"rbccm.com",
"rbcdirectinvesting.com",
"rbcds.com",
"rbcgam.com",
"rbcinsurance.com",
"rbcis.com",
"rbcroyalbank.com",
"rbcwealthmanagement.com",
"rbcwminternational.com",
"rbnz.govt.nz",
"rbs.co.uk",
"rbs.com",
"rbs.nl",
"regiobank.nl",
"regions.com",
"reliancebank.com",
"rembrandt-fo.nl",
"resona-gr.co.jp",
"reverta.lv",
"rhb.com.my",
"rhbbank.com.sg",
"rietumu.com",
"riksbank.se",
"riyadbank.com",
"riyadbank.com.sa",
"robeco.com",
"robeco.fr",
"rothschild.com",
"rothschildbank.com",
"ruralvia.com",
"rzb.at",
"saarlb.de",
"sabb.com",
"sabbtakaful.com",
"sabinebank.com",
"safra.com.br",
"sagabank.co.jp",
"saib.com",
"salliemae.com",
"samba.com",
"sampopankki.fi",
"sanostra.es",
"santander.cl",
"santander.co.uk",
"santander.com",
"santander.com.br",
"santander.com.mx",
"santander.no",
"santanderconsumer.com",
"santanderrio.com.ar",
"santandertotta.pt",
"sarasin.ch",
"sarasin.com",
"saxobank.com",
"saxoprivatbank.com",
"saxoworld.com",
"sberbankcz.cz",
"sbi.co.in",
"sbiuk.com",
"sbs.net.nz",
"sbsbank.co.nz",
"schoellerbank.at",
"schretlen.com",
"schroders.com",
"scotiabank.cl",
"scotiabank.com",
"seb.lv",
"seb.se",
"sebgroup.com",
"securitybankkc.com",
"segurosbanamex.com.mx",
"segurosinbursa.com.mx",
"sella.it",
"sgkb.ch",
"sgkb.ch",
"sgkb.de",
"shb.com.sa",
"shinhan.com",
"shinseibank.com",
"sib.ae",
"skandiabanken.no",
"skandiabanken.se",
"smfg.co.jp",
"smile.co.uk",
"smn.no",
"smpbank.com",
"smpbank.lv",
"smpbank.ru",
"snb.ch",
"snci.lu",
"snsreaal.nl",
"societegenerale.com",
"societegenerale.fr",
"societegenerale.mc",
"sofinco.com",
"southsure.co.nz",
"spaengler.at",
"sparda-b.de",
"sparebank1.no",
"sparkron.dk",
"sparlolland.dk",
"sparnord.dk",
"spks.dk",
"spv.no",
"sr-bank.no",
"standardchartered.ae",
"standardchartered.co.th",
"standardchartered.co.za",
"standardchartered.com",
"standardchartered.com.cn",
"standardchartered.com.hk",
"standardchartered.com.my",
"standardchartered.com.sg",
"standardlife.ca",
"standardlife.co.uk",
"standardlife.com",
"standardlifeinvestments.com",
"standardlifewealth.com",
"statebankofindia.com",
"statestreet.com",
"steiermaerkische.at",
"sterlingfinancialcorporation-spokane.com",
"sterlingsavingsbank.com ",
"stgeorge.com.au",
"storebrand.no",
"suncorp.com.au",
"suncorpbank.com.au",
"suntrust.com",
"svb.com",
"swedbank.lv",
"swedbank.se",
"swissbanking.org",
"sydbank.dk",
"tarjetanaranja.com",
"tbank.com.gr",
"td.com",
"tdcanadatrust.com",
"tesco.com",
"tescobank.com",
"texasbankandtrust.com",
"texascapitalbank.com",
"tkb.ch",
"tkb.lv",
"totalbank.com",
"tradingfloor.com",
"triodos.co.uk",
"triodos.com",
"triodos.nl",
"tsb.co.nz",
"tsbrealty.co.nz",
"tsbtrust.org.nz",
"ttbank.gr",
"uab.ae",
"ubibanca.it",
"ubp.com",
"ubpbank.com",
"ubs.com",
"ulsterbank.co.uk",
"ulsterbank.com",
"ulsterbank.ie",
"unb.com",
"unicaja.es",
"unico.nl",
"unicreditbank.cz",
"unicreditbank.ie",
"unicreditbank.lv",
"unicreditgroup.eu",
"unionbank.com",
"uobgroup.com",
"usaa.com",
"usbank.com",
"usbankcanada.com",
"vanlanschot.com",
"vanlanschot.nl",
"vatican.va",
"vbi.at",
"vekselbanken.no",
"venetobanca.it",
"vestjyskbank.dk",
"video.saxobank.com",
"vontobel.com",
"vpbank.com",
"vpbank.lu",
"wachovia.com",
"wachoviasec.com",
"wellsfargo.com",
"westpac.co.nz",
"westpac.com.au",
"wgzbank.ie",
"wilshirebank.com",
"wir.ch",
"wooribank.com",
"wwsparbank.se",
"ya.no",
"ybonline.co.uk",
"zkb.ch",
"zugerkb.ch"
};
const int kEnableJavaByDefaultForTheseDomainsLength =
sizeof(kEnableJavaByDefaultForTheseDomains) /
sizeof(kEnableJavaByDefaultForTheseDomains[0]);
} // namespace
// PluginObserver -------------------------------------------------------------
#if defined(ENABLE_PLUGIN_INSTALLATION)
class PluginObserver::PluginPlaceholderHost : public PluginInstallerObserver {
public:
PluginPlaceholderHost(PluginObserver* observer,
int routing_id,
string16 plugin_name,
PluginInstaller* installer)
: PluginInstallerObserver(installer),
observer_(observer),
routing_id_(routing_id) {
DCHECK(installer);
switch (installer->state()) {
case PluginInstaller::INSTALLER_STATE_IDLE: {
observer->Send(new ChromeViewMsg_FoundMissingPlugin(routing_id_,
plugin_name));
break;
}
case PluginInstaller::INSTALLER_STATE_DOWNLOADING: {
DownloadStarted();
break;
}
}
}
// PluginInstallerObserver methods:
virtual void DownloadStarted() OVERRIDE {
observer_->Send(new ChromeViewMsg_StartedDownloadingPlugin(routing_id_));
}
virtual void DownloadError(const std::string& msg) OVERRIDE {
observer_->Send(new ChromeViewMsg_ErrorDownloadingPlugin(routing_id_, msg));
}
virtual void DownloadCancelled() OVERRIDE {
observer_->Send(new ChromeViewMsg_CancelledDownloadingPlugin(routing_id_));
}
virtual void DownloadFinished() OVERRIDE {
observer_->Send(new ChromeViewMsg_FinishedDownloadingPlugin(routing_id_));
}
private:
// Weak pointer; owns us.
PluginObserver* observer_;
int routing_id_;
};
#endif // defined(ENABLE_PLUGIN_INSTALLATION)
PluginObserver::PluginObserver(content::WebContents* web_contents)
: content::WebContentsObserver(web_contents),
ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) {
}
PluginObserver::~PluginObserver() {
#if defined(ENABLE_PLUGIN_INSTALLATION)
STLDeleteValues(&plugin_placeholders_);
#endif
}
void PluginObserver::PluginCrashed(const FilePath& plugin_path) {
DCHECK(!plugin_path.value().empty());
string16 plugin_name =
PluginService::GetInstance()->GetPluginDisplayNameByPath(plugin_path);
gfx::Image* icon = &ResourceBundle::GetSharedInstance().GetNativeImageNamed(
IDR_INFOBAR_PLUGIN_CRASHED);
InfoBarTabHelper* infobar_helper =
InfoBarTabHelper::FromWebContents(web_contents());
infobar_helper->AddInfoBar(
new SimpleAlertInfoBarDelegate(
infobar_helper,
icon,
l10n_util::GetStringFUTF16(IDS_PLUGIN_CRASHED_PROMPT, plugin_name),
true));
}
bool PluginObserver::OnMessageReceived(const IPC::Message& message) {
IPC_BEGIN_MESSAGE_MAP(PluginObserver, message)
IPC_MESSAGE_HANDLER(ChromeViewHostMsg_BlockedOutdatedPlugin,
OnBlockedOutdatedPlugin)
IPC_MESSAGE_HANDLER(ChromeViewHostMsg_BlockedUnauthorizedPlugin,
OnBlockedUnauthorizedPlugin)
#if defined(ENABLE_PLUGIN_INSTALLATION)
IPC_MESSAGE_HANDLER(ChromeViewHostMsg_FindMissingPlugin,
OnFindMissingPlugin)
IPC_MESSAGE_HANDLER(ChromeViewHostMsg_RemovePluginPlaceholderHost,
OnRemovePluginPlaceholderHost)
#endif
IPC_MESSAGE_HANDLER(ChromeViewHostMsg_OpenAboutPlugins,
OnOpenAboutPlugins)
IPC_MESSAGE_HANDLER(ChromeViewHostMsg_CouldNotLoadPlugin,
OnCouldNotLoadPlugin)
IPC_MESSAGE_HANDLER(ChromeViewHostMsg_NPAPINotSupported,
OnNPAPINotSupported)
IPC_MESSAGE_UNHANDLED(return false)
IPC_END_MESSAGE_MAP()
return true;
}
void PluginObserver::OnBlockedUnauthorizedPlugin(
const string16& name,
const std::string& identifier) {
std::string name_utf8 = UTF16ToUTF8(name);
if (name_utf8 == PluginMetadata::kJavaGroupName) {
content::WebContents* contents = web_contents();
if (contents) {
GURL url = contents->GetURL();
for (int i = 0; i < kEnableJavaByDefaultForTheseDomainsLength; i++) {
if (url.DomainIs(kEnableJavaByDefaultForTheseDomains[i])) {
contents->Send(new ChromeViewMsg_LoadBlockedPlugins(
contents->GetRoutingID(), identifier));
return;
}
}
}
}
InfoBarTabHelper* infobar_helper =
InfoBarTabHelper::FromWebContents(web_contents());
infobar_helper->AddInfoBar(
new UnauthorizedPluginInfoBarDelegate(
infobar_helper,
Profile::FromBrowserContext(web_contents()->GetBrowserContext())->
GetHostContentSettingsMap(),
name, identifier));
}
void PluginObserver::OnBlockedOutdatedPlugin(int placeholder_id,
const std::string& identifier) {
#if defined(ENABLE_PLUGIN_INSTALLATION)
PluginFinder* finder = PluginFinder::GetInstance();
// Find plugin to update.
PluginInstaller* installer = NULL;
scoped_ptr<PluginMetadata> plugin;
if (!finder->FindPluginWithIdentifier(identifier, &installer, &plugin)) {
NOTREACHED();
return;
}
plugin_placeholders_[placeholder_id] =
new PluginPlaceholderHost(this, placeholder_id,
plugin->name(), installer);
InfoBarTabHelper* infobar_helper =
InfoBarTabHelper::FromWebContents(web_contents());
infobar_helper->AddInfoBar(
OutdatedPluginInfoBarDelegate::Create(web_contents(),
installer, plugin.Pass()));
#else
// If we don't support third-party plug-in installation, we shouldn't have
// outdated plug-ins.
NOTREACHED();
#endif // defined(ENABLE_PLUGIN_INSTALLATION)
}
#if defined(ENABLE_PLUGIN_INSTALLATION)
void PluginObserver::OnFindMissingPlugin(int placeholder_id,
const std::string& mime_type) {
std::string lang = "en-US"; // Oh yes.
scoped_ptr<PluginMetadata> plugin_metadata;
PluginInstaller* installer = NULL;
bool found_plugin = PluginFinder::GetInstance()->FindPlugin(
mime_type, lang, &installer, &plugin_metadata);
if (!found_plugin) {
Send(new ChromeViewMsg_DidNotFindMissingPlugin(placeholder_id));
return;
}
DCHECK(installer);
DCHECK(plugin_metadata.get());
plugin_placeholders_[placeholder_id] =
new PluginPlaceholderHost(this, placeholder_id,
plugin_metadata->name(),
installer);
PluginInstallerInfoBarDelegate::InstallCallback callback =
base::Bind(&PluginObserver::InstallMissingPlugin,
weak_ptr_factory_.GetWeakPtr(), installer);
InfoBarTabHelper* infobar_helper =
InfoBarTabHelper::FromWebContents(web_contents());
InfoBarDelegate* delegate;
#if !defined(OS_WIN)
delegate = PluginInstallerInfoBarDelegate::Create(
infobar_helper, installer, plugin_metadata.Pass(), callback);
#else
delegate = base::win::IsMetroProcess() ?
new PluginMetroModeInfoBarDelegate(
infobar_helper,
l10n_util::GetStringFUTF16(IDS_METRO_MISSING_PLUGIN_PROMPT,
plugin_metadata->name()),
l10n_util::GetStringUTF16(IDS_WIN8_DESKTOP_RESTART),
GURL("https://support.google.com/chrome/?p=ib_display_in_desktop"),
false) :
PluginInstallerInfoBarDelegate::Create(
infobar_helper, installer, plugin_metadata.Pass(), callback);
#endif
infobar_helper->AddInfoBar(delegate);
}
void PluginObserver::InstallMissingPlugin(
PluginInstaller* installer,
const PluginMetadata* plugin_metadata) {
if (plugin_metadata->url_for_display()) {
installer->OpenDownloadURL(plugin_metadata->plugin_url(), web_contents());
} else {
TabModalConfirmDialog::Create(
new ConfirmInstallDialogDelegate(
web_contents(), installer, plugin_metadata->Clone()),
web_contents());
}
}
void PluginObserver::OnRemovePluginPlaceholderHost(int placeholder_id) {
std::map<int, PluginPlaceholderHost*>::iterator it =
plugin_placeholders_.find(placeholder_id);
if (it == plugin_placeholders_.end()) {
NOTREACHED();
return;
}
delete it->second;
plugin_placeholders_.erase(it);
}
#endif // defined(ENABLE_PLUGIN_INSTALLATION)
void PluginObserver::OnOpenAboutPlugins() {
web_contents()->OpenURL(OpenURLParams(
GURL(chrome::kAboutPluginsURL),
content::Referrer(web_contents()->GetURL(),
WebKit::WebReferrerPolicyDefault),
NEW_FOREGROUND_TAB, content::PAGE_TRANSITION_AUTO_BOOKMARK, false));
}
void PluginObserver::OnCouldNotLoadPlugin(const FilePath& plugin_path) {
g_browser_process->metrics_service()->LogPluginLoadingError(plugin_path);
string16 plugin_name =
PluginService::GetInstance()->GetPluginDisplayNameByPath(plugin_path);
InfoBarTabHelper* infobar_helper =
InfoBarTabHelper::FromWebContents(web_contents());
infobar_helper->AddInfoBar(new SimpleAlertInfoBarDelegate(
infobar_helper,
&ResourceBundle::GetSharedInstance().GetNativeImageNamed(
IDR_INFOBAR_PLUGIN_CRASHED),
l10n_util::GetStringFUTF16(IDS_PLUGIN_INITIALIZATION_ERROR_PROMPT,
plugin_name),
true /* auto_expire */));
}
void PluginObserver::OnNPAPINotSupported(const std::string& identifier) {
#if defined(OS_WIN) && defined(ENABLE_PLUGIN_INSTALLATION)
DCHECK(base::win::IsMetroProcess());
Profile* profile =
Profile::FromBrowserContext(web_contents()->GetBrowserContext());
if (profile->IsOffTheRecord())
return;
HostContentSettingsMap* content_settings =
profile->GetHostContentSettingsMap();
if (content_settings->GetContentSetting(
web_contents()->GetURL(),
web_contents()->GetURL(),
CONTENT_SETTINGS_TYPE_METRO_SWITCH_TO_DESKTOP,
std::string()) == CONTENT_SETTING_BLOCK)
return;
scoped_ptr<PluginMetadata> plugin;
if (!PluginFinder::GetInstance()->FindPluginWithIdentifier(
identifier, NULL, &plugin)) {
NOTREACHED();
return;
}
InfoBarTabHelper* infobar_helper =
InfoBarTabHelper::FromWebContents(web_contents());
infobar_helper->AddInfoBar(
new PluginMetroModeInfoBarDelegate(
infobar_helper,
l10n_util::GetStringFUTF16(IDS_METRO_NPAPI_PLUGIN_PROMPT,
plugin->name()),
l10n_util::GetStringUTF16(IDS_WIN8_RESTART),
GURL("https://support.google.com/chrome/?p=ib_redirect_to_desktop"),
true));
#else
NOTREACHED();
#endif
}
|
.global s_prepare_buffers
s_prepare_buffers:
push %r14
push %r15
push %rbp
push %rcx
push %rdi
push %rsi
lea addresses_D_ht+0x1934d, %rdi
add $30536, %rcx
mov (%rdi), %r15w
nop
nop
nop
nop
nop
add $42299, %rbp
lea addresses_WT_ht+0x7b9b, %rsi
lea addresses_D_ht+0x8dbf, %rdi
nop
sub %r14, %r14
mov $53, %rcx
rep movsw
nop
nop
nop
nop
cmp $53086, %rdi
pop %rsi
pop %rdi
pop %rcx
pop %rbp
pop %r15
pop %r14
ret
.global s_faulty_load
s_faulty_load:
push %r11
push %r13
push %r15
push %r8
push %rax
push %rcx
push %rdi
push %rsi
// Store
lea addresses_normal+0x1c769, %r11
clflush (%r11)
nop
nop
xor %r15, %r15
mov $0x5152535455565758, %r13
movq %r13, %xmm1
vmovups %ymm1, (%r11)
nop
nop
nop
cmp %rdi, %rdi
// Store
lea addresses_D+0x153e9, %rcx
and %r8, %r8
mov $0x5152535455565758, %rax
movq %rax, %xmm2
vmovups %ymm2, (%rcx)
nop
nop
nop
nop
dec %rcx
// Store
lea addresses_D+0x17fd1, %r13
nop
nop
nop
xor $31992, %r11
movw $0x5152, (%r13)
nop
nop
nop
cmp $2317, %rax
// REPMOV
lea addresses_UC+0x16ac9, %rsi
lea addresses_UC+0x1d1e9, %rdi
clflush (%rdi)
nop
dec %rax
mov $75, %rcx
rep movsq
and $35840, %rdi
// Store
lea addresses_WT+0xd669, %r15
nop
nop
nop
nop
nop
add %rdi, %rdi
movw $0x5152, (%r15)
nop
nop
nop
nop
nop
add %r13, %r13
// Store
lea addresses_D+0x15399, %rsi
nop
nop
nop
nop
nop
and %r13, %r13
movw $0x5152, (%rsi)
nop
nop
nop
add $42599, %rax
// Store
mov $0x969, %rax
nop
nop
nop
nop
nop
cmp %r8, %r8
movl $0x51525354, (%rax)
nop
nop
nop
xor $29665, %r11
// Faulty Load
mov $0x3267e20000000f69, %rcx
clflush (%rcx)
nop
nop
nop
nop
nop
xor %rsi, %rsi
mov (%rcx), %r13
lea oracles, %r8
and $0xff, %r13
shlq $12, %r13
mov (%r8,%r13,1), %r13
pop %rsi
pop %rdi
pop %rcx
pop %rax
pop %r8
pop %r15
pop %r13
pop %r11
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_NC', 'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 0}}
{'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_normal', 'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 11}}
{'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_D', 'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 7}}
{'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_D', 'NT': True, 'AVXalign': False, 'size': 2, 'congruent': 1}}
{'OP': 'REPM', 'src': {'same': False, 'congruent': 4, 'type': 'addresses_UC'}, 'dst': {'same': True, 'congruent': 4, 'type': 'addresses_UC'}}
{'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_WT', 'NT': False, 'AVXalign': True, 'size': 2, 'congruent': 7}}
{'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_D', 'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 4}}
{'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_P', 'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 8}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'same': True, 'type': 'addresses_NC', 'NT': False, 'AVXalign': False, 'size': 8, 'congruent': 0}}
<gen_prepare_buffer>
{'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_D_ht', 'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 1}}
{'OP': 'REPM', 'src': {'same': False, 'congruent': 0, 'type': 'addresses_WT_ht'}, 'dst': {'same': False, 'congruent': 0, 'type': 'addresses_D_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
*/
|
; Provided under the MIT License: http://mit-license.org/
; Copyright (c) 2020 Andrew Kallmeyer <ask@ask.systems>
%define SECTOR_SIZE 0x200
; Segment register value (so the actual start is at the address 0x10*this)
; This is the first sector after the editor's code
%define USER_CODE_LOC (CODE_SEGMENT+(SECTOR_SIZE/0x10)*(NUM_EXTRA_SECTORS+1))
; Max value for di and si in typing_loop (i.e. the user code buffer)
;
; There's a lot of extra memory still after this but I don't want to move around
; the segment register so this is the limit.
;
; Allows 64k of code
%define USER_CODE_MAX 0xFFFF
; Values in ax after the keyboard read BIOS call
; See Figure 4-3 of the 1987 BIOS manual. (page 195)
%define LEFT_ARROW 0x4B00
%define RIGHT_ARROW 0x4D00
%define EOT 0x2004 ; Ctrl+D
%define MAIN_COLOR 0x17
%define BORDER_COLOR 0x91
%define MAIN_TOP_LEFT 0x0210 ; row = 2, col = 16
%define MAIN_BOTTOM_RIGHT 0x163F ; row = 22, col = 79-16
%define START_ROW 0x02
%define START_COL 0x10
%define END_ROW 0x16
%define END_COL 0x3F
%define LINE_NUM_TOP_LEFT 0x020B ; row = 2, col = 11
%define LINE_NUM_BOTTOM_RIGHT 0x160F ; row = 22, col = 15
%define LINE_NUM_COL 0x0B
; Bitfield values for ch in typing_loop
%define CURSOR_ON_SECOND_NIBBLE 0b01
%define SAVED_NIBBLE_AT_END 0b10
%include "util/bootsect-header.asm"
mov [BOOT_DISK], dl ; Save the boot disk number
; Set video mode, 16 color 80x25 chars
;
; The IBM BIOS manual describes a long procedure for determining which video
; modes are supported and all the possible options for supporting both mono and
; color. Sometimes mono isn't supported if the PC supports color modes. So, I'm
; just going to assume all modern hardware supports color modes.
mov ax, 0x0003
int 0x10
; Make the 8th bit of the colors bg-intensity instead of blink
mov ax, 0x1003
mov bl, 0
int 0x10
; Make the 4th bit of the colors fg-intensity instead of font selection
; Use block 0 for the font
; Apparently this is the default in VGA so maybe we don't need it
mov ax, 0x1103
mov bl, 0
int 0x10
; Color byte is: bg-intensity,bg-r,bg-g,bg-b ; fg-intensity,fg-r,fg-g,fg-b
; Set cursor shape to an underline
mov ax, 0x0100
mov cx, 0x0607
int 0x10
; Set the border color (by clearing the whole screen)
mov ax, 0x0600
xor cx, cx ; row = 0, col = 0
mov dx, 0x184F ; row = 24, col = 79
mov bh, BORDER_COLOR
int 0x10
; Set the background color (by clearing just the middle)
;mov ax, 0x0600
mov cx, MAIN_TOP_LEFT
mov dx, MAIN_BOTTOM_RIGHT
mov bh, MAIN_COLOR
int 0x10
; Set the keyboard repeat speed
mov ax, 0x0305
;mov bx, 0x0107 ; 500 ms delay before repeat ; 16 characters per second
mov bx, 0x0100 ; 500 ms delay before repeat ; 30 characters per second
int 0x16
; Load the code from the extra sectors
mov ah, 0x02
mov al, NUM_EXTRA_SECTORS
mov bx, SECTOR_SIZE ; es:bx is address to write to. es = cs, so write directly after the boot sector
mov cx, 0x0002 ; Cylinder 0; Sector 2 (1 is the boot sector)
mov dl, [BOOT_DISK]
xor dh, dh ; Head 0
int 0x13
; Check for errors
cmp ax, NUM_EXTRA_SECTORS
je start_
push ax ; push the error code
; Print the error message
mov ax, 0x1301 ; Write String, move cursor mode in al
mov bp, error_msg ; String pointer in es:bp (es is at code start from bootsect-header.asm)
mov cx, error_msg_len ; String length
mov dx, MAIN_TOP_LEFT
mov bx, MAIN_COLOR ; bh = 0 (page number); bl = color
int 0x10
pop cx ; pop the error code
call print_hex ; print the error code
jmp $ ; stop forever
; Prints the ascii hex character which represents the integer value of al
; Only accepts 0x0 <= al <= 0xF, anything else is garbage output
; e.g. al = 12 prints "C"
; clobbers ax, and bx
print_hex_char:
mov ah, 0x0E
xor bx, bx
; fallthrough
; Also assumes ah = 0x0E and bx = 0
_print_hex_char:
cmp al, 9
ja .over_9
add al, '0'
int 0x10
ret
.over_9:
sub al, 10
add al, 'A'
int 0x10
ret
; cx = two bytes to write at current cursor
; clobbers ax, and bx
print_hex:
mov ah, 0x0E ; Scrolling teletype BIOS routine (used with int 0x10)
xor bx, bx ; Clear bx. bh = page, bl = color
; Nibble 0 (most significant)
mov al, ch
shr al, 4
call _print_hex_char
; Nibble 1
mov al, ch
and al, 0x0F
call _print_hex_char
; Nibble 2
mov al, cl
shr al, 4
call _print_hex_char
; Nibble 3
mov al, cl
and al, 0x0F
call _print_hex_char
ret
error_msg: db `Error reading additional sectors from disk: `
error_msg_len: equ $-error_msg
BOOT_DISK: db 0x00 ; value is filled first thing
%include "util/bootsect-footer.asm"
; This is also the start for calculating NUM_EXTRTA_SECTORS
; There must be nothing other than the bootsector above this label
start_:
; Print the starting greeting
mov ax, 0x1301 ; Write String, move cursor mode in al
mov bx, BORDER_COLOR ; bh = 0 (page number); bl = color
mov bp, greeting ; String pointer in es:bp (es is at code start from bootsect-header.asm)
mov cx, greeting_len ; Streng length
mov dx, 0x0010 ; row = 0, col = 16
int 0x10
; Print the row header (column byte numbers)
mov bp, row_header ; String pointer in es:bp
mov cx, row_header_len ; Streng length
mov dx, 0x0110 ; row = 1, col = 16
int 0x10
; Print the run instructions
mov bp, run_instr ; String pointer in es:bp
mov cx, run_instr_len ; Streng length
mov dx, 0x1710 ; row = END_ROW+1, col = 16
int 0x10
; Move the cursor for printing the code segment location
mov dh, START_ROW
mov dl, LINE_NUM_COL-4-1 ; Space for "FFFF:"
mov ax, 0x0200
xor bh, bh
int 0x10
; Print the USER_CODE_LOC
mov cx, USER_CODE_LOC
call print_hex
; Print the ":"
mov ah, 0x0E
mov al, ':'
xor bh, bh
int 0x10
; Print the line numbers
; cx = full address for user code
xor cx, cx
print_line_nums:
; Move the cursor to the next line number position
mov ax, 0x0200
xor bh, bh
mov dl, LINE_NUM_COL
int 0x10
call print_hex ; print cx
add cx, 0x10 ; Add 16 bytes to the line number
inc dh ; Add one row to the cursor
cmp dh, END_ROW+1
jne print_line_nums
; Set cursor position to the start
mov ax, 0x0200
mov dx, MAIN_TOP_LEFT
xor bh, bh ; page 0
int 0x10
; --- typing_loop global register variables ---
;
; dx - cursor position (set above)
; [es:di] - the current position to write to in the user code buffer (di=0 is the beginning)
; [es:si] - the end of the user code buffer (will possibly be only half a byte)
; cl - storage for the current byte the cursor is on (2 chars per byte)
; ch - bitfield for state flags about half-bytes (CURSOR_ON_SECOND_NIBBLE | SAVED_NIBBLE_AT_END)
mov ax, USER_CODE_LOC
mov es, ax
xor di, di
xor si, si
xor cx, cx
; Note: all of the jumps in typing_loop loop back here (except for run_code)
;
; I thought it would be fun to save the call and ret instructions since the
; entire program is just this loop (after the setup).
typing_loop:
; Read keyboard
mov ah, 0x00
int 0x16
; ah = key code, al = ascii value
; For the consecutive range checks below, we save an add instruction by
; doing a bit of algebra and packing it into the next sub instruction
; (letting the assembler do the work statically).
sub al, 'a'
cmp al, 'f'-'a'
jbe save_and_print_hex_letter ; jump if al is between 'a' and 'f'
sub al, 'A'-'a' ; -'a' compensates for the sub al, 'a' instruction above
cmp al, 'F'-'A'
jbe save_and_print_hex_letter
sub al, '0'-'A'
cmp al, '9'-'0'
jbe save_and_print_hex_number
add al, '0' ; We're done with the range checks so we don't need the offset
cmp al, `\b` ; Backspace, shift backspace, Ctrl+H
je move_left
cmp ax, LEFT_ARROW
je move_left
cmp ax, RIGHT_ARROW
je move_right
cmp ax, EOT ; Ctrl+D
je run_code
jmp typing_loop ; Doesn't match anything above
; ==== typing_loop internal helpers ===
; Takes an ascii char A-F in al then saves and prints it and continues typing_loop
save_and_print_hex_letter:
mov bl, al
add bl, 0xA ; bl = nibble value (al = 0x0 if input was 'A' or 'a')
add al, 'A' ; al = the character to print
jmp _save_and_print_nibble
; Takes an ascii char 0-9 in al then saves and prints it and continues typing_loop
save_and_print_hex_number:
mov bl, al ; bl = nibble value
add al, '0' ; al = the character to print
; fallthrough
; Takes a nibble value in bl and ascii hex character in al
; then saves and prints it and continues typing_loop
_save_and_print_nibble:
; Print the nibble ascii char (in al)
mov ah, 0x0E ; Write teletype character
xor bh, bh ; Note: cannot clear bl here
int 0x10
test ch, CURSOR_ON_SECOND_NIBBLE
jnz .save_second_nibble
; .save_first_nibble
shl bl, 4 ; Move the nibble into the high half
and cl, 0x0F ; Clear the high half of the temp byte
or cl, bl ; Put the nibble into the high half of cl
cmp di, si
jne move_right ; move_right if it's not the end
; If we're at the end, mark the bit that we have a nibble
or ch, SAVED_NIBBLE_AT_END
jmp move_right
.save_second_nibble:
; Save the byte
and cl, 0xF0 ; clear the low half of the temp byte
or cl, bl ; put the nibble in the low half of the temp byte
cmp di, si
jne move_right ; move_right if we're not at the end
; If we're at the end
cmp si, USER_CODE_MAX
je typing_loop
inc si ; move the end of the buffer forward so we can move the cursor (only user typing can do this)
and ch, ~SAVED_NIBBLE_AT_END ; Clear the bit, we don't have a nibble anymore
jmp move_right
; Moves the cursor to the value in dx and continues typing_loop
set_cursor_and_continue:
mov ah, 0x02
xor bh, bh
int 0x10 ; dx is the cursor position
jmp typing_loop
; Moves the cursor left one nibble then continues typing_loop
; - Saves the byte in cl when moving to a new byte, also loads the existing
; data into cl if applicable
; - Calls move_up when moving to the next line
move_left:
test ch, CURSOR_ON_SECOND_NIBBLE
jz .previous_byte
; We're moving left past the first nibble of a byte,
; never need to change lines because of this
and ch, ~CURSOR_ON_SECOND_NIBBLE
dec dl
jmp set_cursor_and_continue
.previous_byte:
; Don't do anything if we're already at the beginning of the buffer
test di, di
jz typing_loop
or ch, CURSOR_ON_SECOND_NIBBLE ; We stepped past the second nibble
; store the temp byte in the destination memory
mov [es:di], cl
dec di
mov cl, [es:di] ; Load the previous byte
cmp dl, 0x29 ; Column of the first char of the 9th byte
je .extra_space
cmp dl, START_COL
je .previous_line
; Normal case, the char plus 1 space
sub dl, 2
jmp set_cursor_and_continue
.extra_space: ; Move past the two spaces in the middle
sub dl, 3
jmp set_cursor_and_continue
.previous_line:
mov dl, END_COL
jmp _move_up
; Moves the cursor right one nibble then continues typing_loop
; - Saves the byte in cl when moving to a new byte, also loads the existing
; data into cl if applicable
; - Calls move_down when moving to the next line
move_right:
test ch, CURSOR_ON_SECOND_NIBBLE
jnz .next_byte
; We're moving right to the second nibble
; Never have to change lines
cmp di, si
jne .move_one_char_forward ; if we're not at the end
; we're at the end
test ch, SAVED_NIBBLE_AT_END
jnz .move_one_char_forward ; allowed to move one more if there's a nibble
jmp typing_loop ; this is the end, no move moving right
.move_one_char_forward:
or ch, CURSOR_ON_SECOND_NIBBLE ; set the bit
inc dl
jmp set_cursor_and_continue
.next_byte:
cmp di, si ; note: when the user types a character this is never equal
je typing_loop ; do nothing if we're already at the end
; store the temp byte in the destination memory
mov [es:di], cl
inc di
; Set the cl value for the next byte
cmp di, si
jne .load_byte ; if we moved right and we're not at the end, load the data already entered
test ch, SAVED_NIBBLE_AT_END ; if we moved to the end and there's a saved nibble there
jnz .load_byte ; just load the whole byte (the second nibble can be user data if we hit the USER_CODE_MAX)
; If we don't take either of the above jumps
xor cl, cl ; Clear the temp storage for the next byte (maybe not really necessary)
jmp .move_cursor_to_next_byte
.load_byte:
mov cl, [es:di]
; fallthrough
.move_cursor_to_next_byte:
and ch, ~CURSOR_ON_SECOND_NIBBLE ; Clear this bit in the bitfield
cmp dl, 0x26 ; The column of the last char of the 8th byte
je .extra_space
cmp dl, END_COL
je .new_line
; Normal case, the char printed plus 1 space
add dl, 2
jmp set_cursor_and_continue
.extra_space: ; Put two spaces in the middle
add dl, 3
jmp set_cursor_and_continue
.new_line:
mov dl, START_COL
jmp _move_down
; Move the cursor up one line and keep the same column
; - Does not update the di pointer or cx state
; - Does not check bounds
; - Scrolls if necessary
; - Prints existing data if scolling to a part of the buffer with data
_move_up:
cmp dh, START_ROW
je .scroll_down
dec dh
jmp set_cursor_and_continue
.scroll_down:
mov ah, 0x07 ; BIOS scroll down, means make room at the top
jmp _scroll_and_continue
; Move the cursor down one line and keep the same column
; - Does not update the di pointer or cx state
; - Does not check bounds
; - Scrolls if necessary
; - Prints existing data if scolling to a part of the buffer with data
_move_down:
cmp dh, END_ROW ; if we're at the bottom
je .scroll_up
inc dh ; Next row
jmp set_cursor_and_continue
.scroll_up:
mov ah, 0x06 ; BIOS scroll up, means make room at the bottom
jmp _scroll_and_continue
; Scrolls the text up or down one row printing any existing data in the text
; buffer when it does it
; - ah = 0x06 for down; ah = 0x07 for up; ah = anything else for hacks
_scroll_and_continue:
push dx ; save the cursor position
push di ; save the write pointer
push cx ; save the current byte storage (must be last)
mov al, 1 ; scroll one line (shared between the two calls)
; Scroll the user code text area
mov cx, MAIN_TOP_LEFT
mov dx, MAIN_BOTTOM_RIGHT
mov bh, MAIN_COLOR
int 0x10
; Scroll the line numbers
mov cx, LINE_NUM_TOP_LEFT
mov dx, LINE_NUM_BOTTOM_RIGHT
mov bh, BORDER_COLOR
int 0x10
; Set the cursor to the start of the new line number
cmp ah, 0x06
jne .went_up
mov dh, END_ROW
jmp .went_down
.went_up:
mov dh, START_ROW
.went_down:
mov dl, LINE_NUM_COL
mov ah, 0x02
xor bh, bh
int 0x10
; Move the current buffer pos pointer to the beginning of the line
and di, 0xFFF0
; Print the new line number
mov cx, di
call print_hex
; Move the cursor forward to the start of the line
add dl, 5
mov ah, 0x02
xor bh, bh
int 0x10
; Prints a whole hex line from the [es:di] up to the end of the line or [es:si]
; Also checks the SAVED_NIBBLE_AT_END flag and prints it
pop cx ; restore the global cx value (we need the ch flags)
.print_line_loop:
cmp di, si
jne .print_whole_byte
cmp si, USER_CODE_MAX
je .print_whole_byte ; Just always print the last byte even if the user didn't type there yet
test ch, SAVED_NIBBLE_AT_END
jnz .print_one_nibble
jmp .done
.print_one_nibble:
mov al, [es:di]
shr al, 4
call print_hex_char
jmp .done ; no need to skip spaces
.print_whole_byte:
mov al, [es:di]
shr al, 4
call print_hex_char
mov al, [es:di]
and al, 0x0F
call print_hex_char
;.skip_spaces:
; if (di & 0xF) = 7
mov ax, di
and ax, 0xF
cmp al, 7
jne .one_space
;two_spaces:
inc dl
; fallthrough
.one_space:
add dl, 3
mov ah, 0x02
xor bh, bh
int 0x10
; If we printed the last byte of the line, we're done
mov ax, di
and ax, 0xF
cmp ax, 0xF
je .done
inc di
jmp .print_line_loop
.done:
pop di ; restore the write pointer
pop dx ; restore the cursor position
jmp set_cursor_and_continue
run_code:
; Set video mode, 16 color 80x25 chars
mov ax, 0x0003
int 0x10
; Reset the data segement to the user buffer
mov ax, USER_CODE_LOC
mov ds, ax
jmp USER_CODE_LOC:0x00
; ==== Data area ====
greeting: db `Write your x86 (16-bit real mode) hex here:`
greeting_len: equ $-greeting
row_header: db ` 0 1 2 3 4 5 6 7 8 9 A B C D E F`
row_header_len: equ $-row_header
run_instr: db `Press Ctrl+D to run your code immediately.`
run_instr_len: equ $-run_instr
; The -1 is because we don't want the next sector until we have 512+1 bytes
; e.g. for exactly 512 bytes we want 1 extra sector not 2
;
; The +1 is because int division does floor() and we want ceil()
NUM_EXTRA_SECTORS: equ ($-start_-1)/SECTOR_SIZE + 1
|
.global s_prepare_buffers
s_prepare_buffers:
push %r13
push %r8
push %rsi
lea addresses_WT_ht+0x11a53, %r13
nop
nop
cmp $35705, %rsi
vmovups (%r13), %ymm0
vextracti128 $0, %ymm0, %xmm0
vpextrq $1, %xmm0, %r8
nop
and $47662, %r13
pop %rsi
pop %r8
pop %r13
ret
.global s_faulty_load
s_faulty_load:
push %r11
push %r15
push %r8
push %rcx
push %rdi
// Faulty Load
lea addresses_RW+0xe753, %r8
nop
nop
inc %r11
mov (%r8), %r15w
lea oracles, %r8
and $0xff, %r15
shlq $12, %r15
mov (%r8,%r15,1), %r15
pop %rdi
pop %rcx
pop %r8
pop %r15
pop %r11
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'type': 'addresses_RW', 'size': 1, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': False}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'type': 'addresses_RW', 'size': 2, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': True}}
<gen_prepare_buffer>
{'OP': 'LOAD', 'src': {'type': 'addresses_WT_ht', 'size': 32, 'AVXalign': False, 'NT': False, 'congruent': 8, 'same': False}}
{'32': 2115}
32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32
*/
|
#include "askpassphrasedialog.h"
#include "ui_askpassphrasedialog.h"
#include "guiconstants.h"
#include "walletmodel.h"
#include <QMessageBox>
#include <QPushButton>
#include <QKeyEvent>
extern bool fWalletUnlockStakingOnly;
AskPassphraseDialog::AskPassphraseDialog(Mode mode, QWidget *parent) :
QDialog(parent),
ui(new Ui::AskPassphraseDialog),
mode(mode),
model(0),
fCapsLock(false)
{
ui->setupUi(this);
ui->passEdit1->setMaxLength(MAX_PASSPHRASE_SIZE);
ui->passEdit2->setMaxLength(MAX_PASSPHRASE_SIZE);
ui->passEdit3->setMaxLength(MAX_PASSPHRASE_SIZE);
// Setup Caps Lock detection.
ui->passEdit1->installEventFilter(this);
ui->passEdit2->installEventFilter(this);
ui->passEdit3->installEventFilter(this);
switch(mode)
{
case Encrypt: // Ask passphrase x2
ui->passLabel1->hide();
ui->passEdit1->hide();
ui->warningLabel->setText(tr("Enter the new passphrase to the wallet.<br/>Please use a passphrase of <b>10 or more random characters</b>, or <b>eight or more words</b>."));
setWindowTitle(tr("Encrypt wallet"));
break;
case UnlockStaking:
ui->stakingCheckBox->setChecked(true);
ui->stakingCheckBox->show();
// fallthru
case Unlock: // Ask passphrase
ui->warningLabel->setText(tr("This operation needs your wallet passphrase to unlock the wallet."));
ui->passLabel2->hide();
ui->passEdit2->hide();
ui->passLabel3->hide();
ui->passEdit3->hide();
setWindowTitle(tr("Unlock wallet"));
break;
case Decrypt: // Ask passphrase
ui->warningLabel->setText(tr("This operation needs your wallet passphrase to decrypt the wallet."));
ui->passLabel2->hide();
ui->passEdit2->hide();
ui->passLabel3->hide();
ui->passEdit3->hide();
setWindowTitle(tr("Decrypt wallet"));
break;
case ChangePass: // Ask old passphrase + new passphrase x2
setWindowTitle(tr("Change passphrase"));
ui->warningLabel->setText(tr("Enter the old and new passphrase to the wallet."));
break;
}
textChanged();
connect(ui->passEdit1, SIGNAL(textChanged(QString)), this, SLOT(textChanged()));
connect(ui->passEdit2, SIGNAL(textChanged(QString)), this, SLOT(textChanged()));
connect(ui->passEdit3, SIGNAL(textChanged(QString)), this, SLOT(textChanged()));
}
AskPassphraseDialog::~AskPassphraseDialog()
{
secureClearPassFields();
delete ui;
}
void AskPassphraseDialog::setModel(WalletModel *model)
{
this->model = model;
}
void AskPassphraseDialog::accept()
{
SecureString oldpass, newpass1, newpass2;
if(!model)
return;
oldpass.reserve(MAX_PASSPHRASE_SIZE);
newpass1.reserve(MAX_PASSPHRASE_SIZE);
newpass2.reserve(MAX_PASSPHRASE_SIZE);
// TODO: get rid of this .c_str() by implementing SecureString::operator=(std::string)
// Alternately, find a way to make this input mlock()'d to begin with.
oldpass.assign(ui->passEdit1->text().toStdString().c_str());
newpass1.assign(ui->passEdit2->text().toStdString().c_str());
newpass2.assign(ui->passEdit3->text().toStdString().c_str());
secureClearPassFields();
switch(mode)
{
case Encrypt: {
if(newpass1.empty() || newpass2.empty())
{
// Cannot encrypt with empty passphrase
break;
}
QMessageBox::StandardButton retval = QMessageBox::question(this, tr("Confirm wallet encryption"),
tr("Warning: If you encrypt your wallet and lose your passphrase, you will <b>LOSE ALL OF YOUR COINS</b>!") + "<br><br>" + tr("Are you sure you wish to encrypt your wallet?"),
QMessageBox::Yes|QMessageBox::Cancel,
QMessageBox::Cancel);
if(retval == QMessageBox::Yes)
{
if(newpass1 == newpass2)
{
if(model->setWalletEncrypted(true, newpass1))
{
QMessageBox::warning(this, tr("Wallet encrypted"),
"<qt>" +
tr("AmeroCash will close now to finish the encryption process. "
"Remember that encrypting your wallet cannot fully protect "
"your coins from being stolen by malware infecting your computer.") +
"<br><br><b>" +
tr("IMPORTANT: Any previous backups you have made of your wallet file "
"should be replaced with the newly generated, encrypted wallet file. "
"For security reasons, previous backups of the unencrypted wallet file "
"will become useless as soon as you start using the new, encrypted wallet.") +
"</b></qt>");
QApplication::quit();
}
else
{
QMessageBox::critical(this, tr("Wallet encryption failed"),
tr("Wallet encryption failed due to an internal error. Your wallet was not encrypted."));
}
QDialog::accept(); // Success
}
else
{
QMessageBox::critical(this, tr("Wallet encryption failed"),
tr("The supplied passphrases do not match."));
}
}
else
{
QDialog::reject(); // Cancelled
}
} break;
case UnlockStaking:
case Unlock:
if(!model->setWalletLocked(false, oldpass))
{
QMessageBox::critical(this, tr("Wallet unlock failed"),
tr("The passphrase entered for the wallet decryption was incorrect."));
}
else
{
fWalletUnlockStakingOnly = ui->stakingCheckBox->isChecked();
QDialog::accept(); // Success
}
break;
case Decrypt:
if(!model->setWalletEncrypted(false, oldpass))
{
QMessageBox::critical(this, tr("Wallet decryption failed"),
tr("The passphrase entered for the wallet decryption was incorrect."));
}
else
{
QDialog::accept(); // Success
}
break;
case ChangePass:
if(newpass1 == newpass2)
{
if(model->changePassphrase(oldpass, newpass1))
{
QMessageBox::information(this, tr("Wallet encrypted"),
tr("Wallet passphrase was successfully changed."));
QDialog::accept(); // Success
}
else
{
QMessageBox::critical(this, tr("Wallet encryption failed"),
tr("The passphrase entered for the wallet decryption was incorrect."));
}
}
else
{
QMessageBox::critical(this, tr("Wallet encryption failed"),
tr("The supplied passphrases do not match."));
}
break;
}
}
void AskPassphraseDialog::textChanged()
{
// Validate input, set Ok button to enabled when acceptable
bool acceptable = false;
switch(mode)
{
case Encrypt: // New passphrase x2
acceptable = !ui->passEdit2->text().isEmpty() && !ui->passEdit3->text().isEmpty();
break;
case UnlockStaking:
case Unlock: // Old passphrase x1
case Decrypt:
acceptable = !ui->passEdit1->text().isEmpty();
break;
case ChangePass: // Old passphrase x1, new passphrase x2
acceptable = !ui->passEdit1->text().isEmpty() && !ui->passEdit2->text().isEmpty() && !ui->passEdit3->text().isEmpty();
break;
}
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(acceptable);
}
bool AskPassphraseDialog::event(QEvent *event)
{
// Detect Caps Lock key press.
if (event->type() == QEvent::KeyPress) {
QKeyEvent *ke = static_cast<QKeyEvent *>(event);
if (ke->key() == Qt::Key_CapsLock) {
fCapsLock = !fCapsLock;
}
if (fCapsLock) {
ui->capsLabel->setText(tr("Warning: The Caps Lock key is on!"));
} else {
ui->capsLabel->clear();
}
}
return QWidget::event(event);
}
bool AskPassphraseDialog::eventFilter(QObject *object, QEvent *event)
{
/* Detect Caps Lock.
* There is no good OS-independent way to check a key state in Qt, but we
* can detect Caps Lock by checking for the following condition:
* Shift key is down and the result is a lower case character, or
* Shift key is not down and the result is an upper case character.
*/
if (event->type() == QEvent::KeyPress) {
QKeyEvent *ke = static_cast<QKeyEvent *>(event);
QString str = ke->text();
if (str.length() != 0) {
const QChar *psz = str.unicode();
bool fShift = (ke->modifiers() & Qt::ShiftModifier) != 0;
if ((fShift && psz->isLower()) || (!fShift && psz->isUpper())) {
fCapsLock = true;
ui->capsLabel->setText(tr("Warning: The Caps Lock key is on!"));
} else if (psz->isLetter()) {
fCapsLock = false;
ui->capsLabel->clear();
}
}
}
return QDialog::eventFilter(object, event);
}
void AskPassphraseDialog::secureClearPassFields()
{
// Attempt to overwrite text so that they do not linger around in memory
ui->passEdit1->setText(QString(" ").repeated(ui->passEdit1->text().size()));
ui->passEdit2->setText(QString(" ").repeated(ui->passEdit2->text().size()));
ui->passEdit3->setText(QString(" ").repeated(ui->passEdit3->text().size()));
ui->passEdit1->clear();
ui->passEdit2->clear();
ui->passEdit3->clear();
}
|
.686
.model flat, C
; https://docs.microsoft.com/en-us/cpp/porting/overview-of-potential-upgrade-issues-visual-cpp#libraries
includelib legacy_stdio_definitions.lib
extern printf: PROTO C fmt:PTR BYTE, :VARARG
extern setlocale: PROTO C category:SDWORD, locale:PTR BYTE
.const
fmt db "ACP locale: %s", 0ah, 0
locale db ".ACP", 0
.code
; Set the locale to the user-default ANSI code page obtained from the
; operating system. This is required for wide/narrow conversion, since
; the locale "C" (set at program startup) cannot handle MBCS.
setup PROC
push ebp
mov ebp, esp
invoke setlocale, 0, ADDR locale
cmp eax, 0
je @F
invoke printf, ADDR fmt, eax
mov eax, 1
@@:
mov esp, ebp
pop ebp
ret
setup ENDP
END
|
; ********************************************************
; Music Bank
;
; created with Beyond Gameboy Tracker
; ********************************************************
; ************************ Pattern Streams *******************
SECTION "MkillerP0", ROMX
PATTERN_killer0:
DB $0A
DB $02, $01, $1C, $10, $02, $01, $01, $10, $2E, $02, $03, $0C, $02, $00, $0C, $01, $04, $08, $01, $10, $32, $0C, $01, $10, $36, $0C, $02, $00, $01, $10, $3A, $0C
DB $01, $10, $3E, $0C, $01, $1C, $10, $01, $10, $2E, $0C, $02, $00, $0C, $01, $04, $08, $01, $10, $32, $0C, $01, $10, $36, $0C, $01, $10, $3A, $0C, $02, $00, $01
DB $10, $3E, $0C, $01, $1C, $10, $01, $10, $2E, $0C, $02, $00, $0C, $01, $04, $08, $01, $10, $32, $0C, $02, $36, $0C, $01, $1C, $10, $01, $10, $2E, $0C, $02, $00
DB $0C, $01, $04, $08, $01, $10, $32, $0C, $01, $10, $36, $0C, $01, $1C, $10, $01, $10, $2E, $0C, $02, $00, $0C, $01, $04, $08, $01, $10, $32, $0C, $01, $10, $36
DB $0C, $01, $10, $3A, $0C, $02, $00, $01, $10, $3E, $0C, $01, $1C, $10, $01, $10, $2E, $0C, $02, $00, $0C, $01, $04, $08, $01, $10, $32, $0C, $01, $10, $36, $0C
DB $02, $00, $01, $10, $3A, $0C, $01, $10, $3E, $00, $03, $07
SECTION "MkillerP1", ROMX
PATTERN_killer1:
DB $0A
DB $02, $01, $1C, $10, $01, $10, $2E, $02, $17, $0C, $02, $00, $0C, $01, $04, $08, $01, $10, $32, $02, $1B, $0C, $01, $10, $36, $0C, $02, $00, $01, $10, $3A, $0C
DB $01, $10, $3E, $0C, $01, $1C, $10, $01, $10, $2E, $0C, $02, $00, $0C, $01, $04, $08, $01, $10, $32, $02, $1F, $0C, $01, $10, $36, $0C, $01, $10, $3A, $0C, $02
DB $00, $01, $10, $3E, $0C, $01, $1C, $10, $01, $10, $2E, $02, $23, $0C, $02, $00, $0C, $01, $04, $08, $01, $10, $32, $02, $23, $0C, $02, $36, $02, $1B, $0C, $01
DB $1C, $10, $01, $10, $2E, $02, $23, $0C, $02, $00, $0C, $01, $04, $08, $01, $10, $32, $02, $1B, $0C, $01, $10, $36, $0C, $01, $1C, $10, $01, $10, $2E, $0C, $02
DB $00, $0C, $01, $04, $08, $01, $10, $32, $0C, $01, $10, $36, $0C, $01, $10, $3A, $02, $1F, $0C, $02, $00, $01, $10, $3E, $0C, $01, $1C, $10, $01, $10, $2E, $0C
DB $02, $00, $0C, $01, $04, $08, $01, $10, $32, $0C, $01, $10, $36, $0C, $02, $00, $01, $10, $3A, $0C, $01, $10, $3E, $00, $03, $07
SECTION "MkillerP2", ROMX
PATTERN_killer2:
DB $0A
DB $02, $01, $1C, $10, $01, $10, $2E, $02, $17, $0C, $02, $00, $0C, $01, $04, $08, $01, $10, $32, $02, $1B, $0C, $01, $10, $36, $0C, $02, $00, $01, $10, $3A, $02
DB $27, $0C, $01, $10, $3E, $0C, $01, $1C, $10, $01, $10, $2E, $0C, $02, $00, $0C, $01, $04, $08, $01, $10, $32, $02, $1F, $0C, $01, $10, $36, $0C, $01, $10, $3A
DB $0C, $02, $00, $01, $10, $3E, $0C, $01, $1C, $10, $01, $10, $2E, $02, $27, $0C, $02, $00, $0C, $01, $04, $08, $01, $10, $32, $02, $23, $0C, $02, $36, $02, $1B
DB $0C, $01, $1C, $10, $01, $10, $2E, $02, $23, $0C, $02, $00, $0C, $01, $04, $08, $01, $10, $32, $02, $1B, $0C, $01, $10, $36, $0C, $01, $1C, $10, $01, $10, $2E
DB $0C, $02, $00, $0C, $01, $04, $08, $01, $10, $32, $02, $27, $0C, $01, $10, $36, $0C, $01, $10, $3A, $02, $1F, $0C, $02, $00, $01, $10, $3E, $0C, $01, $1C, $10
DB $01, $10, $2E, $02, $1B, $0C, $02, $00, $0C, $01, $04, $08, $01, $10, $32, $02, $27, $0C, $01, $10, $36, $0C, $02, $00, $01, $10, $3A, $0C, $01, $10, $3E, $00
DB $03, $07
SECTION "MkillerP3", ROMX
PATTERN_killer3:
DB $0A
DB $02, $01, $1A, $10, $01, $0E, $2E, $02, $17, $0C, $02, $00, $0C, $01, $02, $08, $01, $0E, $32, $02, $1B, $0C, $01, $0E, $36, $0C, $02, $00, $01, $0E, $3A, $02
DB $27, $0C, $01, $0E, $3E, $0C, $01, $1A, $10, $01, $0E, $2E, $0C, $02, $00, $0C, $01, $02, $08, $01, $0E, $32, $02, $1F, $0C, $01, $0E, $36, $0C, $01, $0E, $3A
DB $0C, $02, $00, $01, $0E, $3E, $0C, $01, $1A, $10, $01, $0E, $2E, $02, $27, $0C, $02, $00, $0C, $01, $02, $08, $01, $0E, $32, $02, $23, $0C, $02, $36, $02, $1B
DB $0C, $01, $1A, $10, $01, $0E, $2E, $02, $23, $0C, $02, $00, $0C, $01, $02, $08, $01, $0E, $32, $02, $1B, $0C, $01, $0E, $36, $0C, $01, $1A, $10, $01, $0E, $2E
DB $0C, $02, $00, $0C, $01, $02, $08, $01, $0E, $32, $02, $27, $0C, $01, $0E, $36, $0C, $01, $0E, $3A, $02, $1F, $0C, $02, $00, $01, $0E, $3E, $0C, $01, $1A, $10
DB $01, $0E, $2E, $02, $1B, $0C, $02, $00, $0C, $01, $02, $08, $01, $0E, $32, $02, $27, $0C, $01, $0E, $36, $0C, $02, $00, $01, $0E, $3A, $0C, $01, $0E, $3E, $00
DB $03, $07
SECTION "MkillerP4", ROMX
PATTERN_killer4:
DB $0A
DB $02, $01, $1C, $10, $02, $01, $01, $10, $2E, $02, $03, $0C, $02, $00, $0C, $01, $04, $08, $01, $10, $32, $0C, $01, $10, $36, $0C, $02, $00, $01, $10, $3A, $0C
DB $01, $10, $3E, $0C, $01, $1C, $10, $01, $10, $2E, $0C, $02, $00, $0C, $01, $04, $08, $01, $10, $32, $0C, $01, $10, $36, $0C, $01, $10, $3A, $0C, $02, $00, $01
DB $10, $3E, $0C, $01, $1C, $10, $01, $10, $2E, $0C, $02, $00, $0C, $01, $04, $08, $01, $10, $32, $0C, $02, $36, $0C, $01, $1C, $10, $01, $10, $2E, $0C, $02, $00
DB $0C, $01, $04, $08, $01, $10, $32, $0C, $01, $10, $36, $0C, $01, $1C, $10, $01, $10, $2E, $0C, $02, $00, $0C, $03, $C0, $01, $04, $08, $01, $10, $32, $0C, $03
DB $80, $01, $04, $08, $01, $10, $36, $0C, $03, $C0, $01, $04, $08, $01, $10, $3A, $0C, $03, $80, $01, $04, $08, $01, $10, $3E, $0C, $03, $C0, $01, $04, $08, $02
DB $02, $0C, $03, $A0, $01, $04, $08, $0C, $03, $80, $01, $04, $08, $0C, $03, $70, $01, $04, $08, $0C, $03, $50, $01, $04, $08, $02, $23, $0C, $03, $30, $01, $04
DB $08, $00, $03, $07
SECTION "MkillerP5", ROMX
PATTERN_killer5:
DB $0A
DB $02, $01, $1B, $10, $01, $0F, $2E, $02, $17, $0C, $02, $00, $0C, $01, $03, $08, $01, $0F, $32, $02, $1B, $0C, $01, $0F, $36, $0C, $02, $00, $01, $0F, $3A, $02
DB $27, $0C, $01, $0F, $3E, $0C, $01, $1B, $10, $01, $0F, $2E, $0C, $02, $00, $0C, $01, $03, $08, $01, $0F, $32, $02, $1F, $0C, $01, $0F, $36, $0C, $01, $0F, $3A
DB $0C, $02, $00, $01, $0F, $3E, $0C, $01, $1B, $10, $01, $0F, $2E, $02, $27, $0C, $02, $00, $0C, $01, $03, $08, $01, $0F, $32, $02, $23, $0C, $02, $36, $02, $1B
DB $0C, $01, $1B, $10, $01, $0F, $2E, $02, $23, $0C, $02, $00, $0C, $01, $03, $08, $01, $0F, $32, $02, $1B, $0C, $01, $0F, $36, $0C, $01, $1B, $10, $01, $0F, $2E
DB $0C, $02, $00, $0C, $01, $03, $08, $01, $0F, $32, $02, $27, $0C, $01, $0F, $36, $0C, $01, $0F, $3A, $02, $1F, $0C, $02, $00, $01, $0F, $3E, $0C, $01, $1B, $10
DB $01, $0F, $2E, $02, $1B, $0C, $02, $00, $0C, $01, $03, $08, $01, $0F, $32, $02, $27, $0C, $01, $0F, $36, $0C, $02, $00, $01, $0F, $3A, $0C, $01, $0F, $3E, $00
DB $03, $07
SECTION "MkillerP6", ROMX
PATTERN_killer6:
DB $0A
DB $02, $01, $1C, $10, $03, $C1, $12, $01, $01, $04, $05, $01, $10, $2E, $02, $17, $0C, $02, $00, $12, $C1, $0C, $01, $04, $08, $12, $81, $01, $10, $05, $01, $10
DB $32, $02, $1B, $0C, $12, $41, $01, $10, $36, $0C, $02, $00, $12, $01, $01, $17, $05, $01, $10, $3A, $02, $27, $0C, $12, $C1, $02, $01, $01, $10, $3E, $0C, $01
DB $1C, $10, $12, $81, $01, $1C, $05, $01, $10, $2E, $0C, $02, $00, $12, $41, $0C, $01, $04, $08, $12, $01, $02, $01, $01, $10, $32, $02, $1F, $0C, $12, $C1, $01
DB $10, $36, $0C, $12, $81, $01, $13, $05, $01, $10, $3A, $0C, $02, $00, $12, $41, $01, $10, $3E, $0C, $01, $1C, $10, $12, $01, $01, $07, $05, $01, $10, $2E, $02
DB $27, $0C, $02, $00, $12, $C1, $02, $01, $0C, $01, $04, $08, $12, $81, $01, $13, $05, $01, $10, $32, $02, $23, $0C, $12, $41, $02, $01, $02, $36, $02, $1B, $0C
DB $01, $1C, $10, $12, $01, $01, $04, $05, $01, $10, $2E, $02, $23, $0C, $02, $00, $12, $C1, $0C, $01, $04, $08, $12, $81, $01, $10, $05, $01, $10, $32, $02, $1B
DB $0C, $12, $41, $01, $04, $05, $01, $10, $36, $0C, $01, $1C, $10, $12, $01, $01, $10, $2E, $0C, $02, $00, $12, $C1, $02, $01, $0C, $01, $04, $08, $12, $81, $01
DB $04, $05, $01, $10, $32, $02, $27, $0C, $12, $41, $01, $10, $36, $0C, $01, $10, $3A, $02, $1F, $0C, $02, $00, $01, $10, $3E, $0C, $01, $1C, $10, $02, $01, $01
DB $10, $2E, $02, $1B, $0C, $02, $00, $0C, $01, $04, $08, $01, $10, $32, $02, $27, $0C, $01, $10, $36, $0C, $02, $00, $01, $10, $3A, $0C, $01, $10, $3E, $00, $03
DB $07
SECTION "MkillerP7", ROMX
PATTERN_killer7:
DB $0A
DB $02, $01, $1C, $10, $12, $01, $01, $04, $05, $01, $10, $2E, $02, $17, $0C, $02, $00, $12, $C1, $0C, $01, $04, $08, $12, $81, $01, $0B, $05, $01, $10, $32, $02
DB $1B, $0C, $12, $41, $01, $10, $36, $0C, $02, $00, $12, $01, $01, $10, $05, $01, $10, $3A, $02, $27, $0C, $12, $C1, $02, $01, $01, $10, $3E, $0C, $01, $1C, $10
DB $12, $81, $01, $04, $05, $01, $10, $2E, $0C, $02, $00, $12, $41, $0C, $01, $04, $08, $12, $01, $02, $01, $01, $10, $32, $02, $1F, $0C, $12, $C1, $01, $10, $36
DB $0C, $12, $81, $01, $0B, $05, $01, $10, $3A, $0C, $02, $00, $12, $41, $01, $10, $3E, $0C, $01, $1C, $10, $12, $01, $01, $13, $05, $01, $10, $2E, $02, $27, $0C
DB $02, $00, $12, $C1, $02, $01, $0C, $01, $04, $08, $12, $81, $01, $17, $05, $01, $10, $32, $02, $23, $0C, $12, $41, $02, $01, $02, $36, $02, $1B, $0C, $01, $1C
DB $10, $12, $01, $01, $04, $05, $01, $10, $2E, $02, $23, $0C, $02, $00, $12, $C1, $0C, $01, $04, $08, $12, $81, $01, $10, $05, $01, $10, $32, $02, $1B, $0C, $12
DB $41, $01, $04, $05, $01, $10, $36, $0C, $01, $1C, $10, $12, $01, $01, $10, $2E, $0C, $02, $00, $12, $C1, $02, $01, $0C, $01, $04, $08, $12, $81, $01, $04, $05
DB $01, $10, $32, $02, $27, $0C, $12, $41, $01, $10, $36, $0C, $01, $10, $3A, $02, $1F, $0C, $02, $00, $01, $10, $3E, $0C, $01, $1C, $10, $02, $01, $01, $10, $2E
DB $02, $1B, $0C, $02, $00, $0C, $01, $04, $08, $01, $10, $32, $02, $27, $0C, $01, $10, $36, $0C, $01, $1C, $10, $01, $10, $3A, $0C, $01, $10, $3E, $00, $03, $07
SECTION "MkillerP8", ROMX
PATTERN_killer8:
DB $0A
DB $02, $01, $1A, $10, $12, $01, $01, $02, $05, $01, $0E, $2E, $02, $17, $0C, $02, $00, $12, $C1, $0C, $01, $02, $08, $12, $81, $01, $0E, $05, $01, $0E, $32, $02
DB $1B, $0C, $12, $41, $01, $0E, $36, $0C, $02, $00, $12, $01, $01, $15, $05, $01, $0E, $3A, $02, $27, $0C, $12, $C1, $02, $01, $01, $0E, $3E, $0C, $01, $1A, $10
DB $12, $81, $01, $1A, $05, $01, $0E, $2E, $0C, $02, $00, $12, $41, $0C, $01, $02, $08, $12, $01, $02, $01, $01, $0E, $32, $02, $1F, $0C, $12, $C1, $01, $0E, $36
DB $0C, $12, $81, $01, $11, $05, $01, $0E, $3A, $0C, $02, $00, $12, $41, $01, $0E, $3E, $0C, $01, $1A, $10, $12, $01, $01, $05, $05, $01, $0E, $2E, $02, $27, $0C
DB $02, $00, $12, $C1, $02, $01, $0C, $01, $02, $08, $12, $81, $01, $11, $05, $01, $0E, $32, $02, $23, $0C, $12, $41, $02, $01, $02, $36, $02, $1B, $0C, $01, $1A
DB $10, $12, $01, $01, $02, $05, $01, $0E, $2E, $02, $23, $0C, $02, $00, $12, $C1, $0C, $01, $02, $08, $12, $81, $01, $0E, $05, $01, $0E, $32, $02, $1B, $0C, $12
DB $41, $01, $02, $05, $01, $0E, $36, $0C, $01, $1A, $10, $12, $01, $01, $0E, $2E, $0C, $02, $00, $12, $C1, $02, $01, $0C, $01, $02, $08, $12, $81, $01, $02, $05
DB $01, $0E, $32, $02, $27, $0C, $12, $41, $01, $0E, $36, $0C, $01, $0E, $3A, $02, $1F, $0C, $02, $00, $01, $0E, $3E, $0C, $01, $1A, $10, $02, $01, $01, $0E, $2E
DB $02, $1B, $0C, $02, $00, $0C, $01, $02, $08, $01, $0E, $32, $02, $27, $0C, $01, $0E, $36, $0C, $02, $00, $01, $0E, $3A, $0C, $01, $0E, $3E, $00, $03, $07
SECTION "MkillerP9", ROMX
PATTERN_killer9:
DB $0A
DB $02, $01, $1B, $10, $12, $01, $01, $03, $05, $01, $0F, $2E, $02, $17, $0C, $02, $00, $12, $C1, $0C, $01, $03, $08, $12, $81, $01, $0A, $05, $01, $0F, $32, $02
DB $1B, $0C, $12, $41, $01, $0F, $36, $0C, $02, $00, $12, $01, $01, $0F, $05, $01, $0F, $3A, $02, $27, $0C, $12, $C1, $02, $01, $01, $0F, $3E, $0C, $01, $1B, $10
DB $12, $81, $01, $03, $05, $01, $0F, $2E, $0C, $02, $00, $12, $41, $0C, $01, $03, $08, $12, $01, $02, $01, $01, $0F, $32, $02, $1F, $0C, $12, $C1, $01, $0F, $36
DB $0C, $12, $81, $01, $0A, $05, $01, $0F, $3A, $0C, $02, $00, $12, $41, $01, $0F, $3E, $0C, $01, $1B, $10, $12, $01, $01, $0F, $2E, $02, $27, $0C, $02, $00, $12
DB $C1, $02, $01, $0C, $01, $03, $08, $12, $81, $01, $16, $05, $01, $0F, $32, $02, $23, $0C, $12, $41, $02, $01, $02, $36, $02, $1B, $0C, $01, $1B, $10, $12, $01
DB $01, $12, $05, $01, $0F, $2E, $02, $23, $0C, $02, $00, $12, $C1, $0C, $01, $03, $08, $12, $81, $01, $0F, $05, $01, $0F, $32, $02, $1B, $0C, $12, $41, $01, $03
DB $05, $01, $0F, $36, $0C, $01, $1B, $10, $12, $01, $01, $0F, $2E, $0C, $02, $00, $12, $C1, $02, $01, $0C, $01, $03, $08, $12, $81, $01, $03, $05, $01, $0F, $32
DB $02, $27, $0C, $12, $41, $01, $0F, $36, $0C, $01, $0F, $3A, $02, $1F, $0C, $02, $00, $02, $01, $01, $0F, $3E, $0C, $01, $1B, $10, $12, $81, $01, $03, $05, $01
DB $0F, $2E, $02, $1B, $0C, $02, $00, $0C, $01, $03, $08, $02, $01, $01, $0F, $32, $02, $27, $0C, $01, $0F, $36, $0C, $02, $00, $01, $0F, $3A, $0C, $01, $0F, $3E
DB $00, $03, $07
SECTION "MkillerP10", ROMX
PATTERN_killer10:
DB $0A
DB $02, $01, $1B, $10, $12, $01, $01, $03, $05, $01, $0F, $2E, $02, $17, $0C, $02, $00, $12, $C1, $0C, $01, $03, $08, $12, $81, $01, $0A, $05, $01, $0F, $32, $02
DB $1B, $0C, $12, $41, $01, $0F, $36, $0C, $02, $00, $12, $01, $01, $0F, $05, $01, $0F, $3A, $02, $27, $0C, $12, $C1, $02, $01, $01, $0F, $3E, $0C, $01, $1B, $10
DB $12, $81, $01, $03, $05, $01, $0F, $2E, $0C, $02, $00, $12, $41, $0C, $01, $03, $08, $12, $01, $02, $01, $01, $0F, $32, $02, $1F, $0C, $12, $C1, $01, $0F, $36
DB $0C, $12, $81, $01, $0A, $05, $01, $0F, $3A, $0C, $02, $00, $12, $41, $01, $0F, $3E, $0C, $01, $1B, $10, $12, $01, $01, $0F, $2E, $02, $27, $0C, $02, $00, $12
DB $C1, $02, $01, $0C, $01, $03, $08, $12, $81, $01, $16, $05, $01, $0F, $32, $02, $23, $0C, $12, $41, $02, $01, $02, $36, $02, $1B, $0C, $01, $1B, $10, $12, $01
DB $01, $12, $05, $01, $0F, $2E, $02, $23, $0C, $02, $00, $12, $C1, $0C, $01, $03, $08, $12, $81, $01, $0F, $05, $01, $0F, $32, $02, $1B, $0C, $12, $41, $01, $03
DB $05, $01, $0F, $36, $0C, $01, $1B, $10, $12, $01, $01, $0F, $2E, $0C, $02, $00, $12, $C1, $02, $01, $0C, $01, $03, $08, $12, $01, $01, $12, $05, $01, $0F, $32
DB $02, $27, $0C, $12, $C1, $01, $0F, $36, $0C, $12, $81, $01, $0F, $05, $01, $0F, $3A, $02, $1F, $0C, $02, $00, $12, $41, $01, $03, $05, $01, $0F, $3E, $0C, $01
DB $1B, $10, $12, $01, $01, $0F, $2E, $02, $1B, $0C, $02, $00, $12, $C1, $02, $01, $0C, $01, $03, $08, $12, $81, $01, $03, $05, $01, $0F, $32, $02, $27, $0C, $12
DB $41, $01, $0F, $36, $0C, $02, $00, $12, $01, $01, $12, $05, $01, $0F, $3A, $0B, $05, $01, $0B, $05, $01, $01, $0F, $3E, $0B, $05, $01, $00, $01, $07
SECTION "MkillerP11", ROMX
PATTERN_killer11:
DB $0A
DB $02, $01, $1C, $10, $11, $0C, $01, $12, $01, $01, $1C, $05, $01, $10, $2E, $02, $17, $0C, $02, $00, $01, $15, $05, $0C, $01, $04, $08, $01, $23, $05, $01, $10
DB $32, $0C, $12, $C1, $01, $1C, $05, $01, $10, $36, $0C, $02, $00, $01, $15, $05, $01, $10, $3A, $0C, $02, $01, $01, $10, $3E, $0C, $01, $1C, $10, $11, $0C, $01
DB $12, $01, $01, $1C, $05, $01, $10, $2E, $0C, $02, $00, $01, $15, $05, $0C, $01, $04, $08, $01, $23, $05, $01, $10, $32, $0C, $12, $C1, $01, $1C, $05, $01, $10
DB $36, $0C, $01, $15, $05, $01, $10, $3A, $0C, $02, $00, $02, $01, $01, $10, $3E, $0C, $01, $1C, $10, $11, $0C, $01, $12, $01, $01, $1C, $05, $01, $10, $2E, $0C
DB $02, $00, $01, $15, $05, $0C, $01, $04, $08, $01, $23, $05, $01, $10, $32, $0C, $12, $C1, $01, $1C, $05, $02, $36, $0C, $01, $1C, $10, $01, $15, $05, $01, $10
DB $2E, $02, $17, $0C, $02, $00, $02, $01, $0C, $01, $04, $08, $12, $81, $01, $1C, $05, $01, $10, $32, $0C, $02, $01, $01, $10, $36, $0C, $01, $1C, $10, $12, $81
DB $01, $1C, $05, $01, $10, $2E, $0C, $02, $00, $02, $01, $0C, $01, $04, $08, $12, $81, $01, $1C, $05, $01, $10, $32, $0C, $02, $01, $01, $10, $36, $0C, $12, $01
DB $01, $16, $05, $01, $10, $3A, $0C, $02, $00, $01, $0A, $05, $01, $10, $3E, $0C, $01, $1C, $10, $02, $01, $01, $10, $2E, $0C, $02, $00, $12, $C1, $01, $19, $05
DB $0C, $01, $04, $08, $01, $0D, $05, $01, $10, $32, $0C, $02, $01, $01, $10, $36, $0C, $01, $1C, $10, $12, $81, $01, $1C, $05, $01, $10, $3A, $0B, $02, $01, $0B
DB $12, $41, $01, $1C, $05, $01, $10, $3E, $0B, $02, $01, $00, $01, $07
SECTION "MkillerP12", ROMX
PATTERN_killer12:
DB $0A
DB $02, $01, $1A, $10, $11, $0C, $01, $12, $01, $01, $1A, $05, $01, $0E, $2E, $02, $17, $0C, $02, $00, $01, $13, $05, $0C, $01, $02, $08, $01, $21, $05, $01, $0E
DB $32, $0C, $12, $C1, $01, $1A, $05, $01, $0E, $36, $0C, $02, $00, $01, $13, $05, $01, $0E, $3A, $0C, $02, $01, $01, $0E, $3E, $0C, $01, $1A, $10, $11, $0C, $01
DB $12, $01, $01, $1A, $05, $01, $0E, $2E, $0C, $02, $00, $01, $13, $05, $0C, $01, $02, $08, $01, $21, $05, $01, $0E, $32, $0C, $12, $C1, $01, $1A, $05, $01, $0E
DB $36, $0C, $01, $13, $05, $01, $0E, $3A, $0C, $02, $00, $02, $01, $01, $0E, $3E, $0C, $01, $1A, $10, $11, $0C, $01, $12, $01, $01, $1A, $05, $01, $0E, $2E, $0C
DB $02, $00, $01, $13, $05, $0C, $01, $02, $08, $01, $21, $05, $01, $0E, $32, $0C, $12, $C1, $01, $1A, $05, $02, $36, $0C, $01, $1A, $10, $01, $13, $05, $01, $0E
DB $2E, $02, $17, $0C, $02, $00, $02, $01, $0C, $01, $02, $08, $12, $81, $01, $1A, $05, $01, $0E, $32, $0C, $02, $01, $01, $0E, $36, $0C, $01, $1A, $10, $12, $81
DB $01, $1A, $05, $01, $0E, $2E, $0C, $02, $00, $02, $01, $0C, $01, $02, $08, $12, $81, $01, $1A, $05, $01, $0E, $32, $0C, $02, $01, $01, $0E, $36, $0C, $12, $01
DB $01, $14, $05, $01, $0E, $3A, $0C, $02, $00, $01, $08, $05, $01, $0E, $3E, $0C, $01, $1A, $10, $02, $01, $01, $0E, $2E, $0C, $02, $00, $12, $C1, $01, $17, $05
DB $0C, $01, $02, $08, $01, $0B, $05, $01, $0E, $32, $0C, $02, $01, $01, $0E, $36, $0C, $01, $1A, $10, $12, $81, $01, $1A, $05, $01, $0E, $3A, $0B, $02, $01, $0B
DB $12, $41, $01, $1A, $05, $01, $0E, $3E, $0B, $02, $01, $00, $01, $07
SECTION "MkillerP13", ROMX
PATTERN_killer13:
DB $0A
DB $02, $01, $1B, $10, $11, $0C, $01, $12, $01, $01, $1B, $05, $01, $0F, $2E, $02, $17, $0C, $02, $00, $01, $14, $05, $0C, $01, $03, $08, $01, $22, $05, $01, $0F
DB $32, $0C, $12, $C1, $01, $1B, $05, $01, $0F, $36, $0C, $02, $00, $01, $14, $05, $01, $0F, $3A, $0C, $02, $01, $01, $0F, $3E, $0C, $01, $1B, $10, $11, $0C, $01
DB $12, $01, $01, $1B, $05, $01, $0F, $2E, $0C, $02, $00, $01, $14, $05, $0C, $01, $03, $08, $01, $22, $05, $01, $0F, $32, $0C, $12, $C1, $01, $1B, $05, $01, $0F
DB $36, $0C, $01, $14, $05, $01, $0F, $3A, $0C, $02, $00, $02, $01, $01, $0F, $3E, $0C, $01, $1B, $10, $11, $0C, $01, $12, $01, $01, $1B, $05, $01, $0F, $2E, $0C
DB $02, $00, $01, $14, $05, $0C, $01, $03, $08, $01, $22, $05, $01, $0F, $32, $0C, $12, $C1, $01, $1B, $05, $02, $36, $0C, $01, $1B, $10, $01, $14, $05, $01, $0F
DB $2E, $02, $17, $0C, $02, $00, $02, $01, $0C, $01, $03, $08, $12, $81, $01, $1B, $05, $01, $0F, $32, $0C, $02, $01, $01, $0F, $36, $0C, $01, $1B, $10, $12, $81
DB $01, $1B, $05, $01, $0F, $2E, $0C, $02, $00, $02, $01, $0C, $01, $03, $08, $12, $81, $01, $1B, $05, $01, $0F, $32, $0C, $02, $01, $01, $0F, $36, $0C, $12, $01
DB $01, $15, $05, $01, $0F, $3A, $0C, $02, $00, $01, $09, $05, $01, $0F, $3E, $0C, $01, $1B, $10, $02, $01, $01, $0F, $2E, $0C, $02, $00, $12, $C1, $01, $18, $05
DB $0C, $01, $03, $08, $01, $0C, $05, $01, $0F, $32, $0C, $02, $01, $01, $0F, $36, $0C, $01, $1B, $10, $12, $81, $01, $1B, $05, $01, $0F, $3A, $0B, $02, $01, $0B
DB $12, $41, $01, $1B, $05, $01, $0F, $3E, $0B, $02, $01, $00, $01, $07
SECTION "MkillerP14", ROMX
PATTERN_killer14:
DB $0A
DB $02, $01, $1C, $10, $03, $C1, $12, $01, $01, $10, $05, $01, $10, $2E, $02, $03, $0C, $02, $00, $03, $41, $12, $C1, $02, $05, $0C, $01, $04, $08, $03, $C1, $12
DB $81, $01, $10, $05, $01, $10, $32, $0C, $03, $41, $12, $41, $02, $05, $01, $10, $36, $0C, $02, $00, $03, $C1, $12, $01, $01, $10, $05, $01, $10, $3A, $0C, $03
DB $41, $12, $C1, $02, $01, $01, $10, $3E, $0C, $01, $1C, $10, $03, $C1, $12, $81, $01, $10, $05, $01, $10, $2E, $0C, $02, $00, $03, $41, $12, $41, $02, $05, $0C
DB $01, $04, $08, $03, $C1, $12, $01, $01, $14, $05, $01, $10, $32, $0C, $03, $41, $12, $C1, $02, $05, $01, $10, $36, $0C, $03, $C1, $12, $81, $01, $14, $05, $01
DB $10, $3A, $0C, $02, $00, $03, $41, $12, $41, $02, $05, $01, $10, $3E, $0C, $01, $1C, $10, $03, $C1, $12, $01, $01, $13, $05, $01, $10, $2E, $0C, $02, $00, $03
DB $41, $12, $C1, $02, $01, $0C, $01, $04, $08, $03, $C1, $12, $81, $01, $13, $05, $01, $10, $32, $0C, $03, $41, $12, $41, $02, $01, $02, $36, $0C, $01, $1C, $10
DB $03, $C1, $12, $01, $01, $10, $05, $01, $10, $2E, $0C, $02, $00, $03, $41, $12, $C1, $02, $05, $0C, $01, $04, $08, $03, $C1, $12, $81, $01, $10, $05, $01, $10
DB $32, $0C, $03, $41, $12, $41, $02, $05, $01, $10, $36, $0C, $01, $1C, $10, $03, $C1, $12, $01, $01, $14, $05, $01, $10, $2E, $0C, $02, $00, $03, $41, $12, $C1
DB $02, $01, $0C, $01, $04, $08, $03, $C1, $12, $01, $01, $14, $05, $01, $10, $32, $0C, $03, $41, $12, $C1, $02, $05, $01, $10, $36, $0C, $03, $C1, $12, $81, $01
DB $13, $05, $01, $10, $3A, $0C, $02, $00, $03, $41, $12, $41, $02, $05, $01, $10, $3E, $0C, $01, $1C, $10, $03, $C1, $12, $01, $01, $13, $05, $01, $10, $2E, $0C
DB $02, $00, $03, $41, $12, $C1, $02, $01, $0C, $01, $04, $08, $03, $C1, $12, $81, $01, $10, $05, $01, $10, $32, $0C, $03, $41, $12, $41, $02, $05, $01, $10, $36
DB $0C, $02, $00, $03, $C1, $12, $01, $01, $10, $05, $01, $10, $3A, $0C, $03, $41, $12, $C1, $02, $05, $01, $10, $3E, $00, $03, $07
SECTION "MkillerP15", ROMX
PATTERN_killer15:
DB $0A
DB $02, $01, $1C, $10, $03, $C1, $12, $01, $01, $10, $05, $01, $10, $2E, $02, $17, $0C, $02, $00, $03, $41, $12, $C1, $02, $05, $0C, $01, $04, $08, $03, $C1, $12
DB $81, $01, $10, $05, $01, $10, $32, $02, $1B, $0C, $03, $41, $12, $41, $02, $05, $01, $10, $36, $0C, $02, $00, $03, $C1, $12, $01, $01, $10, $05, $01, $10, $3A
DB $02, $27, $0C, $03, $41, $12, $C1, $02, $01, $01, $10, $3E, $0C, $01, $1C, $10, $03, $C1, $12, $81, $01, $10, $05, $01, $10, $2E, $0C, $02, $00, $03, $41, $12
DB $41, $02, $05, $0C, $01, $04, $08, $03, $C1, $12, $01, $01, $14, $05, $01, $10, $32, $02, $1F, $0C, $03, $41, $12, $C1, $02, $05, $01, $10, $36, $0C, $03, $C1
DB $12, $81, $01, $14, $05, $01, $10, $3A, $0C, $02, $00, $03, $41, $12, $41, $02, $05, $01, $10, $3E, $0C, $01, $1C, $10, $03, $C1, $12, $01, $01, $13, $05, $01
DB $10, $2E, $02, $27, $0C, $02, $00, $03, $41, $12, $C1, $02, $01, $0C, $01, $04, $08, $03, $C1, $12, $81, $01, $13, $05, $01, $10, $32, $02, $23, $0C, $03, $41
DB $12, $41, $02, $01, $02, $36, $02, $1B, $0C, $01, $1C, $10, $03, $C1, $12, $01, $01, $10, $05, $01, $10, $2E, $02, $23, $0C, $02, $00, $03, $41, $12, $C1, $02
DB $05, $0C, $01, $04, $08, $03, $C1, $12, $81, $01, $10, $05, $01, $10, $32, $02, $1B, $0C, $03, $41, $12, $41, $02, $05, $01, $10, $36, $0C, $01, $1C, $10, $03
DB $C1, $12, $01, $01, $14, $05, $01, $10, $2E, $0C, $02, $00, $03, $41, $12, $C1, $02, $01, $0C, $01, $04, $08, $03, $C1, $12, $01, $01, $14, $05, $01, $10, $32
DB $02, $27, $0C, $03, $41, $12, $C1, $02, $05, $01, $10, $36, $0C, $03, $C1, $12, $81, $01, $13, $05, $01, $10, $3A, $02, $1F, $0C, $02, $00, $03, $41, $12, $41
DB $02, $05, $01, $10, $3E, $0C, $01, $1C, $10, $03, $C1, $12, $01, $01, $13, $05, $01, $10, $2E, $02, $1B, $0C, $02, $00, $03, $41, $12, $C1, $02, $01, $0C, $01
DB $04, $08, $03, $C1, $12, $81, $01, $10, $05, $01, $10, $32, $02, $27, $0C, $03, $41, $12, $41, $02, $05, $01, $10, $36, $0C, $02, $00, $03, $C1, $12, $01, $01
DB $10, $05, $01, $10, $3A, $0C, $03, $41, $12, $C1, $02, $05, $01, $10, $3E, $00, $03, $07
SECTION "MkillerP16", ROMX
PATTERN_killer16:
DB $0A
DB $02, $01, $1C, $10, $03, $C1, $12, $01, $01, $10, $05, $01, $10, $2E, $02, $17, $0C, $02, $00, $03, $41, $12, $C1, $02, $05, $0C, $02, $01, $0E, $02, $27, $0E
DB $01, $1C, $10, $03, $C1, $12, $01, $01, $10, $05, $01, $10, $2E, $02, $03, $0C, $02, $00, $03, $41, $12, $C1, $02, $05, $0C, $02, $01, $00, $10, $01, $1C, $10
DB $03, $C1, $12, $01, $01, $10, $05, $01, $10, $2E, $0C, $02, $00, $03, $41, $12, $C1, $02, $05, $0C, $02, $01, $0E, $01, $1C, $10, $03, $C1, $12, $01, $01, $10
DB $05, $01, $10, $2E, $02, $17, $0C, $02, $00, $03, $41, $12, $C1, $02, $05, $0C, $02, $01, $02, $1B, $0E, $02, $27, $0E, $01, $1C, $10, $03, $C1, $12, $01, $01
DB $10, $05, $01, $10, $2E, $02, $03, $0C, $02, $00, $03, $41, $12, $C1, $02, $05, $0C, $02, $01, $00, $10, $01, $1C, $10, $03, $C1, $12, $01, $01, $10, $05, $01
DB $10, $2E, $0C, $02, $00, $03, $41, $12, $C1, $02, $05, $0C, $02, $01, $00, $07, $07
SECTION "MkillerP17", ROMX
PATTERN_killer17:
DB $0A
DB $02, $01, $1C, $10, $03, $C1, $12, $01, $01, $10, $05, $01, $10, $0E, $02, $17, $0C, $03, $41, $12, $C1, $02, $05, $0C, $02, $00, $02, $01, $02, $1B, $0E, $01
DB $10, $0E, $02, $27, $0E, $01, $1C, $10, $03, $C1, $12, $01, $01, $10, $05, $0C, $03, $41, $12, $C1, $02, $05, $0C, $01, $40, $44, $02, $01, $01, $1C, $0E, $02
DB $1F, $0E, $02, $00, $0E, $03, $C1, $12, $01, $01, $10, $05, $02, $27, $0C, $03, $41, $12, $C1, $02, $05, $0C, $02, $01, $01, $10, $0E, $02, $23, $0C, $02, $1B
DB $0C, $01, $1C, $10, $03, $C1, $12, $01, $01, $10, $05, $02, $23, $0C, $03, $41, $12, $C1, $02, $05, $0C, $01, $1C, $10, $02, $01, $02, $1B, $0E, $02, $00, $01
DB $10, $0E, $0E, $01, $1C, $10, $03, $C1, $12, $01, $01, $10, $05, $02, $27, $0C, $03, $41, $12, $C1, $02, $05, $0C, $01, $40, $44, $02, $01, $01, $1C, $0E, $02
DB $1F, $0E, $02, $00, $02, $1B, $0E, $01, $1C, $10, $03, $C1, $12, $01, $01, $10, $05, $02, $27, $0C, $02, $00, $03, $41, $12, $C1, $02, $05, $0C, $01, $1C, $48
DB $02, $01, $01, $10, $0E, $00, $07, $07
SECTION "MkillerP18", ROMX
PATTERN_killer18:
DB $0A
DB $02, $01, $1C, $10, $03, $C1, $12, $01, $01, $10, $05, $01, $10, $0E, $02, $17, $0C, $03, $41, $12, $C1, $02, $05, $0C, $02, $00, $02, $01, $02, $1B, $0E, $01
DB $28, $48, $01, $10, $0E, $02, $27, $0E, $01, $1C, $10, $03, $C1, $12, $01, $01, $10, $05, $0C, $03, $41, $12, $C1, $02, $05, $0C, $01, $40, $44, $02, $01, $01
DB $1C, $0E, $02, $1F, $0E, $02, $00, $0E, $03, $C1, $12, $01, $01, $10, $05, $02, $27, $0C, $03, $41, $12, $C1, $02, $05, $0C, $01, $28, $48, $02, $01, $01, $10
DB $0E, $02, $23, $0C, $02, $1B, $0C, $01, $1C, $10, $03, $C1, $12, $01, $01, $10, $05, $02, $23, $0C, $03, $41, $12, $C1, $02, $05, $0C, $01, $1C, $10, $02, $01
DB $02, $1B, $0E, $01, $1C, $48, $01, $10, $0E, $0E, $01, $1C, $10, $03, $C1, $12, $01, $01, $10, $05, $02, $27, $0C, $03, $41, $12, $C1, $02, $05, $0C, $01, $40
DB $44, $10, $25, $01, $40, $05, $01, $1C, $0E, $02, $1F, $0E, $02, $00, $0E, $01, $1C, $10, $0C, $02, $00, $0C, $01, $1C, $48, $01, $10, $0E, $0D, $05, $01, $00
DB $01, $07
SECTION "MkillerP19", ROMX
PATTERN_killer19:
DB $0A
DB $02, $01, $1C, $10, $03, $41, $12, $01, $01, $1C, $05, $05, $01, $01, $10, $0E, $02, $17, $0C, $12, $41, $01, $10, $05, $0C, $02, $00, $03, $61, $12, $81, $01
DB $1C, $05, $02, $1B, $0C, $12, $C1, $01, $10, $05, $0C, $01, $28, $48, $03, $81, $12, $81, $01, $1C, $05, $01, $10, $0E, $02, $27, $0C, $12, $41, $01, $10, $05
DB $0C, $01, $1C, $10, $03, $A1, $12, $01, $01, $1C, $05, $0C, $12, $41, $01, $10, $05, $0C, $01, $40, $44, $03, $C1, $12, $81, $01, $1C, $05, $01, $1C, $0E, $02
DB $1F, $0C, $12, $C1, $01, $10, $05, $0C, $02, $00, $12, $81, $01, $1C, $05, $0C, $03, $C1, $12, $41, $01, $10, $05, $0C, $12, $01, $01, $1C, $05, $02, $27, $0C
DB $03, $A1, $12, $41, $01, $10, $05, $0C, $01, $28, $48, $12, $81, $01, $1C, $05, $01, $10, $0E, $02, $23, $0C, $03, $81, $12, $C1, $01, $10, $05, $02, $1B, $0C
DB $01, $1C, $10, $03, $C1, $12, $01, $01, $17, $05, $02, $23, $0C, $12, $41, $01, $0B, $05, $0C, $01, $1C, $10, $12, $81, $01, $17, $05, $02, $1B, $0C, $12, $C1
DB $01, $0B, $05, $0C, $01, $1C, $48, $03, $A1, $12, $81, $01, $17, $05, $01, $10, $0E, $0C, $12, $41, $01, $0B, $05, $0C, $01, $1C, $10, $12, $01, $01, $17, $05
DB $02, $27, $0C, $12, $41, $01, $0B, $05, $0C, $01, $40, $44, $03, $81, $12, $81, $01, $17, $05, $01, $1C, $0E, $02, $1F, $0C, $12, $C1, $01, $0B, $05, $0C, $02
DB $00, $12, $81, $01, $0B, $05, $02, $1B, $0C, $12, $41, $01, $17, $05, $0C, $01, $1C, $10, $03, $41, $12, $01, $01, $0B, $05, $02, $27, $0C, $02, $00, $12, $41
DB $01, $17, $05, $0C, $01, $1C, $48, $12, $81, $01, $0B, $05, $01, $10, $0E, $0C, $03, $21, $12, $C1, $01, $17, $05, $00, $03, $07
SECTION "MkillerP20", ROMX
PATTERN_killer20:
DB $0A
DB $02, $01, $1A, $10, $03, $C1, $12, $01, $01, $15, $05, $01, $0E, $0E, $02, $17, $0C, $12, $41, $01, $09, $05, $0C, $02, $00, $12, $81, $01, $15, $05, $02, $1B
DB $0C, $12, $C1, $01, $09, $05, $0C, $01, $26, $48, $03, $A1, $12, $81, $01, $15, $05, $01, $0E, $0E, $02, $27, $0C, $12, $41, $01, $09, $05, $0C, $01, $1A, $10
DB $12, $01, $01, $15, $05, $0C, $12, $41, $01, $09, $05, $0C, $01, $3E, $44, $03, $81, $12, $81, $01, $15, $05, $01, $1A, $0E, $02, $1F, $0C, $12, $C1, $01, $09
DB $05, $0C, $02, $00, $12, $81, $01, $09, $05, $0C, $12, $41, $01, $15, $05, $0C, $03, $41, $12, $01, $01, $09, $05, $02, $27, $0C, $12, $41, $01, $15, $05, $0C
DB $01, $26, $48, $12, $81, $01, $09, $05, $01, $0E, $0E, $02, $23, $0C, $03, $21, $12, $C1, $01, $15, $05, $02, $1B, $0C, $01, $1A, $10, $03, $C1, $12, $81, $01
DB $1A, $05, $02, $23, $0C, $12, $C1, $01, $0E, $05, $0C, $01, $1A, $10, $12, $81, $01, $1A, $05, $02, $1B, $0C, $03, $C1, $12, $41, $01, $0B, $05, $0C, $01, $1A
DB $48, $12, $01, $01, $17, $05, $01, $0E, $0E, $0C, $03, $A1, $12, $41, $01, $0B, $05, $0C, $01, $1A, $10, $12, $81, $01, $17, $05, $02, $27, $0C, $03, $81, $12
DB $C1, $01, $0B, $05, $0C, $01, $3E, $44, $03, $C1, $12, $81, $01, $1A, $05, $01, $1A, $0E, $02, $1F, $0C, $12, $C1, $01, $0E, $05, $0C, $02, $00, $12, $81, $01
DB $1A, $05, $02, $1B, $0C, $03, $C1, $12, $41, $01, $0B, $05, $0C, $01, $1A, $10, $12, $01, $01, $17, $05, $02, $27, $0C, $02, $00, $03, $A1, $12, $41, $01, $0B
DB $05, $0C, $01, $1A, $48, $12, $81, $01, $17, $05, $01, $0E, $0E, $0C, $03, $81, $12, $C1, $01, $0B, $05, $00, $03, $07
SECTION "MkillerP21", ROMX
PATTERN_killer21:
DB $0A
DB $02, $01, $1B, $10, $03, $C1, $12, $01, $01, $16, $05, $01, $0F, $0E, $02, $17, $0C, $12, $41, $01, $0A, $05, $0C, $02, $00, $12, $81, $01, $16, $05, $02, $1B
DB $0C, $12, $C1, $01, $0A, $05, $0C, $01, $27, $48, $03, $A1, $12, $81, $01, $16, $05, $01, $0F, $0E, $02, $27, $0C, $12, $41, $01, $0A, $05, $0C, $01, $1B, $10
DB $12, $01, $01, $16, $05, $0C, $12, $41, $01, $0A, $05, $0C, $01, $3F, $44, $03, $81, $12, $81, $01, $16, $05, $01, $1B, $0E, $02, $1F, $0C, $12, $C1, $01, $0A
DB $05, $0C, $02, $00, $12, $81, $01, $0A, $05, $0C, $12, $41, $01, $16, $05, $0C, $03, $41, $12, $01, $01, $0A, $05, $02, $27, $0C, $12, $41, $01, $16, $05, $0C
DB $01, $27, $48, $12, $81, $01, $0A, $05, $01, $0F, $0E, $02, $23, $0C, $03, $21, $12, $C1, $01, $16, $05, $02, $1B, $0C, $01, $1B, $10, $03, $C1, $12, $01, $01
DB $1B, $05, $02, $23, $0C, $12, $41, $01, $0F, $05, $0C, $01, $1B, $10, $12, $81, $01, $1B, $05, $02, $1B, $0C, $12, $C1, $01, $0F, $05, $0C, $01, $1B, $48, $03
DB $A1, $12, $81, $01, $1B, $05, $01, $0F, $0E, $0C, $12, $41, $01, $0F, $05, $0C, $01, $1B, $10, $12, $01, $01, $1B, $05, $02, $27, $0C, $12, $41, $01, $0F, $05
DB $0C, $01, $3F, $44, $03, $81, $12, $81, $01, $1B, $05, $01, $1B, $0E, $02, $1F, $0C, $12, $C1, $01, $0F, $05, $0C, $02, $00, $12, $81, $01, $0F, $05, $02, $1B
DB $0C, $12, $41, $01, $1B, $05, $0C, $01, $1B, $10, $03, $41, $12, $01, $01, $0F, $05, $02, $27, $0C, $02, $00, $12, $41, $01, $1B, $05, $0C, $01, $1B, $48, $12
DB $81, $01, $0F, $05, $01, $0F, $0E, $0C, $03, $21, $12, $C1, $01, $1B, $05, $00, $03, $07
SECTION "MkillerP22", ROMX
PATTERN_killer22:
DB $0A
DB $02, $01, $1C, $10, $03, $41, $12, $01, $01, $1C, $05, $01, $10, $0E, $02, $17, $0C, $12, $41, $01, $10, $05, $0C, $02, $00, $03, $61, $12, $81, $01, $1C, $05
DB $02, $1B, $0C, $12, $C1, $01, $10, $05, $0C, $01, $28, $48, $03, $81, $12, $81, $01, $1C, $05, $01, $10, $0E, $02, $27, $0C, $12, $41, $01, $10, $05, $0C, $01
DB $1C, $10, $03, $A1, $12, $01, $01, $1C, $05, $0C, $12, $41, $01, $10, $05, $0C, $01, $40, $44, $03, $C1, $12, $81, $01, $1C, $05, $01, $1C, $0E, $02, $1F, $0C
DB $12, $C1, $01, $10, $05, $0C, $02, $00, $12, $81, $01, $1C, $05, $0C, $03, $C1, $12, $41, $01, $10, $05, $0C, $12, $01, $01, $1C, $05, $02, $27, $0C, $03, $A1
DB $12, $41, $01, $10, $05, $0C, $01, $28, $48, $12, $81, $01, $1C, $05, $01, $10, $0E, $02, $23, $0C, $03, $81, $12, $C1, $01, $10, $05, $02, $1B, $0C, $01, $1C
DB $10, $03, $C1, $12, $01, $01, $15, $05, $02, $23, $0C, $12, $41, $01, $09, $05, $0C, $01, $1C, $10, $12, $81, $01, $15, $05, $02, $1B, $0C, $12, $C1, $01, $09
DB $05, $0C, $01, $1C, $48, $03, $A1, $12, $81, $01, $15, $05, $01, $10, $0E, $0C, $12, $41, $01, $09, $05, $0C, $01, $1C, $10, $12, $01, $01, $15, $05, $02, $27
DB $0C, $12, $41, $01, $09, $05, $0C, $01, $40, $44, $03, $81, $12, $81, $01, $15, $05, $01, $1C, $0E, $02, $1F, $0C, $12, $C1, $01, $09, $05, $0C, $02, $00, $12
DB $81, $01, $09, $05, $02, $1B, $0C, $12, $41, $01, $15, $05, $0C, $01, $1C, $10, $03, $41, $12, $01, $01, $09, $05, $02, $27, $0C, $02, $00, $12, $41, $01, $15
DB $05, $0C, $01, $1C, $48, $12, $81, $01, $09, $05, $01, $10, $0E, $0C, $03, $21, $12, $C1, $01, $15, $05, $00, $03, $07
SECTION "MkillerP23", ROMX
PATTERN_killer23:
DB $0A
DB $02, $01, $1A, $10, $03, $C1, $12, $01, $01, $17, $05, $01, $0E, $0E, $02, $17, $0C, $12, $41, $01, $0B, $05, $0C, $02, $00, $12, $81, $01, $17, $05, $02, $1B
DB $0C, $12, $C1, $01, $0B, $05, $0C, $01, $26, $48, $03, $A1, $12, $81, $01, $17, $05, $01, $0E, $0E, $02, $27, $0C, $12, $41, $01, $0B, $05, $0C, $01, $1A, $10
DB $12, $01, $01, $17, $05, $0C, $12, $41, $01, $0B, $05, $0C, $01, $3E, $44, $03, $81, $12, $81, $01, $17, $05, $01, $1A, $0E, $02, $1F, $0C, $12, $C1, $01, $0B
DB $05, $0C, $02, $00, $12, $81, $01, $0B, $05, $0C, $12, $41, $01, $17, $05, $0C, $03, $41, $12, $01, $01, $0B, $05, $02, $27, $0C, $12, $41, $01, $17, $05, $0C
DB $01, $26, $48, $12, $81, $01, $0B, $05, $01, $0E, $0E, $02, $23, $0C, $03, $21, $12, $C1, $01, $17, $05, $02, $1B, $0C, $01, $1A, $10, $03, $C1, $12, $81, $01
DB $1F, $05, $02, $23, $0C, $12, $C1, $01, $13, $05, $0C, $01, $1A, $10, $12, $81, $01, $1F, $05, $02, $1B, $0C, $03, $C1, $12, $41, $01, $0E, $05, $0C, $01, $1A
DB $48, $12, $01, $01, $1A, $05, $01, $0E, $0E, $0C, $03, $A1, $12, $41, $01, $0E, $05, $0C, $01, $1A, $10, $12, $81, $01, $1A, $05, $02, $27, $0C, $03, $81, $12
DB $C1, $01, $0E, $05, $0C, $01, $3E, $44, $03, $C1, $12, $81, $01, $1F, $05, $01, $1A, $0E, $02, $1F, $0C, $12, $C1, $01, $13, $05, $0C, $02, $00, $12, $81, $01
DB $1F, $05, $02, $1B, $0C, $03, $C1, $12, $41, $01, $0E, $05, $0C, $01, $1A, $10, $12, $01, $01, $1A, $05, $02, $27, $0C, $02, $00, $03, $A1, $12, $41, $01, $0E
DB $05, $0C, $01, $1A, $48, $12, $81, $01, $1A, $05, $01, $0E, $0E, $0C, $03, $81, $12, $C1, $01, $0E, $05, $00, $03, $07
SECTION "MkillerP24", ROMX
PATTERN_killer24:
DB $0A
DB $02, $01, $1B, $10, $03, $C1, $12, $01, $01, $1B, $05, $01, $0F, $0E, $02, $17, $0C, $12, $41, $01, $0F, $05, $0C, $02, $00, $12, $81, $01, $1B, $05, $02, $1B
DB $0C, $12, $C1, $01, $0F, $05, $0C, $01, $27, $48, $03, $A1, $12, $81, $01, $1B, $05, $01, $0F, $0E, $02, $27, $0C, $12, $41, $01, $0F, $05, $0C, $01, $1B, $10
DB $12, $01, $01, $1B, $05, $0C, $12, $41, $01, $0F, $05, $0C, $01, $3F, $44, $12, $81, $01, $1B, $05, $01, $1B, $0E, $02, $1F, $0C, $12, $C1, $01, $0F, $05, $0C
DB $02, $00, $12, $81, $01, $0F, $05, $0C, $12, $41, $01, $1B, $05, $0C, $03, $81, $12, $01, $01, $0F, $05, $02, $27, $0C, $12, $41, $01, $1B, $05, $0C, $01, $27
DB $48, $12, $81, $01, $0F, $05, $01, $0F, $0E, $02, $23, $0C, $12, $C1, $01, $1B, $05, $02, $1B, $0C, $01, $1B, $10, $12, $01, $01, $1B, $05, $02, $23, $0C, $12
DB $41, $01, $0F, $05, $0C, $01, $1B, $10, $12, $81, $01, $1B, $05, $02, $1B, $0C, $12, $C1, $01, $0F, $05, $0C, $01, $1B, $48, $03, $41, $12, $81, $01, $1B, $05
DB $01, $0F, $0E, $0C, $12, $41, $01, $0F, $05, $0C, $01, $1B, $10, $12, $01, $01, $1B, $05, $02, $27, $0C, $12, $41, $01, $0F, $05, $0C, $01, $3F, $44, $12, $81
DB $01, $1B, $05, $01, $1B, $0E, $02, $1F, $0C, $12, $C1, $01, $0F, $05, $0C, $02, $00, $12, $81, $01, $0F, $05, $02, $1B, $0C, $12, $41, $01, $1B, $05, $0C, $01
DB $1B, $10, $03, $21, $12, $01, $01, $0F, $05, $02, $27, $0C, $02, $00, $12, $41, $01, $1B, $05, $0C, $01, $1B, $48, $12, $81, $01, $0F, $05, $01, $0F, $0E, $0C
DB $03, $21, $12, $C1, $01, $1B, $05, $00, $03, $07
SECTION "MkillerP25", ROMX
PATTERN_killer25:
DB $0A
DB $02, $01, $1C, $10, $03, $C1, $12, $01, $01, $1C, $05, $01, $10, $0E, $02, $17, $0C, $12, $41, $01, $10, $05, $0C, $02, $00, $12, $81, $01, $1C, $05, $02, $1B
DB $0C, $12, $C1, $01, $10, $05, $0C, $01, $28, $48, $03, $A1, $12, $81, $01, $1C, $05, $01, $10, $0E, $02, $27, $0C, $12, $41, $01, $10, $05, $0C, $01, $1C, $10
DB $12, $01, $01, $1C, $05, $0C, $12, $41, $01, $10, $05, $0C, $01, $40, $44, $12, $81, $01, $1C, $05, $01, $1C, $0E, $02, $1F, $0C, $12, $C1, $01, $10, $05, $0C
DB $02, $00, $12, $81, $01, $10, $05, $0C, $12, $41, $01, $1C, $05, $0C, $03, $81, $12, $01, $01, $10, $05, $02, $27, $0C, $12, $41, $01, $1C, $05, $0C, $01, $28
DB $48, $12, $81, $01, $10, $05, $01, $10, $0E, $02, $23, $0C, $12, $C1, $01, $1C, $05, $02, $1B, $0C, $01, $1C, $10, $12, $01, $01, $1C, $05, $02, $23, $0C, $12
DB $41, $01, $10, $05, $0C, $01, $1C, $10, $12, $81, $01, $1C, $05, $02, $1B, $0C, $12, $C1, $01, $10, $05, $0C, $01, $1C, $48, $03, $41, $12, $81, $01, $1C, $05
DB $01, $10, $0E, $0C, $12, $41, $01, $10, $05, $0C, $01, $1C, $10, $12, $01, $01, $1C, $05, $02, $27, $0C, $12, $41, $01, $10, $05, $0C, $01, $40, $44, $12, $81
DB $01, $1C, $05, $01, $1C, $0E, $02, $1F, $0C, $12, $C1, $01, $10, $05, $0C, $02, $00, $12, $81, $01, $10, $05, $02, $1B, $0C, $12, $41, $01, $1C, $05, $0C, $01
DB $1C, $10, $03, $21, $12, $01, $01, $10, $05, $02, $27, $0C, $02, $00, $12, $41, $01, $1C, $05, $0C, $01, $1C, $48, $12, $81, $01, $10, $05, $01, $10, $0E, $0C
DB $03, $21, $12, $C1, $01, $1C, $05, $00, $03, $07
SECTION "MkillerP26", ROMX
PATTERN_killer26:
DB $0A
DB $02, $01, $1C, $10, $02, $01, $01, $10, $0E, $02, $17, $0E, $02, $00, $02, $1B, $0E, $01, $28, $48, $01, $10, $0E, $02, $27, $0E, $01, $1C, $10, $0E, $01, $40
DB $44, $01, $1C, $0E, $02, $1F, $0E, $02, $00, $0E, $02, $27, $0E, $01, $28, $48, $01, $10, $0E, $02, $23, $0C, $02, $1B, $0C, $01, $1C, $10, $02, $23, $0E, $01
DB $1C, $10, $02, $1B, $0E, $01, $1C, $48, $01, $10, $0E, $0E, $01, $1C, $10, $02, $27, $0E, $01, $40, $44, $01, $1C, $0E, $02, $1F, $0E, $01, $34, $4C, $02, $1B
DB $0E, $01, $1C, $10, $02, $27, $0C, $02, $00, $0C, $01, $1C, $48, $01, $10, $0E, $00, $07, $07
SECTION "MkillerP27", ROMX
PATTERN_killer27:
DB $0A
DB $02, $01, $1C, $10, $02, $01, $01, $10, $0E, $02, $17, $0E, $02, $00, $02, $1B, $0E, $01, $28, $48, $01, $10, $0E, $02, $27, $0E, $01, $1C, $10, $0E, $01, $40
DB $44, $01, $1C, $0E, $02, $1F, $0E, $01, $34, $4C, $0E, $01, $34, $50, $02, $27, $0C, $02, $00, $0C, $01, $28, $48, $01, $10, $0E, $02, $23, $0C, $02, $1B, $0C
DB $01, $1C, $10, $02, $23, $0E, $01, $1C, $10, $02, $1B, $0E, $01, $1C, $48, $01, $10, $0E, $0E, $01, $1C, $10, $02, $27, $0E, $01, $40, $44, $01, $1C, $0E, $02
DB $1F, $0E, $01, $34, $4C, $02, $1B, $0E, $01, $1C, $10, $02, $27, $0C, $02, $00, $0C, $01, $1C, $48, $01, $10, $0E, $00, $07, $07
SECTION "MkillerP28", ROMX
PATTERN_killer28:
DB $0A
DB $02, $01, $1C, $10, $02, $01, $01, $10, $0E, $02, $17, $0E, $02, $00, $0E, $02, $02, $00, $18, $01, $10, $0E, $0E, $01, $1C, $10, $0E, $02, $00, $0C, $02, $02
DB $0C, $01, $1C, $10, $02, $23, $0E, $01, $1C, $10, $02, $1B, $0E, $01, $1C, $48, $01, $10, $0E, $0E, $01, $1C, $10, $02, $27, $0E, $01, $40, $44, $01, $1C, $0E
DB $02, $1F, $0E, $01, $34, $4C, $02, $1B, $0E, $01, $1C, $10, $02, $27, $0C, $02, $00, $0C, $01, $1C, $48, $01, $10, $0E, $00, $07, $07
SECTION "MkillerP29", ROMX
PATTERN_killer29:
DB $0A
DB $02, $01, $1C, $10, $12, $81, $03, $A1, $11, $37, $01, $01, $1C, $05, $01, $10, $0E, $02, $17, $0C, $12, $41, $02, $05, $0C, $02, $00, $12, $01, $02, $05, $02
DB $1B, $0C, $12, $C1, $02, $05, $0C, $01, $28, $48, $12, $81, $03, $81, $02, $05, $01, $10, $0E, $02, $27, $0C, $12, $41, $02, $05, $0C, $01, $1C, $10, $12, $81
DB $03, $A1, $01, $1C, $05, $0C, $12, $41, $02, $05, $0C, $01, $40, $44, $12, $01, $02, $05, $01, $1C, $0E, $02, $1F, $0C, $12, $C1, $02, $05, $0C, $02, $00, $12
DB $81, $03, $81, $02, $05, $0C, $12, $41, $02, $05, $0C, $12, $01, $03, $41, $02, $05, $02, $27, $0C, $12, $C1, $02, $05, $0C, $01, $28, $48, $12, $81, $03, $A1
DB $01, $1C, $05, $01, $10, $0E, $02, $23, $0C, $12, $41, $03, $41, $02, $05, $02, $1B, $0C, $01, $1C, $10, $12, $81, $03, $A1, $01, $1C, $05, $02, $23, $0C, $12
DB $41, $02, $05, $0C, $01, $1C, $10, $12, $01, $02, $05, $02, $1B, $0C, $12, $C1, $02, $05, $0C, $01, $1C, $48, $12, $81, $03, $81, $02, $05, $01, $10, $0E, $0C
DB $12, $41, $02, $05, $0C, $01, $1C, $10, $12, $01, $03, $41, $02, $05, $02, $27, $0C, $12, $C1, $02, $05, $0C, $01, $40, $44, $12, $81, $03, $A1, $01, $1C, $05
DB $01, $1C, $0E, $02, $1F, $0C, $12, $41, $02, $05, $0C, $02, $00, $12, $01, $02, $05, $02, $1B, $0C, $12, $C1, $02, $05, $0C, $01, $1C, $10, $12, $81, $03, $81
DB $02, $05, $02, $27, $0C, $02, $00, $12, $41, $02, $05, $0C, $01, $1C, $48, $12, $81, $03, $A1, $01, $1C, $05, $01, $10, $0E, $0C, $12, $41, $03, $41, $02, $05
DB $00, $03, $07
SECTION "MkillerP30", ROMX
PATTERN_killer30:
DB $0A
DB $02, $01, $1C, $10, $12, $81, $03, $A1, $11, $57, $01, $01, $1C, $05, $01, $10, $0E, $02, $17, $0C, $12, $41, $02, $05, $0C, $02, $00, $12, $01, $02, $05, $02
DB $1B, $0C, $12, $C1, $02, $05, $0C, $01, $28, $48, $12, $81, $03, $81, $02, $05, $01, $10, $0E, $02, $27, $0C, $12, $41, $02, $05, $0C, $01, $1C, $10, $12, $81
DB $03, $A1, $01, $1C, $05, $0C, $12, $41, $02, $05, $0C, $01, $40, $44, $12, $01, $02, $05, $01, $1C, $0E, $02, $1F, $0C, $12, $C1, $02, $05, $0C, $02, $00, $12
DB $81, $03, $81, $02, $05, $0C, $12, $41, $02, $05, $0C, $12, $01, $03, $41, $02, $05, $02, $27, $0C, $12, $C1, $02, $05, $0C, $01, $28, $48, $12, $81, $03, $A1
DB $01, $1C, $05, $01, $10, $0E, $02, $23, $0C, $12, $41, $03, $41, $02, $05, $02, $1B, $0C, $01, $1C, $10, $12, $81, $03, $A1, $01, $1C, $05, $02, $23, $0C, $12
DB $41, $02, $05, $0C, $01, $1C, $10, $12, $01, $02, $05, $02, $1B, $0C, $12, $C1, $02, $05, $0C, $01, $1C, $48, $12, $81, $03, $81, $02, $05, $01, $10, $0E, $0C
DB $12, $41, $02, $05, $0C, $01, $1C, $10, $12, $01, $03, $41, $02, $05, $02, $27, $0C, $12, $C1, $02, $05, $0C, $01, $40, $44, $12, $81, $03, $A1, $01, $1C, $05
DB $01, $1C, $0E, $02, $1F, $0C, $12, $41, $02, $05, $0C, $02, $00, $12, $01, $02, $05, $02, $1B, $0C, $12, $C1, $02, $05, $0C, $01, $1C, $10, $12, $81, $03, $81
DB $02, $05, $02, $27, $0C, $02, $00, $12, $41, $02, $05, $0C, $01, $1C, $48, $12, $81, $03, $A1, $01, $1C, $05, $01, $10, $0E, $0C, $12, $41, $03, $41, $02, $05
DB $00, $03, $07
SECTION "MkillerP31", ROMX
PATTERN_killer31:
DB $0A
DB $02, $01, $1A, $10, $12, $81, $03, $A1, $11, $47, $01, $01, $1A, $05, $01, $0E, $0E, $02, $17, $0C, $12, $41, $02, $05, $0C, $02, $00, $12, $01, $02, $05, $02
DB $1B, $0C, $12, $C1, $02, $05, $0C, $01, $26, $48, $12, $81, $03, $81, $02, $05, $01, $0E, $0E, $02, $27, $0C, $12, $41, $02, $05, $0C, $01, $1A, $10, $12, $81
DB $03, $A1, $01, $1A, $05, $0C, $12, $41, $02, $05, $0C, $01, $3E, $44, $12, $01, $02, $05, $01, $1A, $0E, $02, $1F, $0C, $12, $C1, $02, $05, $0C, $02, $00, $12
DB $81, $03, $81, $02, $05, $0C, $12, $41, $02, $05, $0C, $12, $01, $03, $41, $02, $05, $02, $27, $0C, $12, $C1, $02, $05, $0C, $01, $26, $48, $12, $81, $03, $A1
DB $01, $1A, $05, $01, $0E, $0E, $02, $23, $0C, $12, $41, $03, $41, $02, $05, $02, $1B, $0C, $01, $1A, $10, $12, $81, $03, $A1, $01, $1A, $05, $02, $23, $0C, $12
DB $41, $02, $05, $0C, $01, $1A, $10, $12, $01, $02, $05, $02, $1B, $0C, $12, $C1, $02, $05, $0C, $01, $1A, $48, $12, $81, $03, $81, $02, $05, $01, $0E, $0E, $0C
DB $12, $41, $02, $05, $0C, $01, $1A, $10, $12, $01, $03, $41, $02, $05, $02, $27, $0C, $12, $C1, $02, $05, $0C, $01, $3E, $44, $12, $81, $03, $A1, $01, $1A, $05
DB $01, $1A, $0E, $02, $1F, $0C, $12, $41, $02, $05, $0C, $02, $00, $12, $01, $02, $05, $02, $1B, $0C, $12, $C1, $02, $05, $0C, $01, $1A, $10, $12, $81, $03, $81
DB $02, $05, $02, $27, $0C, $02, $00, $12, $41, $02, $05, $0C, $01, $1A, $48, $12, $81, $03, $A1, $01, $1A, $05, $01, $0E, $0E, $0C, $12, $41, $03, $41, $02, $05
DB $00, $03, $07
SECTION "MkillerP32", ROMX
PATTERN_killer32:
DB $0A
DB $02, $01, $1B, $10, $12, $81, $03, $A1, $11, $37, $01, $01, $1B, $05, $01, $0F, $0E, $02, $17, $0C, $12, $41, $02, $05, $0C, $02, $00, $12, $01, $02, $05, $02
DB $1B, $0C, $12, $C1, $02, $05, $0C, $01, $27, $48, $12, $81, $03, $81, $02, $05, $01, $0F, $0E, $02, $27, $0C, $12, $41, $02, $05, $0C, $01, $1B, $10, $12, $81
DB $03, $A1, $01, $1B, $05, $0C, $12, $41, $02, $05, $0C, $01, $3F, $44, $12, $01, $02, $05, $01, $1B, $0E, $02, $1F, $0C, $12, $C1, $02, $05, $0C, $02, $00, $12
DB $81, $03, $81, $02, $05, $0C, $12, $41, $02, $05, $0C, $12, $01, $03, $41, $02, $05, $02, $27, $0C, $12, $C1, $02, $05, $0C, $01, $27, $48, $12, $81, $03, $A1
DB $01, $1B, $05, $01, $0F, $0E, $02, $23, $0C, $12, $41, $03, $41, $02, $05, $02, $1B, $0C, $01, $1B, $10, $12, $81, $03, $A1, $01, $1B, $05, $02, $23, $0C, $12
DB $41, $02, $05, $0C, $01, $1B, $10, $12, $01, $02, $05, $02, $1B, $0C, $12, $C1, $02, $05, $0C, $01, $1B, $48, $12, $81, $03, $81, $02, $05, $01, $0F, $0E, $0C
DB $12, $41, $02, $05, $0C, $01, $1B, $10, $12, $01, $03, $41, $02, $05, $02, $27, $0C, $12, $C1, $02, $05, $0C, $01, $3F, $44, $12, $81, $03, $A1, $01, $1B, $05
DB $01, $1B, $0E, $02, $1F, $0C, $12, $41, $02, $05, $0C, $02, $00, $12, $01, $02, $05, $02, $1B, $0C, $12, $C1, $02, $05, $0C, $01, $1B, $10, $12, $81, $03, $81
DB $02, $05, $02, $27, $0C, $02, $00, $12, $41, $02, $05, $0C, $01, $1B, $48, $12, $81, $03, $A1, $01, $1B, $05, $01, $0F, $0E, $0C, $12, $41, $03, $41, $02, $05
DB $00, $03, $07
SECTION "MkillerP33", ROMX
PATTERN_killer33:
DB $0A
DB $02, $01, $1C, $10, $12, $81, $03, $A1, $11, $57, $01, $01, $1C, $05, $01, $10, $0E, $02, $17, $0C, $12, $41, $02, $05, $0C, $02, $00, $12, $01, $02, $05, $01
DB $1C, $0E, $02, $1B, $0C, $12, $C1, $02, $05, $0C, $01, $28, $48, $12, $81, $03, $81, $02, $05, $01, $10, $0E, $02, $27, $0C, $12, $41, $02, $05, $0C, $01, $1C
DB $10, $12, $81, $03, $A1, $01, $1C, $05, $0C, $12, $41, $02, $05, $0C, $01, $40, $44, $12, $01, $02, $05, $01, $1C, $0E, $02, $1F, $0C, $12, $C1, $02, $05, $0C
DB $02, $00, $12, $81, $03, $81, $02, $05, $0C, $12, $41, $02, $05, $0C, $12, $01, $03, $41, $02, $05, $02, $27, $0C, $12, $C1, $02, $05, $0C, $01, $28, $48, $12
DB $81, $03, $21, $01, $1C, $05, $02, $02, $02, $23, $0C, $12, $41, $02, $05, $02, $1B, $0C, $01, $1C, $10, $12, $01, $02, $05, $02, $23, $0C, $12, $C1, $02, $05
DB $0C, $01, $1C, $10, $12, $81, $03, $11, $02, $05, $02, $1B, $0C, $12, $41, $02, $05, $0C, $01, $1C, $48, $12, $01, $03, $01, $02, $05, $0C, $12, $C1, $02, $05
DB $0C, $01, $1C, $10, $02, $01, $02, $27, $0E, $01, $40, $44, $02, $1F, $0E, $02, $00, $02, $1B, $0E, $01, $1C, $10, $02, $27, $0C, $02, $00, $0C, $01, $1C, $48
DB $00, $07, $07
SECTION "MkillerP34", ROMX
PATTERN_killer34:
DB $0A
DB $02, $01, $1C, $10, $12, $81, $03, $A1, $11, $27, $01, $01, $1C, $05, $01, $10, $0E, $02, $17, $0C, $12, $41, $02, $05, $0C, $02, $00, $12, $01, $01, $28, $05
DB $01, $1C, $0E, $02, $1B, $0C, $12, $C1, $02, $05, $0C, $01, $28, $48, $12, $81, $03, $81, $01, $1C, $05, $01, $10, $0E, $02, $27, $0C, $12, $41, $02, $05, $0C
DB $01, $1C, $10, $12, $81, $03, $A1, $01, $28, $05, $01, $10, $2E, $02, $1B, $0C, $12, $41, $02, $05, $0C, $01, $40, $44, $12, $01, $01, $1C, $05, $01, $1C, $0E
DB $02, $1F, $0C, $12, $C1, $02, $05, $0C, $02, $00, $12, $81, $03, $81, $01, $28, $05, $01, $1C, $3A, $02, $1B, $0C, $12, $41, $02, $05, $0C, $12, $01, $03, $41
DB $01, $1C, $05, $01, $10, $2E, $02, $27, $0C, $12, $C1, $02, $05, $0C, $01, $28, $48, $12, $81, $03, $A1, $01, $28, $05, $01, $1C, $2E, $02, $23, $0C, $12, $41
DB $03, $41, $02, $05, $02, $1B, $0C, $01, $1C, $10, $12, $81, $03, $A1, $11, $27, $01, $01, $1C, $05, $01, $10, $0E, $02, $23, $0C, $12, $41, $02, $05, $0C, $01
DB $1C, $10, $12, $01, $01, $28, $05, $01, $10, $2E, $02, $1B, $0C, $12, $C1, $02, $05, $0C, $01, $1C, $48, $12, $81, $03, $81, $01, $1C, $05, $01, $1C, $0E, $02
DB $1B, $0C, $12, $41, $02, $05, $0C, $01, $1C, $10, $12, $81, $03, $A1, $01, $28, $05, $01, $10, $32, $02, $27, $0C, $12, $41, $02, $05, $0C, $01, $40, $44, $12
DB $01, $01, $1C, $05, $01, $10, $36, $02, $1F, $0C, $12, $C1, $02, $05, $0C, $02, $00, $12, $81, $03, $81, $01, $28, $05, $01, $1C, $0E, $02, $1B, $0C, $12, $41
DB $02, $05, $0C, $01, $1C, $10, $12, $01, $03, $41, $01, $1C, $05, $01, $10, $3A, $02, $27, $0C, $02, $00, $12, $C1, $02, $05, $0C, $01, $1C, $48, $12, $81, $03
DB $A1, $01, $28, $05, $01, $10, $3E, $02, $1B, $0C, $12, $41, $03, $41, $02, $05, $00, $03, $07
SECTION "MkillerP35", ROMX
PATTERN_killer35:
DB $0A
DB $02, $01, $1C, $10, $12, $81, $03, $A1, $11, $28, $01, $01, $1C, $05, $01, $10, $0E, $02, $17, $0C, $12, $41, $02, $05, $0C, $02, $00, $12, $01, $01, $28, $05
DB $01, $1C, $0E, $02, $1B, $0C, $12, $C1, $02, $05, $0C, $01, $28, $48, $12, $81, $03, $81, $01, $1C, $05, $01, $10, $0E, $02, $27, $0C, $12, $41, $02, $05, $0C
DB $01, $1C, $10, $12, $81, $03, $A1, $01, $28, $05, $01, $10, $2E, $02, $1B, $0C, $12, $41, $02, $05, $0C, $01, $40, $44, $12, $01, $01, $1C, $05, $01, $1C, $0E
DB $02, $1F, $0C, $12, $C1, $02, $05, $0C, $02, $00, $12, $81, $03, $81, $01, $28, $05, $01, $1C, $3A, $02, $1B, $0C, $12, $41, $02, $05, $0C, $12, $01, $03, $41
DB $01, $1C, $05, $01, $10, $2E, $02, $27, $0C, $12, $C1, $02, $05, $0C, $01, $28, $48, $12, $81, $03, $A1, $01, $28, $05, $01, $1C, $2E, $02, $23, $0C, $12, $41
DB $03, $41, $02, $05, $02, $1B, $0C, $01, $1C, $10, $12, $81, $03, $A1, $11, $27, $01, $01, $1C, $05, $01, $10, $0E, $02, $23, $0C, $12, $41, $02, $05, $0C, $01
DB $1C, $10, $12, $01, $01, $28, $05, $01, $10, $2E, $02, $1B, $0C, $12, $C1, $02, $05, $0C, $01, $1C, $48, $12, $81, $03, $81, $01, $1C, $05, $01, $1C, $0E, $02
DB $1B, $0C, $12, $41, $02, $05, $0C, $01, $1C, $10, $12, $81, $03, $A1, $01, $28, $05, $01, $10, $32, $02, $27, $0C, $12, $41, $02, $05, $0C, $01, $40, $44, $12
DB $01, $01, $1C, $05, $01, $10, $36, $02, $1F, $0C, $12, $C1, $02, $05, $0C, $02, $00, $12, $81, $03, $81, $01, $28, $05, $01, $1C, $0E, $02, $1B, $0C, $12, $41
DB $02, $05, $0C, $01, $1C, $10, $12, $01, $03, $41, $01, $1C, $05, $01, $10, $3A, $02, $27, $0C, $02, $00, $12, $C1, $02, $05, $0C, $01, $1C, $48, $12, $81, $03
DB $A1, $01, $28, $05, $01, $10, $3E, $02, $1B, $0C, $12, $41, $03, $41, $02, $05, $00, $03, $07
SECTION "MkillerP36", ROMX
PATTERN_killer36:
DB $0A
DB $02, $01, $1A, $10, $12, $81, $03, $A1, $11, $27, $01, $01, $1A, $05, $01, $0E, $0E, $02, $17, $0C, $12, $41, $02, $05, $0C, $02, $00, $12, $01, $01, $26, $05
DB $01, $1A, $0E, $02, $1B, $0C, $12, $C1, $02, $05, $0C, $01, $26, $48, $12, $81, $03, $81, $01, $1A, $05, $01, $0E, $0E, $02, $27, $0C, $12, $41, $02, $05, $0C
DB $01, $1A, $10, $12, $81, $03, $A1, $01, $26, $05, $01, $0E, $2E, $02, $1B, $0C, $12, $41, $02, $05, $0C, $01, $3E, $44, $12, $01, $01, $1A, $05, $01, $1A, $0E
DB $02, $1F, $0C, $12, $C1, $02, $05, $0C, $02, $00, $12, $81, $03, $81, $01, $26, $05, $01, $1A, $3A, $02, $1B, $0C, $12, $41, $02, $05, $0C, $12, $01, $03, $41
DB $01, $1A, $05, $01, $0E, $2E, $02, $27, $0C, $12, $C1, $02, $05, $0C, $01, $26, $48, $12, $81, $03, $A1, $01, $26, $05, $01, $1A, $2E, $02, $23, $0C, $12, $41
DB $03, $41, $02, $05, $02, $1B, $0C, $01, $1A, $10, $12, $81, $03, $A1, $11, $27, $01, $01, $1A, $05, $01, $0E, $0E, $02, $23, $0C, $12, $41, $02, $05, $0C, $01
DB $1A, $10, $12, $01, $01, $26, $05, $01, $0E, $2E, $02, $1B, $0C, $12, $C1, $02, $05, $0C, $01, $1A, $48, $12, $81, $03, $81, $01, $1A, $05, $01, $1A, $0E, $02
DB $1B, $0C, $12, $41, $02, $05, $0C, $01, $1A, $10, $12, $81, $03, $A1, $01, $26, $05, $01, $0E, $32, $02, $27, $0C, $12, $41, $02, $05, $0C, $01, $3E, $44, $12
DB $01, $01, $1A, $05, $01, $0E, $36, $02, $1F, $0C, $12, $C1, $02, $05, $0C, $02, $00, $12, $81, $03, $81, $01, $26, $05, $01, $1A, $0E, $02, $1B, $0C, $12, $41
DB $02, $05, $0C, $01, $1A, $10, $12, $01, $03, $41, $01, $1A, $05, $01, $0E, $3A, $02, $27, $0C, $02, $00, $12, $C1, $02, $05, $0C, $01, $1A, $48, $12, $81, $03
DB $A1, $01, $26, $05, $01, $0E, $3E, $02, $1B, $0C, $12, $41, $03, $41, $02, $05, $00, $03, $07
SECTION "MkillerP37", ROMX
PATTERN_killer37:
DB $0A
DB $02, $01, $1B, $10, $12, $81, $03, $A1, $11, $28, $01, $01, $1B, $05, $01, $0F, $0E, $02, $17, $0C, $12, $41, $02, $05, $0C, $02, $00, $12, $01, $01, $27, $05
DB $01, $1B, $0E, $02, $1B, $0C, $12, $C1, $02, $05, $0C, $01, $27, $48, $12, $81, $03, $81, $01, $1B, $05, $01, $0F, $0E, $02, $27, $0C, $12, $41, $02, $05, $0C
DB $01, $1B, $10, $12, $81, $03, $A1, $01, $27, $05, $01, $0F, $2E, $02, $1B, $0C, $12, $41, $02, $05, $0C, $01, $3F, $44, $12, $01, $01, $1B, $05, $01, $1B, $0E
DB $02, $1F, $0C, $12, $C1, $02, $05, $0C, $02, $00, $12, $81, $03, $81, $01, $27, $05, $01, $1B, $3A, $02, $1B, $0C, $12, $41, $02, $05, $0C, $12, $01, $03, $41
DB $01, $1B, $05, $01, $0F, $2E, $02, $27, $0C, $12, $C1, $02, $05, $0C, $01, $27, $48, $12, $81, $03, $A1, $01, $27, $05, $01, $1B, $2E, $02, $23, $0C, $12, $41
DB $03, $41, $02, $05, $02, $1B, $0C, $01, $1B, $10, $12, $81, $03, $A1, $11, $27, $01, $01, $1B, $05, $01, $0F, $0E, $02, $23, $0C, $12, $41, $02, $05, $0C, $01
DB $1B, $10, $12, $01, $01, $27, $05, $01, $0F, $2E, $02, $1B, $0C, $12, $C1, $02, $05, $0C, $01, $1B, $48, $12, $81, $03, $81, $01, $1B, $05, $01, $1B, $0E, $02
DB $1B, $0C, $12, $41, $02, $05, $0C, $01, $1B, $10, $12, $81, $03, $A1, $01, $27, $05, $01, $0F, $32, $02, $27, $0C, $12, $41, $02, $05, $0C, $01, $3F, $44, $12
DB $01, $01, $1B, $05, $01, $0F, $36, $02, $1F, $0C, $12, $C1, $02, $05, $0C, $02, $00, $12, $81, $03, $81, $01, $27, $05, $01, $1B, $0E, $02, $1B, $0C, $12, $41
DB $02, $05, $0C, $01, $1B, $10, $12, $01, $03, $41, $01, $1B, $05, $01, $0F, $3A, $02, $27, $0C, $02, $00, $12, $C1, $02, $05, $0C, $01, $1B, $48, $12, $81, $03
DB $A1, $01, $27, $05, $01, $0F, $3E, $02, $1B, $0C, $12, $41, $03, $41, $02, $05, $00, $03, $07
SECTION "MkillerP38", ROMX
PATTERN_killer38:
DB $0A
DB $02, $01, $1B, $10, $12, $81, $03, $A1, $11, $28, $01, $01, $1B, $05, $01, $0F, $0E, $02, $17, $0C, $12, $41, $02, $05, $0C, $02, $00, $12, $01, $01, $27, $05
DB $01, $1B, $0E, $02, $1B, $0C, $12, $C1, $02, $05, $0C, $01, $27, $48, $12, $81, $03, $81, $01, $1B, $05, $01, $0F, $0E, $02, $27, $0C, $12, $41, $02, $05, $0C
DB $01, $1B, $10, $12, $81, $03, $A1, $01, $27, $05, $01, $0F, $2E, $02, $1B, $0C, $12, $41, $02, $05, $0C, $01, $3F, $44, $12, $01, $01, $1B, $05, $01, $1B, $0E
DB $02, $1F, $0C, $12, $C1, $02, $05, $0C, $02, $00, $12, $81, $03, $81, $01, $27, $05, $01, $1B, $3A, $02, $1B, $0C, $12, $41, $02, $05, $0C, $12, $01, $03, $41
DB $01, $1B, $05, $01, $0F, $2E, $02, $27, $0C, $12, $C1, $02, $05, $0C, $01, $27, $48, $12, $81, $03, $A1, $01, $27, $05, $01, $1B, $2E, $02, $23, $0C, $12, $41
DB $03, $41, $02, $05, $02, $1B, $0C, $01, $1B, $10, $12, $81, $03, $A1, $11, $37, $01, $01, $1B, $05, $01, $0F, $0E, $02, $1F, $0C, $12, $41, $02, $05, $0C, $02
DB $00, $12, $01, $01, $27, $05, $0C, $12, $C1, $02, $05, $0C, $12, $81, $03, $91, $01, $1B, $05, $0C, $12, $41, $02, $05, $02, $02, $0C, $12, $81, $03, $81, $01
DB $27, $05, $0C, $12, $41, $02, $05, $0C, $12, $01, $01, $1B, $05, $0C, $12, $C1, $02, $05, $0C, $12, $81, $03, $61, $01, $27, $05, $0C, $12, $41, $02, $05, $0C
DB $12, $01, $03, $41, $01, $1B, $05, $0C, $12, $C1, $02, $05, $0C, $12, $81, $03, $21, $01, $27, $05, $0C, $12, $41, $03, $11, $02, $05, $00, $03, $07
SECTION "MkillerP39", ROMX
PATTERN_killer39:
DB $0A
DB $02, $01, $1C, $10, $03, $C1, $12, $01, $01, $1C, $05, $01, $10, $0E, $02, $17, $0C, $12, $41, $01, $10, $05, $0C, $02, $00, $12, $81, $01, $1C, $05, $02, $02
DB $02, $03, $0C, $12, $C1, $01, $10, $05, $0C, $03, $A1, $12, $81, $01, $1C, $05, $0C, $12, $41, $01, $10, $05, $0C, $12, $01, $01, $1C, $05, $0C, $12, $41, $01
DB $10, $05, $0C, $12, $81, $01, $1C, $05, $0C, $12, $C1, $01, $10, $05, $0C, $12, $81, $01, $10, $05, $0C, $12, $41, $01, $1C, $05, $0C, $03, $81, $12, $01, $01
DB $10, $05, $0C, $12, $41, $01, $1C, $05, $0C, $12, $81, $01, $10, $05, $0C, $12, $C1, $01, $1C, $05, $0C, $12, $01, $01, $1C, $05, $0C, $12, $41, $01, $10, $05
DB $0C, $12, $81, $01, $1C, $05, $0C, $12, $C1, $01, $10, $05, $0C, $03, $41, $12, $81, $01, $1C, $05, $0C, $12, $41, $01, $10, $05, $0C, $12, $01, $01, $1C, $05
DB $0C, $12, $41, $01, $10, $05, $0C, $12, $81, $01, $1C, $05, $0C, $12, $C1, $01, $10, $05, $0C, $12, $81, $01, $10, $05, $0C, $12, $41, $01, $1C, $05, $0C, $03
DB $21, $12, $01, $01, $10, $05, $0C, $12, $41, $01, $1C, $05, $0C, $12, $81, $01, $10, $05, $0C, $03, $21, $12, $C1, $01, $1C, $05, $00, $03, $07
SECTION "MkillerP40", ROMX
PATTERN_killer40:
DB $0A
DB $02, $02, $00, $02, $01, $02, $02, $02, $03, $00, $7F, $07
SECTION "MkillerP_LAST", ROMX
PATTERN_killerLAST:
DB $08, $84, $FE, $07
; ************************ Order Table *********************
SECTION "MkillerOrderList", ROMX
Music_killer::
DW PATTERN_killer0, BANK(PATTERN_killer0)
DW PATTERN_killer0, BANK(PATTERN_killer0)
DW PATTERN_killer0, BANK(PATTERN_killer0)
DW PATTERN_killer4, BANK(PATTERN_killer4)
DW PATTERN_killer1, BANK(PATTERN_killer1)
DW PATTERN_killer1, BANK(PATTERN_killer1)
DW PATTERN_killer1, BANK(PATTERN_killer1)
DW PATTERN_killer1, BANK(PATTERN_killer1)
DW PATTERN_killer2, BANK(PATTERN_killer2)
DW PATTERN_killer2, BANK(PATTERN_killer2)
DW PATTERN_killer3, BANK(PATTERN_killer3)
DW PATTERN_killer5, BANK(PATTERN_killer5)
DW PATTERN_killer2, BANK(PATTERN_killer2)
DW PATTERN_killer2, BANK(PATTERN_killer2)
DW PATTERN_killer3, BANK(PATTERN_killer3)
DW PATTERN_killer5, BANK(PATTERN_killer5)
DW PATTERN_killer6, BANK(PATTERN_killer6)
DW PATTERN_killer7, BANK(PATTERN_killer7)
DW PATTERN_killer8, BANK(PATTERN_killer8)
DW PATTERN_killer9, BANK(PATTERN_killer9)
DW PATTERN_killer6, BANK(PATTERN_killer6)
DW PATTERN_killer7, BANK(PATTERN_killer7)
DW PATTERN_killer8, BANK(PATTERN_killer8)
DW PATTERN_killer10, BANK(PATTERN_killer10)
DW PATTERN_killer11, BANK(PATTERN_killer11)
DW PATTERN_killer11, BANK(PATTERN_killer11)
DW PATTERN_killer12, BANK(PATTERN_killer12)
DW PATTERN_killer13, BANK(PATTERN_killer13)
DW PATTERN_killer11, BANK(PATTERN_killer11)
DW PATTERN_killer11, BANK(PATTERN_killer11)
DW PATTERN_killer12, BANK(PATTERN_killer12)
DW PATTERN_killer13, BANK(PATTERN_killer13)
DW PATTERN_killer6, BANK(PATTERN_killer6)
DW PATTERN_killer7, BANK(PATTERN_killer7)
DW PATTERN_killer8, BANK(PATTERN_killer8)
DW PATTERN_killer9, BANK(PATTERN_killer9)
DW PATTERN_killer6, BANK(PATTERN_killer6)
DW PATTERN_killer7, BANK(PATTERN_killer7)
DW PATTERN_killer8, BANK(PATTERN_killer8)
DW PATTERN_killer10, BANK(PATTERN_killer10)
DW PATTERN_killer14, BANK(PATTERN_killer14)
DW PATTERN_killer14, BANK(PATTERN_killer14)
DW PATTERN_killer14, BANK(PATTERN_killer14)
DW PATTERN_killer14, BANK(PATTERN_killer14)
DW PATTERN_killer15, BANK(PATTERN_killer15)
DW PATTERN_killer15, BANK(PATTERN_killer15)
DW PATTERN_killer15, BANK(PATTERN_killer15)
DW PATTERN_killer15, BANK(PATTERN_killer15)
DW PATTERN_killer16, BANK(PATTERN_killer16)
DW PATTERN_killer16, BANK(PATTERN_killer16)
DW PATTERN_killer17, BANK(PATTERN_killer17)
DW PATTERN_killer17, BANK(PATTERN_killer17)
DW PATTERN_killer17, BANK(PATTERN_killer17)
DW PATTERN_killer18, BANK(PATTERN_killer18)
DW PATTERN_killer19, BANK(PATTERN_killer19)
DW PATTERN_killer20, BANK(PATTERN_killer20)
DW PATTERN_killer21, BANK(PATTERN_killer21)
DW PATTERN_killer25, BANK(PATTERN_killer25)
DW PATTERN_killer22, BANK(PATTERN_killer22)
DW PATTERN_killer23, BANK(PATTERN_killer23)
DW PATTERN_killer24, BANK(PATTERN_killer24)
DW PATTERN_killer25, BANK(PATTERN_killer25)
DW PATTERN_killer26, BANK(PATTERN_killer26)
DW PATTERN_killer26, BANK(PATTERN_killer26)
DW PATTERN_killer26, BANK(PATTERN_killer26)
DW PATTERN_killer27, BANK(PATTERN_killer27)
DW PATTERN_killer27, BANK(PATTERN_killer27)
DW PATTERN_killer27, BANK(PATTERN_killer27)
DW PATTERN_killer28, BANK(PATTERN_killer28)
DW PATTERN_killer30, BANK(PATTERN_killer30)
DW PATTERN_killer29, BANK(PATTERN_killer29)
DW PATTERN_killer31, BANK(PATTERN_killer31)
DW PATTERN_killer32, BANK(PATTERN_killer32)
DW PATTERN_killer30, BANK(PATTERN_killer30)
DW PATTERN_killer29, BANK(PATTERN_killer29)
DW PATTERN_killer31, BANK(PATTERN_killer31)
DW PATTERN_killer32, BANK(PATTERN_killer32)
DW PATTERN_killer33, BANK(PATTERN_killer33)
DW PATTERN_killer34, BANK(PATTERN_killer34)
DW PATTERN_killer35, BANK(PATTERN_killer35)
DW PATTERN_killer36, BANK(PATTERN_killer36)
DW PATTERN_killer37, BANK(PATTERN_killer37)
DW PATTERN_killer34, BANK(PATTERN_killer34)
DW PATTERN_killer35, BANK(PATTERN_killer35)
DW PATTERN_killer36, BANK(PATTERN_killer36)
DW PATTERN_killer38, BANK(PATTERN_killer38)
DW PATTERN_killer19, BANK(PATTERN_killer19)
DW PATTERN_killer20, BANK(PATTERN_killer20)
DW PATTERN_killer21, BANK(PATTERN_killer21)
DW PATTERN_killer25, BANK(PATTERN_killer25)
DW PATTERN_killer22, BANK(PATTERN_killer22)
DW PATTERN_killer23, BANK(PATTERN_killer23)
DW PATTERN_killer24, BANK(PATTERN_killer24)
DW PATTERN_killer39, BANK(PATTERN_killer39)
DW PATTERN_killerLAST, BANK(PATTERN_killerLAST)
; ********************************************************
; SoundFX Bank
;
; created with Beyond Gameboy Tracker
; ********************************************************
; ************************ SFX Streams *******************
INSTkiller_CHNLOFF: DB $05, $00, $01, $80, $02
INSTkiller1_CHNL1:
DB $03, $00, $01
DB $80, $02
INSTkiller2_CHNL0:
DB $0B, $08, $03
DB $00, $01, $80, $02
INSTkiller3_CHNL2:
DB $05, $20, $0A
DB $FF, $00, $00, $00
DB $00, $00, $00, $00
DB $00, $0F, $FF, $FF
DB $FF, $FF, $FF, $FF
DB $FF, $01, $80, $00
DB $03, $0A, $FF, $FF
DB $FF, $FF, $FF, $FF
DB $FF, $00, $00, $00
DB $00, $00, $00, $00
DB $00, $00, $00, $01
DB $80, $00, $03, $0A
DB $FF, $00, $00, $00
DB $00, $00, $00, $0F
DB $FF, $FF, $FF, $FF
DB $FF, $FF, $FF, $FF
DB $FF, $01, $80, $00
DB $03, $0A, $FF, $FF
DB $FF, $FF, $FF, $FF
DB $FF, $FE, $EE, $EE
DB $E1, $11, $11, $11
DB $11, $11, $11, $01
DB $80, $00, $03, $0A
DB $FF, $11, $11, $11
DB $11, $11, $11, $11
DB $11, $11, $11, $11
DB $11, $11, $11, $11
DB $11, $01, $80, $00
DB $03, $0A, $FF, $EE
DB $EE, $EE, $EE, $EE
DB $EE, $EE, $EE, $EE
DB $EE, $EE, $EE, $EE
DB $EE, $EE, $EE, $01
DB $80, $00, $03, $0A
DB $FF, $EE, $EE, $EE
DB $EE, $EE, $EE, $EE
DB $EE, $EE, $EE, $11
DB $11, $11, $11, $11
DB $11, $01, $80, $00
DB $03, $0A, $FF, $11
DB $11, $11, $11, $11
DB $11, $11, $11, $11
DB $11, $11, $11, $11
DB $11, $11, $11, $01
DB $80, $00, $03, $0A
DB $FF, $11, $11, $11
DB $11, $11, $22, $22
DB $22, $DD, $DD, $DD
DB $DD, $DD, $DD, $DD
DB $DD, $01, $80, $00
DB $03, $0A, $FF, $DD
DB $DD, $DD, $DD, $DD
DB $DD, $DD, $DD, $DD
DB $DD, $DD, $DD, $DD
DB $DD, $DD, $DD, $01
DB $80, $00, $03, $0A
DB $FF, $DD, $DD, $DD
DB $DD, $DD, $DD, $DD
DB $DD, $DD, $DD, $DD
DB $DD, $22, $22, $22
DB $22, $01, $80, $00
DB $03, $0A, $FF, $22
DB $22, $22, $22, $22
DB $22, $22, $22, $22
DB $22, $22, $22, $22
DB $22, $22, $22, $01
DB $80, $00, $03, $0A
DB $FF, $22, $22, $22
DB $22, $22, $22, $22
DB $22, $22, $22, $22
DB $22, $22, $22, $22
DB $23, $01, $80, $00
DB $03, $0A, $FF, $33
DB $33, $33, $33, $33
DB $33, $33, $CC, $CC
DB $CC, $CC, $CC, $CC
DB $CC, $CC, $CC, $01
DB $80, $00, $03, $0A
DB $FF, $CC, $CC, $CC
DB $CC, $CC, $CC, $CC
DB $CC, $CC, $CC, $CC
DB $CC, $CC, $CC, $CC
DB $CC, $01, $80, $00
DB $03, $0A, $FF, $CC
DB $CC, $CC, $CC, $CC
DB $CC, $CC, $CC, $CC
DB $CC, $CC, $CC, $CC
DB $CC, $CC, $CC, $01
DB $80, $00, $03, $01
DB $80, $02
INSTkiller4_CHNL0:
DB $0A, $80, $0B
DB $2A, $05, $D0, $01
DB $80, $02
INSTkiller5_CHNL3:
DB $0A, $56, $05
DB $A0, $01, $80, $00
DB $02, $0A, $41, $05
DB $A0, $01, $80, $00
DB $02, $05, $00, $01
DB $80, $00, $01, $0A
DB $51, $05, $D0, $01
DB $80, $00, $02, $05
DB $00, $01, $80, $00
DB $02, $02
INSTkiller6_CHNL3:
DB $0A, $41, $05
DB $A0, $01, $80, $00
DB $02, $05, $00, $01
DB $80, $02
INSTkiller7_CHNL3:
DB $0A, $52, $05
DB $D0, $01, $80, $00
DB $08, $05, $00, $01
DB $80, $02
INSTkiller8_CHNL3:
DB $0A, $49, $05
DB $D0, $01, $80, $00
DB $01, $05, $00, $01
DB $80, $02
INSTkiller9_CHNL3:
DB $0A, $19, $05
DB $D0, $01, $80, $00
DB $02, $0A, $11, $05
DB $51, $01, $80, $02
INSTkiller10_CHNL0:
DB $0A, $80, $0B
DB $08, $03, $00, $01
DB $80, $00, $01, $0A
DB $40, $00, $01, $02
INSTkiller11_CHNL2:
DB $05, $20, $0A
DB $01, $00, $00, $00
DB $00, $00, $00, $FF
DB $FF, $FF, $FF, $FF
DB $FF, $FF, $FF, $FF
DB $FF, $01, $80, $00
DB $08, $02
INSTkiller12_CHNL2:
DB $05, $20, $0A
DB $02, $00, $00, $00
DB $FF, $FF, $FF, $FF
DB $FF, $FF, $FF, $FF
DB $FF, $FF, $FF, $FF
DB $FF, $01, $80, $00
DB $08, $02
INSTkiller13_CHNL2:
DB $05, $40, $0A
DB $03, $00, $0F, $FF
DB $FF, $FF, $FF, $FF
DB $FF, $FF, $FF, $FF
DB $FF, $FF, $FF, $FF
DB $FF, $01, $80, $00
DB $08, $02
INSTkiller14_CHNL2:
DB $05, $40, $0A
DB $04, $00, $00, $00
DB $00, $00, $FF, $FF
DB $FF, $FF, $FF, $FF
DB $FF, $FF, $FF, $FF
DB $FF, $01, $80, $00
DB $08, $02
INSTkiller15_CHNL2:
DB $05, $60, $0A
DB $05, $00, $00, $00
DB $00, $00, $00, $00
DB $00, $00, $00, $FF
DB $FF, $FF, $FF, $FF
DB $FF, $01, $80, $00
DB $08, $02
INSTkiller16_CHNL2:
DB $05, $60, $0A
DB $06, $00, $00, $00
DB $00, $00, $00, $00
DB $00, $00, $00, $00
DB $00, $0F, $FF, $FF
DB $FF, $01, $80, $00
DB $08, $02
INSTkiller17_CHNL0:
DB $0B, $5C, $05
DB $D3, $01, $80, $02
INSTkiller18_CHNL0:
DB $0A, $80, $0B
DB $1F, $05, $D3, $01
DB $80, $02
INSTkiller19_CHNL0:
DB $0A, $00, $0B
DB $56, $05, $D0, $01
DB $80, $02
INSTkiller20_CHNL0:
DB $0A, $00, $0B
DB $3D, $05, $D0, $01
DB $80, $02
; ************************ SFX Table *********************
Inst_killer::
DW INSTkiller_CHNLOFF
DW INSTkiller1_CHNL1
DW INSTkiller2_CHNL0
DW INSTkiller3_CHNL2
DW INSTkiller4_CHNL0
DW INSTkiller5_CHNL3
DW INSTkiller6_CHNL3
DW INSTkiller7_CHNL3
DW INSTkiller8_CHNL3
DW INSTkiller9_CHNL3
DW INSTkiller10_CHNL0
DW INSTkiller11_CHNL2
DW INSTkiller12_CHNL2
DW INSTkiller13_CHNL2
DW INSTkiller14_CHNL2
DW INSTkiller15_CHNL2
DW INSTkiller16_CHNL2
DW INSTkiller17_CHNL0
DW INSTkiller18_CHNL0
DW INSTkiller19_CHNL0
DW INSTkiller20_CHNL0
|
/*
Title: Arrays
Description: This program demonstrates an array.
Author: William Kwabla.
Date:02/09/19
*/
#include <iostream>
using namespace std;
int main()
{
const int NUM_EMPLOYEES = 6;
int hours[NUM_EMPLOYEES];
int count;
cout << "Enter the hours worked by " << NUM_EMPLOYEES << " employees: ";
for (count = 0; count < NUM_EMPLOYEES; count++)
{
cin >> hours[count];
}
cout << "The hours you entered are: ";
for (count = 0; count < NUM_EMPLOYEES; count++)
{
cout << " " << hours[count];
}
cout << endl;
return 0;
} |
;--- MSX-UNAPI standalone RAM helper installer
; By Konamiman, 6-2019
;
; See USAGE_S for usage instructions.
;
; You can compile it with sjasm (https://github.com/Konamiman/Sjasm/releases):
; sjasm ramhelpr.asm ramhelpr.com (if INSTALLMSR = 0)
; sjasm ramhelpr.asm msr.com (if INSTALLMSR = 10)
; The resulting file is a MSX-DOS .COM program that installs the routines or the helper.
;
; Optional improvements (up to you):
;
; - Add code for uninstallation.
;
; * Version 1.1 copies the contents of the SHELL environment item
; to the PROGRAM environment item.
; This is needed because the SHELL item value becomes RAMHELPR.COM,
; and this leads to "Wrong version of COMMAND" errors.
;
; * Version 1.2:
; - Doesn't read from the mapped RAM ports anymore.
; - The routine to read a byte from a slot+segment doesn't corrupt BC, DE and HL,
; being then compliant with the UNAPI specification.
; - Installs also the DOS 2 mapper support routines if compiled with INSTALL_MSR=1
;
; NOTE: MSR = Standard mapper support routines,
; as defined in MSX-DOS 2 Program Interface Specification
;*******************
;*** CONSTANTS ***
;*******************
;--- Set to 1 to build an installer for the DOS 2 mapper support routines and the UNAPI RAM helper,
; In that case the installer will fail if these routines are already present.
;
; Set to 0 to build an installer for the UNAPI RAM helper only.
INSTALL_MSR: equ 1
;--- System variables and routines
_TERM0: equ 00h
_STROUT: equ 09h
_GENV: equ 6Bh
_SENV: equ 6Ch
ENDTPA: equ 0006h
RDSLT: equ 000Ch
CALSLT: equ 001Ch
ENASLT: equ 0024h
RAMSLOT0: equ 0F341h
RAMSLOT1: equ 0F342h
RAMSLOT3: equ 0F344h
HIMSAV: equ 0F349h
EXPTBL: equ 0FCC1h
EXTBIO: equ 0FFCAh
;*****************************
;*** INITIALIZATION CODE ***
;*****************************
org 100h
;--- Show welcome message
ld de,WELCOME_S
ld c,_STROUT
call 5
;--- Copy SHELL environment item to PROGRAM
; (in DOS 2 only, nothing happens in DOS 1)
ld hl,SHELL_S
ld de,8000h
ld b,255
ld c,_GENV
call 5
ld hl,PROGRAM_S
ld de,8000h
ld c,_SENV
call 5
;--- Put a 0 at the end of the command line
; (needed when running DOS 1)
ld hl,(0080h)
ld h,0
ld bc,0081h
add hl,bc
ld (hl),0
;--- Search the parameter
ld hl,80h
SRCHPAR:
inc hl
ld a,(hl)
cp " "
jr z,SRCHPAR
or a
jr z,SHOWINFO
or 32
if INSTALL_MSR = 1
cp "c"
jp z,DO_CLEANUP
endif
cp "f"
jr z,PARAM_OK
cp "i"
jr nz,SHOWINFO
;Parameter is "i": check if already installed
push hl
ld a,0FFh
ld de,2222h
ld hl,0
call EXTBIO
ld a,h
or l
pop hl
jr z,PARAM_OK
ld de,RH_ALINST_S
ld c,_STROUT
call 5
ld c,_TERM0
jp 5
;--- No parameters or invalid parameter:
; show usage information and terminate
SHOWINFO:
ld de,USAGE_S
ld c,_STROUT
call 5
ld c,_TERM0
jp 5
;--- Parameters OK: Do install
PARAM_OK:
inc hl
NEXT_PARAM:
ld a,(hl)
or a
jr z,DO_INSTALL
cp " "
jr nz,DO_INSTALL
inc hl
jr NEXT_PARAM
DO_INSTALL:
ld (CMDLINE_PNT),hl
if INSTALL_MSR = 1
xor a ;Get mapper support routines
ld de,0402h
call EXTBIO
or a
jp z,INST_HELPER
ld de,MSR_ALINST_S
ld c,_STROUT
call 5
ld c,_TERM0
jp 5
;************************************
;*** CLEANUP USER MODE SEGMENTS ***
;************************************
DO_CLEANUP:
xor a
ld de,0402h
call EXTBIO
or a
ld de,NOMSR_S
jp z,PRINT_END
inc hl
inc hl
inc hl ;Point HL to FREE_SEG
ld a,0FFh
ld b,00Fh
ld de,DO_CLEANUP_NEXT
push de
jp (hl)
DO_CLEANUP_NEXT:
ld de,NOMYMSR_S
jp c,PRINT_END
ld a,b
or c
ld de,IHAVENTFREED_S
jp z,PRINT_END
push bc
ld de,IHAVEFREED_S
ld c,_STROUT
call 5
pop hl
ld de,FREEDSEGCOUNT_S
push de
call NUMTOASC
pop de
ld c,_STROUT
call 5
ld de,USERSEGMENTS_S
PRINT_END:
ld c,_STROUT
call 5
ld c,_TERM0
jp 5
NOMSR_S:
db "*** No mapper support routines are installed.",13,10,"$"
NOMYMSR_S:
db "*** I haven't installed the mapper support routines myself,",13,10
db " therefore I can't free user segments.",13,10,"$"
IHAVENTFREED_S:
db "I haven't found any segment allocated in user mode.",13,10,"$"
IHAVEFREED_S:
db "I have freed $"
USERSEGMENTS_S:
db " segments allocated in user mode.",13,10,"$"
FREEDSEGCOUNT_S:
ds 6
endif
;******************************************
;*** MSR+RAM HELPER INSTALLATION CODE ***
;******************************************
INST_HELPER:
;--- Check that TPA end address is at least 0C2000h
ld a,(ENDTPA+1)
cp 0C2h
jr nc,OK_TPA
ld de,NOTPA_S
ld c,_STROUT
call 5
ld c,_TERM0
jp 5
OK_TPA:
if INSTALL_MSR = 1
;--- If TPA is spread across multiple slots, unify them
ld a,(RAMSLOT0)
ld hl,RAMSLOT3
cp (hl)
jr z,OKTPASLOTS
di
ld a,(RAMSLOT3)
ld h,40h
call ENASLT
ld a,3
out (0FDh),a
ld hl,0
ld de,4000h
ld bc,4000h
ldir
ld a,2
out (0FDh),a
ld h,0
ld a,(RAMSLOT3)
call ENASLT
ld a,(RAMSLOT3)
ld (RAMSLOT0),a
ld (RAMSLOT1),a
ei
ld de,IHAVESETSLOTS_S
ld c,_STROUT
call 5
OKTPASLOTS:
endif
;--- Prepare the two copies of the page 3 code
;>>> Get a copy of old EXTBIO hook
ld hl,EXTBIO
ld de,HOLDEXT__1
ld bc,5
ldir
ld hl,EXTBIO
ld de,HOLDEXT__2
ld bc,5
ldir
;>>> Build the mappers table
if INSTALL_MSR = 0
xor a ;Get mappers table
ld de,0401h
call EXTBIO
or a
jp nz,BUILDP3_DOS2
endif
;>>> Build the mappers table when no MSR are present:
; - If we are going to install MSR, build a MSR compatible
; table where each entry is 8 bytes long.
; - If not, build a reduced table where each entry is 2 bytes long.
BUILDP3_DOS1:
ld ix,MAPTAB__1
ld iy,MAPTAB__2
;Setup mappers entry for the primary mapper
if INSTALL_MSR = 1
ld a,8
else
ld a,2
endif
ld (MAPTAB_SIZE),a
ld a,(RAMSLOT3)
ld h,40h
call ENASLT
ld de,3000h
call MEMTEST1
cp 5
jr nc,OK_PRIMAP
ld a,(RAMSLOT1)
ld h,40h
call ENASLT
ld de,NOMAPPER_S
ld c,_STROUT
call 5
ld c,_TERM0
jp 5
OK_PRIMAP:
if INSTALL_MSR = 1
ld ix,MAPTAB__1+8
ld iy,MAPTAB__2+8
ld (ix-7),a ;Total segments
ld (iy-7),a
sub 5
ld (ix-6),a ;Free segments
ld (iy-6),a
ld a,5
ld (ix-5),a ;Segments allocated for system: our own code + TPA
ld (iy-5),a
xor a
ld (ix-4),a ;Segments allocated for user
ld (iy-4),a
ld (ix-3),a ;Unused
ld (iy-3),a
ld (ix-2),a ;Unused
ld (iy-2),a
ld (ix-1),a ;Unused
ld (iy-1),a
ld a,(RAMSLOT3)
ld (ix-8),a
ld (iy-8),a
else
ld ix,MAPTAB__1+2
ld iy,MAPTAB__2+2
dec a
ld (ix-1),a
ld (iy-1),a
ld a,(RAMSLOT3)
ld (ix-2),a
ld (iy-2),a
endif
;Setup mappers entry for other mappers, if any
ld b,3
BUILDP3_DOS1_L:
push bc
call NEXTSLOT
pop bc
cp 0FFh
jp z,END_BUILD_MAPTAB ;No more mappers
push ix
push iy
ld hl,RAMSLOT3
cp (hl)
jr z,BUILDP3_DOS1_N
ld c,a
push bc
ld h,40h
call ENASLT
ld de,3000h
call MEMTEST1
pop bc
cp 2
jr c,BUILDP3_DOS1_N
if INSTALL_MSR=0 ;For MSR it's "segments count", for RH it's "number of last segment"
dec a
endif
pop iy
pop ix
ld (ix),c
ld (iy),c
ld (ix+1),a
ld (iy+1),a
if INSTALL_MSR = 1
ld (ix+2),a ;Free segments
ld (iy+2),a
xor a
ld (ix+3),a ;Segments allocated to system
ld (iy+3),a
ld (ix+4),a ;Segments allocated to system
ld (iy+4),a
ld (ix+5),a ;Unused
ld (iy+5),a
ld (ix+6),a
ld (iy+6),a
ld (ix+7),a
ld (iy+7),a
push bc
ld bc,8
add ix,bc
add iy,bc
ld a,(MAPTAB_SIZE)
ld b,8
add a,b
ld (MAPTAB_SIZE),a
pop bc
else
inc ix
inc ix
inc iy
inc iy
ld hl,MAPTAB_SIZE
inc (hl)
inc (hl)
endif
djnz BUILDP3_DOS1_L
END_BUILD_MAPTAB:
ld (ix),0 ;End of the table
ld (iy),0
ld hl,MAPTAB_SIZE
inc (hl)
jr END_BUILDP3
BUILDP3_DOS1_N:
pop iy
pop ix
jp BUILDP3_DOS1_L
if INSTALL_MSR=0
;>>> Build the mappers table when MSR are already present
BUILDP3_DOS2:
ld (_CALLRAM_MAPTAB__1+1),hl
ld (_CALLRAM_MAPTAB__2+1),hl
ld a,7 ;Opcode for RLCA
ld (_CALLRAM_RLCAS__1),a
ld (_CALLRAM_RLCAS__1+1),a
ld (_CALLRAM_RLCAS__2),a
ld (_CALLRAM_RLCAS__2+1),a
xor a ;Get mapper support routines
ld de,0402h
call EXTBIO
ld bc,1Eh
add hl,bc
push hl
ld de,PUT_P1__1
ld bc,6
ldir
pop hl
ld de,PUT_P1__2
ld bc,6
ldir
ld hl,0
ld (LDBC__1+1),hl
ld (LDBC__2+1),hl
endif
END_BUILDP3:
if INSTALL_MSR = 1
ld hl,0 ;We don't provide reduced mappers table,
ld (LDBC__1+1),hl ;we've generated a standard table
ld (LDBC__2+1),hl
endif
;--- Calculate final size of page 3 area
ld bc,(MAPTAB_SIZE)
ld b,0
ld hl,P3_CODE_END__1-P3_CODE__1
add hl,bc
ld (0B002h),hl
;--- Allocate space on system work area on page 3
ld hl,(HIMSAV)
ld bc,(0B002h)
or a
sbc hl,bc
ld (HIMSAV),hl
ld a,(RAMSLOT1)
ld h,40h
call ENASLT
;--- Generate the page 3 code for the appropriate address,
; but generate it at 0B004h temporarily
; (we cannot use the allocated page 3 space yet)
ld hl,P3_CODE__1
ld de,P3_CODE__2
ld ix,(HIMSAV)
ld iy,0B004h
ld bc,(0B002h)
call REALLOC
ld hl,(HIMSAV)
ld (0B000h),hl
;--- Install code in segment
if INSTALL_MSR = 1
ld a,(MAPTAB__1)
ld h,40h
call ENASLT
ld a,(MAPTAB__1+1)
dec a
out (0FDh),a
ld hl,SEGMENT_CODE
ld de,4000h
ld bc,SEGMENT_CODE_END-SEGMENT_CODE_START
ldir
;>>> Initialize the segments usage table, marking non-existing segments
ld hl,SEG_USE_TABLE
ld de,SEG_USE_TABLE+1
ld bc,256*4-1
ld (hl),0
ldir
ld ix,MAPTAB__1
ld hl,SEG_USE_TABLE+255
INI_SEG_TABLE_LOOP:
ld a,(ix)
or a
jr z,INI_SEG_TABLE_END
push ix
push hl
ld c,(ix+1) ;Segments count
ld b,0
ld hl,256
or a
sbc hl,bc
ld b,l ;Number of non-existing segments
ld a,0FFh
pop hl
push hl
MARK_NON_EX_LOOP:
ld (hl),a
dec hl
djnz MARK_NON_EX_LOOP
pop hl
pop ix
inc h ;Next entry in SEG_USE_TABLE
ld bc,8
add ix,bc
jr INI_SEG_TABLE_LOOP
;>>> Also mark TPA segments and our own segment as system
INI_SEG_TABLE_END:
ld ix,SEG_USE_TABLE
ld a,2
ld (ix),a
ld (ix+1),a
ld (ix+2),a
ld (ix+3),a
ld bc,(MAPTAB__1+1)
dec c
ld b,0
add ix,bc
ld (ix),a
ld a,2
out (0FDh),a
ld a,(0F342h)
ld h,40h
call ENASLT
endif
;--- All done, now we need to jump to BASIC and do _SYSTEM
ld de,OK_S
ld c,_STROUT
call 5
ld ix,ComLine+2
ld hl,(CMDLINE_PNT) ;No commands to copy?
ld a,(hl)
or a
jr z,OKBSC
ld a,(0F313h) ;DOS 1 and there are commands to copy:
or a ;print warning and ignore them
jr nz,DO_GET_CMD
ld de,CMDWARNING_S
ld c,_STROUT
call 5
jr OKBSC
DO_GET_CMD:
ld (ix-2),"("
ld (ix-1),34
ld a,(hl)
BUCSYS2:
ld (ix),a ;Copy characters until finding 0
inc ix
inc hl
ld a,(hl)
cp "&"
jr nz,NOAMP
ld a,"^"
NOAMP: or a
jr nz,BUCSYS2
ld (ix),34
ld (ix+1),")"
ld (ix+2),0
OKBSC:
ld hl,SystemProg
ld de,08000h
ld bc,0400h
ldir
jp 08000h
SystemProg:
ld a,(0FCC1h)
push af
ld h,0
call 024h
pop af
ld h,040h
call 024h
xor a
ld hl,0F41Fh
ld (0F860h),hl
ld hl,0F423h
ld (0F41Fh),hl
ld (hl),a
ld hl,0F52Ch
ld (0F421h),hl
ld (hl),a
ld hl,0F42Ch
ld (0F862h),hl
ld hl,8030h
jp 04601h
;The following is copied to address 8030h
SysTxT2:
db 3Ah ;:
db 97h,0DDh,0EFh ;DEF USR =
db 0Ch
SigueDir:
dw UsrCode-SystemProg+8000h ;Address of "UsrCode"
db 3Ah,91h,0DDh,"(",34,34,")" ;:? USR("")
db 03Ah,0CAh ;:CALL
db "SYSTEM"
ComLine:
db 0
ds 128 ;Space for extra commands
;>>> This is the code that will be executed by the USR instruction
UsrCode:
;--- Copy page 3 code to its definitive address
ld hl,0B004h
ld de,(0B000h)
ld bc,(0B002h)
ldir
;--- Setup new EXTBIO hook
di
ld a,0C3h
ld (EXTBIO),a
ld hl,(0B000h)
ld bc,NEWEXT__1-P3_CODE__1
add hl,bc
ld (EXTBIO+1),hl
ei
ret
;--- This routine reallocates a piece of code
; based on two different copies assembled in different locations.
; Input: HL = Address of first copy
; DE = Address of second copy
; IX = Target reallocation address
; IY = Address where the patched code will be placed
; BC = Length of code
REALLOC:
push iy
push bc
push de
push hl ;First copy code "as is"
push iy ;(HL to IY, length BC)
pop de
ldir
pop hl
pop de
push de
pop iy ;IY = Second copy
ld b,h
ld c,l
push ix
pop hl
or a
sbc hl,bc
ld b,h
ld c,l ;BC = Distance to sum (IX - HL)
exx
pop bc
exx
pop ix ;Originally IY
;At this point: IX = Destination
; IY = Second copy
; BC = Distance to sum (new dir - 1st copy)
; BC'= Length
REALOOP:
ld a,(ix)
cp (iy)
jr z,NEXT ;If no differences, go to next byte
ld l,a
ld h,(ix+1) ;HL = Data to be changed
add hl,bc ;HL = Data changed
ld (ix),l ;IX = Address of the data to be changed
ld (ix+1),h
call CHKCOMP
jr z,ENDREALL
inc ix
inc iy
NEXT: inc ix ;Next byte to compare
inc iy ;(if we have done substitution, we need to increase twice)
call CHKCOMP
jr nz,REALOOP
ENDREALL:
ret
CHKCOMP:
exx
dec bc ;Decrease counter, if it reaches 0,
ld a,b ;return with Z=1
or c
exx
ret
;--- NEXTSLOT:
; Returns in A the next slot available on the system every time it is called.
; When no more slots are available it returns 0FFh.
; To initialize it, 0FFh must be written in NEXTSL.
; Modifies: AF, BC, HL
NEXTSLOT:
ld a,(NEXTSL)
cp 0FFh
jr nz,NXTSL1
ld a,(EXPTBL) ;First slot
and 10000000b
ld (NEXTSL),a
ret
NXTSL1:
ld a,(NEXTSL)
cp 10001111b
jr z,NOMORESLT ;No more slots?
cp 00000011b
jr z,NOMORESLT
bit 7,a
jr nz,SLTEXP
SLTSIMP:
and 00000011b ;Simple slot
inc a
ld c,a
ld b,0
ld hl,EXPTBL
add hl,bc
ld a,(hl)
and 10000000b
or c
ld (NEXTSL),a
ret
SLTEXP:
ld c,a ;Expanded slot
and 00001100b
cp 00001100b
ld a,c
jr z,SLTSIMP
add 00000100b
ld (NEXTSL),a
ret
NOMORESLT:
ld a,0FFh
ret
NEXTSL:
db 0FFh ;Last returned slot
;--- Direct memory test (for DOS 1)
; INPUT: DE = 256 byte buffer, it must NOT be in page 1
; The slot to be tested must be switched on page 1
; OUTPUT: A = Number of available segments, or:
; 0 -> Error: not a RAM slot
; 1 -> Error: not mapped RAM
; MODIFIES: F, HL, BC, DE
MEMTEST1:
ld a,(5001h) ;Check if it is actually RAM
ld h,a
cpl
ld (5001h),a
ld a,(5001h)
cpl
ld (5001h),a
cpl
cp h
ld a,0
ret z
ld hl,4001h ;Test address
in a,(0FDh)
push af ;A = Current page 2 segment
push de ;DE = Buffer
ld b,0
;* Loop for all segment numbers from 0 to 255
MT1BUC1:
ld a,b ;Switch segment on page 1
out (0FDh),a
ld a,(hl)
ld (de),a ;Save data on the test address...
ld a,b
ld (hl),a ;...then write the supposed segment number on test address
inc de
inc b
ld a,b
cp 0
jr nz,MT1BUC1
;* Negate the value of test address for segment 0:
; this is the number of segments found (0 for 256)
out (0FDh),a
ld a,(hl)
neg
ld (NUMSGS),a
ld b,0
ld c,a
pop de
;* Restore original value of test address for all segments
MT1BUC2:
ld a,b
out (0FDh),a
ld a,(de)
ld (hl),a
inc de
inc b
ld a,b
cp c
jr nz,MT1BUC2
;* Restore original segment on page 1 and return number of segments
pop af
out (0FDh),a
ld a,(NUMSGS)
cp 1 ;No mapped RAM?
jr z,NOMAP1
or a
ret nz
ld a,0FFh ;If 256 segments, return 255
ret
NOMAP1: xor a
ret
NUMSGS: db 0
;--- NUMTOASC: Converts a 16 bit unsigned value to an ASCII string,
; terminating it with a "$" character
; Input: HL = Number to convert
; DE = Destination address for the string
;
; This routine is a modification of one borrowed from:
; http://map.tni.nl/sources/external/z80bits.html
; (this one skips dummy zeros and adds "$" at the end)
NUMTOASC:
;* HL=0 is a special case
ld a,h
or l
jr nz,n2anozero
ex de,hl
ld (hl),"0"
inc hl
ld (hl),"$"
ret
n2anozero:
;* Generate string
push de
ld de,n2abuf
ld bc,-10000
call Num1
ld bc,-1000
call Num1
ld bc,-100
call Num1
ld c,-10
call Num1
ld c,-1
call Num1
;* Copy string to destination, skipping initial zeros
pop de
ld hl,n2abuf-1
n2acopy1:
inc hl
ld a,(hl)
cp "0"
jr z,n2acopy1
n2acopy2:
ld (de),a
cp "$"
ret z
inc de
inc hl
ld a,(hl)
jr n2acopy2
;* Generate a single digit
Num1: ld a,'0'-1
Num2: inc a
add hl,bc
jr c,Num2
sbc hl,bc
ld (de),a
inc de
ret
n2abuf: db "00000$"
;*********************
;*** PAGE 3 CODE ***
;*********************
;It needs to be duplicated so that it can be reallocated. Sorry.
;***>>> First copy <<<***
P3_CODE__1:
;--- Hook and jump table area
HOLDEXT__1: ds 5 ;Old EXTBIO hook
if INSTALL_MSR = 0
PUT_P1__1:
jp _PUTP1__1 ;To be filled with routine PUT_P1 in DOS 2
GET_P1__1:
ld a,2 ;To be filled with routine GET_P1 in DOS 2
ret
_PUTP1__1:
out (0FDh),a
ld (GET_P1__1+1),a
ret
endif
if INSTALL_MSR = 1
MSR_JUMP__1:
jp ALL_SEG__1
jp FRE_SEG__1
jp RD_SEG__1
jp WR_SEG__1
jp CAL_SEG__1
jp CALLS__1
jp PUT_PH__1
jp GET_PH__1
jp PUT_P0__1
jp GET_P0__1
jp PUT_P1__1
jp GET_P1__1
jp PUT_P2__1
jp GET_P2__1
jp PUT_P3__1
jp GET_P3__1
endif
RH_JUMP__1:
jp CALLRAM__1
jp READRAM__1
jp CALLRAM2__1
;--- New destination of the EXTBIO hook
NEWEXT__1:
push af
if INSTALL_MSR = 1
ld a,d
cp 4
jr nz,RHEXT__1
ld a,e
dec a
jr nz,NOMSRTAB__1
;Get mapper variable table
pop af
ld a,(MAPTAB__1)
ld hl,MAPTAB__1
ret
NOMSRTAB__1:
dec a
jr nz,IGNORE__1
;Get mapper support routine address
pop af
ld a,(MAPTAB__1)
ld b,a ;Slot number of primary mapper
ld a,(MAPTAB__1+2)
ld c,a ;Free segments in primary mapper
ld a,(MAPTAB__1+1) ;Total segments in primary mapper
ld hl,MSR_JUMP__1
ret
RHEXT__1:
pop af
push af
else
RHEXT__1:
endif
inc a
jr nz,IGNORE__1
ld a,d
cp 22h
jr nz,IGNORE__1
ld a,e
cp 22h
jr nz,IGNORE__1
ld hl,RH_JUMP__1 ;Address of the jump table
LDBC__1:
ld bc,MAPTAB__1 ;Address of mappers table
pop af
ld a,3 ;Num entries in jump table
ret
IGNORE__1:
pop af
jr HOLDEXT__1
;Note: all routines corrupt the alternate register set.
;--- Routine to call code in a RAM segment
; Input:
; IYh = Slot number
; IYl = Segment number
; IX = Target routine address (must be a page 1 address)
; AF, BC, DE, HL = Parameters for the target routine
;Output:
; AF, BC, DE, HL, IX, IY = Parameters returned from the target
; routine
CALLRAM__1:
ex af,af
call GET_P1__1
push af
ld a,iyl
call PUT_P1__1
ex af,af
call CALSLT
ex af,af
pop af
call PUT_P1__1
ex af,af
ret
;--- Routine to read a byte from a RAM segment
;Input:
; A = Slot number
; B = Segment number
; HL = Address to be read from
; (higher two bits will be ignored)
;Output:
; A = Data readed from the specified address
; BC, DE, HL preserved
READRAM__1:
push bc
push de
push hl
ex af,af
call GET_P1__1
push af
ld a,b
call PUT_P1__1
res 7,h
set 6,h
ex af,af
call RDSLT
ex af,af
pop af
call PUT_P1__1
ex af,af
pop hl
pop de
pop bc
ret
;--- Routine to call code in a RAM segment
; (code location specified in the stack)
;Input:
; AF, BC, DE, HL = Parameters for the target routine
;Output:
; AF, BC, DE, HL, IX, IY = Parameters returned from the target
; routine
;Call as:
; CALL CALLRAM2
;
;CALLRAM2:
; CALL <routine address>
; DB bMMAAAAAA
; DB <segment number>
;
; MM = Slot as the index of the entry in the mapper table.
; AAAAAA = Routine address index:
; 0=4000h, 1=4003h, ..., 63=40BDh
CALLRAM2__1:
exx
ex af,af'
pop ix
ld e,(ix+1) ;Segment number
ld d,(ix) ;Slot and entry point number
dec ix
dec ix
push ix
ld iyl,e
ld a,d
and 00111111b
ld b,a
add a,a
add b ;A = Address index * 3
ld l,a
ld h,40h
push hl
pop ix ;IX = Address to call
ld a,d
and 11000000b
rlca
rlca
rlca ;A = Mapper table index * 2
_CALLRAM_RLCAS__1:
nop ;Will be two more RLCAs (so *8) if MSR are present
nop
ld l,a
ld h,0
_CALLRAM_MAPTAB__1:
ld bc,MAPTAB__1 ;Will be the address of the MSR table if present
add hl,bc
ld a,(hl) ;A = Slot to call
ld iyh,a
ex af,af'
exx
inc sp
inc sp
jr CALLRAM__1
CALLIX__1: jp (ix)
if INSTALL_MSR = 1
;--- ALL_SEG and FRE_SEG
ALL_SEG__1:
push ix
ld ix,ALL_SEG__SEG
jr ALLFRE__1
FRE_SEG__1:
push ix
ld ix,FRE_SEG__SEG
ALLFRE__1:
push iy
push hl
push de
ex af,af'
exx
push af
push bc
push de
push hl
exx
ex af,af'
push af
ld a,(MAPTAB__1) ;Slot number of primary mapper
ld iyh,a
ld a,(MAPTAB__1+1) ;Last segment number (seg count - 1)
dec a
ld iyl,a
pop af
call CALLRAM__1
ex af,af'
exx
pop hl
pop de
pop bc
pop af
exx
ex af,af'
pop de
pop hl
pop iy
pop ix
di
ret
;--- RD_SEG
RD_SEG__1:
di
push hl
push bc
ld b,a
call GET_P2__1 ;Get current page-2 segment
ld c,a ; number and save it in C.
ld a,b
call PUT_P2__1 ;Put required segment into
res 6,h ; page-2 and force address
set 7,h ; to page-2.
ld b,(hl) ;Get the byte.
ld a,c
call PUT_P2__1 ;Restore original page-2
ld a,b ;A := byte value read
pop bc
pop hl
ret
;--- WR_SEG
WR_SEG__1:
di
push hl
push bc
ld b,a
call GET_P2__1 ;Get the current page-2
ld c,a ; segment & save it in C.
ld a,b
call PUT_P2__1 ;Put the required segment
res 6,h ; in page-2 and force the
set 7,h ; address into page-2.
ld (hl),e ;Store the byte.
ld a,c
call PUT_P2__1 ;Restore original segment
pop bc ; to page-2.
pop hl
ret
;--- CALLS and CALL_SEG
CALLS__1:
exx
ex (sp),hl
ld d,(hl)
inc hl ;Extract parameters from in-
push de ; line after the "CALL CALLS"
pop iy ; instruction, and adjust
ld e,(hl) ; the return address.
inc hl
ld d,(hl)
inc hl
push de
pop ix
ex (sp),hl
exx
CAL_SEG__1:
exx ;Preserve main register set.
ex af,af'
push ix
pop hl ;HL := address to call and get
call GET_PH__1 ; current segment for this page
push af ; and save it for return.
push hl
push iy
pop af ;Enable required segment for
call PUT_PH__1 ; this address.
ex af,af'
exx
call CALLIX__1 ;Call the routine via IX
exx
ex af,af'
pop hl ;Restore the original
pop af ; segment to the appropriate
call PUT_PH__1 ; page.
ex af,af'
exx
ret
;--- GET_Pn and PUT_Pn
PUT_PH__1:
bit 7,h ;Jump to appropriate "PUT_Pn"
jr nz,_put_p2_or_p3__1 ; routine, depending on the
bit 6,h ; top two bits of H.
jr z,PUT_P0__1
jr PUT_P1__1
_put_p2_or_p3__1:
bit 6,h
jr z,PUT_P2__1
ret ;jr _put_p3
GET_PH__1:
bit 7,h ;Jump to appropriate "GET_Pn"
jr nz,_get_p2_or_p3__1 ; routine, depending on the
bit 6,h ; top two bits of H.
jr z,GET_P0__1
jr GET_P1__1
_get_p2_or_p3__1:
bit 6,h
jr z,GET_P2__1
xor a ;jr _get_p3
ret
PUT_P0__1:
ld (CURSEGS__1),a
out (0FCh),a
ret
GET_P0__1:
ld a,(CURSEGS__1)
ret
PUT_P1__1:
ld (CURSEGS__1+1),a
out (0FDh),a
ret
GET_P1__1:
ld a,(CURSEGS__1+1)
ret
PUT_P2__1:
ld (CURSEGS__1+2),a
out (0FEh),a
ret
GET_P2__1:
ld a,(CURSEGS__1+2)
ret
GET_P3__1:
ld a,(CURSEGS__1+3)
PUT_P3__1:
ret
CURSEGS__1: db 3,2,1,0
endif
;Mappers table.
;
;If we install the MSR, we also generate a standard table where
;each entry is 8 bytes.
;
;If not, and if no MSR is already present, we generate
;a reduced table where each entry is just two bytes:
;slot + maximum segment number
;
;In both cases, first entry is for the primary mapper,
;and there's always a 0 after the last entry.
MAPTAB__1:
P3_CODE_END__1:
if INSTALL_MSR = 1
ds (8*2)+1
else
ds (4*2)+1 ;Space for building the table
endif
;***>>> Second copy <<<***
P3_CODE__2:
;--- Hook and jump table area
HOLDEXT__2: ds 5 ;Old EXTBIO hook
if INSTALL_MSR = 0
PUT_P1__2:
jp _PUTP1__2 ;To be filled with routine PUT_P1 in DOS 2
GET_P1__2:
ld a,2 ;To be filled with routine GET_P1 in DOS 2
ret
_PUTP1__2:
out (0FDh),a
ld (GET_P1__2+1),a
ret
endif
if INSTALL_MSR = 1
MSR_JUMP__2:
jp ALL_SEG__2
jp FRE_SEG__2
jp RD_SEG__2
jp WR_SEG__2
jp CAL_SEG__2
jp CALLS__2
jp PUT_PH__2
jp GET_PH__2
jp PUT_P0__2
jp GET_P0__2
jp PUT_P1__2
jp GET_P1__2
jp PUT_P2__2
jp GET_P2__2
jp PUT_P3__2
jp GET_P3__2
endif
RH_JUMP__2:
jp CALLRAM__2
jp READRAM__2
jp CALLRAM2__2
;--- New destination of the EXTBIO hook
NEWEXT__2:
push af
if INSTALL_MSR = 1
ld a,d
cp 4
jr nz,RHEXT__2
ld a,e
dec a
jr nz,NOMSRTAB__2
;Get mapper variable table
pop af
ld a,(MAPTAB__2)
ld hl,MAPTAB__2
ret
NOMSRTAB__2:
dec a
jr nz,IGNORE__2
;Get mapper support routine address
pop af
ld a,(MAPTAB__2)
ld b,a ;Slot number of primary mapper
ld a,(MAPTAB__2+2)
ld c,a ;Free segments in primary mapper
ld a,(MAPTAB__2+1) ;Total segments in primary mapper
ld hl,MSR_JUMP__2
ret
RHEXT__2:
pop af
push af
else
RHEXT__2:
endif
inc a
jr nz,IGNORE__2
ld a,d
cp 22h
jr nz,IGNORE__2
ld a,e
cp 22h
jr nz,IGNORE__2
ld hl,RH_JUMP__2 ;Address of the jump table
LDBC__2:
ld bc,MAPTAB__2 ;Address of mappers table
pop af
ld a,3 ;Num entries in jump table
ret
IGNORE__2:
pop af
jr HOLDEXT__2
;Note: all routines corrupt the alternate register set.
;--- Routine to call code in a RAM segment
; Input:
; IYh = Slot number
; IYl = Segment number
; IX = Target routine address (must be a page 1 address)
; AF, BC, DE, HL = Parameters for the target routine
;Output:
; AF, BC, DE, HL, IX, IY = Parameters returned from the target
; routine
CALLRAM__2:
ex af,af
call GET_P1__2
push af
ld a,iyl
call PUT_P1__2
ex af,af
call CALSLT
ex af,af
pop af
call PUT_P1__2
ex af,af
ret
;--- Routine to read a byte from a RAM segment
;Input:
; A = Slot number
; B = Segment number
; HL = Address to be read from
; (higher two bits will be ignored)
;Output:
; A = Data readed from the specified address
; BC, DE, HL preserved
READRAM__2:
push bc
push de
push hl
ex af,af
call GET_P1__2
push af
ld a,b
call PUT_P1__2
res 7,h
set 6,h
ex af,af
call RDSLT
ex af,af
pop af
call PUT_P1__2
ex af,af
pop hl
pop de
pop bc
ret
;--- Routine to call code in a RAM segment
; (code location specified in the stack)
;Input:
; AF, BC, DE, HL = Parameters for the target routine
;Output:
; AF, BC, DE, HL, IX, IY = Parameters returned from the target
; routine
;Call as:
; CALL CALLRAM2
;
;CALLRAM2:
; CALL <routine address>
; DB bMMAAAAAA
; DB <segment number>
;
; MM = Slot as the index of the entry in the mapper table.
; AAAAAA = Routine address index:
; 0=4000h, 1=4003h, ..., 63=40BDh
CALLRAM2__2:
exx
ex af,af'
pop ix
ld e,(ix+1) ;Segment number
ld d,(ix) ;Slot and entry point number
dec ix
dec ix
push ix
ld iyl,e
ld a,d
and 00111111b
ld b,a
add a,a
add b ;A = Address index * 3
ld l,a
ld h,40h
push hl
pop ix ;IX = Address to call
ld a,d
and 11000000b
rlca
rlca
rlca ;A = Mapper table index * 2
_CALLRAM_RLCAS__2:
nop ;Will be two more RLCAs (so *8) if MSR are present
nop
ld l,a
ld h,0
_CALLRAM_MAPTAB__2:
ld bc,MAPTAB__2 ;Will be the address of the MSR table if present
add hl,bc
ld a,(hl) ;A = Slot to call
ld iyh,a
ex af,af'
exx
inc sp
inc sp
jr CALLRAM__2
CALLIX__2: jp (ix)
if INSTALL_MSR = 1
;--- ALL_SEG and FRE_SEG
ALL_SEG__2:
push ix
ld ix,ALL_SEG__SEG
jr ALLFRE__2
FRE_SEG__2:
push ix
ld ix,FRE_SEG__SEG
ALLFRE__2:
push iy
push hl
push de
ex af,af'
exx
push af
push bc
push de
push hl
exx
ex af,af'
push af
ld a,(MAPTAB__2) ;Slot number of primary mapper
ld iyh,a
ld a,(MAPTAB__2+1) ;Last segment number (seg count - 1)
dec a
ld iyl,a
pop af
call CALLRAM__2
ex af,af'
exx
pop hl
pop de
pop bc
pop af
exx
ex af,af'
pop de
pop hl
pop iy
pop ix
di
ret
;--- RD_SEG
RD_SEG__2:
di
push hl
push bc
ld b,a
call GET_P2__2 ;Get current page-2 segment
ld c,a ; number and save it in C.
ld a,b
call PUT_P2__2 ;Put required segment into
res 6,h ; page-2 and force address
set 7,h ; to page-2.
ld b,(hl) ;Get the byte.
ld a,c
call PUT_P2__2 ;Restore original page-2
ld a,b ;A := byte value read
pop bc
pop hl
ret
;--- WR_SEG
WR_SEG__2:
di
push hl
push bc
ld b,a
call GET_P2__2 ;Get the current page-2
ld c,a ; segment & save it in C.
ld a,b
call PUT_P2__2 ;Put the required segment
res 6,h ; in page-2 and force the
set 7,h ; address into page-2.
ld (hl),e ;Store the byte.
ld a,c
call PUT_P2__2 ;Restore original segment
pop bc ; to page-2.
pop hl
ret
;--- CALLS and CALL_SEG
CALLS__2:
exx
ex (sp),hl
ld d,(hl)
inc hl ;Extract parameters from in-
push de ; line after the "CALL CALLS"
pop iy ; instruction, and adjust
ld e,(hl) ; the return address.
inc hl
ld d,(hl)
inc hl
push de
pop ix
ex (sp),hl
exx
CAL_SEG__2:
exx ;Preserve main register set.
ex af,af'
push ix
pop hl ;HL := address to call and get
call GET_PH__2 ; current segment for this page
push af ; and save it for return.
push hl
push iy
pop af ;Enable required segment for
call PUT_PH__2 ; this address.
ex af,af'
exx
call CALLIX__2 ;Call the routine via IX
exx
ex af,af'
pop hl ;Restore the original
pop af ; segment to the appropriate
call PUT_PH__2 ; page.
ex af,af'
exx
ret
;--- GET_Pn and PUT_Pn
PUT_PH__2:
bit 7,h ;Jump to appropriate "PUT_Pn"
jr nz,_put_p2_or_p3__2 ; routine, depending on the
bit 6,h ; top two bits of H.
jr z,PUT_P0__2
jr PUT_P1__2
_put_p2_or_p3__2:
bit 6,h
jr z,PUT_P2__2
ret ;jr _put_p3
GET_PH__2:
bit 7,h ;Jump to appropriate "GET_Pn"
jr nz,_get_p2_or_p3__2 ; routine, depending on the
bit 6,h ; top two bits of H.
jr z,GET_P0__2
jr GET_P1__2
_get_p2_or_p3__2:
bit 6,h
jr z,GET_P2__2
xor a ;jr _get_p3
ret
PUT_P0__2:
ld (CURSEGS__2),a
out (0FCh),a
ret
GET_P0__2:
ld a,(CURSEGS__2)
ret
PUT_P1__2:
ld (CURSEGS__2+1),a
out (0FDh),a
ret
GET_P1__2:
ld a,(CURSEGS__2+1)
ret
PUT_P2__2:
ld (CURSEGS__2+2),a
out (0FEh),a
ret
GET_P2__2:
ld a,(CURSEGS__2+2)
ret
GET_P3__2:
ld a,(CURSEGS__2+3)
PUT_P3__2:
ret
CURSEGS__2: db 3,2,1,0
endif
;Mappers table.
;
;If we install the MSR, we also generate a standard table where
;each entry is 8 bytes.
;
;If not, and if no MSR is already present, we generate
;a reduced table where each entry is just two bytes:
;slot + maximum segment number
;
;In both cases, first entry is for the primary mapper,
;and there's always a 0 after the last entry.
MAPTAB__2:
P3_CODE_END__2:
if INSTALL_MSR = 1
ds (8*2)+1
else
ds (4*2)+1 ;Space for building the table
endif
;*******************************
;*** VARIABLES AND STRINGS ***
;*******************************
CMDLINE_PNT: dw 0 ;Pointer to command line after the first parameter
MAPTAB_SIZE: db 0 ;Size of reduced mappers table (if we build it)
SHELL_S: db "SHELL",0
PROGRAM_S: db "PROGRAM",0
WELCOME_S:
if INSTALL_MSR = 1
db "Standalone mapper support routines + UNAPI RAM helper installer 1.2",13,10
else
db "Standalone UNAPI RAM helper installer 1.2",13,10
endif
db "(c) 2019 by Konamiman",13,10
db 13,10
db "$"
USAGE_S:
; --------------------------------------------------------------------------------
if INSTALL_MSR = 1
db "Usage: msr [i|f] [command[&command[&...]]]",13,10
db " msr c",13,10
else
db "Usage: ramhelpr [i|f] [command[&command[&...]]]",13,10
endif
db 13,10
db "i: Install only if no RAM helper is already installed.",13,10
db "f: Force install, even if the same or other helper is already installed.",13,10
db "command: DOS command to be invoked after the install process (DOS 2 only).",13,10
db " Under COMMAND 2.4x multiple commands can be specified, separated by &.",13,10
if INSTALL_MSR = 1
db 13,10
db "c: Cleanup: free all segments allocated in user mode.",13,10
db " This is necessary because in MSX-DOS 1 those segments won't be freed",13,10
db " automatically when the application allocating them terminates."
endif
db 13,10,"$"
if INSTALL_MSR = 1
MSR_ALINST_S:
db "*** Mapper support routines are already installed.",13,10
db " If you want to install the RAM helper only, use RAMHELPR.COM instead."
db 13,10,"$"
IHAVESETSLOTS_S:
db "- I have set the same slot for all pages of TPA",13,10,13,10,"$"
endif
RH_ALINST_S:
db "*** An UNAPI RAM helper is already installed",13,10,"$"
NOMAPPER_S:
db "*** ERROR: No mapped RAM found.",13,10,"$"
NOTPA_S:
db "*** ERROR: Not enough TPA space",13,10,"$"
CMDWARNING_S:
db 13,10,"* WARNING: The extra DOS command isn't invoked in MSX-DOS 1",13,10,"$"
OK_S: db "Installed. Have fun!",13,10,"$"
if INSTALL_MSR = 1
;****************************************
;*** CODE TO BE COPIED IN A SEGMENT ***
;****************************************
SEGMENT_CODE:
org 4000h
SEGMENT_CODE_START:
ALL_SEG__SEG:
jp _ALL_SEG__SEG
FRE_SEG__SEG:
jp _FRE_SEG__SEG
;ALL_SEG - Parameters: A=0 => allocate user segment
; A=1 => allocate system segment
; B=0 => allocate primary mapper
; B!=0 => allocate FxxxSSPP slot address
; (primary mapper, if 0)
; xxx=000 allocate specified slot only
; xxx=001 allocate other slots than
; specified
; xxx=010 try to allocate specified slot
; and, if it failed, try another slot
; (if any)
; xxx=011 try to allocate other slots
; than specified and, if it failed,
; try specified slot
;
; Results: Carry set => no free segments
; Carry clear => segment allocated
; A=new segment number
; B=slot address of
; mapper slot (0 if called as B=0)
_ALL_SEG__SEG:
and 1
inc a ;Type of segment to allocate
ex af,af'
;
ld c,b
ld a,c ;If requested slot number is
and 10001111b ; zero then use the primary
jr nz,not_primary_all ; mapper slot number. Leave
ld a,(RAMSLOT3) ; the zero in B for now in
or c ; case of a type 000 return.
ld c,a ;C := slot number & type
not_primary_all:
;
; ***** ONLY TRY SPECIFIED SLOT IF TYPE 000 *****
;
ld a,c ;If "type" is 000 then
and 01110000b ; just try to allocate from
jr nz,not_type_000 ; the requested slot and
jr ALL_SEG_SLOT_C ; then jump immediately with
; the result.
not_type_000:
;
;
; ***** TRY SPECIFIED SLOT FIRST FOR TYPE 010 *****
;
ld b,c ;B := real slot & type
cp 00100000b ;For type 010 allocate in
jr nz,not_type_010 ; specified slot if possible.
call ALL_SEG_SLOT_C
jr nc,all_seg_ret
not_type_010:
;
;
; ***** TRY EVERY SLOT EXCEPT SPECIFIED ONE FOR ALL TYPES *****
;
xor a
ld hl,EXPTBL
all_pri_loop: bit 7,(hl) ;Set expanded slot flag in A
jr z,all_not_exp ; if this slot is expanded.
set 7,a
all_not_exp:
all_sec_loop: ld c,a ;Try to allocate a segment
xor b ; from this slot unless it
and 10001111b ; is the specified slot
jr z,skip_slot ; number.
push hl
call ALL_SEG_SLOT_C
pop hl
jr nc,all_seg_ret ;Exit if got segment
skip_slot: ld a,c
;
bit 7,a
jr z,all_not_exp_2 ;If it is an expanded slot
add a,4 ; then step on to next
bit 4,a ; secondary slot and loop
jr z,all_sec_loop ; back if not last one.
all_not_exp_2: inc hl
inc a ;Step onto next primary slot
and 03h ; and loop back if not done
jr nz,all_pri_loop ; the last one.
;
;
; ***** FINALLY TRY SPECIFIED SLOT FOR TYPE 011 *****
;
ld a,b ;Couldn't find segment so if
and 01110000b ; try the specified segment as
cp 00110000b ; a "last resort" if it is
scf ; allocation type 011.
jr nz,all_seg_ret
ld c,b
call ALL_SEG_SLOT_C
;
all_seg_ret: push af ;For all returns other than
ld a,c ; for type 000, return the
and 10001111b ; actual slot number in
ld b,a ; register B, preserving
pop af ; carry flag.
ret
;
;
; --------------------------------------------------
;
;
ALL_SEG_SLOT_C: push bc
;
ld a,c
call GET_MAPPER_POINTERS
jr c,no_seg_ret
;
ld a,(de)
inc de
ld c,a ;C := total segments in mapper
ex af,af'
ld b,a
ex af,af' ;Skip if we are allocating
dec b ; a system segment.
dec b
jr z,all_system
;
;
ld b,0
all_user_loop: ld a,(hl) ;For a user segment look
or a ; through the segment list
jr z,got_user_seg ; forwards until we find a
inc b ; free segment.
inc hl ;C = loop counter
dec c ;B = segment number
jr nz,all_user_loop
jr no_seg_ret ;Error if no free segments
;
got_user_seg: ex de,hl
dec (hl) ;One fewer free segments
inc hl
inc hl
inc (hl) ;One more user segment
jr got_seg_ret ;Jump with B=segment
;
;
all_system: add hl,bc ;For a system segment look
all_sys_loop: dec hl ; through the segment list
ld a,(hl) ; from the end backwards to
or a ; find the highest numbered
jr z,got_sys_seg ; free segment
dec c
jr nz,all_sys_loop
jr no_seg_ret ;Error if no free segments
;
got_sys_seg: ld b,c
dec b ;B = segment number
ex de,hl
dec (hl) ;One fewer free segments
inc hl
inc (hl) ;One more system segments
;
;
got_seg_ret: ex af,af' ;Record the owning process id
ld (de),a ; in the segment list (FFh if
ex af,af' ; it is a system segment).
;
ld a,b ;A := allocated segment number
pop bc
or a ;Return with carry clear
ret ; to indicate success.
;
;
no_seg_ret: pop bc ;If no free segments then
scf ; return with carry set to
ret ; indicate error.
;FRE_SEG - Parameters: A=segment number to free
; B =0 primary mapper
; B!=0 mapper other than primary
;
; Returns: Carry set => error
; Carry clear => segment freed OK
;
;If A=FFh and B=0Fh: Free all segmenst allocated in user mode,
; returns Cy=0 and BC=hoy many segments have been freed
_FRE_SEG__SEG:
ld c,a ;C = segment number
cp 0FFh
jr nz,no_free_all_user
ld a,b
cp 0Fh
jr nz,no_free_all_user
call FREE_USER__SEG
or a
ret
no_free_all_user:
ld a,b
and 10001111b ;If slot number is zero then
jr nz,fre_not_prim ; use the primary mapper slot
ld a,(RAMSLOT3)
fre_not_prim:
call GET_MAPPER_POINTERS
jr c,fre_bad_seg
ld a,(de) ;Check that segment number is
cp c ; smaller than the total
jr c,fre_bad_seg ; segments for this mapper and
jr z,fre_bad_seg ; error if not.
ld b,0
add hl,bc ;HL -> this segment in list
ld a,(hl) ;Error if this segment is
or a ; already free.
jr z,fre_bad_seg
ld (hl),b ;Mark it as free now.
;
ex de,hl
inc hl
inc (hl) ;One more free segment
inc hl
cp 2 ;One fewer user or system segment
jr z,fre_system
inc hl
fre_system: dec (hl)
or a ;Clear carry => success
ret
;
fre_bad_seg: scf ;Set carry to indicate error
ret
;Free all user segments
;Output: BC = How many segments have I freed
FREE_USER__SEG:
ld de,0401h
call EXTBIO
push hl
pop ix ;IX = Mappers table
ld de,SEG_USE_TABLE
ld hl,0 ;HL = How many segments have I freed
FREE_USER_LOOP:
ld a,(ix)
or a
jr z,FREE_USER_END
push de
ld b,(ix+1) ;Total segments in mapper
FREE_USER_LOOP_2:
ld a,(de)
cp 1
jr nz,no_user_segment
xor a
ld (de),a
inc (ix+2) ;One more free segment in mapper
inc hl ;One more segment freed
no_user_segment:
inc de
djnz FREE_USER_LOOP_2
ld (ix+4),b ;Number of segments allocated to user in mapper = 0
ld bc,8
add ix,bc ;Next mappers table entry
pop de
inc d ;Next entry in SEG_USE_TABLE
jr FREE_USER_LOOP
FREE_USER_END:
push hl
pop bc
ret
;This routine gets the pointers for a mapper slot.
;Input: A = Slot number
;Output: DE = Pointer to 2nd byte (total segments) in mappers table for the slot
; HL = Pointer to start of table in SEG_USE_TABLE for the slot
; Cy = 1 on error (not a valid mapper slot number)
GET_MAPPER_POINTERS:
push bc
call _GMP
pop bc
ret
_GMP:
and 10001111b
push af
ld de,0401h
call EXTBIO
pop bc
ex de,hl
ld hl,SEG_USE_TABLE
GMPLOOP:
ld a,(de)
inc de
or a
scf
ret z
cp b
ret z
inc h
inc de
inc de
inc de
inc de
inc de
inc de
inc de
jr GMPLOOP
;This is a four entries table with 256 bytes for each mapper slot.
;Each entry has: 0 = free segment, 1 = allocated to user, 2 = allocated to system, FFh = doesn't exist.
SEG_USE_TABLE:
SEGMENT_CODE_END:
endif
|
;; defines to require multi define-substitution
DEFINE _zzzzz _zzzz
DEFINE _zzzz _zzz
DEFINE _zzz _zz
DEFINE _zz _z
DEFINE _z hl
MACRO xxx
/* /*
/* 3x nested
block
comment */ */
*/
halt
ENDM
/* ld _zzzzz,0
/* 2x nested block comment
assdada */ ld _zzzzz,0
/*
ass dada */ ld _zzzzz,0
*/
DUP /* inbetween arguments for DUP-macro */ 2
ret/* some live code on block comment line
zzz
*/ld _zzzzz,0
xxx ; emit macro
EDUP
// similar test, but outside of DUP
/* block1 */ cpl /* block2 */
ret/*
zzz
// ; '*/ld _zzzzz,0
xxx:ldi/* : */::ldd:ldir:/*:"*/:lddr
: daa
/* END ... // : block comment */ : nop ; LIVE instr!
/* invalid * * / amount of close blocks */ */ /* : */ : ; and no <EOL> here |
RuinsOfAlphKabutoWordRoom_MapScripts:
db 0 ; scene scripts
db 0 ; callbacks
RuinsOfAlphKabutoWordRoom_MapEvents:
db 0, 0 ; filler
db 3 ; warp events
warp_event 9, 5, RUINS_OF_ALPH_KABUTO_ITEM_ROOM, 3
warp_event 10, 5, RUINS_OF_ALPH_KABUTO_ITEM_ROOM, 4
warp_event 17, 11, RUINS_OF_ALPH_INNER_CHAMBER, 4
db 0 ; coord events
db 0 ; bg events
db 0 ; object events
|
#include "CppUTest/TestHarness.h"
extern "C" {
#include "trace.h"
}
TEST_GROUP(test_trace)
{
trace trace_0;
void setup()
{
}
void teardown()
{
}
};
TEST(test_trace, test_trace_basic)
{
const int trigger_level = 120;
trace_init(&trace_0, 1337, trigger_level);
uint16_t sample=0;
int add = 0;
for (int i=0; i<TRACE_SIZE-TRACE_DELAY; i+=add)
{
if (sample > trigger_level && add == 0)
add = 1;
int result = trace_put(&trace_0, sample++);
LONGS_EQUAL(0, result);
}
{
int result = trace_put(&trace_0, sample++);
LONGS_EQUAL(1, result);
}
{
int result = trace_put(&trace_0, sample++);
LONGS_EQUAL(-1, result);
}
}
|
//
// Created by Edward Pfremmer on 1/30/16.
//
#include "BuzzwordFactory.h"
Buzzword* BuzzwordFactory::make(const std::string &string) {
return new Buzzword(string);
}
|
; Licensed to the .NET Foundation under one or more agreements.
; The .NET Foundation licenses this file to you under the MIT license.
; ***********************************************************************
; File: JitHelpers_Fast.asm
;
; Notes: routinues which we believe to be on the hot path for managed
; code in most scenarios.
; ***********************************************************************
include AsmMacros.inc
include asmconstants.inc
; Min amount of stack space that a nested function should allocate.
MIN_SIZE equ 28h
EXTERN g_ephemeral_low:QWORD
EXTERN g_ephemeral_high:QWORD
EXTERN g_lowest_address:QWORD
EXTERN g_highest_address:QWORD
EXTERN g_card_table:QWORD
ifdef FEATURE_MANUALLY_MANAGED_CARD_BUNDLES
EXTERN g_card_bundle_table:QWORD
endif
ifdef FEATURE_USE_SOFTWARE_WRITE_WATCH_FOR_GC_HEAP
EXTERN g_sw_ww_table:QWORD
EXTERN g_sw_ww_enabled_for_gc_heap:BYTE
endif
ifdef WRITE_BARRIER_CHECK
; Those global variables are always defined, but should be 0 for Server GC
g_GCShadow TEXTEQU <?g_GCShadow@@3PEAEEA>
g_GCShadowEnd TEXTEQU <?g_GCShadowEnd@@3PEAEEA>
EXTERN g_GCShadow:QWORD
EXTERN g_GCShadowEnd:QWORD
endif
INVALIDGCVALUE equ 0CCCCCCCDh
ifdef _DEBUG
extern JIT_WriteBarrier_Debug:proc
endif
extern JIT_InternalThrow:proc
; Mark start of the code region that we patch at runtime
LEAF_ENTRY JIT_PatchedCodeStart, _TEXT
ret
LEAF_END JIT_PatchedCodeStart, _TEXT
; This is used by the mechanism to hold either the JIT_WriteBarrier_PreGrow
; or JIT_WriteBarrier_PostGrow code (depending on the state of the GC). It _WILL_
; change at runtime as the GC changes. Initially it should simply be a copy of the
; larger of the two functions (JIT_WriteBarrier_PostGrow) to ensure we have created
; enough space to copy that code in.
LEAF_ENTRY JIT_WriteBarrier, _TEXT
align 16
ifdef _DEBUG
; In debug builds, this just contains jump to the debug version of the write barrier by default
mov rax, JIT_WriteBarrier_Debug
jmp rax
endif
ifdef FEATURE_USE_SOFTWARE_WRITE_WATCH_FOR_GC_HEAP
; JIT_WriteBarrier_WriteWatch_PostGrow64
; Regarding patchable constants:
; - 64-bit constants have to be loaded into a register
; - The constants have to be aligned to 8 bytes so that they can be patched easily
; - The constant loads have been located to minimize NOP padding required to align the constants
; - Using different registers for successive constant loads helps pipeline better. Should we decide to use a special
; non-volatile calling convention, this should be changed to use just one register.
; Do the move into the GC . It is correct to take an AV here, the EH code
; figures out that this came from a WriteBarrier and correctly maps it back
; to the managed method which called the WriteBarrier (see setup in
; InitializeExceptionHandling, vm\exceptionhandling.cpp).
mov [rcx], rdx
; Update the write watch table if necessary
mov rax, rcx
mov r8, 0F0F0F0F0F0F0F0F0h
shr rax, 0Ch ; SoftwareWriteWatch::AddressToTableByteIndexShift
NOP_2_BYTE ; padding for alignment of constant
mov r9, 0F0F0F0F0F0F0F0F0h
add rax, r8
cmp byte ptr [rax], 0h
jne CheckCardTable
mov byte ptr [rax], 0FFh
NOP_3_BYTE ; padding for alignment of constant
; Check the lower and upper ephemeral region bounds
CheckCardTable:
cmp rdx, r9
jb Exit
NOP_3_BYTE ; padding for alignment of constant
mov r8, 0F0F0F0F0F0F0F0F0h
cmp rdx, r8
jae Exit
nop ; padding for alignment of constant
mov rax, 0F0F0F0F0F0F0F0F0h
; Touch the card table entry, if not already dirty.
shr rcx, 0Bh
cmp byte ptr [rcx + rax], 0FFh
jne UpdateCardTable
REPRET
UpdateCardTable:
mov byte ptr [rcx + rax], 0FFh
ifdef FEATURE_MANUALLY_MANAGED_CARD_BUNDLES
mov rax, 0F0F0F0F0F0F0F0F0h
shr rcx, 0Ah
cmp byte ptr [rcx + rax], 0FFh
jne UpdateCardBundleTable
REPRET
UpdateCardBundleTable:
mov byte ptr [rcx + rax], 0FFh
endif
ret
align 16
Exit:
REPRET
else
; JIT_WriteBarrier_PostGrow64
; Do the move into the GC . It is correct to take an AV here, the EH code
; figures out that this came from a WriteBarrier and correctly maps it back
; to the managed method which called the WriteBarrier (see setup in
; InitializeExceptionHandling, vm\exceptionhandling.cpp).
mov [rcx], rdx
NOP_3_BYTE ; padding for alignment of constant
; Can't compare a 64 bit immediate, so we have to move them into a
; register. Values of these immediates will be patched at runtime.
; By using two registers we can pipeline better. Should we decide to use
; a special non-volatile calling convention, this should be changed to
; just one.
mov rax, 0F0F0F0F0F0F0F0F0h
; Check the lower and upper ephemeral region bounds
cmp rdx, rax
jb Exit
nop ; padding for alignment of constant
mov r8, 0F0F0F0F0F0F0F0F0h
cmp rdx, r8
jae Exit
nop ; padding for alignment of constant
mov rax, 0F0F0F0F0F0F0F0F0h
; Touch the card table entry, if not already dirty.
shr rcx, 0Bh
cmp byte ptr [rcx + rax], 0FFh
jne UpdateCardTable
REPRET
UpdateCardTable:
mov byte ptr [rcx + rax], 0FFh
ifdef FEATURE_MANUALLY_MANAGED_CARD_BUNDLES
mov rax, 0F0F0F0F0F0F0F0F0h
shr rcx, 0Ah
cmp byte ptr [rcx + rax], 0FFh
jne UpdateCardBundleTable
REPRET
UpdateCardBundleTable:
mov byte ptr [rcx + rax], 0FFh
endif
ret
align 16
Exit:
REPRET
endif
; make sure this is bigger than any of the others
align 16
nop
LEAF_END_MARKED JIT_WriteBarrier, _TEXT
; Mark start of the code region that we patch at runtime
LEAF_ENTRY JIT_PatchedCodeLast, _TEXT
ret
LEAF_END JIT_PatchedCodeLast, _TEXT
; JIT_ByRefWriteBarrier has weird symantics, see usage in StubLinkerX86.cpp
;
; Entry:
; RDI - address of ref-field (assigned to)
; RSI - address of the data (source)
; RCX is trashed
; RAX is trashed when FEATURE_USE_SOFTWARE_WRITE_WATCH_FOR_GC_HEAP is defined
; Exit:
; RDI, RSI are incremented by SIZEOF(LPVOID)
LEAF_ENTRY JIT_ByRefWriteBarrier, _TEXT
mov rcx, [rsi]
; If !WRITE_BARRIER_CHECK do the write first, otherwise we might have to do some ShadowGC stuff
ifndef WRITE_BARRIER_CHECK
; rcx is [rsi]
mov [rdi], rcx
endif
; When WRITE_BARRIER_CHECK is defined _NotInHeap will write the reference
; but if it isn't then it will just return.
;
; See if this is in GCHeap
cmp rdi, [g_lowest_address]
jb NotInHeap
cmp rdi, [g_highest_address]
jnb NotInHeap
ifdef WRITE_BARRIER_CHECK
; we can only trash rcx in this function so in _DEBUG we need to save
; some scratch registers.
push r10
push r11
push rax
; **ALSO update the shadow GC heap if that is enabled**
; Do not perform the work if g_GCShadow is 0
cmp g_GCShadow, 0
je NoShadow
; If we end up outside of the heap don't corrupt random memory
mov r10, rdi
sub r10, [g_lowest_address]
jb NoShadow
; Check that our adjusted destination is somewhere in the shadow gc
add r10, [g_GCShadow]
cmp r10, [g_GCShadowEnd]
ja NoShadow
; Write ref into real GC
mov [rdi], rcx
; Write ref into shadow GC
mov [r10], rcx
; Ensure that the write to the shadow heap occurs before the read from
; the GC heap so that race conditions are caught by INVALIDGCVALUE
mfence
; Check that GC/ShadowGC values match
mov r11, [rdi]
mov rax, [r10]
cmp rax, r11
je DoneShadow
mov r11, INVALIDGCVALUE
mov [r10], r11
jmp DoneShadow
; If we don't have a shadow GC we won't have done the write yet
NoShadow:
mov [rdi], rcx
; If we had a shadow GC then we already wrote to the real GC at the same time
; as the shadow GC so we want to jump over the real write immediately above.
; Additionally we know for sure that we are inside the heap and therefore don't
; need to replicate the above checks.
DoneShadow:
pop rax
pop r11
pop r10
endif
ifdef FEATURE_USE_SOFTWARE_WRITE_WATCH_FOR_GC_HEAP
; Update the write watch table if necessary
cmp byte ptr [g_sw_ww_enabled_for_gc_heap], 0h
je CheckCardTable
mov rax, rdi
shr rax, 0Ch ; SoftwareWriteWatch::AddressToTableByteIndexShift
add rax, qword ptr [g_sw_ww_table]
cmp byte ptr [rax], 0h
jne CheckCardTable
mov byte ptr [rax], 0FFh
endif
; See if we can just quick out
CheckCardTable:
cmp rcx, [g_ephemeral_low]
jb Exit
cmp rcx, [g_ephemeral_high]
jnb Exit
; move current rdi value into rcx and then increment the pointers
mov rcx, rdi
add rsi, 8h
add rdi, 8h
; Check if we need to update the card table
; Calc pCardByte
shr rcx, 0Bh
add rcx, [g_card_table]
; Check if this card is dirty
cmp byte ptr [rcx], 0FFh
jne UpdateCardTable
REPRET
UpdateCardTable:
mov byte ptr [rcx], 0FFh
ifdef FEATURE_MANUALLY_MANAGED_CARD_BUNDLES
; check if we need to update the card bundle table
; restore destination address from rdi - rdi has been incremented by 8 already
lea rcx, [rdi-8]
shr rcx, 15h
add rcx, [g_card_bundle_table]
cmp byte ptr [rcx], 0FFh
jne UpdateCardBundleTable
REPRET
UpdateCardBundleTable:
mov byte ptr [rcx], 0FFh
endif
ret
align 16
NotInHeap:
; If WRITE_BARRIER_CHECK then we won't have already done the mov and should do it here
; If !WRITE_BARRIER_CHECK we want _NotInHeap and _Leave to be the same and have both
; 16 byte aligned.
ifdef WRITE_BARRIER_CHECK
; rcx is [rsi]
mov [rdi], rcx
endif
Exit:
; Increment the pointers before leaving
add rdi, 8h
add rsi, 8h
ret
LEAF_END_MARKED JIT_ByRefWriteBarrier, _TEXT
Section segment para 'DATA'
align 16
public JIT_WriteBarrier_Loc
JIT_WriteBarrier_Loc:
dq 0
LEAF_ENTRY JIT_WriteBarrier_Callable, _TEXT
; JIT_WriteBarrier(Object** dst, Object* src)
jmp QWORD PTR [JIT_WriteBarrier_Loc]
LEAF_END JIT_WriteBarrier_Callable, _TEXT
; There is an even more optimized version of these helpers possible which takes
; advantage of knowledge of which way the ephemeral heap is growing to only do 1/2
; that check (this is more significant in the JIT_WriteBarrier case).
;
; Additionally we can look into providing helpers which will take the src/dest from
; specific registers (like x86) which _could_ (??) make for easier register allocation
; for the JIT64, however it might lead to having to have some nasty code that treats
; these guys really special like... :(.
;
; Version that does the move, checks whether or not it's in the GC and whether or not
; it needs to have it's card updated
;
; void JIT_CheckedWriteBarrier(Object** dst, Object* src)
LEAF_ENTRY JIT_CheckedWriteBarrier, _TEXT
; When WRITE_BARRIER_CHECK is defined _NotInHeap will write the reference
; but if it isn't then it will just return.
;
; See if this is in GCHeap
cmp rcx, [g_lowest_address]
jb NotInHeap
cmp rcx, [g_highest_address]
jnb NotInHeap
jmp QWORD PTR [JIT_WriteBarrier_Loc]
NotInHeap:
; See comment above about possible AV
mov [rcx], rdx
ret
LEAF_END_MARKED JIT_CheckedWriteBarrier, _TEXT
; The following helper will access ("probe") a word on each page of the stack
; starting with the page right beneath rsp down to the one pointed to by r11.
; The procedure is needed to make sure that the "guard" page is pushed down below the allocated stack frame.
; The call to the helper will be emitted by JIT in the function/funclet prolog when large (larger than 0x3000 bytes) stack frame is required.
;
; NOTE: this helper will NOT modify a value of rsp and can be defined as a leaf function.
PROBE_PAGE_SIZE equ 1000h
LEAF_ENTRY JIT_StackProbe, _TEXT
; On entry:
; r11 - points to the lowest address on the stack frame being allocated (i.e. [InitialSp - FrameSize])
; rsp - points to some byte on the last probed page
; On exit:
; rax - is not preserved
; r11 - is preserved
;
; NOTE: this helper will probe at least one page below the one pointed by rsp.
mov rax, rsp ; rax points to some byte on the last probed page
and rax, -PROBE_PAGE_SIZE ; rax points to the **lowest address** on the last probed page
; This is done to make the following loop end condition simpler.
ProbeLoop:
sub rax, PROBE_PAGE_SIZE ; rax points to the lowest address of the **next page** to probe
test dword ptr [rax], eax ; rax points to the lowest address on the **last probed** page
cmp rax, r11
jg ProbeLoop ; If (rax > r11), then we need to probe at least one more page.
ret
LEAF_END_MARKED JIT_StackProbe, _TEXT
LEAF_ENTRY JIT_ValidateIndirectCall, _TEXT
ret
LEAF_END JIT_ValidateIndirectCall, _TEXT
LEAF_ENTRY JIT_DispatchIndirectCall, _TEXT
ifdef _DEBUG
mov r10, 0CDCDCDCDCDCDCDCDh ; The real helper clobbers these registers, so clobber them too in the fake helper
mov r11, 0CDCDCDCDCDCDCDCDh
endif
rexw jmp rax
LEAF_END JIT_DispatchIndirectCall, _TEXT
end
|
object_const_def ; object_event constants
FloaromaHouseW_MapScripts:
db 0 ; scene scripts
db 0 ; callbacks
FloaromaHouseW_MapEvents:
db 0, 0 ; filler
db 2 ; warp events
warp_event 2, 7, FLOAROMA_TOWN, 3
warp_event 3, 7, FLOAROMA_TOWN, 3
db 0 ; coord events
db 0 ; bg events
db 0 ; object events
|
;
; ZX IF1 & Microdrive functions
;
; char* if1_getname(char *location);
;
; Picks a file name from the specified location
;
; $Id: if1_getname.asm,v 1.2 2015/01/19 01:33:10 pauloscustodio Exp $
;
PUBLIC if1_getname
tempmdvname: defs 11
if1_getname:
pop bc ; ret addr
pop hl ; location
push hl
push bc
ld de,tempmdvname
push de
ld bc,10
ldir
push de
pop hl
previous: dec hl
ld a,(hl)
cp ' '
jr z,previous
inc hl
ld (hl),0
pop hl ; pointer to temp name
ret
|
.EQU Ram_Memory = 255
.CSEG
.ORG 0x40
main: MOV R30, Ram_Memory ;Moves the number of memory adddresses to register 30
MOV R8, 0x00 ;Moves 0 into R8
MOV R5, 0xFF ;Moves 0xFF into register 5
Loop: ST R8, (R30) ;Stores the current value of R30 into R8
SUB R30, 0x01 ;Subtracts 1 from R30 to move to the next lowest memory address
CMP R30, R5 ;Compares R5 and R30
BRNE Loop ;Branches if not equal to loop
|
page ,132
title strrchr - find last occurence of character in string
;***
;strrchr.asm - find last occurrence of character in string
;
; Copyright (c) 1985-2001, Microsoft Corporation. All rights reserved.
;
;Purpose:
; defines strrchr() - find the last occurrence of a given character
; in a string.
;
;Revision History:
; 10-27-83 RN initial version
; 05-18-88 SJM Add model-independent (large model) ifdef
; 08-04-88 SJM convert to cruntime/ add 32-bit support
; 08-23-88 JCR 386 cleanup
; 10-26-88 JCR General cleanup for 386-only code
; 03-26-90 GJF Changed to _stdcall. Also, fixed the copyright.
; 05-10-91 GJF Back to _cdecl, sigh...
; 06-12-01 PML inc->add 1, dec->sub 1 for Pentium 4 perf (vs7#267015)
;
;*******************************************************************************
.xlist
include cruntime.inc
.list
page
;***
;char *strrchr(string, ch) - find last occurrence of ch in string
;
;Purpose:
; Finds the last occurrence of ch in string. The terminating
; null character is used as part of the search.
;
; Algorithm:
; char *
; strrchr (string, ch)
; char *string, ch;
; {
; char *start = string;
;
; while (*string++)
; ;
; while (--string != start && *string != ch)
; ;
; if (*string == ch)
; return(string);
; return(NULL);
; }
;
;Entry:
; char *string - string to search in
; char ch - character to search for
;
;Exit:
; returns a pointer to the last occurrence of ch in the given
; string
; returns NULL if ch does not occurr in the string
;
;Uses:
;
;Exceptions:
;
;*******************************************************************************
CODESEG
public strrchr
strrchr proc \
uses edi, \
string:ptr byte, \
chr:byte
mov edi,[string] ; di = string
xor eax,eax ; al=null byte
or ecx,-1 ; cx = -1
repne scasb ; find the null & count bytes
add ecx,1 ; cx=-byte count (with null)
neg ecx ; cx=+byte count (with null)
sub edi,1 ; di points to terminal null
mov al,chr ; al=search byte
std ; count 'down' on string this time
repne scasb ; find that byte
add edi,1 ; di points to byte which stopped scan
cmp [edi],al ; see if we have a hit
je short returndi ; yes, point to byte
xor eax,eax ; no, return NULL
jmp short toend ; do return sequence
returndi:
mov eax,edi ; ax=pointer to byte
toend:
cld
ifdef _STDCALL_
ret DPSIZE + ISIZE ; _stdcall return
else
ret ; _cdecl return
endif
strrchr endp
end
|
; A133823: Triangle whose rows are sequences of increasing and decreasing cubes:1; 1,8,1; 1,8,27,8,1; ... .
; Submitted by Jamie Morken(s3)
; 1,1,8,1,1,8,27,8,1,1,8,27,64,27,8,1,1,8,27,64,125,64,27,8,1,1,8,27,64,125,216,125,64,27,8,1,1,8,27,64,125,216,343,216,125,64,27,8,1,1,8,27,64,125,216,343,512,343,216,125,64,27,8,1,1,8,27,64,125,216,343,512,729,512,343,216,125,64,27,8,1,1,8,27,64,125,216,343,512,729,1000,729,512,343,216,125,64,27,8,1
mul $0,2
mov $1,1
lpb $0
sub $0,$1
gcd $0,$2
sub $0,1
add $1,4
lpe
div $0,2
add $0,1
pow $0,3
|
; A126335: a(n) = n*(4*n^2+5*n-3)/2.
; 3,23,72,162,305,513,798,1172,1647,2235,2948,3798,4797,5957,7290,8808,10523,12447,14592,16970,19593,22473,25622,29052,32775,36803,41148,45822,50837,56205,61938,68048,74547,81447,88760,96498,104673,113297,122382,131940,141983,152523,163572,175142,187245,199893,213098,226872,241227,256175,271728,287898,304697,322137,340230,358988,378423,398547,419372,440910,463173,486173,509922,534432,559715,585783,612648,640322,668817,698145,728318,759348,791247,824027,857700,892278,927773,964197,1001562,1039880,1079163,1119423,1160672,1202922,1246185,1290473,1335798,1382172,1429607,1478115,1527708,1578398,1630197,1683117,1737170,1792368,1848723,1906247,1964952,2024850,2085953,2148273,2211822,2276612,2342655,2409963,2478548,2548422,2619597,2692085,2765898,2841048,2917547,2995407,3074640,3155258,3237273,3320697,3405542,3491820,3579543,3668723,3759372,3851502,3945125,4040253,4136898,4235072,4334787,4436055,4538888,4643298,4749297,4856897,4966110,5076948,5189423,5303547,5419332,5536790,5655933,5776773,5899322,6023592,6149595,6277343,6406848,6538122,6671177,6806025,6942678,7081148,7221447,7363587,7507580,7653438,7801173,7950797,8102322,8255760,8411123,8568423,8727672,8888882,9052065,9217233,9384398,9553572,9724767,9897995,10073268,10250598,10429997,10611477,10795050,10980728,11168523,11358447,11550512,11744730,11941113,12139673,12340422,12543372,12748535,12955923,13165548,13377422,13591557,13807965,14026658,14247648,14470947,14696567,14924520,15154818,15387473,15622497,15859902,16099700,16341903,16586523,16833572,17083062,17335005,17589413,17846298,18105672,18367547,18631935,18898848,19168298,19440297,19714857,19991990,20271708,20554023,20838947,21126492,21416670,21709493,22004973,22303122,22603952,22907475,23213703,23522648,23834322,24148737,24465905,24785838,25108548,25434047,25762347,26093460,26427398,26764173,27103797,27446282,27791640,28139883,28491023,28845072,29202042,29561945,29924793,30290598,30659372,31031127,31405875
add $0,1
mov $2,1
lpb $0,1
add $1,$4
add $2,$0
sub $0,1
add $1,$2
add $1,1
mov $3,4
add $3,$4
add $2,$3
add $4,5
add $2,$4
lpe
|
ARCH_ARM equ 0
ARCH_MIPS equ 0
ARCH_X86 equ 0
ARCH_X86_64 equ 1
ARCH_PPC32 equ 0
ARCH_PPC64 equ 0
HAVE_ARMV5TE equ 0
HAVE_ARMV6 equ 0
HAVE_ARMV7 equ 0
HAVE_MIPS32 equ 0
HAVE_MMX equ 1
HAVE_SSE equ 1
HAVE_SSE2 equ 1
HAVE_SSE3 equ 1
HAVE_SSSE3 equ 1
HAVE_SSE4_1 equ 1
HAVE_ALTIVEC equ 0
HAVE_VPX_PORTS equ 1
HAVE_STDINT_H equ 1
HAVE_ALT_TREE_LAYOUT equ 0
HAVE_PTHREAD_H equ 1
HAVE_SYS_MMAN_H equ 1
HAVE_UNISTD_H equ 1
CONFIG_EXTERNAL_BUILD equ 0
CONFIG_INSTALL_DOCS equ 0
CONFIG_INSTALL_BINS equ 1
CONFIG_INSTALL_LIBS equ 1
CONFIG_INSTALL_SRCS equ 0
CONFIG_DEBUG equ 0
CONFIG_GPROF equ 0
CONFIG_GCOV equ 0
CONFIG_RVCT equ 0
CONFIG_GCC equ 1
CONFIG_MSVS equ 0
CONFIG_PIC equ 1
CONFIG_BIG_ENDIAN equ 0
CONFIG_CODEC_SRCS equ 0
CONFIG_DEBUG_LIBS equ 0
CONFIG_FAST_UNALIGNED equ 1
CONFIG_MEM_MANAGER equ 0
CONFIG_MEM_TRACKER equ 0
CONFIG_MEM_CHECKS equ 0
CONFIG_MD5 equ 1
CONFIG_DEQUANT_TOKENS equ 0
CONFIG_DC_RECON equ 0
CONFIG_RUNTIME_CPU_DETECT equ 1
CONFIG_POSTPROC equ 1
CONFIG_MULTITHREAD equ 1
CONFIG_INTERNAL_STATS equ 0
CONFIG_VP8_ENCODER equ 0
CONFIG_VP8_DECODER equ 1
CONFIG_VP8 equ 1
CONFIG_ENCODERS equ 0
CONFIG_DECODERS equ 1
CONFIG_STATIC_MSVCRT equ 0
CONFIG_SPATIAL_RESAMPLING equ 1
CONFIG_REALTIME_ONLY equ 0
CONFIG_ERROR_CONCEALMENT equ 0
CONFIG_SHARED equ 0
CONFIG_STATIC equ 1
CONFIG_SMALL equ 0
CONFIG_POSTPROC_VISUALIZER equ 0
CONFIG_OS_SUPPORT equ 1
CONFIG_UNIT_TESTS equ 0
CONFIG_MULTI_RES_ENCODING equ 0
|
; ==================================================================
; MikeOS -- The Mike Operating System kernel
; Copyright (C) 2006 - 2019 MikeOS Developers -- see doc/LICENSE.TXT
;
; FAT12 FLOPPY DISK ROUTINES
; ==================================================================
; ------------------------------------------------------------------
; os_get_file_list -- Generate comma-separated string of files on floppy
; IN/OUT: AX = location to store zero-terminated filename string
os_get_file_list:
pusha
mov word [.file_list_tmp], ax
mov eax, 0 ; Needed for some older BIOSes
call disk_reset_floppy ; Just in case disk was changed
mov ax, 19 ; Root dir starts at logical sector 19
call disk_convert_l2hts
mov si, disk_buffer ; ES:BX should point to our buffer
mov bx, si
mov ah, 2 ; Params for int 13h: read floppy sectors
mov al, 14 ; And read 14 of them
pusha ; Prepare to enter loop
.read_root_dir:
popa
pusha
stc
int 13h ; Read sectors
call disk_reset_floppy ; Check we've read them OK
jnc .show_dir_init ; No errors, continue
call disk_reset_floppy ; Error = reset controller and try again
jnc .read_root_dir
jmp .done ; Double error, exit 'dir' routine
.show_dir_init:
popa
mov ax, 0
mov si, disk_buffer ; Data reader from start of filenames
mov word di, [.file_list_tmp] ; Name destination buffer
.start_entry:
mov al, [si+11] ; File attributes for entry
cmp al, 0Fh ; Windows marker, skip it
je .skip
test al, 18h ; Is this a directory entry or volume label?
jnz .skip ; Yes, ignore it
mov al, [si]
cmp al, 229 ; If we read 229 = deleted filename
je .skip
cmp al, 0 ; 1st byte = entry never used
je .done
mov cx, 1 ; Set char counter
mov dx, si ; Beginning of possible entry
.testdirentry:
inc si
mov al, [si] ; Test for most unusable characters
cmp al, ' ' ; Windows sometimes puts 0 (UTF-8) or 0FFh
jl .nxtdirentry
cmp al, '~'
ja .nxtdirentry
inc cx
cmp cx, 11 ; Done 11 char filename?
je .gotfilename
jmp .testdirentry
.gotfilename: ; Got a filename that passes testing
mov si, dx ; DX = where getting string
mov cx, 0
.loopy:
mov byte al, [si]
cmp al, ' '
je .ignore_space
mov byte [di], al
inc si
inc di
inc cx
cmp cx, 8
je .add_dot
cmp cx, 11
je .done_copy
jmp .loopy
.ignore_space:
inc si
inc cx
cmp cx, 8
je .add_dot
jmp .loopy
.add_dot:
mov byte [di], '.'
inc di
jmp .loopy
.done_copy:
mov byte [di], ',' ; Use comma to separate filenames
inc di
.nxtdirentry:
mov si, dx ; Start of entry, pretend to skip to next
.skip:
add si, 32 ; Shift to next 32 bytes (next filename)
jmp .start_entry
.done:
dec di
mov byte [di], 0 ; Zero-terminate string (gets rid of final comma)
popa
ret
.file_list_tmp dw 0
; ------------------------------------------------------------------
; os_load_file -- Load file into RAM
; IN: AX = location of filename, CX = location in RAM to load file
; OUT: BX = file size (in bytes), carry set if file not found
os_load_file:
call os_string_uppercase
call int_filename_convert
mov [.filename_loc], ax ; Store filename location
mov [.load_position], cx ; And where to load the file!
mov eax, 0 ; Needed for some older BIOSes
call disk_reset_floppy ; In case floppy has been changed
jnc .floppy_ok ; Did the floppy reset OK?
mov ax, .err_msg_floppy_reset ; If not, bail out
jmp os_fatal_error
.floppy_ok: ; Ready to read first block of data
mov ax, 19 ; Root dir starts at logical sector 19
call disk_convert_l2hts
mov si, disk_buffer ; ES:BX should point to our buffer
mov bx, si
mov ah, 2 ; Params for int 13h: read floppy sectors
mov al, 14 ; 14 root directory sectors
pusha ; Prepare to enter loop
.read_root_dir:
popa
pusha
stc ; A few BIOSes clear, but don't set properly
int 13h ; Read sectors
jnc .search_root_dir ; No errors = continue
call disk_reset_floppy ; Problem = reset controller and try again
jnc .read_root_dir
popa
jmp .root_problem ; Double error = exit
.search_root_dir:
popa
mov cx, word 224 ; Search all entries in root dir
mov bx, -32 ; Begin searching at offset 0 in root dir
.next_root_entry:
add bx, 32 ; Bump searched entries by 1 (offset + 32 bytes)
mov di, disk_buffer ; Point root dir at next entry
add di, bx
mov al, [di] ; First character of name
cmp al, 0 ; Last file name already checked?
je .root_problem
cmp al, 229 ; Was this file deleted?
je .next_root_entry ; If yes, skip it
mov al, [di+11] ; Get the attribute byte
cmp al, 0Fh ; Is this a special Windows entry?
je .next_root_entry
test al, 18h ; Is this a directory entry or volume label?
jnz .next_root_entry
mov byte [di+11], 0 ; Add a terminator to directory name entry
mov ax, di ; Convert root buffer name to upper case
call os_string_uppercase
mov si, [.filename_loc] ; DS:SI = location of filename to load
call os_string_compare ; Current entry same as requested?
jc .found_file_to_load
loop .next_root_entry
.root_problem:
mov bx, 0 ; If file not found or major disk error,
stc ; return with size = 0 and carry set
ret
.found_file_to_load: ; Now fetch cluster and load FAT into RAM
mov ax, [di+28] ; Store file size to return to calling routine
mov word [.file_size], ax
cmp ax, 0 ; If the file size is zero, don't bother trying
je .end ; to read more clusters
mov ax, [di+26] ; Now fetch cluster and load FAT into RAM
mov word [.cluster], ax
mov ax, 1 ; Sector 1 = first sector of first FAT
call disk_convert_l2hts
mov di, disk_buffer ; ES:BX points to our buffer
mov bx, di
mov ah, 2 ; int 13h params: read sectors
mov al, 9 ; And read 9 of them
pusha
.read_fat:
popa ; In case registers altered by int 13h
pusha
stc
int 13h
jnc .read_fat_ok
call disk_reset_floppy
jnc .read_fat
popa
jmp .root_problem
.read_fat_ok:
popa
.load_file_sector:
mov ax, word [.cluster] ; Convert sector to logical
add ax, 31
call disk_convert_l2hts ; Make appropriate params for int 13h
mov bx, [.load_position]
mov ah, 02 ; AH = read sectors, AL = just read 1
mov al, 01
stc
int 13h
jnc .calculate_next_cluster ; If there's no error...
call disk_reset_floppy ; Otherwise, reset floppy and retry
jnc .load_file_sector
mov ax, .err_msg_floppy_reset ; Reset failed, bail out
jmp os_fatal_error
.calculate_next_cluster:
mov ax, [.cluster]
mov bx, 3
mul bx
mov bx, 2
div bx ; DX = [CLUSTER] mod 2
mov si, disk_buffer ; AX = word in FAT for the 12 bits
add si, ax
mov ax, word [ds:si]
or dx, dx ; If DX = 0 [CLUSTER] = even, if DX = 1 then odd
jz .even ; If [CLUSTER] = even, drop last 4 bits of word
; with next cluster; if odd, drop first 4 bits
.odd:
shr ax, 4 ; Shift out first 4 bits (belong to another entry)
jmp .calculate_cluster_cont ; Onto next sector!
.even:
and ax, 0FFFh ; Mask out top (last) 4 bits
.calculate_cluster_cont:
mov word [.cluster], ax ; Store cluster
cmp ax, 0FF8h
jae .end
add word [.load_position], 512
jmp .load_file_sector ; Onto next sector!
.end:
mov bx, [.file_size] ; Get file size to pass back in BX
clc ; Carry clear = good load
ret
.bootd db 0 ; Boot device number
.cluster dw 0 ; Cluster of the file we want to load
.pointer dw 0 ; Pointer into disk_buffer, for loading 'file2load'
.filename_loc dw 0 ; Temporary store of filename location
.load_position dw 0 ; Where we'll load the file
.file_size dw 0 ; Size of the file
.string_buff times 12 db 0 ; For size (integer) printing
.err_msg_floppy_reset db 'os_load_file: Floppy failed to reset', 0
; --------------------------------------------------------------------------
; os_write_file -- Save (max 64K) file to disk
; IN: AX = filename, BX = data location, CX = bytes to write
; OUT: Carry clear if OK, set if failure
os_write_file:
pusha
mov si, ax
call os_string_length
cmp ax, 0
je near .failure
mov ax, si
call os_string_uppercase
call int_filename_convert ; Make filename FAT12-style
jc near .failure
mov word [.filesize], cx
mov word [.location], bx
mov word [.filename], ax
call os_file_exists ; Don't overwrite a file if it exists!
jnc near .failure
; First, zero out the .free_clusters list from any previous execution
pusha
mov di, .free_clusters
mov cx, 128
.clean_free_loop:
mov word [di], 0
inc di
inc di
loop .clean_free_loop
popa
; Next, we need to calculate now many 512 byte clusters are required
mov ax, cx
mov dx, 0
mov bx, 512 ; Divide file size by 512 to get clusters needed
div bx
cmp dx, 0
jg .add_a_bit ; If there's a remainder, we need another cluster
jmp .carry_on
.add_a_bit:
add ax, 1
.carry_on:
mov word [.clusters_needed], ax
mov word ax, [.filename] ; Get filename back
call os_create_file ; Create empty root dir entry for this file
jc near .failure ; If we can't write to the media, jump out
mov word bx, [.filesize]
cmp bx, 0
je near .finished
call disk_read_fat ; Get FAT copy into RAM
mov si, disk_buffer + 3 ; And point SI at it (skipping first two clusters)
mov bx, 2 ; Current cluster counter
mov word cx, [.clusters_needed]
mov dx, 0 ; Offset in .free_clusters list
.find_free_cluster:
lodsw ; Get a word
and ax, 0FFFh ; Mask out for even
jz .found_free_even ; Free entry?
.more_odd:
inc bx ; If not, bump our counter
dec si ; 'lodsw' moved on two chars; we only want to move on one
lodsw ; Get word
shr ax, 4 ; Shift for odd
or ax, ax ; Free entry?
jz .found_free_odd
.more_even:
inc bx ; If not, keep going
jmp .find_free_cluster
.found_free_even:
push si
mov si, .free_clusters ; Store cluster
add si, dx
mov word [si], bx
pop si
dec cx ; Got all the clusters we need?
cmp cx, 0
je .finished_list
inc dx ; Next word in our list
inc dx
jmp .more_odd
.found_free_odd:
push si
mov si, .free_clusters ; Store cluster
add si, dx
mov word [si], bx
pop si
dec cx
cmp cx, 0
je .finished_list
inc dx ; Next word in our list
inc dx
jmp .more_even
.finished_list:
; Now the .free_clusters table contains a series of numbers (words)
; that correspond to free clusters on the disk; the next job is to
; create a cluster chain in the FAT for our file
mov cx, 0 ; .free_clusters offset counter
mov word [.count], 1 ; General cluster counter
.chain_loop:
mov word ax, [.count] ; Is this the last cluster?
cmp word ax, [.clusters_needed]
je .last_cluster
mov di, .free_clusters
add di, cx
mov word bx, [di] ; Get cluster
mov ax, bx ; Find out if it's an odd or even cluster
mov dx, 0
mov bx, 3
mul bx
mov bx, 2
div bx ; DX = [.cluster] mod 2
mov si, disk_buffer
add si, ax ; AX = word in FAT for the 12 bit entry
mov ax, word [ds:si]
or dx, dx ; If DX = 0, [.cluster] = even; if DX = 1 then odd
jz .even
.odd:
and ax, 000Fh ; Zero out bits we want to use
mov di, .free_clusters
add di, cx ; Get offset in .free_clusters
mov word bx, [di+2] ; Get number of NEXT cluster
shl bx, 4 ; And convert it into right format for FAT
add ax, bx
mov word [ds:si], ax ; Store cluster data back in FAT copy in RAM
inc word [.count]
inc cx ; Move on a word in .free_clusters
inc cx
jmp .chain_loop
.even:
and ax, 0F000h ; Zero out bits we want to use
mov di, .free_clusters
add di, cx ; Get offset in .free_clusters
mov word bx, [di+2] ; Get number of NEXT free cluster
add ax, bx
mov word [ds:si], ax ; Store cluster data back in FAT copy in RAM
inc word [.count]
inc cx ; Move on a word in .free_clusters
inc cx
jmp .chain_loop
.last_cluster:
mov di, .free_clusters
add di, cx
mov word bx, [di] ; Get cluster
mov ax, bx
mov dx, 0
mov bx, 3
mul bx
mov bx, 2
div bx ; DX = [.cluster] mod 2
mov si, disk_buffer
add si, ax ; AX = word in FAT for the 12 bit entry
mov ax, word [ds:si]
or dx, dx ; If DX = 0, [.cluster] = even; if DX = 1 then odd
jz .even_last
.odd_last:
and ax, 000Fh ; Set relevant parts to FF8h (last cluster in file)
add ax, 0FF80h
jmp .finito
.even_last:
and ax, 0F000h ; Same as above, but for an even cluster
add ax, 0FF8h
.finito:
mov word [ds:si], ax
call disk_write_fat ; Save our FAT back to disk
; Now it's time to save the sectors to disk!
mov cx, 0
.save_loop:
mov di, .free_clusters
add di, cx
mov word ax, [di]
cmp ax, 0
je near .write_root_entry
pusha
add ax, 31
call disk_convert_l2hts
mov word bx, [.location]
mov ah, 3
mov al, 1
stc
int 13h
popa
add word [.location], 512
inc cx
inc cx
jmp .save_loop
.write_root_entry:
; Now it's time to head back to the root directory, find our
; entry and update it with the cluster in use and file size
call disk_read_root_dir
mov word ax, [.filename]
call disk_get_root_entry
mov word ax, [.free_clusters] ; Get first free cluster
mov word [di+26], ax ; Save cluster location into root dir entry
mov word cx, [.filesize]
mov word [di+28], cx
mov byte [di+30], 0 ; File size
mov byte [di+31], 0
call disk_write_root_dir
.finished:
popa
clc
ret
.failure:
popa
stc ; Couldn't write!
ret
.filesize dw 0
.cluster dw 0
.count dw 0
.location dw 0
.clusters_needed dw 0
.filename dw 0
.free_clusters times 128 dw 0
; --------------------------------------------------------------------------
; os_file_exists -- Check for presence of file on the floppy
; IN: AX = filename location; OUT: carry clear if found, set if not
os_file_exists:
call os_string_uppercase
call int_filename_convert ; Make FAT12-style filename
push ax
call os_string_length
cmp ax, 0
je .failure
pop ax
push ax
call disk_read_root_dir
pop ax ; Restore filename
mov di, disk_buffer
call disk_get_root_entry ; Set or clear carry flag
ret
.failure:
pop ax
stc
ret
; --------------------------------------------------------------------------
; os_create_file -- Creates a new 0-byte file on the floppy disk
; IN: AX = location of filename; OUT: Nothing
os_create_file:
clc
call os_string_uppercase
call int_filename_convert ; Make FAT12-style filename
pusha
push ax ; Save filename for now
call os_file_exists ; Does the file already exist?
jnc .exists_error
; Root dir already read into disk_buffer by os_file_exists
mov di, disk_buffer ; So point DI at it!
mov cx, 224 ; Cycle through root dir entries
.next_entry:
mov byte al, [di]
cmp al, 0 ; Is this a free entry?
je .found_free_entry
cmp al, 0E5h ; Is this a free entry?
je .found_free_entry
add di, 32 ; If not, go onto next entry
loop .next_entry
.exists_error: ; We also get here if above loop finds nothing
pop ax ; Get filename back
popa
stc ; Set carry for failure
ret
.found_free_entry:
pop si ; Get filename back
mov cx, 11
rep movsb ; And copy it into RAM copy of root dir (in DI)
sub di, 11 ; Back to start of root dir entry, for clarity
mov byte [di+11], 0 ; Attributes
mov byte [di+12], 0 ; Reserved
mov byte [di+13], 0 ; Reserved
mov byte [di+14], 0C6h ; Creation time
mov byte [di+15], 07Eh ; Creation time
mov byte [di+16], 0 ; Creation date
mov byte [di+17], 0 ; Creation date
mov byte [di+18], 0 ; Last access date
mov byte [di+19], 0 ; Last access date
mov byte [di+20], 0 ; Ignore in FAT12
mov byte [di+21], 0 ; Ignore in FAT12
mov byte [di+22], 0C6h ; Last write time
mov byte [di+23], 07Eh ; Last write time
mov byte [di+24], 0 ; Last write date
mov byte [di+25], 0 ; Last write date
mov byte [di+26], 0 ; First logical cluster
mov byte [di+27], 0 ; First logical cluster
mov byte [di+28], 0 ; File size
mov byte [di+29], 0 ; File size
mov byte [di+30], 0 ; File size
mov byte [di+31], 0 ; File size
call disk_write_root_dir
jc .failure
popa
clc ; Clear carry for success
ret
.failure:
popa
stc
ret
; --------------------------------------------------------------------------
; os_remove_file -- Deletes the specified file from the filesystem
; IN: AX = location of filename to remove
os_remove_file:
pusha
call os_string_uppercase
call int_filename_convert ; Make filename FAT12-style
push ax ; Save filename
clc
call disk_read_root_dir ; Get root dir into disk_buffer
mov di, disk_buffer ; Point DI to root dir
pop ax ; Get chosen filename back
call disk_get_root_entry ; Entry will be returned in DI
jc .failure ; If entry can't be found
mov ax, word [es:di+26] ; Get first cluster number from the dir entry
mov word [.cluster], ax ; And save it
mov byte [di], 0E5h ; Mark directory entry (first byte of filename) as empty
inc di
mov cx, 0 ; Set rest of data in root dir entry to zeros
.clean_loop:
mov byte [di], 0
inc di
inc cx
cmp cx, 31 ; 32-byte entries, minus E5h byte we marked before
jl .clean_loop
call disk_write_root_dir ; Save back the root directory from RAM
call disk_read_fat ; Now FAT is in disk_buffer
mov di, disk_buffer ; And DI points to it
.more_clusters:
mov word ax, [.cluster] ; Get cluster contents
cmp ax, 0 ; If it's zero, this was an empty file
je .nothing_to_do
mov bx, 3 ; Determine if cluster is odd or even number
mul bx
mov bx, 2
div bx ; DX = [first_cluster] mod 2
mov si, disk_buffer ; AX = word in FAT for the 12 bits
add si, ax
mov ax, word [ds:si]
or dx, dx ; If DX = 0 [.cluster] = even, if DX = 1 then odd
jz .even ; If [.cluster] = even, drop last 4 bits of word
; with next cluster; if odd, drop first 4 bits
.odd:
push ax
and ax, 000Fh ; Set cluster data to zero in FAT in RAM
mov word [ds:si], ax
pop ax
shr ax, 4 ; Shift out first 4 bits (they belong to another entry)
jmp .calculate_cluster_cont ; Onto next sector!
.even:
push ax
and ax, 0F000h ; Set cluster data to zero in FAT in RAM
mov word [ds:si], ax
pop ax
and ax, 0FFFh ; Mask out top (last) 4 bits (they belong to another entry)
.calculate_cluster_cont:
mov word [.cluster], ax ; Store cluster
cmp ax, 0FF8h ; Final cluster marker?
jae .end
jmp .more_clusters ; If not, grab more
.end:
call disk_write_fat
jc .failure
.nothing_to_do:
popa
clc
ret
.failure:
popa
stc
ret
.cluster dw 0
; --------------------------------------------------------------------------
; os_rename_file -- Change the name of a file on the disk
; IN: AX = filename to change, BX = new filename (zero-terminated strings)
; OUT: carry set on error
os_rename_file:
push bx
push ax
clc
call disk_read_root_dir ; Get root dir into disk_buffer
mov di, disk_buffer ; Point DI to root dir
pop ax ; Get chosen filename back
call os_string_uppercase
call int_filename_convert
call disk_get_root_entry ; Entry will be returned in DI
jc .fail_read ; Quit out if file not found
pop bx ; Get new filename string (originally passed in BX)
mov ax, bx
call os_string_uppercase
call int_filename_convert
mov si, ax
mov cx, 11 ; Copy new filename string into root dir entry in disk_buffer
rep movsb
call disk_write_root_dir ; Save root dir to disk
jc .fail_write
clc
ret
.fail_read:
pop ax
stc
ret
.fail_write:
stc
ret
; --------------------------------------------------------------------------
; os_get_file_size -- Get file size information for specified file
; IN: AX = filename; OUT: BX = file size in bytes (up to 64K)
; or carry set if file not found
os_get_file_size:
pusha
call os_string_uppercase
call int_filename_convert
clc
push ax
call disk_read_root_dir
jc .failure
pop ax
mov di, disk_buffer
call disk_get_root_entry
jc .failure
mov word bx, [di+28]
mov word [.tmp], bx
popa
mov word bx, [.tmp]
ret
.failure:
popa
stc
ret
.tmp dw 0
; ==================================================================
; INTERNAL OS ROUTINES -- Not accessible to user programs
; ------------------------------------------------------------------
; int_filename_convert -- Change 'TEST.BIN' into 'TEST BIN' as per FAT12
; IN: AX = filename string
; OUT: AX = location of converted string (carry set if invalid)
int_filename_convert:
pusha
mov si, ax
call os_string_length
cmp ax, 14 ; Filename too long?
jg .failure ; Fail if so
cmp ax, 0
je .failure ; Similarly, fail if zero-char string
mov dx, ax ; Store string length for now
mov di, .dest_string
mov cx, 0
.copy_loop:
lodsb
cmp al, '.'
je .extension_found
stosb
inc cx
cmp cx, dx
jg .failure ; No extension found = wrong
jmp .copy_loop
.extension_found:
cmp cx, 0
je .failure ; Fail if extension dot is first char
cmp cx, 8
je .do_extension ; Skip spaces if first bit is 8 chars
; Now it's time to pad out the rest of the first part of the filename
; with spaces, if necessary
.add_spaces:
mov byte [di], ' '
inc di
inc cx
cmp cx, 8
jl .add_spaces
; Finally, copy over the extension
.do_extension:
lodsb ; 3 characters
cmp al, 0
je .failure
stosb
lodsb
cmp al, 0
je .failure
stosb
lodsb
cmp al, 0
je .failure
stosb
mov byte [di], 0 ; Zero-terminate filename
popa
mov ax, .dest_string
clc ; Clear carry for success
ret
.failure:
popa
stc ; Set carry for failure
ret
.dest_string times 13 db 0
; --------------------------------------------------------------------------
; disk_get_root_entry -- Search RAM copy of root dir for file entry
; IN: AX = filename; OUT: DI = location in disk_buffer of root dir entry,
; or carry set if file not found
disk_get_root_entry:
pusha
mov word [.filename], ax
mov cx, 224 ; Search all (224) entries
mov ax, 0 ; Searching at offset 0
.to_next_root_entry:
xchg cx, dx ; We use CX in the inner loop...
mov word si, [.filename] ; Start searching for filename
mov cx, 11
rep cmpsb
je .found_file ; Pointer DI will be at offset 11, if file found
add ax, 32 ; Bump searched entries by 1 (32 bytes/entry)
mov di, disk_buffer ; Point to next root dir entry
add di, ax
xchg dx, cx ; Get the original CX back
loop .to_next_root_entry
popa
stc ; Set carry if entry not found
ret
.found_file:
sub di, 11 ; Move back to start of this root dir entry
mov word [.tmp], di ; Restore all registers except for DI
popa
mov word di, [.tmp]
clc
ret
.filename dw 0
.tmp dw 0
; --------------------------------------------------------------------------
; disk_read_fat -- Read FAT entry from floppy into disk_buffer
; IN: Nothing; OUT: carry set if failure
disk_read_fat:
pusha
mov ax, 1 ; FAT starts at logical sector 1 (after boot sector)
call disk_convert_l2hts
mov si, disk_buffer ; Set ES:BX to point to 8K OS buffer
mov bx, 2000h
mov es, bx
mov bx, si
mov ah, 2 ; Params for int 13h: read floppy sectors
mov al, 9 ; And read 9 of them for first FAT
pusha ; Prepare to enter loop
.read_fat_loop:
popa
pusha
stc ; A few BIOSes do not set properly on error
int 13h ; Read sectors
jnc .fat_done
call disk_reset_floppy ; Reset controller and try again
jnc .read_fat_loop ; Floppy reset OK?
popa
jmp .read_failure ; Fatal double error
.fat_done:
popa ; Restore registers from main loop
popa ; And restore registers from start of system call
clc
ret
.read_failure:
popa
stc ; Set carry flag (for failure)
ret
; --------------------------------------------------------------------------
; disk_write_fat -- Save FAT contents from disk_buffer in RAM to disk
; IN: FAT in disk_buffer; OUT: carry set if failure
disk_write_fat:
pusha
mov ax, 1 ; FAT starts at logical sector 1 (after boot sector)
call disk_convert_l2hts
mov si, disk_buffer ; Set ES:BX to point to 8K OS buffer
mov bx, ds
mov es, bx
mov bx, si
mov ah, 3 ; Params for int 13h: write floppy sectors
mov al, 9 ; And write 9 of them for first FAT
stc ; A few BIOSes do not set properly on error
int 13h ; Write sectors
jc .write_failure ; Fatal double error
popa ; And restore from start of system call
clc
ret
.write_failure:
popa
stc ; Set carry flag (for failure)
ret
; --------------------------------------------------------------------------
; disk_read_root_dir -- Get the root directory contents
; IN: Nothing; OUT: root directory contents in disk_buffer, carry set if error
disk_read_root_dir:
pusha
mov ax, 19 ; Root dir starts at logical sector 19
call disk_convert_l2hts
mov si, disk_buffer ; Set ES:BX to point to OS buffer
mov bx, ds
mov es, bx
mov bx, si
mov ah, 2 ; Params for int 13h: read floppy sectors
mov al, 14 ; And read 14 of them (from 19 onwards)
pusha ; Prepare to enter loop
.read_root_dir_loop:
popa
pusha
stc ; A few BIOSes do not set properly on error
int 13h ; Read sectors
jnc .root_dir_finished
call disk_reset_floppy ; Reset controller and try again
jnc .read_root_dir_loop ; Floppy reset OK?
popa
jmp .read_failure ; Fatal double error
.root_dir_finished:
popa ; Restore registers from main loop
popa ; And restore from start of this system call
clc ; Clear carry (for success)
ret
.read_failure:
popa
stc ; Set carry flag (for failure)
ret
; --------------------------------------------------------------------------
; disk_write_root_dir -- Write root directory contents from disk_buffer to disk
; IN: root dir copy in disk_buffer; OUT: carry set if error
disk_write_root_dir:
pusha
mov ax, 19 ; Root dir starts at logical sector 19
call disk_convert_l2hts
mov si, disk_buffer ; Set ES:BX to point to OS buffer
mov bx, ds
mov es, bx
mov bx, si
mov ah, 3 ; Params for int 13h: write floppy sectors
mov al, 14 ; And write 14 of them (from 19 onwards)
stc ; A few BIOSes do not set properly on error
int 13h ; Write sectors
jc .write_failure
popa ; And restore from start of this system call
clc
ret
.write_failure:
popa
stc ; Set carry flag (for failure)
ret
; --------------------------------------------------------------------------
; Reset floppy disk
disk_reset_floppy:
push ax
push dx
mov ax, 0
; ******************************************************************
mov dl, [bootdev]
; ******************************************************************
stc
int 13h
pop dx
pop ax
ret
; --------------------------------------------------------------------------
; disk_convert_l2hts -- Calculate head, track and sector for int 13h
; IN: logical sector in AX; OUT: correct registers for int 13h
disk_convert_l2hts:
push bx
push ax
mov bx, ax ; Save logical sector
mov dx, 0 ; First the sector
div word [SecsPerTrack] ; Sectors per track
add dl, 01h ; Physical sectors start at 1
mov cl, dl ; Sectors belong in CL for int 13h
mov ax, bx
mov dx, 0 ; Now calculate the head
div word [SecsPerTrack] ; Sectors per track
mov dx, 0
div word [Sides] ; Floppy sides
mov dh, dl ; Head/side
mov ch, al ; Track
pop ax
pop bx
; ******************************************************************
mov dl, [bootdev] ; Set correct device
; ******************************************************************
ret
Sides dw 2
SecsPerTrack dw 18
; ******************************************************************
bootdev db 0 ; Boot device number
; ******************************************************************
; ==================================================================
|
#include <bits/stdc++.h>
using namespace std;
const int MAX = 26;
// Returneaza un sir cu litere albitrare de lungime n
string printRandomString(int n) {
char alphabet[MAX] = { 'a', 'b', 'c', 'd', 'e', 'f', 'g',
'h', 'i', 'j', 'k', 'l', 'm', 'n',
'o', 'p', 'q', 'r', 's', 't', 'u',
'v', 'w', 'x', 'y', 'z' };
string res = "";
for (int i = 0; i < n; i++) {
res = res + alphabet[rand() % MAX];
}
return res;
}
// Driver code
int main() {
srand(time(NULL));
int n = 10;
for(int i = 0; i < n; i++){
cout << printRandomString(n);
cout << " ";
}
return 0;
} |
UndergroundPathRoute7_h:
db GATE ; tileset
db UNDERGROUND_PATH_ROUTE_7_HEIGHT, UNDERGROUND_PATH_ROUTE_7_WIDTH ; dimensions (y, x)
dw UndergroundPathRoute7_Blocks ; blocks
dw UndergroundPathRoute7_TextPointers ; texts
dw UndergroundPathRoute7_Script ; scripts
db 0 ; connections
dw UndergroundPathRoute7_Object ; objects
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Copyright(c) 2011-2016 Intel Corporation All rights reserved.
;
; Redistribution and use in source and binary forms, with or without
; modification, are permitted provided that the following conditions
; are met:
; * Redistributions of source code must retain the above copyright
; notice, this list of conditions and the following disclaimer.
; * Redistributions in binary form must reproduce the above copyright
; notice, this list of conditions and the following disclaimer in
; the documentation and/or other materials provided with the
; distribution.
; * Neither the name of 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 "sha1_job.asm"
%include "sha1_mb_mgr_datastruct.asm"
%include "reg_sizes.asm"
extern sha1_mb_x4_avx
extern sha1_opt_x1
[bits 64]
default rel
section .text
%ifidn __OUTPUT_FORMAT__, elf64
; LINUX register definitions
%define arg1 rdi ; rcx
%define arg2 rsi ; rdx
; idx needs to be in a register not clobberred by sha1_mult
%define idx rdx ; rsi
%else
; WINDOWS register definitions
%define arg1 rcx
%define arg2 rdx
; idx needs to be in a register not clobberred by sha1_mult
%define idx rsi
%endif
; Common definitions
%define state arg1
%define job arg2
%define len2 arg2
%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
%define lens0 r8
%define lens1 r9
%define lens2 r10
%define lens3 r11
; STACK_SPACE needs to be an odd multiple of 8
_XMM_SAVE_SIZE equ 10*16
_GPR_SAVE_SIZE equ 8*2
_ALIGN_SIZE equ 8
_XMM_SAVE equ 0
_GPR_SAVE equ _XMM_SAVE + _XMM_SAVE_SIZE
STACK_SPACE equ _GPR_SAVE + _GPR_SAVE_SIZE + _ALIGN_SIZE
%define APPEND(a,b) a %+ b
; SHA1_JOB* sha1_mb_mgr_flush_avx(SHA1_MB_JOB_MGR *state)
; arg 1 : rcx : state
mk_global sha1_mb_mgr_flush_avx, function
sha1_mb_mgr_flush_avx:
endbranch
sub rsp, STACK_SPACE
mov [rsp + _GPR_SAVE + 8*0], rbx
%ifidn __OUTPUT_FORMAT__, win64
mov [rsp + _GPR_SAVE + 8*1], rsi
vmovdqa [rsp + _XMM_SAVE + 16*0], xmm6
vmovdqa [rsp + _XMM_SAVE + 16*1], xmm7
vmovdqa [rsp + _XMM_SAVE + 16*2], xmm8
vmovdqa [rsp + _XMM_SAVE + 16*3], xmm9
vmovdqa [rsp + _XMM_SAVE + 16*4], xmm10
vmovdqa [rsp + _XMM_SAVE + 16*5], xmm11
vmovdqa [rsp + _XMM_SAVE + 16*6], xmm12
vmovdqa [rsp + _XMM_SAVE + 16*7], xmm13
vmovdqa [rsp + _XMM_SAVE + 16*8], xmm14
vmovdqa [rsp + _XMM_SAVE + 16*9], xmm15
%endif
; use num_lanes_inuse to judge all lanes are empty
cmp dword [state + _num_lanes_inuse], 0
jz return_null
; find a lane with a non-null job
xor idx, idx
cmp qword [state + _ldata + 1 * _LANE_DATA_size + _job_in_lane], 0
cmovne idx, [one]
cmp qword [state + _ldata + 2 * _LANE_DATA_size + _job_in_lane], 0
cmovne idx, [two]
cmp qword [state + _ldata + 3 * _LANE_DATA_size + _job_in_lane], 0
cmovne idx, [three]
; copy idx to empty lanes
copy_lane_data:
mov tmp, [state + _args + _data_ptr + 8*idx]
%assign I 0
%rep 4
cmp qword [state + _ldata + I * _LANE_DATA_size + _job_in_lane], 0
jne APPEND(skip_,I)
mov [state + _args + _data_ptr + 8*I], tmp
mov dword [state + _lens + 4*I], 0xFFFFFFFF
APPEND(skip_,I):
%assign I (I+1)
%endrep
; Find min length
mov DWORD(lens0), [state + _lens + 0*4]
mov idx, lens0
mov DWORD(lens1), [state + _lens + 1*4]
cmp lens1, idx
cmovb idx, lens1
mov DWORD(lens2), [state + _lens + 2*4]
cmp lens2, idx
cmovb idx, lens2
mov DWORD(lens3), [state + _lens + 3*4]
cmp lens3, idx
cmovb idx, lens3
mov len2, idx
and idx, 0xF
and len2, ~0xF
jz len_is_0
; compare with sha-sb threshold, if num_lanes_inuse <= threshold, using sb func
cmp dword [state + _num_lanes_inuse], SHA1_SB_THRESHOLD_AVX
ja mb_processing
; lensN-len2=idx
shr len2, 4
mov [state + _lens + idx*4], DWORD(idx)
mov r10, idx
or r10, 0x1000 ; avx has 4 lanes *4, r10b is idx, r10b2 is 16
; "state" and "args" are the same address, arg1
; len is arg2, idx and nlane in r10
call sha1_opt_x1
; state and idx are intact
jmp len_is_0
mb_processing:
sub lens0, len2
sub lens1, len2
sub lens2, len2
sub lens3, len2
shr len2, 4
mov [state + _lens + 0*4], DWORD(lens0)
mov [state + _lens + 1*4], DWORD(lens1)
mov [state + _lens + 2*4], DWORD(lens2)
mov [state + _lens + 3*4], DWORD(lens3)
; "state" and "args" are the same address, arg1
; len is arg2
call sha1_mb_x4_avx
; state and idx are intact
len_is_0:
; process completed job "idx"
imul lane_data, idx, _LANE_DATA_size
lea lane_data, [state + _ldata + lane_data]
mov job_rax, [lane_data + _job_in_lane]
mov qword [lane_data + _job_in_lane], 0
mov dword [job_rax + _status], STS_COMPLETED
mov unused_lanes, [state + _unused_lanes]
shl unused_lanes, 4
or unused_lanes, idx
mov [state + _unused_lanes], unused_lanes
sub dword [state + _num_lanes_inuse], 1
vmovd xmm0, [state + _args_digest + 4*idx + 0*16]
vpinsrd xmm0, [state + _args_digest + 4*idx + 1*16], 1
vpinsrd xmm0, [state + _args_digest + 4*idx + 2*16], 2
vpinsrd xmm0, [state + _args_digest + 4*idx + 3*16], 3
mov DWORD(tmp2), [state + _args_digest + 4*idx + 4*16]
vmovdqa [job_rax + _result_digest + 0*16], xmm0
mov [job_rax + _result_digest + 1*16], DWORD(tmp2)
return:
%ifidn __OUTPUT_FORMAT__, win64
vmovdqa xmm6, [rsp + _XMM_SAVE + 16*0]
vmovdqa xmm7, [rsp + _XMM_SAVE + 16*1]
vmovdqa xmm8, [rsp + _XMM_SAVE + 16*2]
vmovdqa xmm9, [rsp + _XMM_SAVE + 16*3]
vmovdqa xmm10, [rsp + _XMM_SAVE + 16*4]
vmovdqa xmm11, [rsp + _XMM_SAVE + 16*5]
vmovdqa xmm12, [rsp + _XMM_SAVE + 16*6]
vmovdqa xmm13, [rsp + _XMM_SAVE + 16*7]
vmovdqa xmm14, [rsp + _XMM_SAVE + 16*8]
vmovdqa xmm15, [rsp + _XMM_SAVE + 16*9]
mov rsi, [rsp + _GPR_SAVE + 8*1]
%endif
mov rbx, [rsp + _GPR_SAVE + 8*0]
add rsp, STACK_SPACE
ret
return_null:
xor job_rax, job_rax
jmp return
section .data align=16
align 16
one: dq 1
two: dq 2
three: dq 3
|
; A243283: One more than the partial sums of the characteristic function of A070003.
; 1,1,1,2,2,2,2,3,4,4,4,4,4,4,4,5,5,6,6,6,6,6,6,6,7,7,8,8,8,8,8,9,9,9,9,10,10,10,10,10,10,10,10,10,10,10,10,10,11,12,12,12,12,13,13,13,13,13,13,13,13,13,13,14,14,14,14,14,14,14,14,15,15,15,16,16,16,16,16,16,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,18,18,19
lpb $0
mov $2,$0
sub $0,1
seq $2,319988 ; a(n) = 1 if n is divisible by the square of its largest prime factor, 0 otherwise.
add $1,$2
lpe
add $1,1
mov $0,$1
|
; A129591: For each permutation p of {1,2,...,n} define min(p) = min{ p(i) + i : i = 1..n }; a(n) is the sum of min(p) of all p.
; Submitted by Christian Krause
; 2,5,17,75,407,2619,19487,164571,1555007,16252779,186167087,2319025851,31210884767,451319283339,6978220721807,114883713395931,2006375649873407,37048762422505899,721210940496319727,14761360406583900411,316901715602790903647,7120504270648900589259,167117286496864739776847,4089453358696977611038491,104163308788523064984055487,2757391661948915273187018219,75752124052759449623855541167,2156884403662305316741367226171,63570785787113531718977109584927,1937250645717222548483243573632779
add $0,1
mov $1,1
lpb $0
add $3,$1
mul $1,$0
cmp $3,$2
cmp $3,0
mul $3,$0
sub $0,1
add $4,1
pow $3,$4
add $1,$3
lpe
mov $0,$1
|
section .text
global is_isogram
is_isogram:
; Provide your implementation here
ret
|
; A052472: Number of independent components for a Weyl tensor in n dimensions.
; 0,10,35,84,168,300,495,770,1144,1638,2275,3080,4080,5304,6783,8550,10640,13090,15939,19228,23000,27300,32175,37674,43848,50750,58435,66960,76384,86768,98175,110670,124320,139194,155363,172900,191880,212380,234479,258258,283800,311190,340515,371864,405328,441000,478975,519350,562224,607698,655875,706860,760760,817684,877743,941050,1007720,1077870,1151619,1229088,1310400,1395680,1485055,1578654,1676608,1779050,1886115,1997940,2114664,2236428,2363375,2495650,2633400,2776774,2925923,3081000,3242160,3409560,3583359,3763718,3950800,4144770,4345795,4554044,4769688,4992900,5223855,5462730,5709704,5964958,6228675,6501040,6782240,7072464,7371903,7680750,7999200,8327450,8665699,9014148
mov $1,5
add $1,$0
bin $1,3
mul $1,$0
div $1,2
mov $0,$1
|
/*
* Copyright 2018 The Android Open Source Project
*
* 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 <algorithm>
#include <unistd.h>
#ifdef __ANDROID__
#include <audio_utils/primitives.h>
#endif
#include "AudioProcessorBase.h"
#include "SinkI16.h"
using namespace flowgraph;
SinkI16::SinkI16(int32_t channelCount)
: AudioSink(channelCount) {}
int32_t SinkI16::read(void *data, int32_t numFrames) {
int16_t *shortData = (int16_t *) data;
const int32_t channelCount = input.getSamplesPerFrame();
int32_t framesLeft = numFrames;
while (framesLeft > 0) {
// Run the graph and pull data through the input port.
int32_t framesRead = pull(framesLeft);
if (framesRead <= 0) {
break;
}
const float *signal = input.getBlock();
int32_t numSamples = framesRead * channelCount;
#ifdef __ANDROID__
memcpy_to_i16_from_float(shortData, signal, numSamples);
shortData += numSamples;
signal += numSamples;
#else
for (int i = 0; i < numSamples; i++) {
int32_t n = (int32_t) (*signal++ * 32768.0f);
*shortData++ = std::min(INT16_MAX, std::max(INT16_MIN, n)); // clip
}
#endif
framesLeft -= framesRead;
}
return numFrames - framesLeft;
}
|
/**
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/
#include <aws/workspaces-web/model/GetIdentityProviderResult.h>
#include <aws/core/utils/json/JsonSerializer.h>
#include <aws/core/AmazonWebServiceResult.h>
#include <aws/core/utils/StringUtils.h>
#include <aws/core/utils/UnreferencedParam.h>
#include <utility>
using namespace Aws::WorkSpacesWeb::Model;
using namespace Aws::Utils::Json;
using namespace Aws::Utils;
using namespace Aws;
GetIdentityProviderResult::GetIdentityProviderResult()
{
}
GetIdentityProviderResult::GetIdentityProviderResult(const Aws::AmazonWebServiceResult<JsonValue>& result)
{
*this = result;
}
GetIdentityProviderResult& GetIdentityProviderResult::operator =(const Aws::AmazonWebServiceResult<JsonValue>& result)
{
JsonView jsonValue = result.GetPayload().View();
if(jsonValue.ValueExists("identityProvider"))
{
m_identityProvider = jsonValue.GetObject("identityProvider");
}
return *this;
}
|
db DEX_MR_RIME ; pokedex id
db 80 ; base hp
db 85 ; base attack
db 75 ; base defense
db 70 ; base speed
db 110 ; base special
db PSYCHIC ; species type 1
db ICE ; species type 2
db 46 ; catch rate
db 136 ; base exp yield
INCBIN "pic/ymon/mrrime.pic",0,1 ; 66, sprite dimensions
dw MrRimePicFront
dw MrRimePicBack
; attacks known at lvl 0
db CONFUSION
db BARRIER
db ICE_BEAM
db 0
db 0 ; growth rate
; learnset
tmlearn 1,5,6,8
tmlearn 9,10,15
tmlearn 17,18,19,20,22,24
tmlearn 25,29,30,31,32
tmlearn 33,34,35,40
tmlearn 44,45,46
tmlearn 50,55
db BANK(MrRimePicFront)
|
#include "CDEHead.h"
// User Include Section
#include "Funcs.h"
// Data Section
static const CDE_data CDE_FUN_TestSplineLibrary[] =
{
_T("TestSplineLibrary"), // name
NULL,
1, // # of parameters
_T("TestSplineLibrary"), // function name
_T(""), // array size
CDE_INT, // return value type
};
static const CDE_data CDE_FUN_SplineHelix[] =
{
_T("SplineHelix"), // name
NULL,
1, // # of parameters
_T("SplineHelix"), // function name
_T(""), // array size
CDE_INT, // return value type
};
static const CDE_data *Data[] =
{
CDE_FUN_TestSplineLibrary,
CDE_FUN_SplineHelix,
};
// Function Section
static const CDE_code CDE_TestSplineLibrary =
{
_T("TestSplineLibrary"), // Function name
NULL, // (Not hidden)
NULL, // (No alias)
CDE_ANY, // Flags
CDE_FUN_TestSplineLibrary, // Parameter list
(int (*)())TestSplineLibrary, // Function Pointer
};
static const CDE_code CDE_SplineHelix =
{
_T("SplineHelix"), // Function name
NULL, // (Not hidden)
NULL, // (No alias)
CDE_ANY, // Flags
CDE_FUN_SplineHelix, // Parameter list
(int (*)())SplineHelix, // Function Pointer
};
static const CDE_code *Functions[] = {
&CDE_TestSplineLibrary,
&CDE_SplineHelix,
};
// App Section
// Popup Section
// Import Section
// Export Section
// Unassociated Section
// Classic Menu Section
// Main Section
extern "C" __declspec(dllexport) const CDE_module CDEMODS2_Funcs =
{
2, // Number of functions
Functions, // Function decl. section
2, // Number of data types
Data, // Data declaration section
0, // Number of Applications
NULL, // No Applications
0, // Number of Popups
NULL, // No Popups
0, // Number of Imports
NULL, // No Imports
0, // Number of Exports
NULL, // No Exports
0, // Number of Unassociated Functions
NULL, // No Unassociated Functions
0, // Number of Classic Menus
NULL, // No Classic Menus
NULL, // No Help File Name
NULL, // No Resource DLL Name
NULL, // No Product Name
};
|
.MODEL SMALL
.STACK 100H
.DATA
;variables
s db "ENTER THREE INITIALS: $"
.CODE
MAIN PROC
;initialize DS
MOV AX,@DATA
MOV DS,AX
; enter your code here
;Printing the prompt
lea dx, s
mov ah, 9
int 21h
;First intial input
mov ah,1
int 21h
mov bh , al
;Second intial input
mov ah,1
int 21h
mov bl , al
;Third intial input
mov ah,1
int 21h
mov cl, al
;Printing the initials in new lines
mov dl, 0ah
mov ah , 2
int 21h
mov dL,0dh
int 21h
mov dL,0ah
int 21h
mov dl,bh
mov ah,2
int 21h
mov dl, 0ah
mov ah , 2
int 21h
mov dL,0dh
int 21h
mov dL,0ah
int 21h
mov dl,bl
mov ah,2
int 21h
mov dl, 0ah
mov ah , 2
int 21h
mov dL,0dh
int 21h
mov dL,0ah
int 21h
mov dl,cl
mov ah,2
int 21h
;exit to DOS
MOV AX,4C00H
INT 21H
MAIN ENDP
END MAIN
|
set 6
add R1
cpy R3
|
; A001741: Squares written in base 6.
; 0,1,4,13,24,41,100,121,144,213,244,321,400,441,524,1013,1104,1201,1300,1401,1504,2013,2124,2241,2400,2521,3044,3213,3344,3521,4100,4241,4424,5013,5204,5401,10000,10201,10404,11013,11224,11441,12100,12321,12544,13213,13444,14121,14400,15041,15324,20013,20304,21001,21300,22001,22304,23013,23324,24041,24400,25121,25444,30213,30544,31321,32100,32441,33224,34013,34404,35201,40000,40401,41204,42013,42424,43241,44100,44521,45344,50213,51044,51521,52400,53241,54124,55013,55504,100401,101300,102201,103104,104013,104524,105441,110400,111321,112244,113213
pow $0,2
seq $0,7092 ; Numbers in base 6.
|
; A004201: Accept one, reject one, accept two, reject two, ...
; 1,3,4,7,8,9,13,14,15,16,21,22,23,24,25,31,32,33,34,35,36,43,44,45,46,47,48,49,57,58,59,60,61,62,63,64,73,74,75,76,77,78,79,80,81,91,92,93,94,95,96,97,98,99,100,111,112,113,114,115,116,117,118,119,120,121,133,134,135,136,137,138,139,140,141,142,143,144,157,158,159,160,161,162,163,164,165,166,167,168,169,183,184,185,186,187,188,189,190,191,192,193,194,195,196,211,212,213,214,215,216,217,218,219,220,221,222,223,224,225,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255,256,273,274,275,276,277,278,279,280,281,282,283,284,285,286,287,288,289,307,308,309,310,311,312,313,314,315,316,317,318,319,320,321,322,323,324,343,344,345,346,347,348,349,350,351,352,353,354,355,356,357,358,359,360,361,381,382,383,384,385,386,387,388,389,390,391,392,393,394,395,396,397,398,399,400,421,422,423,424,425,426,427,428,429,430,431,432,433,434,435,436,437,438,439,440,441,463,464,465,466,467,468,469,470,471,472,473,474,475,476,477,478,479,480,481
add $0,1
mov $1,$0
lpb $0
add $1,$2
add $2,1
trn $0,$2
lpe
|
// DlgOpacity.cpp : implementation file
//
#include "stdafx.h"
#include "demo.h"
#include "DlgOpacity.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// DlgOpacity dialog
DlgOpacity::DlgOpacity(CWnd* pParent /*=NULL*/)
: CDialog(DlgOpacity::IDD, pParent)
{
//{{AFX_DATA_INIT(DlgOpacity)
m_level = 0;
//}}AFX_DATA_INIT
}
void DlgOpacity::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(DlgOpacity)
DDX_Control(pDX, IDOK, m_ok);
DDX_Control(pDX, IDCANCEL, m_canc);
DDX_Text(pDX, IDC_EDIT1, m_level);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(DlgOpacity, CDialog)
//{{AFX_MSG_MAP(DlgOpacity)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// DlgOpacity message handlers
BOOL DlgOpacity::OnInitDialog()
{
CDialog::OnInitDialog();
m_ok.SetIcon(IDI_G,BS_LEFT);
m_canc.SetIcon(IDI_R,BS_LEFT);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
|
; A001341: E.g.f.: 6*exp(x)/(1-x)^4;
; Submitted by Christian Krause
; 6,30,174,1158,8742,74046,696750,7219974,81762438,1005151902,13336264686,189992451270,2893180308774,46904155833918,806663460996462,14669947577257926,281298999630211590,5672559830998316574,120014233288249367598,2658221288671765756422,61517040495645640169766,1484761586617705689115710,37311943401651789473443374,974757716939008790622425478,26435041376054254979538715782,743222014699037183431684546206,21635784406569759128462068491630,651385544221487566213100325039174
add $0,1
mov $2,$0
mov $3,1
lpb $0
sub $0,1
add $2,$3
add $3,$2
mul $2,$0
add $2,$3
lpe
mul $3,2
mov $0,$3
|
/**Kattis - walkway
* Simple-ish Dijkstra problem, use map rather than vector, and we calculate the edge weights using geometry.
*
* Time: O(E log V), Space: O(V + E)
*/
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
int e;
map<int, vector<pair<int, ld>>> adjlist;
map<int, ld> dist;
priority_queue<tuple<ld, int>, vector<tuple<ld, int>>, greater<tuple<ld, int>>> pq;
int main() {
cout << fixed << setprecision(2) << endl;
while (true) {
cin >> e;
if (e == 0) break;
adjlist.clear();
dist.clear();
int a, b, h;
for (int i = 0; i < e; i++) {
cin >> a >> b >> h;
ld surface_area = (a + b) * h / 2;
adjlist[a].push_back({b, surface_area * 0.02});
adjlist[b].push_back({a, surface_area * 0.02});
}
int source, dest;
cin >> source >> dest;
while (!pq.empty()) pq.pop();
dist[source] = 0;
pq.emplace(0, source);
while (!pq.empty()) {
auto [d, u] = pq.top();
pq.pop();
if (u == dest) break;
if (d > dist[u]) continue; // inferior pair
for (auto &[v, w] : adjlist[u]) {
if (dist.count(v) && dist[u] + w >= dist[v]) continue; // relaxing through this node doesn't help
dist[v] = dist[u] + w;
pq.emplace(dist[v], v);
}
}
cout << dist[dest] << endl;
}
return 0;
} |
;;
;; 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 "os.asm"
%include "job_aes_hmac.asm"
%include "mb_mgr_datastruct.asm"
%include "reg_sizes.asm"
%include "memcpy.asm"
%include "const.inc"
extern sha512_x2_avx
section .data
default rel
align 16
byteswap: ;ddq 0x08090a0b0c0d0e0f0001020304050607
dq 0x0001020304050607, 0x08090a0b0c0d0e0f
section .text
%ifndef FUNC
%define FUNC submit_job_hmac_sha_512_avx
%define SHA_X_DIGEST_SIZE 512
%endif
%if 1
%ifdef LINUX
%define arg1 rdi
%define arg2 rsi
%define reg3 rcx
%define reg4 rdx
%else
%define arg1 rcx
%define arg2 rdx
%define reg3 rdi
%define reg4 rsi
%endif
%define state arg1
%define job arg2
%define len2 arg2
; idx needs to be in rbx, rbp, r12-r15
%define last_len rbp
%define idx rbp
%define p r11
%define start_offset r11
%define unused_lanes rbx
%define tmp4 rbx
%define job_rax rax
%define len rax
%define size_offset reg3
%define tmp2 reg3
%define lane reg4
%define tmp3 reg4
%define extra_blocks r8
%define tmp r9
%define p2 r9
%define lane_data r10
%endif
; This routine clobbers rbx, rbp, rsi, rdi
struc STACK
_gpr_save: resq 4
_rsp_save: resq 1
endstruc
; JOB* FUNC(MB_MGR_HMAC_sha_512_OOO *state, JOB_AES_HMAC *job)
; arg 1 : rcx : state
; arg 2 : rdx : job
MKGLOBAL(FUNC,function,internal)
FUNC:
mov rax, rsp
sub rsp, STACK_size
and rsp, -16
mov [rsp + _gpr_save + 8*0], rbx
mov [rsp + _gpr_save + 8*1], rbp
%ifndef LINUX
mov [rsp + _gpr_save + 8*2], rsi
mov [rsp + _gpr_save + 8*3], rdi
%endif
mov [rsp + _rsp_save], rax ; original SP
mov unused_lanes, [state + _unused_lanes_sha512]
movzx lane, BYTE(unused_lanes)
shr unused_lanes, 8
imul lane_data, lane, _SHA512_LANE_DATA_size
lea lane_data, [state + _ldata_sha512 + lane_data]
mov [state + _unused_lanes_sha512], unused_lanes
mov len, [job + _msg_len_to_hash_in_bytes]
mov tmp, len
shr tmp, 7 ; divide by 128, len in terms of blocks
mov [lane_data + _job_in_lane_sha512], job
mov dword [lane_data + _outer_done_sha512], 0
vmovdqa xmm0, [state + _lens_sha512]
XVPINSRW xmm0, xmm1, p, lane, tmp, scale_x16
vmovdqa [state + _lens_sha512], xmm0
mov last_len, len
and last_len, 127
lea extra_blocks, [last_len + 17 + 127]
shr extra_blocks, 7
mov [lane_data + _extra_blocks_sha512], DWORD(extra_blocks)
mov p, [job + _src]
add p, [job + _hash_start_src_offset_in_bytes]
mov [state + _args_data_ptr_sha512 + PTR_SZ*lane], p
cmp len, 128
jb copy_lt128
fast_copy:
add p, len
%assign I 0
%rep 2
vmovdqu xmm0, [p - 128 + I*4*16 + 0*16]
vmovdqu xmm1, [p - 128 + I*4*16 + 1*16]
vmovdqu xmm2, [p - 128 + I*4*16 + 2*16]
vmovdqu xmm3, [p - 128 + I*4*16 + 3*16]
vmovdqa [lane_data + _extra_block_sha512 + I*4*16 + 0*16], xmm0
vmovdqa [lane_data + _extra_block_sha512 + I*4*16 + 1*16], xmm1
vmovdqa [lane_data + _extra_block_sha512 + I*4*16 + 2*16], xmm2
vmovdqa [lane_data + _extra_block_sha512 + I*4*16 + 3*16], xmm3
%assign I (I+1)
%endrep
end_fast_copy:
mov size_offset, extra_blocks
shl size_offset, 7
sub size_offset, last_len
add size_offset, 128-8
mov [lane_data + _size_offset_sha512], DWORD(size_offset)
mov start_offset, 128
sub start_offset, last_len
mov [lane_data + _start_offset_sha512], DWORD(start_offset)
lea tmp, [8*128 + 8*len]
bswap tmp
mov [lane_data + _extra_block_sha512 + size_offset], tmp
mov tmp, [job + _auth_key_xor_ipad]
%assign I 0
%rep 4
vmovdqu xmm0, [tmp + I * 2 * 8]
vmovq [state + _args_digest_sha512 + SHA512_DIGEST_WORD_SIZE*lane + (2*I)*SHA512_DIGEST_ROW_SIZE], xmm0
vpextrq [state + _args_digest_sha512 + SHA512_DIGEST_WORD_SIZE*lane + (2*I + 1)*SHA512_DIGEST_ROW_SIZE], xmm0, 1
%assign I (I+1)
%endrep
test len, ~127
jnz ge128_bytes
lt128_bytes:
vmovdqa xmm0, [state + _lens_sha512]
XVPINSRW xmm0, xmm1, tmp, lane, extra_blocks, scale_x16
vmovdqa [state + _lens_sha512], xmm0
lea tmp, [lane_data + _extra_block_sha512 + start_offset]
mov [state + _args_data_ptr_sha512 + PTR_SZ*lane], tmp ;; 8 to hold a UINT8
mov dword [lane_data + _extra_blocks_sha512], 0
ge128_bytes:
cmp unused_lanes, 0xff
jne return_null
jmp start_loop
align 16
start_loop:
; Find min length
vmovdqa xmm0, [state + _lens_sha512]
vphminposuw xmm1, xmm0
vpextrw DWORD(len2), xmm1, 0 ; min value
vpextrw DWORD(idx), xmm1, 1 ; min index (0...1)
cmp len2, 0
je len_is_0
vpshuflw xmm1, xmm1, 0xA0
vpsubw xmm0, xmm0, xmm1
vmovdqa [state + _lens_sha512], xmm0
; "state" and "args" are the same address, arg1
; len is arg2
call sha512_x2_avx
; state and idx are intact
len_is_0:
; process completed job "idx"
imul lane_data, idx, _SHA512_LANE_DATA_size
lea lane_data, [state + _ldata_sha512 + lane_data]
mov DWORD(extra_blocks), [lane_data + _extra_blocks_sha512]
cmp extra_blocks, 0
jne proc_extra_blocks
cmp dword [lane_data + _outer_done_sha512], 0
jne end_loop
proc_outer:
mov dword [lane_data + _outer_done_sha512], 1
mov DWORD(size_offset), [lane_data + _size_offset_sha512]
mov qword [lane_data + _extra_block_sha512 + size_offset], 0
vmovdqa xmm0, [state + _lens_sha512]
XVPINSRW xmm0, xmm1, tmp, idx, 1, scale_x16
vmovdqa [state + _lens_sha512], xmm0
lea tmp, [lane_data + _outer_block_sha512]
mov job, [lane_data + _job_in_lane_sha512]
mov [state + _args_data_ptr_sha512 + PTR_SZ*idx], tmp
%assign I 0
%rep (SHA_X_DIGEST_SIZE / (8 * 16))
vmovq xmm0, [state + _args_digest_sha512 + SHA512_DIGEST_WORD_SIZE*idx + 2*I*SHA512_DIGEST_ROW_SIZE]
vpinsrq xmm0, [state + _args_digest_sha512 + SHA512_DIGEST_WORD_SIZE*idx + (2*I + 1)*SHA512_DIGEST_ROW_SIZE], 1
vpshufb xmm0, [rel byteswap]
vmovdqa [lane_data + _outer_block_sha512 + I * 16], xmm0
%assign I (I+1)
%endrep
mov tmp, [job + _auth_key_xor_opad]
%assign I 0
%rep 4
vmovdqu xmm0, [tmp + I * 16]
vmovq [state + _args_digest_sha512 + SHA512_DIGEST_WORD_SIZE*idx + 2*I*SHA512_DIGEST_ROW_SIZE], xmm0
vpextrq [state + _args_digest_sha512 + SHA512_DIGEST_WORD_SIZE*idx + (2*I + 1)*SHA512_DIGEST_ROW_SIZE], xmm0, 1
%assign I (I+1)
%endrep
jmp start_loop
align 16
proc_extra_blocks:
mov DWORD(start_offset), [lane_data + _start_offset_sha512]
vmovdqa xmm0, [state + _lens_sha512]
XVPINSRW xmm0, xmm1, tmp, idx, extra_blocks, scale_x16
vmovdqa [state + _lens_sha512], xmm0
lea tmp, [lane_data + _extra_block_sha512 + start_offset]
mov [state + _args_data_ptr_sha512 + PTR_SZ*idx], tmp ;; idx is index of shortest length message
mov dword [lane_data + _extra_blocks_sha512], 0
jmp start_loop
align 16
copy_lt128:
;; less than one message block of data
;; destination extra block but backwards by len from where 0x80 pre-populated
lea p2, [lane_data + _extra_block + 128]
sub p2, len
memcpy_avx_128_1 p2, p, len, tmp4, tmp2, xmm0, xmm1, xmm2, xmm3
mov unused_lanes, [state + _unused_lanes_sha512]
jmp end_fast_copy
return_null:
xor job_rax, job_rax
jmp return
align 16
end_loop:
mov job_rax, [lane_data + _job_in_lane_sha512]
mov unused_lanes, [state + _unused_lanes_sha512]
mov qword [lane_data + _job_in_lane_sha512], 0
or dword [job_rax + _status], STS_COMPLETED_HMAC
shl unused_lanes, 8
or unused_lanes, idx
mov [state + _unused_lanes_sha512], unused_lanes
mov p, [job_rax + _auth_tag_output]
%if (SHA_X_DIGEST_SIZE != 384)
cmp qword [job_rax + _auth_tag_output_len_in_bytes], 32
jne copy_full_digest
%else
cmp qword [job_rax + _auth_tag_output_len_in_bytes], 24
jne copy_full_digest
%endif
;; copy 32 bytes for SHA512 / 24 bytes and SHA384
mov QWORD(tmp), [state + _args_digest_sha512 + SHA512_DIGEST_WORD_SIZE*idx + 0*SHA512_DIGEST_ROW_SIZE]
mov QWORD(tmp2), [state + _args_digest_sha512 + SHA512_DIGEST_WORD_SIZE*idx + 1*SHA512_DIGEST_ROW_SIZE]
mov QWORD(tmp3), [state + _args_digest_sha512 + SHA512_DIGEST_WORD_SIZE*idx + 2*SHA512_DIGEST_ROW_SIZE]
%if (SHA_X_DIGEST_SIZE != 384)
mov QWORD(tmp4), [state + _args_digest_sha512 + SHA512_DIGEST_WORD_SIZE*idx + 3*SHA512_DIGEST_ROW_SIZE]
%endif
bswap QWORD(tmp)
bswap QWORD(tmp2)
bswap QWORD(tmp3)
%if (SHA_X_DIGEST_SIZE != 384)
bswap QWORD(tmp4)
%endif
mov [p + 0*8], QWORD(tmp)
mov [p + 1*8], QWORD(tmp2)
mov [p + 2*8], QWORD(tmp3)
%if (SHA_X_DIGEST_SIZE != 384)
mov [p + 3*8], QWORD(tmp4)
%endif
jmp return
copy_full_digest:
;; copy 64 bytes for SHA512 / 48 bytes and SHA384
mov QWORD(tmp), [state + _args_digest_sha512 + SHA512_DIGEST_WORD_SIZE*idx + 0*SHA512_DIGEST_ROW_SIZE]
mov QWORD(tmp2), [state + _args_digest_sha512 + SHA512_DIGEST_WORD_SIZE*idx + 1*SHA512_DIGEST_ROW_SIZE]
mov QWORD(tmp3), [state + _args_digest_sha512 + SHA512_DIGEST_WORD_SIZE*idx + 2*SHA512_DIGEST_ROW_SIZE]
mov QWORD(tmp4), [state + _args_digest_sha512 + SHA512_DIGEST_WORD_SIZE*idx + 3*SHA512_DIGEST_ROW_SIZE]
bswap QWORD(tmp)
bswap QWORD(tmp2)
bswap QWORD(tmp3)
bswap QWORD(tmp4)
mov [p + 0*8], QWORD(tmp)
mov [p + 1*8], QWORD(tmp2)
mov [p + 2*8], QWORD(tmp3)
mov [p + 3*8], QWORD(tmp4)
mov QWORD(tmp), [state + _args_digest_sha512 + SHA512_DIGEST_WORD_SIZE*idx + 4*SHA512_DIGEST_ROW_SIZE]
mov QWORD(tmp2), [state + _args_digest_sha512 + SHA512_DIGEST_WORD_SIZE*idx + 5*SHA512_DIGEST_ROW_SIZE]
%if (SHA_X_DIGEST_SIZE != 384)
mov QWORD(tmp3), [state + _args_digest_sha512 + SHA512_DIGEST_WORD_SIZE*idx + 6*SHA512_DIGEST_ROW_SIZE]
mov QWORD(tmp4), [state + _args_digest_sha512 + SHA512_DIGEST_WORD_SIZE*idx + 7*SHA512_DIGEST_ROW_SIZE]
%endif
bswap QWORD(tmp)
bswap QWORD(tmp2)
%if (SHA_X_DIGEST_SIZE != 384)
bswap QWORD(tmp3)
bswap QWORD(tmp4)
%endif
mov [p + 4*8], QWORD(tmp)
mov [p + 5*8], QWORD(tmp2)
%if (SHA_X_DIGEST_SIZE != 384)
mov [p + 6*8], QWORD(tmp3)
mov [p + 7*8], QWORD(tmp4)
%endif
return:
mov rbx, [rsp + _gpr_save + 8*0]
mov rbp, [rsp + _gpr_save + 8*1]
%ifndef LINUX
mov rsi, [rsp + _gpr_save + 8*2]
mov rdi, [rsp + _gpr_save + 8*3]
%endif
mov rsp, [rsp + _rsp_save] ; original SP
ret
%ifdef LINUX
section .note.GNU-stack noalloc noexec nowrite progbits
%endif
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.